Merge with /pub/scm/linux/kernel/git/torvalds/linux-2.6.git
authorSteve French <sfrench@us.ibm.com>
Tue, 6 Sep 2005 22:47:31 +0000 (15:47 -0700)
committerSteve French <sfrench@us.ibm.com>
Tue, 6 Sep 2005 22:47:31 +0000 (15:47 -0700)
1339 files changed:
Documentation/crypto/api-intro.txt
Documentation/feature-removal-schedule.txt
Documentation/filesystems/proc.txt
Documentation/filesystems/sysfs.txt
Documentation/hwmon/lm78
Documentation/hwmon/w83792d [new file with mode: 0644]
Documentation/i2c/chips/max6875
Documentation/i2c/functionality
Documentation/i2c/porting-clients
Documentation/i2c/writing-clients
Documentation/kbuild/makefiles.txt
Documentation/networking/README.ipw2100 [new file with mode: 0644]
Documentation/networking/README.ipw2200 [new file with mode: 0644]
Documentation/power/swsusp-dmcrypt.txt [new file with mode: 0644]
Documentation/power/swsusp.txt
Documentation/power/video.txt
Documentation/serial/driver
Documentation/vm/locking
Documentation/watchdog/watchdog-api.txt
MAINTAINERS
Makefile
arch/arm/Kconfig
arch/arm/common/gic.c
arch/arm/common/locomo.c
arch/arm/common/sa1111.c
arch/arm/common/scoop.c
arch/arm/kernel/calls.S
arch/arm/kernel/ecard.c
arch/arm/kernel/entry-common.S
arch/arm/kernel/irq.c
arch/arm/kernel/smp.c
arch/arm/kernel/sys_arm.c
arch/arm/kernel/time.c
arch/arm/mach-footbridge/isa-irq.c
arch/arm/mach-h720x/common.c
arch/arm/mach-h720x/cpu-h7202.c
arch/arm/mach-imx/irq.c
arch/arm/mach-integrator/integrator_cp.c
arch/arm/mach-ixp2000/core.c
arch/arm/mach-ixp2000/ixdp2x00.c
arch/arm/mach-ixp2000/ixdp2x01.c
arch/arm/mach-ixp4xx/common.c
arch/arm/mach-ixp4xx/coyote-pci.c
arch/arm/mach-ixp4xx/coyote-setup.c
arch/arm/mach-ixp4xx/gtwx5715-pci.c
arch/arm/mach-ixp4xx/gtwx5715-setup.c
arch/arm/mach-ixp4xx/ixdp425-pci.c
arch/arm/mach-ixp4xx/ixdp425-setup.c
arch/arm/mach-ixp4xx/ixdpg425-pci.c
arch/arm/mach-lh7a40x/common.h
arch/arm/mach-omap1/fpga.c
arch/arm/mach-pxa/corgi.c
arch/arm/mach-pxa/irq.c
arch/arm/mach-pxa/lubbock.c
arch/arm/mach-pxa/mainstone.c
arch/arm/mach-pxa/poodle.c
arch/arm/mach-pxa/time.c
arch/arm/mach-s3c2410/bast-irq.c
arch/arm/mach-s3c2410/clock.c
arch/arm/mach-s3c2410/irq.c
arch/arm/mach-s3c2410/mach-n30.c
arch/arm/mach-s3c2410/pm.c
arch/arm/mach-s3c2410/s3c2440-clock.c
arch/arm/mach-s3c2410/s3c2440-irq.c
arch/arm/mach-sa1100/irq.c
arch/arm/mach-sa1100/neponset.c
arch/arm/mach-sa1100/time.c
arch/arm/mach-versatile/core.c
arch/arm/mm/alignment.c
arch/arm/mm/mm-armv.c
arch/arm/mm/proc-arm6_7.S
arch/arm/plat-omap/gpio.c
arch/cris/Kconfig.debug
arch/frv/kernel/frv_ksyms.c
arch/i386/Kconfig
arch/i386/kernel/Makefile
arch/i386/kernel/acpi/boot.c
arch/i386/kernel/cpu/common.c
arch/i386/kernel/cpu/cpufreq/longhaul.c
arch/i386/kernel/cpu/cyrix.c
arch/i386/kernel/cpu/intel.c
arch/i386/kernel/cpu/intel_cacheinfo.c
arch/i386/kernel/cpu/mtrr/main.c
arch/i386/kernel/crash.c
arch/i386/kernel/doublefault.c
arch/i386/kernel/efi.c
arch/i386/kernel/entry.S
arch/i386/kernel/head.S
arch/i386/kernel/i8237.c [new file with mode: 0644]
arch/i386/kernel/ioport.c
arch/i386/kernel/ldt.c
arch/i386/kernel/machine_kexec.c
arch/i386/kernel/microcode.c
arch/i386/kernel/mpparse.c
arch/i386/kernel/msr.c
arch/i386/kernel/nmi.c
arch/i386/kernel/process.c
arch/i386/kernel/ptrace.c
arch/i386/kernel/reboot.c
arch/i386/kernel/semaphore.c
arch/i386/kernel/setup.c
arch/i386/kernel/signal.c
arch/i386/kernel/smp.c
arch/i386/kernel/smpboot.c
arch/i386/kernel/time.c
arch/i386/kernel/timers/timer_hpet.c
arch/i386/kernel/timers/timer_pit.c
arch/i386/kernel/timers/timer_pm.c
arch/i386/kernel/timers/timer_tsc.c
arch/i386/kernel/traps.c
arch/i386/kernel/vm86.c
arch/i386/kernel/vsyscall-sigreturn.S
arch/i386/mach-es7000/es7000.h
arch/i386/mach-es7000/es7000plat.c
arch/i386/mach-generic/bigsmp.c
arch/i386/mach-generic/probe.c
arch/i386/mach-voyager/voyager_basic.c
arch/i386/mach-voyager/voyager_smp.c
arch/i386/math-emu/get_address.c
arch/i386/mm/fault.c
arch/i386/mm/hugetlbpage.c
arch/i386/mm/init.c
arch/i386/mm/pageattr.c
arch/i386/mm/pgtable.c
arch/i386/power/cpu.c
arch/ia64/Kconfig
arch/ia64/hp/sim/boot/fw-emu.c
arch/ia64/ia32/ia32_signal.c
arch/ia64/kernel/Makefile
arch/ia64/kernel/cpufreq/Kconfig [new file with mode: 0644]
arch/ia64/kernel/cpufreq/Makefile [new file with mode: 0644]
arch/ia64/kernel/cpufreq/acpi-cpufreq.c [new file with mode: 0644]
arch/ia64/kernel/sys_ia64.c
arch/ia64/kernel/uncached.c
arch/ia64/lib/Makefile
arch/ia64/lib/swiotlb.c
arch/ia64/mm/hugetlbpage.c
arch/ia64/pci/pci.c
arch/ia64/sn/include/tio.h
arch/ia64/sn/include/xtalk/hubdev.h
arch/ia64/sn/kernel/bte.c
arch/ia64/sn/kernel/huberror.c
arch/ia64/sn/kernel/io_init.c
arch/ia64/sn/kernel/irq.c
arch/ia64/sn/kernel/setup.c
arch/ia64/sn/kernel/sn2/ptc_deadlock.S
arch/ia64/sn/kernel/sn2/sn2_smp.c
arch/ia64/sn/kernel/sn2/sn_hwperf.c
arch/ia64/sn/kernel/sn2/sn_proc_fs.c
arch/ia64/sn/kernel/sn2/timer_interrupt.c
arch/ia64/sn/pci/Makefile
arch/ia64/sn/pci/pcibr/pcibr_dma.c
arch/ia64/sn/pci/pcibr/pcibr_provider.c
arch/ia64/sn/pci/tioca_provider.c
arch/ia64/sn/pci/tioce_provider.c [new file with mode: 0644]
arch/m68k/kernel/m68k_ksyms.c
arch/m68k/kernel/ptrace.c
arch/m68k/lib/Makefile
arch/m68k/lib/memcmp.c [deleted file]
arch/m68k/lib/memcpy.c [deleted file]
arch/m68k/lib/memset.c [deleted file]
arch/m68k/lib/string.c [new file with mode: 0644]
arch/m68k/mm/Makefile
arch/m68k/mm/cache.c [new file with mode: 0644]
arch/m68k/mm/memory.c
arch/m68knommu/Kconfig
arch/m68knommu/Makefile
arch/m68knommu/defconfig
arch/m68knommu/kernel/setup.c
arch/m68knommu/kernel/traps.c
arch/m68knommu/kernel/vmlinux.lds.S
arch/m68knommu/platform/523x/config.c [new file with mode: 0644]
arch/m68knommu/platform/5307/head.S
arch/m68knommu/platform/68328/entry.S
arch/m68knommu/platform/68360/entry.S
arch/mips/Kconfig
arch/mips/Makefile
arch/mips/au1000/common/pci.c
arch/mips/au1000/common/setup.c
arch/mips/au1000/common/time.c
arch/mips/au1000/csb250/board_setup.c
arch/mips/au1000/csb250/init.c
arch/mips/au1000/db1x00/init.c
arch/mips/au1000/hydrogen3/init.c
arch/mips/au1000/pb1000/board_setup.c
arch/mips/au1000/xxs1500/board_setup.c
arch/mips/au1000/xxs1500/init.c
arch/mips/au1000/xxs1500/irqmap.c
arch/mips/configs/atlas_defconfig
arch/mips/configs/capcella_defconfig
arch/mips/configs/cobalt_defconfig
arch/mips/configs/db1000_defconfig
arch/mips/configs/db1100_defconfig
arch/mips/configs/db1500_defconfig
arch/mips/configs/db1550_defconfig
arch/mips/configs/ddb5476_defconfig
arch/mips/configs/ddb5477_defconfig
arch/mips/configs/decstation_defconfig
arch/mips/configs/e55_defconfig
arch/mips/configs/ev64120_defconfig
arch/mips/configs/ev96100_defconfig
arch/mips/configs/ip22_defconfig
arch/mips/configs/ip27_defconfig
arch/mips/configs/ip32_defconfig
arch/mips/configs/it8172_defconfig
arch/mips/configs/ivr_defconfig
arch/mips/configs/jaguar-atx_defconfig
arch/mips/configs/jmr3927_defconfig
arch/mips/configs/lasat200_defconfig
arch/mips/configs/malta_defconfig
arch/mips/configs/mpc30x_defconfig
arch/mips/configs/ocelot_3_defconfig
arch/mips/configs/ocelot_c_defconfig
arch/mips/configs/ocelot_defconfig
arch/mips/configs/ocelot_g_defconfig
arch/mips/configs/pb1100_defconfig
arch/mips/configs/pb1500_defconfig
arch/mips/configs/pb1550_defconfig
arch/mips/configs/qemu_defconfig [moved from arch/mips/configs/osprey_defconfig with 66% similarity]
arch/mips/configs/rm200_defconfig
arch/mips/configs/sb1250-swarm_defconfig
arch/mips/configs/sead_defconfig
arch/mips/configs/tb0226_defconfig
arch/mips/configs/tb0229_defconfig
arch/mips/configs/workpad_defconfig
arch/mips/configs/yosemite_defconfig
arch/mips/ddb5xxx/ddb5477/irq.c
arch/mips/ddb5xxx/ddb5477/setup.c
arch/mips/dec/ecc-berr.c
arch/mips/dec/int-handler.S
arch/mips/dec/prom/Makefile
arch/mips/defconfig
arch/mips/ite-boards/generic/it8172_setup.c
arch/mips/ite-boards/generic/time.c
arch/mips/kernel/Makefile
arch/mips/kernel/binfmt_elfn32.c
arch/mips/kernel/binfmt_elfo32.c
arch/mips/kernel/cpu-bugs64.c
arch/mips/kernel/cpu-probe.c
arch/mips/kernel/gdb-low.S
arch/mips/kernel/gdb-stub.c
arch/mips/kernel/genex.S
arch/mips/kernel/head.S
arch/mips/kernel/ioctl32.c
arch/mips/kernel/irq.c
arch/mips/kernel/linux32.c
arch/mips/kernel/mips_ksyms.c
arch/mips/kernel/process.c
arch/mips/kernel/ptrace.c
arch/mips/kernel/r2300_switch.S
arch/mips/kernel/r4k_fpu.S
arch/mips/kernel/r4k_switch.S
arch/mips/kernel/setup.c
arch/mips/kernel/signal32.c
arch/mips/kernel/traps.c
arch/mips/kernel/unaligned.c
arch/mips/kernel/vmlinux.lds.S
arch/mips/lasat/at93c.c
arch/mips/lasat/at93c.h
arch/mips/lasat/ds1603.c
arch/mips/lasat/ds1603.h
arch/mips/lasat/image/Makefile
arch/mips/lasat/image/head.S
arch/mips/lasat/interrupt.c
arch/mips/lasat/lasat_board.c
arch/mips/lasat/picvue.c
arch/mips/lasat/picvue.h
arch/mips/lasat/picvue_proc.c
arch/mips/lasat/prom.c
arch/mips/lasat/reset.c
arch/mips/lasat/setup.c
arch/mips/lasat/sysctl.c
arch/mips/lib-32/Makefile
arch/mips/lib-64/Makefile
arch/mips/lib/memcpy.S
arch/mips/math-emu/cp1emu.c
arch/mips/math-emu/kernel_linkage.c
arch/mips/mips-boards/atlas/atlas_int.c
arch/mips/mips-boards/generic/init.c
arch/mips/mips-boards/generic/time.c
arch/mips/mips-boards/malta/malta_setup.c
arch/mips/mm/Makefile
arch/mips/mm/c-r4k.c
arch/mips/mm/c-sb1.c
arch/mips/mm/cerr-sb1.c
arch/mips/mm/dma-noncoherent.c
arch/mips/mm/init.c
arch/mips/mm/pg-sb1.c
arch/mips/mm/tlbex.c
arch/mips/momentum/jaguar_atx/int-handler.S
arch/mips/momentum/jaguar_atx/prom.c
arch/mips/momentum/jaguar_atx/reset.c
arch/mips/momentum/jaguar_atx/setup.c
arch/mips/momentum/ocelot_3/prom.c
arch/mips/momentum/ocelot_c/int-handler.S
arch/mips/momentum/ocelot_c/ocelot_c_fpga.h
arch/mips/momentum/ocelot_c/prom.c
arch/mips/momentum/ocelot_c/reset.c
arch/mips/momentum/ocelot_c/setup.c
arch/mips/pci/fixup-ddb5074.c
arch/mips/pci/fixup-ddb5477.c
arch/mips/pci/fixup-malta.c
arch/mips/pci/fixup-rbtx4927.c
arch/mips/pci/fixup-sni.c
arch/mips/pci/fixup-tb0219.c
arch/mips/pci/ops-ddb5477.c
arch/mips/pci/ops-tx4927.c
arch/mips/pci/pci-ddb5477.c
arch/mips/pci/pci-ip32.c
arch/mips/pci/pci.c
arch/mips/pmc-sierra/yosemite/atmel_read_eeprom.c
arch/mips/pmc-sierra/yosemite/atmel_read_eeprom.h
arch/mips/qemu/Makefile [new file with mode: 0644]
arch/mips/qemu/q-firmware.c [new file with mode: 0644]
arch/mips/qemu/q-int.S [new file with mode: 0644]
arch/mips/qemu/q-irq.c [new file with mode: 0644]
arch/mips/qemu/q-mem.c [new file with mode: 0644]
arch/mips/qemu/q-setup.c [new file with mode: 0644]
arch/mips/sgi-ip22/ip22-eisa.c
arch/mips/sgi-ip22/ip22-hpc.c
arch/mips/sgi-ip22/ip22-int.c
arch/mips/sgi-ip22/ip22-nvram.c
arch/mips/sgi-ip22/ip22-reset.c
arch/mips/sgi-ip22/ip22-time.c
arch/mips/sgi-ip27/ip27-memory.c
arch/mips/sgi-ip32/ip32-reset.c
arch/mips/sibyte/cfe/cfe_error.h
arch/mips/sibyte/cfe/console.c
arch/mips/sibyte/cfe/setup.c
arch/mips/sibyte/cfe/smp.c
arch/mips/sibyte/sb1250/bus_watcher.c
arch/mips/sibyte/sb1250/irq.c
arch/mips/sibyte/swarm/rtc_m41t81.c
arch/mips/sibyte/swarm/setup.c
arch/mips/sni/irq.c
arch/mips/sni/setup.c
arch/mips/tx4927/common/tx4927_irq_handler.S
arch/mips/tx4927/common/tx4927_setup.c
arch/mips/tx4927/toshiba_rbtx4927/Makefile
arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
arch/mips/vr4181/common/Makefile [deleted file]
arch/mips/vr4181/common/int_handler.S [deleted file]
arch/mips/vr4181/common/irq.c [deleted file]
arch/mips/vr4181/common/serial.c [deleted file]
arch/mips/vr4181/common/time.c [deleted file]
arch/mips/vr4181/osprey/Makefile [deleted file]
arch/mips/vr4181/osprey/dbg_io.c [deleted file]
arch/mips/vr4181/osprey/prom.c [deleted file]
arch/mips/vr4181/osprey/reset.c [deleted file]
arch/mips/vr4181/osprey/setup.c [deleted file]
arch/mips/vr41xx/casio-e55/setup.c
arch/mips/vr41xx/common/Makefile
arch/mips/vr41xx/common/icu.c
arch/mips/vr41xx/common/int-handler.S
arch/mips/vr41xx/common/irq.c [new file with mode: 0644]
arch/mips/vr41xx/common/type.c [moved from arch/mips/vr41xx/tanbac-tb0226/setup.c with 85% similarity]
arch/mips/vr41xx/common/vrc4173.c
arch/mips/vr41xx/ibm-workpad/setup.c
arch/mips/vr41xx/nec-cmbvr4133/init.c
arch/mips/vr41xx/tanbac-tb0226/Makefile [deleted file]
arch/mips/vr41xx/tanbac-tb0229/Makefile [deleted file]
arch/mips/vr41xx/tanbac-tb0229/setup.c [deleted file]
arch/mips/vr41xx/victor-mpc30x/Makefile [deleted file]
arch/mips/vr41xx/victor-mpc30x/setup.c [deleted file]
arch/mips/vr41xx/zao-capcella/Makefile [deleted file]
arch/mips/vr41xx/zao-capcella/setup.c [deleted file]
arch/ppc/Kconfig
arch/ppc/Kconfig.debug
arch/ppc/boot/simple/Makefile
arch/ppc/boot/simple/embed_config.c
arch/ppc/boot/simple/head.S
arch/ppc/boot/simple/misc-cpci690.c
arch/ppc/boot/simple/misc-ev64360.c [new file with mode: 0644]
arch/ppc/boot/simple/misc-katana.c
arch/ppc/boot/simple/misc-mv64x60.c
arch/ppc/boot/simple/mv64x60_tty.c
arch/ppc/configs/SM850_defconfig [deleted file]
arch/ppc/configs/SPD823TS_defconfig [deleted file]
arch/ppc/configs/adir_defconfig [deleted file]
arch/ppc/configs/ash_defconfig [deleted file]
arch/ppc/configs/beech_defconfig [deleted file]
arch/ppc/configs/cedar_defconfig [deleted file]
arch/ppc/configs/cpci690_defconfig
arch/ppc/configs/ev64360_defconfig [moved from arch/ppc/configs/k2_defconfig with 53% similarity]
arch/ppc/configs/katana_defconfig
arch/ppc/configs/mcpn765_defconfig [deleted file]
arch/ppc/configs/menf1_defconfig [deleted file]
arch/ppc/configs/mpc8560_ads_defconfig
arch/ppc/configs/oak_defconfig [deleted file]
arch/ppc/configs/pcore_defconfig [deleted file]
arch/ppc/configs/rainier_defconfig [deleted file]
arch/ppc/configs/redwood_defconfig [deleted file]
arch/ppc/kernel/cpu_setup_6xx.S
arch/ppc/kernel/cputable.c
arch/ppc/kernel/find_name.c [deleted file]
arch/ppc/kernel/head_44x.S
arch/ppc/kernel/head_4xx.S
arch/ppc/kernel/head_fsl_booke.S
arch/ppc/kernel/l2cr.S
arch/ppc/kernel/ppc_ksyms.c
arch/ppc/kernel/setup.c
arch/ppc/kernel/traps.c
arch/ppc/mm/init.c
arch/ppc/platforms/4xx/Kconfig
arch/ppc/platforms/4xx/Makefile
arch/ppc/platforms/4xx/ash.c [deleted file]
arch/ppc/platforms/4xx/ash.h [deleted file]
arch/ppc/platforms/4xx/bamboo.c
arch/ppc/platforms/4xx/bamboo.h
arch/ppc/platforms/4xx/ebony.c
arch/ppc/platforms/4xx/ibm405ep.c
arch/ppc/platforms/4xx/ibm405gp.c
arch/ppc/platforms/4xx/ibm405gpr.c
arch/ppc/platforms/4xx/ibm440ep.c
arch/ppc/platforms/4xx/ibm440gp.c
arch/ppc/platforms/4xx/ibm440gx.c
arch/ppc/platforms/4xx/ibm440sp.c
arch/ppc/platforms/4xx/ibmnp405h.c
arch/ppc/platforms/4xx/ibmstb4.c
arch/ppc/platforms/4xx/ibmstb4.h
arch/ppc/platforms/4xx/luan.c
arch/ppc/platforms/4xx/luan.h
arch/ppc/platforms/4xx/oak.c [deleted file]
arch/ppc/platforms/4xx/oak.h [deleted file]
arch/ppc/platforms/4xx/oak_setup.h [deleted file]
arch/ppc/platforms/4xx/ocotea.c
arch/ppc/platforms/4xx/redwood5.c
arch/ppc/platforms/83xx/mpc834x_sys.c
arch/ppc/platforms/83xx/mpc834x_sys.h
arch/ppc/platforms/Makefile
arch/ppc/platforms/adir.h [deleted file]
arch/ppc/platforms/adir_pci.c [deleted file]
arch/ppc/platforms/adir_pic.c [deleted file]
arch/ppc/platforms/adir_setup.c [deleted file]
arch/ppc/platforms/cpci690.c
arch/ppc/platforms/cpci690.h
arch/ppc/platforms/ev64360.c [new file with mode: 0644]
arch/ppc/platforms/ev64360.h [new file with mode: 0644]
arch/ppc/platforms/k2.c [deleted file]
arch/ppc/platforms/k2.h [deleted file]
arch/ppc/platforms/katana.c
arch/ppc/platforms/katana.h
arch/ppc/platforms/mcpn765.c [deleted file]
arch/ppc/platforms/mcpn765.h [deleted file]
arch/ppc/platforms/pcore.c [deleted file]
arch/ppc/platforms/pcore.h [deleted file]
arch/ppc/platforms/pmac_pic.c
arch/ppc/platforms/spd8xx.h [deleted file]
arch/ppc/platforms/tqm8xx.h
arch/ppc/syslib/Makefile
arch/ppc/syslib/mv64360_pic.c
arch/ppc/syslib/mv64x60.c
arch/ppc/syslib/of_device.c
arch/ppc/syslib/open_pic.c
arch/ppc/syslib/ppc4xx_setup.c
arch/ppc/syslib/ppc83xx_pci.h [new file with mode: 0644]
arch/ppc/syslib/ppc83xx_setup.c
arch/ppc/syslib/ppc83xx_setup.h
arch/ppc/syslib/ppc_sys.c
arch/ppc/syslib/pq2_devices.c [new file with mode: 0644]
arch/ppc/syslib/pq2_sys.c [new file with mode: 0644]
arch/ppc64/Kconfig.debug
arch/ppc64/kernel/Makefile
arch/ppc64/kernel/btext.c
arch/ppc64/kernel/cputable.c
arch/ppc64/kernel/entry.S
arch/ppc64/kernel/head.S
arch/ppc64/kernel/lparcfg.c
arch/ppc64/kernel/maple_setup.c
arch/ppc64/kernel/pSeries_lpar.c
arch/ppc64/kernel/pSeries_setup.c
arch/ppc64/kernel/pacaData.c
arch/ppc64/kernel/pmac_setup.c
arch/ppc64/kernel/prom.c
arch/ppc64/kernel/prom_init.c
arch/ppc64/kernel/rtasd.c
arch/ppc64/kernel/rtc.c
arch/ppc64/kernel/scanlog.c
arch/ppc64/kernel/setup.c
arch/ppc64/kernel/sysfs.c
arch/ppc64/kernel/time.c
arch/ppc64/kernel/udbg.c
arch/ppc64/kernel/udbg_16550.c [new file with mode: 0644]
arch/ppc64/kernel/udbg_scc.c [new file with mode: 0644]
arch/ppc64/mm/hugetlbpage.c
arch/ppc64/mm/init.c
arch/ppc64/mm/numa.c
arch/ppc64/mm/slb.c
arch/ppc64/mm/slb_low.S
arch/ppc64/oprofile/common.c
arch/ppc64/oprofile/op_model_power4.c
arch/ppc64/oprofile/op_model_rs64.c
arch/ppc64/xmon/start.c
arch/s390/kernel/debug.c
arch/s390/kernel/entry.S
arch/s390/kernel/entry64.S
arch/s390/mm/fault.c
arch/sh64/Kconfig
arch/sparc/kernel/sparc_ksyms.c
arch/sparc/mm/generic.c
arch/sparc64/Kconfig
arch/sparc64/kernel/entry.S
arch/sparc64/kernel/head.S
arch/sparc64/kernel/pci.c
arch/sparc64/kernel/rtrap.S
arch/sparc64/kernel/setup.c
arch/sparc64/kernel/sparc64_ksyms.c
arch/sparc64/lib/PeeCeeI.c
arch/sparc64/lib/copy_page.S
arch/sparc64/mm/generic.c
arch/sparc64/mm/ultra.S
arch/um/Kconfig
arch/um/Kconfig.char [moved from arch/um/Kconfig_char with 100% similarity]
arch/um/Kconfig.debug
arch/um/Kconfig.i386 [moved from arch/um/Kconfig_i386 with 93% similarity]
arch/um/Kconfig.net [moved from arch/um/Kconfig_net with 98% similarity]
arch/um/Kconfig.scsi [moved from arch/um/Kconfig_scsi with 100% similarity]
arch/um/Kconfig.x86_64 [moved from arch/um/Kconfig_x86_64 with 83% similarity]
arch/um/Makefile
arch/um/Makefile-x86_64
arch/um/drivers/Makefile
arch/um/drivers/chan_user.c
arch/um/drivers/ubd_kern.c
arch/um/include/aio.h [new file with mode: 0644]
arch/um/include/init.h
arch/um/include/irq_kern.h
arch/um/include/os.h
arch/um/include/syscall.h [new file with mode: 0644]
arch/um/include/syscall_user.h [deleted file]
arch/um/include/sysdep-i386/syscalls.h
arch/um/include/sysdep-x86_64/ptrace.h
arch/um/include/sysdep-x86_64/syscalls.h
arch/um/include/tlb.h
arch/um/include/user_util.h
arch/um/kernel/Makefile
arch/um/kernel/irq.c
arch/um/kernel/ksyms.c
arch/um/kernel/main.c
arch/um/kernel/skas/Makefile
arch/um/kernel/skas/include/mmu-skas.h
arch/um/kernel/skas/include/skas.h
arch/um/kernel/skas/mem_user.c
arch/um/kernel/skas/mmu.c
arch/um/kernel/skas/process.c
arch/um/kernel/skas/process_kern.c
arch/um/kernel/skas/syscall.c [new file with mode: 0644]
arch/um/kernel/skas/syscall_kern.c [deleted file]
arch/um/kernel/skas/syscall_user.c [deleted file]
arch/um/kernel/skas/tlb.c
arch/um/kernel/syscall.c [new file with mode: 0644]
arch/um/kernel/syscall_user.c [deleted file]
arch/um/kernel/tlb.c
arch/um/kernel/trap_kern.c
arch/um/kernel/trap_user.c
arch/um/kernel/tt/syscall_kern.c
arch/um/kernel/tt/syscall_user.c
arch/um/kernel/tt/tlb.c
arch/um/kernel/um_arch.c
arch/um/os-Linux/Makefile
arch/um/os-Linux/aio.c [new file with mode: 0644]
arch/um/os-Linux/process.c
arch/um/os-Linux/start_up.c [moved from arch/um/kernel/process.c with 61% similarity]
arch/um/os-Linux/tt.c [new file with mode: 0644]
arch/um/scripts/Makefile.unmap
arch/um/sys-i386/Makefile
arch/um/sys-i386/signal.c
arch/um/sys-i386/stub.S
arch/um/sys-i386/stub_segv.c
arch/um/sys-x86_64/Makefile
arch/um/sys-x86_64/signal.c
arch/um/sys-x86_64/stub.S
arch/um/sys-x86_64/stub_segv.c
arch/v850/configs/rte-ma1-cb_defconfig
arch/v850/configs/rte-me2-cb_defconfig
arch/v850/configs/sim_defconfig
arch/v850/kernel/setup.c
arch/x86_64/Kconfig
arch/x86_64/kernel/Makefile
arch/x86_64/kernel/nmi.c
crypto/Kconfig
crypto/api.c
crypto/cipher.c
crypto/internal.h
crypto/tcrypt.c
crypto/tcrypt.h
crypto/tea.c
drivers/atm/zatm.c
drivers/base/bus.c
drivers/base/class.c
drivers/base/core.c
drivers/base/dd.c
drivers/base/node.c
drivers/base/power/resume.c
drivers/base/power/runtime.c
drivers/base/power/suspend.c
drivers/base/power/sysfs.c
drivers/base/sys.c
drivers/block/Kconfig
drivers/block/cryptoloop.c
drivers/block/floppy.c
drivers/char/Kconfig
drivers/char/moxa.c
drivers/char/mwave/mwavedd.c
drivers/char/mxser.c
drivers/char/rtc.c
drivers/char/snsc_event.c
drivers/char/tpm/tpm_infineon.c
drivers/char/watchdog/Kconfig
drivers/char/watchdog/Makefile
drivers/char/watchdog/booke_wdt.c [new file with mode: 0644]
drivers/char/watchdog/ixp2000_wdt.c
drivers/char/watchdog/ixp4xx_wdt.c
drivers/char/watchdog/s3c2410_wdt.c
drivers/char/watchdog/scx200_wdt.c
drivers/char/watchdog/softdog.c
drivers/char/watchdog/w83627hf_wdt.c
drivers/hwmon/Kconfig
drivers/hwmon/Makefile
drivers/hwmon/adm1021.c
drivers/hwmon/adm1025.c
drivers/hwmon/adm1026.c
drivers/hwmon/adm1031.c
drivers/hwmon/adm9240.c
drivers/hwmon/asb100.c
drivers/hwmon/atxp1.c
drivers/hwmon/ds1621.c
drivers/hwmon/fscher.c
drivers/hwmon/fscpos.c
drivers/hwmon/gl518sm.c
drivers/hwmon/gl520sm.c
drivers/hwmon/hwmon-vid.c [new file with mode: 0644]
drivers/hwmon/hwmon.c [new file with mode: 0644]
drivers/hwmon/it87.c
drivers/hwmon/lm63.c
drivers/hwmon/lm75.c
drivers/hwmon/lm75.h
drivers/hwmon/lm77.c
drivers/hwmon/lm78.c
drivers/hwmon/lm80.c
drivers/hwmon/lm83.c
drivers/hwmon/lm85.c
drivers/hwmon/lm87.c
drivers/hwmon/lm90.c
drivers/hwmon/lm92.c
drivers/hwmon/max1619.c
drivers/hwmon/pc87360.c
drivers/hwmon/sis5595.c
drivers/hwmon/smsc47b397.c
drivers/hwmon/smsc47m1.c
drivers/hwmon/via686a.c
drivers/hwmon/w83627ehf.c
drivers/hwmon/w83627hf.c
drivers/hwmon/w83781d.c
drivers/hwmon/w83792d.c [new file with mode: 0644]
drivers/hwmon/w83l785ts.c
drivers/i2c/Makefile
drivers/i2c/algos/i2c-algo-bit.c
drivers/i2c/algos/i2c-algo-ite.c
drivers/i2c/algos/i2c-algo-pca.c
drivers/i2c/algos/i2c-algo-pcf.c
drivers/i2c/algos/i2c-algo-sgi.c
drivers/i2c/algos/i2c-algo-sibyte.c
drivers/i2c/busses/Kconfig
drivers/i2c/busses/i2c-ali1535.c
drivers/i2c/busses/i2c-ali1563.c
drivers/i2c/busses/i2c-ali15x3.c
drivers/i2c/busses/i2c-amd756.c
drivers/i2c/busses/i2c-amd8111.c
drivers/i2c/busses/i2c-au1550.c
drivers/i2c/busses/i2c-i801.c
drivers/i2c/busses/i2c-ibm_iic.c
drivers/i2c/busses/i2c-iop3xx.c
drivers/i2c/busses/i2c-isa.c
drivers/i2c/busses/i2c-keywest.c
drivers/i2c/busses/i2c-mpc.c
drivers/i2c/busses/i2c-mv64xxx.c
drivers/i2c/busses/i2c-nforce2.c
drivers/i2c/busses/i2c-piix4.c
drivers/i2c/busses/i2c-s3c2410.c
drivers/i2c/busses/i2c-sis5595.c
drivers/i2c/busses/i2c-sis630.c
drivers/i2c/busses/i2c-sis96x.c
drivers/i2c/busses/i2c-stub.c
drivers/i2c/busses/i2c-viapro.c
drivers/i2c/busses/scx200_acb.c
drivers/i2c/chips/Kconfig
drivers/i2c/chips/ds1337.c
drivers/i2c/chips/ds1374.c
drivers/i2c/chips/eeprom.c
drivers/i2c/chips/m41t00.c
drivers/i2c/chips/max6875.c
drivers/i2c/chips/pca9539.c
drivers/i2c/chips/pcf8574.c
drivers/i2c/chips/pcf8591.c
drivers/i2c/chips/rtc8564.c
drivers/i2c/i2c-core.c
drivers/i2c/i2c-dev.c
drivers/i2c/i2c-sensor-detect.c [deleted file]
drivers/i2c/i2c-sensor-vid.c [deleted file]
drivers/ide/ide-io.c
drivers/ide/ide.c
drivers/ide/pci/sc1200.c
drivers/ide/ppc/pmac.c
drivers/ieee1394/pcilynx.c
drivers/input/evdev.c
drivers/macintosh/mediabay.c
drivers/macintosh/via-pmu.c
drivers/md/dm-crypt.c
drivers/media/common/saa7146_i2c.c
drivers/media/dvb/b2c2/flexcop-i2c.c
drivers/media/dvb/cinergyT2/cinergyT2.c
drivers/media/dvb/dvb-usb/cxusb.c
drivers/media/dvb/dvb-usb/dibusb-common.c
drivers/media/dvb/dvb-usb/digitv.c
drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
drivers/media/dvb/pluto2/pluto2.c
drivers/media/dvb/ttpci/Kconfig
drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
drivers/media/video/Kconfig
drivers/media/video/adv7170.c
drivers/media/video/adv7175.c
drivers/media/video/bt819.c
drivers/media/video/bt832.c
drivers/media/video/bt856.c
drivers/media/video/bttv-driver.c
drivers/media/video/bttv-i2c.c
drivers/media/video/cx88/cx88-i2c.c
drivers/media/video/ir-kbd-i2c.c
drivers/media/video/msp3400.c
drivers/media/video/ovcamchip/ov6x20.c
drivers/media/video/ovcamchip/ov6x30.c
drivers/media/video/ovcamchip/ovcamchip_core.c
drivers/media/video/saa7110.c
drivers/media/video/saa7111.c
drivers/media/video/saa7114.c
drivers/media/video/saa7134/saa6752hs.c
drivers/media/video/saa7134/saa7134-i2c.c
drivers/media/video/saa7185.c
drivers/media/video/tda7432.c
drivers/media/video/tda9840.c
drivers/media/video/tda9875.c
drivers/media/video/tda9887.c
drivers/media/video/tea6415c.c
drivers/media/video/tea6420.c
drivers/media/video/tuner-3036.c
drivers/media/video/tuner-core.c
drivers/media/video/tvaudio.c
drivers/media/video/tveeprom.c
drivers/media/video/tvmixer.c
drivers/media/video/vpx3220.c
drivers/media/video/zoran_card.c
drivers/misc/Kconfig
drivers/mmc/mmc.c
drivers/mmc/wbsd.c
drivers/mmc/wbsd.h
drivers/net/Kconfig
drivers/net/bnx2.c
drivers/net/chelsio/common.h
drivers/net/chelsio/cxgb2.c
drivers/net/e1000/e1000_hw.h
drivers/net/e1000/e1000_main.c
drivers/net/irda/vlsi_ir.c
drivers/net/iseries_veth.c
drivers/net/iseries_veth.h [deleted file]
drivers/net/mv643xx_eth.c
drivers/net/mv643xx_eth.h
drivers/net/ne3210.c
drivers/net/phy/Kconfig
drivers/net/phy/mdio_bus.c
drivers/net/s2io.c
drivers/net/sis190.c
drivers/net/sungem.c
drivers/net/sungem.h
drivers/net/tg3.c
drivers/net/tulip/de2104x.c
drivers/net/tulip/tulip_core.c
drivers/net/tulip/uli526x.c
drivers/net/tun.c
drivers/net/wireless/Kconfig
drivers/net/wireless/Makefile
drivers/net/wireless/airo.c
drivers/net/wireless/atmel.c
drivers/net/wireless/hostap/Kconfig [new file with mode: 0644]
drivers/net/wireless/hostap/Makefile [new file with mode: 0644]
drivers/net/wireless/hostap/hostap.c [new file with mode: 0644]
drivers/net/wireless/hostap/hostap.h [new file with mode: 0644]
drivers/net/wireless/hostap/hostap_80211.h [new file with mode: 0644]
drivers/net/wireless/hostap/hostap_80211_rx.c [new file with mode: 0644]
drivers/net/wireless/hostap/hostap_80211_tx.c [new file with mode: 0644]
drivers/net/wireless/hostap/hostap_ap.c [new file with mode: 0644]
drivers/net/wireless/hostap/hostap_ap.h [new file with mode: 0644]
drivers/net/wireless/hostap/hostap_common.h [new file with mode: 0644]
drivers/net/wireless/hostap/hostap_config.h [new file with mode: 0644]
drivers/net/wireless/hostap/hostap_cs.c [new file with mode: 0644]
drivers/net/wireless/hostap/hostap_download.c [new file with mode: 0644]
drivers/net/wireless/hostap/hostap_hw.c [new file with mode: 0644]
drivers/net/wireless/hostap/hostap_info.c [new file with mode: 0644]
drivers/net/wireless/hostap/hostap_ioctl.c [new file with mode: 0644]
drivers/net/wireless/hostap/hostap_pci.c [new file with mode: 0644]
drivers/net/wireless/hostap/hostap_plx.c [new file with mode: 0644]
drivers/net/wireless/hostap/hostap_proc.c [new file with mode: 0644]
drivers/net/wireless/hostap/hostap_wlan.h [new file with mode: 0644]
drivers/net/wireless/ieee802_11.h [deleted file]
drivers/net/wireless/ipw2100.c [new file with mode: 0644]
drivers/net/wireless/ipw2100.h [new file with mode: 0644]
drivers/net/wireless/ipw2200.c [new file with mode: 0644]
drivers/net/wireless/ipw2200.h [new file with mode: 0644]
drivers/net/wireless/orinoco.c
drivers/net/wireless/orinoco_cs.c
drivers/net/wireless/orinoco_nortel.c [new file with mode: 0644]
drivers/net/wireless/orinoco_pci.c
drivers/net/wireless/prism54/islpci_hotplug.c
drivers/net/wireless/spectrum_cs.c [new file with mode: 0644]
drivers/net/wireless/strip.c
drivers/net/wireless/wavelan_cs.c
drivers/net/wireless/wavelan_cs.h
drivers/net/wireless/wavelan_cs.p.h
drivers/net/wireless/wl3501.h
drivers/net/wireless/wl3501_cs.c
drivers/pci/pci.c
drivers/pci/quirks.c
drivers/pci/rom.c
drivers/pcmcia/pxa2xx_base.c
drivers/pcmcia/pxa2xx_mainstone.c
drivers/pcmcia/pxa2xx_sharpsl.c
drivers/pcmcia/sa1100_generic.c
drivers/pcmcia/sa1111_generic.c
drivers/pcmcia/sa11xx_base.c
drivers/s390/block/Kconfig
drivers/s390/block/dasd.c
drivers/s390/block/dasd_devmap.c
drivers/s390/block/dasd_diag.c
drivers/s390/block/dasd_diag.h
drivers/s390/block/dasd_genhd.c
drivers/s390/block/dasd_int.h
drivers/s390/block/dasd_ioctl.c
drivers/s390/block/dasd_proc.c
drivers/s390/char/raw3270.c
drivers/s390/cio/cio.c
drivers/s390/cio/device_fsm.c
drivers/s390/cio/device_ops.c
drivers/s390/cio/ioasm.h
drivers/s390/crypto/z90common.h
drivers/s390/crypto/z90hardware.c
drivers/s390/crypto/z90main.c
drivers/s390/s390mach.c
drivers/sbus/char/Kconfig
drivers/scsi/Kconfig
drivers/scsi/ahci.c
drivers/scsi/ata_piix.c
drivers/scsi/libata-core.c
drivers/scsi/libata-scsi.c
drivers/scsi/libata.h
drivers/scsi/mesh.c
drivers/scsi/sata_nv.c
drivers/scsi/sata_promise.c
drivers/scsi/sata_qstor.c
drivers/scsi/sata_sil.c
drivers/scsi/sata_svw.c
drivers/scsi/sata_sx4.c
drivers/scsi/sata_vsc.c
drivers/serial/21285.c
drivers/serial/8250.c
drivers/serial/8250.h
drivers/serial/Kconfig
drivers/serial/amba-pl010.c
drivers/serial/amba-pl011.c
drivers/serial/au1x00_uart.c
drivers/serial/clps711x.c
drivers/serial/cpm_uart/cpm_uart_core.c
drivers/serial/cpm_uart/cpm_uart_cpm2.c
drivers/serial/crisv10.c
drivers/serial/dz.c
drivers/serial/icom.c
drivers/serial/imx.c
drivers/serial/ioc4_serial.c
drivers/serial/ip22zilog.c
drivers/serial/jsm/jsm_tty.c
drivers/serial/m32r_sio.c
drivers/serial/mpc52xx_uart.c
drivers/serial/mpsc.c
drivers/serial/mux.c
drivers/serial/pmac_zilog.c
drivers/serial/pxa.c
drivers/serial/s3c2410.c
drivers/serial/sa1100.c
drivers/serial/serial_core.c
drivers/serial/serial_lh7a40x.c
drivers/serial/serial_txx9.c
drivers/serial/sh-sci.c
drivers/serial/sn_console.c
drivers/serial/sunsab.c
drivers/serial/sunsu.c
drivers/serial/sunzilog.c
drivers/serial/uart00.c
drivers/serial/v850e_uart.c
drivers/serial/vr41xx_siu.c
drivers/usb/core/hcd.c
drivers/usb/core/hub.c
drivers/usb/core/usb.c
drivers/usb/host/ehci-dbg.c
drivers/usb/host/ohci-dbg.c
drivers/usb/host/sl811-hcd.c
drivers/usb/media/w9968cf.c
drivers/usb/misc/usbtest.c
drivers/usb/net/Makefile
drivers/usb/net/zd1201.c
drivers/video/aty/aty128fb.c
drivers/video/aty/atyfb_base.c
drivers/video/aty/radeon_i2c.c
drivers/video/aty/radeon_pm.c
drivers/video/chipsfb.c
drivers/video/i810/i810_main.c
drivers/video/matrox/matroxfb_maven.c
drivers/video/nvidia/nv_i2c.c
drivers/video/pmag-aa-fb.c
drivers/video/pmag-ba-fb.c
drivers/video/pmagb-b-fb.c
drivers/video/riva/rivafb-i2c.c
drivers/video/s1d13xxxfb.c
drivers/video/savage/savagefb-i2c.c
drivers/video/savage/savagefb_driver.c
fs/Kconfig
fs/aio.c
fs/binfmt_flat.c
fs/devpts/Makefile
fs/devpts/inode.c
fs/devpts/xattr_security.c [deleted file]
fs/nfsd/nfs4recover.c
fs/proc/base.c
fs/proc/task_mmu.c
fs/xattr.c
include/asm-alpha/page.h
include/asm-alpha/types.h
include/asm-arm/arch-ixp4xx/io.h
include/asm-arm/arch-ixp4xx/platform.h
include/asm-arm/arch-pxa/pxa-regs.h
include/asm-arm/arch-s3c2410/regs-clock.h
include/asm-arm/hardware/scoop.h
include/asm-arm/mach/irq.h
include/asm-arm/mach/time.h
include/asm-arm/page.h
include/asm-arm/types.h
include/asm-arm/unistd.h
include/asm-arm26/page.h
include/asm-arm26/types.h
include/asm-cris/page.h
include/asm-cris/types.h
include/asm-frv/page.h
include/asm-frv/types.h
include/asm-generic/page.h [new file with mode: 0644]
include/asm-generic/pgtable.h
include/asm-generic/vmlinux.lds.h
include/asm-h8300/page.h
include/asm-h8300/types.h
include/asm-i386/agp.h
include/asm-i386/apicdef.h
include/asm-i386/bugs.h
include/asm-i386/desc.h
include/asm-i386/kdebug.h
include/asm-i386/mach-es7000/mach_mpparse.h
include/asm-i386/mach-generic/mach_apic.h
include/asm-i386/mpspec.h
include/asm-i386/msr.h
include/asm-i386/page.h
include/asm-i386/pgtable-3level.h
include/asm-i386/pgtable.h
include/asm-i386/processor.h
include/asm-i386/ptrace.h
include/asm-i386/setup.h
include/asm-i386/smp.h
include/asm-i386/system.h
include/asm-i386/thread_info.h
include/asm-i386/timer.h
include/asm-i386/types.h
include/asm-i386/xor.h
include/asm-ia64/acpi.h
include/asm-ia64/fcntl.h
include/asm-ia64/io.h
include/asm-ia64/mmu.h
include/asm-ia64/mmu_context.h
include/asm-ia64/page.h
include/asm-ia64/pal.h
include/asm-ia64/pgtable.h
include/asm-ia64/rwsem.h
include/asm-ia64/sn/addrs.h
include/asm-ia64/sn/geo.h
include/asm-ia64/sn/intr.h
include/asm-ia64/sn/nodepda.h
include/asm-ia64/sn/pcibus_provider_defs.h
include/asm-ia64/sn/pda.h
include/asm-ia64/sn/sn2/sn_hwperf.h
include/asm-ia64/sn/sn_sal.h
include/asm-ia64/sn/tioce.h [new file with mode: 0644]
include/asm-ia64/sn/tioce_provider.h [new file with mode: 0644]
include/asm-ia64/spinlock.h
include/asm-ia64/system.h
include/asm-ia64/types.h
include/asm-m32r/page.h
include/asm-m32r/types.h
include/asm-m68k/cacheflush.h
include/asm-m68k/page.h
include/asm-m68k/string.h
include/asm-m68k/types.h
include/asm-m68knommu/page.h
include/asm-mips/a.out.h
include/asm-mips/addrspace.h
include/asm-mips/asmmacro.h
include/asm-mips/atomic.h
include/asm-mips/bitops.h
include/asm-mips/bugs.h
include/asm-mips/checksum.h
include/asm-mips/cpu-features.h
include/asm-mips/ddb5xxx/ddb5477.h
include/asm-mips/dec/prom.h
include/asm-mips/delay.h
include/asm-mips/elf.h
include/asm-mips/fpregdef.h
include/asm-mips/fpu.h
include/asm-mips/hp-lj/asic.h [deleted file]
include/asm-mips/ip32/mace.h
include/asm-mips/lasat/serial.h
include/asm-mips/local.h
include/asm-mips/mach-au1x00/au1000.h
include/asm-mips/mach-db1x00/db1x00.h
include/asm-mips/mach-generic/spaces.h
include/asm-mips/mach-ip22/spaces.h
include/asm-mips/mach-ip32/cpu-feature-overrides.h
include/asm-mips/mach-jazz/floppy.h
include/asm-mips/mach-pb1x00/pb1500.h
include/asm-mips/mach-qemu/cpu-feature-overrides.h [new file with mode: 0644]
include/asm-mips/mach-qemu/param.h [new file with mode: 0644]
include/asm-mips/mach-vr41xx/timex.h [deleted file]
include/asm-mips/mmu_context.h
include/asm-mips/module.h
include/asm-mips/msgbuf.h
include/asm-mips/paccess.h
include/asm-mips/page.h
include/asm-mips/pci.h
include/asm-mips/pgalloc.h
include/asm-mips/pgtable.h
include/asm-mips/processor.h
include/asm-mips/ptrace.h
include/asm-mips/qemu.h [new file with mode: 0644]
include/asm-mips/r4kcache.h
include/asm-mips/reg.h
include/asm-mips/resource.h
include/asm-mips/rtc.h
include/asm-mips/sgi/gio.h
include/asm-mips/sgi/hpc3.h
include/asm-mips/sgi/ioc.h
include/asm-mips/sgi/ip22.h
include/asm-mips/sgi/mc.h
include/asm-mips/sgiarcs.h
include/asm-mips/sibyte/carmel.h
include/asm-mips/sibyte/sb1250_defs.h
include/asm-mips/sibyte/sb1250_dma.h
include/asm-mips/sibyte/sb1250_genbus.h
include/asm-mips/sibyte/sb1250_int.h
include/asm-mips/sibyte/sb1250_l2c.h
include/asm-mips/sibyte/sb1250_ldt.h
include/asm-mips/sibyte/sb1250_mac.h
include/asm-mips/sibyte/sb1250_mc.h
include/asm-mips/sibyte/sb1250_regs.h
include/asm-mips/sibyte/sb1250_scd.h
include/asm-mips/sibyte/sb1250_smbus.h
include/asm-mips/sibyte/sb1250_syncser.h
include/asm-mips/sibyte/sb1250_uart.h
include/asm-mips/sigcontext.h
include/asm-mips/siginfo.h
include/asm-mips/sim.h
include/asm-mips/socket.h
include/asm-mips/stackframe.h
include/asm-mips/statfs.h
include/asm-mips/string.h
include/asm-mips/system.h
include/asm-mips/thread_info.h
include/asm-mips/titan_dep.h
include/asm-mips/tx4927/tx4927.h
include/asm-mips/tx4927/tx4927_pci.h
include/asm-mips/types.h
include/asm-mips/uaccess.h
include/asm-mips/unistd.h
include/asm-mips/vr4181/irq.h [deleted file]
include/asm-mips/vr4181/vr4181.h [deleted file]
include/asm-mips/vr41xx/vr41xx.h
include/asm-mips/vr41xx/vrc4173.h
include/asm-mips/war.h
include/asm-mips/xxs1500.h
include/asm-parisc/page.h
include/asm-parisc/types.h
include/asm-powerpc/bugs.h [new file with mode: 0644]
include/asm-powerpc/mc146818rtc.h [moved from include/asm-ppc64/mc146818rtc.h with 84% similarity]
include/asm-powerpc/mman.h [moved from include/asm-ppc64/mman.h with 96% similarity]
include/asm-powerpc/module.h [new file with mode: 0644]
include/asm-powerpc/sembuf.h [moved from include/asm-ppc64/sembuf.h with 62% similarity]
include/asm-powerpc/shmbuf.h [moved from include/asm-ppc64/shmbuf.h with 72% similarity]
include/asm-powerpc/siginfo.h [moved from include/asm-ppc64/siginfo.h with 56% similarity]
include/asm-powerpc/socket.h [moved from include/asm-ppc64/socket.h with 88% similarity]
include/asm-powerpc/sockios.h [moved from include/asm-ppc64/sockios.h with 83% similarity]
include/asm-powerpc/termbits.h [moved from include/asm-ppc64/termbits.h with 97% similarity]
include/asm-powerpc/termios.h [moved from include/asm-ppc64/termios.h with 98% similarity]
include/asm-ppc/bugs.h [deleted file]
include/asm-ppc/dma-mapping.h
include/asm-ppc/ibm4xx.h
include/asm-ppc/ibm_ocp.h
include/asm-ppc/irq.h
include/asm-ppc/kmap_types.h
include/asm-ppc/mc146818rtc.h [deleted file]
include/asm-ppc/mman.h [deleted file]
include/asm-ppc/module.h [deleted file]
include/asm-ppc/mpc8260.h
include/asm-ppc/mpc8xx.h
include/asm-ppc/mv64x60.h
include/asm-ppc/mv64x60_defs.h
include/asm-ppc/param.h
include/asm-ppc/pmac_feature.h
include/asm-ppc/ppc_sys.h
include/asm-ppc/sembuf.h [deleted file]
include/asm-ppc/serial.h
include/asm-ppc/shmbuf.h [deleted file]
include/asm-ppc/siginfo.h [deleted file]
include/asm-ppc/socket.h [deleted file]
include/asm-ppc/sockios.h [deleted file]
include/asm-ppc/system.h
include/asm-ppc/termbits.h [deleted file]
include/asm-ppc/termios.h [deleted file]
include/asm-ppc/types.h
include/asm-ppc64/bugs.h [deleted file]
include/asm-ppc64/cputable.h
include/asm-ppc64/lmb.h
include/asm-ppc64/lppaca.h
include/asm-ppc64/machdep.h
include/asm-ppc64/mmu.h
include/asm-ppc64/module.h [deleted file]
include/asm-ppc64/oprofile_impl.h [moved from arch/ppc64/oprofile/op_impl.h with 95% similarity]
include/asm-ppc64/page.h
include/asm-ppc64/system.h
include/asm-ppc64/types.h
include/asm-ppc64/udbg.h
include/asm-s390/debug.h
include/asm-s390/lowcore.h
include/asm-s390/page.h
include/asm-s390/spinlock.h
include/asm-s390/types.h
include/asm-sh/page.h
include/asm-sh/types.h
include/asm-sh64/page.h
include/asm-sh64/types.h
include/asm-sparc/page.h
include/asm-sparc/pgtable.h
include/asm-sparc/types.h
include/asm-sparc64/cpudata.h
include/asm-sparc64/hardirq.h
include/asm-sparc64/io.h
include/asm-sparc64/page.h
include/asm-sparc64/pgtable.h
include/asm-sparc64/types.h
include/asm-um/mmu_context.h
include/asm-um/page.h
include/asm-um/pgalloc.h
include/asm-um/pgtable-2level.h
include/asm-um/pgtable-3level.h
include/asm-um/pgtable.h
include/asm-v850/page.h
include/asm-v850/types.h
include/asm-x86_64/page.h
include/asm-x86_64/pgtable.h
include/asm-x86_64/processor.h
include/asm-x86_64/types.h
include/asm-xtensa/atomic.h
include/asm-xtensa/checksum.h
include/asm-xtensa/delay.h
include/asm-xtensa/io.h
include/asm-xtensa/mmu_context.h
include/asm-xtensa/page.h
include/asm-xtensa/page.h.n [deleted file]
include/asm-xtensa/pci.h
include/asm-xtensa/pgtable.h
include/asm-xtensa/semaphore.h
include/asm-xtensa/string.h
include/asm-xtensa/system.h
include/asm-xtensa/tlbflush.h
include/asm-xtensa/types.h
include/asm-xtensa/uaccess.h
include/linux/capability.h
include/linux/cpu.h
include/linux/crypto.h
include/linux/efi.h
include/linux/etherdevice.h
include/linux/hugetlb.h
include/linux/hwmon-sysfs.h
include/linux/hwmon-vid.h [new file with mode: 0644]
include/linux/hwmon.h [new file with mode: 0644]
include/linux/i2c-id.h
include/linux/i2c-isa.h [new file with mode: 0644]
include/linux/i2c-sensor.h [deleted file]
include/linux/i2c-vid.h [deleted file]
include/linux/i2c.h
include/linux/if_tun.h
include/linux/klist.h
include/linux/libata.h
include/linux/mempolicy.h
include/linux/mmc/host.h
include/linux/mmzone.h
include/linux/mv643xx.h
include/linux/page-flags.h
include/linux/pci_ids.h
include/linux/pm.h
include/linux/ptrace.h
include/linux/serial.h
include/linux/serial_8250.h
include/linux/serial_core.h
include/linux/swap.h
include/linux/swapops.h
include/linux/vmalloc.h
include/media/id.h
include/net/ieee80211.h
include/net/ieee80211_crypt.h [new file with mode: 0644]
include/net/ip_vs.h
include/net/irda/irlan_filter.h
include/net/sock.h
include/net/tcp.h
include/video/pmag-ba-fb.h
include/video/pmagb-b-fb.h
init/Kconfig
init/Makefile
init/do_mounts.c
kernel/fork.c
kernel/power/Kconfig
kernel/power/disk.c
kernel/power/main.c
kernel/power/process.c
kernel/power/swsusp.c
lib/Makefile
lib/klist.c
lib/semaphore-sleepers.c [moved from arch/x86_64/kernel/semaphore.c with 94% similarity]
mm/Kconfig
mm/filemap.c
mm/hugetlb.c
mm/madvise.c
mm/memory.c
mm/mempolicy.c
mm/mremap.c
mm/page_alloc.c
mm/rmap.c
mm/shmem.c
mm/slab.c
mm/sparse.c
mm/swap_state.c
mm/swapfile.c
mm/vmalloc.c
mm/vmscan.c
net/Kconfig
net/Makefile
net/atm/ioctl.c
net/core/ethtool.c
net/core/filter.c
net/core/sock.c
net/decnet/af_decnet.c
net/decnet/dn_nsp_out.c
net/ieee80211/Kconfig [new file with mode: 0644]
net/ieee80211/Makefile [new file with mode: 0644]
net/ieee80211/ieee80211_crypt.c [new file with mode: 0644]
net/ieee80211/ieee80211_crypt_ccmp.c [new file with mode: 0644]
net/ieee80211/ieee80211_crypt_tkip.c [new file with mode: 0644]
net/ieee80211/ieee80211_crypt_wep.c [new file with mode: 0644]
net/ieee80211/ieee80211_module.c [new file with mode: 0644]
net/ieee80211/ieee80211_rx.c [new file with mode: 0644]
net/ieee80211/ieee80211_tx.c [new file with mode: 0644]
net/ieee80211/ieee80211_wx.c [new file with mode: 0644]
net/ipv4/ah4.c
net/ipv4/esp4.c
net/ipv4/ipcomp.c
net/ipv4/ipconfig.c
net/ipv4/netfilter/ipt_CLUSTERIP.c
net/ipv4/tcp.c
net/ipv4/tcp_input.c
net/ipv4/tcp_output.c
net/ipv6/addrconf.c
net/ipv6/ah6.c
net/ipv6/esp6.c
net/ipv6/icmp.c
net/ipv6/ipcomp6.c
net/ipv6/raw.c
net/irda/irlan/irlan_filter.c
net/irda/qos.c
net/netfilter/nfnetlink.c
net/netfilter/nfnetlink_queue.c
net/sctp/endpointola.c
net/sctp/socket.c
net/sctp/sysctl.c
net/sunrpc/auth_gss/gss_krb5_crypto.c
net/sunrpc/auth_gss/gss_krb5_mech.c
net/sunrpc/auth_gss/gss_spkm3_mech.c
net/sunrpc/rpc_pipe.c
scripts/Kbuild.include [new file with mode: 0644]
scripts/Makefile.build
scripts/Makefile.clean
scripts/Makefile.host
scripts/Makefile.lib
scripts/Makefile.modinst
scripts/Makefile.modpost
scripts/conmakehash.c
scripts/kallsyms.c
scripts/kconfig/Makefile
scripts/kconfig/kxgettext.c
scripts/kconfig/lkc.h
scripts/kconfig/menu.c
scripts/kconfig/zconf.tab.c_shipped
scripts/kconfig/zconf.y
scripts/kernel-doc
scripts/lxdialog/dialog.h
scripts/lxdialog/inputbox.c
scripts/mkcompile_h
scripts/mod/sumversion.c
scripts/package/Makefile
scripts/package/builddeb
scripts/package/buildtar [new file with mode: 0644]
scripts/package/mkspec
scripts/reference_discarded.pl
scripts/reference_init.pl
scripts/setlocalversion [new file with mode: 0644]
security/seclvl.c
security/selinux/avc.c
security/selinux/include/security.h
security/selinux/ss/avtab.c
security/selinux/ss/avtab.h
security/selinux/ss/conditional.c
security/selinux/ss/ebitmap.c
security/selinux/ss/ebitmap.h
security/selinux/ss/mls.c
security/selinux/ss/policydb.c
security/selinux/ss/policydb.h
security/selinux/ss/services.c
sound/pci/atiixp.c
usr/Kconfig [new file with mode: 0644]
usr/Makefile

index a2d5b490077298e1b4d365eee679aaf7f877c727..74dffc68ff9f79f9c25409c791f8aaaf7f3188f3 100644 (file)
@@ -223,6 +223,7 @@ CAST5 algorithm contributors:
 
 TEA/XTEA algorithm contributors:
   Aaron Grothe
+  Michael Ringe
 
 Khazad algorithm contributors:
   Aaron Grothe
index 0665cb12bd6650f65f692ab726212deed76422c9..363909056e46f0c41b865977659bc599577b3de3 100644 (file)
@@ -102,16 +102,6 @@ Who:       Jody McIntyre <scjody@steamballoon.com>
 
 ---------------------------
 
-What:  register_serial/unregister_serial
-When:  September 2005
-Why:   This interface does not allow serial ports to be registered against
-       a struct device, and as such does not allow correct power management
-       of such ports.  8250-based ports should use serial8250_register_port
-       and serial8250_unregister_port, or platform devices instead.
-Who:   Russell King <rmk@arm.linux.org.uk>
-
----------------------------
-
 What:  i2c sysfs name change: in1_ref, vid deprecated in favour of cpu0_vid
 When:  November 2005
 Files: drivers/i2c/chips/adm1025.c, drivers/i2c/chips/adm1026.c
index 6c98f2bd421e79f5a84a7a3c72e51b2ac398abc7..5024ba7a592c065820216ecf21ee862355170d41 100644 (file)
@@ -133,6 +133,7 @@ Table 1-1: Process specific entries in /proc
  statm   Process memory status information              
  status  Process status in human readable form          
  wchan   If CONFIG_KALLSYMS is set, a pre-decoded wchan
+ smaps  Extension based on maps, presenting the rss size for each mapped file
 ..............................................................................
 
 For example, to get the status information of a process, all you have to do is
index dc276598a65a3784c4dd7d41470c41f288db9529..c8bce82ddcacdf22e6a7190c204faf154821a619 100644 (file)
@@ -90,7 +90,7 @@ void device_remove_file(struct device *, struct device_attribute *);
 
 It also defines this helper for defining device attributes: 
 
-#define DEVICE_ATTR(_name,_mode,_show,_store)      \
+#define DEVICE_ATTR(_name, _mode, _show, _store)      \
 struct device_attribute dev_attr_##_name = {            \
         .attr = {.name  = __stringify(_name) , .mode   = _mode },      \
         .show   = _show,                                \
@@ -99,14 +99,14 @@ struct device_attribute dev_attr_##_name = {            \
 
 For example, declaring
 
-static DEVICE_ATTR(foo,0644,show_foo,store_foo);
+static DEVICE_ATTR(foo, S_IWUSR | S_IRUGO, show_foo, store_foo);
 
 is equivalent to doing:
 
 static struct device_attribute dev_attr_foo = {
        .attr   = {
                .name = "foo",
-               .mode = 0644,
+               .mode = S_IWUSR | S_IRUGO,
        },
        .show = show_foo,
        .store = store_foo,
@@ -121,8 +121,8 @@ set of sysfs operations for forwarding read and write calls to the
 show and store methods of the attribute owners. 
 
 struct sysfs_ops {
-        ssize_t (*show)(struct kobject *, struct attribute *,char *);
-        ssize_t (*store)(struct kobject *,struct attribute *,const char *);
+        ssize_t (*show)(struct kobject *, struct attribute *, char *);
+        ssize_t (*store)(struct kobject *, struct attribute *, const char *);
 };
 
 [ Subsystems should have already defined a struct kobj_type as a
@@ -137,7 +137,7 @@ calls the associated methods.
 
 To illustrate:
 
-#define to_dev_attr(_attr) container_of(_attr,struct device_attribute,attr)
+#define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr)
 #define to_dev(d) container_of(d, struct device, kobj)
 
 static ssize_t
@@ -148,7 +148,7 @@ dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
         ssize_t ret = 0;
 
         if (dev_attr->show)
-                ret = dev_attr->show(dev,buf);
+                ret = dev_attr->show(dev, buf);
         return ret;
 }
 
@@ -216,16 +216,16 @@ A very simple (and naive) implementation of a device attribute is:
 
 static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf)
 {
-        return sprintf(buf,"%s\n",dev->name);
+       return snprintf(buf, PAGE_SIZE, "%s\n", dev->name);
 }
 
 static ssize_t store_name(struct device * dev, const char * buf)
 {
-       sscanf(buf,"%20s",dev->name);
-       return strlen(buf);
+       sscanf(buf, "%20s", dev->name);
+       return strnlen(buf, PAGE_SIZE);
 }
 
-static DEVICE_ATTR(name,S_IRUGO,show_name,store_name);
+static DEVICE_ATTR(name, S_IRUGO, show_name, store_name);
 
 
 (Note that the real implementation doesn't allow userspace to set the 
@@ -290,7 +290,7 @@ struct device_attribute {
 
 Declaring:
 
-DEVICE_ATTR(_name,_str,_mode,_show,_store);
+DEVICE_ATTR(_name, _str, _mode, _show, _store);
 
 Creation/Removal:
 
@@ -310,7 +310,7 @@ struct bus_attribute {
 
 Declaring:
 
-BUS_ATTR(_name,_mode,_show,_store)
+BUS_ATTR(_name, _mode, _show, _store)
 
 Creation/Removal:
 
@@ -331,7 +331,7 @@ struct driver_attribute {
 
 Declaring:
 
-DRIVER_ATTR(_name,_mode,_show,_store)
+DRIVER_ATTR(_name, _mode, _show, _store)
 
 Creation/Removal:
 
index 357086ed7f64e5307506c225f6c3e46db155f932..fd5dc7a19f0e73361ebafb37141071eae77b9c14 100644 (file)
@@ -2,16 +2,11 @@ Kernel driver lm78
 ==================
 
 Supported chips:
-  * National Semiconductor LM78
+  * National Semiconductor LM78 / LM78-J
     Prefix: 'lm78'
     Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports)
     Datasheet: Publicly available at the National Semiconductor website
                http://www.national.com/
-  * National Semiconductor LM78-J
-    Prefix: 'lm78-j'
-    Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports)
-    Datasheet: Publicly available at the National Semiconductor website
-               http://www.national.com/
   * National Semiconductor LM79
     Prefix: 'lm79'
     Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports)
diff --git a/Documentation/hwmon/w83792d b/Documentation/hwmon/w83792d
new file mode 100644 (file)
index 0000000..8171c28
--- /dev/null
@@ -0,0 +1,174 @@
+Kernel driver w83792d
+=====================
+
+Supported chips:
+  * Winbond W83792D
+    Prefix: 'w83792d'
+    Addresses scanned: I2C 0x2c - 0x2f
+    Datasheet: http://www.winbond.com.tw/E-WINBONDHTM/partner/PDFresult.asp?Pname=1035
+
+Author: Chunhao Huang
+Contact: DZShen <DZShen@Winbond.com.tw>
+
+
+Module Parameters
+-----------------
+
+* init int
+  (default 1)
+  Use 'init=0' to bypass initializing the chip.
+  Try this if your computer crashes when you load the module.
+
+* force_subclients=bus,caddr,saddr,saddr
+  This is used to force the i2c addresses for subclients of
+  a certain chip. Example usage is `force_subclients=0,0x2f,0x4a,0x4b'
+  to force the subclients of chip 0x2f on bus 0 to i2c addresses
+  0x4a and 0x4b.
+
+
+Description
+-----------
+
+This driver implements support for the Winbond W83792AD/D.
+
+Detection of the chip can sometimes be foiled because it can be in an
+internal state that allows no clean access (Bank with ID register is not
+currently selected). If you know the address of the chip, use a 'force'
+parameter; this will put it into a more well-behaved state first.
+
+The driver implements three temperature sensors, seven fan rotation speed
+sensors, nine voltage sensors, and two automatic fan regulation
+strategies called: Smart Fan I (Thermal Cruise mode) and Smart Fan II.
+Automatic fan control mode is possible only for fan1-fan3. Fan4-fan7 can run
+synchronized with selected fan (fan1-fan3). This functionality and manual PWM
+control for fan4-fan7 is not yet implemented.
+
+Temperatures are measured in degrees Celsius and measurement resolution is 1
+degC for temp1 and 0.5 degC for temp2 and temp3. An alarm is triggered when
+the temperature gets higher than the Overtemperature Shutdown value; it stays
+on until the temperature falls below the Hysteresis value.
+
+Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
+triggered if the rotation speed has dropped below a programmable limit. Fan
+readings can be divided by a programmable divider (1, 2, 4, 8, 16, 32, 64 or
+128) to give the readings more range or accuracy.
+
+Voltage sensors (also known as IN sensors) report their values in millivolts.
+An alarm is triggered if the voltage has crossed a programmable minimum
+or maximum limit.
+
+Alarms are provided as output from "realtime status register". Following bits
+are defined:
+
+bit - alarm on:
+0  - in0
+1  - in1
+2  - temp1
+3  - temp2
+4  - temp3
+5  - fan1
+6  - fan2
+7  - fan3
+8  - in2
+9  - in3
+10 - in4
+11 - in5
+12 - in6
+13 - VID change
+14 - chassis
+15 - fan7
+16 - tart1
+17 - tart2
+18 - tart3
+19 - in7
+20 - in8
+21 - fan4
+22 - fan5
+23 - fan6
+
+Tart will be asserted while target temperature cannot be achieved after 3 minutes
+of full speed rotation of corresponding fan.
+
+In addition to the alarms described above, there is a CHAS alarm on the chips
+which triggers if your computer case is open (This one is latched, contrary
+to realtime alarms).
+
+The chips only update values each 3 seconds; reading them more often will
+do no harm, but will return 'old' values.
+
+
+W83792D PROBLEMS
+----------------
+Known problems:
+       - This driver is only for Winbond W83792D C version device, there
+         are also some motherboards with B version W83792D device. The
+         calculation method to in6-in7(measured value, limits) is a little
+         different between C and B version. C or B version can be identified
+         by CR[0x49h].
+       - The function of vid and vrm has not been finished, because I'm NOT
+         very familiar with them. Adding support is welcome.
+       - The function of chassis open detection needs more tests.
+       - If you have ASUS server board and chip was not found: Then you will
+         need to upgrade to latest (or beta) BIOS. If it does not help please
+         contact us.
+
+Fan control
+-----------
+
+Manual mode
+-----------
+
+Works as expected. You just need to specify desired PWM/DC value (fan speed)
+in appropriate pwm# file.
+
+Thermal cruise
+--------------
+
+In this mode, W83792D provides the Smart Fan system to automatically control
+fan speed to keep the temperatures of CPU and the system within specific
+range. At first a wanted temperature and interval must be set. This is done
+via thermal_cruise# file. The tolerance# file serves to create T +- tolerance
+interval. The fan speed will be lowered as long as the current temperature
+remains below the thermal_cruise# +- tolerance# value. Once the temperature
+exceeds the high limit (T+tolerance), the fan will be turned on with a
+specific speed set by pwm# and automatically controlled its PWM duty cycle
+with the temperature varying. Three conditions may occur:
+
+(1) If the temperature still exceeds the high limit, PWM duty
+cycle will increase slowly.
+
+(2) If the temperature goes below the high limit, but still above the low
+limit (T-tolerance), the fan speed will be fixed at the current speed because
+the temperature is in the target range.
+
+(3) If the temperature goes below the low limit, PWM duty cycle will decrease
+slowly to 0 or a preset stop value until the temperature exceeds the low
+limit. (The preset stop value handling is not yet implemented in driver)
+
+Smart Fan II
+------------
+
+W83792D also provides a special mode for fan. Four temperature points are
+available. When related temperature sensors detects the temperature in preset
+temperature region (sf2_point@_fan# +- tolerance#) it will cause fans to run
+on programmed value from sf2_level@_fan#. You need to set four temperatures
+for each fan.
+
+
+/sys files
+----------
+
+pwm[1-3] - this file stores PWM duty cycle or DC value (fan speed) in range:
+       0 (stop) to 255 (full)
+pwm[1-3]_enable - this file controls mode of fan/temperature control:
+            * 0 Disabled
+            * 1 Manual mode
+            * 2 Smart Fan II
+            * 3 Thermal Cruise
+pwm[1-3]_mode - Select PWM of DC mode
+            * 0 DC
+            * 1 PWM
+thermal_cruise[1-3] - Selects the desired temperature for cruise (degC)
+tolerance[1-3] - Value in degrees of Celsius (degC) for +- T
+sf2_point[1-4]_fan[1-3] - four temperature points for each fan for Smart Fan II
+sf2_level[1-3]_fan[1-3] - three PWM/DC levels for each fan for Smart Fan II
index b02002898a09cebd411dbed0c38ba7aeecb69919..96fec562a8e9020fc92a5d8c1de5676bda953cf8 100644 (file)
@@ -4,22 +4,13 @@ Kernel driver max6875
 Supported chips:
   * Maxim MAX6874, MAX6875
     Prefix: 'max6875'
-    Addresses scanned: 0x50, 0x52
+    Addresses scanned: None (see below)
     Datasheet:
         http://pdfserv.maxim-ic.com/en/ds/MAX6874-MAX6875.pdf
 
 Author: Ben Gardner <bgardner@wabtec.com>
 
 
-Module Parameters
------------------
-
-* allow_write int
-  Set to non-zero to enable write permission:
-  *0: Read only
-   1: Read and write
-
-
 Description
 -----------
 
@@ -33,34 +24,85 @@ registers.
 
 The Maxim MAX6874 is a similar, mostly compatible device, with more intputs
 and outputs:
-
              vin     gpi    vout
 MAX6874        6       4       8
 MAX6875        4       3       5
 
-MAX6874 chips can have four different addresses (as opposed to only two for
-the MAX6875). The additional addresses (0x54 and 0x56) are not probed by
-this driver by default, but the probe module parameter can be used if
-needed.
-
-See the datasheet for details on how to program the EEPROM.
+See the datasheet for more information.
 
 
 Sysfs entries
 -------------
 
-eeprom_user   - 512 bytes of user-defined EEPROM space. Only writable if
-                allow_write was set and register 0x43 is 0.
-
-eeprom_config - 70 bytes of config EEPROM. Note that changes will not get
-                loaded into register space until a power cycle or device reset.
-
-reg_config    - 70 bytes of register space. Any changes take affect immediately.
+eeprom        - 512 bytes of user-defined EEPROM space.
 
 
 General Remarks
 ---------------
 
-A typical application will require that the EEPROMs be programmed once and
-never altered afterwards.
+Valid addresses for the MAX6875 are 0x50 and 0x52.
+Valid addresses for the MAX6874 are 0x50, 0x52, 0x54 and 0x56.
+The driver does not probe any address, so you must force the address.
+
+Example:
+$ modprobe max6875 force=0,0x50
+
+The MAX6874/MAX6875 ignores address bit 0, so this driver attaches to multiple
+addresses.  For example, for address 0x50, it also reserves 0x51.
+The even-address instance is called 'max6875', the odd one is 'max6875 subclient'.
+
+
+Programming the chip using i2c-dev
+----------------------------------
+
+Use the i2c-dev interface to access and program the chips.
+Reads and writes are performed differently depending on the address range.
+
+The configuration registers are at addresses 0x00 - 0x45.
+Use i2c_smbus_write_byte_data() to write a register and
+i2c_smbus_read_byte_data() to read a register.
+The command is the register number.
+
+Examples:
+To write a 1 to register 0x45:
+  i2c_smbus_write_byte_data(fd, 0x45, 1);
+
+To read register 0x45:
+  value = i2c_smbus_read_byte_data(fd, 0x45);
+
+
+The configuration EEPROM is at addresses 0x8000 - 0x8045.
+The user EEPROM is at addresses 0x8100 - 0x82ff.
+
+Use i2c_smbus_write_word_data() to write a byte to EEPROM.
+
+The command is the upper byte of the address: 0x80, 0x81, or 0x82.
+The data word is the lower part of the address or'd with data << 8.
+  cmd = address >> 8;
+  val = (address & 0xff) | (data << 8);
+
+Example:
+To write 0x5a to address 0x8003:
+  i2c_smbus_write_word_data(fd, 0x80, 0x5a03);
+
+
+Reading data from the EEPROM is a little more complicated.
+Use i2c_smbus_write_byte_data() to set the read address and then
+i2c_smbus_read_byte() or i2c_smbus_read_i2c_block_data() to read the data.
+
+Example:
+To read data starting at offset 0x8100, first set the address:
+  i2c_smbus_write_byte_data(fd, 0x81, 0x00);
+
+And then read the data
+  value = i2c_smbus_read_byte(fd);
+
+  or
+
+  count = i2c_smbus_read_i2c_block_data(fd, 0x84, buffer);
+
+The block read should read 16 bytes.
+0x84 is the block read command.
+
+See the datasheet for more details.
 
index 8a78a95ae04e25d2aae7d05f6ef91068bccf307f..41ffefbdc60c488e339162454d16043591006f2c 100644 (file)
@@ -115,7 +115,7 @@ CHECKING THROUGH /DEV
 If you try to access an adapter from a userspace program, you will have
 to use the /dev interface. You will still have to check whether the
 functionality you need is supported, of course. This is done using
-the I2C_FUNCS ioctl. An example, adapted from the lm_sensors i2c_detect
+the I2C_FUNCS ioctl. An example, adapted from the lm_sensors i2cdetect
 program, is below:
 
   int file;
index a7adbdd9ea8a51aa46298cd48bdd566b1f9566d3..4849dfd6961c7d2ed2d21eb5e7a65cf72cf0b755 100644 (file)
@@ -1,4 +1,4 @@
-Revision 4, 2004-03-30
+Revision 5, 2005-07-29
 Jean Delvare <khali@linux-fr.org>
 Greg KH <greg@kroah.com>
 
@@ -17,20 +17,22 @@ yours for best results.
 
 Technical changes:
 
-* [Includes] Get rid of "version.h". Replace <linux/i2c-proc.h> with
-  <linux/i2c-sensor.h>. Includes typically look like that:
+* [Includes] Get rid of "version.h" and <linux/i2c-proc.h>.
+  Includes typically look like that:
   #include <linux/module.h>
   #include <linux/init.h>
   #include <linux/slab.h>
   #include <linux/i2c.h>
-  #include <linux/i2c-sensor.h>
-  #include <linux/i2c-vid.h>   /* if you need VRM support */
+  #include <linux/hwmon.h>     /* for hardware monitoring drivers */
+  #include <linux/hwmon-sysfs.h>
+  #include <linux/hwmon-vid.h> /* if you need VRM support */
   #include <asm/io.h>          /* if you have I/O operations */
   Please respect this inclusion order. Some extra headers may be
   required for a given driver (e.g. "lm75.h").
 
-* [Addresses] SENSORS_I2C_END becomes I2C_CLIENT_END, SENSORS_ISA_END
-  becomes I2C_CLIENT_ISA_END.
+* [Addresses] SENSORS_I2C_END becomes I2C_CLIENT_END, ISA addresses
+  are no more handled by the i2c core.
+  SENSORS_INSMOD_<n> becomes I2C_CLIENT_INSMOD_<n>.
 
 * [Client data] Get rid of sysctl_id. Try using standard names for
   register values (for example, temp_os becomes temp_max). You're
@@ -66,13 +68,15 @@ Technical changes:
   if (!(adapter->class & I2C_CLASS_HWMON))
           return 0;
   ISA-only drivers of course don't need this.
+  Call i2c_probe() instead of i2c_detect().
 
 * [Detect] As mentioned earlier, the flags parameter is gone.
   The type_name and client_name strings are replaced by a single
   name string, which will be filled with a lowercase, short string
   (typically the driver name, e.g. "lm75").
   In i2c-only drivers, drop the i2c_is_isa_adapter check, it's
-  useless.
+  useless. Same for isa-only drivers, as the test would always be
+  true. Only hybrid drivers (which are quite rare) still need it.
   The errorN labels are reduced to the number needed. If that number
   is 2 (i2c-only drivers), it is advised that the labels are named
   exit and exit_free. For i2c+isa drivers, labels should be named
@@ -86,6 +90,8 @@ Technical changes:
   device_create_file. Move the driver initialization before any
   sysfs file creation.
   Drop client->id.
+  Drop any 24RF08 corruption prevention you find, as this is now done
+  at the i2c-core level, and doing it twice voids it.
 
 * [Init] Limits must not be set by the driver (can be done later in
   user-space). Chip should not be reset default (although a module
@@ -93,7 +99,8 @@ Technical changes:
   limited to the strictly necessary steps.
 
 * [Detach] Get rid of data, remove the call to
-  i2c_deregister_entry.
+  i2c_deregister_entry. Do not log an error message if
+  i2c_detach_client fails, as i2c-core will now do it for you.
 
 * [Update] Don't access client->data directly, use
   i2c_get_clientdata(client) instead.
index 91664be91ffcd692d62e3602fa8f1b3f9a27f381..077275722a7ccce46cfb1c12e04ed3abe688bd1b 100644 (file)
@@ -148,15 +148,15 @@ are defined in i2c.h to help you support them, as well as a generic
 detection algorithm.
 
 You do not have to use this parameter interface; but don't try to use
-function i2c_probe() (or i2c_detect()) if you don't.
+function i2c_probe() if you don't.
 
 NOTE: If you want to write a `sensors' driver, the interface is slightly
       different! See below.
 
 
 
-Probing classes (i2c)
----------------------
+Probing classes
+---------------
 
 All parameters are given as lists of unsigned 16-bit integers. Lists are
 terminated by I2C_CLIENT_END.
@@ -171,12 +171,18 @@ The following lists are used internally:
    ignore: insmod parameter.
      A list of pairs. The first value is a bus number (-1 for any I2C bus), 
      the second is the I2C address. These addresses are never probed. 
-     This parameter overrules 'normal' and 'probe', but not the 'force' lists.
+     This parameter overrules the 'normal_i2c' list only.
    force: insmod parameter. 
      A list of pairs. The first value is a bus number (-1 for any I2C bus),
      the second is the I2C address. A device is blindly assumed to be on
      the given address, no probing is done. 
 
+Additionally, kind-specific force lists may optionally be defined if
+the driver supports several chip kinds. They are grouped in a
+NULL-terminated list of pointers named forces, those first element if the
+generic force list mentioned above. Each additional list correspond to an
+insmod parameter of the form force_<kind>.
+
 Fortunately, as a module writer, you just have to define the `normal_i2c' 
 parameter. The complete declaration could look like this:
 
@@ -186,66 +192,17 @@ parameter. The complete declaration could look like this:
 
   /* Magic definition of all other variables and things */
   I2C_CLIENT_INSMOD;
+  /* Or, if your driver supports, say, 2 kind of devices: */
+  I2C_CLIENT_INSMOD_2(foo, bar);
+
+If you use the multi-kind form, an enum will be defined for you:
+  enum chips { any_chip, foo, bar, ... }
+You can then (and certainly should) use it in the driver code.
 
 Note that you *have* to call the defined variable `normal_i2c',
 without any prefix!
 
 
-Probing classes (sensors)
--------------------------
-
-If you write a `sensors' driver, you use a slightly different interface.
-As well as I2C addresses, we have to cope with ISA addresses. Also, we
-use a enum of chip types. Don't forget to include `sensors.h'.
-
-The following lists are used internally. They are all lists of integers.
-
-   normal_i2c: filled in by the module writer. Terminated by SENSORS_I2C_END.
-     A list of I2C addresses which should normally be examined.
-   normal_isa: filled in by the module writer. Terminated by SENSORS_ISA_END.
-     A list of ISA addresses which should normally be examined.
-   probe: insmod parameter. Initialize this list with SENSORS_I2C_END values.
-     A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for
-     the ISA bus, -1 for any I2C bus), the second is the address. These
-     addresses are also probed, as if they were in the 'normal' list.
-   ignore: insmod parameter. Initialize this list with SENSORS_I2C_END values.
-     A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for
-     the ISA bus, -1 for any I2C bus), the second is the I2C address. These
-     addresses are never probed. This parameter overrules 'normal' and 
-     'probe', but not the 'force' lists.
-
-Also used is a list of pointers to sensors_force_data structures:
-   force_data: insmod parameters. A list, ending with an element of which
-     the force field is NULL.
-     Each element contains the type of chip and a list of pairs.
-     The first value is a bus number (SENSORS_ISA_BUS for the ISA bus, 
-     -1 for any I2C bus), the second is the address. 
-     These are automatically translated to insmod variables of the form
-     force_foo.
-
-So we have a generic insmod variabled `force', and chip-specific variables
-`force_CHIPNAME'.
-
-Fortunately, as a module writer, you just have to define the `normal_i2c' 
-and `normal_isa' parameters, and define what chip names are used. 
-The complete declaration could look like this:
-  /* Scan i2c addresses 0x37, and 0x48 to 0x4f */
-  static unsigned short normal_i2c[] = { 0x37, 0x48, 0x49, 0x4a, 0x4b, 0x4c,
-                                         0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
-  /* Scan ISA address 0x290 */
-  static unsigned int normal_isa[] = {0x0290,SENSORS_ISA_END};
-
-  /* Define chips foo and bar, as well as all module parameters and things */
-  SENSORS_INSMOD_2(foo,bar);
-
-If you have one chip, you use macro SENSORS_INSMOD_1(chip), if you have 2
-you use macro SENSORS_INSMOD_2(chip1,chip2), etc. If you do not want to
-bother with chip types, you can use SENSORS_INSMOD_0.
-
-A enum is automatically defined as follows:
-  enum chips { any_chip, chip1, chip2, ... }
-
-
 Attaching to an adapter
 -----------------------
 
@@ -264,17 +221,10 @@ detected at a specific address, another callback is called.
     return i2c_probe(adapter,&addr_data,&foo_detect_client);
   }
 
-For `sensors' drivers, use the i2c_detect function instead:
-  
-  int foo_attach_adapter(struct i2c_adapter *adapter)
-  { 
-    return i2c_detect(adapter,&addr_data,&foo_detect_client);
-  }
-
 Remember, structure `addr_data' is defined by the macros explained above,
 so you do not have to define it yourself.
 
-The i2c_probe or i2c_detect function will call the foo_detect_client
+The i2c_probe function will call the foo_detect_client
 function only for those i2c addresses that actually have a device on
 them (unless a `force' parameter was used). In addition, addresses that
 are already in use (by some other registered client) are skipped.
@@ -283,19 +233,18 @@ are already in use (by some other registered client) are skipped.
 The detect client function
 --------------------------
 
-The detect client function is called by i2c_probe or i2c_detect.
-The `kind' parameter contains 0 if this call is due to a `force'
-parameter, and -1 otherwise (for i2c_detect, it contains 0 if
-this call is due to the generic `force' parameter, and the chip type
-number if it is due to a specific `force' parameter).
+The detect client function is called by i2c_probe. The `kind' parameter
+contains -1 for a probed detection, 0 for a forced detection, or a positive
+number for a forced detection with a chip type forced.
 
 Below, some things are only needed if this is a `sensors' driver. Those
 parts are between /* SENSORS ONLY START */ and /* SENSORS ONLY END */
 markers. 
 
-This function should only return an error (any value != 0) if there is
-some reason why no more detection should be done anymore. If the
-detection just fails for this address, return 0.
+Returning an error different from -ENODEV in a detect function will cause
+the detection to stop: other addresses and adapters won't be scanned.
+This should only be done on fatal or internal errors, such as a memory
+shortage or i2c_attach_client failing.
 
 For now, you can ignore the `flags' parameter. It is there for future use.
 
@@ -320,11 +269,10 @@ For now, you can ignore the `flags' parameter. It is there for future use.
     const char *type_name = "";
     int is_isa = i2c_is_isa_adapter(adapter);
 
-    if (is_isa) {
+    /* Do this only if the chip can additionally be found on the ISA bus
+       (hybrid chip). */
 
-      /* If this client can't be on the ISA bus at all, we can stop now
-         (call `goto ERROR0'). But for kicks, we will assume it is all
-         right. */
+    if (is_isa) {
 
       /* Discard immediately if this ISA range is already used */
       if (check_region(address,FOO_EXTENT))
@@ -495,15 +443,13 @@ much simpler than the attachment code, fortunately!
     /* SENSORS ONLY END */
 
     /* Try to detach the client from i2c space */
-    if ((err = i2c_detach_client(client))) {
-      printk("foo.o: Client deregistration failed, client not detached.\n");
+    if ((err = i2c_detach_client(client)))
       return err;
-    }
 
-    /* SENSORS ONLY START */
+    /* HYBRID SENSORS CHIP ONLY START */
     if i2c_is_isa_client(client)
       release_region(client->addr,LM78_EXTENT);
-    /* SENSORS ONLY END */
+    /* HYBRID SENSORS CHIP ONLY END */
 
     kfree(client); /* Frees client data too, if allocated at the same time */
     return 0;
index 2616a58a5a4b829a3fb951e305cf6af37aee4cfa..9a1586590d827fcb11943247362c527dbe419105 100644 (file)
@@ -872,7 +872,13 @@ When kbuild executes the following steps are followed (roughly):
        Assignments to $(targets) are without $(obj)/ prefix.
        if_changed may be used in conjunction with custom commands as
        defined in 6.7 "Custom kbuild commands".
+
        Note: It is a typical mistake to forget the FORCE prerequisite.
+       Another common pitfall is that whitespace is sometimes
+       significant; for instance, the below will fail (note the extra space
+       after the comma):
+               target: source(s) FORCE
+       #WRONG!#        $(call if_changed, ld/objcopy/gzip)
 
     ld
        Link target. Often LDFLAGS_$@ is used to set specific options to ld.
diff --git a/Documentation/networking/README.ipw2100 b/Documentation/networking/README.ipw2100
new file mode 100644 (file)
index 0000000..2046948
--- /dev/null
@@ -0,0 +1,246 @@
+
+===========================
+Intel(R) PRO/Wireless 2100 Network Connection Driver for Linux
+README.ipw2100
+
+March 14, 2005
+
+===========================
+Index
+---------------------------
+0. Introduction
+1. Release 1.1.0 Current Features
+2. Command Line Parameters
+3. Sysfs Helper Files
+4. Radio Kill Switch
+5. Dynamic Firmware
+6. Power Management
+7. Support
+8. License
+
+
+===========================
+0. Introduction
+------------ -----   -----       ----       ---       --         -     
+
+This document provides a brief overview of the features supported by the 
+IPW2100 driver project.  The main project website, where the latest 
+development version of the driver can be found, is:
+
+       http://ipw2100.sourceforge.net
+
+There you can find the not only the latest releases, but also information about
+potential fixes and patches, as well as links to the development mailing list
+for the driver project.
+
+
+===========================
+1. Release 1.1.0 Current Supported Features
+---------------------------     
+- Managed (BSS) and Ad-Hoc (IBSS)
+- WEP (shared key and open)
+- Wireless Tools support 
+- 802.1x (tested with XSupplicant 1.0.1)
+
+Enabled (but not supported) features:
+- Monitor/RFMon mode
+- WPA/WPA2
+
+The distinction between officially supported and enabled is a reflection
+on the amount of validation and interoperability testing that has been
+performed on a given feature.
+
+
+===========================
+2. Command Line Parameters
+---------------------------     
+
+If the driver is built as a module, the following optional parameters are used
+by entering them on the command line with the modprobe command using this
+syntax:
+
+       modprobe ipw2100 [<option>=<VAL1><,VAL2>...]
+
+For example, to disable the radio on driver loading, enter:
+
+       modprobe ipw2100 disable=1
+
+The ipw2100 driver supports the following module parameters:
+
+Name           Value           Example:
+debug          0x0-0xffffffff  debug=1024
+mode           0,1,2           mode=1   /* AdHoc */
+channel                int             channel=3 /* Only valid in AdHoc or Monitor */
+associate      boolean         associate=0 /* Do NOT auto associate */
+disable                boolean         disable=1 /* Do not power the HW */
+
+
+===========================
+3. Sysfs Helper Files
+---------------------------     
+
+There are several ways to control the behavior of the driver.  Many of the 
+general capabilities are exposed through the Wireless Tools (iwconfig).  There
+are a few capabilities that are exposed through entries in the Linux Sysfs.
+
+
+----- Driver Level ------
+For the driver level files, look in /sys/bus/pci/drivers/ipw2100/
+
+  debug_level  
+       
+       This controls the same global as the 'debug' module parameter.  For 
+        information on the various debugging levels available, run the 'dvals'
+       script found in the driver source directory.
+
+       NOTE:  'debug_level' is only enabled if CONFIG_IPW2100_DEBUG is turn
+              on.
+
+----- Device Level ------
+For the device level files look in
+       
+       /sys/bus/pci/drivers/ipw2100/{PCI-ID}/
+
+For example:
+       /sys/bus/pci/drivers/ipw2100/0000:02:01.0
+
+For the device level files, see /sys/bus/pci/drivers/ipw2100:
+
+  rf_kill
+       read - 
+       0 = RF kill not enabled (radio on)
+       1 = SW based RF kill active (radio off)
+       2 = HW based RF kill active (radio off)
+       3 = Both HW and SW RF kill active (radio off)
+       write -
+       0 = If SW based RF kill active, turn the radio back on
+       1 = If radio is on, activate SW based RF kill
+
+       NOTE: If you enable the SW based RF kill and then toggle the HW
+       based RF kill from ON -> OFF -> ON, the radio will NOT come back on
+
+
+===========================
+4. Radio Kill Switch
+---------------------------
+Most laptops provide the ability for the user to physically disable the radio.
+Some vendors have implemented this as a physical switch that requires no
+software to turn the radio off and on.  On other laptops, however, the switch
+is controlled through a button being pressed and a software driver then making
+calls to turn the radio off and on.  This is referred to as a "software based
+RF kill switch"
+
+See the Sysfs helper file 'rf_kill' for determining the state of the RF switch
+on your system.
+
+
+===========================
+5. Dynamic Firmware
+---------------------------     
+As the firmware is licensed under a restricted use license, it can not be 
+included within the kernel sources.  To enable the IPW2100 you will need a 
+firmware image to load into the wireless NIC's processors.
+
+You can obtain these images from <http://ipw2100.sf.net/firmware.php>.
+
+See INSTALL for instructions on installing the firmware.
+
+
+===========================
+6. Power Management
+---------------------------     
+The IPW2100 supports the configuration of the Power Save Protocol 
+through a private wireless extension interface.  The IPW2100 supports 
+the following different modes:
+
+       off     No power management.  Radio is always on.
+       on      Automatic power management
+       1-5     Different levels of power management.  The higher the 
+               number the greater the power savings, but with an impact to 
+               packet latencies. 
+
+Power management works by powering down the radio after a certain 
+interval of time has passed where no packets are passed through the 
+radio.  Once powered down, the radio remains in that state for a given 
+period of time.  For higher power savings, the interval between last 
+packet processed to sleep is shorter and the sleep period is longer.
+
+When the radio is asleep, the access point sending data to the station 
+must buffer packets at the AP until the station wakes up and requests 
+any buffered packets.  If you have an AP that does not correctly support 
+the PSP protocol you may experience packet loss or very poor performance 
+while power management is enabled.  If this is the case, you will need 
+to try and find a firmware update for your AP, or disable power 
+management (via `iwconfig eth1 power off`)
+
+To configure the power level on the IPW2100 you use a combination of 
+iwconfig and iwpriv.  iwconfig is used to turn power management on, off, 
+and set it to auto.
+
+       iwconfig eth1 power off    Disables radio power down
+       iwconfig eth1 power on     Enables radio power management to 
+                                  last set level (defaults to AUTO)
+       iwpriv eth1 set_power 0    Sets power level to AUTO and enables 
+                                  power management if not previously 
+                                  enabled.
+       iwpriv eth1 set_power 1-5  Set the power level as specified, 
+                                  enabling power management if not 
+                                  previously enabled.
+
+You can view the current power level setting via:
+       
+       iwpriv eth1 get_power
+
+It will return the current period or timeout that is configured as a string
+in the form of xxxx/yyyy (z) where xxxx is the timeout interval (amount of
+time after packet processing), yyyy is the period to sleep (amount of time to 
+wait before powering the radio and querying the access point for buffered
+packets), and z is the 'power level'.  If power management is turned off the
+xxxx/yyyy will be replaced with 'off' -- the level reported will be the active
+level if `iwconfig eth1 power on` is invoked.
+
+
+===========================
+7. Support
+---------------------------     
+
+For general development information and support,
+go to:
+       
+    http://ipw2100.sf.net/
+
+The ipw2100 1.1.0 driver and firmware can be downloaded from:  
+
+    http://support.intel.com
+
+For installation support on the ipw2100 1.1.0 driver on Linux kernels 
+2.6.8 or greater, email support is available from:  
+
+    http://supportmail.intel.com
+
+===========================
+8. License
+---------------------------     
+
+  Copyright(c) 2003 - 2005 Intel Corporation. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify it 
+  under the terms of the GNU General Public License (version 2) as 
+  published by the Free Software Foundation.
+  
+  This program is distributed in the hope that it will be useful, but WITHOUT 
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
+  more details.
+  
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc., 59 
+  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+  
+  The full GNU General Public License is included in this distribution in the
+  file called LICENSE.
+  
+  License Contact Information:
+  James P. Ketrenos <ipw2100-admin@linux.intel.com>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
diff --git a/Documentation/networking/README.ipw2200 b/Documentation/networking/README.ipw2200
new file mode 100644 (file)
index 0000000..6916080
--- /dev/null
@@ -0,0 +1,300 @@
+
+Intel(R) PRO/Wireless 2915ABG Driver for Linux in support of:
+
+Intel(R) PRO/Wireless 2200BG Network Connection 
+Intel(R) PRO/Wireless 2915ABG Network Connection 
+
+Note: The Intel(R) PRO/Wireless 2915ABG Driver for Linux and Intel(R) 
+PRO/Wireless 2200BG Driver for Linux is a unified driver that works on 
+both hardware adapters listed above. In this document the Intel(R) 
+PRO/Wireless 2915ABG Driver for Linux will be used to reference the 
+unified driver.
+
+Copyright (C) 2004-2005, Intel Corporation
+
+README.ipw2200
+
+Version: 1.0.0
+Date   : January 31, 2005
+
+
+Index
+-----------------------------------------------
+1.   Introduction
+1.1. Overview of features
+1.2. Module parameters
+1.3. Wireless Extension Private Methods
+1.4. Sysfs Helper Files
+2.   About the Version Numbers
+3.   Support
+4.   License
+
+
+1.   Introduction
+-----------------------------------------------
+The following sections attempt to provide a brief introduction to using 
+the Intel(R) PRO/Wireless 2915ABG Driver for Linux.
+
+This document is not meant to be a comprehensive manual on 
+understanding or using wireless technologies, but should be sufficient 
+to get you moving without wires on Linux.
+
+For information on building and installing the driver, see the INSTALL
+file.
+
+
+1.1. Overview of Features
+-----------------------------------------------
+The current release (1.0.0) supports the following features:
+
++ BSS mode (Infrastructure, Managed)
++ IBSS mode (Ad-Hoc)
++ WEP (OPEN and SHARED KEY mode)
++ 802.1x EAP via wpa_supplicant and xsupplicant
++ Wireless Extension support 
++ Full B and G rate support (2200 and 2915)
++ Full A rate support (2915 only)
++ Transmit power control
++ S state support (ACPI suspend/resume)
++ long/short preamble support
+
+
+
+1.2. Command Line Parameters
+-----------------------------------------------
+
+Like many modules used in the Linux kernel, the Intel(R) PRO/Wireless 
+2915ABG Driver for Linux allows certain configuration options to be 
+provided as module parameters.  The most common way to specify a module 
+parameter is via the command line.  
+
+The general form is:
+
+% modprobe ipw2200 parameter=value
+
+Where the supported parameter are:
+
+  associate
+       Set to 0 to disable the auto scan-and-associate functionality of the
+       driver.  If disabled, the driver will not attempt to scan 
+       for and associate to a network until it has been configured with 
+       one or more properties for the target network, for example configuring 
+       the network SSID.  Default is 1 (auto-associate)
+       
+       Example: % modprobe ipw2200 associate=0
+
+  auto_create
+       Set to 0 to disable the auto creation of an Ad-Hoc network 
+       matching the channel and network name parameters provided.  
+       Default is 1.
+
+  channel
+       channel number for association.  The normal method for setting
+        the channel would be to use the standard wireless tools
+        (i.e. `iwconfig eth1 channel 10`), but it is useful sometimes
+       to set this while debugging.  Channel 0 means 'ANY'
+
+  debug
+       If using a debug build, this is used to control the amount of debug
+       info is logged.  See the 'dval' and 'load' script for more info on
+       how to use this (the dval and load scripts are provided as part 
+       of the ipw2200 development snapshot releases available from the 
+       SourceForge project at http://ipw2200.sf.net)
+
+  mode
+       Can be used to set the default mode of the adapter.  
+       0 = Managed, 1 = Ad-Hoc
+
+
+1.3. Wireless Extension Private Methods
+-----------------------------------------------
+
+As an interface designed to handle generic hardware, there are certain 
+capabilities not exposed through the normal Wireless Tool interface.  As 
+such, a provision is provided for a driver to declare custom, or 
+private, methods.  The Intel(R) PRO/Wireless 2915ABG Driver for Linux 
+defines several of these to configure various settings.
+
+The general form of using the private wireless methods is:
+
+       % iwpriv $IFNAME method parameters
+
+Where $IFNAME is the interface name the device is registered with 
+(typically eth1, customized via one of the various network interface
+name managers, such as ifrename)
+
+The supported private methods are:
+
+  get_mode
+       Can be used to report out which IEEE mode the driver is 
+       configured to support.  Example:
+       
+       % iwpriv eth1 get_mode
+       eth1    get_mode:802.11bg (6)
+
+  set_mode
+       Can be used to configure which IEEE mode the driver will 
+       support.  
+
+       Usage:
+       % iwpriv eth1 set_mode {mode}
+       Where {mode} is a number in the range 1-7:
+       1       802.11a (2915 only)
+       2       802.11b
+       3       802.11ab (2915 only)
+       4       802.11g 
+       5       802.11ag (2915 only)
+       6       802.11bg
+       7       802.11abg (2915 only)
+
+  get_preamble
+       Can be used to report configuration of preamble length.
+
+  set_preamble
+       Can be used to set the configuration of preamble length:
+
+       Usage:
+       % iwpriv eth1 set_preamble {mode}
+       Where {mode} is one of:
+       1       Long preamble only
+       0       Auto (long or short based on connection)
+       
+
+1.4. Sysfs Helper Files:
+-----------------------------------------------
+
+The Linux kernel provides a pseudo file system that can be used to 
+access various components of the operating system.  The Intel(R) 
+PRO/Wireless 2915ABG Driver for Linux exposes several configuration 
+parameters through this mechanism.
+
+An entry in the sysfs can support reading and/or writing.  You can 
+typically query the contents of a sysfs entry through the use of cat, 
+and can set the contents via echo.  For example:
+
+% cat /sys/bus/pci/drivers/ipw2200/debug_level
+
+Will report the current debug level of the driver's logging subsystem 
+(only available if CONFIG_IPW_DEBUG was configured when the driver was 
+built).
+
+You can set the debug level via:
+
+% echo $VALUE > /sys/bus/pci/drivers/ipw2200/debug_level
+
+Where $VALUE would be a number in the case of this sysfs entry.  The 
+input to sysfs files does not have to be a number.  For example, the 
+firmware loader used by hotplug utilizes sysfs entries for transferring 
+the firmware image from user space into the driver.
+
+The Intel(R) PRO/Wireless 2915ABG Driver for Linux exposes sysfs entries 
+at two levels -- driver level, which apply to all instances of the 
+driver (in the event that there are more than one device installed) and 
+device level, which applies only to the single specific instance.
+
+
+1.4.1 Driver Level Sysfs Helper Files
+-----------------------------------------------
+
+For the driver level files, look in /sys/bus/pci/drivers/ipw2200/
+
+  debug_level  
+       
+       This controls the same global as the 'debug' module parameter
+
+
+1.4.2 Device Level Sysfs Helper Files
+-----------------------------------------------
+
+For the device level files, look in
+       
+       /sys/bus/pci/drivers/ipw2200/{PCI-ID}/
+
+For example:
+       /sys/bus/pci/drivers/ipw2200/0000:02:01.0
+
+For the device level files, see /sys/bus/pci/[drivers/ipw2200:
+
+  rf_kill
+       read - 
+       0 = RF kill not enabled (radio on)
+       1 = SW based RF kill active (radio off)
+       2 = HW based RF kill active (radio off)
+       3 = Both HW and SW RF kill active (radio off)
+       write -
+       0 = If SW based RF kill active, turn the radio back on
+       1 = If radio is on, activate SW based RF kill
+
+       NOTE: If you enable the SW based RF kill and then toggle the HW
+       based RF kill from ON -> OFF -> ON, the radio will NOT come back on
+       
+  ucode 
+       read-only access to the ucode version number
+
+
+2.   About the Version Numbers
+-----------------------------------------------
+
+Due to the nature of open source development projects, there are 
+frequently changes being incorporated that have not gone through 
+a complete validation process.  These changes are incorporated into 
+development snapshot releases.
+
+Releases are numbered with a three level scheme: 
+
+       major.minor.development
+
+Any version where the 'development' portion is 0 (for example
+1.0.0, 1.1.0, etc.) indicates a stable version that will be made 
+available for kernel inclusion.
+
+Any version where the 'development' portion is not a 0 (for
+example 1.0.1, 1.1.5, etc.) indicates a development version that is
+being made available for testing and cutting edge users.  The stability 
+and functionality of the development releases are not know.  We make
+efforts to try and keep all snapshots reasonably stable, but due to the
+frequency of their release, and the desire to get those releases 
+available as quickly as possible, unknown anomalies should be expected.
+
+The major version number will be incremented when significant changes
+are made to the driver.  Currently, there are no major changes planned.
+
+
+3.  Support
+-----------------------------------------------
+
+For installation support of the 1.0.0 version, you can contact 
+http://supportmail.intel.com, or you can use the open source project 
+support.
+
+For general information and support, go to:
+       
+    http://ipw2200.sf.net/
+
+
+4.  License
+-----------------------------------------------
+
+  Copyright(c) 2003 - 2005 Intel Corporation. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify it 
+  under the terms of the GNU General Public License version 2 as 
+  published by the Free Software Foundation.
+  
+  This program is distributed in the hope that it will be useful, but WITHOUT 
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
+  more details.
+  
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc., 59 
+  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+  
+  The full GNU General Public License is included in this distribution in the
+  file called LICENSE.
+  
+  Contact Information:
+  James P. Ketrenos <ipw2100-admin@linux.intel.com>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+
diff --git a/Documentation/power/swsusp-dmcrypt.txt b/Documentation/power/swsusp-dmcrypt.txt
new file mode 100644 (file)
index 0000000..59931b4
--- /dev/null
@@ -0,0 +1,138 @@
+Author: Andreas Steinmetz <ast@domdv.de>
+
+
+How to use dm-crypt and swsusp together:
+========================================
+
+Some prerequisites:
+You know how dm-crypt works. If not, visit the following web page:
+http://www.saout.de/misc/dm-crypt/
+You have read Documentation/power/swsusp.txt and understand it.
+You did read Documentation/initrd.txt and know how an initrd works.
+You know how to create or how to modify an initrd.
+
+Now your system is properly set up, your disk is encrypted except for
+the swap device(s) and the boot partition which may contain a mini
+system for crypto setup and/or rescue purposes. You may even have
+an initrd that does your current crypto setup already.
+
+At this point you want to encrypt your swap, too. Still you want to
+be able to suspend using swsusp. This, however, means that you
+have to be able to either enter a passphrase or that you read
+the key(s) from an external device like a pcmcia flash disk
+or an usb stick prior to resume. So you need an initrd, that sets
+up dm-crypt and then asks swsusp to resume from the encrypted
+swap device.
+
+The most important thing is that you set up dm-crypt in such
+a way that the swap device you suspend to/resume from has
+always the same major/minor within the initrd as well as
+within your running system. The easiest way to achieve this is
+to always set up this swap device first with dmsetup, so that
+it will always look like the following:
+
+brw-------  1 root root 254, 0 Jul 28 13:37 /dev/mapper/swap0
+
+Now set up your kernel to use /dev/mapper/swap0 as the default
+resume partition, so your kernel .config contains:
+
+CONFIG_PM_STD_PARTITION="/dev/mapper/swap0"
+
+Prepare your boot loader to use the initrd you will create or
+modify. For lilo the simplest setup looks like the following
+lines:
+
+image=/boot/vmlinuz
+initrd=/boot/initrd.gz
+label=linux
+append="root=/dev/ram0 init=/linuxrc rw"
+
+Finally you need to create or modify your initrd. Lets assume
+you create an initrd that reads the required dm-crypt setup
+from a pcmcia flash disk card. The card is formatted with an ext2
+fs which resides on /dev/hde1 when the card is inserted. The
+card contains at least the encrypted swap setup in a file
+named "swapkey". /etc/fstab of your initrd contains something
+like the following:
+
+/dev/hda1   /mnt    ext3      ro                            0 0
+none        /proc   proc      defaults,noatime,nodiratime   0 0
+none        /sys    sysfs     defaults,noatime,nodiratime   0 0
+
+/dev/hda1 contains an unencrypted mini system that sets up all
+of your crypto devices, again by reading the setup from the
+pcmcia flash disk. What follows now is a /linuxrc for your
+initrd that allows you to resume from encrypted swap and that
+continues boot with your mini system on /dev/hda1 if resume
+does not happen:
+
+#!/bin/sh
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+mount /proc
+mount /sys
+mapped=0
+noresume=`grep -c noresume /proc/cmdline`
+if [ "$*" != "" ]
+then
+  noresume=1
+fi
+dmesg -n 1
+/sbin/cardmgr -q
+for i in 1 2 3 4 5 6 7 8 9 0
+do
+  if [ -f /proc/ide/hde/media ]
+  then
+    usleep 500000
+    mount -t ext2 -o ro /dev/hde1 /mnt
+    if [ -f /mnt/swapkey ]
+    then
+      dmsetup create swap0 /mnt/swapkey > /dev/null 2>&1 && mapped=1
+    fi
+    umount /mnt
+    break
+  fi
+  usleep 500000
+done
+killproc /sbin/cardmgr
+dmesg -n 6
+if [ $mapped = 1 ]
+then
+  if [ $noresume != 0 ]
+  then
+    mkswap /dev/mapper/swap0 > /dev/null 2>&1
+  fi
+  echo 254:0 > /sys/power/resume
+  dmsetup remove swap0
+fi
+umount /sys
+mount /mnt
+umount /proc
+cd /mnt
+pivot_root . mnt
+mount /proc
+umount -l /mnt
+umount /proc
+exec chroot . /sbin/init $* < dev/console > dev/console 2>&1
+
+Please don't mind the weird loop above, busybox's msh doesn't know
+the let statement. Now, what is happening in the script?
+First we have to decide if we want to try to resume, or not.
+We will not resume if booting with "noresume" or any parameters
+for init like "single" or "emergency" as boot parameters.
+
+Then we need to set up dmcrypt with the setup data from the
+pcmcia flash disk. If this succeeds we need to reset the swap
+device if we don't want to resume. The line "echo 254:0 > /sys/power/resume"
+then attempts to resume from the first device mapper device.
+Note that it is important to set the device in /sys/power/resume,
+regardless if resuming or not, otherwise later suspend will fail.
+If resume starts, script execution terminates here.
+
+Otherwise we just remove the encrypted swap device and leave it to the
+mini system on /dev/hda1 to set the whole crypto up (it is up to
+you to modify this to your taste).
+
+What then follows is the well known process to change the root
+file system and continue booting from there. I prefer to unmount
+the initrd prior to continue booting but it is up to you to modify
+this.
index 7a6b7896645942d69815ee3b37594618367a9069..ddf907fbcc0570ba3acf83ae87a8d702e637871b 100644 (file)
@@ -311,3 +311,10 @@ As a rule of thumb use encrypted swap to protect your data while your
 system is shut down or suspended. Additionally use the encrypted
 suspend image to prevent sensitive data from being stolen after
 resume.
+
+Q: Why we cannot suspend to a swap file?
+
+A: Because accessing swap file needs the filesystem mounted, and
+filesystem might do something wrong (like replaying the journal)
+during mount. [Probably could be solved by modifying every filesystem
+to support some kind of "really read-only!" option. Patches welcome.]
index 7a4a5036d123515d0aced385ab21b427a3de3089..1a44e8acb54cff7575abe6ad0e90b57416474ddd 100644 (file)
@@ -46,6 +46,12 @@ There are a few types of systems where video works after S3 resume:
   POSTing bios works. Ole Rohne has patch to do just that at
   http://dev.gentoo.org/~marineam/patch-radeonfb-2.6.11-rc2-mm2.
 
+(8) on some systems, you can use the video_post utility mentioned here:
+  http://bugzilla.kernel.org/show_bug.cgi?id=3670. Do echo 3 > /sys/power/state
+  && /usr/sbin/video_post - which will initialize the display in console mode.
+  If  you are in X, you can switch to a virtual terminal and back to X using
+  CTRL+ALT+F1 - CTRL+ALT+F7 to get the display working in graphical mode again.
+
 Now, if you pass acpi_sleep=something, and it does not work with your
 bios, you'll get a hard crash during resume. Be careful. Also it is
 safest to do your experiments with plain old VGA console. The vesafb
@@ -64,7 +70,8 @@ Model                           hack (or "how to do it")
 ------------------------------------------------------------------------------
 Acer Aspire 1406LC             ole's late BIOS init (7), turn off DRI
 Acer TM 242FX                  vbetool (6)
-Acer TM C300                    vga=normal (only suspend on console, not in X), vbetool (6)
+Acer TM C110                   video_post (8)
+Acer TM C300                    vga=normal (only suspend on console, not in X), vbetool (6) or video_post (8)
 Acer TM 4052LCi                        s3_bios (2)
 Acer TM 636Lci                 s3_bios vga=normal (2)
 Acer TM 650 (Radeon M7)                vga=normal plus boot-radeon (5) gets text console back
index ac7eabbf662aaf9d83814debb4f39d0c79043faf..87856d3cfb67fbcd16baf475c262c909f862cbb1 100644 (file)
@@ -111,24 +111,17 @@ hardware.
        Interrupts: locally disabled.
        This call must not sleep
 
-  stop_tx(port,tty_stop)
+  stop_tx(port)
        Stop transmitting characters.  This might be due to the CTS
        line becoming inactive or the tty layer indicating we want
-       to stop transmission.
-
-       tty_stop: 1 if this call is due to the TTY layer issuing a
-                 TTY stop to the driver (equiv to rs_stop).
+       to stop transmission due to an XOFF character.
 
        Locking: port->lock taken.
        Interrupts: locally disabled.
        This call must not sleep
 
-  start_tx(port,tty_start)
-       start transmitting characters.  (incidentally, nonempty will
-       always be nonzero, and shouldn't be used - it will be dropped).
-
-       tty_start: 1 if this call was due to the TTY layer issuing
-                  a TTY start to the driver (equiv to rs_start)
+  start_tx(port)
+       start transmitting characters.
 
        Locking: port->lock taken.
        Interrupts: locally disabled.
index c3ef09ae3bb114f484247389776415ce401ed405..f366fa956179505cc602ff79f90adc83f95f7a77 100644 (file)
@@ -83,19 +83,18 @@ single address space optimization, so that the zap_page_range (from
 vmtruncate) does not lose sending ipi's to cloned threads that might 
 be spawned underneath it and go to user mode to drag in pte's into tlbs.
 
-swap_list_lock/swap_device_lock
--------------------------------
+swap_lock
+--------------
 The swap devices are chained in priority order from the "swap_list" header. 
 The "swap_list" is used for the round-robin swaphandle allocation strategy.
 The #free swaphandles is maintained in "nr_swap_pages". These two together
-are protected by the swap_list_lock. 
+are protected by the swap_lock.
 
-The swap_device_lock, which is per swap device, protects the reference 
-counts on the corresponding swaphandles, maintained in the "swap_map"
-array, and the "highest_bit" and "lowest_bit" fields.
+The swap_lock also protects all the device reference counts on the
+corresponding swaphandles, maintained in the "swap_map" array, and the
+"highest_bit" and "lowest_bit" fields.
 
-Both of these are spinlocks, and are never acquired from intr level. The
-locking hierarchy is swap_list_lock -> swap_device_lock.
+The swap_lock is a spinlock, and is never acquired from intr level.
 
 To prevent races between swap space deletion or async readahead swapins
 deciding whether a swap handle is being used, ie worthy of being read in
index 28388aa700c67d62d604aed064a14d463f6d1906..c5beb548cfc42b781fd825ff9345f411f087897d 100644 (file)
@@ -228,6 +228,26 @@ advantechwdt.c -- Advantech Single Board Computer
        The GETSTATUS call returns if the device is open or not.
        [FIXME -- silliness again?]
        
+booke_wdt.c -- PowerPC BookE Watchdog Timer
+
+       Timeout default varies according to frequency, supports
+       SETTIMEOUT
+
+       Watchdog can not be turned off, CONFIG_WATCHDOG_NOWAYOUT
+       does not make sense
+
+       GETSUPPORT returns the watchdog_info struct, and
+       GETSTATUS returns the supported options. GETBOOTSTATUS
+       returns a 1 if the last reset was caused by the
+       watchdog and a 0 otherwise. This watchdog can not be
+       disabled once it has been started. The wdt_period kernel
+       parameter selects which bit of the time base changing
+       from 0->1 will trigger the watchdog exception. Changing
+       the timeout from the ioctl calls will change the
+       wdt_period as defined above. Finally if you would like to
+       replace the default Watchdog Handler you can implement the
+       WatchdogHandler() function in your own code.
+
 eurotechwdt.c -- Eurotech CPU-1220/1410
 
        The timeout can be set using the SETTIMEOUT ioctl and defaults
index e8214fe53a5e919feb0e640b189d3b6126a991e3..7e1f67130a16d595d2a7f5879dce0469993de085 100644 (file)
@@ -933,6 +933,13 @@ M: khc@pm.waw.pl
 W:     http://www.kernel.org/pub/linux/utils/net/hdlc/
 S:     Maintained
 
+HARDWARE MONITORING
+P:     Jean Delvare
+M:     khali@linux-fr.org
+L:     lm-sensors@lm-sensors.org
+W:     http://www.lm-sensors.nu/
+S:     Maintained
+
 HARMONY SOUND DRIVER
 P:     Kyle McMartin
 M:     kyle@parisc-linux.org
@@ -991,6 +998,13 @@ M: mike.miller@hp.com
 L:     iss_storagedev@hp.com
 S:     Supported
  
+HOST AP DRIVER
+P:     Jouni Malinen
+M:     jkmaline@cc.hut.fi
+L:     hostap@shmoo.com
+W:     http://hostap.epitest.fi/
+S:     Maintained
+
 HP100: Driver for HP 10/100 Mbit/s Voice Grade Network Adapter Series
 P:     Jaroslav Kysela
 M:     perex@suse.cz
@@ -1007,7 +1021,7 @@ P:        William Irwin
 M:     wli@holomorphy.com
 S:     Maintained
 
-I2C AND SENSORS DRIVERS
+I2C SUBSYSTEM
 P:     Greg Kroah-Hartman
 M:     greg@kroah.com
 P:     Jean Delvare
@@ -2643,11 +2657,6 @@ S:       Maintained
 UCLINUX (AND M68KNOMMU)
 P:     Greg Ungerer
 M:     gerg@uclinux.org
-M:     gerg@snapgear.com
-P:     David McCullough
-M:     davidm@snapgear.com
-P:     D. Jeff Dionne (created first uClinux port)
-M:     jeff@uclinux.org
 W:     http://www.uclinux.org/
 L:     uclinux-dev@uclinux.org  (subscribers-only)
 S:     Maintained
index 3d84df581cf23c287cff7a816c79afd3ec049c42..63e5c9f0bc7ad9776a4f9a33e07600b0085c5672 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -109,10 +109,9 @@ $(if $(KBUILD_OUTPUT),, \
 .PHONY: $(MAKECMDGOALS)
 
 $(filter-out _all,$(MAKECMDGOALS)) _all:
-       $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT)         \
-       KBUILD_SRC=$(CURDIR)         KBUILD_VERBOSE=$(KBUILD_VERBOSE)   \
-       KBUILD_CHECK=$(KBUILD_CHECK) KBUILD_EXTMOD="$(KBUILD_EXTMOD)"   \
-        -f $(CURDIR)/Makefile $@
+       $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
+       KBUILD_SRC=$(CURDIR) \
+       KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile $@
 
 # Leave processing to above invocation of make
 skip-makefile := 1
@@ -233,7 +232,7 @@ ifeq ($(MAKECMDGOALS),)
   KBUILD_MODULES := 1
 endif
 
-export KBUILD_MODULES KBUILD_BUILTIN KBUILD_VERBOSE
+export KBUILD_MODULES KBUILD_BUILTIN
 export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD
 
 # Beautify output
@@ -309,6 +308,9 @@ cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh \
 # Look for make include files relative to root of kernel src
 MAKEFLAGS += --include-dir=$(srctree)
 
+# We need some generic definitions
+include  $(srctree)/scripts/Kbuild.include
+
 # For maximum performance (+ possibly random breakage, uncomment
 # the following)
 
@@ -348,7 +350,7 @@ LINUXINCLUDE    := -Iinclude \
 
 CPPFLAGS        := -D__KERNEL__ $(LINUXINCLUDE)
 
-CFLAGS                 := -Wall -Wstrict-prototypes -Wno-trigraphs \
+CFLAGS                 := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
                   -fno-strict-aliasing -fno-common \
                   -ffreestanding
 AFLAGS         := -D__ASSEMBLY__
@@ -367,15 +369,10 @@ export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
 # even be read-only.
 export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions
 
-# The temporary file to save gcc -MD generated dependencies must not
-# contain a comma
-comma := ,
-depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
-
 # Files to ignore in find ... statements
 
-RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc \) -prune -o
-RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc
+RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg \) -prune -o
+RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg
 
 # ===========================================================================
 # Rules shared between *config targets and build targets
@@ -551,6 +548,26 @@ export KBUILD_IMAGE ?= vmlinux
 # images. Default is /boot, but you can set it to other values
 export INSTALL_PATH ?= /boot
 
+# If CONFIG_LOCALVERSION_AUTO is set, we automatically perform some tests
+# and try to determine if the current source tree is a release tree, of any sort,
+# or if is a pure development tree.
+#
+# A 'release tree' is any tree with a git TAG associated
+# with it.  The primary goal of this is to make it safe for a native
+# git/CVS/SVN user to build a release tree (i.e, 2.6.9) and also to
+# continue developing against the current Linus tree, without having the Linus
+# tree overwrite the 2.6.9 tree when installed.
+#
+# Currently, only git is supported.
+# Other SCMs can edit scripts/setlocalversion and add the appropriate
+# checks as needed.
+
+
+ifdef CONFIG_LOCALVERSION_AUTO
+       localversion-auto := $(shell $(PERL) $(srctree)/scripts/setlocalversion $(srctree))
+       LOCALVERSION := $(LOCALVERSION)$(localversion-auto)
+endif
+
 #
 # INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
 # relocations required by build roots.  This is not defined in the
@@ -691,8 +708,10 @@ endef
 
 # Update vmlinux version before link
 # Use + in front of this rule to silent warning about make -j1
+# First command is ':' to allow us to use + in front of this rule
 cmd_ksym_ld = $(cmd_vmlinux__)
 define rule_ksym_ld
+       : 
        +$(call cmd,vmlinux_version)
        $(call cmd,vmlinux__)
        $(Q)echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd
@@ -722,6 +741,16 @@ quiet_cmd_kallsyms = KSYM    $@
 # Needs to visit scripts/ before $(KALLSYMS) can be used.
 $(KALLSYMS): scripts ;
 
+# Generate some data for debugging strange kallsyms problems
+debug_kallsyms: .tmp_map$(last_kallsyms)
+
+.tmp_map%: .tmp_vmlinux% FORCE
+       ($(OBJDUMP) -h $< | $(AWK) '/^ +[0-9]/{print $$4 " 0 " $$2}'; $(NM) $<) | sort > $@
+
+.tmp_map3: .tmp_map2
+
+.tmp_map2: .tmp_map1
+
 endif # ifdef CONFIG_KALLSYMS
 
 # vmlinux image - including updated kernel symbols
@@ -757,7 +786,7 @@ $(vmlinux-dirs): prepare-all scripts
 prepare2:
 ifneq ($(KBUILD_SRC),)
        @echo '  Using $(srctree) as source for kernel'
-       $(Q)if [ -h $(srctree)/include/asm -o -f $(srctree)/.config ]; then \
+       $(Q)if [ -f $(srctree)/.config ]; then \
                echo "  $(srctree) is not clean, please run 'make mrproper'";\
                echo "  in the '$(srctree)' directory.";\
                /bin/false; \
@@ -769,7 +798,8 @@ endif
 # prepare1 creates a makefile if using a separate output directory
 prepare1: prepare2 outputmakefile
 
-prepare0: prepare1 include/linux/version.h include/asm include/config/MARKER
+prepare0: prepare1 include/linux/version.h include/asm \
+                   include/config/MARKER
 ifneq ($(KBUILD_MODULES),)
        $(Q)rm -rf $(MODVERDIR)
        $(Q)mkdir -p $(MODVERDIR)
@@ -875,7 +905,7 @@ modules_install: _modinst_ _modinst_post
 
 .PHONY: _modinst_
 _modinst_:
-       @if [ -z "`$(DEPMOD) -V | grep module-init-tools`" ]; then \
+       @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \
                echo "Warning: you may need to install module-init-tools"; \
                echo "See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt";\
                sleep 1; \
@@ -1159,37 +1189,49 @@ else
 __srctree = $(srctree)/
 endif
 
+ALLSOURCE_ARCHS := $(ARCH)
+
 define all-sources
        ( find $(__srctree) $(RCS_FIND_IGNORE) \
               \( -name include -o -name arch \) -prune -o \
               -name '*.[chS]' -print; \
-         find $(__srctree)arch/$(ARCH) $(RCS_FIND_IGNORE) \
-              -name '*.[chS]' -print; \
+         for ARCH in $(ALLSOURCE_ARCHS) ; do \
+              find $(__srctree)arch/$${ARCH} $(RCS_FIND_IGNORE) \
+                   -name '*.[chS]' -print; \
+         done ; \
          find $(__srctree)security/selinux/include $(RCS_FIND_IGNORE) \
               -name '*.[chS]' -print; \
          find $(__srctree)include $(RCS_FIND_IGNORE) \
               \( -name config -o -name 'asm-*' \) -prune \
               -o -name '*.[chS]' -print; \
-         find $(__srctree)include/asm-$(ARCH) $(RCS_FIND_IGNORE) \
-              -name '*.[chS]' -print; \
+         for ARCH in $(ALLSOURCE_ARCHS) ; do \
+              find $(__srctree)include/asm-$${ARCH} $(RCS_FIND_IGNORE) \
+                   -name '*.[chS]' -print; \
+         done ; \
          find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \
               -name '*.[chS]' -print )
 endef
 
 quiet_cmd_cscope-file = FILELST cscope.files
-      cmd_cscope-file = $(all-sources) > cscope.files
+      cmd_cscope-file = (echo \-k; echo \-q; $(all-sources)) > cscope.files
 
 quiet_cmd_cscope = MAKE    cscope.out
-      cmd_cscope = cscope -k -b -q
+      cmd_cscope = cscope -b
 
 cscope: FORCE
        $(call cmd,cscope-file)
        $(call cmd,cscope)
 
 quiet_cmd_TAGS = MAKE   $@
-cmd_TAGS = $(all-sources) | etags -
+define cmd_TAGS
+       rm -f $@; \
+       ETAGSF=`etags --version | grep -i exuberant >/dev/null && echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_GPL --extra=+f"`; \
+       $(all-sources) | xargs etags $$ETAGSF -a
+endef
+
+TAGS: FORCE
+       $(call cmd,TAGS)
 
-#      Exuberant ctags works better with -I
 
 quiet_cmd_tags = MAKE   $@
 define cmd_tags
@@ -1198,9 +1240,6 @@ define cmd_tags
        $(all-sources) | xargs ctags $$CTAGSF -a
 endef
 
-TAGS: FORCE
-       $(call cmd,TAGS)
-
 tags: FORCE
        $(call cmd,tags)
 
@@ -1268,82 +1307,11 @@ ifneq ($(cmd_files),)
   include $(cmd_files)
 endif
 
-# Execute command and generate cmd file
-if_changed = $(if $(strip $? \
-                         $(filter-out $(cmd_$(1)),$(cmd_$@))\
-                         $(filter-out $(cmd_$@),$(cmd_$(1)))),\
-       @set -e; \
-       $(if $($(quiet)cmd_$(1)),echo '  $(subst ','\'',$($(quiet)cmd_$(1)))';) \
-       $(cmd_$(1)); \
-       echo 'cmd_$@ := $(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).cmd)
-
-
-# execute the command and also postprocess generated .d dependencies
-# file
-if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\
-                         $(filter-out $(cmd_$(1)),$(cmd_$@))\
-                         $(filter-out $(cmd_$@),$(cmd_$(1)))),\
-       $(Q)set -e; \
-       $(if $($(quiet)cmd_$(1)),echo '  $(subst ','\'',$($(quiet)cmd_$(1)))';) \
-       $(cmd_$(1)); \
-       scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \
-       rm -f $(depfile); \
-       mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
-
-# Usage: $(call if_changed_rule,foo)
-# will check if $(cmd_foo) changed, or any of the prequisites changed,
-# and if so will execute $(rule_foo)
-
-if_changed_rule = $(if $(strip $? \
-                              $(filter-out $(cmd_$(1)),$(cmd_$(@F)))\
-                              $(filter-out $(cmd_$(@F)),$(cmd_$(1)))),\
-                      $(Q)$(rule_$(1)))
-
-# If quiet is set, only print short version of command
-
-cmd = @$(if $($(quiet)cmd_$(1)),echo '  $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
-
-# filechk is used to check if the content of a generated file is updated.
-# Sample usage:
-# define filechk_sample
-#      echo $KERNELRELEASE
-# endef
-# version.h : Makefile
-#      $(call filechk,sample)
-# The rule defined shall write to stdout the content of the new file.
-# The existing file will be compared with the new one.
-# - If no file exist it is created
-# - If the content differ the new file is used
-# - If they are equal no change, and no timestamp update
-
-define filechk
-       @set -e;                                \
-       echo '  CHK     $@';                    \
-       mkdir -p $(dir $@);                     \
-       $(filechk_$(1)) < $< > $@.tmp;          \
-       if [ -r $@ ] && cmp -s $@ $@.tmp; then  \
-               rm -f $@.tmp;                   \
-       else                                    \
-               echo '  UPD     $@';            \
-               mv -f $@.tmp $@;                \
-       fi
-endef
-
-# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=dir
-# Usage:
-# $(Q)$(MAKE) $(build)=dir
-build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
-
 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
 # Usage:
 # $(Q)$(MAKE) $(clean)=dir
 clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
 
-#      $(call descend,<dir>,<target>)
-#      Recursively call a sub-make in <dir> with target <target>
-# Usage is deprecated, because make does not see this as an invocation of make.
-descend =$(Q)$(MAKE) -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj=$(1) $(2)
-
 endif  # skip-makefile
 
 FORCE:
index 4bf0e8737e1fd514477ec4009ba4e908f189b9a9..68dfdba71d74126512efcd4996282ffce11b63a4 100644 (file)
@@ -365,8 +365,8 @@ config NO_IDLE_HZ
 
          Please note that dynamic tick may affect the accuracy of
          timekeeping on some platforms depending on the implementation.
-         Currently at least OMAP platform is known to have accurate
-         timekeeping with dynamic tick.
+         Currently at least OMAP, PXA2xx and SA11x0 platforms are known
+         to have accurate timekeeping with dynamic tick.
 
 config ARCH_DISCONTIGMEM_ENABLE
        bool
index 51dbf5489b6b31fb5a0cd515c9e4839e7bfb9e50..d7499071755976a0a14b7b0c26eb8db62555e7b9 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/smp.h>
+#include <linux/cpumask.h>
 
 #include <asm/irq.h>
 #include <asm/io.h>
index 41f12658c8b47a2862605b39ed78fbdb6c8a55e5..51f430cc2fbf5b7a08bcfed5bc6dee1e97fb1435 100644 (file)
@@ -177,7 +177,7 @@ static void locomo_handler(unsigned int irq, struct irqdesc *desc,
                d = irq_desc + irq;
                for (i = 0; i <= 3; i++, d++, irq++) {
                        if (req & (0x0100 << i)) {
-                               d->handle(irq, d, regs);
+                               desc_handle_irq(irq, d, regs);
                        }
 
                }
@@ -220,7 +220,7 @@ static void locomo_key_handler(unsigned int irq, struct irqdesc *desc,
 
        if (locomo_readl(mapbase + LOCOMO_KEYBOARD + LOCOMO_KIC) & 0x0001) {
                d = irq_desc + LOCOMO_IRQ_KEY_START;
-               d->handle(LOCOMO_IRQ_KEY_START, d, regs);
+               desc_handle_irq(LOCOMO_IRQ_KEY_START, d, regs);
        }
 }
 
@@ -273,7 +273,7 @@ static void locomo_gpio_handler(unsigned int irq, struct irqdesc *desc,
                d = irq_desc + LOCOMO_IRQ_GPIO_START;
                for (i = 0; i <= 15; i++, irq++, d++) {
                        if (req & (0x0001 << i)) {
-                               d->handle(irq, d, regs);
+                               desc_handle_irq(irq, d, regs);
                        }
                }
        }
@@ -328,7 +328,7 @@ static void locomo_lt_handler(unsigned int irq, struct irqdesc *desc,
 
        if (locomo_readl(mapbase + LOCOMO_LTINT) & 0x0001) {
                d = irq_desc + LOCOMO_IRQ_LT_START;
-               d->handle(LOCOMO_IRQ_LT_START, d, regs);
+               desc_handle_irq(LOCOMO_IRQ_LT_START, d, regs);
        }
 }
 
@@ -379,7 +379,7 @@ static void locomo_spi_handler(unsigned int irq, struct irqdesc *desc,
 
                for (i = 0; i <= 3; i++, irq++, d++) {
                        if (req & (0x0001 << i)) {
-                               d->handle(irq, d, regs);
+                               desc_handle_irq(irq, d, regs);
                        }
                }
        }
@@ -651,15 +651,15 @@ __locomo_probe(struct device *me, struct resource *mem, int irq)
        return ret;
 }
 
-static void __locomo_remove(struct locomo *lchip)
+static int locomo_remove_child(struct device *dev, void *data)
 {
-       struct list_head *l, *n;
-
-       list_for_each_safe(l, n, &lchip->dev->children) {
-               struct device *d = list_to_dev(l);
+       device_unregister(dev);
+       return 0;
+} 
 
-               device_unregister(d);
-       }
+static void __locomo_remove(struct locomo *lchip)
+{
+       device_for_each_child(lchip->dev, NULL, locomo_remove_child);
 
        if (lchip->irq != NO_IRQ) {
                set_irq_chained_handler(lchip->irq, NULL);
index 38c2eb667eb9909bd0db0667d6b7461bc4c38c57..1a47fbf9cbbc939a9f8f484c5c89301752000cc5 100644 (file)
@@ -268,8 +268,8 @@ static struct irqchip sa1111_low_chip = {
        .mask           = sa1111_mask_lowirq,
        .unmask         = sa1111_unmask_lowirq,
        .retrigger      = sa1111_retrigger_lowirq,
-       .type           = sa1111_type_lowirq,
-       .wake           = sa1111_wake_lowirq,
+       .set_type       = sa1111_type_lowirq,
+       .set_wake       = sa1111_wake_lowirq,
 };
 
 static void sa1111_mask_highirq(unsigned int irq)
@@ -364,8 +364,8 @@ static struct irqchip sa1111_high_chip = {
        .mask           = sa1111_mask_highirq,
        .unmask         = sa1111_unmask_highirq,
        .retrigger      = sa1111_retrigger_highirq,
-       .type           = sa1111_type_highirq,
-       .wake           = sa1111_wake_highirq,
+       .set_type       = sa1111_type_highirq,
+       .set_wake       = sa1111_wake_highirq,
 };
 
 static void sa1111_setup_irq(struct sa1111 *sachip)
index cfd0d3e550d9ef6d1af15982862904283130eed2..688a595598c8a5cdc7b42a9b55a2b5ffe1868a17 100644 (file)
 
 #define SCOOP_REG(d,adr) (*(volatile unsigned short*)(d +(adr)))
 
+/* PCMCIA to Scoop linkage structures for pxa2xx_sharpsl.c
+   There is no easy way to link multiple scoop devices into one
+   single entity for the pxa2xx_pcmcia device */
+int scoop_num;
+struct scoop_pcmcia_dev *scoop_devs;
+
 struct  scoop_dev {
        void  *base;
        spinlock_t scoop_lock;
index 2b6b4c786e654c125cfa62b750337bc5894b9731..db07ce42b3b2c6873f9b767389ae766d0f89ad6f 100644 (file)
@@ -284,7 +284,7 @@ __syscall_start:
                .long   sys_fstatfs64
                .long   sys_tgkill
                .long   sys_utimes
-/* 270 */      .long   sys_fadvise64_64
+/* 270 */      .long   sys_arm_fadvise64_64_wrapper
                .long   sys_pciconfig_iobase
                .long   sys_pciconfig_read
                .long   sys_pciconfig_write
index 6540db6913381f4474d12594c6a84376d53724dd..dceb826bd216ece20e0e8399eaf785fc7d5cbde3 100644 (file)
@@ -585,7 +585,7 @@ ecard_irq_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
 
                if (pending) {
                        struct irqdesc *d = irq_desc + ec->irq;
-                       d->handle(ec->irq, d, regs);
+                       desc_handle_irq(ec->irq, d, regs);
                        called ++;
                }
        }
@@ -632,7 +632,7 @@ ecard_irqexp_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *reg
                         * Serial cards should go in 0/1, ethernet/scsi in 2/3
                         * otherwise you will lose serial data at high speeds!
                         */
-                       d->handle(ec->irq, d, regs);
+                       desc_handle_irq(ec->irq, d, regs);
                } else {
                        printk(KERN_WARNING "card%d: interrupt from unclaimed "
                               "card???\n", slot);
index 3f8d0e3aefabf71c6bf82783024a72c39988974f..6281d488ac975d225aa10f536b5849db1b528956 100644 (file)
@@ -265,6 +265,10 @@ sys_futex_wrapper:
                str     r5, [sp, #4]            @ push sixth arg
                b       sys_futex
 
+sys_arm_fadvise64_64_wrapper:
+               str     r5, [sp, #4]            @ push r5 to stack
+               b       sys_arm_fadvise64_64
+
 /*
  * Note: off_4k (r5) is always units of 4K.  If we can't do the requested
  * offset, we return EINVAL.
index 395137a8fad276ce20cb250d58920f7c12fac501..3284118f356b90c8ae1ec7320d71ce143d704220 100644 (file)
@@ -207,8 +207,8 @@ void enable_irq_wake(unsigned int irq)
        unsigned long flags;
 
        spin_lock_irqsave(&irq_controller_lock, flags);
-       if (desc->chip->wake)
-               desc->chip->wake(irq, 1);
+       if (desc->chip->set_wake)
+               desc->chip->set_wake(irq, 1);
        spin_unlock_irqrestore(&irq_controller_lock, flags);
 }
 EXPORT_SYMBOL(enable_irq_wake);
@@ -219,8 +219,8 @@ void disable_irq_wake(unsigned int irq)
        unsigned long flags;
 
        spin_lock_irqsave(&irq_controller_lock, flags);
-       if (desc->chip->wake)
-               desc->chip->wake(irq, 0);
+       if (desc->chip->set_wake)
+               desc->chip->set_wake(irq, 0);
        spin_unlock_irqrestore(&irq_controller_lock, flags);
 }
 EXPORT_SYMBOL(disable_irq_wake);
@@ -517,7 +517,7 @@ static void do_pending_irqs(struct pt_regs *regs)
                list_for_each_safe(l, n, &head) {
                        desc = list_entry(l, struct irqdesc, pend);
                        list_del_init(&desc->pend);
-                       desc->handle(desc - irq_desc, desc, regs);
+                       desc_handle_irq(desc - irq_desc, desc, regs);
                }
 
                /*
@@ -545,7 +545,7 @@ asmlinkage void asm_do_IRQ(unsigned int irq, struct pt_regs *regs)
 
        irq_enter();
        spin_lock(&irq_controller_lock);
-       desc->handle(irq, desc, regs);
+       desc_handle_irq(irq, desc, regs);
 
        /*
         * Now re-run any pending interrupts.
@@ -624,9 +624,9 @@ int set_irq_type(unsigned int irq, unsigned int type)
        }
 
        desc = irq_desc + irq;
-       if (desc->chip->type) {
+       if (desc->chip->set_type) {
                spin_lock_irqsave(&irq_controller_lock, flags);
-               ret = desc->chip->type(irq, type);
+               ret = desc->chip->set_type(irq, type);
                spin_unlock_irqrestore(&irq_controller_lock, flags);
        }
 
@@ -846,8 +846,8 @@ unsigned long probe_irq_on(void)
 
                irq_desc[i].probing = 1;
                irq_desc[i].triggered = 0;
-               if (irq_desc[i].chip->type)
-                       irq_desc[i].chip->type(i, IRQT_PROBE);
+               if (irq_desc[i].chip->set_type)
+                       irq_desc[i].chip->set_type(i, IRQT_PROBE);
                irq_desc[i].chip->unmask(i);
                irqs += 1;
        }
index b2085735a2baf1833c90ab1ad9c237d58e869e28..826164945747523fa93712d9d0575051b511ccb7 100644 (file)
@@ -110,7 +110,7 @@ int __cpuinit __cpu_up(unsigned int cpu)
         * We need to tell the secondary core where to find
         * its stack and the page tables.
         */
-       secondary_data.stack = (void *)idle->thread_info + THREAD_SIZE - 8;
+       secondary_data.stack = (void *)idle->thread_info + THREAD_START_SP;
        secondary_data.pgdir = virt_to_phys(pgd);
        wmb();
 
index f897ce2ccf0d358cc79a6493b23d1cf33d91a05a..42629ff84f5a8864787c1d862f001e47a3000765 100644 (file)
@@ -311,3 +311,13 @@ long execve(const char *filename, char **argv, char **envp)
        return ret;
 }
 EXPORT_SYMBOL(execve);
+
+/*
+ * Since loff_t is a 64 bit type we avoid a lot of ABI hastle
+ * with a different argument ordering.
+ */
+asmlinkage long sys_arm_fadvise64_64(int fd, int advice,
+                                    loff_t offset, loff_t len)
+{
+       return sys_fadvise64_64(fd, offset, len, advice);
+}
index 1b7fcd50c3e25c8a208bc3347dc55dc7d0605e1e..8880482dcbffd4dbbfb20ea98def232de3b439d1 100644 (file)
@@ -433,10 +433,12 @@ void timer_dyn_reprogram(void)
 {
        struct dyn_tick_timer *dyn_tick = system_timer->dyn_tick;
 
-       write_seqlock(&xtime_lock);
-       if (dyn_tick->state & DYN_TICK_ENABLED)
-               dyn_tick->reprogram(next_timer_interrupt() - jiffies);
-       write_sequnlock(&xtime_lock);
+       if (dyn_tick) {
+               write_seqlock(&xtime_lock);
+               if (dyn_tick->state & DYN_TICK_ENABLED)
+                       dyn_tick->reprogram(next_timer_interrupt() - jiffies);
+               write_sequnlock(&xtime_lock);
+       }
 }
 
 static ssize_t timer_show_dyn_tick(struct sys_device *dev, char *buf)
index b21016070ea304a07e0ae0a2741f4162c2872537..e1c43b331d64d357ece5282be3929cd136bfe026 100644 (file)
@@ -95,7 +95,7 @@ isa_irq_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
        }
 
        desc = irq_desc + isa_irq;
-       desc->handle(isa_irq, desc, regs);
+       desc_handle_irq(isa_irq, desc, regs);
 }
 
 static struct irqaction irq_cascade = { .handler = no_action, .name = "cascade", };
index 96aa3af70d86ce484220b44cbc996450c568dec1..5110e2e65ddd3176a78c4880daaec219d4eae138 100644 (file)
@@ -108,7 +108,7 @@ h720x_gpio_handler(unsigned int mask, unsigned int irq,
        while (mask) {
                if (mask & 1) {
                        IRQDBG("handling irq %d\n", irq);
-                       desc->handle(irq, desc, regs);
+                       desc_handle_irq(irq, desc, regs);
                }
                irq++;
                desc++;
index 593b6a2a30e1d5e8c2aa05ded41c8cbf1bd1284b..4b3199319e68b4c988f4f24edff2ded120405f24 100644 (file)
@@ -126,7 +126,7 @@ h7202_timerx_demux_handler(unsigned int irq_unused, struct irqdesc *desc,
        desc = irq_desc + irq;
        while (mask) {
                if (mask & 1)
-                       desc->handle(irq, desc, regs);
+                       desc_handle_irq(irq, desc, regs);
                irq++;
                desc++;
                mask >>= 1;
index 0c2713426dfd608faa86ca834e00b1c4c9e7fe58..eeb8a6d4a3999c1f9f605588ab0852e0b4b88621 100644 (file)
@@ -152,7 +152,7 @@ imx_gpio_handler(unsigned int mask, unsigned int irq,
        while (mask) {
                if (mask & 1) {
                        DEBUG_IRQ("handling irq %d\n", irq);
-                       desc->handle(irq, desc, regs);
+                       desc_handle_irq(irq, desc, regs);
                }
                irq++;
                desc++;
@@ -214,7 +214,7 @@ static struct irqchip imx_gpio_chip = {
        .ack = imx_gpio_ack_irq,
        .mask = imx_gpio_mask_irq,
        .unmask = imx_gpio_unmask_irq,
-       .type = imx_gpio_irq_type,
+       .set_type = imx_gpio_irq_type,
 };
 
 void __init
index 569f328c479db0c4d30e468dd2772f3a9775b78a..2be5c03ab87f858c07168e646396566b8fef3106 100644 (file)
@@ -170,7 +170,7 @@ sic_handle_irq(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
                irq += IRQ_SIC_START;
 
                desc = irq_desc + irq;
-               desc->handle(irq, desc, regs);
+               desc_handle_irq(irq, desc, regs);
        } while (status);
 }
 
index 45b18658499f8e8c984bb105682ef4031fb174b3..781d10ae00b7dfc5771fd28d99eab154a8de1706 100644 (file)
@@ -317,7 +317,7 @@ static void ixp2000_GPIO_irq_handler(unsigned int irq, struct irqdesc *desc, str
        for (i = 0; i <= 7; i++) {
                if (status & (1<<i)) {
                        desc = irq_desc + i + IRQ_IXP2000_GPIO0;
-                       desc->handle(i + IRQ_IXP2000_GPIO0, desc, regs);
+                       desc_handle_irq(i + IRQ_IXP2000_GPIO0, desc, regs);
                }
        }
 }
@@ -380,10 +380,10 @@ static void ixp2000_GPIO_irq_unmask(unsigned int irq)
 }
 
 static struct irqchip ixp2000_GPIO_irq_chip = {
-       .type   = ixp2000_GPIO_irq_type,
-       .ack    = ixp2000_GPIO_irq_mask_ack,
-       .mask   = ixp2000_GPIO_irq_mask,
-       .unmask = ixp2000_GPIO_irq_unmask
+       .ack            = ixp2000_GPIO_irq_mask_ack,
+       .mask           = ixp2000_GPIO_irq_mask,
+       .unmask         = ixp2000_GPIO_irq_unmask
+       .set_type       = ixp2000_GPIO_irq_type,
 };
 
 static void ixp2000_pci_irq_mask(unsigned int irq)
index a43369ad876ca57cc27ab0732053ccb5d13417a1..63ba0191aa6572c5ee98db13713cd62096f2aed7 100644 (file)
@@ -133,7 +133,7 @@ static void ixdp2x00_irq_handler(unsigned int irq, struct irqdesc *desc, struct
                        struct irqdesc *cpld_desc;
                        int cpld_irq = IXP2000_BOARD_IRQ(0) + i;
                        cpld_desc = irq_desc + cpld_irq;
-                       cpld_desc->handle(cpld_irq, cpld_desc, regs);
+                       desc_handle_irq(cpld_irq, cpld_desc, regs);
                }
        }
 
index 43447dad165759affb4ddcdd22e108c0cdefd187..7a51099212877c94efef75908be49c37e312ecdf 100644 (file)
@@ -82,7 +82,7 @@ static void ixdp2x01_irq_handler(unsigned int irq, struct irqdesc *desc, struct
                        struct irqdesc *cpld_desc;
                        int cpld_irq = IXP2000_BOARD_IRQ(0) + i;
                        cpld_desc = irq_desc + cpld_irq;
-                       cpld_desc->handle(cpld_irq, cpld_desc, regs);
+                       desc_handle_irq(cpld_irq, cpld_desc, regs);
                }
        }
 
index 04490a9f8f6ecfc2158d8b21ec3aa096b888e1f2..0422e906cc9a64e4ff11d43e866049a72ba52cd0 100644 (file)
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
 
-enum ixp4xx_irq_type {
-       IXP4XX_IRQ_LEVEL, IXP4XX_IRQ_EDGE
-};
-static void ixp4xx_config_irq(unsigned irq, enum ixp4xx_irq_type type);
-
-/*************************************************************************
- * GPIO acces functions
- *************************************************************************/
-
-/*
- * Configure GPIO line for input, interrupt, or output operation
- *
- * TODO: Enable/disable the irq_desc based on interrupt or output mode.
- * TODO: Should these be named ixp4xx_gpio_?
- */
-void gpio_line_config(u8 line, u32 style)
-{
-       static const int gpio2irq[] = {
-               6, 7, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
-       };
-       u32 enable;
-       volatile u32 *int_reg;
-       u32 int_style;
-       enum ixp4xx_irq_type irq_type;
-
-       enable = *IXP4XX_GPIO_GPOER;
-
-       if (style & IXP4XX_GPIO_OUT) {
-               enable &= ~((1) << line);
-       } else if (style & IXP4XX_GPIO_IN) {
-               enable |= ((1) << line);
-
-               switch (style & IXP4XX_GPIO_INTSTYLE_MASK)
-               {
-               case (IXP4XX_GPIO_ACTIVE_HIGH):
-                       int_style = IXP4XX_GPIO_STYLE_ACTIVE_HIGH;
-                       irq_type = IXP4XX_IRQ_LEVEL;
-                       break;
-               case (IXP4XX_GPIO_ACTIVE_LOW):
-                       int_style = IXP4XX_GPIO_STYLE_ACTIVE_LOW;
-                       irq_type = IXP4XX_IRQ_LEVEL;
-                       break;
-               case (IXP4XX_GPIO_RISING_EDGE):
-                       int_style = IXP4XX_GPIO_STYLE_RISING_EDGE;
-                       irq_type = IXP4XX_IRQ_EDGE;
-                       break;
-               case (IXP4XX_GPIO_FALLING_EDGE):
-                       int_style = IXP4XX_GPIO_STYLE_FALLING_EDGE;
-                       irq_type = IXP4XX_IRQ_EDGE;
-                       break;
-               case (IXP4XX_GPIO_TRANSITIONAL):
-                       int_style = IXP4XX_GPIO_STYLE_TRANSITIONAL;
-                       irq_type = IXP4XX_IRQ_EDGE;
-                       break;
-               default:
-                       int_style = IXP4XX_GPIO_STYLE_ACTIVE_HIGH;
-                       irq_type = IXP4XX_IRQ_LEVEL;
-                       break;
-               }
-
-               if (style & IXP4XX_GPIO_INTSTYLE_MASK)
-                       ixp4xx_config_irq(gpio2irq[line], irq_type);
-
-               if (line >= 8) {        /* pins 8-15 */ 
-                       line -= 8;
-                       int_reg = IXP4XX_GPIO_GPIT2R;
-               }
-               else {                  /* pins 0-7 */
-                       int_reg = IXP4XX_GPIO_GPIT1R;
-               }
-
-               /* Clear the style for the appropriate pin */
-               *int_reg &= ~(IXP4XX_GPIO_STYLE_CLEAR << 
-                               (line * IXP4XX_GPIO_STYLE_SIZE));
-
-               /* Set the new style */
-               *int_reg |= (int_style << (line * IXP4XX_GPIO_STYLE_SIZE));
-       }
-
-       *IXP4XX_GPIO_GPOER = enable;
-}
-
-EXPORT_SYMBOL(gpio_line_config);
-
 /*************************************************************************
  * IXP4xx chipset I/O mapping
  *************************************************************************/
@@ -165,6 +81,69 @@ void __init ixp4xx_map_io(void)
  *       (be it PCI or something else) configures that GPIO line
  *       as an IRQ.
  **************************************************************************/
+enum ixp4xx_irq_type {
+       IXP4XX_IRQ_LEVEL, IXP4XX_IRQ_EDGE
+};
+
+static void ixp4xx_config_irq(unsigned irq, enum ixp4xx_irq_type type);
+
+/*
+ * IRQ -> GPIO mapping table
+ */
+static int irq2gpio[32] = {
+       -1, -1, -1, -1, -1, -1,  0,  1,
+       -1, -1, -1, -1, -1, -1, -1, -1,
+       -1, -1, -1,  2,  3,  4,  5,  6,
+        7,  8,  9, 10, 11, 12, -1, -1,
+};
+
+static int ixp4xx_set_irq_type(unsigned int irq, unsigned int type)
+{
+       int line = irq2gpio[irq];
+       u32 int_style;
+       enum ixp4xx_irq_type irq_type;
+       volatile u32 *int_reg;
+
+       /*
+        * Only for GPIO IRQs
+        */
+       if (line < 0)
+               return -EINVAL;
+
+       if (type & IRQT_BOTHEDGE) {
+               int_style = IXP4XX_GPIO_STYLE_TRANSITIONAL;
+               irq_type = IXP4XX_IRQ_EDGE;
+       } else  if (type & IRQT_RISING) {
+               int_style = IXP4XX_GPIO_STYLE_RISING_EDGE;
+               irq_type = IXP4XX_IRQ_EDGE;
+       } else if (type & IRQT_FALLING) {
+               int_style = IXP4XX_GPIO_STYLE_FALLING_EDGE;
+               irq_type = IXP4XX_IRQ_EDGE;
+       } else if (type & IRQT_HIGH) {
+               int_style = IXP4XX_GPIO_STYLE_ACTIVE_HIGH;
+               irq_type = IXP4XX_IRQ_LEVEL;
+       } else if (type & IRQT_LOW) {
+               int_style = IXP4XX_GPIO_STYLE_ACTIVE_LOW;
+               irq_type = IXP4XX_IRQ_LEVEL;
+       }
+
+       ixp4xx_config_irq(irq, irq_type);
+
+       if (line >= 8) {        /* pins 8-15 */
+               line -= 8;
+               int_reg = IXP4XX_GPIO_GPIT2R;
+       } else {                /* pins 0-7 */
+               int_reg = IXP4XX_GPIO_GPIT1R;
+       }
+
+       /* Clear the style for the appropriate pin */
+       *int_reg &= ~(IXP4XX_GPIO_STYLE_CLEAR <<
+                       (line * IXP4XX_GPIO_STYLE_SIZE));
+
+       /* Set the new style */
+       *int_reg |= (int_style << (line * IXP4XX_GPIO_STYLE_SIZE));
+}
+
 static void ixp4xx_irq_mask(unsigned int irq)
 {
        if (cpu_is_ixp46x() && irq >= 32)
@@ -183,12 +162,6 @@ static void ixp4xx_irq_unmask(unsigned int irq)
 
 static void ixp4xx_irq_ack(unsigned int irq)
 {
-       static int irq2gpio[32] = {
-               -1, -1, -1, -1, -1, -1,  0,  1,
-               -1, -1, -1, -1, -1, -1, -1, -1,
-               -1, -1, -1,  2,  3,  4,  5,  6,
-                7,  8,  9, 10, 11, 12, -1, -1,
-       };
        int line = (irq < 32) ? irq2gpio[irq] : -1;
 
        if (line >= 0)
@@ -209,12 +182,14 @@ static struct irqchip ixp4xx_irq_level_chip = {
        .ack    = ixp4xx_irq_mask,
        .mask   = ixp4xx_irq_mask,
        .unmask = ixp4xx_irq_level_unmask,
+       .type   = ixp4xx_set_irq_type
 };
 
 static struct irqchip ixp4xx_irq_edge_chip = {
        .ack    = ixp4xx_irq_ack,
        .mask   = ixp4xx_irq_mask,
        .unmask = ixp4xx_irq_unmask,
+       .type   = ixp4xx_set_irq_type
 };
 
 static void ixp4xx_config_irq(unsigned irq, enum ixp4xx_irq_type type)
index afafb42ae12951c8a96bc615328bee61a5565b07..60de8a94cff5f828cf93840d0d80cff53cc395da 100644 (file)
@@ -30,11 +30,8 @@ extern struct pci_bus *ixp4xx_scan_bus(int nr, struct pci_sys_data *sys);
 
 void __init coyote_pci_preinit(void)
 {
-       gpio_line_config(COYOTE_PCI_SLOT0_PIN,
-                       IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
-
-       gpio_line_config(COYOTE_PCI_SLOT1_PIN,
-                       IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
+       set_irq_type(IRQ_COYOTE_PCI_SLOT0, IRQT_LOW);
+       set_irq_type(IRQ_COYOTE_PCI_SLOT1, IRQT_LOW);
 
        gpio_line_isr_clear(COYOTE_PCI_SLOT0_PIN);
        gpio_line_isr_clear(COYOTE_PCI_SLOT1_PIN);
index 411ea999619055a7b0e73bd3678ecd9ad8806989..8b2f25322452b2c449ca02296128075e4a09918e 100644 (file)
 #include <asm/mach/arch.h>
 #include <asm/mach/flash.h>
 
-void __init coyote_map_io(void)
-{
-       ixp4xx_map_io();
-}
-
 static struct flash_platform_data coyote_flash_data = {
        .map_name       = "cfi_probe",
        .width          = 2,
@@ -107,7 +102,7 @@ MACHINE_START(ADI_COYOTE, "ADI Engineering Coyote")
        .phys_ram       = PHYS_OFFSET,
        .phys_io        = IXP4XX_PERIPHERAL_BASE_PHYS,
        .io_pg_offst    = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
-       .map_io         = coyote_map_io,
+       .map_io         = ixp4xx_map_io,
        .init_irq       = ixp4xx_init_irq,
        .timer          = &ixp4xx_timer,
        .boot_params    = 0x0100,
@@ -125,7 +120,7 @@ MACHINE_START(IXDPG425, "Intel IXDPG425")
        .phys_ram       = PHYS_OFFSET,
        .phys_io        = IXP4XX_PERIPHERAL_BASE_PHYS,
        .io_pg_offst    = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
-       .map_io         = coyote_map_io,
+       .map_io         = ixp4xx_map_io,
        .init_irq       = ixp4xx_init_irq,
        .timer          = &ixp4xx_timer,
        .boot_params    = 0x0100,
index b18035824e3e386c59a38b2c5d6e6db321fe6258..a66484b63d36b12b0dccd06770b3b3a9d2931a7a 100644 (file)
@@ -35,26 +35,20 @@ extern void ixp4xx_pci_preinit(void);
 extern int ixp4xx_setup(int nr, struct pci_sys_data *sys);
 extern struct pci_bus *ixp4xx_scan_bus(int nr, struct pci_sys_data *sys);
 
-        /*
-        * The exact GPIO pins and IRQs are defined in arch-ixp4xx/gtwx5715.h
-        * Slot 0 isn't actually populated with a card connector but
-        * we initialize it anyway in case a future version has the
-        * slot populated or someone with good soldering skills has
-        * some free time.
-        */
-
-
-static void gtwx5715_init_gpio(u8 pin, u32 style)
-{
-       gpio_line_config(pin, style | IXP4XX_GPIO_ACTIVE_LOW);
-
-       if (style & IXP4XX_GPIO_IN) gpio_line_isr_clear(pin);
-}
 
+/*
+ * The exact GPIO pins and IRQs are defined in arch-ixp4xx/gtwx5715.h
+ * Slot 0 isn't actually populated with a card connector but
+ * we initialize it anyway in case a future version has the
+ * slot populated or someone with good soldering skills has
+ * some free time.
+ */
 void __init gtwx5715_pci_preinit(void)
 {
-       gtwx5715_init_gpio(GTWX5715_PCI_SLOT0_INTA_GPIO,        IXP4XX_GPIO_IN);
-       gtwx5715_init_gpio(GTWX5715_PCI_SLOT1_INTA_GPIO,        IXP4XX_GPIO_IN);
+       set_irq_type(GTWX5715_PCI_SLOT0_INTA_IRQ, IRQT_LOW);
+       set_irq_type(GTWX5715_PCI_SLOT0_INTB_IRQ, IRQT_LOW);
+       set_irq_type(GTWX5715_PCI_SLOT1_INTA_IRQ, IRQT_LOW);
+       set_irq_type(GTWX5715_PCI_SLOT1_INTB_IRQ, IRQT_LOW);
 
        ixp4xx_pci_preinit();
 }
index 333459d6aa464bb5394fd46783e9b6690b6ed4aa..3fd92c5cbaa83e21566595aab80090a93dcdd192 100644 (file)
@@ -101,12 +101,6 @@ static struct platform_device gtwx5715_uart_device = {
        .resource       = gtwx5715_uart_resources,
 };
 
-
-void __init gtwx5715_map_io(void)
-{
-       ixp4xx_map_io();
-}
-
 static struct flash_platform_data gtwx5715_flash_data = {
        .map_name       = "cfi_probe",
        .width          = 2,
@@ -144,7 +138,7 @@ MACHINE_START(GTWX5715, "Gemtek GTWX5715 (Linksys WRV54G)")
        .phys_ram       = PHYS_OFFSET,
        .phys_io        = IXP4XX_UART2_BASE_PHYS,
        .io_pg_offst    = ((IXP4XX_UART2_BASE_VIRT) >> 18) & 0xfffc,
-       .map_io         = gtwx5715_map_io,
+       .map_io         = ixp4xx_map_io,
        .init_irq       = ixp4xx_init_irq,
        .timer          = &ixp4xx_timer,
        .boot_params    = 0x0100,
index c2ab9ebb5980cac5d68f1e57f68973461b36e1fa..f9a1d3e7d6922d30c6226690d06162facec746b2 100644 (file)
 
 void __init ixdp425_pci_preinit(void)
 {
-       gpio_line_config(IXDP425_PCI_INTA_PIN,
-                               IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
-       gpio_line_config(IXDP425_PCI_INTB_PIN, 
-                               IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
-       gpio_line_config(IXDP425_PCI_INTC_PIN, 
-                               IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
-       gpio_line_config(IXDP425_PCI_INTD_PIN, 
-                               IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
+       set_irq_type(IRQ_IXDP425_PCI_INTA, IRQT_LOW);
+       set_irq_type(IRQ_IXDP425_PCI_INTB, IRQT_LOW);
+       set_irq_type(IRQ_IXDP425_PCI_INTC, IRQT_LOW);
+       set_irq_type(IRQ_IXDP425_PCI_INTD, IRQT_LOW);
 
        gpio_line_isr_clear(IXDP425_PCI_INTA_PIN);
        gpio_line_isr_clear(IXDP425_PCI_INTB_PIN);
index fa0646c8693b096c7c1ee6b6a16dc3074bff2679..6c14ff3c23a04706df50f9f8ad38e5179994e21b 100644 (file)
 #include <asm/mach/arch.h>
 #include <asm/mach/flash.h>
 
-void __init ixdp425_map_io(void) 
-{
-       ixp4xx_map_io();
-}
-
 static struct flash_platform_data ixdp425_flash_data = {
        .map_name       = "cfi_probe",
        .width          = 2,
@@ -133,7 +128,7 @@ MACHINE_START(IXDP425, "Intel IXDP425 Development Platform")
        .phys_ram       = PHYS_OFFSET,
        .phys_io        = IXP4XX_PERIPHERAL_BASE_PHYS,
        .io_pg_offst    = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
-       .map_io         = ixdp425_map_io,
+       .map_io         = ixp4xx_map_io,
        .init_irq       = ixp4xx_init_irq,
        .timer          = &ixp4xx_timer,
        .boot_params    = 0x0100,
@@ -145,7 +140,7 @@ MACHINE_START(IXDP465, "Intel IXDP465 Development Platform")
        .phys_ram       = PHYS_OFFSET,
        .phys_io        = IXP4XX_PERIPHERAL_BASE_PHYS,
        .io_pg_offst    = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
-       .map_io         = ixdp425_map_io,
+       .map_io         = ixp4xx_map_io,
        .init_irq       = ixp4xx_init_irq,
        .timer          = &ixp4xx_timer,
        .boot_params    = 0x0100,
@@ -157,7 +152,7 @@ MACHINE_START(IXCDP1100, "Intel IXCDP1100 Development Platform")
        .phys_ram       = PHYS_OFFSET,
        .phys_io        = IXP4XX_PERIPHERAL_BASE_PHYS,
        .io_pg_offst    = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
-       .map_io         = ixdp425_map_io,
+       .map_io         = ixp4xx_map_io,
        .init_irq       = ixp4xx_init_irq,
        .timer          = &ixp4xx_timer,
        .boot_params    = 0x0100,
@@ -176,7 +171,7 @@ MACHINE_START(AVILA, "Gateworks Avila Network Platform")
        .phys_ram       = PHYS_OFFSET,
        .phys_io        = IXP4XX_PERIPHERAL_BASE_PHYS,
        .io_pg_offst    = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
-       .map_io         = ixdp425_map_io,
+       .map_io         = ixp4xx_map_io,
        .init_irq       = ixp4xx_init_irq,
        .timer          = &ixp4xx_timer,
        .boot_params    = 0x0100,
index ce4563f006766b411a8758005b782c8752faed2c..fe5e7660de1d5e855594b45a6fdaf7cd4c152655 100644 (file)
@@ -29,8 +29,8 @@ extern struct pci_bus *ixp4xx_scan_bus(int nr, struct pci_sys_data *sys);
 
 void __init ixdpg425_pci_preinit(void)
 {
-       gpio_line_config(6, IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
-       gpio_line_config(7, IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
+       set_irq_type(IRQ_IXP4XX_GPIO6, IRQT_LOW);
+       set_irq_type(IRQ_IXP4XX_GPIO7, IRQT_LOW);
 
        gpio_line_isr_clear(6);
        gpio_line_isr_clear(7);
index beda7c2602fbe37bdeec9b1800d2b00acc6d0850..578a52461fdbc3c5670acdbc9b3d79bb4f8112eb 100644 (file)
@@ -13,4 +13,4 @@ extern struct sys_timer lh7a40x_timer;
 extern void lh7a400_init_irq (void);
 extern void lh7a404_init_irq (void);
 
-#define IRQ_DISPATCH(irq) irq_desc[irq].handle ((irq), &irq_desc[irq], regs)
+#define IRQ_DISPATCH(irq) desc_handle_irq((irq),(irq_desc + irq), regs)
index 7c08f6c2e1d0bc38d0864fb724349de0abcc41ec..c12a7833562570a4e88497c85b5381f3dd0ad080 100644 (file)
@@ -102,7 +102,7 @@ void innovator_fpga_IRQ_demux(unsigned int irq, struct irqdesc *desc,
             fpga_irq++, stat >>= 1) {
                if (stat & 1) {
                        d = irq_desc + fpga_irq;
-                       d->handle(fpga_irq, d, regs);
+                       desc_handle_irq(fpga_irq, d, regs);
                }
        }
 }
index 86b862f56e7e9ad046f0c374e156bb95eb990418..06ea730e8675f713784382b6d76a91e0d0695545 100644 (file)
@@ -60,6 +60,15 @@ static struct scoop_config corgi_scoop_setup = {
        .io_out         = CORGI_SCOOP_IO_OUT,
 };
 
+static struct scoop_pcmcia_dev corgi_pcmcia_scoop[] = {
+{
+       .dev        = &corgiscoop_device.dev,
+       .irq        = CORGI_IRQ_GPIO_CF_IRQ,
+       .cd_irq     = CORGI_IRQ_GPIO_CF_CD,
+       .cd_irq_str = "PCMCIA0 CD",
+},
+};
+
 struct platform_device corgiscoop_device = {
        .name           = "sharp-scoop",
        .id             = -1,
@@ -241,6 +250,9 @@ static void __init corgi_init(void)
        pxa_set_udc_info(&udc_info);
        pxa_set_mci_info(&corgi_mci_platform_data);
 
+       scoop_num = 1;
+       scoop_devs = &corgi_pcmcia_scoop[0];
+
        platform_add_devices(devices, ARRAY_SIZE(devices));
 }
 
index f3cac43124a51627acdd3f7ce86ca404f0d747ca..539b596005fc266b2c49f8d0edfa22d7758b1b13 100644 (file)
@@ -133,7 +133,7 @@ static struct irqchip pxa_low_gpio_chip = {
        .ack            = pxa_ack_low_gpio,
        .mask           = pxa_mask_low_irq,
        .unmask         = pxa_unmask_low_irq,
-       .type           = pxa_gpio_irq_type,
+       .set_type       = pxa_gpio_irq_type,
 };
 
 /*
@@ -157,7 +157,7 @@ static void pxa_gpio_demux_handler(unsigned int irq, struct irqdesc *desc,
                        mask >>= 2;
                        do {
                                if (mask & 1)
-                                       desc->handle(irq, desc, regs);
+                                       desc_handle_irq(irq, desc, regs);
                                irq++;
                                desc++;
                                mask >>= 1;
@@ -172,7 +172,7 @@ static void pxa_gpio_demux_handler(unsigned int irq, struct irqdesc *desc,
                        desc = irq_desc + irq;
                        do {
                                if (mask & 1)
-                                       desc->handle(irq, desc, regs);
+                                       desc_handle_irq(irq, desc, regs);
                                irq++;
                                desc++;
                                mask >>= 1;
@@ -187,7 +187,7 @@ static void pxa_gpio_demux_handler(unsigned int irq, struct irqdesc *desc,
                        desc = irq_desc + irq;
                        do {
                                if (mask & 1)
-                                       desc->handle(irq, desc, regs);
+                                       desc_handle_irq(irq, desc, regs);
                                irq++;
                                desc++;
                                mask >>= 1;
@@ -203,7 +203,7 @@ static void pxa_gpio_demux_handler(unsigned int irq, struct irqdesc *desc,
                        desc = irq_desc + irq;
                        do {
                                if (mask & 1)
-                                       desc->handle(irq, desc, regs);
+                                       desc_handle_irq(irq, desc, regs);
                                irq++;
                                desc++;
                                mask >>= 1;
@@ -241,7 +241,7 @@ static struct irqchip pxa_muxed_gpio_chip = {
        .ack            = pxa_ack_muxed_gpio,
        .mask           = pxa_mask_muxed_gpio,
        .unmask         = pxa_unmask_muxed_gpio,
-       .type           = pxa_gpio_irq_type,
+       .set_type       = pxa_gpio_irq_type,
 };
 
 
index 6309853b59bef49deafd753b6166ceea032e7d8e..923f6eb774c0c80a7e54a5bc7b9cfc45730437f7 100644 (file)
@@ -84,7 +84,7 @@ static void lubbock_irq_handler(unsigned int irq, struct irqdesc *desc,
                if (likely(pending)) {
                        irq = LUBBOCK_IRQ(0) + __ffs(pending);
                        desc = irq_desc + irq;
-                       desc->handle(irq, desc, regs);
+                       desc_handle_irq(irq, desc, regs);
                }
                pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
        } while (pending);
index 827b7b5a5be84438e2f3ceb55c6603198dfee23e..85fdb5b1470a140faa2e5b6a1d9fd02612ac337d 100644 (file)
@@ -72,7 +72,7 @@ static void mainstone_irq_handler(unsigned int irq, struct irqdesc *desc,
                if (likely(pending)) {
                        irq = MAINSTONE_IRQ(0) + __ffs(pending);
                        desc = irq_desc + irq;
-                       desc->handle(irq, desc, regs);
+                       desc_handle_irq(irq, desc, regs);
                }
                pending = MST_INTSETCLR & mainstone_irq_enabled;
        } while (pending);
index 0e4f6fab100a5456cb2d4bef67aa7ea5e7eb3109..47cfb8bb8318abc4812f7ca56a6a339c0645a3da 100644 (file)
@@ -62,6 +62,15 @@ struct platform_device poodle_scoop_device = {
        .resource       = poodle_scoop_resources,
 };
 
+static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
+{
+       .dev        = &poodle_scoop_device.dev,
+       .irq        = POODLE_IRQ_GPIO_CF_IRQ,
+       .cd_irq     = POODLE_IRQ_GPIO_CF_CD,
+       .cd_irq_str = "PCMCIA0 CD",
+},
+};
+
 
 /* LoCoMo device */
 static struct resource locomo_resources[] = {
@@ -147,6 +156,9 @@ static void __init poodle_init(void)
 
        set_pxa_fb_info(&poodle_fb_info);
 
+       scoop_num = 1;
+       scoop_devs = &poodle_pcmcia_scoop[0];
+
        ret = platform_add_devices(devices, ARRAY_SIZE(devices));
        if (ret) {
                printk(KERN_WARNING "poodle: Unable to register LoCoMo device\n");
index 6e5202154f911321a82e53e0b93d716726b57d5e..7dad3f1465e076028954b1f18169ed8b82b2502e 100644 (file)
@@ -70,6 +70,11 @@ static unsigned long pxa_gettimeoffset (void)
        return usec;
 }
 
+#ifdef CONFIG_NO_IDLE_HZ
+static unsigned long initial_match;
+static int match_posponed;
+#endif
+
 static irqreturn_t
 pxa_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
@@ -77,11 +82,19 @@ pxa_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 
        write_seqlock(&xtime_lock);
 
+#ifdef CONFIG_NO_IDLE_HZ
+       if (match_posponed) {
+               match_posponed = 0;
+               OSMR0 = initial_match;
+       }
+#endif
+
        /* Loop until we get ahead of the free running timer.
         * This ensures an exact clock tick count and time accuracy.
-        * IRQs are disabled inside the loop to ensure coherence between
-        * lost_ticks (updated in do_timer()) and the match reg value, so we
-        * can use do_gettimeofday() from interrupt handlers.
+        * Since IRQs are disabled at this point, coherence between
+        * lost_ticks(updated in do_timer()) and the match reg value is
+        * ensured, hence we can use do_gettimeofday() from interrupt
+        * handlers.
         *
         * HACK ALERT: it seems that the PXA timer regs aren't updated right
         * away in all cases when a write occurs.  We therefore compare with
@@ -126,6 +139,42 @@ static void __init pxa_timer_init(void)
        OSCR = 0;               /* initialize free-running timer, force first match */
 }
 
+#ifdef CONFIG_NO_IDLE_HZ
+static int pxa_dyn_tick_enable_disable(void)
+{
+       /* nothing to do */
+       return 0;
+}
+
+static void pxa_dyn_tick_reprogram(unsigned long ticks)
+{
+       if (ticks > 1) {
+               initial_match = OSMR0;
+               OSMR0 = initial_match + ticks * LATCH;
+               match_posponed = 1;
+       }
+}
+
+static irqreturn_t
+pxa_dyn_tick_handler(int irq, void *dev_id, struct pt_regs *regs)
+{
+       if (match_posponed) {
+               match_posponed = 0;
+               OSMR0 = initial_match;
+               if ( (signed long)(initial_match - OSCR) <= 8 )
+                       return pxa_timer_interrupt(irq, dev_id, regs);
+       }
+       return IRQ_NONE;
+}
+
+static struct dyn_tick_timer pxa_dyn_tick = {
+       .enable         = pxa_dyn_tick_enable_disable,
+       .disable        = pxa_dyn_tick_enable_disable,
+       .reprogram      = pxa_dyn_tick_reprogram,
+       .handler        = pxa_dyn_tick_handler,
+};
+#endif
+
 #ifdef CONFIG_PM
 static unsigned long osmr[4], oier;
 
@@ -161,4 +210,7 @@ struct sys_timer pxa_timer = {
        .suspend        = pxa_timer_suspend,
        .resume         = pxa_timer_resume,
        .offset         = pxa_gettimeoffset,
+#ifdef CONFIG_NO_IDLE_HZ
+       .dyn_tick       = &pxa_dyn_tick,
+#endif
 };
index 5e5bbe893cbb7f61fc620896b3a50c0164fdd71e..49914709fa09a9b44007e26fac065530f84751a9 100644 (file)
@@ -124,7 +124,7 @@ bast_irq_pc104_demux(unsigned int irq,
                        irqno = bast_pc104_irqs[i];
                        desc = irq_desc + irqno;
 
-                       desc->handle(irqno, desc, regs);
+                       desc_handle_irq(irqno, desc, regs);
                }
 
                stat >>= 1;
index 9a66050e887d0e99db09d53d1ab91bda120f6353..f59608268751f6769a920c49b73b75fa8ab1fce4 100644 (file)
@@ -388,6 +388,7 @@ int __init s3c24xx_setup_clocks(unsigned long xtal,
                                unsigned long hclk,
                                unsigned long pclk)
 {
+       unsigned long clkslow = __raw_readl(S3C2410_CLKSLOW);
        struct clk *clkp = init_clocks;
        int ptr;
        int ret;
@@ -446,5 +447,13 @@ int __init s3c24xx_setup_clocks(unsigned long xtal,
                }
        }
 
+       /* show the clock-slow value */
+
+       printk("CLOCK: Slow mode (%ld.%ld MHz), %s, MPLL %s, UPLL %s\n",
+              print_mhz(xtal / ( 2 * S3C2410_CLKSLOW_GET_SLOWVAL(clkslow))),
+              (clkslow & S3C2410_CLKSLOW_SLOW) ? "slow" : "fast",
+              (clkslow & S3C2410_CLKSLOW_MPLL_OFF) ? "off" : "on",
+              (clkslow & S3C2410_CLKSLOW_UCLK_OFF) ? "off" : "on");
+
        return 0;
 }
index 973a5fe6769c515d87c6f409b36223fdd93d05a6..66d8c068e940b9436693361f7bdd5dc5f941bc6e 100644 (file)
@@ -184,14 +184,14 @@ struct irqchip s3c_irq_level_chip = {
        .ack       = s3c_irq_maskack,
        .mask      = s3c_irq_mask,
        .unmask    = s3c_irq_unmask,
-       .wake      = s3c_irq_wake
+       .set_wake          = s3c_irq_wake
 };
 
 static struct irqchip s3c_irq_chip = {
        .ack       = s3c_irq_ack,
        .mask      = s3c_irq_mask,
        .unmask    = s3c_irq_unmask,
-       .wake      = s3c_irq_wake
+       .set_wake          = s3c_irq_wake
 };
 
 /* S3C2410_EINTMASK
@@ -350,16 +350,16 @@ static struct irqchip s3c_irqext_chip = {
        .mask       = s3c_irqext_mask,
        .unmask     = s3c_irqext_unmask,
        .ack        = s3c_irqext_ack,
-       .type       = s3c_irqext_type,
-       .wake       = s3c_irqext_wake
+       .set_type    = s3c_irqext_type,
+       .set_wake    = s3c_irqext_wake
 };
 
 static struct irqchip s3c_irq_eint0t4 = {
        .ack       = s3c_irq_ack,
        .mask      = s3c_irq_mask,
        .unmask    = s3c_irq_unmask,
-       .wake      = s3c_irq_wake,
-       .type      = s3c_irqext_type,
+       .set_wake  = s3c_irq_wake,
+       .set_type  = s3c_irqext_type,
 };
 
 /* mask values for the parent registers for each of the interrupt types */
@@ -496,11 +496,11 @@ static void s3c_irq_demux_adc(unsigned int irq,
        if (subsrc != 0) {
                if (subsrc & 1) {
                        mydesc = irq_desc + IRQ_TC;
-                       mydesc->handle( IRQ_TC, mydesc, regs);
+                       desc_handle_irq(IRQ_TC, mydesc, regs);
                }
                if (subsrc & 2) {
                        mydesc = irq_desc + IRQ_ADC;
-                       mydesc->handle(IRQ_ADC, mydesc, regs);
+                       desc_handle_irq(IRQ_ADC, mydesc, regs);
                }
        }
 }
@@ -529,17 +529,17 @@ static void s3c_irq_demux_uart(unsigned int start,
                desc = irq_desc + start;
 
                if (subsrc & 1)
-                       desc->handle(start, desc, regs);
+                       desc_handle_irq(start, desc, regs);
 
                desc++;
 
                if (subsrc & 2)
-                       desc->handle(start+1, desc, regs);
+                       desc_handle_irq(start+1, desc, regs);
 
                desc++;
 
                if (subsrc & 4)
-                       desc->handle(start+2, desc, regs);
+                       desc_handle_irq(start+2, desc, regs);
        }
 }
 
index 79044d9bce38c281644c70a94a5ffd58348dcbda..66bf5bb2b3db2a2b18120379e098496a2700decc 100644 (file)
@@ -110,34 +110,24 @@ void __init n30_init_irq(void)
        s3c24xx_init_irq();
 }
 
-
-static int n30_usbstart_thread(void *unused)
-{
-       /* Turn off suspend on both USB ports, and switch the
-        * selectable USB port to USB device mode. */
-       writel(readl(S3C2410_MISCCR) & ~0x00003008, S3C2410_MISCCR);
-
-       /* Turn off the D+ pull up for 3 seconds so that the USB host
-        * at the other end will do a rescan of the USB bus.  */
-       s3c2410_gpio_setpin(S3C2410_GPB3, 0);
-
-       msleep_interruptible(3*HZ);
-
-       s3c2410_gpio_setpin(S3C2410_GPB3, 1);
-
-       return 0;
-}
-
+/* GPB3 is the line that controls the pull-up for the USB D+ line */
 
 void __init n30_init(void)
 {
        s3c_device_i2c.dev.platform_data = &n30_i2ccfg;
 
-       kthread_run(n30_usbstart_thread, NULL, "n30_usbstart");
+       /* Turn off suspend on both USB ports, and switch the
+        * selectable USB port to USB device mode. */
+
+       s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
+                             S3C2410_MISCCR_USBSUSPND0 |
+                             S3C2410_MISCCR_USBSUSPND1, 0x0);
 }
 
 MACHINE_START(N30, "Acer-N30")
-       /* Maintainer: Christer Weinigel <christer@weinigel.se>, Ben Dooks <ben-linux@fluff.org> */
+       /* Maintainer: Christer Weinigel <christer@weinigel.se>,
+                               Ben Dooks <ben-linux@fluff.org>
+       */
        .phys_ram       = S3C2410_SDRAM_PA,
        .phys_io        = S3C2410_PA_UART,
        .io_pg_offst    = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
index 13a48ee7748434814fc5b325a24a61d52b8dafe7..fe57d966a34d126b62194950ea10882f6c3a20fc 100644 (file)
@@ -585,14 +585,16 @@ static int s3c2410_pm_enter(suspend_state_t state)
 
        s3c2410_pm_check_store();
 
-       // need to make some form of time-delta
-
        /* send the cpu to sleep... */
 
        __raw_writel(0x00, S3C2410_CLKCON);  /* turn off clocks over sleep */
 
        s3c2410_cpu_suspend(regs_save);
 
+       /* restore the cpu state */
+
+       cpu_init();
+
        /* unset the return-from-sleep flag, to ensure reset */
 
        tmp = __raw_readl(S3C2410_GSTATUS2);
index b018a1f680cef41c83b461f1a0b28c4203b91dc0..c67e0979aec38476635be1f2a9e990079c4c6082 100644 (file)
@@ -68,6 +68,7 @@ static struct clk s3c2440_clk_ac97 = {
 static int s3c2440_clk_add(struct sys_device *sysdev)
 {
        unsigned long upllcon = __raw_readl(S3C2410_UPLLCON);
+       unsigned long camdivn = __raw_readl(S3C2440_CAMDIVN);
        struct clk *clk_h;
        struct clk *clk_p;
        struct clk *clk_xtal;
@@ -80,8 +81,9 @@ static int s3c2440_clk_add(struct sys_device *sysdev)
 
        s3c2440_clk_upll.rate = s3c2410_get_pll(upllcon, clk_xtal->rate);
 
-       printk("S3C2440: Clock Support, UPLL %ld.%03ld MHz\n",
-              print_mhz(s3c2440_clk_upll.rate));
+       printk("S3C2440: Clock Support, UPLL %ld.%03ld MHz, DVS %s\n",
+              print_mhz(s3c2440_clk_upll.rate),
+              (camdivn & S3C2440_CAMDIVN_DVSEN) ? "on" : "off");
 
        clk_p = clk_get(NULL, "pclk");
        clk_h = clk_get(NULL, "hclk");
index 7cb9912242a3964b66c3e686bb5688595c3e4e5c..278d0044c85d7c3315e46363094c3c125bb85dfe 100644 (file)
@@ -64,11 +64,11 @@ static void s3c_irq_demux_wdtac97(unsigned int irq,
        if (subsrc != 0) {
                if (subsrc & 1) {
                        mydesc = irq_desc + IRQ_S3C2440_WDT;
-                       mydesc->handle( IRQ_S3C2440_WDT, mydesc, regs);
+                       desc_handle_irq(IRQ_S3C2440_WDT, mydesc, regs);
                }
                if (subsrc & 2) {
                        mydesc = irq_desc + IRQ_S3C2440_AC97;
-                       mydesc->handle(IRQ_S3C2440_AC97, mydesc, regs);
+                       desc_handle_irq(IRQ_S3C2440_AC97, mydesc, regs);
                }
        }
 }
@@ -122,11 +122,11 @@ static void s3c_irq_demux_cam(unsigned int irq,
        if (subsrc != 0) {
                if (subsrc & 1) {
                        mydesc = irq_desc + IRQ_S3C2440_CAM_C;
-                       mydesc->handle( IRQ_S3C2440_WDT, mydesc, regs);
+                       desc_handle_irq(IRQ_S3C2440_CAM_C, mydesc, regs);
                }
                if (subsrc & 2) {
                        mydesc = irq_desc + IRQ_S3C2440_CAM_P;
-                       mydesc->handle(IRQ_S3C2440_AC97, mydesc, regs);
+                       desc_handle_irq(IRQ_S3C2440_CAM_P, mydesc, regs);
                }
        }
 }
index 66a929cb7bc5ba5549e670552c104bf08f14039b..c131a5201b5ba885ba9448381cfaab27ab345634 100644 (file)
@@ -98,8 +98,8 @@ static struct irqchip sa1100_low_gpio_chip = {
        .ack            = sa1100_low_gpio_ack,
        .mask           = sa1100_low_gpio_mask,
        .unmask         = sa1100_low_gpio_unmask,
-       .type           = sa1100_gpio_type,
-       .wake           = sa1100_low_gpio_wake,
+       .set_type       = sa1100_gpio_type,
+       .set_wake       = sa1100_low_gpio_wake,
 };
 
 /*
@@ -126,7 +126,7 @@ sa1100_high_gpio_handler(unsigned int irq, struct irqdesc *desc,
                mask >>= 11;
                do {
                        if (mask & 1)
-                               desc->handle(irq, desc, regs);
+                               desc_handle_irq(irq, desc, regs);
                        mask >>= 1;
                        irq++;
                        desc++;
@@ -181,8 +181,8 @@ static struct irqchip sa1100_high_gpio_chip = {
        .ack            = sa1100_high_gpio_ack,
        .mask           = sa1100_high_gpio_mask,
        .unmask         = sa1100_high_gpio_unmask,
-       .type           = sa1100_gpio_type,
-       .wake           = sa1100_high_gpio_wake,
+       .set_type       = sa1100_gpio_type,
+       .set_wake       = sa1100_high_gpio_wake,
 };
 
 /*
index 1405383463ea7503f940980c93c6dbb83adbe64d..fc061641b7be083cb44d89e33fa22c3826e9c272 100644 (file)
@@ -61,12 +61,12 @@ neponset_irq_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *reg
 
                        if (irr & IRR_ETHERNET) {
                                d = irq_desc + IRQ_NEPONSET_SMC9196;
-                               d->handle(IRQ_NEPONSET_SMC9196, d, regs);
+                               desc_handle_irq(IRQ_NEPONSET_SMC9196, d, regs);
                        }
 
                        if (irr & IRR_USAR) {
                                d = irq_desc + IRQ_NEPONSET_USAR;
-                               d->handle(IRQ_NEPONSET_USAR, d, regs);
+                               desc_handle_irq(IRQ_NEPONSET_USAR, d, regs);
                        }
 
                        desc->chip->unmask(irq);
@@ -74,7 +74,7 @@ neponset_irq_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *reg
 
                if (irr & IRR_SA1111) {
                        d = irq_desc + IRQ_NEPONSET_SA1111;
-                       d->handle(IRQ_NEPONSET_SA1111, d, regs);
+                       desc_handle_irq(IRQ_NEPONSET_SA1111, d, regs);
                }
        }
 }
index 0eeb3616ffea739652f8221504da7a1548374171..47e0420623fc25083a486f74887bff522260108b 100644 (file)
@@ -70,15 +70,11 @@ static unsigned long sa1100_gettimeoffset (void)
        return usec;
 }
 
-/*
- * We will be entered with IRQs enabled.
- *
- * Loop until we get ahead of the free running timer.
- * This ensures an exact clock tick count and time accuracy.
- * IRQs are disabled inside the loop to ensure coherence between
- * lost_ticks (updated in do_timer()) and the match reg value, so we
- * can use do_gettimeofday() from interrupt handlers.
- */
+#ifdef CONFIG_NO_IDLE_HZ
+static unsigned long initial_match;
+static int match_posponed;
+#endif
+
 static irqreturn_t
 sa1100_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
@@ -86,6 +82,21 @@ sa1100_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 
        write_seqlock(&xtime_lock);
 
+#ifdef CONFIG_NO_IDLE_HZ
+       if (match_posponed) {
+               match_posponed = 0;
+               OSMR0 = initial_match;
+       }
+#endif
+
+       /*
+        * Loop until we get ahead of the free running timer.
+        * This ensures an exact clock tick count and time accuracy.
+        * Since IRQs are disabled at this point, coherence between
+        * lost_ticks(updated in do_timer()) and the match reg value is
+        * ensured, hence we can use do_gettimeofday() from interrupt
+        * handlers.
+        */
        do {
                timer_tick(regs);
                OSSR = OSSR_M0;  /* Clear match on timer 0 */
@@ -120,6 +131,42 @@ static void __init sa1100_timer_init(void)
        OSCR = 0;               /* initialize free-running timer, force first match */
 }
 
+#ifdef CONFIG_NO_IDLE_HZ
+static int sa1100_dyn_tick_enable_disable(void)
+{
+       /* nothing to do */
+       return 0;
+}
+
+static void sa1100_dyn_tick_reprogram(unsigned long ticks)
+{
+       if (ticks > 1) {
+               initial_match = OSMR0;
+               OSMR0 = initial_match + ticks * LATCH;
+               match_posponed = 1;
+       }
+}
+
+static irqreturn_t
+sa1100_dyn_tick_handler(int irq, void *dev_id, struct pt_regs *regs)
+{
+       if (match_posponed) {
+               match_posponed = 0;
+               OSMR0 = initial_match;
+               if ((signed long)(initial_match - OSCR) <= 0)
+                       return sa1100_timer_interrupt(irq, dev_id, regs);
+       }
+       return IRQ_NONE;
+}
+
+static struct dyn_tick_timer sa1100_dyn_tick = {
+       .enable         = sa1100_dyn_tick_enable_disable,
+       .disable        = sa1100_dyn_tick_enable_disable,
+       .reprogram      = sa1100_dyn_tick_reprogram,
+       .handler        = sa1100_dyn_tick_handler,
+};
+#endif
+
 #ifdef CONFIG_PM
 unsigned long osmr[4], oier;
 
@@ -156,4 +203,7 @@ struct sys_timer sa1100_timer = {
        .suspend        = sa1100_timer_suspend,
        .resume         = sa1100_timer_resume,
        .offset         = sa1100_gettimeoffset,
+#ifdef CONFIG_NO_IDLE_HZ
+       .dyn_tick       = &sa1100_dyn_tick,
+#endif
 };
index f01c0f8a2bb369ccb7dfb47dc5ea75c13443d0b9..3c8862fde51ad18a362713f821757b1cba4a3903 100644 (file)
@@ -108,7 +108,7 @@ sic_handle_irq(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
                irq += IRQ_SIC_START;
 
                desc = irq_desc + irq;
-               desc->handle(irq, desc, regs);
+               desc_handle_irq(irq, desc, regs);
        } while (status);
 }
 
index 81f4a8a2d34b2c7af8c93074ca8f0c443fb80bc2..4b39d867ac14ef5e4ced59cd5ba3c6157e6427de 100644 (file)
@@ -45,7 +45,7 @@
 
 #define LDST_P_EQ_U(i) ((((i) ^ ((i) >> 1)) & (1 << 23)) == 0)
 
-#define LDSTH_I_BIT(i) (i & (1 << 22))         /* half-word immed      */
+#define LDSTHD_I_BIT(i)        (i & (1 << 22))         /* double/half-word immed */
 #define LDM_S_BIT(i)   (i & (1 << 22))         /* write CPSR from SPSR */
 
 #define RN_BITS(i)     ((i >> 16) & 15)        /* Rn                   */
@@ -68,6 +68,7 @@ static unsigned long ai_sys;
 static unsigned long ai_skipped;
 static unsigned long ai_half;
 static unsigned long ai_word;
+static unsigned long ai_dword;
 static unsigned long ai_multi;
 static int ai_usermode;
 
@@ -93,6 +94,8 @@ proc_alignment_read(char *page, char **start, off_t off, int count, int *eof,
        p += sprintf(p, "Skipped:\t%lu\n", ai_skipped);
        p += sprintf(p, "Half:\t\t%lu\n", ai_half);
        p += sprintf(p, "Word:\t\t%lu\n", ai_word);
+       if (cpu_architecture() >= CPU_ARCH_ARMv5TE)
+               p += sprintf(p, "DWord:\t\t%lu\n", ai_dword);
        p += sprintf(p, "Multi:\t\t%lu\n", ai_multi);
        p += sprintf(p, "User faults:\t%i (%s)\n", ai_usermode,
                        usermode_action[ai_usermode]);
@@ -283,12 +286,6 @@ do_alignment_ldrhstrh(unsigned long addr, unsigned long instr, struct pt_regs *r
 {
        unsigned int rd = RD_BITS(instr);
 
-       if ((instr & 0x01f00ff0) == 0x01000090)
-               goto swp;
-
-       if ((instr & 0x90) != 0x90 || (instr & 0x60) == 0)
-               goto bad;
-
        ai_half += 1;
 
        if (user_mode(regs))
@@ -323,10 +320,47 @@ do_alignment_ldrhstrh(unsigned long addr, unsigned long instr, struct pt_regs *r
 
        return TYPE_LDST;
 
- swp:
-       printk(KERN_ERR "Alignment trap: not handling swp instruction\n");
- bad:
-       return TYPE_ERROR;
+ fault:
+       return TYPE_FAULT;
+}
+
+static int
+do_alignment_ldrdstrd(unsigned long addr, unsigned long instr,
+                     struct pt_regs *regs)
+{
+       unsigned int rd = RD_BITS(instr);
+
+       ai_dword += 1;
+
+       if (user_mode(regs))
+               goto user;
+
+       if ((instr & 0xf0) == 0xd0) {
+               unsigned long val;
+               get32_unaligned_check(val, addr);
+               regs->uregs[rd] = val;
+               get32_unaligned_check(val, addr+4);
+               regs->uregs[rd+1] = val;
+       } else {
+               put32_unaligned_check(regs->uregs[rd], addr);
+               put32_unaligned_check(regs->uregs[rd+1], addr+4);
+       }
+
+       return TYPE_LDST;
+
+ user:
+       if ((instr & 0xf0) == 0xd0) {
+               unsigned long val;
+               get32t_unaligned_check(val, addr);
+               regs->uregs[rd] = val;
+               get32t_unaligned_check(val, addr+4);
+               regs->uregs[rd+1] = val;
+       } else {
+               put32t_unaligned_check(regs->uregs[rd], addr);
+               put32t_unaligned_check(regs->uregs[rd+1], addr+4);
+       }
+
+       return TYPE_LDST;
 
  fault:
        return TYPE_FAULT;
@@ -617,12 +651,20 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
        regs->ARM_pc += thumb_mode(regs) ? 2 : 4;
 
        switch (CODING_BITS(instr)) {
-       case 0x00000000:        /* ldrh or strh */
-               if (LDSTH_I_BIT(instr))
+       case 0x00000000:        /* 3.13.4 load/store instruction extensions */
+               if (LDSTHD_I_BIT(instr))
                        offset.un = (instr & 0xf00) >> 4 | (instr & 15);
                else
                        offset.un = regs->uregs[RM_BITS(instr)];
-               handler = do_alignment_ldrhstrh;
+
+               if ((instr & 0x000000f0) == 0x000000b0 || /* LDRH, STRH */
+                   (instr & 0x001000f0) == 0x001000f0)   /* LDRSH */
+                       handler = do_alignment_ldrhstrh;
+               else if ((instr & 0x001000f0) == 0x000000d0 || /* LDRD */
+                        (instr & 0x001000f0) == 0x000000f0)   /* STRD */
+                       handler = do_alignment_ldrdstrd;
+               else
+                       goto bad;
                break;
 
        case 0x04000000:        /* ldr or str immediate */
index 3c655c54e23131b10cbf33d3d1fb1fe4a81d52be..d125a3dc061c8fb5efb27ceed11ce731ddafe4a5 100644 (file)
@@ -275,11 +275,9 @@ alloc_init_supersection(unsigned long virt, unsigned long phys, int prot)
        int i;
 
        for (i = 0; i < 16; i += 1) {
-               alloc_init_section(virt, phys & SUPERSECTION_MASK,
-                                  prot | PMD_SECT_SUPER);
+               alloc_init_section(virt, phys, prot | PMD_SECT_SUPER);
 
                virt += (PGDIR_SIZE / 2);
-               phys += (PGDIR_SIZE / 2);
        }
 }
 
@@ -297,14 +295,10 @@ alloc_init_page(unsigned long virt, unsigned long phys, unsigned int prot_l1, pg
        pte_t *ptep;
 
        if (pmd_none(*pmdp)) {
-               unsigned long pmdval;
                ptep = alloc_bootmem_low_pages(2 * PTRS_PER_PTE *
                                               sizeof(pte_t));
 
-               pmdval = __pa(ptep) | prot_l1;
-               pmdp[0] = __pmd(pmdval);
-               pmdp[1] = __pmd(pmdval + 256 * sizeof(pte_t));
-               flush_pmd_entry(pmdp);
+               __pmd_populate(pmdp, __pa(ptep) | prot_l1);
        }
        ptep = pte_offset_kernel(pmdp, virt);
 
@@ -459,7 +453,7 @@ static void __init build_mem_type_table(void)
 
        for (i = 0; i < 16; i++) {
                unsigned long v = pgprot_val(protection_map[i]);
-               v &= (~(PTE_BUFFERABLE|PTE_CACHEABLE)) | user_pgprot;
+               v = (v & ~(PTE_BUFFERABLE|PTE_CACHEABLE)) | user_pgprot;
                protection_map[i] = __pgprot(v);
        }
 
@@ -583,23 +577,23 @@ static void __init create_mapping(struct map_desc *md)
  */
 void setup_mm_for_reboot(char mode)
 {
-       unsigned long pmdval;
+       unsigned long base_pmdval;
        pgd_t *pgd;
-       pmd_t *pmd;
        int i;
-       int cpu_arch = cpu_architecture();
 
        if (current->mm && current->mm->pgd)
                pgd = current->mm->pgd;
        else
                pgd = init_mm.pgd;
 
-       for (i = 0; i < FIRST_USER_PGD_NR + USER_PTRS_PER_PGD; i++) {
-               pmdval = (i << PGDIR_SHIFT) |
-                        PMD_SECT_AP_WRITE | PMD_SECT_AP_READ |
-                        PMD_TYPE_SECT;
-               if (cpu_arch <= CPU_ARCH_ARMv5TEJ)
-                       pmdval |= PMD_BIT4;
+       base_pmdval = PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | PMD_TYPE_SECT;
+       if (cpu_architecture() <= CPU_ARCH_ARMv5TEJ)
+               base_pmdval |= PMD_BIT4;
+
+       for (i = 0; i < FIRST_USER_PGD_NR + USER_PTRS_PER_PGD; i++, pgd++) {
+               unsigned long pmdval = (i << PGDIR_SHIFT) | base_pmdval;
+               pmd_t *pmd;
+
                pmd = pmd_off(pgd, i << PGDIR_SHIFT);
                pmd[0] = __pmd(pmdval);
                pmd[1] = __pmd(pmdval + (1 << (PGDIR_SHIFT - 1)));
index 0ee214b824ff2a9cffd5d136180e76a61fb9d197..189ef6a71ba102b49b66b2414a96d470332e3f46 100644 (file)
@@ -38,8 +38,8 @@ ENTRY(cpu_arm7_data_abort)
        mrc     p15, 0, r1, c5, c0, 0           @ get FSR
        mrc     p15, 0, r0, c6, c0, 0           @ get FAR
        ldr     r8, [r0]                        @ read arm instruction
-       tst     r8, #1 << 20                    @ L = 1 -> write?
-       orreq   r1, r1, #1 <<                 @ yes.
+       tst     r8, #1 << 20                    @ L = 0 -> write?
+       orreq   r1, r1, #1 << 11                @ yes.
        and     r7, r8, #15 << 24
        add     pc, pc, r7, lsr #22             @ Now branch to the relevant processing routine
        nop
@@ -71,8 +71,8 @@ ENTRY(cpu_arm6_data_abort)
        mrc     p15, 0, r1, c5, c0, 0           @ get FSR
        mrc     p15, 0, r0, c6, c0, 0           @ get FAR
        ldr     r8, [r2]                        @ read arm instruction
-       tst     r8, #1 << 20                    @ L = 1 -> write?
-       orreq   r1, r1, #1 <<                 @ yes.
+       tst     r8, #1 << 20                    @ L = 0 -> write?
+       orreq   r1, r1, #1 << 11                @ yes.
        and     r7, r8, #14 << 24
        teq     r7, #8 << 24                    @ was it ldm/stm
        movne   pc, lr
index 1c85b4e536c2e005b25f2249113bec4e60d97a5c..aa481ea3d702c0fb00035a1941be2bdbc0d999eb 100644 (file)
@@ -590,7 +590,7 @@ static void gpio_irq_handler(unsigned int irq, struct irqdesc *desc,
                if (!(isr & 1))
                        continue;
                d = irq_desc + gpio_irq;
-               d->handle(gpio_irq, d, regs);
+               desc_handle_irq(gpio_irq, d, regs);
        }
 }
 
index cd72324935c45cd1c01c74b88880352cbc5a5b78..0a1d62a23614884b82d8af1bef6d06f127fb629c 100644 (file)
@@ -5,10 +5,13 @@ config PROFILING
        bool "Kernel profiling support"
 
 config SYSTEM_PROFILER
-        bool "System profiling support"
+       bool "System profiling support"
+
+source "lib/Kconfig.debug"
 
 config ETRAX_KGDB
        bool "Use kernel GDB debugger"
+       depends on DEBUG_KERNEL
        ---help---
          The CRIS version of gdb can be used to remotely debug a running
          Linux kernel via the serial debug port.  Provided you have gdb-cris
@@ -22,25 +25,11 @@ config ETRAX_KGDB
          this option is turned on!
 
 
-config DEBUG_INFO
-        bool "Compile the kernel with debug info"
-        help
-          If you say Y here the resulting kernel image will include
-          debugging info resulting in a larger kernel image.
-          Say Y here only if you plan to use gdb to debug the kernel.
-          If you don't debug the kernel, you can say N.
-
-config FRAME_POINTER
-        bool "Compile the kernel with frame pointers"
-        help
-          If you say Y here the resulting kernel image will be slightly larger
-          and slower, but it will give very useful debugging information.
-          If you don't debug the kernel, you can say N, but we may not be able
-          to solve problems without frame pointers.
-
 config DEBUG_NMI_OOPS
-       bool "NMI causes oops printout"
-       help
-         If the system locks up without any debug information you can say Y
-         here to make it possible to dump an OOPS with an external NMI.
+       bool "NMI causes oops printout"
+       depends on DEBUG_KERNEL
+       help
+         If the system locks up without any debug information you can say Y
+         here to make it possible to dump an OOPS with an external NMI.
+
 endmenu
index 62cfbd9b4f98d6f2f62c79743cc085557e8af5e2..1a76d52471902975401703d0bcb3d107fc787238 100644 (file)
@@ -71,7 +71,6 @@ EXPORT_SYMBOL(memset);
 EXPORT_SYMBOL(memcmp);
 EXPORT_SYMBOL(memscan);
 EXPORT_SYMBOL(memmove);
-EXPORT_SYMBOL(strtok);
 
 EXPORT_SYMBOL(get_wchan);
 
index 619d843ba231492dfb7100d32734ea711c391e7c..3b3b017e1c154fa9419dfec55b969cb48e91b608 100644 (file)
@@ -14,6 +14,10 @@ config X86
          486, 586, Pentiums, and various instruction-set-compatible chips by
          AMD, Cyrix, and others.
 
+config SEMAPHORE_SLEEPERS
+       bool
+       default y
+
 config MMU
        bool
        default y
@@ -754,6 +758,7 @@ config NUMA
        depends on SMP && HIGHMEM64G && (X86_NUMAQ || X86_GENERICARCH || (X86_SUMMIT && ACPI))
        default n if X86_PC
        default y if (X86_NUMAQ || X86_SUMMIT)
+       select SPARSEMEM_STATIC
 
 # Need comments to help the hapless user trying to turn on NUMA support
 comment "NUMA (NUMA-Q) requires SMP, 64GB highmem support"
index 4cc83b322b362dc85739cc42e8df6b955bc7da7e..64682a0edacf5c54490fe5928c1ce716f82be522 100644 (file)
@@ -7,7 +7,7 @@ extra-y := head.o init_task.o vmlinux.lds
 obj-y  := process.o semaphore.o signal.o entry.o traps.o irq.o vm86.o \
                ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \
                pci-dma.o i386_ksyms.o i387.o dmi_scan.o bootflag.o \
-               doublefault.o quirks.o
+               doublefault.o quirks.o i8237.o
 
 obj-y                          += cpu/
 obj-y                          += timers/
index b7808a89d94507fd41abf6c24bd471d5d9099209..34ee500c26e59a4a992dd6c89dbb5cd68ae3bd92 100644 (file)
@@ -833,6 +833,9 @@ acpi_process_madt(void)
                if (!error) {
                        acpi_lapic = 1;
 
+#ifdef CONFIG_X86_GENERICARCH
+                       generic_bigsmp_probe();
+#endif
                        /*
                         * Parse MADT IO-APIC entries
                         */
index 4553ffd94b1f9f2a645e75ba6982e80c40543cd0..46ce9b248f5510088ca7fd1765fcfdd86ea44bd9 100644 (file)
@@ -613,8 +613,8 @@ void __devinit cpu_init(void)
        memcpy(thread->tls_array, &per_cpu(cpu_gdt_table, cpu),
                GDT_ENTRY_TLS_ENTRIES * 8);
 
-       __asm__ __volatile__("lgdt %0" : : "m" (cpu_gdt_descr[cpu]));
-       __asm__ __volatile__("lidt %0" : : "m" (idt_descr));
+       load_gdt(&cpu_gdt_descr[cpu]);
+       load_idt(&idt_descr);
 
        /*
         * Delete NT
@@ -642,12 +642,12 @@ void __devinit cpu_init(void)
        asm volatile ("xorl %eax, %eax; movl %eax, %fs; movl %eax, %gs");
 
        /* Clear all 6 debug registers: */
-
-#define CD(register) set_debugreg(0, register)
-
-       CD(0); CD(1); CD(2); CD(3); /* no db4 and db5 */; CD(6); CD(7);
-
-#undef CD
+       set_debugreg(0, 0);
+       set_debugreg(0, 1);
+       set_debugreg(0, 2);
+       set_debugreg(0, 3);
+       set_debugreg(0, 6);
+       set_debugreg(0, 7);
 
        /*
         * Force FPU initialization:
index 04e3563da4fea19e2a7f0c2c0e0053855cda67f1..bf02b5026e6238ea13ff4743d856ecc5b9be5206 100644 (file)
@@ -64,8 +64,6 @@ static int dont_scale_voltage;
 #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "longhaul", msg)
 
 
-#define __hlt()     __asm__ __volatile__("hlt": : :"memory")
-
 /* Clock ratios multiplied by 10 */
 static int clock_ratio[32];
 static int eblcr_table[32];
@@ -168,11 +166,9 @@ static void do_powersaver(union msr_longhaul *longhaul,
        outb(0xFE,0x21);        /* TMR0 only */
        outb(0xFF,0x80);        /* delay */
 
-       local_irq_enable();
-
-       __hlt();
+       safe_halt();
        wrmsrl(MSR_VIA_LONGHAUL, longhaul->val);
-       __hlt();
+       halt();
 
        local_irq_disable();
 
@@ -251,9 +247,7 @@ static void longhaul_setstate(unsigned int clock_ratio_index)
                bcr2.bits.CLOCKMUL = clock_ratio_index;
                local_irq_disable();
                wrmsrl (MSR_VIA_BCR2, bcr2.val);
-               local_irq_enable();
-
-               __hlt();
+               safe_halt();
 
                /* Disable software clock multiplier */
                rdmsrl (MSR_VIA_BCR2, bcr2.val);
index ba4b01138c8f62d9a01c5b3f2d10549f3edc54c5..ff87cc22b323aee87165e19be9688bc300dcc978 100644 (file)
@@ -132,11 +132,7 @@ static void __init set_cx86_memwb(void)
        setCx86(CX86_CCR2, getCx86(CX86_CCR2) & ~0x04);
        /* set 'Not Write-through' */
        cr0 = 0x20000000;
-       __asm__("movl %%cr0,%%eax\n\t"
-               "orl %0,%%eax\n\t"
-               "movl %%eax,%%cr0\n"
-               : : "r" (cr0)
-               :"ax");
+       write_cr0(read_cr0() | cr0);
        /* CCR2 bit 2: lock NW bit and set WT1 */
        setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x14 );
 }
index a2c33c1a46c5c9a620c3d33c5372ead800120a44..43601de0f6331415aaa8b19594112a3de080ae4f 100644 (file)
@@ -82,16 +82,13 @@ static void __devinit Intel_errata_workarounds(struct cpuinfo_x86 *c)
  */
 static int __devinit num_cpu_cores(struct cpuinfo_x86 *c)
 {
-       unsigned int eax;
+       unsigned int eax, ebx, ecx, edx;
 
        if (c->cpuid_level < 4)
                return 1;
 
-       __asm__("cpuid"
-               : "=a" (eax)
-               : "0" (4), "c" (0)
-               : "bx", "dx");
-
+       /* Intel has a non-standard dependency on %ecx for this CPUID level. */
+       cpuid_count(4, 0, &eax, &ebx, &ecx, &edx);
        if (eax & 0x1f)
                return ((eax >> 26) + 1);
        else
index 6c55b50cf048af7bef9df49bb78b6daa8b71c4ac..9e0d5f83cb9f63879b59b06683449d97923e4ce9 100644 (file)
@@ -305,6 +305,9 @@ static void __devinit cache_shared_cpu_map_setup(unsigned int cpu, int index)
 {
        struct _cpuid4_info     *this_leaf;
        unsigned long num_threads_sharing;
+#ifdef CONFIG_X86_HT
+       struct cpuinfo_x86 *c = cpu_data + cpu;
+#endif
 
        this_leaf = CPUID4_INFO_IDX(cpu, index);
        num_threads_sharing = 1 + this_leaf->eax.split.num_threads_sharing;
@@ -314,10 +317,12 @@ static void __devinit cache_shared_cpu_map_setup(unsigned int cpu, int index)
 #ifdef CONFIG_X86_HT
        else if (num_threads_sharing == smp_num_siblings)
                this_leaf->shared_cpu_map = cpu_sibling_map[cpu];
-#endif
+       else if (num_threads_sharing == (c->x86_num_cores * smp_num_siblings))
+               this_leaf->shared_cpu_map = cpu_core_map[cpu];
        else
-               printk(KERN_INFO "Number of CPUs sharing cache didn't match "
+               printk(KERN_DEBUG "Number of CPUs sharing cache didn't match "
                                "any known set of CPUs\n");
+#endif
 }
 #else
 static void __init cache_shared_cpu_map_setup(unsigned int cpu, int index) {}
index 764cac64e21191310d198e3bd590564e6939d76f..dd4ebd6af7e4cc5e014dff4ab72a3a1ac2650619 100644 (file)
@@ -561,7 +561,7 @@ struct mtrr_value {
 
 static struct mtrr_value * mtrr_state;
 
-static int mtrr_save(struct sys_device * sysdev, u32 state)
+static int mtrr_save(struct sys_device * sysdev, pm_message_t state)
 {
        int i;
        int size = num_var_ranges * sizeof(struct mtrr_value);
index e5fab12f79261a7856d298ac92765d1efa4d075b..913be77bb8446569d99175f0ff6556567bea531b 100644 (file)
@@ -153,7 +153,7 @@ static int crash_nmi_callback(struct pt_regs *regs, int cpu)
        disable_local_APIC();
        atomic_dec(&waiting_for_crash_ipi);
        /* Assume hlt works */
-       __asm__("hlt");
+       halt();
        for(;;);
 
        return 1;
index 789af3e9fb1fff597529ea62a80fc81a9fa2cc6c..5edb1d379add9d24bd353e2ade6c176d0a3cdca5 100644 (file)
@@ -20,7 +20,7 @@ static void doublefault_fn(void)
        struct Xgt_desc_struct gdt_desc = {0, 0};
        unsigned long gdt, tss;
 
-       __asm__ __volatile__("sgdt %0": "=m" (gdt_desc): :"memory");
+       store_gdt(&gdt_desc);
        gdt = gdt_desc.address;
 
        printk("double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
index 385883ea8c199d1008d0db050e1c71ec32ce64ec..ecad519fd395f6a17607c65737713f5aca26c3d3 100644 (file)
@@ -79,7 +79,7 @@ static void efi_call_phys_prelog(void)
         * directory. If I have PSE, I just need to duplicate one entry in
         * page directory.
         */
-       __asm__ __volatile__("movl %%cr4, %0":"=r"(cr4));
+       cr4 = read_cr4();
 
        if (cr4 & X86_CR4_PSE) {
                efi_bak_pg_dir_pointer[0].pgd =
@@ -104,8 +104,7 @@ static void efi_call_phys_prelog(void)
        local_flush_tlb();
 
        cpu_gdt_descr[0].address = __pa(cpu_gdt_descr[0].address);
-       __asm__ __volatile__("lgdt %0":"=m"
-                           (*(struct Xgt_desc_struct *) __pa(&cpu_gdt_descr[0])));
+       load_gdt((struct Xgt_desc_struct *) __pa(&cpu_gdt_descr[0]));
 }
 
 static void efi_call_phys_epilog(void)
@@ -114,8 +113,8 @@ static void efi_call_phys_epilog(void)
 
        cpu_gdt_descr[0].address =
                (unsigned long) __va(cpu_gdt_descr[0].address);
-       __asm__ __volatile__("lgdt %0":"=m"(cpu_gdt_descr));
-       __asm__ __volatile__("movl %%cr4, %0":"=r"(cr4));
+       load_gdt(&cpu_gdt_descr[0]);
+       cr4 = read_cr4();
 
        if (cr4 & X86_CR4_PSE) {
                swapper_pg_dir[pgd_index(0)].pgd =
@@ -233,22 +232,23 @@ void __init efi_map_memmap(void)
 {
        memmap.map = NULL;
 
-       memmap.map = (efi_memory_desc_t *)
-               bt_ioremap((unsigned long) memmap.phys_map,
-                       (memmap.nr_map * sizeof(efi_memory_desc_t)));
-
+       memmap.map = bt_ioremap((unsigned long) memmap.phys_map,
+                       (memmap.nr_map * memmap.desc_size));
        if (memmap.map == NULL)
                printk(KERN_ERR PFX "Could not remap the EFI memmap!\n");
+
+       memmap.map_end = memmap.map + (memmap.nr_map * memmap.desc_size);
 }
 
 #if EFI_DEBUG
 static void __init print_efi_memmap(void)
 {
        efi_memory_desc_t *md;
+       void *p;
        int i;
 
-       for (i = 0; i < memmap.nr_map; i++) {
-               md = &memmap.map[i];
+       for (p = memmap.map, i = 0; p < memmap.map_end; p += memmap.desc_size, i++) {
+               md = p;
                printk(KERN_INFO "mem%02u: type=%u, attr=0x%llx, "
                        "range=[0x%016llx-0x%016llx) (%lluMB)\n",
                        i, md->type, md->attribute, md->phys_addr,
@@ -271,10 +271,10 @@ void efi_memmap_walk(efi_freemem_callback_t callback, void *arg)
        } prev, curr;
        efi_memory_desc_t *md;
        unsigned long start, end;
-       int i;
+       void *p;
 
-       for (i = 0; i < memmap.nr_map; i++) {
-               md = &memmap.map[i];
+       for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
+               md = p;
 
                if ((md->num_pages == 0) || (!is_available_memory(md)))
                        continue;
@@ -325,6 +325,7 @@ void __init efi_init(void)
        memmap.phys_map = EFI_MEMMAP;
        memmap.nr_map = EFI_MEMMAP_SIZE/EFI_MEMDESC_SIZE;
        memmap.desc_version = EFI_MEMDESC_VERSION;
+       memmap.desc_size = EFI_MEMDESC_SIZE;
 
        efi.systab = (efi_system_table_t *)
                boot_ioremap((unsigned long) efi_phys.systab,
@@ -428,22 +429,30 @@ void __init efi_init(void)
                printk(KERN_ERR PFX "Could not map the runtime service table!\n");
 
        /* Map the EFI memory map for use until paging_init() */
-
-       memmap.map = (efi_memory_desc_t *)
-               boot_ioremap((unsigned long) EFI_MEMMAP, EFI_MEMMAP_SIZE);
-
+       memmap.map = boot_ioremap((unsigned long) EFI_MEMMAP, EFI_MEMMAP_SIZE);
        if (memmap.map == NULL)
                printk(KERN_ERR PFX "Could not map the EFI memory map!\n");
 
-       if (EFI_MEMDESC_SIZE != sizeof(efi_memory_desc_t)) {
-               printk(KERN_WARNING PFX "Warning! Kernel-defined memdesc doesn't "
-                          "match the one from EFI!\n");
-       }
+       memmap.map_end = memmap.map + (memmap.nr_map * memmap.desc_size);
+
 #if EFI_DEBUG
        print_efi_memmap();
 #endif
 }
 
+static inline void __init check_range_for_systab(efi_memory_desc_t *md)
+{
+       if (((unsigned long)md->phys_addr <= (unsigned long)efi_phys.systab) &&
+               ((unsigned long)efi_phys.systab < md->phys_addr +
+               ((unsigned long)md->num_pages << EFI_PAGE_SHIFT))) {
+               unsigned long addr;
+
+               addr = md->virt_addr - md->phys_addr +
+                       (unsigned long)efi_phys.systab;
+               efi.systab = (efi_system_table_t *)addr;
+       }
+}
+
 /*
  * This function will switch the EFI runtime services to virtual mode.
  * Essentially, look through the EFI memmap and map every region that
@@ -457,43 +466,32 @@ void __init efi_enter_virtual_mode(void)
 {
        efi_memory_desc_t *md;
        efi_status_t status;
-       int i;
+       void *p;
 
        efi.systab = NULL;
 
-       for (i = 0; i < memmap.nr_map; i++) {
-               md = &memmap.map[i];
+       for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
+               md = p;
 
-               if (md->attribute & EFI_MEMORY_RUNTIME) {
-                       md->virt_addr =
-                               (unsigned long)ioremap(md->phys_addr,
-                                       md->num_pages << EFI_PAGE_SHIFT);
-                       if (!(unsigned long)md->virt_addr) {
-                               printk(KERN_ERR PFX "ioremap of 0x%lX failed\n",
-                                       (unsigned long)md->phys_addr);
-                       }
+               if (!(md->attribute & EFI_MEMORY_RUNTIME))
+                       continue;
 
-                       if (((unsigned long)md->phys_addr <=
-                                       (unsigned long)efi_phys.systab) &&
-                               ((unsigned long)efi_phys.systab <
-                                       md->phys_addr +
-                                       ((unsigned long)md->num_pages <<
-                                               EFI_PAGE_SHIFT))) {
-                               unsigned long addr;
-
-                               addr = md->virt_addr - md->phys_addr +
-                                               (unsigned long)efi_phys.systab;
-                               efi.systab = (efi_system_table_t *)addr;
-                       }
+               md->virt_addr = (unsigned long)ioremap(md->phys_addr,
+                       md->num_pages << EFI_PAGE_SHIFT);
+               if (!(unsigned long)md->virt_addr) {
+                       printk(KERN_ERR PFX "ioremap of 0x%lX failed\n",
+                               (unsigned long)md->phys_addr);
                }
+               /* update the virtual address of the EFI system table */
+               check_range_for_systab(md);
        }
 
        if (!efi.systab)
                BUG();
 
        status = phys_efi_set_virtual_address_map(
-                       sizeof(efi_memory_desc_t) * memmap.nr_map,
-                       sizeof(efi_memory_desc_t),
+                       memmap.desc_size * memmap.nr_map,
+                       memmap.desc_size,
                        memmap.desc_version,
                        memmap.phys_map);
 
@@ -533,10 +531,10 @@ efi_initialize_iomem_resources(struct resource *code_resource,
 {
        struct resource *res;
        efi_memory_desc_t *md;
-       int i;
+       void *p;
 
-       for (i = 0; i < memmap.nr_map; i++) {
-               md = &memmap.map[i];
+       for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
+               md = p;
 
                if ((md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT)) >
                    0x100000000ULL)
@@ -613,10 +611,10 @@ efi_initialize_iomem_resources(struct resource *code_resource,
 u32 efi_mem_type(unsigned long phys_addr)
 {
        efi_memory_desc_t *md;
-       int i;
+       void *p;
 
-       for (i = 0; i < memmap.nr_map; i++) {
-               md = &memmap.map[i];
+       for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
+               md = p;
                if ((md->phys_addr <= phys_addr) && (phys_addr <
                        (md->phys_addr + (md-> num_pages << EFI_PAGE_SHIFT)) ))
                        return md->type;
@@ -627,10 +625,10 @@ u32 efi_mem_type(unsigned long phys_addr)
 u64 efi_mem_attributes(unsigned long phys_addr)
 {
        efi_memory_desc_t *md;
-       int i;
+       void *p;
 
-       for (i = 0; i < memmap.nr_map; i++) {
-               md = &memmap.map[i];
+       for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
+               md = p;
                if ((md->phys_addr <= phys_addr) && (phys_addr <
                        (md->phys_addr + (md-> num_pages << EFI_PAGE_SHIFT)) ))
                        return md->attribute;
index a991d4e5edd247c962b49d5d288d052183b7c138..abb909793efcdce8e0e393e0da9beb738550dc10 100644 (file)
@@ -203,7 +203,7 @@ sysenter_past_esp:
        GET_THREAD_INFO(%ebp)
 
        /* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
-       testw $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),TI_flags(%ebp)
+       testw $(_TIF_SYSCALL_EMU|_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
        jnz syscall_trace_entry
        cmpl $(nr_syscalls), %eax
        jae syscall_badsys
@@ -226,9 +226,9 @@ ENTRY(system_call)
        pushl %eax                      # save orig_eax
        SAVE_ALL
        GET_THREAD_INFO(%ebp)
-                                       # system call tracing in operation
+                                       # system call tracing in operation / emulation
        /* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
-       testw $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),TI_flags(%ebp)
+       testw $(_TIF_SYSCALL_EMU|_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
        jnz syscall_trace_entry
        cmpl $(nr_syscalls), %eax
        jae syscall_badsys
@@ -338,6 +338,9 @@ syscall_trace_entry:
        movl %esp, %eax
        xorl %edx,%edx
        call do_syscall_trace
+       cmpl $0, %eax
+       jne resume_userspace            # ret != 0 -> running under PTRACE_SYSEMU,
+                                       # so must skip actual syscall
        movl ORIG_EAX(%esp), %eax
        cmpl $(nr_syscalls), %eax
        jnae syscall_call
index 4477bb107098c2863ee85a0ef8a27374147ca494..0480ca9e9e577a989d96e71e012b8b6e4f8e0c1d 100644 (file)
@@ -77,6 +77,32 @@ ENTRY(startup_32)
        subl %edi,%ecx
        shrl $2,%ecx
        rep ; stosl
+/*
+ * Copy bootup parameters out of the way.
+ * Note: %esi still has the pointer to the real-mode data.
+ * With the kexec as boot loader, parameter segment might be loaded beyond
+ * kernel image and might not even be addressable by early boot page tables.
+ * (kexec on panic case). Hence copy out the parameters before initializing
+ * page tables.
+ */
+       movl $(boot_params - __PAGE_OFFSET),%edi
+       movl $(PARAM_SIZE/4),%ecx
+       cld
+       rep
+       movsl
+       movl boot_params - __PAGE_OFFSET + NEW_CL_POINTER,%esi
+       andl %esi,%esi
+       jnz 2f                  # New command line protocol
+       cmpw $(OLD_CL_MAGIC),OLD_CL_MAGIC_ADDR
+       jne 1f
+       movzwl OLD_CL_OFFSET,%esi
+       addl $(OLD_CL_BASE_ADDR),%esi
+2:
+       movl $(saved_command_line - __PAGE_OFFSET),%edi
+       movl $(COMMAND_LINE_SIZE/4),%ecx
+       rep
+       movsl
+1:
 
 /*
  * Initialize page tables.  This creates a PDE and a set of page
@@ -214,28 +240,6 @@ ENTRY(startup_32_smp)
  */
        call setup_idt
 
-/*
- * Copy bootup parameters out of the way.
- * Note: %esi still has the pointer to the real-mode data.
- */
-       movl $boot_params,%edi
-       movl $(PARAM_SIZE/4),%ecx
-       cld
-       rep
-       movsl
-       movl boot_params+NEW_CL_POINTER,%esi
-       andl %esi,%esi
-       jnz 2f                  # New command line protocol
-       cmpw $(OLD_CL_MAGIC),OLD_CL_MAGIC_ADDR
-       jne 1f
-       movzwl OLD_CL_OFFSET,%esi
-       addl $(OLD_CL_BASE_ADDR),%esi
-2:
-       movl $saved_command_line,%edi
-       movl $(COMMAND_LINE_SIZE/4),%ecx
-       rep
-       movsl
-1:
 checkCPUtype:
 
        movl $-1,X86_CPUID              #  -1 for no CPUID initially
diff --git a/arch/i386/kernel/i8237.c b/arch/i386/kernel/i8237.c
new file mode 100644 (file)
index 0000000..c36d1c0
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * i8237.c: 8237A DMA controller suspend functions.
+ *
+ * Written by Pierre Ossman, 2005.
+ */
+
+#include <linux/init.h>
+#include <linux/sysdev.h>
+
+#include <asm/dma.h>
+
+/*
+ * This module just handles suspend/resume issues with the
+ * 8237A DMA controller (used for ISA and LPC).
+ * Allocation is handled in kernel/dma.c and normal usage is
+ * in asm/dma.h.
+ */
+
+static int i8237A_resume(struct sys_device *dev)
+{
+       unsigned long flags;
+       int i;
+
+       flags = claim_dma_lock();
+
+       dma_outb(DMA1_RESET_REG, 0);
+       dma_outb(DMA2_RESET_REG, 0);
+
+       for (i = 0;i < 8;i++) {
+               set_dma_addr(i, 0x000000);
+               /* DMA count is a bit weird so this is not 0 */
+               set_dma_count(i, 1);
+       }
+
+       /* Enable cascade DMA or channel 0-3 won't work */
+       enable_dma(4);
+
+       release_dma_lock(flags);
+
+       return 0;
+}
+
+static int i8237A_suspend(struct sys_device *dev, pm_message_t state)
+{
+       return 0;
+}
+
+static struct sysdev_class i8237_sysdev_class = {
+       set_kset_name("i8237"),
+       .suspend = i8237A_suspend,
+       .resume = i8237A_resume,
+};
+
+static struct sys_device device_i8237A = {
+       .id     = 0,
+       .cls    = &i8237_sysdev_class,
+};
+
+static int __init i8237A_init_sysfs(void)
+{
+       int error = sysdev_class_register(&i8237_sysdev_class);
+       if (!error)
+               error = sysdev_register(&device_i8237A);
+       return error;
+}
+
+device_initcall(i8237A_init_sysfs);
index 8b25160393c1f557d99f60f6ccab11d487b25a4b..f2b37654777f522af8231e14a6520a572dcb9cfb 100644 (file)
@@ -132,6 +132,7 @@ asmlinkage long sys_iopl(unsigned long unused)
        volatile struct pt_regs * regs = (struct pt_regs *) &unused;
        unsigned int level = regs->ebx;
        unsigned int old = (regs->eflags >> 12) & 3;
+       struct thread_struct *t = &current->thread;
 
        if (level > 3)
                return -EINVAL;
@@ -140,8 +141,8 @@ asmlinkage long sys_iopl(unsigned long unused)
                if (!capable(CAP_SYS_RAWIO))
                        return -EPERM;
        }
-       regs->eflags = (regs->eflags &~ 0x3000UL) | (level << 12);
-       /* Make sure we return the long way (not sysenter) */
-       set_thread_flag(TIF_IRET);
+       t->iopl = level << 12;
+       regs->eflags = (regs->eflags & ~X86_EFLAGS_IOPL) | t->iopl;
+       set_iopl_mask(t->iopl);
        return 0;
 }
index bb50afbee921cbbe19a4b4fb331e5505f12bd5f4..fe1ffa55587d483668d0f19adda973df7ea57190 100644 (file)
@@ -177,7 +177,7 @@ static int read_default_ldt(void __user * ptr, unsigned long bytecount)
 static int write_ldt(void __user * ptr, unsigned long bytecount, int oldmode)
 {
        struct mm_struct * mm = current->mm;
-       __u32 entry_1, entry_2, *lp;
+       __u32 entry_1, entry_2;
        int error;
        struct user_desc ldt_info;
 
@@ -205,8 +205,6 @@ static int write_ldt(void __user * ptr, unsigned long bytecount, int oldmode)
                        goto out_unlock;
        }
 
-       lp = (__u32 *) ((ldt_info.entry_number << 3) + (char *) mm->context.ldt);
-
        /* Allow LDTs to be cleared by the user. */
        if (ldt_info.base_addr == 0 && ldt_info.limit == 0) {
                if (oldmode || LDT_empty(&ldt_info)) {
@@ -223,8 +221,7 @@ static int write_ldt(void __user * ptr, unsigned long bytecount, int oldmode)
 
        /* Install the new entry ...  */
 install:
-       *lp     = entry_1;
-       *(lp+1) = entry_2;
+       write_ldt_entry(mm->context.ldt, ldt_info.entry_number, entry_1, entry_2);
        error = 0;
 
 out_unlock:
index cb699a2aa1f84a915c8a1105fe66f19548adec10..a912fed4848273381ce5d0d3025dc81a1c7deff4 100644 (file)
 #include <asm/apic.h>
 #include <asm/cpufeature.h>
 #include <asm/desc.h>
-
-static inline unsigned long read_cr3(void)
-{
-       unsigned long cr3;
-       asm volatile("movl %%cr3,%0": "=r"(cr3));
-       return cr3;
-}
+#include <asm/system.h>
 
 #define PAGE_ALIGNED __attribute__ ((__aligned__(PAGE_SIZE)))
 
@@ -99,10 +93,7 @@ static void set_idt(void *newidt, __u16 limit)
        curidt.size    = limit;
        curidt.address = (unsigned long)newidt;
 
-       __asm__ __volatile__ (
-               "lidtl %0\n"
-               : : "m" (curidt)
-               );
+       load_idt(&curidt);
 };
 
 
@@ -114,10 +105,7 @@ static void set_gdt(void *newgdt, __u16 limit)
        curgdt.size    = limit;
        curgdt.address = (unsigned long)newgdt;
 
-       __asm__ __volatile__ (
-               "lgdtl %0\n"
-               : : "m" (curgdt)
-               );
+       load_gdt(&curgdt);
 };
 
 static void load_segments(void)
index a77c612aad003fc66a637d87bd091ddafd114208..165f13158c60c188a63ddd22530b9bf2bc160108 100644 (file)
@@ -164,7 +164,8 @@ static void collect_cpu_info (void *unused)
        }
 
        wrmsr(MSR_IA32_UCODE_REV, 0, 0);
-       __asm__ __volatile__ ("cpuid" : : : "ax", "bx", "cx", "dx");
+       /* see notes above for revision 1.07.  Apparent chip bug */
+       serialize_cpu();
        /* get the current revision from MSR 0x8B */
        rdmsr(MSR_IA32_UCODE_REV, val[0], uci->rev);
        pr_debug("microcode: collect_cpu_info : sig=0x%x, pf=0x%x, rev=0x%x\n",
@@ -377,7 +378,9 @@ static void do_update_one (void * unused)
                (unsigned long) uci->mc->bits >> 16 >> 16);
        wrmsr(MSR_IA32_UCODE_REV, 0, 0);
 
-       __asm__ __volatile__ ("cpuid" : : : "ax", "bx", "cx", "dx");
+       /* see notes above for revision 1.07.  Apparent chip bug */
+       serialize_cpu();
+
        /* get the current revision from MSR 0x8B */
        rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]);
 
index ce838abb27d8b48ab23d06a191766b0e2f9c7272..5d0b9a8fc43dc1e1b1f1da28b560b24c5552abca 100644 (file)
@@ -65,6 +65,8 @@ int nr_ioapics;
 int pic_mode;
 unsigned long mp_lapic_addr;
 
+unsigned int def_to_bigsmp = 0;
+
 /* Processor that is doing the boot up */
 unsigned int boot_cpu_physical_apicid = -1U;
 /* Internal processor count */
@@ -120,7 +122,7 @@ static int MP_valid_apicid(int apicid, int version)
 
 static void __init MP_processor_info (struct mpc_config_processor *m)
 {
-       int ver, apicid;
+       int ver, apicid, cpu, found_bsp = 0;
        physid_mask_t tmp;
        
        if (!(m->mpc_cpuflag & CPU_ENABLED))
@@ -179,6 +181,7 @@ static void __init MP_processor_info (struct mpc_config_processor *m)
        if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
                Dprintk("    Bootup CPU\n");
                boot_cpu_physical_apicid = m->mpc_apicid;
+               found_bsp = 1;
        }
 
        if (num_processors >= NR_CPUS) {
@@ -202,6 +205,11 @@ static void __init MP_processor_info (struct mpc_config_processor *m)
                return;
        }
 
+       if (found_bsp)
+               cpu = 0;
+       else
+               cpu = num_processors - 1;
+       cpu_set(cpu, cpu_possible_map);
        tmp = apicid_to_cpu_present(apicid);
        physids_or(phys_cpu_present_map, phys_cpu_present_map, tmp);
        
@@ -213,6 +221,13 @@ static void __init MP_processor_info (struct mpc_config_processor *m)
                ver = 0x10;
        }
        apic_version[m->mpc_apicid] = ver;
+       if ((num_processors > 8) &&
+           APIC_XAPIC(ver) &&
+           (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL))
+               def_to_bigsmp = 1;
+       else
+               def_to_bigsmp = 0;
+
        bios_cpu_apicid[num_processors - 1] = m->mpc_apicid;
 }
 
index b2f03c39a6fed5eebcd381776ae0948e3f280d4a..03100d6fc5d6304522553d82d73f51b33f3e3f60 100644 (file)
 
 static struct class *msr_class;
 
-/* Note: "err" is handled in a funny way below.  Otherwise one version
-   of gcc or another breaks. */
-
 static inline int wrmsr_eio(u32 reg, u32 eax, u32 edx)
 {
        int err;
 
-       asm volatile ("1:       wrmsr\n"
-                     "2:\n"
-                     ".section .fixup,\"ax\"\n"
-                     "3:       movl %4,%0\n"
-                     " jmp 2b\n"
-                     ".previous\n"
-                     ".section __ex_table,\"a\"\n"
-                     " .align 4\n" "   .long 1b,3b\n" ".previous":"=&bDS" (err)
-                     :"a"(eax), "d"(edx), "c"(reg), "i"(-EIO), "0"(0));
-
+       err = wrmsr_safe(reg, eax, edx);
+       if (err)
+               err = -EIO;
        return err;
 }
 
@@ -70,18 +60,9 @@ static inline int rdmsr_eio(u32 reg, u32 *eax, u32 *edx)
 {
        int err;
 
-       asm volatile ("1:       rdmsr\n"
-                     "2:\n"
-                     ".section .fixup,\"ax\"\n"
-                     "3:       movl %4,%0\n"
-                     " jmp 2b\n"
-                     ".previous\n"
-                     ".section __ex_table,\"a\"\n"
-                     " .align 4\n"
-                     " .long 1b,3b\n"
-                     ".previous":"=&bDS" (err), "=a"(*eax), "=d"(*edx)
-                     :"c"(reg), "i"(-EIO), "0"(0));
-
+       err = rdmsr_safe(reg, eax, edx);
+       if (err)
+               err = -EIO;
        return err;
 }
 
index 8c242bb1ef4571685cebeb2c11c0160a92bc9695..8bbdbda07a2d6c0dd54d68ec06ea968b52d064fb 100644 (file)
@@ -501,8 +501,11 @@ void nmi_watchdog_tick (struct pt_regs * regs)
                 */
                alert_counter[cpu]++;
                if (alert_counter[cpu] == 5*nmi_hz)
+                       /*
+                        * die_nmi will return ONLY if NOTIFY_STOP happens..
+                        */
                        die_nmi(regs, "NMI Watchdog detected LOCKUP");
-       } else {
+
                last_irq_sums[cpu] = sum;
                alert_counter[cpu] = 0;
        }
index e3f362e8af5b33e194ac5b7bad3a9ec294f0a030..b45cbf93d4391b49411cfdaecf7c1e084e184c33 100644 (file)
@@ -164,7 +164,7 @@ static inline void play_dead(void)
         */
        local_irq_disable();
        while (1)
-               __asm__ __volatile__("hlt":::"memory");
+               halt();
 }
 #else
 static inline void play_dead(void)
@@ -313,16 +313,12 @@ void show_regs(struct pt_regs * regs)
        printk(" DS: %04x ES: %04x\n",
                0xffff & regs->xds,0xffff & regs->xes);
 
-       __asm__("movl %%cr0, %0": "=r" (cr0));
-       __asm__("movl %%cr2, %0": "=r" (cr2));
-       __asm__("movl %%cr3, %0": "=r" (cr3));
-       /* This could fault if %cr4 does not exist */
-       __asm__("1: movl %%cr4, %0              \n"
-               "2:                             \n"
-               ".section __ex_table,\"a\"      \n"
-               ".long 1b,2b                    \n"
-               ".previous                      \n"
-               : "=r" (cr4): "0" (0));
+       cr0 = read_cr0();
+       cr2 = read_cr2();
+       cr3 = read_cr3();
+       if (current_cpu_data.x86 > 4) {
+               cr4 = read_cr4();
+       }
        printk("CR0: %08lx CR2: %08lx CR3: %08lx CR4: %08lx\n", cr0, cr2, cr3, cr4);
        show_trace(NULL, &regs->esp);
 }
@@ -682,21 +678,26 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas
        __unlazy_fpu(prev_p);
 
        /*
-        * Reload esp0, LDT and the page table pointer:
+        * Reload esp0.
         */
        load_esp0(tss, next);
 
        /*
-        * Load the per-thread Thread-Local Storage descriptor.
+        * Save away %fs and %gs. No need to save %es and %ds, as
+        * those are always kernel segments while inside the kernel.
+        * Doing this before setting the new TLS descriptors avoids
+        * the situation where we temporarily have non-reloadable
+        * segments in %fs and %gs.  This could be an issue if the
+        * NMI handler ever used %fs or %gs (it does not today), or
+        * if the kernel is running inside of a hypervisor layer.
         */
-       load_TLS(next, cpu);
+       savesegment(fs, prev->fs);
+       savesegment(gs, prev->gs);
 
        /*
-        * Save away %fs and %gs. No need to save %es and %ds, as
-        * those are always kernel segments while inside the kernel.
+        * Load the per-thread Thread-Local Storage descriptor.
         */
-       asm volatile("mov %%fs,%0":"=m" (prev->fs));
-       asm volatile("mov %%gs,%0":"=m" (prev->gs));
+       load_TLS(next, cpu);
 
        /*
         * Restore %fs and %gs if needed.
@@ -710,6 +711,12 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas
        if (prev->gs | next->gs)
                loadsegment(gs, next->gs);
 
+       /*
+        * Restore IOPL if needed.
+        */
+       if (unlikely(prev->iopl != next->iopl))
+               set_iopl_mask(next->iopl);
+
        /*
         * Now maybe reload the debug registers
         */
index 0da59b42843cffebc8d104d09376b734cb4ca948..340980203b095f9cda5113c14369799815dad1e5 100644 (file)
@@ -271,6 +271,8 @@ static void clear_singlestep(struct task_struct *child)
 void ptrace_disable(struct task_struct *child)
 { 
        clear_singlestep(child);
+       clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
+       clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
 }
 
 /*
@@ -509,15 +511,20 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
                  }
                  break;
 
+       case PTRACE_SYSEMU: /* continue and stop at next syscall, which will not be executed */
        case PTRACE_SYSCALL:    /* continue and stop at next (return from) syscall */
        case PTRACE_CONT:       /* restart after signal. */
                ret = -EIO;
                if (!valid_signal(data))
                        break;
-               if (request == PTRACE_SYSCALL) {
+               if (request == PTRACE_SYSEMU) {
+                       set_tsk_thread_flag(child, TIF_SYSCALL_EMU);
+                       clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
+               } else if (request == PTRACE_SYSCALL) {
                        set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
-               }
-               else {
+                       clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
+               } else {
+                       clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
                        clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
                }
                child->exit_code = data;
@@ -542,10 +549,17 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
                wake_up_process(child);
                break;
 
+       case PTRACE_SYSEMU_SINGLESTEP: /* Same as SYSEMU, but singlestep if not syscall */
        case PTRACE_SINGLESTEP: /* set the trap flag. */
                ret = -EIO;
                if (!valid_signal(data))
                        break;
+
+               if (request == PTRACE_SYSEMU_SINGLESTEP)
+                       set_tsk_thread_flag(child, TIF_SYSCALL_EMU);
+               else
+                       clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
+
                clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
                set_singlestep(child);
                child->exit_code = data;
@@ -678,26 +692,52 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code)
  * - triggered by current->work.syscall_trace
  */
 __attribute__((regparm(3)))
-void do_syscall_trace(struct pt_regs *regs, int entryexit)
+int do_syscall_trace(struct pt_regs *regs, int entryexit)
 {
+       int is_sysemu = test_thread_flag(TIF_SYSCALL_EMU), ret = 0;
+       /* With TIF_SYSCALL_EMU set we want to ignore TIF_SINGLESTEP for syscall
+        * interception. */
+       int is_singlestep = !is_sysemu && test_thread_flag(TIF_SINGLESTEP);
+
        /* do the secure computing check first */
        secure_computing(regs->orig_eax);
 
-       if (unlikely(current->audit_context) && entryexit)
-               audit_syscall_exit(current, AUDITSC_RESULT(regs->eax), regs->eax);
+       if (unlikely(current->audit_context)) {
+               if (entryexit)
+                       audit_syscall_exit(current, AUDITSC_RESULT(regs->eax), regs->eax);
+               /* Debug traps, when using PTRACE_SINGLESTEP, must be sent only
+                * on the syscall exit path. Normally, when TIF_SYSCALL_AUDIT is
+                * not used, entry.S will call us only on syscall exit, not
+                * entry; so when TIF_SYSCALL_AUDIT is used we must avoid
+                * calling send_sigtrap() on syscall entry.
+                *
+                * Note that when PTRACE_SYSEMU_SINGLESTEP is used,
+                * is_singlestep is false, despite his name, so we will still do
+                * the correct thing.
+                */
+               else if (is_singlestep)
+                       goto out;
+       }
 
        if (!(current->ptrace & PT_PTRACED))
                goto out;
 
+       /* If a process stops on the 1st tracepoint with SYSCALL_TRACE
+        * and then is resumed with SYSEMU_SINGLESTEP, it will come in
+        * here. We have to check this and return */
+       if (is_sysemu && entryexit)
+               return 0;
+
        /* Fake a debug trap */
-       if (test_thread_flag(TIF_SINGLESTEP))
+       if (is_singlestep)
                send_sigtrap(current, regs, 0);
 
-       if (!test_thread_flag(TIF_SYSCALL_TRACE))
+       if (!test_thread_flag(TIF_SYSCALL_TRACE) && !is_sysemu)
                goto out;
 
        /* the 0x80 provides a way for the tracing parent to distinguish
           between a syscall stop and SIGTRAP delivery */
+       /* Note that the debugger could change the result of test_thread_flag!*/
        ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) ? 0x80 : 0));
 
        /*
@@ -709,9 +749,16 @@ void do_syscall_trace(struct pt_regs *regs, int entryexit)
                send_sig(current->exit_code, current, 1);
                current->exit_code = 0;
        }
+       ret = is_sysemu;
  out:
        if (unlikely(current->audit_context) && !entryexit)
                audit_syscall_entry(current, AUDIT_ARCH_I386, regs->orig_eax,
                                    regs->ebx, regs->ecx, regs->edx, regs->esi);
+       if (ret == 0)
+               return 0;
 
+       regs->orig_eax = -1; /* force skip of syscall restarting */
+       if (unlikely(current->audit_context))
+               audit_syscall_exit(current, AUDITSC_RESULT(regs->eax), regs->eax);
+       return 1;
 }
index c71fef31dc4797d891f10c5d8d257bbf11d73df7..1cbb9c0f47040d9eb430e738f81871ff18aeacee 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/dmi.h>
 #include <asm/uaccess.h>
 #include <asm/apic.h>
+#include <asm/desc.h>
 #include "mach_reboot.h"
 #include <linux/reboot_fixups.h>
 
@@ -242,13 +243,13 @@ void machine_real_restart(unsigned char *code, int length)
 
        /* Set up the IDT for real mode. */
 
-       __asm__ __volatile__ ("lidt %0" : : "m" (real_mode_idt));
+       load_idt(&real_mode_idt);
 
        /* Set up a GDT from which we can load segment descriptors for real
           mode.  The GDT is not used in real mode; it is just needed here to
           prepare the descriptors. */
 
-       __asm__ __volatile__ ("lgdt %0" : : "m" (real_mode_gdt));
+       load_gdt(&real_mode_gdt);
 
        /* Load the data segment registers, and thus the descriptors ready for
           real mode.  The base address of each segment is 0x100, 16 times the
@@ -316,7 +317,7 @@ void machine_emergency_restart(void)
        if (!reboot_thru_bios) {
                if (efi_enabled) {
                        efi.reset_system(EFI_RESET_COLD, EFI_SUCCESS, 0, NULL);
-                       __asm__ __volatile__("lidt %0": :"m" (no_idt));
+                       load_idt(&no_idt);
                        __asm__ __volatile__("int3");
                }
                /* rebooting needs to touch the page at absolute addr 0 */
@@ -325,7 +326,7 @@ void machine_emergency_restart(void)
                        mach_reboot_fixups(); /* for board specific fixups */
                        mach_reboot();
                        /* That didn't work - force a triple fault.. */
-                       __asm__ __volatile__("lidt %0": :"m" (no_idt));
+                       load_idt(&no_idt);
                        __asm__ __volatile__("int3");
                }
        }
index 469f496e55c0f56787929fa1c387572097c9ddc8..7455ab6439438bca2722b0df63f823a93ccc032f 100644 (file)
  * rw semaphores implemented November 1999 by Benjamin LaHaise <bcrl@kvack.org>
  */
 #include <linux/config.h>
-#include <linux/sched.h>
-#include <linux/err.h>
-#include <linux/init.h>
 #include <asm/semaphore.h>
 
-/*
- * Semaphores are implemented using a two-way counter:
- * The "count" variable is decremented for each process
- * that tries to acquire the semaphore, while the "sleeping"
- * variable is a count of such acquires.
- *
- * Notably, the inline "up()" and "down()" functions can
- * efficiently test if they need to do any extra work (up
- * needs to do something only if count was negative before
- * the increment operation.
- *
- * "sleeping" and the contention routine ordering is protected
- * by the spinlock in the semaphore's waitqueue head.
- *
- * Note that these functions are only called when there is
- * contention on the lock, and as such all this is the
- * "non-critical" part of the whole semaphore business. The
- * critical part is the inline stuff in <asm/semaphore.h>
- * where we want to avoid any extra jumps and calls.
- */
-
-/*
- * Logic:
- *  - only on a boundary condition do we need to care. When we go
- *    from a negative count to a non-negative, we wake people up.
- *  - when we go from a non-negative count to a negative do we
- *    (a) synchronize with the "sleeper" count and (b) make sure
- *    that we're on the wakeup list before we synchronize so that
- *    we cannot lose wakeup events.
- */
-
-static fastcall void __attribute_used__  __up(struct semaphore *sem)
-{
-       wake_up(&sem->wait);
-}
-
-static fastcall void __attribute_used__ __sched __down(struct semaphore * sem)
-{
-       struct task_struct *tsk = current;
-       DECLARE_WAITQUEUE(wait, tsk);
-       unsigned long flags;
-
-       tsk->state = TASK_UNINTERRUPTIBLE;
-       spin_lock_irqsave(&sem->wait.lock, flags);
-       add_wait_queue_exclusive_locked(&sem->wait, &wait);
-
-       sem->sleepers++;
-       for (;;) {
-               int sleepers = sem->sleepers;
-
-               /*
-                * Add "everybody else" into it. They aren't
-                * playing, because we own the spinlock in
-                * the wait_queue_head.
-                */
-               if (!atomic_add_negative(sleepers - 1, &sem->count)) {
-                       sem->sleepers = 0;
-                       break;
-               }
-               sem->sleepers = 1;      /* us - see -1 above */
-               spin_unlock_irqrestore(&sem->wait.lock, flags);
-
-               schedule();
-
-               spin_lock_irqsave(&sem->wait.lock, flags);
-               tsk->state = TASK_UNINTERRUPTIBLE;
-       }
-       remove_wait_queue_locked(&sem->wait, &wait);
-       wake_up_locked(&sem->wait);
-       spin_unlock_irqrestore(&sem->wait.lock, flags);
-       tsk->state = TASK_RUNNING;
-}
-
-static fastcall int __attribute_used__ __sched __down_interruptible(struct semaphore * sem)
-{
-       int retval = 0;
-       struct task_struct *tsk = current;
-       DECLARE_WAITQUEUE(wait, tsk);
-       unsigned long flags;
-
-       tsk->state = TASK_INTERRUPTIBLE;
-       spin_lock_irqsave(&sem->wait.lock, flags);
-       add_wait_queue_exclusive_locked(&sem->wait, &wait);
-
-       sem->sleepers++;
-       for (;;) {
-               int sleepers = sem->sleepers;
-
-               /*
-                * With signals pending, this turns into
-                * the trylock failure case - we won't be
-                * sleeping, and we* can't get the lock as
-                * it has contention. Just correct the count
-                * and exit.
-                */
-               if (signal_pending(current)) {
-                       retval = -EINTR;
-                       sem->sleepers = 0;
-                       atomic_add(sleepers, &sem->count);
-                       break;
-               }
-
-               /*
-                * Add "everybody else" into it. They aren't
-                * playing, because we own the spinlock in
-                * wait_queue_head. The "-1" is because we're
-                * still hoping to get the semaphore.
-                */
-               if (!atomic_add_negative(sleepers - 1, &sem->count)) {
-                       sem->sleepers = 0;
-                       break;
-               }
-               sem->sleepers = 1;      /* us - see -1 above */
-               spin_unlock_irqrestore(&sem->wait.lock, flags);
-
-               schedule();
-
-               spin_lock_irqsave(&sem->wait.lock, flags);
-               tsk->state = TASK_INTERRUPTIBLE;
-       }
-       remove_wait_queue_locked(&sem->wait, &wait);
-       wake_up_locked(&sem->wait);
-       spin_unlock_irqrestore(&sem->wait.lock, flags);
-
-       tsk->state = TASK_RUNNING;
-       return retval;
-}
-
-/*
- * Trylock failed - make sure we correct for
- * having decremented the count.
- *
- * We could have done the trylock with a
- * single "cmpxchg" without failure cases,
- * but then it wouldn't work on a 386.
- */
-static fastcall int __attribute_used__ __down_trylock(struct semaphore * sem)
-{
-       int sleepers;
-       unsigned long flags;
-
-       spin_lock_irqsave(&sem->wait.lock, flags);
-       sleepers = sem->sleepers + 1;
-       sem->sleepers = 0;
-
-       /*
-        * Add "everybody else" and us into it. They aren't
-        * playing, because we own the spinlock in the
-        * wait_queue_head.
-        */
-       if (!atomic_add_negative(sleepers, &sem->count)) {
-               wake_up_locked(&sem->wait);
-       }
-
-       spin_unlock_irqrestore(&sem->wait.lock, flags);
-       return 1;
-}
-
-
 /*
  * The semaphore operations have a special calling sequence that
  * allow us to do a simpler in-line version of them. These routines
index af4de58cab543362bb19d8e31c85006cd7c17e9d..294bcca985ab7ec2de873dff4716f0681500c0be 100644 (file)
@@ -370,12 +370,16 @@ static void __init limit_regions(unsigned long long size)
        int i;
 
        if (efi_enabled) {
-               for (i = 0; i < memmap.nr_map; i++) {
-                       current_addr = memmap.map[i].phys_addr +
-                                      (memmap.map[i].num_pages << 12);
-                       if (memmap.map[i].type == EFI_CONVENTIONAL_MEMORY) {
+               efi_memory_desc_t *md;
+               void *p;
+
+               for (p = memmap.map, i = 0; p < memmap.map_end;
+                       p += memmap.desc_size, i++) {
+                       md = p;
+                       current_addr = md->phys_addr + (md->num_pages << 12);
+                       if (md->type == EFI_CONVENTIONAL_MEMORY) {
                                if (current_addr >= size) {
-                                       memmap.map[i].num_pages -=
+                                       md->num_pages -=
                                                (((current_addr-size) + PAGE_SIZE-1) >> PAGE_SHIFT);
                                        memmap.nr_map = i + 1;
                                        return;
@@ -1581,8 +1585,14 @@ void __init setup_arch(char **cmdline_p)
         */
        acpi_boot_table_init();
        acpi_boot_init();
-#endif
 
+#if defined(CONFIG_SMP) && defined(CONFIG_X86_PC)
+       if (def_to_bigsmp)
+               printk(KERN_WARNING "More than 8 CPUs detected and "
+                       "CONFIG_X86_PC cannot handle it.\nUse "
+                       "CONFIG_X86_GENERICARCH or CONFIG_X86_BIGSMP.\n");
+#endif
+#endif
 #ifdef CONFIG_X86_LOCAL_APIC
        if (smp_found_config)
                get_smp_config();
index 140e340569c67711fc83f3f54cf4139d64c701aa..61eb0c8a6e47dc9763c8f78d85f3aa3e7be40456 100644 (file)
@@ -278,9 +278,9 @@ setup_sigcontext(struct sigcontext __user *sc, struct _fpstate __user *fpstate,
        int tmp, err = 0;
 
        tmp = 0;
-       __asm__("movl %%gs,%0" : "=r"(tmp): "0"(tmp));
+       savesegment(gs, tmp);
        err |= __put_user(tmp, (unsigned int __user *)&sc->gs);
-       __asm__("movl %%fs,%0" : "=r"(tmp): "0"(tmp));
+       savesegment(fs, tmp);
        err |= __put_user(tmp, (unsigned int __user *)&sc->fs);
 
        err |= __put_user(regs->xes, (unsigned int __user *)&sc->es);
@@ -604,7 +604,9 @@ int fastcall do_signal(struct pt_regs *regs, sigset_t *oldset)
         * We want the common case to go fast, which
         * is why we may in certain cases get here from
         * kernel mode. Just return without doing anything
-        * if so.
+        * if so.  vm86 regs switched out by assembly code
+        * before reaching here, so testing against kernel
+        * CS suffices.
         */
        if (!user_mode(regs))
                return 1;
index cec4bde67161254106267d6c6e4715aaeea93a3a..48b55db3680f3eaac2b1a67274343677ceb1a32d 100644 (file)
@@ -576,7 +576,7 @@ static void stop_this_cpu (void * dummy)
        local_irq_disable();
        disable_local_APIC();
        if (cpu_data[smp_processor_id()].hlt_works_ok)
-               for(;;) __asm__("hlt");
+               for(;;) halt();
        for (;;);
 }
 
index 8ac8e9fd5614fa10237dc58fa6620d52cff8e5e3..5e4893d2b9f272b4c1120f3812cebef501f4164f 100644 (file)
@@ -88,6 +88,8 @@ EXPORT_SYMBOL(cpu_online_map);
 cpumask_t cpu_callin_map;
 cpumask_t cpu_callout_map;
 EXPORT_SYMBOL(cpu_callout_map);
+cpumask_t cpu_possible_map;
+EXPORT_SYMBOL(cpu_possible_map);
 static cpumask_t smp_commenced_mask;
 
 /* TSC's upper 32 bits can't be written in eariler CPU (before prescott), there
@@ -1017,8 +1019,8 @@ int __devinit smp_prepare_cpu(int cpu)
        tsc_sync_disabled = 1;
 
        /* init low mem mapping */
-       memcpy(swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS,
-                       sizeof(swapper_pg_dir[0]) * KERNEL_PGD_PTRS);
+       clone_pgd_range(swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS,
+                       KERNEL_PGD_PTRS);
        flush_tlb_all();
        schedule_work(&task);
        wait_for_completion(&done);
@@ -1265,6 +1267,7 @@ void __devinit smp_prepare_boot_cpu(void)
        cpu_set(smp_processor_id(), cpu_online_map);
        cpu_set(smp_processor_id(), cpu_callout_map);
        cpu_set(smp_processor_id(), cpu_present_map);
+       cpu_set(smp_processor_id(), cpu_possible_map);
        per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
 }
 
index 0ee9dee8af06280c85ba403208cacc237da08b43..6f794a78ee1e7be1f12074b7c0cfaad15aa8a9fd 100644 (file)
@@ -383,6 +383,7 @@ void notify_arch_cmos_timer(void)
 
 static long clock_cmos_diff, sleep_start;
 
+static struct timer_opts *last_timer;
 static int timer_suspend(struct sys_device *dev, pm_message_t state)
 {
        /*
@@ -391,6 +392,10 @@ static int timer_suspend(struct sys_device *dev, pm_message_t state)
        clock_cmos_diff = -get_cmos_time();
        clock_cmos_diff += get_seconds();
        sleep_start = get_cmos_time();
+       last_timer = cur_timer;
+       cur_timer = &timer_none;
+       if (last_timer->suspend)
+               last_timer->suspend(state);
        return 0;
 }
 
@@ -404,6 +409,7 @@ static int timer_resume(struct sys_device *dev)
        if (is_hpet_enabled())
                hpet_reenable();
 #endif
+       setup_pit_timer();
        sec = get_cmos_time() + clock_cmos_diff;
        sleep_length = (get_cmos_time() - sleep_start) * HZ;
        write_seqlock_irqsave(&xtime_lock, flags);
@@ -412,6 +418,10 @@ static int timer_resume(struct sys_device *dev)
        write_sequnlock_irqrestore(&xtime_lock, flags);
        jiffies += sleep_length;
        wall_jiffies += sleep_length;
+       if (last_timer->resume)
+               last_timer->resume();
+       cur_timer = last_timer;
+       last_timer = NULL;
        return 0;
 }
 
index ef8dac5dd33b103bbc5f8c6f5c9b7ce52bfe4582..001de97c9e4a78b720cf5d567e60656739c200a5 100644 (file)
@@ -136,6 +136,8 @@ static void delay_hpet(unsigned long loops)
        } while ((hpet_end - hpet_start) < (loops));
 }
 
+static struct timer_opts timer_hpet;
+
 static int __init init_hpet(char* override)
 {
        unsigned long result, remain;
@@ -163,6 +165,8 @@ static int __init init_hpet(char* override)
                        }
                        set_cyc2ns_scale(cpu_khz/1000);
                }
+               /* set this only when cpu_has_tsc */
+               timer_hpet.read_timer = read_timer_tsc;
        }
 
        /*
@@ -177,6 +181,19 @@ static int __init init_hpet(char* override)
        return 0;
 }
 
+static int hpet_resume(void)
+{
+       write_seqlock(&monotonic_lock);
+       /* Assume this is the last mark offset time */
+       rdtsc(last_tsc_low, last_tsc_high);
+
+       if (hpet_use_timer)
+               hpet_last = hpet_readl(HPET_T0_CMP) - hpet_tick;
+       else
+               hpet_last = hpet_readl(HPET_COUNTER);
+       write_sequnlock(&monotonic_lock);
+       return 0;
+}
 /************************************************************/
 
 /* tsc timer_opts struct */
@@ -186,7 +203,7 @@ static struct timer_opts timer_hpet __read_mostly = {
        .get_offset =           get_offset_hpet,
        .monotonic_clock =      monotonic_clock_hpet,
        .delay =                delay_hpet,
-       .read_timer =           read_timer_tsc,
+       .resume =               hpet_resume,
 };
 
 struct init_timer_opts __initdata timer_hpet_init = {
index 06de036a820c23d63395e559ac9db1f5daedc2a3..eddb640382342db9b2cee7483d228d0648a64e00 100644 (file)
@@ -175,30 +175,3 @@ void setup_pit_timer(void)
        outb(LATCH >> 8 , PIT_CH0);     /* MSB */
        spin_unlock_irqrestore(&i8253_lock, flags);
 }
-
-static int timer_resume(struct sys_device *dev)
-{
-       setup_pit_timer();
-       return 0;
-}
-
-static struct sysdev_class timer_sysclass = {
-       set_kset_name("timer_pit"),
-       .resume = timer_resume,
-};
-
-static struct sys_device device_timer = {
-       .id     = 0,
-       .cls    = &timer_sysclass,
-};
-
-static int __init init_timer_sysfs(void)
-{
-       int error = sysdev_class_register(&timer_sysclass);
-       if (!error)
-               error = sysdev_register(&device_timer);
-       return error;
-}
-
-device_initcall(init_timer_sysfs);
-
index 4ef20e66349862ebe383c5e371a3c1bbe2abbff8..264edaaac315b3e75c0781cb0a016e275151dc67 100644 (file)
@@ -186,6 +186,14 @@ static void mark_offset_pmtmr(void)
        }
 }
 
+static int pmtmr_resume(void)
+{
+       write_seqlock(&monotonic_lock);
+       /* Assume this is the last mark offset time */
+       offset_tick = read_pmtmr();
+       write_sequnlock(&monotonic_lock);
+       return 0;
+}
 
 static unsigned long long monotonic_clock_pmtmr(void)
 {
@@ -247,6 +255,7 @@ static struct timer_opts timer_pmtmr = {
        .monotonic_clock        = monotonic_clock_pmtmr,
        .delay                  = delay_pmtmr,
        .read_timer             = read_timer_tsc,
+       .resume                 = pmtmr_resume,
 };
 
 struct init_timer_opts __initdata timer_pmtmr_init = {
index 8f4e4d5bc560d58138f24ab514902f18a175bd57..6dd470cc9f72a2e6e71264c988112bd1ef11e2a7 100644 (file)
@@ -543,6 +543,19 @@ static int __init init_tsc(char* override)
        return -ENODEV;
 }
 
+static int tsc_resume(void)
+{
+       write_seqlock(&monotonic_lock);
+       /* Assume this is the last mark offset time */
+       rdtsc(last_tsc_low, last_tsc_high);
+#ifdef CONFIG_HPET_TIMER
+       if (is_hpet_enabled() && hpet_use_timer)
+               hpet_last = hpet_readl(HPET_COUNTER);
+#endif
+       write_sequnlock(&monotonic_lock);
+       return 0;
+}
+
 #ifndef CONFIG_X86_TSC
 /* disable flag for tsc.  Takes effect by clearing the TSC cpu flag
  * in cpu/common.c */
@@ -573,6 +586,7 @@ static struct timer_opts timer_tsc = {
        .monotonic_clock = monotonic_clock_tsc,
        .delay = delay_tsc,
        .read_timer = read_timer_tsc,
+       .resume = tsc_resume,
 };
 
 struct init_timer_opts __initdata timer_tsc_init = {
index cd2d5d5514fe0ffcdf78cadfbabdf5863ede040c..54629bb5893ae1c9ab6765ea6b84a23c1fae3761 100644 (file)
@@ -210,7 +210,7 @@ void show_registers(struct pt_regs *regs)
        unsigned short ss;
 
        esp = (unsigned long) (&regs->esp);
-       ss = __KERNEL_DS;
+       savesegment(ss, ss);
        if (user_mode(regs)) {
                in_kernel = 0;
                esp = regs->esp;
@@ -267,9 +267,6 @@ static void handle_BUG(struct pt_regs *regs)
        char c;
        unsigned long eip;
 
-       if (user_mode(regs))
-               goto no_bug;            /* Not in kernel */
-
        eip = regs->eip;
 
        if (eip < PAGE_OFFSET)
@@ -568,6 +565,10 @@ static DEFINE_SPINLOCK(nmi_print_lock);
 
 void die_nmi (struct pt_regs *regs, const char *msg)
 {
+       if (notify_die(DIE_NMIWATCHDOG, msg, regs, 0, 0, SIGINT) ==
+           NOTIFY_STOP)
+               return;
+
        spin_lock(&nmi_print_lock);
        /*
        * We are in trouble anyway, lets at least try
@@ -1008,7 +1009,7 @@ void __init trap_init_f00f_bug(void)
         * it uses the read-only mapped virtual address.
         */
        idt_descr.address = fix_to_virt(FIX_F00F_IDT);
-       __asm__ __volatile__("lidt %0" : : "m" (idt_descr));
+       load_idt(&idt_descr);
 }
 #endif
 
index ec0f68ce68860c5b7e15e6158a79afbd5e93c3a5..16b485009622a578e274c260cf975b3fd1a77f0e 100644 (file)
@@ -294,8 +294,8 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
  */
        info->regs32->eax = 0;
        tsk->thread.saved_esp0 = tsk->thread.esp0;
-       asm volatile("mov %%fs,%0":"=m" (tsk->thread.saved_fs));
-       asm volatile("mov %%gs,%0":"=m" (tsk->thread.saved_gs));
+       savesegment(fs, tsk->thread.saved_fs);
+       savesegment(gs, tsk->thread.saved_gs);
 
        tss = &per_cpu(init_tss, get_cpu());
        tsk->thread.esp0 = (unsigned long) &info->VM86_TSS_ESP0;
@@ -542,7 +542,7 @@ void handle_vm86_fault(struct kernel_vm86_regs * regs, long error_code)
        unsigned char opcode;
        unsigned char __user *csp;
        unsigned char __user *ssp;
-       unsigned short ip, sp;
+       unsigned short ip, sp, orig_flags;
        int data32, pref_done;
 
 #define CHECK_IF_IN_TRAP \
@@ -551,8 +551,12 @@ void handle_vm86_fault(struct kernel_vm86_regs * regs, long error_code)
 #define VM86_FAULT_RETURN do { \
        if (VMPI.force_return_for_pic  && (VEFLAGS & (IF_MASK | VIF_MASK))) \
                return_to_32bit(regs, VM86_PICRETURN); \
+       if (orig_flags & TF_MASK) \
+               handle_vm86_trap(regs, 0, 1); \
        return; } while (0)
 
+       orig_flags = *(unsigned short *)&regs->eflags;
+
        csp = (unsigned char __user *) (regs->cs << 4);
        ssp = (unsigned char __user *) (regs->ss << 4);
        sp = SP(regs);
index c8fcf75b9be33fbf35f6b36311fae25d47d8be1d..68afa50dd7cf79bf0d5eb021115c59e03fee692f 100644 (file)
@@ -15,7 +15,7 @@
 */
 
        .text
-       .org    __kernel_vsyscall+32
+       .org __kernel_vsyscall+32,0x90
        .globl __kernel_sigreturn
        .type __kernel_sigreturn,@function
 __kernel_sigreturn:
@@ -35,6 +35,7 @@ __kernel_rt_sigreturn:
        int $0x80
 .LEND_rt_sigreturn:
        .size __kernel_rt_sigreturn,.-.LSTART_rt_sigreturn
+       .balign 32
        .previous
 
        .section .eh_frame,"a",@progbits
index 70691f0c4ce28a8ae5cd9b6fb7fa517c5d6ba509..898ed905e1195638c9e39594d0cd5495bd1a3d59 100644 (file)
@@ -104,7 +104,8 @@ struct mip_reg {
 #define        MIP_SW_APIC             0x1020b
 #define        MIP_FUNC(VALUE)         (VALUE & 0xff)
 
-extern int parse_unisys_oem (char *oemptr, int oem_entries);
-extern int find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length);
+extern int parse_unisys_oem (char *oemptr);
+extern int find_unisys_acpi_oem_table(unsigned long *oem_addr);
+extern void setup_unisys ();
 extern int es7000_start_cpu(int cpu, unsigned long eip);
 extern void es7000_sw_apic(void);
index d5936d500479f235c89c11e51c431dd0ffaef819..2000bdca2fc2cc3a93a9c9393012bd5db707d91d 100644 (file)
@@ -75,12 +75,29 @@ es7000_rename_gsi(int ioapic, int gsi)
 
 #endif // (CONFIG_X86_IO_APIC) && (CONFIG_ACPI_INTERPRETER || CONFIG_ACPI_BOOT)
 
+void __init
+setup_unisys ()
+{
+       /*
+        * Determine the generation of the ES7000 currently running.
+        *
+        * es7000_plat = 1 if the machine is a 5xx ES7000 box
+        * es7000_plat = 2 if the machine is a x86_64 ES7000 box
+        *
+        */
+       if (!(boot_cpu_data.x86 <= 15 && boot_cpu_data.x86_model <= 2))
+               es7000_plat = 2;
+       else
+               es7000_plat = 1;
+       ioapic_renumber_irq = es7000_rename_gsi;
+}
+
 /*
  * Parse the OEM Table
  */
 
 int __init
-parse_unisys_oem (char *oemptr, int oem_entries)
+parse_unisys_oem (char *oemptr)
 {
        int                     i;
        int                     success = 0;
@@ -95,7 +112,7 @@ parse_unisys_oem (char *oemptr, int oem_entries)
 
        tp += 8;
 
-       for (i=0; i <= oem_entries; i++) {
+       for (i=0; i <= 6; i++) {
                type = *tp++;
                size = *tp++;
                tp -= 2;
@@ -130,34 +147,18 @@ parse_unisys_oem (char *oemptr, int oem_entries)
                default:
                        break;
                }
-               if (i == 6) break;
                tp += size;
        }
 
        if (success < 2) {
                es7000_plat = 0;
-       } else {
-               printk("\nEnabling ES7000 specific features...\n");
-               /*
-                * Determine the generation of the ES7000 currently running.
-                *
-                * es7000_plat = 0 if the machine is NOT a Unisys ES7000 box
-                * es7000_plat = 1 if the machine is a 5xx ES7000 box
-                * es7000_plat = 2 if the machine is a x86_64 ES7000 box
-                *
-                */
-               if (!(boot_cpu_data.x86 <= 15 && boot_cpu_data.x86_model <= 2))
-                       es7000_plat = 2;
-               else
-                       es7000_plat = 1;
-
-               ioapic_renumber_irq = es7000_rename_gsi;
-       }
+       } else
+               setup_unisys();
        return es7000_plat;
 }
 
 int __init
-find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length)
+find_unisys_acpi_oem_table(unsigned long *oem_addr)
 {
        struct acpi_table_rsdp          *rsdp = NULL;
        unsigned long                   rsdp_phys = 0;
@@ -201,13 +202,11 @@ find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length)
                                acpi_table_print(header, sdt.entry[i].pa);
                                t = (struct oem_table *) __acpi_map_table(sdt.entry[i].pa, header->length);
                                addr = (void *) __acpi_map_table(t->OEMTableAddr, t->OEMTableSize);
-                               *length = header->length;
                                *oem_addr = (unsigned long) addr;
                                return 0;
                        }
                }
        }
-       Dprintk("ES7000: did not find Unisys ACPI OEM table!\n");
        return -1;
 }
 
index 25883b44f6253f092b4eab9a67cc61c822e0401e..037b2af1a1f4972a0940f723d1fa39310b4e1dfd 100644 (file)
@@ -47,7 +47,10 @@ static struct dmi_system_id __initdata bigsmp_dmi_table[] = {
 
 static __init int probe_bigsmp(void)
 { 
-       dmi_check_system(bigsmp_dmi_table);
+       if (def_to_bigsmp)
+               dmi_bigsmp = 1;
+       else
+               dmi_check_system(bigsmp_dmi_table);
        return dmi_bigsmp; 
 } 
 
index 5497c65a8790bfd0175564aed83b7129f5f5ceb2..cea5b3ce4b5766c9747294090542e4eb063b75eb 100644 (file)
@@ -30,6 +30,25 @@ struct genapic *apic_probe[] __initdata = {
        NULL,
 };
 
+static int cmdline_apic;
+
+void __init generic_bigsmp_probe(void)
+{
+       /*
+        * This routine is used to switch to bigsmp mode when
+        * - There is no apic= option specified by the user
+        * - generic_apic_probe() has choosen apic_default as the sub_arch
+        * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support
+        */
+
+       if (!cmdline_apic && genapic == &apic_default)
+               if (apic_bigsmp.probe()) {
+                       genapic = &apic_bigsmp;
+                       printk(KERN_INFO "Overriding APIC driver with %s\n",
+                              genapic->name);
+               }
+}
+
 void __init generic_apic_probe(char *command_line) 
 { 
        char *s;
@@ -52,6 +71,7 @@ void __init generic_apic_probe(char *command_line)
                if (!changed)
                        printk(KERN_ERR "Unknown genapic `%s' specified.\n", s);
                *p = old;
+               cmdline_apic = changed;
        } 
        for (i = 0; !changed && apic_probe[i]; i++) { 
                if (apic_probe[i]->probe()) {
index c6384061328a5d72acaed91f216c26fef86a8c91..cc69875d979b9445b3ebcc0549906656ee3f2767 100644 (file)
@@ -234,10 +234,9 @@ voyager_power_off(void)
 #endif
        }
        /* and wait for it to happen */
-       for(;;) {
-               __asm("cli");
-               __asm("hlt");
-       }
+       local_irq_disable();
+       for(;;)
+               halt();
 }
 
 /* copied from process.c */
@@ -278,10 +277,9 @@ machine_restart(char *cmd)
                outb(basebd | 0x08, VOYAGER_MC_SETUP);
                outb(0x02, catbase + 0x21);
        }
-       for(;;) {
-               asm("cli");
-               asm("hlt");
-       }
+       local_irq_disable();
+       for(;;)
+               halt();
 }
 
 void
index 0e1f4208b07ce46ecc8d883dc3f2121fb07f5c92..46b0cf4a31e006fc6002569ae3eac4b7a5478a6a 100644 (file)
@@ -242,6 +242,8 @@ static cpumask_t smp_commenced_mask = CPU_MASK_NONE;
 cpumask_t cpu_callin_map = CPU_MASK_NONE;
 cpumask_t cpu_callout_map = CPU_MASK_NONE;
 EXPORT_SYMBOL(cpu_callout_map);
+cpumask_t cpu_possible_map = CPU_MASK_ALL;
+EXPORT_SYMBOL(cpu_possible_map);
 
 /* The per processor IRQ masks (these are usually kept in sync) */
 static __u16 vic_irq_mask[NR_CPUS] __cacheline_aligned;
@@ -1015,7 +1017,7 @@ smp_stop_cpu_function(void *dummy)
        cpu_clear(smp_processor_id(), cpu_online_map);
        local_irq_disable();
        for(;;)
-              __asm__("hlt");
+               halt();
 }
 
 static DEFINE_SPINLOCK(call_lock);
@@ -1910,6 +1912,7 @@ void __devinit smp_prepare_boot_cpu(void)
 {
        cpu_set(smp_processor_id(), cpu_online_map);
        cpu_set(smp_processor_id(), cpu_callout_map);
+       cpu_set(smp_processor_id(), cpu_possible_map);
 }
 
 int __devinit
index 91175738e94808a8aa5a988f1fe5183211fa58ca..9819b705efa422af8c3f1ee5652fa0649f606811 100644 (file)
@@ -155,7 +155,6 @@ static long pm_address(u_char FPU_modrm, u_char segment,
 { 
   struct desc_struct descriptor;
   unsigned long base_address, limit, address, seg_top;
-  unsigned short selector;
 
   segment--;
 
@@ -173,17 +172,11 @@ static long pm_address(u_char FPU_modrm, u_char segment,
       /* fs and gs aren't used by the kernel, so they still have their
         user-space values. */
     case PREFIX_FS_-1:
-      /* The cast is needed here to get gcc 2.8.0 to use a 16 bit register
-        in the assembler statement. */
-
-      __asm__("mov %%fs,%0":"=r" (selector));
-      addr->selector = selector;
+      /* N.B. - movl %seg, mem is a 2 byte write regardless of prefix */
+      savesegment(fs, addr->selector);
       break;
     case PREFIX_GS_-1:
-      /* The cast is needed here to get gcc 2.8.0 to use a 16 bit register
-        in the assembler statement. */
-      __asm__("mov %%gs,%0":"=r" (selector));
-      addr->selector = selector;
+      savesegment(gs, addr->selector);
       break;
     default:
       addr->selector = PM_REG_(segment);
index 8e90339d6eaaa18c96a5292c53f6590235804764..411b8500ad1b07736c92412fb3eaced4e5baf4f8 100644 (file)
@@ -199,6 +199,18 @@ static inline int is_prefetch(struct pt_regs *regs, unsigned long addr,
        return 0;
 } 
 
+static noinline void force_sig_info_fault(int si_signo, int si_code,
+       unsigned long address, struct task_struct *tsk)
+{
+       siginfo_t info;
+
+       info.si_signo = si_signo;
+       info.si_errno = 0;
+       info.si_code = si_code;
+       info.si_addr = (void __user *)address;
+       force_sig_info(si_signo, &info, tsk);
+}
+
 fastcall void do_invalid_op(struct pt_regs *, unsigned long);
 
 /*
@@ -218,11 +230,10 @@ fastcall void do_page_fault(struct pt_regs *regs, unsigned long error_code)
        struct vm_area_struct * vma;
        unsigned long address;
        unsigned long page;
-       int write;
-       siginfo_t info;
+       int write, si_code;
 
        /* get the address */
-       __asm__("movl %%cr2,%0":"=r" (address));
+        address = read_cr2();
 
        if (notify_die(DIE_PAGE_FAULT, "page fault", regs, error_code, 14,
                                        SIGSEGV) == NOTIFY_STOP)
@@ -233,7 +244,7 @@ fastcall void do_page_fault(struct pt_regs *regs, unsigned long error_code)
 
        tsk = current;
 
-       info.si_code = SEGV_MAPERR;
+       si_code = SEGV_MAPERR;
 
        /*
         * We fault-in kernel-space virtual memory on-demand. The
@@ -313,7 +324,7 @@ fastcall void do_page_fault(struct pt_regs *regs, unsigned long error_code)
  * we can handle it..
  */
 good_area:
-       info.si_code = SEGV_ACCERR;
+       si_code = SEGV_ACCERR;
        write = 0;
        switch (error_code & 3) {
                default:        /* 3: write, present */
@@ -387,11 +398,7 @@ bad_area_nosemaphore:
                /* Kernel addresses are always protection faults */
                tsk->thread.error_code = error_code | (address >= TASK_SIZE);
                tsk->thread.trap_no = 14;
-               info.si_signo = SIGSEGV;
-               info.si_errno = 0;
-               /* info.si_code has been set above */
-               info.si_addr = (void __user *)address;
-               force_sig_info(SIGSEGV, &info, tsk);
+               force_sig_info_fault(SIGSEGV, si_code, address, tsk);
                return;
        }
 
@@ -446,7 +453,7 @@ no_context:
        printk(" at virtual address %08lx\n",address);
        printk(KERN_ALERT " printing eip:\n");
        printk("%08lx\n", regs->eip);
-       asm("movl %%cr3,%0":"=r" (page));
+       page = read_cr3();
        page = ((unsigned long *) __va(page))[address >> 22];
        printk(KERN_ALERT "*pde = %08lx\n", page);
        /*
@@ -500,11 +507,7 @@ do_sigbus:
        tsk->thread.cr2 = address;
        tsk->thread.error_code = error_code;
        tsk->thread.trap_no = 14;
-       info.si_signo = SIGBUS;
-       info.si_errno = 0;
-       info.si_code = BUS_ADRERR;
-       info.si_addr = (void __user *)address;
-       force_sig_info(SIGBUS, &info, tsk);
+       force_sig_info_fault(SIGBUS, BUS_ADRERR, address, tsk);
        return;
 
 vmalloc_fault:
@@ -523,7 +526,7 @@ vmalloc_fault:
                pmd_t *pmd, *pmd_k;
                pte_t *pte_k;
 
-               asm("movl %%cr3,%0":"=r" (pgd_paddr));
+               pgd_paddr = read_cr3();
                pgd = index + (pgd_t *)__va(pgd_paddr);
                pgd_k = init_mm.pgd + index;
 
index 3b099f32b9487a054db420509ad25591ea0d06eb..d524127c9afc3b2f92b3e5ad6b3dbce20bec42f7 100644 (file)
@@ -22,12 +22,15 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
 {
        pgd_t *pgd;
        pud_t *pud;
-       pmd_t *pmd = NULL;
+       pte_t *pte = NULL;
 
        pgd = pgd_offset(mm, addr);
        pud = pud_alloc(mm, pgd, addr);
-       pmd = pmd_alloc(mm, pud, addr);
-       return (pte_t *) pmd;
+       if (pud)
+               pte = (pte_t *) pmd_alloc(mm, pud, addr);
+       BUG_ON(pte && !pte_none(*pte) && !pte_huge(*pte));
+
+       return pte;
 }
 
 pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
@@ -37,8 +40,11 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
        pmd_t *pmd = NULL;
 
        pgd = pgd_offset(mm, addr);
-       pud = pud_offset(pgd, addr);
-       pmd = pmd_offset(pud, addr);
+       if (pgd_present(*pgd)) {
+               pud = pud_offset(pgd, addr);
+               if (pud_present(*pud))
+                       pmd = pmd_offset(pud, addr);
+       }
        return (pte_t *) pmd;
 }
 
@@ -118,17 +124,6 @@ follow_huge_pmd(struct mm_struct *mm, unsigned long address,
 }
 #endif
 
-void hugetlb_clean_stale_pgtable(pte_t *pte)
-{
-       pmd_t *pmd = (pmd_t *) pte;
-       struct page *page;
-
-       page = pmd_page(*pmd);
-       pmd_clear(pmd);
-       dec_page_state(nr_page_table_pages);
-       page_cache_release(page);
-}
-
 /* x86_64 also uses this file */
 
 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
index 12216b52e28bf9b50060c509060fea3057fb298e..9edfc058b8943bb95cf056a86ffe7a2e443e6b5a 100644 (file)
@@ -198,9 +198,10 @@ int page_is_ram(unsigned long pagenr)
 
        if (efi_enabled) {
                efi_memory_desc_t *md;
+               void *p;
 
-               for (i = 0; i < memmap.nr_map; i++) {
-                       md = &memmap.map[i];
+               for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
+                       md = p;
                        if (!is_available_memory(md))
                                continue;
                        addr = (md->phys_addr+PAGE_SIZE-1) >> PAGE_SHIFT;
@@ -348,7 +349,7 @@ static void __init pagetable_init (void)
         * All user-space mappings are explicitly cleared after
         * SMP startup.
         */
-       pgd_base[0] = pgd_base[USER_PTRS_PER_PGD];
+       set_pgd(&pgd_base[0], pgd_base[USER_PTRS_PER_PGD]);
 #endif
 }
 
index cb3da6baa704208d4faf2977d411190d9a2aa88f..f600fc244f0284e67261e394de644705a67eb744 100644 (file)
@@ -12,6 +12,7 @@
 #include <asm/uaccess.h>
 #include <asm/processor.h>
 #include <asm/tlbflush.h>
+#include <asm/pgalloc.h>
 
 static DEFINE_SPINLOCK(cpa_lock);
 static struct list_head df_list = LIST_HEAD_INIT(df_list);
@@ -52,8 +53,8 @@ static struct page *split_large_page(unsigned long address, pgprot_t prot)
        addr = address & LARGE_PAGE_MASK; 
        pbase = (pte_t *)page_address(base);
        for (i = 0; i < PTRS_PER_PTE; i++, addr += PAGE_SIZE) {
-               pbase[i] = pfn_pte(addr >> PAGE_SHIFT, 
-                                  addr == address ? prot : PAGE_KERNEL);
+               set_pte(&pbase[i], pfn_pte(addr >> PAGE_SHIFT,
+                                          addr == address ? prot : PAGE_KERNEL));
        }
        return base;
 } 
@@ -62,7 +63,7 @@ static void flush_kernel_map(void *dummy)
 { 
        /* Could use CLFLUSH here if the CPU supports it (Hammer,P4) */
        if (boot_cpu_data.x86_model >= 4) 
-               asm volatile("wbinvd":::"memory"); 
+               wbinvd();
        /* Flush all to work around Errata in early athlons regarding 
         * large page flushing. 
         */
index bd2f7afc7a2a5d6726b14a35bdf48492bf4730a1..dcdce2c6c53239ad1ba747319ea6aecefa6d7a1a 100644 (file)
@@ -207,19 +207,19 @@ void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused)
 {
        unsigned long flags;
 
-       if (PTRS_PER_PMD == 1)
+       if (PTRS_PER_PMD == 1) {
+               memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t));
                spin_lock_irqsave(&pgd_lock, flags);
+       }
 
-       memcpy((pgd_t *)pgd + USER_PTRS_PER_PGD,
+       clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
                        swapper_pg_dir + USER_PTRS_PER_PGD,
-                       (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
-
+                       KERNEL_PGD_PTRS);
        if (PTRS_PER_PMD > 1)
                return;
 
        pgd_list_add(pgd);
        spin_unlock_irqrestore(&pgd_lock, flags);
-       memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t));
 }
 
 /* never called when PTRS_PER_PMD > 1 */
index c547c1af6fa1a86ea8e25f4dd62332c3f3302faa..7b0b9ad848e58eb9a723c16c87af4b1eb0aaa566 100644 (file)
@@ -42,25 +42,25 @@ void __save_processor_state(struct saved_context *ctxt)
        /*
         * descriptor tables
         */
-       asm volatile ("sgdt %0" : "=m" (ctxt->gdt_limit));
-       asm volatile ("sidt %0" : "=m" (ctxt->idt_limit));
-       asm volatile ("str %0"  : "=m" (ctxt->tr));
+       store_gdt(&ctxt->gdt_limit);
+       store_idt(&ctxt->idt_limit);
+       store_tr(ctxt->tr);
 
        /*
         * segment registers
         */
-       asm volatile ("movw %%es, %0" : "=m" (ctxt->es));
-       asm volatile ("movw %%fs, %0" : "=m" (ctxt->fs));
-       asm volatile ("movw %%gs, %0" : "=m" (ctxt->gs));
-       asm volatile ("movw %%ss, %0" : "=m" (ctxt->ss));
+       savesegment(es, ctxt->es);
+       savesegment(fs, ctxt->fs);
+       savesegment(gs, ctxt->gs);
+       savesegment(ss, ctxt->ss);
 
        /*
         * control registers 
         */
-       asm volatile ("movl %%cr0, %0" : "=r" (ctxt->cr0));
-       asm volatile ("movl %%cr2, %0" : "=r" (ctxt->cr2));
-       asm volatile ("movl %%cr3, %0" : "=r" (ctxt->cr3));
-       asm volatile ("movl %%cr4, %0" : "=r" (ctxt->cr4));
+       ctxt->cr0 = read_cr0();
+       ctxt->cr2 = read_cr2();
+       ctxt->cr3 = read_cr3();
+       ctxt->cr4 = read_cr4();
 }
 
 void save_processor_state(void)
@@ -84,7 +84,6 @@ static void fix_processor_context(void)
        struct tss_struct * t = &per_cpu(init_tss, cpu);
 
        set_tss_desc(cpu,t);    /* This just modifies memory; should not be necessary. But... This is necessary, because 386 hardware has concept of busy TSS or some similar stupidity. */
-        per_cpu(cpu_gdt_table, cpu)[GDT_ENTRY_TSS].b &= 0xfffffdff;
 
        load_TR_desc();                         /* This does ltr */
        load_LDT(&current->active_mm->context); /* This does lldt */
@@ -109,25 +108,25 @@ void __restore_processor_state(struct saved_context *ctxt)
        /*
         * control registers
         */
-       asm volatile ("movl %0, %%cr4" :: "r" (ctxt->cr4));
-       asm volatile ("movl %0, %%cr3" :: "r" (ctxt->cr3));
-       asm volatile ("movl %0, %%cr2" :: "r" (ctxt->cr2));
-       asm volatile ("movl %0, %%cr0" :: "r" (ctxt->cr0));
+       write_cr4(ctxt->cr4);
+       write_cr3(ctxt->cr3);
+       write_cr2(ctxt->cr2);
+       write_cr2(ctxt->cr0);
 
        /*
         * now restore the descriptor tables to their proper values
         * ltr is done i fix_processor_context().
         */
-       asm volatile ("lgdt %0" :: "m" (ctxt->gdt_limit));
-       asm volatile ("lidt %0" :: "m" (ctxt->idt_limit));
+       load_gdt(&ctxt->gdt_limit);
+       load_idt(&ctxt->idt_limit);
 
        /*
         * segment registers
         */
-       asm volatile ("movw %0, %%es" :: "r" (ctxt->es));
-       asm volatile ("movw %0, %%fs" :: "r" (ctxt->fs));
-       asm volatile ("movw %0, %%gs" :: "r" (ctxt->gs));
-       asm volatile ("movw %0, %%ss" :: "r" (ctxt->ss));
+       loadsegment(es, ctxt->es);
+       loadsegment(fs, ctxt->fs);
+       loadsegment(gs, ctxt->gs);
+       loadsegment(ss, ctxt->ss);
 
        /*
         * sysenter MSRs
index 80988136f26d7dec0791f62c1df59eca73af35ea..3deced637f07c814706698e6e90a10088aebe889 100644 (file)
@@ -383,6 +383,12 @@ source "drivers/acpi/Kconfig"
 
 endif
 
+if PM
+
+source "arch/ia64/kernel/cpufreq/Kconfig"
+
+endif
+
 endmenu
 
 if !IA64_HP_SIM
index 5c46928e3dc655739bf0081ce19f503848930054..30fdfb1d0a53e3d08c9f817eaf34a0bd7b9a78f3 100644 (file)
@@ -237,17 +237,6 @@ sal_emulator (long index, unsigned long in1, unsigned long in2,
        return ((struct sal_ret_values) {status, r9, r10, r11});
 }
 
-
-/*
- * This is here to work around a bug in egcs-1.1.1b that causes the
- * compiler to crash (seems like a bug in the new alias analysis code.
- */
-void *
-id (long addr)
-{
-       return (void *) addr;
-}
-
 struct ia64_boot_param *
 sys_fw_init (const char *args, int arglen)
 {
index ebb89be2aa2dba5acbcaf7773414ff7ca51a1b87..aa891c9bc9b67ac268970391f49122f37af4b22a 100644 (file)
@@ -29,7 +29,6 @@
 #include <asm/uaccess.h>
 #include <asm/rse.h>
 #include <asm/sigcontext.h>
-#include <asm/segment.h>
 
 #include "ia32priv.h"
 
index e1fb68ddec26328f5ea7f19ce099628fea81b664..b242594be55b46716d0ddf0a08e01dab60df14dd 100644 (file)
@@ -20,6 +20,7 @@ obj-$(CONFIG_SMP)             += smp.o smpboot.o domain.o
 obj-$(CONFIG_NUMA)             += numa.o
 obj-$(CONFIG_PERFMON)          += perfmon_default_smpl.o
 obj-$(CONFIG_IA64_CYCLONE)     += cyclone.o
+obj-$(CONFIG_CPU_FREQ)         += cpufreq/
 obj-$(CONFIG_IA64_MCA_RECOVERY)        += mca_recovery.o
 obj-$(CONFIG_KPROBES)          += kprobes.o jprobes.o
 obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR)  += uncached.o
diff --git a/arch/ia64/kernel/cpufreq/Kconfig b/arch/ia64/kernel/cpufreq/Kconfig
new file mode 100644 (file)
index 0000000..2d9d527
--- /dev/null
@@ -0,0 +1,29 @@
+
+#
+# CPU Frequency scaling
+#
+
+menu "CPU Frequency scaling"
+
+source "drivers/cpufreq/Kconfig"
+
+if CPU_FREQ
+
+comment "CPUFreq processor drivers"
+
+config IA64_ACPI_CPUFREQ
+       tristate "ACPI Processor P-States driver"
+       select CPU_FREQ_TABLE
+       depends on ACPI_PROCESSOR
+       help
+       This driver adds a CPUFreq driver which utilizes the ACPI
+       Processor Performance States.
+
+       For details, take a look at <file:Documentation/cpu-freq/>.
+
+       If in doubt, say N.
+
+endif   # CPU_FREQ
+
+endmenu
+
diff --git a/arch/ia64/kernel/cpufreq/Makefile b/arch/ia64/kernel/cpufreq/Makefile
new file mode 100644 (file)
index 0000000..f748d34
--- /dev/null
@@ -0,0 +1 @@
+obj-$(CONFIG_IA64_ACPI_CPUFREQ)                += acpi-cpufreq.o
diff --git a/arch/ia64/kernel/cpufreq/acpi-cpufreq.c b/arch/ia64/kernel/cpufreq/acpi-cpufreq.c
new file mode 100644 (file)
index 0000000..da4d5cf
--- /dev/null
@@ -0,0 +1,499 @@
+/*
+ * arch/ia64/kernel/cpufreq/acpi-cpufreq.c
+ * This file provides the ACPI based P-state support. This
+ * module works with generic cpufreq infrastructure. Most of
+ * the code is based on i386 version
+ * (arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c)
+ *
+ * Copyright (C) 2005 Intel Corp
+ *      Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/cpufreq.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <asm/pal.h>
+
+#include <linux/acpi.h>
+#include <acpi/processor.h>
+
+#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "acpi-cpufreq", msg)
+
+MODULE_AUTHOR("Venkatesh Pallipadi");
+MODULE_DESCRIPTION("ACPI Processor P-States Driver");
+MODULE_LICENSE("GPL");
+
+
+struct cpufreq_acpi_io {
+       struct acpi_processor_performance       acpi_data;
+       struct cpufreq_frequency_table          *freq_table;
+       unsigned int                            resume;
+};
+
+static struct cpufreq_acpi_io  *acpi_io_data[NR_CPUS];
+
+static struct cpufreq_driver acpi_cpufreq_driver;
+
+
+static int
+processor_set_pstate (
+       u32     value)
+{
+       s64 retval;
+
+       dprintk("processor_set_pstate\n");
+
+       retval = ia64_pal_set_pstate((u64)value);
+
+       if (retval) {
+               dprintk("Failed to set freq to 0x%x, with error 0x%x\n",
+                       value, retval);
+               return -ENODEV;
+       }
+       return (int)retval;
+}
+
+
+static int
+processor_get_pstate (
+       u32     *value)
+{
+       u64     pstate_index = 0;
+       s64     retval;
+
+       dprintk("processor_get_pstate\n");
+
+       retval = ia64_pal_get_pstate(&pstate_index);
+       *value = (u32) pstate_index;
+
+       if (retval)
+               dprintk("Failed to get current freq with "
+                       "error 0x%x, idx 0x%x\n", retval, *value);
+
+       return (int)retval;
+}
+
+
+/* To be used only after data->acpi_data is initialized */
+static unsigned
+extract_clock (
+       struct cpufreq_acpi_io *data,
+       unsigned value,
+       unsigned int cpu)
+{
+       unsigned long i;
+
+       dprintk("extract_clock\n");
+
+       for (i = 0; i < data->acpi_data.state_count; i++) {
+               if (value >= data->acpi_data.states[i].control)
+                       return data->acpi_data.states[i].core_frequency;
+       }
+       return data->acpi_data.states[i-1].core_frequency;
+}
+
+
+static unsigned int
+processor_get_freq (
+       struct cpufreq_acpi_io  *data,
+       unsigned int            cpu)
+{
+       int                     ret = 0;
+       u32                     value = 0;
+       cpumask_t               saved_mask;
+       unsigned long           clock_freq;
+
+       dprintk("processor_get_freq\n");
+
+       saved_mask = current->cpus_allowed;
+       set_cpus_allowed(current, cpumask_of_cpu(cpu));
+       if (smp_processor_id() != cpu) {
+               ret = -EAGAIN;
+               goto migrate_end;
+       }
+
+       /*
+        * processor_get_pstate gets the average frequency since the
+        * last get. So, do two PAL_get_freq()...
+        */
+       ret = processor_get_pstate(&value);
+       ret = processor_get_pstate(&value);
+
+       if (ret) {
+               set_cpus_allowed(current, saved_mask);
+               printk(KERN_WARNING "get performance failed with error %d\n",
+                      ret);
+               ret = -EAGAIN;
+               goto migrate_end;
+       }
+       clock_freq = extract_clock(data, value, cpu);
+       ret = (clock_freq*1000);
+
+migrate_end:
+       set_cpus_allowed(current, saved_mask);
+       return ret;
+}
+
+
+static int
+processor_set_freq (
+       struct cpufreq_acpi_io  *data,
+       unsigned int            cpu,
+       int                     state)
+{
+       int                     ret = 0;
+       u32                     value = 0;
+       struct cpufreq_freqs    cpufreq_freqs;
+       cpumask_t               saved_mask;
+       int                     retval;
+
+       dprintk("processor_set_freq\n");
+
+       saved_mask = current->cpus_allowed;
+       set_cpus_allowed(current, cpumask_of_cpu(cpu));
+       if (smp_processor_id() != cpu) {
+               retval = -EAGAIN;
+               goto migrate_end;
+       }
+
+       if (state == data->acpi_data.state) {
+               if (unlikely(data->resume)) {
+                       dprintk("Called after resume, resetting to P%d\n", state);
+                       data->resume = 0;
+               } else {
+                       dprintk("Already at target state (P%d)\n", state);
+                       retval = 0;
+                       goto migrate_end;
+               }
+       }
+
+       dprintk("Transitioning from P%d to P%d\n",
+               data->acpi_data.state, state);
+
+       /* cpufreq frequency struct */
+       cpufreq_freqs.cpu = cpu;
+       cpufreq_freqs.old = data->freq_table[data->acpi_data.state].frequency;
+       cpufreq_freqs.new = data->freq_table[state].frequency;
+
+       /* notify cpufreq */
+       cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_PRECHANGE);
+
+       /*
+        * First we write the target state's 'control' value to the
+        * control_register.
+        */
+
+       value = (u32) data->acpi_data.states[state].control;
+
+       dprintk("Transitioning to state: 0x%08x\n", value);
+
+       ret = processor_set_pstate(value);
+       if (ret) {
+               unsigned int tmp = cpufreq_freqs.new;
+               cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_POSTCHANGE);
+               cpufreq_freqs.new = cpufreq_freqs.old;
+               cpufreq_freqs.old = tmp;
+               cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_PRECHANGE);
+               cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_POSTCHANGE);
+               printk(KERN_WARNING "Transition failed with error %d\n", ret);
+               retval = -ENODEV;
+               goto migrate_end;
+       }
+
+       cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_POSTCHANGE);
+
+       data->acpi_data.state = state;
+
+       retval = 0;
+
+migrate_end:
+       set_cpus_allowed(current, saved_mask);
+       return (retval);
+}
+
+
+static unsigned int
+acpi_cpufreq_get (
+       unsigned int            cpu)
+{
+       struct cpufreq_acpi_io *data = acpi_io_data[cpu];
+
+       dprintk("acpi_cpufreq_get\n");
+
+       return processor_get_freq(data, cpu);
+}
+
+
+static int
+acpi_cpufreq_target (
+       struct cpufreq_policy   *policy,
+       unsigned int target_freq,
+       unsigned int relation)
+{
+       struct cpufreq_acpi_io *data = acpi_io_data[policy->cpu];
+       unsigned int next_state = 0;
+       unsigned int result = 0;
+
+       dprintk("acpi_cpufreq_setpolicy\n");
+
+       result = cpufreq_frequency_table_target(policy,
+                       data->freq_table, target_freq, relation, &next_state);
+       if (result)
+               return (result);
+
+       result = processor_set_freq(data, policy->cpu, next_state);
+
+       return (result);
+}
+
+
+static int
+acpi_cpufreq_verify (
+       struct cpufreq_policy   *policy)
+{
+       unsigned int result = 0;
+       struct cpufreq_acpi_io *data = acpi_io_data[policy->cpu];
+
+       dprintk("acpi_cpufreq_verify\n");
+
+       result = cpufreq_frequency_table_verify(policy,
+                       data->freq_table);
+
+       return (result);
+}
+
+
+/*
+ * processor_init_pdc - let BIOS know about the SMP capabilities
+ * of this driver
+ * @perf: processor-specific acpi_io_data struct
+ * @cpu: CPU being initialized
+ *
+ * To avoid issues with legacy OSes, some BIOSes require to be informed of
+ * the SMP capabilities of OS P-state driver. Here we set the bits in _PDC
+ * accordingly. Actual call to _PDC is done in driver/acpi/processor.c
+ */
+static void
+processor_init_pdc (
+               struct acpi_processor_performance *perf,
+               unsigned int cpu,
+               struct acpi_object_list *obj_list
+               )
+{
+       union acpi_object *obj;
+       u32 *buf;
+
+       dprintk("processor_init_pdc\n");
+
+       perf->pdc = NULL;
+       /* Initialize pdc. It will be used later. */
+       if (!obj_list)
+               return;
+
+       if (!(obj_list->count && obj_list->pointer))
+               return;
+
+       obj = obj_list->pointer;
+       if ((obj->buffer.length == 12) && obj->buffer.pointer) {
+               buf = (u32 *)obj->buffer.pointer;
+                       buf[0] = ACPI_PDC_REVISION_ID;
+                       buf[1] = 1;
+                       buf[2] = ACPI_PDC_EST_CAPABILITY_SMP;
+               perf->pdc = obj_list;
+       }
+       return;
+}
+
+
+static int
+acpi_cpufreq_cpu_init (
+       struct cpufreq_policy   *policy)
+{
+       unsigned int            i;
+       unsigned int            cpu = policy->cpu;
+       struct cpufreq_acpi_io  *data;
+       unsigned int            result = 0;
+
+       union acpi_object               arg0 = {ACPI_TYPE_BUFFER};
+       u32                             arg0_buf[3];
+       struct acpi_object_list         arg_list = {1, &arg0};
+
+       dprintk("acpi_cpufreq_cpu_init\n");
+       /* setup arg_list for _PDC settings */
+        arg0.buffer.length = 12;
+        arg0.buffer.pointer = (u8 *) arg0_buf;
+
+       data = kmalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL);
+       if (!data)
+               return (-ENOMEM);
+
+       memset(data, 0, sizeof(struct cpufreq_acpi_io));
+
+       acpi_io_data[cpu] = data;
+
+       processor_init_pdc(&data->acpi_data, cpu, &arg_list);
+       result = acpi_processor_register_performance(&data->acpi_data, cpu);
+       data->acpi_data.pdc = NULL;
+
+       if (result)
+               goto err_free;
+
+       /* capability check */
+       if (data->acpi_data.state_count <= 1) {
+               dprintk("No P-States\n");
+               result = -ENODEV;
+               goto err_unreg;
+       }
+
+       if ((data->acpi_data.control_register.space_id !=
+                                       ACPI_ADR_SPACE_FIXED_HARDWARE) ||
+           (data->acpi_data.status_register.space_id !=
+                                       ACPI_ADR_SPACE_FIXED_HARDWARE)) {
+               dprintk("Unsupported address space [%d, %d]\n",
+                       (u32) (data->acpi_data.control_register.space_id),
+                       (u32) (data->acpi_data.status_register.space_id));
+               result = -ENODEV;
+               goto err_unreg;
+       }
+
+       /* alloc freq_table */
+       data->freq_table = kmalloc(sizeof(struct cpufreq_frequency_table) *
+                                  (data->acpi_data.state_count + 1),
+                                  GFP_KERNEL);
+       if (!data->freq_table) {
+               result = -ENOMEM;
+               goto err_unreg;
+       }
+
+       /* detect transition latency */
+       policy->cpuinfo.transition_latency = 0;
+       for (i=0; i<data->acpi_data.state_count; i++) {
+               if ((data->acpi_data.states[i].transition_latency * 1000) >
+                   policy->cpuinfo.transition_latency) {
+                       policy->cpuinfo.transition_latency =
+                           data->acpi_data.states[i].transition_latency * 1000;
+               }
+       }
+       policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
+
+       policy->cur = processor_get_freq(data, policy->cpu);
+
+       /* table init */
+       for (i = 0; i <= data->acpi_data.state_count; i++)
+       {
+               data->freq_table[i].index = i;
+               if (i < data->acpi_data.state_count) {
+                       data->freq_table[i].frequency =
+                             data->acpi_data.states[i].core_frequency * 1000;
+               } else {
+                       data->freq_table[i].frequency = CPUFREQ_TABLE_END;
+               }
+       }
+
+       result = cpufreq_frequency_table_cpuinfo(policy, data->freq_table);
+       if (result) {
+               goto err_freqfree;
+       }
+
+       /* notify BIOS that we exist */
+       acpi_processor_notify_smm(THIS_MODULE);
+
+       printk(KERN_INFO "acpi-cpufreq: CPU%u - ACPI performance management "
+              "activated.\n", cpu);
+
+       for (i = 0; i < data->acpi_data.state_count; i++)
+               dprintk("     %cP%d: %d MHz, %d mW, %d uS, %d uS, 0x%x 0x%x\n",
+                       (i == data->acpi_data.state?'*':' '), i,
+                       (u32) data->acpi_data.states[i].core_frequency,
+                       (u32) data->acpi_data.states[i].power,
+                       (u32) data->acpi_data.states[i].transition_latency,
+                       (u32) data->acpi_data.states[i].bus_master_latency,
+                       (u32) data->acpi_data.states[i].status,
+                       (u32) data->acpi_data.states[i].control);
+
+       cpufreq_frequency_table_get_attr(data->freq_table, policy->cpu);
+
+       /* the first call to ->target() should result in us actually
+        * writing something to the appropriate registers. */
+       data->resume = 1;
+
+       return (result);
+
+ err_freqfree:
+       kfree(data->freq_table);
+ err_unreg:
+       acpi_processor_unregister_performance(&data->acpi_data, cpu);
+ err_free:
+       kfree(data);
+       acpi_io_data[cpu] = NULL;
+
+       return (result);
+}
+
+
+static int
+acpi_cpufreq_cpu_exit (
+       struct cpufreq_policy   *policy)
+{
+       struct cpufreq_acpi_io *data = acpi_io_data[policy->cpu];
+
+       dprintk("acpi_cpufreq_cpu_exit\n");
+
+       if (data) {
+               cpufreq_frequency_table_put_attr(policy->cpu);
+               acpi_io_data[policy->cpu] = NULL;
+               acpi_processor_unregister_performance(&data->acpi_data,
+                                                     policy->cpu);
+               kfree(data);
+       }
+
+       return (0);
+}
+
+
+static struct freq_attr* acpi_cpufreq_attr[] = {
+       &cpufreq_freq_attr_scaling_available_freqs,
+       NULL,
+};
+
+
+static struct cpufreq_driver acpi_cpufreq_driver = {
+       .verify         = acpi_cpufreq_verify,
+       .target         = acpi_cpufreq_target,
+       .get            = acpi_cpufreq_get,
+       .init           = acpi_cpufreq_cpu_init,
+       .exit           = acpi_cpufreq_cpu_exit,
+       .name           = "acpi-cpufreq",
+       .owner          = THIS_MODULE,
+       .attr           = acpi_cpufreq_attr,
+};
+
+
+static int __init
+acpi_cpufreq_init (void)
+{
+       dprintk("acpi_cpufreq_init\n");
+
+       return cpufreq_register_driver(&acpi_cpufreq_driver);
+}
+
+
+static void __exit
+acpi_cpufreq_exit (void)
+{
+       dprintk("acpi_cpufreq_exit\n");
+
+       cpufreq_unregister_driver(&acpi_cpufreq_driver);
+       return;
+}
+
+
+late_initcall(acpi_cpufreq_init);
+module_exit(acpi_cpufreq_exit);
+
index 770fab37928ee9e4c3870b8875473f7a53d1213b..f2dbcd1db0d4dc99b3baca0d0b677c3ed788a58c 100644 (file)
@@ -35,7 +35,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
                return -ENOMEM;
 
 #ifdef CONFIG_HUGETLB_PAGE
-       if (REGION_NUMBER(addr) == REGION_HPAGE)
+       if (REGION_NUMBER(addr) == RGN_HPAGE)
                addr = 0;
 #endif
        if (!addr)
index 490dfc9ab47ffd51bd02167047e7dcb3a9de5041..4e9d06c48a8ba40c3cb70d39e352efa793f26f48 100644 (file)
@@ -184,7 +184,7 @@ uncached_free_page(unsigned long maddr)
 {
        int node;
 
-       node = nasid_to_cnodeid(NASID_GET(maddr));
+       node = paddr_to_nid(maddr - __IA64_UNCACHED_OFFSET);
 
        dprintk(KERN_DEBUG "uncached_free_page(%lx) on node %i\n", maddr, node);
 
@@ -217,7 +217,7 @@ uncached_build_memmap(unsigned long start, unsigned long end, void *arg)
 
        memset((char *)vstart, 0, length);
 
-       node = nasid_to_cnodeid(NASID_GET(start));
+       node = paddr_to_nid(start);
 
        for (; vstart < vend ; vstart += PAGE_SIZE) {
                dprintk(KERN_INFO "sticking %lx into the pool!\n", vstart);
index 1902c3c2ef923f57ff19b9550cd34bb75ce7a4bb..799407e7726f2a9c54f301ce50f71c253f514174 100644 (file)
@@ -6,7 +6,7 @@ obj-y := io.o
 
 lib-y := __divsi3.o __udivsi3.o __modsi3.o __umodsi3.o                 \
        __divdi3.o __udivdi3.o __moddi3.o __umoddi3.o                   \
-       bitop.o checksum.o clear_page.o csum_partial_copy.o copy_page.o \
+       bitop.o checksum.o clear_page.o csum_partial_copy.o             \
        clear_user.o strncpy_from_user.o strlen_user.o strnlen_user.o   \
        flush.o ip_fast_csum.o do_csum.o                                \
        memset.o strlen.o swiotlb.o
index ab7b3ad99a7fa9f9c87c78474ee7fda27d3f01b0..dbc0b3e449c5fe7ad8e81c284d00c85b0bf600fe 100644 (file)
@@ -93,8 +93,7 @@ static int __init
 setup_io_tlb_npages(char *str)
 {
        if (isdigit(*str)) {
-               io_tlb_nslabs = simple_strtoul(str, &str, 0) <<
-                       (PAGE_SHIFT - IO_TLB_SHIFT);
+               io_tlb_nslabs = simple_strtoul(str, &str, 0);
                /* avoid tail segment of size < IO_TLB_SEGSIZE */
                io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
        }
@@ -117,7 +116,7 @@ swiotlb_init_with_default_size (size_t default_size)
        unsigned long i;
 
        if (!io_tlb_nslabs) {
-               io_tlb_nslabs = (default_size >> PAGE_SHIFT);
+               io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
                io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
        }
 
index e0a776a3044c89f5614de6e2284c6a338cda6170..2d13889d0a9915da645b074ecbef1f8a0b56d116 100644 (file)
@@ -76,7 +76,7 @@ int is_aligned_hugepage_range(unsigned long addr, unsigned long len)
                return -EINVAL;
        if (addr & ~HPAGE_MASK)
                return -EINVAL;
-       if (REGION_NUMBER(addr) != REGION_HPAGE)
+       if (REGION_NUMBER(addr) != RGN_HPAGE)
                return -EINVAL;
 
        return 0;
@@ -87,7 +87,7 @@ struct page *follow_huge_addr(struct mm_struct *mm, unsigned long addr, int writ
        struct page *page;
        pte_t *ptep;
 
-       if (REGION_NUMBER(addr) != REGION_HPAGE)
+       if (REGION_NUMBER(addr) != RGN_HPAGE)
                return ERR_PTR(-EINVAL);
 
        ptep = huge_pte_offset(mm, addr);
@@ -142,8 +142,8 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
                return -ENOMEM;
        if (len & ~HPAGE_MASK)
                return -EINVAL;
-       /* This code assumes that REGION_HPAGE != 0. */
-       if ((REGION_NUMBER(addr) != REGION_HPAGE) || (addr & (HPAGE_SIZE - 1)))
+       /* This code assumes that RGN_HPAGE != 0. */
+       if ((REGION_NUMBER(addr) != RGN_HPAGE) || (addr & (HPAGE_SIZE - 1)))
                addr = HPAGE_REGION_BASE;
        else
                addr = ALIGN(addr, HPAGE_SIZE);
index f9472c50ab4298a072fd25cfca6743ff69122b91..9977c122e9fa2c1a314e2d90fb5260dba87b0cb7 100644 (file)
@@ -24,7 +24,6 @@
 
 #include <asm/machvec.h>
 #include <asm/page.h>
-#include <asm/segment.h>
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/sal.h>
index 0139124dd54a66935124494ff4cff213f0452d89..6b2e7b75eb19136cee3f7f5943667c55ee75da90 100644 (file)
@@ -3,7 +3,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 2000-2004 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 2000-2005 Silicon Graphics, Inc. All rights reserved.
  */
 
 #ifndef _ASM_IA64_SN_TIO_H
 #define TIO_ITTE_VALID_MASK    0x1
 #define TIO_ITTE_VALID_SHIFT   16
 
+#define TIO_ITTE_WIDGET(itte) \
+       (((itte) >> TIO_ITTE_WIDGET_SHIFT) & TIO_ITTE_WIDGET_MASK)
+#define TIO_ITTE_VALID(itte) \
+       (((itte) >> TIO_ITTE_VALID_SHIFT) & TIO_ITTE_VALID_MASK)
 
 #define TIO_ITTE_PUT(nasid, bigwin, widget, addr, valid) \
         REMOTE_HUB_S((nasid), TIO_ITTE(bigwin), \
index 580a1c0403a73c373c60cf34cc59f985bb5a16f0..71c2b271b4c687daabd4e886023fe85dacfeeb94 100644 (file)
@@ -3,7 +3,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1992 - 1997, 2000-2004 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 1992 - 1997, 2000-2005 Silicon Graphics, Inc. All rights reserved.
  */
 #ifndef _ASM_IA64_SN_XTALK_HUBDEV_H
 #define _ASM_IA64_SN_XTALK_HUBDEV_H
@@ -16,6 +16,9 @@
 #define IIO_ITTE_WIDGET_MASK    ((1<<IIO_ITTE_WIDGET_BITS)-1)
 #define IIO_ITTE_WIDGET_SHIFT   8
 
+#define IIO_ITTE_WIDGET(itte)  \
+       (((itte) >> IIO_ITTE_WIDGET_SHIFT) & IIO_ITTE_WIDGET_MASK)
+
 /*
  * Use the top big window as a surrogate for the first small window
  */
@@ -34,7 +37,8 @@ struct sn_flush_device_list {
        unsigned long sfdl_force_int_addr;
        unsigned long sfdl_flush_value;
        volatile unsigned long *sfdl_flush_addr;
-       uint64_t sfdl_persistent_busnum;
+       uint32_t sfdl_persistent_busnum;
+       uint32_t sfdl_persistent_segment;
        struct pcibus_info *sfdl_pcibus_info;
        spinlock_t sfdl_flush_lock;
 };
@@ -58,7 +62,8 @@ struct hubdev_info {
 
        void                            *hdi_nodepda;
        void                            *hdi_node_vertex;
-       void                            *hdi_xtalk_vertex;
+       uint32_t                        max_segment_number;
+       uint32_t                        max_pcibus_number;
 };
 
 extern void hubdev_init_node(nodepda_t *, cnodeid_t);
index 647deae9bfcd57c3fef46b03d7f47912f6c985b1..45854c637e9ca035f2d16dac86da2698ec300030 100644 (file)
 
 /* two interfaces on two btes */
 #define MAX_INTERFACES_TO_TRY          4
+#define MAX_NODES_TO_TRY               2
 
 static struct bteinfo_s *bte_if_on_node(nasid_t nasid, int interface)
 {
        nodepda_t *tmp_nodepda;
 
+       if (nasid_to_cnodeid(nasid) == -1)
+               return (struct bteinfo_s *)NULL;;
+
        tmp_nodepda = NODEPDA(nasid_to_cnodeid(nasid));
        return &tmp_nodepda->bte_if[interface];
 
 }
 
+static inline void bte_start_transfer(struct bteinfo_s *bte, u64 len, u64 mode)
+{
+       if (is_shub2()) {
+               BTE_CTRL_STORE(bte, (IBLS_BUSY | ((len) | (mode) << 24)));
+       } else {
+               BTE_LNSTAT_STORE(bte, len);
+               BTE_CTRL_STORE(bte, mode);
+       }
+}
+
 /************************************************************************
  * Block Transfer Engine copy related functions.
  *
@@ -67,13 +81,15 @@ bte_result_t bte_copy(u64 src, u64 dest, u64 len, u64 mode, void *notification)
 {
        u64 transfer_size;
        u64 transfer_stat;
+       u64 notif_phys_addr;
        struct bteinfo_s *bte;
        bte_result_t bte_status;
        unsigned long irq_flags;
        unsigned long itc_end = 0;
-       struct bteinfo_s *btes_to_try[MAX_INTERFACES_TO_TRY];
-       int bte_if_index;
-       int bte_pri, bte_sec;
+       int nasid_to_try[MAX_NODES_TO_TRY];
+       int my_nasid = get_nasid();
+       int bte_if_index, nasid_index;
+       int bte_first, btes_per_node = BTES_PER_NODE;
 
        BTE_PRINTK(("bte_copy(0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%p)\n",
                    src, dest, len, mode, notification));
@@ -86,36 +102,26 @@ bte_result_t bte_copy(u64 src, u64 dest, u64 len, u64 mode, void *notification)
                 (src & L1_CACHE_MASK) || (dest & L1_CACHE_MASK));
        BUG_ON(!(len < ((BTE_LEN_MASK + 1) << L1_CACHE_SHIFT)));
 
-       /* CPU 0 (per node) tries bte0 first, CPU 1 try bte1 first */
-       if (cpuid_to_subnode(smp_processor_id()) == 0) {
-               bte_pri = 0;
-               bte_sec = 1;
-       } else {
-               bte_pri = 1;
-               bte_sec = 0;
-       }
+       /*
+        * Start with interface corresponding to cpu number
+        */
+       bte_first = raw_smp_processor_id() % btes_per_node;
 
        if (mode & BTE_USE_DEST) {
                /* try remote then local */
-               btes_to_try[0] = bte_if_on_node(NASID_GET(dest), bte_pri);
-               btes_to_try[1] = bte_if_on_node(NASID_GET(dest), bte_sec);
+               nasid_to_try[0] = NASID_GET(dest);
                if (mode & BTE_USE_ANY) {
-                       btes_to_try[2] = bte_if_on_node(get_nasid(), bte_pri);
-                       btes_to_try[3] = bte_if_on_node(get_nasid(), bte_sec);
+                       nasid_to_try[1] = my_nasid;
                } else {
-                       btes_to_try[2] = NULL;
-                       btes_to_try[3] = NULL;
+                       nasid_to_try[1] = (int)NULL;
                }
        } else {
                /* try local then remote */
-               btes_to_try[0] = bte_if_on_node(get_nasid(), bte_pri);
-               btes_to_try[1] = bte_if_on_node(get_nasid(), bte_sec);
+               nasid_to_try[0] = my_nasid;
                if (mode & BTE_USE_ANY) {
-                       btes_to_try[2] = bte_if_on_node(NASID_GET(dest), bte_pri);
-                       btes_to_try[3] = bte_if_on_node(NASID_GET(dest), bte_sec);
+                       nasid_to_try[1] = NASID_GET(dest);
                } else {
-                       btes_to_try[2] = NULL;
-                       btes_to_try[3] = NULL;
+                       nasid_to_try[1] = (int)NULL;
                }
        }
 
@@ -123,11 +129,12 @@ retry_bteop:
        do {
                local_irq_save(irq_flags);
 
-               bte_if_index = 0;
+               bte_if_index = bte_first;
+               nasid_index = 0;
 
                /* Attempt to lock one of the BTE interfaces. */
-               while (bte_if_index < MAX_INTERFACES_TO_TRY) {
-                       bte = btes_to_try[bte_if_index++];
+               while (nasid_index < MAX_NODES_TO_TRY) {
+                       bte = bte_if_on_node(nasid_to_try[nasid_index],bte_if_index);
 
                        if (bte == NULL) {
                                continue;
@@ -143,6 +150,15 @@ retry_bteop:
                                        break;
                                }
                        }
+
+                       bte_if_index = (bte_if_index + 1) % btes_per_node; /* Next interface */
+                       if (bte_if_index == bte_first) {
+                               /*
+                                * We've tried all interfaces on this node
+                                */
+                               nasid_index++;
+                       }
+
                        bte = NULL;
                }
 
@@ -169,7 +185,13 @@ retry_bteop:
 
        /* Initialize the notification to a known value. */
        *bte->most_rcnt_na = BTE_WORD_BUSY;
+       notif_phys_addr = TO_PHYS(ia64_tpa((unsigned long)bte->most_rcnt_na));
 
+       if (is_shub2()) {
+               src = SH2_TIO_PHYS_TO_DMA(src);
+               dest = SH2_TIO_PHYS_TO_DMA(dest);
+               notif_phys_addr = SH2_TIO_PHYS_TO_DMA(notif_phys_addr);
+       }
        /* Set the source and destination registers */
        BTE_PRINTKV(("IBSA = 0x%lx)\n", (TO_PHYS(src))));
        BTE_SRC_STORE(bte, TO_PHYS(src));
@@ -177,14 +199,12 @@ retry_bteop:
        BTE_DEST_STORE(bte, TO_PHYS(dest));
 
        /* Set the notification register */
-       BTE_PRINTKV(("IBNA = 0x%lx)\n",
-                    TO_PHYS(ia64_tpa((unsigned long)bte->most_rcnt_na))));
-       BTE_NOTIF_STORE(bte,
-                       TO_PHYS(ia64_tpa((unsigned long)bte->most_rcnt_na)));
+       BTE_PRINTKV(("IBNA = 0x%lx)\n", notif_phys_addr));
+       BTE_NOTIF_STORE(bte, notif_phys_addr);
 
        /* Initiate the transfer */
        BTE_PRINTK(("IBCT = 0x%lx)\n", BTE_VALID_MODE(mode)));
-       BTE_START_TRANSFER(bte, transfer_size, BTE_VALID_MODE(mode));
+       bte_start_transfer(bte, transfer_size, BTE_VALID_MODE(mode));
 
        itc_end = ia64_get_itc() + (40000000 * local_cpu_data->cyc_per_usec);
 
@@ -195,6 +215,7 @@ retry_bteop:
        }
 
        while ((transfer_stat = *bte->most_rcnt_na) == BTE_WORD_BUSY) {
+               cpu_relax();
                if (ia64_get_itc() > itc_end) {
                        BTE_PRINTK(("BTE timeout nasid 0x%x bte%d IBLS = 0x%lx na 0x%lx\n",
                                NASID_GET(bte->bte_base_addr), bte->bte_num,
index 5c39b43ba3c029604103bb1757dbe3d5db1faa5c..5c5eb01c50f02b53f97513eda0e1e65e3daa2c00 100644 (file)
@@ -76,7 +76,7 @@ void hubiio_crb_free(struct hubdev_info *hubdev_info, int crbnum)
         */
        REMOTE_HUB_S(hubdev_info->hdi_nasid, IIO_ICDR, (IIO_ICDR_PND | crbnum));
        while (REMOTE_HUB_L(hubdev_info->hdi_nasid, IIO_ICDR) & IIO_ICDR_PND)
-               udelay(1);
+               cpu_relax();
 
 }
 
index 414cdf2e3c965e124223833a1ed036783e4c4392..4564ed0b5ff31e32aab74c819369e3762382f512 100644 (file)
@@ -18,6 +18,7 @@
 #include <asm/sn/simulator.h>
 #include <asm/sn/sn_sal.h>
 #include <asm/sn/tioca_provider.h>
+#include <asm/sn/tioce_provider.h>
 #include "xtalk/hubdev.h"
 #include "xtalk/xwidgetdev.h"
 
@@ -44,6 +45,9 @@ int sn_ioif_inited = 0;               /* SN I/O infrastructure initialized? */
 
 struct sn_pcibus_provider *sn_pci_provider[PCIIO_ASIC_MAX_TYPES];      /* indexed by asic type */
 
+static int max_segment_number = 0; /* Default highest segment number */
+static int max_pcibus_number = 255; /* Default highest pci bus number */
+
 /*
  * Hooks and struct for unsupported pci providers
  */
@@ -157,13 +161,28 @@ static void sn_fixup_ionodes(void)
        uint64_t nasid;
        int i, widget;
 
+       /*
+        * Get SGI Specific HUB chipset information.
+        * Inform Prom that this kernel can support domain bus numbering.
+        */
        for (i = 0; i < numionodes; i++) {
                hubdev = (struct hubdev_info *)(NODEPDA(i)->pdinfo);
                nasid = cnodeid_to_nasid(i);
+               hubdev->max_segment_number = 0xffffffff;
+               hubdev->max_pcibus_number = 0xff;
                status = sal_get_hubdev_info(nasid, (uint64_t) __pa(hubdev));
                if (status)
                        continue;
 
+               /* Save the largest Domain and pcibus numbers found. */
+               if (hubdev->max_segment_number) {
+                       /*
+                        * Dealing with a Prom that supports segments.
+                        */
+                       max_segment_number = hubdev->max_segment_number;
+                       max_pcibus_number = hubdev->max_pcibus_number;
+               }
+
                /* Attach the error interrupt handlers */
                if (nasid & 1)
                        ice_error_init(hubdev);
@@ -230,7 +249,7 @@ void sn_pci_unfixup_slot(struct pci_dev *dev)
 void sn_pci_fixup_slot(struct pci_dev *dev)
 {
        int idx;
-       int segment = 0;
+       int segment = pci_domain_nr(dev->bus);
        int status = 0;
        struct pcibus_bussoft *bs;
        struct pci_bus *host_pci_bus;
@@ -283,9 +302,9 @@ void sn_pci_fixup_slot(struct pci_dev *dev)
         * PCI host_pci_dev struct and set up host bus linkages
         */
 
-       bus_no = SN_PCIDEV_INFO(dev)->pdi_slot_host_handle >> 32;
+       bus_no = (SN_PCIDEV_INFO(dev)->pdi_slot_host_handle >> 32) & 0xff;
        devfn = SN_PCIDEV_INFO(dev)->pdi_slot_host_handle & 0xffffffff;
-       host_pci_bus = pci_find_bus(pci_domain_nr(dev->bus), bus_no);
+       host_pci_bus = pci_find_bus(segment, bus_no);
        host_pci_dev = pci_get_slot(host_pci_bus, devfn);
 
        SN_PCIDEV_INFO(dev)->host_pci_dev = host_pci_dev;
@@ -333,6 +352,7 @@ void sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
        prom_bussoft_ptr = __va(prom_bussoft_ptr);
 
        controller = kcalloc(1,sizeof(struct pci_controller), GFP_KERNEL);
+       controller->segment = segment;
        if (!controller)
                BUG();
 
@@ -390,7 +410,7 @@ void sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
        if (controller->node >= num_online_nodes()) {
                struct pcibus_bussoft *b = SN_PCIBUS_BUSSOFT(bus);
 
-               printk(KERN_WARNING "Device ASIC=%u XID=%u PBUSNUM=%lu"
+               printk(KERN_WARNING "Device ASIC=%u XID=%u PBUSNUM=%u"
                                    "L_IO=%lx L_MEM=%lx BASE=%lx\n",
                        b->bs_asic_type, b->bs_xid, b->bs_persist_busnum,
                        b->bs_legacy_io, b->bs_legacy_mem, b->bs_base);
@@ -445,6 +465,7 @@ sn_sysdata_free_start:
 static int __init sn_pci_init(void)
 {
        int i = 0;
+       int j = 0;
        struct pci_dev *pci_dev = NULL;
        extern void sn_init_cpei_timer(void);
 #ifdef CONFIG_PROC_FS
@@ -464,6 +485,7 @@ static int __init sn_pci_init(void)
 
        pcibr_init_provider();
        tioca_init_provider();
+       tioce_init_provider();
 
        /*
         * This is needed to avoid bounce limit checks in the blk layer
@@ -479,8 +501,9 @@ static int __init sn_pci_init(void)
 #endif
 
        /* busses are not known yet ... */
-       for (i = 0; i < PCI_BUSES_TO_SCAN; i++)
-               sn_pci_controller_fixup(0, i, NULL);
+       for (i = 0; i <= max_segment_number; i++)
+               for (j = 0; j <= max_pcibus_number; j++)
+                       sn_pci_controller_fixup(i, j, NULL);
 
        /*
         * Generic Linux PCI Layer has created the pci_bus and pci_dev 
index 84d276a14ecb178d696d239f0758efaff251ee47..9fc74631ba8aa92568a8fed1e27c0a202e00f92f 100644 (file)
@@ -5,7 +5,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
  */
 
 #include <linux/irq.h>
@@ -76,16 +76,14 @@ static void sn_enable_irq(unsigned int irq)
 
 static void sn_ack_irq(unsigned int irq)
 {
-       uint64_t event_occurred, mask = 0;
-       int nasid;
+       u64 event_occurred, mask = 0;
 
        irq = irq & 0xff;
-       nasid = get_nasid();
        event_occurred =
-           HUB_L((uint64_t *) GLOBAL_MMR_ADDR(nasid, SH_EVENT_OCCURRED));
+           HUB_L((u64*)LOCAL_MMR_ADDR(SH_EVENT_OCCURRED));
        mask = event_occurred & SH_ALL_INT_MASK;
-       HUB_S((uint64_t *) GLOBAL_MMR_ADDR(nasid, SH_EVENT_OCCURRED_ALIAS),
-                mask);
+       HUB_S((u64*)LOCAL_MMR_ADDR(SH_EVENT_OCCURRED_ALIAS),
+             mask);
        __set_bit(irq, (volatile void *)pda->sn_in_service_ivecs);
 
        move_irq(irq);
@@ -93,15 +91,12 @@ static void sn_ack_irq(unsigned int irq)
 
 static void sn_end_irq(unsigned int irq)
 {
-       int nasid;
        int ivec;
-       uint64_t event_occurred;
+       u64 event_occurred;
 
        ivec = irq & 0xff;
        if (ivec == SGI_UART_VECTOR) {
-               nasid = get_nasid();
-               event_occurred = HUB_L((uint64_t *) GLOBAL_MMR_ADDR
-                                      (nasid, SH_EVENT_OCCURRED));
+               event_occurred = HUB_L((u64*)LOCAL_MMR_ADDR (SH_EVENT_OCCURRED));
                /* If the UART bit is set here, we may have received an
                 * interrupt from the UART that the driver missed.  To
                 * make sure, we IPI ourselves to force us to look again.
@@ -132,6 +127,7 @@ static void sn_set_affinity_irq(unsigned int irq, cpumask_t mask)
                int local_widget, status;
                nasid_t local_nasid;
                struct sn_irq_info *new_irq_info;
+               struct sn_pcibus_provider *pci_provider;
 
                new_irq_info = kmalloc(sizeof(struct sn_irq_info), GFP_ATOMIC);
                if (new_irq_info == NULL)
@@ -171,8 +167,9 @@ static void sn_set_affinity_irq(unsigned int irq, cpumask_t mask)
                new_irq_info->irq_cpuid = cpuid;
                register_intr_pda(new_irq_info);
 
-               if (IS_PCI_BRIDGE_ASIC(new_irq_info->irq_bridge_type))
-                       pcibr_change_devices_irq(new_irq_info);
+               pci_provider = sn_pci_provider[new_irq_info->irq_bridge_type];
+               if (pci_provider && pci_provider->target_interrupt)
+                       (pci_provider->target_interrupt)(new_irq_info);
 
                spin_lock(&sn_irq_info_lock);
                list_replace_rcu(&sn_irq_info->list, &new_irq_info->list);
@@ -317,6 +314,16 @@ void sn_irq_unfixup(struct pci_dev *pci_dev)
        pci_dev_put(pci_dev);
 }
 
+static inline void
+sn_call_force_intr_provider(struct sn_irq_info *sn_irq_info)
+{
+       struct sn_pcibus_provider *pci_provider;
+
+       pci_provider = sn_pci_provider[sn_irq_info->irq_bridge_type];
+       if (pci_provider && pci_provider->force_interrupt)
+               (*pci_provider->force_interrupt)(sn_irq_info);
+}
+
 static void force_interrupt(int irq)
 {
        struct sn_irq_info *sn_irq_info;
@@ -325,11 +332,9 @@ static void force_interrupt(int irq)
                return;
 
        rcu_read_lock();
-       list_for_each_entry_rcu(sn_irq_info, sn_irq_lh[irq], list) {
-               if (IS_PCI_BRIDGE_ASIC(sn_irq_info->irq_bridge_type) &&
-                   (sn_irq_info->irq_bridge != NULL))
-                       pcibr_force_interrupt(sn_irq_info);
-       }
+       list_for_each_entry_rcu(sn_irq_info, sn_irq_lh[irq], list)
+               sn_call_force_intr_provider(sn_irq_info);
+
        rcu_read_unlock();
 }
 
@@ -351,6 +356,14 @@ static void sn_check_intr(int irq, struct sn_irq_info *sn_irq_info)
        struct pcidev_info *pcidev_info;
        struct pcibus_info *pcibus_info;
 
+       /*
+        * Bridge types attached to TIO (anything but PIC) do not need this WAR
+        * since they do not target Shub II interrupt registers.  If that
+        * ever changes, this check needs to accomodate.
+        */
+       if (sn_irq_info->irq_bridge_type != PCIIO_ASIC_TYPE_PIC)
+               return;
+
        pcidev_info = (struct pcidev_info *)sn_irq_info->irq_pciioinfo;
        if (!pcidev_info)
                return;
@@ -377,16 +390,12 @@ static void sn_check_intr(int irq, struct sn_irq_info *sn_irq_info)
                break;
        }
        if (!test_bit(irr_bit, &irr_reg)) {
-               if (!test_bit(irq, pda->sn_soft_irr)) {
-                       if (!test_bit(irq, pda->sn_in_service_ivecs)) {
-                               regval &= 0xff;
-                               if (sn_irq_info->irq_int_bit & regval &
-                                   sn_irq_info->irq_last_intr) {
-                                       regval &=
-                                           ~(sn_irq_info->
-                                             irq_int_bit & regval);
-                                       pcibr_force_interrupt(sn_irq_info);
-                               }
+               if (!test_bit(irq, pda->sn_in_service_ivecs)) {
+                       regval &= 0xff;
+                       if (sn_irq_info->irq_int_bit & regval &
+                           sn_irq_info->irq_last_intr) {
+                               regval &= ~(sn_irq_info->irq_int_bit & regval);
+                               sn_call_force_intr_provider(sn_irq_info);
                        }
                }
        }
@@ -404,13 +413,7 @@ void sn_lb_int_war_check(void)
        rcu_read_lock();
        for (i = pda->sn_first_irq; i <= pda->sn_last_irq; i++) {
                list_for_each_entry_rcu(sn_irq_info, sn_irq_lh[i], list) {
-                       /*
-                        * Only call for PCI bridges that are fully
-                        * initialized.
-                        */
-                       if (IS_PCI_BRIDGE_ASIC(sn_irq_info->irq_bridge_type) &&
-                           (sn_irq_info->irq_bridge != NULL))
-                               sn_check_intr(i, sn_irq_info);
+                       sn_check_intr(i, sn_irq_info);
                }
        }
        rcu_read_unlock();
index 7c7fe441d62371ec513365bd89814397e0888b2e..a594aca959e6e141eb83a8769887f9199dc8b42a 100644 (file)
@@ -80,8 +80,6 @@ EXPORT_PER_CPU_SYMBOL(__sn_cnodeid_to_nasid);
 DEFINE_PER_CPU(struct nodepda_s *, __sn_nodepda);
 EXPORT_PER_CPU_SYMBOL(__sn_nodepda);
 
-partid_t sn_partid = -1;
-EXPORT_SYMBOL(sn_partid);
 char sn_system_serial_number_string[128];
 EXPORT_SYMBOL(sn_system_serial_number_string);
 u64 sn_partition_serial_number;
@@ -403,6 +401,7 @@ static void __init sn_init_pdas(char **cmdline_p)
                memset(nodepdaindr[cnode], 0, sizeof(nodepda_t));
                memset(nodepdaindr[cnode]->phys_cpuid, -1,
                    sizeof(nodepdaindr[cnode]->phys_cpuid));
+               spin_lock_init(&nodepdaindr[cnode]->ptc_lock);
        }
 
        /*
@@ -532,8 +531,8 @@ void __init sn_cpu_init(void)
         */
        {
                u64 pio1[] = {SH1_PIO_WRITE_STATUS_0, 0, SH1_PIO_WRITE_STATUS_1, 0};
-               u64 pio2[] = {SH2_PIO_WRITE_STATUS_0, SH2_PIO_WRITE_STATUS_1,
-                       SH2_PIO_WRITE_STATUS_2, SH2_PIO_WRITE_STATUS_3};
+               u64 pio2[] = {SH2_PIO_WRITE_STATUS_0, SH2_PIO_WRITE_STATUS_2,
+                       SH2_PIO_WRITE_STATUS_1, SH2_PIO_WRITE_STATUS_3};
                u64 *pio;
                pio = is_shub1() ? pio1 : pio2;
                pda->pio_write_status_addr = (volatile unsigned long *) LOCAL_MMR_ADDR(pio[slice]);
index 96cb71d156820f9b33df9a07ea5049afe3bc77b9..3fa95065a4460e618a4cb4d4e1979ed830fc6cee 100644 (file)
@@ -3,7 +3,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 2000-2004 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 2000-2005 Silicon Graphics, Inc. All rights reserved.
  */
 
 #include <asm/types.h>
@@ -11,7 +11,7 @@
 
 #define DEADLOCKBIT    SH_PIO_WRITE_STATUS_WRITE_DEADLOCK_SHFT
 #define WRITECOUNTMASK SH_PIO_WRITE_STATUS_PENDING_WRITE_COUNT_MASK
-#define ALIAS_OFFSET   (SH1_PIO_WRITE_STATUS_0_ALIAS-SH1_PIO_WRITE_STATUS_0)
+#define ALIAS_OFFSET   8
 
 
        .global sn2_ptc_deadlock_recovery_core
@@ -36,13 +36,15 @@ sn2_ptc_deadlock_recovery_core:
        extr.u  piowcphy=piowc,0,61;;   // Convert piowc to uncached physical address
        dep     piowcphy=-1,piowcphy,63,1
        movl    mask=WRITECOUNTMASK
+       mov     r8=r0
 
 1:
        add     scr2=ALIAS_OFFSET,piowc // Address of WRITE_STATUS alias register 
-       mov     scr1=7;;                // Clear DEADLOCK, WRITE_ERROR, MULTI_WRITE_ERROR
-       st8.rel [scr2]=scr1;;
+       ;;
+       ld8.acq scr1=[scr2];;
 
 5:     ld8.acq scr1=[piowc];;          // Wait for PIOs to complete.
+       hint    @pause
        and     scr2=scr1,mask;;        // mask of writecount bits
        cmp.ne  p6,p0=zeroval,scr2
 (p6)   br.cond.sptk 5b
@@ -57,6 +59,7 @@ sn2_ptc_deadlock_recovery_core:
        st8.rel [ptc0]=data0            // Write PTC0 & wait for completion.
 
 5:     ld8.acq scr1=[piowcphy];;       // Wait for PIOs to complete.
+       hint    @pause
        and     scr2=scr1,mask;;        // mask of writecount bits
        cmp.ne  p6,p0=zeroval,scr2
 (p6)   br.cond.sptk 5b;;
@@ -67,6 +70,7 @@ sn2_ptc_deadlock_recovery_core:
 (p7)   st8.rel [ptc1]=data1;;          // Now write PTC1.
 
 5:     ld8.acq scr1=[piowcphy];;       // Wait for PIOs to complete.
+       hint    @pause
        and     scr2=scr1,mask;;        // mask of writecount bits
        cmp.ne  p6,p0=zeroval,scr2
 (p6)   br.cond.sptk 5b
@@ -77,6 +81,7 @@ sn2_ptc_deadlock_recovery_core:
        srlz.i;;
        ////////////// END   PHYSICAL MODE ////////////////////
 
+(p8)   add     r8=1,r8
 (p8)   br.cond.spnt 1b;;               // Repeat if DEADLOCK occurred.
 
        br.ret.sptk     rp
index 7af05a7ac743a2416774ef75245f51b0d0b203a4..0a4ee50c302f94750f6c9f8876970e58b19d8b0e 100644 (file)
@@ -5,7 +5,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 2000-2004 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 2000-2005 Silicon Graphics, Inc. All rights reserved.
  */
 
 #include <linux/init.h>
@@ -20,6 +20,8 @@
 #include <linux/module.h>
 #include <linux/bitops.h>
 #include <linux/nodemask.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 
 #include <asm/processor.h>
 #include <asm/irq.h>
 #include <asm/sn/nodepda.h>
 #include <asm/sn/rw_mmr.h>
 
-void sn2_ptc_deadlock_recovery(volatile unsigned long *, unsigned long data0, 
-       volatile unsigned long *, unsigned long data1);
+DEFINE_PER_CPU(struct ptc_stats, ptcstats);
+DECLARE_PER_CPU(struct ptc_stats, ptcstats);
 
 static  __cacheline_aligned DEFINE_SPINLOCK(sn2_global_ptc_lock);
 
-static unsigned long sn2_ptc_deadlock_count;
+void sn2_ptc_deadlock_recovery(short *, short, int, volatile unsigned long *, unsigned long data0,
+       volatile unsigned long *, unsigned long data1);
+
+#ifdef DEBUG_PTC
+/*
+ * ptctest:
+ *
+ *     xyz - 3 digit hex number:
+ *             x - Force PTC purges to use shub:
+ *                     0 - no force
+ *                     1 - force
+ *             y - interupt enable
+ *                     0 - disable interrupts
+ *                     1 - leave interuupts enabled
+ *             z - type of lock:
+ *                     0 - global lock
+ *                     1 - node local lock
+ *                     2 - no lock
+ *
+ *     Note: on shub1, only ptctest == 0 is supported. Don't try other values!
+ */
+
+static unsigned int sn2_ptctest = 0;
+
+static int __init ptc_test(char *str)
+{
+       get_option(&str, &sn2_ptctest);
+       return 1;
+}
+__setup("ptctest=", ptc_test);
+
+static inline int ptc_lock(unsigned long *flagp)
+{
+       unsigned long opt = sn2_ptctest & 255;
+
+       switch (opt) {
+       case 0x00:
+               spin_lock_irqsave(&sn2_global_ptc_lock, *flagp);
+               break;
+       case 0x01:
+               spin_lock_irqsave(&sn_nodepda->ptc_lock, *flagp);
+               break;
+       case 0x02:
+               local_irq_save(*flagp);
+               break;
+       case 0x10:
+               spin_lock(&sn2_global_ptc_lock);
+               break;
+       case 0x11:
+               spin_lock(&sn_nodepda->ptc_lock);
+               break;
+       case 0x12:
+               break;
+       default:
+               BUG();
+       }
+       return opt;
+}
+
+static inline void ptc_unlock(unsigned long flags, int opt)
+{
+       switch (opt) {
+       case 0x00:
+               spin_unlock_irqrestore(&sn2_global_ptc_lock, flags);
+               break;
+       case 0x01:
+               spin_unlock_irqrestore(&sn_nodepda->ptc_lock, flags);
+               break;
+       case 0x02:
+               local_irq_restore(flags);
+               break;
+       case 0x10:
+               spin_unlock(&sn2_global_ptc_lock);
+               break;
+       case 0x11:
+               spin_unlock(&sn_nodepda->ptc_lock);
+               break;
+       case 0x12:
+               break;
+       default:
+               BUG();
+       }
+}
+#else
+
+#define sn2_ptctest    0
+
+static inline int ptc_lock(unsigned long *flagp)
+{
+       spin_lock_irqsave(&sn2_global_ptc_lock, *flagp);
+       return 0;
+}
+
+static inline void ptc_unlock(unsigned long flags, int opt)
+{
+       spin_unlock_irqrestore(&sn2_global_ptc_lock, flags);
+}
+#endif
+
+struct ptc_stats {
+       unsigned long ptc_l;
+       unsigned long change_rid;
+       unsigned long shub_ptc_flushes;
+       unsigned long nodes_flushed;
+       unsigned long deadlocks;
+       unsigned long lock_itc_clocks;
+       unsigned long shub_itc_clocks;
+       unsigned long shub_itc_clocks_max;
+};
 
 static inline unsigned long wait_piowc(void)
 {
@@ -89,9 +199,9 @@ void
 sn2_global_tlb_purge(unsigned long start, unsigned long end,
                     unsigned long nbits)
 {
-       int i, shub1, cnode, mynasid, cpu, lcpu = 0, nasid, flushed = 0;
+       int i, opt, shub1, cnode, mynasid, cpu, lcpu = 0, nasid, flushed = 0;
        volatile unsigned long *ptc0, *ptc1;
-       unsigned long flags = 0, data0 = 0, data1 = 0;
+       unsigned long itc, itc2, flags, data0 = 0, data1 = 0;
        struct mm_struct *mm = current->active_mm;
        short nasids[MAX_NUMNODES], nix;
        nodemask_t nodes_flushed;
@@ -114,16 +224,19 @@ sn2_global_tlb_purge(unsigned long start, unsigned long end,
                        start += (1UL << nbits);
                } while (start < end);
                ia64_srlz_i();
+               __get_cpu_var(ptcstats).ptc_l++;
                preempt_enable();
                return;
        }
 
        if (atomic_read(&mm->mm_users) == 1) {
                flush_tlb_mm(mm);
+               __get_cpu_var(ptcstats).change_rid++;
                preempt_enable();
                return;
        }
 
+       itc = ia64_get_itc();
        nix = 0;
        for_each_node_mask(cnode, nodes_flushed)
                nasids[nix++] = cnodeid_to_nasid(cnode);
@@ -148,7 +261,12 @@ sn2_global_tlb_purge(unsigned long start, unsigned long end,
 
        mynasid = get_nasid();
 
-       spin_lock_irqsave(&sn2_global_ptc_lock, flags);
+       itc = ia64_get_itc();
+       opt = ptc_lock(&flags);
+       itc2 = ia64_get_itc();
+       __get_cpu_var(ptcstats).lock_itc_clocks += itc2 - itc;
+       __get_cpu_var(ptcstats).shub_ptc_flushes++;
+       __get_cpu_var(ptcstats).nodes_flushed += nix;
 
        do {
                if (shub1)
@@ -157,7 +275,7 @@ sn2_global_tlb_purge(unsigned long start, unsigned long end,
                        data0 = (data0 & ~SH2_PTC_ADDR_MASK) | (start & SH2_PTC_ADDR_MASK);
                for (i = 0; i < nix; i++) {
                        nasid = nasids[i];
-                       if (unlikely(nasid == mynasid)) {
+                       if ((!(sn2_ptctest & 3)) && unlikely(nasid == mynasid)) {
                                ia64_ptcga(start, nbits << 2);
                                ia64_srlz_i();
                        } else {
@@ -169,18 +287,22 @@ sn2_global_tlb_purge(unsigned long start, unsigned long end,
                                flushed = 1;
                        }
                }
-
                if (flushed
                    && (wait_piowc() &
-                       SH_PIO_WRITE_STATUS_WRITE_DEADLOCK_MASK)) {
-                       sn2_ptc_deadlock_recovery(ptc0, data0, ptc1, data1);
+                               (SH_PIO_WRITE_STATUS_WRITE_DEADLOCK_MASK))) {
+                       sn2_ptc_deadlock_recovery(nasids, nix, mynasid, ptc0, data0, ptc1, data1);
                }
 
                start += (1UL << nbits);
 
        } while (start < end);
 
-       spin_unlock_irqrestore(&sn2_global_ptc_lock, flags);
+       itc2 = ia64_get_itc() - itc2;
+       __get_cpu_var(ptcstats).shub_itc_clocks += itc2;
+       if (itc2 > __get_cpu_var(ptcstats).shub_itc_clocks_max)
+               __get_cpu_var(ptcstats).shub_itc_clocks_max = itc2;
+
+       ptc_unlock(flags, opt);
 
        preempt_enable();
 }
@@ -192,31 +314,29 @@ sn2_global_tlb_purge(unsigned long start, unsigned long end,
  * TLB flush transaction.  The recovery sequence is somewhat tricky & is
  * coded in assembly language.
  */
-void sn2_ptc_deadlock_recovery(volatile unsigned long *ptc0, unsigned long data0,
+void sn2_ptc_deadlock_recovery(short *nasids, short nix, int mynasid, volatile unsigned long *ptc0, unsigned long data0,
        volatile unsigned long *ptc1, unsigned long data1)
 {
        extern void sn2_ptc_deadlock_recovery_core(volatile unsigned long *, unsigned long,
                volatile unsigned long *, unsigned long, volatile unsigned long *, unsigned long);
-       int cnode, mycnode, nasid;
-       volatile unsigned long *piows;
-       volatile unsigned long zeroval;
+       short nasid, i;
+       unsigned long *piows, zeroval;
 
-       sn2_ptc_deadlock_count++;
+       __get_cpu_var(ptcstats).deadlocks++;
 
-       piows = pda->pio_write_status_addr;
+       piows = (unsigned long *) pda->pio_write_status_addr;
        zeroval = pda->pio_write_status_val;
 
-       mycnode = numa_node_id();
-
-       for_each_online_node(cnode) {
-               if (is_headless_node(cnode) || cnode == mycnode)
+       for (i=0; i < nix; i++) {
+               nasid = nasids[i];
+               if (!(sn2_ptctest & 3) && nasid == mynasid)
                        continue;
-               nasid = cnodeid_to_nasid(cnode);
                ptc0 = CHANGE_NASID(nasid, ptc0);
                if (ptc1)
                        ptc1 = CHANGE_NASID(nasid, ptc1);
                sn2_ptc_deadlock_recovery_core(ptc0, data0, ptc1, data1, piows, zeroval);
        }
+
 }
 
 /**
@@ -293,3 +413,93 @@ void sn2_send_IPI(int cpuid, int vector, int delivery_mode, int redirect)
 
        sn_send_IPI_phys(nasid, physid, vector, delivery_mode);
 }
+
+#ifdef CONFIG_PROC_FS
+
+#define PTC_BASENAME   "sgi_sn/ptc_statistics"
+
+static void *sn2_ptc_seq_start(struct seq_file *file, loff_t * offset)
+{
+       if (*offset < NR_CPUS)
+               return offset;
+       return NULL;
+}
+
+static void *sn2_ptc_seq_next(struct seq_file *file, void *data, loff_t * offset)
+{
+       (*offset)++;
+       if (*offset < NR_CPUS)
+               return offset;
+       return NULL;
+}
+
+static void sn2_ptc_seq_stop(struct seq_file *file, void *data)
+{
+}
+
+static int sn2_ptc_seq_show(struct seq_file *file, void *data)
+{
+       struct ptc_stats *stat;
+       int cpu;
+
+       cpu = *(loff_t *) data;
+
+       if (!cpu) {
+               seq_printf(file, "# ptc_l change_rid shub_ptc_flushes shub_nodes_flushed deadlocks lock_nsec shub_nsec shub_nsec_max\n");
+               seq_printf(file, "# ptctest %d\n", sn2_ptctest);
+       }
+
+       if (cpu < NR_CPUS && cpu_online(cpu)) {
+               stat = &per_cpu(ptcstats, cpu);
+               seq_printf(file, "cpu %d %ld %ld %ld %ld %ld %ld %ld %ld\n", cpu, stat->ptc_l,
+                               stat->change_rid, stat->shub_ptc_flushes, stat->nodes_flushed,
+                               stat->deadlocks,
+                               1000 * stat->lock_itc_clocks / per_cpu(cpu_info, cpu).cyc_per_usec,
+                               1000 * stat->shub_itc_clocks / per_cpu(cpu_info, cpu).cyc_per_usec,
+                               1000 * stat->shub_itc_clocks_max / per_cpu(cpu_info, cpu).cyc_per_usec);
+       }
+
+       return 0;
+}
+
+static struct seq_operations sn2_ptc_seq_ops = {
+       .start = sn2_ptc_seq_start,
+       .next = sn2_ptc_seq_next,
+       .stop = sn2_ptc_seq_stop,
+       .show = sn2_ptc_seq_show
+};
+
+int sn2_ptc_proc_open(struct inode *inode, struct file *file)
+{
+       return seq_open(file, &sn2_ptc_seq_ops);
+}
+
+static struct file_operations proc_sn2_ptc_operations = {
+       .open = sn2_ptc_proc_open,
+       .read = seq_read,
+       .llseek = seq_lseek,
+       .release = seq_release,
+};
+
+static struct proc_dir_entry *proc_sn2_ptc;
+
+static int __init sn2_ptc_init(void)
+{
+       if (!(proc_sn2_ptc = create_proc_entry(PTC_BASENAME, 0444, NULL))) {
+               printk(KERN_ERR "unable to create %s proc entry", PTC_BASENAME);
+               return -EINVAL;
+       }
+       proc_sn2_ptc->proc_fops = &proc_sn2_ptc_operations;
+       spin_lock_init(&sn2_global_ptc_lock);
+       return 0;
+}
+
+static void __exit sn2_ptc_exit(void)
+{
+       remove_proc_entry(PTC_BASENAME, NULL);
+}
+
+module_init(sn2_ptc_init);
+module_exit(sn2_ptc_exit);
+#endif /* CONFIG_PROC_FS */
+
index 833e700fdac93e4ada8c663c8c182b4d899cf05b..0513aacac8c13898a8e7edf57cfe9530b13e553d 100644 (file)
@@ -36,7 +36,6 @@
 #include <asm/topology.h>
 #include <asm/smp.h>
 #include <asm/semaphore.h>
-#include <asm/segment.h>
 #include <asm/uaccess.h>
 #include <asm/sal.h>
 #include <asm/sn/io.h>
@@ -59,7 +58,7 @@ static int sn_hwperf_enum_objects(int *nobj, struct sn_hwperf_object_info **ret)
        struct sn_hwperf_object_info *objbuf = NULL;
 
        if ((e = sn_hwperf_init()) < 0) {
-               printk("sn_hwperf_init failed: err %d\n", e);
+               printk(KERN_ERR "sn_hwperf_init failed: err %d\n", e);
                goto out;
        }
 
@@ -111,7 +110,7 @@ static int sn_hwperf_geoid_to_cnode(char *location)
        if (sn_hwperf_location_to_bpos(location, &rack, &bay, &slot, &slab))
                return -1;
 
-       for (cnode = 0; cnode < numionodes; cnode++) {
+       for_each_node(cnode) {
                geoid = cnodeid_get_geoid(cnode);
                module_id = geo_module(geoid);
                this_rack = MODULE_GET_RACK(module_id);
@@ -124,11 +123,13 @@ static int sn_hwperf_geoid_to_cnode(char *location)
                }
        }
 
-       return cnode < numionodes ? cnode : -1;
+       return node_possible(cnode) ? cnode : -1;
 }
 
 static int sn_hwperf_obj_to_cnode(struct sn_hwperf_object_info * obj)
 {
+       if (!SN_HWPERF_IS_NODE(obj) && !SN_HWPERF_IS_IONODE(obj))
+               BUG();
        if (!obj->sn_hwp_this_part)
                return -1;
        return sn_hwperf_geoid_to_cnode(obj->location);
@@ -174,31 +175,199 @@ static const char *sn_hwperf_get_slabname(struct sn_hwperf_object_info *obj,
        return slabname;
 }
 
-static void print_pci_topology(struct seq_file *s,
-       struct sn_hwperf_object_info *obj, int *ordinal,
-       u64 rack, u64 bay, u64 slot, u64 slab)
+static void print_pci_topology(struct seq_file *s)
+{
+       char *p;
+       size_t sz;
+       int e;
+
+       for (sz = PAGE_SIZE; sz < 16 * PAGE_SIZE; sz += PAGE_SIZE) {
+               if (!(p = (char *)kmalloc(sz, GFP_KERNEL)))
+                       break;
+               e = ia64_sn_ioif_get_pci_topology(__pa(p), sz);
+               if (e == SALRET_OK)
+                       seq_puts(s, p);
+               kfree(p);
+               if (e == SALRET_OK || e == SALRET_NOT_IMPLEMENTED)
+                       break;
+       }
+}
+
+static inline int sn_hwperf_has_cpus(cnodeid_t node)
+{
+       return node_online(node) && nr_cpus_node(node);
+}
+
+static inline int sn_hwperf_has_mem(cnodeid_t node)
+{
+       return node_online(node) && NODE_DATA(node)->node_present_pages;
+}
+
+static struct sn_hwperf_object_info *
+sn_hwperf_findobj_id(struct sn_hwperf_object_info *objbuf,
+       int nobj, int id)
 {
-       char *p1;
-       char *p2;
-       char *pg;
-
-       if (!(pg = (char *)get_zeroed_page(GFP_KERNEL)))
-               return; /* ignore */
-       if (ia64_sn_ioif_get_pci_topology(rack, bay, slot, slab,
-               __pa(pg), PAGE_SIZE) == SN_HWPERF_OP_OK) {
-               for (p1=pg; *p1 && p1 < pg + PAGE_SIZE;) {
-                       if (!(p2 = strchr(p1, '\n')))
+       int i;
+       struct sn_hwperf_object_info *p = objbuf;
+
+       for (i=0; i < nobj; i++, p++) {
+               if (p->id == id)
+                       return p;
+       }
+
+       return NULL;
+
+}
+
+static int sn_hwperf_get_nearest_node_objdata(struct sn_hwperf_object_info *objbuf,
+       int nobj, cnodeid_t node, cnodeid_t *near_mem_node, cnodeid_t *near_cpu_node)
+{
+       int e;
+       struct sn_hwperf_object_info *nodeobj = NULL;
+       struct sn_hwperf_object_info *op;
+       struct sn_hwperf_object_info *dest;
+       struct sn_hwperf_object_info *router;
+       struct sn_hwperf_port_info ptdata[16];
+       int sz, i, j;
+       cnodeid_t c;
+       int found_mem = 0;
+       int found_cpu = 0;
+
+       if (!node_possible(node))
+               return -EINVAL;
+
+       if (sn_hwperf_has_cpus(node)) {
+               if (near_cpu_node)
+                       *near_cpu_node = node;
+               found_cpu++;
+       }
+
+       if (sn_hwperf_has_mem(node)) {
+               if (near_mem_node)
+                       *near_mem_node = node;
+               found_mem++;
+       }
+
+       if (found_cpu && found_mem)
+               return 0; /* trivially successful */
+
+       /* find the argument node object */
+       for (i=0, op=objbuf; i < nobj; i++, op++) {
+               if (!SN_HWPERF_IS_NODE(op) && !SN_HWPERF_IS_IONODE(op))
+                       continue;
+               if (node == sn_hwperf_obj_to_cnode(op)) {
+                       nodeobj = op;
+                       break;
+               }
+       }
+       if (!nodeobj) {
+               e = -ENOENT;
+               goto err;
+       }
+
+       /* get it's interconnect topology */
+       sz = op->ports * sizeof(struct sn_hwperf_port_info);
+       if (sz > sizeof(ptdata))
+               BUG();
+       e = ia64_sn_hwperf_op(sn_hwperf_master_nasid,
+                             SN_HWPERF_ENUM_PORTS, nodeobj->id, sz,
+                             (u64)&ptdata, 0, 0, NULL);
+       if (e != SN_HWPERF_OP_OK) {
+               e = -EINVAL;
+               goto err;
+       }
+
+       /* find nearest node with cpus and nearest memory */
+       for (router=NULL, j=0; j < op->ports; j++) {
+               dest = sn_hwperf_findobj_id(objbuf, nobj, ptdata[j].conn_id);
+               if (!dest || SN_HWPERF_FOREIGN(dest) ||
+                   !SN_HWPERF_IS_NODE(dest) || SN_HWPERF_IS_IONODE(dest)) {
+                       continue;
+               }
+               c = sn_hwperf_obj_to_cnode(dest);
+               if (!found_cpu && sn_hwperf_has_cpus(c)) {
+                       if (near_cpu_node)
+                               *near_cpu_node = c;
+                       found_cpu++;
+               }
+               if (!found_mem && sn_hwperf_has_mem(c)) {
+                       if (near_mem_node)
+                               *near_mem_node = c;
+                       found_mem++;
+               }
+               if (SN_HWPERF_IS_ROUTER(dest))
+                       router = dest;
+       }
+
+       if (router && (!found_cpu || !found_mem)) {
+               /* search for a node connected to the same router */
+               sz = router->ports * sizeof(struct sn_hwperf_port_info);
+               if (sz > sizeof(ptdata))
+                       BUG();
+               e = ia64_sn_hwperf_op(sn_hwperf_master_nasid,
+                                     SN_HWPERF_ENUM_PORTS, router->id, sz,
+                                     (u64)&ptdata, 0, 0, NULL);
+               if (e != SN_HWPERF_OP_OK) {
+                       e = -EINVAL;
+                       goto err;
+               }
+               for (j=0; j < router->ports; j++) {
+                       dest = sn_hwperf_findobj_id(objbuf, nobj,
+                               ptdata[j].conn_id);
+                       if (!dest || dest->id == node ||
+                           SN_HWPERF_FOREIGN(dest) ||
+                           !SN_HWPERF_IS_NODE(dest) ||
+                           SN_HWPERF_IS_IONODE(dest)) {
+                               continue;
+                       }
+                       c = sn_hwperf_obj_to_cnode(dest);
+                       if (!found_cpu && sn_hwperf_has_cpus(c)) {
+                               if (near_cpu_node)
+                                       *near_cpu_node = c;
+                               found_cpu++;
+                       }
+                       if (!found_mem && sn_hwperf_has_mem(c)) {
+                               if (near_mem_node)
+                                       *near_mem_node = c;
+                               found_mem++;
+                       }
+                       if (found_cpu && found_mem)
+                               break;
+               }
+       }
+
+       if (!found_cpu || !found_mem) {
+               /* resort to _any_ node with CPUs and memory */
+               for (i=0, op=objbuf; i < nobj; i++, op++) {
+                       if (SN_HWPERF_FOREIGN(op) ||
+                           SN_HWPERF_IS_IONODE(op) ||
+                           !SN_HWPERF_IS_NODE(op)) {
+                               continue;
+                       }
+                       c = sn_hwperf_obj_to_cnode(op);
+                       if (!found_cpu && sn_hwperf_has_cpus(c)) {
+                               if (near_cpu_node)
+                                       *near_cpu_node = c;
+                               found_cpu++;
+                       }
+                       if (!found_mem && sn_hwperf_has_mem(c)) {
+                               if (near_mem_node)
+                                       *near_mem_node = c;
+                               found_mem++;
+                       }
+                       if (found_cpu && found_mem)
                                break;
-                       *p2 = '\0';
-                       seq_printf(s, "pcibus %d %s-%s\n",
-                               *ordinal, obj->location, p1);
-                       (*ordinal)++;
-                       p1 = p2 + 1;
                }
        }
-       free_page((unsigned long)pg);
+
+       if (!found_cpu || !found_mem)
+               e = -ENODATA;
+
+err:
+       return e;
 }
 
+
 static int sn_topology_show(struct seq_file *s, void *d)
 {
        int sz;
@@ -215,7 +384,6 @@ static int sn_topology_show(struct seq_file *s, void *d)
        struct sn_hwperf_object_info *p;
        struct sn_hwperf_object_info *obj = d;  /* this object */
        struct sn_hwperf_object_info *objs = s->private; /* all objects */
-       int rack, bay, slot, slab;
        u8 shubtype;
        u8 system_size;
        u8 sharing_size;
@@ -225,7 +393,6 @@ static int sn_topology_show(struct seq_file *s, void *d)
        u8 region_size;
        u16 nasid_mask;
        int nasid_msb;
-       int pci_bus_ordinal = 0;
 
        if (obj == objs) {
                seq_printf(s, "# sn_topology version 2\n");
@@ -253,6 +420,8 @@ static int sn_topology_show(struct seq_file *s, void *d)
                        shubtype ? "shub2" : "shub1", 
                        (u64)nasid_mask << nasid_shift, nasid_msb, nasid_shift,
                        system_size, sharing_size, coher, region_size);
+
+               print_pci_topology(s);
        }
 
        if (SN_HWPERF_FOREIGN(obj)) {
@@ -272,11 +441,24 @@ static int sn_topology_show(struct seq_file *s, void *d)
        if (!SN_HWPERF_IS_NODE(obj) && !SN_HWPERF_IS_IONODE(obj))
                seq_putc(s, '\n');
        else {
+               cnodeid_t near_mem = -1;
+               cnodeid_t near_cpu = -1;
+
                seq_printf(s, ", nasid 0x%x", cnodeid_to_nasid(ordinal));
-               for (i=0; i < numionodes; i++) {
-                       seq_printf(s, i ? ":%d" : ", dist %d",
-                               node_distance(ordinal, i));
+
+               if (sn_hwperf_get_nearest_node_objdata(objs, sn_hwperf_obj_cnt,
+                       ordinal, &near_mem, &near_cpu) == 0) {
+                       seq_printf(s, ", near_mem_nodeid %d, near_cpu_nodeid %d",
+                               near_mem, near_cpu);
+               }
+
+               if (!SN_HWPERF_IS_IONODE(obj)) {
+                       for_each_online_node(i) {
+                               seq_printf(s, i ? ":%d" : ", dist %d",
+                                       node_distance(ordinal, i));
+                       }
                }
+
                seq_putc(s, '\n');
 
                /*
@@ -300,17 +482,6 @@ static int sn_topology_show(struct seq_file *s, void *d)
                                seq_putc(s, '\n');
                        }
                }
-
-               /*
-                * PCI busses attached to this node, if any
-                */
-               if (sn_hwperf_location_to_bpos(obj->location,
-                       &rack, &bay, &slot, &slab)) {
-                       /* export pci bus info */
-                       print_pci_topology(s, obj, &pci_bus_ordinal,
-                               rack, bay, slot, slab);
-
-               }
        }
 
        if (obj->ports) {
@@ -572,6 +743,8 @@ sn_hwperf_ioctl(struct inode *in, struct file *fp, u32 op, u64 arg)
                if ((r = sn_hwperf_enum_objects(&nobj, &objs)) == 0) {
                        memset(p, 0, a.sz);
                        for (i = 0; i < nobj; i++) {
+                               if (!SN_HWPERF_IS_NODE(objs + i))
+                                       continue;
                                node = sn_hwperf_obj_to_cnode(objs + i);
                                for_each_online_cpu(j) {
                                        if (node != cpu_to_node(j))
@@ -598,7 +771,7 @@ sn_hwperf_ioctl(struct inode *in, struct file *fp, u32 op, u64 arg)
 
        case SN_HWPERF_GET_NODE_NASID:
                if (a.sz != sizeof(u64) ||
-                  (node = a.arg) < 0 || node >= numionodes) {
+                  (node = a.arg) < 0 || !node_possible(node)) {
                        r = -EINVAL;
                        goto error;
                }
@@ -627,6 +800,14 @@ sn_hwperf_ioctl(struct inode *in, struct file *fp, u32 op, u64 arg)
                                vfree(objs);
                                goto error;
                        }
+
+                       if (!SN_HWPERF_IS_NODE(objs + i) &&
+                           !SN_HWPERF_IS_IONODE(objs + i)) {
+                               r = -ENOENT;
+                               vfree(objs);
+                               goto error;
+                       }
+
                        *(u64 *)p = (u64)sn_hwperf_obj_to_cnode(objs + i);
                        vfree(objs);
                }
@@ -692,6 +873,7 @@ static int sn_hwperf_init(void)
 
        /* single threaded, once-only initialization */
        down(&sn_hwperf_init_mutex);
+
        if (sn_hwperf_salheap) {
                up(&sn_hwperf_init_mutex);
                return e;
@@ -742,19 +924,6 @@ out:
                sn_hwperf_salheap = NULL;
                sn_hwperf_obj_cnt = 0;
        }
-
-       if (!e) {
-               /*
-                * Register a dynamic misc device for ioctl. Platforms
-                * supporting hotplug will create /dev/sn_hwperf, else
-                * user can to look up the minor number in /proc/misc.
-                */
-               if ((e = misc_register(&sn_hwperf_dev)) != 0) {
-                       printk(KERN_ERR "sn_hwperf_init: misc register "
-                              "for \"sn_hwperf\" failed, err %d\n", e);
-               }
-       }
-
        up(&sn_hwperf_init_mutex);
        return e;
 }
@@ -782,3 +951,41 @@ int sn_topology_release(struct inode *inode, struct file *file)
        vfree(seq->private);
        return seq_release(inode, file);
 }
+
+int sn_hwperf_get_nearest_node(cnodeid_t node,
+       cnodeid_t *near_mem_node, cnodeid_t *near_cpu_node)
+{
+       int e;
+       int nobj;
+       struct sn_hwperf_object_info *objbuf;
+
+       if ((e = sn_hwperf_enum_objects(&nobj, &objbuf)) == 0) {
+               e = sn_hwperf_get_nearest_node_objdata(objbuf, nobj,
+                       node, near_mem_node, near_cpu_node);
+               vfree(objbuf);
+       }
+
+       return e;
+}
+
+static int __devinit sn_hwperf_misc_register_init(void)
+{
+       int e;
+
+       sn_hwperf_init();
+
+       /*
+        * Register a dynamic misc device for hwperf ioctls. Platforms
+        * supporting hotplug will create /dev/sn_hwperf, else user
+        * can to look up the minor number in /proc/misc.
+        */
+       if ((e = misc_register(&sn_hwperf_dev)) != 0) {
+               printk(KERN_ERR "sn_hwperf_misc_register_init: failed to "
+               "register misc device for \"%s\"\n", sn_hwperf_dev.name);
+       }
+
+       return e;
+}
+
+device_initcall(sn_hwperf_misc_register_init); /* after misc_init() */
+EXPORT_SYMBOL(sn_hwperf_get_nearest_node);
index 6a80fca807b9c59119ca08367da12e1d7ceca651..51bf82720d994188faf55a74b68888908f78c3e1 100644 (file)
@@ -3,7 +3,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 2000-2004 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 2000-2005 Silicon Graphics, Inc. All rights reserved.
  */
 #include <linux/config.h>
 #include <asm/uaccess.h>
@@ -15,7 +15,7 @@
 
 static int partition_id_show(struct seq_file *s, void *p)
 {
-       seq_printf(s, "%d\n", sn_local_partid());
+       seq_printf(s, "%d\n", sn_partition_id);
        return 0;
 }
 
index cde7375390b0db4e4160ffaaf44d6bc44dfb0763..adf5db2e2afeb4e2742457b40c062e0546e42972 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *
  *
- * Copyright (c) 2003 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2005 Silicon Graphics, Inc.  All Rights Reserved.
  * 
  * This program is free software; you can redistribute it and/or modify it 
  * under the terms of version 2 of the GNU General Public License 
@@ -50,14 +50,16 @@ void sn_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
                             LED_CPU_HEARTBEAT, LED_CPU_HEARTBEAT);
        }
 
-       if (enable_shub_wars_1_1()) {
-               /* Bugfix code for SHUB 1.1 */
-               if (pda->pio_shub_war_cam_addr)
-                       *pda->pio_shub_war_cam_addr = 0x8000000000000010UL;
+       if (is_shub1()) {
+               if (enable_shub_wars_1_1()) {
+                       /* Bugfix code for SHUB 1.1 */
+                       if (pda->pio_shub_war_cam_addr)
+                               *pda->pio_shub_war_cam_addr = 0x8000000000000010UL;
+               }
+               if (pda->sn_lb_int_war_ticks == 0)
+                       sn_lb_int_war_check();
+               pda->sn_lb_int_war_ticks++;
+               if (pda->sn_lb_int_war_ticks >= SN_LB_INT_WAR_INTERVAL)
+                       pda->sn_lb_int_war_ticks = 0;
        }
-       if (pda->sn_lb_int_war_ticks == 0)
-               sn_lb_int_war_check();
-       pda->sn_lb_int_war_ticks++;
-       if (pda->sn_lb_int_war_ticks >= SN_LB_INT_WAR_INTERVAL)
-               pda->sn_lb_int_war_ticks = 0;
 }
index 2f915bce25f9e6734040ccb0611b2236acac12ee..321576b1b425f8916858c875058326148216fa8f 100644 (file)
@@ -7,4 +7,4 @@
 #
 # Makefile for the sn pci general routines.
 
-obj-y := pci_dma.o tioca_provider.o pcibr/ 
+obj-y := pci_dma.o tioca_provider.o tioce_provider.o pcibr/
index b058dc2a0b9d3dfb7a17fe73f2ae35f72266ebd3..34093476e9652fc03938edeadeddb4596d439d34 100644 (file)
@@ -3,7 +3,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 2001-2004 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 2001-2005 Silicon Graphics, Inc. All rights reserved.
  */
 
 #include <linux/types.h>
@@ -215,8 +215,8 @@ void sn_dma_flush(uint64_t addr)
        int is_tio;
        int wid_num;
        int i, j;
-       int bwin;
        uint64_t flags;
+       uint64_t itte;
        struct hubdev_info *hubinfo;
        volatile struct sn_flush_device_list *p;
        struct sn_flush_nasid_entry *flush_nasid_list;
@@ -233,31 +233,36 @@ void sn_dma_flush(uint64_t addr)
        if (!hubinfo) {
                BUG();
        }
-       is_tio = (nasid & 1);
-       if (is_tio) {
-               wid_num = TIO_SWIN_WIDGETNUM(addr);
-               bwin = TIO_BWIN_WINDOWNUM(addr);
-       } else {
-               wid_num = SWIN_WIDGETNUM(addr);
-               bwin = BWIN_WINDOWNUM(addr);
-       }
 
        flush_nasid_list = &hubinfo->hdi_flush_nasid_list;
        if (flush_nasid_list->widget_p == NULL)
                return;
-       if (bwin > 0) {
-               uint64_t itte = flush_nasid_list->iio_itte[bwin];
 
-               if (is_tio) {
-                       wid_num = (itte >> TIO_ITTE_WIDGET_SHIFT) &
-                           TIO_ITTE_WIDGET_MASK;
-               } else {
-                       wid_num = (itte >> IIO_ITTE_WIDGET_SHIFT) &
-                           IIO_ITTE_WIDGET_MASK;
-               }
+       is_tio = (nasid & 1);
+       if (is_tio) {
+               int itte_index;
+
+               if (TIO_HWIN(addr))
+                       itte_index = 0;
+               else if (TIO_BWIN_WINDOWNUM(addr))
+                       itte_index = TIO_BWIN_WINDOWNUM(addr);
+               else
+                       itte_index = -1;
+
+               if (itte_index >= 0) {
+                       itte = flush_nasid_list->iio_itte[itte_index];
+                       if (! TIO_ITTE_VALID(itte))
+                               return;
+                       wid_num = TIO_ITTE_WIDGET(itte);
+               } else
+                       wid_num = TIO_SWIN_WIDGETNUM(addr);
+       } else {
+               if (BWIN_WINDOWNUM(addr)) {
+                       itte = flush_nasid_list->iio_itte[BWIN_WINDOWNUM(addr)];
+                       wid_num = IIO_ITTE_WIDGET(itte);
+               } else
+                       wid_num = SWIN_WIDGETNUM(addr);
        }
-       if (flush_nasid_list->widget_p == NULL)
-               return;
        if (flush_nasid_list->widget_p[wid_num] == NULL)
                return;
        p = &flush_nasid_list->widget_p[wid_num][0];
@@ -283,10 +288,16 @@ void sn_dma_flush(uint64_t addr)
        /*
         * For TIOCP use the Device(x) Write Request Buffer Flush Bridge
         * register since it ensures the data has entered the coherence
-        * domain, unlike PIC
+        * domain, unlike PIC.
         */
        if (is_tio) {
-               uint32_t tio_id = REMOTE_HUB_L(nasid, TIO_NODE_ID);
+               /*
+                * Note:  devices behind TIOCE should never be matched in the
+                * above code, and so the following code is PIC/CP centric.
+                * If CE ever needs the sn_dma_flush mechanism, we will have
+                * to account for that here and in tioce_bus_fixup().
+                */
+               uint32_t tio_id = HUB_L(TIO_IOSPACE_ADDR(nasid, TIO_NODE_ID));
                uint32_t revnum = XWIDGET_PART_REV_NUM(tio_id);
 
                /* TIOCP BRINGUP WAR (PV907516): Don't write buffer flush reg */
@@ -306,7 +317,8 @@ void sn_dma_flush(uint64_t addr)
                *(volatile uint32_t *)(p->sfdl_force_int_addr) = 1;
 
                /* wait for the interrupt to come back. */
-               while (*(p->sfdl_flush_addr) != 0x10f) ;
+               while (*(p->sfdl_flush_addr) != 0x10f)
+                       cpu_relax();
 
                /* okay, everything is synched up. */
                spin_unlock_irqrestore((spinlock_t *)&p->sfdl_flush_lock, flags);
index b95e928636a1bb6c4417e23381b9bfd27992c6fc..7b03b8084ffc441d90d3725e601816f6b856d741 100644 (file)
@@ -15,6 +15,7 @@
 #include <asm/sn/pcibus_provider_defs.h>
 #include <asm/sn/pcidev.h>
 #include <asm/sn/sn_sal.h>
+#include <asm/sn/sn2/sn_hwperf.h>
 #include "xtalk/xwidgetdev.h"
 #include "xtalk/hubdev.h"
 
@@ -60,7 +61,7 @@ static int sal_pcibr_error_interrupt(struct pcibus_info *soft)
        ret_stuff.status = 0;
        ret_stuff.v0 = 0;
 
-       segment = 0;
+       segment = soft->pbi_buscommon.bs_persist_segment;
        busnum = soft->pbi_buscommon.bs_persist_busnum;
        SAL_CALL_NOLOCK(ret_stuff,
                        (u64) SN_SAL_IOIF_ERROR_INTERRUPT,
@@ -88,6 +89,7 @@ void *
 pcibr_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *controller)
 {
        int nasid, cnode, j;
+       cnodeid_t near_cnode;
        struct hubdev_info *hubdev_info;
        struct pcibus_info *soft;
        struct sn_flush_device_list *sn_flush_device_list;
@@ -115,7 +117,7 @@ pcibr_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *cont
        /*
         * register the bridge's error interrupt handler
         */
-       if (request_irq(SGI_PCIBR_ERROR, (void *)pcibr_error_intr_handler,
+       if (request_irq(SGI_PCIASIC_ERROR, (void *)pcibr_error_intr_handler,
                        SA_SHIRQ, "PCIBR error", (void *)(soft))) {
                printk(KERN_WARNING
                       "pcibr cannot allocate interrupt for error handler\n");
@@ -142,9 +144,12 @@ pcibr_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *cont
                             j++, sn_flush_device_list++) {
                                if (sn_flush_device_list->sfdl_slot == -1)
                                        continue;
-                               if (sn_flush_device_list->
-                                   sfdl_persistent_busnum ==
-                                   soft->pbi_buscommon.bs_persist_busnum)
+                               if ((sn_flush_device_list->
+                                    sfdl_persistent_segment ==
+                                    soft->pbi_buscommon.bs_persist_segment) &&
+                                    (sn_flush_device_list->
+                                    sfdl_persistent_busnum ==
+                                    soft->pbi_buscommon.bs_persist_busnum))
                                        sn_flush_device_list->sfdl_pcibus_info =
                                            soft;
                        }
@@ -158,12 +163,18 @@ pcibr_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *cont
        memset(soft->pbi_int_ate_resource.ate, 0,
               (soft->pbi_int_ate_size * sizeof(uint64_t)));
 
-       if (prom_bussoft->bs_asic_type == PCIIO_ASIC_TYPE_TIOCP)
-               /*
-                * TIO PCI Bridge with no closest node information.
-                * FIXME: Find another way to determine the closest node
-                */
-               controller->node = -1;
+       if (prom_bussoft->bs_asic_type == PCIIO_ASIC_TYPE_TIOCP) {
+               /* TIO PCI Bridge: find nearest node with CPUs */
+               int e = sn_hwperf_get_nearest_node(cnode, NULL, &near_cnode);
+
+               if (e < 0) {
+                       near_cnode = (cnodeid_t)-1; /* use any node */
+                       printk(KERN_WARNING "pcibr_bus_fixup: failed to find "
+                               "near node with CPUs to TIO node %d, err=%d\n",
+                               cnode, e);
+               }
+               controller->node = near_cnode;
+       }
        else
                controller->node = cnode;
        return soft;
@@ -175,6 +186,9 @@ void pcibr_force_interrupt(struct sn_irq_info *sn_irq_info)
        struct pcibus_info *pcibus_info;
        int bit = sn_irq_info->irq_int_bit;
 
+       if (! sn_irq_info->irq_bridge)
+               return;
+
        pcidev_info = (struct pcidev_info *)sn_irq_info->irq_pciioinfo;
        if (pcidev_info) {
                pcibus_info =
@@ -184,7 +198,7 @@ void pcibr_force_interrupt(struct sn_irq_info *sn_irq_info)
        }
 }
 
-void pcibr_change_devices_irq(struct sn_irq_info *sn_irq_info)
+void pcibr_target_interrupt(struct sn_irq_info *sn_irq_info)
 {
        struct pcidev_info *pcidev_info;
        struct pcibus_info *pcibus_info;
@@ -219,6 +233,8 @@ struct sn_pcibus_provider pcibr_provider = {
        .dma_map_consistent = pcibr_dma_map_consistent,
        .dma_unmap = pcibr_dma_unmap,
        .bus_fixup = pcibr_bus_fixup,
+       .force_interrupt = pcibr_force_interrupt,
+       .target_interrupt = pcibr_target_interrupt
 };
 
 int
index 5d76a758146597d45d822474789223db97dcb4bc..ea09c12f02586de9d6bc49507951fb919420ea70 100644 (file)
@@ -559,7 +559,7 @@ tioca_error_intr_handler(int irq, void *arg, struct pt_regs *pt)
        ret_stuff.status = 0;
        ret_stuff.v0 = 0;
 
-       segment = 0;
+       segment = soft->ca_common.bs_persist_segment;
        busnum = soft->ca_common.bs_persist_busnum;
 
        SAL_CALL_NOLOCK(ret_stuff,
@@ -622,7 +622,8 @@ tioca_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *cont
            nasid_to_cnodeid(tioca_common->ca_closest_nasid);
        tioca_common->ca_kernel_private = (uint64_t) tioca_kern;
 
-       bus = pci_find_bus(0, tioca_common->ca_common.bs_persist_busnum);
+       bus = pci_find_bus(tioca_common->ca_common.bs_persist_segment,
+               tioca_common->ca_common.bs_persist_busnum);
        BUG_ON(!bus);
        tioca_kern->ca_devices = &bus->devices;
 
@@ -656,6 +657,8 @@ static struct sn_pcibus_provider tioca_pci_interfaces = {
        .dma_map_consistent = tioca_dma_map,
        .dma_unmap = tioca_dma_unmap,
        .bus_fixup = tioca_bus_fixup,
+       .force_interrupt = NULL,
+       .target_interrupt = NULL
 };
 
 /**
diff --git a/arch/ia64/sn/pci/tioce_provider.c b/arch/ia64/sn/pci/tioce_provider.c
new file mode 100644 (file)
index 0000000..8e75db2
--- /dev/null
@@ -0,0 +1,771 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2003-2005 Silicon Graphics, Inc.  All Rights Reserved.
+ */
+
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/pci.h>
+#include <asm/sn/sn_sal.h>
+#include <asm/sn/addrs.h>
+#include <asm/sn/pcidev.h>
+#include <asm/sn/pcibus_provider_defs.h>
+#include <asm/sn/tioce_provider.h>
+
+/**
+ * Bus address ranges for the 5 flavors of TIOCE DMA
+ */
+
+#define TIOCE_D64_MIN  0x8000000000000000UL
+#define TIOCE_D64_MAX  0xffffffffffffffffUL
+#define TIOCE_D64_ADDR(a)      ((a) >= TIOCE_D64_MIN)
+
+#define TIOCE_D32_MIN  0x0000000080000000UL
+#define TIOCE_D32_MAX  0x00000000ffffffffUL
+#define TIOCE_D32_ADDR(a)      ((a) >= TIOCE_D32_MIN && (a) <= TIOCE_D32_MAX)
+
+#define TIOCE_M32_MIN  0x0000000000000000UL
+#define TIOCE_M32_MAX  0x000000007fffffffUL
+#define TIOCE_M32_ADDR(a)      ((a) >= TIOCE_M32_MIN && (a) <= TIOCE_M32_MAX)
+
+#define TIOCE_M40_MIN  0x0000004000000000UL
+#define TIOCE_M40_MAX  0x0000007fffffffffUL
+#define TIOCE_M40_ADDR(a)      ((a) >= TIOCE_M40_MIN && (a) <= TIOCE_M40_MAX)
+
+#define TIOCE_M40S_MIN 0x0000008000000000UL
+#define TIOCE_M40S_MAX 0x000000ffffffffffUL
+#define TIOCE_M40S_ADDR(a)     ((a) >= TIOCE_M40S_MIN && (a) <= TIOCE_M40S_MAX)
+
+/*
+ * ATE manipulation macros.
+ */
+
+#define ATE_PAGESHIFT(ps)      (__ffs(ps))
+#define ATE_PAGEMASK(ps)       ((ps)-1)
+
+#define ATE_PAGE(x, ps) ((x) >> ATE_PAGESHIFT(ps))
+#define ATE_NPAGES(start, len, pagesize) \
+       (ATE_PAGE((start)+(len)-1, pagesize) - ATE_PAGE(start, pagesize) + 1)
+
+#define ATE_VALID(ate) ((ate) & (1UL << 63))
+#define ATE_MAKE(addr, ps) (((addr) & ~ATE_PAGEMASK(ps)) | (1UL << 63))
+
+/*
+ * Flavors of ate-based mapping supported by tioce_alloc_map()
+ */
+
+#define TIOCE_ATE_M32  1
+#define TIOCE_ATE_M40  2
+#define TIOCE_ATE_M40S 3
+
+#define KB(x)  ((x) << 10)
+#define MB(x)  ((x) << 20)
+#define GB(x)  ((x) << 30)
+
+/**
+ * tioce_dma_d64 - create a DMA mapping using 64-bit direct mode
+ * @ct_addr: system coretalk address
+ *
+ * Map @ct_addr into 64-bit CE bus space.  No device context is necessary
+ * and no CE mapping are consumed.
+ *
+ * Bits 53:0 come from the coretalk address.  The remaining bits are set as
+ * follows:
+ *
+ * 63    - must be 1 to indicate d64 mode to CE hardware
+ * 62    - barrier bit ... controlled with tioce_dma_barrier()
+ * 61    - 0 since this is not an MSI transaction
+ * 60:54 - reserved, MBZ
+ */
+static uint64_t
+tioce_dma_d64(unsigned long ct_addr)
+{
+       uint64_t bus_addr;
+
+       bus_addr = ct_addr | (1UL << 63);
+
+       return bus_addr;
+}
+
+/**
+ * pcidev_to_tioce - return misc ce related pointers given a pci_dev
+ * @pci_dev: pci device context
+ * @base: ptr to store struct tioce_mmr * for the CE holding this device
+ * @kernel: ptr to store struct tioce_kernel * for the CE holding this device
+ * @port: ptr to store the CE port number that this device is on
+ *
+ * Return pointers to various CE-related structures for the CE upstream of
+ * @pci_dev.
+ */
+static inline void
+pcidev_to_tioce(struct pci_dev *pdev, struct tioce **base,
+               struct tioce_kernel **kernel, int *port)
+{
+       struct pcidev_info *pcidev_info;
+       struct tioce_common *ce_common;
+       struct tioce_kernel *ce_kernel;
+
+       pcidev_info = SN_PCIDEV_INFO(pdev);
+       ce_common = (struct tioce_common *)pcidev_info->pdi_pcibus_info;
+       ce_kernel = (struct tioce_kernel *)ce_common->ce_kernel_private;
+
+       if (base)
+               *base = (struct tioce *)ce_common->ce_pcibus.bs_base;
+       if (kernel)
+               *kernel = ce_kernel;
+
+       /*
+        * we use port as a zero-based value internally, even though the
+        * documentation is 1-based.
+        */
+       if (port)
+               *port =
+                   (pdev->bus->number < ce_kernel->ce_port1_secondary) ? 0 : 1;
+}
+
+/**
+ * tioce_alloc_map - Given a coretalk address, map it to pcie bus address
+ * space using one of the various ATE-based address modes.
+ * @ce_kern: tioce context
+ * @type: map mode to use
+ * @port: 0-based port that the requesting device is downstream of
+ * @ct_addr: the coretalk address to map
+ * @len: number of bytes to map
+ *
+ * Given the addressing type, set up various paramaters that define the
+ * ATE pool to use.  Search for a contiguous block of entries to cover the
+ * length, and if enough resources exist, fill in the ATE's and construct a
+ * tioce_dmamap struct to track the mapping.
+ */
+static uint64_t
+tioce_alloc_map(struct tioce_kernel *ce_kern, int type, int port,
+               uint64_t ct_addr, int len)
+{
+       int i;
+       int j;
+       int first;
+       int last;
+       int entries;
+       int nates;
+       int pagesize;
+       uint64_t *ate_shadow;
+       uint64_t *ate_reg;
+       uint64_t addr;
+       struct tioce *ce_mmr;
+       uint64_t bus_base;
+       struct tioce_dmamap *map;
+
+       ce_mmr = (struct tioce *)ce_kern->ce_common->ce_pcibus.bs_base;
+
+       switch (type) {
+       case TIOCE_ATE_M32:
+               /*
+                * The first 64 entries of the ate3240 pool are dedicated to
+                * super-page (TIOCE_ATE_M40S) mode.
+                */
+               first = 64;
+               entries = TIOCE_NUM_M3240_ATES - 64;
+               ate_shadow = ce_kern->ce_ate3240_shadow;
+               ate_reg = ce_mmr->ce_ure_ate3240;
+               pagesize = ce_kern->ce_ate3240_pagesize;
+               bus_base = TIOCE_M32_MIN;
+               break;
+       case TIOCE_ATE_M40:
+               first = 0;
+               entries = TIOCE_NUM_M40_ATES;
+               ate_shadow = ce_kern->ce_ate40_shadow;
+               ate_reg = ce_mmr->ce_ure_ate40;
+               pagesize = MB(64);
+               bus_base = TIOCE_M40_MIN;
+               break;
+       case TIOCE_ATE_M40S:
+               /*
+                * ate3240 entries 0-31 are dedicated to port1 super-page
+                * mappings.  ate3240 entries 32-63 are dedicated to port2.
+                */
+               first = port * 32;
+               entries = 32;
+               ate_shadow = ce_kern->ce_ate3240_shadow;
+               ate_reg = ce_mmr->ce_ure_ate3240;
+               pagesize = GB(16);
+               bus_base = TIOCE_M40S_MIN;
+               break;
+       default:
+               return 0;
+       }
+
+       nates = ATE_NPAGES(ct_addr, len, pagesize);
+       if (nates > entries)
+               return 0;
+
+       last = first + entries - nates;
+       for (i = first; i <= last; i++) {
+               if (ATE_VALID(ate_shadow[i]))
+                       continue;
+
+               for (j = i; j < i + nates; j++)
+                       if (ATE_VALID(ate_shadow[j]))
+                               break;
+
+               if (j >= i + nates)
+                       break;
+       }
+
+       if (i > last)
+               return 0;
+
+       map = kcalloc(1, sizeof(struct tioce_dmamap), GFP_ATOMIC);
+       if (!map)
+               return 0;
+
+       addr = ct_addr;
+       for (j = 0; j < nates; j++) {
+               uint64_t ate;
+
+               ate = ATE_MAKE(addr, pagesize);
+               ate_shadow[i + j] = ate;
+               ate_reg[i + j] = ate;
+               addr += pagesize;
+       }
+
+       map->refcnt = 1;
+       map->nbytes = nates * pagesize;
+       map->ct_start = ct_addr & ~ATE_PAGEMASK(pagesize);
+       map->pci_start = bus_base + (i * pagesize);
+       map->ate_hw = &ate_reg[i];
+       map->ate_shadow = &ate_shadow[i];
+       map->ate_count = nates;
+
+       list_add(&map->ce_dmamap_list, &ce_kern->ce_dmamap_list);
+
+       return (map->pci_start + (ct_addr - map->ct_start));
+}
+
+/**
+ * tioce_dma_d32 - create a DMA mapping using 32-bit direct mode
+ * @pdev: linux pci_dev representing the function
+ * @paddr: system physical address
+ *
+ * Map @paddr into 32-bit bus space of the CE associated with @pcidev_info.
+ */
+static uint64_t
+tioce_dma_d32(struct pci_dev *pdev, uint64_t ct_addr)
+{
+       int dma_ok;
+       int port;
+       struct tioce *ce_mmr;
+       struct tioce_kernel *ce_kern;
+       uint64_t ct_upper;
+       uint64_t ct_lower;
+       dma_addr_t bus_addr;
+
+       ct_upper = ct_addr & ~0x3fffffffUL;
+       ct_lower = ct_addr & 0x3fffffffUL;
+
+       pcidev_to_tioce(pdev, &ce_mmr, &ce_kern, &port);
+
+       if (ce_kern->ce_port[port].dirmap_refcnt == 0) {
+               volatile uint64_t tmp;
+
+               ce_kern->ce_port[port].dirmap_shadow = ct_upper;
+               ce_mmr->ce_ure_dir_map[port] = ct_upper;
+               tmp = ce_mmr->ce_ure_dir_map[port];
+               dma_ok = 1;
+       } else
+               dma_ok = (ce_kern->ce_port[port].dirmap_shadow == ct_upper);
+
+       if (dma_ok) {
+               ce_kern->ce_port[port].dirmap_refcnt++;
+               bus_addr = TIOCE_D32_MIN + ct_lower;
+       } else
+               bus_addr = 0;
+
+       return bus_addr;
+}
+
+/**
+ * tioce_dma_barrier - swizzle a TIOCE bus address to include or exclude
+ * the barrier bit.
+ * @bus_addr:  bus address to swizzle
+ *
+ * Given a TIOCE bus address, set the appropriate bit to indicate barrier
+ * attributes.
+ */
+static uint64_t
+tioce_dma_barrier(uint64_t bus_addr, int on)
+{
+       uint64_t barrier_bit;
+
+       /* barrier not supported in M40/M40S mode */
+       if (TIOCE_M40_ADDR(bus_addr) || TIOCE_M40S_ADDR(bus_addr))
+               return bus_addr;
+
+       if (TIOCE_D64_ADDR(bus_addr))
+               barrier_bit = (1UL << 62);
+       else                    /* must be m32 or d32 */
+               barrier_bit = (1UL << 30);
+
+       return (on) ? (bus_addr | barrier_bit) : (bus_addr & ~barrier_bit);
+}
+
+/**
+ * tioce_dma_unmap - release CE mapping resources
+ * @pdev: linux pci_dev representing the function
+ * @bus_addr: bus address returned by an earlier tioce_dma_map
+ * @dir: mapping direction (unused)
+ *
+ * Locate mapping resources associated with @bus_addr and release them.
+ * For mappings created using the direct modes there are no resources
+ * to release.
+ */
+void
+tioce_dma_unmap(struct pci_dev *pdev, dma_addr_t bus_addr, int dir)
+{
+       int i;
+       int port;
+       struct tioce_kernel *ce_kern;
+       struct tioce *ce_mmr;
+       unsigned long flags;
+
+       bus_addr = tioce_dma_barrier(bus_addr, 0);
+       pcidev_to_tioce(pdev, &ce_mmr, &ce_kern, &port);
+
+       /* nothing to do for D64 */
+
+       if (TIOCE_D64_ADDR(bus_addr))
+               return;
+
+       spin_lock_irqsave(&ce_kern->ce_lock, flags);
+
+       if (TIOCE_D32_ADDR(bus_addr)) {
+               if (--ce_kern->ce_port[port].dirmap_refcnt == 0) {
+                       ce_kern->ce_port[port].dirmap_shadow = 0;
+                       ce_mmr->ce_ure_dir_map[port] = 0;
+               }
+       } else {
+               struct tioce_dmamap *map;
+
+               list_for_each_entry(map, &ce_kern->ce_dmamap_list,
+                                   ce_dmamap_list) {
+                       uint64_t last;
+
+                       last = map->pci_start + map->nbytes - 1;
+                       if (bus_addr >= map->pci_start && bus_addr <= last)
+                               break;
+               }
+
+               if (&map->ce_dmamap_list == &ce_kern->ce_dmamap_list) {
+                       printk(KERN_WARNING
+                              "%s:  %s - no map found for bus_addr 0x%lx\n",
+                              __FUNCTION__, pci_name(pdev), bus_addr);
+               } else if (--map->refcnt == 0) {
+                       for (i = 0; i < map->ate_count; i++) {
+                               map->ate_shadow[i] = 0;
+                               map->ate_hw[i] = 0;
+                       }
+
+                       list_del(&map->ce_dmamap_list);
+                       kfree(map);
+               }
+       }
+
+       spin_unlock_irqrestore(&ce_kern->ce_lock, flags);
+}
+
+/**
+ * tioce_do_dma_map - map pages for PCI DMA
+ * @pdev: linux pci_dev representing the function
+ * @paddr: host physical address to map
+ * @byte_count: bytes to map
+ *
+ * This is the main wrapper for mapping host physical pages to CE PCI space.
+ * The mapping mode used is based on the device's dma_mask.
+ */
+static uint64_t
+tioce_do_dma_map(struct pci_dev *pdev, uint64_t paddr, size_t byte_count,
+                int barrier)
+{
+       unsigned long flags;
+       uint64_t ct_addr;
+       uint64_t mapaddr = 0;
+       struct tioce_kernel *ce_kern;
+       struct tioce_dmamap *map;
+       int port;
+       uint64_t dma_mask;
+
+       dma_mask = (barrier) ? pdev->dev.coherent_dma_mask : pdev->dma_mask;
+
+       /* cards must be able to address at least 31 bits */
+       if (dma_mask < 0x7fffffffUL)
+               return 0;
+
+       ct_addr = PHYS_TO_TIODMA(paddr);
+
+       /*
+        * If the device can generate 64 bit addresses, create a D64 map.
+        * Since this should never fail, bypass the rest of the checks.
+        */
+       if (dma_mask == ~0UL) {
+               mapaddr = tioce_dma_d64(ct_addr);
+               goto dma_map_done;
+       }
+
+       pcidev_to_tioce(pdev, NULL, &ce_kern, &port);
+
+       spin_lock_irqsave(&ce_kern->ce_lock, flags);
+
+       /*
+        * D64 didn't work ... See if we have an existing map that covers
+        * this address range.  Must account for devices dma_mask here since
+        * an existing map might have been done in a mode using more pci
+        * address bits than this device can support.
+        */
+       list_for_each_entry(map, &ce_kern->ce_dmamap_list, ce_dmamap_list) {
+               uint64_t last;
+
+               last = map->ct_start + map->nbytes - 1;
+               if (ct_addr >= map->ct_start &&
+                   ct_addr + byte_count - 1 <= last &&
+                   map->pci_start <= dma_mask) {
+                       map->refcnt++;
+                       mapaddr = map->pci_start + (ct_addr - map->ct_start);
+                       break;
+               }
+       }
+
+       /*
+        * If we don't have a map yet, and the card can generate 40
+        * bit addresses, try the M40/M40S modes.  Note these modes do not
+        * support a barrier bit, so if we need a consistent map these
+        * won't work.
+        */
+       if (!mapaddr && !barrier && dma_mask >= 0xffffffffffUL) {
+               /*
+                * We have two options for 40-bit mappings:  16GB "super" ATE's
+                * and 64MB "regular" ATE's.  We'll try both if needed for a
+                * given mapping but which one we try first depends on the
+                * size.  For requests >64MB, prefer to use a super page with
+                * regular as the fallback. Otherwise, try in the reverse order.
+                */
+
+               if (byte_count > MB(64)) {
+                       mapaddr = tioce_alloc_map(ce_kern, TIOCE_ATE_M40S,
+                                                 port, ct_addr, byte_count);
+                       if (!mapaddr)
+                               mapaddr =
+                                   tioce_alloc_map(ce_kern, TIOCE_ATE_M40, -1,
+                                                   ct_addr, byte_count);
+               } else {
+                       mapaddr = tioce_alloc_map(ce_kern, TIOCE_ATE_M40, -1,
+                                                 ct_addr, byte_count);
+                       if (!mapaddr)
+                               mapaddr =
+                                   tioce_alloc_map(ce_kern, TIOCE_ATE_M40S,
+                                                   port, ct_addr, byte_count);
+               }
+       }
+
+       /*
+        * 32-bit direct is the next mode to try
+        */
+       if (!mapaddr && dma_mask >= 0xffffffffUL)
+               mapaddr = tioce_dma_d32(pdev, ct_addr);
+
+       /*
+        * Last resort, try 32-bit ATE-based map.
+        */
+       if (!mapaddr)
+               mapaddr =
+                   tioce_alloc_map(ce_kern, TIOCE_ATE_M32, -1, ct_addr,
+                                   byte_count);
+
+       spin_unlock_irqrestore(&ce_kern->ce_lock, flags);
+
+dma_map_done:
+       if (mapaddr & barrier)
+               mapaddr = tioce_dma_barrier(mapaddr, 1);
+
+       return mapaddr;
+}
+
+/**
+ * tioce_dma - standard pci dma map interface
+ * @pdev: pci device requesting the map
+ * @paddr: system physical address to map into pci space
+ * @byte_count: # bytes to map
+ *
+ * Simply call tioce_do_dma_map() to create a map with the barrier bit clear
+ * in the address.
+ */
+static uint64_t
+tioce_dma(struct pci_dev *pdev, uint64_t paddr, size_t byte_count)
+{
+       return tioce_do_dma_map(pdev, paddr, byte_count, 0);
+}
+
+/**
+ * tioce_dma_consistent - consistent pci dma map interface
+ * @pdev: pci device requesting the map
+ * @paddr: system physical address to map into pci space
+ * @byte_count: # bytes to map
+ *
+ * Simply call tioce_do_dma_map() to create a map with the barrier bit set
+ * in the address.
+ */ static uint64_t
+tioce_dma_consistent(struct pci_dev *pdev, uint64_t paddr, size_t byte_count)
+{
+       return tioce_do_dma_map(pdev, paddr, byte_count, 1);
+}
+
+/**
+ * tioce_error_intr_handler - SGI TIO CE error interrupt handler
+ * @irq: unused
+ * @arg: pointer to tioce_common struct for the given CE
+ * @pt: unused
+ *
+ * Handle a CE error interrupt.  Simply a wrapper around a SAL call which
+ * defers processing to the SGI prom.
+ */ static irqreturn_t
+tioce_error_intr_handler(int irq, void *arg, struct pt_regs *pt)
+{
+       struct tioce_common *soft = arg;
+       struct ia64_sal_retval ret_stuff;
+       ret_stuff.status = 0;
+       ret_stuff.v0 = 0;
+
+       SAL_CALL_NOLOCK(ret_stuff, (u64) SN_SAL_IOIF_ERROR_INTERRUPT,
+                       soft->ce_pcibus.bs_persist_segment,
+                       soft->ce_pcibus.bs_persist_busnum, 0, 0, 0, 0, 0);
+
+       return IRQ_HANDLED;
+}
+
+/**
+ * tioce_kern_init - init kernel structures related to a given TIOCE
+ * @tioce_common: ptr to a cached tioce_common struct that originated in prom
+ */ static struct tioce_kernel *
+tioce_kern_init(struct tioce_common *tioce_common)
+{
+       int i;
+       uint32_t tmp;
+       struct tioce *tioce_mmr;
+       struct tioce_kernel *tioce_kern;
+
+       tioce_kern = kcalloc(1, sizeof(struct tioce_kernel), GFP_KERNEL);
+       if (!tioce_kern) {
+               return NULL;
+       }
+
+       tioce_kern->ce_common = tioce_common;
+       spin_lock_init(&tioce_kern->ce_lock);
+       INIT_LIST_HEAD(&tioce_kern->ce_dmamap_list);
+       tioce_common->ce_kernel_private = (uint64_t) tioce_kern;
+
+       /*
+        * Determine the secondary bus number of the port2 logical PPB.
+        * This is used to decide whether a given pci device resides on
+        * port1 or port2.  Note:  We don't have enough plumbing set up
+        * here to use pci_read_config_xxx() so use the raw_pci_ops vector.
+        */
+
+       raw_pci_ops->read(tioce_common->ce_pcibus.bs_persist_segment,
+                         tioce_common->ce_pcibus.bs_persist_busnum,
+                         PCI_DEVFN(2, 0), PCI_SECONDARY_BUS, 1, &tmp);
+       tioce_kern->ce_port1_secondary = (uint8_t) tmp;
+
+       /*
+        * Set PMU pagesize to the largest size available, and zero out
+        * the ate's.
+        */
+
+       tioce_mmr = (struct tioce *)tioce_common->ce_pcibus.bs_base;
+       tioce_mmr->ce_ure_page_map &= ~CE_URE_PAGESIZE_MASK;
+       tioce_mmr->ce_ure_page_map |= CE_URE_256K_PAGESIZE;
+       tioce_kern->ce_ate3240_pagesize = KB(256);
+
+       for (i = 0; i < TIOCE_NUM_M40_ATES; i++) {
+               tioce_kern->ce_ate40_shadow[i] = 0;
+               tioce_mmr->ce_ure_ate40[i] = 0;
+       }
+
+       for (i = 0; i < TIOCE_NUM_M3240_ATES; i++) {
+               tioce_kern->ce_ate3240_shadow[i] = 0;
+               tioce_mmr->ce_ure_ate3240[i] = 0;
+       }
+
+       return tioce_kern;
+}
+
+/**
+ * tioce_force_interrupt - implement altix force_interrupt() backend for CE
+ * @sn_irq_info: sn asic irq that we need an interrupt generated for
+ *
+ * Given an sn_irq_info struct, set the proper bit in ce_adm_force_int to
+ * force a secondary interrupt to be generated.  This is to work around an
+ * asic issue where there is a small window of opportunity for a legacy device
+ * interrupt to be lost.
+ */
+static void
+tioce_force_interrupt(struct sn_irq_info *sn_irq_info)
+{
+       struct pcidev_info *pcidev_info;
+       struct tioce_common *ce_common;
+       struct tioce *ce_mmr;
+       uint64_t force_int_val;
+
+       if (!sn_irq_info->irq_bridge)
+               return;
+
+       if (sn_irq_info->irq_bridge_type != PCIIO_ASIC_TYPE_TIOCE)
+               return;
+
+       pcidev_info = (struct pcidev_info *)sn_irq_info->irq_pciioinfo;
+       if (!pcidev_info)
+               return;
+
+       ce_common = (struct tioce_common *)pcidev_info->pdi_pcibus_info;
+       ce_mmr = (struct tioce *)ce_common->ce_pcibus.bs_base;
+
+       /*
+        * irq_int_bit is originally set up by prom, and holds the interrupt
+        * bit shift (not mask) as defined by the bit definitions in the
+        * ce_adm_int mmr.  These shifts are not the same for the
+        * ce_adm_force_int register, so do an explicit mapping here to make
+        * things clearer.
+        */
+
+       switch (sn_irq_info->irq_int_bit) {
+       case CE_ADM_INT_PCIE_PORT1_DEV_A_SHFT:
+               force_int_val = 1UL << CE_ADM_FORCE_INT_PCIE_PORT1_DEV_A_SHFT;
+               break;
+       case CE_ADM_INT_PCIE_PORT1_DEV_B_SHFT:
+               force_int_val = 1UL << CE_ADM_FORCE_INT_PCIE_PORT1_DEV_B_SHFT;
+               break;
+       case CE_ADM_INT_PCIE_PORT1_DEV_C_SHFT:
+               force_int_val = 1UL << CE_ADM_FORCE_INT_PCIE_PORT1_DEV_C_SHFT;
+               break;
+       case CE_ADM_INT_PCIE_PORT1_DEV_D_SHFT:
+               force_int_val = 1UL << CE_ADM_FORCE_INT_PCIE_PORT1_DEV_D_SHFT;
+               break;
+       case CE_ADM_INT_PCIE_PORT2_DEV_A_SHFT:
+               force_int_val = 1UL << CE_ADM_FORCE_INT_PCIE_PORT2_DEV_A_SHFT;
+               break;
+       case CE_ADM_INT_PCIE_PORT2_DEV_B_SHFT:
+               force_int_val = 1UL << CE_ADM_FORCE_INT_PCIE_PORT2_DEV_B_SHFT;
+               break;
+       case CE_ADM_INT_PCIE_PORT2_DEV_C_SHFT:
+               force_int_val = 1UL << CE_ADM_FORCE_INT_PCIE_PORT2_DEV_C_SHFT;
+               break;
+       case CE_ADM_INT_PCIE_PORT2_DEV_D_SHFT:
+               force_int_val = 1UL << CE_ADM_FORCE_INT_PCIE_PORT2_DEV_D_SHFT;
+               break;
+       default:
+               return;
+       }
+       ce_mmr->ce_adm_force_int = force_int_val;
+}
+
+/**
+ * tioce_target_interrupt - implement set_irq_affinity for tioce resident
+ * functions.  Note:  only applies to line interrupts, not MSI's.
+ *
+ * @sn_irq_info: SN IRQ context
+ *
+ * Given an sn_irq_info, set the associated CE device's interrupt destination
+ * register.  Since the interrupt destination registers are on a per-ce-slot
+ * basis, this will retarget line interrupts for all functions downstream of
+ * the slot.
+ */
+static void
+tioce_target_interrupt(struct sn_irq_info *sn_irq_info)
+{
+       struct pcidev_info *pcidev_info;
+       struct tioce_common *ce_common;
+       struct tioce *ce_mmr;
+       int bit;
+
+       pcidev_info = (struct pcidev_info *)sn_irq_info->irq_pciioinfo;
+       if (!pcidev_info)
+               return;
+
+       ce_common = (struct tioce_common *)pcidev_info->pdi_pcibus_info;
+       ce_mmr = (struct tioce *)ce_common->ce_pcibus.bs_base;
+
+       bit = sn_irq_info->irq_int_bit;
+
+       ce_mmr->ce_adm_int_mask |= (1UL << bit);
+       ce_mmr->ce_adm_int_dest[bit] =
+               ((uint64_t)sn_irq_info->irq_irq << INTR_VECTOR_SHFT) |
+                          sn_irq_info->irq_xtalkaddr;
+       ce_mmr->ce_adm_int_mask &= ~(1UL << bit);
+
+       tioce_force_interrupt(sn_irq_info);
+}
+
+/**
+ * tioce_bus_fixup - perform final PCI fixup for a TIO CE bus
+ * @prom_bussoft: Common prom/kernel struct representing the bus
+ *
+ * Replicates the tioce_common pointed to by @prom_bussoft in kernel
+ * space.  Allocates and initializes a kernel-only area for a given CE,
+ * and sets up an irq for handling CE error interrupts.
+ *
+ * On successful setup, returns the kernel version of tioce_common back to
+ * the caller.
+ */
+static void *
+tioce_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *controller)
+{
+       struct tioce_common *tioce_common;
+
+       /*
+        * Allocate kernel bus soft and copy from prom.
+        */
+
+       tioce_common = kcalloc(1, sizeof(struct tioce_common), GFP_KERNEL);
+       if (!tioce_common)
+               return NULL;
+
+       memcpy(tioce_common, prom_bussoft, sizeof(struct tioce_common));
+       tioce_common->ce_pcibus.bs_base |= __IA64_UNCACHED_OFFSET;
+
+       if (tioce_kern_init(tioce_common) == NULL) {
+               kfree(tioce_common);
+               return NULL;
+       }
+
+       if (request_irq(SGI_PCIASIC_ERROR,
+                       tioce_error_intr_handler,
+                       SA_SHIRQ, "TIOCE error", (void *)tioce_common))
+               printk(KERN_WARNING
+                      "%s:  Unable to get irq %d.  "
+                      "Error interrupts won't be routed for "
+                      "TIOCE bus %04x:%02x\n",
+                      __FUNCTION__, SGI_PCIASIC_ERROR,
+                      tioce_common->ce_pcibus.bs_persist_segment,
+                      tioce_common->ce_pcibus.bs_persist_busnum);
+
+       return tioce_common;
+}
+
+static struct sn_pcibus_provider tioce_pci_interfaces = {
+       .dma_map = tioce_dma,
+       .dma_map_consistent = tioce_dma_consistent,
+       .dma_unmap = tioce_dma_unmap,
+       .bus_fixup = tioce_bus_fixup,
+       .force_interrupt = tioce_force_interrupt,
+       .target_interrupt = tioce_target_interrupt
+};
+
+/**
+ * tioce_init_provider - init SN PCI provider ops for TIO CE
+ */
+int
+tioce_init_provider(void)
+{
+       sn_pci_provider[PCIIO_ASIC_TYPE_TIOCE] = &tioce_pci_interfaces;
+       return 0;
+}
index fe837e31afbf39eeb1208a8488a066e1c90febaf..73e2f5e168ddd17706a22333303e3e6c486e872b 100644 (file)
@@ -74,10 +74,6 @@ EXPORT_SYMBOL(vme_brdtype);
 EXPORT_SYMBOL(__ashldi3);
 EXPORT_SYMBOL(__ashrdi3);
 EXPORT_SYMBOL(__lshrdi3);
-EXPORT_SYMBOL(memcpy);
-EXPORT_SYMBOL(memset);
-EXPORT_SYMBOL(memcmp);
-EXPORT_SYMBOL(memscan);
 EXPORT_SYMBOL(__muldi3);
 
 EXPORT_SYMBOL(__down_failed);
index f4e1e5eb8e1289a1c37a0dc4eed78568e9fae73b..8ed1b01a6a8742a7d44dad74f96bf11d7e395558 100644 (file)
@@ -95,7 +95,7 @@ static inline int put_reg(struct task_struct *task, int regno,
        if (regno == PT_USP)
                addr = &task->thread.usp;
        else if (regno < sizeof(regoff)/sizeof(regoff[0]))
-               addr = (unsigned long *) (task->thread.esp0 + regoff[regno]);
+               addr = (unsigned long *)(task->thread.esp0 + regoff[regno]);
        else
                return -1;
        *addr = data;
@@ -103,48 +103,56 @@ static inline int put_reg(struct task_struct *task, int regno,
 }
 
 /*
- * Called by kernel/ptrace.c when detaching..
- *
  * Make sure the single step bit is not set.
  */
-void ptrace_disable(struct task_struct *child)
+static inline void singlestep_disable(struct task_struct *child)
 {
-       unsigned long tmp;
-       /* make sure the single step bit is not set. */
-       tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16);
+       unsigned long tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16);
        put_reg(child, PT_SR, tmp);
        child->thread.work.delayed_trace = 0;
+}
+
+/*
+ * Called by kernel/ptrace.c when detaching..
+ */
+void ptrace_disable(struct task_struct *child)
+{
+       singlestep_disable(child);
        child->thread.work.syscall_trace = 0;
 }
 
 asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
 {
        struct task_struct *child;
-       int ret;
+       unsigned long tmp;
+       int i, ret = 0;
 
        lock_kernel();
-       ret = -EPERM;
        if (request == PTRACE_TRACEME) {
                /* are we already being traced? */
-               if (current->ptrace & PT_PTRACED)
+               if (current->ptrace & PT_PTRACED) {
+                       ret = -EPERM;
                        goto out;
+               }
                /* set the ptrace bit in the process flags. */
                current->ptrace |= PT_PTRACED;
-               ret = 0;
                goto out;
        }
-       ret = -ESRCH;
        read_lock(&tasklist_lock);
        child = find_task_by_pid(pid);
        if (child)
                get_task_struct(child);
        read_unlock(&tasklist_lock);
-       if (!child)
+       if (unlikely(!child)) {
+               ret = -ESRCH;
                goto out;
+       }
 
-       ret = -EPERM;
-       if (pid == 1)           /* you may not mess with init */
+       /* you may not mess with init */
+       if (unlikely(pid == 1)) {
+               ret = -EPERM;
                goto out_tsk;
+       }
 
        if (request == PTRACE_ATTACH) {
                ret = ptrace_attach(child);
@@ -152,227 +160,171 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
        }
 
        ret = ptrace_check_attach(child, request == PTRACE_KILL);
-       if (ret < 0)
+       if (ret)
                goto out_tsk;
 
        switch (request) {
        /* when I and D space are separate, these will need to be fixed. */
-               case PTRACE_PEEKTEXT: /* read word at location addr. */
-               case PTRACE_PEEKDATA: {
-                       unsigned long tmp;
-                       int copied;
-
-                       copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 0);
-                       ret = -EIO;
-                       if (copied != sizeof(tmp))
-                               break;
-                       ret = put_user(tmp,(unsigned long *) data);
-                       break;
-               }
+       case PTRACE_PEEKTEXT:   /* read word at location addr. */
+       case PTRACE_PEEKDATA:
+               i = access_process_vm(child, addr, &tmp, sizeof(tmp), 0);
+               if (i != sizeof(tmp))
+                       goto out_eio;
+               ret = put_user(tmp, (unsigned long *)data);
+               break;
 
        /* read the word at location addr in the USER area. */
-               case PTRACE_PEEKUSR: {
-                       unsigned long tmp;
-
-                       ret = -EIO;
-                       if ((addr & 3) || addr < 0 ||
-                           addr > sizeof(struct user) - 3)
-                               break;
-
-                       tmp = 0;  /* Default return condition */
-                       addr = addr >> 2; /* temporary hack. */
-                       ret = -EIO;
-                       if (addr < 19) {
-                               tmp = get_reg(child, addr);
-                               if (addr == PT_SR)
-                                       tmp >>= 16;
-                       } else if (addr >= 21 && addr < 49) {
-                               tmp = child->thread.fp[addr - 21];
-#ifdef CONFIG_M68KFPU_EMU
-                               /* Convert internal fpu reg representation
-                                * into long double format
-                                */
-                               if (FPU_IS_EMU && (addr < 45) && !(addr % 3))
-                                       tmp = ((tmp & 0xffff0000) << 15) |
-                                             ((tmp & 0x0000ffff) << 16);
-#endif
-                       } else
-                               break;
-                       ret = put_user(tmp,(unsigned long *) data);
-                       break;
-               }
-
-      /* when I and D space are separate, this will have to be fixed. */
-               case PTRACE_POKETEXT: /* write the word at location addr. */
-               case PTRACE_POKEDATA:
-                       ret = 0;
-                       if (access_process_vm(child, addr, &data, sizeof(data), 1) == sizeof(data))
-                               break;
-                       ret = -EIO;
-                       break;
-
-               case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
-                       ret = -EIO;
-                       if ((addr & 3) || addr < 0 ||
-                           addr > sizeof(struct user) - 3)
-                               break;
-
-                       addr = addr >> 2; /* temporary hack. */
-
-                       if (addr == PT_SR) {
-                               data &= SR_MASK;
-                               data <<= 16;
-                               data |= get_reg(child, PT_SR) & ~(SR_MASK << 16);
-                       }
-                       if (addr < 19) {
-                               if (put_reg(child, addr, data))
-                                       break;
-                               ret = 0;
-                               break;
-                       }
-                       if (addr >= 21 && addr < 48)
-                       {
-#ifdef CONFIG_M68KFPU_EMU
-                               /* Convert long double format
-                                * into internal fpu reg representation
-                                */
-                               if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) {
-                                       data = (unsigned long)data << 15;
-                                       data = (data & 0xffff0000) |
-                                              ((data & 0x0000ffff) >> 1);
-                               }
-#endif
-                               child->thread.fp[addr - 21] = data;
-                               ret = 0;
-                       }
+       case PTRACE_PEEKUSR:
+               if (addr & 3)
+                       goto out_eio;
+               addr >>= 2;     /* temporary hack. */
+
+               if (addr >= 0 && addr < 19) {
+                       tmp = get_reg(child, addr);
+                       if (addr == PT_SR)
+                               tmp >>= 16;
+               } else if (addr >= 21 && addr < 49) {
+                       tmp = child->thread.fp[addr - 21];
+                       /* Convert internal fpu reg representation
+                        * into long double format
+                        */
+                       if (FPU_IS_EMU && (addr < 45) && !(addr % 3))
+                               tmp = ((tmp & 0xffff0000) << 15) |
+                                     ((tmp & 0x0000ffff) << 16);
+               } else
                        break;
-
-               case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
-               case PTRACE_CONT: { /* restart after signal. */
-                       long tmp;
-
-                       ret = -EIO;
-                       if (!valid_signal(data))
-                               break;
-                       if (request == PTRACE_SYSCALL) {
-                                       child->thread.work.syscall_trace = ~0;
-                       } else {
-                                       child->thread.work.syscall_trace = 0;
+               ret = put_user(tmp, (unsigned long *)data);
+               break;
+
+       /* when I and D space are separate, this will have to be fixed. */
+       case PTRACE_POKETEXT:   /* write the word at location addr. */
+       case PTRACE_POKEDATA:
+               if (access_process_vm(child, addr, &data, sizeof(data), 1) != sizeof(data))
+                       goto out_eio;
+               break;
+
+       case PTRACE_POKEUSR:    /* write the word at location addr in the USER area */
+               if (addr & 3)
+                       goto out_eio;
+               addr >>= 2;     /* temporary hack. */
+
+               if (addr == PT_SR) {
+                       data &= SR_MASK;
+                       data <<= 16;
+                       data |= get_reg(child, PT_SR) & ~(SR_MASK << 16);
+               } else if (addr >= 0 && addr < 19) {
+                       if (put_reg(child, addr, data))
+                               goto out_eio;
+               } else if (addr >= 21 && addr < 48) {
+                       /* Convert long double format
+                        * into internal fpu reg representation
+                        */
+                       if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) {
+                               data = (unsigned long)data << 15;
+                               data = (data & 0xffff0000) |
+                                      ((data & 0x0000ffff) >> 1);
                        }
-                       child->exit_code = data;
-                       /* make sure the single step bit is not set. */
-                       tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16);
-                       put_reg(child, PT_SR, tmp);
-                       child->thread.work.delayed_trace = 0;
-                       wake_up_process(child);
-                       ret = 0;
-                       break;
-               }
-
-/*
- * make the child exit.  Best I can do is send it a sigkill.
- * perhaps it should be put in the status that it wants to
- * exit.
- */
-               case PTRACE_KILL: {
-                       long tmp;
-
-                       ret = 0;
-                       if (child->exit_state == EXIT_ZOMBIE) /* already dead */
-                               break;
-                       child->exit_code = SIGKILL;
-       /* make sure the single step bit is not set. */
-                       tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16);
-                       put_reg(child, PT_SR, tmp);
-                       child->thread.work.delayed_trace = 0;
-                       wake_up_process(child);
-                       break;
-               }
-
-               case PTRACE_SINGLESTEP: {  /* set the trap flag. */
-                       long tmp;
-
-                       ret = -EIO;
-                       if (!valid_signal(data))
-                               break;
+                       child->thread.fp[addr - 21] = data;
+               } else
+                       goto out_eio;
+               break;
+
+       case PTRACE_SYSCALL:    /* continue and stop at next (return from) syscall */
+       case PTRACE_CONT:       /* restart after signal. */
+               if (!valid_signal(data))
+                       goto out_eio;
+
+               if (request == PTRACE_SYSCALL)
+                       child->thread.work.syscall_trace = ~0;
+               else
                        child->thread.work.syscall_trace = 0;
-                       tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16);
-                       put_reg(child, PT_SR, tmp);
-                       child->thread.work.delayed_trace = 1;
-
-                       child->exit_code = data;
-       /* give it a chance to run. */
-                       wake_up_process(child);
-                       ret = 0;
-                       break;
-               }
+               child->exit_code = data;
+               singlestep_disable(child);
+               wake_up_process(child);
+               break;
 
-               case PTRACE_DETACH:     /* detach a process that was attached. */
-                       ret = ptrace_detach(child, data);
+       /*
+        * make the child exit.  Best I can do is send it a sigkill.
+        * perhaps it should be put in the status that it wants to
+        * exit.
+        */
+       case PTRACE_KILL:
+               if (child->exit_state == EXIT_ZOMBIE) /* already dead */
                        break;
-
-               case PTRACE_GETREGS: { /* Get all gp regs from the child. */
-                       int i;
-                       unsigned long tmp;
-                       for (i = 0; i < 19; i++) {
-                           tmp = get_reg(child, i);
-                           if (i == PT_SR)
+               child->exit_code = SIGKILL;
+               singlestep_disable(child);
+               wake_up_process(child);
+               break;
+
+       case PTRACE_SINGLESTEP: /* set the trap flag. */
+               if (!valid_signal(data))
+                       goto out_eio;
+
+               child->thread.work.syscall_trace = 0;
+               tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16);
+               put_reg(child, PT_SR, tmp);
+               child->thread.work.delayed_trace = 1;
+
+               child->exit_code = data;
+               /* give it a chance to run. */
+               wake_up_process(child);
+               break;
+
+       case PTRACE_DETACH:     /* detach a process that was attached. */
+               ret = ptrace_detach(child, data);
+               break;
+
+       case PTRACE_GETREGS:    /* Get all gp regs from the child. */
+               for (i = 0; i < 19; i++) {
+                       tmp = get_reg(child, i);
+                       if (i == PT_SR)
                                tmp >>= 16;
-                           if (put_user(tmp, (unsigned long *) data)) {
-                               ret = -EFAULT;
+                       ret = put_user(tmp, (unsigned long *)data);
+                       if (ret)
                                break;
-                           }
-                           data += sizeof(long);
-                       }
-                       ret = 0;
-                       break;
+                       data += sizeof(long);
                }
+               break;
 
-               case PTRACE_SETREGS: { /* Set all gp regs in the child. */
-                       int i;
-                       unsigned long tmp;
-                       for (i = 0; i < 19; i++) {
-                           if (get_user(tmp, (unsigned long *) data)) {
-                               ret = -EFAULT;
+       case PTRACE_SETREGS:    /* Set all gp regs in the child. */
+               for (i = 0; i < 19; i++) {
+                       ret = get_user(tmp, (unsigned long *)data);
+                       if (ret)
                                break;
-                           }
-                           if (i == PT_SR) {
+                       if (i == PT_SR) {
                                tmp &= SR_MASK;
                                tmp <<= 16;
                                tmp |= get_reg(child, PT_SR) & ~(SR_MASK << 16);
-                           }
-                           put_reg(child, i, tmp);
-                           data += sizeof(long);
                        }
-                       ret = 0;
-                       break;
+                       put_reg(child, i, tmp);
+                       data += sizeof(long);
                }
-
-               case PTRACE_GETFPREGS: { /* Get the child FPU state. */
-                       ret = 0;
-                       if (copy_to_user((void *)data, &child->thread.fp,
-                                        sizeof(struct user_m68kfp_struct)))
-                               ret = -EFAULT;
-                       break;
-               }
-
-               case PTRACE_SETFPREGS: { /* Set the child FPU state. */
-                       ret = 0;
-                       if (copy_from_user(&child->thread.fp, (void *)data,
-                                          sizeof(struct user_m68kfp_struct)))
-                               ret = -EFAULT;
-                       break;
-               }
-
-               default:
-                       ret = ptrace_request(child, request, addr, data);
-                       break;
+               break;
+
+       case PTRACE_GETFPREGS:  /* Get the child FPU state. */
+               if (copy_to_user((void *)data, &child->thread.fp,
+                                sizeof(struct user_m68kfp_struct)))
+                       ret = -EFAULT;
+               break;
+
+       case PTRACE_SETFPREGS:  /* Set the child FPU state. */
+               if (copy_from_user(&child->thread.fp, (void *)data,
+                                  sizeof(struct user_m68kfp_struct)))
+                       ret = -EFAULT;
+               break;
+
+       default:
+               ret = ptrace_request(child, request, addr, data);
+               break;
        }
 out_tsk:
        put_task_struct(child);
 out:
        unlock_kernel();
        return ret;
+out_eio:
+       ret = -EIO;
+       goto out_tsk;
 }
 
 asmlinkage void syscall_trace(void)
index 34b6dbc29c8570a7a5a8e61dc0000b02ba9a0447..ebe51a513817510677db666a4df59a862b7c08d8 100644 (file)
@@ -5,4 +5,4 @@
 EXTRA_AFLAGS := -traditional
 
 lib-y          := ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \
-                       checksum.o memcmp.o memcpy.o memset.o semaphore.o
+                       checksum.o string.o semaphore.o
diff --git a/arch/m68k/lib/memcmp.c b/arch/m68k/lib/memcmp.c
deleted file mode 100644 (file)
index f4796fe..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <linux/types.h>
-
-int memcmp(const void * cs,const void * ct,size_t count)
-{
-  const unsigned char *su1, *su2;
-
-  for( su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--)
-    if (*su1 != *su2)
-      return((*su1 < *su2) ? -1 : +1);
-  return(0);
-}
diff --git a/arch/m68k/lib/memcpy.c b/arch/m68k/lib/memcpy.c
deleted file mode 100644 (file)
index 73e1818..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-#include <linux/types.h>
-
-void * memcpy(void * to, const void * from, size_t n)
-{
-  void *xto = to;
-  size_t temp, temp1;
-
-  if (!n)
-    return xto;
-  if ((long) to & 1)
-    {
-      char *cto = to;
-      const char *cfrom = from;
-      *cto++ = *cfrom++;
-      to = cto;
-      from = cfrom;
-      n--;
-    }
-  if (n > 2 && (long) to & 2)
-    {
-      short *sto = to;
-      const short *sfrom = from;
-      *sto++ = *sfrom++;
-      to = sto;
-      from = sfrom;
-      n -= 2;
-    }
-  temp = n >> 2;
-  if (temp)
-    {
-      long *lto = to;
-      const long *lfrom = from;
-
-      __asm__ __volatile__("movel %2,%3\n\t"
-                          "andw  #7,%3\n\t"
-                          "lsrl  #3,%2\n\t"
-                          "negw  %3\n\t"
-                          "jmp   %%pc@(1f,%3:w:2)\n\t"
-                          "4:\t"
-                          "movel %0@+,%1@+\n\t"
-                          "movel %0@+,%1@+\n\t"
-                          "movel %0@+,%1@+\n\t"
-                          "movel %0@+,%1@+\n\t"
-                          "movel %0@+,%1@+\n\t"
-                          "movel %0@+,%1@+\n\t"
-                          "movel %0@+,%1@+\n\t"
-                          "movel %0@+,%1@+\n\t"
-                          "1:\t"
-                          "dbra  %2,4b\n\t"
-                          "clrw  %2\n\t"
-                          "subql #1,%2\n\t"
-                          "jpl   4b\n\t"
-                          : "=a" (lfrom), "=a" (lto), "=d" (temp),
-                          "=&d" (temp1)
-                          : "0" (lfrom), "1" (lto), "2" (temp)
-                          );
-      to = lto;
-      from = lfrom;
-    }
-  if (n & 2)
-    {
-      short *sto = to;
-      const short *sfrom = from;
-      *sto++ = *sfrom++;
-      to = sto;
-      from = sfrom;
-    }
-  if (n & 1)
-    {
-      char *cto = to;
-      const char *cfrom = from;
-      *cto = *cfrom;
-    }
-  return xto;
-}
diff --git a/arch/m68k/lib/memset.c b/arch/m68k/lib/memset.c
deleted file mode 100644 (file)
index d55fdb2..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#include <linux/types.h>
-
-void * memset(void * s, int c, size_t count)
-{
-  void *xs = s;
-  size_t temp, temp1;
-
-  if (!count)
-    return xs;
-  c &= 0xff;
-  c |= c << 8;
-  c |= c << 16;
-  if ((long) s & 1)
-    {
-      char *cs = s;
-      *cs++ = c;
-      s = cs;
-      count--;
-    }
-  if (count > 2 && (long) s & 2)
-    {
-      short *ss = s;
-      *ss++ = c;
-      s = ss;
-      count -= 2;
-    }
-  temp = count >> 2;
-  if (temp)
-    {
-      long *ls = s;
-
-      __asm__ __volatile__("movel %1,%2\n\t"
-                          "andw  #7,%2\n\t"
-                          "lsrl  #3,%1\n\t"
-                          "negw  %2\n\t"
-                          "jmp   %%pc@(2f,%2:w:2)\n\t"
-                          "1:\t"
-                          "movel %3,%0@+\n\t"
-                          "movel %3,%0@+\n\t"
-                          "movel %3,%0@+\n\t"
-                          "movel %3,%0@+\n\t"
-                          "movel %3,%0@+\n\t"
-                          "movel %3,%0@+\n\t"
-                          "movel %3,%0@+\n\t"
-                          "movel %3,%0@+\n\t"
-                          "2:\t"
-                          "dbra  %1,1b\n\t"
-                          "clrw  %1\n\t"
-                          "subql #1,%1\n\t"
-                          "jpl   1b\n\t"
-                          : "=a" (ls), "=d" (temp), "=&d" (temp1)
-                          : "d" (c), "0" (ls), "1" (temp)
-                          );
-      s = ls;
-    }
-  if (count & 2)
-    {
-      short *ss = s;
-      *ss++ = c;
-      s = ss;
-    }
-  if (count & 1)
-    {
-      char *cs = s;
-      *cs = c;
-    }
-  return xs;
-}
diff --git a/arch/m68k/lib/string.c b/arch/m68k/lib/string.c
new file mode 100644 (file)
index 0000000..b92b89e
--- /dev/null
@@ -0,0 +1,237 @@
+
+#include <linux/types.h>
+#include <linux/module.h>
+
+void *memset(void *s, int c, size_t count)
+{
+       void *xs = s;
+       size_t temp, temp1;
+
+       if (!count)
+               return xs;
+       c &= 0xff;
+       c |= c << 8;
+       c |= c << 16;
+       if ((long)s & 1) {
+               char *cs = s;
+               *cs++ = c;
+               s = cs;
+               count--;
+       }
+       if (count > 2 && (long)s & 2) {
+               short *ss = s;
+               *ss++ = c;
+               s = ss;
+               count -= 2;
+       }
+       temp = count >> 2;
+       if (temp) {
+               long *ls = s;
+
+               asm volatile (
+                       "       movel %1,%2\n"
+                       "       andw  #7,%2\n"
+                       "       lsrl  #3,%1\n"
+                       "       negw  %2\n"
+                       "       jmp   %%pc@(2f,%2:w:2)\n"
+                       "1:     movel %3,%0@+\n"
+                       "       movel %3,%0@+\n"
+                       "       movel %3,%0@+\n"
+                       "       movel %3,%0@+\n"
+                       "       movel %3,%0@+\n"
+                       "       movel %3,%0@+\n"
+                       "       movel %3,%0@+\n"
+                       "       movel %3,%0@+\n"
+                       "2:     dbra  %1,1b\n"
+                       "       clrw  %1\n"
+                       "       subql #1,%1\n"
+                       "       jpl   1b"
+                       : "=a" (ls), "=d" (temp), "=&d" (temp1)
+                       : "d" (c), "0" (ls), "1" (temp));
+               s = ls;
+       }
+       if (count & 2) {
+               short *ss = s;
+               *ss++ = c;
+               s = ss;
+       }
+       if (count & 1) {
+               char *cs = s;
+               *cs = c;
+       }
+       return xs;
+}
+EXPORT_SYMBOL(memset);
+
+void *memcpy(void *to, const void *from, size_t n)
+{
+       void *xto = to;
+       size_t temp, temp1;
+
+       if (!n)
+               return xto;
+       if ((long)to & 1) {
+               char *cto = to;
+               const char *cfrom = from;
+               *cto++ = *cfrom++;
+               to = cto;
+               from = cfrom;
+               n--;
+       }
+       if (n > 2 && (long)to & 2) {
+               short *sto = to;
+               const short *sfrom = from;
+               *sto++ = *sfrom++;
+               to = sto;
+               from = sfrom;
+               n -= 2;
+       }
+       temp = n >> 2;
+       if (temp) {
+               long *lto = to;
+               const long *lfrom = from;
+
+               asm volatile (
+                       "       movel %2,%3\n"
+                       "       andw  #7,%3\n"
+                       "       lsrl  #3,%2\n"
+                       "       negw  %3\n"
+                       "       jmp   %%pc@(1f,%3:w:2)\n"
+                       "4:     movel %0@+,%1@+\n"
+                       "       movel %0@+,%1@+\n"
+                       "       movel %0@+,%1@+\n"
+                       "       movel %0@+,%1@+\n"
+                       "       movel %0@+,%1@+\n"
+                       "       movel %0@+,%1@+\n"
+                       "       movel %0@+,%1@+\n"
+                       "       movel %0@+,%1@+\n"
+                       "1:     dbra  %2,4b\n"
+                       "       clrw  %2\n"
+                       "       subql #1,%2\n"
+                       "       jpl   4b"
+                       : "=a" (lfrom), "=a" (lto), "=d" (temp), "=&d" (temp1)
+                       : "0" (lfrom), "1" (lto), "2" (temp));
+               to = lto;
+               from = lfrom;
+       }
+       if (n & 2) {
+               short *sto = to;
+               const short *sfrom = from;
+               *sto++ = *sfrom++;
+               to = sto;
+               from = sfrom;
+       }
+       if (n & 1) {
+               char *cto = to;
+               const char *cfrom = from;
+               *cto = *cfrom;
+       }
+       return xto;
+}
+EXPORT_SYMBOL(memcpy);
+
+void *memmove(void *dest, const void *src, size_t n)
+{
+       void *xdest = dest;
+       size_t temp;
+
+       if (!n)
+               return xdest;
+
+       if (dest < src) {
+               if ((long)dest & 1) {
+                       char *cdest = dest;
+                       const char *csrc = src;
+                       *cdest++ = *csrc++;
+                       dest = cdest;
+                       src = csrc;
+                       n--;
+               }
+               if (n > 2 && (long)dest & 2) {
+                       short *sdest = dest;
+                       const short *ssrc = src;
+                       *sdest++ = *ssrc++;
+                       dest = sdest;
+                       src = ssrc;
+                       n -= 2;
+               }
+               temp = n >> 2;
+               if (temp) {
+                       long *ldest = dest;
+                       const long *lsrc = src;
+                       temp--;
+                       do
+                               *ldest++ = *lsrc++;
+                       while (temp--);
+                       dest = ldest;
+                       src = lsrc;
+               }
+               if (n & 2) {
+                       short *sdest = dest;
+                       const short *ssrc = src;
+                       *sdest++ = *ssrc++;
+                       dest = sdest;
+                       src = ssrc;
+               }
+               if (n & 1) {
+                       char *cdest = dest;
+                       const char *csrc = src;
+                       *cdest = *csrc;
+               }
+       } else {
+               dest = (char *)dest + n;
+               src = (const char *)src + n;
+               if ((long)dest & 1) {
+                       char *cdest = dest;
+                       const char *csrc = src;
+                       *--cdest = *--csrc;
+                       dest = cdest;
+                       src = csrc;
+                       n--;
+               }
+               if (n > 2 && (long)dest & 2) {
+                       short *sdest = dest;
+                       const short *ssrc = src;
+                       *--sdest = *--ssrc;
+                       dest = sdest;
+                       src = ssrc;
+                       n -= 2;
+               }
+               temp = n >> 2;
+               if (temp) {
+                       long *ldest = dest;
+                       const long *lsrc = src;
+                       temp--;
+                       do
+                               *--ldest = *--lsrc;
+                       while (temp--);
+                       dest = ldest;
+                       src = lsrc;
+               }
+               if (n & 2) {
+                       short *sdest = dest;
+                       const short *ssrc = src;
+                       *--sdest = *--ssrc;
+                       dest = sdest;
+                       src = ssrc;
+               }
+               if (n & 1) {
+                       char *cdest = dest;
+                       const char *csrc = src;
+                       *--cdest = *--csrc;
+               }
+       }
+       return xdest;
+}
+EXPORT_SYMBOL(memmove);
+
+int memcmp(const void *cs, const void *ct, size_t count)
+{
+       const unsigned char *su1, *su2;
+
+       for (su1 = cs, su2 = ct; count > 0; ++su1, ++su2, count--)
+               if (*su1 != *su2)
+                       return *su1 < *su2 ? -1 : +1;
+       return 0;
+}
+EXPORT_SYMBOL(memcmp);
index 90f1c735c110d60b2fa6732d87a3d999ac9bd6d3..5eaa43c4cb3c81c02317ad162c5404ad76f96b81 100644 (file)
@@ -2,7 +2,7 @@
 # Makefile for the linux m68k-specific parts of the memory manager.
 #
 
-obj-y          := init.o fault.o hwtest.o
+obj-y          := cache.o init.o fault.o hwtest.o
 
 obj-$(CONFIG_MMU_MOTOROLA)     += kmap.o memory.o motorola.o
 obj-$(CONFIG_MMU_SUN3)         += sun3kmap.o sun3mmu.o
diff --git a/arch/m68k/mm/cache.c b/arch/m68k/mm/cache.c
new file mode 100644 (file)
index 0000000..5437fff
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ *  linux/arch/m68k/mm/cache.c
+ *
+ *  Instruction cache handling
+ *
+ *  Copyright (C) 1995  Hamish Macdonald
+ */
+
+#include <linux/module.h>
+#include <asm/pgalloc.h>
+#include <asm/traps.h>
+
+
+static unsigned long virt_to_phys_slow(unsigned long vaddr)
+{
+       if (CPU_IS_060) {
+               unsigned long paddr;
+
+               /* The PLPAR instruction causes an access error if the translation
+                * is not possible. To catch this we use the same exception mechanism
+                * as for user space accesses in <asm/uaccess.h>. */
+               asm volatile (".chip 68060\n"
+                             "1: plpar (%0)\n"
+                             ".chip 68k\n"
+                             "2:\n"
+                             ".section .fixup,\"ax\"\n"
+                             "   .even\n"
+                             "3: sub.l %0,%0\n"
+                             "   jra 2b\n"
+                             ".previous\n"
+                             ".section __ex_table,\"a\"\n"
+                             "   .align 4\n"
+                             "   .long 1b,3b\n"
+                             ".previous"
+                             : "=a" (paddr)
+                             : "0" (vaddr));
+               return paddr;
+       } else if (CPU_IS_040) {
+               unsigned long mmusr;
+
+               asm volatile (".chip 68040\n\t"
+                             "ptestr (%1)\n\t"
+                             "movec %%mmusr, %0\n\t"
+                             ".chip 68k"
+                             : "=r" (mmusr)
+                             : "a" (vaddr));
+
+               if (mmusr & MMU_R_040)
+                       return (mmusr & PAGE_MASK) | (vaddr & ~PAGE_MASK);
+       } else {
+               unsigned short mmusr;
+               unsigned long *descaddr;
+
+               asm volatile ("ptestr %3,%2@,#7,%0\n\t"
+                             "pmove %%psr,%1@"
+                             : "=a&" (descaddr)
+                             : "a" (&mmusr), "a" (vaddr), "d" (get_fs().seg));
+               if (mmusr & (MMU_I|MMU_B|MMU_L))
+                       return 0;
+               descaddr = phys_to_virt((unsigned long)descaddr);
+               switch (mmusr & MMU_NUM) {
+               case 1:
+                       return (*descaddr & 0xfe000000) | (vaddr & 0x01ffffff);
+               case 2:
+                       return (*descaddr & 0xfffc0000) | (vaddr & 0x0003ffff);
+               case 3:
+                       return (*descaddr & PAGE_MASK) | (vaddr & ~PAGE_MASK);
+               }
+       }
+       return 0;
+}
+
+/* Push n pages at kernel virtual address and clear the icache */
+/* RZ: use cpush %bc instead of cpush %dc, cinv %ic */
+void flush_icache_range(unsigned long address, unsigned long endaddr)
+{
+
+       if (CPU_IS_040_OR_060) {
+               address &= PAGE_MASK;
+
+               do {
+                       asm volatile ("nop\n\t"
+                                     ".chip 68040\n\t"
+                                     "cpushp %%bc,(%0)\n\t"
+                                     ".chip 68k"
+                                     : : "a" (virt_to_phys_slow(address)));
+                       address += PAGE_SIZE;
+               } while (address < endaddr);
+       } else {
+               unsigned long tmp;
+               asm volatile ("movec %%cacr,%0\n\t"
+                             "orw %1,%0\n\t"
+                             "movec %0,%%cacr"
+                             : "=&d" (tmp)
+                             : "di" (FLUSH_I));
+       }
+}
+EXPORT_SYMBOL(flush_icache_range);
+
+void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
+                            unsigned long addr, int len)
+{
+       if (CPU_IS_040_OR_060) {
+               asm volatile ("nop\n\t"
+                             ".chip 68040\n\t"
+                             "cpushp %%bc,(%0)\n\t"
+                             ".chip 68k"
+                             : : "a" (page_to_phys(page)));
+       } else {
+               unsigned long tmp;
+               asm volatile ("movec %%cacr,%0\n\t"
+                             "orw %1,%0\n\t"
+                             "movec %0,%%cacr"
+                             : "=&d" (tmp)
+                             : "di" (FLUSH_I));
+       }
+}
+
index 1453a6013721f1ac7bed4bf111add6fffe63f51b..559942ce0e1e7bde2773ac90f5150dca5e542e5e 100644 (file)
@@ -354,110 +354,6 @@ void cache_push (unsigned long paddr, int len)
 #endif
 }
 
-static unsigned long virt_to_phys_slow(unsigned long vaddr)
-{
-       if (CPU_IS_060) {
-               mm_segment_t fs = get_fs();
-               unsigned long paddr;
-
-               set_fs(get_ds());
-
-               /* The PLPAR instruction causes an access error if the translation
-                * is not possible. To catch this we use the same exception mechanism
-                * as for user space accesses in <asm/uaccess.h>. */
-               asm volatile (".chip 68060\n"
-                             "1: plpar (%0)\n"
-                             ".chip 68k\n"
-                             "2:\n"
-                             ".section .fixup,\"ax\"\n"
-                             "   .even\n"
-                             "3: sub.l %0,%0\n"
-                             "   jra 2b\n"
-                             ".previous\n"
-                             ".section __ex_table,\"a\"\n"
-                             "   .align 4\n"
-                             "   .long 1b,3b\n"
-                             ".previous"
-                             : "=a" (paddr)
-                             : "0" (vaddr));
-               set_fs(fs);
-               return paddr;
-       } else if (CPU_IS_040) {
-               mm_segment_t fs = get_fs();
-               unsigned long mmusr;
-
-               set_fs(get_ds());
-
-               asm volatile (".chip 68040\n\t"
-                             "ptestr (%1)\n\t"
-                             "movec %%mmusr, %0\n\t"
-                             ".chip 68k"
-                             : "=r" (mmusr)
-                             : "a" (vaddr));
-               set_fs(fs);
-
-               if (mmusr & MMU_R_040)
-                       return (mmusr & PAGE_MASK) | (vaddr & ~PAGE_MASK);
-       } else {
-               unsigned short mmusr;
-               unsigned long *descaddr;
-
-               asm volatile ("ptestr #5,%2@,#7,%0\n\t"
-                             "pmove %%psr,%1@"
-                             : "=a&" (descaddr)
-                             : "a" (&mmusr), "a" (vaddr));
-               if (mmusr & (MMU_I|MMU_B|MMU_L))
-                       return 0;
-               descaddr = phys_to_virt((unsigned long)descaddr);
-               switch (mmusr & MMU_NUM) {
-               case 1:
-                       return (*descaddr & 0xfe000000) | (vaddr & 0x01ffffff);
-               case 2:
-                       return (*descaddr & 0xfffc0000) | (vaddr & 0x0003ffff);
-               case 3:
-                       return (*descaddr & PAGE_MASK) | (vaddr & ~PAGE_MASK);
-               }
-       }
-       return 0;
-}
-
-/* Push n pages at kernel virtual address and clear the icache */
-/* RZ: use cpush %bc instead of cpush %dc, cinv %ic */
-void flush_icache_range(unsigned long address, unsigned long endaddr)
-{
-       if (CPU_IS_040_OR_060) {
-               address &= PAGE_MASK;
-
-               if (address >= PAGE_OFFSET && address < (unsigned long)high_memory) {
-                       do {
-                               asm volatile ("nop\n\t"
-                                             ".chip 68040\n\t"
-                                             "cpushp %%bc,(%0)\n\t"
-                                             ".chip 68k"
-                                             : : "a" (virt_to_phys((void *)address)));
-                               address += PAGE_SIZE;
-                       } while (address < endaddr);
-               } else {
-                       do {
-                               asm volatile ("nop\n\t"
-                                             ".chip 68040\n\t"
-                                             "cpushp %%bc,(%0)\n\t"
-                                             ".chip 68k"
-                                             : : "a" (virt_to_phys_slow(address)));
-                               address += PAGE_SIZE;
-                       } while (address < endaddr);
-               }
-       } else {
-               unsigned long tmp;
-               asm volatile ("movec %%cacr,%0\n\t"
-                             "orw %1,%0\n\t"
-                             "movec %0,%%cacr"
-                             : "=&d" (tmp)
-                             : "di" (FLUSH_I));
-       }
-}
-
-
 #ifndef CONFIG_SINGLE_MEMORY_CHUNK
 int mm_end_of_chunk (unsigned long addr, int len)
 {
index 117f183f0b43ce63d52f2f9537a7807b625edc71..8520df9cee6dd8c6cd9464b9d28bd23ee2292c83 100644 (file)
@@ -71,21 +71,31 @@ config M5206e
        help
          Motorola ColdFire 5206e processor support.
 
+config M523x
+       bool "MCF523x"
+       help
+         Freescale Coldfire 5230/1/2/4/5 processor support
+
 config M5249
        bool "MCF5249"
        help
          Motorola ColdFire 5249 processor support.
 
-config M527x
-       bool "MCF527x"
+config M5271
+       bool "MCF5271"
        help
-         Freescale (Motorola) ColdFire 5270/5271/5274/5275 processor support.
+         Freescale (Motorola) ColdFire 5270/5271 processor support.
 
 config M5272
        bool "MCF5272"
        help
          Motorola ColdFire 5272 processor support.
 
+config M5275
+       bool "MCF5275"
+       help
+         Freescale (Motorola) ColdFire 5274/5275 processor support.
+
 config M528x
        bool "MCF528x"
        help
@@ -103,9 +113,14 @@ config M5407
 
 endchoice
 
+config M527x
+       bool
+       depends on (M5271 || M5275)
+       default y
+
 config COLDFIRE
        bool
-       depends on (M5206 || M5206e || M5249 || M527x || M5272 || M528x || M5307 || M5407)
+       depends on (M5206 || M5206e || M523x || M5249 || M527x || M5272 || M528x || M5307 || M5407)
        default y
 
 choice
@@ -183,6 +198,11 @@ config CLOCK_60MHz
        help
          Select a 60MHz CPU clock frequency.
 
+config CLOCK_62_5MHz
+       bool "62.5MHz"
+       help
+         Select a 62.5MHz CPU clock frequency.
+
 config CLOCK_64MHz
        bool "64MHz"
        help
@@ -302,6 +322,12 @@ config ELITE
        help
          Support for the Motorola M5206eLITE board.
 
+config M5235EVB
+       bool "Freescale M5235EVB support"
+       depends on M523x
+       help
+         Support for the Freescale M5235EVB board.
+
 config M5249C3
        bool "Motorola M5249C3 board support"
        depends on M5249
@@ -310,13 +336,13 @@ config M5249C3
 
 config M5271EVB
        bool "Freescale (Motorola) M5271EVB board support"
-       depends on M527x
+       depends on M5271
        help
          Support for the Freescale (Motorola) M5271EVB board.
 
 config M5275EVB
        bool "Freescale (Motorola) M5275EVB board support"
-       depends on M527x
+       depends on M5275
        help
          Support for the Freescale (Motorola) M5275EVB board.
 
@@ -343,6 +369,12 @@ config COBRA5282
        depends on M528x
        help
          Support for the senTec COBRA5282 board.
+         
+config SOM5282EM
+       bool "EMAC.Inc SOM5282EM board support"
+       depends on M528x
+       help
+         Support for the EMAC.Inc SOM5282EM module.  
 
 config ARN5307
        bool "Arnewsh 5307 board support"
@@ -410,6 +442,12 @@ config CPU16B
        help
          Support for the SNEHA CPU16B board.
 
+config MOD5272
+       bool "Netburner MOD-5272 board support"
+       depends on M5272
+       help
+         Support for the Netburner MOD-5272 board.
+
 config ROMFS_FROM_ROM
        bool "  ROMFS image not RAM resident"
        depends on (NETtel || SNAPGEAR)
@@ -430,7 +468,7 @@ config ARNEWSH
 config MOTOROLA
        bool
        default y
-       depends on (M5206eC3 || M5249C3 || M5271EVB || M5272C3 || M5275EVB || M5282EVB || M5307C3 || M5407C3)
+       depends on (M5206eC3 || M5235EVB || M5249C3 || M5271EVB || M5272C3 || M5275EVB || M5282EVB || M5307C3 || M5407C3)
 
 config HW_FEITH
        bool
@@ -441,6 +479,11 @@ config senTec
        bool
        default y
        depends on (COBRA5272 || COBRA5282)
+       
+config EMAC_INC
+       bool
+       default y
+       depends on (SOM5282EM)
 
 config SNEHA
         bool
@@ -455,6 +498,15 @@ config LARGE_ALLOCS
          a lot of RAM, and you need to able to allocate very large
          contiguous chunks. If unsure, say N.
 
+config 4KSTACKS
+       bool "Use 4Kb for kernel stacks instead of 8Kb"
+       default y
+       help
+         If you say Y here the kernel will use a 4Kb stacksize for the
+         kernel stack attached to each process/thread. This facilitates
+         running more threads on a system and also reduces the pressure
+         on the VM subsystem for higher order allocations.
+
 choice
        prompt "RAM size"
        default AUTO
index a254aa9d49986eb2ff03137fa72bd96b99ba6949..7ce5e55b2401e40716faeaaf5fdacbe903cfea2f 100644 (file)
@@ -14,6 +14,7 @@ platform-$(CONFIG_M68VZ328)   := 68VZ328
 platform-$(CONFIG_M68360)      := 68360
 platform-$(CONFIG_M5206)       := 5206
 platform-$(CONFIG_M5206e)      := 5206e
+platform-$(CONFIG_M523x)       := 523x
 platform-$(CONFIG_M5249)       := 5249
 platform-$(CONFIG_M527x)       := 527x
 platform-$(CONFIG_M5272)       := 5272
@@ -29,6 +30,7 @@ board-$(CONFIG_UCQUICC)               := uCquicc
 board-$(CONFIG_DRAGEN2)                := de2
 board-$(CONFIG_ARNEWSH)                := ARNEWSH
 board-$(CONFIG_MOTOROLA)       := MOTOROLA
+board-$(CONFIG_M5235EVB)       := M5235EVB
 board-$(CONFIG_M5271EVB)       := M5271EVB
 board-$(CONFIG_M5275EVB)       := M5275EVB
 board-$(CONFIG_M5282EVB)       := M5282EVB
@@ -39,6 +41,7 @@ board-$(CONFIG_SECUREEDGEMP3) := MP3
 board-$(CONFIG_CLEOPATRA)      := CLEOPATRA
 board-$(CONFIG_senTec)         := senTec
 board-$(CONFIG_SNEHA)          := SNEHA
+board-$(CONFIG_MOD5272)                := MOD5272
 BOARD := $(board-y)
 
 model-$(CONFIG_RAMKERNEL)      := ram
@@ -53,6 +56,7 @@ MODEL := $(model-y)
 #
 cpuclass-$(CONFIG_M5206)       := 5307
 cpuclass-$(CONFIG_M5206e)      := 5307
+cpuclass-$(CONFIG_M523x)       := 5307
 cpuclass-$(CONFIG_M5249)       := 5307
 cpuclass-$(CONFIG_M527x)       := 5307
 cpuclass-$(CONFIG_M5272)       := 5307
@@ -76,6 +80,7 @@ export PLATFORM BOARD MODEL CPUCLASS
 #
 cflags-$(CONFIG_M5206)         := -m5200 -Wa,-S -Wa,-m5200
 cflags-$(CONFIG_M5206e)                := -m5200 -Wa,-S -Wa,-m5200
+cflags-$(CONFIG_M523x)         := -m5307 -Wa,-S -Wa,-m5307
 cflags-$(CONFIG_M5249)         := -m5200 -Wa,-S -Wa,-m5200
 cflags-$(CONFIG_M527x)         := -m5307 -Wa,-S -Wa,-m5307
 cflags-$(CONFIG_M5272)         := -m5307 -Wa,-S -Wa,-m5307
@@ -109,7 +114,7 @@ libs-y      += arch/m68knommu/lib/
 prepare: include/asm-$(ARCH)/asm-offsets.h
 
 archclean:
-       $(call descend arch/$(ARCH)/boot, subdirclean)
+       $(Q)$(MAKE) $(clean)=arch/m68knommu/boot
 
 include/asm-$(ARCH)/asm-offsets.h: arch/$(ARCH)/kernel/asm-offsets.s \
                                   include/asm include/linux/version.h \
index e4bd31be966a285cdf897369279d96344aa6b44a..87f2d6587c56f56cf757b7ff7df2dc5f4e6291df 100644 (file)
@@ -1,24 +1,48 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.13-uc0
+# Wed Aug 31 15:03:26 2005
 #
+CONFIG_M68KNOMMU=y
 # CONFIG_MMU is not set
 # CONFIG_FPU is not set
 CONFIG_UID16=y
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+CONFIG_GENERIC_CALIBRATE_DELAY=y
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
 
 #
 # General setup
 #
-# CONFIG_SYSVIPC is not set
+CONFIG_LOCALVERSION=""
+# CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
 # CONFIG_SYSCTL is not set
-CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_AUDIT is not set
+# CONFIG_HOTPLUG is not set
+# CONFIG_KOBJECT_UEVENT is not set
+# CONFIG_IKCONFIG is not set
+CONFIG_EMBEDDED=y
+# CONFIG_KALLSYMS is not set
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_BASE_FULL=y
+# CONFIG_FUTEX is not set
+# CONFIG_EPOLL is not set
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_BASE_SMALL=0
 
 #
 # Loadable module support
@@ -34,9 +58,11 @@ CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_M68360 is not set
 # CONFIG_M5206 is not set
 # CONFIG_M5206e is not set
+# CONFIG_M523x is not set
 # CONFIG_M5249 is not set
-# CONFIG_M527x is not set
+# CONFIG_M5271 is not set
 CONFIG_M5272=y
+# CONFIG_M5275 is not set
 # CONFIG_M528x is not set
 # CONFIG_M5307 is not set
 # CONFIG_M5407 is not set
@@ -54,6 +80,8 @@ CONFIG_COLDFIRE=y
 # CONFIG_CLOCK_50MHz is not set
 # CONFIG_CLOCK_54MHz is not set
 # CONFIG_CLOCK_60MHz is not set
+# CONFIG_CLOCK_62_5MHz is not set
+# CONFIG_CLOCK_64MHz is not set
 CONFIG_CLOCK_66MHz=y
 # CONFIG_CLOCK_70MHz is not set
 # CONFIG_CLOCK_100MHz is not set
@@ -65,13 +93,19 @@ CONFIG_CLOCK_66MHz=y
 # Platform
 #
 CONFIG_M5272C3=y
+# CONFIG_COBRA5272 is not set
+# CONFIG_CANCam is not set
+# CONFIG_SCALES is not set
 # CONFIG_NETtel is not set
+# CONFIG_CPU16B is not set
+# CONFIG_MOD5272 is not set
 CONFIG_MOTOROLA=y
 # CONFIG_LARGE_ALLOCS is not set
-# CONFIG_RAMAUTO is not set
+CONFIG_4KSTACKS=y
+CONFIG_RAMAUTO=y
 # CONFIG_RAM4MB is not set
 # CONFIG_RAM8MB is not set
-CONFIG_RAM16MB=y
+# CONFIG_RAM16MB is not set
 # CONFIG_RAM32MB is not set
 CONFIG_RAMAUTOBIT=y
 # CONFIG_RAM8BIT is not set
@@ -79,33 +113,117 @@ CONFIG_RAMAUTOBIT=y
 # CONFIG_RAM32BIT is not set
 CONFIG_RAMKERNEL=y
 # CONFIG_ROMKERNEL is not set
-# CONFIG_HIMEMKERNEL is not set
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
 
 #
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
 # CONFIG_PCI is not set
-# CONFIG_HOTPLUG is not set
+
+#
+# PCCARD (PCMCIA/CardBus) support
+#
+# CONFIG_PCCARD is not set
+
+#
+# PCI Hotplug Support
+#
 
 #
 # Executable file formats
 #
-CONFIG_KCORE_AOUT=y
 CONFIG_BINFMT_FLAT=y
 # CONFIG_BINFMT_ZFLAT is not set
+# CONFIG_BINFMT_SHARED_FLAT is not set
+# CONFIG_BINFMT_MISC is not set
 
 #
 # Power management options
 #
 # CONFIG_PM is not set
 
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+# CONFIG_IP_PNP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+# CONFIG_IP_TCPDIAG is not set
+# CONFIG_IP_TCPDIAG_IPV6 is not set
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_BIC=y
+# CONFIG_IPV6 is not set
+# CONFIG_NETFILTER is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_FW_LOADER is not set
+
 #
 # Memory Technology Devices (MTD)
 #
 CONFIG_MTD=y
 # CONFIG_MTD_DEBUG is not set
-CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_CONCAT is not set
+CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_REDBOOT_PARTS is not set
 # CONFIG_MTD_CMDLINE_PARTS is not set
 
@@ -116,35 +234,50 @@ CONFIG_MTD_CHAR=y
 CONFIG_MTD_BLOCK=y
 # CONFIG_FTL is not set
 # CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
 
 #
 # RAM/ROM/Flash chip drivers
 #
 # CONFIG_MTD_CFI is not set
 # CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
 CONFIG_MTD_RAM=y
 # CONFIG_MTD_ROM is not set
 # CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_OBSOLETE_CHIPS is not set
 
 #
 # Mapping drivers for chip access
 #
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
 CONFIG_MTD_UCLINUX=y
+# CONFIG_MTD_SNAPGEARuC is not set
+# CONFIG_MTD_PLATRAM is not set
 
 #
 # Self-contained MTD device drivers
 #
 # CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
 # CONFIG_MTD_BLKMTD is not set
+# CONFIG_MTD_BLOCK2MTD is not set
 
 #
 # Disk-On-Chip Device Drivers
 #
-# CONFIG_MTD_DOC1000 is not set
 # CONFIG_MTD_DOC2000 is not set
 # CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
 
 #
 # NAND Flash Device Drivers
@@ -159,21 +292,32 @@ CONFIG_MTD_UCLINUX=y
 #
 # Plug and Play support
 #
-# CONFIG_PNP is not set
 
 #
 # Block devices
 #
 # CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_DEV_COW_COMMON is not set
 # CONFIG_BLK_DEV_LOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
 CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=4096
 # CONFIG_BLK_DEV_INITRD is not set
-# CONFIG_BLK_DEV_BLKMEM is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
 
 #
-# ATA/IDE/MFM/RLL support
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+# CONFIG_IOSCHED_DEADLINE is not set
+# CONFIG_IOSCHED_CFQ is not set
+# CONFIG_ATA_OVER_ETH is not set
+
+#
+# ATA/ATAPI/MFM/RLL support
 #
 # CONFIG_IDE is not set
 
@@ -190,249 +334,230 @@ CONFIG_BLK_DEV_RAM_SIZE=4096
 #
 # Fusion MPT device support
 #
+# CONFIG_FUSION is not set
 
 #
-# I2O device support
-#
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK_DEV is not set
-# CONFIG_NETFILTER is not set
-# CONFIG_FILTER is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-# CONFIG_IP_PNP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_INET_ECN is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_XFRM_USER is not set
-# CONFIG_IPV6 is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
+# IEEE 1394 (FireWire) support
 #
-CONFIG_IPV6_SCTP__=y
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_LLC is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
 
 #
-# QoS and/or fair queueing
+# I2O device support
 #
-# CONFIG_NET_SCHED is not set
 
 #
-# Network testing
+# Network device support
 #
-# CONFIG_NET_PKTGEN is not set
 CONFIG_NETDEVICES=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
 
 #
 # Ethernet (10 or 100Mbit)
 #
 CONFIG_NET_ETHERNET=y
 # CONFIG_MII is not set
+# CONFIG_NET_VENDOR_SMC is not set
+# CONFIG_NE2000 is not set
+# CONFIG_NET_PCI is not set
 CONFIG_FEC=y
+# CONFIG_FEC2 is not set
 
 #
 # Ethernet (1000 Mbit)
 #
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
 CONFIG_PPP=y
 # CONFIG_PPP_MULTILINK is not set
+# CONFIG_PPP_FILTER is not set
 # CONFIG_PPP_ASYNC is not set
 # CONFIG_PPP_SYNC_TTY is not set
 # CONFIG_PPP_DEFLATE is not set
 # CONFIG_PPP_BSDCOMP is not set
 # CONFIG_PPPOE is not set
 # CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
 
 #
-# Wireless LAN (non-hamradio)
+# ISDN subsystem
 #
-# CONFIG_NET_RADIO is not set
+# CONFIG_ISDN is not set
 
 #
-# Token Ring devices (depends on LLC=y)
+# Telephony Support
 #
-# CONFIG_SHAPER is not set
+# CONFIG_PHONE is not set
 
 #
-# Wan interfaces
+# Input device support
 #
-# CONFIG_WAN is not set
+# CONFIG_INPUT is not set
 
 #
-# Amateur Radio support
+# Hardware I/O ports
 #
-# CONFIG_HAMRADIO is not set
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
 
 #
-# IrDA (infrared) support
+# Character devices
 #
-# CONFIG_IRDA is not set
+# CONFIG_VT is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+# CONFIG_LEDMAN is not set
+# CONFIG_RESETSWITCH is not set
 
 #
-# ISDN subsystem
+# Serial drivers
 #
-# CONFIG_ISDN_BOOL is not set
+# CONFIG_SERIAL_8250 is not set
 
 #
-# Telephony Support
+# Non-8250 serial port support
 #
-# CONFIG_PHONE is not set
+CONFIG_SERIAL_COLDFIRE=y
+# CONFIG_UNIX98_PTYS is not set
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
 
 #
-# Input device support
+# IPMI
 #
-CONFIG_INPUT=y
+# CONFIG_IPMI_HANDLER is not set
 
 #
-# Userland interfaces
+# Watchdog Cards
 #
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_EVBUG is not set
+# CONFIG_WATCHDOG is not set
+# CONFIG_MCFWATCHDOG is not set
+# CONFIG_RTC is not set
+# CONFIG_GEN_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
 
 #
-# Input I/O drivers
+# Ftape, the floppy tape device driver
 #
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-CONFIG_SERIO_I8042=y
-CONFIG_SERIO_SERPORT=y
-# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_RAW_DRIVER is not set
 
 #
-# Input Device Drivers
+# TPM devices
 #
-CONFIG_INPUT_KEYBOARD=y
-CONFIG_KEYBOARD_ATKBD=y
-# CONFIG_KEYBOARD_SUNKBD is not set
-# CONFIG_KEYBOARD_XTKBD is not set
-# CONFIG_KEYBOARD_NEWTON is not set
-CONFIG_INPUT_MOUSE=y
-CONFIG_MOUSE_PS2=y
-# CONFIG_MOUSE_SERIAL is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
+# CONFIG_MCF_QSPI is not set
+# CONFIG_M41T11M6 is not set
 
 #
-# Character devices
+# I2C support
 #
-# CONFIG_VT is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-# CONFIG_RESETSWITCH is not set
+# CONFIG_I2C is not set
+# CONFIG_I2C_SENSOR is not set
 
 #
-# Serial drivers
+# Dallas's 1-wire bus
 #
-# CONFIG_SERIAL_8250 is not set
+# CONFIG_W1 is not set
 
 #
-# Non-8250 serial port support
+# Hardware Monitoring support
 #
-CONFIG_SERIAL_COLDFIRE=y
-# CONFIG_UNIX98_PTYS is not set
+# CONFIG_HWMON is not set
 
 #
-# I2C support
+# Misc devices
 #
-# CONFIG_I2C is not set
 
 #
-# I2C Hardware Sensors Mainboard support
+# Multimedia devices
 #
+# CONFIG_VIDEO_DEV is not set
 
 #
-# I2C Hardware Sensors Chip support
+# Digital Video Broadcasting Devices
 #
+# CONFIG_DVB is not set
 
 #
-# Mice
+# Graphics support
 #
-# CONFIG_BUSMOUSE is not set
-# CONFIG_QIC02_TAPE is not set
+# CONFIG_FB is not set
 
 #
-# IPMI
+# SPI support
 #
-# CONFIG_IPMI_HANDLER is not set
+# CONFIG_SPI is not set
 
 #
-# Watchdog Cards
+# Sound
 #
-# CONFIG_WATCHDOG is not set
-# CONFIG_NVRAM is not set
-# CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
+# CONFIG_SOUND is not set
 
 #
-# Ftape, the floppy tape device driver
+# USB support
 #
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-# CONFIG_HANGCHECK_TIMER is not set
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
 
 #
-# Multimedia devices
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
+
+#
+# InfiniBand support
+#
+
+#
+# SN Devices
 #
-# CONFIG_VIDEO_DEV is not set
 
 #
 # File systems
 #
 CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
 # CONFIG_EXT3_FS is not set
 # CONFIG_JBD is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+
+#
+# XFS support
+#
 # CONFIG_XFS_FS is not set
 # CONFIG_MINIX_FS is not set
 CONFIG_ROMFS_FS=y
+CONFIG_MAGIC_ROM_PTR=y
+# CONFIG_INOTIFY is not set
 # CONFIG_QUOTA is not set
+# CONFIG_DNOTIFY is not set
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -445,15 +570,17 @@ CONFIG_ROMFS_FS=y
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
 # Pseudo filesystems
 #
 CONFIG_PROC_FS=y
-# CONFIG_DEVFS_FS is not set
+CONFIG_SYSFS=y
 # CONFIG_TMPFS is not set
+# CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
 #
@@ -462,6 +589,7 @@ CONFIG_RAMFS=y
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
@@ -479,12 +607,10 @@ CONFIG_RAMFS=y
 #
 # CONFIG_NFS_FS is not set
 # CONFIG_NFSD is not set
-# CONFIG_EXPORTFS is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
 # CONFIG_AFS_FS is not set
 
 #
@@ -494,30 +620,19 @@ CONFIG_RAMFS=y
 CONFIG_MSDOS_PARTITION=y
 
 #
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-
-#
-# Bluetooth support
+# Native Language Support
 #
-# CONFIG_BT is not set
+# CONFIG_NLS is not set
 
 #
 # Kernel hacking
 #
+# CONFIG_PRINTK_TIME is not set
+# CONFIG_DEBUG_KERNEL is not set
+CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_FULLDEBUG is not set
-# CONFIG_MAGIC_SYSRQ is not set
 # CONFIG_HIGHPROFILE is not set
+# CONFIG_BOOTPARAM is not set
 # CONFIG_DUMPTOFLASH is not set
 # CONFIG_NO_KERNEL_MSG is not set
 # CONFIG_BDM_DISABLE is not set
@@ -525,6 +640,7 @@ CONFIG_MSDOS_PARTITION=y
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
@@ -532,7 +648,13 @@ CONFIG_MSDOS_PARTITION=y
 #
 # CONFIG_CRYPTO is not set
 
+#
+# Hardware crypto devices
+#
+
 #
 # Library routines
 #
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
+# CONFIG_LIBCRC32C is not set
index 557238596dcb9bd14ad93e8f4c031296885d34db..a220345e9746d063ba2997ab3dc0544651b676e2 100644 (file)
@@ -6,7 +6,7 @@
  *  Copyleft  ()) 2000       James D. Schettine {james@telos-systems.com}
  *  Copyright (C) 1998       Kenneth Albanowski <kjahds@kjahds.com>
  *  Copyright (C) 1995       Hamish Macdonald
- *  Copyright (C) 2000       Lineo Inc. (www.lineo.com) 
+ *  Copyright (C) 2000       Lineo Inc. (www.lineo.com)
  *  Copyright (C) 2001              Lineo, Inc. <www.lineo.com>
  *
  *  68VZ328 Fixes/support    Evan Stawnyczy <e@lineo.ca>
@@ -23,6 +23,7 @@
 #include <linux/interrupt.h>
 #include <linux/fs.h>
 #include <linux/fb.h>
+#include <linux/module.h>
 #include <linux/console.h>
 #include <linux/genhd.h>
 #include <linux/errno.h>
@@ -45,6 +46,9 @@ unsigned long rom_length;
 unsigned long memory_start;
 unsigned long memory_end;
 
+EXPORT_SYMBOL(memory_start);
+EXPORT_SYMBOL(memory_end);
+
 char command_line[COMMAND_LINE_SIZE];
 
 /* setup some dummy routines */
@@ -103,15 +107,21 @@ void (*mach_power_off)( void ) = NULL;
 #if defined(CONFIG_M5206e)
        #define CPU "COLDFIRE(m5206e)"
 #endif
+#if defined(CONFIG_M523x)
+       #define CPU "COLDFIRE(m523x)"
+#endif
 #if defined(CONFIG_M5249)
        #define CPU "COLDFIRE(m5249)"
 #endif
-#if defined(CONFIG_M527x)
-       #define CPU "COLDFIRE(m5270/5271/5274/5275)"
+#if defined(CONFIG_M5271)
+       #define CPU "COLDFIRE(m5270/5271)"
 #endif
 #if defined(CONFIG_M5272)
        #define CPU "COLDFIRE(m5272)"
 #endif
+#if defined(CONFIG_M5275)
+       #define CPU "COLDFIRE(m5274/5275)"
+#endif
 #if defined(CONFIG_M528x)
        #define CPU "COLDFIRE(m5280/5282)"
 #endif
@@ -152,7 +162,7 @@ void setup_arch(char **cmdline_p)
        init_mm.start_code = (unsigned long) &_stext;
        init_mm.end_code = (unsigned long) &_etext;
        init_mm.end_data = (unsigned long) &_edata;
-       init_mm.brk = (unsigned long) 0; 
+       init_mm.brk = (unsigned long) 0;
 
        config_BSP(&command_line[0], sizeof(command_line));
 
@@ -171,7 +181,7 @@ void setup_arch(char **cmdline_p)
 #endif
 #ifdef CONFIG_ELITE
        printk(KERN_INFO "Modified for M5206eLITE by Rob Scott, rscott@mtrob.fdns.net\n");
-#endif  
+#endif
 #ifdef CONFIG_TELOS
        printk(KERN_INFO "Modified for Omnia ToolVox by James D. Schettine, james@telos-systems.com\n");
 #endif
@@ -200,6 +210,9 @@ void setup_arch(char **cmdline_p)
 #ifdef CONFIG_DRAGEN2
        printk(KERN_INFO "DragonEngine II board support by Georges Menie\n");
 #endif
+#ifdef CONFIG_M5235EVB
+       printk(KERN_INFO "Motorola M5235EVB support (C)2005 Syn-tech Systems, Inc. (Jate Sujjavanich)");
+#endif
 
 #ifdef DEBUG
        printk(KERN_DEBUG "KERNEL -> TEXT=0x%06x-0x%06x DATA=0x%06x-0x%06x "
@@ -223,7 +236,7 @@ void setup_arch(char **cmdline_p)
        saved_command_line[COMMAND_LINE_SIZE-1] = 0;
 
 #ifdef DEBUG
-       if (strlen(*cmdline_p)) 
+       if (strlen(*cmdline_p))
                printk(KERN_DEBUG "Command line: '%s'\n", *cmdline_p);
 #endif
 
index ad7dc6347f19092ec56f5fdf3a546ccda5a7836d..5bc06846286453e52f83a138244c07e5af1502e5 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/signal.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/module.h>
 #include <linux/types.h>
 #include <linux/a.out.h>
 #include <linux/user.h>
@@ -38,7 +39,7 @@
 #include <asm/machdep.h>
 #include <asm/siginfo.h>
 
-static char *vec_names[] = {
+static char const * const vec_names[] = {
        "RESET SP", "RESET PC", "BUS ERROR", "ADDRESS ERROR",
        "ILLEGAL INSTRUCTION", "ZERO DIVIDE", "CHK", "TRAPcc",
        "PRIVILEGE VIOLATION", "TRACE", "LINE 1010", "LINE 1111",
@@ -106,17 +107,20 @@ asmlinkage void buserr_c(struct frame *fp)
 
 int kstack_depth_to_print = 48;
 
-void show_stack(struct task_struct *task, unsigned long *esp)
+void show_stack(struct task_struct *task, unsigned long *stack)
 {
-       unsigned long *stack, *endstack, addr;
+       unsigned long *endstack, addr;
        extern char _start, _etext;
        int i;
 
-       if (esp == NULL)
-               esp = (unsigned long *) &esp;
+       if (!stack) {
+               if (task)
+                       stack = (unsigned long *)task->thread.ksp;
+               else
+                       stack = (unsigned long *)&stack;
+       }
 
-       stack = esp;
-       addr = (unsigned long) esp;
+       addr = (unsigned long) stack;
        endstack = (unsigned long *) PAGE_ALIGN(addr);
 
        printk(KERN_EMERG "Stack from %08lx:", (unsigned long)stack);
@@ -306,6 +310,8 @@ void dump_stack(void)
        show_stack(current, &stack);
 }
 
+EXPORT_SYMBOL(dump_stack);
+
 #ifdef CONFIG_M68KFPU_EMU
 asmlinkage void fpemu_signal(int signal, int code, void *addr)
 {
index 31cb12892da5a58e73ee0fe1a720e84d03964309..47f06787190dfb14491db3cb2c06376471acd6e1 100644 (file)
  */
 #if defined(CONFIG_ELITE)
 #define        RAM_START       0x30020000
-#define        RAM_END         0xe0000
+#define        RAM_LENGTH      0xe0000
 #endif
 
 /*
 #if defined(CONFIG_M5206eC3) || defined(CONFIG_M5249C3) || \
     defined(CONFIG_M5272C3) || defined(CONFIG_M5307C3) || \
     defined(CONFIG_ARN5307) || defined(CONFIG_M5407C3) || \
-    defined(CONFIG_M5271EVB) || defined(CONFIG_M5275EVB)
+    defined(CONFIG_M5271EVB) || defined(CONFIG_M5275EVB) || \
+    defined(CONFIG_M5235EVB)
 #define        RAM_START       0x20000
 #define        RAM_LENGTH      0x3e0000
 #endif
 #define  RAM_LENGTH  0x3f0000
 #endif
 
+
+/*
+ *     The EMAC SoM-5282EM module.
+ */
+#if defined(CONFIG_SOM5282EM)
+#define  RAM_START   0x10000
+#define  RAM_LENGTH  0xff0000
+#endif
+
+
 /*
  *     These flash boot boards use all of ram for operation. Again the
  *     actual memory size is not important here, assume at least 4MiB.
 #endif
 
 /*
- *     Sneha Boards mimimun memmory
+ *     Sneha Boards mimimun memory
  *     The end of RAM will vary depending on how much ram is fitted,
  *     but this isn't important here, we assume at least 4MiB.
  */
 #define        RAM_LENGTH      0x3e0000
 #endif
 
+#if defined(CONFIG_MOD5272)
+#define RAM_START      0x02000000
+#define RAM_LENGTH     0x00800000
+#define RAMVEC_START   0x20000000
+#define RAMVEC_LENGTH  0x00000400
+#endif
 
 #if defined(CONFIG_RAMKERNEL)
 #define        TEXT            ram
diff --git a/arch/m68knommu/platform/523x/config.c b/arch/m68knommu/platform/523x/config.c
new file mode 100644 (file)
index 0000000..22767ce
--- /dev/null
@@ -0,0 +1,82 @@
+/***************************************************************************/
+
+/*
+ *     linux/arch/m68knommu/platform/523x/config.c
+ *
+ *     Sub-architcture dependant initialization code for the Freescale
+ *     523x CPUs.
+ *
+ *     Copyright (C) 1999-2005, Greg Ungerer (gerg@snapgear.com)
+ *     Copyright (C) 2001-2003, SnapGear Inc. (www.snapgear.com)
+ */
+
+/***************************************************************************/
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/param.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <asm/dma.h>
+#include <asm/traps.h>
+#include <asm/machdep.h>
+#include <asm/coldfire.h>
+#include <asm/mcfsim.h>
+#include <asm/mcfdma.h>
+
+/***************************************************************************/
+
+void coldfire_pit_tick(void);
+void coldfire_pit_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
+unsigned long coldfire_pit_offset(void);
+void coldfire_trap_init(void);
+void coldfire_reset(void);
+
+/***************************************************************************/
+
+/*
+ *     DMA channel base address table.
+ */
+unsigned int   dma_base_addr[MAX_M68K_DMA_CHANNELS] = {
+        MCF_MBAR + MCFDMA_BASE0,
+};
+
+unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
+
+/***************************************************************************/
+
+void mcf_disableall(void)
+{
+       *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH)) = 0xffffffff;
+       *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL)) = 0xffffffff;
+}
+
+/***************************************************************************/
+
+void mcf_autovector(unsigned int vec)
+{
+       /* Everything is auto-vectored on the 5272 */
+}
+
+/***************************************************************************/
+
+void config_BSP(char *commandp, int size)
+{
+       mcf_disableall();
+
+#ifdef CONFIG_BOOTPARAM
+       strncpy(commandp, CONFIG_BOOTPARAM_STRING, size);
+       commandp[size-1] = 0;
+#else
+       memset(commandp, 0, size);
+#endif
+
+       mach_sched_init = coldfire_pit_init;
+       mach_tick = coldfire_pit_tick;
+       mach_gettimeoffset = coldfire_pit_offset;
+       mach_trap_init = coldfire_trap_init;
+       mach_reset = coldfire_reset;
+}
+
+/***************************************************************************/
index c7d7a395c4cc871e0d286dc73f0fe164eab0271c..7f4ba837901f6dfa74dd7e4cb2c64ee8f25f2316 100644 (file)
  *     Memory size exceptions for special cases. Some boards may be set
  *     for auto memory sizing, but we can't do it that way for some reason.
  *     For example the 5206eLITE board has static RAM, and auto-detecting
- *     the SDRAM will do you no good at all.
+ *     the SDRAM will do you no good at all. Same goes for the MOD5272.
  */
 #ifdef CONFIG_RAMAUTO
 #if defined(CONFIG_M5206eLITE)
-#define        MEM_SIZE        0x00100000              /* 1MiB default memory */
+#define        MEM_SIZE        0x00100000      /* 1MiB default memory */
+#endif
+#if defined(CONFIG_MOD5272)
+#define MEM_SIZE       0x00800000      /* 8MiB default memory */
 #endif
 #endif /* CONFIG_RAMAUTO */
 
+
 /*
  *     If we don't have a fixed memory size now, then lets build in code
  *     to auto detect the DRAM size. Obviously this is the prefered
 
 /*
  *     Most ColdFire boards have their DRAM starting at address 0.
- *     Notable exception is the 5206eLITE board.
+ *     Notable exception is the 5206eLITE board, another is the MOD5272.
  */
 #if defined(CONFIG_M5206eLITE)
 #define        MEM_BASE        0x30000000
 #endif
+#if defined(CONFIG_MOD5272)
+#define MEM_BASE       0x02000000
+#define VBR_BASE       0x20000000      /* vectors in SRAM */
+#endif
 
 #ifndef MEM_BASE
 #define        MEM_BASE        0x00000000      /* memory base at address 0 */
@@ -188,6 +196,7 @@ _start:
        movel   %a7,_rambase
 
        GET_MEM_SIZE                            /* macro code determines size */
+       addl    %a7,%d0
        movel   %d0,_ramend                     /* set end ram addr */
 
        /*
index 0f5d1fe8eb5fc99bc55e2496826c3129d8d4ca56..7d8990d784a2bf8f54ee63f39a2da0c9c6d752e5 100644 (file)
@@ -79,7 +79,7 @@ ENTRY(system_call)
        movel   %sp@(PT_ORIG_D0),%d0
 
        movel   %sp,%d1                 /* get thread_info pointer */
-       andl    #0xffffe000,%d1
+       andl    #-THREAD_SIZE,%d1
        movel   %d1,%a2
        btst    #TIF_SYSCALL_TRACE,%a2@(TI_FLAGS)
        jne     do_trace
@@ -105,7 +105,7 @@ Luser_return:
        andw    #ALLOWINT,%sr
 
        movel   %sp,%d1                 /* get thread_info pointer */
-       andl    #0xffffe000,%d1
+       andl    #-THREAD_SIZE,%d1
        movel   %d1,%a2
        move    %a2@(TI_FLAGS),%d1      /* thread_info->flags */
        andl    #_TIF_WORK_MASK,%d1
index f7bc80a60e0fe645ea6faa8a4e2cb6ceb5eb48f4..8ff48adf24abec4dbec33f1e8c395ff96ceaed1b 100644 (file)
@@ -96,7 +96,7 @@ Luser_return:
        andw    #ALLOWINT,%sr
 
        movel   %sp,%d1                 /* get thread_info pointer */
-       andl    #0xffffe000,%d1
+       andl    #-THREAD_SIZE,%d1
        movel   %d1,%a2
        move    %a2@(TI_FLAGS),%d1      /* thread_info->flags */
        andl    #_TIF_WORK_MASK,%d1
index 898de2df1fc761c35f67cb223d42e57110b9b45f..d79fba0aa8bf12657cdaab3e9946fdd884a76c7e 100644 (file)
@@ -4,26 +4,46 @@ config MIPS
        # Horrible source of confusion.  Die, die, die ...
        select EMBEDDED
 
-config MIPS64
-       bool "64-bit kernel"
-       help
-         Select this option if you want to build a 64-bit kernel.  You should
-         only select this option if you have hardware that actually has a
-         64-bit processor and if your application will actually benefit from
-         64-bit processing, otherwise say N.  You must say Y for kernels for
-         SGI IP27 (Origin 200 and 2000) and SGI IP32 (O2).  If in doubt say N.
+mainmenu "Linux/MIPS Kernel Configuration"
 
-config 64BIT
-       def_bool MIPS64
+source "init/Kconfig"
 
-config MIPS32
+config SYS_SUPPORTS_32BIT_KERNEL
+       bool
+config SYS_SUPPORTS_64BIT_KERNEL
+       bool
+config CPU_SUPPORTS_32BIT_KERNEL
+       bool
+config CPU_SUPPORTS_64BIT_KERNEL
        bool
-       depends on MIPS64 = 'n'
-       default y
 
-mainmenu "Linux/MIPS Kernel Configuration"
+menu "Kernel type"
 
-source "init/Kconfig"
+choice
+
+       prompt "Kernel code model"
+       help
+         You should only select this option if you have a workload that
+         actually benefits from 64-bit processing or if your machine has
+         large memory.  You will only be presented a single option in this
+         menu if your system does not support both 32-bit and 64-bit kernels.
+
+config 32BIT
+       bool "32-bit kernel"
+       depends on CPU_SUPPORTS_32BIT_KERNEL && SYS_SUPPORTS_32BIT_KERNEL
+       select TRAD_SIGNALS
+       help
+         Select this option if you want to build a 32-bit kernel.
+
+config 64BIT
+       bool "64-bit kernel"
+       depends on CPU_SUPPORTS_64BIT_KERNEL && SYS_SUPPORTS_64BIT_KERNEL
+       help
+         Select this option if you want to build a 64-bit kernel.
+
+endchoice
+
+endmenu
 
 menu "Machine selection"
 
@@ -34,6 +54,8 @@ config MACH_JAZZ
        select GENERIC_ISA_DMA
        select I8259
        select ISA
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
        help
         This a family of machines based on the MIPS R4030 chipset which was
         used by several vendors to build RISC/os and Windows NT workstations.
@@ -71,7 +93,9 @@ config OLIVETTI_M700
          <http://www.linux-mips.org/>.
 
 config MACH_VR41XX
-       bool "Support for NEC VR41XX-based machines"
+       bool "Support for NEC VR4100 series based machines"
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
 
 config NEC_CMBVR4133
        bool "Support for NEC CMB-VR4133"
@@ -80,7 +104,6 @@ config NEC_CMBVR4133
        select DMA_NONCOHERENT
        select IRQ_CPU
        select HW_HAS_PCI
-       select PCI_VR41XX
 
 config ROCKHOPPER
        bool "Support for Rockhopper baseboard"
@@ -91,6 +114,7 @@ config ROCKHOPPER
 config CASIO_E55
        bool "Support for CASIO CASSIOPEIA E-10/15/55/65"
        depends on MACH_VR41XX
+       select CPU_LITTLE_ENDIAN
        select DMA_NONCOHERENT
        select IRQ_CPU
        select ISA
@@ -98,53 +122,54 @@ config CASIO_E55
 config IBM_WORKPAD
        bool "Support for IBM WorkPad z50"
        depends on MACH_VR41XX
+       select CPU_LITTLE_ENDIAN
        select DMA_NONCOHERENT
        select IRQ_CPU
        select ISA
 
-config TANBAC_TB0226
-       bool "Support for TANBAC TB0226 (Mbase)"
+config TANBAC_TB022X
+       bool "Support for TANBAC VR4131 multichip module and TANBAC VR4131DIMM"
        depends on MACH_VR41XX
+       select CPU_LITTLE_ENDIAN
        select DMA_NONCOHERENT
-       select HW_HAS_PCI
        select IRQ_CPU
+       select HW_HAS_PCI
        help
-         The TANBAC TB0226 (Mbase) is a MIPS-based platform manufactured by TANBAC.
-         Please refer to <http://www.tanbac.co.jp/> about Mbase.
+         The TANBAC VR4131 multichip module(TB0225) and
+         the TANBAC VR4131DIMM(TB0229) are MIPS-based platforms
+         manufactured by TANBAC.
+         Please refer to <http://www.tanbac.co.jp/>
+         about VR4131 multichip module and VR4131DIMM.
 
-config TANBAC_TB0229
-       bool "Support for TANBAC TB0229 (VR4131DIMM)"
-       depends on MACH_VR41XX
-       select DMA_NONCOHERENT
-       select HW_HAS_PCI
-       select IRQ_CPU
+config TANBAC_TB0226
+       bool "Support for TANBAC Mbase(TB0226)"
+       depends on TANBAC_TB022X
+       select GPIO_VR41XX
        help
-         The TANBAC TB0229 (VR4131DIMM) is a MIPS-based platform manufactured by TANBAC.
-         Please refer to <http://www.tanbac.co.jp/> about VR4131DIMM.
+         The TANBAC Mbase(TB0226) is a MIPS-based platform manufactured by TANBAC.
+         Please refer to <http://www.tanbac.co.jp/> about Mbase.
 
 config VICTOR_MPC30X
        bool "Support for Victor MP-C303/304"
+       depends on MACH_VR41XX
+       select CPU_LITTLE_ENDIAN
        select DMA_NONCOHERENT
-       select HW_HAS_PCI
        select IRQ_CPU
-       depends on MACH_VR41XX
+       select HW_HAS_PCI
 
 config ZAO_CAPCELLA
        bool "Support for ZAO Networks Capcella"
        depends on MACH_VR41XX
+       select CPU_LITTLE_ENDIAN
        select DMA_NONCOHERENT
-       select HW_HAS_PCI
        select IRQ_CPU
+       select HW_HAS_PCI
 
 config PCI_VR41XX
        bool "Add PCI control unit support of NEC VR4100 series"
-       depends on MACH_VR41XX && PCI
-
-config VRC4171
-       tristate "Add NEC VRC4171 companion chip support"
-       depends on MACH_VR41XX && ISA
-       ---help---
-         The NEC VRC4171/4171A is a companion chip for NEC VR4111/VR4121.
+       depends on MACH_VR41XX && HW_HAS_PCI
+       default y
+       select PCI
 
 config VRC4173
        tristate "Add NEC VRC4173 companion chip support"
@@ -154,25 +179,28 @@ config VRC4173
 
 config TOSHIBA_JMR3927
        bool "Support for Toshiba JMR-TX3927 board"
-       depends on MIPS32
        select DMA_NONCOHERENT
        select HW_HAS_PCI
        select SWAP_IO_SPACE
+       select SYS_SUPPORTS_32BIT_KERNEL
 
 config MIPS_COBALT
-       bool "Support for Cobalt Server (EXPERIMENTAL)"
+       bool "Support for Cobalt Server"
        depends on EXPERIMENTAL
        select DMA_NONCOHERENT
        select HW_HAS_PCI
        select I8259
        select IRQ_CPU
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
 
 config MACH_DECSTATION
        bool "Support for DECstations"
        select BOOT_ELF32
        select DMA_NONCOHERENT
        select IRQ_CPU
-       depends on MIPS32 || EXPERIMENTAL
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
        ---help---
          This enables support for DEC's MIPS based workstations.  For details
          see the Linux/MIPS FAQ on <http://www.linux-mips.org/> and the
@@ -194,6 +222,8 @@ config MIPS_EV64120
        select DMA_NONCOHERENT
        select HW_HAS_PCI
        select MIPS_GT64120
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL
        help
          This is an evaluation board based on the Galileo GT-64120
          single-chip system controller that contains a MIPS R5000 compatible
@@ -214,6 +244,8 @@ config MIPS_EV96100
        select MIPS_GT96100
        select RM7000_CPU_SCACHE
        select SWAP_IO_SPACE
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL
        help
          This is an evaluation board based on the Galileo GT-96100 LAN/WAN
          communications controllers containing a MIPS R5000 compatible core
@@ -224,6 +256,8 @@ config MIPS_IVR
        bool "Support for Globespan IVR board"
        select DMA_NONCOHERENT
        select HW_HAS_PCI
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
        help
          This is an evaluation board built by Globespan to showcase thir
          iVR (Internet Video Recorder) design. It utilizes a QED RM5231
@@ -237,6 +271,8 @@ config LASAT
        select HW_HAS_PCI
        select MIPS_GT64120
        select R5000_CPU_SCACHE
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
 
 config PICVUE
        tristate "PICVUE LCD display driver"
@@ -258,6 +294,8 @@ config MIPS_ITE8172
        bool "Support for ITE 8172G board"
        select DMA_NONCOHERENT
        select HW_HAS_PCI
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
        help
          Ths is an evaluation board made by ITE <http://www.ite.com.tw/>
          with ATX form factor that utilizes a MIPS R5000 to work with its
@@ -281,6 +319,8 @@ config MIPS_ATLAS
        select HW_HAS_PCI
        select MIPS_GT64120
        select SWAP_IO_SPACE
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL
        help
          This enables support for the QED R5231-based MIPS Atlas evaluation
          board.
@@ -295,6 +335,8 @@ config MIPS_MALTA
        select I8259
        select MIPS_GT64120
        select SWAP_IO_SPACE
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL
        help
          This enables support for the VR5000-based MIPS Malta evaluation
          board.
@@ -304,6 +346,8 @@ config MIPS_SEAD
        depends on EXPERIMENTAL
        select IRQ_CPU
        select DMA_NONCOHERENT
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL
 
 config MOMENCO_OCELOT
        bool "Support for Momentum Ocelot board"
@@ -314,6 +358,8 @@ config MOMENCO_OCELOT
        select MIPS_GT64120
        select RM7000_CPU_SCACHE
        select SWAP_IO_SPACE
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL
        help
          The Ocelot is a MIPS-based Single Board Computer (SBC) made by
          Momentum Computer <http://www.momenco.com/>.
@@ -327,6 +373,8 @@ config MOMENCO_OCELOT_G
        select PCI_MARVELL
        select RM7000_CPU_SCACHE
        select SWAP_IO_SPACE
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL
        help
          The Ocelot is a MIPS-based Single Board Computer (SBC) made by
          Momentum Computer <http://www.momenco.com/>.
@@ -340,6 +388,8 @@ config MOMENCO_OCELOT_C
        select PCI_MARVELL
        select RM7000_CPU_SCACHE
        select SWAP_IO_SPACE
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL
        help
          The Ocelot is a MIPS-based Single Board Computer (SBC) made by
          Momentum Computer <http://www.momenco.com/>.
@@ -355,6 +405,8 @@ config MOMENCO_OCELOT_3
        select PCI_MARVELL
        select RM7000_CPU_SCACHE
        select SWAP_IO_SPACE
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL
        help
          The Ocelot-3 is based off Discovery III System Controller and
          PMC-Sierra Rm79000 core.
@@ -371,6 +423,8 @@ config MOMENCO_JAGUAR_ATX
        select PCI_MARVELL
        select RM7000_CPU_SCACHE
        select SWAP_IO_SPACE
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL
        help
          The Jaguar ATX is a MIPS-based Single Board Computer (SBC) made by
          Momentum Computer <http://www.momenco.com/>.
@@ -390,6 +444,8 @@ config PMC_YOSEMITE
        select IRQ_CPU_RM7K
        select IRQ_CPU_RM9K
        select SWAP_IO_SPACE
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL
        help
          Yosemite is an evaluation board for the RM9000x2 processor
          manufactured by PMC-Sierra
@@ -407,6 +463,8 @@ config DDB5074
        select IRQ_CPU
        select I8259
        select ISA
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL
        help
          This enables support for the VR5000-based NEC DDB Vrc-5074
          evaluation board.
@@ -419,6 +477,8 @@ config DDB5476
        select IRQ_CPU
        select I8259
        select ISA
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
        help
          This enables support for the R5432-based NEC DDB Vrc-5476
          evaluation board.
@@ -433,6 +493,8 @@ config DDB5477
        select HW_HAS_PCI
        select I8259
        select IRQ_CPU
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
        help
          This enables support for the R5432-based NEC DDB Vrc-5477,
          or Rockhopper/SolutionGear boards with R5432/R5500 CPUs.
@@ -445,10 +507,23 @@ config DDB5477_BUS_FREQUENCY
        depends on DDB5477
        default 0
 
-config NEC_OSPREY
-       bool "Support for NEC Osprey board"
-       select DMA_NONCOHERENT
-       select IRQ_CPU
+config QEMU
+       bool "Support for Qemu"
+       select DMA_COHERENT
+       select GENERIC_ISA_DMA
+       select HAVE_STD_PC_SERIAL_PORT
+       select I8259
+       select ISA
+       select SWAP_IO_SPACE
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_BIG_ENDIAN
+       help
+        Qemu is a software emulator which among other architectures also
+        can simulate a MIPS32 4Kc system.  This patch adds support for the
+        system architecture that currently is being simulated by Qemu.  It
+        will eventually be removed again when Qemu has the capability to
+        simulate actual MIPS hardware platforms.  More information on Qemu
+        can be found at http://www.linux-mips.org/wiki/Qemu.
 
 config SGI_IP22
        bool "Support for SGI IP22 (Indy/Indigo2)"
@@ -459,6 +534,8 @@ config SGI_IP22
        select IP22_CPU_SCACHE
        select IRQ_CPU
        select SWAP_IO_SPACE
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL
        help
          This are the SGI Indy, Challenge S and Indigo2, as well as certain
          OEM variants like the Tandem CMN B006S. To compile a Linux kernel
@@ -466,12 +543,12 @@ config SGI_IP22
 
 config SGI_IP27
        bool "Support for SGI IP27 (Origin200/2000)"
-       depends on MIPS64
        select ARC
        select ARC64
        select DMA_IP27
        select HW_HAS_PCI
        select PCI_DOMAINS
+       select SYS_SUPPORTS_64BIT_KERNEL
        help
          This are the SGI Origin 200, Origin 2000 and Onyx 2 Graphics
          workstations.  To compile a Linux kernel that runs on these, say Y
@@ -534,7 +611,7 @@ config REPLICATE_EXHANDLERS
 
 config SGI_IP32
        bool "Support for SGI IP32 (O2) (EXPERIMENTAL)"
-       depends on MIPS64 && EXPERIMENTAL
+       depends on EXPERIMENTAL
        select ARC
        select ARC32
        select BOOT_ELF32
@@ -544,12 +621,13 @@ config SGI_IP32
        select HW_HAS_PCI
        select R5000_CPU_SCACHE
        select RM7000_CPU_SCACHE
+       select SYS_SUPPORTS_64BIT_KERNEL
        help
          If you want this kernel to run on SGI O2 workstation, say Y here.
 
 config SOC_AU1X00
-       depends on MIPS32
        bool "Support for AMD/Alchemy Au1X00 SOCs"
+       select SYS_SUPPORTS_32BIT_KERNEL
 
 choice
        prompt "Au1X00 SOC Type"
@@ -661,6 +739,8 @@ config SIBYTE_SB1xxx_SOC
        select BOOT_ELF32
        select DMA_COHERENT
        select SWAP_IO_SPACE
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL
 
 choice
        prompt "BCM1xxx SOC-based board"
@@ -880,6 +960,8 @@ config SNI_RM200_PCI
        select HW_HAS_PCI
        select I8259
        select ISA
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
        help
          The SNI RM200 PCI was a MIPS-based platform manufactured by Siemens
          Nixdorf Informationssysteme (SNI), parent company of Pyramid
@@ -888,13 +970,14 @@ config SNI_RM200_PCI
 
 config TOSHIBA_RBTX4927
        bool "Support for Toshiba TBTX49[23]7 board"
-       depends on MIPS32
        select DMA_NONCOHERENT
        select HAS_TXX9_SERIAL
        select HW_HAS_PCI
        select I8259
        select ISA
        select SWAP_IO_SPACE
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL
        help
          This Toshiba board is based on the TX4927 processor. Say Y here to
          support this machine type
@@ -926,13 +1009,21 @@ config ARC
        depends on SNI_RM200_PCI || SGI_IP32 || SGI_IP27 || SGI_IP22 || MIPS_MAGNUM_4000 || OLIVETTI_M700 || ACER_PICA_61
        default y
 
-config DMA_COHERENT
+config DMA_COHERENT
+       bool
+
+config DMA_IP27
        bool
 
-config DMA_IP27
+config DMA_IP32
        bool
+       select DMA_NEED_PCI_MAP_STATE
 
-config DMA_NONCOHERENT
+config DMA_NONCOHERENT
+       bool
+       select DMA_NEED_PCI_MAP_STATE
+
+config DMA_NEED_PCI_MAP_STATE
        bool
 
 config EARLY_PRINTK
@@ -974,7 +1065,7 @@ config MIPS_DISABLE_OBSOLETE_IDE
 
 config CPU_LITTLE_ENDIAN
        bool "Generate little endian code"
-       default y if ACER_PICA_61 || CASIO_E55 || DDB5074 || DDB5476 || DDB5477 || MACH_DECSTATION || IBM_WORKPAD || LASAT || MIPS_COBALT || MIPS_ITE8172 || MIPS_IVR || SOC_AU1X00 || NEC_OSPREY || OLIVETTI_M700 || SNI_RM200_PCI || VICTOR_MPC30X || ZAO_CAPCELLA
+       default y if ACER_PICA_61 || CASIO_E55 || DDB5074 || DDB5476 || DDB5477 || MACH_DECSTATION || IBM_WORKPAD || LASAT || MIPS_COBALT || MIPS_ITE8172 || MIPS_IVR || SOC_AU1X00 || OLIVETTI_M700 || SNI_RM200_PCI || VICTOR_MPC30X || ZAO_CAPCELLA
        default n if MIPS_EV64120 || MIPS_EV96100 || MOMENCO_OCELOT || MOMENCO_OCELOT_G || SGI_IP22 || SGI_IP27 || SGI_IP32 || TOSHIBA_JMR3927
        help
          Some MIPS machines can be configured for either little or big endian
@@ -1091,11 +1182,6 @@ config ARC32
 config HAVE_STD_PC_SERIAL_PORT
        bool
 
-config VR4181
-       bool
-       depends on NEC_OSPREY
-       default y
-
 config ARC_CONSOLE
        bool "ARC console support"
        depends on SGI_IP22 || SNI_RM200_PCI
@@ -1145,13 +1231,16 @@ choice
 
 config CPU_MIPS32
        bool "MIPS32"
+       select CPU_SUPPORTS_32BIT_KERNEL
 
 config CPU_MIPS64
        bool "MIPS64"
+       select CPU_SUPPORTS_32BIT_KERNEL
+       select CPU_SUPPORTS_64BIT_KERNEL
 
 config CPU_R3000
        bool "R3000"
-       depends on MIPS32
+       select CPU_SUPPORTS_32BIT_KERNEL
        help
          Please make sure to pick the right CPU type. Linux/MIPS is not
          designed to be generic, i.e. Kernels compiled for R3000 CPUs will
@@ -1162,10 +1251,12 @@ config CPU_R3000
 
 config CPU_TX39XX
        bool "R39XX"
-       depends on MIPS32
+       select CPU_SUPPORTS_32BIT_KERNEL
 
 config CPU_VR41XX
        bool "R41xx"
+       select CPU_SUPPORTS_32BIT_KERNEL
+       select CPU_SUPPORTS_64BIT_KERNEL
        help
          The options selects support for the NEC VR41xx series of processors.
          Only choose this option if you have one of these processors as a
@@ -1174,20 +1265,28 @@ config CPU_VR41XX
 
 config CPU_R4300
        bool "R4300"
+       select CPU_SUPPORTS_32BIT_KERNEL
+       select CPU_SUPPORTS_64BIT_KERNEL
        help
          MIPS Technologies R4300-series processors.
 
 config CPU_R4X00
        bool "R4x00"
+       select CPU_SUPPORTS_32BIT_KERNEL
+       select CPU_SUPPORTS_64BIT_KERNEL
        help
          MIPS Technologies R4000-series processors other than 4300, including
          the R4000, R4400, R4600, and 4700.
 
 config CPU_TX49XX
        bool "R49XX"
+       select CPU_SUPPORTS_32BIT_KERNEL
+       select CPU_SUPPORTS_64BIT_KERNEL
 
 config CPU_R5000
        bool "R5000"
+       select CPU_SUPPORTS_32BIT_KERNEL
+       select CPU_SUPPORTS_64BIT_KERNEL
        help
          MIPS Technologies R5000-series processors other than the Nevada.
 
@@ -1196,36 +1295,48 @@ config CPU_R5432
 
 config CPU_R6000
        bool "R6000"
-       depends on MIPS32 && EXPERIMENTAL
+       depends on EXPERIMENTAL
+       select CPU_SUPPORTS_32BIT_KERNEL
        help
          MIPS Technologies R6000 and R6000A series processors.  Note these
          processors are extremly rare and the support for them is incomplete.
 
 config CPU_NEVADA
        bool "RM52xx"
+       select CPU_SUPPORTS_32BIT_KERNEL
+       select CPU_SUPPORTS_64BIT_KERNEL
        help
          QED / PMC-Sierra RM52xx-series ("Nevada") processors.
 
 config CPU_R8000
        bool "R8000"
-       depends on MIPS64 && EXPERIMENTAL
+       depends on EXPERIMENTAL
+       select CPU_SUPPORTS_64BIT_KERNEL
        help
          MIPS Technologies R8000 processors.  Note these processors are
          uncommon and the support for them is incomplete.
 
 config CPU_R10000
        bool "R10000"
+       select CPU_SUPPORTS_32BIT_KERNEL
+       select CPU_SUPPORTS_64BIT_KERNEL
        help
          MIPS Technologies R10000-series processors.
 
 config CPU_RM7000
        bool "RM7000"
+       select CPU_SUPPORTS_32BIT_KERNEL
+       select CPU_SUPPORTS_64BIT_KERNEL
 
 config CPU_RM9000
        bool "RM9000"
+       select CPU_SUPPORTS_32BIT_KERNEL
+       select CPU_SUPPORTS_64BIT_KERNEL
 
 config CPU_SB1
        bool "SB1"
+       select CPU_SUPPORTS_32BIT_KERNEL
+       select CPU_SUPPORTS_64BIT_KERNEL
 
 endchoice
 
@@ -1321,11 +1432,11 @@ config SB1_PASS_2_1_WORKAROUNDS
 
 config 64BIT_PHYS_ADDR
        bool "Support for 64-bit physical address space"
-       depends on (CPU_R4X00 || CPU_R5000 || CPU_RM7000 || CPU_RM9000 || CPU_R10000 || CPU_SB1 || CPU_MIPS32 || CPU_MIPS64) && MIPS32
+       depends on (CPU_R4X00 || CPU_R5000 || CPU_RM7000 || CPU_RM9000 || CPU_R10000 || CPU_SB1 || CPU_MIPS32 || CPU_MIPS64) && 32BIT
 
 config CPU_ADVANCED
        bool "Override CPU Options"
-       depends on MIPS32
+       depends on 32BIT
        help
          Saying yes here allows you to select support for various features
          your CPU may or may not have.  Most people should say N here.
@@ -1379,7 +1490,7 @@ config CPU_HAS_SYNC
 #
 config HIGHMEM
        bool "High Memory Support"
-       depends on MIPS32 && (CPU_R3000 || CPU_SB1 || CPU_R7000 || CPU_RM9000 || CPU_R10000) && !(MACH_DECSTATION || MOMENCO_JAGUAR_ATX)
+       depends on 32BIT && (CPU_R3000 || CPU_SB1 || CPU_R7000 || CPU_RM9000 || CPU_R10000) && !(MACH_DECSTATION || MOMENCO_JAGUAR_ATX)
 
 config ARCH_FLATMEM_ENABLE
        def_bool y
@@ -1439,7 +1550,7 @@ config RTC_DS1742
 
 config MIPS_INSANE_LARGE
        bool "Support for large 64-bit configurations"
-       depends on CPU_R10000 && MIPS64
+       depends on CPU_R10000 && 64BIT
        help
          MIPS R10000 does support a 44 bit / 16TB address space as opposed to
          previous 64-bit processors which only supported 40 bit / 1TB. If you
@@ -1540,11 +1651,11 @@ source "fs/Kconfig.binfmt"
 
 config TRAD_SIGNALS
        bool
-       default y if MIPS32
+       default y if 32BIT
 
 config BUILD_ELF64
        bool "Use 64-bit ELF format for building"
-       depends on MIPS64
+       depends on 64BIT
        help
          A 64-bit kernel is usually built using the 64-bit ELF binary object
          format as it's one that allows arbitrary 64-bit constructs.  For
@@ -1559,11 +1670,11 @@ config BUILD_ELF64
 
 config BINFMT_IRIX
        bool "Include IRIX binary compatibility"
-       depends on !CPU_LITTLE_ENDIAN && MIPS32 && BROKEN
+       depends on !CPU_LITTLE_ENDIAN && 32BIT && BROKEN
 
 config MIPS32_COMPAT
        bool "Kernel support for Linux/MIPS 32-bit binary compatibility"
-       depends on MIPS64
+       depends on 64BIT
        help
          Select this option if you want Linux/MIPS 32-bit binary
          compatibility. Since all software available for Linux/MIPS is
index bc1c44274a58a4f5e165d35384b1af13d08c8af1..b0fdaee8d8d95228a810f23ed680e7134022f4ee 100644 (file)
@@ -37,12 +37,12 @@ else
 64bit-emul             = elf64btsmip
 endif
 
-ifdef CONFIG_MIPS32
+ifdef CONFIG_32BIT
 gcc-abi                        = 32
 tool-prefix            = $(32bit-tool-prefix)
 UTS_MACHINE            := mips
 endif
-ifdef CONFIG_MIPS64
+ifdef CONFIG_64BIT
 gcc-abi                        = 64
 tool-prefix            = $(64bit-tool-prefix)
 UTS_MACHINE            := mips64
@@ -63,7 +63,7 @@ ld-emul                       = $(32bit-emul)
 vmlinux-32             = vmlinux
 vmlinux-64             = vmlinux.64
 
-cflags-$(CONFIG_MIPS64)        += $(call cc-option,-mno-explicit-relocs)
+cflags-$(CONFIG_64BIT) += $(call cc-option,-mno-explicit-relocs)
 endif
 
 #
@@ -177,7 +177,7 @@ cflags-$(CONFIG_CPU_MIPS64) += \
 
 cflags-$(CONFIG_CPU_R5000)     += \
                        $(call set_gccflags,r5000,mips4,r5000,mips4,mips2) \
-                       -Wa,--trap 
+                       -Wa,--trap
 
 cflags-$(CONFIG_CPU_R5432)     += \
                        $(call set_gccflags,r5400,mips4,r5000,mips4,mips2) \
@@ -423,6 +423,12 @@ core-$(CONFIG_PMC_YOSEMITE)        += arch/mips/pmc-sierra/yosemite/
 cflags-$(CONFIG_PMC_YOSEMITE)  += -Iinclude/asm-mips/mach-yosemite
 load-$(CONFIG_PMC_YOSEMITE)    += 0xffffffff80100000
 
+# Qemu simulating MIPS32 4Kc
+#
+core-$(CONFIG_QEMU)            += arch/mips/qemu/
+cflags-$(CONFIG_QEMU)          += -Iinclude/asm-mips/mach-qemu
+load-$(CONFIG_QEMU)            += 0xffffffff80010000
+
 #
 # Momentum Ocelot-3
 #
@@ -468,13 +474,6 @@ core-$(CONFIG_LASAT)               += arch/mips/lasat/
 cflags-$(CONFIG_LASAT)         += -Iinclude/asm-mips/mach-lasat
 load-$(CONFIG_LASAT)           += 0xffffffff80000000
 
-#
-# NEC Osprey (vr4181) board
-#
-core-$(CONFIG_NEC_OSPREY)      += arch/mips/vr4181/common/ \
-                                  arch/mips/vr4181/osprey/
-load-$(CONFIG_NEC_OSPREY)      += 0xffffffff80002000
-
 #
 # Common VR41xx
 #
@@ -490,13 +489,11 @@ load-$(CONFIG_NEC_CMBVR4133)      += 0xffffffff80100000
 #
 # ZAO Networks Capcella (VR4131)
 #
-core-$(CONFIG_ZAO_CAPCELLA)    += arch/mips/vr41xx/zao-capcella/
 load-$(CONFIG_ZAO_CAPCELLA)    += 0xffffffff80000000
 
 #
 # Victor MP-C303/304 (VR4122)
 #
-core-$(CONFIG_VICTOR_MPC30X)   += arch/mips/vr41xx/victor-mpc30x/
 load-$(CONFIG_VICTOR_MPC30X)   += 0xffffffff80001000
 
 #
@@ -512,16 +509,9 @@ core-$(CONFIG_CASIO_E55)   += arch/mips/vr41xx/casio-e55/
 load-$(CONFIG_CASIO_E55)       += 0xffffffff80004000
 
 #
-# TANBAC TB0226 Mbase (VR4131)
-#
-core-$(CONFIG_TANBAC_TB0226)   += arch/mips/vr41xx/tanbac-tb0226/
-load-$(CONFIG_TANBAC_TB0226)   += 0xffffffff80000000
-
-#
-# TANBAC TB0229 VR4131DIMM (VR4131)
+# TANBAC VR4131 multichip module(TB0225) and TANBAC VR4131DIMM(TB0229) (VR4131)
 #
-core-$(CONFIG_TANBAC_TB0229)   += arch/mips/vr41xx/tanbac-tb0229/
-load-$(CONFIG_TANBAC_TB0229)   += 0xffffffff80000000
+load-$(CONFIG_TANBAC_TB022X)   += 0xffffffff80000000
 
 #
 # SGI IP22 (Indy/Indigo2)
@@ -534,10 +524,10 @@ load-$(CONFIG_TANBAC_TB0229)      += 0xffffffff80000000
 #
 core-$(CONFIG_SGI_IP22)                += arch/mips/sgi-ip22/
 cflags-$(CONFIG_SGI_IP22)      += -Iinclude/asm-mips/mach-ip22
-ifdef CONFIG_MIPS32
+ifdef CONFIG_32BIT
 load-$(CONFIG_SGI_IP22)                += 0xffffffff88002000
 endif
-ifdef CONFIG_MIPS64
+ifdef CONFIG_64BIT
 load-$(CONFIG_SGI_IP22)                += 0xffffffff88004000
 endif
 
@@ -642,7 +632,7 @@ load-$(CONFIG_TOSHIBA_RBTX4927)     += 0xffffffff80020000
 cflags-y                       += -Iinclude/asm-mips/mach-generic
 drivers-$(CONFIG_PCI)          += arch/mips/pci/
 
-ifdef CONFIG_MIPS32
+ifdef CONFIG_32BIT
 ifdef CONFIG_CPU_LITTLE_ENDIAN
 JIFFIES                        = jiffies_64
 else
@@ -674,8 +664,8 @@ CPPFLAGS_vmlinux.lds := \
 head-y := arch/mips/kernel/head.o arch/mips/kernel/init_task.o
 
 libs-y                 += arch/mips/lib/
-libs-$(CONFIG_MIPS32)  += arch/mips/lib-32/
-libs-$(CONFIG_MIPS64)  += arch/mips/lib-64/
+libs-$(CONFIG_32BIT)   += arch/mips/lib-32/
+libs-$(CONFIG_64BIT)   += arch/mips/lib-64/
 
 core-y                 += arch/mips/kernel/ arch/mips/mm/ arch/mips/math-emu/
 
@@ -683,7 +673,7 @@ drivers-$(CONFIG_OPROFILE)  += arch/mips/oprofile/
 
 ifdef CONFIG_LASAT
 rom.bin rom.sw: vmlinux
-       $(call descend,arch/mips/lasat/image,$@)
+       $(Q)$(MAKE) $(build)=arch/mips/lasat/image $@
 endif
 
 #
@@ -730,7 +720,7 @@ archclean:
        @$(MAKE) $(clean)=arch/mips/boot
        @$(MAKE) $(clean)=arch/mips/lasat
 
-# Generate <asm/offset.h 
+# Generate <asm/offset.h
 #
 # The default rule is suffering from funny problems on MIPS so we using our
 # own ...
index 533721eef6ae3f36b580a2b4605c94d224143851..4e5a6e1a9a6ed1313baccf87b20d380702da3713 100644 (file)
 
 /* TBD */
 static struct resource pci_io_resource = {
-       "pci IO space", 
+       "pci IO space",
        (u32)PCI_IO_START,
        (u32)PCI_IO_END,
        IORESOURCE_IO
 };
 
 static struct resource pci_mem_resource = {
-       "pci memory space", 
+       "pci memory space",
        (u32)PCI_MEM_START,
        (u32)PCI_MEM_END,
        IORESOURCE_MEM
@@ -68,7 +68,7 @@ static unsigned long virt_io_addr;
 static int __init au1x_pci_setup(void)
 {
 #if defined(CONFIG_SOC_AU1500) || defined(CONFIG_SOC_AU1550)
-       virt_io_addr = (unsigned long)ioremap(Au1500_PCI_IO_START, 
+       virt_io_addr = (unsigned long)ioremap(Au1500_PCI_IO_START,
                        Au1500_PCI_IO_END - Au1500_PCI_IO_START + 1);
 
        if (!virt_io_addr) {
@@ -77,7 +77,7 @@ static int __init au1x_pci_setup(void)
        }
 
 #ifdef CONFIG_DMA_NONCOHERENT
-       /* 
+       /*
          *  Set the NC bit in controller for Au1500 pre-AC silicon
         */
        u32 prid = read_c0_prid();
index dbc8b1bda9637efd339ebd70c97d72c20b87e161..eff89e109ce69f8648a414c54ac82f73237b80f0 100644 (file)
@@ -97,7 +97,7 @@ static int __init au1x00_setup(void)
                argptr = prom_getcmdline();
                strcat(argptr, " console=ttyS0,115200");
        }
-#endif   
+#endif
 
 #ifdef CONFIG_FB_AU1100
     if ((argptr = strstr(argptr, "video=")) == NULL) {
index fe418f1620c3b62245352ed2259be0d086cf3bf0..57675b41480e89b99ffd179e9d66e03378ebfb8b 100644 (file)
@@ -281,7 +281,7 @@ unsigned long cal_r4koff(void)
                        cpu_speed = count * 2;
                }
 #else
-               cpu_speed = (au_readl(SYS_CPUPLL) & 0x0000003f) * 
+               cpu_speed = (au_readl(SYS_CPUPLL) & 0x0000003f) *
                        AU1000_SRC_CLK;
                count = cpu_speed / 2;
 #endif
@@ -356,7 +356,7 @@ static unsigned long do_fast_cp0_gettimeoffset(void)
                : "hi", "lo", GCC_REG_ACCUM);
 
        /*
-        * Due to possible jiffies inconsistencies, we need to check 
+        * Due to possible jiffies inconsistencies, we need to check
         * the result so that we'll get a timer that is monotonic.
         */
        if (res >= USECS_PER_JIFFY)
@@ -375,8 +375,8 @@ static unsigned long do_fast_pm_gettimeoffset(void)
        au_sync();
        offset = pc0 - last_pc0;
        if (offset > 2*MATCH20_INC) {
-               printk("huge offset %x, last_pc0 %x last_match20 %x pc0 %x\n", 
-                               (unsigned)offset, (unsigned)last_pc0, 
+               printk("huge offset %x, last_pc0 %x last_match20 %x pc0 %x\n",
+                               (unsigned)offset, (unsigned)last_pc0,
                                (unsigned)last_match20, (unsigned)pc0);
        }
        offset = (unsigned long)((offset * 305) / 10);
@@ -394,11 +394,11 @@ void au1xxx_timer_setup(struct irqaction *irq)
        r4k_offset = cal_r4koff();
        printk("%08lx(%d)\n", r4k_offset, (int) r4k_offset);
 
-       //est_freq = 2*r4k_offset*HZ;   
-       est_freq = r4k_offset*HZ;       
+       //est_freq = 2*r4k_offset*HZ;
+       est_freq = r4k_offset*HZ;
        est_freq += 5000;    /* round */
        est_freq -= est_freq%10000;
-       printk("CPU frequency %d.%02d MHz\n", est_freq/1000000, 
+       printk("CPU frequency %d.%02d MHz\n", est_freq/1000000,
               (est_freq%1000000)*100/1000000);
        set_au1x00_speed(est_freq);
        set_au1x00_lcd_clock(); // program the LCD clock
index 90426eaffb23655e2b1ed7ab48f8784f1f218e85..1c55c5f59d759ba5704b2fee60c18bb36c73eb5a 100644 (file)
@@ -182,7 +182,7 @@ void __init board_setup(void)
        au_writel(0xf0000000, Au1500_PCI_MWMASK_DEV);
        au_writel(0, Au1500_PCI_MWBASE_REV_CCL);
        au_writel(0x02a00356, Au1500_PCI_STATCMD);
-       au_writel(0x00003c04, Au1500_PCI_HDRTYPE);      
+       au_writel(0x00003c04, Au1500_PCI_HDRTYPE);
        au_writel(0x00000008, Au1500_PCI_MBAR);
        au_sync();
 
@@ -216,7 +216,7 @@ csb250_pci_idsel(unsigned int devsel, int assert)
        unsigned int    gpio2_pins;
 
        retval = 1;
-       
+
        /* First, disable both selects, then assert the one requested.
        */
        au_writel(0xc000c000, GPIO2_OUTPUT);
index 4320057fc4391c0f25ca535d55e80a8bd13eeff0..bd99733abc0be21fd6a592adb4b7bc8d31c847b9 100644 (file)
@@ -81,7 +81,7 @@ int __init prom_init(int argc, char **argv, char **envp, int *prom_vec)
        csb_env[0] = env1;
 
        mips_machgroup = MACH_GROUP_ALCHEMY;
-       mips_machtype = MACH_CSB250;  
+       mips_machtype = MACH_CSB250;
 
        prom_init_cmdline();
        memsize_str = prom_getenv("memsize");
index 51eee94a5e824a0c82d4fd3b1ac7299a43ebc7c6..4b9d5e46edbbc42133fdbd268967c2ddc213adc0 100644 (file)
@@ -61,7 +61,7 @@ void __init prom_init(void)
        prom_envp = (char **) fw_arg2;
 
        mips_machgroup = MACH_GROUP_ALCHEMY;
-       mips_machtype = MACH_DB1000;    /* set the platform # */   
+       mips_machtype = MACH_DB1000;    /* set the platform # */
 
        prom_init_cmdline();
 
index eee4adf98711d7f7447e990e48f5418952f79bfd..8cc9879dd582261272135a2f2e68f8585b231aa5 100644 (file)
@@ -63,7 +63,7 @@ int __init prom_init(int argc, char **argv, char **envp, int *prom_vec)
        prom_envp = envp;
 
        mips_machgroup = MACH_GROUP_ALCHEMY;
-       mips_machtype = MACH_DB1000;    /* set the platform # */   
+       mips_machtype = MACH_DB1000;    /* set the platform # */
        prom_init_cmdline();
 
        memsize_str = prom_getenv("memsize");
index 2fa211b69329e8a05c080a929c8efcdb2f15f29f..0b4807dc9f44e3d93289f6091f495d750cef4051 100644 (file)
@@ -174,7 +174,7 @@ void __init board_setup(void)
        case 0x02: /* HB */
                break;
        default:  /* HC and newer */
-               /* Enable sys bus clock divider when IDLE state or no bus 
+               /* Enable sys bus clock divider when IDLE state or no bus
                   activity. */
                au_writel(au_readl(SYS_POWERCTRL) | (0x3 << 5), SYS_POWERCTRL);
                break;
index 9dadc82536f45f8ed49243a2ee462508db3dabd8..1e59433dfd66a3ace22f153268be5fa2d8a9084b 100644 (file)
@@ -49,7 +49,7 @@ void board_reset (void)
 void __init board_setup(void)
 {
        u32 pin_func;
-       
+
        // set multiple use pins (UART3/GPIO) to UART (it's used as UART too)
        pin_func = au_readl(SYS_PINFUNC) & (u32)(~SYS_PF_UR3);
        pin_func |= SYS_PF_UR3;
@@ -75,11 +75,11 @@ void __init board_setup(void)
        au_writel(1, GPIO2_ENABLE);
        /* gpio2 208/9/10/11 are inputs */
        au_writel((1<<8) | (1<<9) | (1<<10) | (1<<11), GPIO2_DIR);
-       
+
        /* turn off power */
        au_writel((au_readl(GPIO2_PINSTATE) & ~(1<<14))|(1<<30), GPIO2_OUTPUT);
 #endif
-       
+
 
 #ifdef CONFIG_PCI
 #if defined(__MIPSEB__)
index 03f755291b519e61e2fd508e25693968fc1c7816..f1c76533b6fc8ea4b3ebff2f5b43b6276e98f9dd 100644 (file)
@@ -55,7 +55,7 @@ void __init prom_init(void)
        prom_envp = (char **) fw_arg2;
 
        mips_machgroup = MACH_GROUP_ALCHEMY;
-       mips_machtype = MACH_XXS1500;   /* set the platform # */   
+       mips_machtype = MACH_XXS1500;   /* set the platform # */
 
        prom_init_cmdline();
 
index 954800a0ab527401aa014eb3c8fdbb5442410622..52f2f7daeb0559bdfaab23050c0c159823b72c6e 100644 (file)
@@ -56,7 +56,7 @@ au1xxx_irq_map_t au1xxx_irq_map[] = {
        { AU1500_GPIO_207, INTC_INT_LOW_LEVEL, 0 },
 
        { AU1000_GPIO_0, INTC_INT_LOW_LEVEL, 0 },
-       { AU1000_GPIO_1, INTC_INT_LOW_LEVEL, 0 }, 
+       { AU1000_GPIO_1, INTC_INT_LOW_LEVEL, 0 },
        { AU1000_GPIO_2, INTC_INT_LOW_LEVEL, 0 },
        { AU1000_GPIO_3, INTC_INT_LOW_LEVEL, 0 },
        { AU1000_GPIO_4, INTC_INT_LOW_LEVEL, 0 }, /* CF interrupt */
index caad7ca27abd1a00f39002a982dc340546c30c90..3120a02b8670a5329728b13e9cd9a173c9fe2e69 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:00 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -88,6 +88,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_MIPS_BONITO64=y
 CONFIG_MIPS_MSC=y
 # CONFIG_CPU_LITTLE_ENDIAN is not set
index 1b7f8a702d06ed89a93ef9f6bd3c7c502a02e897..158e7165f4e32fe5bb645e5b8649dc110441eaf2 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:00 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -97,6 +97,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_IRQ_CPU=y
 CONFIG_MIPS_L1_CACHE_SHIFT=5
index 8861854561e589f0bc2a126349dc0e85fa20a282..4302c6f914f5048080944be60daaef39dd29dd81 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:00 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -82,6 +82,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_I8259=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_IRQ_CPU=y
index 19cac1bf4f017ab23f40053acee392d4b853ea75..962fc14b58c287a8644f758ee2bd7fe33b121c15 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:01 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -104,6 +104,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_MIPS_L1_CACHE_SHIFT=5
 
index 035ac95d197eee3063aa4290bc3c972635e9b3ee..6a528d479d70103e0ee50815b751f0ae54cf7d54 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:01 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -104,6 +104,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_MIPS_L1_CACHE_SHIFT=5
 
index c38c4ed18fe7cfffc15de92a434b88efecf1c029..fed6f2fab48be54265f2ab218e56132ada5103be 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:01 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
index ee81309ae3a5edc29ae8520251fa40c79a429a88..178c0ad1af750dfdf97925f5a749a11a38be3fb8 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:02 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
index d43ed57c4b4ea285e8a0610d2c04ec90995cbde0..70addc73f699600891cc9aebc1a352c5184762ef 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:02 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -82,6 +82,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_I8259=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_IRQ_CPU=y
index 5a032cdefd63050f7a8fcfc69276f86e7182481a..60292808b3841f6e621fa93b6b65b76e96228faa 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:02 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -83,6 +83,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_I8259=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_IRQ_CPU=y
index 32ada79da9d8875f1eaadbb405eef1e04b34345d..66ec1f41d122a96d3738e614904eca7cf0dd47c9 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:03 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -88,6 +88,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_EARLY_PRINTK=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_IRQ_CPU=y
index 52074a2085fbc8ace1c4596f0081b846524c36b9..ba2ec01defb11efff11e7701aec4e0690a0a914e 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:03 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -96,6 +96,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_IRQ_CPU=y
 CONFIG_MIPS_L1_CACHE_SHIFT=5
index 360e842fd4be7f6af0cf203ff8e07d9fb266d0d5..17e87f70f602e731be20a77200cc14422d8ee555 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:03 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -89,6 +89,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 # CONFIG_CPU_LITTLE_ENDIAN is not set
 CONFIG_MIPS_GT64120=y
 # CONFIG_SYSCLK_75 is not set
index 657a9508d31a924898f1ee23d558e1b4399f83c6..9da4140eae002344b2a5695bae2d100882919893 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:03 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -88,6 +88,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 # CONFIG_CPU_LITTLE_ENDIAN is not set
 CONFIG_IRQ_CPU=y
 CONFIG_MIPS_GT64120=y
index 3fb102e6a7f7d0d26394fa1306d5212c533ab0c3..17fa5c4e3ad13849cd6d0a90a6d053ec3e3c2939 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:04 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -90,6 +90,7 @@ CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_ARC=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 # CONFIG_CPU_LITTLE_ENDIAN is not set
 CONFIG_IRQ_CPU=y
 CONFIG_SWAP_IO_SPACE=y
index b5bab3a42fc4e1e0329cf083503121fbdb004c4a..b2a67da1e031f0ac10582f9a7d39e3948cfcd192 100644 (file)
@@ -4,7 +4,7 @@
 # Wed Jan 26 02:49:04 2005
 #
 CONFIG_MIPS=y
-CONFIG_MIPS64=y
+CONFIG_64BIT=y
 CONFIG_64BIT=y
 
 #
index bdf1415475ff63e338b65cb6ad3b5a86303ffec7..b26e1173365ddd1291101d57aa25939307012dff 100644 (file)
@@ -4,7 +4,7 @@
 # Wed Jan 26 02:49:04 2005
 #
 CONFIG_MIPS=y
-CONFIG_MIPS64=y
+CONFIG_64BIT=y
 CONFIG_64BIT=y
 
 #
@@ -84,6 +84,7 @@ CONFIG_ARC=y
 CONFIG_DMA_IP32=y
 CONFIG_OWN_DMA=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 # CONFIG_CPU_LITTLE_ENDIAN is not set
 CONFIG_ARC32=y
 CONFIG_BOOT_ELF32=y
index 1ca7746388f0ef694ef8928ea321598294d6f4b9..08bd3ad64761712d8fa881cc4761609830eca540 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:05 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -90,6 +90,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_ITE_BOARD_GEN=y
 CONFIG_IT8172_CIR=y
index c6eef708be1e9bdaa16a20944cae80413ebe3e83..583ef5c5b1cd69137389b25d7c37b11aa647281b 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:05 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -89,6 +89,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_ITE_BOARD_GEN=y
 CONFIG_IT8172_CIR=y
index 757c4e88cc005641ca94997f198712297a21f281..8abb5a0c6c1219fd466e2d9ea681505e9e64da21 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:05 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -81,6 +81,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_LIMITED_DMA=y
 # CONFIG_CPU_LITTLE_ENDIAN is not set
 CONFIG_IRQ_CPU=y
index e5a613906554acaca581480a7a216809c538365f..da5d9ee2ecceb8e55680f6e474b826fffca7408d 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:06 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -82,6 +82,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 # CONFIG_CPU_LITTLE_ENDIAN is not set
 CONFIG_MIPS_TX3927=y
 CONFIG_SWAP_IO_SPACE=y
index 1e7697834e90fda20fcbbc5eeeb8af6bd4bae96a..8d600ae890f48e1cf4d3eb6ffc7783fa21550f02 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:06 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -92,6 +92,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_MIPS_NILE4=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_MIPS_GT64120=y
index 61fb9fb97e6e33793252f4effb9a87453803b973..79519ac5af4a8c71c7d45d8e6adf2df659fc2eb0 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:53:14 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -88,6 +88,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_GENERIC_ISA_DMA=y
 CONFIG_I8259=y
 CONFIG_MIPS_BONITO64=y
index 31b8f2ad73385dd9fadfc2545bfa47f4f199f029..0fea57ef18f2069b32bad99498201e2af8f15a06 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:07 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -97,6 +97,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_IRQ_CPU=y
 CONFIG_MIPS_L1_CACHE_SHIFT=5
index 2cce682fffcf66c54b57580d00f6cb013cec0ed3..b4cf97a732bc5ba566c736e5665486d3a61ca82e 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:07 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -89,6 +89,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 # CONFIG_CPU_LITTLE_ENDIAN is not set
 CONFIG_IRQ_CPU=y
 CONFIG_IRQ_CPU_RM7K=y
index 0cbf48a62e02078d1c8b7667238e8984abafae7f..a38903db85a071c55d532e218addd3d9478ff007 100644 (file)
@@ -4,7 +4,7 @@
 # Wed Jan 26 02:49:07 2005
 #
 CONFIG_MIPS=y
-CONFIG_MIPS64=y
+CONFIG_64BIT=y
 CONFIG_64BIT=y
 
 #
@@ -80,6 +80,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 # CONFIG_CPU_LITTLE_ENDIAN is not set
 CONFIG_IRQ_CPU=y
 CONFIG_IRQ_MV64340=y
index 4043950d360a9f1443f6647692a6147446809e8e..920d59b56a4efc456035f2e6841a5e99757d5535 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:08 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -82,6 +82,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 # CONFIG_CPU_LITTLE_ENDIAN is not set
 CONFIG_IRQ_CPU=y
 CONFIG_IRQ_CPU_RM7K=y
index 3870af4537adeac3bb45afedd00e470138c91eda..ef5ea50893d14a8f7b88311ab69c8fd9c745d4d9 100644 (file)
@@ -4,7 +4,7 @@
 # Wed Jan 26 02:49:08 2005
 #
 CONFIG_MIPS=y
-CONFIG_MIPS64=y
+CONFIG_64BIT=y
 CONFIG_64BIT=y
 
 #
@@ -80,6 +80,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 # CONFIG_CPU_LITTLE_ENDIAN is not set
 CONFIG_IRQ_CPU=y
 CONFIG_IRQ_CPU_RM7K=y
index 6cdabd550300bf45437b86f2f010d85c26959d0a..813e3a8b480bfc46d5e4cfb6623c0c798f97d4cd 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:08 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -104,6 +104,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_SWAP_IO_SPACE=y
 # CONFIG_AU1X00_USB_DEVICE is not set
index 2aebbd2e82b377608775760632b3c5d5ea92efd1..49e528340a396924c342b875d34e711635acf325 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:09 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
index 9e21edc28280df696451dba8d22c40e7effe94f1..8e426776c098e6295656a97a842236685a64a8ac 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:09 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
similarity index 66%
rename from arch/mips/configs/osprey_defconfig
rename to arch/mips/configs/qemu_defconfig
index 989cb9e7ae8367be0b7a2c6ad464f1675738d259..b6568e421b9980710ca20c7dc3fb49fcd5615755 100644 (file)
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.11-rc2
-# Wed Jan 26 02:49:08 2005
+# Linux kernel version: 2.6.13-rc6
+# Mon Aug  8 11:49:54 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
-# CONFIG_64BIT is not set
-CONFIG_MIPS32=y
 
 #
 # Code maturity level options
 #
-CONFIG_EXPERIMENTAL=y
+# CONFIG_EXPERIMENTAL is not set
 CONFIG_CLEAN_COMPILE=y
 CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
 
 #
 # General setup
 #
 CONFIG_LOCALVERSION=""
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_SWAP is not set
+# CONFIG_SYSVIPC is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
+# CONFIG_SYSCTL is not set
 # CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
 CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
+CONFIG_PRINTK=y
+# CONFIG_BUG is not set
+# CONFIG_BASE_FULL is not set
+# CONFIG_FUTEX is not set
+# CONFIG_EPOLL is not set
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-CONFIG_SHMEM=y
+# CONFIG_SHMEM is not set
 CONFIG_CC_ALIGN_FUNCTIONS=0
 CONFIG_CC_ALIGN_LABELS=0
 CONFIG_CC_ALIGN_LOOPS=0
 CONFIG_CC_ALIGN_JUMPS=0
-# CONFIG_TINY_SHMEM is not set
+CONFIG_TINY_SHMEM=y
+CONFIG_BASE_SMALL=1
 
 #
 # Loadable module support
 #
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-CONFIG_MODVERSIONS=y
-CONFIG_MODULE_SRCVERSION_ALL=y
-CONFIG_KMOD=y
+# CONFIG_MODULES is not set
 
 #
 # Machine selection
 #
-# CONFIG_MACH_JAZZ is not set
-# CONFIG_MACH_VR41XX is not set
-# CONFIG_TOSHIBA_JMR3927 is not set
+# CONFIG_MIPS_MTX1 is not set
+# CONFIG_MIPS_BOSPORUS is not set
+# CONFIG_MIPS_PB1000 is not set
+# CONFIG_MIPS_PB1100 is not set
+# CONFIG_MIPS_PB1500 is not set
+# CONFIG_MIPS_PB1550 is not set
+# CONFIG_MIPS_PB1200 is not set
+# CONFIG_MIPS_DB1000 is not set
+# CONFIG_MIPS_DB1100 is not set
+# CONFIG_MIPS_DB1500 is not set
+# CONFIG_MIPS_DB1550 is not set
+# CONFIG_MIPS_DB1200 is not set
+# CONFIG_MIPS_MIRAGE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MIPS_EV64120 is not set
 # CONFIG_MIPS_EV96100 is not set
 # CONFIG_MIPS_IVR is not set
-# CONFIG_LASAT is not set
 # CONFIG_MIPS_ITE8172 is not set
+# CONFIG_MACH_JAZZ is not set
+# CONFIG_LASAT is not set
 # CONFIG_MIPS_ATLAS is not set
 # CONFIG_MIPS_MALTA is not set
 # CONFIG_MIPS_SEAD is not set
+# CONFIG_MOMENCO_JAGUAR_ATX is not set
 # CONFIG_MOMENCO_OCELOT is not set
-# CONFIG_MOMENCO_OCELOT_G is not set
-# CONFIG_MOMENCO_OCELOT_C is not set
 # CONFIG_MOMENCO_OCELOT_3 is not set
-# CONFIG_MOMENCO_JAGUAR_ATX is not set
-# CONFIG_PMC_YOSEMITE is not set
+# CONFIG_MOMENCO_OCELOT_C is not set
+# CONFIG_MOMENCO_OCELOT_G is not set
+# CONFIG_MIPS_XXS1500 is not set
+# CONFIG_PNX8550_V2PCI is not set
+# CONFIG_PNX8550_JBS is not set
 # CONFIG_DDB5074 is not set
 # CONFIG_DDB5476 is not set
 # CONFIG_DDB5477 is not set
-CONFIG_NEC_OSPREY=y
+# CONFIG_MACH_VR41XX is not set
+# CONFIG_PMC_YOSEMITE is not set
+CONFIG_QEMU=y
 # CONFIG_SGI_IP22 is not set
-# CONFIG_SOC_AU1X00 is not set
-# CONFIG_SIBYTE_SB1xxx_SOC is not set
+# CONFIG_SGI_IP27 is not set
+# CONFIG_SGI_IP32 is not set
+# CONFIG_SIBYTE_SWARM is not set
+# CONFIG_SIBYTE_SENTOSA is not set
+# CONFIG_SIBYTE_RHONE is not set
+# CONFIG_SIBYTE_CARMEL is not set
+# CONFIG_SIBYTE_PTSWARM is not set
+# CONFIG_SIBYTE_LITTLESUR is not set
+# CONFIG_SIBYTE_CRHINE is not set
+# CONFIG_SIBYTE_CRHONE is not set
 # CONFIG_SNI_RM200_PCI is not set
+# CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
+# CONFIG_TOSHIBA_RBTX4938 is not set
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
-CONFIG_DMA_NONCOHERENT=y
-CONFIG_CPU_LITTLE_ENDIAN=y
-CONFIG_IRQ_CPU=y
+CONFIG_DMA_COHERENT=y
+CONFIG_GENERIC_ISA_DMA=y
+CONFIG_I8259=y
+CONFIG_CPU_BIG_ENDIAN=y
+# CONFIG_CPU_LITTLE_ENDIAN is not set
+CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y
+CONFIG_SWAP_IO_SPACE=y
 CONFIG_MIPS_L1_CACHE_SHIFT=5
-CONFIG_VR4181=y
+CONFIG_HAVE_STD_PC_SERIAL_PORT=y
 
 #
 # CPU selection
 #
-# CONFIG_CPU_MIPS32 is not set
-# CONFIG_CPU_MIPS64 is not set
+# CONFIG_CPU_MIPS32_R1 is not set
+# CONFIG_CPU_MIPS32_R2 is not set
+# CONFIG_CPU_MIPS64_R1 is not set
+# CONFIG_CPU_MIPS64_R2 is not set
 # CONFIG_CPU_R3000 is not set
 # CONFIG_CPU_TX39XX is not set
-CONFIG_CPU_VR41XX=y
+# CONFIG_CPU_VR41XX is not set
 # CONFIG_CPU_R4300 is not set
-# CONFIG_CPU_R4X00 is not set
+CONFIG_CPU_R4X00=y
 # CONFIG_CPU_TX49XX is not set
 # CONFIG_CPU_R5000 is not set
 # CONFIG_CPU_R5432 is not set
@@ -113,17 +138,36 @@ CONFIG_CPU_VR41XX=y
 # CONFIG_CPU_RM7000 is not set
 # CONFIG_CPU_RM9000 is not set
 # CONFIG_CPU_SB1 is not set
+CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
+CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
+CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y
+
+#
+# Kernel type
+#
+CONFIG_32BIT=y
+# CONFIG_64BIT is not set
 CONFIG_PAGE_SIZE_4KB=y
 # CONFIG_PAGE_SIZE_8KB is not set
 # CONFIG_PAGE_SIZE_16KB is not set
 # CONFIG_PAGE_SIZE_64KB is not set
+# CONFIG_MIPS_MT is not set
+# CONFIG_64BIT_PHYS_ADDR is not set
 # CONFIG_CPU_ADVANCED is not set
+CONFIG_CPU_HAS_LLSC=y
+CONFIG_CPU_HAS_LLDSCD=y
 CONFIG_CPU_HAS_SYNC=y
+CONFIG_ARCH_FLATMEM_ENABLE=y
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_PREEMPT_NONE=y
+# CONFIG_PREEMPT_VOLUNTARY is not set
 # CONFIG_PREEMPT is not set
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
 #
+CONFIG_ISA=y
 CONFIG_MMU=y
 
 #
@@ -131,10 +175,6 @@ CONFIG_MMU=y
 #
 # CONFIG_PCCARD is not set
 
-#
-# PC-card bridges
-#
-
 #
 # PCI Hotplug Support
 #
@@ -146,6 +186,56 @@ CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 CONFIG_TRAD_SIGNALS=y
 
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_IP_MROUTE is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_BIC=y
+# CONFIG_IPV6 is not set
+# CONFIG_NETFILTER is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
+
+#
+# Network testing
+#
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+
 #
 # Device Drivers
 #
@@ -154,7 +244,7 @@ CONFIG_TRAD_SIGNALS=y
 # Generic Driver Options
 #
 CONFIG_STANDALONE=y
-CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_PREVENT_FIRMWARE_BUILD is not set
 # CONFIG_FW_LOADER is not set
 
 #
@@ -170,6 +260,7 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
 #
 # Plug and Play support
 #
+# CONFIG_PNP is not set
 
 #
 # Block devices
@@ -181,19 +272,16 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_BLK_DEV_RAM is not set
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_INITRAMFS_SOURCE=""
-# CONFIG_LBD is not set
-CONFIG_CDROM_PKTCDVD=m
-CONFIG_CDROM_PKTCDVD_BUFFERS=8
-# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+# CONFIG_CDROM_PKTCDVD is not set
 
 #
 # IO Schedulers
 #
 CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-CONFIG_ATA_OVER_ETH=m
+# CONFIG_IOSCHED_AS is not set
+# CONFIG_IOSCHED_DEADLINE is not set
+# CONFIG_IOSCHED_CFQ is not set
+# CONFIG_ATA_OVER_ETH is not set
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -205,6 +293,11 @@ CONFIG_ATA_OVER_ETH=m
 #
 # CONFIG_SCSI is not set
 
+#
+# Old CD-ROM drivers (not SCSI, not IDE)
+#
+# CONFIG_CD_NO_IDESCSI is not set
+
 #
 # Multi-device support (RAID and LVM)
 #
@@ -213,6 +306,7 @@ CONFIG_ATA_OVER_ETH=m
 #
 # Fusion MPT device support
 #
+# CONFIG_FUSION is not set
 
 #
 # IEEE 1394 (FireWire) support
@@ -223,84 +317,41 @@ CONFIG_ATA_OVER_ETH=m
 #
 
 #
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
+# Network device support
 #
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-CONFIG_NETLINK_DEV=y
-CONFIG_UNIX=y
-CONFIG_NET_KEY=y
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-# CONFIG_IP_PNP_DHCP is not set
-CONFIG_IP_PNP_BOOTP=y
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-CONFIG_INET_TUNNEL=m
-CONFIG_IP_TCPDIAG=m
-# CONFIG_IP_TCPDIAG_IPV6 is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-CONFIG_XFRM=y
-CONFIG_XFRM_USER=m
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
 
 #
 # Ethernet (10 or 100Mbit)
 #
 CONFIG_NET_ETHERNET=y
-# CONFIG_MII is not set
+CONFIG_MII=y
+# CONFIG_NET_VENDOR_3COM is not set
+# CONFIG_NET_VENDOR_SMC is not set
+# CONFIG_NET_VENDOR_RACAL is not set
+# CONFIG_DEPCA is not set
+# CONFIG_HP100 is not set
+CONFIG_NET_ISA=y
+# CONFIG_E2100 is not set
+# CONFIG_EWRK3 is not set
+# CONFIG_EEXPRESS is not set
+# CONFIG_EEXPRESS_PRO is not set
+# CONFIG_HPLAN_PLUS is not set
+# CONFIG_HPLAN is not set
+# CONFIG_LP486E is not set
+# CONFIG_ETH16I is not set
+CONFIG_NE2000=y
+# CONFIG_NET_PCI is not set
+# CONFIG_NET_POCKET is not set
 
 #
 # Ethernet (1000 Mbit)
@@ -313,6 +364,7 @@ CONFIG_NET_ETHERNET=y
 #
 # Token Ring devices
 #
+# CONFIG_TR is not set
 
 #
 # Wireless LAN (non-hamradio)
@@ -325,8 +377,8 @@ CONFIG_NET_ETHERNET=y
 # CONFIG_WAN is not set
 # CONFIG_PPP is not set
 # CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
 
 #
 # ISDN subsystem
@@ -346,27 +398,12 @@ CONFIG_INPUT=y
 #
 # Userland interfaces
 #
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_MOUSEDEV is not set
 # CONFIG_INPUT_JOYDEV is not set
 # CONFIG_INPUT_TSDEV is not set
 # CONFIG_INPUT_EVDEV is not set
 # CONFIG_INPUT_EVBUG is not set
 
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-# CONFIG_SERIO_I8042 is not set
-CONFIG_SERIO_SERPORT=y
-# CONFIG_SERIO_CT82C710 is not set
-# CONFIG_SERIO_LIBPS2 is not set
-CONFIG_SERIO_RAW=m
-
 #
 # Input Device Drivers
 #
@@ -376,6 +413,12 @@ CONFIG_SERIO_RAW=m
 # CONFIG_INPUT_TOUCHSCREEN is not set
 # CONFIG_INPUT_MISC is not set
 
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
 #
 # Character devices
 #
@@ -397,9 +440,8 @@ CONFIG_SERIAL_8250_NR_UARTS=4
 #
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
+# CONFIG_UNIX98_PTYS is not set
+# CONFIG_LEGACY_PTYS is not set
 
 #
 # IPMI
@@ -418,19 +460,28 @@ CONFIG_LEGACY_PTY_COUNT=256
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
 
+#
+# TPM devices
+#
+
 #
 # I2C support
 #
 # CONFIG_I2C is not set
+# CONFIG_I2C_SENSOR is not set
 
 #
 # Dallas's 1-wire bus
 #
 # CONFIG_W1 is not set
 
+#
+# Hardware Monitoring support
+#
+# CONFIG_HWMON is not set
+
 #
 # Misc devices
 #
@@ -453,9 +504,9 @@ CONFIG_LEGACY_PTY_COUNT=256
 #
 # Console display driver support
 #
-# CONFIG_VGA_CONSOLE is not set
+CONFIG_VGA_CONSOLE=y
+# CONFIG_MDA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
-# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
 # Sound
@@ -468,10 +519,6 @@ CONFIG_DUMMY_CONSOLE=y
 # CONFIG_USB_ARCH_HAS_HCD is not set
 # CONFIG_USB_ARCH_HAS_OHCI is not set
 
-#
-# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
-#
-
 #
 # USB Gadget Support
 #
@@ -487,20 +534,29 @@ CONFIG_DUMMY_CONSOLE=y
 #
 # CONFIG_INFINIBAND is not set
 
+#
+# SN Devices
+#
+
 #
 # File systems
 #
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS is not set
 # CONFIG_EXT3_FS is not set
 # CONFIG_JBD is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+
+#
+# XFS support
+#
 # CONFIG_XFS_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
 # CONFIG_QUOTA is not set
-CONFIG_DNOTIFY=y
+# CONFIG_DNOTIFY is not set
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -520,12 +576,8 @@ CONFIG_DNOTIFY=y
 #
 # Pseudo filesystems
 #
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
-CONFIG_DEVPTS_FS_XATTR=y
-CONFIG_DEVPTS_FS_SECURITY=y
+# CONFIG_PROC_FS is not set
+# CONFIG_SYSFS is not set
 # CONFIG_TMPFS is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
@@ -533,13 +585,7 @@ CONFIG_RAMFS=y
 #
 # Miscellaneous filesystems
 #
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
 # CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
 # CONFIG_CRAMFS is not set
 # CONFIG_VXFS_FS is not set
 # CONFIG_HPFS_FS is not set
@@ -551,23 +597,18 @@ CONFIG_RAMFS=y
 # Network File Systems
 #
 CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-CONFIG_NFSD=y
-# CONFIG_NFSD_V3 is not set
-# CONFIG_NFSD_TCP is not set
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
+# CONFIG_NFSD is not set
 CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
-CONFIG_EXPORTFS=y
+CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
-# CONFIG_AFS_FS is not set
 
 #
 # Partition Types
@@ -580,23 +621,19 @@ CONFIG_MSDOS_PARTITION=y
 #
 # CONFIG_NLS is not set
 
-#
-# Profiling support
-#
-# CONFIG_PROFILING is not set
-
 #
 # Kernel hacking
 #
+# CONFIG_PRINTK_TIME is not set
 # CONFIG_DEBUG_KERNEL is not set
+CONFIG_LOG_BUF_SHIFT=14
 CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE="ip=bootp ether=46,0x03fe0300,eth0"
+CONFIG_CMDLINE="console=ttyS0 debug ip=172.20.0.2:172.20.0.1::255.255.0.0"
 
 #
 # Security options
 #
-CONFIG_KEYS=y
-CONFIG_KEYS_DEBUG_PROC_KEYS=y
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
@@ -612,7 +649,7 @@ CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # Library routines
 #
 # CONFIG_CRC_CCITT is not set
-# CONFIG_CRC32 is not set
-CONFIG_LIBCRC32C=m
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_GENERIC_IRQ_PROBE=y
index d0c85a4009d609f229c2ea336ceb43497c183d20..17d4fce6c4c6c297010309d3a3d241886a404645 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:09 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -91,6 +91,7 @@ CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_ARC=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_GENERIC_ISA_DMA=y
 CONFIG_I8259=y
 CONFIG_CPU_LITTLE_ENDIAN=y
index 84978b70714b5eb481b9dc6b5aa9e22d0b28093a..1dc935f3758264e4d2e9e56f4778d5b6249b94eb 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:10 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
index 7c718a429b04d00f3cc3f75c695e9c966e970b92..dd07e866b128e83adbddb3035b44748550f4b1ac 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:10 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -80,6 +80,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_IRQ_CPU=y
 CONFIG_MIPS_BOARDS_GEN=y
index e01727cd0fe904b069f90fe4a1f183105bc4a886..c9d3f83caf0f73dc964e70b707d982ac9e3b8725 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:12 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -95,6 +95,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_IRQ_CPU=y
 CONFIG_MIPS_L1_CACHE_SHIFT=5
index c6ba3de276145c765c18ec94eebc1a976f46cd9b..2cb669188aa9a4aed3b522a1d403014f0cf09c23 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:12 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -98,6 +98,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_IRQ_CPU=y
 CONFIG_MIPS_L1_CACHE_SHIFT=5
index 915c43b6e2d95c9b82feddf986f6991bbc40877c..16e07fca446f69cc99d7482dfb869888ff6b7948 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:12 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -96,6 +96,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_IRQ_CPU=y
 CONFIG_MIPS_L1_CACHE_SHIFT=5
index 562f2b8043ac4b25d49428b272f1cc0a6f2930f4..6d2290777ad7e6510d14aab7ac564a87f3c17185 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:49:13 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
index 5f027bfa4af8f9047cfa35cea667e88826c95c16..9ffe1a9142caef3e86c19faa03a4dd9906e94e6b 100644 (file)
@@ -76,7 +76,7 @@ set_pci_int_attr(u32 pci, u32 intn, u32 active, u32 trigger)
 extern void vrc5477_irq_init(u32 base);
 extern void mips_cpu_irq_init(u32 base);
 extern asmlinkage void ddb5477_handle_int(void);
-extern int setup_irq(unsigned int irq, struct irqaction *irqaction);  
+extern int setup_irq(unsigned int irq, struct irqaction *irqaction);
 static struct irqaction irq_cascade = { no_action, 0, CPU_MASK_NONE, "cascade", NULL, NULL };
 
 void __init arch_init_irq(void)
@@ -94,7 +94,7 @@ void __init arch_init_irq(void)
        /* setup PCI interrupt attributes */
        set_pci_int_attr(PCI0, INTA, ACTIVE_LOW, LEVEL_SENSE);
        set_pci_int_attr(PCI0, INTB, ACTIVE_LOW, LEVEL_SENSE);
-       if (mips_machtype == MACH_NEC_ROCKHOPPERII) 
+       if (mips_machtype == MACH_NEC_ROCKHOPPERII)
                set_pci_int_attr(PCI0, INTC, ACTIVE_HIGH, LEVEL_SENSE);
        else
                set_pci_int_attr(PCI0, INTC, ACTIVE_LOW, LEVEL_SENSE);
@@ -134,7 +134,7 @@ void __init arch_init_irq(void)
 
        /* setup cascade interrupts */
        setup_irq(VRC5477_IRQ_BASE + VRC5477_I8259_CASCADE, &irq_cascade);
-       setup_irq(CPU_IRQ_BASE + CPU_VRC5477_CASCADE, &irq_cascade);      
+       setup_irq(CPU_IRQ_BASE + CPU_VRC5477_CASCADE, &irq_cascade);
 
        /* hook up the first-level interrupt handler */
        set_except_vector(0, ddb5477_handle_int);
index 15c6e543b56f09b5788281235520ba095462a95d..d62f5a789b0544d62bae459910d539018446816e 100644 (file)
@@ -141,7 +141,7 @@ static void __init ddb_time_init(void)
 
        /* mips_hpt_frequency is 1/2 of the cpu core freq */
        i =  (read_c0_config() >> 28 ) & 7;
-       if ((current_cpu_data.cputype == CPU_R5432) && (i == 3)) 
+       if ((current_cpu_data.cputype == CPU_R5432) && (i == 3))
                i = 4;
        mips_hpt_frequency = bus_frequency*(i+4)/4;
 }
@@ -298,11 +298,11 @@ static void __init ddb5477_board_init(void)
 
        if (mips_machtype == MACH_NEC_ROCKHOPPER
           ||  mips_machtype == MACH_NEC_ROCKHOPPERII) {
-               /* Disable bus diagnostics. */ 
+               /* Disable bus diagnostics. */
                ddb_out32(DDB_PCICTL0_L, 0);
                ddb_out32(DDB_PCICTL0_H, 0);
                ddb_out32(DDB_PCICTL1_L, 0);
-               ddb_out32(DDB_PCICTL1_H, 0);         
+               ddb_out32(DDB_PCICTL1_H, 0);
        }
 
        if (mips_machtype == MACH_NEC_ROCKHOPPER) {
@@ -354,7 +354,7 @@ static void __init ddb5477_board_init(void)
                 */
                pci_write_config_byte(&dev_m1533, 0x58, 0x74);
 
-               /* 
+               /*
                 * positive decode (bit6 -0)
                 * enable IDE controler interrupt (bit 4 -1)
                 * setup SIRQ to point to IRQ 14 (bit 3:0 - 1101)
@@ -364,31 +364,31 @@ static void __init ddb5477_board_init(void)
                /* Setup M5229 registers */
                dev_m5229.bus = &bus;
                dev_m5229.sysdata = NULL;
-               dev_m5229.devfn = 4*8;          // slot 4 (AD15): M5229 IDE 
+               dev_m5229.devfn = 4*8;          // slot 4 (AD15): M5229 IDE
 
                /*
                 * enable IDE in the M5229 config register 0x50 (bit 0 - 1)
-                * M5229 IDSEL is addr:15; see above setting 
+                * M5229 IDSEL is addr:15; see above setting
                 */
                pci_read_config_byte(&dev_m5229, 0x50, &temp8);
                pci_write_config_byte(&dev_m5229, 0x50, temp8 | 0x1);
 
-               /* 
-                * enable bus master (bit 2)  and IO decoding  (bit 0) 
+               /*
+                * enable bus master (bit 2)  and IO decoding  (bit 0)
                 */
                pci_read_config_byte(&dev_m5229, 0x04, &temp8);
                pci_write_config_byte(&dev_m5229, 0x04, temp8 | 0x5);
 
                /*
                 * enable native, copied from arch/ppc/k2boot/head.S
-                * TODO - need volatile, need to be portable 
+                * TODO - need volatile, need to be portable
                 */
                pci_write_config_byte(&dev_m5229, 0x09, 0xef);
 
-               /* Set Primary Channel Command Block Timing */ 
+               /* Set Primary Channel Command Block Timing */
                pci_write_config_byte(&dev_m5229, 0x59, 0x31);
 
-               /* 
+               /*
                 * Enable primary channel 40-pin cable
                 * M5229 register 0x4a (bit 0)
                 */
index 133fb7c48e6c6f748804a5918552ba8458f75e3b..6dbce92eb0683c775a143069bffcb2ad1a9d83f6 100644 (file)
@@ -253,7 +253,7 @@ static inline void dec_kn03_be_init(void)
 
        kn0x_erraddr = (void *)(KN03_SLOT_BASE + IOASIC_ERRADDR);
        kn0x_chksyn = (void *)(KN03_SLOT_BASE + IOASIC_CHKSYN);
-                       
+
        /*
         * Set normal ECC detection and generation, enable ECC correction.
         * For KN05 we also need to make sure EE (?) is enabled in the MB.
index 3b379099321999b789643de2aa555206d640b883..c89768d5c4e55458dd79c797a5daedbbb577afc4 100644 (file)
                 */
                mfc0    t0,CP0_CAUSE            # get pending interrupts
                mfc0    t1,CP0_STATUS
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
                lw      t2,cpu_fpu_mask
 #endif
                andi    t0,ST0_IM               # CAUSE.CE may be non-zero!
 
                beqz    t0,spurious
 
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
                 and    t2,t0
                bnez    t2,fpu                  # handle FPU immediately
 #endif
@@ -271,7 +271,7 @@ handle_it:
                j       ret_from_irq
                 nop
 
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 fpu:
                j       handle_fpe_int
                 nop
index 373822ec2d8c28e512d6b7ae48f2fd018c143636..bcd0247b3a66731636ec6aad45733b793e6e40f3 100644 (file)
@@ -5,7 +5,7 @@
 
 lib-y                  += init.o memory.o cmdline.o identify.o console.o
 
-lib-$(CONFIG_MIPS32)   += locore.o
-lib-$(CONFIG_MIPS64)   += call_o32.o
+lib-$(CONFIG_32BIT)    += locore.o
+lib-$(CONFIG_64BIT)    += call_o32.o
 
 EXTRA_AFLAGS := $(CFLAGS)
index d55fe665926f06e10dc3c6b704b9bb0b08d23419..20f84b119b4c344067beda1809cf490ed360e35f 100644 (file)
@@ -4,9 +4,9 @@
 # Wed Jan 26 02:48:59 2005
 #
 CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
 # CONFIG_64BIT is not set
-CONFIG_MIPS32=y
+# CONFIG_64BIT is not set
+CONFIG_32BIT=y
 
 #
 # Code maturity level options
@@ -90,6 +90,7 @@ CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_ARC=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
 # CONFIG_CPU_LITTLE_ENDIAN is not set
 CONFIG_IRQ_CPU=y
 CONFIG_SWAP_IO_SPACE=y
index d808a67294b8cbc4fc1947ae1ed96e7ba0fe73e8..a5f6d84bc1813ae865c035ce09e2df14c2f6f370 100644 (file)
@@ -129,7 +129,7 @@ static void __init it8172_setup(void)
 
        /*
         * IO/MEM resources.
-        * 
+        *
         * revisit this area.
         */
        set_io_port_base(KSEG1);
index 30a6c0d5fc5094dee3af65abddb473b83cd457e4..f5d67ee21ac632f1e8c6a14a9d612f7de6273080 100644 (file)
@@ -72,7 +72,7 @@ static inline int rtc_dm_binary(void) { return saved_control & RTC_DM_BINARY; }
 static inline unsigned char
 bin_to_hw(unsigned char c)
 {
-       if (rtc_dm_binary()) 
+       if (rtc_dm_binary())
                return c;
        else
                return ((c/10) << 4) + (c%10);
@@ -91,9 +91,9 @@ hw_to_bin(unsigned char c)
 static inline unsigned char
 hour_bin_to_hw(unsigned char c)
 {
-       if (rtc_24h()) 
+       if (rtc_24h())
                return bin_to_hw(c);
-       if (c >= 12) 
+       if (c >= 12)
                return 0x80 | bin_to_hw((c==12)?12:c-12);  /* 12 is 12pm */
        else
                return bin_to_hw((c==0)?12:c);  /* 0 is 12 AM, not 0 am */
@@ -105,9 +105,9 @@ hour_hw_to_bin(unsigned char c)
        unsigned char tmp = hw_to_bin(c&0x3f);
        if (rtc_24h())
                return tmp;
-       if (c & 0x80) 
+       if (c & 0x80)
                return (tmp==12)?12:tmp+12;     /* 12pm is 12, not 24 */
-       else 
+       else
                return (tmp==12)?0:tmp;         /* 12am is 0 */
 }
 
@@ -145,7 +145,7 @@ static unsigned long __init cal_r4koff(void)
        return (mips_hpt_frequency / HZ);
 }
 
-static unsigned long 
+static unsigned long
 it8172_rtc_get_time(void)
 {
        unsigned int year, mon, day, hour, min, sec;
@@ -166,12 +166,12 @@ it8172_rtc_get_time(void)
        hour = hour_hw_to_bin(CMOS_READ(RTC_HOURS));
        day = hw_to_bin(CMOS_READ(RTC_DAY_OF_MONTH));
        mon = hw_to_bin(CMOS_READ(RTC_MONTH));
-       year = hw_to_bin(CMOS_READ(RTC_YEAR)) + 
+       year = hw_to_bin(CMOS_READ(RTC_YEAR)) +
                hw_to_bin(*rtc_century_reg) * 100;
 
        /* restore interrupts */
        local_irq_restore(flags);
-               
+
        return mktime(year, mon, day, hour, min, sec);
 }
 
index a0230ee0f7f4bbcba350dea796615597de92b3ae..d3303584fbd1f86789d1990c113039513712406f 100644 (file)
@@ -13,8 +13,8 @@ binfmt_irix-objs      := irixelf.o irixinv.o irixioctl.o irixsig.o    \
 
 ifdef CONFIG_MODULES
 obj-y                          += mips_ksyms.o module.o
-obj-$(CONFIG_MIPS32)           += module-elf32.o
-obj-$(CONFIG_MIPS64)           += module-elf64.o
+obj-$(CONFIG_32BIT)            += module-elf32.o
+obj-$(CONFIG_64BIT)            += module-elf64.o
 endif
 
 obj-$(CONFIG_CPU_R3000)                += r2300_fpu.o r2300_switch.o
@@ -45,8 +45,8 @@ obj-$(CONFIG_IRQ_CPU_RM7K)    += irq-rm7000.o
 obj-$(CONFIG_IRQ_CPU_RM9K)     += irq-rm9000.o
 obj-$(CONFIG_IRQ_MV64340)      += irq-mv6434x.o
 
-obj-$(CONFIG_MIPS32)           += scall32-o32.o
-obj-$(CONFIG_MIPS64)           += scall64-64.o
+obj-$(CONFIG_32BIT)            += scall32-o32.o
+obj-$(CONFIG_64BIT)            += scall64-64.o
 obj-$(CONFIG_BINFMT_IRIX)      += binfmt_irix.o
 obj-$(CONFIG_MIPS32_COMPAT)    += ioctl32.o linux32.o signal32.o
 obj-$(CONFIG_MIPS32_N32)       += binfmt_elfn32.o scall64-n32.o signal_n32.o
@@ -55,7 +55,7 @@ obj-$(CONFIG_MIPS32_O32)      += binfmt_elfo32.o scall64-o32.o ptrace32.o
 obj-$(CONFIG_KGDB)             += gdb-low.o gdb-stub.o
 obj-$(CONFIG_PROC_FS)          += proc.o
 
-obj-$(CONFIG_MIPS64)           += cpu-bugs64.o
+obj-$(CONFIG_64BIT)            += cpu-bugs64.o
 
 obj-$(CONFIG_GEN_RTC)          += genrtc.o
 
index ed47041f30306c2fe93125465bff104c30cb71c2..6b645fbb1ddcd800092a3cd555dca0cf4439b5b7 100644 (file)
@@ -103,7 +103,7 @@ jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
         * Convert jiffies to nanoseconds and seperate with
         * one divide.
         */
-       u64 nsec = (u64)jiffies * TICK_NSEC; 
+       u64 nsec = (u64)jiffies * TICK_NSEC;
        value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &value->tv_usec);
        value->tv_usec /= NSEC_PER_USEC;
 }
index ee21b18c37a8a08c36c8b160955903a111585e2f..b4075e99c452218d17a4e94834cf7dc12cc8b12d 100644 (file)
@@ -105,7 +105,7 @@ jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
         * Convert jiffies to nanoseconds and seperate with
         * one divide.
         */
-       u64 nsec = (u64)jiffies * TICK_NSEC; 
+       u64 nsec = (u64)jiffies * TICK_NSEC;
        value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &value->tv_usec);
        value->tv_usec /= NSEC_PER_USEC;
 }
index 11ebe5d4c446fe390406106a02f564b8a1588399..47a087b6c11ba881d33d2aa2d3aaf2ffce50374a 100644 (file)
@@ -137,7 +137,7 @@ static inline void check_mult_sh(void)
        for (i = 0; i < 8; i++)
                if (v1[i] != w[i])
                        bug = 1;
-               
+
        if (bug == 0) {
                printk("no.\n");
                return;
@@ -149,7 +149,7 @@ static inline void check_mult_sh(void)
        for (i = 0; i < 8; i++)
                if (v2[i] != w[i])
                        fix = 0;
-               
+
        if (fix == 1) {
                printk("yes.\n");
                return;
index 4bb84958231410b6b644f0fe9f692063dab872a5..7685f8baf3f022da8843c5ef1847966a5085765f 100644 (file)
@@ -229,15 +229,9 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c)
                break;
        case PRID_IMP_VR41XX:
                switch (c->processor_id & 0xf0) {
-#ifndef CONFIG_VR4181
                case PRID_REV_VR4111:
                        c->cputype = CPU_VR4111;
                        break;
-#else
-               case PRID_REV_VR4181:
-                       c->cputype = CPU_VR4181;
-                       break;
-#endif
                case PRID_REV_VR4121:
                        c->cputype = CPU_VR4121;
                        break;
index ece6ddaf7011e943615874d1405d9322e217ee74..512bedbfa7b9ef0a36629193c19eb6b9d56ce129 100644 (file)
 #include <asm/stackframe.h>
 #include <asm/gdb-stub.h>
 
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 #define DMFC0  mfc0
 #define DMTC0  mtc0
 #define LDC1   lwc1
 #define SDC1   lwc1
 #endif
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 #define DMFC0  dmfc0
 #define DMTC0  dmtc0
 #define LDC1   ldc1
index 269889302a27d786c101d6d2da754351607b91c3..d3fd1ab14274c25daeaa1fce41159f5b3a07d9d5 100644 (file)
@@ -687,8 +687,8 @@ void handle_exception (struct gdb_regs *regs)
         * acquire the big kgdb spinlock
         */
        if (!spin_trylock(&kgdb_lock)) {
-               /* 
-                * some other CPU has the lock, we should go back to 
+               /*
+                * some other CPU has the lock, we should go back to
                 * receive the gdb_wait IPC
                 */
                return;
@@ -703,7 +703,7 @@ void handle_exception (struct gdb_regs *regs)
                async_bp.addr = 0;
        }
 
-       /* 
+       /*
         * acquire the CPU spinlocks
         */
        for (i = num_online_cpus()-1; i >= 0; i--)
@@ -894,7 +894,7 @@ void handle_exception (struct gdb_regs *regs)
                        ptr = &input_buffer[1];
                        if (hexToLong(&ptr, &addr))
                                regs->cp0_epc = addr;
-         
+
                        goto exit_kgdb_exception;
                        break;
 
@@ -1001,7 +1001,7 @@ void breakpoint(void)
                return;
 
        __asm__ __volatile__(
-                       ".globl breakinst\n\t" 
+                       ".globl breakinst\n\t"
                        ".set\tnoreorder\n\t"
                        "nop\n"
                        "breakinst:\tbreak\n\t"
@@ -1014,7 +1014,7 @@ void breakpoint(void)
 void async_breakpoint(void)
 {
        __asm__ __volatile__(
-                       ".globl async_breakinst\n\t" 
+                       ".globl async_breakinst\n\t"
                        ".set\tnoreorder\n\t"
                        "nop\n"
                        "async_breakinst:\tbreak\n\t"
index a5b0a389b063a37d169fdb50bf9933c054b0ec1e..e7f6c1b9080622c3250aa4062e5598d1618cf1d8 100644 (file)
@@ -54,7 +54,7 @@ NESTED(except_vec3_generic, 0, sp)
 #endif
        mfc0    k1, CP0_CAUSE
        andi    k1, k1, 0x7c
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        dsll    k1, k1, 1
 #endif
        PTR_L   k0, exception_handlers(k1)
@@ -81,7 +81,7 @@ NESTED(except_vec3_r4000, 0, sp)
        beq     k1, k0, handle_vced
         li     k0, 14<<2
        beq     k1, k0, handle_vcei
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        dsll    k1, k1, 1
 #endif
        .set    pop
@@ -244,12 +244,12 @@ NESTED(nmi_handler, PT_SIZE, sp)
           start with an n and gas will believe \n is ok ...  */
        .macro  __BUILD_verbose nexception
        LONG_L  a1, PT_EPC(sp)
-#if CONFIG_MIPS32
+#ifdef CONFIG_32BIT
        PRINT("Got \nexception at %08lx\012")
-#endif 
-#if CONFIG_MIPS64
+#endif
+#ifdef CONFIG_64BIT
        PRINT("Got \nexception at %016lx\012")
-#endif 
+#endif
        .endm
 
        .macro  __BUILD_count exception
@@ -293,7 +293,7 @@ NESTED(nmi_handler, PT_SIZE, sp)
        BUILD_HANDLER mcheck mcheck cli verbose         /* #24 */
        BUILD_HANDLER reserved reserved sti verbose     /* others */
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 /* A temporary overflow handler used by check_daddi(). */
 
        __INIT
index a64e87d22014a40ffa9f4ef58c73c1dac4e8383d..2a1b45d66f047dbca7ed7ee05e232e459b8b7157 100644 (file)
        .endm
 
        .macro  setup_c0_status_pri
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        setup_c0_status ST0_KX 0
 #else
        setup_c0_status 0 0
        .endm
 
        .macro  setup_c0_status_sec
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        setup_c0_status ST0_KX ST0_BEV
 #else
        setup_c0_status 0 ST0_BEV
@@ -215,7 +215,7 @@ NESTED(smp_bootstrap, 16, sp)
         * slightly different layout ...
         */
        page    swapper_pg_dir, _PGD_ORDER
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        page    invalid_pmd_table, _PMD_ORDER
 #endif
        page    invalid_pte_table, _PTE_ORDER
index 519cd5d0aebb83b165dec61263e7b97a81485a75..c069719ff0d842a89c3d9b442cb4f5cd07147ee8 100644 (file)
@@ -27,7 +27,7 @@ long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
 #include "compat_ioctl.c"
 
 typedef int (* ioctl32_handler_t)(unsigned int, unsigned int, unsigned long, struct file *);
-                                                                                
+
 #define COMPATIBLE_IOCTL(cmd)          HANDLE_IOCTL((cmd),sys_ioctl)
 #define HANDLE_IOCTL(cmd,handler)      { (cmd), (ioctl32_handler_t)(handler), NULL },
 #define IOCTL_TABLE_START \
index 441157a1f994a4d07cf90ffc248a1e6dc71af5f3..7d93992e462c847deb025a798943b7f6f6eef78e 100644 (file)
@@ -77,7 +77,7 @@ int show_interrupts(struct seq_file *p, void *v)
        if (i < NR_IRQS) {
                spin_lock_irqsave(&irq_desc[i].lock, flags);
                action = irq_desc[i].action;
-               if (!action) 
+               if (!action)
                        goto skip;
                seq_printf(p, "%3d: ",i);
 #ifndef CONFIG_SMP
index 993abc868e54984253b9a10a0150762f34017e3e..4613219dd73ef9f290529589012372b499285418 100644 (file)
@@ -313,7 +313,7 @@ asmlinkage int sys32_sysinfo(struct sysinfo32 *info)
        struct sysinfo s;
        int ret, err;
        mm_segment_t old_fs = get_fs ();
-       
+
        set_fs (KERNEL_DS);
        ret = sys_sysinfo(&s);
        set_fs (old_fs);
@@ -560,7 +560,7 @@ struct ipc64_perm32 {
        compat_gid_t gid;
        compat_uid_t cuid;
        compat_gid_t cgid;
-       compat_mode_t   mode; 
+       compat_mode_t   mode;
        unsigned short  seq;
        unsigned short __pad1;
        unsigned int __unused1;
@@ -1334,17 +1334,17 @@ asmlinkage int sys32_sendfile(int out_fd, int in_fd, compat_off_t *offset,
        mm_segment_t old_fs = get_fs();
        int ret;
        off_t of;
-       
+
        if (offset && get_user(of, offset))
                return -EFAULT;
-               
+
        set_fs(KERNEL_DS);
        ret = sys_sendfile(out_fd, in_fd, offset ? &of : NULL, count);
        set_fs(old_fs);
-       
+
        if (offset && put_user(of, offset))
                return -EFAULT;
-               
+
        return ret;
 }
 
@@ -1362,11 +1362,11 @@ static unsigned char socketcall_nargs[18]={AL(0),AL(3),AL(3),AL(3),AL(2),AL(3),
 #undef AL
 
 /*
- *     System call vectors. 
+ *     System call vectors.
  *
  *     Argument checking cleaned up. Saved 20% in size.
  *  This function doesn't need to set the kernel lock because
- *  it is set by the callees. 
+ *  it is set by the callees.
  */
 
 asmlinkage long sys32_socketcall(int call, unsigned int *args32)
@@ -1402,11 +1402,11 @@ asmlinkage long sys32_socketcall(int call, unsigned int *args32)
        /* copy_from_user should be SMP safe. */
        if (copy_from_user(a, args32, socketcall_nargs[call]))
                return -EFAULT;
-               
+
        a0=a[0];
        a1=a[1];
-       
-       switch(call) 
+
+       switch(call)
        {
                case SYS_SOCKET:
                        err = sys_socket(a0,a1,a[2]);
index eed29fc9dc823d3ce9af99a016c5d7c34b67607f..86e42c633f73a60e95a939a7433b18b89118dd1b 100644 (file)
@@ -35,7 +35,7 @@ EXPORT_SYMBOL(memcpy);
 EXPORT_SYMBOL(memmove);
 EXPORT_SYMBOL(strcat);
 EXPORT_SYMBOL(strchr);
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 EXPORT_SYMBOL(strncmp);
 #endif
 EXPORT_SYMBOL(strlen);
index 6e70c42c20589f2a401033927dcc33273a1d017e..e4f2f80113876a5ac0d3312344852343973b8032 100644 (file)
@@ -70,7 +70,7 @@ void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp)
 
        /* New thread loses kernel privileges. */
        status = regs->cp0_status & ~(ST0_CU0|ST0_CU1|KU_MASK);
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        status &= ~ST0_FR;
        status |= (current->thread.mflags & MF_32BIT_REGS) ? 0 : ST0_FR;
 #endif
@@ -236,10 +236,10 @@ static int __init get_frame_info(struct mips_frame_info *info, void *func)
                        break;
 
                if (
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
                    ip->i_format.opcode == sw_op &&
 #endif
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
                    ip->i_format.opcode == sd_op &&
 #endif
                    ip->i_format.rs == 29)
@@ -353,7 +353,7 @@ schedule_timeout_caller:
 
 out:
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        if (current->thread.mflags & MF_32BIT_REGS) /* Kludge for 32-bit ps  */
                pc &= 0xffffffffUL;
 #endif
index 92e70ca3bff9d60bb6bf51a660f75b09496d089c..0b571a5b4b83a7705a3a0d06ffd97de88432a866 100644 (file)
@@ -124,7 +124,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
                        if (tsk_used_math(child)) {
                                fpureg_t *fregs = get_fpu_regs(child);
 
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
                                /*
                                 * The odd registers are actually the high
                                 * order bits of the values stored in the even
@@ -135,7 +135,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
                                else
                                        tmp = (unsigned long) (fregs[(addr - 32)] & 0xffffffff);
 #endif
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
                                tmp = fregs[addr - FPR_BASE];
 #endif
                        } else {
@@ -213,7 +213,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
                                       sizeof(child->thread.fpu.hard));
                                child->thread.fpu.hard.fcr31 = 0;
                        }
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
                        /*
                         * The odd registers are actually the high order bits
                         * of the values stored in the even registers - unless
@@ -227,7 +227,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
                                fregs[addr - FPR_BASE] |= data;
                        }
 #endif
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
                        fregs[addr - FPR_BASE] = data;
 #endif
                        break;
@@ -304,14 +304,14 @@ out:
 static inline int audit_arch(void)
 {
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        if (!(current->thread.mflags & MF_32BIT_REGS))
                return AUDIT_ARCH_MIPSEL64;
 #endif /* MIPS64 */
        return AUDIT_ARCH_MIPSEL;
 
 #else /* big endian... */
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        if (!(current->thread.mflags & MF_32BIT_REGS))
                return AUDIT_ARCH_MIPS64;
 #endif /* MIPS64 */
index 243e7b629af61f694b927f3004493e4d7a84d4f1..f10019640ee997847d1e7548cd4971efb5afd437 100644 (file)
@@ -35,7 +35,7 @@
 /*
  * FPU context is saved iff the process has used it's FPU in the current
  * time slice as indicated by TIF_USEDFPU.  In any case, the CU1 bit for user
- * space STATUS register should be 0, so that a process *always* starts its 
+ * space STATUS register should be 0, so that a process *always* starts its
  * userland with FPU disabled after each context switch.
  *
  * FPU will be enabled as soon as the process accesses FPU again, through
@@ -55,7 +55,7 @@ LEAF(resume)
        cpu_save_nonscratch a0
        sw      ra, THREAD_REG31(a0)
 
-       /* 
+       /*
         * check if we need to save FPU registers
         */
        lw      t3, TASK_THREAD_INFO(a0)
index ebb643d8d14c0812c6ec348cb29b56848b0c5ec3..aba665bcb3864e22b73c69f4ec7c94ae39199d29 100644 (file)
@@ -36,7 +36,7 @@
 LEAF(_save_fp_context)
        cfc1    t1, fcr31
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        /* Store the 16 odd double precision registers */
        EX      sdc1 $f1, SC_FPREGS+8(a0)
        EX      sdc1 $f3, SC_FPREGS+24(a0)
@@ -118,7 +118,7 @@ LEAF(_save_fp_context32)
  */
 LEAF(_restore_fp_context)
        EX      lw t0, SC_FPC_CSR(a0)
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        EX      ldc1 $f1, SC_FPREGS+8(a0)
        EX      ldc1 $f3, SC_FPREGS+24(a0)
        EX      ldc1 $f5, SC_FPREGS+40(a0)
index 1fc3b2eb12bd2d80de44b5f86c479a1487161360..e02b7722ccb8d1753e073bf85eb08b18849f7f8f 100644 (file)
@@ -33,7 +33,7 @@
 /*
  * FPU context is saved iff the process has used it's FPU in the current
  * time slice as indicated by _TIF_USEDFPU.  In any case, the CU1 bit for user
- * space STATUS register should be 0, so that a process *always* starts its 
+ * space STATUS register should be 0, so that a process *always* starts its
  * userland with FPU disabled after each context switch.
  *
  * FPU will be enabled as soon as the process accesses FPU again, through
  * Save a thread's fp context.
  */
 LEAF(_save_fp)
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        mfc0    t1, CP0_STATUS
 #endif
        fpu_save_double a0 t1 t0 t2             # clobbers t1
@@ -142,7 +142,7 @@ LEAF(_init_fpu)
 
        li      t1, -1                          # SNaN
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        sll     t0, t0, 5
        bgez    t0, 1f                          # 16 / 32 register mode?
 
@@ -164,7 +164,7 @@ LEAF(_init_fpu)
        dmtc1   t1, $f31
 1:
 #endif
-       
+
 #ifdef CONFIG_CPU_MIPS32
        mtc1    t1, $f0
        mtc1    t1, $f1
index 3a240e3e004c368c10cc86df391ac2fc2ceefdbe..12b531c295c40e352b4f88d42aadfbd2a38e0fec 100644 (file)
@@ -241,7 +241,7 @@ static inline int parse_rd_cmdline(unsigned long* rd_start, unsigned long* rd_en
        if (*tmp)
                strcat(command_line, tmp);
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        /* HACK: Guess if the sign extension was forgotten */
        if (start > 0x0000000080000000 && start < 0x00000000ffffffff)
                start |= 0xffffffff00000000;
@@ -446,7 +446,7 @@ static inline void resource_init(void)
 {
        int i;
 
-#if defined(CONFIG_MIPS64) && !defined(CONFIG_BUILD_ELF64)
+#if defined(CONFIG_64BIT) && !defined(CONFIG_BUILD_ELF64)
        /*
         * The 64bit code in 32bit object format trick can't represent
         * 64bit wide relocations for linker script symbols.
index f6875f023a29fdc34ef22bedbb292f9ccf3db9bc..8ddfbd8d425a9532ea994ae519931a8067ea5af0 100644 (file)
@@ -558,7 +558,7 @@ static inline int setup_sigcontext32(struct pt_regs *regs,
        if (!used_math())
                goto out;
 
-       /* 
+       /*
         * Save FPU state to signal context.  Signal handler will "inherit"
         * current FPU state.
         */
index 56c36e42e0a69fb08a981b3882aa21d60db896b8..a53b1ed7b38625540bddb2af051015f617d6387c 100644 (file)
@@ -924,7 +924,7 @@ void __init per_cpu_trap_init(void)
         * flag that some firmware may have left set and the TS bit (for
         * IP27).  Set XX for ISA IV code to work.
         */
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        status_set |= ST0_FR|ST0_KX|ST0_SX|ST0_UX;
 #endif
        if (current_cpu_data.isa_level == MIPS_CPU_ISA_IV)
index 3f24a1d45865bf1d85ddad15fc70797cea83fad3..36c5212e092887cd163720963a3af2590b20ef5a 100644 (file)
@@ -240,7 +240,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
                break;
 
        case lwu_op:
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
                /*
                 * A 32-bit kernel might be running on a 64-bit processor.  But
                 * if we're on a 32-bit processor and an i-cache incoherency
@@ -278,13 +278,13 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
                *newvalue = value;
                *regptr = &regs->regs[insn.i_format.rt];
                break;
-#endif /* CONFIG_MIPS64 */
+#endif /* CONFIG_64BIT */
 
                /* Cannot handle 64-bit instructions in 32-bit kernel */
                goto sigill;
 
        case ld_op:
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
                /*
                 * A 32-bit kernel might be running on a 64-bit processor.  But
                 * if we're on a 32-bit processor and an i-cache incoherency
@@ -320,7 +320,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
                *newvalue = value;
                *regptr = &regs->regs[insn.i_format.rt];
                break;
-#endif /* CONFIG_MIPS64 */
+#endif /* CONFIG_64BIT */
 
                /* Cannot handle 64-bit instructions in 32-bit kernel */
                goto sigill;
@@ -392,7 +392,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
                break;
 
        case sd_op:
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
                /*
                 * A 32-bit kernel might be running on a 64-bit processor.  But
                 * if we're on a 32-bit processor and an i-cache incoherency
@@ -428,7 +428,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
                if (res)
                        goto fault;
                break;
-#endif /* CONFIG_MIPS64 */
+#endif /* CONFIG_64BIT */
 
                /* Cannot handle 64-bit instructions in 32-bit kernel */
                goto sigill;
index e830d788c10653a066c1b6eb4693775625887593..482ac310c937dd55a651e903b744358933bc33ad 100644 (file)
@@ -15,7 +15,7 @@ SECTIONS
   /* This is the value for an Origin kernel, taken from an IRIX kernel.  */
   /* . = 0xc00000000001c000; */
 
-  /* Set the vaddr for the text segment to a value 
+  /* Set the vaddr for the text segment to a value
         >= 0xa800 0000 0001 9000 if no symmon is going to configured
         >= 0xa800 0000 0030 0000 otherwise  */
 
index f6add041ebec1a77dfcd33e3bf787d5e76641f2c..ca26e554615ee62bd99522106cd5f2cf9594034a 100644 (file)
@@ -1,7 +1,7 @@
-/* 
+/*
  * Atmel AT93C46 serial eeprom driver
  *
- * Brian Murphy <brian.murphy@eicon.com> 
+ * Brian Murphy <brian.murphy@eicon.com>
  *
  */
 #include <linux/kernel.h>
 
 struct at93c_defs *at93c;
 
-static void at93c_reg_write(u32 val) 
+static void at93c_reg_write(u32 val)
 {
        *at93c->reg = val;
 }
 
-static u32 at93c_reg_read(void) 
+static u32 at93c_reg_read(void)
 {
        u32 tmp = *at93c->reg;
        return tmp;
@@ -81,7 +81,7 @@ static u8 at93c_read_byte(void)
 }
 
 static void at93c_write_bits(u32 data, int size)
-{               
+{
        int i;
        int shift = size - 1;
        u32 mask = (1 << shift);
@@ -90,7 +90,7 @@ static void at93c_write_bits(u32 data, int size)
                at93c_write_databit((data & mask) >> shift);
                data <<= 1;
        }
-}       
+}
 
 static void at93c_init_op(void)
 {
@@ -104,8 +104,8 @@ static void at93c_end_op(void)
        lasat_ndelay(250);
 }
 
-static void at93c_wait(void) 
-{ 
+static void at93c_wait(void)
+{
        at93c_init_op();
        while (!at93c_read_databit())
                ;
index a912ac2171b0a642bd301d11d670410a4ae00341..cfe2f99b1d440884ab84f4da1e2bad8f989c3e48 100644 (file)
@@ -1,7 +1,7 @@
-/* 
+/*
  * Atmel AT93C46 serial eeprom driver
  *
- * Brian Murphy <brian.murphy@eicon.com> 
+ * Brian Murphy <brian.murphy@eicon.com>
  *
  */
 
index 7bbf6cf923c98f85f7a00e556558e2ccc64fe7a2..9d7812e03dcd9322f5410963e8a63398878d57d2 100644 (file)
@@ -1,7 +1,7 @@
-/* 
- * Dallas Semiconductors 1603 RTC driver 
+/*
+ * Dallas Semiconductors 1603 RTC driver
  *
- * Brian Murphy <brian@murphy.dk> 
+ * Brian Murphy <brian@murphy.dk>
  *
  */
 #include <linux/kernel.h>
 struct ds_defs *ds1603 = NULL;
 
 /* HW specific register functions */
-static void rtc_reg_write(unsigned long val) 
+static void rtc_reg_write(unsigned long val)
 {
        *ds1603->reg = val;
 }
 
-static unsigned long rtc_reg_read(void) 
+static unsigned long rtc_reg_read(void)
 {
        unsigned long tmp = *ds1603->reg;
        return tmp;
@@ -80,7 +80,7 @@ static unsigned int rtc_read_databit(void)
 {
        unsigned int data;
 
-       data = (rtc_datareg_read() & (1 << ds1603->data_read_shift)) 
+       data = (rtc_datareg_read() & (1 << ds1603->data_read_shift))
                >> ds1603->data_read_shift;
        rtc_cycle_clock(rtc_reg_read());
        return data;
index 55f3b0423c203969b87e2895f52a2137bdfbfa7e..c2e5c76a379dd188ad68ebcc2c7571128fe1a10d 100644 (file)
@@ -1,7 +1,7 @@
-/* 
- * Dallas Semiconductors 1603 RTC driver 
+/*
+ * Dallas Semiconductors 1603 RTC driver
  *
- * Brian Murphy <brian@murphy.dk> 
+ * Brian Murphy <brian@murphy.dk>
  *
  */
 #ifndef __DS1603_H
index 18b6430f11be1295697b470c0e0f3a05ecee5487..35ecd6483ef64b79de29b9e8a1c241ce90a3aa39 100644 (file)
@@ -21,7 +21,7 @@ LDSCRIPT= -L$(obj) -Tromscript.normal
 HEAD_DEFINES := -D_kernel_start=0x$(KERNEL_START) \
                -D_kernel_entry=0x$(KERNEL_ENTRY) \
                -D VERSION="\"$(Version)\"" \
-               -D TIMESTAMP=$(shell date +%s) 
+               -D TIMESTAMP=$(shell date +%s)
 
 $(obj)/head.o: $(obj)/head.S $(KERNEL_IMAGE)
        $(CC) -fno-pic $(HEAD_DEFINES) -I$(TOPDIR)/include -c -o $@ $<
index 426bd7de17bb998c1cbbb1a14f4bb9dd128d08ef..efb95f2609c2a1cb1a52e8b21a3ee2eae3f50566 100644 (file)
@@ -27,5 +27,5 @@ reldate:
        .word   TIMESTAMP
 
        .org    0x50
-release:       
+release:
        .string VERSION
index 1148a2d20aa752d9abf702ab1ffe0ad891754a72..c90da163944067f2dbb1aab17874708032d76337 100644 (file)
@@ -15,7 +15,7 @@
  *  with this program; if not, write to the Free Software Foundation, Inc.,
  *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
  *
- * Routines for generic manipulation of the interrupts found on the 
+ * Routines for generic manipulation of the interrupts found on the
  * Lasat boards.
  */
 #include <linux/init.h>
@@ -101,7 +101,7 @@ static unsigned long get_int_status_100(void)
        return *lasat_int_status & *lasat_int_mask;
 }
 
-static unsigned long get_int_status_200(void) 
+static unsigned long get_int_status_200(void)
 {
        unsigned long int_status;
 
index 8c784bcf11118d3e96710581869029ba7b04835e..fc9b0e2a6be10d8bee0f2e8ce2fca3dc9c2bc854 100644 (file)
@@ -67,7 +67,7 @@ static void init_flash_sizes(void)
 
        if (mips_machtype == MACH_LASAT_100) {
                lasat_board_info.li_flash_base = 0x1e000000;
-               
+
                lb[LASAT_MTD_BOOTLOADER] = 0x1e400000;
 
                if (lasat_board_info.li_flash_size > 0x200000) {
@@ -103,7 +103,7 @@ int lasat_init_board_info(void)
        memset(&lasat_board_info, 0, sizeof(lasat_board_info));
 
        /* First read the EEPROM info */
-       EEPROMRead(0, (unsigned char *)&lasat_board_info.li_eeprom_info, 
+       EEPROMRead(0, (unsigned char *)&lasat_board_info.li_eeprom_info,
                   sizeof(struct lasat_eeprom_struct));
 
        /* Check the CRC */
@@ -188,7 +188,7 @@ int lasat_init_board_info(void)
        case 0x1:
                lasat_board_info.li_cpu_hz =
                        lasat_board_info.li_bus_hz +
-                       (lasat_board_info.li_bus_hz >> 1);      
+                       (lasat_board_info.li_bus_hz >> 1);
                break;
        case 0x2:
                lasat_board_info.li_cpu_hz =
@@ -271,7 +271,7 @@ void lasat_write_eeprom_info(void)
        lasat_board_info.li_eeprom_info.crc32 = crc;
 
        /* Write the EEPROM info */
-       EEPROMWrite(0, (unsigned char *)&lasat_board_info.li_eeprom_info, 
+       EEPROMWrite(0, (unsigned char *)&lasat_board_info.li_eeprom_info,
                    sizeof(struct lasat_eeprom_struct));
 }
 
index 5637cd153926cdc85f461dff16178b187aa0e156..9ae82c3ffb07d98f990808601e5a9517983e5777 100644 (file)
@@ -1,7 +1,7 @@
-/* 
+/*
  * Picvue PVC160206 display driver
  *
- * Brian Murphy <brian@murphy.dk> 
+ * Brian Murphy <brian@murphy.dk>
  *
  */
 #include <linux/kernel.h>
@@ -24,12 +24,12 @@ struct pvc_defs *picvue = NULL;
 
 DECLARE_MUTEX(pvc_sem);
 
-static void pvc_reg_write(u32 val) 
+static void pvc_reg_write(u32 val)
 {
        *picvue->reg = val;
 }
 
-static u32 pvc_reg_read(void) 
+static u32 pvc_reg_read(void)
 {
        u32 tmp = *picvue->reg;
        return tmp;
@@ -65,12 +65,12 @@ static u8 pvc_read_data(void)
 {
        u32 data = pvc_reg_read();
        u8 byte;
-       data |= picvue->rw; 
+       data |= picvue->rw;
        data &= ~picvue->rs;
        pvc_reg_write(data);
        ndelay(40);
        byte = pvc_read_byte(data);
-       data |= picvue->rs; 
+       data |= picvue->rs;
        pvc_reg_write(data);
        return byte;
 }
index 74a39039135db23c7a2a82ebca22d2c2f3e74bfb..2a96bf971897aa044f957d88bd7239ef53fa67f0 100644 (file)
@@ -1,7 +1,7 @@
-/* 
+/*
  * Picvue PVC160206 display driver
  *
- * Brian Murphy <brian.murphy@eicon.com> 
+ * Brian Murphy <brian.murphy@eicon.com>
  *
  */
 #include <asm/semaphore.h>
index eaa2b4625124a297057d1927c4fe6e76f2234356..cce7cddcdb084a37409913db23549ef13676012f 100644 (file)
@@ -1,7 +1,7 @@
-/* 
+/*
  * Picvue PVC160206 display driver
  *
- * Brian Murphy <brian.murphy@eicon.com> 
+ * Brian Murphy <brian.murphy@eicon.com>
  *
  */
 #include <linux/kernel.h>
@@ -51,10 +51,10 @@ static int pvc_proc_read_line(char *page, char **start,
         page += sprintf(page, "%s\n", pvc_lines[lineno]);
        up(&pvc_sem);
 
-        return page - origpage; 
+        return page - origpage;
 }
 
-static int pvc_proc_write_line(struct file *file, const char *buffer,            
+static int pvc_proc_write_line(struct file *file, const char *buffer,
                            unsigned long count, void *data)
 {
         int origcount = count;
@@ -119,7 +119,7 @@ static int pvc_proc_read_scroll(char *page, char **start,
         page += sprintf(page, "%d\n", scroll_dir * scroll_interval);
        up(&pvc_sem);
 
-        return page - origpage; 
+        return page - origpage;
 }
 
 
index ca62881c9e52e1142f8aecb9b40598b8eb6919df..88c7ab871ec44bbe0c4f7dae9a92ca5c58b36da7 100644 (file)
@@ -42,7 +42,7 @@ static void null_prom_putc(char c)
 /* these are functions provided by the bootloader */
 static void (* prom_putc)(char c) = null_prom_putc;
 void (* prom_printf)(const char * fmt, ...) = null_prom_printf;
-void (* prom_display)(const char *string, int pos, int clear) = 
+void (* prom_display)(const char *string, int pos, int clear) =
                null_prom_display;
 void (* prom_monitor)(void) = null_prom_monitor;
 
index 37e4912ee1c88baa861b17784a696d334b441ad8..8d7d7a454f9a4e6f439042422842fa87d313419b 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * Thomas Horsten <thh@lasat.com>
  * Copyright (C) 2000 LASAT Networks A/S.
  *
index e371ed5cbe347a0e2475e1ede66ab1e15c89a17c..f2604fab9a9961912d72102318a06a7f94522dcb 100644 (file)
@@ -105,7 +105,7 @@ static int lasat_panic_prom_monitor(struct notifier_block *this,
        return NOTIFY_DONE;
 }
 
-static struct notifier_block lasat_panic_block[] = 
+static struct notifier_block lasat_panic_block[] =
 {
        { lasat_panic_display, NULL, INT_MAX },
        { lasat_panic_prom_monitor, NULL, INT_MIN }
@@ -120,7 +120,7 @@ static void lasat_timer_setup(struct irqaction *irq)
 {
 
        write_c0_compare(
-               read_c0_count() + 
+               read_c0_count() +
                mips_hpt_frequency / HZ);
        change_c0_status(ST0_IM, IE_IRQ0 | IE_IRQ5);
 }
index 1c0cc620a43f865e5da1bbd84abe928aa45b773f..8ff43a1c1e99c43f8cbbf5f49310f448b5fc87b4 100644 (file)
 
 static DECLARE_MUTEX(lasat_info_sem);
 
-/* Strategy function to write EEPROM after changing string entry */ 
+/* Strategy function to write EEPROM after changing string entry */
 int sysctl_lasatstring(ctl_table *table, int *name, int nlen,
                void *oldval, size_t *oldlenp,
                void *newval, size_t newlen, void **context)
 {
        int r;
        down(&lasat_info_sem);
-       r = sysctl_string(table, name, 
+       r = sysctl_string(table, name,
                          nlen, oldval, oldlenp, newval, newlen, context);
        if (r < 0) {
                up(&lasat_info_sem);
@@ -74,7 +74,7 @@ int proc_dolasatstring(ctl_table *table, int write, struct file *filp,
        return 0;
 }
 
-/* proc function to write EEPROM after changing int entry */ 
+/* proc function to write EEPROM after changing int entry */
 int proc_dolasatint(ctl_table *table, int write, struct file *filp,
                       void *buffer, size_t *lenp, loff_t *ppos)
 {
@@ -93,7 +93,7 @@ int proc_dolasatint(ctl_table *table, int write, struct file *filp,
 static int rtctmp;
 
 #ifdef CONFIG_DS1603
-/* proc function to read/write RealTime Clock */ 
+/* proc function to read/write RealTime Clock */
 int proc_dolasatrtc(ctl_table *table, int write, struct file *filp,
                       void *buffer, size_t *lenp, loff_t *ppos)
 {
@@ -165,9 +165,9 @@ static char lasat_bcastaddr[16];
 void update_bcastaddr(void)
 {
        unsigned int ip;
-       
-       ip = (lasat_board_info.li_eeprom_info.ipaddr & 
-               lasat_board_info.li_eeprom_info.netmask) | 
+
+       ip = (lasat_board_info.li_eeprom_info.ipaddr &
+               lasat_board_info.li_eeprom_info.netmask) |
                ~lasat_board_info.li_eeprom_info.netmask;
 
        sprintf(lasat_bcastaddr, "%d.%d.%d.%d",
@@ -205,7 +205,7 @@ int proc_lasat_ip(ctl_table *table, int write, struct file *filp,
                                break;
                        len++;
                }
-               if (len >= sizeof(proc_lasat_ipbuf)-1) 
+               if (len >= sizeof(proc_lasat_ipbuf)-1)
                        len = sizeof(proc_lasat_ipbuf) - 1;
                if (copy_from_user(proc_lasat_ipbuf, buffer, len))
                {
@@ -249,8 +249,8 @@ int proc_lasat_ip(ctl_table *table, int write, struct file *filp,
 }
 #endif /* defined(CONFIG_INET) */
 
-static int sysctl_lasat_eeprom_value(ctl_table *table, int *name, int nlen, 
-                                    void *oldval, size_t *oldlenp, 
+static int sysctl_lasat_eeprom_value(ctl_table *table, int *name, int nlen,
+                                    void *oldval, size_t *oldlenp,
                                     void *newval, size_t newlen,
                                     void **context)
 {
@@ -293,7 +293,7 @@ int proc_lasat_eeprom_value(ctl_table *table, int write, struct file *filp,
                if (!strcmp(filp->f_dentry->d_name.name, "debugaccess"))
                        lasat_board_info.li_eeprom_info.debugaccess = lasat_board_info.li_debugaccess;
        }
-       lasat_write_eeprom_info();      
+       lasat_write_eeprom_info();
        up(&lasat_info_sem);
        return 0;
 }
@@ -316,8 +316,8 @@ static ctl_table lasat_table[] = {
         0644, NULL, &proc_lasat_ip, &sysctl_lasat_intvec},
        {LASAT_NETMASK, "netmask", &lasat_board_info.li_eeprom_info.netmask, sizeof(int),
         0644, NULL, &proc_lasat_ip, &sysctl_lasat_intvec},
-       {LASAT_BCAST, "bcastaddr", &lasat_bcastaddr, 
-               sizeof(lasat_bcastaddr), 0600, NULL, 
+       {LASAT_BCAST, "bcastaddr", &lasat_bcastaddr,
+               sizeof(lasat_bcastaddr), 0600, NULL,
                &proc_dostring, &sysctl_string},
 #endif
        {LASAT_PASSWORD, "passwd_hash", &lasat_board_info.li_eeprom_info.passwd_hash, sizeof(lasat_board_info.li_eeprom_info.passwd_hash),
index fd6a2bafdfcf270be8d13bf9eb812d12f20cc0cd..ad285786e74b341ea9a9e30192e9dbf625f1a96b 100644 (file)
@@ -2,7 +2,7 @@
 # Makefile for MIPS-specific library files..
 #
 
-lib-y  += csum_partial.o memset.o watch.o 
+lib-y  += csum_partial.o memset.o watch.o
 
 obj-$(CONFIG_CPU_MIPS32)       += dump_tlb.o
 obj-$(CONFIG_CPU_MIPS64)       += dump_tlb.o
index fd6a2bafdfcf270be8d13bf9eb812d12f20cc0cd..ad285786e74b341ea9a9e30192e9dbf625f1a96b 100644 (file)
@@ -2,7 +2,7 @@
 # Makefile for MIPS-specific library files..
 #
 
-lib-y  += csum_partial.o memset.o watch.o 
+lib-y  += csum_partial.o memset.o watch.o
 
 obj-$(CONFIG_CPU_MIPS32)       += dump_tlb.o
 obj-$(CONFIG_CPU_MIPS64)       += dump_tlb.o
index afa8eae18ff672aecc79e1febf02116b50e6c9fc..90ee8d43261f591d2f509bf10ae7c6981e6bc3b5 100644 (file)
@@ -79,7 +79,7 @@
 /*
  * Only on the 64-bit kernel we can made use of 64-bit registers.
  */
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 #define USE_DOUBLE
 #endif
 
 #define NBYTES 8
 #define LOG_NBYTES 3
 
-/* 
+/*
  * As we are sharing code base with the mips32 tree (which use the o32 ABI
  * register definitions). We need to redefine the register definitions from
  * the n64 ABI register naming to the o32 ABI register naming.
 #define t5     $13
 #define t6     $14
 #define t7     $15
-       
+
 #else
 
 #define LOAD   lw
index 20a552be02ee400f82c461002fec46d869c18741..99c550632d44a541f29a7c70ee7052ae09869fa9 100644 (file)
@@ -320,7 +320,7 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_soft_struct *ctx)
        case cop1_op:
                switch (MIPSInst_RS(ir)) {
 
-#if __mips64 && !defined(SINGLE_ONLY_FPU)
+#if defined(__mips64) && !defined(SINGLE_ONLY_FPU)
                case dmfc_op:
                        /* copregister fs -> gpr[rt] */
                        if (MIPSInst_RT(ir) != 0) {
@@ -805,7 +805,7 @@ static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_soft_struct *ctx,
                ieee754dp d;
                ieee754sp s;
                int w;
-#if __mips64
+#ifdef __mips64
                s64 l;
 #endif
        } rv;                   /* resulting value */
@@ -950,7 +950,7 @@ static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_soft_struct *ctx,
                }
 #endif /* __mips >= 2 */
 
-#if __mips64 && !defined(SINGLE_ONLY_FPU)
+#if defined(__mips64) && !defined(SINGLE_ONLY_FPU)
                case fcvtl_op:{
                        ieee754sp fs;
 
@@ -1125,7 +1125,7 @@ static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_soft_struct *ctx,
                }
 #endif
 
-#if __mips64 && !defined(SINGLE_ONLY_FPU)
+#if defined(__mips64) && !defined(SINGLE_ONLY_FPU)
                case fcvtl_op:{
                        ieee754dp fs;
 
@@ -1203,7 +1203,7 @@ static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_soft_struct *ctx,
                break;
        }
 
-#if __mips64 && !defined(SINGLE_ONLY_FPU)
+#if defined(__mips64) && !defined(SINGLE_ONLY_FPU)
        case l_fmt:{
                switch (MIPSInst_FUNC(ir)) {
                case fcvts_op:
@@ -1267,7 +1267,7 @@ static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_soft_struct *ctx,
        case w_fmt:
                SITOREG(rv.w, MIPSInst_FD(ir));
                break;
-#if __mips64 && !defined(SINGLE_ONLY_FPU)
+#if defined(__mips64) && !defined(SINGLE_ONLY_FPU)
        case l_fmt:
                DITOREG(rv.l, MIPSInst_FD(ir));
                break;
index 04397fec30fc487b8c75a5cd4a9b9a1e5f252064..4002f0cf79f3d443651761b54185b82ed5988c06 100644 (file)
@@ -86,7 +86,7 @@ int fpu_emulator_restore_context(struct sigcontext *sc)
        return err;
 }
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 /*
  * This is the o32 version
  */
index 8f1d875217a21241f5c5fd0c84441c2e783aeb43..19d4b0792460b6ba0be750f5f170690c12bdfb8a 100644 (file)
@@ -122,7 +122,7 @@ void __init arch_init_irq(void)
        int i;
 
        atlas_hw0_icregs = (struct atlas_ictrl_regs *)ioremap (ATLAS_ICTRL_REGS_BASE, sizeof(struct atlas_ictrl_regs *));
-       
+
        /*
         * Mask out all interrupt by writing "1" to all bit position in
         * the interrupt reset reg.
index 31caf0603a3f47dc42db6639e48c27c4d81f970d..311155d1d3ed6955303392c414df35068507528a 100644 (file)
@@ -200,7 +200,7 @@ void __init kgdb_config (void)
                        generic_putDebugChar = saa9730_putDebugChar;
                        generic_getDebugChar = saa9730_getDebugChar;
                }
-               else 
+               else
 #endif
                {
                        speed = rs_kgdb_hook(line, speed);
@@ -243,7 +243,7 @@ void __init prom_init(void)
        mips_revision_corid = MIPS_REVISION_CORID;
 
        if (mips_revision_corid == MIPS_REVISION_CORID_CORE_EMUL) {
-               if (BONITO_PCIDID == 0x0001df53 || 
+               if (BONITO_PCIDID == 0x0001df53 ||
                    BONITO_PCIDID == 0x0003df53)
                        mips_revision_corid = MIPS_REVISION_CORID_CORE_EMUL_BON;
                else
@@ -310,7 +310,7 @@ void __init prom_init(void)
        case MIPS_REVISION_CORID_CORE_MSC:
        case MIPS_REVISION_CORID_CORE_FPGA2:
        case MIPS_REVISION_CORID_CORE_EMUL_MSC:
-               _pcictrl_msc = (unsigned long)ioremap(MIPS_MSC01_PCI_REG_BASE, 0x2000); 
+               _pcictrl_msc = (unsigned long)ioremap(MIPS_MSC01_PCI_REG_BASE, 0x2000);
 
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
                MSC_WRITE(MSC01_PCI_SWAP, MSC01_PCI_SWAP_NOSWAP);
index fe7fc17305a69193d23396d0800de698d4ceff20..16315444dd5acf489f04bbad6231cf0cc8d25201 100644 (file)
@@ -89,7 +89,7 @@ static unsigned int __init estimate_cpu_frequency(void)
         * really calculate the timer frequency
         * For now we hardwire the SEAD board frequency to 12MHz.
         */
-       
+
        if ((prid == (PRID_COMP_MIPS | PRID_IMP_20KC)) ||
            (prid == (PRID_COMP_MIPS | PRID_IMP_25KF)))
                count = 12000000;
index 3377e66de9eb350892f2c6bf9007c583b23672e3..df6db6419ae9906402398b575fc04389a8714862 100644 (file)
@@ -149,15 +149,15 @@ static int __init malta_setup(void)
                        argptr = prom_getcmdline();
                        if (strstr(argptr, "iobcuncached")) {
                                BONITO_PCICACHECTRL &= ~BONITO_PCICACHECTRL_IOBCCOH_EN;
-                               BONITO_PCIMEMBASECFG = BONITO_PCIMEMBASECFG & 
+                               BONITO_PCIMEMBASECFG = BONITO_PCIMEMBASECFG &
                                        ~(BONITO_PCIMEMBASECFG_MEMBASE0_CACHED |
                                          BONITO_PCIMEMBASECFG_MEMBASE1_CACHED);
                                printk("Disabled Bonito IOBC coherency\n");
                        }
                        else {
                                BONITO_PCICACHECTRL |= BONITO_PCICACHECTRL_IOBCCOH_EN;
-                               BONITO_PCIMEMBASECFG |= 
-                                       (BONITO_PCIMEMBASECFG_MEMBASE0_CACHED | 
+                               BONITO_PCIMEMBASECFG |=
+                                       (BONITO_PCIMEMBASECFG_MEMBASE0_CACHED |
                                         BONITO_PCIMEMBASECFG_MEMBASE1_CACHED);
                                printk("Disabled Bonito IOBC coherency\n");
                        }
index f61e038b4440435b7c0cc3a64e7d6840a7f6f339..b56a0abdc3d4216efa3919737fc0d8da6474b04c 100644 (file)
@@ -5,8 +5,8 @@
 obj-y                          += cache.o extable.o fault.o init.o pgtable.o \
                                   tlbex.o tlbex-fault.o
 
-obj-$(CONFIG_MIPS32)           += ioremap.o pgtable-32.o
-obj-$(CONFIG_MIPS64)           += pgtable-64.o
+obj-$(CONFIG_32BIT)            += ioremap.o pgtable-32.o
+obj-$(CONFIG_64BIT)            += pgtable-64.o
 obj-$(CONFIG_HIGHMEM)          += highmem.o
 
 obj-$(CONFIG_CPU_MIPS32)       += c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o
index a03ebb2cba6775de0354da8c5ed4c27ab38a9fbc..5ea84bc98c6a3fd8058d04ae8b56646f28dacf60 100644 (file)
@@ -126,13 +126,13 @@ static inline void tx49_blast_icache32(void)
 
        CACHE32_UNROLL32_ALIGN2;
        /* I'm in even chunk.  blast odd chunks */
-       for (ws = 0; ws < ws_end; ws += ws_inc) 
-               for (addr = start + 0x400; addr < end; addr += 0x400 * 2) 
+       for (ws = 0; ws < ws_end; ws += ws_inc)
+               for (addr = start + 0x400; addr < end; addr += 0x400 * 2)
                        cache32_unroll32(addr|ws,Index_Invalidate_I);
        CACHE32_UNROLL32_ALIGN;
        /* I'm in odd chunk.  blast even chunks */
-       for (ws = 0; ws < ws_end; ws += ws_inc) 
-               for (addr = start; addr < end; addr += 0x400 * 2) 
+       for (ws = 0; ws < ws_end; ws += ws_inc)
+               for (addr = start; addr < end; addr += 0x400 * 2)
                        cache32_unroll32(addr|ws,Index_Invalidate_I);
 }
 
@@ -156,13 +156,13 @@ static inline void tx49_blast_icache32_page_indexed(unsigned long page)
 
        CACHE32_UNROLL32_ALIGN2;
        /* I'm in even chunk.  blast odd chunks */
-       for (ws = 0; ws < ws_end; ws += ws_inc) 
-               for (addr = start + 0x400; addr < end; addr += 0x400 * 2) 
+       for (ws = 0; ws < ws_end; ws += ws_inc)
+               for (addr = start + 0x400; addr < end; addr += 0x400 * 2)
                        cache32_unroll32(addr|ws,Index_Invalidate_I);
        CACHE32_UNROLL32_ALIGN;
        /* I'm in odd chunk.  blast even chunks */
-       for (ws = 0; ws < ws_end; ws += ws_inc) 
-               for (addr = start; addr < end; addr += 0x400 * 2) 
+       for (ws = 0; ws < ws_end; ws += ws_inc)
+               for (addr = start; addr < end; addr += 0x400 * 2)
                        cache32_unroll32(addr|ws,Index_Invalidate_I);
 }
 
@@ -723,10 +723,10 @@ static void local_r4k_flush_cache_sigtramp(void * arg)
                        ".set push\n\t"
                        ".set noat\n\t"
                        ".set mips3\n\t"
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
                        "la     $at,1f\n\t"
 #endif
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
                        "dla    $at,1f\n\t"
 #endif
                        "cache  %0,($at)\n\t"
index ab30afd63b3257ee80515a922cf8bd2dfe6f0c72..502f68c664b244d58ec71ca1ee7ee940b45c379d 100644 (file)
@@ -270,7 +270,7 @@ static void local_sb1_flush_icache_range(unsigned long start,
                __sb1_writeback_inv_dcache_all();
        else
                __sb1_writeback_inv_dcache_range(start, end);
-       
+
        /* Just flush the whole icache if the range is big enough */
        if ((end - start) > icache_range_cutoff)
                __sb1_flush_icache_all();
index 13d96d62764ef08f31108e3539287537aa127efc..7166ffe635021a4124e8e9556791fc9cafafedb2 100644 (file)
@@ -25,7 +25,7 @@
 #include <asm/sibyte/sb1250_regs.h>
 #include <asm/sibyte/sb1250_scd.h>
 #endif
+
 /* SB1 definitions */
 
 /* XXX should come from config1 XXX */
@@ -136,14 +136,14 @@ static inline void breakout_cerrd(unsigned int val)
 
 #ifndef CONFIG_SIBYTE_BUS_WATCHER
 
-static void check_bus_watcher(void)              
-{                               
+static void check_bus_watcher(void)
+{
        uint32_t status, l2_err, memio_err;
 
        /* Destructive read, clears register and interrupt */
        status = csr_in32(IOADDR(A_SCD_BUS_ERR_STATUS));
        /* Bit 31 is always on, but there's no #define for that */
-       if (status & ~(1UL << 31)) {  
+       if (status & ~(1UL << 31)) {
                l2_err = csr_in32(IOADDR(A_BUS_L2_ERRORS));
                memio_err = csr_in32(IOADDR(A_BUS_MEM_IO_ERRORS));
                prom_printf("Bus watcher error counters: %08x %08x\n", l2_err, memio_err);
@@ -153,14 +153,14 @@ static void check_bus_watcher(void)
                       (int)(G_SCD_BERR_TID(status) >> 6),
                       (int)G_SCD_BERR_RID(status),
                       (int)G_SCD_BERR_DCODE(status));
-       } else {                
-               prom_printf("Bus watcher indicates no error\n"); 
-       }                       
-}                                       
-#else                                                    
-extern void check_bus_watcher(void);    
-#endif                                          
-                                
+       } else {
+               prom_printf("Bus watcher indicates no error\n");
+       }
+}
+#else
+extern void check_bus_watcher(void);
+#endif
+
 asmlinkage void sb1_cache_error(void)
 {
        uint64_t cerr_dpa;
index 9895e32b0fceca7d37899a096f62cd18d78f6c42..59e54f12212ecf86a41a22a4705936cdc3b6b2b2 100644 (file)
@@ -162,7 +162,7 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
 
        for (i = 0; i < nents; i++, sg++) {
                unsigned long addr;
+
                addr = (unsigned long) page_address(sg->page);
                if (addr)
                        __dma_sync(addr + sg->offset, sg->length, direction);
@@ -230,9 +230,9 @@ void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
        size_t size, enum dma_data_direction direction)
 {
        unsigned long addr;
+
        BUG_ON(direction == DMA_NONE);
+
        addr = dma_handle + PAGE_OFFSET;
        __dma_sync(addr, size, direction);
 }
@@ -282,9 +282,9 @@ void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
        enum dma_data_direction direction)
 {
        int i;
+
        BUG_ON(direction == DMA_NONE);
+
        /* Make sure that gcc doesn't leave the empty loop body.  */
        for (i = 0; i < nelems; i++, sg++)
                __dma_sync((unsigned long)page_address(sg->page),
index 9c9a271c8a3ae440748d89a22c464ea46444c46c..dc6830b10fab774fde2a19cdfbdc1b400df14ead 100644 (file)
@@ -96,7 +96,7 @@ static void __init kmap_init(void)
        kmap_prot = PAGE_KERNEL;
 }
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 static void __init fixrange_init(unsigned long start, unsigned long end,
        pgd_t *pgd_base)
 {
@@ -125,7 +125,7 @@ static void __init fixrange_init(unsigned long start, unsigned long end,
                j = 0;
        }
 }
-#endif /* CONFIG_MIPS64 */
+#endif /* CONFIG_64BIT */
 #endif /* CONFIG_HIGHMEM */
 
 #ifndef CONFIG_NEED_MULTIPLE_NODES
@@ -258,7 +258,7 @@ void __init mem_init(void)
 #ifdef CONFIG_BLK_DEV_INITRD
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        /* Switch from KSEG0 to XKPHYS addresses */
        start = (unsigned long)phys_to_virt(CPHYSADDR(start));
        end = (unsigned long)phys_to_virt(CPHYSADDR(end));
@@ -286,7 +286,7 @@ void free_initmem(void)
 
        addr = (unsigned long) &__init_begin;
        while (addr < (unsigned long) &__init_end) {
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
                page = PAGE_OFFSET | CPHYSADDR(addr);
 #else
                page = addr;
index 59d131b5e536811917691bd12bf2b936c11a9f4c..1b6df7133c1e1bdcb72ffbcbdbd45d9f8bf92f07 100644 (file)
@@ -114,7 +114,7 @@ static inline void copy_page_cpu(void *to, void *from)
        "       pref    " SB1_PREF_STORE_STREAMED_HINT ",  -64(%1)\n"
        "       pref    " SB1_PREF_LOAD_STREAMED_HINT  ",  -32(%0)\n"
        "1:     pref    " SB1_PREF_STORE_STREAMED_HINT ",  -32(%1)\n"
-# ifdef CONFIG_MIPS64
+# ifdef CONFIG_64BIT
        "       ld      $8, -128(%0)    \n"  /* Block copy a cacheline */
        "       ld      $9, -120(%0)    \n"
        "       ld      $10, -112(%0)   \n"
@@ -148,7 +148,7 @@ static inline void copy_page_cpu(void *to, void *from)
        "       daddiu  %0, %0, -128    \n"
        "       daddiu  %1, %1, -128    \n"
 #endif
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        "       ld      $8, 0(%0)       \n"  /* Block copy a cacheline */
        "1:     ld      $9, 8(%0)       \n"
        "       ld      $10, 16(%0)     \n"
@@ -178,7 +178,7 @@ static inline void copy_page_cpu(void *to, void *from)
        "       daddiu  %0, %0, 32      \n"
        "       daddiu  %1, %1, 32      \n"
        "       bnel    %0, %2, 1b      \n"
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        "        ld     $8, 0(%0)       \n"
 #else
        "        lw     $2, 0(%0)       \n"
@@ -186,7 +186,7 @@ static inline void copy_page_cpu(void *to, void *from)
        "       .set    pop             \n"
        : "+r" (src), "+r" (dst)
        : "r" (end)
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        : "$8","$9","$10","$11","memory");
 #else
        : "$2","$3","$6","$7","$8","$9","$10","$11","memory");
@@ -198,7 +198,7 @@ static inline void copy_page_cpu(void *to, void *from)
 
 /*
  * Pad descriptors to cacheline, since each is exclusively owned by a
- * particular CPU. 
+ * particular CPU.
  */
 typedef struct dmadscr_s {
        u64 dscr_a;
index 87e229f4d3d5c354b5ce3d8acf5290f8a00c23bf..6569be3983c79fde6e950aa7823b294f89dedac5 100644 (file)
@@ -448,7 +448,7 @@ L_LA(_r3000_write_probe_fail)
 L_LA(_r3000_write_probe_ok)
 
 /* convenience macros for instructions */
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 # define i_LW(buf, rs, rt, off) i_ld(buf, rs, rt, off)
 # define i_SW(buf, rs, rt, off) i_sd(buf, rs, rt, off)
 # define i_SLL(buf, rs, rt, sh) i_dsll(buf, rs, rt, sh)
@@ -486,7 +486,7 @@ L_LA(_r3000_write_probe_ok)
 #define i_ssnop(buf) i_sll(buf, 0, 0, 1)
 #define i_ehb(buf) i_sll(buf, 0, 0, 3)
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 static __init int __attribute__((unused)) in_compat_space_p(long addr)
 {
        /* Is this address in 32bit compat space? */
@@ -516,7 +516,7 @@ static __init int rel_lo(long val)
 
 static __init void i_LA_mostly(u32 **buf, unsigned int rs, long addr)
 {
-#if CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        if (!in_compat_space_p(addr)) {
                i_lui(buf, rs, rel_highest(addr));
                if (rel_higher(addr))
@@ -682,7 +682,7 @@ static void il_bgezl(u32 **p, struct reloc **r, unsigned int reg,
 #define C0_EPC         14
 #define C0_XCONTEXT    20
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 # define GET_CONTEXT(buf, reg) i_MFC0(buf, reg, C0_XCONTEXT)
 #else
 # define GET_CONTEXT(buf, reg) i_MFC0(buf, reg, C0_CONTEXT)
@@ -923,7 +923,7 @@ static __init void build_tlb_write_entry(u32 **p, struct label **l,
        }
 }
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 /*
  * TMP and PTR are scratch.
  * TMP will be clobbered, PTR will hold the pmd entry.
@@ -1010,7 +1010,7 @@ build_get_pgd_vmalloc64(u32 **p, struct label **l, struct reloc **r,
        }
 }
 
-#else /* !CONFIG_MIPS64 */
+#else /* !CONFIG_64BIT */
 
 /*
  * TMP and PTR are scratch.
@@ -1038,7 +1038,7 @@ build_get_pgde32(u32 **p, unsigned int tmp, unsigned int ptr)
        i_addu(p, ptr, ptr, tmp); /* add in pgd offset */
 }
 
-#endif /* !CONFIG_MIPS64 */
+#endif /* !CONFIG_64BIT */
 
 static __init void build_adjust_context(u32 **p, unsigned int ctx)
 {
@@ -1159,7 +1159,7 @@ static void __init build_r4000_tlb_refill_handler(void)
                /* No need for i_nop */
        }
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        build_get_pmde64(&p, &l, &r, K0, K1); /* get pmd in K1 */
 #else
        build_get_pgde32(&p, K0, K1); /* get pgd in K1 */
@@ -1171,7 +1171,7 @@ static void __init build_r4000_tlb_refill_handler(void)
        l_leave(&l, p);
        i_eret(&p); /* return from trap */
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        build_get_pgd_vmalloc64(&p, &l, &r, K0, K1);
 #endif
 
@@ -1182,7 +1182,7 @@ static void __init build_r4000_tlb_refill_handler(void)
         * need three, with the the second nop'ed and the third being
         * unused.
         */
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
        if ((p - tlb_handler) > 64)
                panic("TLB refill handler space exceeded");
 #else
@@ -1195,12 +1195,12 @@ static void __init build_r4000_tlb_refill_handler(void)
        /*
         * Now fold the handler in the TLB refill handler space.
         */
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
        f = final_handler;
        /* Simplest case, just copy the handler. */
        copy_handler(relocs, labels, tlb_handler, p, f);
        final_len = p - tlb_handler;
-#else /* CONFIG_MIPS64 */
+#else /* CONFIG_64BIT */
        f = final_handler + 32;
        if ((p - tlb_handler) <= 32) {
                /* Just copy the handler. */
@@ -1235,7 +1235,7 @@ static void __init build_r4000_tlb_refill_handler(void)
                copy_handler(relocs, labels, split, p, final_handler);
                final_len = (f - (final_handler + 32)) + (p - split);
        }
-#endif /* CONFIG_MIPS64 */
+#endif /* CONFIG_64BIT */
 
        resolve_relocs(relocs, labels);
        printk("Synthesized TLB refill handler (%u instructions).\n",
@@ -1605,7 +1605,7 @@ build_r4000_tlbchange_handler_head(u32 **p, struct label **l,
                                   struct reloc **r, unsigned int pte,
                                   unsigned int ptr)
 {
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        build_get_pmde64(p, l, r, pte, ptr); /* get pmd in ptr */
 #else
        build_get_pgde32(p, pte, ptr); /* get pgd in ptr */
@@ -1636,7 +1636,7 @@ build_r4000_tlbchange_handler_tail(u32 **p, struct label **l,
        l_leave(l, *p);
        i_eret(p); /* return from trap */
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        build_get_pgd_vmalloc64(p, l, r, tmp, ptr);
 #endif
 }
index 43fd5a58077c51ee63cd268eb0c496583f96c05f..55bc789733f2dcae18aab4f811aa816031c51a3d 100644 (file)
                SAVE_ALL
                CLI
                .set    at
-               mfc0    t0, CP0_CAUSE  
+               mfc0    t0, CP0_CAUSE
                mfc0    t2, CP0_STATUS
 
                and     t0, t2
-        
+
                andi    t1, t0, STATUSF_IP0     /* sw0 software interrupt */
                bnez    t1, ll_sw0_irq
                andi    t1, t0, STATUSF_IP1     /* sw1 software interrupt */
@@ -103,25 +103,25 @@ ll_pcia_irq:
                move    a1, sp
                jal     do_IRQ
                j       ret_from_irq
-       
+
 ll_pcib_irq:
                li      a0, 5
                move    a1, sp
                jal     do_IRQ
                j       ret_from_irq
-       
+
 ll_uart_irq:
                li      a0, 6
                move    a1, sp
                jal     do_IRQ
                j       ret_from_irq
-       
+
 ll_cputimer_irq:
                li      a0, 7
                move    a1, sp
                jal     ll_timer_interrupt
                j       ret_from_irq
-       
+
 ll_mv64340_decode_irq:
                move    a0, sp
                jal     ll_mv64340_irq
index fa5982ac0ac61db403e023e868bdce6e941ba8d0..14ae2e71358506b3364304cce3b7315774b3d7c1 100644 (file)
@@ -64,7 +64,7 @@ static u8 exchange_bit(u8 val, u8 cs)
 
        /* turn the clock off and read-strobe */
        JAGUAR_FPGA_WRITE((val << 2) | cs | 0x10, EEPROM_MODE);
-       
+
        /* return the data */
        return ((JAGUAR_FPGA_READ(EEPROM_MODE) >> 3) & 0x1);
 }
@@ -90,7 +90,7 @@ void get_mac(char dest[6])
 }
 #endif
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 
 unsigned long signext(unsigned long addr)
 {
@@ -143,7 +143,7 @@ char *arg64(unsigned long addrin, int arg_index)
 
        return p;
 }
-#endif  /* CONFIG_MIPS64 */
+#endif  /* CONFIG_64BIT */
 
 /* PMON passes arguments in C main() style */
 void __init prom_init(void)
@@ -158,7 +158,7 @@ void __init prom_init(void)
 //     ja_setup_console();     /* The very first thing.  */
 #endif
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        char *ptr;
 
        printk("Mips64 Jaguar-ATX\n");
@@ -201,7 +201,7 @@ void __init prom_init(void)
        }
        printk("arcs_cmdline: %s\n", arcs_cmdline);
 
-#else   /* CONFIG_MIPS64 */
+#else   /* CONFIG_64BIT */
        /* save the PROM vectors for debugging use */
        debug_vectors = cv;
 
@@ -226,7 +226,7 @@ void __init prom_init(void)
                }
                env++;
        }
-#endif /* CONFIG_MIPS64 */
+#endif /* CONFIG_64BIT */
        mips_machgroup = MACH_GROUP_MOMENCO;
        mips_machtype = MACH_MOMENCO_JAGUAR_ATX;
 
index 48039484cdf98ab85d95d29d466ff505ac66a2a9..c4236b1e59fa55b8d1b4ead6b51751903f82289e 100644 (file)
@@ -27,7 +27,7 @@
 void momenco_jaguar_restart(char *command)
 {
        /* base address of timekeeper portion of part */
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        void *nvram = (void*) 0xfffffffffc807000;
 #else
        void *nvram = (void*) 0xfc807000;
index 30462e715066a469437b303775d1073230b1edc4..90288cf2b1e083556c8acb51ac2ea1b996a52f5d 100644 (file)
@@ -105,7 +105,7 @@ void __init bus_error_init(void) { /* nothing */ }
 
 static __init void wire_stupidity_into_tlb(void)
 {
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
        write_c0_wired(0);
        local_flush_tlb_all();
 
@@ -451,7 +451,7 @@ static int  __init momenco_jaguar_atx_setup(void)
 #ifdef GEMDEBUG_TRACEBUFFER
        {
          unsigned int tbControl;
-         tbControl = 
+         tbControl =
            0 << 26 |  /* post trigger delay 0 */
                    0x2 << 16 |         /* sequential trace mode */
            //      0x0 << 16 |         /* non-sequential trace mode */
index 89c17a0c0bedbbf6b68e750a5fe46a5ca7af5404..c4fa9c525faaa56fb476454c5fd78a79772f1994 100644 (file)
@@ -93,7 +93,7 @@ void get_mac(char dest[6])
 #endif
 
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 
 unsigned long signext(unsigned long addr)
 {
@@ -145,7 +145,7 @@ char *arg64(unsigned long addrin, int arg_index)
 
        return p;
 }
-#endif  /* CONFIG_MIPS64 */
+#endif  /* CONFIG_64BIT */
 
 void __init prom_init(void)
 {
@@ -155,7 +155,7 @@ void __init prom_init(void)
        struct callvectors *cv = (struct callvectors *) fw_arg3;
        int i;
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        char *ptr;
        printk("prom_init - MIPS64\n");
 
@@ -198,7 +198,7 @@ void __init prom_init(void)
        }
        printk("arcs_cmdline: %s\n", arcs_cmdline);
 
-#else   /* CONFIG_MIPS64 */
+#else   /* CONFIG_64BIT */
 
        /* save the PROM vectors for debugging use */
        debug_vectors = cv;
@@ -224,7 +224,7 @@ void __init prom_init(void)
                }
                env++;
        }
-#endif /* CONFIG_MIPS64 */
+#endif /* CONFIG_64BIT */
 
        mips_machgroup = MACH_GROUP_MOMENCO;
        mips_machtype = MACH_MOMENCO_OCELOT_3;
@@ -234,7 +234,7 @@ void __init prom_init(void)
        get_mac(prom_mac_addr_base);
 #endif
 
-#ifndef CONFIG_MIPS64
+#ifndef CONFIG_64BIT
        debug_vectors->printf("Booting Linux kernel...\n");
 #endif
 }
index 2f2430648abc075ca168647b90696b944426e47d..52349d9bf1be8f5b3d3a1238a8145ae90721a5dc 100644 (file)
                SAVE_ALL
                CLI
                .set    at
-               mfc0    t0, CP0_CAUSE  
+               mfc0    t0, CP0_CAUSE
                mfc0    t2, CP0_STATUS
 
                and     t0, t2
-        
+
                andi    t1, t0, STATUSF_IP0     /* sw0 software interrupt */
                bnez    t1, ll_sw0_irq
                andi    t1, t0, STATUSF_IP1     /* sw1 software interrupt */
@@ -83,7 +83,7 @@ ll_pmc_irq:
                move    a1, sp
                jal     do_IRQ
                j       ret_from_irq
-       
+
 ll_cpci_decode_irq:
                move    a0, sp
                jal     ll_cpci_irq
@@ -99,4 +99,4 @@ ll_cputimer_irq:
                move    a1, sp
                jal     do_IRQ
                j       ret_from_irq
-       
+
index a6cf7a7959b3566a9932257f3da5e31cf88d90a2..97fb77dad7235b58d9d873f1adceee69fd62a35a 100644 (file)
@@ -32,7 +32,7 @@
 
 #include <linux/config.h>
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 #define OCELOT_C_CS0_ADDR       (0xfffffffffc000000)
 #else
 #define OCELOT_C_CS0_ADDR               (0xfc000000)
index 49ac302d8901b5b7a661fcb97643c580ae6b47c2..5b6809724b15efa987fa2880fa46047bc528af1b 100644 (file)
@@ -67,7 +67,7 @@ static u8 exchange_bit(u8 val, u8 cs)
 
        /* turn the clock off and read-strobe */
        OCELOT_FPGA_WRITE((val << 2) | cs | 0x10, EEPROM_MODE);
-       
+
        /* return the data */
        return ((OCELOT_FPGA_READ(EEPROM_MODE) >> 3) & 0x1);
 }
@@ -94,7 +94,7 @@ void get_mac(char dest[6])
 #endif
 
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 
 unsigned long signext(unsigned long addr)
 {
@@ -144,7 +144,7 @@ char *arg64(unsigned long addrin, int arg_index)
   p = (char *)get_arg(args, arg_index);
   return p;
 }
-#endif  /* CONFIG_MIPS64 */
+#endif  /* CONFIG_64BIT */
 
 
 void __init prom_init(void)
@@ -155,7 +155,7 @@ void __init prom_init(void)
        struct callvectors *cv = (struct callvectors *) fw_arg3;
        int i;
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        char *ptr;
 
        printk("prom_init - MIPS64\n");
@@ -197,7 +197,7 @@ void __init prom_init(void)
        }
        printk("arcs_cmdline: %s\n", arcs_cmdline);
 
-#else   /* CONFIG_MIPS64 */
+#else   /* CONFIG_64BIT */
        /* save the PROM vectors for debugging use */
        debug_vectors = cv;
 
@@ -222,7 +222,7 @@ void __init prom_init(void)
                }
                env++;
        }
-#endif /* CONFIG_MIPS64 */
+#endif /* CONFIG_64BIT */
 
        mips_machgroup = MACH_GROUP_MOMENCO;
        mips_machtype = MACH_MOMENCO_OCELOT_C;
@@ -232,7 +232,7 @@ void __init prom_init(void)
        get_mac(prom_mac_addr_base);
 #endif
 
-#ifndef CONFIG_MIPS64
+#ifndef CONFIG_64BIT
        debug_vectors->printf("Booting Linux kernel...\n");
 #endif
 }
index 1f2b4263cc8cb4753eb666b39d3c8e4631ddcdb8..6a2489f3b9a0f3648d7459d8c7e833e7e9bc41a5 100644 (file)
@@ -28,7 +28,7 @@ void momenco_ocelot_restart(char *command)
 {
        /* base address of timekeeper portion of part */
        void *nvram = (void *)
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
                0xfffffffffc807000;
 #else
                0xfc807000;
index 021c00e3c07c7934878ee878b476cc6a93661d21..844ddd06349b9d23f737eddf7df99ac11a76a484 100644 (file)
@@ -109,7 +109,7 @@ void PMON_v2_setup(void)
        */
   printk("PMON_v2_setup\n");
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        /* marvell and extra space */
        add_wired_entry(ENTRYLO(0xf4000000), ENTRYLO(0xf4010000), 0xfffffffff4000000, PM_64K);
        /* fpga, rtc, and uart */
@@ -134,7 +134,7 @@ void PMON_v2_setup(void)
 
 unsigned long m48t37y_get_time(void)
 {
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        unsigned char *rtc_base = (unsigned char*)0xfffffffffc800000;
 #else
        unsigned char* rtc_base = (unsigned char*)0xfc800000;
@@ -163,7 +163,7 @@ unsigned long m48t37y_get_time(void)
 
 int m48t37y_set_time(unsigned long sec)
 {
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        unsigned char* rtc_base = (unsigned char*)0xfffffffffc800000;
 #else
        unsigned char* rtc_base = (unsigned char*)0xfc800000;
@@ -342,7 +342,7 @@ static void __init momenco_ocelot_c_setup(void)
 
 early_initcall(momenco_ocelot_c_setup);
 
-#ifndef CONFIG_MIPS64
+#ifndef CONFIG_64BIT
 /* This needs to be one of the first initcalls, because no I/O port access
    can work before this */
 static int io_base_ioremap(void)
index b345e528a53c8bd1fb8534a2b8cb6c13ff7e1962..5a4a7c239c421220fc99e0284bbfcff95b965e39 100644 (file)
@@ -5,7 +5,7 @@ static void ddb5074_fixup(struct pci_dev *dev)
 {
        extern struct pci_dev *pci_pmu;
        u8 t8;
-                                                                
+
        pci_pmu = dev;  /* for LEDs D2 and D3 */
        /* Program the lines for LEDs D2 and D3 to output */
        pci_read_config_byte(dev, 0x7d, &t8);
index 6abdc88bab1e3fe14962403ae5fc6f03534286bc..2f1444e606542b4400747d34e1c10aad14c8f726 100644 (file)
@@ -65,7 +65,7 @@ static void ddb5477_amd_lance_fixup(struct pci_dev *dev)
        ioaddr = pci_resource_start(dev, 0);
 
        inw(ioaddr + PCNET32_WIO_RESET);        /* reset chip */
-                                                                                
+
        /* bcr_18 |= 0x0800 */
        outw(18, ioaddr + PCNET32_WIO_RAP);
        temp = inw(ioaddr + PCNET32_WIO_BDP);
index b9296d9942b3740e9e1a17f5f8a94fe30add7f35..bf2c41d1e9c53858601c8161204f022cc9fdb7c6 100644 (file)
@@ -56,7 +56,7 @@ static void __init malta_piix_func0_fixup(struct pci_dev *pdev)
                0,  0,  0,  3,
                4,  5,  6,  7,
                0,  9, 10, 11,
-               12, 0, 14, 15 
+               12, 0, 14, 15
        };
        int i;
 
index de4e443da208506a7e10945b401bbd08363f52ff..ceeb1860895ad67f5b57d817fd89885d7acf0978 100644 (file)
@@ -7,7 +7,7 @@
  * Author: MontaVista Software, Inc.
  *              ppopov@mvista.com or source@mvista.com
  *
- * Copyright (C) 2000-2001 Toshiba Corporation 
+ * Copyright (C) 2000-2001 Toshiba Corporation
  *
  * Copyright (C) 2004 MontaVista Software Inc.
  * Author: Manish Lachwani (mlachwani@mvista.com)
index c8ef01a017ccd8645d87e5b040ee9c974ad8c627..a176f2ca8656b1536db9f740c8de822d3340f265 100644 (file)
@@ -32,7 +32,7 @@
  * Device 4: Unused
  * Device 5: Slot 2
  * Device 6: Slot 3
- * Device 7: Slot 4    
+ * Device 7: Slot 4
  *
  * Documentation says the VGA is device 5 and device 3 is unused but that
  * seem to be a documentation error.  At least on my RM200C the Cirrus
index 850a900f0eb4eb8c8b8c6fcbfd581cb94890fb9b..bc55b06e190446655922d0203aa866777a69688c 100644 (file)
@@ -29,27 +29,12 @@ int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 
        switch (slot) {
        case 12:
-               vr41xx_set_irq_trigger(TB0219_PCI_SLOT1_PIN,
-                                      TRIGGER_LEVEL,
-                                      SIGNAL_THROUGH);
-               vr41xx_set_irq_level(TB0219_PCI_SLOT1_PIN,
-                                    LEVEL_LOW);
                irq = TB0219_PCI_SLOT1_IRQ;
                break;
        case 13:
-               vr41xx_set_irq_trigger(TB0219_PCI_SLOT2_PIN,
-                                      TRIGGER_LEVEL,
-                                      SIGNAL_THROUGH);
-               vr41xx_set_irq_level(TB0219_PCI_SLOT2_PIN,
-                                    LEVEL_LOW);
                irq = TB0219_PCI_SLOT2_IRQ;
                break;
        case 14:
-               vr41xx_set_irq_trigger(TB0219_PCI_SLOT3_PIN,
-                                      TRIGGER_LEVEL,
-                                      SIGNAL_THROUGH);
-               vr41xx_set_irq_level(TB0219_PCI_SLOT3_PIN,
-                                    LEVEL_LOW);
                irq = TB0219_PCI_SLOT3_IRQ;
                break;
        default:
index e955443fedf930f3a5f33df04eefa1dccec09a1e..0406b50a37d8d46c4f72219feed294fd97f7dea4 100644 (file)
@@ -127,7 +127,7 @@ static inline void ddb_close_config_base(struct pci_config_swap *swap)
 }
 
 static int read_config_dword(struct pci_config_swap *swap,
-                            struct pci_bus *bus, u32 devfn, u32 where, 
+                            struct pci_bus *bus, u32 devfn, u32 where,
                             u32 * val)
 {
        u32 bus_num, slot_num, func_num;
@@ -153,7 +153,7 @@ static int read_config_dword(struct pci_config_swap *swap,
 }
 
 static int read_config_word(struct pci_config_swap *swap,
-                           struct pci_bus *bus, u32 devfn, u32 where, 
+                           struct pci_bus *bus, u32 devfn, u32 where,
                            u16 * val)
 {
        int status;
index 2a9d7227fe87c98053aa076df91092ff56cb662c..7688b7711329364f48363ea13caaf27d81bcae94 100644 (file)
@@ -1,16 +1,16 @@
 /*
  * Copyright 2001 MontaVista Software Inc.
  * Author: MontaVista Software, Inc.
- *              ahennessy@mvista.com       
+ *              ahennessy@mvista.com
  *
- * Copyright (C) 2000-2001 Toshiba Corporation 
+ * Copyright (C) 2000-2001 Toshiba Corporation
  * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
  *
  * Based on arch/mips/ddb5xxx/ddb5477/pci_ops.c
  *
  *     Define the pci_ops for the Toshiba rbtx4927
  *
- * Much of the code is derived from the original DDB5074 port by 
+ * Much of the code is derived from the original DDB5074 port by
  * Geert Uytterhoeven <geert@sonycom.com>
  *
  * Copyright 2004 MontaVista Software Inc.
index 4ddd53eaf6568517d5baef7f4ee683a431a8eb2e..826d653184e576d1322c496d87a850102be309f6 100644 (file)
@@ -76,7 +76,7 @@ struct pci_controller ddb5477_io_controller = {
  */
 
 /*
- * irq mapping : device -> pci int # -> vrc4377 irq# , 
+ * irq mapping : device -> pci int # -> vrc4377 irq# ,
  * ddb5477 board manual page 4  and vrc5477 manual page 46
  */
 
@@ -137,9 +137,9 @@ int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
        unsigned char *slot_irq_map;
        unsigned char irq;
 
-       /* 
+       /*
         * We ignore the swizzled slot and pin values.  The original
-        * pci_fixup_irq() codes largely base irq number on the dev slot 
+        * pci_fixup_irq() codes largely base irq number on the dev slot
         * numbers because except for one case they are unique even
         * though there are multiple pci buses.
         */
@@ -160,7 +160,7 @@ int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 
        if (mips_machtype == MACH_NEC_ROCKHOPPERII) {
                /* hack to distinquish overlapping slot 20s, one
-                * on bus 0 (ALI USB on the M1535 on the backplane), 
+                * on bus 0 (ALI USB on the M1535 on the backplane),
                 * and one on bus 2 (NEC USB controller on the CPU board)
                 * Make the M1535 USB - ISA IRQ number 9.
                 */
index 1faeb034f06e45157b74ad283756b6b674999810..000dc6af6cd39310d0bd940f0c766fc96326090c 100644 (file)
@@ -84,7 +84,7 @@ static irqreturn_t macepci_error(int irq, void *dev, struct pt_regs *regs)
 
 
 extern struct pci_ops mace_pci_ops;
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 static struct resource mace_pci_mem_resource = {
        .name   = "SGI O2 PCI MEM",
        .start  = MACEPCI_HI_MEMORY,
index 8141dffac2411e8bd951f6777d08092d0e27feba..a8d499b0a36f1eca62d814d9477aba8becb734d8 100644 (file)
@@ -132,7 +132,7 @@ static int __init pcibios_init(void)
                hose->need_domain_info = need_domain_info;
                next_busno = bus->subordinate + 1;
                /* Don't allow 8-bit bus number overflow inside the hose -
-                  reserve some space for bridges. */ 
+                  reserve some space for bridges. */
                if (next_busno > 224) {
                        next_busno = 0;
                        need_domain_info = 1;
@@ -260,7 +260,7 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus)
                   (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
                pci_read_bridge_bases(bus);
                pcibios_fixup_device_resources(dev, bus);
-       } 
+       }
 
        for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) {
                struct pci_dev *dev = pci_dev_b(ln);
@@ -292,8 +292,25 @@ pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
        region->end = res->end - offset;
 }
 
+void __devinit
+pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
+                       struct pci_bus_region *region)
+{
+       struct pci_controller *hose = (struct pci_controller *)dev->sysdata;
+       unsigned long offset = 0;
+
+       if (res->flags & IORESOURCE_IO)
+               offset = hose->io_offset;
+       else if (res->flags & IORESOURCE_MEM)
+               offset = hose->mem_offset;
+
+       res->start = region->start + offset;
+       res->end = region->end + offset;
+}
+
 #ifdef CONFIG_HOTPLUG
 EXPORT_SYMBOL(pcibios_resource_to_bus);
+EXPORT_SYMBOL(pcibios_bus_to_resource);
 EXPORT_SYMBOL(PCIBIOS_MIN_IO);
 EXPORT_SYMBOL(PCIBIOS_MIN_MEM);
 #endif
index b067988614c34ce6c871a26d2d10d23d8749d16e..97862f45496d76ce0aa72c349182b53b5a895811 100644 (file)
@@ -30,7 +30,7 @@
  *
  * This code reads the ATMEL 24CXX EEPROM. The PMC-Sierra Yosemite board uses the ATMEL
  * 24C32/24C64 which uses two byte addressing as compared to 24C16. Note that this program
- * uses the serial port like /dev/ttyS0, to communicate with the EEPROM. Hence, you are 
+ * uses the serial port like /dev/ttyS0, to communicate with the EEPROM. Hence, you are
  * expected to have a connectivity from the EEPROM to the serial port. This program does
  * __not__ communicate using the I2C protocol
  */
@@ -64,14 +64,14 @@ static void send_ack(void)
 static void send_byte(unsigned char byte)
 {
        int     i = 0;
-       
-       for (i = 7; i >= 0; i--) 
+
+       for (i = 7; i >= 0; i--)
                send_bit((byte >> i) & 0x01);
 }
-       
+
 static void send_start(void)
 {
-       sda_hi; 
+       sda_hi;
        delay(TXX);
        scl_hi;
        delay(TXX);
@@ -114,9 +114,9 @@ static unsigned char recv_byte(void) {
         int i;
         unsigned char byte=0;
 
-        for (i=7;i>=0;i--)                             
+        for (i=7;i>=0;i--)
                 byte |= (recv_bit() << i);
+
         return byte;
 }
 
index d27566d99ffca79ad597b06f8a1dcb1188045d74..c19f01a320450168e4ed98947fd8a6d9011aacbd 100644 (file)
@@ -27,7 +27,7 @@
  */
 
 /*
- * Header file for atmel_read_eeprom.c 
+ * Header file for atmel_read_eeprom.c
  */
 
 #include <linux/types.h>
@@ -46,7 +46,7 @@
 #define        DEFAULT_PORT    "/dev/ttyS0"    /* Port to open */
 #define        TXX             0               /* Dummy loop for spinning */
 
-#define        BLOCK_SEL       0x00            
+#define        BLOCK_SEL       0x00
 #define        SLAVE_ADDR      0xa0
 #define        READ_BIT        0x01
 #define        WRITE_BIT       0x00
diff --git a/arch/mips/qemu/Makefile b/arch/mips/qemu/Makefile
new file mode 100644 (file)
index 0000000..934944a
--- /dev/null
@@ -0,0 +1,5 @@
+#
+# Makefile for Qemu specific kernel interface routines under Linux.
+#
+
+obj-y          = q-firmware.o q-int.o q-irq.o q-mem.o q-setup.o
diff --git a/arch/mips/qemu/q-firmware.c b/arch/mips/qemu/q-firmware.c
new file mode 100644 (file)
index 0000000..5980f02
--- /dev/null
@@ -0,0 +1,7 @@
+#include <linux/init.h>
+#include <asm/bootinfo.h>
+
+void __init prom_init(void)
+{
+       add_memory_region(0x0<<20, 0x10<<20, BOOT_MEM_RAM);
+}
diff --git a/arch/mips/qemu/q-int.S b/arch/mips/qemu/q-int.S
new file mode 100644 (file)
index 0000000..6e3dfe5
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Qemu interrupt handler code.
+ *
+ * Copyright (C) 2005 by Ralf Baechle
+ */
+#include <asm/asm.h>
+#include <asm/regdef.h>
+#include <asm/stackframe.h>
+
+       .align  5
+       NESTED(qemu_handle_int, PT_SIZE, sp)
+       SAVE_ALL
+       CLI
+       move    a0, sp
+       PTR_LA  ra, ret_from_irq
+       j       do_qemu_int
+       END(qemu_handle_int)
diff --git a/arch/mips/qemu/q-irq.c b/arch/mips/qemu/q-irq.c
new file mode 100644 (file)
index 0000000..2c4e070
--- /dev/null
@@ -0,0 +1,37 @@
+#include <linux/init.h>
+#include <linux/linkage.h>
+
+#include <asm/i8259.h>
+#include <asm/mipsregs.h>
+#include <asm/qemu.h>
+#include <asm/system.h>
+#include <asm/time.h>
+
+extern asmlinkage void qemu_handle_int(void);
+
+asmlinkage void do_qemu_int(struct pt_regs *regs)
+{
+       unsigned int pending = read_c0_status() & read_c0_cause();
+
+       if (pending & 0x8000) {
+               ll_timer_interrupt(Q_COUNT_COMPARE_IRQ, regs);
+               return;
+       }
+       if (pending & 0x0400) {
+               int irq = i8259_irq();
+
+               if (likely(irq >= 0))
+                       do_IRQ(irq, regs);
+
+               return;
+       }
+}
+
+void __init arch_init_irq(void)
+{
+       set_except_vector(0, qemu_handle_int);
+       mips_hpt_frequency = QEMU_C0_COUNTER_CLOCK;             /* 100MHz */
+
+       init_i8259_irqs();
+       set_c0_status(0x8400);
+}
diff --git a/arch/mips/qemu/q-mem.c b/arch/mips/qemu/q-mem.c
new file mode 100644 (file)
index 0000000..d174fac
--- /dev/null
@@ -0,0 +1,6 @@
+#include <linux/init.h>
+
+unsigned long __init prom_free_prom_memory(void)
+{
+       return 0UL;
+}
diff --git a/arch/mips/qemu/q-setup.c b/arch/mips/qemu/q-setup.c
new file mode 100644 (file)
index 0000000..1a80eee
--- /dev/null
@@ -0,0 +1,20 @@
+#include <linux/init.h>
+#include <asm/io.h>
+#include <asm/time.h>
+
+#define QEMU_PORT_BASE 0xb4000000
+
+static void __init qemu_timer_setup(struct irqaction *irq)
+{
+       /* set the clock to 100 Hz */
+       outb_p(0x34,0x43);              /* binary, mode 2, LSB/MSB, ch 0 */
+       outb_p(LATCH & 0xff , 0x40);    /* LSB */
+       outb(LATCH >> 8 , 0x40);        /* MSB */
+       setup_irq(0, irq);
+}
+
+void __init plat_setup(void)
+{
+       set_io_port_base(QEMU_PORT_BASE);
+       board_timer_setup = qemu_timer_setup;
+}
index 0ab4abf65d58109845f6dca7afa7c6d0b386bfb1..fa0e719c5bd1c3d4c7032de57c05fe261fd54762 100644 (file)
@@ -242,7 +242,7 @@ int __init ip22_eisa_init(void)
        int i, c;
        char *str;
        u8 *slot_addr;
-       
+
        if (!(sgimc->systemid & SGIMC_SYSID_EPRESENT)) {
                printk(KERN_INFO "EISA: bus not present.\n");
                return 1;
index c0afeccb08c40d42c68afdadf9cb1410a04f0c1a..5c00cdd20d8e05196f421cec71a109de63e0d399 100644 (file)
@@ -49,7 +49,7 @@ void __init sgihpc_init(void)
                sgint = &sgioc->int3;
                system_type = "SGI Indy";
        }
-       
+
        sgi_ioc_reset = (SGIOC_RESET_PPORT | SGIOC_RESET_KBDMOUSE |
                         SGIOC_RESET_EISA | SGIOC_RESET_ISDN |
                         SGIOC_RESET_LC0OFF);
index ea2844d29e6ecca93dbfe898d3f003edd2d6812b..d16fb43b1a93ba745f2a9838247f7bd1f845f932 100644 (file)
@@ -28,7 +28,7 @@
 /* #define DEBUG_SGINT */
 
 /* So far nothing hangs here */
-#undef USE_LIO3_IRQ 
+#undef USE_LIO3_IRQ
 
 struct sgint_regs *sgint;
 
@@ -272,32 +272,32 @@ void indy_buserror_irq(struct pt_regs *regs)
        irq_exit();
 }
 
-static struct irqaction local0_cascade = { 
+static struct irqaction local0_cascade = {
        .handler        = no_action,
        .flags          = SA_INTERRUPT,
        .name           = "local0 cascade",
 };
 
-static struct irqaction local1_cascade = { 
+static struct irqaction local1_cascade = {
        .handler        = no_action,
        .flags          = SA_INTERRUPT,
        .name           = "local1 cascade",
 };
 
-static struct irqaction buserr = { 
+static struct irqaction buserr = {
        .handler        = no_action,
        .flags          = SA_INTERRUPT,
        .name           = "Bus Error",
 };
 
-static struct irqaction map0_cascade = { 
+static struct irqaction map0_cascade = {
        .handler        = no_action,
        .flags          = SA_INTERRUPT,
        .name           = "mapable0 cascade",
 };
 
 #ifdef USE_LIO3_IRQ
-static struct irqaction map1_cascade = { 
+static struct irqaction map1_cascade = {
        .handler        = no_action,
        .flags          = SA_INTERRUPT,
        .name           = "mapable1 cascade",
index de43e86fa17ce409db8a008da58b445281e07c8a..fd29fd407ae83da6db8022277ff294128b73b8f4 100644 (file)
@@ -39,7 +39,7 @@
        *ptr |= EEPROM_CSEL;    \
        *ptr |= EEPROM_ECLK; })
 
-               
+
 #define eeprom_cs_off(ptr) ({  \
        *ptr &= ~EEPROM_ECLK;   \
        *ptr &= ~EEPROM_CSEL;   \
@@ -50,7 +50,7 @@
 /*
  * clock in the nvram command and the register number. For the
  * national semiconductor nv ram chip the op code is 3 bits and
- * the address is 6/8 bits. 
+ * the address is 6/8 bits.
  */
 static inline void eeprom_cmd(volatile unsigned int *ctrl, unsigned cmd,
                              unsigned reg)
@@ -90,7 +90,7 @@ unsigned short ip22_eeprom_read(volatile unsigned int *ctrl, int reg)
                if (*ctrl & EEPROM_DATI)
                        res |= 1;
        }
-               
+
        eeprom_cs_off(ctrl);
 
        return res;
@@ -113,7 +113,7 @@ unsigned short ip22_nvram_read(int reg)
                reg <<= 1;
                tmp = hpc3c0->bbram[reg++] & 0xff;
                return (tmp << 8) | (hpc3c0->bbram[reg] & 0xff);
-       }               
+       }
 }
 
 EXPORT_SYMBOL(ip22_nvram_read);
index ed5c60adce6303737ffb2abd86ab3df3d082af39..214ffd2e98a332dad828755ea2f4da9619dee12c 100644 (file)
@@ -185,7 +185,7 @@ static irqreturn_t panel_int(int irq, void *dev_id, struct pt_regs *regs)
                add_timer(&debounce_timer);
        }
 
-       /* Power button was pressed 
+       /* Power button was pressed
         * ioc.ps page 22: "The Panel Register is called Power Control by Full
         * House. Only lowest 2 bits are used. Guiness uses upper four bits
         * for volume control". This is not true, all bits are pulled high
index 173f76805ea3d30d3928d235f756d5f587b978fe..df9b5694328a1801f0e04a9b403b0227622cb194 100644 (file)
@@ -126,7 +126,7 @@ static __init void indy_time_init(void)
        unsigned long r4k_ticks[3];
        unsigned long r4k_tick;
 
-       /* 
+       /*
         * Figure out the r4k offset, the algorithm is very simple and works in
         * _all_ cases as long as the 8254 counter register itself works ok (as
         * an interrupt driving timer it does not because of bug, this is why
index a160d04f7dbe05904f84f60a262ba3b3fbb287d1..ef20d9ac0ba3d0d39d7510c46f465d41ea041932 100644 (file)
@@ -538,7 +538,7 @@ void __init mem_init(void)
        for_each_online_node(node) {
                unsigned slot, numslots;
                struct page *end, *p;
-       
+
                /*
                 * This will free up the bootmem, ie, slot 0 memory.
                 */
index 281f090e48a4105cad5d75ba109a58ab98645ea9..88e1f52059ff6a45c1d461cffb42302377bbe4e2 100644 (file)
@@ -140,7 +140,7 @@ static irqreturn_t ip32_rtc_int(int irq, void *dev_id, struct pt_regs *regs)
 
        reg_c = CMOS_READ(RTC_INTR_FLAGS);
        if (!(reg_c & RTC_IRQF)) {
-               printk(KERN_WARNING 
+               printk(KERN_WARNING
                        "%s: RTC IRQ without RTC_IRQF\n", __FUNCTION__);
        }
        /* Wait until interrupt goes away */
index 77eb4935bfb4b0b6a08ab87331c1a456dd290209..975f00002cbe269ef399b3fafe32c4c934f4619c 100644 (file)
  */
 
 /*  *********************************************************************
-    *  
+    *
     *  Broadcom Common Firmware Environment (CFE)
-    *  
+    *
     *  Error codes                             File: cfe_error.h
-    *  
+    *
     *  CFE's global error code list is here.
-    *  
+    *
     *  Author:  Mitch Lichtenberg
-    *  
+    *
     ********************************************************************* */
 
 
index 53a5c1eb5611fa2943fe0cd9df118d0b5541504a..7721100d0275dd566c9aa67d1b5b1489beb00eed 100644 (file)
@@ -38,7 +38,7 @@ static void cfe_console_write(struct console *cons, const char *str,
                        last += written;
                } while (last < count);
        }
-                       
+
 }
 
 static int cfe_console_setup(struct console *cons, char *str)
index d6d0364fa7603a1a29e6be2371f54cd6174566ba..7a2c7a8510d421593d487233ea1834740fa0d9ed 100644 (file)
@@ -33,7 +33,7 @@
 #include "cfe_error.h"
 
 /* Max ram addressable in 32-bit segments */
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 #define MAX_RAM_SIZE (~0ULL)
 #else
 #ifdef CONFIG_HIGHMEM
@@ -285,7 +285,7 @@ void __init prom_init(void)
                while (1) ;
        }
        cfe_init(cfe_handle, cfe_ept);
-       /* 
+       /*
         * Get the handle for (at least) prom_putchar, possibly for
         * boot console
         */
index 73392190d2b17f7851f0d5ee9d004e1e7679c9c9..e44ce1a9eea94e53da9c0628eb7765dce48ece47 100644 (file)
@@ -57,7 +57,7 @@ void __init prom_prepare_cpus(unsigned int max_cpus)
 void prom_boot_secondary(int cpu, struct task_struct *idle)
 {
        int retval;
-       
+
        retval = cfe_cpu_start(cpu_logical_map(cpu), &smp_bootstrap,
                               __KSTK_TOS(idle),
                               (unsigned long)idle->thread_info, 0);
index 182a16f42e2d746c86ba4abd83d71a868b82422d..1a97e3127aeb951fb199a981463fb1b3fe6da7f1 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
-/* 
+/*
  * The Bus Watcher monitors internal bus transactions and maintains
  * counts of transactions with error status, logging details and
  * causing one of several interrupts.  This driver provides a handler
@@ -155,7 +155,7 @@ static int bw_read_proc(char *page, char **start, off_t off,
 static void create_proc_decoder(struct bw_stats_struct *stats)
 {
        struct proc_dir_entry *ent;
-       
+
        ent = create_proc_read_entry("bus_watcher", S_IWUSR | S_IRUGO, NULL,
                                     bw_read_proc, stats);
        if (!ent) {
index 2728abbc94d29b6fb2ffc6986265b888e75c18d5..2725b263ccedaf7286c46506d67fac7088205ecc 100644 (file)
@@ -377,7 +377,7 @@ void __init arch_init_irq(void)
 
        /*
         * Note that the timer interrupts are also mapped, but this is
-        * done in sb1250_time_init().  Also, the profiling driver 
+        * done in sb1250_time_init().  Also, the profiling driver
         * does its own management of IP7.
         */
 
@@ -392,7 +392,7 @@ void __init arch_init_irq(void)
        if (kgdb_flag) {
                kgdb_irq = K_INT_UART_0 + kgdb_port;
 
-#ifdef CONFIG_SIBYTE_SB1250_DUART      
+#ifdef CONFIG_SIBYTE_SB1250_DUART
                sb1250_duart_present[kgdb_port] = 0;
 #endif
                /* Setup uart 1 settings, mapper */
index 0e633ee8d83cb79d78b1480768ef862572d0e978..a686bb716ec67e8b5061c9c975689bd6a502e6eb 100644 (file)
@@ -128,7 +128,7 @@ static int m41t81_write(uint8_t addr, int b)
                /* Clear error bit by writing a 1 */
                bus_writeq(M_SMB_ERROR, SMB_CSR(R_SMB_STATUS));
                return -1;
-       } 
+       }
 
        /* read the same byte again to make sure it is written */
        bus_writeq(V_SMB_ADDR(M41T81_CCR_ADDRESS) | V_SMB_TT_RD1BYTE,
@@ -136,7 +136,7 @@ static int m41t81_write(uint8_t addr, int b)
 
        while (bus_readq(SMB_CSR(R_SMB_STATUS)) & M_SMB_BUSY)
                ;
-       
+
        return 0;
 }
 
@@ -148,13 +148,13 @@ int m41t81_set_time(unsigned long t)
 
        /*
         * Note the write order matters as it ensures the correctness.
-        * When we write sec, 10th sec is clear.  It is reasonable to 
+        * When we write sec, 10th sec is clear.  It is reasonable to
         * believe we should finish writing min within a second.
         */
 
        tm.tm_sec = BIN2BCD(tm.tm_sec);
        m41t81_write(M41T81REG_SC, tm.tm_sec);
-       
+
        tm.tm_min = BIN2BCD(tm.tm_min);
        m41t81_write(M41T81REG_MN, tm.tm_min);
 
@@ -187,7 +187,7 @@ unsigned long m41t81_get_time(void)
 {
        unsigned int year, mon, day, hour, min, sec;
 
-       /* 
+       /*
         * min is valid if two reads of sec are the same.
         */
        for (;;) {
index 457aeb7be85830bce79ebc75b34b54d46d348f03..4daeaa413def7fe8367c76670172b746c6bec1e4 100644 (file)
@@ -73,7 +73,7 @@ int swarm_be_handler(struct pt_regs *regs, int is_fixup)
 {
        if (!is_fixup && (regs->cp0_cause & 4)) {
                /* Data bus error - print PA */
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
                printk("DBE physical address: %010lx\n",
                       __read_64bit_c0_register($26, 1));
 #else
@@ -98,7 +98,7 @@ static int __init swarm_setup(void)
                rtc_get_time = xicor_get_time;
                rtc_set_time = xicor_set_time;
        }
+
        if (m41t81_probe()) {
                printk("swarm setup: M41T81 RTC detected.\n");
                rtc_get_time = m41t81_get_time;
index 62c760f14674a4d54611d9749654c0f733fadca3..141a310d74d80da02d6e470d7d3f0bc1c4237a63 100644 (file)
@@ -103,7 +103,7 @@ static unsigned int ls1bit8(unsigned int x)
 
 /*
  * hwint 1 deals with EISA and SCSI interrupts,
- * 
+ *
  * The EISA_INT bit in CSITPEND is high active, all others are low active.
  */
 void pciasic_hwint1(struct pt_regs *regs)
index 8f67cee4317bd17051daf8f8b582eda6426051c6..1b3f8a0903e10722de9dc67150289d79f7c74701 100644 (file)
@@ -111,7 +111,7 @@ static struct resource sni_mem_resource = {
  * The RM200/RM300 has a few holes in it's PCI/EISA memory address space used
  * for other purposes.  Be paranoid and allocate all of the before the PCI
  * code gets a chance to to map anything else there ...
- * 
+ *
  * This leaves the following areas available:
  *
  * 0x10000000 - 0x1009ffff (640kB) PCI/EISA/ISA Bus Memory
index ca123e28d1ef3630d00867b54fb5ada7f3c0448d..dd3ceda9d712f84cc6e828bd446556c9a76913b9 100644 (file)
                CLI
                .set    at
 
-               mfc0    t0, CP0_CAUSE  
+               mfc0    t0, CP0_CAUSE
                mfc0    t1, CP0_STATUS
                and     t0, t1
-        
+
                andi    t1, t0, STATUSF_IP7     /* cpu timer */
                bnez    t1, ll_ip7
-               
+
                /* IP6..IP3 multiplexed -- do not use */
 
                andi    t1, t0, STATUSF_IP2     /* tx4927 pic */
index 16bcbdc6d1cc7f0a182d4b390329040c84b0c2af..26d7c53612a88cf93aaa49cfb99cd7f8980f568a 100644 (file)
@@ -152,7 +152,7 @@ dump_cp0(char *key)
        print_cp0(key, 16, "CONFIG  ", read_c0_config());
        return;
 }
-       
+
 void print_pic(char *key, u32 reg, char *name)
 {
        printk("%s pic:0x%08x:%s=0x%08x\n", key, reg, name,
index 86ca4cf2d587490344e9cf9fd14dc6d88de2144e..c1a377a80a5d3de7d0069f3fb4e980476599fd2c 100644 (file)
@@ -1,5 +1,5 @@
-obj-y  += toshiba_rbtx4927_prom.o 
-obj-y  += toshiba_rbtx4927_setup.o 
-obj-y  += toshiba_rbtx4927_irq.o 
+obj-y  += toshiba_rbtx4927_prom.o
+obj-y  += toshiba_rbtx4927_setup.o
+obj-y  += toshiba_rbtx4927_irq.o
 
 EXTRA_AFLAGS := $(CFLAGS)
index fd5b433f83b762ceb12f606f93fbc7255081ab94..aee07ff2212a37bb1348a6a48d783dea94a8146e 100644 (file)
@@ -31,7 +31,7 @@
 
 
 /*
-IRQ  Device  
+IRQ  Device
 00   RBTX4927-ISA/00
 01   RBTX4927-ISA/01 PS2/Keyboard
 02   RBTX4927-ISA/02 Cascade RBTX4927-ISA (irqs 8-15)
@@ -52,15 +52,15 @@ IRQ  Device
 16   TX4927-CP0/00 Software 0
 17   TX4927-CP0/01 Software 1
 18   TX4927-CP0/02 Cascade TX4927-CP0
-19   TX4927-CP0/03 Multiplexed -- do not use 
-20   TX4927-CP0/04 Multiplexed -- do not use 
-21   TX4927-CP0/05 Multiplexed -- do not use 
-22   TX4927-CP0/06 Multiplexed -- do not use 
+19   TX4927-CP0/03 Multiplexed -- do not use
+20   TX4927-CP0/04 Multiplexed -- do not use
+21   TX4927-CP0/05 Multiplexed -- do not use
+22   TX4927-CP0/06 Multiplexed -- do not use
 23   TX4927-CP0/07 CPU TIMER
 
 24   TX4927-PIC/00
 25   TX4927-PIC/01
-26   TX4927-PIC/02  
+26   TX4927-PIC/02
 27   TX4927-PIC/03 Cascade RBTX4927-IOC
 28   TX4927-PIC/04
 29   TX4927-PIC/05 RBTX4927 RTL-8019AS ethernet
@@ -80,7 +80,7 @@ IRQ  Device
 43   TX4927-PIC/19
 44   TX4927-PIC/20
 45   TX4927-PIC/21
-46   TX4927-PIC/22 TX4927 PCI PCI-ERR 
+46   TX4927-PIC/22 TX4927 PCI PCI-ERR
 47   TX4927-PIC/23 TX4927 PCI PCI-PMA (not used)
 48   TX4927-PIC/24
 49   TX4927-PIC/25
@@ -100,7 +100,7 @@ IRQ  Device
 62 RBTX4927-IOC/06
 63 RBTX4927-IOC/07
 
-NOTES: 
+NOTES:
 SouthBridge/INTR is mapped to SouthBridge/A=PCI-B/#58
 SouthBridge/ISA/pin=0 no pci irq used by this device
 SouthBridge/IDE/pin=1 no pci irq used by this device, using INTR via ISA IRQ14
@@ -175,19 +175,19 @@ JP7 is not bus master -- do NOT use -- only 4 pci bus master's allowed -- SouthB
 static const u32 toshiba_rbtx4927_irq_debug_flag =
     (TOSHIBA_RBTX4927_IRQ_NONE | TOSHIBA_RBTX4927_IRQ_INFO |
      TOSHIBA_RBTX4927_IRQ_WARN | TOSHIBA_RBTX4927_IRQ_EROR
-//                                                 | TOSHIBA_RBTX4927_IRQ_IOC_INIT  
-//                                                 | TOSHIBA_RBTX4927_IRQ_IOC_STARTUP  
-//                                                 | TOSHIBA_RBTX4927_IRQ_IOC_SHUTDOWN  
-//                                                 | TOSHIBA_RBTX4927_IRQ_IOC_ENABLE  
-//                                                 | TOSHIBA_RBTX4927_IRQ_IOC_DISABLE  
-//                                                 | TOSHIBA_RBTX4927_IRQ_IOC_MASK  
-//                                                 | TOSHIBA_RBTX4927_IRQ_IOC_ENDIRQ  
-//                                                 | TOSHIBA_RBTX4927_IRQ_ISA_INIT  
-//                                                 | TOSHIBA_RBTX4927_IRQ_ISA_STARTUP  
-//                                                 | TOSHIBA_RBTX4927_IRQ_ISA_SHUTDOWN  
-//                                                 | TOSHIBA_RBTX4927_IRQ_ISA_ENABLE  
-//                                                 | TOSHIBA_RBTX4927_IRQ_ISA_DISABLE  
-//                                                 | TOSHIBA_RBTX4927_IRQ_ISA_MASK  
+//                                                 | TOSHIBA_RBTX4927_IRQ_IOC_INIT
+//                                                 | TOSHIBA_RBTX4927_IRQ_IOC_STARTUP
+//                                                 | TOSHIBA_RBTX4927_IRQ_IOC_SHUTDOWN
+//                                                 | TOSHIBA_RBTX4927_IRQ_IOC_ENABLE
+//                                                 | TOSHIBA_RBTX4927_IRQ_IOC_DISABLE
+//                                                 | TOSHIBA_RBTX4927_IRQ_IOC_MASK
+//                                                 | TOSHIBA_RBTX4927_IRQ_IOC_ENDIRQ
+//                                                 | TOSHIBA_RBTX4927_IRQ_ISA_INIT
+//                                                 | TOSHIBA_RBTX4927_IRQ_ISA_STARTUP
+//                                                 | TOSHIBA_RBTX4927_IRQ_ISA_SHUTDOWN
+//                                                 | TOSHIBA_RBTX4927_IRQ_ISA_ENABLE
+//                                                 | TOSHIBA_RBTX4927_IRQ_ISA_DISABLE
+//                                                 | TOSHIBA_RBTX4927_IRQ_ISA_MASK
 //                                                 | TOSHIBA_RBTX4927_IRQ_ISA_ENDIRQ
     );
 #endif
index 8724ea3ae04eff263e10146af7c50b7f464c38e6..fc0720599fd9d64ab4e4d12be4d317a9b37fcb98 100644 (file)
@@ -395,7 +395,7 @@ static int __init tx4927_pcibios_init(void)
                        /* enable secondary ide */
                        v08_43 |= 0x80;
 
-                       /* 
+                       /*
                         * !!! DO NOT REMOVE THIS COMMENT IT IS REQUIRED BY SMSC !!!
                         *
                         * This line of code is intended to provide the user with a work
diff --git a/arch/mips/vr4181/common/Makefile b/arch/mips/vr4181/common/Makefile
deleted file mode 100644 (file)
index f7587ca..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#
-# Makefile for common code of NEC vr4181 based boards
-#
-
-obj-y   := irq.o int_handler.o serial.o time.o
-
-EXTRA_AFLAGS := $(CFLAGS)
diff --git a/arch/mips/vr4181/common/int_handler.S b/arch/mips/vr4181/common/int_handler.S
deleted file mode 100644 (file)
index 2c041b8..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * arch/mips/vr4181/common/int_handler.S
- *
- * Adapted to the VR4181 and almost entirely rewritten:
- * Copyright (C) 1999 Bradley D. LaRonde and Michael Klar
- *
- * Clean up to conform to the new IRQ
- * Copyright (C) 2001 MontaVista Software Inc.
- * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- */
-
-#include <asm/asm.h>
-#include <asm/regdef.h>
-#include <asm/mipsregs.h>
-#include <asm/stackframe.h>
-
-#include <asm/vr4181/vr4181.h>
-
-/*
- * [jsun]
- * See include/asm/vr4181/irq.h for IRQ assignment and strategy.
- */
-
-       .text
-       .set    noreorder
-
-       .align  5
-       NESTED(vr4181_handle_irq, PT_SIZE, ra)
-
-       .set    noat
-       SAVE_ALL
-       CLI
-
-       .set    at
-       .set    noreorder
-
-       mfc0    t0, CP0_CAUSE
-       mfc0    t2, CP0_STATUS
-
-       and     t0, t2
-
-       /* we check IP3 first; it happens most frequently */
-       andi    t1, t0, STATUSF_IP3
-       bnez    t1, ll_cpu_ip3
-       andi    t1, t0, STATUSF_IP2
-       bnez    t1, ll_cpu_ip2
-       andi    t1, t0, STATUSF_IP7     /* cpu timer */
-       bnez    t1, ll_cputimer_irq
-       andi    t1, t0, STATUSF_IP4
-       bnez    t1, ll_cpu_ip4
-       andi    t1, t0, STATUSF_IP5
-       bnez    t1, ll_cpu_ip5
-       andi    t1, t0, STATUSF_IP6
-       bnez    t1, ll_cpu_ip6
-       andi    t1, t0, STATUSF_IP0     /* software int 0 */
-       bnez    t1, ll_cpu_ip0
-       andi    t1, t0, STATUSF_IP1     /* software int 1 */
-       bnez    t1, ll_cpu_ip1
-       nop
-
-       .set    reorder
-do_spurious:
-       j       spurious_interrupt
-
-/*
- * regular CPU irqs
- */
-ll_cputimer_irq:
-       li      a0, VR4181_IRQ_TIMER
-       move    a1, sp
-       jal     do_IRQ
-       j       ret_from_irq
-
-
-ll_cpu_ip0:
-       li      a0, VR4181_IRQ_SW1
-       move    a1, sp
-       jal     do_IRQ
-       j       ret_from_irq
-
-ll_cpu_ip1:
-       li      a0, VR4181_IRQ_SW2
-       move    a1, sp
-       jal     do_IRQ
-       j       ret_from_irq
-
-ll_cpu_ip3:
-       li      a0, VR4181_IRQ_INT1
-       move    a1, sp
-       jal     do_IRQ
-       j       ret_from_irq
-
-ll_cpu_ip4:
-       li      a0, VR4181_IRQ_INT2
-       move    a1, sp
-       jal     do_IRQ
-       j       ret_from_irq
-
-ll_cpu_ip5:
-       li      a0, VR4181_IRQ_INT3
-       move    a1, sp
-       jal     do_IRQ
-       j       ret_from_irq
-
-ll_cpu_ip6:
-       li      a0, VR4181_IRQ_INT4
-       move    a1, sp
-       jal     do_IRQ
-       j       ret_from_irq
-
-/*
- *  One of the sys irq has happend.
- *
- *  In the interest of speed, we first determine in the following order
- *  which 16-irq block have pending interrupts:
- *     sysint1 (16 sources, including cascading intrs from GPIO)
- *     sysint2
- *     gpio (16 intr sources)
- *
- *  Then we do binary search to find the exact interrupt source.
- */
-ll_cpu_ip2:
-
-       lui     t3,%hi(VR4181_SYSINT1REG)
-       lhu     t0,%lo(VR4181_SYSINT1REG)(t3)
-       lhu     t2,%lo(VR4181_MSYSINT1REG)(t3)
-       and     t0, 0xfffb              /* hack - remove RTC Long 1 intr */
-       and     t0, t2
-       beqz    t0, check_sysint2
-
-       /* check for GPIO interrupts */
-       andi    t1, t0, 0x0100
-       bnez    t1, check_gpio_int
-
-       /* so we have an interrupt in sysint1 which is not gpio int */
-       li      a0, VR4181_SYS_IRQ_BASE - 1
-       j       check_16
-
-check_sysint2:
-
-       lhu     t0,%lo(VR4181_SYSINT2REG)(t3)
-       lhu     t2,%lo(VR4181_MSYSINT2REG)(t3)
-       and     t0, 0xfffe              /* hack - remove RTC Long 2 intr */
-       and     t0, t2
-       li      a0, VR4181_SYS_IRQ_BASE + 16 - 1
-       j       check_16
-
-check_gpio_int:
-       lui     t3,%hi(VR4181_GPINTMSK)
-       lhu     t0,%lo(VR4181_GPINTMSK)(t3)
-       lhu     t2,%lo(VR4181_GPINTSTAT)(t3)
-       xori    t0, 0xffff                      /* why? reverse logic? */
-       and     t0, t2
-       li      a0, VR4181_GPIO_IRQ_BASE - 1
-       j       check_16
-
-/*
- *  When we reach check_16, we have 16-bit status in t0 and base irq number
- *  in a0.
- */
-check_16:
-       andi    t1, t0, 0xff
-       bnez    t1, check_8
-
-       srl     t0, 8
-       addi    a0, 8
-       j       check_8
-
-/*
- *  When we reach check_8, we have 8-bit status in t0 and base irq number
- *  in a0.
- */
-check_8:
-       andi    t1, t0, 0xf
-       bnez    t1, check_4
-
-       srl     t0, 4
-       addi    a0, 4
-       j       check_4
-
-/*
- *  When we reach check_4, we have 4-bit status in t0 and base irq number
- *  in a0.
- */
-check_4:
-       andi    t0, t0, 0xf
-       beqz    t0, do_spurious
-
-loop:
-       andi    t2, t0, 0x1
-       srl     t0, 1
-       addi    a0, 1
-       beqz    t2, loop
-
-found_it:
-       move    a1, sp
-       jal     do_IRQ
-
-       j       ret_from_irq
-
-       END(vr4181_handle_irq)
diff --git a/arch/mips/vr4181/common/irq.c b/arch/mips/vr4181/common/irq.c
deleted file mode 100644 (file)
index 2cdf77c..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * Copyright (C) 2001 MontaVista Software Inc.
- * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
- * Copyright (C) 2005 Ralf Baechle (ralf@linux-mips.org)
- *
- * linux/arch/mips/vr4181/common/irq.c
- *     Completely re-written to use the new irq.c
- *
- * Credits to Bradley D. LaRonde and Michael Klar for writing the original
- * irq.c file which was derived from the common irq.c file.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-#include <linux/types.h>
-#include <linux/init.h>
-#include <linux/kernel_stat.h>
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/interrupt.h>
-#include <linux/slab.h>
-#include <linux/random.h>
-
-#include <asm/irq.h>
-#include <asm/mipsregs.h>
-#include <asm/gdb-stub.h>
-
-#include <asm/vr4181/vr4181.h>
-
-/*
- * Strategy:
- *
- * We essentially have three irq controllers, CPU, system, and gpio.
- *
- * CPU irq controller is taken care by arch/mips/kernel/irq_cpu.c and
- * CONFIG_IRQ_CPU config option.
- *
- * We here provide sys_irq and gpio_irq controller code.
- */
-
-static int sys_irq_base;
-static int gpio_irq_base;
-
-/* ---------------------- sys irq ------------------------ */
-static void
-sys_irq_enable(unsigned int irq)
-{
-       irq -= sys_irq_base;
-       if (irq < 16) {
-               *VR4181_MSYSINT1REG |= (u16)(1 << irq);
-       } else {
-               irq -= 16;
-               *VR4181_MSYSINT2REG |= (u16)(1 << irq);
-       }
-}
-
-static void
-sys_irq_disable(unsigned int irq)
-{
-       irq -= sys_irq_base;
-       if (irq < 16) {
-               *VR4181_MSYSINT1REG &= ~((u16)(1 << irq));
-       } else {
-               irq -= 16;
-               *VR4181_MSYSINT2REG &= ~((u16)(1 << irq));
-       }
-
-}
-
-static unsigned int
-sys_irq_startup(unsigned int irq)
-{
-       sys_irq_enable(irq);
-       return 0;
-}
-
-#define sys_irq_shutdown       sys_irq_disable
-#define sys_irq_ack            sys_irq_disable
-
-static void
-sys_irq_end(unsigned int irq)
-{
-       if(!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
-               sys_irq_enable(irq);
-}
-
-static hw_irq_controller sys_irq_controller = {
-       "vr4181_sys_irq",
-       sys_irq_startup,
-       sys_irq_shutdown,
-       sys_irq_enable,
-       sys_irq_disable,
-       sys_irq_ack,
-       sys_irq_end,
-       NULL                    /* no affinity stuff for UP */
-};
-
-/* ---------------------- gpio irq ------------------------ */
-/* gpio irq lines use reverse logic */
-static void
-gpio_irq_enable(unsigned int irq)
-{
-       irq -= gpio_irq_base;
-       *VR4181_GPINTMSK &= ~((u16)(1 << irq));
-}
-
-static void
-gpio_irq_disable(unsigned int irq)
-{
-       irq -= gpio_irq_base;
-       *VR4181_GPINTMSK |= (u16)(1 << irq);
-}
-
-static unsigned int
-gpio_irq_startup(unsigned int irq)
-{
-       gpio_irq_enable(irq);
-
-       irq -= gpio_irq_base;
-       *VR4181_GPINTEN |= (u16)(1 << irq );
-
-       return 0;
-}
-
-static void
-gpio_irq_shutdown(unsigned int irq)
-{
-       gpio_irq_disable(irq);
-
-       irq -= gpio_irq_base;
-       *VR4181_GPINTEN &= ~((u16)(1 << irq ));
-}
-
-static void
-gpio_irq_ack(unsigned int irq)
-{
-       u16 irqtype;
-       u16 irqshift;
-
-       gpio_irq_disable(irq);
-
-       /* we clear interrupt if it is edge triggered */
-       irq -= gpio_irq_base;
-       if (irq < 8) {
-               irqtype = *VR4181_GPINTTYPL;
-               irqshift = 2 << (irq*2);
-       } else {
-               irqtype = *VR4181_GPINTTYPH;
-               irqshift = 2 << ((irq-8)*2);
-       }
-       if ( ! (irqtype & irqshift) ) {
-               *VR4181_GPINTSTAT = (u16) (1 << irq);
-       }
-}
-
-static void
-gpio_irq_end(unsigned int irq)
-{
-       if(!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
-               gpio_irq_enable(irq);
-}
-
-static hw_irq_controller gpio_irq_controller = {
-       "vr4181_gpio_irq",
-       gpio_irq_startup,
-       gpio_irq_shutdown,
-       gpio_irq_enable,
-       gpio_irq_disable,
-       gpio_irq_ack,
-       gpio_irq_end,
-       NULL                    /* no affinity stuff for UP */
-};
-
-/* ---------------------  IRQ init stuff ---------------------- */
-
-extern asmlinkage void vr4181_handle_irq(void);
-extern void breakpoint(void);
-extern int setup_irq(unsigned int irq, struct irqaction *irqaction);
-extern void mips_cpu_irq_init(u32 irq_base);
-
-static struct irqaction cascade =
-       { no_action, SA_INTERRUPT, CPU_MASK_NONE, "cascade", NULL, NULL };
-static struct irqaction reserved =
-       { no_action, SA_INTERRUPT, CPU_MASK_NONE, "cascade", NULL, NULL };
-
-void __init arch_init_irq(void)
-{
-       int i;
-
-       set_except_vector(0, vr4181_handle_irq);
-
-       /* init CPU irqs */
-       mips_cpu_irq_init(VR4181_CPU_IRQ_BASE);
-
-       /* init sys irqs */
-       sys_irq_base = VR4181_SYS_IRQ_BASE;
-       for (i=sys_irq_base; i < sys_irq_base + VR4181_NUM_SYS_IRQ; i++) {
-               irq_desc[i].status = IRQ_DISABLED;
-               irq_desc[i].action = NULL;
-               irq_desc[i].depth = 1;
-               irq_desc[i].handler = &sys_irq_controller;
-       }
-
-       /* init gpio irqs */
-       gpio_irq_base = VR4181_GPIO_IRQ_BASE;
-       for (i=gpio_irq_base; i < gpio_irq_base + VR4181_NUM_GPIO_IRQ; i++) {
-               irq_desc[i].status = IRQ_DISABLED;
-               irq_desc[i].action = NULL;
-               irq_desc[i].depth = 1;
-               irq_desc[i].handler = &gpio_irq_controller;
-       }
-
-       /* Default all ICU IRQs to off ... */
-       *VR4181_MSYSINT1REG = 0;
-       *VR4181_MSYSINT2REG = 0;
-
-       /* We initialize the level 2 ICU registers to all bits disabled. */
-       *VR4181_MPIUINTREG = 0;
-       *VR4181_MAIUINTREG = 0;
-       *VR4181_MKIUINTREG = 0;
-
-       /* disable all GPIO intrs */
-       *VR4181_GPINTMSK = 0xffff;
-
-       /* vector handler.  What these do is register the IRQ as non-sharable */
-       setup_irq(VR4181_IRQ_INT0, &cascade);
-       setup_irq(VR4181_IRQ_GIU, &cascade);
-
-       /*
-        * RTC interrupts are interesting.  They have two destinations.
-        * One is at sys irq controller, and the other is at CPU IP3 and IP4.
-        * RTC timer is used as system timer.
-        * We enable them here, but timer routine will register later
-        * with CPU IP3/IP4.
-        */
-       setup_irq(VR4181_IRQ_RTCL1, &reserved);
-       setup_irq(VR4181_IRQ_RTCL2, &reserved);
-}
diff --git a/arch/mips/vr4181/common/serial.c b/arch/mips/vr4181/common/serial.c
deleted file mode 100644 (file)
index 3f62c62..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2001 MontaVista Software Inc.
- * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
- *
- * arch/mips/vr4181/common/serial.c
- *     initialize serial port on vr4181.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under  the terms of the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- */
-
-/*
- * [jsun, 010925]
- * You need to make sure rs_table has at least one element in
- * drivers/char/serial.c file. There is no good way to do it right
- * now.         A workaround is to include CONFIG_SERIAL_MANY_PORTS in your
- * configure file, which would gives you 64 ports and wastes 11K ram.
- */
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/serial.h>
-
-#include <asm/vr4181/vr4181.h>
-
-void __init vr4181_init_serial(void)
-{
-       struct serial_struct s;
-
-       /* turn on UART clock */
-       *VR4181_CMUCLKMSK |= VR4181_CMUCLKMSK_MSKSIU;
-
-       /* clear memory */
-       memset(&s, 0, sizeof(s));
-
-       s.line = 0;                     /* we set the first one */
-       s.baud_base = 1152000;
-       s.irq = VR4181_IRQ_SIU;
-       s.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST; /* STD_COM_FLAGS */
-       s.iomem_base = (u8*)VR4181_SIURB;
-       s.iomem_reg_shift = 0;
-       s.io_type = SERIAL_IO_MEM;
-       if (early_serial_setup(&s) != 0) {
-               panic("vr4181_init_serial() failed!");
-       }
-}
-
diff --git a/arch/mips/vr4181/common/time.c b/arch/mips/vr4181/common/time.c
deleted file mode 100644 (file)
index 1781407..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright 2001 MontaVista Software Inc.
- * Author: jsun@mvista.com or jsun@junsun.net
- *
- * rtc and time ops for vr4181.         Part of code is drived from
- * linux-vr, originally written         by Bradley D. LaRonde & Michael Klar.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under  the terms of the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/spinlock.h>
-#include <linux/param.h>                       /* for HZ */
-#include <linux/time.h>
-#include <linux/interrupt.h>
-
-#include <asm/system.h>
-#include <asm/time.h>
-
-#include <asm/vr4181/vr4181.h>
-
-#define COUNTS_PER_JIFFY ((32768 + HZ/2) / HZ)
-
-/*
- * RTC ops
- */
-
-DEFINE_SPINLOCK(rtc_lock);
-
-/* per VR41xx docs, bad data can be read if between 2 counts */
-static inline unsigned short
-read_time_reg(volatile unsigned short *reg)
-{
-       unsigned short value;
-       do {
-               value = *reg;
-               barrier();
-       } while (value != *reg);
-       return value;
-}
-
-static unsigned long
-vr4181_rtc_get_time(void)
-{
-       unsigned short regh, regm, regl;
-
-       // why this crazy order, you ask?  to guarantee that neither m
-       // nor l wrap before all 3 read
-       do {
-               regm = read_time_reg(VR4181_ETIMEMREG);
-               barrier();
-               regh = read_time_reg(VR4181_ETIMEHREG);
-               barrier();
-               regl = read_time_reg(VR4181_ETIMELREG);
-       } while (regm != read_time_reg(VR4181_ETIMEMREG));
-       return ((regh << 17) | (regm << 1) | (regl >> 15));
-}
-
-static int
-vr4181_rtc_set_time(unsigned long timeval)
-{
-       unsigned short intreg;
-       unsigned long flags;
-
-       spin_lock_irqsave(&rtc_lock, flags);
-       intreg = *VR4181_RTCINTREG & 0x05;
-       barrier();
-       *VR4181_ETIMELREG = timeval << 15;
-       *VR4181_ETIMEMREG = timeval >> 1;
-       *VR4181_ETIMEHREG = timeval >> 17;
-       barrier();
-       // assume that any ints that just triggered are invalid, since the
-       // time value is written non-atomically in 3 separate regs
-       *VR4181_RTCINTREG = 0x05 ^ intreg;
-       spin_unlock_irqrestore(&rtc_lock, flags);
-
-       return 0;
-}
-
-
-/*
- * timer interrupt routine (wrapper)
- *
- * we need our own interrupt routine because we need to clear
- * RTC1 interrupt.
- */
-static void
-vr4181_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       /* Clear the interrupt. */
-       *VR4181_RTCINTREG = 0x2;
-
-       /* call the generic one */
-       timer_interrupt(irq, dev_id, regs);
-}
-
-
-/*
- * vr4181_time_init:
- *
- * We pick the following choices:
- *   . we use elapsed timer as the RTC.         We set some reasonable init data since
- *     it does not persist across reset
- *   . we use RTC1 as the system timer interrupt source.
- *   . we use CPU counter for fast_gettimeoffset and we calivrate the cpu
- *     frequency.  In other words, we use calibrate_div64_gettimeoffset().
- *   . we use our own timer interrupt routine which clears the interrupt
- *     and then calls the generic high-level timer interrupt routine.
- *
- */
-
-extern int setup_irq(unsigned int irq, struct irqaction *irqaction);
-
-static void
-vr4181_timer_setup(struct irqaction *irq)
-{
-       /* over-write the handler to be our own one */
-       irq->handler = vr4181_timer_interrupt;
-
-       /* sets up the frequency */
-       *VR4181_RTCL1LREG = COUNTS_PER_JIFFY;
-       *VR4181_RTCL1HREG = 0;
-
-       /* and ack any pending ints */
-       *VR4181_RTCINTREG = 0x2;
-
-       /* setup irqaction */
-       setup_irq(VR4181_IRQ_INT1, irq);
-
-}
-
-void
-vr4181_init_time(void)
-{
-       /* setup hookup functions */
-       rtc_get_time = vr4181_rtc_get_time;
-       rtc_set_time = vr4181_rtc_set_time;
-
-       board_timer_setup = vr4181_timer_setup;
-}
-
diff --git a/arch/mips/vr4181/osprey/Makefile b/arch/mips/vr4181/osprey/Makefile
deleted file mode 100644 (file)
index 34be057..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#
-# Makefile for common code of NEC Osprey board
-#
-
-obj-y   := setup.o prom.o reset.o
-
-obj-$(CONFIG_KGDB)     += dbg_io.o
diff --git a/arch/mips/vr4181/osprey/dbg_io.c b/arch/mips/vr4181/osprey/dbg_io.c
deleted file mode 100644 (file)
index 5e8a840..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * kgdb io functions for osprey.  We use the serial port on debug board.
- *
- * Copyright (C) 2001 MontaVista Software Inc.
- * Author: jsun@mvista.com or jsun@junsun.net
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- */
-
-/* ======================= CONFIG ======================== */
-
-/* [jsun] we use the second serial port for kdb */
-#define         BASE                    0xb7fffff0
-#define         MAX_BAUD                115200
-
-/* distance in bytes between two serial registers */
-#define         REG_OFFSET              1
-
-/*
- * 0 - kgdb does serial init
- * 1 - kgdb skip serial init
- */
-static int remoteDebugInitialized = 1;
-
-/*
- * the default baud rate *if* kgdb does serial init
- */
-#define                BAUD_DEFAULT            UART16550_BAUD_38400
-
-/* ======================= END OF CONFIG ======================== */
-
-typedef unsigned char uint8;
-typedef unsigned int uint32;
-
-#define         UART16550_BAUD_2400             2400
-#define         UART16550_BAUD_4800             4800
-#define         UART16550_BAUD_9600             9600
-#define         UART16550_BAUD_19200            19200
-#define         UART16550_BAUD_38400            38400
-#define         UART16550_BAUD_57600            57600
-#define         UART16550_BAUD_115200           115200
-
-#define         UART16550_PARITY_NONE           0
-#define         UART16550_PARITY_ODD            0x08
-#define         UART16550_PARITY_EVEN           0x18
-#define         UART16550_PARITY_MARK           0x28
-#define         UART16550_PARITY_SPACE          0x38
-
-#define         UART16550_DATA_5BIT             0x0
-#define         UART16550_DATA_6BIT             0x1
-#define         UART16550_DATA_7BIT             0x2
-#define         UART16550_DATA_8BIT             0x3
-
-#define         UART16550_STOP_1BIT             0x0
-#define         UART16550_STOP_2BIT             0x4
-
-/* register offset */
-#define         OFS_RCV_BUFFER          0
-#define         OFS_TRANS_HOLD          0
-#define         OFS_SEND_BUFFER         0
-#define         OFS_INTR_ENABLE         (1*REG_OFFSET)
-#define         OFS_INTR_ID             (2*REG_OFFSET)
-#define         OFS_DATA_FORMAT         (3*REG_OFFSET)
-#define         OFS_LINE_CONTROL        (3*REG_OFFSET)
-#define         OFS_MODEM_CONTROL       (4*REG_OFFSET)
-#define         OFS_RS232_OUTPUT        (4*REG_OFFSET)
-#define         OFS_LINE_STATUS         (5*REG_OFFSET)
-#define         OFS_MODEM_STATUS        (6*REG_OFFSET)
-#define         OFS_RS232_INPUT         (6*REG_OFFSET)
-#define         OFS_SCRATCH_PAD         (7*REG_OFFSET)
-
-#define         OFS_DIVISOR_LSB         (0*REG_OFFSET)
-#define         OFS_DIVISOR_MSB         (1*REG_OFFSET)
-
-
-/* memory-mapped read/write of the port */
-#define         UART16550_READ(y)    (*((volatile uint8*)(BASE + y)))
-#define         UART16550_WRITE(y, z)  ((*((volatile uint8*)(BASE + y))) = z)
-
-void debugInit(uint32 baud, uint8 data, uint8 parity, uint8 stop)
-{
-        /* disable interrupts */
-        UART16550_WRITE(OFS_INTR_ENABLE, 0);
-
-        /* set up buad rate */
-        {
-                uint32 divisor;
-
-                /* set DIAB bit */
-                UART16550_WRITE(OFS_LINE_CONTROL, 0x80);
-
-                /* set divisor */
-                divisor = MAX_BAUD / baud;
-                UART16550_WRITE(OFS_DIVISOR_LSB, divisor & 0xff);
-                UART16550_WRITE(OFS_DIVISOR_MSB, (divisor & 0xff00) >> 8);
-
-                /* clear DIAB bit */
-                UART16550_WRITE(OFS_LINE_CONTROL, 0x0);
-        }
-
-        /* set data format */
-        UART16550_WRITE(OFS_DATA_FORMAT, data | parity | stop);
-}
-
-
-uint8 getDebugChar(void)
-{
-        if (!remoteDebugInitialized) {
-                remoteDebugInitialized = 1;
-                debugInit(BAUD_DEFAULT,
-                          UART16550_DATA_8BIT,
-                          UART16550_PARITY_NONE, UART16550_STOP_1BIT);
-        }
-
-        while ((UART16550_READ(OFS_LINE_STATUS) & 0x1) == 0);
-        return UART16550_READ(OFS_RCV_BUFFER);
-}
-
-
-int putDebugChar(uint8 byte)
-{
-        if (!remoteDebugInitialized) {
-                remoteDebugInitialized = 1;
-                debugInit(BAUD_DEFAULT,
-                          UART16550_DATA_8BIT,
-                          UART16550_PARITY_NONE, UART16550_STOP_1BIT);
-        }
-
-        while ((UART16550_READ(OFS_LINE_STATUS) & 0x20) == 0);
-        UART16550_WRITE(OFS_SEND_BUFFER, byte);
-        return 1;
-}
diff --git a/arch/mips/vr4181/osprey/prom.c b/arch/mips/vr4181/osprey/prom.c
deleted file mode 100644 (file)
index af0d145..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2001 MontaVista Software Inc.
- * Author: jsun@mvista.com or jsun@junsun.net
- *
- * arch/mips/vr4181/osprey/prom.c
- *     prom code for osprey.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under  the terms of the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- */
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/mm.h>
-#include <linux/bootmem.h>
-#include <asm/bootinfo.h>
-#include <asm/addrspace.h>
-
-const char *get_system_type(void)
-{
-       return "NEC_Vr41xx Osprey";
-}
-
-/*
- * [jsun] right now we assume it is the nec debug monitor, which does
- * not pass any arguments.
- */
-void __init prom_init(void)
-{
-       // cmdline is now set in default config
-       // strcpy(arcs_cmdline, "ip=bootp ");
-       // strcat(arcs_cmdline, "ether=46,0x03fe0300,eth0 ");
-       // strcpy(arcs_cmdline, "ether=0,0x0300,eth0 "
-       // strcat(arcs_cmdline, "video=vr4181fb:xres:240,yres:320,bpp:8 ");
-
-       mips_machgroup = MACH_GROUP_NEC_VR41XX;
-       mips_machtype = MACH_NEC_OSPREY;
-
-       /* 16MB fixed */
-       add_memory_region(0, 16 << 20, BOOT_MEM_RAM);
-}
-
-unsigned long __init prom_free_prom_memory(void)
-{
-       return 0;
-}
diff --git a/arch/mips/vr4181/osprey/reset.c b/arch/mips/vr4181/osprey/reset.c
deleted file mode 100644 (file)
index 036ae83..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify it
- * under  the terms of the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- * Copyright (C) 1997, 2001 Ralf Baechle
- * Copyright 2001 MontaVista Software Inc.
- * Author: jsun@mvista.com or jsun@junsun.net
- */
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <asm/io.h>
-#include <asm/cacheflush.h>
-#include <asm/processor.h>
-#include <asm/reboot.h>
-#include <asm/system.h>
-
-void nec_osprey_restart(char *command)
-{
-       set_c0_status(ST0_ERL);
-       change_c0_config(CONF_CM_CMASK, CONF_CM_UNCACHED);
-       flush_cache_all();
-       write_c0_wired(0);
-       __asm__ __volatile__("jr\t%0"::"r"(0xbfc00000));
-}
-
-void nec_osprey_halt(void)
-{
-       printk(KERN_NOTICE "\n** You can safely turn off the power\n");
-       while (1)
-               __asm__(".set\tmips3\n\t"
-                       "wait\n\t"
-                       ".set\tmips0");
-}
-
-void nec_osprey_power_off(void)
-{
-       nec_osprey_halt();
-}
diff --git a/arch/mips/vr4181/osprey/setup.c b/arch/mips/vr4181/osprey/setup.c
deleted file mode 100644 (file)
index 2ff7140..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * linux/arch/mips/vr4181/setup.c
- *
- * VR41xx setup routines
- *
- * Copyright (C) 1999 Bradley D. LaRonde
- * Copyright (C) 1999, 2000 Michael Klar
- *
- * Copyright 2001 MontaVista Software Inc.
- * Author: jsun@mvista.com or jsun@junsun.net
- * Copyright (C) 2005 Ralf Baechle (ralf@linux-mips.org)
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- */
-
-#include <linux/ide.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <asm/reboot.h>
-#include <asm/vr4181/vr4181.h>
-#include <asm/io.h>
-
-
-extern void nec_osprey_restart(char* c);
-extern void nec_osprey_halt(void);
-extern void nec_osprey_power_off(void);
-
-extern void vr4181_init_serial(void);
-extern void vr4181_init_time(void);
-
-static void __init nec_osprey_setup(void)
-{
-       set_io_port_base(VR4181_PORT_BASE);
-       isa_slot_offset = VR4181_ISAMEM_BASE;
-
-       vr4181_init_serial();
-       vr4181_init_time();
-
-       _machine_restart = nec_osprey_restart;
-       _machine_halt = nec_osprey_halt;
-       _machine_power_off = nec_osprey_power_off;
-
-       /* setup resource limit */
-       ioport_resource.end = 0xffffffff;
-       iomem_resource.end = 0xffffffff;
-
-       /* [jsun] hack */
-       /*
-       printk("[jsun] hack to change external ISA control register, %x -> %x\n",
-               (*VR4181_XISACTL),
-               (*VR4181_XISACTL) | 0x2);
-       *VR4181_XISACTL |= 0x2;
-       */
-
-       // *VR4181_GPHIBSTH = 0x2000;
-       // *VR4181_GPMD0REG = 0x00c0;
-       // *VR4181_GPINTEN       = 1<<6;
-
-       /* [jsun] I believe this will get the interrupt type right
-        * for the ether port.
-        */
-       *VR4181_GPINTTYPL = 0x3000;
-}
-
-early_initcall(nec_osprey_setup);
index aa8605ab76ff251244c79ed0e5268635ba4993c6..d29201acc4f31cc72087f1013a2cf9198217c82e 100644 (file)
 #include <asm/io.h>
 #include <asm/vr41xx/e55.h>
 
-const char *get_system_type(void)
-{
-       return "CASIO CASSIOPEIA E-11/15/55/65";
-}
-
 static int __init casio_e55_setup(void)
 {
        set_io_port_base(IO_PORT_BASE);
index fa98ef3855bc73c663df5d752e2abb84be722366..9096302a7ecc1e79fed3a3a73f71d67241c07fce 100644 (file)
@@ -2,7 +2,7 @@
 # Makefile for common code of the NEC VR4100 series.
 #
 
-obj-y                          += bcu.o cmu.o icu.o init.o int-handler.o pmu.o
+obj-y                          += bcu.o cmu.o icu.o init.o int-handler.o irq.o pmu.o type.o
 obj-$(CONFIG_VRC4173)          += vrc4173.o
 
 EXTRA_AFLAGS := $(CFLAGS)
index c842661144cb9d6edb5ac1dae41f7bb62efd3e5f..0b73c5ab3c0c1ff968803097e3090bbd1c0a3de3 100644 (file)
@@ -3,8 +3,7 @@
  *
  *  Copyright (C) 2001-2002  MontaVista Software Inc.
  *    Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com>
- *  Copyright (C) 2003-2004  Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
- *  Copyright (C) 2005 Ralf Baechle (ralf@linux-mips.org)
+ *  Copyright (C) 2003-2005  Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -31,7 +30,7 @@
  */
 #include <linux/errno.h>
 #include <linux/init.h>
-#include <linux/interrupt.h>
+#include <linux/ioport.h>
 #include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/smp.h>
 
 #include <asm/cpu.h>
 #include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/irq_cpu.h>
 #include <asm/vr41xx/vr41xx.h>
 
-extern asmlinkage void vr41xx_handle_interrupt(void);
-
-extern void init_vr41xx_giuint_irq(void);
-extern void giuint_irq_dispatch(struct pt_regs *regs);
-
-static uint32_t icu1_base;
-static uint32_t icu2_base;
-
-static struct irqaction icu_cascade = {
-       .handler        = no_action,
-       .mask           = CPU_MASK_NONE,
-       .name           = "cascade",
-};
+static void __iomem *icu1_base;
+static void __iomem *icu2_base;
 
 static unsigned char sysint1_assign[16] = {
        0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 static unsigned char sysint2_assign[16] = {
-       2, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+       2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 
-#define SYSINT1REG_TYPE1       KSEG1ADDR(0x0b000080)
-#define SYSINT2REG_TYPE1       KSEG1ADDR(0x0b000200)
+#define ICU1_TYPE1_BASE        0x0b000080UL
+#define ICU2_TYPE1_BASE        0x0b000200UL
 
-#define SYSINT1REG_TYPE2       KSEG1ADDR(0x0f000080)
-#define SYSINT2REG_TYPE2       KSEG1ADDR(0x0f0000a0)
+#define ICU1_TYPE2_BASE        0x0f000080UL
+#define ICU2_TYPE2_BASE        0x0f0000a0UL
+
+#define ICU1_SIZE      0x20
+#define ICU2_SIZE      0x1c
 
 #define SYSINT1REG     0x00
 #define PIUINTREG      0x02
@@ -106,61 +95,61 @@ static unsigned char sysint2_assign[16] = {
 #define SYSINT1_IRQ_TO_PIN(x)  ((x) - SYSINT1_IRQ_BASE)        /* Pin 0-15 */
 #define SYSINT2_IRQ_TO_PIN(x)  ((x) - SYSINT2_IRQ_BASE)        /* Pin 0-15 */
 
-#define read_icu1(offset)      readw(icu1_base + (offset))
-#define write_icu1(val, offset)        writew((val), icu1_base + (offset))
+#define INT_TO_IRQ(x)          ((x) + 2)       /* Int0-4 -> IRQ2-6 */
+
+#define icu1_read(offset)              readw(icu1_base + (offset))
+#define icu1_write(offset, value)      writew((value), icu1_base + (offset))
 
-#define read_icu2(offset)      readw(icu2_base + (offset))
-#define write_icu2(val, offset)        writew((val), icu2_base + (offset))
+#define icu2_read(offset)              readw(icu2_base + (offset))
+#define icu2_write(offset, value)      writew((value), icu2_base + (offset))
 
 #define INTASSIGN_MAX  4
 #define INTASSIGN_MASK 0x0007
 
-static inline uint16_t set_icu1(uint8_t offset, uint16_t set)
+static inline uint16_t icu1_set(uint8_t offset, uint16_t set)
 {
-       uint16_t res;
+       uint16_t data;
 
-       res = read_icu1(offset);
-       res |= set;
-       write_icu1(res, offset);
+       data = icu1_read(offset);
+       data |= set;
+       icu1_write(offset, data);
 
-       return res;
+       return data;
 }
 
-static inline uint16_t clear_icu1(uint8_t offset, uint16_t clear)
+static inline uint16_t icu1_clear(uint8_t offset, uint16_t clear)
 {
-       uint16_t res;
+       uint16_t data;
 
-       res = read_icu1(offset);
-       res &= ~clear;
-       write_icu1(res, offset);
+       data = icu1_read(offset);
+       data &= ~clear;
+       icu1_write(offset, data);
 
-       return res;
+       return data;
 }
 
-static inline uint16_t set_icu2(uint8_t offset, uint16_t set)
+static inline uint16_t icu2_set(uint8_t offset, uint16_t set)
 {
-       uint16_t res;
+       uint16_t data;
 
-       res = read_icu2(offset);
-       res |= set;
-       write_icu2(res, offset);
+       data = icu2_read(offset);
+       data |= set;
+       icu2_write(offset, data);
 
-       return res;
+       return data;
 }
 
-static inline uint16_t clear_icu2(uint8_t offset, uint16_t clear)
+static inline uint16_t icu2_clear(uint8_t offset, uint16_t clear)
 {
-       uint16_t res;
+       uint16_t data;
 
-       res = read_icu2(offset);
-       res &= ~clear;
-       write_icu2(res, offset);
+       data = icu2_read(offset);
+       data &= ~clear;
+       icu2_write(offset, data);
 
-       return res;
+       return data;
 }
 
-/*=======================================================================*/
-
 void vr41xx_enable_piuint(uint16_t mask)
 {
        irq_desc_t *desc = irq_desc + PIU_IRQ;
@@ -169,7 +158,7 @@ void vr41xx_enable_piuint(uint16_t mask)
        if (current_cpu_data.cputype == CPU_VR4111 ||
            current_cpu_data.cputype == CPU_VR4121) {
                spin_lock_irqsave(&desc->lock, flags);
-               set_icu1(MPIUINTREG, mask);
+               icu1_set(MPIUINTREG, mask);
                spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
@@ -184,7 +173,7 @@ void vr41xx_disable_piuint(uint16_t mask)
        if (current_cpu_data.cputype == CPU_VR4111 ||
            current_cpu_data.cputype == CPU_VR4121) {
                spin_lock_irqsave(&desc->lock, flags);
-               clear_icu1(MPIUINTREG, mask);
+               icu1_clear(MPIUINTREG, mask);
                spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
@@ -199,7 +188,7 @@ void vr41xx_enable_aiuint(uint16_t mask)
        if (current_cpu_data.cputype == CPU_VR4111 ||
            current_cpu_data.cputype == CPU_VR4121) {
                spin_lock_irqsave(&desc->lock, flags);
-               set_icu1(MAIUINTREG, mask);
+               icu1_set(MAIUINTREG, mask);
                spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
@@ -214,7 +203,7 @@ void vr41xx_disable_aiuint(uint16_t mask)
        if (current_cpu_data.cputype == CPU_VR4111 ||
            current_cpu_data.cputype == CPU_VR4121) {
                spin_lock_irqsave(&desc->lock, flags);
-               clear_icu1(MAIUINTREG, mask);
+               icu1_clear(MAIUINTREG, mask);
                spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
@@ -229,7 +218,7 @@ void vr41xx_enable_kiuint(uint16_t mask)
        if (current_cpu_data.cputype == CPU_VR4111 ||
            current_cpu_data.cputype == CPU_VR4121) {
                spin_lock_irqsave(&desc->lock, flags);
-               set_icu1(MKIUINTREG, mask);
+               icu1_set(MKIUINTREG, mask);
                spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
@@ -244,7 +233,7 @@ void vr41xx_disable_kiuint(uint16_t mask)
        if (current_cpu_data.cputype == CPU_VR4111 ||
            current_cpu_data.cputype == CPU_VR4121) {
                spin_lock_irqsave(&desc->lock, flags);
-               clear_icu1(MKIUINTREG, mask);
+               icu1_clear(MKIUINTREG, mask);
                spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
@@ -257,7 +246,7 @@ void vr41xx_enable_dsiuint(uint16_t mask)
        unsigned long flags;
 
        spin_lock_irqsave(&desc->lock, flags);
-       set_icu1(MDSIUINTREG, mask);
+       icu1_set(MDSIUINTREG, mask);
        spin_unlock_irqrestore(&desc->lock, flags);
 }
 
@@ -269,7 +258,7 @@ void vr41xx_disable_dsiuint(uint16_t mask)
        unsigned long flags;
 
        spin_lock_irqsave(&desc->lock, flags);
-       clear_icu1(MDSIUINTREG, mask);
+       icu1_clear(MDSIUINTREG, mask);
        spin_unlock_irqrestore(&desc->lock, flags);
 }
 
@@ -281,7 +270,7 @@ void vr41xx_enable_firint(uint16_t mask)
        unsigned long flags;
 
        spin_lock_irqsave(&desc->lock, flags);
-       set_icu2(MFIRINTREG, mask);
+       icu2_set(MFIRINTREG, mask);
        spin_unlock_irqrestore(&desc->lock, flags);
 }
 
@@ -293,7 +282,7 @@ void vr41xx_disable_firint(uint16_t mask)
        unsigned long flags;
 
        spin_lock_irqsave(&desc->lock, flags);
-       clear_icu2(MFIRINTREG, mask);
+       icu2_clear(MFIRINTREG, mask);
        spin_unlock_irqrestore(&desc->lock, flags);
 }
 
@@ -308,7 +297,7 @@ void vr41xx_enable_pciint(void)
            current_cpu_data.cputype == CPU_VR4131 ||
            current_cpu_data.cputype == CPU_VR4133) {
                spin_lock_irqsave(&desc->lock, flags);
-               write_icu2(PCIINT0, MPCIINTREG);
+               icu2_write(MPCIINTREG, PCIINT0);
                spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
@@ -324,7 +313,7 @@ void vr41xx_disable_pciint(void)
            current_cpu_data.cputype == CPU_VR4131 ||
            current_cpu_data.cputype == CPU_VR4133) {
                spin_lock_irqsave(&desc->lock, flags);
-               write_icu2(0, MPCIINTREG);
+               icu2_write(MPCIINTREG, 0);
                spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
@@ -340,7 +329,7 @@ void vr41xx_enable_scuint(void)
            current_cpu_data.cputype == CPU_VR4131 ||
            current_cpu_data.cputype == CPU_VR4133) {
                spin_lock_irqsave(&desc->lock, flags);
-               write_icu2(SCUINT0, MSCUINTREG);
+               icu2_write(MSCUINTREG, SCUINT0);
                spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
@@ -356,7 +345,7 @@ void vr41xx_disable_scuint(void)
            current_cpu_data.cputype == CPU_VR4131 ||
            current_cpu_data.cputype == CPU_VR4133) {
                spin_lock_irqsave(&desc->lock, flags);
-               write_icu2(0, MSCUINTREG);
+               icu2_write(MSCUINTREG, 0);
                spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
@@ -372,7 +361,7 @@ void vr41xx_enable_csiint(uint16_t mask)
            current_cpu_data.cputype == CPU_VR4131 ||
            current_cpu_data.cputype == CPU_VR4133) {
                spin_lock_irqsave(&desc->lock, flags);
-               set_icu2(MCSIINTREG, mask);
+               icu2_set(MCSIINTREG, mask);
                spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
@@ -388,7 +377,7 @@ void vr41xx_disable_csiint(uint16_t mask)
            current_cpu_data.cputype == CPU_VR4131 ||
            current_cpu_data.cputype == CPU_VR4133) {
                spin_lock_irqsave(&desc->lock, flags);
-               clear_icu2(MCSIINTREG, mask);
+               icu2_clear(MCSIINTREG, mask);
                spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
@@ -404,7 +393,7 @@ void vr41xx_enable_bcuint(void)
            current_cpu_data.cputype == CPU_VR4131 ||
            current_cpu_data.cputype == CPU_VR4133) {
                spin_lock_irqsave(&desc->lock, flags);
-               write_icu2(BCUINTR, MBCUINTREG);
+               icu2_write(MBCUINTREG, BCUINTR);
                spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
@@ -420,30 +409,28 @@ void vr41xx_disable_bcuint(void)
            current_cpu_data.cputype == CPU_VR4131 ||
            current_cpu_data.cputype == CPU_VR4133) {
                spin_lock_irqsave(&desc->lock, flags);
-               write_icu2(0, MBCUINTREG);
+               icu2_write(MBCUINTREG, 0);
                spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
 
 EXPORT_SYMBOL(vr41xx_disable_bcuint);
 
-/*=======================================================================*/
-
 static unsigned int startup_sysint1_irq(unsigned int irq)
 {
-       set_icu1(MSYSINT1REG, (uint16_t)1 << SYSINT1_IRQ_TO_PIN(irq));
+       icu1_set(MSYSINT1REG, 1 << SYSINT1_IRQ_TO_PIN(irq));
 
        return 0; /* never anything pending */
 }
 
 static void shutdown_sysint1_irq(unsigned int irq)
 {
-       clear_icu1(MSYSINT1REG, (uint16_t)1 << SYSINT1_IRQ_TO_PIN(irq));
+       icu1_clear(MSYSINT1REG, 1 << SYSINT1_IRQ_TO_PIN(irq));
 }
 
 static void enable_sysint1_irq(unsigned int irq)
 {
-       set_icu1(MSYSINT1REG, (uint16_t)1 << SYSINT1_IRQ_TO_PIN(irq));
+       icu1_set(MSYSINT1REG, 1 << SYSINT1_IRQ_TO_PIN(irq));
 }
 
 #define disable_sysint1_irq    shutdown_sysint1_irq
@@ -452,7 +439,7 @@ static void enable_sysint1_irq(unsigned int irq)
 static void end_sysint1_irq(unsigned int irq)
 {
        if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
-               set_icu1(MSYSINT1REG, (uint16_t)1 << SYSINT1_IRQ_TO_PIN(irq));
+               icu1_set(MSYSINT1REG, 1 << SYSINT1_IRQ_TO_PIN(irq));
 }
 
 static struct hw_interrupt_type sysint1_irq_type = {
@@ -465,23 +452,21 @@ static struct hw_interrupt_type sysint1_irq_type = {
        .end            = end_sysint1_irq,
 };
 
-/*=======================================================================*/
-
 static unsigned int startup_sysint2_irq(unsigned int irq)
 {
-       set_icu2(MSYSINT2REG, (uint16_t)1 << SYSINT2_IRQ_TO_PIN(irq));
+       icu2_set(MSYSINT2REG, 1 << SYSINT2_IRQ_TO_PIN(irq));
 
        return 0; /* never anything pending */
 }
 
 static void shutdown_sysint2_irq(unsigned int irq)
 {
-       clear_icu2(MSYSINT2REG, (uint16_t)1 << SYSINT2_IRQ_TO_PIN(irq));
+       icu2_clear(MSYSINT2REG, 1 << SYSINT2_IRQ_TO_PIN(irq));
 }
 
 static void enable_sysint2_irq(unsigned int irq)
 {
-       set_icu2(MSYSINT2REG, (uint16_t)1 << SYSINT2_IRQ_TO_PIN(irq));
+       icu2_set(MSYSINT2REG, 1 << SYSINT2_IRQ_TO_PIN(irq));
 }
 
 #define disable_sysint2_irq    shutdown_sysint2_irq
@@ -490,7 +475,7 @@ static void enable_sysint2_irq(unsigned int irq)
 static void end_sysint2_irq(unsigned int irq)
 {
        if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
-               set_icu2(MSYSINT2REG, (uint16_t)1 << SYSINT2_IRQ_TO_PIN(irq));
+               icu2_set(MSYSINT2REG, 1 << SYSINT2_IRQ_TO_PIN(irq));
 }
 
 static struct hw_interrupt_type sysint2_irq_type = {
@@ -503,8 +488,6 @@ static struct hw_interrupt_type sysint2_irq_type = {
        .end            = end_sysint2_irq,
 };
 
-/*=======================================================================*/
-
 static inline int set_sysint1_assign(unsigned int irq, unsigned char assign)
 {
        irq_desc_t *desc = irq_desc + irq;
@@ -515,8 +498,8 @@ static inline int set_sysint1_assign(unsigned int irq, unsigned char assign)
 
        spin_lock_irq(&desc->lock);
 
-       intassign0 = read_icu1(INTASSIGN0);
-       intassign1 = read_icu1(INTASSIGN1);
+       intassign0 = icu1_read(INTASSIGN0);
+       intassign1 = icu1_read(INTASSIGN1);
 
        switch (pin) {
        case 0:
@@ -556,8 +539,8 @@ static inline int set_sysint1_assign(unsigned int irq, unsigned char assign)
        }
 
        sysint1_assign[pin] = assign;
-       write_icu1(intassign0, INTASSIGN0);
-       write_icu1(intassign1, INTASSIGN1);
+       icu1_write(INTASSIGN0, intassign0);
+       icu1_write(INTASSIGN1, intassign1);
 
        spin_unlock_irq(&desc->lock);
 
@@ -574,8 +557,8 @@ static inline int set_sysint2_assign(unsigned int irq, unsigned char assign)
 
        spin_lock_irq(&desc->lock);
 
-       intassign2 = read_icu1(INTASSIGN2);
-       intassign3 = read_icu1(INTASSIGN3);
+       intassign2 = icu1_read(INTASSIGN2);
+       intassign3 = icu1_read(INTASSIGN3);
 
        switch (pin) {
        case 0:
@@ -623,8 +606,8 @@ static inline int set_sysint2_assign(unsigned int irq, unsigned char assign)
        }
 
        sysint2_assign[pin] = assign;
-       write_icu1(intassign2, INTASSIGN2);
-       write_icu1(intassign3, INTASSIGN3);
+       icu1_write(INTASSIGN2, intassign2);
+       icu1_write(INTASSIGN3, intassign3);
 
        spin_unlock_irq(&desc->lock);
 
@@ -651,88 +634,92 @@ int vr41xx_set_intassign(unsigned int irq, unsigned char intassign)
 
 EXPORT_SYMBOL(vr41xx_set_intassign);
 
-/*=======================================================================*/
-
-asmlinkage void irq_dispatch(unsigned char intnum, struct pt_regs *regs)
+static int icu_get_irq(unsigned int irq, struct pt_regs *regs)
 {
        uint16_t pend1, pend2;
        uint16_t mask1, mask2;
        int i;
 
-       pend1 = read_icu1(SYSINT1REG);
-       mask1 = read_icu1(MSYSINT1REG);
+       pend1 = icu1_read(SYSINT1REG);
+       mask1 = icu1_read(MSYSINT1REG);
 
-       pend2 = read_icu2(SYSINT2REG);
-       mask2 = read_icu2(MSYSINT2REG);
+       pend2 = icu2_read(SYSINT2REG);
+       mask2 = icu2_read(MSYSINT2REG);
 
        mask1 &= pend1;
        mask2 &= pend2;
 
        if (mask1) {
                for (i = 0; i < 16; i++) {
-                       if (intnum == sysint1_assign[i] &&
-                           (mask1 & ((uint16_t)1 << i))) {
-                               if (i == 8)
-                                       giuint_irq_dispatch(regs);
-                               else
-                                       do_IRQ(SYSINT1_IRQ(i), regs);
-                               return;
-                       }
+                       if (irq == INT_TO_IRQ(sysint1_assign[i]) && (mask1 & (1 << i)))
+                               return SYSINT1_IRQ(i);
                }
        }
 
        if (mask2) {
                for (i = 0; i < 16; i++) {
-                       if (intnum == sysint2_assign[i] &&
-                           (mask2 & ((uint16_t)1 << i))) {
-                               do_IRQ(SYSINT2_IRQ(i), regs);
-                               return;
-                       }
+                       if (irq == INT_TO_IRQ(sysint2_assign[i]) && (mask2 & (1 << i)))
+                               return SYSINT2_IRQ(i);
                }
        }
 
        printk(KERN_ERR "spurious ICU interrupt: %04x,%04x\n", pend1, pend2);
 
        atomic_inc(&irq_err_count);
-}
 
-/*=======================================================================*/
+       return -1;
+}
 
 static int __init vr41xx_icu_init(void)
 {
+       unsigned long icu1_start, icu2_start;
+       int i;
+
        switch (current_cpu_data.cputype) {
        case CPU_VR4111:
        case CPU_VR4121:
-               icu1_base = SYSINT1REG_TYPE1;
-               icu2_base = SYSINT2REG_TYPE1;
+               icu1_start = ICU1_TYPE1_BASE;
+               icu2_start = ICU2_TYPE1_BASE;
                break;
        case CPU_VR4122:
        case CPU_VR4131:
        case CPU_VR4133:
-               icu1_base = SYSINT1REG_TYPE2;
-               icu2_base = SYSINT2REG_TYPE2;
+               icu1_start = ICU1_TYPE2_BASE;
+               icu2_start = ICU2_TYPE2_BASE;
                break;
        default:
                printk(KERN_ERR "ICU: Unexpected CPU of NEC VR4100 series\n");
-               return -EINVAL;
+               return -ENODEV;
        }
 
-       write_icu1(0, MSYSINT1REG);
-       write_icu1(0xffff, MGIUINTLREG);
+       if (request_mem_region(icu1_start, ICU1_SIZE, "ICU") == NULL)
+               return -EBUSY;
 
-       write_icu2(0, MSYSINT2REG);
-       write_icu2(0xffff, MGIUINTHREG);
+       if (request_mem_region(icu2_start, ICU2_SIZE, "ICU") == NULL) {
+               release_mem_region(icu1_start, ICU1_SIZE);
+               return -EBUSY;
+       }
 
-       return 0;
-}
+       icu1_base = ioremap(icu1_start, ICU1_SIZE);
+       if (icu1_base == NULL) {
+               release_mem_region(icu1_start, ICU1_SIZE);
+               release_mem_region(icu2_start, ICU2_SIZE);
+               return -ENOMEM;
+       }
 
-early_initcall(vr41xx_icu_init);
+       icu2_base = ioremap(icu2_start, ICU2_SIZE);
+       if (icu2_base == NULL) {
+               iounmap(icu1_base);
+               release_mem_region(icu1_start, ICU1_SIZE);
+               release_mem_region(icu2_start, ICU2_SIZE);
+               return -ENOMEM;
+       }
 
-/*=======================================================================*/
+       icu1_write(MSYSINT1REG, 0);
+       icu1_write(MGIUINTLREG, 0xffff);
 
-static inline void init_vr41xx_icu_irq(void)
-{
-       int i;
+       icu2_write(MSYSINT2REG, 0);
+       icu2_write(MGIUINTHREG, 0xffff);
 
        for (i = SYSINT1_IRQ_BASE; i <= SYSINT1_IRQ_LAST; i++)
                irq_desc[i].handler = &sysint1_irq_type;
@@ -740,18 +727,13 @@ static inline void init_vr41xx_icu_irq(void)
        for (i = SYSINT2_IRQ_BASE; i <= SYSINT2_IRQ_LAST; i++)
                irq_desc[i].handler = &sysint2_irq_type;
 
-       setup_irq(INT0_CASCADE_IRQ, &icu_cascade);
-       setup_irq(INT1_CASCADE_IRQ, &icu_cascade);
-       setup_irq(INT2_CASCADE_IRQ, &icu_cascade);
-       setup_irq(INT3_CASCADE_IRQ, &icu_cascade);
-       setup_irq(INT4_CASCADE_IRQ, &icu_cascade);
-}
+       cascade_irq(INT0_IRQ, icu_get_irq);
+       cascade_irq(INT1_IRQ, icu_get_irq);
+       cascade_irq(INT2_IRQ, icu_get_irq);
+       cascade_irq(INT3_IRQ, icu_get_irq);
+       cascade_irq(INT4_IRQ, icu_get_irq);
 
-void __init arch_init_irq(void)
-{
-       mips_cpu_irq_init(MIPS_CPU_IRQ_BASE);
-       init_vr41xx_icu_irq();
-       init_vr41xx_giuint_irq();
-
-       set_except_vector(0, vr41xx_handle_interrupt);
+       return 0;
 }
+
+core_initcall(vr41xx_icu_init);
index 38ff89b505f21a44a96eaafb7dd70028ff43c795..272c13aee4fd1c7e0bffc10e01330b278c7fd330 100644 (file)
 
                andi    t1, t0, CAUSEF_IP3      # check for Int1
                bnez    t1, handle_int
-               li      a0, 1
+               li      a0, 3
 
                andi    t1, t0, CAUSEF_IP4      # check for Int2
                bnez    t1, handle_int
-               li      a0, 2
+               li      a0, 4
 
                andi    t1, t0, CAUSEF_IP5      # check for Int3
                bnez    t1, handle_int
-               li      a0, 3
+               li      a0, 5
 
                andi    t1, t0, CAUSEF_IP6      # check for Int4
                bnez    t1, handle_int
-               li      a0, 4
+               li      a0, 6
 
 1:
                andi    t1, t0, CAUSEF_IP2      # check for Int0
                bnez    t1, handle_int
-               li      a0, 0
+               li      a0, 2
 
                andi    t1, t0, CAUSEF_IP0      # check for IP0
                bnez    t1, handle_irq
diff --git a/arch/mips/vr41xx/common/irq.c b/arch/mips/vr41xx/common/irq.c
new file mode 100644 (file)
index 0000000..43b214d
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ *  Interrupt handing routines for NEC VR4100 series.
+ *
+ *  Copyright (C) 2005  Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include <linux/interrupt.h>
+#include <linux/module.h>
+
+#include <asm/irq_cpu.h>
+#include <asm/system.h>
+#include <asm/vr41xx/vr41xx.h>
+
+typedef struct irq_cascade {
+       int (*get_irq)(unsigned int, struct pt_regs *);
+} irq_cascade_t;
+
+static irq_cascade_t irq_cascade[NR_IRQS] __cacheline_aligned;
+
+static struct irqaction cascade_irqaction = {
+       .handler        = no_action,
+       .mask           = CPU_MASK_NONE,
+       .name           = "cascade",
+};
+
+int cascade_irq(unsigned int irq, int (*get_irq)(unsigned int, struct pt_regs *))
+{
+       int retval = 0;
+
+       if (irq >= NR_IRQS)
+               return -EINVAL;
+
+       if (irq_cascade[irq].get_irq != NULL)
+               free_irq(irq, NULL);
+
+       irq_cascade[irq].get_irq = get_irq;
+
+       if (get_irq != NULL) {
+               retval = setup_irq(irq, &cascade_irqaction);
+               if (retval < 0)
+                       irq_cascade[irq].get_irq = NULL;
+       }
+
+       return retval;
+}
+
+EXPORT_SYMBOL_GPL(cascade_irq);
+
+asmlinkage void irq_dispatch(unsigned int irq, struct pt_regs *regs)
+{
+       irq_cascade_t *cascade;
+       irq_desc_t *desc;
+
+       if (irq >= NR_IRQS) {
+               atomic_inc(&irq_err_count);
+               return;
+       }
+
+       cascade = irq_cascade + irq;
+       if (cascade->get_irq != NULL) {
+               unsigned int source_irq = irq;
+               desc = irq_desc + source_irq;
+               desc->handler->ack(source_irq);
+               irq = cascade->get_irq(irq, regs);
+               if (irq < 0)
+                       atomic_inc(&irq_err_count);
+               else
+                       irq_dispatch(irq, regs);
+               desc->handler->end(source_irq);
+       } else
+               do_IRQ(irq, regs);
+}
+
+extern asmlinkage void vr41xx_handle_interrupt(void);
+
+void __init arch_init_irq(void)
+{
+       mips_cpu_irq_init(MIPS_CPU_IRQ_BASE);
+
+       set_except_vector(0, vr41xx_handle_interrupt);
+}
similarity index 85%
rename from arch/mips/vr41xx/tanbac-tb0226/setup.c
rename to arch/mips/vr41xx/common/type.c
index 60027e5dea25cc0df1038476752180e02c489d4d..bcb5f71b5026b77780d7e35add1c508e849e9510 100644 (file)
@@ -1,7 +1,7 @@
 /*
- *  setup.c, Setup for the TANBAC TB0226.
+ *  type.c, System type for NEC VR4100 series.
  *
- *  Copyright (C) 2002-2005  Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
+ *  Copyright (C) 2005  Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -20,5 +20,5 @@
 
 const char *get_system_type(void)
 {
-       return "TANBAC TB0226";
+       return "NEC VR4100 series";
 }
index 5475dd72e2649becc41a73cd54718cb051946067..ba58764ef8ead5b0613fa13424caa50c336446c9 100644 (file)
@@ -476,7 +476,7 @@ static inline int vrc4173_icu_init(int cascade_irq)
 
        if (cascade_irq < GIU_IRQ(0) || cascade_irq > GIU_IRQ(15))
                return -EINVAL;
-       
+
        vrc4173_outw(0, VRC4173_MSYSINT1REG);
 
        vr41xx_set_irq_trigger(GIU_IRQ_TO_PIN(cascade_irq), TRIGGER_LEVEL, SIGNAL_THROUGH);
index cff44602d3d414f0fae2dad5ffe1af26a1d5e94c..e4b34ad6ea61ec8bf3e087fb02d51007403e9e41 100644 (file)
 #include <asm/io.h>
 #include <asm/vr41xx/workpad.h>
 
-const char *get_system_type(void)
-{
-       return "IBM WorkPad z50";
-}
-
 static int __init ibm_workpad_setup(void)
 {
        set_io_port_base(IO_PORT_BASE);
index 87f06b3f5a9cbf29a6ceb8a6eb496cd3937fcd67..be590edb0b83944b2c8dd7d083a83ec9dc2b6da6 100644 (file)
  * Manish Lachwani (mlachwani@mvista.com)
  */
 #include <linux/config.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/string.h>
-
-#include <asm/bootinfo.h>
 
 #ifdef CONFIG_ROCKHOPPER
 #include <asm/io.h>
 
 #define PCICONFDREG    0xaf000c14
 #define PCICONFAREG    0xaf000c18
-#endif
-
-const char *get_system_type(void)
-{
-       return "NEC CMB-VR4133";
-}
 
-#ifdef CONFIG_ROCKHOPPER
 void disable_pcnet(void)
 {
        u32 data;
diff --git a/arch/mips/vr41xx/tanbac-tb0226/Makefile b/arch/mips/vr41xx/tanbac-tb0226/Makefile
deleted file mode 100644 (file)
index 372f953..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#
-# Makefile for the TANBAC TB0226 specific parts of the kernel
-#
-
-obj-y                  += setup.o
diff --git a/arch/mips/vr41xx/tanbac-tb0229/Makefile b/arch/mips/vr41xx/tanbac-tb0229/Makefile
deleted file mode 100644 (file)
index 9c6b864..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#
-# Makefile for the TANBAC TB0229(VR4131DIMM) specific parts of the kernel
-#
-
-obj-y                          := setup.o
diff --git a/arch/mips/vr41xx/tanbac-tb0229/setup.c b/arch/mips/vr41xx/tanbac-tb0229/setup.c
deleted file mode 100644 (file)
index 5c1b757..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- *  setup.c, Setup for the TANBAC TB0229 (VR4131DIMM)
- *
- *  Copyright (C) 2002-2005  Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
- *
- *  Modified for TANBAC TB0229:
- *  Copyright (C) 2003  Megasolution Inc.  <matsu@megasolution.jp>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-const char *get_system_type(void)
-{
-       return "TANBAC TB0229";
-}
diff --git a/arch/mips/vr41xx/victor-mpc30x/Makefile b/arch/mips/vr41xx/victor-mpc30x/Makefile
deleted file mode 100644 (file)
index a2e8086..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#
-# Makefile for the Victor MP-C303/304 specific parts of the kernel
-#
-
-obj-y                  += setup.o
diff --git a/arch/mips/vr41xx/victor-mpc30x/setup.c b/arch/mips/vr41xx/victor-mpc30x/setup.c
deleted file mode 100644 (file)
index f591e36..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- *  setup.c, Setup for the Victor MP-C303/304.
- *
- *  Copyright (C) 2002-2005  Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-const char *get_system_type(void)
-{
-       return "Victor MP-C303/304";
-}
diff --git a/arch/mips/vr41xx/zao-capcella/Makefile b/arch/mips/vr41xx/zao-capcella/Makefile
deleted file mode 100644 (file)
index cf42019..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#
-# Makefile for the ZAO Networks Capcella  specific parts of the kernel
-#
-
-obj-y                  += setup.o
diff --git a/arch/mips/vr41xx/zao-capcella/setup.c b/arch/mips/vr41xx/zao-capcella/setup.c
deleted file mode 100644 (file)
index 17bade2..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- *  setup.c, Setup for the ZAO Networks Capcella.
- *
- *  Copyright (C) 2002-2005  Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-const char *get_system_type(void)
-{
-       return "ZAO Networks Capcella";
-}
index e6fa1d1cc03a210991b6b029cd9c6bb50106037e..36dee0ff5ca048719ba8b6f9187fb6918ccb7cf7 100644 (file)
@@ -330,14 +330,6 @@ config RPXLITE
          End of life: end 2000 ?
          URL: see TQM850L
 
-         SPD823TS:
-         MPC823 based board used in the "Tele Server" product
-         Manufacturer: Speech Design, <http://www.speech-design.de/>
-         Date of Release: Mid 2000 (?)
-         End of life: -
-         URL: <http://www.speech-design.de/>
-         select "English", then "Teleteam Solutions", then "TeleServer"
-
          IVMS8:
          MPC860 based board used in the "Integrated Voice Mail System",
          Small Version (8 voice channels)
@@ -354,13 +346,6 @@ config RPXLITE
          End of life: -
          URL: <http://www.speech-design.de/>
 
-         SM850:
-         Service Module (based on TQM850L)
-         Manufacturer: Dependable Computer Systems, <http://www.decomsys.com/>
-         Date of Release: end 2000 (?)
-         End of life: mid 2001 (?)
-         URL: <http://www.tz-mikroelektronik.de/ServiceModule/index.html>
-
          HERMES:
          Hermes-Pro ISDN/LAN router with integrated 8 x hub
          Manufacturer: Multidata Gesellschaft fur Datentechnik und Informatik
@@ -464,13 +449,6 @@ config TQM860L
 config FPS850L
        bool "FPS850L"
 
-config SPD823TS
-       bool "SPD823TS"
-       help
-         Say Y here to support the Speech Design 823 Tele-Server from Speech
-         Design, released in 2000.  The manufacturer's website is at
-         <http://www.speech-design.de/>.
-
 config IVMS8
        bool "IVMS8"
        help
@@ -485,14 +463,6 @@ config IVML24
          from Speech Design, released March 2001.  The manufacturer's website
          is at <http://www.speech-design.de/>.
 
-config SM850
-       bool "SM850"
-       help
-         Say Y here to support the Service Module 850 from Dependable
-         Computer Systems, an SBC based on the TQM850L module by TQ
-         Components.  This board is no longer in production.  The
-         manufacturer's website is at <http://www.decomsys.com/>.
-
 config HERMES_PRO
        bool "HERMES"
 
@@ -525,6 +495,11 @@ config WINCEPT
          MPC821 PowerPC, introduced in 1998 and designed to be used in
          thin-client machines.  Say Y to support it directly.
 
+         Be aware that PCI buses can only function when SYS board is plugged
+         into the PIB (Platform IO Board) board from Freescale which provide
+         3 PCI slots.  The PIBs PCI initialization is the bootloader's
+         responsiblilty.
+
 endchoice
 
 choice
@@ -578,9 +553,6 @@ config CPCI690
        help
          Select CPCI690 if configuring a Force CPCI690 cPCI board.
 
-config PCORE
-       bool "Force-PowerCore"
-
 config POWERPMC250
        bool "Force-PowerPMC250"
 
@@ -613,9 +585,6 @@ config EV64260
 config LOPEC
        bool "Motorola-LoPEC"
 
-config MCPN765
-       bool "Motorola-MCPN765"
-
 config MVME5100
        bool "Motorola-MVME5100"
 
@@ -637,12 +606,6 @@ config SANDPOINT
 config RADSTONE_PPC7D
        bool "Radstone Technology PPC7D board"
 
-config ADIR
-       bool "SBS-Adirondack"
-
-config K2
-       bool "SBS-K2"
-
 config PAL4
        bool "SBS-Palomar4"
 
@@ -713,6 +676,11 @@ config MPC834x_SYS
        help
          This option enables support for the MPC 834x SYS evaluation board.
 
+config EV64360
+       bool "Marvell-EV64360BP"
+       help
+         Select EV64360 if configuring a Marvell EV64360BP Evaluation
+         platform.
 endchoice
 
 config PQ2ADS
@@ -722,7 +690,7 @@ config PQ2ADS
 
 config TQM8xxL
        bool
-       depends on 8xx && (TQM823L || TQM850L || FPS850L || TQM855L || TQM860L || SM850)
+       depends on 8xx && (TQM823L || TQM850L || FPS850L || TQM855L || TQM860L)
        default y
 
 config EMBEDDEDBOOT
@@ -796,15 +764,15 @@ config PPC_OF
 
 config PPC_GEN550
        bool
-       depends on SANDPOINT || MCPN765 || SPRUCE || PPLUS || PCORE || \
-               PRPMC750 || K2 || PRPMC800 || LOPEC || \
+       depends on SANDPOINT || SPRUCE || PPLUS || \
+               PRPMC750 || PRPMC800 || LOPEC || \
                (EV64260 && !SERIAL_MPSC) || CHESTNUT || RADSTONE_PPC7D || \
                83xx
        default y
 
 config FORCE
        bool
-       depends on 6xx && (PCORE || POWERPMC250)
+       depends on 6xx && POWERPMC250
        default y
 
 config GT64260
@@ -814,7 +782,7 @@ config GT64260
 
 config MV64360         # Really MV64360 & MV64460
        bool
-       depends on CHESTNUT || KATANA || RADSTONE_PPC7D || HDPU
+       depends on CHESTNUT || KATANA || RADSTONE_PPC7D || HDPU || EV64360
        default y
 
 config MV64X60
@@ -867,7 +835,7 @@ config EPIC_SERIAL_MODE
 
 config MPC10X_BRIDGE
        bool
-       depends on PCORE || POWERPMC250 || LOPEC || SANDPOINT
+       depends on POWERPMC250 || LOPEC || SANDPOINT
        default y
 
 config MPC10X_OPENPIC
@@ -886,10 +854,6 @@ config SANDPOINT_ENABLE_UART1
          If this option is enabled then the MPC824x processor will run
          in DUART mode instead of UART mode.
 
-config CPC710_DATA_GATHERING
-       bool "Enable CPC710 data gathering"
-       depends on K2
-
 config HARRIER_STORE_GATHERING
        bool "Enable Harrier store gathering"
        depends on HARRIER
@@ -1194,6 +1158,11 @@ config PCI_DOMAINS
        bool
        default PCI
 
+config MPC83xx_PCI2
+       bool "  Supprt for 2nd PCI host controller"
+       depends on PCI && MPC834x
+       default y if MPC834x_SYS
+
 config PCI_QSPAN
        bool "QSpan PCI"
        depends on !4xx && !CPM2 && 8xx
index e16c7710d4bef3442160e3d1886b7ac2690ba786..61653cb60c4e3f01f294f0dd04301446d5049a1d 100644 (file)
@@ -62,7 +62,8 @@ config BOOTX_TEXT
 
 config SERIAL_TEXT_DEBUG
        bool "Support for early boot texts over serial port"
-       depends on 4xx || GT64260 || LOPEC || PPLUS || PRPMC800 || PPC_GEN550 || PPC_MPC52xx
+       depends on 4xx || LOPEC || MV64X60 || PPLUS || PRPMC800 || \
+               PPC_GEN550 || PPC_MPC52xx
 
 config PPC_OCP
        bool
index d4dc4fa79647e856fcd5a853dd0e41106cab9b02..b7bd8f61a4adaab4afb1fd4a5bda99693bfcbc55 100644 (file)
@@ -96,10 +96,6 @@ zimageinitrd-$(CONFIG_OCOTEA)                := zImage.initrd-TREE
 zimageinitrd-$(CONFIG_GEMINI)          := zImage.initrd-STRIPELF
          end-$(CONFIG_GEMINI)          := gemini
 
-     extra.o-$(CONFIG_K2)              := prepmap.o
-         end-$(CONFIG_K2)              := k2
-   cacheflag-$(CONFIG_K2)              := -include $(clear_L2_L3)
-
      extra.o-$(CONFIG_KATANA)          := misc-katana.o
          end-$(CONFIG_KATANA)          := katana
    cacheflag-$(CONFIG_KATANA)          := -include $(clear_L2_L3)
@@ -108,12 +104,15 @@ zimageinitrd-$(CONFIG_GEMINI)             := zImage.initrd-STRIPELF
          end-$(CONFIG_RADSTONE_PPC7D)  := radstone_ppc7d
    cacheflag-$(CONFIG_RADSTONE_PPC7D)  := -include $(clear_L2_L3)
 
+     extra.o-$(CONFIG_EV64360)          := misc-ev64360.o
+         end-$(CONFIG_EV64360)          := ev64360
+   cacheflag-$(CONFIG_EV64360)          := -include $(clear_L2_L3)
+
 # kconfig 'feature', only one of these will ever be 'y' at a time.
 # The rest will be unset.
-motorola := $(CONFIG_MCPN765)$(CONFIG_MVME5100)$(CONFIG_PRPMC750) \
+motorola := $(CONFIG_MVME5100)$(CONFIG_PRPMC750) \
 $(CONFIG_PRPMC800)$(CONFIG_LOPEC)$(CONFIG_PPLUS)
 motorola := $(strip $(motorola))
-pcore := $(CONFIG_PCORE)$(CONFIG_POWERPMC250)
 
       zimage-$(motorola)               := zImage-PPLUS
 zimageinitrd-$(motorola)               := zImage.initrd-PPLUS
@@ -123,12 +122,6 @@ zimageinitrd-$(motorola)           := zImage.initrd-PPLUS
      extra.o-$(CONFIG_PPLUS)           := prepmap.o
      extra.o-$(CONFIG_LOPEC)           := mpc10x_memory.o
 
-      zimage-$(pcore)                  := zImage-STRIPELF
-zimageinitrd-$(pcore)                  := zImage.initrd-STRIPELF
-     extra.o-$(pcore)                  := chrpmap.o
-         end-$(pcore)                  := pcore
-   cacheflag-$(pcore)                  := -include $(clear_L2_L3)
-
 # Really only valid if CONFIG_6xx=y
       zimage-$(CONFIG_PPC_PREP)                := zImage-PPLUS
 zimageinitrd-$(CONFIG_PPC_PREP)                := zImage.initrd-PPLUS
@@ -158,8 +151,6 @@ zimageinitrd-$(CONFIG_LITE5200)             := zImage.initrd-STRIPELF
 
 # This is a treeboot that needs init functions until the
 # boot rom is sorted out (i.e. this is short lived)
-extra-aflags-$(CONFIG_REDWOOD_4)       := -Wa,-m405
-extra.o-$(CONFIG_REDWOOD_4)            := rw4/rw4_init.o rw4/rw4_init_brd.o
 EXTRA_AFLAGS := $(extra-aflags-y)
 # head.o needs to get the cacheflags defined.
 AFLAGS_head.o                          += $(cacheflag-y)
index c342b47e763e526e469b869603d224226ba12919..491a691d10ccabb007b73f8b34de4dbc4f246f2e 100644 (file)
@@ -784,28 +784,12 @@ embed_config(bd_t ** bdp)
 #ifdef CONFIG_IBM_OPENBIOS
 /* This could possibly work for all treeboot roms.
 */
-#if defined(CONFIG_ASH) || defined(CONFIG_BEECH) || defined(CONFIG_BUBINGA)
+#if defined(CONFIG_BUBINGA)
 #define BOARD_INFO_VECTOR       0xFFF80B50 /* openbios 1.19 moved this vector down  - armin */
 #else
 #define BOARD_INFO_VECTOR      0xFFFE0B50
 #endif
 
-#ifdef CONFIG_BEECH
-static void
-get_board_info(bd_t **bdp)
-{
-       typedef void (*PFV)(bd_t *bd);
-       ((PFV)(*(unsigned long *)BOARD_INFO_VECTOR))(*bdp);
-       return;
-}
-
-void
-embed_config(bd_t **bdp)
-{
-        *bdp = &bdinfo;
-       get_board_info(bdp);
-}
-#else /* !CONFIG_BEECH */
 void
 embed_config(bd_t **bdp)
 {
@@ -860,7 +844,6 @@ embed_config(bd_t **bdp)
 #endif
        timebase_period_ns = 1000000000 / bd->bi_tbfreq;
 }
-#endif /* CONFIG_BEECH */
 #endif /* CONFIG_IBM_OPENBIOS */
 
 #ifdef CONFIG_EP405
@@ -943,39 +926,3 @@ embed_config(bd_t **bdp)
 #endif
 }
 #endif
-
-#ifdef CONFIG_RAINIER
-/* Rainier uses vxworks bootrom */
-void
-embed_config(bd_t **bdp)
-{
-       u_char  *cp;
-       int     i;
-       bd_t    *bd;
-       
-       bd = &bdinfo;
-       *bdp = bd;
-       
-       for(i=0;i<8192;i+=32) {
-               __asm__("dccci 0,%0" :: "r" (i));
-       }
-       __asm__("iccci 0,0");
-       __asm__("sync;isync");
-
-       /* init ram for parity */
-       memset(0, 0,0x400000);  /* Lo memory */
-
-
-       bd->bi_memsize   = (32 * 1024 * 1024) ;
-       bd->bi_intfreq = 133000000; //the internal clock is 133 MHz
-       bd->bi_busfreq   = 100000000;
-       bd->bi_pci_busfreq= 33000000;
-
-       cp = (u_char *)def_enet_addr;
-       for (i=0; i<6; i++) {
-               bd->bi_enetaddr[i] = *cp++;
-       }
-
-}
-#endif
-
index 524053202bb4844232c5f3a57809f1d00ffba39d..5e4adc298bf9cdaf4aa12e655413a84fa1cdf190 100644 (file)
@@ -120,15 +120,6 @@ haveOF:
        mtspr   SPRN_DER,r4
 #endif
 
-#ifdef CONFIG_REDWOOD_4
-       /* All of this Redwood 4 stuff will soon disappear when the
-        * boot rom is straightened out.
-        */
-       mr      r29, r3         /* Easier than changing the other code */
-       bl      HdwInit
-       mr      r3, r29
-#endif
-
 #if defined(CONFIG_MBX) || defined(CONFIG_RPX8260) || defined(CONFIG_PPC_PREP)
        mr      r4,r29  /* put the board info pointer where the relocate
                         * routine will find it
index ef08e86c9b25d398ddb2144bbeadcf4f2c4cd660..26860300fa090e9302570811475afad8ab768dc2 100644 (file)
  */
 
 #include <linux/types.h>
+#include <asm/io.h>
 #include <platforms/cpci690.h>
 
+#define        KB      (1024UL)
+#define        MB      (1024UL*KB)
+#define        GB      (1024UL*MB)
+
 extern u32 mv64x60_console_baud;
 extern u32 mv64x60_mpsc_clk_src;
 extern u32 mv64x60_mpsc_clk_freq;
 
+u32 mag = 0xffff;
+
+unsigned long
+get_mem_size(void)
+{
+       u32     size;
+
+       switch (in_8(((void __iomem *)CPCI690_BR_BASE + CPCI690_BR_MEM_CTLR))
+                       & 0x07) {
+       case 0x01:
+               size = 256*MB;
+               break;
+       case 0x02:
+               size = 512*MB;
+               break;
+       case 0x03:
+               size = 768*MB;
+               break;
+       case 0x04:
+               size = 1*GB;
+               break;
+       case 0x05:
+               size = 1*GB + 512*MB;
+               break;
+       case 0x06:
+               size = 2*GB;
+               break;
+       default:
+               size = 0;
+       }
+
+       return size;
+}
+
 void
 mv64x60_board_init(void __iomem *old_base, void __iomem *new_base)
 {
        mv64x60_console_baud = CPCI690_MPSC_BAUD;
        mv64x60_mpsc_clk_src = CPCI690_MPSC_CLK_SRC;
-       mv64x60_mpsc_clk_freq = CPCI690_BUS_FREQ;
+       mv64x60_mpsc_clk_freq =
+               (get_mem_size() >= (1*GB)) ? 100000000 : 133333333;
 }
diff --git a/arch/ppc/boot/simple/misc-ev64360.c b/arch/ppc/boot/simple/misc-ev64360.c
new file mode 100644 (file)
index 0000000..cd1ccf2
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * arch/ppc/boot/simple/misc-ev64360.c
+ * Copyright (C) 2005 Lee Nicks <allinux@gmail.com>
+ *
+ * Based on arch/ppc/boot/simple/misc-katana.c from:
+ * Mark A. Greer <source@mvista.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <asm/io.h>
+#include <asm/mv64x60_defs.h>
+#include <platforms/ev64360.h>
+
+extern u32 mv64x60_console_baud;
+extern u32 mv64x60_mpsc_clk_src;
+extern u32 mv64x60_mpsc_clk_freq;
+
+/* Not in the kernel so won't include kernel.h to get its 'min' definition */
+#ifndef min
+#define        min(a,b)        (((a) < (b)) ? (a) : (b))
+#endif
+
+void
+mv64x60_board_init(void __iomem *old_base, void __iomem *new_base)
+{
+       mv64x60_console_baud  = EV64360_DEFAULT_BAUD;
+       mv64x60_mpsc_clk_src  = EV64360_MPSC_CLK_SRC;
+       mv64x60_mpsc_clk_freq = EV64360_MPSC_CLK_FREQ;
+}
index b6e1bb833157d0d6815c670dee9a29caf676fdfb..ec94a11bacac6d2320d9adbaaaf4d2ab874334d2 100644 (file)
@@ -26,6 +26,8 @@ extern u32 mv64x60_mpsc_clk_freq;
 #define        min(a,b)        (((a) < (b)) ? (a) : (b))
 #endif
 
+unsigned long mv64360_get_mem_size(void);
+
 void
 mv64x60_board_init(void __iomem *old_base, void __iomem *new_base)
 {
@@ -35,3 +37,9 @@ mv64x60_board_init(void __iomem *old_base, void __iomem *new_base)
                min(katana_bus_freq((void __iomem *)KATANA_CPLD_BASE),
                        MV64x60_TCLK_FREQ_MAX);
 }
+
+unsigned long
+get_mem_size(void)
+{
+       return mv64360_get_mem_size();
+}
index 7e88fc6d207d2b0dafdcdcba52429d4a8f3a52c4..258d4599fadc5b294322f9d3f11dcea4d3c7bff3 100644 (file)
 extern struct bi_record *decompress_kernel(unsigned long load_addr,
        int num_words, unsigned long cksum);
 
+
+u32 size_reg[MV64x60_CPU2MEM_WINDOWS] = {
+       MV64x60_CPU2MEM_0_SIZE, MV64x60_CPU2MEM_1_SIZE,
+       MV64x60_CPU2MEM_2_SIZE, MV64x60_CPU2MEM_3_SIZE
+};
+
+/* Read mem ctlr to get the amount of mem in system */
+unsigned long
+mv64360_get_mem_size(void)
+{
+       u32     enables, i, v;
+       u32     mem = 0;
+
+       enables = in_le32((void __iomem *)CONFIG_MV64X60_NEW_BASE +
+               MV64360_CPU_BAR_ENABLE) & 0xf;
+
+       for (i=0; i<MV64x60_CPU2MEM_WINDOWS; i++)
+               if (!(enables & (1<<i))) {
+                       v = in_le32((void __iomem *)CONFIG_MV64X60_NEW_BASE
+                               + size_reg[i]) & 0xffff;
+                       v = (v + 1) << 16;
+                       mem += v;
+               }
+
+       return mem;
+}
+
 void
 mv64x60_move_base(void __iomem *old_base, void __iomem *new_base)
 {
index 5b45eb46b669335482fd7354aeff34191a69eab8..b9c24d4c738bb56005c22226afa8cc33378cd9e7 100644 (file)
 #include <asm/mv64x60_defs.h>
 #include <mpsc_defs.h>
 
+#ifdef CONFIG_EV64360
+#include <platforms/ev64360.h>
+u32    mv64x60_console_baud = EV64360_DEFAULT_BAUD;
+u32    mv64x60_mpsc_clk_src = EV64360_MPSC_CLK_SRC; /* TCLK */
+u32    mv64x60_mpsc_clk_freq = EV64360_MPSC_CLK_FREQ;
+#else
 u32    mv64x60_console_baud = 9600;
 u32    mv64x60_mpsc_clk_src = 8; /* TCLK */
 u32    mv64x60_mpsc_clk_freq = 100000000;
+#endif
 
 extern void udelay(long);
 static void stop_dma(int chan);
diff --git a/arch/ppc/configs/SM850_defconfig b/arch/ppc/configs/SM850_defconfig
deleted file mode 100644 (file)
index 021884b..0000000
+++ /dev/null
@@ -1,522 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MMU=y
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
-CONFIG_HAVE_DEC_LOCK=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_LOG_BUF_SHIFT=14
-CONFIG_EMBEDDED=y
-CONFIG_FUTEX=y
-# CONFIG_EPOLL is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-# CONFIG_MODVERSIONS is not set
-CONFIG_KMOD=y
-
-#
-# Platform support
-#
-CONFIG_PPC=y
-CONFIG_PPC32=y
-# CONFIG_6xx is not set
-# CONFIG_40x is not set
-# CONFIG_POWER3 is not set
-CONFIG_8xx=y
-
-#
-# IBM 4xx options
-#
-CONFIG_EMBEDDEDBOOT=y
-CONFIG_SERIAL_CONSOLE=y
-CONFIG_NOT_COHERENT_CACHE=y
-# CONFIG_RPXLITE is not set
-# CONFIG_RPXCLASSIC is not set
-# CONFIG_BSEIP is not set
-# CONFIG_FADS is not set
-# CONFIG_TQM823L is not set
-# CONFIG_TQM850L is not set
-# CONFIG_TQM855L is not set
-# CONFIG_TQM860L is not set
-# CONFIG_FPS850L is not set
-# CONFIG_SPD823TS is not set
-# CONFIG_IVMS8 is not set
-# CONFIG_IVML24 is not set
-CONFIG_SM850=y
-# CONFIG_HERMES_PRO is not set
-# CONFIG_IP860 is not set
-# CONFIG_LWMON is not set
-# CONFIG_PCU_E is not set
-# CONFIG_CCM is not set
-# CONFIG_LANTEC is not set
-# CONFIG_MBX is not set
-# CONFIG_WINCEPT is not set
-CONFIG_TQM8xxL=y
-# CONFIG_SMP is not set
-# CONFIG_PREEMPT is not set
-CONFIG_MATH_EMULATION=y
-# CONFIG_CPU_FREQ is not set
-
-#
-# General setup
-#
-# CONFIG_HIGHMEM is not set
-# CONFIG_PCI is not set
-# CONFIG_PCI_DOMAINS is not set
-# CONFIG_PCI_QSPAN is not set
-CONFIG_KCORE_ELF=y
-CONFIG_BINFMT_ELF=y
-CONFIG_KERNEL_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_HOTPLUG is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="console=ttyCPM1"
-
-#
-# Advanced setup
-#
-# CONFIG_ADVANCED_OPTIONS is not set
-
-#
-# Default settings for advanced configuration options are used
-#
-CONFIG_HIGHMEM_START=0xfe000000
-CONFIG_LOWMEM_SIZE=0x30000000
-CONFIG_KERNEL_START=0xc0000000
-CONFIG_TASK_SIZE=0x80000000
-CONFIG_BOOT_LOAD=0x00400000
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Plug and Play support
-#
-# CONFIG_PNP is not set
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_DEV_LOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_RAM is not set
-# CONFIG_BLK_DEV_INITRD is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI support
-#
-# CONFIG_SCSI is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# I2O device support
-#
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK_DEV is not set
-# CONFIG_NETFILTER is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_INET_ECN is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_IPV6 is not set
-# CONFIG_XFRM_USER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-CONFIG_IPV6_SCTP__=y
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_LLC is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_MII is not set
-# CONFIG_OAKNET is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Token Ring devices (depends on LLC=y)
-#
-# CONFIG_SHAPER is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN_BOOL is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Old CD-ROM drivers (not SCSI, not IDE)
-#
-# CONFIG_CD_NO_IDESCSI is not set
-
-#
-# Input device support
-#
-# CONFIG_INPUT is not set
-
-#
-# Userland interfaces
-#
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-# CONFIG_SERIO is not set
-
-#
-# Input Device Drivers
-#
-
-#
-# Macintosh device drivers
-#
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_8250 is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_SERIAL_CPM=y
-CONFIG_SERIAL_CPM_CONSOLE=y
-# CONFIG_SERIAL_CPM_SCC1 is not set
-# CONFIG_SERIAL_CPM_SCC2 is not set
-# CONFIG_SERIAL_CPM_SCC3 is not set
-# CONFIG_SERIAL_CPM_SCC4 is not set
-CONFIG_SERIAL_CPM_SMC1=y
-CONFIG_SERIAL_CPM_SMC2=y
-CONFIG_SERIAL_CPM_ALT_SMC2=y
-CONFIG_UNIX98_PTYS=y
-# CONFIG_LEGACY_PTYS is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# I2C Hardware Sensors Mainboard support
-#
-
-#
-# I2C Hardware Sensors Chip support
-#
-# CONFIG_I2C_SENSOR is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_NVRAM is not set
-CONFIG_GEN_RTC=y
-# CONFIG_GEN_RTC_X is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-# CONFIG_HANGCHECK_TIMER is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# File systems
-#
-# CONFIG_EXT2_FS is not set
-CONFIG_EXT3_FS=y
-CONFIG_EXT3_FS_XATTR=y
-# CONFIG_EXT3_FS_POSIX_ACL is not set
-# CONFIG_EXT3_FS_SECURITY is not set
-CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=y
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-# CONFIG_DEVFS_FS is not set
-CONFIG_DEVPTS_FS=y
-# CONFIG_DEVPTS_FS_XATTR is not set
-CONFIG_TMPFS=y
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-# CONFIG_EXPORTFS is not set
-CONFIG_SUNRPC=y
-# CONFIG_SUNRPC_GSS is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-CONFIG_PARTITION_ADVANCED=y
-# CONFIG_ACORN_PARTITION is not set
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ATARI_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
-# CONFIG_MSDOS_PARTITION is not set
-# CONFIG_LDM_PARTITION is not set
-# CONFIG_NEC98_PARTITION is not set
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# MPC8xx CPM Options
-#
-CONFIG_SCC_ENET=y
-# CONFIG_SCC1_ENET is not set
-# CONFIG_SCC2_ENET is not set
-CONFIG_SCC3_ENET=y
-# CONFIG_FEC_ENET is not set
-CONFIG_ENET_BIG_BUFFERS=y
-
-#
-# Generic MPC8xx Options
-#
-CONFIG_8xx_COPYBACK=y
-CONFIG_8xx_CPU6=y
-# CONFIG_UCODE_PATCH is not set
-
-#
-# USB support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# Library routines
-#
-# CONFIG_CRC32 is not set
-
-#
-# Kernel hacking
-#
-# CONFIG_DEBUG_KERNEL is not set
-# CONFIG_KALLSYMS is not set
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
diff --git a/arch/ppc/configs/SPD823TS_defconfig b/arch/ppc/configs/SPD823TS_defconfig
deleted file mode 100644 (file)
index ba60fea..0000000
+++ /dev/null
@@ -1,520 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MMU=y
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
-CONFIG_HAVE_DEC_LOCK=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_LOG_BUF_SHIFT=14
-CONFIG_EMBEDDED=y
-CONFIG_FUTEX=y
-# CONFIG_EPOLL is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-# CONFIG_MODVERSIONS is not set
-CONFIG_KMOD=y
-
-#
-# Platform support
-#
-CONFIG_PPC=y
-CONFIG_PPC32=y
-# CONFIG_6xx is not set
-# CONFIG_40x is not set
-# CONFIG_POWER3 is not set
-CONFIG_8xx=y
-
-#
-# IBM 4xx options
-#
-CONFIG_EMBEDDEDBOOT=y
-CONFIG_SERIAL_CONSOLE=y
-CONFIG_NOT_COHERENT_CACHE=y
-# CONFIG_RPXLITE is not set
-# CONFIG_RPXCLASSIC is not set
-# CONFIG_BSEIP is not set
-# CONFIG_FADS is not set
-# CONFIG_TQM823L is not set
-# CONFIG_TQM850L is not set
-# CONFIG_TQM855L is not set
-# CONFIG_TQM860L is not set
-# CONFIG_FPS850L is not set
-CONFIG_SPD823TS=y
-# CONFIG_IVMS8 is not set
-# CONFIG_IVML24 is not set
-# CONFIG_SM850 is not set
-# CONFIG_HERMES_PRO is not set
-# CONFIG_IP860 is not set
-# CONFIG_LWMON is not set
-# CONFIG_PCU_E is not set
-# CONFIG_CCM is not set
-# CONFIG_LANTEC is not set
-# CONFIG_MBX is not set
-# CONFIG_WINCEPT is not set
-# CONFIG_SMP is not set
-# CONFIG_PREEMPT is not set
-CONFIG_MATH_EMULATION=y
-# CONFIG_CPU_FREQ is not set
-
-#
-# General setup
-#
-# CONFIG_HIGHMEM is not set
-# CONFIG_PCI is not set
-# CONFIG_PCI_DOMAINS is not set
-# CONFIG_PCI_QSPAN is not set
-CONFIG_KCORE_ELF=y
-CONFIG_BINFMT_ELF=y
-CONFIG_KERNEL_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_HOTPLUG is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-# CONFIG_CMDLINE_BOOL is not set
-
-#
-# Advanced setup
-#
-# CONFIG_ADVANCED_OPTIONS is not set
-
-#
-# Default settings for advanced configuration options are used
-#
-CONFIG_HIGHMEM_START=0xfe000000
-CONFIG_LOWMEM_SIZE=0x30000000
-CONFIG_KERNEL_START=0xc0000000
-CONFIG_TASK_SIZE=0x80000000
-CONFIG_BOOT_LOAD=0x00400000
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Plug and Play support
-#
-# CONFIG_PNP is not set
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_DEV_LOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_RAM is not set
-# CONFIG_BLK_DEV_INITRD is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI support
-#
-# CONFIG_SCSI is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# I2O device support
-#
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK_DEV is not set
-# CONFIG_NETFILTER is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_INET_ECN is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_IPV6 is not set
-# CONFIG_XFRM_USER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-CONFIG_IPV6_SCTP__=y
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_LLC is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_MII is not set
-# CONFIG_OAKNET is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Token Ring devices (depends on LLC=y)
-#
-# CONFIG_SHAPER is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN_BOOL is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Old CD-ROM drivers (not SCSI, not IDE)
-#
-# CONFIG_CD_NO_IDESCSI is not set
-
-#
-# Input device support
-#
-# CONFIG_INPUT is not set
-
-#
-# Userland interfaces
-#
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-# CONFIG_SERIO is not set
-
-#
-# Input Device Drivers
-#
-
-#
-# Macintosh device drivers
-#
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_8250 is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_SERIAL_CPM=y
-CONFIG_SERIAL_CPM_CONSOLE=y
-# CONFIG_SERIAL_CPM_SCC1 is not set
-# CONFIG_SERIAL_CPM_SCC2 is not set
-# CONFIG_SERIAL_CPM_SCC3 is not set
-# CONFIG_SERIAL_CPM_SCC4 is not set
-CONFIG_SERIAL_CPM_SMC1=y
-# CONFIG_SERIAL_CPM_SMC2 is not set
-CONFIG_SERIAL_CPM_ALT_SMC2=y
-CONFIG_UNIX98_PTYS=y
-# CONFIG_LEGACY_PTYS is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# I2C Hardware Sensors Mainboard support
-#
-
-#
-# I2C Hardware Sensors Chip support
-#
-# CONFIG_I2C_SENSOR is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_NVRAM is not set
-CONFIG_GEN_RTC=y
-# CONFIG_GEN_RTC_X is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-# CONFIG_HANGCHECK_TIMER is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# File systems
-#
-# CONFIG_EXT2_FS is not set
-CONFIG_EXT3_FS=y
-CONFIG_EXT3_FS_XATTR=y
-# CONFIG_EXT3_FS_POSIX_ACL is not set
-# CONFIG_EXT3_FS_SECURITY is not set
-CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=y
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-# CONFIG_DEVFS_FS is not set
-CONFIG_DEVPTS_FS=y
-# CONFIG_DEVPTS_FS_XATTR is not set
-CONFIG_TMPFS=y
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-# CONFIG_EXPORTFS is not set
-CONFIG_SUNRPC=y
-# CONFIG_SUNRPC_GSS is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-CONFIG_PARTITION_ADVANCED=y
-# CONFIG_ACORN_PARTITION is not set
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ATARI_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
-# CONFIG_MSDOS_PARTITION is not set
-# CONFIG_LDM_PARTITION is not set
-# CONFIG_NEC98_PARTITION is not set
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# MPC8xx CPM Options
-#
-CONFIG_SCC_ENET=y
-# CONFIG_SCC1_ENET is not set
-CONFIG_SCC2_ENET=y
-# CONFIG_SCC3_ENET is not set
-# CONFIG_FEC_ENET is not set
-CONFIG_ENET_BIG_BUFFERS=y
-
-#
-# Generic MPC8xx Options
-#
-CONFIG_8xx_COPYBACK=y
-# CONFIG_8xx_CPU6 is not set
-# CONFIG_UCODE_PATCH is not set
-
-#
-# USB support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# Library routines
-#
-# CONFIG_CRC32 is not set
-
-#
-# Kernel hacking
-#
-# CONFIG_DEBUG_KERNEL is not set
-# CONFIG_KALLSYMS is not set
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
diff --git a/arch/ppc/configs/adir_defconfig b/arch/ppc/configs/adir_defconfig
deleted file mode 100644 (file)
index f20e653..0000000
+++ /dev/null
@@ -1,805 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MMU=y
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
-CONFIG_HAVE_DEC_LOCK=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_EMBEDDED is not set
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-# CONFIG_MODVERSIONS is not set
-CONFIG_KMOD=y
-
-#
-# Platform support
-#
-CONFIG_PPC=y
-CONFIG_PPC32=y
-CONFIG_6xx=y
-# CONFIG_40x is not set
-# CONFIG_POWER3 is not set
-# CONFIG_8xx is not set
-
-#
-# IBM 4xx options
-#
-# CONFIG_8260 is not set
-CONFIG_GENERIC_ISA_DMA=y
-CONFIG_PPC_STD_MMU=y
-# CONFIG_PPC_MULTIPLATFORM is not set
-# CONFIG_APUS is not set
-# CONFIG_WILLOW_2 is not set
-# CONFIG_PCORE is not set
-# CONFIG_POWERPMC250 is not set
-# CONFIG_EV64260 is not set
-# CONFIG_SPRUCE is not set
-# CONFIG_LOPEC is not set
-# CONFIG_MCPN765 is not set
-# CONFIG_MVME5100 is not set
-# CONFIG_PPLUS is not set
-# CONFIG_PRPMC750 is not set
-# CONFIG_PRPMC800 is not set
-# CONFIG_SANDPOINT is not set
-CONFIG_ADIR=y
-# CONFIG_K2 is not set
-# CONFIG_PAL4 is not set
-# CONFIG_GEMINI is not set
-# CONFIG_SMP is not set
-# CONFIG_PREEMPT is not set
-# CONFIG_ALTIVEC is not set
-# CONFIG_TAU is not set
-# CONFIG_CPU_FREQ is not set
-
-#
-# General setup
-#
-# CONFIG_HIGHMEM is not set
-CONFIG_PCI=y
-CONFIG_PCI_DOMAINS=y
-CONFIG_KCORE_ELF=y
-CONFIG_BINFMT_ELF=y
-CONFIG_KERNEL_ELF=y
-# CONFIG_BINFMT_MISC is not set
-CONFIG_PCI_LEGACY_PROC=y
-# CONFIG_PCI_NAMES is not set
-# CONFIG_HOTPLUG is not set
-
-#
-# Parallel port support
-#
-CONFIG_PARPORT=y
-CONFIG_PARPORT_PC=y
-CONFIG_PARPORT_PC_CML1=y
-# CONFIG_PARPORT_SERIAL is not set
-CONFIG_PARPORT_PC_FIFO=y
-CONFIG_PARPORT_PC_SUPERIO=y
-# CONFIG_PARPORT_OTHER is not set
-CONFIG_PARPORT_1284=y
-# CONFIG_PPC601_SYNC_FIX is not set
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="ip=on"
-
-#
-# Advanced setup
-#
-# CONFIG_ADVANCED_OPTIONS is not set
-
-#
-# Default settings for advanced configuration options are used
-#
-CONFIG_HIGHMEM_START=0xfe000000
-CONFIG_LOWMEM_SIZE=0x30000000
-CONFIG_KERNEL_START=0xc0000000
-CONFIG_TASK_SIZE=0x80000000
-CONFIG_BOOT_LOAD=0x00800000
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Plug and Play support
-#
-# CONFIG_PNP is not set
-
-#
-# Block devices
-#
-CONFIG_BLK_DEV_FD=y
-# CONFIG_PARIDE is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_NBD is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_INITRD=y
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI support
-#
-CONFIG_SCSI=y
-
-#
-# SCSI support type (disk, tape, CD-ROM)
-#
-CONFIG_BLK_DEV_SD=y
-CONFIG_CHR_DEV_ST=y
-# CONFIG_CHR_DEV_OSST is not set
-CONFIG_BLK_DEV_SR=y
-CONFIG_BLK_DEV_SR_VENDOR=y
-CONFIG_CHR_DEV_SG=y
-
-#
-# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
-#
-# CONFIG_SCSI_MULTI_LUN is not set
-# CONFIG_SCSI_REPORT_LUNS is not set
-CONFIG_SCSI_CONSTANTS=y
-# CONFIG_SCSI_LOGGING is not set
-
-#
-# SCSI low-level drivers
-#
-# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
-# CONFIG_SCSI_ACARD is not set
-# CONFIG_SCSI_AACRAID is not set
-# CONFIG_SCSI_AIC7XXX is not set
-# CONFIG_SCSI_AIC7XXX_OLD is not set
-# CONFIG_SCSI_AIC79XX is not set
-# CONFIG_SCSI_DPT_I2O is not set
-# CONFIG_SCSI_ADVANSYS is not set
-# CONFIG_SCSI_IN2000 is not set
-# CONFIG_SCSI_AM53C974 is not set
-# CONFIG_SCSI_MEGARAID is not set
-# CONFIG_SCSI_BUSLOGIC is not set
-# CONFIG_SCSI_CPQFCTS is not set
-# CONFIG_SCSI_DMX3191D is not set
-# CONFIG_SCSI_EATA is not set
-# CONFIG_SCSI_EATA_PIO is not set
-# CONFIG_SCSI_FUTURE_DOMAIN is not set
-# CONFIG_SCSI_GDTH is not set
-# CONFIG_SCSI_GENERIC_NCR5380 is not set
-# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
-# CONFIG_SCSI_INITIO is not set
-# CONFIG_SCSI_INIA100 is not set
-# CONFIG_SCSI_PPA is not set
-# CONFIG_SCSI_IMM is not set
-# CONFIG_SCSI_NCR53C7xx is not set
-# CONFIG_SCSI_SYM53C8XX_2 is not set
-CONFIG_SCSI_NCR53C8XX=y
-CONFIG_SCSI_SYM53C8XX=y
-CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS=8
-CONFIG_SCSI_NCR53C8XX_MAX_TAGS=32
-CONFIG_SCSI_NCR53C8XX_SYNC=20
-# CONFIG_SCSI_NCR53C8XX_PROFILE is not set
-# CONFIG_SCSI_NCR53C8XX_IOMAPPED is not set
-# CONFIG_SCSI_NCR53C8XX_PQS_PDS is not set
-# CONFIG_SCSI_NCR53C8XX_SYMBIOS_COMPAT is not set
-# CONFIG_SCSI_PCI2000 is not set
-# CONFIG_SCSI_PCI2220I is not set
-# CONFIG_SCSI_QLOGIC_ISP is not set
-# CONFIG_SCSI_QLOGIC_FC is not set
-# CONFIG_SCSI_QLOGIC_1280 is not set
-# CONFIG_SCSI_DC395x is not set
-# CONFIG_SCSI_DC390T is not set
-# CONFIG_SCSI_U14_34F is not set
-# CONFIG_SCSI_NSP32 is not set
-# CONFIG_SCSI_DEBUG is not set
-
-#
-# Fusion MPT device support
-#
-# CONFIG_FUSION is not set
-
-#
-# IEEE 1394 (FireWire) support (EXPERIMENTAL)
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK_DEV is not set
-CONFIG_NETFILTER=y
-# CONFIG_NETFILTER_DEBUG is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_INET_ECN is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-
-#
-# IP: Netfilter Configuration
-#
-CONFIG_IP_NF_CONNTRACK=m
-CONFIG_IP_NF_FTP=m
-CONFIG_IP_NF_IRC=m
-CONFIG_IP_NF_TFTP=m
-CONFIG_IP_NF_AMANDA=m
-# CONFIG_IP_NF_QUEUE is not set
-CONFIG_IP_NF_IPTABLES=m
-CONFIG_IP_NF_MATCH_LIMIT=m
-CONFIG_IP_NF_MATCH_MAC=m
-CONFIG_IP_NF_MATCH_PKTTYPE=m
-CONFIG_IP_NF_MATCH_MARK=m
-CONFIG_IP_NF_MATCH_MULTIPORT=m
-CONFIG_IP_NF_MATCH_TOS=m
-CONFIG_IP_NF_MATCH_ECN=m
-CONFIG_IP_NF_MATCH_DSCP=m
-CONFIG_IP_NF_MATCH_AH_ESP=m
-CONFIG_IP_NF_MATCH_LENGTH=m
-CONFIG_IP_NF_MATCH_TTL=m
-CONFIG_IP_NF_MATCH_TCPMSS=m
-CONFIG_IP_NF_MATCH_HELPER=m
-CONFIG_IP_NF_MATCH_STATE=m
-CONFIG_IP_NF_MATCH_CONNTRACK=m
-CONFIG_IP_NF_MATCH_UNCLEAN=m
-CONFIG_IP_NF_MATCH_OWNER=m
-CONFIG_IP_NF_FILTER=m
-CONFIG_IP_NF_TARGET_REJECT=m
-CONFIG_IP_NF_TARGET_MIRROR=m
-CONFIG_IP_NF_NAT=m
-CONFIG_IP_NF_NAT_NEEDED=y
-CONFIG_IP_NF_TARGET_MASQUERADE=m
-CONFIG_IP_NF_TARGET_REDIRECT=m
-CONFIG_IP_NF_NAT_SNMP_BASIC=m
-CONFIG_IP_NF_NAT_IRC=m
-CONFIG_IP_NF_NAT_FTP=m
-CONFIG_IP_NF_NAT_TFTP=m
-CONFIG_IP_NF_NAT_AMANDA=m
-# CONFIG_IP_NF_MANGLE is not set
-# CONFIG_IP_NF_TARGET_LOG is not set
-# CONFIG_IP_NF_TARGET_ULOG is not set
-CONFIG_IP_NF_TARGET_TCPMSS=m
-CONFIG_IP_NF_ARPTABLES=m
-CONFIG_IP_NF_ARPFILTER=m
-CONFIG_IP_NF_COMPAT_IPCHAINS=m
-# CONFIG_IP_NF_COMPAT_IPFWADM is not set
-# CONFIG_IPV6 is not set
-# CONFIG_XFRM_USER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-CONFIG_IPV6_SCTP__=y
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_LLC is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-CONFIG_NETDEVICES=y
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
-# CONFIG_OAKNET is not set
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_NET_VENDOR_3COM is not set
-
-#
-# Tulip family network device support
-#
-# CONFIG_NET_TULIP is not set
-# CONFIG_HP100 is not set
-CONFIG_NET_PCI=y
-# CONFIG_PCNET32 is not set
-# CONFIG_AMD8111_ETH is not set
-# CONFIG_ADAPTEC_STARFIRE is not set
-# CONFIG_B44 is not set
-# CONFIG_DGRS is not set
-CONFIG_EEPRO100=y
-# CONFIG_EEPRO100_PIO is not set
-# CONFIG_E100 is not set
-# CONFIG_FEALNX is not set
-# CONFIG_NATSEMI is not set
-# CONFIG_NE2K_PCI is not set
-# CONFIG_8139CP is not set
-# CONFIG_8139TOO is not set
-# CONFIG_SIS900 is not set
-# CONFIG_EPIC100 is not set
-# CONFIG_SUNDANCE is not set
-# CONFIG_TLAN is not set
-# CONFIG_VIA_RHINE is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_TIGON3 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_IXGB is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PLIP is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Token Ring devices (depends on LLC=y)
-#
-# CONFIG_NET_FC is not set
-# CONFIG_RCPCI is not set
-# CONFIG_SHAPER is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN_BOOL is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Old CD-ROM drivers (not SCSI, not IDE)
-#
-# CONFIG_CD_NO_IDESCSI is not set
-
-#
-# Input device support
-#
-# CONFIG_INPUT is not set
-
-#
-# Userland interfaces
-#
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-# CONFIG_SERIO is not set
-
-#
-# Input Device Drivers
-#
-
-#
-# Macintosh device drivers
-#
-
-#
-# Character devices
-#
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_EXTENDED is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=256
-# CONFIG_PRINTER is not set
-# CONFIG_PPDEV is not set
-# CONFIG_TIPAR is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# I2C Hardware Sensors Mainboard support
-#
-
-#
-# I2C Hardware Sensors Chip support
-#
-# CONFIG_I2C_SENSOR is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_NVRAM is not set
-CONFIG_GEN_RTC=y
-# CONFIG_GEN_RTC_X is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-# CONFIG_HANGCHECK_TIMER is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-CONFIG_EXT3_FS=y
-CONFIG_EXT3_FS_XATTR=y
-# CONFIG_EXT3_FS_POSIX_ACL is not set
-# CONFIG_EXT3_FS_SECURITY is not set
-CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=y
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-# CONFIG_DEVFS_FS is not set
-CONFIG_DEVPTS_FS=y
-# CONFIG_DEVPTS_FS_XATTR is not set
-CONFIG_TMPFS=y
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-# CONFIG_EXPORTFS is not set
-CONFIG_SUNRPC=y
-# CONFIG_SUNRPC_GSS is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-CONFIG_USB=y
-# CONFIG_USB_DEBUG is not set
-
-#
-# Miscellaneous USB options
-#
-CONFIG_USB_DEVICEFS=y
-# CONFIG_USB_BANDWIDTH is not set
-CONFIG_USB_DYNAMIC_MINORS=y
-
-#
-# USB Host Controller Drivers
-#
-# CONFIG_USB_EHCI_HCD is not set
-CONFIG_USB_OHCI_HCD=y
-# CONFIG_USB_UHCI_HCD is not set
-
-#
-# USB Device Class drivers
-#
-# CONFIG_USB_BLUETOOTH_TTY is not set
-CONFIG_USB_ACM=m
-# CONFIG_USB_PRINTER is not set
-CONFIG_USB_STORAGE=m
-# CONFIG_USB_STORAGE_DEBUG is not set
-# CONFIG_USB_STORAGE_DATAFAB is not set
-CONFIG_USB_STORAGE_FREECOM=y
-# CONFIG_USB_STORAGE_ISD200 is not set
-CONFIG_USB_STORAGE_DPCM=y
-# CONFIG_USB_STORAGE_HP8200e is not set
-# CONFIG_USB_STORAGE_SDDR09 is not set
-# CONFIG_USB_STORAGE_SDDR55 is not set
-# CONFIG_USB_STORAGE_JUMPSHOT is not set
-
-#
-# USB Human Interface Devices (HID)
-#
-CONFIG_USB_HID=m
-
-#
-# Input core support is needed for USB HID input layer or HIDBP support
-#
-CONFIG_USB_HIDDEV=y
-
-#
-# USB HID Boot Protocol drivers
-#
-
-#
-# USB Imaging devices
-#
-# CONFIG_USB_MDC800 is not set
-# CONFIG_USB_SCANNER is not set
-# CONFIG_USB_MICROTEK is not set
-# CONFIG_USB_HPUSBSCSI is not set
-
-#
-# USB Multimedia devices
-#
-# CONFIG_USB_DABUSB is not set
-
-#
-# Video4Linux support is needed for USB Multimedia device support
-#
-
-#
-# USB Network adaptors
-#
-# CONFIG_USB_CATC is not set
-# CONFIG_USB_KAWETH is not set
-# CONFIG_USB_PEGASUS is not set
-# CONFIG_USB_RTL8150 is not set
-# CONFIG_USB_USBNET is not set
-
-#
-# USB port drivers
-#
-# CONFIG_USB_USS720 is not set
-
-#
-# USB Serial Converter support
-#
-CONFIG_USB_SERIAL=m
-# CONFIG_USB_SERIAL_GENERIC is not set
-# CONFIG_USB_SERIAL_BELKIN is not set
-# CONFIG_USB_SERIAL_WHITEHEAT is not set
-# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
-# CONFIG_USB_SERIAL_EMPEG is not set
-# CONFIG_USB_SERIAL_FTDI_SIO is not set
-CONFIG_USB_SERIAL_VISOR=m
-# CONFIG_USB_SERIAL_IPAQ is not set
-# CONFIG_USB_SERIAL_IR is not set
-# CONFIG_USB_SERIAL_EDGEPORT is not set
-# CONFIG_USB_SERIAL_EDGEPORT_TI is not set
-# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
-CONFIG_USB_SERIAL_KEYSPAN=m
-# CONFIG_USB_SERIAL_KEYSPAN_MPR is not set
-CONFIG_USB_SERIAL_KEYSPAN_USA28=y
-CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
-# CONFIG_USB_SERIAL_KEYSPAN_USA28XA is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA28XB is not set
-CONFIG_USB_SERIAL_KEYSPAN_USA19=y
-CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
-CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
-CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
-CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
-CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
-# CONFIG_USB_SERIAL_KEYSPAN_USA49WLC is not set
-# CONFIG_USB_SERIAL_KLSI is not set
-# CONFIG_USB_SERIAL_KOBIL_SCT is not set
-# CONFIG_USB_SERIAL_MCT_U232 is not set
-# CONFIG_USB_SERIAL_PL2303 is not set
-# CONFIG_USB_SERIAL_SAFE is not set
-# CONFIG_USB_SERIAL_CYBERJACK is not set
-# CONFIG_USB_SERIAL_XIRCOM is not set
-# CONFIG_USB_SERIAL_OMNINET is not set
-CONFIG_USB_EZUSB=y
-
-#
-# USB Miscellaneous drivers
-#
-# CONFIG_USB_TIGL is not set
-# CONFIG_USB_AUERSWALD is not set
-# CONFIG_USB_RIO500 is not set
-# CONFIG_USB_LCD is not set
-# CONFIG_USB_TEST is not set
-# CONFIG_USB_GADGET is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# Library routines
-#
-# CONFIG_CRC32 is not set
-
-#
-# Kernel hacking
-#
-# CONFIG_DEBUG_KERNEL is not set
-# CONFIG_KALLSYMS is not set
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
diff --git a/arch/ppc/configs/ash_defconfig b/arch/ppc/configs/ash_defconfig
deleted file mode 100644 (file)
index c4a73cc..0000000
+++ /dev/null
@@ -1,666 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MMU=y
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
-CONFIG_HAVE_DEC_LOCK=y
-CONFIG_PPC=y
-CONFIG_PPC32=y
-CONFIG_GENERIC_NVRAM=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_HOTPLUG is not set
-# CONFIG_IKCONFIG is not set
-CONFIG_EMBEDDED=y
-# CONFIG_KALLSYMS is not set
-CONFIG_FUTEX=y
-# CONFIG_EPOLL is not set
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-# CONFIG_MODVERSIONS is not set
-CONFIG_KMOD=y
-
-#
-# Processor
-#
-# CONFIG_6xx is not set
-CONFIG_40x=y
-# CONFIG_44x is not set
-# CONFIG_POWER3 is not set
-# CONFIG_POWER4 is not set
-# CONFIG_8xx is not set
-# CONFIG_MATH_EMULATION is not set
-# CONFIG_CPU_FREQ is not set
-CONFIG_4xx=y
-
-#
-# IBM 4xx options
-#
-CONFIG_ASH=y
-# CONFIG_CPCI405 is not set
-# CONFIG_EP405 is not set
-# CONFIG_EVB405EP is not set
-# CONFIG_OAK is not set
-# CONFIG_REDWOOD_5 is not set
-# CONFIG_REDWOOD_6 is not set
-# CONFIG_SYCAMORE is not set
-# CONFIG_WALNUT is not set
-CONFIG_NP405H=y
-CONFIG_IBM405_ERR77=y
-CONFIG_IBM405_ERR51=y
-CONFIG_IBM_OCP=y
-CONFIG_PPC_OCP=y
-CONFIG_IBM_OPENBIOS=y
-# CONFIG_PM is not set
-CONFIG_UART0_TTYS0=y
-# CONFIG_UART0_TTYS1 is not set
-CONFIG_NOT_COHERENT_CACHE=y
-
-#
-# Platform options
-#
-# CONFIG_PC_KEYBOARD is not set
-# CONFIG_SMP is not set
-# CONFIG_PREEMPT is not set
-# CONFIG_HIGHMEM is not set
-CONFIG_KERNEL_ELF=y
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="ip=on"
-
-#
-# Bus options
-#
-CONFIG_PCI=y
-CONFIG_PCI_DOMAINS=y
-CONFIG_PCI_LEGACY_PROC=y
-# CONFIG_PCI_NAMES is not set
-
-#
-# Advanced setup
-#
-# CONFIG_ADVANCED_OPTIONS is not set
-
-#
-# Default settings for advanced configuration options are used
-#
-CONFIG_HIGHMEM_START=0xfe000000
-CONFIG_LOWMEM_SIZE=0x30000000
-CONFIG_KERNEL_START=0xc0000000
-CONFIG_TASK_SIZE=0x80000000
-CONFIG_BOOT_LOAD=0x00400000
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_CARMEL is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_INITRD=y
-# CONFIG_LBD is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-# CONFIG_FUSION is not set
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-
-#
-# Macintosh device drivers
-#
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-# CONFIG_PACKET is not set
-# CONFIG_NETLINK_DEV is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-# CONFIG_IP_PNP_DHCP is not set
-CONFIG_IP_PNP_BOOTP=y
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_IP_MROUTE is not set
-# CONFIG_ARPD is not set
-CONFIG_SYN_COOKIES=y
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_IPV6 is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-CONFIG_NETDEVICES=y
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-# CONFIG_NET_ETHERNET is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SIS190 is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_TIGON3 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_IXGB is not set
-CONFIG_IBM_EMAC=y
-# CONFIG_IBM_EMAC_ERRMSG is not set
-CONFIG_IBM_EMAC_RXB=64
-CONFIG_IBM_EMAC_TXB=8
-CONFIG_IBM_EMAC_FGAP=8
-CONFIG_IBM_EMAC_SKBRES=0
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-# CONFIG_RCPCI is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-CONFIG_SERIO_I8042=y
-CONFIG_SERIO_SERPORT=y
-# CONFIG_SERIO_CT82C710 is not set
-# CONFIG_SERIO_PCIPS2 is not set
-
-#
-# Input Device Drivers
-#
-CONFIG_INPUT_KEYBOARD=y
-CONFIG_KEYBOARD_ATKBD=y
-# CONFIG_KEYBOARD_SUNKBD is not set
-# CONFIG_KEYBOARD_LKKBD is not set
-# CONFIG_KEYBOARD_XTKBD is not set
-# CONFIG_KEYBOARD_NEWTON is not set
-CONFIG_INPUT_MOUSE=y
-CONFIG_MOUSE_PS2=y
-# CONFIG_MOUSE_SERIAL is not set
-# CONFIG_MOUSE_VSXXXAA is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_SERIAL_8250_NR_UARTS=4
-# CONFIG_SERIAL_8250_EXTENDED is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-CONFIG_WATCHDOG=y
-# CONFIG_WATCHDOG_NOWAYOUT is not set
-
-#
-# Watchdog Device Drivers
-#
-# CONFIG_SOFT_WATCHDOG is not set
-
-#
-# PCI-based Watchdog Cards
-#
-# CONFIG_PCIPCWATCHDOG is not set
-# CONFIG_WDTPCI is not set
-# CONFIG_NVRAM is not set
-CONFIG_GEN_RTC=y
-# CONFIG_GEN_RTC_X is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# I2C support
-#
-CONFIG_I2C=y
-# CONFIG_I2C_CHARDEV is not set
-
-#
-# I2C Algorithms
-#
-# CONFIG_I2C_ALGOBIT is not set
-# CONFIG_I2C_ALGOPCF is not set
-
-#
-# I2C Hardware Bus support
-#
-# CONFIG_I2C_ALI1535 is not set
-# CONFIG_I2C_ALI15X3 is not set
-# CONFIG_I2C_AMD756 is not set
-# CONFIG_I2C_AMD8111 is not set
-# CONFIG_I2C_I801 is not set
-# CONFIG_I2C_I810 is not set
-# CONFIG_I2C_IBM_IIC is not set
-# CONFIG_I2C_ISA is not set
-# CONFIG_I2C_NFORCE2 is not set
-# CONFIG_I2C_PARPORT_LIGHT is not set
-# CONFIG_I2C_PIIX4 is not set
-# CONFIG_I2C_PROSAVAGE is not set
-# CONFIG_I2C_SAVAGE4 is not set
-# CONFIG_SCx200_ACB is not set
-# CONFIG_I2C_SIS5595 is not set
-# CONFIG_I2C_SIS630 is not set
-# CONFIG_I2C_SIS96X is not set
-# CONFIG_I2C_VIA is not set
-# CONFIG_I2C_VIAPRO is not set
-# CONFIG_I2C_VOODOO3 is not set
-
-#
-# Hardware Sensors Chip support
-#
-# CONFIG_I2C_SENSOR is not set
-# CONFIG_SENSORS_ADM1021 is not set
-# CONFIG_SENSORS_ASB100 is not set
-# CONFIG_SENSORS_DS1621 is not set
-# CONFIG_SENSORS_FSCHER is not set
-# CONFIG_SENSORS_GL518SM is not set
-# CONFIG_SENSORS_IT87 is not set
-# CONFIG_SENSORS_LM75 is not set
-# CONFIG_SENSORS_LM78 is not set
-# CONFIG_SENSORS_LM80 is not set
-# CONFIG_SENSORS_LM83 is not set
-# CONFIG_SENSORS_LM85 is not set
-# CONFIG_SENSORS_LM90 is not set
-# CONFIG_SENSORS_VIA686A is not set
-# CONFIG_SENSORS_W83781D is not set
-# CONFIG_SENSORS_W83L785TS is not set
-# CONFIG_SENSORS_W83627HF is not set
-
-#
-# Other I2C Chip support
-#
-# CONFIG_SENSORS_EEPROM is not set
-# CONFIG_I2C_DEBUG_CORE is not set
-# CONFIG_I2C_DEBUG_ALGO is not set
-# CONFIG_I2C_DEBUG_BUS is not set
-# CONFIG_I2C_DEBUG_CHIP is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-# CONFIG_DEVFS_FS is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
-CONFIG_TMPFS=y
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-# CONFIG_EXPORTFS is not set
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-CONFIG_PARTITION_ADVANCED=y
-# CONFIG_ACORN_PARTITION is not set
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ATARI_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
-# CONFIG_MSDOS_PARTITION is not set
-# CONFIG_LDM_PARTITION is not set
-# CONFIG_NEC98_PARTITION is not set
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
-
-#
-# Native Language Support
-#
-# CONFIG_NLS is not set
-
-#
-# IBM 40x options
-#
-
-#
-# Library routines
-#
-CONFIG_CRC32=y
-
-#
-# Kernel hacking
-#
-# CONFIG_DEBUG_KERNEL is not set
-# CONFIG_SERIAL_TEXT_DEBUG is not set
-CONFIG_OCP=y
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
diff --git a/arch/ppc/configs/beech_defconfig b/arch/ppc/configs/beech_defconfig
deleted file mode 100644 (file)
index 0bd671b..0000000
+++ /dev/null
@@ -1,615 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MMU=y
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
-CONFIG_HAVE_DEC_LOCK=y
-CONFIG_PPC=y
-CONFIG_PPC32=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-# CONFIG_STANDALONE is not set
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-# CONFIG_SWAP is not set
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_IKCONFIG is not set
-CONFIG_EMBEDDED=y
-# CONFIG_KALLSYMS is not set
-CONFIG_FUTEX=y
-# CONFIG_EPOLL is not set
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-CONFIG_MODVERSIONS=y
-CONFIG_KMOD=y
-
-#
-# Processor
-#
-# CONFIG_6xx is not set
-CONFIG_40x=y
-# CONFIG_44x is not set
-# CONFIG_POWER3 is not set
-# CONFIG_POWER4 is not set
-# CONFIG_8xx is not set
-# CONFIG_MATH_EMULATION is not set
-# CONFIG_CPU_FREQ is not set
-CONFIG_4xx=y
-
-#
-# IBM 4xx options
-#
-# CONFIG_ASH is not set
-CONFIG_BEECH=y
-# CONFIG_CEDAR is not set
-# CONFIG_CPCI405 is not set
-# CONFIG_EP405 is not set
-# CONFIG_OAK is not set
-# CONFIG_REDWOOD_4 is not set
-# CONFIG_REDWOOD_5 is not set
-# CONFIG_REDWOOD_6 is not set
-# CONFIG_SYCAMORE is not set
-# CONFIG_TIVO is not set
-# CONFIG_WALNUT is not set
-CONFIG_IBM405_ERR77=y
-CONFIG_IBM405_ERR51=y
-CONFIG_IBM_OCP=y
-CONFIG_IBM_OPENBIOS=y
-CONFIG_405_DMA=y
-# CONFIG_PM is not set
-CONFIG_UART0_TTYS0=y
-# CONFIG_UART0_TTYS1 is not set
-CONFIG_NOT_COHERENT_CACHE=y
-
-#
-# Platform options
-#
-# CONFIG_PC_KEYBOARD is not set
-# CONFIG_SMP is not set
-# CONFIG_PREEMPT is not set
-# CONFIG_HIGHMEM is not set
-CONFIG_KERNEL_ELF=y
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_CMDLINE_BOOL is not set
-
-#
-# Bus options
-#
-# CONFIG_PCI is not set
-# CONFIG_PCI_DOMAINS is not set
-# CONFIG_HOTPLUG is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Advanced setup
-#
-# CONFIG_ADVANCED_OPTIONS is not set
-
-#
-# Default settings for advanced configuration options are used
-#
-CONFIG_HIGHMEM_START=0xfe000000
-CONFIG_LOWMEM_SIZE=0x30000000
-CONFIG_KERNEL_START=0xc0000000
-CONFIG_TASK_SIZE=0x80000000
-CONFIG_BOOT_LOAD=0x00400000
-
-#
-# Generic Driver Options
-#
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-CONFIG_MTD_PARTITIONS=y
-# CONFIG_MTD_CONCAT is not set
-# CONFIG_MTD_REDBOOT_PARTS is not set
-# CONFIG_MTD_CMDLINE_PARTS is not set
-
-#
-# User Modules And Translation Layers
-#
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-# CONFIG_INFTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-CONFIG_MTD_CFI=y
-CONFIG_MTD_JEDECPROBE=y
-CONFIG_MTD_GEN_PROBE=y
-# CONFIG_MTD_CFI_ADV_OPTIONS is not set
-# CONFIG_MTD_CFI_INTELEXT is not set
-CONFIG_MTD_CFI_AMDSTD=y
-# CONFIG_MTD_CFI_STAA is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_OBSOLETE_CHIPS is not set
-
-#
-# Mapping drivers for chip access
-#
-# CONFIG_MTD_COMPLEX_MAPPINGS is not set
-# CONFIG_MTD_PHYSMAP is not set
-CONFIG_MTD_BEECH=y
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD is not set
-
-#
-# Disk-On-Chip Device Drivers
-#
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOC2001PLUS is not set
-
-#
-# NAND Flash Device Drivers
-#
-# CONFIG_MTD_NAND is not set
-
-#
-# Plug and Play support
-#
-# CONFIG_PNP is not set
-
-#
-# Block devices
-#
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_INITRD=y
-# CONFIG_LBD is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# I2O device support
-#
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-# CONFIG_PACKET is not set
-# CONFIG_NETLINK_DEV is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-# CONFIG_IP_PNP_DHCP is not set
-CONFIG_IP_PNP_BOOTP=y
-CONFIG_IP_PNP_RARP=y
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_IP_MROUTE is not set
-# CONFIG_ARPD is not set
-# CONFIG_INET_ECN is not set
-CONFIG_SYN_COOKIES=y
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_IPV6 is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-CONFIG_IPV6_SCTP__=y
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_MII is not set
-# CONFIG_OAKNET is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_SHAPER is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN_BOOL is not set
-
-#
-# Graphics support
-#
-CONFIG_FB=y
-# CONFIG_FB_CT65550 is not set
-# CONFIG_FB_S3TRIO is not set
-# CONFIG_FB_VGA16 is not set
-# CONFIG_FB_VIRTUAL is not set
-
-#
-# Logo configuration
-#
-# CONFIG_LOGO is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-# CONFIG_INPUT_MOUSEDEV is not set
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-# CONFIG_SERIO_I8042 is not set
-# CONFIG_SERIO_SERPORT is not set
-# CONFIG_SERIO_CT82C710 is not set
-
-#
-# Input Device Drivers
-#
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Macintosh device drivers
-#
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_SERIAL_8250_NR_UARTS=4
-# CONFIG_SERIAL_8250_EXTENDED is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=256
-
-#
-# I2C support
-#
-CONFIG_I2C=y
-# CONFIG_I2C_CHARDEV is not set
-
-#
-# I2C Algorithms
-#
-# CONFIG_I2C_ALGOBIT is not set
-# CONFIG_I2C_ALGOPCF is not set
-
-#
-# I2C Hardware Bus support
-#
-# CONFIG_I2C_AMD756 is not set
-# CONFIG_I2C_AMD8111 is not set
-CONFIG_I2C_IBM_IIC=y
-
-#
-# I2C Hardware Sensors Chip support
-#
-# CONFIG_I2C_SENSOR is not set
-# CONFIG_SENSORS_ADM1021 is not set
-# CONFIG_SENSORS_EEPROM is not set
-# CONFIG_SENSORS_IT87 is not set
-# CONFIG_SENSORS_LM75 is not set
-# CONFIG_SENSORS_LM78 is not set
-# CONFIG_SENSORS_LM85 is not set
-# CONFIG_SENSORS_VIA686A is not set
-# CONFIG_SENSORS_W83781D is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_NVRAM is not set
-CONFIG_GEN_RTC=y
-# CONFIG_GEN_RTC_X is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-CONFIG_DEVFS_FS=y
-# CONFIG_DEVFS_MOUNT is not set
-# CONFIG_DEVFS_DEBUG is not set
-CONFIG_DEVPTS_FS=y
-# CONFIG_DEVPTS_FS_XATTR is not set
-CONFIG_TMPFS=y
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_JFFS_FS is not set
-# CONFIG_JFFS2_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-# CONFIG_EXPORTFS is not set
-CONFIG_SUNRPC=y
-# CONFIG_SUNRPC_GSS is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-
-#
-# Sound
-#
-CONFIG_SOUND=y
-
-#
-# Advanced Linux Sound Architecture
-#
-# CONFIG_SND is not set
-
-#
-# Open Sound System
-#
-# CONFIG_SOUND_PRIME is not set
-
-#
-# IBM 40x options
-#
-
-#
-# USB support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# Library routines
-#
-# CONFIG_CRC32 is not set
-
-#
-# Kernel hacking
-#
-# CONFIG_DEBUG_KERNEL is not set
-# CONFIG_SERIAL_TEXT_DEBUG is not set
-CONFIG_OCP=y
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
diff --git a/arch/ppc/configs/cedar_defconfig b/arch/ppc/configs/cedar_defconfig
deleted file mode 100644 (file)
index 5de8288..0000000
+++ /dev/null
@@ -1,534 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MMU=y
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
-CONFIG_HAVE_DEC_LOCK=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_LOG_BUF_SHIFT=14
-CONFIG_EMBEDDED=y
-CONFIG_FUTEX=y
-# CONFIG_EPOLL is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-# CONFIG_MODVERSIONS is not set
-CONFIG_KMOD=y
-
-#
-# Platform support
-#
-CONFIG_PPC=y
-CONFIG_PPC32=y
-# CONFIG_6xx is not set
-CONFIG_40x=y
-# CONFIG_POWER3 is not set
-# CONFIG_8xx is not set
-CONFIG_4xx=y
-
-#
-# IBM 4xx options
-#
-# CONFIG_ASH is not set
-# CONFIG_BEECH is not set
-CONFIG_CEDAR=y
-# CONFIG_CPCI405 is not set
-# CONFIG_EP405 is not set
-# CONFIG_OAK is not set
-# CONFIG_REDWOOD_4 is not set
-# CONFIG_REDWOOD_5 is not set
-# CONFIG_REDWOOD_6 is not set
-# CONFIG_SYCAMORE is not set
-# CONFIG_TIVO is not set
-# CONFIG_WALNUT is not set
-CONFIG_IBM405_ERR77=y
-CONFIG_IBM405_ERR51=y
-CONFIG_IBM_OCP=y
-CONFIG_NP405L=y
-CONFIG_BIOS_FIXUP=y
-CONFIG_IBM_OPENBIOS=y
-# CONFIG_405_DMA is not set
-# CONFIG_PM is not set
-CONFIG_UART0_TTYS0=y
-# CONFIG_UART0_TTYS1 is not set
-CONFIG_NOT_COHERENT_CACHE=y
-# CONFIG_SMP is not set
-# CONFIG_PREEMPT is not set
-# CONFIG_MATH_EMULATION is not set
-# CONFIG_CPU_FREQ is not set
-
-#
-# General setup
-#
-# CONFIG_HIGHMEM is not set
-# CONFIG_PCI is not set
-# CONFIG_PCI_DOMAINS is not set
-# CONFIG_PC_KEYBOARD is not set
-CONFIG_KCORE_ELF=y
-CONFIG_BINFMT_ELF=y
-CONFIG_KERNEL_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_HOTPLUG is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-# CONFIG_CMDLINE_BOOL is not set
-
-#
-# Advanced setup
-#
-# CONFIG_ADVANCED_OPTIONS is not set
-
-#
-# Default settings for advanced configuration options are used
-#
-CONFIG_HIGHMEM_START=0xfe000000
-CONFIG_LOWMEM_SIZE=0x30000000
-CONFIG_KERNEL_START=0xc0000000
-CONFIG_TASK_SIZE=0x80000000
-CONFIG_BOOT_LOAD=0x00400000
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Plug and Play support
-#
-# CONFIG_PNP is not set
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_NBD is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_INITRD=y
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI support
-#
-# CONFIG_SCSI is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# I2O device support
-#
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-# CONFIG_PACKET is not set
-# CONFIG_NETLINK_DEV is not set
-# CONFIG_NETFILTER is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-CONFIG_IP_PNP_BOOTP=y
-CONFIG_IP_PNP_RARP=y
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_IP_MROUTE is not set
-# CONFIG_ARPD is not set
-# CONFIG_INET_ECN is not set
-CONFIG_SYN_COOKIES=y
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_IPV6 is not set
-# CONFIG_XFRM_USER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-CONFIG_IPV6_SCTP__=y
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_LLC is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-# CONFIG_NET_ETHERNET is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Token Ring devices (depends on LLC=y)
-#
-# CONFIG_SHAPER is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN_BOOL is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Old CD-ROM drivers (not SCSI, not IDE)
-#
-# CONFIG_CD_NO_IDESCSI is not set
-
-#
-# Input device support
-#
-# CONFIG_INPUT is not set
-
-#
-# Userland interfaces
-#
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-# CONFIG_SERIO is not set
-
-#
-# Input Device Drivers
-#
-
-#
-# Macintosh device drivers
-#
-
-#
-# Character devices
-#
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_EXTENDED is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=256
-
-#
-# I2C support
-#
-CONFIG_I2C=y
-# CONFIG_I2C_ALGOBIT is not set
-# CONFIG_I2C_ALGOPCF is not set
-CONFIG_I2C_IBM_OCP_ALGO=y
-CONFIG_I2C_IBM_OCP_ADAP=y
-# CONFIG_I2C_CHARDEV is not set
-
-#
-# I2C Hardware Sensors Mainboard support
-#
-# CONFIG_I2C_AMD756 is not set
-# CONFIG_I2C_AMD8111 is not set
-
-#
-# I2C Hardware Sensors Chip support
-#
-# CONFIG_SENSORS_ADM1021 is not set
-# CONFIG_SENSORS_IT87 is not set
-# CONFIG_SENSORS_LM75 is not set
-# CONFIG_SENSORS_LM85 is not set
-# CONFIG_SENSORS_VIA686A is not set
-# CONFIG_SENSORS_W83781D is not set
-# CONFIG_I2C_SENSOR is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-CONFIG_WATCHDOG=y
-# CONFIG_WATCHDOG_NOWAYOUT is not set
-# CONFIG_SOFT_WATCHDOG is not set
-# CONFIG_WDT is not set
-# CONFIG_WDTPCI is not set
-# CONFIG_PCWATCHDOG is not set
-# CONFIG_ACQUIRE_WDT is not set
-# CONFIG_ADVANTECH_WDT is not set
-# CONFIG_EUROTECH_WDT is not set
-# CONFIG_IB700_WDT is not set
-# CONFIG_MIXCOMWD is not set
-# CONFIG_SCx200_WDT is not set
-# CONFIG_60XX_WDT is not set
-# CONFIG_W83877F_WDT is not set
-# CONFIG_MACHZ_WDT is not set
-# CONFIG_SC520_WDT is not set
-# CONFIG_AMD7XX_TCO is not set
-# CONFIG_ALIM7101_WDT is not set
-# CONFIG_SC1200_WDT is not set
-# CONFIG_WAFER_WDT is not set
-# CONFIG_CPU5_WDT is not set
-# CONFIG_NVRAM is not set
-# CONFIG_GEN_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-# CONFIG_HANGCHECK_TIMER is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-# CONFIG_DEVFS_FS is not set
-CONFIG_DEVPTS_FS=y
-# CONFIG_DEVPTS_FS_XATTR is not set
-CONFIG_TMPFS=y
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-# CONFIG_EXPORTFS is not set
-CONFIG_SUNRPC=y
-# CONFIG_SUNRPC_GSS is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-CONFIG_PARTITION_ADVANCED=y
-# CONFIG_ACORN_PARTITION is not set
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ATARI_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
-# CONFIG_MSDOS_PARTITION is not set
-# CONFIG_LDM_PARTITION is not set
-# CONFIG_NEC98_PARTITION is not set
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# IBM 40x options
-#
-
-#
-# USB support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# Library routines
-#
-CONFIG_CRC32=y
-
-#
-# Kernel hacking
-#
-# CONFIG_DEBUG_KERNEL is not set
-# CONFIG_KALLSYMS is not set
-# CONFIG_SERIAL_TEXT_DEBUG is not set
-CONFIG_OCP=y
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
index 53948793d9af5e0f95a730e5c3026b7ba02491ab..ff3f7e02ab0fb6fb35aec0084944c385a236e87b 100644 (file)
@@ -1,15 +1,17 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.10-rc2
-# Fri Dec  3 15:56:10 2004
+# Linux kernel version: 2.6.13-mm1
+# Thu Sep  1 17:10:37 2005
 #
 CONFIG_MMU=y
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_PPC=y
 CONFIG_PPC32=y
 CONFIG_GENERIC_NVRAM=y
+CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
 
 #
 # Code maturity level options
@@ -17,33 +19,38 @@ CONFIG_GENERIC_NVRAM=y
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
 CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
 
 #
 # General setup
 #
 CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
 # CONFIG_SWAP is not set
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
 # CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
 CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_EMBEDDED is not set
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_BASE_FULL=y
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SHMEM=y
 CONFIG_CC_ALIGN_FUNCTIONS=0
 CONFIG_CC_ALIGN_LABELS=0
 CONFIG_CC_ALIGN_LOOPS=0
 CONFIG_CC_ALIGN_JUMPS=0
 # CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
 
 #
 # Loadable module support
@@ -65,38 +72,42 @@ CONFIG_6xx=y
 # CONFIG_POWER3 is not set
 # CONFIG_POWER4 is not set
 # CONFIG_8xx is not set
+# CONFIG_E200 is not set
 # CONFIG_E500 is not set
+CONFIG_PPC_FPU=y
 CONFIG_ALTIVEC=y
 # CONFIG_TAU is not set
+# CONFIG_KEXEC is not set
 # CONFIG_CPU_FREQ is not set
+# CONFIG_WANT_EARLY_SERIAL is not set
 CONFIG_PPC_STD_MMU=y
 # CONFIG_NOT_COHERENT_CACHE is not set
 
+#
+# Performance-monitoring counters support
+#
+# CONFIG_PERFCTR is not set
+
 #
 # Platform options
 #
 # CONFIG_PPC_MULTIPLATFORM is not set
 # CONFIG_APUS is not set
 # CONFIG_KATANA is not set
-# CONFIG_DMV182 is not set
 # CONFIG_WILLOW is not set
 CONFIG_CPCI690=y
-# CONFIG_PCORE is not set
 # CONFIG_POWERPMC250 is not set
-# CONFIG_EV64260 is not set
-# CONFIG_DB64360 is not set
 # CONFIG_CHESTNUT is not set
 # CONFIG_SPRUCE is not set
+# CONFIG_HDPU is not set
+# CONFIG_EV64260 is not set
 # CONFIG_LOPEC is not set
-# CONFIG_MCPN765 is not set
 # CONFIG_MVME5100 is not set
 # CONFIG_PPLUS is not set
 # CONFIG_PRPMC750 is not set
 # CONFIG_PRPMC800 is not set
-# CONFIG_PRPMC880 is not set
 # CONFIG_SANDPOINT is not set
-# CONFIG_ADIR is not set
-# CONFIG_K2 is not set
+# CONFIG_RADSTONE_PPC7D is not set
 # CONFIG_PAL4 is not set
 # CONFIG_GEMINI is not set
 # CONFIG_EST8260 is not set
@@ -105,22 +116,41 @@ CONFIG_CPCI690=y
 # CONFIG_RPX8260 is not set
 # CONFIG_TQM8260 is not set
 # CONFIG_ADS8272 is not set
+# CONFIG_PQ2FADS is not set
 # CONFIG_LITE5200 is not set
+# CONFIG_MPC834x_SYS is not set
+# CONFIG_EV64360 is not set
+CONFIG_GT64260=y
+CONFIG_MV64X60=y
 
 #
 # Set bridge options
 #
 CONFIG_MV64X60_BASE=0xf1000000
 CONFIG_MV64X60_NEW_BASE=0xf1000000
-CONFIG_GT64260=y
-CONFIG_MV64X60=y
 # CONFIG_SMP is not set
+CONFIG_HIGHMEM=y
+CONFIG_HZ_100=y
+# CONFIG_HZ_250 is not set
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=100
+CONFIG_PREEMPT_NONE=y
+# CONFIG_PREEMPT_VOLUNTARY is not set
 # CONFIG_PREEMPT is not set
-# CONFIG_HIGHMEM is not set
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+# CONFIG_SPARSEMEM_STATIC is not set
 CONFIG_BINFMT_ELF=y
 CONFIG_BINFMT_MISC=y
 CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="console=ttyMM0,9600 ip=on"
+CONFIG_CMDLINE="console=ttyMM0 ip=on"
+# CONFIG_PM is not set
+CONFIG_SECCOMP=y
+CONFIG_ISA_DMA_API=y
 
 #
 # Bus options
@@ -129,7 +159,11 @@ CONFIG_GENERIC_ISA_DMA=y
 CONFIG_PCI=y
 CONFIG_PCI_DOMAINS=y
 CONFIG_PCI_LEGACY_PROC=y
-CONFIG_PCI_NAMES=y
+
+#
+# PCCARD (PCMCIA/CardBus) support
+#
+# CONFIG_PCCARD is not set
 
 #
 # Advanced setup
@@ -145,6 +179,76 @@ CONFIG_KERNEL_START=0xc0000000
 CONFIG_TASK_SIZE=0x80000000
 CONFIG_BOOT_LOAD=0x00800000
 
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_IP_MROUTE is not set
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_BIC=y
+# CONFIG_IPV6 is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NETFILTER_NETLINK is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_IEEE80211 is not set
+
 #
 # Device Drivers
 #
@@ -154,6 +258,7 @@ CONFIG_BOOT_LOAD=0x00800000
 #
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_FW_LOADER is not set
 
 #
 # Memory Technology Devices (MTD)
@@ -177,6 +282,7 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_BLK_CPQ_CISS_DA is not set
 # CONFIG_BLK_DEV_DAC960 is not set
 # CONFIG_BLK_DEV_UMEM is not set
+# CONFIG_BLK_DEV_COW_COMMON is not set
 CONFIG_BLK_DEV_LOOP=y
 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
@@ -185,7 +291,6 @@ CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=4096
 CONFIG_BLK_DEV_INITRD=y
-CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
 # CONFIG_CDROM_PKTCDVD is not set
 
@@ -196,6 +301,7 @@ CONFIG_IOSCHED_NOOP=y
 CONFIG_IOSCHED_AS=y
 CONFIG_IOSCHED_DEADLINE=y
 CONFIG_IOSCHED_CFQ=y
+# CONFIG_ATA_OVER_ETH is not set
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -205,6 +311,7 @@ CONFIG_IOSCHED_CFQ=y
 #
 # SCSI device support
 #
+# CONFIG_RAID_ATTRS is not set
 # CONFIG_SCSI is not set
 
 #
@@ -215,6 +322,7 @@ CONFIG_IOSCHED_CFQ=y
 #
 # Fusion MPT device support
 #
+# CONFIG_FUSION is not set
 
 #
 # IEEE 1394 (FireWire) support
@@ -231,71 +339,8 @@ CONFIG_IOSCHED_CFQ=y
 #
 
 #
-# Networking support
+# Network device support
 #
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK_DEV is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_IP_MROUTE is not set
-# CONFIG_ARPD is not set
-CONFIG_SYN_COOKIES=y
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_TUNNEL is not set
-CONFIG_IP_TCPDIAG=y
-# CONFIG_IP_TCPDIAG_IPV6 is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
@@ -307,6 +352,11 @@ CONFIG_NETDEVICES=y
 #
 # CONFIG_ARCNET is not set
 
+#
+# PHY device support
+#
+# CONFIG_PHYLIB is not set
+
 #
 # Ethernet (10 or 100Mbit)
 #
@@ -328,6 +378,7 @@ CONFIG_TULIP=y
 # CONFIG_DE4X5 is not set
 # CONFIG_WINBOND_840 is not set
 # CONFIG_DM9102 is not set
+# CONFIG_ULI526X is not set
 # CONFIG_HP100 is not set
 CONFIG_NET_PCI=y
 # CONFIG_PCNET32 is not set
@@ -337,7 +388,6 @@ CONFIG_NET_PCI=y
 # CONFIG_FORCEDETH is not set
 # CONFIG_DGRS is not set
 CONFIG_EEPRO100=y
-# CONFIG_EEPRO100_PIO is not set
 # CONFIG_E100 is not set
 # CONFIG_FEALNX is not set
 # CONFIG_NATSEMI is not set
@@ -360,13 +410,18 @@ CONFIG_EEPRO100=y
 # CONFIG_HAMACHI is not set
 # CONFIG_YELLOWFIN is not set
 # CONFIG_R8169 is not set
+# CONFIG_SIS190 is not set
+# CONFIG_SKGE is not set
+# CONFIG_SKY2 is not set
 # CONFIG_SK98LIN is not set
 # CONFIG_VIA_VELOCITY is not set
 # CONFIG_TIGON3 is not set
+# CONFIG_BNX2 is not set
 
 #
 # Ethernet (10000 Mbit)
 #
+# CONFIG_CHELSIO_T1 is not set
 # CONFIG_IXGB is not set
 # CONFIG_S2IO is not set
 
@@ -390,6 +445,11 @@ CONFIG_EEPRO100=y
 # CONFIG_SLIP is not set
 # CONFIG_SHAPER is not set
 # CONFIG_NETCONSOLE is not set
+# CONFIG_KGDBOE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NETPOLL_RX is not set
+# CONFIG_NETPOLL_TRAP is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
 
 #
 # ISDN subsystem
@@ -418,14 +478,6 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
 # CONFIG_INPUT_EVDEV is not set
 # CONFIG_INPUT_EVBUG is not set
 
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-# CONFIG_SERIO is not set
-# CONFIG_SERIO_I8042 is not set
-
 #
 # Input Device Drivers
 #
@@ -435,6 +487,12 @@ CONFIG_SOUND_GAMEPORT=y
 # CONFIG_INPUT_TOUCHSCREEN is not set
 # CONFIG_INPUT_MISC is not set
 
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
 #
 # Character devices
 #
@@ -455,6 +513,7 @@ CONFIG_SERIAL_MPSC=y
 CONFIG_SERIAL_MPSC_CONSOLE=y
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
+# CONFIG_SERIAL_JSM is not set
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
@@ -482,6 +541,11 @@ CONFIG_GEN_RTC=y
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
 
+#
+# TPM devices
+#
+# CONFIG_TCG_TPM is not set
+
 #
 # I2C support
 #
@@ -492,10 +556,21 @@ CONFIG_GEN_RTC=y
 #
 # CONFIG_W1 is not set
 
+#
+# Hardware Monitoring support
+#
+CONFIG_HWMON=y
+# CONFIG_HWMON_VID is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
+
 #
 # Misc devices
 #
 
+#
+# Multimedia Capabilities Port drivers
+#
+
 #
 # Multimedia devices
 #
@@ -517,6 +592,11 @@ CONFIG_GEN_RTC=y
 # CONFIG_VGA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
+#
+# Speakup console speech
+#
+# CONFIG_SPEAKUP is not set
+
 #
 # Sound
 #
@@ -525,35 +605,59 @@ CONFIG_DUMMY_CONSOLE=y
 #
 # USB support
 #
-# CONFIG_USB is not set
 CONFIG_USB_ARCH_HAS_HCD=y
 CONFIG_USB_ARCH_HAS_OHCI=y
+# CONFIG_USB is not set
 
 #
-# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+# USB Gadget Support
 #
+# CONFIG_USB_GADGET is not set
 
 #
-# USB Gadget Support
+# MMC/SD Card support
 #
-# CONFIG_USB_GADGET is not set
+# CONFIG_MMC is not set
+
+#
+# InfiniBand support
+#
+# CONFIG_INFINIBAND is not set
+
+#
+# SN Devices
+#
+
+#
+# Distributed Lock Manager
+#
+# CONFIG_DLM is not set
 
 #
 # File systems
 #
 CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
 # CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
+# CONFIG_REISER4_FS is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+
+#
+# XFS support
+#
 # CONFIG_XFS_FS is not set
+# CONFIG_OCFS2_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
 # CONFIG_QUOTA is not set
 CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
 
 #
 # CD-ROM/DVD Filesystems
@@ -574,20 +678,18 @@ CONFIG_DNOTIFY=y
 CONFIG_PROC_FS=y
 CONFIG_PROC_KCORE=y
 CONFIG_SYSFS=y
-CONFIG_DEVFS_FS=y
-# CONFIG_DEVFS_MOUNT is not set
-# CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
-# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
+# CONFIG_CONFIGFS_FS is not set
+# CONFIG_RELAYFS_FS is not set
 
 #
 # Miscellaneous filesystems
 #
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
+# CONFIG_ASFS_FS is not set
 # CONFIG_HFS_FS is not set
 # CONFIG_HFSPLUS_FS is not set
 # CONFIG_BEFS_FS is not set
@@ -605,13 +707,14 @@ CONFIG_RAMFS=y
 #
 CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
 CONFIG_NFS_V4=y
 # CONFIG_NFS_DIRECTIO is not set
 # CONFIG_NFSD is not set
 CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
-# CONFIG_EXPORTFS is not set
+CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
 CONFIG_SUNRPC_GSS=y
 CONFIG_RPCSEC_GSS_KRB5=y
@@ -621,6 +724,7 @@ CONFIG_RPCSEC_GSS_KRB5=y
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
 
 #
 # Partition Types
@@ -637,6 +741,7 @@ CONFIG_MSDOS_PARTITION=y
 # Library routines
 #
 # CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
 CONFIG_CRC32=y
 # CONFIG_LIBCRC32C is not set
 
@@ -648,7 +753,9 @@ CONFIG_CRC32=y
 #
 # Kernel hacking
 #
+# CONFIG_PRINTK_TIME is not set
 # CONFIG_DEBUG_KERNEL is not set
+CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_SERIAL_TEXT_DEBUG is not set
 
 #
@@ -669,6 +776,7 @@ CONFIG_CRYPTO_MD5=y
 # CONFIG_CRYPTO_SHA256 is not set
 # CONFIG_CRYPTO_SHA512 is not set
 # CONFIG_CRYPTO_WP512 is not set
+# CONFIG_CRYPTO_TGR192 is not set
 CONFIG_CRYPTO_DES=y
 # CONFIG_CRYPTO_BLOWFISH is not set
 # CONFIG_CRYPTO_TWOFISH is not set
@@ -684,3 +792,7 @@ CONFIG_CRYPTO_DES=y
 # CONFIG_CRYPTO_MICHAEL_MIC is not set
 # CONFIG_CRYPTO_CRC32C is not set
 # CONFIG_CRYPTO_TEST is not set
+
+#
+# Hardware crypto devices
+#
similarity index 53%
rename from arch/ppc/configs/k2_defconfig
rename to arch/ppc/configs/ev64360_defconfig
index f10f5a6d2dae18e58621b9fe39c4deb22c7a8001..de9bbb791db98f3abac6706fd938f7b3a17d25ae 100644 (file)
@@ -1,52 +1,60 @@
 #
 # Automatically generated make config: don't edit
+# Linux kernel version: 2.6.13-rc5
+# Fri Aug  5 15:18:23 2005
 #
 CONFIG_MMU=y
+CONFIG_GENERIC_HARDIRQS=y
 CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_HAVE_DEC_LOCK=y
 CONFIG_PPC=y
 CONFIG_PPC32=y
 CONFIG_GENERIC_NVRAM=y
+CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
 CONFIG_BROKEN_ON_SMP=y
+CONFIG_LOCK_KERNEL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
 
 #
 # General setup
 #
+CONFIG_LOCALVERSION=""
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
-# CONFIG_POSIX_MQUEUE is not set
+CONFIG_POSIX_MQUEUE=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
 # CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_HOTPLUG is not set
+CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
-CONFIG_EMBEDDED=y
+# CONFIG_EMBEDDED is not set
 CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_BASE_FULL=y
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
 
 #
 # Loadable module support
 #
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-# CONFIG_MODVERSIONS is not set
-CONFIG_KMOD=y
+# CONFIG_MODULES is not set
 
 #
 # Processor
@@ -57,21 +65,33 @@ CONFIG_6xx=y
 # CONFIG_POWER3 is not set
 # CONFIG_POWER4 is not set
 # CONFIG_8xx is not set
-# CONFIG_ALTIVEC is not set
-# CONFIG_TAU is not set
+# CONFIG_E200 is not set
+# CONFIG_E500 is not set
+CONFIG_PPC_FPU=y
+CONFIG_ALTIVEC=y
+CONFIG_TAU=y
+# CONFIG_TAU_INT is not set
+# CONFIG_TAU_AVERAGE is not set
+# CONFIG_KEXEC is not set
 # CONFIG_CPU_FREQ is not set
+# CONFIG_PM is not set
 CONFIG_PPC_STD_MMU=y
+CONFIG_NOT_COHERENT_CACHE=y
 
 #
 # Platform options
 #
 # CONFIG_PPC_MULTIPLATFORM is not set
 # CONFIG_APUS is not set
+# CONFIG_KATANA is not set
 # CONFIG_WILLOW is not set
+# CONFIG_CPCI690 is not set
 # CONFIG_PCORE is not set
 # CONFIG_POWERPMC250 is not set
-# CONFIG_EV64260 is not set
+# CONFIG_CHESTNUT is not set
 # CONFIG_SPRUCE is not set
+# CONFIG_HDPU is not set
+# CONFIG_EV64260 is not set
 # CONFIG_LOPEC is not set
 # CONFIG_MCPN765 is not set
 # CONFIG_MVME5100 is not set
@@ -79,24 +99,51 @@ CONFIG_PPC_STD_MMU=y
 # CONFIG_PRPMC750 is not set
 # CONFIG_PRPMC800 is not set
 # CONFIG_SANDPOINT is not set
+# CONFIG_RADSTONE_PPC7D is not set
 # CONFIG_ADIR is not set
-CONFIG_K2=y
+# CONFIG_K2 is not set
 # CONFIG_PAL4 is not set
 # CONFIG_GEMINI is not set
 # CONFIG_EST8260 is not set
+# CONFIG_SBC82xx is not set
 # CONFIG_SBS8260 is not set
-# CONFIG_RPX6 is not set
+# CONFIG_RPX8260 is not set
 # CONFIG_TQM8260 is not set
-CONFIG_PPC_GEN550=y
-# CONFIG_CPC710_DATA_GATHERING is not set
+# CONFIG_ADS8272 is not set
+# CONFIG_PQ2FADS is not set
+# CONFIG_LITE5200 is not set
+# CONFIG_MPC834x_SYS is not set
+CONFIG_EV64360=y
+CONFIG_MV64360=y
+CONFIG_MV64X60=y
+
+#
+# Set bridge options
+#
+CONFIG_MV64X60_BASE=0xf1000000
+CONFIG_MV64X60_NEW_BASE=0xf1000000
 # CONFIG_SMP is not set
-# CONFIG_PREEMPT is not set
 # CONFIG_HIGHMEM is not set
-CONFIG_KERNEL_ELF=y
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+# CONFIG_PREEMPT_NONE is not set
+# CONFIG_PREEMPT_VOLUNTARY is not set
+CONFIG_PREEMPT=y
+CONFIG_PREEMPT_BKL=y
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
 CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
+CONFIG_BINFMT_MISC=y
 CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="ip=on"
+CONFIG_CMDLINE="console=ttyMM0,115200 root=/dev/mtdblock1 rw rootfstype=jffs2"
+CONFIG_SECCOMP=y
+CONFIG_ISA_DMA_API=y
 
 #
 # Bus options
@@ -108,19 +155,91 @@ CONFIG_PCI_DOMAINS=y
 # CONFIG_PCI_NAMES is not set
 
 #
-# Advanced setup
+# PCCARD (PCMCIA/CardBus) support
 #
-# CONFIG_ADVANCED_OPTIONS is not set
+# CONFIG_PCCARD is not set
 
 #
-# Default settings for advanced configuration options are used
+# Advanced setup
 #
+CONFIG_ADVANCED_OPTIONS=y
 CONFIG_HIGHMEM_START=0xfe000000
+# CONFIG_LOWMEM_SIZE_BOOL is not set
 CONFIG_LOWMEM_SIZE=0x30000000
+# CONFIG_KERNEL_START_BOOL is not set
 CONFIG_KERNEL_START=0xc0000000
+# CONFIG_TASK_SIZE_BOOL is not set
 CONFIG_TASK_SIZE=0x80000000
+# CONFIG_CONSISTENT_START_BOOL is not set
+CONFIG_CONSISTENT_START=0xff100000
+# CONFIG_CONSISTENT_SIZE_BOOL is not set
+CONFIG_CONSISTENT_SIZE=0x00200000
+# CONFIG_BOOT_LOAD_BOOL is not set
 CONFIG_BOOT_LOAD=0x00800000
 
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_IP_MROUTE is not set
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_BIC=y
+# CONFIG_IPV6 is not set
+# CONFIG_NETFILTER is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+
 #
 # Device Drivers
 #
@@ -128,11 +247,90 @@ CONFIG_BOOT_LOAD=0x00800000
 #
 # Generic Driver Options
 #
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_FW_LOADER is not set
 
 #
 # Memory Technology Devices (MTD)
 #
-# CONFIG_MTD is not set
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+CONFIG_MTD_CONCAT=y
+CONFIG_MTD_PARTITIONS=y
+# CONFIG_MTD_REDBOOT_PARTS is not set
+# CONFIG_MTD_CMDLINE_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=y
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_GEN_PROBE=y
+CONFIG_MTD_CFI_ADV_OPTIONS=y
+CONFIG_MTD_CFI_NOSWAP=y
+# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
+# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
+CONFIG_MTD_CFI_GEOMETRY=y
+# CONFIG_MTD_MAP_BANK_WIDTH_1 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_2 is not set
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+# CONFIG_MTD_CFI_I1 is not set
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_OTP is not set
+CONFIG_MTD_CFI_INTELEXT=y
+# CONFIG_MTD_CFI_AMDSTD is not set
+# CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=y
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+CONFIG_MTD_PHYSMAP=y
+CONFIG_MTD_PHYSMAP_START=0xff000000
+CONFIG_MTD_PHYSMAP_LEN=0x01000000
+CONFIG_MTD_PHYSMAP_BANKWIDTH=4
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_PMC551 is not set
+# CONFIG_MTD_SLRAM is not set
+CONFIG_MTD_PHRAM=y
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLKMTD is not set
+# CONFIG_MTD_BLOCK2MTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+
+#
+# NAND Flash Device Drivers
+#
+# CONFIG_MTD_NAND is not set
 
 #
 # Parallel port support
@@ -151,72 +349,32 @@ CONFIG_BOOT_LOAD=0x00800000
 # CONFIG_BLK_CPQ_CISS_DA is not set
 # CONFIG_BLK_DEV_DAC960 is not set
 # CONFIG_BLK_DEV_UMEM is not set
+# CONFIG_BLK_DEV_COW_COMMON is not set
 CONFIG_BLK_DEV_LOOP=y
 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_CARMEL is not set
+# CONFIG_BLK_DEV_SX8 is not set
 CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=32768
 CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_ATA_OVER_ETH is not set
 
 #
 # ATA/ATAPI/MFM/RLL support
 #
-CONFIG_IDE=y
-CONFIG_BLK_DEV_IDE=y
-
-#
-# Please see Documentation/ide.txt for help/info on IDE drives
-#
-CONFIG_BLK_DEV_IDEDISK=y
-# CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_IDEDISK_STROKE is not set
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
-
-#
-# IDE chipset support/bugfixes
-#
-# CONFIG_IDE_GENERIC is not set
-CONFIG_BLK_DEV_IDEPCI=y
-# CONFIG_IDEPCI_SHARE_IRQ is not set
-# CONFIG_BLK_DEV_OFFBOARD is not set
-# CONFIG_BLK_DEV_GENERIC is not set
-# CONFIG_BLK_DEV_OPTI621 is not set
-# CONFIG_BLK_DEV_SL82C105 is not set
-CONFIG_BLK_DEV_IDEDMA_PCI=y
-# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
-# CONFIG_IDEDMA_PCI_AUTO is not set
-CONFIG_BLK_DEV_ADMA=y
-# CONFIG_BLK_DEV_AEC62XX is not set
-CONFIG_BLK_DEV_ALI15X3=y
-# CONFIG_WDC_ALI15X3 is not set
-# CONFIG_BLK_DEV_AMD74XX is not set
-# CONFIG_BLK_DEV_CMD64X is not set
-# CONFIG_BLK_DEV_TRIFLEX is not set
-# CONFIG_BLK_DEV_CY82C693 is not set
-# CONFIG_BLK_DEV_CS5520 is not set
-# CONFIG_BLK_DEV_CS5530 is not set
-# CONFIG_BLK_DEV_HPT34X is not set
-# CONFIG_BLK_DEV_HPT366 is not set
-# CONFIG_BLK_DEV_SC1200 is not set
-# CONFIG_BLK_DEV_PIIX is not set
-# CONFIG_BLK_DEV_NS87415 is not set
-# CONFIG_BLK_DEV_PDC202XX_OLD is not set
-# CONFIG_BLK_DEV_PDC202XX_NEW is not set
-# CONFIG_BLK_DEV_SVWKS is not set
-# CONFIG_BLK_DEV_SIIMAGE is not set
-# CONFIG_BLK_DEV_SLC90E66 is not set
-# CONFIG_BLK_DEV_TRM290 is not set
-# CONFIG_BLK_DEV_VIA82CXXX is not set
-CONFIG_BLK_DEV_IDEDMA=y
-# CONFIG_IDEDMA_IVB is not set
-# CONFIG_IDEDMA_AUTO is not set
-# CONFIG_BLK_DEV_HD is not set
+# CONFIG_IDE is not set
 
 #
 # SCSI device support
@@ -248,122 +406,8 @@ CONFIG_BLK_DEV_IDEDMA=y
 #
 
 #
-# Networking support
-#
-CONFIG_NET=y
-
+# Network device support
 #
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK_DEV is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-
-#
-# IP: Virtual Server Configuration
-#
-# CONFIG_IP_VS is not set
-# CONFIG_IPV6 is not set
-CONFIG_NETFILTER=y
-# CONFIG_NETFILTER_DEBUG is not set
-
-#
-# IP: Netfilter Configuration
-#
-CONFIG_IP_NF_CONNTRACK=m
-CONFIG_IP_NF_FTP=m
-# CONFIG_IP_NF_IRC is not set
-# CONFIG_IP_NF_TFTP is not set
-# CONFIG_IP_NF_AMANDA is not set
-# CONFIG_IP_NF_QUEUE is not set
-CONFIG_IP_NF_IPTABLES=m
-CONFIG_IP_NF_MATCH_LIMIT=m
-# CONFIG_IP_NF_MATCH_IPRANGE is not set
-CONFIG_IP_NF_MATCH_MAC=m
-CONFIG_IP_NF_MATCH_PKTTYPE=m
-CONFIG_IP_NF_MATCH_MARK=m
-CONFIG_IP_NF_MATCH_MULTIPORT=m
-CONFIG_IP_NF_MATCH_TOS=m
-# CONFIG_IP_NF_MATCH_RECENT is not set
-CONFIG_IP_NF_MATCH_ECN=m
-CONFIG_IP_NF_MATCH_DSCP=m
-CONFIG_IP_NF_MATCH_AH_ESP=m
-# CONFIG_IP_NF_MATCH_LENGTH is not set
-# CONFIG_IP_NF_MATCH_TTL is not set
-CONFIG_IP_NF_MATCH_TCPMSS=m
-CONFIG_IP_NF_MATCH_HELPER=m
-CONFIG_IP_NF_MATCH_STATE=m
-CONFIG_IP_NF_MATCH_CONNTRACK=m
-CONFIG_IP_NF_MATCH_OWNER=m
-CONFIG_IP_NF_FILTER=m
-CONFIG_IP_NF_TARGET_REJECT=m
-CONFIG_IP_NF_NAT=m
-CONFIG_IP_NF_NAT_NEEDED=y
-CONFIG_IP_NF_TARGET_MASQUERADE=m
-CONFIG_IP_NF_TARGET_REDIRECT=m
-# CONFIG_IP_NF_TARGET_NETMAP is not set
-# CONFIG_IP_NF_TARGET_SAME is not set
-# CONFIG_IP_NF_NAT_SNMP_BASIC is not set
-CONFIG_IP_NF_NAT_FTP=m
-# CONFIG_IP_NF_MANGLE is not set
-# CONFIG_IP_NF_TARGET_LOG is not set
-CONFIG_IP_NF_TARGET_ULOG=m
-CONFIG_IP_NF_TARGET_TCPMSS=m
-CONFIG_IP_NF_ARPTABLES=m
-CONFIG_IP_NF_ARPFILTER=m
-# CONFIG_IP_NF_ARP_MANGLE is not set
-CONFIG_IP_NF_COMPAT_IPCHAINS=m
-# CONFIG_IP_NF_COMPAT_IPFWADM is not set
-# CONFIG_IP_NF_RAW is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
@@ -378,38 +422,7 @@ CONFIG_NETDEVICES=y
 #
 # Ethernet (10 or 100Mbit)
 #
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
-# CONFIG_OAKNET is not set
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_NET_VENDOR_3COM is not set
-
-#
-# Tulip family network device support
-#
-# CONFIG_NET_TULIP is not set
-# CONFIG_HP100 is not set
-CONFIG_NET_PCI=y
-# CONFIG_PCNET32 is not set
-# CONFIG_AMD8111_ETH is not set
-# CONFIG_ADAPTEC_STARFIRE is not set
-# CONFIG_B44 is not set
-# CONFIG_FORCEDETH is not set
-# CONFIG_DGRS is not set
-CONFIG_EEPRO100=y
-# CONFIG_EEPRO100_PIO is not set
-# CONFIG_E100 is not set
-# CONFIG_FEALNX is not set
-# CONFIG_NATSEMI is not set
-# CONFIG_NE2K_PCI is not set
-# CONFIG_8139CP is not set
-# CONFIG_8139TOO is not set
-# CONFIG_SIS900 is not set
-# CONFIG_EPIC100 is not set
-# CONFIG_SUNDANCE is not set
-# CONFIG_TLAN is not set
-# CONFIG_VIA_RHINE is not set
+# CONFIG_NET_ETHERNET is not set
 
 #
 # Ethernet (1000 Mbit)
@@ -421,8 +434,14 @@ CONFIG_EEPRO100=y
 # CONFIG_HAMACHI is not set
 # CONFIG_YELLOWFIN is not set
 # CONFIG_R8169 is not set
+# CONFIG_SKGE is not set
 # CONFIG_SK98LIN is not set
 # CONFIG_TIGON3 is not set
+# CONFIG_BNX2 is not set
+CONFIG_MV643XX_ETH=y
+CONFIG_MV643XX_ETH_0=y
+# CONFIG_MV643XX_ETH_1 is not set
+# CONFIG_MV643XX_ETH_2 is not set
 
 #
 # Ethernet (10000 Mbit)
@@ -448,9 +467,10 @@ CONFIG_EEPRO100=y
 # CONFIG_HIPPI is not set
 # CONFIG_PPP is not set
 # CONFIG_SLIP is not set
-# CONFIG_RCPCI is not set
 # CONFIG_SHAPER is not set
 # CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
 
 #
 # ISDN subsystem
@@ -465,47 +485,59 @@ CONFIG_EEPRO100=y
 #
 # Input device support
 #
-# CONFIG_INPUT is not set
+CONFIG_INPUT=y
 
 #
 # Userland interfaces
 #
+CONFIG_INPUT_MOUSEDEV=y
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
 
 #
-# Input I/O drivers
+# Input Device Drivers
 #
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-# CONFIG_SERIO is not set
-# CONFIG_SERIO_I8042 is not set
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
 
 #
-# Input Device Drivers
+# Hardware I/O ports
 #
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
 
 #
 # Character devices
 #
-# CONFIG_VT is not set
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
 # CONFIG_SERIAL_NONSTANDARD is not set
 
 #
 # Serial drivers
 #
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_SERIAL_8250_NR_UARTS=2
-# CONFIG_SERIAL_8250_EXTENDED is not set
+# CONFIG_SERIAL_8250 is not set
 
 #
 # Non-8250 serial port support
 #
+CONFIG_SERIAL_MPSC=y
+CONFIG_SERIAL_MPSC_CONSOLE=y
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
+# CONFIG_SERIAL_JSM is not set
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
 
 #
 # IPMI
@@ -526,15 +558,31 @@ CONFIG_GEN_RTC=y
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
 
+#
+# TPM devices
+#
+# CONFIG_TCG_TPM is not set
+
 #
 # I2C support
 #
 # CONFIG_I2C is not set
+# CONFIG_I2C_SENSOR is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Hardware Monitoring support
+#
+CONFIG_HWMON=y
+# CONFIG_HWMON_DEBUG_CHIP is not set
 
 #
 # Misc devices
@@ -555,6 +603,12 @@ CONFIG_GEN_RTC=y
 #
 # CONFIG_FB is not set
 
+#
+# Console display driver support
+#
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+
 #
 # Sound
 #
@@ -563,6 +617,8 @@ CONFIG_GEN_RTC=y
 #
 # USB support
 #
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
 # CONFIG_USB is not set
 
 #
@@ -570,19 +626,41 @@ CONFIG_GEN_RTC=y
 #
 # CONFIG_USB_GADGET is not set
 
+#
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
+
+#
+# InfiniBand support
+#
+# CONFIG_INFINIBAND is not set
+
+#
+# SN Devices
+#
+
 #
 # File systems
 #
 CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
 # CONFIG_EXT3_FS is not set
 # CONFIG_JBD is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+
+#
+# XFS support
+#
 # CONFIG_XFS_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
 # CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 
@@ -595,7 +673,8 @@ CONFIG_EXT2_FS=y
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
 # CONFIG_NTFS_FS is not set
 
 #
@@ -604,9 +683,9 @@ CONFIG_EXT2_FS=y
 CONFIG_PROC_FS=y
 CONFIG_PROC_KCORE=y
 CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -620,6 +699,14 @@ CONFIG_RAMFS=y
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+CONFIG_JFFS2_FS=y
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
+CONFIG_JFFS2_ZLIB=y
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
 # CONFIG_CRAMFS is not set
 # CONFIG_VXFS_FS is not set
 # CONFIG_HPFS_FS is not set
@@ -631,20 +718,22 @@ CONFIG_RAMFS=y
 # Network File Systems
 #
 CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
 # CONFIG_NFS_V4 is not set
 # CONFIG_NFS_DIRECTIO is not set
 # CONFIG_NFSD is not set
 CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
-# CONFIG_EXPORTFS is not set
+CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
 # CONFIG_AFS_FS is not set
 
 #
@@ -661,20 +750,35 @@ CONFIG_MSDOS_PARTITION=y
 #
 # Library routines
 #
-# CONFIG_CRC32 is not set
+# CONFIG_CRC_CCITT is not set
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=y
+
+#
+# Profiling support
+#
+# CONFIG_PROFILING is not set
 
 #
 # Kernel hacking
 #
+# CONFIG_PRINTK_TIME is not set
 # CONFIG_DEBUG_KERNEL is not set
-# CONFIG_SERIAL_TEXT_DEBUG is not set
+CONFIG_LOG_BUF_SHIFT=14
 
 #
 # Security options
 #
+# CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
 
 #
 # Cryptographic options
 #
 # CONFIG_CRYPTO is not set
+
+#
+# Hardware crypto devices
+#
index f0b0d572015400442ef82b4f3cd163ae99444f84..0f3bb9af9c22bcf346a8559c7f11458cd22d9060 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.11
-# Tue Mar  8 17:31:00 2005
+# Linux kernel version: 2.6.13-mm1
+# Thu Sep  1 17:16:03 2005
 #
 CONFIG_MMU=y
 CONFIG_GENERIC_HARDIRQS=y
@@ -11,6 +11,7 @@ CONFIG_HAVE_DEC_LOCK=y
 CONFIG_PPC=y
 CONFIG_PPC32=y
 CONFIG_GENERIC_NVRAM=y
+CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
 
 #
 # Code maturity level options
@@ -18,28 +19,31 @@ CONFIG_GENERIC_NVRAM=y
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
 CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
 
 #
 # General setup
 #
 CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
 # CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
 CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
+CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_EMBEDDED is not set
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_PRINTK=y
+CONFIG_BUG=y
 CONFIG_BASE_FULL=y
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SHMEM=y
 CONFIG_CC_ALIGN_FUNCTIONS=0
 CONFIG_CC_ALIGN_LABELS=0
@@ -68,14 +72,22 @@ CONFIG_6xx=y
 # CONFIG_POWER3 is not set
 # CONFIG_POWER4 is not set
 # CONFIG_8xx is not set
+# CONFIG_E200 is not set
 # CONFIG_E500 is not set
+CONFIG_PPC_FPU=y
 CONFIG_ALTIVEC=y
 # CONFIG_TAU is not set
+# CONFIG_KEXEC is not set
 # CONFIG_CPU_FREQ is not set
-# CONFIG_83xx is not set
+# CONFIG_WANT_EARLY_SERIAL is not set
 CONFIG_PPC_STD_MMU=y
 CONFIG_NOT_COHERENT_CACHE=y
 
+#
+# Performance-monitoring counters support
+#
+# CONFIG_PERFCTR is not set
+
 #
 # Platform options
 #
@@ -84,21 +96,18 @@ CONFIG_NOT_COHERENT_CACHE=y
 CONFIG_KATANA=y
 # CONFIG_WILLOW is not set
 # CONFIG_CPCI690 is not set
-# CONFIG_PCORE is not set
 # CONFIG_POWERPMC250 is not set
 # CONFIG_CHESTNUT is not set
 # CONFIG_SPRUCE is not set
+# CONFIG_HDPU is not set
 # CONFIG_EV64260 is not set
 # CONFIG_LOPEC is not set
-# CONFIG_MCPN765 is not set
 # CONFIG_MVME5100 is not set
 # CONFIG_PPLUS is not set
 # CONFIG_PRPMC750 is not set
 # CONFIG_PRPMC800 is not set
 # CONFIG_SANDPOINT is not set
 # CONFIG_RADSTONE_PPC7D is not set
-# CONFIG_ADIR is not set
-# CONFIG_K2 is not set
 # CONFIG_PAL4 is not set
 # CONFIG_GEMINI is not set
 # CONFIG_EST8260 is not set
@@ -109,6 +118,8 @@ CONFIG_KATANA=y
 # CONFIG_ADS8272 is not set
 # CONFIG_PQ2FADS is not set
 # CONFIG_LITE5200 is not set
+# CONFIG_MPC834x_SYS is not set
+# CONFIG_EV64360 is not set
 CONFIG_MV64360=y
 CONFIG_MV64X60=y
 
@@ -118,12 +129,28 @@ CONFIG_MV64X60=y
 CONFIG_MV64X60_BASE=0xf8100000
 CONFIG_MV64X60_NEW_BASE=0xf8100000
 # CONFIG_SMP is not set
+CONFIG_HIGHMEM=y
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+CONFIG_PREEMPT_NONE=y
+# CONFIG_PREEMPT_VOLUNTARY is not set
 # CONFIG_PREEMPT is not set
-# CONFIG_HIGHMEM is not set
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+# CONFIG_SPARSEMEM_STATIC is not set
 CONFIG_BINFMT_ELF=y
 CONFIG_BINFMT_MISC=y
 CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="console=ttyMM0,9600 ip=on"
+CONFIG_CMDLINE="console=ttyMM0 ip=on"
+# CONFIG_PM is not set
+CONFIG_SECCOMP=y
+CONFIG_ISA_DMA_API=y
 
 #
 # Bus options
@@ -132,21 +159,17 @@ CONFIG_GENERIC_ISA_DMA=y
 CONFIG_PCI=y
 CONFIG_PCI_DOMAINS=y
 CONFIG_PCI_LEGACY_PROC=y
-CONFIG_PCI_NAMES=y
 
 #
 # PCCARD (PCMCIA/CardBus) support
 #
 # CONFIG_PCCARD is not set
 
-#
-# PC-card bridges
-#
-
 #
 # Advanced setup
 #
 CONFIG_ADVANCED_OPTIONS=y
+# CONFIG_HIGHMEM_START_BOOL is not set
 CONFIG_HIGHMEM_START=0xfe000000
 # CONFIG_LOWMEM_SIZE_BOOL is not set
 CONFIG_LOWMEM_SIZE=0x30000000
@@ -161,6 +184,76 @@ CONFIG_CONSISTENT_SIZE=0x00400000
 # CONFIG_BOOT_LOAD_BOOL is not set
 CONFIG_BOOT_LOAD=0x00800000
 
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_IP_MROUTE is not set
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_BIC=y
+# CONFIG_IPV6 is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NETFILTER_NETLINK is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_IEEE80211 is not set
+
 #
 # Device Drivers
 #
@@ -177,8 +270,8 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
 #
 CONFIG_MTD=y
 # CONFIG_MTD_DEBUG is not set
-CONFIG_MTD_PARTITIONS=y
 CONFIG_MTD_CONCAT=y
+CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_REDBOOT_PARTS is not set
 # CONFIG_MTD_CMDLINE_PARTS is not set
 
@@ -212,6 +305,7 @@ CONFIG_MTD_MAP_BANK_WIDTH_4=y
 CONFIG_MTD_CFI_I2=y
 # CONFIG_MTD_CFI_I4 is not set
 # CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_OTP is not set
 CONFIG_MTD_CFI_INTELEXT=y
 # CONFIG_MTD_CFI_AMDSTD is not set
 # CONFIG_MTD_CFI_STAA is not set
@@ -219,7 +313,6 @@ CONFIG_MTD_CFI_UTIL=y
 # CONFIG_MTD_RAM is not set
 # CONFIG_MTD_ROM is not set
 # CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_XIP is not set
 
 #
 # Mapping drivers for chip access
@@ -229,6 +322,7 @@ CONFIG_MTD_PHYSMAP=y
 CONFIG_MTD_PHYSMAP_START=0xe0000000
 CONFIG_MTD_PHYSMAP_LEN=0x0
 CONFIG_MTD_PHYSMAP_BANKWIDTH=4
+# CONFIG_MTD_PLATRAM is not set
 
 #
 # Self-contained MTD device drivers
@@ -278,7 +372,6 @@ CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=4096
 CONFIG_BLK_DEV_INITRD=y
-CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_LBD is not set
 # CONFIG_CDROM_PKTCDVD is not set
 
@@ -299,6 +392,7 @@ CONFIG_IOSCHED_CFQ=y
 #
 # SCSI device support
 #
+# CONFIG_RAID_ATTRS is not set
 # CONFIG_SCSI is not set
 
 #
@@ -309,6 +403,7 @@ CONFIG_IOSCHED_CFQ=y
 #
 # Fusion MPT device support
 #
+# CONFIG_FUSION is not set
 
 #
 # IEEE 1394 (FireWire) support
@@ -325,71 +420,8 @@ CONFIG_IOSCHED_CFQ=y
 #
 
 #
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK_DEV is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_IP_MROUTE is not set
-# CONFIG_ARPD is not set
-CONFIG_SYN_COOKIES=y
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_TUNNEL is not set
-CONFIG_IP_TCPDIAG=y
-# CONFIG_IP_TCPDIAG_IPV6 is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
+# Network device support
 #
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
@@ -401,6 +433,11 @@ CONFIG_NETDEVICES=y
 #
 # CONFIG_ARCNET is not set
 
+#
+# PHY device support
+#
+# CONFIG_PHYLIB is not set
+
 #
 # Ethernet (10 or 100Mbit)
 #
@@ -422,6 +459,7 @@ CONFIG_TULIP=y
 # CONFIG_DE4X5 is not set
 # CONFIG_WINBOND_840 is not set
 # CONFIG_DM9102 is not set
+# CONFIG_ULI526X is not set
 # CONFIG_HP100 is not set
 CONFIG_NET_PCI=y
 # CONFIG_PCNET32 is not set
@@ -448,14 +486,19 @@ CONFIG_E100=y
 #
 # CONFIG_ACENIC is not set
 # CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
+CONFIG_E1000=y
+# CONFIG_E1000_NAPI is not set
 # CONFIG_NS83820 is not set
 # CONFIG_HAMACHI is not set
 # CONFIG_YELLOWFIN is not set
 # CONFIG_R8169 is not set
+# CONFIG_SIS190 is not set
+# CONFIG_SKGE is not set
+# CONFIG_SKY2 is not set
 # CONFIG_SK98LIN is not set
 # CONFIG_VIA_VELOCITY is not set
 # CONFIG_TIGON3 is not set
+# CONFIG_BNX2 is not set
 CONFIG_MV643XX_ETH=y
 CONFIG_MV643XX_ETH_0=y
 CONFIG_MV643XX_ETH_1=y
@@ -464,6 +507,7 @@ CONFIG_MV643XX_ETH_2=y
 #
 # Ethernet (10000 Mbit)
 #
+# CONFIG_CHELSIO_T1 is not set
 # CONFIG_IXGB is not set
 # CONFIG_S2IO is not set
 
@@ -487,6 +531,11 @@ CONFIG_MV643XX_ETH_2=y
 # CONFIG_SLIP is not set
 # CONFIG_SHAPER is not set
 # CONFIG_NETCONSOLE is not set
+# CONFIG_KGDBOE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NETPOLL_RX is not set
+# CONFIG_NETPOLL_TRAP is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
 
 #
 # ISDN subsystem
@@ -515,14 +564,6 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
 # CONFIG_INPUT_EVDEV is not set
 # CONFIG_INPUT_EVBUG is not set
 
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-# CONFIG_SERIO is not set
-# CONFIG_SERIO_I8042 is not set
-
 #
 # Input Device Drivers
 #
@@ -532,6 +573,12 @@ CONFIG_SOUND_GAMEPORT=y
 # CONFIG_INPUT_TOUCHSCREEN is not set
 # CONFIG_INPUT_MISC is not set
 
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
 #
 # Character devices
 #
@@ -552,6 +599,7 @@ CONFIG_SERIAL_MPSC=y
 CONFIG_SERIAL_MPSC_CONSOLE=y
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
+# CONFIG_SERIAL_JSM is not set
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
@@ -579,6 +627,11 @@ CONFIG_GEN_RTC=y
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
 
+#
+# TPM devices
+#
+# CONFIG_TCG_TPM is not set
+
 #
 # I2C support
 #
@@ -602,11 +655,10 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_AMD8111 is not set
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
-# CONFIG_I2C_ISA is not set
+# CONFIG_I2C_PIIX4 is not set
 # CONFIG_I2C_MPC is not set
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
-# CONFIG_I2C_PIIX4 is not set
 # CONFIG_I2C_PROSAVAGE is not set
 # CONFIG_I2C_SAVAGE4 is not set
 # CONFIG_SCx200_ACB is not set
@@ -621,14 +673,39 @@ CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_MV64XXX=y
 
 #
-# Hardware Sensors Chip support
+# Miscellaneous I2C Chip support
 #
-# CONFIG_I2C_SENSOR is not set
+# CONFIG_SENSORS_DS1337 is not set
+# CONFIG_SENSORS_DS1374 is not set
+# CONFIG_SENSORS_EEPROM is not set
+# CONFIG_SENSORS_PCF8574 is not set
+# CONFIG_SENSORS_PCA9539 is not set
+# CONFIG_SENSORS_PCF8591 is not set
+# CONFIG_SENSORS_RTC8564 is not set
+CONFIG_SENSORS_M41T00=y
+# CONFIG_SENSORS_MAX6875 is not set
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Hardware Monitoring support
+#
+CONFIG_HWMON=y
+# CONFIG_HWMON_VID is not set
 # CONFIG_SENSORS_ADM1021 is not set
 # CONFIG_SENSORS_ADM1025 is not set
 # CONFIG_SENSORS_ADM1026 is not set
 # CONFIG_SENSORS_ADM1031 is not set
+# CONFIG_SENSORS_ADM9240 is not set
 # CONFIG_SENSORS_ASB100 is not set
+# CONFIG_SENSORS_ATXP1 is not set
 # CONFIG_SENSORS_DS1621 is not set
 # CONFIG_SENSORS_FSCHER is not set
 # CONFIG_SENSORS_FSCPOS is not set
@@ -644,36 +721,26 @@ CONFIG_I2C_MV64XXX=y
 # CONFIG_SENSORS_LM85 is not set
 # CONFIG_SENSORS_LM87 is not set
 # CONFIG_SENSORS_LM90 is not set
+# CONFIG_SENSORS_LM92 is not set
 # CONFIG_SENSORS_MAX1619 is not set
 # CONFIG_SENSORS_PC87360 is not set
-# CONFIG_SENSORS_SMSC47B397 is not set
 # CONFIG_SENSORS_SIS5595 is not set
 # CONFIG_SENSORS_SMSC47M1 is not set
+# CONFIG_SENSORS_SMSC47B397 is not set
 # CONFIG_SENSORS_VIA686A is not set
 # CONFIG_SENSORS_W83781D is not set
+# CONFIG_SENSORS_W83792D is not set
 # CONFIG_SENSORS_W83L785TS is not set
 # CONFIG_SENSORS_W83627HF is not set
+# CONFIG_SENSORS_W83627EHF is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
 
 #
-# Other I2C Chip support
-#
-# CONFIG_SENSORS_EEPROM is not set
-# CONFIG_SENSORS_PCF8574 is not set
-# CONFIG_SENSORS_PCF8591 is not set
-# CONFIG_SENSORS_RTC8564 is not set
-CONFIG_SENSORS_M41T00=y
-# CONFIG_I2C_DEBUG_CORE is not set
-# CONFIG_I2C_DEBUG_ALGO is not set
-# CONFIG_I2C_DEBUG_BUS is not set
-# CONFIG_I2C_DEBUG_CHIP is not set
-
-#
-# Dallas's 1-wire bus
+# Misc devices
 #
-# CONFIG_W1 is not set
 
 #
-# Misc devices
+# Multimedia Capabilities Port drivers
 #
 
 #
@@ -697,6 +764,11 @@ CONFIG_SENSORS_M41T00=y
 # CONFIG_VGA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 
+#
+# Speakup console speech
+#
+# CONFIG_SPEAKUP is not set
+
 #
 # Sound
 #
@@ -705,13 +777,9 @@ CONFIG_DUMMY_CONSOLE=y
 #
 # USB support
 #
-# CONFIG_USB is not set
 CONFIG_USB_ARCH_HAS_HCD=y
 CONFIG_USB_ARCH_HAS_OHCI=y
-
-#
-# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
-#
+# CONFIG_USB is not set
 
 #
 # USB Gadget Support
@@ -728,26 +796,40 @@ CONFIG_USB_ARCH_HAS_OHCI=y
 #
 # CONFIG_INFINIBAND is not set
 
+#
+# SN Devices
+#
+
+#
+# Distributed Lock Manager
+#
+# CONFIG_DLM is not set
+
 #
 # File systems
 #
 CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
 # CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
+# CONFIG_REISER4_FS is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
 
 #
 # XFS support
 #
 # CONFIG_XFS_FS is not set
+# CONFIG_OCFS2_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
 # CONFIG_QUOTA is not set
 CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
 
 #
 # CD-ROM/DVD Filesystems
@@ -768,20 +850,18 @@ CONFIG_DNOTIFY=y
 CONFIG_PROC_FS=y
 CONFIG_PROC_KCORE=y
 CONFIG_SYSFS=y
-CONFIG_DEVFS_FS=y
-# CONFIG_DEVFS_MOUNT is not set
-# CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
-# CONFIG_TMPFS_XATTR is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
+# CONFIG_CONFIGFS_FS is not set
+# CONFIG_RELAYFS_FS is not set
 
 #
 # Miscellaneous filesystems
 #
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
+# CONFIG_ASFS_FS is not set
 # CONFIG_HFS_FS is not set
 # CONFIG_HFSPLUS_FS is not set
 # CONFIG_BEFS_FS is not set
@@ -801,12 +881,14 @@ CONFIG_RAMFS=y
 #
 CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
 # CONFIG_NFS_V4 is not set
 # CONFIG_NFS_DIRECTIO is not set
 # CONFIG_NFSD is not set
 CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
@@ -815,6 +897,7 @@ CONFIG_SUNRPC=y
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
 
 #
 # Partition Types
@@ -831,6 +914,7 @@ CONFIG_MSDOS_PARTITION=y
 # Library routines
 #
 # CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
 CONFIG_CRC32=y
 # CONFIG_LIBCRC32C is not set
 
@@ -842,8 +926,10 @@ CONFIG_CRC32=y
 #
 # Kernel hacking
 #
-# CONFIG_DEBUG_KERNEL is not set
 # CONFIG_PRINTK_TIME is not set
+# CONFIG_DEBUG_KERNEL is not set
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_SERIAL_TEXT_DEBUG is not set
 
 #
 # Security options
diff --git a/arch/ppc/configs/mcpn765_defconfig b/arch/ppc/configs/mcpn765_defconfig
deleted file mode 100644 (file)
index 899e89a..0000000
+++ /dev/null
@@ -1,579 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MMU=y
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
-CONFIG_HAVE_DEC_LOCK=y
-CONFIG_PPC=y
-CONFIG_PPC32=y
-CONFIG_GENERIC_NVRAM=y
-
-#
-# Code maturity level options
-#
-# CONFIG_EXPERIMENTAL is not set
-CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-# CONFIG_SWAP is not set
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_HOTPLUG is not set
-# CONFIG_IKCONFIG is not set
-CONFIG_EMBEDDED=y
-CONFIG_KALLSYMS=y
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODULE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-# CONFIG_KMOD is not set
-
-#
-# Processor
-#
-CONFIG_6xx=y
-# CONFIG_40x is not set
-# CONFIG_44x is not set
-# CONFIG_POWER3 is not set
-# CONFIG_POWER4 is not set
-# CONFIG_8xx is not set
-CONFIG_ALTIVEC=y
-# CONFIG_TAU is not set
-# CONFIG_CPU_FREQ is not set
-CONFIG_PPC_STD_MMU=y
-
-#
-# Platform options
-#
-# CONFIG_PPC_MULTIPLATFORM is not set
-# CONFIG_APUS is not set
-# CONFIG_WILLOW is not set
-# CONFIG_PCORE is not set
-# CONFIG_POWERPMC250 is not set
-# CONFIG_EV64260 is not set
-# CONFIG_SPRUCE is not set
-# CONFIG_LOPEC is not set
-CONFIG_MCPN765=y
-# CONFIG_MVME5100 is not set
-# CONFIG_PPLUS is not set
-# CONFIG_PRPMC750 is not set
-# CONFIG_PRPMC800 is not set
-# CONFIG_SANDPOINT is not set
-# CONFIG_ADIR is not set
-# CONFIG_K2 is not set
-# CONFIG_PAL4 is not set
-# CONFIG_GEMINI is not set
-# CONFIG_EST8260 is not set
-# CONFIG_SBS8260 is not set
-# CONFIG_RPX6 is not set
-# CONFIG_TQM8260 is not set
-CONFIG_PPC_GEN550=y
-# CONFIG_SMP is not set
-# CONFIG_PREEMPT is not set
-CONFIG_HIGHMEM=y
-CONFIG_KERNEL_ELF=y
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="ip=on"
-
-#
-# Bus options
-#
-CONFIG_GENERIC_ISA_DMA=y
-CONFIG_PCI=y
-CONFIG_PCI_DOMAINS=y
-# CONFIG_PCI_LEGACY_PROC is not set
-# CONFIG_PCI_NAMES is not set
-
-#
-# Advanced setup
-#
-# CONFIG_ADVANCED_OPTIONS is not set
-
-#
-# Default settings for advanced configuration options are used
-#
-CONFIG_HIGHMEM_START=0xfe000000
-CONFIG_LOWMEM_SIZE=0x30000000
-CONFIG_KERNEL_START=0xc0000000
-CONFIG_TASK_SIZE=0x80000000
-CONFIG_BOOT_LOAD=0x00800000
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_CARMEL is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_INITRD=y
-# CONFIG_LBD is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-CONFIG_IDE=y
-CONFIG_BLK_DEV_IDE=y
-
-#
-# Please see Documentation/ide.txt for help/info on IDE drives
-#
-CONFIG_BLK_DEV_IDEDISK=y
-# CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_IDEDISK_STROKE is not set
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_IDE_TASK_IOCTL is not set
-
-#
-# IDE chipset support/bugfixes
-#
-# CONFIG_IDE_GENERIC is not set
-CONFIG_BLK_DEV_IDEPCI=y
-# CONFIG_IDEPCI_SHARE_IRQ is not set
-# CONFIG_BLK_DEV_OFFBOARD is not set
-# CONFIG_BLK_DEV_GENERIC is not set
-# CONFIG_BLK_DEV_SL82C105 is not set
-CONFIG_BLK_DEV_IDEDMA_PCI=y
-# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
-# CONFIG_IDEDMA_PCI_AUTO is not set
-CONFIG_BLK_DEV_ADMA=y
-# CONFIG_BLK_DEV_AEC62XX is not set
-# CONFIG_BLK_DEV_ALI15X3 is not set
-# CONFIG_BLK_DEV_AMD74XX is not set
-# CONFIG_BLK_DEV_CMD64X is not set
-# CONFIG_BLK_DEV_TRIFLEX is not set
-# CONFIG_BLK_DEV_CY82C693 is not set
-# CONFIG_BLK_DEV_CS5530 is not set
-# CONFIG_BLK_DEV_HPT34X is not set
-# CONFIG_BLK_DEV_HPT366 is not set
-# CONFIG_BLK_DEV_SC1200 is not set
-# CONFIG_BLK_DEV_PIIX is not set
-# CONFIG_BLK_DEV_NS87415 is not set
-# CONFIG_BLK_DEV_PDC202XX_OLD is not set
-# CONFIG_BLK_DEV_PDC202XX_NEW is not set
-# CONFIG_BLK_DEV_SVWKS is not set
-# CONFIG_BLK_DEV_SIIMAGE is not set
-# CONFIG_BLK_DEV_SLC90E66 is not set
-# CONFIG_BLK_DEV_TRM290 is not set
-CONFIG_BLK_DEV_VIA82CXXX=y
-CONFIG_BLK_DEV_IDEDMA=y
-# CONFIG_IDEDMA_IVB is not set
-# CONFIG_IDEDMA_AUTO is not set
-# CONFIG_BLK_DEV_HD is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-# CONFIG_FUSION is not set
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-
-#
-# Macintosh device drivers
-#
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK_DEV is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_NETFILTER is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-CONFIG_NETDEVICES=y
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
-# CONFIG_OAKNET is not set
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_NET_VENDOR_3COM is not set
-
-#
-# Tulip family network device support
-#
-CONFIG_NET_TULIP=y
-CONFIG_TULIP=y
-# CONFIG_TULIP_MMIO is not set
-# CONFIG_TULIP_NAPI is not set
-# CONFIG_DE4X5 is not set
-# CONFIG_WINBOND_840 is not set
-# CONFIG_DM9102 is not set
-# CONFIG_HP100 is not set
-# CONFIG_NET_PCI is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_R8169 is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_TIGON3 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_IXGB is not set
-# CONFIG_FDDI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-# CONFIG_INPUT is not set
-
-#
-# Userland interfaces
-#
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-# CONFIG_SERIO is not set
-# CONFIG_SERIO_I8042 is not set
-
-#
-# Input Device Drivers
-#
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_SERIAL_8250_NR_UARTS=4
-# CONFIG_SERIAL_8250_EXTENDED is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_NVRAM is not set
-CONFIG_GEN_RTC=y
-# CONFIG_GEN_RTC_X is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-# CONFIG_DEVPTS_FS_XATTR is not set
-CONFIG_TMPFS=y
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-# CONFIG_EXPORTFS is not set
-CONFIG_SUNRPC=y
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-
-#
-# Native Language Support
-#
-# CONFIG_NLS is not set
-
-#
-# Library routines
-#
-CONFIG_CRC32=y
-
-#
-# Kernel hacking
-#
-# CONFIG_DEBUG_KERNEL is not set
-# CONFIG_SERIAL_TEXT_DEBUG is not set
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
diff --git a/arch/ppc/configs/menf1_defconfig b/arch/ppc/configs/menf1_defconfig
deleted file mode 100644 (file)
index 321659b..0000000
+++ /dev/null
@@ -1,621 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MMU=y
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
-CONFIG_HAVE_DEC_LOCK=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_EMBEDDED is not set
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-# CONFIG_MODVERSIONS is not set
-CONFIG_KMOD=y
-
-#
-# Platform support
-#
-CONFIG_PPC=y
-CONFIG_PPC32=y
-CONFIG_6xx=y
-# CONFIG_40x is not set
-# CONFIG_POWER3 is not set
-# CONFIG_8xx is not set
-
-#
-# IBM 4xx options
-#
-# CONFIG_8260 is not set
-CONFIG_GENERIC_ISA_DMA=y
-CONFIG_PPC_STD_MMU=y
-# CONFIG_PPC_MULTIPLATFORM is not set
-# CONFIG_APUS is not set
-# CONFIG_WILLOW_2 is not set
-# CONFIG_PCORE is not set
-# CONFIG_POWERPMC250 is not set
-# CONFIG_EV64260 is not set
-# CONFIG_SPRUCE is not set
-CONFIG_MENF1=y
-# CONFIG_LOPEC is not set
-# CONFIG_MCPN765 is not set
-# CONFIG_MVME5100 is not set
-# CONFIG_PPLUS is not set
-# CONFIG_PRPMC750 is not set
-# CONFIG_PRPMC800 is not set
-# CONFIG_SANDPOINT is not set
-# CONFIG_ADIR is not set
-# CONFIG_K2 is not set
-# CONFIG_PAL4 is not set
-# CONFIG_GEMINI is not set
-CONFIG_MPC10X_STORE_GATHERING=y
-# CONFIG_SMP is not set
-# CONFIG_PREEMPT is not set
-# CONFIG_ALTIVEC is not set
-# CONFIG_TAU is not set
-# CONFIG_CPU_FREQ is not set
-
-#
-# General setup
-#
-# CONFIG_HIGHMEM is not set
-CONFIG_PCI=y
-CONFIG_PCI_DOMAINS=y
-CONFIG_KCORE_ELF=y
-CONFIG_BINFMT_ELF=y
-CONFIG_KERNEL_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_PCI_LEGACY_PROC is not set
-# CONFIG_PCI_NAMES is not set
-# CONFIG_HOTPLUG is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-# CONFIG_PPC601_SYNC_FIX is not set
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="ip=on"
-
-#
-# Advanced setup
-#
-# CONFIG_ADVANCED_OPTIONS is not set
-
-#
-# Default settings for advanced configuration options are used
-#
-CONFIG_HIGHMEM_START=0xfe000000
-CONFIG_LOWMEM_SIZE=0x30000000
-CONFIG_KERNEL_START=0xc0000000
-CONFIG_TASK_SIZE=0x80000000
-CONFIG_BOOT_LOAD=0x00800000
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Plug and Play support
-#
-# CONFIG_PNP is not set
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-# CONFIG_BLK_DEV_LOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_RAM is not set
-# CONFIG_BLK_DEV_INITRD is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-CONFIG_IDE=y
-
-#
-# IDE, ATA and ATAPI Block devices
-#
-CONFIG_BLK_DEV_IDE=y
-
-#
-# Please see Documentation/ide.txt for help/info on IDE drives
-#
-# CONFIG_BLK_DEV_HD is not set
-CONFIG_BLK_DEV_IDEDISK=y
-# CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_IDEDISK_STROKE is not set
-CONFIG_BLK_DEV_IDECD=y
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_IDE_TASK_IOCTL is not set
-
-#
-# IDE chipset support/bugfixes
-#
-# CONFIG_BLK_DEV_IDEPCI is not set
-
-#
-# SCSI support
-#
-# CONFIG_SCSI is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# IEEE 1394 (FireWire) support (EXPERIMENTAL)
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK_DEV is not set
-CONFIG_NETFILTER=y
-# CONFIG_NETFILTER_DEBUG is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_IP_MROUTE is not set
-# CONFIG_ARPD is not set
-# CONFIG_INET_ECN is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-
-#
-# IP: Netfilter Configuration
-#
-CONFIG_IP_NF_CONNTRACK=m
-CONFIG_IP_NF_FTP=m
-CONFIG_IP_NF_IRC=m
-# CONFIG_IP_NF_TFTP is not set
-# CONFIG_IP_NF_AMANDA is not set
-# CONFIG_IP_NF_QUEUE is not set
-CONFIG_IP_NF_IPTABLES=m
-CONFIG_IP_NF_MATCH_LIMIT=m
-CONFIG_IP_NF_MATCH_MAC=m
-CONFIG_IP_NF_MATCH_PKTTYPE=m
-CONFIG_IP_NF_MATCH_MARK=m
-CONFIG_IP_NF_MATCH_MULTIPORT=m
-CONFIG_IP_NF_MATCH_TOS=m
-CONFIG_IP_NF_MATCH_ECN=m
-CONFIG_IP_NF_MATCH_DSCP=m
-CONFIG_IP_NF_MATCH_AH_ESP=m
-CONFIG_IP_NF_MATCH_LENGTH=m
-CONFIG_IP_NF_MATCH_TTL=m
-CONFIG_IP_NF_MATCH_TCPMSS=m
-CONFIG_IP_NF_MATCH_HELPER=m
-CONFIG_IP_NF_MATCH_STATE=m
-CONFIG_IP_NF_MATCH_CONNTRACK=m
-CONFIG_IP_NF_MATCH_UNCLEAN=m
-CONFIG_IP_NF_MATCH_OWNER=m
-CONFIG_IP_NF_FILTER=m
-CONFIG_IP_NF_TARGET_REJECT=m
-CONFIG_IP_NF_TARGET_MIRROR=m
-CONFIG_IP_NF_NAT=m
-CONFIG_IP_NF_NAT_NEEDED=y
-CONFIG_IP_NF_TARGET_MASQUERADE=m
-CONFIG_IP_NF_TARGET_REDIRECT=m
-# CONFIG_IP_NF_NAT_SNMP_BASIC is not set
-CONFIG_IP_NF_NAT_IRC=m
-CONFIG_IP_NF_NAT_FTP=m
-# CONFIG_IP_NF_MANGLE is not set
-# CONFIG_IP_NF_TARGET_LOG is not set
-CONFIG_IP_NF_TARGET_ULOG=m
-CONFIG_IP_NF_TARGET_TCPMSS=m
-CONFIG_IP_NF_ARPTABLES=m
-CONFIG_IP_NF_ARPFILTER=m
-CONFIG_IP_NF_COMPAT_IPCHAINS=m
-# CONFIG_IP_NF_COMPAT_IPFWADM is not set
-# CONFIG_IPV6 is not set
-# CONFIG_XFRM_USER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-CONFIG_IPV6_SCTP__=y
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_LLC is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-CONFIG_NETDEVICES=y
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
-# CONFIG_OAKNET is not set
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_NET_VENDOR_3COM is not set
-
-#
-# Tulip family network device support
-#
-# CONFIG_NET_TULIP is not set
-# CONFIG_HP100 is not set
-CONFIG_NET_PCI=y
-# CONFIG_PCNET32 is not set
-# CONFIG_AMD8111_ETH is not set
-# CONFIG_ADAPTEC_STARFIRE is not set
-# CONFIG_B44 is not set
-# CONFIG_DGRS is not set
-# CONFIG_EEPRO100 is not set
-# CONFIG_E100 is not set
-# CONFIG_FEALNX is not set
-# CONFIG_NATSEMI is not set
-# CONFIG_NE2K_PCI is not set
-# CONFIG_8139CP is not set
-# CONFIG_8139TOO is not set
-# CONFIG_SIS900 is not set
-# CONFIG_EPIC100 is not set
-# CONFIG_SUNDANCE is not set
-# CONFIG_TLAN is not set
-# CONFIG_VIA_RHINE is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_TIGON3 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_IXGB is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Token Ring devices (depends on LLC=y)
-#
-# CONFIG_RCPCI is not set
-# CONFIG_SHAPER is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN_BOOL is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Old CD-ROM drivers (not SCSI, not IDE)
-#
-# CONFIG_CD_NO_IDESCSI is not set
-
-#
-# Input device support
-#
-# CONFIG_INPUT is not set
-
-#
-# Userland interfaces
-#
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-# CONFIG_SERIO is not set
-
-#
-# Input Device Drivers
-#
-
-#
-# Macintosh device drivers
-#
-
-#
-# Character devices
-#
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_EXTENDED is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=256
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# I2C Hardware Sensors Mainboard support
-#
-
-#
-# I2C Hardware Sensors Chip support
-#
-# CONFIG_I2C_SENSOR is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_NVRAM is not set
-CONFIG_GEN_RTC=y
-# CONFIG_GEN_RTC_X is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-# CONFIG_HANGCHECK_TIMER is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-CONFIG_EXT3_FS=y
-CONFIG_EXT3_FS_XATTR=y
-# CONFIG_EXT3_FS_POSIX_ACL is not set
-# CONFIG_EXT3_FS_SECURITY is not set
-CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=y
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-CONFIG_ISO9660_FS=y
-# CONFIG_JOLIET is not set
-# CONFIG_ZISOFS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-# CONFIG_DEVFS_FS is not set
-CONFIG_DEVPTS_FS=y
-# CONFIG_DEVPTS_FS_XATTR is not set
-CONFIG_TMPFS=y
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-# CONFIG_EXPORTFS is not set
-CONFIG_SUNRPC=y
-# CONFIG_SUNRPC_GSS is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-# CONFIG_USB_GADGET is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# Library routines
-#
-# CONFIG_CRC32 is not set
-
-#
-# Kernel hacking
-#
-# CONFIG_DEBUG_KERNEL is not set
-# CONFIG_KALLSYMS is not set
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
index 38a343c9056ad3ead368322966518796f58f1f8a..f834fb541ad50e4e8871a5a097c92c1ff6172da9 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.11-rc1
-# Thu Jan 20 01:24:56 2005
+# Linux kernel version: 2.6.13-rc6
+# Thu Aug 11 18:14:45 2005
 #
 CONFIG_MMU=y
 CONFIG_GENERIC_HARDIRQS=y
@@ -11,6 +11,7 @@ CONFIG_HAVE_DEC_LOCK=y
 CONFIG_PPC=y
 CONFIG_PPC32=y
 CONFIG_GENERIC_NVRAM=y
+CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
 
 #
 # Code maturity level options
@@ -18,6 +19,7 @@ CONFIG_GENERIC_NVRAM=y
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
 CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
 
 #
 # General setup
@@ -29,12 +31,14 @@ CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
 # CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_HOTPLUG is not set
 CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
 # CONFIG_KALLSYMS is not set
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_BASE_FULL=y
 CONFIG_FUTEX=y
 # CONFIG_EPOLL is not set
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -44,6 +48,7 @@ CONFIG_CC_ALIGN_LABELS=0
 CONFIG_CC_ALIGN_LOOPS=0
 CONFIG_CC_ALIGN_JUMPS=0
 # CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
 
 #
 # Loadable module support
@@ -59,12 +64,16 @@ CONFIG_CC_ALIGN_JUMPS=0
 # CONFIG_POWER3 is not set
 # CONFIG_POWER4 is not set
 # CONFIG_8xx is not set
+# CONFIG_E200 is not set
 CONFIG_E500=y
 CONFIG_BOOKE=y
 CONFIG_FSL_BOOKE=y
+# CONFIG_PHYS_64BIT is not set
 CONFIG_SPE=y
 CONFIG_MATH_EMULATION=y
+# CONFIG_KEXEC is not set
 # CONFIG_CPU_FREQ is not set
+# CONFIG_PM is not set
 CONFIG_85xx=y
 CONFIG_PPC_INDIRECT_PCI_BE=y
 
@@ -72,9 +81,11 @@ CONFIG_PPC_INDIRECT_PCI_BE=y
 # Freescale 85xx options
 #
 # CONFIG_MPC8540_ADS is not set
+# CONFIG_MPC8548_CDS is not set
 # CONFIG_MPC8555_CDS is not set
 CONFIG_MPC8560_ADS=y
 # CONFIG_SBC8560 is not set
+# CONFIG_STX_GP3 is not set
 CONFIG_MPC8560=y
 
 #
@@ -83,11 +94,25 @@ CONFIG_MPC8560=y
 CONFIG_CPM2=y
 # CONFIG_PC_KEYBOARD is not set
 # CONFIG_SMP is not set
-# CONFIG_PREEMPT is not set
 # CONFIG_HIGHMEM is not set
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+CONFIG_PREEMPT_NONE=y
+# CONFIG_PREEMPT_VOLUNTARY is not set
+# CONFIG_PREEMPT is not set
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 # CONFIG_CMDLINE_BOOL is not set
+CONFIG_SECCOMP=y
+CONFIG_ISA_DMA_API=y
 
 #
 # Bus options
@@ -102,10 +127,6 @@ CONFIG_PCI_NAMES=y
 #
 # CONFIG_PCCARD is not set
 
-#
-# PC-card bridges
-#
-
 #
 # Advanced setup
 #
@@ -120,6 +141,69 @@ CONFIG_KERNEL_START=0xc0000000
 CONFIG_TASK_SIZE=0x80000000
 CONFIG_BOOT_LOAD=0x00800000
 
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_IP_MROUTE is not set
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_IP_TCPDIAG=y
+# CONFIG_IP_TCPDIAG_IPV6 is not set
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_BIC=y
+# CONFIG_IPV6 is not set
+# CONFIG_NETFILTER is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+
 #
 # Device Drivers
 #
@@ -193,6 +277,7 @@ CONFIG_IOSCHED_CFQ=y
 #
 # Fusion MPT device support
 #
+# CONFIG_FUSION is not set
 
 #
 # IEEE 1394 (FireWire) support
@@ -209,71 +294,8 @@ CONFIG_IOSCHED_CFQ=y
 #
 
 #
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK_DEV is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-CONFIG_IP_PNP_BOOTP=y
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_IP_MROUTE is not set
-# CONFIG_ARPD is not set
-CONFIG_SYN_COOKIES=y
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_TUNNEL is not set
-CONFIG_IP_TCPDIAG=y
-# CONFIG_IP_TCPDIAG_IPV6 is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
+# Network device support
 #
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
@@ -311,8 +333,10 @@ CONFIG_MII=y
 # CONFIG_HAMACHI is not set
 # CONFIG_YELLOWFIN is not set
 # CONFIG_R8169 is not set
+# CONFIG_SKGE is not set
 # CONFIG_SK98LIN is not set
 # CONFIG_TIGON3 is not set
+# CONFIG_BNX2 is not set
 CONFIG_GIANFAR=y
 CONFIG_GFAR_NAPI=y
 
@@ -342,6 +366,8 @@ CONFIG_GFAR_NAPI=y
 # CONFIG_SLIP is not set
 # CONFIG_SHAPER is not set
 # CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
 
 #
 # ISDN subsystem
@@ -367,14 +393,6 @@ CONFIG_INPUT=y
 # CONFIG_INPUT_EVDEV is not set
 # CONFIG_INPUT_EVBUG is not set
 
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-# CONFIG_SERIO is not set
-# CONFIG_SERIO_I8042 is not set
-
 #
 # Input Device Drivers
 #
@@ -384,6 +402,12 @@ CONFIG_SOUND_GAMEPORT=y
 # CONFIG_INPUT_TOUCHSCREEN is not set
 # CONFIG_INPUT_MISC is not set
 
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
 #
 # Character devices
 #
@@ -403,11 +427,12 @@ CONFIG_SERIAL_CORE_CONSOLE=y
 CONFIG_SERIAL_CPM=y
 CONFIG_SERIAL_CPM_CONSOLE=y
 CONFIG_SERIAL_CPM_SCC1=y
-# CONFIG_SERIAL_CPM_SCC2 is not set
+CONFIG_SERIAL_CPM_SCC2=y
 # CONFIG_SERIAL_CPM_SCC3 is not set
-CONFIG_SERIAL_CPM_SCC4=y
+# CONFIG_SERIAL_CPM_SCC4 is not set
 # CONFIG_SERIAL_CPM_SMC1 is not set
 # CONFIG_SERIAL_CPM_SMC2 is not set
+# CONFIG_SERIAL_JSM is not set
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
@@ -435,6 +460,11 @@ CONFIG_GEN_RTC=y
 # CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
 
+#
+# TPM devices
+#
+# CONFIG_TCG_TPM is not set
+
 #
 # I2C support
 #
@@ -458,11 +488,11 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_AMD8111 is not set
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
+# CONFIG_I2C_PIIX4 is not set
 # CONFIG_I2C_ISA is not set
 CONFIG_I2C_MPC=y
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
-# CONFIG_I2C_PIIX4 is not set
 # CONFIG_I2C_PROSAVAGE is not set
 # CONFIG_I2C_SAVAGE4 is not set
 # CONFIG_SCx200_ACB is not set
@@ -473,19 +503,46 @@ CONFIG_I2C_MPC=y
 # CONFIG_I2C_VIAPRO is not set
 # CONFIG_I2C_VOODOO3 is not set
 # CONFIG_I2C_PCA_ISA is not set
+# CONFIG_I2C_SENSOR is not set
 
 #
-# Hardware Sensors Chip support
+# Miscellaneous I2C Chip support
 #
-# CONFIG_I2C_SENSOR is not set
+# CONFIG_SENSORS_DS1337 is not set
+# CONFIG_SENSORS_DS1374 is not set
+# CONFIG_SENSORS_EEPROM is not set
+# CONFIG_SENSORS_PCF8574 is not set
+# CONFIG_SENSORS_PCA9539 is not set
+# CONFIG_SENSORS_PCF8591 is not set
+# CONFIG_SENSORS_RTC8564 is not set
+# CONFIG_SENSORS_M41T00 is not set
+# CONFIG_SENSORS_MAX6875 is not set
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Hardware Monitoring support
+#
+CONFIG_HWMON=y
 # CONFIG_SENSORS_ADM1021 is not set
 # CONFIG_SENSORS_ADM1025 is not set
 # CONFIG_SENSORS_ADM1026 is not set
 # CONFIG_SENSORS_ADM1031 is not set
+# CONFIG_SENSORS_ADM9240 is not set
 # CONFIG_SENSORS_ASB100 is not set
+# CONFIG_SENSORS_ATXP1 is not set
 # CONFIG_SENSORS_DS1621 is not set
 # CONFIG_SENSORS_FSCHER is not set
+# CONFIG_SENSORS_FSCPOS is not set
 # CONFIG_SENSORS_GL518SM is not set
+# CONFIG_SENSORS_GL520SM is not set
 # CONFIG_SENSORS_IT87 is not set
 # CONFIG_SENSORS_LM63 is not set
 # CONFIG_SENSORS_LM75 is not set
@@ -496,31 +553,18 @@ CONFIG_I2C_MPC=y
 # CONFIG_SENSORS_LM85 is not set
 # CONFIG_SENSORS_LM87 is not set
 # CONFIG_SENSORS_LM90 is not set
+# CONFIG_SENSORS_LM92 is not set
 # CONFIG_SENSORS_MAX1619 is not set
 # CONFIG_SENSORS_PC87360 is not set
-# CONFIG_SENSORS_SMSC47B397 is not set
+# CONFIG_SENSORS_SIS5595 is not set
 # CONFIG_SENSORS_SMSC47M1 is not set
+# CONFIG_SENSORS_SMSC47B397 is not set
 # CONFIG_SENSORS_VIA686A is not set
 # CONFIG_SENSORS_W83781D is not set
 # CONFIG_SENSORS_W83L785TS is not set
 # CONFIG_SENSORS_W83627HF is not set
-
-#
-# Other I2C Chip support
-#
-# CONFIG_SENSORS_EEPROM is not set
-# CONFIG_SENSORS_PCF8574 is not set
-# CONFIG_SENSORS_PCF8591 is not set
-# CONFIG_SENSORS_RTC8564 is not set
-# CONFIG_I2C_DEBUG_CORE is not set
-# CONFIG_I2C_DEBUG_ALGO is not set
-# CONFIG_I2C_DEBUG_BUS is not set
-# CONFIG_I2C_DEBUG_CHIP is not set
-
-#
-# Dallas's 1-wire bus
-#
-# CONFIG_W1 is not set
+# CONFIG_SENSORS_W83627EHF is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
 
 #
 # Misc devices
@@ -540,7 +584,6 @@ CONFIG_I2C_MPC=y
 # Graphics support
 #
 # CONFIG_FB is not set
-# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
 # Sound
@@ -550,13 +593,9 @@ CONFIG_I2C_MPC=y
 #
 # USB support
 #
-# CONFIG_USB is not set
 CONFIG_USB_ARCH_HAS_HCD=y
 CONFIG_USB_ARCH_HAS_OHCI=y
-
-#
-# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
-#
+# CONFIG_USB is not set
 
 #
 # USB Gadget Support
@@ -573,11 +612,16 @@ CONFIG_USB_ARCH_HAS_OHCI=y
 #
 # CONFIG_INFINIBAND is not set
 
+#
+# SN Devices
+#
+
 #
 # File systems
 #
 CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
 CONFIG_EXT3_FS=y
 CONFIG_EXT3_FS_XATTR=y
 # CONFIG_EXT3_FS_POSIX_ACL is not set
@@ -587,9 +631,15 @@ CONFIG_JBD=y
 CONFIG_FS_MBCACHE=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+
+#
+# XFS support
+#
 # CONFIG_XFS_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
 # CONFIG_QUOTA is not set
 CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
@@ -614,7 +664,6 @@ CONFIG_DNOTIFY=y
 CONFIG_PROC_FS=y
 CONFIG_PROC_KCORE=y
 CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
 # CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
 # CONFIG_TMPFS_XATTR is not set
@@ -648,7 +697,7 @@ CONFIG_NFS_FS=y
 # CONFIG_NFSD is not set
 CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
-# CONFIG_EXPORTFS is not set
+CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
@@ -700,7 +749,9 @@ CONFIG_CRC32=y
 #
 # Kernel hacking
 #
+# CONFIG_PRINTK_TIME is not set
 # CONFIG_DEBUG_KERNEL is not set
+CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_KGDB_CONSOLE is not set
 
 #
diff --git a/arch/ppc/configs/oak_defconfig b/arch/ppc/configs/oak_defconfig
deleted file mode 100644 (file)
index 366cc48..0000000
+++ /dev/null
@@ -1,485 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MMU=y
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
-CONFIG_HAVE_DEC_LOCK=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_LOG_BUF_SHIFT=14
-CONFIG_EMBEDDED=y
-CONFIG_FUTEX=y
-# CONFIG_EPOLL is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-# CONFIG_MODVERSIONS is not set
-CONFIG_KMOD=y
-
-#
-# Platform support
-#
-CONFIG_PPC=y
-CONFIG_PPC32=y
-# CONFIG_6xx is not set
-CONFIG_40x=y
-# CONFIG_POWER3 is not set
-# CONFIG_8xx is not set
-CONFIG_4xx=y
-
-#
-# IBM 4xx options
-#
-# CONFIG_ASH is not set
-# CONFIG_BEECH is not set
-# CONFIG_CEDAR is not set
-# CONFIG_CPCI405 is not set
-# CONFIG_EP405 is not set
-CONFIG_OAK=y
-# CONFIG_REDWOOD_4 is not set
-# CONFIG_REDWOOD_5 is not set
-# CONFIG_REDWOOD_6 is not set
-# CONFIG_SYCAMORE is not set
-# CONFIG_TIVO is not set
-# CONFIG_WALNUT is not set
-CONFIG_IBM405_ERR51=y
-CONFIG_403GCX=y
-# CONFIG_405_DMA is not set
-# CONFIG_PM is not set
-CONFIG_UART0_TTYS0=y
-# CONFIG_UART0_TTYS1 is not set
-CONFIG_NOT_COHERENT_CACHE=y
-# CONFIG_SMP is not set
-# CONFIG_PREEMPT is not set
-# CONFIG_MATH_EMULATION is not set
-# CONFIG_CPU_FREQ is not set
-
-#
-# General setup
-#
-# CONFIG_HIGHMEM is not set
-# CONFIG_PCI is not set
-# CONFIG_PCI_DOMAINS is not set
-# CONFIG_PC_KEYBOARD is not set
-CONFIG_KCORE_ELF=y
-CONFIG_BINFMT_ELF=y
-CONFIG_KERNEL_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_HOTPLUG is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-# CONFIG_CMDLINE_BOOL is not set
-
-#
-# Advanced setup
-#
-# CONFIG_ADVANCED_OPTIONS is not set
-
-#
-# Default settings for advanced configuration options are used
-#
-CONFIG_HIGHMEM_START=0xfe000000
-CONFIG_LOWMEM_SIZE=0x30000000
-CONFIG_KERNEL_START=0xc0000000
-CONFIG_TASK_SIZE=0x80000000
-CONFIG_BOOT_LOAD=0x00400000
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Plug and Play support
-#
-# CONFIG_PNP is not set
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_NBD is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_INITRD=y
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI support
-#
-# CONFIG_SCSI is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# I2O device support
-#
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-# CONFIG_PACKET is not set
-# CONFIG_NETLINK_DEV is not set
-# CONFIG_NETFILTER is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-# CONFIG_IP_PNP_DHCP is not set
-CONFIG_IP_PNP_BOOTP=y
-CONFIG_IP_PNP_RARP=y
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_IP_MROUTE is not set
-# CONFIG_ARPD is not set
-# CONFIG_INET_ECN is not set
-CONFIG_SYN_COOKIES=y
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_IPV6 is not set
-# CONFIG_XFRM_USER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-CONFIG_IPV6_SCTP__=y
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_LLC is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_MII is not set
-CONFIG_OAKNET=y
-
-#
-# Ethernet (1000 Mbit)
-#
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Token Ring devices (depends on LLC=y)
-#
-# CONFIG_SHAPER is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN_BOOL is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Old CD-ROM drivers (not SCSI, not IDE)
-#
-# CONFIG_CD_NO_IDESCSI is not set
-
-#
-# Input device support
-#
-# CONFIG_INPUT is not set
-
-#
-# Userland interfaces
-#
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-# CONFIG_SERIO is not set
-
-#
-# Input Device Drivers
-#
-
-#
-# Macintosh device drivers
-#
-
-#
-# Character devices
-#
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_EXTENDED is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-# CONFIG_UNIX98_PTYS is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# I2C Hardware Sensors Mainboard support
-#
-
-#
-# I2C Hardware Sensors Chip support
-#
-# CONFIG_I2C_SENSOR is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_NVRAM is not set
-CONFIG_GEN_RTC=y
-# CONFIG_GEN_RTC_X is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-# CONFIG_HANGCHECK_TIMER is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-# CONFIG_DEVFS_FS is not set
-CONFIG_TMPFS=y
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-# CONFIG_EXPORTFS is not set
-CONFIG_SUNRPC=y
-# CONFIG_SUNRPC_GSS is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# IBM 40x options
-#
-
-#
-# USB support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# Library routines
-#
-# CONFIG_CRC32 is not set
-
-#
-# Kernel hacking
-#
-# CONFIG_DEBUG_KERNEL is not set
-# CONFIG_KALLSYMS is not set
-# CONFIG_SERIAL_TEXT_DEBUG is not set
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
diff --git a/arch/ppc/configs/pcore_defconfig b/arch/ppc/configs/pcore_defconfig
deleted file mode 100644 (file)
index ed34405..0000000
+++ /dev/null
@@ -1,716 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MMU=y
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
-CONFIG_HAVE_DEC_LOCK=y
-CONFIG_PPC=y
-CONFIG_PPC32=y
-CONFIG_GENERIC_NVRAM=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_HOTPLUG is not set
-# CONFIG_IKCONFIG is not set
-CONFIG_EMBEDDED=y
-CONFIG_KALLSYMS=y
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-# CONFIG_MODVERSIONS is not set
-CONFIG_KMOD=y
-
-#
-# Processor
-#
-CONFIG_6xx=y
-# CONFIG_40x is not set
-# CONFIG_44x is not set
-# CONFIG_POWER3 is not set
-# CONFIG_POWER4 is not set
-# CONFIG_8xx is not set
-CONFIG_ALTIVEC=y
-# CONFIG_TAU is not set
-# CONFIG_CPU_FREQ is not set
-CONFIG_PPC_STD_MMU=y
-
-#
-# Platform options
-#
-# CONFIG_PPC_MULTIPLATFORM is not set
-# CONFIG_APUS is not set
-# CONFIG_WILLOW is not set
-CONFIG_PCORE=y
-# CONFIG_POWERPMC250 is not set
-# CONFIG_EV64260 is not set
-# CONFIG_SPRUCE is not set
-# CONFIG_LOPEC is not set
-# CONFIG_MCPN765 is not set
-# CONFIG_MVME5100 is not set
-# CONFIG_PPLUS is not set
-# CONFIG_PRPMC750 is not set
-# CONFIG_PRPMC800 is not set
-# CONFIG_SANDPOINT is not set
-# CONFIG_ADIR is not set
-# CONFIG_K2 is not set
-# CONFIG_PAL4 is not set
-# CONFIG_GEMINI is not set
-# CONFIG_EST8260 is not set
-# CONFIG_SBS8260 is not set
-# CONFIG_RPX6 is not set
-# CONFIG_TQM8260 is not set
-CONFIG_PPC_GEN550=y
-CONFIG_FORCE=y
-# CONFIG_MPC10X_STORE_GATHERING is not set
-# CONFIG_SMP is not set
-# CONFIG_PREEMPT is not set
-# CONFIG_HIGHMEM is not set
-CONFIG_KERNEL_ELF=y
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="ip=on"
-
-#
-# Bus options
-#
-CONFIG_GENERIC_ISA_DMA=y
-CONFIG_PCI=y
-CONFIG_PCI_DOMAINS=y
-# CONFIG_PCI_LEGACY_PROC is not set
-# CONFIG_PCI_NAMES is not set
-
-#
-# Advanced setup
-#
-# CONFIG_ADVANCED_OPTIONS is not set
-
-#
-# Default settings for advanced configuration options are used
-#
-CONFIG_HIGHMEM_START=0xfe000000
-CONFIG_LOWMEM_SIZE=0x30000000
-CONFIG_KERNEL_START=0xc0000000
-CONFIG_TASK_SIZE=0x80000000
-CONFIG_BOOT_LOAD=0x00800000
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-# CONFIG_BLK_DEV_LOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_CARMEL is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_INITRD=y
-# CONFIG_LBD is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI device support
-#
-CONFIG_SCSI=y
-CONFIG_SCSI_PROC_FS=y
-
-#
-# SCSI support type (disk, tape, CD-ROM)
-#
-CONFIG_BLK_DEV_SD=y
-# CONFIG_CHR_DEV_ST is not set
-# CONFIG_CHR_DEV_OSST is not set
-CONFIG_BLK_DEV_SR=y
-# CONFIG_BLK_DEV_SR_VENDOR is not set
-# CONFIG_CHR_DEV_SG is not set
-
-#
-# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
-#
-# CONFIG_SCSI_MULTI_LUN is not set
-# CONFIG_SCSI_REPORT_LUNS is not set
-# CONFIG_SCSI_CONSTANTS is not set
-# CONFIG_SCSI_LOGGING is not set
-
-#
-# SCSI Transport Attributes
-#
-# CONFIG_SCSI_SPI_ATTRS is not set
-# CONFIG_SCSI_FC_ATTRS is not set
-
-#
-# SCSI low-level drivers
-#
-# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
-# CONFIG_SCSI_ACARD is not set
-# CONFIG_SCSI_AACRAID is not set
-# CONFIG_SCSI_AIC7XXX is not set
-# CONFIG_SCSI_AIC7XXX_OLD is not set
-# CONFIG_SCSI_AIC79XX is not set
-# CONFIG_SCSI_ADVANSYS is not set
-# CONFIG_SCSI_MEGARAID is not set
-# CONFIG_SCSI_SATA is not set
-# CONFIG_SCSI_BUSLOGIC is not set
-# CONFIG_SCSI_CPQFCTS is not set
-# CONFIG_SCSI_DMX3191D is not set
-# CONFIG_SCSI_EATA is not set
-# CONFIG_SCSI_EATA_PIO is not set
-# CONFIG_SCSI_FUTURE_DOMAIN is not set
-# CONFIG_SCSI_GDTH is not set
-# CONFIG_SCSI_IPS is not set
-# CONFIG_SCSI_INIA100 is not set
-CONFIG_SCSI_SYM53C8XX_2=y
-CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
-CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
-CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
-# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set
-# CONFIG_SCSI_QLOGIC_ISP is not set
-# CONFIG_SCSI_QLOGIC_FC is not set
-# CONFIG_SCSI_QLOGIC_1280 is not set
-CONFIG_SCSI_QLA2XXX=y
-# CONFIG_SCSI_QLA21XX is not set
-# CONFIG_SCSI_QLA22XX is not set
-# CONFIG_SCSI_QLA2300 is not set
-# CONFIG_SCSI_QLA2322 is not set
-# CONFIG_SCSI_QLA6312 is not set
-# CONFIG_SCSI_QLA6322 is not set
-# CONFIG_SCSI_DC395x is not set
-# CONFIG_SCSI_DC390T is not set
-# CONFIG_SCSI_NSP32 is not set
-# CONFIG_SCSI_DEBUG is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-# CONFIG_FUSION is not set
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-
-#
-# Macintosh device drivers
-#
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK_DEV is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_IP_MROUTE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-
-#
-# IP: Virtual Server Configuration
-#
-# CONFIG_IP_VS is not set
-# CONFIG_IPV6 is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-CONFIG_NETFILTER=y
-# CONFIG_NETFILTER_DEBUG is not set
-
-#
-# IP: Netfilter Configuration
-#
-CONFIG_IP_NF_CONNTRACK=m
-CONFIG_IP_NF_FTP=m
-CONFIG_IP_NF_IRC=m
-# CONFIG_IP_NF_TFTP is not set
-# CONFIG_IP_NF_AMANDA is not set
-# CONFIG_IP_NF_QUEUE is not set
-CONFIG_IP_NF_IPTABLES=m
-CONFIG_IP_NF_MATCH_LIMIT=m
-# CONFIG_IP_NF_MATCH_IPRANGE is not set
-CONFIG_IP_NF_MATCH_MAC=m
-CONFIG_IP_NF_MATCH_PKTTYPE=m
-CONFIG_IP_NF_MATCH_MARK=m
-CONFIG_IP_NF_MATCH_MULTIPORT=m
-CONFIG_IP_NF_MATCH_TOS=m
-# CONFIG_IP_NF_MATCH_RECENT is not set
-CONFIG_IP_NF_MATCH_ECN=m
-CONFIG_IP_NF_MATCH_DSCP=m
-CONFIG_IP_NF_MATCH_AH_ESP=m
-CONFIG_IP_NF_MATCH_LENGTH=m
-CONFIG_IP_NF_MATCH_TTL=m
-CONFIG_IP_NF_MATCH_TCPMSS=m
-CONFIG_IP_NF_MATCH_HELPER=m
-CONFIG_IP_NF_MATCH_STATE=m
-CONFIG_IP_NF_MATCH_CONNTRACK=m
-CONFIG_IP_NF_MATCH_OWNER=m
-CONFIG_IP_NF_FILTER=m
-CONFIG_IP_NF_TARGET_REJECT=m
-CONFIG_IP_NF_NAT=m
-CONFIG_IP_NF_NAT_NEEDED=y
-CONFIG_IP_NF_TARGET_MASQUERADE=m
-CONFIG_IP_NF_TARGET_REDIRECT=m
-# CONFIG_IP_NF_TARGET_NETMAP is not set
-# CONFIG_IP_NF_TARGET_SAME is not set
-# CONFIG_IP_NF_NAT_SNMP_BASIC is not set
-CONFIG_IP_NF_NAT_IRC=m
-CONFIG_IP_NF_NAT_FTP=m
-# CONFIG_IP_NF_MANGLE is not set
-# CONFIG_IP_NF_TARGET_LOG is not set
-CONFIG_IP_NF_TARGET_ULOG=m
-CONFIG_IP_NF_TARGET_TCPMSS=m
-CONFIG_IP_NF_ARPTABLES=m
-CONFIG_IP_NF_ARPFILTER=m
-# CONFIG_IP_NF_ARP_MANGLE is not set
-CONFIG_IP_NF_COMPAT_IPCHAINS=m
-# CONFIG_IP_NF_COMPAT_IPFWADM is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-CONFIG_NETDEVICES=y
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
-# CONFIG_OAKNET is not set
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_NET_VENDOR_3COM is not set
-
-#
-# Tulip family network device support
-#
-CONFIG_NET_TULIP=y
-# CONFIG_DE2104X is not set
-CONFIG_TULIP=y
-# CONFIG_TULIP_MWI is not set
-# CONFIG_TULIP_MMIO is not set
-# CONFIG_TULIP_NAPI is not set
-# CONFIG_DE4X5 is not set
-# CONFIG_WINBOND_840 is not set
-# CONFIG_DM9102 is not set
-# CONFIG_HP100 is not set
-CONFIG_NET_PCI=y
-# CONFIG_PCNET32 is not set
-# CONFIG_AMD8111_ETH is not set
-# CONFIG_ADAPTEC_STARFIRE is not set
-# CONFIG_B44 is not set
-# CONFIG_FORCEDETH is not set
-# CONFIG_DGRS is not set
-CONFIG_EEPRO100=y
-# CONFIG_EEPRO100_PIO is not set
-# CONFIG_E100 is not set
-# CONFIG_FEALNX is not set
-# CONFIG_NATSEMI is not set
-# CONFIG_NE2K_PCI is not set
-# CONFIG_8139CP is not set
-# CONFIG_8139TOO is not set
-# CONFIG_SIS900 is not set
-# CONFIG_EPIC100 is not set
-# CONFIG_SUNDANCE is not set
-# CONFIG_TLAN is not set
-# CONFIG_VIA_RHINE is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SIS190 is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_TIGON3 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_IXGB is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-# CONFIG_NET_FC is not set
-# CONFIG_RCPCI is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-# CONFIG_INPUT is not set
-
-#
-# Userland interfaces
-#
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-# CONFIG_SERIO is not set
-# CONFIG_SERIO_I8042 is not set
-
-#
-# Input Device Drivers
-#
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_SERIAL_8250_NR_UARTS=2
-# CONFIG_SERIAL_8250_EXTENDED is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_NVRAM is not set
-CONFIG_GEN_RTC=y
-# CONFIG_GEN_RTC_X is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-CONFIG_EXT3_FS=y
-CONFIG_EXT3_FS_XATTR=y
-# CONFIG_EXT3_FS_POSIX_ACL is not set
-# CONFIG_EXT3_FS_SECURITY is not set
-CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=y
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-# CONFIG_DEVFS_FS is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
-CONFIG_TMPFS=y
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-# CONFIG_EXPORTFS is not set
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-
-#
-# Native Language Support
-#
-# CONFIG_NLS is not set
-
-#
-# Library routines
-#
-CONFIG_CRC32=y
-
-#
-# Kernel hacking
-#
-# CONFIG_DEBUG_KERNEL is not set
-# CONFIG_SERIAL_TEXT_DEBUG is not set
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
diff --git a/arch/ppc/configs/rainier_defconfig b/arch/ppc/configs/rainier_defconfig
deleted file mode 100644 (file)
index 4d4fcdc..0000000
+++ /dev/null
@@ -1,599 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MMU=y
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
-CONFIG_HAVE_DEC_LOCK=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-
-#
-# General setup
-#
-# CONFIG_SWAP is not set
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_LOG_BUF_SHIFT=14
-CONFIG_EMBEDDED=y
-CONFIG_FUTEX=y
-# CONFIG_EPOLL is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODULE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-CONFIG_MODVERSIONS=y
-CONFIG_KMOD=y
-
-#
-# Platform support
-#
-CONFIG_PPC=y
-CONFIG_PPC32=y
-# CONFIG_6xx is not set
-CONFIG_40x=y
-# CONFIG_POWER3 is not set
-# CONFIG_8xx is not set
-CONFIG_4xx=y
-
-#
-# IBM 4xx options
-#
-# CONFIG_ASH is not set
-# CONFIG_BEECH is not set
-# CONFIG_CEDAR is not set
-# CONFIG_CPCI405 is not set
-# CONFIG_EP405 is not set
-# CONFIG_OAK is not set
-# CONFIG_REDWOOD_4 is not set
-# CONFIG_REDWOOD_5 is not set
-# CONFIG_REDWOOD_6 is not set
-# CONFIG_SYCAMORE is not set
-# CONFIG_TIVO is not set
-CONFIG_WALNUT=y
-CONFIG_IBM405_ERR77=y
-CONFIG_IBM405_ERR51=y
-CONFIG_IBM_OCP=y
-CONFIG_BIOS_FIXUP=y
-CONFIG_405GP=y
-CONFIG_IBM_OPENBIOS=y
-CONFIG_405_DMA=y
-# CONFIG_PM is not set
-CONFIG_UART0_TTYS0=y
-# CONFIG_UART0_TTYS1 is not set
-CONFIG_NOT_COHERENT_CACHE=y
-# CONFIG_SMP is not set
-# CONFIG_PREEMPT is not set
-# CONFIG_MATH_EMULATION is not set
-# CONFIG_CPU_FREQ is not set
-
-#
-# General setup
-#
-# CONFIG_HIGHMEM is not set
-CONFIG_PCI=y
-CONFIG_PCI_DOMAINS=y
-# CONFIG_PC_KEYBOARD is not set
-CONFIG_KCORE_ELF=y
-CONFIG_BINFMT_ELF=y
-CONFIG_KERNEL_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_PCI_LEGACY_PROC is not set
-CONFIG_PCI_NAMES=y
-# CONFIG_HOTPLUG is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-# CONFIG_CMDLINE_BOOL is not set
-
-#
-# Advanced setup
-#
-# CONFIG_ADVANCED_OPTIONS is not set
-
-#
-# Default settings for advanced configuration options are used
-#
-CONFIG_HIGHMEM_START=0xfe000000
-CONFIG_LOWMEM_SIZE=0x30000000
-CONFIG_KERNEL_START=0xc0000000
-CONFIG_TASK_SIZE=0x80000000
-CONFIG_BOOT_LOAD=0x00400000
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Plug and Play support
-#
-# CONFIG_PNP is not set
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-CONFIG_BLK_DEV_LOOP=y
-CONFIG_BLK_DEV_NBD=y
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_INITRD=y
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI support
-#
-# CONFIG_SCSI is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# IEEE 1394 (FireWire) support (EXPERIMENTAL)
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK_DEV is not set
-# CONFIG_NETFILTER is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-# CONFIG_IP_PNP_DHCP is not set
-CONFIG_IP_PNP_BOOTP=y
-CONFIG_IP_PNP_RARP=y
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_IP_MROUTE is not set
-# CONFIG_ARPD is not set
-# CONFIG_INET_ECN is not set
-CONFIG_SYN_COOKIES=y
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_IPV6 is not set
-# CONFIG_XFRM_USER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-CONFIG_IPV6_SCTP__=y
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_LLC is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-CONFIG_NETDEVICES=y
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
-# CONFIG_OAKNET is not set
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_NET_VENDOR_3COM is not set
-
-#
-# Tulip family network device support
-#
-# CONFIG_NET_TULIP is not set
-# CONFIG_HP100 is not set
-CONFIG_NET_PCI=y
-CONFIG_PCNET32=y
-# CONFIG_AMD8111_ETH is not set
-# CONFIG_ADAPTEC_STARFIRE is not set
-# CONFIG_B44 is not set
-# CONFIG_DGRS is not set
-CONFIG_EEPRO100=y
-# CONFIG_EEPRO100_PIO is not set
-# CONFIG_E100 is not set
-# CONFIG_FEALNX is not set
-# CONFIG_NATSEMI is not set
-# CONFIG_NE2K_PCI is not set
-# CONFIG_8139CP is not set
-# CONFIG_8139TOO is not set
-# CONFIG_SIS900 is not set
-# CONFIG_EPIC100 is not set
-# CONFIG_SUNDANCE is not set
-# CONFIG_TLAN is not set
-# CONFIG_VIA_RHINE is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_TIGON3 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_IXGB is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-CONFIG_PPP=y
-# CONFIG_PPP_MULTILINK is not set
-# CONFIG_PPP_FILTER is not set
-# CONFIG_PPP_ASYNC is not set
-# CONFIG_PPP_SYNC_TTY is not set
-# CONFIG_PPP_DEFLATE is not set
-# CONFIG_PPP_BSDCOMP is not set
-# CONFIG_PPPOE is not set
-# CONFIG_SLIP is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Token Ring devices (depends on LLC=y)
-#
-# CONFIG_RCPCI is not set
-# CONFIG_SHAPER is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN_BOOL is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Old CD-ROM drivers (not SCSI, not IDE)
-#
-# CONFIG_CD_NO_IDESCSI is not set
-
-#
-# Input device support
-#
-# CONFIG_INPUT is not set
-
-#
-# Userland interfaces
-#
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-CONFIG_SERIO_I8042=y
-CONFIG_SERIO_SERPORT=y
-# CONFIG_SERIO_CT82C710 is not set
-
-#
-# Input Device Drivers
-#
-
-#
-# Macintosh device drivers
-#
-
-#
-# Character devices
-#
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_8250 is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=256
-
-#
-# I2C support
-#
-CONFIG_I2C=y
-# CONFIG_I2C_ALGOBIT is not set
-# CONFIG_I2C_ALGOPCF is not set
-# CONFIG_I2C_IBM_OCP_ALGO is not set
-CONFIG_I2C_CHARDEV=y
-
-#
-# I2C Hardware Sensors Mainboard support
-#
-# CONFIG_I2C_ALI15X3 is not set
-# CONFIG_I2C_AMD756 is not set
-# CONFIG_I2C_AMD8111 is not set
-# CONFIG_I2C_I801 is not set
-# CONFIG_I2C_PIIX4 is not set
-# CONFIG_I2C_SIS96X is not set
-# CONFIG_I2C_VIAPRO is not set
-
-#
-# I2C Hardware Sensors Chip support
-#
-# CONFIG_SENSORS_ADM1021 is not set
-# CONFIG_SENSORS_IT87 is not set
-# CONFIG_SENSORS_LM75 is not set
-# CONFIG_SENSORS_LM85 is not set
-# CONFIG_SENSORS_VIA686A is not set
-# CONFIG_SENSORS_W83781D is not set
-# CONFIG_I2C_SENSOR is not set
-
-#
-# Mice
-#
-CONFIG_BUSMOUSE=y
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-CONFIG_WATCHDOG=y
-# CONFIG_WATCHDOG_NOWAYOUT is not set
-# CONFIG_SOFT_WATCHDOG is not set
-# CONFIG_WDT is not set
-# CONFIG_WDTPCI is not set
-# CONFIG_PCWATCHDOG is not set
-# CONFIG_ACQUIRE_WDT is not set
-# CONFIG_ADVANTECH_WDT is not set
-# CONFIG_EUROTECH_WDT is not set
-# CONFIG_IB700_WDT is not set
-# CONFIG_MIXCOMWD is not set
-# CONFIG_SCx200_WDT is not set
-# CONFIG_60XX_WDT is not set
-# CONFIG_W83877F_WDT is not set
-# CONFIG_MACHZ_WDT is not set
-# CONFIG_SC520_WDT is not set
-# CONFIG_AMD7XX_TCO is not set
-# CONFIG_ALIM7101_WDT is not set
-# CONFIG_SC1200_WDT is not set
-# CONFIG_WAFER_WDT is not set
-# CONFIG_CPU5_WDT is not set
-# CONFIG_NVRAM is not set
-CONFIG_GEN_RTC=y
-# CONFIG_GEN_RTC_X is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-# CONFIG_HANGCHECK_TIMER is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-CONFIG_AUTOFS_FS=y
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-CONFIG_ISO9660_FS=y
-# CONFIG_JOLIET is not set
-# CONFIG_ZISOFS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-# CONFIG_DEVFS_FS is not set
-CONFIG_DEVPTS_FS=y
-# CONFIG_DEVPTS_FS_XATTR is not set
-CONFIG_TMPFS=y
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-CONFIG_NFSD=y
-# CONFIG_NFSD_V3 is not set
-# CONFIG_NFSD_TCP is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-CONFIG_EXPORTFS=y
-CONFIG_SUNRPC=y
-# CONFIG_SUNRPC_GSS is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# IBM 40x options
-#
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-# CONFIG_USB_GADGET is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# Library routines
-#
-# CONFIG_CRC32 is not set
-
-#
-# Kernel hacking
-#
-# CONFIG_DEBUG_KERNEL is not set
-# CONFIG_KALLSYMS is not set
-# CONFIG_SERIAL_TEXT_DEBUG is not set
-CONFIG_OCP=y
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
diff --git a/arch/ppc/configs/redwood_defconfig b/arch/ppc/configs/redwood_defconfig
deleted file mode 100644 (file)
index 4aa348d..0000000
+++ /dev/null
@@ -1,540 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MMU=y
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
-CONFIG_HAVE_DEC_LOCK=y
-CONFIG_PPC=y
-CONFIG_PPC32=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-# CONFIG_STANDALONE is not set
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_IKCONFIG is not set
-CONFIG_EMBEDDED=y
-# CONFIG_KALLSYMS is not set
-CONFIG_FUTEX=y
-# CONFIG_EPOLL is not set
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODULE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-# CONFIG_MODVERSIONS is not set
-CONFIG_KMOD=y
-
-#
-# Processor
-#
-# CONFIG_6xx is not set
-CONFIG_40x=y
-# CONFIG_44x is not set
-# CONFIG_POWER3 is not set
-# CONFIG_POWER4 is not set
-# CONFIG_8xx is not set
-# CONFIG_MATH_EMULATION is not set
-# CONFIG_CPU_FREQ is not set
-CONFIG_4xx=y
-
-#
-# IBM 4xx options
-#
-# CONFIG_ASH is not set
-# CONFIG_BEECH is not set
-# CONFIG_CEDAR is not set
-# CONFIG_CPCI405 is not set
-# CONFIG_EP405 is not set
-# CONFIG_OAK is not set
-CONFIG_REDWOOD_4=y
-# CONFIG_REDWOOD_5 is not set
-# CONFIG_REDWOOD_6 is not set
-# CONFIG_SYCAMORE is not set
-# CONFIG_TIVO is not set
-# CONFIG_WALNUT is not set
-CONFIG_IBM405_ERR77=y
-CONFIG_IBM405_ERR51=y
-CONFIG_IBM_OCP=y
-CONFIG_STB03xxx=y
-CONFIG_IBM_OPENBIOS=y
-# CONFIG_405_DMA is not set
-# CONFIG_PM is not set
-CONFIG_UART0_TTYS0=y
-# CONFIG_UART0_TTYS1 is not set
-# CONFIG_SERIAL_SICC is not set
-CONFIG_NOT_COHERENT_CACHE=y
-
-#
-# Platform options
-#
-# CONFIG_PC_KEYBOARD is not set
-# CONFIG_SMP is not set
-# CONFIG_PREEMPT is not set
-# CONFIG_HIGHMEM is not set
-CONFIG_KERNEL_ELF=y
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_CMDLINE_BOOL is not set
-
-#
-# Bus options
-#
-# CONFIG_PCI is not set
-# CONFIG_PCI_DOMAINS is not set
-# CONFIG_HOTPLUG is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Advanced setup
-#
-# CONFIG_ADVANCED_OPTIONS is not set
-
-#
-# Default settings for advanced configuration options are used
-#
-CONFIG_HIGHMEM_START=0xfe000000
-CONFIG_LOWMEM_SIZE=0x30000000
-CONFIG_KERNEL_START=0xc0000000
-CONFIG_TASK_SIZE=0x80000000
-CONFIG_BOOT_LOAD=0x00400000
-
-#
-# Generic Driver Options
-#
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Plug and Play support
-#
-# CONFIG_PNP is not set
-
-#
-# Block devices
-#
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_INITRD=y
-# CONFIG_LBD is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# I2O device support
-#
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-# CONFIG_PACKET is not set
-# CONFIG_NETLINK_DEV is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-CONFIG_IP_PNP_BOOTP=y
-CONFIG_IP_PNP_RARP=y
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_IP_MROUTE is not set
-# CONFIG_ARPD is not set
-# CONFIG_INET_ECN is not set
-CONFIG_SYN_COOKIES=y
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_IPV6 is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-CONFIG_IPV6_SCTP__=y
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
-CONFIG_OAKNET=y
-
-#
-# Ethernet (1000 Mbit)
-#
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_SHAPER is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN_BOOL is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-# CONFIG_INPUT_MOUSEDEV is not set
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-# CONFIG_SERIO_I8042 is not set
-# CONFIG_SERIO_SERPORT is not set
-# CONFIG_SERIO_CT82C710 is not set
-
-#
-# Input Device Drivers
-#
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Macintosh device drivers
-#
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_SERIAL_8250_NR_UARTS=4
-# CONFIG_SERIAL_8250_EXTENDED is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-# CONFIG_UNIX98_PTYS is not set
-
-#
-# I2C support
-#
-CONFIG_I2C=y
-# CONFIG_I2C_CHARDEV is not set
-
-#
-# I2C Algorithms
-#
-# CONFIG_I2C_ALGOBIT is not set
-# CONFIG_I2C_ALGOPCF is not set
-
-#
-# I2C Hardware Bus support
-#
-# CONFIG_I2C_AMD756 is not set
-# CONFIG_I2C_AMD8111 is not set
-CONFIG_I2C_IBM_IIC=y
-
-#
-# I2C Hardware Sensors Chip support
-#
-# CONFIG_I2C_SENSOR is not set
-# CONFIG_SENSORS_ADM1021 is not set
-# CONFIG_SENSORS_EEPROM is not set
-# CONFIG_SENSORS_IT87 is not set
-# CONFIG_SENSORS_LM75 is not set
-# CONFIG_SENSORS_LM78 is not set
-# CONFIG_SENSORS_LM85 is not set
-# CONFIG_SENSORS_VIA686A is not set
-# CONFIG_SENSORS_W83781D is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_NVRAM is not set
-CONFIG_GEN_RTC=y
-# CONFIG_GEN_RTC_X is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-CONFIG_EXT3_FS=y
-CONFIG_EXT3_FS_XATTR=y
-# CONFIG_EXT3_FS_POSIX_ACL is not set
-# CONFIG_EXT3_FS_SECURITY is not set
-CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=y
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-# CONFIG_DEVFS_FS is not set
-CONFIG_TMPFS=y
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-# CONFIG_EXPORTFS is not set
-CONFIG_SUNRPC=y
-# CONFIG_SUNRPC_GSS is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# IBM 40x options
-#
-
-#
-# USB support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# Library routines
-#
-CONFIG_CRC32=y
-
-#
-# Kernel hacking
-#
-# CONFIG_DEBUG_KERNEL is not set
-CONFIG_SERIAL_TEXT_DEBUG=y
-CONFIG_OCP=y
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
index 468721d9ebd214c1048f9b293f0fa3d9a56d807d..bd037caa40559e0e79409e7ac9d5a4130ee32afd 100644 (file)
@@ -249,8 +249,11 @@ END_FTR_SECTION_IFSET(CPU_FTR_NO_DPM)
        sync
        isync
 
-       /* Enable L2 HW prefetch
+       /* Enable L2 HW prefetch, if L2 is enabled
         */
+       mfspr   r3,SPRN_L2CR
+       andis.  r3,r3,L2CR_L2E@h
+       beqlr
        mfspr   r3,SPRN_MSSCR0
        ori     r3,r3,3
        sync
@@ -324,6 +327,7 @@ _GLOBAL(__save_cpu_setup)
        cmplwi  cr4,r3,0x8002   /* 7457 */
        cmplwi  cr5,r3,0x8003   /* 7447A */
        cmplwi  cr6,r3,0x7000   /* 750FX */
+       cmplwi  cr7,r3,0x8004   /* 7448 */
        /* cr1 is 7400 || 7410 */
        cror    4*cr1+eq,4*cr1+eq,4*cr2+eq
        /* cr0 is 74xx */
@@ -331,6 +335,7 @@ _GLOBAL(__save_cpu_setup)
        cror    4*cr0+eq,4*cr0+eq,4*cr4+eq
        cror    4*cr0+eq,4*cr0+eq,4*cr1+eq
        cror    4*cr0+eq,4*cr0+eq,4*cr5+eq
+       cror    4*cr0+eq,4*cr0+eq,4*cr7+eq
        bne     1f
        /* Backup 74xx specific regs */
        mfspr   r4,SPRN_MSSCR0
@@ -393,6 +398,7 @@ _GLOBAL(__restore_cpu_setup)
        cmplwi  cr4,r3,0x8002   /* 7457 */
        cmplwi  cr5,r3,0x8003   /* 7447A */
        cmplwi  cr6,r3,0x7000   /* 750FX */
+       cmplwi  cr7,r3,0x8004   /* 7448 */
        /* cr1 is 7400 || 7410 */
        cror    4*cr1+eq,4*cr1+eq,4*cr2+eq
        /* cr0 is 74xx */
@@ -400,6 +406,7 @@ _GLOBAL(__restore_cpu_setup)
        cror    4*cr0+eq,4*cr0+eq,4*cr4+eq
        cror    4*cr0+eq,4*cr0+eq,4*cr1+eq
        cror    4*cr0+eq,4*cr0+eq,4*cr5+eq
+       cror    4*cr0+eq,4*cr0+eq,4*cr7+eq
        bne     2f
        /* Restore 74xx specific regs */
        lwz     r4,CS_MSSCR0(r5)
index 8a3d74f2531e840a3a31717cbee94e24ab530baf..546e1ea4cafa31a6bb126dfce2fdcbde2e3fe6d3 100644 (file)
@@ -198,10 +198,10 @@ struct cpu_spec   cpu_specs[] = {
                .num_pmcs               = 4,
                .cpu_setup              = __setup_cpu_750
        },
-       {       /* 745/755 */
-               .pvr_mask               = 0xfffff000,
-               .pvr_value              = 0x00083000,
-               .cpu_name               = "745/755",
+       {       /* 750CX (80100 and 8010x?) */
+               .pvr_mask               = 0xfffffff0,
+               .pvr_value              = 0x00080100,
+               .cpu_name               = "750CX",
                .cpu_features           = CPU_FTR_COMMON |
                        CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
                        CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_TAU |
@@ -210,11 +210,11 @@ struct cpu_spec   cpu_specs[] = {
                .icache_bsize           = 32,
                .dcache_bsize           = 32,
                .num_pmcs               = 4,
-               .cpu_setup              = __setup_cpu_750
+               .cpu_setup              = __setup_cpu_750cx
        },
-       {       /* 750CX (80100 and 8010x?) */
+       {       /* 750CX (82201 and 82202) */
                .pvr_mask               = 0xfffffff0,
-               .pvr_value              = 0x00080100,
+               .pvr_value              = 0x00082200,
                .cpu_name               = "750CX",
                .cpu_features           = CPU_FTR_COMMON |
                        CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
@@ -226,10 +226,10 @@ struct cpu_spec   cpu_specs[] = {
                .num_pmcs               = 4,
                .cpu_setup              = __setup_cpu_750cx
        },
-       {       /* 750CX (82201 and 82202) */
+       {       /* 750CXe (82214) */
                .pvr_mask               = 0xfffffff0,
-               .pvr_value              = 0x00082200,
-               .cpu_name               = "750CX",
+               .pvr_value              = 0x00082210,
+               .cpu_name               = "750CXe",
                .cpu_features           = CPU_FTR_COMMON |
                        CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
                        CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_TAU |
@@ -240,9 +240,9 @@ struct cpu_spec     cpu_specs[] = {
                .num_pmcs               = 4,
                .cpu_setup              = __setup_cpu_750cx
        },
-       {       /* 750CXe (82214) */
-               .pvr_mask               = 0xfffffff0,
-               .pvr_value              = 0x00082210,
+       {       /* 750CXe "Gekko" (83214) */
+               .pvr_mask               = 0xffffffff,
+               .pvr_value              = 0x00083214,
                .cpu_name               = "750CXe",
                .cpu_features           = CPU_FTR_COMMON |
                        CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
@@ -254,6 +254,20 @@ struct cpu_spec    cpu_specs[] = {
                .num_pmcs               = 4,
                .cpu_setup              = __setup_cpu_750cx
        },
+       {       /* 745/755 */
+               .pvr_mask               = 0xfffff000,
+               .pvr_value              = 0x00083000,
+               .cpu_name               = "745/755",
+               .cpu_features           = CPU_FTR_COMMON |
+                       CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
+                       CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_TAU |
+                       CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP,
+               .cpu_user_features      = COMMON_PPC,
+               .icache_bsize           = 32,
+               .dcache_bsize           = 32,
+               .num_pmcs               = 4,
+               .cpu_setup              = __setup_cpu_750
+       },
        {       /* 750FX rev 1.x */
                .pvr_mask               = 0xffffff00,
                .pvr_value              = 0x70000100,
@@ -536,6 +550,22 @@ struct cpu_spec    cpu_specs[] = {
                .num_pmcs               = 6,
                .cpu_setup              = __setup_cpu_745x
        },
+       {       /* 7448 */
+               .pvr_mask               = 0xffff0000,
+               .pvr_value              = 0x80040000,
+               .cpu_name               = "7448",
+               .cpu_features           = CPU_FTR_COMMON |
+                       CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
+                       CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR |
+                       CPU_FTR_ALTIVEC_COMP | CPU_FTR_HPTE_TABLE |
+                       CPU_FTR_SPEC7450 | CPU_FTR_NAP_DISABLE_L2_PR |
+                       CPU_FTR_HAS_HIGH_BATS | CPU_FTR_NEED_COHERENT,
+               .cpu_user_features      = COMMON_PPC | PPC_FEATURE_ALTIVEC_COMP,
+               .icache_bsize           = 32,
+               .dcache_bsize           = 32,
+               .num_pmcs               = 6,
+               .cpu_setup              = __setup_cpu_745x
+       },
        {       /* 82xx (8240, 8245, 8260 are all 603e cores) */
                .pvr_mask               = 0x7fff0000,
                .pvr_value              = 0x00810000,
@@ -922,6 +952,26 @@ struct cpu_spec    cpu_specs[] = {
                .icache_bsize           = 32,
                .dcache_bsize           = 32,
        },
+       { /* 440GX Rev. F */
+               .pvr_mask               = 0xf0000fff,
+               .pvr_value              = 0x50000894,
+               .cpu_name               = "440GX Rev. F",
+               .cpu_features           = CPU_FTR_SPLIT_ID_CACHE |
+                       CPU_FTR_USE_TB,
+               .cpu_user_features      = PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
+               .icache_bsize           = 32,
+               .dcache_bsize           = 32,
+       },
+       { /* 440SP Rev. A */
+               .pvr_mask               = 0xff000fff,
+               .pvr_value              = 0x53000891,
+               .cpu_name               = "440SP Rev. A",
+               .cpu_features           = CPU_FTR_SPLIT_ID_CACHE |
+                       CPU_FTR_USE_TB,
+               .cpu_user_features      = PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
+               .icache_bsize           = 32,
+               .dcache_bsize           = 32,
+       },
 #endif /* CONFIG_44x */
 #ifdef CONFIG_FSL_BOOKE
        {       /* e200z5 */
diff --git a/arch/ppc/kernel/find_name.c b/arch/ppc/kernel/find_name.c
deleted file mode 100644 (file)
index 3c0fa8e..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#include <stdio.h>
-#include <asm/page.h>
-#include <sys/mman.h>
-#include <strings.h>
-/*
- * Finds a given address in the System.map and prints it out
- * with its neighbors.  -- Cort
- */
-
-int main(int argc, char **argv)
-{
-       unsigned long addr, cmp, i;
-       FILE *f;
-       char s[256], last[256];
-       
-       if ( argc < 2 )
-       {
-               fprintf(stderr, "Usage: %s <address>\n", argv[0]);
-               return -1;
-       }
-
-       for ( i = 1 ; argv[i] ; i++ )
-       {
-               sscanf( argv[i], "%0lx", &addr );
-               /* adjust if addr is relative to kernelbase */
-               if ( addr < PAGE_OFFSET )
-                       addr += PAGE_OFFSET;
-               
-               if ( (f = fopen( "System.map", "r" )) == NULL )
-               {
-                       perror("fopen()\n");
-                       exit(-1);
-               }
-               
-               while ( !feof(f) )
-               {
-                       fgets(s, 255 , f);
-                       sscanf( s, "%0lx", &cmp );
-                       if ( addr < cmp )
-                               break;
-                       strcpy( last, s);
-               }
-               
-               printf( "%s%s", last, s );
-       }               
-       fclose(f);
-       return 0;
-}
index 69ff3a9961e8728d061e258c0b7121a0aa71e97c..9e68e32edb6065a25a9d90a2710ee1cd61b26c7b 100644 (file)
@@ -462,7 +462,11 @@ interrupt_base:
 
        /* Watchdog Timer Interrupt */
        /* TODO: Add watchdog support */
+#ifdef CONFIG_BOOKE_WDT
+       CRITICAL_EXCEPTION(0x1020, WatchdogTimer, WatchdogException)
+#else
        CRITICAL_EXCEPTION(0x1020, WatchdogTimer, UnknownException)
+#endif
 
        /* Data TLB Error Interrupt */
        START_EXCEPTION(DataTLBError)
index 23fb51819ba5128735dd7bb28edf5085c02b2da2..0a5e723d3be6c820fb116489824e1b963e5b2dcc 100644 (file)
@@ -448,7 +448,9 @@ label:
 
 /* 0x1020 - Watchdog Timer (WDT) Exception
 */
-
+#ifdef CONFIG_BOOKE_WDT
+       CRITICAL_EXCEPTION(0x1020, WDTException, WatchdogException)
+#else
        CRITICAL_EXCEPTION(0x1020, WDTException, UnknownException)
 #endif
 
index eb804b7a3cb21117fbbcf45769aabb3788d0d37c..4028f4c7d97893f0e6785c032f5f469282f30b72 100644 (file)
@@ -564,8 +564,11 @@ interrupt_base:
        EXCEPTION(0x3100, FixedIntervalTimer, UnknownException, EXC_XFER_EE)
 
        /* Watchdog Timer Interrupt */
-       /* TODO: Add watchdog support */
+#ifdef CONFIG_BOOKE_WDT
+       CRITICAL_EXCEPTION(0x3200, WatchdogTimer, WatchdogException)
+#else
        CRITICAL_EXCEPTION(0x3200, WatchdogTimer, UnknownException)
+#endif
 
        /* Data TLB Error Interrupt */
        START_EXCEPTION(DataTLBError)
index c39441048266f7ba918f3793f41fa8588267d309..861115249b3595fcadcb6319fef16e97de96c940 100644 (file)
@@ -156,6 +156,26 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
               The bit moved on the 7450.....
          ****/
 
+BEGIN_FTR_SECTION
+       /* Disable L2 prefetch on some 745x and try to ensure
+        * L2 prefetch engines are idle. As explained by errata
+        * text, we can't be sure they are, we just hope very hard
+        * that well be enough (sic !). At least I noticed Apple
+        * doesn't even bother doing the dcbf's here...
+        */
+       mfspr   r4,SPRN_MSSCR0
+       rlwinm  r4,r4,0,0,29
+       sync
+       mtspr   SPRN_MSSCR0,r4
+       sync
+       isync
+       lis     r4,KERNELBASE@h
+       dcbf    0,r4
+       dcbf    0,r4
+       dcbf    0,r4
+       dcbf    0,r4
+END_FTR_SECTION_IFSET(CPU_FTR_SPEC7450)
+
        /* TODO: use HW flush assist when available */
 
        lis     r4,0x0002
@@ -230,7 +250,16 @@ END_FTR_SECTION_IFSET(CPU_FTR_SPEC7450)
        oris    r3,r3,0x8000
        mtspr   SPRN_L2CR,r3
        sync
-
+       
+       /* Enable L2 HW prefetch on 744x/745x */
+BEGIN_FTR_SECTION
+       mfspr   r3,SPRN_MSSCR0
+       ori     r3,r3,3
+       sync
+       mtspr   SPRN_MSSCR0,r3
+       sync
+       isync
+END_FTR_SECTION_IFSET(CPU_FTR_SPEC7450)
 4:
 
        /* Restore HID0[DPM] to whatever it was before */
index e7d40cc6c1b6fb266a5ab2fe49e72f7046193fc1..88f6bb7b6964ec6ab8ee47c8ab6e0bce7a1cc19b 100644 (file)
@@ -51,9 +51,6 @@
 #include <asm/commproc.h>
 #endif
 
-/* Tell string.h we don't want memcpy etc. as cpp defines */
-#define EXPORT_SYMTAB_STROPS
-
 extern void transfer_to_handler(void);
 extern void do_IRQ(struct pt_regs *regs);
 extern void MachineCheckException(struct pt_regs *regs);
@@ -263,6 +260,7 @@ EXPORT_SYMBOL(__ashrdi3);
 EXPORT_SYMBOL(__ashldi3);
 EXPORT_SYMBOL(__lshrdi3);
 EXPORT_SYMBOL(memcpy);
+EXPORT_SYMBOL(cacheable_memcpy);
 EXPORT_SYMBOL(memset);
 EXPORT_SYMBOL(memmove);
 EXPORT_SYMBOL(memscan);
index 929e5d1cc7fea145ecffdd2e6968b929dde1ebd6..545cfd0fab59969e0c8c2a54de4d4e602cd643c9 100644 (file)
 #include <asm/xmon.h>
 #include <asm/ocp.h>
 
-#if defined(CONFIG_85xx) || defined(CONFIG_83xx) || defined(CONFIG_MPC10X_BRIDGE)
+#define USES_PPC_SYS (defined(CONFIG_85xx) || defined(CONFIG_83xx) || \
+                     defined(CONFIG_MPC10X_BRIDGE) || defined(CONFIG_8260) || \
+                     defined(CONFIG_PPC_MPC52xx))
+
+#if USES_PPC_SYS
 #include <asm/ppc_sys.h>
 #endif
 
@@ -241,7 +245,7 @@ int show_cpuinfo(struct seq_file *m, void *v)
        seq_printf(m, "bogomips\t: %lu.%02lu\n",
                   lpj / (500000/HZ), (lpj / (5000/HZ)) % 100);
 
-#if defined(CONFIG_85xx) || defined(CONFIG_83xx) || defined(CONFIG_MPC10X_BRIDGE)
+#if USES_PPC_SYS
        if (cur_ppc_sys_spec->ppc_sys_name)
                seq_printf(m, "chipset\t\t: %s\n",
                        cur_ppc_sys_spec->ppc_sys_name);
@@ -615,6 +619,26 @@ machine_init(unsigned long r3, unsigned long r4, unsigned long r5,
        if (ppc_md.progress)
                ppc_md.progress("id mach(): done", 0x200);
 }
+#ifdef CONFIG_BOOKE_WDT
+/* Checks wdt=x and wdt_period=xx command-line option */
+int __init early_parse_wdt(char *p)
+{
+       if (p && strncmp(p, "0", 1) != 0)
+              booke_wdt_enabled = 1;
+
+       return 0;
+}
+early_param("wdt", early_parse_wdt);
+
+int __init early_parse_wdt_period (char *p)
+{
+       if (p)
+               booke_wdt_period = simple_strtoul(p, NULL, 0);
+
+       return 0;
+}
+early_param("wdt_period", early_parse_wdt_period);
+#endif /* CONFIG_BOOKE_WDT */
 
 /* Checks "l2cr=xxxx" command-line option */
 int __init ppc_setup_l2cr(char *str)
index 9e6ae5696650259da8212b076ca441f145fd5dbb..d87423d1003a6c1de89d4880aff8aa17c889a1c9 100644 (file)
@@ -904,6 +904,25 @@ void SPEFloatingPointException(struct pt_regs *regs)
 }
 #endif
 
+#ifdef CONFIG_BOOKE_WDT
+/*
+ * Default handler for a Watchdog exception,
+ * spins until a reboot occurs
+ */
+void __attribute__ ((weak)) WatchdogHandler(struct pt_regs *regs)
+{
+       /* Generic WatchdogHandler, implement your own */
+       mtspr(SPRN_TCR, mfspr(SPRN_TCR)&(~TCR_WIE));
+       return;
+}
+
+void WatchdogException(struct pt_regs *regs)
+{
+       printk (KERN_EMERG "PowerPC Book-E Watchdog Exception\n");
+       WatchdogHandler(regs);
+}
+#endif
+
 void __init trap_init(void)
 {
 }
index 33ada72c73302900a8f34a1c69a9763eb59dd6be..f421a4b337f6a96caaafbbd18dc6e7e8c184a6ec 100644 (file)
@@ -560,9 +560,10 @@ void flush_dcache_page(struct page *page)
 void flush_dcache_icache_page(struct page *page)
 {
 #ifdef CONFIG_BOOKE
-       __flush_dcache_icache(kmap(page));
-       kunmap(page);
-#elif CONFIG_8xx
+       void *start = kmap_atomic(page, KM_PPC_SYNC_ICACHE);
+       __flush_dcache_icache(start);
+       kunmap_atomic(start, KM_PPC_SYNC_ICACHE);
+#elif defined(CONFIG_8xx)
        /* On 8xx there is no need to kmap since highmem is not supported */
        __flush_dcache_icache(page_address(page)); 
 #else
index 805dd98908a3cd4e90164f2e0c1cde80d0c8ef5e..76f4476cab44b7803b7a481fb9785a2d78b73027 100644 (file)
@@ -16,11 +16,6 @@ choice
        depends on 40x
        default WALNUT
 
-config ASH
-       bool "Ash"
-       help
-         This option enables support for the IBM NP405H evaluation board.
-
 config BUBINGA
        bool "Bubinga"
        select WANT_EARLY_SERIAL
@@ -37,11 +32,6 @@ config EP405
        help
          This option enables support for the EP405/EP405PC boards.
 
-config OAK
-       bool "Oak"
-       help
-         This option enables support for the IBM 403GCX evaluation board.
-
 config REDWOOD_5
        bool "Redwood-5"
        help
@@ -152,13 +142,13 @@ config IBM440EP_ERR42
 # All 405-based cores up until the 405GPR and 405EP have this errata.
 config IBM405_ERR77
        bool
-       depends on 40x && !403GCX && !405GPR
+       depends on 40x && !403GCX && !405GPR && !405EP
        default y
 
 # All 40x-based cores, up until the 405GPR and 405EP have this errata.
 config IBM405_ERR51
        bool
-       depends on 40x && !405GPR
+       depends on 40x && !405GPR && !405EP
        default y
 
 config BOOKE
@@ -186,6 +176,7 @@ config BIOS_FIXUP
        depends on BUBINGA || EP405 || SYCAMORE || WALNUT
        default y
 
+# OAK doesn't exist but wanted to keep this around for any future 403GCX boards
 config 403GCX
        bool
        depends OAK
index 844c3b5066e8b103f487b1cd14e5f8e0da554721..1dd6d7fd6a9a8b08b25203af8b12a82b48968fa9 100644 (file)
@@ -1,14 +1,12 @@
 #
 # Makefile for the PowerPC 4xx linux kernel.
 
-obj-$(CONFIG_ASH)              += ash.o
 obj-$(CONFIG_BAMBOO)           += bamboo.o
 obj-$(CONFIG_CPCI405)          += cpci405.o
 obj-$(CONFIG_EBONY)            += ebony.o
 obj-$(CONFIG_EP405)            += ep405.o
 obj-$(CONFIG_BUBINGA)          += bubinga.o
 obj-$(CONFIG_LUAN)             += luan.o
-obj-$(CONFIG_OAK)              += oak.o
 obj-$(CONFIG_OCOTEA)           += ocotea.o
 obj-$(CONFIG_REDWOOD_5)                += redwood5.o
 obj-$(CONFIG_REDWOOD_6)                += redwood6.o
diff --git a/arch/ppc/platforms/4xx/ash.c b/arch/ppc/platforms/4xx/ash.c
deleted file mode 100644 (file)
index ce29117..0000000
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * arch/ppc/platforms/4xx/ash.c
- *
- * Support for the IBM NP405H ash eval board
- *
- * Author: Armin Kuster <akuster@mvista.com>
- *
- * 2001-2002 (c) MontaVista, Software, Inc.  This file is licensed under
- * the terms of the GNU General Public License version 2.  This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/pagemap.h>
-#include <linux/pci.h>
-
-#include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <asm/io.h>
-#include <asm/ocp.h>
-#include <asm/ibm_ocp_pci.h>
-#include <asm/todc.h>
-
-#ifdef DEBUG
-#define DBG(x...) printk(x)
-#else
-#define DBG(x...)
-#endif
-
-void *ash_rtc_base;
-
-/* Some IRQs unique to Walnut.
- * Used by the generic 405 PCI setup functions in ppc4xx_pci.c
- */
-int __init
-ppc405_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
-{
-       static char pci_irq_table[][4] =
-           /*
-            *      PCI IDSEL/INTPIN->INTLINE
-            *      A       B       C       D
-            */
-       {
-               {24, 24, 24, 24},       /* IDSEL 1 - PCI slot 1 */
-               {25, 25, 25, 25},       /* IDSEL 2 - PCI slot 2 */
-               {26, 26, 26, 26},       /* IDSEL 3 - PCI slot 3 */
-               {27, 27, 27, 27},       /* IDSEL 4 - PCI slot 4 */
-       };
-
-       const long min_idsel = 1, max_idsel = 4, irqs_per_slot = 4;
-       return PCI_IRQ_TABLE_LOOKUP;
-}
-
-void __init
-ash_setup_arch(void)
-{
-       ppc4xx_setup_arch();
-
-       ibm_ocp_set_emac(0, 3);
-
-#ifdef CONFIG_DEBUG_BRINGUP
-       int i;
-       printk("\n");
-       printk("machine\t: %s\n", PPC4xx_MACHINE_NAME);
-       printk("\n");
-       printk("bi_s_version\t %s\n", bip->bi_s_version);
-       printk("bi_r_version\t %s\n", bip->bi_r_version);
-       printk("bi_memsize\t 0x%8.8x\t %dMBytes\n", bip->bi_memsize,
-              bip->bi_memsize / (1024 * 1000));
-       for (i = 0; i < EMAC_NUMS; i++) {
-               printk("bi_enetaddr %d\t %2.2x%2.2x%2.2x-%2.2x%2.2x%2.2x\n", i,
-                      bip->bi_enetaddr[i][0], bip->bi_enetaddr[i][1],
-                      bip->bi_enetaddr[i][2], bip->bi_enetaddr[i][3],
-                      bip->bi_enetaddr[i][4], bip->bi_enetaddr[i][5]);
-       }
-       printk("bi_pci_enetaddr %d\t %2.2x%2.2x%2.2x-%2.2x%2.2x%2.2x\n", 0,
-              bip->bi_pci_enetaddr[0], bip->bi_pci_enetaddr[1],
-              bip->bi_pci_enetaddr[2], bip->bi_pci_enetaddr[3],
-              bip->bi_pci_enetaddr[4], bip->bi_pci_enetaddr[5]);
-
-       printk("bi_intfreq\t 0x%8.8x\t clock:\t %dMhz\n",
-              bip->bi_intfreq, bip->bi_intfreq / 1000000);
-
-       printk("bi_busfreq\t 0x%8.8x\t plb bus clock:\t %dMHz\n",
-              bip->bi_busfreq, bip->bi_busfreq / 1000000);
-       printk("bi_pci_busfreq\t 0x%8.8x\t pci bus clock:\t %dMHz\n",
-              bip->bi_pci_busfreq, bip->bi_pci_busfreq / 1000000);
-
-       printk("\n");
-#endif
-       /* RTC step for ash */
-       ash_rtc_base = (void *) ASH_RTC_VADDR;
-       TODC_INIT(TODC_TYPE_DS1743, ash_rtc_base, ash_rtc_base, ash_rtc_base,
-                 8);
-}
-
-void __init
-bios_fixup(struct pci_controller *hose, struct pcil0_regs *pcip)
-{
-       /*
-        * Expected PCI mapping:
-        *
-        *  PLB addr             PCI memory addr
-        *  ---------------------       ---------------------
-        *  0000'0000 - 7fff'ffff <---  0000'0000 - 7fff'ffff
-        *  8000'0000 - Bfff'ffff --->  8000'0000 - Bfff'ffff
-        *
-        *  PLB addr             PCI io addr
-        *  ---------------------       ---------------------
-        *  e800'0000 - e800'ffff --->  0000'0000 - 0001'0000
-        *
-        * The following code is simplified by assuming that the bootrom
-        * has been well behaved in following this mapping.
-        */
-
-#ifdef DEBUG
-       int i;
-
-       printk("ioremap PCLIO_BASE = 0x%x\n", pcip);
-       printk("PCI bridge regs before fixup \n");
-       for (i = 0; i <= 2; i++) {
-               printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].ma)));
-               printk(" pmm%dla\t0x%x\n", i, in_le32(&(pcip->pmm[i].la)));
-               printk(" pmm%dpcila\t0x%x\n", i,
-                      in_le32(&(pcip->pmm[i].pcila)));
-               printk(" pmm%dpciha\t0x%x\n", i,
-                      in_le32(&(pcip->pmm[i].pciha)));
-       }
-       printk(" ptm1ms\t0x%x\n", in_le32(&(pcip->ptm1ms)));
-       printk(" ptm1la\t0x%x\n", in_le32(&(pcip->ptm1la)));
-       printk(" ptm2ms\t0x%x\n", in_le32(&(pcip->ptm2ms)));
-       printk(" ptm2la\t0x%x\n", in_le32(&(pcip->ptm2la)));
-       for (bar = PCI_BASE_ADDRESS_1; bar <= PCI_BASE_ADDRESS_2; bar += 4) {
-               early_read_config_dword(hose, hose->first_busno,
-                                       PCI_FUNC(hose->first_busno), bar,
-                                       &bar_response);
-               DBG("BUS %d, device %d, Function %d bar 0x%8.8x is 0x%8.8x\n",
-                   hose->first_busno, PCI_SLOT(hose->first_busno),
-                   PCI_FUNC(hose->first_busno), bar, bar_response);
-       }
-
-#endif
-       if (ppc_md.progress)
-               ppc_md.progress("bios_fixup(): enter", 0x800);
-
-       /* added for IBM boot rom version 1.15 bios bar changes  -AK */
-
-       /* Disable region first */
-       out_le32((void *) &(pcip->pmm[0].ma), 0x00000000);
-       /* PLB starting addr, PCI: 0x80000000 */
-       out_le32((void *) &(pcip->pmm[0].la), 0x80000000);
-       /* PCI start addr, 0x80000000 */
-       out_le32((void *) &(pcip->pmm[0].pcila), PPC405_PCI_MEM_BASE);
-       /* 512MB range of PLB to PCI */
-       out_le32((void *) &(pcip->pmm[0].pciha), 0x00000000);
-       /* Enable no pre-fetch, enable region */
-       out_le32((void *) &(pcip->pmm[0].ma), ((0xffffffff -
-                                               (PPC405_PCI_UPPER_MEM -
-                                                PPC405_PCI_MEM_BASE)) | 0x01));
-
-       /* Disable region one */
-       out_le32((void *) &(pcip->pmm[1].ma), 0x00000000);
-       out_le32((void *) &(pcip->pmm[1].la), 0x00000000);
-       out_le32((void *) &(pcip->pmm[1].pcila), 0x00000000);
-       out_le32((void *) &(pcip->pmm[1].pciha), 0x00000000);
-       out_le32((void *) &(pcip->pmm[1].ma), 0x00000000);
-
-       /* Disable region two */
-       out_le32((void *) &(pcip->pmm[2].ma), 0x00000000);
-       out_le32((void *) &(pcip->pmm[2].la), 0x00000000);
-       out_le32((void *) &(pcip->pmm[2].pcila), 0x00000000);
-       out_le32((void *) &(pcip->pmm[2].pciha), 0x00000000);
-       out_le32((void *) &(pcip->pmm[2].ma), 0x00000000);
-
-       /* Enable PTM1 and PTM2, mapped to PLB address 0. */
-
-       out_le32((void *) &(pcip->ptm1la), 0x00000000);
-       out_le32((void *) &(pcip->ptm1ms), 0x00000001);
-       out_le32((void *) &(pcip->ptm2la), 0x00000000);
-       out_le32((void *) &(pcip->ptm2ms), 0x00000001);
-
-       /* Write zero to PTM1 BAR. */
-
-       early_write_config_dword(hose, hose->first_busno,
-                                PCI_FUNC(hose->first_busno),
-                                PCI_BASE_ADDRESS_1,
-                                0x00000000);
-
-       /* Disable PTM2 (unused) */
-
-       out_le32((void *) &(pcip->ptm2la), 0x00000000);
-       out_le32((void *) &(pcip->ptm2ms), 0x00000000);
-
-       /* end work arround */
-       if (ppc_md.progress)
-               ppc_md.progress("bios_fixup(): done", 0x800);
-
-#ifdef DEBUG
-       printk("PCI bridge regs after fixup \n");
-       for (i = 0; i <= 2; i++) {
-               printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].ma)));
-               printk(" pmm%dla\t0x%x\n", i, in_le32(&(pcip->pmm[i].la)));
-               printk(" pmm%dpcila\t0x%x\n", i,
-                      in_le32(&(pcip->pmm[i].pcila)));
-               printk(" pmm%dpciha\t0x%x\n", i,
-                      in_le32(&(pcip->pmm[i].pciha)));
-       }
-       printk(" ptm1ms\t0x%x\n", in_le32(&(pcip->ptm1ms)));
-       printk(" ptm1la\t0x%x\n", in_le32(&(pcip->ptm1la)));
-       printk(" ptm2ms\t0x%x\n", in_le32(&(pcip->ptm2ms)));
-       printk(" ptm2la\t0x%x\n", in_le32(&(pcip->ptm2la)));
-
-       for (bar = PCI_BASE_ADDRESS_1; bar <= PCI_BASE_ADDRESS_2; bar += 4) {
-               early_read_config_dword(hose, hose->first_busno,
-                                       PCI_FUNC(hose->first_busno), bar,
-                                       &bar_response);
-               DBG("BUS %d, device %d, Function %d bar 0x%8.8x is 0x%8.8x\n",
-                   hose->first_busno, PCI_SLOT(hose->first_busno),
-                   PCI_FUNC(hose->first_busno), bar, bar_response);
-       }
-
-
-#endif
-}
-
-void __init
-ash_map_io(void)
-{
-       ppc4xx_map_io();
-       io_block_mapping(ASH_RTC_VADDR, ASH_RTC_PADDR, ASH_RTC_SIZE, _PAGE_IO);
-}
-
-void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
-             unsigned long r6, unsigned long r7)
-{
-       ppc4xx_init(r3, r4, r5, r6, r7);
-
-       ppc_md.setup_arch = ash_setup_arch;
-       ppc_md.setup_io_mappings = ash_map_io;
-
-#ifdef CONFIG_PPC_RTC
-       ppc_md.time_init = todc_time_init;
-       ppc_md.set_rtc_time = todc_set_rtc_time;
-       ppc_md.get_rtc_time = todc_get_rtc_time;
-       ppc_md.nvram_read_val = todc_direct_read_val;
-       ppc_md.nvram_write_val = todc_direct_write_val;
-#endif
-}
diff --git a/arch/ppc/platforms/4xx/ash.h b/arch/ppc/platforms/4xx/ash.h
deleted file mode 100644 (file)
index 5f7448e..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * arch/ppc/platforms/4xx/ash.h
- *
- * Macros, definitions, and data structures specific to the IBM PowerPC
- * Ash eval board.
- *
- * Author: Armin Kuster <akuster@mvista.com>
- *
- * 2000-2002 (c) MontaVista, Software, Inc.  This file is licensed under
- * the terms of the GNU General Public License version 2.  This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-
-#ifdef __KERNEL__
-#ifndef __ASM_ASH_H__
-#define __ASM_ASH_H__
-#include <platforms/4xx/ibmnp405h.h>
-
-#ifndef __ASSEMBLY__
-/*
- * Data structure defining board information maintained by the boot
- * ROM on IBM's "Ash" evaluation board. An effort has been made to
- * keep the field names consistent with the 8xx 'bd_t' board info
- * structures.
- */
-
-typedef struct board_info {
-       unsigned char    bi_s_version[4];       /* Version of this structure */
-       unsigned char    bi_r_version[30];      /* Version of the IBM ROM */
-       unsigned int     bi_memsize;            /* DRAM installed, in bytes */
-       unsigned char    bi_enetaddr[4][6];     /* Local Ethernet MAC address */
-       unsigned char    bi_pci_enetaddr[6];
-       unsigned int     bi_intfreq;            /* Processor speed, in Hz */
-       unsigned int     bi_busfreq;            /* PLB Bus speed, in Hz */
-       unsigned int     bi_pci_busfreq;        /* PCI speed in Hz */
-} bd_t;
-
-/* Some 4xx parts use a different timebase frequency from the internal clock.
-*/
-#define bi_tbfreq bi_intfreq
-
-/* Memory map for the IBM "Ash" NP405H evaluation board.
- */
-
-extern  void *ash_rtc_base;
-#define ASH_RTC_PADDR          ((uint)0xf0000000)
-#define ASH_RTC_VADDR          ASH_RTC_PADDR
-#define ASH_RTC_SIZE           ((uint)8*1024)
-
-
-/* Early initialization address mapping for block_io.
- * Standard 405GP map.
- */
-#define PPC4xx_PCI_IO_PADDR    ((uint)PPC405_PCI_PHY_IO_BASE)
-#define PPC4xx_PCI_IO_VADDR    PPC4xx_PCI_IO_PADDR
-#define PPC4xx_PCI_IO_SIZE     ((uint)64*1024)
-#define PPC4xx_PCI_CFG_PADDR   ((uint)PPC405_PCI_CONFIG_ADDR)
-#define PPC4xx_PCI_CFG_VADDR   PPC4xx_PCI_CFG_PADDR
-#define PPC4xx_PCI_CFG_SIZE    ((uint)4*1024)
-#define PPC4xx_PCI_LCFG_PADDR  ((uint)0xef400000)
-#define PPC4xx_PCI_LCFG_VADDR  PPC4xx_PCI_LCFG_PADDR
-#define PPC4xx_PCI_LCFG_SIZE   ((uint)4*1024)
-#define PPC4xx_ONB_IO_PADDR    ((uint)0xef600000)
-#define PPC4xx_ONB_IO_VADDR    PPC4xx_ONB_IO_PADDR
-#define PPC4xx_ONB_IO_SIZE     ((uint)4*1024)
-
-#define NR_BOARD_IRQS 32
-
-#ifdef CONFIG_PPC405GP_INTERNAL_CLOCK
-#define BASE_BAUD              201600
-#else
-#define BASE_BAUD              691200
-#endif
-
-#define PPC4xx_MACHINE_NAME "IBM NP405H Ash"
-
-extern char pci_irq_table[][4];
-
-
-#endif /* !__ASSEMBLY__ */
-#endif /* __ASM_ASH_H__ */
-#endif /* __KERNEL__ */
index f116787b0b76cc1dee4e0583a0681eceaa24e557..ac391d463d78af752e05b3dddff082e1604e6927 100644 (file)
 #include <syslib/gen550.h>
 #include <syslib/ibm440gx_common.h>
 
-/*
- * This is a horrible kludge, we eventually need to abstract this
- * generic PHY stuff, so the  standard phy mode defines can be
- * easily used from arch code.
- */
-#include "../../../../drivers/net/ibm_emac/ibm_emac_phy.h"
-
 bd_t __res;
 
 static struct ibm44x_clocks clocks __initdata;
@@ -123,33 +116,69 @@ bamboo_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
 
 static void __init bamboo_set_emacdata(void)
 {
-       unsigned char * selection1_base;
+       u8 * base_addr;
        struct ocp_def *def;
        struct ocp_func_emac_data *emacdata;
-       u8 selection1_val;
+       u8 val;
        int mode;
+       u32 excluded = 0;
 
-       selection1_base = ioremap64(BAMBOO_FPGA_SELECTION1_REG_ADDR, 16);
-       selection1_val = readb(selection1_base);
-       iounmap((void *) selection1_base);
-       if (BAMBOO_SEL_MII(selection1_val))
+       base_addr = ioremap64(BAMBOO_FPGA_SELECTION1_REG_ADDR, 16);
+       val = readb(base_addr);
+       iounmap((void *) base_addr);
+       if (BAMBOO_SEL_MII(val))
                mode = PHY_MODE_MII;
-       else if (BAMBOO_SEL_RMII(selection1_val))
+       else if (BAMBOO_SEL_RMII(val))
                mode = PHY_MODE_RMII;
        else
                mode = PHY_MODE_SMII;
 
-       /* Set mac_addr and phy mode for each EMAC */
+       /*
+        * SW2 on the Bamboo is used for ethernet configuration and is accessed
+        * via the CONFIG2 register in the FPGA.  If the ANEG pin is set,
+        * overwrite the supported features with the settings in SW2.
+        *
+        * This is used as a workaround for the improperly biased RJ-45 sockets
+        * on the Rev. 0 Bamboo.  By default only 10baseT is functional.
+        * Removing inductors L17 and L18 from the board allows 100baseT, but
+        * disables 10baseT.  The Rev. 1 has no such limitations.
+        */
+
+       base_addr = ioremap64(BAMBOO_FPGA_CONFIG2_REG_ADDR, 8);
+       val = readb(base_addr);
+       iounmap((void *) base_addr);
+       if (!BAMBOO_AUTONEGOTIATE(val)) {
+               excluded |= SUPPORTED_Autoneg;
+               if (BAMBOO_FORCE_100Mbps(val)) {
+                       excluded |= SUPPORTED_10baseT_Full;
+                       excluded |= SUPPORTED_10baseT_Half;
+                       if (BAMBOO_FULL_DUPLEX_EN(val))
+                               excluded |= SUPPORTED_100baseT_Half;
+                       else
+                               excluded |= SUPPORTED_100baseT_Full;
+               } else {
+                       excluded |= SUPPORTED_100baseT_Full;
+                       excluded |= SUPPORTED_100baseT_Half;
+                       if (BAMBOO_FULL_DUPLEX_EN(val))
+                               excluded |= SUPPORTED_10baseT_Half;
+                       else
+                               excluded |= SUPPORTED_10baseT_Full;
+               }
+       }
+
+       /* Set mac_addr, phy mode and unsupported phy features for each EMAC */
 
        def = ocp_get_one_device(OCP_VENDOR_IBM, OCP_FUNC_EMAC, 0);
        emacdata = def->additions;
        memcpy(emacdata->mac_addr, __res.bi_enetaddr, 6);
        emacdata->phy_mode = mode;
+       emacdata->phy_feat_exc = excluded;
 
        def = ocp_get_one_device(OCP_VENDOR_IBM, OCP_FUNC_EMAC, 1);
        emacdata = def->additions;
        memcpy(emacdata->mac_addr, __res.bi_enet1addr, 6);
        emacdata->phy_mode = mode;
+       emacdata->phy_feat_exc = excluded;
 }
 
 static int
index 63d7145041486f1a8206d8aafe57899cb26d4857..5c01928264941ad0a227c38e693a4facd7d4cfe8 100644 (file)
@@ -88,7 +88,7 @@
 #define STD_UART_OP(num)                                       \
        { 0, BASE_BAUD, 0, UART##num##_INT,                     \
                (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST),        \
-               iomem_base: UART##num##_IO_BASE,                \
+               iomem_base: (void*)UART##num##_IO_BASE,         \
                io_type: SERIAL_IO_MEM},
 
 #define SERIAL_PORT_DFNS       \
index 509e69a095f0a43b2ff4069b7995f121bb76e77f..0fd3442f51310318ac15c1d954766854067b391e 100644 (file)
 #include <syslib/gen550.h>
 #include <syslib/ibm440gp_common.h>
 
-/*
- * This is a horrible kludge, we eventually need to abstract this
- * generic PHY stuff, so the  standard phy mode defines can be
- * easily used from arch code.
- */
-#include "../../../../drivers/net/ibm_emac/ibm_emac_phy.h"
-
 bd_t __res;
 
 static struct ibm44x_clocks clocks __initdata;
index 6d44567f4dd215ad6f2554eff26a2d84fc5ca25d..093b28d27a413dbe778be1b7d4b5384e2b94ff88 100644 (file)
@@ -33,6 +33,7 @@ static struct ocp_func_mal_data ibm405ep_mal0_def = {
        .txde_irq       = 13,           /* TX Descriptor Error IRQ */
        .rxde_irq       = 14,           /* RX Descriptor Error IRQ */
        .serr_irq       = 10,           /* MAL System Error IRQ    */
+       .dcr_base       = DCRN_MAL_BASE /* MAL0_CFG DCR number */
 };
 OCP_SYSFS_MAL_DATA()
 
index dfd7ef3ba5f81138fb960b8086ef81cc8614f78f..e5700469a6829092e643a840c7a8b99cb09c9849 100644 (file)
@@ -46,6 +46,7 @@ static struct ocp_func_mal_data ibm405gp_mal0_def = {
        .txde_irq       = 13,           /* TX Descriptor Error IRQ */
        .rxde_irq       = 14,           /* RX Descriptor Error IRQ */
        .serr_irq       = 10,           /* MAL System Error IRQ    */
+       .dcr_base       = DCRN_MAL_BASE /* MAL0_CFG DCR number */
 };
 OCP_SYSFS_MAL_DATA()
 
index 01c8ccbc7214460fe5b06e1905d5432cb16e1899..cd0d00d8e8ee51fb22e8df9619cf571835a977cc 100644 (file)
@@ -42,6 +42,7 @@ static struct ocp_func_mal_data ibm405gpr_mal0_def = {
        .txde_irq       = 13,           /* TX Descriptor Error IRQ */
        .rxde_irq       = 14,           /* RX Descriptor Error IRQ */
        .serr_irq       = 10,           /* MAL System Error IRQ    */
+       .dcr_base       = DCRN_MAL_BASE /* MAL0_CFG DCR number */
 };
 OCP_SYSFS_MAL_DATA()
 
index 284da01f1ffd64d1582461d72953744cbc8422e0..4712de8ff80fd3b750a7f54b9db95578be418c53 100644 (file)
@@ -53,6 +53,7 @@ static struct ocp_func_mal_data ibm440ep_mal0_def = {
        .txde_irq       = 33,           /* TX Descriptor Error IRQ */
        .rxde_irq       = 34,           /* RX Descriptor Error IRQ */
        .serr_irq       = 32,           /* MAL System Error IRQ    */
+       .dcr_base       = DCRN_MAL_BASE /* MAL0_CFG DCR number */
 };
 OCP_SYSFS_MAL_DATA()
 
index 27615ef8309ccf1230421840e00e7b3a7f3646ae..d926245e8b3ebf013e61b1da0831adea976b3018 100644 (file)
@@ -56,6 +56,7 @@ static struct ocp_func_mal_data ibm440gp_mal0_def = {
        .txde_irq       = 33,           /* TX Descriptor Error IRQ */
        .rxde_irq       = 34,           /* RX Descriptor Error IRQ */
        .serr_irq       = 32,           /* MAL System Error IRQ    */
+       .dcr_base       = DCRN_MAL_BASE /* MAL0_CFG DCR number */
 };
 OCP_SYSFS_MAL_DATA()
 
index 1f38f42835b461e6093e64f2f0f0f1970d857b77..956f45e4ef97287b08d1165d3c956834b24dc6f7 100644 (file)
@@ -84,6 +84,7 @@ static struct ocp_func_mal_data ibm440gx_mal0_def = {
        .txde_irq       = 33,           /* TX Descriptor Error IRQ */
        .rxde_irq       = 34,           /* RX Descriptor Error IRQ */
        .serr_irq       = 32,           /* MAL System Error IRQ    */
+       .dcr_base       = DCRN_MAL_BASE /* MAL0_CFG DCR number */
 };
 OCP_SYSFS_MAL_DATA()
 
index fa3e003a0db94b274b9190d3fcf8c22e9fad336c..feb17e41ef6951ae0c28902249893e4c0dcbe4e9 100644 (file)
@@ -43,6 +43,7 @@ static struct ocp_func_mal_data ibm440sp_mal0_def = {
        .txde_irq       = 34,           /* TX Descriptor Error IRQ */
        .rxde_irq       = 35,           /* RX Descriptor Error IRQ */
        .serr_irq       = 33,           /* MAL System Error IRQ    */
+       .dcr_base       = DCRN_MAL_BASE /* MAL0_CFG DCR number */
 };
 OCP_SYSFS_MAL_DATA()
 
index ecdc5be6ae28208cd718963b9a90478e5bda4a17..a477a78f4902956920bfb8d5985f861992e0229f 100644 (file)
@@ -34,7 +34,7 @@ static struct ocp_func_emac_data ibmnp405h_emac1_def = {
        .zmii_mux       = 1,            /* ZMII input of this EMAC */
        .mal_idx        = 0,            /* MAL device index */
        .mal_rx_chan    = 1,            /* MAL rx channel number */
-       .mal_tx_chan    = 1,            /* MAL tx channel number */
+       .mal_tx_chan    = 2,            /* MAL tx channel number */
        .wol_irq        = 41,           /* WOL interrupt number */
        .mdio_idx       = -1,           /* No shared MDIO */
        .tah_idx        = -1,           /* No TAH */
@@ -46,7 +46,7 @@ static struct ocp_func_emac_data ibmnp405h_emac2_def = {
        .zmii_mux       = 2,            /* ZMII input of this EMAC */
        .mal_idx        = 0,            /* MAL device index */
        .mal_rx_chan    = 2,            /* MAL rx channel number */
-       .mal_tx_chan    = 2,            /* MAL tx channel number */
+       .mal_tx_chan    = 4,            /* MAL tx channel number */
        .wol_irq        = 41,           /* WOL interrupt number */
        .mdio_idx       = -1,           /* No shared MDIO */
        .tah_idx        = -1,           /* No TAH */
@@ -58,7 +58,7 @@ static struct ocp_func_emac_data ibmnp405h_emac3_def = {
        .zmii_mux       = 3,            /* ZMII input of this EMAC */
        .mal_idx        = 0,            /* MAL device index */
        .mal_rx_chan    = 3,            /* MAL rx channel number */
-       .mal_tx_chan    = 3,            /* MAL tx channel number */
+       .mal_tx_chan    = 6,            /* MAL tx channel number */
        .wol_irq        = 41,           /* WOL interrupt number */
        .mdio_idx       = -1,           /* No shared MDIO */
        .tah_idx        = -1,           /* No TAH */
@@ -73,6 +73,7 @@ static struct ocp_func_mal_data ibmnp405h_mal0_def = {
        .txde_irq       = 46,           /* TX Descriptor Error IRQ */
        .rxde_irq       = 47,           /* RX Descriptor Error IRQ */
        .serr_irq       = 45,           /* MAL System Error IRQ    */
+       .dcr_base       = DCRN_MAL_BASE /* MAL0_CFG DCR number */
 };
 OCP_SYSFS_MAL_DATA()
 
index 874d16bab73c073b8c90688b1e68b41aca38054f..d90627b68faa5580516d0419fcac699fc3a5e3c8 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/init.h>
 #include <asm/ocp.h>
+#include <asm/ppc4xx_pic.h>
 #include <platforms/4xx/ibmstb4.h>
 
 static struct ocp_func_iic_data ibmstb4_iic0_def = {
@@ -72,12 +73,51 @@ struct ocp_def core_ocp[] __initdata = {
          .irq          = IDE0_IRQ,
          .pm           = OCP_CPM_NA,
        },
-       { .vendor       = OCP_VENDOR_IBM,
-         .function     = OCP_FUNC_USB,
-         .paddr        = USB0_BASE,
-         .irq          = USB0_IRQ,
-         .pm           = OCP_CPM_NA,
-       },
        { .vendor       = OCP_VENDOR_INVALID,
        }
 };
+
+/* Polarity and triggering settings for internal interrupt sources */
+struct ppc4xx_uic_settings ppc4xx_core_uic_cfg[] __initdata = {
+       { .polarity     = 0x7fffff01,
+         .triggering   = 0x00000000,
+         .ext_irq_mask = 0x0000007e,   /* IRQ0 - IRQ5 */
+       }
+};
+
+static struct resource ohci_usb_resources[] = {
+       [0] = {
+               .start  = USB0_BASE,
+               .end    = USB0_BASE + USB0_SIZE - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = USB0_IRQ,
+               .end    = USB0_IRQ,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static u64 dma_mask = 0xffffffffULL;
+
+static struct platform_device ohci_usb_device = {
+       .name           = "ppc-soc-ohci",
+       .id             = 0,
+       .num_resources  = ARRAY_SIZE(ohci_usb_resources),
+       .resource       = ohci_usb_resources,
+       .dev            = {
+               .dma_mask = &dma_mask,
+               .coherent_dma_mask = 0xffffffffULL,
+       }
+};
+
+static struct platform_device *ibmstb4_devs[] __initdata = {
+       &ohci_usb_device,
+};
+
+static int __init
+ibmstb4_platform_add_devices(void)
+{
+       return platform_add_devices(ibmstb4_devs, ARRAY_SIZE(ibmstb4_devs));
+}
+arch_initcall(ibmstb4_platform_add_devices);
index bcb4b1ee71f2677b60375c2272c395f0563734ef..9f21d4c88a3d21a84d8b721b29315bbab49cc2b4 100644 (file)
@@ -73,9 +73,9 @@
 #define OPB0_BASE      0x40000000
 #define GPIO0_BASE     0x40060000
 
+#define USB0_BASE      0x40010000
+#define USB0_SIZE      0xA0
 #define USB0_IRQ       18
-#define USB0_BASE      STB04xxx_MAP_IO_ADDR(0x40010000)
-#define USB0_EXTENT 4096
 
 #define IIC_NUMS 2
 #define UART_NUMS      3
index 95359f748e7b4374fa5a0a8f4d51b950919fe79d..a38e6f9ef858ae78db73688c3a80b52d217303da 100644 (file)
 #include <syslib/ibm440gx_common.h>
 #include <syslib/ibm440sp_common.h>
 
-/*
- * This is a horrible kludge, we eventually need to abstract this
- * generic PHY stuff, so the  standard phy mode defines can be
- * easily used from arch code.
- */
-#include "../../../../drivers/net/ibm_emac/ibm_emac_phy.h"
-
 bd_t __res;
 
 static struct ibm44x_clocks clocks __initdata;
index 09b444c8781638a97d86cd9ded72e64b6d1872ff..bbe7d0766db8acde12b746af50e67c6d6e0f735a 100644 (file)
@@ -55,7 +55,7 @@
 #define STD_UART_OP(num)                                       \
        { 0, BASE_BAUD, 0, UART##num##_INT,                     \
                (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST),        \
-               iomem_base: UART##num##_IO_BASE,                \
+               iomem_base: (void*)UART##num##_IO_BASE,         \
                io_type: SERIAL_IO_MEM},
 
 #define SERIAL_PORT_DFNS       \
diff --git a/arch/ppc/platforms/4xx/oak.c b/arch/ppc/platforms/4xx/oak.c
deleted file mode 100644 (file)
index fa25ee1..0000000
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- *
- *    Copyright (c) 1999-2000 Grant Erickson <grant@lcse.umn.edu>
- *
- *    Module name: oak.c
- *
- *    Description:
- *      Architecture- / platform-specific boot-time initialization code for
- *      the IBM PowerPC 403GCX "Oak" evaluation board. Adapted from original
- *      code by Gary Thomas, Cort Dougan <cort@fsmlabs.com>, and Dan Malek
- *      <dan@net4x.com>.
- *
- */
-
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/smp.h>
-#include <linux/threads.h>
-#include <linux/param.h>
-#include <linux/string.h>
-#include <linux/initrd.h>
-#include <linux/irq.h>
-#include <linux/seq_file.h>
-
-#include <asm/board.h>
-#include <asm/machdep.h>
-#include <asm/page.h>
-#include <asm/bootinfo.h>
-#include <asm/ppc4xx_pic.h>
-#include <asm/time.h>
-
-#include "oak.h"
-
-/* Function Prototypes */
-
-extern void abort(void);
-
-/* Global Variables */
-
-unsigned char __res[sizeof(bd_t)];
-
-
-/*
- * void __init oak_init()
- *
- * Description:
- *   This routine...
- *
- * Input(s):
- *   r3 - Optional pointer to a board information structure.
- *   r4 - Optional pointer to the physical starting address of the init RAM
- *        disk.
- *   r5 - Optional pointer to the physical ending address of the init RAM
- *        disk.
- *   r6 - Optional pointer to the physical starting address of any kernel
- *        command-line parameters.
- *   r7 - Optional pointer to the physical ending address of any kernel
- *        command-line parameters.
- *
- * Output(s):
- *   N/A
- *
- * Returns:
- *   N/A
- *
- */
-void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
-             unsigned long r6, unsigned long r7)
-{
-       parse_bootinfo(find_bootinfo());
-
-       /*
-        * If we were passed in a board information, copy it into the
-        * residual data area.
-        */
-       if (r3) {
-               memcpy((void *)__res, (void *)(r3 + KERNELBASE), sizeof(bd_t));
-       }
-
-#if defined(CONFIG_BLK_DEV_INITRD)
-       /*
-        * If the init RAM disk has been configured in, and there's a valid
-        * starting address for it, set it up.
-        */
-       if (r4) {
-               initrd_start = r4 + KERNELBASE;
-               initrd_end = r5 + KERNELBASE;
-       }
-#endif /* CONFIG_BLK_DEV_INITRD */
-
-       /* Copy the kernel command line arguments to a safe place. */
-
-       if (r6) {
-               *(char *)(r7 + KERNELBASE) = 0;
-               strcpy(cmd_line, (char *)(r6 + KERNELBASE));
-       }
-
-       /* Initialize machine-dependency vectors */
-
-       ppc_md.setup_arch               = oak_setup_arch;
-       ppc_md.show_percpuinfo          = oak_show_percpuinfo;
-       ppc_md.irq_canonicalize         = NULL;
-       ppc_md.init_IRQ                 = ppc4xx_pic_init;
-       ppc_md.get_irq                  = NULL;  /* Set in ppc4xx_pic_init() */
-       ppc_md.init                     = NULL;
-
-       ppc_md.restart                  = oak_restart;
-       ppc_md.power_off                = oak_power_off;
-       ppc_md.halt                     = oak_halt;
-
-       ppc_md.time_init                = oak_time_init;
-       ppc_md.set_rtc_time             = oak_set_rtc_time;
-       ppc_md.get_rtc_time             = oak_get_rtc_time;
-       ppc_md.calibrate_decr           = oak_calibrate_decr;
-}
-
-/*
- * Document me.
- */
-void __init
-oak_setup_arch(void)
-{
-       /* XXX - Implement me */
-}
-
-/*
- * int oak_show_percpuinfo()
- *
- * Description:
- *   This routine pretty-prints the platform's internal CPU and bus clock
- *   frequencies into the buffer for usage in /proc/cpuinfo.
- *
- * Input(s):
- *  *buffer - Buffer into which CPU and bus clock frequencies are to be
- *            printed.
- *
- * Output(s):
- *  *buffer - Buffer with the CPU and bus clock frequencies.
- *
- * Returns:
- *   The number of bytes copied into 'buffer' if OK, otherwise zero or less
- *   on error.
- */
-int
-oak_show_percpuinfo(struct seq_file *m, int i)
-{
-       bd_t *bp = (bd_t *)__res;
-
-       seq_printf(m, "clock\t\t: %dMHz\n"
-                  "bus clock\t\t: %dMHz\n",
-                  bp->bi_intfreq / 1000000,
-                  bp->bi_busfreq / 1000000);
-
-       return 0;
-}
-
-/*
- * Document me.
- */
-void
-oak_restart(char *cmd)
-{
-       abort();
-}
-
-/*
- * Document me.
- */
-void
-oak_power_off(void)
-{
-       oak_restart(NULL);
-}
-
-/*
- * Document me.
- */
-void
-oak_halt(void)
-{
-       oak_restart(NULL);
-}
-
-/*
- * Document me.
- */
-long __init
-oak_time_init(void)
-{
-       /* XXX - Implement me */
-       return 0;
-}
-
-/*
- * Document me.
- */
-int __init
-oak_set_rtc_time(unsigned long time)
-{
-       /* XXX - Implement me */
-
-       return (0);
-}
-
-/*
- * Document me.
- */
-unsigned long __init
-oak_get_rtc_time(void)
-{
-       /* XXX - Implement me */
-
-       return (0);
-}
-
-/*
- * void __init oak_calibrate_decr()
- *
- * Description:
- *   This routine retrieves the internal processor frequency from the board
- *   information structure, sets up the kernel timer decrementer based on
- *   that value, enables the 403 programmable interval timer (PIT) and sets
- *   it up for auto-reload.
- *
- * Input(s):
- *   N/A
- *
- * Output(s):
- *   N/A
- *
- * Returns:
- *   N/A
- *
- */
-void __init
-oak_calibrate_decr(void)
-{
-       unsigned int freq;
-       bd_t *bip = (bd_t *)__res;
-
-       freq = bip->bi_intfreq;
-
-       decrementer_count = freq / HZ;
-       count_period_num = 1;
-       count_period_den = freq;
-
-       /* Enable the PIT and set auto-reload of its value */
-
-       mtspr(SPRN_TCR, TCR_PIE | TCR_ARE);
-
-       /* Clear any pending timer interrupts */
-
-       mtspr(SPRN_TSR, TSR_ENW | TSR_WIS | TSR_PIS | TSR_FIS);
-}
diff --git a/arch/ppc/platforms/4xx/oak.h b/arch/ppc/platforms/4xx/oak.h
deleted file mode 100644 (file)
index 1b86a4c..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- *
- *    Copyright (c) 1999 Grant Erickson <grant@lcse.umn.edu>
- *
- *    Module name: oak.h
- *
- *    Description:
- *     Macros, definitions, and data structures specific to the IBM PowerPC
- *      403G{A,B,C,CX} "Oak" evaluation board. Anything specific to the pro-
- *      cessor itself is defined elsewhere.
- *
- */
-
-#ifdef __KERNEL__
-#ifndef __ASM_OAK_H__
-#define __ASM_OAK_H__
-
-/* We have an IBM 403G{A,B,C,CX} core */
-#include <asm/ibm403.h>
-
-#define _IO_BASE       0
-#define _ISA_MEM_BASE  0
-#define PCI_DRAM_OFFSET        0
-
-/* Memory map for the "Oak" evaluation board */
-
-#define        PPC403SPU_IO_BASE       0x40000000      /* 403 On-chip serial port */
-#define        PPC403SPU_IO_SIZE       0x00000008
-#define        OAKSERIAL_IO_BASE       0x7E000000      /* NS16550DV serial port */
-#define        OAKSERIAL_IO_SIZE       0x00000008
-#define        OAKNET_IO_BASE          0xF4000000      /* NS83902AV Ethernet */
-#define        OAKNET_IO_SIZE          0x00000040
-#define        OAKPROM_IO_BASE         0xFFFE0000      /* AMD 29F010 Flash ROM */
-#define        OAKPROM_IO_SIZE         0x00020000
-
-
-/* Interrupt assignments fixed by the hardware implementation */
-
-/* This is annoying kbuild-2.4 problem. -- Tom */
-
-#define        PPC403SPU_RX_INT        4       /* AIC_INT4 */
-#define        PPC403SPU_TX_INT        5       /* AIC_INT5 */
-#define        OAKNET_INT              27      /* AIC_INT27 */
-#define        OAKSERIAL_INT           28      /* AIC_INT28 */
-
-#ifndef __ASSEMBLY__
-/*
- * Data structure defining board information maintained by the boot
- * ROM on IBM's "Oak" evaluation board. An effort has been made to
- * keep the field names consistent with the 8xx 'bd_t' board info
- * structures.
- */
-
-typedef struct board_info {
-       unsigned char    bi_s_version[4];       /* Version of this structure */
-       unsigned char    bi_r_version[30];      /* Version of the IBM ROM */
-       unsigned int     bi_memsize;            /* DRAM installed, in bytes */
-       unsigned char    bi_enetaddr[6];        /* Ethernet MAC address */
-       unsigned int     bi_intfreq;            /* Processor speed, in Hz */
-       unsigned int     bi_busfreq;            /* Bus speed, in Hz */
-} bd_t;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern void             oak_init(unsigned long r3,
-                                 unsigned long ird_start,
-                                 unsigned long ird_end,
-                                 unsigned long cline_start,
-                                 unsigned long cline_end);
-extern void             oak_setup_arch(void);
-extern int              oak_setup_residual(char *buffer);
-extern void             oak_init_IRQ(void);
-extern int              oak_get_irq(struct pt_regs *regs);
-extern void             oak_restart(char *cmd);
-extern void             oak_power_off(void);
-extern void             oak_halt(void);
-extern void             oak_time_init(void);
-extern int              oak_set_rtc_time(unsigned long now);
-extern unsigned long    oak_get_rtc_time(void);
-extern void             oak_calibrate_decr(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-/* Some 4xx parts use a different timebase frequency from the internal clock.
-*/
-#define bi_tbfreq bi_intfreq
-
-#define PPC4xx_MACHINE_NAME    "IBM Oak"
-
-#endif /* !__ASSEMBLY__ */
-#endif /* __ASM_OAK_H__ */
-#endif /* __KERNEL__ */
diff --git a/arch/ppc/platforms/4xx/oak_setup.h b/arch/ppc/platforms/4xx/oak_setup.h
deleted file mode 100644 (file)
index 8648bd0..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- *
- *    Copyright (c) 1999-2000 Grant Erickson <grant@lcse.umn.edu>
- *
- *    Module name: oak_setup.h
- *
- *    Description:
- *      Architecture- / platform-specific boot-time initialization code for
- *      the IBM PowerPC 403GCX "Oak" evaluation board. Adapted from original
- *      code by Gary Thomas, Cort Dougan <cort@cs.nmt.edu>, and Dan Malek
- *      <dan@netx4.com>.
- *
- */
-
-#ifndef        __OAK_SETUP_H__
-#define        __OAK_SETUP_H__
-
-#include <asm/ptrace.h>
-#include <asm/board.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern unsigned char    __res[sizeof(bd_t)];
-
-extern void             oak_init(unsigned long r3,
-                                 unsigned long ird_start,
-                                 unsigned long ird_end,
-                                 unsigned long cline_start,
-                                 unsigned long cline_end);
-extern void             oak_setup_arch(void);
-extern int              oak_setup_residual(char *buffer);
-extern void             oak_init_IRQ(void);
-extern int              oak_get_irq(struct pt_regs *regs);
-extern void             oak_restart(char *cmd);
-extern void             oak_power_off(void);
-extern void             oak_halt(void);
-extern void             oak_time_init(void);
-extern int              oak_set_rtc_time(unsigned long now);
-extern unsigned long    oak_get_rtc_time(void);
-extern void             oak_calibrate_decr(void);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __OAK_SETUP_H__ */
index 8fc34a3447694afc2ebb95c3f5d60357c29fbb7a..80028df1b445b422ece4a9edfc02186b8aced50e 100644 (file)
 #include <syslib/gen550.h>
 #include <syslib/ibm440gx_common.h>
 
-/*
- * This is a horrible kludge, we eventually need to abstract this
- * generic PHY stuff, so the  standard phy mode defines can be
- * easily used from arch code.
- */
-#include "../../../../drivers/net/ibm_emac/ibm_emac_phy.h"
-
 bd_t __res;
 
 static struct ibm44x_clocks clocks __initdata;
index 2f5e410afbc557534ed978a2d51f29595aafc35c..bee8b4ac8afd221ba6c2a1b566249cb934505897 100644 (file)
 #include <linux/ioport.h>
 #include <asm/io.h>
 #include <asm/machdep.h>
+#include <asm/ppc4xx_pic.h>
+
+/*
+ * Define external IRQ senses and polarities.
+ */
+unsigned char ppc4xx_uic_ext_irq_cfg[] __initdata = {
+       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* Ext Int 0 */
+       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* Ext Int 1 */
+       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* Ext Int 2 */
+       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* Ext Int 3 */
+       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* Ext Int 4 */
+       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* Ext Int 5 */
+};
 
 static struct resource smc91x_resources[] = {
        [0] = {
index ddd04d4c1ea9ecb0b95413d6e51fc01b0856fe38..b38a851a64ecc2250a4b1dca23377083e703aeb4 100644 (file)
@@ -62,9 +62,29 @@ extern unsigned long total_memory;   /* in mm/init */
 unsigned char __res[sizeof (bd_t)];
 
 #ifdef CONFIG_PCI
-#error "PCI is not supported"
-/* NEED mpc83xx_map_irq & mpc83xx_exclude_device
-   see platforms/85xx/mpc85xx_ads_common.c */
+int
+mpc83xx_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
+{
+       static char pci_irq_table[][4] =
+           /*
+            *      PCI IDSEL/INTPIN->INTLINE
+            *       A      B      C      D
+            */
+       {
+               {PIRQA, PIRQB,  PIRQC,  PIRQD}, /* idsel 0x11 */
+               {PIRQC, PIRQD,  PIRQA,  PIRQB}, /* idsel 0x12 */
+               {PIRQD, PIRQA,  PIRQB,  PIRQC}  /* idsel 0x13 */
+       };
+
+       const long min_idsel = 0x11, max_idsel = 0x13, irqs_per_slot = 4;
+       return PCI_IRQ_TABLE_LOOKUP;
+}
+
+int
+mpc83xx_exclude_device(u_char bus, u_char devfn)
+{
+       return PCIBIOS_SUCCESSFUL;
+}
 #endif /* CONFIG_PCI */
 
 /* ************************************************************************
@@ -88,7 +108,7 @@ mpc834x_sys_setup_arch(void)
 
 #ifdef CONFIG_PCI
        /* setup PCI host bridges */
-       mpc83xx_sys_setup_hose();
+       mpc83xx_setup_hose();
 #endif
        mpc83xx_early_serial_map();
 
@@ -175,10 +195,17 @@ mpc834x_sys_init_IRQ(void)
                IRQ_SENSE_LEVEL,        /* EXT 1 */
                IRQ_SENSE_LEVEL,        /* EXT 2 */
                0,                      /* EXT 3 */
+#ifdef CONFIG_PCI
+               IRQ_SENSE_LEVEL,        /* EXT 4 */
+               IRQ_SENSE_LEVEL,        /* EXT 5 */
+               IRQ_SENSE_LEVEL,        /* EXT 6 */
+               IRQ_SENSE_LEVEL,        /* EXT 7 */
+#else
                0,                      /* EXT 4 */
                0,                      /* EXT 5 */
                0,                      /* EXT 6 */
                0,                      /* EXT 7 */
+#endif
        };
 
        ipic_init(binfo->bi_immr_base + 0x00700, 0, MPC83xx_IPIC_IRQ_OFFSET, senses, 8);
index a2f6e49d71512946ca5e89e2b7d7ca80fec0f8de..1584cd77a9ef35ecfccba2dd1bd891ec02b6abb9 100644 (file)
@@ -26,7 +26,7 @@
 #define VIRT_IMMRBAR           ((uint)0xfe000000)
 
 #define BCSR_PHYS_ADDR         ((uint)0xf8000000)
-#define BCSR_SIZE              ((uint)(32 * 1024))
+#define BCSR_SIZE              ((uint)(128 * 1024))
 
 #define BCSR_MISC_REG2_OFF     0x07
 #define BCSR_MISC_REG2_PORESET 0x01
 #define BCSR_MISC_REG3_OFF     0x08
 #define BCSR_MISC_REG3_CNFLOCK 0x80
 
-#ifdef CONFIG_PCI
-/* PCI interrupt controller */
-#define PIRQA        MPC83xx_IRQ_IRQ4
-#define PIRQB        MPC83xx_IRQ_IRQ5
-#define PIRQC        MPC83xx_IRQ_IRQ6
-#define PIRQD        MPC83xx_IRQ_IRQ7
-
-#define MPC834x_SYS_PCI1_LOWER_IO        0x00000000
-#define MPC834x_SYS_PCI1_UPPER_IO        0x00ffffff
-
-#define MPC834x_SYS_PCI1_LOWER_MEM       0x80000000
-#define MPC834x_SYS_PCI1_UPPER_MEM       0x9fffffff
-
-#define MPC834x_SYS_PCI1_IO_BASE         0xe2000000
-#define MPC834x_SYS_PCI1_MEM_OFFSET      0x00000000
-
-#define MPC834x_SYS_PCI1_IO_SIZE         0x01000000
-#endif /* CONFIG_PCI */
+#define PIRQA  MPC83xx_IRQ_EXT4
+#define PIRQB  MPC83xx_IRQ_EXT5
+#define PIRQC  MPC83xx_IRQ_EXT6
+#define PIRQD  MPC83xx_IRQ_EXT7
+
+#define MPC83xx_PCI1_LOWER_IO  0x00000000
+#define MPC83xx_PCI1_UPPER_IO  0x00ffffff
+#define MPC83xx_PCI1_LOWER_MEM 0x80000000
+#define MPC83xx_PCI1_UPPER_MEM 0x9fffffff
+#define MPC83xx_PCI1_IO_BASE   0xe2000000
+#define MPC83xx_PCI1_MEM_OFFSET        0x00000000
+#define MPC83xx_PCI1_IO_SIZE   0x01000000
+
+#define MPC83xx_PCI2_LOWER_IO  0x00000000
+#define MPC83xx_PCI2_UPPER_IO  0x00ffffff
+#define MPC83xx_PCI2_LOWER_MEM 0xa0000000
+#define MPC83xx_PCI2_UPPER_MEM 0xbfffffff
+#define MPC83xx_PCI2_IO_BASE   0xe3000000
+#define MPC83xx_PCI2_MEM_OFFSET        0x00000000
+#define MPC83xx_PCI2_IO_SIZE   0x01000000
 
 #endif                /* __MACH_MPC83XX_SYS_H__ */
index 5488a053f4155f2ab733ab8ce259668374341379..ff7452e5d8e511ef79f6e97a8eb38bc9b301ce6c 100644 (file)
@@ -21,22 +21,17 @@ obj-$(CONFIG_CPU_FREQ_PMAC) += pmac_cpufreq.o
 endif
 obj-$(CONFIG_PMAC_BACKLIGHT)   += pmac_backlight.o
 obj-$(CONFIG_PREP_RESIDUAL)    += residual.o
-obj-$(CONFIG_ADIR)             += adir_setup.o adir_pic.o adir_pci.o
 obj-$(CONFIG_PQ2ADS)           += pq2ads.o
 obj-$(CONFIG_TQM8260)          += tqm8260_setup.o
 obj-$(CONFIG_CPCI690)          += cpci690.o
 obj-$(CONFIG_EV64260)          += ev64260.o
 obj-$(CONFIG_CHESTNUT)         += chestnut.o
 obj-$(CONFIG_GEMINI)           += gemini_pci.o gemini_setup.o gemini_prom.o
-obj-$(CONFIG_K2)               += k2.o
 obj-$(CONFIG_LOPEC)            += lopec.o
 obj-$(CONFIG_KATANA)           += katana.o
 obj-$(CONFIG_HDPU)             += hdpu.o
-obj-$(CONFIG_MCPN765)          += mcpn765.o
-obj-$(CONFIG_MENF1)            += menf1_setup.o menf1_pci.o
 obj-$(CONFIG_MVME5100)         += mvme5100.o
 obj-$(CONFIG_PAL4)             += pal4_setup.o pal4_pci.o
-obj-$(CONFIG_PCORE)            += pcore.o
 obj-$(CONFIG_POWERPMC250)      += powerpmc250.o
 obj-$(CONFIG_PPLUS)            += pplus.o
 obj-$(CONFIG_PRPMC750)         += prpmc750.o
@@ -46,6 +41,7 @@ obj-$(CONFIG_SANDPOINT)               += sandpoint.o
 obj-$(CONFIG_SBC82xx)          += sbc82xx.o
 obj-$(CONFIG_SPRUCE)           += spruce.o
 obj-$(CONFIG_LITE5200)         += lite5200.o
+obj-$(CONFIG_EV64360)          += ev64360.o
 
 ifeq ($(CONFIG_SMP),y)
 obj-$(CONFIG_PPC_PMAC)         += pmac_smp.o
diff --git a/arch/ppc/platforms/adir.h b/arch/ppc/platforms/adir.h
deleted file mode 100644 (file)
index 13a748b..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * arch/ppc/platforms/adir.h
- *
- * Definitions for SBS Adirondack board support
- *
- * By Michael Sokolov <msokolov@ivan.Harhan.ORG>
- */
-
-#ifndef __PPC_PLATFORMS_ADIR_H
-#define __PPC_PLATFORMS_ADIR_H
-
-/*
- * SBS Adirondack definitions
- */
-
-/* PPC physical address space layout. We use the one set up by the firmware. */
-#define        ADIR_PCI32_MEM_BASE     0x80000000
-#define        ADIR_PCI32_MEM_SIZE     0x20000000
-#define        ADIR_PCI64_MEM_BASE     0xA0000000
-#define        ADIR_PCI64_MEM_SIZE     0x20000000
-#define        ADIR_PCI32_IO_BASE      0xC0000000
-#define        ADIR_PCI32_IO_SIZE      0x10000000
-#define        ADIR_PCI64_IO_BASE      0xD0000000
-#define        ADIR_PCI64_IO_SIZE      0x10000000
-#define        ADIR_PCI64_PHB          0xFF400000
-#define        ADIR_PCI32_PHB          0xFF500000
-
-#define ADIR_PCI64_CONFIG_ADDR (ADIR_PCI64_PHB + 0x000f8000)
-#define ADIR_PCI64_CONFIG_DATA (ADIR_PCI64_PHB + 0x000f8010)
-
-#define ADIR_PCI32_CONFIG_ADDR (ADIR_PCI32_PHB + 0x000f8000)
-#define ADIR_PCI32_CONFIG_DATA (ADIR_PCI32_PHB + 0x000f8010)
-
-/* System memory as seen from PCI */
-#define ADIR_PCI_SYS_MEM_BASE  0x80000000
-
-/* Static virtual mapping of PCI I/O */
-#define        ADIR_PCI32_VIRT_IO_BASE 0xFE000000
-#define        ADIR_PCI32_VIRT_IO_SIZE 0x01000000
-#define        ADIR_PCI64_VIRT_IO_BASE 0xFF000000
-#define        ADIR_PCI64_VIRT_IO_SIZE 0x01000000
-
-/* Registers */
-#define        ADIR_NVRAM_RTC_ADDR     0x74
-#define        ADIR_NVRAM_RTC_DATA     0x75
-
-#define        ADIR_BOARD_ID_REG       (ADIR_PCI32_VIRT_IO_BASE + 0x08FFF0)
-#define        ADIR_CPLD1REV_REG       (ADIR_PCI32_VIRT_IO_BASE + 0x08FFF1)
-#define        ADIR_CPLD2REV_REG       (ADIR_PCI32_VIRT_IO_BASE + 0x08FFF2)
-#define        ADIR_FLASHCTL_REG       (ADIR_PCI32_VIRT_IO_BASE + 0x08FFF3)
-#define        ADIR_CPC710_STAT_REG    (ADIR_PCI32_VIRT_IO_BASE + 0x08FFF4)
-#define        ADIR_CLOCK_REG          (ADIR_PCI32_VIRT_IO_BASE + 0x08FFF5)
-#define        ADIR_GPIO_REG           (ADIR_PCI32_VIRT_IO_BASE + 0x08FFF8)
-#define        ADIR_MISC_REG           (ADIR_PCI32_VIRT_IO_BASE + 0x08FFF9)
-#define        ADIR_LED_REG            (ADIR_PCI32_VIRT_IO_BASE + 0x08FFFA)
-
-#define        ADIR_CLOCK_REG_PD       0x10
-#define        ADIR_CLOCK_REG_SPREAD   0x08
-#define        ADIR_CLOCK_REG_SEL133   0x04
-#define        ADIR_CLOCK_REG_SEL1     0x02
-#define        ADIR_CLOCK_REG_SEL0     0x01
-
-#define        ADIR_PROCA_INT_MASK     (ADIR_PCI32_VIRT_IO_BASE + 0x0EFFF0)
-#define        ADIR_PROCB_INT_MASK     (ADIR_PCI32_VIRT_IO_BASE + 0x0EFFF2)
-#define        ADIR_PROCA_INT_STAT     (ADIR_PCI32_VIRT_IO_BASE + 0x0EFFF4)
-#define        ADIR_PROCB_INT_STAT     (ADIR_PCI32_VIRT_IO_BASE + 0x0EFFF6)
-
-/* Linux IRQ numbers */
-#define        ADIR_IRQ_NONE           -1
-#define        ADIR_IRQ_SERIAL2        3
-#define        ADIR_IRQ_SERIAL1        4
-#define        ADIR_IRQ_FDC            6
-#define        ADIR_IRQ_PARALLEL       7
-#define        ADIR_IRQ_VIA_AUDIO      10
-#define        ADIR_IRQ_VIA_USB        11
-#define        ADIR_IRQ_IDE0           14
-#define        ADIR_IRQ_IDE1           15
-#define        ADIR_IRQ_PCI0_INTA      16
-#define        ADIR_IRQ_PCI0_INTB      17
-#define        ADIR_IRQ_PCI0_INTC      18
-#define        ADIR_IRQ_PCI0_INTD      19
-#define        ADIR_IRQ_PCI1_INTA      20
-#define        ADIR_IRQ_PCI1_INTB      21
-#define        ADIR_IRQ_PCI1_INTC      22
-#define        ADIR_IRQ_PCI1_INTD      23
-#define        ADIR_IRQ_MBSCSI         24      /* motherboard SCSI */
-#define        ADIR_IRQ_MBETH1         25      /* motherboard Ethernet 1 */
-#define        ADIR_IRQ_MBETH0         26      /* motherboard Ethernet 0 */
-#define        ADIR_IRQ_CPC710_INT1    27
-#define        ADIR_IRQ_CPC710_INT2    28
-#define        ADIR_IRQ_VT82C686_NMI   29
-#define        ADIR_IRQ_VT82C686_INTR  30
-#define        ADIR_IRQ_INTERPROC      31
-
-#endif /* __PPC_PLATFORMS_ADIR_H */
diff --git a/arch/ppc/platforms/adir_pci.c b/arch/ppc/platforms/adir_pci.c
deleted file mode 100644 (file)
index f94ac53..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * arch/ppc/platforms/adir_pci.c
- *
- * PCI support for SBS Adirondack
- *
- * By Michael Sokolov <msokolov@ivan.Harhan.ORG>
- * based on the K2 version by Matt Porter <mporter@mvista.com>
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <linux/slab.h>
-
-#include <asm/byteorder.h>
-#include <asm/io.h>
-#include <asm/uaccess.h>
-#include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-
-#include <syslib/cpc710.h>
-#include "adir.h"
-
-#undef DEBUG
-#ifdef DEBUG
-#define DBG(x...) printk(x)
-#else
-#define DBG(x...)
-#endif /* DEBUG */
-
-static inline int __init
-adir_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
-{
-#define        PCIIRQ(a,b,c,d) {ADIR_IRQ_##a,ADIR_IRQ_##b,ADIR_IRQ_##c,ADIR_IRQ_##d},
-       struct pci_controller *hose = pci_bus_to_hose(dev->bus->number);
-       /*
-        * The three PCI devices on the motherboard have dedicated lines to the
-        * CPLD interrupt controller, bypassing the standard PCI INTA-D and the
-        * PC interrupt controller. All other PCI devices (slots) have usual
-        * staggered INTA-D lines, resulting in 8 lines total (PCI0 INTA-D and
-        * PCI1 INTA-D). All 8 go to the CPLD interrupt controller. PCI0 INTA-D
-        * also go to the south bridge, so we have the option of taking them
-        * via the CPLD interrupt controller or via the south bridge 8259
-        * 8258 thingy. PCI1 INTA-D can only be taken via the CPLD interrupt
-        * controller. We take all PCI interrupts via the CPLD interrupt
-        * controller as recommended by SBS.
-        *
-        * We also have some monkey business with the PCI devices within the
-        * VT82C686B south bridge itself. This chip actually has 7 functions on
-        * its IDSEL. Function 0 is the actual south bridge, function 1 is IDE,
-        * and function 4 is some special stuff. The other 4 functions are just
-        * regular PCI devices bundled in the chip. 2 and 3 are USB UHCIs and 5
-        * and 6 are audio (not supported on the Adirondack).
-        *
-        * This is where the monkey business begins. PCI devices are supposed
-        * to signal normal PCI interrupts. But the 4 functions in question are
-        * located in the south bridge chip, which is designed with the
-        * assumption that it will be fielding PCI INTA-D interrupts rather
-        * than generating them. Here's what it does. Each of the functions in
-        * question routes its interrupt to one of the IRQs on the 8259 thingy.
-        * Which one? It looks at the Interrupt Line register in the PCI config
-        * space, even though the PCI spec says it's for BIOS/OS interaction
-        * only.
-        *
-        * How do we deal with this? We take these interrupts via 8259 IRQs as
-        * we have to. We return the desired IRQ numbers from this routine when
-        * called for the functions in question. The PCI scan code will then
-        * stick our return value into the Interrupt Line register in the PCI
-        * config space, and the interrupt will actually go there. We identify
-        * these functions within the south bridge IDSEL by their interrupt pin
-        * numbers, as the VT82C686B has 04 in the Interrupt Pin register for
-        * USB and 03 for audio.
-        */
-       if (!hose->index) {
-               static char pci_irq_table[][4] =
-               /*
-                *             PCI IDSEL/INTPIN->INTLINE
-                *             A          B          C          D
-                */
-               {
-    /* south bridge */ PCIIRQ(IDE0,      NONE,      VIA_AUDIO, VIA_USB)
-    /* Ethernet 0 */   PCIIRQ(MBETH0,    MBETH0,    MBETH0,    MBETH0)
-    /* PCI0 slot 1 */  PCIIRQ(PCI0_INTB, PCI0_INTC, PCI0_INTD, PCI0_INTA)
-    /* PCI0 slot 2 */  PCIIRQ(PCI0_INTC, PCI0_INTD, PCI0_INTA, PCI0_INTB)
-    /* PCI0 slot 3 */  PCIIRQ(PCI0_INTD, PCI0_INTA, PCI0_INTB, PCI0_INTC)
-               };
-               const long min_idsel = 3, max_idsel = 7, irqs_per_slot = 4;
-               return PCI_IRQ_TABLE_LOOKUP;
-       } else {
-               static char pci_irq_table[][4] =
-               /*
-                *             PCI IDSEL/INTPIN->INTLINE
-                *             A          B          C          D
-                */
-               {
-    /* Ethernet 1 */   PCIIRQ(MBETH1,    MBETH1,    MBETH1,    MBETH1)
-    /* SCSI */         PCIIRQ(MBSCSI,    MBSCSI,    MBSCSI,    MBSCSI)
-    /* PCI1 slot 1 */  PCIIRQ(PCI1_INTB, PCI1_INTC, PCI1_INTD, PCI1_INTA)
-    /* PCI1 slot 2 */  PCIIRQ(PCI1_INTC, PCI1_INTD, PCI1_INTA, PCI1_INTB)
-    /* PCI1 slot 3 */  PCIIRQ(PCI1_INTD, PCI1_INTA, PCI1_INTB, PCI1_INTC)
-               };
-               const long min_idsel = 3, max_idsel = 7, irqs_per_slot = 4;
-               return PCI_IRQ_TABLE_LOOKUP;
-       }
-#undef PCIIRQ
-}
-
-static void
-adir_pcibios_fixup_resources(struct pci_dev *dev)
-{
-       int i;
-
-       if ((dev->vendor == PCI_VENDOR_ID_IBM) &&
-                       (dev->device == PCI_DEVICE_ID_IBM_CPC710_PCI64))
-       {
-               DBG("Fixup CPC710 resources\n");
-               for (i=0; i<DEVICE_COUNT_RESOURCE; i++)
-               {
-                       dev->resource[i].start = 0;
-                       dev->resource[i].end = 0;
-               }
-       }
-}
-
-/*
- * CPC710 DD3 has an errata causing it to hang the system if a type 0 config
- * cycle is attempted on its PCI32 interface with a device number > 21.
- * CPC710's PCI bridges map device numbers 1 through 21 to AD11 through AD31.
- * Per the PCI spec it MUST accept all other device numbers and do nothing, and
- * software MUST scan all device numbers without assuming how IDSELs are
- * mapped. However, as the CPC710 DD3's errata causes such correct scanning
- * procedure to hang the system, we have no choice but to introduce this hack
- * of knowingly avoiding device numbers > 21 on PCI0,
- */
-static int
-adir_exclude_device(u_char bus, u_char devfn)
-{
-       if ((bus == 0) && (PCI_SLOT(devfn) > 21))
-               return PCIBIOS_DEVICE_NOT_FOUND;
-       else
-               return PCIBIOS_SUCCESSFUL;
-}
-
-void adir_find_bridges(void)
-{
-       struct pci_controller *hose_a, *hose_b;
-
-       /* Setup PCI32 hose */
-       hose_a = pcibios_alloc_controller();
-       if (!hose_a)
-               return;
-
-       hose_a->first_busno = 0;
-       hose_a->last_busno = 0xff;
-       hose_a->pci_mem_offset = ADIR_PCI32_MEM_BASE;
-       hose_a->io_space.start = 0;
-       hose_a->io_space.end = ADIR_PCI32_VIRT_IO_SIZE - 1;
-       hose_a->mem_space.start = 0;
-       hose_a->mem_space.end = ADIR_PCI32_MEM_SIZE - 1;
-       hose_a->io_resource.start = 0;
-       hose_a->io_resource.end = ADIR_PCI32_VIRT_IO_SIZE - 1;
-       hose_a->io_resource.flags = IORESOURCE_IO;
-       hose_a->mem_resources[0].start = ADIR_PCI32_MEM_BASE;
-       hose_a->mem_resources[0].end = ADIR_PCI32_MEM_BASE +
-                                       ADIR_PCI32_MEM_SIZE - 1;
-       hose_a->mem_resources[0].flags = IORESOURCE_MEM;
-       hose_a->io_base_phys = ADIR_PCI32_IO_BASE;
-       hose_a->io_base_virt = (void *) ADIR_PCI32_VIRT_IO_BASE;
-
-       ppc_md.pci_exclude_device = adir_exclude_device;
-       setup_indirect_pci(hose_a, ADIR_PCI32_CONFIG_ADDR,
-                          ADIR_PCI32_CONFIG_DATA);
-
-       /* Initialize PCI32 bus registers */
-       early_write_config_byte(hose_a,
-                       hose_a->first_busno,
-                       PCI_DEVFN(0, 0),
-                       CPC710_BUS_NUMBER,
-                       hose_a->first_busno);
-       early_write_config_byte(hose_a,
-                       hose_a->first_busno,
-                       PCI_DEVFN(0, 0),
-                       CPC710_SUB_BUS_NUMBER,
-                       hose_a->last_busno);
-
-       hose_a->last_busno = pciauto_bus_scan(hose_a, hose_a->first_busno);
-
-       /* Write out correct max subordinate bus number for hose A */
-       early_write_config_byte(hose_a,
-                       hose_a->first_busno,
-                       PCI_DEVFN(0, 0),
-                       CPC710_SUB_BUS_NUMBER,
-                       hose_a->last_busno);
-
-       /* Setup PCI64 hose */
-       hose_b = pcibios_alloc_controller();
-       if (!hose_b)
-               return;
-
-       hose_b->first_busno = hose_a->last_busno + 1;
-       hose_b->last_busno = 0xff;
-       hose_b->pci_mem_offset = ADIR_PCI64_MEM_BASE;
-       hose_b->io_space.start = 0;
-       hose_b->io_space.end = ADIR_PCI64_VIRT_IO_SIZE - 1;
-       hose_b->mem_space.start = 0;
-       hose_b->mem_space.end = ADIR_PCI64_MEM_SIZE - 1;
-       hose_b->io_resource.start = 0;
-       hose_b->io_resource.end = ADIR_PCI64_VIRT_IO_SIZE - 1;
-       hose_b->io_resource.flags = IORESOURCE_IO;
-       hose_b->mem_resources[0].start = ADIR_PCI64_MEM_BASE;
-       hose_b->mem_resources[0].end = ADIR_PCI64_MEM_BASE +
-                                       ADIR_PCI64_MEM_SIZE - 1;
-       hose_b->mem_resources[0].flags = IORESOURCE_MEM;
-       hose_b->io_base_phys = ADIR_PCI64_IO_BASE;
-       hose_b->io_base_virt = (void *) ADIR_PCI64_VIRT_IO_BASE;
-
-       setup_indirect_pci(hose_b, ADIR_PCI64_CONFIG_ADDR,
-                          ADIR_PCI64_CONFIG_DATA);
-
-       /* Initialize PCI64 bus registers */
-       early_write_config_byte(hose_b,
-                       0,
-                       PCI_DEVFN(0, 0),
-                       CPC710_SUB_BUS_NUMBER,
-                       0xff);
-
-       early_write_config_byte(hose_b,
-                       0,
-                       PCI_DEVFN(0, 0),
-                       CPC710_BUS_NUMBER,
-                       hose_b->first_busno);
-
-       hose_b->last_busno = pciauto_bus_scan(hose_b,
-                       hose_b->first_busno);
-
-       /* Write out correct max subordinate bus number for hose B */
-       early_write_config_byte(hose_b,
-                       hose_b->first_busno,
-                       PCI_DEVFN(0, 0),
-                       CPC710_SUB_BUS_NUMBER,
-                       hose_b->last_busno);
-
-       ppc_md.pcibios_fixup = NULL;
-       ppc_md.pcibios_fixup_resources = adir_pcibios_fixup_resources;
-       ppc_md.pci_swizzle = common_swizzle;
-       ppc_md.pci_map_irq = adir_map_irq;
-}
diff --git a/arch/ppc/platforms/adir_pic.c b/arch/ppc/platforms/adir_pic.c
deleted file mode 100644 (file)
index 9947cba..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * arch/ppc/platforms/adir_pic.c
- *
- * Interrupt controller support for SBS Adirondack
- *
- * By Michael Sokolov <msokolov@ivan.Harhan.ORG>
- * based on the K2 and SCM versions by Matt Porter <mporter@mvista.com>
- */
-
-#include <linux/stddef.h>
-#include <linux/init.h>
-#include <linux/sched.h>
-#include <linux/pci.h>
-#include <linux/interrupt.h>
-
-#include <asm/io.h>
-#include <asm/i8259.h>
-#include "adir.h"
-
-static void adir_onboard_pic_enable(unsigned int irq);
-static void adir_onboard_pic_disable(unsigned int irq);
-
-__init static void
-adir_onboard_pic_init(void)
-{
-       volatile u_short *maskreg = (volatile u_short *) ADIR_PROCA_INT_MASK;
-
-       /* Disable all Adirondack onboard interrupts */
-       out_be16(maskreg, 0xFFFF);
-}
-
-static int
-adir_onboard_pic_get_irq(void)
-{
-       volatile u_short *statreg = (volatile u_short *) ADIR_PROCA_INT_STAT;
-       int irq;
-       u_short int_status, int_test;
-
-       int_status = in_be16(statreg);
-       for (irq = 0, int_test = 1; irq < 16; irq++, int_test <<= 1) {
-               if (int_status & int_test)
-                       break;
-       }
-
-       if (irq == 16)
-               return -1;
-
-       return (irq+16);
-}
-
-static void
-adir_onboard_pic_enable(unsigned int irq)
-{
-       volatile u_short *maskreg = (volatile u_short *) ADIR_PROCA_INT_MASK;
-
-       /* Change irq to Adirondack onboard native value */
-       irq -= 16;
-
-       /* Enable requested irq number */
-       out_be16(maskreg, in_be16(maskreg) & ~(1 << irq));
-}
-
-static void
-adir_onboard_pic_disable(unsigned int irq)
-{
-       volatile u_short *maskreg = (volatile u_short *) ADIR_PROCA_INT_MASK;
-
-       /* Change irq to Adirondack onboard native value */
-       irq -= 16;
-
-       /* Disable requested irq number */
-       out_be16(maskreg, in_be16(maskreg) | (1 << irq));
-}
-
-static struct hw_interrupt_type adir_onboard_pic = {
-       " ADIR PIC ",
-       NULL,
-       NULL,
-       adir_onboard_pic_enable,                /* unmask */
-       adir_onboard_pic_disable,               /* mask */
-       adir_onboard_pic_disable,               /* mask and ack */
-       NULL,
-       NULL
-};
-
-static struct irqaction noop_action = {
-       .handler        = no_action,
-       .flags          = SA_INTERRUPT,
-       .mask           = CPU_MASK_NONE,
-       .name           = "82c59 primary cascade",
-};
-
-/*
- * Linux interrupt values are assigned as follows:
- *
- *     0-15            VT82C686 8259 interrupts
- *     16-31           Adirondack CPLD interrupts
- */
-__init void
-adir_init_IRQ(void)
-{
-       int     i;
-
-       /* Initialize the cascaded 8259's on the VT82C686 */
-       for (i=0; i<16; i++)
-               irq_desc[i].handler = &i8259_pic;
-       i8259_init(NULL);
-
-       /* Initialize Adirondack CPLD PIC and enable 8259 interrupt cascade */
-       for (i=16; i<32; i++)
-               irq_desc[i].handler = &adir_onboard_pic;
-       adir_onboard_pic_init();
-
-       /* Enable 8259 interrupt cascade */
-       setup_irq(ADIR_IRQ_VT82C686_INTR, &noop_action);
-}
-
-int
-adir_get_irq(struct pt_regs *regs)
-{
-       int     irq;
-
-       if ((irq = adir_onboard_pic_get_irq()) < 0)
-               return irq;
-
-       if (irq == ADIR_IRQ_VT82C686_INTR)
-               irq = i8259_irq(regs);
-
-       return irq;
-}
diff --git a/arch/ppc/platforms/adir_setup.c b/arch/ppc/platforms/adir_setup.c
deleted file mode 100644 (file)
index 6a6754e..0000000
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * arch/ppc/platforms/adir_setup.c
- *
- * Board setup routines for SBS Adirondack
- *
- * By Michael Sokolov <msokolov@ivan.Harhan.ORG>
- * based on the K2 version by Matt Porter <mporter@mvista.com>
- */
-
-#include <linux/config.h>
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/reboot.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/types.h>
-#include <linux/major.h>
-#include <linux/initrd.h>
-#include <linux/console.h>
-#include <linux/delay.h>
-#include <linux/ide.h>
-#include <linux/seq_file.h>
-#include <linux/root_dev.h>
-
-#include <asm/system.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <asm/dma.h>
-#include <asm/io.h>
-#include <asm/machdep.h>
-#include <asm/time.h>
-#include <asm/todc.h>
-#include <asm/bootinfo.h>
-
-#include "adir.h"
-
-extern void adir_init_IRQ(void);
-extern int adir_get_irq(struct pt_regs *);
-extern void adir_find_bridges(void);
-extern unsigned long loops_per_jiffy;
-
-static unsigned int cpu_750cx[16] = {
-       5, 15, 14, 0, 4, 13, 0, 9, 6, 11, 8, 10, 16, 12, 7, 0
-};
-
-static int
-adir_get_bus_speed(void)
-{
-       if (!(*((u_char *) ADIR_CLOCK_REG) & ADIR_CLOCK_REG_SEL133))
-               return 100000000;
-       else
-               return 133333333;
-}
-
-static int
-adir_get_cpu_speed(void)
-{
-       unsigned long hid1;
-       int cpu_speed;
-
-       hid1 = mfspr(SPRN_HID1) >> 28;
-
-       hid1 = cpu_750cx[hid1];
-
-       cpu_speed = adir_get_bus_speed()*hid1/2;
-       return cpu_speed;
-}
-
-static void __init
-adir_calibrate_decr(void)
-{
-       int freq, divisor = 4;
-
-       /* determine processor bus speed */
-       freq = adir_get_bus_speed();
-       tb_ticks_per_jiffy = freq / HZ / divisor;
-       tb_to_us = mulhwu_scale_factor(freq/divisor, 1000000);
-}
-
-static int
-adir_show_cpuinfo(struct seq_file *m)
-{
-       seq_printf(m, "vendor\t\t: SBS\n");
-       seq_printf(m, "machine\t\t: Adirondack\n");
-       seq_printf(m, "cpu speed\t: %dMhz\n", adir_get_cpu_speed()/1000000);
-       seq_printf(m, "bus speed\t: %dMhz\n", adir_get_bus_speed()/1000000);
-       seq_printf(m, "memory type\t: SDRAM\n");
-
-       return 0;
-}
-
-extern char cmd_line[];
-
-TODC_ALLOC();
-
-static void __init
-adir_setup_arch(void)
-{
-       unsigned int cpu;
-
-       /* Setup TODC access */
-       TODC_INIT(TODC_TYPE_MC146818, ADIR_NVRAM_RTC_ADDR, 0,
-                 ADIR_NVRAM_RTC_DATA, 8);
-
-       /* init to some ~sane value until calibrate_delay() runs */
-        loops_per_jiffy = 50000000/HZ;
-
-       /* Setup PCI host bridges */
-        adir_find_bridges();
-
-#ifdef CONFIG_BLK_DEV_INITRD
-       if (initrd_start)
-               ROOT_DEV = Root_RAM0;
-       else
-#endif
-#ifdef CONFIG_ROOT_NFS
-               ROOT_DEV = Root_NFS;
-#else
-               ROOT_DEV = Root_SDA1;
-#endif
-
-       /* Identify the system */
-       printk("System Identification: SBS Adirondack - PowerPC 750CXe @ %d Mhz\n", adir_get_cpu_speed()/1000000);
-       printk("SBS Adirondack port (C) 2001 SBS Technologies, Inc.\n");
-
-       /* Identify the CPU manufacturer */
-       cpu = mfspr(SPRN_PVR);
-       printk("CPU manufacturer: IBM [rev=%04x]\n", (cpu & 0xffff));
-}
-
-static void
-adir_restart(char *cmd)
-{
-       local_irq_disable();
-       /* SRR0 has system reset vector, SRR1 has default MSR value */
-       /* rfi restores MSR from SRR1 and sets the PC to the SRR0 value */
-       __asm__ __volatile__
-       ("lis   3,0xfff0\n\t"
-        "ori   3,3,0x0100\n\t"
-        "mtspr 26,3\n\t"
-        "li    3,0\n\t"
-        "mtspr 27,3\n\t"
-        "rfi\n\t");
-       for(;;);
-}
-
-static void
-adir_power_off(void)
-{
-       for(;;);
-}
-
-static void
-adir_halt(void)
-{
-       adir_restart(NULL);
-}
-
-static unsigned long __init
-adir_find_end_of_memory(void)
-{
-       return boot_mem_size;
-}
-
-static void __init
-adir_map_io(void)
-{
-       io_block_mapping(ADIR_PCI32_VIRT_IO_BASE, ADIR_PCI32_IO_BASE,
-                               ADIR_PCI32_VIRT_IO_SIZE, _PAGE_IO);
-       io_block_mapping(ADIR_PCI64_VIRT_IO_BASE, ADIR_PCI64_IO_BASE,
-                               ADIR_PCI64_VIRT_IO_SIZE, _PAGE_IO);
-}
-
-void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
-             unsigned long r6, unsigned long r7)
-{
-       /*
-        * On the Adirondack we use bi_recs and pass the pointer to them in R3.
-        */
-       parse_bootinfo((struct bi_record *) (r3 + KERNELBASE));
-
-       /* Remember, isa_io_base is virtual but isa_mem_base is physical! */
-       isa_io_base = ADIR_PCI32_VIRT_IO_BASE;
-       isa_mem_base = ADIR_PCI32_MEM_BASE;
-       pci_dram_offset = ADIR_PCI_SYS_MEM_BASE;
-
-       ppc_md.setup_arch = adir_setup_arch;
-       ppc_md.show_cpuinfo = adir_show_cpuinfo;
-       ppc_md.irq_canonicalize = NULL;
-       ppc_md.init_IRQ = adir_init_IRQ;
-       ppc_md.get_irq = adir_get_irq;
-       ppc_md.init = NULL;
-
-       ppc_md.find_end_of_memory = adir_find_end_of_memory;
-       ppc_md.setup_io_mappings = adir_map_io;
-
-       ppc_md.restart = adir_restart;
-       ppc_md.power_off = adir_power_off;
-       ppc_md.halt = adir_halt;
-
-       ppc_md.time_init = todc_time_init;
-       ppc_md.set_rtc_time = todc_set_rtc_time;
-       ppc_md.get_rtc_time = todc_get_rtc_time;
-       ppc_md.nvram_read_val = todc_mc146818_read_val;
-       ppc_md.nvram_write_val = todc_mc146818_write_val;
-       ppc_md.calibrate_decr = adir_calibrate_decr;
-}
index 507870c9a97a160e8852b7da45d57fb69b9518a9..f64ac2acb603e9b41d0b63a09d88c67df8d6ef40 100644 (file)
 #define SET_PCI_IDE_NATIVE
 
 static struct mv64x60_handle   bh;
-static u32 cpci690_br_base;
-
-static const unsigned int cpu_7xx[16] = { /* 7xx & 74xx (but not 745x) */
-       18, 15, 14, 2, 4, 13, 5, 9, 6, 11, 8, 10, 16, 12, 7, 0
-};
+static void __iomem *cpci690_br_base;
 
 TODC_ALLOC();
 
@@ -55,7 +51,7 @@ cpci690_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
                 *         A   B   C   D
                 */
                {
-                       { 90, 91, 88, 89}, /* IDSEL 30/20 - Sentinel */
+                       { 90, 91, 88, 89 }, /* IDSEL 30/20 - Sentinel */
                };
 
                const long min_idsel = 20, max_idsel = 20, irqs_per_slot = 4;
@@ -67,9 +63,9 @@ cpci690_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
                 *         A   B   C   D
                 */
                {
-                       { 93, 94, 95, 92}, /* IDSEL 28/18 - PMC slot 2 */
-                       {  0,  0,  0,  0}, /* IDSEL 29/19 - Not used */
-                       { 94, 95, 92, 93}, /* IDSEL 30/20 - PMC slot 1 */
+                       { 93, 94, 95, 92 }, /* IDSEL 28/18 - PMC slot 2 */
+                       {  0,  0,  0,  0 }, /* IDSEL 29/19 - Not used */
+                       { 94, 95, 92, 93 }, /* IDSEL 30/20 - PMC slot 1 */
                };
 
                const long min_idsel = 18, max_idsel = 20, irqs_per_slot = 4;
@@ -77,68 +73,29 @@ cpci690_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
        }
 }
 
-static int
-cpci690_get_cpu_speed(void)
-{
-       unsigned long   hid1;
+#define        GB      (1024UL * 1024UL * 1024UL)
 
-       hid1 = mfspr(SPRN_HID1) >> 28;
-       return CPCI690_BUS_FREQ * cpu_7xx[hid1]/2;
+static u32
+cpci690_get_bus_freq(void)
+{
+       if (boot_mem_size >= (1*GB)) /* bus speed based on mem size */
+               return 100000000;
+       else
+               return 133333333;
 }
 
-#define        KB      (1024UL)
-#define        MB      (1024UL * KB)
-#define        GB      (1024UL * MB)
+static const unsigned int cpu_750xx[32] = { /* 750FX & 750GX */
+        0,  0,  2,  2,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,/* 0-15*/
+       16, 17, 18, 19, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40,  0 /*16-31*/
+};
 
-unsigned long __init
-cpci690_find_end_of_memory(void)
+static int
+cpci690_get_cpu_freq(void)
 {
-       u32             mem_ctlr_size;
-       static u32      board_size;
-       static u8       first_time = 1;
-
-       if (first_time) {
-               /* Using cpci690_set_bat() mapping ==> virt addr == phys addr */
-               switch (in_8((u8 *) (cpci690_br_base +
-                       CPCI690_BR_MEM_CTLR)) & 0x07) {
-               case 0x01:
-                       board_size = 256*MB;
-                       break;
-               case 0x02:
-                       board_size = 512*MB;
-                       break;
-               case 0x03:
-                       board_size = 768*MB;
-                       break;
-               case 0x04:
-                       board_size = 1*GB;
-                       break;
-               case 0x05:
-                       board_size = 1*GB + 512*MB;
-                       break;
-               case 0x06:
-                       board_size = 2*GB;
-                       break;
-               default:
-                       board_size = 0xffffffff; /* use mem ctlr size */
-               } /* switch */
-
-               mem_ctlr_size =  mv64x60_get_mem_size(CONFIG_MV64X60_NEW_BASE,
-                       MV64x60_TYPE_GT64260A);
-
-               /* Check that mem ctlr & board reg agree.  If not, pick MIN. */
-               if (board_size != mem_ctlr_size) {
-                       printk(KERN_WARNING "Board register & memory controller"
-                               "mem size disagree (board reg: 0x%lx, "
-                               "mem ctlr: 0x%lx)\n",
-                               (ulong)board_size, (ulong)mem_ctlr_size);
-                       board_size = min(board_size, mem_ctlr_size);
-               }
-
-               first_time = 0;
-       } /* if */
-
-       return board_size;
+       unsigned long   pll_cfg;
+
+       pll_cfg = (mfspr(SPRN_HID1) & 0xf8000000) >> 27;
+       return cpci690_get_bus_freq() * cpu_750xx[pll_cfg]/2;
 }
 
 static void __init
@@ -228,7 +185,7 @@ cpci690_setup_peripherals(void)
        mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_0_WIN, CPCI690_BR_BASE,
                CPCI690_BR_SIZE, 0);
        bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_0_WIN);
-       cpci690_br_base = (u32)ioremap(CPCI690_BR_BASE, CPCI690_BR_SIZE);
+       cpci690_br_base = ioremap(CPCI690_BR_BASE, CPCI690_BR_SIZE);
 
        mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_1_WIN, CPCI690_TODC_BASE,
                CPCI690_TODC_SIZE, 0);
@@ -329,7 +286,7 @@ cpci690_fixup_mpsc_pdata(struct platform_device *pdev)
        pdata->max_idle = 40;
        pdata->default_baud = CPCI690_MPSC_BAUD;
        pdata->brg_clk_src = CPCI690_MPSC_CLK_SRC;
-       pdata->brg_clk_freq = CPCI690_BUS_FREQ;
+       pdata->brg_clk_freq = cpci690_get_bus_freq();
 }
 
 static int __init
@@ -365,7 +322,7 @@ cpci690_reset_board(void)
        u32     i = 10000;
 
        local_irq_disable();
-       out_8((u8 *)(cpci690_br_base + CPCI690_BR_SW_RESET), 0x11);
+       out_8((cpci690_br_base + CPCI690_BR_SW_RESET), 0x11);
 
        while (i != 0) i++;
        panic("restart failed\n");
@@ -394,10 +351,40 @@ cpci690_power_off(void)
 static int
 cpci690_show_cpuinfo(struct seq_file *m)
 {
+       char    *s;
+
+       seq_printf(m, "cpu MHz\t\t: %d\n",
+               (cpci690_get_cpu_freq() + 500000) / 1000000);
+       seq_printf(m, "bus MHz\t\t: %d\n",
+               (cpci690_get_bus_freq() + 500000) / 1000000);
        seq_printf(m, "vendor\t\t: " BOARD_VENDOR "\n");
        seq_printf(m, "machine\t\t: " BOARD_MACHINE "\n");
-       seq_printf(m, "cpu MHz\t\t: %d\n", cpci690_get_cpu_speed()/1000/1000);
-       seq_printf(m, "bus MHz\t\t: %d\n", CPCI690_BUS_FREQ/1000/1000);
+       seq_printf(m, "FPGA Revision\t: %d\n",
+               in_8(cpci690_br_base + CPCI690_BR_MEM_CTLR) >> 5);
+
+       switch(bh.type) {
+       case MV64x60_TYPE_GT64260A:
+               s = "gt64260a";
+               break;
+       case MV64x60_TYPE_GT64260B:
+               s = "gt64260b";
+               break;
+       case MV64x60_TYPE_MV64360:
+               s = "mv64360";
+               break;
+       case MV64x60_TYPE_MV64460:
+               s = "mv64460";
+               break;
+       default:
+               s = "Unknown";
+       }
+       seq_printf(m, "bridge type\t: %s\n", s);
+       seq_printf(m, "bridge rev\t: 0x%x\n", bh.rev);
+#if defined(CONFIG_NOT_COHERENT_CACHE)
+       seq_printf(m, "coherency\t: %s\n", "off");
+#else
+       seq_printf(m, "coherency\t: %s\n", "on");
+#endif
 
        return 0;
 }
@@ -407,7 +394,7 @@ cpci690_calibrate_decr(void)
 {
        ulong freq;
 
-       freq = CPCI690_BUS_FREQ / 4;
+       freq = cpci690_get_bus_freq() / 4;
 
        printk(KERN_INFO "time_init: decrementer frequency = %lu.%.6lu MHz\n",
               freq/1000000, freq%1000000);
@@ -416,25 +403,12 @@ cpci690_calibrate_decr(void)
        tb_to_us = mulhwu_scale_factor(freq, 1000000);
 }
 
-static __inline__ void
-cpci690_set_bat(u32 addr, u32 size)
-{
-       addr &= 0xfffe0000;
-       size &= 0x1ffe0000;
-       size = ((size >> 17) - 1) << 2;
-
-       mb();
-       mtspr(SPRN_DBAT1U, addr | size | 0x2); /* Vs == 1; Vp == 0 */
-       mtspr(SPRN_DBAT1L, addr | 0x2a); /* WIMG bits == 0101; PP == r/w access */
-       mb();
-}
-
-#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
+#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB_MPSC)
 static void __init
 cpci690_map_io(void)
 {
        io_block_mapping(CONFIG_MV64X60_NEW_BASE, CONFIG_MV64X60_NEW_BASE,
-               128 * KB, _PAGE_IO);
+               128 * 1024, _PAGE_IO);
 }
 #endif
 
@@ -442,14 +416,15 @@ void __init
 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
              unsigned long r6, unsigned long r7)
 {
-#ifdef CONFIG_BLK_DEV_INITRD
-       initrd_start=initrd_end=0;
-       initrd_below_start_ok=0;
-#endif /* CONFIG_BLK_DEV_INITRD */
-
        parse_bootinfo(find_bootinfo());
 
-       loops_per_jiffy = cpci690_get_cpu_speed() / HZ;
+#ifdef CONFIG_BLK_DEV_INITRD
+       /* take care of initrd if we have one */
+       if (r4) {
+               initrd_start = r4 + KERNELBASE;
+               initrd_end = r5 + KERNELBASE;
+       }
+#endif /* CONFIG_BLK_DEV_INITRD */
 
        isa_mem_base = 0;
 
@@ -460,7 +435,6 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
        ppc_md.restart = cpci690_restart;
        ppc_md.power_off = cpci690_power_off;
        ppc_md.halt = cpci690_halt;
-       ppc_md.find_end_of_memory = cpci690_find_end_of_memory;
        ppc_md.time_init = todc_time_init;
        ppc_md.set_rtc_time = todc_set_rtc_time;
        ppc_md.get_rtc_time = todc_get_rtc_time;
@@ -468,22 +442,13 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
        ppc_md.nvram_write_val = todc_direct_write_val;
        ppc_md.calibrate_decr = cpci690_calibrate_decr;
 
-       /*
-        * Need to map in board regs (used by cpci690_find_end_of_memory())
-        * and the bridge's regs (used by progress);
-        */
-       cpci690_set_bat(CPCI690_BR_BASE, 32 * MB);
-       cpci690_br_base = CPCI690_BR_BASE;
-
-#ifdef CONFIG_SERIAL_TEXT_DEBUG
+#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB_MPSC)
        ppc_md.setup_io_mappings = cpci690_map_io;
+#ifdef CONFIG_SERIAL_TEXT_DEBUG
        ppc_md.progress = mv64x60_mpsc_progress;
        mv64x60_progress_init(CONFIG_MV64X60_NEW_BASE);
 #endif /* CONFIG_SERIAL_TEXT_DEBUG */
-#ifdef CONFIG_KGDB
-       ppc_md.setup_io_mappings = cpci690_map_io;
-       ppc_md.early_serial_map = cpci690_early_serial_map;
-#endif /* CONFIG_KGDB */
+#endif /* defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB_MPSC) */
 
 #if defined(CONFIG_SERIAL_MPSC)
        platform_notify = cpci690_platform_notify;
index 36cd2673c7427a452e843f4c68ad17f79591afb2..49584c9cedf38bf30df283c4190e989eb376db04 100644 (file)
@@ -73,6 +73,4 @@ typedef struct board_info {
 #define        CPCI690_MPSC_BAUD                       9600
 #define        CPCI690_MPSC_CLK_SRC                    8 /* TCLK */
 
-#define        CPCI690_BUS_FREQ                        133333333
-
 #endif /* __PPC_PLATFORMS_CPCI690_H */
diff --git a/arch/ppc/platforms/ev64360.c b/arch/ppc/platforms/ev64360.c
new file mode 100644 (file)
index 0000000..9811a8a
--- /dev/null
@@ -0,0 +1,510 @@
+/*
+ * arch/ppc/platforms/ev64360.c
+ *
+ * Board setup routines for the Marvell EV-64360-BP Evaluation Board.
+ *
+ * Author: Lee Nicks <allinux@gmail.com>
+ *
+ * Based on code done by Rabeeh Khoury - rabeeh@galileo.co.il
+ * Based on code done by - Mark A. Greer <mgreer@mvista.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/kdev_t.h>
+#include <linux/console.h>
+#include <linux/initrd.h>
+#include <linux/root_dev.h>
+#include <linux/delay.h>
+#include <linux/seq_file.h>
+#include <linux/bootmem.h>
+#include <linux/mtd/physmap.h>
+#include <linux/mv643xx.h>
+#ifdef CONFIG_BOOTIMG
+#include <linux/bootimg.h>
+#endif
+#include <asm/page.h>
+#include <asm/time.h>
+#include <asm/smp.h>
+#include <asm/todc.h>
+#include <asm/bootinfo.h>
+#include <asm/ppcboot.h>
+#include <asm/mv64x60.h>
+#include <platforms/ev64360.h>
+
+#define BOARD_VENDOR    "Marvell"
+#define BOARD_MACHINE   "EV-64360-BP"
+
+static struct          mv64x60_handle bh;
+static void __iomem    *sram_base;
+
+static u32             ev64360_flash_size_0;
+static u32             ev64360_flash_size_1;
+
+static u32             ev64360_bus_frequency;
+
+unsigned char  __res[sizeof(bd_t)];
+
+static int __init
+ev64360_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
+{
+       return 0;
+}
+
+static void __init
+ev64360_setup_bridge(void)
+{
+       struct mv64x60_setup_info si;
+       int i;
+
+       memset(&si, 0, sizeof(si));
+
+       si.phys_reg_base = CONFIG_MV64X60_NEW_BASE;
+
+       #ifdef CONFIG_PCI
+       si.pci_1.enable_bus = 1;
+       si.pci_1.pci_io.cpu_base = EV64360_PCI1_IO_START_PROC_ADDR;
+       si.pci_1.pci_io.pci_base_hi = 0;
+       si.pci_1.pci_io.pci_base_lo = EV64360_PCI1_IO_START_PCI_ADDR;
+       si.pci_1.pci_io.size = EV64360_PCI1_IO_SIZE;
+       si.pci_1.pci_io.swap = MV64x60_CPU2PCI_SWAP_NONE;
+       si.pci_1.pci_mem[0].cpu_base = EV64360_PCI1_MEM_START_PROC_ADDR;
+       si.pci_1.pci_mem[0].pci_base_hi = EV64360_PCI1_MEM_START_PCI_HI_ADDR;
+       si.pci_1.pci_mem[0].pci_base_lo = EV64360_PCI1_MEM_START_PCI_LO_ADDR;
+       si.pci_1.pci_mem[0].size = EV64360_PCI1_MEM_SIZE;
+       si.pci_1.pci_mem[0].swap = MV64x60_CPU2PCI_SWAP_NONE;
+       si.pci_1.pci_cmd_bits = 0;
+       si.pci_1.latency_timer = 0x80;
+       #else
+       si.pci_0.enable_bus = 0;
+       si.pci_1.enable_bus = 0;
+       #endif
+
+       for (i = 0; i < MV64x60_CPU2MEM_WINDOWS; i++) {
+#if defined(CONFIG_NOT_COHERENT_CACHE)
+               si.cpu_prot_options[i] = 0;
+               si.enet_options[i] = MV64360_ENET2MEM_SNOOP_NONE;
+               si.mpsc_options[i] = MV64360_MPSC2MEM_SNOOP_NONE;
+               si.idma_options[i] = MV64360_IDMA2MEM_SNOOP_NONE;
+
+               si.pci_1.acc_cntl_options[i] =
+                   MV64360_PCI_ACC_CNTL_SNOOP_NONE |
+                   MV64360_PCI_ACC_CNTL_SWAP_NONE |
+                   MV64360_PCI_ACC_CNTL_MBURST_128_BYTES |
+                   MV64360_PCI_ACC_CNTL_RDSIZE_256_BYTES;
+#else
+               si.cpu_prot_options[i] = 0;
+               si.enet_options[i] = MV64360_ENET2MEM_SNOOP_NONE; /* errata */
+               si.mpsc_options[i] = MV64360_MPSC2MEM_SNOOP_NONE; /* errata */
+               si.idma_options[i] = MV64360_IDMA2MEM_SNOOP_NONE; /* errata */
+
+               si.pci_1.acc_cntl_options[i] =
+                   MV64360_PCI_ACC_CNTL_SNOOP_WB |
+                   MV64360_PCI_ACC_CNTL_SWAP_NONE |
+                   MV64360_PCI_ACC_CNTL_MBURST_32_BYTES |
+                   MV64360_PCI_ACC_CNTL_RDSIZE_32_BYTES;
+#endif
+       }
+
+       if (mv64x60_init(&bh, &si))
+               printk(KERN_WARNING "Bridge initialization failed.\n");
+
+       #ifdef CONFIG_PCI
+       pci_dram_offset = 0; /* sys mem at same addr on PCI & cpu bus */
+       ppc_md.pci_swizzle = common_swizzle;
+       ppc_md.pci_map_irq = ev64360_map_irq;
+       ppc_md.pci_exclude_device = mv64x60_pci_exclude_device;
+
+       mv64x60_set_bus(&bh, 1, 0);
+       bh.hose_b->first_busno = 0;
+       bh.hose_b->last_busno = 0xff;
+       #endif
+}
+
+/* Bridge & platform setup routines */
+void __init
+ev64360_intr_setup(void)
+{
+       /* MPP 8, 9, and 10 */
+       mv64x60_clr_bits(&bh, MV64x60_MPP_CNTL_1, 0xfff);
+
+       /*
+        * Define GPP 8,9,and 10 interrupt polarity as active low
+        * input signal and level triggered
+        */
+       mv64x60_set_bits(&bh, MV64x60_GPP_LEVEL_CNTL, 0x700);
+       mv64x60_clr_bits(&bh, MV64x60_GPP_IO_CNTL, 0x700);
+
+       /* Config GPP intr ctlr to respond to level trigger */
+       mv64x60_set_bits(&bh, MV64x60_COMM_ARBITER_CNTL, (1<<10));
+
+       /* Erranum FEr PCI-#8 */
+       mv64x60_clr_bits(&bh, MV64x60_PCI0_CMD, (1<<5) | (1<<9));
+       mv64x60_clr_bits(&bh, MV64x60_PCI1_CMD, (1<<5) | (1<<9));
+
+       /*
+        * Dismiss and then enable interrupt on GPP interrupt cause
+        * for CPU #0
+        */
+       mv64x60_write(&bh, MV64x60_GPP_INTR_CAUSE, ~0x700);
+       mv64x60_set_bits(&bh, MV64x60_GPP_INTR_MASK, 0x700);
+
+       /*
+        * Dismiss and then enable interrupt on CPU #0 high cause reg
+        * BIT25 summarizes GPP interrupts 8-15
+        */
+       mv64x60_set_bits(&bh, MV64360_IC_CPU0_INTR_MASK_HI, (1<<25));
+}
+
+void __init
+ev64360_setup_peripherals(void)
+{
+       u32 base;
+
+       /* Set up window for boot CS */
+       mv64x60_set_32bit_window(&bh, MV64x60_CPU2BOOT_WIN,
+                EV64360_BOOT_WINDOW_BASE, EV64360_BOOT_WINDOW_SIZE, 0);
+       bh.ci->enable_window_32bit(&bh, MV64x60_CPU2BOOT_WIN);
+
+       /* We only use the 32-bit flash */
+       mv64x60_get_32bit_window(&bh, MV64x60_CPU2BOOT_WIN, &base,
+               &ev64360_flash_size_0);
+       ev64360_flash_size_1 = 0;
+
+       mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_1_WIN,
+                EV64360_RTC_WINDOW_BASE, EV64360_RTC_WINDOW_SIZE, 0);
+       bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_1_WIN);
+
+       mv64x60_set_32bit_window(&bh, MV64x60_CPU2SRAM_WIN,
+                EV64360_INTERNAL_SRAM_BASE, MV64360_SRAM_SIZE, 0);
+       bh.ci->enable_window_32bit(&bh, MV64x60_CPU2SRAM_WIN);
+       sram_base = ioremap(EV64360_INTERNAL_SRAM_BASE, MV64360_SRAM_SIZE);
+
+       /* Set up Enet->SRAM window */
+       mv64x60_set_32bit_window(&bh, MV64x60_ENET2MEM_4_WIN,
+               EV64360_INTERNAL_SRAM_BASE, MV64360_SRAM_SIZE, 0x2);
+       bh.ci->enable_window_32bit(&bh, MV64x60_ENET2MEM_4_WIN);
+
+       /* Give enet r/w access to memory region */
+       mv64x60_set_bits(&bh, MV64360_ENET2MEM_ACC_PROT_0, (0x3 << (4 << 1)));
+       mv64x60_set_bits(&bh, MV64360_ENET2MEM_ACC_PROT_1, (0x3 << (4 << 1)));
+       mv64x60_set_bits(&bh, MV64360_ENET2MEM_ACC_PROT_2, (0x3 << (4 << 1)));
+
+       mv64x60_clr_bits(&bh, MV64x60_PCI1_PCI_DECODE_CNTL, (1 << 3));
+       mv64x60_clr_bits(&bh, MV64x60_TIMR_CNTR_0_3_CNTL,
+                        ((1 << 0) | (1 << 8) | (1 << 16) | (1 << 24)));
+
+#if defined(CONFIG_NOT_COHERENT_CACHE)
+       mv64x60_write(&bh, MV64360_SRAM_CONFIG, 0x00160000);
+#else
+       mv64x60_write(&bh, MV64360_SRAM_CONFIG, 0x001600b2);
+#endif
+
+       /*
+        * Setting the SRAM to 0. Note that this generates parity errors on
+        * internal data path in SRAM since it's first time accessing it
+        * while after reset it's not configured.
+        */
+       memset(sram_base, 0, MV64360_SRAM_SIZE);
+
+       /* set up PCI interrupt controller */
+       ev64360_intr_setup();
+}
+
+static void __init
+ev64360_setup_arch(void)
+{
+       if (ppc_md.progress)
+               ppc_md.progress("ev64360_setup_arch: enter", 0);
+
+       set_tb(0, 0);
+
+#ifdef CONFIG_BLK_DEV_INITRD
+       if (initrd_start)
+               ROOT_DEV = Root_RAM0;
+       else
+#endif
+#ifdef   CONFIG_ROOT_NFS
+               ROOT_DEV = Root_NFS;
+#else
+               ROOT_DEV = Root_SDA2;
+#endif
+
+       /*
+        * Set up the L2CR register.
+        */
+       _set_L2CR(L2CR_L2E | L2CR_L2PE);
+
+       if (ppc_md.progress)
+               ppc_md.progress("ev64360_setup_arch: calling setup_bridge", 0);
+
+       ev64360_setup_bridge();
+       ev64360_setup_peripherals();
+       ev64360_bus_frequency = ev64360_bus_freq();
+
+       printk(KERN_INFO "%s %s port (C) 2005 Lee Nicks "
+               "(allinux@gmail.com)\n", BOARD_VENDOR, BOARD_MACHINE);
+       if (ppc_md.progress)
+               ppc_md.progress("ev64360_setup_arch: exit", 0);
+}
+
+/* Platform device data fixup routines. */
+#if defined(CONFIG_SERIAL_MPSC)
+static void __init
+ev64360_fixup_mpsc_pdata(struct platform_device *pdev)
+{
+       struct mpsc_pdata *pdata;
+
+       pdata = (struct mpsc_pdata *)pdev->dev.platform_data;
+
+       pdata->max_idle = 40;
+       pdata->default_baud = EV64360_DEFAULT_BAUD;
+       pdata->brg_clk_src = EV64360_MPSC_CLK_SRC;
+       /*
+        * TCLK (not SysCLk) is routed to BRG, then to the MPSC.  On most parts,
+        * TCLK == SysCLK but on 64460, they are separate pins.
+        * SysCLK can go up to 200 MHz but TCLK can only go up to 133 MHz.
+        */
+       pdata->brg_clk_freq = min(ev64360_bus_frequency, MV64x60_TCLK_FREQ_MAX);
+}
+#endif
+
+#if defined(CONFIG_MV643XX_ETH)
+static void __init
+ev64360_fixup_eth_pdata(struct platform_device *pdev)
+{
+       struct mv643xx_eth_platform_data *eth_pd;
+       static u16 phy_addr[] = {
+               EV64360_ETH0_PHY_ADDR,
+               EV64360_ETH1_PHY_ADDR,
+               EV64360_ETH2_PHY_ADDR,
+       };
+
+       eth_pd = pdev->dev.platform_data;
+       eth_pd->force_phy_addr = 1;
+       eth_pd->phy_addr = phy_addr[pdev->id];
+       eth_pd->tx_queue_size = EV64360_ETH_TX_QUEUE_SIZE;
+       eth_pd->rx_queue_size = EV64360_ETH_RX_QUEUE_SIZE;
+}
+#endif
+
+static int __init
+ev64360_platform_notify(struct device *dev)
+{
+       static struct {
+               char    *bus_id;
+               void    ((*rtn)(struct platform_device *pdev));
+       } dev_map[] = {
+#if defined(CONFIG_SERIAL_MPSC)
+               { MPSC_CTLR_NAME ".0", ev64360_fixup_mpsc_pdata },
+               { MPSC_CTLR_NAME ".1", ev64360_fixup_mpsc_pdata },
+#endif
+#if defined(CONFIG_MV643XX_ETH)
+               { MV643XX_ETH_NAME ".0", ev64360_fixup_eth_pdata },
+               { MV643XX_ETH_NAME ".1", ev64360_fixup_eth_pdata },
+               { MV643XX_ETH_NAME ".2", ev64360_fixup_eth_pdata },
+#endif
+       };
+       struct platform_device  *pdev;
+       int     i;
+
+       if (dev && dev->bus_id)
+               for (i=0; i<ARRAY_SIZE(dev_map); i++)
+                       if (!strncmp(dev->bus_id, dev_map[i].bus_id,
+                               BUS_ID_SIZE)) {
+
+                               pdev = container_of(dev,
+                                       struct platform_device, dev);
+                               dev_map[i].rtn(pdev);
+                       }
+
+       return 0;
+}
+
+#ifdef CONFIG_MTD_PHYSMAP
+
+#ifndef MB
+#define MB     (1 << 20)
+#endif
+
+/*
+ * MTD Layout.
+ *
+ * FLASH Amount:       0xff000000 - 0xffffffff
+ * -------------       -----------------------
+ * Reserved:           0xff000000 - 0xff03ffff
+ * JFFS2 file system:  0xff040000 - 0xffefffff
+ * U-boot:             0xfff00000 - 0xffffffff
+ */
+static int __init
+ev64360_setup_mtd(void)
+{
+       u32     size;
+       int     ptbl_entries;
+       static struct mtd_partition     *ptbl;
+
+       size = ev64360_flash_size_0 + ev64360_flash_size_1;
+       if (!size)
+               return -ENOMEM;
+
+       ptbl_entries = 3;
+
+       if ((ptbl = kmalloc(ptbl_entries * sizeof(struct mtd_partition),
+               GFP_KERNEL)) == NULL) {
+
+               printk(KERN_WARNING "Can't alloc MTD partition table\n");
+               return -ENOMEM;
+       }
+       memset(ptbl, 0, ptbl_entries * sizeof(struct mtd_partition));
+
+       ptbl[0].name = "reserved";
+       ptbl[0].offset = 0;
+       ptbl[0].size = EV64360_MTD_RESERVED_SIZE;
+       ptbl[1].name = "jffs2";
+       ptbl[1].offset = EV64360_MTD_RESERVED_SIZE;
+       ptbl[1].size = EV64360_MTD_JFFS2_SIZE;
+       ptbl[2].name = "U-BOOT";
+       ptbl[2].offset = EV64360_MTD_RESERVED_SIZE + EV64360_MTD_JFFS2_SIZE;
+       ptbl[2].size = EV64360_MTD_UBOOT_SIZE;
+
+       physmap_map.size = size;
+       physmap_set_partitions(ptbl, ptbl_entries);
+       return 0;
+}
+
+arch_initcall(ev64360_setup_mtd);
+#endif
+
+static void
+ev64360_restart(char *cmd)
+{
+       ulong   i = 0xffffffff;
+       volatile unsigned char * rtc_base = ioremap(EV64360_RTC_WINDOW_BASE,0x4000);
+
+       /* issue hard reset */
+       rtc_base[0xf] = 0x80;
+       rtc_base[0xc] = 0x00;
+       rtc_base[0xd] = 0x01;
+       rtc_base[0xf] = 0x83;
+
+       while (i-- > 0) ;
+       panic("restart failed\n");
+}
+
+static void
+ev64360_halt(void)
+{
+       while (1) ;
+       /* NOTREACHED */
+}
+
+static void
+ev64360_power_off(void)
+{
+       ev64360_halt();
+       /* NOTREACHED */
+}
+
+static int
+ev64360_show_cpuinfo(struct seq_file *m)
+{
+       seq_printf(m, "vendor\t\t: " BOARD_VENDOR "\n");
+       seq_printf(m, "machine\t\t: " BOARD_MACHINE "\n");
+       seq_printf(m, "bus speed\t: %dMHz\n", ev64360_bus_frequency/1000/1000);
+
+       return 0;
+}
+
+static void __init
+ev64360_calibrate_decr(void)
+{
+       u32 freq;
+
+       freq = ev64360_bus_frequency / 4;
+
+       printk(KERN_INFO "time_init: decrementer frequency = %lu.%.6lu MHz\n",
+              (long)freq / 1000000, (long)freq % 1000000);
+
+       tb_ticks_per_jiffy = freq / HZ;
+       tb_to_us = mulhwu_scale_factor(freq, 1000000);
+}
+
+unsigned long __init
+ev64360_find_end_of_memory(void)
+{
+       return mv64x60_get_mem_size(CONFIG_MV64X60_NEW_BASE,
+               MV64x60_TYPE_MV64360);
+}
+
+static inline void
+ev64360_set_bat(void)
+{
+       mb();
+       mtspr(SPRN_DBAT2U, 0xf0001ffe);
+       mtspr(SPRN_DBAT2L, 0xf000002a);
+       mb();
+}
+
+#if defined(CONFIG_SERIAL_TEXT_DEBUG) && defined(CONFIG_SERIAL_MPSC_CONSOLE)
+static void __init
+ev64360_map_io(void)
+{
+       io_block_mapping(CONFIG_MV64X60_NEW_BASE, \
+                        CONFIG_MV64X60_NEW_BASE, \
+                        0x00020000, _PAGE_IO);
+}
+#endif
+
+void __init
+platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
+             unsigned long r6, unsigned long r7)
+{
+       parse_bootinfo(find_bootinfo());
+
+       /* ASSUMPTION:  If both r3 (bd_t pointer) and r6 (cmdline pointer)
+        * are non-zero, then we should use the board info from the bd_t
+        * structure and the cmdline pointed to by r6 instead of the
+        * information from birecs, if any.  Otherwise, use the information
+        * from birecs as discovered by the preceeding call to
+        * parse_bootinfo().  This rule should work with both PPCBoot, which
+        * uses a bd_t board info structure, and the kernel boot wrapper,
+        * which uses birecs.
+        */
+       if (r3 && r6) {
+               /* copy board info structure */
+               memcpy( (void *)__res,(void *)(r3+KERNELBASE), sizeof(bd_t) );
+               /* copy command line */
+               *(char *)(r7+KERNELBASE) = 0;
+               strcpy(cmd_line, (char *)(r6+KERNELBASE));
+       }
+       #ifdef CONFIG_ISA
+       isa_mem_base = 0;
+       #endif
+
+       ppc_md.setup_arch = ev64360_setup_arch;
+       ppc_md.show_cpuinfo = ev64360_show_cpuinfo;
+       ppc_md.init_IRQ = mv64360_init_irq;
+       ppc_md.get_irq = mv64360_get_irq;
+       ppc_md.restart = ev64360_restart;
+       ppc_md.power_off = ev64360_power_off;
+       ppc_md.halt = ev64360_halt;
+       ppc_md.find_end_of_memory = ev64360_find_end_of_memory;
+       ppc_md.calibrate_decr = ev64360_calibrate_decr;
+
+#if defined(CONFIG_SERIAL_TEXT_DEBUG) && defined(CONFIG_SERIAL_MPSC_CONSOLE)
+       ppc_md.setup_io_mappings = ev64360_map_io;
+       ppc_md.progress = mv64x60_mpsc_progress;
+       mv64x60_progress_init(CONFIG_MV64X60_NEW_BASE);
+#endif
+
+#if defined(CONFIG_SERIAL_MPSC) || defined(CONFIG_MV643XX_ETH)
+       platform_notify = ev64360_platform_notify;
+#endif
+
+       ev64360_set_bat(); /* Need for ev64360_find_end_of_memory and progress */
+}
diff --git a/arch/ppc/platforms/ev64360.h b/arch/ppc/platforms/ev64360.h
new file mode 100644 (file)
index 0000000..68eabe4
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * arch/ppc/platforms/ev64360.h
+ *
+ * Definitions for Marvell EV-64360-BP Evaluation Board.
+ *
+ * Author: Lee Nicks <allinux@gmail.com>
+ *
+ * Based on code done by Rabeeh Khoury - rabeeh@galileo.co.il
+ * Based on code done by Mark A. Greer <mgreer@mvista.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+/*
+ * The MV64360 has 2 PCI buses each with 1 window from the CPU bus to
+ * PCI I/O space and 4 windows from the CPU bus to PCI MEM space.
+ * We'll only use one PCI MEM window on each PCI bus.
+ *
+ * This is the CPU physical memory map (windows must be at least 64KB and start
+ * on a boundary that is a multiple of the window size):
+ *
+ *    0x42000000-0x4203ffff      - Internal SRAM
+ *    0xf1000000-0xf100ffff      - MV64360 Registers (CONFIG_MV64X60_NEW_BASE)
+ *    0xfc800000-0xfcffffff      - RTC
+ *    0xff000000-0xffffffff      - Boot window, 16 MB flash
+ *    0xc0000000-0xc3ffffff      - PCI I/O (second hose)
+ *    0x80000000-0xbfffffff      - PCI MEM (second hose)
+ */
+
+#ifndef __PPC_PLATFORMS_EV64360_H
+#define __PPC_PLATFORMS_EV64360_H
+
+/* CPU Physical Memory Map setup. */
+#define EV64360_BOOT_WINDOW_BASE               0xff000000
+#define EV64360_BOOT_WINDOW_SIZE               0x01000000 /* 16 MB */
+#define EV64360_INTERNAL_SRAM_BASE             0x42000000
+#define EV64360_RTC_WINDOW_BASE                        0xfc800000
+#define EV64360_RTC_WINDOW_SIZE                        0x00800000 /* 8 MB */
+
+#define EV64360_PCI1_MEM_START_PROC_ADDR       0x80000000
+#define EV64360_PCI1_MEM_START_PCI_HI_ADDR     0x00000000
+#define EV64360_PCI1_MEM_START_PCI_LO_ADDR     0x80000000
+#define EV64360_PCI1_MEM_SIZE                  0x40000000 /* 1 GB */
+#define EV64360_PCI1_IO_START_PROC_ADDR                0xc0000000
+#define EV64360_PCI1_IO_START_PCI_ADDR         0x00000000
+#define EV64360_PCI1_IO_SIZE                   0x04000000 /* 64 MB */
+
+#define        EV64360_DEFAULT_BAUD                    115200
+#define        EV64360_MPSC_CLK_SRC                    8         /* TCLK */
+#define EV64360_MPSC_CLK_FREQ                  133333333
+
+#define        EV64360_MTD_RESERVED_SIZE               0x40000
+#define EV64360_MTD_JFFS2_SIZE                 0xec0000
+#define EV64360_MTD_UBOOT_SIZE                 0x100000
+
+#define        EV64360_ETH0_PHY_ADDR                   8
+#define        EV64360_ETH1_PHY_ADDR                   9
+#define        EV64360_ETH2_PHY_ADDR                   10
+
+#define EV64360_ETH_TX_QUEUE_SIZE              800
+#define EV64360_ETH_RX_QUEUE_SIZE              400
+
+#define        EV64360_ETH_PORT_CONFIG_VALUE                   \
+       ETH_UNICAST_NORMAL_MODE                 |       \
+       ETH_DEFAULT_RX_QUEUE_0                  |       \
+       ETH_DEFAULT_RX_ARP_QUEUE_0              |       \
+       ETH_RECEIVE_BC_IF_NOT_IP_OR_ARP         |       \
+       ETH_RECEIVE_BC_IF_IP                    |       \
+       ETH_RECEIVE_BC_IF_ARP                   |       \
+       ETH_CAPTURE_TCP_FRAMES_DIS              |       \
+       ETH_CAPTURE_UDP_FRAMES_DIS              |       \
+       ETH_DEFAULT_RX_TCP_QUEUE_0              |       \
+       ETH_DEFAULT_RX_UDP_QUEUE_0              |       \
+       ETH_DEFAULT_RX_BPDU_QUEUE_0
+
+#define        EV64360_ETH_PORT_CONFIG_EXTEND_VALUE            \
+       ETH_SPAN_BPDU_PACKETS_AS_NORMAL         |       \
+       ETH_PARTITION_DISABLE
+
+#define        GT_ETH_IPG_INT_RX(value)                        \
+       ((value & 0x3fff) << 8)
+
+#define        EV64360_ETH_PORT_SDMA_CONFIG_VALUE              \
+       ETH_RX_BURST_SIZE_4_64BIT               |       \
+       GT_ETH_IPG_INT_RX(0)                    |       \
+       ETH_TX_BURST_SIZE_4_64BIT
+
+#define        EV64360_ETH_PORT_SERIAL_CONTROL_VALUE           \
+       ETH_FORCE_LINK_PASS                     |       \
+       ETH_ENABLE_AUTO_NEG_FOR_DUPLX           |       \
+       ETH_DISABLE_AUTO_NEG_FOR_FLOW_CTRL      |       \
+       ETH_ADV_SYMMETRIC_FLOW_CTRL             |       \
+       ETH_FORCE_FC_MODE_NO_PAUSE_DIS_TX       |       \
+       ETH_FORCE_BP_MODE_NO_JAM                |       \
+       BIT9                                    |       \
+       ETH_DO_NOT_FORCE_LINK_FAIL              |       \
+       ETH_RETRANSMIT_16_ATTEMPTS              |       \
+       ETH_ENABLE_AUTO_NEG_SPEED_GMII          |       \
+       ETH_DTE_ADV_0                           |       \
+       ETH_DISABLE_AUTO_NEG_BYPASS             |       \
+       ETH_AUTO_NEG_NO_CHANGE                  |       \
+       ETH_MAX_RX_PACKET_9700BYTE              |       \
+       ETH_CLR_EXT_LOOPBACK                    |       \
+       ETH_SET_FULL_DUPLEX_MODE                |       \
+       ETH_ENABLE_FLOW_CTRL_TX_RX_IN_FULL_DUPLEX
+
+static inline u32
+ev64360_bus_freq(void)
+{
+       return 133333333;
+}
+
+#endif /* __PPC_PLATFORMS_EV64360_H */
diff --git a/arch/ppc/platforms/k2.c b/arch/ppc/platforms/k2.c
deleted file mode 100644 (file)
index aacb438..0000000
+++ /dev/null
@@ -1,613 +0,0 @@
-/*
- * arch/ppc/platforms/k2.c
- *
- * Board setup routines for SBS K2
- *
- * Author: Matt Porter <mporter@mvista.com>
- *
- * Updated by: Randy Vinson <rvinson@mvista.com.
- *
- * 2001-2004 (c) MontaVista, Software, Inc.  This file is licensed under
- * the terms of the GNU General Public License version 2.  This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-
-#include <linux/config.h>
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/reboot.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/types.h>
-#include <linux/major.h>
-#include <linux/initrd.h>
-#include <linux/console.h>
-#include <linux/delay.h>
-#include <linux/ide.h>
-#include <linux/irq.h>
-#include <linux/seq_file.h>
-#include <linux/root_dev.h>
-
-#include <asm/system.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <asm/dma.h>
-#include <asm/io.h>
-#include <asm/machdep.h>
-#include <asm/time.h>
-#include <asm/i8259.h>
-#include <asm/todc.h>
-#include <asm/bootinfo.h>
-
-#include <syslib/cpc710.h>
-#include "k2.h"
-
-extern unsigned long loops_per_jiffy;
-extern void gen550_progress(char *, unsigned short);
-
-static unsigned int cpu_7xx[16] = {
-       0, 15, 14, 0, 0, 13, 5, 9, 6, 11, 8, 10, 16, 12, 7, 0
-};
-static unsigned int cpu_6xx[16] = {
-       0, 0, 14, 0, 0, 13, 5, 9, 6, 11, 8, 10, 0, 12, 7, 0
-};
-
-static inline int __init
-k2_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
-{
-       struct pci_controller *hose = pci_bus_to_hose(dev->bus->number);
-       /*
-        * Check our hose index.  If we are zero then we are on the
-        * local PCI hose, otherwise we are on the cPCI hose.
-        */
-       if (!hose->index) {
-               static char pci_irq_table[][4] =
-                       /*
-                        *      PCI IDSEL/INTPIN->INTLINE
-                        *      A       B       C       D
-                        */
-               {
-                       {1,     0,      0,      0},     /* Ethernet */
-                       {5,     5,      5,      5},     /* PMC Site 1 */
-                       {6,     6,      6,      6},     /* PMC Site 2 */
-                       {0,     0,      0,      0},     /* unused */
-                       {0,     0,      0,      0},     /* unused */
-                       {0,     0,      0,      0},     /* PCI-ISA Bridge */
-                       {0,     0,      0,      0},     /* unused */
-                       {0,     0,      0,      0},     /* unused */
-                       {0,     0,      0,      0},     /* unused */
-                       {0,     0,      0,      0},     /* unused */
-                       {0,     0,      0,      0},     /* unused */
-                       {0,     0,      0,      0},     /* unused */
-                       {0,     0,      0,      0},     /* unused */
-                       {0,     0,      0,      0},     /* unused */
-                       {15,    0,      0,      0},     /* M5229 IDE */
-               };
-               const long min_idsel = 3, max_idsel = 17, irqs_per_slot = 4;
-               return PCI_IRQ_TABLE_LOOKUP;
-       } else {
-               static char pci_irq_table[][4] =
-               /*
-                *      PCI IDSEL/INTPIN->INTLINE
-                *      A       B       C       D
-                */
-               {
-                       {10,    11,     12,     9},     /* cPCI slot 8 */
-                       {11,    12,     9,      10},    /* cPCI slot 7 */
-                       {12,    9,      10,     11},    /* cPCI slot 6 */
-                       {9,     10,     11,     12},    /* cPCI slot 5 */
-                       {10,    11,     12,     9},     /* cPCI slot 4 */
-                       {11,    12,     9,      10},    /* cPCI slot 3 */
-                       {12,    9,      10,     11},    /* cPCI slot 2 */
-               };
-               const long min_idsel = 15, max_idsel = 21, irqs_per_slot = 4;
-               return PCI_IRQ_TABLE_LOOKUP;
-       }
-}
-
-void k2_pcibios_fixup(void)
-{
-#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
-       struct pci_dev *ide_dev;
-
-       /*
-        * Enable DMA support on hdc
-        */
-       ide_dev = pci_get_device(PCI_VENDOR_ID_AL,
-                                 PCI_DEVICE_ID_AL_M5229, NULL);
-
-       if (ide_dev) {
-
-               unsigned long ide_dma_base;
-
-               ide_dma_base = pci_resource_start(ide_dev, 4);
-               outb(0x00, ide_dma_base + 0x2);
-               outb(0x20, ide_dma_base + 0xa);
-               pci_dev_put(ide_dev);
-       }
-#endif
-}
-
-void k2_pcibios_fixup_resources(struct pci_dev *dev)
-{
-       int i;
-
-       if ((dev->vendor == PCI_VENDOR_ID_IBM) &&
-           (dev->device == PCI_DEVICE_ID_IBM_CPC710_PCI64)) {
-               pr_debug("Fixup CPC710 resources\n");
-               for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
-                       dev->resource[i].start = 0;
-                       dev->resource[i].end = 0;
-               }
-       }
-}
-
-void k2_setup_hoses(void)
-{
-       struct pci_controller *hose_a, *hose_b;
-
-       /*
-        * Reconfigure CPC710 memory map so
-        * we have some more PCI memory space.
-        */
-
-       /* Set FPHB mode */
-       __raw_writel(0x808000e0, PGCHP);        /* Set FPHB mode */
-
-       /* PCI32 mappings */
-       __raw_writel(0x00000000, K2_PCI32_BAR + PIBAR); /* PCI I/O base */
-       __raw_writel(0x00000000, K2_PCI32_BAR + PMBAR); /* PCI Mem base */
-       __raw_writel(0xf0000000, K2_PCI32_BAR + MSIZE); /* 256MB */
-       __raw_writel(0xfff00000, K2_PCI32_BAR + IOSIZE); /* 1MB */
-       __raw_writel(0xc0000000, K2_PCI32_BAR + SMBAR); /* Base@0xc0000000 */
-       __raw_writel(0x80000000, K2_PCI32_BAR + SIBAR); /* Base@0x80000000 */
-       __raw_writel(0x000000c0, K2_PCI32_BAR + PSSIZE); /* 1GB space */
-       __raw_writel(0x000000c0, K2_PCI32_BAR + PPSIZE); /* 1GB space */
-       __raw_writel(0x00000000, K2_PCI32_BAR + BARPS); /* Base@0x00000000 */
-       __raw_writel(0x00000000, K2_PCI32_BAR + BARPP); /* Base@0x00000000 */
-       __raw_writel(0x00000080, K2_PCI32_BAR + PSBAR); /* Base@0x80 */
-       __raw_writel(0x00000000, K2_PCI32_BAR + PPBAR);
-
-       __raw_writel(0xc0000000, K2_PCI32_BAR + BPMDLK);
-       __raw_writel(0xd0000000, K2_PCI32_BAR + TPMDLK);
-       __raw_writel(0x80000000, K2_PCI32_BAR + BIODLK);
-       __raw_writel(0x80100000, K2_PCI32_BAR + TIODLK);
-       __raw_writel(0xe0008000, K2_PCI32_BAR + DLKCTRL);
-       __raw_writel(0xffffffff, K2_PCI32_BAR + DLKDEV);
-
-       /* PCI64 mappings */
-       __raw_writel(0x00100000, K2_PCI64_BAR + PIBAR); /* PCI I/O base */
-       __raw_writel(0x10000000, K2_PCI64_BAR + PMBAR); /* PCI Mem base */
-       __raw_writel(0xf0000000, K2_PCI64_BAR + MSIZE); /* 256MB */
-       __raw_writel(0xfff00000, K2_PCI64_BAR + IOSIZE); /* 1MB */
-       __raw_writel(0xd0000000, K2_PCI64_BAR + SMBAR); /* Base@0xd0000000 */
-       __raw_writel(0x80100000, K2_PCI64_BAR + SIBAR); /* Base@0x80100000 */
-       __raw_writel(0x000000c0, K2_PCI64_BAR + PSSIZE); /* 1GB space */
-       __raw_writel(0x000000c0, K2_PCI64_BAR + PPSIZE); /* 1GB space */
-       __raw_writel(0x00000000, K2_PCI64_BAR + BARPS); /* Base@0x00000000 */
-       __raw_writel(0x00000000, K2_PCI64_BAR + BARPP); /* Base@0x00000000 */
-
-       /* Setup PCI32 hose */
-       hose_a = pcibios_alloc_controller();
-       if (!hose_a)
-               return;
-
-       hose_a->first_busno = 0;
-       hose_a->last_busno = 0xff;
-       hose_a->pci_mem_offset = K2_PCI32_MEM_BASE;
-
-       pci_init_resource(&hose_a->io_resource,
-                         K2_PCI32_LOWER_IO,
-                         K2_PCI32_UPPER_IO,
-                         IORESOURCE_IO, "PCI32 host bridge");
-
-       pci_init_resource(&hose_a->mem_resources[0],
-                         K2_PCI32_LOWER_MEM + K2_PCI32_MEM_BASE,
-                         K2_PCI32_UPPER_MEM + K2_PCI32_MEM_BASE,
-                         IORESOURCE_MEM, "PCI32 host bridge");
-
-       hose_a->io_space.start = K2_PCI32_LOWER_IO;
-       hose_a->io_space.end = K2_PCI32_UPPER_IO;
-       hose_a->mem_space.start = K2_PCI32_LOWER_MEM;
-       hose_a->mem_space.end = K2_PCI32_UPPER_MEM;
-       hose_a->io_base_virt = (void *)K2_ISA_IO_BASE;
-
-       setup_indirect_pci(hose_a, K2_PCI32_CONFIG_ADDR, K2_PCI32_CONFIG_DATA);
-
-       /* Initialize PCI32 bus registers */
-       early_write_config_byte(hose_a,
-                               hose_a->first_busno,
-                               PCI_DEVFN(0, 0),
-                               CPC710_BUS_NUMBER, hose_a->first_busno);
-
-       early_write_config_byte(hose_a,
-                               hose_a->first_busno,
-                               PCI_DEVFN(0, 0),
-                               CPC710_SUB_BUS_NUMBER, hose_a->last_busno);
-
-       /* Enable PCI interrupt polling */
-       early_write_config_byte(hose_a,
-                               hose_a->first_busno,
-                               PCI_DEVFN(8, 0), 0x45, 0x80);
-
-       /* Route polled PCI interrupts */
-       early_write_config_byte(hose_a,
-                               hose_a->first_busno,
-                               PCI_DEVFN(8, 0), 0x48, 0x58);
-
-       early_write_config_byte(hose_a,
-                               hose_a->first_busno,
-                               PCI_DEVFN(8, 0), 0x49, 0x07);
-
-       early_write_config_byte(hose_a,
-                               hose_a->first_busno,
-                               PCI_DEVFN(8, 0), 0x4a, 0x31);
-
-       early_write_config_byte(hose_a,
-                               hose_a->first_busno,
-                               PCI_DEVFN(8, 0), 0x4b, 0xb9);
-
-       /* route secondary IDE channel interrupt to IRQ 15 */
-       early_write_config_byte(hose_a,
-                               hose_a->first_busno,
-                               PCI_DEVFN(8, 0), 0x75, 0x0f);
-
-       /* enable IDE controller IDSEL */
-       early_write_config_byte(hose_a,
-                               hose_a->first_busno,
-                               PCI_DEVFN(8, 0), 0x58, 0x48);
-
-       /* Enable IDE function */
-       early_write_config_byte(hose_a,
-                               hose_a->first_busno,
-                               PCI_DEVFN(17, 0), 0x50, 0x03);
-
-       /* Set M5229 IDE controller to native mode */
-       early_write_config_byte(hose_a,
-                               hose_a->first_busno,
-                               PCI_DEVFN(17, 0), PCI_CLASS_PROG, 0xdf);
-
-       hose_a->last_busno = pciauto_bus_scan(hose_a, hose_a->first_busno);
-
-       /* Write out correct max subordinate bus number for hose A */
-       early_write_config_byte(hose_a,
-                               hose_a->first_busno,
-                               PCI_DEVFN(0, 0),
-                               CPC710_SUB_BUS_NUMBER, hose_a->last_busno);
-
-       /* Only setup PCI64 hose if we are in the system slot */
-       if (!(readb(K2_MISC_REG) & K2_SYS_SLOT_MASK)) {
-               /* Setup PCI64 hose */
-               hose_b = pcibios_alloc_controller();
-               if (!hose_b)
-                       return;
-
-               hose_b->first_busno = hose_a->last_busno + 1;
-               hose_b->last_busno = 0xff;
-
-               /* Reminder: quit changing the following, it is correct. */
-               hose_b->pci_mem_offset = K2_PCI32_MEM_BASE;
-
-               pci_init_resource(&hose_b->io_resource,
-                                 K2_PCI64_LOWER_IO,
-                                 K2_PCI64_UPPER_IO,
-                                 IORESOURCE_IO, "PCI64 host bridge");
-
-               pci_init_resource(&hose_b->mem_resources[0],
-                                 K2_PCI64_LOWER_MEM + K2_PCI32_MEM_BASE,
-                                 K2_PCI64_UPPER_MEM + K2_PCI32_MEM_BASE,
-                                 IORESOURCE_MEM, "PCI64 host bridge");
-
-               hose_b->io_space.start = K2_PCI64_LOWER_IO;
-               hose_b->io_space.end = K2_PCI64_UPPER_IO;
-               hose_b->mem_space.start = K2_PCI64_LOWER_MEM;
-               hose_b->mem_space.end = K2_PCI64_UPPER_MEM;
-               hose_b->io_base_virt = (void *)K2_ISA_IO_BASE;
-
-               setup_indirect_pci(hose_b,
-                                  K2_PCI64_CONFIG_ADDR, K2_PCI64_CONFIG_DATA);
-
-               /* Initialize PCI64 bus registers */
-               early_write_config_byte(hose_b,
-                                       0,
-                                       PCI_DEVFN(0, 0),
-                                       CPC710_SUB_BUS_NUMBER, 0xff);
-
-               early_write_config_byte(hose_b,
-                                       0,
-                                       PCI_DEVFN(0, 0),
-                                       CPC710_BUS_NUMBER, hose_b->first_busno);
-
-               hose_b->last_busno = pciauto_bus_scan(hose_b,
-                                                     hose_b->first_busno);
-
-               /* Write out correct max subordinate bus number for hose B */
-               early_write_config_byte(hose_b,
-                                       hose_b->first_busno,
-                                       PCI_DEVFN(0, 0),
-                                       CPC710_SUB_BUS_NUMBER,
-                                       hose_b->last_busno);
-
-               /* Configure PCI64 PSBAR */
-               early_write_config_dword(hose_b,
-                                        hose_b->first_busno,
-                                        PCI_DEVFN(0, 0),
-                                        PCI_BASE_ADDRESS_0,
-                                        K2_PCI64_SYS_MEM_BASE);
-       }
-
-       /* Configure i8259 level/edge settings */
-       outb(0x62, 0x4d0);
-       outb(0xde, 0x4d1);
-
-#ifdef CONFIG_CPC710_DATA_GATHERING
-       {
-               unsigned int tmp;
-               tmp = __raw_readl(ABCNTL);
-               /* Enable data gathering on both PCI interfaces */
-               __raw_writel(tmp | 0x05000000, ABCNTL);
-       }
-#endif
-
-       ppc_md.pcibios_fixup = k2_pcibios_fixup;
-       ppc_md.pcibios_fixup_resources = k2_pcibios_fixup_resources;
-       ppc_md.pci_swizzle = common_swizzle;
-       ppc_md.pci_map_irq = k2_map_irq;
-}
-
-static int k2_get_bus_speed(void)
-{
-       int bus_speed;
-       unsigned char board_id;
-
-       board_id = *(unsigned char *)K2_BOARD_ID_REG;
-
-       switch (K2_BUS_SPD(board_id)) {
-
-       case 0:
-       default:
-               bus_speed = 100000000;
-               break;
-
-       case 1:
-               bus_speed = 83333333;
-               break;
-
-       case 2:
-               bus_speed = 75000000;
-               break;
-
-       case 3:
-               bus_speed = 66666666;
-               break;
-       }
-       return bus_speed;
-}
-
-static int k2_get_cpu_speed(void)
-{
-       unsigned long hid1;
-       int cpu_speed;
-
-       hid1 = mfspr(SPRN_HID1) >> 28;
-
-       if ((mfspr(SPRN_PVR) >> 16) == 8)
-               hid1 = cpu_7xx[hid1];
-       else
-               hid1 = cpu_6xx[hid1];
-
-       cpu_speed = k2_get_bus_speed() * hid1 / 2;
-       return cpu_speed;
-}
-
-static void __init k2_calibrate_decr(void)
-{
-       int freq, divisor = 4;
-
-       /* determine processor bus speed */
-       freq = k2_get_bus_speed();
-       tb_ticks_per_jiffy = freq / HZ / divisor;
-       tb_to_us = mulhwu_scale_factor(freq / divisor, 1000000);
-}
-
-static int k2_show_cpuinfo(struct seq_file *m)
-{
-       unsigned char k2_geo_bits, k2_system_slot;
-
-       seq_printf(m, "vendor\t\t: SBS\n");
-       seq_printf(m, "machine\t\t: K2\n");
-       seq_printf(m, "cpu speed\t: %dMhz\n", k2_get_cpu_speed() / 1000000);
-       seq_printf(m, "bus speed\t: %dMhz\n", k2_get_bus_speed() / 1000000);
-       seq_printf(m, "memory type\t: SDRAM\n");
-
-       k2_geo_bits = readb(K2_MSIZ_GEO_REG) & K2_GEO_ADR_MASK;
-       k2_system_slot = !(readb(K2_MISC_REG) & K2_SYS_SLOT_MASK);
-       seq_printf(m, "backplane\t: %s slot board",
-                  k2_system_slot ? "System" : "Non system");
-       seq_printf(m, "with geographical address %x\n", k2_geo_bits);
-
-       return 0;
-}
-
-TODC_ALLOC();
-
-static void __init k2_setup_arch(void)
-{
-       unsigned int cpu;
-
-       /* Setup TODC access */
-       TODC_INIT(TODC_TYPE_MK48T37, 0, 0,
-                 ioremap(K2_RTC_BASE_ADDRESS, K2_RTC_SIZE), 8);
-
-       /* init to some ~sane value until calibrate_delay() runs */
-       loops_per_jiffy = 50000000 / HZ;
-
-       /* make FLASH transactions higher priority than PCI to avoid deadlock */
-       __raw_writel(__raw_readl(SIOC1) | 0x80000000, SIOC1);
-
-       /* Set hardware to access FLASH page 2 */
-       __raw_writel(1 << 29, GPOUT);
-
-       /* Setup PCI host bridges */
-       k2_setup_hoses();
-
-#ifdef CONFIG_BLK_DEV_INITRD
-       if (initrd_start)
-               ROOT_DEV = Root_RAM0;
-       else
-#endif
-#ifdef CONFIG_ROOT_NFS
-               ROOT_DEV = Root_NFS;
-#else
-               ROOT_DEV = Root_HDC1;
-#endif
-
-       /* Identify the system */
-       printk(KERN_INFO "System Identification: SBS K2 - PowerPC 750 @ "
-                       "%d Mhz\n", k2_get_cpu_speed() / 1000000);
-       printk(KERN_INFO "Port by MontaVista Software, Inc. "
-                       "(source@mvista.com)\n");
-
-       /* Identify the CPU manufacturer */
-       cpu = PVR_REV(mfspr(SPRN_PVR));
-       printk(KERN_INFO "CPU manufacturer: %s [rev=%04x]\n",
-                       (cpu & (1 << 15)) ? "IBM" : "Motorola", cpu);
-}
-
-static void k2_restart(char *cmd)
-{
-       local_irq_disable();
-
-       /* Flip FLASH back to page 1 to access firmware image */
-       __raw_writel(0, GPOUT);
-
-       /* SRR0 has system reset vector, SRR1 has default MSR value */
-       /* rfi restores MSR from SRR1 and sets the PC to the SRR0 value */
-       mtspr(SPRN_SRR0, 0xfff00100);
-       mtspr(SPRN_SRR1, 0);
-       __asm__ __volatile__("rfi\n\t");
-
-       /* not reached */
-       for (;;) ;
-}
-
-static void k2_power_off(void)
-{
-       for (;;) ;
-}
-
-static void k2_halt(void)
-{
-       k2_restart(NULL);
-}
-
-/*
- * Set BAT 3 to map PCI32 I/O space.
- */
-static __inline__ void k2_set_bat(void)
-{
-       /* wait for all outstanding memory accesses to complete */
-       mb();
-
-       /* setup DBATs */
-       mtspr(SPRN_DBAT2U, 0x80001ffe);
-       mtspr(SPRN_DBAT2L, 0x8000002a);
-       mtspr(SPRN_DBAT3U, 0xf0001ffe);
-       mtspr(SPRN_DBAT3L, 0xf000002a);
-
-       /* wait for updates */
-       mb();
-}
-
-static unsigned long __init k2_find_end_of_memory(void)
-{
-       unsigned long total;
-       unsigned char msize = 7;        /* Default to 128MB */
-
-       msize = K2_MEM_SIZE(readb(K2_MSIZ_GEO_REG));
-
-       switch (msize) {
-       case 2:
-               /*
-                * This will break without a lowered
-                * KERNELBASE or CONFIG_HIGHMEM on.
-                * It seems non 1GB builds exist yet,
-                * though.
-                */
-               total = K2_MEM_SIZE_1GB;
-               break;
-       case 3:
-       case 4:
-               total = K2_MEM_SIZE_512MB;
-               break;
-       case 5:
-       case 6:
-               total = K2_MEM_SIZE_256MB;
-               break;
-       case 7:
-               total = K2_MEM_SIZE_128MB;
-               break;
-       default:
-               printk
-                   ("K2: Invalid memory size detected, defaulting to 128MB\n");
-               total = K2_MEM_SIZE_128MB;
-               break;
-       }
-       return total;
-}
-
-static void __init k2_map_io(void)
-{
-       io_block_mapping(K2_PCI32_IO_BASE,
-                        K2_PCI32_IO_BASE, 0x00200000, _PAGE_IO);
-       io_block_mapping(0xff000000, 0xff000000, 0x01000000, _PAGE_IO);
-}
-
-static void __init k2_init_irq(void)
-{
-       int i;
-
-       for (i = 0; i < 16; i++)
-               irq_desc[i].handler = &i8259_pic;
-
-       i8259_init(0);
-}
-
-void __init platform_init(unsigned long r3, unsigned long r4,
-                         unsigned long r5, unsigned long r6, unsigned long r7)
-{
-       parse_bootinfo((struct bi_record *)(r3 + KERNELBASE));
-
-       k2_set_bat();
-
-       isa_io_base = K2_ISA_IO_BASE;
-       isa_mem_base = K2_ISA_MEM_BASE;
-       pci_dram_offset = K2_PCI32_SYS_MEM_BASE;
-
-       ppc_md.setup_arch = k2_setup_arch;
-       ppc_md.show_cpuinfo = k2_show_cpuinfo;
-       ppc_md.init_IRQ = k2_init_irq;
-       ppc_md.get_irq = i8259_irq;
-
-       ppc_md.find_end_of_memory = k2_find_end_of_memory;
-       ppc_md.setup_io_mappings = k2_map_io;
-
-       ppc_md.restart = k2_restart;
-       ppc_md.power_off = k2_power_off;
-       ppc_md.halt = k2_halt;
-
-       ppc_md.time_init = todc_time_init;
-       ppc_md.set_rtc_time = todc_set_rtc_time;
-       ppc_md.get_rtc_time = todc_get_rtc_time;
-       ppc_md.calibrate_decr = k2_calibrate_decr;
-
-       ppc_md.nvram_read_val = todc_direct_read_val;
-       ppc_md.nvram_write_val = todc_direct_write_val;
-
-#ifdef CONFIG_SERIAL_TEXT_DEBUG
-       ppc_md.progress = gen550_progress;
-#endif
-}
diff --git a/arch/ppc/platforms/k2.h b/arch/ppc/platforms/k2.h
deleted file mode 100644 (file)
index 78326ab..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * arch/ppc/platforms/k2.h
- *
- * Definitions for SBS K2 board support
- *
- * Author: Matt Porter <mporter@mvista.com>
- *
- * 2001 (c) MontaVista, Software, Inc.  This file is licensed under
- * the terms of the GNU General Public License version 2.  This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-
-#ifndef __PPC_PLATFORMS_K2_H
-#define __PPC_PLATFORMS_K2_H
-
-/*
- * SBS K2 definitions
- */
-
-#define        K2_PCI64_BAR            0xff400000
-#define        K2_PCI32_BAR            0xff500000
-
-#define K2_PCI64_CONFIG_ADDR   (K2_PCI64_BAR + 0x000f8000)
-#define K2_PCI64_CONFIG_DATA   (K2_PCI64_BAR + 0x000f8010)
-
-#define K2_PCI32_CONFIG_ADDR   (K2_PCI32_BAR + 0x000f8000)
-#define K2_PCI32_CONFIG_DATA   (K2_PCI32_BAR + 0x000f8010)
-
-#define K2_PCI64_MEM_BASE      0xd0000000
-#define K2_PCI64_IO_BASE       0x80100000
-
-#define K2_PCI32_MEM_BASE      0xc0000000
-#define K2_PCI32_IO_BASE       0x80000000
-
-#define K2_PCI32_SYS_MEM_BASE  0x80000000
-#define K2_PCI64_SYS_MEM_BASE  K2_PCI32_SYS_MEM_BASE
-
-#define K2_PCI32_LOWER_MEM     0x00000000
-#define K2_PCI32_UPPER_MEM     0x0fffffff
-#define K2_PCI32_LOWER_IO      0x00000000
-#define K2_PCI32_UPPER_IO      0x000fffff
-
-#define K2_PCI64_LOWER_MEM     0x10000000
-#define K2_PCI64_UPPER_MEM     0x1fffffff
-#define K2_PCI64_LOWER_IO      0x00100000
-#define        K2_PCI64_UPPER_IO       0x001fffff
-
-#define K2_ISA_IO_BASE         K2_PCI32_IO_BASE
-#define K2_ISA_MEM_BASE                K2_PCI32_MEM_BASE
-
-#define K2_BOARD_ID_REG                (K2_ISA_IO_BASE + 0x800)
-#define K2_MISC_REG            (K2_ISA_IO_BASE + 0x804)
-#define K2_MSIZ_GEO_REG                (K2_ISA_IO_BASE + 0x808)
-#define K2_HOT_SWAP_REG                (K2_ISA_IO_BASE + 0x80c)
-#define K2_PLD2_REG            (K2_ISA_IO_BASE + 0x80e)
-#define K2_PLD3_REG            (K2_ISA_IO_BASE + 0x80f)
-
-#define K2_BUS_SPD(board_id)   (board_id >> 2) & 3
-
-#define K2_RTC_BASE_OFFSET     0x90000
-#define K2_RTC_BASE_ADDRESS    (K2_PCI32_MEM_BASE + K2_RTC_BASE_OFFSET)
-#define K2_RTC_SIZE            0x8000
-
-#define K2_MEM_SIZE_MASK       0xe0
-#define K2_MEM_SIZE(size_reg)  (size_reg & K2_MEM_SIZE_MASK) >> 5
-#define        K2_MEM_SIZE_1GB         0x40000000
-#define K2_MEM_SIZE_512MB      0x20000000
-#define K2_MEM_SIZE_256MB      0x10000000
-#define K2_MEM_SIZE_128MB      0x08000000
-
-#define K2_L2CACHE_MASK                0x03    /* Mask for 2 L2 Cache bits */
-#define K2_L2CACHE_512KB       0x00    /* 512KB */
-#define K2_L2CACHE_256KB       0x01    /* 256KB */
-#define K2_L2CACHE_1MB         0x02    /* 1MB */
-#define K2_L2CACHE_NONE                0x03    /* None */
-
-#define K2_GEO_ADR_MASK                0x1f
-
-#define K2_SYS_SLOT_MASK       0x08
-
-#endif /* __PPC_PLATFORMS_K2_H */
index 169dbf6534b9d0aec791a1c235d7a10635e4851b..2b53afae0e9c2d7cfe8a01b66d792652c3e6d29d 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/bootimg.h>
 #endif
 #include <asm/io.h>
+#include <asm/unistd.h>
 #include <asm/page.h>
 #include <asm/time.h>
 #include <asm/smp.h>
 #include <asm/mv64x60.h>
 #include <platforms/katana.h>
 
-static struct          mv64x60_handle bh;
-static katana_id_t     katana_id;
-static void __iomem    *cpld_base;
-static void __iomem    *sram_base;
-
-static u32             katana_flash_size_0;
-static u32             katana_flash_size_1;
-
-static u32             katana_bus_frequency;
+static struct mv64x60_handle   bh;
+static katana_id_t             katana_id;
+static void __iomem            *cpld_base;
+static void __iomem            *sram_base;
+static u32                     katana_flash_size_0;
+static u32                     katana_flash_size_1;
+static u32                     katana_bus_frequency;
+static struct pci_controller   katana_hose_a;
 
 unsigned char  __res[sizeof(bd_t)];
 
@@ -71,8 +71,12 @@ katana_irq_lookup_750i(unsigned char idsel, unsigned char pin)
                        KATANA_PCI_INTA_IRQ_750i, KATANA_PCI_INTB_IRQ_750i },
                /* IDSEL 6 (T8110) */
                {KATANA_PCI_INTD_IRQ_750i, 0, 0, 0 },
+               /* IDSEL 7 (unused) */
+               {0, 0, 0, 0 },
+               /* IDSEL 8 (Intel 82544) (752i only but doesn't harm 750i) */
+               {KATANA_PCI_INTD_IRQ_750i, 0, 0, 0 },
        };
-       const long min_idsel = 4, max_idsel = 6, irqs_per_slot = 4;
+       const long min_idsel = 4, max_idsel = 8, irqs_per_slot = 4;
 
        return PCI_IRQ_TABLE_LOOKUP;
 }
@@ -148,7 +152,7 @@ katana_get_proc_num(void)
                        save_exclude = mv64x60_pci_exclude_bridge;
                        mv64x60_pci_exclude_bridge = 0;
 
-                       early_read_config_word(bh.hose_a, 0,
+                       early_read_config_word(bh.hose_b, 0,
                                PCI_DEVFN(0,0), PCI_DEVICE_ID, &val);
 
                        mv64x60_pci_exclude_bridge = save_exclude;
@@ -191,7 +195,8 @@ katana_setup_bridge(void)
        struct mv64x60_setup_info si;
        void __iomem *vaddr;
        int i;
-       u16 val;
+       u32 v;
+       u16 val, type;
        u8 save_exclude;
 
        /*
@@ -222,6 +227,20 @@ katana_setup_bridge(void)
                        PCI_DEVICE_ID, val);
        }
 
+       /*
+        * While we're in here, set the hotswap register correctly.
+        * Turn off blue LED; mask ENUM#, clear insertion & extraction bits.
+        */
+       early_read_config_dword(&hose, 0, PCI_DEVFN(0, 0),
+               MV64360_PCICFG_CPCI_HOTSWAP, &v);
+       v &= ~(1<<19);
+       v |= ((1<<17) | (1<<22) | (1<<23));
+       early_write_config_dword(&hose, 0, PCI_DEVFN(0, 0),
+               MV64360_PCICFG_CPCI_HOTSWAP, v);
+
+       /* While we're at it, grab the bridge type for later */
+       early_read_config_word(&hose, 0, PCI_DEVFN(0, 0), PCI_DEVICE_ID, &type);
+
        mv64x60_pci_exclude_bridge = save_exclude;
        iounmap(vaddr);
 
@@ -251,21 +270,23 @@ katana_setup_bridge(void)
                si.idma_options[i] = MV64360_IDMA2MEM_SNOOP_NONE;
 
                si.pci_1.acc_cntl_options[i] =
-                   MV64360_PCI_ACC_CNTL_SNOOP_NONE |
-                   MV64360_PCI_ACC_CNTL_SWAP_NONE |
-                   MV64360_PCI_ACC_CNTL_MBURST_128_BYTES |
-                   MV64360_PCI_ACC_CNTL_RDSIZE_256_BYTES;
+                       MV64360_PCI_ACC_CNTL_SNOOP_NONE |
+                       MV64360_PCI_ACC_CNTL_SWAP_NONE |
+                       MV64360_PCI_ACC_CNTL_MBURST_128_BYTES |
+                       MV64360_PCI_ACC_CNTL_RDSIZE_256_BYTES;
 #else
                si.cpu_prot_options[i] = 0;
-               si.enet_options[i] = MV64360_ENET2MEM_SNOOP_NONE; /* errata */
-               si.mpsc_options[i] = MV64360_MPSC2MEM_SNOOP_NONE; /* errata */
-               si.idma_options[i] = MV64360_IDMA2MEM_SNOOP_NONE; /* errata */
+               si.enet_options[i] = MV64360_ENET2MEM_SNOOP_WB;
+               si.mpsc_options[i] = MV64360_MPSC2MEM_SNOOP_WB;
+               si.idma_options[i] = MV64360_IDMA2MEM_SNOOP_WB;
 
                si.pci_1.acc_cntl_options[i] =
-                   MV64360_PCI_ACC_CNTL_SNOOP_WB |
-                   MV64360_PCI_ACC_CNTL_SWAP_NONE |
-                   MV64360_PCI_ACC_CNTL_MBURST_32_BYTES |
-                   MV64360_PCI_ACC_CNTL_RDSIZE_32_BYTES;
+                       MV64360_PCI_ACC_CNTL_SNOOP_WB |
+                       MV64360_PCI_ACC_CNTL_SWAP_NONE |
+                       MV64360_PCI_ACC_CNTL_MBURST_32_BYTES |
+                       ((type == PCI_DEVICE_ID_MARVELL_MV64360) ?
+                               MV64360_PCI_ACC_CNTL_RDSIZE_32_BYTES :
+                               MV64360_PCI_ACC_CNTL_RDSIZE_256_BYTES);
 #endif
        }
 
@@ -281,12 +302,26 @@ katana_setup_bridge(void)
        mv64x60_set_bus(&bh, 1, 0);
        bh.hose_b->first_busno = 0;
        bh.hose_b->last_busno = 0xff;
+
+       /*
+        * Need to access hotswap reg which is in the pci config area of the
+        * bridge's hose 0.  Note that pcibios_alloc_controller() can't be used
+        * to alloc hose_a b/c that would make hose 0 known to the generic
+        * pci code which we don't want.
+        */
+       bh.hose_a = &katana_hose_a;
+       setup_indirect_pci_nomap(bh.hose_a,
+               bh.v_base + MV64x60_PCI0_CONFIG_ADDR,
+               bh.v_base + MV64x60_PCI0_CONFIG_DATA);
 }
 
 /* Bridge & platform setup routines */
 void __init
 katana_intr_setup(void)
 {
+       if (bh.type == MV64x60_TYPE_MV64460) /* As per instns from Marvell */
+               mv64x60_clr_bits(&bh, MV64x60_CPU_MASTER_CNTL, 1 << 15);
+
        /* MPP 8, 9, and 10 */
        mv64x60_clr_bits(&bh, MV64x60_MPP_CNTL_1, 0xfff);
 
@@ -309,9 +344,16 @@ katana_intr_setup(void)
        /* Config GPP intr ctlr to respond to level trigger */
        mv64x60_set_bits(&bh, MV64x60_COMM_ARBITER_CNTL, (1<<10));
 
-       /* Erranum FEr PCI-#8 */
-       mv64x60_clr_bits(&bh, MV64x60_PCI0_CMD, (1<<5) | (1<<9));
-       mv64x60_clr_bits(&bh, MV64x60_PCI1_CMD, (1<<5) | (1<<9));
+       if (bh.type == MV64x60_TYPE_MV64360) {
+               /* Erratum FEr PCI-#9 */
+               mv64x60_clr_bits(&bh, MV64x60_PCI1_CMD,
+                               (1<<4) | (1<<5) | (1<<6) | (1<<7));
+               mv64x60_set_bits(&bh, MV64x60_PCI1_CMD, (1<<8) | (1<<9));
+       } else {
+               mv64x60_clr_bits(&bh, MV64x60_PCI1_CMD, (1<<6) | (1<<7));
+               mv64x60_set_bits(&bh, MV64x60_PCI1_CMD,
+                               (1<<4) | (1<<5) | (1<<8) | (1<<9));
+       }
 
        /*
         * Dismiss and then enable interrupt on GPP interrupt cause
@@ -473,17 +515,46 @@ katana_setup_arch(void)
                ppc_md.progress("katana_setup_arch: exit", 0);
 }
 
+void
+katana_fixup_resources(struct pci_dev *dev)
+{
+       u16     v16;
+
+       pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, L1_CACHE_LINE_SIZE>>2);
+
+       pci_read_config_word(dev, PCI_COMMAND, &v16);
+       v16 |= PCI_COMMAND_INVALIDATE | PCI_COMMAND_FAST_BACK;
+       pci_write_config_word(dev, PCI_COMMAND, v16);
+}
+
+static const unsigned int cpu_750xx[32] = { /* 750FX & 750GX */
+        0,  0,  2,  2,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,/* 0-15*/
+       16, 17, 18, 19, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40,  0 /*16-31*/
+};
+
+static int
+katana_get_cpu_freq(void)
+{
+       unsigned long   pll_cfg;
+
+       pll_cfg = (mfspr(SPRN_HID1) & 0xf8000000) >> 27;
+       return katana_bus_frequency * cpu_750xx[pll_cfg]/2;
+}
+
 /* Platform device data fixup routines. */
 #if defined(CONFIG_SERIAL_MPSC)
 static void __init
 katana_fixup_mpsc_pdata(struct platform_device *pdev)
 {
-       struct mpsc_pdata *pdata;
+       struct mpsc_pdata *pdata = (struct mpsc_pdata *)pdev->dev.platform_data;
+       bd_t *bdp = (bd_t *)__res;
 
-       pdata = (struct mpsc_pdata *)pdev->dev.platform_data;
+       if (bdp->bi_baudrate)
+               pdata->default_baud = bdp->bi_baudrate;
+       else
+               pdata->default_baud = KATANA_DEFAULT_BAUD;
 
        pdata->max_idle = 40;
-       pdata->default_baud = KATANA_DEFAULT_BAUD;
        pdata->brg_clk_src = KATANA_MPSC_CLK_SRC;
        /*
         * TCLK (not SysCLk) is routed to BRG, then to the MPSC.  On most parts,
@@ -513,6 +584,18 @@ katana_fixup_eth_pdata(struct platform_device *pdev)
 }
 #endif
 
+#if defined(CONFIG_SYSFS)
+static void __init
+katana_fixup_mv64xxx_pdata(struct platform_device *pdev)
+{
+       struct mv64xxx_pdata *pdata = (struct mv64xxx_pdata *)
+               pdev->dev.platform_data;
+
+       /* Katana supports the mv64xxx hotswap register */
+       pdata->hs_reg_valid = 1;
+}
+#endif
+
 static int __init
 katana_platform_notify(struct device *dev)
 {
@@ -528,6 +611,9 @@ katana_platform_notify(struct device *dev)
                { MV643XX_ETH_NAME ".0", katana_fixup_eth_pdata },
                { MV643XX_ETH_NAME ".1", katana_fixup_eth_pdata },
                { MV643XX_ETH_NAME ".2", katana_fixup_eth_pdata },
+#endif
+#if defined(CONFIG_SYSFS)
+               { MV64XXX_DEV_NAME ".0", katana_fixup_mv64xxx_pdata },
 #endif
        };
        struct platform_device  *pdev;
@@ -536,8 +622,7 @@ katana_platform_notify(struct device *dev)
        if (dev && dev->bus_id)
                for (i=0; i<ARRAY_SIZE(dev_map); i++)
                        if (!strncmp(dev->bus_id, dev_map[i].bus_id,
-                               BUS_ID_SIZE)) {
-
+                                       BUS_ID_SIZE)) {
                                pdev = container_of(dev,
                                        struct platform_device, dev);
                                dev_map[i].rtn(pdev);
@@ -578,8 +663,7 @@ katana_setup_mtd(void)
        ptbl_entries = (size >= (64*MB)) ? 6 : 4;
 
        if ((ptbl = kmalloc(ptbl_entries * sizeof(struct mtd_partition),
-               GFP_KERNEL)) == NULL) {
-
+                       GFP_KERNEL)) == NULL) {
                printk(KERN_WARNING "Can't alloc MTD partition table\n");
                return -ENOMEM;
        }
@@ -611,7 +695,6 @@ katana_setup_mtd(void)
        physmap_set_partitions(ptbl, ptbl_entries);
        return 0;
 }
-
 arch_initcall(katana_setup_mtd);
 #endif
 
@@ -632,7 +715,22 @@ katana_halt(void)
 {
        u8      v;
 
-       if (katana_id == KATANA_ID_752I) {
+       /* Turn on blue LED to indicate its okay to remove */
+       if (katana_id == KATANA_ID_750I) {
+               u32     v;
+               u8      save_exclude;
+
+               /* Set LOO bit in cPCI HotSwap reg of hose 0 to turn on LED. */
+               save_exclude = mv64x60_pci_exclude_bridge;
+               mv64x60_pci_exclude_bridge = 0;
+               early_read_config_dword(bh.hose_a, 0, PCI_DEVFN(0, 0),
+                       MV64360_PCICFG_CPCI_HOTSWAP, &v);
+               v &= 0xff;
+               v |= (1 << 19);
+               early_write_config_dword(bh.hose_a, 0, PCI_DEVFN(0, 0),
+                       MV64360_PCICFG_CPCI_HOTSWAP, v);
+               mv64x60_pci_exclude_bridge = save_exclude;
+       } else if (katana_id == KATANA_ID_752I) {
                   v = in_8(cpld_base + HSL_PLD_BASE + HSL_PLD_HOT_SWAP_OFF);
                   v |= HSL_PLD_HOT_SWAP_LED_BIT;
                   out_8(cpld_base + HSL_PLD_BASE + HSL_PLD_HOT_SWAP_OFF, v);
@@ -652,37 +750,65 @@ katana_power_off(void)
 static int
 katana_show_cpuinfo(struct seq_file *m)
 {
+       char    *s;
+
+       seq_printf(m, "cpu freq\t: %dMHz\n",
+               (katana_get_cpu_freq() + 500000) / 1000000);
+       seq_printf(m, "bus freq\t: %ldMHz\n",
+               ((long)katana_bus_frequency + 500000) / 1000000);
        seq_printf(m, "vendor\t\t: Artesyn Communication Products, LLC\n");
 
        seq_printf(m, "board\t\t: ");
-
        switch (katana_id) {
        case KATANA_ID_3750:
-               seq_printf(m, "Katana 3750\n");
+               seq_printf(m, "Katana 3750");
                break;
 
        case KATANA_ID_750I:
-               seq_printf(m, "Katana 750i\n");
+               seq_printf(m, "Katana 750i");
                break;
 
        case KATANA_ID_752I:
-               seq_printf(m, "Katana 752i\n");
+               seq_printf(m, "Katana 752i");
                break;
 
        default:
-               seq_printf(m, "Unknown\n");
+               seq_printf(m, "Unknown");
                break;
        }
-
-       seq_printf(m, "product ID\t: 0x%x\n",
+       seq_printf(m, " (product id: 0x%x)\n",
                   in_8(cpld_base + KATANA_CPLD_PRODUCT_ID));
+
+       seq_printf(m, "pci mode\t: %sMonarch\n",
+               katana_is_monarch()? "" : "Non-");
        seq_printf(m, "hardware rev\t: 0x%x\n",
                   in_8(cpld_base+KATANA_CPLD_HARDWARE_VER));
-       seq_printf(m, "PLD rev\t\t: 0x%x\n",
+       seq_printf(m, "pld rev\t\t: 0x%x\n",
                   in_8(cpld_base + KATANA_CPLD_PLD_VER));
-       seq_printf(m, "PLB freq\t: %ldMhz\n",
-               (long)katana_bus_frequency / 1000000);
-       seq_printf(m, "PCI\t\t: %sMonarch\n", katana_is_monarch()? "" : "Non-");
+
+       switch(bh.type) {
+       case MV64x60_TYPE_GT64260A:
+               s = "gt64260a";
+               break;
+       case MV64x60_TYPE_GT64260B:
+               s = "gt64260b";
+               break;
+       case MV64x60_TYPE_MV64360:
+               s = "mv64360";
+               break;
+       case MV64x60_TYPE_MV64460:
+               s = "mv64460";
+               break;
+       default:
+               s = "Unknown";
+       }
+       seq_printf(m, "bridge type\t: %s\n", s);
+       seq_printf(m, "bridge rev\t: 0x%x\n", bh.rev);
+#if defined(CONFIG_NOT_COHERENT_CACHE)
+       seq_printf(m, "coherency\t: %s\n", "off");
+#else
+       seq_printf(m, "coherency\t: %s\n", "on");
+#endif
 
        return 0;
 }
@@ -701,11 +827,20 @@ katana_calibrate_decr(void)
        tb_to_us = mulhwu_scale_factor(freq, 1000000);
 }
 
+/*
+ * The katana supports both uImage and zImage.  If uImage, get the mem size
+ * from the bd info.  If zImage, the bootwrapper adds a BI_MEMSIZE entry in
+ * the bi_rec data which is sucked out and put into boot_mem_size by
+ * parse_bootinfo().  MMU_init() will then use the boot_mem_size for the mem
+ * size and not call this routine.  The only way this will fail is when a uImage
+ * is used but the fw doesn't pass in a valid bi_memsize.  This should never
+ * happen, though.
+ */
 unsigned long __init
 katana_find_end_of_memory(void)
 {
-       return mv64x60_get_mem_size(CONFIG_MV64X60_NEW_BASE,
-               MV64x60_TYPE_MV64360);
+       bd_t *bdp = (bd_t *)__res;
+       return bdp->bi_memsize;
 }
 
 #if defined(CONFIG_I2C_MV64XXX) && defined(CONFIG_SENSORS_M41T00)
@@ -729,15 +864,6 @@ katana_rtc_hookup(void)
 late_initcall(katana_rtc_hookup);
 #endif
 
-static inline void
-katana_set_bat(void)
-{
-       mb();
-       mtspr(SPRN_DBAT2U, 0xf0001ffe);
-       mtspr(SPRN_DBAT2L, 0xf000002a);
-       mb();
-}
-
 #if defined(CONFIG_SERIAL_TEXT_DEBUG) && defined(CONFIG_SERIAL_MPSC_CONSOLE)
 static void __init
 katana_map_io(void)
@@ -763,15 +889,24 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
         */
        if (r3 && r6) {
                /* copy board info structure */
-               memcpy( (void *)__res,(void *)(r3+KERNELBASE), sizeof(bd_t) );
+               memcpy((void *)__res, (void *)(r3+KERNELBASE), sizeof(bd_t));
                /* copy command line */
                *(char *)(r7+KERNELBASE) = 0;
                strcpy(cmd_line, (char *)(r6+KERNELBASE));
        }
 
+#ifdef CONFIG_BLK_DEV_INITRD
+       /* take care of initrd if we have one */
+       if (r4) {
+               initrd_start = r4 + KERNELBASE;
+               initrd_end = r5 + KERNELBASE;
+       }
+#endif /* CONFIG_BLK_DEV_INITRD */
+
        isa_mem_base = 0;
 
        ppc_md.setup_arch = katana_setup_arch;
+       ppc_md.pcibios_fixup_resources = katana_fixup_resources;
        ppc_md.show_cpuinfo = katana_show_cpuinfo;
        ppc_md.init_IRQ = mv64360_init_irq;
        ppc_md.get_irq = mv64360_get_irq;
@@ -790,6 +925,4 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
 #if defined(CONFIG_SERIAL_MPSC) || defined(CONFIG_MV643XX_ETH)
        platform_notify = katana_platform_notify;
 #endif
-
-       katana_set_bat(); /* Need for katana_find_end_of_memory and progress */
 }
index b82ed81950f591e17676ea0e4513787cb66ad974..597257eff2ec5a2e6216cb99d717863ac66cb43b 100644 (file)
 #define KATANA_PCI1_IO_SIZE                     0x04000000 /* 64 MB */
 
 /* Board-specific IRQ info */
-#define  KATANA_PCI_INTA_IRQ_3750              64+8
-#define  KATANA_PCI_INTB_IRQ_3750              64+9
-#define  KATANA_PCI_INTC_IRQ_3750              64+10
-
-#define  KATANA_PCI_INTA_IRQ_750i              64+8
-#define  KATANA_PCI_INTB_IRQ_750i              64+9
-#define  KATANA_PCI_INTC_IRQ_750i              64+10
-#define  KATANA_PCI_INTD_IRQ_750i              64+14
+#define  KATANA_PCI_INTA_IRQ_3750              (64+8)
+#define  KATANA_PCI_INTB_IRQ_3750              (64+9)
+#define  KATANA_PCI_INTC_IRQ_3750              (64+10)
+
+#define  KATANA_PCI_INTA_IRQ_750i              (64+8)
+#define  KATANA_PCI_INTB_IRQ_750i              (64+9)
+#define  KATANA_PCI_INTC_IRQ_750i              (64+10)
+#define  KATANA_PCI_INTD_IRQ_750i              (64+14)
 
 #define KATANA_CPLD_RST_EVENT                  0x00000000
 #define KATANA_CPLD_RST_CMD                    0x00001000
diff --git a/arch/ppc/platforms/mcpn765.c b/arch/ppc/platforms/mcpn765.c
deleted file mode 100644 (file)
index e88d294..0000000
+++ /dev/null
@@ -1,527 +0,0 @@
-/*
- * arch/ppc/platforms/mcpn765.c
- *
- * Board setup routines for the Motorola MCG MCPN765 cPCI Board.
- *
- * Author: Mark A. Greer
- *         mgreer@mvista.com
- *
- * Modified by Randy Vinson (rvinson@mvista.com)
- *
- * 2001-2002 (c) MontaVista, Software, Inc.  This file is licensed under
- * the terms of the GNU General Public License version 2.  This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-
-/*
- * This file adds support for the Motorola MCG MCPN765.
- */
-#include <linux/config.h>
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/reboot.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/major.h>
-#include <linux/initrd.h>
-#include <linux/console.h>
-#include <linux/delay.h>
-#include <linux/irq.h>
-#include <linux/seq_file.h>
-#include <linux/root_dev.h>
-#include <linux/serial.h>
-#include <linux/tty.h> /* for linux/serial_core.h */
-#include <linux/serial_core.h>
-#include <linux/slab.h>
-
-#include <asm/system.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <asm/time.h>
-#include <asm/dma.h>
-#include <asm/byteorder.h>
-#include <asm/io.h>
-#include <asm/machdep.h>
-#include <asm/prom.h>
-#include <asm/smp.h>
-#include <asm/open_pic.h>
-#include <asm/i8259.h>
-#include <asm/todc.h>
-#include <asm/pci-bridge.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <asm/bootinfo.h>
-#include <asm/hawk.h>
-#include <asm/kgdb.h>
-
-#include "mcpn765.h"
-
-static u_char mcpn765_openpic_initsenses[] __initdata = {
-       (IRQ_SENSE_EDGE  | IRQ_POLARITY_POSITIVE),/* 16: i8259 cascade */
-       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 17: COM1,2,3,4 */
-       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 18: Enet 1 (front) */
-       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 19: HAWK WDT XXXX */
-       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 20: 21554 bridge */
-       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 21: cPCI INTA# */
-       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 22: cPCI INTB# */
-       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 23: cPCI INTC# */
-       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 24: cPCI INTD# */
-       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 25: PMC1 INTA#,PMC2 INTB#*/
-       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 26: PMC1 INTB#,PMC2 INTC#*/
-       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 27: PMC1 INTC#,PMC2 INTD#*/
-       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 28: PMC1 INTD#,PMC2 INTA#*/
-       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 29: Enet 2 (J3) */
-       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 30: Abort Switch */
-       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 31: RTC Alarm */
-};
-
-extern void mcpn765_set_VIA_IDE_native(void);
-
-extern u_int openpic_irq(void);
-extern char cmd_line[];
-
-extern void gen550_progress(char *, unsigned short);
-extern void gen550_init(int, struct uart_port *);
-
-int use_of_interrupt_tree = 0;
-
-static void mcpn765_halt(void);
-
-TODC_ALLOC();
-
-/*
- * Motorola MCG MCPN765 interrupt routing.
- */
-static inline int
-mcpn765_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
-{
-       static char pci_irq_table[][4] =
-       /*
-        *      PCI IDSEL/INTPIN->INTLINE
-        *         A   B   C   D
-        */
-       {
-               { 14,  0,  0,  0 },     /* IDSEL 11 - have to manually set */
-               {  0,  0,  0,  0 },     /* IDSEL 12 - unused */
-               {  0,  0,  0,  0 },     /* IDSEL 13 - unused */
-               { 18,  0,  0,  0 },     /* IDSEL 14 - Enet 0 */
-               {  0,  0,  0,  0 },     /* IDSEL 15 - unused */
-               { 25, 26, 27, 28 },     /* IDSEL 16 - PMC Slot 1 */
-               { 28, 25, 26, 27 },     /* IDSEL 17 - PMC Slot 2 */
-               {  0,  0,  0,  0 },     /* IDSEL 18 - PMC 2B Connector XXXX */
-               { 29,  0,  0,  0 },     /* IDSEL 19 - Enet 1 */
-               { 20,  0,  0,  0 },     /* IDSEL 20 - 21554 cPCI bridge */
-       };
-
-       const long min_idsel = 11, max_idsel = 20, irqs_per_slot = 4;
-       return PCI_IRQ_TABLE_LOOKUP;
-}
-
-void __init
-mcpn765_set_VIA_IDE_legacy(void)
-{
-       unsigned short vend, dev;
-
-       early_read_config_word(0, 0, PCI_DEVFN(0xb, 1), PCI_VENDOR_ID, &vend);
-       early_read_config_word(0, 0, PCI_DEVFN(0xb, 1), PCI_DEVICE_ID, &dev);
-
-       if ((vend == PCI_VENDOR_ID_VIA) &&
-           (dev == PCI_DEVICE_ID_VIA_82C586_1)) {
-
-               unsigned char temp;
-
-               /* put back original "standard" port base addresses */
-               early_write_config_dword(0, 0, PCI_DEVFN(0xb, 1),
-                                        PCI_BASE_ADDRESS_0, 0x1f1);
-               early_write_config_dword(0, 0, PCI_DEVFN(0xb, 1),
-                                        PCI_BASE_ADDRESS_1, 0x3f5);
-               early_write_config_dword(0, 0, PCI_DEVFN(0xb, 1),
-                                        PCI_BASE_ADDRESS_2, 0x171);
-               early_write_config_dword(0, 0, PCI_DEVFN(0xb, 1),
-                                        PCI_BASE_ADDRESS_3, 0x375);
-               early_write_config_dword(0, 0, PCI_DEVFN(0xb, 1),
-                                        PCI_BASE_ADDRESS_4, 0xcc01);
-
-               /* put into legacy mode */
-               early_read_config_byte(0, 0, PCI_DEVFN(0xb, 1), PCI_CLASS_PROG,
-                                      &temp);
-               temp &= ~0x05;
-               early_write_config_byte(0, 0, PCI_DEVFN(0xb, 1), PCI_CLASS_PROG,
-                                       temp);
-       }
-}
-
-void
-mcpn765_set_VIA_IDE_native(void)
-{
-       unsigned short vend, dev;
-
-       early_read_config_word(0, 0, PCI_DEVFN(0xb, 1), PCI_VENDOR_ID, &vend);
-       early_read_config_word(0, 0, PCI_DEVFN(0xb, 1), PCI_DEVICE_ID, &dev);
-
-       if ((vend == PCI_VENDOR_ID_VIA) &&
-           (dev == PCI_DEVICE_ID_VIA_82C586_1)) {
-
-               unsigned char temp;
-
-               /* put into native mode */
-               early_read_config_byte(0, 0, PCI_DEVFN(0xb, 1), PCI_CLASS_PROG,
-                                      &temp);
-               temp |= 0x05;
-               early_write_config_byte(0, 0, PCI_DEVFN(0xb, 1), PCI_CLASS_PROG,
-                                       temp);
-       }
-}
-
-/*
- * Initialize the VIA 82c586b.
- */
-static void __init
-mcpn765_setup_via_82c586b(void)
-{
-       struct pci_dev  *dev;
-       u_char          c;
-
-       if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
-                                  PCI_DEVICE_ID_VIA_82C586_0,
-                                  NULL)) == NULL) {
-               printk("No VIA ISA bridge found\n");
-               mcpn765_halt();
-               /* NOTREACHED */
-       }
-
-       /*
-        * If the firmware left the EISA 4d0/4d1 ports enabled, make sure
-        * IRQ 14 is set for edge.
-        */
-       pci_read_config_byte(dev, 0x47, &c);
-
-       if (c & (1<<5)) {
-               c = inb(0x4d1);
-               c &= ~(1<<6);
-               outb(c, 0x4d1);
-       }
-
-       /* Disable PNP IRQ routing since we use the Hawk's MPIC */
-       pci_write_config_dword(dev, 0x54, 0);
-       pci_write_config_byte(dev, 0x58, 0);
-
-       pci_dev_put(dev);
-       if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
-                                  PCI_DEVICE_ID_VIA_82C586_1,
-                                  NULL)) == NULL) {
-               printk("No VIA ISA bridge found\n");
-               mcpn765_halt();
-               /* NOTREACHED */
-       }
-
-       /*
-        * PPCBug doesn't set the enable bits for the IDE device.
-        * Turn them on now.
-        */
-       pci_read_config_byte(dev, 0x40, &c);
-       c |= 0x03;
-       pci_write_config_byte(dev, 0x40, c);
-       pci_dev_put(dev);
-
-       return;
-}
-
-void __init
-mcpn765_pcibios_fixup(void)
-{
-       /* Do MCPN765 board specific initialization.  */
-       mcpn765_setup_via_82c586b();
-}
-
-void __init
-mcpn765_find_bridges(void)
-{
-       struct pci_controller   *hose;
-
-       hose = pcibios_alloc_controller();
-
-       if (!hose)
-               return;
-
-       hose->first_busno = 0;
-       hose->last_busno = 0xff;
-       hose->pci_mem_offset = MCPN765_PCI_PHY_MEM_OFFSET;
-
-       pci_init_resource(&hose->io_resource,
-                       MCPN765_PCI_IO_START,
-                       MCPN765_PCI_IO_END,
-                       IORESOURCE_IO,
-                       "PCI host bridge");
-
-       pci_init_resource(&hose->mem_resources[0],
-                       MCPN765_PCI_MEM_START,
-                       MCPN765_PCI_MEM_END,
-                       IORESOURCE_MEM,
-                       "PCI host bridge");
-
-       hose->io_space.start = MCPN765_PCI_IO_START;
-       hose->io_space.end = MCPN765_PCI_IO_END;
-       hose->mem_space.start = MCPN765_PCI_MEM_START;
-       hose->mem_space.end = MCPN765_PCI_MEM_END - HAWK_MPIC_SIZE;
-
-       if (hawk_init(hose,
-                      MCPN765_HAWK_PPC_REG_BASE,
-                      MCPN765_PROC_PCI_MEM_START,
-                      MCPN765_PROC_PCI_MEM_END - HAWK_MPIC_SIZE,
-                      MCPN765_PROC_PCI_IO_START,
-                      MCPN765_PROC_PCI_IO_END,
-                      MCPN765_PCI_MEM_END - HAWK_MPIC_SIZE + 1) != 0) {
-               printk("Could not initialize HAWK bridge\n");
-       }
-
-       /* VIA IDE BAR decoders are only 16-bits wide. PCI Auto Config
-        * will reassign the bars outside of 16-bit I/O space, which will 
-        * "break" things. To prevent this, we'll set the IDE chip into
-        * legacy mode and seed the bars with their legacy addresses (in 16-bit
-        * I/O space). The Auto Config code will skip the IDE contoller in 
-        * legacy mode, so our bar values will stick.
-        */
-       mcpn765_set_VIA_IDE_legacy();
-
-       hose->last_busno = pciauto_bus_scan(hose, hose->first_busno);
-
-       /* Now that we've got 16-bit addresses in the bars, we can switch the
-        * IDE controller back into native mode so we can do "modern" resource
-        * and interrupt management.
-        */
-       mcpn765_set_VIA_IDE_native();
-
-       ppc_md.pcibios_fixup = mcpn765_pcibios_fixup;
-       ppc_md.pcibios_fixup_bus = NULL;
-       ppc_md.pci_swizzle = common_swizzle;
-       ppc_md.pci_map_irq = mcpn765_map_irq;
-
-       return;
-}
-static void __init
-mcpn765_setup_arch(void)
-{
-       struct pci_controller *hose;
-
-       if ( ppc_md.progress )
-               ppc_md.progress("mcpn765_setup_arch: enter", 0);
-
-       loops_per_jiffy = 50000000 / HZ;
-
-#ifdef CONFIG_BLK_DEV_INITRD
-       if (initrd_start)
-               ROOT_DEV = Root_RAM0;
-       else
-#endif
-#ifdef CONFIG_ROOT_NFS
-               ROOT_DEV = Root_NFS;
-#else
-               ROOT_DEV = Root_SDA2;
-#endif
-
-       if ( ppc_md.progress )
-               ppc_md.progress("mcpn765_setup_arch: find_bridges", 0);
-
-       /* Lookup PCI host bridges */
-       mcpn765_find_bridges();
-
-       hose = pci_bus_to_hose(0);
-       isa_io_base = (ulong)hose->io_base_virt;
-
-       TODC_INIT(TODC_TYPE_MK48T37,
-                 (MCPN765_PHYS_NVRAM_AS0 - isa_io_base),
-                 (MCPN765_PHYS_NVRAM_AS1 - isa_io_base),
-                 (MCPN765_PHYS_NVRAM_DATA - isa_io_base),
-                 8);
-
-       OpenPIC_InitSenses = mcpn765_openpic_initsenses;
-       OpenPIC_NumInitSenses = sizeof(mcpn765_openpic_initsenses);
-
-       printk("Motorola MCG MCPN765 cPCI Non-System Board\n");
-       printk("MCPN765 port (MontaVista Software, Inc. (source@mvista.com))\n");
-
-       if ( ppc_md.progress )
-               ppc_md.progress("mcpn765_setup_arch: exit", 0);
-
-       return;
-}
-
-static void __init
-mcpn765_init2(void)
-{
-
-       request_region(0x00,0x20,"dma1");
-       request_region(0x20,0x20,"pic1");
-       request_region(0x40,0x20,"timer");
-       request_region(0x80,0x10,"dma page reg");
-       request_region(0xa0,0x20,"pic2");
-       request_region(0xc0,0x20,"dma2");
-
-       return;
-}
-
-/*
- * Interrupt setup and service.
- * Have MPIC on HAWK and cascaded 8259s on VIA 82586 cascaded to MPIC.
- */
-static void __init
-mcpn765_init_IRQ(void)
-{
-       int i;
-
-       if ( ppc_md.progress )
-               ppc_md.progress("init_irq: enter", 0);
-
-       openpic_init(NUM_8259_INTERRUPTS);
-       openpic_hookup_cascade(NUM_8259_INTERRUPTS, "82c59 cascade",
-                       i8259_irq);
-
-       for(i=0; i < NUM_8259_INTERRUPTS; i++)
-               irq_desc[i].handler = &i8259_pic;
-
-       i8259_init(0);
-
-       if ( ppc_md.progress )
-               ppc_md.progress("init_irq: exit", 0);
-
-       return;
-}
-
-static u32
-mcpn765_irq_canonicalize(u32 irq)
-{
-       if (irq == 2)
-               return 9;
-       else
-               return irq;
-}
-
-static unsigned long __init
-mcpn765_find_end_of_memory(void)
-{
-       return hawk_get_mem_size(MCPN765_HAWK_SMC_BASE);
-}
-
-static void __init
-mcpn765_map_io(void)
-{
-       io_block_mapping(0xfe800000, 0xfe800000, 0x00800000, _PAGE_IO);
-}
-
-static void
-mcpn765_reset_board(void)
-{
-       local_irq_disable();
-
-       /* set VIA IDE controller into native mode */
-       mcpn765_set_VIA_IDE_native();
-
-       /* Set exception prefix high - to the firmware */
-       _nmask_and_or_msr(0, MSR_IP);
-
-       out_8((u_char *)MCPN765_BOARD_MODRST_REG, 0x01);
-
-       return;
-}
-
-static void
-mcpn765_restart(char *cmd)
-{
-       volatile ulong  i = 10000000;
-
-       mcpn765_reset_board();
-
-       while (i-- > 0);
-       panic("restart failed\n");
-}
-
-static void
-mcpn765_power_off(void)
-{
-       mcpn765_halt();
-       /* NOTREACHED */
-}
-
-static void
-mcpn765_halt(void)
-{
-       local_irq_disable();
-       while (1);
-       /* NOTREACHED */
-}
-
-static int
-mcpn765_show_cpuinfo(struct seq_file *m)
-{
-       seq_printf(m, "vendor\t\t: Motorola MCG\n");
-       seq_printf(m, "machine\t\t: MCPN765\n");
-
-       return 0;
-}
-
-/*
- * Set BAT 3 to map 0xf0000000 to end of physical memory space.
- */
-static __inline__ void
-mcpn765_set_bat(void)
-{
-       mb();
-       mtspr(SPRN_DBAT1U, 0xfe8000fe);
-       mtspr(SPRN_DBAT1L, 0xfe80002a);
-       mb();
-}
-
-void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
-               unsigned long r6, unsigned long r7)
-{
-       parse_bootinfo(find_bootinfo());
-
-       /* Map in board regs, etc. */
-       mcpn765_set_bat();
-
-       isa_mem_base = MCPN765_ISA_MEM_BASE;
-       pci_dram_offset = MCPN765_PCI_DRAM_OFFSET;
-       ISA_DMA_THRESHOLD = 0x00ffffff;
-       DMA_MODE_READ = 0x44;
-       DMA_MODE_WRITE = 0x48;
-
-       ppc_md.setup_arch = mcpn765_setup_arch;
-       ppc_md.show_cpuinfo = mcpn765_show_cpuinfo;
-       ppc_md.irq_canonicalize = mcpn765_irq_canonicalize;
-       ppc_md.init_IRQ = mcpn765_init_IRQ;
-       ppc_md.get_irq = openpic_get_irq;
-       ppc_md.init = mcpn765_init2;
-
-       ppc_md.restart = mcpn765_restart;
-       ppc_md.power_off = mcpn765_power_off;
-       ppc_md.halt = mcpn765_halt;
-
-       ppc_md.find_end_of_memory = mcpn765_find_end_of_memory;
-       ppc_md.setup_io_mappings = mcpn765_map_io;
-
-       ppc_md.time_init = todc_time_init;
-       ppc_md.set_rtc_time = todc_set_rtc_time;
-       ppc_md.get_rtc_time = todc_get_rtc_time;
-       ppc_md.calibrate_decr = todc_calibrate_decr;
-
-       ppc_md.nvram_read_val = todc_m48txx_read_val;
-       ppc_md.nvram_write_val = todc_m48txx_write_val;
-
-       ppc_md.heartbeat = NULL;
-       ppc_md.heartbeat_reset = 0;
-       ppc_md.heartbeat_count = 0;
-
-#ifdef CONFIG_SERIAL_TEXT_DEBUG
-       ppc_md.progress = gen550_progress;
-#endif
-#ifdef CONFIG_KGDB
-       ppc_md.kgdb_map_scc = gen550_kgdb_map_scc;
-#endif
-
-       return;
-}
diff --git a/arch/ppc/platforms/mcpn765.h b/arch/ppc/platforms/mcpn765.h
deleted file mode 100644 (file)
index 4d35eca..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * arch/ppc/platforms/mcpn765.h
- *
- * Definitions for Motorola MCG MCPN765 cPCI Board.
- *
- * Author: Mark A. Greer
- *         mgreer@mvista.com
- *
- * 2001-2004 (c) MontaVista, Software, Inc.  This file is licensed under
- * the terms of the GNU General Public License version 2.  This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-
-/*
- * From Processor to PCI:
- *   PCI Mem Space: 0x80000000 - 0xc0000000 -> 0x80000000 - 0xc0000000 (1 GB)
- *   PCI I/O Space: 0xfd800000 - 0xfe000000 -> 0x00000000 - 0x00800000 (8 MB)
- *     Note: Must skip 0xfe000000-0xfe400000 for CONFIG_HIGHMEM/PKMAP area
- *   MPIC in PCI Mem Space: 0xfe800000 - 0xfe830000 (not all used by MPIC)
- *
- * From PCI to Processor:
- *   System Memory: 0x00000000 -> 0x00000000
- */
-
-#ifndef __PPC_PLATFORMS_MCPN765_H
-#define __PPC_PLATFORMS_MCPN765_H
-#include <linux/config.h>
-
-/* PCI Memory space mapping info */
-#define        MCPN765_PCI_MEM_SIZE            0x40000000U
-#define MCPN765_PROC_PCI_MEM_START     0x80000000U
-#define MCPN765_PROC_PCI_MEM_END       (MCPN765_PROC_PCI_MEM_START +   \
-                                        MCPN765_PCI_MEM_SIZE - 1)
-#define MCPN765_PCI_MEM_START          0x80000000U
-#define MCPN765_PCI_MEM_END            (MCPN765_PCI_MEM_START +        \
-                                        MCPN765_PCI_MEM_SIZE - 1)
-
-/* PCI I/O space mapping info */
-#define        MCPN765_PCI_IO_SIZE             0x00800000U
-#define MCPN765_PROC_PCI_IO_START      0xfd800000U
-#define MCPN765_PROC_PCI_IO_END                (MCPN765_PROC_PCI_IO_START +    \
-                                        MCPN765_PCI_IO_SIZE - 1)
-#define MCPN765_PCI_IO_START           0x00000000U
-#define MCPN765_PCI_IO_END             (MCPN765_PCI_IO_START +         \
-                                        MCPN765_PCI_IO_SIZE - 1)
-
-/* System memory mapping info */
-#define MCPN765_PCI_DRAM_OFFSET                0x00000000U
-#define MCPN765_PCI_PHY_MEM_OFFSET     0x00000000U
-
-#define MCPN765_ISA_MEM_BASE           0x00000000U
-#define MCPN765_ISA_IO_BASE            MCPN765_PROC_PCI_IO_START
-
-/* Define base addresses for important sets of registers */
-#define MCPN765_HAWK_MPIC_BASE         0xfe800000U
-#define MCPN765_HAWK_SMC_BASE          0xfef80000U
-#define        MCPN765_HAWK_PPC_REG_BASE       0xfeff0000U
-
-/* Define MCPN765 board register addresses. */
-#define        MCPN765_BOARD_STATUS_REG        0xfef88080U
-#define        MCPN765_BOARD_MODFAIL_REG       0xfef88090U
-#define        MCPN765_BOARD_MODRST_REG        0xfef880a0U
-#define        MCPN765_BOARD_TBEN_REG          0xfef880c0U
-#define        MCPN765_BOARD_GEOGRAPHICAL_REG  0xfef880e8U
-#define        MCPN765_BOARD_EXT_FEATURE_REG   0xfef880f0U
-#define        MCPN765_BOARD_LAST_RESET_REG    0xfef880f8U
-
-/* Defines for UART */
-
-/* Define the UART base addresses */
-#define        MCPN765_SERIAL_1                0xfef88000
-#define        MCPN765_SERIAL_2                0xfef88200
-#define        MCPN765_SERIAL_3                0xfef88400
-#define        MCPN765_SERIAL_4                0xfef88600
-
-#ifdef CONFIG_SERIAL_MANY_PORTS
-#define RS_TABLE_SIZE  64
-#else
-#define RS_TABLE_SIZE  4
-#endif
-
-/* Rate for the 1.8432 Mhz clock for the onboard serial chip */
-#define BASE_BAUD      ( 1843200 / 16 )
-#define UART_CLK       1843200
-
-#ifdef CONFIG_SERIAL_DETECT_IRQ
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST|ASYNC_AUTO_IRQ)
-#else
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST)
-#endif
-
-/* All UART IRQ's are wire-OR'd to IRQ 17 */
-#define STD_SERIAL_PORT_DFNS \
-        { 0, BASE_BAUD, MCPN765_SERIAL_1, 17, STD_COM_FLAGS, /* ttyS0 */\
-               iomem_base: (u8 *)MCPN765_SERIAL_1,                     \
-               iomem_reg_shift: 4,                                     \
-               io_type: SERIAL_IO_MEM },                               \
-        { 0, BASE_BAUD, MCPN765_SERIAL_2, 17, STD_COM_FLAGS, /* ttyS1 */\
-               iomem_base: (u8 *)MCPN765_SERIAL_2,                     \
-               iomem_reg_shift: 4,                                     \
-               io_type: SERIAL_IO_MEM },                               \
-        { 0, BASE_BAUD, MCPN765_SERIAL_3, 17, STD_COM_FLAGS, /* ttyS2 */\
-               iomem_base: (u8 *)MCPN765_SERIAL_3,                     \
-               iomem_reg_shift: 4,                                     \
-               io_type: SERIAL_IO_MEM },                               \
-        { 0, BASE_BAUD, MCPN765_SERIAL_4, 17, STD_COM_FLAGS, /* ttyS3 */\
-               iomem_base: (u8 *)MCPN765_SERIAL_4,                     \
-               iomem_reg_shift: 4,                                     \
-               io_type: SERIAL_IO_MEM },
-
-#define SERIAL_PORT_DFNS \
-        STD_SERIAL_PORT_DFNS
-
-/* Define the NVRAM/RTC address strobe & data registers */
-#define MCPN765_PHYS_NVRAM_AS0          0xfef880c8U
-#define MCPN765_PHYS_NVRAM_AS1          0xfef880d0U
-#define MCPN765_PHYS_NVRAM_DATA         0xfef880d8U
-
-extern void mcpn765_find_bridges(void);
-
-#endif /* __PPC_PLATFORMS_MCPN765_H */
diff --git a/arch/ppc/platforms/pcore.c b/arch/ppc/platforms/pcore.c
deleted file mode 100644 (file)
index d719163..0000000
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * arch/ppc/platforms/pcore_setup.c
- *
- * Setup routines for Force PCORE boards
- *
- * Author: Matt Porter <mporter@mvista.com>
- *
- * 2001 (c) MontaVista, Software, Inc.  This file is licensed under
- * the terms of the GNU General Public License version 2.  This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-
-#include <linux/config.h>
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/reboot.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/types.h>
-#include <linux/major.h>
-#include <linux/initrd.h>
-#include <linux/console.h>
-#include <linux/irq.h>
-#include <linux/seq_file.h>
-#include <linux/root_dev.h>
-
-#include <asm/io.h>
-#include <asm/machdep.h>
-#include <asm/time.h>
-#include <asm/i8259.h>
-#include <asm/mpc10x.h>
-#include <asm/todc.h>
-#include <asm/bootinfo.h>
-#include <asm/kgdb.h>
-
-#include "pcore.h"
-
-extern unsigned long loops_per_jiffy;
-
-static int board_type;
-
-static inline int __init
-pcore_6750_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
-{
-       static char pci_irq_table[][4] =
-       /*
-        *      PCI IDSEL/INTPIN->INTLINE
-        *      A       B       C       D
-        */
-       {
-               {9,     10,     11,     12},    /* IDSEL 24 - DEC 21554 */
-               {10,    0,      0,      0},     /* IDSEL 25 - DEC 21143 */
-               {11,    12,     9,      10},    /* IDSEL 26 - PMC I */
-               {12,    9,      10,     11},    /* IDSEL 27 - PMC II */
-               {0,     0,      0,      0},     /* IDSEL 28 - unused */
-               {0,     0,      9,      0},     /* IDSEL 29 - unused */
-               {0,     0,      0,      0},     /* IDSEL 30 - Winbond */
-               };
-       const long min_idsel = 24, max_idsel = 30, irqs_per_slot = 4;
-       return PCI_IRQ_TABLE_LOOKUP;
-};
-
-static inline int __init
-pcore_680_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
-{
-       static char pci_irq_table[][4] =
-       /*
-        *      PCI IDSEL/INTPIN->INTLINE
-        *      A       B       C       D
-        */
-       {
-               {9,     10,     11,     12},    /* IDSEL 24 - Sentinel */
-               {10,    0,      0,      0},     /* IDSEL 25 - i82559 #1 */
-               {11,    12,     9,      10},    /* IDSEL 26 - PMC I */
-               {12,    9,      10,     11},    /* IDSEL 27 - PMC II */
-               {9,     0,      0,      0},     /* IDSEL 28 - i82559 #2 */
-               {0,     0,      0,      0},     /* IDSEL 29 - unused */
-               {0,     0,      0,      0},     /* IDSEL 30 - Winbond */
-               };
-       const long min_idsel = 24, max_idsel = 30, irqs_per_slot = 4;
-       return PCI_IRQ_TABLE_LOOKUP;
-};
-
-void __init
-pcore_pcibios_fixup(void)
-{
-       struct pci_dev *dev;
-
-       if ((dev = pci_get_device(PCI_VENDOR_ID_WINBOND,
-                               PCI_DEVICE_ID_WINBOND_83C553,
-                               0)))
-       {
-               /* Reroute interrupts both IDE channels to 15 */
-               pci_write_config_byte(dev,
-                               PCORE_WINBOND_IDE_INT,
-                               0xff);
-
-               /* Route INTA-D to IRQ9-12, respectively */
-               pci_write_config_word(dev,
-                               PCORE_WINBOND_PCI_INT,
-                               0x9abc);
-
-               /*
-                * Set up 8259 edge/level triggering
-                */
-               outb(0x00, PCORE_WINBOND_PRI_EDG_LVL);
-               outb(0x1e, PCORE_WINBOND_SEC_EDG_LVL);
-               pci_dev_put(dev);
-       }
-}
-
-int __init
-pcore_find_bridges(void)
-{
-       struct pci_controller* hose;
-       int host_bridge, board_type;
-
-       hose = pcibios_alloc_controller();
-       if (!hose)
-               return 0;
-
-       mpc10x_bridge_init(hose,
-                       MPC10X_MEM_MAP_B,
-                       MPC10X_MEM_MAP_B,
-                       MPC10X_MAPB_EUMB_BASE);
-
-       /* Determine board type */
-       early_read_config_dword(hose,
-                       0,
-                       PCI_DEVFN(0,0),
-                       PCI_VENDOR_ID,
-                       &host_bridge);
-       if (host_bridge == MPC10X_BRIDGE_106)
-               board_type = PCORE_TYPE_6750;
-       else /* MPC10X_BRIDGE_107 */
-               board_type = PCORE_TYPE_680;
-
-       hose->last_busno = pciauto_bus_scan(hose, hose->first_busno);
-
-       ppc_md.pcibios_fixup = pcore_pcibios_fixup;
-       ppc_md.pci_swizzle = common_swizzle;
-
-       if (board_type == PCORE_TYPE_6750)
-               ppc_md.pci_map_irq = pcore_6750_map_irq;
-       else /* PCORE_TYPE_680 */
-               ppc_md.pci_map_irq = pcore_680_map_irq;
-
-       return board_type;
-}
-
-/* Dummy variable to satisfy mpc10x_common.o */
-void *OpenPIC_Addr;
-
-static int
-pcore_show_cpuinfo(struct seq_file *m)
-{
-       seq_printf(m, "vendor\t\t: Force Computers\n");
-
-       if (board_type == PCORE_TYPE_6750)
-               seq_printf(m, "machine\t\t: PowerCore 6750\n");
-       else /* PCORE_TYPE_680 */
-               seq_printf(m, "machine\t\t: PowerCore 680\n");
-
-       seq_printf(m, "L2\t\t: " );
-       if (board_type == PCORE_TYPE_6750)
-               switch (readb(PCORE_DCCR_REG) & PCORE_DCCR_L2_MASK)
-               {
-                       case PCORE_DCCR_L2_0KB:
-                               seq_printf(m, "nocache");
-                               break;
-                       case PCORE_DCCR_L2_256KB:
-                               seq_printf(m, "256KB");
-                               break;
-                       case PCORE_DCCR_L2_1MB:
-                               seq_printf(m, "1MB");
-                               break;
-                       case PCORE_DCCR_L2_512KB:
-                               seq_printf(m, "512KB");
-                               break;
-                       default:
-                               seq_printf(m, "error");
-                               break;
-               }
-       else /* PCORE_TYPE_680 */
-               switch (readb(PCORE_DCCR_REG) & PCORE_DCCR_L2_MASK)
-               {
-                       case PCORE_DCCR_L2_2MB:
-                               seq_printf(m, "2MB");
-                               break;
-                       case PCORE_DCCR_L2_256KB:
-                               seq_printf(m, "reserved");
-                               break;
-                       case PCORE_DCCR_L2_1MB:
-                               seq_printf(m, "1MB");
-                               break;
-                       case PCORE_DCCR_L2_512KB:
-                               seq_printf(m, "512KB");
-                               break;
-                       default:
-                               seq_printf(m, "error");
-                               break;
-               }
-
-       seq_printf(m, "\n");
-
-       return 0;
-}
-
-static void __init
-pcore_setup_arch(void)
-{
-       /* init to some ~sane value until calibrate_delay() runs */
-       loops_per_jiffy = 50000000/HZ;
-
-       /* Lookup PCI host bridges */
-       board_type = pcore_find_bridges();
-
-#ifdef CONFIG_BLK_DEV_INITRD
-       if (initrd_start)
-               ROOT_DEV = Root_RAM0;
-        else
-#endif
-#ifdef CONFIG_ROOT_NFS
-               ROOT_DEV = Root_NFS;
-#else
-               ROOT_DEV = Root_SDA2;
-#endif
-
-       printk(KERN_INFO "Force PowerCore ");
-       if (board_type == PCORE_TYPE_6750)
-               printk("6750\n");
-       else
-               printk("680\n");
-       printk(KERN_INFO "Port by MontaVista Software, Inc. (source@mvista.com)\n");
-       _set_L2CR(L2CR_L2E | _get_L2CR());
-
-}
-
-static void
-pcore_restart(char *cmd)
-{
-       local_irq_disable();
-       /* Hard reset */
-       writeb(0x11, 0xfe000332);
-       while(1);
-}
-
-static void
-pcore_halt(void)
-{
-       local_irq_disable();
-       /* Turn off user LEDs */
-       writeb(0x00, 0xfe000300);
-       while (1);
-}
-
-static void
-pcore_power_off(void)
-{
-       pcore_halt();
-}
-
-
-static void __init
-pcore_init_IRQ(void)
-{
-       int i;
-
-       for ( i = 0 ; i < 16 ; i++ )
-               irq_desc[i].handler = &i8259_pic;
-
-       i8259_init(0);
-}
-
-/*
- * Set BAT 3 to map 0xf0000000 to end of physical memory space.
- */
-static __inline__ void
-pcore_set_bat(void)
-{
-       mb();
-       mtspr(SPRN_DBAT3U, 0xf0001ffe);
-       mtspr(SPRN_DBAT3L, 0xfe80002a);
-       mb();
-
-}
-
-static unsigned long __init
-pcore_find_end_of_memory(void)
-{
-
-       return mpc10x_get_mem_size(MPC10X_MEM_MAP_B);
-}
-
-static void __init
-pcore_map_io(void)
-{
-       io_block_mapping(0xfe000000, 0xfe000000, 0x02000000, _PAGE_IO);
-}
-
-TODC_ALLOC();
-
-void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
-               unsigned long r6, unsigned long r7)
-{
-       parse_bootinfo(find_bootinfo());
-
-       /* Cover I/O space with a BAT */
-       /* yuck, better hope your ram size is a power of 2  -- paulus */
-       pcore_set_bat();
-
-       isa_io_base = MPC10X_MAPB_ISA_IO_BASE;
-       isa_mem_base = MPC10X_MAPB_ISA_MEM_BASE;
-       pci_dram_offset = MPC10X_MAPB_DRAM_OFFSET;
-
-       ppc_md.setup_arch       = pcore_setup_arch;
-       ppc_md.show_cpuinfo     = pcore_show_cpuinfo;
-       ppc_md.init_IRQ         = pcore_init_IRQ;
-       ppc_md.get_irq          = i8259_irq;
-
-       ppc_md.find_end_of_memory = pcore_find_end_of_memory;
-       ppc_md.setup_io_mappings = pcore_map_io;
-
-       ppc_md.restart          = pcore_restart;
-       ppc_md.power_off        = pcore_power_off;
-       ppc_md.halt             = pcore_halt;
-
-       TODC_INIT(TODC_TYPE_MK48T59,
-                 PCORE_NVRAM_AS0,
-                 PCORE_NVRAM_AS1,
-                 PCORE_NVRAM_DATA,
-                 8);
-
-       ppc_md.time_init        = todc_time_init;
-       ppc_md.get_rtc_time     = todc_get_rtc_time;
-       ppc_md.set_rtc_time     = todc_set_rtc_time;
-       ppc_md.calibrate_decr   = todc_calibrate_decr;
-
-       ppc_md.nvram_read_val   = todc_m48txx_read_val;
-       ppc_md.nvram_write_val  = todc_m48txx_write_val;
-
-#ifdef CONFIG_SERIAL_TEXT_DEBUG
-       ppc_md.progress = gen550_progress;
-#endif
-#ifdef CONFIG_KGDB
-       ppc_md.kgdb_map_scc = gen550_kgdb_map_scc;
-#endif
-}
diff --git a/arch/ppc/platforms/pcore.h b/arch/ppc/platforms/pcore.h
deleted file mode 100644 (file)
index c6a26e7..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * arch/ppc/platforms/pcore.h
- *
- * Definitions for Force PowerCore board support
- *
- * Author: Matt Porter <mporter@mvista.com>
- *
- * 2001 (c) MontaVista, Software, Inc.  This file is licensed under
- * the terms of the GNU General Public License version 2.  This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-
-#ifndef __PPC_PLATFORMS_PCORE_H
-#define __PPC_PLATFORMS_PCORE_H
-
-#include <asm/mpc10x.h>
-
-#define PCORE_TYPE_6750                        1
-#define PCORE_TYPE_680                 2
-
-#define PCORE_NVRAM_AS0                        0x73
-#define PCORE_NVRAM_AS1                        0x75
-#define PCORE_NVRAM_DATA               0x77
-
-#define PCORE_DCCR_REG                 (MPC10X_MAPB_ISA_IO_BASE + 0x308)
-#define PCORE_DCCR_L2_MASK             0xc0
-#define PCORE_DCCR_L2_0KB              0x00
-#define PCORE_DCCR_L2_256KB            0x40
-#define PCORE_DCCR_L2_512KB            0xc0
-#define PCORE_DCCR_L2_1MB              0x80
-#define PCORE_DCCR_L2_2MB              0x00
-
-#define PCORE_WINBOND_IDE_INT          0x43
-#define PCORE_WINBOND_PCI_INT          0x44
-#define PCORE_WINBOND_PRI_EDG_LVL      0x4d0
-#define PCORE_WINBOND_SEC_EDG_LVL      0x4d1
-
-#endif /* __PPC_PLATFORMS_PCORE_H */
index 9f92e1bb7f346b00ea715354da8fbd87081a22fe..2ce058895e039438d70d5a0964bd111356c243e5 100644 (file)
@@ -619,7 +619,7 @@ not_found:
        return viaint;
 }
 
-static int pmacpic_suspend(struct sys_device *sysdev, u32 state)
+static int pmacpic_suspend(struct sys_device *sysdev, pm_message_t state)
 {
        int viaint = pmacpic_find_viaint();
 
diff --git a/arch/ppc/platforms/spd8xx.h b/arch/ppc/platforms/spd8xx.h
deleted file mode 100644 (file)
index ed48d14..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Speech Design SPD8xxTS board specific definitions
- *
- * Copyright (c) 2000,2001 Wolfgang Denk (wd@denx.de)
- */
-
-#ifdef __KERNEL__
-#ifndef __ASM_SPD8XX_H__
-#define __ASM_SPD8XX_H__
-
-#include <linux/config.h>
-
-#include <asm/ppcboot.h>
-
-#ifndef __ASSEMBLY__
-#define SPD_IMMR_BASE  0xFFF00000      /* phys. addr of IMMR */
-#define SPD_IMAP_SIZE  (64 * 1024)     /* size of mapped area */
-
-#define IMAP_ADDR      SPD_IMMR_BASE   /* physical base address of IMMR area */
-#define IMAP_SIZE      SPD_IMAP_SIZE   /* mapped size of IMMR area */
-
-#define PCMCIA_MEM_ADDR        ((uint)0xFE100000)
-#define PCMCIA_MEM_SIZE        ((uint)(64 * 1024))
-
-#define IDE0_INTERRUPT 10              /* = IRQ5 */
-#define IDE1_INTERRUPT 12              /* = IRQ6 */
-#define CPM_INTERRUPT  13              /* = SIU_LEVEL6 (was: SIU_LEVEL2) */
-
-/* override the default number of IDE hardware interfaces */
-#define MAX_HWIFS      2
-
-/*
- * Definitions for IDE0 Interface
- */
-#define IDE0_BASE_OFFSET               0x0000  /* Offset in PCMCIA memory */
-#define IDE0_DATA_REG_OFFSET           0x0000
-#define IDE0_ERROR_REG_OFFSET          0x0081
-#define IDE0_NSECTOR_REG_OFFSET                0x0082
-#define IDE0_SECTOR_REG_OFFSET         0x0083
-#define IDE0_LCYL_REG_OFFSET           0x0084
-#define IDE0_HCYL_REG_OFFSET           0x0085
-#define IDE0_SELECT_REG_OFFSET         0x0086
-#define IDE0_STATUS_REG_OFFSET         0x0087
-#define IDE0_CONTROL_REG_OFFSET                0x0106
-#define IDE0_IRQ_REG_OFFSET            0x000A  /* not used */
-
-/*
- * Definitions for IDE1 Interface
- */
-#define IDE1_BASE_OFFSET               0x0C00  /* Offset in PCMCIA memory */
-#define IDE1_DATA_REG_OFFSET           0x0000
-#define IDE1_ERROR_REG_OFFSET          0x0081
-#define IDE1_NSECTOR_REG_OFFSET                0x0082
-#define IDE1_SECTOR_REG_OFFSET         0x0083
-#define IDE1_LCYL_REG_OFFSET           0x0084
-#define IDE1_HCYL_REG_OFFSET           0x0085
-#define IDE1_SELECT_REG_OFFSET         0x0086
-#define IDE1_STATUS_REG_OFFSET         0x0087
-#define IDE1_CONTROL_REG_OFFSET                0x0106
-#define IDE1_IRQ_REG_OFFSET            0x000A  /* not used */
-
-/* CPM Ethernet through SCCx.
- *
- * Bits in parallel I/O port registers that have to be set/cleared
- * to configure the pins for SCC2 use.
- */
-#define PA_ENET_MDC    ((ushort)0x0001)        /* PA 15 !!! */
-#define PA_ENET_MDIO   ((ushort)0x0002)        /* PA 14 !!! */
-#define PA_ENET_RXD    ((ushort)0x0004)        /* PA 13 */
-#define PA_ENET_TXD    ((ushort)0x0008)        /* PA 12 */
-#define PA_ENET_RCLK   ((ushort)0x0200)        /* PA  6 */
-#define PA_ENET_TCLK   ((ushort)0x0400)        /* PA  5 */
-
-#define PB_ENET_TENA   ((uint)0x00002000)      /* PB 18 */
-
-#define PC_ENET_CLSN   ((ushort)0x0040)        /* PC  9 */
-#define PC_ENET_RENA   ((ushort)0x0080)        /* PC  8 */
-#define PC_ENET_RESET  ((ushort)0x0100)        /* PC  7 !!! */
-
-/* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK2) to
- * SCC2.  Also, make sure GR2 (bit 16) and SC2 (bit 17) are zero.
- */
-#define SICR_ENET_MASK ((uint)0x0000ff00)
-#define SICR_ENET_CLKRT        ((uint)0x00002E00)
-
-/* We don't use the 8259.
-*/
-#define NR_8259_INTS   0
-
-#endif /* !__ASSEMBLY__ */
-#endif /* __ASM_SPD8XX_H__ */
-#endif /* __KERNEL__ */
index 2150dc87b18f2cb607a1a223df8eeb2ba1428f0e..43ac064ebe5afca4099081157daa241d0b17b64c 100644 (file)
@@ -147,29 +147,6 @@ static __inline__ void ide_led(int on)
 #define SICR_ENET_CLKRT        ((uint)0x00002600)
 #endif /* CONFIG_FPS850L */
 
-/***  SM850  *********************************************************/
-
-/* The SM850 Service Module uses SCC2 for IrDA and SCC3 for Ethernet */
-
-#ifdef CONFIG_SM850
-#define PB_ENET_RXD    ((uint)0x00000004)      /* PB 29 */
-#define PB_ENET_TXD    ((uint)0x00000002)      /* PB 30 */
-#define PA_ENET_RCLK   ((ushort)0x0100)        /* PA  7 */
-#define PA_ENET_TCLK   ((ushort)0x0400)        /* PA  5 */
-
-#define PC_ENET_LBK    ((ushort)0x0008)        /* PC 12 */
-#define PC_ENET_TENA   ((ushort)0x0004)        /* PC 13 */
-
-#define PC_ENET_RENA   ((ushort)0x0800)        /* PC  4 */
-#define PC_ENET_CLSN   ((ushort)0x0400)        /* PC  5 */
-
-/* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK1) to
- * SCC3.  Also, make sure GR3 (bit 8) and SC3 (bit 9) are zero.
- */
-#define SICR_ENET_MASK ((uint)0x00FF0000)
-#define SICR_ENET_CLKRT        ((uint)0x00260000)
-#endif /* CONFIG_SM850 */
-
 /* We don't use the 8259.
 */
 #define NR_8259_INTS   0
index 220a65ab0a51f608089e7a49941aae852937a096..8b9b226005d125c0e130d8fb9f29a59cbf414a1a 100644 (file)
@@ -43,8 +43,6 @@ obj-$(CONFIG_PPC_PMAC)                += open_pic.o indirect_pci.o
 obj-$(CONFIG_POWER4)           += open_pic2.o
 obj-$(CONFIG_PPC_CHRP)         += open_pic.o indirect_pci.o i8259.o
 obj-$(CONFIG_PPC_PREP)         += open_pic.o indirect_pci.o i8259.o todc_time.o
-obj-$(CONFIG_ADIR)             += i8259.o indirect_pci.o pci_auto.o \
-                                       todc_time.o
 obj-$(CONFIG_BAMBOO)           += indirect_pci.o pci_auto.o todc_time.o
 obj-$(CONFIG_CPCI690)          += todc_time.o pci_auto.o
 obj-$(CONFIG_EBONY)            += indirect_pci.o pci_auto.o todc_time.o
@@ -52,16 +50,10 @@ obj-$(CONFIG_EV64260)               += todc_time.o pci_auto.o
 obj-$(CONFIG_CHESTNUT)         += mv64360_pic.o pci_auto.o
 obj-$(CONFIG_GEMINI)           += open_pic.o indirect_pci.o
 obj-$(CONFIG_GT64260)          += gt64260_pic.o
-obj-$(CONFIG_K2)               += i8259.o indirect_pci.o todc_time.o \
-                                       pci_auto.o
 obj-$(CONFIG_LOPEC)            += i8259.o pci_auto.o todc_time.o
 obj-$(CONFIG_HDPU)             += pci_auto.o
 obj-$(CONFIG_LUAN)             += indirect_pci.o pci_auto.o todc_time.o
 obj-$(CONFIG_KATANA)           += pci_auto.o
-obj-$(CONFIG_MCPN765)          += todc_time.o indirect_pci.o pci_auto.o \
-                                       open_pic.o i8259.o hawk_common.o
-obj-$(CONFIG_MENF1)            += todc_time.o i8259.o mpc10x_common.o \
-                                       pci_auto.o indirect_pci.o
 obj-$(CONFIG_MV64360)          += mv64360_pic.o
 obj-$(CONFIG_MV64X60)          += mv64x60.o mv64x60_win.o indirect_pci.o
 obj-$(CONFIG_MVME5100)         += open_pic.o todc_time.o indirect_pci.o \
@@ -69,7 +61,6 @@ obj-$(CONFIG_MVME5100)                += open_pic.o todc_time.o indirect_pci.o \
 obj-$(CONFIG_MVME5100_IPMC761_PRESENT) += i8259.o
 obj-$(CONFIG_OCOTEA)           += indirect_pci.o pci_auto.o todc_time.o
 obj-$(CONFIG_PAL4)             += cpc700_pic.o
-obj-$(CONFIG_PCORE)            += todc_time.o i8259.o pci_auto.o
 obj-$(CONFIG_POWERPMC250)      += pci_auto.o
 obj-$(CONFIG_PPLUS)            += hawk_common.o open_pic.o i8259.o \
                                   indirect_pci.o todc_time.o pci_auto.o
@@ -82,7 +73,8 @@ obj-$(CONFIG_SANDPOINT)               += i8259.o pci_auto.o todc_time.o
 obj-$(CONFIG_SBC82xx)          += todc_time.o
 obj-$(CONFIG_SPRUCE)           += cpc700_pic.o indirect_pci.o pci_auto.o \
                                   todc_time.o
-obj-$(CONFIG_8260)             += m8260_setup.o
+obj-$(CONFIG_8260)             += m8260_setup.o pq2_devices.o pq2_sys.o \
+                                  ppc_sys.o
 obj-$(CONFIG_PCI_8260)         += m82xx_pci.o indirect_pci.o pci_auto.o
 obj-$(CONFIG_8260_PCI9)                += m8260_pci_erratum9.o
 obj-$(CONFIG_CPM2)             += cpm2_common.o cpm2_pic.o
index 74d8996418e942ae3c67c9b8bf0509491185a650..8356da4678a2d49d8510b73680f5941042c44143 100644 (file)
@@ -366,10 +366,16 @@ mv64360_pci_error_int_handler(int irq, void *dev_id, struct pt_regs *regs)
        return IRQ_HANDLED;
 }
 
+/*
+ * Bit 0 of MV64x60_PCIx_ERR_MASK does not exist on the 64360 and because of
+ * errata FEr-#11 and FEr-##16 for the 64460, it should be 0 on that chip as
+ * well.  IOW, don't set bit 0.
+ */
+#define MV64360_PCI0_ERR_MASK_VAL      0x00a50c24
+
 static int __init
 mv64360_register_hdlrs(void)
 {
-       u32     mask;
        int     rc;
 
        /* Clear old errors and register CPU interface error intr handler */
@@ -387,17 +393,6 @@ mv64360_register_hdlrs(void)
                mv64360_sram_error_int_handler,SA_INTERRUPT,SRAM_INTR_STR, 0)))
                printk(KERN_WARNING "Can't register SRAM error handler: %d",rc);
 
-       /*
-        * Bit 0 reserved on 64360 and erratum FEr PCI-#11 (PCI internal
-        * data parity error set incorrectly) on rev 0 & 1 of 64460 requires
-        * bit 0 to be cleared.
-        */
-       mask = 0x00a50c24;
-
-       if ((mv64x60_get_bridge_type() == MV64x60_TYPE_MV64460) &&
-               (mv64x60_get_bridge_rev() > 1))
-               mask |= 0x1;    /* enable DPErr on 64460 */
-
        /* Clear old errors and register PCI 0 error intr handler */
        mv64x60_write(&bh, MV64x60_PCI0_ERR_CAUSE, 0);
        if ((rc = request_irq(MV64360_IRQ_PCI0 + mv64360_irq_base,
@@ -407,7 +402,11 @@ mv64360_register_hdlrs(void)
                        rc);
 
        mv64x60_write(&bh, MV64x60_PCI0_ERR_MASK, 0);
-       mv64x60_write(&bh, MV64x60_PCI0_ERR_MASK, mask);
+       mv64x60_write(&bh, MV64x60_PCI0_ERR_MASK, MV64360_PCI0_ERR_MASK_VAL);
+
+       /* Erratum FEr PCI-#16 says to clear bit 0 of PCI SERRn Mask reg. */
+       mv64x60_write(&bh, MV64x60_PCI0_ERR_SERR_MASK,
+               mv64x60_read(&bh, MV64x60_PCI0_ERR_SERR_MASK) & ~0x1UL);
 
        /* Clear old errors and register PCI 1 error intr handler */
        mv64x60_write(&bh, MV64x60_PCI1_ERR_CAUSE, 0);
@@ -418,7 +417,11 @@ mv64360_register_hdlrs(void)
                        rc);
 
        mv64x60_write(&bh, MV64x60_PCI1_ERR_MASK, 0);
-       mv64x60_write(&bh, MV64x60_PCI1_ERR_MASK, mask);
+       mv64x60_write(&bh, MV64x60_PCI1_ERR_MASK, MV64360_PCI0_ERR_MASK_VAL);
+
+       /* Erratum FEr PCI-#16 says to clear bit 0 of PCI Intr Mask reg. */
+       mv64x60_write(&bh, MV64x60_PCI1_ERR_SERR_MASK,
+               mv64x60_read(&bh, MV64x60_PCI1_ERR_SERR_MASK) & ~0x1UL);
 
        return 0;
 }
index cc77177fa1c620eb6aad9efb5f1776a8d0b816cb..6262b11f366f713eaf228ca10bb6e77ef206bb82 100644 (file)
 #include <asm/mv64x60.h>
 
 
-u8             mv64x60_pci_exclude_bridge = 1;
+u8 mv64x60_pci_exclude_bridge = 1;
 spinlock_t     mv64x60_lock = SPIN_LOCK_UNLOCKED;
 
-static phys_addr_t     mv64x60_bridge_pbase = 0;
-static void            *mv64x60_bridge_vbase = 0;
+static phys_addr_t     mv64x60_bridge_pbase;
+static void            *mv64x60_bridge_vbase;
 static u32             mv64x60_bridge_type = MV64x60_TYPE_INVALID;
-static u32             mv64x60_bridge_rev = 0;
+static u32             mv64x60_bridge_rev;
+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GT64260)
+static struct pci_controller   sysfs_hose_a;
+#endif
 
 static u32 gt64260_translate_size(u32 base, u32 size, u32 num_bits);
 static u32 gt64260_untranslate_size(u32 base, u32 size, u32 num_bits);
@@ -432,6 +435,20 @@ static struct platform_device i2c_device = {
 };
 #endif
 
+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GT64260)
+static struct mv64xxx_pdata mv64xxx_pdata = {
+       .hs_reg_valid   = 0,
+};
+
+static struct platform_device mv64xxx_device = { /* general mv64x60 stuff */
+       .name   = MV64XXX_DEV_NAME,
+       .id     = 0,
+       .dev = {
+               .platform_data = &mv64xxx_pdata,
+       },
+};
+#endif
+
 static struct platform_device *mv64x60_pd_devs[] __initdata = {
 #ifdef CONFIG_SERIAL_MPSC
        &mpsc_shared_device,
@@ -453,6 +470,9 @@ static struct platform_device *mv64x60_pd_devs[] __initdata = {
 #ifdef CONFIG_I2C_MV64XXX
        &i2c_device,
 #endif
+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GT64260)
+       &mv64xxx_device,
+#endif
 };
 
 /*
@@ -574,6 +594,11 @@ mv64x60_early_init(struct mv64x60_handle *bh, struct mv64x60_setup_info *si)
        bh->hose_a = &hose_a;
        bh->hose_b = &hose_b;
 
+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GT64260)
+       /* Save a copy of hose_a for sysfs functions -- hack */
+       memcpy(&sysfs_hose_a, &hose_a, sizeof(hose_a));
+#endif
+
        mv64x60_set_bus(bh, 0, 0);
        mv64x60_set_bus(bh, 1, 0);
 
@@ -590,8 +615,6 @@ mv64x60_early_init(struct mv64x60_handle *bh, struct mv64x60_setup_info *si)
 
        mv64x60_set_bits(bh, MV64x60_PCI0_TO_RETRY, 0xffff);
        mv64x60_set_bits(bh, MV64x60_PCI1_TO_RETRY, 0xffff);
-
-       return;
 }
 
 /*
@@ -628,19 +651,15 @@ mv64x60_get_32bit_window(struct mv64x60_handle *bh, u32 window,
                        val = mv64x60_read(bh, size_reg);
                        val = get_from_field(val, size_bits);
                        *size = bh->ci->untranslate_size(*base, val, size_bits);
-               }
-               else
+               } else
                        *size = 0;
-       }
-       else {
+       } else {
                *base = 0;
                *size = 0;
        }
 
        pr_debug("get 32bit window: %d, base: 0x%x, size: 0x%x\n",
                window, *base, *size);
-
-       return;
 }
 
 /*
@@ -677,8 +696,6 @@ mv64x60_set_32bit_window(struct mv64x60_handle *bh, u32 window,
 
                (void)mv64x60_read(bh, base_reg); /* Flush FIFO */
        }
-
-       return;
 }
 
 /*
@@ -712,11 +729,9 @@ mv64x60_get_64bit_window(struct mv64x60_handle *bh, u32 window,
                        val = get_from_field(val, size_bits);
                        *size = bh->ci->untranslate_size(*base_lo, val,
                                                                size_bits);
-               }
-               else
+               } else
                        *size = 0;
-       }
-       else {
+       } else {
                *base_hi = 0;
                *base_lo = 0;
                *size = 0;
@@ -724,8 +739,6 @@ mv64x60_get_64bit_window(struct mv64x60_handle *bh, u32 window,
 
        pr_debug("get 64bit window: %d, base hi: 0x%x, base lo: 0x%x, "
                "size: 0x%x\n", window, *base_hi, *base_lo, *size);
-
-       return;
 }
 
 /*
@@ -766,8 +779,6 @@ mv64x60_set_64bit_window(struct mv64x60_handle *bh, u32 window,
 
                (void)mv64x60_read(bh, base_lo_reg); /* Flush FIFO */
        }
-
-       return;
 }
 
 /*
@@ -1008,8 +1019,6 @@ mv64x60_get_mem_windows(struct mv64x60_handle *bh,
                        mem_windows[i][0] = 0;
                        mem_windows[i][1] = 0;
                }
-
-       return;
 }
 
 /*
@@ -1077,8 +1086,6 @@ mv64x60_config_cpu2mem_windows(struct mv64x60_handle *bh,
                        }
 
                }
-
-       return;
 }
 
 /*
@@ -1112,8 +1119,7 @@ mv64x60_config_cpu2pci_windows(struct mv64x60_handle *bh,
                mv64x60_set_32bit_window(bh, remap_tab[bus][0],
                        pi->pci_io.pci_base_lo, 0, 0);
                bh->ci->enable_window_32bit(bh, win_tab[bus][0]);
-       }
-       else /* Actually, the window should already be disabled */
+       } else /* Actually, the window should already be disabled */
                bh->ci->disable_window_32bit(bh, win_tab[bus][0]);
 
        for (i=0; i<3; i++)
@@ -1125,11 +1131,8 @@ mv64x60_config_cpu2pci_windows(struct mv64x60_handle *bh,
                                pi->pci_mem[i].pci_base_hi,
                                pi->pci_mem[i].pci_base_lo, 0, 0);
                        bh->ci->enable_window_32bit(bh, win_tab[bus][i+1]);
-               }
-               else /* Actually, the window should already be disabled */
+               } else /* Actually, the window should already be disabled */
                        bh->ci->disable_window_32bit(bh, win_tab[bus][i+1]);
-
-       return;
 }
 
 /*
@@ -1206,8 +1209,6 @@ mv64x60_config_pci2mem_windows(struct mv64x60_handle *bh,
                                MV64x60_PCI0_BAR_ENABLE :
                                MV64x60_PCI1_BAR_ENABLE), (1 << i));
                }
-
-       return;
 }
 
 /*
@@ -1229,7 +1230,6 @@ mv64x60_alloc_hose(struct mv64x60_handle *bh, u32 cfg_addr, u32 cfg_data,
        *hose = pcibios_alloc_controller();
        setup_indirect_pci_nomap(*hose, bh->v_base + cfg_addr,
                bh->v_base + cfg_data);
-       return;
 }
 
 /*
@@ -1272,7 +1272,6 @@ mv64x60_config_resources(struct pci_controller *hose,
                                                pi->pci_mem[0].size - 1;
        hose->pci_mem_offset = pi->pci_mem[0].cpu_base -
                                                pi->pci_mem[0].pci_base_lo;
-       return;
 }
 
 /*
@@ -1309,7 +1308,6 @@ mv64x60_config_pci_params(struct pci_controller *hose,
        early_write_config_word(hose, 0, devfn, PCI_CACHE_LINE_SIZE, u16_val);
 
        mv64x60_pci_exclude_bridge = save_exclude;
-       return;
 }
 
 /*
@@ -1336,8 +1334,7 @@ mv64x60_set_bus(struct mv64x60_handle *bh, u32 bus, u32 child_bus)
                p2p_cfg = MV64x60_PCI0_P2P_CONFIG;
                pci_cfg_offset = 0x64;
                hose = bh->hose_a;
-       }
-       else {
+       } else {
                pci_mode = bh->pci_mode_b;
                p2p_cfg = MV64x60_PCI1_P2P_CONFIG;
                pci_cfg_offset = 0xe4;
@@ -1352,8 +1349,7 @@ mv64x60_set_bus(struct mv64x60_handle *bh, u32 bus, u32 child_bus)
                val |= (child_bus << 16) | 0xff;
                mv64x60_write(bh, p2p_cfg, val);
                (void)mv64x60_read(bh, p2p_cfg); /* Flush FIFO */
-       }
-       else { /* PCI-X */
+       } else { /* PCI-X */
                /*
                 * Need to use the current bus/dev number (that's in the
                 * P2P CONFIG reg) to access the bridge's pci config space.
@@ -1365,8 +1361,6 @@ mv64x60_set_bus(struct mv64x60_handle *bh, u32 bus, u32 child_bus)
                        pci_cfg_offset, child_bus << 8);
                mv64x60_pci_exclude_bridge = save_exclude;
        }
-
-       return;
 }
 
 /*
@@ -1423,8 +1417,6 @@ mv64x60_pd_fixup(struct mv64x60_handle *bh, struct platform_device *pd_devs[],
                        j++;
                }
        }
-
-       return;
 }
 
 /*
@@ -1498,8 +1490,6 @@ gt64260_set_pci2mem_window(struct pci_controller *hose, u32 bus, u32 window,
        early_write_config_dword(hose, 0, PCI_DEVFN(0, 0),
                gt64260_reg_addrs[bus][window], mv64x60_mask(base, 20) | 0x8);
        mv64x60_pci_exclude_bridge = save_exclude;
-
-       return;
 }
 
 /*
@@ -1523,8 +1513,6 @@ gt64260_set_pci2regs_window(struct mv64x60_handle *bh,
        early_write_config_dword(hose, 0, PCI_DEVFN(0,0), gt64260_offset[bus],
                (base << 16));
        mv64x60_pci_exclude_bridge = save_exclude;
-
-       return;
 }
 
 /*
@@ -1561,7 +1549,6 @@ static void __init
 gt64260_enable_window_32bit(struct mv64x60_handle *bh, u32 window)
 {
        pr_debug("enable 32bit window: %d\n", window);
-       return;
 }
 
 /*
@@ -1584,8 +1571,6 @@ gt64260_disable_window_32bit(struct mv64x60_handle *bh, u32 window)
                mv64x60_write(bh, gt64260_32bit_windows[window].base_reg,0xfff);
                mv64x60_write(bh, gt64260_32bit_windows[window].size_reg, 0);
        }
-
-       return;
 }
 
 /*
@@ -1599,7 +1584,6 @@ static void __init
 gt64260_enable_window_64bit(struct mv64x60_handle *bh, u32 window)
 {
        pr_debug("enable 64bit window: %d\n", window);
-       return; /* Enabled when window configured (i.e., when top >= base) */
 }
 
 /*
@@ -1624,8 +1608,6 @@ gt64260_disable_window_64bit(struct mv64x60_handle *bh, u32 window)
                mv64x60_write(bh, gt64260_64bit_windows[window].base_hi_reg, 0);
                mv64x60_write(bh, gt64260_64bit_windows[window].size_reg, 0);
        }
-
-       return;
 }
 
 /*
@@ -1712,8 +1694,6 @@ gt64260_disable_all_windows(struct mv64x60_handle *bh,
        mv64x60_write(bh, GT64260_IC_CPU_INT_1_MASK, 0);
        mv64x60_write(bh, GT64260_IC_CPU_INT_2_MASK, 0);
        mv64x60_write(bh, GT64260_IC_CPU_INT_3_MASK, 0);
-
-       return;
 }
 
 /*
@@ -1781,14 +1761,11 @@ gt64260a_chip_specific_init(struct mv64x60_handle *bh,
        mv64x60_mpsc1_pdata.cache_mgmt = 1;
 
        if ((r = platform_get_resource(&mpsc1_device, IORESOURCE_IRQ, 0))
-               != NULL) {
-
+                       != NULL) {
                r->start = MV64x60_IRQ_SDMA_0;
                r->end = MV64x60_IRQ_SDMA_0;
        }
 #endif
-
-       return;
 }
 
 /*
@@ -1861,14 +1838,11 @@ gt64260b_chip_specific_init(struct mv64x60_handle *bh,
        mv64x60_mpsc1_pdata.cache_mgmt = 1;
 
        if ((r = platform_get_resource(&mpsc1_device, IORESOURCE_IRQ, 0))
-               != NULL) {
-
+                       != NULL) {
                r->start = MV64x60_IRQ_SDMA_0;
                r->end = MV64x60_IRQ_SDMA_0;
        }
 #endif
-
-       return;
 }
 
 /*
@@ -1945,8 +1919,6 @@ mv64360_set_pci2mem_window(struct pci_controller *hose, u32 bus, u32 window,
                mv64360_reg_addrs[bus][window].base_lo_bar,
                mv64x60_mask(base,20) | 0xc);
        mv64x60_pci_exclude_bridge = save_exclude;
-
-       return;
 }
 
 /*
@@ -1972,8 +1944,6 @@ mv64360_set_pci2regs_window(struct mv64x60_handle *bh,
        early_write_config_dword(hose, 0, PCI_DEVFN(0,0),
                mv64360_offset[bus][1], 0);
        mv64x60_pci_exclude_bridge = save_exclude;
-
-       return;
 }
 
 /*
@@ -2082,8 +2052,6 @@ mv64360_enable_window_32bit(struct mv64x60_handle *bh, u32 window)
                                "32bit table corrupted");
                }
        }
-
-       return;
 }
 
 /*
@@ -2139,8 +2107,6 @@ mv64360_disable_window_32bit(struct mv64x60_handle *bh, u32 window)
                                "32bit table corrupted");
                }
        }
-
-       return;
 }
 
 /*
@@ -2158,8 +2124,7 @@ mv64360_enable_window_64bit(struct mv64x60_handle *bh, u32 window)
                (mv64360_64bit_windows[window].size_reg != 0)) {
 
                if ((mv64360_64bit_windows[window].extra & MV64x60_EXTRA_MASK)
-                       == MV64x60_EXTRA_PCIACC_ENAB)
-
+                               == MV64x60_EXTRA_PCIACC_ENAB)
                        mv64x60_set_bits(bh,
                                mv64360_64bit_windows[window].base_lo_reg,
                                (1 << (mv64360_64bit_windows[window].extra &
@@ -2168,8 +2133,6 @@ mv64360_enable_window_64bit(struct mv64x60_handle *bh, u32 window)
                        printk(KERN_ERR "mv64360_enable: %s\n",
                                "64bit table corrupted");
        }
-
-       return;
 }
 
 /*
@@ -2186,11 +2149,9 @@ mv64360_disable_window_64bit(struct mv64x60_handle *bh, u32 window)
                mv64360_64bit_windows[window].size_reg);
 
        if ((mv64360_64bit_windows[window].base_lo_reg != 0) &&
-               (mv64360_64bit_windows[window].size_reg != 0)) {
-
+                       (mv64360_64bit_windows[window].size_reg != 0)) {
                if ((mv64360_64bit_windows[window].extra & MV64x60_EXTRA_MASK)
-                       == MV64x60_EXTRA_PCIACC_ENAB)
-
+                               == MV64x60_EXTRA_PCIACC_ENAB)
                        mv64x60_clr_bits(bh,
                                mv64360_64bit_windows[window].base_lo_reg,
                                (1 << (mv64360_64bit_windows[window].extra &
@@ -2199,8 +2160,6 @@ mv64360_disable_window_64bit(struct mv64x60_handle *bh, u32 window)
                        printk(KERN_ERR "mv64360_disable: %s\n",
                                "64bit table corrupted");
        }
-
-       return;
 }
 
 /*
@@ -2241,8 +2200,6 @@ mv64360_disable_all_windows(struct mv64x60_handle *bh,
        /* Disable all PCI-><whatever> windows */
        mv64x60_set_bits(bh, MV64x60_PCI0_BAR_ENABLE, 0x0000f9ff);
        mv64x60_set_bits(bh, MV64x60_PCI1_BAR_ENABLE, 0x0000f9ff);
-
-       return;
 }
 
 /*
@@ -2335,8 +2292,6 @@ mv64360_config_io2mem_windows(struct mv64x60_handle *bh,
                        mv64x60_set_bits(bh, MV64360_IDMA2MEM_ACC_PROT_3,
                                (0x3 << (i << 1)));
                }
-
-       return;
 }
 
 /*
@@ -2350,42 +2305,145 @@ static void __init
 mv64360_set_mpsc2regs_window(struct mv64x60_handle *bh, u32 base)
 {
        pr_debug("set mpsc->internal regs, base: 0x%x\n", base);
-
        mv64x60_write(bh, MV64360_MPSC2REGS_BASE, base & 0xffff0000);
-       return;
 }
 
 /*
  * mv64360_chip_specific_init()
  *
- * No errata work arounds for the MV64360 implemented at this point.
+ * Implement errata work arounds for the MV64360.
  */
 static void __init
 mv64360_chip_specific_init(struct mv64x60_handle *bh,
        struct mv64x60_setup_info *si)
 {
+#if !defined(CONFIG_NOT_COHERENT_CACHE)
+       mv64x60_set_bits(bh, MV64360_D_UNIT_CONTROL_HIGH, (1<<24));
+#endif
 #ifdef CONFIG_SERIAL_MPSC
        mv64x60_mpsc0_pdata.brg_can_tune = 1;
        mv64x60_mpsc0_pdata.cache_mgmt = 1;
        mv64x60_mpsc1_pdata.brg_can_tune = 1;
        mv64x60_mpsc1_pdata.cache_mgmt = 1;
 #endif
-
-       return;
 }
 
 /*
  * mv64460_chip_specific_init()
  *
- * No errata work arounds for the MV64460 implemented at this point.
+ * Implement errata work arounds for the MV64460.
  */
 static void __init
 mv64460_chip_specific_init(struct mv64x60_handle *bh,
        struct mv64x60_setup_info *si)
 {
+#if !defined(CONFIG_NOT_COHERENT_CACHE)
+       mv64x60_set_bits(bh, MV64360_D_UNIT_CONTROL_HIGH, (1<<24) | (1<<25));
+       mv64x60_set_bits(bh, MV64460_D_UNIT_MMASK, (1<<1) | (1<<4));
+#endif
 #ifdef CONFIG_SERIAL_MPSC
        mv64x60_mpsc0_pdata.brg_can_tune = 1;
+       mv64x60_mpsc0_pdata.cache_mgmt = 1;
        mv64x60_mpsc1_pdata.brg_can_tune = 1;
+       mv64x60_mpsc1_pdata.cache_mgmt = 1;
 #endif
-       return;
 }
+
+
+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GT64260)
+/* Export the hotswap register via sysfs for enum event monitoring */
+#define        VAL_LEN_MAX     11 /* 32-bit hex or dec stringified number + '\n' */
+
+DECLARE_MUTEX(mv64xxx_hs_lock);
+
+static ssize_t
+mv64xxx_hs_reg_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
+{
+       u32     v;
+       u8      save_exclude;
+
+       if (off > 0)
+               return 0;
+       if (count < VAL_LEN_MAX)
+               return -EINVAL;
+
+       if (down_interruptible(&mv64xxx_hs_lock))
+               return -ERESTARTSYS;
+       save_exclude = mv64x60_pci_exclude_bridge;
+       mv64x60_pci_exclude_bridge = 0;
+       early_read_config_dword(&sysfs_hose_a, 0, PCI_DEVFN(0, 0),
+                       MV64360_PCICFG_CPCI_HOTSWAP, &v);
+       mv64x60_pci_exclude_bridge = save_exclude;
+       up(&mv64xxx_hs_lock);
+
+       return sprintf(buf, "0x%08x\n", v);
+}
+
+static ssize_t
+mv64xxx_hs_reg_write(struct kobject *kobj, char *buf, loff_t off, size_t count)
+{
+       u32     v;
+       u8      save_exclude;
+
+       if (off > 0)
+               return 0;
+       if (count <= 0)
+               return -EINVAL;
+
+       if (sscanf(buf, "%i", &v) == 1) {
+               if (down_interruptible(&mv64xxx_hs_lock))
+                       return -ERESTARTSYS;
+               save_exclude = mv64x60_pci_exclude_bridge;
+               mv64x60_pci_exclude_bridge = 0;
+               early_write_config_dword(&sysfs_hose_a, 0, PCI_DEVFN(0, 0),
+                               MV64360_PCICFG_CPCI_HOTSWAP, v);
+               mv64x60_pci_exclude_bridge = save_exclude;
+               up(&mv64xxx_hs_lock);
+       }
+       else
+               count = -EINVAL;
+
+       return count;
+}
+
+static struct bin_attribute mv64xxx_hs_reg_attr = { /* Hotswap register */
+       .attr = {
+               .name = "hs_reg",
+               .mode = S_IRUGO | S_IWUSR,
+               .owner = THIS_MODULE,
+       },
+       .size  = VAL_LEN_MAX,
+       .read  = mv64xxx_hs_reg_read,
+       .write = mv64xxx_hs_reg_write,
+};
+
+/* Provide sysfs file indicating if this platform supports the hs_reg */
+static ssize_t
+mv64xxx_hs_reg_valid_show(struct device *dev, struct device_attribute *attr,
+               char *buf)
+{
+       struct platform_device  *pdev;
+       struct mv64xxx_pdata    *pdp;
+       u32                     v;
+
+       pdev = container_of(dev, struct platform_device, dev);
+       pdp = (struct mv64xxx_pdata *)pdev->dev.platform_data;
+
+       if (down_interruptible(&mv64xxx_hs_lock))
+               return -ERESTARTSYS;
+       v = pdp->hs_reg_valid;
+       up(&mv64xxx_hs_lock);
+
+       return sprintf(buf, "%i\n", v);
+}
+static DEVICE_ATTR(hs_reg_valid, S_IRUGO, mv64xxx_hs_reg_valid_show, NULL);
+
+static int __init
+mv64xxx_sysfs_init(void)
+{
+       sysfs_create_bin_file(&mv64xxx_device.dev.kobj, &mv64xxx_hs_reg_attr);
+       sysfs_create_file(&mv64xxx_device.dev.kobj,&dev_attr_hs_reg_valid.attr);
+       return 0;
+}
+subsys_initcall(mv64xxx_sysfs_init);
+#endif
index 1eb4f726ca9ffb09567d77489d9e5bf341f29357..da8a0f2128dccc23bc06cc8b3f8a93809384e7ec 100644 (file)
@@ -105,7 +105,7 @@ static int of_device_remove(struct device *dev)
        return 0;
 }
 
-static int of_device_suspend(struct device *dev, u32 state)
+static int of_device_suspend(struct device *dev, pm_message_t state)
 {
        struct of_device * of_dev = to_of_device(dev);
        struct of_platform_driver * drv = to_of_platform_driver(dev->driver);
index ad39b86ca92ca545c879c951307a05c3f0404208..53da58523e39f3380e303f4f33e0ca20c32db81d 100644 (file)
@@ -948,7 +948,7 @@ static void openpic_cached_disable_irq(u_int irq)
  * we need something better to deal with that... Maybe switch to S1 for
  * cpufreq changes
  */
-int openpic_suspend(struct sys_device *sysdev, u32 state)
+int openpic_suspend(struct sys_device *sysdev, pm_message_t state)
 {
        int     i;
        unsigned long flags;
index e170aebeb69b897dc94fdcf90b5e39870cf714e1..b843c4fef25e694ba56182ff2ff68e0fe9a0b269 100644 (file)
 extern void abort(void);
 extern void ppc4xx_find_bridges(void);
 
-extern void ppc4xx_wdt_heartbeat(void);
-extern int wdt_enable;
-extern unsigned long wdt_period;
-
 /* Global Variables */
 bd_t __res;
 
@@ -171,7 +167,7 @@ ppc4xx_calibrate_decr(void)
        unsigned int freq;
        bd_t *bip = &__res;
 
-#if defined(CONFIG_WALNUT) || defined(CONFIG_ASH) || defined(CONFIG_SYCAMORE)
+#if defined(CONFIG_WALNUT) || defined(CONFIG_SYCAMORE)
        /* Walnut boot rom sets DCR CHCR1 (aka CPC0_CR1) bit CETE to 1 */
        mtdcr(DCRN_CHCR1, mfdcr(DCRN_CHCR1) & ~CHR1_CETE);
 #endif
@@ -257,22 +253,6 @@ ppc4xx_init(unsigned long r3, unsigned long r4, unsigned long r5,
                *(char *) (r7 + KERNELBASE) = 0;
                strcpy(cmd_line, (char *) (r6 + KERNELBASE));
        }
-#if defined(CONFIG_PPC405_WDT)
-/* Look for wdt= option on command line */
-       if (strstr(cmd_line, "wdt=")) {
-               int valid_wdt = 0;
-               char *p, *q;
-               for (q = cmd_line; (p = strstr(q, "wdt=")) != 0;) {
-                       q = p + 4;
-                       if (p > cmd_line && p[-1] != ' ')
-                               continue;
-                       wdt_period = simple_strtoul(q, &q, 0);
-                       valid_wdt = 1;
-                       ++q;
-               }
-               wdt_enable = valid_wdt;
-       }
-#endif
 
        /* Initialize machine-dependent vectors */
 
@@ -287,11 +267,6 @@ ppc4xx_init(unsigned long r3, unsigned long r4, unsigned long r5,
 
        ppc_md.calibrate_decr = ppc4xx_calibrate_decr;
 
-#ifdef CONFIG_PPC405_WDT
-       ppc_md.heartbeat = ppc4xx_wdt_heartbeat;
-#endif
-       ppc_md.heartbeat_count = 0;
-
        ppc_md.find_end_of_memory = ppc4xx_find_end_of_memory;
        ppc_md.setup_io_mappings = ppc4xx_map_io;
 
diff --git a/arch/ppc/syslib/ppc83xx_pci.h b/arch/ppc/syslib/ppc83xx_pci.h
new file mode 100644 (file)
index 0000000..ec69164
--- /dev/null
@@ -0,0 +1,151 @@
+/* Created by Tony Li <tony.li@freescale.com>
+ * Copyright (c) 2005 freescale semiconductor
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the  GNU General Public License along
+ * with this program; if not, write  to the Free Software Foundation, Inc.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __PPC_SYSLIB_PPC83XX_PCI_H
+#define __PPC_SYSLIB_PPC83XX_PCI_H
+
+typedef struct immr_clk {
+       u32 spmr; /* system PLL mode Register  */
+       u32 occr; /* output clock control Register  */
+       u32 sccr; /* system clock control Register  */
+       u8 res0[0xF4];
+} immr_clk_t;
+
+/*
+ * Sequencer
+ */
+typedef struct immr_ios {
+       u32     potar0;
+       u8      res0[4];
+       u32     pobar0;
+       u8      res1[4];
+       u32     pocmr0;
+       u8      res2[4];
+       u32     potar1;
+       u8      res3[4];
+       u32     pobar1;
+       u8      res4[4];
+       u32     pocmr1;
+       u8      res5[4];
+       u32     potar2;
+       u8      res6[4];
+       u32     pobar2;
+       u8      res7[4];
+       u32     pocmr2;
+       u8      res8[4];
+       u32     potar3;
+       u8      res9[4];
+       u32     pobar3;
+       u8      res10[4];
+       u32     pocmr3;
+       u8      res11[4];
+       u32     potar4;
+       u8      res12[4];
+       u32     pobar4;
+       u8      res13[4];
+       u32     pocmr4;
+       u8      res14[4];
+       u32     potar5;
+       u8      res15[4];
+       u32     pobar5;
+       u8      res16[4];
+       u32     pocmr5;
+       u8      res17[4];
+       u8      res18[0x60];
+       u32     pmcr;
+       u8      res19[4];
+       u32     dtcr;
+       u8      res20[4];
+} immr_ios_t;
+#define POTAR_TA_MASK  0x000fffff
+#define POBAR_BA_MASK  0x000fffff
+#define POCMR_EN       0x80000000
+#define POCMR_IO       0x40000000 /* 0--memory space 1--I/O space */
+#define POCMR_SE       0x20000000 /* streaming enable */
+#define POCMR_DST      0x10000000 /* 0--PCI1 1--PCI2 */
+#define POCMR_CM_MASK  0x000fffff
+
+/*
+ * PCI Controller Control and Status Registers
+ */
+typedef struct immr_pcictrl {
+       u32     esr;
+       u32     ecdr;
+       u32     eer;
+       u32     eatcr;
+       u32     eacr;
+       u32     eeacr;
+       u32     edlcr;
+       u32     edhcr;
+       u32     gcr;
+       u32     ecr;
+       u32     gsr;
+       u8      res0[12];
+       u32     pitar2;
+       u8      res1[4];
+       u32     pibar2;
+       u32     piebar2;
+       u32     piwar2;
+       u8      res2[4];
+       u32     pitar1;
+       u8      res3[4];
+       u32     pibar1;
+       u32     piebar1;
+       u32     piwar1;
+       u8      res4[4];
+       u32     pitar0;
+       u8      res5[4];
+       u32     pibar0;
+       u8      res6[4];
+       u32     piwar0;
+       u8      res7[132];
+} immr_pcictrl_t;
+#define PITAR_TA_MASK  0x000fffff
+#define PIBAR_MASK     0xffffffff
+#define PIEBAR_EBA_MASK        0x000fffff
+#define PIWAR_EN       0x80000000
+#define PIWAR_PF       0x20000000
+#define PIWAR_RTT_MASK 0x000f0000
+#define PIWAR_RTT_NO_SNOOP     0x00040000
+#define PIWAR_RTT_SNOOP        0x00050000
+#define PIWAR_WTT_MASK 0x0000f000
+#define PIWAR_WTT_NO_SNOOP     0x00004000
+#define PIWAR_WTT_SNOOP        0x00005000
+#define PIWAR_IWS_MASK 0x0000003F
+#define PIWAR_IWS_4K   0x0000000B
+#define PIWAR_IWS_8K   0x0000000C
+#define PIWAR_IWS_16K  0x0000000D
+#define PIWAR_IWS_32K  0x0000000E
+#define PIWAR_IWS_64K  0x0000000F
+#define PIWAR_IWS_128K 0x00000010
+#define PIWAR_IWS_256K 0x00000011
+#define PIWAR_IWS_512K 0x00000012
+#define PIWAR_IWS_1M   0x00000013
+#define PIWAR_IWS_2M   0x00000014
+#define PIWAR_IWS_4M   0x00000015
+#define PIWAR_IWS_8M   0x00000016
+#define PIWAR_IWS_16M  0x00000017
+#define PIWAR_IWS_32M  0x00000018
+#define PIWAR_IWS_64M  0x00000019
+#define PIWAR_IWS_128M 0x0000001A
+#define PIWAR_IWS_256M 0x0000001B
+#define PIWAR_IWS_512M 0x0000001C
+#define PIWAR_IWS_1G   0x0000001D
+#define PIWAR_IWS_2G   0x0000001E
+
+#endif /* __PPC_SYSLIB_PPC83XX_PCI_H */
index 602a86891f7fd826cf7b38ab92a899d23f21dc4d..890484e576e79ef7af48163043869da1a727e808 100644 (file)
  * under  the terms of  the GNU General  Public License as published by the
  * Free Software Foundation;  either version 2 of the  License, or (at your
  * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the  GNU General Public License along
+ * with this program; if not, write  to the Free Software Foundation, Inc.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Added PCI support -- Tony Li <tony.li@freescale.com>
  */
 
 #include <linux/config.h>
 #include <asm/delay.h>
 
 #include <syslib/ppc83xx_setup.h>
+#if defined(CONFIG_PCI)
+#include <asm/delay.h>
+#include <syslib/ppc83xx_pci.h>
+#endif
 
 phys_addr_t immrbar;
 
@@ -162,4 +177,237 @@ mpc83xx_halt(void)
        for(;;);
 }
 
-/* PCI SUPPORT DOES NOT EXIT, MODEL after ppc85xx_setup.c */
+#if defined(CONFIG_PCI)
+void __init
+mpc83xx_setup_pci1(struct pci_controller *hose)
+{
+       u16 reg16;
+       volatile immr_pcictrl_t * pci_ctrl;
+       volatile immr_ios_t * ios;
+       bd_t *binfo = (bd_t *) __res;
+
+       pci_ctrl = ioremap(binfo->bi_immr_base + 0x8500, sizeof(immr_pcictrl_t));
+       ios = ioremap(binfo->bi_immr_base + 0x8400, sizeof(immr_ios_t));
+
+       /*
+        * Configure PCI Outbound Translation Windows
+        */
+       ios->potar0 = (MPC83xx_PCI1_LOWER_MEM >> 12) & POTAR_TA_MASK;
+       ios->pobar0 = (MPC83xx_PCI1_LOWER_MEM >> 12) & POBAR_BA_MASK;
+       ios->pocmr0 = POCMR_EN |
+               (((0xffffffff - (MPC83xx_PCI1_UPPER_MEM -
+                               MPC83xx_PCI1_LOWER_MEM)) >> 12) & POCMR_CM_MASK);
+
+       /* mapped to PCI1 IO space */
+       ios->potar1 = (MPC83xx_PCI1_LOWER_IO >> 12) & POTAR_TA_MASK;
+       ios->pobar1 = (MPC83xx_PCI1_IO_BASE >> 12) & POBAR_BA_MASK;
+       ios->pocmr1 = POCMR_EN | POCMR_IO |
+               (((0xffffffff - (MPC83xx_PCI1_UPPER_IO -
+                               MPC83xx_PCI1_LOWER_IO)) >> 12) & POCMR_CM_MASK);
+
+       /*
+        * Configure PCI Inbound Translation Windows
+        */
+       pci_ctrl->pitar1 = 0x0;
+       pci_ctrl->pibar1 = 0x0;
+       pci_ctrl->piebar1 = 0x0;
+       pci_ctrl->piwar1 = PIWAR_EN | PIWAR_PF | PIWAR_RTT_SNOOP | PIWAR_WTT_SNOOP | PIWAR_IWS_2G;
+
+       /*
+        * Release PCI RST signal
+        */
+       pci_ctrl->gcr = 0;
+       udelay(2000);
+       pci_ctrl->gcr = 1;
+       udelay(2000);
+
+       reg16 = 0xff;
+       early_read_config_word(hose, hose->first_busno, 0, PCI_COMMAND, &reg16);
+       reg16 |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
+       early_write_config_word(hose, hose->first_busno, 0, PCI_COMMAND, reg16);
+
+       /*
+        * Clear non-reserved bits in status register.
+        */
+       early_write_config_word(hose, hose->first_busno, 0, PCI_STATUS, 0xffff);
+       early_write_config_byte(hose, hose->first_busno, 0, PCI_LATENCY_TIMER, 0x80);
+
+       iounmap(pci_ctrl);
+       iounmap(ios);
+}
+
+void __init
+mpc83xx_setup_pci2(struct pci_controller *hose)
+{
+       u16 reg16;
+       volatile immr_pcictrl_t * pci_ctrl;
+       volatile immr_ios_t * ios;
+       bd_t *binfo = (bd_t *) __res;
+
+       pci_ctrl = ioremap(binfo->bi_immr_base + 0x8600, sizeof(immr_pcictrl_t));
+       ios = ioremap(binfo->bi_immr_base + 0x8400, sizeof(immr_ios_t));
+
+       /*
+        * Configure PCI Outbound Translation Windows
+        */
+       ios->potar3 = (MPC83xx_PCI2_LOWER_MEM >> 12) & POTAR_TA_MASK;
+       ios->pobar3 = (MPC83xx_PCI2_LOWER_MEM >> 12) & POBAR_BA_MASK;
+       ios->pocmr3 = POCMR_EN | POCMR_DST |
+               (((0xffffffff - (MPC83xx_PCI2_UPPER_MEM -
+                               MPC83xx_PCI2_LOWER_MEM)) >> 12) & POCMR_CM_MASK);
+
+       /* mapped to PCI2 IO space */
+       ios->potar4 = (MPC83xx_PCI2_LOWER_IO >> 12) & POTAR_TA_MASK;
+       ios->pobar4 = (MPC83xx_PCI2_IO_BASE >> 12) & POBAR_BA_MASK;
+       ios->pocmr4 = POCMR_EN | POCMR_DST | POCMR_IO |
+               (((0xffffffff - (MPC83xx_PCI2_UPPER_IO -
+                               MPC83xx_PCI2_LOWER_IO)) >> 12) & POCMR_CM_MASK);
+
+       /*
+        * Configure PCI Inbound Translation Windows
+        */
+       pci_ctrl->pitar1 = 0x0;
+       pci_ctrl->pibar1 = 0x0;
+       pci_ctrl->piebar1 = 0x0;
+       pci_ctrl->piwar1 = PIWAR_EN | PIWAR_PF | PIWAR_RTT_SNOOP | PIWAR_WTT_SNOOP | PIWAR_IWS_2G;
+
+       /*
+        * Release PCI RST signal
+        */
+       pci_ctrl->gcr = 0;
+       udelay(2000);
+       pci_ctrl->gcr = 1;
+       udelay(2000);
+
+       reg16 = 0xff;
+       early_read_config_word(hose, hose->first_busno, 0, PCI_COMMAND, &reg16);
+       reg16 |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
+       early_write_config_word(hose, hose->first_busno, 0, PCI_COMMAND, reg16);
+
+       /*
+        * Clear non-reserved bits in status register.
+        */
+       early_write_config_word(hose, hose->first_busno, 0, PCI_STATUS, 0xffff);
+       early_write_config_byte(hose, hose->first_busno, 0, PCI_LATENCY_TIMER, 0x80);
+
+       iounmap(pci_ctrl);
+       iounmap(ios);
+}
+
+/*
+ * PCI buses can be enabled only if SYS board combinates with PIB
+ * (Platform IO Board) board which provide 3 PCI slots. There is 2 PCI buses
+ * and 3 PCI slots, so people must configure the routes between them before
+ * enable PCI bus. This routes are under the control of PCA9555PW device which
+ * can be accessed via I2C bus 2 and are configured by firmware. Refer to
+ * Freescale to get more information about firmware configuration.
+ */
+
+extern int mpc83xx_exclude_device(u_char bus, u_char devfn);
+extern int mpc83xx_map_irq(struct pci_dev *dev, unsigned char idsel,
+               unsigned char pin);
+void __init
+mpc83xx_setup_hose(void)
+{
+       u32 val32;
+       volatile immr_clk_t * clk;
+       struct pci_controller * hose1;
+#ifdef CONFIG_MPC83xx_PCI2
+       struct pci_controller * hose2;
+#endif
+       bd_t * binfo = (bd_t *)__res;
+
+       clk = ioremap(binfo->bi_immr_base + 0xA00,
+                       sizeof(immr_clk_t));
+
+       /*
+        * Configure PCI controller and PCI_CLK_OUTPUT both in 66M mode
+        */
+       val32 = clk->occr;
+       udelay(2000);
+       clk->occr = 0xff000000;
+       udelay(2000);
+
+       iounmap(clk);
+
+       hose1 = pcibios_alloc_controller();
+       if(!hose1)
+               return;
+
+       ppc_md.pci_swizzle = common_swizzle;
+       ppc_md.pci_map_irq = mpc83xx_map_irq;
+
+       hose1->bus_offset = 0;
+       hose1->first_busno = 0;
+       hose1->last_busno = 0xff;
+
+       setup_indirect_pci(hose1, binfo->bi_immr_base + PCI1_CFG_ADDR_OFFSET,
+                       binfo->bi_immr_base + PCI1_CFG_DATA_OFFSET);
+       hose1->set_cfg_type = 1;
+
+       mpc83xx_setup_pci1(hose1);
+
+       hose1->pci_mem_offset = MPC83xx_PCI1_MEM_OFFSET;
+       hose1->mem_space.start = MPC83xx_PCI1_LOWER_MEM;
+       hose1->mem_space.end = MPC83xx_PCI1_UPPER_MEM;
+
+       hose1->io_base_phys = MPC83xx_PCI1_IO_BASE;
+       hose1->io_space.start = MPC83xx_PCI1_LOWER_IO;
+       hose1->io_space.end = MPC83xx_PCI1_UPPER_IO;
+#ifdef CONFIG_MPC83xx_PCI2
+       isa_io_base = (unsigned long)ioremap(MPC83xx_PCI1_IO_BASE,
+                       MPC83xx_PCI1_IO_SIZE + MPC83xx_PCI2_IO_SIZE);
+#else
+       isa_io_base = (unsigned long)ioremap(MPC83xx_PCI1_IO_BASE,
+                       MPC83xx_PCI1_IO_SIZE);
+#endif /* CONFIG_MPC83xx_PCI2 */
+       hose1->io_base_virt = (void *)isa_io_base;
+       /* setup resources */
+       pci_init_resource(&hose1->io_resource,
+                       MPC83xx_PCI1_LOWER_IO,
+                       MPC83xx_PCI1_UPPER_IO,
+                       IORESOURCE_IO, "PCI host bridge 1");
+       pci_init_resource(&hose1->mem_resources[0],
+                       MPC83xx_PCI1_LOWER_MEM,
+                       MPC83xx_PCI1_UPPER_MEM,
+                       IORESOURCE_MEM, "PCI host bridge 1");
+
+       ppc_md.pci_exclude_device = mpc83xx_exclude_device;
+       hose1->last_busno = pciauto_bus_scan(hose1, hose1->first_busno);
+
+#ifdef CONFIG_MPC83xx_PCI2
+       hose2 = pcibios_alloc_controller();
+       if(!hose2)
+               return;
+
+       hose2->bus_offset = hose1->last_busno + 1;
+       hose2->first_busno = hose1->last_busno + 1;
+       hose2->last_busno = 0xff;
+       setup_indirect_pci(hose2, binfo->bi_immr_base + PCI2_CFG_ADDR_OFFSET,
+                       binfo->bi_immr_base + PCI2_CFG_DATA_OFFSET);
+       hose2->set_cfg_type = 1;
+
+       mpc83xx_setup_pci2(hose2);
+
+       hose2->pci_mem_offset = MPC83xx_PCI2_MEM_OFFSET;
+       hose2->mem_space.start = MPC83xx_PCI2_LOWER_MEM;
+       hose2->mem_space.end = MPC83xx_PCI2_UPPER_MEM;
+
+       hose2->io_base_phys = MPC83xx_PCI2_IO_BASE;
+       hose2->io_space.start = MPC83xx_PCI2_LOWER_IO;
+       hose2->io_space.end = MPC83xx_PCI2_UPPER_IO;
+       hose2->io_base_virt = (void *)(isa_io_base + MPC83xx_PCI1_IO_SIZE);
+       /* setup resources */
+       pci_init_resource(&hose2->io_resource,
+                       MPC83xx_PCI2_LOWER_IO,
+                       MPC83xx_PCI2_UPPER_IO,
+                       IORESOURCE_IO, "PCI host bridge 2");
+       pci_init_resource(&hose2->mem_resources[0],
+                       MPC83xx_PCI2_LOWER_MEM,
+                       MPC83xx_PCI2_UPPER_MEM,
+                       IORESOURCE_MEM, "PCI host bridge 2");
+
+       hose2->last_busno = pciauto_bus_scan(hose2, hose2->first_busno);
+#endif /* CONFIG_MPC83xx_PCI2 */
+}
+#endif /*CONFIG_PCI*/
index 683f179b746ca995989ccf2ec8d588c275ac8c57..c766c1a5f786d62fee8413145563cf5634e0627d 100644 (file)
  * Free Software Foundation;  either version 2 of the  License, or (at your
  * option) any later version.
  *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the  GNU General Public License along
+ * with this program; if not, write  to the Free Software Foundation, Inc.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
 #ifndef __PPC_SYSLIB_PPC83XX_SETUP_H
@@ -19,7 +27,6 @@
 
 #include <linux/config.h>
 #include <linux/init.h>
-#include <asm/ppcboot.h>
 
 extern unsigned long mpc83xx_find_end_of_memory(void) __init;
 extern long mpc83xx_time_init(void) __init;
@@ -31,13 +38,11 @@ extern void mpc83xx_halt(void);
 extern void mpc83xx_setup_hose(void) __init;
 
 /* PCI config */
-#if 0
-#define PCI1_CFG_ADDR_OFFSET   (FIXME)
-#define PCI1_CFG_DATA_OFFSET   (FIXME)
+#define PCI1_CFG_ADDR_OFFSET (0x8300)
+#define PCI1_CFG_DATA_OFFSET (0x8304)
 
-#define PCI2_CFG_ADDR_OFFSET   (FIXME)
-#define PCI2_CFG_DATA_OFFSET   (FIXME)
-#endif
+#define PCI2_CFG_ADDR_OFFSET (0x8380)
+#define PCI2_CFG_DATA_OFFSET (0x8384)
 
 /* Serial Config */
 #ifdef CONFIG_SERIAL_MANY_PORTS
index 879202352560d5993321e63947bdaee4b149d4c9..52ba0c68078df3c09052d4fcac72550af29b86cb 100644 (file)
@@ -6,6 +6,7 @@
  * Maintainer: Kumar Gala <kumar.gala@freescale.com>
  *
  * Copyright 2005 Freescale Semiconductor Inc.
+ * Copyright 2005 MontaVista, Inc. by Vitaly Bordug <vbordug@ru.mvista.com>
  *
  * This program is free software; you can redistribute  it and/or modify it
  * under  the terms of  the GNU General  Public License as published by the
@@ -35,10 +36,59 @@ void __init identify_ppc_sys_by_id(u32 id)
 
 void __init identify_ppc_sys_by_name(char *name)
 {
-       /* TODO */
+       unsigned int i = 0;
+       while (ppc_sys_specs[i].ppc_sys_name[0])
+       {
+               if (!strcmp(ppc_sys_specs[i].ppc_sys_name, name))
+                       break;
+               i++;
+       }
+       cur_ppc_sys_spec = &ppc_sys_specs[i];
        return;
 }
 
+static int __init count_sys_specs(void)
+{
+       int i = 0;
+       while (ppc_sys_specs[i].ppc_sys_name[0])
+               i++;
+       return i;
+}
+
+static int __init find_chip_by_name_and_id(char *name, u32 id)
+{
+       int ret = -1;
+       unsigned int i = 0;
+       unsigned int j = 0;
+       unsigned int dups = 0;
+
+       unsigned char matched[count_sys_specs()];
+
+       while (ppc_sys_specs[i].ppc_sys_name[0]) {
+               if (!strcmp(ppc_sys_specs[i].ppc_sys_name, name))
+                       matched[j++] = i;
+               i++;
+       }
+       if (j != 0) {
+               for (i = 0; i < j; i++) {
+                       if ((ppc_sys_specs[matched[i]].mask & id) ==
+                           ppc_sys_specs[matched[i]].value) {
+                               ret = matched[i];
+                               dups++;
+                       }
+               }
+               ret = (dups == 1) ? ret : (-1 * dups);
+       }
+       return ret;
+}
+
+void __init identify_ppc_sys_by_name_and_id(char *name, u32 id)
+{
+       int i = find_chip_by_name_and_id(name, id);
+       BUG_ON(i < 0);
+       cur_ppc_sys_spec = &ppc_sys_specs[i];
+}
+
 /* Update all memory resources by paddr, call before platform_device_register */
 void __init
 ppc_sys_fixup_mem_resource(struct platform_device *pdev, phys_addr_t paddr)
diff --git a/arch/ppc/syslib/pq2_devices.c b/arch/ppc/syslib/pq2_devices.c
new file mode 100644 (file)
index 0000000..1d38697
--- /dev/null
@@ -0,0 +1,389 @@
+/*
+ * arch/ppc/syslib/pq2_devices.c
+ *
+ * PQ2 Device descriptions
+ *
+ * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/ioport.h>
+#include <asm/cpm2.h>
+#include <asm/irq.h>
+#include <asm/ppc_sys.h>
+
+struct platform_device ppc_sys_platform_devices[] = {
+       [MPC82xx_CPM_FCC1] = {
+               .name = "fsl-cpm-fcc",
+               .id     = 1,
+               .num_resources   = 3,
+               .resource = (struct resource[]) {
+                       {
+                               .name   = "fcc_regs",
+                               .start  = 0x11300,
+                               .end    = 0x1131f,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .name   = "fcc_pram",
+                               .start  = 0x8400,
+                               .end    = 0x84ff,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .start  = SIU_INT_FCC1,
+                               .end    = SIU_INT_FCC1,
+                               .flags  = IORESOURCE_IRQ,
+                       },
+               },
+       },
+       [MPC82xx_CPM_FCC2] = {
+               .name = "fsl-cpm-fcc",
+               .id     = 2,
+               .num_resources   = 3,
+               .resource = (struct resource[]) {
+                       {
+                               .name   = "fcc_regs",
+                               .start  = 0x11320,
+                               .end    = 0x1133f,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .name   = "fcc_pram",
+                               .start  = 0x8500,
+                               .end    = 0x85ff,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .start  = SIU_INT_FCC2,
+                               .end    = SIU_INT_FCC2,
+                               .flags  = IORESOURCE_IRQ,
+                       },
+               },
+       },
+       [MPC82xx_CPM_FCC3] = {
+               .name = "fsl-cpm-fcc",
+               .id     = 3,
+               .num_resources   = 3,
+               .resource = (struct resource[]) {
+                       {
+                               .name   = "fcc_regs",
+                               .start  = 0x11340,
+                               .end    = 0x1135f,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .name   = "fcc_pram",
+                               .start  = 0x8600,
+                               .end    = 0x86ff,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .start  = SIU_INT_FCC3,
+                               .end    = SIU_INT_FCC3,
+                               .flags  = IORESOURCE_IRQ,
+                       },
+               },
+       },
+       [MPC82xx_CPM_I2C] = {
+               .name = "fsl-cpm-i2c",
+               .id     = 1,
+               .num_resources   = 3,
+               .resource = (struct resource[]) {
+                       {
+                               .name   = "i2c_mem",
+                               .start  = 0x11860,
+                               .end    = 0x118BF,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .name   = "i2c_pram",
+                               .start  = 0x8afc,
+                               .end    = 0x8afd,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .start  = SIU_INT_I2C,
+                               .end    = SIU_INT_I2C,
+                               .flags  = IORESOURCE_IRQ,
+                       },
+               },
+       },
+       [MPC82xx_CPM_SCC1] = {
+               .name = "fsl-cpm-scc",
+               .id     = 1,
+               .num_resources   = 3,
+               .resource = (struct resource[]) {
+                       {
+                               .name   = "scc_mem",
+                               .start  = 0x11A00,
+                               .end    = 0x11A1F,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .name   = "scc_pram",
+                               .start  = 0x8000,
+                               .end    = 0x80ff,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .start  = SIU_INT_SCC1,
+                               .end    = SIU_INT_SCC1,
+                               .flags  = IORESOURCE_IRQ,
+                       },
+               },
+       },
+       [MPC82xx_CPM_SCC2] = {
+               .name = "fsl-cpm-scc",
+               .id     = 2,
+               .num_resources   = 3,
+               .resource = (struct resource[]) {
+                       {
+                               .name   = "scc_mem",
+                               .start  = 0x11A20,
+                               .end    = 0x11A3F,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .name   = "scc_pram",
+                               .start  = 0x8100,
+                               .end    = 0x81ff,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .start  = SIU_INT_SCC2,
+                               .end    = SIU_INT_SCC2,
+                               .flags  = IORESOURCE_IRQ,
+                       },
+               },
+       },
+       [MPC82xx_CPM_SCC3] = {
+               .name = "fsl-cpm-scc",
+               .id     = 3,
+               .num_resources   = 3,
+               .resource = (struct resource[]) {
+                       {
+                               .name   = "scc_mem",
+                               .start  = 0x11A40,
+                               .end    = 0x11A5F,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .name   = "scc_pram",
+                               .start  = 0x8200,
+                               .end    = 0x82ff,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .start  = SIU_INT_SCC3,
+                               .end    = SIU_INT_SCC3,
+                               .flags  = IORESOURCE_IRQ,
+                       },
+               },
+       },
+       [MPC82xx_CPM_SCC4] = {
+               .name = "fsl-cpm-scc",
+               .id     = 4,
+               .num_resources   = 3,
+               .resource = (struct resource[]) {
+                       {
+                               .name   = "scc_mem",
+                               .start  = 0x11A60,
+                               .end    = 0x11A7F,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .name   = "scc_pram",
+                               .start  = 0x8300,
+                               .end    = 0x83ff,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .start  = SIU_INT_SCC4,
+                               .end    = SIU_INT_SCC4,
+                               .flags  = IORESOURCE_IRQ,
+                       },
+               },
+       },
+       [MPC82xx_CPM_SPI] = {
+               .name = "fsl-cpm-spi",
+               .id     = 1,
+               .num_resources   = 3,
+               .resource = (struct resource[]) {
+                       {
+                               .name   = "spi_mem",
+                               .start  = 0x11AA0,
+                               .end    = 0x11AFF,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .name   = "spi_pram",
+                               .start  = 0x89fc,
+                               .end    = 0x89fd,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .start  = SIU_INT_SPI,
+                               .end    = SIU_INT_SPI,
+                               .flags  = IORESOURCE_IRQ,
+                       },
+               },
+       },
+       [MPC82xx_CPM_MCC1] = {
+               .name = "fsl-cpm-mcc",
+               .id     = 1,
+               .num_resources   = 3,
+               .resource = (struct resource[]) {
+                       {
+                               .name   = "mcc_mem",
+                               .start  = 0x11B30,
+                               .end    = 0x11B3F,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .name   = "mcc_pram",
+                               .start  = 0x8700,
+                               .end    = 0x877f,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .start  = SIU_INT_MCC1,
+                               .end    = SIU_INT_MCC1,
+                               .flags  = IORESOURCE_IRQ,
+                       },
+               },
+       },
+       [MPC82xx_CPM_MCC2] = {
+               .name = "fsl-cpm-mcc",
+               .id     = 2,
+               .num_resources   = 3,
+               .resource = (struct resource[]) {
+                       {
+                               .name   = "mcc_mem",
+                               .start  = 0x11B50,
+                               .end    = 0x11B5F,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .name   = "mcc_pram",
+                               .start  = 0x8800,
+                               .end    = 0x887f,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .start  = SIU_INT_MCC2,
+                               .end    = SIU_INT_MCC2,
+                               .flags  = IORESOURCE_IRQ,
+                       },
+               },
+       },
+       [MPC82xx_CPM_SMC1] = {
+               .name = "fsl-cpm-smc",
+               .id     = 1,
+               .num_resources   = 3,
+               .resource = (struct resource[]) {
+                       {
+                               .name   = "smc_mem",
+                               .start  = 0x11A80,
+                               .end    = 0x11A8F,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .name   = "smc_pram",
+                               .start  = 0x87fc,
+                               .end    = 0x87fd,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .start  = SIU_INT_SMC1,
+                               .end    = SIU_INT_SMC1,
+                               .flags  = IORESOURCE_IRQ,
+                       },
+               },
+       },
+       [MPC82xx_CPM_SMC2] = {
+               .name = "fsl-cpm-smc",
+               .id     = 2,
+               .num_resources   = 3,
+               .resource = (struct resource[]) {
+                       {
+                               .name   = "smc_mem",
+                               .start  = 0x11A90,
+                               .end    = 0x11A9F,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .name   = "smc_pram",
+                               .start  = 0x88fc,
+                               .end    = 0x88fd,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .start  = SIU_INT_SMC2,
+                               .end    = SIU_INT_SMC2,
+                               .flags  = IORESOURCE_IRQ,
+                       },
+               },
+       },
+       [MPC82xx_CPM_USB] = {
+               .name = "fsl-cpm-usb",
+               .id     = 1,
+               .num_resources  = 3,
+               .resource = (struct resource[]) {
+                       {
+                               .name   = "usb_mem",
+                               .start  = 0x11b60,
+                               .end    = 0x11b78,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .name   = "usb_pram",
+                               .start  = 0x8b00,
+                               .end    = 0x8bff,
+                               .flags  = IORESOURCE_MEM,
+                       },
+                       {
+                               .start  = SIU_INT_USB,
+                               .end    = SIU_INT_USB,
+                               .flags  = IORESOURCE_IRQ,
+                       },
+
+               },
+       },
+       [MPC82xx_SEC1] = {
+               .name = "fsl-sec",
+               .id = 1,
+               .num_resources = 1,
+               .resource = (struct resource[]) {
+                       {
+                               .name   = "sec_mem",
+                               .start  = 0x40000,
+                               .end    = 0x52fff,
+                               .flags  = IORESOURCE_MEM,
+                       },
+               },
+       },
+};
+
+static int __init mach_mpc82xx_fixup(struct platform_device *pdev)
+{
+       ppc_sys_fixup_mem_resource(pdev, CPM_MAP_ADDR);
+       return 0;
+}
+
+static int __init mach_mpc82xx_init(void)
+{
+       if (ppc_md.progress)
+               ppc_md.progress("mach_mpc82xx_init:enter", 0);
+       ppc_sys_device_fixup = mach_mpc82xx_fixup;
+       return 0;
+}
+
+postcore_initcall(mach_mpc82xx_init);
diff --git a/arch/ppc/syslib/pq2_sys.c b/arch/ppc/syslib/pq2_sys.c
new file mode 100644 (file)
index 0000000..7b6c9eb
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+ * arch/ppc/syslib/pq2_devices.c
+ *
+ * PQ2 System descriptions
+ *
+ * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/device.h>
+
+#include <asm/ppc_sys.h>
+
+struct ppc_sys_spec *cur_ppc_sys_spec;
+struct ppc_sys_spec ppc_sys_specs[] = {
+       /* below is a list of the 8260 family of processors */
+       {
+               .ppc_sys_name   = "8250",
+               .mask           = 0x0000ff00,
+               .value          = 0x00000000,
+               .num_devices    = 12,
+               .device_list = (enum ppc_sys_devices[])
+               {
+                       MPC82xx_CPM_FCC1, MPC82xx_CPM_FCC2, MPC82xx_CPM_FCC3,
+                       MPC82xx_CPM_SCC1, MPC82xx_CPM_SCC2, MPC82xx_CPM_SCC3,
+                       MPC82xx_CPM_SCC4, MPC82xx_CPM_MCC1, MPC82xx_CPM_SMC1,
+                       MPC82xx_CPM_SMC2, MPC82xx_CPM_SPI, MPC82xx_CPM_I2C,
+               }
+       },
+       {
+               .ppc_sys_name   = "8255",
+               .mask           = 0x0000ff00,
+               .value          = 0x00000000,
+               .num_devices    = 11,
+               .device_list = (enum ppc_sys_devices[])
+               {
+                       MPC82xx_CPM_FCC1, MPC82xx_CPM_FCC2, MPC82xx_CPM_SCC1,
+                       MPC82xx_CPM_SCC2, MPC82xx_CPM_SCC3, MPC82xx_CPM_SCC4,
+                       MPC82xx_CPM_MCC1, MPC82xx_CPM_SMC1, MPC82xx_CPM_SMC2,
+                       MPC82xx_CPM_SPI, MPC82xx_CPM_I2C,
+               }
+       },
+       {
+               .ppc_sys_name   = "8260",
+               .mask           = 0x0000ff00,
+               .value          = 0x00000000,
+               .num_devices    = 12,
+               .device_list = (enum ppc_sys_devices[])
+               {
+                       MPC82xx_CPM_FCC1, MPC82xx_CPM_FCC2, MPC82xx_CPM_FCC3,
+                       MPC82xx_CPM_SCC1, MPC82xx_CPM_SCC2, MPC82xx_CPM_SCC3,
+                       MPC82xx_CPM_SCC4, MPC82xx_CPM_MCC1, MPC82xx_CPM_SMC1,
+                       MPC82xx_CPM_SMC2, MPC82xx_CPM_SPI, MPC82xx_CPM_I2C,
+               }
+       },
+       {
+               .ppc_sys_name   = "8264",
+               .mask           = 0x0000ff00,
+               .value          = 0x00000000,
+               .num_devices    = 12,
+               .device_list = (enum ppc_sys_devices[])
+               {
+                       MPC82xx_CPM_FCC1, MPC82xx_CPM_FCC2, MPC82xx_CPM_FCC3,
+                       MPC82xx_CPM_SCC1, MPC82xx_CPM_SCC2, MPC82xx_CPM_SCC3,
+                       MPC82xx_CPM_SCC4, MPC82xx_CPM_MCC1, MPC82xx_CPM_SMC1,
+                       MPC82xx_CPM_SMC2, MPC82xx_CPM_SPI, MPC82xx_CPM_I2C,
+               }
+       },
+       {
+               .ppc_sys_name   = "8265",
+               .mask           = 0x0000ff00,
+               .value          = 0x00000000,
+               .num_devices    = 12,
+               .device_list = (enum ppc_sys_devices[])
+               {
+                       MPC82xx_CPM_FCC1, MPC82xx_CPM_FCC2, MPC82xx_CPM_FCC3,
+                       MPC82xx_CPM_SCC1, MPC82xx_CPM_SCC2, MPC82xx_CPM_SCC3,
+                       MPC82xx_CPM_SCC4, MPC82xx_CPM_MCC1, MPC82xx_CPM_SMC1,
+                       MPC82xx_CPM_SMC2, MPC82xx_CPM_SPI, MPC82xx_CPM_I2C,
+               }
+       },
+       {
+               .ppc_sys_name   = "8266",
+               .mask           = 0x0000ff00,
+               .value          = 0x00000000,
+               .num_devices    = 12,
+               .device_list = (enum ppc_sys_devices[])
+               {
+                       MPC82xx_CPM_FCC1, MPC82xx_CPM_FCC2, MPC82xx_CPM_FCC3,
+                       MPC82xx_CPM_SCC1, MPC82xx_CPM_SCC2, MPC82xx_CPM_SCC3,
+                       MPC82xx_CPM_SCC4, MPC82xx_CPM_MCC1, MPC82xx_CPM_SMC1,
+                       MPC82xx_CPM_SMC2, MPC82xx_CPM_SPI, MPC82xx_CPM_I2C,
+               }
+       },
+       /* below is a list of the 8272 family of processors */
+       {
+               .ppc_sys_name   = "8247",
+               .mask           = 0x0000ff00,
+               .value          = 0x00000d00,
+               .num_devices    = 10,
+               .device_list = (enum ppc_sys_devices[])
+               {
+                       MPC82xx_CPM_FCC1, MPC82xx_CPM_FCC2, MPC82xx_CPM_SCC1,
+                       MPC82xx_CPM_SCC2, MPC82xx_CPM_SCC3, MPC82xx_CPM_SMC1,
+                       MPC82xx_CPM_SMC2, MPC82xx_CPM_SPI, MPC82xx_CPM_I2C,
+                       MPC82xx_CPM_USB,
+               },
+       },
+       {
+               .ppc_sys_name   = "8248",
+               .mask           = 0x0000ff00,
+               .value          = 0x00000c00,
+               .num_devices    = 11,
+               .device_list = (enum ppc_sys_devices[])
+               {
+                       MPC82xx_CPM_FCC1, MPC82xx_CPM_FCC2, MPC82xx_CPM_SCC1,
+                       MPC82xx_CPM_SCC2, MPC82xx_CPM_SCC3, MPC82xx_CPM_SMC1,
+                       MPC82xx_CPM_SMC2, MPC82xx_CPM_SPI, MPC82xx_CPM_I2C,
+                       MPC82xx_CPM_USB, MPC82xx_SEC1,
+               },
+       },
+       {
+               .ppc_sys_name   = "8271",
+               .mask           = 0x0000ff00,
+               .value          = 0x00000d00,
+               .num_devices    = 10,
+               .device_list = (enum ppc_sys_devices[])
+               {
+                       MPC82xx_CPM_FCC1, MPC82xx_CPM_FCC2, MPC82xx_CPM_SCC1,
+                       MPC82xx_CPM_SCC2, MPC82xx_CPM_SCC3, MPC82xx_CPM_SMC1,
+                       MPC82xx_CPM_SMC2, MPC82xx_CPM_SPI, MPC82xx_CPM_I2C,
+                       MPC82xx_CPM_USB,
+               },
+       },
+       {
+               .ppc_sys_name   = "8272",
+               .mask           = 0x0000ff00,
+               .value          = 0x00000c00,
+               .num_devices    = 11,
+               .device_list = (enum ppc_sys_devices[])
+               {
+                       MPC82xx_CPM_FCC1, MPC82xx_CPM_FCC2, MPC82xx_CPM_SCC1,
+                       MPC82xx_CPM_SCC2, MPC82xx_CPM_SCC3, MPC82xx_CPM_SMC1,
+                       MPC82xx_CPM_SMC2, MPC82xx_CPM_SPI, MPC82xx_CPM_I2C,
+                       MPC82xx_CPM_USB, MPC82xx_SEC1,
+               },
+       },
+       /* below is a list of the 8280 family of processors */
+       {
+               .ppc_sys_name   = "8270",
+               .mask           = 0x0000ff00,
+               .value          = 0x00000a00,
+               .num_devices    = 12,
+               .device_list = (enum ppc_sys_devices[])
+               {
+                       MPC82xx_CPM_FCC1, MPC82xx_CPM_FCC2, MPC82xx_CPM_FCC3,
+                       MPC82xx_CPM_SCC1, MPC82xx_CPM_SCC2, MPC82xx_CPM_SCC3,
+                       MPC82xx_CPM_SCC4, MPC82xx_CPM_MCC1, MPC82xx_CPM_SMC1,
+                       MPC82xx_CPM_SMC2, MPC82xx_CPM_SPI, MPC82xx_CPM_I2C,
+               },
+       },
+       {
+               .ppc_sys_name   = "8275",
+               .mask           = 0x0000ff00,
+               .value          = 0x00000a00,
+               .num_devices    = 12,
+               .device_list = (enum ppc_sys_devices[])
+               {
+                       MPC82xx_CPM_FCC1, MPC82xx_CPM_FCC2, MPC82xx_CPM_FCC3,
+                       MPC82xx_CPM_SCC1, MPC82xx_CPM_SCC2, MPC82xx_CPM_SCC3,
+                       MPC82xx_CPM_SCC4, MPC82xx_CPM_MCC1, MPC82xx_CPM_SMC1,
+                       MPC82xx_CPM_SMC2, MPC82xx_CPM_SPI, MPC82xx_CPM_I2C,
+               },
+       },
+       {
+               .ppc_sys_name   = "8280",
+               .mask           = 0x0000ff00,
+               .value          = 0x00000a00,
+               .num_devices    = 13,
+               .device_list = (enum ppc_sys_devices[])
+               {
+                       MPC82xx_CPM_FCC1, MPC82xx_CPM_FCC2, MPC82xx_CPM_FCC3,
+                       MPC82xx_CPM_SCC1, MPC82xx_CPM_SCC2, MPC82xx_CPM_SCC3,
+                       MPC82xx_CPM_SCC4, MPC82xx_CPM_MCC1, MPC82xx_CPM_MCC2,
+                       MPC82xx_CPM_SMC1, MPC82xx_CPM_SMC2, MPC82xx_CPM_SPI,
+                       MPC82xx_CPM_I2C,
+               },
+       },
+       {
+               /* default match */
+               .ppc_sys_name   = "",
+               .mask           = 0x00000000,
+               .value          = 0x00000000,
+       },
+};
index 46b1ce58da3b39abd2ae6349040bc87001dd607c..f16a5030527bd1e8f8818dc7337d49ba049054f3 100644 (file)
@@ -41,10 +41,19 @@ config XMON
        help
          Include in-kernel hooks for the xmon kernel monitor/debugger.
          Unless you are intending to debug the kernel, say N here.
+         Make sure to enable also CONFIG_BOOTX_TEXT on Macs. Otherwise
+         nothing will appear on the screen (xmon writes directly to the
+         framebuffer memory).
+         The cmdline option 'xmon' or 'xmon=early' will drop into xmon very
+         early during boot. 'xmon=on' will just enable the xmon debugger hooks.
+         'xmon=off' will disable the debugger hooks if CONFIG_XMON_DEFAULT is set.
 
 config XMON_DEFAULT
        bool "Enable xmon by default"
        depends on XMON
+       help
+         xmon is normally disabled unless booted with 'xmon=on'.
+         Use 'xmon=off' to disable xmon init during runtime.
 
 config PPCDBG
        bool "Include PPCDBG realtime debugging"
index f4b3bfcc109d2e76c883704fca5fc6479438d9fe..ae60eb1193c6c5bd90cafc5c603cc2cdb4b54d3f 100644 (file)
@@ -31,7 +31,7 @@ obj-$(CONFIG_PPC_MULTIPLATFORM) += nvram.o i8259.o prom_init.o prom.o
 
 obj-$(CONFIG_PPC_PSERIES) += pSeries_pci.o pSeries_lpar.o pSeries_hvCall.o \
                             pSeries_nvram.o rtasd.o ras.o pSeries_reconfig.o \
-                            pSeries_setup.o pSeries_iommu.o
+                            pSeries_setup.o pSeries_iommu.o udbg_16550.o
 
 obj-$(CONFIG_PPC_BPA) += bpa_setup.o bpa_iommu.o bpa_nvram.o \
                         bpa_iic.o spider-pic.o
@@ -58,9 +58,11 @@ obj-$(CONFIG_XICS)           += xics.o
 obj-$(CONFIG_MPIC)             += mpic.o
 
 obj-$(CONFIG_PPC_PMAC)         += pmac_setup.o pmac_feature.o pmac_pci.o \
-                                  pmac_time.o pmac_nvram.o pmac_low_i2c.o
+                                  pmac_time.o pmac_nvram.o pmac_low_i2c.o \
+                                  udbg_scc.o
 
-obj-$(CONFIG_PPC_MAPLE)                += maple_setup.o maple_pci.o maple_time.o
+obj-$(CONFIG_PPC_MAPLE)                += maple_setup.o maple_pci.o maple_time.o \
+                                  udbg_16550.o
 
 obj-$(CONFIG_U3_DART)          += u3_iommu.o
 
index c53f079e9b77af0a4ead0bc85543802ab882fe0f..b6fbfbe9032d4f26cee7109116e1464f7ad8a385 100644 (file)
@@ -7,7 +7,6 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/init.h>
-#include <linux/version.h>
 
 #include <asm/sections.h>
 #include <asm/prom.h>
index 4847f2ac8c9fe1d9d8de70ce428d46925699e162..8831a28c3c4ea2f5e28032e4bc3b4bad5d5cce62 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 
+#include <asm/oprofile_impl.h>
 #include <asm/cputable.h>
 
 struct cpu_spec* cur_cpu_spec = NULL;
@@ -54,24 +55,32 @@ struct cpu_spec     cpu_specs[] = {
                .pvr_value              = 0x00400000,
                .cpu_name               = "POWER3 (630)",
                .cpu_features           = CPU_FTR_SPLIT_ID_CACHE |
-                       CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_IABR |
-                       CPU_FTR_PMC8,
+                       CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_IABR,
                .cpu_user_features = COMMON_USER_PPC64,
                .icache_bsize           = 128,
                .dcache_bsize           = 128,
+               .num_pmcs               = 8,
                .cpu_setup              = __setup_cpu_power3,
+#ifdef CONFIG_OPROFILE
+               .oprofile_cpu_type      = "ppc64/power3",
+               .oprofile_model         = &op_model_rs64,
+#endif
        },
        {       /* Power3+ */
                .pvr_mask               = 0xffff0000,
                .pvr_value              = 0x00410000,
                .cpu_name               = "POWER3 (630+)",
                .cpu_features           = CPU_FTR_SPLIT_ID_CACHE |
-                       CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_IABR |
-                       CPU_FTR_PMC8,
+                       CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_IABR,
                .cpu_user_features      = COMMON_USER_PPC64,
                .icache_bsize           = 128,
                .dcache_bsize           = 128,
+               .num_pmcs               = 8,
                .cpu_setup              = __setup_cpu_power3,
+#ifdef CONFIG_OPROFILE
+               .oprofile_cpu_type      = "ppc64/power3",
+               .oprofile_model         = &op_model_rs64,
+#endif
        },
        {       /* Northstar */
                .pvr_mask               = 0xffff0000,
@@ -79,11 +88,16 @@ struct cpu_spec     cpu_specs[] = {
                .cpu_name               = "RS64-II (northstar)",
                .cpu_features           = CPU_FTR_SPLIT_ID_CACHE |
                        CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_IABR |
-                       CPU_FTR_PMC8 | CPU_FTR_MMCRA | CPU_FTR_CTRL,
+                       CPU_FTR_MMCRA | CPU_FTR_CTRL,
                .cpu_user_features      = COMMON_USER_PPC64,
                .icache_bsize           = 128,
                .dcache_bsize           = 128,
+               .num_pmcs               = 8,
                .cpu_setup              = __setup_cpu_power3,
+#ifdef CONFIG_OPROFILE
+               .oprofile_cpu_type      = "ppc64/rs64",
+               .oprofile_model         = &op_model_rs64,
+#endif
        },
        {       /* Pulsar */
                .pvr_mask               = 0xffff0000,
@@ -91,11 +105,16 @@ struct cpu_spec    cpu_specs[] = {
                .cpu_name               = "RS64-III (pulsar)",
                .cpu_features           = CPU_FTR_SPLIT_ID_CACHE |
                        CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_IABR |
-                       CPU_FTR_PMC8 | CPU_FTR_MMCRA | CPU_FTR_CTRL,
+                       CPU_FTR_MMCRA | CPU_FTR_CTRL,
                .cpu_user_features      = COMMON_USER_PPC64,
                .icache_bsize           = 128,
                .dcache_bsize           = 128,
+               .num_pmcs               = 8,
                .cpu_setup              = __setup_cpu_power3,
+#ifdef CONFIG_OPROFILE
+               .oprofile_cpu_type      = "ppc64/rs64",
+               .oprofile_model         = &op_model_rs64,
+#endif
        },
        {       /* I-star */
                .pvr_mask               = 0xffff0000,
@@ -103,11 +122,16 @@ struct cpu_spec   cpu_specs[] = {
                .cpu_name               = "RS64-III (icestar)",
                .cpu_features           = CPU_FTR_SPLIT_ID_CACHE |
                        CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_IABR |
-                       CPU_FTR_PMC8 | CPU_FTR_MMCRA | CPU_FTR_CTRL,
+                       CPU_FTR_MMCRA | CPU_FTR_CTRL,
                .cpu_user_features      = COMMON_USER_PPC64,
                .icache_bsize           = 128,
                .dcache_bsize           = 128,
+               .num_pmcs               = 8,
                .cpu_setup              = __setup_cpu_power3,
+#ifdef CONFIG_OPROFILE
+               .oprofile_cpu_type      = "ppc64/rs64",
+               .oprofile_model         = &op_model_rs64,
+#endif
        },
        {       /* S-star */
                .pvr_mask               = 0xffff0000,
@@ -115,11 +139,16 @@ struct cpu_spec   cpu_specs[] = {
                .cpu_name               = "RS64-IV (sstar)",
                .cpu_features           = CPU_FTR_SPLIT_ID_CACHE |
                        CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_IABR |
-                       CPU_FTR_PMC8 | CPU_FTR_MMCRA | CPU_FTR_CTRL,
+                       CPU_FTR_MMCRA | CPU_FTR_CTRL,
                .cpu_user_features      = COMMON_USER_PPC64,
                .icache_bsize           = 128,
                .dcache_bsize           = 128,
+               .num_pmcs               = 8,
                .cpu_setup              = __setup_cpu_power3,
+#ifdef CONFIG_OPROFILE
+               .oprofile_cpu_type      = "ppc64/rs64",
+               .oprofile_model         = &op_model_rs64,
+#endif
        },
        {       /* Power4 */
                .pvr_mask               = 0xffff0000,
@@ -127,11 +156,16 @@ struct cpu_spec   cpu_specs[] = {
                .cpu_name               = "POWER4 (gp)",
                .cpu_features           = CPU_FTR_SPLIT_ID_CACHE |
                        CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE |
-                       CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_PMC8 | CPU_FTR_MMCRA,
+                       CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_MMCRA,
                .cpu_user_features      = COMMON_USER_PPC64,
                .icache_bsize           = 128,
                .dcache_bsize           = 128,
+               .num_pmcs               = 8,
                .cpu_setup              = __setup_cpu_power4,
+#ifdef CONFIG_OPROFILE
+               .oprofile_cpu_type      = "ppc64/power4",
+               .oprofile_model         = &op_model_rs64,
+#endif
        },
        {       /* Power4+ */
                .pvr_mask               = 0xffff0000,
@@ -139,11 +173,16 @@ struct cpu_spec   cpu_specs[] = {
                .cpu_name               = "POWER4+ (gq)",
                .cpu_features           = CPU_FTR_SPLIT_ID_CACHE |
                        CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE |
-                       CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_PMC8 | CPU_FTR_MMCRA,
+                       CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_MMCRA,
                .cpu_user_features      = COMMON_USER_PPC64,
                .icache_bsize           = 128,
                .dcache_bsize           = 128,
+               .num_pmcs               = 8,
                .cpu_setup              = __setup_cpu_power4,
+#ifdef CONFIG_OPROFILE
+               .oprofile_cpu_type      = "ppc64/power4",
+               .oprofile_model         = &op_model_power4,
+#endif
        },
        {       /* PPC970 */
                .pvr_mask               = 0xffff0000,
@@ -152,12 +191,17 @@ struct cpu_spec   cpu_specs[] = {
                .cpu_features           = CPU_FTR_SPLIT_ID_CACHE |
                        CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE |
                        CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_ALTIVEC_COMP |
-                       CPU_FTR_CAN_NAP | CPU_FTR_PMC8 | CPU_FTR_MMCRA,
+                       CPU_FTR_CAN_NAP | CPU_FTR_MMCRA,
                .cpu_user_features      = COMMON_USER_PPC64 |
                        PPC_FEATURE_HAS_ALTIVEC_COMP,
                .icache_bsize           = 128,
                .dcache_bsize           = 128,
+               .num_pmcs               = 8,
                .cpu_setup              = __setup_cpu_ppc970,
+#ifdef CONFIG_OPROFILE
+               .oprofile_cpu_type      = "ppc64/970",
+               .oprofile_model         = &op_model_power4,
+#endif
        },
        {       /* PPC970FX */
                .pvr_mask               = 0xffff0000,
@@ -166,12 +210,17 @@ struct cpu_spec   cpu_specs[] = {
                .cpu_features           = CPU_FTR_SPLIT_ID_CACHE |
                        CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE |
                        CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_ALTIVEC_COMP |
-                       CPU_FTR_CAN_NAP | CPU_FTR_PMC8 | CPU_FTR_MMCRA,
+                       CPU_FTR_CAN_NAP | CPU_FTR_MMCRA,
                .cpu_user_features      = COMMON_USER_PPC64 |
                        PPC_FEATURE_HAS_ALTIVEC_COMP,
                .icache_bsize           = 128,
                .dcache_bsize           = 128,
+               .num_pmcs               = 8,
                .cpu_setup              = __setup_cpu_ppc970,
+#ifdef CONFIG_OPROFILE
+               .oprofile_cpu_type      = "ppc64/970",
+               .oprofile_model         = &op_model_power4,
+#endif
        },
        {       /* PPC970MP */
                .pvr_mask               = 0xffff0000,
@@ -180,12 +229,16 @@ struct cpu_spec   cpu_specs[] = {
                .cpu_features           = CPU_FTR_SPLIT_ID_CACHE |
                        CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE |
                        CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_ALTIVEC_COMP |
-                       CPU_FTR_CAN_NAP | CPU_FTR_PMC8 | CPU_FTR_MMCRA,
+                       CPU_FTR_CAN_NAP | CPU_FTR_MMCRA,
                .cpu_user_features      = COMMON_USER_PPC64 |
                        PPC_FEATURE_HAS_ALTIVEC_COMP,
                .icache_bsize           = 128,
                .dcache_bsize           = 128,
                .cpu_setup              = __setup_cpu_ppc970,
+#ifdef CONFIG_OPROFILE
+               .oprofile_cpu_type      = "ppc64/970",
+               .oprofile_model         = &op_model_power4,
+#endif
        },
        {       /* Power5 */
                .pvr_mask               = 0xffff0000,
@@ -199,7 +252,12 @@ struct cpu_spec    cpu_specs[] = {
                .cpu_user_features      = COMMON_USER_PPC64,
                .icache_bsize           = 128,
                .dcache_bsize           = 128,
+               .num_pmcs               = 6,
                .cpu_setup              = __setup_cpu_power4,
+#ifdef CONFIG_OPROFILE
+               .oprofile_cpu_type      = "ppc64/power5",
+               .oprofile_model         = &op_model_power4,
+#endif
        },
        {       /* Power5 */
                .pvr_mask               = 0xffff0000,
@@ -213,7 +271,12 @@ struct cpu_spec    cpu_specs[] = {
                .cpu_user_features      = COMMON_USER_PPC64,
                .icache_bsize           = 128,
                .dcache_bsize           = 128,
+               .num_pmcs               = 6,
                .cpu_setup              = __setup_cpu_power4,
+#ifdef CONFIG_OPROFILE
+               .oprofile_cpu_type      = "ppc64/power5",
+               .oprofile_model         = &op_model_power4,
+#endif
        },
        {       /* BE DD1.x */
                .pvr_mask               = 0xffff0000,
@@ -239,6 +302,7 @@ struct cpu_spec     cpu_specs[] = {
                .cpu_user_features      = COMMON_USER_PPC64,
                .icache_bsize           = 128,
                .dcache_bsize           = 128,
+               .num_pmcs               = 6,
                .cpu_setup              = __setup_cpu_power4,
        }
 };
index b61572eb2a7130d7a46924f8412024b9879286e7..bf99b4a92f20864313c7d79211a5d5a6db68a7ce 100644 (file)
@@ -400,15 +400,14 @@ BEGIN_FTR_SECTION
        cmpd    cr1,r6,r9       /* or is new ESID the same as current ESID? */
        cror    eq,4*cr1+eq,eq
        beq     2f              /* if yes, don't slbie it */
-       oris    r0,r6,0x0800    /* set C (class) bit */
 
        /* Bolt in the new stack SLB entry */
        ld      r7,KSP_VSID(r4) /* Get new stack's VSID */
-       oris    r6,r6,(SLB_ESID_V)@h
-       ori     r6,r6,(SLB_NUM_BOLTED-1)@l
-       slbie   r0
-       slbie   r0              /* Workaround POWER5 < DD2.1 issue */
-       slbmte  r7,r6
+       oris    r0,r6,(SLB_ESID_V)@h
+       ori     r0,r0,(SLB_NUM_BOLTED-1)@l
+       slbie   r6
+       slbie   r6              /* Workaround POWER5 < DD2.1 issue */
+       slbmte  r7,r0
        isync
 
 2:
index 036959775623759b4fbd939dca7fae590b160a2f..b436206e317df175118e3aed5ac28441e06980d7 100644 (file)
@@ -1646,8 +1646,9 @@ _GLOBAL(__secondary_start)
 #else
        /* set the ASR */
        ld      r3,systemcfg@got(r2)    /* r3 = ptr to systemcfg         */
+       ld      r3,0(r3)
        lwz     r3,PLATFORM(r3)         /* r3 = platform flags           */
-       cmpldi  r3,PLATFORM_PSERIES_LPAR
+       andi.   r3,r3,PLATFORM_LPAR     /* Test if bit 0 is set (LPAR bit) */
        bne     98f
        mfspr   r3,PVR
        srwi    r3,r3,16
@@ -1809,8 +1810,9 @@ _STATIC(start_here_multiplatform)
        ld      r3,PACASTABREAL(r13)
        ori     r4,r3,1                 /* turn on valid bit             */
        ld      r3,systemcfg@got(r2)    /* r3 = ptr to systemcfg */
+       ld      r3,0(r3)
        lwz     r3,PLATFORM(r3)         /* r3 = platform flags */
-       cmpldi  r3,PLATFORM_PSERIES_LPAR
+       andi.   r3,r3,PLATFORM_LPAR     /* Test if bit 0 is set (LPAR bit) */
        bne     98f
        mfspr   r3,PVR
        srwi    r3,r3,16
@@ -1828,9 +1830,10 @@ _STATIC(start_here_multiplatform)
 99:
        /* Set SDR1 (hash table pointer) */
        ld      r3,systemcfg@got(r2)    /* r3 = ptr to systemcfg */
+       ld      r3,0(r3)
        lwz     r3,PLATFORM(r3)         /* r3 = platform flags */
        /* Test if bit 0 is set (LPAR bit) */
-       andi.   r3,r3,0x1
+       andi.   r3,r3,PLATFORM_LPAR
        bne     98f
        LOADADDR(r6,_SDR1)              /* Only if NOT LPAR */
        sub     r6,r6,r26
index edad361a8db00a9fbc5e3c7950ee575e22f8d4db..cae19bbd5acd9d790ef84945b678872ffd1c2593 100644 (file)
@@ -569,7 +569,7 @@ struct file_operations lparcfg_fops = {
 int __init lparcfg_init(void)
 {
        struct proc_dir_entry *ent;
-       mode_t mode = S_IRUSR;
+       mode_t mode = S_IRUSR | S_IRGRP | S_IROTH;
 
        /* Allow writing if we have FW_FEATURE_SPLPAR */
        if (firmware_has_feature(FW_FEATURE_SPLPAR)) {
index bb55b5a569103ca48d7932d753f41ceeb9349f11..fc0567498a3a30deeb69bb80cc897e98e5b8db40 100644 (file)
@@ -207,9 +207,6 @@ static void __init maple_init_early(void)
                comport = (void *)ioremap(physport, 16);
                udbg_init_uart(comport, default_speed);
 
-               ppc_md.udbg_putc = udbg_putc;
-               ppc_md.udbg_getc = udbg_getc;
-               ppc_md.udbg_getc_poll = udbg_getc_poll;
                DBG("Hello World !\n");
        }
 
index 0a3ddc9227c56edd27182ea533b487452b519f17..a6de83f2078fc70c563fb6d487d789f0201e430f 100644 (file)
@@ -192,9 +192,9 @@ static unsigned char udbg_getcLP(void)
 void udbg_init_debug_lpar(void)
 {
        vtermno = 0;
-       ppc_md.udbg_putc = udbg_putcLP;
-       ppc_md.udbg_getc = udbg_getcLP;
-       ppc_md.udbg_getc_poll = udbg_getc_pollLP;
+       udbg_putc = udbg_putcLP;
+       udbg_getc = udbg_getcLP;
+       udbg_getc_poll = udbg_getc_pollLP;
 }
 
 /* returns 0 if couldn't find or use /chosen/stdout as console */
@@ -227,18 +227,18 @@ int find_udbg_vterm(void)
                        termno = (u32 *)get_property(stdout_node, "reg", NULL);
                        if (termno) {
                                vtermno = termno[0];
-                               ppc_md.udbg_putc = udbg_putcLP;
-                               ppc_md.udbg_getc = udbg_getcLP;
-                               ppc_md.udbg_getc_poll = udbg_getc_pollLP;
+                               udbg_putc = udbg_putcLP;
+                               udbg_getc = udbg_getcLP;
+                               udbg_getc_poll = udbg_getc_pollLP;
                                found = 1;
                        }
                } else if (device_is_compatible(stdout_node, "hvterm-protocol")) {
                        termno = (u32 *)get_property(stdout_node, "reg", NULL);
                        if (termno) {
                                vtermno = termno[0];
-                               ppc_md.udbg_putc = udbg_hvsi_putc;
-                               ppc_md.udbg_getc = udbg_hvsi_getc;
-                               ppc_md.udbg_getc_poll = udbg_hvsi_getc_poll;
+                               udbg_putc = udbg_hvsi_putc;
+                               udbg_getc = udbg_hvsi_getc;
+                               udbg_getc_poll = udbg_hvsi_getc_poll;
                                found = 1;
                        }
                }
@@ -266,6 +266,10 @@ void vpa_init(int cpu)
 
        /* Register the Virtual Processor Area (VPA) */
        flags = 1UL << (63 - 18);
+
+       if (cpu_has_feature(CPU_FTR_ALTIVEC))
+               paca[cpu].lppaca.vmxregs_in_use = 1;
+
        ret = register_vpa(flags, hwcpu, __pa(vpa));
 
        if (ret)
index f0f0630cf07cb0098030d92297f4e4d12b0ed74d..9490b6c5b1736ae7fa5b42b7cbdf9a02020bd791 100644 (file)
@@ -37,7 +37,7 @@
 #include <linux/ioport.h>
 #include <linux/console.h>
 #include <linux/pci.h>
-#include <linux/version.h>
+#include <linux/utsname.h>
 #include <linux/adb.h>
 #include <linux/module.h>
 #include <linux/delay.h>
@@ -272,7 +272,7 @@ static int __init pSeries_init_panel(void)
 {
        /* Manually leave the kernel version on the panel. */
        ppc_md.progress("Linux ppc64\n", 0);
-       ppc_md.progress(UTS_RELEASE, 0);
+       ppc_md.progress(system_utsname.version, 0);
 
        return 0;
 }
@@ -397,9 +397,6 @@ static void __init pSeries_init_early(void)
                comport = (void *)ioremap(physport, 16);
                udbg_init_uart(comport, default_speed);
 
-               ppc_md.udbg_putc = udbg_putc;
-               ppc_md.udbg_getc = udbg_getc;
-               ppc_md.udbg_getc_poll = udbg_getc_poll;
                DBG("Hello World !\n");
        }
 
index 6182a2cd90a50e171b1812cef88ab76eaf843a55..33a2d8db3f21d428feb9185b9909cc2f2fb8880e 100644 (file)
@@ -59,6 +59,7 @@ extern unsigned long __toc_start;
                .fpregs_in_use = 1,                                         \
                .end_of_quantum = 0xfffffffffffffffful,                     \
                .slb_count = 64,                                            \
+               .vmxregs_in_use = 0,                                        \
        },                                                                  \
 
 #ifdef CONFIG_PPC_ISERIES
index 8ff86a766cdf7d3595b5aab03224150cacc992c4..e7f695dcd8c8dd4dae28d7626e421f93397eca19 100644 (file)
@@ -274,16 +274,6 @@ static void __pmac pmac_halt(void)
 }
 
 #ifdef CONFIG_BOOTX_TEXT
-static int dummy_getc_poll(void)
-{
-       return -1;
-}
-
-static unsigned char dummy_getc(void)
-{
-       return 0;
-}
-
 static void btext_putc(unsigned char c)
 {
        btext_drawchar(c);
@@ -342,16 +332,13 @@ static void __init pmac_init_early(void)
                sccdbg = 1;
                        udbg_init_scc(NULL);
                }
-
-       else {
 #ifdef CONFIG_BOOTX_TEXT
+       else {
                init_boot_display();
 
-               ppc_md.udbg_putc = btext_putc;
-               ppc_md.udbg_getc = dummy_getc;
-               ppc_md.udbg_getc_poll = dummy_getc_poll;
-#endif /* CONFIG_BOOTX_TEXT */
+               udbg_putc = btext_putc;
        }
+#endif /* CONFIG_BOOTX_TEXT */
 
        /* Setup interrupt mapping options */
        ppc64_interrupt_controller = IC_OPEN_PIC;
index b21848826791e224a7bf9bd737de5c0feba74ebe..6ad5a8467f87f1aed705aa793e6f1175e42f207d 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/init.h>
-#include <linux/version.h>
 #include <linux/threads.h>
 #include <linux/spinlock.h>
 #include <linux/types.h>
index 122283a1d39a79d2cb988b51128bec5e582cccdd..9979919cdf9297c1481091151caca0a401ea6a94 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/init.h>
-#include <linux/version.h>
 #include <linux/threads.h>
 #include <linux/spinlock.h>
 #include <linux/types.h>
index b0c3b829fe47c43eac16b7d5ff9d885f0fd1b5c4..e26b0420b6ddea490c8a6fb8f81a0bd9ac351422 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/vmalloc.h>
 #include <linux/spinlock.h>
 #include <linux/cpu.h>
+#include <linux/delay.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -412,8 +413,7 @@ static void do_event_scan_all_cpus(long delay)
 
                /* Drop hotplug lock, and sleep for the specified delay */
                unlock_cpu_hotplug();
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(delay);
+               msleep_interruptible(delay);
                lock_cpu_hotplug();
 
                cpu = next_cpu(cpu, cpu_online_map);
@@ -442,7 +442,7 @@ static int rtasd(void *unused)
 
        printk(KERN_INFO "RTAS daemon started\n");
 
-       DEBUG("will sleep for %d jiffies\n", (HZ*60/rtas_event_scan_rate) / 2);
+       DEBUG("will sleep for %d milliseconds\n", (30000/rtas_event_scan_rate));
 
        /* See if we have any error stored in NVRAM */
        memset(logdata, 0, rtas_error_log_max);
@@ -459,7 +459,7 @@ static int rtasd(void *unused)
        }
 
        /* First pass. */
-       do_event_scan_all_cpus(HZ);
+       do_event_scan_all_cpus(1000);
 
        if (surveillance_timeout != -1) {
                DEBUG("enabling surveillance\n");
@@ -471,7 +471,7 @@ static int rtasd(void *unused)
         * machines have problems if we call event-scan too
         * quickly. */
        for (;;)
-               do_event_scan_all_cpus((HZ*60/rtas_event_scan_rate) / 2);
+               do_event_scan_all_cpus(30000/rtas_event_scan_rate);
 
 error:
        /* Should delete proc entries */
index d729fefa0df580f389eb2425edd54f89d53a7752..6ff52bc61325bc500c243ded44c6076415e663e6 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/spinlock.h>
 #include <linux/bcd.h>
 #include <linux/interrupt.h>
+#include <linux/delay.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -351,8 +352,7 @@ void rtas_get_rtc_time(struct rtc_time *rtc_tm)
                                return; /* delay not allowed */
                        }
                        wait_time = rtas_extended_busy_delay_time(error);
-                       set_current_state(TASK_INTERRUPTIBLE);
-                       schedule_timeout(wait_time);
+                       msleep_interruptible(wait_time);
                        error = RTAS_CLOCK_BUSY;
                }
        } while (error == RTAS_CLOCK_BUSY && (__get_tb() < max_wait_tb));
@@ -386,8 +386,7 @@ int rtas_set_rtc_time(struct rtc_time *tm)
                        if (in_interrupt())
                                return 1;       /* probably decrementer */
                        wait_time = rtas_extended_busy_delay_time(error);
-                       set_current_state(TASK_INTERRUPTIBLE);
-                       schedule_timeout(wait_time);
+                       msleep_interruptible(wait_time);
                        error = RTAS_CLOCK_BUSY;
                }
        } while (error == RTAS_CLOCK_BUSY && (__get_tb() < max_wait_tb));
index 4d70736619c7d5153c8d54bc10e12eb078cb686a..215bf8900304ea8aa135434feeb26b33b53c6c41 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/errno.h>
 #include <linux/proc_fs.h>
 #include <linux/init.h>
+#include <linux/delay.h>
 #include <asm/uaccess.h>
 #include <asm/rtas.h>
 #include <asm/prom.h>
@@ -77,7 +78,7 @@ static ssize_t scanlog_read(struct file *file, char __user *buf,
                return -EFAULT;
 
        for (;;) {
-               wait_time = HZ/2;       /* default wait if no data */
+               wait_time = 500;        /* default wait if no data */
                spin_lock(&rtas_data_buf_lock);
                memcpy(rtas_data_buf, data, RTAS_DATA_BUF_SIZE);
                status = rtas_call(ibm_scan_log_dump, 2, 1, NULL,
@@ -107,24 +108,14 @@ static ssize_t scanlog_read(struct file *file, char __user *buf,
                        break;
                    default:
                        if (status > 9900 && status <= 9905) {
-                               /* No data.  RTAS is hinting at a delay required
-                                * between 1-100000 milliseconds
-                                */
-                               int ms = 1;
-                               for (; status > 9900; status--)
-                                       ms = ms * 10;
-                               /* Use microseconds for reasonable accuracy */
-                               ms *= 1000;
-                               wait_time = ms / (1000000/HZ); /* round down is fine */
-                               /* Fall through to sleep */
+                               wait_time = rtas_extended_busy_delay_time(status);
                        } else {
                                printk(KERN_ERR "scanlog: unknown error from rtas: %d\n", status);
                                return -EIO;
                        }
                }
                /* Apparently no data yet.  Wait and try again. */
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(wait_time);
+               msleep_interruptible(wait_time);
        }
        /*NOTREACHED*/
 }
index ee3b20de2e7a3f5c701dc7bf5af50e5999ed8b78..d0bb68af0ea41d48bca4bc945d6e727ffcd2a424 100644 (file)
@@ -25,7 +25,7 @@
 #include <linux/seq_file.h>
 #include <linux/ioport.h>
 #include <linux/console.h>
-#include <linux/version.h>
+#include <linux/utsname.h>
 #include <linux/tty.h>
 #include <linux/root_dev.h>
 #include <linux/notifier.h>
@@ -89,7 +89,7 @@ extern void udbg_init_maple_realmode(void);
 #define EARLY_DEBUG_INIT() udbg_init_maple_realmode()
 #define EARLY_DEBUG_INIT() udbg_init_pmac_realmode()
 #define EARLY_DEBUG_INIT()                                             \
-       do { ppc_md.udbg_putc = call_rtas_display_status_delay; } while(0)
+       do { udbg_putc = call_rtas_display_status_delay; } while(0)
 #endif
 
 /* extern void *stab; */
@@ -108,7 +108,6 @@ int boot_cpuid = 0;
 int boot_cpuid_phys = 0;
 dev_t boot_dev;
 u64 ppc64_pft_size;
-u64 ppc64_debug_switch;
 
 struct ppc64_caches ppc64_caches;
 EXPORT_SYMBOL_GPL(ppc64_caches);
@@ -154,34 +153,6 @@ struct screen_info screen_info = {
        .orig_video_points = 16
 };
 
-/*
- * Initialize the PPCDBG state.  Called before relocation has been enabled.
- */
-void __init ppcdbg_initialize(void)
-{
-       ppc64_debug_switch = PPC_DEBUG_DEFAULT; /* | PPCDBG_BUSWALK | */
-       /* PPCDBG_PHBINIT | PPCDBG_MM | PPCDBG_MMINIT | PPCDBG_TCEINIT | PPCDBG_TCE */;
-}
-
-/*
- * Early boot console based on udbg
- */
-static struct console udbg_console = {
-       .name   = "udbg",
-       .write  = udbg_console_write,
-       .flags  = CON_PRINTBUFFER,
-       .index  = -1,
-};
-static int early_console_initialized;
-
-void __init disable_early_printk(void)
-{
-       if (!early_console_initialized)
-               return;
-       unregister_console(&udbg_console);
-       early_console_initialized = 0;
-}
-
 #if defined(CONFIG_PPC_MULTIPLATFORM) && defined(CONFIG_SMP)
 
 static int smt_enabled_cmdline;
@@ -425,12 +396,6 @@ void __init early_setup(unsigned long dt_ptr)
        }
        ppc_md = **mach;
 
-       /* our udbg callbacks got overriden by the above, let's put them
-        * back in. Ultimately, I want those things to be split from the
-        * main ppc_md
-        */
-       EARLY_DEBUG_INIT();
-
        DBG("Found, Initializing memory management...\n");
 
        /*
@@ -636,8 +601,7 @@ void __init setup_system(void)
        /*
         * Register early console
         */
-       early_console_initialized = 1;
-       register_console(&udbg_console);
+       register_early_udbg_console();
 
        /* Save unparsed command line copy for /proc/cmdline */
        strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE);
@@ -657,7 +621,7 @@ void __init setup_system(void)
        smp_release_cpus();
 #endif /* defined(CONFIG_SMP) && !defined(CONFIG_PPC_ISERIES) */
 
-       printk("Starting Linux PPC64 %s\n", UTS_RELEASE);
+       printk("Starting Linux PPC64 %s\n", system_utsname.version);
 
        printk("-----------------------------------------------------\n");
        printk("ppc64_pft_size                = 0x%lx\n", ppc64_pft_size);
index f311ee7c0070d2d024d25b78b88622e154793ce5..6654b350979cfd3a868c029677fff0239d9972ed 100644 (file)
@@ -215,18 +215,23 @@ static void register_cpu_online(unsigned int cpu)
        if (cpu_has_feature(CPU_FTR_MMCRA))
                sysdev_create_file(s, &attr_mmcra);
 
-       sysdev_create_file(s, &attr_pmc1);
-       sysdev_create_file(s, &attr_pmc2);
-       sysdev_create_file(s, &attr_pmc3);
-       sysdev_create_file(s, &attr_pmc4);
-       sysdev_create_file(s, &attr_pmc5);
-       sysdev_create_file(s, &attr_pmc6);
-
-       if (cpu_has_feature(CPU_FTR_PMC8)) {
+       if (cur_cpu_spec->num_pmcs >= 1)
+               sysdev_create_file(s, &attr_pmc1);
+       if (cur_cpu_spec->num_pmcs >= 2)
+               sysdev_create_file(s, &attr_pmc2);
+       if (cur_cpu_spec->num_pmcs >= 3)
+               sysdev_create_file(s, &attr_pmc3);
+       if (cur_cpu_spec->num_pmcs >= 4)
+               sysdev_create_file(s, &attr_pmc4);
+       if (cur_cpu_spec->num_pmcs >= 5)
+               sysdev_create_file(s, &attr_pmc5);
+       if (cur_cpu_spec->num_pmcs >= 6)
+               sysdev_create_file(s, &attr_pmc6);
+       if (cur_cpu_spec->num_pmcs >= 7)
                sysdev_create_file(s, &attr_pmc7);
+       if (cur_cpu_spec->num_pmcs >= 8)
                sysdev_create_file(s, &attr_pmc8);
-       }
-
+  
        if (cpu_has_feature(CPU_FTR_SMT))
                sysdev_create_file(s, &attr_purr);
 }
@@ -252,17 +257,22 @@ static void unregister_cpu_online(unsigned int cpu)
        if (cpu_has_feature(CPU_FTR_MMCRA))
                sysdev_remove_file(s, &attr_mmcra);
 
-       sysdev_remove_file(s, &attr_pmc1);
-       sysdev_remove_file(s, &attr_pmc2);
-       sysdev_remove_file(s, &attr_pmc3);
-       sysdev_remove_file(s, &attr_pmc4);
-       sysdev_remove_file(s, &attr_pmc5);
-       sysdev_remove_file(s, &attr_pmc6);
-
-       if (cpu_has_feature(CPU_FTR_PMC8)) {
+       if (cur_cpu_spec->num_pmcs >= 1)
+               sysdev_remove_file(s, &attr_pmc1);
+       if (cur_cpu_spec->num_pmcs >= 2)
+               sysdev_remove_file(s, &attr_pmc2);
+       if (cur_cpu_spec->num_pmcs >= 3)
+               sysdev_remove_file(s, &attr_pmc3);
+       if (cur_cpu_spec->num_pmcs >= 4)
+               sysdev_remove_file(s, &attr_pmc4);
+       if (cur_cpu_spec->num_pmcs >= 5)
+               sysdev_remove_file(s, &attr_pmc5);
+       if (cur_cpu_spec->num_pmcs >= 6)
+               sysdev_remove_file(s, &attr_pmc6);
+       if (cur_cpu_spec->num_pmcs >= 7)
                sysdev_remove_file(s, &attr_pmc7);
+       if (cur_cpu_spec->num_pmcs >= 8)
                sysdev_remove_file(s, &attr_pmc8);
-       }
 
        if (cpu_has_feature(CPU_FTR_SMT))
                sysdev_remove_file(s, &attr_purr);
index 1696e1b05bb9c8b914d5a6198cb5ecd8bb00b6ba..91ef95ccda4fca400f2efe3fd6d983a2f85a40b8 100644 (file)
@@ -51,7 +51,6 @@
 #include <linux/cpu.h>
 #include <linux/security.h>
 
-#include <asm/segment.h>
 #include <asm/io.h>
 #include <asm/processor.h>
 #include <asm/nvram.h>
index c0da45540f0f50e1a2695b4f325e99831cccd3e1..ed6766e21f5a4c5df82405b2ac5530aec54f4e36 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * NS16550 Serial Port (uart) debugging stuff.
+ * polling mode stateless debugging stuff, originally for NS16550 Serial Ports
  *
  * c 2001 PPC 64 Team, IBM Corp
  *
 #define WANT_PPCDBG_TAB /* Only defined here */
 #include <linux/config.h>
 #include <linux/types.h>
+#include <linux/sched.h>
+#include <linux/console.h>
 #include <asm/ppcdebug.h>
 #include <asm/processor.h>
-#include <asm/uaccess.h>
-#include <asm/machdep.h>
-#include <asm/io.h>
-#include <asm/prom.h>
-#include <asm/pmac_feature.h>
 
-extern u8 real_readb(volatile u8 __iomem  *addr);
-extern void real_writeb(u8 data, volatile u8 __iomem *addr);
-
-struct NS16550 {
-       /* this struct must be packed */
-       unsigned char rbr;  /* 0 */
-       unsigned char ier;  /* 1 */
-       unsigned char fcr;  /* 2 */
-       unsigned char lcr;  /* 3 */
-       unsigned char mcr;  /* 4 */
-       unsigned char lsr;  /* 5 */
-       unsigned char msr;  /* 6 */
-       unsigned char scr;  /* 7 */
-};
-
-#define thr rbr
-#define iir fcr
-#define dll rbr
-#define dlm ier
-#define dlab lcr
-
-#define LSR_DR   0x01  /* Data ready */
-#define LSR_OE   0x02  /* Overrun */
-#define LSR_PE   0x04  /* Parity error */
-#define LSR_FE   0x08  /* Framing error */
-#define LSR_BI   0x10  /* Break */
-#define LSR_THRE 0x20  /* Xmit holding register empty */
-#define LSR_TEMT 0x40  /* Xmitter empty */
-#define LSR_ERR  0x80  /* Error */
-
-static volatile struct NS16550 __iomem *udbg_comport;
-
-void udbg_init_uart(void __iomem *comport, unsigned int speed)
-{
-       u16 dll = speed ? (115200 / speed) : 12;
-
-       if (comport) {
-               udbg_comport = (struct NS16550 __iomem *)comport;
-               out_8(&udbg_comport->lcr, 0x00);
-               out_8(&udbg_comport->ier, 0xff);
-               out_8(&udbg_comport->ier, 0x00);
-               out_8(&udbg_comport->lcr, 0x80);        /* Access baud rate */
-               out_8(&udbg_comport->dll, dll & 0xff);  /* 1 = 115200,  2 = 57600,
-                                                          3 = 38400, 12 = 9600 baud */
-               out_8(&udbg_comport->dlm, dll >> 8);    /* dll >> 8 which should be zero
-                                                          for fast rates; */
-               out_8(&udbg_comport->lcr, 0x03);        /* 8 data, 1 stop, no parity */
-               out_8(&udbg_comport->mcr, 0x03);        /* RTS/DTR */
-               out_8(&udbg_comport->fcr ,0x07);        /* Clear & enable FIFOs */
-       }
-}
-
-#ifdef CONFIG_PPC_PMAC
-
-#define        SCC_TXRDY       4
-#define SCC_RXRDY      1
-
-static volatile u8 __iomem *sccc;
-static volatile u8 __iomem *sccd;
-
-static unsigned char scc_inittab[] = {
-    13, 0,             /* set baud rate divisor */
-    12, 0,
-    14, 1,             /* baud rate gen enable, src=rtxc */
-    11, 0x50,          /* clocks = br gen */
-    5,  0xea,          /* tx 8 bits, assert DTR & RTS */
-    4,  0x46,          /* x16 clock, 1 stop */
-    3,  0xc1,          /* rx enable, 8 bits */
-};
-
-void udbg_init_scc(struct device_node *np)
-{
-       u32 *reg;
-       unsigned long addr;
-       int i, x;
-
-       if (np == NULL)
-               np = of_find_node_by_name(NULL, "escc");
-       if (np == NULL || np->parent == NULL)
-               return;
-
-       udbg_printf("found SCC...\n");
-       /* Get address within mac-io ASIC */ 
-       reg = (u32 *)get_property(np, "reg", NULL);
-       if (reg == NULL)
-               return;
-       addr = reg[0];
-       udbg_printf("local addr: %lx\n", addr);
-       /* Get address of mac-io PCI itself */
-       reg = (u32 *)get_property(np->parent, "assigned-addresses", NULL);
-       if (reg == NULL)
-               return;
-       addr += reg[2];
-       udbg_printf("final addr: %lx\n", addr);
-
-       /* Setup for 57600 8N1 */
-       addr += 0x20;
-       sccc = (volatile u8 * __iomem) ioremap(addr & PAGE_MASK, PAGE_SIZE) ;
-       sccc += addr & ~PAGE_MASK;
-       sccd = sccc + 0x10;
-
-       udbg_printf("ioremap result sccc: %p\n", sccc);
-       mb();
-
-       for (i = 20000; i != 0; --i)
-               x = in_8(sccc);
-       out_8(sccc, 0x09);              /* reset A or B side */
-       out_8(sccc, 0xc0);
-       for (i = 0; i < sizeof(scc_inittab); ++i)
-               out_8(sccc, scc_inittab[i]);
-
-       ppc_md.udbg_putc = udbg_putc;
-       ppc_md.udbg_getc = udbg_getc;
-       ppc_md.udbg_getc_poll = udbg_getc_poll;
-
-       udbg_puts("Hello World !\n");
-}
-
-#endif /* CONFIG_PPC_PMAC */
-
-#ifdef CONFIG_PPC_PMAC
-static void udbg_real_putc(unsigned char c)
-{
-       while ((real_readb(sccc) & SCC_TXRDY) == 0)
-               ;
-       real_writeb(c, sccd);
-       if (c == '\n')
-               udbg_real_putc('\r');
-}
-
-void udbg_init_pmac_realmode(void)
-{
-       sccc = (volatile u8 __iomem *)0x80013020ul;
-       sccd = (volatile u8 __iomem *)0x80013030ul;
-
-       ppc_md.udbg_putc = udbg_real_putc;
-       ppc_md.udbg_getc = NULL;
-       ppc_md.udbg_getc_poll = NULL;
-}
-#endif /* CONFIG_PPC_PMAC */
-
-#ifdef CONFIG_PPC_MAPLE
-void udbg_maple_real_putc(unsigned char c)
-{
-       if (udbg_comport) {
-               while ((real_readb(&udbg_comport->lsr) & LSR_THRE) == 0)
-                       /* wait for idle */;
-               real_writeb(c, &udbg_comport->thr); eieio();
-               if (c == '\n') {
-                       /* Also put a CR.  This is for convenience. */
-                       while ((real_readb(&udbg_comport->lsr) & LSR_THRE) == 0)
-                               /* wait for idle */;
-                       real_writeb('\r', &udbg_comport->thr); eieio();
-               }
-       }
-}
-
-void udbg_init_maple_realmode(void)
-{
-       udbg_comport = (volatile struct NS16550 __iomem *)0xf40003f8;
-
-       ppc_md.udbg_putc = udbg_maple_real_putc;
-       ppc_md.udbg_getc = NULL;
-       ppc_md.udbg_getc_poll = NULL;
-}
-#endif /* CONFIG_PPC_MAPLE */
-
-void udbg_putc(unsigned char c)
-{
-       if (udbg_comport) {
-               while ((in_8(&udbg_comport->lsr) & LSR_THRE) == 0)
-                       /* wait for idle */;
-               out_8(&udbg_comport->thr, c);
-               if (c == '\n') {
-                       /* Also put a CR.  This is for convenience. */
-                       while ((in_8(&udbg_comport->lsr) & LSR_THRE) == 0)
-                               /* wait for idle */; 
-                       out_8(&udbg_comport->thr, '\r');
-               }
-       }
-#ifdef CONFIG_PPC_PMAC
-       else if (sccc) {
-               while ((in_8(sccc) & SCC_TXRDY) == 0)
-                       ;
-               out_8(sccd,  c);                
-               if (c == '\n')
-                       udbg_putc('\r');
-       }
-#endif /* CONFIG_PPC_PMAC */
-}
-
-int udbg_getc_poll(void)
-{
-       if (udbg_comport) {
-               if ((in_8(&udbg_comport->lsr) & LSR_DR) != 0)
-                       return in_8(&udbg_comport->rbr);
-               else
-                       return -1;
-       }
-#ifdef CONFIG_PPC_PMAC
-       else if (sccc) {
-               if ((in_8(sccc) & SCC_RXRDY) != 0)
-                       return in_8(sccd);
-               else
-                       return -1;
-       }
-#endif /* CONFIG_PPC_PMAC */
-       return -1;
-}
-
-unsigned char udbg_getc(void)
-{
-       if (udbg_comport) {
-               while ((in_8(&udbg_comport->lsr) & LSR_DR) == 0)
-                       /* wait for char */;
-               return in_8(&udbg_comport->rbr);
-       }
-#ifdef CONFIG_PPC_PMAC
-       else if (sccc) {
-               while ((in_8(sccc) & SCC_RXRDY) == 0)
-                       ;
-               return in_8(sccd);
-       }
-#endif /* CONFIG_PPC_PMAC */
-       return 0;
-}
+void (*udbg_putc)(unsigned char c);
+unsigned char (*udbg_getc)(void);
+int (*udbg_getc_poll)(void);
 
+/* udbg library, used by xmon et al */
 void udbg_puts(const char *s)
 {
-       if (ppc_md.udbg_putc) {
+       if (udbg_putc) {
                char c;
 
                if (s && *s != '\0') {
                        while ((c = *s++) != '\0')
-                               ppc_md.udbg_putc(c);
+                               udbg_putc(c);
                }
        }
 #if 0
@@ -270,12 +45,12 @@ int udbg_write(const char *s, int n)
        int remain = n;
        char c;
 
-       if (!ppc_md.udbg_putc)
+       if (!udbg_putc)
                return 0;
 
        if (s && *s != '\0') {
                while (((c = *s++) != '\0') && (remain-- > 0)) {
-                       ppc_md.udbg_putc(c);
+                       udbg_putc(c);
                }
        }
 
@@ -287,12 +62,12 @@ int udbg_read(char *buf, int buflen)
        char c, *p = buf;
        int i;
 
-       if (!ppc_md.udbg_getc)
+       if (!udbg_getc)
                return 0;
 
        for (i = 0; i < buflen; ++i) {
                do {
-                       c = ppc_md.udbg_getc();
+                       c = udbg_getc();
                } while (c == 0x11 || c == 0x13);
                if (c == 0)
                        break;
@@ -302,11 +77,6 @@ int udbg_read(char *buf, int buflen)
        return i;
 }
 
-void udbg_console_write(struct console *con, const char *s, unsigned int n)
-{
-       udbg_write(s, n);
-}
-
 #define UDBG_BUFSIZE 256
 void udbg_printf(const char *fmt, ...)
 {
@@ -319,6 +89,10 @@ void udbg_printf(const char *fmt, ...)
        va_end(args);
 }
 
+/* PPCDBG stuff */
+
+u64 ppc64_debug_switch;
+
 /* Special print used by PPCDBG() macro */
 void udbg_ppcdbg(unsigned long debug_flags, const char *fmt, ...)
 {
@@ -358,3 +132,43 @@ unsigned long udbg_ifdebug(unsigned long flags)
 {
        return (flags & ppc64_debug_switch);
 }
+
+/*
+ * Initialize the PPCDBG state.  Called before relocation has been enabled.
+ */
+void __init ppcdbg_initialize(void)
+{
+       ppc64_debug_switch = PPC_DEBUG_DEFAULT; /* | PPCDBG_BUSWALK | */
+       /* PPCDBG_PHBINIT | PPCDBG_MM | PPCDBG_MMINIT | PPCDBG_TCEINIT | PPCDBG_TCE */;
+}
+
+/*
+ * Early boot console based on udbg
+ */
+static void udbg_console_write(struct console *con, const char *s,
+               unsigned int n)
+{
+       udbg_write(s, n);
+}
+
+static struct console udbg_console = {
+       .name   = "udbg",
+       .write  = udbg_console_write,
+       .flags  = CON_PRINTBUFFER,
+       .index  = -1,
+};
+
+void __init disable_early_printk(void)
+{
+       unregister_console(&udbg_console);
+}
+
+/* called by setup_system */
+void register_early_udbg_console(void)
+{
+       register_console(&udbg_console);
+}
+
+#if 0   /* if you want to use this as a regular output console */
+console_initcall(register_udbg_console);
+#endif
diff --git a/arch/ppc64/kernel/udbg_16550.c b/arch/ppc64/kernel/udbg_16550.c
new file mode 100644 (file)
index 0000000..9313574
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * udbg for for NS16550 compatable serial ports
+ *
+ * Copyright (C) 2001-2005 PPC 64 Team, IBM Corp
+ *
+ *      This program is free software; you can redistribute it and/or
+ *      modify it under the terms of the GNU General Public License
+ *      as published by the Free Software Foundation; either version
+ *      2 of the License, or (at your option) any later version.
+ */
+#include <linux/config.h>
+#include <linux/types.h>
+#include <asm/udbg.h>
+#include <asm/io.h>
+
+extern u8 real_readb(volatile u8 __iomem  *addr);
+extern void real_writeb(u8 data, volatile u8 __iomem *addr);
+
+struct NS16550 {
+       /* this struct must be packed */
+       unsigned char rbr;  /* 0 */
+       unsigned char ier;  /* 1 */
+       unsigned char fcr;  /* 2 */
+       unsigned char lcr;  /* 3 */
+       unsigned char mcr;  /* 4 */
+       unsigned char lsr;  /* 5 */
+       unsigned char msr;  /* 6 */
+       unsigned char scr;  /* 7 */
+};
+
+#define thr rbr
+#define iir fcr
+#define dll rbr
+#define dlm ier
+#define dlab lcr
+
+#define LSR_DR   0x01  /* Data ready */
+#define LSR_OE   0x02  /* Overrun */
+#define LSR_PE   0x04  /* Parity error */
+#define LSR_FE   0x08  /* Framing error */
+#define LSR_BI   0x10  /* Break */
+#define LSR_THRE 0x20  /* Xmit holding register empty */
+#define LSR_TEMT 0x40  /* Xmitter empty */
+#define LSR_ERR  0x80  /* Error */
+
+static volatile struct NS16550 __iomem *udbg_comport;
+
+static void udbg_550_putc(unsigned char c)
+{
+       if (udbg_comport) {
+               while ((in_8(&udbg_comport->lsr) & LSR_THRE) == 0)
+                       /* wait for idle */;
+               out_8(&udbg_comport->thr, c);
+               if (c == '\n')
+                       udbg_550_putc('\r');
+       }
+}
+
+static int udbg_550_getc_poll(void)
+{
+       if (udbg_comport) {
+               if ((in_8(&udbg_comport->lsr) & LSR_DR) != 0)
+                       return in_8(&udbg_comport->rbr);
+               else
+                       return -1;
+       }
+       return -1;
+}
+
+static unsigned char udbg_550_getc(void)
+{
+       if (udbg_comport) {
+               while ((in_8(&udbg_comport->lsr) & LSR_DR) == 0)
+                       /* wait for char */;
+               return in_8(&udbg_comport->rbr);
+       }
+       return 0;
+}
+
+void udbg_init_uart(void __iomem *comport, unsigned int speed)
+{
+       u16 dll = speed ? (115200 / speed) : 12;
+
+       if (comport) {
+               udbg_comport = (struct NS16550 __iomem *)comport;
+               out_8(&udbg_comport->lcr, 0x00);
+               out_8(&udbg_comport->ier, 0xff);
+               out_8(&udbg_comport->ier, 0x00);
+               out_8(&udbg_comport->lcr, 0x80);        /* Access baud rate */
+               out_8(&udbg_comport->dll, dll & 0xff);  /* 1 = 115200,  2 = 57600,
+                                                          3 = 38400, 12 = 9600 baud */
+               out_8(&udbg_comport->dlm, dll >> 8);    /* dll >> 8 which should be zero
+                                                          for fast rates; */
+               out_8(&udbg_comport->lcr, 0x03);        /* 8 data, 1 stop, no parity */
+               out_8(&udbg_comport->mcr, 0x03);        /* RTS/DTR */
+               out_8(&udbg_comport->fcr ,0x07);        /* Clear & enable FIFOs */
+               udbg_putc = udbg_550_putc;
+               udbg_getc = udbg_550_getc;
+               udbg_getc_poll = udbg_550_getc_poll;
+       }
+}
+
+#ifdef CONFIG_PPC_MAPLE
+void udbg_maple_real_putc(unsigned char c)
+{
+       if (udbg_comport) {
+               while ((real_readb(&udbg_comport->lsr) & LSR_THRE) == 0)
+                       /* wait for idle */;
+               real_writeb(c, &udbg_comport->thr); eieio();
+               if (c == '\n')
+                       udbg_maple_real_putc('\r');
+       }
+}
+
+void udbg_init_maple_realmode(void)
+{
+       udbg_comport = (volatile struct NS16550 __iomem *)0xf40003f8;
+
+       udbg_putc = udbg_maple_real_putc;
+       udbg_getc = NULL;
+       udbg_getc_poll = NULL;
+}
+#endif /* CONFIG_PPC_MAPLE */
diff --git a/arch/ppc64/kernel/udbg_scc.c b/arch/ppc64/kernel/udbg_scc.c
new file mode 100644 (file)
index 0000000..c47fd6c
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ * udbg for for zilog scc ports as found on Apple PowerMacs
+ *
+ * Copyright (C) 2001-2005 PPC 64 Team, IBM Corp
+ *
+ *      This program is free software; you can redistribute it and/or
+ *      modify it under the terms of the GNU General Public License
+ *      as published by the Free Software Foundation; either version
+ *      2 of the License, or (at your option) any later version.
+ */
+#include <linux/config.h>
+#include <linux/types.h>
+#include <asm/udbg.h>
+#include <asm/processor.h>
+#include <asm/naca.h>
+#include <asm/io.h>
+#include <asm/prom.h>
+#include <asm/pmac_feature.h>
+
+extern u8 real_readb(volatile u8 __iomem  *addr);
+extern void real_writeb(u8 data, volatile u8 __iomem *addr);
+
+#define        SCC_TXRDY       4
+#define SCC_RXRDY      1
+
+static volatile u8 __iomem *sccc;
+static volatile u8 __iomem *sccd;
+
+static void udbg_scc_putc(unsigned char c)
+{
+       if (sccc) {
+               while ((in_8(sccc) & SCC_TXRDY) == 0)
+                       ;
+               out_8(sccd,  c);
+               if (c == '\n')
+                       udbg_scc_putc('\r');
+       }
+}
+
+static int udbg_scc_getc_poll(void)
+{
+       if (sccc) {
+               if ((in_8(sccc) & SCC_RXRDY) != 0)
+                       return in_8(sccd);
+               else
+                       return -1;
+       }
+       return -1;
+}
+
+static unsigned char udbg_scc_getc(void)
+{
+       if (sccc) {
+               while ((in_8(sccc) & SCC_RXRDY) == 0)
+                       ;
+               return in_8(sccd);
+       }
+       return 0;
+}
+
+static unsigned char scc_inittab[] = {
+    13, 0,             /* set baud rate divisor */
+    12, 0,
+    14, 1,             /* baud rate gen enable, src=rtxc */
+    11, 0x50,          /* clocks = br gen */
+    5,  0xea,          /* tx 8 bits, assert DTR & RTS */
+    4,  0x46,          /* x16 clock, 1 stop */
+    3,  0xc1,          /* rx enable, 8 bits */
+};
+
+void udbg_init_scc(struct device_node *np)
+{
+       u32 *reg;
+       unsigned long addr;
+       int i, x;
+
+       if (np == NULL)
+               np = of_find_node_by_name(NULL, "escc");
+       if (np == NULL || np->parent == NULL)
+               return;
+
+       udbg_printf("found SCC...\n");
+       /* Get address within mac-io ASIC */
+       reg = (u32 *)get_property(np, "reg", NULL);
+       if (reg == NULL)
+               return;
+       addr = reg[0];
+       udbg_printf("local addr: %lx\n", addr);
+       /* Get address of mac-io PCI itself */
+       reg = (u32 *)get_property(np->parent, "assigned-addresses", NULL);
+       if (reg == NULL)
+               return;
+       addr += reg[2];
+       udbg_printf("final addr: %lx\n", addr);
+
+       /* Setup for 57600 8N1 */
+       addr += 0x20;
+       sccc = (volatile u8 * __iomem) ioremap(addr & PAGE_MASK, PAGE_SIZE) ;
+       sccc += addr & ~PAGE_MASK;
+       sccd = sccc + 0x10;
+
+       udbg_printf("ioremap result sccc: %p\n", sccc);
+       mb();
+
+       for (i = 20000; i != 0; --i)
+               x = in_8(sccc);
+       out_8(sccc, 0x09);              /* reset A or B side */
+       out_8(sccc, 0xc0);
+       for (i = 0; i < sizeof(scc_inittab); ++i)
+               out_8(sccc, scc_inittab[i]);
+
+       udbg_putc = udbg_scc_putc;
+       udbg_getc = udbg_scc_getc;
+       udbg_getc_poll = udbg_scc_getc_poll;
+
+       udbg_puts("Hello World !\n");
+}
+
+static void udbg_real_scc_putc(unsigned char c)
+{
+       while ((real_readb(sccc) & SCC_TXRDY) == 0)
+               ;
+       real_writeb(c, sccd);
+       if (c == '\n')
+               udbg_real_scc_putc('\r');
+}
+
+void udbg_init_pmac_realmode(void)
+{
+       sccc = (volatile u8 __iomem *)0x80013020ul;
+       sccd = (volatile u8 __iomem *)0x80013030ul;
+
+       udbg_putc = udbg_real_scc_putc;
+       udbg_getc = NULL;
+       udbg_getc_poll = NULL;
+}
index e7833c80eb6824dc93abcfb3ff73dba56d53ac9d..338771ec70d7622775190417f69085496ac2e209 100644 (file)
@@ -144,7 +144,8 @@ static void flush_low_segments(void *parm)
        for (i = 0; i < NUM_LOW_AREAS; i++) {
                if (! (areas & (1U << i)))
                        continue;
-               asm volatile("slbie %0" : : "r" (i << SID_SHIFT));
+               asm volatile("slbie %0"
+                            : : "r" ((i << SID_SHIFT) | SLBIE_C));
        }
 
        asm volatile("isync" : : : "memory");
@@ -164,7 +165,8 @@ static void flush_high_segments(void *parm)
                        continue;
                for (j = 0; j < (1UL << (HTLB_AREA_SHIFT-SID_SHIFT)); j++)
                        asm volatile("slbie %0"
-                                    :: "r" ((i << HTLB_AREA_SHIFT) + (j << SID_SHIFT)));
+                                    :: "r" (((i << HTLB_AREA_SHIFT)
+                                            + (j << SID_SHIFT)) | SLBIE_C));
        }
 
        asm volatile("isync" : : : "memory");
index c02dc9809ca57a2a3299c2c5c83efe9a360583ea..a14ab87df49114dbc9d02566b5014d4e91d0b939 100644 (file)
@@ -392,6 +392,7 @@ void free_initmem(void)
 
        addr = (unsigned long)__init_begin;
        for (; addr < (unsigned long)__init_end; addr += PAGE_SIZE) {
+               memset((void *)addr, 0xcc, PAGE_SIZE);
                ClearPageReserved(virt_to_page(addr));
                set_page_count(virt_to_page(addr), 1);
                free_page(addr);
@@ -552,27 +553,18 @@ void __init do_init_bootmem(void)
        /* Add all physical memory to the bootmem map, mark each area
         * present.
         */
-       for (i=0; i < lmb.memory.cnt; i++) {
-               unsigned long base, size;
-               unsigned long start_pfn, end_pfn;
-
-               base = lmb.memory.region[i].base;
-               size = lmb.memory.region[i].size;
-
-               start_pfn = base >> PAGE_SHIFT;
-               end_pfn = start_pfn + (size >> PAGE_SHIFT);
-               memory_present(0, start_pfn, end_pfn);
-
-               free_bootmem(base, size);
-       }
+       for (i=0; i < lmb.memory.cnt; i++)
+               free_bootmem(lmb_start_pfn(&lmb.memory, i),
+                            lmb_size_bytes(&lmb.memory, i));
 
        /* reserve the sections we're already using */
-       for (i=0; i < lmb.reserved.cnt; i++) {
-               unsigned long base = lmb.reserved.region[i].base;
-               unsigned long size = lmb.reserved.region[i].size;
+       for (i=0; i < lmb.reserved.cnt; i++)
+               reserve_bootmem(lmb_start_pfn(&lmb.reserved, i),
+                               lmb_size_bytes(&lmb.reserved, i));
 
-               reserve_bootmem(base, size);
-       }
+       for (i=0; i < lmb.memory.cnt; i++)
+               memory_present(0, lmb_start_pfn(&lmb.memory, i),
+                              lmb_end_pfn(&lmb.memory, i));
 }
 
 /*
index c3116f0d788c359969fcd120eda6eb461451faad..cb864b8f27505abee687702fca4833dbf9d6016b 100644 (file)
@@ -440,8 +440,6 @@ new_range:
                for (i = start ; i < (start+size); i += MEMORY_INCREMENT)
                        numa_memory_lookup_table[i >> MEMORY_INCREMENT_SHIFT] =
                                numa_domain;
-               memory_present(numa_domain, start >> PAGE_SHIFT,
-                                               (start + size) >> PAGE_SHIFT);
 
                if (--ranges)
                        goto new_range;
@@ -483,7 +481,6 @@ static void __init setup_nonnuma(void)
 
        for (i = 0 ; i < top_of_ram; i += MEMORY_INCREMENT)
                numa_memory_lookup_table[i >> MEMORY_INCREMENT_SHIFT] = 0;
-       memory_present(0, 0, init_node_data[0].node_end_pfn);
 }
 
 static void __init dump_numa_topology(void)
@@ -695,6 +692,46 @@ new_range:
                                                     size);
                        }
                }
+               /*
+                * This loop may look famaliar, but we have to do it again
+                * after marking our reserved memory to mark memory present
+                * for sparsemem.
+                */
+               addr_cells = get_mem_addr_cells();
+               size_cells = get_mem_size_cells();
+               memory = NULL;
+               while ((memory = of_find_node_by_type(memory, "memory")) != NULL) {
+                       unsigned long mem_start, mem_size;
+                       int numa_domain, ranges;
+                       unsigned int *memcell_buf;
+                       unsigned int len;
+
+                       memcell_buf = (unsigned int *)get_property(memory, "reg", &len);
+                       if (!memcell_buf || len <= 0)
+                               continue;
+
+                       ranges = memory->n_addrs;       /* ranges in cell */
+new_range2:
+                       mem_start = read_n_cells(addr_cells, &memcell_buf);
+                       mem_size = read_n_cells(size_cells, &memcell_buf);
+                       if (numa_enabled) {
+                               numa_domain = of_node_numa_domain(memory);
+                               if (numa_domain  >= MAX_NUMNODES)
+                                       numa_domain = 0;
+                       } else
+                               numa_domain =  0;
+
+                       if (numa_domain != nid)
+                               continue;
+
+                       mem_size = numa_enforce_memory_limit(mem_start, mem_size);
+                       memory_present(numa_domain, mem_start >> PAGE_SHIFT,
+                                      (mem_start + mem_size) >> PAGE_SHIFT);
+
+                       if (--ranges)           /* process all ranges in cell */
+                               goto new_range2;
+               }
+
        }
 }
 
index 244150a0bc18713ee49267b4f79521d2197722fd..0473953f6a37713cdf1cc8d18597511a299c102e 100644 (file)
@@ -87,8 +87,8 @@ void switch_slb(struct task_struct *tsk, struct mm_struct *mm)
                int i;
                asm volatile("isync" : : : "memory");
                for (i = 0; i < offset; i++) {
-                       esid_data = (unsigned long)get_paca()->slb_cache[i]
-                               << SID_SHIFT;
+                       esid_data = ((unsigned long)get_paca()->slb_cache[i]
+                               << SID_SHIFT) | SLBIE_C;
                        asm volatile("slbie %0" : : "r" (esid_data));
                }
                asm volatile("isync" : : : "memory");
index bab255889c58214c60214606d3577e9093bc24ca..698d6b9ed6d19566d83a2299715f72a512ef96bb 100644 (file)
@@ -97,25 +97,21 @@ BEGIN_FTR_SECTION
        lhz     r9,PACAHIGHHTLBAREAS(r13)
        srdi    r11,r3,(HTLB_AREA_SHIFT-SID_SHIFT)
        srd     r9,r9,r11
-       andi.   r9,r9,1
-       bne     5f
+       lhz     r11,PACALOWHTLBAREAS(r13)
+       srd     r11,r11,r3
+       or      r9,r9,r11
+END_FTR_SECTION_IFSET(CPU_FTR_16M_PAGE)
+#endif /* CONFIG_HUGETLB_PAGE */
 
        li      r11,SLB_VSID_USER
 
-       cmpldi  r3,16
-       bge     6f
-
-       lhz     r9,PACALOWHTLBAREAS(r13)
-       srd     r9,r9,r3
-       andi.   r9,r9,1
-
-       beq     6f
-
-5:     li      r11,SLB_VSID_USER|SLB_VSID_L
+#ifdef CONFIG_HUGETLB_PAGE
+BEGIN_FTR_SECTION
+       rldimi  r11,r9,8,55             /* shift masked bit into SLB_VSID_L */
 END_FTR_SECTION_IFSET(CPU_FTR_16M_PAGE)
 #endif /* CONFIG_HUGETLB_PAGE */
 
-6:     ld      r9,PACACONTEXTID(r13)
+       ld      r9,PACACONTEXTID(r13)
        rldimi  r3,r9,USER_ESID_BITS,0
 
 9:     /* r3 = protovsid, r11 = flags, r10 = esid_data, cr7 = <>KERNELBASE */
index 4acd1a424933d7c08afa1bf7908ef1ddc13104b1..e5f572710aa07bb2e912ec8c58f2a6cd2cac9132 100644 (file)
 #include <asm/ptrace.h>
 #include <asm/system.h>
 #include <asm/pmc.h>
+#include <asm/cputable.h>
+#include <asm/oprofile_impl.h>
 
-#include "op_impl.h"
-
-extern struct op_ppc64_model op_model_rs64;
-extern struct op_ppc64_model op_model_power4;
 static struct op_ppc64_model *model;
 
 static struct op_counter_config ctr[OP_MAX_COUNTER];
@@ -123,53 +121,13 @@ static int op_ppc64_create_files(struct super_block *sb, struct dentry *root)
 
 int __init oprofile_arch_init(struct oprofile_operations *ops)
 {
-       unsigned int pvr;
-
-       pvr = mfspr(SPRN_PVR);
-
-       switch (PVR_VER(pvr)) {
-               case PV_630:
-               case PV_630p:
-                       model = &op_model_rs64;
-                       model->num_counters = 8;
-                       ops->cpu_type = "ppc64/power3";
-                       break;
-
-               case PV_NORTHSTAR:
-               case PV_PULSAR:
-               case PV_ICESTAR:
-               case PV_SSTAR:
-                       model = &op_model_rs64;
-                       model->num_counters = 8;
-                       ops->cpu_type = "ppc64/rs64";
-                       break;
-
-               case PV_POWER4:
-               case PV_POWER4p:
-                       model = &op_model_power4;
-                       model->num_counters = 8;
-                       ops->cpu_type = "ppc64/power4";
-                       break;
-
-               case PV_970:
-               case PV_970FX:
-               case PV_970MP:
-                       model = &op_model_power4;
-                       model->num_counters = 8;
-                       ops->cpu_type = "ppc64/970";
-                       break;
-
-               case PV_POWER5:
-               case PV_POWER5p:
-                       model = &op_model_power4;
-                       model->num_counters = 6;
-                       ops->cpu_type = "ppc64/power5";
-                       break;
-
-               default:
-                       return -ENODEV;
-       }
+       if (!cur_cpu_spec->oprofile_model || !cur_cpu_spec->oprofile_cpu_type)
+               return -ENODEV;
+
+       model = cur_cpu_spec->oprofile_model;
+       model->num_counters = cur_cpu_spec->num_pmcs;
 
+       ops->cpu_type = cur_cpu_spec->oprofile_cpu_type;
        ops->create_files = op_ppc64_create_files;
        ops->setup = op_ppc64_setup;
        ops->shutdown = op_ppc64_shutdown;
index 3d103d66870dd55d285ba5329b658241c948c577..32b2bb5625fe3a4f055e445ab1f4619b148f4844 100644 (file)
 #include <asm/cputable.h>
 #include <asm/systemcfg.h>
 #include <asm/rtas.h>
+#include <asm/oprofile_impl.h>
 
 #define dbg(args...)
 
-#include "op_impl.h"
-
 static unsigned long reset_value[OP_MAX_COUNTER];
 
-static int num_counters;
 static int oprofile_running;
 static int mmcra_has_sihv;
 
@@ -45,8 +43,6 @@ static void power4_reg_setup(struct op_counter_config *ctr,
 {
        int i;
 
-       num_counters = num_ctrs;
-
        /*
         * SIHV / SIPR bits are only implemented on POWER4+ (GQ) and above.
         * However we disable it on all POWER4 until we verify it works
@@ -68,7 +64,7 @@ static void power4_reg_setup(struct op_counter_config *ctr,
 
        backtrace_spinlocks = sys->backtrace_spinlocks;
 
-       for (i = 0; i < num_counters; ++i)
+       for (i = 0; i < cur_cpu_spec->num_pmcs; ++i)
                reset_value[i] = 0x80000000UL - ctr[i].count;
 
        /* setup user and kernel profiling */
@@ -121,7 +117,7 @@ static void power4_start(struct op_counter_config *ctr)
        /* set the PMM bit (see comment below) */
        mtmsrd(mfmsr() | MSR_PMM);
 
-       for (i = 0; i < num_counters; ++i) {
+       for (i = 0; i < cur_cpu_spec->num_pmcs; ++i) {
                if (ctr[i].enabled) {
                        ctr_write(i, reset_value[i]);
                } else {
@@ -272,7 +268,7 @@ static void power4_handle_interrupt(struct pt_regs *regs,
        /* set the PMM bit (see comment below) */
        mtmsrd(mfmsr() | MSR_PMM);
 
-       for (i = 0; i < num_counters; ++i) {
+       for (i = 0; i < cur_cpu_spec->num_pmcs; ++i) {
                val = ctr_read(i);
                if (val < 0) {
                        if (oprofile_running && ctr[i].enabled) {
index bcec506c266a8d171f0ecbbba52aeeffb85a3723..08c5b333f5c4bfc5a266f294df95fb80c98cd5f8 100644 (file)
 #include <asm/system.h>
 #include <asm/processor.h>
 #include <asm/cputable.h>
+#include <asm/oprofile_impl.h>
 
 #define dbg(args...)
 
-#include "op_impl.h"
-
 static void ctrl_write(unsigned int i, unsigned int val)
 {
        unsigned int tmp = 0;
index f86b584acd76d16793e55be30848319d3e7066de..e50c158191e169fb4a08c23ef04caa842089c91c 100644 (file)
@@ -61,7 +61,9 @@ xmon_read(void *handle, void *ptr, int nb)
 int
 xmon_read_poll(void)
 {
-       return udbg_getc_poll();
+       if (udbg_getc_poll)
+               return udbg_getc_poll();
+       return -1;
 }
  
 FILE *xmon_stdin;
index 960ba6029c3a00c0f77727519450b3591278a272..bc59282da7620408fd98aec3b8e3b643759e47e0 100644 (file)
@@ -62,7 +62,7 @@ typedef struct
 } debug_sprintf_entry_t;
 
 
-extern void tod_to_timeval(uint64_t todval, struct timeval *xtime);
+extern void tod_to_timeval(uint64_t todval, struct timespec *xtime);
 
 /* internal function prototyes */
 
@@ -374,9 +374,24 @@ debug_info_copy(debug_info_t* in, int mode)
 {
         int i,j;
         debug_info_t* rc;
+        unsigned long flags;
+
+       /* get a consistent copy of the debug areas */
+       do {
+               rc = debug_info_alloc(in->name, in->pages_per_area,
+                       in->nr_areas, in->buf_size, in->level, mode);
+               spin_lock_irqsave(&in->lock, flags);
+               if(!rc)
+                       goto out;
+               /* has something changed in the meantime ? */
+               if((rc->pages_per_area == in->pages_per_area) &&
+                  (rc->nr_areas == in->nr_areas)) {
+                       break;
+               }
+               spin_unlock_irqrestore(&in->lock, flags);
+               debug_info_free(rc);
+       } while (1);
 
-        rc = debug_info_alloc(in->name, in->pages_per_area, in->nr_areas,
-                               in->buf_size, in->level, mode);
         if(!rc || (mode == NO_AREAS))
                 goto out;
 
@@ -386,6 +401,7 @@ debug_info_copy(debug_info_t* in, int mode)
                }
         }
 out:
+        spin_unlock_irqrestore(&in->lock, flags);
         return rc;
 }
 
@@ -593,19 +609,15 @@ debug_open(struct inode *inode, struct file *file)
        debug_info_t *debug_info, *debug_info_snapshot;
 
        down(&debug_lock);
-
-       /* find debug log and view */
-       debug_info = debug_area_first;
-       while(debug_info != NULL){
-               for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
-                       if (!debug_info->views[i])
-                               continue;
-                       else if (debug_info->debugfs_entries[i] ==
-                                file->f_dentry) {
-                               goto found;     /* found view ! */
-                       }
+       debug_info = (struct debug_info*)file->f_dentry->d_inode->u.generic_ip;
+       /* find debug view */
+       for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
+               if (!debug_info->views[i])
+                       continue;
+               else if (debug_info->debugfs_entries[i] ==
+                        file->f_dentry) {
+                       goto found;     /* found view ! */
                }
-               debug_info = debug_info->next;
        }
        /* no entry found */
        rc = -EINVAL;
@@ -833,7 +845,7 @@ extern inline void
 debug_finish_entry(debug_info_t * id, debug_entry_t* active, int level,
                        int exception)
 {
-       STCK(active->id.stck);
+       active->id.stck = get_clock();
        active->id.fields.cpuid = smp_processor_id();
        active->caller = __builtin_return_address(0);
        active->id.fields.exception = exception;
@@ -1078,7 +1090,7 @@ debug_register_view(debug_info_t * id, struct debug_view *view)
        if (view->input_proc)
                mode |= S_IWUSR;
        pde = debugfs_create_file(view->name, mode, id->debugfs_root_entry,
-                               NULL, &debug_file_ops);
+                               id , &debug_file_ops);
        if (!pde){
                printk(KERN_WARNING "debug: debugfs_create_file() failed!"\
                        " Cannot register view %s/%s\n", id->name,view->name);
@@ -1432,7 +1444,7 @@ int
 debug_dflt_header_fn(debug_info_t * id, struct debug_view *view,
                         int area, debug_entry_t * entry, char *out_buf)
 {
-       struct timeval time_val;
+       struct timespec time_spec;
        unsigned long long time;
        char *except_str;
        unsigned long caller;
@@ -1443,7 +1455,7 @@ debug_dflt_header_fn(debug_info_t * id, struct debug_view *view,
        time = entry->id.stck;
        /* adjust todclock to 1970 */
        time -= 0x8126d60e46000000LL - (0x3c26700LL * 1000000 * 4096);
-       tod_to_timeval(time, &time_val);
+       tod_to_timeval(time, &time_spec);
 
        if (entry->id.fields.exception)
                except_str = "*";
@@ -1451,7 +1463,7 @@ debug_dflt_header_fn(debug_info_t * id, struct debug_view *view,
                except_str = "-";
        caller = ((unsigned long) entry->caller) & PSW_ADDR_INSN;
        rc += sprintf(out_buf, "%02i %011lu:%06lu %1u %1s %02i %p  ",
-                     area, time_val.tv_sec, time_val.tv_usec, level,
+                     area, time_spec.tv_sec, time_spec.tv_nsec / 1000, level,
                      except_str, entry->id.fields.cpuid, (void *) caller);
        return rc;
 }
index 1a271b16cb5ca30d31af64a74423959d73d1b72e..cbe7d6a2d02cdc36bf5ac511f41e4c16f60410fa 100644 (file)
@@ -138,14 +138,14 @@ STACK_SIZE  = 1 << STACK_SHIFT
        st      %r12,__SF_BACKCHAIN(%r15)       # clear back chain
        .endm
 
-       .macro  RESTORE_ALL sync
-       mvc     __LC_RETURN_PSW(8),SP_PSW(%r15) # move user PSW to lowcore
+       .macro  RESTORE_ALL psworg,sync
+       mvc     \psworg(8),SP_PSW(%r15) # move user PSW to lowcore
        .if !\sync
-       ni      __LC_RETURN_PSW+1,0xfd  # clear wait state bit
+       ni      \psworg+1,0xfd          # clear wait state bit
        .endif
        lm      %r0,%r15,SP_R0(%r15)    # load gprs 0-15 of user
        STORE_TIMER __LC_EXIT_TIMER
-       lpsw    __LC_RETURN_PSW         # back to caller
+       lpsw    \psworg                 # back to caller
        .endm
 
 /*
@@ -235,7 +235,7 @@ sysc_return:
        tm      __TI_flags+3(%r9),_TIF_WORK_SVC
        bnz     BASED(sysc_work)  # there is work to do (signals etc.)
 sysc_leave:
-        RESTORE_ALL 1
+        RESTORE_ALL __LC_RETURN_PSW,1
 
 #
 # recheck if there is more work to do
@@ -312,8 +312,6 @@ sysc_singlestep:
        la      %r14,BASED(sysc_return) # load adr. of system return
        br      %r1                     # branch to do_single_step
 
-__critical_end:
-
 #
 # call trace before and after sys_call
 #
@@ -571,7 +569,8 @@ io_return:
        tm      __TI_flags+3(%r9),_TIF_WORK_INT
        bnz     BASED(io_work)         # there is work to do (signals etc.)
 io_leave:
-        RESTORE_ALL 0
+        RESTORE_ALL __LC_RETURN_PSW,0
+io_done:
 
 #ifdef CONFIG_PREEMPT
 io_preempt:
@@ -621,7 +620,7 @@ io_work_loop:
 #
 io_mcck_pending:
        l       %r1,BASED(.Ls390_handle_mcck)
-       l       %r14,BASED(io_work_loop)
+       la      %r14,BASED(io_work_loop)
        br      %r1                    # TIF bit will be cleared by handler
 
 #
@@ -674,6 +673,8 @@ ext_no_vtime:
        basr    %r14,%r1
        b       BASED(io_return)
 
+__critical_end:
+
 /*
  * Machine check handler routines
  */
@@ -681,6 +682,7 @@ ext_no_vtime:
         .globl mcck_int_handler
 mcck_int_handler:
        spt     __LC_CPU_TIMER_SAVE_AREA        # revalidate cpu timer
+       mvc     __LC_ASYNC_ENTER_TIMER(8),__LC_CPU_TIMER_SAVE_AREA
        lm      %r0,%r15,__LC_GPREGS_SAVE_AREA  # revalidate gprs
        SAVE_ALL_BASE __LC_SAVE_AREA+32
        la      %r12,__LC_MCK_OLD_PSW
@@ -693,17 +695,8 @@ mcck_int_handler:
        mvc     __LC_ASYNC_ENTER_TIMER(8),__LC_LAST_UPDATE_TIMER
        mvc     __LC_SYNC_ENTER_TIMER(8),__LC_LAST_UPDATE_TIMER
        mvc     __LC_EXIT_TIMER(8),__LC_LAST_UPDATE_TIMER
-0:     tm      __LC_MCCK_CODE+2,0x08   # mwp of old psw valid?
-       bno     BASED(mcck_no_vtime)    # no -> skip cleanup critical
-       tm      __LC_MCK_OLD_PSW+1,0x01 # interrupting from user ?
-       bz      BASED(mcck_no_vtime)
-       UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
-       UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
-       mvc     __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
-mcck_no_vtime:
 #endif
-0:
-       tm      __LC_MCCK_CODE+2,0x09   # mwp + ia of old psw valid?
+0:     tm      __LC_MCCK_CODE+2,0x09   # mwp + ia of old psw valid?
        bno     BASED(mcck_int_main)    # no -> skip cleanup critical
        tm      __LC_MCK_OLD_PSW+1,0x01 # test problem state bit
        bnz     BASED(mcck_int_main)    # from user -> load async stack
@@ -720,6 +713,16 @@ mcck_int_main:
        be      BASED(0f)
        l       %r15,__LC_PANIC_STACK   # load panic stack
 0:     CREATE_STACK_FRAME __LC_MCK_OLD_PSW,__LC_SAVE_AREA+32
+#ifdef CONFIG_VIRT_CPU_ACCOUNTING
+       tm      __LC_MCCK_CODE+2,0x08   # mwp of old psw valid?
+       bno     BASED(mcck_no_vtime)    # no -> skip cleanup critical
+       tm      __LC_MCK_OLD_PSW+1,0x01 # interrupting from user ?
+       bz      BASED(mcck_no_vtime)
+       UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
+       UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
+       mvc     __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
+mcck_no_vtime:
+#endif
        l       %r9,__LC_THREAD_INFO    # load pointer to thread_info struct
        la      %r2,SP_PTREGS(%r15)     # load pt_regs
        l       %r1,BASED(.Ls390_mcck)
@@ -737,7 +740,7 @@ mcck_int_main:
        l       %r1,BASED(.Ls390_handle_mcck)
        basr    %r14,%r1                # call machine check handler
 mcck_return:
-        RESTORE_ALL 0
+        RESTORE_ALL __LC_RETURN_MCCK_PSW,0
 
 #ifdef CONFIG_SMP
 /*
@@ -803,6 +806,10 @@ cleanup_table_sysc_leave:
        .long   sysc_leave + 0x80000000, sysc_work_loop + 0x80000000
 cleanup_table_sysc_work_loop:
        .long   sysc_work_loop + 0x80000000, sysc_reschedule + 0x80000000
+cleanup_table_io_leave:
+       .long   io_leave + 0x80000000, io_done + 0x80000000
+cleanup_table_io_work_loop:
+       .long   io_work_loop + 0x80000000, io_mcck_pending + 0x80000000
 
 cleanup_critical:
        clc     4(4,%r12),BASED(cleanup_table_system_call)
@@ -824,11 +831,27 @@ cleanup_critical:
        bl      BASED(0f)
        clc     4(4,%r12),BASED(cleanup_table_sysc_work_loop+4)
        bl      BASED(cleanup_sysc_return)
+0:
+       clc     4(4,%r12),BASED(cleanup_table_io_leave)
+       bl      BASED(0f)
+       clc     4(4,%r12),BASED(cleanup_table_io_leave+4)
+       bl      BASED(cleanup_io_leave)
+0:
+       clc     4(4,%r12),BASED(cleanup_table_io_work_loop)
+       bl      BASED(0f)
+       clc     4(4,%r12),BASED(cleanup_table_io_work_loop+4)
+       bl      BASED(cleanup_io_return)
 0:
        br      %r14
 
 cleanup_system_call:
        mvc     __LC_RETURN_PSW(8),0(%r12)
+       c       %r12,BASED(.Lmck_old_psw)
+       be      BASED(0f)
+       la      %r12,__LC_SAVE_AREA+16
+       b       BASED(1f)
+0:     la      %r12,__LC_SAVE_AREA+32
+1:
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
        clc     __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+4)
        bh      BASED(0f)
@@ -838,11 +861,13 @@ cleanup_system_call:
 #endif
        clc     __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn)
        bh      BASED(0f)
-       mvc     __LC_SAVE_AREA(16),__LC_SAVE_AREA+16
-0:     st      %r13,__LC_SAVE_AREA+20
+       mvc     __LC_SAVE_AREA(16),0(%r12)
+0:     st      %r13,4(%r12)
+       st      %r12,__LC_SAVE_AREA+48  # argh
        SAVE_ALL __LC_SVC_OLD_PSW,__LC_SAVE_AREA,1
        CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
-       st      %r15,__LC_SAVE_AREA+28
+       l       %r12,__LC_SAVE_AREA+48  # argh
+       st      %r15,12(%r12)
        lh      %r7,0x8a
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
 cleanup_vtime:
@@ -879,17 +904,21 @@ cleanup_sysc_return:
 
 cleanup_sysc_leave:
        clc     4(4,%r12),BASED(cleanup_sysc_leave_insn)
-       be      BASED(0f)
+       be      BASED(2f)
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
        mvc     __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
        clc     4(4,%r12),BASED(cleanup_sysc_leave_insn+4)
-       be      BASED(0f)
+       be      BASED(2f)
 #endif
        mvc     __LC_RETURN_PSW(8),SP_PSW(%r15)
-       mvc     __LC_SAVE_AREA+16(16),SP_R12(%r15)
-       lm      %r0,%r11,SP_R0(%r15)
+       c       %r12,BASED(.Lmck_old_psw)
+       bne     BASED(0f)
+       mvc     __LC_SAVE_AREA+32(16),SP_R12(%r15)
+       b       BASED(1f)
+0:     mvc     __LC_SAVE_AREA+16(16),SP_R12(%r15)
+1:     lm      %r0,%r11,SP_R0(%r15)
        l       %r15,SP_R15(%r15)
-0:     la      %r12,__LC_RETURN_PSW
+2:     la      %r12,__LC_RETURN_PSW
        br      %r14
 cleanup_sysc_leave_insn:
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
@@ -897,6 +926,36 @@ cleanup_sysc_leave_insn:
 #endif
        .long   sysc_leave + 10 + 0x80000000
 
+cleanup_io_return:
+       mvc     __LC_RETURN_PSW(4),0(%r12)
+       mvc     __LC_RETURN_PSW+4(4),BASED(cleanup_table_io_work_loop)
+       la      %r12,__LC_RETURN_PSW
+       br      %r14
+
+cleanup_io_leave:
+       clc     4(4,%r12),BASED(cleanup_io_leave_insn)
+       be      BASED(2f)
+#ifdef CONFIG_VIRT_CPU_ACCOUNTING
+       mvc     __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
+       clc     4(4,%r12),BASED(cleanup_io_leave_insn+4)
+       be      BASED(2f)
+#endif
+       mvc     __LC_RETURN_PSW(8),SP_PSW(%r15)
+       c       %r12,BASED(.Lmck_old_psw)
+       bne     BASED(0f)
+       mvc     __LC_SAVE_AREA+32(16),SP_R12(%r15)
+       b       BASED(1f)
+0:     mvc     __LC_SAVE_AREA+16(16),SP_R12(%r15)
+1:     lm      %r0,%r11,SP_R0(%r15)
+       l       %r15,SP_R15(%r15)
+2:     la      %r12,__LC_RETURN_PSW
+       br      %r14
+cleanup_io_leave_insn:
+#ifdef CONFIG_VIRT_CPU_ACCOUNTING
+       .long   io_leave + 18 + 0x80000000
+#endif
+       .long   io_leave + 14 + 0x80000000
+
 /*
  * Integer constants
  */
@@ -918,6 +977,7 @@ cleanup_sysc_leave_insn:
 .Ls390_mcck:   .long  s390_do_machine_check
 .Ls390_handle_mcck:
               .long  s390_handle_mcck
+.Lmck_old_psw: .long  __LC_MCK_OLD_PSW
 .Ldo_IRQ:      .long  do_IRQ
 .Ldo_extint:   .long  do_extint
 .Ldo_signal:   .long  do_signal
index d9f22915008cf3465ecfdbde29ce9648f7d9d9cd..fb77b72ab2627a3ae3f7988f037bbfc230029e62 100644 (file)
@@ -131,14 +131,14 @@ _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_MCCK_PENDING)
        stg     %r12,__SF_BACKCHAIN(%r15)
         .endm
 
-       .macro  RESTORE_ALL sync
-       mvc     __LC_RETURN_PSW(16),SP_PSW(%r15) # move user PSW to lowcore
+       .macro  RESTORE_ALL psworg,sync
+       mvc     \psworg(16),SP_PSW(%r15) # move user PSW to lowcore
        .if !\sync
-       ni      __LC_RETURN_PSW+1,0xfd  # clear wait state bit
+       ni      \psworg+1,0xfd          # clear wait state bit
        .endif
        lmg     %r0,%r15,SP_R0(%r15)    # load gprs 0-15 of user
        STORE_TIMER __LC_EXIT_TIMER
-       lpswe   __LC_RETURN_PSW         # back to caller
+       lpswe   \psworg                 # back to caller
        .endm
 
 /*
@@ -214,8 +214,8 @@ sysc_nr_ok:
 sysc_do_restart:
        larl    %r10,sys_call_table
 #ifdef CONFIG_S390_SUPPORT
-        tm      SP_PSW+3(%r15),0x01  # are we running in 31 bit mode ?
-        jo      sysc_noemu
+       tm      __TI_flags+5(%r9),(_TIF_31BIT>>16)  # running in 31 bit mode ?
+       jno     sysc_noemu
        larl    %r10,sys_call_table_emu  # use 31 bit emulation system calls
 sysc_noemu:
 #endif
@@ -233,7 +233,7 @@ sysc_return:
        tm      __TI_flags+7(%r9),_TIF_WORK_SVC
        jnz     sysc_work         # there is work to do (signals etc.)
 sysc_leave:
-        RESTORE_ALL 1
+        RESTORE_ALL __LC_RETURN_PSW,1
 
 #
 # recheck if there is more work to do
@@ -308,8 +308,6 @@ sysc_singlestep:
        jg      do_single_step          # branch to do_sigtrap
 
 
-__critical_end:
-
 #
 # call syscall_trace before and after system call
 # special linkage: %r12 contains the return address for trace_svc
@@ -612,7 +610,8 @@ io_return:
        tm      __TI_flags+7(%r9),_TIF_WORK_INT
        jnz     io_work                # there is work to do (signals etc.)
 io_leave:
-        RESTORE_ALL 0
+        RESTORE_ALL __LC_RETURN_PSW,0
+io_done:
 
 #ifdef CONFIG_PREEMPT
 io_preempt:
@@ -711,6 +710,8 @@ ext_no_vtime:
        brasl   %r14,do_extint
        j       io_return
 
+__critical_end:
+
 /*
  * Machine check handler routines
  */
@@ -718,6 +719,7 @@ ext_no_vtime:
 mcck_int_handler:
        la      %r1,4095                # revalidate r1
        spt     __LC_CPU_TIMER_SAVE_AREA-4095(%r1)      # revalidate cpu timer
+       mvc     __LC_ASYNC_ENTER_TIMER(8),__LC_CPU_TIMER_SAVE_AREA-4095(%r1)
        lmg     %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs
        SAVE_ALL_BASE __LC_SAVE_AREA+64
        la      %r12,__LC_MCK_OLD_PSW
@@ -730,17 +732,8 @@ mcck_int_handler:
        mvc     __LC_ASYNC_ENTER_TIMER(8),__LC_LAST_UPDATE_TIMER
        mvc     __LC_SYNC_ENTER_TIMER(8),__LC_LAST_UPDATE_TIMER
        mvc     __LC_EXIT_TIMER(8),__LC_LAST_UPDATE_TIMER
-0:     tm      __LC_MCCK_CODE+2,0x08   # mwp of old psw valid?
-       jno     mcck_no_vtime           # no -> no timer update
-       tm      __LC_MCK_OLD_PSW+1,0x01 # interrupting from user ?
-       jz      mcck_no_vtime
-       UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
-       UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
-       mvc     __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
-mcck_no_vtime:
 #endif
-0:
-       tm      __LC_MCCK_CODE+2,0x09   # mwp + ia of old psw valid?
+0:     tm      __LC_MCCK_CODE+2,0x09   # mwp + ia of old psw valid?
        jno     mcck_int_main           # no -> skip cleanup critical
        tm      __LC_MCK_OLD_PSW+1,0x01 # test problem state bit
        jnz     mcck_int_main           # from user -> load kernel stack
@@ -756,6 +749,16 @@ mcck_int_main:
        jz      0f
        lg      %r15,__LC_PANIC_STACK   # load panic stack
 0:     CREATE_STACK_FRAME __LC_MCK_OLD_PSW,__LC_SAVE_AREA+64
+#ifdef CONFIG_VIRT_CPU_ACCOUNTING
+       tm      __LC_MCCK_CODE+2,0x08   # mwp of old psw valid?
+       jno     mcck_no_vtime           # no -> no timer update
+       tm      __LC_MCK_OLD_PSW+1,0x01 # interrupting from user ?
+       jz      mcck_no_vtime
+       UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
+       UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
+       mvc     __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
+mcck_no_vtime:
+#endif
        lg      %r9,__LC_THREAD_INFO    # load pointer to thread_info struct
        la      %r2,SP_PTREGS(%r15)     # load pt_regs
        brasl   %r14,s390_do_machine_check
@@ -771,7 +774,7 @@ mcck_int_main:
        jno     mcck_return
        brasl   %r14,s390_handle_mcck
 mcck_return:
-        RESTORE_ALL 0
+        RESTORE_ALL __LC_RETURN_MCCK_PSW,0
 
 #ifdef CONFIG_SMP
 /*
@@ -833,6 +836,10 @@ cleanup_table_sysc_leave:
        .quad   sysc_leave, sysc_work_loop
 cleanup_table_sysc_work_loop:
        .quad   sysc_work_loop, sysc_reschedule
+cleanup_table_io_leave:
+       .quad   io_leave, io_done
+cleanup_table_io_work_loop:
+       .quad   io_work_loop, io_mcck_pending
 
 cleanup_critical:
        clc     8(8,%r12),BASED(cleanup_table_system_call)
@@ -854,11 +861,27 @@ cleanup_critical:
        jl      0f
        clc     8(8,%r12),BASED(cleanup_table_sysc_work_loop+8)
        jl      cleanup_sysc_return
+0:
+       clc     8(8,%r12),BASED(cleanup_table_io_leave)
+       jl      0f
+       clc     8(8,%r12),BASED(cleanup_table_io_leave+8)
+       jl      cleanup_io_leave
+0:
+       clc     8(8,%r12),BASED(cleanup_table_io_work_loop)
+       jl      0f
+       clc     8(8,%r12),BASED(cleanup_table_io_work_loop+8)
+       jl      cleanup_io_return
 0:
        br      %r14
 
 cleanup_system_call:
        mvc     __LC_RETURN_PSW(16),0(%r12)
+       cghi    %r12,__LC_MCK_OLD_PSW
+       je      0f
+       la      %r12,__LC_SAVE_AREA+32
+       j       1f
+0:     la      %r12,__LC_SAVE_AREA+64
+1:
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
        clc     __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+8)
        jh      0f
@@ -868,11 +891,13 @@ cleanup_system_call:
 #endif
        clc     __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn)
        jh      0f
-       mvc     __LC_SAVE_AREA(32),__LC_SAVE_AREA+32
-0:     stg     %r13,__LC_SAVE_AREA+40
+       mvc     __LC_SAVE_AREA(32),0(%r12)
+0:     stg     %r13,8(%r12)
+       stg     %r12,__LC_SAVE_AREA+96  # argh
        SAVE_ALL __LC_SVC_OLD_PSW,__LC_SAVE_AREA,1
        CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
-       stg     %r15,__LC_SAVE_AREA+56
+       lg      %r12,__LC_SAVE_AREA+96  # argh
+       stg     %r15,24(%r12)
        llgh    %r7,__LC_SVC_INT_CODE
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
 cleanup_vtime:
@@ -909,17 +934,21 @@ cleanup_sysc_return:
 
 cleanup_sysc_leave:
        clc     8(8,%r12),BASED(cleanup_sysc_leave_insn)
-       je      0f
+       je      2f
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
        mvc     __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
        clc     8(8,%r12),BASED(cleanup_sysc_leave_insn+8)
-       je      0f
+       je      2f
 #endif
        mvc     __LC_RETURN_PSW(16),SP_PSW(%r15)
-       mvc     __LC_SAVE_AREA+32(32),SP_R12(%r15)
-       lmg     %r0,%r11,SP_R0(%r15)
+       cghi    %r12,__LC_MCK_OLD_PSW
+       jne     0f
+       mvc     __LC_SAVE_AREA+64(32),SP_R12(%r15)
+       j       1f
+0:     mvc     __LC_SAVE_AREA+32(32),SP_R12(%r15)
+1:     lmg     %r0,%r11,SP_R0(%r15)
        lg      %r15,SP_R15(%r15)
-0:     la      %r12,__LC_RETURN_PSW
+2:     la      %r12,__LC_RETURN_PSW
        br      %r14
 cleanup_sysc_leave_insn:
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
@@ -927,6 +956,36 @@ cleanup_sysc_leave_insn:
 #endif
        .quad   sysc_leave + 12
 
+cleanup_io_return:
+       mvc     __LC_RETURN_PSW(8),0(%r12)
+       mvc     __LC_RETURN_PSW+8(8),BASED(cleanup_table_io_work_loop)
+       la      %r12,__LC_RETURN_PSW
+       br      %r14
+
+cleanup_io_leave:
+       clc     8(8,%r12),BASED(cleanup_io_leave_insn)
+       je      2f
+#ifdef CONFIG_VIRT_CPU_ACCOUNTING
+       mvc     __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
+       clc     8(8,%r12),BASED(cleanup_io_leave_insn+8)
+       je      2f
+#endif
+       mvc     __LC_RETURN_PSW(16),SP_PSW(%r15)
+       cghi    %r12,__LC_MCK_OLD_PSW
+       jne     0f
+       mvc     __LC_SAVE_AREA+64(32),SP_R12(%r15)
+       j       1f
+0:     mvc     __LC_SAVE_AREA+32(32),SP_R12(%r15)
+1:     lmg     %r0,%r11,SP_R0(%r15)
+       lg      %r15,SP_R15(%r15)
+2:     la      %r12,__LC_RETURN_PSW
+       br      %r14
+cleanup_io_leave_insn:
+#ifdef CONFIG_VIRT_CPU_ACCOUNTING
+       .quad   io_leave + 20
+#endif
+       .quad   io_leave + 16
+
 /*
  * Integer constants
  */
index 75fde949d12570a68d1a5aaa228fc946fccc0c4b..856a971759b1a2d0776c347914d1dc3015885659 100644 (file)
@@ -563,12 +563,14 @@ pfault_interrupt(struct pt_regs *regs, __u16 error_code)
                         * interrupt. pfault_wait is valid. Set pfault_wait
                         * back to zero and wake up the process. This can
                         * safely be done because the task is still sleeping
-                        * and can't procude new pfaults. */
+                        * and can't produce new pfaults. */
                        tsk->thread.pfault_wait = 0;
                        wake_up_process(tsk);
+                       put_task_struct(tsk);
                }
        } else {
                /* signal bit not set -> a real page is missing. */
+               get_task_struct(tsk);
                set_task_state(tsk, TASK_UNINTERRUPTIBLE);
                if (xchg(&tsk->thread.pfault_wait, 1) != 0) {
                        /* Completion interrupt was faster than the initial
@@ -578,6 +580,7 @@ pfault_interrupt(struct pt_regs *regs, __u16 error_code)
                         * mode and can't produce new pfaults. */
                        tsk->thread.pfault_wait = 0;
                        set_task_state(tsk, TASK_RUNNING);
+                       put_task_struct(tsk);
                } else
                        set_tsk_need_resched(tsk);
        }
index 4c3e5334adb3208361123062aabf5abe8c7fd745..fb35b45dc130074b3fd6d0170c58588f17885f1e 100644 (file)
@@ -29,10 +29,6 @@ config GENERIC_CALIBRATE_DELAY
        bool
        default y
 
-config LOG_BUF_SHIFT
-       int
-       default 14
-
 config RWSEM_XCHGADD_ALGORITHM
        bool
 
index 8faa8dc4de435cd7850170a5ea266f19cd00ac6b..5d974a2b735a9ac354295ec6e4870cfb85049e12 100644 (file)
@@ -175,7 +175,6 @@ EXPORT_SYMBOL(set_auxio);
 EXPORT_SYMBOL(get_auxio);
 #endif
 EXPORT_SYMBOL(request_fast_irq);
-EXPORT_SYMBOL(io_remap_page_range);
 EXPORT_SYMBOL(io_remap_pfn_range);
   /* P3: iounit_xxx may be needed, sun4d users */
 /* EXPORT_SYMBOL(iounit_map_dma_init); */
index db27eee3bda19511b49f7b83c0fd472082319d46..20ccb957fb7795118b5f06b21d7c5649423e72b4 100644 (file)
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
 
-static inline void forget_pte(pte_t page)
-{
-#if 0 /* old 2.4 code */
-       if (pte_none(page))
-               return;
-       if (pte_present(page)) {
-               unsigned long pfn = pte_pfn(page);
-               struct page *ptpage;
-               if (!pfn_valid(pfn))
-                       return;
-               ptpage = pfn_to_page(pfn);
-               if (PageReserved(ptpage))
-                       return;
-               page_cache_release(ptpage);
-               return;
-       }
-       swap_free(pte_to_swp_entry(page));
-#else
-       if (!pte_none(page)) {
-               printk("forget_pte: old mapping existed!\n");
-               BUG();
-       }
-#endif
-}
-
 /* Remap IO memory, the same way as remap_pfn_range(), but use
  * the obio memory space.
  *
@@ -60,7 +35,6 @@ static inline void io_remap_pte_range(struct mm_struct *mm, pte_t * pte, unsigne
                pte_t oldpage = *pte;
                pte_clear(mm, address, pte);
                set_pte(pte, mk_pte_io(offset, prot, space));
-               forget_pte(oldpage);
                address += PAGE_SIZE;
                offset += PAGE_SIZE;
                pte++;
@@ -88,37 +62,6 @@ static inline int io_remap_pmd_range(struct mm_struct *mm, pmd_t * pmd, unsigned
        return 0;
 }
 
-int io_remap_page_range(struct vm_area_struct *vma, unsigned long from, unsigned long offset, unsigned long size, pgprot_t prot, int space)
-{
-       int error = 0;
-       pgd_t * dir;
-       unsigned long beg = from;
-       unsigned long end = from + size;
-       struct mm_struct *mm = vma->vm_mm;
-
-       prot = __pgprot(pg_iobits);
-       offset -= from;
-       dir = pgd_offset(mm, from);
-       flush_cache_range(vma, beg, end);
-
-       spin_lock(&mm->page_table_lock);
-       while (from < end) {
-               pmd_t *pmd = pmd_alloc(current->mm, dir, from);
-               error = -ENOMEM;
-               if (!pmd)
-                       break;
-               error = io_remap_pmd_range(mm, pmd, from, end - from, offset + from, prot, space);
-               if (error)
-                       break;
-               from = (from + PGDIR_SIZE) & PGDIR_MASK;
-               dir++;
-       }
-       spin_unlock(&mm->page_table_lock);
-
-       flush_tlb_range(vma, beg, end);
-       return error;
-}
-
 int io_remap_pfn_range(struct vm_area_struct *vma, unsigned long from,
                        unsigned long pfn, unsigned long size, pgprot_t prot)
 {
index 9afd28e2c4d510e5d2e6f3f3c312f40ba8e9c748..73ec6aec5ed5c60198f25876bd8e21f079ee3ab2 100644 (file)
@@ -5,6 +5,16 @@
 
 mainmenu "Linux/UltraSPARC Kernel Configuration"
 
+config SPARC64
+       bool
+       default y
+       help
+         SPARC is a family of RISC microprocessors designed and marketed by
+         Sun Microsystems, incorporated.  This port covers the newer 64-bit
+         UltraSPARC.  The UltraLinux project maintains both the SPARC32 and
+         SPARC64 ports; its web page is available at
+         <http://www.ultralinux.org/>.
+
 config 64BIT
        def_bool y
 
@@ -71,75 +81,6 @@ config SYSVIPC_COMPAT
 
 menu "General machine setup"
 
-config BBC_I2C
-       tristate "UltraSPARC-III bootbus i2c controller driver"
-       depends on PCI
-       help
-         The BBC devices on the UltraSPARC III have two I2C controllers.  The
-         first I2C controller connects mainly to configuration PROMs (NVRAM,
-         CPU configuration, DIMM types, etc.).  The second I2C controller
-         connects to environmental control devices such as fans and
-         temperature sensors.  The second controller also connects to the
-         smartcard reader, if present.  Say Y to enable support for these.
-
-config VT
-       bool "Virtual terminal" if EMBEDDED
-       select INPUT
-       default y
-       ---help---
-         If you say Y here, you will get support for terminal devices with
-         display and keyboard devices. These are called "virtual" because you
-         can run several virtual terminals (also called virtual consoles) on
-         one physical terminal. This is rather useful, for example one
-         virtual terminal can collect system messages and warnings, another
-         one can be used for a text-mode user session, and a third could run
-         an X session, all in parallel. Switching between virtual terminals
-         is done with certain key combinations, usually Alt-<function key>.
-
-         The setterm command ("man setterm") can be used to change the
-         properties (such as colors or beeping) of a virtual terminal. The
-         man page console_codes(4) ("man console_codes") contains the special
-         character sequences that can be used to change those properties
-         directly. The fonts used on virtual terminals can be changed with
-         the setfont ("man setfont") command and the key bindings are defined
-         with the loadkeys ("man loadkeys") command.
-
-         You need at least one virtual terminal device in order to make use
-         of your keyboard and monitor. Therefore, only people configuring an
-         embedded system would want to say N here in order to save some
-         memory; the only way to log into such a system is then via a serial
-         or network connection.
-
-         If unsure, say Y, or else you won't be able to do much with your new
-         shiny Linux system :-)
-
-config VT_CONSOLE
-       bool "Support for console on virtual terminal" if EMBEDDED
-       depends on VT
-       default y
-       ---help---
-         The system console is the device which receives all kernel messages
-         and warnings and which allows logins in single user mode. If you
-         answer Y here, a virtual terminal (the device used to interact with
-         a physical terminal) can be used as system console. This is the most
-         common mode of operations, so you should say Y here unless you want
-         the kernel messages be output only to a serial port (in which case
-         you should say Y to "Console on serial port", below).
-
-         If you do say Y here, by default the currently visible virtual
-         terminal (/dev/tty0) will be used as system console. You can change
-         that with a kernel command line option such as "console=tty3" which
-         would use the third virtual terminal as system console. (Try "man
-         bootparam" or see the documentation of your boot loader (lilo or
-         loadlin) about how to pass options to the kernel at boot time.)
-
-         If unsure, say Y.
-
-config HW_CONSOLE
-       bool
-       depends on VT
-       default y
-
 config SMP
        bool "Symmetric multi-processing support"
        ---help---
@@ -205,17 +146,6 @@ config US2E_FREQ
 
          If in doubt, say N.
 
-# Identify this as a Sparc64 build
-config SPARC64
-       bool
-       default y
-       help
-         SPARC is a family of RISC microprocessors designed and marketed by
-         Sun Microsystems, incorporated.  This port covers the newer 64-bit
-         UltraSPARC.  The UltraLinux project maintains both the SPARC32 and
-         SPARC64 ports; its web page is available at
-         <http://www.ultralinux.org/>.
-
 # Global things across all Sun machines.
 config RWSEM_GENERIC_SPINLOCK
        bool
@@ -246,6 +176,10 @@ config HUGETLB_PAGE_SIZE_64K
 
 endchoice
 
+endmenu
+
+source "mm/Kconfig"
+
 config GENERIC_ISA_DMA
        bool
        default y
@@ -344,33 +278,6 @@ config PCI_DOMAINS
        bool
        default PCI
 
-config RTC
-       tristate
-       depends on PCI
-       default y
-       ---help---
-         If you say Y here and create a character special file /dev/rtc with
-         major number 10 and minor number 135 using mknod ("man mknod"), you
-         will get access to the real time clock (or hardware clock) built
-         into your computer.
-
-         Every PC has such a clock built in. It can be used to generate
-         signals from as low as 1Hz up to 8192Hz, and can also be used
-         as a 24 hour alarm. It reports status information via the file
-         /proc/driver/rtc and its behaviour is set by various ioctls on
-         /dev/rtc.
-
-         If you run Linux on a multiprocessor machine and said Y to
-         "Symmetric Multi Processing" above, you should say Y here to read
-         and set the RTC in an SMP compatible fashion.
-
-         If you think you have a use for such a device (such as periodic data
-         sampling), then say Y here, and read <file:Documentation/rtc.txt>
-         for details.
-
-         To compile this driver as a module, choose M here: the
-         module will be called rtc.
-
 source "drivers/pci/Kconfig"
 
 config SUN_OPENPROMFS
@@ -414,6 +321,8 @@ config BINFMT_AOUT32
          If you want to run SunOS binaries (see SunOS binary emulation below)
          or other a.out binaries, say Y. If unsure, say N.
 
+menu "Executable file formats"
+
 source "fs/Kconfig.binfmt"
 
 config SUNOS_EMUL
@@ -436,74 +345,7 @@ config SOLARIS_EMUL
          To compile this code as a module, choose M here: the
          module will be called solaris.
 
-source "drivers/parport/Kconfig"
-
-config PRINTER
-       tristate "Parallel printer support"
-       depends on PARPORT
-       ---help---
-         If you intend to attach a printer to the parallel port of your Linux
-         box (as opposed to using a serial printer; if the connector at the
-         printer has 9 or 25 holes ["female"], then it's serial), say Y.
-         Also read the Printing-HOWTO, available from
-         <http://www.tldp.org/docs.html#howto>.
-
-         It is possible to share one parallel port among several devices
-         (e.g. printer and ZIP drive) and it is safe to compile the
-         corresponding drivers into the kernel.
-         To compile this driver as a module, choose M here and read
-         <file:Documentation/parport.txt>.  The module will be called lp.
-
-         If you have several parallel ports, you can specify which ports to
-         use with the "lp" kernel command line option.  (Try "man bootparam"
-         or see the documentation of your boot loader (lilo or loadlin) about
-         how to pass options to the kernel at boot time.)  The syntax of the
-         "lp" command line option can be found in <file:drivers/char/lp.c>.
-
-         If you have more than 8 printers, you need to increase the LP_NO
-         macro in lp.c and the PARPORT_MAX macro in parport.h.
-
-config PPDEV
-       tristate "Support for user-space parallel port device drivers"
-       depends on PARPORT
-       ---help---
-         Saying Y to this adds support for /dev/parport device nodes.  This
-         is needed for programs that want portable access to the parallel
-         port, for instance deviceid (which displays Plug-and-Play device
-         IDs).
-
-         This is the parallel port equivalent of SCSI generic support (sg).
-         It is safe to say N to this -- it is not needed for normal printing
-         or parallel port CD-ROM/disk support.
-
-         To compile this driver as a module, choose M here: the
-         module will be called ppdev.
-
-         If unsure, say N.
-
-config ENVCTRL
-       tristate "SUNW, envctrl support"
-       depends on PCI
-       help
-         Kernel support for temperature and fan monitoring on Sun SME
-         machines.
-
-         To compile this driver as a module, choose M here: the
-         module will be called envctrl.
-
-config DISPLAY7SEG
-       tristate "7-Segment Display support"
-       depends on PCI
-       ---help---
-         This is the driver for the 7-segment display and LED present on
-         Sun Microsystems CompactPCI models CP1400 and CP1500.
-
-         To compile this driver as a module, choose M here: the
-         module will be called display7seg.
-
-         If you do not have a CompactPCI model CP1400 or CP1500, or
-         another UltraSPARC-IIi-cEngine boardset with a 7-segment display,
-         you should say N to this option.
+endmenu
 
 config CMDLINE_BOOL
        bool "Default bootloader kernel arguments"
@@ -521,148 +363,16 @@ config CMDLINE
 
          NOTE: This option WILL override the PROM bootargs setting!
 
-source "mm/Kconfig"
-
-endmenu
-
 source "net/Kconfig"
 
-source "drivers/base/Kconfig"
-
-source "drivers/video/Kconfig"
-
-source "drivers/serial/Kconfig"
+source "drivers/Kconfig"
 
 source "drivers/sbus/char/Kconfig"
 
-source "drivers/mtd/Kconfig"
-
-source "drivers/block/Kconfig"
-
-source "drivers/ide/Kconfig"
-
-source "drivers/scsi/Kconfig"
-
 source "drivers/fc4/Kconfig"
 
-source "drivers/md/Kconfig"
-
-if PCI
-source "drivers/message/fusion/Kconfig"
-endif
-
-source "drivers/ieee1394/Kconfig"
-
-source "drivers/net/Kconfig"
-
-source "drivers/isdn/Kconfig"
-
-source "drivers/telephony/Kconfig"
-
-# This one must be before the filesystem configs. -DaveM
-
-menu "Unix98 PTY support"
-
-config UNIX98_PTYS
-       bool "Unix98 PTY support"
-       ---help---
-         A pseudo terminal (PTY) is a software device consisting of two
-         halves: a master and a slave. The slave device behaves identical to
-         a physical terminal; the master device is used by a process to
-         read data from and write data to the slave, thereby emulating a
-         terminal. Typical programs for the master side are telnet servers
-         and xterms.
-
-         Linux has traditionally used the BSD-like names /dev/ptyxx for
-         masters and /dev/ttyxx for slaves of pseudo terminals. This scheme
-         has a number of problems. The GNU C library glibc 2.1 and later,
-         however, supports the Unix98 naming standard: in order to acquire a
-         pseudo terminal, a process opens /dev/ptmx; the number of the pseudo
-         terminal is then made available to the process and the pseudo
-         terminal slave can be accessed as /dev/pts/<number>. What was
-         traditionally /dev/ttyp2 will then be /dev/pts/2, for example.
-
-         The entries in /dev/pts/ are created on the fly by a virtual
-         file system; therefore, if you say Y here you should say Y to
-         "/dev/pts file system for Unix98 PTYs" as well.
-
-         If you want to say Y here, you need to have the C library glibc 2.1
-         or later (equal to libc-6.1, check with "ls -l /lib/libc.so.*").
-         Read the instructions in <file:Documentation/Changes> pertaining to
-         pseudo terminals. It's safe to say N.
-
-config UNIX98_PTY_COUNT
-       int "Maximum number of Unix98 PTYs in use (0-2048)"
-       depends on UNIX98_PTYS
-       default "256"
-       help
-         The maximum number of Unix98 PTYs that can be used at any one time.
-         The default is 256, and should be enough for desktop systems. Server
-         machines which support incoming telnet/rlogin/ssh connections and/or
-         serve several X terminals may want to increase this: every incoming
-         connection and every xterm uses up one PTY.
-
-         When not in use, each additional set of 256 PTYs occupy
-         approximately 8 KB of kernel memory on 32-bit architectures.
-
-endmenu
-
-menu "XFree86 DRI support"
-
-config DRM
-       bool "Direct Rendering Manager (XFree86 DRI support)"
-       help
-         Kernel-level support for the Direct Rendering Infrastructure (DRI)
-         introduced in XFree86 4.0. If you say Y here, you need to select
-         the module that's right for your graphics card from the list below.
-         These modules provide support for synchronization, security, and
-         DMA transfers. Please see <http://dri.sourceforge.net/> for more
-         details.  You should also select and configure AGP
-         (/dev/agpgart) support.
-
-config DRM_FFB
-       tristate "Creator/Creator3D"
-       depends on DRM && BROKEN
-       help
-         Choose this option if you have one of Sun's Creator3D-based graphics
-         and frame buffer cards.  Product page at
-         <http://www.sun.com/desktop/products/Graphics/creator3d.html>.
-
-config DRM_TDFX
-       tristate "3dfx Banshee/Voodoo3+"
-       depends on DRM
-       help
-         Choose this option if you have a 3dfx Banshee or Voodoo3 (or later),
-         graphics card.  If M is selected, the module will be called tdfx.
-
-config DRM_R128
-       tristate "ATI Rage 128"
-       depends on DRM
-       help
-         Choose this option if you have an ATI Rage 128 graphics card.  If M
-         is selected, the module will be called r128.  AGP support for
-         this card is strongly suggested (unless you have a PCI version).
-
-endmenu
-
-source "drivers/input/Kconfig"
-
-source "drivers/i2c/Kconfig"
-
-source "drivers/hwmon/Kconfig"
-
 source "fs/Kconfig"
 
-source "drivers/media/Kconfig"
-
-source "sound/Kconfig"
-
-source "drivers/usb/Kconfig"
-
-source "drivers/infiniband/Kconfig"
-
-source "drivers/char/watchdog/Kconfig"
-
 source "arch/sparc64/oprofile/Kconfig"
 
 source "arch/sparc64/Kconfig.debug"
index cecdc0a7521f1d36fce506ab64e49ca41136d879..3e0badb820c5798996c296b913130cb7e5ac9d0a 100644 (file)
@@ -927,139 +927,6 @@ __spitfire_insn_access_exception:
        ba,pt           %xcc, rtrap
         clr            %l6
 
-       /* Capture I/D/E-cache state into per-cpu error scoreboard.
-        *
-        * %g1:         (TL>=0) ? 1 : 0
-        * %g2:         scratch
-        * %g3:         scratch
-        * %g4:         AFSR
-        * %g5:         AFAR
-        * %g6:         current thread ptr
-        * %g7:         scratch
-        */
-#define CHEETAH_LOG_ERROR                                              \
-       /* Put "TL1" software bit into AFSR. */                         \
-       and             %g1, 0x1, %g1;                                  \
-       sllx            %g1, 63, %g2;                                   \
-       or              %g4, %g2, %g4;                                  \
-       /* Get log entry pointer for this cpu at this trap level. */    \
-       BRANCH_IF_JALAPENO(g2,g3,50f)                                   \
-       ldxa            [%g0] ASI_SAFARI_CONFIG, %g2;                   \
-       srlx            %g2, 17, %g2;                                   \
-       ba,pt           %xcc, 60f;                                      \
-        and            %g2, 0x3ff, %g2;                                \
-50:    ldxa            [%g0] ASI_JBUS_CONFIG, %g2;                     \
-       srlx            %g2, 17, %g2;                                   \
-       and             %g2, 0x1f, %g2;                                 \
-60:    sllx            %g2, 9, %g2;                                    \
-       sethi           %hi(cheetah_error_log), %g3;                    \
-       ldx             [%g3 + %lo(cheetah_error_log)], %g3;            \
-       brz,pn          %g3, 80f;                                       \
-        nop;                                                           \
-       add             %g3, %g2, %g3;                                  \
-       sllx            %g1, 8, %g1;                                    \
-       add             %g3, %g1, %g1;                                  \
-       /* %g1 holds pointer to the top of the logging scoreboard */    \
-       ldx             [%g1 + 0x0], %g7;                               \
-       cmp             %g7, -1;                                        \
-       bne,pn          %xcc, 80f;                                      \
-        nop;                                                           \
-       stx             %g4, [%g1 + 0x0];                               \
-       stx             %g5, [%g1 + 0x8];                               \
-       add             %g1, 0x10, %g1;                                 \
-       /* %g1 now points to D-cache logging area */                    \
-       set             0x3ff8, %g2;    /* DC_addr mask         */      \
-       and             %g5, %g2, %g2;  /* DC_addr bits of AFAR */      \
-       srlx            %g5, 12, %g3;                                   \
-       or              %g3, 1, %g3;    /* PHYS tag + valid     */      \
-10:    ldxa            [%g2] ASI_DCACHE_TAG, %g7;                      \
-       cmp             %g3, %g7;       /* TAG match?           */      \
-       bne,pt          %xcc, 13f;                                      \
-        nop;                                                           \
-       /* Yep, what we want, capture state. */                         \
-       stx             %g2, [%g1 + 0x20];                              \
-       stx             %g7, [%g1 + 0x28];                              \
-       /* A membar Sync is required before and after utag access. */   \
-       membar          #Sync;                                          \
-       ldxa            [%g2] ASI_DCACHE_UTAG, %g7;                     \
-       membar          #Sync;                                          \
-       stx             %g7, [%g1 + 0x30];                              \
-       ldxa            [%g2] ASI_DCACHE_SNOOP_TAG, %g7;                \
-       stx             %g7, [%g1 + 0x38];                              \
-       clr             %g3;                                            \
-12:    ldxa            [%g2 + %g3] ASI_DCACHE_DATA, %g7;               \
-       stx             %g7, [%g1];                                     \
-       add             %g3, (1 << 5), %g3;                             \
-       cmp             %g3, (4 << 5);                                  \
-       bl,pt           %xcc, 12b;                                      \
-        add            %g1, 0x8, %g1;                                  \
-       ba,pt           %xcc, 20f;                                      \
-        add            %g1, 0x20, %g1;                                 \
-13:    sethi           %hi(1 << 14), %g7;                              \
-       add             %g2, %g7, %g2;                                  \
-       srlx            %g2, 14, %g7;                                   \
-       cmp             %g7, 4;                                         \
-       bl,pt           %xcc, 10b;                                      \
-        nop;                                                           \
-       add             %g1, 0x40, %g1;                                 \
-20:    /* %g1 now points to I-cache logging area */                    \
-       set             0x1fe0, %g2;    /* IC_addr mask         */      \
-       and             %g5, %g2, %g2;  /* IC_addr bits of AFAR */      \
-       sllx            %g2, 1, %g2;    /* IC_addr[13:6]==VA[12:5] */   \
-       srlx            %g5, (13 - 8), %g3; /* Make PTAG */             \
-       andn            %g3, 0xff, %g3; /* Mask off undefined bits */   \
-21:    ldxa            [%g2] ASI_IC_TAG, %g7;                          \
-       andn            %g7, 0xff, %g7;                                 \
-       cmp             %g3, %g7;                                       \
-       bne,pt          %xcc, 23f;                                      \
-        nop;                                                           \
-       /* Yep, what we want, capture state. */                         \
-       stx             %g2, [%g1 + 0x40];                              \
-       stx             %g7, [%g1 + 0x48];                              \
-       add             %g2, (1 << 3), %g2;                             \
-       ldxa            [%g2] ASI_IC_TAG, %g7;                          \
-       add             %g2, (1 << 3), %g2;                             \
-       stx             %g7, [%g1 + 0x50];                              \
-       ldxa            [%g2] ASI_IC_TAG, %g7;                          \
-       add             %g2, (1 << 3), %g2;                             \
-       stx             %g7, [%g1 + 0x60];                              \
-       ldxa            [%g2] ASI_IC_TAG, %g7;                          \
-       stx             %g7, [%g1 + 0x68];                              \
-       sub             %g2, (3 << 3), %g2;                             \
-       ldxa            [%g2] ASI_IC_STAG, %g7;                         \
-       stx             %g7, [%g1 + 0x58];                              \
-       clr             %g3;                                            \
-       srlx            %g2, 2, %g2;                                    \
-22:    ldxa            [%g2 + %g3] ASI_IC_INSTR, %g7;                  \
-       stx             %g7, [%g1];                                     \
-       add             %g3, (1 << 3), %g3;                             \
-       cmp             %g3, (8 << 3);                                  \
-       bl,pt           %xcc, 22b;                                      \
-        add            %g1, 0x8, %g1;                                  \
-       ba,pt           %xcc, 30f;                                      \
-        add            %g1, 0x30, %g1;                                 \
-23:    sethi           %hi(1 << 14), %g7;                              \
-       add             %g2, %g7, %g2;                                  \
-       srlx            %g2, 14, %g7;                                   \
-       cmp             %g7, 4;                                         \
-       bl,pt           %xcc, 21b;                                      \
-        nop;                                                           \
-       add             %g1, 0x70, %g1;                                 \
-30:    /* %g1 now points to E-cache logging area */                    \
-       andn            %g5, (32 - 1), %g2;     /* E-cache subblock */  \
-       stx             %g2, [%g1 + 0x20];                              \
-       ldxa            [%g2] ASI_EC_TAG_DATA, %g7;                     \
-       stx             %g7, [%g1 + 0x28];                              \
-       ldxa            [%g2] ASI_EC_R, %g0;                            \
-       clr             %g3;                                            \
-31:    ldxa            [%g3] ASI_EC_DATA, %g7;                         \
-       stx             %g7, [%g1 + %g3];                               \
-       add             %g3, 0x8, %g3;                                  \
-       cmp             %g3, 0x20;                                      \
-       bl,pt           %xcc, 31b;                                      \
-        nop;                                                           \
-80:    /* DONE */
-
        /* These get patched into the trap table at boot time
         * once we know we have a cheetah processor.
         */
@@ -1296,6 +1163,170 @@ dcpe_icpe_tl1_common:
        membar          #Sync
        retry
 
+       /* Capture I/D/E-cache state into per-cpu error scoreboard.
+        *
+        * %g1:         (TL>=0) ? 1 : 0
+        * %g2:         scratch
+        * %g3:         scratch
+        * %g4:         AFSR
+        * %g5:         AFAR
+        * %g6:         current thread ptr
+        * %g7:         scratch
+        */
+__cheetah_log_error:
+       /* Put "TL1" software bit into AFSR. */
+       and             %g1, 0x1, %g1
+       sllx            %g1, 63, %g2
+       or              %g4, %g2, %g4
+
+       /* Get log entry pointer for this cpu at this trap level. */
+       BRANCH_IF_JALAPENO(g2,g3,50f)
+       ldxa            [%g0] ASI_SAFARI_CONFIG, %g2
+       srlx            %g2, 17, %g2
+       ba,pt           %xcc, 60f
+        and            %g2, 0x3ff, %g2
+
+50:    ldxa            [%g0] ASI_JBUS_CONFIG, %g2
+       srlx            %g2, 17, %g2
+       and             %g2, 0x1f, %g2
+
+60:    sllx            %g2, 9, %g2
+       sethi           %hi(cheetah_error_log), %g3
+       ldx             [%g3 + %lo(cheetah_error_log)], %g3
+       brz,pn          %g3, 80f
+        nop
+
+       add             %g3, %g2, %g3
+       sllx            %g1, 8, %g1
+       add             %g3, %g1, %g1
+
+       /* %g1 holds pointer to the top of the logging scoreboard */
+       ldx             [%g1 + 0x0], %g7
+       cmp             %g7, -1
+       bne,pn          %xcc, 80f
+        nop
+
+       stx             %g4, [%g1 + 0x0]
+       stx             %g5, [%g1 + 0x8]
+       add             %g1, 0x10, %g1
+
+       /* %g1 now points to D-cache logging area */
+       set             0x3ff8, %g2     /* DC_addr mask         */
+       and             %g5, %g2, %g2   /* DC_addr bits of AFAR */
+       srlx            %g5, 12, %g3
+       or              %g3, 1, %g3     /* PHYS tag + valid     */
+
+10:    ldxa            [%g2] ASI_DCACHE_TAG, %g7
+       cmp             %g3, %g7        /* TAG match?           */
+       bne,pt          %xcc, 13f
+        nop
+
+       /* Yep, what we want, capture state. */
+       stx             %g2, [%g1 + 0x20]
+       stx             %g7, [%g1 + 0x28]
+
+       /* A membar Sync is required before and after utag access. */
+       membar          #Sync
+       ldxa            [%g2] ASI_DCACHE_UTAG, %g7
+       membar          #Sync
+       stx             %g7, [%g1 + 0x30]
+       ldxa            [%g2] ASI_DCACHE_SNOOP_TAG, %g7
+       stx             %g7, [%g1 + 0x38]
+       clr             %g3
+
+12:    ldxa            [%g2 + %g3] ASI_DCACHE_DATA, %g7
+       stx             %g7, [%g1]
+       add             %g3, (1 << 5), %g3
+       cmp             %g3, (4 << 5)
+       bl,pt           %xcc, 12b
+        add            %g1, 0x8, %g1
+
+       ba,pt           %xcc, 20f
+        add            %g1, 0x20, %g1
+
+13:    sethi           %hi(1 << 14), %g7
+       add             %g2, %g7, %g2
+       srlx            %g2, 14, %g7
+       cmp             %g7, 4
+       bl,pt           %xcc, 10b
+        nop
+
+       add             %g1, 0x40, %g1
+
+       /* %g1 now points to I-cache logging area */
+20:    set             0x1fe0, %g2     /* IC_addr mask         */
+       and             %g5, %g2, %g2   /* IC_addr bits of AFAR */
+       sllx            %g2, 1, %g2     /* IC_addr[13:6]==VA[12:5] */
+       srlx            %g5, (13 - 8), %g3 /* Make PTAG */
+       andn            %g3, 0xff, %g3  /* Mask off undefined bits */
+
+21:    ldxa            [%g2] ASI_IC_TAG, %g7
+       andn            %g7, 0xff, %g7
+       cmp             %g3, %g7
+       bne,pt          %xcc, 23f
+        nop
+
+       /* Yep, what we want, capture state. */
+       stx             %g2, [%g1 + 0x40]
+       stx             %g7, [%g1 + 0x48]
+       add             %g2, (1 << 3), %g2
+       ldxa            [%g2] ASI_IC_TAG, %g7
+       add             %g2, (1 << 3), %g2
+       stx             %g7, [%g1 + 0x50]
+       ldxa            [%g2] ASI_IC_TAG, %g7
+       add             %g2, (1 << 3), %g2
+       stx             %g7, [%g1 + 0x60]
+       ldxa            [%g2] ASI_IC_TAG, %g7
+       stx             %g7, [%g1 + 0x68]
+       sub             %g2, (3 << 3), %g2
+       ldxa            [%g2] ASI_IC_STAG, %g7
+       stx             %g7, [%g1 + 0x58]
+       clr             %g3
+       srlx            %g2, 2, %g2
+
+22:    ldxa            [%g2 + %g3] ASI_IC_INSTR, %g7
+       stx             %g7, [%g1]
+       add             %g3, (1 << 3), %g3
+       cmp             %g3, (8 << 3)
+       bl,pt           %xcc, 22b
+        add            %g1, 0x8, %g1
+
+       ba,pt           %xcc, 30f
+        add            %g1, 0x30, %g1
+
+23:    sethi           %hi(1 << 14), %g7
+       add             %g2, %g7, %g2
+       srlx            %g2, 14, %g7
+       cmp             %g7, 4
+       bl,pt           %xcc, 21b
+        nop
+
+       add             %g1, 0x70, %g1
+
+       /* %g1 now points to E-cache logging area */
+30:    andn            %g5, (32 - 1), %g2
+       stx             %g2, [%g1 + 0x20]
+       ldxa            [%g2] ASI_EC_TAG_DATA, %g7
+       stx             %g7, [%g1 + 0x28]
+       ldxa            [%g2] ASI_EC_R, %g0
+       clr             %g3
+
+31:    ldxa            [%g3] ASI_EC_DATA, %g7
+       stx             %g7, [%g1 + %g3]
+       add             %g3, 0x8, %g3
+       cmp             %g3, 0x20
+
+       bl,pt           %xcc, 31b
+        nop
+80:
+       rdpr            %tt, %g2
+       cmp             %g2, 0x70
+       be              c_fast_ecc
+        cmp            %g2, 0x63
+       be              c_cee
+        nop
+       ba,pt           %xcc, c_deferred
+
        /* Cheetah FECC trap handling, we get here from tl{0,1}_fecc
         * in the trap table.  That code has done a memory barrier
         * and has disabled both the I-cache and D-cache in the DCU
@@ -1321,8 +1352,10 @@ cheetah_fast_ecc:
        stxa            %g4, [%g0] ASI_AFSR
        membar          #Sync
 
-       CHEETAH_LOG_ERROR
+       ba,pt           %xcc, __cheetah_log_error
+        nop
 
+c_fast_ecc:
        rdpr            %pil, %g2
        wrpr            %g0, 15, %pil
        ba,pt           %xcc, etrap_irq
@@ -1347,8 +1380,10 @@ cheetah_cee:
        stxa            %g4, [%g0] ASI_AFSR
        membar          #Sync
 
-       CHEETAH_LOG_ERROR
+       ba,pt           %xcc, __cheetah_log_error
+        nop
 
+c_cee:
        rdpr            %pil, %g2
        wrpr            %g0, 15, %pil
        ba,pt           %xcc, etrap_irq
@@ -1373,8 +1408,10 @@ cheetah_deferred_trap:
        stxa            %g4, [%g0] ASI_AFSR
        membar          #Sync
 
-       CHEETAH_LOG_ERROR
+       ba,pt           %xcc, __cheetah_log_error
+        nop
 
+c_deferred:
        rdpr            %pil, %g2
        wrpr            %g0, 15, %pil
        ba,pt           %xcc, etrap_irq
index 8104a56ca2d8e779b7999cf14d62db03155f8129..1fa06c4e3bdb8da1c5496dc14fa5547a69fe79f0 100644 (file)
@@ -538,11 +538,12 @@ cheetah_tlb_fixup:
         nop
        call    cheetah_plus_patch_winfixup
         nop
-       
 
 2:     /* Patch copy/page operations to cheetah optimized versions. */
        call    cheetah_patch_copyops
         nop
+       call    cheetah_patch_copy_page
+        nop
        call    cheetah_patch_cachetlbops
         nop
 
index f21c993f885616cf963e8fe804b7303ecdc1e6bc..ec8bf4012c0c411b66505727387d38a57f43fdc3 100644 (file)
@@ -736,8 +736,7 @@ static void __pci_mmap_set_flags(struct pci_dev *dev, struct vm_area_struct *vma
 static void __pci_mmap_set_pgprot(struct pci_dev *dev, struct vm_area_struct *vma,
                                             enum pci_mmap_state mmap_state)
 {
-       /* Our io_remap_page_range/io_remap_pfn_range takes care of this,
-          do nothing. */
+       /* Our io_remap_pfn_range takes care of this, do nothing.  */
 }
 
 /* Perform the actual remap of the pages for a PCI device mapping, as appropriate
index 0696ed4b9d644f01aef775f2a92aad1e67ea4a13..fafd227735fa1d13b79f8b97e74aa6b3d81f2715 100644 (file)
@@ -153,11 +153,14 @@ __handle_signal:
 rtrap_irq:
 rtrap_clr_l6:  clr                     %l6
 rtrap:
-               ldub                    [%g6 + TI_CPU], %l0
-               sethi                   %hi(irq_stat), %l2      ! &softirq_active
-               or                      %l2, %lo(irq_stat), %l2 ! &softirq_active
-irqsz_patchme: sllx                    %l0, 0, %l0
-               lduw                    [%l2 + %l0], %l1        ! softirq_pending
+#ifndef CONFIG_SMP
+               sethi                   %hi(per_cpu____cpu_data), %l0
+               lduw                    [%l0 + %lo(per_cpu____cpu_data)], %l1
+#else
+               sethi                   %hi(per_cpu____cpu_data), %l0
+               or                      %l0, %lo(per_cpu____cpu_data), %l0
+               lduw                    [%l0 + %g5], %l1
+#endif
                cmp                     %l1, 0
 
                /* mm/ultra.S:xcall_report_regs KNOWS about this load. */
index fbdfed3798d883667c7ab70715c0f740075898d2..ddbed3341a232770b7c929291fc4f959862d9a17 100644 (file)
@@ -511,18 +511,6 @@ void __init setup_arch(char **cmdline_p)
        conswitchp = &prom_con;
 #endif
 
-#ifdef CONFIG_SMP
-       i = (unsigned long)&irq_stat[1] - (unsigned long)&irq_stat[0];
-       if ((i == SMP_CACHE_BYTES) || (i == (2 * SMP_CACHE_BYTES))) {
-               extern unsigned int irqsz_patchme[1];
-               irqsz_patchme[0] |= ((i == SMP_CACHE_BYTES) ? SMP_CACHE_BYTES_SHIFT : \
-                                                       SMP_CACHE_BYTES_SHIFT + 1);
-               flushi((long)&irqsz_patchme[0]);
-       } else {
-               prom_printf("Unexpected size of irq_stat[] elements\n");
-               prom_halt();
-       }
-#endif
        /* Work out if we are starfire early on */
        check_if_starfire();
 
index a3ea697f1adbffb88f7de3ec9d5c4a8fe969da19..d89fc24808d3eccd137db229c0bef7438b19ec7a 100644 (file)
@@ -88,8 +88,6 @@ extern int svr4_setcontext(svr4_ucontext_t *uc, struct pt_regs *regs);
 extern int compat_sys_ioctl(unsigned int fd, unsigned int cmd, u32 arg);
 extern int (*handle_mathemu)(struct pt_regs *, struct fpustate *);
 extern long sparc32_open(const char __user * filename, int flags, int mode);
-extern int io_remap_page_range(struct vm_area_struct *vma, unsigned long from,
-       unsigned long offset, unsigned long size, pgprot_t prot, int space);
 extern int io_remap_pfn_range(struct vm_area_struct *vma, unsigned long from,
        unsigned long pfn, unsigned long size, pgprot_t prot);
 extern void (*prom_palette)(int);
@@ -245,7 +243,6 @@ EXPORT_SYMBOL(pci_dma_supported);
 #endif
 
 /* I/O device mmaping on Sparc64. */
-EXPORT_SYMBOL(io_remap_page_range);
 EXPORT_SYMBOL(io_remap_pfn_range);
 
 /* Solaris/SunOS binary compatibility */
index 3008d536e8c29b4367a7b38969a3b2d1838eb9de..3c6cfbb20360fe7fb8a38a8105b356b88865928d 100644 (file)
@@ -7,28 +7,31 @@
 #include <asm/io.h>
 #include <asm/byteorder.h>
 
-void outsb(void __iomem *addr, const void *src, unsigned long count)
+void outsb(unsigned long __addr, const void *src, unsigned long count)
 {
+       void __iomem *addr = (void __iomem *) __addr;
        const u8 *p = src;
 
-       while(count--)
+       while (count--)
                outb(*p++, addr);
 }
 
-void outsw(void __iomem *addr, const void *src, unsigned long count)
+void outsw(unsigned long __addr, const void *src, unsigned long count)
 {
-       if(count) {
+       void __iomem *addr = (void __iomem *) __addr;
+
+       if (count) {
                u16 *ps = (u16 *)src;
                u32 *pi;
 
-               if(((u64)src) & 0x2) {
+               if (((u64)src) & 0x2) {
                        u16 val = le16_to_cpup(ps);
                        outw(val, addr);
                        ps++;
                        count--;
                }
                pi = (u32 *)ps;
-               while(count >= 2) {
+               while (count >= 2) {
                        u32 w = le32_to_cpup(pi);
 
                        pi++;
@@ -37,19 +40,21 @@ void outsw(void __iomem *addr, const void *src, unsigned long count)
                        count -= 2;
                }
                ps = (u16 *)pi;
-               if(count) {
+               if (count) {
                        u16 val = le16_to_cpup(ps);
                        outw(val, addr);
                }
        }
 }
 
-void outsl(void __iomem *addr, const void *src, unsigned long count)
+void outsl(unsigned long __addr, const void *src, unsigned long count)
 {
-       if(count) {
-               if((((u64)src) & 0x3) == 0) {
+       void __iomem *addr = (void __iomem *) __addr;
+
+       if (count) {
+               if ((((u64)src) & 0x3) == 0) {
                        u32 *p = (u32 *)src;
-                       while(count--) {
+                       while (count--) {
                                u32 val = cpu_to_le32p(p);
                                outl(val, addr);
                                p++;
@@ -60,13 +65,13 @@ void outsl(void __iomem *addr, const void *src, unsigned long count)
                        u32 l = 0, l2;
                        u32 *pi;
 
-                       switch(((u64)src) & 0x3) {
+                       switch (((u64)src) & 0x3) {
                        case 0x2:
                                count -= 1;
                                l = cpu_to_le16p(ps) << 16;
                                ps++;
                                pi = (u32 *)ps;
-                               while(count--) {
+                               while (count--) {
                                        l2 = cpu_to_le32p(pi);
                                        pi++;
                                        outl(((l >> 16) | (l2 << 16)), addr);
@@ -86,7 +91,7 @@ void outsl(void __iomem *addr, const void *src, unsigned long count)
                                ps++;
                                l |= (l2 << 16);
                                pi = (u32 *)ps;
-                               while(count--) {
+                               while (count--) {
                                        l2 = cpu_to_le32p(pi);
                                        pi++;
                                        outl(((l >> 8) | (l2 << 24)), addr);
@@ -101,7 +106,7 @@ void outsl(void __iomem *addr, const void *src, unsigned long count)
                                pb = (u8 *)src;
                                l = (*pb++ << 24);
                                pi = (u32 *)pb;
-                               while(count--) {
+                               while (count--) {
                                        l2 = cpu_to_le32p(pi);
                                        pi++;
                                        outl(((l >> 24) | (l2 << 8)), addr);
@@ -119,16 +124,18 @@ void outsl(void __iomem *addr, const void *src, unsigned long count)
        }
 }
 
-void insb(void __iomem *addr, void *dst, unsigned long count)
+void insb(unsigned long __addr, void *dst, unsigned long count)
 {
-       if(count) {
+       void __iomem *addr = (void __iomem *) __addr;
+
+       if (count) {
                u32 *pi;
                u8 *pb = dst;
 
-               while((((unsigned long)pb) & 0x3) && count--)
+               while ((((unsigned long)pb) & 0x3) && count--)
                        *pb++ = inb(addr);
                pi = (u32 *)pb;
-               while(count >= 4) {
+               while (count >= 4) {
                        u32 w;
 
                        w  = (inb(addr) << 24);
@@ -139,23 +146,25 @@ void insb(void __iomem *addr, void *dst, unsigned long count)
                        count -= 4;
                }
                pb = (u8 *)pi;
-               while(count--)
+               while (count--)
                        *pb++ = inb(addr);
        }
 }
 
-void insw(void __iomem *addr, void *dst, unsigned long count)
+void insw(unsigned long __addr, void *dst, unsigned long count)
 {
-       if(count) {
+       void __iomem *addr = (void __iomem *) __addr;
+
+       if (count) {
                u16 *ps = dst;
                u32 *pi;
 
-               if(((unsigned long)ps) & 0x2) {
+               if (((unsigned long)ps) & 0x2) {
                        *ps++ = le16_to_cpu(inw(addr));
                        count--;
                }
                pi = (u32 *)ps;
-               while(count >= 2) {
+               while (count >= 2) {
                        u32 w;
 
                        w  = (le16_to_cpu(inw(addr)) << 16);
@@ -164,31 +173,33 @@ void insw(void __iomem *addr, void *dst, unsigned long count)
                        count -= 2;
                }
                ps = (u16 *)pi;
-               if(count)
+               if (count)
                        *ps = le16_to_cpu(inw(addr));
        }
 }
 
-void insl(void __iomem *addr, void *dst, unsigned long count)
+void insl(unsigned long __addr, void *dst, unsigned long count)
 {
-       if(count) {
-               if((((unsigned long)dst) & 0x3) == 0) {
+       void __iomem *addr = (void __iomem *) __addr;
+
+       if (count) {
+               if ((((unsigned long)dst) & 0x3) == 0) {
                        u32 *pi = dst;
-                       while(count--)
+                       while (count--)
                                *pi++ = le32_to_cpu(inl(addr));
                } else {
                        u32 l = 0, l2, *pi;
                        u16 *ps;
                        u8 *pb;
 
-                       switch(((unsigned long)dst) & 3) {
+                       switch (((unsigned long)dst) & 3) {
                        case 0x2:
                                ps = dst;
                                count -= 1;
                                l = le32_to_cpu(inl(addr));
                                *ps++ = l;
                                pi = (u32 *)ps;
-                               while(count--) {
+                               while (count--) {
                                        l2 = le32_to_cpu(inl(addr));
                                        *pi++ = (l << 16) | (l2 >> 16);
                                        l = l2;
@@ -205,7 +216,7 @@ void insl(void __iomem *addr, void *dst, unsigned long count)
                                ps = (u16 *)pb;
                                *ps++ = ((l >> 8) & 0xffff);
                                pi = (u32 *)ps;
-                               while(count--) {
+                               while (count--) {
                                        l2 = le32_to_cpu(inl(addr));
                                        *pi++ = (l << 24) | (l2 >> 8);
                                        l = l2;
@@ -220,7 +231,7 @@ void insl(void __iomem *addr, void *dst, unsigned long count)
                                l = le32_to_cpu(inl(addr));
                                *pb++ = l >> 24;
                                pi = (u32 *)pb;
-                               while(count--) {
+                               while (count--) {
                                        l2 = le32_to_cpu(inl(addr));
                                        *pi++ = (l << 8) | (l2 >> 24);
                                        l = l2;
index 23ebf2c970b71d950c2bea623e60b58c36b7b46c..feebb14fd27a3d3d63adae00b4653e7d43d3083e 100644 (file)
@@ -87,7 +87,7 @@ copy_user_page:               /* %o0=dest, %o1=src, %o2=vaddr */
        membar          #Sync
        wrpr            %o2, 0x0, %pstate
 
-       BRANCH_IF_ANY_CHEETAH(g3,o2,1f)
+cheetah_copy_page_insn:
        ba,pt           %xcc, 9f
         nop
 
@@ -240,3 +240,14 @@ copy_user_page:            /* %o0=dest, %o1=src, %o2=vaddr */
         stw            %o4, [%g6 + TI_PRE_COUNT]
 
        .size           copy_user_page, .-copy_user_page
+
+       .globl          cheetah_patch_copy_page
+cheetah_patch_copy_page:
+       sethi           %hi(0x01000000), %o1    ! NOP
+       sethi           %hi(cheetah_copy_page_insn), %o0
+       or              %o0, %lo(cheetah_copy_page_insn), %o0
+       stw             %o1, [%o0]
+       membar          #StoreStore
+       flush           %o0
+       retl
+        nop
index 6b31f6117a950ac400d3c78c68f759754c434b54..c954d91f01d0463aa75f607c393f1c7f4fd7dfcb 100644 (file)
@@ -116,37 +116,6 @@ static inline int io_remap_pud_range(struct mm_struct *mm, pud_t * pud, unsigned
        return 0;
 }
 
-int io_remap_page_range(struct vm_area_struct *vma, unsigned long from, unsigned long offset, unsigned long size, pgprot_t prot, int space)
-{
-       int error = 0;
-       pgd_t * dir;
-       unsigned long beg = from;
-       unsigned long end = from + size;
-       struct mm_struct *mm = vma->vm_mm;
-
-       prot = __pgprot(pg_iobits);
-       offset -= from;
-       dir = pgd_offset(mm, from);
-       flush_cache_range(vma, beg, end);
-
-       spin_lock(&mm->page_table_lock);
-       while (from < end) {
-               pud_t *pud = pud_alloc(mm, dir, from);
-               error = -ENOMEM;
-               if (!pud)
-                       break;
-               error = io_remap_pud_range(mm, pud, from, end - from, offset + from, prot, space);
-               if (error)
-                       break;
-               from = (from + PGDIR_SIZE) & PGDIR_MASK;
-               dir++;
-       }
-       flush_tlb_range(vma, beg, end);
-       spin_unlock(&mm->page_table_lock);
-
-       return error;
-}
-
 int io_remap_pfn_range(struct vm_area_struct *vma, unsigned long from,
                unsigned long pfn, unsigned long size, pgprot_t prot)
 {
index 363770893797770233005c315d7644ff902272a7..8dfa825eca51f5a92a269400b15b366f92b766ca 100644 (file)
@@ -10,6 +10,7 @@
 #include <asm/page.h>
 #include <asm/spitfire.h>
 #include <asm/mmu_context.h>
+#include <asm/mmu.h>
 #include <asm/pil.h>
 #include <asm/head.h>
 #include <asm/thread_info.h>
@@ -45,6 +46,8 @@ __flush_tlb_mm: /* %o0=(ctx & TAG_CONTEXT_BITS), %o1=SECONDARY_CONTEXT */
        nop
        nop
        nop
+       nop
+       nop
 
        .align          32
        .globl          __flush_tlb_pending
@@ -73,6 +76,9 @@ __flush_tlb_pending:
        retl
         wrpr           %g7, 0x0, %pstate
        nop
+       nop
+       nop
+       nop
 
        .align          32
        .globl          __flush_tlb_kernel_range
@@ -224,16 +230,8 @@ __update_mmu_cache:        /* %o0=hw_context, %o1=address, %o2=pte, %o3=fault_code */
         or             %o5, %o0, %o5
        ba,a,pt         %xcc, __prefill_itlb
 
-       /* Cheetah specific versions, patched at boot time.
-        *
-        * This writes of the PRIMARY_CONTEXT register in this file are
-        * safe even on Cheetah+ and later wrt. the page size fields.
-        * The nucleus page size fields do not matter because we make
-        * no data references, and these instructions execute out of a
-        * locked I-TLB entry sitting in the fully assosciative I-TLB.
-        * This sequence should also never trap.
-        */
-__cheetah_flush_tlb_mm: /* 15 insns */
+       /* Cheetah specific versions, patched at boot time. */
+__cheetah_flush_tlb_mm: /* 18 insns */
        rdpr            %pstate, %g7
        andn            %g7, PSTATE_IE, %g2
        wrpr            %g2, 0x0, %pstate
@@ -241,6 +239,9 @@ __cheetah_flush_tlb_mm: /* 15 insns */
        mov             PRIMARY_CONTEXT, %o2
        mov             0x40, %g3
        ldxa            [%o2] ASI_DMMU, %g2
+       srlx            %g2, CTX_PGSZ1_NUC_SHIFT, %o1
+       sllx            %o1, CTX_PGSZ1_NUC_SHIFT, %o1
+       or              %o0, %o1, %o0   /* Preserve nucleus page size fields */
        stxa            %o0, [%o2] ASI_DMMU
        stxa            %g0, [%g3] ASI_DMMU_DEMAP
        stxa            %g0, [%g3] ASI_IMMU_DEMAP
@@ -250,7 +251,7 @@ __cheetah_flush_tlb_mm: /* 15 insns */
        retl
         wrpr           %g7, 0x0, %pstate
 
-__cheetah_flush_tlb_pending:   /* 23 insns */
+__cheetah_flush_tlb_pending:   /* 26 insns */
        /* %o0 = context, %o1 = nr, %o2 = vaddrs[] */
        rdpr            %pstate, %g7
        sllx            %o1, 3, %o1
@@ -259,6 +260,9 @@ __cheetah_flush_tlb_pending:        /* 23 insns */
        wrpr            %g0, 1, %tl
        mov             PRIMARY_CONTEXT, %o4
        ldxa            [%o4] ASI_DMMU, %g2
+       srlx            %g2, CTX_PGSZ1_NUC_SHIFT, %o3
+       sllx            %o3, CTX_PGSZ1_NUC_SHIFT, %o3
+       or              %o0, %o3, %o0   /* Preserve nucleus page size fields */
        stxa            %o0, [%o4] ASI_DMMU
 1:     sub             %o1, (1 << 3), %o1
        ldx             [%o2 + %o1], %o3
@@ -311,14 +315,14 @@ cheetah_patch_cachetlbops:
        sethi           %hi(__cheetah_flush_tlb_mm), %o1
        or              %o1, %lo(__cheetah_flush_tlb_mm), %o1
        call            cheetah_patch_one
-        mov            15, %o2
+        mov            18, %o2
 
        sethi           %hi(__flush_tlb_pending), %o0
        or              %o0, %lo(__flush_tlb_pending), %o0
        sethi           %hi(__cheetah_flush_tlb_pending), %o1
        or              %o1, %lo(__cheetah_flush_tlb_pending), %o1
        call            cheetah_patch_one
-        mov            23, %o2
+        mov            26, %o2
 
 #ifdef DCACHE_ALIASING_POSSIBLE
        sethi           %hi(__flush_dcache_page), %o0
@@ -352,9 +356,12 @@ cheetah_patch_cachetlbops:
        .globl          xcall_flush_tlb_mm
 xcall_flush_tlb_mm:
        mov             PRIMARY_CONTEXT, %g2
-       mov             0x40, %g4
        ldxa            [%g2] ASI_DMMU, %g3
+       srlx            %g3, CTX_PGSZ1_NUC_SHIFT, %g4
+       sllx            %g4, CTX_PGSZ1_NUC_SHIFT, %g4
+       or              %g5, %g4, %g5   /* Preserve nucleus page size fields */
        stxa            %g5, [%g2] ASI_DMMU
+       mov             0x40, %g4
        stxa            %g0, [%g4] ASI_DMMU_DEMAP
        stxa            %g0, [%g4] ASI_IMMU_DEMAP
        stxa            %g3, [%g2] ASI_DMMU
@@ -366,6 +373,10 @@ xcall_flush_tlb_pending:
        sllx            %g1, 3, %g1
        mov             PRIMARY_CONTEXT, %g4
        ldxa            [%g4] ASI_DMMU, %g2
+       srlx            %g2, CTX_PGSZ1_NUC_SHIFT, %g4
+       sllx            %g4, CTX_PGSZ1_NUC_SHIFT, %g4
+       or              %g5, %g4, %g5
+       mov             PRIMARY_CONTEXT, %g4
        stxa            %g5, [%g4] ASI_DMMU
 1:     sub             %g1, (1 << 3), %g1
        ldx             [%g7 + %g1], %g5
index f945444df49c32aade7099e431fe14a10e756b3f..684e1f8b2755da5c5b2da0ad5e973505aa71a1a7 100644 (file)
@@ -73,7 +73,7 @@ config MODE_SKAS
        to CONFIG_MODE_TT).  Otherwise, it is safe to say Y.  Disabling this
        option will shrink the UML binary slightly.
 
-source "arch/um/Kconfig_arch"
+source "arch/um/Kconfig.arch"
 source "mm/Kconfig"
 
 config LD_SCRIPT_STATIC
@@ -196,7 +196,7 @@ config HOST_2G_2G
 config SMP
        bool "Symmetric multi-processing support (EXPERIMENTAL)"
        default n
-       depends on MODE_TT && EXPERIMENTAL
+       depends on (MODE_TT && EXPERIMENTAL && !SMP_BROKEN) || (BROKEN && SMP_BROKEN)
        help
        This option enables UML SMP support.
        It is NOT related to having a real SMP box. Not directly, at least.
@@ -279,7 +279,7 @@ source "net/Kconfig"
 
 source "drivers/base/Kconfig"
 
-source "arch/um/Kconfig_char"
+source "arch/um/Kconfig.char"
 
 source "drivers/block/Kconfig"
 
@@ -287,7 +287,7 @@ config NETDEVICES
        bool
        default NET
 
-source "arch/um/Kconfig_net"
+source "arch/um/Kconfig.net"
 
 source "drivers/net/Kconfig"
 
@@ -311,7 +311,7 @@ config GENERIC_ISA_DMA
        depends on SCSI
        default y
 
-source "arch/um/Kconfig_scsi"
+source "arch/um/Kconfig.scsi"
 
 endmenu
 
similarity index 100%
rename from arch/um/Kconfig_char
rename to arch/um/Kconfig.char
index bd41e4286d0d4b743fafc74a993f167c7cac0955..5681a8bd370b2db1201382405a7edf885efa12cd 100644 (file)
@@ -2,6 +2,17 @@ menu "Kernel hacking"
 
 source "lib/Kconfig.debug"
 
+config CMDLINE_ON_HOST
+       bool "Show command line arguments on the host in TT mode"
+       depends on MODE_TT
+       default !DEBUG_INFO
+       help
+       This controls whether arguments in guest processes should be shown on
+       the host's ps output.
+       Enabling this option hinders debugging on some recent GDB versions
+       (because GDB gets "confused" when we do an execvp()). So probably you
+       should disable it.
+
 config PT_PROXY
        bool "Enable ptrace proxy"
        depends on XTERM_CHAN && DEBUG_INFO && MODE_TT
similarity index 93%
rename from arch/um/Kconfig_i386
rename to arch/um/Kconfig.i386
index 27c18a8d9d17d72c22d6f1c08ec6001d8bbc9563..8ad156a00499acf682a808e37d5120337f15c5b2 100644 (file)
@@ -6,6 +6,10 @@ config 64BIT
        bool
        default n
 
+config SEMAPHORE_SLEEPERS
+       bool
+       default y
+
 config TOP_ADDR
        hex
        default 0xc0000000 if !HOST_2G_2G
similarity index 98%
rename from arch/um/Kconfig_net
rename to arch/um/Kconfig.net
index fa2ab2dd78b71f7f1f44a84d3a6611c1fd3bba36..14a04ebdeae9cbd02703f70556afed68b8a2a23c 100644 (file)
@@ -34,7 +34,7 @@ config UML_NET_ETHERTAP
         link with the host.
 
         To use this, your host kernel must have support for Ethertap
-        devices.  Also, if your host kernel is 2.4.x, it must have 
+        devices.  Also, if your host kernel is 2.4.x, it must have
         CONFIG_NETLINK_DEV configured as Y or M.
 
         For more information, see
@@ -43,7 +43,7 @@ config UML_NET_ETHERTAP
         networking.
 
         If you'd like to set up an IP network with the host and/or the
-        outside world, say Y to this, the Daemon Transport and/or the 
+        outside world, say Y to this, the Daemon Transport and/or the
         Slip Transport.  You'll need at least one of them, but may choose
         more than one without conflict.  If you don't need UML networking,
         say N.
@@ -78,7 +78,7 @@ config UML_NET_SLIP
 
         The Ethertap Transport is preferred over slip because of its
         limitations.  If you prefer slip, however, say Y here.  Otherwise
-        choose the Multicast transport (to network multiple UMLs on 
+        choose the Multicast transport (to network multiple UMLs on
         multiple hosts), Ethertap (to network with the host and the
         outside world), and/or the Daemon transport (to network multiple
         UMLs on a single host).  You may choose more than one without
@@ -138,7 +138,7 @@ config UML_NET_PCAP
        depends on UML_NET && EXPERIMENTAL
        help
        The pcap transport makes a pcap packet stream on the host look
-       like an ethernet device inside UML.  This is useful for making 
+       like an ethernet device inside UML.  This is useful for making
        UML act as a network monitor for the host.  You must have libcap
        installed in order to build the pcap transport into UML.
 
@@ -169,11 +169,11 @@ config UML_NET_SLIRP
         setup string.  The effect of this transport on the UML is similar
         that of a host behind a firewall that masquerades all network
         connections passing through it (but is less secure).
-       
+
         To use this you should first have slirp compiled somewhere
         accessible on the host, and have read its documentation.  If you
         don't need UML networking, say N.
-       
+
         Startup example: "eth0=slirp,FE:FD:01:02:03:04,/usr/local/bin/slirp"
 
 endmenu
similarity index 100%
rename from arch/um/Kconfig_scsi
rename to arch/um/Kconfig.scsi
similarity index 83%
rename from arch/um/Kconfig_x86_64
rename to arch/um/Kconfig.x86_64
index 735a047c890cadeb1784246ab92dca64cc5aa441..bd35e59419c8b8ff88aeeb2277a74b875eacc6df 100644 (file)
@@ -6,6 +6,10 @@ config 64BIT
        bool
        default y
 
+config SEMAPHORE_SLEEPERS
+       bool
+       default y
+
 config TOP_ADDR
        hex
        default 0x80000000
@@ -33,3 +37,7 @@ config ARCH_HAS_SC_SIGNALS
 config ARCH_REUSE_HOST_VSYSCALL_AREA
        bool
        default n
+
+config SMP_BROKEN
+       bool
+       default y
index f5a83a72aa75fef618989c92aefa7d551cd674b7..b15f6048caae839cbde7e8fe02ffc8041dbdfc78 100644 (file)
@@ -56,6 +56,7 @@ SYS_DIR               := $(ARCH_DIR)/include/sysdep-$(SUBARCH)
 
 CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
        $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap
+AFLAGS += $(ARCH_INCLUDE)
 
 USER_CFLAGS := $(patsubst -I%,,$(CFLAGS))
 USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \
@@ -101,10 +102,10 @@ define archhelp
 endef
 
 ifneq ($(KBUILD_SRC),)
-$(shell mkdir -p $(ARCH_DIR) && ln -fsn $(srctree)/$(ARCH_DIR)/Kconfig_$(SUBARCH) $(ARCH_DIR)/Kconfig_arch)
-CLEAN_FILES += $(ARCH_DIR)/Kconfig_arch
+$(shell mkdir -p $(ARCH_DIR) && ln -fsn $(srctree)/$(ARCH_DIR)/Kconfig.$(SUBARCH) $(ARCH_DIR)/Kconfig.arch)
+CLEAN_FILES += $(ARCH_DIR)/Kconfig.arch
 else
-$(shell cd $(ARCH_DIR) && ln -sf Kconfig_$(SUBARCH) Kconfig_arch)
+$(shell cd $(ARCH_DIR) && ln -sf Kconfig.$(SUBARCH) Kconfig.arch)
 endif
 
 prepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS)
@@ -147,7 +148,7 @@ CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/include/uml-config.h \
 
 MRPROPER_FILES += $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) \
        $(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS)) $(ARCH_DIR)/os \
-       $(ARCH_DIR)/Kconfig_arch
+       $(ARCH_DIR)/Kconfig.arch
 
 archclean:
        $(Q)$(MAKE) $(clean)=$(ARCH_DIR)/util
index aa2f7174ebca428f4674cdba4f684e8c20c23ba7..baddb5d64ca56ead6f3c1faee0670709e9f0d2d9 100644 (file)
@@ -6,7 +6,7 @@ START := 0x60000000
 
 #We #undef __x86_64__ for kernelspace, not for userspace where
 #it's needed for headers to work!
-CFLAGS += -U__$(SUBARCH)__ -fno-builtin $(STUB_CFLAGS)
+CFLAGS += -U__$(SUBARCH)__ -fno-builtin
 USER_CFLAGS += -fno-builtin
 
 ELF_ARCH := i386:x86-64
index de17d4c6e02db13309752ca26a99c2536f5f0163..783e18cae090ec1d1c77e0cafc05cfd5fa703608 100644 (file)
@@ -13,7 +13,7 @@ mcast-objs := mcast_kern.o mcast_user.o
 net-objs := net_kern.o net_user.o
 mconsole-objs := mconsole_kern.o mconsole_user.o
 hostaudio-objs := hostaudio_kern.o
-ubd-objs := ubd_kern.o ubd_user.o
+ubd-objs := ubd_kern.o
 port-objs := port_kern.o port_user.o
 harddog-objs := harddog_kern.o harddog_user.o
 
index 5d3768156c92b3a9653ac022ce6b9c1f3f486719..de3bce71aeb3e8f3b3d283da35a77949a6444022 100644 (file)
@@ -63,7 +63,7 @@ error:
  *
  * SIGWINCH can't be received synchronously, so you have to set up to receive it
  * as a signal.  That being the case, if you are going to wait for it, it is
- * convenient to sit in a pause() and wait for the signal to bounce you out of
+ * convenient to sit in sigsuspend() and wait for the signal to bounce you out of
  * it (see below for how we make sure to exit only on SIGWINCH).
  */
 
@@ -94,18 +94,19 @@ static int winch_thread(void *arg)
                       "byte, err = %d\n", -count);
 
        /* We are not using SIG_IGN on purpose, so don't fix it as I thought to
-        * do! If using SIG_IGN, the pause() call below would not stop on
+        * do! If using SIG_IGN, the sigsuspend() call below would not stop on
         * SIGWINCH. */
 
        signal(SIGWINCH, winch_handler);
        sigfillset(&sigs);
-       sigdelset(&sigs, SIGWINCH);
-       /* Block anything else than SIGWINCH. */
+       /* Block all signals possible. */
        if(sigprocmask(SIG_SETMASK, &sigs, NULL) < 0){
                printk("winch_thread : sigprocmask failed, errno = %d\n", 
                       errno);
                exit(1);
        }
+       /* In sigsuspend(), block anything else than SIGWINCH. */
+       sigdelset(&sigs, SIGWINCH);
 
        if(setsid() < 0){
                printk("winch_thread : setsid failed, errno = %d\n", errno);
@@ -130,7 +131,7 @@ static int winch_thread(void *arg)
        while(1){
                /* This will be interrupted by SIGWINCH only, since other signals
                 * are blocked.*/
-               pause();
+               sigsuspend(&sigs);
 
                count = os_write_file(pipe_fd, &c, sizeof(c));
                if(count != sizeof(c))
index 344b24d09a7c07a773f81ab99ab6b4688675b6d9..e77a38da4350d6b4abdccfd3cab1c1d5755c3864 100644 (file)
@@ -35,6 +35,7 @@
 #include "linux/blkpg.h"
 #include "linux/genhd.h"
 #include "linux/spinlock.h"
+#include "asm/atomic.h"
 #include "asm/segment.h"
 #include "asm/uaccess.h"
 #include "asm/irq.h"
 #include "mem.h"
 #include "mem_kern.h"
 #include "cow.h"
+#include "aio.h"
 
 enum ubd_req { UBD_READ, UBD_WRITE };
 
 struct io_thread_req {
-       enum ubd_req op;
+       enum aio_type op;
        int fds[2];
        unsigned long offsets[2];
        unsigned long long offset;
        unsigned long length;
        char *buffer;
        int sectorsize;
-       unsigned long sector_mask;
-       unsigned long long cow_offset;
-       unsigned long bitmap_words[2];
+       int bitmap_offset;
+       long bitmap_start;
+       long bitmap_end;
        int error;
 };
 
@@ -80,28 +82,31 @@ extern int create_cow_file(char *cow_file, char *backing_file,
                           unsigned long *bitmap_len_out,
                           int *data_offset_out);
 extern int read_cow_bitmap(int fd, void *buf, int offset, int len);
-extern void do_io(struct io_thread_req *req);
+extern void do_io(struct io_thread_req *req, struct request *r,
+                 unsigned long *bitmap);
 
-static inline int ubd_test_bit(__u64 bit, unsigned char *data)
+static inline int ubd_test_bit(__u64 bit, void *data)
 {
+       unsigned char *buffer = data;
        __u64 n;
        int bits, off;
 
-       bits = sizeof(data[0]) * 8;
+       bits = sizeof(buffer[0]) * 8;
        n = bit / bits;
        off = bit % bits;
-       return((data[n] & (1 << off)) != 0);
+       return((buffer[n] & (1 << off)) != 0);
 }
 
-static inline void ubd_set_bit(__u64 bit, unsigned char *data)
+static inline void ubd_set_bit(__u64 bit, void *data)
 {
+       unsigned char *buffer = data;
        __u64 n;
        int bits, off;
 
-       bits = sizeof(data[0]) * 8;
+       bits = sizeof(buffer[0]) * 8;
        n = bit / bits;
        off = bit % bits;
-       data[n] |= (1 << off);
+       buffer[n] |= (1 << off);
 }
 /*End stuff from ubd_user.h*/
 
@@ -110,8 +115,6 @@ static inline void ubd_set_bit(__u64 bit, unsigned char *data)
 static DEFINE_SPINLOCK(ubd_io_lock);
 static DEFINE_SPINLOCK(ubd_lock);
 
-static void (*do_ubd)(void);
-
 static int ubd_open(struct inode * inode, struct file * filp);
 static int ubd_release(struct inode * inode, struct file * file);
 static int ubd_ioctl(struct inode * inode, struct file * file,
@@ -158,6 +161,8 @@ struct cow {
         int data_offset;
 };
 
+#define MAX_SG 64
+
 struct ubd {
        char *file;
        int count;
@@ -168,6 +173,7 @@ struct ubd {
        int no_cow;
        struct cow cow;
        struct platform_device pdev;
+        struct scatterlist sg[MAX_SG];
 };
 
 #define DEFAULT_COW { \
@@ -460,80 +466,113 @@ __uml_help(fakehd,
 );
 
 static void do_ubd_request(request_queue_t * q);
-
-/* Only changed by ubd_init, which is an initcall. */
-int thread_fd = -1;
+static int in_ubd;
 
 /* Changed by ubd_handler, which is serialized because interrupts only
  * happen on CPU 0.
  */
 int intr_count = 0;
 
-/* call ubd_finish if you need to serialize */
-static void __ubd_finish(struct request *req, int error)
+static void ubd_end_request(struct request *req, int bytes, int uptodate)
 {
-       int nsect;
-
-       if(error){
-               end_request(req, 0);
-               return;
+       if (!end_that_request_first(req, uptodate, bytes >> 9)) {
+               add_disk_randomness(req->rq_disk);
+               end_that_request_last(req);
        }
-       nsect = req->current_nr_sectors;
-       req->sector += nsect;
-       req->buffer += nsect << 9;
-       req->errors = 0;
-       req->nr_sectors -= nsect;
-       req->current_nr_sectors = 0;
-       end_request(req, 1);
 }
 
-static inline void ubd_finish(struct request *req, int error)
+/* call ubd_finish if you need to serialize */
+static void __ubd_finish(struct request *req, int bytes)
 {
-       spin_lock(&ubd_io_lock);
-       __ubd_finish(req, error);
-       spin_unlock(&ubd_io_lock);
+       if(bytes < 0){
+               ubd_end_request(req, 0, 0);
+               return;
+       }
+
+       ubd_end_request(req, bytes, 1);
 }
 
-/* Called without ubd_io_lock held */
-static void ubd_handler(void)
+static inline void ubd_finish(struct request *req, int bytes)
 {
-       struct io_thread_req req;
-       struct request *rq = elv_next_request(ubd_queue);
-       int n;
-
-       do_ubd = NULL;
-       intr_count++;
-       n = os_read_file(thread_fd, &req, sizeof(req));
-       if(n != sizeof(req)){
-               printk(KERN_ERR "Pid %d - spurious interrupt in ubd_handler, "
-                      "err = %d\n", os_getpid(), -n);
-               spin_lock(&ubd_io_lock);
-               end_request(rq, 0);
-               spin_unlock(&ubd_io_lock);
-               return;
-       }
-        
-       ubd_finish(rq, req.error);
-       reactivate_fd(thread_fd, UBD_IRQ);      
-       do_ubd_request(ubd_queue);
+       spin_lock(&ubd_io_lock);
+       __ubd_finish(req, bytes);
+       spin_unlock(&ubd_io_lock);
 }
 
+struct bitmap_io {
+        atomic_t count;
+        struct aio_context aio;
+};
+
+struct ubd_aio {
+        struct aio_context aio;
+        struct request *req;
+        int len;
+        struct bitmap_io *bitmap;
+        void *bitmap_buf;
+};
+
+static int ubd_reply_fd = -1;
+
 static irqreturn_t ubd_intr(int irq, void *dev, struct pt_regs *unused)
 {
-       ubd_handler();
-       return(IRQ_HANDLED);
-}
+       struct aio_thread_reply reply;
+       struct ubd_aio *aio;
+       struct request *req;
+       int err, n, fd = (int) (long) dev;
+
+       while(1){
+               err = os_read_file(fd, &reply, sizeof(reply));
+               if(err == -EAGAIN)
+                       break;
+               if(err < 0){
+                       printk("ubd_aio_handler - read returned err %d\n",
+                              -err);
+                       break;
+               }
 
-/* Only changed by ubd_init, which is an initcall. */
-static int io_pid = -1;
+                aio = container_of(reply.data, struct ubd_aio, aio);
+                n = reply.err;
 
-void kill_io_thread(void)
-{
-       if(io_pid != -1) 
-               os_kill_process(io_pid, 1);
-}
+               if(n == 0){
+                       req = aio->req;
+                       req->nr_sectors -= aio->len >> 9;
+
+                       if((aio->bitmap != NULL) &&
+                          (atomic_dec_and_test(&aio->bitmap->count))){
+                                aio->aio = aio->bitmap->aio;
+                                aio->len = 0;
+                                kfree(aio->bitmap);
+                                aio->bitmap = NULL;
+                                submit_aio(&aio->aio);
+                       }
+                       else {
+                               if((req->nr_sectors == 0) &&
+                                   (aio->bitmap == NULL)){
+                                       int len = req->hard_nr_sectors << 9;
+                                       ubd_finish(req, len);
+                               }
+
+                                if(aio->bitmap_buf != NULL)
+                                        kfree(aio->bitmap_buf);
+                               kfree(aio);
+                       }
+               }
+                else if(n < 0){
+                        ubd_finish(aio->req, n);
+                        if(aio->bitmap != NULL)
+                                kfree(aio->bitmap);
+                        if(aio->bitmap_buf != NULL)
+                                kfree(aio->bitmap_buf);
+                        kfree(aio);
+                }
+       }
+       reactivate_fd(fd, UBD_IRQ);
 
-__uml_exitcall(kill_io_thread);
+        do_ubd_request(ubd_queue);
+
+       return(IRQ_HANDLED);
+}
 
 static int ubd_file_size(struct ubd *dev, __u64 *size_out)
 {
@@ -569,7 +608,7 @@ static int ubd_open_dev(struct ubd *dev)
                                &dev->cow.data_offset, create_ptr);
 
        if((dev->fd == -ENOENT) && create_cow){
-               dev->fd = create_cow_file(dev->file, dev->cow.file, 
+               dev->fd = create_cow_file(dev->file, dev->cow.file,
                                          dev->openflags, 1 << 9, PAGE_SIZE,
                                          &dev->cow.bitmap_offset, 
                                          &dev->cow.bitmap_len,
@@ -668,21 +707,22 @@ static int ubd_add(int n)
        struct ubd *dev = &ubd_dev[n];
        int err;
 
+       err = -ENODEV;
        if(dev->file == NULL)
-               return(-ENODEV);
+               goto out;
 
        if (ubd_open_dev(dev))
-               return(-ENODEV);
+               goto out;
 
        err = ubd_file_size(dev, &dev->size);
        if(err < 0)
-               return(err);
+               goto out_close;
 
        dev->size = ROUND_BLOCK(dev->size);
 
        err = ubd_new_disk(MAJOR_NR, dev->size, n, &ubd_gendisk[n]);
        if(err) 
-               return(err);
+               goto out_close;
  
        if(fake_major != MAJOR_NR)
                ubd_new_disk(fake_major, dev->size, n, 
@@ -693,8 +733,11 @@ static int ubd_add(int n)
        if (fake_ide)
                make_ide_entries(ubd_gendisk[n]->disk_name);
 
+       err = 0;
+out_close:
        ubd_close(dev);
-       return 0;
+out:
+       return err;
 }
 
 static int ubd_config(char *str)
@@ -827,6 +870,10 @@ int ubd_init(void)
 {
         int i;
 
+       ubd_reply_fd = init_aio_irq(UBD_IRQ, "ubd", ubd_intr);
+       if(ubd_reply_fd < 0)
+               printk("Setting up ubd AIO failed, err = %d\n", ubd_reply_fd);
+
        devfs_mk_dir("ubd");
        if (register_blkdev(MAJOR_NR, "ubd"))
                return -1;
@@ -837,6 +884,7 @@ int ubd_init(void)
                return -1;
        }
                
+       blk_queue_max_hw_segments(ubd_queue, MAX_SG);
        if (fake_major != MAJOR_NR) {
                char name[sizeof("ubd_nnn\0")];
 
@@ -848,40 +896,12 @@ int ubd_init(void)
        driver_register(&ubd_driver);
        for (i = 0; i < MAX_DEV; i++) 
                ubd_add(i);
+
        return 0;
 }
 
 late_initcall(ubd_init);
 
-int ubd_driver_init(void){
-       unsigned long stack;
-       int err;
-
-       /* Set by CONFIG_BLK_DEV_UBD_SYNC or ubd=sync.*/
-       if(global_openflags.s){
-               printk(KERN_INFO "ubd: Synchronous mode\n");
-               /* Letting ubd=sync be like using ubd#s= instead of ubd#= is
-                * enough. So use anyway the io thread. */
-       }
-       stack = alloc_stack(0, 0);
-       io_pid = start_io_thread(stack + PAGE_SIZE - sizeof(void *), 
-                                &thread_fd);
-       if(io_pid < 0){
-               printk(KERN_ERR 
-                      "ubd : Failed to start I/O thread (errno = %d) - "
-                      "falling back to synchronous I/O\n", -io_pid);
-               io_pid = -1;
-               return(0);
-       }
-       err = um_request_irq(UBD_IRQ, thread_fd, IRQ_READ, ubd_intr, 
-                            SA_INTERRUPT, "ubd", ubd_dev);
-       if(err != 0)
-               printk(KERN_ERR "um_request_irq failed - errno = %d\n", -err);
-       return(err);
-}
-
-device_initcall(ubd_driver_init);
-
 static int ubd_open(struct inode *inode, struct file *filp)
 {
        struct gendisk *disk = inode->i_bdev->bd_disk;
@@ -919,105 +939,55 @@ static int ubd_release(struct inode * inode, struct file * file)
        return(0);
 }
 
-static void cowify_bitmap(__u64 io_offset, int length, unsigned long *cow_mask,
-                         __u64 *cow_offset, unsigned long *bitmap,
-                         __u64 bitmap_offset, unsigned long *bitmap_words,
-                         __u64 bitmap_len)
+static void cowify_bitmap(struct io_thread_req *req, unsigned long *bitmap)
 {
-       __u64 sector = io_offset >> 9;
-       int i, update_bitmap = 0;
-
-       for(i = 0; i < length >> 9; i++){
-               if(cow_mask != NULL)
-                       ubd_set_bit(i, (unsigned char *) cow_mask);
-               if(ubd_test_bit(sector + i, (unsigned char *) bitmap))
-                       continue;
-
-               update_bitmap = 1;
-               ubd_set_bit(sector + i, (unsigned char *) bitmap);
-       }
-
-       if(!update_bitmap)
-               return;
-
-       *cow_offset = sector / (sizeof(unsigned long) * 8);
-
-       /* This takes care of the case where we're exactly at the end of the
-        * device, and *cow_offset + 1 is off the end.  So, just back it up
-        * by one word.  Thanks to Lynn Kerby for the fix and James McMechan
-        * for the original diagnosis.
-        */
-       if(*cow_offset == ((bitmap_len + sizeof(unsigned long) - 1) /
-                          sizeof(unsigned long) - 1))
-               (*cow_offset)--;
-
-       bitmap_words[0] = bitmap[*cow_offset];
-       bitmap_words[1] = bitmap[*cow_offset + 1];
-
-       *cow_offset *= sizeof(unsigned long);
-       *cow_offset += bitmap_offset;
-}
+        __u64 sector = req->offset / req->sectorsize;
+        int i;
 
-static void cowify_req(struct io_thread_req *req, unsigned long *bitmap,
-                      __u64 bitmap_offset, __u64 bitmap_len)
-{
-       __u64 sector = req->offset >> 9;
-       int i;
+        for(i = 0; i < req->length / req->sectorsize; i++){
+                if(ubd_test_bit(sector + i, bitmap))
+                        continue;
 
-       if(req->length > (sizeof(req->sector_mask) * 8) << 9)
-               panic("Operation too long");
+                if(req->bitmap_start == -1)
+                        req->bitmap_start = sector + i;
+                req->bitmap_end = sector + i + 1;
 
-       if(req->op == UBD_READ) {
-               for(i = 0; i < req->length >> 9; i++){
-                       if(ubd_test_bit(sector + i, (unsigned char *) bitmap))
-                               ubd_set_bit(i, (unsigned char *) 
-                                           &req->sector_mask);
-                }
-       }
-       else cowify_bitmap(req->offset, req->length, &req->sector_mask,
-                          &req->cow_offset, bitmap, bitmap_offset,
-                          req->bitmap_words, bitmap_len);
+                ubd_set_bit(sector + i, bitmap);
+        }
 }
 
 /* Called with ubd_io_lock held */
-static int prepare_request(struct request *req, struct io_thread_req *io_req)
+static int prepare_request(struct request *req, struct io_thread_req *io_req,
+                           unsigned long long offset, int page_offset,
+                           int len, struct page *page)
 {
        struct gendisk *disk = req->rq_disk;
        struct ubd *dev = disk->private_data;
-       __u64 offset;
-       int len;
-
-       if(req->rq_status == RQ_INACTIVE) return(1);
 
        /* This should be impossible now */
        if((rq_data_dir(req) == WRITE) && !dev->openflags.w){
                printk("Write attempted on readonly ubd device %s\n", 
                       disk->disk_name);
-               end_request(req, 0);
+                ubd_end_request(req, 0, 0);
                return(1);
        }
 
-       offset = ((__u64) req->sector) << 9;
-       len = req->current_nr_sectors << 9;
-
        io_req->fds[0] = (dev->cow.file != NULL) ? dev->cow.fd : dev->fd;
        io_req->fds[1] = dev->fd;
-       io_req->cow_offset = -1;
        io_req->offset = offset;
        io_req->length = len;
        io_req->error = 0;
-       io_req->sector_mask = 0;
-
-       io_req->op = (rq_data_dir(req) == READ) ? UBD_READ : UBD_WRITE;
+       io_req->op = (rq_data_dir(req) == READ) ? AIO_READ : AIO_WRITE;
        io_req->offsets[0] = 0;
        io_req->offsets[1] = dev->cow.data_offset;
-       io_req->buffer = req->buffer;
+        io_req->buffer = page_address(page) + page_offset;
        io_req->sectorsize = 1 << 9;
+        io_req->bitmap_offset = dev->cow.bitmap_offset;
+        io_req->bitmap_start = -1;
+        io_req->bitmap_end = -1;
 
-       if(dev->cow.file != NULL)
-               cowify_req(io_req, dev->cow.bitmap, dev->cow.bitmap_offset,
-                          dev->cow.bitmap_len);
-
+        if((dev->cow.file != NULL) && (io_req->op == UBD_WRITE))
+                cowify_bitmap(io_req, dev->cow.bitmap);
        return(0);
 }
 
@@ -1026,30 +996,36 @@ static void do_ubd_request(request_queue_t *q)
 {
        struct io_thread_req io_req;
        struct request *req;
-       int err, n;
-
-       if(thread_fd == -1){
-               while((req = elv_next_request(q)) != NULL){
-                       err = prepare_request(req, &io_req);
-                       if(!err){
-                               do_io(&io_req);
-                               __ubd_finish(req, io_req.error);
-                       }
-               }
-       }
-       else {
-               if(do_ubd || (req = elv_next_request(q)) == NULL)
-                       return;
-               err = prepare_request(req, &io_req);
-               if(!err){
-                       do_ubd = ubd_handler;
-                       n = os_write_file(thread_fd, (char *) &io_req,
-                                        sizeof(io_req));
-                       if(n != sizeof(io_req))
-                               printk("write to io thread failed, "
-                                      "errno = %d\n", -n);
+       __u64 sector;
+       int err;
+
+       if(in_ubd)
+               return;
+       in_ubd = 1;
+       while((req = elv_next_request(q)) != NULL){
+               struct gendisk *disk = req->rq_disk;
+               struct ubd *dev = disk->private_data;
+               int n, i;
+
+               blkdev_dequeue_request(req);
+
+               sector = req->sector;
+               n = blk_rq_map_sg(q, req, dev->sg);
+
+               for(i = 0; i < n; i++){
+                       struct scatterlist *sg = &dev->sg[i];
+
+                       err = prepare_request(req, &io_req, sector << 9,
+                                             sg->offset, sg->length,
+                                             sg->page);
+                       if(err)
+                               continue;
+
+                       sector += sg->length >> 9;
+                       do_io(&io_req, req, dev->cow.bitmap);
                }
        }
+       in_ubd = 0;
 }
 
 static int ubd_ioctl(struct inode * inode, struct file * file,
@@ -1265,131 +1241,95 @@ int create_cow_file(char *cow_file, char *backing_file, struct openflags flags,
        return(err);
 }
 
-static int update_bitmap(struct io_thread_req *req)
-{
-       int n;
-
-       if(req->cow_offset == -1)
-               return(0);
-
-       n = os_seek_file(req->fds[1], req->cow_offset);
-       if(n < 0){
-               printk("do_io - bitmap lseek failed : err = %d\n", -n);
-               return(1);
-       }
-
-       n = os_write_file(req->fds[1], &req->bitmap_words,
-                         sizeof(req->bitmap_words));
-       if(n != sizeof(req->bitmap_words)){
-               printk("do_io - bitmap update failed, err = %d fd = %d\n", -n,
-                      req->fds[1]);
-               return(1);
-       }
-
-       return(0);
-}
-
-void do_io(struct io_thread_req *req)
+void do_io(struct io_thread_req *req, struct request *r, unsigned long *bitmap)
 {
-       char *buf;
-       unsigned long len;
-       int n, nsectors, start, end, bit;
-       int err;
-       __u64 off;
-
-       nsectors = req->length / req->sectorsize;
-       start = 0;
-       do {
-               bit = ubd_test_bit(start, (unsigned char *) &req->sector_mask);
-               end = start;
-               while((end < nsectors) &&
-                     (ubd_test_bit(end, (unsigned char *)
-                                   &req->sector_mask) == bit))
-                       end++;
-
-               off = req->offset + req->offsets[bit] +
-                       start * req->sectorsize;
-               len = (end - start) * req->sectorsize;
-               buf = &req->buffer[start * req->sectorsize];
-
-               err = os_seek_file(req->fds[bit], off);
-               if(err < 0){
-                       printk("do_io - lseek failed : err = %d\n", -err);
-                       req->error = 1;
-                       return;
-               }
-               if(req->op == UBD_READ){
-                       n = 0;
-                       do {
-                               buf = &buf[n];
-                               len -= n;
-                               n = os_read_file(req->fds[bit], buf, len);
-                               if (n < 0) {
-                                       printk("do_io - read failed, err = %d "
-                                              "fd = %d\n", -n, req->fds[bit]);
-                                       req->error = 1;
-                                       return;
-                               }
-                       } while((n < len) && (n != 0));
-                       if (n < len) memset(&buf[n], 0, len - n);
-               } else {
-                       n = os_write_file(req->fds[bit], buf, len);
-                       if(n != len){
-                               printk("do_io - write failed err = %d "
-                                      "fd = %d\n", -n, req->fds[bit]);
-                               req->error = 1;
-                               return;
-                       }
-               }
+        struct ubd_aio *aio;
+        struct bitmap_io *bitmap_io = NULL;
+        char *buf;
+        void *bitmap_buf = NULL;
+        unsigned long len, sector;
+        int nsectors, start, end, bit, err;
+        __u64 off;
+
+        if(req->bitmap_start != -1){
+                /* Round up to the nearest word */
+                int round = sizeof(unsigned long);
+                len = (req->bitmap_end - req->bitmap_start +
+                       round * 8 - 1) / (round * 8);
+                len *= round;
+
+                off = req->bitmap_start / (8 * round);
+                off *= round;
+
+                bitmap_io = kmalloc(sizeof(*bitmap_io), GFP_KERNEL);
+                if(bitmap_io == NULL){
+                        printk("Failed to kmalloc bitmap IO\n");
+                        req->error = 1;
+                        return;
+                }
 
-               start = end;
-       } while(start < nsectors);
+                bitmap_buf = kmalloc(len, GFP_KERNEL);
+                if(bitmap_buf == NULL){
+                        printk("do_io : kmalloc of bitmap chunk "
+                               "failed\n");
+                        kfree(bitmap_io);
+                        req->error = 1;
+                        return;
+                }
+                memcpy(bitmap_buf, &bitmap[off / sizeof(bitmap[0])], len);
+
+                *bitmap_io = ((struct bitmap_io)
+                        { .count       = ATOMIC_INIT(0),
+                          .aio         = INIT_AIO(AIO_WRITE, req->fds[1],
+                                                   bitmap_buf, len,
+                                                   req->bitmap_offset + off,
+                                                   ubd_reply_fd) } );
+        }
 
-       req->error = update_bitmap(req);
-}
+        nsectors = req->length / req->sectorsize;
+        start = 0;
+        end = nsectors;
+        bit = 0;
+        do {
+                if(bitmap != NULL){
+                        sector = req->offset / req->sectorsize;
+                        bit = ubd_test_bit(sector + start, bitmap);
+                        end = start;
+                        while((end < nsectors) &&
+                              (ubd_test_bit(sector + end, bitmap) == bit))
+                                end++;
+                }
 
-/* Changed in start_io_thread, which is serialized by being called only
- * from ubd_init, which is an initcall.
- */
-int kernel_fd = -1;
+                off = req->offsets[bit] + req->offset +
+                        start * req->sectorsize;
+                len = (end - start) * req->sectorsize;
+                buf = &req->buffer[start * req->sectorsize];
 
-/* Only changed by the io thread */
-int io_count = 0;
+                aio = kmalloc(sizeof(*aio), GFP_KERNEL);
+                if(aio == NULL){
+                        req->error = 1;
+                        return;
+                }
 
-int io_thread(void *arg)
-{
-       struct io_thread_req req;
-       int n;
+                *aio = ((struct ubd_aio)
+                        { .aio         = INIT_AIO(req->op, req->fds[bit], buf,
+                                                   len, off, ubd_reply_fd),
+                          .len         = len,
+                          .req         = r,
+                          .bitmap      = bitmap_io,
+                          .bitmap_buf  = bitmap_buf });
+
+                if(aio->bitmap != NULL)
+                        atomic_inc(&aio->bitmap->count);
+
+                err = submit_aio(&aio->aio);
+                if(err){
+                        printk("do_io - submit_aio failed, "
+                               "err = %d\n", err);
+                        req->error = 1;
+                        return;
+                }
 
-       ignore_sigwinch_sig();
-       while(1){
-               n = os_read_file(kernel_fd, &req, sizeof(req));
-               if(n != sizeof(req)){
-                       if(n < 0)
-                               printk("io_thread - read failed, fd = %d, "
-                                      "err = %d\n", kernel_fd, -n);
-                       else {
-                               printk("io_thread - short read, fd = %d, "
-                                      "length = %d\n", kernel_fd, n);
-                       }
-                       continue;
-               }
-               io_count++;
-               do_io(&req);
-               n = os_write_file(kernel_fd, &req, sizeof(req));
-               if(n != sizeof(req))
-                       printk("io_thread - write failed, fd = %d, err = %d\n",
-                              kernel_fd, -n);
-       }
+                start = end;
+        } while(start < nsectors);
 }
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/include/aio.h b/arch/um/include/aio.h
new file mode 100644 (file)
index 0000000..83f1687
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2004 Jeff Dike (jdike@karaya.com)
+ * Licensed under the GPL
+ */
+
+#ifndef AIO_H__
+#define AIO_H__
+
+enum aio_type { AIO_READ, AIO_WRITE, AIO_MMAP };
+
+struct aio_thread_reply {
+       void *data;
+       int err;
+};
+
+struct aio_context {
+       enum aio_type type;
+       int fd;
+       void *data;
+       int len;
+       unsigned long long offset;
+       int reply_fd;
+       struct aio_context *next;
+};
+
+#define INIT_AIO(aio_type, aio_fd, aio_data, aio_len, aio_offset, \
+                aio_reply_fd) \
+       { .type         = aio_type, \
+         .fd           = aio_fd, \
+         .data         = aio_data, \
+         .len          = aio_len, \
+         .offset       = aio_offset, \
+         .reply_fd     = aio_reply_fd }
+
+#define INIT_AIO_CONTEXT { .reply_fd   = -1, \
+                          .next        = NULL }
+
+extern int submit_aio(struct aio_context *aio);
+
+#endif
index 55c2693f877827abab61514a648c8ee20ce7d98b..cbd79a8d213dc4532b8f760d3b1ca207fa98b3f1 100644 (file)
@@ -111,7 +111,15 @@ extern struct uml_param __uml_setup_start, __uml_setup_end;
 
 #ifndef __KERNEL__
 
-#define __initcall(fn) static initcall_t __initcall_##fn __init_call = fn
+#define __define_initcall(level,fn) \
+       static initcall_t __initcall_##fn __attribute_used__ \
+       __attribute__((__section__(".initcall" level ".init"))) = fn
+
+/* Userspace initcalls shouldn't depend on anything in the kernel, so we'll
+ * make them run first.
+ */
+#define __initcall(fn) __define_initcall("1", fn)
+
 #define __exitcall(fn) static exitcall_t __exitcall_##fn __exit_call = fn
 
 #define __init_call __attribute__ ((unused,__section__ (".initcall.init")))
index 3af52a634c4c2c5b9d8eb16cd93b1cd879e91e6d..c222d56b14940192c9a1b8eb659e8c966a4fb656 100644 (file)
@@ -7,12 +7,15 @@
 #define __IRQ_KERN_H__
 
 #include "linux/interrupt.h"
+#include "asm/ptrace.h"
 
 extern int um_request_irq(unsigned int irq, int fd, int type,
                          irqreturn_t (*handler)(int, void *,
                                                 struct pt_regs *),
                          unsigned long irqflags,  const char * devname,
                          void *dev_id);
+extern int init_aio_irq(int irq, char *name,
+                       irqreturn_t (*handler)(int, void *, struct pt_regs *));
 
 #endif
 
index 881d2988d2d80ef2564a41309edf0c93099f4edd..4c362458052cb3acf0d8a80256122e122b226f01 100644 (file)
@@ -153,6 +153,11 @@ extern int os_file_type(char *file);
 extern int os_file_mode(char *file, struct openflags *mode_out);
 extern int os_lock_file(int fd, int excl);
 
+/* start_up.c */
+extern void os_early_checks(void);
+extern int can_do_skas(void);
+
+/* process.c */
 extern unsigned long os_process_pc(int pid);
 extern int os_process_parent(int pid);
 extern void os_stop_process(int pid);
@@ -161,6 +166,9 @@ extern void os_kill_ptraced_process(int pid, int reap_child);
 extern void os_usr1_process(int pid);
 extern int os_getpid(void);
 extern int os_getpgrp(void);
+extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int));
+extern void init_new_thread_signals(int altstack);
+extern int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr);
 
 extern int os_map_memory(void *virt, int fd, unsigned long long off,
                         unsigned long len, int r, int w, int x);
@@ -170,6 +178,13 @@ extern int os_unmap_memory(void *addr, int len);
 extern void os_flush_stdout(void);
 extern unsigned long long os_usecs(void);
 
+/* tt.c
+ * for tt mode only (will be deleted in future...)
+ */
+extern void forward_pending_sigio(int target);
+extern int start_fork_tramp(void *arg, unsigned long temp_stack,
+                           int clone_flags, int (*tramp)(void *));
+
 #endif
 
 /*
diff --git a/arch/um/include/syscall.h b/arch/um/include/syscall.h
new file mode 100644 (file)
index 0000000..dda1df9
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Licensed under the GPL
+ */
+
+#ifndef __SYSCALL_USER_H
+#define __SYSCALL_USER_H
+
+extern int record_syscall_start(int syscall);
+extern void record_syscall_end(int index, long result);
+
+#endif
diff --git a/arch/um/include/syscall_user.h b/arch/um/include/syscall_user.h
deleted file mode 100644 (file)
index 811d0ec..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __SYSCALL_USER_H
-#define __SYSCALL_USER_H
-
-extern int record_syscall_start(int syscall);
-extern void record_syscall_end(int index, long result);
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index be0a3e3469ebd2a3d2c2350a9cef6fbea969d254..a0d5b74d3731f41f0b7b03138c882557dc022bb1 100644 (file)
@@ -16,6 +16,8 @@ extern syscall_handler_t sys_rt_sigaction;
 
 extern syscall_handler_t old_mmap_i386;
 
+extern syscall_handler_t *sys_call_table[];
+
 #define EXECUTE_SYSCALL(syscall, regs) \
        ((long (*)(struct syscall_args)) (*sys_call_table[syscall]))(SYSCALL_ARGS(&regs->regs))
 
index be8acd5efd974ac9a3b36a2b3a7703d332900996..331aa2d1f3f5469f04c0fa9bbefe0a15934edde0 100644 (file)
@@ -227,7 +227,7 @@ struct syscall_args {
                         panic("Bad register in UPT_SET : %d\n", reg);  \
                        break; \
                 } \
-                val; \
+                __upt_val; \
         })
 
 #define UPT_SET_SYSCALL_RETURN(r, res) \
index 67923cca5691952194da13faa048c94c16f560e2..e06f83e80f4a9e8aa57d5cf5ff26cd455e367d89 100644 (file)
@@ -14,6 +14,8 @@ typedef long syscall_handler_t(void);
 
 extern syscall_handler_t *ia32_sys_call_table[];
 
+extern syscall_handler_t *sys_call_table[];
+
 #define EXECUTE_SYSCALL(syscall, regs) \
        (((long (*)(long, long, long, long, long, long)) \
          (*sys_call_table[syscall]))(UPT_SYSCALL_ARG1(&regs->regs), \
index c6f9628f39bfd159a87df0dd19c07053b536142e..45d7da6c3b2c5a3eb25715e280e2274e32dcf155 100644 (file)
@@ -9,7 +9,7 @@
 #include "um_mmu.h"
 
 struct host_vm_op {
-       enum { MMAP, MUNMAP, MPROTECT } type;
+       enum { NONE, MMAP, MUNMAP, MPROTECT } type;
        union {
                struct {
                        unsigned long addr;
@@ -38,24 +38,10 @@ extern void mprotect_kernel_vm(int w);
 extern void force_flush_all(void);
 extern void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
                              unsigned long end_addr, int force,
-                             void (*do_ops)(union mm_context *,
-                                            struct host_vm_op *, int));
+                            int (*do_ops)(union mm_context *,
+                                          struct host_vm_op *, int, int,
+                                          void **));
 extern int flush_tlb_kernel_range_common(unsigned long start,
                                         unsigned long end);
 
-extern int add_mmap(unsigned long virt, unsigned long phys, unsigned long len,
-                   int r, int w, int x, struct host_vm_op *ops, int index,
-                    int last_filled, union mm_context *mmu,
-                    void (*do_ops)(union mm_context *, struct host_vm_op *,
-                                   int));
-extern int add_munmap(unsigned long addr, unsigned long len,
-                     struct host_vm_op *ops, int index, int last_filled,
-                      union mm_context *mmu,
-                      void (*do_ops)(union mm_context *, struct host_vm_op *,
-                                     int));
-extern int add_mprotect(unsigned long addr, unsigned long len, int r, int w,
-                       int x, struct host_vm_op *ops, int index,
-                        int last_filled, union mm_context *mmu,
-                        void (*do_ops)(union mm_context *, struct host_vm_op *,
-                                       int));
 #endif
index 7b6a24dfd302b7b90388a164c72e6c9ee79219f2..bb505e01d9942140ece4e25f43589d1949a03ec7 100644 (file)
@@ -54,8 +54,6 @@ extern void stack_protections(unsigned long address);
 extern void task_protections(unsigned long address);
 extern int wait_for_stop(int pid, int sig, int cont_type, void *relay);
 extern void *add_signal_handler(int sig, void (*handler)(int));
-extern int start_fork_tramp(void *arg, unsigned long temp_stack, 
-                           int clone_flags, int (*tramp)(void *));
 extern int linux_main(int argc, char **argv);
 extern void set_cmdline(char *cmd);
 extern void input_cb(void (*proc)(void *), void *arg, int arg_len);
@@ -64,8 +62,6 @@ extern void *um_kmalloc(int size);
 extern int switcheroo(int fd, int prot, void *from, void *to, int size);
 extern void setup_machinename(char *machine_out);
 extern void setup_hostinfo(void);
-extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int));
-extern void init_new_thread_signals(int altstack);
 extern void do_exec(int old_pid, int new_pid);
 extern void tracer_panic(char *msg, ...);
 extern char *get_umid(int only_if_set);
@@ -74,16 +70,12 @@ extern int detach(int pid, int sig);
 extern int attach(int pid);
 extern void kill_child_dead(int pid);
 extern int cont(int pid);
-extern void check_ptrace(void);
 extern void check_sigio(void);
-extern int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr);
 extern void write_sigio_workaround(void);
 extern void arch_check_bugs(void);
 extern int cpu_feature(char *what, char *buf, int len);
 extern int arch_handle_signal(int sig, union uml_pt_regs *regs);
 extern int arch_fixup(unsigned long address, void *sc_ptr);
-extern void forward_pending_sigio(int target);
-extern int can_do_skas(void);
 extern void arch_init_thread(void);
 extern int setjmp_wrapper(void (*proc)(void *, void *), ...);
 extern int raw(int fd);
index a8918e80df9623542a7b2cce781c2476b4fb9827..614b8ebeb0ed026a7ee41060eb2f5fd42a3b06c2 100644 (file)
@@ -8,25 +8,24 @@ clean-files :=
 
 obj-y = config.o exec_kern.o exitcode.o \
        helper.o init_task.o irq.o irq_user.o ksyms.o main.o mem.o mem_user.o \
-       physmem.o process.o process_kern.o ptrace.o reboot.o resource.o \
-       sigio_user.o sigio_kern.o signal_kern.o signal_user.o smp.o \
-       syscall_kern.o sysrq.o tempfile.o time.o time_kern.o \
-       tlb.o trap_kern.o trap_user.o uaccess_user.o um_arch.o umid.o \
-       user_util.o
+       physmem.o process_kern.o ptrace.o reboot.o resource.o sigio_user.o \
+       sigio_kern.o signal_kern.o signal_user.o smp.o syscall_kern.o sysrq.o \
+       tempfile.o time.o time_kern.o tlb.o trap_kern.o trap_user.o \
+       uaccess_user.o um_arch.o umid.o user_util.o
 
 obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
 obj-$(CONFIG_GPROF)    += gprof_syms.o
 obj-$(CONFIG_GCOV)     += gmon_syms.o
 obj-$(CONFIG_TTY_LOG)  += tty_log.o
-obj-$(CONFIG_SYSCALL_DEBUG) += syscall_user.o
+obj-$(CONFIG_SYSCALL_DEBUG) += syscall.o
 
 obj-$(CONFIG_MODE_TT) += tt/
 obj-$(CONFIG_MODE_SKAS) += skas/
 
 user-objs-$(CONFIG_TTY_LOG) += tty_log.o
 
-USER_OBJS := $(user-objs-y) config.o helper.o main.o process.o tempfile.o \
-       time.o tty_log.o umid.o user_util.o
+USER_OBJS := $(user-objs-y) config.o helper.o main.o tempfile.o time.o \
+       tty_log.o umid.o user_util.o
 
 include arch/um/scripts/Makefile.rules
 
index 9f18061ef4c98d16915f7f040709340ed6740ad2..dcd814971995ca858c2ce01667800437c65f43b9 100644 (file)
@@ -31,7 +31,7 @@
 #include "kern_util.h"
 #include "irq_user.h"
 #include "irq_kern.h"
-
+#include "os.h"
 
 /*
  * Generic, controller-independent functions:
@@ -168,13 +168,32 @@ void __init init_IRQ(void)
        }
 }
 
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+int init_aio_irq(int irq, char *name, irqreturn_t (*handler)(int, void *,
+                                                            struct pt_regs *))
+{
+       int fds[2], err;
+
+       err = os_pipe(fds, 1, 1);
+       if(err){
+               printk("init_aio_irq - os_pipe failed, err = %d\n", -err);
+               goto out;
+       }
+
+       err = um_request_irq(irq, fds[0], IRQ_READ, handler,
+                            SA_INTERRUPT | SA_SAMPLE_RANDOM, name,
+                            (void *) (long) fds[0]);
+       if(err){
+               printk("init_aio_irq - : um_request_irq failed, err = %d\n",
+                      err);
+               goto out_close;
+       }
+
+       err = fds[1];
+       goto out;
+
+ out_close:
+       os_close_file(fds[0]);
+       os_close_file(fds[1]);
+ out:
+       return(err);
+}
index 99439fa15ef42514b8e563623f6eaa8238c829cc..32d3076dd2204206e06aed7d835dbc4659c6e47a 100644 (file)
@@ -114,22 +114,3 @@ extern void FASTCALL( __read_lock_failed(rwlock_t *rw));
 EXPORT_SYMBOL(__read_lock_failed);
 
 #endif
-
-#ifdef CONFIG_HIGHMEM
-EXPORT_SYMBOL(kmap);
-EXPORT_SYMBOL(kunmap);
-EXPORT_SYMBOL(kmap_atomic);
-EXPORT_SYMBOL(kunmap_atomic);
-EXPORT_SYMBOL(kmap_atomic_to_page);
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 1e1a87f1c510cbc7a2d3a4ea472bd6395f6e4bb2..d31027f0fe392e9753fbe04e9ef106f719a2b5d4 100644 (file)
@@ -97,7 +97,7 @@ int main(int argc, char **argv, char **envp)
                exit(1);
        }
 
-#ifdef UML_CONFIG_MODE_TT
+#ifdef UML_CONFIG_CMDLINE_ON_HOST
        /* Allocate memory for thread command lines */
        if(argc < 2 || strlen(argv[1]) < THREAD_NAME_LEN - 1){
 
index d296d55ade4b99b9fac4488cb76f3420c9929a2a..db36c7c9594070669c4d328f0221f10f10550ac6 100644 (file)
@@ -4,7 +4,7 @@
 #
 
 obj-y := clone.o exec_kern.o mem.o mem_user.o mmu.o process.o process_kern.o \
-       syscall_kern.o syscall_user.o tlb.o trap_user.o uaccess.o \
+       syscall.o tlb.o trap_user.o uaccess.o
 
 subdir- := util
 
index 278b72f1d9adf5a6c3767dd972ae0bf153da9c06..09536f81ee42f6e527154d5085fa4f73865da114 100644 (file)
@@ -6,11 +6,15 @@
 #ifndef __SKAS_MMU_H
 #define __SKAS_MMU_H
 
+#include "linux/config.h"
 #include "mm_id.h"
 
 struct mmu_context_skas {
        struct mm_id id;
         unsigned long last_page_table;
+#ifdef CONFIG_3_LEVEL_PGTABLES
+        unsigned long last_pmd;
+#endif
 };
 
 extern void switch_mm_skas(struct mm_id * mm_idp);
index d983ea842547fe807fcd5b8c7bc1ca1d51887400..060934740f9f94e65ed1b4dafd2587b9836766ff 100644 (file)
@@ -24,28 +24,26 @@ extern void new_thread_proc(void *stack, void (*handler)(int sig));
 extern void remove_sigstack(void);
 extern void new_thread_handler(int sig);
 extern void handle_syscall(union uml_pt_regs *regs);
-extern int map(struct mm_id * mm_idp, unsigned long virt, unsigned long len,
-               int r, int w, int x, int phys_fd, unsigned long long offset);
-extern int unmap(struct mm_id * mm_idp, void *addr, unsigned long len);
+extern int map(struct mm_id * mm_idp, unsigned long virt,
+              unsigned long len, int r, int w, int x, int phys_fd,
+              unsigned long long offset, int done, void **data);
+extern int unmap(struct mm_id * mm_idp, void *addr, unsigned long len,
+                int done, void **data);
 extern int protect(struct mm_id * mm_idp, unsigned long addr,
-                  unsigned long len, int r, int w, int x);
+                  unsigned long len, int r, int w, int x, int done,
+                  void **data);
 extern void user_signal(int sig, union uml_pt_regs *regs, int pid);
-extern int new_mm(int from);
+extern int new_mm(int from, unsigned long stack);
 extern int start_userspace(unsigned long stub_stack);
 extern int copy_context_skas0(unsigned long stack, int pid);
 extern void get_skas_faultinfo(int pid, struct faultinfo * fi);
 extern long execute_syscall_skas(void *r);
 extern unsigned long current_stub_stack(void);
+extern long run_syscall_stub(struct mm_id * mm_idp,
+                             int syscall, unsigned long *args, long expected,
+                             void **addr, int done);
+extern long syscall_stub_data(struct mm_id * mm_idp,
+                              unsigned long *data, int data_count,
+                              void **addr, void **stub_addr);
 
 #endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index b0980ff3bd95bb14279ad94e2581f91ae725d1ac..1d89640bd5028852c5cf180534a37237ebaed8c3 100644 (file)
@@ -5,13 +5,14 @@
 
 #include <signal.h>
 #include <errno.h>
+#include <string.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
 #include <asm/page.h>
 #include <asm/unistd.h>
 #include "mem_user.h"
 #include "mem.h"
-#include "mm_id.h"
+#include "skas.h"
 #include "user.h"
 #include "os.h"
 #include "proc_mm.h"
 #include "uml-config.h"
 #include "sysdep/ptrace.h"
 #include "sysdep/stub.h"
-#include "skas.h"
 
-extern unsigned long syscall_stub, __syscall_stub_start;
+extern unsigned long batch_syscall_stub, __syscall_stub_start;
 
 extern void wait_stub_done(int pid, int sig, char * fname);
 
-static long run_syscall_stub(struct mm_id * mm_idp, int syscall,
-                             unsigned long *args)
+static inline unsigned long *check_init_stack(struct mm_id * mm_idp,
+                                             unsigned long *stack)
+{
+       if(stack == NULL){
+               stack = (unsigned long *) mm_idp->stack + 2;
+               *stack = 0;
+       }
+       return stack;
+}
+
+extern int proc_mm;
+
+int single_count = 0;
+int multi_count = 0;
+int multi_op_count = 0;
+
+static long do_syscall_stub(struct mm_id *mm_idp, void **addr)
 {
+       unsigned long regs[MAX_REG_NR];
+       unsigned long *data;
+       unsigned long *syscall;
+       long ret, offset;
         int n, pid = mm_idp->u.pid;
-        unsigned long regs[MAX_REG_NR];
+
+       if(proc_mm)
+#warning Need to look up userspace_pid by cpu
+               pid = userspace_pid[0];
+
+       multi_count++;
 
         get_safe_registers(regs);
         regs[REGS_IP_INDEX] = UML_CONFIG_STUB_CODE +
-                ((unsigned long) &syscall_stub -
+               ((unsigned long) &batch_syscall_stub -
                  (unsigned long) &__syscall_stub_start);
-        /* XXX Don't have a define for starting a syscall */
-        regs[REGS_SYSCALL_NR] = syscall;
-        regs[REGS_SYSCALL_ARG1] = args[0];
-        regs[REGS_SYSCALL_ARG2] = args[1];
-        regs[REGS_SYSCALL_ARG3] = args[2];
-        regs[REGS_SYSCALL_ARG4] = args[3];
-        regs[REGS_SYSCALL_ARG5] = args[4];
-        regs[REGS_SYSCALL_ARG6] = args[5];
-        n = ptrace_setregs(pid, regs);
-        if(n < 0){
-                printk("run_syscall_stub : PTRACE_SETREGS failed, "
-                       "errno = %d\n", n);
-                return(n);
+       n = ptrace_setregs(pid, regs);
+       if(n < 0)
+               panic("do_syscall_stub : PTRACE_SETREGS failed, errno = %d\n",
+                     n);
+
+       wait_stub_done(pid, 0, "do_syscall_stub");
+
+       /* When the stub stops, we find the following values on the
+        * beginning of the stack:
+        * (long )return_value
+        * (long )offset to failed sycall-data (0, if no error)
+        */
+       ret = *((unsigned long *) mm_idp->stack);
+       offset = *((unsigned long *) mm_idp->stack + 1);
+       if (offset) {
+               data = (unsigned long *)(mm_idp->stack +
+                                        offset - UML_CONFIG_STUB_DATA);
+               syscall = (unsigned long *)((unsigned long)data + data[0]);
+               printk("do_syscall_stub: syscall %ld failed, return value = "
+                      "0x%lx, expected return value = 0x%lx\n",
+                      syscall[0], ret, syscall[7]);
+               printk("    syscall parameters: "
+                      "0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx\n",
+                      syscall[1], syscall[2], syscall[3],
+                      syscall[4], syscall[5], syscall[6]);
+               for(n = 1; n < data[0]/sizeof(long); n++) {
+                       if(n == 1)
+                               printk("    additional syscall data:");
+                       if(n % 4 == 1)
+                               printk("\n      ");
+                       printk("  0x%lx", data[n]);
+               }
+               if(n > 1)
+                       printk("\n");
+       }
+       else ret = 0;
+
+       *addr = check_init_stack(mm_idp, NULL);
+
+       return ret;
+}
+
+long run_syscall_stub(struct mm_id * mm_idp, int syscall,
+                     unsigned long *args, long expected, void **addr,
+                     int done)
+{
+       unsigned long *stack = check_init_stack(mm_idp, *addr);
+
+       if(done && *addr == NULL)
+               single_count++;
+
+       *stack += sizeof(long);
+       stack += *stack / sizeof(long);
+
+        *stack++ = syscall;
+        *stack++ = args[0];
+        *stack++ = args[1];
+        *stack++ = args[2];
+        *stack++ = args[3];
+        *stack++ = args[4];
+        *stack++ = args[5];
+       *stack++ = expected;
+        *stack = 0;
+        multi_op_count++;
+
+        if(!done && ((((unsigned long) stack) & ~PAGE_MASK) <
+                    PAGE_SIZE - 10 * sizeof(long))){
+               *addr = stack;
+                return 0;
         }
 
-        wait_stub_done(pid, 0, "run_syscall_stub");
+       return do_syscall_stub(mm_idp, addr);
+}
+
+long syscall_stub_data(struct mm_id * mm_idp,
+                      unsigned long *data, int data_count,
+                      void **addr, void **stub_addr)
+{
+       unsigned long *stack;
+       int ret = 0;
 
-        return(*((unsigned long *) mm_idp->stack));
+       /* If *addr still is uninitialized, it *must* contain NULL.
+        * Thus in this case do_syscall_stub correctly won't be called.
+        */
+       if((((unsigned long) *addr) & ~PAGE_MASK) >=
+          PAGE_SIZE - (10 + data_count) * sizeof(long)) {
+               ret = do_syscall_stub(mm_idp, addr);
+               /* in case of error, don't overwrite data on stack */
+               if(ret)
+                       return ret;
+       }
+
+       stack = check_init_stack(mm_idp, *addr);
+       *addr = stack;
+
+       *stack = data_count * sizeof(long);
+
+       memcpy(stack + 1, data, data_count * sizeof(long));
+
+       *stub_addr = (void *)(((unsigned long)(stack + 1) & ~PAGE_MASK) +
+                             UML_CONFIG_STUB_DATA);
+
+       return 0;
 }
 
-int map(struct mm_id *mm_idp, unsigned long virt, unsigned long len,
-        int r, int w, int x, int phys_fd, unsigned long long offset)
+int map(struct mm_id * mm_idp, unsigned long virt, unsigned long len,
+       int r, int w, int x, int phys_fd, unsigned long long offset,
+       int done, void **data)
 {
-        int prot, n;
+        int prot, ret;
 
         prot = (r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) |
                 (x ? PROT_EXEC : 0);
@@ -70,6 +180,7 @@ int map(struct mm_id *mm_idp, unsigned long virt, unsigned long len,
         if(proc_mm){
                 struct proc_mm_op map;
                 int fd = mm_idp->u.mm_fd;
+
                 map = ((struct proc_mm_op) { .op       = MM_MMAP,
                                              .u                =
                                              { .mmap   =
@@ -81,63 +192,61 @@ int map(struct mm_id *mm_idp, unsigned long virt, unsigned long len,
                                                  .fd   = phys_fd,
                                                  .offset= offset
                                                } } } );
-                n = os_write_file(fd, &map, sizeof(map));
-                if(n != sizeof(map))
-                        printk("map : /proc/mm map failed, err = %d\n", -n);
+               ret = os_write_file(fd, &map, sizeof(map));
+               if(ret != sizeof(map))
+                       printk("map : /proc/mm map failed, err = %d\n", -ret);
+               else ret = 0;
         }
         else {
-                long res;
                 unsigned long args[] = { virt, len, prot,
                                          MAP_SHARED | MAP_FIXED, phys_fd,
                                          MMAP_OFFSET(offset) };
 
-                res = run_syscall_stub(mm_idp, STUB_MMAP_NR, args);
-                if((void *) res == MAP_FAILED)
-                        printk("mmap stub failed, errno = %d\n", res);
+               ret = run_syscall_stub(mm_idp, STUB_MMAP_NR, args, virt,
+                                      data, done);
         }
 
-        return 0;
+       return ret;
 }
 
-int unmap(struct mm_id *mm_idp, void *addr, unsigned long len)
+int unmap(struct mm_id * mm_idp, void *addr, unsigned long len, int done,
+         void **data)
 {
-        int n;
+        int ret;
 
         if(proc_mm){
                 struct proc_mm_op unmap;
                 int fd = mm_idp->u.mm_fd;
+
                 unmap = ((struct proc_mm_op) { .op     = MM_MUNMAP,
                                                .u      =
                                                { .munmap       =
                                                  { .addr       =
                                                    (unsigned long) addr,
                                                    .len                = len } } } );
-                n = os_write_file(fd, &unmap, sizeof(unmap));
-                if(n != sizeof(unmap)) {
-                        if(n < 0)
-                                return(n);
-                        else if(n > 0)
-                                return(-EIO);
-                }
+               ret = os_write_file(fd, &unmap, sizeof(unmap));
+               if(ret != sizeof(unmap))
+                       printk("unmap - proc_mm write returned %d\n", ret);
+               else ret = 0;
         }
         else {
-                int res;
                 unsigned long args[] = { (unsigned long) addr, len, 0, 0, 0,
                                          0 };
 
-                res = run_syscall_stub(mm_idp, __NR_munmap, args);
-                if(res < 0)
-                        printk("munmap stub failed, errno = %d\n", res);
+               ret = run_syscall_stub(mm_idp, __NR_munmap, args, 0,
+                                      data, done);
+                if(ret < 0)
+                        printk("munmap stub failed, errno = %d\n", ret);
         }
 
-        return(0);
+        return ret;
 }
 
-int protect(struct mm_id *mm_idp, unsigned long addr, unsigned long len,
-           int r, int w, int x)
+int protect(struct mm_id * mm_idp, unsigned long addr, unsigned long len,
+           int r, int w, int x, int done, void **data)
 {
         struct proc_mm_op protect;
-        int prot, n;
+        int prot, ret;
 
         prot = (r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) |
                 (x ? PROT_EXEC : 0);
@@ -152,20 +261,19 @@ int protect(struct mm_id *mm_idp, unsigned long addr, unsigned long len,
                                                      .len      = len,
                                                      .prot     = prot } } } );
 
-                n = os_write_file(fd, &protect, sizeof(protect));
-                if(n != sizeof(protect))
-                        panic("protect failed, err = %d", -n);
+                ret = os_write_file(fd, &protect, sizeof(protect));
+                if(ret != sizeof(protect))
+                        printk("protect failed, err = %d", -ret);
+                else ret = 0;
         }
         else {
-                int res;
                 unsigned long args[] = { addr, len, prot, 0, 0, 0 };
 
-                res = run_syscall_stub(mm_idp, __NR_mprotect, args);
-                if(res < 0)
-                        panic("mprotect stub failed, errno = %d\n", res);
+                ret = run_syscall_stub(mm_idp, __NR_mprotect, args, 0,
+                                       data, done);
         }
 
-        return(0);
+        return ret;
 }
 
 void before_mem_skas(unsigned long unused)
index d232daa42c314c009aa5e76141eae73217711641..240143b616a2c359629492e38fcfa8056732aa78 100644 (file)
@@ -56,6 +56,9 @@ static int init_stub_pte(struct mm_struct *mm, unsigned long proc,
         */
 
         mm->context.skas.last_page_table = pmd_page_kernel(*pmd);
+#ifdef CONFIG_3_LEVEL_PGTABLES
+        mm->context.skas.last_pmd = (unsigned long) __va(pud_val(*pud));
+#endif
 
        *pte = mk_pte(virt_to_page(kernel), __pgprot(_PAGE_PRESENT));
        *pte = pte_mkexec(*pte);
@@ -77,23 +80,14 @@ int init_new_context_skas(struct task_struct *task, struct mm_struct *mm)
        struct mm_struct *cur_mm = current->mm;
        struct mm_id *cur_mm_id = &cur_mm->context.skas.id;
        struct mm_id *mm_id = &mm->context.skas.id;
-       unsigned long stack;
-       int from, ret;
+       unsigned long stack = 0;
+       int from, ret = -ENOMEM;
 
-       if(proc_mm){
-               if((cur_mm != NULL) && (cur_mm != &init_mm))
-                       from = cur_mm->context.skas.id.u.mm_fd;
-               else from = -1;
+       if(!proc_mm || !ptrace_faultinfo){
+               stack = get_zeroed_page(GFP_KERNEL);
+               if(stack == 0)
+                       goto out;
 
-               ret = new_mm(from);
-               if(ret < 0){
-                       printk("init_new_context_skas - new_mm failed, "
-                              "errno = %d\n", ret);
-                       return ret;
-               }
-               mm_id->u.mm_fd = ret;
-       }
-       else {
                /* This zeros the entry that pgd_alloc didn't, needed since
                 * we are about to reinitialize it, and want mm.nr_ptes to
                 * be accurate.
@@ -103,20 +97,30 @@ int init_new_context_skas(struct task_struct *task, struct mm_struct *mm)
                ret = init_stub_pte(mm, CONFIG_STUB_CODE,
                                    (unsigned long) &__syscall_stub_start);
                if(ret)
-                       goto out;
-
-               ret = -ENOMEM;
-               stack = get_zeroed_page(GFP_KERNEL);
-               if(stack == 0)
-                       goto out;
-               mm_id->stack = stack;
+                       goto out_free;
 
                ret = init_stub_pte(mm, CONFIG_STUB_DATA, stack);
                if(ret)
                        goto out_free;
 
                mm->nr_ptes--;
+       }
+       mm_id->stack = stack;
 
+       if(proc_mm){
+               if((cur_mm != NULL) && (cur_mm != &init_mm))
+                       from = cur_mm_id->u.mm_fd;
+               else from = -1;
+
+               ret = new_mm(from, stack);
+               if(ret < 0){
+                       printk("init_new_context_skas - new_mm failed, "
+                              "errno = %d\n", ret);
+                       goto out_free;
+               }
+               mm_id->u.mm_fd = ret;
+       }
+       else {
                if((cur_mm != NULL) && (cur_mm != &init_mm))
                        mm_id->u.pid = copy_context_skas0(stack,
                                                          cur_mm_id->u.pid);
@@ -126,7 +130,8 @@ int init_new_context_skas(struct task_struct *task, struct mm_struct *mm)
        return 0;
 
  out_free:
-       free_page(mm_id->stack);
+       if(mm_id->stack != 0)
+               free_page(mm_id->stack);
  out:
        return ret;
 }
@@ -137,9 +142,15 @@ void destroy_context_skas(struct mm_struct *mm)
 
        if(proc_mm)
                os_close_file(mmu->id.u.mm_fd);
-       else {
+       else
                os_kill_ptraced_process(mmu->id.u.pid, 1);
+
+       if(!proc_mm || !ptrace_faultinfo){
                free_page(mmu->id.stack);
-               free_page(mmu->last_page_table);
+               pte_free_kernel((pte_t *) mmu->last_page_table);
+                dec_page_state(nr_page_table_pages);
+#ifdef CONFIG_3_LEVEL_PGTABLES
+               pmd_free((pmd_t *) mmu->last_pmd);
+#endif
        }
 }
index f228f8b54194f3216b5382e83fea567af1471a2c..5cd0e992978969c8d076b3fd9ce4fd0fe9d3a4c1 100644 (file)
@@ -138,6 +138,8 @@ static void handle_trap(int pid, union uml_pt_regs *regs, int local_using_sysemu
 }
 
 extern int __syscall_stub_start;
+int stub_code_fd = -1;
+__u64 stub_code_offset;
 
 static int userspace_tramp(void *stack)
 {
@@ -152,31 +154,31 @@ static int userspace_tramp(void *stack)
                /* This has a pte, but it can't be mapped in with the usual
                 * tlb_flush mechanism because this is part of that mechanism
                 */
-               int fd;
-               __u64 offset;
-
-               fd = phys_mapping(to_phys(&__syscall_stub_start), &offset);
                addr = mmap64((void *) UML_CONFIG_STUB_CODE, page_size(),
-                             PROT_EXEC, MAP_FIXED | MAP_PRIVATE, fd, offset);
+                             PROT_EXEC, MAP_FIXED | MAP_PRIVATE,
+                             stub_code_fd, stub_code_offset);
                if(addr == MAP_FAILED){
-                       printk("mapping mmap stub failed, errno = %d\n",
+                       printk("mapping stub code failed, errno = %d\n",
                               errno);
                        exit(1);
                }
 
                if(stack != NULL){
+                       int fd;
+                       __u64 offset;
+
                        fd = phys_mapping(to_phys(stack), &offset);
                        addr = mmap((void *) UML_CONFIG_STUB_DATA, page_size(),
                                    PROT_READ | PROT_WRITE,
                                    MAP_FIXED | MAP_SHARED, fd, offset);
                        if(addr == MAP_FAILED){
-                               printk("mapping segfault stack failed, "
+                               printk("mapping stub stack failed, "
                                       "errno = %d\n", errno);
                                exit(1);
                        }
                }
        }
-       if(!ptrace_faultinfo && (stack != NULL)){
+       if(!ptrace_faultinfo){
                unsigned long v = UML_CONFIG_STUB_CODE +
                                  (unsigned long) stub_segv_handler -
                                  (unsigned long) &__syscall_stub_start;
@@ -202,6 +204,10 @@ int start_userspace(unsigned long stub_stack)
        unsigned long sp;
        int pid, status, n, flags;
 
+       if ( stub_code_fd == -1 )
+               stub_code_fd = phys_mapping(to_phys(&__syscall_stub_start),
+                                           &stub_code_offset);
+
        stack = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC,
                     MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
        if(stack == MAP_FAILED)
@@ -363,6 +369,53 @@ int copy_context_skas0(unsigned long new_stack, int pid)
        return pid;
 }
 
+/*
+ * This is used only, if proc_mm is available, while PTRACE_FAULTINFO
+ * isn't. Opening /proc/mm creates a new mm_context, which lacks the stub-pages
+ * Thus, we map them using /proc/mm-fd
+ */
+void map_stub_pages(int fd, unsigned long code,
+                   unsigned long data, unsigned long stack)
+{
+       struct proc_mm_op mmop;
+       int n;
+
+       mmop = ((struct proc_mm_op) { .op        = MM_MMAP,
+                                     .u         =
+                                     { .mmap    =
+                                       { .addr    = code,
+                                         .len     = PAGE_SIZE,
+                                         .prot    = PROT_EXEC,
+                                         .flags   = MAP_FIXED | MAP_PRIVATE,
+                                         .fd      = stub_code_fd,
+                                         .offset  = stub_code_offset
+       } } });
+       n = os_write_file(fd, &mmop, sizeof(mmop));
+       if(n != sizeof(mmop))
+               panic("map_stub_pages : /proc/mm map for code failed, "
+                     "err = %d\n", -n);
+
+       if ( stack ) {
+               __u64 map_offset;
+               int map_fd = phys_mapping(to_phys((void *)stack), &map_offset);
+               mmop = ((struct proc_mm_op)
+                               { .op        = MM_MMAP,
+                                 .u         =
+                                 { .mmap    =
+                                   { .addr    = data,
+                                     .len     = PAGE_SIZE,
+                                     .prot    = PROT_READ | PROT_WRITE,
+                                     .flags   = MAP_FIXED | MAP_SHARED,
+                                     .fd      = map_fd,
+                                     .offset  = map_offset
+               } } });
+               n = os_write_file(fd, &mmop, sizeof(mmop));
+               if(n != sizeof(mmop))
+                       panic("map_stub_pages : /proc/mm map for data failed, "
+                             "err = %d\n", -n);
+       }
+}
+
 void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr,
                void (*handler)(int))
 {
index cbabab104ac3ef904bdd7a2f9ec43e3d415e73ab..3d1b227226e653d6ded1b4b8005c6d20a388530d 100644 (file)
@@ -129,7 +129,9 @@ int copy_thread_skas(int nr, unsigned long clone_flags, unsigned long sp,
        return(0);
 }
 
-int new_mm(int from)
+extern void map_stub_pages(int fd, unsigned long code,
+                          unsigned long data, unsigned long stack);
+int new_mm(int from, unsigned long stack)
 {
        struct proc_mm_op copy;
        int n, fd;
@@ -148,6 +150,9 @@ int new_mm(int from)
                               "err = %d\n", -n);
        }
 
+       if(!ptrace_faultinfo)
+               map_stub_pages(fd, CONFIG_STUB_CODE, CONFIG_STUB_DATA, stack);
+
        return(fd);
 }
 
diff --git a/arch/um/kernel/skas/syscall.c b/arch/um/kernel/skas/syscall.c
new file mode 100644 (file)
index 0000000..51fb940
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Licensed under the GPL
+ */
+
+#include "linux/sys.h"
+#include "linux/ptrace.h"
+#include "asm/errno.h"
+#include "asm/unistd.h"
+#include "asm/ptrace.h"
+#include "asm/current.h"
+#include "sysdep/syscalls.h"
+#include "kern_util.h"
+#include "syscall.h"
+
+void handle_syscall(union uml_pt_regs *r)
+{
+       struct pt_regs *regs = container_of(r, struct pt_regs, regs);
+       long result;
+       int syscall;
+#ifdef UML_CONFIG_SYSCALL_DEBUG
+       int index;
+
+       index = record_syscall_start(UPT_SYSCALL_NR(r));
+#endif
+       syscall_trace(r, 0);
+
+       current->thread.nsyscalls++;
+       nsyscalls++;
+
+       /* This should go in the declaration of syscall, but when I do that,
+        * strace -f -c bash -c 'ls ; ls' breaks, sometimes not tracing
+        * children at all, sometimes hanging when bash doesn't see the first
+        * ls exit.
+        * The assembly looks functionally the same to me.  This is
+        *     gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)
+        * in case it's a compiler bug.
+        */
+       syscall = UPT_SYSCALL_NR(r);
+       if((syscall >= NR_syscalls) || (syscall < 0))
+               result = -ENOSYS;
+       else result = EXECUTE_SYSCALL(syscall, regs);
+
+       REGS_SET_SYSCALL_RETURN(r->skas.regs, result);
+
+       syscall_trace(r, 1);
+#ifdef UML_CONFIG_SYSCALL_DEBUG
+       record_syscall_end(index, result);
+#endif
+}
diff --git a/arch/um/kernel/skas/syscall_kern.c b/arch/um/kernel/skas/syscall_kern.c
deleted file mode 100644 (file)
index bdf040c..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/* 
- * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
- * Licensed under the GPL
- */
-
-#include "linux/sys.h"
-#include "linux/ptrace.h"
-#include "asm/errno.h"
-#include "asm/unistd.h"
-#include "asm/ptrace.h"
-#include "asm/current.h"
-#include "sysdep/syscalls.h"
-#include "kern_util.h"
-
-extern syscall_handler_t *sys_call_table[];
-
-long execute_syscall_skas(void *r)
-{
-       struct pt_regs *regs = r;
-       long res;
-       int syscall;
-
-       current->thread.nsyscalls++;
-       nsyscalls++;
-       syscall = UPT_SYSCALL_NR(&regs->regs);
-
-       if((syscall >= NR_syscalls) || (syscall < 0))
-               res = -ENOSYS;
-       else res = EXECUTE_SYSCALL(syscall, regs);
-
-       return(res);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/kernel/skas/syscall_user.c b/arch/um/kernel/skas/syscall_user.c
deleted file mode 100644 (file)
index 6b06649..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <stdlib.h>
-#include <signal.h>
-#include "kern_util.h"
-#include "uml-config.h"
-#include "syscall_user.h"
-#include "sysdep/ptrace.h"
-#include "sysdep/sigcontext.h"
-#include "skas.h"
-
-void handle_syscall(union uml_pt_regs *regs)
-{
-       long result;
-#ifdef UML_CONFIG_SYSCALL_DEBUG
-       int index;
-
-       index = record_syscall_start(UPT_SYSCALL_NR(regs));
-#endif
-
-       syscall_trace(regs, 0);
-       result = execute_syscall_skas(regs);
-
-       REGS_SET_SYSCALL_RETURN(regs->skas.regs, result);
-
-       syscall_trace(regs, 1);
-#ifdef UML_CONFIG_SYSCALL_DEBUG
-       record_syscall_end(index, result);
-#endif
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 6230999c672c90ff3a36abf31d23f8c774c3f2eb..6e84963dfc29e99c93bcdfe1cd2e11c1103c9310 100644 (file)
 #include "os.h"
 #include "tlb.h"
 
-static void do_ops(union mm_context *mmu, struct host_vm_op *ops, int last)
+static int do_ops(union mm_context *mmu, struct host_vm_op *ops, int last,
+                 int finished, void **flush)
 {
        struct host_vm_op *op;
-       int i;
+        int i, ret = 0;
 
-       for(i = 0; i <= last; i++){
+        for(i = 0; i <= last && !ret; i++){
                op = &ops[i];
                switch(op->type){
                case MMAP:
-                        map(&mmu->skas.id, op->u.mmap.addr, op->u.mmap.len,
-                           op->u.mmap.r, op->u.mmap.w, op->u.mmap.x,
-                           op->u.mmap.fd, op->u.mmap.offset);
+                       ret = map(&mmu->skas.id, op->u.mmap.addr,
+                                 op->u.mmap.len, op->u.mmap.r, op->u.mmap.w,
+                                 op->u.mmap.x, op->u.mmap.fd,
+                                 op->u.mmap.offset, finished, flush);
                        break;
                case MUNMAP:
-                        unmap(&mmu->skas.id, (void *) op->u.munmap.addr,
-                             op->u.munmap.len);
+                       ret = unmap(&mmu->skas.id,
+                                   (void *) op->u.munmap.addr,
+                                   op->u.munmap.len, finished, flush);
                        break;
                case MPROTECT:
-                        protect(&mmu->skas.id, op->u.mprotect.addr,
-                                op->u.mprotect.len, op->u.mprotect.r,
-                                op->u.mprotect.w, op->u.mprotect.x);
+                       ret = protect(&mmu->skas.id, op->u.mprotect.addr,
+                                     op->u.mprotect.len, op->u.mprotect.r,
+                                     op->u.mprotect.w, op->u.mprotect.x,
+                                     finished, flush);
                        break;
                default:
                        printk("Unknown op type %d in do_ops\n", op->type);
                        break;
                }
        }
+
+       return ret;
 }
 
 extern int proc_mm;
diff --git a/arch/um/kernel/syscall.c b/arch/um/kernel/syscall.c
new file mode 100644 (file)
index 0000000..1429c13
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Licensed under the GPL
+ */
+
+#include "kern_util.h"
+#include "syscall.h"
+#include "os.h"
+
+struct {
+       int syscall;
+       int pid;
+       long result;
+       unsigned long long start;
+       unsigned long long end;
+} syscall_record[1024];
+
+int record_syscall_start(int syscall)
+{
+       int max, index;
+
+       max = sizeof(syscall_record)/sizeof(syscall_record[0]);
+       index = next_syscall_index(max);
+
+       syscall_record[index].syscall = syscall;
+       syscall_record[index].pid = current_pid();
+       syscall_record[index].result = 0xdeadbeef;
+       syscall_record[index].start = os_usecs();
+       return(index);
+}
+
+void record_syscall_end(int index, long result)
+{
+       syscall_record[index].result = result;
+       syscall_record[index].end = os_usecs();
+}
diff --git a/arch/um/kernel/syscall_user.c b/arch/um/kernel/syscall_user.c
deleted file mode 100644 (file)
index 01b711e..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <stdlib.h>
-#include <sys/time.h>
-#include "kern_util.h"
-#include "syscall_user.h"
-
-struct {
-       int syscall;
-       int pid;
-       long result;
-       struct timeval start;
-       struct timeval end;
-} syscall_record[1024];
-
-int record_syscall_start(int syscall)
-{
-       int max, index;
-
-       max = sizeof(syscall_record)/sizeof(syscall_record[0]);
-       index = next_syscall_index(max);
-
-       syscall_record[index].syscall = syscall;
-       syscall_record[index].pid = current_pid();
-       syscall_record[index].result = 0xdeadbeef;
-       gettimeofday(&syscall_record[index].start, NULL);
-       return(index);
-}
-
-void record_syscall_end(int index, long result)
-{
-       syscall_record[index].result = result;
-       gettimeofday(&syscall_record[index].end, NULL);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 83ec8d4747fd039482aca79dc9137371d0b86989..80ed6188e8a21a511ce60216ffe7e53cb3f8786c 100644 (file)
 #include "mem_user.h"
 #include "os.h"
 
+static int add_mmap(unsigned long virt, unsigned long phys, unsigned long len,
+                   int r, int w, int x, struct host_vm_op *ops, int *index,
+                   int last_filled, union mm_context *mmu, void **flush,
+                   int (*do_ops)(union mm_context *, struct host_vm_op *,
+                                 int, int, void **))
+{
+        __u64 offset;
+       struct host_vm_op *last;
+       int fd, ret = 0;
+
+       fd = phys_mapping(phys, &offset);
+       if(*index != -1){
+               last = &ops[*index];
+               if((last->type == MMAP) &&
+                  (last->u.mmap.addr + last->u.mmap.len == virt) &&
+                  (last->u.mmap.r == r) && (last->u.mmap.w == w) &&
+                  (last->u.mmap.x == x) && (last->u.mmap.fd == fd) &&
+                  (last->u.mmap.offset + last->u.mmap.len == offset)){
+                       last->u.mmap.len += len;
+                       return 0;
+               }
+       }
+
+       if(*index == last_filled){
+               ret = (*do_ops)(mmu, ops, last_filled, 0, flush);
+               *index = -1;
+       }
+
+       ops[++*index] = ((struct host_vm_op) { .type    = MMAP,
+                                               .u = { .mmap = {
+                                                      .addr    = virt,
+                                                      .len     = len,
+                                                      .r       = r,
+                                                      .w       = w,
+                                                      .x       = x,
+                                                      .fd      = fd,
+                                                      .offset  = offset }
+                          } });
+       return ret;
+}
+
+static int add_munmap(unsigned long addr, unsigned long len,
+                     struct host_vm_op *ops, int *index, int last_filled,
+                     union mm_context *mmu, void **flush,
+                     int (*do_ops)(union mm_context *, struct host_vm_op *,
+                                   int, int, void **))
+{
+       struct host_vm_op *last;
+       int ret = 0;
+
+       if(*index != -1){
+               last = &ops[*index];
+               if((last->type == MUNMAP) &&
+                  (last->u.munmap.addr + last->u.mmap.len == addr)){
+                       last->u.munmap.len += len;
+                       return 0;
+               }
+       }
+
+       if(*index == last_filled){
+               ret = (*do_ops)(mmu, ops, last_filled, 0, flush);
+               *index = -1;
+       }
+
+       ops[++*index] = ((struct host_vm_op) { .type    = MUNMAP,
+                                              .u = { .munmap = {
+                                                       .addr   = addr,
+                                                       .len    = len } } });
+       return ret;
+}
+
+static int add_mprotect(unsigned long addr, unsigned long len, int r, int w,
+                       int x, struct host_vm_op *ops, int *index,
+                       int last_filled, union mm_context *mmu, void **flush,
+                       int (*do_ops)(union mm_context *, struct host_vm_op *,
+                                     int, int, void **))
+{
+       struct host_vm_op *last;
+       int ret = 0;
+
+       if(*index != -1){
+               last = &ops[*index];
+               if((last->type == MPROTECT) &&
+                  (last->u.mprotect.addr + last->u.mprotect.len == addr) &&
+                  (last->u.mprotect.r == r) && (last->u.mprotect.w == w) &&
+                  (last->u.mprotect.x == x)){
+                       last->u.mprotect.len += len;
+                       return 0;
+               }
+       }
+
+       if(*index == last_filled){
+               ret = (*do_ops)(mmu, ops, last_filled, 0, flush);
+               *index = -1;
+       }
+
+       ops[++*index] = ((struct host_vm_op) { .type    = MPROTECT,
+                                              .u = { .mprotect = {
+                                                      .addr    = addr,
+                                                      .len     = len,
+                                                      .r       = r,
+                                                      .w       = w,
+                                                      .x       = x } } });
+       return ret;
+}
+
 #define ADD_ROUND(n, inc) (((n) + (inc)) & ~((inc) - 1))
 
 void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
                       unsigned long end_addr, int force,
-                      void (*do_ops)(union mm_context *, struct host_vm_op *,
-                                     int))
+                     int (*do_ops)(union mm_context *, struct host_vm_op *,
+                                   int, int, void **))
 {
         pgd_t *npgd;
         pud_t *npud;
@@ -29,21 +135,24 @@ void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
         union mm_context *mmu = &mm->context;
         unsigned long addr, end;
         int r, w, x;
-        struct host_vm_op ops[16];
+        struct host_vm_op ops[1];
+        void *flush = NULL;
         int op_index = -1, last_op = sizeof(ops) / sizeof(ops[0]) - 1;
+        int ret = 0;
 
         if(mm == NULL) return;
 
-        for(addr = start_addr; addr < end_addr;){
+        ops[0].type = NONE;
+        for(addr = start_addr; addr < end_addr && !ret;){
                 npgd = pgd_offset(mm, addr);
                 if(!pgd_present(*npgd)){
                         end = ADD_ROUND(addr, PGDIR_SIZE);
                         if(end > end_addr)
                                 end = end_addr;
                         if(force || pgd_newpage(*npgd)){
-                                op_index = add_munmap(addr, end - addr, ops,
-                                                      op_index, last_op, mmu,
-                                                      do_ops);
+                                ret = add_munmap(addr, end - addr, ops,
+                                                 &op_index, last_op, mmu,
+                                                 &flush, do_ops);
                                 pgd_mkuptodate(*npgd);
                         }
                         addr = end;
@@ -56,9 +165,9 @@ void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
                         if(end > end_addr)
                                 end = end_addr;
                         if(force || pud_newpage(*npud)){
-                                op_index = add_munmap(addr, end - addr, ops,
-                                                      op_index, last_op, mmu,
-                                                      do_ops);
+                                ret = add_munmap(addr, end - addr, ops,
+                                                 &op_index, last_op, mmu,
+                                                 &flush, do_ops);
                                 pud_mkuptodate(*npud);
                         }
                         addr = end;
@@ -71,9 +180,9 @@ void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
                         if(end > end_addr)
                                 end = end_addr;
                         if(force || pmd_newpage(*npmd)){
-                                op_index = add_munmap(addr, end - addr, ops,
-                                                      op_index, last_op, mmu,
-                                                      do_ops);
+                                ret = add_munmap(addr, end - addr, ops,
+                                                 &op_index, last_op, mmu,
+                                                 &flush, do_ops);
                                 pmd_mkuptodate(*npmd);
                         }
                         addr = end;
@@ -92,24 +201,32 @@ void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
                 }
                 if(force || pte_newpage(*npte)){
                         if(pte_present(*npte))
-                                op_index = add_mmap(addr,
-                                                    pte_val(*npte) & PAGE_MASK,
-                                                    PAGE_SIZE, r, w, x, ops,
-                                                    op_index, last_op, mmu,
-                                                    do_ops);
-                        else op_index = add_munmap(addr, PAGE_SIZE, ops,
-                                                   op_index, last_op, mmu,
-                                                   do_ops);
+                         ret = add_mmap(addr,
+                                        pte_val(*npte) & PAGE_MASK,
+                                        PAGE_SIZE, r, w, x, ops,
+                                        &op_index, last_op, mmu,
+                                        &flush, do_ops);
+                       else ret = add_munmap(addr, PAGE_SIZE, ops,
+                                             &op_index, last_op, mmu,
+                                             &flush, do_ops);
                 }
                 else if(pte_newprot(*npte))
-                        op_index = add_mprotect(addr, PAGE_SIZE, r, w, x, ops,
-                                                op_index, last_op, mmu,
-                                                do_ops);
+                       ret = add_mprotect(addr, PAGE_SIZE, r, w, x, ops,
+                                          &op_index, last_op, mmu,
+                                          &flush, do_ops);
 
                 *npte = pte_mkuptodate(*npte);
                 addr += PAGE_SIZE;
         }
-        (*do_ops)(mmu, ops, op_index);
+
+       if(!ret)
+               ret = (*do_ops)(mmu, ops, op_index, 1, &flush);
+
+       /* This is not an else because ret is modified above */
+       if(ret) {
+               printk("fix_range_common: failed, killing current process\n");
+               force_sig(SIGKILL, current);
+       }
 }
 
 int flush_tlb_kernel_range_common(unsigned long start, unsigned long end)
@@ -226,106 +343,6 @@ pte_t *addr_pte(struct task_struct *task, unsigned long addr)
         return(pte_offset_map(pmd, addr));
 }
 
-int add_mmap(unsigned long virt, unsigned long phys, unsigned long len,
-             int r, int w, int x, struct host_vm_op *ops, int index,
-             int last_filled, union mm_context *mmu,
-             void (*do_ops)(union mm_context *, struct host_vm_op *, int))
-{
-        __u64 offset;
-       struct host_vm_op *last;
-       int fd;
-
-       fd = phys_mapping(phys, &offset);
-       if(index != -1){
-               last = &ops[index];
-               if((last->type == MMAP) &&
-                  (last->u.mmap.addr + last->u.mmap.len == virt) &&
-                  (last->u.mmap.r == r) && (last->u.mmap.w == w) &&
-                  (last->u.mmap.x == x) && (last->u.mmap.fd == fd) &&
-                  (last->u.mmap.offset + last->u.mmap.len == offset)){
-                       last->u.mmap.len += len;
-                       return(index);
-               }
-       }
-
-       if(index == last_filled){
-               (*do_ops)(mmu, ops, last_filled);
-               index = -1;
-       }
-
-       ops[++index] = ((struct host_vm_op) { .type     = MMAP,
-                                             .u = { .mmap = {
-                                                     .addr     = virt,
-                                                     .len      = len,
-                                                     .r        = r,
-                                                     .w        = w,
-                                                     .x        = x,
-                                                     .fd       = fd,
-                                                     .offset   = offset }
-                                             } });
-       return(index);
-}
-
-int add_munmap(unsigned long addr, unsigned long len, struct host_vm_op *ops,
-              int index, int last_filled, union mm_context *mmu,
-              void (*do_ops)(union mm_context *, struct host_vm_op *, int))
-{
-       struct host_vm_op *last;
-
-       if(index != -1){
-               last = &ops[index];
-               if((last->type == MUNMAP) &&
-                  (last->u.munmap.addr + last->u.mmap.len == addr)){
-                       last->u.munmap.len += len;
-                       return(index);
-               }
-       }
-
-       if(index == last_filled){
-               (*do_ops)(mmu, ops, last_filled);
-               index = -1;
-       }
-
-       ops[++index] = ((struct host_vm_op) { .type     = MUNMAP,
-                                             .u = { .munmap = {
-                                                     .addr     = addr,
-                                                     .len      = len } } });
-       return(index);
-}
-
-int add_mprotect(unsigned long addr, unsigned long len, int r, int w, int x,
-                 struct host_vm_op *ops, int index, int last_filled,
-                 union mm_context *mmu,
-                 void (*do_ops)(union mm_context *, struct host_vm_op *, int))
-{
-       struct host_vm_op *last;
-
-       if(index != -1){
-               last = &ops[index];
-               if((last->type == MPROTECT) &&
-                  (last->u.mprotect.addr + last->u.mprotect.len == addr) &&
-                  (last->u.mprotect.r == r) && (last->u.mprotect.w == w) &&
-                  (last->u.mprotect.x == x)){
-                       last->u.mprotect.len += len;
-                       return(index);
-               }
-       }
-
-       if(index == last_filled){
-               (*do_ops)(mmu, ops, last_filled);
-               index = -1;
-       }
-
-       ops[++index] = ((struct host_vm_op) { .type     = MPROTECT,
-                                             .u = { .mprotect = {
-                                                     .addr     = addr,
-                                                     .len      = len,
-                                                     .r        = r,
-                                                     .w        = w,
-                                                     .x        = x } } });
-       return(index);
-}
-
 void flush_tlb_page(struct vm_area_struct *vma, unsigned long address)
 {
         address &= PAGE_MASK;
index c20aef120598ddb071f6362ca8868ecdc8373eca..b5fc89fe9eab8f2e51859e5a44c5f2bf5d226ab4 100644 (file)
@@ -26,6 +26,7 @@
 #include "mem.h"
 #include "mem_kern.h"
 
+/* Note this is constrained to return 0, -EFAULT, -EACCESS, -ENOMEM by segv(). */
 int handle_page_fault(unsigned long address, unsigned long ip, 
                      int is_write, int is_user, int *code_out)
 {
@@ -35,7 +36,6 @@ int handle_page_fault(unsigned long address, unsigned long ip,
        pud_t *pud;
        pmd_t *pmd;
        pte_t *pte;
-       unsigned long page;
        int err = -EFAULT;
 
        *code_out = SEGV_MAPERR;
@@ -52,7 +52,7 @@ int handle_page_fault(unsigned long address, unsigned long ip,
        else if(expand_stack(vma, address)) 
                goto out;
 
- good_area:
+good_area:
        *code_out = SEGV_ACCERR;
        if(is_write && !(vma->vm_flags & VM_WRITE)) 
                goto out;
@@ -60,9 +60,8 @@ int handle_page_fault(unsigned long address, unsigned long ip,
         if(!(vma->vm_flags & (VM_READ | VM_EXEC)))
                 goto out;
 
-       page = address & PAGE_MASK;
        do {
- survive:
+survive:
                switch (handle_mm_fault(mm, vma, address, is_write)){
                case VM_FAULT_MINOR:
                        current->min_flt++;
@@ -79,16 +78,16 @@ int handle_page_fault(unsigned long address, unsigned long ip,
                default:
                        BUG();
                }
-               pgd = pgd_offset(mm, page);
-               pud = pud_offset(pgd, page);
-               pmd = pmd_offset(pud, page);
-               pte = pte_offset_kernel(pmd, page);
+               pgd = pgd_offset(mm, address);
+               pud = pud_offset(pgd, address);
+               pmd = pmd_offset(pud, address);
+               pte = pte_offset_kernel(pmd, address);
        } while(!pte_present(*pte));
        err = 0;
        *pte = pte_mkyoung(*pte);
        if(pte_write(*pte)) *pte = pte_mkdirty(*pte);
-       flush_tlb_page(vma, page);
- out:
+       flush_tlb_page(vma, address);
+out:
        up_read(&mm->mmap_sem);
        return(err);
 
@@ -144,19 +143,18 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user, void *sc)
                panic("Kernel mode fault at addr 0x%lx, ip 0x%lx", 
                      address, ip);
 
-       if(err == -EACCES){
+       if (err == -EACCES) {
                si.si_signo = SIGBUS;
                si.si_errno = 0;
                si.si_code = BUS_ADRERR;
                si.si_addr = (void *)address;
                 current->thread.arch.faultinfo = fi;
                force_sig_info(SIGBUS, &si, current);
-       }
-       else if(err == -ENOMEM){
+       } else if (err == -ENOMEM) {
                printk("VM: killing process %s\n", current->comm);
                do_exit(SIGKILL);
-       }
-       else {
+       } else {
+               BUG_ON(err != -EFAULT);
                si.si_signo = SIGSEGV;
                si.si_addr = (void *) address;
                 current->thread.arch.faultinfo = fi;
@@ -200,30 +198,3 @@ void winch(int sig, union uml_pt_regs *regs)
 void trap_init(void)
 {
 }
-
-DEFINE_SPINLOCK(trap_lock);
-
-static int trap_index = 0;
-
-int next_trap_index(int limit)
-{
-       int ret;
-
-       spin_lock(&trap_lock);
-       ret = trap_index;
-       if(++trap_index == limit)
-               trap_index = 0;
-       spin_unlock(&trap_lock);
-       return(ret);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index f825a6eda3f599ac6f080cedce1f52bb69955715..e9ccd6b8d3c78d1092b07c4cb93cda92f9559f9d 100644 (file)
@@ -40,35 +40,14 @@ void kill_child_dead(int pid)
        } while(1);
 }
 
-/* Unlocked - don't care if this is a bit off */
-int nsegfaults = 0;
-
-struct {
-       unsigned long address;
-       int is_write;
-       int pid;
-       unsigned long sp;
-       int is_user;
-} segfault_record[1024];
-
 void segv_handler(int sig, union uml_pt_regs *regs)
 {
-       int index, max;
         struct faultinfo * fi = UPT_FAULTINFO(regs);
 
         if(UPT_IS_USER(regs) && !SEGV_IS_FIXABLE(fi)){
                 bad_segv(*fi, UPT_IP(regs));
                return;
        }
-       max = sizeof(segfault_record)/sizeof(segfault_record[0]);
-       index = next_trap_index(max);
-
-       nsegfaults++;
-        segfault_record[index].address = FAULT_ADDRESS(*fi);
-       segfault_record[index].pid = os_getpid();
-        segfault_record[index].is_write = FAULT_WRITE(*fi);
-       segfault_record[index].sp = UPT_SP(regs);
-       segfault_record[index].is_user = UPT_IS_USER(regs);
         segv(*fi, UPT_IP(regs), UPT_IS_USER(regs), regs);
 }
 
index 2650a628719e41136291fae37b44ff9d3c02cb48..3d29c90514cc0e10093b15c40188281e9fe92e7b 100644 (file)
 #include "asm/uaccess.h"
 #include "asm/stat.h"
 #include "sysdep/syscalls.h"
+#include "sysdep/sigcontext.h"
 #include "kern_util.h"
+#include "syscall.h"
 
-extern syscall_handler_t *sys_call_table[];
-
-long execute_syscall_tt(void *r)
+void syscall_handler_tt(int sig, struct pt_regs *regs)
 {
-       struct pt_regs *regs = r;
-       long res;
+       void *sc;
+       long result;
        int syscall;
-
 #ifdef CONFIG_SYSCALL_DEBUG
+       int index;
+       index = record_syscall_start(syscall);
+#endif
+       sc = UPT_SC(&regs->regs);
+       SC_START_SYSCALL(sc);
+
+       syscall_trace(&regs->regs, 0);
+
        current->thread.nsyscalls++;
        nsyscalls++;
-#endif
        syscall = UPT_SYSCALL_NR(&regs->regs);
 
        if((syscall >= NR_syscalls) || (syscall < 0))
-               res = -ENOSYS;
-       else res = EXECUTE_SYSCALL(syscall, regs);
+               result = -ENOSYS;
+       else result = EXECUTE_SYSCALL(syscall, regs);
 
-       return(res);
-}
+       /* regs->sc may have changed while the system call ran (there may
+        * have been an interrupt or segfault), so it needs to be refreshed.
+        */
+       UPT_SC(&regs->regs) = sc;
 
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+       SC_SET_SYSCALL_RETURN(sc, result);
+
+       syscall_trace(&regs->regs, 1);
+#ifdef CONFIG_SYSCALL_DEBUG
+       record_syscall_end(index, result);
+#endif
+}
index b218316cfdb29aa169beb82ecdeca42d89a6407f..902987bf379b2c8bd55fed640704255b6e6d02bd 100644 (file)
 #include "task.h"
 #include "user_util.h"
 #include "kern_util.h"
-#include "syscall_user.h"
+#include "syscall.h"
 #include "tt.h"
 
-
-void syscall_handler_tt(int sig, union uml_pt_regs *regs)
-{
-       void *sc;
-       long result;
-       int syscall;
-#ifdef UML_CONFIG_DEBUG_SYSCALL
-       int index;
-#endif
-
-       syscall = UPT_SYSCALL_NR(regs);
-       sc = UPT_SC(regs);
-       SC_START_SYSCALL(sc);
-
-#ifdef UML_CONFIG_DEBUG_SYSCALL
-       index = record_syscall_start(syscall);
-#endif
-       syscall_trace(regs, 0);
-       result = execute_syscall_tt(regs);
-
-       /* regs->sc may have changed while the system call ran (there may
-        * have been an interrupt or segfault), so it needs to be refreshed.
-        */
-       UPT_SC(regs) = sc;
-
-       SC_SET_SYSCALL_RETURN(sc, result);
-
-       syscall_trace(regs, 1);
-#ifdef UML_CONFIG_DEBUG_SYSCALL
-       record_syscall_end(index, result);
-#endif
-}
-
 void do_sigtrap(void *task)
 {
        UPT_SYSCALL_NR(TASK_REGS(task)) = -1;
index 2eefb43bc9c2e3a01cb547ca657d654b98e2b19c..f1d85dbb45b9827d50f325d0d9560d4f3d4a09db 100644 (file)
 #include "os.h"
 #include "tlb.h"
 
-static void do_ops(union mm_context *mmu, struct host_vm_op *ops, int last)
+static int do_ops(union mm_context *mmu, struct host_vm_op *ops, int last,
+                   int finished, void **flush)
 {
        struct host_vm_op *op;
-       int i;
+        int i, ret=0;
 
-       for(i = 0; i <= last; i++){
+        for(i = 0; i <= last && !ret; i++){
                op = &ops[i];
                switch(op->type){
                case MMAP:
-                        os_map_memory((void *) op->u.mmap.addr, op->u.mmap.fd,
-                                     op->u.mmap.offset, op->u.mmap.len,
-                                     op->u.mmap.r, op->u.mmap.w,
-                                     op->u.mmap.x);
+                        ret = os_map_memory((void *) op->u.mmap.addr,
+                                            op->u.mmap.fd, op->u.mmap.offset,
+                                            op->u.mmap.len, op->u.mmap.r,
+                                            op->u.mmap.w, op->u.mmap.x);
                        break;
                case MUNMAP:
-                       os_unmap_memory((void *) op->u.munmap.addr,
-                                       op->u.munmap.len);
+                        ret = os_unmap_memory((void *) op->u.munmap.addr,
+                                              op->u.munmap.len);
                        break;
                case MPROTECT:
+                        ret = protect_memory(op->u.mprotect.addr,
+                                             op->u.munmap.len,
+                                             op->u.mprotect.r,
+                                             op->u.mprotect.w,
+                                             op->u.mprotect.x, 1);
                        protect_memory(op->u.mprotect.addr, op->u.munmap.len,
                                       op->u.mprotect.r, op->u.mprotect.w,
                                       op->u.mprotect.x, 1);
@@ -45,6 +51,8 @@ static void do_ops(union mm_context *mmu, struct host_vm_op *ops, int last)
                        break;
                }
        }
+
+       return ret;
 }
 
 static void fix_range(struct mm_struct *mm, unsigned long start_addr, 
index ca2bb6f09a7d4f5231f8910bb3df4ba2151ae478..09f6f7ce4695f73c10a1507acfb122b854cf2fe5 100644 (file)
@@ -126,7 +126,7 @@ unsigned long start_vm;
 unsigned long end_vm;
 int ncpus = 1;
 
-#ifdef CONFIG_MODE_TT
+#ifdef CONFIG_CMDLINE_ON_HOST
 /* Pointer set in linux_main, the array itself is private to each thread,
  * and changed at address space creation time so this poses no concurrency
  * problems.
@@ -141,7 +141,7 @@ long physmem_size = 32 * 1024 * 1024;
 
 void set_cmdline(char *cmd)
 {
-#ifdef CONFIG_MODE_TT
+#ifdef CONFIG_CMDLINE_ON_HOST
        char *umid, *ptr;
 
        if(CHOOSE_MODE(honeypot, 0)) return;
@@ -333,6 +333,7 @@ int linux_main(int argc, char **argv)
        if(have_root == 0)
                add_arg(DEFAULT_COMMAND_LINE);
 
+       os_early_checks();
        mode_tt = force_tt ? 1 : !can_do_skas();
 #ifndef CONFIG_MODE_TT
        if (mode_tt) {
@@ -385,7 +386,7 @@ int linux_main(int argc, char **argv)
 
        setup_machinename(system_utsname.machine);
 
-#ifdef CONFIG_MODE_TT
+#ifdef CONFIG_CMDLINE_ON_HOST
        argv1_begin = argv[1];
        argv1_end = &argv[1][strlen(argv[1])];
 #endif
@@ -470,7 +471,6 @@ void __init setup_arch(char **cmdline_p)
 void __init check_bugs(void)
 {
        arch_check_bugs();
-       check_ptrace();
        check_sigio();
        check_devanon();
 }
index 4ddf540284ce601b66f54f089656846d4522ec80..d3c1560e3ed85365bf1a93ffa6c644c38d6f3727 100644 (file)
@@ -3,11 +3,16 @@
 # Licensed under the GPL
 #
 
-obj-y = elf_aux.o file.o process.o signal.o time.o tty.o user_syms.o drivers/ \
-       sys-$(SUBARCH)/
+obj-y = aio.o elf_aux.o file.o process.o signal.o start_up.o time.o tt.o \
+       tty.o user_syms.o drivers/ sys-$(SUBARCH)/
 
-USER_OBJS := elf_aux.o file.o process.o signal.o time.o tty.o
+USER_OBJS := aio.o elf_aux.o file.o process.o signal.o start_up.o time.o tt.o \
+       tty.o
 
 CFLAGS_user_syms.o += -DSUBARCH_$(SUBARCH)
 
+HAVE_AIO_ABI := $(shell [ -r /usr/include/linux/aio_abi.h ] && \
+       echo -DHAVE_AIO_ABI )
+CFLAGS_aio.o += $(HAVE_AIO_ABI)
+
 include arch/um/scripts/Makefile.rules
diff --git a/arch/um/os-Linux/aio.c b/arch/um/os-Linux/aio.c
new file mode 100644 (file)
index 0000000..b04897c
--- /dev/null
@@ -0,0 +1,414 @@
+/*
+ * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
+ * Licensed under the GPL
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+#include <string.h>
+#include <errno.h>
+#include <sched.h>
+#include <sys/syscall.h>
+#include "os.h"
+#include "helper.h"
+#include "aio.h"
+#include "init.h"
+#include "user.h"
+#include "mode.h"
+
+static int aio_req_fd_r = -1;
+static int aio_req_fd_w = -1;
+
+static int update_aio(struct aio_context *aio, int res)
+{
+        if(res < 0)
+                aio->len = res;
+        else if((res == 0) && (aio->type == AIO_READ)){
+                /* This is the EOF case - we have hit the end of the file
+                 * and it ends in a partial block, so we fill the end of
+                 * the block with zeros and claim success.
+                 */
+                memset(aio->data, 0, aio->len);
+                aio->len = 0;
+        }
+        else if(res > 0){
+                aio->len -= res;
+                aio->data += res;
+                aio->offset += res;
+                return aio->len;
+        }
+
+        return 0;
+}
+
+#if defined(HAVE_AIO_ABI)
+#include <linux/aio_abi.h>
+
+/* If we have the headers, we are going to build with AIO enabled.
+ * If we don't have aio in libc, we define the necessary stubs here.
+ */
+
+#if !defined(HAVE_AIO_LIBC)
+
+static long io_setup(int n, aio_context_t *ctxp)
+{
+        return syscall(__NR_io_setup, n, ctxp);
+}
+
+static long io_submit(aio_context_t ctx, long nr, struct iocb **iocbpp)
+{
+        return syscall(__NR_io_submit, ctx, nr, iocbpp);
+}
+
+static long io_getevents(aio_context_t ctx_id, long min_nr, long nr,
+                         struct io_event *events, struct timespec *timeout)
+{
+        return syscall(__NR_io_getevents, ctx_id, min_nr, nr, events, timeout);
+}
+
+#endif
+
+/* The AIO_MMAP cases force the mmapped page into memory here
+ * rather than in whatever place first touches the data.  I used
+ * to do this by touching the page, but that's delicate because
+ * gcc is prone to optimizing that away.  So, what's done here
+ * is we read from the descriptor from which the page was
+ * mapped.  The caller is required to pass an offset which is
+ * inside the page that was mapped.  Thus, when the read
+ * returns, we know that the page is in the page cache, and
+ * that it now backs the mmapped area.
+ */
+
+static int do_aio(aio_context_t ctx, struct aio_context *aio)
+{
+        struct iocb iocb, *iocbp = &iocb;
+        char c;
+        int err;
+
+        iocb = ((struct iocb) { .aio_data      = (unsigned long) aio,
+                                .aio_reqprio   = 0,
+                                .aio_fildes    = aio->fd,
+                                .aio_buf       = (unsigned long) aio->data,
+                                .aio_nbytes    = aio->len,
+                                .aio_offset    = aio->offset,
+                                .aio_reserved1 = 0,
+                                .aio_reserved2 = 0,
+                                .aio_reserved3 = 0 });
+
+        switch(aio->type){
+        case AIO_READ:
+                iocb.aio_lio_opcode = IOCB_CMD_PREAD;
+                break;
+        case AIO_WRITE:
+                iocb.aio_lio_opcode = IOCB_CMD_PWRITE;
+                break;
+        case AIO_MMAP:
+                iocb.aio_lio_opcode = IOCB_CMD_PREAD;
+                iocb.aio_buf = (unsigned long) &c;
+                iocb.aio_nbytes = sizeof(c);
+                break;
+        default:
+                printk("Bogus op in do_aio - %d\n", aio->type);
+                err = -EINVAL;
+                goto out;
+        }
+
+        err = io_submit(ctx, 1, &iocbp);
+        if(err > 0)
+                err = 0;
+
+ out:
+        return err;
+}
+
+static aio_context_t ctx = 0;
+
+static int aio_thread(void *arg)
+{
+        struct aio_thread_reply reply;
+        struct aio_context *aio;
+        struct io_event event;
+        int err, n;
+
+        signal(SIGWINCH, SIG_IGN);
+
+        while(1){
+                n = io_getevents(ctx, 1, 1, &event, NULL);
+                if(n < 0){
+                        if(errno == EINTR)
+                                continue;
+                        printk("aio_thread - io_getevents failed, "
+                               "errno = %d\n", errno);
+                }
+                else {
+                       aio = (struct aio_context *) event.data;
+                       if(update_aio(aio, event.res)){
+                               do_aio(ctx, aio);
+                               continue;
+                       }
+
+                        reply = ((struct aio_thread_reply)
+                               { .data = aio,
+                                 .err  = aio->len });
+                       err = os_write_file(aio->reply_fd, &reply,
+                                           sizeof(reply));
+                        if(err != sizeof(reply))
+                               printk("aio_thread - write failed, "
+                                      "fd = %d, err = %d\n", aio->reply_fd,
+                                      -err);
+                }
+        }
+        return 0;
+}
+
+#endif
+
+static int do_not_aio(struct aio_context *aio)
+{
+        char c;
+        int err;
+
+        switch(aio->type){
+        case AIO_READ:
+                err = os_seek_file(aio->fd, aio->offset);
+                if(err)
+                        goto out;
+
+                err = os_read_file(aio->fd, aio->data, aio->len);
+                break;
+        case AIO_WRITE:
+                err = os_seek_file(aio->fd, aio->offset);
+                if(err)
+                        goto out;
+
+                err = os_write_file(aio->fd, aio->data, aio->len);
+                break;
+        case AIO_MMAP:
+                err = os_seek_file(aio->fd, aio->offset);
+                if(err)
+                        goto out;
+
+                err = os_read_file(aio->fd, &c, sizeof(c));
+                break;
+        default:
+                printk("do_not_aio - bad request type : %d\n", aio->type);
+                err = -EINVAL;
+                break;
+        }
+
+ out:
+        return err;
+}
+
+static int not_aio_thread(void *arg)
+{
+        struct aio_context *aio;
+        struct aio_thread_reply reply;
+        int err;
+
+        signal(SIGWINCH, SIG_IGN);
+        while(1){
+                err = os_read_file(aio_req_fd_r, &aio, sizeof(aio));
+                if(err != sizeof(aio)){
+                        if(err < 0)
+                                printk("not_aio_thread - read failed, "
+                                       "fd = %d, err = %d\n", aio_req_fd_r,
+                                       -err);
+                        else {
+                                printk("not_aio_thread - short read, fd = %d, "
+                                       "length = %d\n", aio_req_fd_r, err);
+                        }
+                        continue;
+                }
+ again:
+                err = do_not_aio(aio);
+
+                if(update_aio(aio, err))
+                        goto again;
+
+                reply = ((struct aio_thread_reply) { .data     = aio,
+                                                     .err      = aio->len });
+                err = os_write_file(aio->reply_fd, &reply, sizeof(reply));
+                if(err != sizeof(reply))
+                        printk("not_aio_thread - write failed, fd = %d, "
+                               "err = %d\n", aio_req_fd_r, -err);
+        }
+}
+
+static int submit_aio_24(struct aio_context *aio)
+{
+        int err;
+
+        err = os_write_file(aio_req_fd_w, &aio, sizeof(aio));
+        if(err == sizeof(aio))
+                err = 0;
+
+        return err;
+}
+
+static int aio_pid = -1;
+static int (*submit_proc)(struct aio_context *aio);
+
+static int init_aio_24(void)
+{
+        unsigned long stack;
+        int fds[2], err;
+
+        err = os_pipe(fds, 1, 1);
+        if(err)
+                goto out;
+
+        aio_req_fd_w = fds[0];
+        aio_req_fd_r = fds[1];
+        err = run_helper_thread(not_aio_thread, NULL,
+                                CLONE_FILES | CLONE_VM | SIGCHLD, &stack, 0);
+        if(err < 0)
+                goto out_close_pipe;
+
+        aio_pid = err;
+        goto out;
+
+ out_close_pipe:
+        os_close_file(fds[0]);
+        os_close_file(fds[1]);
+        aio_req_fd_w = -1;
+        aio_req_fd_r = -1;
+ out:
+#ifndef HAVE_AIO_ABI
+       printk("/usr/include/linux/aio_abi.h not present during build\n");
+#endif
+       printk("2.6 host AIO support not used - falling back to I/O "
+              "thread\n");
+
+       submit_proc = submit_aio_24;
+
+        return 0;
+}
+
+#ifdef HAVE_AIO_ABI
+#define DEFAULT_24_AIO 0
+static int submit_aio_26(struct aio_context *aio)
+{
+       struct aio_thread_reply reply;
+       int err;
+
+       err = do_aio(ctx, aio);
+       if(err){
+               reply = ((struct aio_thread_reply) { .data = aio,
+                                                    .err  = err });
+               err = os_write_file(aio->reply_fd, &reply, sizeof(reply));
+               if(err != sizeof(reply))
+                       printk("submit_aio_26 - write failed, "
+                              "fd = %d, err = %d\n", aio->reply_fd, -err);
+               else err = 0;
+       }
+
+       return err;
+}
+
+static int init_aio_26(void)
+{
+        unsigned long stack;
+        int err;
+
+        if(io_setup(256, &ctx)){
+                printk("aio_thread failed to initialize context, err = %d\n",
+                       errno);
+                return -errno;
+        }
+
+        err = run_helper_thread(aio_thread, NULL,
+                                CLONE_FILES | CLONE_VM | SIGCHLD, &stack, 0);
+        if(err < 0)
+                return -errno;
+
+        aio_pid = err;
+
+       printk("Using 2.6 host AIO\n");
+
+       submit_proc = submit_aio_26;
+
+        return 0;
+}
+
+#else
+#define DEFAULT_24_AIO 1
+static int submit_aio_26(struct aio_context *aio)
+{
+        return -ENOSYS;
+}
+
+static int init_aio_26(void)
+{
+       submit_proc = submit_aio_26;
+        return -ENOSYS;
+}
+#endif
+
+static int aio_24 = DEFAULT_24_AIO;
+
+static int __init set_aio_24(char *name, int *add)
+{
+        aio_24 = 1;
+        return 0;
+}
+
+__uml_setup("aio=2.4", set_aio_24,
+"aio=2.4\n"
+"    This is used to force UML to use 2.4-style AIO even when 2.6 AIO is\n"
+"    available.  2.4 AIO is a single thread that handles one request at a\n"
+"    time, synchronously.  2.6 AIO is a thread which uses the 2.6 AIO \n"
+"    interface to handle an arbitrary number of pending requests.  2.6 AIO \n"
+"    is not available in tt mode, on 2.4 hosts, or when UML is built with\n"
+"    /usr/include/linux/aio_abi.h not available.  Many distributions don't\n"
+"    include aio_abi.h, so you will need to copy it from a kernel tree to\n"
+"    your /usr/include/linux in order to build an AIO-capable UML\n\n"
+);
+
+static int init_aio(void)
+{
+        int err;
+
+        CHOOSE_MODE(({
+                if(!aio_24){
+                        printk("Disabling 2.6 AIO in tt mode\n");
+                        aio_24 = 1;
+                } }), (void) 0);
+
+        if(!aio_24){
+                err = init_aio_26();
+                if(err && (errno == ENOSYS)){
+                        printk("2.6 AIO not supported on the host - "
+                               "reverting to 2.4 AIO\n");
+                        aio_24 = 1;
+                }
+                else return err;
+        }
+
+        if(aio_24)
+                return init_aio_24();
+
+        return 0;
+}
+
+/* The reason for the __initcall/__uml_exitcall asymmetry is that init_aio
+ * needs to be called when the kernel is running because it calls run_helper,
+ * which needs get_free_page.  exit_aio is a __uml_exitcall because the generic
+ * kernel does not run __exitcalls on shutdown, and can't because many of them
+ * break when called outside of module unloading.
+ */
+__initcall(init_aio);
+
+static void exit_aio(void)
+{
+        if(aio_pid != -1)
+                os_kill_process(aio_pid, 1);
+}
+
+__uml_exitcall(exit_aio);
+
+int submit_aio(struct aio_context *aio)
+{
+       return (*submit_proc)(aio);
+}
index 1e126bfd31a7b89b5d9663ae4a1b7cefcb294422..d32413e4b4ce21faa2f3b61dbb690b6fecd90d87 100644 (file)
@@ -3,10 +3,10 @@
  * Licensed under the GPL
  */
 
-#include <unistd.h>
 #include <stdio.h>
 #include <errno.h>
 #include <signal.h>
+#include <setjmp.h>
 #include <linux/unistd.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
 #include "os.h"
 #include "user.h"
 #include "user_util.h"
+#include "signal_user.h"
+#include "process.h"
+#include "irq_user.h"
+#include "kern_util.h"
 
 #define ARBITRARY_ADDR -1
 #define FAILURE_PID    -1
@@ -114,8 +118,10 @@ void os_usr1_process(int pid)
        kill(pid, SIGUSR1);
 }
 
-/*Don't use the glibc version, which caches the result in TLS. It misses some
- * syscalls, and also breaks with clone(), which does not unshare the TLS.*/
+/* Don't use the glibc version, which caches the result in TLS. It misses some
+ * syscalls, and also breaks with clone(), which does not unshare the TLS.
+ */
+
 inline _syscall0(pid_t, getpid)
 
 int os_getpid(void)
@@ -164,6 +170,52 @@ int os_unmap_memory(void *addr, int len)
         return(0);
 }
 
+void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int))
+{
+       int flags = 0, pages;
+
+       if(sig_stack != NULL){
+               pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER);
+               set_sigstack(sig_stack, pages * page_size());
+               flags = SA_ONSTACK;
+       }
+       if(usr1_handler) set_handler(SIGUSR1, usr1_handler, flags, -1);
+}
+
+void init_new_thread_signals(int altstack)
+{
+       int flags = altstack ? SA_ONSTACK : 0;
+
+       set_handler(SIGSEGV, (__sighandler_t) sig_handler, flags,
+                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+       set_handler(SIGTRAP, (__sighandler_t) sig_handler, flags,
+                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+       set_handler(SIGFPE, (__sighandler_t) sig_handler, flags,
+                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+       set_handler(SIGILL, (__sighandler_t) sig_handler, flags,
+                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+       set_handler(SIGBUS, (__sighandler_t) sig_handler, flags,
+                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+       set_handler(SIGUSR2, (__sighandler_t) sig_handler,
+                   flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+       signal(SIGHUP, SIG_IGN);
+
+       init_irq_signals(altstack);
+}
+
+int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr)
+{
+       sigjmp_buf buf;
+       int n;
+
+       *jmp_ptr = &buf;
+       n = sigsetjmp(buf, 1);
+       if(n != 0)
+               return(n);
+       (*fn)(arg);
+       return(0);
+}
+
 /*
  * Overrides for Emacs so that we follow Linus's tabbing style.
  * Emacs will notice this stuff at the end of the file and automatically
similarity index 61%
rename from arch/um/kernel/process.c
rename to arch/um/os-Linux/start_up.c
index 67acd92c5322f14cc96c6186a7336df51906718d..040cc1472bc77d4ad44ca7022c253bdda9fbe4ef 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
  * Licensed under the GPL
  */
@@ -19,7 +19,6 @@
 #include "user_util.h"
 #include "kern_util.h"
 #include "user.h"
-#include "process.h"
 #include "signal_kern.h"
 #include "signal_user.h"
 #include "sysdep/ptrace.h"
 #include "registers.h"
 #endif
 
-void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int))
-{
-       int flags = 0, pages;
-
-       if(sig_stack != NULL){
-               pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER);
-               set_sigstack(sig_stack, pages * page_size());
-               flags = SA_ONSTACK;
-       }
-       if(usr1_handler) set_handler(SIGUSR1, usr1_handler, flags, -1);
-}
-
-void init_new_thread_signals(int altstack)
-{
-       int flags = altstack ? SA_ONSTACK : 0;
-
-       set_handler(SIGSEGV, (__sighandler_t) sig_handler, flags,
-                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
-       set_handler(SIGTRAP, (__sighandler_t) sig_handler, flags, 
-                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
-       set_handler(SIGFPE, (__sighandler_t) sig_handler, flags, 
-                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
-       set_handler(SIGILL, (__sighandler_t) sig_handler, flags, 
-                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
-       set_handler(SIGBUS, (__sighandler_t) sig_handler, flags, 
-                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
-       set_handler(SIGUSR2, (__sighandler_t) sig_handler, 
-                   flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
-       signal(SIGHUP, SIG_IGN);
-
-       init_irq_signals(altstack);
-}
-
-struct tramp {
-       int (*tramp)(void *);
-       void *tramp_data;
-       unsigned long temp_stack;
-       int flags;
-       int pid;
-};
-
-/* See above for why sigkill is here */
-
-int sigkill = SIGKILL;
-
-int outer_tramp(void *arg)
-{
-       struct tramp *t;
-       int sig = sigkill;
-
-       t = arg;
-       t->pid = clone(t->tramp, (void *) t->temp_stack + page_size()/2,
-                      t->flags, t->tramp_data);
-       if(t->pid > 0) wait_for_stop(t->pid, SIGSTOP, PTRACE_CONT, NULL);
-       kill(os_getpid(), sig);
-       _exit(0);
-}
-
-int start_fork_tramp(void *thread_arg, unsigned long temp_stack, 
-                    int clone_flags, int (*tramp)(void *))
-{
-       struct tramp arg;
-       unsigned long sp;
-       int new_pid, status, err;
-
-       /* The trampoline will run on the temporary stack */
-       sp = stack_sp(temp_stack);
-
-       clone_flags |= CLONE_FILES | SIGCHLD;
-
-       arg.tramp = tramp;
-       arg.tramp_data = thread_arg;
-       arg.temp_stack = temp_stack;
-       arg.flags = clone_flags;
-
-       /* Start the process and wait for it to kill itself */
-       new_pid = clone(outer_tramp, (void *) sp, clone_flags, &arg);
-       if(new_pid < 0)
-               return(new_pid);
-
-       CATCH_EINTR(err = waitpid(new_pid, &status, 0));
-       if(err < 0)
-               panic("Waiting for outer trampoline failed - errno = %d",
-                     errno);
-
-       if(!WIFSIGNALED(status) || (WTERMSIG(status) != SIGKILL))
-               panic("outer trampoline didn't exit with SIGKILL, "
-                     "status = %d", status);
-
-       return(arg.pid);
-}
-
 static int ptrace_child(void *arg)
 {
        int ret;
@@ -165,7 +72,7 @@ static int start_ptraced_child(void **stack_out)
        void *stack;
        unsigned long sp;
        int pid, n, status;
-       
+
        stack = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC,
                     MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
        if(stack == MAP_FAILED)
@@ -173,10 +80,10 @@ static int start_ptraced_child(void **stack_out)
        sp = (unsigned long) stack + PAGE_SIZE - sizeof(void *);
        pid = clone(ptrace_child, (void *) sp, SIGCHLD, NULL);
        if(pid < 0)
-               panic("check_ptrace : clone failed, errno = %d", errno);
+               panic("start_ptraced_child : clone failed, errno = %d", errno);
        CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
        if(n < 0)
-               panic("check_ptrace : wait failed, errno = %d", errno);
+               panic("check_ptrace : clone failed, errno = %d", errno);
        if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP))
                panic("check_ptrace : expected SIGSTOP, got status = %d",
                      status);
@@ -185,11 +92,14 @@ static int start_ptraced_child(void **stack_out)
        return(pid);
 }
 
-/* When testing for SYSEMU support, if it is one of the broken versions, we must
- * just avoid using sysemu, not panic, but only if SYSEMU features are broken.
+/* When testing for SYSEMU support, if it is one of the broken versions, we
+ * must just avoid using sysemu, not panic, but only if SYSEMU features are
+ * broken.
  * So only for SYSEMU features we test mustpanic, while normal host features
- * must work anyway!*/
-static int stop_ptraced_child(int pid, void *stack, int exitcode, int mustpanic)
+ * must work anyway!
+ */
+static int stop_ptraced_child(int pid, void *stack, int exitcode,
+                             int mustpanic)
 {
        int status, n, ret = 0;
 
@@ -217,8 +127,6 @@ static int stop_ptraced_child(int pid, void *stack, int exitcode, int mustpanic)
        return ret;
 }
 
-static int force_sysemu_disabled = 0;
-
 int ptrace_faultinfo = 1;
 int proc_mm = 1;
 
@@ -228,29 +136,32 @@ static int __init skas0_cmd_param(char *str, int* add)
        return 0;
 }
 
+__uml_setup("skas0", skas0_cmd_param,
+               "skas0\n"
+               "    Disables SKAS3 usage, so that SKAS0 is used, unless \n"
+               "    you specify mode=tt.\n\n");
+
+static int force_sysemu_disabled = 0;
+
 static int __init nosysemu_cmd_param(char *str, int* add)
 {
        force_sysemu_disabled = 1;
        return 0;
 }
 
-__uml_setup("skas0", skas0_cmd_param,
-               "skas0\n"
-               "    Disables SKAS3 usage, so that SKAS0 is used, unless you \n"
-               "    specify mode=tt.\n\n");
-
 __uml_setup("nosysemu", nosysemu_cmd_param,
-               "nosysemu\n"
-               "    Turns off syscall emulation patch for ptrace (SYSEMU) on.\n"
-               "    SYSEMU is a performance-patch introduced by Laurent Vivier. It changes\n"
-               "    behaviour of ptrace() and helps reducing host context switch rate.\n"
-               "    To make it working, you need a kernel patch for your host, too.\n"
-               "    See http://perso.wanadoo.fr/laurent.vivier/UML/ for further information.\n\n");
+"nosysemu\n"
+"    Turns off syscall emulation patch for ptrace (SYSEMU) on.\n"
+"    SYSEMU is a performance-patch introduced by Laurent Vivier. It changes\n"
+"    behaviour of ptrace() and helps reducing host context switch rate.\n"
+"    To make it working, you need a kernel patch for your host, too.\n"
+"    See http://perso.wanadoo.fr/laurent.vivier/UML/ for further \n"
+"    information.\n\n");
 
 static void __init check_sysemu(void)
 {
        void *stack;
-       int pid, syscall, n, status, count=0;
+       int pid, n, status, count=0;
 
        printk("Checking syscall emulation patch for ptrace...");
        sysemu_supported = 0;
@@ -281,6 +192,12 @@ static void __init check_sysemu(void)
 
        printk("Checking advanced syscall emulation patch for ptrace...");
        pid = start_ptraced_child(&stack);
+
+       if(ptrace(PTRACE_OLDSETOPTIONS, pid, 0,
+                 (void *) PTRACE_O_TRACESYSGOOD) < 0)
+               panic("check_ptrace: PTRACE_OLDSETOPTIONS failed, errno = %d",
+                     errno);
+
        while(1){
                count++;
                if(ptrace(PTRACE_SYSEMU_SINGLESTEP, pid, 0, 0) < 0)
@@ -288,15 +205,10 @@ static void __init check_sysemu(void)
                CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
                if(n < 0)
                        panic("check_ptrace : wait failed, errno = %d", errno);
-               if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
-                       panic("check_ptrace : expected (SIGTRAP|SYSCALL_TRAP), "
-                             "got status = %d", status);
-
-               syscall = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_NR_OFFSET,
-                                0);
-               if(syscall == __NR_getpid){
+               if(WIFSTOPPED(status) && (WSTOPSIG(status) == (SIGTRAP|0x80))){
                        if (!count)
-                               panic("check_ptrace : SYSEMU_SINGLESTEP doesn't singlestep");
+                               panic("check_ptrace : SYSEMU_SINGLESTEP "
+                                     "doesn't singlestep");
                        n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET,
                                   os_getpid());
                        if(n < 0)
@@ -304,6 +216,11 @@ static void __init check_sysemu(void)
                                      "call return, errno = %d", errno);
                        break;
                }
+               else if(WIFSTOPPED(status) && (WSTOPSIG(status) == SIGTRAP))
+                       count++;
+               else
+                       panic("check_ptrace : expected SIGTRAP or "
+                             "(SIGTRAP|0x80), got status = %d", status);
        }
        if (stop_ptraced_child(pid, stack, 0, 0) < 0)
                goto fail_stopped;
@@ -321,7 +238,7 @@ fail_stopped:
        printk("missing\n");
 }
 
-void __init check_ptrace(void)
+static void __init check_ptrace(void)
 {
        void *stack;
        int pid, syscall, n, status;
@@ -329,20 +246,20 @@ void __init check_ptrace(void)
        printk("Checking that ptrace can change system call numbers...");
        pid = start_ptraced_child(&stack);
 
-       if (ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0)
-               panic("check_ptrace: PTRACE_SETOPTIONS failed, errno = %d", errno);
+       if(ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0)
+               panic("check_ptrace: PTRACE_OLDSETOPTIONS failed, errno = %d", errno);
 
        while(1){
                if(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0)
-                       panic("check_ptrace : ptrace failed, errno = %d", 
+                       panic("check_ptrace : ptrace failed, errno = %d",
                              errno);
                CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
                if(n < 0)
                        panic("check_ptrace : wait failed, errno = %d", errno);
-               if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP + 0x80))
-                       panic("check_ptrace : expected SIGTRAP + 0x80, "
+               if(!WIFSTOPPED(status) || (WSTOPSIG(status) != (SIGTRAP|0x80)))
+                       panic("check_ptrace : expected (SIGTRAP|0x80), "
                              "got status = %d", status);
-               
+
                syscall = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_NR_OFFSET,
                                 0);
                if(syscall == __NR_getpid){
@@ -359,33 +276,36 @@ void __init check_ptrace(void)
        check_sysemu();
 }
 
-int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr)
+void os_early_checks(void)
 {
-       sigjmp_buf buf;
-       int n;
-
-       *jmp_ptr = &buf;
-       n = sigsetjmp(buf, 1);
-       if(n != 0)
-               return(n);
-       (*fn)(arg);
-       return(0);
+       check_ptrace();
 }
 
-void forward_pending_sigio(int target)
+static int __init noprocmm_cmd_param(char *str, int* add)
 {
-       sigset_t sigs;
+       proc_mm = 0;
+       return 0;
+}
+
+__uml_setup("noprocmm", noprocmm_cmd_param,
+"noprocmm\n"
+"    Turns off usage of /proc/mm, even if host supports it.\n"
+"    To support /proc/mm, the host needs to be patched using\n"
+"    the current skas3 patch.\n\n");
 
-       if(sigpending(&sigs)) 
-               panic("forward_pending_sigio : sigpending failed");
-       if(sigismember(&sigs, SIGIO))
-               kill(target, SIGIO);
+static int __init noptracefaultinfo_cmd_param(char *str, int* add)
+{
+       ptrace_faultinfo = 0;
+       return 0;
 }
 
-extern void *__syscall_stub_start, __syscall_stub_end;
+__uml_setup("noptracefaultinfo", noptracefaultinfo_cmd_param,
+"noptracefaultinfo\n"
+"    Turns off usage of PTRACE_FAULTINFO, even if host supports\n"
+"    it. To support PTRACE_FAULTINFO, the host needs to be patched\n"
+"    using the current skas3 patch.\n\n");
 
 #ifdef UML_CONFIG_MODE_SKAS
-
 static inline void check_skas3_ptrace_support(void)
 {
        struct ptrace_faultinfo fi;
@@ -400,9 +320,8 @@ static inline void check_skas3_ptrace_support(void)
                ptrace_faultinfo = 0;
                if(errno == EIO)
                        printf("not found\n");
-               else {
+               else
                        perror("not found");
-               }
        }
        else {
                if (!ptrace_faultinfo)
@@ -419,9 +338,10 @@ int can_do_skas(void)
 {
        printf("Checking for /proc/mm...");
        if (os_access("/proc/mm", OS_ACC_W_OK) < 0) {
-               proc_mm = 0;
+               proc_mm = 0;
                printf("not found\n");
-       } else {
+       }
+       else {
                if (!proc_mm)
                        printf("found but disabled on command line\n");
                else
diff --git a/arch/um/os-Linux/tt.c b/arch/um/os-Linux/tt.c
new file mode 100644 (file)
index 0000000..5b047ab
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Licensed under the GPL
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <signal.h>
+#include <sched.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <setjmp.h>
+#include <sys/time.h>
+#include <sys/ptrace.h>
+#include <linux/ptrace.h>
+#include <sys/wait.h>
+#include <sys/mman.h>
+#include <asm/ptrace.h>
+#include <asm/unistd.h>
+#include <asm/page.h>
+#include "user_util.h"
+#include "kern_util.h"
+#include "user.h"
+#include "signal_kern.h"
+#include "signal_user.h"
+#include "sysdep/ptrace.h"
+#include "sysdep/sigcontext.h"
+#include "irq_user.h"
+#include "ptrace_user.h"
+#include "time_user.h"
+#include "init.h"
+#include "os.h"
+#include "uml-config.h"
+#include "choose-mode.h"
+#include "mode.h"
+#include "tempfile.h"
+
+/*
+ *-------------------------
+ * only for tt mode (will be deleted in future...)
+ *-------------------------
+ */
+
+struct tramp {
+       int (*tramp)(void *);
+       void *tramp_data;
+       unsigned long temp_stack;
+       int flags;
+       int pid;
+};
+
+/* See above for why sigkill is here */
+
+int sigkill = SIGKILL;
+
+int outer_tramp(void *arg)
+{
+       struct tramp *t;
+       int sig = sigkill;
+
+       t = arg;
+       t->pid = clone(t->tramp, (void *) t->temp_stack + page_size()/2,
+                      t->flags, t->tramp_data);
+       if(t->pid > 0) wait_for_stop(t->pid, SIGSTOP, PTRACE_CONT, NULL);
+       kill(os_getpid(), sig);
+       _exit(0);
+}
+
+int start_fork_tramp(void *thread_arg, unsigned long temp_stack,
+                    int clone_flags, int (*tramp)(void *))
+{
+       struct tramp arg;
+       unsigned long sp;
+       int new_pid, status, err;
+
+       /* The trampoline will run on the temporary stack */
+       sp = stack_sp(temp_stack);
+
+       clone_flags |= CLONE_FILES | SIGCHLD;
+
+       arg.tramp = tramp;
+       arg.tramp_data = thread_arg;
+       arg.temp_stack = temp_stack;
+       arg.flags = clone_flags;
+
+       /* Start the process and wait for it to kill itself */
+       new_pid = clone(outer_tramp, (void *) sp, clone_flags, &arg);
+       if(new_pid < 0)
+               return(new_pid);
+
+       CATCH_EINTR(err = waitpid(new_pid, &status, 0));
+       if(err < 0)
+               panic("Waiting for outer trampoline failed - errno = %d",
+                     errno);
+
+       if(!WIFSIGNALED(status) || (WTERMSIG(status) != SIGKILL))
+               panic("outer trampoline didn't exit with SIGKILL, "
+                     "status = %d", status);
+
+       return(arg.pid);
+}
+
+void forward_pending_sigio(int target)
+{
+       sigset_t sigs;
+
+       if(sigpending(&sigs))
+               panic("forward_pending_sigio : sigpending failed");
+       if(sigismember(&sigs, SIGIO))
+               kill(target, SIGIO);
+}
+
index 802d027a1e13007a12dae1b0a1a329296853c0ce..b2165188d94219301225b6a4a1aaf1fb961cd3f5 100644 (file)
@@ -12,7 +12,7 @@ $(obj)/unmap.o: _c_flags = $(call unprofile,$(CFLAGS))
 
 quiet_cmd_wrapld = LD      $@
 define cmd_wrapld
-       $(LD) $(LDFLAGS) -r -o $(obj)/unmap_tmp.o $< $(shell $(CC) $(CFLAGS) -print-file-name=libc.a); \
+       $(LD) $(LDFLAGS) -r -o $(obj)/unmap_tmp.o $< ; \
        $(OBJCOPY) $(UML_OBJCOPYFLAGS) $(obj)/unmap_tmp.o $@ -G switcheroo
 endef
 
index 77c3c4d29f55f48702ef4e1e42d8b00b082f273e..4ca2a229da4997adebe0bc5f0425727bdda0e790 100644 (file)
@@ -16,13 +16,7 @@ semaphore.c-dir = kernel
 highmem.c-dir = mm
 module.c-dir = kernel
 
-STUB_CFLAGS = -Wp,-MD,$(depfile) $(call unprofile,$(USER_CFLAGS))
-
-# _cflags works with kernel files, not with userspace ones, but c_flags does,
-# why ask why?
-$(obj)/stub_segv.o : c_flags = $(STUB_CFLAGS)
-
-$(obj)/stub.o : a_flags = $(STUB_CFLAGS)
+$(obj)/stub_segv.o : _c_flags = $(call unprofile,$(CFLAGS))
 
 subdir- := util
 
index 4efc69a039d70022592cec5430a46a1c9a08c826..16bc19928b3c53c49d93ca825798d42d256fdc06 100644 (file)
@@ -122,9 +122,9 @@ int copy_sc_from_user_tt(struct sigcontext *to, struct sigcontext *from,
        int err;
 
        to_fp = to->fpstate;
-       from_fp = from->fpstate;
        sigs = to->oldmask;
        err = copy_from_user(to, from, sizeof(*to));
+       from_fp = to->fpstate;
        to->oldmask = sigs;
        to->fpstate = to_fp;
        if(to_fp != NULL)
index 2f2c70a8f043440ef99f68c20332158292407972..6a70d9ab5c2905177429ba9b0f3ae2c1fc084fad 100644 (file)
@@ -2,7 +2,50 @@
 
        .globl syscall_stub
 .section .__syscall_stub, "x"
-syscall_stub:
-       int     $0x80
+
+       .globl batch_syscall_stub
+batch_syscall_stub:
+       /* load pointer to first operation */
+       mov     $(UML_CONFIG_STUB_DATA+8), %esp
+
+again:
+       /* load length of additional data */
+       mov     0x0(%esp), %eax
+
+       /* if(length == 0) : end of list */
+       /* write possible 0 to header */
+       mov     %eax, UML_CONFIG_STUB_DATA+4
+       cmpl    $0, %eax
+       jz      done
+
+       /* save current pointer */
+       mov     %esp, UML_CONFIG_STUB_DATA+4
+
+       /* skip additional data */
+       add     %eax, %esp
+
+       /* load syscall-# */
+       pop     %eax
+
+       /* load syscall params */
+       pop     %ebx
+       pop     %ecx
+       pop     %edx
+       pop     %esi
+       pop     %edi
+       pop     %ebp
+
+       /* execute syscall */
+       int     $0x80
+
+       /* check return value */
+       pop     %ebx
+       cmp     %ebx, %eax
+       je      again
+
+done:
+       /* save return value */
        mov     %eax, UML_CONFIG_STUB_DATA
+
+       /* stop */
        int3
index 68aeabe3a654703b76d20633ba7b3d36832060a4..1e88b275edacea8dede15209a158c2b4ad279cc4 100644 (file)
@@ -3,8 +3,7 @@
  * Licensed under the GPL
  */
 
-#include <signal.h>
-#include <asm/sigcontext.h>
+#include <asm/signal.h>
 #include <asm/unistd.h>
 #include "uml-config.h"
 #include "sysdep/sigcontext.h"
index 7488206ce6f4ae91ba20123a9efcede188b10996..f0ab574d1e95b6bc64a583e3ac1e6ac42ede4f03 100644 (file)
@@ -6,7 +6,7 @@
 
 #XXX: why into lib-y?
 lib-y = bitops.o bugs.o csum-partial.o delay.o fault.o mem.o memcpy.o \
-       ptrace.o ptrace_user.o semaphore.o sigcontext.o signal.o stub.o \
+       ptrace.o ptrace_user.o sigcontext.o signal.o stub.o \
        stub_segv.o syscalls.o syscall_table.o sysrq.o thunk.o
 
 obj-y := ksyms.o
@@ -15,7 +15,7 @@ obj-$(CONFIG_MODULES) += module.o um_module.o
 USER_OBJS := ptrace_user.o sigcontext.o
 
 SYMLINKS = bitops.c csum-copy.S csum-partial.c csum-wrappers.c memcpy.S \
-       semaphore.c thunk.S module.c
+       thunk.S module.c
 
 include arch/um/scripts/Makefile.rules
 
@@ -24,17 +24,10 @@ csum-copy.S-dir = lib
 csum-partial.c-dir = lib
 csum-wrappers.c-dir = lib
 memcpy.S-dir = lib
-semaphore.c-dir = kernel
 thunk.S-dir = lib
 module.c-dir = kernel
 
-STUB_CFLAGS = -Wp,-MD,$(depfile) $(call unprofile,$(USER_CFLAGS))
-
-# _cflags works with kernel files, not with userspace ones, but c_flags does,
-# why ask why?
-$(obj)/stub_segv.o : c_flags = $(STUB_CFLAGS)
-
-$(obj)/stub.o : a_flags = $(STUB_CFLAGS)
+$(obj)/stub_segv.o: _c_flags = $(call unprofile,$(CFLAGS))
 
 subdir- := util
 
index 8fdaed06c10dcce12aed363bb7abe32788d8e441..fe1d065332b11d33f215a8f4a43654be69aff7a9 100644 (file)
@@ -104,28 +104,35 @@ int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp,
 int copy_sc_from_user_tt(struct sigcontext *to, struct sigcontext *from,
                         int fpsize)
 {
-       struct _fpstate *to_fp, *from_fp;
-       unsigned long sigs;
-       int err;
-
-       to_fp = to->fpstate;
-       from_fp = from->fpstate;
-       sigs = to->oldmask;
-       err = copy_from_user(to, from, sizeof(*to));
-       to->oldmask = sigs;
-       return(err);
+       struct _fpstate *to_fp, *from_fp;
+       unsigned long sigs;
+       int err;
+
+       to_fp = to->fpstate;
+       sigs = to->oldmask;
+       err = copy_from_user(to, from, sizeof(*to));
+       from_fp = to->fpstate;
+       to->fpstate = to_fp;
+       to->oldmask = sigs;
+       if(to_fp != NULL)
+               err |= copy_from_user(to_fp, from_fp, fpsize);
+       return(err);
 }
 
 int copy_sc_to_user_tt(struct sigcontext *to, struct _fpstate *fp,
                       struct sigcontext *from, int fpsize)
 {
-       struct _fpstate *to_fp, *from_fp;
-       int err;
-
-       to_fp = (fp ? fp : (struct _fpstate *) (to + 1));
-       from_fp = from->fpstate;
-       err = copy_to_user(to, from, sizeof(*to));
-       return(err);
+       struct _fpstate *to_fp, *from_fp;
+       int err;
+
+       to_fp = (fp ? fp : (struct _fpstate *) (to + 1));
+       from_fp = from->fpstate;
+       err = copy_to_user(to, from, sizeof(*to));
+       if(from_fp != NULL){
+               err |= copy_to_user(&to->fpstate, &to_fp, sizeof(to->fpstate));
+               err |= copy_to_user(to_fp, from_fp, fpsize);
+       }
+       return(err);
 }
 
 #endif
index 31c14925716bc1c2cf7db2be034e79738c4cb0fa..03c2797357842f2ad8cc4d61651c1e110d88ddb5 100644 (file)
@@ -13,3 +13,54 @@ syscall_stub:
        or      %rcx, %rbx
        movq    %rax, (%rbx)
        int3
+
+       .globl batch_syscall_stub
+batch_syscall_stub:
+       mov     $(UML_CONFIG_STUB_DATA >> 32), %rbx
+       sal     $32, %rbx
+       mov     $(UML_CONFIG_STUB_DATA & 0xffffffff), %rax
+       or      %rax, %rbx
+       /* load pointer to first operation */
+       mov     %rbx, %rsp
+       add     $0x10, %rsp
+again:
+       /* load length of additional data */
+       mov     0x0(%rsp), %rax
+
+       /* if(length == 0) : end of list */
+       /* write possible 0 to header */
+       mov     %rax, 8(%rbx)
+       cmp     $0, %rax
+       jz      done
+
+       /* save current pointer */
+       mov     %rsp, 8(%rbx)
+
+       /* skip additional data */
+       add     %rax, %rsp
+
+       /* load syscall-# */
+       pop     %rax
+
+       /* load syscall params */
+       pop     %rdi
+       pop     %rsi
+       pop     %rdx
+       pop     %r10
+       pop     %r8
+       pop     %r9
+
+       /* execute syscall */
+       syscall
+
+       /* check return value */
+       pop     %rcx
+       cmp     %rcx, %rax
+       je      again
+
+done:
+       /* save return value */
+       mov     %rax, (%rbx)
+
+       /* stop */
+       int3
index 161d1fe9c034f8d931447d6303ded11b278d65ef..65a131b362b689b634608f0ae83ddbc6ebf5e029 100644 (file)
@@ -3,9 +3,10 @@
  * Licensed under the GPL
  */
 
-#include <signal.h>
+#include <asm/signal.h>
 #include <linux/compiler.h>
 #include <asm/unistd.h>
+#include <asm/ucontext.h>
 #include "uml-config.h"
 #include "sysdep/sigcontext.h"
 #include "sysdep/faultinfo.h"
index 1b5ca3c3a6586195bead156fbebd5a436f730b91..1a5beda36e29e91a8e9edad4633f80d00970abca 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.12-uc0
-# Thu Jul 21 11:08:27 2005
+# Linux kernel version: 2.6.13-uc0
+# Fri Sep  2 13:54:27 2005
 #
 # CONFIG_MMU is not set
 # CONFIG_UID16 is not set
@@ -44,6 +44,8 @@ CONFIG_ZERO_BSS=y
 # CONFIG_V850E_HIGHRES_TIMER is not set
 # CONFIG_RESET_GUARD is not set
 CONFIG_LARGE_ALLOCS=y
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
 
 #
 # Code maturity level options
@@ -110,6 +112,52 @@ CONFIG_BINFMT_FLAT=y
 # CONFIG_BINFMT_SHARED_FLAT is not set
 # CONFIG_BINFMT_MISC is not set
 
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_PACKET is not set
+# CONFIG_UNIX is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+# CONFIG_IP_PNP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+# CONFIG_IP_TCPDIAG is not set
+# CONFIG_IP_TCPDIAG_IPV6 is not set
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_BIC=y
+# CONFIG_IPV6 is not set
+# CONFIG_NETFILTER is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+
 #
 # Generic Driver Options
 #
@@ -158,6 +206,7 @@ CONFIG_MTD_CFI_I2=y
 # Mapping drivers for chip access
 #
 # CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PLATRAM is not set
 
 #
 # Self-contained MTD device drivers
@@ -232,6 +281,7 @@ CONFIG_IOSCHED_NOOP=y
 #
 # Fusion MPT device support
 #
+# CONFIG_FUSION is not set
 
 #
 # IEEE 1394 (FireWire) support
@@ -244,53 +294,8 @@ CONFIG_IOSCHED_NOOP=y
 # CONFIG_I2O is not set
 
 #
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-# CONFIG_PACKET is not set
-# CONFIG_UNIX is not set
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-# CONFIG_IP_PNP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_TUNNEL is not set
-# CONFIG_IP_TCPDIAG is not set
-# CONFIG_IP_TCPDIAG_IPV6 is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
+# Network device support
 #
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
@@ -372,6 +377,8 @@ CONFIG_EEPRO100=y
 # CONFIG_FDDI is not set
 # CONFIG_PPP is not set
 # CONFIG_SLIP is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
 
 #
 # ISDN subsystem
@@ -472,6 +479,7 @@ CONFIG_SERIAL_CORE_CONSOLE=y
 # CONFIG_JBD is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
 
 #
 # XFS support
@@ -479,6 +487,8 @@ CONFIG_SERIAL_CORE_CONSOLE=y
 # CONFIG_XFS_FS is not set
 # CONFIG_MINIX_FS is not set
 CONFIG_ROMFS_FS=y
+# CONFIG_MAGIC_ROM_PTR is not set
+CONFIG_INOTIFY=y
 # CONFIG_QUOTA is not set
 CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
@@ -524,9 +534,11 @@ CONFIG_RAMFS=y
 #
 CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
 # CONFIG_NFSD is not set
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
 # CONFIG_SMB_FS is not set
 # CONFIG_CIFS is not set
index 44becc065404ef3ee0b5359a8b5c268836ed6603..15e66647806129086517246af4450612ba6bd971 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.12-uc0
-# Thu Jul 21 11:30:08 2005
+# Linux kernel version: 2.6.13-uc0
+# Fri Sep  2 13:47:50 2005
 #
 # CONFIG_MMU is not set
 # CONFIG_UID16 is not set
@@ -41,6 +41,8 @@ CONFIG_ZERO_BSS=y
 # CONFIG_V850E_HIGHRES_TIMER is not set
 # CONFIG_RESET_GUARD is not set
 CONFIG_LARGE_ALLOCS=y
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
 
 #
 # Code maturity level options
@@ -56,7 +58,6 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
 CONFIG_LOCALVERSION=""
 # CONFIG_BSD_PROCESS_ACCT is not set
 # CONFIG_SYSCTL is not set
-# CONFIG_AUDIT is not set
 # CONFIG_HOTPLUG is not set
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
@@ -103,6 +104,11 @@ CONFIG_BINFMT_FLAT=y
 # CONFIG_BINFMT_SHARED_FLAT is not set
 # CONFIG_BINFMT_MISC is not set
 
+#
+# Networking
+#
+# CONFIG_NET is not set
+
 #
 # Generic Driver Options
 #
@@ -151,6 +157,7 @@ CONFIG_MTD_CFI_I2=y
 # Mapping drivers for chip access
 #
 # CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PLATRAM is not set
 
 #
 # Self-contained MTD device drivers
@@ -218,6 +225,7 @@ CONFIG_IOSCHED_NOOP=y
 #
 # Fusion MPT device support
 #
+# CONFIG_FUSION is not set
 
 #
 # IEEE 1394 (FireWire) support
@@ -228,9 +236,8 @@ CONFIG_IOSCHED_NOOP=y
 #
 
 #
-# Networking support
+# Network device support
 #
-# CONFIG_NET is not set
 # CONFIG_NETPOLL is not set
 # CONFIG_NET_POLL_CONTROLLER is not set
 
@@ -311,7 +318,6 @@ CONFIG_SERIAL_CORE_CONSOLE=y
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
 
 #
@@ -335,6 +341,7 @@ CONFIG_SERIAL_CORE_CONSOLE=y
 # CONFIG_JBD is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
 
 #
 # XFS support
@@ -342,6 +349,8 @@ CONFIG_SERIAL_CORE_CONSOLE=y
 # CONFIG_XFS_FS is not set
 # CONFIG_MINIX_FS is not set
 CONFIG_ROMFS_FS=y
+# CONFIG_MAGIC_ROM_PTR is not set
+CONFIG_INOTIFY=y
 # CONFIG_QUOTA is not set
 CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
index d73f5f9d8383cad36448998a76e5ac18078c4871..f31ba7398ad009f6499c389bab3be5dc0de23efc 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.12-uc0
-# Thu Jul 21 11:29:27 2005
+# Linux kernel version: 2.6.13-uc0
+# Fri Sep  2 13:36:43 2005
 #
 # CONFIG_MMU is not set
 # CONFIG_UID16 is not set
@@ -36,6 +36,8 @@ CONFIG_NO_CACHE=y
 CONFIG_ZERO_BSS=y
 # CONFIG_RESET_GUARD is not set
 CONFIG_LARGE_ALLOCS=y
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
 
 #
 # Code maturity level options
@@ -51,7 +53,6 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
 CONFIG_LOCALVERSION=""
 # CONFIG_BSD_PROCESS_ACCT is not set
 # CONFIG_SYSCTL is not set
-# CONFIG_AUDIT is not set
 # CONFIG_HOTPLUG is not set
 # CONFIG_IKCONFIG is not set
 CONFIG_EMBEDDED=y
@@ -98,6 +99,11 @@ CONFIG_BINFMT_FLAT=y
 # CONFIG_BINFMT_SHARED_FLAT is not set
 # CONFIG_BINFMT_MISC is not set
 
+#
+# Networking
+#
+# CONFIG_NET is not set
+
 #
 # Generic Driver Options
 #
@@ -146,6 +152,7 @@ CONFIG_MTD_CFI_I2=y
 # Mapping drivers for chip access
 #
 # CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PLATRAM is not set
 
 #
 # Self-contained MTD device drivers
@@ -213,6 +220,7 @@ CONFIG_IOSCHED_NOOP=y
 #
 # Fusion MPT device support
 #
+# CONFIG_FUSION is not set
 
 #
 # IEEE 1394 (FireWire) support
@@ -223,9 +231,8 @@ CONFIG_IOSCHED_NOOP=y
 #
 
 #
-# Networking support
+# Network device support
 #
-# CONFIG_NET is not set
 # CONFIG_NETPOLL is not set
 # CONFIG_NET_POLL_CONTROLLER is not set
 
@@ -300,7 +307,6 @@ CONFIG_SERIO=y
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
 
 #
@@ -324,6 +330,7 @@ CONFIG_SERIO=y
 # CONFIG_JBD is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
 
 #
 # XFS support
@@ -331,6 +338,8 @@ CONFIG_SERIO=y
 # CONFIG_XFS_FS is not set
 # CONFIG_MINIX_FS is not set
 CONFIG_ROMFS_FS=y
+# CONFIG_MAGIC_ROM_PTR is not set
+CONFIG_INOTIFY=y
 # CONFIG_QUOTA is not set
 CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
index c41d72b01b8806cf07ddbc5a664240f0597a84b6..abd48409dcca51f5d4816aaf54e4fa9e149e7fe9 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * arch/v850/kernel/setup.c -- Arch-dependent initialization functions
  *
- *  Copyright (C) 2001,02,03  NEC Electronics Corporation
- *  Copyright (C) 2001,02,03  Miles Bader <miles@gnu.org>
+ *  Copyright (C) 2001,02,03,05  NEC Electronics Corporation
+ *  Copyright (C) 2001,02,03,05  Miles Bader <miles@gnu.org>
  *
  * This file is subject to the terms and conditions of the GNU General
  * Public License.  See the file COPYING in the main directory of this
@@ -98,10 +98,20 @@ void __init trap_init (void)
 }
 
 #ifdef CONFIG_MTD
+
+/* From drivers/mtd/devices/slram.c */
+#define SLRAM_BLK_SZ 0x4000
+
 /* Set the root filesystem to be the given memory region.
    Some parameter may be appended to CMD_LINE.  */
 void set_mem_root (void *addr, size_t len, char *cmd_line)
 {
+       /* Some sort of idiocy in MTD means we must supply a length that's
+          a multiple of SLRAM_BLK_SZ.  We just round up the real length,
+          as the file system shouldn't attempt to access anything beyond
+          the end of the image anyway.  */
+       len = (((len - 1) + SLRAM_BLK_SZ) / SLRAM_BLK_SZ) * SLRAM_BLK_SZ;
+
        /* The only way to pass info to the MTD slram driver is via
           the command line.  */
        if (*cmd_line) {
@@ -284,3 +294,33 @@ init_mem_alloc (unsigned long ram_start, unsigned long ram_len)
        free_area_init_node (0, NODE_DATA(0), zones_size,
                             ADDR_TO_PAGE (PAGE_OFFSET), 0);
 }
+
+\f
+
+/* Taken from m68knommu */
+void show_mem(void)
+{
+    unsigned long i;
+    int free = 0, total = 0, reserved = 0, shared = 0;
+    int cached = 0;
+
+    printk(KERN_INFO "\nMem-info:\n");
+    show_free_areas();
+    i = max_mapnr;
+    while (i-- > 0) {
+       total++;
+       if (PageReserved(mem_map+i))
+           reserved++;
+       else if (PageSwapCache(mem_map+i))
+           cached++;
+       else if (!page_count(mem_map+i))
+           free++;
+       else
+           shared += page_count(mem_map+i) - 1;
+    }
+    printk(KERN_INFO "%d pages of RAM\n",total);
+    printk(KERN_INFO "%d free pages\n",free);
+    printk(KERN_INFO "%d reserved pages\n",reserved);
+    printk(KERN_INFO "%d pages shared\n",shared);
+    printk(KERN_INFO "%d pages swap cached\n",cached);
+}
index 660a03a89e6663bf7f04bd83c163c441210e8dc1..75e52c57f19c0442e2288e7eefef45355b835e71 100644 (file)
@@ -24,6 +24,10 @@ config X86
        bool
        default y
 
+config SEMAPHORE_SLEEPERS
+       bool
+       default y
+
 config MMU
        bool
        default y
index 48f9e2c19cd6f78a4cdc21efdec7afec0da19277..c32e198d7b2bfa8c734cad85c249da3b230585c7 100644 (file)
@@ -4,10 +4,10 @@
 
 extra-y        := head.o head64.o init_task.o vmlinux.lds
 EXTRA_AFLAGS   := -traditional
-obj-y  := process.o semaphore.o signal.o entry.o traps.o irq.o \
+obj-y  := process.o signal.o entry.o traps.o irq.o \
                ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_x86_64.o \
                x8664_ksyms.o i387.o syscall.o vsyscall.o \
-               setup64.o bootflag.o e820.o reboot.o quirks.o
+               setup64.o bootflag.o e820.o reboot.o quirks.o i8237.o
 
 obj-$(CONFIG_X86_MCE)         += mce.o
 obj-$(CONFIG_X86_MCE_INTEL)    += mce_intel.o
@@ -45,3 +45,4 @@ swiotlb-$(CONFIG_SWIOTLB)      += ../../ia64/lib/swiotlb.o
 microcode-$(subst m,y,$(CONFIG_MICROCODE))  += ../../i386/kernel/microcode.o
 intel_cacheinfo-y              += ../../i386/kernel/cpu/intel_cacheinfo.o
 quirks-y                       += ../../i386/kernel/quirks.o
+i8237-y                                += ../../i386/kernel/i8237.o
index 4e44d6e6b7e52f35d55993ea9616d4ef39a165fa..64a8e05d5811b82fd258365d539ea37c72ed0b2c 100644 (file)
@@ -290,7 +290,7 @@ void enable_timer_nmi_watchdog(void)
 
 static int nmi_pm_active; /* nmi_active before suspend */
 
-static int lapic_nmi_suspend(struct sys_device *dev, u32 state)
+static int lapic_nmi_suspend(struct sys_device *dev, pm_message_t state)
 {
        nmi_pm_active = nmi_active;
        disable_lapic_nmi_watchdog();
index 256c0b1fed10ddfb8e3f242651ccdefdd970cfa9..89299f4ffe1243ae190ac5134cf8fc1d86474bf8 100644 (file)
@@ -219,7 +219,7 @@ config CRYPTO_CAST6
          described in RFC2612.
 
 config CRYPTO_TEA
-       tristate "TEA and XTEA cipher algorithms"
+       tristate "TEA, XTEA and XETA cipher algorithms"
        depends on CRYPTO
        help
          TEA cipher algorithm.
@@ -232,6 +232,9 @@ config CRYPTO_TEA
          the TEA algorithm to address a potential key weakness
          in the TEA algorithm.
 
+         Xtendend Encryption Tiny Algorithm is a mis-implementation 
+         of the XTEA algorithm for compatibility purposes.
+
 config CRYPTO_ARC4
        tristate "ARC4 cipher algorithm"
        depends on CRYPTO
index b4728811ce3b1570e7ee2806644692d099c32cdf..959c4e5f264f42ed831720149b3627d9a9e6300c 100644 (file)
@@ -66,7 +66,8 @@ static inline struct crypto_alg *crypto_alg_mod_lookup(const char *name)
 
 static int crypto_init_flags(struct crypto_tfm *tfm, u32 flags)
 {
-       tfm->crt_flags = 0;
+       tfm->crt_flags = flags & CRYPTO_TFM_REQ_MASK;
+       flags &= ~CRYPTO_TFM_REQ_MASK;
        
        switch (crypto_tfm_alg_type(tfm)) {
        case CRYPTO_ALG_TYPE_CIPHER:
index 8da644364cb4225824575ec4813741b9d46d7041..3df47f93c9db01e0a19da8af237ab800ae9d34b1 100644 (file)
@@ -377,11 +377,7 @@ static int nocrypt_iv(struct crypto_tfm *tfm,
 int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags)
 {
        u32 mode = flags & CRYPTO_TFM_MODE_MASK;
-       
        tfm->crt_cipher.cit_mode = mode ? mode : CRYPTO_TFM_MODE_ECB;
-       if (flags & CRYPTO_TFM_REQ_WEAK_KEY)
-               tfm->crt_flags = CRYPTO_TFM_REQ_WEAK_KEY;
-       
        return 0;
 }
 
index 37515beafc8ce44ff501d15d617968248656b59f..37aa652ce5ce6f89e4738ac07dd770b8df4a6ac9 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <asm/kmap_types.h>
 
 extern enum km_type crypto_km_types[];
@@ -38,7 +39,7 @@ static inline void crypto_kunmap(void *vaddr, int out)
 
 static inline void crypto_yield(struct crypto_tfm *tfm)
 {
-       if (!in_atomic())
+       if (tfm->crt_flags & CRYPTO_TFM_REQ_MAY_SLEEP)
                cond_resched();
 }
 
index bd7524cfff33e6ab71c9b37e6f98733e498a354a..68639419c5bd0283697d60defb50f6cf109e8f5e 100644 (file)
@@ -72,7 +72,7 @@ static char *check[] = {
        "des", "md5", "des3_ede", "rot13", "sha1", "sha256", "blowfish",
        "twofish", "serpent", "sha384", "sha512", "md4", "aes", "cast6",
        "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
-       "khazad", "wp512", "wp384", "wp256", "tnepres", NULL
+       "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", NULL
 };
 
 static void hexdump(unsigned char *buf, unsigned int len)
@@ -859,6 +859,10 @@ static void do_test(void)
                test_cipher ("anubis", MODE_CBC, ENCRYPT, anubis_cbc_enc_tv_template, ANUBIS_CBC_ENC_TEST_VECTORS);
                test_cipher ("anubis", MODE_CBC, DECRYPT, anubis_cbc_dec_tv_template, ANUBIS_CBC_ENC_TEST_VECTORS);
 
+               //XETA
+               test_cipher ("xeta", MODE_ECB, ENCRYPT, xeta_enc_tv_template, XETA_ENC_TEST_VECTORS);
+               test_cipher ("xeta", MODE_ECB, DECRYPT, xeta_dec_tv_template, XETA_DEC_TEST_VECTORS);
+
                test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS);
                test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS);
                test_hash("wp512", wp512_tv_template, WP512_TEST_VECTORS);
@@ -1016,6 +1020,11 @@ static void do_test(void)
        case 29:
                test_hash("tgr128", tgr128_tv_template, TGR128_TEST_VECTORS);
                break;
+               
+       case 30:
+               test_cipher ("xeta", MODE_ECB, ENCRYPT, xeta_enc_tv_template, XETA_ENC_TEST_VECTORS);
+               test_cipher ("xeta", MODE_ECB, DECRYPT, xeta_dec_tv_template, XETA_DEC_TEST_VECTORS);
+               break;
 
 #ifdef CONFIG_CRYPTO_HMAC
        case 100:
index c01a0ce9b40a09be75d879246c7d667e7c28f9ba..522ffd4b6f43ef990ec9645ba6033ee4e755248f 100644 (file)
@@ -2211,7 +2211,7 @@ static struct cipher_testvec xtea_enc_tv_template[] = {
                .klen   = 16,
                .input  = { [0 ... 8] = 0x00 },
                .ilen   = 8,
-               .result = { 0xaa, 0x22, 0x96, 0xe5, 0x6c, 0x61, 0xf3, 0x45 },
+               .result = { 0xd8, 0xd4, 0xe9, 0xde, 0xd9, 0x1e, 0x13, 0xf7 },
                .rlen   = 8,
        }, {
                .key    = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
@@ -2219,31 +2219,31 @@ static struct cipher_testvec xtea_enc_tv_template[] = {
                .klen   = 16,
                .input  = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
                .ilen   = 8,
-               .result = { 0x82, 0x3e, 0xeb, 0x35, 0xdc, 0xdd, 0xd9, 0xc3 },
+               .result = { 0x94, 0xeb, 0xc8, 0x96, 0x84, 0x6a, 0x49, 0xa8 },
                .rlen   = 8,
        }, {
                .key    = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
                            0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
                .klen   = 16,
-               .input  = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
+               .input  = { 0x3e, 0xce, 0xae, 0x22, 0x60, 0x56, 0xa8, 0x9d,
                            0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
                .ilen   = 16,
-               .result = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea,
+               .result = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea, 
                            0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c },
                .rlen   = 16,
        }, {
                .key    = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
                            0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
                .klen   = 16,
-               .input  = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
-                           0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
-                           0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
+               .input  = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, 
+                           0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 
+                           0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, 
                            0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
                .ilen   = 32,
-               .result = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1,
-                           0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4,
-                           0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f,
-                           0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 },
+               .result = { 0x99, 0x81, 0x9f, 0x5d, 0x6f, 0x4b, 0x31, 0x3a,
+                           0x86, 0xff, 0x6f, 0xd0, 0xe3, 0x87, 0x70, 0x07,
+                           0x4d, 0xb8, 0xcf, 0xf3, 0x99, 0x50, 0xb3, 0xd4,
+                           0x73, 0xa2, 0xfa, 0xc9, 0x16, 0x59, 0x5d, 0x81 },
                .rlen   = 32,
        }
 };
@@ -2252,7 +2252,7 @@ static struct cipher_testvec xtea_dec_tv_template[] = {
        {
                .key    = { [0 ... 15] = 0x00 },
                .klen   = 16,
-               .input  = { 0xaa, 0x22, 0x96, 0xe5, 0x6c, 0x61, 0xf3, 0x45 },
+               .input  = { 0xd8, 0xd4, 0xe9, 0xde, 0xd9, 0x1e, 0x13, 0xf7 },
                .ilen   = 8,
                .result = { [0 ... 8] = 0x00 },
                .rlen   = 8,
@@ -2260,7 +2260,7 @@ static struct cipher_testvec xtea_dec_tv_template[] = {
                .key    = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
                            0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
                .klen   = 16,
-               .input  = { 0x82, 0x3e, 0xeb, 0x35, 0xdc, 0xdd, 0xd9, 0xc3 },
+               .input  = { 0x94, 0xeb, 0xc8, 0x96, 0x84, 0x6a, 0x49, 0xa8 },
                .ilen   = 8,
                .result = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
                .rlen   = 8,
@@ -2268,24 +2268,24 @@ static struct cipher_testvec xtea_dec_tv_template[] = {
                .key    = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
                            0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
                .klen   = 16,
-               .input  = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea,
-                           0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c },
+               .input  = { 0x3e, 0xce, 0xae, 0x22, 0x60, 0x56, 0xa8, 0x9d,
+                           0x77, 0x4d, 0xd4, 0xb4, 0x87, 0x24, 0xe3, 0x9a },
                .ilen   = 16,
-               .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
+               .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, 
                            0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
                .rlen   = 16,
        }, {
                .key    = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
                            0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
                .klen   = 16,
-               .input  = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1,
-                           0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4,
-                           0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f,
-                           0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 },
+               .input  = { 0x99, 0x81, 0x9f, 0x5d, 0x6f, 0x4b, 0x31, 0x3a,
+                           0x86, 0xff, 0x6f, 0xd0, 0xe3, 0x87, 0x70, 0x07,
+                           0x4d, 0xb8, 0xcf, 0xf3, 0x99, 0x50, 0xb3, 0xd4,
+                           0x73, 0xa2, 0xfa, 0xc9, 0x16, 0x59, 0x5d, 0x81 },
                .ilen   = 32,
-               .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
-                           0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
-                           0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
+               .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, 
+                           0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 
+                           0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, 
                            0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
                .rlen   = 32,
        }
@@ -2594,6 +2594,98 @@ static struct cipher_testvec anubis_cbc_dec_tv_template[] = {
        },
 };
 
+/* 
+ * XETA test vectors 
+ */
+#define XETA_ENC_TEST_VECTORS  4
+#define XETA_DEC_TEST_VECTORS  4
+
+static struct cipher_testvec xeta_enc_tv_template[] = {
+       {
+               .key    = { [0 ... 15] = 0x00 },
+               .klen   = 16,
+               .input  = { [0 ... 8] = 0x00 },
+               .ilen   = 8,
+               .result = { 0xaa, 0x22, 0x96, 0xe5, 0x6c, 0x61, 0xf3, 0x45 },
+               .rlen   = 8,
+       }, {
+               .key    = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
+                           0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
+               .klen   = 16,
+               .input  = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
+               .ilen   = 8,
+               .result = { 0x82, 0x3e, 0xeb, 0x35, 0xdc, 0xdd, 0xd9, 0xc3 },
+               .rlen   = 8,
+       }, {
+               .key    = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
+                           0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
+               .klen   = 16,
+               .input  = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, 
+                           0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
+               .ilen   = 16,
+               .result = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea, 
+                           0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c },
+               .rlen   = 16,
+       }, {
+               .key    = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
+                           0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
+               .klen   = 16,
+               .input  = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, 
+                           0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 
+                           0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, 
+                           0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
+               .ilen   = 32,
+               .result = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1, 
+                           0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4, 
+                           0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f, 
+                           0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 },
+               .rlen   = 32,
+       }
+};
+
+static struct cipher_testvec xeta_dec_tv_template[] = {
+       {
+               .key    = { [0 ... 15] = 0x00 },
+               .klen   = 16,
+               .input  = { 0xaa, 0x22, 0x96, 0xe5, 0x6c, 0x61, 0xf3, 0x45 },
+               .ilen   = 8,
+               .result = { [0 ... 8] = 0x00 },
+               .rlen   = 8,
+       }, {
+               .key    = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
+                           0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
+               .klen   = 16,
+               .input  = { 0x82, 0x3e, 0xeb, 0x35, 0xdc, 0xdd, 0xd9, 0xc3 },
+               .ilen   = 8,
+               .result = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
+               .rlen   = 8,
+       }, {
+               .key    = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
+                           0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
+               .klen   = 16,
+               .input  = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea, 
+                           0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c },
+               .ilen   = 16,
+               .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, 
+                           0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
+               .rlen   = 16,
+       }, {
+               .key    = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
+                           0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
+               .klen   = 16,
+               .input  = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1, 
+                           0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4, 
+                           0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f, 
+                           0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 },
+               .ilen   = 32,
+               .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, 
+                           0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 
+                           0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, 
+                           0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
+               .rlen   = 32,
+       }
+};
+
 /*
  * Compression stuff.
  */
index 03c23cbd3afa1f6373d964b308463701ab316458..5924efdd3a169980c3893a9b9f8d931259d25ec9 100644 (file)
@@ -1,11 +1,15 @@
 /* 
  * Cryptographic API.
  *
- * TEA and Xtended TEA Algorithms
+ * TEA, XTEA, and XETA crypto alogrithms
  *
  * The TEA and Xtended TEA algorithms were developed by David Wheeler 
  * and Roger Needham at the Computer Laboratory of Cambridge University.
  *
+ * Due to the order of evaluation in XTEA many people have incorrectly
+ * implemented it.  XETA (XTEA in the wrong order), exists for
+ * compatibility with these implementations.
+ *
  * Copyright (c) 2004 Aaron Grothe ajgrothe@yahoo.com
  *
  * This program is free software; you can redistribute it and/or modify
@@ -153,9 +157,9 @@ static void xtea_encrypt(void *ctx_arg, u8 *dst, const u8 *src)
        z = u32_in (src + 4);
 
        while (sum != limit) {
-               y += (z << 4 ^ z >> 5) + (z ^ sum) + ctx->KEY[sum&3]
+               y += ((z << 4 ^ z >> 5) + z) ^ (sum + ctx->KEY[sum&3])
                sum += XTEA_DELTA;
-               z += (y << 4 ^ y >> 5) + (y ^ sum) + ctx->KEY[sum>>11 &3]
+               z += ((y << 4 ^ y >> 5) + y) ^ (sum + ctx->KEY[sum>>11 &3])
        }
        
        u32_out (dst, y);
@@ -174,6 +178,51 @@ static void xtea_decrypt(void *ctx_arg, u8 *dst, const u8 *src)
 
        sum = XTEA_DELTA * XTEA_ROUNDS;
 
+       while (sum) {
+               z -= ((y << 4 ^ y >> 5) + y) ^ (sum + ctx->KEY[sum>>11 & 3]);
+               sum -= XTEA_DELTA;
+               y -= ((z << 4 ^ z >> 5) + z) ^ (sum + ctx->KEY[sum & 3]);
+       }
+       
+       u32_out (dst, y);
+       u32_out (dst + 4, z);
+
+}
+
+
+static void xeta_encrypt(void *ctx_arg, u8 *dst, const u8 *src)
+{ 
+
+       u32 y, z, sum = 0;
+       u32 limit = XTEA_DELTA * XTEA_ROUNDS;
+
+       struct xtea_ctx *ctx = ctx_arg;
+
+       y = u32_in (src);
+       z = u32_in (src + 4);
+
+       while (sum != limit) {
+               y += (z << 4 ^ z >> 5) + (z ^ sum) + ctx->KEY[sum&3];
+               sum += XTEA_DELTA;
+               z += (y << 4 ^ y >> 5) + (y ^ sum) + ctx->KEY[sum>>11 &3];
+       }
+       
+       u32_out (dst, y);
+       u32_out (dst + 4, z);
+
+}
+
+static void xeta_decrypt(void *ctx_arg, u8 *dst, const u8 *src)
+{ 
+
+       u32 y, z, sum;
+       struct tea_ctx *ctx = ctx_arg;
+
+       y = u32_in (src);
+       z = u32_in (src + 4);
+
+       sum = XTEA_DELTA * XTEA_ROUNDS;
+
        while (sum) {
                z -= (y << 4 ^ y >> 5) + (y ^ sum) + ctx->KEY[sum>>11 & 3];
                sum -= XTEA_DELTA;
@@ -215,6 +264,21 @@ static struct crypto_alg xtea_alg = {
        .cia_decrypt            =       xtea_decrypt } }
 };
 
+static struct crypto_alg xeta_alg = {
+       .cra_name               =       "xeta",
+       .cra_flags              =       CRYPTO_ALG_TYPE_CIPHER,
+       .cra_blocksize          =       XTEA_BLOCK_SIZE,
+       .cra_ctxsize            =       sizeof (struct xtea_ctx),
+       .cra_module             =       THIS_MODULE,
+       .cra_list               =       LIST_HEAD_INIT(xtea_alg.cra_list),
+       .cra_u                  =       { .cipher = {
+       .cia_min_keysize        =       XTEA_KEY_SIZE,
+       .cia_max_keysize        =       XTEA_KEY_SIZE,
+       .cia_setkey             =       xtea_setkey,
+       .cia_encrypt            =       xeta_encrypt,
+       .cia_decrypt            =       xeta_decrypt } }
+};
+
 static int __init init(void)
 {
        int ret = 0;
@@ -229,6 +293,13 @@ static int __init init(void)
                goto out;
        }
 
+       ret = crypto_register_alg(&xeta_alg);
+       if (ret < 0) {
+               crypto_unregister_alg(&tea_alg);
+               crypto_unregister_alg(&xtea_alg);
+               goto out;
+       }
+
 out:   
        return ret;
 }
@@ -237,12 +308,14 @@ static void __exit fini(void)
 {
        crypto_unregister_alg(&tea_alg);
        crypto_unregister_alg(&xtea_alg);
+       crypto_unregister_alg(&xeta_alg);
 }
 
 MODULE_ALIAS("xtea");
+MODULE_ALIAS("xeta");
 
 module_init(init);
 module_exit(fini);
 
 MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("TEA & XTEA Cryptographic Algorithms");
+MODULE_DESCRIPTION("TEA, XTEA & XETA Cryptographic Algorithms");
index c4b75ecf9460442d3dea8fba8ce0628cb315b801..55959e4d1cb77d3aef5269340fff23241f873d58 100644 (file)
@@ -417,9 +417,9 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
                chan = (here[3] & uPD98401_AAL5_CHAN) >>
                    uPD98401_AAL5_CHAN_SHIFT;
                if (chan < zatm_dev->chans && zatm_dev->rx_map[chan]) {
-                       int pos = ZATM_VCC(vcc)->pool;
-
+                       int pos;
                        vcc = zatm_dev->rx_map[chan];
+                       pos = ZATM_VCC(vcc)->pool;
                        if (skb == zatm_dev->last_free[pos])
                                zatm_dev->last_free[pos] = NULL;
                        skb_unlink(skb, zatm_dev->pool + pos);
index ab53832d57e5eff507b8e4552983446641f02d51..17e96698410e43c47464fb6d509cf082b0a0a724 100644 (file)
@@ -156,7 +156,9 @@ static ssize_t driver_unbind(struct device_driver *drv,
                device_release_driver(dev);
                err = count;
        }
-       return err;
+       if (err)
+               return err;
+       return count;
 }
 static DRIVER_ATTR(unbind, S_IWUSR, NULL, driver_unbind);
 
@@ -358,7 +360,7 @@ int bus_add_device(struct device * dev)
        if (bus) {
                pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id);
                device_attach(dev);
-               klist_add_tail(&bus->klist_devices, &dev->knode_bus);
+               klist_add_tail(&dev->knode_bus, &bus->klist_devices);
                error = device_add_attrs(bus, dev);
                if (!error) {
                        sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id);
@@ -446,7 +448,7 @@ int bus_add_driver(struct device_driver * drv)
                }
 
                driver_attach(drv);
-               klist_add_tail(&bus->klist_drivers, &drv->knode_bus);
+               klist_add_tail(&drv->knode_bus, &bus->klist_drivers);
                module_add_driver(drv->owner, drv);
 
                driver_add_attrs(bus, drv);
index 0154a1623b2198965be09dbf4bd9552b5525ba4e..d164c32a97ad4e90426a4f1e8a244b8d5f7d93d3 100644 (file)
@@ -299,10 +299,8 @@ static void class_dev_release(struct kobject * kobj)
 
        pr_debug("device class '%s': release.\n", cd->class_id);
 
-       if (cd->devt_attr) {
-               kfree(cd->devt_attr);
-               cd->devt_attr = NULL;
-       }
+       kfree(cd->devt_attr);
+       cd->devt_attr = NULL;
 
        if (cls->release)
                cls->release(cd);
@@ -452,10 +450,29 @@ void class_device_initialize(struct class_device *class_dev)
        INIT_LIST_HEAD(&class_dev->node);
 }
 
+static char *make_class_name(struct class_device *class_dev)
+{
+       char *name;
+       int size;
+
+       size = strlen(class_dev->class->name) +
+               strlen(kobject_name(&class_dev->kobj)) + 2;
+
+       name = kmalloc(size, GFP_KERNEL);
+       if (!name)
+               return ERR_PTR(-ENOMEM);
+
+       strcpy(name, class_dev->class->name);
+       strcat(name, ":");
+       strcat(name, kobject_name(&class_dev->kobj));
+       return name;
+}
+
 int class_device_add(struct class_device *class_dev)
 {
        struct class * parent = NULL;
        struct class_interface * class_intf;
+       char *class_name = NULL;
        int error;
 
        class_dev = class_device_get(class_dev);
@@ -500,9 +517,13 @@ int class_device_add(struct class_device *class_dev)
        }
 
        class_device_add_attrs(class_dev);
-       if (class_dev->dev)
+       if (class_dev->dev) {
+               class_name = make_class_name(class_dev);
                sysfs_create_link(&class_dev->kobj,
                                  &class_dev->dev->kobj, "device");
+               sysfs_create_link(&class_dev->dev->kobj, &class_dev->kobj,
+                                 class_name);
+       }
 
        /* notify any interfaces this device is now here */
        if (parent) {
@@ -519,6 +540,7 @@ int class_device_add(struct class_device *class_dev)
        if (error && parent)
                class_put(parent);
        class_device_put(class_dev);
+       kfree(class_name);
        return error;
 }
 
@@ -584,6 +606,7 @@ void class_device_del(struct class_device *class_dev)
 {
        struct class * parent = class_dev->class;
        struct class_interface * class_intf;
+       char *class_name = NULL;
 
        if (parent) {
                down(&parent->sem);
@@ -594,8 +617,11 @@ void class_device_del(struct class_device *class_dev)
                up(&parent->sem);
        }
 
-       if (class_dev->dev)
+       if (class_dev->dev) {
+               class_name = make_class_name(class_dev);
                sysfs_remove_link(&class_dev->kobj, "device");
+               sysfs_remove_link(&class_dev->dev->kobj, class_name);
+       }
        if (class_dev->devt_attr)
                class_device_remove_file(class_dev, class_dev->devt_attr);
        class_device_remove_attrs(class_dev);
@@ -605,6 +631,7 @@ void class_device_del(struct class_device *class_dev)
 
        if (parent)
                class_put(parent);
+       kfree(class_name);
 }
 
 void class_device_unregister(struct class_device *class_dev)
index efe03a024a5bc39bf958881143d740312c3b09bc..c8a33df007612b1e417744a262ba3fe1026114dd 100644 (file)
@@ -249,7 +249,7 @@ int device_add(struct device *dev)
        if ((error = bus_add_device(dev)))
                goto BusError;
        if (parent)
-               klist_add_tail(&parent->klist_children, &dev->knode_parent);
+               klist_add_tail(&dev->knode_parent, &parent->klist_children);
 
        /* notify platform of device entry */
        if (platform_notify)
index 16323f9cbff08fb066f8d10cda4bb76cfe711564..d5bbce38282fd233f06ef77891257a399be2471e 100644 (file)
@@ -42,7 +42,7 @@ void device_bind_driver(struct device * dev)
 {
        pr_debug("bound device '%s' to driver '%s'\n",
                 dev->bus_id, dev->driver->name);
-       klist_add_tail(&dev->driver->klist_devices, &dev->knode_driver);
+       klist_add_tail(&dev->knode_driver, &dev->driver->klist_devices);
        sysfs_create_link(&dev->driver->kobj, &dev->kobj,
                          kobject_name(&dev->kobj));
        sysfs_create_link(&dev->kobj, &dev->driver->kobj, "driver");
index 904b27caf697df2c0d14d1cab426212bad27bb25..16c513aa4d4877afa7522eedc7e695568648cbf7 100644 (file)
@@ -39,13 +39,25 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
        int n;
        int nid = dev->id;
        struct sysinfo i;
+       struct page_state ps;
        unsigned long inactive;
        unsigned long active;
        unsigned long free;
 
        si_meminfo_node(&i, nid);
+       get_page_state_node(&ps, nid);
        __get_zone_counts(&active, &inactive, &free, NODE_DATA(nid));
 
+       /* Check for negative values in these approximate counters */
+       if ((long)ps.nr_dirty < 0)
+               ps.nr_dirty = 0;
+       if ((long)ps.nr_writeback < 0)
+               ps.nr_writeback = 0;
+       if ((long)ps.nr_mapped < 0)
+               ps.nr_mapped = 0;
+       if ((long)ps.nr_slab < 0)
+               ps.nr_slab = 0;
+
        n = sprintf(buf, "\n"
                       "Node %d MemTotal:     %8lu kB\n"
                       "Node %d MemFree:      %8lu kB\n"
@@ -55,7 +67,11 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
                       "Node %d HighTotal:    %8lu kB\n"
                       "Node %d HighFree:     %8lu kB\n"
                       "Node %d LowTotal:     %8lu kB\n"
-                      "Node %d LowFree:      %8lu kB\n",
+                      "Node %d LowFree:      %8lu kB\n"
+                      "Node %d Dirty:        %8lu kB\n"
+                      "Node %d Writeback:    %8lu kB\n"
+                      "Node %d Mapped:       %8lu kB\n"
+                      "Node %d Slab:         %8lu kB\n",
                       nid, K(i.totalram),
                       nid, K(i.freeram),
                       nid, K(i.totalram - i.freeram),
@@ -64,7 +80,11 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
                       nid, K(i.totalhigh),
                       nid, K(i.freehigh),
                       nid, K(i.totalram - i.totalhigh),
-                      nid, K(i.freeram - i.freehigh));
+                      nid, K(i.freeram - i.freehigh),
+                      nid, K(ps.nr_dirty),
+                      nid, K(ps.nr_writeback),
+                      nid, K(ps.nr_mapped),
+                      nid, K(ps.nr_slab));
        n += hugetlb_report_node_meminfo(nid, buf + n);
        return n;
 }
index bdd96b03b8857a14367535bf408224b1eb939503..0a7aa07b9a2a600cc9b52992b8e0f0d44216af17 100644 (file)
@@ -26,11 +26,11 @@ int resume_device(struct device * dev)
 
        down(&dev->sem);
        if (dev->power.pm_parent
-                       && dev->power.pm_parent->power.power_state) {
+                       && dev->power.pm_parent->power.power_state.event) {
                dev_err(dev, "PM: resume from %d, parent %s still %d\n",
-                       dev->power.power_state,
+                       dev->power.power_state.event,
                        dev->power.pm_parent->bus_id,
-                       dev->power.pm_parent->power.power_state);
+                       dev->power.pm_parent->power.power_state.event);
        }
        if (dev->bus && dev->bus->resume) {
                dev_dbg(dev,"resuming\n");
@@ -54,7 +54,7 @@ void dpm_resume(void)
                list_add_tail(entry, &dpm_active);
 
                up(&dpm_list_sem);
-               if (!dev->power.prev_state)
+               if (!dev->power.prev_state.event)
                        resume_device(dev);
                down(&dpm_list_sem);
                put_device(dev);
index 325962d8019153d28316399ab7b5a8da3887293e..e8f0519f5dfa88566e3e49d34d0e637180793a7c 100644 (file)
 static void runtime_resume(struct device * dev)
 {
        dev_dbg(dev, "resuming\n");
-       if (!dev->power.power_state)
+       if (!dev->power.power_state.event)
                return;
        if (!resume_device(dev))
-               dev->power.power_state = 0;
+               dev->power.power_state = PMSG_ON;
 }
 
 
@@ -49,10 +49,10 @@ int dpm_runtime_suspend(struct device * dev, pm_message_t state)
        int error = 0;
 
        down(&dpm_sem);
-       if (dev->power.power_state == state)
+       if (dev->power.power_state.event == state.event)
                goto Done;
 
-       if (dev->power.power_state)
+       if (dev->power.power_state.event)
                runtime_resume(dev);
 
        if (!(error = suspend_device(dev, state)))
index 2ccee3763acfae23a3d1de899179dd5ac0ca9419..50501764d0508a6493256380df820eb35b8c96e1 100644 (file)
@@ -40,22 +40,22 @@ int suspend_device(struct device * dev, pm_message_t state)
        int error = 0;
 
        down(&dev->sem);
-       if (dev->power.power_state) {
+       if (dev->power.power_state.event) {
                dev_dbg(dev, "PM: suspend %d-->%d\n",
-                       dev->power.power_state, state);
+                       dev->power.power_state.event, state.event);
        }
        if (dev->power.pm_parent
-                       && dev->power.pm_parent->power.power_state) {
+                       && dev->power.pm_parent->power.power_state.event) {
                dev_err(dev,
                        "PM: suspend %d->%d, parent %s already %d\n",
-                       dev->power.power_state, state,
+                       dev->power.power_state.event, state.event,
                        dev->power.pm_parent->bus_id,
-                       dev->power.pm_parent->power.power_state);
+                       dev->power.pm_parent->power.power_state.event);
        }
 
        dev->power.prev_state = dev->power.power_state;
 
-       if (dev->bus && dev->bus->suspend && !dev->power.power_state) {
+       if (dev->bus && dev->bus->suspend && !dev->power.power_state.event) {
                dev_dbg(dev, "suspending\n");
                error = dev->bus->suspend(dev, state);
        }
index f82b3df9545f68b66cd1866862bc665a1f7e00c5..8d04fb435c176ebc92f89793cb5998d05721694b 100644 (file)
 
 static ssize_t state_show(struct device * dev, struct device_attribute *attr, char * buf)
 {
-       return sprintf(buf, "%u\n", dev->power.power_state);
+       return sprintf(buf, "%u\n", dev->power.power_state.event);
 }
 
 static ssize_t state_store(struct device * dev, struct device_attribute *attr, const char * buf, size_t n)
 {
-       u32 state;
+       pm_message_t state;
        char * rest;
        int error = 0;
 
-       state = simple_strtoul(buf, &rest, 10);
+       state.event = simple_strtoul(buf, &rest, 10);
        if (*rest)
                return -EINVAL;
-       if (state)
+       if (state.event)
                error = dpm_runtime_suspend(dev, state);
        else
                dpm_runtime_resume(dev);
index 214b96435409e139ae730be68de1439b569cae1d..3431eb6004c3287f6c0be52ddcb75d13d6037f0e 100644 (file)
@@ -288,6 +288,27 @@ void sysdev_shutdown(void)
        up(&sysdev_drivers_lock);
 }
 
+static void __sysdev_resume(struct sys_device *dev)
+{
+       struct sysdev_class *cls = dev->cls;
+       struct sysdev_driver *drv;
+
+       /* First, call the class-specific one */
+       if (cls->resume)
+               cls->resume(dev);
+
+       /* Call auxillary drivers next. */
+       list_for_each_entry(drv, &cls->drivers, entry) {
+               if (drv->resume)
+                       drv->resume(dev);
+       }
+
+       /* Call global drivers. */
+       list_for_each_entry(drv, &sysdev_drivers, entry) {
+               if (drv->resume)
+                       drv->resume(dev);
+       }
+}
 
 /**
  *     sysdev_suspend - Suspend all system devices.
@@ -305,38 +326,93 @@ void sysdev_shutdown(void)
 int sysdev_suspend(pm_message_t state)
 {
        struct sysdev_class * cls;
+       struct sys_device *sysdev, *err_dev;
+       struct sysdev_driver *drv, *err_drv;
+       int ret;
 
        pr_debug("Suspending System Devices\n");
 
        list_for_each_entry_reverse(cls, &system_subsys.kset.list,
                                    kset.kobj.entry) {
-               struct sys_device * sysdev;
 
                pr_debug("Suspending type '%s':\n",
                         kobject_name(&cls->kset.kobj));
 
                list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) {
-                       struct sysdev_driver * drv;
                        pr_debug(" %s\n", kobject_name(&sysdev->kobj));
 
                        /* Call global drivers first. */
                        list_for_each_entry(drv, &sysdev_drivers, entry) {
-                               if (drv->suspend)
-                                       drv->suspend(sysdev, state);
+                               if (drv->suspend) {
+                                       ret = drv->suspend(sysdev, state);
+                                       if (ret)
+                                               goto gbl_driver;
+                               }
                        }
 
                        /* Call auxillary drivers next. */
                        list_for_each_entry(drv, &cls->drivers, entry) {
-                               if (drv->suspend)
-                                       drv->suspend(sysdev, state);
+                               if (drv->suspend) {
+                                       ret = drv->suspend(sysdev, state);
+                                       if (ret)
+                                               goto aux_driver;
+                               }
                        }
 
                        /* Now call the generic one */
-                       if (cls->suspend)
-                               cls->suspend(sysdev, state);
+                       if (cls->suspend) {
+                               ret = cls->suspend(sysdev, state);
+                               if (ret)
+                                       goto cls_driver;
+                       }
                }
        }
        return 0;
+       /* resume current sysdev */
+cls_driver:
+       drv = NULL;
+       printk(KERN_ERR "Class suspend failed for %s\n",
+               kobject_name(&sysdev->kobj));
+
+aux_driver:
+       if (drv)
+               printk(KERN_ERR "Class driver suspend failed for %s\n",
+                               kobject_name(&sysdev->kobj));
+       list_for_each_entry(err_drv, &cls->drivers, entry) {
+               if (err_drv == drv)
+                       break;
+               if (err_drv->resume)
+                       err_drv->resume(sysdev);
+       }
+       drv = NULL;
+
+gbl_driver:
+       if (drv)
+               printk(KERN_ERR "sysdev driver suspend failed for %s\n",
+                               kobject_name(&sysdev->kobj));
+       list_for_each_entry(err_drv, &sysdev_drivers, entry) {
+               if (err_drv == drv)
+                       break;
+               if (err_drv->resume)
+                       err_drv->resume(sysdev);
+       }
+       /* resume other sysdevs in current class */
+       list_for_each_entry(err_dev, &cls->kset.list, kobj.entry) {
+               if (err_dev == sysdev)
+                       break;
+               pr_debug(" %s\n", kobject_name(&err_dev->kobj));
+               __sysdev_resume(err_dev);
+       }
+
+       /* resume other classes */
+       list_for_each_entry_continue(cls, &system_subsys.kset.list,
+                                       kset.kobj.entry) {
+               list_for_each_entry(err_dev, &cls->kset.list, kobj.entry) {
+                       pr_debug(" %s\n", kobject_name(&err_dev->kobj));
+                       __sysdev_resume(err_dev);
+               }
+       }
+       return ret;
 }
 
 
@@ -362,25 +438,9 @@ int sysdev_resume(void)
                         kobject_name(&cls->kset.kobj));
 
                list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) {
-                       struct sysdev_driver * drv;
                        pr_debug(" %s\n", kobject_name(&sysdev->kobj));
 
-                       /* First, call the class-specific one */
-                       if (cls->resume)
-                               cls->resume(sysdev);
-
-                       /* Call auxillary drivers next. */
-                       list_for_each_entry(drv, &cls->drivers, entry) {
-                               if (drv->resume)
-                                       drv->resume(sysdev);
-                       }
-
-                       /* Call global drivers. */
-                       list_for_each_entry(drv, &sysdev_drivers, entry) {
-                               if (drv->resume)
-                                       drv->resume(sysdev);
-                       }
-
+                       __sysdev_resume(sysdev);
                }
        }
        return 0;
index b594768b0241f3d198d802ada4d192b356677310..6b736364cc5b886589c54a21bfdc8afdda448fe9 100644 (file)
@@ -408,54 +408,12 @@ config BLK_DEV_INITRD
          "real" root file system, etc. See <file:Documentation/initrd.txt>
          for details.
 
-config INITRAMFS_SOURCE
-       string "Initramfs source file(s)"
-       default ""
-       help
-         This can be either a single cpio archive with a .cpio suffix or a
-         space-separated list of directories and files for building the
-         initramfs image.  A cpio archive should contain a filesystem archive
-         to be used as an initramfs image.  Directories should contain a
-         filesystem layout to be included in the initramfs image.  Files
-         should contain entries according to the format described by the
-         "usr/gen_init_cpio" program in the kernel tree.
-
-         When multiple directories and files are specified then the
-         initramfs image will be the aggregate of all of them.
-
-         See <file:Documentation/early-userspace/README for more details.
-
-         If you are not sure, leave it blank.
-
-config INITRAMFS_ROOT_UID
-       int "User ID to map to 0 (user root)"
-       depends on INITRAMFS_SOURCE!=""
-       default "0"
-       help
-         This setting is only meaningful if the INITRAMFS_SOURCE is
-         contains a directory.  Setting this user ID (UID) to something
-         other than "0" will cause all files owned by that UID to be
-         owned by user root in the initial ramdisk image.
-
-         If you are not sure, leave it set to "0".
-
-config INITRAMFS_ROOT_GID
-       int "Group ID to map to 0 (group root)"
-       depends on INITRAMFS_SOURCE!=""
-       default "0"
-       help
-         This setting is only meaningful if the INITRAMFS_SOURCE is
-         contains a directory.  Setting this group ID (GID) to something
-         other than "0" will cause all files owned by that GID to be
-         owned by group root in the initial ramdisk image.
-
-         If you are not sure, leave it set to "0".
 
 #XXX - it makes sense to enable this only for 32-bit subarch's, not for x86_64
 #for instance.
 config LBD
        bool "Support for Large Block Devices"
-       depends on X86 || MIPS32 || PPC32 || ARCH_S390_31 || SUPERH || UML
+       depends on X86 || (MIPS && 32BIT) || PPC32 || ARCH_S390_31 || SUPERH || UML
        help
          Say Y here if you want to attach large (bigger than 2TB) discs to
          your machine, or if you want to have a raid or loopback device
index 5be6f998d8c56e0b2f1134624f115c89783a65e3..3d4261c39f16d2542b9dc22c1cc077ed8bc07c1f 100644 (file)
@@ -57,9 +57,11 @@ cryptoloop_init(struct loop_device *lo, const struct loop_info64 *info)
        mode = strsep(&cmsp, "-");
 
        if (mode == NULL || strcmp(mode, "cbc") == 0)
-               tfm = crypto_alloc_tfm(cipher, CRYPTO_TFM_MODE_CBC);
+               tfm = crypto_alloc_tfm(cipher, CRYPTO_TFM_MODE_CBC |
+                                              CRYPTO_TFM_REQ_MAY_SLEEP);
        else if (strcmp(mode, "ecb") == 0)
-               tfm = crypto_alloc_tfm(cipher, CRYPTO_TFM_MODE_ECB);
+               tfm = crypto_alloc_tfm(cipher, CRYPTO_TFM_MODE_ECB |
+                                              CRYPTO_TFM_REQ_MAY_SLEEP);
        if (tfm == NULL)
                return -EINVAL;
 
index f0c1084b840fd9fceb465521b1bb8cbbc7198529..888dad5eef34994fad9718223f31a1fc8513866f 100644 (file)
@@ -493,6 +493,8 @@ static struct floppy_struct user_params[N_DRIVE];
 
 static sector_t floppy_sizes[256];
 
+static char floppy_device_name[] = "floppy";
+
 /*
  * The driver is trying to determine the correct media format
  * while probing is set. rw_interrupt() clears it after a
@@ -4191,18 +4193,24 @@ static int __init floppy_setup(char *str)
 
 static int have_no_fdc = -ENODEV;
 
+static ssize_t floppy_cmos_show(struct device *dev,
+                               struct device_attribute *attr, char *buf)
+{
+       struct platform_device *p;
+       int drive;
+
+       p = container_of(dev, struct platform_device,dev);
+       drive = p->id;
+       return sprintf(buf, "%X\n", UDP->cmos);
+}
+DEVICE_ATTR(cmos,S_IRUGO,floppy_cmos_show,NULL);
+
 static void floppy_device_release(struct device *dev)
 {
        complete(&device_release);
 }
 
-static struct platform_device floppy_device = {
-       .name           = "floppy",
-       .id             = 0,
-       .dev            = {
-                       .release = floppy_device_release,
-                       }
-};
+static struct platform_device floppy_device[N_DRIVE];
 
 static struct kobject *floppy_find(dev_t dev, int *part, void *data)
 {
@@ -4370,20 +4378,26 @@ static int __init floppy_init(void)
                goto out_flush_work;
        }
 
-       err = platform_device_register(&floppy_device);
-       if (err)
-               goto out_flush_work;
-
        for (drive = 0; drive < N_DRIVE; drive++) {
                if (!(allowed_drive_mask & (1 << drive)))
                        continue;
                if (fdc_state[FDC(drive)].version == FDC_NONE)
                        continue;
+
+               floppy_device[drive].name = floppy_device_name;
+               floppy_device[drive].id = drive;
+               floppy_device[drive].dev.release = floppy_device_release;
+
+               err = platform_device_register(&floppy_device[drive]);
+               if (err)
+                       goto out_flush_work;
+
+               device_create_file(&floppy_device[drive].dev,&dev_attr_cmos);
                /* to be cleaned up... */
                disks[drive]->private_data = (void *)(long)drive;
                disks[drive]->queue = floppy_queue;
                disks[drive]->flags |= GENHD_FL_REMOVABLE;
-               disks[drive]->driverfs_dev = &floppy_device.dev;
+               disks[drive]->driverfs_dev = &floppy_device[drive].dev;
                add_disk(disks[drive]);
        }
 
@@ -4603,10 +4617,11 @@ void cleanup_module(void)
                    fdc_state[FDC(drive)].version != FDC_NONE) {
                        del_gendisk(disks[drive]);
                        unregister_devfs_entries(drive);
+                       device_remove_file(&floppy_device[drive].dev, &dev_attr_cmos);
+                       platform_device_unregister(&floppy_device[drive]);
                }
                put_disk(disks[drive]);
        }
-       platform_device_unregister(&floppy_device);
        devfs_remove("floppy");
 
        del_timer_sync(&fd_timeout);
index 7333b41d4224240b19f683e12010c261b94417cd..a1de06d76de63e8742558f0f20e587e1fcfa3cf6 100644 (file)
@@ -735,7 +735,7 @@ config SGI_IP27_RTC
 
 config GEN_RTC
        tristate "Generic /dev/rtc emulation"
-       depends on RTC!=y && !IA64 && !ARM && !PPC64 && !M32R && !SPARC32
+       depends on RTC!=y && !IA64 && !ARM && !PPC64 && !M32R && !SPARC32 && !SPARC64
        ---help---
          If you say Y here and create a character special file /dev/rtc with
          major number 10 and minor number 135 using mknod ("man mknod"), you
@@ -842,8 +842,7 @@ config SONYPI
 
 config TANBAC_TB0219
        tristate "TANBAC TB0219 base board support"
-       depends TANBAC_TB0229
-
+       depends TANBAC_TB022X
 
 menu "Ftape, the floppy tape device driver"
 
index 95f7046ff059184c5c7b8024e83881c922c25289..79e490ef2cf2ea352045e2d5a71913bac50158eb 100644 (file)
@@ -339,7 +339,7 @@ static int __init moxa_init(void)
 
        init_MUTEX(&moxaBuffSem);
        moxaDriver->owner = THIS_MODULE;
-       moxaDriver->name = "ttya";
+       moxaDriver->name = "ttyMX";
        moxaDriver->devfs_name = "tts/a";
        moxaDriver->major = ttymajor;
        moxaDriver->minor_start = 0;
index d568991ac6b3eafcc2dd85b48a881756c9353d2c..8666171e187b0cf1b53437308566d0ef48b8de9e 100644 (file)
@@ -57,6 +57,7 @@
 #include <linux/sched.h>
 #include <linux/spinlock.h>
 #include <linux/delay.h>
+#include <linux/serial_8250.h>
 #include "smapi.h"
 #include "mwavedd.h"
 #include "3780i.h"
@@ -410,8 +411,8 @@ static ssize_t mwave_write(struct file *file, const char __user *buf,
 
 static int register_serial_portandirq(unsigned int port, int irq)
 {
-       struct serial_struct serial;
-
+       struct uart_port uart;
+       
        switch ( port ) {
                case 0x3f8:
                case 0x2f8:
@@ -442,12 +443,14 @@ static int register_serial_portandirq(unsigned int port, int irq)
        } /* switch */
        /* irq is okay */
 
-       memset(&serial, 0, sizeof(serial));
-       serial.port = port;
-       serial.irq = irq;
-       serial.flags = ASYNC_SHARE_IRQ;
-
-       return register_serial(&serial);
+       memset(&uart, 0, sizeof(struct uart_port));
+       
+       uart.uartclk =  1843200;
+       uart.iobase = port;
+       uart.irq = irq;
+       uart.iotype = UPIO_PORT;
+       uart.flags =  UPF_SHARE_IRQ;
+       return serial8250_register_port(&uart);
 }
 
 
@@ -523,7 +526,7 @@ static void mwave_exit(void)
 #endif
 
        if ( pDrvData->sLine >= 0 ) {
-               unregister_serial(pDrvData->sLine);
+               serial8250_unregister_port(pDrvData->sLine);
        }
        if (pDrvData->bMwaveDevRegistered) {
                misc_deregister(&mwave_misc_dev);
index f022f0944434158f31eb3a9b3f0c9da35abadf1b..d0ef1ae412981d774289575dba2ea8a866975e37 100644 (file)
@@ -63,7 +63,6 @@
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/segment.h>
 #include <asm/bitops.h>
 #include <asm/uaccess.h>
 
index cd4fe8b1709f67593d47939819c9fd6a37e32ce3..63fff7c1244a29941dba32b1047ad63a31644831 100644 (file)
@@ -938,10 +938,9 @@ found:
 
        /*
         * XXX Interrupt pin #7 in Espresso is shared between RTC and
-        * PCI Slot 2 INTA# (and some INTx# in Slot 1). SA_INTERRUPT here
-        * is asking for trouble with add-on boards. Change to SA_SHIRQ.
+        * PCI Slot 2 INTA# (and some INTx# in Slot 1).
         */
-       if (request_irq(rtc_irq, rtc_interrupt, SA_INTERRUPT, "rtc", (void *)&rtc_port)) {
+       if (request_irq(rtc_irq, rtc_interrupt, SA_SHIRQ, "rtc", (void *)&rtc_port)) {
                /*
                 * Standard way for sparc to print irq's is to use
                 * __irq_itoa(). I think for EBus it's ok to use %d.
index d692af57213a7cbfac0a7e884749c94a35fb4b73..baaa365285fa973776beddcb0ae5c09389ffbe65 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/sched.h>
 #include <linux/byteorder/generic.h>
 #include <asm/sn/sn_sal.h>
+#include <asm/unaligned.h>
 #include "snsc.h"
 
 static struct subch_data_s *event_sd;
@@ -62,13 +63,16 @@ static int
 scdrv_parse_event(char *event, int *src, int *code, int *esp_code, char *desc)
 {
        char *desc_end;
+       __be32 from_buf;
 
        /* record event source address */
-       *src = be32_to_cpup((__be32 *)event);
+       from_buf = get_unaligned((__be32 *)event);
+       *src = be32_to_cpup(&from_buf);
        event += 4;                     /* move on to event code */
 
        /* record the system controller's event code */
-       *code = be32_to_cpup((__be32 *)event);
+       from_buf = get_unaligned((__be32 *)event);
+       *code = be32_to_cpup(&from_buf);
        event += 4;                     /* move on to event arguments */
 
        /* how many arguments are in the packet? */
@@ -82,7 +86,8 @@ scdrv_parse_event(char *event, int *src, int *code, int *esp_code, char *desc)
                /* not an integer argument, so give up */
                return -1;
        }
-       *esp_code = be32_to_cpup((__be32 *)event);
+       from_buf = get_unaligned((__be32 *)event);
+       *esp_code = be32_to_cpup(&from_buf);
        event += 4;
 
        /* parse out the event description */
index dc8c540391fdc690f2f30c0a69a6f586794d4c86..939e51e119e62bb63665afbf4591887861e5ea33 100644 (file)
@@ -14,7 +14,6 @@
  * License.
  */
 
-#include <acpi/acpi_bus.h>
 #include <linux/pnp.h>
 #include "tpm.h"
 
 #define        TPM_MAX_TRIES           5000
 #define        TPM_INFINEON_DEV_VEN_VALUE      0x15D1
 
-/* These values will be filled after ACPI-call */
+/* These values will be filled after PnP-call */
 static int TPM_INF_DATA = 0;
 static int TPM_INF_ADDR = 0;
+static int pnp_registered = 0;
 
 /* TPM header definitions */
 enum infineon_tpm_header {
@@ -356,24 +356,26 @@ static const struct pnp_device_id tpm_pnp_tbl[] = {
        {"IFX0102", 0},
        {"", 0}
 };
+MODULE_DEVICE_TABLE(pnp, tpm_pnp_tbl);
 
-static int __devinit tpm_inf_acpi_probe(struct pnp_dev *dev,
+static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
                                        const struct pnp_device_id *dev_id)
 {
-       TPM_INF_ADDR = (pnp_port_start(dev, 0) & 0xff);
-       TPM_INF_DATA = ((TPM_INF_ADDR + 1) & 0xff);
-       tpm_inf.base = pnp_port_start(dev, 1);
-       dev_info(&dev->dev, "Found %s with ID %s\n",
-                dev->name, dev_id->id);
-       if (!((tpm_inf.base >> 8) & 0xff))
-               tpm_inf.base = 0;
-       return 0;
+       if (pnp_port_valid(dev, 0)) {
+               TPM_INF_ADDR = (pnp_port_start(dev, 0) & 0xff);
+               TPM_INF_DATA = ((TPM_INF_ADDR + 1) & 0xff);
+               tpm_inf.base = pnp_port_start(dev, 1);
+               dev_info(&dev->dev, "Found %s with ID %s\n",
+               dev->name, dev_id->id);
+               return 0;
+       }
+       return -ENODEV;
 }
 
 static struct pnp_driver tpm_inf_pnp = {
        .name = "tpm_inf_pnp",
        .id_table = tpm_pnp_tbl,
-       .probe = tpm_inf_acpi_probe,
+       .probe = tpm_inf_pnp_probe,
 };
 
 static int __devinit tpm_inf_probe(struct pci_dev *pci_dev,
@@ -386,19 +388,30 @@ static int __devinit tpm_inf_probe(struct pci_dev *pci_dev,
        int productid[2];
        char chipname[20];
 
-       if (pci_enable_device(pci_dev))
-               return -EIO;
+       rc = pci_enable_device(pci_dev);
+       if (rc)
+               return rc;
 
        dev_info(&pci_dev->dev, "LPC-bus found at 0x%x\n", pci_id->device);
 
-       /* read IO-ports from ACPI */
-       pnp_register_driver(&tpm_inf_pnp);
-       pnp_unregister_driver(&tpm_inf_pnp);
+       /* read IO-ports from PnP */
+       rc = pnp_register_driver(&tpm_inf_pnp);
+       if (rc < 0) {
+               dev_err(&pci_dev->dev,
+                       "Error %x from pnp_register_driver!\n",rc);
+               goto error2;
+       }
+       if (!rc) {
+               dev_info(&pci_dev->dev, "No Infineon TPM found!\n");
+               goto error;
+       } else {
+               pnp_registered = 1;
+       }
 
        /* Make sure, we have received valid config ports */
        if (!TPM_INF_ADDR) {
-               pci_disable_device(pci_dev);
-               return -EIO;
+               dev_err(&pci_dev->dev, "No valid IO-ports received!\n");
+               goto error;
        }
 
        /* query chip for its vendor, its version number a.s.o. */
@@ -418,23 +431,21 @@ static int __devinit tpm_inf_probe(struct pci_dev *pci_dev,
 
        switch ((productid[0] << 8) | productid[1]) {
        case 6:
-               sprintf(chipname, " (SLD 9630 TT 1.1)");
+               snprintf(chipname, sizeof(chipname), " (SLD 9630 TT 1.1)");
                break;
        case 11:
-               sprintf(chipname, " (SLB 9635 TT 1.2)");
+               snprintf(chipname, sizeof(chipname), " (SLB 9635 TT 1.2)");
                break;
        default:
-               sprintf(chipname, " (unknown chip)");
+               snprintf(chipname, sizeof(chipname), " (unknown chip)");
                break;
        }
-       chipname[19] = 0;
 
        if ((vendorid[0] << 8 | vendorid[1]) == (TPM_INFINEON_DEV_VEN_VALUE)) {
 
                if (tpm_inf.base == 0) {
                        dev_err(&pci_dev->dev, "No IO-ports found!\n");
-                       pci_disable_device(pci_dev);
-                       return -EIO;
+                       goto error;
                }
                /* configure TPM with IO-ports */
                outb(IOLIMH, TPM_INF_ADDR);
@@ -452,8 +463,7 @@ static int __devinit tpm_inf_probe(struct pci_dev *pci_dev,
                        dev_err(&pci_dev->dev,
                                "Could not set IO-ports to %04x\n",
                                tpm_inf.base);
-                       pci_disable_device(pci_dev);
-                       return -EIO;
+                       goto error;
                }
 
                /* activate register */
@@ -479,14 +489,16 @@ static int __devinit tpm_inf_probe(struct pci_dev *pci_dev,
                         productid[0], productid[1], chipname);
 
                rc = tpm_register_hardware(pci_dev, &tpm_inf);
-               if (rc < 0) {
-                       pci_disable_device(pci_dev);
-                       return -ENODEV;
-               }
+               if (rc < 0)
+                       goto error;
                return 0;
        } else {
                dev_info(&pci_dev->dev, "No Infineon TPM found!\n");
+error:
+               pnp_unregister_driver(&tpm_inf_pnp);
+error2:
                pci_disable_device(pci_dev);
+               pnp_registered = 0;
                return -ENODEV;
        }
 }
@@ -521,6 +533,8 @@ static int __init init_inf(void)
 
 static void __exit cleanup_inf(void)
 {
+       if (pnp_registered)
+               pnp_unregister_driver(&tpm_inf_pnp);
        pci_unregister_driver(&inf_pci_driver);
 }
 
index b53e2e2b5aee93f3dcd03b362b51652b75a78c03..c3898afce3aed341e06e56a7d03b0425f27296b4 100644 (file)
@@ -346,6 +346,13 @@ config 8xx_WDT
        tristate "MPC8xx Watchdog Timer"
        depends on WATCHDOG && 8xx
 
+config BOOKE_WDT
+       tristate "PowerPC Book-E Watchdog Timer"
+       depends on WATCHDOG && (BOOKE || 4xx)
+       ---help---
+         Please see Documentation/watchdog/watchdog-api.txt for
+         more information.
+
 # MIPS Architecture
 
 config INDYDOG
index c1838834ea7f0ac5ea147a724d985853a535ce49..cfeac6f10137e5fc30862d8f287a53d3c084e73a 100644 (file)
@@ -2,42 +2,68 @@
 # Makefile for the WatchDog device drivers.
 #
 
+# Only one watchdog can succeed. We probe the ISA/PCI/USB based
+# watchdog-cards first, then the architecture specific watchdog
+# drivers and then the architecture independant "softdog" driver.
+# This means that if your ISA/PCI/USB card isn't detected that
+# you can fall back to an architecture specific driver and if
+# that also fails then you can fall back to the software watchdog
+# to give you some cover.
+
+# ISA-based Watchdog Cards
 obj-$(CONFIG_PCWATCHDOG) += pcwd.o
-obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o
-obj-$(CONFIG_ADVANTECH_WDT) += advantechwdt.o
-obj-$(CONFIG_IB700_WDT) += ib700wdt.o
 obj-$(CONFIG_MIXCOMWD) += mixcomwd.o
-obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o
-obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o
 obj-$(CONFIG_WDT) += wdt.o
+
+# PCI-based Watchdog Cards
+obj-$(CONFIG_PCIPCWATCHDOG) += pcwd_pci.o
 obj-$(CONFIG_WDTPCI) += wdt_pci.o
+
+# USB-based Watchdog Cards
+obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o
+
+# ARM Architecture
 obj-$(CONFIG_21285_WATCHDOG) += wdt285.o
 obj-$(CONFIG_977_WATCHDOG) += wdt977.o
-obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o
-obj-$(CONFIG_MACHZ_WDT) += machzwd.o
-obj-$(CONFIG_SH_WDT) += shwdt.o
+obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o
+obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o
 obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o
 obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o
-obj-$(CONFIG_EUROTECH_WDT) += eurotechwdt.o
-obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o
-obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o
-obj-$(CONFIG_SC520_WDT) += sc520_wdt.o
-obj-$(CONFIG_ALIM7101_WDT) += alim7101_wdt.o
+
+# X86 (i386 + ia64 + x86_64) Architecture
+obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o
+obj-$(CONFIG_ADVANTECH_WDT) += advantechwdt.o
 obj-$(CONFIG_ALIM1535_WDT) += alim1535_wdt.o
-obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o
+obj-$(CONFIG_ALIM7101_WDT) += alim7101_wdt.o
+obj-$(CONFIG_SC520_WDT) += sc520_wdt.o
+obj-$(CONFIG_EUROTECH_WDT) += eurotechwdt.o
+obj-$(CONFIG_IB700_WDT) += ib700wdt.o
 obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o
+obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o
+obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o
+obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o
+obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o
 obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o
-obj-$(CONFIG_INDYDOG) += indydog.o
-obj-$(CONFIG_PCIPCWATCHDOG) += pcwd_pci.o
-obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o
-obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o
-obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o
+obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o
+obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o
+obj-$(CONFIG_MACHZ_WDT) += machzwd.o
+
+# PowerPC Architecture
 obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o
+
+# PPC64 Architecture
 obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
+obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
+
+# MIPS Architecture
+obj-$(CONFIG_INDYDOG) += indydog.o
+
+# S390 Architecture
+
+# SUPERH Architecture
+obj-$(CONFIG_SH_WDT) += shwdt.o
 
-# Only one watchdog can succeed. We probe the hardware watchdog
-# drivers first, then the softdog driver.  This means if your hardware
-# watchdog dies or is 'borrowed' for some reason the software watchdog
-# still gives you some cover.
+# SPARC64 Architecture
 
+# Architecture Independant
 obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
diff --git a/drivers/char/watchdog/booke_wdt.c b/drivers/char/watchdog/booke_wdt.c
new file mode 100644 (file)
index 0000000..abc30cc
--- /dev/null
@@ -0,0 +1,192 @@
+/*
+ * drivers/char/watchdog/booke_wdt.c
+ *
+ * Watchdog timer for PowerPC Book-E systems
+ *
+ * Author: Matthew McClintock
+ * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ *
+ * Copyright 2005 Freescale Semiconductor Inc.
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/miscdevice.h>
+#include <linux/notifier.h>
+#include <linux/watchdog.h>
+
+#include <asm/reg_booke.h>
+#include <asm/uaccess.h>
+#include <asm/system.h>
+
+/* If the kernel parameter wdt_enable=1, the watchdog will be enabled at boot.
+ * Also, the wdt_period sets the watchdog timer period timeout.
+ * For E500 cpus the wdt_period sets which bit changing from 0->1 will
+ * trigger a watchog timeout. This watchdog timeout will occur 3 times, the
+ * first time nothing will happen, the second time a watchdog exception will
+ * occur, and the final time the board will reset.
+ */
+
+#ifdef CONFIG_FSL_BOOKE
+#define WDT_PERIOD_DEFAULT 63  /* Ex. wdt_period=28 bus=333Mhz , reset=~40sec */
+#else
+#define WDT_PERIOD_DEFAULT 4   /* Refer to the PPC40x and PPC4xx manuals */
+#endif                         /* for timing information */
+
+u32 booke_wdt_enabled = 0;
+u32 booke_wdt_period = WDT_PERIOD_DEFAULT;
+
+#ifdef CONFIG_FSL_BOOKE
+#define WDTP(x)                ((((63-x)&0x3)<<30)|(((63-x)&0x3c)<<15))
+#else
+#define WDTP(x)                (TCR_WP(x))
+#endif
+
+/*
+ * booke_wdt_enable:
+ */
+static __inline__ void booke_wdt_enable(void)
+{
+       u32 val;
+
+       val = mfspr(SPRN_TCR);
+       val |= (TCR_WIE|TCR_WRC(WRC_CHIP)|WDTP(booke_wdt_period));
+
+       mtspr(SPRN_TCR, val);
+}
+
+/*
+ * booke_wdt_ping:
+ */
+static __inline__ void booke_wdt_ping(void)
+{
+       mtspr(SPRN_TSR, TSR_ENW|TSR_WIS);
+}
+
+/*
+ * booke_wdt_write:
+ */
+static ssize_t booke_wdt_write (struct file *file, const char *buf,
+                               size_t count, loff_t *ppos)
+{
+       booke_wdt_ping();
+       return count;
+}
+
+static struct watchdog_info ident = {
+  .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
+  .firmware_version = 0,
+  .identity = "PowerPC Book-E Watchdog",
+};
+
+/*
+ * booke_wdt_ioctl:
+ */
+static int booke_wdt_ioctl (struct inode *inode, struct file *file,
+                           unsigned int cmd, unsigned long arg)
+{
+       u32 tmp = 0;
+
+       switch (cmd) {
+       case WDIOC_GETSUPPORT:
+               if (copy_to_user ((struct watchdog_info *) arg, &ident,
+                               sizeof(struct watchdog_info)))
+                       return -EFAULT;
+       case WDIOC_GETSTATUS:
+               return put_user(ident.options, (u32 *) arg);
+       case WDIOC_GETBOOTSTATUS:
+               /* XXX: something is clearing TSR */
+               tmp = mfspr(SPRN_TSR) & TSR_WRS(3);
+               /* returns 1 if last reset was caused by the WDT */
+               return (tmp ? 1 : 0);
+       case WDIOC_KEEPALIVE:
+               booke_wdt_ping();
+               return 0;
+       case WDIOC_SETTIMEOUT:
+               if (get_user(booke_wdt_period, (u32 *) arg))
+                       return -EFAULT;
+               mtspr(SPRN_TCR, (mfspr(SPRN_TCR)&~WDTP(0))|WDTP(booke_wdt_period));
+               return 0;
+       case WDIOC_GETTIMEOUT:
+               return put_user(booke_wdt_period, (u32 *) arg);
+       case WDIOC_SETOPTIONS:
+               if (get_user(tmp, (u32 *) arg))
+                       return -EINVAL;
+               if (tmp == WDIOS_ENABLECARD) {
+                       booke_wdt_ping();
+                       break;
+               } else
+                       return -EINVAL;
+               return 0;
+       default:
+               return -ENOIOCTLCMD;
+       }
+
+       return 0;
+}
+/*
+ * booke_wdt_open:
+ */
+static int booke_wdt_open (struct inode *inode, struct file *file)
+{
+       if (booke_wdt_enabled == 0) {
+               booke_wdt_enabled = 1;
+               booke_wdt_enable();
+               printk (KERN_INFO "PowerPC Book-E Watchdog Timer Enabled (wdt_period=%d)\n",
+                               booke_wdt_period);
+       }
+
+       return 0;
+}
+
+static struct file_operations booke_wdt_fops = {
+  .owner = THIS_MODULE,
+  .llseek = no_llseek,
+  .write = booke_wdt_write,
+  .ioctl = booke_wdt_ioctl,
+  .open = booke_wdt_open,
+};
+
+static struct miscdevice booke_wdt_miscdev = {
+  .minor = WATCHDOG_MINOR,
+  .name = "watchdog",
+  .fops = &booke_wdt_fops,
+};
+
+static void __exit booke_wdt_exit(void)
+{
+       misc_deregister(&booke_wdt_miscdev);
+}
+
+/*
+ * booke_wdt_init:
+ */
+static int __init booke_wdt_init(void)
+{
+       int ret = 0;
+
+       printk (KERN_INFO "PowerPC Book-E Watchdog Timer Loaded\n");
+       ident.firmware_version = cpu_specs[0].pvr_value;
+
+       ret = misc_register(&booke_wdt_miscdev);
+       if (ret) {
+               printk (KERN_CRIT "Cannot register miscdev on minor=%d (err=%d)\n",
+                               WATCHDOG_MINOR, ret);
+               return ret;
+       }
+
+       if (booke_wdt_enabled == 1) {
+               printk (KERN_INFO "PowerPC Book-E Watchdog Timer Enabled (wdt_period=%d)\n",
+                               booke_wdt_period);
+               booke_wdt_enable();
+       }
+
+       return ret;
+}
+device_initcall(booke_wdt_init);
index e7640bc4904b3fb869f75f770027edcdd9022ba9..0cfb9b9c4a4b2c47634cf329640b89651a6802ad 100644 (file)
@@ -182,7 +182,7 @@ static struct file_operations ixp2000_wdt_fops =
 static struct miscdevice ixp2000_wdt_miscdev =
 {
        .minor          = WATCHDOG_MINOR,
-       .name           = "IXP2000 Watchdog",
+       .name           = "watchdog",
        .fops           = &ixp2000_wdt_fops,
 };
 
index 8d916afbf4facdab59621fa874195bbaf4c4bacd..b5be8b11104af45e10c8f2f998de50706f1c5f25 100644 (file)
@@ -176,7 +176,7 @@ static struct file_operations ixp4xx_wdt_fops =
 static struct miscdevice ixp4xx_wdt_miscdev =
 {
        .minor          = WATCHDOG_MINOR,
-       .name           = "IXP4xx Watchdog",
+       .name           = "watchdog",
        .fops           = &ixp4xx_wdt_fops,
 };
 
index f85ac898a49aa7632cf06a5182acbbc1bb742a2f..8b292bf343c4169d57ee694fbc14f38d9c659695 100644 (file)
  *                             Fixed tmr_count / wdt_count confusion
  *                             Added configurable debug
  *
- *     11-Jan-2004     BJD     Fixed divide-by-2 in timeout code
+ *     11-Jan-2005     BJD     Fixed divide-by-2 in timeout code
+ *
+ *     25-Jan-2005     DA      Added suspend/resume support
+ *                             Replaced reboot notifier with .shutdown method
  *
  *     10-Mar-2005     LCVR    Changed S3C2410_VA to S3C24XX_VA
 */
@@ -40,8 +43,6 @@
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
 #include <linux/fs.h>
-#include <linux/notifier.h>
-#include <linux/reboot.h>
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/interrupt.h>
@@ -317,20 +318,6 @@ static int s3c2410wdt_ioctl(struct inode *inode, struct file *file,
        }
 }
 
-/*
- *     Notifier for system down
- */
-
-static int s3c2410wdt_notify_sys(struct notifier_block *this, unsigned long code,
-                             void *unused)
-{
-       if(code==SYS_DOWN || code==SYS_HALT) {
-               /* Turn the WDT off */
-               s3c2410wdt_stop();
-       }
-       return NOTIFY_DONE;
-}
-
 /* kernel interface */
 
 static struct file_operations s3c2410wdt_fops = {
@@ -348,10 +335,6 @@ static struct miscdevice s3c2410wdt_miscdev = {
        .fops           = &s3c2410wdt_fops,
 };
 
-static struct notifier_block s3c2410wdt_notifier = {
-       .notifier_call  = s3c2410wdt_notify_sys,
-};
-
 /* interrupt handler code */
 
 static irqreturn_t s3c2410wdt_irq(int irqno, void *param,
@@ -432,18 +415,10 @@ static int s3c2410wdt_probe(struct device *dev)
                }
        }
 
-       ret = register_reboot_notifier(&s3c2410wdt_notifier);
-       if (ret) {
-               printk (KERN_ERR PFX "cannot register reboot notifier (%d)\n",
-                       ret);
-               return ret;
-       }
-
        ret = misc_register(&s3c2410wdt_miscdev);
        if (ret) {
                printk (KERN_ERR PFX "cannot register miscdev on minor=%d (%d)\n",
                        WATCHDOG_MINOR, ret);
-               unregister_reboot_notifier(&s3c2410wdt_notifier);
                return ret;
        }
 
@@ -479,15 +454,63 @@ static int s3c2410wdt_remove(struct device *dev)
        return 0;
 }
 
+static void s3c2410wdt_shutdown(struct device *dev)
+{
+       s3c2410wdt_stop();      
+}
+
+#ifdef CONFIG_PM
+
+static unsigned long wtcon_save;
+static unsigned long wtdat_save;
+
+static int s3c2410wdt_suspend(struct device *dev, u32 state, u32 level)
+{
+       if (level == SUSPEND_POWER_DOWN) {
+               /* Save watchdog state, and turn it off. */
+               wtcon_save = readl(wdt_base + S3C2410_WTCON);
+               wtdat_save = readl(wdt_base + S3C2410_WTDAT);
+
+               /* Note that WTCNT doesn't need to be saved. */
+               s3c2410wdt_stop();
+       }
+
+       return 0;
+}
+
+static int s3c2410wdt_resume(struct device *dev, u32 level)
+{
+       if (level == RESUME_POWER_ON) {
+               /* Restore watchdog state. */
+
+               writel(wtdat_save, wdt_base + S3C2410_WTDAT);
+               writel(wtdat_save, wdt_base + S3C2410_WTCNT); /* Reset count */
+               writel(wtcon_save, wdt_base + S3C2410_WTCON);
+
+               printk(KERN_INFO PFX "watchdog %sabled\n",
+                      (wtcon_save & S3C2410_WTCON_ENABLE) ? "en" : "dis");
+       }
+
+       return 0;
+}
+
+#else
+#define s3c2410wdt_suspend NULL
+#define s3c2410wdt_resume  NULL
+#endif /* CONFIG_PM */
+
+
 static struct device_driver s3c2410wdt_driver = {
        .name           = "s3c2410-wdt",
        .bus            = &platform_bus_type,
        .probe          = s3c2410wdt_probe,
        .remove         = s3c2410wdt_remove,
+       .shutdown       = s3c2410wdt_shutdown,
+       .suspend        = s3c2410wdt_suspend,
+       .resume         = s3c2410wdt_resume,
 };
 
 
-
 static char banner[] __initdata = KERN_INFO "S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics\n";
 
 static int __init watchdog_init(void)
@@ -499,13 +522,13 @@ static int __init watchdog_init(void)
 static void __exit watchdog_exit(void)
 {
        driver_unregister(&s3c2410wdt_driver);
-       unregister_reboot_notifier(&s3c2410wdt_notifier);
 }
 
 module_init(watchdog_init);
 module_exit(watchdog_exit);
 
-MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
+MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>, "
+             "Dimitry Andric <dimitry.andric@tomtom.com>");
 MODULE_DESCRIPTION("S3C2410 Watchdog Device Driver");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
index c4568569f3a8cf9fe3561c80881ba99580563dc4..b4a102a2d7e390cfa3774d0a6c7871756e6b11ec 100644 (file)
@@ -206,7 +206,7 @@ static struct file_operations scx200_wdt_fops = {
 
 static struct miscdevice scx200_wdt_miscdev = {
        .minor = WATCHDOG_MINOR,
-       .name  = NAME,
+       .name  = "watchdog",
        .fops  = &scx200_wdt_fops,
 };
 
index 4d7ed931f5c6c918f738eea02caee70acfd4b493..20e5eb8667f2a738d9bbb16031cf0e6a4dc22733 100644 (file)
@@ -77,7 +77,7 @@ static void watchdog_fire(unsigned long);
 
 static struct timer_list watchdog_ticktock =
                TIMER_INITIALIZER(watchdog_fire, 0, 0);
-static unsigned long timer_alive;
+static unsigned long driver_open, orphan_timer;
 static char expect_close;
 
 
@@ -87,6 +87,9 @@ static char expect_close;
 
 static void watchdog_fire(unsigned long data)
 {
+       if (test_and_clear_bit(0, &orphan_timer))
+               module_put(THIS_MODULE);
+
        if (soft_noboot)
                printk(KERN_CRIT PFX "Triggered - Reboot ignored.\n");
        else
@@ -128,9 +131,9 @@ static int softdog_set_heartbeat(int t)
 
 static int softdog_open(struct inode *inode, struct file *file)
 {
-       if(test_and_set_bit(0, &timer_alive))
+       if (test_and_set_bit(0, &driver_open))
                return -EBUSY;
-       if (nowayout)
+       if (!test_and_clear_bit(0, &orphan_timer))
                __module_get(THIS_MODULE);
        /*
         *      Activate timer
@@ -147,11 +150,13 @@ static int softdog_release(struct inode *inode, struct file *file)
         */
        if (expect_close == 42) {
                softdog_stop();
+               module_put(THIS_MODULE);
        } else {
                printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n");
+               set_bit(0, &orphan_timer);
                softdog_keepalive();
        }
-       clear_bit(0, &timer_alive);
+       clear_bit(0, &driver_open);
        expect_close = 0;
        return 0;
 }
index 465e0fd0423d48b2c405836ac428a14af8c37a09..b5d8210154216bec46da66ae16ede0793746010f 100644 (file)
@@ -93,6 +93,12 @@ w83627hf_init(void)
 
        w83627hf_select_wd_register();
 
+       outb_p(0xF6, WDT_EFER); /* Select CRF6 */
+       t=inb_p(WDT_EFDR);      /* read CRF6 */
+       if (t != 0) {
+               printk (KERN_INFO PFX "Watchdog already running. Resetting timeout to %d sec\n", timeout);
+               outb_p(timeout, WDT_EFDR);    /* Write back to CRF6 */
+       }
        outb_p(0xF5, WDT_EFER); /* Select CRF5 */
        t=inb_p(WDT_EFDR);      /* read CRF5 */
        t&=~0x0C;               /* set second mode & disable keyboard turning off watchdog */
index 140d5f851a5b0c735dffc620778f4735048152b9..138dc50270e3e51e714893602c937b5fa95ec14e 100644 (file)
@@ -12,12 +12,20 @@ config HWMON
          of a system. Most modern motherboards include such a device. It
          can include temperature sensors, voltage sensors, fan speed
          sensors and various additional features such as the ability to
-         control the speed of the fans.
+         control the speed of the fans.  If you want this support you
+         should say Y here and also to the specific driver(s) for your
+         sensors chip(s) below.
+
+         This support can also be built as a module.  If so, the module
+         will be called hwmon.
+
+config HWMON_VID
+       tristate
+       default n
 
 config SENSORS_ADM1021
        tristate "Analog Devices ADM1021 and compatibles"
        depends on HWMON && I2C
-       select I2C_SENSOR
        help
          If you say yes here you get support for Analog Devices ADM1021
          and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A,
@@ -30,7 +38,7 @@ config SENSORS_ADM1021
 config SENSORS_ADM1025
        tristate "Analog Devices ADM1025 and compatibles"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
+       select HWMON_VID
        help
          If you say yes here you get support for Analog Devices ADM1025
          and Philips NE1619 sensor chips.
@@ -41,7 +49,7 @@ config SENSORS_ADM1025
 config SENSORS_ADM1026
        tristate "Analog Devices ADM1026 and compatibles"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
+       select HWMON_VID
        help
          If you say yes here you get support for Analog Devices ADM1026
          sensor chip.
@@ -52,7 +60,6 @@ config SENSORS_ADM1026
 config SENSORS_ADM1031
        tristate "Analog Devices ADM1031 and compatibles"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
        help
          If you say yes here you get support for Analog Devices ADM1031
          and ADM1030 sensor chips.
@@ -63,7 +70,7 @@ config SENSORS_ADM1031
 config SENSORS_ADM9240
        tristate "Analog Devices ADM9240 and compatibles"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
+       select HWMON_VID
        help
          If you say yes here you get support for Analog Devices ADM9240,
          Dallas DS1780, National Semiconductor LM81 sensor chips.
@@ -74,7 +81,7 @@ config SENSORS_ADM9240
 config SENSORS_ASB100
        tristate "Asus ASB100 Bach"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
+       select HWMON_VID
        help
          If you say yes here you get support for the ASB100 Bach sensor
          chip found on some Asus mainboards.
@@ -85,7 +92,7 @@ config SENSORS_ASB100
 config SENSORS_ATXP1
        tristate "Attansic ATXP1 VID controller"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
+       select HWMON_VID
        help
          If you say yes here you get support for the Attansic ATXP1 VID
          controller.
@@ -99,7 +106,6 @@ config SENSORS_ATXP1
 config SENSORS_DS1621
        tristate "Dallas Semiconductor DS1621 and DS1625"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
        help
          If you say yes here you get support for Dallas Semiconductor
          DS1621 and DS1625 sensor chips.
@@ -110,7 +116,6 @@ config SENSORS_DS1621
 config SENSORS_FSCHER
        tristate "FSC Hermes"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
        help
          If you say yes here you get support for Fujitsu Siemens
          Computers Hermes sensor chips.
@@ -121,7 +126,6 @@ config SENSORS_FSCHER
 config SENSORS_FSCPOS
        tristate "FSC Poseidon"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
        help
          If you say yes here you get support for Fujitsu Siemens
          Computers Poseidon sensor chips.
@@ -132,7 +136,6 @@ config SENSORS_FSCPOS
 config SENSORS_GL518SM
        tristate "Genesys Logic GL518SM"
        depends on HWMON && I2C
-       select I2C_SENSOR
        help
          If you say yes here you get support for Genesys Logic GL518SM
          sensor chips.
@@ -143,7 +146,7 @@ config SENSORS_GL518SM
 config SENSORS_GL520SM
        tristate "Genesys Logic GL520SM"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
+       select HWMON_VID
        help
          If you say yes here you get support for Genesys Logic GL520SM
          sensor chips.
@@ -154,7 +157,8 @@ config SENSORS_GL520SM
 config SENSORS_IT87
        tristate "ITE IT87xx and compatibles"
        depends on HWMON && I2C
-       select I2C_SENSOR
+       select I2C_ISA
+       select HWMON_VID
        help
          If you say yes here you get support for ITE IT87xx sensor chips
          and clones: SiS960.
@@ -165,7 +169,6 @@ config SENSORS_IT87
 config SENSORS_LM63
        tristate "National Semiconductor LM63"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
        help
          If you say yes here you get support for the National Semiconductor
          LM63 remote diode digital temperature sensor with integrated fan
@@ -178,7 +181,6 @@ config SENSORS_LM63
 config SENSORS_LM75
        tristate "National Semiconductor LM75 and compatibles"
        depends on HWMON && I2C
-       select I2C_SENSOR
        help
          If you say yes here you get support for National Semiconductor LM75
          sensor chips and clones: Dallas Semiconductor DS75 and DS1775 (in
@@ -194,7 +196,6 @@ config SENSORS_LM75
 config SENSORS_LM77
        tristate "National Semiconductor LM77"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
        help
          If you say yes here you get support for National Semiconductor LM77
          sensor chips.
@@ -205,7 +206,8 @@ config SENSORS_LM77
 config SENSORS_LM78
        tristate "National Semiconductor LM78 and compatibles"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
+       select I2C_ISA
+       select HWMON_VID
        help
          If you say yes here you get support for National Semiconductor LM78,
          LM78-J and LM79.
@@ -216,7 +218,6 @@ config SENSORS_LM78
 config SENSORS_LM80
        tristate "National Semiconductor LM80"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
        help
          If you say yes here you get support for National Semiconductor
          LM80 sensor chips.
@@ -227,7 +228,6 @@ config SENSORS_LM80
 config SENSORS_LM83
        tristate "National Semiconductor LM83"
        depends on HWMON && I2C
-       select I2C_SENSOR
        help
          If you say yes here you get support for National Semiconductor
          LM83 sensor chips.
@@ -238,7 +238,7 @@ config SENSORS_LM83
 config SENSORS_LM85
        tristate "National Semiconductor LM85 and compatibles"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
+       select HWMON_VID
        help
          If you say yes here you get support for National Semiconductor LM85
          sensor chips and clones: ADT7463, EMC6D100, EMC6D102 and ADM1027.
@@ -249,7 +249,7 @@ config SENSORS_LM85
 config SENSORS_LM87
        tristate "National Semiconductor LM87"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
+       select HWMON_VID
        help
          If you say yes here you get support for National Semiconductor LM87
          sensor chips.
@@ -260,7 +260,6 @@ config SENSORS_LM87
 config SENSORS_LM90
        tristate "National Semiconductor LM90 and compatibles"
        depends on HWMON && I2C
-       select I2C_SENSOR
        help
          If you say yes here you get support for National Semiconductor LM90,
          LM86, LM89 and LM99, Analog Devices ADM1032 and Maxim MAX6657 and
@@ -275,7 +274,6 @@ config SENSORS_LM90
 config SENSORS_LM92
        tristate "National Semiconductor LM92 and compatibles"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
        help
          If you say yes here you get support for National Semiconductor LM92
          and Maxim MAX6635 sensor chips.
@@ -286,7 +284,6 @@ config SENSORS_LM92
 config SENSORS_MAX1619
        tristate "Maxim MAX1619 sensor chip"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
        help
          If you say yes here you get support for MAX1619 sensor chip.
 
@@ -296,8 +293,8 @@ config SENSORS_MAX1619
 config SENSORS_PC87360
        tristate "National Semiconductor PC87360 family"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
        select I2C_ISA
+       select HWMON_VID
        help
          If you say yes here you get access to the hardware monitoring
          functions of the National Semiconductor PC8736x Super-I/O chips.
@@ -311,7 +308,6 @@ config SENSORS_PC87360
 config SENSORS_SIS5595
        tristate "Silicon Integrated Systems Corp. SiS5595"
        depends on HWMON && I2C && PCI && EXPERIMENTAL
-       select I2C_SENSOR
        select I2C_ISA
        help
          If you say yes here you get support for the integrated sensors in
@@ -323,7 +319,6 @@ config SENSORS_SIS5595
 config SENSORS_SMSC47M1
        tristate "SMSC LPC47M10x and compatibles"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
        select I2C_ISA
        help
          If you say yes here you get support for the integrated fan
@@ -336,7 +331,6 @@ config SENSORS_SMSC47M1
 config SENSORS_SMSC47B397
        tristate "SMSC LPC47B397-NC"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
        select I2C_ISA
        help
          If you say yes here you get support for the SMSC LPC47B397-NC
@@ -348,7 +342,6 @@ config SENSORS_SMSC47B397
 config SENSORS_VIA686A
        tristate "VIA686A"
        depends on HWMON && I2C && PCI
-       select I2C_SENSOR
        select I2C_ISA
        help
          If you say yes here you get support for the integrated sensors in
@@ -360,7 +353,8 @@ config SENSORS_VIA686A
 config SENSORS_W83781D
        tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F"
        depends on HWMON && I2C
-       select I2C_SENSOR
+       select I2C_ISA
+       select HWMON_VID
        help
          If you say yes here you get support for the Winbond W8378x series
          of sensor chips: the W83781D, W83782D, W83783S and W83627HF,
@@ -369,10 +363,18 @@ config SENSORS_W83781D
          This driver can also be built as a module.  If so, the module
          will be called w83781d.
 
+config SENSORS_W83792D
+       tristate "Winbond W83792D"
+       depends on HWMON && I2C && EXPERIMENTAL
+       help
+         If you say yes here you get support for the Winbond W83792D chip.
+
+         This driver can also be built as a module.  If so, the module
+         will be called w83792d.
+
 config SENSORS_W83L785TS
        tristate "Winbond W83L785TS-S"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
        help
          If you say yes here you get support for the Winbond W83L785TS-S
          sensor chip, which is used on the Asus A7N8X, among other
@@ -384,8 +386,8 @@ config SENSORS_W83L785TS
 config SENSORS_W83627HF
        tristate "Winbond W83627HF, W83627THF, W83637HF, W83697HF"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
        select I2C_ISA
+       select HWMON_VID
        help
          If you say yes here you get support for the Winbond W836X7 series
          of sensor chips: the W83627HF, W83627THF, W83637HF, and the W83697HF
@@ -396,7 +398,6 @@ config SENSORS_W83627HF
 config SENSORS_W83627EHF
        tristate "Winbond W83627EHF"
        depends on HWMON && I2C && EXPERIMENTAL
-       select I2C_SENSOR
        select I2C_ISA
        help
          If you say yes here you get preliminary support for the hardware
@@ -404,6 +405,9 @@ config SENSORS_W83627EHF
          Only fan and temperature inputs are supported at the moment, while
          the chip does much more than that.
 
+         This driver also supports the W83627EHG, which is the lead-free
+         version of the W83627EHF.
+
          This driver can also be built as a module.  If so, the module
          will be called w83627ehf.
 
index 2781403a0236d1e02d3c82d3bdaac323da2a2dd7..381f1bf04cc5531f2f4f2376f2c0afc61fff57b7 100644 (file)
@@ -2,9 +2,13 @@
 # Makefile for sensor chip drivers.
 #
 
+obj-$(CONFIG_HWMON)            += hwmon.o
+obj-$(CONFIG_HWMON_VID)                += hwmon-vid.o
+
 # asb100, then w83781d go first, as they can override other drivers' addresses.
 obj-$(CONFIG_SENSORS_ASB100)   += asb100.o
 obj-$(CONFIG_SENSORS_W83627HF) += w83627hf.o
+obj-$(CONFIG_SENSORS_W83792D)  += w83792d.o
 obj-$(CONFIG_SENSORS_W83781D)  += w83781d.o
 
 obj-$(CONFIG_SENSORS_ADM1021)  += adm1021.o
index d2c774c32f45b942a92453eb110346fa028e7bd7..e928cdb041cba28d76f23821172becc7c3589397 100644 (file)
@@ -24,7 +24,8 @@
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
 
 
 /* Addresses to scan */
@@ -32,10 +33,9 @@ static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a,
                                        0x29, 0x2a, 0x2b,
                                        0x4c, 0x4d, 0x4e, 
                                        I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
-SENSORS_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1066);
+I2C_CLIENT_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1066);
 
 /* adm1021 constants specified below */
 
@@ -89,6 +89,7 @@ clearing it.  Weird, ey?   --Phil  */
 /* Each client has this additional data */
 struct adm1021_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        enum chips type;
 
        struct semaphore update_lock;
@@ -185,7 +186,7 @@ static int adm1021_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, adm1021_detect);
+       return i2c_probe(adapter, &addr_data, adm1021_detect);
 }
 
 static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
@@ -196,15 +197,6 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
        int err = 0;
        const char *type_name = "";
 
-       /* Make sure we aren't probing the ISA bus!! This is just a safety check
-          at this moment; i2c_detect really won't call us. */
-#ifdef DEBUG
-       if (i2c_is_isa_adapter(adapter)) {
-               dev_dbg(&adapter->dev, "adm1021_detect called for an ISA bus adapter?!?\n");
-               return 0;
-       }
-#endif
-
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
                goto error0;
 
@@ -295,6 +287,12 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
                adm1021_init_client(new_client);
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto error2;
+       }
+
        device_create_file(&new_client->dev, &dev_attr_temp1_max);
        device_create_file(&new_client->dev, &dev_attr_temp1_min);
        device_create_file(&new_client->dev, &dev_attr_temp1_input);
@@ -305,6 +303,8 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
+error2:
+       i2c_detach_client(new_client);
 error1:
        kfree(data);
 error0:
@@ -322,14 +322,15 @@ static void adm1021_init_client(struct i2c_client *client)
 
 static int adm1021_detach_client(struct i2c_client *client)
 {
+       struct adm1021_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
        return 0;
 }
 
index e452d0daf906e314f9b0a2444aa64a9b93803609..526b7ff179ebb83c0bc1197a978e85344424a6c8 100644 (file)
@@ -50,8 +50,9 @@
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
-#include <linux/i2c-vid.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-vid.h>
+#include <linux/err.h>
 
 /*
  * Addresses to scan
  */
 
 static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /*
  * Insmod parameters
  */
 
-SENSORS_INSMOD_2(adm1025, ne1619);
+I2C_CLIENT_INSMOD_2(adm1025, ne1619);
 
 /*
  * The ADM1025 registers
@@ -132,6 +132,7 @@ static struct i2c_driver adm1025_driver = {
 
 struct adm1025_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore update_lock;
        char valid; /* zero until following fields are valid */
        unsigned long last_updated; /* in jiffies */
@@ -312,7 +313,7 @@ static int adm1025_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, adm1025_detect);
+       return i2c_probe(adapter, &addr_data, adm1025_detect);
 }
 
 /*
@@ -416,6 +417,12 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind)
        adm1025_init_client(new_client);
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        device_create_file(&new_client->dev, &dev_attr_in0_input);
        device_create_file(&new_client->dev, &dev_attr_in1_input);
        device_create_file(&new_client->dev, &dev_attr_in2_input);
@@ -452,6 +459,8 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
+exit_detach:
+       i2c_detach_client(new_client);
 exit_free:
        kfree(data);
 exit:
@@ -464,7 +473,7 @@ static void adm1025_init_client(struct i2c_client *client)
        struct adm1025_data *data = i2c_get_clientdata(client);
        int i;
 
-       data->vrm = i2c_which_vrm();
+       data->vrm = vid_which_vrm();
 
        /*
         * Set high limits
@@ -502,15 +511,15 @@ static void adm1025_init_client(struct i2c_client *client)
 
 static int adm1025_detach_client(struct i2c_client *client)
 {
+       struct adm1025_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, "
-                       "client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
        return 0;
 }
 
index c8a7f47911f99f315189cc60cb73ba23e888b5fb..625158110fd4ff74294debbc2a67a550012f90c9 100644 (file)
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
-#include <linux/i2c-vid.h>
+#include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
+#include <linux/hwmon-vid.h>
+#include <linux/err.h>
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
-SENSORS_INSMOD_1(adm1026);
+I2C_CLIENT_INSMOD_1(adm1026);
 
 static int gpio_input[17]  = { -1, -1, -1, -1, -1, -1, -1, -1, -1,
                                -1, -1, -1, -1, -1, -1, -1, -1 }; 
@@ -259,6 +259,7 @@ struct pwm_data {
 
 struct adm1026_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore lock;
        enum chips type;
 
@@ -319,13 +320,15 @@ int adm1026_attach_adapter(struct i2c_adapter *adapter)
        if (!(adapter->class & I2C_CLASS_HWMON)) {
                return 0;
        }
-       return i2c_detect(adapter, &addr_data, adm1026_detect);
+       return i2c_probe(adapter, &addr_data, adm1026_detect);
 }
 
 int adm1026_detach_client(struct i2c_client *client)
 {
+       struct adm1026_data *data = i2c_get_clientdata(client);
+       hwmon_device_unregister(data->class_dev);
        i2c_detach_client(client);
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
        return 0;
 }
 
@@ -1549,12 +1552,18 @@ int adm1026_detect(struct i2c_adapter *adapter, int address,
                goto exitfree;
 
        /* Set the VRM version */
-       data->vrm = i2c_which_vrm();
+       data->vrm = vid_which_vrm();
 
        /* Initialize the ADM1026 chip */
        adm1026_init_client(new_client);
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exitdetach;
+       }
+
        device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr);
        device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr);
        device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr);
@@ -1690,6 +1699,8 @@ int adm1026_detect(struct i2c_adapter *adapter, int address,
        return 0;
 
        /* Error out and cleanup code */
+exitdetach:
+       i2c_detach_client(new_client);
 exitfree:
        kfree(data);
 exit:
index 9362509572709596d92849a666199f4cf1bcb46a..58338ed7c8a1c676095e3c9672fa08e453455a7b 100644 (file)
@@ -26,7 +26,8 @@
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
 
 /* Following macros takes channel parameter starting from 0 to 2 */
 #define ADM1031_REG_FAN_SPEED(nr)      (0x08 + (nr))
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
-SENSORS_INSMOD_2(adm1030, adm1031);
+I2C_CLIENT_INSMOD_2(adm1030, adm1031);
 
 typedef u8 auto_chan_table_t[8][2];
 
 /* Each client has this additional data */
 struct adm1031_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore update_lock;
        int chip_type;
        char valid;             /* !=0 if following fields are valid */
@@ -725,10 +726,10 @@ static int adm1031_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, adm1031_detect);
+       return i2c_probe(adapter, &addr_data, adm1031_detect);
 }
 
-/* This function is called by i2c_detect */
+/* This function is called by i2c_probe */
 static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind)
 {
        struct i2c_client *new_client;
@@ -788,6 +789,12 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind)
        adm1031_init_client(new_client);
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        device_create_file(&new_client->dev, &dev_attr_fan1_input);
        device_create_file(&new_client->dev, &dev_attr_fan1_div);
        device_create_file(&new_client->dev, &dev_attr_fan1_min);
@@ -833,6 +840,8 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
+exit_detach:
+       i2c_detach_client(new_client);
 exit_free:
        kfree(data);
 exit:
@@ -841,11 +850,14 @@ exit:
 
 static int adm1031_detach_client(struct i2c_client *client)
 {
+       struct adm1031_data *data = i2c_get_clientdata(client);
        int ret;
+
+       hwmon_device_unregister(data->class_dev);
        if ((ret = i2c_detach_client(client)) != 0) {
                return ret;
        }
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
        return 0;
 }
 
index ce2a6eb93f6e5d4c7baed6fc26797b86988559e4..bc7faef162f7b562fc99a8c8481d73c0809e6e2c 100644 (file)
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
-#include <linux/i2c-vid.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-vid.h>
+#include <linux/err.h>
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
                                        I2C_CLIENT_END };
 
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-
 /* Insmod parameters */
-SENSORS_INSMOD_3(adm9240, ds1780, lm81);
+I2C_CLIENT_INSMOD_3(adm9240, ds1780, lm81);
 
 /* ADM9240 registers */
 #define ADM9240_REG_MAN_ID             0x3e
@@ -150,6 +149,7 @@ static struct i2c_driver adm9240_driver = {
 struct adm9240_data {
        enum chips type;
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore update_lock;
        char valid;
        unsigned long last_updated_measure;
@@ -582,6 +582,12 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)
        adm9240_init_client(new_client);
 
        /* populate sysfs filesystem */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        device_create_file(&new_client->dev, &dev_attr_in0_input);
        device_create_file(&new_client->dev, &dev_attr_in0_min);
        device_create_file(&new_client->dev, &dev_attr_in0_max);
@@ -615,6 +621,9 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)
        device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
 
        return 0;
+
+exit_detach:
+       i2c_detach_client(new_client);
 exit_free:
        kfree(data);
 exit:
@@ -625,20 +634,20 @@ static int adm9240_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, adm9240_detect);
+       return i2c_probe(adapter, &addr_data, adm9240_detect);
 }
 
 static int adm9240_detach_client(struct i2c_client *client)
 {
+       struct adm9240_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, "
-                               "client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
        return 0;
 }
 
@@ -648,7 +657,7 @@ static void adm9240_init_client(struct i2c_client *client)
        u8 conf = adm9240_read_value(client, ADM9240_REG_CONFIG);
        u8 mode = adm9240_read_value(client, ADM9240_REG_TEMP_CONF) & 3;
 
-       data->vrm = i2c_which_vrm(); /* need this to report vid as mV */
+       data->vrm = vid_which_vrm(); /* need this to report vid as mV */
 
        dev_info(&client->dev, "Using VRM: %d.%d\n", data->vrm / 10,
                        data->vrm % 10);
index 70d996d6fe0a95c607c06afe6b0a8da01025a39e..8e34855a627406200510db53dd9e374d87ce7db9 100644 (file)
@@ -39,8 +39,9 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
-#include <linux/i2c-vid.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-vid.h>
+#include <linux/err.h>
 #include <linux/init.h>
 #include <linux/jiffies.h>
 #include "lm75.h"
 /* I2C addresses to scan */
 static unsigned short normal_i2c[] = { 0x2d, I2C_CLIENT_END };
 
-/* ISA addresses to scan (none) */
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-
 /* Insmod parameters */
-SENSORS_INSMOD_1(asb100);
+I2C_CLIENT_INSMOD_1(asb100);
 I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: "
        "{bus, clientaddr, subclientaddr1, subclientaddr2}");
 
@@ -183,6 +181,7 @@ static u8 DIV_TO_REG(long val)
    dynamically allocated, at the same time the client itself is allocated. */
 struct asb100_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore lock;
        enum chips type;
 
@@ -621,7 +620,7 @@ static int asb100_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, asb100_detect);
+       return i2c_probe(adapter, &addr_data, asb100_detect);
 }
 
 static int asb100_detect_subclients(struct i2c_adapter *adapter, int address,
@@ -714,14 +713,6 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind)
        struct i2c_client *new_client;
        struct asb100_data *data;
 
-       /* asb100 is SMBus only */
-       if (i2c_is_isa_adapter(adapter)) {
-               pr_debug("asb100.o: detect failed, "
-                               "cannot attach to legacy adapter!\n");
-               err = -ENODEV;
-               goto ERROR0;
-       }
-
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
                pr_debug("asb100.o: detect failed, "
                                "smbus byte data not supported!\n");
@@ -821,6 +812,12 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind)
        data->fan_min[2] = asb100_read_value(new_client, ASB100_REG_FAN_MIN(2));
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto ERROR3;
+       }
+
        device_create_file_in(new_client, 0);
        device_create_file_in(new_client, 1);
        device_create_file_in(new_client, 2);
@@ -847,6 +844,11 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
+ERROR3:
+       i2c_detach_client(data->lm75[1]);
+       i2c_detach_client(data->lm75[0]);
+       kfree(data->lm75[1]);
+       kfree(data->lm75[0]);
 ERROR2:
        i2c_detach_client(new_client);
 ERROR1:
@@ -857,21 +859,23 @@ ERROR0:
 
 static int asb100_detach_client(struct i2c_client *client)
 {
+       struct asb100_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "client deregistration failed; "
-                       "client not detached.\n");
+       /* main client */
+       if (data)
+               hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
-       if (i2c_get_clientdata(client)==NULL) {
-               /* subclients */
+       /* main client */
+       if (data)
+               kfree(data);
+
+       /* subclient */
+       else
                kfree(client);
-       } else {
-               /* main client */
-               kfree(i2c_get_clientdata(client));
-       }
 
        return 0;
 }
@@ -969,7 +973,7 @@ static void asb100_init_client(struct i2c_client *client)
 
        vid = asb100_read_value(client, ASB100_REG_VID_FANDIV) & 0x0f;
        vid |= (asb100_read_value(client, ASB100_REG_CHIPID) & 0x01) << 4;
-       data->vrm = i2c_which_vrm();
+       data->vrm = vid_which_vrm();
        vid = vid_from_reg(vid, data->vrm);
 
        /* Start monitoring */
index fca3fc1cef72f02c1217d32cbfc0fa8876c63e40..deb4d34c9539bab6428d9f5fad5d62a357b787b2 100644 (file)
@@ -23,8 +23,9 @@
 #include <linux/module.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
-#include <linux/i2c-vid.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-vid.h>
+#include <linux/err.h>
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("System voltages control via Attansic ATXP1");
@@ -40,9 +41,8 @@ MODULE_AUTHOR("Sebastian Witt <se.witt@gmx.net>");
 #define ATXP1_GPIO1MASK        0x0f
 
 static unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
-SENSORS_INSMOD_1(atxp1);
+I2C_CLIENT_INSMOD_1(atxp1);
 
 static int atxp1_attach_adapter(struct i2c_adapter * adapter);
 static int atxp1_detach_client(struct i2c_client * client);
@@ -59,6 +59,7 @@ static struct i2c_driver atxp1_driver = {
 
 struct atxp1_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore update_lock;
        unsigned long last_updated;
        u8 valid;
@@ -252,7 +253,7 @@ static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2);
 
 static int atxp1_attach_adapter(struct i2c_adapter *adapter)
 {
-       return i2c_detect(adapter, &addr_data, &atxp1_detect);
+       return i2c_probe(adapter, &addr_data, &atxp1_detect);
 };
 
 static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind)
@@ -295,7 +296,7 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind)
        }
 
        /* Get VRM */
-       data->vrm = i2c_which_vrm();
+       data->vrm = vid_which_vrm();
 
        if ((data->vrm != 90) && (data->vrm != 91)) {
                dev_err(&new_client->dev, "Not supporting VRM %d.%d\n",
@@ -317,6 +318,12 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind)
                goto exit_free;
        }
 
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        device_create_file(&new_client->dev, &dev_attr_gpio1);
        device_create_file(&new_client->dev, &dev_attr_gpio2);
        device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
@@ -326,6 +333,8 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
+exit_detach:
+       i2c_detach_client(new_client);
 exit_free:
        kfree(data);
 exit:
@@ -334,14 +343,17 @@ exit:
 
 static int atxp1_detach_client(struct i2c_client * client)
 {
+       struct atxp1_data * data = i2c_get_clientdata(client);
        int err;
 
+       hwmon_device_unregister(data->class_dev);
+
        err = i2c_detach_client(client);
 
        if (err)
                dev_err(&client->dev, "Failed to detach client.\n");
        else
-               kfree(i2c_get_clientdata(client));
+               kfree(data);
 
        return err;
 };
index 5360d58804f6244e4de94a2b85b9b312cd36a409..b0199e063d0ebf02f1b8f92910086b0353f5cd55 100644 (file)
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
 #include "lm75.h"
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
                                        0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
-SENSORS_INSMOD_1(ds1621);
+I2C_CLIENT_INSMOD_1(ds1621);
 static int polarity = -1;
 module_param(polarity, int, 0);
 MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low");
@@ -71,6 +71,7 @@ MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low")
 /* Each client has this additional data */
 struct ds1621_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore update_lock;
        char valid;                     /* !=0 if following fields are valid */
        unsigned long last_updated;     /* In jiffies */
@@ -179,10 +180,10 @@ static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, set_temp_max);
 
 static int ds1621_attach_adapter(struct i2c_adapter *adapter)
 {
-       return i2c_detect(adapter, &addr_data, ds1621_detect);
+       return i2c_probe(adapter, &addr_data, ds1621_detect);
 }
 
-/* This function is called by i2c_detect */
+/* This function is called by i2c_probe */
 int ds1621_detect(struct i2c_adapter *adapter, int address,
                   int kind)
 {
@@ -250,6 +251,12 @@ int ds1621_detect(struct i2c_adapter *adapter, int address,
        ds1621_init_client(new_client);
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        device_create_file(&new_client->dev, &dev_attr_alarms);
        device_create_file(&new_client->dev, &dev_attr_temp1_input);
        device_create_file(&new_client->dev, &dev_attr_temp1_min);
@@ -259,6 +266,8 @@ int ds1621_detect(struct i2c_adapter *adapter, int address,
 
 /* OK, this is not exactly good programming practice, usually. But it is
    very code-efficient in this case. */
+      exit_detach:
+       i2c_detach_client(new_client);
       exit_free:
        kfree(data);
       exit:
@@ -267,15 +276,15 @@ int ds1621_detect(struct i2c_adapter *adapter, int address,
 
 static int ds1621_detach_client(struct i2c_client *client)
 {
+       struct ds1621_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, "
-                       "client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
 
        return 0;
 }
index da411741c2c579964e8b1ac857d370154a8a33f3..eef6061d786b4e3c397b6bf9445a2d835be2b427 100644 (file)
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
 
 /*
  * Addresses to scan
  */
 
 static unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /*
  * Insmod parameters
  */
 
-SENSORS_INSMOD_1(fscher);
+I2C_CLIENT_INSMOD_1(fscher);
 
 /*
  * The FSCHER registers
@@ -132,6 +132,7 @@ static struct i2c_driver fscher_driver = {
 
 struct fscher_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore update_lock;
        char valid; /* zero until following fields are valid */
        unsigned long last_updated; /* in jiffies */
@@ -287,7 +288,7 @@ static int fscher_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, fscher_detect);
+       return i2c_probe(adapter, &addr_data, fscher_detect);
 }
 
 static int fscher_detect(struct i2c_adapter *adapter, int address, int kind)
@@ -341,6 +342,12 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind)
        fscher_init_client(new_client);
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        device_create_file_revision(new_client);
        device_create_file_alarms(new_client);
        device_create_file_control(new_client);
@@ -360,6 +367,8 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
+exit_detach:
+       i2c_detach_client(new_client);
 exit_free:
        kfree(data);
 exit:
@@ -368,15 +377,15 @@ exit:
 
 static int fscher_detach_client(struct i2c_client *client)
 {
+       struct fscher_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, "
-                       "client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
        return 0;
 }
 
index 301ae98bd0adb1fca9d0f0e6687a538019439a0b..5fc77a5fed07b4b25d8fc21d27e22cc55a6a71a9 100644 (file)
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
 #include <linux/init.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
 
 /*
  * Addresses to scan
  */
 static unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /*
  * Insmod parameters
  */
-SENSORS_INSMOD_1(fscpos);
+I2C_CLIENT_INSMOD_1(fscpos);
 
 /*
  * The FSCPOS registers
@@ -113,6 +113,7 @@ static struct i2c_driver fscpos_driver = {
  */
 struct fscpos_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore update_lock;
        char valid;             /* 0 until following fields are valid */
        unsigned long last_updated;     /* In jiffies */
@@ -434,7 +435,7 @@ static int fscpos_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, fscpos_detect);
+       return i2c_probe(adapter, &addr_data, fscpos_detect);
 }
 
 int fscpos_detect(struct i2c_adapter *adapter, int address, int kind)
@@ -496,6 +497,12 @@ int fscpos_detect(struct i2c_adapter *adapter, int address, int kind)
        dev_info(&new_client->dev, "Found fscpos chip, rev %u\n", data->revision);
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        device_create_file(&new_client->dev, &dev_attr_event);
        device_create_file(&new_client->dev, &dev_attr_in0_input);
        device_create_file(&new_client->dev, &dev_attr_in1_input);
@@ -526,6 +533,8 @@ int fscpos_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
+exit_detach:
+       i2c_detach_client(new_client);
 exit_free:
        kfree(data);
 exit:
@@ -534,14 +543,14 @@ exit:
 
 static int fscpos_detach_client(struct i2c_client *client)
 {
+       struct fscpos_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, client"
-                                                       " not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
        return 0;
 }
 
index 6bedf729dcf5c251b27c18676af66fab4b68793f..256b9323c84b1e83f087cf51a3b34bb9190548fb 100644 (file)
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
-SENSORS_INSMOD_2(gl518sm_r00, gl518sm_r80);
+I2C_CLIENT_INSMOD_2(gl518sm_r00, gl518sm_r80);
 
 /* Many GL518 constants specified below */
 
@@ -117,6 +117,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
 /* Each client has this additional data */
 struct gl518_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        enum chips type;
 
        struct semaphore update_lock;
@@ -346,7 +347,7 @@ static int gl518_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, gl518_detect);
+       return i2c_probe(adapter, &addr_data, gl518_detect);
 }
 
 static int gl518_detect(struct i2c_adapter *adapter, int address, int kind)
@@ -419,6 +420,12 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind)
        gl518_init_client((struct i2c_client *) new_client);
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        device_create_file(&new_client->dev, &dev_attr_in0_input);
        device_create_file(&new_client->dev, &dev_attr_in1_input);
        device_create_file(&new_client->dev, &dev_attr_in2_input);
@@ -450,6 +457,8 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind)
 /* OK, this is not exactly good programming practice, usually. But it is
    very code-efficient in this case. */
 
+exit_detach:
+       i2c_detach_client(new_client);
 exit_free:
        kfree(data);
 exit:
@@ -477,16 +486,15 @@ static void gl518_init_client(struct i2c_client *client)
 
 static int gl518_detach_client(struct i2c_client *client)
 {
+       struct gl518_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, "
-                       "client not detached.\n");
-               return err;
-       }
+       hwmon_device_unregister(data->class_dev);
 
-       kfree(i2c_get_clientdata(client));
+       if ((err = i2c_detach_client(client)))
+               return err;
 
+       kfree(data);
        return 0;
 }
 
index 80ae8d30c2afc4d556f054a0f6e7fbcf1a0d627e..12fd757066fc9cad503b32a5c1df1e056909fbb5 100644 (file)
@@ -26,8 +26,9 @@
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
-#include <linux/i2c-vid.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-vid.h>
+#include <linux/err.h>
 
 /* Type of the extra sensor */
 static unsigned short extra_sensor_type;
@@ -36,10 +37,9 @@ MODULE_PARM_DESC(extra_sensor_type, "Type of extra sensor (0=autodetect, 1=tempe
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
-SENSORS_INSMOD_1(gl520sm);
+I2C_CLIENT_INSMOD_1(gl520sm);
 
 /* Many GL520 constants specified below 
 One of the inputs can be configured as either temp or voltage.
@@ -120,6 +120,7 @@ static struct i2c_driver gl520_driver = {
 /* Client data */
 struct gl520_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore update_lock;
        char valid;             /* zero until the following fields are valid */
        unsigned long last_updated;     /* in jiffies */
@@ -518,7 +519,7 @@ static int gl520_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, gl520_detect);
+       return i2c_probe(adapter, &addr_data, gl520_detect);
 }
 
 static int gl520_detect(struct i2c_adapter *adapter, int address, int kind)
@@ -571,6 +572,12 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind)
        gl520_init_client(new_client);
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        device_create_file_vid(new_client, 0);
 
        device_create_file_in(new_client, 0);
@@ -592,6 +599,8 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
+exit_detach:
+       i2c_detach_client(new_client);
 exit_free:
        kfree(data);
 exit:
@@ -608,7 +617,7 @@ static void gl520_init_client(struct i2c_client *client)
        conf = oldconf = gl520_read_value(client, GL520_REG_CONF);
 
        data->alarm_mask = 0xff;
-       data->vrm = i2c_which_vrm();
+       data->vrm = vid_which_vrm();
 
        if (extra_sensor_type == 1)
                conf &= ~0x10;
@@ -639,15 +648,15 @@ static void gl520_init_client(struct i2c_client *client)
 
 static int gl520_detach_client(struct i2c_client *client)
 {
+       struct gl520_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, "
-                       "client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
        return 0;
 }
 
diff --git a/drivers/hwmon/hwmon-vid.c b/drivers/hwmon/hwmon-vid.c
new file mode 100644 (file)
index 0000000..312769a
--- /dev/null
@@ -0,0 +1,189 @@
+/*
+    hwmon-vid.c - VID/VRM/VRD voltage conversions
+
+    Copyright (c) 2004 Rudolf Marek <r.marek@sh.cvut.cz>
+
+    Partly imported from i2c-vid.h of the lm_sensors project
+    Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com>
+    With assistance from Trent Piepho <xyzzy@speakeasy.org>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/hwmon-vid.h>
+
+/*
+    Common code for decoding VID pins.
+
+    References:
+
+    For VRM 8.4 to 9.1, "VRM x.y DC-DC Converter Design Guidelines",
+    available at http://developer.intel.com/.
+
+    For VRD 10.0 and up, "VRD x.y Design Guide",
+    available at http://developer.intel.com/.
+
+    AMD Opteron processors don't follow the Intel specifications.
+    I'm going to "make up" 2.4 as the spec number for the Opterons.
+    No good reason just a mnemonic for the 24x Opteron processor
+    series.
+
+    Opteron VID encoding is:
+       00000  =  1.550 V
+       00001  =  1.525 V
+        . . . .
+       11110  =  0.800 V
+       11111  =  0.000 V (off)
+*/
+
+/* vrm is the VRM/VRD document version multiplied by 10.
+   val is the 4-, 5- or 6-bit VID code.
+   Returned value is in mV to avoid floating point in the kernel. */
+int vid_from_reg(int val, int vrm)
+{
+       int vid;
+
+       switch(vrm) {
+
+       case  0:
+               return 0;
+
+       case 100:               /* VRD 10.0 */
+               if((val & 0x1f) == 0x1f)
+                       return 0;
+               if((val & 0x1f) <= 0x09 || val == 0x0a)
+                       vid = 10875 - (val & 0x1f) * 250;
+               else
+                       vid = 18625 - (val & 0x1f) * 250;
+               if(val & 0x20)
+                       vid -= 125;
+               vid /= 10;      /* only return 3 dec. places for now */
+               return vid;
+
+       case 24:                /* Opteron processor */
+               return(val == 0x1f ? 0 : 1550 - val * 25);
+
+       case 91:                /* VRM 9.1 */
+       case 90:                /* VRM 9.0 */
+               return(val == 0x1f ? 0 :
+                                      1850 - val * 25);
+
+       case 85:                /* VRM 8.5 */
+               return((val & 0x10  ? 25 : 0) +
+                      ((val & 0x0f) > 0x04 ? 2050 : 1250) -
+                      ((val & 0x0f) * 50));
+
+       case 84:                /* VRM 8.4 */
+               val &= 0x0f;
+                               /* fall through */
+       default:                /* VRM 8.2 */
+               return(val == 0x1f ? 0 :
+                      val & 0x10  ? 5100 - (val) * 100 :
+                                    2050 - (val) * 50);
+       }
+}
+
+
+/*
+    After this point is the code to automatically determine which
+    VRM/VRD specification should be used depending on the CPU.
+*/
+
+struct vrm_model {
+       u8 vendor;
+       u8 eff_family;
+       u8 eff_model;
+       int vrm_type;
+};
+
+#define ANY 0xFF
+
+#ifdef CONFIG_X86
+
+static struct vrm_model vrm_models[] = {
+       {X86_VENDOR_AMD, 0x6, ANY, 90},         /* Athlon Duron etc */
+       {X86_VENDOR_AMD, 0xF, ANY, 24},         /* Athlon 64, Opteron */
+       {X86_VENDOR_INTEL, 0x6, 0x9, 85},       /* 0.13um too */
+       {X86_VENDOR_INTEL, 0x6, 0xB, 85},       /* Tualatin */
+       {X86_VENDOR_INTEL, 0x6, ANY, 82},       /* any P6 */
+       {X86_VENDOR_INTEL, 0x7, ANY, 0},        /* Itanium */
+       {X86_VENDOR_INTEL, 0xF, 0x0, 90},       /* P4 */
+       {X86_VENDOR_INTEL, 0xF, 0x1, 90},       /* P4 Willamette */
+       {X86_VENDOR_INTEL, 0xF, 0x2, 90},       /* P4 Northwood */
+       {X86_VENDOR_INTEL, 0xF, 0x3, 100},      /* P4 Prescott */
+       {X86_VENDOR_INTEL, 0xF, 0x4, 100},      /* P4 Prescott */
+       {X86_VENDOR_INTEL, 0x10,ANY, 0},        /* Itanium 2 */
+       {X86_VENDOR_UNKNOWN, ANY, ANY, 0}       /* stop here */
+};
+
+static int find_vrm(u8 eff_family, u8 eff_model, u8 vendor)
+{
+       int i = 0;
+
+       while (vrm_models[i].vendor!=X86_VENDOR_UNKNOWN) {
+               if (vrm_models[i].vendor==vendor)
+                       if ((vrm_models[i].eff_family==eff_family)
+                        && ((vrm_models[i].eff_model==eff_model) ||
+                            (vrm_models[i].eff_model==ANY)))
+                               return vrm_models[i].vrm_type;
+               i++;
+       }
+
+       return 0;
+}
+
+int vid_which_vrm(void)
+{
+       struct cpuinfo_x86 *c = cpu_data;
+       u32 eax;
+       u8 eff_family, eff_model;
+       int vrm_ret;
+
+       if (c->x86 < 6)         /* Any CPU with family lower than 6 */
+               return 0;       /* doesn't have VID and/or CPUID */
+
+       eax = cpuid_eax(1);
+       eff_family = ((eax & 0x00000F00)>>8);
+       eff_model  = ((eax & 0x000000F0)>>4);
+       if (eff_family == 0xF) {        /* use extended model & family */
+               eff_family += ((eax & 0x00F00000)>>20);
+               eff_model += ((eax & 0x000F0000)>>16)<<4;
+       }
+       vrm_ret = find_vrm(eff_family,eff_model,c->x86_vendor);
+       if (vrm_ret == 0)
+               printk(KERN_INFO "hwmon-vid: Unknown VRM version of your "
+                      "x86 CPU\n");
+       return vrm_ret;
+}
+
+/* and now something completely different for the non-x86 world */
+#else
+int vid_which_vrm(void)
+{
+       printk(KERN_INFO "hwmon-vid: Unknown VRM version of your CPU\n");
+       return 0;
+}
+#endif
+
+EXPORT_SYMBOL(vid_from_reg);
+EXPORT_SYMBOL(vid_which_vrm);
+
+MODULE_AUTHOR("Rudolf Marek <r.marek@sh.cvut.cz>");
+
+MODULE_DESCRIPTION("hwmon-vid driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
new file mode 100644 (file)
index 0000000..9b41c9b
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+    hwmon.c - part of lm_sensors, Linux kernel modules for hardware monitoring
+
+    This file defines the sysfs class "hwmon", for use by sensors drivers.
+
+    Copyright (C) 2005 Mark M. Hoffman <mhoffman@lightlink.com>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; version 2 of the License.
+*/
+
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/kdev_t.h>
+#include <linux/idr.h>
+#include <linux/hwmon.h>
+
+#define HWMON_ID_PREFIX "hwmon"
+#define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d"
+
+static struct class *hwmon_class;
+
+static DEFINE_IDR(hwmon_idr);
+
+/**
+ * hwmon_device_register - register w/ hwmon sysfs class
+ * @dev: the device to register
+ *
+ * hwmon_device_unregister() must be called when the class device is no
+ * longer needed.
+ *
+ * Returns the pointer to the new struct class device.
+ */
+struct class_device *hwmon_device_register(struct device *dev)
+{
+       struct class_device *cdev;
+       int id;
+
+       if (idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0)
+               return ERR_PTR(-ENOMEM);
+
+       if (idr_get_new(&hwmon_idr, NULL, &id) < 0)
+               return ERR_PTR(-ENOMEM);
+
+       id = id & MAX_ID_MASK;
+       cdev = class_device_create(hwmon_class, MKDEV(0,0), dev,
+                                       HWMON_ID_FORMAT, id);
+
+       if (IS_ERR(cdev))
+               idr_remove(&hwmon_idr, id);
+
+       return cdev;
+}
+
+/**
+ * hwmon_device_unregister - removes the previously registered class device
+ *
+ * @cdev: the class device to destroy
+ */
+void hwmon_device_unregister(struct class_device *cdev)
+{
+       int id;
+
+       if (sscanf(cdev->class_id, HWMON_ID_FORMAT, &id) == 1) {
+               class_device_unregister(cdev);
+               idr_remove(&hwmon_idr, id);
+       } else
+               dev_dbg(cdev->dev,
+                       "hwmon_device_unregister() failed: bad class ID!\n");
+}
+
+static int __init hwmon_init(void)
+{
+       hwmon_class = class_create(THIS_MODULE, "hwmon");
+       if (IS_ERR(hwmon_class)) {
+               printk(KERN_ERR "hwmon.c: couldn't create sysfs class\n");
+               return PTR_ERR(hwmon_class);
+       }
+       return 0;
+}
+
+static void __exit hwmon_exit(void)
+{
+       class_destroy(hwmon_class);
+}
+
+module_init(hwmon_init);
+module_exit(hwmon_exit);
+
+EXPORT_SYMBOL_GPL(hwmon_device_register);
+EXPORT_SYMBOL_GPL(hwmon_device_unregister);
+
+MODULE_AUTHOR("Mark M. Hoffman <mhoffman@lightlink.com>");
+MODULE_DESCRIPTION("hardware monitoring sysfs/class support");
+MODULE_LICENSE("GPL");
+
index db20c9e47393a36bbd04b580ce92560ff6dcc331..53cc2b6d63854a835e661a0b2921640b6e36e915 100644 (file)
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
-#include <linux/i2c-vid.h>
+#include <linux/i2c-isa.h>
+#include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
+#include <linux/hwmon-vid.h>
+#include <linux/err.h>
 #include <asm/io.h>
 
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
                                        0x2e, 0x2f, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END };
+static unsigned short isa_address = 0x290;
 
 /* Insmod parameters */
-SENSORS_INSMOD_2(it87, it8712);
+I2C_CLIENT_INSMOD_2(it87, it8712);
 
 #define        REG     0x2e    /* The register to read/write */
 #define        DEV     0x07    /* Register: Logical device select */
@@ -192,6 +194,7 @@ static int DIV_TO_REG(int val)
    allocated. */
 struct it87_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore lock;
        enum chips type;
 
@@ -218,7 +221,7 @@ struct it87_data {
 
 
 static int it87_attach_adapter(struct i2c_adapter *adapter);
-static int it87_find(int *address);
+static int it87_isa_attach_adapter(struct i2c_adapter *adapter);
 static int it87_detect(struct i2c_adapter *adapter, int address, int kind);
 static int it87_detach_client(struct i2c_client *client);
 
@@ -239,6 +242,14 @@ static struct i2c_driver it87_driver = {
        .detach_client  = it87_detach_client,
 };
 
+static struct i2c_driver it87_isa_driver = {
+       .owner          = THIS_MODULE,
+       .name           = "it87-isa",
+       .attach_adapter = it87_isa_attach_adapter,
+       .detach_client  = it87_detach_client,
+};
+
+
 static ssize_t show_in(struct device *dev, struct device_attribute *attr,
                char *buf)
 {
@@ -686,11 +697,16 @@ static int it87_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, it87_detect);
+       return i2c_probe(adapter, &addr_data, it87_detect);
 }
 
-/* SuperIO detection - will change normal_isa[0] if a chip is found */
-static int it87_find(int *address)
+static int it87_isa_attach_adapter(struct i2c_adapter *adapter)
+{
+       return it87_detect(adapter, isa_address, -1);
+}
+
+/* SuperIO detection - will change isa_address if a chip is found */
+static int __init it87_find(int *address)
 {
        int err = -ENODEV;
 
@@ -721,7 +737,7 @@ exit:
        return err;
 }
 
-/* This function is called by i2c_detect */
+/* This function is called by i2c_probe */
 int it87_detect(struct i2c_adapter *adapter, int address, int kind)
 {
        int i;
@@ -738,7 +754,7 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
 
        /* Reserve the ISA region */
        if (is_isa)
-               if (!request_region(address, IT87_EXTENT, it87_driver.name))
+               if (!request_region(address, IT87_EXTENT, it87_isa_driver.name))
                        goto ERROR0;
 
        /* Probe whether there is anything available on this address. Already
@@ -784,7 +800,7 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
        i2c_set_clientdata(new_client, data);
        new_client->addr = address;
        new_client->adapter = adapter;
-       new_client->driver = &it87_driver;
+       new_client->driver = is_isa ? &it87_isa_driver : &it87_driver;
        new_client->flags = 0;
 
        /* Now, we do the remaining detection. */
@@ -840,6 +856,12 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
        it87_init_client(new_client, data);
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto ERROR3;
+       }
+
        device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr);
        device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr);
        device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr);
@@ -897,13 +919,15 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
        }
 
        if (data->type == it8712) {
-               data->vrm = i2c_which_vrm();
+               data->vrm = vid_which_vrm();
                device_create_file_vrm(new_client);
                device_create_file_vid(new_client);
        }
 
        return 0;
 
+ERROR3:
+       i2c_detach_client(new_client);
 ERROR2:
        kfree(data);
 ERROR1:
@@ -915,17 +939,17 @@ ERROR0:
 
 static int it87_detach_client(struct i2c_client *client)
 {
+       struct it87_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev,
-                       "Client deregistration failed, client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
        if(i2c_is_isa_client(client))
                release_region(client->addr, IT87_EXTENT);
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
 
        return 0;
 }
@@ -1158,16 +1182,28 @@ static struct it87_data *it87_update_device(struct device *dev)
 
 static int __init sm_it87_init(void)
 {
-       int addr;
+       int addr, res;
 
        if (!it87_find(&addr)) {
-               normal_isa[0] = addr;
+               isa_address = addr;
+       }
+
+       res = i2c_add_driver(&it87_driver);
+       if (res)
+               return res;
+
+       res = i2c_isa_add_driver(&it87_isa_driver);
+       if (res) {
+               i2c_del_driver(&it87_driver);
+               return res;
        }
-       return i2c_add_driver(&it87_driver);
+
+       return 0;
 }
 
 static void __exit sm_it87_exit(void)
 {
+       i2c_isa_del_driver(&it87_isa_driver);
        i2c_del_driver(&it87_driver);
 }
 
index 7c6f9ea5a254c53614e2269a89263a4aad96184f..be5c7095ecbb2648bf86a05583373b0e9a30a157 100644 (file)
@@ -42,8 +42,9 @@
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
 #include <linux/hwmon-sysfs.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
 
 /*
  * Addresses to scan
  */
 
 static unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /*
  * Insmod parameters
  */
 
-SENSORS_INSMOD_1(lm63);
+I2C_CLIENT_INSMOD_1(lm63);
 
 /*
  * The LM63 registers
@@ -152,6 +152,7 @@ static struct i2c_driver lm63_driver = {
 
 struct lm63_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore update_lock;
        char valid; /* zero until following fields are valid */
        unsigned long last_updated; /* in jiffies */
@@ -358,7 +359,7 @@ static int lm63_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, lm63_detect);
+       return i2c_probe(adapter, &addr_data, lm63_detect);
 }
 
 /*
@@ -437,6 +438,12 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind)
        lm63_init_client(new_client);
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        if (data->config & 0x04) { /* tachometer enabled */
                device_create_file(&new_client->dev,
                                   &sensor_dev_attr_fan1_input.dev_attr);
@@ -462,6 +469,8 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
+exit_detach:
+       i2c_detach_client(new_client);
 exit_free:
        kfree(data);
 exit:
@@ -505,15 +514,15 @@ static void lm63_init_client(struct i2c_client *client)
 
 static int lm63_detach_client(struct i2c_client *client)
 {
+       struct lm63_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, "
-                       "client not detached\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
        return 0;
 }
 
index 5be164ed278ebaf236f9b65b98663b450cef8ba5..9a3ebdf583f403ec80f4c066aa64459bfb4ccfac 100644 (file)
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
 #include "lm75.h"
 
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
                                        0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
-SENSORS_INSMOD_1(lm75);
+I2C_CLIENT_INSMOD_1(lm75);
 
 /* Many LM75 constants specified below */
 
@@ -46,6 +46,7 @@ SENSORS_INSMOD_1(lm75);
 /* Each client has this additional data */
 struct lm75_data {
        struct i2c_client       client;
+       struct class_device *class_dev;
        struct semaphore        update_lock;
        char                    valid;          /* !=0 if following fields are valid */
        unsigned long           last_updated;   /* In jiffies */
@@ -107,10 +108,10 @@ static int lm75_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, lm75_detect);
+       return i2c_probe(adapter, &addr_data, lm75_detect);
 }
 
-/* This function is called by i2c_detect */
+/* This function is called by i2c_probe */
 static int lm75_detect(struct i2c_adapter *adapter, int address, int kind)
 {
        int i;
@@ -119,16 +120,6 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind)
        int err = 0;
        const char *name = "";
 
-       /* Make sure we aren't probing the ISA bus!! This is just a safety check
-          at this moment; i2c_detect really won't call us. */
-#ifdef DEBUG
-       if (i2c_is_isa_adapter(adapter)) {
-               dev_dbg(&adapter->dev,
-                       "lm75_detect called for an ISA bus adapter?!?\n");
-               goto exit;
-       }
-#endif
-
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
                                     I2C_FUNC_SMBUS_WORD_DATA))
                goto exit;
@@ -208,12 +199,20 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind)
        lm75_init_client(new_client);
        
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        device_create_file(&new_client->dev, &dev_attr_temp1_max);
        device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);
        device_create_file(&new_client->dev, &dev_attr_temp1_input);
 
        return 0;
 
+exit_detach:
+       i2c_detach_client(new_client);
 exit_free:
        kfree(data);
 exit:
@@ -222,8 +221,10 @@ exit:
 
 static int lm75_detach_client(struct i2c_client *client)
 {
+       struct lm75_data *data = i2c_get_clientdata(client);
+       hwmon_device_unregister(data->class_dev);
        i2c_detach_client(client);
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
        return 0;
 }
 
@@ -251,8 +252,12 @@ static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value)
 
 static void lm75_init_client(struct i2c_client *client)
 {
-       /* Initialize the LM75 chip */
-       lm75_write_value(client, LM75_REG_CONF, 0);
+       int reg;
+
+       /* Enable if in shutdown mode */
+       reg = lm75_read_value(client, LM75_REG_CONF);
+       if (reg >= 0 && (reg & 0x01))
+               lm75_write_value(client, LM75_REG_CONF, reg & 0xfe);
 }
 
 static struct lm75_data *lm75_update_device(struct device *dev)
index 63e3f2fb4c21dd4ef6b2063a993e4b5f2e237672..af7dc650ee1506878901453ea51bc75dee764392 100644 (file)
@@ -25,7 +25,7 @@
     which contains this code, we don't worry about the wasted space.
 */
 
-#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
 
 /* straight from the datasheet */
 #define LM75_TEMP_MIN (-55000)
index b98f449529976083b38c881f5cc9997050d500a7..866eab96a6f6f6594374037bda6eeb08c5a39c1a 100644 (file)
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
-
+#include <linux/hwmon.h>
+#include <linux/err.h>
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
-SENSORS_INSMOD_1(lm77);
+I2C_CLIENT_INSMOD_1(lm77);
 
 /* The LM77 registers */
 #define LM77_REG_TEMP          0x00
@@ -51,6 +50,7 @@ SENSORS_INSMOD_1(lm77);
 /* Each client has this additional data */
 struct lm77_data {
        struct i2c_client       client;
+       struct class_device *class_dev;
        struct semaphore        update_lock;
        char                    valid;
        unsigned long           last_updated;   /* In jiffies */
@@ -208,10 +208,10 @@ static int lm77_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, lm77_detect);
+       return i2c_probe(adapter, &addr_data, lm77_detect);
 }
 
-/* This function is called by i2c_detect */
+/* This function is called by i2c_probe */
 static int lm77_detect(struct i2c_adapter *adapter, int address, int kind)
 {
        struct i2c_client *new_client;
@@ -317,6 +317,12 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind)
        lm77_init_client(new_client);
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        device_create_file(&new_client->dev, &dev_attr_temp1_input);
        device_create_file(&new_client->dev, &dev_attr_temp1_crit);
        device_create_file(&new_client->dev, &dev_attr_temp1_min);
@@ -327,6 +333,8 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind)
        device_create_file(&new_client->dev, &dev_attr_alarms);
        return 0;
 
+exit_detach:
+       i2c_detach_client(new_client);
 exit_free:
        kfree(data);
 exit:
@@ -335,8 +343,10 @@ exit:
 
 static int lm77_detach_client(struct i2c_client *client)
 {
+       struct lm77_data *data = i2c_get_clientdata(client);
+       hwmon_device_unregister(data->class_dev);
        i2c_detach_client(client);
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
        return 0;
 }
 
index 29241469dcbac09d2617c365e7b5388fc6908308..f6730dc3573b68096814ccff7e8a898aae45122a 100644 (file)
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
+#include <linux/i2c-isa.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-vid.h>
+#include <linux/err.h>
 #include <asm/io.h>
 
 /* Addresses to scan */
@@ -31,10 +34,10 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24,
                                        0x25, 0x26, 0x27, 0x28, 0x29,
                                        0x2a, 0x2b, 0x2c, 0x2d, 0x2e,
                                        0x2f, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END };
+static unsigned short isa_address = 0x290;
 
 /* Insmod parameters */
-SENSORS_INSMOD_3(lm78, lm78j, lm79);
+I2C_CLIENT_INSMOD_2(lm78, lm79);
 
 /* Many LM78 constants specified below */
 
@@ -104,13 +107,6 @@ static inline int TEMP_FROM_REG(s8 val)
        return val * 1000;
 }
 
-/* VID: mV
-   REG: (see doc/vid) */
-static inline int VID_FROM_REG(u8 val)
-{
-       return val==0x1f ? 0 : val>=0x10 ? 5100-val*100 : 2050-val*50;
-}
-
 #define DIV_FROM_REG(val) (1 << (val))
 
 /* There are some complications in a module like this. First off, LM78 chips
@@ -134,6 +130,7 @@ static inline int VID_FROM_REG(u8 val)
    allocated. */
 struct lm78_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore lock;
        enum chips type;
 
@@ -156,6 +153,7 @@ struct lm78_data {
 
 
 static int lm78_attach_adapter(struct i2c_adapter *adapter);
+static int lm78_isa_attach_adapter(struct i2c_adapter *adapter);
 static int lm78_detect(struct i2c_adapter *adapter, int address, int kind);
 static int lm78_detach_client(struct i2c_client *client);
 
@@ -174,6 +172,14 @@ static struct i2c_driver lm78_driver = {
        .detach_client  = lm78_detach_client,
 };
 
+static struct i2c_driver lm78_isa_driver = {
+       .owner          = THIS_MODULE,
+       .name           = "lm78-isa",
+       .attach_adapter = lm78_isa_attach_adapter,
+       .detach_client  = lm78_detach_client,
+};
+
+
 /* 7 Voltages */
 static ssize_t show_in(struct device *dev, char *buf, int nr)
 {
@@ -445,7 +451,7 @@ static DEVICE_ATTR(fan3_div, S_IRUGO, show_fan_3_div, NULL);
 static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct lm78_data *data = lm78_update_device(dev);
-       return sprintf(buf, "%d\n", VID_FROM_REG(data->vid));
+       return sprintf(buf, "%d\n", vid_from_reg(82, data->vid));
 }
 static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
 
@@ -465,10 +471,15 @@ static int lm78_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, lm78_detect);
+       return i2c_probe(adapter, &addr_data, lm78_detect);
+}
+
+static int lm78_isa_attach_adapter(struct i2c_adapter *adapter)
+{
+       return lm78_detect(adapter, isa_address, -1);
 }
 
-/* This function is called by i2c_detect */
+/* This function is called by i2c_probe */
 int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
 {
        int i, err;
@@ -485,7 +496,8 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
 
        /* Reserve the ISA region */
        if (is_isa)
-               if (!request_region(address, LM78_EXTENT, lm78_driver.name)) {
+               if (!request_region(address, LM78_EXTENT,
+                                   lm78_isa_driver.name)) {
                        err = -EBUSY;
                        goto ERROR0;
                }
@@ -540,7 +552,7 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
        i2c_set_clientdata(new_client, data);
        new_client->addr = address;
        new_client->adapter = adapter;
-       new_client->driver = &lm78_driver;
+       new_client->driver = is_isa ? &lm78_isa_driver : &lm78_driver;
        new_client->flags = 0;
 
        /* Now, we do the remaining detection. */
@@ -559,10 +571,9 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
        /* Determine the chip type. */
        if (kind <= 0) {
                i = lm78_read_value(new_client, LM78_REG_CHIPID);
-               if (i == 0x00 || i == 0x20)
+               if (i == 0x00 || i == 0x20      /* LM78 */
+                || i == 0x40)                  /* LM78-J */
                        kind = lm78;
-               else if (i == 0x40)
-                       kind = lm78j;
                else if ((i & 0xfe) == 0xc0)
                        kind = lm79;
                else {
@@ -578,8 +589,6 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
 
        if (kind == lm78) {
                client_name = "lm78";
-       } else if (kind == lm78j) {
-               client_name = "lm78-j";
        } else if (kind == lm79) {
                client_name = "lm79";
        }
@@ -605,6 +614,12 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
        }
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto ERROR3;
+       }
+
        device_create_file(&new_client->dev, &dev_attr_in0_input);
        device_create_file(&new_client->dev, &dev_attr_in0_min);
        device_create_file(&new_client->dev, &dev_attr_in0_max);
@@ -643,6 +658,8 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
+ERROR3:
+       i2c_detach_client(new_client);
 ERROR2:
        kfree(data);
 ERROR1:
@@ -654,18 +671,18 @@ ERROR0:
 
 static int lm78_detach_client(struct i2c_client *client)
 {
+       struct lm78_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev,
-                   "Client deregistration failed, client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
        if(i2c_is_isa_client(client))
                release_region(client->addr, LM78_EXTENT);
 
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
 
        return 0;
 }
@@ -777,18 +794,31 @@ static struct lm78_data *lm78_update_device(struct device *dev)
 
 static int __init sm_lm78_init(void)
 {
-       return i2c_add_driver(&lm78_driver);
+       int res;
+
+       res = i2c_add_driver(&lm78_driver);
+       if (res)
+               return res;
+
+       res = i2c_isa_add_driver(&lm78_isa_driver);
+       if (res) {
+               i2c_del_driver(&lm78_driver);
+               return res;
+       }
+
+       return 0;
 }
 
 static void __exit sm_lm78_exit(void)
 {
+       i2c_isa_del_driver(&lm78_isa_driver);
        i2c_del_driver(&lm78_driver);
 }
 
 
 
 MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>");
-MODULE_DESCRIPTION("LM78, LM78-J and LM79 driver");
+MODULE_DESCRIPTION("LM78/LM79 driver");
 MODULE_LICENSE("GPL");
 
 module_init(sm_lm78_init);
index 8100595feb44640133c6ae6aa7308839f35c7711..83af8b3a0cac02ba04ef70f1ec4b8f118de210b5 100644 (file)
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c,
                                        0x2d, 0x2e, 0x2f, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
-SENSORS_INSMOD_1(lm80);
+I2C_CLIENT_INSMOD_1(lm80);
 
 /* Many LM80 constants specified below */
 
@@ -107,6 +107,7 @@ static inline long TEMP_FROM_REG(u16 temp)
 
 struct lm80_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore update_lock;
        char valid;             /* !=0 if following fields are valid */
        unsigned long last_updated;     /* In jiffies */
@@ -389,7 +390,7 @@ static int lm80_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, lm80_detect);
+       return i2c_probe(adapter, &addr_data, lm80_detect);
 }
 
 int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
@@ -451,6 +452,12 @@ int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
        data->fan_min[1] = lm80_read_value(new_client, LM80_REG_FAN_MIN(2));
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto error_detach;
+       }
+
        device_create_file(&new_client->dev, &dev_attr_in0_min);
        device_create_file(&new_client->dev, &dev_attr_in1_min);
        device_create_file(&new_client->dev, &dev_attr_in2_min);
@@ -487,6 +494,8 @@ int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
+error_detach:
+       i2c_detach_client(new_client);
 error_free:
        kfree(data);
 exit:
@@ -495,15 +504,15 @@ exit:
 
 static int lm80_detach_client(struct i2c_client *client)
 {
+       struct lm80_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, "
-                       "client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
        return 0;
 }
 
index a49008b444c8ef483f3e6ec933578c3a9e57e240..d74b2c20c719376eea2c8231938f66be28a5f9d8 100644 (file)
@@ -32,8 +32,9 @@
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
 #include <linux/hwmon-sysfs.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
 
 /*
  * Addresses to scan
@@ -45,13 +46,12 @@ static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a,
                                        0x29, 0x2a, 0x2b,
                                        0x4c, 0x4d, 0x4e,
                                        I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /*
  * Insmod parameters
  */
 
-SENSORS_INSMOD_1(lm83);
+I2C_CLIENT_INSMOD_1(lm83);
 
 /*
  * The LM83 registers
@@ -138,6 +138,7 @@ static struct i2c_driver lm83_driver = {
 
 struct lm83_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore update_lock;
        char valid; /* zero until following fields are valid */
        unsigned long last_updated; /* in jiffies */
@@ -212,7 +213,7 @@ static int lm83_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, lm83_detect);
+       return i2c_probe(adapter, &addr_data, lm83_detect);
 }
 
 /*
@@ -312,6 +313,12 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind)
         */
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        device_create_file(&new_client->dev,
                           &sensor_dev_attr_temp1_input.dev_attr);
        device_create_file(&new_client->dev,
@@ -340,6 +347,8 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
+exit_detach:
+       i2c_detach_client(new_client);
 exit_free:
        kfree(data);
 exit:
@@ -348,15 +357,15 @@ exit:
 
 static int lm83_detach_client(struct i2c_client *client)
 {
+       struct lm83_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev,
-                   "Client deregistration failed, client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
        return 0;
 }
 
index b4d7fd41826478a241d50535a70bbbf0507c8de4..ab214df9624bc423376bef632b4a87d0d1f2cf96 100644 (file)
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
-#include <linux/i2c-vid.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-vid.h>
+#include <linux/err.h>
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
-SENSORS_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102);
+I2C_CLIENT_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102);
 
 /* The LM85 registers */
 
@@ -281,15 +281,6 @@ static int ZONE_TO_REG( int zone )
 #define PPR_TO_REG(val,fan) (SENSORS_LIMIT((val)-1,0,3)<<(fan *2))
 #define PPR_FROM_REG(val,fan) ((((val)>>(fan * 2))&0x03)+1)
 
-/* i2c-vid.h defines vid_from_reg() */
-#define VID_FROM_REG(val,vrm) (vid_from_reg((val),(vrm)))
-
-/* Unlike some other drivers we DO NOT set initial limits.  Use
- * the config file to set limits.  Some users have reported
- * motherboards shutting down when we set limits in a previous
- * version of the driver.
- */
-
 /* Chip sampling rates
  *
  * Some sensors are not updated more frequently than once per second
@@ -339,6 +330,7 @@ struct lm85_autofan {
 
 struct lm85_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore lock;
        enum chips type;
 
@@ -1019,7 +1011,7 @@ int lm85_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, lm85_detect);
+       return i2c_probe(adapter, &addr_data, lm85_detect);
 }
 
 int lm85_detect(struct i2c_adapter *adapter, int address,
@@ -1031,11 +1023,6 @@ int lm85_detect(struct i2c_adapter *adapter, int address,
        int err = 0;
        const char *type_name = "";
 
-       if (i2c_is_isa_adapter(adapter)) {
-               /* This chip has no ISA interface */
-               goto ERROR0 ;
-       };
-
        if (!i2c_check_functionality(adapter,
                                        I2C_FUNC_SMBUS_BYTE_DATA)) {
                /* We need to be able to do byte I/O */
@@ -1160,12 +1147,18 @@ int lm85_detect(struct i2c_adapter *adapter, int address,
                goto ERROR1;
 
        /* Set the VRM version */
-       data->vrm = i2c_which_vrm();
+       data->vrm = vid_which_vrm();
 
        /* Initialize the LM85 chip */
        lm85_init_client(new_client);
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto ERROR2;
+       }
+
        device_create_file(&new_client->dev, &dev_attr_fan1_input);
        device_create_file(&new_client->dev, &dev_attr_fan2_input);
        device_create_file(&new_client->dev, &dev_attr_fan3_input);
@@ -1235,6 +1228,8 @@ int lm85_detect(struct i2c_adapter *adapter, int address,
        return 0;
 
        /* Error out and cleanup code */
+    ERROR2:
+       i2c_detach_client(new_client);
     ERROR1:
        kfree(data);
     ERROR0:
@@ -1243,8 +1238,10 @@ int lm85_detect(struct i2c_adapter *adapter, int address,
 
 int lm85_detach_client(struct i2c_client *client)
 {
+       struct lm85_data *data = i2c_get_clientdata(client);
+       hwmon_device_unregister(data->class_dev);
        i2c_detach_client(client);
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
        return 0;
 }
 
index 1921ed1af182df9f05dc68b114e7115f51009bea..dca996de4c331e5eae87c3a868fb47c46ca9b3e6 100644 (file)
@@ -57,8 +57,9 @@
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
-#include <linux/i2c-vid.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-vid.h>
+#include <linux/err.h>
 
 /*
  * Addresses to scan
  */
 
 static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /*
  * Insmod parameters
  */
 
-SENSORS_INSMOD_1(lm87);
+I2C_CLIENT_INSMOD_1(lm87);
 
 /*
  * The LM87 registers
@@ -175,6 +175,7 @@ static struct i2c_driver lm87_driver = {
 
 struct lm87_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore update_lock;
        char valid; /* zero until following fields are valid */
        unsigned long last_updated; /* In jiffies */
@@ -537,7 +538,7 @@ static int lm87_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, lm87_detect);
+       return i2c_probe(adapter, &addr_data, lm87_detect);
 }
 
 /*
@@ -608,6 +609,12 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
        data->in_scale[7] = 1875;
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        device_create_file(&new_client->dev, &dev_attr_in1_input);
        device_create_file(&new_client->dev, &dev_attr_in1_min);
        device_create_file(&new_client->dev, &dev_attr_in1_max);
@@ -673,6 +680,8 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
+exit_detach:
+       i2c_detach_client(new_client);
 exit_free:
        kfree(data);
 exit:
@@ -685,7 +694,7 @@ static void lm87_init_client(struct i2c_client *client)
        u8 config;
 
        data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE);
-       data->vrm = i2c_which_vrm();
+       data->vrm = vid_which_vrm();
 
        config = lm87_read_value(client, LM87_REG_CONFIG);
        if (!(config & 0x01)) {
@@ -719,15 +728,15 @@ static void lm87_init_client(struct i2c_client *client)
 
 static int lm87_detach_client(struct i2c_client *client)
 {
+       struct lm87_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, "
-                       "client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
        return 0;
 }
 
index a67dcadf7cb04381882b71185786fa1c945677d2..14de05fcd431e76c87c4a7ffc2e65c4d1e1252a4 100644 (file)
@@ -75,8 +75,9 @@
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
 #include <linux/hwmon-sysfs.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
 
 /*
  * Addresses to scan
  */
 
 static unsigned short normal_i2c[] = { 0x4c, 0x4d, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /*
  * Insmod parameters
  */
 
-SENSORS_INSMOD_6(lm90, adm1032, lm99, lm86, max6657, adt7461);
+I2C_CLIENT_INSMOD_6(lm90, adm1032, lm99, lm86, max6657, adt7461);
 
 /*
  * The LM90 registers
@@ -200,6 +200,7 @@ static struct i2c_driver lm90_driver = {
 
 struct lm90_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore update_lock;
        char valid; /* zero until following fields are valid */
        unsigned long last_updated; /* in jiffies */
@@ -352,7 +353,7 @@ static int lm90_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, lm90_detect);
+       return i2c_probe(adapter, &addr_data, lm90_detect);
 }
 
 /*
@@ -500,6 +501,12 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
        lm90_init_client(new_client);
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        device_create_file(&new_client->dev,
                           &sensor_dev_attr_temp1_input.dev_attr);
        device_create_file(&new_client->dev,
@@ -524,6 +531,8 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
+exit_detach:
+       i2c_detach_client(new_client);
 exit_free:
        kfree(data);
 exit:
@@ -547,15 +556,15 @@ static void lm90_init_client(struct i2c_client *client)
 
 static int lm90_detach_client(struct i2c_client *client)
 {
+       struct lm90_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, "
-                       "client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
        return 0;
 }
 
index 215c8e40ffdd4041e114aa7912f93e9292b61be3..647b7c7cd575df129ed9ed7bbb7535e2d1422232 100644 (file)
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
-
+#include <linux/hwmon.h>
+#include <linux/err.h>
 
 /* The LM92 and MAX6635 have 2 two-state pins for address selection,
    resulting in 4 possible addresses. */
 static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b,
                                       I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
-SENSORS_INSMOD_1(lm92);
+I2C_CLIENT_INSMOD_1(lm92);
 
 /* The LM92 registers */
 #define LM92_REG_CONFIG                        0x01 /* 8-bit, RW */
@@ -96,6 +95,7 @@ static struct i2c_driver lm92_driver;
 /* Client data (each client gets its own) */
 struct lm92_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore update_lock;
        char valid; /* zero until following fields are valid */
        unsigned long last_updated; /* in jiffies */
@@ -359,6 +359,12 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind)
        lm92_init_client(new_client);
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        device_create_file(&new_client->dev, &dev_attr_temp1_input);
        device_create_file(&new_client->dev, &dev_attr_temp1_crit);
        device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst);
@@ -370,6 +376,8 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
+exit_detach:
+       i2c_detach_client(new_client);
 exit_free:
        kfree(data);
 exit:
@@ -380,20 +388,20 @@ static int lm92_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, lm92_detect);
+       return i2c_probe(adapter, &addr_data, lm92_detect);
 }
 
 static int lm92_detach_client(struct i2c_client *client)
 {
+       struct lm92_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, "
-                       "client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
        return 0;
 }
 
index 3c159f1d49ee3e6e0bf6b8acd5ccbfa8093ec938..16bf71f3a04d941f92391e64f8a6980b2e903315 100644 (file)
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
-
+#include <linux/hwmon.h>
+#include <linux/err.h>
 
 static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a,
                                        0x29, 0x2a, 0x2b,
                                        0x4c, 0x4d, 0x4e,
                                        I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /*
  * Insmod parameters
  */
 
-SENSORS_INSMOD_1(max1619);
+I2C_CLIENT_INSMOD_1(max1619);
 
 /*
  * The MAX1619 registers
@@ -104,6 +103,7 @@ static struct i2c_driver max1619_driver = {
 
 struct max1619_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore update_lock;
        char valid; /* zero until following fields are valid */
        unsigned long last_updated; /* in jiffies */
@@ -179,7 +179,7 @@ static int max1619_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, max1619_detect);
+       return i2c_probe(adapter, &addr_data, max1619_detect);
 }
 
 /*
@@ -275,6 +275,12 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind)
        max1619_init_client(new_client);
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        device_create_file(&new_client->dev, &dev_attr_temp1_input);
        device_create_file(&new_client->dev, &dev_attr_temp2_input);
        device_create_file(&new_client->dev, &dev_attr_temp2_min);
@@ -285,6 +291,8 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
+exit_detach:
+       i2c_detach_client(new_client);
 exit_free:
        kfree(data);
 exit:
@@ -308,15 +316,15 @@ static void max1619_init_client(struct i2c_client *client)
 
 static int max1619_detach_client(struct i2c_client *client)
 {
+       struct max1619_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, "
-                       "client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
        return 0;
 }
 
index fa4032d53b790b3e08dd6fdf6d730e4258ae05e5..cf2a35799c7ce5939744ba91adf5b23a24a9289e 100644 (file)
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
-#include <linux/i2c-vid.h>
+#include <linux/i2c-isa.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-sysfs.h>
+#include <linux/hwmon-vid.h>
+#include <linux/err.h>
 #include <asm/io.h>
 
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END };
-static struct i2c_force_data forces[] = {{ NULL }};
 static u8 devid;
-static unsigned int extra_isa[3];
+static unsigned short address;
+static unsigned short extra_isa[3];
 static u8 confreg[4];
 
 enum chips { any_chip, pc87360, pc87363, pc87364, pc87365, pc87366 };
-static struct i2c_address_data addr_data = {
-       .normal_i2c             = normal_i2c,
-       .normal_isa             = normal_isa,
-       .forces                 = forces,
-};
 
 static int init = 1;
 module_param(init, int, 0);
@@ -186,6 +182,7 @@ static inline u8 PWM_TO_REG(int val, int inv)
 
 struct pc87360_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore lock;
        struct semaphore update_lock;
        char valid;             /* !=0 if following fields are valid */
@@ -224,8 +221,7 @@ struct pc87360_data {
  * Functions declaration
  */
 
-static int pc87360_attach_adapter(struct i2c_adapter *adapter);
-static int pc87360_detect(struct i2c_adapter *adapter, int address, int kind);
+static int pc87360_detect(struct i2c_adapter *adapter);
 static int pc87360_detach_client(struct i2c_client *client);
 
 static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank,
@@ -242,8 +238,7 @@ static struct pc87360_data *pc87360_update_device(struct device *dev);
 static struct i2c_driver pc87360_driver = {
        .owner          = THIS_MODULE,
        .name           = "pc87360",
-       .flags          = I2C_DF_NOTIFY,
-       .attach_adapter = pc87360_attach_adapter,
+       .attach_adapter = pc87360_detect,
        .detach_client  = pc87360_detach_client,
 };
 
@@ -251,168 +246,178 @@ static struct i2c_driver pc87360_driver = {
  * Sysfs stuff
  */
 
-static ssize_t set_fan_min(struct device *dev, const char *buf,
-       size_t count, int nr)
+static ssize_t show_fan_input(struct device *dev, struct device_attribute *devattr, char *buf)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct pc87360_data *data = pc87360_update_device(dev);
+       return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan[attr->index],
+                      FAN_DIV_FROM_REG(data->fan_status[attr->index])));
+}
+static ssize_t show_fan_min(struct device *dev, struct device_attribute *devattr, char *buf)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct pc87360_data *data = pc87360_update_device(dev);
+       return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan_min[attr->index],
+                      FAN_DIV_FROM_REG(data->fan_status[attr->index])));
+}
+static ssize_t show_fan_div(struct device *dev, struct device_attribute *devattr, char *buf)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct pc87360_data *data = pc87360_update_device(dev);
+       return sprintf(buf, "%u\n",
+                      FAN_DIV_FROM_REG(data->fan_status[attr->index]));
+}
+static ssize_t show_fan_status(struct device *dev, struct device_attribute *devattr, char *buf)
 {
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct pc87360_data *data = pc87360_update_device(dev);
+       return sprintf(buf, "%u\n",
+                      FAN_STATUS_FROM_REG(data->fan_status[attr->index]));
+}
+static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr, const char *buf,
+       size_t count)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
        struct i2c_client *client = to_i2c_client(dev);
        struct pc87360_data *data = i2c_get_clientdata(client);
        long fan_min = simple_strtol(buf, NULL, 10);
 
        down(&data->update_lock);
-       fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[nr]));
+       fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[attr->index]));
 
        /* If it wouldn't fit, change clock divisor */
        while (fan_min > 255
-           && (data->fan_status[nr] & 0x60) != 0x60) {
+           && (data->fan_status[attr->index] & 0x60) != 0x60) {
                fan_min >>= 1;
-               data->fan[nr] >>= 1;
-               data->fan_status[nr] += 0x20;
+               data->fan[attr->index] >>= 1;
+               data->fan_status[attr->index] += 0x20;
        }
-       data->fan_min[nr] = fan_min > 255 ? 255 : fan_min;
-       pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_MIN(nr),
-                           data->fan_min[nr]);
+       data->fan_min[attr->index] = fan_min > 255 ? 255 : fan_min;
+       pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_MIN(attr->index),
+                           data->fan_min[attr->index]);
 
        /* Write new divider, preserve alarm bits */
-       pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(nr),
-                           data->fan_status[nr] & 0xF9);
+       pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(attr->index),
+                           data->fan_status[attr->index] & 0xF9);
        up(&data->update_lock);
 
        return count;
 }
 
 #define show_and_set_fan(offset) \
-static ssize_t show_fan##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \
-{ \
-       struct pc87360_data *data = pc87360_update_device(dev); \
-       return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan[offset-1], \
-                      FAN_DIV_FROM_REG(data->fan_status[offset-1]))); \
-} \
-static ssize_t show_fan##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \
-{ \
-       struct pc87360_data *data = pc87360_update_device(dev); \
-       return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan_min[offset-1], \
-                      FAN_DIV_FROM_REG(data->fan_status[offset-1]))); \
-} \
-static ssize_t show_fan##offset##_div(struct device *dev, struct device_attribute *attr, char *buf) \
-{ \
-       struct pc87360_data *data = pc87360_update_device(dev); \
-       return sprintf(buf, "%u\n", \
-                      FAN_DIV_FROM_REG(data->fan_status[offset-1])); \
-} \
-static ssize_t show_fan##offset##_status(struct device *dev, struct device_attribute *attr, char *buf) \
-{ \
-       struct pc87360_data *data = pc87360_update_device(dev); \
-       return sprintf(buf, "%u\n", \
-                      FAN_STATUS_FROM_REG(data->fan_status[offset-1])); \
-} \
-static ssize_t set_fan##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \
-       size_t count) \
-{ \
-       return set_fan_min(dev, buf, count, offset-1); \
-} \
-static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
-       show_fan##offset##_input, NULL); \
-static DEVICE_ATTR(fan##offset##_min, S_IWUSR | S_IRUGO, \
-       show_fan##offset##_min, set_fan##offset##_min); \
-static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \
-       show_fan##offset##_div, NULL); \
-static DEVICE_ATTR(fan##offset##_status, S_IRUGO, \
-       show_fan##offset##_status, NULL);
+static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
+       show_fan_input, NULL, offset-1); \
+static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IWUSR | S_IRUGO, \
+       show_fan_min, set_fan_min, offset-1); \
+static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO, \
+       show_fan_div, NULL, offset-1); \
+static SENSOR_DEVICE_ATTR(fan##offset##_status, S_IRUGO, \
+       show_fan_status, NULL, offset-1);
 show_and_set_fan(1)
 show_and_set_fan(2)
 show_and_set_fan(3)
 
+static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct pc87360_data *data = pc87360_update_device(dev);
+       return sprintf(buf, "%u\n",
+                      PWM_FROM_REG(data->pwm[attr->index],
+                                   FAN_CONFIG_INVERT(data->fan_conf,
+                                                     attr->index)));
+}
+static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, const char *buf,
+       size_t count)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct i2c_client *client = to_i2c_client(dev);
+       struct pc87360_data *data = i2c_get_clientdata(client);
+       long val = simple_strtol(buf, NULL, 10);
+
+       down(&data->update_lock);
+       data->pwm[attr->index] = PWM_TO_REG(val,
+                             FAN_CONFIG_INVERT(data->fan_conf, attr->index));
+       pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(attr->index),
+                           data->pwm[attr->index]);
+       up(&data->update_lock);
+       return count;
+}
+
 #define show_and_set_pwm(offset) \
-static ssize_t show_pwm##offset(struct device *dev, struct device_attribute *attr, char *buf) \
-{ \
-       struct pc87360_data *data = pc87360_update_device(dev); \
-       return sprintf(buf, "%u\n", \
-                      PWM_FROM_REG(data->pwm[offset-1], \
-                                   FAN_CONFIG_INVERT(data->fan_conf, \
-                                                     offset-1))); \
-} \
-static ssize_t set_pwm##offset(struct device *dev, struct device_attribute *attr, const char *buf, \
-       size_t count) \
-{ \
-       struct i2c_client *client = to_i2c_client(dev); \
-       struct pc87360_data *data = i2c_get_clientdata(client); \
-       long val = simple_strtol(buf, NULL, 10); \
- \
-       down(&data->update_lock); \
-       data->pwm[offset-1] = PWM_TO_REG(val, \
-                             FAN_CONFIG_INVERT(data->fan_conf, offset-1)); \
-       pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(offset-1), \
-                           data->pwm[offset-1]); \
-       up(&data->update_lock); \
-       return count; \
-} \
-static DEVICE_ATTR(pwm##offset, S_IWUSR | S_IRUGO, \
-       show_pwm##offset, set_pwm##offset);
+static SENSOR_DEVICE_ATTR(pwm##offset, S_IWUSR | S_IRUGO, \
+       show_pwm, set_pwm, offset-1);
 show_and_set_pwm(1)
 show_and_set_pwm(2)
 show_and_set_pwm(3)
 
+static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct pc87360_data *data = pc87360_update_device(dev);
+       return sprintf(buf, "%u\n", IN_FROM_REG(data->in[attr->index],
+                      data->in_vref));
+}
+static ssize_t show_in_min(struct device *dev, struct device_attribute *devattr, char *buf)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct pc87360_data *data = pc87360_update_device(dev);
+       return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[attr->index],
+                      data->in_vref));
+}
+static ssize_t show_in_max(struct device *dev, struct device_attribute *devattr, char *buf)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct pc87360_data *data = pc87360_update_device(dev);
+       return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[attr->index],
+                      data->in_vref));
+}
+static ssize_t show_in_status(struct device *dev, struct device_attribute *devattr, char *buf)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct pc87360_data *data = pc87360_update_device(dev);
+       return sprintf(buf, "%u\n", data->in_status[attr->index]);
+}
+static ssize_t set_in_min(struct device *dev, struct device_attribute *devattr, const char *buf,
+       size_t count)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct i2c_client *client = to_i2c_client(dev);
+       struct pc87360_data *data = i2c_get_clientdata(client);
+       long val = simple_strtol(buf, NULL, 10);
+
+       down(&data->update_lock);
+       data->in_min[attr->index] = IN_TO_REG(val, data->in_vref);
+       pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MIN,
+                           data->in_min[attr->index]);
+       up(&data->update_lock);
+       return count;
+}
+static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, const char *buf,
+       size_t count)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct i2c_client *client = to_i2c_client(dev);
+       struct pc87360_data *data = i2c_get_clientdata(client);
+       long val = simple_strtol(buf, NULL, 10);
+
+       down(&data->update_lock);
+       data->in_max[attr->index] = IN_TO_REG(val,
+                              data->in_vref);
+       pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MAX,
+                           data->in_max[attr->index]);
+       up(&data->update_lock);
+       return count;
+}
+
 #define show_and_set_in(offset) \
-static ssize_t show_in##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \
-{ \
-       struct pc87360_data *data = pc87360_update_device(dev); \
-       return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset], \
-                      data->in_vref)); \
-} \
-static ssize_t show_in##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \
-{ \
-       struct pc87360_data *data = pc87360_update_device(dev); \
-       return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset], \
-                      data->in_vref)); \
-} \
-static ssize_t show_in##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \
-{ \
-       struct pc87360_data *data = pc87360_update_device(dev); \
-       return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset], \
-                      data->in_vref)); \
-} \
-static ssize_t show_in##offset##_status(struct device *dev, struct device_attribute *attr, char *buf) \
-{ \
-       struct pc87360_data *data = pc87360_update_device(dev); \
-       return sprintf(buf, "%u\n", data->in_status[offset]); \
-} \
-static ssize_t set_in##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \
-       size_t count) \
-{ \
-       struct i2c_client *client = to_i2c_client(dev); \
-       struct pc87360_data *data = i2c_get_clientdata(client); \
-       long val = simple_strtol(buf, NULL, 10); \
- \
-       down(&data->update_lock); \
-       data->in_min[offset] = IN_TO_REG(val, data->in_vref); \
-       pc87360_write_value(data, LD_IN, offset, PC87365_REG_IN_MIN, \
-                           data->in_min[offset]); \
-       up(&data->update_lock); \
-       return count; \
-} \
-static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
-       size_t count) \
-{ \
-       struct i2c_client *client = to_i2c_client(dev); \
-       struct pc87360_data *data = i2c_get_clientdata(client); \
-       long val = simple_strtol(buf, NULL, 10); \
- \
-       down(&data->update_lock); \
-       data->in_max[offset] = IN_TO_REG(val, \
-                              data->in_vref); \
-       pc87360_write_value(data, LD_IN, offset, PC87365_REG_IN_MAX, \
-                           data->in_max[offset]); \
-       up(&data->update_lock); \
-       return count; \
-} \
-static DEVICE_ATTR(in##offset##_input, S_IRUGO, \
-       show_in##offset##_input, NULL); \
-static DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \
-       show_in##offset##_min, set_in##offset##_min); \
-static DEVICE_ATTR(in##offset##_max, S_IWUSR | S_IRUGO, \
-       show_in##offset##_max, set_in##offset##_max); \
-static DEVICE_ATTR(in##offset##_status, S_IRUGO, \
-       show_in##offset##_status, NULL);
+static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \
+       show_in_input, NULL, offset); \
+static SENSOR_DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \
+       show_in_min, set_in_min, offset); \
+static SENSOR_DEVICE_ATTR(in##offset##_max, S_IWUSR | S_IRUGO, \
+       show_in_max, set_in_max, offset); \
+static SENSOR_DEVICE_ATTR(in##offset##_status, S_IRUGO, \
+       show_in_status, NULL, offset);
 show_and_set_in(0)
 show_and_set_in(1)
 show_and_set_in(2)
@@ -425,88 +430,97 @@ show_and_set_in(8)
 show_and_set_in(9)
 show_and_set_in(10)
 
+static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct pc87360_data *data = pc87360_update_device(dev);
+       return sprintf(buf, "%u\n", IN_FROM_REG(data->in[attr->index],
+                      data->in_vref));
+}
+static ssize_t show_therm_min(struct device *dev, struct device_attribute *devattr, char *buf)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct pc87360_data *data = pc87360_update_device(dev);
+       return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[attr->index],
+                      data->in_vref));
+}
+static ssize_t show_therm_max(struct device *dev, struct device_attribute *devattr, char *buf)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct pc87360_data *data = pc87360_update_device(dev);
+       return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[attr->index],
+                      data->in_vref));
+}
+static ssize_t show_therm_crit(struct device *dev, struct device_attribute *devattr, char *buf)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct pc87360_data *data = pc87360_update_device(dev);
+       return sprintf(buf, "%u\n", IN_FROM_REG(data->in_crit[attr->index-11],
+                      data->in_vref));
+}
+static ssize_t show_therm_status(struct device *dev, struct device_attribute *devattr, char *buf)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct pc87360_data *data = pc87360_update_device(dev);
+       return sprintf(buf, "%u\n", data->in_status[attr->index]);
+}
+static ssize_t set_therm_min(struct device *dev, struct device_attribute *devattr, const char *buf,
+       size_t count)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct i2c_client *client = to_i2c_client(dev);
+       struct pc87360_data *data = i2c_get_clientdata(client);
+       long val = simple_strtol(buf, NULL, 10);
+
+       down(&data->update_lock);
+       data->in_min[attr->index] = IN_TO_REG(val, data->in_vref);
+       pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MIN,
+                           data->in_min[attr->index]);
+       up(&data->update_lock);
+       return count;
+}
+static ssize_t set_therm_max(struct device *dev, struct device_attribute *devattr, const char *buf,
+       size_t count)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct i2c_client *client = to_i2c_client(dev);
+       struct pc87360_data *data = i2c_get_clientdata(client);
+       long val = simple_strtol(buf, NULL, 10);
+
+       down(&data->update_lock);
+       data->in_max[attr->index] = IN_TO_REG(val, data->in_vref);
+       pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MAX,
+                           data->in_max[attr->index]);
+       up(&data->update_lock);
+       return count;
+}
+static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devattr, const char *buf,
+       size_t count)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct i2c_client *client = to_i2c_client(dev);
+       struct pc87360_data *data = i2c_get_clientdata(client);
+       long val = simple_strtol(buf, NULL, 10);
+
+       down(&data->update_lock);
+       data->in_crit[attr->index-11] = IN_TO_REG(val, data->in_vref);
+       pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_CRIT,
+                           data->in_crit[attr->index-11]);
+       up(&data->update_lock);
+       return count;
+}
+
 #define show_and_set_therm(offset) \
-static ssize_t show_temp##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \
-{ \
-       struct pc87360_data *data = pc87360_update_device(dev); \
-       return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset+7], \
-                      data->in_vref)); \
-} \
-static ssize_t show_temp##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \
-{ \
-       struct pc87360_data *data = pc87360_update_device(dev); \
-       return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset+7], \
-                      data->in_vref)); \
-} \
-static ssize_t show_temp##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \
-{ \
-       struct pc87360_data *data = pc87360_update_device(dev); \
-       return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset+7], \
-                      data->in_vref)); \
-} \
-static ssize_t show_temp##offset##_crit(struct device *dev, struct device_attribute *attr, char *buf) \
-{ \
-       struct pc87360_data *data = pc87360_update_device(dev); \
-       return sprintf(buf, "%u\n", IN_FROM_REG(data->in_crit[offset-4], \
-                      data->in_vref)); \
-} \
-static ssize_t show_temp##offset##_status(struct device *dev, struct device_attribute *attr, char *buf) \
-{ \
-       struct pc87360_data *data = pc87360_update_device(dev); \
-       return sprintf(buf, "%u\n", data->in_status[offset+7]); \
-} \
-static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \
-       size_t count) \
-{ \
-       struct i2c_client *client = to_i2c_client(dev); \
-       struct pc87360_data *data = i2c_get_clientdata(client); \
-       long val = simple_strtol(buf, NULL, 10); \
- \
-       down(&data->update_lock); \
-       data->in_min[offset+7] = IN_TO_REG(val, data->in_vref); \
-       pc87360_write_value(data, LD_IN, offset+7, PC87365_REG_TEMP_MIN, \
-                           data->in_min[offset+7]); \
-       up(&data->update_lock); \
-       return count; \
-} \
-static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
-       size_t count) \
-{ \
-       struct i2c_client *client = to_i2c_client(dev); \
-       struct pc87360_data *data = i2c_get_clientdata(client); \
-       long val = simple_strtol(buf, NULL, 10); \
- \
-       down(&data->update_lock); \
-       data->in_max[offset+7] = IN_TO_REG(val, data->in_vref); \
-       pc87360_write_value(data, LD_IN, offset+7, PC87365_REG_TEMP_MAX, \
-                           data->in_max[offset+7]); \
-       up(&data->update_lock); \
-       return count; \
-} \
-static ssize_t set_temp##offset##_crit(struct device *dev, struct device_attribute *attr, const char *buf, \
-       size_t count) \
-{ \
-       struct i2c_client *client = to_i2c_client(dev); \
-       struct pc87360_data *data = i2c_get_clientdata(client); \
-       long val = simple_strtol(buf, NULL, 10); \
- \
-       down(&data->update_lock); \
-       data->in_crit[offset-4] = IN_TO_REG(val, data->in_vref); \
-       pc87360_write_value(data, LD_IN, offset+7, PC87365_REG_TEMP_CRIT, \
-                           data->in_crit[offset-4]); \
-       up(&data->update_lock); \
-       return count; \
-} \
-static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
-       show_temp##offset##_input, NULL); \
-static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
-       show_temp##offset##_min, set_temp##offset##_min); \
-static DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \
-       show_temp##offset##_max, set_temp##offset##_max); \
-static DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \
-       show_temp##offset##_crit, set_temp##offset##_crit); \
-static DEVICE_ATTR(temp##offset##_status, S_IRUGO, \
-       show_temp##offset##_status, NULL);
+static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
+       show_therm_input, NULL, 11+offset-4); \
+static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
+       show_therm_min, set_therm_min, 11+offset-4); \
+static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \
+       show_therm_max, set_therm_max, 11+offset-4); \
+static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \
+       show_therm_crit, set_therm_crit, 11+offset-4); \
+static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \
+       show_therm_status, NULL, 11+offset-4);
 show_and_set_therm(4)
 show_and_set_therm(5)
 show_and_set_therm(6)
@@ -539,84 +553,93 @@ static ssize_t show_in_alarms(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR(alarms_in, S_IRUGO, show_in_alarms, NULL);
 
+static ssize_t show_temp_input(struct device *dev, struct device_attribute *devattr, char *buf)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct pc87360_data *data = pc87360_update_device(dev);
+       return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index]));
+}
+static ssize_t show_temp_min(struct device *dev, struct device_attribute *devattr, char *buf)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct pc87360_data *data = pc87360_update_device(dev);
+       return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[attr->index]));
+}
+static ssize_t show_temp_max(struct device *dev, struct device_attribute *devattr, char *buf)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct pc87360_data *data = pc87360_update_device(dev);
+       return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[attr->index]));
+}
+static ssize_t show_temp_crit(struct device *dev, struct device_attribute *devattr, char *buf)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct pc87360_data *data = pc87360_update_device(dev);
+       return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[attr->index]));
+}
+static ssize_t show_temp_status(struct device *dev, struct device_attribute *devattr, char *buf)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct pc87360_data *data = pc87360_update_device(dev);
+       return sprintf(buf, "%d\n", data->temp_status[attr->index]);
+}
+static ssize_t set_temp_min(struct device *dev, struct device_attribute *devattr, const char *buf,
+       size_t count)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct i2c_client *client = to_i2c_client(dev);
+       struct pc87360_data *data = i2c_get_clientdata(client);
+       long val = simple_strtol(buf, NULL, 10);
+
+       down(&data->update_lock);
+       data->temp_min[attr->index] = TEMP_TO_REG(val);
+       pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MIN,
+                           data->temp_min[attr->index]);
+       up(&data->update_lock);
+       return count;
+}
+static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr, const char *buf,
+       size_t count)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct i2c_client *client = to_i2c_client(dev);
+       struct pc87360_data *data = i2c_get_clientdata(client);
+       long val = simple_strtol(buf, NULL, 10);
+
+       down(&data->update_lock);
+       data->temp_max[attr->index] = TEMP_TO_REG(val);
+       pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MAX,
+                           data->temp_max[attr->index]);
+       up(&data->update_lock);
+       return count;
+}
+static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devattr, const char *buf,
+       size_t count)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct i2c_client *client = to_i2c_client(dev);
+       struct pc87360_data *data = i2c_get_clientdata(client);
+       long val = simple_strtol(buf, NULL, 10);
+
+       down(&data->update_lock);
+       data->temp_crit[attr->index] = TEMP_TO_REG(val);
+       pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_CRIT,
+                           data->temp_crit[attr->index]);
+       up(&data->update_lock);
+       return count;
+}
+
 #define show_and_set_temp(offset) \
-static ssize_t show_temp##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \
-{ \
-       struct pc87360_data *data = pc87360_update_device(dev); \
-       return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[offset-1])); \
-} \
-static ssize_t show_temp##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \
-{ \
-       struct pc87360_data *data = pc87360_update_device(dev); \
-       return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[offset-1])); \
-} \
-static ssize_t show_temp##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \
-{ \
-       struct pc87360_data *data = pc87360_update_device(dev); \
-       return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[offset-1])); \
-}\
-static ssize_t show_temp##offset##_crit(struct device *dev, struct device_attribute *attr, char *buf) \
-{ \
-       struct pc87360_data *data = pc87360_update_device(dev); \
-       return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[offset-1])); \
-}\
-static ssize_t show_temp##offset##_status(struct device *dev, struct device_attribute *attr, char *buf) \
-{ \
-       struct pc87360_data *data = pc87360_update_device(dev); \
-       return sprintf(buf, "%d\n", data->temp_status[offset-1]); \
-}\
-static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \
-       size_t count) \
-{ \
-       struct i2c_client *client = to_i2c_client(dev); \
-       struct pc87360_data *data = i2c_get_clientdata(client); \
-       long val = simple_strtol(buf, NULL, 10); \
- \
-       down(&data->update_lock); \
-       data->temp_min[offset-1] = TEMP_TO_REG(val); \
-       pc87360_write_value(data, LD_TEMP, offset-1, PC87365_REG_TEMP_MIN, \
-                           data->temp_min[offset-1]); \
-       up(&data->update_lock); \
-       return count; \
-} \
-static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
-       size_t count) \
-{ \
-       struct i2c_client *client = to_i2c_client(dev); \
-       struct pc87360_data *data = i2c_get_clientdata(client); \
-       long val = simple_strtol(buf, NULL, 10); \
- \
-       down(&data->update_lock); \
-       data->temp_max[offset-1] = TEMP_TO_REG(val); \
-       pc87360_write_value(data, LD_TEMP, offset-1, PC87365_REG_TEMP_MAX, \
-                           data->temp_max[offset-1]); \
-       up(&data->update_lock); \
-       return count; \
-} \
-static ssize_t set_temp##offset##_crit(struct device *dev, struct device_attribute *attr, const char *buf, \
-       size_t count) \
-{ \
-       struct i2c_client *client = to_i2c_client(dev); \
-       struct pc87360_data *data = i2c_get_clientdata(client); \
-       long val = simple_strtol(buf, NULL, 10); \
- \
-       down(&data->update_lock); \
-       data->temp_crit[offset-1] = TEMP_TO_REG(val); \
-       pc87360_write_value(data, LD_TEMP, offset-1, PC87365_REG_TEMP_CRIT, \
-                           data->temp_crit[offset-1]); \
-       up(&data->update_lock); \
-       return count; \
-} \
-static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
-       show_temp##offset##_input, NULL); \
-static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
-       show_temp##offset##_min, set_temp##offset##_min); \
-static DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \
-       show_temp##offset##_max, set_temp##offset##_max); \
-static DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \
-       show_temp##offset##_crit, set_temp##offset##_crit); \
-static DEVICE_ATTR(temp##offset##_status, S_IRUGO, \
-       show_temp##offset##_status, NULL);
+static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
+       show_temp_input, NULL, offset-1); \
+static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
+       show_temp_min, set_temp_min, offset-1); \
+static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \
+       show_temp_max, set_temp_max, offset-1); \
+static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \
+       show_temp_crit, set_temp_crit, offset-1); \
+static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \
+       show_temp_status, NULL, offset-1);
 show_and_set_temp(1)
 show_and_set_temp(2)
 show_and_set_temp(3)
@@ -632,12 +655,7 @@ static DEVICE_ATTR(alarms_temp, S_IRUGO, show_temp_alarms, NULL);
  * Device detection, registration and update
  */
 
-static int pc87360_attach_adapter(struct i2c_adapter *adapter)
-{
-       return i2c_detect(adapter, &addr_data, pc87360_detect);
-}
-
-static int pc87360_find(int sioaddr, u8 *devid, int *address)
+static int __init pc87360_find(int sioaddr, u8 *devid, unsigned short *addresses)
 {
        u16 val;
        int i;
@@ -683,7 +701,7 @@ static int pc87360_find(int sioaddr, u8 *devid, int *address)
                        continue;
                }
 
-               address[i] = val;
+               addresses[i] = val;
 
                if (i==0) { /* Fans */
                        confreg[0] = superio_inb(sioaddr, 0xF0);
@@ -727,9 +745,7 @@ static int pc87360_find(int sioaddr, u8 *devid, int *address)
        return 0;
 }
 
-/* We don't really care about the address.
-   Read from extra_isa instead. */
-int pc87360_detect(struct i2c_adapter *adapter, int address, int kind)
+static int pc87360_detect(struct i2c_adapter *adapter)
 {
        int i;
        struct i2c_client *new_client;
@@ -738,9 +754,6 @@ int pc87360_detect(struct i2c_adapter *adapter, int address, int kind)
        const char *name = "pc87360";
        int use_thermistors = 0;
 
-       if (!i2c_is_isa_adapter(adapter))
-               return -ENODEV;
-
        if (!(data = kmalloc(sizeof(struct pc87360_data), GFP_KERNEL)))
                return -ENOMEM;
        memset(data, 0x00, sizeof(struct pc87360_data));
@@ -838,51 +851,57 @@ int pc87360_detect(struct i2c_adapter *adapter, int address, int kind)
        }
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto ERROR3;
+       }
+
        if (data->innr) {
-               device_create_file(&new_client->dev, &dev_attr_in0_input);
-               device_create_file(&new_client->dev, &dev_attr_in1_input);
-               device_create_file(&new_client->dev, &dev_attr_in2_input);
-               device_create_file(&new_client->dev, &dev_attr_in3_input);
-               device_create_file(&new_client->dev, &dev_attr_in4_input);
-               device_create_file(&new_client->dev, &dev_attr_in5_input);
-               device_create_file(&new_client->dev, &dev_attr_in6_input);
-               device_create_file(&new_client->dev, &dev_attr_in7_input);
-               device_create_file(&new_client->dev, &dev_attr_in8_input);
-               device_create_file(&new_client->dev, &dev_attr_in9_input);
-               device_create_file(&new_client->dev, &dev_attr_in10_input);
-               device_create_file(&new_client->dev, &dev_attr_in0_min);
-               device_create_file(&new_client->dev, &dev_attr_in1_min);
-               device_create_file(&new_client->dev, &dev_attr_in2_min);
-               device_create_file(&new_client->dev, &dev_attr_in3_min);
-               device_create_file(&new_client->dev, &dev_attr_in4_min);
-               device_create_file(&new_client->dev, &dev_attr_in5_min);
-               device_create_file(&new_client->dev, &dev_attr_in6_min);
-               device_create_file(&new_client->dev, &dev_attr_in7_min);
-               device_create_file(&new_client->dev, &dev_attr_in8_min);
-               device_create_file(&new_client->dev, &dev_attr_in9_min);
-               device_create_file(&new_client->dev, &dev_attr_in10_min);
-               device_create_file(&new_client->dev, &dev_attr_in0_max);
-               device_create_file(&new_client->dev, &dev_attr_in1_max);
-               device_create_file(&new_client->dev, &dev_attr_in2_max);
-               device_create_file(&new_client->dev, &dev_attr_in3_max);
-               device_create_file(&new_client->dev, &dev_attr_in4_max);
-               device_create_file(&new_client->dev, &dev_attr_in5_max);
-               device_create_file(&new_client->dev, &dev_attr_in6_max);
-               device_create_file(&new_client->dev, &dev_attr_in7_max);
-               device_create_file(&new_client->dev, &dev_attr_in8_max);
-               device_create_file(&new_client->dev, &dev_attr_in9_max);
-               device_create_file(&new_client->dev, &dev_attr_in10_max);
-               device_create_file(&new_client->dev, &dev_attr_in0_status);
-               device_create_file(&new_client->dev, &dev_attr_in1_status);
-               device_create_file(&new_client->dev, &dev_attr_in2_status);
-               device_create_file(&new_client->dev, &dev_attr_in3_status);
-               device_create_file(&new_client->dev, &dev_attr_in4_status);
-               device_create_file(&new_client->dev, &dev_attr_in5_status);
-               device_create_file(&new_client->dev, &dev_attr_in6_status);
-               device_create_file(&new_client->dev, &dev_attr_in7_status);
-               device_create_file(&new_client->dev, &dev_attr_in8_status);
-               device_create_file(&new_client->dev, &dev_attr_in9_status);
-               device_create_file(&new_client->dev, &dev_attr_in10_status);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in9_input.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in10_input.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in1_min.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in2_min.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in3_min.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in4_min.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in5_min.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in6_min.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in7_min.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in8_min.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in9_min.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in10_min.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in1_max.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in2_max.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in3_max.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in4_max.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in5_max.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in6_max.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in7_max.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in8_max.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in9_max.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in10_max.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in0_status.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in1_status.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in2_status.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in3_status.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in4_status.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in5_status.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in6_status.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in7_status.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in8_status.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in9_status.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_in10_status.dev_attr);
 
                device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
                device_create_file(&new_client->dev, &dev_attr_vrm);
@@ -890,90 +909,92 @@ int pc87360_detect(struct i2c_adapter *adapter, int address, int kind)
        }
 
        if (data->tempnr) {
-               device_create_file(&new_client->dev, &dev_attr_temp1_input);
-               device_create_file(&new_client->dev, &dev_attr_temp2_input);
-               device_create_file(&new_client->dev, &dev_attr_temp1_min);
-               device_create_file(&new_client->dev, &dev_attr_temp2_min);
-               device_create_file(&new_client->dev, &dev_attr_temp1_max);
-               device_create_file(&new_client->dev, &dev_attr_temp2_max);
-               device_create_file(&new_client->dev, &dev_attr_temp1_crit);
-               device_create_file(&new_client->dev, &dev_attr_temp2_crit);
-               device_create_file(&new_client->dev, &dev_attr_temp1_status);
-               device_create_file(&new_client->dev, &dev_attr_temp2_status);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp1_crit.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp2_crit.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp1_status.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp2_status.dev_attr);
 
                device_create_file(&new_client->dev, &dev_attr_alarms_temp);
        }
        if (data->tempnr == 3) {
-               device_create_file(&new_client->dev, &dev_attr_temp3_input);
-               device_create_file(&new_client->dev, &dev_attr_temp3_min);
-               device_create_file(&new_client->dev, &dev_attr_temp3_max);
-               device_create_file(&new_client->dev, &dev_attr_temp3_crit);
-               device_create_file(&new_client->dev, &dev_attr_temp3_status);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp3_input.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp3_min.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp3_max.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp3_crit.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp3_status.dev_attr);
        }
        if (data->innr == 14) {
-               device_create_file(&new_client->dev, &dev_attr_temp4_input);
-               device_create_file(&new_client->dev, &dev_attr_temp5_input);
-               device_create_file(&new_client->dev, &dev_attr_temp6_input);
-               device_create_file(&new_client->dev, &dev_attr_temp4_min);
-               device_create_file(&new_client->dev, &dev_attr_temp5_min);
-               device_create_file(&new_client->dev, &dev_attr_temp6_min);
-               device_create_file(&new_client->dev, &dev_attr_temp4_max);
-               device_create_file(&new_client->dev, &dev_attr_temp5_max);
-               device_create_file(&new_client->dev, &dev_attr_temp6_max);
-               device_create_file(&new_client->dev, &dev_attr_temp4_crit);
-               device_create_file(&new_client->dev, &dev_attr_temp5_crit);
-               device_create_file(&new_client->dev, &dev_attr_temp6_crit);
-               device_create_file(&new_client->dev, &dev_attr_temp4_status);
-               device_create_file(&new_client->dev, &dev_attr_temp5_status);
-               device_create_file(&new_client->dev, &dev_attr_temp6_status);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp4_input.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp5_input.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp6_input.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp4_min.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp5_min.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp6_min.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp4_max.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp5_max.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp6_max.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp4_crit.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp5_crit.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp6_crit.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp4_status.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp5_status.dev_attr);
+               device_create_file(&new_client->dev, &sensor_dev_attr_temp6_status.dev_attr);
        }
 
        if (data->fannr) {
                if (FAN_CONFIG_MONITOR(data->fan_conf, 0)) {
                        device_create_file(&new_client->dev,
-                                          &dev_attr_fan1_input);
+                                          &sensor_dev_attr_fan1_input.dev_attr);
                        device_create_file(&new_client->dev,
-                                          &dev_attr_fan1_min);
+                                          &sensor_dev_attr_fan1_min.dev_attr);
                        device_create_file(&new_client->dev,
-                                          &dev_attr_fan1_div);
+                                          &sensor_dev_attr_fan1_div.dev_attr);
                        device_create_file(&new_client->dev,
-                                          &dev_attr_fan1_status);
+                                          &sensor_dev_attr_fan1_status.dev_attr);
                }
 
                if (FAN_CONFIG_MONITOR(data->fan_conf, 1)) {
                        device_create_file(&new_client->dev,
-                                          &dev_attr_fan2_input);
+                                          &sensor_dev_attr_fan2_input.dev_attr);
                        device_create_file(&new_client->dev,
-                                          &dev_attr_fan2_min);
+                                          &sensor_dev_attr_fan2_min.dev_attr);
                        device_create_file(&new_client->dev,
-                                          &dev_attr_fan2_div);
+                                          &sensor_dev_attr_fan2_div.dev_attr);
                        device_create_file(&new_client->dev,
-                                          &dev_attr_fan2_status);
+                                          &sensor_dev_attr_fan2_status.dev_attr);
                }
 
                if (FAN_CONFIG_CONTROL(data->fan_conf, 0))
-                       device_create_file(&new_client->dev, &dev_attr_pwm1);
+                       device_create_file(&new_client->dev, &sensor_dev_attr_pwm1.dev_attr);
                if (FAN_CONFIG_CONTROL(data->fan_conf, 1))
-                       device_create_file(&new_client->dev, &dev_attr_pwm2);
+                       device_create_file(&new_client->dev, &sensor_dev_attr_pwm2.dev_attr);
        }
        if (data->fannr == 3) {
                if (FAN_CONFIG_MONITOR(data->fan_conf, 2)) {
                        device_create_file(&new_client->dev,
-                                          &dev_attr_fan3_input);
+                                          &sensor_dev_attr_fan3_input.dev_attr);
                        device_create_file(&new_client->dev,
-                                          &dev_attr_fan3_min);
+                                          &sensor_dev_attr_fan3_min.dev_attr);
                        device_create_file(&new_client->dev,
-                                          &dev_attr_fan3_div);
+                                          &sensor_dev_attr_fan3_div.dev_attr);
                        device_create_file(&new_client->dev,
-                                          &dev_attr_fan3_status);
+                                          &sensor_dev_attr_fan3_status.dev_attr);
                }
 
                if (FAN_CONFIG_CONTROL(data->fan_conf, 2))
-                       device_create_file(&new_client->dev, &dev_attr_pwm3);
+                       device_create_file(&new_client->dev, &sensor_dev_attr_pwm3.dev_attr);
        }
 
        return 0;
 
+ERROR3:
+       i2c_detach_client(new_client);
 ERROR2:
        for (i = 0; i < 3; i++) {
                if (data->address[i]) {
@@ -990,11 +1011,10 @@ static int pc87360_detach_client(struct i2c_client *client)
        struct pc87360_data *data = i2c_get_clientdata(client);
        int i;
 
-       if ((i = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, "
-                       "client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((i = i2c_detach_client(client)))
                return i;
-       }
 
        for (i = 0; i < 3; i++) {
                if (data->address[i]) {
@@ -1320,23 +1340,23 @@ static int __init pc87360_init(void)
        /* Arbitrarily pick one of the addresses */
        for (i = 0; i < 3; i++) {
                if (extra_isa[i] != 0x0000) {
-                       normal_isa[0] = extra_isa[i];
+                       address = extra_isa[i];
                        break;
                }
        }
 
-       if (normal_isa[0] == 0x0000) {
+       if (address == 0x0000) {
                printk(KERN_WARNING "pc87360: No active logical device, "
                       "module not inserted.\n");
                return -ENODEV;
        }
 
-       return i2c_add_driver(&pc87360_driver);
+       return i2c_isa_add_driver(&pc87360_driver);
 }
 
 static void __exit pc87360_exit(void)
 {
-       i2c_del_driver(&pc87360_driver);
+       i2c_isa_del_driver(&pc87360_driver);
 }
 
 
index 6bbfc8fb4f13247d61cedb2124a74b5df4589620..8610bce08244d1bb3f74dcca18ef48112c717073 100644 (file)
@@ -55,7 +55,9 @@
 #include <linux/ioport.h>
 #include <linux/pci.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
+#include <linux/i2c-isa.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
 #include <linux/init.h>
 #include <linux/jiffies.h>
 #include <asm/io.h>
@@ -68,14 +70,10 @@ module_param(force_addr, ushort, 0);
 MODULE_PARM_DESC(force_addr,
                 "Initialize the base address of the sensors");
 
-/* Addresses to scan.
+/* Device address
    Note that we can't determine the ISA address until we have initialized
    our module */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END };
-
-/* Insmod parameters */
-SENSORS_INSMOD_1(sis5595);
+static unsigned short address;
 
 /* Many SIS5595 constants specified below */
 
@@ -168,6 +166,7 @@ static inline u8 DIV_TO_REG(int val)
    allocated. */
 struct sis5595_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore lock;
 
        struct semaphore update_lock;
@@ -190,8 +189,7 @@ struct sis5595_data {
 
 static struct pci_dev *s_bridge;       /* pointer to the (only) sis5595 */
 
-static int sis5595_attach_adapter(struct i2c_adapter *adapter);
-static int sis5595_detect(struct i2c_adapter *adapter, int address, int kind);
+static int sis5595_detect(struct i2c_adapter *adapter);
 static int sis5595_detach_client(struct i2c_client *client);
 
 static int sis5595_read_value(struct i2c_client *client, u8 register);
@@ -202,9 +200,7 @@ static void sis5595_init_client(struct i2c_client *client);
 static struct i2c_driver sis5595_driver = {
        .owner          = THIS_MODULE,
        .name           = "sis5595",
-       .id             = I2C_DRIVERID_SIS5595,
-       .flags          = I2C_DF_NOTIFY,
-       .attach_adapter = sis5595_attach_adapter,
+       .attach_adapter = sis5595_detect,
        .detach_client  = sis5595_detach_client,
 };
 
@@ -476,14 +472,7 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, ch
 static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
  
 /* This is called when the module is loaded */
-static int sis5595_attach_adapter(struct i2c_adapter *adapter)
-{
-       if (!(adapter->class & I2C_CLASS_HWMON))
-               return 0;
-       return i2c_detect(adapter, &addr_data, sis5595_detect);
-}
-
-int sis5595_detect(struct i2c_adapter *adapter, int address, int kind)
+static int sis5595_detect(struct i2c_adapter *adapter)
 {
        int err = 0;
        int i;
@@ -492,10 +481,6 @@ int sis5595_detect(struct i2c_adapter *adapter, int address, int kind)
        char val;
        u16 a;
 
-       /* Make sure we are probing the ISA bus!!  */
-       if (!i2c_is_isa_adapter(adapter))
-               goto exit;
-
        if (force_addr)
                address = force_addr & ~(SIS5595_EXTENT - 1);
        /* Reserve the ISA region */
@@ -578,6 +563,12 @@ int sis5595_detect(struct i2c_adapter *adapter, int address, int kind)
        }
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        device_create_file(&new_client->dev, &dev_attr_in0_input);
        device_create_file(&new_client->dev, &dev_attr_in0_min);
        device_create_file(&new_client->dev, &dev_attr_in0_max);
@@ -608,7 +599,9 @@ int sis5595_detect(struct i2c_adapter *adapter, int address, int kind)
                device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);
        }
        return 0;
-       
+
+exit_detach:
+       i2c_detach_client(new_client);
 exit_free:
        kfree(data);
 exit_release:
@@ -619,18 +612,17 @@ exit:
 
 static int sis5595_detach_client(struct i2c_client *client)
 {
+       struct sis5595_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev,
-                   "Client deregistration failed, client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
-       if (i2c_is_isa_client(client))
-               release_region(client->addr, SIS5595_EXTENT);
+       release_region(client->addr, SIS5595_EXTENT);
 
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
 
        return 0;
 }
@@ -745,7 +737,6 @@ static int __devinit sis5595_pci_probe(struct pci_dev *dev,
 {
        u16 val;
        int *i;
-       int addr = 0;
 
        for (i = blacklist; *i != 0; i++) {
                struct pci_dev *dev;
@@ -761,22 +752,19 @@ static int __devinit sis5595_pci_probe(struct pci_dev *dev,
            pci_read_config_word(dev, SIS5595_BASE_REG, &val))
                return -ENODEV;
        
-       addr = val & ~(SIS5595_EXTENT - 1);
-       if (addr == 0 && force_addr == 0) {
+       address = val & ~(SIS5595_EXTENT - 1);
+       if (address == 0 && force_addr == 0) {
                dev_err(&dev->dev, "Base address not set - upgrade BIOS or use force_addr=0xaddr\n");
                return -ENODEV;
        }
-       if (force_addr)
-               addr = force_addr;      /* so detect will get called */
 
-       if (!addr) {
+       if (!address) {
                dev_err(&dev->dev,"No SiS 5595 sensors found.\n");
                return -ENODEV;
        }
-       normal_isa[0] = addr;
 
        s_bridge = pci_dev_get(dev);
-       if (i2c_add_driver(&sis5595_driver)) {
+       if (i2c_isa_add_driver(&sis5595_driver)) {
                pci_dev_put(s_bridge);
                s_bridge = NULL;
        }
@@ -803,7 +791,7 @@ static void __exit sm_sis5595_exit(void)
 {
        pci_unregister_driver(&sis5595_pci_driver);
        if (s_bridge != NULL) {
-               i2c_del_driver(&sis5595_driver);
+               i2c_isa_del_driver(&sis5595_driver);
                pci_dev_put(s_bridge);
                s_bridge = NULL;
        }
index fdeeb3ab6f2f3e9146b607ddc00c5d3ffd239bed..7fe71576dea4b7416e6b15ae387e56dc6238da1d 100644 (file)
 #include <linux/ioport.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
+#include <linux/i2c-isa.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
 #include <linux/init.h>
 #include <asm/io.h>
 
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
 /* Address is autodetected, there is no default value */
-static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END };
-static struct i2c_force_data forces[] = {{NULL}};
-
-enum chips { any_chip, smsc47b397 };
-static struct i2c_address_data addr_data = {
-       .normal_i2c             = normal_i2c,
-       .normal_isa             = normal_isa,
-       .probe                  = normal_i2c,           /* cheat */
-       .ignore                 = normal_i2c,           /* cheat */
-       .forces                 = forces,
-};
+static unsigned short address;
 
 /* Super-I/0 registers and commands */
 
@@ -100,6 +91,7 @@ static u8 smsc47b397_reg_temp[] = {0x25, 0x26, 0x27, 0x80};
 
 struct smsc47b397_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore lock;
 
        struct semaphore update_lock;
@@ -215,52 +207,40 @@ sysfs_fan(4);
 #define device_create_file_fan(client, num) \
        device_create_file(&client->dev, &dev_attr_fan##num##_input)
 
-static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind);
-
-static int smsc47b397_attach_adapter(struct i2c_adapter *adapter)
-{
-       if (!(adapter->class & I2C_CLASS_HWMON))
-               return 0;
-       return i2c_detect(adapter, &addr_data, smsc47b397_detect);
-}
-
 static int smsc47b397_detach_client(struct i2c_client *client)
 {
+       struct smsc47b397_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, "
-                       "client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
        release_region(client->addr, SMSC_EXTENT);
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
 
        return 0;
 }
 
+static int smsc47b397_detect(struct i2c_adapter *adapter);
+
 static struct i2c_driver smsc47b397_driver = {
        .owner          = THIS_MODULE,
        .name           = "smsc47b397",
-       .id             = I2C_DRIVERID_SMSC47B397,
-       .flags          = I2C_DF_NOTIFY,
-       .attach_adapter = smsc47b397_attach_adapter,
+       .attach_adapter = smsc47b397_detect,
        .detach_client  = smsc47b397_detach_client,
 };
 
-static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind)
+static int smsc47b397_detect(struct i2c_adapter *adapter)
 {
        struct i2c_client *new_client;
        struct smsc47b397_data *data;
        int err = 0;
 
-       if (!i2c_is_isa_adapter(adapter)) {
-               return 0;
-       }
-
-       if (!request_region(addr, SMSC_EXTENT, smsc47b397_driver.name)) {
-               dev_err(&adapter->dev, "Region 0x%x already in use!\n", addr);
+       if (!request_region(address, SMSC_EXTENT, smsc47b397_driver.name)) {
+               dev_err(&adapter->dev, "Region 0x%x already in use!\n",
+                       address);
                return -EBUSY;
        }
 
@@ -272,7 +252,7 @@ static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind)
 
        new_client = &data->client;
        i2c_set_clientdata(new_client, data);
-       new_client->addr = addr;
+       new_client->addr = address;
        init_MUTEX(&data->lock);
        new_client->adapter = adapter;
        new_client->driver = &smsc47b397_driver;
@@ -285,6 +265,12 @@ static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind)
        if ((err = i2c_attach_client(new_client)))
                goto error_free;
 
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto error_detach;
+       }
+
        device_create_file_temp(new_client, 1);
        device_create_file_temp(new_client, 2);
        device_create_file_temp(new_client, 3);
@@ -297,14 +283,16 @@ static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind)
 
        return 0;
 
+error_detach:
+       i2c_detach_client(new_client);
 error_free:
        kfree(data);
 error_release:
-       release_region(addr, SMSC_EXTENT);
+       release_region(address, SMSC_EXTENT);
        return err;
 }
 
-static int __init smsc47b397_find(unsigned int *addr)
+static int __init smsc47b397_find(unsigned short *addr)
 {
        u8 id, rev;
 
@@ -333,15 +321,15 @@ static int __init smsc47b397_init(void)
 {
        int ret;
 
-       if ((ret = smsc47b397_find(normal_isa)))
+       if ((ret = smsc47b397_find(&address)))
                return ret;
 
-       return i2c_add_driver(&smsc47b397_driver);
+       return i2c_isa_add_driver(&smsc47b397_driver);
 }
 
 static void __exit smsc47b397_exit(void)
 {
-       i2c_del_driver(&smsc47b397_driver);
+       i2c_isa_del_driver(&smsc47b397_driver);
 }
 
 MODULE_AUTHOR("Mark M. Hoffman <mhoffman@lightlink.com>");
index 7166ad0b2fda666e5ace936c0b3960de9bbdd7b0..7e699a8ede262916369a88c57001f6de86eafbad 100644 (file)
 #include <linux/ioport.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
+#include <linux/i2c-isa.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
 #include <linux/init.h>
 #include <asm/io.h>
 
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
 /* Address is autodetected, there is no default value */
-static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END };
-static struct i2c_force_data forces[] = {{NULL}};
-
-enum chips { any_chip, smsc47m1 };
-static struct i2c_address_data addr_data = {
-       .normal_i2c             = normal_i2c,
-       .normal_isa             = normal_isa,
-       .forces                 = forces,
-};
+static unsigned short address;
 
 /* Super-I/0 registers and commands */
 
@@ -108,6 +101,7 @@ superio_exit(void)
 
 struct smsc47m1_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore lock;
 
        struct semaphore update_lock;
@@ -121,9 +115,7 @@ struct smsc47m1_data {
 };
 
 
-static int smsc47m1_attach_adapter(struct i2c_adapter *adapter);
-static int smsc47m1_find(int *address);
-static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind);
+static int smsc47m1_detect(struct i2c_adapter *adapter);
 static int smsc47m1_detach_client(struct i2c_client *client);
 
 static int smsc47m1_read_value(struct i2c_client *client, u8 reg);
@@ -136,9 +128,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
 static struct i2c_driver smsc47m1_driver = {
        .owner          = THIS_MODULE,
        .name           = "smsc47m1",
-       .id             = I2C_DRIVERID_SMSC47M1,
-       .flags          = I2C_DF_NOTIFY,
-       .attach_adapter = smsc47m1_attach_adapter,
+       .attach_adapter = smsc47m1_detect,
        .detach_client  = smsc47m1_detach_client,
 };
 
@@ -354,14 +344,7 @@ fan_present(2);
 
 static DEVICE_ATTR(alarms, S_IRUGO, get_alarms, NULL);
 
-static int smsc47m1_attach_adapter(struct i2c_adapter *adapter)
-{
-       if (!(adapter->class & I2C_CLASS_HWMON))
-               return 0;
-       return i2c_detect(adapter, &addr_data, smsc47m1_detect);
-}
-
-static int smsc47m1_find(int *address)
+static int __init smsc47m1_find(unsigned short *addr)
 {
        u8 val;
 
@@ -388,10 +371,10 @@ static int smsc47m1_find(int *address)
        }
 
        superio_select();
-       *address = (superio_inb(SUPERIO_REG_BASE) << 8)
-                |  superio_inb(SUPERIO_REG_BASE + 1);
+       *addr = (superio_inb(SUPERIO_REG_BASE) << 8)
+             |  superio_inb(SUPERIO_REG_BASE + 1);
        val = superio_inb(SUPERIO_REG_ACT);
-       if (*address == 0 || (val & 0x01) == 0) {
+       if (*addr == 0 || (val & 0x01) == 0) {
                printk(KERN_INFO "smsc47m1: Device is disabled, will not use\n");
                superio_exit();
                return -ENODEV;
@@ -401,17 +384,13 @@ static int smsc47m1_find(int *address)
        return 0;
 }
 
-static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind)
+static int smsc47m1_detect(struct i2c_adapter *adapter)
 {
        struct i2c_client *new_client;
        struct smsc47m1_data *data;
        int err = 0;
        int fan1, fan2, pwm1, pwm2;
 
-       if (!i2c_is_isa_adapter(adapter)) {
-               return 0;
-       }
-
        if (!request_region(address, SMSC_EXTENT, smsc47m1_driver.name)) {
                dev_err(&adapter->dev, "Region 0x%x already in use!\n", address);
                return -EBUSY;
@@ -461,6 +440,13 @@ static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind)
           function. */
        smsc47m1_update_device(&new_client->dev, 1);
 
+       /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto error_detach;
+       }
+
        if (fan1) {
                device_create_file(&new_client->dev, &dev_attr_fan1_input);
                device_create_file(&new_client->dev, &dev_attr_fan1_min);
@@ -494,6 +480,8 @@ static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
+error_detach:
+       i2c_detach_client(new_client);
 error_free:
        kfree(data);
 error_release:
@@ -503,16 +491,16 @@ error_release:
 
 static int smsc47m1_detach_client(struct i2c_client *client)
 {
+       struct smsc47m1_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, "
-                       "client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
        release_region(client->addr, SMSC_EXTENT);
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
 
        return 0;
 }
@@ -573,16 +561,16 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
 
 static int __init sm_smsc47m1_init(void)
 {
-       if (smsc47m1_find(normal_isa)) {
+       if (smsc47m1_find(&address)) {
                return -ENODEV;
        }
 
-       return i2c_add_driver(&smsc47m1_driver);
+       return i2c_isa_add_driver(&smsc47m1_driver);
 }
 
 static void __exit sm_smsc47m1_exit(void)
 {
-       i2c_del_driver(&smsc47m1_driver);
+       i2c_isa_del_driver(&smsc47m1_driver);
 }
 
 MODULE_AUTHOR("Mark D. Studebaker <mdsxyz123@yahoo.com>");
index 164d47948390d39206537b206c5e11c9a2c6faa1..eb84997627c8245456ab40c3d402d72b51104ce9 100644 (file)
@@ -35,7 +35,9 @@
 #include <linux/pci.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
+#include <linux/i2c-isa.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
 #include <linux/init.h>
 #include <asm/io.h>
 
@@ -47,14 +49,10 @@ module_param(force_addr, ushort, 0);
 MODULE_PARM_DESC(force_addr,
                 "Initialize the base address of the sensors");
 
-/* Addresses to scan.
+/* Device address
    Note that we can't determine the ISA address until we have initialized
    our module */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END };
-
-/* Insmod parameters */
-SENSORS_INSMOD_1(via686a);
+static unsigned short address;
 
 /*
    The Via 686a southbridge has a LM78-like chip integrated on the same IC.
@@ -297,6 +295,7 @@ static inline long TEMP_FROM_REG10(u16 val)
    via686a client is allocated. */
 struct via686a_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore update_lock;
        char valid;             /* !=0 if following fields are valid */
        unsigned long last_updated;     /* In jiffies */
@@ -315,8 +314,7 @@ struct via686a_data {
 
 static struct pci_dev *s_bridge;       /* pointer to the (only) via686a */
 
-static int via686a_attach_adapter(struct i2c_adapter *adapter);
-static int via686a_detect(struct i2c_adapter *adapter, int address, int kind);
+static int via686a_detect(struct i2c_adapter *adapter);
 static int via686a_detach_client(struct i2c_client *client);
 
 static inline int via686a_read_value(struct i2c_client *client, u8 reg)
@@ -576,22 +574,13 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
 static struct i2c_driver via686a_driver = {
        .owner          = THIS_MODULE,
        .name           = "via686a",
-       .id             = I2C_DRIVERID_VIA686A,
-       .flags          = I2C_DF_NOTIFY,
-       .attach_adapter = via686a_attach_adapter,
+       .attach_adapter = via686a_detect,
        .detach_client  = via686a_detach_client,
 };
 
 
 /* This is called when the module is loaded */
-static int via686a_attach_adapter(struct i2c_adapter *adapter)
-{
-       if (!(adapter->class & I2C_CLASS_HWMON))
-               return 0;
-       return i2c_detect(adapter, &addr_data, via686a_detect);
-}
-
-static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
+static int via686a_detect(struct i2c_adapter *adapter)
 {
        struct i2c_client *new_client;
        struct via686a_data *data;
@@ -599,13 +588,6 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
        const char client_name[] = "via686a";
        u16 val;
 
-       /* Make sure we are probing the ISA bus!!  */
-       if (!i2c_is_isa_adapter(adapter)) {
-               dev_err(&adapter->dev,
-               "via686a_detect called for an I2C bus adapter?!?\n");
-               return 0;
-       }
-
        /* 8231 requires multiple of 256, we enforce that on 686 as well */
        if (force_addr)
                address = force_addr & 0xFF00;
@@ -637,7 +619,7 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
 
        if (!(data = kmalloc(sizeof(struct via686a_data), GFP_KERNEL))) {
                err = -ENOMEM;
-               goto ERROR0;
+               goto exit_release;
        }
        memset(data, 0, sizeof(struct via686a_data));
 
@@ -655,12 +637,18 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
        init_MUTEX(&data->update_lock);
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
-               goto ERROR3;
+               goto exit_free;
 
        /* Initialize the VIA686A chip */
        via686a_init_client(new_client);
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        device_create_file(&new_client->dev, &dev_attr_in0_input);
        device_create_file(&new_client->dev, &dev_attr_in1_input);
        device_create_file(&new_client->dev, &dev_attr_in2_input);
@@ -695,25 +683,27 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
-ERROR3:
+exit_detach:
+       i2c_detach_client(new_client);
+exit_free:
        kfree(data);
-ERROR0:
+exit_release:
        release_region(address, VIA686A_EXTENT);
        return err;
 }
 
 static int via686a_detach_client(struct i2c_client *client)
 {
+       struct via686a_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev,
-               "Client deregistration failed, client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
        release_region(client->addr, VIA686A_EXTENT);
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
 
        return 0;
 }
@@ -810,29 +800,25 @@ static int __devinit via686a_pci_probe(struct pci_dev *dev,
                                       const struct pci_device_id *id)
 {
        u16 val;
-       int addr = 0;
 
        if (PCIBIOS_SUCCESSFUL !=
            pci_read_config_word(dev, VIA686A_BASE_REG, &val))
                return -ENODEV;
 
-       addr = val & ~(VIA686A_EXTENT - 1);
-       if (addr == 0 && force_addr == 0) {
+       address = val & ~(VIA686A_EXTENT - 1);
+       if (address == 0 && force_addr == 0) {
                dev_err(&dev->dev, "base address not set - upgrade BIOS "
                        "or use force_addr=0xaddr\n");
                return -ENODEV;
        }
-       if (force_addr)
-               addr = force_addr;      /* so detect will get called */
 
-       if (!addr) {
+       if (!address) {
                dev_err(&dev->dev, "No Via 686A sensors found.\n");
                return -ENODEV;
        }
-       normal_isa[0] = addr;
 
        s_bridge = pci_dev_get(dev);
-       if (i2c_add_driver(&via686a_driver)) {
+       if (i2c_isa_add_driver(&via686a_driver)) {
                pci_dev_put(s_bridge);
                s_bridge = NULL;
        }
@@ -859,7 +845,7 @@ static void __exit sm_via686a_exit(void)
 {
        pci_unregister_driver(&via686a_pci_driver);
        if (s_bridge != NULL) {
-               i2c_del_driver(&via686a_driver);
+               i2c_isa_del_driver(&via686a_driver);
                pci_dev_put(s_bridge);
                s_bridge = NULL;
        }
index 8a40b6976e1ad25838a37c70c49e4235a1ea3281..b60efe8f8b26691a70bc64f5617d362b68e7a2be 100644 (file)
@@ -9,6 +9,9 @@
     Thanks to Leon Moonen, Steve Cliffe and Grant Coady for their help
     in testing and debugging this driver.
 
+    This driver also supports the W83627EHG, which is the lead-free
+    version of the W83627EHF.
+
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
+#include <linux/i2c-isa.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
 #include <asm/io.h>
 #include "lm75.h"
 
-/* Addresses to scan
-   The actual ISA address is read from Super-I/O configuration space */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END };
-
-/* Insmod parameters */
-SENSORS_INSMOD_1(w83627ehf);
+/* The actual ISA address is read from Super-I/O configuration space */
+static unsigned short address;
 
 /*
  * Super-I/O constants and functions
@@ -174,6 +174,7 @@ temp1_to_reg(int temp)
 
 struct w83627ehf_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore lock;
 
        struct semaphore update_lock;
@@ -666,15 +667,12 @@ static void w83627ehf_init_client(struct i2c_client *client)
        }
 }
 
-static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind)
+static int w83627ehf_detect(struct i2c_adapter *adapter)
 {
        struct i2c_client *client;
        struct w83627ehf_data *data;
        int i, err = 0;
 
-       if (!i2c_is_isa_adapter(adapter))
-               return 0;
-
        if (!request_region(address, REGION_LENGTH, w83627ehf_driver.name)) {
                err = -EBUSY;
                goto exit;
@@ -720,6 +718,12 @@ static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind)
                data->has_fan |= (1 << 4);
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        device_create_file(&client->dev, &dev_attr_fan1_input);
        device_create_file(&client->dev, &dev_attr_fan1_min);
        device_create_file(&client->dev, &dev_attr_fan1_div);
@@ -753,6 +757,8 @@ static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
+exit_detach:
+       i2c_detach_client(client);
 exit_free:
        kfree(data);
 exit_release:
@@ -761,24 +767,17 @@ exit:
        return err;
 }
 
-static int w83627ehf_attach_adapter(struct i2c_adapter *adapter)
-{
-       if (!(adapter->class & I2C_CLASS_HWMON))
-               return 0;
-       return i2c_detect(adapter, &addr_data, w83627ehf_detect);
-}
-
 static int w83627ehf_detach_client(struct i2c_client *client)
 {
+       struct w83627ehf_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, "
-                       "client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
        release_region(client->addr, REGION_LENGTH);
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
 
        return 0;
 }
@@ -786,12 +785,11 @@ static int w83627ehf_detach_client(struct i2c_client *client)
 static struct i2c_driver w83627ehf_driver = {
        .owner          = THIS_MODULE,
        .name           = "w83627ehf",
-       .flags          = I2C_DF_NOTIFY,
-       .attach_adapter = w83627ehf_attach_adapter,
+       .attach_adapter = w83627ehf_detect,
        .detach_client  = w83627ehf_detach_client,
 };
 
-static int __init w83627ehf_find(int sioaddr, int *address)
+static int __init w83627ehf_find(int sioaddr, unsigned short *addr)
 {
        u16 val;
 
@@ -809,8 +807,8 @@ static int __init w83627ehf_find(int sioaddr, int *address)
        superio_select(W83627EHF_LD_HWM);
        val = (superio_inb(SIO_REG_ADDR) << 8)
            | superio_inb(SIO_REG_ADDR + 1);
-       *address = val & ~(REGION_LENGTH - 1);
-       if (*address == 0) {
+       *addr = val & ~(REGION_LENGTH - 1);
+       if (*addr == 0) {
                superio_exit();
                return -ENODEV;
        }
@@ -826,16 +824,16 @@ static int __init w83627ehf_find(int sioaddr, int *address)
 
 static int __init sensors_w83627ehf_init(void)
 {
-       if (w83627ehf_find(0x2e, &normal_isa[0])
-        && w83627ehf_find(0x4e, &normal_isa[0]))
+       if (w83627ehf_find(0x2e, &address)
+        && w83627ehf_find(0x4e, &address))
                return -ENODEV;
 
-       return i2c_add_driver(&w83627ehf_driver);
+       return i2c_isa_add_driver(&w83627ehf_driver);
 }
 
 static void __exit sensors_w83627ehf_exit(void)
 {
-       i2c_del_driver(&w83627ehf_driver);
+       i2c_isa_del_driver(&w83627ehf_driver);
 }
 
 MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
index bd87a42e068ae4d6ac0fd1763d61b3c32b1bb5d7..02bd5c0239a2daba693652cdafb431efd75e77a4 100644 (file)
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
-#include <linux/i2c-vid.h>
+#include <linux/i2c-isa.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-vid.h>
+#include <linux/err.h>
 #include <asm/io.h>
 #include "lm75.h"
 
@@ -56,12 +58,11 @@ module_param(force_i2c, byte, 0);
 MODULE_PARM_DESC(force_i2c,
                 "Initialize the i2c address of the sensors");
 
-/* Addresses to scan */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END };
+/* The actual ISA address is read from Super-I/O configuration space */
+static unsigned short address;
 
 /* Insmod parameters */
-SENSORS_INSMOD_4(w83627hf, w83627thf, w83697hf, w83637hf);
+enum chips { any_chip, w83627hf, w83627thf, w83697hf, w83637hf };
 
 static int init = 1;
 module_param(init, bool, 0);
@@ -277,6 +278,7 @@ static inline u8 DIV_TO_REG(long val)
    dynamically allocated, at the same time when a new client is allocated. */
 struct w83627hf_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore lock;
        enum chips type;
 
@@ -314,9 +316,7 @@ struct w83627hf_data {
 };
 
 
-static int w83627hf_attach_adapter(struct i2c_adapter *adapter);
-static int w83627hf_detect(struct i2c_adapter *adapter, int address,
-                         int kind);
+static int w83627hf_detect(struct i2c_adapter *adapter);
 static int w83627hf_detach_client(struct i2c_client *client);
 
 static int w83627hf_read_value(struct i2c_client *client, u16 register);
@@ -328,9 +328,7 @@ static void w83627hf_init_client(struct i2c_client *client);
 static struct i2c_driver w83627hf_driver = {
        .owner          = THIS_MODULE,
        .name           = "w83627hf",
-       .id             = I2C_DRIVERID_W83627HF,
-       .flags          = I2C_DF_NOTIFY,
-       .attach_adapter = w83627hf_attach_adapter,
+       .attach_adapter = w83627hf_detect,
        .detach_client  = w83627hf_detach_client,
 };
 
@@ -959,16 +957,7 @@ device_create_file(&client->dev, &dev_attr_temp##offset##_type); \
 } while (0)
 
 
-/* This function is called when:
-     * w83627hf_driver is inserted (when this module is loaded), for each
-       available adapter
-     * when a new adapter is inserted (and w83627hf_driver is still present) */
-static int w83627hf_attach_adapter(struct i2c_adapter *adapter)
-{
-       return i2c_detect(adapter, &addr_data, w83627hf_detect);
-}
-
-static int w83627hf_find(int sioaddr, int *address)
+static int __init w83627hf_find(int sioaddr, unsigned short *addr)
 {
        u16 val;
 
@@ -988,32 +977,24 @@ static int w83627hf_find(int sioaddr, int *address)
        superio_select(W83627HF_LD_HWM);
        val = (superio_inb(WINB_BASE_REG) << 8) |
               superio_inb(WINB_BASE_REG + 1);
-       *address = val & ~(WINB_EXTENT - 1);
-       if (*address == 0 && force_addr == 0) {
+       *addr = val & ~(WINB_EXTENT - 1);
+       if (*addr == 0 && force_addr == 0) {
                superio_exit();
                return -ENODEV;
        }
-       if (force_addr)
-               *address = force_addr;  /* so detect will get called */
 
        superio_exit();
        return 0;
 }
 
-int w83627hf_detect(struct i2c_adapter *adapter, int address,
-                  int kind)
+static int w83627hf_detect(struct i2c_adapter *adapter)
 {
-       int val;
+       int val, kind;
        struct i2c_client *new_client;
        struct w83627hf_data *data;
        int err = 0;
        const char *client_name = "";
 
-       if (!i2c_is_isa_adapter(adapter)) {
-               err = -ENODEV;
-               goto ERROR0;
-       }
-
        if(force_addr)
                address = force_addr & ~(WINB_EXTENT - 1);
 
@@ -1102,6 +1083,12 @@ int w83627hf_detect(struct i2c_adapter *adapter, int address,
        data->fan_min[2] = w83627hf_read_value(new_client, W83781D_REG_FAN_MIN(3));
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto ERROR3;
+       }
+
        device_create_file_in(new_client, 0);
        if (kind != w83697hf)
                device_create_file_in(new_client, 1);
@@ -1152,6 +1139,8 @@ int w83627hf_detect(struct i2c_adapter *adapter, int address,
 
        return 0;
 
+      ERROR3:
+       i2c_detach_client(new_client);
       ERROR2:
        kfree(data);
       ERROR1:
@@ -1162,16 +1151,16 @@ int w83627hf_detect(struct i2c_adapter *adapter, int address,
 
 static int w83627hf_detach_client(struct i2c_client *client)
 {
+       struct w83627hf_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev,
-                      "Client deregistration failed, client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
        release_region(client->addr, WINB_EXTENT);
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
 
        return 0;
 }
@@ -1327,7 +1316,7 @@ static void w83627hf_init_client(struct i2c_client *client)
                data->vrm = (data->vrm_ovt & 0x01) ? 90 : 82;
        } else {
                /* Convert VID to voltage based on default VRM */
-               data->vrm = i2c_which_vrm();
+               data->vrm = vid_which_vrm();
        }
 
        tmp = w83627hf_read_value(client, W83781D_REG_SCFG1);
@@ -1485,20 +1474,17 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev)
 
 static int __init sensors_w83627hf_init(void)
 {
-       int addr;
-
-       if (w83627hf_find(0x2e, &addr)
-        && w83627hf_find(0x4e, &addr)) {
+       if (w83627hf_find(0x2e, &address)
+        && w83627hf_find(0x4e, &address)) {
                return -ENODEV;
        }
-       normal_isa[0] = addr;
 
-       return i2c_add_driver(&w83627hf_driver);
+       return i2c_isa_add_driver(&w83627hf_driver);
 }
 
 static void __exit sensors_w83627hf_exit(void)
 {
-       i2c_del_driver(&w83627hf_driver);
+       i2c_isa_del_driver(&w83627hf_driver);
 }
 
 MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>, "
index 0bb131ce09ebc931fdebf415c75c6c6f255f7e11..4c43337ca780abe0cde6ee81590de98b3edfbff8 100644 (file)
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
-#include <linux/i2c-vid.h>
+#include <linux/i2c-isa.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-vid.h>
+#include <linux/err.h>
 #include <asm/io.h>
 #include "lm75.h"
 
 static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
                                        0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
                                        0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END };
+static unsigned short isa_address = 0x290;
 
 /* Insmod parameters */
-SENSORS_INSMOD_5(w83781d, w83782d, w83783s, w83627hf, as99127f);
+I2C_CLIENT_INSMOD_5(w83781d, w83782d, w83783s, w83627hf, as99127f);
 I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: "
                    "{bus, clientaddr, subclientaddr1, subclientaddr2}");
 
@@ -218,6 +220,7 @@ DIV_TO_REG(long val, enum chips type)
    allocated. */
 struct w83781d_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore lock;
        enum chips type;
 
@@ -255,6 +258,7 @@ struct w83781d_data {
 };
 
 static int w83781d_attach_adapter(struct i2c_adapter *adapter);
+static int w83781d_isa_attach_adapter(struct i2c_adapter *adapter);
 static int w83781d_detect(struct i2c_adapter *adapter, int address, int kind);
 static int w83781d_detach_client(struct i2c_client *client);
 
@@ -273,6 +277,14 @@ static struct i2c_driver w83781d_driver = {
        .detach_client = w83781d_detach_client,
 };
 
+static struct i2c_driver w83781d_isa_driver = {
+       .owner = THIS_MODULE,
+       .name = "w83781d-isa",
+       .attach_adapter = w83781d_isa_attach_adapter,
+       .detach_client = w83781d_detach_client,
+};
+
+
 /* following are the sysfs callback functions */
 #define show_in_reg(reg) \
 static ssize_t show_##reg (struct device *dev, char *buf, int nr) \
@@ -856,7 +868,13 @@ w83781d_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, w83781d_detect);
+       return i2c_probe(adapter, &addr_data, w83781d_detect);
+}
+
+static int
+w83781d_isa_attach_adapter(struct i2c_adapter *adapter)
+{
+       return w83781d_detect(adapter, isa_address, -1);
 }
 
 /* Assumes that adapter is of I2C, not ISA variety.
@@ -961,10 +979,10 @@ w83781d_detect_subclients(struct i2c_adapter *adapter, int address, int kind,
 ERROR_SC_3:
        i2c_detach_client(data->lm75[0]);
 ERROR_SC_2:
-       if (NULL != data->lm75[1])
+       if (data->lm75[1])
                kfree(data->lm75[1]);
 ERROR_SC_1:
-       if (NULL != data->lm75[0])
+       if (data->lm75[0])
                kfree(data->lm75[0]);
 ERROR_SC_0:
        return err;
@@ -999,7 +1017,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
        
        if (is_isa)
                if (!request_region(address, W83781D_EXTENT,
-                                   w83781d_driver.name)) {
+                                   w83781d_isa_driver.name)) {
                        dev_dbg(&adapter->dev, "Request of region "
                                "0x%x-0x%x for w83781d failed\n", address,
                                address + W83781D_EXTENT - 1);
@@ -1057,7 +1075,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
        new_client->addr = address;
        init_MUTEX(&data->lock);
        new_client->adapter = adapter;
-       new_client->driver = &w83781d_driver;
+       new_client->driver = is_isa ? &w83781d_isa_driver : &w83781d_driver;
        new_client->flags = 0;
 
        /* Now, we do the remaining detection. */
@@ -1189,6 +1207,12 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
                        data->pwmenable[i] = 1;
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto ERROR4;
+       }
+
        device_create_file_in(new_client, 0);
        if (kind != w83783s)
                device_create_file_in(new_client, 1);
@@ -1241,6 +1265,15 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
+ERROR4:
+       if (data->lm75[1]) {
+               i2c_detach_client(data->lm75[1]);
+               kfree(data->lm75[1]);
+       }
+       if (data->lm75[0]) {
+               i2c_detach_client(data->lm75[0]);
+               kfree(data->lm75[0]);
+       }
 ERROR3:
        i2c_detach_client(new_client);
 ERROR2:
@@ -1255,24 +1288,26 @@ ERROR0:
 static int
 w83781d_detach_client(struct i2c_client *client)
 {
+       struct w83781d_data *data = i2c_get_clientdata(client);
        int err;
 
+       /* main client */
+       if (data)
+               hwmon_device_unregister(data->class_dev);
+
        if (i2c_is_isa_client(client))
                release_region(client->addr, W83781D_EXTENT);
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev,
-                      "Client deregistration failed, client not detached.\n");
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
-       if (i2c_get_clientdata(client)==NULL) {
-               /* subclients */
+       /* main client */
+       if (data)
+               kfree(data);
+
+       /* subclient */
+       else
                kfree(client);
-       } else {
-               /* main client */
-               kfree(i2c_get_clientdata(client));
-       }
 
        return 0;
 }
@@ -1443,7 +1478,7 @@ w83781d_init_client(struct i2c_client *client)
                w83781d_write_value(client, W83781D_REG_BEEP_INTS2, 0);
        }
 
-       data->vrm = i2c_which_vrm();
+       data->vrm = vid_which_vrm();
 
        if ((type != w83781d) && (type != as99127f)) {
                tmp = w83781d_read_value(client, W83781D_REG_SCFG1);
@@ -1613,12 +1648,25 @@ static struct w83781d_data *w83781d_update_device(struct device *dev)
 static int __init
 sensors_w83781d_init(void)
 {
-       return i2c_add_driver(&w83781d_driver);
+       int res;
+
+       res = i2c_add_driver(&w83781d_driver);
+       if (res)
+               return res;
+
+       res = i2c_isa_add_driver(&w83781d_isa_driver);
+       if (res) {
+               i2c_del_driver(&w83781d_driver);
+               return res;
+       }
+
+       return 0;
 }
 
 static void __exit
 sensors_w83781d_exit(void)
 {
+       i2c_isa_del_driver(&w83781d_isa_driver);
        i2c_del_driver(&w83781d_driver);
 }
 
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c
new file mode 100644 (file)
index 0000000..ba0c280
--- /dev/null
@@ -0,0 +1,1649 @@
+/*
+    w83792d.c - Part of lm_sensors, Linux kernel modules for hardware
+                monitoring
+    Copyright (C) 2004, 2005 Winbond Electronics Corp.
+                        Chunhao Huang <DZShen@Winbond.com.tw>,
+                        Rudolf Marek <r.marek@sh.cvut.cz>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+    Note:
+    1. This driver is only for 2.6 kernel, 2.4 kernel need a different driver.
+    2. This driver is only for Winbond W83792D C version device, there
+       are also some motherboards with B version W83792D device. The
+       calculation method to in6-in7(measured value, limits) is a little
+       different between C and B version. C or B version can be identified
+       by CR[0x49h].
+*/
+
+/*
+    Supports following chips:
+
+    Chip       #vin    #fanin  #pwm    #temp   wchipid vendid  i2c     ISA
+    w83792d    9       7       7       3       0x7a    0x5ca3  yes     no
+*/
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-sysfs.h>
+#include <linux/err.h>
+
+/* Addresses to scan */
+static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END };
+
+/* Insmod parameters */
+I2C_CLIENT_INSMOD_1(w83792d);
+I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: "
+                       "{bus, clientaddr, subclientaddr1, subclientaddr2}");
+
+static int init;
+module_param(init, bool, 0);
+MODULE_PARM_DESC(init, "Set to one to force chip initialization");
+
+/* The W83792D registers */
+static const u8 W83792D_REG_IN[9] = {
+       0x20,   /* Vcore A in DataSheet */
+       0x21,   /* Vcore B in DataSheet */
+       0x22,   /* VIN0 in DataSheet */
+       0x23,   /* VIN1 in DataSheet */
+       0x24,   /* VIN2 in DataSheet */
+       0x25,   /* VIN3 in DataSheet */
+       0x26,   /* 5VCC in DataSheet */
+       0xB0,   /* 5VSB in DataSheet */
+       0xB1    /* VBAT in DataSheet */
+};
+#define W83792D_REG_LOW_BITS1 0x3E  /* Low Bits I in DataSheet */
+#define W83792D_REG_LOW_BITS2 0x3F  /* Low Bits II in DataSheet */
+static const u8 W83792D_REG_IN_MAX[9] = {
+       0x2B,   /* Vcore A High Limit in DataSheet */
+       0x2D,   /* Vcore B High Limit in DataSheet */
+       0x2F,   /* VIN0 High Limit in DataSheet */
+       0x31,   /* VIN1 High Limit in DataSheet */
+       0x33,   /* VIN2 High Limit in DataSheet */
+       0x35,   /* VIN3 High Limit in DataSheet */
+       0x37,   /* 5VCC High Limit in DataSheet */
+       0xB4,   /* 5VSB High Limit in DataSheet */
+       0xB6    /* VBAT High Limit in DataSheet */
+};
+static const u8 W83792D_REG_IN_MIN[9] = {
+       0x2C,   /* Vcore A Low Limit in DataSheet */
+       0x2E,   /* Vcore B Low Limit in DataSheet */
+       0x30,   /* VIN0 Low Limit in DataSheet */
+       0x32,   /* VIN1 Low Limit in DataSheet */
+       0x34,   /* VIN2 Low Limit in DataSheet */
+       0x36,   /* VIN3 Low Limit in DataSheet */
+       0x38,   /* 5VCC Low Limit in DataSheet */
+       0xB5,   /* 5VSB Low Limit in DataSheet */
+       0xB7    /* VBAT Low Limit in DataSheet */
+};
+static const u8 W83792D_REG_FAN[7] = {
+       0x28,   /* FAN 1 Count in DataSheet */
+       0x29,   /* FAN 2 Count in DataSheet */
+       0x2A,   /* FAN 3 Count in DataSheet */
+       0xB8,   /* FAN 4 Count in DataSheet */
+       0xB9,   /* FAN 5 Count in DataSheet */
+       0xBA,   /* FAN 6 Count in DataSheet */
+       0xBE    /* FAN 7 Count in DataSheet */
+};
+static const u8 W83792D_REG_FAN_MIN[7] = {
+       0x3B,   /* FAN 1 Count Low Limit in DataSheet */
+       0x3C,   /* FAN 2 Count Low Limit in DataSheet */
+       0x3D,   /* FAN 3 Count Low Limit in DataSheet */
+       0xBB,   /* FAN 4 Count Low Limit in DataSheet */
+       0xBC,   /* FAN 5 Count Low Limit in DataSheet */
+       0xBD,   /* FAN 6 Count Low Limit in DataSheet */
+       0xBF    /* FAN 7 Count Low Limit in DataSheet */
+};
+#define W83792D_REG_FAN_CFG 0x84       /* FAN Configuration in DataSheet */
+static const u8 W83792D_REG_FAN_DIV[4] = {
+       0x47,   /* contains FAN2 and FAN1 Divisor */
+       0x5B,   /* contains FAN4 and FAN3 Divisor */
+       0x5C,   /* contains FAN6 and FAN5 Divisor */
+       0x9E    /* contains FAN7 Divisor. */
+};
+static const u8 W83792D_REG_PWM[7] = {
+       0x81,   /* FAN 1 Duty Cycle, be used to control */
+       0x83,   /* FAN 2 Duty Cycle, be used to control */
+       0x94,   /* FAN 3 Duty Cycle, be used to control */
+       0xA3,   /* FAN 4 Duty Cycle, be used to control */
+       0xA4,   /* FAN 5 Duty Cycle, be used to control */
+       0xA5,   /* FAN 6 Duty Cycle, be used to control */
+       0xA6    /* FAN 7 Duty Cycle, be used to control */
+};
+#define W83792D_REG_BANK               0x4E
+#define W83792D_REG_TEMP2_CONFIG       0xC2
+#define W83792D_REG_TEMP3_CONFIG       0xCA
+
+static const u8 W83792D_REG_TEMP1[3] = {
+       0x27,   /* TEMP 1 in DataSheet */
+       0x39,   /* TEMP 1 Over in DataSheet */
+       0x3A,   /* TEMP 1 Hyst in DataSheet */
+};
+
+static const u8 W83792D_REG_TEMP_ADD[2][6] = {
+       { 0xC0,         /* TEMP 2 in DataSheet */
+         0xC1,         /* TEMP 2(0.5 deg) in DataSheet */
+         0xC5,         /* TEMP 2 Over High part in DataSheet */
+         0xC6,         /* TEMP 2 Over Low part in DataSheet */
+         0xC3,         /* TEMP 2 Thyst High part in DataSheet */
+         0xC4 },       /* TEMP 2 Thyst Low part in DataSheet */
+       { 0xC8,         /* TEMP 3 in DataSheet */
+         0xC9,         /* TEMP 3(0.5 deg) in DataSheet */
+         0xCD,         /* TEMP 3 Over High part in DataSheet */
+         0xCE,         /* TEMP 3 Over Low part in DataSheet */
+         0xCB,         /* TEMP 3 Thyst High part in DataSheet */
+         0xCC }        /* TEMP 3 Thyst Low part in DataSheet */
+};
+
+static const u8 W83792D_REG_THERMAL[3] = {
+       0x85,   /* SmartFanI: Fan1 target value */
+       0x86,   /* SmartFanI: Fan2 target value */
+       0x96    /* SmartFanI: Fan3 target value */
+};
+
+static const u8 W83792D_REG_TOLERANCE[3] = {
+       0x87,   /* (bit3-0)SmartFan Fan1 tolerance */
+       0x87,   /* (bit7-4)SmartFan Fan2 tolerance */
+       0x97    /* (bit3-0)SmartFan Fan3 tolerance */
+};
+
+static const u8 W83792D_REG_POINTS[3][4] = {
+       { 0x85,         /* SmartFanII: Fan1 temp point 1 */
+         0xE3,         /* SmartFanII: Fan1 temp point 2 */
+         0xE4,         /* SmartFanII: Fan1 temp point 3 */
+         0xE5 },       /* SmartFanII: Fan1 temp point 4 */
+       { 0x86,         /* SmartFanII: Fan2 temp point 1 */
+         0xE6,         /* SmartFanII: Fan2 temp point 2 */
+         0xE7,         /* SmartFanII: Fan2 temp point 3 */
+         0xE8 },       /* SmartFanII: Fan2 temp point 4 */
+       { 0x96,         /* SmartFanII: Fan3 temp point 1 */
+         0xE9,         /* SmartFanII: Fan3 temp point 2 */
+         0xEA,         /* SmartFanII: Fan3 temp point 3 */
+         0xEB }        /* SmartFanII: Fan3 temp point 4 */
+};
+
+static const u8 W83792D_REG_LEVELS[3][4] = {
+       { 0x88,         /* (bit3-0) SmartFanII: Fan1 Non-Stop */
+         0x88,         /* (bit7-4) SmartFanII: Fan1 Level 1 */
+         0xE0,         /* (bit7-4) SmartFanII: Fan1 Level 2 */
+         0xE0 },       /* (bit3-0) SmartFanII: Fan1 Level 3 */
+       { 0x89,         /* (bit3-0) SmartFanII: Fan2 Non-Stop */
+         0x89,         /* (bit7-4) SmartFanII: Fan2 Level 1 */
+         0xE1,         /* (bit7-4) SmartFanII: Fan2 Level 2 */
+         0xE1 },       /* (bit3-0) SmartFanII: Fan2 Level 3 */
+       { 0x98,         /* (bit3-0) SmartFanII: Fan3 Non-Stop */
+         0x98,         /* (bit7-4) SmartFanII: Fan3 Level 1 */
+         0xE2,         /* (bit7-4) SmartFanII: Fan3 Level 2 */
+         0xE2 }        /* (bit3-0) SmartFanII: Fan3 Level 3 */
+};
+
+#define W83792D_REG_CONFIG             0x40
+#define W83792D_REG_VID_FANDIV         0x47
+#define W83792D_REG_CHIPID             0x49
+#define W83792D_REG_WCHIPID            0x58
+#define W83792D_REG_CHIPMAN            0x4F
+#define W83792D_REG_PIN                        0x4B
+#define W83792D_REG_I2C_SUBADDR                0x4A
+
+#define W83792D_REG_ALARM1 0xA9                /* realtime status register1 */
+#define W83792D_REG_ALARM2 0xAA                /* realtime status register2 */
+#define W83792D_REG_ALARM3 0xAB                /* realtime status register3 */
+#define W83792D_REG_CHASSIS 0x42       /* Bit 5: Case Open status bit */
+#define W83792D_REG_CHASSIS_CLR 0x44   /* Bit 7: Case Open CLR_CHS/Reset bit */
+
+/* control in0/in1 's limit modifiability */
+#define W83792D_REG_VID_IN_B           0x17
+
+#define W83792D_REG_VBAT               0x5D
+#define W83792D_REG_I2C_ADDR           0x48
+
+/* Conversions. Rounding and limit checking is only done on the TO_REG
+   variants. Note that you should be a bit careful with which arguments
+   these macros are called: arguments may be evaluated more than once.
+   Fixing this is just not worth it. */
+#define IN_FROM_REG(nr,val) (((nr)<=1)?(val*2): \
+                               ((((nr)==6)||((nr)==7))?(val*6):(val*4)))
+#define IN_TO_REG(nr,val) (((nr)<=1)?(val/2): \
+                               ((((nr)==6)||((nr)==7))?(val/6):(val/4)))
+
+static inline u8
+FAN_TO_REG(long rpm, int div)
+{
+       if (rpm == 0)
+               return 255;
+       rpm = SENSORS_LIMIT(rpm, 1, 1000000);
+       return SENSORS_LIMIT((1350000 + rpm * div / 2) / (rpm * div), 1, 254);
+}
+
+#define FAN_FROM_REG(val,div)  ((val) == 0   ? -1 : \
+                               ((val) == 255 ? 0 : \
+                                               1350000 / ((val) * (div))))
+
+/* for temp1 */
+#define TEMP1_TO_REG(val)      (SENSORS_LIMIT(((val) < 0 ? (val)+0x100*1000 \
+                                       : (val)) / 1000, 0, 0xff))
+#define TEMP1_FROM_REG(val)    (((val) & 0x80 ? (val)-0x100 : (val)) * 1000)
+/* for temp2 and temp3, because they need addtional resolution */
+#define TEMP_ADD_FROM_REG(val1, val2) \
+       ((((val1) & 0x80 ? (val1)-0x100 \
+               : (val1)) * 1000) + ((val2 & 0x80) ? 500 : 0))
+#define TEMP_ADD_TO_REG_HIGH(val) \
+       (SENSORS_LIMIT(((val) < 0 ? (val)+0x100*1000 \
+                       : (val)) / 1000, 0, 0xff))
+#define TEMP_ADD_TO_REG_LOW(val)       ((val%1000) ? 0x80 : 0x00)
+
+#define PWM_FROM_REG(val)              (val)
+#define PWM_TO_REG(val)                        (SENSORS_LIMIT((val),0,255))
+#define DIV_FROM_REG(val)              (1 << (val))
+
+static inline u8
+DIV_TO_REG(long val)
+{
+       int i;
+       val = SENSORS_LIMIT(val, 1, 128) >> 1;
+       for (i = 0; i < 6; i++) {
+               if (val == 0)
+                       break;
+               val >>= 1;
+       }
+       return ((u8) i);
+}
+
+struct w83792d_data {
+       struct i2c_client client;
+       struct class_device *class_dev;
+       struct semaphore lock;
+       enum chips type;
+
+       struct semaphore update_lock;
+       char valid;             /* !=0 if following fields are valid */
+       unsigned long last_updated;     /* In jiffies */
+
+       /* array of 2 pointers to subclients */
+       struct i2c_client *lm75[2];
+
+       u8 in[9];               /* Register value */
+       u8 in_max[9];           /* Register value */
+       u8 in_min[9];           /* Register value */
+       u8 low_bits[2];         /* Additional resolution to voltage in0-6 */
+       u8 fan[7];              /* Register value */
+       u8 fan_min[7];          /* Register value */
+       u8 temp1[3];            /* current, over, thyst */
+       u8 temp_add[2][6];      /* Register value */
+       u8 fan_div[7];          /* Register encoding, shifted right */
+       u8 pwm[7];              /* We only consider the first 3 set of pwm,
+                                  although 792 chip has 7 set of pwm. */
+       u8 pwmenable[3];
+       u8 pwm_mode[7];         /* indicates PWM or DC mode: 1->PWM; 0->DC */
+       u32 alarms;             /* realtime status register encoding,combined */
+       u8 chassis;             /* Chassis status */
+       u8 chassis_clear;       /* CLR_CHS, clear chassis intrusion detection */
+       u8 thermal_cruise[3];   /* Smart FanI: Fan1,2,3 target value */
+       u8 tolerance[3];        /* Fan1,2,3 tolerance(Smart Fan I/II) */
+       u8 sf2_points[3][4];    /* Smart FanII: Fan1,2,3 temperature points */
+       u8 sf2_levels[3][4];    /* Smart FanII: Fan1,2,3 duty cycle levels */
+};
+
+static int w83792d_attach_adapter(struct i2c_adapter *adapter);
+static int w83792d_detect(struct i2c_adapter *adapter, int address, int kind);
+static int w83792d_detach_client(struct i2c_client *client);
+
+static int w83792d_read_value(struct i2c_client *client, u8 register);
+static int w83792d_write_value(struct i2c_client *client, u8 register,
+                               u8 value);
+static struct w83792d_data *w83792d_update_device(struct device *dev);
+
+#ifdef DEBUG
+static void w83792d_print_debug(struct w83792d_data *data, struct device *dev);
+#endif
+
+static void w83792d_init_client(struct i2c_client *client);
+
+static struct i2c_driver w83792d_driver = {
+       .owner = THIS_MODULE,
+       .name = "w83792d",
+       .flags = I2C_DF_NOTIFY,
+       .attach_adapter = w83792d_attach_adapter,
+       .detach_client = w83792d_detach_client,
+};
+
+static long in_count_from_reg(int nr, struct w83792d_data *data)
+{
+       u16 vol_count = data->in[nr];
+       u16 low_bits = 0;
+       vol_count = (vol_count << 2);
+       switch (nr)
+       {
+       case 0:  /* vin0 */
+               low_bits = (data->low_bits[0]) & 0x03;
+               break;
+       case 1:  /* vin1 */
+               low_bits = ((data->low_bits[0]) & 0x0c) >> 2;
+               break;
+       case 2:  /* vin2 */
+               low_bits = ((data->low_bits[0]) & 0x30) >> 4;
+               break;
+       case 3:  /* vin3 */
+               low_bits = ((data->low_bits[0]) & 0xc0) >> 6;
+               break;
+       case 4:  /* vin4 */
+               low_bits = (data->low_bits[1]) & 0x03;
+               break;
+       case 5:  /* vin5 */
+               low_bits = ((data->low_bits[1]) & 0x0c) >> 2;
+               break;
+       case 6:  /* vin6 */
+               low_bits = ((data->low_bits[1]) & 0x30) >> 4;
+       default:
+               break;
+       }
+       vol_count = vol_count | low_bits;
+       return vol_count;
+}
+
+/* following are the sysfs callback functions */
+static ssize_t show_in(struct device *dev, struct device_attribute *attr,
+                       char *buf)
+{
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
+       struct w83792d_data *data = w83792d_update_device(dev);
+       return sprintf(buf,"%ld\n", IN_FROM_REG(nr,(in_count_from_reg(nr, data))));
+}
+
+#define show_in_reg(reg) \
+static ssize_t show_##reg(struct device *dev, struct device_attribute *attr, \
+                       char *buf) \
+{ \
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \
+       int nr = sensor_attr->index; \
+       struct w83792d_data *data = w83792d_update_device(dev); \
+       return sprintf(buf,"%ld\n", (long)(IN_FROM_REG(nr, (data->reg[nr])*4))); \
+}
+
+show_in_reg(in_min);
+show_in_reg(in_max);
+
+#define store_in_reg(REG, reg) \
+static ssize_t store_in_##reg (struct device *dev, \
+                               struct device_attribute *attr, \
+                               const char *buf, size_t count) \
+{ \
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \
+       int nr = sensor_attr->index; \
+       struct i2c_client *client = to_i2c_client(dev); \
+       struct w83792d_data *data = i2c_get_clientdata(client); \
+       u32 val; \
+        \
+       val = simple_strtoul(buf, NULL, 10); \
+       data->in_##reg[nr] = SENSORS_LIMIT(IN_TO_REG(nr, val)/4, 0, 255); \
+       w83792d_write_value(client, W83792D_REG_IN_##REG[nr], data->in_##reg[nr]); \
+        \
+       return count; \
+}
+store_in_reg(MIN, min);
+store_in_reg(MAX, max);
+
+#define sysfs_in_reg(offset) \
+static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in, \
+                               NULL, offset); \
+static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
+                               show_in_min, store_in_min, offset); \
+static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
+                               show_in_max, store_in_max, offset);
+
+sysfs_in_reg(0);
+sysfs_in_reg(1);
+sysfs_in_reg(2);
+sysfs_in_reg(3);
+sysfs_in_reg(4);
+sysfs_in_reg(5);
+sysfs_in_reg(6);
+sysfs_in_reg(7);
+sysfs_in_reg(8);
+
+#define device_create_file_in(client, offset) \
+do { \
+device_create_file(&client->dev, &sensor_dev_attr_in##offset##_input.dev_attr); \
+device_create_file(&client->dev, &sensor_dev_attr_in##offset##_max.dev_attr); \
+device_create_file(&client->dev, &sensor_dev_attr_in##offset##_min.dev_attr); \
+} while (0)
+
+#define show_fan_reg(reg) \
+static ssize_t show_##reg (struct device *dev, struct device_attribute *attr, \
+                       char *buf) \
+{ \
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \
+       int nr = sensor_attr->index - 1; \
+       struct w83792d_data *data = w83792d_update_device(dev); \
+       return sprintf(buf,"%d\n", \
+               FAN_FROM_REG(data->reg[nr], DIV_FROM_REG(data->fan_div[nr]))); \
+}
+
+show_fan_reg(fan);
+show_fan_reg(fan_min);
+
+static ssize_t
+store_fan_min(struct device *dev, struct device_attribute *attr,
+               const char *buf, size_t count)
+{
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index - 1;
+       struct i2c_client *client = to_i2c_client(dev);
+       struct w83792d_data *data = i2c_get_clientdata(client);
+       u32 val;
+
+       val = simple_strtoul(buf, NULL, 10);
+       data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
+       w83792d_write_value(client, W83792D_REG_FAN_MIN[nr],
+                               data->fan_min[nr]);
+
+       return count;
+}
+
+static ssize_t
+show_fan_div(struct device *dev, struct device_attribute *attr,
+               char *buf)
+{
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
+       struct w83792d_data *data = w83792d_update_device(dev);
+       return sprintf(buf, "%u\n", DIV_FROM_REG(data->fan_div[nr - 1]));
+}
+
+/* Note: we save and restore the fan minimum here, because its value is
+   determined in part by the fan divisor.  This follows the principle of
+   least suprise; the user doesn't expect the fan minimum to change just
+   because the divisor changed. */
+static ssize_t
+store_fan_div(struct device *dev, struct device_attribute *attr,
+               const char *buf, size_t count)
+{
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index - 1;
+       struct i2c_client *client = to_i2c_client(dev);
+       struct w83792d_data *data = i2c_get_clientdata(client);
+       unsigned long min;
+       /*u8 reg;*/
+       u8 fan_div_reg = 0;
+       u8 tmp_fan_div;
+
+       /* Save fan_min */
+       min = FAN_FROM_REG(data->fan_min[nr],
+                          DIV_FROM_REG(data->fan_div[nr]));
+
+       data->fan_div[nr] = DIV_TO_REG(simple_strtoul(buf, NULL, 10));
+
+       fan_div_reg = w83792d_read_value(client, W83792D_REG_FAN_DIV[nr >> 1]);
+       fan_div_reg &= (nr & 0x01) ? 0x8f : 0xf8;
+       tmp_fan_div = (nr & 0x01) ? (((data->fan_div[nr]) << 4) & 0x70)
+                                       : ((data->fan_div[nr]) & 0x07);
+       w83792d_write_value(client, W83792D_REG_FAN_DIV[nr >> 1],
+                                       fan_div_reg | tmp_fan_div);
+
+       /* Restore fan_min */
+       data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
+       w83792d_write_value(client, W83792D_REG_FAN_MIN[nr], data->fan_min[nr]);
+
+       return count;
+}
+
+#define sysfs_fan(offset) \
+static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan, NULL, \
+                               offset); \
+static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
+                               show_fan_div, store_fan_div, offset); \
+static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
+                               show_fan_min, store_fan_min, offset);
+
+sysfs_fan(1);
+sysfs_fan(2);
+sysfs_fan(3);
+sysfs_fan(4);
+sysfs_fan(5);
+sysfs_fan(6);
+sysfs_fan(7);
+
+#define device_create_file_fan(client, offset) \
+do { \
+device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_input.dev_attr); \
+device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_div.dev_attr); \
+device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_min.dev_attr); \
+} while (0)
+
+
+/* read/write the temperature1, includes measured value and limits */
+
+static ssize_t show_temp1(struct device *dev, struct device_attribute *attr,
+                               char *buf)
+{
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
+       struct w83792d_data *data = w83792d_update_device(dev);
+       return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->temp1[nr]));
+}
+
+static ssize_t store_temp1(struct device *dev, struct device_attribute *attr,
+                               const char *buf, size_t count)
+{
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
+       struct i2c_client *client = to_i2c_client(dev);
+       struct w83792d_data *data = i2c_get_clientdata(client);
+       s32 val;
+
+       val = simple_strtol(buf, NULL, 10);
+
+       data->temp1[nr] = TEMP1_TO_REG(val);
+       w83792d_write_value(client, W83792D_REG_TEMP1[nr],
+               data->temp1[nr]);
+
+       return count;
+}
+
+
+static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL, 0);
+static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp1,
+                               store_temp1, 1);
+static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1,
+                               store_temp1, 2);
+
+#define device_create_file_temp1(client) \
+do { \
+device_create_file(&client->dev, &sensor_dev_attr_temp1_input.dev_attr); \
+device_create_file(&client->dev, &sensor_dev_attr_temp1_max.dev_attr); \
+device_create_file(&client->dev, &sensor_dev_attr_temp1_max_hyst.dev_attr); \
+} while (0)
+
+
+/* read/write the temperature2-3, includes measured value and limits */
+
+static ssize_t show_temp23(struct device *dev, struct device_attribute *attr,
+                               char *buf)
+{
+       struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr);
+       int nr = sensor_attr->nr;
+       int index = sensor_attr->index;
+       struct w83792d_data *data = w83792d_update_device(dev);
+       return sprintf(buf,"%ld\n",
+               (long)TEMP_ADD_FROM_REG(data->temp_add[nr][index],
+                       data->temp_add[nr][index+1]));
+}
+
+static ssize_t store_temp23(struct device *dev, struct device_attribute *attr,
+                               const char *buf, size_t count)
+{
+       struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr);
+       int nr = sensor_attr->nr;
+       int index = sensor_attr->index;
+       struct i2c_client *client = to_i2c_client(dev);
+       struct w83792d_data *data = i2c_get_clientdata(client);
+       s32 val;
+
+       val = simple_strtol(buf, NULL, 10);
+
+       data->temp_add[nr][index] = TEMP_ADD_TO_REG_HIGH(val);
+       data->temp_add[nr][index+1] = TEMP_ADD_TO_REG_LOW(val);
+       w83792d_write_value(client, W83792D_REG_TEMP_ADD[nr][index],
+               data->temp_add[nr][index]);
+       w83792d_write_value(client, W83792D_REG_TEMP_ADD[nr][index+1],
+               data->temp_add[nr][index+1]);
+
+       return count;
+}
+
+#define sysfs_temp23(name,idx) \
+static SENSOR_DEVICE_ATTR_2(name##_input, S_IRUGO, show_temp23, NULL, \
+                               idx, 0); \
+static SENSOR_DEVICE_ATTR_2(name##_max, S_IRUGO | S_IWUSR, \
+                               show_temp23, store_temp23, idx, 2); \
+static SENSOR_DEVICE_ATTR_2(name##_max_hyst, S_IRUGO | S_IWUSR, \
+                               show_temp23, store_temp23, idx, 4);
+
+sysfs_temp23(temp2,0)
+sysfs_temp23(temp3,1)
+
+#define device_create_file_temp_add(client, offset) \
+do { \
+device_create_file(&client->dev, &sensor_dev_attr_temp##offset##_input.dev_attr); \
+device_create_file(&client->dev, &sensor_dev_attr_temp##offset##_max.dev_attr); \
+device_create_file(&client->dev, \
+&sensor_dev_attr_temp##offset##_max_hyst.dev_attr); \
+} while (0)
+
+
+/* get reatime status of all sensors items: voltage, temp, fan */
+static ssize_t
+show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct w83792d_data *data = w83792d_update_device(dev);
+       return sprintf(buf, "%d\n", data->alarms);
+}
+
+static
+DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);
+#define device_create_file_alarms(client) \
+device_create_file(&client->dev, &dev_attr_alarms);
+
+
+
+static ssize_t
+show_pwm(struct device *dev, struct device_attribute *attr,
+               char *buf)
+{
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
+       struct w83792d_data *data = w83792d_update_device(dev);
+       return sprintf(buf, "%ld\n", (long) PWM_FROM_REG(data->pwm[nr-1]));
+}
+
+static ssize_t
+show_pwmenable(struct device *dev, struct device_attribute *attr,
+                       char *buf)
+{
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index - 1;
+       struct w83792d_data *data = w83792d_update_device(dev);
+       long pwm_enable_tmp = 1;
+
+       switch (data->pwmenable[nr]) {
+       case 0:
+               pwm_enable_tmp = 1; /* manual mode */
+               break;
+       case 1:
+               pwm_enable_tmp = 3; /*thermal cruise/Smart Fan I */
+               break;
+       case 2:
+               pwm_enable_tmp = 2; /* Smart Fan II */
+               break;
+       }
+
+       return sprintf(buf, "%ld\n", pwm_enable_tmp);
+}
+
+static ssize_t
+store_pwm(struct device *dev, struct device_attribute *attr,
+               const char *buf, size_t count)
+{
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index - 1;
+       struct i2c_client *client = to_i2c_client(dev);
+       struct w83792d_data *data = i2c_get_clientdata(client);
+       u32 val;
+
+       val = simple_strtoul(buf, NULL, 10);
+       data->pwm[nr] = PWM_TO_REG(val);
+       w83792d_write_value(client, W83792D_REG_PWM[nr], data->pwm[nr]);
+
+       return count;
+}
+
+static ssize_t
+store_pwmenable(struct device *dev, struct device_attribute *attr,
+                       const char *buf, size_t count)
+{
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index - 1;
+       struct i2c_client *client = to_i2c_client(dev);
+       struct w83792d_data *data = i2c_get_clientdata(client);
+       u32 val;
+       u8 fan_cfg_tmp, cfg1_tmp, cfg2_tmp, cfg3_tmp, cfg4_tmp;
+
+       val = simple_strtoul(buf, NULL, 10);
+       switch (val) {
+       case 1:
+               data->pwmenable[nr] = 0; /* manual mode */
+               break;
+       case 2:
+               data->pwmenable[nr] = 2; /* Smart Fan II */
+               break;
+       case 3:
+               data->pwmenable[nr] = 1; /* thermal cruise/Smart Fan I */
+               break;
+       default:
+               return -EINVAL;
+       }
+       cfg1_tmp = data->pwmenable[0];
+       cfg2_tmp = (data->pwmenable[1]) << 2;
+       cfg3_tmp = (data->pwmenable[2]) << 4;
+       cfg4_tmp = w83792d_read_value(client,W83792D_REG_FAN_CFG) & 0xc0;
+       fan_cfg_tmp = ((cfg4_tmp | cfg3_tmp) | cfg2_tmp) | cfg1_tmp;
+       w83792d_write_value(client, W83792D_REG_FAN_CFG, fan_cfg_tmp);
+
+       return count;
+}
+
+#define sysfs_pwm(offset) \
+static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \
+                               show_pwm, store_pwm, offset); \
+static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \
+                               show_pwmenable, store_pwmenable, offset); \
+
+sysfs_pwm(1);
+sysfs_pwm(2);
+sysfs_pwm(3);
+
+
+#define device_create_file_pwm(client, offset) \
+do { \
+device_create_file(&client->dev, &sensor_dev_attr_pwm##offset.dev_attr); \
+} while (0)
+
+#define device_create_file_pwmenable(client, offset) \
+do { \
+device_create_file(&client->dev, &sensor_dev_attr_pwm##offset##_enable.dev_attr); \
+} while (0)
+
+
+static ssize_t
+show_pwm_mode(struct device *dev, struct device_attribute *attr,
+                       char *buf)
+{
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
+       struct w83792d_data *data = w83792d_update_device(dev);
+       return sprintf(buf, "%d\n", data->pwm_mode[nr-1]);
+}
+
+static ssize_t
+store_pwm_mode(struct device *dev, struct device_attribute *attr,
+                       const char *buf, size_t count)
+{
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index - 1;
+       struct i2c_client *client = to_i2c_client(dev);
+       struct w83792d_data *data = i2c_get_clientdata(client);
+       u32 val;
+       u8 pwm_mode_mask = 0;
+
+       val = simple_strtoul(buf, NULL, 10);
+       data->pwm_mode[nr] = SENSORS_LIMIT(val, 0, 1);
+       pwm_mode_mask = w83792d_read_value(client,
+               W83792D_REG_PWM[nr]) & 0x7f;
+       w83792d_write_value(client, W83792D_REG_PWM[nr],
+               ((data->pwm_mode[nr]) << 7) | pwm_mode_mask);
+
+       return count;
+}
+
+#define sysfs_pwm_mode(offset) \
+static SENSOR_DEVICE_ATTR(pwm##offset##_mode, S_IRUGO | S_IWUSR, \
+                               show_pwm_mode, store_pwm_mode, offset);
+
+sysfs_pwm_mode(1);
+sysfs_pwm_mode(2);
+sysfs_pwm_mode(3);
+
+#define device_create_file_pwm_mode(client, offset) \
+do { \
+device_create_file(&client->dev, &sensor_dev_attr_pwm##offset##_mode.dev_attr); \
+} while (0)
+
+
+static ssize_t
+show_regs_chassis(struct device *dev, struct device_attribute *attr,
+                       char *buf)
+{
+       struct w83792d_data *data = w83792d_update_device(dev);
+       return sprintf(buf, "%d\n", data->chassis);
+}
+
+static DEVICE_ATTR(chassis, S_IRUGO, show_regs_chassis, NULL);
+
+#define device_create_file_chassis(client) \
+do { \
+device_create_file(&client->dev, &dev_attr_chassis); \
+} while (0)
+
+
+static ssize_t
+show_chassis_clear(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct w83792d_data *data = w83792d_update_device(dev);
+       return sprintf(buf, "%d\n", data->chassis_clear);
+}
+
+static ssize_t
+store_chassis_clear(struct device *dev, struct device_attribute *attr,
+                       const char *buf, size_t count)
+{
+       struct i2c_client *client = to_i2c_client(dev);
+       struct w83792d_data *data = i2c_get_clientdata(client);
+       u32 val;
+       u8 temp1 = 0, temp2 = 0;
+
+       val = simple_strtoul(buf, NULL, 10);
+
+       data->chassis_clear = SENSORS_LIMIT(val, 0 ,1);
+       temp1 = ((data->chassis_clear) << 7) & 0x80;
+       temp2 = w83792d_read_value(client,
+               W83792D_REG_CHASSIS_CLR) & 0x7f;
+       w83792d_write_value(client, W83792D_REG_CHASSIS_CLR, temp1 | temp2);
+
+       return count;
+}
+
+static DEVICE_ATTR(chassis_clear, S_IRUGO | S_IWUSR,
+               show_chassis_clear, store_chassis_clear);
+
+#define device_create_file_chassis_clear(client) \
+do { \
+device_create_file(&client->dev, &dev_attr_chassis_clear); \
+} while (0)
+
+
+
+/* For Smart Fan I / Thermal Cruise */
+static ssize_t
+show_thermal_cruise(struct device *dev, struct device_attribute *attr,
+                       char *buf)
+{
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
+       struct w83792d_data *data = w83792d_update_device(dev);
+       return sprintf(buf, "%ld\n", (long)data->thermal_cruise[nr-1]);
+}
+
+static ssize_t
+store_thermal_cruise(struct device *dev, struct device_attribute *attr,
+                       const char *buf, size_t count)
+{
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index - 1;
+       struct i2c_client *client = to_i2c_client(dev);
+       struct w83792d_data *data = i2c_get_clientdata(client);
+       u32 val;
+       u8 target_tmp=0, target_mask=0;
+
+       val = simple_strtoul(buf, NULL, 10);
+       target_tmp = val;
+       target_tmp = target_tmp & 0x7f;
+       target_mask = w83792d_read_value(client, W83792D_REG_THERMAL[nr]) & 0x80;
+       data->thermal_cruise[nr] = SENSORS_LIMIT(target_tmp, 0, 255);
+       w83792d_write_value(client, W83792D_REG_THERMAL[nr],
+               (data->thermal_cruise[nr]) | target_mask);
+
+       return count;
+}
+
+#define sysfs_thermal_cruise(offset) \
+static SENSOR_DEVICE_ATTR(thermal_cruise##offset, S_IRUGO | S_IWUSR, \
+                       show_thermal_cruise, store_thermal_cruise, offset);
+
+sysfs_thermal_cruise(1);
+sysfs_thermal_cruise(2);
+sysfs_thermal_cruise(3);
+
+#define device_create_file_thermal_cruise(client, offset) \
+do { \
+device_create_file(&client->dev, \
+&sensor_dev_attr_thermal_cruise##offset.dev_attr); \
+} while (0)
+
+
+/* For Smart Fan I/Thermal Cruise and Smart Fan II */
+static ssize_t
+show_tolerance(struct device *dev, struct device_attribute *attr,
+               char *buf)
+{
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index;
+       struct w83792d_data *data = w83792d_update_device(dev);
+       return sprintf(buf, "%ld\n", (long)data->tolerance[nr-1]);
+}
+
+static ssize_t
+store_tolerance(struct device *dev, struct device_attribute *attr,
+               const char *buf, size_t count)
+{
+       struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+       int nr = sensor_attr->index - 1;
+       struct i2c_client *client = to_i2c_client(dev);
+       struct w83792d_data *data = i2c_get_clientdata(client);
+       u32 val;
+       u8 tol_tmp, tol_mask;
+
+       val = simple_strtoul(buf, NULL, 10);
+       tol_mask = w83792d_read_value(client,
+               W83792D_REG_TOLERANCE[nr]) & ((nr == 1) ? 0x0f : 0xf0);
+       tol_tmp = SENSORS_LIMIT(val, 0, 15);
+       tol_tmp &= 0x0f;
+       data->tolerance[nr] = tol_tmp;
+       if (nr == 1) {
+               tol_tmp <<= 4;
+       }
+       w83792d_write_value(client, W83792D_REG_TOLERANCE[nr],
+               tol_mask | tol_tmp);
+
+       return count;
+}
+
+#define sysfs_tolerance(offset) \
+static SENSOR_DEVICE_ATTR(tolerance##offset, S_IRUGO | S_IWUSR, \
+                               show_tolerance, store_tolerance, offset);
+
+sysfs_tolerance(1);
+sysfs_tolerance(2);
+sysfs_tolerance(3);
+
+#define device_create_file_tolerance(client, offset) \
+do { \
+device_create_file(&client->dev, &sensor_dev_attr_tolerance##offset.dev_attr); \
+} while (0)
+
+
+/* For Smart Fan II */
+static ssize_t
+show_sf2_point(struct device *dev, struct device_attribute *attr,
+               char *buf)
+{
+       struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr);
+       int nr = sensor_attr->nr;
+       int index = sensor_attr->index;
+       struct w83792d_data *data = w83792d_update_device(dev);
+       return sprintf(buf, "%ld\n", (long)data->sf2_points[index-1][nr-1]);
+}
+
+static ssize_t
+store_sf2_point(struct device *dev, struct device_attribute *attr,
+               const char *buf, size_t count)
+{
+       struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr);
+       int nr = sensor_attr->nr - 1;
+       int index = sensor_attr->index - 1;
+       struct i2c_client *client = to_i2c_client(dev);
+       struct w83792d_data *data = i2c_get_clientdata(client);
+       u32 val;
+       u8 mask_tmp = 0;
+
+       val = simple_strtoul(buf, NULL, 10);
+       data->sf2_points[index][nr] = SENSORS_LIMIT(val, 0, 127);
+       mask_tmp = w83792d_read_value(client,
+                                       W83792D_REG_POINTS[index][nr]) & 0x80;
+       w83792d_write_value(client, W83792D_REG_POINTS[index][nr],
+               mask_tmp|data->sf2_points[index][nr]);
+
+       return count;
+}
+
+#define sysfs_sf2_point(offset, index) \
+static SENSOR_DEVICE_ATTR_2(sf2_point##offset##_fan##index, S_IRUGO | S_IWUSR, \
+                               show_sf2_point, store_sf2_point, offset, index);
+
+sysfs_sf2_point(1, 1); /* Fan1 */
+sysfs_sf2_point(2, 1); /* Fan1 */
+sysfs_sf2_point(3, 1); /* Fan1 */
+sysfs_sf2_point(4, 1); /* Fan1 */
+sysfs_sf2_point(1, 2); /* Fan2 */
+sysfs_sf2_point(2, 2); /* Fan2 */
+sysfs_sf2_point(3, 2); /* Fan2 */
+sysfs_sf2_point(4, 2); /* Fan2 */
+sysfs_sf2_point(1, 3); /* Fan3 */
+sysfs_sf2_point(2, 3); /* Fan3 */
+sysfs_sf2_point(3, 3); /* Fan3 */
+sysfs_sf2_point(4, 3); /* Fan3 */
+
+#define device_create_file_sf2_point(client, offset, index) \
+do { \
+device_create_file(&client->dev, \
+&sensor_dev_attr_sf2_point##offset##_fan##index.dev_attr); \
+} while (0)
+
+
+static ssize_t
+show_sf2_level(struct device *dev, struct device_attribute *attr,
+               char *buf)
+{
+       struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr);
+       int nr = sensor_attr->nr;
+       int index = sensor_attr->index;
+       struct w83792d_data *data = w83792d_update_device(dev);
+       return sprintf(buf, "%d\n",
+                       (((data->sf2_levels[index-1][nr]) * 100) / 15));
+}
+
+static ssize_t
+store_sf2_level(struct device *dev, struct device_attribute *attr,
+               const char *buf, size_t count)
+{
+       struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr);
+       int nr = sensor_attr->nr;
+       int index = sensor_attr->index - 1;
+       struct i2c_client *client = to_i2c_client(dev);
+       struct w83792d_data *data = i2c_get_clientdata(client);
+       u32 val;
+       u8 mask_tmp=0, level_tmp=0;
+
+       val = simple_strtoul(buf, NULL, 10);
+       data->sf2_levels[index][nr] = SENSORS_LIMIT((val * 15) / 100, 0, 15);
+       mask_tmp = w83792d_read_value(client, W83792D_REG_LEVELS[index][nr])
+               & ((nr==3) ? 0xf0 : 0x0f);
+       if (nr==3) {
+               level_tmp = data->sf2_levels[index][nr];
+       } else {
+               level_tmp = data->sf2_levels[index][nr] << 4;
+       }
+       w83792d_write_value(client, W83792D_REG_LEVELS[index][nr], level_tmp | mask_tmp);
+
+       return count;
+}
+
+#define sysfs_sf2_level(offset, index) \
+static SENSOR_DEVICE_ATTR_2(sf2_level##offset##_fan##index, S_IRUGO | S_IWUSR, \
+                               show_sf2_level, store_sf2_level, offset, index);
+
+sysfs_sf2_level(1, 1); /* Fan1 */
+sysfs_sf2_level(2, 1); /* Fan1 */
+sysfs_sf2_level(3, 1); /* Fan1 */
+sysfs_sf2_level(1, 2); /* Fan2 */
+sysfs_sf2_level(2, 2); /* Fan2 */
+sysfs_sf2_level(3, 2); /* Fan2 */
+sysfs_sf2_level(1, 3); /* Fan3 */
+sysfs_sf2_level(2, 3); /* Fan3 */
+sysfs_sf2_level(3, 3); /* Fan3 */
+
+#define device_create_file_sf2_level(client, offset, index) \
+do { \
+device_create_file(&client->dev, \
+&sensor_dev_attr_sf2_level##offset##_fan##index.dev_attr); \
+} while (0)
+
+
+/* This function is called when:
+     * w83792d_driver is inserted (when this module is loaded), for each
+       available adapter
+     * when a new adapter is inserted (and w83792d_driver is still present) */
+static int
+w83792d_attach_adapter(struct i2c_adapter *adapter)
+{
+       if (!(adapter->class & I2C_CLASS_HWMON))
+               return 0;
+       return i2c_probe(adapter, &addr_data, w83792d_detect);
+}
+
+
+static int
+w83792d_create_subclient(struct i2c_adapter *adapter,
+                               struct i2c_client *new_client, int addr,
+                               struct i2c_client **sub_cli)
+{
+       int err;
+       struct i2c_client *sub_client;
+
+       (*sub_cli) = sub_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
+       if (!(sub_client)) {
+               return -ENOMEM;
+       }
+       memset(sub_client, 0x00, sizeof(struct i2c_client));
+       sub_client->addr = 0x48 + addr;
+       i2c_set_clientdata(sub_client, NULL);
+       sub_client->adapter = adapter;
+       sub_client->driver = &w83792d_driver;
+       sub_client->flags = 0;
+       strlcpy(sub_client->name, "w83792d subclient", I2C_NAME_SIZE);
+       if ((err = i2c_attach_client(sub_client))) {
+               dev_err(&new_client->dev, "subclient registration "
+                       "at address 0x%x failed\n", sub_client->addr);
+               kfree(sub_client);
+               return err;
+       }
+       return 0;
+}
+
+
+static int
+w83792d_detect_subclients(struct i2c_adapter *adapter, int address, int kind,
+               struct i2c_client *new_client)
+{
+       int i, id, err;
+       u8 val;
+       struct w83792d_data *data = i2c_get_clientdata(new_client);
+
+       id = i2c_adapter_id(adapter);
+       if (force_subclients[0] == id && force_subclients[1] == address) {
+               for (i = 2; i <= 3; i++) {
+                       if (force_subclients[i] < 0x48 ||
+                           force_subclients[i] > 0x4f) {
+                               dev_err(&new_client->dev, "invalid subclient "
+                                       "address %d; must be 0x48-0x4f\n",
+                                       force_subclients[i]);
+                               err = -ENODEV;
+                               goto ERROR_SC_0;
+                       }
+               }
+               w83792d_write_value(new_client, W83792D_REG_I2C_SUBADDR,
+                                       (force_subclients[2] & 0x07) |
+                                       ((force_subclients[3] & 0x07) << 4));
+       }
+
+       val = w83792d_read_value(new_client, W83792D_REG_I2C_SUBADDR);
+       if (!(val & 0x08)) {
+               err = w83792d_create_subclient(adapter, new_client, val & 0x7,
+                                               &data->lm75[0]);
+               if (err < 0)
+                       goto ERROR_SC_0;
+       }
+       if (!(val & 0x80)) {
+               if ((data->lm75[0] != NULL) &&
+                       ((val & 0x7) == ((val >> 4) & 0x7))) {
+                       dev_err(&new_client->dev, "duplicate addresses 0x%x, "
+                               "use force_subclient\n", data->lm75[0]->addr);
+                       err = -ENODEV;
+                       goto ERROR_SC_1;
+               }
+               err = w83792d_create_subclient(adapter, new_client,
+                                               (val >> 4) & 0x7, &data->lm75[1]);
+               if (err < 0)
+                       goto ERROR_SC_1;
+       }
+
+       return 0;
+
+/* Undo inits in case of errors */
+
+ERROR_SC_1:
+       if (data->lm75[0] != NULL) {
+               i2c_detach_client(data->lm75[0]);
+               kfree(data->lm75[0]);
+       }
+ERROR_SC_0:
+       return err;
+}
+
+
+static int
+w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
+{
+       int i = 0, val1 = 0, val2;
+       struct i2c_client *new_client;
+       struct w83792d_data *data;
+       int err = 0;
+       const char *client_name = "";
+
+       if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
+               goto ERROR0;
+       }
+
+       /* OK. For now, we presume we have a valid client. We now create the
+          client structure, even though we cannot fill it completely yet.
+          But it allows us to access w83792d_{read,write}_value. */
+
+       if (!(data = kmalloc(sizeof(struct w83792d_data), GFP_KERNEL))) {
+               err = -ENOMEM;
+               goto ERROR0;
+       }
+       memset(data, 0, sizeof(struct w83792d_data));
+
+       new_client = &data->client;
+       i2c_set_clientdata(new_client, data);
+       new_client->addr = address;
+       init_MUTEX(&data->lock);
+       new_client->adapter = adapter;
+       new_client->driver = &w83792d_driver;
+       new_client->flags = 0;
+
+       /* Now, we do the remaining detection. */
+
+       /* The w83792d may be stuck in some other bank than bank 0. This may
+          make reading other information impossible. Specify a force=... or
+          force_*=... parameter, and the Winbond will be reset to the right
+          bank. */
+       if (kind < 0) {
+               if (w83792d_read_value(new_client, W83792D_REG_CONFIG) & 0x80) {
+                       dev_warn(&new_client->dev, "Detection failed at step "
+                               "3\n");
+                       goto ERROR1;
+               }
+               val1 = w83792d_read_value(new_client, W83792D_REG_BANK);
+               val2 = w83792d_read_value(new_client, W83792D_REG_CHIPMAN);
+               /* Check for Winbond ID if in bank 0 */
+               if (!(val1 & 0x07)) {  /* is Bank0 */
+                       if (((!(val1 & 0x80)) && (val2 != 0xa3)) ||
+                            ((val1 & 0x80) && (val2 != 0x5c))) {
+                               goto ERROR1;
+                       }
+               }
+               /* If Winbond chip, address of chip and W83792D_REG_I2C_ADDR
+                  should match */
+               if (w83792d_read_value(new_client,
+                                       W83792D_REG_I2C_ADDR) != address) {
+                       dev_warn(&new_client->dev, "Detection failed "
+                               "at step 5\n");
+                       goto ERROR1;
+               }
+       }
+
+       /* We have either had a force parameter, or we have already detected the
+          Winbond. Put it now into bank 0 and Vendor ID High Byte */
+       w83792d_write_value(new_client,
+                           W83792D_REG_BANK,
+                           (w83792d_read_value(new_client,
+                               W83792D_REG_BANK) & 0x78) | 0x80);
+
+       /* Determine the chip type. */
+       if (kind <= 0) {
+               /* get vendor ID */
+               val2 = w83792d_read_value(new_client, W83792D_REG_CHIPMAN);
+               if (val2 != 0x5c) {  /* the vendor is NOT Winbond */
+                       goto ERROR1;
+               }
+               val1 = w83792d_read_value(new_client, W83792D_REG_WCHIPID);
+               if (val1 == 0x7a && address >= 0x2c) {
+                       kind = w83792d;
+               } else {
+                       if (kind == 0)
+                                       dev_warn(&new_client->dev,
+                                       "w83792d: Ignoring 'force' parameter for"
+                                       " unknown chip at adapter %d, address"
+                                       " 0x%02x\n", i2c_adapter_id(adapter),
+                                       address);
+                       goto ERROR1;
+               }
+       }
+
+       if (kind == w83792d) {
+               client_name = "w83792d";
+       } else {
+               dev_err(&new_client->dev, "w83792d: Internal error: unknown"
+                                         " kind (%d)?!?", kind);
+               goto ERROR1;
+       }
+
+       /* Fill in the remaining client fields and put into the global list */
+       strlcpy(new_client->name, client_name, I2C_NAME_SIZE);
+       data->type = kind;
+
+       data->valid = 0;
+       init_MUTEX(&data->update_lock);
+
+       /* Tell the I2C layer a new client has arrived */
+       if ((err = i2c_attach_client(new_client)))
+               goto ERROR1;
+
+       if ((err = w83792d_detect_subclients(adapter, address,
+                       kind, new_client)))
+               goto ERROR2;
+
+       /* Initialize the chip */
+       w83792d_init_client(new_client);
+
+       /* A few vars need to be filled upon startup */
+       for (i = 1; i <= 7; i++) {
+               data->fan_min[i - 1] = w83792d_read_value(new_client,
+                                       W83792D_REG_FAN_MIN[i]);
+       }
+
+       /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto ERROR3;
+       }
+       device_create_file_in(new_client, 0);
+       device_create_file_in(new_client, 1);
+       device_create_file_in(new_client, 2);
+       device_create_file_in(new_client, 3);
+       device_create_file_in(new_client, 4);
+       device_create_file_in(new_client, 5);
+       device_create_file_in(new_client, 6);
+       device_create_file_in(new_client, 7);
+       device_create_file_in(new_client, 8);
+
+       device_create_file_fan(new_client, 1);
+       device_create_file_fan(new_client, 2);
+       device_create_file_fan(new_client, 3);
+       device_create_file_fan(new_client, 4);
+       device_create_file_fan(new_client, 5);
+       device_create_file_fan(new_client, 6);
+       device_create_file_fan(new_client, 7);
+
+       device_create_file_temp1(new_client);           /* Temp1 */
+       device_create_file_temp_add(new_client, 2);     /* Temp2 */
+       device_create_file_temp_add(new_client, 3);     /* Temp3 */
+
+       device_create_file_alarms(new_client);
+
+       device_create_file_pwm(new_client, 1);
+       device_create_file_pwm(new_client, 2);
+       device_create_file_pwm(new_client, 3);
+
+       device_create_file_pwmenable(new_client, 1);
+       device_create_file_pwmenable(new_client, 2);
+       device_create_file_pwmenable(new_client, 3);
+
+       device_create_file_pwm_mode(new_client, 1);
+       device_create_file_pwm_mode(new_client, 2);
+       device_create_file_pwm_mode(new_client, 3);
+
+       device_create_file_chassis(new_client);
+       device_create_file_chassis_clear(new_client);
+
+       device_create_file_thermal_cruise(new_client, 1);
+       device_create_file_thermal_cruise(new_client, 2);
+       device_create_file_thermal_cruise(new_client, 3);
+
+       device_create_file_tolerance(new_client, 1);
+       device_create_file_tolerance(new_client, 2);
+       device_create_file_tolerance(new_client, 3);
+
+       device_create_file_sf2_point(new_client, 1, 1); /* Fan1 */
+       device_create_file_sf2_point(new_client, 2, 1); /* Fan1 */
+       device_create_file_sf2_point(new_client, 3, 1); /* Fan1 */
+       device_create_file_sf2_point(new_client, 4, 1); /* Fan1 */
+       device_create_file_sf2_point(new_client, 1, 2); /* Fan2 */
+       device_create_file_sf2_point(new_client, 2, 2); /* Fan2 */
+       device_create_file_sf2_point(new_client, 3, 2); /* Fan2 */
+       device_create_file_sf2_point(new_client, 4, 2); /* Fan2 */
+       device_create_file_sf2_point(new_client, 1, 3); /* Fan3 */
+       device_create_file_sf2_point(new_client, 2, 3); /* Fan3 */
+       device_create_file_sf2_point(new_client, 3, 3); /* Fan3 */
+       device_create_file_sf2_point(new_client, 4, 3); /* Fan3 */
+
+       device_create_file_sf2_level(new_client, 1, 1); /* Fan1 */
+       device_create_file_sf2_level(new_client, 2, 1); /* Fan1 */
+       device_create_file_sf2_level(new_client, 3, 1); /* Fan1 */
+       device_create_file_sf2_level(new_client, 1, 2); /* Fan2 */
+       device_create_file_sf2_level(new_client, 2, 2); /* Fan2 */
+       device_create_file_sf2_level(new_client, 3, 2); /* Fan2 */
+       device_create_file_sf2_level(new_client, 1, 3); /* Fan3 */
+       device_create_file_sf2_level(new_client, 2, 3); /* Fan3 */
+       device_create_file_sf2_level(new_client, 3, 3); /* Fan3 */
+
+       return 0;
+
+ERROR3:
+       if (data->lm75[0] != NULL) {
+               i2c_detach_client(data->lm75[0]);
+               kfree(data->lm75[0]);
+       }
+       if (data->lm75[1] != NULL) {
+               i2c_detach_client(data->lm75[1]);
+               kfree(data->lm75[1]);
+       }
+ERROR2:
+       i2c_detach_client(new_client);
+ERROR1:
+       kfree(data);
+ERROR0:
+       return err;
+}
+
+static int
+w83792d_detach_client(struct i2c_client *client)
+{
+       struct w83792d_data *data = i2c_get_clientdata(client);
+       int err;
+
+       /* main client */
+       if (data)
+               hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
+               return err;
+
+       /* main client */
+       if (data)
+               kfree(data);
+       /* subclient */
+       else
+               kfree(client);
+
+       return 0;
+}
+
+/* The SMBus locks itself, usually, but nothing may access the Winbond between
+   bank switches. ISA access must always be locked explicitly!
+   We ignore the W83792D BUSY flag at this moment - it could lead to deadlocks,
+   would slow down the W83792D access and should not be necessary.
+   There are some ugly typecasts here, but the good news is - they should
+   nowhere else be necessary! */
+static int
+w83792d_read_value(struct i2c_client *client, u8 reg)
+{
+       int res=0;
+       res = i2c_smbus_read_byte_data(client, reg);
+
+       return res;
+}
+
+static int
+w83792d_write_value(struct i2c_client *client, u8 reg, u8 value)
+{
+       i2c_smbus_write_byte_data(client, reg,  value);
+       return 0;
+}
+
+/* Called when we have found a new W83792D. It should set limits, etc. */
+static void
+w83792d_init_client(struct i2c_client *client)
+{
+       u8 temp2_cfg, temp3_cfg, vid_in_b;
+
+       if (init) {
+               w83792d_write_value(client, W83792D_REG_CONFIG, 0x80);
+       }
+       /* Clear the bit6 of W83792D_REG_VID_IN_B(set it into 0):
+          W83792D_REG_VID_IN_B bit6 = 0: the high/low limit of
+            vin0/vin1 can be modified by user;
+          W83792D_REG_VID_IN_B bit6 = 1: the high/low limit of
+            vin0/vin1 auto-updated, can NOT be modified by user. */
+       vid_in_b = w83792d_read_value(client, W83792D_REG_VID_IN_B);
+       w83792d_write_value(client, W83792D_REG_VID_IN_B,
+                           vid_in_b & 0xbf);
+
+       temp2_cfg = w83792d_read_value(client, W83792D_REG_TEMP2_CONFIG);
+       temp3_cfg = w83792d_read_value(client, W83792D_REG_TEMP3_CONFIG);
+       w83792d_write_value(client, W83792D_REG_TEMP2_CONFIG,
+                               temp2_cfg & 0xe6);
+       w83792d_write_value(client, W83792D_REG_TEMP3_CONFIG,
+                               temp3_cfg & 0xe6);
+
+       /* Start monitoring */
+       w83792d_write_value(client, W83792D_REG_CONFIG,
+                           (w83792d_read_value(client,
+                                               W83792D_REG_CONFIG) & 0xf7)
+                           | 0x01);
+}
+
+static struct w83792d_data *w83792d_update_device(struct device *dev)
+{
+       struct i2c_client *client = to_i2c_client(dev);
+       struct w83792d_data *data = i2c_get_clientdata(client);
+       int i, j;
+       u8 reg_array_tmp[4], pwm_array_tmp[7], reg_tmp;
+
+       down(&data->update_lock);
+
+       if (time_after
+           (jiffies - data->last_updated, (unsigned long) (HZ * 3))
+           || time_before(jiffies, data->last_updated) || !data->valid) {
+               dev_dbg(dev, "Starting device update\n");
+
+               /* Update the voltages measured value and limits */
+               for (i = 0; i < 9; i++) {
+                       data->in[i] = w83792d_read_value(client,
+                                               W83792D_REG_IN[i]);
+                       data->in_max[i] = w83792d_read_value(client,
+                                               W83792D_REG_IN_MAX[i]);
+                       data->in_min[i] = w83792d_read_value(client,
+                                               W83792D_REG_IN_MIN[i]);
+               }
+               data->low_bits[0] = w83792d_read_value(client,
+                                               W83792D_REG_LOW_BITS1);
+               data->low_bits[1] = w83792d_read_value(client,
+                                               W83792D_REG_LOW_BITS2);
+               for (i = 0; i < 7; i++) {
+                       /* Update the Fan measured value and limits */
+                       data->fan[i] = w83792d_read_value(client,
+                                               W83792D_REG_FAN[i]);
+                       data->fan_min[i] = w83792d_read_value(client,
+                                               W83792D_REG_FAN_MIN[i]);
+                       /* Update the PWM/DC Value and PWM/DC flag */
+                       pwm_array_tmp[i] = w83792d_read_value(client,
+                                               W83792D_REG_PWM[i]);
+                       data->pwm[i] = pwm_array_tmp[i] & 0x0f;
+                       data->pwm_mode[i] = (pwm_array_tmp[i] >> 7) & 0x01;
+               }
+
+               reg_tmp = w83792d_read_value(client, W83792D_REG_FAN_CFG);
+               data->pwmenable[0] = reg_tmp & 0x03;
+               data->pwmenable[1] = (reg_tmp>>2) & 0x03;
+               data->pwmenable[2] = (reg_tmp>>4) & 0x03;
+
+               for (i = 0; i < 3; i++) {
+                       data->temp1[i] = w83792d_read_value(client,
+                                                       W83792D_REG_TEMP1[i]);
+               }
+               for (i = 0; i < 2; i++) {
+                       for (j = 0; j < 6; j++) {
+                               data->temp_add[i][j] = w83792d_read_value(
+                                       client,W83792D_REG_TEMP_ADD[i][j]);
+                       }
+               }
+
+               /* Update the Fan Divisor */
+               for (i = 0; i < 4; i++) {
+                       reg_array_tmp[i] = w83792d_read_value(client,
+                                                       W83792D_REG_FAN_DIV[i]);
+               }
+               data->fan_div[0] = reg_array_tmp[0] & 0x07;
+               data->fan_div[1] = (reg_array_tmp[0] >> 4) & 0x07;
+               data->fan_div[2] = reg_array_tmp[1] & 0x07;
+               data->fan_div[3] = (reg_array_tmp[1] >> 4) & 0x07;
+               data->fan_div[4] = reg_array_tmp[2] & 0x07;
+               data->fan_div[5] = (reg_array_tmp[2] >> 4) & 0x07;
+               data->fan_div[6] = reg_array_tmp[3] & 0x07;
+
+               /* Update the realtime status */
+               data->alarms = w83792d_read_value(client, W83792D_REG_ALARM1) +
+                       (w83792d_read_value(client, W83792D_REG_ALARM2) << 8) +
+                       (w83792d_read_value(client, W83792D_REG_ALARM3) << 16);
+
+               /* Update CaseOpen status and it's CLR_CHS. */
+               data->chassis = (w83792d_read_value(client,
+                       W83792D_REG_CHASSIS) >> 5) & 0x01;
+               data->chassis_clear = (w83792d_read_value(client,
+                       W83792D_REG_CHASSIS_CLR) >> 7) & 0x01;
+
+               /* Update Thermal Cruise/Smart Fan I target value */
+               for (i = 0; i < 3; i++) {
+                       data->thermal_cruise[i] =
+                               w83792d_read_value(client,
+                               W83792D_REG_THERMAL[i]) & 0x7f;
+               }
+
+               /* Update Smart Fan I/II tolerance */
+               reg_tmp = w83792d_read_value(client, W83792D_REG_TOLERANCE[0]);
+               data->tolerance[0] = reg_tmp & 0x0f;
+               data->tolerance[1] = (reg_tmp >> 4) & 0x0f;
+               data->tolerance[2] = w83792d_read_value(client,
+                                       W83792D_REG_TOLERANCE[2]) & 0x0f;
+
+               /* Update Smart Fan II temperature points */
+               for (i = 0; i < 3; i++) {
+                       for (j = 0; j < 4; j++) {
+                               data->sf2_points[i][j] = w83792d_read_value(
+                                       client,W83792D_REG_POINTS[i][j]) & 0x7f;
+                       }
+               }
+
+               /* Update Smart Fan II duty cycle levels */
+               for (i = 0; i < 3; i++) {
+                       reg_tmp = w83792d_read_value(client,
+                                               W83792D_REG_LEVELS[i][0]);
+                       data->sf2_levels[i][0] = reg_tmp & 0x0f;
+                       data->sf2_levels[i][1] = (reg_tmp >> 4) & 0x0f;
+                       reg_tmp = w83792d_read_value(client,
+                                               W83792D_REG_LEVELS[i][2]);
+                       data->sf2_levels[i][2] = (reg_tmp >> 4) & 0x0f;
+                       data->sf2_levels[i][3] = reg_tmp & 0x0f;
+               }
+
+               data->last_updated = jiffies;
+               data->valid = 1;
+       }
+
+       up(&data->update_lock);
+
+#ifdef DEBUG
+       w83792d_print_debug(data, dev);
+#endif
+
+       return data;
+}
+
+#ifdef DEBUG
+static void w83792d_print_debug(struct w83792d_data *data, struct device *dev)
+{
+       int i=0, j=0;
+       dev_dbg(dev, "==========The following is the debug message...========\n");
+       dev_dbg(dev, "9 set of Voltages: =====>\n");
+       for (i=0; i<9; i++) {
+               dev_dbg(dev, "vin[%d] is: 0x%x\n", i, data->in[i]);
+               dev_dbg(dev, "vin[%d] max is: 0x%x\n", i, data->in_max[i]);
+               dev_dbg(dev, "vin[%d] min is: 0x%x\n", i, data->in_min[i]);
+       }
+       dev_dbg(dev, "Low Bit1 is: 0x%x\n", data->low_bits[0]);
+       dev_dbg(dev, "Low Bit2 is: 0x%x\n", data->low_bits[1]);
+       dev_dbg(dev, "7 set of Fan Counts and Duty Cycles: =====>\n");
+       for (i=0; i<7; i++) {
+               dev_dbg(dev, "fan[%d] is: 0x%x\n", i, data->fan[i]);
+               dev_dbg(dev, "fan[%d] min is: 0x%x\n", i, data->fan_min[i]);
+               dev_dbg(dev, "pwm[%d]     is: 0x%x\n", i, data->pwm[i]);
+               dev_dbg(dev, "pwm_mode[%d] is: 0x%x\n", i, data->pwm_mode[i]);
+       }
+       dev_dbg(dev, "3 set of Temperatures: =====>\n");
+       for (i=0; i<3; i++) {
+               dev_dbg(dev, "temp1[%d] is: 0x%x\n", i, data->temp1[i]);
+       }
+
+       for (i=0; i<2; i++) {
+               for (j=0; j<6; j++) {
+                       dev_dbg(dev, "temp_add[%d][%d] is: 0x%x\n", i, j,
+                                                       data->temp_add[i][j]);
+               }
+       }
+
+       for (i=0; i<7; i++) {
+               dev_dbg(dev, "fan_div[%d] is: 0x%x\n", i, data->fan_div[i]);
+       }
+       dev_dbg(dev, "==========End of the debug message...==================\n");
+       dev_dbg(dev, "\n");
+}
+#endif
+
+static int __init
+sensors_w83792d_init(void)
+{
+       return i2c_add_driver(&w83792d_driver);
+}
+
+static void __exit
+sensors_w83792d_exit(void)
+{
+       i2c_del_driver(&w83792d_driver);
+}
+
+MODULE_AUTHOR("Chunhao Huang @ Winbond <DZShen@Winbond.com.tw>");
+MODULE_DESCRIPTION("W83792AD/D driver for linux-2.6");
+MODULE_LICENSE("GPL");
+
+module_init(sensors_w83792d_init);
+module_exit(sensors_w83792d_exit);
+
index 4469d52aba4c6faefa0bc3047b379ad614eea6d3..133e34ab1d0af1a1ab0b965ca58fb59c554d6d11 100644 (file)
@@ -36,7 +36,8 @@
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
 
 /* How many retries on register read error */
 #define MAX_RETRIES    5
  */
 
 static unsigned short normal_i2c[] = { 0x2e, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /*
  * Insmod parameters
  */
 
-SENSORS_INSMOD_1(w83l785ts);
+I2C_CLIENT_INSMOD_1(w83l785ts);
 
 /*
  * The W83L785TS-S registers
@@ -105,6 +105,7 @@ static struct i2c_driver w83l785ts_driver = {
 
 struct w83l785ts_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore update_lock;
        char valid; /* zero until following fields are valid */
        unsigned long last_updated; /* in jiffies */
@@ -140,7 +141,7 @@ static int w83l785ts_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, w83l785ts_detect);
+       return i2c_probe(adapter, &addr_data, w83l785ts_detect);
 }
 
 /*
@@ -239,11 +240,19 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
         */
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto exit_detach;
+       }
+
        device_create_file(&new_client->dev, &dev_attr_temp1_input);
        device_create_file(&new_client->dev, &dev_attr_temp1_max);
 
        return 0;
 
+exit_detach:
+       i2c_detach_client(new_client);
 exit_free:
        kfree(data);
 exit:
@@ -252,15 +261,15 @@ exit:
 
 static int w83l785ts_detach_client(struct i2c_client *client)
 {
+       struct w83l785ts_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, "
-                       "client not detached.\n");
+       hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
-       kfree(i2c_get_clientdata(client));
+       kfree(data);
        return 0;
 }
 
index cd170395a8c7ced66695536007f0684e2cf4201d..71c5a854ac5d646d31e03ad511ea5ceb00ef8af8 100644 (file)
@@ -4,12 +4,8 @@
 
 obj-$(CONFIG_I2C)              += i2c-core.o
 obj-$(CONFIG_I2C_CHARDEV)      += i2c-dev.o
-obj-$(CONFIG_I2C_SENSOR)       += i2c-sensor.o
 obj-y                          += busses/ chips/ algos/
 
-i2c-sensor-objs := i2c-sensor-detect.o i2c-sensor-vid.o
-
-
 ifeq ($(CONFIG_I2C_DEBUG_CORE),y)
 EXTRA_CFLAGS += -DDEBUG
 endif
index fb5b732238ed814095319f5e7518159cd6bbd8ac..df05df1a0ef61f20de8239e36bb3202ac7ae6ae5 100644 (file)
@@ -519,8 +519,6 @@ static u32 bit_func(struct i2c_adapter *adap)
 /* -----exported algorithm data: ------------------------------------- */
 
 static struct i2c_algorithm i2c_bit_algo = {
-       .name           = "Bit-shift algorithm",
-       .id             = I2C_ALGO_BIT,
        .master_xfer    = bit_xfer,
        .functionality  = bit_func,
 };
@@ -541,8 +539,6 @@ int i2c_bit_add_bus(struct i2c_adapter *adap)
        DEB2(dev_dbg(&adap->dev, "hw routines registered.\n"));
 
        /* register new adapter to i2c module... */
-
-       adap->id |= i2c_bit_algo.id;
        adap->algo = &i2c_bit_algo;
 
        adap->timeout = 100;    /* default values, should       */
index e6cae39f47aa062c7f09eb67ed1500bf41dbf665..2db7bfc852252dbf1b74c29ede26071b522a92e1 100644 (file)
@@ -713,8 +713,6 @@ static u32 iic_func(struct i2c_adapter *adap)
 /* -----exported algorithm data: ------------------------------------- */
 
 static struct i2c_algorithm iic_algo = {
-       .name           = "ITE IIC algorithm",
-       .id             = I2C_ALGO_IIC,
        .master_xfer    = iic_xfer,
        .algo_control   = algo_control, /* ioctl */
        .functionality  = iic_func,
@@ -738,8 +736,6 @@ int i2c_iic_add_bus(struct i2c_adapter *adap)
                    adap->name));
 
        /* register new adapter to i2c module... */
-
-       adap->id |= iic_algo.id;
        adap->algo = &iic_algo;
 
        adap->timeout = 100;    /* default values, should       */
index cc3a952401f2ea8354cf89ac5e43c151bd151cbe..beb10edfe9c1774c7426945962b749b9831c7c88 100644 (file)
@@ -187,12 +187,14 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
        int numbytes = 0;
        int state;
        int ret;
+       int timeout = 100;
 
-       state = pca_status(adap);
-       if ( state != 0xF8 ) {
-               dev_dbg(&i2c_adap->dev, "bus is not idle. status is %#04x\n", state );
-               /* FIXME: what to do. Force stop ? */
-               return -EREMOTEIO;
+       while ((state = pca_status(adap)) != 0xf8 && timeout--) {
+               msleep(10);
+       }
+       if (state != 0xf8) {
+               dev_dbg(&i2c_adap->dev, "bus is not idle. status is %#04x\n", state);
+               return -EIO;
        }
 
        DEB1("{{{ XFER %d messages\n", num);
@@ -354,8 +356,6 @@ static int pca_init(struct i2c_algo_pca_data *adap)
 }
 
 static struct i2c_algorithm pca_algo = {
-       .name           = "PCA9564 algorithm",
-       .id             = I2C_ALGO_PCA,
        .master_xfer    = pca_xfer,
        .functionality  = pca_func,
 };
@@ -369,8 +369,6 @@ int i2c_pca_add_bus(struct i2c_adapter *adap)
        int rval;
 
        /* register new adapter to i2c module... */
-
-       adap->id |= pca_algo.id;
        adap->algo = &pca_algo;
 
        adap->timeout = 100;            /* default values, should       */
index 8d087dac32afc7e22575ff32be4c8a2262d3ddb1..6e498df1f717aea6f238b6ce91d990b9a7cbedfa 100644 (file)
@@ -459,8 +459,6 @@ static u32 pcf_func(struct i2c_adapter *adap)
 /* -----exported algorithm data: ------------------------------------- */
 
 static struct i2c_algorithm pcf_algo = {
-       .name           = "PCF8584 algorithm",
-       .id             = I2C_ALGO_PCF,
        .master_xfer    = pcf_xfer,
        .functionality  = pcf_func,
 };
@@ -476,8 +474,6 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
        DEB2(dev_dbg(&adap->dev, "hw routines registered.\n"));
 
        /* register new adapter to i2c module... */
-
-       adap->id |= pcf_algo.id;
        adap->algo = &pcf_algo;
 
        adap->timeout = 100;            /* default values, should       */
index 422721b241e5a0914f5383502035eb3dffc1f165..932c4fa86c7374eb9cf667ab14a8d20cc94adcbf 100644 (file)
@@ -149,7 +149,7 @@ static int sgi_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs,
                        err = i2c_write(adap, p->buf, p->len);
        }
 
-       return err;
+       return (err < 0) ? err : i;
 }
 
 static u32 sgi_func(struct i2c_adapter *adap)
@@ -158,8 +158,6 @@ static u32 sgi_func(struct i2c_adapter *adap)
 }
 
 static struct i2c_algorithm sgi_algo = {
-       .name           = "SGI algorithm",
-       .id             = I2C_ALGO_SGI,
        .master_xfer    = sgi_xfer,
        .functionality  = sgi_func,
 };
@@ -169,7 +167,6 @@ static struct i2c_algorithm sgi_algo = {
  */
 int i2c_sgi_add_bus(struct i2c_adapter *adap)
 {
-       adap->id |= sgi_algo.id;
        adap->algo = &sgi_algo;
 
        return i2c_add_adapter(adap);
index f2785499237bf10135f571c0ebfddb9b9e4e5474..8ed5ad12552fed1ccf1f6ee7669c54afd652cf83 100644 (file)
@@ -135,8 +135,6 @@ static u32 bit_func(struct i2c_adapter *adap)
 /* -----exported algorithm data: ------------------------------------- */
 
 static struct i2c_algorithm i2c_sibyte_algo = {
-       .name           = "SiByte algorithm",
-       .id             = I2C_ALGO_SIBYTE,
        .smbus_xfer     = smbus_xfer,
        .algo_control   = algo_control, /* ioctl */
        .functionality  = bit_func,
@@ -151,8 +149,6 @@ int i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed)
        struct i2c_algo_sibyte_data *adap = i2c_adap->algo_data;
 
        /* register new adapter to i2c module... */
-
-       i2c_adap->id |= i2c_sibyte_algo.id;
        i2c_adap->algo = &i2c_sibyte_algo;
         
         /* Set the frequency to 100 kHz */
index 916ba5e40a96dd9810a0e4014cefb46541054475..6e9da1372225b73ab74c304824be223c5f078592 100644 (file)
@@ -182,14 +182,8 @@ config I2C_IOP3XX
          will be called i2c-iop3xx.
 
 config I2C_ISA
-       tristate "ISA Bus support"
+       tristate
        depends on I2C
-       help
-         If you say yes to this option, support will be included for i2c
-         interfaces that are on the ISA bus.
-
-         This driver can also be built as a module.  If so, the module
-         will be called i2c-isa.
 
 config I2C_ITE
        tristate "ITE I2C Adapter"
index f634a0780cf04b400a24ffb134967394b91c5b47..f021acd2674e9cfe6377a3225520418363a51fc9 100644 (file)
@@ -472,8 +472,6 @@ static u32 ali1535_func(struct i2c_adapter *adapter)
 }
 
 static struct i2c_algorithm smbus_algorithm = {
-       .name           = "Non-i2c SMBus adapter",
-       .id             = I2C_ALGO_SMBUS,
        .smbus_xfer     = ali1535_access,
        .functionality  = ali1535_func,
 };
index fdd881aee618172df04f70977ee4cb4a57e7d58c..86947504aea1e041f64677052882a552bae14d7a 100644 (file)
@@ -366,8 +366,6 @@ static void ali1563_shutdown(struct pci_dev *dev)
 }
 
 static struct i2c_algorithm ali1563_algorithm = {
-       .name           = "Non-i2c SMBus adapter",
-       .id             = I2C_ALGO_SMBUS,
        .smbus_xfer     = ali1563_access,
        .functionality  = ali1563_func,
 };
index 0f781a1a3323bc3c49c000ef1820ba7773d601ca..b3f50bff39a06c79f00e5ce59ddc0eea229008e3 100644 (file)
@@ -462,8 +462,6 @@ static u32 ali15x3_func(struct i2c_adapter *adapter)
 }
 
 static struct i2c_algorithm smbus_algorithm = {
-       .name           = "Non-I2C SMBus adapter",
-       .id             = I2C_ALGO_SMBUS,
        .smbus_xfer     = ali15x3_access,
        .functionality  = ali15x3_func,
 };
index 6347ebc6fb53522c1a423b5b6b21cb3589c55524..6ad0603384b8a34c8577c442185cece17c70d763 100644 (file)
@@ -295,8 +295,6 @@ static u32 amd756_func(struct i2c_adapter *adapter)
 }
 
 static struct i2c_algorithm smbus_algorithm = {
-       .name           = "Non-I2C SMBus adapter",
-       .id             = I2C_ALGO_SMBUS,
        .smbus_xfer     = amd756_access,
        .functionality  = amd756_func,
 };
index d6644481d2a097230d508e02fcd57248d84fb927..45ea24ba14d5b2d537502a6d3e43a4065f96902a 100644 (file)
@@ -323,8 +323,6 @@ static u32 amd8111_func(struct i2c_adapter *adapter)
 }
 
 static struct i2c_algorithm smbus_algorithm = {
-       .name = "Non-I2C SMBus 2.0 adapter",
-       .id = I2C_ALGO_SMBUS,
        .smbus_xfer = amd8111_access,
        .functionality = amd8111_func,
 };
index a7ff112e49bf28b5c0aed2ae46a353a9f56bf0bf..d06edce03bf40dd83604708018d4ce5165cd852f 100644 (file)
@@ -283,8 +283,6 @@ au1550_func(struct i2c_adapter *adap)
 }
 
 static struct i2c_algorithm au1550_algo = {
-       .name           = "Au1550 algorithm",
-       .id             = I2C_ALGO_AU1550,
        .master_xfer    = au1550_xfer,
        .functionality  = au1550_func,
 };
index 1ab41313ce5186d72f3a7398295dee8524576b0a..709beab76609eb43bdd4deb1b2a96db195d23aa0 100644 (file)
@@ -535,8 +535,6 @@ static u32 i801_func(struct i2c_adapter *adapter)
 }
 
 static struct i2c_algorithm smbus_algorithm = {
-       .name           = "Non-I2C SMBus adapter",
-       .id             = I2C_ALGO_SMBUS,
        .smbus_xfer     = i801_access,
        .functionality  = i801_func,
 };
index 93ca36dc777e3cd474a798ecbaaf5081aa760e5d..a3ed9590f028b17796e984816e0003ae3dca8270 100644 (file)
@@ -627,8 +627,6 @@ static u32 iic_func(struct i2c_adapter *adap)
 }
 
 static struct i2c_algorithm iic_algo = {
-       .name           = "IBM IIC algorithm",
-       .id             = I2C_ALGO_OCP,
        .master_xfer    = iic_xfer,
        .functionality  = iic_func
 };
@@ -727,7 +725,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){
        adap = &dev->adap;
        strcpy(adap->name, "IBM IIC");
        i2c_set_adapdata(adap, dev);
-       adap->id = I2C_HW_OCP | iic_algo.id;
+       adap->id = I2C_HW_OCP;
        adap->algo = &iic_algo;
        adap->client_register = NULL;
        adap->client_unregister = NULL;
index 6b682e903f09c6735abaedf7f75508b9177c3cc0..7bd9102db701cd205eb0c347eba78deb971e99d8 100644 (file)
@@ -399,8 +399,6 @@ iop3xx_i2c_func(struct i2c_adapter *adap)
 }
 
 static struct i2c_algorithm iop3xx_i2c_algo = {
-       .name           = "IOP3xx I2C algorithm",
-       .id             = I2C_ALGO_IOP3XX,
        .master_xfer    = iop3xx_i2c_master_xfer,
        .algo_control   = iop3xx_i2c_algo_control,
        .functionality  = iop3xx_i2c_func,
index 00e7f7157b75d98f46ef085f9d311517a546a726..bdc6806dafaece2b13752d55ded93cdd7bc7c525 100644 (file)
@@ -1,6 +1,8 @@
 /*
-    i2c-isa.c - Part of lm_sensors, Linux kernel modules for hardware
-            monitoring
+    i2c-isa.c - an i2c-core-like thing for ISA hardware monitoring chips
+    Copyright (C) 2005  Jean Delvare <khali@linux-fr.org>
+
+    Based on the i2c-isa pseudo-adapter from the lm_sensors project
     Copyright (c) 1998, 1999  Frodo Looijaard <frodol@dds.nl> 
 
     This program is free software; you can redistribute it and/or modify
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-/* This implements an i2c algorithm/adapter for ISA bus. Not that this is
-   on first sight very useful; almost no functionality is preserved.
-   Except that it makes writing drivers for chips which can be on both
-   the SMBus and the ISA bus very much easier. See lm78.c for an example
-   of this. */
+/* This implements an i2c-core-like thing for ISA hardware monitoring
+   chips. Such chips are linked to the i2c subsystem for historical
+   reasons (because the early ISA hardware monitoring chips such as the
+   LM78 had both an I2C and an ISA interface). They used to be
+   registered with the main i2c-core, but as a first step in the
+   direction of a clean separation between I2C and ISA chip drivers,
+   we now have this separate core for ISA ones. It is significantly
+   more simple than the real one, of course, because we don't have to
+   handle multiple busses: there is only one (fake) ISA adapter.
+   It is worth noting that we still rely on i2c-core for some things
+   at the moment - but hopefully this won't last. */
 
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/i2c.h>
+#include <linux/i2c-isa.h>
 
 static u32 isa_func(struct i2c_adapter *adapter);
 
 /* This is the actual algorithm we define */
 static struct i2c_algorithm isa_algorithm = {
-       .name           = "ISA bus algorithm",
-       .id             = I2C_ALGO_ISA,
        .functionality  = isa_func,
 };
 
 /* There can only be one... */
 static struct i2c_adapter isa_adapter = {
        .owner          = THIS_MODULE,
+       .id             = I2C_HW_ISA,
        .class          = I2C_CLASS_HWMON,
        .algo           = &isa_algorithm,
        .name           = "ISA main adapter",
@@ -53,17 +61,146 @@ static u32 isa_func(struct i2c_adapter *adapter)
        return 0;
 }
 
+
+/* Copied from i2c-core */
+static ssize_t show_adapter_name(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       struct i2c_adapter *adap = dev_to_i2c_adapter(dev);
+       return sprintf(buf, "%s\n", adap->name);
+}
+static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL);
+
+static int i2c_isa_device_probe(struct device *dev)
+{
+       return -ENODEV;
+}
+
+static int i2c_isa_device_remove(struct device *dev)
+{
+       return 0;
+}
+
+
+/* We implement an interface which resembles i2c_{add,del}_driver,
+   but for i2c-isa drivers. We don't have to remember and handle lists
+   of drivers and adapters so this is much more simple, of course. */
+
+int i2c_isa_add_driver(struct i2c_driver *driver)
+{
+       int res;
+
+       /* Add the driver to the list of i2c drivers in the driver core */
+       driver->driver.name = driver->name;
+       driver->driver.bus = &i2c_bus_type;
+       driver->driver.probe = i2c_isa_device_probe;
+       driver->driver.remove = i2c_isa_device_remove;
+       res = driver_register(&driver->driver);
+       if (res)
+               return res;
+       dev_dbg(&isa_adapter.dev, "Driver %s registered\n", driver->name);
+
+       /* Now look for clients */
+       driver->attach_adapter(&isa_adapter);
+
+       return 0;
+}
+
+int i2c_isa_del_driver(struct i2c_driver *driver)
+{
+       struct list_head *item, *_n;
+       struct i2c_client *client;
+       int res;
+
+       /* Detach all clients belonging to this one driver */
+       list_for_each_safe(item, _n, &isa_adapter.clients) {
+               client = list_entry(item, struct i2c_client, list);
+               if (client->driver != driver)
+                       continue;
+               dev_dbg(&isa_adapter.dev, "Detaching client %s at 0x%x\n",
+                       client->name, client->addr);
+               if ((res = driver->detach_client(client))) {
+                       dev_err(&isa_adapter.dev, "Failed, driver "
+                               "%s not unregistered!\n",
+                               driver->name);
+                       return res;
+               }
+       }
+
+       /* Get the driver off the core list */
+       driver_unregister(&driver->driver);
+       dev_dbg(&isa_adapter.dev, "Driver %s unregistered\n", driver->name);
+
+       return 0;
+}
+
+
 static int __init i2c_isa_init(void)
 {
-       return i2c_add_adapter(&isa_adapter);
+       init_MUTEX(&isa_adapter.clist_lock);
+       INIT_LIST_HEAD(&isa_adapter.clients);
+
+       isa_adapter.nr = ANY_I2C_ISA_BUS;
+       isa_adapter.dev.parent = &platform_bus;
+       sprintf(isa_adapter.dev.bus_id, "i2c-%d", isa_adapter.nr);
+       isa_adapter.dev.driver = &i2c_adapter_driver;
+       isa_adapter.dev.release = &i2c_adapter_dev_release;
+       device_register(&isa_adapter.dev);
+       device_create_file(&isa_adapter.dev, &dev_attr_name);
+
+       /* Add this adapter to the i2c_adapter class */
+       memset(&isa_adapter.class_dev, 0x00, sizeof(struct class_device));
+       isa_adapter.class_dev.dev = &isa_adapter.dev;
+       isa_adapter.class_dev.class = &i2c_adapter_class;
+       strlcpy(isa_adapter.class_dev.class_id, isa_adapter.dev.bus_id,
+               BUS_ID_SIZE);
+       class_device_register(&isa_adapter.class_dev);
+
+       dev_dbg(&isa_adapter.dev, "%s registered\n", isa_adapter.name);
+
+       return 0;
 }
 
 static void __exit i2c_isa_exit(void)
 {
-       i2c_del_adapter(&isa_adapter);
+#ifdef DEBUG
+       struct list_head  *item, *_n;
+       struct i2c_client *client = NULL;
+#endif
+
+       /* There should be no more active client */
+#ifdef DEBUG
+       dev_dbg(&isa_adapter.dev, "Looking for clients\n");
+       list_for_each_safe(item, _n, &isa_adapter.clients) {
+               client = list_entry(item, struct i2c_client, list);
+               dev_err(&isa_adapter.dev, "Driver %s still has an active "
+                       "ISA client at 0x%x\n", client->driver->name,
+                       client->addr);
+       }
+       if (client != NULL)
+               return;
+#endif
+
+       /* Clean up the sysfs representation */
+       dev_dbg(&isa_adapter.dev, "Unregistering from sysfs\n");
+       init_completion(&isa_adapter.dev_released);
+       init_completion(&isa_adapter.class_dev_released);
+       class_device_unregister(&isa_adapter.class_dev);
+       device_remove_file(&isa_adapter.dev, &dev_attr_name);
+       device_unregister(&isa_adapter.dev);
+
+       /* Wait for sysfs to drop all references */
+       dev_dbg(&isa_adapter.dev, "Waiting for sysfs completion\n");
+       wait_for_completion(&isa_adapter.dev_released);
+       wait_for_completion(&isa_adapter.class_dev_released);
+
+       dev_dbg(&isa_adapter.dev, "%s unregistered\n", isa_adapter.name);
 }
 
-MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>");
+EXPORT_SYMBOL(i2c_isa_add_driver);
+EXPORT_SYMBOL(i2c_isa_del_driver);
+
+MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
 MODULE_DESCRIPTION("ISA bus access through i2c");
 MODULE_LICENSE("GPL");
 
index 94ae808314f75905bf3dfb00d8ac075fce1c08f9..37b49c2daf5f824a5057ff713effce45149f7116 100644 (file)
@@ -87,12 +87,9 @@ static const char *__kw_state_names[] = {
 };
 #endif /* DEBUG */
 
-static int probe;
-
 MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
 MODULE_DESCRIPTION("I2C driver for Apple's Keywest");
 MODULE_LICENSE("GPL");
-module_param(probe, bool, 0);
 
 #ifdef POLLED_MODE
 /* Don't schedule, the g5 fan controller is too
@@ -498,8 +495,6 @@ keywest_func(struct i2c_adapter * adapter)
 
 /* For now, we only handle combined mode (smbus) */
 static struct i2c_algorithm keywest_algorithm = {
-       .name           = "Keywest i2c",
-       .id             = I2C_ALGO_SMBUS,
        .smbus_xfer     = keywest_smbus_xfer,
        .master_xfer    = keywest_xfer,
        .functionality  = keywest_func,
@@ -621,7 +616,6 @@ create_iface(struct device_node *np, struct device *dev)
                sprintf(chan->adapter.name, "%s %d", np->parent->name, i);
                chan->iface = iface;
                chan->chan_no = i;
-               chan->adapter.id = I2C_ALGO_SMBUS;
                chan->adapter.algo = &keywest_algorithm;
                chan->adapter.algo_data = NULL;
                chan->adapter.client_register = NULL;
@@ -635,15 +629,6 @@ create_iface(struct device_node *np, struct device *dev)
                                chan->adapter.name);
                        i2c_set_adapdata(&chan->adapter, NULL);
                }
-               if (probe) {
-                       printk("Probe: ");
-                       for (addr = 0x00; addr <= 0x7f; addr++) {
-                               if (i2c_smbus_xfer(&chan->adapter,addr,
-                                   0,0,0,I2C_SMBUS_QUICK,NULL) >= 0)
-                                       printk("%02x ", addr);
-                       }
-                       printk("\n");
-               }
        }
 
        printk(KERN_INFO "Found KeyWest i2c on \"%s\", %d channel%s, stepping: %d bits\n",
index 9ad3e9262e8ae059621c43413cb48c95ccd9aec7..f065583ddcf104dea3b14ef5e3015234c985c72f 100644 (file)
@@ -272,8 +272,6 @@ static u32 mpc_functionality(struct i2c_adapter *adap)
 }
 
 static struct i2c_algorithm mpc_algo = {
-       .name = "MPC algorithm",
-       .id = I2C_ALGO_MPC107,
        .master_xfer = mpc_xfer,
        .functionality = mpc_functionality,
 };
@@ -281,7 +279,7 @@ static struct i2c_algorithm mpc_algo = {
 static struct i2c_adapter mpc_ops = {
        .owner = THIS_MODULE,
        .name = "MPC adapter",
-       .id = I2C_ALGO_MPC107 | I2C_HW_MPC107,
+       .id = I2C_HW_MPC107,
        .algo = &mpc_algo,
        .class = I2C_CLASS_HWMON,
        .timeout = 1,
index 5b852782d2f5956cc4984a617facd1da2e64f592..99abca45fece4d9ea24603529e4ff00a5d9ad271 100644 (file)
@@ -423,18 +423,16 @@ static int
 mv64xxx_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
 {
        struct mv64xxx_i2c_data *drv_data = i2c_get_adapdata(adap);
-       int     i, rc = 0;
+       int     i, rc;
 
        for (i=0; i<num; i++)
-               if ((rc = mv64xxx_i2c_execute_msg(drv_data, &msgs[i])) != 0)
-                       break;
+               if ((rc = mv64xxx_i2c_execute_msg(drv_data, &msgs[i])) < 0)
+                       return rc;
 
-       return rc;
+       return num;
 }
 
 static struct i2c_algorithm mv64xxx_i2c_algo = {
-       .name = MV64XXX_I2C_CTLR_NAME " algorithm",
-       .id = I2C_ALGO_MV64XXX,
        .master_xfer = mv64xxx_i2c_xfer,
        .functionality = mv64xxx_i2c_functionality,
 };
@@ -523,7 +521,7 @@ mv64xxx_i2c_probe(struct device *dev)
        drv_data->freq_m = pdata->freq_m;
        drv_data->freq_n = pdata->freq_n;
        drv_data->irq = platform_get_irq(pd, 0);
-       drv_data->adapter.id = I2C_ALGO_MV64XXX | I2C_HW_MV64XXX;
+       drv_data->adapter.id = I2C_HW_MV64XXX;
        drv_data->adapter.algo = &mv64xxx_i2c_algo;
        drv_data->adapter.owner = THIS_MODULE;
        drv_data->adapter.class = I2C_CLASS_HWMON;
index 74eb89aa935084819903ff54d79722d5c368574a..e0b7a913431e0c1c7664f474a904e8db44a57c92 100644 (file)
@@ -110,8 +110,6 @@ static u32 nforce2_func(struct i2c_adapter *adapter);
 
 
 static struct i2c_algorithm smbus_algorithm = {
-       .name = "Non-I2C SMBus adapter",
-       .id = I2C_ALGO_SMBUS,
        .smbus_xfer = nforce2_access,
        .functionality = nforce2_func,
 };
@@ -131,7 +129,6 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
        struct nforce2_smbus *smbus = adap->algo_data;
        unsigned char protocol, pec, temp;
        unsigned char len = 0; /* to keep the compiler quiet */
-       int timeout = 0;
        int i;
 
        protocol = (read_write == I2C_SMBUS_READ) ? NVIDIA_SMB_PRTCL_READ :
@@ -191,29 +188,10 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
                case I2C_SMBUS_PROC_CALL:
                        dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
                        return -1;
-                       /*
-                       outb_p(command, NVIDIA_SMB_CMD);
-                       outb_p(data->word, NVIDIA_SMB_DATA);
-                       outb_p(data->word >> 8, NVIDIA_SMB_DATA + 1);
-                       protocol = NVIDIA_SMB_PRTCL_PROC_CALL | pec;
-                       read_write = I2C_SMBUS_READ;
-                       break;
-                        */
 
                case I2C_SMBUS_BLOCK_PROC_CALL:
                        dev_err(&adap->dev, "I2C_SMBUS_BLOCK_PROC_CALL not supported!\n");
                        return -1;
-                       /*
-                       protocol |= pec;
-                       len = min_t(u8, data->block[0], 31);
-                       outb_p(command, NVIDIA_SMB_CMD);
-                       outb_p(len, NVIDIA_SMB_BCNT);
-                       for (i = 0; i < len; i++)
-                               outb_p(data->block[i + 1], NVIDIA_SMB_DATA + i);
-                       protocol = NVIDIA_SMB_PRTCL_BLOCK_PROC_CALL | pec;
-                       read_write = I2C_SMBUS_READ;
-                       break;
-                       */
 
                case I2C_SMBUS_WORD_DATA_PEC:
                case I2C_SMBUS_BLOCK_DATA_PEC:
@@ -232,12 +210,6 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
 
        temp = inb_p(NVIDIA_SMB_STS);
 
-#if 0
-       do {
-               i2c_do_pause(1);
-               temp = inb_p(NVIDIA_SMB_STS);
-       } while (((temp & NVIDIA_SMB_STS_DONE) == 0) && (timeout++ < MAX_TIMEOUT));
-#endif
        if (~temp & NVIDIA_SMB_STS_DONE) {
                udelay(500);
                temp = inb_p(NVIDIA_SMB_STS);
@@ -247,9 +219,10 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
                temp = inb_p(NVIDIA_SMB_STS);
        }
 
-       if ((timeout >= MAX_TIMEOUT) || (~temp & NVIDIA_SMB_STS_DONE)
-               || (temp & NVIDIA_SMB_STS_STATUS))
+       if ((~temp & NVIDIA_SMB_STS_DONE) || (temp & NVIDIA_SMB_STS_STATUS)) {
+               dev_dbg(&adap->dev, "SMBus Timeout! (0x%02x)\n", temp);
                return -1;
+       }
 
        if (read_write == I2C_SMBUS_WRITE)
                return 0;
index 6d34ee381ce19837a92a98b0cf47274dd92d7a16..6d48a4da7bed97e2d4ecabdbe8ee98e3f8f12244 100644 (file)
@@ -399,8 +399,6 @@ static u32 piix4_func(struct i2c_adapter *adapter)
 }
 
 static struct i2c_algorithm smbus_algorithm = {
-       .name           = "Non-I2C SMBus adapter",
-       .id             = I2C_ALGO_SMBUS,
        .smbus_xfer     = piix4_access,
        .functionality  = piix4_func,
 };
index a3b38257cc3d51e9f4d9ab826c03edd7173a4523..73a092fb0e7e955411bb2f559c0e92222980716b 100644 (file)
@@ -568,7 +568,6 @@ static u32 s3c24xx_i2c_func(struct i2c_adapter *adap)
 /* i2c bus registration info */
 
 static struct i2c_algorithm s3c24xx_i2c_algorithm = {
-       .name                   = "S3C2410-I2C-Algorithm",
        .master_xfer            = s3c24xx_i2c_xfer,
        .functionality          = s3c24xx_i2c_func,
 };
index bbd5e4e52f093cd7709d2c2d98d657ed9b598c1a..080318d6f54b313faa9458e6170499afaa8585c6 100644 (file)
@@ -357,8 +357,6 @@ static u32 sis5595_func(struct i2c_adapter *adapter)
 }
 
 static struct i2c_algorithm smbus_algorithm = {
-       .name           = "Non-I2C SMBus adapter",
-       .id             = I2C_ALGO_SMBUS,
        .smbus_xfer     = sis5595_access,
        .functionality  = sis5595_func,
 };
index f58455e7689e57da7aff99a086a4f6846153b329..86f0f448fa0b91a6ad3f2da9d6c29e5efe2dc70e 100644 (file)
@@ -448,8 +448,6 @@ exit:
 
 
 static struct i2c_algorithm smbus_algorithm = {
-       .name           = "Non-I2C SMBus adapter",
-       .id             = I2C_ALGO_SMBUS,
        .smbus_xfer     = sis630_access,
        .functionality  = sis630_func,
 };
index 6484792e23a1aacf9402ab41413ecb16987581e6..ead2ff3cf60e705eb9e0d36d0e8c67c139b2e5f9 100644 (file)
@@ -249,8 +249,6 @@ static u32 sis96x_func(struct i2c_adapter *adapter)
 }
 
 static struct i2c_algorithm smbus_algorithm = {
-       .name           = "Non-I2C SMBus adapter",
-       .id             = I2C_ALGO_SMBUS,
        .smbus_xfer     = sis96x_access,
        .functionality  = sis96x_func,
 };
index 00d94e886955eb9b4374e2d8bd07dcab1ba5d04b..73f481e93a36458c3040e391d3a16ac649d9affd 100644 (file)
@@ -109,8 +109,6 @@ static u32 stub_func(struct i2c_adapter *adapter)
 }
 
 static struct i2c_algorithm smbus_algorithm = {
-       .name           = "Non-I2C SMBus adapter",
-       .id             = I2C_ALGO_SMBUS,
        .functionality  = stub_func,
        .smbus_xfer     = stub_xfer,
 };
index 6b5008005c6fc1e276e9bf766d5eeb9815a997bf..99d209e0485adba2e08d23117e404c4656a46c99 100644 (file)
@@ -286,8 +286,6 @@ static u32 vt596_func(struct i2c_adapter *adapter)
 }
 
 static struct i2c_algorithm smbus_algorithm = {
-       .name           = "Non-I2C SMBus adapter",
-       .id             = I2C_ALGO_SMBUS,
        .smbus_xfer     = vt596_access,
        .functionality  = vt596_func,
 };
index a18bdd9aa7ba29b65fa6d699b74ea6595cfff848..a1d580e05361255d8096ea01fa72399f2d9ad94b 100644 (file)
@@ -395,8 +395,6 @@ static u32 scx200_acb_func(struct i2c_adapter *adapter)
 
 /* For now, we only handle combined mode (smbus) */
 static struct i2c_algorithm scx200_acb_algorithm = {
-       .name           = "NatSemi SCx200 ACCESS.bus",
-       .id             = I2C_ALGO_SMBUS,
        .smbus_xfer     = scx200_acb_smbus_xfer,
        .functionality  = scx200_acb_func,
 };
@@ -456,7 +454,7 @@ static int  __init scx200_acb_create(int base, int index)
        i2c_set_adapdata(adapter, iface);
        snprintf(adapter->name, I2C_NAME_SIZE, "SCx200 ACB%d", index);
        adapter->owner = THIS_MODULE;
-       adapter->id = I2C_ALGO_SMBUS;
+       adapter->id = I2C_HW_SMBUS_SCX200;
        adapter->algo = &scx200_acb_algorithm;
        adapter->class = I2C_CLASS_HWMON;
 
index 43f70dbfc03f6f8865580816ab311fa8ac8a4854..6bd44a44cd28bedc1b3b3157f88e44c99645b5d6 100644 (file)
@@ -2,17 +2,12 @@
 # Miscellaneous I2C chip drivers configuration
 #
 
-config I2C_SENSOR
-       tristate
-       default n
-
 menu "Miscellaneous I2C Chip support"
        depends on I2C
 
 config SENSORS_DS1337
        tristate "Dallas Semiconductor DS1337 and DS1339 Real Time Clock"
        depends on I2C && EXPERIMENTAL
-       select I2C_SENSOR
        help
          If you say yes here you get support for Dallas Semiconductor
          DS1337 and DS1339 real-time clock chips.
@@ -23,7 +18,6 @@ config SENSORS_DS1337
 config SENSORS_DS1374
        tristate "Maxim/Dallas Semiconductor DS1374 Real Time Clock"
        depends on I2C && EXPERIMENTAL
-       select I2C_SENSOR
        help
          If you say yes here you get support for Dallas Semiconductor
          DS1374 real-time clock chips.
@@ -34,7 +28,6 @@ config SENSORS_DS1374
 config SENSORS_EEPROM
        tristate "EEPROM reader"
        depends on I2C && EXPERIMENTAL
-       select I2C_SENSOR
        help
          If you say yes here you get read-only access to the EEPROM data
          available on modern memory DIMMs and Sony Vaio laptops.  Such
@@ -46,7 +39,6 @@ config SENSORS_EEPROM
 config SENSORS_PCF8574
        tristate "Philips PCF8574 and PCF8574A"
        depends on I2C && EXPERIMENTAL
-       select I2C_SENSOR
        help
          If you say yes here you get support for Philips PCF8574 and 
          PCF8574A chips.
@@ -67,7 +59,6 @@ config SENSORS_PCA9539
 config SENSORS_PCF8591
        tristate "Philips PCF8591"
        depends on I2C && EXPERIMENTAL
-       select I2C_SENSOR
        help
          If you say yes here you get support for Philips PCF8591 chips.
 
@@ -77,7 +68,6 @@ config SENSORS_PCF8591
 config SENSORS_RTC8564
        tristate "Epson 8564 RTC chip"
        depends on I2C && EXPERIMENTAL
-       select I2C_SENSOR
        help
          If you say yes here you get support for the Epson 8564 RTC chip.
 
index 82cf959989fd3f3126ea83255a57e2e8c659fb1d..9d3175c03395681d1fe3b29a91bccb3566f64869 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
 #include <linux/string.h>
 #include <linux/rtc.h>         /* get the user-level API */
 #include <linux/bcd.h>
@@ -39,9 +38,8 @@
  * Functions declaration
  */
 static unsigned short normal_i2c[] = { 0x68, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
-SENSORS_INSMOD_1(ds1337);
+I2C_CLIENT_INSMOD_1(ds1337);
 
 static int ds1337_attach_adapter(struct i2c_adapter *adapter);
 static int ds1337_detect(struct i2c_adapter *adapter, int address, int kind);
@@ -227,7 +225,7 @@ int ds1337_do_command(int bus, int cmd, void *arg)
 
 static int ds1337_attach_adapter(struct i2c_adapter *adapter)
 {
-       return i2c_detect(adapter, &addr_data, ds1337_detect);
+       return i2c_probe(adapter, &addr_data, ds1337_detect);
 }
 
 /*
@@ -354,11 +352,8 @@ static int ds1337_detach_client(struct i2c_client *client)
        int err;
        struct ds1337_data *data = i2c_get_clientdata(client);
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, "
-                       "client not detached.\n");
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
        list_del(&data->list);
        kfree(data);
index a445736d8838c46df70ab7c23d3a396d33915145..0936327a946db0a8c5ca673f4a42ef8eae3dc598 100644 (file)
@@ -53,7 +53,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c = normal_addr,
        .probe = ignore,
        .ignore = ignore,
-       .force = ignore,
 };
 
 static ulong ds1374_read_rtc(void)
@@ -166,7 +165,7 @@ static void ds1374_set_tlet(ulong arg)
                         "can't confirm time set from rtc chip\n");
 }
 
-ulong new_time;
+static ulong new_time;
 
 DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, (ulong) & new_time);
 
index a2da31b0dd7bda7260f77a93478b4d5d688af40c..d58403a479086d9b8660f85b0fcf5e4bbacbffe7 100644 (file)
 #include <linux/sched.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54,
                                        0x55, 0x56, 0x57, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
-SENSORS_INSMOD_1(eeprom);
+I2C_CLIENT_INSMOD_1(eeprom);
 
 
 /* Size of EEPROM in bytes */
@@ -153,21 +151,16 @@ static struct bin_attribute eeprom_attr = {
 
 static int eeprom_attach_adapter(struct i2c_adapter *adapter)
 {
-       return i2c_detect(adapter, &addr_data, eeprom_detect);
+       return i2c_probe(adapter, &addr_data, eeprom_detect);
 }
 
-/* This function is called by i2c_detect */
+/* This function is called by i2c_probe */
 int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
 {
        struct i2c_client *new_client;
        struct eeprom_data *data;
        int err = 0;
 
-       /* prevent 24RF08 corruption */
-       if (kind < 0)
-               i2c_smbus_xfer(adapter, address, 0, 0, 0,
-                              I2C_SMBUS_QUICK, NULL);
-
        /* There are three ways we can read the EEPROM data:
           (1) I2C block reads (faster, but unsupported by most adapters)
           (2) Consecutive byte reads (100% overhead)
@@ -231,10 +224,8 @@ static int eeprom_detach_client(struct i2c_client *client)
        int err;
 
        err = i2c_detach_client(client);
-       if (err) {
-               dev_err(&client->dev, "Client deregistration failed, client not detached.\n");
+       if (err)
                return err;
-       }
 
        kfree(i2c_get_clientdata(client));
 
index 778d7e12859dd0de54ed2b877c6d0ffcee72dfee..3f14528a52a9248cdc1d44a0968fe4d54956d547 100644 (file)
@@ -42,7 +42,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_addr,
        .probe                  = ignore,
        .ignore                 = ignore,
-       .force                  = ignore,
 };
 
 ulong
@@ -145,7 +144,7 @@ m41t00_set_tlet(ulong arg)
        return;
 }
 
-ulong  new_time;
+static ulong   new_time;
 
 DECLARE_TASKLET_DISABLED(m41t00_tasklet, m41t00_set_tlet, (ulong)&new_time);
 
index 0230375f72e551bb227fda676eecadff0e5def79..9e1aeb69abf9fa1009e281e7a88f22e9aef21089 100644 (file)
@@ -5,97 +5,60 @@
 
     Based on i2c/chips/eeprom.c
 
-    The MAX6875 has two EEPROM sections: config and user.
-    At reset, the config EEPROM is read into the registers.
+    The MAX6875 has a bank of registers and two banks of EEPROM.
+    Address ranges are defined as follows:
+     * 0x0000 - 0x0046 = configuration registers
+     * 0x8000 - 0x8046 = configuration EEPROM
+     * 0x8100 - 0x82FF = user EEPROM
 
-    This driver make 3 binary files available in sysfs:
-      reg_config    - direct access to the registers
-      eeprom_config - acesses configuration eeprom space
-      eeprom_user   - free for application use
+    This driver makes the user EEPROM available for read.
 
-    In our application, we put device serial & model numbers in user eeprom.
+    The registers & config EEPROM should be accessed via i2c-dev.
 
-    Notes:
-      1) The datasheet says that register 0x44 / EEPROM 0x8044 should NOT
-         be overwritten, so the driver explicitly prevents that.
-      2) It's a good idea to keep the config (0x45) locked in config EEPROM.
-         You can temporarily enable config writes by changing register 0x45.
+    The MAX6875 ignores the lowest address bit, so each chip responds to
+    two addresses - 0x50/0x51 and 0x52/0x53.
+
+    Note that the MAX6875 uses i2c_smbus_write_byte_data() to set the read
+    address, so this driver is destructive if loaded for the wrong EEPROM chip.
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; version 2 of the License.
 */
 
-#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/slab.h>
-#include <linux/sched.h>
-#include <linux/delay.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
+#include <asm/semaphore.h>
 
-/* Addresses to scan */
-/* No address scanned by default, as this could corrupt standard EEPROMS. */
+/* Do not scan - the MAX6875 access method will write to some EEPROM chips */
 static unsigned short normal_i2c[] = {I2C_CLIENT_END};
-static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END};
 
 /* Insmod parameters */
-SENSORS_INSMOD_1(max6875);
-
-/* this param will prevent 'accidental' writes to the eeprom */
-static int allow_write = 0;
-module_param(allow_write, int, 0);
-MODULE_PARM_DESC(allow_write,
-                "Enable write access:\n"
-                "*0: Read only\n"
-                " 1: Read/Write access");
+I2C_CLIENT_INSMOD_1(max6875);
 
 /* The MAX6875 can only read/write 16 bytes at a time */
 #define SLICE_SIZE                     16
 #define SLICE_BITS                     4
 
-/* CONFIG EEPROM is at addresses 0x8000 - 0x8045, registers are at 0 - 0x45 */
-#define CONFIG_EEPROM_BASE             0x8000
-#define CONFIG_EEPROM_SIZE             0x0046
-#define CONFIG_EEPROM_SLICES           5
-
 /* USER EEPROM is at addresses 0x8100 - 0x82FF */
 #define USER_EEPROM_BASE               0x8100
 #define USER_EEPROM_SIZE               0x0200
 #define USER_EEPROM_SLICES             32
 
 /* MAX6875 commands */
-#define MAX6875_CMD_BLOCK_WRITE                0x83
-#define MAX6875_CMD_BLOCK_READ         0x84
-#define MAX6875_CMD_REBOOT             0x88
-
-enum max6875_area_type {
-       max6875_register_config=0,
-       max6875_eeprom_config,
-       max6875_eeprom_user,
-       max6857_max
-};
-
-struct eeprom_block {
-       enum max6875_area_type  type;
-       u8                      slices;
-       u32                     size;
-       u32                     valid;
-       u32                     base;
-       unsigned long           *updated;
-       u8                      *data;
-};
+#define MAX6875_CMD_BLK_READ           0x84
 
 /* Each client has this additional data */
 struct max6875_data {
        struct i2c_client       client;
        struct semaphore        update_lock;
-       struct eeprom_block     blocks[max6857_max];
-       /* the above structs point into the arrays below */
-       u8 data[USER_EEPROM_SIZE + (CONFIG_EEPROM_SIZE*2)];
-       unsigned long last_updated[USER_EEPROM_SLICES + (CONFIG_EEPROM_SLICES*2)];
+
+       u32                     valid;
+       u8                      data[USER_EEPROM_SIZE];
+       unsigned long           last_updated[USER_EEPROM_SLICES];
 };
 
 static int max6875_attach_adapter(struct i2c_adapter *adapter);
@@ -111,337 +74,160 @@ static struct i2c_driver max6875_driver = {
        .detach_client  = max6875_detach_client,
 };
 
-static int max6875_update_slice(struct i2c_client *client,
-                               struct eeprom_block *blk,
-                               int slice)
+static void max6875_update_slice(struct i2c_client *client, int slice)
 {
        struct max6875_data *data = i2c_get_clientdata(client);
-       int i, j, addr, count;
-       u8 rdbuf[SLICE_SIZE];
-       int retval = 0;
+       int i, j, addr;
+       u8 *buf;
 
-       if (slice >= blk->slices)
-               return -1;
+       if (slice >= USER_EEPROM_SLICES)
+               return;
 
        down(&data->update_lock);
 
-       if (!(blk->valid & (1 << slice)) ||
-           (jiffies - blk->updated[slice] > 300 * HZ) ||
-           (jiffies < blk->updated[slice])) {
-               dev_dbg(&client->dev, "Starting eeprom update, slice %u, base %u\n",
-                       slice, blk->base);
+       buf = &data->data[slice << SLICE_BITS];
 
-               addr = blk->base + (slice << SLICE_BITS);
-               count = blk->size - (slice << SLICE_BITS);
-               if (count > SLICE_SIZE) {
-                       count = SLICE_SIZE;
-               }
+       if (!(data->valid & (1 << slice)) ||
+           time_after(jiffies, data->last_updated[slice])) {
 
-               /* Preset the read address */
-               if (addr < 0x100) {
-                       /* select the register */
-                       if (i2c_smbus_write_byte(client, addr & 0xFF)) {
-                               dev_dbg(&client->dev, "max6875 register select has failed!\n");
-                               retval = -1;
-                               goto exit;
-                       }
-               } else {
-                       /* select the eeprom */
-                       if (i2c_smbus_write_byte_data(client, addr >> 8, addr & 0xFF)) {
-                               dev_dbg(&client->dev, "max6875 address set has failed!\n");
-                               retval = -1;
-                               goto exit;
-                       }
+               dev_dbg(&client->dev, "Starting update of slice %u\n", slice);
+
+               data->valid &= ~(1 << slice);
+
+               addr = USER_EEPROM_BASE + (slice << SLICE_BITS);
+
+               /* select the eeprom address */
+               if (i2c_smbus_write_byte_data(client, addr >> 8, addr & 0xFF)) {
+                       dev_err(&client->dev, "address set failed\n");
+                       goto exit_up;
                }
 
-               if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
-                       if (i2c_smbus_read_i2c_block_data(client, MAX6875_CMD_BLOCK_READ,
-                                                         rdbuf) != SLICE_SIZE)
-                       {
-                               retval = -1;
-                               goto exit;
+               if (i2c_check_functionality(client->adapter,
+                                           I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
+                       if (i2c_smbus_read_i2c_block_data(client,
+                                                         MAX6875_CMD_BLK_READ,
+                                                         buf) != SLICE_SIZE) {
+                               goto exit_up;
                        }
-
-                       memcpy(&blk->data[slice << SLICE_BITS], rdbuf, count);
                } else {
-                       for (i = 0; i < count; i++) {
+                       for (i = 0; i < SLICE_SIZE; i++) {
                                j = i2c_smbus_read_byte(client);
-                               if (j < 0)
-                               {
-                                       retval = -1;
-                                       goto exit;
+                               if (j < 0) {
+                                       goto exit_up;
                                }
-                               blk->data[(slice << SLICE_BITS) + i] = (u8) j;
+                               buf[i] = j;
                        }
                }
-               blk->updated[slice] = jiffies;
-               blk->valid |= (1 << slice);
+               data->last_updated[slice] = jiffies;
+               data->valid |= (1 << slice);
        }
-       exit:
+exit_up:
        up(&data->update_lock);
-       return retval;
 }
 
-static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off, size_t count,
-                           enum max6875_area_type area_type)
+static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off,
+                           size_t count)
 {
-       struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj));
+       struct i2c_client *client = kobj_to_i2c_client(kobj);
        struct max6875_data *data = i2c_get_clientdata(client);
-       struct eeprom_block *blk;
-       int slice;
-
-       blk = &data->blocks[area_type];
+       int slice, max_slice;
 
-       if (off > blk->size)
+       if (off > USER_EEPROM_SIZE)
                return 0;
-       if (off + count > blk->size)
-               count = blk->size - off;
 
-       /* Only refresh slices which contain requested bytes */
-       for (slice = (off >> SLICE_BITS); slice <= ((off + count - 1) >> SLICE_BITS); slice++)
-               max6875_update_slice(client, blk, slice);
+       if (off + count > USER_EEPROM_SIZE)
+               count = USER_EEPROM_SIZE - off;
 
-       memcpy(buf, &blk->data[off], count);
+       /* refresh slices which contain requested bytes */
+       max_slice = (off + count - 1) >> SLICE_BITS;
+       for (slice = (off >> SLICE_BITS); slice <= max_slice; slice++)
+               max6875_update_slice(client, slice);
 
-       return count;
-}
-
-static ssize_t max6875_user_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
-{
-       return max6875_read(kobj, buf, off, count, max6875_eeprom_user);
-}
-
-static ssize_t max6875_config_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
-{
-       return max6875_read(kobj, buf, off, count, max6875_eeprom_config);
-}
-
-static ssize_t max6875_cfgreg_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
-{
-       return max6875_read(kobj, buf, off, count, max6875_register_config);
-}
-
-
-static ssize_t max6875_write(struct kobject *kobj, char *buf, loff_t off, size_t count,
-                            enum max6875_area_type area_type)
-{
-       struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj));
-       struct max6875_data *data = i2c_get_clientdata(client);
-       struct eeprom_block *blk;
-       int slice, addr, retval;
-       ssize_t sent = 0;
-
-       blk = &data->blocks[area_type];
-
-       if (off > blk->size)
-               return 0;
-       if ((off + count) > blk->size)
-               count = blk->size - off;
-
-       if (down_interruptible(&data->update_lock))
-               return -EAGAIN;
-
-       /* writing to a register is done with i2c_smbus_write_byte_data() */
-       if (blk->type == max6875_register_config) {
-               for (sent = 0; sent < count; sent++) {
-                       addr = off + sent;
-                       if (addr == 0x44)
-                               continue;
-
-                       retval = i2c_smbus_write_byte_data(client, addr, buf[sent]);
-               }
-       } else {
-               int cmd, val;
-
-               /* We are writing to EEPROM */
-               for (sent = 0; sent < count; sent++) {
-                       addr = blk->base + off + sent;
-                       cmd = addr >> 8;
-                       val = (addr & 0xff) | (buf[sent] << 8); // reversed
-
-                       if (addr == 0x8044)
-                               continue;
-
-                       retval = i2c_smbus_write_word_data(client, cmd, val);
-
-                       if (retval) {
-                               goto error_exit;
-                       }
+       memcpy(buf, &data->data[off], count);
 
-                       /* A write takes up to 11 ms */
-                       msleep(11);
-               }
-       }
-
-       /* Invalidate the scratch buffer */
-       for (slice = (off >> SLICE_BITS); slice <= ((off + count - 1) >> SLICE_BITS); slice++)
-               blk->valid &= ~(1 << slice);
-
-       error_exit:
-       up(&data->update_lock);
-
-       return sent;
-}
-
-static ssize_t max6875_user_write(struct kobject *kobj, char *buf, loff_t off, size_t count)
-{
-       return max6875_write(kobj, buf, off, count, max6875_eeprom_user);
-}
-
-static ssize_t max6875_config_write(struct kobject *kobj, char *buf, loff_t off, size_t count)
-{
-       return max6875_write(kobj, buf, off, count, max6875_eeprom_config);
-}
-
-static ssize_t max6875_cfgreg_write(struct kobject *kobj, char *buf, loff_t off, size_t count)
-{
-       return max6875_write(kobj, buf, off, count, max6875_register_config);
+       return count;
 }
 
 static struct bin_attribute user_eeprom_attr = {
        .attr = {
-               .name = "eeprom_user",
-               .mode = S_IRUGO | S_IWUSR | S_IWGRP,
-               .owner = THIS_MODULE,
-       },
-       .size  = USER_EEPROM_SIZE,
-       .read  = max6875_user_read,
-       .write = max6875_user_write,
-};
-
-static struct bin_attribute config_eeprom_attr = {
-       .attr = {
-               .name = "eeprom_config",
-               .mode = S_IRUGO | S_IWUSR,
-               .owner = THIS_MODULE,
-       },
-       .size  = CONFIG_EEPROM_SIZE,
-       .read  = max6875_config_read,
-       .write = max6875_config_write,
-};
-
-static struct bin_attribute config_register_attr = {
-       .attr = {
-               .name = "reg_config",
-               .mode = S_IRUGO | S_IWUSR,
+               .name = "eeprom",
+               .mode = S_IRUGO,
                .owner = THIS_MODULE,
        },
-       .size  = CONFIG_EEPROM_SIZE,
-       .read  = max6875_cfgreg_read,
-       .write = max6875_cfgreg_write,
+       .size = USER_EEPROM_SIZE,
+       .read = max6875_read,
 };
 
 static int max6875_attach_adapter(struct i2c_adapter *adapter)
 {
-       return i2c_detect(adapter, &addr_data, max6875_detect);
+       return i2c_probe(adapter, &addr_data, max6875_detect);
 }
 
-/* This function is called by i2c_detect */
+/* This function is called by i2c_probe */
 static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
 {
-       struct i2c_client *new_client;
+       struct i2c_client *real_client;
+       struct i2c_client *fake_client;
        struct max6875_data *data;
        int err = 0;
 
-       /* Prevent 24RF08 corruption (in case of user error) */
-       if (kind < 0)
-               i2c_smbus_xfer(adapter, address, 0, 0, 0,
-                              I2C_SMBUS_QUICK, NULL);
-
-       /* There are three ways we can read the EEPROM data:
-          (1) I2C block reads (faster, but unsupported by most adapters)
-          (2) Consecutive byte reads (100% overhead)
-          (3) Regular byte data reads (200% overhead)
-          The third method is not implemented by this driver because all
-          known adapters support at least the second. */
-       if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA |
-                                    I2C_FUNC_SMBUS_BYTE |
-                                    I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
-               goto exit;
-
-       /* OK. For now, we presume we have a valid client. We now create the
-          client structure, even though we cannot fill it completely yet.
-          But it allows us to access eeprom_{read,write}_value. */
-       if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL))) {
-               err = -ENOMEM;
-               goto exit;
-       }
+       if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA
+                                    | I2C_FUNC_SMBUS_READ_BYTE))
+               return 0;
+
+       /* Only check even addresses */
+       if (address & 1)
+               return 0;
+
+       if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL)))
+               return -ENOMEM;
        memset(data, 0, sizeof(struct max6875_data));
 
-       new_client = &data->client;
-       i2c_set_clientdata(new_client, data);
-       new_client->addr = address;
-       new_client->adapter = adapter;
-       new_client->driver = &max6875_driver;
-       new_client->flags = 0;
-
-       /* Setup the user section */
-       data->blocks[max6875_eeprom_user].type    = max6875_eeprom_user;
-       data->blocks[max6875_eeprom_user].slices  = USER_EEPROM_SLICES;
-       data->blocks[max6875_eeprom_user].size    = USER_EEPROM_SIZE;
-       data->blocks[max6875_eeprom_user].base    = USER_EEPROM_BASE;
-       data->blocks[max6875_eeprom_user].data    = data->data;
-       data->blocks[max6875_eeprom_user].updated = data->last_updated;
-
-       /* Setup the config section */
-       data->blocks[max6875_eeprom_config].type    = max6875_eeprom_config;
-       data->blocks[max6875_eeprom_config].slices  = CONFIG_EEPROM_SLICES;
-       data->blocks[max6875_eeprom_config].size    = CONFIG_EEPROM_SIZE;
-       data->blocks[max6875_eeprom_config].base    = CONFIG_EEPROM_BASE;
-       data->blocks[max6875_eeprom_config].data    = &data->data[USER_EEPROM_SIZE];
-       data->blocks[max6875_eeprom_config].updated = &data->last_updated[USER_EEPROM_SLICES];
-
-       /* Setup the register section */
-       data->blocks[max6875_register_config].type    = max6875_register_config;
-       data->blocks[max6875_register_config].slices  = CONFIG_EEPROM_SLICES;
-       data->blocks[max6875_register_config].size    = CONFIG_EEPROM_SIZE;
-       data->blocks[max6875_register_config].base    = 0;
-       data->blocks[max6875_register_config].data    = &data->data[USER_EEPROM_SIZE+CONFIG_EEPROM_SIZE];
-       data->blocks[max6875_register_config].updated = &data->last_updated[USER_EEPROM_SLICES+CONFIG_EEPROM_SLICES];
-
-       /* Init the data */
-       memset(data->data, 0xff, sizeof(data->data));
-
-       /* Fill in the remaining client fields */
-       strlcpy(new_client->name, "max6875", I2C_NAME_SIZE);
+       /* A fake client is created on the odd address */
+       if (!(fake_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL))) {
+               err = -ENOMEM;
+               goto exit_kfree1;
+       }
+       memset(fake_client, 0, sizeof(struct i2c_client));
+
+       /* Init real i2c_client */
+       real_client = &data->client;
+       i2c_set_clientdata(real_client, data);
+       real_client->addr = address;
+       real_client->adapter = adapter;
+       real_client->driver = &max6875_driver;
+       real_client->flags = 0;
+       strlcpy(real_client->name, "max6875", I2C_NAME_SIZE);
        init_MUTEX(&data->update_lock);
 
-       /* Verify that the chip is really what we think it is */
-       if ((max6875_update_slice(new_client, &data->blocks[max6875_eeprom_config], 4) < 0) ||
-           (max6875_update_slice(new_client, &data->blocks[max6875_register_config], 4) < 0))
-               goto exit_kfree;
-
-       /* 0x41,0x42 must be zero and 0x40 must match in eeprom and registers */
-       if ((data->blocks[max6875_eeprom_config].data[0x41] != 0) ||
-           (data->blocks[max6875_eeprom_config].data[0x42] != 0) ||
-           (data->blocks[max6875_register_config].data[0x41] != 0) ||
-           (data->blocks[max6875_register_config].data[0x42] != 0) ||
-           (data->blocks[max6875_eeprom_config].data[0x40] !=
-            data->blocks[max6875_register_config].data[0x40]))
-               goto exit_kfree;
-
-       /* Tell the I2C layer a new client has arrived */
-       if ((err = i2c_attach_client(new_client)))
-               goto exit_kfree;
-
-       /* create the sysfs eeprom files with the correct permissions */
-       if (allow_write == 0) {
-               user_eeprom_attr.attr.mode &= ~S_IWUGO;
-               user_eeprom_attr.write = NULL;
-               config_eeprom_attr.attr.mode &= ~S_IWUGO;
-               config_eeprom_attr.write = NULL;
-               config_register_attr.attr.mode &= ~S_IWUGO;
-               config_register_attr.write = NULL;
-       }
-       sysfs_create_bin_file(&new_client->dev.kobj, &user_eeprom_attr);
-       sysfs_create_bin_file(&new_client->dev.kobj, &config_eeprom_attr);
-       sysfs_create_bin_file(&new_client->dev.kobj, &config_register_attr);
+       /* Init fake client data */
+       /* set the client data to the i2c_client so that it will get freed */
+       i2c_set_clientdata(fake_client, fake_client);
+       fake_client->addr = address | 1;
+       fake_client->adapter = adapter;
+       fake_client->driver = &max6875_driver;
+       fake_client->flags = 0;
+       strlcpy(fake_client->name, "max6875 subclient", I2C_NAME_SIZE);
+
+       /* Prevent 24RF08 corruption (in case of user error) */
+       i2c_smbus_write_quick(real_client, 0);
+
+       if ((err = i2c_attach_client(real_client)) != 0)
+               goto exit_kfree2;
+
+       if ((err = i2c_attach_client(fake_client)) != 0)
+               goto exit_detach;
+
+       sysfs_create_bin_file(&real_client->dev.kobj, &user_eeprom_attr);
 
        return 0;
 
-exit_kfree:
+exit_detach:
+       i2c_detach_client(real_client);
+exit_kfree2:
+       kfree(fake_client);
+exit_kfree1:
        kfree(data);
-exit:
        return err;
 }
 
@@ -450,13 +236,9 @@ static int max6875_detach_client(struct i2c_client *client)
        int err;
 
        err = i2c_detach_client(client);
-       if (err) {
-               dev_err(&client->dev, "Client deregistration failed, client not detached.\n");
+       if (err)
                return err;
-       }
-
        kfree(i2c_get_clientdata(client));
-
        return 0;
 }
 
index 9f3ad45daae209e27bb656780ebb44a7d3e81764..225577fdda4d58113202f395ce08ee1c1c4f200a 100644 (file)
 #include <linux/slab.h>
 #include <linux/i2c.h>
 #include <linux/hwmon-sysfs.h>
-#include <linux/i2c-sensor.h>
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = {0x74, 0x75, 0x76, 0x77, I2C_CLIENT_END};
-static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END};
 
 /* Insmod parameters */
-SENSORS_INSMOD_1(pca9539);
+I2C_CLIENT_INSMOD_1(pca9539);
 
 enum pca9539_cmd
 {
@@ -109,10 +107,10 @@ static struct attribute_group pca9539_defattr_group = {
 
 static int pca9539_attach_adapter(struct i2c_adapter *adapter)
 {
-       return i2c_detect(adapter, &addr_data, pca9539_detect);
+       return i2c_probe(adapter, &addr_data, pca9539_detect);
 }
 
-/* This function is called by i2c_detect */
+/* This function is called by i2c_probe */
 static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind)
 {
        struct i2c_client *new_client;
@@ -164,10 +162,8 @@ static int pca9539_detach_client(struct i2c_client *client)
 {
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed.\n");
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
        kfree(i2c_get_clientdata(client));
        return 0;
index cfcf646540804c11780bb4d6503f74f075a4635c..6525743ff9fd76846c4fbc7c74c6dcdbd06121cf 100644 (file)
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
                                        0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
                                        I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
-SENSORS_INSMOD_2(pcf8574, pcf8574a);
+I2C_CLIENT_INSMOD_2(pcf8574, pcf8574a);
 
 /* Initial values */
 #define PCF8574_INIT 255       /* All outputs on (input mode) */
@@ -113,10 +111,10 @@ static DEVICE_ATTR(write, S_IWUSR | S_IRUGO, show_write, set_write);
 
 static int pcf8574_attach_adapter(struct i2c_adapter *adapter)
 {
-       return i2c_detect(adapter, &addr_data, pcf8574_detect);
+       return i2c_probe(adapter, &addr_data, pcf8574_detect);
 }
 
-/* This function is called by i2c_detect */
+/* This function is called by i2c_probe */
 int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind)
 {
        struct i2c_client *new_client;
@@ -186,11 +184,8 @@ static int pcf8574_detach_client(struct i2c_client *client)
 {
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev,
-                       "Client deregistration failed, client not detached.\n");
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
        kfree(i2c_get_clientdata(client));
        return 0;
index db812ade85645bb2288190eec7a2f0359a532d92..80f1df9a4500f7582c757b815eb1efc7d8f101fd 100644 (file)
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
                                        0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
-SENSORS_INSMOD_1(pcf8591);
+I2C_CLIENT_INSMOD_1(pcf8591);
 
 static int input_mode;
 module_param(input_mode, int, 0);
@@ -164,10 +162,10 @@ static DEVICE_ATTR(out0_enable, S_IWUSR | S_IRUGO,
  */
 static int pcf8591_attach_adapter(struct i2c_adapter *adapter)
 {
-       return i2c_detect(adapter, &addr_data, pcf8591_detect);
+       return i2c_probe(adapter, &addr_data, pcf8591_detect);
 }
 
-/* This function is called by i2c_detect */
+/* This function is called by i2c_probe */
 int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
 {
        struct i2c_client *new_client;
@@ -241,11 +239,8 @@ static int pcf8591_detach_client(struct i2c_client *client)
 {
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev,
-                       "Client deregistration failed, client not detached.\n");
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
        kfree(i2c_get_clientdata(client));
        return 0;
index 588fc2261a91e5f3695a8c4234ece5c9b364553f..0b5385c892b1ae827fcb9d3345a77787fe56f5cb 100644 (file)
@@ -67,7 +67,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_addr,
        .probe                  = ignore,
        .ignore                 = ignore,
-       .force                  = ignore,
 };
 
 static int rtc8564_read_mem(struct i2c_client *client, struct mem *mem);
index 4a9ead27759693bd218f294d53c2bfd54d656b4e..dda472e5e8be3bca0be40f383b2643048c3d0c51 100644 (file)
@@ -61,7 +61,7 @@ static int i2c_bus_resume(struct device * dev)
        return rc;
 }
 
-static struct bus_type i2c_bus_type = {
+struct bus_type i2c_bus_type = {
        .name =         "i2c",
        .match =        i2c_device_match,
        .suspend =      i2c_bus_suspend,
@@ -78,13 +78,13 @@ static int i2c_device_remove(struct device *dev)
        return 0;
 }
 
-static void i2c_adapter_dev_release(struct device *dev)
+void i2c_adapter_dev_release(struct device *dev)
 {
        struct i2c_adapter *adap = dev_to_i2c_adapter(dev);
        complete(&adap->dev_released);
 }
 
-static struct device_driver i2c_adapter_driver = {
+struct device_driver i2c_adapter_driver = {
        .name = "i2c_adapter",
        .bus = &i2c_bus_type,
        .probe = i2c_device_probe,
@@ -97,7 +97,7 @@ static void i2c_adapter_class_dev_release(struct class_device *dev)
        complete(&adap->class_dev_released);
 }
 
-static struct class i2c_adapter_class = {
+struct class i2c_adapter_class = {
        .name =         "i2c-adapter",
        .release =      &i2c_adapter_class_dev_release,
 };
@@ -188,6 +188,8 @@ int i2c_add_adapter(struct i2c_adapter *adap)
        strlcpy(adap->class_dev.class_id, adap->dev.bus_id, BUS_ID_SIZE);
        class_device_register(&adap->class_dev);
 
+       dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name);
+
        /* inform drivers of new adapters */
        list_for_each(item,&drivers) {
                driver = list_entry(item, struct i2c_driver, list);
@@ -196,8 +198,6 @@ int i2c_add_adapter(struct i2c_adapter *adap)
                        driver->attach_adapter(adap);
        }
 
-       dev_dbg(&adap->dev, "registered as adapter #%d\n", adap->nr);
-
 out_unlock:
        up(&core_lists);
        return res;
@@ -220,8 +220,8 @@ int i2c_del_adapter(struct i2c_adapter *adap)
                        break;
        }
        if (adap_from_list != adap) {
-               pr_debug("I2C: Attempting to delete an unregistered "
-                        "adapter\n");
+               pr_debug("i2c-core: attempting to delete unregistered "
+                        "adapter [%s]\n", adap->name);
                res = -EINVAL;
                goto out_unlock;
        }
@@ -230,9 +230,8 @@ int i2c_del_adapter(struct i2c_adapter *adap)
                driver = list_entry(item, struct i2c_driver, list);
                if (driver->detach_adapter)
                        if ((res = driver->detach_adapter(adap))) {
-                               dev_warn(&adap->dev, "can't detach adapter "
-                                        "while detaching driver %s: driver "
-                                        "not detached!\n", driver->name);
+                               dev_err(&adap->dev, "detach_adapter failed "
+                                       "for driver [%s]\n", driver->name);
                                goto out_unlock;
                        }
        }
@@ -247,9 +246,8 @@ int i2c_del_adapter(struct i2c_adapter *adap)
                 * must be deleted, as this would cause invalid states.
                 */
                if ((res=client->driver->detach_client(client))) {
-                       dev_err(&adap->dev, "adapter not "
-                               "unregistered, because client at "
-                               "address %02x can't be detached. ",
+                       dev_err(&adap->dev, "detach_client failed for client "
+                               "[%s] at address 0x%02x\n", client->name,
                                client->addr);
                        goto out_unlock;
                }
@@ -270,7 +268,7 @@ int i2c_del_adapter(struct i2c_adapter *adap)
        /* free dynamically allocated bus id */
        idr_remove(&i2c_adapter_idr, adap->nr);
 
-       dev_dbg(&adap->dev, "adapter unregistered\n");
+       dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name);
 
  out_unlock:
        up(&core_lists);
@@ -303,7 +301,7 @@ int i2c_add_driver(struct i2c_driver *driver)
                goto out_unlock;
        
        list_add_tail(&driver->list,&drivers);
-       pr_debug("i2c-core: driver %s registered.\n", driver->name);
+       pr_debug("i2c-core: driver [%s] registered\n", driver->name);
 
        /* now look for instances of driver on our adapters */
        if (driver->flags & I2C_DF_NOTIFY) {
@@ -331,21 +329,17 @@ int i2c_del_driver(struct i2c_driver *driver)
        /* Have a look at each adapter, if clients of this driver are still
         * attached. If so, detach them to be able to kill the driver 
         * afterwards.
-        */
-       pr_debug("i2c-core: unregister_driver - looking for clients.\n");
-       /* removing clients does not depend on the notify flag, else 
+        *
+        * Removing clients does not depend on the notify flag, else
         * invalid operation might (will!) result, when using stale client
         * pointers.
         */
        list_for_each(item1,&adapters) {
                adap = list_entry(item1, struct i2c_adapter, list);
-               dev_dbg(&adap->dev, "examining adapter\n");
                if (driver->detach_adapter) {
                        if ((res = driver->detach_adapter(adap))) {
-                               dev_warn(&adap->dev, "while unregistering "
-                                      "dummy driver %s, adapter could "
-                                      "not be detached properly; driver "
-                                      "not unloaded!",driver->name);
+                               dev_err(&adap->dev, "detach_adapter failed "
+                                       "for driver [%s]\n", driver->name);
                                goto out_unlock;
                        }
                } else {
@@ -353,16 +347,13 @@ int i2c_del_driver(struct i2c_driver *driver)
                                client = list_entry(item2, struct i2c_client, list);
                                if (client->driver != driver)
                                        continue;
-                               pr_debug("i2c-core.o: detaching client %s:\n", client->name);
+                               dev_dbg(&adap->dev, "detaching client [%s] "
+                                       "at 0x%02x\n", client->name,
+                                       client->addr);
                                if ((res = driver->detach_client(client))) {
-                                       dev_err(&adap->dev, "while "
-                                               "unregistering driver "
-                                               "`%s', the client at "
-                                               "address %02x of "
-                                               "adapter could not "
-                                               "be detached; driver "
-                                               "not unloaded!",
-                                               driver->name,
+                                       dev_err(&adap->dev, "detach_client "
+                                               "failed for client [%s] at "
+                                               "0x%02x\n", client->name,
                                                client->addr);
                                        goto out_unlock;
                                }
@@ -372,7 +363,7 @@ int i2c_del_driver(struct i2c_driver *driver)
 
        driver_unregister(&driver->driver);
        list_del(&driver->list);
-       pr_debug("i2c-core: driver unregistered: %s\n", driver->name);
+       pr_debug("i2c-core: driver [%s] unregistered\n", driver->name);
 
  out_unlock:
        up(&core_lists);
@@ -417,15 +408,12 @@ int i2c_attach_client(struct i2c_client *client)
        
        if (adapter->client_register)  {
                if (adapter->client_register(client))  {
-                       dev_warn(&adapter->dev, "warning: client_register "
-                               "seems to have failed for client %02x\n",
-                               client->addr);
+                       dev_dbg(&adapter->dev, "client_register "
+                               "failed for client [%s] at 0x%02x\n",
+                               client->name, client->addr);
                }
        }
 
-       dev_dbg(&adapter->dev, "client [%s] registered to adapter\n",
-               client->name);
-
        if (client->flags & I2C_CLIENT_ALLOW_USE)
                client->usage_count = 0;
 
@@ -436,7 +424,8 @@ int i2c_attach_client(struct i2c_client *client)
        
        snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id),
                "%d-%04x", i2c_adapter_id(adapter), client->addr);
-       pr_debug("registering %s\n", client->dev.bus_id);
+       dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n",
+               client->name, client->dev.bus_id);
        device_register(&client->dev);
        device_create_file(&client->dev, &dev_attr_client_name);
        
@@ -449,8 +438,12 @@ int i2c_detach_client(struct i2c_client *client)
        struct i2c_adapter *adapter = client->adapter;
        int res = 0;
        
-       if ((client->flags & I2C_CLIENT_ALLOW_USE) && (client->usage_count > 0))
+       if ((client->flags & I2C_CLIENT_ALLOW_USE)
+        && (client->usage_count > 0)) {
+               dev_warn(&client->dev, "Client [%s] still busy, "
+                        "can't detach\n", client->name);
                return -EBUSY;
+       }
 
        if (adapter->client_unregister)  {
                res = adapter->client_unregister(client);
@@ -669,98 +662,128 @@ int i2c_control(struct i2c_client *client,
  * Will not work for 10-bit addresses!
  * ----------------------------------------------------
  */
+static int i2c_probe_address(struct i2c_adapter *adapter, int addr, int kind,
+                            int (*found_proc) (struct i2c_adapter *, int, int))
+{
+       int err;
+
+       /* Make sure the address is valid */
+       if (addr < 0x03 || addr > 0x77) {
+               dev_warn(&adapter->dev, "Invalid probe address 0x%02x\n",
+                        addr);
+               return -EINVAL;
+       }
+
+       /* Skip if already in use */
+       if (i2c_check_addr(adapter, addr))
+               return 0;
+
+       /* Make sure there is something at this address, unless forced */
+       if (kind < 0) {
+               if (i2c_smbus_xfer(adapter, addr, 0, 0, 0,
+                                  I2C_SMBUS_QUICK, NULL) < 0)
+                       return 0;
+
+               /* prevent 24RF08 corruption */
+               if ((addr & ~0x0f) == 0x50)
+                       i2c_smbus_xfer(adapter, addr, 0, 0, 0,
+                                      I2C_SMBUS_QUICK, NULL);
+       }
+
+       /* Finally call the custom detection function */
+       err = found_proc(adapter, addr, kind);
+
+       /* -ENODEV can be returned if there is a chip at the given address
+          but it isn't supported by this chip driver. We catch it here as
+          this isn't an error. */
+       return (err == -ENODEV) ? 0 : err;
+}
+
 int i2c_probe(struct i2c_adapter *adapter,
              struct i2c_client_address_data *address_data,
              int (*found_proc) (struct i2c_adapter *, int, int))
 {
-       int addr,i,found,err;
+       int i, err;
        int adap_id = i2c_adapter_id(adapter);
 
        /* Forget it if we can't probe using SMBUS_QUICK */
        if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_QUICK))
                return -1;
 
-       for (addr = 0x00; addr <= 0x7f; addr++) {
-
-               /* Skip if already in use */
-               if (i2c_check_addr(adapter,addr))
-                       continue;
-
-               /* If it is in one of the force entries, we don't do any detection
-                  at all */
-               found = 0;
-
-               for (i = 0; !found && (address_data->force[i] != I2C_CLIENT_END); i += 2) {
-                       if (((adap_id == address_data->force[i]) || 
-                            (address_data->force[i] == ANY_I2C_BUS)) &&
-                            (addr == address_data->force[i+1])) {
-                               dev_dbg(&adapter->dev, "found force parameter for adapter %d, addr %04x\n",
-                                       adap_id, addr);
-                               if ((err = found_proc(adapter,addr,0)))
-                                       return err;
-                               found = 1;
-                       }
-               }
-               if (found) 
-                       continue;
-
-               /* If this address is in one of the ignores, we can forget about
-                  it right now */
-               for (i = 0;
-                    !found && (address_data->ignore[i] != I2C_CLIENT_END);
-                    i += 2) {
-                       if (((adap_id == address_data->ignore[i]) || 
-                           ((address_data->ignore[i] == ANY_I2C_BUS))) &&
-                           (addr == address_data->ignore[i+1])) {
-                               dev_dbg(&adapter->dev, "found ignore parameter for adapter %d, "
-                                       "addr %04x\n", adap_id ,addr);
-                               found = 1;
+       /* Force entries are done first, and are not affected by ignore
+          entries */
+       if (address_data->forces) {
+               unsigned short **forces = address_data->forces;
+               int kind;
+
+               for (kind = 0; forces[kind]; kind++) {
+                       for (i = 0; forces[kind][i] != I2C_CLIENT_END;
+                            i += 2) {
+                               if (forces[kind][i] == adap_id
+                                || forces[kind][i] == ANY_I2C_BUS) {
+                                       dev_dbg(&adapter->dev, "found force "
+                                               "parameter for adapter %d, "
+                                               "addr 0x%02x, kind %d\n",
+                                               adap_id, forces[kind][i + 1],
+                                               kind);
+                                       err = i2c_probe_address(adapter,
+                                               forces[kind][i + 1],
+                                               kind, found_proc);
+                                       if (err)
+                                               return err;
+                               }
                        }
                }
-               if (found) 
-                       continue;
+       }
 
-               /* Now, we will do a detection, but only if it is in the normal or 
-                  probe entries */  
-               for (i = 0;
-                    !found && (address_data->normal_i2c[i] != I2C_CLIENT_END);
-                    i += 1) {
-                       if (addr == address_data->normal_i2c[i]) {
-                               found = 1;
-                               dev_dbg(&adapter->dev, "found normal i2c entry for adapter %d, "
-                                       "addr %02x\n", adap_id, addr);
-                       }
+       /* Probe entries are done second, and are not affected by ignore
+          entries either */
+       for (i = 0; address_data->probe[i] != I2C_CLIENT_END; i += 2) {
+               if (address_data->probe[i] == adap_id
+                || address_data->probe[i] == ANY_I2C_BUS) {
+                       dev_dbg(&adapter->dev, "found probe parameter for "
+                               "adapter %d, addr 0x%02x\n", adap_id,
+                               address_data->probe[i + 1]);
+                       err = i2c_probe_address(adapter,
+                                               address_data->probe[i + 1],
+                                               -1, found_proc);
+                       if (err)
+                               return err;
                }
+       }
 
-               for (i = 0;
-                    !found && (address_data->probe[i] != I2C_CLIENT_END);
-                    i += 2) {
-                       if (((adap_id == address_data->probe[i]) ||
-                           ((address_data->probe[i] == ANY_I2C_BUS))) &&
-                           (addr == address_data->probe[i+1])) {
-                               found = 1;
-                               dev_dbg(&adapter->dev, "found probe parameter for adapter %d, "
-                                       "addr %04x\n", adap_id,addr);
+       /* Normal entries are done last, unless shadowed by an ignore entry */
+       for (i = 0; address_data->normal_i2c[i] != I2C_CLIENT_END; i += 1) {
+               int j, ignore;
+
+               ignore = 0;
+               for (j = 0; address_data->ignore[j] != I2C_CLIENT_END;
+                    j += 2) {
+                       if ((address_data->ignore[j] == adap_id ||
+                            address_data->ignore[j] == ANY_I2C_BUS)
+                        && address_data->ignore[j + 1]
+                           == address_data->normal_i2c[i]) {
+                               dev_dbg(&adapter->dev, "found ignore "
+                                       "parameter for adapter %d, "
+                                       "addr 0x%02x\n", adap_id,
+                                       address_data->ignore[j + 1]);
                        }
+                       ignore = 1;
+                       break;
                }
-               if (!found) 
+               if (ignore)
                        continue;
 
-               /* OK, so we really should examine this address. First check
-                  whether there is some client here at all! */
-               if (i2c_smbus_xfer(adapter,addr,0,0,0,I2C_SMBUS_QUICK,NULL) >= 0)
-                       if ((err = found_proc(adapter,addr,-1)))
-                               return err;
+               dev_dbg(&adapter->dev, "found normal entry for adapter %d, "
+                       "addr 0x%02x\n", adap_id,
+                       address_data->normal_i2c[i]);
+               err = i2c_probe_address(adapter, address_data->normal_i2c[i],
+                                       -1, found_proc);
+               if (err)
+                       return err;
        }
-       return 0;
-}
 
-/*
- * return id number for a specific adapter
- */
-int i2c_adapter_id(struct i2c_adapter *adap)
-{
-       return adap->nr;
+       return 0;
 }
 
 struct i2c_adapter* i2c_get_adapter(int id)
@@ -1171,6 +1194,12 @@ s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags,
 }
 
 
+/* Next four are needed by i2c-isa */
+EXPORT_SYMBOL_GPL(i2c_adapter_dev_release);
+EXPORT_SYMBOL_GPL(i2c_adapter_driver);
+EXPORT_SYMBOL_GPL(i2c_adapter_class);
+EXPORT_SYMBOL_GPL(i2c_bus_type);
+
 EXPORT_SYMBOL(i2c_add_adapter);
 EXPORT_SYMBOL(i2c_del_adapter);
 EXPORT_SYMBOL(i2c_add_driver);
@@ -1186,7 +1215,6 @@ EXPORT_SYMBOL(i2c_master_send);
 EXPORT_SYMBOL(i2c_master_recv);
 EXPORT_SYMBOL(i2c_control);
 EXPORT_SYMBOL(i2c_transfer);
-EXPORT_SYMBOL(i2c_adapter_id);
 EXPORT_SYMBOL(i2c_get_adapter);
 EXPORT_SYMBOL(i2c_put_adapter);
 EXPORT_SYMBOL(i2c_probe);
index bc5d557e5dd93063ba7d6a18d2abde2569e482cd..aa7a4fadef64d6d8106bd1a9d80d5227e8d9026a 100644 (file)
@@ -434,7 +434,8 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap)
 
        devfs_mk_cdev(MKDEV(I2C_MAJOR, i2c_dev->minor),
                        S_IFCHR|S_IRUSR|S_IWUSR, "i2c/%d", i2c_dev->minor);
-       dev_dbg(&adap->dev, "Registered as minor %d\n", i2c_dev->minor);
+       pr_debug("i2c-dev: adapter [%s] registered as minor %d\n",
+                adap->name, i2c_dev->minor);
 
        /* register this i2c device with the driver core */
        i2c_dev->adap = adap;
@@ -471,7 +472,7 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap)
        wait_for_completion(&i2c_dev->released);
        kfree(i2c_dev);
 
-       dev_dbg(&adap->dev, "Adapter unregistered\n");
+       pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name);
        return 0;
 }
 
diff --git a/drivers/i2c/i2c-sensor-detect.c b/drivers/i2c/i2c-sensor-detect.c
deleted file mode 100644 (file)
index f99a816..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
-    i2c-sensor-detect.c - Part of lm_sensors, Linux kernel modules for hardware
-                         monitoring
-    Copyright (c) 1998 - 2001 Frodo Looijaard <frodol@dds.nl> and
-    Mark D. Studebaker <mdsxyz123@yahoo.com>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
-
-static unsigned short empty[] = {I2C_CLIENT_END};
-static unsigned int empty_isa[] = {I2C_CLIENT_ISA_END};
-
-/* Very inefficient for ISA detects, and won't work for 10-bit addresses! */
-int i2c_detect(struct i2c_adapter *adapter,
-              struct i2c_address_data *address_data,
-              int (*found_proc) (struct i2c_adapter *, int, int))
-{
-       int addr, i, found, j, err;
-       struct i2c_force_data *this_force;
-       int is_isa = i2c_is_isa_adapter(adapter);
-       int adapter_id =
-           is_isa ? ANY_I2C_ISA_BUS : i2c_adapter_id(adapter);
-       unsigned short *normal_i2c;
-       unsigned int *normal_isa;
-       unsigned short *probe;
-       unsigned short *ignore;
-
-       /* Forget it if we can't probe using SMBUS_QUICK */
-       if ((!is_isa) &&
-           !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK))
-               return -1;
-       
-       /* Use default "empty" list if the adapter doesn't specify any */
-       normal_i2c = probe = ignore = empty;
-       normal_isa = empty_isa;
-       if (address_data->normal_i2c)
-               normal_i2c = address_data->normal_i2c;
-       if (address_data->normal_isa)
-               normal_isa = address_data->normal_isa;
-       if (address_data->probe)
-               probe = address_data->probe;
-       if (address_data->ignore)
-               ignore = address_data->ignore;
-
-       for (addr = 0x00; addr <= (is_isa ? 0xffff : 0x7f); addr++) {
-               if (!is_isa && i2c_check_addr(adapter, addr))
-                       continue;
-
-               /* If it is in one of the force entries, we don't do any
-                  detection at all */
-               found = 0;
-               for (i = 0; !found && (this_force = address_data->forces + i, this_force->force); i++) {
-                       for (j = 0; !found && (this_force->force[j] != I2C_CLIENT_END); j += 2) {
-                               if ( ((adapter_id == this_force->force[j]) ||
-                                     ((this_force->force[j] == ANY_I2C_BUS) && !is_isa)) &&
-                                     (addr == this_force->force[j + 1]) ) {
-                                       dev_dbg(&adapter->dev, "found force parameter for adapter %d, addr %04x\n", adapter_id, addr);
-                                       if ((err = found_proc(adapter, addr, this_force->kind)))
-                                               return err;
-                                       found = 1;
-                               }
-                       }
-               }
-               if (found)
-                       continue;
-
-               /* If this address is in one of the ignores, we can forget about it
-                  right now */
-               for (i = 0; !found && (ignore[i] != I2C_CLIENT_END); i += 2) {
-                       if ( ((adapter_id == ignore[i]) ||
-                             ((ignore[i] == ANY_I2C_BUS) &&
-                              !is_isa)) &&
-                             (addr == ignore[i + 1])) {
-                               dev_dbg(&adapter->dev, "found ignore parameter for adapter %d, addr %04x\n", adapter_id, addr);
-                               found = 1;
-                       }
-               }
-               if (found)
-                       continue;
-
-               /* Now, we will do a detection, but only if it is in the normal or 
-                  probe entries */
-               if (is_isa) {
-                       for (i = 0; !found && (normal_isa[i] != I2C_CLIENT_ISA_END); i += 1) {
-                               if (addr == normal_isa[i]) {
-                                       dev_dbg(&adapter->dev, "found normal isa entry for adapter %d, addr %04x\n", adapter_id, addr);
-                                       found = 1;
-                               }
-                       }
-               } else {
-                       for (i = 0; !found && (normal_i2c[i] != I2C_CLIENT_END); i += 1) {
-                               if (addr == normal_i2c[i]) {
-                                       found = 1;
-                                       dev_dbg(&adapter->dev, "found normal i2c entry for adapter %d, addr %02x\n", adapter_id, addr);
-                               }
-                       }
-               }
-
-               for (i = 0;
-                    !found && (probe[i] != I2C_CLIENT_END);
-                    i += 2) {
-                       if (((adapter_id == probe[i]) ||
-                            ((probe[i] == ANY_I2C_BUS) && !is_isa))
-                           && (addr == probe[i + 1])) {
-                               dev_dbg(&adapter->dev, "found probe parameter for adapter %d, addr %04x\n", adapter_id, addr);
-                               found = 1;
-                       }
-               }
-               if (!found)
-                       continue;
-
-               /* OK, so we really should examine this address. First check
-                  whether there is some client here at all! */
-               if (is_isa ||
-                   (i2c_smbus_xfer (adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) >= 0))
-                       if ((err = found_proc(adapter, addr, -1)))
-                               return err;
-       }
-       return 0;
-}
-
-EXPORT_SYMBOL(i2c_detect);
-
-MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>, "
-             "Rudolf Marek <r.marek@sh.cvut.cz>");
-
-MODULE_DESCRIPTION("i2c-sensor driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/i2c-sensor-vid.c b/drivers/i2c/i2c-sensor-vid.c
deleted file mode 100644 (file)
index 922e22f..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
-    i2c-sensor-vid.c -  Part of lm_sensors, Linux kernel modules for hardware
-                       monitoring
-
-    Copyright (c) 2004 Rudolf Marek <r.marek@sh.cvut.cz>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-
-struct vrm_model {
-       u8 vendor;
-       u8 eff_family;
-       u8 eff_model;
-       int vrm_type;
-};
-
-#define ANY 0xFF
-
-#ifdef CONFIG_X86
-
-static struct vrm_model vrm_models[] = {
-       {X86_VENDOR_AMD, 0x6, ANY, 90},         /* Athlon Duron etc */
-       {X86_VENDOR_AMD, 0xF, ANY, 24},         /* Athlon 64, Opteron */
-       {X86_VENDOR_INTEL, 0x6, 0x9, 85},       /* 0.13um too */
-       {X86_VENDOR_INTEL, 0x6, 0xB, 85},       /* 0xB Tualatin */
-       {X86_VENDOR_INTEL, 0x6, ANY, 82},       /* any P6 */
-       {X86_VENDOR_INTEL, 0x7, ANY, 0},        /* Itanium */
-       {X86_VENDOR_INTEL, 0xF, 0x3, 100},      /* P4 Prescott */
-       {X86_VENDOR_INTEL, 0xF, ANY, 90},       /* P4 before Prescott */
-       {X86_VENDOR_INTEL, 0x10,ANY, 0},        /* Itanium 2 */
-       {X86_VENDOR_UNKNOWN, ANY, ANY, 0}       /* stop here */
-       };
-
-static int find_vrm(u8 eff_family, u8 eff_model, u8 vendor)
-{
-       int i = 0;
-
-       while (vrm_models[i].vendor!=X86_VENDOR_UNKNOWN) {
-               if (vrm_models[i].vendor==vendor)
-                       if ((vrm_models[i].eff_family==eff_family)&& \
-                       ((vrm_models[i].eff_model==eff_model)|| \
-                       (vrm_models[i].eff_model==ANY)))
-                               return vrm_models[i].vrm_type;
-               i++;
-       }
-
-       return 0;
-}
-
-int i2c_which_vrm(void)
-{
-       struct cpuinfo_x86 *c = cpu_data;
-       u32 eax;
-       u8 eff_family, eff_model;
-       int vrm_ret;
-
-       if (c->x86 < 6) return 0;       /* any CPU with familly lower than 6
-                                       dont have VID and/or CPUID */
-       eax = cpuid_eax(1);
-       eff_family = ((eax & 0x00000F00)>>8);
-       eff_model  = ((eax & 0x000000F0)>>4);
-       if (eff_family == 0xF) {        /* use extended model & family */
-               eff_family += ((eax & 0x00F00000)>>20);
-               eff_model += ((eax & 0x000F0000)>>16)<<4;
-       }
-       vrm_ret = find_vrm(eff_family,eff_model,c->x86_vendor);
-       if (vrm_ret == 0)
-               printk(KERN_INFO "i2c-sensor.o: Unknown VRM version of your"
-               " x86 CPU\n");
-       return vrm_ret;
-}
-
-/* and now for something completely different for Non-x86 world*/
-#else
-int i2c_which_vrm(void)
-{
-       printk(KERN_INFO "i2c-sensor.o: Unknown VRM version of your CPU\n");
-       return 0;
-}
-#endif
-
-EXPORT_SYMBOL(i2c_which_vrm);
index 248e3cc8b3527dd37bbc8a60417a1658e46d8845..f174aee659e5e0d086314e6ba3ebcfb3c92249cc 100644 (file)
@@ -150,7 +150,7 @@ static void ide_complete_power_step(ide_drive_t *drive, struct request *rq, u8 s
 
        switch (rq->pm->pm_step) {
        case ide_pm_flush_cache:        /* Suspend step 1 (flush cache) complete */
-               if (rq->pm->pm_state == 4)
+               if (rq->pm->pm_state == PM_EVENT_FREEZE)
                        rq->pm->pm_step = ide_pm_state_completed;
                else
                        rq->pm->pm_step = idedisk_pm_standby;
index dae1bd5b8c3e1e16872af0eb5470ff93b3231230..73ca8f73917d9172bba616311437ccb3de9966e9 100644 (file)
@@ -1229,7 +1229,7 @@ static int generic_ide_suspend(struct device *dev, pm_message_t state)
        rq.special = &args;
        rq.pm = &rqpm;
        rqpm.pm_step = ide_pm_state_start_suspend;
-       rqpm.pm_state = state;
+       rqpm.pm_state = state.event;
 
        return ide_do_drive_cmd(drive, &rq, ide_wait);
 }
@@ -1248,7 +1248,7 @@ static int generic_ide_resume(struct device *dev)
        rq.special = &args;
        rq.pm = &rqpm;
        rqpm.pm_step = ide_pm_state_start_resume;
-       rqpm.pm_state = 0;
+       rqpm.pm_state = PM_EVENT_ON;
 
        return ide_do_drive_cmd(drive, &rq, ide_head_wait);
 }
index 10592cec6c43aca4e7bdf2443cff2d0dde5ca402..24e21b2838c15028bd4f72c4a2305ddf0b7b54a3 100644 (file)
@@ -350,9 +350,9 @@ static int sc1200_suspend (struct pci_dev *dev, pm_message_t state)
 {
        ide_hwif_t              *hwif = NULL;
 
-       printk("SC1200: suspend(%u)\n", state);
+       printk("SC1200: suspend(%u)\n", state.event);
 
-       if (state == 0) {
+       if (state.event == PM_EVENT_ON) {
                // we only save state when going from full power to less
 
                //
@@ -386,8 +386,8 @@ static int sc1200_suspend (struct pci_dev *dev, pm_message_t state)
        /* You don't need to iterate over disks -- sysfs should have done that for you already */ 
 
        pci_disable_device(dev);
-       pci_set_power_state(dev,state);
-       dev->current_state = state;
+       pci_set_power_state(dev, pci_choose_state(dev, state));
+       dev->current_state = state.event;
        return 0;
 }
 
@@ -396,8 +396,8 @@ static int sc1200_resume (struct pci_dev *dev)
        ide_hwif_t      *hwif = NULL;
 
 printk("SC1200: resume\n");
-       pci_set_power_state(dev,0);     // bring chip back from sleep state
-       dev->current_state = 0;
+       pci_set_power_state(dev, PCI_D0);       // bring chip back from sleep state
+       dev->current_state = PM_EVENT_ON;
        pci_enable_device(dev);
        //
        // loop over all interfaces that are part of this pci device:
index ea65b070a3675b2e3c3f2b6e1e1840f93adb6cb8..87d1f8a1f41e4de7a0595d8702bf101276af2ba5 100644 (file)
@@ -1504,12 +1504,12 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
 }
 
 static int
-pmac_ide_macio_suspend(struct macio_dev *mdev, u32 state)
+pmac_ide_macio_suspend(struct macio_dev *mdev, pm_message_t state)
 {
        ide_hwif_t      *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev);
        int             rc = 0;
 
-       if (state != mdev->ofdev.dev.power.power_state && state >= 2) {
+       if (state.event != mdev->ofdev.dev.power.power_state.event && state.event >= PM_EVENT_SUSPEND) {
                rc = pmac_ide_do_suspend(hwif);
                if (rc == 0)
                        mdev->ofdev.dev.power.power_state = state;
@@ -1524,10 +1524,10 @@ pmac_ide_macio_resume(struct macio_dev *mdev)
        ide_hwif_t      *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev);
        int             rc = 0;
        
-       if (mdev->ofdev.dev.power.power_state != 0) {
+       if (mdev->ofdev.dev.power.power_state.event != PM_EVENT_ON) {
                rc = pmac_ide_do_resume(hwif);
                if (rc == 0)
-                       mdev->ofdev.dev.power.power_state = 0;
+                       mdev->ofdev.dev.power.power_state = PMSG_ON;
        }
 
        return rc;
@@ -1608,12 +1608,12 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
 }
 
 static int
-pmac_ide_pci_suspend(struct pci_dev *pdev, u32 state)
+pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 {
        ide_hwif_t      *hwif = (ide_hwif_t *)pci_get_drvdata(pdev);
        int             rc = 0;
        
-       if (state != pdev->dev.power.power_state && state >= 2) {
+       if (state.event != pdev->dev.power.power_state.event && state.event >= 2) {
                rc = pmac_ide_do_suspend(hwif);
                if (rc == 0)
                        pdev->dev.power.power_state = state;
@@ -1628,10 +1628,10 @@ pmac_ide_pci_resume(struct pci_dev *pdev)
        ide_hwif_t      *hwif = (ide_hwif_t *)pci_get_drvdata(pdev);
        int             rc = 0;
        
-       if (pdev->dev.power.power_state != 0) {
+       if (pdev->dev.power.power_state.event != PM_EVENT_ON) {
                rc = pmac_ide_do_resume(hwif);
                if (rc == 0)
-                       pdev->dev.power.power_state = 0;
+                       pdev->dev.power.power_state = PMSG_ON;
        }
 
        return rc;
index 36074e6eeebb5703e9a9848f40254c000eef65b8..6b1ab875333b1d54d88fc53f40fc571899538985 100644 (file)
@@ -1464,26 +1464,6 @@ static int __devinit add_card(struct pci_dev *dev,
                                                   { 0x50, I2C_M_RD, 20, (unsigned char*) lynx->bus_info_block }
                                                 };
 
-
-#ifdef CONFIG_IEEE1394_VERBOSEDEBUG
-                        union i2c_smbus_data data;
-
-                        if (i2c_smbus_xfer(i2c_ad, 80, 0, I2C_SMBUS_WRITE, 0, I2C_SMBUS_BYTE,NULL))
-                                PRINT(KERN_ERR, lynx->id,"eeprom read start has failed");
-                        else
-                        {
-                                u16 addr;
-                                for (addr=0x00; addr < 0x100; addr++) {
-                                        if (i2c_smbus_xfer(i2c_ad, 80, 0, I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE,& data)) {
-                                                PRINT(KERN_ERR, lynx->id, "unable to read i2c %x", addr);
-                                                break;
-                                        }
-                                        else
-                                                PRINT(KERN_DEBUG, lynx->id,"got serial eeprom data at %x: %x",addr, data.byte);
-                                }
-                        }
-#endif
-
                         /* we use i2c_transfer, because i2c_smbus_read_block_data does not work properly and we
                            do it more efficiently in one transaction rather then using several reads */
                         if (i2c_transfer(i2c_ad, msg, 2) < 0) {
index 20e3a165989fb943b0ce29a2009120ce86b57f0b..f8b278d3559bc2b3553d8949192ee1ce6494bc78 100644 (file)
@@ -160,6 +160,8 @@ struct input_event_compat {
 #  define COMPAT_TEST IS_IA32_PROCESS(ia64_task_regs(current))
 #elif defined(CONFIG_ARCH_S390)
 #  define COMPAT_TEST test_thread_flag(TIF_31BIT)
+#elif defined(CONFIG_MIPS)
+#  define COMPAT_TEST (current->thread.mflags & MF_32BIT_ADDR)
 #else
 #  define COMPAT_TEST test_thread_flag(TIF_32BIT)
 #endif
index 7c16c25fc5d471068945bf04d9bc00c63b4e037f..c0712a1ea5afabc9e7370371bf545fe11d1b118d 100644 (file)
@@ -708,7 +708,7 @@ static int __pmac media_bay_suspend(struct macio_dev *mdev, pm_message_t state)
 {
        struct media_bay_info   *bay = macio_get_drvdata(mdev);
 
-       if (state != mdev->ofdev.dev.power.power_state && state == PM_SUSPEND_MEM) {
+       if (state.event != mdev->ofdev.dev.power.power_state.event && state.event == PM_EVENT_SUSPEND) {
                down(&bay->lock);
                bay->sleeping = 1;
                set_mb_power(bay, 0);
@@ -723,8 +723,8 @@ static int __pmac media_bay_resume(struct macio_dev *mdev)
 {
        struct media_bay_info   *bay = macio_get_drvdata(mdev);
 
-       if (mdev->ofdev.dev.power.power_state != 0) {
-               mdev->ofdev.dev.power.power_state = 0;
+       if (mdev->ofdev.dev.power.power_state.event != PM_EVENT_ON) {
+               mdev->ofdev.dev.power.power_state = PMSG_ON;
 
                /* We re-enable the bay using it's previous content
                   only if it did not change. Note those bozo timings,
index 4a0a0ad2d03c09e7bff0e9185c4355e274514264..645a2e5c70ab494298b9d0359dcb38726d5fe4d6 100644 (file)
@@ -3065,7 +3065,7 @@ static int pmu_sys_suspended = 0;
 
 static int pmu_sys_suspend(struct sys_device *sysdev, pm_message_t state)
 {
-       if (state != PM_SUSPEND_DISK || pmu_sys_suspended)
+       if (state.event != PM_EVENT_SUSPEND || pmu_sys_suspended)
                return 0;
 
        /* Suspend PMU event interrupts */
index d0a4bab220e5e6b5608e50810b3dead70e7be095..b82bc31504762e8bee7db798d44d1ce697b43258 100644 (file)
@@ -144,7 +144,7 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
        }
 
        /* Hash the cipher key with the given hash algorithm */
-       hash_tfm = crypto_alloc_tfm(opts, 0);
+       hash_tfm = crypto_alloc_tfm(opts, CRYPTO_TFM_REQ_MAY_SLEEP);
        if (hash_tfm == NULL) {
                ti->error = PFX "Error initializing ESSIV hash";
                return -EINVAL;
@@ -172,7 +172,8 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
 
        /* Setup the essiv_tfm with the given salt */
        essiv_tfm = crypto_alloc_tfm(crypto_tfm_alg_name(cc->tfm),
-                                    CRYPTO_TFM_MODE_ECB);
+                                    CRYPTO_TFM_MODE_ECB |
+                                    CRYPTO_TFM_REQ_MAY_SLEEP);
        if (essiv_tfm == NULL) {
                ti->error = PFX "Error allocating crypto tfm for ESSIV";
                kfree(salt);
@@ -587,7 +588,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
                goto bad1;
        }
 
-       tfm = crypto_alloc_tfm(cipher, crypto_flags);
+       tfm = crypto_alloc_tfm(cipher, crypto_flags | CRYPTO_TFM_REQ_MAY_SLEEP);
        if (!tfm) {
                ti->error = PFX "Error allocating crypto tfm";
                goto bad1;
index 781f23f0cbcc597e79363d230cda2872908b06e3..6284894505c6f0595d8afb06e06087c1b8231cbe 100644 (file)
@@ -387,8 +387,6 @@ static int saa7146_i2c_xfer(struct i2c_adapter* adapter, struct i2c_msg *msg, in
 
 /* exported algorithm data */
 static struct i2c_algorithm saa7146_algo = {
-       .name           = "saa7146 i2c algorithm",
-       .id             = I2C_ALGO_SAA7146,
        .master_xfer    = saa7146_i2c_xfer,
        .functionality  = saa7146_i2c_func,
 };
@@ -412,7 +410,7 @@ int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c
 #endif
                i2c_adapter->algo          = &saa7146_algo;
                i2c_adapter->algo_data     = NULL;
-               i2c_adapter->id            = I2C_ALGO_SAA7146;
+               i2c_adapter->id            = I2C_HW_SAA7146;
                i2c_adapter->timeout = SAA7146_I2C_TIMEOUT;
                i2c_adapter->retries = SAA7146_I2C_RETRIES;
        }
index be4266d4ae9114da7d1a56e74f97453ee9e14065..56495cb6cd02d39a3ded4a581e3d732231c4c320 100644 (file)
@@ -172,8 +172,6 @@ static u32 flexcop_i2c_func(struct i2c_adapter *adapter)
 }
 
 static struct i2c_algorithm flexcop_algo = {
-       .name                   = "FlexCop I2C algorithm",
-       .id                             = I2C_ALGO_BIT,
        .master_xfer    = flexcop_master_xfer,
        .functionality  = flexcop_i2c_func,
 };
@@ -192,7 +190,6 @@ int flexcop_i2c_init(struct flexcop_device *fc)
        fc->i2c_adap.class          = I2C_CLASS_TV_DIGITAL;
        fc->i2c_adap.algo       = &flexcop_algo;
        fc->i2c_adap.algo_data  = NULL;
-       fc->i2c_adap.id         = I2C_ALGO_BIT;
 
        if ((ret = i2c_add_adapter(&fc->i2c_adap)) < 0)
                return ret;
index 7d8b3cad350bea238b84d4029cf209d894c116f5..9ea5747b121101759808370f15f68d6e2280312e 100644 (file)
@@ -888,7 +888,7 @@ static int cinergyt2_suspend (struct usb_interface *intf, pm_message_t state)
        if (down_interruptible(&cinergyt2->sem))
                return -ERESTARTSYS;
 
-       if (state > 0) {        /* state 0 seems to mean DEVICE_PM_ON */
+       if (state.event > PM_EVENT_ON) {
                struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
 #ifdef ENABLE_RC
                cancel_delayed_work(&cinergyt2->rc_query_work);
index c3e1b661aae632b74c74c207e67a0f1c1483605b..9e96a188f1e9a7b0996c44d64eb6d90aa10cdc54 100644 (file)
@@ -141,8 +141,6 @@ static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
 }
 
 static struct i2c_algorithm cxusb_i2c_algo = {
-       .name          = "Conexant USB I2C algorithm",
-       .id            = I2C_ALGO_BIT,
        .master_xfer   = cxusb_i2c_xfer,
        .functionality = cxusb_i2c_func,
 };
index 9b9d6f8ee74eb768d919297c82a9818cbeac8987..00b946419b408fb1128bd52088f2d5fd034f4811 100644 (file)
@@ -156,8 +156,6 @@ static u32 dibusb_i2c_func(struct i2c_adapter *adapter)
 }
 
 struct i2c_algorithm dibusb_i2c_algo = {
-       .name          = "DiBcom USB I2C algorithm",
-       .id            = I2C_ALGO_BIT,
        .master_xfer   = dibusb_i2c_xfer,
        .functionality = dibusb_i2c_func,
 };
index 9a676afc1d6e89c4943db39b1e3a93202adbf033..f70e0be0920aee35ef9b1cdc075a4331fc3e7511 100644 (file)
@@ -77,8 +77,6 @@ static u32 digitv_i2c_func(struct i2c_adapter *adapter)
 }
 
 static struct i2c_algorithm digitv_i2c_algo = {
-       .name          = "Nebula DigiTV USB I2C algorithm",
-       .id            = I2C_ALGO_BIT,
        .master_xfer   = digitv_i2c_xfer,
        .functionality = digitv_i2c_func,
 };
index 9f0a8d90d1463885c106b9f8191f012f13f25824..da970947dfc72e5a77df1a4fa4a552c8ad16b038 100644 (file)
@@ -27,7 +27,6 @@ int dvb_usb_i2c_init(struct dvb_usb_device *d)
 #endif
        d->i2c_adap.algo      = d->props.i2c_algo;
        d->i2c_adap.algo_data = NULL;
-       d->i2c_adap.id        = I2C_ALGO_BIT;
 
        i2c_set_adapdata(&d->i2c_adap, d);
 
index 706e0bcb5ede3dd750f8387cc9ccd156834cdcf4..85b437bbddcdaed624b6a1389dafd982b5560c07 100644 (file)
@@ -633,7 +633,6 @@ static int __devinit pluto2_probe(struct pci_dev *pdev,
        i2c_set_adapdata(&pluto->i2c_adap, pluto);
        strcpy(pluto->i2c_adap.name, DRIVER_NAME);
        pluto->i2c_adap.owner = THIS_MODULE;
-       pluto->i2c_adap.id = I2C_ALGO_BIT;
        pluto->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
        pluto->i2c_adap.dev.parent = &pdev->dev;
        pluto->i2c_adap.algo_data = &pluto->i2c_bit;
index bf3c011d2cfb3cbc77852c36712d665fe5e25e6f..d8bf65877897bd6a0e1650c19e825584ead7ea9c 100644 (file)
@@ -102,6 +102,9 @@ config DVB_BUDGET_AV
        select VIDEO_DEV
        select VIDEO_SAA7146_VV
        select DVB_STV0299
+       select DVB_TDA1004X
+       select DVB_TDA10021
+       select FW_LOADER
        help
          Support for simple SAA7146 based DVB cards
          (so called Budget- or Nova-PCI cards) without onboard
index aa43b5fcb8e7b352999ef911f93d7fc4f9955155..7daf7b1598a0d4dfb96c37daf6b406044d03bf8c 100644 (file)
@@ -1472,8 +1472,6 @@ static void frontend_init(struct ttusb* ttusb)
 
 
 static struct i2c_algorithm ttusb_dec_algo = {
-       .name           = "ttusb dec i2c algorithm",
-       .id             = I2C_ALGO_BIT,
        .master_xfer    = master_xfer,
        .functionality  = functionality,
 };
@@ -1525,7 +1523,6 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
 #endif
        ttusb->i2c_adap.algo              = &ttusb_dec_algo;
        ttusb->i2c_adap.algo_data         = NULL;
-       ttusb->i2c_adap.id                = I2C_ALGO_BIT;
 
        result = i2c_add_adapter(&ttusb->i2c_adap);
        if (result) {
index 3f5742396096dd61cbc49648c63d763bb530b84e..16c85c081e6ebe1533462a08084d0427a93f90bb 100644 (file)
@@ -254,6 +254,7 @@ config VIDEO_SAA7134_DVB
        select VIDEO_BUF_DVB
        select DVB_MT352
        select DVB_CX22702
+       select DVB_TDA1004X
        ---help---
          This adds support for DVB cards based on the
          Philips saa7134 chip.
index 48989eda2400a120e5fea0a7e74bc500309d10e5..52e32f05d625b2fc9c0bcba9caa2aa60b9ac8878 100644 (file)
@@ -391,7 +391,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_i2c,
        .probe                  = &ignore,
        .ignore                 = &ignore,
-       .force                  = &ignore,
 };
 
 static struct i2c_driver i2c_driver_adv7170;
index f898b65863741162d6269cf062d625e51660d3be..b5ed9544bdea14702564a7037f96ed9bc388e3ca 100644 (file)
@@ -441,7 +441,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_i2c,
        .probe                  = &ignore,
        .ignore                 = &ignore,
-       .force                  = &ignore,
 };
 
 static struct i2c_driver i2c_driver_adv7175;
index 8733588f6db3db1905628cc1ba99a4c62c51ec9e..c6cfa7c48b04e5d5547437ab6703f61d25653dc2 100644 (file)
@@ -507,7 +507,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_i2c,
        .probe                  = &ignore,
        .ignore                 = &ignore,
-       .force                  = &ignore,
 };
 
 static struct i2c_driver i2c_driver_bt819;
index a070417e65e6c9ce5a4219c00cf944a35c0fb6a2..76c1b63ebdf27b4eb78c47cdd8a4d74065ca62dc 100644 (file)
@@ -188,7 +188,7 @@ static int bt832_probe(struct i2c_adapter *adap)
        if (adap->class & I2C_CLASS_TV_ANALOG)
                return i2c_probe(adap, &addr_data, bt832_attach);
 #else
-       if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848))
+       if (adap->id == I2C_HW_B_BT848)
                return i2c_probe(adap, &addr_data, bt832_attach);
 #endif
        return 0;
@@ -241,7 +241,7 @@ static struct i2c_driver driver = {
 };
 static struct i2c_client client_template =
 {
-       I2C_DEVNAME("bt832"),
+       .name       = "bt832",
        .flags      = I2C_CLIENT_ALLOW_USE,
         .driver     = &driver,
 };
index a5d529ccf3ad174fb1aead3cac87e48f03dcebd2..c13d2865886882b36c3a8ee91f4a39a11e8c0362 100644 (file)
@@ -295,7 +295,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_i2c,
        .probe                  = &ignore,
        .ignore                 = &ignore,
-       .force                  = &ignore,
 };
 
 static struct i2c_driver i2c_driver_bt856;
index eee9322ce21b06efb02a6bf51e2b662231983189..087efb4dea09a4b67a36e21a7a46c28f76c8831a 100644 (file)
@@ -4047,7 +4047,6 @@ static int bttv_suspend(struct pci_dev *pci_dev, pm_message_t state)
        struct bttv_buffer_set idle;
        unsigned long flags;
 
-       dprintk("bttv%d: suspend %d\n", btv->c.nr, state);
 
        /* stop dma + irqs */
        spin_lock_irqsave(&btv->s_lock,flags);
index 234a85563769164e69987082961728d45a20af1b..706dc48df9625e1741bc9c9029db86b897fe500a 100644 (file)
@@ -109,7 +109,7 @@ static struct i2c_adapter bttv_i2c_adap_sw_template = {
 #ifdef I2C_CLASS_TV_ANALOG
        .class             = I2C_CLASS_TV_ANALOG,
 #endif
-       I2C_DEVNAME("bt848"),
+       .name              = "bt848",
        .id                = I2C_HW_B_BT848,
        .client_register   = attach_inform,
 };
@@ -270,8 +270,6 @@ static int bttv_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int
 }
 
 static struct i2c_algorithm bttv_algo = {
-       .name          = "bt878",
-       .id            = I2C_ALGO_BIT | I2C_HW_B_BT848 /* FIXME */,
        .master_xfer   = bttv_i2c_xfer,
        .algo_control  = algo_control,
        .functionality = functionality,
@@ -282,8 +280,8 @@ static struct i2c_adapter bttv_i2c_adap_hw_template = {
 #ifdef I2C_CLASS_TV_ANALOG
        .class         = I2C_CLASS_TV_ANALOG,
 #endif
-       I2C_DEVNAME("bt878"),
-       .id            = I2C_ALGO_BIT | I2C_HW_B_BT848 /* FIXME */,
+       .name          = "bt878",
+       .id            = I2C_HW_B_BT848 /* FIXME */,
        .algo          = &bttv_algo,
        .client_register = attach_inform,
 };
@@ -298,7 +296,7 @@ static int attach_inform(struct i2c_client *client)
        if (bttv_debug)
                printk(KERN_DEBUG "bttv%d: %s i2c attach [addr=0x%x,client=%s]\n",
                        btv->c.nr,client->driver->name,client->addr,
-                       i2c_clientname(client));
+                       client->name);
        if (!client->driver->command)
                return 0;
 
@@ -326,7 +324,7 @@ void bttv_call_i2c_clients(struct bttv *btv, unsigned int cmd, void *arg)
 }
 
 static struct i2c_client bttv_i2c_client_template = {
-       I2C_DEVNAME("bttv internal"),
+       .name   = "bttv internal",
 };
 
 
index a628a55299c670cb87f1554f6e566f3fff69a664..7f598039e0257602bf8016c9e097b982e2c257e3 100644 (file)
@@ -95,7 +95,7 @@ static int attach_inform(struct i2c_client *client)
        struct cx88_core *core = i2c_get_adapdata(client->adapter);
 
        dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n",
-               client->driver->name,client->addr,i2c_clientname(client));
+               client->driver->name, client->addr, client->name);
        if (!client->driver->command)
                return 0;
 
@@ -128,7 +128,7 @@ static int detach_inform(struct i2c_client *client)
 {
        struct cx88_core *core = i2c_get_adapdata(client->adapter);
 
-       dprintk(1, "i2c detach [client=%s]\n", i2c_clientname(client));
+       dprintk(1, "i2c detach [client=%s]\n", client->name);
        return 0;
 }
 
@@ -152,7 +152,7 @@ static struct i2c_algo_bit_data cx8800_i2c_algo_template = {
 /* ----------------------------------------------------------------------- */
 
 static struct i2c_adapter cx8800_i2c_adap_template = {
-       I2C_DEVNAME("cx2388x"),
+       .name              = "cx2388x",
        .owner             = THIS_MODULE,
        .id                = I2C_HW_B_CX2388x,
        .client_register   = attach_inform,
@@ -160,7 +160,7 @@ static struct i2c_adapter cx8800_i2c_adap_template = {
 };
 
 static struct i2c_client cx8800_i2c_client_template = {
-        I2C_DEVNAME("cx88xx internal"),
+        .name  = "cx88xx internal",
 };
 
 static char *i2c_devs[128] = {
index 9fc5055e001cd9f0f5aeaaee1a856ff093070edd..1e273ff3f956802b9b664a62e3c9505e1e8efc49 100644 (file)
@@ -308,7 +308,7 @@ static struct i2c_driver driver = {
 
 static struct i2c_client client_template =
 {
-        I2C_DEVNAME("unset"),
+        .name = "unset",
         .driver = &driver
 };
 
@@ -429,10 +429,10 @@ static int ir_probe(struct i2c_adapter *adap)
        struct i2c_client c; char buf; int i,rc;
 
        switch (adap->id) {
-       case I2C_ALGO_BIT | I2C_HW_B_BT848:
+       case I2C_HW_B_BT848:
                probe = probe_bttv;
                break;
-       case I2C_ALGO_SAA7134:
+       case I2C_HW_SAA7134:
                probe = probe_saa7134;
                break;
        }
index 62f1b8ddb98b8bc153602271c7d84337c6e67efe..ca02f6f14b000ece1f11eb12333da9b141dd2e90 100644 (file)
@@ -1416,7 +1416,7 @@ static int msp_detach(struct i2c_client *client);
 static int msp_probe(struct i2c_adapter *adap);
 static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg);
 
-static int msp_suspend(struct device * dev, u32 state, u32 level);
+static int msp_suspend(struct device * dev, pm_message_t state, u32 level);
 static int msp_resume(struct device * dev, u32 level);
 
 static void msp_wake_thread(struct i2c_client *client);
@@ -1437,7 +1437,7 @@ static struct i2c_driver driver = {
 
 static struct i2c_client client_template =
 {
-       I2C_DEVNAME("(unset)"),
+       .name      = "(unset)",
        .flags     = I2C_CLIENT_ALLOW_USE,
         .driver    = &driver,
 };
@@ -1509,7 +1509,7 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind)
        }
 
        /* hello world :-) */
-       printk(KERN_INFO "msp34xx: init: chip=%s",i2c_clientname(c));
+       printk(KERN_INFO "msp34xx: init: chip=%s", c->name);
        if (HAVE_NICAM(msp))
                printk(" +nicam");
        if (HAVE_SIMPLE(msp))
@@ -1817,7 +1817,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
        return 0;
 }
 
-static int msp_suspend(struct device * dev, u32 state, u32 level)
+static int msp_suspend(struct device * dev, pm_message_t state, u32 level)
 {
        struct i2c_client *c = container_of(dev, struct i2c_client, dev);
 
index 3433619ad93f91c501f34677dbd822b2336dfcb4..b3f4d266cedead6f1afd053ec0b4e2edd117b88e 100644 (file)
@@ -164,10 +164,10 @@ static int ov6x20_init(struct i2c_client *c)
        DDEBUG(4, &c->dev, "entered");
 
        switch (c->adapter->id) {
-       case I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV511:
+       case I2C_HW_SMBUS_OV511:
                rc = ov_write_regvals(c, regvals_init_6x20_511);
                break;
-       case I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV518:
+       case I2C_HW_SMBUS_OV518:
                rc = ov_write_regvals(c, regvals_init_6x20_518);
                break;
        default:
@@ -338,7 +338,7 @@ static int ov6x20_mode_init(struct i2c_client *c, struct ovcamchip_window *win)
        /******** Palette-specific regs ********/
 
        /* OV518 needs 8 bit multiplexed in color mode, and 16 bit in B&W */
-       if (c->adapter->id == (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV518)) {
+       if (c->adapter->id == I2C_HW_SMBUS_OV518) {
                if (win->format == VIDEO_PALETTE_GREY)
                        ov_write_mask(c, 0x13, 0x00, 0x20);
                else
index 44a842379b457bce335279b447d348bce027886f..6eab458ab792a88e58313731f11ab27160fe1535 100644 (file)
@@ -301,7 +301,7 @@ static int ov6x30_mode_init(struct i2c_client *c, struct ovcamchip_window *win)
        /******** Palette-specific regs ********/
 
        if (win->format == VIDEO_PALETTE_GREY) {
-               if (c->adapter->id == (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV518)) {
+               if (c->adapter->id == I2C_HW_SMBUS_OV518) {
                        /* Do nothing - we're already in 8-bit mode */
                } else {
                        ov_write_mask(c, 0x13, 0x20, 0x20);
@@ -313,7 +313,7 @@ static int ov6x30_mode_init(struct i2c_client *c, struct ovcamchip_window *win)
                 * Therefore, the OV6630 needs to be in 8-bit multiplexed
                 * output mode */
 
-               if (c->adapter->id == (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV518)) {
+               if (c->adapter->id == I2C_HW_SMBUS_OV518) {
                        /* Do nothing - we want to stay in 8-bit mode */
                        /* Warning: Messing with reg 0x13 breaks OV518 color */
                } else {
index 54dd5612d3b823d2a4a761605078720cbdac51ba..2de34ebf0673db67f0785e15a845cf371c4ef4a6 100644 (file)
@@ -296,10 +296,10 @@ static int ovcamchip_attach(struct i2c_adapter *adap)
         * attach to adapters that are known to contain OV camera chips. */
 
        switch (adap->id) {
-       case (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV511):
-       case (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV518):
-       case (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OVFX2):
-       case (I2C_ALGO_SMBUS | I2C_HW_SMBUS_W9968CF):
+       case I2C_HW_SMBUS_OV511:
+       case I2C_HW_SMBUS_OV518:
+       case I2C_HW_SMBUS_OVFX2:
+       case I2C_HW_SMBUS_W9968CF:
                PDEBUG(1, "Adapter ID 0x%06x accepted", adap->id);
                break;
        default:
@@ -314,7 +314,7 @@ static int ovcamchip_attach(struct i2c_adapter *adap)
        }
        memcpy(c, &client_template, sizeof *c);
        c->adapter = adap;
-       strcpy(i2c_clientname(c), "OV????");
+       strcpy(c->name, "OV????");
 
        ov = kmalloc(sizeof *ov, GFP_KERNEL);
        if (!ov) {
@@ -328,7 +328,7 @@ static int ovcamchip_attach(struct i2c_adapter *adap)
        if (rc < 0)
                goto error;
 
-       strcpy(i2c_clientname(c), chip_names[ov->subtype]);
+       strcpy(c->name, chip_names[ov->subtype]);
 
        PDEBUG(1, "Camera chip detection complete");
 
@@ -421,7 +421,7 @@ static struct i2c_driver driver = {
 };
 
 static struct i2c_client client_template = {
-       I2C_DEVNAME("(unset)"),
+       .name =         "(unset)",
        .driver =       &driver,
 };
 
index 22d055d8a695591d04b65107a6034488c462dcb5..e116bdbed310945a3cb51f0975bac25e6776c0c7 100644 (file)
@@ -470,7 +470,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_i2c,
        .probe                  = &ignore,
        .ignore                 = &ignore,
-       .force                  = &ignore,
 };
 
 static struct i2c_driver i2c_driver_saa7110;
index fcd897382fcfc0fe5dc1271db95a6ae0079634ca..f18df53d98ff16c7b7b1027b5d0e5057ae7510c3 100644 (file)
@@ -489,7 +489,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_i2c,
        .probe                  = &ignore,
        .ignore                 = &ignore,
-       .force                  = &ignore,
 };
 
 static struct i2c_driver i2c_driver_saa7111;
index 2ba997f5ef1d50c20a785eadc3a2bfba2f3779f8..e0c70f54f0737f93cc8aa519fb588b93c0794eed 100644 (file)
@@ -827,7 +827,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_i2c,
        .probe                  = &ignore,
        .ignore                 = &ignore,
-       .force                  = &ignore,
 };
 
 static struct i2c_driver i2c_driver_saa7114;
index 79d05ea1b69b06535ddb3206ba6ed5a25e006c60..382911c6ef2243813b02fe7d8107ed5194f17b4c 100644 (file)
@@ -598,7 +598,7 @@ static struct i2c_driver driver = {
 
 static struct i2c_client client_template =
 {
-       I2C_DEVNAME("saa6752hs"),
+       .name       = "saa6752hs",
        .flags      = I2C_CLIENT_ALLOW_USE,
         .driver     = &driver,
 };
index 1203b93a572c4a80da2a872a80e5a9be7c0d58cd..eae6b529713fe6cb3ff77673878fbcaeda776aae 100644 (file)
@@ -334,7 +334,7 @@ static int attach_inform(struct i2c_client *client)
        struct tuner_setup tun_setup;
 
        d1printk( "%s i2c attach [addr=0x%x,client=%s]\n",
-               client->driver->name,client->addr,i2c_clientname(client));
+                client->driver->name, client->addr, client->name);
 
        if (!client->driver->command)
                return 0;
@@ -370,8 +370,6 @@ static int attach_inform(struct i2c_client *client)
 }
 
 static struct i2c_algorithm saa7134_algo = {
-       .name          = "saa7134",
-       .id            = I2C_ALGO_SAA7134,
        .master_xfer   = saa7134_i2c_xfer,
        .algo_control  = algo_control,
        .functionality = functionality,
@@ -382,14 +380,14 @@ static struct i2c_adapter saa7134_adap_template = {
 #ifdef I2C_CLASS_TV_ANALOG
        .class         = I2C_CLASS_TV_ANALOG,
 #endif
-       I2C_DEVNAME("saa7134"),
-       .id            = I2C_ALGO_SAA7134,
+       .name          = "saa7134",
+       .id            = I2C_HW_SAA7134,
        .algo          = &saa7134_algo,
        .client_register = attach_inform,
 };
 
 static struct i2c_client saa7134_client_template = {
-       I2C_DEVNAME("saa7134 internal"),
+       .name   = "saa7134 internal",
 };
 
 /* ----------------------------------------------------------- */
index 108e7a4a02734dbd9d1e803a0a40ab5ac2ad3691..e93412f4407cb9d7fa1008d4c21a9e018555d534 100644 (file)
@@ -387,7 +387,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_i2c,
        .probe                  = &ignore,
        .ignore                 = &ignore,
-       .force                  = &ignore,
 };
 
 static struct i2c_driver i2c_driver_saa7185;
index 7cb1fb3e66f90a46f015982657beb02c2a973f55..255b6088ebf9ba8a86f448a29b96e57f3cce33d8 100644 (file)
@@ -328,7 +328,7 @@ static int tda7432_probe(struct i2c_adapter *adap)
        if (adap->class & I2C_CLASS_TV_ANALOG)
                return i2c_probe(adap, &addr_data, tda7432_attach);
 #else
-       if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848))
+       if (adap->id == I2C_HW_B_BT848)
                return i2c_probe(adap, &addr_data, tda7432_attach);
 #endif
        return 0;
@@ -513,7 +513,7 @@ static struct i2c_driver driver = {
 
 static struct i2c_client client_template =
 {
-       I2C_DEVNAME("tda7432"),
+       .name       = "tda7432",
        .driver     = &driver,
 };
 
index c29bdfc3244e8f2562e9744d5f8d508f89a4b525..1794686612c6dccac93431e3b5f22f1f1c62f9f1 100644 (file)
@@ -205,7 +205,7 @@ static int detect(struct i2c_adapter *adapter, int address, int kind)
 static int attach(struct i2c_adapter *adapter)
 {
        /* let's see whether this is a know adapter we can attach to */
-       if (adapter->id != I2C_ALGO_SAA7146) {
+       if (adapter->id != I2C_HW_SAA7146) {
                dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id);
                return -ENODEV;
        }
@@ -231,7 +231,7 @@ static struct i2c_driver driver = {
 };
 
 static struct i2c_client client_template = {
-       I2C_DEVNAME("tda9840"),
+       .name = "tda9840",
        .driver = &driver,
 };
 
index 566e1a5ca135578c002b8d833706522bec4cd176..7e3dcdb262b0ef0c65e18a7c693da652b3da37bc 100644 (file)
@@ -262,7 +262,7 @@ static int tda9875_probe(struct i2c_adapter *adap)
        if (adap->class & I2C_CLASS_TV_ANALOG)
                return i2c_probe(adap, &addr_data, tda9875_attach);
 #else
-       if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848))
+       if (adap->id == I2C_HW_B_BT848)
                return i2c_probe(adap, &addr_data, tda9875_attach);
 #endif
        return 0;
@@ -384,7 +384,7 @@ static struct i2c_driver driver = {
 
 static struct i2c_client client_template =
 {
-        I2C_DEVNAME("tda9875"),
+        .name      = "tda9875",
         .driver    = &driver,
 };
 
index 108c3ad7d62229f73d29e0c75459311da8d8e359..d60fc562aecdc4a1e2d05974cf976e11ec29aaf4 100644 (file)
@@ -618,9 +618,9 @@ static int tda9887_probe(struct i2c_adapter *adap)
                return i2c_probe(adap, &addr_data, tda9887_attach);
 #else
        switch (adap->id) {
-       case I2C_ALGO_BIT | I2C_HW_B_BT848:
-       case I2C_ALGO_BIT | I2C_HW_B_RIVA:
-       case I2C_ALGO_SAA7134:
+       case I2C_HW_B_BT848:
+       case I2C_HW_B_RIVA:
+       case I2C_HW_SAA7134:
                return i2c_probe(adap, &addr_data, tda9887_attach);
                break;
        }
@@ -760,7 +760,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg)
        return 0;
 }
 
-static int tda9887_suspend(struct device * dev, u32 state, u32 level)
+static int tda9887_suspend(struct device * dev, pm_message_t state, u32 level)
 {
        dprintk("tda9887: suspend\n");
        return 0;
@@ -793,7 +793,7 @@ static struct i2c_driver driver = {
 };
 static struct i2c_client client_template =
 {
-       I2C_DEVNAME("tda9887"),
+       .name      = "tda9887",
        .flags     = I2C_CLIENT_ALLOW_USE,
         .driver    = &driver,
 };
index b44db8a7b94dfed4ca0e6e3c1acd03ad9c4465d0..ee3688348b662bac1dc06dc7be1893cd537f185d 100644 (file)
@@ -86,7 +86,7 @@ static int detect(struct i2c_adapter *adapter, int address, int kind)
 static int attach(struct i2c_adapter *adapter)
 {
        /* let's see whether this is a know adapter we can attach to */
-       if (adapter->id != I2C_ALGO_SAA7146) {
+       if (adapter->id != I2C_HW_SAA7146) {
                dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id);
                return -ENODEV;
        }
@@ -200,7 +200,7 @@ static struct i2c_driver driver = {
 };
 
 static struct i2c_client client_template = {
-       I2C_DEVNAME("tea6415c"),
+       .name = "tea6415c",
        .driver = &driver,
 };
 
index 48d4db7d507b1d77b14429abae83d2960bb1a9a9..17975c19da5ee376f08ba2b7e98b96d4469b519b 100644 (file)
@@ -135,7 +135,7 @@ static int tea6420_detect(struct i2c_adapter *adapter, int address, int kind)
 static int attach(struct i2c_adapter *adapter)
 {
        /* let's see whether this is a know adapter we can attach to */
-       if (adapter->id != I2C_ALGO_SAA7146) {
+       if (adapter->id != I2C_HW_SAA7146) {
                dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id);
                return -ENODEV;
        }
@@ -177,7 +177,7 @@ static struct i2c_driver driver = {
 };
 
 static struct i2c_client client_template = {
-       I2C_DEVNAME("tea6420"),
+       .name = "tea6420",
        .driver = &driver,
 };
 
index 7d825e510ffd577a891c281e941658713b3a729e..79203595b9c13456d09c7c700b3127f16ed52734 100644 (file)
@@ -41,7 +41,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c     = normal_i2c,
        .probe          = &ignore,
        .ignore         = &ignore,
-       .force          = &ignore,
 };
 
 /* ---------------------------------------------------------------------- */
@@ -166,7 +165,7 @@ static int
 tuner_probe(struct i2c_adapter *adap)
 {
        this_adap = 0;
-       if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_LP))
+       if (adap->id == I2C_HW_B_LP)
                return i2c_probe(adap, &addr_data, tuner_attach);
        return 0;
 }
index f0a579827a2416d0c132320ac8842118a220ae45..3b1893c2ae3b136ffbf80d6fbf7122e53ce274ca 100644 (file)
@@ -672,7 +672,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
        return 0;
 }
 
-static int tuner_suspend(struct device *dev, u32 state, u32 level)
+static int tuner_suspend(struct device *dev, pm_message_t state, u32 level)
 {
        struct i2c_client *c = container_of (dev, struct i2c_client, dev);
        struct tuner *t = i2c_get_clientdata (c);
@@ -709,7 +709,7 @@ static struct i2c_driver driver = {
                   },
 };
 static struct i2c_client client_template = {
-       I2C_DEVNAME("(tuner unset)"),
+       .name = "(tuner unset)",
        .flags = I2C_CLIENT_ALLOW_USE,
        .driver = &driver,
 };
index f42a1efa8fcfa8c4ce83fbe7b6a6dae7337ff645..258724b2d6d21a2001450996a3ac23541bc5afdb 100644 (file)
@@ -162,24 +162,23 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val)
        unsigned char buffer[2];
 
        if (-1 == subaddr) {
-               dprintk("%s: chip_write: 0x%x\n",
-                       i2c_clientname(&chip->c), val);
+               dprintk("%s: chip_write: 0x%x\n", chip->c.name, val);
                chip->shadow.bytes[1] = val;
                buffer[0] = val;
                if (1 != i2c_master_send(&chip->c,buffer,1)) {
                        printk(KERN_WARNING "%s: I/O error (write 0x%x)\n",
-                              i2c_clientname(&chip->c), val);
+                              chip->c.name, val);
                        return -1;
                }
        } else {
                dprintk("%s: chip_write: reg%d=0x%x\n",
-                       i2c_clientname(&chip->c), subaddr, val);
+                       chip->c.name, subaddr, val);
                chip->shadow.bytes[subaddr+1] = val;
                buffer[0] = subaddr;
                buffer[1] = val;
                if (2 != i2c_master_send(&chip->c,buffer,2)) {
                        printk(KERN_WARNING "%s: I/O error (write reg%d=0x%x)\n",
-                              i2c_clientname(&chip->c), subaddr, val);
+                              chip->c.name, subaddr, val);
                        return -1;
                }
        }
@@ -203,11 +202,10 @@ static int chip_read(struct CHIPSTATE *chip)
        unsigned char buffer;
 
        if (1 != i2c_master_recv(&chip->c,&buffer,1)) {
-               printk(KERN_WARNING "%s: I/O error (read)\n",
-                      i2c_clientname(&chip->c));
+               printk(KERN_WARNING "%s: I/O error (read)\n", chip->c.name);
                return -1;
        }
-       dprintk("%s: chip_read: 0x%x\n",i2c_clientname(&chip->c),buffer);
+       dprintk("%s: chip_read: 0x%x\n", chip->c.name, buffer);
        return buffer;
 }
 
@@ -222,12 +220,11 @@ static int chip_read2(struct CHIPSTATE *chip, int subaddr)
         write[0] = subaddr;
 
        if (2 != i2c_transfer(chip->c.adapter,msgs,2)) {
-               printk(KERN_WARNING "%s: I/O error (read2)\n",
-                      i2c_clientname(&chip->c));
+               printk(KERN_WARNING "%s: I/O error (read2)\n", chip->c.name);
                return -1;
        }
        dprintk("%s: chip_read2: reg%d=0x%x\n",
-               i2c_clientname(&chip->c),subaddr,read[0]);
+               chip->c.name, subaddr, read[0]);
        return read[0];
 }
 
@@ -240,7 +237,7 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd)
 
        /* update our shadow register set; print bytes if (debug > 0) */
        dprintk("%s: chip_cmd(%s): reg=%d, data:",
-               i2c_clientname(&chip->c),name,cmd->bytes[0]);
+               chip->c.name, name, cmd->bytes[0]);
        for (i = 1; i < cmd->count; i++) {
                dprintk(" 0x%x",cmd->bytes[i]);
                chip->shadow.bytes[i+cmd->bytes[0]] = cmd->bytes[i];
@@ -249,7 +246,7 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd)
 
        /* send data to the chip */
        if (cmd->count != i2c_master_send(&chip->c,cmd->bytes,cmd->count)) {
-               printk(KERN_WARNING "%s: I/O error (%s)\n", i2c_clientname(&chip->c), name);
+               printk(KERN_WARNING "%s: I/O error (%s)\n", chip->c.name, name);
                return -1;
        }
        return 0;
@@ -274,9 +271,9 @@ static int chip_thread(void *data)
         struct CHIPSTATE *chip = data;
        struct CHIPDESC  *desc = chiplist + chip->type;
 
-       daemonize("%s",i2c_clientname(&chip->c));
+       daemonize("%s", chip->c.name);
        allow_signal(SIGTERM);
-       dprintk("%s: thread started\n", i2c_clientname(&chip->c));
+       dprintk("%s: thread started\n", chip->c.name);
 
        for (;;) {
                add_wait_queue(&chip->wq, &wait);
@@ -288,7 +285,7 @@ static int chip_thread(void *data)
                try_to_freeze();
                if (chip->done || signal_pending(current))
                        break;
-               dprintk("%s: thread wakeup\n", i2c_clientname(&chip->c));
+               dprintk("%s: thread wakeup\n", chip->c.name);
 
                /* don't do anything for radio or if mode != auto */
                if (chip->norm == VIDEO_MODE_RADIO || chip->mode != 0)
@@ -301,7 +298,7 @@ static int chip_thread(void *data)
                mod_timer(&chip->wt, jiffies+2*HZ);
        }
 
-       dprintk("%s: thread exiting\n", i2c_clientname(&chip->c));
+       dprintk("%s: thread exiting\n", chip->c.name);
         complete_and_exit(&chip->texit, 0);
        return 0;
 }
@@ -314,7 +311,7 @@ static void generic_checkmode(struct CHIPSTATE *chip)
        if (mode == chip->prevmode)
            return;
 
-       dprintk("%s: thread checkmode\n", i2c_clientname(&chip->c));
+       dprintk("%s: thread checkmode\n", chip->c.name);
        chip->prevmode = mode;
 
        if (mode & VIDEO_SOUND_STEREO)
@@ -1098,7 +1095,7 @@ static int tda8425_initialize(struct CHIPSTATE *chip)
                            /* extern   */ TDA8425_S1_CH1, /* intern */ TDA8425_S1_OFF,
                            /* off      */ TDA8425_S1_OFF, /* on     */ TDA8425_S1_CH2};
 
-       if (chip->c.adapter->id == (I2C_ALGO_BIT | I2C_HW_B_RIVA)) {
+       if (chip->c.adapter->id == I2C_HW_B_RIVA) {
                memcpy (desc->inputmap, inputmap, sizeof (inputmap));
        }
        return 0;
@@ -1501,7 +1498,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind)
                (desc->flags & CHIP_HAS_INPUTSEL)   ? " audiomux"    : "");
 
        /* fill required data structures */
-       strcpy(i2c_clientname(&chip->c),desc->name);
+       strcpy(chip->c.name, desc->name);
        chip->type = desc-chiplist;
        chip->shadow.count = desc->registers+1;
         chip->prevmode = -1;
@@ -1538,7 +1535,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind)
                chip->tpid = kernel_thread(chip_thread,(void *)chip,0);
                if (chip->tpid < 0)
                        printk(KERN_WARNING "%s: kernel_thread() failed\n",
-                              i2c_clientname(&chip->c));
+                              chip->c.name);
                wake_up_interruptible(&chip->wq);
        }
        return 0;
@@ -1548,16 +1545,16 @@ static int chip_probe(struct i2c_adapter *adap)
 {
        /* don't attach on saa7146 based cards,
           because dedicated drivers are used */
-       if ((adap->id & I2C_ALGO_SAA7146))
+       if (adap->id == I2C_HW_SAA7146)
                return 0;
 #ifdef I2C_CLASS_TV_ANALOG
        if (adap->class & I2C_CLASS_TV_ANALOG)
                return i2c_probe(adap, &addr_data, chip_attach);
 #else
        switch (adap->id) {
-       case I2C_ALGO_BIT | I2C_HW_B_BT848:
-       case I2C_ALGO_BIT | I2C_HW_B_RIVA:
-       case I2C_ALGO_SAA7134:
+       case I2C_HW_B_BT848:
+       case I2C_HW_B_RIVA:
+       case I2C_HW_SAA7134:
                return i2c_probe(adap, &addr_data, chip_attach);
        }
 #endif
@@ -1591,7 +1588,7 @@ static int chip_command(struct i2c_client *client,
        struct CHIPSTATE *chip = i2c_get_clientdata(client);
        struct CHIPDESC  *desc = chiplist + chip->type;
 
-       dprintk("%s: chip_command 0x%x\n",i2c_clientname(&chip->c),cmd);
+       dprintk("%s: chip_command 0x%x\n", chip->c.name, cmd);
 
        switch (cmd) {
        case AUDC_SET_INPUT:
@@ -1702,7 +1699,7 @@ static struct i2c_driver driver = {
 
 static struct i2c_client client_template =
 {
-       I2C_DEVNAME("(unset)"),
+       .name       = "(unset)",
        .flags      = I2C_CLIENT_ALLOW_USE,
         .driver     = &driver,
 };
index 127ec38ebd60822d4b48954a6331705c8f3ffd3e..3c3356a01cc67e9dc3cf9b09114a3bd8e1485dcf 100644 (file)
@@ -534,7 +534,7 @@ static int
 tveeprom_attach_adapter (struct i2c_adapter *adapter)
 {
        dprintk(1,"%s: id 0x%x\n",__FUNCTION__,adapter->id);
-       if (adapter->id != (I2C_ALGO_BIT | I2C_HW_B_BT848))
+       if (adapter->id != I2C_HW_B_BT848)
                return 0;
        return i2c_probe(adapter, &addr_data, tveeprom_detect_client);
 }
index 51b99cdbf29e8bc9447dc65eea4b53d7f230e2ae..a43301a154af413dc2f5754beaa410ee3dfd14ca 100644 (file)
@@ -91,7 +91,7 @@ static int tvmixer_ioctl(struct inode *inode, struct file *file, unsigned int cm
         if (cmd == SOUND_MIXER_INFO) {
                 mixer_info info;
                 strlcpy(info.id, "tv card", sizeof(info.id));
-                strlcpy(info.name, i2c_clientname(client), sizeof(info.name));
+                strlcpy(info.name, client->name, sizeof(info.name));
                 info.modify_counter = 42 /* FIXME */;
                 if (copy_to_user(argp, &info, sizeof(info)))
                         return -EFAULT;
@@ -100,7 +100,7 @@ static int tvmixer_ioctl(struct inode *inode, struct file *file, unsigned int cm
         if (cmd == SOUND_OLD_MIXER_INFO) {
                 _old_mixer_info info;
                 strlcpy(info.id, "tv card", sizeof(info.id));
-                strlcpy(info.name, i2c_clientname(client), sizeof(info.name));
+                strlcpy(info.name, client->name, sizeof(info.name));
                 if (copy_to_user(argp, &info, sizeof(info)))
                         return -EFAULT;
                 return 0;
@@ -276,9 +276,9 @@ static int tvmixer_clients(struct i2c_client *client)
 #else
        /* TV card ??? */
        switch (client->adapter->id) {
-       case I2C_ALGO_BIT | I2C_HW_SMBUS_VOODOO3:
-       case I2C_ALGO_BIT | I2C_HW_B_BT848:
-       case I2C_ALGO_BIT | I2C_HW_B_RIVA:
+       case I2C_HW_SMBUS_VOODOO3:
+       case I2C_HW_B_BT848:
+       case I2C_HW_B_RIVA:
                /* ok, have a look ... */
                break;
        default:
@@ -295,7 +295,7 @@ static int tvmixer_clients(struct i2c_client *client)
                        devices[i].dev = NULL;
                        devices[i].minor = -1;
                        printk("tvmixer: %s unregistered (#1)\n",
-                              i2c_clientname(client));
+                              client->name);
                        return 0;
                }
        }
@@ -354,7 +354,7 @@ static void __exit tvmixer_cleanup_module(void)
                if (devices[i].minor != -1) {
                        unregister_sound_mixer(devices[i].minor);
                        printk("tvmixer: %s unregistered (#2)\n",
-                              i2c_clientname(devices[i].dev));
+                              devices[i].dev->name);
                }
        }
 }
index 5dbd9f6bf353b4730309411e514a4ba0c77a6a54..4437bdebe24f64676c3249961326aa3c1c17505d 100644 (file)
@@ -576,7 +576,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_i2c,
        .probe                  = &ignore,
        .ignore                 = &ignore,
-       .force                  = &ignore,
 };
 
 static struct i2c_driver vpx3220_i2c_driver;
index 25743085b2d5a97a1a800939aad63ba5eb5c20ca..eed2acea17791305a94965ab63020b7f9d41459f 100644 (file)
@@ -737,7 +737,7 @@ static struct i2c_algo_bit_data zoran_i2c_bit_data_template = {
 };
 
 static struct i2c_adapter zoran_i2c_adapter_template = {
-       I2C_DEVNAME("zr36057"),
+       .name = "zr36057",
        .id = I2C_HW_B_ZR36067,
        .algo = NULL,
        .client_register = zoran_i2c_client_register,
index 7fc692a8f5b080e8db0a7c133db23f5eced53297..dea6589d153364c0b2f6799f1380e3f99ca180a4 100644 (file)
@@ -6,7 +6,7 @@ menu "Misc devices"
 
 config IBM_ASM
        tristate "Device driver for IBM RSA service processor"
-       depends on X86 && PCI && EXPERIMENTAL
+       depends on X86 && PCI && EXPERIMENTAL && BROKEN
        ---help---
          This option enables device driver support for in-band access to the
          IBM RSA (Condor) service processor in eServer xSeries systems.
index 3c5904834fe8289db5672fae41a543d9bc7c6059..0a8165974ba763abebeb0519434f849ea8876413 100644 (file)
@@ -457,6 +457,11 @@ static void mmc_idle_cards(struct mmc_host *host)
 {
        struct mmc_command cmd;
 
+       host->ios.chip_select = MMC_CS_HIGH;
+       host->ops->set_ios(host, &host->ios);
+
+       mmc_delay(1);
+
        cmd.opcode = MMC_GO_IDLE_STATE;
        cmd.arg = 0;
        cmd.flags = MMC_RSP_NONE;
@@ -464,6 +469,11 @@ static void mmc_idle_cards(struct mmc_host *host)
        mmc_wait_for_cmd(host, &cmd, 0);
 
        mmc_delay(1);
+
+       host->ios.chip_select = MMC_CS_DONTCARE;
+       host->ops->set_ios(host, &host->ios);
+
+       mmc_delay(1);
 }
 
 /*
@@ -475,6 +485,7 @@ static void mmc_power_up(struct mmc_host *host)
 
        host->ios.vdd = bit;
        host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
+       host->ios.chip_select = MMC_CS_DONTCARE;
        host->ios.power_mode = MMC_POWER_UP;
        host->ops->set_ios(host, &host->ios);
 
@@ -492,6 +503,7 @@ static void mmc_power_off(struct mmc_host *host)
        host->ios.clock = 0;
        host->ios.vdd = 0;
        host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
+       host->ios.chip_select = MMC_CS_DONTCARE;
        host->ios.power_mode = MMC_POWER_OFF;
        host->ops->set_ios(host, &host->ios);
 }
index 402c2d661fb2814d06983d6a6f0e3c89c110e89f..08ae22aed9e8f7f38a1c61af4a0b87b92b563a0b 100644 (file)
@@ -42,7 +42,7 @@
 #include "wbsd.h"
 
 #define DRIVER_NAME "wbsd"
-#define DRIVER_VERSION "1.3"
+#define DRIVER_VERSION "1.4"
 
 #ifdef CONFIG_MMC_DEBUG
 #define DBG(x...) \
@@ -960,8 +960,9 @@ static void wbsd_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
        struct wbsd_host* host = mmc_priv(mmc);
        u8 clk, setup, pwr;
        
-       DBGF("clock %uHz busmode %u powermode %u Vdd %u\n",
-               ios->clock, ios->bus_mode, ios->power_mode, ios->vdd);
+       DBGF("clock %uHz busmode %u powermode %u cs %u Vdd %u\n",
+               ios->clock, ios->bus_mode, ios->power_mode, ios->chip_select,
+               ios->vdd);
 
        spin_lock_bh(&host->lock);
 
@@ -1003,13 +1004,11 @@ static void wbsd_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
 
        /*
         * MMC cards need to have pin 1 high during init.
-        * Init time corresponds rather nicely with the bus mode.
         * It wreaks havoc with the card detection though so
-        * that needs to be disabed.
+        * that needs to be disabled.
         */
        setup = wbsd_read_index(host, WBSD_IDX_SETUP);
-       if ((ios->power_mode == MMC_POWER_ON) &&
-               (ios->bus_mode == MMC_BUSMODE_OPENDRAIN))
+       if (ios->chip_select == MMC_CS_HIGH)
        {
                setup |= WBSD_DAT3_H;
                host->flags |= WBSD_FIGNORE_DETECT;
@@ -1017,7 +1016,12 @@ static void wbsd_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
        else
        {
                setup &= ~WBSD_DAT3_H;
-               host->flags &= ~WBSD_FIGNORE_DETECT;
+
+               /*
+                * We cannot resume card detection immediatly
+                * because of capacitance and delays in the chip.
+                */
+               mod_timer(&host->ignore_timer, jiffies + HZ/100);
        }
        wbsd_write_index(host, WBSD_IDX_SETUP, setup);
        
@@ -1035,6 +1039,31 @@ static struct mmc_host_ops wbsd_ops = {
  *                                                                           *
 \*****************************************************************************/
 
+/*
+ * Helper function to reset detection ignore
+ */
+
+static void wbsd_reset_ignore(unsigned long data)
+{
+       struct wbsd_host *host = (struct wbsd_host*)data;
+
+       BUG_ON(host == NULL);
+
+       DBG("Resetting card detection ignore\n");
+
+       spin_lock_bh(&host->lock);
+
+       host->flags &= ~WBSD_FIGNORE_DETECT;
+
+       /*
+        * Card status might have changed during the
+        * blackout.
+        */
+       tasklet_schedule(&host->card_tasklet);
+
+       spin_unlock_bh(&host->lock);
+}
+
 /*
  * Helper function for card detection
  */
@@ -1097,7 +1126,7 @@ static void wbsd_tasklet_card(unsigned long param)
                         * Delay card detection to allow electrical connections
                         * to stabilise.
                         */
-                       mod_timer(&host->timer, jiffies + HZ/2);
+                       mod_timer(&host->detect_timer, jiffies + HZ/2);
                }
                
                spin_unlock(&host->lock);
@@ -1124,6 +1153,8 @@ static void wbsd_tasklet_card(unsigned long param)
 
                mmc_detect_change(host->mmc);
        }
+       else
+               spin_unlock(&host->lock);
 }
 
 static void wbsd_tasklet_fifo(unsigned long param)
@@ -1328,11 +1359,15 @@ static int __devinit wbsd_alloc_mmc(struct device* dev)
        spin_lock_init(&host->lock);
        
        /*
-        * Set up detection timer
+        * Set up timers
         */
-       init_timer(&host->timer);
-       host->timer.data = (unsigned long)host;
-       host->timer.function = wbsd_detect_card;
+       init_timer(&host->detect_timer);
+       host->detect_timer.data = (unsigned long)host;
+       host->detect_timer.function = wbsd_detect_card;
+
+       init_timer(&host->ignore_timer);
+       host->ignore_timer.data = (unsigned long)host;
+       host->ignore_timer.function = wbsd_reset_ignore;
        
        /*
         * Maximum number of segments. Worst case is one sector per segment
@@ -1370,7 +1405,8 @@ static void __devexit wbsd_free_mmc(struct device* dev)
        host = mmc_priv(mmc);
        BUG_ON(host == NULL);
        
-       del_timer_sync(&host->timer);
+       del_timer_sync(&host->ignore_timer);
+       del_timer_sync(&host->detect_timer);
        
        mmc_free_host(mmc);
        
index 661a9f6a6e6ff5b63cfc423f1bd203fa5b1eb614..8af43549f5d5b95b34bbe8b17b1fad18199be236 100644 (file)
@@ -181,5 +181,6 @@ struct wbsd_host
        struct tasklet_struct   finish_tasklet;
        struct tasklet_struct   block_tasklet;
        
-       struct timer_list       timer;          /* Card detection timer */
+       struct timer_list       detect_timer;   /* Card detection timer */
+       struct timer_list       ignore_timer;   /* Ignore detection timer */
 };
index e0239a10d3250ff44f61b91c21f6d68584d1a9fd..ae9e7a579b94984a978264a38d4f0ac3e1e9b6ed 100644 (file)
@@ -397,7 +397,7 @@ config SUN3LANCE
          If you're not building a kernel for a Sun 3, say N.
 
 config SUN3_82586
-       tristate "Sun3 on-board Intel 82586 support"
+       bool "Sun3 on-board Intel 82586 support"
        depends on NET_ETHERNET && SUN3
        help
          This driver enables support for the on-board Intel 82586 based
@@ -447,7 +447,7 @@ config NET_SB1250_MAC
 
 config SGI_IOC3_ETH
        bool "SGI IOC3 Ethernet"
-       depends on NET_ETHERNET && PCI && SGI_IP27
+       depends on NET_ETHERNET && PCI && SGI_IP27 && BROKEN
        select CRC32
        select MII
        help
@@ -1924,12 +1924,15 @@ config R8169_VLAN
          If in doubt, say Y.
 
 config SIS190
-       tristate "SiS190 gigabit ethernet support"
+       tristate "SiS190/SiS191 gigabit ethernet support"
        depends on PCI
        select CRC32
        select MII
        ---help---
-         Say Y here if you have a SiS 190 PCI Gigabit Ethernet adapter.
+         Say Y here if you have a SiS 190 PCI Fast Ethernet adapter or
+         a SiS 191 PCI Gigabit Ethernet adapter. Both are expected to
+         appear in lan on motherboard designs which are based on SiS 965
+         and SiS 966 south bridge.
 
          To compile this driver as a module, choose M here: the module
          will be called sis190.  This is recommended.
index 7babf6af4e28dd1113b467dd47907e191aad9b02..55a72c7ad001a20ae03b4c3ebf3fe61281688884 100644 (file)
@@ -2004,14 +2004,14 @@ bnx2_init_cpus(struct bnx2 *bp)
 }
 
 static int
-bnx2_set_power_state(struct bnx2 *bp, int state)
+bnx2_set_power_state(struct bnx2 *bp, pci_power_t state)
 {
        u16 pmcsr;
 
        pci_read_config_word(bp->pdev, bp->pm_cap + PCI_PM_CTRL, &pmcsr);
 
        switch (state) {
-       case 0: {
+       case PCI_D0: {
                u32 val;
 
                pci_write_config_word(bp->pdev, bp->pm_cap + PCI_PM_CTRL,
@@ -2032,7 +2032,7 @@ bnx2_set_power_state(struct bnx2 *bp, int state)
                REG_WR(bp, BNX2_RPM_CONFIG, val);
                break;
        }
-       case 3: {
+       case PCI_D3hot: {
                int i;
                u32 val, wol_msg;
 
@@ -3886,7 +3886,7 @@ bnx2_open(struct net_device *dev)
        struct bnx2 *bp = dev->priv;
        int rc;
 
-       bnx2_set_power_state(bp, 0);
+       bnx2_set_power_state(bp, PCI_D0);
        bnx2_disable_int(bp);
 
        rc = bnx2_alloc_mem(bp);
@@ -4197,7 +4197,7 @@ bnx2_close(struct net_device *dev)
        bnx2_free_mem(bp);
        bp->link_up = 0;
        netif_carrier_off(bp->dev);
-       bnx2_set_power_state(bp, 3);
+       bnx2_set_power_state(bp, PCI_D3hot);
        return 0;
 }
 
@@ -5203,7 +5203,7 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
                               BNX2_PCICFG_MISC_CONFIG_REG_WINDOW_ENA |
                               BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP);
 
-       bnx2_set_power_state(bp, 0);
+       bnx2_set_power_state(bp, PCI_D0);
 
        bp->chip_id = REG_RD(bp, BNX2_MISC_ID);
 
@@ -5495,7 +5495,7 @@ bnx2_remove_one(struct pci_dev *pdev)
 }
 
 static int
-bnx2_suspend(struct pci_dev *pdev, u32 state)
+bnx2_suspend(struct pci_dev *pdev, pm_message_t state)
 {
        struct net_device *dev = pci_get_drvdata(pdev);
        struct bnx2 *bp = dev->priv;
@@ -5513,7 +5513,7 @@ bnx2_suspend(struct pci_dev *pdev, u32 state)
                reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
        bnx2_reset_chip(bp, reset_code);
        bnx2_free_skbs(bp);
-       bnx2_set_power_state(bp, state);
+       bnx2_set_power_state(bp, pci_choose_state(pdev, state));
        return 0;
 }
 
@@ -5526,7 +5526,7 @@ bnx2_resume(struct pci_dev *pdev)
        if (!netif_running(dev))
                return 0;
 
-       bnx2_set_power_state(bp, 0);
+       bnx2_set_power_state(bp, PCI_D0);
        netif_device_attach(dev);
        bnx2_init_nic(bp);
        bnx2_netif_start(bp);
index f09348802b46fb8fabe0f9535e6808c68b59bbee..bf3e7b6a7a1898290635cfb134f6bce0016992ef 100644 (file)
@@ -88,7 +88,7 @@ struct t1_rx_mode {
 
 static inline u8 *t1_get_next_mcaddr(struct t1_rx_mode *rm)
 {
-       u8 *addr = 0;
+       u8 *addr = NULL;
 
        if (rm->idx++ < rm->dev->mc_count) {
                addr = rm->list->dmi_addr;
@@ -190,7 +190,7 @@ struct sge;
 struct peespi;
 
 struct adapter {
-       u8 *regs;
+       u8 __iomem *regs;
        struct pci_dev *pdev;
        unsigned long registered_device_map;
        unsigned long open_device_map;
index 28ae478b386dcccb5259949e6bb321fc97a37040..349ebe783ed6b87892d242e679e5a9b210a51696 100644 (file)
@@ -824,7 +824,7 @@ static void cxgb_proc_cleanup(struct adapter *adapter,
 static int t1_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
 {
         struct adapter *adapter = dev->priv;
-        struct mii_ioctl_data *data = (struct mii_ioctl_data *)&req->ifr_data;
+        struct mii_ioctl_data *data = if_mii(req);
 
        switch (cmd) {
         case SIOCGMIIPHY:
index 93e9f8788751e462f31d2f2edb17212f7aa7e954..51c2b3a18b6f385f9c86698b7840cf70838025a0 100644 (file)
@@ -1270,7 +1270,7 @@ struct e1000_hw_stats {
 
 /* Structure containing variables used by the shared code (e1000_hw.c) */
 struct e1000_hw {
-    uint8_t *hw_addr;
+    uint8_t __iomem *hw_addr;
     uint8_t *flash_address;
     e1000_mac_type mac_type;
     e1000_phy_type phy_type;
index 9b596e0bbf95cc04d73448a38098e9dc3f003bae..7c8a0a22dcd5425545389fb056f9e9a1f4ee8f90 100644 (file)
@@ -162,7 +162,7 @@ static void e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
 static void e1000_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
 static void e1000_restore_vlan(struct e1000_adapter *adapter);
 
-static int e1000_suspend(struct pci_dev *pdev, uint32_t state);
+static int e1000_suspend(struct pci_dev *pdev, pm_message_t state);
 #ifdef CONFIG_PM
 static int e1000_resume(struct pci_dev *pdev);
 #endif
@@ -3642,7 +3642,7 @@ e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx)
 }
 
 static int
-e1000_suspend(struct pci_dev *pdev, uint32_t state)
+e1000_suspend(struct pci_dev *pdev, pm_message_t state)
 {
        struct net_device *netdev = pci_get_drvdata(pdev);
        struct e1000_adapter *adapter = netdev_priv(netdev);
@@ -3726,9 +3726,7 @@ e1000_suspend(struct pci_dev *pdev, uint32_t state)
        }
 
        pci_disable_device(pdev);
-
-       state = (state > 0) ? 3 : 0;
-       pci_set_power_state(pdev, state);
+       pci_set_power_state(pdev, pci_choose_state(pdev, state));
 
        return 0;
 }
@@ -3741,13 +3739,13 @@ e1000_resume(struct pci_dev *pdev)
        struct e1000_adapter *adapter = netdev_priv(netdev);
        uint32_t manc, ret_val, swsm;
 
-       pci_set_power_state(pdev, 0);
+       pci_set_power_state(pdev, PCI_D0);
        pci_restore_state(pdev);
        ret_val = pci_enable_device(pdev);
        pci_set_master(pdev);
 
-       pci_enable_wake(pdev, 3, 0);
-       pci_enable_wake(pdev, 4, 0); /* 4 == D3 cold */
+       pci_enable_wake(pdev, PCI_D3hot, 0);
+       pci_enable_wake(pdev, PCI_D3cold, 0);
 
        e1000_reset(adapter);
        E1000_WRITE_REG(&adapter->hw, WUS, ~0);
index 006e4f57560675bb48a19b62fa6ec54fd0158337..6d9de626c9670db8e0f4d436cfbfda6913fd6ceb 100644 (file)
@@ -1749,11 +1749,6 @@ static int vlsi_irda_suspend(struct pci_dev *pdev, pm_message_t state)
        struct net_device *ndev = pci_get_drvdata(pdev);
        vlsi_irda_dev_t *idev;
 
-       if (state < 1 || state > 3 ) {
-               IRDA_ERROR("%s - %s: invalid pm state request: %u\n",
-                          __FUNCTION__, PCIDEV_NAME(pdev), state);
-               return 0;
-       }
        if (!ndev) {
                IRDA_ERROR("%s - %s: no netdevice \n",
                           __FUNCTION__, PCIDEV_NAME(pdev));
@@ -1762,12 +1757,12 @@ static int vlsi_irda_suspend(struct pci_dev *pdev, pm_message_t state)
        idev = ndev->priv;      
        down(&idev->sem);
        if (pdev->current_state != 0) {                 /* already suspended */
-               if (state > pdev->current_state) {      /* simply go deeper */
-                       pci_set_power_state(pdev,state);
-                       pdev->current_state = state;
+               if (state.event > pdev->current_state) {        /* simply go deeper */
+                       pci_set_power_state(pdev, pci_choose_state(pdev, state));
+                       pdev->current_state = state.event;
                }
                else
-                       IRDA_ERROR("%s - %s: invalid suspend request %u -> %u\n", __FUNCTION__, PCIDEV_NAME(pdev), pdev->current_state, state);
+                       IRDA_ERROR("%s - %s: invalid suspend request %u -> %u\n", __FUNCTION__, PCIDEV_NAME(pdev), pdev->current_state, state.event);
                up(&idev->sem);
                return 0;
        }
@@ -1781,8 +1776,8 @@ static int vlsi_irda_suspend(struct pci_dev *pdev, pm_message_t state)
                        idev->new_baud = idev->baud;
        }
 
-       pci_set_power_state(pdev,state);
-       pdev->current_state = state;
+       pci_set_power_state(pdev, pci_choose_state(pdev, state));
+       pdev->current_state = state.event;
        idev->resume_ok = 1;
        up(&idev->sem);
        return 0;
@@ -1807,8 +1802,8 @@ static int vlsi_irda_resume(struct pci_dev *pdev)
                return 0;
        }
        
-       pci_set_power_state(pdev, 0);
-       pdev->current_state = 0;
+       pci_set_power_state(pdev, PCI_D0);
+       pdev->current_state = PM_EVENT_ON;
 
        if (!idev->resume_ok) {
                /* should be obsolete now - but used to happen due to:
index 183ba97785b0dbadeff6745838d254845fa5a6b1..dc5d089bf184a8091c704de78d2c8fd6451c2224 100644 (file)
 #include <asm/iommu.h>
 #include <asm/vio.h>
 
-#include "iseries_veth.h"
+#undef DEBUG
 
 MODULE_AUTHOR("Kyle Lucke <klucke@us.ibm.com>");
 MODULE_DESCRIPTION("iSeries Virtual ethernet driver");
 MODULE_LICENSE("GPL");
 
+#define VETH_EVENT_CAP (0)
+#define VETH_EVENT_FRAMES      (1)
+#define VETH_EVENT_MONITOR     (2)
+#define VETH_EVENT_FRAMES_ACK  (3)
+
+#define VETH_MAX_ACKS_PER_MSG  (20)
+#define VETH_MAX_FRAMES_PER_MSG        (6)
+
+struct veth_frames_data {
+       u32 addr[VETH_MAX_FRAMES_PER_MSG];
+       u16 len[VETH_MAX_FRAMES_PER_MSG];
+       u32 eofmask;
+};
+#define VETH_EOF_SHIFT         (32-VETH_MAX_FRAMES_PER_MSG)
+
+struct veth_frames_ack_data {
+       u16 token[VETH_MAX_ACKS_PER_MSG];
+};
+
+struct veth_cap_data {
+       u8 caps_version;
+       u8 rsvd1;
+       u16 num_buffers;
+       u16 ack_threshold;
+       u16 rsvd2;
+       u32 ack_timeout;
+       u32 rsvd3;
+       u64 rsvd4[3];
+};
+
+struct veth_lpevent {
+       struct HvLpEvent base_event;
+       union {
+               struct veth_cap_data caps_data;
+               struct veth_frames_data frames_data;
+               struct veth_frames_ack_data frames_ack_data;
+       } u;
+
+};
+
+#define DRV_NAME       "iseries_veth"
+#define DRV_VERSION    "2.0"
+
 #define VETH_NUMBUFFERS                (120)
 #define VETH_ACKTIMEOUT        (1000000) /* microseconds */
 #define VETH_MAX_MCAST         (12)
@@ -113,9 +156,9 @@ MODULE_LICENSE("GPL");
 
 struct veth_msg {
        struct veth_msg *next;
-       struct VethFramesData data;
+       struct veth_frames_data data;
        int token;
-       unsigned long in_use;
+       int in_use;
        struct sk_buff *skb;
        struct device *dev;
 };
@@ -125,23 +168,28 @@ struct veth_lpar_connection {
        struct work_struct statemachine_wq;
        struct veth_msg *msgs;
        int num_events;
-       struct VethCapData local_caps;
+       struct veth_cap_data local_caps;
 
+       struct kobject kobject;
        struct timer_list ack_timer;
 
+       struct timer_list reset_timer;
+       unsigned int reset_timeout;
+       unsigned long last_contact;
+       int outstanding_tx;
+
        spinlock_t lock;
        unsigned long state;
        HvLpInstanceId src_inst;
        HvLpInstanceId dst_inst;
-       struct VethLpEvent cap_event, cap_ack_event;
+       struct veth_lpevent cap_event, cap_ack_event;
        u16 pending_acks[VETH_MAX_ACKS_PER_MSG];
        u32 num_pending_acks;
 
        int num_ack_events;
-       struct VethCapData remote_caps;
+       struct veth_cap_data remote_caps;
        u32 ack_timeout;
 
-       spinlock_t msg_stack_lock;
        struct veth_msg *msg_stack_head;
 };
 
@@ -151,15 +199,17 @@ struct veth_port {
        u64 mac_addr;
        HvLpIndexMap lpar_map;
 
-       spinlock_t pending_gate;
-       struct sk_buff *pending_skb;
-       HvLpIndexMap pending_lpmask;
+       /* queue_lock protects the stopped_map and dev's queue. */
+       spinlock_t queue_lock;
+       HvLpIndexMap stopped_map;
 
+       /* mcast_gate protects promiscuous, num_mcast & mcast_addr. */
        rwlock_t mcast_gate;
        int promiscuous;
-       int all_mcast;
        int num_mcast;
        u64 mcast_addr[VETH_MAX_MCAST];
+
+       struct kobject kobject;
 };
 
 static HvLpIndex this_lp;
@@ -168,44 +218,56 @@ static struct net_device *veth_dev[HVMAXARCHITECTEDVIRTUALLANS]; /* = 0 */
 
 static int veth_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static void veth_recycle_msg(struct veth_lpar_connection *, struct veth_msg *);
-static void veth_flush_pending(struct veth_lpar_connection *cnx);
-static void veth_receive(struct veth_lpar_connection *, struct VethLpEvent *);
-static void veth_timed_ack(unsigned long connectionPtr);
+static void veth_wake_queues(struct veth_lpar_connection *cnx);
+static void veth_stop_queues(struct veth_lpar_connection *cnx);
+static void veth_receive(struct veth_lpar_connection *, struct veth_lpevent *);
+static void veth_release_connection(struct kobject *kobject);
+static void veth_timed_ack(unsigned long ptr);
+static void veth_timed_reset(unsigned long ptr);
 
 /*
  * Utility functions
  */
 
-#define veth_printk(prio, fmt, args...) \
-       printk(prio "%s: " fmt, __FILE__, ## args)
+#define veth_info(fmt, args...) \
+       printk(KERN_INFO DRV_NAME ": " fmt, ## args)
 
 #define veth_error(fmt, args...) \
-       printk(KERN_ERR "(%s:%3.3d) ERROR: " fmt, __FILE__, __LINE__ , ## args)
+       printk(KERN_ERR DRV_NAME ": Error: " fmt, ## args)
+
+#ifdef DEBUG
+#define veth_debug(fmt, args...) \
+       printk(KERN_DEBUG DRV_NAME ": " fmt, ## args)
+#else
+#define veth_debug(fmt, args...) do {} while (0)
+#endif
 
+/* You must hold the connection's lock when you call this function. */
 static inline void veth_stack_push(struct veth_lpar_connection *cnx,
                                   struct veth_msg *msg)
 {
-       unsigned long flags;
-
-       spin_lock_irqsave(&cnx->msg_stack_lock, flags);
        msg->next = cnx->msg_stack_head;
        cnx->msg_stack_head = msg;
-       spin_unlock_irqrestore(&cnx->msg_stack_lock, flags);
 }
 
+/* You must hold the connection's lock when you call this function. */
 static inline struct veth_msg *veth_stack_pop(struct veth_lpar_connection *cnx)
 {
-       unsigned long flags;
        struct veth_msg *msg;
 
-       spin_lock_irqsave(&cnx->msg_stack_lock, flags);
        msg = cnx->msg_stack_head;
        if (msg)
                cnx->msg_stack_head = cnx->msg_stack_head->next;
-       spin_unlock_irqrestore(&cnx->msg_stack_lock, flags);
+
        return msg;
 }
 
+/* You must hold the connection's lock when you call this function. */
+static inline int veth_stack_is_empty(struct veth_lpar_connection *cnx)
+{
+       return cnx->msg_stack_head == NULL;
+}
+
 static inline HvLpEvent_Rc
 veth_signalevent(struct veth_lpar_connection *cnx, u16 subtype,
                 HvLpEvent_AckInd ackind, HvLpEvent_AckType acktype,
@@ -249,13 +311,144 @@ static int veth_allocate_events(HvLpIndex rlp, int number)
        struct veth_allocation vc = { COMPLETION_INITIALIZER(vc.c), 0 };
 
        mf_allocate_lp_events(rlp, HvLpEvent_Type_VirtualLan,
-                           sizeof(struct VethLpEvent), number,
+                           sizeof(struct veth_lpevent), number,
                            &veth_complete_allocation, &vc);
        wait_for_completion(&vc.c);
 
        return vc.num;
 }
 
+/*
+ * sysfs support
+ */
+
+struct veth_cnx_attribute {
+       struct attribute attr;
+       ssize_t (*show)(struct veth_lpar_connection *, char *buf);
+       ssize_t (*store)(struct veth_lpar_connection *, const char *buf);
+};
+
+static ssize_t veth_cnx_attribute_show(struct kobject *kobj,
+               struct attribute *attr, char *buf)
+{
+       struct veth_cnx_attribute *cnx_attr;
+       struct veth_lpar_connection *cnx;
+
+       cnx_attr = container_of(attr, struct veth_cnx_attribute, attr);
+       cnx = container_of(kobj, struct veth_lpar_connection, kobject);
+
+       if (!cnx_attr->show)
+               return -EIO;
+
+       return cnx_attr->show(cnx, buf);
+}
+
+#define CUSTOM_CNX_ATTR(_name, _format, _expression)                   \
+static ssize_t _name##_show(struct veth_lpar_connection *cnx, char *buf)\
+{                                                                      \
+       return sprintf(buf, _format, _expression);                      \
+}                                                                      \
+struct veth_cnx_attribute veth_cnx_attr_##_name = __ATTR_RO(_name)
+
+#define SIMPLE_CNX_ATTR(_name) \
+       CUSTOM_CNX_ATTR(_name, "%lu\n", (unsigned long)cnx->_name)
+
+SIMPLE_CNX_ATTR(outstanding_tx);
+SIMPLE_CNX_ATTR(remote_lp);
+SIMPLE_CNX_ATTR(num_events);
+SIMPLE_CNX_ATTR(src_inst);
+SIMPLE_CNX_ATTR(dst_inst);
+SIMPLE_CNX_ATTR(num_pending_acks);
+SIMPLE_CNX_ATTR(num_ack_events);
+CUSTOM_CNX_ATTR(ack_timeout, "%d\n", jiffies_to_msecs(cnx->ack_timeout));
+CUSTOM_CNX_ATTR(reset_timeout, "%d\n", jiffies_to_msecs(cnx->reset_timeout));
+CUSTOM_CNX_ATTR(state, "0x%.4lX\n", cnx->state);
+CUSTOM_CNX_ATTR(last_contact, "%d\n", cnx->last_contact ?
+               jiffies_to_msecs(jiffies - cnx->last_contact) : 0);
+
+#define GET_CNX_ATTR(_name)    (&veth_cnx_attr_##_name.attr)
+
+static struct attribute *veth_cnx_default_attrs[] = {
+       GET_CNX_ATTR(outstanding_tx),
+       GET_CNX_ATTR(remote_lp),
+       GET_CNX_ATTR(num_events),
+       GET_CNX_ATTR(reset_timeout),
+       GET_CNX_ATTR(last_contact),
+       GET_CNX_ATTR(state),
+       GET_CNX_ATTR(src_inst),
+       GET_CNX_ATTR(dst_inst),
+       GET_CNX_ATTR(num_pending_acks),
+       GET_CNX_ATTR(num_ack_events),
+       GET_CNX_ATTR(ack_timeout),
+       NULL
+};
+
+static struct sysfs_ops veth_cnx_sysfs_ops = {
+               .show = veth_cnx_attribute_show
+};
+
+static struct kobj_type veth_lpar_connection_ktype = {
+       .release        = veth_release_connection,
+       .sysfs_ops      = &veth_cnx_sysfs_ops,
+       .default_attrs  = veth_cnx_default_attrs
+};
+
+struct veth_port_attribute {
+       struct attribute attr;
+       ssize_t (*show)(struct veth_port *, char *buf);
+       ssize_t (*store)(struct veth_port *, const char *buf);
+};
+
+static ssize_t veth_port_attribute_show(struct kobject *kobj,
+               struct attribute *attr, char *buf)
+{
+       struct veth_port_attribute *port_attr;
+       struct veth_port *port;
+
+       port_attr = container_of(attr, struct veth_port_attribute, attr);
+       port = container_of(kobj, struct veth_port, kobject);
+
+       if (!port_attr->show)
+               return -EIO;
+
+       return port_attr->show(port, buf);
+}
+
+#define CUSTOM_PORT_ATTR(_name, _format, _expression)                  \
+static ssize_t _name##_show(struct veth_port *port, char *buf)         \
+{                                                                      \
+       return sprintf(buf, _format, _expression);                      \
+}                                                                      \
+struct veth_port_attribute veth_port_attr_##_name = __ATTR_RO(_name)
+
+#define SIMPLE_PORT_ATTR(_name)        \
+       CUSTOM_PORT_ATTR(_name, "%lu\n", (unsigned long)port->_name)
+
+SIMPLE_PORT_ATTR(promiscuous);
+SIMPLE_PORT_ATTR(num_mcast);
+CUSTOM_PORT_ATTR(lpar_map, "0x%X\n", port->lpar_map);
+CUSTOM_PORT_ATTR(stopped_map, "0x%X\n", port->stopped_map);
+CUSTOM_PORT_ATTR(mac_addr, "0x%lX\n", port->mac_addr);
+
+#define GET_PORT_ATTR(_name)   (&veth_port_attr_##_name.attr)
+static struct attribute *veth_port_default_attrs[] = {
+       GET_PORT_ATTR(mac_addr),
+       GET_PORT_ATTR(lpar_map),
+       GET_PORT_ATTR(stopped_map),
+       GET_PORT_ATTR(promiscuous),
+       GET_PORT_ATTR(num_mcast),
+       NULL
+};
+
+static struct sysfs_ops veth_port_sysfs_ops = {
+       .show = veth_port_attribute_show
+};
+
+static struct kobj_type veth_port_ktype = {
+       .sysfs_ops      = &veth_port_sysfs_ops,
+       .default_attrs  = veth_port_default_attrs
+};
+
 /*
  * LPAR connection code
  */
@@ -266,7 +459,7 @@ static inline void veth_kick_statemachine(struct veth_lpar_connection *cnx)
 }
 
 static void veth_take_cap(struct veth_lpar_connection *cnx,
-                         struct VethLpEvent *event)
+                         struct veth_lpevent *event)
 {
        unsigned long flags;
 
@@ -278,7 +471,7 @@ static void veth_take_cap(struct veth_lpar_connection *cnx,
                                                  HvLpEvent_Type_VirtualLan);
 
        if (cnx->state & VETH_STATE_GOTCAPS) {
-               veth_error("Received a second capabilities from lpar %d\n",
+               veth_error("Received a second capabilities from LPAR %d.\n",
                           cnx->remote_lp);
                event->base_event.xRc = HvLpEvent_Rc_BufferNotAvailable;
                HvCallEvent_ackLpEvent((struct HvLpEvent *) event);
@@ -291,13 +484,13 @@ static void veth_take_cap(struct veth_lpar_connection *cnx,
 }
 
 static void veth_take_cap_ack(struct veth_lpar_connection *cnx,
-                             struct VethLpEvent *event)
+                             struct veth_lpevent *event)
 {
        unsigned long flags;
 
        spin_lock_irqsave(&cnx->lock, flags);
        if (cnx->state & VETH_STATE_GOTCAPACK) {
-               veth_error("Received a second capabilities ack from lpar %d\n",
+               veth_error("Received a second capabilities ack from LPAR %d.\n",
                           cnx->remote_lp);
        } else {
                memcpy(&cnx->cap_ack_event, event,
@@ -309,19 +502,24 @@ static void veth_take_cap_ack(struct veth_lpar_connection *cnx,
 }
 
 static void veth_take_monitor_ack(struct veth_lpar_connection *cnx,
-                                 struct VethLpEvent *event)
+                                 struct veth_lpevent *event)
 {
        unsigned long flags;
 
        spin_lock_irqsave(&cnx->lock, flags);
-       veth_printk(KERN_DEBUG, "Monitor ack returned for lpar %d\n",
-                   cnx->remote_lp);
-       cnx->state |= VETH_STATE_RESET;
-       veth_kick_statemachine(cnx);
+       veth_debug("cnx %d: lost connection.\n", cnx->remote_lp);
+
+       /* Avoid kicking the statemachine once we're shutdown.
+        * It's unnecessary and it could break veth_stop_connection(). */
+
+       if (! (cnx->state & VETH_STATE_SHUTDOWN)) {
+               cnx->state |= VETH_STATE_RESET;
+               veth_kick_statemachine(cnx);
+       }
        spin_unlock_irqrestore(&cnx->lock, flags);
 }
 
-static void veth_handle_ack(struct VethLpEvent *event)
+static void veth_handle_ack(struct veth_lpevent *event)
 {
        HvLpIndex rlp = event->base_event.xTargetLp;
        struct veth_lpar_connection *cnx = veth_cnx[rlp];
@@ -329,58 +527,67 @@ static void veth_handle_ack(struct VethLpEvent *event)
        BUG_ON(! cnx);
 
        switch (event->base_event.xSubtype) {
-       case VethEventTypeCap:
+       case VETH_EVENT_CAP:
                veth_take_cap_ack(cnx, event);
                break;
-       case VethEventTypeMonitor:
+       case VETH_EVENT_MONITOR:
                veth_take_monitor_ack(cnx, event);
                break;
        default:
-               veth_error("Unknown ack type %d from lpar %d\n",
-                          event->base_event.xSubtype, rlp);
+               veth_error("Unknown ack type %d from LPAR %d.\n",
+                               event->base_event.xSubtype, rlp);
        };
 }
 
-static void veth_handle_int(struct VethLpEvent *event)
+static void veth_handle_int(struct veth_lpevent *event)
 {
        HvLpIndex rlp = event->base_event.xSourceLp;
        struct veth_lpar_connection *cnx = veth_cnx[rlp];
        unsigned long flags;
-       int i;
+       int i, acked = 0;
 
        BUG_ON(! cnx);
 
        switch (event->base_event.xSubtype) {
-       case VethEventTypeCap:
+       case VETH_EVENT_CAP:
                veth_take_cap(cnx, event);
                break;
-       case VethEventTypeMonitor:
+       case VETH_EVENT_MONITOR:
                /* do nothing... this'll hang out here til we're dead,
                 * and the hypervisor will return it for us. */
                break;
-       case VethEventTypeFramesAck:
+       case VETH_EVENT_FRAMES_ACK:
                spin_lock_irqsave(&cnx->lock, flags);
+
                for (i = 0; i < VETH_MAX_ACKS_PER_MSG; ++i) {
                        u16 msgnum = event->u.frames_ack_data.token[i];
 
-                       if (msgnum < VETH_NUMBUFFERS)
+                       if (msgnum < VETH_NUMBUFFERS) {
                                veth_recycle_msg(cnx, cnx->msgs + msgnum);
+                               cnx->outstanding_tx--;
+                               acked++;
+                       }
+               }
+
+               if (acked > 0) {
+                       cnx->last_contact = jiffies;
+                       veth_wake_queues(cnx);
                }
+
                spin_unlock_irqrestore(&cnx->lock, flags);
-               veth_flush_pending(cnx);
                break;
-       case VethEventTypeFrames:
+       case VETH_EVENT_FRAMES:
                veth_receive(cnx, event);
                break;
        default:
-               veth_error("Unknown interrupt type %d from lpar %d\n",
-                          event->base_event.xSubtype, rlp);
+               veth_error("Unknown interrupt type %d from LPAR %d.\n",
+                               event->base_event.xSubtype, rlp);
        };
 }
 
 static void veth_handle_event(struct HvLpEvent *event, struct pt_regs *regs)
 {
-       struct VethLpEvent *veth_event = (struct VethLpEvent *)event;
+       struct veth_lpevent *veth_event = (struct veth_lpevent *)event;
 
        if (event->xFlags.xFunction == HvLpEvent_Function_Ack)
                veth_handle_ack(veth_event);
@@ -390,7 +597,7 @@ static void veth_handle_event(struct HvLpEvent *event, struct pt_regs *regs)
 
 static int veth_process_caps(struct veth_lpar_connection *cnx)
 {
-       struct VethCapData *remote_caps = &cnx->remote_caps;
+       struct veth_cap_data *remote_caps = &cnx->remote_caps;
        int num_acks_needed;
 
        /* Convert timer to jiffies */
@@ -400,8 +607,8 @@ static int veth_process_caps(struct veth_lpar_connection *cnx)
             || (remote_caps->ack_threshold > VETH_MAX_ACKS_PER_MSG)
             || (remote_caps->ack_threshold == 0)
             || (cnx->ack_timeout == 0) ) {
-               veth_error("Received incompatible capabilities from lpar %d\n",
-                          cnx->remote_lp);
+               veth_error("Received incompatible capabilities from LPAR %d.\n",
+                               cnx->remote_lp);
                return HvLpEvent_Rc_InvalidSubtypeData;
        }
 
@@ -418,8 +625,8 @@ static int veth_process_caps(struct veth_lpar_connection *cnx)
                        cnx->num_ack_events += num;
 
                if (cnx->num_ack_events < num_acks_needed) {
-                       veth_error("Couldn't allocate enough ack events for lpar %d\n",
-                                  cnx->remote_lp);
+                       veth_error("Couldn't allocate enough ack events "
+                                       "for LPAR %d.\n", cnx->remote_lp);
 
                        return HvLpEvent_Rc_BufferNotAvailable;
                }
@@ -440,15 +647,15 @@ static void veth_statemachine(void *p)
 
  restart:
        if (cnx->state & VETH_STATE_RESET) {
-               int i;
-
-               del_timer(&cnx->ack_timer);
-
                if (cnx->state & VETH_STATE_OPEN)
                        HvCallEvent_closeLpEventPath(cnx->remote_lp,
                                                     HvLpEvent_Type_VirtualLan);
 
-               /* reset ack data */
+               /*
+                * Reset ack data. This prevents the ack_timer actually
+                * doing anything, even if it runs one more time when
+                * we drop the lock below.
+                */
                memset(&cnx->pending_acks, 0xff, sizeof (cnx->pending_acks));
                cnx->num_pending_acks = 0;
 
@@ -458,14 +665,32 @@ static void veth_statemachine(void *p)
                                | VETH_STATE_SENTCAPACK | VETH_STATE_READY);
 
                /* Clean up any leftover messages */
-               if (cnx->msgs)
+               if (cnx->msgs) {
+                       int i;
                        for (i = 0; i < VETH_NUMBUFFERS; ++i)
                                veth_recycle_msg(cnx, cnx->msgs + i);
+               }
+
+               cnx->outstanding_tx = 0;
+               veth_wake_queues(cnx);
+
+               /* Drop the lock so we can do stuff that might sleep or
+                * take other locks. */
                spin_unlock_irq(&cnx->lock);
-               veth_flush_pending(cnx);
+
+               del_timer_sync(&cnx->ack_timer);
+               del_timer_sync(&cnx->reset_timer);
+
                spin_lock_irq(&cnx->lock);
+
                if (cnx->state & VETH_STATE_RESET)
                        goto restart;
+
+               /* Hack, wait for the other end to reset itself. */
+               if (! (cnx->state & VETH_STATE_SHUTDOWN)) {
+                       schedule_delayed_work(&cnx->statemachine_wq, 5 * HZ);
+                       goto out;
+               }
        }
 
        if (cnx->state & VETH_STATE_SHUTDOWN)
@@ -488,7 +713,7 @@ static void veth_statemachine(void *p)
 
        if ( (cnx->state & VETH_STATE_OPEN)
             && !(cnx->state & VETH_STATE_SENTMON) ) {
-               rc = veth_signalevent(cnx, VethEventTypeMonitor,
+               rc = veth_signalevent(cnx, VETH_EVENT_MONITOR,
                                      HvLpEvent_AckInd_DoAck,
                                      HvLpEvent_AckType_DeferredAck,
                                      0, 0, 0, 0, 0, 0);
@@ -498,9 +723,8 @@ static void veth_statemachine(void *p)
                } else {
                        if ( (rc != HvLpEvent_Rc_PartitionDead)
                             && (rc != HvLpEvent_Rc_PathClosed) )
-                               veth_error("Error sending monitor to "
-                                          "lpar %d, rc=%x\n",
-                                          rlp, (int) rc);
+                               veth_error("Error sending monitor to LPAR %d, "
+                                               "rc = %d\n", rlp, rc);
 
                        /* Oh well, hope we get a cap from the other
                         * end and do better when that kicks us */
@@ -512,7 +736,7 @@ static void veth_statemachine(void *p)
             && !(cnx->state & VETH_STATE_SENTCAPS)) {
                u64 *rawcap = (u64 *)&cnx->local_caps;
 
-               rc = veth_signalevent(cnx, VethEventTypeCap,
+               rc = veth_signalevent(cnx, VETH_EVENT_CAP,
                                      HvLpEvent_AckInd_DoAck,
                                      HvLpEvent_AckType_ImmediateAck,
                                      0, rawcap[0], rawcap[1], rawcap[2],
@@ -523,9 +747,9 @@ static void veth_statemachine(void *p)
                } else {
                        if ( (rc != HvLpEvent_Rc_PartitionDead)
                             && (rc != HvLpEvent_Rc_PathClosed) )
-                               veth_error("Error sending caps to "
-                                          "lpar %d, rc=%x\n",
-                                          rlp, (int) rc);
+                               veth_error("Error sending caps to LPAR %d, "
+                                               "rc = %d\n", rlp, rc);
+
                        /* Oh well, hope we get a cap from the other
                         * end and do better when that kicks us */
                        goto out;
@@ -534,7 +758,7 @@ static void veth_statemachine(void *p)
 
        if ((cnx->state & VETH_STATE_GOTCAPS)
            && !(cnx->state & VETH_STATE_SENTCAPACK)) {
-               struct VethCapData *remote_caps = &cnx->remote_caps;
+               struct veth_cap_data *remote_caps = &cnx->remote_caps;
 
                memcpy(remote_caps, &cnx->cap_event.u.caps_data,
                       sizeof(*remote_caps));
@@ -565,10 +789,8 @@ static void veth_statemachine(void *p)
                        add_timer(&cnx->ack_timer);
                        cnx->state |= VETH_STATE_READY;
                } else {
-                       veth_printk(KERN_ERR, "Caps rejected (rc=%d) by "
-                                   "lpar %d\n",
-                                   cnx->cap_ack_event.base_event.xRc,
-                                   rlp);
+                       veth_error("Caps rejected by LPAR %d, rc = %d\n",
+                                       rlp, cnx->cap_ack_event.base_event.xRc);
                        goto cant_cope;
                }
        }
@@ -581,8 +803,8 @@ static void veth_statemachine(void *p)
        /* FIXME: we get here if something happens we really can't
         * cope with.  The link will never work once we get here, and
         * all we can do is not lock the rest of the system up */
-       veth_error("Badness on connection to lpar %d (state=%04lx) "
-                  " - shutting down\n", rlp, cnx->state);
+       veth_error("Unrecoverable error on connection to LPAR %d, shutting down"
+                       " (state = 0x%04lx)\n", rlp, cnx->state);
        cnx->state |= VETH_STATE_SHUTDOWN;
        spin_unlock_irq(&cnx->lock);
 }
@@ -591,7 +813,7 @@ static int veth_init_connection(u8 rlp)
 {
        struct veth_lpar_connection *cnx;
        struct veth_msg *msgs;
-       int i;
+       int i, rc;
 
        if ( (rlp == this_lp)
             || ! HvLpConfig_doLpsCommunicateOnVirtualLan(this_lp, rlp) )
@@ -605,22 +827,36 @@ static int veth_init_connection(u8 rlp)
        cnx->remote_lp = rlp;
        spin_lock_init(&cnx->lock);
        INIT_WORK(&cnx->statemachine_wq, veth_statemachine, cnx);
+
        init_timer(&cnx->ack_timer);
        cnx->ack_timer.function = veth_timed_ack;
        cnx->ack_timer.data = (unsigned long) cnx;
+
+       init_timer(&cnx->reset_timer);
+       cnx->reset_timer.function = veth_timed_reset;
+       cnx->reset_timer.data = (unsigned long) cnx;
+       cnx->reset_timeout = 5 * HZ * (VETH_ACKTIMEOUT / 1000000);
+
        memset(&cnx->pending_acks, 0xff, sizeof (cnx->pending_acks));
 
        veth_cnx[rlp] = cnx;
 
+       /* This gets us 1 reference, which is held on behalf of the driver
+        * infrastructure. It's released at module unload. */
+       kobject_init(&cnx->kobject);
+       cnx->kobject.ktype = &veth_lpar_connection_ktype;
+       rc = kobject_set_name(&cnx->kobject, "cnx%.2d", rlp);
+       if (rc != 0)
+               return rc;
+
        msgs = kmalloc(VETH_NUMBUFFERS * sizeof(struct veth_msg), GFP_KERNEL);
        if (! msgs) {
-               veth_error("Can't allocate buffers for lpar %d\n", rlp);
+               veth_error("Can't allocate buffers for LPAR %d.\n", rlp);
                return -ENOMEM;
        }
 
        cnx->msgs = msgs;
        memset(msgs, 0, VETH_NUMBUFFERS * sizeof(struct veth_msg));
-       spin_lock_init(&cnx->msg_stack_lock);
 
        for (i = 0; i < VETH_NUMBUFFERS; i++) {
                msgs[i].token = i;
@@ -630,8 +866,7 @@ static int veth_init_connection(u8 rlp)
        cnx->num_events = veth_allocate_events(rlp, 2 + VETH_NUMBUFFERS);
 
        if (cnx->num_events < (2 + VETH_NUMBUFFERS)) {
-               veth_error("Can't allocate events for lpar %d, only got %d\n",
-                          rlp, cnx->num_events);
+               veth_error("Can't allocate enough events for LPAR %d.\n", rlp);
                return -ENOMEM;
        }
 
@@ -642,11 +877,9 @@ static int veth_init_connection(u8 rlp)
        return 0;
 }
 
-static void veth_stop_connection(u8 rlp)
+static void veth_stop_connection(struct veth_lpar_connection *cnx)
 {
-       struct veth_lpar_connection *cnx = veth_cnx[rlp];
-
-       if (! cnx)
+       if (!cnx)
                return;
 
        spin_lock_irq(&cnx->lock);
@@ -654,12 +887,23 @@ static void veth_stop_connection(u8 rlp)
        veth_kick_statemachine(cnx);
        spin_unlock_irq(&cnx->lock);
 
+       /* There's a slim chance the reset code has just queued the
+        * statemachine to run in five seconds. If so we need to cancel
+        * that and requeue the work to run now. */
+       if (cancel_delayed_work(&cnx->statemachine_wq)) {
+               spin_lock_irq(&cnx->lock);
+               veth_kick_statemachine(cnx);
+               spin_unlock_irq(&cnx->lock);
+       }
+
+       /* Wait for the state machine to run. */
        flush_scheduled_work();
+}
 
-       /* FIXME: not sure if this is necessary - will already have
-        * been deleted by the state machine, just want to make sure
-        * its not running any more */
-       del_timer_sync(&cnx->ack_timer);
+static void veth_destroy_connection(struct veth_lpar_connection *cnx)
+{
+       if (!cnx)
+               return;
 
        if (cnx->num_events > 0)
                mf_deallocate_lp_events(cnx->remote_lp,
@@ -671,18 +915,18 @@ static void veth_stop_connection(u8 rlp)
                                      HvLpEvent_Type_VirtualLan,
                                      cnx->num_ack_events,
                                      NULL, NULL);
-}
-
-static void veth_destroy_connection(u8 rlp)
-{
-       struct veth_lpar_connection *cnx = veth_cnx[rlp];
-
-       if (! cnx)
-               return;
 
        kfree(cnx->msgs);
+       veth_cnx[cnx->remote_lp] = NULL;
        kfree(cnx);
-       veth_cnx[rlp] = NULL;
+}
+
+static void veth_release_connection(struct kobject *kobj)
+{
+       struct veth_lpar_connection *cnx;
+       cnx = container_of(kobj, struct veth_lpar_connection, kobject);
+       veth_stop_connection(cnx);
+       veth_destroy_connection(cnx);
 }
 
 /*
@@ -726,17 +970,15 @@ static void veth_set_multicast_list(struct net_device *dev)
 
        write_lock_irqsave(&port->mcast_gate, flags);
 
-       if (dev->flags & IFF_PROMISC) { /* set promiscuous mode */
-               printk(KERN_INFO "%s: Promiscuous mode enabled.\n",
-                      dev->name);
+       if ((dev->flags & IFF_PROMISC) || (dev->flags & IFF_ALLMULTI) ||
+                       (dev->mc_count > VETH_MAX_MCAST)) {
                port->promiscuous = 1;
-       } else if ( (dev->flags & IFF_ALLMULTI)
-                   || (dev->mc_count > VETH_MAX_MCAST) ) {
-               port->all_mcast = 1;
        } else {
                struct dev_mc_list *dmi = dev->mc_list;
                int i;
 
+               port->promiscuous = 0;
+
                /* Update table */
                port->num_mcast = 0;
 
@@ -758,9 +1000,10 @@ static void veth_set_multicast_list(struct net_device *dev)
 
 static void veth_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
-       strncpy(info->driver, "veth", sizeof(info->driver) - 1);
+       strncpy(info->driver, DRV_NAME, sizeof(info->driver) - 1);
        info->driver[sizeof(info->driver) - 1] = '\0';
-       strncpy(info->version, "1.0", sizeof(info->version) - 1);
+       strncpy(info->version, DRV_VERSION, sizeof(info->version) - 1);
+       info->version[sizeof(info->version) - 1] = '\0';
 }
 
 static int veth_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
@@ -791,49 +1034,6 @@ static struct ethtool_ops ops = {
        .get_link = veth_get_link,
 };
 
-static void veth_tx_timeout(struct net_device *dev)
-{
-       struct veth_port *port = (struct veth_port *)dev->priv;
-       struct net_device_stats *stats = &port->stats;
-       unsigned long flags;
-       int i;
-
-       stats->tx_errors++;
-
-       spin_lock_irqsave(&port->pending_gate, flags);
-
-       if (!port->pending_lpmask) {
-               spin_unlock_irqrestore(&port->pending_gate, flags);
-               return;
-       }
-
-       printk(KERN_WARNING "%s: Tx timeout!  Resetting lp connections: %08x\n",
-              dev->name, port->pending_lpmask);
-
-       for (i = 0; i < HVMAXARCHITECTEDLPS; i++) {
-               struct veth_lpar_connection *cnx = veth_cnx[i];
-
-               if (! (port->pending_lpmask & (1<<i)))
-                       continue;
-
-               /* If we're pending on it, we must be connected to it,
-                * so we should certainly have a structure for it. */
-               BUG_ON(! cnx);
-
-               /* Theoretically we could be kicking a connection
-                * which doesn't deserve it, but in practice if we've
-                * had a Tx timeout, the pending_lpmask will have
-                * exactly one bit set - the connection causing the
-                * problem. */
-               spin_lock(&cnx->lock);
-               cnx->state |= VETH_STATE_RESET;
-               veth_kick_statemachine(cnx);
-               spin_unlock(&cnx->lock);
-       }
-
-       spin_unlock_irqrestore(&port->pending_gate, flags);
-}
-
 static struct net_device * __init veth_probe_one(int vlan, struct device *vdev)
 {
        struct net_device *dev;
@@ -848,8 +1048,9 @@ static struct net_device * __init veth_probe_one(int vlan, struct device *vdev)
 
        port = (struct veth_port *) dev->priv;
 
-       spin_lock_init(&port->pending_gate);
+       spin_lock_init(&port->queue_lock);
        rwlock_init(&port->mcast_gate);
+       port->stopped_map = 0;
 
        for (i = 0; i < HVMAXARCHITECTEDLPS; i++) {
                HvLpVirtualLanIndexMap map;
@@ -882,22 +1083,24 @@ static struct net_device * __init veth_probe_one(int vlan, struct device *vdev)
        dev->set_multicast_list = veth_set_multicast_list;
        SET_ETHTOOL_OPS(dev, &ops);
 
-       dev->watchdog_timeo = 2 * (VETH_ACKTIMEOUT * HZ / 1000000);
-       dev->tx_timeout = veth_tx_timeout;
-
        SET_NETDEV_DEV(dev, vdev);
 
        rc = register_netdev(dev);
        if (rc != 0) {
-               veth_printk(KERN_ERR,
-                           "Failed to register ethernet device for vlan %d\n",
-                           vlan);
+               veth_error("Failed registering net device for vlan%d.\n", vlan);
                free_netdev(dev);
                return NULL;
        }
 
-       veth_printk(KERN_DEBUG, "%s attached to iSeries vlan %d (lpar_map=0x%04x)\n",
-                   dev->name, vlan, port->lpar_map);
+       kobject_init(&port->kobject);
+       port->kobject.parent = &dev->class_dev.kobj;
+       port->kobject.ktype  = &veth_port_ktype;
+       kobject_set_name(&port->kobject, "veth_port");
+       if (0 != kobject_add(&port->kobject))
+               veth_error("Failed adding port for %s to sysfs.\n", dev->name);
+
+       veth_info("%s attached to iSeries vlan %d (LPAR map = 0x%.4X)\n",
+                       dev->name, vlan, port->lpar_map);
 
        return dev;
 }
@@ -912,98 +1115,95 @@ static int veth_transmit_to_one(struct sk_buff *skb, HvLpIndex rlp,
        struct veth_lpar_connection *cnx = veth_cnx[rlp];
        struct veth_port *port = (struct veth_port *) dev->priv;
        HvLpEvent_Rc rc;
-       u32 dma_address, dma_length;
        struct veth_msg *msg = NULL;
-       int err = 0;
        unsigned long flags;
 
-       if (! cnx) {
-               port->stats.tx_errors++;
-               dev_kfree_skb(skb);
+       if (! cnx)
                return 0;
-       }
 
        spin_lock_irqsave(&cnx->lock, flags);
 
        if (! (cnx->state & VETH_STATE_READY))
-               goto drop;
+               goto no_error;
 
-       if ((skb->len - 14) > VETH_MAX_MTU)
+       if ((skb->len - ETH_HLEN) > VETH_MAX_MTU)
                goto drop;
 
        msg = veth_stack_pop(cnx);
-
-       if (! msg) {
-               err = 1;
+       if (! msg)
                goto drop;
-       }
 
-       dma_length = skb->len;
-       dma_address = dma_map_single(port->dev, skb->data,
-                                    dma_length, DMA_TO_DEVICE);
+       msg->in_use = 1;
+       msg->skb = skb_get(skb);
+
+       msg->data.addr[0] = dma_map_single(port->dev, skb->data,
+                               skb->len, DMA_TO_DEVICE);
 
-       if (dma_mapping_error(dma_address))
+       if (dma_mapping_error(msg->data.addr[0]))
                goto recycle_and_drop;
 
-       /* Is it really necessary to check the length and address
-        * fields of the first entry here? */
-       msg->skb = skb;
        msg->dev = port->dev;
-       msg->data.addr[0] = dma_address;
-       msg->data.len[0] = dma_length;
+       msg->data.len[0] = skb->len;
        msg->data.eofmask = 1 << VETH_EOF_SHIFT;
-       set_bit(0, &(msg->in_use));
-       rc = veth_signaldata(cnx, VethEventTypeFrames, msg->token, &msg->data);
+
+       rc = veth_signaldata(cnx, VETH_EVENT_FRAMES, msg->token, &msg->data);
 
        if (rc != HvLpEvent_Rc_Good)
                goto recycle_and_drop;
 
+       /* If the timer's not already running, start it now. */
+       if (0 == cnx->outstanding_tx)
+               mod_timer(&cnx->reset_timer, jiffies + cnx->reset_timeout);
+
+       cnx->last_contact = jiffies;
+       cnx->outstanding_tx++;
+
+       if (veth_stack_is_empty(cnx))
+               veth_stop_queues(cnx);
+
+ no_error:
        spin_unlock_irqrestore(&cnx->lock, flags);
        return 0;
 
  recycle_and_drop:
-       msg->skb = NULL;
-       /* need to set in use to make veth_recycle_msg in case this
-        * was a mapping failure */
-       set_bit(0, &msg->in_use);
        veth_recycle_msg(cnx, msg);
  drop:
-       port->stats.tx_errors++;
-       dev_kfree_skb(skb);
        spin_unlock_irqrestore(&cnx->lock, flags);
-       return err;
+       return 1;
 }
 
-static HvLpIndexMap veth_transmit_to_many(struct sk_buff *skb,
+static void veth_transmit_to_many(struct sk_buff *skb,
                                          HvLpIndexMap lpmask,
                                          struct net_device *dev)
 {
        struct veth_port *port = (struct veth_port *) dev->priv;
-       int i;
-       int rc;
+       int i, success, error;
+
+       success = error = 0;
 
        for (i = 0; i < HVMAXARCHITECTEDLPS; i++) {
                if ((lpmask & (1 << i)) == 0)
                        continue;
 
-               rc = veth_transmit_to_one(skb_get(skb), i, dev);
-               if (! rc)
-                       lpmask &= ~(1<<i);
+               if (veth_transmit_to_one(skb, i, dev))
+                       error = 1;
+               else
+                       success = 1;
        }
 
-       if (! lpmask) {
+       if (error)
+               port->stats.tx_errors++;
+
+       if (success) {
                port->stats.tx_packets++;
                port->stats.tx_bytes += skb->len;
        }
-
-       return lpmask;
 }
 
 static int veth_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        unsigned char *frame = skb->data;
        struct veth_port *port = (struct veth_port *) dev->priv;
-       unsigned long flags;
        HvLpIndexMap lpmask;
 
        if (! (frame[0] & 0x01)) {
@@ -1020,44 +1220,27 @@ static int veth_start_xmit(struct sk_buff *skb, struct net_device *dev)
                lpmask = port->lpar_map;
        }
 
-       spin_lock_irqsave(&port->pending_gate, flags);
-
-       lpmask = veth_transmit_to_many(skb, lpmask, dev);
-
-       dev->trans_start = jiffies;
+       veth_transmit_to_many(skb, lpmask, dev);
 
-       if (! lpmask) {
-               dev_kfree_skb(skb);
-       } else {
-               if (port->pending_skb) {
-                       veth_error("%s: Tx while skb was pending!\n",
-                                  dev->name);
-                       dev_kfree_skb(skb);
-                       spin_unlock_irqrestore(&port->pending_gate, flags);
-                       return 1;
-               }
-
-               port->pending_skb = skb;
-               port->pending_lpmask = lpmask;
-               netif_stop_queue(dev);
-       }
-
-       spin_unlock_irqrestore(&port->pending_gate, flags);
+       dev_kfree_skb(skb);
 
        return 0;
 }
 
+/* You must hold the connection's lock when you call this function. */
 static void veth_recycle_msg(struct veth_lpar_connection *cnx,
                             struct veth_msg *msg)
 {
        u32 dma_address, dma_length;
 
-       if (test_and_clear_bit(0, &msg->in_use)) {
+       if (msg->in_use) {
+               msg->in_use = 0;
                dma_address = msg->data.addr[0];
                dma_length = msg->data.len[0];
 
-               dma_unmap_single(msg->dev, dma_address, dma_length,
-                                DMA_TO_DEVICE);
+               if (!dma_mapping_error(dma_address))
+                       dma_unmap_single(msg->dev, dma_address, dma_length,
+                                       DMA_TO_DEVICE);
 
                if (msg->skb) {
                        dev_kfree_skb_any(msg->skb);
@@ -1066,15 +1249,16 @@ static void veth_recycle_msg(struct veth_lpar_connection *cnx,
 
                memset(&msg->data, 0, sizeof(msg->data));
                veth_stack_push(cnx, msg);
-       } else
-               if (cnx->state & VETH_STATE_OPEN)
-                       veth_error("Bogus frames ack from lpar %d (#%d)\n",
-                                  cnx->remote_lp, msg->token);
+       } else if (cnx->state & VETH_STATE_OPEN) {
+               veth_error("Non-pending frame (# %d) acked by LPAR %d.\n",
+                               cnx->remote_lp, msg->token);
+       }
 }
 
-static void veth_flush_pending(struct veth_lpar_connection *cnx)
+static void veth_wake_queues(struct veth_lpar_connection *cnx)
 {
        int i;
+
        for (i = 0; i < HVMAXARCHITECTEDVIRTUALLANS; i++) {
                struct net_device *dev = veth_dev[i];
                struct veth_port *port;
@@ -1088,20 +1272,77 @@ static void veth_flush_pending(struct veth_lpar_connection *cnx)
                if (! (port->lpar_map & (1<<cnx->remote_lp)))
                        continue;
 
-               spin_lock_irqsave(&port->pending_gate, flags);
-               if (port->pending_skb) {
-                       port->pending_lpmask =
-                               veth_transmit_to_many(port->pending_skb,
-                                                     port->pending_lpmask,
-                                                     dev);
-                       if (! port->pending_lpmask) {
-                               dev_kfree_skb_any(port->pending_skb);
-                               port->pending_skb = NULL;
-                               netif_wake_queue(dev);
-                       }
+               spin_lock_irqsave(&port->queue_lock, flags);
+
+               port->stopped_map &= ~(1 << cnx->remote_lp);
+
+               if (0 == port->stopped_map && netif_queue_stopped(dev)) {
+                       veth_debug("cnx %d: woke queue for %s.\n",
+                                       cnx->remote_lp, dev->name);
+                       netif_wake_queue(dev);
+               }
+               spin_unlock_irqrestore(&port->queue_lock, flags);
+       }
+}
+
+static void veth_stop_queues(struct veth_lpar_connection *cnx)
+{
+       int i;
+
+       for (i = 0; i < HVMAXARCHITECTEDVIRTUALLANS; i++) {
+               struct net_device *dev = veth_dev[i];
+               struct veth_port *port;
+
+               if (! dev)
+                       continue;
+
+               port = (struct veth_port *)dev->priv;
+
+               /* If this cnx is not on the vlan for this port, continue */
+               if (! (port->lpar_map & (1 << cnx->remote_lp)))
+                       continue;
+
+               spin_lock(&port->queue_lock);
+
+               netif_stop_queue(dev);
+               port->stopped_map |= (1 << cnx->remote_lp);
+
+               veth_debug("cnx %d: stopped queue for %s, map = 0x%x.\n",
+                               cnx->remote_lp, dev->name, port->stopped_map);
+
+               spin_unlock(&port->queue_lock);
+       }
+}
+
+static void veth_timed_reset(unsigned long ptr)
+{
+       struct veth_lpar_connection *cnx = (struct veth_lpar_connection *)ptr;
+       unsigned long trigger_time, flags;
+
+       /* FIXME is it possible this fires after veth_stop_connection()?
+        * That would reschedule the statemachine for 5 seconds and probably
+        * execute it after the module's been unloaded. Hmm. */
+
+       spin_lock_irqsave(&cnx->lock, flags);
+
+       if (cnx->outstanding_tx > 0) {
+               trigger_time = cnx->last_contact + cnx->reset_timeout;
+
+               if (trigger_time < jiffies) {
+                       cnx->state |= VETH_STATE_RESET;
+                       veth_kick_statemachine(cnx);
+                       veth_error("%d packets not acked by LPAR %d within %d "
+                                       "seconds, resetting.\n",
+                                       cnx->outstanding_tx, cnx->remote_lp,
+                                       cnx->reset_timeout / HZ);
+               } else {
+                       /* Reschedule the timer */
+                       trigger_time = jiffies + cnx->reset_timeout;
+                       mod_timer(&cnx->reset_timer, trigger_time);
                }
-               spin_unlock_irqrestore(&port->pending_gate, flags);
        }
+
+       spin_unlock_irqrestore(&cnx->lock, flags);
 }
 
 /*
@@ -1117,12 +1358,9 @@ static inline int veth_frame_wanted(struct veth_port *port, u64 mac_addr)
        if ( (mac_addr == port->mac_addr) || (mac_addr == 0xffffffffffff0000) )
                return 1;
 
-       if (! (((char *) &mac_addr)[0] & 0x01))
-               return 0;
-
        read_lock_irqsave(&port->mcast_gate, flags);
 
-       if (port->promiscuous || port->all_mcast) {
+       if (port->promiscuous) {
                wanted = 1;
                goto out;
        }
@@ -1175,21 +1413,21 @@ static void veth_flush_acks(struct veth_lpar_connection *cnx)
 {
        HvLpEvent_Rc rc;
 
-       rc = veth_signaldata(cnx, VethEventTypeFramesAck,
+       rc = veth_signaldata(cnx, VETH_EVENT_FRAMES_ACK,
                             0, &cnx->pending_acks);
 
        if (rc != HvLpEvent_Rc_Good)
-               veth_error("Error 0x%x acking frames from lpar %d!\n",
-                          (unsigned)rc, cnx->remote_lp);
+               veth_error("Failed acking frames from LPAR %d, rc = %d\n",
+                               cnx->remote_lp, (int)rc);
 
        cnx->num_pending_acks = 0;
        memset(&cnx->pending_acks, 0xff, sizeof(cnx->pending_acks));
 }
 
 static void veth_receive(struct veth_lpar_connection *cnx,
-                        struct VethLpEvent *event)
+                        struct veth_lpevent *event)
 {
-       struct VethFramesData *senddata = &event->u.frames_data;
+       struct veth_frames_data *senddata = &event->u.frames_data;
        int startchunk = 0;
        int nchunks;
        unsigned long flags;
@@ -1216,9 +1454,10 @@ static void veth_receive(struct veth_lpar_connection *cnx,
                /* make sure that we have at least 1 EOF entry in the
                 * remaining entries */
                if (! (senddata->eofmask >> (startchunk + VETH_EOF_SHIFT))) {
-                       veth_error("missing EOF frag in event "
-                                  "eofmask=0x%x startchunk=%d\n",
-                                  (unsigned) senddata->eofmask, startchunk);
+                       veth_error("Missing EOF fragment in event "
+                                       "eofmask = 0x%x startchunk = %d\n",
+                                       (unsigned)senddata->eofmask,
+                                       startchunk);
                        break;
                }
 
@@ -1237,8 +1476,9 @@ static void veth_receive(struct veth_lpar_connection *cnx,
                /* nchunks == # of chunks in this frame */
 
                if ((length - ETH_HLEN) > VETH_MAX_MTU) {
-                       veth_error("Received oversize frame from lpar %d "
-                                  "(length=%d)\n", cnx->remote_lp, length);
+                       veth_error("Received oversize frame from LPAR %d "
+                                       "(length = %d)\n",
+                                       cnx->remote_lp, length);
                        continue;
                }
 
@@ -1331,15 +1571,33 @@ static void veth_timed_ack(unsigned long ptr)
 
 static int veth_remove(struct vio_dev *vdev)
 {
-       int i = vdev->unit_address;
+       struct veth_lpar_connection *cnx;
        struct net_device *dev;
+       struct veth_port *port;
+       int i;
 
-       dev = veth_dev[i];
-       if (dev != NULL) {
-               veth_dev[i] = NULL;
-               unregister_netdev(dev);
-               free_netdev(dev);
+       dev = veth_dev[vdev->unit_address];
+
+       if (! dev)
+               return 0;
+
+       port = netdev_priv(dev);
+
+       for (i = 0; i < HVMAXARCHITECTEDLPS; i++) {
+               cnx = veth_cnx[i];
+
+               if (cnx && (port->lpar_map & (1 << i))) {
+                       /* Drop our reference to connections on our VLAN */
+                       kobject_put(&cnx->kobject);
+               }
        }
+
+       veth_dev[vdev->unit_address] = NULL;
+       kobject_del(&port->kobject);
+       kobject_put(&port->kobject);
+       unregister_netdev(dev);
+       free_netdev(dev);
+
        return 0;
 }
 
@@ -1347,6 +1605,7 @@ static int veth_probe(struct vio_dev *vdev, const struct vio_device_id *id)
 {
        int i = vdev->unit_address;
        struct net_device *dev;
+       struct veth_port *port;
 
        dev = veth_probe_one(i, &vdev->dev);
        if (dev == NULL) {
@@ -1355,11 +1614,23 @@ static int veth_probe(struct vio_dev *vdev, const struct vio_device_id *id)
        }
        veth_dev[i] = dev;
 
-       /* Start the state machine on each connection, to commence
-        * link negotiation */
-       for (i = 0; i < HVMAXARCHITECTEDLPS; i++)
-               if (veth_cnx[i])
-                       veth_kick_statemachine(veth_cnx[i]);
+       port = (struct veth_port*)netdev_priv(dev);
+
+       /* Start the state machine on each connection on this vlan. If we're
+        * the first dev to do so this will commence link negotiation */
+       for (i = 0; i < HVMAXARCHITECTEDLPS; i++) {
+               struct veth_lpar_connection *cnx;
+
+               if (! (port->lpar_map & (1 << i)))
+                       continue;
+
+               cnx = veth_cnx[i];
+               if (!cnx)
+                       continue;
+
+               kobject_get(&cnx->kobject);
+               veth_kick_statemachine(cnx);
+       }
 
        return 0;
 }
@@ -1375,7 +1646,7 @@ static struct vio_device_id veth_device_table[] __devinitdata = {
 MODULE_DEVICE_TABLE(vio, veth_device_table);
 
 static struct vio_driver veth_driver = {
-       .name = "iseries_veth",
+       .name = DRV_NAME,
        .id_table = veth_device_table,
        .probe = veth_probe,
        .remove = veth_remove
@@ -1388,29 +1659,29 @@ static struct vio_driver veth_driver = {
 void __exit veth_module_cleanup(void)
 {
        int i;
+       struct veth_lpar_connection *cnx;
 
-       /* Stop the queues first to stop any new packets being sent. */
-       for (i = 0; i < HVMAXARCHITECTEDVIRTUALLANS; i++)
-               if (veth_dev[i])
-                       netif_stop_queue(veth_dev[i]);
-
-       /* Stop the connections before we unregister the driver. This
-        * ensures there's no skbs lying around holding the device open. */
-       for (i = 0; i < HVMAXARCHITECTEDLPS; ++i)
-               veth_stop_connection(i);
-
+       /* Disconnect our "irq" to stop events coming from the Hypervisor. */
        HvLpEvent_unregisterHandler(HvLpEvent_Type_VirtualLan);
 
-       /* Hypervisor callbacks may have scheduled more work while we
-        * were stoping connections. Now that we've disconnected from
-        * the hypervisor make sure everything's finished. */
+       /* Make sure any work queued from Hypervisor callbacks is finished. */
        flush_scheduled_work();
 
-       vio_unregister_driver(&veth_driver);
+       for (i = 0; i < HVMAXARCHITECTEDLPS; ++i) {
+               cnx = veth_cnx[i];
+
+               if (!cnx)
+                       continue;
 
-       for (i = 0; i < HVMAXARCHITECTEDLPS; ++i)
-               veth_destroy_connection(i);
+               /* Remove the connection from sysfs */
+               kobject_del(&cnx->kobject);
+               /* Drop the driver's reference to the connection */
+               kobject_put(&cnx->kobject);
+       }
 
+       /* Unregister the driver, which will close all the netdevs and stop
+        * the connections when they're no longer referenced. */
+       vio_unregister_driver(&veth_driver);
 }
 module_exit(veth_module_cleanup);
 
@@ -1423,15 +1694,37 @@ int __init veth_module_init(void)
 
        for (i = 0; i < HVMAXARCHITECTEDLPS; ++i) {
                rc = veth_init_connection(i);
-               if (rc != 0) {
-                       veth_module_cleanup();
-                       return rc;
-               }
+               if (rc != 0)
+                       goto error;
        }
 
        HvLpEvent_registerHandler(HvLpEvent_Type_VirtualLan,
                                  &veth_handle_event);
 
-       return vio_register_driver(&veth_driver);
+       rc = vio_register_driver(&veth_driver);
+       if (rc != 0)
+               goto error;
+
+       for (i = 0; i < HVMAXARCHITECTEDLPS; ++i) {
+               struct kobject *kobj;
+
+               if (!veth_cnx[i])
+                       continue;
+
+               kobj = &veth_cnx[i]->kobject;
+               kobj->parent = &veth_driver.driver.kobj;
+               /* If the add failes, complain but otherwise continue */
+               if (0 != kobject_add(kobj))
+                       veth_error("cnx %d: Failed adding to sysfs.\n", i);
+       }
+
+       return 0;
+
+error:
+       for (i = 0; i < HVMAXARCHITECTEDLPS; ++i) {
+               veth_destroy_connection(veth_cnx[i]);
+       }
+
+       return rc;
 }
 module_init(veth_module_init);
diff --git a/drivers/net/iseries_veth.h b/drivers/net/iseries_veth.h
deleted file mode 100644 (file)
index d9370f7..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/* File veth.h created by Kyle A. Lucke on Mon Aug  7 2000. */
-
-#ifndef _ISERIES_VETH_H
-#define _ISERIES_VETH_H
-
-#define VethEventTypeCap       (0)
-#define VethEventTypeFrames    (1)
-#define VethEventTypeMonitor   (2)
-#define VethEventTypeFramesAck (3)
-
-#define VETH_MAX_ACKS_PER_MSG  (20)
-#define VETH_MAX_FRAMES_PER_MSG        (6)
-
-struct VethFramesData {
-       u32 addr[VETH_MAX_FRAMES_PER_MSG];
-       u16 len[VETH_MAX_FRAMES_PER_MSG];
-       u32 eofmask;
-};
-#define VETH_EOF_SHIFT         (32-VETH_MAX_FRAMES_PER_MSG)
-
-struct VethFramesAckData {
-       u16 token[VETH_MAX_ACKS_PER_MSG];
-};
-
-struct VethCapData {
-       u8 caps_version;
-       u8 rsvd1;
-       u16 num_buffers;
-       u16 ack_threshold;
-       u16 rsvd2;
-       u32 ack_timeout;
-       u32 rsvd3;
-       u64 rsvd4[3];
-};
-
-struct VethLpEvent {
-       struct HvLpEvent base_event;
-       union {
-               struct VethCapData caps_data;
-               struct VethFramesData frames_data;
-               struct VethFramesAckData frames_ack_data;
-       } u;
-
-};
-
-#endif /* _ISERIES_VETH_H */
index fb6b232069d6c43066fbb6f9d7b7244b8770d496..7c9dbc8c9423ae005a5be12175dc3c33397b367c 100644 (file)
 
 #define INT_CAUSE_UNMASK_ALL           0x0007ffff
 #define INT_CAUSE_UNMASK_ALL_EXT       0x0011ffff
-#ifdef MV643XX_RX_QUEUE_FILL_ON_TASK
 #define INT_CAUSE_MASK_ALL             0x00000000
+#define INT_CAUSE_MASK_ALL_EXT         0x00000000
 #define INT_CAUSE_CHECK_BITS           INT_CAUSE_UNMASK_ALL
 #define INT_CAUSE_CHECK_BITS_EXT       INT_CAUSE_UNMASK_ALL_EXT
-#endif
 
 #ifdef MV643XX_CHECKSUM_OFFLOAD_TX
 #define MAX_DESCS_PER_SKB      (MAX_SKB_FRAGS + 1)
@@ -259,14 +258,13 @@ static void mv643xx_eth_update_mac_address(struct net_device *dev)
 static void mv643xx_eth_set_rx_mode(struct net_device *dev)
 {
        struct mv643xx_private *mp = netdev_priv(dev);
-       u32 config_reg;
 
-       config_reg = ethernet_get_config_reg(mp->port_num);
        if (dev->flags & IFF_PROMISC)
-               config_reg |= (u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE;
+               mp->port_config |= (u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE;
        else
-               config_reg &= ~(u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE;
-       ethernet_set_config_reg(mp->port_num, config_reg);
+               mp->port_config &= ~(u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE;
+
+       mv_write(MV643XX_ETH_PORT_CONFIG_REG(mp->port_num), mp->port_config);
 }
 
 /*
@@ -369,15 +367,6 @@ static int mv643xx_eth_free_tx_queue(struct net_device *dev,
 
                        dev_kfree_skb_irq(pkt_info.return_info);
                        released = 0;
-
-                       /*
-                        * Decrement the number of outstanding skbs counter on
-                        * the TX queue.
-                        */
-                       if (mp->tx_ring_skbs == 0)
-                               panic("ERROR - TX outstanding SKBs"
-                                               " counter is corrupted");
-                       mp->tx_ring_skbs--;
                } else
                        dma_unmap_page(NULL, pkt_info.buf_ptr,
                                        pkt_info.byte_cnt, DMA_TO_DEVICE);
@@ -412,15 +401,13 @@ static int mv643xx_eth_receive_queue(struct net_device *dev)
        struct pkt_info pkt_info;
 
 #ifdef MV643XX_NAPI
-       while (eth_port_receive(mp, &pkt_info) == ETH_OK && budget > 0) {
+       while (budget-- > 0 && eth_port_receive(mp, &pkt_info) == ETH_OK) {
 #else
        while (eth_port_receive(mp, &pkt_info) == ETH_OK) {
 #endif
                mp->rx_ring_skbs--;
                received_packets++;
-#ifdef MV643XX_NAPI
-               budget--;
-#endif
+
                /* Update statistics. Note byte count includes 4 byte CRC count */
                stats->rx_packets++;
                stats->rx_bytes += pkt_info.byte_cnt;
@@ -1044,9 +1031,6 @@ static void mv643xx_tx(struct net_device *dev)
                                                DMA_TO_DEVICE);
 
                        dev_kfree_skb_irq(pkt_info.return_info);
-
-                       if (mp->tx_ring_skbs)
-                               mp->tx_ring_skbs--;
                } else
                        dma_unmap_page(NULL, pkt_info.buf_ptr,
                                        pkt_info.byte_cnt, DMA_TO_DEVICE);
@@ -1189,7 +1173,6 @@ linear:
                pkt_info.buf_ptr = dma_map_single(NULL, skb->data, skb->len,
                                                        DMA_TO_DEVICE);
                pkt_info.return_info = skb;
-               mp->tx_ring_skbs++;
                status = eth_port_send(mp, &pkt_info);
                if ((status == ETH_ERROR) || (status == ETH_QUEUE_FULL))
                        printk(KERN_ERR "%s: Error on transmitting packet\n",
@@ -1274,7 +1257,6 @@ linear:
                                pkt_info.cmd_sts |= ETH_TX_ENABLE_INTERRUPT |
                                                        ETH_TX_LAST_DESC;
                                pkt_info.return_info = skb;
-                               mp->tx_ring_skbs++;
                        } else {
                                pkt_info.return_info = 0;
                        }
@@ -1311,7 +1293,6 @@ linear:
        pkt_info.buf_ptr = dma_map_single(NULL, skb->data, skb->len,
                                                                DMA_TO_DEVICE);
        pkt_info.return_info = skb;
-       mp->tx_ring_skbs++;
        status = eth_port_send(mp, &pkt_info);
        if ((status == ETH_ERROR) || (status == ETH_QUEUE_FULL))
                printk(KERN_ERR "%s: Error on transmitting packet\n",
@@ -1356,6 +1337,43 @@ static struct net_device_stats *mv643xx_eth_get_stats(struct net_device *dev)
        return &mp->stats;
 }
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static inline void mv643xx_enable_irq(struct mv643xx_private *mp)
+{
+       int port_num = mp->port_num;
+       unsigned long flags;
+
+       spin_lock_irqsave(&mp->lock, flags);
+       mv_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num),
+                                       INT_CAUSE_UNMASK_ALL);
+       mv_write(MV643XX_ETH_INTERRUPT_EXTEND_MASK_REG(port_num),
+                                       INT_CAUSE_UNMASK_ALL_EXT);
+       spin_unlock_irqrestore(&mp->lock, flags);
+}
+
+static inline void mv643xx_disable_irq(struct mv643xx_private *mp)
+{
+       int port_num = mp->port_num;
+       unsigned long flags;
+
+       spin_lock_irqsave(&mp->lock, flags);
+       mv_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num),
+                                       INT_CAUSE_MASK_ALL);
+       mv_write(MV643XX_ETH_INTERRUPT_EXTEND_MASK_REG(port_num),
+                                       INT_CAUSE_MASK_ALL_EXT);
+       spin_unlock_irqrestore(&mp->lock, flags);
+}
+
+static void mv643xx_netpoll(struct net_device *netdev)
+{
+       struct mv643xx_private *mp = netdev_priv(netdev);
+
+       mv643xx_disable_irq(mp);
+       mv643xx_eth_int_handler(netdev->irq, netdev, NULL);
+       mv643xx_enable_irq(mp);
+}
+#endif
+
 /*/
  * mv643xx_eth_probe
  *
@@ -1406,6 +1424,10 @@ static int mv643xx_eth_probe(struct device *ddev)
        dev->weight = 64;
 #endif
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+       dev->poll_controller = mv643xx_netpoll;
+#endif
+
        dev->watchdog_timeo = 2 * HZ;
        dev->tx_queue_len = mp->tx_ring_size;
        dev->base_addr = 0;
@@ -1883,6 +1905,9 @@ static void eth_port_start(struct mv643xx_private *mp)
        /* Enable port Rx. */
        mv_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num),
                                                mp->port_rx_queue_command);
+
+       /* Disable port bandwidth limits by clearing MTU register */
+       mv_write(MV643XX_ETH_MAXIMUM_TRANSMIT_UNIT(port_num), 0);
 }
 
 /*
@@ -2292,34 +2317,6 @@ static void eth_port_reset(unsigned int port_num)
        mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), reg_data);
 }
 
-/*
- * ethernet_set_config_reg - Set specified bits in configuration register.
- *
- * DESCRIPTION:
- *     This function sets specified bits in the given ethernet
- *     configuration register.
- *
- * INPUT:
- *     unsigned int    eth_port_num    Ethernet Port number.
- *     unsigned int    value           32 bit value.
- *
- * OUTPUT:
- *     The set bits in the value parameter are set in the configuration
- *     register.
- *
- * RETURN:
- *     None.
- *
- */
-static void ethernet_set_config_reg(unsigned int eth_port_num,
-                                                       unsigned int value)
-{
-       unsigned int eth_config_reg;
-
-       eth_config_reg = mv_read(MV643XX_ETH_PORT_CONFIG_REG(eth_port_num));
-       eth_config_reg |= value;
-       mv_write(MV643XX_ETH_PORT_CONFIG_REG(eth_port_num), eth_config_reg);
-}
 
 static int eth_port_autoneg_supported(unsigned int eth_port_num)
 {
@@ -2345,31 +2342,6 @@ static int eth_port_link_is_up(unsigned int eth_port_num)
        return 0;
 }
 
-/*
- * ethernet_get_config_reg - Get the port configuration register
- *
- * DESCRIPTION:
- *     This function returns the configuration register value of the given
- *     ethernet port.
- *
- * INPUT:
- *     unsigned int    eth_port_num    Ethernet Port number.
- *
- * OUTPUT:
- *     None.
- *
- * RETURN:
- *     Port configuration register value.
- */
-static unsigned int ethernet_get_config_reg(unsigned int eth_port_num)
-{
-       unsigned int eth_config_reg;
-
-       eth_config_reg = mv_read(MV643XX_ETH_PORT_CONFIG_EXTEND_REG
-                                                               (eth_port_num));
-       return eth_config_reg;
-}
-
 /*
  * eth_port_read_smi_reg - Read PHY registers
  *
@@ -2528,6 +2500,9 @@ static ETH_FUNC_RET_STATUS eth_port_send(struct mv643xx_private *mp,
                return ETH_ERROR;
        }
 
+       mp->tx_ring_skbs++;
+       BUG_ON(mp->tx_ring_skbs > mp->tx_ring_size);
+
        /* Get the Tx Desc ring indexes */
        tx_desc_curr = mp->tx_curr_desc_q;
        tx_desc_used = mp->tx_used_desc_q;
@@ -2594,6 +2569,9 @@ static ETH_FUNC_RET_STATUS eth_port_send(struct mv643xx_private *mp,
        if (mp->tx_resource_err)
                return ETH_QUEUE_FULL;
 
+       mp->tx_ring_skbs++;
+       BUG_ON(mp->tx_ring_skbs > mp->tx_ring_size);
+
        /* Get the Tx Desc ring indexes */
        tx_desc_curr = mp->tx_curr_desc_q;
        tx_desc_used = mp->tx_used_desc_q;
@@ -2694,6 +2672,9 @@ static ETH_FUNC_RET_STATUS eth_tx_return_desc(struct mv643xx_private *mp,
        /* Any Tx return cancels the Tx resource error status */
        mp->tx_resource_err = 0;
 
+       BUG_ON(mp->tx_ring_skbs == 0);
+       mp->tx_ring_skbs--;
+
        return ETH_OK;
 }
 
index 7678b59c29523456454b37fc4eede501a82f96e4..bcfda5192da02ef83fbe86e9a61c6a375221984b 100644 (file)
@@ -408,10 +408,6 @@ static void eth_port_init(struct mv643xx_private *mp);
 static void eth_port_reset(unsigned int eth_port_num);
 static void eth_port_start(struct mv643xx_private *mp);
 
-static void ethernet_set_config_reg(unsigned int eth_port_num,
-                                   unsigned int value);
-static unsigned int ethernet_get_config_reg(unsigned int eth_port_num);
-
 /* Port MAC address routines */
 static void eth_port_uc_addr_set(unsigned int eth_port_num,
                                 unsigned char *p_addr);
index 6c92f09690151cbb4233fd4a56b6ec9a2e165314..73501d846588bb58126e3eb59edb9b92d567be96 100644 (file)
@@ -26,9 +26,6 @@
        Updated to EISA probing API 5/2003 by Marc Zyngier.
 */
 
-static const char *version =
-       "ne3210.c: Driver revision v0.03, 30/09/98\n";
-
 #include <linux/module.h>
 #include <linux/eisa.h>
 #include <linux/kernel.h>
@@ -197,7 +194,7 @@ static int __init ne3210_eisa_probe (struct device *device)
        ei_status.priv = phys_mem;
 
        if (ei_debug > 0)
-               printk(version);
+               printk("ne3210 loaded.\n");
 
        ei_status.reset_8390 = &ne3210_reset_8390;
        ei_status.block_input = &ne3210_block_input;
@@ -360,12 +357,12 @@ MODULE_DESCRIPTION("NE3210 EISA Ethernet driver");
 MODULE_LICENSE("GPL");
 MODULE_DEVICE_TABLE(eisa, ne3210_ids);
 
-int ne3210_init(void)
+static int ne3210_init(void)
 {
        return eisa_driver_register (&ne3210_eisa_driver);
 }
 
-void ne3210_cleanup(void)
+static void ne3210_cleanup(void)
 {
        eisa_driver_unregister (&ne3210_eisa_driver);
 }
index 6a2fe35834785cb2e17d80dfb2f01a02429e992b..14f4de1a8180289db3f05ca5395c3a93d6df0296 100644 (file)
@@ -6,7 +6,7 @@ menu "PHY device support"
 
 config PHYLIB
        tristate "PHY Device support and infrastructure"
-       depends on NET_ETHERNET
+       depends on NET_ETHERNET && (BROKEN || !ARCH_S390)
        help
          Ethernet controllers are usually attached to PHY
          devices.  This option provides infrastructure for
index 41f62c0c5fcb54c733243fe3799c81373316ae90..90630672703d1c1886e169b4e718d44c0357899b 100644 (file)
@@ -128,7 +128,7 @@ static int mdio_bus_match(struct device *dev, struct device_driver *drv)
 /* Suspend and resume.  Copied from platform_suspend and
  * platform_resume
  */
-static int mdio_bus_suspend(struct device * dev, u32 state)
+static int mdio_bus_suspend(struct device * dev, pm_message_t state)
 {
        int ret = 0;
        struct device_driver *drv = dev->driver;
@@ -170,7 +170,7 @@ int __init mdio_bus_init(void)
        return bus_register(&mdio_bus_type);
 }
 
-void __exit mdio_bus_exit(void)
+void mdio_bus_exit(void)
 {
        bus_unregister(&mdio_bus_type);
 }
index 7ca78228b104f2fa165322a47826e056b4754314..5dda043bd9d73e0195f4c39657cc7d9285e6afbb 100644 (file)
@@ -686,7 +686,7 @@ static void free_shared_mem(struct s2io_nic *nic)
 
 static int s2io_verify_pci_mode(nic_t *nic)
 {
-       XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
+       XENA_dev_config_t __iomem *bar0 = nic->bar0;
        register u64 val64 = 0;
        int     mode;
 
@@ -704,7 +704,7 @@ static int s2io_verify_pci_mode(nic_t *nic)
  */
 static int s2io_print_pci_mode(nic_t *nic)
 {
-       XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
+       XENA_dev_config_t __iomem *bar0 = nic->bar0;
        register u64 val64 = 0;
        int     mode;
        struct config_param *config = &nic->config;
@@ -1403,7 +1403,7 @@ static int init_nic(struct s2io_nic *nic)
        writeq(0xffbbffbbffbbffbbULL, &bar0->mc_pause_thresh_q4q7);
 
        /* Disable RMAC PAD STRIPPING */
-       add = (void *) &bar0->mac_cfg;
+       add = &bar0->mac_cfg;
        val64 = readq(&bar0->mac_cfg);
        val64 &= ~(MAC_CFG_RMAC_STRIP_PAD);
        writeq(RMAC_CFG_KEY(0x4C0D), &bar0->rmac_cfg_key);
@@ -1934,7 +1934,7 @@ static int start_nic(struct s2io_nic *nic)
                val64 |= 0x0000800000000000ULL;
                writeq(val64, &bar0->gpio_control);
                val64 = 0x0411040400000000ULL;
-               writeq(val64, (void __iomem *) ((u8 *) bar0 + 0x2700));
+               writeq(val64, (void __iomem *)bar0 + 0x2700);
        }
 
        /*
@@ -2395,7 +2395,7 @@ static int s2io_poll(struct net_device *dev, int *budget)
        int pkt_cnt = 0, org_pkts_to_process;
        mac_info_t *mac_control;
        struct config_param *config;
-       XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
+       XENA_dev_config_t __iomem *bar0 = nic->bar0;
        u64 val64;
        int i;
 
@@ -2831,7 +2831,7 @@ void s2io_reset(nic_t * sp)
                val64 |= 0x0000800000000000ULL;
                writeq(val64, &bar0->gpio_control);
                val64 = 0x0411040400000000ULL;
-               writeq(val64, (void __iomem *) ((u8 *) bar0 + 0x2700));
+               writeq(val64, (void __iomem *)bar0 + 0x2700);
        }
 
        /*
@@ -3234,7 +3234,7 @@ s2io_alarm_handle(unsigned long data)
 
 static void s2io_txpic_intr_handle(nic_t *sp)
 {
-       XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
+       XENA_dev_config_t __iomem *bar0 = sp->bar0;
        u64 val64;
 
        val64 = readq(&bar0->pic_int_status);
index bf3440aa6c248005dace01a7855a1aaabae1da65..92f75529eff82cf91bd0780052c29f0f6092c6bd 100644 (file)
@@ -179,14 +179,6 @@ enum sis190_register_content {
        TxInterFrameGapShift    = 24,
        TxDMAShift              = 8, /* DMA burst value (0-7) is shift this many bits */
 
-       /* StationControl */
-       _1000bpsF               = 0x1c00,
-       _1000bpsH               = 0x0c00,
-       _100bpsF                = 0x1800,
-       _100bpsH                = 0x0800,
-       _10bpsF                 = 0x1400,
-       _10bpsH                 = 0x0400,
-
        LinkStatus              = 0x02,         // unused
        FullDup                 = 0x01,         // unused
 
@@ -279,6 +271,12 @@ enum sis190_eeprom_address {
        EEPROMMACAddr   = 0x03
 };
 
+enum sis190_feature {
+       F_HAS_RGMII     = 1,
+       F_PHY_88E1111   = 2,
+       F_PHY_BCM5461   = 4
+};
+
 struct sis190_private {
        void __iomem *mmio_addr;
        struct pci_dev *pci_dev;
@@ -300,6 +298,7 @@ struct sis190_private {
        u32 msg_enable;
        struct mii_if_info mii_if;
        struct list_head first_phy;
+       u32 features;
 };
 
 struct sis190_phy {
@@ -321,24 +320,25 @@ static struct mii_chip_info {
         const char *name;
         u16 id[2];
         unsigned int type;
+       u32 feature;
 } mii_chip_table[] = {
-       { "Broadcom PHY BCM5461", { 0x0020, 0x60c0 }, LAN },
-       { "Agere PHY ET1101B",    { 0x0282, 0xf010 }, LAN },
-       { "Marvell PHY 88E1111",  { 0x0141, 0x0cc0 }, LAN },
-       { "Realtek PHY RTL8201",  { 0x0000, 0x8200 }, LAN },
+       { "Broadcom PHY BCM5461", { 0x0020, 0x60c0 }, LAN, F_PHY_BCM5461 },
+       { "Agere PHY ET1101B",    { 0x0282, 0xf010 }, LAN, 0 },
+       { "Marvell PHY 88E1111",  { 0x0141, 0x0cc0 }, LAN, F_PHY_88E1111 },
+       { "Realtek PHY RTL8201",  { 0x0000, 0x8200 }, LAN, 0 },
        { NULL, }
 };
 
 const static struct {
        const char *name;
-       u8 version;             /* depend on docs */
-       u32 RxConfigMask;       /* clear the bits supported by this chip */
 } sis_chip_info[] = {
-       { DRV_NAME, 0x00, 0xff7e1880, },
+       { "SiS 190 PCI Fast Ethernet adapter" },
+       { "SiS 191 PCI Gigabit Ethernet adapter" },
 };
 
 static struct pci_device_id sis190_pci_tbl[] __devinitdata = {
        { PCI_DEVICE(PCI_VENDOR_ID_SI, 0x0190), 0, 0, 0 },
+       { PCI_DEVICE(PCI_VENDOR_ID_SI, 0x0191), 0, 0, 1 },
        { 0, },
 };
 
@@ -360,7 +360,7 @@ MODULE_VERSION(DRV_VERSION);
 MODULE_LICENSE("GPL");
 
 static const u32 sis190_intr_mask =
-       RxQEmpty | RxQInt | TxQ1Int | TxQ0Int | RxHalt | TxHalt;
+       RxQEmpty | RxQInt | TxQ1Int | TxQ0Int | RxHalt | TxHalt | LinkChange;
 
 /*
  * Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
@@ -879,11 +879,6 @@ static void sis190_hw_start(struct net_device *dev)
 
        SIS_W32(IntrStatus, 0xffffffff);
        SIS_W32(IntrMask, 0x0);
-       /*
-        * Default is 100Mbps.
-        * A bit strange: 100Mbps is 0x1801 elsewhere -- FR 2005/06/09
-        */
-       SIS_W16(StationControl, 0x1901);
        SIS_W32(GMIIControl, 0x0);
        SIS_W32(TxMacControl, 0x60);
        SIS_W16(RxMacControl, 0x02);
@@ -923,35 +918,30 @@ static void sis190_phy_task(void * data)
                     BMSR_ANEGCOMPLETE)) {
                net_link(tp, KERN_WARNING "%s: PHY reset until link up.\n",
                         dev->name);
+               netif_carrier_off(dev);
                mdio_write(ioaddr, phy_id, MII_BMCR, val | BMCR_RESET);
                mod_timer(&tp->timer, jiffies + SIS190_PHY_TIMEOUT);
        } else {
                /* Rejoice ! */
                struct {
                        int val;
+                       u32 ctl;
                        const char *msg;
-                       u16 ctl;
                } reg31[] = {
-                       { LPA_1000XFULL | LPA_SLCT,
-                               "1000 Mbps Full Duplex",
-                               0x01 | _1000bpsF },
-                       { LPA_1000XHALF | LPA_SLCT,
-                               "1000 Mbps Half Duplex",
-                               0x01 | _1000bpsH },
-                       { LPA_100FULL,
-                               "100 Mbps Full Duplex",
-                               0x01 | _100bpsF },
-                       { LPA_100HALF,
-                               "100 Mbps Half Duplex",
-                               0x01 | _100bpsH },
-                       { LPA_10FULL,
-                               "10 Mbps Full Duplex",
-                               0x01 | _10bpsF },
-                       { LPA_10HALF,
-                               "10 Mbps Half Duplex",
-                               0x01 | _10bpsH },
-                       { 0, "unknown", 0x0000 }
-               }, *p;
+                       { LPA_1000XFULL | LPA_SLCT, 0x07000c00 | 0x00001000,
+                               "1000 Mbps Full Duplex" },
+                       { LPA_1000XHALF | LPA_SLCT, 0x07000c00,
+                               "1000 Mbps Half Duplex" },
+                       { LPA_100FULL, 0x04000800 | 0x00001000,
+                               "100 Mbps Full Duplex" },
+                       { LPA_100HALF, 0x04000800,
+                               "100 Mbps Half Duplex" },
+                       { LPA_10FULL, 0x04000400 | 0x00001000,
+                               "10 Mbps Full Duplex" },
+                       { LPA_10HALF, 0x04000400,
+                               "10 Mbps Half Duplex" },
+                       { 0, 0x04000400, "unknown" }
+               }, *p;
                u16 adv;
 
                val = mdio_read(ioaddr, phy_id, 0x1f);
@@ -964,12 +954,29 @@ static void sis190_phy_task(void * data)
 
                val &= adv;
 
-               for (p = reg31; p->ctl; p++) {
+               for (p = reg31; p->val; p++) {
                        if ((val & p->val) == p->val)
                                break;
                }
-               if (p->ctl)
-                       SIS_W16(StationControl, p->ctl);
+
+               p->ctl |= SIS_R32(StationControl) & ~0x0f001c00;
+
+               if ((tp->features & F_HAS_RGMII) &&
+                   (tp->features & F_PHY_BCM5461)) {
+                       // Set Tx Delay in RGMII mode.
+                       mdio_write(ioaddr, phy_id, 0x18, 0xf1c7);
+                       udelay(200);
+                       mdio_write(ioaddr, phy_id, 0x1c, 0x8c00);
+                       p->ctl |= 0x03000000;
+               }
+
+               SIS_W32(StationControl, p->ctl);
+
+               if (tp->features & F_HAS_RGMII) {
+                       SIS_W32(RGDelay, 0x0441);
+                       SIS_W32(RGDelay, 0x0440);
+               }
+
                net_link(tp, KERN_INFO "%s: link on %s mode.\n", dev->name,
                         p->msg);
                netif_carrier_on(dev);
@@ -1308,6 +1315,7 @@ static void sis190_init_phy(struct net_device *dev, struct sis190_private *tp,
                phy->type = (p->type == MIX) ?
                        ((mii_status & (BMSR_100FULL | BMSR_100HALF)) ?
                                LAN : HOME) : p->type;
+               tp->features |= p->feature;
        } else
                phy->type = UNKNOWN;
 
@@ -1316,6 +1324,25 @@ static void sis190_init_phy(struct net_device *dev, struct sis190_private *tp,
                  (phy->type == UNKNOWN) ? "Unknown PHY" : p->name, phy_id);
 }
 
+static void sis190_mii_probe_88e1111_fixup(struct sis190_private *tp)
+{
+       if (tp->features & F_PHY_88E1111) {
+               void __iomem *ioaddr = tp->mmio_addr;
+               int phy_id = tp->mii_if.phy_id;
+               u16 reg[2][2] = {
+                       { 0x808b, 0x0ce1 },
+                       { 0x808f, 0x0c60 }
+               }, *p;
+
+               p = (tp->features & F_HAS_RGMII) ? reg[0] : reg[1];
+
+               mdio_write(ioaddr, phy_id, 0x1b, p[0]);
+               udelay(200);
+               mdio_write(ioaddr, phy_id, 0x14, p[1]);
+               udelay(200);
+       }
+}
+
 /**
  *     sis190_mii_probe - Probe MII PHY for sis190
  *     @dev: the net device to probe for
@@ -1366,6 +1393,8 @@ static int __devinit sis190_mii_probe(struct net_device *dev)
        /* Select default PHY for mac */
        sis190_default_phy(dev);
 
+       sis190_mii_probe_88e1111_fixup(tp);
+
        mii_if->dev = dev;
        mii_if->mdio_read = __mdio_read;
        mii_if->mdio_write = __mdio_write;
@@ -1505,6 +1534,11 @@ static void sis190_tx_timeout(struct net_device *dev)
        netif_wake_queue(dev);
 }
 
+static void sis190_set_rgmii(struct sis190_private *tp, u8 reg)
+{
+       tp->features |= (reg & 0x80) ? F_HAS_RGMII : 0;
+}
+
 static int __devinit sis190_get_mac_addr_from_eeprom(struct pci_dev *pdev,
                                                     struct net_device *dev)
 {
@@ -1532,6 +1566,8 @@ static int __devinit sis190_get_mac_addr_from_eeprom(struct pci_dev *pdev,
                ((u16 *)dev->dev_addr)[0] = le16_to_cpu(w);
        }
 
+       sis190_set_rgmii(tp, sis190_read_eeprom(ioaddr, EEPROMInfo));
+
        return 0;
 }
 
@@ -1577,6 +1613,8 @@ static int __devinit sis190_get_mac_addr_from_apc(struct pci_dev *pdev,
        outb(0x12, 0x78);
        reg = inb(0x79);
 
+       sis190_set_rgmii(tp, reg);
+
        /* Restore the value to ISA Bridge */
        pci_write_config_byte(isa_bridge, 0x48, tmp8);
        pci_dev_put(isa_bridge);
@@ -1799,6 +1837,9 @@ static int __devinit sis190_init_one(struct pci_dev *pdev,
               dev->dev_addr[2], dev->dev_addr[3],
               dev->dev_addr[4], dev->dev_addr[5]);
 
+       net_probe(tp, KERN_INFO "%s: %s mode.\n", dev->name,
+                 (tp->features & F_HAS_RGMII) ? "RGMII" : "GMII");
+
        netif_carrier_off(dev);
 
        sis190_set_speed_auto(dev);
index 2608e7a3d214b280d8d1ec12a265612a477bd14a..3f67a42e8503f2f3ee243324023fe41319d63ae4 100644 (file)
@@ -948,6 +948,7 @@ static irqreturn_t gem_interrupt(int irq, void *dev_id, struct pt_regs *regs)
                u32 gem_status = readl(gp->regs + GREG_STAT);
 
                if (gem_status == 0) {
+                       netif_poll_enable(dev);
                        spin_unlock_irqrestore(&gp->lock, flags);
                        return IRQ_NONE;
                }
index 7143fd7cf3f84fd3fbf5867ee482a2e35037bd66..ff8ae5f7997001f3725a0d943f89e5937dc57f87 100644 (file)
@@ -1020,7 +1020,7 @@ struct gem {
                
        struct gem_init_block   *init_block;
        struct sk_buff          *rx_skbs[RX_RING_SIZE];
-       struct sk_buff          *tx_skbs[RX_RING_SIZE];
+       struct sk_buff          *tx_skbs[TX_RING_SIZE];
        dma_addr_t              gblock_dvma;
 
        struct pci_dev          *pdev;
index af8263a1580ea5b6fca000c5ea59b2cd3af7a4af..dc57352e5a974e8f7c64433e71cda98728ac5d0b 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/ip.h>
 #include <linux/tcp.h>
 #include <linux/workqueue.h>
+#include <linux/prefetch.h>
 
 #include <net/checksum.h>
 
@@ -66,8 +67,8 @@
 
 #define DRV_MODULE_NAME                "tg3"
 #define PFX DRV_MODULE_NAME    ": "
-#define DRV_MODULE_VERSION     "3.37"
-#define DRV_MODULE_RELDATE     "August 25, 2005"
+#define DRV_MODULE_VERSION     "3.39"
+#define DRV_MODULE_RELDATE     "September 5, 2005"
 
 #define TG3_DEF_MAC_MODE       0
 #define TG3_DEF_RX_MODE                0
                                   TG3_RX_RCB_RING_SIZE(tp))
 #define TG3_TX_RING_BYTES      (sizeof(struct tg3_tx_buffer_desc) * \
                                 TG3_TX_RING_SIZE)
-#define TX_RING_GAP(TP)        \
-       (TG3_TX_RING_SIZE - (TP)->tx_pending)
 #define TX_BUFFS_AVAIL(TP)                                             \
-       (((TP)->tx_cons <= (TP)->tx_prod) ?                             \
-         (TP)->tx_cons + (TP)->tx_pending - (TP)->tx_prod :            \
-         (TP)->tx_cons - (TP)->tx_prod - TX_RING_GAP(TP))
+       ((TP)->tx_pending -                                             \
+        (((TP)->tx_prod - (TP)->tx_cons) & (TG3_TX_RING_SIZE - 1)))
 #define NEXT_TX(N)             (((N) + 1) & (TG3_TX_RING_SIZE - 1))
 
 #define RX_PKT_BUF_SZ          (1536 + tp->rx_offset + 64)
@@ -490,7 +488,8 @@ static void tg3_disable_ints(struct tg3 *tp)
 
 static inline void tg3_cond_int(struct tg3 *tp)
 {
-       if (tp->hw_status->status & SD_STATUS_UPDATED)
+       if (!(tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) &&
+           (tp->hw_status->status & SD_STATUS_UPDATED))
                tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl | GRC_LCLCTRL_SETINT);
 }
 
@@ -2880,9 +2879,13 @@ static void tg3_tx(struct tg3 *tp)
 
        tp->tx_cons = sw_idx;
 
-       if (netif_queue_stopped(tp->dev) &&
-           (TX_BUFFS_AVAIL(tp) > TG3_TX_WAKEUP_THRESH))
-               netif_wake_queue(tp->dev);
+       if (unlikely(netif_queue_stopped(tp->dev))) {
+               spin_lock(&tp->tx_lock);
+               if (netif_queue_stopped(tp->dev) &&
+                   (TX_BUFFS_AVAIL(tp) > TG3_TX_WAKEUP_THRESH))
+                       netif_wake_queue(tp->dev);
+               spin_unlock(&tp->tx_lock);
+       }
 }
 
 /* Returns size of skb allocated or < 0 on error.
@@ -3198,9 +3201,7 @@ static int tg3_poll(struct net_device *netdev, int *budget)
 
        /* run TX completion thread */
        if (sblk->idx[0].tx_consumer != tp->tx_cons) {
-               spin_lock(&tp->tx_lock);
                tg3_tx(tp);
-               spin_unlock(&tp->tx_lock);
        }
 
        /* run RX thread, within the bounds set by NAPI.
@@ -3220,18 +3221,17 @@ static int tg3_poll(struct net_device *netdev, int *budget)
                netdev->quota -= work_done;
        }
 
-       if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)
+       if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) {
                tp->last_tag = sblk->status_tag;
-       rmb();
-       sblk->status &= ~SD_STATUS_UPDATED;
+               rmb();
+       } else
+               sblk->status &= ~SD_STATUS_UPDATED;
 
        /* if no more work, tell net stack and NIC we're done */
        done = !tg3_has_work(tp);
        if (done) {
-               spin_lock(&tp->lock);
                netif_rx_complete(netdev);
                tg3_restart_ints(tp);
-               spin_unlock(&tp->lock);
        }
 
        return (done ? 0 : 1);
@@ -3279,8 +3279,9 @@ static irqreturn_t tg3_msi(int irq, void *dev_id, struct pt_regs *regs)
 {
        struct net_device *dev = dev_id;
        struct tg3 *tp = netdev_priv(dev);
-       struct tg3_hw_status *sblk = tp->hw_status;
 
+       prefetch(tp->hw_status);
+       prefetch(&tp->rx_rcb[tp->rx_rcb_ptr]);
        /*
         * Writing any value to intr-mbox-0 clears PCI INTA# and
         * chip-internal interrupt pending events.
@@ -3289,19 +3290,9 @@ static irqreturn_t tg3_msi(int irq, void *dev_id, struct pt_regs *regs)
         * event coalescing.
         */
        tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001);
-       tp->last_tag = sblk->status_tag;
-       rmb();
-       if (tg3_irq_sync(tp))
-               goto out;
-       sblk->status &= ~SD_STATUS_UPDATED;
-       if (likely(tg3_has_work(tp)))
+       if (likely(!tg3_irq_sync(tp)))
                netif_rx_schedule(dev);         /* schedule NAPI poll */
-       else {
-               /* No work, re-enable interrupts.  */
-               tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
-                            tp->last_tag << 24);
-       }
-out:
+
        return IRQ_RETVAL(1);
 }
 
@@ -3331,9 +3322,10 @@ static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
                if (tg3_irq_sync(tp))
                        goto out;
                sblk->status &= ~SD_STATUS_UPDATED;
-               if (likely(tg3_has_work(tp)))
+               if (likely(tg3_has_work(tp))) {
+                       prefetch(&tp->rx_rcb[tp->rx_rcb_ptr]);
                        netif_rx_schedule(dev);         /* schedule NAPI poll */
-               else {
+               else {
                        /* No work, shared interrupt perhaps?  re-enable
                         * interrupts, and flush that PCI write
                         */
@@ -3359,7 +3351,7 @@ static irqreturn_t tg3_interrupt_tagged(int irq, void *dev_id, struct pt_regs *r
         * Reading the PCI State register will confirm whether the
         * interrupt is ours and will flush the status block.
         */
-       if ((sblk->status & SD_STATUS_UPDATED) ||
+       if ((sblk->status_tag != tp->last_tag) ||
            !(tr32(TG3PCI_PCISTATE) & PCISTATE_INT_NOT_ACTIVE)) {
                /*
                 * writing any value to intr-mbox-0 clears PCI INTA# and
@@ -3370,19 +3362,17 @@ static irqreturn_t tg3_interrupt_tagged(int irq, void *dev_id, struct pt_regs *r
                 */
                tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
                             0x00000001);
-               tp->last_tag = sblk->status_tag;
-               rmb();
                if (tg3_irq_sync(tp))
                        goto out;
-               sblk->status &= ~SD_STATUS_UPDATED;
-               if (likely(tg3_has_work(tp)))
-                       netif_rx_schedule(dev);         /* schedule NAPI poll */
-               else {
-                       /* no work, shared interrupt perhaps?  re-enable
-                        * interrupts, and flush that PCI write
+               if (netif_rx_schedule_prep(dev)) {
+                       prefetch(&tp->rx_rcb[tp->rx_rcb_ptr]);
+                       /* Update last_tag to mark that this status has been
+                        * seen. Because interrupt may be shared, we may be
+                        * racing with tg3_poll(), so only update last_tag
+                        * if tg3_poll() is not scheduled.
                         */
-                       tw32_mailbox_f(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
-                                      tp->last_tag << 24);
+                       tp->last_tag = sblk->status_tag;
+                       __netif_rx_schedule(dev);
                }
        } else {        /* shared interrupt */
                handled = 0;
@@ -3716,8 +3706,11 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
        tw32_tx_mbox((MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW), entry);
 
        tp->tx_prod = entry;
-       if (TX_BUFFS_AVAIL(tp) <= (MAX_SKB_FRAGS + 1))
+       if (TX_BUFFS_AVAIL(tp) <= (MAX_SKB_FRAGS + 1)) {
                netif_stop_queue(dev);
+               if (TX_BUFFS_AVAIL(tp) > TG3_TX_WAKEUP_THRESH)
+                       netif_wake_queue(tp->dev);
+       }
 
 out_unlock:
        mmiowb();
@@ -5960,7 +5953,7 @@ static int tg3_reset_hw(struct tg3 *tp)
        tw32(MAC_LED_CTRL, tp->led_ctrl);
 
        tw32(MAC_MI_STAT, MAC_MI_STAT_LNKSTAT_ATTN_ENAB);
-       if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) {
+       if (tp->tg3_flags2 & TG3_FLG2_ANY_SERDES) {
                tw32_f(MAC_RX_MODE, RX_MODE_RESET);
                udelay(10);
        }
@@ -6242,6 +6235,7 @@ static int tg3_test_interrupt(struct tg3 *tp)
        if (err)
                return err;
 
+       tp->hw_status->status &= ~SD_STATUS_UPDATED;
        tg3_enable_ints(tp);
 
        tw32_f(HOSTCC_MODE, tp->coalesce_mode | HOSTCC_MODE_ENABLE |
@@ -7557,6 +7551,38 @@ static void tg3_get_strings (struct net_device *dev, u32 stringset, u8 *buf)
        }
 }
 
+static int tg3_phys_id(struct net_device *dev, u32 data)
+{
+       struct tg3 *tp = netdev_priv(dev);
+       int i;
+
+       if (!netif_running(tp->dev))
+               return -EAGAIN;
+
+       if (data == 0)
+               data = 2;
+
+       for (i = 0; i < (data * 2); i++) {
+               if ((i % 2) == 0)
+                       tw32(MAC_LED_CTRL, LED_CTRL_LNKLED_OVERRIDE |
+                                          LED_CTRL_1000MBPS_ON |
+                                          LED_CTRL_100MBPS_ON |
+                                          LED_CTRL_10MBPS_ON |
+                                          LED_CTRL_TRAFFIC_OVERRIDE |
+                                          LED_CTRL_TRAFFIC_BLINK |
+                                          LED_CTRL_TRAFFIC_LED);
+       
+               else
+                       tw32(MAC_LED_CTRL, LED_CTRL_LNKLED_OVERRIDE |
+                                          LED_CTRL_TRAFFIC_OVERRIDE);
+
+               if (msleep_interruptible(500))
+                       break;
+       }
+       tw32(MAC_LED_CTRL, tp->led_ctrl);
+       return 0;
+}
+
 static void tg3_get_ethtool_stats (struct net_device *dev,
                                   struct ethtool_stats *estats, u64 *tmp_stats)
 {
@@ -7616,7 +7642,7 @@ static int tg3_test_link(struct tg3 *tp)
        if (!netif_running(tp->dev))
                return -ENODEV;
 
-       if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES)
+       if (tp->tg3_flags2 & TG3_FLG2_ANY_SERDES)
                max = TG3_SERDES_TIMEOUT_SEC;
        else
                max = TG3_COPPER_TIMEOUT_SEC;
@@ -7901,9 +7927,12 @@ static int tg3_test_memory(struct tg3 *tp)
        return err;
 }
 
-static int tg3_test_loopback(struct tg3 *tp)
+#define TG3_MAC_LOOPBACK       0
+#define TG3_PHY_LOOPBACK       1
+
+static int tg3_run_loopback(struct tg3 *tp, int loopback_mode)
 {
-       u32 mac_mode, send_idx, rx_start_idx, rx_idx, tx_idx, opaque_key;
+       u32 mac_mode, rx_start_idx, rx_idx, tx_idx, opaque_key;
        u32 desc_idx;
        struct sk_buff *skb, *rx_skb;
        u8 *tx_data;
@@ -7911,18 +7940,26 @@ static int tg3_test_loopback(struct tg3 *tp)
        int num_pkts, tx_len, rx_len, i, err;
        struct tg3_rx_buffer_desc *desc;
 
-       if (!netif_running(tp->dev))
-               return -ENODEV;
+       if (loopback_mode == TG3_MAC_LOOPBACK) {
+               mac_mode = (tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK) |
+                          MAC_MODE_PORT_INT_LPBACK | MAC_MODE_LINK_POLARITY |
+                          MAC_MODE_PORT_MODE_GMII;
+               tw32(MAC_MODE, mac_mode);
+       } else if (loopback_mode == TG3_PHY_LOOPBACK) {
+               mac_mode = (tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK) |
+                          MAC_MODE_LINK_POLARITY | MAC_MODE_PORT_MODE_GMII;
+               if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401)
+                       mac_mode &= ~MAC_MODE_LINK_POLARITY;
+               tw32(MAC_MODE, mac_mode);
+
+               tg3_writephy(tp, MII_BMCR, BMCR_LOOPBACK | BMCR_FULLDPLX |
+                                          BMCR_SPEED1000);
+       }
+       else
+               return -EINVAL;
 
        err = -EIO;
 
-       tg3_reset_hw(tp);
-
-       mac_mode = (tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK) |
-                  MAC_MODE_PORT_INT_LPBACK | MAC_MODE_LINK_POLARITY |
-                  MAC_MODE_PORT_MODE_GMII;
-       tw32(MAC_MODE, mac_mode);
-
        tx_len = 1514;
        skb = dev_alloc_skb(tx_len);
        tx_data = skb_put(skb, tx_len);
@@ -7943,15 +7980,15 @@ static int tg3_test_loopback(struct tg3 *tp)
 
        rx_start_idx = tp->hw_status->idx[0].rx_producer;
 
-       send_idx = 0;
        num_pkts = 0;
 
-       tg3_set_txd(tp, send_idx, map, tx_len, 0, 1);
+       tg3_set_txd(tp, tp->tx_prod, map, tx_len, 0, 1);
 
-       send_idx++;
+       tp->tx_prod++;
        num_pkts++;
 
-       tw32_tx_mbox(MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW, send_idx);
+       tw32_tx_mbox(MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW,
+                    tp->tx_prod);
        tr32_mailbox(MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW);
 
        udelay(10);
@@ -7964,7 +8001,7 @@ static int tg3_test_loopback(struct tg3 *tp)
 
                tx_idx = tp->hw_status->idx[0].tx_consumer;
                rx_idx = tp->hw_status->idx[0].rx_producer;
-               if ((tx_idx == send_idx) &&
+               if ((tx_idx == tp->tx_prod) &&
                    (rx_idx == (rx_start_idx + num_pkts)))
                        break;
        }
@@ -7972,7 +8009,7 @@ static int tg3_test_loopback(struct tg3 *tp)
        pci_unmap_single(tp->pdev, map, tx_len, PCI_DMA_TODEVICE);
        dev_kfree_skb(skb);
 
-       if (tx_idx != send_idx)
+       if (tx_idx != tp->tx_prod)
                goto out;
 
        if (rx_idx != rx_start_idx + num_pkts)
@@ -8008,6 +8045,30 @@ out:
        return err;
 }
 
+#define TG3_MAC_LOOPBACK_FAILED                1
+#define TG3_PHY_LOOPBACK_FAILED                2
+#define TG3_LOOPBACK_FAILED            (TG3_MAC_LOOPBACK_FAILED |      \
+                                        TG3_PHY_LOOPBACK_FAILED)
+
+static int tg3_test_loopback(struct tg3 *tp)
+{
+       int err = 0;
+
+       if (!netif_running(tp->dev))
+               return TG3_LOOPBACK_FAILED;
+
+       tg3_reset_hw(tp);
+
+       if (tg3_run_loopback(tp, TG3_MAC_LOOPBACK))
+               err |= TG3_MAC_LOOPBACK_FAILED;
+       if (!(tp->tg3_flags2 & TG3_FLG2_PHY_SERDES)) {
+               if (tg3_run_loopback(tp, TG3_PHY_LOOPBACK))
+                       err |= TG3_PHY_LOOPBACK_FAILED;
+       }
+
+       return err;
+}
+
 static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest,
                          u64 *data)
 {
@@ -8048,10 +8109,8 @@ static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest,
                        etest->flags |= ETH_TEST_FL_FAILED;
                        data[3] = 1;
                }
-               if (tg3_test_loopback(tp) != 0) {
+               if ((data[4] = tg3_test_loopback(tp)) != 0)
                        etest->flags |= ETH_TEST_FL_FAILED;
-                       data[4] = 1;
-               }
 
                tg3_full_unlock(tp);
 
@@ -8239,6 +8298,7 @@ static struct ethtool_ops tg3_ethtool_ops = {
        .self_test_count        = tg3_get_test_count,
        .self_test              = tg3_self_test,
        .get_strings            = tg3_get_strings,
+       .phys_id                = tg3_phys_id,
        .get_stats_count        = tg3_get_stats_count,
        .get_ethtool_stats      = tg3_get_ethtool_stats,
        .get_coalesce           = tg3_get_coalesce,
@@ -8303,7 +8363,8 @@ static void __devinit tg3_get_nvram_info(struct tg3 *tp)
                tw32(NVRAM_CFG1, nvcfg1);
        }
 
-       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) {
+       if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) ||
+           (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780)) {
                switch (nvcfg1 & NVRAM_CFG1_VENDOR_MASK) {
                        case FLASH_VENDOR_ATMEL_FLASH_BUFFERED:
                                tp->nvram_jedecnum = JEDEC_ATMEL;
@@ -8717,8 +8778,9 @@ static int tg3_nvram_write_block_buffered(struct tg3 *tp, u32 offset, u32 len,
                if (i == (len - 4))
                        nvram_cmd |= NVRAM_CMD_LAST;
 
-               if ((tp->nvram_jedecnum == JEDEC_ST) &&
-                       (nvram_cmd & NVRAM_CMD_FIRST)) {
+               if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752) &&
+                   (tp->nvram_jedecnum == JEDEC_ST) &&
+                   (nvram_cmd & NVRAM_CMD_FIRST)) {
 
                        if ((ret = tg3_nvram_exec_cmd(tp,
                                NVRAM_CMD_WREN | NVRAM_CMD_GO |
index fc353e348f9aeaab909b216d8301706d014178af..a22d00198e4d6b5cde5b46ebff6cb1e569e6f68e 100644 (file)
@@ -1934,7 +1934,7 @@ static int __init de_init_one (struct pci_dev *pdev,
        struct de_private *de;
        int rc;
        void __iomem *regs;
-       long pciaddr;
+       unsigned long pciaddr;
        static int board_idx = -1;
 
        board_idx++;
index 05da5bea564c9481846b9109aac24712b6f3ed3c..6266a9a7e6e3a36430b33039af682f3dbdd15607 100644 (file)
@@ -238,6 +238,7 @@ static struct pci_device_id tulip_pci_tbl[] = {
        { 0x17B3, 0xAB08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
        { 0x10b7, 0x9300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET }, /* 3Com 3CSOHO100B-TX */
        { 0x14ea, 0xab08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET }, /* Planex FNW-3602-TX */
+       { 0x1414, 0x0002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
        { } /* terminate list */
 };
 MODULE_DEVICE_TABLE(pci, tulip_pci_tbl);
index 5ae22b7bc5cab0896004e53370c11891660b48db..1a43163362569f9c08458c079d5c78257dcce08b 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/timer.h>
-#include <linux/ptrace.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
 #include <linux/slab.h>
@@ -34,6 +33,7 @@
 #include <linux/skbuff.h>
 #include <linux/delay.h>
 #include <linux/spinlock.h>
+#include <linux/dma-mapping.h>
 
 #include <asm/processor.h>
 #include <asm/bitops.h>
index effab0b9adca176b6b6a3b9fd553b256d9f1c850..50b8c6754b1ef333a225406a7465e9fdd2985dd6 100644 (file)
@@ -18,6 +18,9 @@
 /*
  *  Changes:
  *
+ *  Mike Kershaw <dragorn@kismetwireless.net> 2005/08/14
+ *    Add TUNSETLINK ioctl to set the link encapsulation
+ *
  *  Mark Smith <markzzzsmith@yahoo.com.au>
  *   Use random_ether_addr() for tap MAC address.
  *
@@ -612,6 +615,18 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
                DBG(KERN_INFO "%s: owner set to %d\n", tun->dev->name, tun->owner);
                break;
 
+       case TUNSETLINK:
+               /* Only allow setting the type when the interface is down */
+               if (tun->dev->flags & IFF_UP) {
+                       DBG(KERN_INFO "%s: Linktype set failed because interface is up\n",
+                               tun->dev->name);
+                       return -EBUSY;
+               } else {
+                       tun->dev->type = (int) arg;
+                       DBG(KERN_INFO "%s: linktype set to %d\n", tun->dev->name, tun->dev->type);
+               }
+               break;
+
 #ifdef TUN_DEBUG
        case TUNSETDEBUG:
                tun->debug = arg;
index ec3f75a030d2073248791d443d9f432027dd35bf..00a07f32a81e292c056a8a6bea9d973d747c4076 100644 (file)
@@ -137,6 +137,110 @@ config PCMCIA_RAYCS
 comment "Wireless 802.11b ISA/PCI cards support"
        depends on NET_RADIO && (ISA || PCI || PPC_PMAC || PCMCIA)
 
+config IPW2100
+       tristate "Intel PRO/Wireless 2100 Network Connection"
+       depends on NET_RADIO && PCI && IEEE80211
+       select FW_LOADER
+       ---help---
+          A driver for the Intel PRO/Wireless 2100 Network 
+         Connection 802.11b wireless network adapter.
+
+          See <file:Documentation/networking/README.ipw2100> for information on
+          the capabilities currently enabled in this driver and for tips
+          for debugging issues and problems.
+
+         In order to use this driver, you will need a firmware image for it.
+          You can obtain the firmware from
+         <http://ipw2100.sf.net/>.  Once you have the firmware image, you 
+         will need to place it in /etc/firmware.
+
+          You will also very likely need the Wireless Tools in order to
+          configure your card:
+
+          <http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>.
+          If you want to compile the driver as a module ( = code which can be
+          inserted in and remvoed from the running kernel whenever you want),
+          say M here and read <file:Documentation/modules.txt>.  The module
+          will be called ipw2100.ko.
+       
+config IPW2100_MONITOR
+        bool "Enable promiscuous mode"
+        depends on IPW2100
+        ---help---
+         Enables promiscuous/monitor mode support for the ipw2100 driver.
+         With this feature compiled into the driver, you can switch to 
+         promiscuous mode via the Wireless Tool's Monitor mode.  While in this
+         mode, no packets can be sent.
+
+config IPW_DEBUG
+       bool "Enable full debugging output in IPW2100 module."
+       depends on IPW2100
+       ---help---
+         This option will enable debug tracing output for the IPW2100.  
+
+         This will result in the kernel module being ~60k larger.  You can 
+         control which debug output is sent to the kernel log by setting the 
+         value in 
+
+         /sys/bus/pci/drivers/ipw2100/debug_level
+
+         This entry will only exist if this option is enabled.
+
+         If you are not trying to debug or develop the IPW2100 driver, you 
+         most likely want to say N here.
+
+config IPW2200
+       tristate "Intel PRO/Wireless 2200BG and 2915ABG Network Connection"
+       depends on IEEE80211 && PCI
+       select FW_LOADER
+       ---help---
+          A driver for the Intel PRO/Wireless 2200BG and 2915ABG Network
+         Connection adapters. 
+
+          See <file:Documentation/networking/README.ipw2200> for 
+         information on the capabilities currently enabled in this 
+         driver and for tips for debugging issues and problems.
+
+         In order to use this driver, you will need a firmware image for it.
+          You can obtain the firmware from
+         <http://ipw2200.sf.net/>.  See the above referenced README.ipw2200 
+         for information on where to install the firmare images.
+
+          You will also very likely need the Wireless Tools in order to
+          configure your card:
+
+          <http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>.
+          If you want to compile the driver as a module ( = code which can be
+          inserted in and remvoed from the running kernel whenever you want),
+          say M here and read <file:Documentation/modules.txt>.  The module
+          will be called ipw2200.ko.
+
+config IPW_DEBUG
+       bool "Enable full debugging output in IPW2200 module."
+       depends on IPW2200
+       ---help---
+         This option will enable debug tracing output for the IPW2200.  
+
+         This will result in the kernel module being ~100k larger.  You can 
+         control which debug output is sent to the kernel log by setting the 
+         value in 
+
+         /sys/bus/pci/drivers/ipw2200/debug_level
+
+         This entry will only exist if this option is enabled.
+
+         To set a value, simply echo an 8-byte hex value to the same file:
+
+         % echo 0x00000FFO > /sys/bus/pci/drivers/ipw2200/debug_level
+
+         You can find the list of debug mask values in 
+         drivers/net/wireless/ipw2200.h
+
+         If you are not trying to debug or develop the IPW2200 driver, you 
+         most likely want to say N here.
+
 config AIRO
        tristate "Cisco/Aironet 34X/35X/4500/4800 ISA and PCI cards"
        depends on NET_RADIO && ISA && (PCI || BROKEN)
@@ -185,8 +289,8 @@ config APPLE_AIRPORT
          a non-standard interface
 
 config PLX_HERMES
-       tristate "Hermes in PLX9052 based PCI adaptor support (Netgear MA301 etc.) (EXPERIMENTAL)"
-       depends on PCI && HERMES && EXPERIMENTAL
+       tristate "Hermes in PLX9052 based PCI adaptor support (Netgear MA301 etc.)"
+       depends on PCI && HERMES
        help
          Enable support for PCMCIA cards supported by the "Hermes" (aka
          orinoco) driver when used in PLX9052 based PCI adaptors.  These
@@ -195,12 +299,9 @@ config PLX_HERMES
          802.11b PCMCIA cards can be used in desktop machines.  The Netgear
          MA301 is such an adaptor.
 
-         Support for these adaptors is so far still incomplete and buggy.
-         You have been warned.
-
 config TMD_HERMES
-       tristate "Hermes in TMD7160 based PCI adaptor support (EXPERIMENTAL)"
-       depends on PCI && HERMES && EXPERIMENTAL
+       tristate "Hermes in TMD7160 based PCI adaptor support"
+       depends on PCI && HERMES
        help
          Enable support for PCMCIA cards supported by the "Hermes" (aka
          orinoco) driver when used in TMD7160 based PCI adaptors.  These
@@ -208,12 +309,18 @@ config TMD_HERMES
          PCI <-> PCMCIA bridge.  Several vendors sell such adaptors so that
          802.11b PCMCIA cards can be used in desktop machines.
 
-         Support for these adaptors is so far still incomplete and buggy.
-         You have been warned.
+config NORTEL_HERMES
+       tristate "Nortel emobility PCI adaptor support"
+       depends on PCI && HERMES
+       help
+         Enable support for PCMCIA cards supported by the "Hermes" (aka
+         orinoco) driver when used in Nortel emobility PCI adaptors.  These
+         adaptors are not full PCMCIA controllers, but act as a more limited
+         PCI <-> PCMCIA bridge.
 
 config PCI_HERMES
-       tristate "Prism 2.5 PCI 802.11b adaptor support (EXPERIMENTAL)"
-       depends on PCI && HERMES && EXPERIMENTAL
+       tristate "Prism 2.5 PCI 802.11b adaptor support"
+       depends on PCI && HERMES
        help
          Enable support for PCI and mini-PCI 802.11b wireless NICs based on
          the Prism 2.5 chipset.  These are true PCI cards, not the 802.11b
@@ -268,6 +375,19 @@ config PCMCIA_HERMES
          configure your card and that /etc/pcmcia/wireless.opts works:
          <http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>.
 
+config PCMCIA_SPECTRUM
+       tristate "Symbol Spectrum24 Trilogy PCMCIA card support"
+       depends on NET_RADIO && PCMCIA && HERMES
+       ---help---
+
+         This is a driver for 802.11b cards using RAM-loadable Symbol
+         firmware, such as Symbol Wireless Networker LA4100, CompactFlash
+         cards by Socket Communications and Intel PRO/Wireless 2011B.
+
+         This driver requires firmware download on startup.  Utilities
+         for downloading Symbol firmware are available at
+         <http://sourceforge.net/projects/orinoco/>
+
 config AIRO_CS
        tristate "Cisco/Aironet 34X/35X/4500/4800 PCMCIA cards"
        depends on NET_RADIO && PCMCIA && (BROKEN || !M32R)
@@ -355,6 +475,8 @@ config PRISM54
          say M here and read <file:Documentation/modules.txt>.  The module
          will be called prism54.ko.
 
+source "drivers/net/wireless/hostap/Kconfig"
+
 # yes, this works even when no drivers are selected
 config NET_WIRELESS
        bool
index 2b87841322cc8f7d27fac0a36bdb063d204d7420..3a6f7ba326cab35fb735f407b79e31a97bcc2ac4 100644 (file)
@@ -2,6 +2,10 @@
 # Makefile for the Linux Wireless network device drivers.
 #
 
+obj-$(CONFIG_IPW2100) += ipw2100.o
+
+obj-$(CONFIG_IPW2200) += ipw2200.o
+
 obj-$(CONFIG_STRIP) += strip.o
 obj-$(CONFIG_ARLAN) += arlan.o 
 
@@ -18,6 +22,8 @@ obj-$(CONFIG_APPLE_AIRPORT)   += airport.o
 obj-$(CONFIG_PLX_HERMES)       += orinoco_plx.o
 obj-$(CONFIG_PCI_HERMES)       += orinoco_pci.o
 obj-$(CONFIG_TMD_HERMES)       += orinoco_tmd.o
+obj-$(CONFIG_NORTEL_HERMES)    += orinoco_nortel.o
+obj-$(CONFIG_PCMCIA_SPECTRUM)  += spectrum_cs.o
 
 obj-$(CONFIG_AIRO)             += airo.o
 obj-$(CONFIG_AIRO_CS)          += airo_cs.o airo.o
@@ -28,6 +34,8 @@ obj-$(CONFIG_PCMCIA_ATMEL)      += atmel_cs.o
 
 obj-$(CONFIG_PRISM54)          += prism54/
 
+obj-$(CONFIG_HOSTAP)           += hostap/
+
 # 16-bit wireless PCMCIA client drivers
 obj-$(CONFIG_PCMCIA_RAYCS)     += ray_cs.o
 obj-$(CONFIG_PCMCIA_WL3501)    += wl3501_cs.o
index df20adcd0730aa1cf5fb899d7b2017209782fb6c..dbcb5a8a219401aeabaafad5387cc7114b156ad1 100644 (file)
@@ -1040,7 +1040,7 @@ typedef struct {
        u16 status;
 } WifiCtlHdr;
 
-WifiCtlHdr wifictlhdr8023 = {
+static WifiCtlHdr wifictlhdr8023 = {
        .ctlhdr = {
                .ctl    = HOST_DONT_RLSE,
        }
@@ -1111,13 +1111,13 @@ static int airo_thread(void *data);
 static void timer_func( struct net_device *dev );
 static int airo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 #ifdef WIRELESS_EXT
-struct iw_statistics *airo_get_wireless_stats (struct net_device *dev);
+static struct iw_statistics *airo_get_wireless_stats (struct net_device *dev);
 static void airo_read_wireless_stats (struct airo_info *local);
 #endif /* WIRELESS_EXT */
 #ifdef CISCO_EXT
 static int readrids(struct net_device *dev, aironet_ioctl *comp);
 static int writerids(struct net_device *dev, aironet_ioctl *comp);
-int flashcard(struct net_device *dev, aironet_ioctl *comp);
+static int flashcard(struct net_device *dev, aironet_ioctl *comp);
 #endif /* CISCO_EXT */
 #ifdef MICSUPPORT
 static void micinit(struct airo_info *ai);
@@ -1226,6 +1226,12 @@ static int setup_proc_entry( struct net_device *dev,
 static int takedown_proc_entry( struct net_device *dev,
                                struct airo_info *apriv );
 
+static int cmdreset(struct airo_info *ai);
+static int setflashmode (struct airo_info *ai);
+static int flashgchar(struct airo_info *ai,int matchbyte,int dwelltime);
+static int flashputbuf(struct airo_info *ai);
+static int flashrestart(struct airo_info *ai,struct net_device *dev);
+
 #ifdef MICSUPPORT
 /***********************************************************************
  *                              MIC ROUTINES                           *
@@ -1234,10 +1240,11 @@ static int takedown_proc_entry( struct net_device *dev,
 
 static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSeq);
 static void MoveWindow(miccntx *context, u32 micSeq);
-void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct crypto_tfm *);
-void emmh32_init(emmh32_context *context);
-void emmh32_update(emmh32_context *context, u8 *pOctets, int len);
-void emmh32_final(emmh32_context *context, u8 digest[4]);
+static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct crypto_tfm *);
+static void emmh32_init(emmh32_context *context);
+static void emmh32_update(emmh32_context *context, u8 *pOctets, int len);
+static void emmh32_final(emmh32_context *context, u8 digest[4]);
+static int flashpchar(struct airo_info *ai,int byte,int dwelltime);
 
 /* micinit - Initialize mic seed */
 
@@ -1301,7 +1308,7 @@ static int micsetup(struct airo_info *ai) {
        int i;
 
        if (ai->tfm == NULL)
-               ai->tfm = crypto_alloc_tfm("aes", 0);
+               ai->tfm = crypto_alloc_tfm("aes", CRYPTO_TFM_REQ_MAY_SLEEP);
 
         if (ai->tfm == NULL) {
                 printk(KERN_ERR "airo: failed to load transform for AES\n");
@@ -1315,7 +1322,7 @@ static int micsetup(struct airo_info *ai) {
        return SUCCESS;
 }
 
-char micsnap[]= {0xAA,0xAA,0x03,0x00,0x40,0x96,0x00,0x02};
+static char micsnap[] = {0xAA,0xAA,0x03,0x00,0x40,0x96,0x00,0x02};
 
 /*===========================================================================
  * Description: Mic a packet
@@ -1570,7 +1577,7 @@ static void MoveWindow(miccntx *context, u32 micSeq)
 static unsigned char aes_counter[16];
 
 /* expand the key to fill the MMH coefficient array */
-void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct crypto_tfm *tfm)
+static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct crypto_tfm *tfm)
 {
   /* take the keying material, expand if necessary, truncate at 16-bytes */
   /* run through AES counter mode to generate context->coeff[] */
@@ -1602,7 +1609,7 @@ void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct crypto
 }
 
 /* prepare for calculation of a new mic */
-void emmh32_init(emmh32_context *context)
+static void emmh32_init(emmh32_context *context)
 {
        /* prepare for new mic calculation */
        context->accum = 0;
@@ -1610,7 +1617,7 @@ void emmh32_init(emmh32_context *context)
 }
 
 /* add some bytes to the mic calculation */
-void emmh32_update(emmh32_context *context, u8 *pOctets, int len)
+static void emmh32_update(emmh32_context *context, u8 *pOctets, int len)
 {
        int     coeff_position, byte_position;
   
@@ -1652,7 +1659,7 @@ void emmh32_update(emmh32_context *context, u8 *pOctets, int len)
 static u32 mask32[4] = { 0x00000000L, 0xFF000000L, 0xFFFF0000L, 0xFFFFFF00L };
 
 /* calculate the mic */
-void emmh32_final(emmh32_context *context, u8 digest[4])
+static void emmh32_final(emmh32_context *context, u8 digest[4])
 {
        int     coeff_position, byte_position;
        u32     val;
@@ -2232,7 +2239,7 @@ static void airo_read_stats(struct airo_info *ai) {
        u32 *vals = stats_rid.vals;
 
        clear_bit(JOB_STATS, &ai->flags);
-       if (ai->power) {
+       if (ai->power.event) {
                up(&ai->sem);
                return;
        }
@@ -2255,7 +2262,7 @@ static void airo_read_stats(struct airo_info *ai) {
        ai->stats.rx_fifo_errors = vals[0];
 }
 
-struct net_device_stats *airo_get_stats(struct net_device *dev)
+static struct net_device_stats *airo_get_stats(struct net_device *dev)
 {
        struct airo_info *local =  dev->priv;
 
@@ -2403,8 +2410,7 @@ void stop_airo_card( struct net_device *dev, int freeres )
                }
         }
 #ifdef MICSUPPORT
-       if (ai->tfm)
-               crypto_free_tfm(ai->tfm);
+       crypto_free_tfm(ai->tfm);
 #endif
        del_airo_dev( dev );
        free_netdev( dev );
@@ -2414,7 +2420,7 @@ EXPORT_SYMBOL(stop_airo_card);
 
 static int add_airo_dev( struct net_device *dev );
 
-int wll_header_parse(struct sk_buff *skb, unsigned char *haddr)
+static int wll_header_parse(struct sk_buff *skb, unsigned char *haddr)
 {
        memcpy(haddr, skb->mac.raw + 10, ETH_ALEN);
        return ETH_ALEN;
@@ -2681,7 +2687,7 @@ static struct net_device *init_wifidev(struct airo_info *ai,
        return dev;
 }
 
-int reset_card( struct net_device *dev , int lock) {
+static int reset_card( struct net_device *dev , int lock) {
        struct airo_info *ai = dev->priv;
 
        if (lock && down_interruptible(&ai->sem))
@@ -2696,9 +2702,9 @@ int reset_card( struct net_device *dev , int lock) {
        return 0;
 }
 
-struct net_device *_init_airo_card( unsigned short irq, int port,
-                                   int is_pcmcia, struct pci_dev *pci,
-                                   struct device *dmdev )
+static struct net_device *_init_airo_card( unsigned short irq, int port,
+                                          int is_pcmcia, struct pci_dev *pci,
+                                          struct device *dmdev )
 {
        struct net_device *dev;
        struct airo_info *ai;
@@ -2962,7 +2968,7 @@ static int airo_thread(void *data) {
                        break;
                }
 
-               if (ai->power || test_bit(FLAG_FLASHING, &ai->flags)) {
+               if (ai->power.event || test_bit(FLAG_FLASHING, &ai->flags)) {
                        up(&ai->sem);
                        continue;
                }
@@ -5514,7 +5520,7 @@ static int airo_pci_resume(struct pci_dev *pdev)
        pci_restore_state(pdev);
        pci_enable_wake(pdev, pci_choose_state(pdev, ai->power), 0);
 
-       if (ai->power > 1) {
+       if (ai->power.event > 1) {
                reset_card(dev, 0);
                mpi_init_descriptors(ai);
                setup_card(ai, dev->dev_addr, 0);
@@ -7116,7 +7122,7 @@ static int airo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
        int rc = 0;
        struct airo_info *ai = (struct airo_info *)dev->priv;
 
-       if (ai->power)
+       if (ai->power.event)
                return 0;
 
        switch (cmd) {
@@ -7195,7 +7201,7 @@ static void airo_read_wireless_stats(struct airo_info *local)
 
        /* Get stats out of the card */
        clear_bit(JOB_WSTATS, &local->flags);
-       if (local->power) {
+       if (local->power.event) {
                up(&local->sem);
                return;
        }
@@ -7235,7 +7241,7 @@ static void airo_read_wireless_stats(struct airo_info *local)
        local->wstats.miss.beacon = vals[34];
 }
 
-struct iw_statistics *airo_get_wireless_stats(struct net_device *dev)
+static struct iw_statistics *airo_get_wireless_stats(struct net_device *dev)
 {
        struct airo_info *local =  dev->priv;
 
@@ -7450,14 +7456,8 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
  * Flash command switch table
  */
 
-int flashcard(struct net_device *dev, aironet_ioctl *comp) {
+static int flashcard(struct net_device *dev, aironet_ioctl *comp) {
        int z;
-       int cmdreset(struct airo_info *);
-       int setflashmode(struct airo_info *);
-       int flashgchar(struct airo_info *,int,int);
-       int flashpchar(struct airo_info *,int,int);
-       int flashputbuf(struct airo_info *);
-       int flashrestart(struct airo_info *,struct net_device *);
 
        /* Only super-user can modify flash */
        if (!capable(CAP_NET_ADMIN))
@@ -7515,7 +7515,7 @@ int flashcard(struct net_device *dev, aironet_ioctl *comp) {
  * card.
  */
 
-int cmdreset(struct airo_info *ai) {
+static int cmdreset(struct airo_info *ai) {
        disable_MAC(ai, 1);
 
        if(!waitbusy (ai)){
@@ -7539,7 +7539,7 @@ int cmdreset(struct airo_info *ai) {
  * mode
  */
 
-int setflashmode (struct airo_info *ai) {
+static int setflashmode (struct airo_info *ai) {
        set_bit (FLAG_FLASHING, &ai->flags);
 
        OUT4500(ai, SWS0, FLASH_COMMAND);
@@ -7566,7 +7566,7 @@ int setflashmode (struct airo_info *ai) {
  * x 50us for  echo .
  */
 
-int flashpchar(struct airo_info *ai,int byte,int dwelltime) {
+static int flashpchar(struct airo_info *ai,int byte,int dwelltime) {
        int echo;
        int waittime;
 
@@ -7606,7 +7606,7 @@ int flashpchar(struct airo_info *ai,int byte,int dwelltime) {
  * Get a character from the card matching matchbyte
  * Step 3)
  */
-int flashgchar(struct airo_info *ai,int matchbyte,int dwelltime){
+static int flashgchar(struct airo_info *ai,int matchbyte,int dwelltime){
        int           rchar;
        unsigned char rbyte=0;
 
@@ -7637,7 +7637,7 @@ int flashgchar(struct airo_info *ai,int matchbyte,int dwelltime){
  * send to the card
  */
 
-int flashputbuf(struct airo_info *ai){
+static int flashputbuf(struct airo_info *ai){
        int            nwords;
 
        /* Write stuff */
@@ -7659,7 +7659,7 @@ int flashputbuf(struct airo_info *ai){
 /*
  *
  */
-int flashrestart(struct airo_info *ai,struct net_device *dev){
+static int flashrestart(struct airo_info *ai,struct net_device *dev){
        int    i,status;
 
        ssleep(1);                      /* Added 12/7/00 */
index 18a7d38d2a1301f833dd36eb4ed587d73390e109..f48a6e7292245298e3b73d7c31d7c1cd84b9b37c 100644 (file)
@@ -68,7 +68,7 @@
 #include <linux/device.h>
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
-#include "ieee802_11.h"
+#include <net/ieee80211.h>
 #include "atmel.h"
 
 #define DRIVER_MAJOR 0
@@ -618,12 +618,12 @@ static int atmel_lock_mac(struct atmel_private *priv);
 static void atmel_wmem32(struct atmel_private *priv, u16 pos, u32 data);
 static void atmel_command_irq(struct atmel_private *priv);
 static int atmel_validate_channel(struct atmel_private *priv, int channel);
-static void atmel_management_frame(struct atmel_private *priv, struct ieee802_11_hdr *header, 
+static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_hdr *header, 
                                   u16 frame_len, u8 rssi);
 static void atmel_management_timer(u_long a);
 static void atmel_send_command(struct atmel_private *priv, int command, void *cmd, int cmd_size);
 static int atmel_send_command_wait(struct atmel_private *priv, int command, void *cmd, int cmd_size);
-static void atmel_transmit_management_frame(struct atmel_private *priv, struct ieee802_11_hdr *header,
+static void atmel_transmit_management_frame(struct atmel_private *priv, struct ieee80211_hdr *header,
                                            u8 *body, int body_len);
 
 static u8 atmel_get_mib8(struct atmel_private *priv, u8 type, u8 index);
@@ -827,7 +827,7 @@ static void tx_update_descriptor(struct atmel_private *priv, int is_bcast, u16 l
 static int start_tx (struct sk_buff *skb, struct net_device *dev)
 {
        struct atmel_private *priv = netdev_priv(dev);
-       struct ieee802_11_hdr header;
+       struct ieee80211_hdr header;
        unsigned long flags;
        u16 buff, frame_ctl, len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
        u8 SNAP_RFC1024[6] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
@@ -863,17 +863,17 @@ static int start_tx (struct sk_buff *skb, struct net_device *dev)
                return 1;
        }
        
-       frame_ctl = IEEE802_11_FTYPE_DATA;
+       frame_ctl = IEEE80211_FTYPE_DATA;
        header.duration_id = 0;
        header.seq_ctl = 0;
        if (priv->wep_is_on)
-               frame_ctl |= IEEE802_11_FCTL_WEP;
+               frame_ctl |= IEEE80211_FCTL_PROTECTED;
        if (priv->operating_mode == IW_MODE_ADHOC) {
                memcpy(&header.addr1, skb->data, 6);
                memcpy(&header.addr2, dev->dev_addr, 6);
                memcpy(&header.addr3, priv->BSSID, 6);
        } else {
-               frame_ctl |= IEEE802_11_FCTL_TODS;
+               frame_ctl |= IEEE80211_FCTL_TODS;
                memcpy(&header.addr1, priv->CurrentBSSID, 6);
                memcpy(&header.addr2, dev->dev_addr, 6);
                memcpy(&header.addr3, skb->data, 6);
@@ -902,7 +902,7 @@ static int start_tx (struct sk_buff *skb, struct net_device *dev)
 }
 
 static void atmel_transmit_management_frame(struct atmel_private *priv, 
-                                           struct ieee802_11_hdr *header,
+                                           struct ieee80211_hdr *header,
                                            u8 *body, int body_len)
 {
        u16 buff;
@@ -917,7 +917,7 @@ static void atmel_transmit_management_frame(struct atmel_private *priv,
        tx_update_descriptor(priv, header->addr1[0] & 0x01, len, buff, TX_PACKET_TYPE_MGMT);
 }
        
-static void fast_rx_path(struct atmel_private *priv, struct ieee802_11_hdr *header, 
+static void fast_rx_path(struct atmel_private *priv, struct ieee80211_hdr *header, 
                         u16 msdu_size, u16 rx_packet_loc, u32 crc)
 {
        /* fast path: unfragmented packet copy directly into skbuf */
@@ -955,7 +955,7 @@ static void fast_rx_path(struct atmel_private *priv, struct ieee802_11_hdr *head
        }
        
        memcpy(skbp, header->addr1, 6); /* destination address */
-       if (le16_to_cpu(header->frame_ctl) & IEEE802_11_FCTL_FROMDS) 
+       if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS) 
                memcpy(&skbp[6], header->addr3, 6);
        else
                memcpy(&skbp[6], header->addr2, 6); /* source address */
@@ -990,14 +990,14 @@ static int probe_crc(struct atmel_private *priv, u16 packet_loc, u16 msdu_size)
        return (crc ^ 0xffffffff) == netcrc;
 }
 
-static void frag_rx_path(struct atmel_private *priv, struct ieee802_11_hdr *header, 
+static void frag_rx_path(struct atmel_private *priv, struct ieee80211_hdr *header, 
                         u16 msdu_size, u16 rx_packet_loc, u32 crc, u16 seq_no, u8 frag_no, int more_frags)
 {
        u8 mac4[6]; 
        u8 source[6];
        struct sk_buff *skb;
 
-       if (le16_to_cpu(header->frame_ctl) & IEEE802_11_FCTL_FROMDS) 
+       if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS) 
                memcpy(source, header->addr3, 6);
        else
                memcpy(source, header->addr2, 6); 
@@ -1082,7 +1082,7 @@ static void frag_rx_path(struct atmel_private *priv, struct ieee802_11_hdr *head
 static void rx_done_irq(struct atmel_private *priv)
 {
        int i;
-       struct ieee802_11_hdr header;
+       struct ieee80211_hdr header;
        
        for (i = 0; 
             atmel_rmem8(priv, atmel_rx(priv, RX_DESC_FLAGS_OFFSET, priv->rx_desc_head)) == RX_DESC_FLAG_VALID &&
@@ -1117,7 +1117,7 @@ static void rx_done_irq(struct atmel_private *priv)
                /* probe for CRC use here if needed  once five packets have arrived with
                   the same crc status, we assume we know what's happening and stop probing */
                if (priv->probe_crc) {
-                       if (!priv->wep_is_on || !(frame_ctl & IEEE802_11_FCTL_WEP)) {
+                       if (!priv->wep_is_on || !(frame_ctl & IEEE80211_FCTL_PROTECTED)) {
                                priv->do_rx_crc = probe_crc(priv, rx_packet_loc, msdu_size);
                        } else {
                                priv->do_rx_crc = probe_crc(priv, rx_packet_loc + 24, msdu_size - 24);
@@ -1132,16 +1132,16 @@ static void rx_done_irq(struct atmel_private *priv)
                }
                    
                /* don't CRC header when WEP in use */
-               if (priv->do_rx_crc && (!priv->wep_is_on || !(frame_ctl & IEEE802_11_FCTL_WEP))) {
+               if (priv->do_rx_crc && (!priv->wep_is_on || !(frame_ctl & IEEE80211_FCTL_PROTECTED))) {
                        crc = crc32_le(0xffffffff, (unsigned char *)&header, 24);
                }
                msdu_size -= 24; /* header */
 
-               if ((frame_ctl & IEEE802_11_FCTL_FTYPE) == IEEE802_11_FTYPE_DATA) { 
+               if ((frame_ctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) { 
                        
-                       int more_fragments = frame_ctl & IEEE802_11_FCTL_MOREFRAGS;
-                       u8 packet_fragment_no = seq_control & IEEE802_11_SCTL_FRAG;
-                       u16 packet_sequence_no = (seq_control & IEEE802_11_SCTL_SEQ) >> 4;
+                       int more_fragments = frame_ctl & IEEE80211_FCTL_MOREFRAGS;
+                       u8 packet_fragment_no = seq_control & IEEE80211_SCTL_FRAG;
+                       u16 packet_sequence_no = (seq_control & IEEE80211_SCTL_SEQ) >> 4;
                        
                        if (!more_fragments && packet_fragment_no == 0 ) {
                                fast_rx_path(priv, &header, msdu_size, rx_packet_loc, crc);
@@ -1151,7 +1151,7 @@ static void rx_done_irq(struct atmel_private *priv)
                        }
                }
                
-               if ((frame_ctl & IEEE802_11_FCTL_FTYPE) == IEEE802_11_FTYPE_MGMT) {
+               if ((frame_ctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) {
                        /* copy rest of packet into buffer */
                        atmel_copy_to_host(priv->dev, (unsigned char *)&priv->rx_buf, rx_packet_loc + 24, msdu_size);
                        
@@ -2663,10 +2663,10 @@ static void handle_beacon_probe(struct atmel_private *priv, u16 capability, u8 c
  
 static void send_authentication_request(struct atmel_private *priv, u8 *challenge, int challenge_len)
 {
-       struct ieee802_11_hdr header;
+       struct ieee80211_hdr header;
        struct auth_body auth;
        
-       header.frame_ctl = cpu_to_le16(IEEE802_11_FTYPE_MGMT | IEEE802_11_STYPE_AUTH); 
+       header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH); 
        header.duration_id      = cpu_to_le16(0x8000);  
        header.seq_ctl = 0;
        memcpy(header.addr1, priv->CurrentBSSID, 6);
@@ -2677,7 +2677,7 @@ static void send_authentication_request(struct atmel_private *priv, u8 *challeng
                auth.alg = cpu_to_le16(C80211_MGMT_AAN_SHAREDKEY); 
                /* no WEP for authentication frames with TrSeqNo 1 */
                if (priv->CurrentAuthentTransactionSeqNum != 1)
-                       header.frame_ctl |=  cpu_to_le16(IEEE802_11_FCTL_WEP); 
+                       header.frame_ctl |=  cpu_to_le16(IEEE80211_FCTL_PROTECTED);
        } else {
                auth.alg = cpu_to_le16(C80211_MGMT_AAN_OPENSYSTEM);
        }
@@ -2701,7 +2701,7 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
 {
        u8 *ssid_el_p;
        int bodysize;
-       struct ieee802_11_hdr header;
+       struct ieee80211_hdr header;
        struct ass_req_format {
                u16 capability;
                u16 listen_interval; 
@@ -2714,8 +2714,8 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
                u8 rates[4];
        } body;
                
-       header.frame_ctl = cpu_to_le16(IEEE802_11_FTYPE_MGMT | 
-               (is_reassoc ? IEEE802_11_STYPE_REASSOC_REQ : IEEE802_11_STYPE_ASSOC_REQ));
+       header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | 
+               (is_reassoc ? IEEE80211_STYPE_REASSOC_REQ : IEEE80211_STYPE_ASSOC_REQ));
        header.duration_id = cpu_to_le16(0x8000);
        header.seq_ctl = 0;
 
@@ -2751,9 +2751,9 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
        atmel_transmit_management_frame(priv, &header, (void *)&body, bodysize);
 }
 
-static int is_frame_from_current_bss(struct atmel_private *priv, struct ieee802_11_hdr *header)
+static int is_frame_from_current_bss(struct atmel_private *priv, struct ieee80211_hdr *header)
 {
-       if (le16_to_cpu(header->frame_ctl) & IEEE802_11_FCTL_FROMDS)
+       if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS)
                return memcmp(header->addr3, priv->CurrentBSSID, 6) == 0;
        else
                return memcmp(header->addr2, priv->CurrentBSSID, 6) == 0;
@@ -2801,7 +2801,7 @@ static int retrieve_bss(struct atmel_private *priv)
 }
 
 
-static void store_bss_info(struct atmel_private *priv, struct ieee802_11_hdr *header,
+static void store_bss_info(struct atmel_private *priv, struct ieee80211_hdr *header,
                           u16 capability, u16 beacon_period, u8 channel, u8 rssi, 
                           u8 ssid_len, u8 *ssid, int is_beacon)
 {
@@ -3085,12 +3085,12 @@ static void atmel_smooth_qual(struct atmel_private *priv)
 }
 
 /* deals with incoming managment frames. */
-static void atmel_management_frame(struct atmel_private *priv, struct ieee802_11_hdr *header, 
+static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_hdr *header, 
                      u16 frame_len, u8 rssi)
 {
        u16 subtype;
        
-       switch (subtype = le16_to_cpu(header->frame_ctl) & IEEE802_11_FCTL_STYPE) {
+       switch (subtype = le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_STYPE) {
        case C80211_SUBTYPE_MGMT_BEACON :
        case C80211_SUBTYPE_MGMT_ProbeResponse:
                
diff --git a/drivers/net/wireless/hostap/Kconfig b/drivers/net/wireless/hostap/Kconfig
new file mode 100644 (file)
index 0000000..56f41c7
--- /dev/null
@@ -0,0 +1,73 @@
+config HOSTAP
+       tristate "IEEE 802.11 for Host AP (Prism2/2.5/3 and WEP/TKIP/CCMP)"
+       depends on NET_RADIO
+       select IEEE80211
+       select IEEE80211_CRYPT_WEP
+       ---help---
+       Shared driver code for IEEE 802.11b wireless cards based on
+       Intersil Prism2/2.5/3 chipset. This driver supports so called
+       Host AP mode that allows the card to act as an IEEE 802.11
+       access point.
+
+       See <http://hostap.epitest.fi/> for more information about the
+       Host AP driver configuration and tools. This site includes
+       information and tools (hostapd and wpa_supplicant) for WPA/WPA2
+       support.
+
+       This option includes the base Host AP driver code that is shared by
+       different hardware models. You will also need to enable support for
+       PLX/PCI/CS version of the driver to actually use the driver.
+
+       The driver can be compiled as a module and it will be called
+       "hostap.ko".
+
+config HOSTAP_FIRMWARE
+       bool "Support downloading firmware images with Host AP driver"
+       depends on HOSTAP
+       ---help---
+       Configure Host AP driver to include support for firmware image
+       download. Current version supports only downloading to volatile, i.e.,
+       RAM memory. Flash upgrade is not yet supported.
+
+       Firmware image downloading needs user space tool, prism2_srec. It is
+       available from http://hostap.epitest.fi/.
+
+config HOSTAP_PLX
+       tristate "Host AP driver for Prism2/2.5/3 in PLX9052 PCI adaptors"
+       depends on PCI && HOSTAP
+       ---help---
+       Host AP driver's version for Prism2/2.5/3 PC Cards in PLX9052 based
+       PCI adaptors.
+
+       "Host AP support for Prism2/2.5/3 IEEE 802.11b" is required for this
+       driver and its help text includes more information about the Host AP
+       driver.
+
+       The driver can be compiled as a module and will be named
+       "hostap_plx.ko".
+
+config HOSTAP_PCI
+       tristate "Host AP driver for Prism2.5 PCI adaptors"
+       depends on PCI && HOSTAP
+       ---help---
+       Host AP driver's version for Prism2.5 PCI adaptors.
+
+       "Host AP support for Prism2/2.5/3 IEEE 802.11b" is required for this
+       driver and its help text includes more information about the Host AP
+       driver.
+
+       The driver can be compiled as a module and will be named
+       "hostap_pci.ko".
+
+config HOSTAP_CS
+       tristate "Host AP driver for Prism2/2.5/3 PC Cards"
+       depends on PCMCIA!=n && HOSTAP
+       ---help---
+       Host AP driver's version for Prism2/2.5/3 PC Cards.
+
+       "Host AP support for Prism2/2.5/3 IEEE 802.11b" is required for this
+       driver and its help text includes more information about the Host AP
+       driver.
+
+       The driver can be compiled as a module and will be named
+       "hostap_cs.ko".
diff --git a/drivers/net/wireless/hostap/Makefile b/drivers/net/wireless/hostap/Makefile
new file mode 100644 (file)
index 0000000..fc62235
--- /dev/null
@@ -0,0 +1,5 @@
+obj-$(CONFIG_HOSTAP) += hostap.o
+
+obj-$(CONFIG_HOSTAP_CS) += hostap_cs.o
+obj-$(CONFIG_HOSTAP_PLX) += hostap_plx.o
+obj-$(CONFIG_HOSTAP_PCI) += hostap_pci.o
diff --git a/drivers/net/wireless/hostap/hostap.c b/drivers/net/wireless/hostap/hostap.c
new file mode 100644 (file)
index 0000000..e7f5821
--- /dev/null
@@ -0,0 +1,1198 @@
+/*
+ * Host AP (software wireless LAN access point) driver for
+ * Intersil Prism2/2.5/3 - hostap.o module, common routines
+ *
+ * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
+ * <jkmaline@cc.hut.fi>
+ * Copyright (c) 2002-2005, Jouni Malinen <jkmaline@cc.hut.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. See README and COPYING for
+ * more details.
+ */
+
+#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/proc_fs.h>
+#include <linux/if_arp.h>
+#include <linux/delay.h>
+#include <linux/random.h>
+#include <linux/workqueue.h>
+#include <linux/kmod.h>
+#include <linux/rtnetlink.h>
+#include <linux/wireless.h>
+#include <net/iw_handler.h>
+#include <net/ieee80211.h>
+#include <net/ieee80211_crypt.h>
+#include <asm/uaccess.h>
+
+#include "hostap_wlan.h"
+#include "hostap_80211.h"
+#include "hostap_ap.h"
+#include "hostap.h"
+
+MODULE_AUTHOR("Jouni Malinen");
+MODULE_DESCRIPTION("Host AP common routines");
+MODULE_LICENSE("GPL");
+MODULE_VERSION(PRISM2_VERSION);
+
+#define TX_TIMEOUT (2 * HZ)
+
+#define PRISM2_MAX_FRAME_SIZE 2304
+#define PRISM2_MIN_MTU 256
+/* FIX: */
+#define PRISM2_MAX_MTU (PRISM2_MAX_FRAME_SIZE - (6 /* LLC */ + 8 /* WEP */))
+
+
+/* hostap.c */
+static int prism2_wds_add(local_info_t *local, u8 *remote_addr,
+                         int rtnl_locked);
+static int prism2_wds_del(local_info_t *local, u8 *remote_addr,
+                         int rtnl_locked, int do_not_remove);
+
+/* hostap_ap.c */
+static int prism2_ap_get_sta_qual(local_info_t *local, struct sockaddr addr[],
+                                 struct iw_quality qual[], int buf_size,
+                                 int aplist);
+static int prism2_ap_translate_scan(struct net_device *dev, char *buffer);
+static int prism2_hostapd(struct ap_data *ap,
+                         struct prism2_hostapd_param *param);
+static void * ap_crypt_get_ptrs(struct ap_data *ap, u8 *addr, int permanent,
+                               struct ieee80211_crypt_data ***crypt);
+static void ap_control_kickall(struct ap_data *ap);
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+static int ap_control_add_mac(struct mac_restrictions *mac_restrictions,
+                             u8 *mac);
+static int ap_control_del_mac(struct mac_restrictions *mac_restrictions,
+                             u8 *mac);
+static void ap_control_flush_macs(struct mac_restrictions *mac_restrictions);
+static int ap_control_kick_mac(struct ap_data *ap, struct net_device *dev,
+                              u8 *mac);
+#endif /* !PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+
+static const long freq_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442,
+                                 2447, 2452, 2457, 2462, 2467, 2472, 2484 };
+#define FREQ_COUNT (sizeof(freq_list) / sizeof(freq_list[0]))
+
+
+/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
+/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
+static unsigned char rfc1042_header[] =
+{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
+/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
+static unsigned char bridge_tunnel_header[] =
+{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
+/* No encapsulation header if EtherType < 0x600 (=length) */
+
+
+/* FIX: these could be compiled separately and linked together to hostap.o */
+#include "hostap_ap.c"
+#include "hostap_info.c"
+#include "hostap_ioctl.c"
+#include "hostap_proc.c"
+#include "hostap_80211_rx.c"
+#include "hostap_80211_tx.c"
+
+
+struct net_device * hostap_add_interface(struct local_info *local,
+                                        int type, int rtnl_locked,
+                                        const char *prefix,
+                                        const char *name)
+{
+       struct net_device *dev, *mdev;
+       struct hostap_interface *iface;
+       int ret;
+
+       dev = alloc_etherdev(sizeof(struct hostap_interface));
+       if (dev == NULL)
+               return NULL;
+
+       iface = netdev_priv(dev);
+       iface->dev = dev;
+       iface->local = local;
+       iface->type = type;
+       list_add(&iface->list, &local->hostap_interfaces);
+
+       mdev = local->dev;
+       memcpy(dev->dev_addr, mdev->dev_addr, ETH_ALEN);
+       dev->base_addr = mdev->base_addr;
+       dev->irq = mdev->irq;
+       dev->mem_start = mdev->mem_start;
+       dev->mem_end = mdev->mem_end;
+
+       hostap_setup_dev(dev, local, 0);
+       dev->destructor = free_netdev;
+
+       sprintf(dev->name, "%s%s", prefix, name);
+       if (!rtnl_locked)
+               rtnl_lock();
+
+       ret = 0;
+       if (strchr(dev->name, '%'))
+               ret = dev_alloc_name(dev, dev->name);
+
+       SET_NETDEV_DEV(dev, mdev->class_dev.dev);
+       if (ret >= 0)
+               ret = register_netdevice(dev);
+
+       if (!rtnl_locked)
+               rtnl_unlock();
+
+       if (ret < 0) {
+               printk(KERN_WARNING "%s: failed to add new netdevice!\n",
+                      dev->name);
+               free_netdev(dev);
+               return NULL;
+       }
+
+       printk(KERN_DEBUG "%s: registered netdevice %s\n",
+              mdev->name, dev->name);
+
+       return dev;
+}
+
+
+void hostap_remove_interface(struct net_device *dev, int rtnl_locked,
+                            int remove_from_list)
+{
+       struct hostap_interface *iface;
+
+       if (!dev)
+               return;
+
+       iface = netdev_priv(dev);
+
+       if (remove_from_list) {
+               list_del(&iface->list);
+       }
+
+       if (dev == iface->local->ddev)
+               iface->local->ddev = NULL;
+       else if (dev == iface->local->apdev)
+               iface->local->apdev = NULL;
+       else if (dev == iface->local->stadev)
+               iface->local->stadev = NULL;
+
+       if (rtnl_locked)
+               unregister_netdevice(dev);
+       else
+               unregister_netdev(dev);
+
+       /* dev->destructor = free_netdev() will free the device data, including
+        * private data, when removing the device */
+}
+
+
+static inline int prism2_wds_special_addr(u8 *addr)
+{
+       if (addr[0] || addr[1] || addr[2] || addr[3] || addr[4] || addr[5])
+               return 0;
+
+       return 1;
+}
+
+
+static int prism2_wds_add(local_info_t *local, u8 *remote_addr,
+                         int rtnl_locked)
+{
+       struct net_device *dev;
+       struct list_head *ptr;
+       struct hostap_interface *iface, *empty, *match;
+
+       empty = match = NULL;
+       read_lock_bh(&local->iface_lock);
+       list_for_each(ptr, &local->hostap_interfaces) {
+               iface = list_entry(ptr, struct hostap_interface, list);
+               if (iface->type != HOSTAP_INTERFACE_WDS)
+                       continue;
+
+               if (prism2_wds_special_addr(iface->u.wds.remote_addr))
+                       empty = iface;
+               else if (memcmp(iface->u.wds.remote_addr, remote_addr,
+                               ETH_ALEN) == 0) {
+                       match = iface;
+                       break;
+               }
+       }
+       if (!match && empty && !prism2_wds_special_addr(remote_addr)) {
+               /* take pre-allocated entry into use */
+               memcpy(empty->u.wds.remote_addr, remote_addr, ETH_ALEN);
+               read_unlock_bh(&local->iface_lock);
+               printk(KERN_DEBUG "%s: using pre-allocated WDS netdevice %s\n",
+                      local->dev->name, empty->dev->name);
+               return 0;
+       }
+       read_unlock_bh(&local->iface_lock);
+
+       if (!prism2_wds_special_addr(remote_addr)) {
+               if (match)
+                       return -EEXIST;
+               hostap_add_sta(local->ap, remote_addr);
+       }
+
+       if (local->wds_connections >= local->wds_max_connections)
+               return -ENOBUFS;
+
+       /* verify that there is room for wds# postfix in the interface name */
+       if (strlen(local->dev->name) > IFNAMSIZ - 5) {
+               printk(KERN_DEBUG "'%s' too long base device name\n",
+                      local->dev->name);
+               return -EINVAL;
+       }
+
+       dev = hostap_add_interface(local, HOSTAP_INTERFACE_WDS, rtnl_locked,
+                                  local->ddev->name, "wds%d");
+       if (dev == NULL)
+               return -ENOMEM;
+
+       iface = netdev_priv(dev);
+       memcpy(iface->u.wds.remote_addr, remote_addr, ETH_ALEN);
+
+       local->wds_connections++;
+
+       return 0;
+}
+
+
+static int prism2_wds_del(local_info_t *local, u8 *remote_addr,
+                         int rtnl_locked, int do_not_remove)
+{
+       unsigned long flags;
+       struct list_head *ptr;
+       struct hostap_interface *iface, *selected = NULL;
+
+       write_lock_irqsave(&local->iface_lock, flags);
+       list_for_each(ptr, &local->hostap_interfaces) {
+               iface = list_entry(ptr, struct hostap_interface, list);
+               if (iface->type != HOSTAP_INTERFACE_WDS)
+                       continue;
+
+               if (memcmp(iface->u.wds.remote_addr, remote_addr,
+                          ETH_ALEN) == 0) {
+                       selected = iface;
+                       break;
+               }
+       }
+       if (selected && !do_not_remove)
+               list_del(&selected->list);
+       write_unlock_irqrestore(&local->iface_lock, flags);
+
+       if (selected) {
+               if (do_not_remove)
+                       memset(selected->u.wds.remote_addr, 0, ETH_ALEN);
+               else {
+                       hostap_remove_interface(selected->dev, rtnl_locked, 0);
+                       local->wds_connections--;
+               }
+       }
+
+       return selected ? 0 : -ENODEV;
+}
+
+
+u16 hostap_tx_callback_register(local_info_t *local,
+                               void (*func)(struct sk_buff *, int ok, void *),
+                               void *data)
+{
+       unsigned long flags;
+       struct hostap_tx_callback_info *entry;
+
+       entry = (struct hostap_tx_callback_info *) kmalloc(sizeof(*entry),
+                                                          GFP_ATOMIC);
+       if (entry == NULL)
+               return 0;
+
+       entry->func = func;
+       entry->data = data;
+
+       spin_lock_irqsave(&local->lock, flags);
+       entry->idx = local->tx_callback ? local->tx_callback->idx + 1 : 1;
+       entry->next = local->tx_callback;
+       local->tx_callback = entry;
+       spin_unlock_irqrestore(&local->lock, flags);
+
+       return entry->idx;
+}
+
+
+int hostap_tx_callback_unregister(local_info_t *local, u16 idx)
+{
+       unsigned long flags;
+       struct hostap_tx_callback_info *cb, *prev = NULL;
+
+       spin_lock_irqsave(&local->lock, flags);
+       cb = local->tx_callback;
+       while (cb != NULL && cb->idx != idx) {
+               prev = cb;
+               cb = cb->next;
+       }
+       if (cb) {
+               if (prev == NULL)
+                       local->tx_callback = cb->next;
+               else
+                       prev->next = cb->next;
+               kfree(cb);
+       }
+       spin_unlock_irqrestore(&local->lock, flags);
+
+       return cb ? 0 : -1;
+}
+
+
+/* val is in host byte order */
+int hostap_set_word(struct net_device *dev, int rid, u16 val)
+{
+       struct hostap_interface *iface;
+       u16 tmp = cpu_to_le16(val);
+       iface = netdev_priv(dev);
+       return iface->local->func->set_rid(dev, rid, &tmp, 2);
+}
+
+
+int hostap_set_string(struct net_device *dev, int rid, const char *val)
+{
+       struct hostap_interface *iface;
+       char buf[MAX_SSID_LEN + 2];
+       int len;
+
+       iface = netdev_priv(dev);
+       len = strlen(val);
+       if (len > MAX_SSID_LEN)
+               return -1;
+       memset(buf, 0, sizeof(buf));
+       buf[0] = len; /* little endian 16 bit word */
+       memcpy(buf + 2, val, len);
+
+       return iface->local->func->set_rid(dev, rid, &buf, MAX_SSID_LEN + 2);
+}
+
+
+u16 hostap_get_porttype(local_info_t *local)
+{
+       if (local->iw_mode == IW_MODE_ADHOC && local->pseudo_adhoc)
+               return HFA384X_PORTTYPE_PSEUDO_IBSS;
+       if (local->iw_mode == IW_MODE_ADHOC)
+               return HFA384X_PORTTYPE_IBSS;
+       if (local->iw_mode == IW_MODE_INFRA)
+               return HFA384X_PORTTYPE_BSS;
+       if (local->iw_mode == IW_MODE_REPEAT)
+               return HFA384X_PORTTYPE_WDS;
+       if (local->iw_mode == IW_MODE_MONITOR)
+               return HFA384X_PORTTYPE_PSEUDO_IBSS;
+       return HFA384X_PORTTYPE_HOSTAP;
+}
+
+
+int hostap_set_encryption(local_info_t *local)
+{
+       u16 val, old_val;
+       int i, keylen, len, idx;
+       char keybuf[WEP_KEY_LEN + 1];
+       enum { NONE, WEP, OTHER } encrypt_type;
+
+       idx = local->tx_keyidx;
+       if (local->crypt[idx] == NULL || local->crypt[idx]->ops == NULL)
+               encrypt_type = NONE;
+       else if (strcmp(local->crypt[idx]->ops->name, "WEP") == 0)
+               encrypt_type = WEP;
+       else
+               encrypt_type = OTHER;
+
+       if (local->func->get_rid(local->dev, HFA384X_RID_CNFWEPFLAGS, &val, 2,
+                                1) < 0) {
+               printk(KERN_DEBUG "Could not read current WEP flags.\n");
+               goto fail;
+       }
+       le16_to_cpus(&val);
+       old_val = val;
+
+       if (encrypt_type != NONE || local->privacy_invoked)
+               val |= HFA384X_WEPFLAGS_PRIVACYINVOKED;
+       else
+               val &= ~HFA384X_WEPFLAGS_PRIVACYINVOKED;
+
+       if (local->open_wep || encrypt_type == NONE ||
+           ((local->ieee_802_1x || local->wpa) && local->host_decrypt))
+               val &= ~HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED;
+       else
+               val |= HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED;
+
+       if ((encrypt_type != NONE || local->privacy_invoked) &&
+           (encrypt_type == OTHER || local->host_encrypt))
+               val |= HFA384X_WEPFLAGS_HOSTENCRYPT;
+       else
+               val &= ~HFA384X_WEPFLAGS_HOSTENCRYPT;
+       if ((encrypt_type != NONE || local->privacy_invoked) &&
+           (encrypt_type == OTHER || local->host_decrypt))
+               val |= HFA384X_WEPFLAGS_HOSTDECRYPT;
+       else
+               val &= ~HFA384X_WEPFLAGS_HOSTDECRYPT;
+
+       if (val != old_val &&
+           hostap_set_word(local->dev, HFA384X_RID_CNFWEPFLAGS, val)) {
+               printk(KERN_DEBUG "Could not write new WEP flags (0x%x)\n",
+                      val);
+               goto fail;
+       }
+
+       if (encrypt_type != WEP)
+               return 0;
+
+       /* 104-bit support seems to require that all the keys are set to the
+        * same keylen */
+       keylen = 6; /* first 5 octets */
+       len = local->crypt[idx]->ops->get_key(keybuf, sizeof(keybuf),
+                                             NULL, local->crypt[idx]->priv);
+       if (idx >= 0 && idx < WEP_KEYS && len > 5)
+               keylen = WEP_KEY_LEN + 1; /* first 13 octets */
+
+       for (i = 0; i < WEP_KEYS; i++) {
+               memset(keybuf, 0, sizeof(keybuf));
+               if (local->crypt[i]) {
+                       (void) local->crypt[i]->ops->get_key(
+                               keybuf, sizeof(keybuf),
+                               NULL, local->crypt[i]->priv);
+               }
+               if (local->func->set_rid(local->dev,
+                                        HFA384X_RID_CNFDEFAULTKEY0 + i,
+                                        keybuf, keylen)) {
+                       printk(KERN_DEBUG "Could not set key %d (len=%d)\n",
+                              i, keylen);
+                       goto fail;
+               }
+       }
+       if (hostap_set_word(local->dev, HFA384X_RID_CNFWEPDEFAULTKEYID, idx)) {
+               printk(KERN_DEBUG "Could not set default keyid %d\n", idx);
+               goto fail;
+       }
+
+       return 0;
+
+ fail:
+       printk(KERN_DEBUG "%s: encryption setup failed\n", local->dev->name);
+       return -1;
+}
+
+
+int hostap_set_antsel(local_info_t *local)
+{
+       u16 val;
+       int ret = 0;
+
+       if (local->antsel_tx != HOSTAP_ANTSEL_DO_NOT_TOUCH &&
+           local->func->cmd(local->dev, HFA384X_CMDCODE_READMIF,
+                            HFA386X_CR_TX_CONFIGURE,
+                            NULL, &val) == 0) {
+               val &= ~(BIT(2) | BIT(1));
+               switch (local->antsel_tx) {
+               case HOSTAP_ANTSEL_DIVERSITY:
+                       val |= BIT(1);
+                       break;
+               case HOSTAP_ANTSEL_LOW:
+                       break;
+               case HOSTAP_ANTSEL_HIGH:
+                       val |= BIT(2);
+                       break;
+               }
+
+               if (local->func->cmd(local->dev, HFA384X_CMDCODE_WRITEMIF,
+                                    HFA386X_CR_TX_CONFIGURE, &val, NULL)) {
+                       printk(KERN_INFO "%s: setting TX AntSel failed\n",
+                              local->dev->name);
+                       ret = -1;
+               }
+       }
+
+       if (local->antsel_rx != HOSTAP_ANTSEL_DO_NOT_TOUCH &&
+           local->func->cmd(local->dev, HFA384X_CMDCODE_READMIF,
+                            HFA386X_CR_RX_CONFIGURE,
+                            NULL, &val) == 0) {
+               val &= ~(BIT(1) | BIT(0));
+               switch (local->antsel_rx) {
+               case HOSTAP_ANTSEL_DIVERSITY:
+                       break;
+               case HOSTAP_ANTSEL_LOW:
+                       val |= BIT(0);
+                       break;
+               case HOSTAP_ANTSEL_HIGH:
+                       val |= BIT(0) | BIT(1);
+                       break;
+               }
+
+               if (local->func->cmd(local->dev, HFA384X_CMDCODE_WRITEMIF,
+                                    HFA386X_CR_RX_CONFIGURE, &val, NULL)) {
+                       printk(KERN_INFO "%s: setting RX AntSel failed\n",
+                              local->dev->name);
+                       ret = -1;
+               }
+       }
+
+       return ret;
+}
+
+
+int hostap_set_roaming(local_info_t *local)
+{
+       u16 val;
+
+       switch (local->host_roaming) {
+       case 1:
+               val = HFA384X_ROAMING_HOST;
+               break;
+       case 2:
+               val = HFA384X_ROAMING_DISABLED;
+               break;
+       case 0:
+       default:
+               val = HFA384X_ROAMING_FIRMWARE;
+               break;
+       }
+
+       return hostap_set_word(local->dev, HFA384X_RID_CNFROAMINGMODE, val);
+}
+
+
+int hostap_set_auth_algs(local_info_t *local)
+{
+       int val = local->auth_algs;
+       /* At least STA f/w v0.6.2 seems to have issues with cnfAuthentication
+        * set to include both Open and Shared Key flags. It tries to use
+        * Shared Key authentication in that case even if WEP keys are not
+        * configured.. STA f/w v0.7.6 is able to handle such configuration,
+        * but it is unknown when this was fixed between 0.6.2 .. 0.7.6. */
+       if (local->sta_fw_ver < PRISM2_FW_VER(0,7,0) &&
+           val != PRISM2_AUTH_OPEN && val != PRISM2_AUTH_SHARED_KEY)
+               val = PRISM2_AUTH_OPEN;
+
+       if (hostap_set_word(local->dev, HFA384X_RID_CNFAUTHENTICATION, val)) {
+               printk(KERN_INFO "%s: cnfAuthentication setting to 0x%x "
+                      "failed\n", local->dev->name, local->auth_algs);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+
+void hostap_dump_rx_header(const char *name, const struct hfa384x_rx_frame *rx)
+{
+       u16 status, fc;
+
+       status = __le16_to_cpu(rx->status);
+
+       printk(KERN_DEBUG "%s: RX status=0x%04x (port=%d, type=%d, "
+              "fcserr=%d) silence=%d signal=%d rate=%d rxflow=%d; "
+              "jiffies=%ld\n",
+              name, status, (status >> 8) & 0x07, status >> 13, status & 1,
+              rx->silence, rx->signal, rx->rate, rx->rxflow, jiffies);
+
+       fc = __le16_to_cpu(rx->frame_control);
+       printk(KERN_DEBUG "   FC=0x%04x (type=%d:%d) dur=0x%04x seq=0x%04x "
+              "data_len=%d%s%s\n",
+              fc, WLAN_FC_GET_TYPE(fc) >> 2, WLAN_FC_GET_STYPE(fc) >> 4,
+              __le16_to_cpu(rx->duration_id), __le16_to_cpu(rx->seq_ctrl),
+              __le16_to_cpu(rx->data_len),
+              fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "",
+              fc & IEEE80211_FCTL_FROMDS ? " [FromDS]" : "");
+
+       printk(KERN_DEBUG "   A1=" MACSTR " A2=" MACSTR " A3=" MACSTR " A4="
+              MACSTR "\n",
+              MAC2STR(rx->addr1), MAC2STR(rx->addr2), MAC2STR(rx->addr3),
+              MAC2STR(rx->addr4));
+
+       printk(KERN_DEBUG "   dst=" MACSTR " src=" MACSTR " len=%d\n",
+              MAC2STR(rx->dst_addr), MAC2STR(rx->src_addr),
+              __be16_to_cpu(rx->len));
+}
+
+
+void hostap_dump_tx_header(const char *name, const struct hfa384x_tx_frame *tx)
+{
+       u16 fc;
+
+       printk(KERN_DEBUG "%s: TX status=0x%04x retry_count=%d tx_rate=%d "
+              "tx_control=0x%04x; jiffies=%ld\n",
+              name, __le16_to_cpu(tx->status), tx->retry_count, tx->tx_rate,
+              __le16_to_cpu(tx->tx_control), jiffies);
+
+       fc = __le16_to_cpu(tx->frame_control);
+       printk(KERN_DEBUG "   FC=0x%04x (type=%d:%d) dur=0x%04x seq=0x%04x "
+              "data_len=%d%s%s\n",
+              fc, WLAN_FC_GET_TYPE(fc) >> 2, WLAN_FC_GET_STYPE(fc) >> 4,
+              __le16_to_cpu(tx->duration_id), __le16_to_cpu(tx->seq_ctrl),
+              __le16_to_cpu(tx->data_len),
+              fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "",
+              fc & IEEE80211_FCTL_FROMDS ? " [FromDS]" : "");
+
+       printk(KERN_DEBUG "   A1=" MACSTR " A2=" MACSTR " A3=" MACSTR " A4="
+              MACSTR "\n",
+              MAC2STR(tx->addr1), MAC2STR(tx->addr2), MAC2STR(tx->addr3),
+              MAC2STR(tx->addr4));
+
+       printk(KERN_DEBUG "   dst=" MACSTR " src=" MACSTR " len=%d\n",
+              MAC2STR(tx->dst_addr), MAC2STR(tx->src_addr),
+              __be16_to_cpu(tx->len));
+}
+
+
+int hostap_80211_header_parse(struct sk_buff *skb, unsigned char *haddr)
+{
+       memcpy(haddr, skb->mac.raw + 10, ETH_ALEN); /* addr2 */
+       return ETH_ALEN;
+}
+
+
+int hostap_80211_prism_header_parse(struct sk_buff *skb, unsigned char *haddr)
+{
+       if (*(u32 *)skb->mac.raw == LWNG_CAP_DID_BASE) {
+               memcpy(haddr, skb->mac.raw +
+                      sizeof(struct linux_wlan_ng_prism_hdr) + 10,
+                      ETH_ALEN); /* addr2 */
+       } else { /* (*(u32 *)skb->mac.raw == htonl(LWNG_CAPHDR_VERSION)) */
+               memcpy(haddr, skb->mac.raw +
+                      sizeof(struct linux_wlan_ng_cap_hdr) + 10,
+                      ETH_ALEN); /* addr2 */
+       }
+       return ETH_ALEN;
+}
+
+
+int hostap_80211_get_hdrlen(u16 fc)
+{
+       int hdrlen = 24;
+
+       switch (WLAN_FC_GET_TYPE(fc)) {
+       case IEEE80211_FTYPE_DATA:
+               if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
+                       hdrlen = 30; /* Addr4 */
+               break;
+       case IEEE80211_FTYPE_CTL:
+               switch (WLAN_FC_GET_STYPE(fc)) {
+               case IEEE80211_STYPE_CTS:
+               case IEEE80211_STYPE_ACK:
+                       hdrlen = 10;
+                       break;
+               default:
+                       hdrlen = 16;
+                       break;
+               }
+               break;
+       }
+
+       return hdrlen;
+}
+
+
+struct net_device_stats *hostap_get_stats(struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       iface = netdev_priv(dev);
+       return &iface->stats;
+}
+
+
+static int prism2_close(struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       PDEBUG(DEBUG_FLOW, "%s: prism2_close\n", dev->name);
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (dev == local->ddev) {
+               prism2_sta_deauth(local, WLAN_REASON_DEAUTH_LEAVING);
+       }
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+       if (!local->hostapd && dev == local->dev &&
+           (!local->func->card_present || local->func->card_present(local)) &&
+           local->hw_ready && local->ap && local->iw_mode == IW_MODE_MASTER)
+               hostap_deauth_all_stas(dev, local->ap, 1);
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+       if (local->func->dev_close && local->func->dev_close(local))
+               return 0;
+
+       if (dev == local->dev) {
+               local->func->hw_shutdown(dev, HOSTAP_HW_ENABLE_CMDCOMPL);
+       }
+
+       if (netif_running(dev)) {
+               netif_stop_queue(dev);
+               netif_device_detach(dev);
+       }
+
+       flush_scheduled_work();
+
+       module_put(local->hw_module);
+
+       local->num_dev_open--;
+
+       if (dev != local->dev && local->dev->flags & IFF_UP &&
+           local->master_dev_auto_open && local->num_dev_open == 1) {
+               /* Close master radio interface automatically if it was also
+                * opened automatically and we are now closing the last
+                * remaining non-master device. */
+               dev_close(local->dev);
+       }
+
+       return 0;
+}
+
+
+static int prism2_open(struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       PDEBUG(DEBUG_FLOW, "%s: prism2_open\n", dev->name);
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (local->no_pri) {
+               printk(KERN_DEBUG "%s: could not set interface UP - no PRI "
+                      "f/w\n", dev->name);
+               return 1;
+       }
+
+       if ((local->func->card_present && !local->func->card_present(local)) ||
+           local->hw_downloading)
+               return -ENODEV;
+
+       if (local->func->dev_open && local->func->dev_open(local))
+               return 1;
+
+       if (!try_module_get(local->hw_module))
+               return -ENODEV;
+       local->num_dev_open++;
+
+       if (!local->dev_enabled && local->func->hw_enable(dev, 1)) {
+               printk(KERN_WARNING "%s: could not enable MAC port\n",
+                      dev->name);
+               prism2_close(dev);
+               return 1;
+       }
+       if (!local->dev_enabled)
+               prism2_callback(local, PRISM2_CALLBACK_ENABLE);
+       local->dev_enabled = 1;
+
+       if (dev != local->dev && !(local->dev->flags & IFF_UP)) {
+               /* Master radio interface is needed for all operation, so open
+                * it automatically when any virtual net_device is opened. */
+               local->master_dev_auto_open = 1;
+               dev_open(local->dev);
+       }
+
+       netif_device_attach(dev);
+       netif_start_queue(dev);
+
+       return 0;
+}
+
+
+static int prism2_set_mac_address(struct net_device *dev, void *p)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       struct list_head *ptr;
+       struct sockaddr *addr = p;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (local->func->set_rid(dev, HFA384X_RID_CNFOWNMACADDR, addr->sa_data,
+                                ETH_ALEN) < 0 || local->func->reset_port(dev))
+               return -EINVAL;
+
+       read_lock_bh(&local->iface_lock);
+       list_for_each(ptr, &local->hostap_interfaces) {
+               iface = list_entry(ptr, struct hostap_interface, list);
+               memcpy(iface->dev->dev_addr, addr->sa_data, ETH_ALEN);
+       }
+       memcpy(local->dev->dev_addr, addr->sa_data, ETH_ALEN);
+       read_unlock_bh(&local->iface_lock);
+
+       return 0;
+}
+
+
+/* TODO: to be further implemented as soon as Prism2 fully supports
+ *       GroupAddresses and correct documentation is available */
+void hostap_set_multicast_list_queue(void *data)
+{
+       struct net_device *dev = (struct net_device *) data;
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+       if (hostap_set_word(dev, HFA384X_RID_PROMISCUOUSMODE,
+                           local->is_promisc)) {
+               printk(KERN_INFO "%s: %sabling promiscuous mode failed\n",
+                      dev->name, local->is_promisc ? "en" : "dis");
+       }
+}
+
+
+static void hostap_set_multicast_list(struct net_device *dev)
+{
+#if 0
+       /* FIX: promiscuous mode seems to be causing a lot of problems with
+        * some station firmware versions (FCSErr frames, invalid MACPort, etc.
+        * corrupted incoming frames). This code is now commented out while the
+        * problems are investigated. */
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+       if ((dev->flags & IFF_ALLMULTI) || (dev->flags & IFF_PROMISC)) {
+               local->is_promisc = 1;
+       } else {
+               local->is_promisc = 0;
+       }
+
+       schedule_work(&local->set_multicast_list_queue);
+#endif
+}
+
+
+static int prism2_change_mtu(struct net_device *dev, int new_mtu)
+{
+       if (new_mtu < PRISM2_MIN_MTU || new_mtu > PRISM2_MAX_MTU)
+               return -EINVAL;
+
+       dev->mtu = new_mtu;
+       return 0;
+}
+
+
+static void prism2_tx_timeout(struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       struct hfa384x_regs regs;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       printk(KERN_WARNING "%s Tx timed out! Resetting card\n", dev->name);
+       netif_stop_queue(local->dev);
+
+       local->func->read_regs(dev, &regs);
+       printk(KERN_DEBUG "%s: CMD=%04x EVSTAT=%04x "
+              "OFFSET0=%04x OFFSET1=%04x SWSUPPORT0=%04x\n",
+              dev->name, regs.cmd, regs.evstat, regs.offset0, regs.offset1,
+              regs.swsupport0);
+
+       local->func->schedule_reset(local);
+}
+
+
+void hostap_setup_dev(struct net_device *dev, local_info_t *local,
+                     int main_dev)
+{
+       struct hostap_interface *iface;
+
+       iface = netdev_priv(dev);
+       ether_setup(dev);
+
+       /* kernel callbacks */
+       dev->get_stats = hostap_get_stats;
+       if (iface) {
+               /* Currently, we point to the proper spy_data only on
+                * the main_dev. This could be fixed. Jean II */
+               iface->wireless_data.spy_data = &iface->spy_data;
+               dev->wireless_data = &iface->wireless_data;
+       }
+       dev->wireless_handlers =
+               (struct iw_handler_def *) &hostap_iw_handler_def;
+       dev->do_ioctl = hostap_ioctl;
+       dev->open = prism2_open;
+       dev->stop = prism2_close;
+       dev->hard_start_xmit = hostap_data_start_xmit;
+       dev->set_mac_address = prism2_set_mac_address;
+       dev->set_multicast_list = hostap_set_multicast_list;
+       dev->change_mtu = prism2_change_mtu;
+       dev->tx_timeout = prism2_tx_timeout;
+       dev->watchdog_timeo = TX_TIMEOUT;
+
+       dev->mtu = local->mtu;
+       if (!main_dev) {
+               /* use main radio device queue */
+               dev->tx_queue_len = 0;
+       }
+
+       SET_ETHTOOL_OPS(dev, &prism2_ethtool_ops);
+
+       netif_stop_queue(dev);
+}
+
+
+static int hostap_enable_hostapd(local_info_t *local, int rtnl_locked)
+{
+       struct net_device *dev = local->dev;
+
+       if (local->apdev)
+               return -EEXIST;
+
+       printk(KERN_DEBUG "%s: enabling hostapd mode\n", dev->name);
+
+       local->apdev = hostap_add_interface(local, HOSTAP_INTERFACE_AP,
+                                           rtnl_locked, local->ddev->name,
+                                           "ap");
+       if (local->apdev == NULL)
+               return -ENOMEM;
+
+       local->apdev->hard_start_xmit = hostap_mgmt_start_xmit;
+       local->apdev->type = ARPHRD_IEEE80211;
+       local->apdev->hard_header_parse = hostap_80211_header_parse;
+
+       return 0;
+}
+
+
+static int hostap_disable_hostapd(local_info_t *local, int rtnl_locked)
+{
+       struct net_device *dev = local->dev;
+
+       printk(KERN_DEBUG "%s: disabling hostapd mode\n", dev->name);
+
+       hostap_remove_interface(local->apdev, rtnl_locked, 1);
+       local->apdev = NULL;
+
+       return 0;
+}
+
+
+static int hostap_enable_hostapd_sta(local_info_t *local, int rtnl_locked)
+{
+       struct net_device *dev = local->dev;
+
+       if (local->stadev)
+               return -EEXIST;
+
+       printk(KERN_DEBUG "%s: enabling hostapd STA mode\n", dev->name);
+
+       local->stadev = hostap_add_interface(local, HOSTAP_INTERFACE_STA,
+                                            rtnl_locked, local->ddev->name,
+                                            "sta");
+       if (local->stadev == NULL)
+               return -ENOMEM;
+
+       return 0;
+}
+
+
+static int hostap_disable_hostapd_sta(local_info_t *local, int rtnl_locked)
+{
+       struct net_device *dev = local->dev;
+
+       printk(KERN_DEBUG "%s: disabling hostapd mode\n", dev->name);
+
+       hostap_remove_interface(local->stadev, rtnl_locked, 1);
+       local->stadev = NULL;
+
+       return 0;
+}
+
+
+int hostap_set_hostapd(local_info_t *local, int val, int rtnl_locked)
+{
+       int ret;
+
+       if (val < 0 || val > 1)
+               return -EINVAL;
+
+       if (local->hostapd == val)
+               return 0;
+
+       if (val) {
+               ret = hostap_enable_hostapd(local, rtnl_locked);
+               if (ret == 0)
+                       local->hostapd = 1;
+       } else {
+               local->hostapd = 0;
+               ret = hostap_disable_hostapd(local, rtnl_locked);
+               if (ret != 0)
+                       local->hostapd = 1;
+       }
+
+       return ret;
+}
+
+
+int hostap_set_hostapd_sta(local_info_t *local, int val, int rtnl_locked)
+{
+       int ret;
+
+       if (val < 0 || val > 1)
+               return -EINVAL;
+
+       if (local->hostapd_sta == val)
+               return 0;
+
+       if (val) {
+               ret = hostap_enable_hostapd_sta(local, rtnl_locked);
+               if (ret == 0)
+                       local->hostapd_sta = 1;
+       } else {
+               local->hostapd_sta = 0;
+               ret = hostap_disable_hostapd_sta(local, rtnl_locked);
+               if (ret != 0)
+                       local->hostapd_sta = 1;
+       }
+
+
+       return ret;
+}
+
+
+int prism2_update_comms_qual(struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int ret = 0;
+       struct hfa384x_comms_quality sq;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+       if (!local->sta_fw_ver)
+               ret = -1;
+       else if (local->sta_fw_ver >= PRISM2_FW_VER(1,3,1)) {
+               if (local->func->get_rid(local->dev,
+                                        HFA384X_RID_DBMCOMMSQUALITY,
+                                        &sq, sizeof(sq), 1) >= 0) {
+                       local->comms_qual = (s16) le16_to_cpu(sq.comm_qual);
+                       local->avg_signal = (s16) le16_to_cpu(sq.signal_level);
+                       local->avg_noise = (s16) le16_to_cpu(sq.noise_level);
+                       local->last_comms_qual_update = jiffies;
+               } else
+                       ret = -1;
+       } else {
+               if (local->func->get_rid(local->dev, HFA384X_RID_COMMSQUALITY,
+                                        &sq, sizeof(sq), 1) >= 0) {
+                       local->comms_qual = le16_to_cpu(sq.comm_qual);
+                       local->avg_signal = HFA384X_LEVEL_TO_dBm(
+                               le16_to_cpu(sq.signal_level));
+                       local->avg_noise = HFA384X_LEVEL_TO_dBm(
+                               le16_to_cpu(sq.noise_level));
+                       local->last_comms_qual_update = jiffies;
+               } else
+                       ret = -1;
+       }
+
+       return ret;
+}
+
+
+int prism2_sta_send_mgmt(local_info_t *local, u8 *dst, u16 stype,
+                        u8 *body, size_t bodylen)
+{
+       struct sk_buff *skb;
+       struct hostap_ieee80211_mgmt *mgmt;
+       struct hostap_skb_tx_data *meta;
+       struct net_device *dev = local->dev;
+
+       skb = dev_alloc_skb(IEEE80211_MGMT_HDR_LEN + bodylen);
+       if (skb == NULL)
+               return -ENOMEM;
+
+       mgmt = (struct hostap_ieee80211_mgmt *)
+               skb_put(skb, IEEE80211_MGMT_HDR_LEN);
+       memset(mgmt, 0, IEEE80211_MGMT_HDR_LEN);
+       mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype);
+       memcpy(mgmt->da, dst, ETH_ALEN);
+       memcpy(mgmt->sa, dev->dev_addr, ETH_ALEN);
+       memcpy(mgmt->bssid, dst, ETH_ALEN);
+       if (body)
+               memcpy(skb_put(skb, bodylen), body, bodylen);
+
+       meta = (struct hostap_skb_tx_data *) skb->cb;
+       memset(meta, 0, sizeof(*meta));
+       meta->magic = HOSTAP_SKB_TX_DATA_MAGIC;
+       meta->iface = netdev_priv(dev);
+
+       skb->dev = dev;
+       skb->mac.raw = skb->nh.raw = skb->data;
+       dev_queue_xmit(skb);
+
+       return 0;
+}
+
+
+int prism2_sta_deauth(local_info_t *local, u16 reason)
+{
+       union iwreq_data wrqu;
+       int ret;
+
+       if (local->iw_mode != IW_MODE_INFRA ||
+           memcmp(local->bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) == 0 ||
+           memcmp(local->bssid, "\x44\x44\x44\x44\x44\x44", ETH_ALEN) == 0)
+               return 0;
+
+       reason = cpu_to_le16(reason);
+       ret = prism2_sta_send_mgmt(local, local->bssid, IEEE80211_STYPE_DEAUTH,
+                                  (u8 *) &reason, 2);
+       memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
+       wireless_send_event(local->dev, SIOCGIWAP, &wrqu, NULL);
+       return ret;
+}
+
+
+struct proc_dir_entry *hostap_proc;
+
+static int __init hostap_init(void)
+{
+       if (proc_net != NULL) {
+               hostap_proc = proc_mkdir("hostap", proc_net);
+               if (!hostap_proc)
+                       printk(KERN_WARNING "Failed to mkdir "
+                              "/proc/net/hostap\n");
+       } else
+               hostap_proc = NULL;
+
+       return 0;
+}
+
+
+static void __exit hostap_exit(void)
+{
+       if (hostap_proc != NULL) {
+               hostap_proc = NULL;
+               remove_proc_entry("hostap", proc_net);
+       }
+}
+
+
+EXPORT_SYMBOL(hostap_set_word);
+EXPORT_SYMBOL(hostap_set_string);
+EXPORT_SYMBOL(hostap_get_porttype);
+EXPORT_SYMBOL(hostap_set_encryption);
+EXPORT_SYMBOL(hostap_set_antsel);
+EXPORT_SYMBOL(hostap_set_roaming);
+EXPORT_SYMBOL(hostap_set_auth_algs);
+EXPORT_SYMBOL(hostap_dump_rx_header);
+EXPORT_SYMBOL(hostap_dump_tx_header);
+EXPORT_SYMBOL(hostap_80211_header_parse);
+EXPORT_SYMBOL(hostap_80211_prism_header_parse);
+EXPORT_SYMBOL(hostap_80211_get_hdrlen);
+EXPORT_SYMBOL(hostap_get_stats);
+EXPORT_SYMBOL(hostap_setup_dev);
+EXPORT_SYMBOL(hostap_proc);
+EXPORT_SYMBOL(hostap_set_multicast_list_queue);
+EXPORT_SYMBOL(hostap_set_hostapd);
+EXPORT_SYMBOL(hostap_set_hostapd_sta);
+EXPORT_SYMBOL(hostap_add_interface);
+EXPORT_SYMBOL(hostap_remove_interface);
+EXPORT_SYMBOL(prism2_update_comms_qual);
+
+module_init(hostap_init);
+module_exit(hostap_exit);
diff --git a/drivers/net/wireless/hostap/hostap.h b/drivers/net/wireless/hostap/hostap.h
new file mode 100644 (file)
index 0000000..5fac89b
--- /dev/null
@@ -0,0 +1,57 @@
+#ifndef HOSTAP_H
+#define HOSTAP_H
+
+/* hostap.c */
+
+extern struct proc_dir_entry *hostap_proc;
+
+u16 hostap_tx_callback_register(local_info_t *local,
+                               void (*func)(struct sk_buff *, int ok, void *),
+                               void *data);
+int hostap_tx_callback_unregister(local_info_t *local, u16 idx);
+int hostap_set_word(struct net_device *dev, int rid, u16 val);
+int hostap_set_string(struct net_device *dev, int rid, const char *val);
+u16 hostap_get_porttype(local_info_t *local);
+int hostap_set_encryption(local_info_t *local);
+int hostap_set_antsel(local_info_t *local);
+int hostap_set_roaming(local_info_t *local);
+int hostap_set_auth_algs(local_info_t *local);
+void hostap_dump_rx_header(const char *name,
+                          const struct hfa384x_rx_frame *rx);
+void hostap_dump_tx_header(const char *name,
+                          const struct hfa384x_tx_frame *tx);
+int hostap_80211_header_parse(struct sk_buff *skb, unsigned char *haddr);
+int hostap_80211_prism_header_parse(struct sk_buff *skb, unsigned char *haddr);
+int hostap_80211_get_hdrlen(u16 fc);
+struct net_device_stats *hostap_get_stats(struct net_device *dev);
+void hostap_setup_dev(struct net_device *dev, local_info_t *local,
+                     int main_dev);
+void hostap_set_multicast_list_queue(void *data);
+int hostap_set_hostapd(local_info_t *local, int val, int rtnl_locked);
+int hostap_set_hostapd_sta(local_info_t *local, int val, int rtnl_locked);
+void hostap_cleanup(local_info_t *local);
+void hostap_cleanup_handler(void *data);
+struct net_device * hostap_add_interface(struct local_info *local,
+                                        int type, int rtnl_locked,
+                                        const char *prefix, const char *name);
+void hostap_remove_interface(struct net_device *dev, int rtnl_locked,
+                            int remove_from_list);
+int prism2_update_comms_qual(struct net_device *dev);
+int prism2_sta_send_mgmt(local_info_t *local, u8 *dst, u16 stype,
+                        u8 *body, size_t bodylen);
+int prism2_sta_deauth(local_info_t *local, u16 reason);
+
+
+/* hostap_proc.c */
+
+void hostap_init_proc(local_info_t *local);
+void hostap_remove_proc(local_info_t *local);
+
+
+/* hostap_info.c */
+
+void hostap_info_init(local_info_t *local);
+void hostap_info_process(local_info_t *local, struct sk_buff *skb);
+
+
+#endif /* HOSTAP_H */
diff --git a/drivers/net/wireless/hostap/hostap_80211.h b/drivers/net/wireless/hostap/hostap_80211.h
new file mode 100644 (file)
index 0000000..bf506f5
--- /dev/null
@@ -0,0 +1,96 @@
+#ifndef HOSTAP_80211_H
+#define HOSTAP_80211_H
+
+struct hostap_ieee80211_mgmt {
+       u16 frame_control;
+       u16 duration;
+       u8 da[6];
+       u8 sa[6];
+       u8 bssid[6];
+       u16 seq_ctrl;
+       union {
+               struct {
+                       u16 auth_alg;
+                       u16 auth_transaction;
+                       u16 status_code;
+                       /* possibly followed by Challenge text */
+                       u8 variable[0];
+               } __attribute__ ((packed)) auth;
+               struct {
+                       u16 reason_code;
+               } __attribute__ ((packed)) deauth;
+               struct {
+                       u16 capab_info;
+                       u16 listen_interval;
+                       /* followed by SSID and Supported rates */
+                       u8 variable[0];
+               } __attribute__ ((packed)) assoc_req;
+               struct {
+                       u16 capab_info;
+                       u16 status_code;
+                       u16 aid;
+                       /* followed by Supported rates */
+                       u8 variable[0];
+               } __attribute__ ((packed)) assoc_resp, reassoc_resp;
+               struct {
+                       u16 capab_info;
+                       u16 listen_interval;
+                       u8 current_ap[6];
+                       /* followed by SSID and Supported rates */
+                       u8 variable[0];
+               } __attribute__ ((packed)) reassoc_req;
+               struct {
+                       u16 reason_code;
+               } __attribute__ ((packed)) disassoc;
+               struct {
+               } __attribute__ ((packed)) probe_req;
+               struct {
+                       u8 timestamp[8];
+                       u16 beacon_int;
+                       u16 capab_info;
+                       /* followed by some of SSID, Supported rates,
+                        * FH Params, DS Params, CF Params, IBSS Params, TIM */
+                       u8 variable[0];
+               } __attribute__ ((packed)) beacon, probe_resp;
+       } u;
+} __attribute__ ((packed));
+
+
+#define IEEE80211_MGMT_HDR_LEN 24
+#define IEEE80211_DATA_HDR3_LEN 24
+#define IEEE80211_DATA_HDR4_LEN 30
+
+
+struct hostap_80211_rx_status {
+       u32 mac_time;
+       u8 signal;
+       u8 noise;
+       u16 rate; /* in 100 kbps */
+};
+
+
+void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
+                    struct hostap_80211_rx_status *rx_stats);
+
+
+/* prism2_rx_80211 'type' argument */
+enum {
+       PRISM2_RX_MONITOR, PRISM2_RX_MGMT, PRISM2_RX_NON_ASSOC,
+       PRISM2_RX_NULLFUNC_ACK
+};
+
+int prism2_rx_80211(struct net_device *dev, struct sk_buff *skb,
+                   struct hostap_80211_rx_status *rx_stats, int type);
+void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
+                    struct hostap_80211_rx_status *rx_stats);
+void hostap_dump_rx_80211(const char *name, struct sk_buff *skb,
+                         struct hostap_80211_rx_status *rx_stats);
+
+void hostap_dump_tx_80211(const char *name, struct sk_buff *skb);
+int hostap_data_start_xmit(struct sk_buff *skb, struct net_device *dev);
+int hostap_mgmt_start_xmit(struct sk_buff *skb, struct net_device *dev);
+struct sk_buff * hostap_tx_encrypt(struct sk_buff *skb,
+                                  struct ieee80211_crypt_data *crypt);
+int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev);
+
+#endif /* HOSTAP_80211_H */
diff --git a/drivers/net/wireless/hostap/hostap_80211_rx.c b/drivers/net/wireless/hostap/hostap_80211_rx.c
new file mode 100644 (file)
index 0000000..b050124
--- /dev/null
@@ -0,0 +1,1091 @@
+#include <linux/etherdevice.h>
+
+#include "hostap_80211.h"
+#include "hostap.h"
+
+void hostap_dump_rx_80211(const char *name, struct sk_buff *skb,
+                         struct hostap_80211_rx_status *rx_stats)
+{
+       struct ieee80211_hdr *hdr;
+       u16 fc;
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+
+       printk(KERN_DEBUG "%s: RX signal=%d noise=%d rate=%d len=%d "
+              "jiffies=%ld\n",
+              name, rx_stats->signal, rx_stats->noise, rx_stats->rate,
+              skb->len, jiffies);
+
+       if (skb->len < 2)
+               return;
+
+       fc = le16_to_cpu(hdr->frame_ctl);
+       printk(KERN_DEBUG "   FC=0x%04x (type=%d:%d)%s%s",
+              fc, WLAN_FC_GET_TYPE(fc) >> 2, WLAN_FC_GET_STYPE(fc) >> 4,
+              fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "",
+              fc & IEEE80211_FCTL_FROMDS ? " [FromDS]" : "");
+
+       if (skb->len < IEEE80211_DATA_HDR3_LEN) {
+               printk("\n");
+               return;
+       }
+
+       printk(" dur=0x%04x seq=0x%04x\n", le16_to_cpu(hdr->duration_id),
+              le16_to_cpu(hdr->seq_ctl));
+
+       printk(KERN_DEBUG "   A1=" MACSTR " A2=" MACSTR " A3=" MACSTR,
+              MAC2STR(hdr->addr1), MAC2STR(hdr->addr2), MAC2STR(hdr->addr3));
+       if (skb->len >= 30)
+               printk(" A4=" MACSTR, MAC2STR(hdr->addr4));
+       printk("\n");
+}
+
+
+/* Send RX frame to netif with 802.11 (and possible prism) header.
+ * Called from hardware or software IRQ context. */
+int prism2_rx_80211(struct net_device *dev, struct sk_buff *skb,
+                   struct hostap_80211_rx_status *rx_stats, int type)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int hdrlen, phdrlen, head_need, tail_need;
+       u16 fc;
+       int prism_header, ret;
+       struct ieee80211_hdr *hdr;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+       dev->last_rx = jiffies;
+
+       if (dev->type == ARPHRD_IEEE80211_PRISM) {
+               if (local->monitor_type == PRISM2_MONITOR_PRISM) {
+                       prism_header = 1;
+                       phdrlen = sizeof(struct linux_wlan_ng_prism_hdr);
+               } else { /* local->monitor_type == PRISM2_MONITOR_CAPHDR */
+                       prism_header = 2;
+                       phdrlen = sizeof(struct linux_wlan_ng_cap_hdr);
+               }
+       } else {
+               prism_header = 0;
+               phdrlen = 0;
+       }
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       fc = le16_to_cpu(hdr->frame_ctl);
+
+       if (type == PRISM2_RX_MGMT && (fc & IEEE80211_FCTL_VERS)) {
+               printk(KERN_DEBUG "%s: dropped management frame with header "
+                      "version %d\n", dev->name, fc & IEEE80211_FCTL_VERS);
+               dev_kfree_skb_any(skb);
+               return 0;
+       }
+
+       hdrlen = hostap_80211_get_hdrlen(fc);
+
+       /* check if there is enough room for extra data; if not, expand skb
+        * buffer to be large enough for the changes */
+       head_need = phdrlen;
+       tail_need = 0;
+#ifdef PRISM2_ADD_BOGUS_CRC
+       tail_need += 4;
+#endif /* PRISM2_ADD_BOGUS_CRC */
+
+       head_need -= skb_headroom(skb);
+       tail_need -= skb_tailroom(skb);
+
+       if (head_need > 0 || tail_need > 0) {
+               if (pskb_expand_head(skb, head_need > 0 ? head_need : 0,
+                                    tail_need > 0 ? tail_need : 0,
+                                    GFP_ATOMIC)) {
+                       printk(KERN_DEBUG "%s: prism2_rx_80211 failed to "
+                              "reallocate skb buffer\n", dev->name);
+                       dev_kfree_skb_any(skb);
+                       return 0;
+               }
+       }
+
+       /* We now have an skb with enough head and tail room, so just insert
+        * the extra data */
+
+#ifdef PRISM2_ADD_BOGUS_CRC
+       memset(skb_put(skb, 4), 0xff, 4); /* Prism2 strips CRC */
+#endif /* PRISM2_ADD_BOGUS_CRC */
+
+       if (prism_header == 1) {
+               struct linux_wlan_ng_prism_hdr *hdr;
+               hdr = (struct linux_wlan_ng_prism_hdr *)
+                       skb_push(skb, phdrlen);
+               memset(hdr, 0, phdrlen);
+               hdr->msgcode = LWNG_CAP_DID_BASE;
+               hdr->msglen = sizeof(*hdr);
+               memcpy(hdr->devname, dev->name, sizeof(hdr->devname));
+#define LWNG_SETVAL(f,i,s,l,d) \
+hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \
+hdr->f.status = s; hdr->f.len = l; hdr->f.data = d
+               LWNG_SETVAL(hosttime, 1, 0, 4, jiffies);
+               LWNG_SETVAL(mactime, 2, 0, 4, rx_stats->mac_time);
+               LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0);
+               LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0);
+               LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0);
+               LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal);
+               LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise);
+               LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5);
+               LWNG_SETVAL(istx, 9, 0, 4, 0);
+               LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen);
+#undef LWNG_SETVAL
+       } else if (prism_header == 2) {
+               struct linux_wlan_ng_cap_hdr *hdr;
+               hdr = (struct linux_wlan_ng_cap_hdr *)
+                       skb_push(skb, phdrlen);
+               memset(hdr, 0, phdrlen);
+               hdr->version    = htonl(LWNG_CAPHDR_VERSION);
+               hdr->length     = htonl(phdrlen);
+               hdr->mactime    = __cpu_to_be64(rx_stats->mac_time);
+               hdr->hosttime   = __cpu_to_be64(jiffies);
+               hdr->phytype    = htonl(4); /* dss_dot11_b */
+               hdr->channel    = htonl(local->channel);
+               hdr->datarate   = htonl(rx_stats->rate);
+               hdr->antenna    = htonl(0); /* unknown */
+               hdr->priority   = htonl(0); /* unknown */
+               hdr->ssi_type   = htonl(3); /* raw */
+               hdr->ssi_signal = htonl(rx_stats->signal);
+               hdr->ssi_noise  = htonl(rx_stats->noise);
+               hdr->preamble   = htonl(0); /* unknown */
+               hdr->encoding   = htonl(1); /* cck */
+       }
+
+       ret = skb->len - phdrlen;
+       skb->dev = dev;
+       skb->mac.raw = skb->data;
+       skb_pull(skb, hdrlen);
+       if (prism_header)
+               skb_pull(skb, phdrlen);
+       skb->pkt_type = PACKET_OTHERHOST;
+       skb->protocol = __constant_htons(ETH_P_802_2);
+       memset(skb->cb, 0, sizeof(skb->cb));
+       netif_rx(skb);
+
+       return ret;
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static void monitor_rx(struct net_device *dev, struct sk_buff *skb,
+                      struct hostap_80211_rx_status *rx_stats)
+{
+       struct net_device_stats *stats;
+       int len;
+
+       len = prism2_rx_80211(dev, skb, rx_stats, PRISM2_RX_MONITOR);
+       stats = hostap_get_stats(dev);
+       stats->rx_packets++;
+       stats->rx_bytes += len;
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static struct prism2_frag_entry *
+prism2_frag_cache_find(local_info_t *local, unsigned int seq,
+                      unsigned int frag, u8 *src, u8 *dst)
+{
+       struct prism2_frag_entry *entry;
+       int i;
+
+       for (i = 0; i < PRISM2_FRAG_CACHE_LEN; i++) {
+               entry = &local->frag_cache[i];
+               if (entry->skb != NULL &&
+                   time_after(jiffies, entry->first_frag_time + 2 * HZ)) {
+                       printk(KERN_DEBUG "%s: expiring fragment cache entry "
+                              "seq=%u last_frag=%u\n",
+                              local->dev->name, entry->seq, entry->last_frag);
+                       dev_kfree_skb(entry->skb);
+                       entry->skb = NULL;
+               }
+
+               if (entry->skb != NULL && entry->seq == seq &&
+                   (entry->last_frag + 1 == frag || frag == -1) &&
+                   memcmp(entry->src_addr, src, ETH_ALEN) == 0 &&
+                   memcmp(entry->dst_addr, dst, ETH_ALEN) == 0)
+                       return entry;
+       }
+
+       return NULL;
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static struct sk_buff *
+prism2_frag_cache_get(local_info_t *local, struct ieee80211_hdr *hdr)
+{
+       struct sk_buff *skb = NULL;
+       u16 sc;
+       unsigned int frag, seq;
+       struct prism2_frag_entry *entry;
+
+       sc = le16_to_cpu(hdr->seq_ctl);
+       frag = WLAN_GET_SEQ_FRAG(sc);
+       seq = WLAN_GET_SEQ_SEQ(sc) >> 4;
+
+       if (frag == 0) {
+               /* Reserve enough space to fit maximum frame length */
+               skb = dev_alloc_skb(local->dev->mtu +
+                                   sizeof(struct ieee80211_hdr) +
+                                   8 /* LLC */ +
+                                   2 /* alignment */ +
+                                   8 /* WEP */ + ETH_ALEN /* WDS */);
+               if (skb == NULL)
+                       return NULL;
+
+               entry = &local->frag_cache[local->frag_next_idx];
+               local->frag_next_idx++;
+               if (local->frag_next_idx >= PRISM2_FRAG_CACHE_LEN)
+                       local->frag_next_idx = 0;
+
+               if (entry->skb != NULL)
+                       dev_kfree_skb(entry->skb);
+
+               entry->first_frag_time = jiffies;
+               entry->seq = seq;
+               entry->last_frag = frag;
+               entry->skb = skb;
+               memcpy(entry->src_addr, hdr->addr2, ETH_ALEN);
+               memcpy(entry->dst_addr, hdr->addr1, ETH_ALEN);
+       } else {
+               /* received a fragment of a frame for which the head fragment
+                * should have already been received */
+               entry = prism2_frag_cache_find(local, seq, frag, hdr->addr2,
+                                              hdr->addr1);
+               if (entry != NULL) {
+                       entry->last_frag = frag;
+                       skb = entry->skb;
+               }
+       }
+
+       return skb;
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static int prism2_frag_cache_invalidate(local_info_t *local,
+                                       struct ieee80211_hdr *hdr)
+{
+       u16 sc;
+       unsigned int seq;
+       struct prism2_frag_entry *entry;
+
+       sc = le16_to_cpu(hdr->seq_ctl);
+       seq = WLAN_GET_SEQ_SEQ(sc) >> 4;
+
+       entry = prism2_frag_cache_find(local, seq, -1, hdr->addr2, hdr->addr1);
+
+       if (entry == NULL) {
+               printk(KERN_DEBUG "%s: could not invalidate fragment cache "
+                      "entry (seq=%u)\n",
+                      local->dev->name, seq);
+               return -1;
+       }
+
+       entry->skb = NULL;
+       return 0;
+}
+
+
+static struct hostap_bss_info *__hostap_get_bss(local_info_t *local, u8 *bssid,
+                                               u8 *ssid, size_t ssid_len)
+{
+       struct list_head *ptr;
+       struct hostap_bss_info *bss;
+
+       list_for_each(ptr, &local->bss_list) {
+               bss = list_entry(ptr, struct hostap_bss_info, list);
+               if (memcmp(bss->bssid, bssid, ETH_ALEN) == 0 &&
+                   (ssid == NULL ||
+                    (ssid_len == bss->ssid_len &&
+                     memcmp(ssid, bss->ssid, ssid_len) == 0))) {
+                       list_move(&bss->list, &local->bss_list);
+                       return bss;
+               }
+       }
+
+       return NULL;
+}
+
+
+static struct hostap_bss_info *__hostap_add_bss(local_info_t *local, u8 *bssid,
+                                               u8 *ssid, size_t ssid_len)
+{
+       struct hostap_bss_info *bss;
+
+       if (local->num_bss_info >= HOSTAP_MAX_BSS_COUNT) {
+               bss = list_entry(local->bss_list.prev,
+                                struct hostap_bss_info, list);
+               list_del(&bss->list);
+               local->num_bss_info--;
+       } else {
+               bss = (struct hostap_bss_info *)
+                       kmalloc(sizeof(*bss), GFP_ATOMIC);
+               if (bss == NULL)
+                       return NULL;
+       }
+
+       memset(bss, 0, sizeof(*bss));
+       memcpy(bss->bssid, bssid, ETH_ALEN);
+       memcpy(bss->ssid, ssid, ssid_len);
+       bss->ssid_len = ssid_len;
+       local->num_bss_info++;
+       list_add(&bss->list, &local->bss_list);
+       return bss;
+}
+
+
+static void __hostap_expire_bss(local_info_t *local)
+{
+       struct hostap_bss_info *bss;
+
+       while (local->num_bss_info > 0) {
+               bss = list_entry(local->bss_list.prev,
+                                struct hostap_bss_info, list);
+               if (!time_after(jiffies, bss->last_update + 60 * HZ))
+                       break;
+
+               list_del(&bss->list);
+               local->num_bss_info--;
+               kfree(bss);
+       }
+}
+
+
+/* Both IEEE 802.11 Beacon and Probe Response frames have similar structure, so
+ * the same routine can be used to parse both of them. */
+static void hostap_rx_sta_beacon(local_info_t *local, struct sk_buff *skb,
+                                int stype)
+{
+       struct hostap_ieee80211_mgmt *mgmt;
+       int left, chan = 0;
+       u8 *pos;
+       u8 *ssid = NULL, *wpa = NULL, *rsn = NULL;
+       size_t ssid_len = 0, wpa_len = 0, rsn_len = 0;
+       struct hostap_bss_info *bss;
+
+       if (skb->len < IEEE80211_MGMT_HDR_LEN + sizeof(mgmt->u.beacon))
+               return;
+
+       mgmt = (struct hostap_ieee80211_mgmt *) skb->data;
+       pos = mgmt->u.beacon.variable;
+       left = skb->len - (pos - skb->data);
+
+       while (left >= 2) {
+               if (2 + pos[1] > left)
+                       return; /* parse failed */
+               switch (*pos) {
+               case WLAN_EID_SSID:
+                       ssid = pos + 2;
+                       ssid_len = pos[1];
+                       break;
+               case WLAN_EID_GENERIC:
+                       if (pos[1] >= 4 &&
+                           pos[2] == 0x00 && pos[3] == 0x50 &&
+                           pos[4] == 0xf2 && pos[5] == 1) {
+                               wpa = pos;
+                               wpa_len = pos[1] + 2;
+                       }
+                       break;
+               case WLAN_EID_RSN:
+                       rsn = pos;
+                       rsn_len = pos[1] + 2;
+                       break;
+               case WLAN_EID_DS_PARAMS:
+                       if (pos[1] >= 1)
+                               chan = pos[2];
+                       break;
+               }
+               left -= 2 + pos[1];
+               pos += 2 + pos[1];
+       }
+
+       if (wpa_len > MAX_WPA_IE_LEN)
+               wpa_len = MAX_WPA_IE_LEN;
+       if (rsn_len > MAX_WPA_IE_LEN)
+               rsn_len = MAX_WPA_IE_LEN;
+       if (ssid_len > sizeof(bss->ssid))
+               ssid_len = sizeof(bss->ssid);
+
+       spin_lock(&local->lock);
+       bss = __hostap_get_bss(local, mgmt->bssid, ssid, ssid_len);
+       if (bss == NULL)
+               bss = __hostap_add_bss(local, mgmt->bssid, ssid, ssid_len);
+       if (bss) {
+               bss->last_update = jiffies;
+               bss->count++;
+               bss->capab_info = le16_to_cpu(mgmt->u.beacon.capab_info);
+               if (wpa) {
+                       memcpy(bss->wpa_ie, wpa, wpa_len);
+                       bss->wpa_ie_len = wpa_len;
+               } else
+                       bss->wpa_ie_len = 0;
+               if (rsn) {
+                       memcpy(bss->rsn_ie, rsn, rsn_len);
+                       bss->rsn_ie_len = rsn_len;
+               } else
+                       bss->rsn_ie_len = 0;
+               bss->chan = chan;
+       }
+       __hostap_expire_bss(local);
+       spin_unlock(&local->lock);
+}
+
+
+static inline int
+hostap_rx_frame_mgmt(local_info_t *local, struct sk_buff *skb,
+                    struct hostap_80211_rx_status *rx_stats, u16 type,
+                    u16 stype)
+{
+       if (local->iw_mode == IW_MODE_MASTER) {
+               hostap_update_sta_ps(local, (struct ieee80211_hdr *)
+                                    skb->data);
+       }
+
+       if (local->hostapd && type == IEEE80211_FTYPE_MGMT) {
+               if (stype == IEEE80211_STYPE_BEACON &&
+                   local->iw_mode == IW_MODE_MASTER) {
+                       struct sk_buff *skb2;
+                       /* Process beacon frames also in kernel driver to
+                        * update STA(AP) table statistics */
+                       skb2 = skb_clone(skb, GFP_ATOMIC);
+                       if (skb2)
+                               hostap_rx(skb2->dev, skb2, rx_stats);
+               }
+
+               /* send management frames to the user space daemon for
+                * processing */
+               local->apdevstats.rx_packets++;
+               local->apdevstats.rx_bytes += skb->len;
+               if (local->apdev == NULL)
+                       return -1;
+               prism2_rx_80211(local->apdev, skb, rx_stats, PRISM2_RX_MGMT);
+               return 0;
+       }
+
+       if (local->iw_mode == IW_MODE_MASTER) {
+               if (type != IEEE80211_FTYPE_MGMT &&
+                   type != IEEE80211_FTYPE_CTL) {
+                       printk(KERN_DEBUG "%s: unknown management frame "
+                              "(type=0x%02x, stype=0x%02x) dropped\n",
+                              skb->dev->name, type >> 2, stype >> 4);
+                       return -1;
+               }
+
+               hostap_rx(skb->dev, skb, rx_stats);
+               return 0;
+       } else if (type == IEEE80211_FTYPE_MGMT &&
+                  (stype == IEEE80211_STYPE_BEACON ||
+                   stype == IEEE80211_STYPE_PROBE_RESP)) {
+               hostap_rx_sta_beacon(local, skb, stype);
+               return -1;
+       } else if (type == IEEE80211_FTYPE_MGMT &&
+                  (stype == IEEE80211_STYPE_ASSOC_RESP ||
+                   stype == IEEE80211_STYPE_REASSOC_RESP)) {
+               /* Ignore (Re)AssocResp silently since these are not currently
+                * needed but are still received when WPA/RSN mode is enabled.
+                */
+               return -1;
+       } else {
+               printk(KERN_DEBUG "%s: hostap_rx_frame_mgmt: dropped unhandled"
+                      " management frame in non-Host AP mode (type=%d:%d)\n",
+                      skb->dev->name, type >> 2, stype >> 4);
+               return -1;
+       }
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static inline struct net_device *prism2_rx_get_wds(local_info_t *local,
+                                                  u8 *addr)
+{
+       struct hostap_interface *iface = NULL;
+       struct list_head *ptr;
+
+       read_lock_bh(&local->iface_lock);
+       list_for_each(ptr, &local->hostap_interfaces) {
+               iface = list_entry(ptr, struct hostap_interface, list);
+               if (iface->type == HOSTAP_INTERFACE_WDS &&
+                   memcmp(iface->u.wds.remote_addr, addr, ETH_ALEN) == 0)
+                       break;
+               iface = NULL;
+       }
+       read_unlock_bh(&local->iface_lock);
+
+       return iface ? iface->dev : NULL;
+}
+
+
+static inline int
+hostap_rx_frame_wds(local_info_t *local, struct ieee80211_hdr *hdr,
+                   u16 fc, struct net_device **wds)
+{
+       /* FIX: is this really supposed to accept WDS frames only in Master
+        * mode? What about Repeater or Managed with WDS frames? */
+       if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) !=
+           (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS) &&
+           (local->iw_mode != IW_MODE_MASTER || !(fc & IEEE80211_FCTL_TODS)))
+               return 0; /* not a WDS frame */
+
+       /* Possible WDS frame: either IEEE 802.11 compliant (if FromDS)
+        * or own non-standard frame with 4th address after payload */
+       if (memcmp(hdr->addr1, local->dev->dev_addr, ETH_ALEN) != 0 &&
+           (hdr->addr1[0] != 0xff || hdr->addr1[1] != 0xff ||
+            hdr->addr1[2] != 0xff || hdr->addr1[3] != 0xff ||
+            hdr->addr1[4] != 0xff || hdr->addr1[5] != 0xff)) {
+               /* RA (or BSSID) is not ours - drop */
+               PDEBUG(DEBUG_EXTRA, "%s: received WDS frame with "
+                      "not own or broadcast %s=" MACSTR "\n",
+                      local->dev->name,
+                      fc & IEEE80211_FCTL_FROMDS ? "RA" : "BSSID",
+                      MAC2STR(hdr->addr1));
+               return -1;
+       }
+
+       /* check if the frame came from a registered WDS connection */
+       *wds = prism2_rx_get_wds(local, hdr->addr2);
+       if (*wds == NULL && fc & IEEE80211_FCTL_FROMDS &&
+           (local->iw_mode != IW_MODE_INFRA ||
+            !(local->wds_type & HOSTAP_WDS_AP_CLIENT) ||
+            memcmp(hdr->addr2, local->bssid, ETH_ALEN) != 0)) {
+               /* require that WDS link has been registered with TA or the
+                * frame is from current AP when using 'AP client mode' */
+               PDEBUG(DEBUG_EXTRA, "%s: received WDS[4 addr] frame "
+                      "from unknown TA=" MACSTR "\n",
+                      local->dev->name, MAC2STR(hdr->addr2));
+               if (local->ap && local->ap->autom_ap_wds)
+                       hostap_wds_link_oper(local, hdr->addr2, WDS_ADD);
+               return -1;
+       }
+
+       if (*wds && !(fc & IEEE80211_FCTL_FROMDS) && local->ap &&
+           hostap_is_sta_assoc(local->ap, hdr->addr2)) {
+               /* STA is actually associated with us even though it has a
+                * registered WDS link. Assume it is in 'AP client' mode.
+                * Since this is a 3-addr frame, assume it is not (bogus) WDS
+                * frame and process it like any normal ToDS frame from
+                * associated STA. */
+               *wds = NULL;
+       }
+
+       return 0;
+}
+
+
+static int hostap_is_eapol_frame(local_info_t *local, struct sk_buff *skb)
+{
+       struct net_device *dev = local->dev;
+       u16 fc, ethertype;
+       struct ieee80211_hdr *hdr;
+       u8 *pos;
+
+       if (skb->len < 24)
+               return 0;
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       fc = le16_to_cpu(hdr->frame_ctl);
+
+       /* check that the frame is unicast frame to us */
+       if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
+           IEEE80211_FCTL_TODS &&
+           memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0 &&
+           memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0) {
+               /* ToDS frame with own addr BSSID and DA */
+       } else if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
+                  IEEE80211_FCTL_FROMDS &&
+                  memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0) {
+               /* FromDS frame with own addr as DA */
+       } else
+               return 0;
+
+       if (skb->len < 24 + 8)
+               return 0;
+
+       /* check for port access entity Ethernet type */
+       pos = skb->data + 24;
+       ethertype = (pos[6] << 8) | pos[7];
+       if (ethertype == ETH_P_PAE)
+               return 1;
+
+       return 0;
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static inline int
+hostap_rx_frame_decrypt(local_info_t *local, struct sk_buff *skb,
+                       struct ieee80211_crypt_data *crypt)
+{
+       struct ieee80211_hdr *hdr;
+       int res, hdrlen;
+
+       if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
+               return 0;
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       hdrlen = hostap_80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
+
+       if (local->tkip_countermeasures &&
+           strcmp(crypt->ops->name, "TKIP") == 0) {
+               if (net_ratelimit()) {
+                       printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
+                              "received packet from " MACSTR "\n",
+                              local->dev->name, MAC2STR(hdr->addr2));
+               }
+               return -1;
+       }
+
+       atomic_inc(&crypt->refcnt);
+       res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
+       atomic_dec(&crypt->refcnt);
+       if (res < 0) {
+               printk(KERN_DEBUG "%s: decryption failed (SA=" MACSTR
+                      ") res=%d\n",
+                      local->dev->name, MAC2STR(hdr->addr2), res);
+               local->comm_tallies.rx_discards_wep_undecryptable++;
+               return -1;
+       }
+
+       return res;
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static inline int
+hostap_rx_frame_decrypt_msdu(local_info_t *local, struct sk_buff *skb,
+                            int keyidx, struct ieee80211_crypt_data *crypt)
+{
+       struct ieee80211_hdr *hdr;
+       int res, hdrlen;
+
+       if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
+               return 0;
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       hdrlen = hostap_80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
+
+       atomic_inc(&crypt->refcnt);
+       res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
+       atomic_dec(&crypt->refcnt);
+       if (res < 0) {
+               printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed"
+                      " (SA=" MACSTR " keyidx=%d)\n",
+                      local->dev->name, MAC2STR(hdr->addr2), keyidx);
+               return -1;
+       }
+
+       return 0;
+}
+
+
+/* All received frames are sent to this function. @skb contains the frame in
+ * IEEE 802.11 format, i.e., in the format it was sent over air.
+ * This function is called only as a tasklet (software IRQ). */
+void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
+                    struct hostap_80211_rx_status *rx_stats)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       struct ieee80211_hdr *hdr;
+       size_t hdrlen;
+       u16 fc, type, stype, sc;
+       struct net_device *wds = NULL;
+       struct net_device_stats *stats;
+       unsigned int frag;
+       u8 *payload;
+       struct sk_buff *skb2 = NULL;
+       u16 ethertype;
+       int frame_authorized = 0;
+       int from_assoc_ap = 0;
+       u8 dst[ETH_ALEN];
+       u8 src[ETH_ALEN];
+       struct ieee80211_crypt_data *crypt = NULL;
+       void *sta = NULL;
+       int keyidx = 0;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+       iface->stats.rx_packets++;
+       iface->stats.rx_bytes += skb->len;
+
+       /* dev is the master radio device; change this to be the default
+        * virtual interface (this may be changed to WDS device below) */
+       dev = local->ddev;
+       iface = netdev_priv(dev);
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       stats = hostap_get_stats(dev);
+
+       if (skb->len < 10)
+               goto rx_dropped;
+
+       fc = le16_to_cpu(hdr->frame_ctl);
+       type = WLAN_FC_GET_TYPE(fc);
+       stype = WLAN_FC_GET_STYPE(fc);
+       sc = le16_to_cpu(hdr->seq_ctl);
+       frag = WLAN_GET_SEQ_FRAG(sc);
+       hdrlen = hostap_80211_get_hdrlen(fc);
+
+       /* Put this code here so that we avoid duplicating it in all
+        * Rx paths. - Jean II */
+#ifdef IW_WIRELESS_SPY         /* defined in iw_handler.h */
+       /* If spy monitoring on */
+       if (iface->spy_data.spy_number > 0) {
+               struct iw_quality wstats;
+               wstats.level = rx_stats->signal;
+               wstats.noise = rx_stats->noise;
+               wstats.updated = 6;     /* No qual value */
+               /* Update spy records */
+               wireless_spy_update(dev, hdr->addr2, &wstats);
+       }
+#endif /* IW_WIRELESS_SPY */
+       hostap_update_rx_stats(local->ap, hdr, rx_stats);
+
+       if (local->iw_mode == IW_MODE_MONITOR) {
+               monitor_rx(dev, skb, rx_stats);
+               return;
+       }
+
+       if (local->host_decrypt) {
+               int idx = 0;
+               if (skb->len >= hdrlen + 3)
+                       idx = skb->data[hdrlen + 3] >> 6;
+               crypt = local->crypt[idx];
+               sta = NULL;
+
+               /* Use station specific key to override default keys if the
+                * receiver address is a unicast address ("individual RA"). If
+                * bcrx_sta_key parameter is set, station specific key is used
+                * even with broad/multicast targets (this is against IEEE
+                * 802.11, but makes it easier to use different keys with
+                * stations that do not support WEP key mapping). */
+
+               if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key)
+                       (void) hostap_handle_sta_crypto(local, hdr, &crypt,
+                                                       &sta);
+
+               /* allow NULL decrypt to indicate an station specific override
+                * for default encryption */
+               if (crypt && (crypt->ops == NULL ||
+                             crypt->ops->decrypt_mpdu == NULL))
+                       crypt = NULL;
+
+               if (!crypt && (fc & IEEE80211_FCTL_PROTECTED)) {
+#if 0
+                       /* This seems to be triggered by some (multicast?)
+                        * frames from other than current BSS, so just drop the
+                        * frames silently instead of filling system log with
+                        * these reports. */
+                       printk(KERN_DEBUG "%s: WEP decryption failed (not set)"
+                              " (SA=" MACSTR ")\n",
+                              local->dev->name, MAC2STR(hdr->addr2));
+#endif
+                       local->comm_tallies.rx_discards_wep_undecryptable++;
+                       goto rx_dropped;
+               }
+       }
+
+       if (type != IEEE80211_FTYPE_DATA) {
+               if (type == IEEE80211_FTYPE_MGMT &&
+                   stype == IEEE80211_STYPE_AUTH &&
+                   fc & IEEE80211_FCTL_PROTECTED && local->host_decrypt &&
+                   (keyidx = hostap_rx_frame_decrypt(local, skb, crypt)) < 0)
+               {
+                       printk(KERN_DEBUG "%s: failed to decrypt mgmt::auth "
+                              "from " MACSTR "\n", dev->name,
+                              MAC2STR(hdr->addr2));
+                       /* TODO: could inform hostapd about this so that it
+                        * could send auth failure report */
+                       goto rx_dropped;
+               }
+
+               if (hostap_rx_frame_mgmt(local, skb, rx_stats, type, stype))
+                       goto rx_dropped;
+               else
+                       goto rx_exit;
+       }
+
+       /* Data frame - extract src/dst addresses */
+       if (skb->len < IEEE80211_DATA_HDR3_LEN)
+               goto rx_dropped;
+
+       switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
+       case IEEE80211_FCTL_FROMDS:
+               memcpy(dst, hdr->addr1, ETH_ALEN);
+               memcpy(src, hdr->addr3, ETH_ALEN);
+               break;
+       case IEEE80211_FCTL_TODS:
+               memcpy(dst, hdr->addr3, ETH_ALEN);
+               memcpy(src, hdr->addr2, ETH_ALEN);
+               break;
+       case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
+               if (skb->len < IEEE80211_DATA_HDR4_LEN)
+                       goto rx_dropped;
+               memcpy(dst, hdr->addr3, ETH_ALEN);
+               memcpy(src, hdr->addr4, ETH_ALEN);
+               break;
+       case 0:
+               memcpy(dst, hdr->addr1, ETH_ALEN);
+               memcpy(src, hdr->addr2, ETH_ALEN);
+               break;
+       }
+
+       if (hostap_rx_frame_wds(local, hdr, fc, &wds))
+               goto rx_dropped;
+       if (wds) {
+               skb->dev = dev = wds;
+               stats = hostap_get_stats(dev);
+       }
+
+       if (local->iw_mode == IW_MODE_MASTER && !wds &&
+           (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
+           IEEE80211_FCTL_FROMDS &&
+           local->stadev &&
+           memcmp(hdr->addr2, local->assoc_ap_addr, ETH_ALEN) == 0) {
+               /* Frame from BSSID of the AP for which we are a client */
+               skb->dev = dev = local->stadev;
+               stats = hostap_get_stats(dev);
+               from_assoc_ap = 1;
+       }
+
+       dev->last_rx = jiffies;
+
+       if ((local->iw_mode == IW_MODE_MASTER ||
+            local->iw_mode == IW_MODE_REPEAT) &&
+           !from_assoc_ap) {
+               switch (hostap_handle_sta_rx(local, dev, skb, rx_stats,
+                                            wds != NULL)) {
+               case AP_RX_CONTINUE_NOT_AUTHORIZED:
+                       frame_authorized = 0;
+                       break;
+               case AP_RX_CONTINUE:
+                       frame_authorized = 1;
+                       break;
+               case AP_RX_DROP:
+                       goto rx_dropped;
+               case AP_RX_EXIT:
+                       goto rx_exit;
+               }
+       }
+
+       /* Nullfunc frames may have PS-bit set, so they must be passed to
+        * hostap_handle_sta_rx() before being dropped here. */
+       if (stype != IEEE80211_STYPE_DATA &&
+           stype != IEEE80211_STYPE_DATA_CFACK &&
+           stype != IEEE80211_STYPE_DATA_CFPOLL &&
+           stype != IEEE80211_STYPE_DATA_CFACKPOLL) {
+               if (stype != IEEE80211_STYPE_NULLFUNC)
+                       printk(KERN_DEBUG "%s: RX: dropped data frame "
+                              "with no data (type=0x%02x, subtype=0x%02x)\n",
+                              dev->name, type >> 2, stype >> 4);
+               goto rx_dropped;
+       }
+
+       /* skb: hdr + (possibly fragmented, possibly encrypted) payload */
+
+       if (local->host_decrypt && (fc & IEEE80211_FCTL_PROTECTED) &&
+           (keyidx = hostap_rx_frame_decrypt(local, skb, crypt)) < 0)
+               goto rx_dropped;
+       hdr = (struct ieee80211_hdr *) skb->data;
+
+       /* skb: hdr + (possibly fragmented) plaintext payload */
+
+       if (local->host_decrypt && (fc & IEEE80211_FCTL_PROTECTED) &&
+           (frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) {
+               int flen;
+               struct sk_buff *frag_skb =
+                       prism2_frag_cache_get(local, hdr);
+               if (!frag_skb) {
+                       printk(KERN_DEBUG "%s: Rx cannot get skb from "
+                              "fragment cache (morefrag=%d seq=%u frag=%u)\n",
+                              dev->name, (fc & IEEE80211_FCTL_MOREFRAGS) != 0,
+                              WLAN_GET_SEQ_SEQ(sc) >> 4, frag);
+                       goto rx_dropped;
+               }
+
+               flen = skb->len;
+               if (frag != 0)
+                       flen -= hdrlen;
+
+               if (frag_skb->tail + flen > frag_skb->end) {
+                       printk(KERN_WARNING "%s: host decrypted and "
+                              "reassembled frame did not fit skb\n",
+                              dev->name);
+                       prism2_frag_cache_invalidate(local, hdr);
+                       goto rx_dropped;
+               }
+
+               if (frag == 0) {
+                       /* copy first fragment (including full headers) into
+                        * beginning of the fragment cache skb */
+                       memcpy(skb_put(frag_skb, flen), skb->data, flen);
+               } else {
+                       /* append frame payload to the end of the fragment
+                        * cache skb */
+                       memcpy(skb_put(frag_skb, flen), skb->data + hdrlen,
+                              flen);
+               }
+               dev_kfree_skb(skb);
+               skb = NULL;
+
+               if (fc & IEEE80211_FCTL_MOREFRAGS) {
+                       /* more fragments expected - leave the skb in fragment
+                        * cache for now; it will be delivered to upper layers
+                        * after all fragments have been received */
+                       goto rx_exit;
+               }
+
+               /* this was the last fragment and the frame will be
+                * delivered, so remove skb from fragment cache */
+               skb = frag_skb;
+               hdr = (struct ieee80211_hdr *) skb->data;
+               prism2_frag_cache_invalidate(local, hdr);
+       }
+
+       /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
+        * encrypted/authenticated */
+
+       if (local->host_decrypt && (fc & IEEE80211_FCTL_PROTECTED) &&
+           hostap_rx_frame_decrypt_msdu(local, skb, keyidx, crypt))
+               goto rx_dropped;
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !local->open_wep) {
+               if (local->ieee_802_1x &&
+                   hostap_is_eapol_frame(local, skb)) {
+                       /* pass unencrypted EAPOL frames even if encryption is
+                        * configured */
+                       PDEBUG(DEBUG_EXTRA2, "%s: RX: IEEE 802.1X - passing "
+                              "unencrypted EAPOL frame\n", local->dev->name);
+               } else {
+                       printk(KERN_DEBUG "%s: encryption configured, but RX "
+                              "frame not encrypted (SA=" MACSTR ")\n",
+                              local->dev->name, MAC2STR(hdr->addr2));
+                       goto rx_dropped;
+               }
+       }
+
+       if (local->drop_unencrypted && !(fc & IEEE80211_FCTL_PROTECTED) &&
+           !hostap_is_eapol_frame(local, skb)) {
+               if (net_ratelimit()) {
+                       printk(KERN_DEBUG "%s: dropped unencrypted RX data "
+                              "frame from " MACSTR " (drop_unencrypted=1)\n",
+                              dev->name, MAC2STR(hdr->addr2));
+               }
+               goto rx_dropped;
+       }
+
+       /* skb: hdr + (possible reassembled) full plaintext payload */
+
+       payload = skb->data + hdrlen;
+       ethertype = (payload[6] << 8) | payload[7];
+
+       /* If IEEE 802.1X is used, check whether the port is authorized to send
+        * the received frame. */
+       if (local->ieee_802_1x && local->iw_mode == IW_MODE_MASTER) {
+               if (ethertype == ETH_P_PAE) {
+                       PDEBUG(DEBUG_EXTRA2, "%s: RX: IEEE 802.1X frame\n",
+                              dev->name);
+                       if (local->hostapd && local->apdev) {
+                               /* Send IEEE 802.1X frames to the user
+                                * space daemon for processing */
+                               prism2_rx_80211(local->apdev, skb, rx_stats,
+                                               PRISM2_RX_MGMT);
+                               local->apdevstats.rx_packets++;
+                               local->apdevstats.rx_bytes += skb->len;
+                               goto rx_exit;
+                       }
+               } else if (!frame_authorized) {
+                       printk(KERN_DEBUG "%s: dropped frame from "
+                              "unauthorized port (IEEE 802.1X): "
+                              "ethertype=0x%04x\n",
+                              dev->name, ethertype);
+                       goto rx_dropped;
+               }
+       }
+
+       /* convert hdr + possible LLC headers into Ethernet header */
+       if (skb->len - hdrlen >= 8 &&
+           ((memcmp(payload, rfc1042_header, 6) == 0 &&
+             ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
+            memcmp(payload, bridge_tunnel_header, 6) == 0)) {
+               /* remove RFC1042 or Bridge-Tunnel encapsulation and
+                * replace EtherType */
+               skb_pull(skb, hdrlen + 6);
+               memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
+               memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
+       } else {
+               u16 len;
+               /* Leave Ethernet header part of hdr and full payload */
+               skb_pull(skb, hdrlen);
+               len = htons(skb->len);
+               memcpy(skb_push(skb, 2), &len, 2);
+               memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
+               memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
+       }
+
+       if (wds && ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
+                   IEEE80211_FCTL_TODS) &&
+           skb->len >= ETH_HLEN + ETH_ALEN) {
+               /* Non-standard frame: get addr4 from its bogus location after
+                * the payload */
+               memcpy(skb->data + ETH_ALEN,
+                      skb->data + skb->len - ETH_ALEN, ETH_ALEN);
+               skb_trim(skb, skb->len - ETH_ALEN);
+       }
+
+       stats->rx_packets++;
+       stats->rx_bytes += skb->len;
+
+       if (local->iw_mode == IW_MODE_MASTER && !wds &&
+           local->ap->bridge_packets) {
+               if (dst[0] & 0x01) {
+                       /* copy multicast frame both to the higher layers and
+                        * to the wireless media */
+                       local->ap->bridged_multicast++;
+                       skb2 = skb_clone(skb, GFP_ATOMIC);
+                       if (skb2 == NULL)
+                               printk(KERN_DEBUG "%s: skb_clone failed for "
+                                      "multicast frame\n", dev->name);
+               } else if (hostap_is_sta_authorized(local->ap, dst)) {
+                       /* send frame directly to the associated STA using
+                        * wireless media and not passing to higher layers */
+                       local->ap->bridged_unicast++;
+                       skb2 = skb;
+                       skb = NULL;
+               }
+       }
+
+       if (skb2 != NULL) {
+               /* send to wireless media */
+               skb2->protocol = __constant_htons(ETH_P_802_3);
+               skb2->mac.raw = skb2->nh.raw = skb2->data;
+               /* skb2->nh.raw = skb2->data + ETH_HLEN; */
+               skb2->dev = dev;
+               dev_queue_xmit(skb2);
+       }
+
+       if (skb) {
+               skb->protocol = eth_type_trans(skb, dev);
+               memset(skb->cb, 0, sizeof(skb->cb));
+               skb->dev = dev;
+               netif_rx(skb);
+       }
+
+ rx_exit:
+       if (sta)
+               hostap_handle_sta_release(sta);
+       return;
+
+ rx_dropped:
+       dev_kfree_skb(skb);
+
+       stats->rx_dropped++;
+       goto rx_exit;
+}
+
+
+EXPORT_SYMBOL(hostap_80211_rx);
diff --git a/drivers/net/wireless/hostap/hostap_80211_tx.c b/drivers/net/wireless/hostap/hostap_80211_tx.c
new file mode 100644 (file)
index 0000000..6358015
--- /dev/null
@@ -0,0 +1,524 @@
+void hostap_dump_tx_80211(const char *name, struct sk_buff *skb)
+{
+       struct ieee80211_hdr *hdr;
+       u16 fc;
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+
+       printk(KERN_DEBUG "%s: TX len=%d jiffies=%ld\n",
+              name, skb->len, jiffies);
+
+       if (skb->len < 2)
+               return;
+
+       fc = le16_to_cpu(hdr->frame_ctl);
+       printk(KERN_DEBUG "   FC=0x%04x (type=%d:%d)%s%s",
+              fc, WLAN_FC_GET_TYPE(fc) >> 2, WLAN_FC_GET_STYPE(fc) >> 4,
+              fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "",
+              fc & IEEE80211_FCTL_FROMDS ? " [FromDS]" : "");
+
+       if (skb->len < IEEE80211_DATA_HDR3_LEN) {
+               printk("\n");
+               return;
+       }
+
+       printk(" dur=0x%04x seq=0x%04x\n", le16_to_cpu(hdr->duration_id),
+              le16_to_cpu(hdr->seq_ctl));
+
+       printk(KERN_DEBUG "   A1=" MACSTR " A2=" MACSTR " A3=" MACSTR,
+              MAC2STR(hdr->addr1), MAC2STR(hdr->addr2), MAC2STR(hdr->addr3));
+       if (skb->len >= 30)
+               printk(" A4=" MACSTR, MAC2STR(hdr->addr4));
+       printk("\n");
+}
+
+
+/* hard_start_xmit function for data interfaces (wlan#, wlan#wds#, wlan#sta)
+ * Convert Ethernet header into a suitable IEEE 802.11 header depending on
+ * device configuration. */
+int hostap_data_start_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int need_headroom, need_tailroom = 0;
+       struct ieee80211_hdr hdr;
+       u16 fc, ethertype = 0;
+       enum {
+               WDS_NO = 0, WDS_OWN_FRAME, WDS_COMPLIANT_FRAME
+       } use_wds = WDS_NO;
+       u8 *encaps_data;
+       int hdr_len, encaps_len, skip_header_bytes;
+       int to_assoc_ap = 0;
+       struct hostap_skb_tx_data *meta;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (skb->len < ETH_HLEN) {
+               printk(KERN_DEBUG "%s: hostap_data_start_xmit: short skb "
+                      "(len=%d)\n", dev->name, skb->len);
+               kfree_skb(skb);
+               return 0;
+       }
+
+       if (local->ddev != dev) {
+               use_wds = (local->iw_mode == IW_MODE_MASTER &&
+                          !(local->wds_type & HOSTAP_WDS_STANDARD_FRAME)) ?
+                       WDS_OWN_FRAME : WDS_COMPLIANT_FRAME;
+               if (dev == local->stadev) {
+                       to_assoc_ap = 1;
+                       use_wds = WDS_NO;
+               } else if (dev == local->apdev) {
+                       printk(KERN_DEBUG "%s: prism2_tx: trying to use "
+                              "AP device with Ethernet net dev\n", dev->name);
+                       kfree_skb(skb);
+                       return 0;
+               }
+       } else {
+               if (local->iw_mode == IW_MODE_REPEAT) {
+                       printk(KERN_DEBUG "%s: prism2_tx: trying to use "
+                              "non-WDS link in Repeater mode\n", dev->name);
+                       kfree_skb(skb);
+                       return 0;
+               } else if (local->iw_mode == IW_MODE_INFRA &&
+                          (local->wds_type & HOSTAP_WDS_AP_CLIENT) &&
+                          memcmp(skb->data + ETH_ALEN, dev->dev_addr,
+                                 ETH_ALEN) != 0) {
+                       /* AP client mode: send frames with foreign src addr
+                        * using 4-addr WDS frames */
+                       use_wds = WDS_COMPLIANT_FRAME;
+               }
+       }
+
+       /* Incoming skb->data: dst_addr[6], src_addr[6], proto[2], payload
+        * ==>
+        * Prism2 TX frame with 802.11 header:
+        * txdesc (address order depending on used mode; includes dst_addr and
+        * src_addr), possible encapsulation (RFC1042/Bridge-Tunnel;
+        * proto[2], payload {, possible addr4[6]} */
+
+       ethertype = (skb->data[12] << 8) | skb->data[13];
+
+       memset(&hdr, 0, sizeof(hdr));
+
+       /* Length of data after IEEE 802.11 header */
+       encaps_data = NULL;
+       encaps_len = 0;
+       skip_header_bytes = ETH_HLEN;
+       if (ethertype == ETH_P_AARP || ethertype == ETH_P_IPX) {
+               encaps_data = bridge_tunnel_header;
+               encaps_len = sizeof(bridge_tunnel_header);
+               skip_header_bytes -= 2;
+       } else if (ethertype >= 0x600) {
+               encaps_data = rfc1042_header;
+               encaps_len = sizeof(rfc1042_header);
+               skip_header_bytes -= 2;
+       }
+
+       fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA;
+       hdr_len = IEEE80211_DATA_HDR3_LEN;
+
+       if (use_wds != WDS_NO) {
+               /* Note! Prism2 station firmware has problems with sending real
+                * 802.11 frames with four addresses; until these problems can
+                * be fixed or worked around, 4-addr frames needed for WDS are
+                * using incompatible format: FromDS flag is not set and the
+                * fourth address is added after the frame payload; it is
+                * assumed, that the receiving station knows how to handle this
+                * frame format */
+
+               if (use_wds == WDS_COMPLIANT_FRAME) {
+                       fc |= IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS;
+                       /* From&To DS: Addr1 = RA, Addr2 = TA, Addr3 = DA,
+                        * Addr4 = SA */
+                       memcpy(&hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN);
+                       hdr_len += ETH_ALEN;
+               } else {
+                       /* bogus 4-addr format to workaround Prism2 station
+                        * f/w bug */
+                       fc |= IEEE80211_FCTL_TODS;
+                       /* From DS: Addr1 = DA (used as RA),
+                        * Addr2 = BSSID (used as TA), Addr3 = SA (used as DA),
+                        */
+
+                       /* SA from skb->data + ETH_ALEN will be added after
+                        * frame payload; use hdr.addr4 as a temporary buffer
+                        */
+                       memcpy(&hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN);
+                       need_tailroom += ETH_ALEN;
+               }
+
+               /* send broadcast and multicast frames to broadcast RA, if
+                * configured; otherwise, use unicast RA of the WDS link */
+               if ((local->wds_type & HOSTAP_WDS_BROADCAST_RA) &&
+                   skb->data[0] & 0x01)
+                       memset(&hdr.addr1, 0xff, ETH_ALEN);
+               else if (iface->type == HOSTAP_INTERFACE_WDS)
+                       memcpy(&hdr.addr1, iface->u.wds.remote_addr,
+                              ETH_ALEN);
+               else
+                       memcpy(&hdr.addr1, local->bssid, ETH_ALEN);
+               memcpy(&hdr.addr2, dev->dev_addr, ETH_ALEN);
+               memcpy(&hdr.addr3, skb->data, ETH_ALEN);
+       } else if (local->iw_mode == IW_MODE_MASTER && !to_assoc_ap) {
+               fc |= IEEE80211_FCTL_FROMDS;
+               /* From DS: Addr1 = DA, Addr2 = BSSID, Addr3 = SA */
+               memcpy(&hdr.addr1, skb->data, ETH_ALEN);
+               memcpy(&hdr.addr2, dev->dev_addr, ETH_ALEN);
+               memcpy(&hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN);
+       } else if (local->iw_mode == IW_MODE_INFRA || to_assoc_ap) {
+               fc |= IEEE80211_FCTL_TODS;
+               /* To DS: Addr1 = BSSID, Addr2 = SA, Addr3 = DA */
+               memcpy(&hdr.addr1, to_assoc_ap ?
+                      local->assoc_ap_addr : local->bssid, ETH_ALEN);
+               memcpy(&hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN);
+               memcpy(&hdr.addr3, skb->data, ETH_ALEN);
+       } else if (local->iw_mode == IW_MODE_ADHOC) {
+               /* not From/To DS: Addr1 = DA, Addr2 = SA, Addr3 = BSSID */
+               memcpy(&hdr.addr1, skb->data, ETH_ALEN);
+               memcpy(&hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN);
+               memcpy(&hdr.addr3, local->bssid, ETH_ALEN);
+       }
+
+       hdr.frame_ctl = cpu_to_le16(fc);
+
+       skb_pull(skb, skip_header_bytes);
+       need_headroom = local->func->need_tx_headroom + hdr_len + encaps_len;
+       if (skb_tailroom(skb) < need_tailroom) {
+               skb = skb_unshare(skb, GFP_ATOMIC);
+               if (skb == NULL) {
+                       iface->stats.tx_dropped++;
+                       return 0;
+               }
+               if (pskb_expand_head(skb, need_headroom, need_tailroom,
+                                    GFP_ATOMIC)) {
+                       kfree_skb(skb);
+                       iface->stats.tx_dropped++;
+                       return 0;
+               }
+       } else if (skb_headroom(skb) < need_headroom) {
+               struct sk_buff *tmp = skb;
+               skb = skb_realloc_headroom(skb, need_headroom);
+               kfree_skb(tmp);
+               if (skb == NULL) {
+                       iface->stats.tx_dropped++;
+                       return 0;
+               }
+       } else {
+               skb = skb_unshare(skb, GFP_ATOMIC);
+               if (skb == NULL) {
+                       iface->stats.tx_dropped++;
+                       return 0;
+               }
+       }
+
+       if (encaps_data)
+               memcpy(skb_push(skb, encaps_len), encaps_data, encaps_len);
+       memcpy(skb_push(skb, hdr_len), &hdr, hdr_len);
+       if (use_wds == WDS_OWN_FRAME) {
+               memcpy(skb_put(skb, ETH_ALEN), &hdr.addr4, ETH_ALEN);
+       }
+
+       iface->stats.tx_packets++;
+       iface->stats.tx_bytes += skb->len;
+
+       skb->mac.raw = skb->data;
+       meta = (struct hostap_skb_tx_data *) skb->cb;
+       memset(meta, 0, sizeof(*meta));
+       meta->magic = HOSTAP_SKB_TX_DATA_MAGIC;
+       if (use_wds)
+               meta->flags |= HOSTAP_TX_FLAGS_WDS;
+       meta->ethertype = ethertype;
+       meta->iface = iface;
+
+       /* Send IEEE 802.11 encapsulated frame using the master radio device */
+       skb->dev = local->dev;
+       dev_queue_xmit(skb);
+       return 0;
+}
+
+
+/* hard_start_xmit function for hostapd wlan#ap interfaces */
+int hostap_mgmt_start_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       struct hostap_skb_tx_data *meta;
+       struct ieee80211_hdr *hdr;
+       u16 fc;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (skb->len < 10) {
+               printk(KERN_DEBUG "%s: hostap_mgmt_start_xmit: short skb "
+                      "(len=%d)\n", dev->name, skb->len);
+               kfree_skb(skb);
+               return 0;
+       }
+
+       iface->stats.tx_packets++;
+       iface->stats.tx_bytes += skb->len;
+
+       meta = (struct hostap_skb_tx_data *) skb->cb;
+       memset(meta, 0, sizeof(*meta));
+       meta->magic = HOSTAP_SKB_TX_DATA_MAGIC;
+       meta->iface = iface;
+
+       if (skb->len >= IEEE80211_DATA_HDR3_LEN + sizeof(rfc1042_header) + 2) {
+               hdr = (struct ieee80211_hdr *) skb->data;
+               fc = le16_to_cpu(hdr->frame_ctl);
+               if (WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA &&
+                   WLAN_FC_GET_STYPE(fc) == IEEE80211_STYPE_DATA) {
+                       u8 *pos = &skb->data[IEEE80211_DATA_HDR3_LEN +
+                                            sizeof(rfc1042_header)];
+                       meta->ethertype = (pos[0] << 8) | pos[1];
+               }
+       }
+
+       /* Send IEEE 802.11 encapsulated frame using the master radio device */
+       skb->dev = local->dev;
+       dev_queue_xmit(skb);
+       return 0;
+}
+
+
+/* Called only from software IRQ */
+struct sk_buff * hostap_tx_encrypt(struct sk_buff *skb,
+                                  struct ieee80211_crypt_data *crypt)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       struct ieee80211_hdr *hdr;
+       u16 fc;
+       int hdr_len, res;
+
+       iface = netdev_priv(skb->dev);
+       local = iface->local;
+
+       if (skb->len < IEEE80211_DATA_HDR3_LEN) {
+               kfree_skb(skb);
+               return NULL;
+       }
+
+       if (local->tkip_countermeasures &&
+           crypt && crypt->ops && strcmp(crypt->ops->name, "TKIP") == 0) {
+               hdr = (struct ieee80211_hdr *) skb->data;
+               if (net_ratelimit()) {
+                       printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
+                              "TX packet to " MACSTR "\n",
+                              local->dev->name, MAC2STR(hdr->addr1));
+               }
+               kfree_skb(skb);
+               return NULL;
+       }
+
+       skb = skb_unshare(skb, GFP_ATOMIC);
+       if (skb == NULL)
+               return NULL;
+
+       if ((skb_headroom(skb) < crypt->ops->extra_prefix_len ||
+            skb_tailroom(skb) < crypt->ops->extra_postfix_len) &&
+           pskb_expand_head(skb, crypt->ops->extra_prefix_len,
+                            crypt->ops->extra_postfix_len, GFP_ATOMIC)) {
+               kfree_skb(skb);
+               return NULL;
+       }
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       fc = le16_to_cpu(hdr->frame_ctl);
+       hdr_len = hostap_80211_get_hdrlen(fc);
+
+       /* Host-based IEEE 802.11 fragmentation for TX is not yet supported, so
+        * call both MSDU and MPDU encryption functions from here. */
+       atomic_inc(&crypt->refcnt);
+       res = 0;
+       if (crypt->ops->encrypt_msdu)
+               res = crypt->ops->encrypt_msdu(skb, hdr_len, crypt->priv);
+       if (res == 0 && crypt->ops->encrypt_mpdu)
+               res = crypt->ops->encrypt_mpdu(skb, hdr_len, crypt->priv);
+       atomic_dec(&crypt->refcnt);
+       if (res < 0) {
+               kfree_skb(skb);
+               return NULL;
+       }
+
+       return skb;
+}
+
+
+/* hard_start_xmit function for master radio interface wifi#.
+ * AP processing (TX rate control, power save buffering, etc.).
+ * Use hardware TX function to send the frame. */
+int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int ret = 1;
+       u16 fc;
+       struct hostap_tx_data tx;
+       ap_tx_ret tx_ret;
+       struct hostap_skb_tx_data *meta;
+       int no_encrypt = 0;
+       struct ieee80211_hdr *hdr;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       tx.skb = skb;
+       tx.sta_ptr = NULL;
+
+       meta = (struct hostap_skb_tx_data *) skb->cb;
+       if (meta->magic != HOSTAP_SKB_TX_DATA_MAGIC) {
+               printk(KERN_DEBUG "%s: invalid skb->cb magic (0x%08x, "
+                      "expected 0x%08x)\n",
+                      dev->name, meta->magic, HOSTAP_SKB_TX_DATA_MAGIC);
+               ret = 0;
+               iface->stats.tx_dropped++;
+               goto fail;
+       }
+
+       if (local->host_encrypt) {
+               /* Set crypt to default algorithm and key; will be replaced in
+                * AP code if STA has own alg/key */
+               tx.crypt = local->crypt[local->tx_keyidx];
+               tx.host_encrypt = 1;
+       } else {
+               tx.crypt = NULL;
+               tx.host_encrypt = 0;
+       }
+
+       if (skb->len < 24) {
+               printk(KERN_DEBUG "%s: hostap_master_start_xmit: short skb "
+                      "(len=%d)\n", dev->name, skb->len);
+               ret = 0;
+               iface->stats.tx_dropped++;
+               goto fail;
+       }
+
+       /* FIX (?):
+        * Wi-Fi 802.11b test plan suggests that AP should ignore power save
+        * bit in authentication and (re)association frames and assume tha
+        * STA remains awake for the response. */
+       tx_ret = hostap_handle_sta_tx(local, &tx);
+       skb = tx.skb;
+       meta = (struct hostap_skb_tx_data *) skb->cb;
+       hdr = (struct ieee80211_hdr *) skb->data;
+       fc = le16_to_cpu(hdr->frame_ctl);
+       switch (tx_ret) {
+       case AP_TX_CONTINUE:
+               break;
+       case AP_TX_CONTINUE_NOT_AUTHORIZED:
+               if (local->ieee_802_1x &&
+                   WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA &&
+                   meta->ethertype != ETH_P_PAE &&
+                   !(meta->flags & HOSTAP_TX_FLAGS_WDS)) {
+                       printk(KERN_DEBUG "%s: dropped frame to unauthorized "
+                              "port (IEEE 802.1X): ethertype=0x%04x\n",
+                              dev->name, meta->ethertype);
+                       hostap_dump_tx_80211(dev->name, skb);
+
+                       ret = 0; /* drop packet */
+                       iface->stats.tx_dropped++;
+                       goto fail;
+               }
+               break;
+       case AP_TX_DROP:
+               ret = 0; /* drop packet */
+               iface->stats.tx_dropped++;
+               goto fail;
+       case AP_TX_RETRY:
+               goto fail;
+       case AP_TX_BUFFERED:
+               /* do not free skb here, it will be freed when the
+                * buffered frame is sent/timed out */
+               ret = 0;
+               goto tx_exit;
+       }
+
+       /* Request TX callback if protocol version is 2 in 802.11 header;
+        * this version 2 is a special case used between hostapd and kernel
+        * driver */
+       if (((fc & IEEE80211_FCTL_VERS) == BIT(1)) &&
+           local->ap && local->ap->tx_callback_idx && meta->tx_cb_idx == 0) {
+               meta->tx_cb_idx = local->ap->tx_callback_idx;
+
+               /* remove special version from the frame header */
+               fc &= ~IEEE80211_FCTL_VERS;
+               hdr->frame_ctl = cpu_to_le16(fc);
+       }
+
+       if (WLAN_FC_GET_TYPE(fc) != IEEE80211_FTYPE_DATA) {
+               no_encrypt = 1;
+               tx.crypt = NULL;
+       }
+
+       if (local->ieee_802_1x && meta->ethertype == ETH_P_PAE && tx.crypt &&
+           !(fc & IEEE80211_FCTL_VERS)) {
+               no_encrypt = 1;
+               PDEBUG(DEBUG_EXTRA2, "%s: TX: IEEE 802.1X - passing "
+                      "unencrypted EAPOL frame\n", dev->name);
+               tx.crypt = NULL; /* no encryption for IEEE 802.1X frames */
+       }
+
+       if (tx.crypt && (!tx.crypt->ops || !tx.crypt->ops->encrypt_mpdu))
+               tx.crypt = NULL;
+       else if ((tx.crypt || local->crypt[local->tx_keyidx]) && !no_encrypt) {
+               /* Add ISWEP flag both for firmware and host based encryption
+                */
+               fc |= IEEE80211_FCTL_PROTECTED;
+               hdr->frame_ctl = cpu_to_le16(fc);
+       } else if (local->drop_unencrypted &&
+                  WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA &&
+                  meta->ethertype != ETH_P_PAE) {
+               if (net_ratelimit()) {
+                       printk(KERN_DEBUG "%s: dropped unencrypted TX data "
+                              "frame (drop_unencrypted=1)\n", dev->name);
+               }
+               iface->stats.tx_dropped++;
+               ret = 0;
+               goto fail;
+       }
+
+       if (tx.crypt) {
+               skb = hostap_tx_encrypt(skb, tx.crypt);
+               if (skb == NULL) {
+                       printk(KERN_DEBUG "%s: TX - encryption failed\n",
+                              dev->name);
+                       ret = 0;
+                       goto fail;
+               }
+               meta = (struct hostap_skb_tx_data *) skb->cb;
+               if (meta->magic != HOSTAP_SKB_TX_DATA_MAGIC) {
+                       printk(KERN_DEBUG "%s: invalid skb->cb magic (0x%08x, "
+                              "expected 0x%08x) after hostap_tx_encrypt\n",
+                              dev->name, meta->magic,
+                              HOSTAP_SKB_TX_DATA_MAGIC);
+                       ret = 0;
+                       iface->stats.tx_dropped++;
+                       goto fail;
+               }
+       }
+
+       if (local->func->tx == NULL || local->func->tx(skb, dev)) {
+               ret = 0;
+               iface->stats.tx_dropped++;
+       } else {
+               ret = 0;
+               iface->stats.tx_packets++;
+               iface->stats.tx_bytes += skb->len;
+       }
+
+ fail:
+       if (!ret && skb)
+               dev_kfree_skb(skb);
+ tx_exit:
+       if (tx.sta_ptr)
+               hostap_handle_sta_release(tx.sta_ptr);
+       return ret;
+}
+
+
+EXPORT_SYMBOL(hostap_dump_tx_80211);
+EXPORT_SYMBOL(hostap_tx_encrypt);
+EXPORT_SYMBOL(hostap_master_start_xmit);
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c
new file mode 100644 (file)
index 0000000..930cef8
--- /dev/null
@@ -0,0 +1,3288 @@
+/*
+ * Intersil Prism2 driver with Host AP (software access point) support
+ * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
+ * <jkmaline@cc.hut.fi>
+ * Copyright (c) 2002-2005, Jouni Malinen <jkmaline@cc.hut.fi>
+ *
+ * This file is to be included into hostap.c when S/W AP functionality is
+ * compiled.
+ *
+ * AP:  FIX:
+ * - if unicast Class 2 (assoc,reassoc,disassoc) frame received from
+ *   unauthenticated STA, send deauth. frame (8802.11: 5.5)
+ * - if unicast Class 3 (data with to/from DS,deauth,pspoll) frame received
+ *   from authenticated, but unassoc STA, send disassoc frame (8802.11: 5.5)
+ * - if unicast Class 3 received from unauthenticated STA, send deauth. frame
+ *   (8802.11: 5.5)
+ */
+
+static int other_ap_policy[MAX_PARM_DEVICES] = { AP_OTHER_AP_SKIP_ALL,
+                                                DEF_INTS };
+module_param_array(other_ap_policy, int, NULL, 0444);
+MODULE_PARM_DESC(other_ap_policy, "Other AP beacon monitoring policy (0-3)");
+
+static int ap_max_inactivity[MAX_PARM_DEVICES] = { AP_MAX_INACTIVITY_SEC,
+                                                  DEF_INTS };
+module_param_array(ap_max_inactivity, int, NULL, 0444);
+MODULE_PARM_DESC(ap_max_inactivity, "AP timeout (in seconds) for station "
+                "inactivity");
+
+static int ap_bridge_packets[MAX_PARM_DEVICES] = { 1, DEF_INTS };
+module_param_array(ap_bridge_packets, int, NULL, 0444);
+MODULE_PARM_DESC(ap_bridge_packets, "Bridge packets directly between "
+                "stations");
+
+static int autom_ap_wds[MAX_PARM_DEVICES] = { 0, DEF_INTS };
+module_param_array(autom_ap_wds, int, NULL, 0444);
+MODULE_PARM_DESC(autom_ap_wds, "Add WDS connections to other APs "
+                "automatically");
+
+
+static struct sta_info* ap_get_sta(struct ap_data *ap, u8 *sta);
+static void hostap_event_expired_sta(struct net_device *dev,
+                                    struct sta_info *sta);
+static void handle_add_proc_queue(void *data);
+
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+static void handle_wds_oper_queue(void *data);
+static void prism2_send_mgmt(struct net_device *dev,
+                            u16 type_subtype, char *body,
+                            int body_len, u8 *addr, u16 tx_cb_idx);
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+
+#ifndef PRISM2_NO_PROCFS_DEBUG
+static int ap_debug_proc_read(char *page, char **start, off_t off,
+                             int count, int *eof, void *data)
+{
+       char *p = page;
+       struct ap_data *ap = (struct ap_data *) data;
+
+       if (off != 0) {
+               *eof = 1;
+               return 0;
+       }
+
+       p += sprintf(p, "BridgedUnicastFrames=%u\n", ap->bridged_unicast);
+       p += sprintf(p, "BridgedMulticastFrames=%u\n", ap->bridged_multicast);
+       p += sprintf(p, "max_inactivity=%u\n", ap->max_inactivity / HZ);
+       p += sprintf(p, "bridge_packets=%u\n", ap->bridge_packets);
+       p += sprintf(p, "nullfunc_ack=%u\n", ap->nullfunc_ack);
+       p += sprintf(p, "autom_ap_wds=%u\n", ap->autom_ap_wds);
+       p += sprintf(p, "auth_algs=%u\n", ap->local->auth_algs);
+       p += sprintf(p, "tx_drop_nonassoc=%u\n", ap->tx_drop_nonassoc);
+
+       return (p - page);
+}
+#endif /* PRISM2_NO_PROCFS_DEBUG */
+
+
+static void ap_sta_hash_add(struct ap_data *ap, struct sta_info *sta)
+{
+       sta->hnext = ap->sta_hash[STA_HASH(sta->addr)];
+       ap->sta_hash[STA_HASH(sta->addr)] = sta;
+}
+
+static void ap_sta_hash_del(struct ap_data *ap, struct sta_info *sta)
+{
+       struct sta_info *s;
+
+       s = ap->sta_hash[STA_HASH(sta->addr)];
+       if (s == NULL) return;
+       if (memcmp(s->addr, sta->addr, ETH_ALEN) == 0) {
+               ap->sta_hash[STA_HASH(sta->addr)] = s->hnext;
+               return;
+       }
+
+       while (s->hnext != NULL && memcmp(s->hnext->addr, sta->addr, ETH_ALEN)
+              != 0)
+               s = s->hnext;
+       if (s->hnext != NULL)
+               s->hnext = s->hnext->hnext;
+       else
+               printk("AP: could not remove STA " MACSTR " from hash table\n",
+                      MAC2STR(sta->addr));
+}
+
+static void ap_free_sta(struct ap_data *ap, struct sta_info *sta)
+{
+       if (sta->ap && sta->local)
+               hostap_event_expired_sta(sta->local->dev, sta);
+
+       if (ap->proc != NULL) {
+               char name[20];
+               sprintf(name, MACSTR, MAC2STR(sta->addr));
+               remove_proc_entry(name, ap->proc);
+       }
+
+       if (sta->crypt) {
+               sta->crypt->ops->deinit(sta->crypt->priv);
+               kfree(sta->crypt);
+               sta->crypt = NULL;
+       }
+
+       skb_queue_purge(&sta->tx_buf);
+
+       ap->num_sta--;
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+       if (sta->aid > 0)
+               ap->sta_aid[sta->aid - 1] = NULL;
+
+       if (!sta->ap && sta->u.sta.challenge)
+               kfree(sta->u.sta.challenge);
+       del_timer(&sta->timer);
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+       kfree(sta);
+}
+
+
+static void hostap_set_tim(local_info_t *local, int aid, int set)
+{
+       if (local->func->set_tim)
+               local->func->set_tim(local->dev, aid, set);
+}
+
+
+static void hostap_event_new_sta(struct net_device *dev, struct sta_info *sta)
+{
+       union iwreq_data wrqu;
+       memset(&wrqu, 0, sizeof(wrqu));
+       memcpy(wrqu.addr.sa_data, sta->addr, ETH_ALEN);
+       wrqu.addr.sa_family = ARPHRD_ETHER;
+       wireless_send_event(dev, IWEVREGISTERED, &wrqu, NULL);
+}
+
+
+static void hostap_event_expired_sta(struct net_device *dev,
+                                    struct sta_info *sta)
+{
+       union iwreq_data wrqu;
+       memset(&wrqu, 0, sizeof(wrqu));
+       memcpy(wrqu.addr.sa_data, sta->addr, ETH_ALEN);
+       wrqu.addr.sa_family = ARPHRD_ETHER;
+       wireless_send_event(dev, IWEVEXPIRED, &wrqu, NULL);
+}
+
+
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+
+static void ap_handle_timer(unsigned long data)
+{
+       struct sta_info *sta = (struct sta_info *) data;
+       local_info_t *local;
+       struct ap_data *ap;
+       unsigned long next_time = 0;
+       int was_assoc;
+
+       if (sta == NULL || sta->local == NULL || sta->local->ap == NULL) {
+               PDEBUG(DEBUG_AP, "ap_handle_timer() called with NULL data\n");
+               return;
+       }
+
+       local = sta->local;
+       ap = local->ap;
+       was_assoc = sta->flags & WLAN_STA_ASSOC;
+
+       if (atomic_read(&sta->users) != 0)
+               next_time = jiffies + HZ;
+       else if ((sta->flags & WLAN_STA_PERM) && !(sta->flags & WLAN_STA_AUTH))
+               next_time = jiffies + ap->max_inactivity;
+
+       if (time_before(jiffies, sta->last_rx + ap->max_inactivity)) {
+               /* station activity detected; reset timeout state */
+               sta->timeout_next = STA_NULLFUNC;
+               next_time = sta->last_rx + ap->max_inactivity;
+       } else if (sta->timeout_next == STA_DISASSOC &&
+                  !(sta->flags & WLAN_STA_PENDING_POLL)) {
+               /* STA ACKed data nullfunc frame poll */
+               sta->timeout_next = STA_NULLFUNC;
+               next_time = jiffies + ap->max_inactivity;
+       }
+
+       if (next_time) {
+               sta->timer.expires = next_time;
+               add_timer(&sta->timer);
+               return;
+       }
+
+       if (sta->ap)
+               sta->timeout_next = STA_DEAUTH;
+
+       if (sta->timeout_next == STA_DEAUTH && !(sta->flags & WLAN_STA_PERM)) {
+               spin_lock(&ap->sta_table_lock);
+               ap_sta_hash_del(ap, sta);
+               list_del(&sta->list);
+               spin_unlock(&ap->sta_table_lock);
+               sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
+       } else if (sta->timeout_next == STA_DISASSOC)
+               sta->flags &= ~WLAN_STA_ASSOC;
+
+       if (was_assoc && !(sta->flags & WLAN_STA_ASSOC) && !sta->ap)
+               hostap_event_expired_sta(local->dev, sta);
+
+       if (sta->timeout_next == STA_DEAUTH && sta->aid > 0 &&
+           !skb_queue_empty(&sta->tx_buf)) {
+               hostap_set_tim(local, sta->aid, 0);
+               sta->flags &= ~WLAN_STA_TIM;
+       }
+
+       if (sta->ap) {
+               if (ap->autom_ap_wds) {
+                       PDEBUG(DEBUG_AP, "%s: removing automatic WDS "
+                              "connection to AP " MACSTR "\n",
+                              local->dev->name, MAC2STR(sta->addr));
+                       hostap_wds_link_oper(local, sta->addr, WDS_DEL);
+               }
+       } else if (sta->timeout_next == STA_NULLFUNC) {
+               /* send data frame to poll STA and check whether this frame
+                * is ACKed */
+               /* FIX: IEEE80211_STYPE_NULLFUNC would be more appropriate, but
+                * it is apparently not retried so TX Exc events are not
+                * received for it */
+               sta->flags |= WLAN_STA_PENDING_POLL;
+               prism2_send_mgmt(local->dev, IEEE80211_FTYPE_DATA |
+                                IEEE80211_STYPE_DATA, NULL, 0,
+                                sta->addr, ap->tx_callback_poll);
+       } else {
+               int deauth = sta->timeout_next == STA_DEAUTH;
+               u16 resp;
+               PDEBUG(DEBUG_AP, "%s: sending %s info to STA " MACSTR
+                      "(last=%lu, jiffies=%lu)\n",
+                      local->dev->name,
+                      deauth ? "deauthentication" : "disassociation",
+                      MAC2STR(sta->addr), sta->last_rx, jiffies);
+
+               resp = cpu_to_le16(deauth ? WLAN_REASON_PREV_AUTH_NOT_VALID :
+                                  WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY);
+               prism2_send_mgmt(local->dev, IEEE80211_FTYPE_MGMT |
+                                (deauth ? IEEE80211_STYPE_DEAUTH :
+                                 IEEE80211_STYPE_DISASSOC),
+                                (char *) &resp, 2, sta->addr, 0);
+       }
+
+       if (sta->timeout_next == STA_DEAUTH) {
+               if (sta->flags & WLAN_STA_PERM) {
+                       PDEBUG(DEBUG_AP, "%s: STA " MACSTR " would have been "
+                              "removed, but it has 'perm' flag\n",
+                              local->dev->name, MAC2STR(sta->addr));
+               } else
+                       ap_free_sta(ap, sta);
+               return;
+       }
+
+       if (sta->timeout_next == STA_NULLFUNC) {
+               sta->timeout_next = STA_DISASSOC;
+               sta->timer.expires = jiffies + AP_DISASSOC_DELAY;
+       } else {
+               sta->timeout_next = STA_DEAUTH;
+               sta->timer.expires = jiffies + AP_DEAUTH_DELAY;
+       }
+
+       add_timer(&sta->timer);
+}
+
+
+void hostap_deauth_all_stas(struct net_device *dev, struct ap_data *ap,
+                           int resend)
+{
+       u8 addr[ETH_ALEN];
+       u16 resp;
+       int i;
+
+       PDEBUG(DEBUG_AP, "%s: Deauthenticate all stations\n", dev->name);
+       memset(addr, 0xff, ETH_ALEN);
+
+       resp = __constant_cpu_to_le16(WLAN_REASON_PREV_AUTH_NOT_VALID);
+
+       /* deauth message sent; try to resend it few times; the message is
+        * broadcast, so it may be delayed until next DTIM; there is not much
+        * else we can do at this point since the driver is going to be shut
+        * down */
+       for (i = 0; i < 5; i++) {
+               prism2_send_mgmt(dev, IEEE80211_FTYPE_MGMT |
+                                IEEE80211_STYPE_DEAUTH,
+                                (char *) &resp, 2, addr, 0);
+
+               if (!resend || ap->num_sta <= 0)
+                       return;
+
+               mdelay(50);
+       }
+}
+
+
+static int ap_control_proc_read(char *page, char **start, off_t off,
+                               int count, int *eof, void *data)
+{
+       char *p = page;
+       struct ap_data *ap = (struct ap_data *) data;
+       char *policy_txt;
+       struct list_head *ptr;
+       struct mac_entry *entry;
+
+       if (off != 0) {
+               *eof = 1;
+               return 0;
+       }
+
+       switch (ap->mac_restrictions.policy) {
+       case MAC_POLICY_OPEN:
+               policy_txt = "open";
+               break;
+       case MAC_POLICY_ALLOW:
+               policy_txt = "allow";
+               break;
+       case MAC_POLICY_DENY:
+               policy_txt = "deny";
+               break;
+       default:
+               policy_txt = "unknown";
+               break;
+       };
+       p += sprintf(p, "MAC policy: %s\n", policy_txt);
+       p += sprintf(p, "MAC entries: %u\n", ap->mac_restrictions.entries);
+       p += sprintf(p, "MAC list:\n");
+       spin_lock_bh(&ap->mac_restrictions.lock);
+       for (ptr = ap->mac_restrictions.mac_list.next;
+            ptr != &ap->mac_restrictions.mac_list; ptr = ptr->next) {
+               if (p - page > PAGE_SIZE - 80) {
+                       p += sprintf(p, "All entries did not fit one page.\n");
+                       break;
+               }
+
+               entry = list_entry(ptr, struct mac_entry, list);
+               p += sprintf(p, MACSTR "\n", MAC2STR(entry->addr));
+       }
+       spin_unlock_bh(&ap->mac_restrictions.lock);
+
+       return (p - page);
+}
+
+
+static int ap_control_add_mac(struct mac_restrictions *mac_restrictions,
+                             u8 *mac)
+{
+       struct mac_entry *entry;
+
+       entry = kmalloc(sizeof(struct mac_entry), GFP_KERNEL);
+       if (entry == NULL)
+               return -1;
+
+       memcpy(entry->addr, mac, ETH_ALEN);
+
+       spin_lock_bh(&mac_restrictions->lock);
+       list_add_tail(&entry->list, &mac_restrictions->mac_list);
+       mac_restrictions->entries++;
+       spin_unlock_bh(&mac_restrictions->lock);
+
+       return 0;
+}
+
+
+static int ap_control_del_mac(struct mac_restrictions *mac_restrictions,
+                             u8 *mac)
+{
+       struct list_head *ptr;
+       struct mac_entry *entry;
+
+       spin_lock_bh(&mac_restrictions->lock);
+       for (ptr = mac_restrictions->mac_list.next;
+            ptr != &mac_restrictions->mac_list; ptr = ptr->next) {
+               entry = list_entry(ptr, struct mac_entry, list);
+
+               if (memcmp(entry->addr, mac, ETH_ALEN) == 0) {
+                       list_del(ptr);
+                       kfree(entry);
+                       mac_restrictions->entries--;
+                       spin_unlock_bh(&mac_restrictions->lock);
+                       return 0;
+               }
+       }
+       spin_unlock_bh(&mac_restrictions->lock);
+       return -1;
+}
+
+
+static int ap_control_mac_deny(struct mac_restrictions *mac_restrictions,
+                              u8 *mac)
+{
+       struct list_head *ptr;
+       struct mac_entry *entry;
+       int found = 0;
+
+       if (mac_restrictions->policy == MAC_POLICY_OPEN)
+               return 0;
+
+       spin_lock_bh(&mac_restrictions->lock);
+       for (ptr = mac_restrictions->mac_list.next;
+            ptr != &mac_restrictions->mac_list; ptr = ptr->next) {
+               entry = list_entry(ptr, struct mac_entry, list);
+
+               if (memcmp(entry->addr, mac, ETH_ALEN) == 0) {
+                       found = 1;
+                       break;
+               }
+       }
+       spin_unlock_bh(&mac_restrictions->lock);
+
+       if (mac_restrictions->policy == MAC_POLICY_ALLOW)
+               return !found;
+       else
+               return found;
+}
+
+
+static void ap_control_flush_macs(struct mac_restrictions *mac_restrictions)
+{
+       struct list_head *ptr, *n;
+       struct mac_entry *entry;
+
+       if (mac_restrictions->entries == 0)
+               return;
+
+       spin_lock_bh(&mac_restrictions->lock);
+       for (ptr = mac_restrictions->mac_list.next, n = ptr->next;
+            ptr != &mac_restrictions->mac_list;
+            ptr = n, n = ptr->next) {
+               entry = list_entry(ptr, struct mac_entry, list);
+               list_del(ptr);
+               kfree(entry);
+       }
+       mac_restrictions->entries = 0;
+       spin_unlock_bh(&mac_restrictions->lock);
+}
+
+
+static int ap_control_kick_mac(struct ap_data *ap, struct net_device *dev,
+                              u8 *mac)
+{
+       struct sta_info *sta;
+       u16 resp;
+
+       spin_lock_bh(&ap->sta_table_lock);
+       sta = ap_get_sta(ap, mac);
+       if (sta) {
+               ap_sta_hash_del(ap, sta);
+               list_del(&sta->list);
+       }
+       spin_unlock_bh(&ap->sta_table_lock);
+
+       if (!sta)
+               return -EINVAL;
+
+       resp = cpu_to_le16(WLAN_REASON_PREV_AUTH_NOT_VALID);
+       prism2_send_mgmt(dev, IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH,
+                        (char *) &resp, 2, sta->addr, 0);
+
+       if ((sta->flags & WLAN_STA_ASSOC) && !sta->ap)
+               hostap_event_expired_sta(dev, sta);
+
+       ap_free_sta(ap, sta);
+
+       return 0;
+}
+
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+
+static void ap_control_kickall(struct ap_data *ap)
+{
+       struct list_head *ptr, *n;
+       struct sta_info *sta;
+
+       spin_lock_bh(&ap->sta_table_lock);
+       for (ptr = ap->sta_list.next, n = ptr->next; ptr != &ap->sta_list;
+            ptr = n, n = ptr->next) {
+               sta = list_entry(ptr, struct sta_info, list);
+               ap_sta_hash_del(ap, sta);
+               list_del(&sta->list);
+               if ((sta->flags & WLAN_STA_ASSOC) && !sta->ap && sta->local)
+                       hostap_event_expired_sta(sta->local->dev, sta);
+               ap_free_sta(ap, sta);
+       }
+       spin_unlock_bh(&ap->sta_table_lock);
+}
+
+
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+
+#define PROC_LIMIT (PAGE_SIZE - 80)
+
+static int prism2_ap_proc_read(char *page, char **start, off_t off,
+                              int count, int *eof, void *data)
+{
+       char *p = page;
+       struct ap_data *ap = (struct ap_data *) data;
+       struct list_head *ptr;
+       int i;
+
+       if (off > PROC_LIMIT) {
+               *eof = 1;
+               return 0;
+       }
+
+       p += sprintf(p, "# BSSID CHAN SIGNAL NOISE RATE SSID FLAGS\n");
+       spin_lock_bh(&ap->sta_table_lock);
+       for (ptr = ap->sta_list.next; ptr != &ap->sta_list; ptr = ptr->next) {
+               struct sta_info *sta = (struct sta_info *) ptr;
+
+               if (!sta->ap)
+                       continue;
+
+               p += sprintf(p, MACSTR " %d %d %d %d '", MAC2STR(sta->addr),
+                            sta->u.ap.channel, sta->last_rx_signal,
+                            sta->last_rx_silence, sta->last_rx_rate);
+               for (i = 0; i < sta->u.ap.ssid_len; i++)
+                       p += sprintf(p, ((sta->u.ap.ssid[i] >= 32 &&
+                                         sta->u.ap.ssid[i] < 127) ?
+                                        "%c" : "<%02x>"),
+                                    sta->u.ap.ssid[i]);
+               p += sprintf(p, "'");
+               if (sta->capability & WLAN_CAPABILITY_ESS)
+                       p += sprintf(p, " [ESS]");
+               if (sta->capability & WLAN_CAPABILITY_IBSS)
+                       p += sprintf(p, " [IBSS]");
+               if (sta->capability & WLAN_CAPABILITY_PRIVACY)
+                       p += sprintf(p, " [WEP]");
+               p += sprintf(p, "\n");
+
+               if ((p - page) > PROC_LIMIT) {
+                       printk(KERN_DEBUG "hostap: ap proc did not fit\n");
+                       break;
+               }
+       }
+       spin_unlock_bh(&ap->sta_table_lock);
+
+       if ((p - page) <= off) {
+               *eof = 1;
+               return 0;
+       }
+
+       *start = page + off;
+
+       return (p - page - off);
+}
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+
+void hostap_check_sta_fw_version(struct ap_data *ap, int sta_fw_ver)
+{
+       if (!ap)
+               return;
+
+       if (sta_fw_ver == PRISM2_FW_VER(0,8,0)) {
+               PDEBUG(DEBUG_AP, "Using data::nullfunc ACK workaround - "
+                      "firmware upgrade recommended\n");
+               ap->nullfunc_ack = 1;
+       } else
+               ap->nullfunc_ack = 0;
+
+       if (sta_fw_ver == PRISM2_FW_VER(1,4,2)) {
+               printk(KERN_WARNING "%s: Warning: secondary station firmware "
+                      "version 1.4.2 does not seem to work in Host AP mode\n",
+                      ap->local->dev->name);
+       }
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static void hostap_ap_tx_cb(struct sk_buff *skb, int ok, void *data)
+{
+       struct ap_data *ap = data;
+       u16 fc;
+       struct ieee80211_hdr *hdr;
+
+       if (!ap->local->hostapd || !ap->local->apdev) {
+               dev_kfree_skb(skb);
+               return;
+       }
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       fc = le16_to_cpu(hdr->frame_ctl);
+
+       /* Pass the TX callback frame to the hostapd; use 802.11 header version
+        * 1 to indicate failure (no ACK) and 2 success (frame ACKed) */
+
+       fc &= ~IEEE80211_FCTL_VERS;
+       fc |= ok ? BIT(1) : BIT(0);
+       hdr->frame_ctl = cpu_to_le16(fc);
+
+       skb->dev = ap->local->apdev;
+       skb_pull(skb, hostap_80211_get_hdrlen(fc));
+       skb->pkt_type = PACKET_OTHERHOST;
+       skb->protocol = __constant_htons(ETH_P_802_2);
+       memset(skb->cb, 0, sizeof(skb->cb));
+       netif_rx(skb);
+}
+
+
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+/* Called only as a tasklet (software IRQ) */
+static void hostap_ap_tx_cb_auth(struct sk_buff *skb, int ok, void *data)
+{
+       struct ap_data *ap = data;
+       struct net_device *dev = ap->local->dev;
+       struct ieee80211_hdr *hdr;
+       u16 fc, *pos, auth_alg, auth_transaction, status;
+       struct sta_info *sta = NULL;
+       char *txt = NULL;
+
+       if (ap->local->hostapd) {
+               dev_kfree_skb(skb);
+               return;
+       }
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       fc = le16_to_cpu(hdr->frame_ctl);
+       if (WLAN_FC_GET_TYPE(fc) != IEEE80211_FTYPE_MGMT ||
+           WLAN_FC_GET_STYPE(fc) != IEEE80211_STYPE_AUTH ||
+           skb->len < IEEE80211_MGMT_HDR_LEN + 6) {
+               printk(KERN_DEBUG "%s: hostap_ap_tx_cb_auth received invalid "
+                      "frame\n", dev->name);
+               dev_kfree_skb(skb);
+               return;
+       }
+
+       pos = (u16 *) (skb->data + IEEE80211_MGMT_HDR_LEN);
+       auth_alg = le16_to_cpu(*pos++);
+       auth_transaction = le16_to_cpu(*pos++);
+       status = le16_to_cpu(*pos++);
+
+       if (!ok) {
+               txt = "frame was not ACKed";
+               goto done;
+       }
+
+       spin_lock(&ap->sta_table_lock);
+       sta = ap_get_sta(ap, hdr->addr1);
+       if (sta)
+               atomic_inc(&sta->users);
+       spin_unlock(&ap->sta_table_lock);
+
+       if (!sta) {
+               txt = "STA not found";
+               goto done;
+       }
+
+       if (status == WLAN_STATUS_SUCCESS &&
+           ((auth_alg == WLAN_AUTH_OPEN && auth_transaction == 2) ||
+            (auth_alg == WLAN_AUTH_SHARED_KEY && auth_transaction == 4))) {
+               txt = "STA authenticated";
+               sta->flags |= WLAN_STA_AUTH;
+               sta->last_auth = jiffies;
+       } else if (status != WLAN_STATUS_SUCCESS)
+               txt = "authentication failed";
+
+ done:
+       if (sta)
+               atomic_dec(&sta->users);
+       if (txt) {
+               PDEBUG(DEBUG_AP, "%s: " MACSTR " auth_cb - alg=%d trans#=%d "
+                      "status=%d - %s\n",
+                      dev->name, MAC2STR(hdr->addr1), auth_alg,
+                      auth_transaction, status, txt);
+       }
+       dev_kfree_skb(skb);
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static void hostap_ap_tx_cb_assoc(struct sk_buff *skb, int ok, void *data)
+{
+       struct ap_data *ap = data;
+       struct net_device *dev = ap->local->dev;
+       struct ieee80211_hdr *hdr;
+       u16 fc, *pos, status;
+       struct sta_info *sta = NULL;
+       char *txt = NULL;
+
+       if (ap->local->hostapd) {
+               dev_kfree_skb(skb);
+               return;
+       }
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       fc = le16_to_cpu(hdr->frame_ctl);
+       if (WLAN_FC_GET_TYPE(fc) != IEEE80211_FTYPE_MGMT ||
+           (WLAN_FC_GET_STYPE(fc) != IEEE80211_STYPE_ASSOC_RESP &&
+            WLAN_FC_GET_STYPE(fc) != IEEE80211_STYPE_REASSOC_RESP) ||
+           skb->len < IEEE80211_MGMT_HDR_LEN + 4) {
+               printk(KERN_DEBUG "%s: hostap_ap_tx_cb_assoc received invalid "
+                      "frame\n", dev->name);
+               dev_kfree_skb(skb);
+               return;
+       }
+
+       if (!ok) {
+               txt = "frame was not ACKed";
+               goto done;
+       }
+
+       spin_lock(&ap->sta_table_lock);
+       sta = ap_get_sta(ap, hdr->addr1);
+       if (sta)
+               atomic_inc(&sta->users);
+       spin_unlock(&ap->sta_table_lock);
+
+       if (!sta) {
+               txt = "STA not found";
+               goto done;
+       }
+
+       pos = (u16 *) (skb->data + IEEE80211_MGMT_HDR_LEN);
+       pos++;
+       status = le16_to_cpu(*pos++);
+       if (status == WLAN_STATUS_SUCCESS) {
+               if (!(sta->flags & WLAN_STA_ASSOC))
+                       hostap_event_new_sta(dev, sta);
+               txt = "STA associated";
+               sta->flags |= WLAN_STA_ASSOC;
+               sta->last_assoc = jiffies;
+       } else
+               txt = "association failed";
+
+ done:
+       if (sta)
+               atomic_dec(&sta->users);
+       if (txt) {
+               PDEBUG(DEBUG_AP, "%s: " MACSTR " assoc_cb - %s\n",
+                      dev->name, MAC2STR(hdr->addr1), txt);
+       }
+       dev_kfree_skb(skb);
+}
+
+/* Called only as a tasklet (software IRQ); TX callback for poll frames used
+ * in verifying whether the STA is still present. */
+static void hostap_ap_tx_cb_poll(struct sk_buff *skb, int ok, void *data)
+{
+       struct ap_data *ap = data;
+       struct ieee80211_hdr *hdr;
+       struct sta_info *sta;
+
+       if (skb->len < 24)
+               goto fail;
+       hdr = (struct ieee80211_hdr *) skb->data;
+       if (ok) {
+               spin_lock(&ap->sta_table_lock);
+               sta = ap_get_sta(ap, hdr->addr1);
+               if (sta)
+                       sta->flags &= ~WLAN_STA_PENDING_POLL;
+               spin_unlock(&ap->sta_table_lock);
+       } else {
+               PDEBUG(DEBUG_AP, "%s: STA " MACSTR " did not ACK activity "
+                      "poll frame\n", ap->local->dev->name,
+                      MAC2STR(hdr->addr1));
+       }
+
+ fail:
+       dev_kfree_skb(skb);
+}
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+
+void hostap_init_data(local_info_t *local)
+{
+       struct ap_data *ap = local->ap;
+
+       if (ap == NULL) {
+               printk(KERN_WARNING "hostap_init_data: ap == NULL\n");
+               return;
+       }
+       memset(ap, 0, sizeof(struct ap_data));
+       ap->local = local;
+
+       ap->ap_policy = GET_INT_PARM(other_ap_policy, local->card_idx);
+       ap->bridge_packets = GET_INT_PARM(ap_bridge_packets, local->card_idx);
+       ap->max_inactivity =
+               GET_INT_PARM(ap_max_inactivity, local->card_idx) * HZ;
+       ap->autom_ap_wds = GET_INT_PARM(autom_ap_wds, local->card_idx);
+
+       spin_lock_init(&ap->sta_table_lock);
+       INIT_LIST_HEAD(&ap->sta_list);
+
+       /* Initialize task queue structure for AP management */
+       INIT_WORK(&local->ap->add_sta_proc_queue, handle_add_proc_queue, ap);
+
+       ap->tx_callback_idx =
+               hostap_tx_callback_register(local, hostap_ap_tx_cb, ap);
+       if (ap->tx_callback_idx == 0)
+               printk(KERN_WARNING "%s: failed to register TX callback for "
+                      "AP\n", local->dev->name);
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+       INIT_WORK(&local->ap->wds_oper_queue, handle_wds_oper_queue, local);
+
+       ap->tx_callback_auth =
+               hostap_tx_callback_register(local, hostap_ap_tx_cb_auth, ap);
+       ap->tx_callback_assoc =
+               hostap_tx_callback_register(local, hostap_ap_tx_cb_assoc, ap);
+       ap->tx_callback_poll =
+               hostap_tx_callback_register(local, hostap_ap_tx_cb_poll, ap);
+       if (ap->tx_callback_auth == 0 || ap->tx_callback_assoc == 0 ||
+               ap->tx_callback_poll == 0)
+               printk(KERN_WARNING "%s: failed to register TX callback for "
+                      "AP\n", local->dev->name);
+
+       spin_lock_init(&ap->mac_restrictions.lock);
+       INIT_LIST_HEAD(&ap->mac_restrictions.mac_list);
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+       ap->initialized = 1;
+}
+
+
+void hostap_init_ap_proc(local_info_t *local)
+{
+       struct ap_data *ap = local->ap;
+
+       ap->proc = local->proc;
+       if (ap->proc == NULL)
+               return;
+
+#ifndef PRISM2_NO_PROCFS_DEBUG
+       create_proc_read_entry("ap_debug", 0, ap->proc,
+                              ap_debug_proc_read, ap);
+#endif /* PRISM2_NO_PROCFS_DEBUG */
+
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+       create_proc_read_entry("ap_control", 0, ap->proc,
+                              ap_control_proc_read, ap);
+       create_proc_read_entry("ap", 0, ap->proc,
+                              prism2_ap_proc_read, ap);
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+}
+
+
+void hostap_free_data(struct ap_data *ap)
+{
+       struct list_head *n, *ptr;
+
+       if (ap == NULL || !ap->initialized) {
+               printk(KERN_DEBUG "hostap_free_data: ap has not yet been "
+                      "initialized - skip resource freeing\n");
+               return;
+       }
+
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+       if (ap->crypt)
+               ap->crypt->deinit(ap->crypt_priv);
+       ap->crypt = ap->crypt_priv = NULL;
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+       list_for_each_safe(ptr, n, &ap->sta_list) {
+               struct sta_info *sta = list_entry(ptr, struct sta_info, list);
+               ap_sta_hash_del(ap, sta);
+               list_del(&sta->list);
+               if ((sta->flags & WLAN_STA_ASSOC) && !sta->ap && sta->local)
+                       hostap_event_expired_sta(sta->local->dev, sta);
+               ap_free_sta(ap, sta);
+       }
+
+#ifndef PRISM2_NO_PROCFS_DEBUG
+       if (ap->proc != NULL) {
+               remove_proc_entry("ap_debug", ap->proc);
+       }
+#endif /* PRISM2_NO_PROCFS_DEBUG */
+
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+       if (ap->proc != NULL) {
+         remove_proc_entry("ap", ap->proc);
+               remove_proc_entry("ap_control", ap->proc);
+       }
+       ap_control_flush_macs(&ap->mac_restrictions);
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+       ap->initialized = 0;
+}
+
+
+/* caller should have mutex for AP STA list handling */
+static struct sta_info* ap_get_sta(struct ap_data *ap, u8 *sta)
+{
+       struct sta_info *s;
+
+       s = ap->sta_hash[STA_HASH(sta)];
+       while (s != NULL && memcmp(s->addr, sta, ETH_ALEN) != 0)
+               s = s->hnext;
+       return s;
+}
+
+
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+
+/* Called from timer handler and from scheduled AP queue handlers */
+static void prism2_send_mgmt(struct net_device *dev,
+                            u16 type_subtype, char *body,
+                            int body_len, u8 *addr, u16 tx_cb_idx)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       struct ieee80211_hdr *hdr;
+       u16 fc;
+       struct sk_buff *skb;
+       struct hostap_skb_tx_data *meta;
+       int hdrlen;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+       dev = local->dev; /* always use master radio device */
+       iface = netdev_priv(dev);
+
+       if (!(dev->flags & IFF_UP)) {
+               PDEBUG(DEBUG_AP, "%s: prism2_send_mgmt - device is not UP - "
+                      "cannot send frame\n", dev->name);
+               return;
+       }
+
+       skb = dev_alloc_skb(sizeof(*hdr) + body_len);
+       if (skb == NULL) {
+               PDEBUG(DEBUG_AP, "%s: prism2_send_mgmt failed to allocate "
+                      "skb\n", dev->name);
+               return;
+       }
+
+       fc = type_subtype;
+       hdrlen = hostap_80211_get_hdrlen(fc);
+       hdr = (struct ieee80211_hdr *) skb_put(skb, hdrlen);
+       if (body)
+               memcpy(skb_put(skb, body_len), body, body_len);
+
+       memset(hdr, 0, hdrlen);
+
+       /* FIX: ctrl::ack sending used special HFA384X_TX_CTRL_802_11
+        * tx_control instead of using local->tx_control */
+
+
+       memcpy(hdr->addr1, addr, ETH_ALEN); /* DA / RA */
+       if (WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA) {
+               fc |= IEEE80211_FCTL_FROMDS;
+               memcpy(hdr->addr2, dev->dev_addr, ETH_ALEN); /* BSSID */
+               memcpy(hdr->addr3, dev->dev_addr, ETH_ALEN); /* SA */
+       } else if (WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_CTL) {
+               /* control:ACK does not have addr2 or addr3 */
+               memset(hdr->addr2, 0, ETH_ALEN);
+               memset(hdr->addr3, 0, ETH_ALEN);
+       } else {
+               memcpy(hdr->addr2, dev->dev_addr, ETH_ALEN); /* SA */
+               memcpy(hdr->addr3, dev->dev_addr, ETH_ALEN); /* BSSID */
+       }
+
+       hdr->frame_ctl = cpu_to_le16(fc);
+
+       meta = (struct hostap_skb_tx_data *) skb->cb;
+       memset(meta, 0, sizeof(*meta));
+       meta->magic = HOSTAP_SKB_TX_DATA_MAGIC;
+       meta->iface = iface;
+       meta->tx_cb_idx = tx_cb_idx;
+
+       skb->dev = dev;
+       skb->mac.raw = skb->nh.raw = skb->data;
+       dev_queue_xmit(skb);
+}
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+
+static int prism2_sta_proc_read(char *page, char **start, off_t off,
+                               int count, int *eof, void *data)
+{
+       char *p = page;
+       struct sta_info *sta = (struct sta_info *) data;
+       int i;
+
+       /* FIX: possible race condition.. the STA data could have just expired,
+        * but proc entry was still here so that the read could have started;
+        * some locking should be done here.. */
+
+       if (off != 0) {
+               *eof = 1;
+               return 0;
+       }
+
+       p += sprintf(p, "%s=" MACSTR "\nusers=%d\naid=%d\n"
+                    "flags=0x%04x%s%s%s%s%s%s%s\n"
+                    "capability=0x%02x\nlisten_interval=%d\nsupported_rates=",
+                    sta->ap ? "AP" : "STA",
+                    MAC2STR(sta->addr), atomic_read(&sta->users), sta->aid,
+                    sta->flags,
+                    sta->flags & WLAN_STA_AUTH ? " AUTH" : "",
+                    sta->flags & WLAN_STA_ASSOC ? " ASSOC" : "",
+                    sta->flags & WLAN_STA_PS ? " PS" : "",
+                    sta->flags & WLAN_STA_TIM ? " TIM" : "",
+                    sta->flags & WLAN_STA_PERM ? " PERM" : "",
+                    sta->flags & WLAN_STA_AUTHORIZED ? " AUTHORIZED" : "",
+                    sta->flags & WLAN_STA_PENDING_POLL ? " POLL" : "",
+                    sta->capability, sta->listen_interval);
+       /* supported_rates: 500 kbit/s units with msb ignored */
+       for (i = 0; i < sizeof(sta->supported_rates); i++)
+               if (sta->supported_rates[i] != 0)
+                       p += sprintf(p, "%d%sMbps ",
+                                    (sta->supported_rates[i] & 0x7f) / 2,
+                                    sta->supported_rates[i] & 1 ? ".5" : "");
+       p += sprintf(p, "\njiffies=%lu\nlast_auth=%lu\nlast_assoc=%lu\n"
+                    "last_rx=%lu\nlast_tx=%lu\nrx_packets=%lu\n"
+                    "tx_packets=%lu\n"
+                    "rx_bytes=%lu\ntx_bytes=%lu\nbuffer_count=%d\n"
+                    "last_rx: silence=%d dBm signal=%d dBm rate=%d%s Mbps\n"
+                    "tx_rate=%d\ntx[1M]=%d\ntx[2M]=%d\ntx[5.5M]=%d\n"
+                    "tx[11M]=%d\n"
+                    "rx[1M]=%d\nrx[2M]=%d\nrx[5.5M]=%d\nrx[11M]=%d\n",
+                    jiffies, sta->last_auth, sta->last_assoc, sta->last_rx,
+                    sta->last_tx,
+                    sta->rx_packets, sta->tx_packets, sta->rx_bytes,
+                    sta->tx_bytes, skb_queue_len(&sta->tx_buf),
+                    sta->last_rx_silence,
+                    sta->last_rx_signal, sta->last_rx_rate / 10,
+                    sta->last_rx_rate % 10 ? ".5" : "",
+                    sta->tx_rate, sta->tx_count[0], sta->tx_count[1],
+                    sta->tx_count[2], sta->tx_count[3],  sta->rx_count[0],
+                    sta->rx_count[1], sta->rx_count[2], sta->rx_count[3]);
+       if (sta->crypt && sta->crypt->ops && sta->crypt->ops->print_stats)
+               p = sta->crypt->ops->print_stats(p, sta->crypt->priv);
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+       if (sta->ap) {
+               if (sta->u.ap.channel >= 0)
+                       p += sprintf(p, "channel=%d\n", sta->u.ap.channel);
+               p += sprintf(p, "ssid=");
+               for (i = 0; i < sta->u.ap.ssid_len; i++)
+                       p += sprintf(p, ((sta->u.ap.ssid[i] >= 32 &&
+                                         sta->u.ap.ssid[i] < 127) ?
+                                        "%c" : "<%02x>"),
+                                    sta->u.ap.ssid[i]);
+               p += sprintf(p, "\n");
+       }
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+       return (p - page);
+}
+
+
+static void handle_add_proc_queue(void *data)
+{
+       struct ap_data *ap = (struct ap_data *) data;
+       struct sta_info *sta;
+       char name[20];
+       struct add_sta_proc_data *entry, *prev;
+
+       entry = ap->add_sta_proc_entries;
+       ap->add_sta_proc_entries = NULL;
+
+       while (entry) {
+               spin_lock_bh(&ap->sta_table_lock);
+               sta = ap_get_sta(ap, entry->addr);
+               if (sta)
+                       atomic_inc(&sta->users);
+               spin_unlock_bh(&ap->sta_table_lock);
+
+               if (sta) {
+                       sprintf(name, MACSTR, MAC2STR(sta->addr));
+                       sta->proc = create_proc_read_entry(
+                               name, 0, ap->proc,
+                               prism2_sta_proc_read, sta);
+
+                       atomic_dec(&sta->users);
+               }
+
+               prev = entry;
+               entry = entry->next;
+               kfree(prev);
+       }
+}
+
+
+static struct sta_info * ap_add_sta(struct ap_data *ap, u8 *addr)
+{
+       struct sta_info *sta;
+
+       sta = (struct sta_info *)
+               kmalloc(sizeof(struct sta_info), GFP_ATOMIC);
+       if (sta == NULL) {
+               PDEBUG(DEBUG_AP, "AP: kmalloc failed\n");
+               return NULL;
+       }
+
+       /* initialize STA info data */
+       memset(sta, 0, sizeof(struct sta_info));
+       sta->local = ap->local;
+       skb_queue_head_init(&sta->tx_buf);
+       memcpy(sta->addr, addr, ETH_ALEN);
+
+       atomic_inc(&sta->users);
+       spin_lock_bh(&ap->sta_table_lock);
+       list_add(&sta->list, &ap->sta_list);
+       ap->num_sta++;
+       ap_sta_hash_add(ap, sta);
+       spin_unlock_bh(&ap->sta_table_lock);
+
+       if (ap->proc) {
+               struct add_sta_proc_data *entry;
+               /* schedule a non-interrupt context process to add a procfs
+                * entry for the STA since procfs code use GFP_KERNEL */
+               entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
+               if (entry) {
+                       memcpy(entry->addr, sta->addr, ETH_ALEN);
+                       entry->next = ap->add_sta_proc_entries;
+                       ap->add_sta_proc_entries = entry;
+                       schedule_work(&ap->add_sta_proc_queue);
+               } else
+                       printk(KERN_DEBUG "Failed to add STA proc data\n");
+       }
+
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+       init_timer(&sta->timer);
+       sta->timer.expires = jiffies + ap->max_inactivity;
+       sta->timer.data = (unsigned long) sta;
+       sta->timer.function = ap_handle_timer;
+       if (!ap->local->hostapd)
+               add_timer(&sta->timer);
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+       return sta;
+}
+
+
+static int ap_tx_rate_ok(int rateidx, struct sta_info *sta,
+                        local_info_t *local)
+{
+       if (rateidx > sta->tx_max_rate ||
+           !(sta->tx_supp_rates & (1 << rateidx)))
+               return 0;
+
+       if (local->tx_rate_control != 0 &&
+           !(local->tx_rate_control & (1 << rateidx)))
+               return 0;
+
+       return 1;
+}
+
+
+static void prism2_check_tx_rates(struct sta_info *sta)
+{
+       int i;
+
+       sta->tx_supp_rates = 0;
+       for (i = 0; i < sizeof(sta->supported_rates); i++) {
+               if ((sta->supported_rates[i] & 0x7f) == 2)
+                       sta->tx_supp_rates |= WLAN_RATE_1M;
+               if ((sta->supported_rates[i] & 0x7f) == 4)
+                       sta->tx_supp_rates |= WLAN_RATE_2M;
+               if ((sta->supported_rates[i] & 0x7f) == 11)
+                       sta->tx_supp_rates |= WLAN_RATE_5M5;
+               if ((sta->supported_rates[i] & 0x7f) == 22)
+                       sta->tx_supp_rates |= WLAN_RATE_11M;
+       }
+       sta->tx_max_rate = sta->tx_rate = sta->tx_rate_idx = 0;
+       if (sta->tx_supp_rates & WLAN_RATE_1M) {
+               sta->tx_max_rate = 0;
+               if (ap_tx_rate_ok(0, sta, sta->local)) {
+                       sta->tx_rate = 10;
+                       sta->tx_rate_idx = 0;
+               }
+       }
+       if (sta->tx_supp_rates & WLAN_RATE_2M) {
+               sta->tx_max_rate = 1;
+               if (ap_tx_rate_ok(1, sta, sta->local)) {
+                       sta->tx_rate = 20;
+                       sta->tx_rate_idx = 1;
+               }
+       }
+       if (sta->tx_supp_rates & WLAN_RATE_5M5) {
+               sta->tx_max_rate = 2;
+               if (ap_tx_rate_ok(2, sta, sta->local)) {
+                       sta->tx_rate = 55;
+                       sta->tx_rate_idx = 2;
+               }
+       }
+       if (sta->tx_supp_rates & WLAN_RATE_11M) {
+               sta->tx_max_rate = 3;
+               if (ap_tx_rate_ok(3, sta, sta->local)) {
+                       sta->tx_rate = 110;
+                       sta->tx_rate_idx = 3;
+               }
+       }
+}
+
+
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+
+static void ap_crypt_init(struct ap_data *ap)
+{
+       ap->crypt = ieee80211_get_crypto_ops("WEP");
+
+       if (ap->crypt) {
+               if (ap->crypt->init) {
+                       ap->crypt_priv = ap->crypt->init(0);
+                       if (ap->crypt_priv == NULL)
+                               ap->crypt = NULL;
+                       else {
+                               u8 key[WEP_KEY_LEN];
+                               get_random_bytes(key, WEP_KEY_LEN);
+                               ap->crypt->set_key(key, WEP_KEY_LEN, NULL,
+                                                  ap->crypt_priv);
+                       }
+               }
+       }
+
+       if (ap->crypt == NULL) {
+               printk(KERN_WARNING "AP could not initialize WEP: load module "
+                      "ieee80211_crypt_wep.ko\n");
+       }
+}
+
+
+/* Generate challenge data for shared key authentication. IEEE 802.11 specifies
+ * that WEP algorithm is used for generating challange. This should be unique,
+ * but otherwise there is not really need for randomness etc. Initialize WEP
+ * with pseudo random key and then use increasing IV to get unique challenge
+ * streams.
+ *
+ * Called only as a scheduled task for pending AP frames.
+ */
+static char * ap_auth_make_challenge(struct ap_data *ap)
+{
+       char *tmpbuf;
+       struct sk_buff *skb;
+
+       if (ap->crypt == NULL) {
+               ap_crypt_init(ap);
+               if (ap->crypt == NULL)
+                       return NULL;
+       }
+
+       tmpbuf = (char *) kmalloc(WLAN_AUTH_CHALLENGE_LEN, GFP_ATOMIC);
+       if (tmpbuf == NULL) {
+               PDEBUG(DEBUG_AP, "AP: kmalloc failed for challenge\n");
+               return NULL;
+       }
+
+       skb = dev_alloc_skb(WLAN_AUTH_CHALLENGE_LEN +
+                           ap->crypt->extra_prefix_len +
+                           ap->crypt->extra_postfix_len);
+       if (skb == NULL) {
+               kfree(tmpbuf);
+               return NULL;
+       }
+
+       skb_reserve(skb, ap->crypt->extra_prefix_len);
+       memset(skb_put(skb, WLAN_AUTH_CHALLENGE_LEN), 0,
+              WLAN_AUTH_CHALLENGE_LEN);
+       if (ap->crypt->encrypt_mpdu(skb, 0, ap->crypt_priv)) {
+               dev_kfree_skb(skb);
+               kfree(tmpbuf);
+               return NULL;
+       }
+
+       memcpy(tmpbuf, skb->data + ap->crypt->extra_prefix_len,
+              WLAN_AUTH_CHALLENGE_LEN);
+       dev_kfree_skb(skb);
+
+       return tmpbuf;
+}
+
+
+/* Called only as a scheduled task for pending AP frames. */
+static void handle_authen(local_info_t *local, struct sk_buff *skb,
+                         struct hostap_80211_rx_status *rx_stats)
+{
+       struct net_device *dev = local->dev;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+       size_t hdrlen;
+       struct ap_data *ap = local->ap;
+       char body[8 + WLAN_AUTH_CHALLENGE_LEN], *challenge = NULL;
+       int len, olen;
+       u16 auth_alg, auth_transaction, status_code, *pos;
+       u16 resp = WLAN_STATUS_SUCCESS, fc;
+       struct sta_info *sta = NULL;
+       struct ieee80211_crypt_data *crypt;
+       char *txt = "";
+
+       len = skb->len - IEEE80211_MGMT_HDR_LEN;
+
+       fc = le16_to_cpu(hdr->frame_ctl);
+       hdrlen = hostap_80211_get_hdrlen(fc);
+
+       if (len < 6) {
+               PDEBUG(DEBUG_AP, "%s: handle_authen - too short payload "
+                      "(len=%d) from " MACSTR "\n", dev->name, len,
+                      MAC2STR(hdr->addr2));
+               return;
+       }
+
+       spin_lock_bh(&local->ap->sta_table_lock);
+       sta = ap_get_sta(local->ap, hdr->addr2);
+       if (sta)
+               atomic_inc(&sta->users);
+       spin_unlock_bh(&local->ap->sta_table_lock);
+
+       if (sta && sta->crypt)
+               crypt = sta->crypt;
+       else {
+               int idx = 0;
+               if (skb->len >= hdrlen + 3)
+                       idx = skb->data[hdrlen + 3] >> 6;
+               crypt = local->crypt[idx];
+       }
+
+       pos = (u16 *) (skb->data + IEEE80211_MGMT_HDR_LEN);
+       auth_alg = __le16_to_cpu(*pos);
+       pos++;
+       auth_transaction = __le16_to_cpu(*pos);
+       pos++;
+       status_code = __le16_to_cpu(*pos);
+       pos++;
+
+       if (memcmp(dev->dev_addr, hdr->addr2, ETH_ALEN) == 0 ||
+           ap_control_mac_deny(&ap->mac_restrictions, hdr->addr2)) {
+               txt = "authentication denied";
+               resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
+               goto fail;
+       }
+
+       if (((local->auth_algs & PRISM2_AUTH_OPEN) &&
+            auth_alg == WLAN_AUTH_OPEN) ||
+           ((local->auth_algs & PRISM2_AUTH_SHARED_KEY) &&
+            crypt && auth_alg == WLAN_AUTH_SHARED_KEY)) {
+       } else {
+               txt = "unsupported algorithm";
+               resp = WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
+               goto fail;
+       }
+
+       if (len >= 8) {
+               u8 *u = (u8 *) pos;
+               if (*u == WLAN_EID_CHALLENGE) {
+                       if (*(u + 1) != WLAN_AUTH_CHALLENGE_LEN) {
+                               txt = "invalid challenge len";
+                               resp = WLAN_STATUS_CHALLENGE_FAIL;
+                               goto fail;
+                       }
+                       if (len - 8 < WLAN_AUTH_CHALLENGE_LEN) {
+                               txt = "challenge underflow";
+                               resp = WLAN_STATUS_CHALLENGE_FAIL;
+                               goto fail;
+                       }
+                       challenge = (char *) (u + 2);
+               }
+       }
+
+       if (sta && sta->ap) {
+               if (time_after(jiffies, sta->u.ap.last_beacon +
+                              (10 * sta->listen_interval * HZ) / 1024)) {
+                       PDEBUG(DEBUG_AP, "%s: no beacons received for a while,"
+                              " assuming AP " MACSTR " is now STA\n",
+                              dev->name, MAC2STR(sta->addr));
+                       sta->ap = 0;
+                       sta->flags = 0;
+                       sta->u.sta.challenge = NULL;
+               } else {
+                       txt = "AP trying to authenticate?";
+                       resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
+                       goto fail;
+               }
+       }
+
+       if ((auth_alg == WLAN_AUTH_OPEN && auth_transaction == 1) ||
+           (auth_alg == WLAN_AUTH_SHARED_KEY &&
+            (auth_transaction == 1 ||
+             (auth_transaction == 3 && sta != NULL &&
+              sta->u.sta.challenge != NULL)))) {
+       } else {
+               txt = "unknown authentication transaction number";
+               resp = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
+               goto fail;
+       }
+
+       if (sta == NULL) {
+               txt = "new STA";
+
+               if (local->ap->num_sta >= MAX_STA_COUNT) {
+                       /* FIX: might try to remove some old STAs first? */
+                       txt = "no more room for new STAs";
+                       resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
+                       goto fail;
+               }
+
+               sta = ap_add_sta(local->ap, hdr->addr2);
+               if (sta == NULL) {
+                       txt = "ap_add_sta failed";
+                       resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
+                       goto fail;
+               }
+       }
+
+       switch (auth_alg) {
+       case WLAN_AUTH_OPEN:
+               txt = "authOK";
+               /* IEEE 802.11 standard is not completely clear about
+                * whether STA is considered authenticated after
+                * authentication OK frame has been send or after it
+                * has been ACKed. In order to reduce interoperability
+                * issues, mark the STA authenticated before ACK. */
+               sta->flags |= WLAN_STA_AUTH;
+               break;
+
+       case WLAN_AUTH_SHARED_KEY:
+               if (auth_transaction == 1) {
+                       if (sta->u.sta.challenge == NULL) {
+                               sta->u.sta.challenge =
+                                       ap_auth_make_challenge(local->ap);
+                               if (sta->u.sta.challenge == NULL) {
+                                       resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
+                                       goto fail;
+                               }
+                       }
+               } else {
+                       if (sta->u.sta.challenge == NULL ||
+                           challenge == NULL ||
+                           memcmp(sta->u.sta.challenge, challenge,
+                                  WLAN_AUTH_CHALLENGE_LEN) != 0 ||
+                           !(fc & IEEE80211_FCTL_PROTECTED)) {
+                               txt = "challenge response incorrect";
+                               resp = WLAN_STATUS_CHALLENGE_FAIL;
+                               goto fail;
+                       }
+
+                       txt = "challenge OK - authOK";
+                       /* IEEE 802.11 standard is not completely clear about
+                        * whether STA is considered authenticated after
+                        * authentication OK frame has been send or after it
+                        * has been ACKed. In order to reduce interoperability
+                        * issues, mark the STA authenticated before ACK. */
+                       sta->flags |= WLAN_STA_AUTH;
+                       kfree(sta->u.sta.challenge);
+                       sta->u.sta.challenge = NULL;
+               }
+               break;
+       }
+
+ fail:
+       pos = (u16 *) body;
+       *pos = cpu_to_le16(auth_alg);
+       pos++;
+       *pos = cpu_to_le16(auth_transaction + 1);
+       pos++;
+       *pos = cpu_to_le16(resp); /* status_code */
+       pos++;
+       olen = 6;
+
+       if (resp == WLAN_STATUS_SUCCESS && sta != NULL &&
+           sta->u.sta.challenge != NULL &&
+           auth_alg == WLAN_AUTH_SHARED_KEY && auth_transaction == 1) {
+               u8 *tmp = (u8 *) pos;
+               *tmp++ = WLAN_EID_CHALLENGE;
+               *tmp++ = WLAN_AUTH_CHALLENGE_LEN;
+               pos++;
+               memcpy(pos, sta->u.sta.challenge, WLAN_AUTH_CHALLENGE_LEN);
+               olen += 2 + WLAN_AUTH_CHALLENGE_LEN;
+       }
+
+       prism2_send_mgmt(dev, IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH,
+                        body, olen, hdr->addr2, ap->tx_callback_auth);
+
+       if (sta) {
+               sta->last_rx = jiffies;
+               atomic_dec(&sta->users);
+       }
+
+       if (resp) {
+               PDEBUG(DEBUG_AP, "%s: " MACSTR " auth (alg=%d trans#=%d "
+                      "stat=%d len=%d fc=%04x) ==> %d (%s)\n",
+                      dev->name, MAC2STR(hdr->addr2), auth_alg,
+                      auth_transaction, status_code, len, fc, resp, txt);
+       }
+}
+
+
+/* Called only as a scheduled task for pending AP frames. */
+static void handle_assoc(local_info_t *local, struct sk_buff *skb,
+                        struct hostap_80211_rx_status *rx_stats, int reassoc)
+{
+       struct net_device *dev = local->dev;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+       char body[12], *p, *lpos;
+       int len, left;
+       u16 *pos;
+       u16 resp = WLAN_STATUS_SUCCESS;
+       struct sta_info *sta = NULL;
+       int send_deauth = 0;
+       char *txt = "";
+       u8 prev_ap[ETH_ALEN];
+
+       left = len = skb->len - IEEE80211_MGMT_HDR_LEN;
+
+       if (len < (reassoc ? 10 : 4)) {
+               PDEBUG(DEBUG_AP, "%s: handle_assoc - too short payload "
+                      "(len=%d, reassoc=%d) from " MACSTR "\n",
+                      dev->name, len, reassoc, MAC2STR(hdr->addr2));
+               return;
+       }
+
+       spin_lock_bh(&local->ap->sta_table_lock);
+       sta = ap_get_sta(local->ap, hdr->addr2);
+       if (sta == NULL || (sta->flags & WLAN_STA_AUTH) == 0) {
+               spin_unlock_bh(&local->ap->sta_table_lock);
+               txt = "trying to associate before authentication";
+               send_deauth = 1;
+               resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
+               sta = NULL; /* do not decrement sta->users */
+               goto fail;
+       }
+       atomic_inc(&sta->users);
+       spin_unlock_bh(&local->ap->sta_table_lock);
+
+       pos = (u16 *) (skb->data + IEEE80211_MGMT_HDR_LEN);
+       sta->capability = __le16_to_cpu(*pos);
+       pos++; left -= 2;
+       sta->listen_interval = __le16_to_cpu(*pos);
+       pos++; left -= 2;
+
+       if (reassoc) {
+               memcpy(prev_ap, pos, ETH_ALEN);
+               pos++; pos++; pos++; left -= 6;
+       } else
+               memset(prev_ap, 0, ETH_ALEN);
+
+       if (left >= 2) {
+               unsigned int ileft;
+               unsigned char *u = (unsigned char *) pos;
+
+               if (*u == WLAN_EID_SSID) {
+                       u++; left--;
+                       ileft = *u;
+                       u++; left--;
+
+                       if (ileft > left || ileft > MAX_SSID_LEN) {
+                               txt = "SSID overflow";
+                               resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
+                               goto fail;
+                       }
+
+                       if (ileft != strlen(local->essid) ||
+                           memcmp(local->essid, u, ileft) != 0) {
+                               txt = "not our SSID";
+                               resp = WLAN_STATUS_ASSOC_DENIED_UNSPEC;
+                               goto fail;
+                       }
+
+                       u += ileft;
+                       left -= ileft;
+               }
+
+               if (left >= 2 && *u == WLAN_EID_SUPP_RATES) {
+                       u++; left--;
+                       ileft = *u;
+                       u++; left--;
+
+                       if (ileft > left || ileft == 0 ||
+                           ileft > WLAN_SUPP_RATES_MAX) {
+                               txt = "SUPP_RATES len error";
+                               resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
+                               goto fail;
+                       }
+
+                       memset(sta->supported_rates, 0,
+                              sizeof(sta->supported_rates));
+                       memcpy(sta->supported_rates, u, ileft);
+                       prism2_check_tx_rates(sta);
+
+                       u += ileft;
+                       left -= ileft;
+               }
+
+               if (left > 0) {
+                       PDEBUG(DEBUG_AP, "%s: assoc from " MACSTR " with extra"
+                              " data (%d bytes) [",
+                              dev->name, MAC2STR(hdr->addr2), left);
+                       while (left > 0) {
+                               PDEBUG2(DEBUG_AP, "<%02x>", *u);
+                               u++; left--;
+                       }
+                       PDEBUG2(DEBUG_AP, "]\n");
+               }
+       } else {
+               txt = "frame underflow";
+               resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
+               goto fail;
+       }
+
+       /* get a unique AID */
+       if (sta->aid > 0)
+               txt = "OK, old AID";
+       else {
+               spin_lock_bh(&local->ap->sta_table_lock);
+               for (sta->aid = 1; sta->aid <= MAX_AID_TABLE_SIZE; sta->aid++)
+                       if (local->ap->sta_aid[sta->aid - 1] == NULL)
+                               break;
+               if (sta->aid > MAX_AID_TABLE_SIZE) {
+                       sta->aid = 0;
+                       spin_unlock_bh(&local->ap->sta_table_lock);
+                       resp = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;
+                       txt = "no room for more AIDs";
+               } else {
+                       local->ap->sta_aid[sta->aid - 1] = sta;
+                       spin_unlock_bh(&local->ap->sta_table_lock);
+                       txt = "OK, new AID";
+               }
+       }
+
+ fail:
+       pos = (u16 *) body;
+
+       if (send_deauth) {
+               *pos = __constant_cpu_to_le16(
+                       WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH);
+               pos++;
+       } else {
+               /* FIX: CF-Pollable and CF-PollReq should be set to match the
+                * values in beacons/probe responses */
+               /* FIX: how about privacy and WEP? */
+               /* capability */
+               *pos = __constant_cpu_to_le16(WLAN_CAPABILITY_ESS);
+               pos++;
+
+               /* status_code */
+               *pos = __cpu_to_le16(resp);
+               pos++;
+
+               *pos = __cpu_to_le16((sta && sta->aid > 0 ? sta->aid : 0) |
+                                    BIT(14) | BIT(15)); /* AID */
+               pos++;
+
+               /* Supported rates (Information element) */
+               p = (char *) pos;
+               *p++ = WLAN_EID_SUPP_RATES;
+               lpos = p;
+               *p++ = 0; /* len */
+               if (local->tx_rate_control & WLAN_RATE_1M) {
+                       *p++ = local->basic_rates & WLAN_RATE_1M ? 0x82 : 0x02;
+                       (*lpos)++;
+               }
+               if (local->tx_rate_control & WLAN_RATE_2M) {
+                       *p++ = local->basic_rates & WLAN_RATE_2M ? 0x84 : 0x04;
+                       (*lpos)++;
+               }
+               if (local->tx_rate_control & WLAN_RATE_5M5) {
+                       *p++ = local->basic_rates & WLAN_RATE_5M5 ?
+                               0x8b : 0x0b;
+                       (*lpos)++;
+               }
+               if (local->tx_rate_control & WLAN_RATE_11M) {
+                       *p++ = local->basic_rates & WLAN_RATE_11M ?
+                               0x96 : 0x16;
+                       (*lpos)++;
+               }
+               pos = (u16 *) p;
+       }
+
+       prism2_send_mgmt(dev, IEEE80211_FTYPE_MGMT |
+                        (send_deauth ? IEEE80211_STYPE_DEAUTH :
+                         (reassoc ? IEEE80211_STYPE_REASSOC_RESP :
+                          IEEE80211_STYPE_ASSOC_RESP)),
+                        body, (u8 *) pos - (u8 *) body,
+                        hdr->addr2,
+                        send_deauth ? 0 : local->ap->tx_callback_assoc);
+
+       if (sta) {
+               if (resp == WLAN_STATUS_SUCCESS) {
+                       sta->last_rx = jiffies;
+                       /* STA will be marked associated from TX callback, if
+                        * AssocResp is ACKed */
+               }
+               atomic_dec(&sta->users);
+       }
+
+#if 0
+       PDEBUG(DEBUG_AP, "%s: " MACSTR " %sassoc (len=%d prev_ap=" MACSTR
+              ") => %d(%d) (%s)\n",
+              dev->name, MAC2STR(hdr->addr2), reassoc ? "re" : "", len,
+              MAC2STR(prev_ap), resp, send_deauth, txt);
+#endif
+}
+
+
+/* Called only as a scheduled task for pending AP frames. */
+static void handle_deauth(local_info_t *local, struct sk_buff *skb,
+                         struct hostap_80211_rx_status *rx_stats)
+{
+       struct net_device *dev = local->dev;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+       char *body = (char *) (skb->data + IEEE80211_MGMT_HDR_LEN);
+       int len;
+       u16 reason_code, *pos;
+       struct sta_info *sta = NULL;
+
+       len = skb->len - IEEE80211_MGMT_HDR_LEN;
+
+       if (len < 2) {
+               printk("handle_deauth - too short payload (len=%d)\n", len);
+               return;
+       }
+
+       pos = (u16 *) body;
+       reason_code = __le16_to_cpu(*pos);
+
+       PDEBUG(DEBUG_AP, "%s: deauthentication: " MACSTR " len=%d, "
+              "reason_code=%d\n", dev->name, MAC2STR(hdr->addr2), len,
+              reason_code);
+
+       spin_lock_bh(&local->ap->sta_table_lock);
+       sta = ap_get_sta(local->ap, hdr->addr2);
+       if (sta != NULL) {
+               if ((sta->flags & WLAN_STA_ASSOC) && !sta->ap)
+                       hostap_event_expired_sta(local->dev, sta);
+               sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
+       }
+       spin_unlock_bh(&local->ap->sta_table_lock);
+       if (sta == NULL) {
+               printk("%s: deauthentication from " MACSTR ", "
+              "reason_code=%d, but STA not authenticated\n", dev->name,
+                      MAC2STR(hdr->addr2), reason_code);
+       }
+}
+
+
+/* Called only as a scheduled task for pending AP frames. */
+static void handle_disassoc(local_info_t *local, struct sk_buff *skb,
+                           struct hostap_80211_rx_status *rx_stats)
+{
+       struct net_device *dev = local->dev;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+       char *body = skb->data + IEEE80211_MGMT_HDR_LEN;
+       int len;
+       u16 reason_code, *pos;
+       struct sta_info *sta = NULL;
+
+       len = skb->len - IEEE80211_MGMT_HDR_LEN;
+
+       if (len < 2) {
+               printk("handle_disassoc - too short payload (len=%d)\n", len);
+               return;
+       }
+
+       pos = (u16 *) body;
+       reason_code = __le16_to_cpu(*pos);
+
+       PDEBUG(DEBUG_AP, "%s: disassociation: " MACSTR " len=%d, "
+              "reason_code=%d\n", dev->name, MAC2STR(hdr->addr2), len,
+              reason_code);
+
+       spin_lock_bh(&local->ap->sta_table_lock);
+       sta = ap_get_sta(local->ap, hdr->addr2);
+       if (sta != NULL) {
+               if ((sta->flags & WLAN_STA_ASSOC) && !sta->ap)
+                       hostap_event_expired_sta(local->dev, sta);
+               sta->flags &= ~WLAN_STA_ASSOC;
+       }
+       spin_unlock_bh(&local->ap->sta_table_lock);
+       if (sta == NULL) {
+               printk("%s: disassociation from " MACSTR ", "
+                      "reason_code=%d, but STA not authenticated\n",
+                      dev->name, MAC2STR(hdr->addr2), reason_code);
+       }
+}
+
+
+/* Called only as a scheduled task for pending AP frames. */
+static void ap_handle_data_nullfunc(local_info_t *local,
+                                   struct ieee80211_hdr *hdr)
+{
+       struct net_device *dev = local->dev;
+
+       /* some STA f/w's seem to require control::ACK frame for
+        * data::nullfunc, but at least Prism2 station f/w version 0.8.0 does
+        * not send this..
+        * send control::ACK for the data::nullfunc */
+
+       printk(KERN_DEBUG "Sending control::ACK for data::nullfunc\n");
+       prism2_send_mgmt(dev, IEEE80211_FTYPE_CTL | IEEE80211_STYPE_ACK,
+                        NULL, 0, hdr->addr2, 0);
+}
+
+
+/* Called only as a scheduled task for pending AP frames. */
+static void ap_handle_dropped_data(local_info_t *local,
+                                  struct ieee80211_hdr *hdr)
+{
+       struct net_device *dev = local->dev;
+       struct sta_info *sta;
+       u16 reason;
+
+       spin_lock_bh(&local->ap->sta_table_lock);
+       sta = ap_get_sta(local->ap, hdr->addr2);
+       if (sta)
+               atomic_inc(&sta->users);
+       spin_unlock_bh(&local->ap->sta_table_lock);
+
+       if (sta != NULL && (sta->flags & WLAN_STA_ASSOC)) {
+               PDEBUG(DEBUG_AP, "ap_handle_dropped_data: STA is now okay?\n");
+               atomic_dec(&sta->users);
+               return;
+       }
+
+       reason = __constant_cpu_to_le16(
+               WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
+       prism2_send_mgmt(dev, IEEE80211_FTYPE_MGMT |
+                        ((sta == NULL || !(sta->flags & WLAN_STA_ASSOC)) ?
+                         IEEE80211_STYPE_DEAUTH : IEEE80211_STYPE_DISASSOC),
+                        (char *) &reason, sizeof(reason), hdr->addr2, 0);
+
+       if (sta)
+               atomic_dec(&sta->users);
+}
+
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+
+/* Called only as a scheduled task for pending AP frames. */
+static void pspoll_send_buffered(local_info_t *local, struct sta_info *sta,
+                                struct sk_buff *skb)
+{
+       struct hostap_skb_tx_data *meta;
+
+       if (!(sta->flags & WLAN_STA_PS)) {
+               /* Station has moved to non-PS mode, so send all buffered
+                * frames using normal device queue. */
+               dev_queue_xmit(skb);
+               return;
+       }
+
+       /* add a flag for hostap_handle_sta_tx() to know that this skb should
+        * be passed through even though STA is using PS */
+       meta = (struct hostap_skb_tx_data *) skb->cb;
+       meta->flags |= HOSTAP_TX_FLAGS_BUFFERED_FRAME;
+       if (!skb_queue_empty(&sta->tx_buf)) {
+               /* indicate to STA that more frames follow */
+               meta->flags |= HOSTAP_TX_FLAGS_ADD_MOREDATA;
+       }
+       dev_queue_xmit(skb);
+}
+
+
+/* Called only as a scheduled task for pending AP frames. */
+static void handle_pspoll(local_info_t *local,
+                         struct ieee80211_hdr *hdr,
+                         struct hostap_80211_rx_status *rx_stats)
+{
+       struct net_device *dev = local->dev;
+       struct sta_info *sta;
+       u16 aid;
+       struct sk_buff *skb;
+
+       PDEBUG(DEBUG_PS2, "handle_pspoll: BSSID=" MACSTR ", TA=" MACSTR
+              " PWRMGT=%d\n",
+              MAC2STR(hdr->addr1), MAC2STR(hdr->addr2),
+              !!(le16_to_cpu(hdr->frame_ctl) & IEEE80211_FCTL_PM));
+
+       if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) {
+               PDEBUG(DEBUG_AP, "handle_pspoll - addr1(BSSID)=" MACSTR
+                      " not own MAC\n", MAC2STR(hdr->addr1));
+               return;
+       }
+
+       aid = __le16_to_cpu(hdr->duration_id);
+       if ((aid & (BIT(15) | BIT(14))) != (BIT(15) | BIT(14))) {
+               PDEBUG(DEBUG_PS, "   PSPOLL and AID[15:14] not set\n");
+               return;
+       }
+       aid &= ~BIT(15) & ~BIT(14);
+       if (aid == 0 || aid > MAX_AID_TABLE_SIZE) {
+               PDEBUG(DEBUG_PS, "   invalid aid=%d\n", aid);
+               return;
+       }
+       PDEBUG(DEBUG_PS2, "   aid=%d\n", aid);
+
+       spin_lock_bh(&local->ap->sta_table_lock);
+       sta = ap_get_sta(local->ap, hdr->addr2);
+       if (sta)
+               atomic_inc(&sta->users);
+       spin_unlock_bh(&local->ap->sta_table_lock);
+
+       if (sta == NULL) {
+               PDEBUG(DEBUG_PS, "   STA not found\n");
+               return;
+       }
+       if (sta->aid != aid) {
+               PDEBUG(DEBUG_PS, "   received aid=%i does not match with "
+                      "assoc.aid=%d\n", aid, sta->aid);
+               return;
+       }
+
+       /* FIX: todo:
+        * - add timeout for buffering (clear aid in TIM vector if buffer timed
+        *   out (expiry time must be longer than ListenInterval for
+        *   the corresponding STA; "8802-11: 11.2.1.9 AP aging function"
+        * - what to do, if buffered, pspolled, and sent frame is not ACKed by
+        *   sta; store buffer for later use and leave TIM aid bit set? use
+        *   TX event to check whether frame was ACKed?
+        */
+
+       while ((skb = skb_dequeue(&sta->tx_buf)) != NULL) {
+               /* send buffered frame .. */
+               PDEBUG(DEBUG_PS2, "Sending buffered frame to STA after PS POLL"
+                      " (buffer_count=%d)\n", skb_queue_len(&sta->tx_buf));
+
+               pspoll_send_buffered(local, sta, skb);
+
+               if (sta->flags & WLAN_STA_PS) {
+                       /* send only one buffered packet per PS Poll */
+                       /* FIX: should ignore further PS Polls until the
+                        * buffered packet that was just sent is acknowledged
+                        * (Tx or TxExc event) */
+                       break;
+               }
+       }
+
+       if (skb_queue_empty(&sta->tx_buf)) {
+               /* try to clear aid from TIM */
+               if (!(sta->flags & WLAN_STA_TIM))
+                       PDEBUG(DEBUG_PS2,  "Re-unsetting TIM for aid %d\n",
+                              aid);
+               hostap_set_tim(local, aid, 0);
+               sta->flags &= ~WLAN_STA_TIM;
+       }
+
+       atomic_dec(&sta->users);
+}
+
+
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+
+static void handle_wds_oper_queue(void *data)
+{
+       local_info_t *local = data;
+       struct wds_oper_data *entry, *prev;
+
+       spin_lock_bh(&local->lock);
+       entry = local->ap->wds_oper_entries;
+       local->ap->wds_oper_entries = NULL;
+       spin_unlock_bh(&local->lock);
+
+       while (entry) {
+               PDEBUG(DEBUG_AP, "%s: %s automatic WDS connection "
+                      "to AP " MACSTR "\n",
+                      local->dev->name,
+                      entry->type == WDS_ADD ? "adding" : "removing",
+                      MAC2STR(entry->addr));
+               if (entry->type == WDS_ADD)
+                       prism2_wds_add(local, entry->addr, 0);
+               else if (entry->type == WDS_DEL)
+                       prism2_wds_del(local, entry->addr, 0, 1);
+
+               prev = entry;
+               entry = entry->next;
+               kfree(prev);
+       }
+}
+
+
+/* Called only as a scheduled task for pending AP frames. */
+static void handle_beacon(local_info_t *local, struct sk_buff *skb,
+                         struct hostap_80211_rx_status *rx_stats)
+{
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+       char *body = skb->data + IEEE80211_MGMT_HDR_LEN;
+       int len, left;
+       u16 *pos, beacon_int, capability;
+       char *ssid = NULL;
+       unsigned char *supp_rates = NULL;
+       int ssid_len = 0, supp_rates_len = 0;
+       struct sta_info *sta = NULL;
+       int new_sta = 0, channel = -1;
+
+       len = skb->len - IEEE80211_MGMT_HDR_LEN;
+
+       if (len < 8 + 2 + 2) {
+               printk(KERN_DEBUG "handle_beacon - too short payload "
+                      "(len=%d)\n", len);
+               return;
+       }
+
+       pos = (u16 *) body;
+       left = len;
+
+       /* Timestamp (8 octets) */
+       pos += 4; left -= 8;
+       /* Beacon interval (2 octets) */
+       beacon_int = __le16_to_cpu(*pos);
+       pos++; left -= 2;
+       /* Capability information (2 octets) */
+       capability = __le16_to_cpu(*pos);
+       pos++; left -= 2;
+
+       if (local->ap->ap_policy != AP_OTHER_AP_EVEN_IBSS &&
+           capability & WLAN_CAPABILITY_IBSS)
+               return;
+
+       if (left >= 2) {
+               unsigned int ileft;
+               unsigned char *u = (unsigned char *) pos;
+
+               if (*u == WLAN_EID_SSID) {
+                       u++; left--;
+                       ileft = *u;
+                       u++; left--;
+
+                       if (ileft > left || ileft > MAX_SSID_LEN) {
+                               PDEBUG(DEBUG_AP, "SSID: overflow\n");
+                               return;
+                       }
+
+                       if (local->ap->ap_policy == AP_OTHER_AP_SAME_SSID &&
+                           (ileft != strlen(local->essid) ||
+                            memcmp(local->essid, u, ileft) != 0)) {
+                               /* not our SSID */
+                               return;
+                       }
+
+                       ssid = u;
+                       ssid_len = ileft;
+
+                       u += ileft;
+                       left -= ileft;
+               }
+
+               if (*u == WLAN_EID_SUPP_RATES) {
+                       u++; left--;
+                       ileft = *u;
+                       u++; left--;
+
+                       if (ileft > left || ileft == 0 || ileft > 8) {
+                               PDEBUG(DEBUG_AP, " - SUPP_RATES len error\n");
+                               return;
+                       }
+
+                       supp_rates = u;
+                       supp_rates_len = ileft;
+
+                       u += ileft;
+                       left -= ileft;
+               }
+
+               if (*u == WLAN_EID_DS_PARAMS) {
+                       u++; left--;
+                       ileft = *u;
+                       u++; left--;
+
+                       if (ileft > left || ileft != 1) {
+                               PDEBUG(DEBUG_AP, " - DS_PARAMS len error\n");
+                               return;
+                       }
+
+                       channel = *u;
+
+                       u += ileft;
+                       left -= ileft;
+               }
+       }
+
+       spin_lock_bh(&local->ap->sta_table_lock);
+       sta = ap_get_sta(local->ap, hdr->addr2);
+       if (sta != NULL)
+               atomic_inc(&sta->users);
+       spin_unlock_bh(&local->ap->sta_table_lock);
+
+       if (sta == NULL) {
+               /* add new AP */
+               new_sta = 1;
+               sta = ap_add_sta(local->ap, hdr->addr2);
+               if (sta == NULL) {
+                       printk(KERN_INFO "prism2: kmalloc failed for AP "
+                              "data structure\n");
+                       return;
+               }
+               hostap_event_new_sta(local->dev, sta);
+
+               /* mark APs authentication and associated for pseudo ad-hoc
+                * style communication */
+               sta->flags = WLAN_STA_AUTH | WLAN_STA_ASSOC;
+
+               if (local->ap->autom_ap_wds) {
+                       hostap_wds_link_oper(local, sta->addr, WDS_ADD);
+               }
+       }
+
+       sta->ap = 1;
+       if (ssid) {
+               sta->u.ap.ssid_len = ssid_len;
+               memcpy(sta->u.ap.ssid, ssid, ssid_len);
+               sta->u.ap.ssid[ssid_len] = '\0';
+       } else {
+               sta->u.ap.ssid_len = 0;
+               sta->u.ap.ssid[0] = '\0';
+       }
+       sta->u.ap.channel = channel;
+       sta->rx_packets++;
+       sta->rx_bytes += len;
+       sta->u.ap.last_beacon = sta->last_rx = jiffies;
+       sta->capability = capability;
+       sta->listen_interval = beacon_int;
+
+       atomic_dec(&sta->users);
+
+       if (new_sta) {
+               memset(sta->supported_rates, 0, sizeof(sta->supported_rates));
+               memcpy(sta->supported_rates, supp_rates, supp_rates_len);
+               prism2_check_tx_rates(sta);
+       }
+}
+
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+
+/* Called only as a tasklet. */
+static void handle_ap_item(local_info_t *local, struct sk_buff *skb,
+                          struct hostap_80211_rx_status *rx_stats)
+{
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+       struct net_device *dev = local->dev;
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+       u16 fc, type, stype;
+       struct ieee80211_hdr *hdr;
+
+       /* FIX: should give skb->len to handler functions and check that the
+        * buffer is long enough */
+       hdr = (struct ieee80211_hdr *) skb->data;
+       fc = le16_to_cpu(hdr->frame_ctl);
+       type = WLAN_FC_GET_TYPE(fc);
+       stype = WLAN_FC_GET_STYPE(fc);
+
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+       if (!local->hostapd && type == IEEE80211_FTYPE_DATA) {
+               PDEBUG(DEBUG_AP, "handle_ap_item - data frame\n");
+
+               if (!(fc & IEEE80211_FCTL_TODS) ||
+                   (fc & IEEE80211_FCTL_FROMDS)) {
+                       if (stype == IEEE80211_STYPE_NULLFUNC) {
+                               /* no ToDS nullfunc seems to be used to check
+                                * AP association; so send reject message to
+                                * speed up re-association */
+                               ap_handle_dropped_data(local, hdr);
+                               goto done;
+                       }
+                       PDEBUG(DEBUG_AP, "   not ToDS frame (fc=0x%04x)\n",
+                              fc);
+                       goto done;
+               }
+
+               if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) {
+                       PDEBUG(DEBUG_AP, "handle_ap_item - addr1(BSSID)="
+                              MACSTR " not own MAC\n",
+                              MAC2STR(hdr->addr1));
+                       goto done;
+               }
+
+               if (local->ap->nullfunc_ack &&
+                   stype == IEEE80211_STYPE_NULLFUNC)
+                       ap_handle_data_nullfunc(local, hdr);
+               else
+                       ap_handle_dropped_data(local, hdr);
+               goto done;
+       }
+
+       if (type == IEEE80211_FTYPE_MGMT && stype == IEEE80211_STYPE_BEACON) {
+               handle_beacon(local, skb, rx_stats);
+               goto done;
+       }
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+       if (type == IEEE80211_FTYPE_CTL && stype == IEEE80211_STYPE_PSPOLL) {
+               handle_pspoll(local, hdr, rx_stats);
+               goto done;
+       }
+
+       if (local->hostapd) {
+               PDEBUG(DEBUG_AP, "Unknown frame in AP queue: type=0x%02x "
+                      "subtype=0x%02x\n", type, stype);
+               goto done;
+       }
+
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+       if (type != IEEE80211_FTYPE_MGMT) {
+               PDEBUG(DEBUG_AP, "handle_ap_item - not a management frame?\n");
+               goto done;
+       }
+
+       if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) {
+               PDEBUG(DEBUG_AP, "handle_ap_item - addr1(DA)=" MACSTR
+                      " not own MAC\n", MAC2STR(hdr->addr1));
+               goto done;
+       }
+
+       if (memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN)) {
+               PDEBUG(DEBUG_AP, "handle_ap_item - addr3(BSSID)=" MACSTR
+                      " not own MAC\n", MAC2STR(hdr->addr3));
+               goto done;
+       }
+
+       switch (stype) {
+       case IEEE80211_STYPE_ASSOC_REQ:
+               handle_assoc(local, skb, rx_stats, 0);
+               break;
+       case IEEE80211_STYPE_ASSOC_RESP:
+               PDEBUG(DEBUG_AP, "==> ASSOC RESP (ignored)\n");
+               break;
+       case IEEE80211_STYPE_REASSOC_REQ:
+               handle_assoc(local, skb, rx_stats, 1);
+               break;
+       case IEEE80211_STYPE_REASSOC_RESP:
+               PDEBUG(DEBUG_AP, "==> REASSOC RESP (ignored)\n");
+               break;
+       case IEEE80211_STYPE_ATIM:
+               PDEBUG(DEBUG_AP, "==> ATIM (ignored)\n");
+               break;
+       case IEEE80211_STYPE_DISASSOC:
+               handle_disassoc(local, skb, rx_stats);
+               break;
+       case IEEE80211_STYPE_AUTH:
+               handle_authen(local, skb, rx_stats);
+               break;
+       case IEEE80211_STYPE_DEAUTH:
+               handle_deauth(local, skb, rx_stats);
+               break;
+       default:
+               PDEBUG(DEBUG_AP, "Unknown mgmt frame subtype 0x%02x\n",
+                      stype >> 4);
+               break;
+       }
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+ done:
+       dev_kfree_skb(skb);
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+void hostap_rx(struct net_device *dev, struct sk_buff *skb,
+              struct hostap_80211_rx_status *rx_stats)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       u16 fc;
+       struct ieee80211_hdr *hdr;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (skb->len < 16)
+               goto drop;
+
+       local->stats.rx_packets++;
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       fc = le16_to_cpu(hdr->frame_ctl);
+
+       if (local->ap->ap_policy == AP_OTHER_AP_SKIP_ALL &&
+           WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_MGMT &&
+           WLAN_FC_GET_STYPE(fc) == IEEE80211_STYPE_BEACON)
+               goto drop;
+
+       skb->protocol = __constant_htons(ETH_P_HOSTAP);
+       handle_ap_item(local, skb, rx_stats);
+       return;
+
+ drop:
+       dev_kfree_skb(skb);
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static void schedule_packet_send(local_info_t *local, struct sta_info *sta)
+{
+       struct sk_buff *skb;
+       struct ieee80211_hdr *hdr;
+       struct hostap_80211_rx_status rx_stats;
+
+       if (skb_queue_empty(&sta->tx_buf))
+               return;
+
+       skb = dev_alloc_skb(16);
+       if (skb == NULL) {
+               printk(KERN_DEBUG "%s: schedule_packet_send: skb alloc "
+                      "failed\n", local->dev->name);
+               return;
+       }
+
+       hdr = (struct ieee80211_hdr *) skb_put(skb, 16);
+
+       /* Generate a fake pspoll frame to start packet delivery */
+       hdr->frame_ctl = __constant_cpu_to_le16(
+               IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
+       memcpy(hdr->addr1, local->dev->dev_addr, ETH_ALEN);
+       memcpy(hdr->addr2, sta->addr, ETH_ALEN);
+       hdr->duration_id = cpu_to_le16(sta->aid | BIT(15) | BIT(14));
+
+       PDEBUG(DEBUG_PS2, "%s: Scheduling buffered packet delivery for "
+              "STA " MACSTR "\n", local->dev->name, MAC2STR(sta->addr));
+
+       skb->dev = local->dev;
+
+       memset(&rx_stats, 0, sizeof(rx_stats));
+       hostap_rx(local->dev, skb, &rx_stats);
+}
+
+
+static int prism2_ap_get_sta_qual(local_info_t *local, struct sockaddr addr[],
+                                 struct iw_quality qual[], int buf_size,
+                                 int aplist)
+{
+       struct ap_data *ap = local->ap;
+       struct list_head *ptr;
+       int count = 0;
+
+       spin_lock_bh(&ap->sta_table_lock);
+
+       for (ptr = ap->sta_list.next; ptr != NULL && ptr != &ap->sta_list;
+            ptr = ptr->next) {
+               struct sta_info *sta = (struct sta_info *) ptr;
+
+               if (aplist && !sta->ap)
+                       continue;
+               addr[count].sa_family = ARPHRD_ETHER;
+               memcpy(addr[count].sa_data, sta->addr, ETH_ALEN);
+               if (sta->last_rx_silence == 0)
+                       qual[count].qual = sta->last_rx_signal < 27 ?
+                               0 : (sta->last_rx_signal - 27) * 92 / 127;
+               else
+                       qual[count].qual = sta->last_rx_signal -
+                               sta->last_rx_silence - 35;
+               qual[count].level = HFA384X_LEVEL_TO_dBm(sta->last_rx_signal);
+               qual[count].noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
+               qual[count].updated = sta->last_rx_updated;
+
+               sta->last_rx_updated = 0;
+
+               count++;
+               if (count >= buf_size)
+                       break;
+       }
+       spin_unlock_bh(&ap->sta_table_lock);
+
+       return count;
+}
+
+
+/* Translate our list of Access Points & Stations to a card independant
+ * format that the Wireless Tools will understand - Jean II */
+static int prism2_ap_translate_scan(struct net_device *dev, char *buffer)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       struct ap_data *ap;
+       struct list_head *ptr;
+       struct iw_event iwe;
+       char *current_ev = buffer;
+       char *end_buf = buffer + IW_SCAN_MAX_DATA;
+#if !defined(PRISM2_NO_KERNEL_IEEE80211_MGMT)
+       char buf[64];
+#endif
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+       ap = local->ap;
+
+       spin_lock_bh(&ap->sta_table_lock);
+
+       for (ptr = ap->sta_list.next; ptr != NULL && ptr != &ap->sta_list;
+            ptr = ptr->next) {
+               struct sta_info *sta = (struct sta_info *) ptr;
+
+               /* First entry *MUST* be the AP MAC address */
+               memset(&iwe, 0, sizeof(iwe));
+               iwe.cmd = SIOCGIWAP;
+               iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
+               memcpy(iwe.u.ap_addr.sa_data, sta->addr, ETH_ALEN);
+               iwe.len = IW_EV_ADDR_LEN;
+               current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
+                                                 IW_EV_ADDR_LEN);
+
+               /* Use the mode to indicate if it's a station or
+                * an Access Point */
+               memset(&iwe, 0, sizeof(iwe));
+               iwe.cmd = SIOCGIWMODE;
+               if (sta->ap)
+                       iwe.u.mode = IW_MODE_MASTER;
+               else
+                       iwe.u.mode = IW_MODE_INFRA;
+               iwe.len = IW_EV_UINT_LEN;
+               current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
+                                                 IW_EV_UINT_LEN);
+
+               /* Some quality */
+               memset(&iwe, 0, sizeof(iwe));
+               iwe.cmd = IWEVQUAL;
+               if (sta->last_rx_silence == 0)
+                       iwe.u.qual.qual = sta->last_rx_signal < 27 ?
+                               0 : (sta->last_rx_signal - 27) * 92 / 127;
+               else
+                       iwe.u.qual.qual = sta->last_rx_signal -
+                               sta->last_rx_silence - 35;
+               iwe.u.qual.level = HFA384X_LEVEL_TO_dBm(sta->last_rx_signal);
+               iwe.u.qual.noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
+               iwe.u.qual.updated = sta->last_rx_updated;
+               iwe.len = IW_EV_QUAL_LEN;
+               current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
+                                                 IW_EV_QUAL_LEN);
+
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+               if (sta->ap) {
+                       memset(&iwe, 0, sizeof(iwe));
+                       iwe.cmd = SIOCGIWESSID;
+                       iwe.u.data.length = sta->u.ap.ssid_len;
+                       iwe.u.data.flags = 1;
+                       current_ev = iwe_stream_add_point(current_ev, end_buf,
+                                                         &iwe,
+                                                         sta->u.ap.ssid);
+
+                       memset(&iwe, 0, sizeof(iwe));
+                       iwe.cmd = SIOCGIWENCODE;
+                       if (sta->capability & WLAN_CAPABILITY_PRIVACY)
+                               iwe.u.data.flags =
+                                       IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
+                       else
+                               iwe.u.data.flags = IW_ENCODE_DISABLED;
+                       current_ev = iwe_stream_add_point(current_ev, end_buf,
+                                                         &iwe,
+                                                         sta->u.ap.ssid
+                                                         /* 0 byte memcpy */);
+
+                       if (sta->u.ap.channel > 0 &&
+                           sta->u.ap.channel <= FREQ_COUNT) {
+                               memset(&iwe, 0, sizeof(iwe));
+                               iwe.cmd = SIOCGIWFREQ;
+                               iwe.u.freq.m = freq_list[sta->u.ap.channel - 1]
+                                       * 100000;
+                               iwe.u.freq.e = 1;
+                               current_ev = iwe_stream_add_event(
+                                       current_ev, end_buf, &iwe,
+                                       IW_EV_FREQ_LEN);
+                       }
+
+                       memset(&iwe, 0, sizeof(iwe));
+                       iwe.cmd = IWEVCUSTOM;
+                       sprintf(buf, "beacon_interval=%d",
+                               sta->listen_interval);
+                       iwe.u.data.length = strlen(buf);
+                       current_ev = iwe_stream_add_point(current_ev, end_buf,
+                                                         &iwe, buf);
+               }
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+               sta->last_rx_updated = 0;
+
+               /* To be continued, we should make good use of IWEVCUSTOM */
+       }
+
+       spin_unlock_bh(&ap->sta_table_lock);
+
+       return current_ev - buffer;
+}
+
+
+static int prism2_hostapd_add_sta(struct ap_data *ap,
+                                 struct prism2_hostapd_param *param)
+{
+       struct sta_info *sta;
+
+       spin_lock_bh(&ap->sta_table_lock);
+       sta = ap_get_sta(ap, param->sta_addr);
+       if (sta)
+               atomic_inc(&sta->users);
+       spin_unlock_bh(&ap->sta_table_lock);
+
+       if (sta == NULL) {
+               sta = ap_add_sta(ap, param->sta_addr);
+               if (sta == NULL)
+                       return -1;
+       }
+
+       if (!(sta->flags & WLAN_STA_ASSOC) && !sta->ap && sta->local)
+               hostap_event_new_sta(sta->local->dev, sta);
+
+       sta->flags |= WLAN_STA_AUTH | WLAN_STA_ASSOC;
+       sta->last_rx = jiffies;
+       sta->aid = param->u.add_sta.aid;
+       sta->capability = param->u.add_sta.capability;
+       sta->tx_supp_rates = param->u.add_sta.tx_supp_rates;
+       if (sta->tx_supp_rates & WLAN_RATE_1M)
+               sta->supported_rates[0] = 2;
+       if (sta->tx_supp_rates & WLAN_RATE_2M)
+               sta->supported_rates[1] = 4;
+       if (sta->tx_supp_rates & WLAN_RATE_5M5)
+               sta->supported_rates[2] = 11;
+       if (sta->tx_supp_rates & WLAN_RATE_11M)
+               sta->supported_rates[3] = 22;
+       prism2_check_tx_rates(sta);
+       atomic_dec(&sta->users);
+       return 0;
+}
+
+
+static int prism2_hostapd_remove_sta(struct ap_data *ap,
+                                    struct prism2_hostapd_param *param)
+{
+       struct sta_info *sta;
+
+       spin_lock_bh(&ap->sta_table_lock);
+       sta = ap_get_sta(ap, param->sta_addr);
+       if (sta) {
+               ap_sta_hash_del(ap, sta);
+               list_del(&sta->list);
+       }
+       spin_unlock_bh(&ap->sta_table_lock);
+
+       if (!sta)
+               return -ENOENT;
+
+       if ((sta->flags & WLAN_STA_ASSOC) && !sta->ap && sta->local)
+               hostap_event_expired_sta(sta->local->dev, sta);
+       ap_free_sta(ap, sta);
+
+       return 0;
+}
+
+
+static int prism2_hostapd_get_info_sta(struct ap_data *ap,
+                                      struct prism2_hostapd_param *param)
+{
+       struct sta_info *sta;
+
+       spin_lock_bh(&ap->sta_table_lock);
+       sta = ap_get_sta(ap, param->sta_addr);
+       if (sta)
+               atomic_inc(&sta->users);
+       spin_unlock_bh(&ap->sta_table_lock);
+
+       if (!sta)
+               return -ENOENT;
+
+       param->u.get_info_sta.inactive_sec = (jiffies - sta->last_rx) / HZ;
+
+       atomic_dec(&sta->users);
+
+       return 1;
+}
+
+
+static int prism2_hostapd_set_flags_sta(struct ap_data *ap,
+                                       struct prism2_hostapd_param *param)
+{
+       struct sta_info *sta;
+
+       spin_lock_bh(&ap->sta_table_lock);
+       sta = ap_get_sta(ap, param->sta_addr);
+       if (sta) {
+               sta->flags |= param->u.set_flags_sta.flags_or;
+               sta->flags &= param->u.set_flags_sta.flags_and;
+       }
+       spin_unlock_bh(&ap->sta_table_lock);
+
+       if (!sta)
+               return -ENOENT;
+
+       return 0;
+}
+
+
+static int prism2_hostapd_sta_clear_stats(struct ap_data *ap,
+                                         struct prism2_hostapd_param *param)
+{
+       struct sta_info *sta;
+       int rate;
+
+       spin_lock_bh(&ap->sta_table_lock);
+       sta = ap_get_sta(ap, param->sta_addr);
+       if (sta) {
+               sta->rx_packets = sta->tx_packets = 0;
+               sta->rx_bytes = sta->tx_bytes = 0;
+               for (rate = 0; rate < WLAN_RATE_COUNT; rate++) {
+                       sta->tx_count[rate] = 0;
+                       sta->rx_count[rate] = 0;
+               }
+       }
+       spin_unlock_bh(&ap->sta_table_lock);
+
+       if (!sta)
+               return -ENOENT;
+
+       return 0;
+}
+
+
+static int prism2_hostapd(struct ap_data *ap,
+                         struct prism2_hostapd_param *param)
+{
+       switch (param->cmd) {
+       case PRISM2_HOSTAPD_FLUSH:
+               ap_control_kickall(ap);
+               return 0;
+       case PRISM2_HOSTAPD_ADD_STA:
+               return prism2_hostapd_add_sta(ap, param);
+       case PRISM2_HOSTAPD_REMOVE_STA:
+               return prism2_hostapd_remove_sta(ap, param);
+       case PRISM2_HOSTAPD_GET_INFO_STA:
+               return prism2_hostapd_get_info_sta(ap, param);
+       case PRISM2_HOSTAPD_SET_FLAGS_STA:
+               return prism2_hostapd_set_flags_sta(ap, param);
+       case PRISM2_HOSTAPD_STA_CLEAR_STATS:
+               return prism2_hostapd_sta_clear_stats(ap, param);
+       default:
+               printk(KERN_WARNING "prism2_hostapd: unknown cmd=%d\n",
+                      param->cmd);
+               return -EOPNOTSUPP;
+       }
+}
+
+
+/* Update station info for host-based TX rate control and return current
+ * TX rate */
+static int ap_update_sta_tx_rate(struct sta_info *sta, struct net_device *dev)
+{
+       int ret = sta->tx_rate;
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       sta->tx_count[sta->tx_rate_idx]++;
+       sta->tx_since_last_failure++;
+       sta->tx_consecutive_exc = 0;
+       if (sta->tx_since_last_failure >= WLAN_RATE_UPDATE_COUNT &&
+           sta->tx_rate_idx < sta->tx_max_rate) {
+               /* use next higher rate */
+               int old_rate, new_rate;
+               old_rate = new_rate = sta->tx_rate_idx;
+               while (new_rate < sta->tx_max_rate) {
+                       new_rate++;
+                       if (ap_tx_rate_ok(new_rate, sta, local)) {
+                               sta->tx_rate_idx = new_rate;
+                               break;
+                       }
+               }
+               if (old_rate != sta->tx_rate_idx) {
+                       switch (sta->tx_rate_idx) {
+                       case 0: sta->tx_rate = 10; break;
+                       case 1: sta->tx_rate = 20; break;
+                       case 2: sta->tx_rate = 55; break;
+                       case 3: sta->tx_rate = 110; break;
+                       default: sta->tx_rate = 0; break;
+                       }
+                       PDEBUG(DEBUG_AP, "%s: STA " MACSTR " TX rate raised to"
+                              " %d\n", dev->name, MAC2STR(sta->addr),
+                              sta->tx_rate);
+               }
+               sta->tx_since_last_failure = 0;
+       }
+
+       return ret;
+}
+
+
+/* Called only from software IRQ. Called for each TX frame prior possible
+ * encryption and transmit. */
+ap_tx_ret hostap_handle_sta_tx(local_info_t *local, struct hostap_tx_data *tx)
+{
+       struct sta_info *sta = NULL;
+       struct sk_buff *skb = tx->skb;
+       int set_tim, ret;
+       struct ieee80211_hdr *hdr;
+       struct hostap_skb_tx_data *meta;
+
+       meta = (struct hostap_skb_tx_data *) skb->cb;
+       ret = AP_TX_CONTINUE;
+       if (local->ap == NULL || skb->len < 10 ||
+           meta->iface->type == HOSTAP_INTERFACE_STA)
+               goto out;
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+
+       if (hdr->addr1[0] & 0x01) {
+               /* broadcast/multicast frame - no AP related processing */
+               goto out;
+       }
+
+       /* unicast packet - check whether destination STA is associated */
+       spin_lock(&local->ap->sta_table_lock);
+       sta = ap_get_sta(local->ap, hdr->addr1);
+       if (sta)
+               atomic_inc(&sta->users);
+       spin_unlock(&local->ap->sta_table_lock);
+
+       if (local->iw_mode == IW_MODE_MASTER && sta == NULL &&
+           !(meta->flags & HOSTAP_TX_FLAGS_WDS) &&
+           meta->iface->type != HOSTAP_INTERFACE_MASTER &&
+           meta->iface->type != HOSTAP_INTERFACE_AP) {
+#if 0
+               /* This can happen, e.g., when wlan0 is added to a bridge and
+                * bridging code does not know which port is the correct target
+                * for a unicast frame. In this case, the packet is send to all
+                * ports of the bridge. Since this is a valid scenario, do not
+                * print out any errors here. */
+               if (net_ratelimit()) {
+                       printk(KERN_DEBUG "AP: drop packet to non-associated "
+                              "STA " MACSTR "\n", MAC2STR(hdr->addr1));
+               }
+#endif
+               local->ap->tx_drop_nonassoc++;
+               ret = AP_TX_DROP;
+               goto out;
+       }
+
+       if (sta == NULL)
+               goto out;
+
+       if (!(sta->flags & WLAN_STA_AUTHORIZED))
+               ret = AP_TX_CONTINUE_NOT_AUTHORIZED;
+
+       /* Set tx_rate if using host-based TX rate control */
+       if (!local->fw_tx_rate_control)
+               local->ap->last_tx_rate = meta->rate =
+                       ap_update_sta_tx_rate(sta, local->dev);
+
+       if (local->iw_mode != IW_MODE_MASTER)
+               goto out;
+
+       if (!(sta->flags & WLAN_STA_PS))
+               goto out;
+
+       if (meta->flags & HOSTAP_TX_FLAGS_ADD_MOREDATA) {
+               /* indicate to STA that more frames follow */
+               hdr->frame_ctl |=
+                       __constant_cpu_to_le16(IEEE80211_FCTL_MOREDATA);
+       }
+
+       if (meta->flags & HOSTAP_TX_FLAGS_BUFFERED_FRAME) {
+               /* packet was already buffered and now send due to
+                * PS poll, so do not rebuffer it */
+               goto out;
+       }
+
+       if (skb_queue_len(&sta->tx_buf) >= STA_MAX_TX_BUFFER) {
+               PDEBUG(DEBUG_PS, "%s: No more space in STA (" MACSTR ")'s PS "
+                      "mode buffer\n", local->dev->name, MAC2STR(sta->addr));
+               /* Make sure that TIM is set for the station (it might not be
+                * after AP wlan hw reset). */
+               /* FIX: should fix hw reset to restore bits based on STA
+                * buffer state.. */
+               hostap_set_tim(local, sta->aid, 1);
+               sta->flags |= WLAN_STA_TIM;
+               ret = AP_TX_DROP;
+               goto out;
+       }
+
+       /* STA in PS mode, buffer frame for later delivery */
+       set_tim = skb_queue_empty(&sta->tx_buf);
+       skb_queue_tail(&sta->tx_buf, skb);
+       /* FIX: could save RX time to skb and expire buffered frames after
+        * some time if STA does not poll for them */
+
+       if (set_tim) {
+               if (sta->flags & WLAN_STA_TIM)
+                       PDEBUG(DEBUG_PS2, "Re-setting TIM for aid %d\n",
+                              sta->aid);
+               hostap_set_tim(local, sta->aid, 1);
+               sta->flags |= WLAN_STA_TIM;
+       }
+
+       ret = AP_TX_BUFFERED;
+
+ out:
+       if (sta != NULL) {
+               if (ret == AP_TX_CONTINUE ||
+                   ret == AP_TX_CONTINUE_NOT_AUTHORIZED) {
+                       sta->tx_packets++;
+                       sta->tx_bytes += skb->len;
+                       sta->last_tx = jiffies;
+               }
+
+               if ((ret == AP_TX_CONTINUE ||
+                    ret == AP_TX_CONTINUE_NOT_AUTHORIZED) &&
+                   sta->crypt && tx->host_encrypt) {
+                       tx->crypt = sta->crypt;
+                       tx->sta_ptr = sta; /* hostap_handle_sta_release() will
+                                           * be called to release sta info
+                                           * later */
+               } else
+                       atomic_dec(&sta->users);
+       }
+
+       return ret;
+}
+
+
+void hostap_handle_sta_release(void *ptr)
+{
+       struct sta_info *sta = ptr;
+       atomic_dec(&sta->users);
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+void hostap_handle_sta_tx_exc(local_info_t *local, struct sk_buff *skb)
+{
+       struct sta_info *sta;
+       struct ieee80211_hdr *hdr;
+       struct hostap_skb_tx_data *meta;
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       meta = (struct hostap_skb_tx_data *) skb->cb;
+
+       spin_lock(&local->ap->sta_table_lock);
+       sta = ap_get_sta(local->ap, hdr->addr1);
+       if (!sta) {
+               spin_unlock(&local->ap->sta_table_lock);
+               PDEBUG(DEBUG_AP, "%s: Could not find STA " MACSTR " for this "
+                      "TX error (@%lu)\n",
+                      local->dev->name, MAC2STR(hdr->addr1), jiffies);
+               return;
+       }
+
+       sta->tx_since_last_failure = 0;
+       sta->tx_consecutive_exc++;
+
+       if (sta->tx_consecutive_exc >= WLAN_RATE_DECREASE_THRESHOLD &&
+           sta->tx_rate_idx > 0 && meta->rate <= sta->tx_rate) {
+               /* use next lower rate */
+               int old, rate;
+               old = rate = sta->tx_rate_idx;
+               while (rate > 0) {
+                       rate--;
+                       if (ap_tx_rate_ok(rate, sta, local)) {
+                               sta->tx_rate_idx = rate;
+                               break;
+                       }
+               }
+               if (old != sta->tx_rate_idx) {
+                       switch (sta->tx_rate_idx) {
+                       case 0: sta->tx_rate = 10; break;
+                       case 1: sta->tx_rate = 20; break;
+                       case 2: sta->tx_rate = 55; break;
+                       case 3: sta->tx_rate = 110; break;
+                       default: sta->tx_rate = 0; break;
+                       }
+                       PDEBUG(DEBUG_AP, "%s: STA " MACSTR " TX rate lowered "
+                              "to %d\n", local->dev->name, MAC2STR(sta->addr),
+                              sta->tx_rate);
+               }
+               sta->tx_consecutive_exc = 0;
+       }
+       spin_unlock(&local->ap->sta_table_lock);
+}
+
+
+static void hostap_update_sta_ps2(local_info_t *local, struct sta_info *sta,
+                                 int pwrmgt, int type, int stype)
+{
+       if (pwrmgt && !(sta->flags & WLAN_STA_PS)) {
+               sta->flags |= WLAN_STA_PS;
+               PDEBUG(DEBUG_PS2, "STA " MACSTR " changed to use PS "
+                      "mode (type=0x%02X, stype=0x%02X)\n",
+                      MAC2STR(sta->addr), type >> 2, stype >> 4);
+       } else if (!pwrmgt && (sta->flags & WLAN_STA_PS)) {
+               sta->flags &= ~WLAN_STA_PS;
+               PDEBUG(DEBUG_PS2, "STA " MACSTR " changed to not use "
+                      "PS mode (type=0x%02X, stype=0x%02X)\n",
+                      MAC2STR(sta->addr), type >> 2, stype >> 4);
+               if (type != IEEE80211_FTYPE_CTL ||
+                   stype != IEEE80211_STYPE_PSPOLL)
+                       schedule_packet_send(local, sta);
+       }
+}
+
+
+/* Called only as a tasklet (software IRQ). Called for each RX frame to update
+ * STA power saving state. pwrmgt is a flag from 802.11 frame_ctl field. */
+int hostap_update_sta_ps(local_info_t *local, struct ieee80211_hdr *hdr)
+{
+       struct sta_info *sta;
+       u16 fc;
+
+       spin_lock(&local->ap->sta_table_lock);
+       sta = ap_get_sta(local->ap, hdr->addr2);
+       if (sta)
+               atomic_inc(&sta->users);
+       spin_unlock(&local->ap->sta_table_lock);
+
+       if (!sta)
+               return -1;
+
+       fc = le16_to_cpu(hdr->frame_ctl);
+       hostap_update_sta_ps2(local, sta, fc & IEEE80211_FCTL_PM,
+                             WLAN_FC_GET_TYPE(fc), WLAN_FC_GET_STYPE(fc));
+
+       atomic_dec(&sta->users);
+       return 0;
+}
+
+
+/* Called only as a tasklet (software IRQ). Called for each RX frame after
+ * getting RX header and payload from hardware. */
+ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
+                              struct sk_buff *skb,
+                              struct hostap_80211_rx_status *rx_stats,
+                              int wds)
+{
+       int ret;
+       struct sta_info *sta;
+       u16 fc, type, stype;
+       struct ieee80211_hdr *hdr;
+
+       if (local->ap == NULL)
+               return AP_RX_CONTINUE;
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+
+       fc = le16_to_cpu(hdr->frame_ctl);
+       type = WLAN_FC_GET_TYPE(fc);
+       stype = WLAN_FC_GET_STYPE(fc);
+
+       spin_lock(&local->ap->sta_table_lock);
+       sta = ap_get_sta(local->ap, hdr->addr2);
+       if (sta)
+               atomic_inc(&sta->users);
+       spin_unlock(&local->ap->sta_table_lock);
+
+       if (sta && !(sta->flags & WLAN_STA_AUTHORIZED))
+               ret = AP_RX_CONTINUE_NOT_AUTHORIZED;
+       else
+               ret = AP_RX_CONTINUE;
+
+
+       if (fc & IEEE80211_FCTL_TODS) {
+               if (!wds && (sta == NULL || !(sta->flags & WLAN_STA_ASSOC))) {
+                       if (local->hostapd) {
+                               prism2_rx_80211(local->apdev, skb, rx_stats,
+                                               PRISM2_RX_NON_ASSOC);
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+                       } else {
+                               printk(KERN_DEBUG "%s: dropped received packet"
+                                      " from non-associated STA " MACSTR
+                                      " (type=0x%02x, subtype=0x%02x)\n",
+                                      dev->name, MAC2STR(hdr->addr2),
+                                      type >> 2, stype >> 4);
+                               hostap_rx(dev, skb, rx_stats);
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+                       }
+                       ret = AP_RX_EXIT;
+                       goto out;
+               }
+       } else if (fc & IEEE80211_FCTL_FROMDS) {
+               if (!wds) {
+                       /* FromDS frame - not for us; probably
+                        * broadcast/multicast in another BSS - drop */
+                       if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0) {
+                               printk(KERN_DEBUG "Odd.. FromDS packet "
+                                      "received with own BSSID\n");
+                               hostap_dump_rx_80211(dev->name, skb, rx_stats);
+                       }
+                       ret = AP_RX_DROP;
+                       goto out;
+               }
+       } else if (stype == IEEE80211_STYPE_NULLFUNC && sta == NULL &&
+                  memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0) {
+
+               if (local->hostapd) {
+                       prism2_rx_80211(local->apdev, skb, rx_stats,
+                                       PRISM2_RX_NON_ASSOC);
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+               } else {
+                       /* At least Lucent f/w seems to send data::nullfunc
+                        * frames with no ToDS flag when the current AP returns
+                        * after being unavailable for some time. Speed up
+                        * re-association by informing the station about it not
+                        * being associated. */
+                       printk(KERN_DEBUG "%s: rejected received nullfunc "
+                              "frame without ToDS from not associated STA "
+                              MACSTR "\n",
+                              dev->name, MAC2STR(hdr->addr2));
+                       hostap_rx(dev, skb, rx_stats);
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+               }
+               ret = AP_RX_EXIT;
+               goto out;
+       } else if (stype == IEEE80211_STYPE_NULLFUNC) {
+               /* At least Lucent cards seem to send periodic nullfunc
+                * frames with ToDS. Let these through to update SQ
+                * stats and PS state. Nullfunc frames do not contain
+                * any data and they will be dropped below. */
+       } else {
+               /* If BSSID (Addr3) is foreign, this frame is a normal
+                * broadcast frame from an IBSS network. Drop it silently.
+                * If BSSID is own, report the dropping of this frame. */
+               if (memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0) {
+                       printk(KERN_DEBUG "%s: dropped received packet from "
+                              MACSTR " with no ToDS flag (type=0x%02x, "
+                              "subtype=0x%02x)\n", dev->name,
+                              MAC2STR(hdr->addr2), type >> 2, stype >> 4);
+                       hostap_dump_rx_80211(dev->name, skb, rx_stats);
+               }
+               ret = AP_RX_DROP;
+               goto out;
+       }
+
+       if (sta) {
+               hostap_update_sta_ps2(local, sta, fc & IEEE80211_FCTL_PM,
+                                     type, stype);
+
+               sta->rx_packets++;
+               sta->rx_bytes += skb->len;
+               sta->last_rx = jiffies;
+       }
+
+       if (local->ap->nullfunc_ack && stype == IEEE80211_STYPE_NULLFUNC &&
+           fc & IEEE80211_FCTL_TODS) {
+               if (local->hostapd) {
+                       prism2_rx_80211(local->apdev, skb, rx_stats,
+                                       PRISM2_RX_NULLFUNC_ACK);
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+               } else {
+                       /* some STA f/w's seem to require control::ACK frame
+                        * for data::nullfunc, but Prism2 f/w 0.8.0 (at least
+                        * from Compaq) does not send this.. Try to generate
+                        * ACK for these frames from the host driver to make
+                        * power saving work with, e.g., Lucent WaveLAN f/w */
+                       hostap_rx(dev, skb, rx_stats);
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+               }
+               ret = AP_RX_EXIT;
+               goto out;
+       }
+
+ out:
+       if (sta)
+               atomic_dec(&sta->users);
+
+       return ret;
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+int hostap_handle_sta_crypto(local_info_t *local,
+                            struct ieee80211_hdr *hdr,
+                            struct ieee80211_crypt_data **crypt,
+                            void **sta_ptr)
+{
+       struct sta_info *sta;
+
+       spin_lock(&local->ap->sta_table_lock);
+       sta = ap_get_sta(local->ap, hdr->addr2);
+       if (sta)
+               atomic_inc(&sta->users);
+       spin_unlock(&local->ap->sta_table_lock);
+
+       if (!sta)
+               return -1;
+
+       if (sta->crypt) {
+               *crypt = sta->crypt;
+               *sta_ptr = sta;
+               /* hostap_handle_sta_release() will be called to release STA
+                * info */
+       } else
+               atomic_dec(&sta->users);
+
+       return 0;
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+int hostap_is_sta_assoc(struct ap_data *ap, u8 *sta_addr)
+{
+       struct sta_info *sta;
+       int ret = 0;
+
+       spin_lock(&ap->sta_table_lock);
+       sta = ap_get_sta(ap, sta_addr);
+       if (sta != NULL && (sta->flags & WLAN_STA_ASSOC) && !sta->ap)
+               ret = 1;
+       spin_unlock(&ap->sta_table_lock);
+
+       return ret;
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+int hostap_is_sta_authorized(struct ap_data *ap, u8 *sta_addr)
+{
+       struct sta_info *sta;
+       int ret = 0;
+
+       spin_lock(&ap->sta_table_lock);
+       sta = ap_get_sta(ap, sta_addr);
+       if (sta != NULL && (sta->flags & WLAN_STA_ASSOC) && !sta->ap &&
+           ((sta->flags & WLAN_STA_AUTHORIZED) ||
+            ap->local->ieee_802_1x == 0))
+               ret = 1;
+       spin_unlock(&ap->sta_table_lock);
+
+       return ret;
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+int hostap_add_sta(struct ap_data *ap, u8 *sta_addr)
+{
+       struct sta_info *sta;
+       int ret = 1;
+
+       if (!ap)
+               return -1;
+
+       spin_lock(&ap->sta_table_lock);
+       sta = ap_get_sta(ap, sta_addr);
+       if (sta)
+               ret = 0;
+       spin_unlock(&ap->sta_table_lock);
+
+       if (ret == 1) {
+               sta = ap_add_sta(ap, sta_addr);
+               if (!sta)
+                       ret = -1;
+               sta->flags = WLAN_STA_AUTH | WLAN_STA_ASSOC;
+               sta->ap = 1;
+               memset(sta->supported_rates, 0, sizeof(sta->supported_rates));
+               /* No way of knowing which rates are supported since we did not
+                * get supported rates element from beacon/assoc req. Assume
+                * that remote end supports all 802.11b rates. */
+               sta->supported_rates[0] = 0x82;
+               sta->supported_rates[1] = 0x84;
+               sta->supported_rates[2] = 0x0b;
+               sta->supported_rates[3] = 0x16;
+               sta->tx_supp_rates = WLAN_RATE_1M | WLAN_RATE_2M |
+                       WLAN_RATE_5M5 | WLAN_RATE_11M;
+               sta->tx_rate = 110;
+               sta->tx_max_rate = sta->tx_rate_idx = 3;
+       }
+
+       return ret;
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+int hostap_update_rx_stats(struct ap_data *ap,
+                          struct ieee80211_hdr *hdr,
+                          struct hostap_80211_rx_status *rx_stats)
+{
+       struct sta_info *sta;
+
+       if (!ap)
+               return -1;
+
+       spin_lock(&ap->sta_table_lock);
+       sta = ap_get_sta(ap, hdr->addr2);
+       if (sta) {
+               sta->last_rx_silence = rx_stats->noise;
+               sta->last_rx_signal = rx_stats->signal;
+               sta->last_rx_rate = rx_stats->rate;
+               sta->last_rx_updated = 7;
+               if (rx_stats->rate == 10)
+                       sta->rx_count[0]++;
+               else if (rx_stats->rate == 20)
+                       sta->rx_count[1]++;
+               else if (rx_stats->rate == 55)
+                       sta->rx_count[2]++;
+               else if (rx_stats->rate == 110)
+                       sta->rx_count[3]++;
+       }
+       spin_unlock(&ap->sta_table_lock);
+
+       return sta ? 0 : -1;
+}
+
+
+void hostap_update_rates(local_info_t *local)
+{
+       struct list_head *ptr;
+       struct ap_data *ap = local->ap;
+
+       if (!ap)
+               return;
+
+       spin_lock_bh(&ap->sta_table_lock);
+       for (ptr = ap->sta_list.next; ptr != &ap->sta_list; ptr = ptr->next) {
+               struct sta_info *sta = (struct sta_info *) ptr;
+               prism2_check_tx_rates(sta);
+       }
+       spin_unlock_bh(&ap->sta_table_lock);
+}
+
+
+static void * ap_crypt_get_ptrs(struct ap_data *ap, u8 *addr, int permanent,
+                               struct ieee80211_crypt_data ***crypt)
+{
+       struct sta_info *sta;
+
+       spin_lock_bh(&ap->sta_table_lock);
+       sta = ap_get_sta(ap, addr);
+       if (sta)
+               atomic_inc(&sta->users);
+       spin_unlock_bh(&ap->sta_table_lock);
+
+       if (!sta && permanent)
+               sta = ap_add_sta(ap, addr);
+
+       if (!sta)
+               return NULL;
+
+       if (permanent)
+               sta->flags |= WLAN_STA_PERM;
+
+       *crypt = &sta->crypt;
+
+       return sta;
+}
+
+
+void hostap_add_wds_links(local_info_t *local)
+{
+       struct ap_data *ap = local->ap;
+       struct list_head *ptr;
+
+       spin_lock_bh(&ap->sta_table_lock);
+       list_for_each(ptr, &ap->sta_list) {
+               struct sta_info *sta = list_entry(ptr, struct sta_info, list);
+               if (sta->ap)
+                       hostap_wds_link_oper(local, sta->addr, WDS_ADD);
+       }
+       spin_unlock_bh(&ap->sta_table_lock);
+
+       schedule_work(&local->ap->wds_oper_queue);
+}
+
+
+void hostap_wds_link_oper(local_info_t *local, u8 *addr, wds_oper_type type)
+{
+       struct wds_oper_data *entry;
+
+       entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
+       if (!entry)
+               return;
+       memcpy(entry->addr, addr, ETH_ALEN);
+       entry->type = type;
+       spin_lock_bh(&local->lock);
+       entry->next = local->ap->wds_oper_entries;
+       local->ap->wds_oper_entries = entry;
+       spin_unlock_bh(&local->lock);
+
+       schedule_work(&local->ap->wds_oper_queue);
+}
+
+
+EXPORT_SYMBOL(hostap_init_data);
+EXPORT_SYMBOL(hostap_init_ap_proc);
+EXPORT_SYMBOL(hostap_free_data);
+EXPORT_SYMBOL(hostap_check_sta_fw_version);
+EXPORT_SYMBOL(hostap_handle_sta_tx);
+EXPORT_SYMBOL(hostap_handle_sta_release);
+EXPORT_SYMBOL(hostap_handle_sta_tx_exc);
+EXPORT_SYMBOL(hostap_update_sta_ps);
+EXPORT_SYMBOL(hostap_handle_sta_rx);
+EXPORT_SYMBOL(hostap_is_sta_assoc);
+EXPORT_SYMBOL(hostap_is_sta_authorized);
+EXPORT_SYMBOL(hostap_add_sta);
+EXPORT_SYMBOL(hostap_update_rates);
+EXPORT_SYMBOL(hostap_add_wds_links);
+EXPORT_SYMBOL(hostap_wds_link_oper);
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+EXPORT_SYMBOL(hostap_deauth_all_stas);
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
diff --git a/drivers/net/wireless/hostap/hostap_ap.h b/drivers/net/wireless/hostap/hostap_ap.h
new file mode 100644 (file)
index 0000000..816a52b
--- /dev/null
@@ -0,0 +1,261 @@
+#ifndef HOSTAP_AP_H
+#define HOSTAP_AP_H
+
+/* AP data structures for STAs */
+
+/* maximum number of frames to buffer per STA */
+#define STA_MAX_TX_BUFFER 32
+
+/* STA flags */
+#define WLAN_STA_AUTH BIT(0)
+#define WLAN_STA_ASSOC BIT(1)
+#define WLAN_STA_PS BIT(2)
+#define WLAN_STA_TIM BIT(3) /* TIM bit is on for PS stations */
+#define WLAN_STA_PERM BIT(4) /* permanent; do not remove entry on expiration */
+#define WLAN_STA_AUTHORIZED BIT(5) /* If 802.1X is used, this flag is
+                                   * controlling whether STA is authorized to
+                                   * send and receive non-IEEE 802.1X frames
+                                   */
+#define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */
+
+#define WLAN_RATE_1M BIT(0)
+#define WLAN_RATE_2M BIT(1)
+#define WLAN_RATE_5M5 BIT(2)
+#define WLAN_RATE_11M BIT(3)
+#define WLAN_RATE_COUNT 4
+
+/* Maximum size of Supported Rates info element. IEEE 802.11 has a limit of 8,
+ * but some pre-standard IEEE 802.11g products use longer elements. */
+#define WLAN_SUPP_RATES_MAX 32
+
+/* Try to increase TX rate after # successfully sent consecutive packets */
+#define WLAN_RATE_UPDATE_COUNT 50
+
+/* Decrease TX rate after # consecutive dropped packets */
+#define WLAN_RATE_DECREASE_THRESHOLD 2
+
+struct sta_info {
+       struct list_head list;
+       struct sta_info *hnext; /* next entry in hash table list */
+       atomic_t users; /* number of users (do not remove if > 0) */
+       struct proc_dir_entry *proc;
+
+       u8 addr[6];
+       u16 aid; /* STA's unique AID (1 .. 2007) or 0 if not yet assigned */
+       u32 flags;
+       u16 capability;
+       u16 listen_interval; /* or beacon_int for APs */
+       u8 supported_rates[WLAN_SUPP_RATES_MAX];
+
+       unsigned long last_auth;
+       unsigned long last_assoc;
+       unsigned long last_rx;
+       unsigned long last_tx;
+       unsigned long rx_packets, tx_packets;
+       unsigned long rx_bytes, tx_bytes;
+       struct sk_buff_head tx_buf;
+       /* FIX: timeout buffers with an expiry time somehow derived from
+        * listen_interval */
+
+       s8 last_rx_silence; /* Noise in dBm */
+       s8 last_rx_signal; /* Signal strength in dBm */
+       u8 last_rx_rate; /* TX rate in 0.1 Mbps */
+       u8 last_rx_updated; /* IWSPY's struct iw_quality::updated */
+
+       u8 tx_supp_rates; /* bit field of supported TX rates */
+       u8 tx_rate; /* current TX rate (in 0.1 Mbps) */
+       u8 tx_rate_idx; /* current TX rate (WLAN_RATE_*) */
+       u8 tx_max_rate; /* max TX rate (WLAN_RATE_*) */
+       u32 tx_count[WLAN_RATE_COUNT]; /* number of frames sent (per rate) */
+       u32 rx_count[WLAN_RATE_COUNT]; /* number of frames received (per rate)
+                                       */
+       u32 tx_since_last_failure;
+       u32 tx_consecutive_exc;
+
+       struct ieee80211_crypt_data *crypt;
+
+       int ap; /* whether this station is an AP */
+
+       local_info_t *local;
+
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+       union {
+               struct {
+                       char *challenge; /* shared key authentication
+                                         * challenge */
+               } sta;
+               struct {
+                       int ssid_len;
+                       unsigned char ssid[MAX_SSID_LEN + 1]; /* AP's ssid */
+                       int channel;
+                       unsigned long last_beacon; /* last RX beacon time */
+               } ap;
+       } u;
+
+       struct timer_list timer;
+       enum { STA_NULLFUNC = 0, STA_DISASSOC, STA_DEAUTH } timeout_next;
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+};
+
+
+#define MAX_STA_COUNT 1024
+
+/* Maximum number of AIDs to use for STAs; must be 2007 or lower
+ * (8802.11 limitation) */
+#define MAX_AID_TABLE_SIZE 128
+
+#define STA_HASH_SIZE 256
+#define STA_HASH(sta) (sta[5])
+
+
+/* Default value for maximum station inactivity. After AP_MAX_INACTIVITY_SEC
+ * has passed since last received frame from the station, a nullfunc data
+ * frame is sent to the station. If this frame is not acknowledged and no other
+ * frames have been received, the station will be disassociated after
+ * AP_DISASSOC_DELAY. Similarily, a the station will be deauthenticated after
+ * AP_DEAUTH_DELAY. AP_TIMEOUT_RESOLUTION is the resolution that is used with
+ * max inactivity timer. */
+#define AP_MAX_INACTIVITY_SEC (5 * 60)
+#define AP_DISASSOC_DELAY (HZ)
+#define AP_DEAUTH_DELAY (HZ)
+
+/* ap_policy: whether to accept frames to/from other APs/IBSS */
+typedef enum {
+       AP_OTHER_AP_SKIP_ALL = 0,
+       AP_OTHER_AP_SAME_SSID = 1,
+       AP_OTHER_AP_ALL = 2,
+       AP_OTHER_AP_EVEN_IBSS = 3
+} ap_policy_enum;
+
+#define PRISM2_AUTH_OPEN BIT(0)
+#define PRISM2_AUTH_SHARED_KEY BIT(1)
+
+
+/* MAC address-based restrictions */
+struct mac_entry {
+       struct list_head list;
+       u8 addr[6];
+};
+
+struct mac_restrictions {
+       enum { MAC_POLICY_OPEN = 0, MAC_POLICY_ALLOW, MAC_POLICY_DENY } policy;
+       unsigned int entries;
+       struct list_head mac_list;
+       spinlock_t lock;
+};
+
+
+struct add_sta_proc_data {
+       u8 addr[ETH_ALEN];
+       struct add_sta_proc_data *next;
+};
+
+
+typedef enum { WDS_ADD, WDS_DEL } wds_oper_type;
+struct wds_oper_data {
+       wds_oper_type type;
+       u8 addr[ETH_ALEN];
+       struct wds_oper_data *next;
+};
+
+
+struct ap_data {
+       int initialized; /* whether ap_data has been initialized */
+       local_info_t *local;
+       int bridge_packets; /* send packet to associated STAs directly to the
+                            * wireless media instead of higher layers in the
+                            * kernel */
+       unsigned int bridged_unicast; /* number of unicast frames bridged on
+                                      * wireless media */
+       unsigned int bridged_multicast; /* number of non-unicast frames
+                                        * bridged on wireless media */
+       unsigned int tx_drop_nonassoc; /* number of unicast TX packets dropped
+                                       * because they were to an address that
+                                       * was not associated */
+       int nullfunc_ack; /* use workaround for nullfunc frame ACKs */
+
+       spinlock_t sta_table_lock;
+       int num_sta; /* number of entries in sta_list */
+       struct list_head sta_list; /* STA info list head */
+       struct sta_info *sta_hash[STA_HASH_SIZE];
+
+       struct proc_dir_entry *proc;
+
+       ap_policy_enum ap_policy;
+       unsigned int max_inactivity;
+       int autom_ap_wds;
+
+       struct mac_restrictions mac_restrictions; /* MAC-based auth */
+       int last_tx_rate;
+
+       struct work_struct add_sta_proc_queue;
+       struct add_sta_proc_data *add_sta_proc_entries;
+
+       struct work_struct wds_oper_queue;
+       struct wds_oper_data *wds_oper_entries;
+
+       u16 tx_callback_idx;
+
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+       /* pointers to STA info; based on allocated AID or NULL if AID free
+        * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
+        * and so on
+        */
+       struct sta_info *sta_aid[MAX_AID_TABLE_SIZE];
+
+       u16 tx_callback_auth, tx_callback_assoc, tx_callback_poll;
+
+       /* WEP operations for generating challenges to be used with shared key
+        * authentication */
+       struct ieee80211_crypto_ops *crypt;
+       void *crypt_priv;
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+};
+
+
+void hostap_rx(struct net_device *dev, struct sk_buff *skb,
+              struct hostap_80211_rx_status *rx_stats);
+void hostap_init_data(local_info_t *local);
+void hostap_init_ap_proc(local_info_t *local);
+void hostap_free_data(struct ap_data *ap);
+void hostap_check_sta_fw_version(struct ap_data *ap, int sta_fw_ver);
+
+typedef enum {
+       AP_TX_CONTINUE, AP_TX_DROP, AP_TX_RETRY, AP_TX_BUFFERED,
+       AP_TX_CONTINUE_NOT_AUTHORIZED
+} ap_tx_ret;
+struct hostap_tx_data {
+       struct sk_buff *skb;
+       int host_encrypt;
+       struct ieee80211_crypt_data *crypt;
+       void *sta_ptr;
+};
+ap_tx_ret hostap_handle_sta_tx(local_info_t *local, struct hostap_tx_data *tx);
+void hostap_handle_sta_release(void *ptr);
+void hostap_handle_sta_tx_exc(local_info_t *local, struct sk_buff *skb);
+int hostap_update_sta_ps(local_info_t *local, struct ieee80211_hdr *hdr);
+typedef enum {
+       AP_RX_CONTINUE, AP_RX_DROP, AP_RX_EXIT, AP_RX_CONTINUE_NOT_AUTHORIZED
+} ap_rx_ret;
+ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
+                              struct sk_buff *skb,
+                              struct hostap_80211_rx_status *rx_stats,
+                              int wds);
+int hostap_handle_sta_crypto(local_info_t *local, struct ieee80211_hdr *hdr,
+                            struct ieee80211_crypt_data **crypt,
+                            void **sta_ptr);
+int hostap_is_sta_assoc(struct ap_data *ap, u8 *sta_addr);
+int hostap_is_sta_authorized(struct ap_data *ap, u8 *sta_addr);
+int hostap_add_sta(struct ap_data *ap, u8 *sta_addr);
+int hostap_update_rx_stats(struct ap_data *ap, struct ieee80211_hdr *hdr,
+                          struct hostap_80211_rx_status *rx_stats);
+void hostap_update_rates(local_info_t *local);
+void hostap_add_wds_links(local_info_t *local);
+void hostap_wds_link_oper(local_info_t *local, u8 *addr, wds_oper_type type);
+
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+void hostap_deauth_all_stas(struct net_device *dev, struct ap_data *ap,
+                           int resend);
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+#endif /* HOSTAP_AP_H */
diff --git a/drivers/net/wireless/hostap/hostap_common.h b/drivers/net/wireless/hostap/hostap_common.h
new file mode 100644 (file)
index 0000000..6f4fa9d
--- /dev/null
@@ -0,0 +1,435 @@
+#ifndef HOSTAP_COMMON_H
+#define HOSTAP_COMMON_H
+
+#define BIT(x) (1 << (x))
+
+#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
+#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
+
+
+/* IEEE 802.11 defines */
+
+/* Information Element IDs */
+#define WLAN_EID_SSID 0
+#define WLAN_EID_SUPP_RATES 1
+#define WLAN_EID_FH_PARAMS 2
+#define WLAN_EID_DS_PARAMS 3
+#define WLAN_EID_CF_PARAMS 4
+#define WLAN_EID_TIM 5
+#define WLAN_EID_IBSS_PARAMS 6
+#define WLAN_EID_CHALLENGE 16
+#define WLAN_EID_RSN 48
+#define WLAN_EID_GENERIC 221
+
+
+/* HFA384X Configuration RIDs */
+#define HFA384X_RID_CNFPORTTYPE 0xFC00
+#define HFA384X_RID_CNFOWNMACADDR 0xFC01
+#define HFA384X_RID_CNFDESIREDSSID 0xFC02
+#define HFA384X_RID_CNFOWNCHANNEL 0xFC03
+#define HFA384X_RID_CNFOWNSSID 0xFC04
+#define HFA384X_RID_CNFOWNATIMWINDOW 0xFC05
+#define HFA384X_RID_CNFSYSTEMSCALE 0xFC06
+#define HFA384X_RID_CNFMAXDATALEN 0xFC07
+#define HFA384X_RID_CNFWDSADDRESS 0xFC08
+#define HFA384X_RID_CNFPMENABLED 0xFC09
+#define HFA384X_RID_CNFPMEPS 0xFC0A
+#define HFA384X_RID_CNFMULTICASTRECEIVE 0xFC0B
+#define HFA384X_RID_CNFMAXSLEEPDURATION 0xFC0C
+#define HFA384X_RID_CNFPMHOLDOVERDURATION 0xFC0D
+#define HFA384X_RID_CNFOWNNAME 0xFC0E
+#define HFA384X_RID_CNFOWNDTIMPERIOD 0xFC10
+#define HFA384X_RID_CNFWDSADDRESS1 0xFC11 /* AP f/w only */
+#define HFA384X_RID_CNFWDSADDRESS2 0xFC12 /* AP f/w only */
+#define HFA384X_RID_CNFWDSADDRESS3 0xFC13 /* AP f/w only */
+#define HFA384X_RID_CNFWDSADDRESS4 0xFC14 /* AP f/w only */
+#define HFA384X_RID_CNFWDSADDRESS5 0xFC15 /* AP f/w only */
+#define HFA384X_RID_CNFWDSADDRESS6 0xFC16 /* AP f/w only */
+#define HFA384X_RID_CNFMULTICASTPMBUFFERING 0xFC17 /* AP f/w only */
+#define HFA384X_RID_UNKNOWN1 0xFC20
+#define HFA384X_RID_UNKNOWN2 0xFC21
+#define HFA384X_RID_CNFWEPDEFAULTKEYID 0xFC23
+#define HFA384X_RID_CNFDEFAULTKEY0 0xFC24
+#define HFA384X_RID_CNFDEFAULTKEY1 0xFC25
+#define HFA384X_RID_CNFDEFAULTKEY2 0xFC26
+#define HFA384X_RID_CNFDEFAULTKEY3 0xFC27
+#define HFA384X_RID_CNFWEPFLAGS 0xFC28
+#define HFA384X_RID_CNFWEPKEYMAPPINGTABLE 0xFC29
+#define HFA384X_RID_CNFAUTHENTICATION 0xFC2A
+#define HFA384X_RID_CNFMAXASSOCSTA 0xFC2B /* AP f/w only */
+#define HFA384X_RID_CNFTXCONTROL 0xFC2C
+#define HFA384X_RID_CNFROAMINGMODE 0xFC2D
+#define HFA384X_RID_CNFHOSTAUTHENTICATION 0xFC2E /* AP f/w only */
+#define HFA384X_RID_CNFRCVCRCERROR 0xFC30
+#define HFA384X_RID_CNFMMLIFE 0xFC31
+#define HFA384X_RID_CNFALTRETRYCOUNT 0xFC32
+#define HFA384X_RID_CNFBEACONINT 0xFC33
+#define HFA384X_RID_CNFAPPCFINFO 0xFC34 /* AP f/w only */
+#define HFA384X_RID_CNFSTAPCFINFO 0xFC35
+#define HFA384X_RID_CNFPRIORITYQUSAGE 0xFC37
+#define HFA384X_RID_CNFTIMCTRL 0xFC40
+#define HFA384X_RID_UNKNOWN3 0xFC41 /* added in STA f/w 0.7.x */
+#define HFA384X_RID_CNFTHIRTY2TALLY 0xFC42 /* added in STA f/w 0.8.0 */
+#define HFA384X_RID_CNFENHSECURITY 0xFC43 /* AP f/w or STA f/w >= 1.6.3 */
+#define HFA384X_RID_CNFDBMADJUST 0xFC46 /* added in STA f/w 1.3.1 */
+#define HFA384X_RID_GENERICELEMENT 0xFC48 /* added in STA f/w 1.7.0;
+                                          * write only */
+#define HFA384X_RID_PROPAGATIONDELAY 0xFC49 /* added in STA f/w 1.7.6 */
+#define HFA384X_RID_GROUPADDRESSES 0xFC80
+#define HFA384X_RID_CREATEIBSS 0xFC81
+#define HFA384X_RID_FRAGMENTATIONTHRESHOLD 0xFC82
+#define HFA384X_RID_RTSTHRESHOLD 0xFC83
+#define HFA384X_RID_TXRATECONTROL 0xFC84
+#define HFA384X_RID_PROMISCUOUSMODE 0xFC85
+#define HFA384X_RID_FRAGMENTATIONTHRESHOLD0 0xFC90 /* AP f/w only */
+#define HFA384X_RID_FRAGMENTATIONTHRESHOLD1 0xFC91 /* AP f/w only */
+#define HFA384X_RID_FRAGMENTATIONTHRESHOLD2 0xFC92 /* AP f/w only */
+#define HFA384X_RID_FRAGMENTATIONTHRESHOLD3 0xFC93 /* AP f/w only */
+#define HFA384X_RID_FRAGMENTATIONTHRESHOLD4 0xFC94 /* AP f/w only */
+#define HFA384X_RID_FRAGMENTATIONTHRESHOLD5 0xFC95 /* AP f/w only */
+#define HFA384X_RID_FRAGMENTATIONTHRESHOLD6 0xFC96 /* AP f/w only */
+#define HFA384X_RID_RTSTHRESHOLD0 0xFC97 /* AP f/w only */
+#define HFA384X_RID_RTSTHRESHOLD1 0xFC98 /* AP f/w only */
+#define HFA384X_RID_RTSTHRESHOLD2 0xFC99 /* AP f/w only */
+#define HFA384X_RID_RTSTHRESHOLD3 0xFC9A /* AP f/w only */
+#define HFA384X_RID_RTSTHRESHOLD4 0xFC9B /* AP f/w only */
+#define HFA384X_RID_RTSTHRESHOLD5 0xFC9C /* AP f/w only */
+#define HFA384X_RID_RTSTHRESHOLD6 0xFC9D /* AP f/w only */
+#define HFA384X_RID_TXRATECONTROL0 0xFC9E /* AP f/w only */
+#define HFA384X_RID_TXRATECONTROL1 0xFC9F /* AP f/w only */
+#define HFA384X_RID_TXRATECONTROL2 0xFCA0 /* AP f/w only */
+#define HFA384X_RID_TXRATECONTROL3 0xFCA1 /* AP f/w only */
+#define HFA384X_RID_TXRATECONTROL4 0xFCA2 /* AP f/w only */
+#define HFA384X_RID_TXRATECONTROL5 0xFCA3 /* AP f/w only */
+#define HFA384X_RID_TXRATECONTROL6 0xFCA4 /* AP f/w only */
+#define HFA384X_RID_CNFSHORTPREAMBLE 0xFCB0
+#define HFA384X_RID_CNFEXCLUDELONGPREAMBLE 0xFCB1
+#define HFA384X_RID_CNFAUTHENTICATIONRSPTO 0xFCB2
+#define HFA384X_RID_CNFBASICRATES 0xFCB3
+#define HFA384X_RID_CNFSUPPORTEDRATES 0xFCB4
+#define HFA384X_RID_CNFFALLBACKCTRL 0xFCB5 /* added in STA f/w 1.3.1 */
+#define HFA384X_RID_WEPKEYDISABLE 0xFCB6 /* added in STA f/w 1.3.1 */
+#define HFA384X_RID_WEPKEYMAPINDEX 0xFCB7 /* ? */
+#define HFA384X_RID_BROADCASTKEYID 0xFCB8 /* ? */
+#define HFA384X_RID_ENTSECFLAGEYID 0xFCB9 /* ? */
+#define HFA384X_RID_CNFPASSIVESCANCTRL 0xFCBA /* added in STA f/w 1.5.0 */
+#define HFA384X_RID_SSNHANDLINGMODE 0xFCBB /* added in STA f/w 1.7.0 */
+#define HFA384X_RID_MDCCONTROL 0xFCBC /* added in STA f/w 1.7.0 */
+#define HFA384X_RID_MDCCOUNTRY 0xFCBD /* added in STA f/w 1.7.0 */
+#define HFA384X_RID_TXPOWERMAX 0xFCBE /* added in STA f/w 1.7.0 */
+#define HFA384X_RID_CNFLFOENABLED 0xFCBF /* added in STA f/w 1.6.3 */
+#define HFA384X_RID_CAPINFO 0xFCC0 /* added in STA f/w 1.7.0 */
+#define HFA384X_RID_LISTENINTERVAL 0xFCC1 /* added in STA f/w 1.7.0 */
+#define HFA384X_RID_SW_ANT_DIV 0xFCC2 /* added in STA f/w 1.7.0; Prism3 */
+#define HFA384X_RID_LED_CTRL 0xFCC4 /* added in STA f/w 1.7.6 */
+#define HFA384X_RID_HFODELAY 0xFCC5 /* added in STA f/w 1.7.6 */
+#define HFA384X_RID_DISALLOWEDBSSID 0xFCC6 /* added in STA f/w 1.8.0 */
+#define HFA384X_RID_TICKTIME 0xFCE0
+#define HFA384X_RID_SCANREQUEST 0xFCE1
+#define HFA384X_RID_JOINREQUEST 0xFCE2
+#define HFA384X_RID_AUTHENTICATESTATION 0xFCE3 /* AP f/w only */
+#define HFA384X_RID_CHANNELINFOREQUEST 0xFCE4 /* AP f/w only */
+#define HFA384X_RID_HOSTSCAN 0xFCE5 /* added in STA f/w 1.3.1 */
+
+/* HFA384X Information RIDs */
+#define HFA384X_RID_MAXLOADTIME 0xFD00
+#define HFA384X_RID_DOWNLOADBUFFER 0xFD01
+#define HFA384X_RID_PRIID 0xFD02
+#define HFA384X_RID_PRISUPRANGE 0xFD03
+#define HFA384X_RID_CFIACTRANGES 0xFD04
+#define HFA384X_RID_NICSERNUM 0xFD0A
+#define HFA384X_RID_NICID 0xFD0B
+#define HFA384X_RID_MFISUPRANGE 0xFD0C
+#define HFA384X_RID_CFISUPRANGE 0xFD0D
+#define HFA384X_RID_CHANNELLIST 0xFD10
+#define HFA384X_RID_REGULATORYDOMAINS 0xFD11
+#define HFA384X_RID_TEMPTYPE 0xFD12
+#define HFA384X_RID_CIS 0xFD13
+#define HFA384X_RID_STAID 0xFD20
+#define HFA384X_RID_STASUPRANGE 0xFD21
+#define HFA384X_RID_MFIACTRANGES 0xFD22
+#define HFA384X_RID_CFIACTRANGES2 0xFD23
+#define HFA384X_RID_PRODUCTNAME 0xFD24 /* added in STA f/w 1.3.1;
+                                       * only Prism2.5(?) */
+#define HFA384X_RID_PORTSTATUS 0xFD40
+#define HFA384X_RID_CURRENTSSID 0xFD41
+#define HFA384X_RID_CURRENTBSSID 0xFD42
+#define HFA384X_RID_COMMSQUALITY 0xFD43
+#define HFA384X_RID_CURRENTTXRATE 0xFD44
+#define HFA384X_RID_CURRENTBEACONINTERVAL 0xFD45
+#define HFA384X_RID_CURRENTSCALETHRESHOLDS 0xFD46
+#define HFA384X_RID_PROTOCOLRSPTIME 0xFD47
+#define HFA384X_RID_SHORTRETRYLIMIT 0xFD48
+#define HFA384X_RID_LONGRETRYLIMIT 0xFD49
+#define HFA384X_RID_MAXTRANSMITLIFETIME 0xFD4A
+#define HFA384X_RID_MAXRECEIVELIFETIME 0xFD4B
+#define HFA384X_RID_CFPOLLABLE 0xFD4C
+#define HFA384X_RID_AUTHENTICATIONALGORITHMS 0xFD4D
+#define HFA384X_RID_PRIVACYOPTIONIMPLEMENTED 0xFD4F
+#define HFA384X_RID_DBMCOMMSQUALITY 0xFD51 /* added in STA f/w 1.3.1 */
+#define HFA384X_RID_CURRENTTXRATE1 0xFD80 /* AP f/w only */
+#define HFA384X_RID_CURRENTTXRATE2 0xFD81 /* AP f/w only */
+#define HFA384X_RID_CURRENTTXRATE3 0xFD82 /* AP f/w only */
+#define HFA384X_RID_CURRENTTXRATE4 0xFD83 /* AP f/w only */
+#define HFA384X_RID_CURRENTTXRATE5 0xFD84 /* AP f/w only */
+#define HFA384X_RID_CURRENTTXRATE6 0xFD85 /* AP f/w only */
+#define HFA384X_RID_OWNMACADDR 0xFD86 /* AP f/w only */
+#define HFA384X_RID_SCANRESULTSTABLE 0xFD88 /* added in STA f/w 0.8.3 */
+#define HFA384X_RID_HOSTSCANRESULTS 0xFD89 /* added in STA f/w 1.3.1 */
+#define HFA384X_RID_AUTHENTICATIONUSED 0xFD8A /* added in STA f/w 1.3.4 */
+#define HFA384X_RID_CNFFAASWITCHCTRL 0xFD8B /* added in STA f/w 1.6.3 */
+#define HFA384X_RID_ASSOCIATIONFAILURE 0xFD8D /* added in STA f/w 1.8.0 */
+#define HFA384X_RID_PHYTYPE 0xFDC0
+#define HFA384X_RID_CURRENTCHANNEL 0xFDC1
+#define HFA384X_RID_CURRENTPOWERSTATE 0xFDC2
+#define HFA384X_RID_CCAMODE 0xFDC3
+#define HFA384X_RID_SUPPORTEDDATARATES 0xFDC6
+#define HFA384X_RID_LFO_VOLT_REG_TEST_RES 0xFDC7 /* added in STA f/w 1.7.1 */
+#define HFA384X_RID_BUILDSEQ 0xFFFE
+#define HFA384X_RID_FWID 0xFFFF
+
+
+struct hfa384x_comp_ident
+{
+       u16 id;
+       u16 variant;
+       u16 major;
+       u16 minor;
+} __attribute__ ((packed));
+
+#define HFA384X_COMP_ID_PRI 0x15
+#define HFA384X_COMP_ID_STA 0x1f
+#define HFA384X_COMP_ID_FW_AP 0x14b
+
+struct hfa384x_sup_range
+{
+       u16 role;
+       u16 id;
+       u16 variant;
+       u16 bottom;
+       u16 top;
+} __attribute__ ((packed));
+
+
+struct hfa384x_build_id
+{
+       u16 pri_seq;
+       u16 sec_seq;
+} __attribute__ ((packed));
+
+/* FD01 - Download Buffer */
+struct hfa384x_rid_download_buffer
+{
+       u16 page;
+       u16 offset;
+       u16 length;
+} __attribute__ ((packed));
+
+/* BSS connection quality (RID FD43 range, RID FD51 dBm-normalized) */
+struct hfa384x_comms_quality {
+       u16 comm_qual; /* 0 .. 92 */
+       u16 signal_level; /* 27 .. 154 */
+       u16 noise_level; /* 27 .. 154 */
+} __attribute__ ((packed));
+
+
+/* netdevice private ioctls (used, e.g., with iwpriv from user space) */
+
+/* New wireless extensions API - SET/GET convention (even ioctl numbers are
+ * root only)
+ */
+#define PRISM2_IOCTL_PRISM2_PARAM (SIOCIWFIRSTPRIV + 0)
+#define PRISM2_IOCTL_GET_PRISM2_PARAM (SIOCIWFIRSTPRIV + 1)
+#define PRISM2_IOCTL_WRITEMIF (SIOCIWFIRSTPRIV + 2)
+#define PRISM2_IOCTL_READMIF (SIOCIWFIRSTPRIV + 3)
+#define PRISM2_IOCTL_MONITOR (SIOCIWFIRSTPRIV + 4)
+#define PRISM2_IOCTL_RESET (SIOCIWFIRSTPRIV + 6)
+#define PRISM2_IOCTL_INQUIRE (SIOCIWFIRSTPRIV + 8)
+#define PRISM2_IOCTL_WDS_ADD (SIOCIWFIRSTPRIV + 10)
+#define PRISM2_IOCTL_WDS_DEL (SIOCIWFIRSTPRIV + 12)
+#define PRISM2_IOCTL_SET_RID_WORD (SIOCIWFIRSTPRIV + 14)
+#define PRISM2_IOCTL_MACCMD (SIOCIWFIRSTPRIV + 16)
+#define PRISM2_IOCTL_ADDMAC (SIOCIWFIRSTPRIV + 18)
+#define PRISM2_IOCTL_DELMAC (SIOCIWFIRSTPRIV + 20)
+#define PRISM2_IOCTL_KICKMAC (SIOCIWFIRSTPRIV + 22)
+
+/* following are not in SIOCGIWPRIV list; check permission in the driver code
+ */
+#define PRISM2_IOCTL_DOWNLOAD (SIOCDEVPRIVATE + 13)
+#define PRISM2_IOCTL_HOSTAPD (SIOCDEVPRIVATE + 14)
+
+
+/* PRISM2_IOCTL_PRISM2_PARAM ioctl() subtypes: */
+enum {
+       /* PRISM2_PARAM_PTYPE = 1, */ /* REMOVED 2003-10-22 */
+       PRISM2_PARAM_TXRATECTRL = 2,
+       PRISM2_PARAM_BEACON_INT = 3,
+       PRISM2_PARAM_PSEUDO_IBSS = 4,
+       PRISM2_PARAM_ALC = 5,
+       /* PRISM2_PARAM_TXPOWER = 6, */ /* REMOVED 2003-10-22 */
+       PRISM2_PARAM_DUMP = 7,
+       PRISM2_PARAM_OTHER_AP_POLICY = 8,
+       PRISM2_PARAM_AP_MAX_INACTIVITY = 9,
+       PRISM2_PARAM_AP_BRIDGE_PACKETS = 10,
+       PRISM2_PARAM_DTIM_PERIOD = 11,
+       PRISM2_PARAM_AP_NULLFUNC_ACK = 12,
+       PRISM2_PARAM_MAX_WDS = 13,
+       PRISM2_PARAM_AP_AUTOM_AP_WDS = 14,
+       PRISM2_PARAM_AP_AUTH_ALGS = 15,
+       PRISM2_PARAM_MONITOR_ALLOW_FCSERR = 16,
+       PRISM2_PARAM_HOST_ENCRYPT = 17,
+       PRISM2_PARAM_HOST_DECRYPT = 18,
+       /* PRISM2_PARAM_BUS_MASTER_THRESHOLD_RX = 19, REMOVED 2005-08-14 */
+       /* PRISM2_PARAM_BUS_MASTER_THRESHOLD_TX = 20, REMOVED 2005-08-14 */
+       PRISM2_PARAM_HOST_ROAMING = 21,
+       PRISM2_PARAM_BCRX_STA_KEY = 22,
+       PRISM2_PARAM_IEEE_802_1X = 23,
+       PRISM2_PARAM_ANTSEL_TX = 24,
+       PRISM2_PARAM_ANTSEL_RX = 25,
+       PRISM2_PARAM_MONITOR_TYPE = 26,
+       PRISM2_PARAM_WDS_TYPE = 27,
+       PRISM2_PARAM_HOSTSCAN = 28,
+       PRISM2_PARAM_AP_SCAN = 29,
+       PRISM2_PARAM_ENH_SEC = 30,
+       PRISM2_PARAM_IO_DEBUG = 31,
+       PRISM2_PARAM_BASIC_RATES = 32,
+       PRISM2_PARAM_OPER_RATES = 33,
+       PRISM2_PARAM_HOSTAPD = 34,
+       PRISM2_PARAM_HOSTAPD_STA = 35,
+       PRISM2_PARAM_WPA = 36,
+       PRISM2_PARAM_PRIVACY_INVOKED = 37,
+       PRISM2_PARAM_TKIP_COUNTERMEASURES = 38,
+       PRISM2_PARAM_DROP_UNENCRYPTED = 39,
+       PRISM2_PARAM_SCAN_CHANNEL_MASK = 40,
+};
+
+enum { HOSTAP_ANTSEL_DO_NOT_TOUCH = 0, HOSTAP_ANTSEL_DIVERSITY = 1,
+       HOSTAP_ANTSEL_LOW = 2, HOSTAP_ANTSEL_HIGH = 3 };
+
+
+/* PRISM2_IOCTL_MACCMD ioctl() subcommands: */
+enum { AP_MAC_CMD_POLICY_OPEN = 0, AP_MAC_CMD_POLICY_ALLOW = 1,
+       AP_MAC_CMD_POLICY_DENY = 2, AP_MAC_CMD_FLUSH = 3,
+       AP_MAC_CMD_KICKALL = 4 };
+
+
+/* PRISM2_IOCTL_DOWNLOAD ioctl() dl_cmd: */
+enum {
+       PRISM2_DOWNLOAD_VOLATILE = 1 /* RAM */,
+       /* Note! Old versions of prism2_srec have a fatal error in CRC-16
+        * calculation, which will corrupt all non-volatile downloads.
+        * PRISM2_DOWNLOAD_NON_VOLATILE used to be 2, but it is now 3 to
+        * prevent use of old versions of prism2_srec for non-volatile
+        * download. */
+       PRISM2_DOWNLOAD_NON_VOLATILE = 3 /* FLASH */,
+       PRISM2_DOWNLOAD_VOLATILE_GENESIS = 4 /* RAM in Genesis mode */,
+       /* Persistent versions of volatile download commands (keep firmware
+        * data in memory and automatically re-download after hw_reset */
+       PRISM2_DOWNLOAD_VOLATILE_PERSISTENT = 5,
+       PRISM2_DOWNLOAD_VOLATILE_GENESIS_PERSISTENT = 6,
+};
+
+struct prism2_download_param {
+       u32 dl_cmd;
+       u32 start_addr;
+       u32 num_areas;
+       struct prism2_download_area {
+               u32 addr; /* wlan card address */
+               u32 len;
+               void __user *ptr; /* pointer to data in user space */
+       } data[0];
+};
+
+#define PRISM2_MAX_DOWNLOAD_AREA_LEN 131072
+#define PRISM2_MAX_DOWNLOAD_LEN 262144
+
+
+/* PRISM2_IOCTL_HOSTAPD ioctl() cmd: */
+enum {
+       PRISM2_HOSTAPD_FLUSH = 1,
+       PRISM2_HOSTAPD_ADD_STA = 2,
+       PRISM2_HOSTAPD_REMOVE_STA = 3,
+       PRISM2_HOSTAPD_GET_INFO_STA = 4,
+       /* REMOVED: PRISM2_HOSTAPD_RESET_TXEXC_STA = 5, */
+       PRISM2_SET_ENCRYPTION = 6,
+       PRISM2_GET_ENCRYPTION = 7,
+       PRISM2_HOSTAPD_SET_FLAGS_STA = 8,
+       PRISM2_HOSTAPD_GET_RID = 9,
+       PRISM2_HOSTAPD_SET_RID = 10,
+       PRISM2_HOSTAPD_SET_ASSOC_AP_ADDR = 11,
+       PRISM2_HOSTAPD_SET_GENERIC_ELEMENT = 12,
+       PRISM2_HOSTAPD_MLME = 13,
+       PRISM2_HOSTAPD_SCAN_REQ = 14,
+       PRISM2_HOSTAPD_STA_CLEAR_STATS = 15,
+};
+
+#define PRISM2_HOSTAPD_MAX_BUF_SIZE 1024
+#define PRISM2_HOSTAPD_RID_HDR_LEN \
+((int) (&((struct prism2_hostapd_param *) 0)->u.rid.data))
+#define PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \
+((int) (&((struct prism2_hostapd_param *) 0)->u.generic_elem.data))
+
+/* Maximum length for algorithm names (-1 for nul termination) used in ioctl()
+ */
+#define HOSTAP_CRYPT_ALG_NAME_LEN 16
+
+
+struct prism2_hostapd_param {
+       u32 cmd;
+       u8 sta_addr[ETH_ALEN];
+       union {
+               struct {
+                       u16 aid;
+                       u16 capability;
+                       u8 tx_supp_rates;
+               } add_sta;
+               struct {
+                       u32 inactive_sec;
+               } get_info_sta;
+               struct {
+                       u8 alg[HOSTAP_CRYPT_ALG_NAME_LEN];
+                       u32 flags;
+                       u32 err;
+                       u8 idx;
+                       u8 seq[8]; /* sequence counter (set: RX, get: TX) */
+                       u16 key_len;
+                       u8 key[0];
+               } crypt;
+               struct {
+                       u32 flags_and;
+                       u32 flags_or;
+               } set_flags_sta;
+               struct {
+                       u16 rid;
+                       u16 len;
+                       u8 data[0];
+               } rid;
+               struct {
+                       u8 len;
+                       u8 data[0];
+               } generic_elem;
+               struct {
+#define MLME_STA_DEAUTH 0
+#define MLME_STA_DISASSOC 1
+                       u16 cmd;
+                       u16 reason_code;
+               } mlme;
+               struct {
+                       u8 ssid_len;
+                       u8 ssid[32];
+               } scan_req;
+       } u;
+};
+
+#define HOSTAP_CRYPT_FLAG_SET_TX_KEY BIT(0)
+#define HOSTAP_CRYPT_FLAG_PERMANENT BIT(1)
+
+#define HOSTAP_CRYPT_ERR_UNKNOWN_ALG 2
+#define HOSTAP_CRYPT_ERR_UNKNOWN_ADDR 3
+#define HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED 4
+#define HOSTAP_CRYPT_ERR_KEY_SET_FAILED 5
+#define HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED 6
+#define HOSTAP_CRYPT_ERR_CARD_CONF_FAILED 7
+
+
+#endif /* HOSTAP_COMMON_H */
diff --git a/drivers/net/wireless/hostap/hostap_config.h b/drivers/net/wireless/hostap/hostap_config.h
new file mode 100644 (file)
index 0000000..7ed3425
--- /dev/null
@@ -0,0 +1,55 @@
+#ifndef HOSTAP_CONFIG_H
+#define HOSTAP_CONFIG_H
+
+#define PRISM2_VERSION "0.4.4-kernel"
+
+/* In the previous versions of Host AP driver, support for user space version
+ * of IEEE 802.11 management (hostapd) used to be disabled in the default
+ * configuration. From now on, support for hostapd is always included and it is
+ * possible to disable kernel driver version of IEEE 802.11 management with a
+ * separate define, PRISM2_NO_KERNEL_IEEE80211_MGMT. */
+/* #define PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+/* Maximum number of events handler per one interrupt */
+#define PRISM2_MAX_INTERRUPT_EVENTS 20
+
+/* Include code for downloading firmware images into volatile RAM. */
+#define PRISM2_DOWNLOAD_SUPPORT
+
+/* Allow kernel configuration to enable download support. */
+#if !defined(PRISM2_DOWNLOAD_SUPPORT) && defined(CONFIG_HOSTAP_FIRMWARE)
+#define PRISM2_DOWNLOAD_SUPPORT
+#endif
+
+#ifdef PRISM2_DOWNLOAD_SUPPORT
+/* Allow writing firmware images into flash, i.e., to non-volatile storage.
+ * Before you enable this option, you should make absolutely sure that you are
+ * using prism2_srec utility that comes with THIS version of the driver!
+ * In addition, please note that it is possible to kill your card with
+ * non-volatile download if you are using incorrect image. This feature has not
+ * been fully tested, so please be careful with it. */
+/* #define PRISM2_NON_VOLATILE_DOWNLOAD */
+#endif /* PRISM2_DOWNLOAD_SUPPORT */
+
+/* Save low-level I/O for debugging. This should not be enabled in normal use.
+ */
+/* #define PRISM2_IO_DEBUG */
+
+/* Following defines can be used to remove unneeded parts of the driver, e.g.,
+ * to limit the size of the kernel module. Definitions can be added here in
+ * hostap_config.h or they can be added to make command with EXTRA_CFLAGS,
+ * e.g.,
+ * 'make pccard EXTRA_CFLAGS="-DPRISM2_NO_DEBUG -DPRISM2_NO_PROCFS_DEBUG"'
+ */
+
+/* Do not include debug messages into the driver */
+/* #define PRISM2_NO_DEBUG */
+
+/* Do not include /proc/net/prism2/wlan#/{registers,debug} */
+/* #define PRISM2_NO_PROCFS_DEBUG */
+
+/* Do not include station functionality (i.e., allow only Master (Host AP) mode
+ */
+/* #define PRISM2_NO_STATION_MODES */
+
+#endif /* HOSTAP_CONFIG_H */
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
new file mode 100644 (file)
index 0000000..faa83ba
--- /dev/null
@@ -0,0 +1,1030 @@
+#define PRISM2_PCCARD
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/if.h>
+#include <linux/wait.h>
+#include <linux/timer.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/workqueue.h>
+#include <linux/wireless.h>
+#include <net/iw_handler.h>
+
+#include <pcmcia/cs_types.h>
+#include <pcmcia/cs.h>
+#include <pcmcia/cistpl.h>
+#include <pcmcia/cisreg.h>
+#include <pcmcia/ds.h>
+
+#include <asm/io.h>
+
+#include "hostap_wlan.h"
+
+
+static char *version = PRISM2_VERSION " (Jouni Malinen <jkmaline@cc.hut.fi>)";
+static dev_info_t dev_info = "hostap_cs";
+static dev_link_t *dev_list = NULL;
+
+MODULE_AUTHOR("Jouni Malinen");
+MODULE_DESCRIPTION("Support for Intersil Prism2-based 802.11 wireless LAN "
+                  "cards (PC Card).");
+MODULE_SUPPORTED_DEVICE("Intersil Prism2-based WLAN cards (PC Card)");
+MODULE_LICENSE("GPL");
+MODULE_VERSION(PRISM2_VERSION);
+
+
+static int ignore_cis_vcc;
+module_param(ignore_cis_vcc, int, 0444);
+MODULE_PARM_DESC(ignore_cis_vcc, "Ignore broken CIS VCC entry");
+
+
+/* struct local_info::hw_priv */
+struct hostap_cs_priv {
+       dev_node_t node;
+       dev_link_t *link;
+       int sandisk_connectplus;
+};
+
+
+#ifdef PRISM2_IO_DEBUG
+
+static inline void hfa384x_outb_debug(struct net_device *dev, int a, u8 v)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       unsigned long flags;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+       spin_lock_irqsave(&local->lock, flags);
+       prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTB, a, v);
+       outb(v, dev->base_addr + a);
+       spin_unlock_irqrestore(&local->lock, flags);
+}
+
+static inline u8 hfa384x_inb_debug(struct net_device *dev, int a)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       unsigned long flags;
+       u8 v;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+       spin_lock_irqsave(&local->lock, flags);
+       v = inb(dev->base_addr + a);
+       prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INB, a, v);
+       spin_unlock_irqrestore(&local->lock, flags);
+       return v;
+}
+
+static inline void hfa384x_outw_debug(struct net_device *dev, int a, u16 v)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       unsigned long flags;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+       spin_lock_irqsave(&local->lock, flags);
+       prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTW, a, v);
+       outw(v, dev->base_addr + a);
+       spin_unlock_irqrestore(&local->lock, flags);
+}
+
+static inline u16 hfa384x_inw_debug(struct net_device *dev, int a)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       unsigned long flags;
+       u16 v;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+       spin_lock_irqsave(&local->lock, flags);
+       v = inw(dev->base_addr + a);
+       prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INW, a, v);
+       spin_unlock_irqrestore(&local->lock, flags);
+       return v;
+}
+
+static inline void hfa384x_outsw_debug(struct net_device *dev, int a,
+                                      u8 *buf, int wc)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       unsigned long flags;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+       spin_lock_irqsave(&local->lock, flags);
+       prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTSW, a, wc);
+       outsw(dev->base_addr + a, buf, wc);
+       spin_unlock_irqrestore(&local->lock, flags);
+}
+
+static inline void hfa384x_insw_debug(struct net_device *dev, int a,
+                                     u8 *buf, int wc)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       unsigned long flags;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+       spin_lock_irqsave(&local->lock, flags);
+       prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INSW, a, wc);
+       insw(dev->base_addr + a, buf, wc);
+       spin_unlock_irqrestore(&local->lock, flags);
+}
+
+#define HFA384X_OUTB(v,a) hfa384x_outb_debug(dev, (a), (v))
+#define HFA384X_INB(a) hfa384x_inb_debug(dev, (a))
+#define HFA384X_OUTW(v,a) hfa384x_outw_debug(dev, (a), (v))
+#define HFA384X_INW(a) hfa384x_inw_debug(dev, (a))
+#define HFA384X_OUTSW(a, buf, wc) hfa384x_outsw_debug(dev, (a), (buf), (wc))
+#define HFA384X_INSW(a, buf, wc) hfa384x_insw_debug(dev, (a), (buf), (wc))
+
+#else /* PRISM2_IO_DEBUG */
+
+#define HFA384X_OUTB(v,a) outb((v), dev->base_addr + (a))
+#define HFA384X_INB(a) inb(dev->base_addr + (a))
+#define HFA384X_OUTW(v,a) outw((v), dev->base_addr + (a))
+#define HFA384X_INW(a) inw(dev->base_addr + (a))
+#define HFA384X_INSW(a, buf, wc) insw(dev->base_addr + (a), buf, wc)
+#define HFA384X_OUTSW(a, buf, wc) outsw(dev->base_addr + (a), buf, wc)
+
+#endif /* PRISM2_IO_DEBUG */
+
+
+static int hfa384x_from_bap(struct net_device *dev, u16 bap, void *buf,
+                           int len)
+{
+       u16 d_off;
+       u16 *pos;
+
+       d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
+       pos = (u16 *) buf;
+
+       if (len / 2)
+               HFA384X_INSW(d_off, buf, len / 2);
+       pos += len / 2;
+
+       if (len & 1)
+               *((char *) pos) = HFA384X_INB(d_off);
+
+       return 0;
+}
+
+
+static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len)
+{
+       u16 d_off;
+       u16 *pos;
+
+       d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
+       pos = (u16 *) buf;
+
+       if (len / 2)
+               HFA384X_OUTSW(d_off, buf, len / 2);
+       pos += len / 2;
+
+       if (len & 1)
+               HFA384X_OUTB(*((char *) pos), d_off);
+
+       return 0;
+}
+
+
+/* FIX: This might change at some point.. */
+#include "hostap_hw.c"
+
+
+
+static void prism2_detach(dev_link_t *link);
+static void prism2_release(u_long arg);
+static int prism2_event(event_t event, int priority,
+                       event_callback_args_t *args);
+
+
+static int prism2_pccard_card_present(local_info_t *local)
+{
+       struct hostap_cs_priv *hw_priv = local->hw_priv;
+       if (hw_priv != NULL && hw_priv->link != NULL &&
+           ((hw_priv->link->state & (DEV_PRESENT | DEV_CONFIG)) ==
+            (DEV_PRESENT | DEV_CONFIG)))
+               return 1;
+       return 0;
+}
+
+
+/*
+ * SanDisk CompactFlash WLAN Flashcard - Product Manual v1.0
+ * Document No. 20-10-00058, January 2004
+ * http://www.sandisk.com/pdf/industrial/ProdManualCFWLANv1.0.pdf
+ */
+#define SANDISK_WLAN_ACTIVATION_OFF 0x40
+#define SANDISK_HCR_OFF 0x42
+
+
+static void sandisk_set_iobase(local_info_t *local)
+{
+       int res;
+       conf_reg_t reg;
+       struct hostap_cs_priv *hw_priv = local->hw_priv;
+
+       reg.Function = 0;
+       reg.Action = CS_WRITE;
+       reg.Offset = 0x10; /* 0x3f0 IO base 1 */
+       reg.Value = hw_priv->link->io.BasePort1 & 0x00ff;
+       res = pcmcia_access_configuration_register(hw_priv->link->handle,
+                                                  &reg);
+       if (res != CS_SUCCESS) {
+               printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -"
+                      " res=%d\n", res);
+       }
+       udelay(10);
+
+       reg.Function = 0;
+       reg.Action = CS_WRITE;
+       reg.Offset = 0x12; /* 0x3f2 IO base 2 */
+       reg.Value = (hw_priv->link->io.BasePort1 & 0xff00) >> 8;
+       res = pcmcia_access_configuration_register(hw_priv->link->handle,
+                                                  &reg);
+       if (res != CS_SUCCESS) {
+               printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -"
+                      " res=%d\n", res);
+       }
+}
+
+
+static void sandisk_write_hcr(local_info_t *local, int hcr)
+{
+       struct net_device *dev = local->dev;
+       int i;
+
+       HFA384X_OUTB(0x80, SANDISK_WLAN_ACTIVATION_OFF);
+       udelay(50);
+       for (i = 0; i < 10; i++) {
+               HFA384X_OUTB(hcr, SANDISK_HCR_OFF);
+       }
+       udelay(55);
+       HFA384X_OUTB(0x45, SANDISK_WLAN_ACTIVATION_OFF);
+}
+
+
+static int sandisk_enable_wireless(struct net_device *dev)
+{
+       int res, ret = 0;
+       conf_reg_t reg;
+       struct hostap_interface *iface = dev->priv;
+       local_info_t *local = iface->local;
+       tuple_t tuple;
+       cisparse_t *parse = NULL;
+       u_char buf[64];
+       struct hostap_cs_priv *hw_priv = local->hw_priv;
+
+       if (hw_priv->link->io.NumPorts1 < 0x42) {
+               /* Not enough ports to be SanDisk multi-function card */
+               ret = -ENODEV;
+               goto done;
+       }
+
+       parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
+       if (parse == NULL) {
+               ret = -ENOMEM;
+               goto done;
+       }
+
+       tuple.DesiredTuple = CISTPL_MANFID;
+       tuple.Attributes = TUPLE_RETURN_COMMON;
+       tuple.TupleData = buf;
+       tuple.TupleDataMax = sizeof(buf);
+       tuple.TupleOffset = 0;
+       if (pcmcia_get_first_tuple(hw_priv->link->handle, &tuple) ||
+           pcmcia_get_tuple_data(hw_priv->link->handle, &tuple) ||
+           pcmcia_parse_tuple(hw_priv->link->handle, &tuple, parse) ||
+           parse->manfid.manf != 0xd601 || parse->manfid.card != 0x0101) {
+               /* No SanDisk manfid found */
+               ret = -ENODEV;
+               goto done;
+       }
+
+       tuple.DesiredTuple = CISTPL_LONGLINK_MFC;
+       if (pcmcia_get_first_tuple(hw_priv->link->handle, &tuple) ||
+           pcmcia_get_tuple_data(hw_priv->link->handle, &tuple) ||
+           pcmcia_parse_tuple(hw_priv->link->handle, &tuple, parse) ||
+               parse->longlink_mfc.nfn < 2) {
+               /* No multi-function links found */
+               ret = -ENODEV;
+               goto done;
+       }
+
+       printk(KERN_DEBUG "%s: Multi-function SanDisk ConnectPlus detected"
+              " - using vendor-specific initialization\n", dev->name);
+       hw_priv->sandisk_connectplus = 1;
+
+       reg.Function = 0;
+       reg.Action = CS_WRITE;
+       reg.Offset = CISREG_COR;
+       reg.Value = COR_SOFT_RESET;
+       res = pcmcia_access_configuration_register(hw_priv->link->handle,
+                                                  &reg);
+       if (res != CS_SUCCESS) {
+               printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
+                      dev->name, res);
+               goto done;
+       }
+       mdelay(5);
+
+       reg.Function = 0;
+       reg.Action = CS_WRITE;
+       reg.Offset = CISREG_COR;
+       /*
+        * Do not enable interrupts here to avoid some bogus events. Interrupts
+        * will be enabled during the first cor_sreset call.
+        */
+       reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA;
+       res = pcmcia_access_configuration_register(hw_priv->link->handle,
+                                                  &reg);
+       if (res != CS_SUCCESS) {
+               printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
+                      dev->name, res);
+               goto done;
+       }
+       mdelay(5);
+
+       sandisk_set_iobase(local);
+
+       HFA384X_OUTB(0xc5, SANDISK_WLAN_ACTIVATION_OFF);
+       udelay(10);
+       HFA384X_OUTB(0x4b, SANDISK_WLAN_ACTIVATION_OFF);
+       udelay(10);
+
+done:
+       kfree(parse);
+       return ret;
+}
+
+
+static void prism2_pccard_cor_sreset(local_info_t *local)
+{
+       int res;
+       conf_reg_t reg;
+       struct hostap_cs_priv *hw_priv = local->hw_priv;
+
+       if (!prism2_pccard_card_present(local))
+              return;
+
+       reg.Function = 0;
+       reg.Action = CS_READ;
+       reg.Offset = CISREG_COR;
+       reg.Value = 0;
+       res = pcmcia_access_configuration_register(hw_priv->link->handle,
+                                                  &reg);
+       if (res != CS_SUCCESS) {
+               printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n",
+                      res);
+               return;
+       }
+       printk(KERN_DEBUG "prism2_pccard_cor_sreset: original COR %02x\n",
+              reg.Value);
+
+       reg.Action = CS_WRITE;
+       reg.Value |= COR_SOFT_RESET;
+       res = pcmcia_access_configuration_register(hw_priv->link->handle,
+                                                  &reg);
+       if (res != CS_SUCCESS) {
+               printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n",
+                      res);
+               return;
+       }
+
+       mdelay(hw_priv->sandisk_connectplus ? 5 : 2);
+
+       reg.Value &= ~COR_SOFT_RESET;
+       if (hw_priv->sandisk_connectplus)
+               reg.Value |= COR_IREQ_ENA;
+       res = pcmcia_access_configuration_register(hw_priv->link->handle,
+                                                  &reg);
+       if (res != CS_SUCCESS) {
+               printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n",
+                      res);
+               return;
+       }
+
+       mdelay(hw_priv->sandisk_connectplus ? 5 : 2);
+
+       if (hw_priv->sandisk_connectplus)
+               sandisk_set_iobase(local);
+}
+
+
+static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
+{
+       int res;
+       conf_reg_t reg;
+       int old_cor;
+       struct hostap_cs_priv *hw_priv = local->hw_priv;
+
+       if (!prism2_pccard_card_present(local))
+              return;
+
+       if (hw_priv->sandisk_connectplus) {
+               sandisk_write_hcr(local, hcr);
+               return;
+       }
+
+       reg.Function = 0;
+       reg.Action = CS_READ;
+       reg.Offset = CISREG_COR;
+       reg.Value = 0;
+       res = pcmcia_access_configuration_register(hw_priv->link->handle,
+                                                  &reg);
+       if (res != CS_SUCCESS) {
+               printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 "
+                      "(%d)\n", res);
+               return;
+       }
+       printk(KERN_DEBUG "prism2_pccard_genesis_sreset: original COR %02x\n",
+              reg.Value);
+       old_cor = reg.Value;
+
+       reg.Action = CS_WRITE;
+       reg.Value |= COR_SOFT_RESET;
+       res = pcmcia_access_configuration_register(hw_priv->link->handle,
+                                                  &reg);
+       if (res != CS_SUCCESS) {
+               printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 "
+                      "(%d)\n", res);
+               return;
+       }
+
+       mdelay(10);
+
+       /* Setup Genesis mode */
+       reg.Action = CS_WRITE;
+       reg.Value = hcr;
+       reg.Offset = CISREG_CCSR;
+       res = pcmcia_access_configuration_register(hw_priv->link->handle,
+                                                  &reg);
+       if (res != CS_SUCCESS) {
+               printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 "
+                      "(%d)\n", res);
+               return;
+       }
+       mdelay(10);
+
+       reg.Action = CS_WRITE;
+       reg.Offset = CISREG_COR;
+       reg.Value = old_cor & ~COR_SOFT_RESET;
+       res = pcmcia_access_configuration_register(hw_priv->link->handle,
+                                                  &reg);
+       if (res != CS_SUCCESS) {
+               printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 "
+                      "(%d)\n", res);
+               return;
+       }
+
+       mdelay(10);
+}
+
+
+static int prism2_pccard_dev_open(local_info_t *local)
+{
+       struct hostap_cs_priv *hw_priv = local->hw_priv;
+       hw_priv->link->open++;
+       return 0;
+}
+
+
+static int prism2_pccard_dev_close(local_info_t *local)
+{
+       struct hostap_cs_priv *hw_priv;
+
+       if (local == NULL || local->hw_priv == NULL)
+               return 1;
+       hw_priv = local->hw_priv;
+       if (hw_priv->link == NULL)
+               return 1;
+
+       if (!hw_priv->link->open) {
+               printk(KERN_WARNING "%s: prism2_pccard_dev_close(): "
+                      "link not open?!\n", local->dev->name);
+               return 1;
+       }
+
+       hw_priv->link->open--;
+
+       return 0;
+}
+
+
+static struct prism2_helper_functions prism2_pccard_funcs =
+{
+       .card_present   = prism2_pccard_card_present,
+       .cor_sreset     = prism2_pccard_cor_sreset,
+       .dev_open       = prism2_pccard_dev_open,
+       .dev_close      = prism2_pccard_dev_close,
+       .genesis_reset  = prism2_pccard_genesis_reset,
+       .hw_type        = HOSTAP_HW_PCCARD,
+};
+
+
+/* allocate local data and register with CardServices
+ * initialize dev_link structure, but do not configure the card yet */
+static dev_link_t *prism2_attach(void)
+{
+       dev_link_t *link;
+       client_reg_t client_reg;
+       int ret;
+
+       link = kmalloc(sizeof(dev_link_t), GFP_KERNEL);
+       if (link == NULL)
+               return NULL;
+
+       memset(link, 0, sizeof(dev_link_t));
+
+       PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info);
+       link->conf.Vcc = 33;
+       link->conf.IntType = INT_MEMORY_AND_IO;
+
+       /* register with CardServices */
+       link->next = dev_list;
+       dev_list = link;
+       client_reg.dev_info = &dev_info;
+       client_reg.Version = 0x0210;
+       client_reg.event_callback_args.client_data = link;
+       ret = pcmcia_register_client(&link->handle, &client_reg);
+       if (ret != CS_SUCCESS) {
+               cs_error(link->handle, RegisterClient, ret);
+               prism2_detach(link);
+               return NULL;
+       }
+       return link;
+}
+
+
+static void prism2_detach(dev_link_t *link)
+{
+       dev_link_t **linkp;
+
+       PDEBUG(DEBUG_FLOW, "prism2_detach\n");
+
+       for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
+               if (*linkp == link)
+                       break;
+       if (*linkp == NULL) {
+               printk(KERN_WARNING "%s: Attempt to detach non-existing "
+                      "PCMCIA client\n", dev_info);
+               return;
+       }
+
+       if (link->state & DEV_CONFIG) {
+               prism2_release((u_long)link);
+       }
+
+       if (link->handle) {
+               int res = pcmcia_deregister_client(link->handle);
+               if (res) {
+                       printk("CardService(DeregisterClient) => %d\n", res);
+                       cs_error(link->handle, DeregisterClient, res);
+               }
+       }
+
+       *linkp = link->next;
+       /* release net devices */
+       if (link->priv) {
+               struct net_device *dev;
+               struct hostap_interface *iface;
+               dev = link->priv;
+               iface = netdev_priv(dev);
+               kfree(iface->local->hw_priv);
+               iface->local->hw_priv = NULL;
+               prism2_free_local_data(dev);
+       }
+       kfree(link);
+}
+
+
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
+
+#define CFG_CHECK2(fn, retf) \
+do { int ret = (retf); \
+if (ret != 0) { \
+       PDEBUG(DEBUG_EXTRA, "CardServices(" #fn ") returned %d\n", ret); \
+       cs_error(link->handle, fn, ret); \
+       goto next_entry; \
+} \
+} while (0)
+
+
+/* run after a CARD_INSERTION event is received to configure the PCMCIA
+ * socket and make the device available to the system */
+static int prism2_config(dev_link_t *link)
+{
+       struct net_device *dev;
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int ret = 1;
+       tuple_t tuple;
+       cisparse_t *parse;
+       int last_fn, last_ret;
+       u_char buf[64];
+       config_info_t conf;
+       cistpl_cftable_entry_t dflt = { 0 };
+       struct hostap_cs_priv *hw_priv;
+
+       PDEBUG(DEBUG_FLOW, "prism2_config()\n");
+
+       parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
+       hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
+       if (parse == NULL || hw_priv == NULL) {
+               kfree(parse);
+               kfree(hw_priv);
+               ret = -ENOMEM;
+               goto failed;
+       }
+       memset(hw_priv, 0, sizeof(*hw_priv));
+
+       tuple.DesiredTuple = CISTPL_CONFIG;
+       tuple.Attributes = 0;
+       tuple.TupleData = buf;
+       tuple.TupleDataMax = sizeof(buf);
+       tuple.TupleOffset = 0;
+       CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link->handle, &tuple));
+       CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link->handle, &tuple));
+       CS_CHECK(ParseTuple, pcmcia_parse_tuple(link->handle, &tuple, parse));
+       link->conf.ConfigBase = parse->config.base;
+       link->conf.Present = parse->config.rmask[0];
+
+       CS_CHECK(GetConfigurationInfo,
+                pcmcia_get_configuration_info(link->handle, &conf));
+       PDEBUG(DEBUG_HW, "%s: %s Vcc=%d (from config)\n", dev_info,
+              ignore_cis_vcc ? "ignoring" : "setting", conf.Vcc);
+       link->conf.Vcc = conf.Vcc;
+
+       /* Look for an appropriate configuration table entry in the CIS */
+       tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
+       CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link->handle, &tuple));
+       for (;;) {
+               cistpl_cftable_entry_t *cfg = &(parse->cftable_entry);
+               CFG_CHECK2(GetTupleData,
+                          pcmcia_get_tuple_data(link->handle, &tuple));
+               CFG_CHECK2(ParseTuple,
+                          pcmcia_parse_tuple(link->handle, &tuple, parse));
+
+               if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
+                       dflt = *cfg;
+               if (cfg->index == 0)
+                       goto next_entry;
+               link->conf.ConfigIndex = cfg->index;
+               PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X "
+                      "(default 0x%02X)\n", cfg->index, dflt.index);
+
+               /* Does this card need audio output? */
+               if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
+                       link->conf.Attributes |= CONF_ENABLE_SPKR;
+                       link->conf.Status = CCSR_AUDIO_ENA;
+               }
+
+               /* Use power settings for Vcc and Vpp if present */
+               /*  Note that the CIS values need to be rescaled */
+               if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
+                       if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] /
+                           10000 && !ignore_cis_vcc) {
+                               PDEBUG(DEBUG_EXTRA, "  Vcc mismatch - skipping"
+                                      " this entry\n");
+                               goto next_entry;
+                       }
+               } else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) {
+                       if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] /
+                           10000 && !ignore_cis_vcc) {
+                               PDEBUG(DEBUG_EXTRA, "  Vcc (default) mismatch "
+                                      "- skipping this entry\n");
+                               goto next_entry;
+                       }
+               }
+
+               if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
+                       link->conf.Vpp1 = link->conf.Vpp2 =
+                               cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
+               else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM))
+                       link->conf.Vpp1 = link->conf.Vpp2 =
+                               dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000;
+
+               /* Do we need to allocate an interrupt? */
+               if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1)
+                       link->conf.Attributes |= CONF_ENABLE_IRQ;
+               else if (!(link->conf.Attributes & CONF_ENABLE_IRQ)) {
+                       /* At least Compaq WL200 does not have IRQInfo1 set,
+                        * but it does not work without interrupts.. */
+                       printk("Config has no IRQ info, but trying to enable "
+                              "IRQ anyway..\n");
+                       link->conf.Attributes |= CONF_ENABLE_IRQ;
+               }
+
+               /* IO window settings */
+               PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d "
+                      "dflt.io.nwin=%d\n",
+                      cfg->io.nwin, dflt.io.nwin);
+               link->io.NumPorts1 = link->io.NumPorts2 = 0;
+               if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
+                       cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io;
+                       link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
+                       PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, "
+                              "io.base=0x%04x, len=%d\n", io->flags,
+                              io->win[0].base, io->win[0].len);
+                       if (!(io->flags & CISTPL_IO_8BIT))
+                               link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
+                       if (!(io->flags & CISTPL_IO_16BIT))
+                               link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
+                       link->io.IOAddrLines = io->flags &
+                               CISTPL_IO_LINES_MASK;
+                       link->io.BasePort1 = io->win[0].base;
+                       link->io.NumPorts1 = io->win[0].len;
+                       if (io->nwin > 1) {
+                               link->io.Attributes2 = link->io.Attributes1;
+                               link->io.BasePort2 = io->win[1].base;
+                               link->io.NumPorts2 = io->win[1].len;
+                       }
+               }
+
+               /* This reserves IO space but doesn't actually enable it */
+               CFG_CHECK2(RequestIO,
+                          pcmcia_request_io(link->handle, &link->io));
+
+               /* This configuration table entry is OK */
+               break;
+
+       next_entry:
+               CS_CHECK(GetNextTuple,
+                        pcmcia_get_next_tuple(link->handle, &tuple));
+       }
+
+       /* Need to allocate net_device before requesting IRQ handler */
+       dev = prism2_init_local_data(&prism2_pccard_funcs, 0,
+                                    &handle_to_dev(link->handle));
+       if (dev == NULL)
+               goto failed;
+       link->priv = dev;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+       local->hw_priv = hw_priv;
+       hw_priv->link = link;
+       strcpy(hw_priv->node.dev_name, dev->name);
+       link->dev = &hw_priv->node;
+
+       /*
+        * Allocate an interrupt line.  Note that this does not assign a
+        * handler to the interrupt, unless the 'Handler' member of the
+        * irq structure is initialized.
+        */
+       if (link->conf.Attributes & CONF_ENABLE_IRQ) {
+               link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
+               link->irq.IRQInfo1 = IRQ_LEVEL_ID;
+               link->irq.Handler = prism2_interrupt;
+               link->irq.Instance = dev;
+               CS_CHECK(RequestIRQ,
+                        pcmcia_request_irq(link->handle, &link->irq));
+       }
+
+       /*
+        * This actually configures the PCMCIA socket -- setting up
+        * the I/O windows and the interrupt mapping, and putting the
+        * card and host interface into "Memory and IO" mode.
+        */
+       CS_CHECK(RequestConfiguration,
+                pcmcia_request_configuration(link->handle, &link->conf));
+
+       dev->irq = link->irq.AssignedIRQ;
+       dev->base_addr = link->io.BasePort1;
+
+       /* Finally, report what we've done */
+       printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d",
+              dev_info, link->conf.ConfigIndex,
+              link->conf.Vcc / 10, link->conf.Vcc % 10);
+       if (link->conf.Vpp1)
+               printk(", Vpp %d.%d", link->conf.Vpp1 / 10,
+                      link->conf.Vpp1 % 10);
+       if (link->conf.Attributes & CONF_ENABLE_IRQ)
+               printk(", irq %d", link->irq.AssignedIRQ);
+       if (link->io.NumPorts1)
+               printk(", io 0x%04x-0x%04x", link->io.BasePort1,
+                      link->io.BasePort1+link->io.NumPorts1-1);
+       if (link->io.NumPorts2)
+               printk(" & 0x%04x-0x%04x", link->io.BasePort2,
+                      link->io.BasePort2+link->io.NumPorts2-1);
+       printk("\n");
+
+       link->state |= DEV_CONFIG;
+       link->state &= ~DEV_CONFIG_PENDING;
+
+       local->shutdown = 0;
+
+       sandisk_enable_wireless(dev);
+
+       ret = prism2_hw_config(dev, 1);
+       if (!ret) {
+               ret = hostap_hw_ready(dev);
+               if (ret == 0 && local->ddev)
+                       strcpy(hw_priv->node.dev_name, local->ddev->name);
+       }
+       kfree(parse);
+       return ret;
+
+ cs_failed:
+       cs_error(link->handle, last_fn, last_ret);
+
+ failed:
+       kfree(parse);
+       kfree(hw_priv);
+       prism2_release((u_long)link);
+       return ret;
+}
+
+
+static void prism2_release(u_long arg)
+{
+       dev_link_t *link = (dev_link_t *)arg;
+
+       PDEBUG(DEBUG_FLOW, "prism2_release\n");
+
+       if (link->priv) {
+               struct net_device *dev = link->priv;
+               struct hostap_interface *iface;
+
+               iface = netdev_priv(dev);
+               if (link->state & DEV_CONFIG)
+                       prism2_hw_shutdown(dev, 0);
+               iface->local->shutdown = 1;
+       }
+
+       if (link->win)
+               pcmcia_release_window(link->win);
+       pcmcia_release_configuration(link->handle);
+       if (link->io.NumPorts1)
+               pcmcia_release_io(link->handle, &link->io);
+       if (link->irq.AssignedIRQ)
+               pcmcia_release_irq(link->handle, &link->irq);
+
+       link->state &= ~DEV_CONFIG;
+
+       PDEBUG(DEBUG_FLOW, "release - done\n");
+}
+
+
+static int prism2_event(event_t event, int priority,
+                       event_callback_args_t *args)
+{
+       dev_link_t *link = args->client_data;
+       struct net_device *dev = (struct net_device *) link->priv;
+
+       switch (event) {
+       case CS_EVENT_CARD_INSERTION:
+               PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_INSERTION\n", dev_info);
+               link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
+               if (prism2_config(link)) {
+                       PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n");
+               }
+               break;
+
+       case CS_EVENT_CARD_REMOVAL:
+               PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_REMOVAL\n", dev_info);
+               link->state &= ~DEV_PRESENT;
+               if (link->state & DEV_CONFIG) {
+                       netif_stop_queue(dev);
+                       netif_device_detach(dev);
+                       prism2_release((u_long) link);
+               }
+               break;
+
+       case CS_EVENT_PM_SUSPEND:
+               PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info);
+               link->state |= DEV_SUSPEND;
+               /* fall through */
+
+       case CS_EVENT_RESET_PHYSICAL:
+               PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_RESET_PHYSICAL\n", dev_info);
+               if (link->state & DEV_CONFIG) {
+                       if (link->open) {
+                               netif_stop_queue(dev);
+                               netif_device_detach(dev);
+                       }
+                       prism2_suspend(dev);
+                       pcmcia_release_configuration(link->handle);
+               }
+               break;
+
+       case CS_EVENT_PM_RESUME:
+               PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info);
+               link->state &= ~DEV_SUSPEND;
+               /* fall through */
+
+       case CS_EVENT_CARD_RESET:
+               PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_RESET\n", dev_info);
+               if (link->state & DEV_CONFIG) {
+                       pcmcia_request_configuration(link->handle,
+                                                    &link->conf);
+                       prism2_hw_shutdown(dev, 1);
+                       prism2_hw_config(dev, link->open ? 0 : 1);
+                       if (link->open) {
+                               netif_device_attach(dev);
+                               netif_start_queue(dev);
+                       }
+               }
+               break;
+
+       default:
+               PDEBUG(DEBUG_EXTRA, "%s: prism2_event() - unknown event %d\n",
+                      dev_info, event);
+               break;
+       }
+       return 0;
+}
+
+
+static struct pcmcia_device_id hostap_cs_ids[] = {
+       PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100),
+       PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300),
+       PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777),
+       PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000),
+       PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002),
+       PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002),
+       PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002),
+       PCMCIA_DEVICE_MANF_CARD(0x026f, 0x030b),
+       PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612),
+       PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613),
+       PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002),
+       PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002),
+       PCMCIA_DEVICE_MANF_CARD(0x02d2, 0x0001),
+       PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x0001),
+       PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300),
+       PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000),
+       PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002),
+       PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005),
+       PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010),
+       PCMCIA_MFC_DEVICE_PROD_ID12(0, "SanDisk", "ConnectPlus",
+                                   0x7a954bd9, 0x74be00c6),
+       PCMCIA_DEVICE_PROD_ID1234(
+               "Intersil", "PRISM 2_5 PCMCIA ADAPTER", "ISL37300P",
+               "Eval-RevA",
+               0x4b801a17, 0x6345a0bf, 0xc9049a39, 0xc23adc0e),
+       PCMCIA_DEVICE_PROD_ID123(
+               "Addtron", "AWP-100 Wireless PCMCIA", "Version 01.02",
+               0xe6ec52ce, 0x08649af2, 0x4b74baa0),
+       PCMCIA_DEVICE_PROD_ID123(
+               "D", "Link DWL-650 11Mbps WLAN Card", "Version 01.02",
+               0x71b18589, 0xb6f1b0ab, 0x4b74baa0),
+       PCMCIA_DEVICE_PROD_ID123(
+               "Instant Wireless ", " Network PC CARD", "Version 01.02",
+               0x11d901af, 0x6e9bd926, 0x4b74baa0),
+       PCMCIA_DEVICE_PROD_ID123(
+               "SMC", "SMC2632W", "Version 01.02",
+               0xc4f8b18b, 0x474a1f2a, 0x4b74baa0),
+       PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-CF-S11G", 
+                               0x2decece3, 0x82067c18),
+       PCMCIA_DEVICE_PROD_ID12("Compaq", "WL200_11Mbps_Wireless_PCI_Card",
+                               0x54f7c49c, 0x15a75e5b),
+       PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE",
+                               0x74c5e40d, 0xdb472a18),
+       PCMCIA_DEVICE_PROD_ID12("Linksys", "Wireless CompactFlash Card",
+                               0x0733cc81, 0x0c52f395),
+       PCMCIA_DEVICE_PROD_ID12(
+               "ZoomAir 11Mbps High", "Rate wireless Networking",
+               0x273fe3db, 0x32a1eaee),
+       PCMCIA_DEVICE_NULL
+};
+MODULE_DEVICE_TABLE(pcmcia, hostap_cs_ids);
+
+
+static struct pcmcia_driver hostap_driver = {
+       .drv            = {
+               .name   = "hostap_cs",
+       },
+       .attach         = prism2_attach,
+       .detach         = prism2_detach,
+       .owner          = THIS_MODULE,
+       .event          = prism2_event,
+       .id_table       = hostap_cs_ids,
+};
+
+static int __init init_prism2_pccard(void)
+{
+       printk(KERN_INFO "%s: %s\n", dev_info, version);
+       return pcmcia_register_driver(&hostap_driver);
+}
+
+static void __exit exit_prism2_pccard(void)
+{
+       pcmcia_unregister_driver(&hostap_driver);
+       printk(KERN_INFO "%s: Driver unloaded\n", dev_info);
+}
+
+
+module_init(init_prism2_pccard);
+module_exit(exit_prism2_pccard);
diff --git a/drivers/net/wireless/hostap/hostap_download.c b/drivers/net/wireless/hostap/hostap_download.c
new file mode 100644 (file)
index 0000000..ab26b52
--- /dev/null
@@ -0,0 +1,766 @@
+static int prism2_enable_aux_port(struct net_device *dev, int enable)
+{
+       u16 val, reg;
+       int i, tries;
+       unsigned long flags;
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (local->no_pri) {
+               if (enable) {
+                       PDEBUG(DEBUG_EXTRA2, "%s: no PRI f/w - assuming Aux "
+                              "port is already enabled\n", dev->name);
+               }
+               return 0;
+       }
+
+       spin_lock_irqsave(&local->cmdlock, flags);
+
+       /* wait until busy bit is clear */
+       tries = HFA384X_CMD_BUSY_TIMEOUT;
+       while (HFA384X_INW(HFA384X_CMD_OFF) & HFA384X_CMD_BUSY && tries > 0) {
+               tries--;
+               udelay(1);
+       }
+       if (tries == 0) {
+               reg = HFA384X_INW(HFA384X_CMD_OFF);
+               spin_unlock_irqrestore(&local->cmdlock, flags);
+               printk("%s: prism2_enable_aux_port - timeout - reg=0x%04x\n",
+                      dev->name, reg);
+               return -ETIMEDOUT;
+       }
+
+       val = HFA384X_INW(HFA384X_CONTROL_OFF);
+
+       if (enable) {
+               HFA384X_OUTW(HFA384X_AUX_MAGIC0, HFA384X_PARAM0_OFF);
+               HFA384X_OUTW(HFA384X_AUX_MAGIC1, HFA384X_PARAM1_OFF);
+               HFA384X_OUTW(HFA384X_AUX_MAGIC2, HFA384X_PARAM2_OFF);
+
+               if ((val & HFA384X_AUX_PORT_MASK) != HFA384X_AUX_PORT_DISABLED)
+                       printk("prism2_enable_aux_port: was not disabled!?\n");
+               val &= ~HFA384X_AUX_PORT_MASK;
+               val |= HFA384X_AUX_PORT_ENABLE;
+       } else {
+               HFA384X_OUTW(0, HFA384X_PARAM0_OFF);
+               HFA384X_OUTW(0, HFA384X_PARAM1_OFF);
+               HFA384X_OUTW(0, HFA384X_PARAM2_OFF);
+
+               if ((val & HFA384X_AUX_PORT_MASK) != HFA384X_AUX_PORT_ENABLED)
+                       printk("prism2_enable_aux_port: was not enabled!?\n");
+               val &= ~HFA384X_AUX_PORT_MASK;
+               val |= HFA384X_AUX_PORT_DISABLE;
+       }
+       HFA384X_OUTW(val, HFA384X_CONTROL_OFF);
+
+       udelay(5);
+
+       i = 10000;
+       while (i > 0) {
+               val = HFA384X_INW(HFA384X_CONTROL_OFF);
+               val &= HFA384X_AUX_PORT_MASK;
+
+               if ((enable && val == HFA384X_AUX_PORT_ENABLED) ||
+                   (!enable && val == HFA384X_AUX_PORT_DISABLED))
+                       break;
+
+               udelay(10);
+               i--;
+       }
+
+       spin_unlock_irqrestore(&local->cmdlock, flags);
+
+       if (i == 0) {
+               printk("prism2_enable_aux_port(%d) timed out\n",
+                      enable);
+               return -ETIMEDOUT;
+       }
+
+       return 0;
+}
+
+
+static int hfa384x_from_aux(struct net_device *dev, unsigned int addr, int len,
+                           void *buf)
+{
+       u16 page, offset;
+       if (addr & 1 || len & 1)
+               return -1;
+
+       page = addr >> 7;
+       offset = addr & 0x7f;
+
+       HFA384X_OUTW(page, HFA384X_AUXPAGE_OFF);
+       HFA384X_OUTW(offset, HFA384X_AUXOFFSET_OFF);
+
+       udelay(5);
+
+#ifdef PRISM2_PCI
+       {
+               u16 *pos = (u16 *) buf;
+               while (len > 0) {
+                       *pos++ = HFA384X_INW_DATA(HFA384X_AUXDATA_OFF);
+                       len -= 2;
+               }
+       }
+#else /* PRISM2_PCI */
+       HFA384X_INSW(HFA384X_AUXDATA_OFF, buf, len / 2);
+#endif /* PRISM2_PCI */
+
+       return 0;
+}
+
+
+static int hfa384x_to_aux(struct net_device *dev, unsigned int addr, int len,
+                         void *buf)
+{
+       u16 page, offset;
+       if (addr & 1 || len & 1)
+               return -1;
+
+       page = addr >> 7;
+       offset = addr & 0x7f;
+
+       HFA384X_OUTW(page, HFA384X_AUXPAGE_OFF);
+       HFA384X_OUTW(offset, HFA384X_AUXOFFSET_OFF);
+
+       udelay(5);
+
+#ifdef PRISM2_PCI
+       {
+               u16 *pos = (u16 *) buf;
+               while (len > 0) {
+                       HFA384X_OUTW_DATA(*pos++, HFA384X_AUXDATA_OFF);
+                       len -= 2;
+               }
+       }
+#else /* PRISM2_PCI */
+       HFA384X_OUTSW(HFA384X_AUXDATA_OFF, buf, len / 2);
+#endif /* PRISM2_PCI */
+
+       return 0;
+}
+
+
+static int prism2_pda_ok(u8 *buf)
+{
+       u16 *pda = (u16 *) buf;
+       int pos;
+       u16 len, pdr;
+
+       if (buf[0] == 0xff && buf[1] == 0x00 && buf[2] == 0xff &&
+           buf[3] == 0x00)
+               return 0;
+
+       pos = 0;
+       while (pos + 1 < PRISM2_PDA_SIZE / 2) {
+               len = le16_to_cpu(pda[pos]);
+               pdr = le16_to_cpu(pda[pos + 1]);
+               if (len == 0 || pos + len > PRISM2_PDA_SIZE / 2)
+                       return 0;
+
+               if (pdr == 0x0000 && len == 2) {
+                       /* PDA end found */
+                       return 1;
+               }
+
+               pos += len + 1;
+       }
+
+       return 0;
+}
+
+
+static int prism2_download_aux_dump(struct net_device *dev,
+                                    unsigned int addr, int len, u8 *buf)
+{
+       int res;
+
+       prism2_enable_aux_port(dev, 1);
+       res = hfa384x_from_aux(dev, addr, len, buf);
+       prism2_enable_aux_port(dev, 0);
+       if (res)
+               return -1;
+
+       return 0;
+}
+
+
+static u8 * prism2_read_pda(struct net_device *dev)
+{
+       u8 *buf;
+       int res, i, found = 0;
+#define NUM_PDA_ADDRS 4
+       unsigned int pda_addr[NUM_PDA_ADDRS] = {
+               0x7f0000 /* others than HFA3841 */,
+               0x3f0000 /* HFA3841 */,
+               0x390000 /* apparently used in older cards */,
+               0x7f0002 /* Intel PRO/Wireless 2011B (PCI) */,
+       };
+
+       buf = (u8 *) kmalloc(PRISM2_PDA_SIZE, GFP_KERNEL);
+       if (buf == NULL)
+               return NULL;
+
+       /* Note: wlan card should be in initial state (just after init cmd)
+        * and no other operations should be performed concurrently. */
+
+       prism2_enable_aux_port(dev, 1);
+
+       for (i = 0; i < NUM_PDA_ADDRS; i++) {
+               PDEBUG(DEBUG_EXTRA2, "%s: trying to read PDA from 0x%08x",
+                      dev->name, pda_addr[i]);
+               res = hfa384x_from_aux(dev, pda_addr[i], PRISM2_PDA_SIZE, buf);
+               if (res)
+                       continue;
+               if (res == 0 && prism2_pda_ok(buf)) {
+                       PDEBUG2(DEBUG_EXTRA2, ": OK\n");
+                       found = 1;
+                       break;
+               } else {
+                       PDEBUG2(DEBUG_EXTRA2, ": failed\n");
+               }
+       }
+
+       prism2_enable_aux_port(dev, 0);
+
+       if (!found) {
+               printk(KERN_DEBUG "%s: valid PDA not found\n", dev->name);
+               kfree(buf);
+               buf = NULL;
+       }
+
+       return buf;
+}
+
+
+static int prism2_download_volatile(local_info_t *local,
+                                   struct prism2_download_data *param)
+{
+       struct net_device *dev = local->dev;
+       int ret = 0, i;
+       u16 param0, param1;
+
+       if (local->hw_downloading) {
+               printk(KERN_WARNING "%s: Already downloading - aborting new "
+                      "request\n", dev->name);
+               return -1;
+       }
+
+       local->hw_downloading = 1;
+       if (local->pri_only) {
+               hfa384x_disable_interrupts(dev);
+       } else {
+               prism2_hw_shutdown(dev, 0);
+
+               if (prism2_hw_init(dev, 0)) {
+                       printk(KERN_WARNING "%s: Could not initialize card for"
+                              " download\n", dev->name);
+                       ret = -1;
+                       goto out;
+               }
+       }
+
+       if (prism2_enable_aux_port(dev, 1)) {
+               printk(KERN_WARNING "%s: Could not enable AUX port\n",
+                      dev->name);
+               ret = -1;
+               goto out;
+       }
+
+       param0 = param->start_addr & 0xffff;
+       param1 = param->start_addr >> 16;
+
+       HFA384X_OUTW(0, HFA384X_PARAM2_OFF);
+       HFA384X_OUTW(param1, HFA384X_PARAM1_OFF);
+       if (hfa384x_cmd_wait(dev, HFA384X_CMDCODE_DOWNLOAD |
+                            (HFA384X_PROGMODE_ENABLE_VOLATILE << 8),
+                            param0)) {
+               printk(KERN_WARNING "%s: Download command execution failed\n",
+                      dev->name);
+               ret = -1;
+               goto out;
+       }
+
+       for (i = 0; i < param->num_areas; i++) {
+               PDEBUG(DEBUG_EXTRA2, "%s: Writing %d bytes at 0x%08x\n",
+                      dev->name, param->data[i].len, param->data[i].addr);
+               if (hfa384x_to_aux(dev, param->data[i].addr,
+                                  param->data[i].len, param->data[i].data)) {
+                       printk(KERN_WARNING "%s: RAM download at 0x%08x "
+                              "(len=%d) failed\n", dev->name,
+                              param->data[i].addr, param->data[i].len);
+                       ret = -1;
+                       goto out;
+               }
+       }
+
+       HFA384X_OUTW(param1, HFA384X_PARAM1_OFF);
+       HFA384X_OUTW(0, HFA384X_PARAM2_OFF);
+       if (hfa384x_cmd_no_wait(dev, HFA384X_CMDCODE_DOWNLOAD |
+                               (HFA384X_PROGMODE_DISABLE << 8), param0)) {
+               printk(KERN_WARNING "%s: Download command execution failed\n",
+                      dev->name);
+               ret = -1;
+               goto out;
+       }
+       /* ProgMode disable causes the hardware to restart itself from the
+        * given starting address. Give hw some time and ACK command just in
+        * case restart did not happen. */
+       mdelay(5);
+       HFA384X_OUTW(HFA384X_EV_CMD, HFA384X_EVACK_OFF);
+
+       if (prism2_enable_aux_port(dev, 0)) {
+               printk(KERN_DEBUG "%s: Disabling AUX port failed\n",
+                      dev->name);
+               /* continue anyway.. restart should have taken care of this */
+       }
+
+       mdelay(5);
+       local->hw_downloading = 0;
+       if (prism2_hw_config(dev, 2)) {
+               printk(KERN_WARNING "%s: Card configuration after RAM "
+                      "download failed\n", dev->name);
+               ret = -1;
+               goto out;
+       }
+
+ out:
+       local->hw_downloading = 0;
+       return ret;
+}
+
+
+static int prism2_enable_genesis(local_info_t *local, int hcr)
+{
+       struct net_device *dev = local->dev;
+       u8 initseq[4] = { 0x00, 0xe1, 0xa1, 0xff };
+       u8 readbuf[4];
+
+       printk(KERN_DEBUG "%s: test Genesis mode with HCR 0x%02x\n",
+              dev->name, hcr);
+       local->func->cor_sreset(local);
+       hfa384x_to_aux(dev, 0x7e0038, sizeof(initseq), initseq);
+       local->func->genesis_reset(local, hcr);
+
+       /* Readback test */
+       hfa384x_from_aux(dev, 0x7e0038, sizeof(readbuf), readbuf);
+       hfa384x_to_aux(dev, 0x7e0038, sizeof(initseq), initseq);
+       hfa384x_from_aux(dev, 0x7e0038, sizeof(readbuf), readbuf);
+
+       if (memcmp(initseq, readbuf, sizeof(initseq)) == 0) {
+               printk(KERN_DEBUG "Readback test succeeded, HCR 0x%02x\n",
+                      hcr);
+               return 0;
+       } else {
+               printk(KERN_DEBUG "Readback test failed, HCR 0x%02x "
+                      "write %02x %02x %02x %02x read %02x %02x %02x %02x\n",
+                      hcr, initseq[0], initseq[1], initseq[2], initseq[3],
+                      readbuf[0], readbuf[1], readbuf[2], readbuf[3]);
+               return 1;
+       }
+}
+
+
+static int prism2_get_ram_size(local_info_t *local)
+{
+       int ret;
+
+       /* Try to enable genesis mode; 0x1F for x8 SRAM or 0x0F for x16 SRAM */
+       if (prism2_enable_genesis(local, 0x1f) == 0)
+               ret = 8;
+       else if (prism2_enable_genesis(local, 0x0f) == 0)
+               ret = 16;
+       else
+               ret = -1;
+
+       /* Disable genesis mode */
+       local->func->genesis_reset(local, ret == 16 ? 0x07 : 0x17);
+
+       return ret;
+}
+
+
+static int prism2_download_genesis(local_info_t *local,
+                                  struct prism2_download_data *param)
+{
+       struct net_device *dev = local->dev;
+       int ram16 = 0, i;
+       int ret = 0;
+
+       if (local->hw_downloading) {
+               printk(KERN_WARNING "%s: Already downloading - aborting new "
+                      "request\n", dev->name);
+               return -EBUSY;
+       }
+
+       if (!local->func->genesis_reset || !local->func->cor_sreset) {
+               printk(KERN_INFO "%s: Genesis mode downloading not supported "
+                      "with this hwmodel\n", dev->name);
+               return -EOPNOTSUPP;
+       }
+
+       local->hw_downloading = 1;
+
+       if (prism2_enable_aux_port(dev, 1)) {
+               printk(KERN_DEBUG "%s: failed to enable AUX port\n",
+                      dev->name);
+               ret = -EIO;
+               goto out;
+       }
+
+       if (local->sram_type == -1) {
+               /* 0x1F for x8 SRAM or 0x0F for x16 SRAM */
+               if (prism2_enable_genesis(local, 0x1f) == 0) {
+                       ram16 = 0;
+                       PDEBUG(DEBUG_EXTRA2, "%s: Genesis mode OK using x8 "
+                              "SRAM\n", dev->name);
+               } else if (prism2_enable_genesis(local, 0x0f) == 0) {
+                       ram16 = 1;
+                       PDEBUG(DEBUG_EXTRA2, "%s: Genesis mode OK using x16 "
+                              "SRAM\n", dev->name);
+               } else {
+                       printk(KERN_DEBUG "%s: Could not initiate genesis "
+                              "mode\n", dev->name);
+                       ret = -EIO;
+                       goto out;
+               }
+       } else {
+               if (prism2_enable_genesis(local, local->sram_type == 8 ?
+                                         0x1f : 0x0f)) {
+                       printk(KERN_DEBUG "%s: Failed to set Genesis "
+                              "mode (sram_type=%d)\n", dev->name,
+                              local->sram_type);
+                       ret = -EIO;
+                       goto out;
+               }
+               ram16 = local->sram_type != 8;
+       }
+
+       for (i = 0; i < param->num_areas; i++) {
+               PDEBUG(DEBUG_EXTRA2, "%s: Writing %d bytes at 0x%08x\n",
+                      dev->name, param->data[i].len, param->data[i].addr);
+               if (hfa384x_to_aux(dev, param->data[i].addr,
+                                  param->data[i].len, param->data[i].data)) {
+                       printk(KERN_WARNING "%s: RAM download at 0x%08x "
+                              "(len=%d) failed\n", dev->name,
+                              param->data[i].addr, param->data[i].len);
+                       ret = -EIO;
+                       goto out;
+               }
+       }
+
+       PDEBUG(DEBUG_EXTRA2, "Disable genesis mode\n");
+       local->func->genesis_reset(local, ram16 ? 0x07 : 0x17);
+       if (prism2_enable_aux_port(dev, 0)) {
+               printk(KERN_DEBUG "%s: Failed to disable AUX port\n",
+                      dev->name);
+       }
+
+       mdelay(5);
+       local->hw_downloading = 0;
+
+       PDEBUG(DEBUG_EXTRA2, "Trying to initialize card\n");
+       /*
+        * Make sure the INIT command does not generate a command completion
+        * event by disabling interrupts.
+        */
+       hfa384x_disable_interrupts(dev);
+       if (prism2_hw_init(dev, 1)) {
+               printk(KERN_DEBUG "%s: Initialization after genesis mode "
+                      "download failed\n", dev->name);
+               ret = -EIO;
+               goto out;
+       }
+
+       PDEBUG(DEBUG_EXTRA2, "Card initialized - running PRI only\n");
+       if (prism2_hw_init2(dev, 1)) {
+               printk(KERN_DEBUG "%s: Initialization(2) after genesis mode "
+                      "download failed\n", dev->name);
+               ret = -EIO;
+               goto out;
+       }
+
+ out:
+       local->hw_downloading = 0;
+       return ret;
+}
+
+
+#ifdef PRISM2_NON_VOLATILE_DOWNLOAD
+/* Note! Non-volatile downloading functionality has not yet been tested
+ * thoroughly and it may corrupt flash image and effectively kill the card that
+ * is being updated. You have been warned. */
+
+static inline int prism2_download_block(struct net_device *dev,
+                                       u32 addr, u8 *data,
+                                       u32 bufaddr, int rest_len)
+{
+       u16 param0, param1;
+       int block_len;
+
+       block_len = rest_len < 4096 ? rest_len : 4096;
+
+       param0 = addr & 0xffff;
+       param1 = addr >> 16;
+
+       HFA384X_OUTW(block_len, HFA384X_PARAM2_OFF);
+       HFA384X_OUTW(param1, HFA384X_PARAM1_OFF);
+
+       if (hfa384x_cmd_wait(dev, HFA384X_CMDCODE_DOWNLOAD |
+                            (HFA384X_PROGMODE_ENABLE_NON_VOLATILE << 8),
+                            param0)) {
+               printk(KERN_WARNING "%s: Flash download command execution "
+                      "failed\n", dev->name);
+               return -1;
+       }
+
+       if (hfa384x_to_aux(dev, bufaddr, block_len, data)) {
+               printk(KERN_WARNING "%s: flash download at 0x%08x "
+                      "(len=%d) failed\n", dev->name, addr, block_len);
+               return -1;
+       }
+
+       HFA384X_OUTW(0, HFA384X_PARAM2_OFF);
+       HFA384X_OUTW(0, HFA384X_PARAM1_OFF);
+       if (hfa384x_cmd_wait(dev, HFA384X_CMDCODE_DOWNLOAD |
+                            (HFA384X_PROGMODE_PROGRAM_NON_VOLATILE << 8),
+                            0)) {
+               printk(KERN_WARNING "%s: Flash write command execution "
+                      "failed\n", dev->name);
+               return -1;
+       }
+
+       return block_len;
+}
+
+
+static int prism2_download_nonvolatile(local_info_t *local,
+                                      struct prism2_download_data *dl)
+{
+       struct net_device *dev = local->dev;
+       int ret = 0, i;
+       struct {
+               u16 page;
+               u16 offset;
+               u16 len;
+       } dlbuffer;
+       u32 bufaddr;
+
+       if (local->hw_downloading) {
+               printk(KERN_WARNING "%s: Already downloading - aborting new "
+                      "request\n", dev->name);
+               return -1;
+       }
+
+       ret = local->func->get_rid(dev, HFA384X_RID_DOWNLOADBUFFER,
+                                  &dlbuffer, 6, 0);
+
+       if (ret < 0) {
+               printk(KERN_WARNING "%s: Could not read download buffer "
+                      "parameters\n", dev->name);
+               goto out;
+       }
+
+       dlbuffer.page = le16_to_cpu(dlbuffer.page);
+       dlbuffer.offset = le16_to_cpu(dlbuffer.offset);
+       dlbuffer.len = le16_to_cpu(dlbuffer.len);
+
+       printk(KERN_DEBUG "Download buffer: %d bytes at 0x%04x:0x%04x\n",
+              dlbuffer.len, dlbuffer.page, dlbuffer.offset);
+
+       bufaddr = (dlbuffer.page << 7) + dlbuffer.offset;
+
+       local->hw_downloading = 1;
+
+       if (!local->pri_only) {
+               prism2_hw_shutdown(dev, 0);
+
+               if (prism2_hw_init(dev, 0)) {
+                       printk(KERN_WARNING "%s: Could not initialize card for"
+                              " download\n", dev->name);
+                       ret = -1;
+                       goto out;
+               }
+       }
+
+       hfa384x_disable_interrupts(dev);
+
+       if (prism2_enable_aux_port(dev, 1)) {
+               printk(KERN_WARNING "%s: Could not enable AUX port\n",
+                      dev->name);
+               ret = -1;
+               goto out;
+       }
+
+       printk(KERN_DEBUG "%s: starting flash download\n", dev->name);
+       for (i = 0; i < dl->num_areas; i++) {
+               int rest_len = dl->data[i].len;
+               int data_off = 0;
+
+               while (rest_len > 0) {
+                       int block_len;
+
+                       block_len = prism2_download_block(
+                               dev, dl->data[i].addr + data_off,
+                               dl->data[i].data + data_off, bufaddr,
+                               rest_len);
+
+                       if (block_len < 0) {
+                               ret = -1;
+                               goto out;
+                       }
+
+                       rest_len -= block_len;
+                       data_off += block_len;
+               }
+       }
+
+       HFA384X_OUTW(0, HFA384X_PARAM1_OFF);
+       HFA384X_OUTW(0, HFA384X_PARAM2_OFF);
+       if (hfa384x_cmd_wait(dev, HFA384X_CMDCODE_DOWNLOAD |
+                               (HFA384X_PROGMODE_DISABLE << 8), 0)) {
+               printk(KERN_WARNING "%s: Download command execution failed\n",
+                      dev->name);
+               ret = -1;
+               goto out;
+       }
+
+       if (prism2_enable_aux_port(dev, 0)) {
+               printk(KERN_DEBUG "%s: Disabling AUX port failed\n",
+                      dev->name);
+               /* continue anyway.. restart should have taken care of this */
+       }
+
+       mdelay(5);
+
+       local->func->hw_reset(dev);
+       local->hw_downloading = 0;
+       if (prism2_hw_config(dev, 2)) {
+               printk(KERN_WARNING "%s: Card configuration after flash "
+                      "download failed\n", dev->name);
+               ret = -1;
+       } else {
+               printk(KERN_INFO "%s: Card initialized successfully after "
+                      "flash download\n", dev->name);
+       }
+
+ out:
+       local->hw_downloading = 0;
+       return ret;
+}
+#endif /* PRISM2_NON_VOLATILE_DOWNLOAD */
+
+
+static void prism2_download_free_data(struct prism2_download_data *dl)
+{
+       int i;
+
+       if (dl == NULL)
+               return;
+
+       for (i = 0; i < dl->num_areas; i++)
+               kfree(dl->data[i].data);
+       kfree(dl);
+}
+
+
+static int prism2_download(local_info_t *local,
+                          struct prism2_download_param *param)
+{
+       int ret = 0;
+       int i;
+       u32 total_len = 0;
+       struct prism2_download_data *dl = NULL;
+
+       printk(KERN_DEBUG "prism2_download: dl_cmd=%d start_addr=0x%08x "
+              "num_areas=%d\n",
+              param->dl_cmd, param->start_addr, param->num_areas);
+
+       if (param->num_areas > 100) {
+               ret = -EINVAL;
+               goto out;
+       }
+
+       dl = kmalloc(sizeof(*dl) + param->num_areas *
+                    sizeof(struct prism2_download_data_area), GFP_KERNEL);
+       if (dl == NULL) {
+               ret = -ENOMEM;
+               goto out;
+       }
+       memset(dl, 0, sizeof(*dl) + param->num_areas *
+              sizeof(struct prism2_download_data_area));
+       dl->dl_cmd = param->dl_cmd;
+       dl->start_addr = param->start_addr;
+       dl->num_areas = param->num_areas;
+       for (i = 0; i < param->num_areas; i++) {
+               PDEBUG(DEBUG_EXTRA2,
+                      "  area %d: addr=0x%08x len=%d ptr=0x%p\n",
+                      i, param->data[i].addr, param->data[i].len,
+                      param->data[i].ptr);
+
+               dl->data[i].addr = param->data[i].addr;
+               dl->data[i].len = param->data[i].len;
+
+               total_len += param->data[i].len;
+               if (param->data[i].len > PRISM2_MAX_DOWNLOAD_AREA_LEN ||
+                   total_len > PRISM2_MAX_DOWNLOAD_LEN) {
+                       ret = -E2BIG;
+                       goto out;
+               }
+
+               dl->data[i].data = kmalloc(dl->data[i].len, GFP_KERNEL);
+               if (dl->data[i].data == NULL) {
+                       ret = -ENOMEM;
+                       goto out;
+               }
+
+               if (copy_from_user(dl->data[i].data, param->data[i].ptr,
+                                  param->data[i].len)) {
+                       ret = -EFAULT;
+                       goto out;
+               }
+       }
+
+       switch (param->dl_cmd) {
+       case PRISM2_DOWNLOAD_VOLATILE:
+       case PRISM2_DOWNLOAD_VOLATILE_PERSISTENT:
+               ret = prism2_download_volatile(local, dl);
+               break;
+       case PRISM2_DOWNLOAD_VOLATILE_GENESIS:
+       case PRISM2_DOWNLOAD_VOLATILE_GENESIS_PERSISTENT:
+               ret = prism2_download_genesis(local, dl);
+               break;
+       case PRISM2_DOWNLOAD_NON_VOLATILE:
+#ifdef PRISM2_NON_VOLATILE_DOWNLOAD
+               ret = prism2_download_nonvolatile(local, dl);
+#else /* PRISM2_NON_VOLATILE_DOWNLOAD */
+               printk(KERN_INFO "%s: non-volatile downloading not enabled\n",
+                      local->dev->name);
+               ret = -EOPNOTSUPP;
+#endif /* PRISM2_NON_VOLATILE_DOWNLOAD */
+               break;
+       default:
+               printk(KERN_DEBUG "%s: unsupported download command %d\n",
+                      local->dev->name, param->dl_cmd);
+               ret = -EINVAL;
+               break;
+       };
+
+ out:
+       if (ret == 0 && dl &&
+           param->dl_cmd == PRISM2_DOWNLOAD_VOLATILE_GENESIS_PERSISTENT) {
+               prism2_download_free_data(local->dl_pri);
+               local->dl_pri = dl;
+       } else if (ret == 0 && dl &&
+                  param->dl_cmd == PRISM2_DOWNLOAD_VOLATILE_PERSISTENT) {
+               prism2_download_free_data(local->dl_sec);
+               local->dl_sec = dl;
+       } else
+               prism2_download_free_data(dl);
+
+       return ret;
+}
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c
new file mode 100644 (file)
index 0000000..e533a66
--- /dev/null
@@ -0,0 +1,3445 @@
+/*
+ * Host AP (software wireless LAN access point) driver for
+ * Intersil Prism2/2.5/3.
+ *
+ * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
+ * <jkmaline@cc.hut.fi>
+ * Copyright (c) 2002-2005, Jouni Malinen <jkmaline@cc.hut.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. See README and COPYING for
+ * more details.
+ *
+ * FIX:
+ * - there is currently no way of associating TX packets to correct wds device
+ *   when TX Exc/OK event occurs, so all tx_packets and some
+ *   tx_errors/tx_dropped are added to the main netdevice; using sw_support
+ *   field in txdesc might be used to fix this (using Alloc event to increment
+ *   tx_packets would need some further info in txfid table)
+ *
+ * Buffer Access Path (BAP) usage:
+ *   Prism2 cards have two separate BAPs for accessing the card memory. These
+ *   should allow concurrent access to two different frames and the driver
+ *   previously used BAP0 for sending data and BAP1 for receiving data.
+ *   However, there seems to be number of issues with concurrent access and at
+ *   least one know hardware bug in using BAP0 and BAP1 concurrently with PCI
+ *   Prism2.5. Therefore, the driver now only uses BAP0 for moving data between
+ *   host and card memories. BAP0 accesses are protected with local->baplock
+ *   (spin_lock_bh) to prevent concurrent use.
+ */
+
+
+#include <linux/config.h>
+#include <linux/version.h>
+
+#include <asm/delay.h>
+#include <asm/uaccess.h>
+
+#include <linux/slab.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/proc_fs.h>
+#include <linux/if_arp.h>
+#include <linux/delay.h>
+#include <linux/random.h>
+#include <linux/wait.h>
+#include <linux/sched.h>
+#include <linux/rtnetlink.h>
+#include <linux/wireless.h>
+#include <net/iw_handler.h>
+#include <net/ieee80211.h>
+#include <net/ieee80211_crypt.h>
+#include <asm/irq.h>
+
+#include "hostap_80211.h"
+#include "hostap.h"
+#include "hostap_ap.h"
+
+
+/* #define final_version */
+
+static int mtu = 1500;
+module_param(mtu, int, 0444);
+MODULE_PARM_DESC(mtu, "Maximum transfer unit");
+
+static int channel[MAX_PARM_DEVICES] = { 3, DEF_INTS };
+module_param_array(channel, int, NULL, 0444);
+MODULE_PARM_DESC(channel, "Initial channel");
+
+static char essid[33] = "test";
+module_param_string(essid, essid, sizeof(essid), 0444);
+MODULE_PARM_DESC(essid, "Host AP's ESSID");
+
+static int iw_mode[MAX_PARM_DEVICES] = { IW_MODE_MASTER, DEF_INTS };
+module_param_array(iw_mode, int, NULL, 0444);
+MODULE_PARM_DESC(iw_mode, "Initial operation mode");
+
+static int beacon_int[MAX_PARM_DEVICES] = { 100, DEF_INTS };
+module_param_array(beacon_int, int, NULL, 0444);
+MODULE_PARM_DESC(beacon_int, "Beacon interval (1 = 1024 usec)");
+
+static int dtim_period[MAX_PARM_DEVICES] = { 1, DEF_INTS };
+module_param_array(dtim_period, int, NULL, 0444);
+MODULE_PARM_DESC(dtim_period, "DTIM period");
+
+static char dev_template[16] = "wlan%d";
+module_param_string(dev_template, dev_template, sizeof(dev_template), 0444);
+MODULE_PARM_DESC(dev_template, "Prefix for network device name (default: "
+                "wlan%d)");
+
+#ifdef final_version
+#define EXTRA_EVENTS_WTERR 0
+#else
+/* check WTERR events (Wait Time-out) in development versions */
+#define EXTRA_EVENTS_WTERR HFA384X_EV_WTERR
+#endif
+
+/* Events that will be using BAP0 */
+#define HFA384X_BAP0_EVENTS \
+       (HFA384X_EV_TXEXC | HFA384X_EV_RX | HFA384X_EV_INFO | HFA384X_EV_TX)
+
+/* event mask, i.e., events that will result in an interrupt */
+#define HFA384X_EVENT_MASK \
+       (HFA384X_BAP0_EVENTS | HFA384X_EV_ALLOC | HFA384X_EV_INFDROP | \
+       HFA384X_EV_CMD | HFA384X_EV_TICK | \
+       EXTRA_EVENTS_WTERR)
+
+/* Default TX control flags: use 802.11 headers and request interrupt for
+ * failed transmits. Frames that request ACK callback, will add
+ * _TX_OK flag and _ALT_RTRY flag may be used to select different retry policy.
+ */
+#define HFA384X_TX_CTRL_FLAGS \
+       (HFA384X_TX_CTRL_802_11 | HFA384X_TX_CTRL_TX_EX)
+
+
+/* ca. 1 usec */
+#define HFA384X_CMD_BUSY_TIMEOUT 5000
+#define HFA384X_BAP_BUSY_TIMEOUT 50000
+
+/* ca. 10 usec */
+#define HFA384X_CMD_COMPL_TIMEOUT 20000
+#define HFA384X_DL_COMPL_TIMEOUT 1000000
+
+/* Wait times for initialization; yield to other processes to avoid busy
+ * waiting for long time. */
+#define HFA384X_INIT_TIMEOUT (HZ / 2) /* 500 ms */
+#define HFA384X_ALLOC_COMPL_TIMEOUT (HZ / 20) /* 50 ms */
+
+
+static void prism2_hw_reset(struct net_device *dev);
+static void prism2_check_sta_fw_version(local_info_t *local);
+
+#ifdef PRISM2_DOWNLOAD_SUPPORT
+/* hostap_download.c */
+static int prism2_download_aux_dump(struct net_device *dev,
+                                   unsigned int addr, int len, u8 *buf);
+static u8 * prism2_read_pda(struct net_device *dev);
+static int prism2_download(local_info_t *local,
+                          struct prism2_download_param *param);
+static void prism2_download_free_data(struct prism2_download_data *dl);
+static int prism2_download_volatile(local_info_t *local,
+                                   struct prism2_download_data *param);
+static int prism2_download_genesis(local_info_t *local,
+                                  struct prism2_download_data *param);
+static int prism2_get_ram_size(local_info_t *local);
+#endif /* PRISM2_DOWNLOAD_SUPPORT */
+
+
+
+
+#ifndef final_version
+/* magic value written to SWSUPPORT0 reg. for detecting whether card is still
+ * present */
+#define HFA384X_MAGIC 0x8A32
+#endif
+
+
+static u16 hfa384x_read_reg(struct net_device *dev, u16 reg)
+{
+       return HFA384X_INW(reg);
+}
+
+
+static void hfa384x_read_regs(struct net_device *dev,
+                             struct hfa384x_regs *regs)
+{
+       regs->cmd = HFA384X_INW(HFA384X_CMD_OFF);
+       regs->evstat = HFA384X_INW(HFA384X_EVSTAT_OFF);
+       regs->offset0 = HFA384X_INW(HFA384X_OFFSET0_OFF);
+       regs->offset1 = HFA384X_INW(HFA384X_OFFSET1_OFF);
+       regs->swsupport0 = HFA384X_INW(HFA384X_SWSUPPORT0_OFF);
+}
+
+
+/**
+ * __hostap_cmd_queue_free - Free Prism2 command queue entry (private)
+ * @local: pointer to private Host AP driver data
+ * @entry: Prism2 command queue entry to be freed
+ * @del_req: request the entry to be removed
+ *
+ * Internal helper function for freeing Prism2 command queue entries.
+ * Caller must have acquired local->cmdlock before calling this function.
+ */
+static inline void __hostap_cmd_queue_free(local_info_t *local,
+                                          struct hostap_cmd_queue *entry,
+                                          int del_req)
+{
+       if (del_req) {
+               entry->del_req = 1;
+               if (!list_empty(&entry->list)) {
+                       list_del_init(&entry->list);
+                       local->cmd_queue_len--;
+               }
+       }
+
+       if (atomic_dec_and_test(&entry->usecnt) && entry->del_req)
+               kfree(entry);
+}
+
+
+/**
+ * hostap_cmd_queue_free - Free Prism2 command queue entry
+ * @local: pointer to private Host AP driver data
+ * @entry: Prism2 command queue entry to be freed
+ * @del_req: request the entry to be removed
+ *
+ * Free a Prism2 command queue entry.
+ */
+static inline void hostap_cmd_queue_free(local_info_t *local,
+                                        struct hostap_cmd_queue *entry,
+                                        int del_req)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&local->cmdlock, flags);
+       __hostap_cmd_queue_free(local, entry, del_req);
+       spin_unlock_irqrestore(&local->cmdlock, flags);
+}
+
+
+/**
+ * prism2_clear_cmd_queue - Free all pending Prism2 command queue entries
+ * @local: pointer to private Host AP driver data
+ */
+static void prism2_clear_cmd_queue(local_info_t *local)
+{
+       struct list_head *ptr, *n;
+       unsigned long flags;
+       struct hostap_cmd_queue *entry;
+
+       spin_lock_irqsave(&local->cmdlock, flags);
+       list_for_each_safe(ptr, n, &local->cmd_queue) {
+               entry = list_entry(ptr, struct hostap_cmd_queue, list);
+               atomic_inc(&entry->usecnt);
+               printk(KERN_DEBUG "%s: removed pending cmd_queue entry "
+                      "(type=%d, cmd=0x%04x, param0=0x%04x)\n",
+                      local->dev->name, entry->type, entry->cmd,
+                      entry->param0);
+               __hostap_cmd_queue_free(local, entry, 1);
+       }
+       if (local->cmd_queue_len) {
+               /* This should not happen; print debug message and clear
+                * queue length. */
+               printk(KERN_DEBUG "%s: cmd_queue_len (%d) not zero after "
+                      "flush\n", local->dev->name, local->cmd_queue_len);
+               local->cmd_queue_len = 0;
+       }
+       spin_unlock_irqrestore(&local->cmdlock, flags);
+}
+
+
+/**
+ * hfa384x_cmd_issue - Issue a Prism2 command to the hardware
+ * @dev: pointer to net_device
+ * @entry: Prism2 command queue entry to be issued
+ */
+static inline int hfa384x_cmd_issue(struct net_device *dev,
+                                   struct hostap_cmd_queue *entry)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int tries;
+       u16 reg;
+       unsigned long flags;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (local->func->card_present && !local->func->card_present(local))
+               return -ENODEV;
+
+       if (entry->issued) {
+               printk(KERN_DEBUG "%s: driver bug - re-issuing command @%p\n",
+                      dev->name, entry);
+       }
+
+       /* wait until busy bit is clear; this should always be clear since the
+        * commands are serialized */
+       tries = HFA384X_CMD_BUSY_TIMEOUT;
+       while (HFA384X_INW(HFA384X_CMD_OFF) & HFA384X_CMD_BUSY && tries > 0) {
+               tries--;
+               udelay(1);
+       }
+#ifndef final_version
+       if (tries != HFA384X_CMD_BUSY_TIMEOUT) {
+               prism2_io_debug_error(dev, 1);
+               printk(KERN_DEBUG "%s: hfa384x_cmd_issue: cmd reg was busy "
+                      "for %d usec\n", dev->name,
+                      HFA384X_CMD_BUSY_TIMEOUT - tries);
+       }
+#endif
+       if (tries == 0) {
+               reg = HFA384X_INW(HFA384X_CMD_OFF);
+               prism2_io_debug_error(dev, 2);
+               printk(KERN_DEBUG "%s: hfa384x_cmd_issue - timeout - "
+                      "reg=0x%04x\n", dev->name, reg);
+               return -ETIMEDOUT;
+       }
+
+       /* write command */
+       spin_lock_irqsave(&local->cmdlock, flags);
+       HFA384X_OUTW(entry->param0, HFA384X_PARAM0_OFF);
+       HFA384X_OUTW(entry->param1, HFA384X_PARAM1_OFF);
+       HFA384X_OUTW(entry->cmd, HFA384X_CMD_OFF);
+       entry->issued = 1;
+       spin_unlock_irqrestore(&local->cmdlock, flags);
+
+       return 0;
+}
+
+
+/**
+ * hfa384x_cmd - Issue a Prism2 command and wait (sleep) for completion
+ * @dev: pointer to net_device
+ * @cmd: Prism2 command code (HFA384X_CMD_CODE_*)
+ * @param0: value for Param0 register
+ * @param1: value for Param1 register (pointer; %NULL if not used)
+ * @resp0: pointer for Resp0 data or %NULL if Resp0 is not needed
+ *
+ * Issue given command (possibly after waiting in command queue) and sleep
+ * until the command is completed (or timed out or interrupted). This can be
+ * called only from user process context.
+ */
+static int hfa384x_cmd(struct net_device *dev, u16 cmd, u16 param0,
+                      u16 *param1, u16 *resp0)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int err, res, issue, issued = 0;
+       unsigned long flags;
+       struct hostap_cmd_queue *entry;
+       DECLARE_WAITQUEUE(wait, current);
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (in_interrupt()) {
+               printk(KERN_DEBUG "%s: hfa384x_cmd called from interrupt "
+                      "context\n", dev->name);
+               return -1;
+       }
+
+       if (local->cmd_queue_len >= HOSTAP_CMD_QUEUE_MAX_LEN) {
+               printk(KERN_DEBUG "%s: hfa384x_cmd: cmd_queue full\n",
+                      dev->name);
+               return -1;
+       }
+
+       if (signal_pending(current))
+               return -EINTR;
+
+       entry = (struct hostap_cmd_queue *)
+               kmalloc(sizeof(*entry), GFP_ATOMIC);
+       if (entry == NULL) {
+               printk(KERN_DEBUG "%s: hfa384x_cmd - kmalloc failed\n",
+                      dev->name);
+               return -ENOMEM;
+       }
+       memset(entry, 0, sizeof(*entry));
+       atomic_set(&entry->usecnt, 1);
+       entry->type = CMD_SLEEP;
+       entry->cmd = cmd;
+       entry->param0 = param0;
+       if (param1)
+               entry->param1 = *param1;
+       init_waitqueue_head(&entry->compl);
+
+       /* prepare to wait for command completion event, but do not sleep yet
+        */
+       add_wait_queue(&entry->compl, &wait);
+       set_current_state(TASK_INTERRUPTIBLE);
+
+       spin_lock_irqsave(&local->cmdlock, flags);
+       issue = list_empty(&local->cmd_queue);
+       if (issue)
+               entry->issuing = 1;
+       list_add_tail(&entry->list, &local->cmd_queue);
+       local->cmd_queue_len++;
+       spin_unlock_irqrestore(&local->cmdlock, flags);
+
+       err = 0;
+       if (!issue)
+               goto wait_completion;
+
+       if (signal_pending(current))
+               err = -EINTR;
+
+       if (!err) {
+               if (hfa384x_cmd_issue(dev, entry))
+                       err = -ETIMEDOUT;
+               else
+                       issued = 1;
+       }
+
+ wait_completion:
+       if (!err && entry->type != CMD_COMPLETED) {
+               /* sleep until command is completed or timed out */
+               res = schedule_timeout(2 * HZ);
+       } else
+               res = -1;
+
+       if (!err && signal_pending(current))
+               err = -EINTR;
+
+       if (err && issued) {
+               /* the command was issued, so a CmdCompl event should occur
+                * soon; however, there's a pending signal and
+                * schedule_timeout() would be interrupted; wait a short period
+                * of time to avoid removing entry from the list before
+                * CmdCompl event */
+               udelay(300);
+       }
+
+       set_current_state(TASK_RUNNING);
+       remove_wait_queue(&entry->compl, &wait);
+
+       /* If entry->list is still in the list, it must be removed
+        * first and in this case prism2_cmd_ev() does not yet have
+        * local reference to it, and the data can be kfree()'d
+        * here. If the command completion event is still generated,
+        * it will be assigned to next (possibly) pending command, but
+        * the driver will reset the card anyway due to timeout
+        *
+        * If the entry is not in the list prism2_cmd_ev() has a local
+        * reference to it, but keeps cmdlock as long as the data is
+        * needed, so the data can be kfree()'d here. */
+
+       /* FIX: if the entry->list is in the list, it has not been completed
+        * yet, so removing it here is somewhat wrong.. this could cause
+        * references to freed memory and next list_del() causing NULL pointer
+        * dereference.. it would probably be better to leave the entry in the
+        * list and the list should be emptied during hw reset */
+
+       spin_lock_irqsave(&local->cmdlock, flags);
+       if (!list_empty(&entry->list)) {
+               printk(KERN_DEBUG "%s: hfa384x_cmd: entry still in list? "
+                      "(entry=%p, type=%d, res=%d)\n", dev->name, entry,
+                      entry->type, res);
+               list_del_init(&entry->list);
+               local->cmd_queue_len--;
+       }
+       spin_unlock_irqrestore(&local->cmdlock, flags);
+
+       if (err) {
+               printk(KERN_DEBUG "%s: hfa384x_cmd: interrupted; err=%d\n",
+                      dev->name, err);
+               res = err;
+               goto done;
+       }
+
+       if (entry->type != CMD_COMPLETED) {
+               u16 reg = HFA384X_INW(HFA384X_EVSTAT_OFF);
+               printk(KERN_DEBUG "%s: hfa384x_cmd: command was not "
+                      "completed (res=%d, entry=%p, type=%d, cmd=0x%04x, "
+                      "param0=0x%04x, EVSTAT=%04x INTEN=%04x)\n", dev->name,
+                      res, entry, entry->type, entry->cmd, entry->param0, reg,
+                      HFA384X_INW(HFA384X_INTEN_OFF));
+               if (reg & HFA384X_EV_CMD) {
+                       /* Command completion event is pending, but the
+                        * interrupt was not delivered - probably an issue
+                        * with pcmcia-cs configuration. */
+                       printk(KERN_WARNING "%s: interrupt delivery does not "
+                              "seem to work\n", dev->name);
+               }
+               prism2_io_debug_error(dev, 3);
+               res = -ETIMEDOUT;
+               goto done;
+       }
+
+       if (resp0 != NULL)
+               *resp0 = entry->resp0;
+#ifndef final_version
+       if (entry->res) {
+               printk(KERN_DEBUG "%s: CMD=0x%04x => res=0x%02x, "
+                      "resp0=0x%04x\n",
+                      dev->name, cmd, entry->res, entry->resp0);
+       }
+#endif /* final_version */
+
+       res = entry->res;
+ done:
+       hostap_cmd_queue_free(local, entry, 1);
+       return res;
+}
+
+
+/**
+ * hfa384x_cmd_callback - Issue a Prism2 command; callback when completed
+ * @dev: pointer to net_device
+ * @cmd: Prism2 command code (HFA384X_CMD_CODE_*)
+ * @param0: value for Param0 register
+ * @callback: command completion callback function (%NULL = no callback)
+ * @context: context data to be given to the callback function
+ *
+ * Issue given command (possibly after waiting in command queue) and use
+ * callback function to indicate command completion. This can be called both
+ * from user and interrupt context. The callback function will be called in
+ * hardware IRQ context. It can be %NULL, when no function is called when
+ * command is completed.
+ */
+static int hfa384x_cmd_callback(struct net_device *dev, u16 cmd, u16 param0,
+                               void (*callback)(struct net_device *dev,
+                                                long context, u16 resp0,
+                                                u16 status),
+                               long context)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int issue, ret;
+       unsigned long flags;
+       struct hostap_cmd_queue *entry;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (local->cmd_queue_len >= HOSTAP_CMD_QUEUE_MAX_LEN + 2) {
+               printk(KERN_DEBUG "%s: hfa384x_cmd: cmd_queue full\n",
+                      dev->name);
+               return -1;
+       }
+
+       entry = (struct hostap_cmd_queue *)
+               kmalloc(sizeof(*entry), GFP_ATOMIC);
+       if (entry == NULL) {
+               printk(KERN_DEBUG "%s: hfa384x_cmd_callback - kmalloc "
+                      "failed\n", dev->name);
+               return -ENOMEM;
+       }
+       memset(entry, 0, sizeof(*entry));
+       atomic_set(&entry->usecnt, 1);
+       entry->type = CMD_CALLBACK;
+       entry->cmd = cmd;
+       entry->param0 = param0;
+       entry->callback = callback;
+       entry->context = context;
+
+       spin_lock_irqsave(&local->cmdlock, flags);
+       issue = list_empty(&local->cmd_queue);
+       if (issue)
+               entry->issuing = 1;
+       list_add_tail(&entry->list, &local->cmd_queue);
+       local->cmd_queue_len++;
+       spin_unlock_irqrestore(&local->cmdlock, flags);
+
+       if (issue && hfa384x_cmd_issue(dev, entry))
+               ret = -ETIMEDOUT;
+       else
+               ret = 0;
+
+       hostap_cmd_queue_free(local, entry, ret);
+
+       return ret;
+}
+
+
+/**
+ * __hfa384x_cmd_no_wait - Issue a Prism2 command (private)
+ * @dev: pointer to net_device
+ * @cmd: Prism2 command code (HFA384X_CMD_CODE_*)
+ * @param0: value for Param0 register
+ * @io_debug_num: I/O debug error number
+ *
+ * Shared helper function for hfa384x_cmd_wait() and hfa384x_cmd_no_wait().
+ */
+static int __hfa384x_cmd_no_wait(struct net_device *dev, u16 cmd, u16 param0,
+                                int io_debug_num)
+{
+       int tries;
+       u16 reg;
+
+       /* wait until busy bit is clear; this should always be clear since the
+        * commands are serialized */
+       tries = HFA384X_CMD_BUSY_TIMEOUT;
+       while (HFA384X_INW(HFA384X_CMD_OFF) & HFA384X_CMD_BUSY && tries > 0) {
+               tries--;
+               udelay(1);
+       }
+       if (tries == 0) {
+               reg = HFA384X_INW(HFA384X_CMD_OFF);
+               prism2_io_debug_error(dev, io_debug_num);
+               printk(KERN_DEBUG "%s: __hfa384x_cmd_no_wait(%d) - timeout - "
+                      "reg=0x%04x\n", dev->name, io_debug_num, reg);
+               return -ETIMEDOUT;
+       }
+
+       /* write command */
+       HFA384X_OUTW(param0, HFA384X_PARAM0_OFF);
+       HFA384X_OUTW(cmd, HFA384X_CMD_OFF);
+
+       return 0;
+}
+
+
+/**
+ * hfa384x_cmd_wait - Issue a Prism2 command and busy wait for completion
+ * @dev: pointer to net_device
+ * @cmd: Prism2 command code (HFA384X_CMD_CODE_*)
+ * @param0: value for Param0 register
+ */
+static int hfa384x_cmd_wait(struct net_device *dev, u16 cmd, u16 param0)
+{
+       int res, tries;
+       u16 reg;
+
+       res = __hfa384x_cmd_no_wait(dev, cmd, param0, 4);
+       if (res)
+               return res;
+
+        /* wait for command completion */
+       if ((cmd & HFA384X_CMDCODE_MASK) == HFA384X_CMDCODE_DOWNLOAD)
+               tries = HFA384X_DL_COMPL_TIMEOUT;
+       else
+               tries = HFA384X_CMD_COMPL_TIMEOUT;
+
+        while (!(HFA384X_INW(HFA384X_EVSTAT_OFF) & HFA384X_EV_CMD) &&
+               tries > 0) {
+                tries--;
+                udelay(10);
+        }
+        if (tries == 0) {
+                reg = HFA384X_INW(HFA384X_EVSTAT_OFF);
+               prism2_io_debug_error(dev, 5);
+                printk(KERN_DEBUG "%s: hfa384x_cmd_wait - timeout2 - "
+                      "reg=0x%04x\n", dev->name, reg);
+                return -ETIMEDOUT;
+        }
+
+        res = (HFA384X_INW(HFA384X_STATUS_OFF) &
+               (BIT(14) | BIT(13) | BIT(12) | BIT(11) | BIT(10) | BIT(9) |
+                BIT(8))) >> 8;
+#ifndef final_version
+       if (res) {
+               printk(KERN_DEBUG "%s: CMD=0x%04x => res=0x%02x\n",
+                      dev->name, cmd, res);
+       }
+#endif
+
+       HFA384X_OUTW(HFA384X_EV_CMD, HFA384X_EVACK_OFF);
+
+       return res;
+}
+
+
+/**
+ * hfa384x_cmd_no_wait - Issue a Prism2 command; do not wait for completion
+ * @dev: pointer to net_device
+ * @cmd: Prism2 command code (HFA384X_CMD_CODE_*)
+ * @param0: value for Param0 register
+ */
+static inline int hfa384x_cmd_no_wait(struct net_device *dev, u16 cmd,
+                                     u16 param0)
+{
+       return __hfa384x_cmd_no_wait(dev, cmd, param0, 6);
+}
+
+
+/**
+ * prism2_cmd_ev - Prism2 command completion event handler
+ * @dev: pointer to net_device
+ *
+ * Interrupt handler for command completion events. Called by the main
+ * interrupt handler in hardware IRQ context. Read Resp0 and status registers
+ * from the hardware and ACK the event. Depending on the issued command type
+ * either wake up the sleeping process that is waiting for command completion
+ * or call the callback function. Issue the next command, if one is pending.
+ */
+static void prism2_cmd_ev(struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       struct hostap_cmd_queue *entry = NULL;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       spin_lock(&local->cmdlock);
+       if (!list_empty(&local->cmd_queue)) {
+               entry = list_entry(local->cmd_queue.next,
+                                  struct hostap_cmd_queue, list);
+               atomic_inc(&entry->usecnt);
+               list_del_init(&entry->list);
+               local->cmd_queue_len--;
+
+               if (!entry->issued) {
+                       printk(KERN_DEBUG "%s: Command completion event, but "
+                              "cmd not issued\n", dev->name);
+                       __hostap_cmd_queue_free(local, entry, 1);
+                       entry = NULL;
+               }
+       }
+       spin_unlock(&local->cmdlock);
+
+       if (!entry) {
+               HFA384X_OUTW(HFA384X_EV_CMD, HFA384X_EVACK_OFF);
+               printk(KERN_DEBUG "%s: Command completion event, but no "
+                      "pending commands\n", dev->name);
+               return;
+       }
+
+       entry->resp0 = HFA384X_INW(HFA384X_RESP0_OFF);
+       entry->res = (HFA384X_INW(HFA384X_STATUS_OFF) &
+                     (BIT(14) | BIT(13) | BIT(12) | BIT(11) | BIT(10) |
+                      BIT(9) | BIT(8))) >> 8;
+       HFA384X_OUTW(HFA384X_EV_CMD, HFA384X_EVACK_OFF);
+
+       /* TODO: rest of the CmdEv handling could be moved to tasklet */
+       if (entry->type == CMD_SLEEP) {
+               entry->type = CMD_COMPLETED;
+               wake_up_interruptible(&entry->compl);
+       } else if (entry->type == CMD_CALLBACK) {
+               if (entry->callback)
+                       entry->callback(dev, entry->context, entry->resp0,
+                                       entry->res);
+       } else {
+               printk(KERN_DEBUG "%s: Invalid command completion type %d\n",
+                      dev->name, entry->type);
+       }
+       hostap_cmd_queue_free(local, entry, 1);
+
+       /* issue next command, if pending */
+       entry = NULL;
+       spin_lock(&local->cmdlock);
+       if (!list_empty(&local->cmd_queue)) {
+               entry = list_entry(local->cmd_queue.next,
+                                  struct hostap_cmd_queue, list);
+               if (entry->issuing) {
+                       /* hfa384x_cmd() has already started issuing this
+                        * command, so do not start here */
+                       entry = NULL;
+               }
+               if (entry)
+                       atomic_inc(&entry->usecnt);
+       }
+       spin_unlock(&local->cmdlock);
+
+       if (entry) {
+               /* issue next command; if command issuing fails, remove the
+                * entry from cmd_queue */
+               int res = hfa384x_cmd_issue(dev, entry);
+               spin_lock(&local->cmdlock);
+               __hostap_cmd_queue_free(local, entry, res);
+               spin_unlock(&local->cmdlock);
+       }
+}
+
+
+static inline int hfa384x_wait_offset(struct net_device *dev, u16 o_off)
+{
+       int tries = HFA384X_BAP_BUSY_TIMEOUT;
+       int res = HFA384X_INW(o_off) & HFA384X_OFFSET_BUSY;
+
+       while (res && tries > 0) {
+               tries--;
+               udelay(1);
+               res = HFA384X_INW(o_off) & HFA384X_OFFSET_BUSY;
+       }
+       return res;
+}
+
+
+/* Offset must be even */
+static int hfa384x_setup_bap(struct net_device *dev, u16 bap, u16 id,
+                            int offset)
+{
+       u16 o_off, s_off;
+       int ret = 0;
+
+       if (offset % 2 || bap > 1)
+               return -EINVAL;
+
+       if (bap == BAP1) {
+               o_off = HFA384X_OFFSET1_OFF;
+               s_off = HFA384X_SELECT1_OFF;
+       } else {
+               o_off = HFA384X_OFFSET0_OFF;
+               s_off = HFA384X_SELECT0_OFF;
+       }
+
+       if (hfa384x_wait_offset(dev, o_off)) {
+               prism2_io_debug_error(dev, 7);
+               printk(KERN_DEBUG "%s: hfa384x_setup_bap - timeout before\n",
+                      dev->name);
+               ret = -ETIMEDOUT;
+               goto out;
+       }
+
+       HFA384X_OUTW(id, s_off);
+       HFA384X_OUTW(offset, o_off);
+
+       if (hfa384x_wait_offset(dev, o_off)) {
+               prism2_io_debug_error(dev, 8);
+               printk(KERN_DEBUG "%s: hfa384x_setup_bap - timeout after\n",
+                      dev->name);
+               ret = -ETIMEDOUT;
+               goto out;
+       }
+#ifndef final_version
+       if (HFA384X_INW(o_off) & HFA384X_OFFSET_ERR) {
+               prism2_io_debug_error(dev, 9);
+               printk(KERN_DEBUG "%s: hfa384x_setup_bap - offset error "
+                      "(%d,0x04%x,%d); reg=0x%04x\n",
+                      dev->name, bap, id, offset, HFA384X_INW(o_off));
+               ret = -EINVAL;
+       }
+#endif
+
+ out:
+       return ret;
+}
+
+
+static int hfa384x_get_rid(struct net_device *dev, u16 rid, void *buf, int len,
+                          int exact_len)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int res, rlen = 0;
+       struct hfa384x_rid_hdr rec;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (local->no_pri) {
+               printk(KERN_DEBUG "%s: cannot get RID %04x (len=%d) - no PRI "
+                      "f/w\n", dev->name, rid, len);
+               return -ENOTTY; /* Well.. not really correct, but return
+                                * something unique enough.. */
+       }
+
+       if ((local->func->card_present && !local->func->card_present(local)) ||
+           local->hw_downloading)
+               return -ENODEV;
+
+       res = down_interruptible(&local->rid_bap_sem);
+       if (res)
+               return res;
+
+       res = hfa384x_cmd(dev, HFA384X_CMDCODE_ACCESS, rid, NULL, NULL);
+       if (res) {
+               printk(KERN_DEBUG "%s: hfa384x_get_rid: CMDCODE_ACCESS failed "
+                      "(res=%d, rid=%04x, len=%d)\n",
+                      dev->name, res, rid, len);
+               up(&local->rid_bap_sem);
+               return res;
+       }
+
+       spin_lock_bh(&local->baplock);
+
+       res = hfa384x_setup_bap(dev, BAP0, rid, 0);
+       if (!res)
+               res = hfa384x_from_bap(dev, BAP0, &rec, sizeof(rec));
+
+       if (le16_to_cpu(rec.len) == 0) {
+               /* RID not available */
+               res = -ENODATA;
+       }
+
+       rlen = (le16_to_cpu(rec.len) - 1) * 2;
+       if (!res && exact_len && rlen != len) {
+               printk(KERN_DEBUG "%s: hfa384x_get_rid - RID len mismatch: "
+                      "rid=0x%04x, len=%d (expected %d)\n",
+                      dev->name, rid, rlen, len);
+               res = -ENODATA;
+       }
+
+       if (!res)
+               res = hfa384x_from_bap(dev, BAP0, buf, len);
+
+       spin_unlock_bh(&local->baplock);
+       up(&local->rid_bap_sem);
+
+       if (res) {
+               if (res != -ENODATA)
+                       printk(KERN_DEBUG "%s: hfa384x_get_rid (rid=%04x, "
+                              "len=%d) - failed - res=%d\n", dev->name, rid,
+                              len, res);
+               if (res == -ETIMEDOUT)
+                       prism2_hw_reset(dev);
+               return res;
+       }
+
+       return rlen;
+}
+
+
+static int hfa384x_set_rid(struct net_device *dev, u16 rid, void *buf, int len)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       struct hfa384x_rid_hdr rec;
+       int res;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (local->no_pri) {
+               printk(KERN_DEBUG "%s: cannot set RID %04x (len=%d) - no PRI "
+                      "f/w\n", dev->name, rid, len);
+               return -ENOTTY; /* Well.. not really correct, but return
+                                * something unique enough.. */
+       }
+
+       if ((local->func->card_present && !local->func->card_present(local)) ||
+           local->hw_downloading)
+               return -ENODEV;
+
+       rec.rid = cpu_to_le16(rid);
+       /* RID len in words and +1 for rec.rid */
+       rec.len = cpu_to_le16(len / 2 + len % 2 + 1);
+
+       res = down_interruptible(&local->rid_bap_sem);
+       if (res)
+               return res;
+
+       spin_lock_bh(&local->baplock);
+       res = hfa384x_setup_bap(dev, BAP0, rid, 0);
+       if (!res)
+               res = hfa384x_to_bap(dev, BAP0, &rec, sizeof(rec));
+       if (!res)
+               res = hfa384x_to_bap(dev, BAP0, buf, len);
+       spin_unlock_bh(&local->baplock);
+
+       if (res) {
+               printk(KERN_DEBUG "%s: hfa384x_set_rid (rid=%04x, len=%d) - "
+                      "failed - res=%d\n", dev->name, rid, len, res);
+               up(&local->rid_bap_sem);
+               return res;
+       }
+
+       res = hfa384x_cmd(dev, HFA384X_CMDCODE_ACCESS_WRITE, rid, NULL, NULL);
+       up(&local->rid_bap_sem);
+       if (res) {
+               printk(KERN_DEBUG "%s: hfa384x_set_rid: CMDCODE_ACCESS_WRITE "
+                      "failed (res=%d, rid=%04x, len=%d)\n",
+                      dev->name, res, rid, len);
+               return res;
+       }
+
+       if (res == -ETIMEDOUT)
+               prism2_hw_reset(dev);
+
+       return res;
+}
+
+
+static void hfa384x_disable_interrupts(struct net_device *dev)
+{
+       /* disable interrupts and clear event status */
+       HFA384X_OUTW(0, HFA384X_INTEN_OFF);
+       HFA384X_OUTW(0xffff, HFA384X_EVACK_OFF);
+}
+
+
+static void hfa384x_enable_interrupts(struct net_device *dev)
+{
+       /* ack pending events and enable interrupts from selected events */
+       HFA384X_OUTW(0xffff, HFA384X_EVACK_OFF);
+       HFA384X_OUTW(HFA384X_EVENT_MASK, HFA384X_INTEN_OFF);
+}
+
+
+static void hfa384x_events_no_bap0(struct net_device *dev)
+{
+       HFA384X_OUTW(HFA384X_EVENT_MASK & ~HFA384X_BAP0_EVENTS,
+                    HFA384X_INTEN_OFF);
+}
+
+
+static void hfa384x_events_all(struct net_device *dev)
+{
+       HFA384X_OUTW(HFA384X_EVENT_MASK, HFA384X_INTEN_OFF);
+}
+
+
+static void hfa384x_events_only_cmd(struct net_device *dev)
+{
+       HFA384X_OUTW(HFA384X_EV_CMD, HFA384X_INTEN_OFF);
+}
+
+
+static u16 hfa384x_allocate_fid(struct net_device *dev, int len)
+{
+       u16 fid;
+       unsigned long delay;
+
+       /* FIX: this could be replace with hfa384x_cmd() if the Alloc event
+        * below would be handled like CmdCompl event (sleep here, wake up from
+        * interrupt handler */
+       if (hfa384x_cmd_wait(dev, HFA384X_CMDCODE_ALLOC, len)) {
+               printk(KERN_DEBUG "%s: cannot allocate fid, len=%d\n",
+                      dev->name, len);
+               return 0xffff;
+       }
+
+       delay = jiffies + HFA384X_ALLOC_COMPL_TIMEOUT;
+       while (!(HFA384X_INW(HFA384X_EVSTAT_OFF) & HFA384X_EV_ALLOC) &&
+              time_before(jiffies, delay))
+               yield();
+       if (!(HFA384X_INW(HFA384X_EVSTAT_OFF) & HFA384X_EV_ALLOC)) {
+               printk("%s: fid allocate, len=%d - timeout\n", dev->name, len);
+               return 0xffff;
+       }
+
+       fid = HFA384X_INW(HFA384X_ALLOCFID_OFF);
+       HFA384X_OUTW(HFA384X_EV_ALLOC, HFA384X_EVACK_OFF);
+
+       return fid;
+}
+
+
+static int prism2_reset_port(struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int res;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (!local->dev_enabled)
+               return 0;
+
+       res = hfa384x_cmd(dev, HFA384X_CMDCODE_DISABLE, 0,
+                         NULL, NULL);
+       if (res)
+               printk(KERN_DEBUG "%s: reset port failed to disable port\n",
+                      dev->name);
+       else {
+               res = hfa384x_cmd(dev, HFA384X_CMDCODE_ENABLE, 0,
+                                 NULL, NULL);
+               if (res)
+                       printk(KERN_DEBUG "%s: reset port failed to enable "
+                              "port\n", dev->name);
+       }
+
+       /* It looks like at least some STA firmware versions reset
+        * fragmentation threshold back to 2346 after enable command. Restore
+        * the configured value, if it differs from this default. */
+       if (local->fragm_threshold != 2346 &&
+           hostap_set_word(dev, HFA384X_RID_FRAGMENTATIONTHRESHOLD,
+                           local->fragm_threshold)) {
+               printk(KERN_DEBUG "%s: failed to restore fragmentation "
+                      "threshold (%d) after Port0 enable\n",
+                      dev->name, local->fragm_threshold);
+       }
+
+       return res;
+}
+
+
+static int prism2_get_version_info(struct net_device *dev, u16 rid,
+                                  const char *txt)
+{
+       struct hfa384x_comp_ident comp;
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (local->no_pri) {
+               /* PRI f/w not yet available - cannot read RIDs */
+               return -1;
+       }
+       if (hfa384x_get_rid(dev, rid, &comp, sizeof(comp), 1) < 0) {
+               printk(KERN_DEBUG "Could not get RID for component %s\n", txt);
+               return -1;
+       }
+
+       printk(KERN_INFO "%s: %s: id=0x%02x v%d.%d.%d\n", dev->name, txt,
+              __le16_to_cpu(comp.id), __le16_to_cpu(comp.major),
+              __le16_to_cpu(comp.minor), __le16_to_cpu(comp.variant));
+       return 0;
+}
+
+
+static int prism2_setup_rids(struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       u16 tmp;
+       int ret = 0;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       hostap_set_word(dev, HFA384X_RID_TICKTIME, 2000);
+
+       if (!local->fw_ap) {
+               tmp = hostap_get_porttype(local);
+               ret = hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE, tmp);
+               if (ret) {
+                       printk("%s: Port type setting to %d failed\n",
+                              dev->name, tmp);
+                       goto fail;
+               }
+       }
+
+       /* Setting SSID to empty string seems to kill the card in Host AP mode
+        */
+       if (local->iw_mode != IW_MODE_MASTER || local->essid[0] != '\0') {
+               ret = hostap_set_string(dev, HFA384X_RID_CNFOWNSSID,
+                                       local->essid);
+               if (ret) {
+                       printk("%s: AP own SSID setting failed\n", dev->name);
+                       goto fail;
+               }
+       }
+
+       ret = hostap_set_word(dev, HFA384X_RID_CNFMAXDATALEN,
+                             PRISM2_DATA_MAXLEN);
+       if (ret) {
+               printk("%s: MAC data length setting to %d failed\n",
+                      dev->name, PRISM2_DATA_MAXLEN);
+               goto fail;
+       }
+
+       if (hfa384x_get_rid(dev, HFA384X_RID_CHANNELLIST, &tmp, 2, 1) < 0) {
+               printk("%s: Channel list read failed\n", dev->name);
+               ret = -EINVAL;
+               goto fail;
+       }
+       local->channel_mask = __le16_to_cpu(tmp);
+
+       if (local->channel < 1 || local->channel > 14 ||
+           !(local->channel_mask & (1 << (local->channel - 1)))) {
+               printk(KERN_WARNING "%s: Channel setting out of range "
+                      "(%d)!\n", dev->name, local->channel);
+               ret = -EBUSY;
+               goto fail;
+       }
+
+       ret = hostap_set_word(dev, HFA384X_RID_CNFOWNCHANNEL, local->channel);
+       if (ret) {
+               printk("%s: Channel setting to %d failed\n",
+                      dev->name, local->channel);
+               goto fail;
+       }
+
+       ret = hostap_set_word(dev, HFA384X_RID_CNFBEACONINT,
+                             local->beacon_int);
+       if (ret) {
+               printk("%s: Beacon interval setting to %d failed\n",
+                      dev->name, local->beacon_int);
+               /* this may fail with Symbol/Lucent firmware */
+               if (ret == -ETIMEDOUT)
+                       goto fail;
+       }
+
+       ret = hostap_set_word(dev, HFA384X_RID_CNFOWNDTIMPERIOD,
+                             local->dtim_period);
+       if (ret) {
+               printk("%s: DTIM period setting to %d failed\n",
+                      dev->name, local->dtim_period);
+               /* this may fail with Symbol/Lucent firmware */
+               if (ret == -ETIMEDOUT)
+                       goto fail;
+       }
+
+       ret = hostap_set_word(dev, HFA384X_RID_PROMISCUOUSMODE,
+                             local->is_promisc);
+       if (ret)
+               printk(KERN_INFO "%s: Setting promiscuous mode (%d) failed\n",
+                      dev->name, local->is_promisc);
+
+       if (!local->fw_ap) {
+               ret = hostap_set_string(dev, HFA384X_RID_CNFDESIREDSSID,
+                                       local->essid);
+               if (ret) {
+                       printk("%s: Desired SSID setting failed\n", dev->name);
+                       goto fail;
+               }
+       }
+
+       /* Setup TXRateControl, defaults to allow use of 1, 2, 5.5, and
+        * 11 Mbps in automatic TX rate fallback and 1 and 2 Mbps as basic
+        * rates */
+       if (local->tx_rate_control == 0) {
+               local->tx_rate_control =
+                       HFA384X_RATES_1MBPS |
+                       HFA384X_RATES_2MBPS |
+                       HFA384X_RATES_5MBPS |
+                       HFA384X_RATES_11MBPS;
+       }
+       if (local->basic_rates == 0)
+               local->basic_rates = HFA384X_RATES_1MBPS | HFA384X_RATES_2MBPS;
+
+       if (!local->fw_ap) {
+               ret = hostap_set_word(dev, HFA384X_RID_TXRATECONTROL,
+                                     local->tx_rate_control);
+               if (ret) {
+                       printk("%s: TXRateControl setting to %d failed\n",
+                              dev->name, local->tx_rate_control);
+                       goto fail;
+               }
+
+               ret = hostap_set_word(dev, HFA384X_RID_CNFSUPPORTEDRATES,
+                                     local->tx_rate_control);
+               if (ret) {
+                       printk("%s: cnfSupportedRates setting to %d failed\n",
+                              dev->name, local->tx_rate_control);
+               }
+
+               ret = hostap_set_word(dev, HFA384X_RID_CNFBASICRATES,
+                                     local->basic_rates);
+               if (ret) {
+                       printk("%s: cnfBasicRates setting to %d failed\n",
+                              dev->name, local->basic_rates);
+               }
+
+               ret = hostap_set_word(dev, HFA384X_RID_CREATEIBSS, 1);
+               if (ret) {
+                       printk("%s: Create IBSS setting to 1 failed\n",
+                              dev->name);
+               }
+       }
+
+       if (local->name_set)
+               (void) hostap_set_string(dev, HFA384X_RID_CNFOWNNAME,
+                                        local->name);
+
+       if (hostap_set_encryption(local)) {
+               printk(KERN_INFO "%s: could not configure encryption\n",
+                      dev->name);
+       }
+
+       (void) hostap_set_antsel(local);
+
+       if (hostap_set_roaming(local)) {
+               printk(KERN_INFO "%s: could not set host roaming\n",
+                      dev->name);
+       }
+
+       if (local->sta_fw_ver >= PRISM2_FW_VER(1,6,3) &&
+           hostap_set_word(dev, HFA384X_RID_CNFENHSECURITY, local->enh_sec))
+               printk(KERN_INFO "%s: cnfEnhSecurity setting to 0x%x failed\n",
+                      dev->name, local->enh_sec);
+
+       /* 32-bit tallies were added in STA f/w 0.8.0, but they were apparently
+        * not working correctly (last seven counters report bogus values).
+        * This has been fixed in 0.8.2, so enable 32-bit tallies only
+        * beginning with that firmware version. Another bug fix for 32-bit
+        * tallies in 1.4.0; should 16-bit tallies be used for some other
+        * versions, too? */
+       if (local->sta_fw_ver >= PRISM2_FW_VER(0,8,2)) {
+               if (hostap_set_word(dev, HFA384X_RID_CNFTHIRTY2TALLY, 1)) {
+                       printk(KERN_INFO "%s: cnfThirty2Tally setting "
+                              "failed\n", dev->name);
+                       local->tallies32 = 0;
+               } else
+                       local->tallies32 = 1;
+       } else
+               local->tallies32 = 0;
+
+       hostap_set_auth_algs(local);
+
+       if (hostap_set_word(dev, HFA384X_RID_FRAGMENTATIONTHRESHOLD,
+                           local->fragm_threshold)) {
+               printk(KERN_INFO "%s: setting FragmentationThreshold to %d "
+                      "failed\n", dev->name, local->fragm_threshold);
+       }
+
+       if (hostap_set_word(dev, HFA384X_RID_RTSTHRESHOLD,
+                           local->rts_threshold)) {
+               printk(KERN_INFO "%s: setting RTSThreshold to %d failed\n",
+                      dev->name, local->rts_threshold);
+       }
+
+       if (local->manual_retry_count >= 0 &&
+           hostap_set_word(dev, HFA384X_RID_CNFALTRETRYCOUNT,
+                           local->manual_retry_count)) {
+               printk(KERN_INFO "%s: setting cnfAltRetryCount to %d failed\n",
+                      dev->name, local->manual_retry_count);
+       }
+
+       if (local->sta_fw_ver >= PRISM2_FW_VER(1,3,1) &&
+           hfa384x_get_rid(dev, HFA384X_RID_CNFDBMADJUST, &tmp, 2, 1) == 2) {
+               local->rssi_to_dBm = le16_to_cpu(tmp);
+       }
+
+       if (local->sta_fw_ver >= PRISM2_FW_VER(1,7,0) && local->wpa &&
+           hostap_set_word(dev, HFA384X_RID_SSNHANDLINGMODE, 1)) {
+               printk(KERN_INFO "%s: setting ssnHandlingMode to 1 failed\n",
+                      dev->name);
+       }
+
+       if (local->sta_fw_ver >= PRISM2_FW_VER(1,7,0) && local->generic_elem &&
+           hfa384x_set_rid(dev, HFA384X_RID_GENERICELEMENT,
+                           local->generic_elem, local->generic_elem_len)) {
+               printk(KERN_INFO "%s: setting genericElement failed\n",
+                      dev->name);
+       }
+
+ fail:
+       return ret;
+}
+
+
+static int prism2_hw_init(struct net_device *dev, int initial)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int ret, first = 1;
+       unsigned long start, delay;
+
+       PDEBUG(DEBUG_FLOW, "prism2_hw_init()\n");
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       clear_bit(HOSTAP_BITS_TRANSMIT, &local->bits);
+
+ init:
+       /* initialize HFA 384x */
+       ret = hfa384x_cmd_no_wait(dev, HFA384X_CMDCODE_INIT, 0);
+       if (ret) {
+               printk(KERN_INFO "%s: first command failed - assuming card "
+                      "does not have primary firmware\n", dev_info);
+       }
+
+       if (first && (HFA384X_INW(HFA384X_EVSTAT_OFF) & HFA384X_EV_CMD)) {
+               /* EvStat has Cmd bit set in some cases, so retry once if no
+                * wait was needed */
+               HFA384X_OUTW(HFA384X_EV_CMD, HFA384X_EVACK_OFF);
+               printk(KERN_DEBUG "%s: init command completed too quickly - "
+                      "retrying\n", dev->name);
+               first = 0;
+               goto init;
+       }
+
+       start = jiffies;
+       delay = jiffies + HFA384X_INIT_TIMEOUT;
+       while (!(HFA384X_INW(HFA384X_EVSTAT_OFF) & HFA384X_EV_CMD) &&
+              time_before(jiffies, delay))
+               yield();
+       if (!(HFA384X_INW(HFA384X_EVSTAT_OFF) & HFA384X_EV_CMD)) {
+               printk(KERN_DEBUG "%s: assuming no Primary image in "
+                      "flash - card initialization not completed\n",
+                      dev_info);
+               local->no_pri = 1;
+#ifdef PRISM2_DOWNLOAD_SUPPORT
+                       if (local->sram_type == -1)
+                               local->sram_type = prism2_get_ram_size(local);
+#endif /* PRISM2_DOWNLOAD_SUPPORT */
+               return 1;
+       }
+       local->no_pri = 0;
+       printk(KERN_DEBUG "prism2_hw_init: initialized in %lu ms\n",
+              (jiffies - start) * 1000 / HZ);
+       HFA384X_OUTW(HFA384X_EV_CMD, HFA384X_EVACK_OFF);
+       return 0;
+}
+
+
+static int prism2_hw_init2(struct net_device *dev, int initial)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int i;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+#ifdef PRISM2_DOWNLOAD_SUPPORT
+       kfree(local->pda);
+       if (local->no_pri)
+               local->pda = NULL;
+       else
+               local->pda = prism2_read_pda(dev);
+#endif /* PRISM2_DOWNLOAD_SUPPORT */
+
+       hfa384x_disable_interrupts(dev);
+
+#ifndef final_version
+       HFA384X_OUTW(HFA384X_MAGIC, HFA384X_SWSUPPORT0_OFF);
+       if (HFA384X_INW(HFA384X_SWSUPPORT0_OFF) != HFA384X_MAGIC) {
+               printk("SWSUPPORT0 write/read failed: %04X != %04X\n",
+                      HFA384X_INW(HFA384X_SWSUPPORT0_OFF), HFA384X_MAGIC);
+               goto failed;
+       }
+#endif
+
+       if (initial || local->pri_only) {
+               hfa384x_events_only_cmd(dev);
+               /* get card version information */
+               if (prism2_get_version_info(dev, HFA384X_RID_NICID, "NIC") ||
+                   prism2_get_version_info(dev, HFA384X_RID_PRIID, "PRI")) {
+                       hfa384x_disable_interrupts(dev);
+                       goto failed;
+               }
+
+               if (prism2_get_version_info(dev, HFA384X_RID_STAID, "STA")) {
+                       printk(KERN_DEBUG "%s: Failed to read STA f/w version "
+                              "- only Primary f/w present\n", dev->name);
+                       local->pri_only = 1;
+                       return 0;
+               }
+               local->pri_only = 0;
+               hfa384x_disable_interrupts(dev);
+       }
+
+       /* FIX: could convert allocate_fid to use sleeping CmdCompl wait and
+        * enable interrupts before this. This would also require some sort of
+        * sleeping AllocEv waiting */
+
+       /* allocate TX FIDs */
+       local->txfid_len = PRISM2_TXFID_LEN;
+       for (i = 0; i < PRISM2_TXFID_COUNT; i++) {
+               local->txfid[i] = hfa384x_allocate_fid(dev, local->txfid_len);
+               if (local->txfid[i] == 0xffff && local->txfid_len > 1600) {
+                       local->txfid[i] = hfa384x_allocate_fid(dev, 1600);
+                       if (local->txfid[i] != 0xffff) {
+                               printk(KERN_DEBUG "%s: Using shorter TX FID "
+                                      "(1600 bytes)\n", dev->name);
+                               local->txfid_len = 1600;
+                       }
+               }
+               if (local->txfid[i] == 0xffff)
+                       goto failed;
+               local->intransmitfid[i] = PRISM2_TXFID_EMPTY;
+       }
+
+       hfa384x_events_only_cmd(dev);
+
+       if (initial) {
+               struct list_head *ptr;
+               prism2_check_sta_fw_version(local);
+
+               if (hfa384x_get_rid(dev, HFA384X_RID_CNFOWNMACADDR,
+                                   &dev->dev_addr, 6, 1) < 0) {
+                       printk("%s: could not get own MAC address\n",
+                              dev->name);
+               }
+               list_for_each(ptr, &local->hostap_interfaces) {
+                       iface = list_entry(ptr, struct hostap_interface, list);
+                       memcpy(iface->dev->dev_addr, dev->dev_addr, ETH_ALEN);
+               }
+       } else if (local->fw_ap)
+               prism2_check_sta_fw_version(local);
+
+       prism2_setup_rids(dev);
+
+       /* MAC is now configured, but port 0 is not yet enabled */
+       return 0;
+
+ failed:
+       if (!local->no_pri)
+               printk(KERN_WARNING "%s: Initialization failed\n", dev_info);
+       return 1;
+}
+
+
+static int prism2_hw_enable(struct net_device *dev, int initial)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int was_resetting;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+       was_resetting = local->hw_resetting;
+
+       if (hfa384x_cmd(dev, HFA384X_CMDCODE_ENABLE, 0, NULL, NULL)) {
+               printk("%s: MAC port 0 enabling failed\n", dev->name);
+               return 1;
+       }
+
+       local->hw_ready = 1;
+       local->hw_reset_tries = 0;
+       local->hw_resetting = 0;
+       hfa384x_enable_interrupts(dev);
+
+       /* at least D-Link DWL-650 seems to require additional port reset
+        * before it starts acting as an AP, so reset port automatically
+        * here just in case */
+       if (initial && prism2_reset_port(dev)) {
+               printk("%s: MAC port 0 reseting failed\n", dev->name);
+               return 1;
+       }
+
+       if (was_resetting && netif_queue_stopped(dev)) {
+               /* If hw_reset() was called during pending transmit, netif
+                * queue was stopped. Wake it up now since the wlan card has
+                * been resetted. */
+               netif_wake_queue(dev);
+       }
+
+       return 0;
+}
+
+
+static int prism2_hw_config(struct net_device *dev, int initial)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (local->hw_downloading)
+               return 1;
+
+       if (prism2_hw_init(dev, initial)) {
+               return local->no_pri ? 0 : 1;
+       }
+
+       if (prism2_hw_init2(dev, initial))
+               return 1;
+
+       /* Enable firmware if secondary image is loaded and at least one of the
+        * netdevices is up. */
+       if (!local->pri_only &&
+           (initial == 0 || (initial == 2 && local->num_dev_open > 0))) {
+               if (!local->dev_enabled)
+                       prism2_callback(local, PRISM2_CALLBACK_ENABLE);
+               local->dev_enabled = 1;
+               return prism2_hw_enable(dev, initial);
+       }
+
+       return 0;
+}
+
+
+static void prism2_hw_shutdown(struct net_device *dev, int no_disable)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       /* Allow only command completion events during disable */
+       hfa384x_events_only_cmd(dev);
+
+       local->hw_ready = 0;
+       if (local->dev_enabled)
+               prism2_callback(local, PRISM2_CALLBACK_DISABLE);
+       local->dev_enabled = 0;
+
+       if (local->func->card_present && !local->func->card_present(local)) {
+               printk(KERN_DEBUG "%s: card already removed or not configured "
+                      "during shutdown\n", dev->name);
+               return;
+       }
+
+       if ((no_disable & HOSTAP_HW_NO_DISABLE) == 0 &&
+           hfa384x_cmd(dev, HFA384X_CMDCODE_DISABLE, 0, NULL, NULL))
+               printk(KERN_WARNING "%s: Shutdown failed\n", dev_info);
+
+       hfa384x_disable_interrupts(dev);
+
+       if (no_disable & HOSTAP_HW_ENABLE_CMDCOMPL)
+               hfa384x_events_only_cmd(dev);
+       else
+               prism2_clear_cmd_queue(local);
+}
+
+
+static void prism2_hw_reset(struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+#if 0
+       static long last_reset = 0;
+
+       /* do not reset card more than once per second to avoid ending up in a
+        * busy loop reseting the card */
+       if (time_before_eq(jiffies, last_reset + HZ))
+               return;
+       last_reset = jiffies;
+#endif
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (in_interrupt()) {
+               printk(KERN_DEBUG "%s: driver bug - prism2_hw_reset() called "
+                      "in interrupt context\n", dev->name);
+               return;
+       }
+
+       if (local->hw_downloading)
+               return;
+
+       if (local->hw_resetting) {
+               printk(KERN_WARNING "%s: %s: already resetting card - "
+                      "ignoring reset request\n", dev_info, dev->name);
+               return;
+       }
+
+       local->hw_reset_tries++;
+       if (local->hw_reset_tries > 10) {
+               printk(KERN_WARNING "%s: too many reset tries, skipping\n",
+                      dev->name);
+               return;
+       }
+
+       printk(KERN_WARNING "%s: %s: resetting card\n", dev_info, dev->name);
+       hfa384x_disable_interrupts(dev);
+       local->hw_resetting = 1;
+       if (local->func->cor_sreset) {
+               /* Host system seems to hang in some cases with high traffic
+                * load or shared interrupts during COR sreset. Disable shared
+                * interrupts during reset to avoid these crashes. COS sreset
+                * takes quite a long time, so it is unfortunate that this
+                * seems to be needed. Anyway, I do not know of any better way
+                * of avoiding the crash. */
+               disable_irq(dev->irq);
+               local->func->cor_sreset(local);
+               enable_irq(dev->irq);
+       }
+       prism2_hw_shutdown(dev, 1);
+       prism2_hw_config(dev, 0);
+       local->hw_resetting = 0;
+
+#ifdef PRISM2_DOWNLOAD_SUPPORT
+       if (local->dl_pri) {
+               printk(KERN_DEBUG "%s: persistent download of primary "
+                      "firmware\n", dev->name);
+               if (prism2_download_genesis(local, local->dl_pri) < 0)
+                       printk(KERN_WARNING "%s: download (PRI) failed\n",
+                              dev->name);
+       }
+
+       if (local->dl_sec) {
+               printk(KERN_DEBUG "%s: persistent download of secondary "
+                      "firmware\n", dev->name);
+               if (prism2_download_volatile(local, local->dl_sec) < 0)
+                       printk(KERN_WARNING "%s: download (SEC) failed\n",
+                              dev->name);
+       }
+#endif /* PRISM2_DOWNLOAD_SUPPORT */
+
+       /* TODO: restore beacon TIM bits for STAs that have buffered frames */
+}
+
+
+static void prism2_schedule_reset(local_info_t *local)
+{
+       schedule_work(&local->reset_queue);
+}
+
+
+/* Called only as scheduled task after noticing card timeout in interrupt
+ * context */
+static void handle_reset_queue(void *data)
+{
+       local_info_t *local = (local_info_t *) data;
+
+       printk(KERN_DEBUG "%s: scheduled card reset\n", local->dev->name);
+       prism2_hw_reset(local->dev);
+
+       if (netif_queue_stopped(local->dev)) {
+               int i;
+
+               for (i = 0; i < PRISM2_TXFID_COUNT; i++)
+                       if (local->intransmitfid[i] == PRISM2_TXFID_EMPTY) {
+                               PDEBUG(DEBUG_EXTRA, "prism2_tx_timeout: "
+                                      "wake up queue\n");
+                               netif_wake_queue(local->dev);
+                               break;
+                       }
+       }
+}
+
+
+static int prism2_get_txfid_idx(local_info_t *local)
+{
+       int idx, end;
+       unsigned long flags;
+
+       spin_lock_irqsave(&local->txfidlock, flags);
+       end = idx = local->next_txfid;
+       do {
+               if (local->intransmitfid[idx] == PRISM2_TXFID_EMPTY) {
+                       local->intransmitfid[idx] = PRISM2_TXFID_RESERVED;
+                       spin_unlock_irqrestore(&local->txfidlock, flags);
+                       return idx;
+               }
+               idx++;
+               if (idx >= PRISM2_TXFID_COUNT)
+                       idx = 0;
+       } while (idx != end);
+       spin_unlock_irqrestore(&local->txfidlock, flags);
+
+       PDEBUG(DEBUG_EXTRA2, "prism2_get_txfid_idx: no room in txfid buf: "
+              "packet dropped\n");
+       local->stats.tx_dropped++;
+
+       return -1;
+}
+
+
+/* Called only from hardware IRQ */
+static void prism2_transmit_cb(struct net_device *dev, long context,
+                              u16 resp0, u16 res)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int idx = (int) context;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (res) {
+               printk(KERN_DEBUG "%s: prism2_transmit_cb - res=0x%02x\n",
+                      dev->name, res);
+               return;
+       }
+
+       if (idx < 0 || idx >= PRISM2_TXFID_COUNT) {
+               printk(KERN_DEBUG "%s: prism2_transmit_cb called with invalid "
+                      "idx=%d\n", dev->name, idx);
+               return;
+       }
+
+       if (!test_and_clear_bit(HOSTAP_BITS_TRANSMIT, &local->bits)) {
+               printk(KERN_DEBUG "%s: driver bug: prism2_transmit_cb called "
+                      "with no pending transmit\n", dev->name);
+       }
+
+       if (netif_queue_stopped(dev)) {
+               /* ready for next TX, so wake up queue that was stopped in
+                * prism2_transmit() */
+               netif_wake_queue(dev);
+       }
+
+       spin_lock(&local->txfidlock);
+
+       /* With reclaim, Resp0 contains new txfid for transmit; the old txfid
+        * will be automatically allocated for the next TX frame */
+       local->intransmitfid[idx] = resp0;
+
+       PDEBUG(DEBUG_FID, "%s: prism2_transmit_cb: txfid[%d]=0x%04x, "
+              "resp0=0x%04x, transmit_txfid=0x%04x\n",
+              dev->name, idx, local->txfid[idx],
+              resp0, local->intransmitfid[local->next_txfid]);
+
+       idx++;
+       if (idx >= PRISM2_TXFID_COUNT)
+               idx = 0;
+       local->next_txfid = idx;
+
+       /* check if all TX buffers are occupied */
+       do {
+               if (local->intransmitfid[idx] == PRISM2_TXFID_EMPTY) {
+                       spin_unlock(&local->txfidlock);
+                       return;
+               }
+               idx++;
+               if (idx >= PRISM2_TXFID_COUNT)
+                       idx = 0;
+       } while (idx != local->next_txfid);
+       spin_unlock(&local->txfidlock);
+
+       /* no empty TX buffers, stop queue */
+       netif_stop_queue(dev);
+}
+
+
+/* Called only from software IRQ if PCI bus master is not used (with bus master
+ * this can be called both from software and hardware IRQ) */
+static int prism2_transmit(struct net_device *dev, int idx)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int res;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       /* The driver tries to stop netif queue so that there would not be
+        * more than one attempt to transmit frames going on; check that this
+        * is really the case */
+
+       if (test_and_set_bit(HOSTAP_BITS_TRANSMIT, &local->bits)) {
+               printk(KERN_DEBUG "%s: driver bug - prism2_transmit() called "
+                      "when previous TX was pending\n", dev->name);
+               return -1;
+       }
+
+       /* stop the queue for the time that transmit is pending */
+       netif_stop_queue(dev);
+
+       /* transmit packet */
+       res = hfa384x_cmd_callback(
+               dev,
+               HFA384X_CMDCODE_TRANSMIT | HFA384X_CMD_TX_RECLAIM,
+               local->txfid[idx],
+               prism2_transmit_cb, (long) idx);
+
+       if (res) {
+               struct net_device_stats *stats;
+               printk(KERN_DEBUG "%s: prism2_transmit: CMDCODE_TRANSMIT "
+                      "failed (res=%d)\n", dev->name, res);
+               stats = hostap_get_stats(dev);
+               stats->tx_dropped++;
+               netif_wake_queue(dev);
+               return -1;
+       }
+       dev->trans_start = jiffies;
+
+       /* Since we did not wait for command completion, the card continues
+        * to process on the background and we will finish handling when
+        * command completion event is handled (prism2_cmd_ev() function) */
+
+       return 0;
+}
+
+
+/* Send IEEE 802.11 frame (convert the header into Prism2 TX descriptor and
+ * send the payload with this descriptor) */
+/* Called only from software IRQ */
+static int prism2_tx_80211(struct sk_buff *skb, struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       struct hfa384x_tx_frame txdesc;
+       struct hostap_skb_tx_data *meta;
+       int hdr_len, data_len, idx, res, ret = -1;
+       u16 tx_control, fc;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       meta = (struct hostap_skb_tx_data *) skb->cb;
+
+       prism2_callback(local, PRISM2_CALLBACK_TX_START);
+
+       if ((local->func->card_present && !local->func->card_present(local)) ||
+           !local->hw_ready || local->hw_downloading || local->pri_only) {
+               if (net_ratelimit()) {
+                       printk(KERN_DEBUG "%s: prism2_tx_80211: hw not ready -"
+                              " skipping\n", dev->name);
+               }
+               goto fail;
+       }
+
+       memset(&txdesc, 0, sizeof(txdesc));
+
+       /* skb->data starts with txdesc->frame_control */
+       hdr_len = 24;
+       memcpy(&txdesc.frame_control, skb->data, hdr_len);
+       fc = le16_to_cpu(txdesc.frame_control);
+       if (WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA &&
+           (fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS) &&
+           skb->len >= 30) {
+               /* Addr4 */
+               memcpy(txdesc.addr4, skb->data + hdr_len, ETH_ALEN);
+               hdr_len += ETH_ALEN;
+       }
+
+       tx_control = local->tx_control;
+       if (meta->tx_cb_idx) {
+               tx_control |= HFA384X_TX_CTRL_TX_OK;
+               txdesc.sw_support = cpu_to_le16(meta->tx_cb_idx);
+       }
+       txdesc.tx_control = cpu_to_le16(tx_control);
+       txdesc.tx_rate = meta->rate;
+
+       data_len = skb->len - hdr_len;
+       txdesc.data_len = cpu_to_le16(data_len);
+       txdesc.len = cpu_to_be16(data_len);
+
+       idx = prism2_get_txfid_idx(local);
+       if (idx < 0)
+               goto fail;
+
+       if (local->frame_dump & PRISM2_DUMP_TX_HDR)
+               hostap_dump_tx_header(dev->name, &txdesc);
+
+       spin_lock(&local->baplock);
+       res = hfa384x_setup_bap(dev, BAP0, local->txfid[idx], 0);
+
+       if (!res)
+               res = hfa384x_to_bap(dev, BAP0, &txdesc, sizeof(txdesc));
+       if (!res)
+               res = hfa384x_to_bap(dev, BAP0, skb->data + hdr_len,
+                                    skb->len - hdr_len);
+       spin_unlock(&local->baplock);
+
+       if (!res)
+               res = prism2_transmit(dev, idx);
+       if (res) {
+               printk(KERN_DEBUG "%s: prism2_tx_80211 - to BAP0 failed\n",
+                      dev->name);
+               local->intransmitfid[idx] = PRISM2_TXFID_EMPTY;
+               schedule_work(&local->reset_queue);
+               goto fail;
+       }
+
+       ret = 0;
+
+fail:
+       prism2_callback(local, PRISM2_CALLBACK_TX_END);
+       return ret;
+}
+
+
+/* Some SMP systems have reported number of odd errors with hostap_pci. fid
+ * register has changed values between consecutive reads for an unknown reason.
+ * This should really not happen, so more debugging is needed. This test
+ * version is a big slower, but it will detect most of such register changes
+ * and will try to get the correct fid eventually. */
+#define EXTRA_FID_READ_TESTS
+
+static inline u16 prism2_read_fid_reg(struct net_device *dev, u16 reg)
+{
+#ifdef EXTRA_FID_READ_TESTS
+       u16 val, val2, val3;
+       int i;
+
+       for (i = 0; i < 10; i++) {
+               val = HFA384X_INW(reg);
+               val2 = HFA384X_INW(reg);
+               val3 = HFA384X_INW(reg);
+
+               if (val == val2 && val == val3)
+                       return val;
+
+               printk(KERN_DEBUG "%s: detected fid change (try=%d, reg=%04x):"
+                      " %04x %04x %04x\n",
+                      dev->name, i, reg, val, val2, val3);
+               if ((val == val2 || val == val3) && val != 0)
+                       return val;
+               if (val2 == val3 && val2 != 0)
+                       return val2;
+       }
+       printk(KERN_WARNING "%s: Uhhuh.. could not read good fid from reg "
+              "%04x (%04x %04x %04x)\n", dev->name, reg, val, val2, val3);
+       return val;
+#else /* EXTRA_FID_READ_TESTS */
+       return HFA384X_INW(reg);
+#endif /* EXTRA_FID_READ_TESTS */
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static void prism2_rx(local_info_t *local)
+{
+       struct net_device *dev = local->dev;
+       int res, rx_pending = 0;
+       u16 len, hdr_len, rxfid, status, macport;
+       struct net_device_stats *stats;
+       struct hfa384x_rx_frame rxdesc;
+       struct sk_buff *skb = NULL;
+
+       prism2_callback(local, PRISM2_CALLBACK_RX_START);
+       stats = hostap_get_stats(dev);
+
+       rxfid = prism2_read_fid_reg(dev, HFA384X_RXFID_OFF);
+#ifndef final_version
+       if (rxfid == 0) {
+               rxfid = HFA384X_INW(HFA384X_RXFID_OFF);
+               printk(KERN_DEBUG "prism2_rx: rxfid=0 (next 0x%04x)\n",
+                      rxfid);
+               if (rxfid == 0) {
+                       schedule_work(&local->reset_queue);
+                       goto rx_dropped;
+               }
+               /* try to continue with the new rxfid value */
+       }
+#endif
+
+       spin_lock(&local->baplock);
+       res = hfa384x_setup_bap(dev, BAP0, rxfid, 0);
+       if (!res)
+               res = hfa384x_from_bap(dev, BAP0, &rxdesc, sizeof(rxdesc));
+
+       if (res) {
+               spin_unlock(&local->baplock);
+               printk(KERN_DEBUG "%s: copy from BAP0 failed %d\n", dev->name,
+                      res);
+               if (res == -ETIMEDOUT) {
+                       schedule_work(&local->reset_queue);
+               }
+               goto rx_dropped;
+       }
+
+       len = le16_to_cpu(rxdesc.data_len);
+       hdr_len = sizeof(rxdesc);
+       status = le16_to_cpu(rxdesc.status);
+       macport = (status >> 8) & 0x07;
+
+       /* Drop frames with too large reported payload length. Monitor mode
+        * seems to sometimes pass frames (e.g., ctrl::ack) with signed and
+        * negative value, so allow also values 65522 .. 65534 (-14 .. -2) for
+        * macport 7 */
+       if (len > PRISM2_DATA_MAXLEN + 8 /* WEP */) {
+               if (macport == 7 && local->iw_mode == IW_MODE_MONITOR) {
+                       if (len >= (u16) -14) {
+                               hdr_len -= 65535 - len;
+                               hdr_len--;
+                       }
+                       len = 0;
+               } else {
+                       spin_unlock(&local->baplock);
+                       printk(KERN_DEBUG "%s: Received frame with invalid "
+                              "length 0x%04x\n", dev->name, len);
+                       hostap_dump_rx_header(dev->name, &rxdesc);
+                       goto rx_dropped;
+               }
+       }
+
+       skb = dev_alloc_skb(len + hdr_len);
+       if (!skb) {
+               spin_unlock(&local->baplock);
+               printk(KERN_DEBUG "%s: RX failed to allocate skb\n",
+                      dev->name);
+               goto rx_dropped;
+       }
+       skb->dev = dev;
+       memcpy(skb_put(skb, hdr_len), &rxdesc, hdr_len);
+
+       if (len > 0)
+               res = hfa384x_from_bap(dev, BAP0, skb_put(skb, len), len);
+       spin_unlock(&local->baplock);
+       if (res) {
+               printk(KERN_DEBUG "%s: RX failed to read "
+                      "frame data\n", dev->name);
+               goto rx_dropped;
+       }
+
+       skb_queue_tail(&local->rx_list, skb);
+       tasklet_schedule(&local->rx_tasklet);
+
+ rx_exit:
+       prism2_callback(local, PRISM2_CALLBACK_RX_END);
+       if (!rx_pending) {
+               HFA384X_OUTW(HFA384X_EV_RX, HFA384X_EVACK_OFF);
+       }
+
+       return;
+
+ rx_dropped:
+       stats->rx_dropped++;
+       if (skb)
+               dev_kfree_skb(skb);
+       goto rx_exit;
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static void hostap_rx_skb(local_info_t *local, struct sk_buff *skb)
+{
+       struct hfa384x_rx_frame *rxdesc;
+       struct net_device *dev = skb->dev;
+       struct hostap_80211_rx_status stats;
+       int hdrlen, rx_hdrlen;
+
+       rx_hdrlen = sizeof(*rxdesc);
+       if (skb->len < sizeof(*rxdesc)) {
+               /* Allow monitor mode to receive shorter frames */
+               if (local->iw_mode == IW_MODE_MONITOR &&
+                   skb->len >= sizeof(*rxdesc) - 30) {
+                       rx_hdrlen = skb->len;
+               } else {
+                       dev_kfree_skb(skb);
+                       return;
+               }
+       }
+
+       rxdesc = (struct hfa384x_rx_frame *) skb->data;
+
+       if (local->frame_dump & PRISM2_DUMP_RX_HDR &&
+           skb->len >= sizeof(*rxdesc))
+               hostap_dump_rx_header(dev->name, rxdesc);
+
+       if (le16_to_cpu(rxdesc->status) & HFA384X_RX_STATUS_FCSERR &&
+           (!local->monitor_allow_fcserr ||
+            local->iw_mode != IW_MODE_MONITOR))
+               goto drop;
+
+       if (skb->len > PRISM2_DATA_MAXLEN) {
+               printk(KERN_DEBUG "%s: RX: len(%d) > MAX(%d)\n",
+                      dev->name, skb->len, PRISM2_DATA_MAXLEN);
+               goto drop;
+       }
+
+       stats.mac_time = le32_to_cpu(rxdesc->time);
+       stats.signal = rxdesc->signal - local->rssi_to_dBm;
+       stats.noise = rxdesc->silence - local->rssi_to_dBm;
+       stats.rate = rxdesc->rate;
+
+       /* Convert Prism2 RX structure into IEEE 802.11 header */
+       hdrlen = hostap_80211_get_hdrlen(le16_to_cpu(rxdesc->frame_control));
+       if (hdrlen > rx_hdrlen)
+               hdrlen = rx_hdrlen;
+
+       memmove(skb_pull(skb, rx_hdrlen - hdrlen),
+               &rxdesc->frame_control, hdrlen);
+
+       hostap_80211_rx(dev, skb, &stats);
+       return;
+
+ drop:
+       dev_kfree_skb(skb);
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static void hostap_rx_tasklet(unsigned long data)
+{
+       local_info_t *local = (local_info_t *) data;
+       struct sk_buff *skb;
+
+       while ((skb = skb_dequeue(&local->rx_list)) != NULL)
+               hostap_rx_skb(local, skb);
+}
+
+
+/* Called only from hardware IRQ */
+static void prism2_alloc_ev(struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int idx;
+       u16 fid;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       fid = prism2_read_fid_reg(dev, HFA384X_ALLOCFID_OFF);
+
+       PDEBUG(DEBUG_FID, "FID: interrupt: ALLOC - fid=0x%04x\n", fid);
+
+       spin_lock(&local->txfidlock);
+       idx = local->next_alloc;
+
+       do {
+               if (local->txfid[idx] == fid) {
+                       PDEBUG(DEBUG_FID, "FID: found matching txfid[%d]\n",
+                              idx);
+
+#ifndef final_version
+                       if (local->intransmitfid[idx] == PRISM2_TXFID_EMPTY)
+                               printk("Already released txfid found at idx "
+                                      "%d\n", idx);
+                       if (local->intransmitfid[idx] == PRISM2_TXFID_RESERVED)
+                               printk("Already reserved txfid found at idx "
+                                      "%d\n", idx);
+#endif
+                       local->intransmitfid[idx] = PRISM2_TXFID_EMPTY;
+                       idx++;
+                       local->next_alloc = idx >= PRISM2_TXFID_COUNT ? 0 :
+                               idx;
+
+                       if (!test_bit(HOSTAP_BITS_TRANSMIT, &local->bits) &&
+                           netif_queue_stopped(dev))
+                               netif_wake_queue(dev);
+
+                       spin_unlock(&local->txfidlock);
+                       return;
+               }
+
+               idx++;
+               if (idx >= PRISM2_TXFID_COUNT)
+                       idx = 0;
+       } while (idx != local->next_alloc);
+
+       printk(KERN_WARNING "%s: could not find matching txfid (0x%04x, new "
+              "read 0x%04x) for alloc event\n", dev->name, fid,
+              HFA384X_INW(HFA384X_ALLOCFID_OFF));
+       printk(KERN_DEBUG "TXFIDs:");
+       for (idx = 0; idx < PRISM2_TXFID_COUNT; idx++)
+               printk(" %04x[%04x]", local->txfid[idx],
+                      local->intransmitfid[idx]);
+       printk("\n");
+       spin_unlock(&local->txfidlock);
+
+       /* FIX: should probably schedule reset; reference to one txfid was lost
+        * completely.. Bad things will happen if we run out of txfids
+        * Actually, this will cause netdev watchdog to notice TX timeout and
+        * then card reset after all txfids have been leaked. */
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static void hostap_tx_callback(local_info_t *local,
+                              struct hfa384x_tx_frame *txdesc, int ok,
+                              char *payload)
+{
+       u16 sw_support, hdrlen, len;
+       struct sk_buff *skb;
+       struct hostap_tx_callback_info *cb;
+
+       /* Make sure that frame was from us. */
+       if (memcmp(txdesc->addr2, local->dev->dev_addr, ETH_ALEN)) {
+               printk(KERN_DEBUG "%s: TX callback - foreign frame\n",
+                      local->dev->name);
+               return;
+       }
+
+       sw_support = le16_to_cpu(txdesc->sw_support);
+
+       spin_lock(&local->lock);
+       cb = local->tx_callback;
+       while (cb != NULL && cb->idx != sw_support)
+               cb = cb->next;
+       spin_unlock(&local->lock);
+
+       if (cb == NULL) {
+               printk(KERN_DEBUG "%s: could not find TX callback (idx %d)\n",
+                      local->dev->name, sw_support);
+               return;
+       }
+
+       hdrlen = hostap_80211_get_hdrlen(le16_to_cpu(txdesc->frame_control));
+       len = le16_to_cpu(txdesc->data_len);
+       skb = dev_alloc_skb(hdrlen + len);
+       if (skb == NULL) {
+               printk(KERN_DEBUG "%s: hostap_tx_callback failed to allocate "
+                      "skb\n", local->dev->name);
+               return;
+       }
+
+       memcpy(skb_put(skb, hdrlen), (void *) &txdesc->frame_control, hdrlen);
+       if (payload)
+               memcpy(skb_put(skb, len), payload, len);
+
+       skb->dev = local->dev;
+       skb->mac.raw = skb->data;
+
+       cb->func(skb, ok, cb->data);
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static int hostap_tx_compl_read(local_info_t *local, int error,
+                               struct hfa384x_tx_frame *txdesc,
+                               char **payload)
+{
+       u16 fid, len;
+       int res, ret = 0;
+       struct net_device *dev = local->dev;
+
+       fid = prism2_read_fid_reg(dev, HFA384X_TXCOMPLFID_OFF);
+
+       PDEBUG(DEBUG_FID, "interrupt: TX (err=%d) - fid=0x%04x\n", fid, error);
+
+       spin_lock(&local->baplock);
+       res = hfa384x_setup_bap(dev, BAP0, fid, 0);
+       if (!res)
+               res = hfa384x_from_bap(dev, BAP0, txdesc, sizeof(*txdesc));
+       if (res) {
+               PDEBUG(DEBUG_EXTRA, "%s: TX (err=%d) - fid=0x%04x - could not "
+                      "read txdesc\n", dev->name, error, fid);
+               if (res == -ETIMEDOUT) {
+                       schedule_work(&local->reset_queue);
+               }
+               ret = -1;
+               goto fail;
+       }
+       if (txdesc->sw_support) {
+               len = le16_to_cpu(txdesc->data_len);
+               if (len < PRISM2_DATA_MAXLEN) {
+                       *payload = (char *) kmalloc(len, GFP_ATOMIC);
+                       if (*payload == NULL ||
+                           hfa384x_from_bap(dev, BAP0, *payload, len)) {
+                               PDEBUG(DEBUG_EXTRA, "%s: could not read TX "
+                                      "frame payload\n", dev->name);
+                               kfree(*payload);
+                               *payload = NULL;
+                               ret = -1;
+                               goto fail;
+                       }
+               }
+       }
+
+ fail:
+       spin_unlock(&local->baplock);
+
+       return ret;
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static void prism2_tx_ev(local_info_t *local)
+{
+       struct net_device *dev = local->dev;
+       char *payload = NULL;
+       struct hfa384x_tx_frame txdesc;
+
+       if (hostap_tx_compl_read(local, 0, &txdesc, &payload))
+               goto fail;
+
+       if (local->frame_dump & PRISM2_DUMP_TX_HDR) {
+               PDEBUG(DEBUG_EXTRA, "%s: TX - status=0x%04x "
+                      "retry_count=%d tx_rate=%d seq_ctrl=%d "
+                      "duration_id=%d\n",
+                      dev->name, le16_to_cpu(txdesc.status),
+                      txdesc.retry_count, txdesc.tx_rate,
+                      le16_to_cpu(txdesc.seq_ctrl),
+                      le16_to_cpu(txdesc.duration_id));
+       }
+
+       if (txdesc.sw_support)
+               hostap_tx_callback(local, &txdesc, 1, payload);
+       kfree(payload);
+
+ fail:
+       HFA384X_OUTW(HFA384X_EV_TX, HFA384X_EVACK_OFF);
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static void hostap_sta_tx_exc_tasklet(unsigned long data)
+{
+       local_info_t *local = (local_info_t *) data;
+       struct sk_buff *skb;
+
+       while ((skb = skb_dequeue(&local->sta_tx_exc_list)) != NULL) {
+               struct hfa384x_tx_frame *txdesc =
+                       (struct hfa384x_tx_frame *) skb->data;
+
+               if (skb->len >= sizeof(*txdesc)) {
+                       /* Convert Prism2 RX structure into IEEE 802.11 header
+                        */
+                       u16 fc = le16_to_cpu(txdesc->frame_control);
+                       int hdrlen = hostap_80211_get_hdrlen(fc);
+                       memmove(skb_pull(skb, sizeof(*txdesc) - hdrlen),
+                               &txdesc->frame_control, hdrlen);
+
+                       hostap_handle_sta_tx_exc(local, skb);
+               }
+               dev_kfree_skb(skb);
+       }
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static void prism2_txexc(local_info_t *local)
+{
+       struct net_device *dev = local->dev;
+       u16 status, fc;
+       int show_dump, res;
+       char *payload = NULL;
+       struct hfa384x_tx_frame txdesc;
+
+       show_dump = local->frame_dump & PRISM2_DUMP_TXEXC_HDR;
+       local->stats.tx_errors++;
+
+       res = hostap_tx_compl_read(local, 1, &txdesc, &payload);
+       HFA384X_OUTW(HFA384X_EV_TXEXC, HFA384X_EVACK_OFF);
+       if (res)
+               return;
+
+       status = le16_to_cpu(txdesc.status);
+
+       /* We produce a TXDROP event only for retry or lifetime
+        * exceeded, because that's the only status that really mean
+        * that this particular node went away.
+        * Other errors means that *we* screwed up. - Jean II */
+       if (status & (HFA384X_TX_STATUS_RETRYERR | HFA384X_TX_STATUS_AGEDERR))
+       {
+               union iwreq_data wrqu;
+
+               /* Copy 802.11 dest address. */
+               memcpy(wrqu.addr.sa_data, txdesc.addr1, ETH_ALEN);
+               wrqu.addr.sa_family = ARPHRD_ETHER;
+               wireless_send_event(dev, IWEVTXDROP, &wrqu, NULL);
+       } else
+               show_dump = 1;
+
+       if (local->iw_mode == IW_MODE_MASTER ||
+           local->iw_mode == IW_MODE_REPEAT ||
+           local->wds_type & HOSTAP_WDS_AP_CLIENT) {
+               struct sk_buff *skb;
+               skb = dev_alloc_skb(sizeof(txdesc));
+               if (skb) {
+                       memcpy(skb_put(skb, sizeof(txdesc)), &txdesc,
+                              sizeof(txdesc));
+                       skb_queue_tail(&local->sta_tx_exc_list, skb);
+                       tasklet_schedule(&local->sta_tx_exc_tasklet);
+               }
+       }
+
+       if (txdesc.sw_support)
+               hostap_tx_callback(local, &txdesc, 0, payload);
+       kfree(payload);
+
+       if (!show_dump)
+               return;
+
+       PDEBUG(DEBUG_EXTRA, "%s: TXEXC - status=0x%04x (%s%s%s%s)"
+              " tx_control=%04x\n",
+              dev->name, status,
+              status & HFA384X_TX_STATUS_RETRYERR ? "[RetryErr]" : "",
+              status & HFA384X_TX_STATUS_AGEDERR ? "[AgedErr]" : "",
+              status & HFA384X_TX_STATUS_DISCON ? "[Discon]" : "",
+              status & HFA384X_TX_STATUS_FORMERR ? "[FormErr]" : "",
+              le16_to_cpu(txdesc.tx_control));
+
+       fc = le16_to_cpu(txdesc.frame_control);
+       PDEBUG(DEBUG_EXTRA, "   retry_count=%d tx_rate=%d fc=0x%04x "
+              "(%s%s%s::%d%s%s)\n",
+              txdesc.retry_count, txdesc.tx_rate, fc,
+              WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_MGMT ? "Mgmt" : "",
+              WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_CTL ? "Ctrl" : "",
+              WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA ? "Data" : "",
+              WLAN_FC_GET_STYPE(fc) >> 4,
+              fc & IEEE80211_FCTL_TODS ? " ToDS" : "",
+              fc & IEEE80211_FCTL_FROMDS ? " FromDS" : "");
+       PDEBUG(DEBUG_EXTRA, "   A1=" MACSTR " A2=" MACSTR " A3="
+              MACSTR " A4=" MACSTR "\n",
+              MAC2STR(txdesc.addr1), MAC2STR(txdesc.addr2),
+              MAC2STR(txdesc.addr3), MAC2STR(txdesc.addr4));
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static void hostap_info_tasklet(unsigned long data)
+{
+       local_info_t *local = (local_info_t *) data;
+       struct sk_buff *skb;
+
+       while ((skb = skb_dequeue(&local->info_list)) != NULL) {
+               hostap_info_process(local, skb);
+               dev_kfree_skb(skb);
+       }
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static void prism2_info(local_info_t *local)
+{
+       struct net_device *dev = local->dev;
+       u16 fid;
+       int res, left;
+       struct hfa384x_info_frame info;
+       struct sk_buff *skb;
+
+       fid = HFA384X_INW(HFA384X_INFOFID_OFF);
+
+       spin_lock(&local->baplock);
+       res = hfa384x_setup_bap(dev, BAP0, fid, 0);
+       if (!res)
+               res = hfa384x_from_bap(dev, BAP0, &info, sizeof(info));
+       if (res) {
+               spin_unlock(&local->baplock);
+               printk(KERN_DEBUG "Could not get info frame (fid=0x%04x)\n",
+                      fid);
+               if (res == -ETIMEDOUT) {
+                       schedule_work(&local->reset_queue);
+               }
+               goto out;
+       }
+
+       le16_to_cpus(&info.len);
+       le16_to_cpus(&info.type);
+       left = (info.len - 1) * 2;
+
+       if (info.len & 0x8000 || info.len == 0 || left > 2060) {
+               /* data register seems to give 0x8000 in some error cases even
+                * though busy bit is not set in offset register;
+                * in addition, length must be at least 1 due to type field */
+               spin_unlock(&local->baplock);
+               printk(KERN_DEBUG "%s: Received info frame with invalid "
+                      "length 0x%04x (type 0x%04x)\n", dev->name, info.len,
+                      info.type);
+               goto out;
+       }
+
+       skb = dev_alloc_skb(sizeof(info) + left);
+       if (skb == NULL) {
+               spin_unlock(&local->baplock);
+               printk(KERN_DEBUG "%s: Could not allocate skb for info "
+                      "frame\n", dev->name);
+               goto out;
+       }
+
+       memcpy(skb_put(skb, sizeof(info)), &info, sizeof(info));
+       if (left > 0 && hfa384x_from_bap(dev, BAP0, skb_put(skb, left), left))
+       {
+               spin_unlock(&local->baplock);
+               printk(KERN_WARNING "%s: Info frame read failed (fid=0x%04x, "
+                      "len=0x%04x, type=0x%04x\n",
+                      dev->name, fid, info.len, info.type);
+               dev_kfree_skb(skb);
+               goto out;
+       }
+       spin_unlock(&local->baplock);
+
+       skb_queue_tail(&local->info_list, skb);
+       tasklet_schedule(&local->info_tasklet);
+
+ out:
+       HFA384X_OUTW(HFA384X_EV_INFO, HFA384X_EVACK_OFF);
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static void hostap_bap_tasklet(unsigned long data)
+{
+       local_info_t *local = (local_info_t *) data;
+       struct net_device *dev = local->dev;
+       u16 ev;
+       int frames = 30;
+
+       if (local->func->card_present && !local->func->card_present(local))
+               return;
+
+       set_bit(HOSTAP_BITS_BAP_TASKLET, &local->bits);
+
+       /* Process all pending BAP events without generating new interrupts
+        * for them */
+       while (frames-- > 0) {
+               ev = HFA384X_INW(HFA384X_EVSTAT_OFF);
+               if (ev == 0xffff || !(ev & HFA384X_BAP0_EVENTS))
+                       break;
+               if (ev & HFA384X_EV_RX)
+                       prism2_rx(local);
+               if (ev & HFA384X_EV_INFO)
+                       prism2_info(local);
+               if (ev & HFA384X_EV_TX)
+                       prism2_tx_ev(local);
+               if (ev & HFA384X_EV_TXEXC)
+                       prism2_txexc(local);
+       }
+
+       set_bit(HOSTAP_BITS_BAP_TASKLET2, &local->bits);
+       clear_bit(HOSTAP_BITS_BAP_TASKLET, &local->bits);
+
+       /* Enable interrupts for new BAP events */
+       hfa384x_events_all(dev);
+       clear_bit(HOSTAP_BITS_BAP_TASKLET2, &local->bits);
+}
+
+
+/* Called only from hardware IRQ */
+static void prism2_infdrop(struct net_device *dev)
+{
+       static unsigned long last_inquire = 0;
+
+       PDEBUG(DEBUG_EXTRA, "%s: INFDROP event\n", dev->name);
+
+       /* some firmware versions seem to get stuck with
+        * full CommTallies in high traffic load cases; every
+        * packet will then cause INFDROP event and CommTallies
+        * info frame will not be sent automatically. Try to
+        * get out of this state by inquiring CommTallies. */
+       if (!last_inquire || time_after(jiffies, last_inquire + HZ)) {
+               hfa384x_cmd_callback(dev, HFA384X_CMDCODE_INQUIRE,
+                                    HFA384X_INFO_COMMTALLIES, NULL, 0);
+               last_inquire = jiffies;
+       }
+}
+
+
+/* Called only from hardware IRQ */
+static void prism2_ev_tick(struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       u16 evstat, inten;
+       static int prev_stuck = 0;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (time_after(jiffies, local->last_tick_timer + 5 * HZ) &&
+           local->last_tick_timer) {
+               evstat = HFA384X_INW(HFA384X_EVSTAT_OFF);
+               inten = HFA384X_INW(HFA384X_INTEN_OFF);
+               if (!prev_stuck) {
+                       printk(KERN_INFO "%s: SW TICK stuck? "
+                              "bits=0x%lx EvStat=%04x IntEn=%04x\n",
+                              dev->name, local->bits, evstat, inten);
+               }
+               local->sw_tick_stuck++;
+               if ((evstat & HFA384X_BAP0_EVENTS) &&
+                   (inten & HFA384X_BAP0_EVENTS)) {
+                       printk(KERN_INFO "%s: trying to recover from IRQ "
+                              "hang\n", dev->name);
+                       hfa384x_events_no_bap0(dev);
+               }
+               prev_stuck = 1;
+       } else
+               prev_stuck = 0;
+}
+
+
+/* Called only from hardware IRQ */
+static inline void prism2_check_magic(local_info_t *local)
+{
+       /* at least PCI Prism2.5 with bus mastering seems to sometimes
+        * return 0x0000 in SWSUPPORT0 for unknown reason, but re-reading the
+        * register once or twice seems to get the correct value.. PCI cards
+        * cannot anyway be removed during normal operation, so there is not
+        * really any need for this verification with them. */
+
+#ifndef PRISM2_PCI
+#ifndef final_version
+       static unsigned long last_magic_err = 0;
+       struct net_device *dev = local->dev;
+
+       if (HFA384X_INW(HFA384X_SWSUPPORT0_OFF) != HFA384X_MAGIC) {
+               if (!local->hw_ready)
+                       return;
+               HFA384X_OUTW(0xffff, HFA384X_EVACK_OFF);
+               if (time_after(jiffies, last_magic_err + 10 * HZ)) {
+                       printk("%s: Interrupt, but SWSUPPORT0 does not match: "
+                              "%04X != %04X - card removed?\n", dev->name,
+                              HFA384X_INW(HFA384X_SWSUPPORT0_OFF),
+                              HFA384X_MAGIC);
+                       last_magic_err = jiffies;
+               } else if (net_ratelimit()) {
+                       printk(KERN_DEBUG "%s: interrupt - SWSUPPORT0=%04x "
+                              "MAGIC=%04x\n", dev->name,
+                              HFA384X_INW(HFA384X_SWSUPPORT0_OFF),
+                              HFA384X_MAGIC);
+               }
+               if (HFA384X_INW(HFA384X_SWSUPPORT0_OFF) != 0xffff)
+                       schedule_work(&local->reset_queue);
+               return;
+       }
+#endif /* final_version */
+#endif /* !PRISM2_PCI */
+}
+
+
+/* Called only from hardware IRQ */
+static irqreturn_t prism2_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+       struct net_device *dev = (struct net_device *) dev_id;
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int events = 0;
+       u16 ev;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INTERRUPT, 0, 0);
+
+       if (local->func->card_present && !local->func->card_present(local)) {
+               if (net_ratelimit()) {
+                       printk(KERN_DEBUG "%s: Interrupt, but dev not OK\n",
+                              dev->name);
+               }
+               return IRQ_HANDLED;
+       }
+
+       prism2_check_magic(local);
+
+       for (;;) {
+               ev = HFA384X_INW(HFA384X_EVSTAT_OFF);
+               if (ev == 0xffff) {
+                       if (local->shutdown)
+                               return IRQ_HANDLED;
+                       HFA384X_OUTW(0xffff, HFA384X_EVACK_OFF);
+                       printk(KERN_DEBUG "%s: prism2_interrupt: ev=0xffff\n",
+                              dev->name);
+                       return IRQ_HANDLED;
+               }
+
+               ev &= HFA384X_INW(HFA384X_INTEN_OFF);
+               if (ev == 0)
+                       break;
+
+               if (ev & HFA384X_EV_CMD) {
+                       prism2_cmd_ev(dev);
+               }
+
+               /* Above events are needed even before hw is ready, but other
+                * events should be skipped during initialization. This may
+                * change for AllocEv if allocate_fid is implemented without
+                * busy waiting. */
+               if (!local->hw_ready || local->hw_resetting ||
+                   !local->dev_enabled) {
+                       ev = HFA384X_INW(HFA384X_EVSTAT_OFF);
+                       if (ev & HFA384X_EV_CMD)
+                               goto next_event;
+                       if ((ev & HFA384X_EVENT_MASK) == 0)
+                               return IRQ_HANDLED;
+                       if (local->dev_enabled && (ev & ~HFA384X_EV_TICK) &&
+                           net_ratelimit()) {
+                               printk(KERN_DEBUG "%s: prism2_interrupt: hw "
+                                      "not ready; skipping events 0x%04x "
+                                      "(IntEn=0x%04x)%s%s%s\n",
+                                      dev->name, ev,
+                                      HFA384X_INW(HFA384X_INTEN_OFF),
+                                      !local->hw_ready ? " (!hw_ready)" : "",
+                                      local->hw_resetting ?
+                                      " (hw_resetting)" : "",
+                                      !local->dev_enabled ?
+                                      " (!dev_enabled)" : "");
+                       }
+                       HFA384X_OUTW(ev, HFA384X_EVACK_OFF);
+                       return IRQ_HANDLED;
+               }
+
+               if (ev & HFA384X_EV_TICK) {
+                       prism2_ev_tick(dev);
+                       HFA384X_OUTW(HFA384X_EV_TICK, HFA384X_EVACK_OFF);
+               }
+
+               if (ev & HFA384X_EV_ALLOC) {
+                       prism2_alloc_ev(dev);
+                       HFA384X_OUTW(HFA384X_EV_ALLOC, HFA384X_EVACK_OFF);
+               }
+
+               /* Reading data from the card is quite time consuming, so do it
+                * in tasklets. TX, TXEXC, RX, and INFO events will be ACKed
+                * and unmasked after needed data has been read completely. */
+               if (ev & HFA384X_BAP0_EVENTS) {
+                       hfa384x_events_no_bap0(dev);
+                       tasklet_schedule(&local->bap_tasklet);
+               }
+
+#ifndef final_version
+               if (ev & HFA384X_EV_WTERR) {
+                       PDEBUG(DEBUG_EXTRA, "%s: WTERR event\n", dev->name);
+                       HFA384X_OUTW(HFA384X_EV_WTERR, HFA384X_EVACK_OFF);
+               }
+#endif /* final_version */
+
+               if (ev & HFA384X_EV_INFDROP) {
+                       prism2_infdrop(dev);
+                       HFA384X_OUTW(HFA384X_EV_INFDROP, HFA384X_EVACK_OFF);
+               }
+
+       next_event:
+               events++;
+               if (events >= PRISM2_MAX_INTERRUPT_EVENTS) {
+                       PDEBUG(DEBUG_EXTRA, "prism2_interrupt: >%d events "
+                              "(EvStat=0x%04x)\n",
+                              PRISM2_MAX_INTERRUPT_EVENTS,
+                              HFA384X_INW(HFA384X_EVSTAT_OFF));
+                       break;
+               }
+       }
+       prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INTERRUPT, 0, 1);
+       return IRQ_RETVAL(events);
+}
+
+
+static void prism2_check_sta_fw_version(local_info_t *local)
+{
+       struct hfa384x_comp_ident comp;
+       int id, variant, major, minor;
+
+       if (hfa384x_get_rid(local->dev, HFA384X_RID_STAID,
+                           &comp, sizeof(comp), 1) < 0)
+               return;
+
+       local->fw_ap = 0;
+       id = le16_to_cpu(comp.id);
+       if (id != HFA384X_COMP_ID_STA) {
+               if (id == HFA384X_COMP_ID_FW_AP)
+                       local->fw_ap = 1;
+               return;
+       }
+
+       major = __le16_to_cpu(comp.major);
+       minor = __le16_to_cpu(comp.minor);
+       variant = __le16_to_cpu(comp.variant);
+       local->sta_fw_ver = PRISM2_FW_VER(major, minor, variant);
+
+       /* Station firmware versions before 1.4.x seem to have a bug in
+        * firmware-based WEP encryption when using Host AP mode, so use
+        * host_encrypt as a default for them. Firmware version 1.4.9 is the
+        * first one that has been seen to produce correct encryption, but the
+        * bug might be fixed before that (although, at least 1.4.2 is broken).
+        */
+       local->fw_encrypt_ok = local->sta_fw_ver >= PRISM2_FW_VER(1,4,9);
+
+       if (local->iw_mode == IW_MODE_MASTER && !local->host_encrypt &&
+           !local->fw_encrypt_ok) {
+               printk(KERN_DEBUG "%s: defaulting to host-based encryption as "
+                      "a workaround for firmware bug in Host AP mode WEP\n",
+                      local->dev->name);
+               local->host_encrypt = 1;
+       }
+
+       /* IEEE 802.11 standard compliant WDS frames (4 addresses) were broken
+        * in station firmware versions before 1.5.x. With these versions, the
+        * driver uses a workaround with bogus frame format (4th address after
+        * the payload). This is not compatible with other AP devices. Since
+        * the firmware bug is fixed in the latest station firmware versions,
+        * automatically enable standard compliant mode for cards using station
+        * firmware version 1.5.0 or newer. */
+       if (local->sta_fw_ver >= PRISM2_FW_VER(1,5,0))
+               local->wds_type |= HOSTAP_WDS_STANDARD_FRAME;
+       else {
+               printk(KERN_DEBUG "%s: defaulting to bogus WDS frame as a "
+                      "workaround for firmware bug in Host AP mode WDS\n",
+                      local->dev->name);
+       }
+
+       hostap_check_sta_fw_version(local->ap, local->sta_fw_ver);
+}
+
+
+static void prism2_crypt_deinit_entries(local_info_t *local, int force)
+{
+       struct list_head *ptr, *n;
+       struct ieee80211_crypt_data *entry;
+
+       for (ptr = local->crypt_deinit_list.next, n = ptr->next;
+            ptr != &local->crypt_deinit_list; ptr = n, n = ptr->next) {
+               entry = list_entry(ptr, struct ieee80211_crypt_data, list);
+
+               if (atomic_read(&entry->refcnt) != 0 && !force)
+                       continue;
+
+               list_del(ptr);
+
+               if (entry->ops)
+                       entry->ops->deinit(entry->priv);
+               kfree(entry);
+       }
+}
+
+
+static void prism2_crypt_deinit_handler(unsigned long data)
+{
+       local_info_t *local = (local_info_t *) data;
+       unsigned long flags;
+
+       spin_lock_irqsave(&local->lock, flags);
+       prism2_crypt_deinit_entries(local, 0);
+       if (!list_empty(&local->crypt_deinit_list)) {
+               printk(KERN_DEBUG "%s: entries remaining in delayed crypt "
+                      "deletion list\n", local->dev->name);
+               local->crypt_deinit_timer.expires = jiffies + HZ;
+               add_timer(&local->crypt_deinit_timer);
+       }
+       spin_unlock_irqrestore(&local->lock, flags);
+
+}
+
+
+static void hostap_passive_scan(unsigned long data)
+{
+       local_info_t *local = (local_info_t *) data;
+       struct net_device *dev = local->dev;
+       u16 channel;
+
+       if (local->passive_scan_interval <= 0)
+               return;
+
+       if (local->passive_scan_state == PASSIVE_SCAN_LISTEN) {
+               int max_tries = 16;
+
+               /* Even though host system does not really know when the WLAN
+                * MAC is sending frames, try to avoid changing channels for
+                * passive scanning when a host-generated frame is being
+                * transmitted */
+               if (test_bit(HOSTAP_BITS_TRANSMIT, &local->bits)) {
+                       printk(KERN_DEBUG "%s: passive scan detected pending "
+                              "TX - delaying\n", dev->name);
+                       local->passive_scan_timer.expires = jiffies + HZ / 10;
+                       add_timer(&local->passive_scan_timer);
+                       return;
+               }
+
+               do {
+                       local->passive_scan_channel++;
+                       if (local->passive_scan_channel > 14)
+                               local->passive_scan_channel = 1;
+                       max_tries--;
+               } while (!(local->channel_mask &
+                          (1 << (local->passive_scan_channel - 1))) &&
+                        max_tries > 0);
+
+               if (max_tries == 0) {
+                       printk(KERN_INFO "%s: no allowed passive scan channels"
+                              " found\n", dev->name);
+                       return;
+               }
+
+               printk(KERN_DEBUG "%s: passive scan channel %d\n",
+                      dev->name, local->passive_scan_channel);
+               channel = local->passive_scan_channel;
+               local->passive_scan_state = PASSIVE_SCAN_WAIT;
+               local->passive_scan_timer.expires = jiffies + HZ / 10;
+       } else {
+               channel = local->channel;
+               local->passive_scan_state = PASSIVE_SCAN_LISTEN;
+               local->passive_scan_timer.expires = jiffies +
+                       local->passive_scan_interval * HZ;
+       }
+
+       if (hfa384x_cmd_callback(dev, HFA384X_CMDCODE_TEST |
+                                (HFA384X_TEST_CHANGE_CHANNEL << 8),
+                                channel, NULL, 0))
+               printk(KERN_ERR "%s: passive scan channel set %d "
+                      "failed\n", dev->name, channel);
+
+       add_timer(&local->passive_scan_timer);
+}
+
+
+/* Called only as a scheduled task when communications quality values should
+ * be updated. */
+static void handle_comms_qual_update(void *data)
+{
+       local_info_t *local = data;
+       prism2_update_comms_qual(local->dev);
+}
+
+
+/* Software watchdog - called as a timer. Hardware interrupt (Tick event) is
+ * used to monitor that local->last_tick_timer is being updated. If not,
+ * interrupt busy-loop is assumed and driver tries to recover by masking out
+ * some events. */
+static void hostap_tick_timer(unsigned long data)
+{
+       static unsigned long last_inquire = 0;
+       local_info_t *local = (local_info_t *) data;
+       local->last_tick_timer = jiffies;
+
+       /* Inquire CommTallies every 10 seconds to keep the statistics updated
+        * more often during low load and when using 32-bit tallies. */
+       if ((!last_inquire || time_after(jiffies, last_inquire + 10 * HZ)) &&
+           !local->hw_downloading && local->hw_ready &&
+           !local->hw_resetting && local->dev_enabled) {
+               hfa384x_cmd_callback(local->dev, HFA384X_CMDCODE_INQUIRE,
+                                    HFA384X_INFO_COMMTALLIES, NULL, 0);
+               last_inquire = jiffies;
+       }
+
+       if ((local->last_comms_qual_update == 0 ||
+            time_after(jiffies, local->last_comms_qual_update + 10 * HZ)) &&
+           (local->iw_mode == IW_MODE_INFRA ||
+            local->iw_mode == IW_MODE_ADHOC)) {
+               schedule_work(&local->comms_qual_update);
+       }
+
+       local->tick_timer.expires = jiffies + 2 * HZ;
+       add_timer(&local->tick_timer);
+}
+
+
+#ifndef PRISM2_NO_PROCFS_DEBUG
+static int prism2_registers_proc_read(char *page, char **start, off_t off,
+                                     int count, int *eof, void *data)
+{
+       char *p = page;
+       local_info_t *local = (local_info_t *) data;
+
+       if (off != 0) {
+               *eof = 1;
+               return 0;
+       }
+
+#define SHOW_REG(n) \
+p += sprintf(p, #n "=%04x\n", hfa384x_read_reg(local->dev, HFA384X_##n##_OFF))
+
+       SHOW_REG(CMD);
+       SHOW_REG(PARAM0);
+       SHOW_REG(PARAM1);
+       SHOW_REG(PARAM2);
+       SHOW_REG(STATUS);
+       SHOW_REG(RESP0);
+       SHOW_REG(RESP1);
+       SHOW_REG(RESP2);
+       SHOW_REG(INFOFID);
+       SHOW_REG(CONTROL);
+       SHOW_REG(SELECT0);
+       SHOW_REG(SELECT1);
+       SHOW_REG(OFFSET0);
+       SHOW_REG(OFFSET1);
+       SHOW_REG(RXFID);
+       SHOW_REG(ALLOCFID);
+       SHOW_REG(TXCOMPLFID);
+       SHOW_REG(SWSUPPORT0);
+       SHOW_REG(SWSUPPORT1);
+       SHOW_REG(SWSUPPORT2);
+       SHOW_REG(EVSTAT);
+       SHOW_REG(INTEN);
+       SHOW_REG(EVACK);
+       /* Do not read data registers, because they change the state of the
+        * MAC (offset += 2) */
+       /* SHOW_REG(DATA0); */
+       /* SHOW_REG(DATA1); */
+       SHOW_REG(AUXPAGE);
+       SHOW_REG(AUXOFFSET);
+       /* SHOW_REG(AUXDATA); */
+#ifdef PRISM2_PCI
+       SHOW_REG(PCICOR);
+       SHOW_REG(PCIHCR);
+       SHOW_REG(PCI_M0_ADDRH);
+       SHOW_REG(PCI_M0_ADDRL);
+       SHOW_REG(PCI_M0_LEN);
+       SHOW_REG(PCI_M0_CTL);
+       SHOW_REG(PCI_STATUS);
+       SHOW_REG(PCI_M1_ADDRH);
+       SHOW_REG(PCI_M1_ADDRL);
+       SHOW_REG(PCI_M1_LEN);
+       SHOW_REG(PCI_M1_CTL);
+#endif /* PRISM2_PCI */
+
+       return (p - page);
+}
+#endif /* PRISM2_NO_PROCFS_DEBUG */
+
+
+struct set_tim_data {
+       struct list_head list;
+       int aid;
+       int set;
+};
+
+static int prism2_set_tim(struct net_device *dev, int aid, int set)
+{
+       struct list_head *ptr;
+       struct set_tim_data *new_entry;
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       new_entry = (struct set_tim_data *)
+               kmalloc(sizeof(*new_entry), GFP_ATOMIC);
+       if (new_entry == NULL) {
+               printk(KERN_DEBUG "%s: prism2_set_tim: kmalloc failed\n",
+                      local->dev->name);
+               return -ENOMEM;
+       }
+       memset(new_entry, 0, sizeof(*new_entry));
+       new_entry->aid = aid;
+       new_entry->set = set;
+
+       spin_lock_bh(&local->set_tim_lock);
+       list_for_each(ptr, &local->set_tim_list) {
+               struct set_tim_data *entry =
+                       list_entry(ptr, struct set_tim_data, list);
+               if (entry->aid == aid) {
+                       PDEBUG(DEBUG_PS2, "%s: prism2_set_tim: aid=%d "
+                              "set=%d ==> %d\n",
+                              local->dev->name, aid, entry->set, set);
+                       entry->set = set;
+                       kfree(new_entry);
+                       new_entry = NULL;
+                       break;
+               }
+       }
+       if (new_entry)
+               list_add_tail(&new_entry->list, &local->set_tim_list);
+       spin_unlock_bh(&local->set_tim_lock);
+
+       schedule_work(&local->set_tim_queue);
+
+       return 0;
+}
+
+
+static void handle_set_tim_queue(void *data)
+{
+       local_info_t *local = (local_info_t *) data;
+       struct set_tim_data *entry;
+       u16 val;
+
+       for (;;) {
+               entry = NULL;
+               spin_lock_bh(&local->set_tim_lock);
+               if (!list_empty(&local->set_tim_list)) {
+                       entry = list_entry(local->set_tim_list.next,
+                                          struct set_tim_data, list);
+                       list_del(&entry->list);
+               }
+               spin_unlock_bh(&local->set_tim_lock);
+               if (!entry)
+                       break;
+
+               PDEBUG(DEBUG_PS2, "%s: handle_set_tim_queue: aid=%d set=%d\n",
+                      local->dev->name, entry->aid, entry->set);
+
+               val = entry->aid;
+               if (entry->set)
+                       val |= 0x8000;
+               if (hostap_set_word(local->dev, HFA384X_RID_CNFTIMCTRL, val)) {
+                       printk(KERN_DEBUG "%s: set_tim failed (aid=%d "
+                              "set=%d)\n",
+                              local->dev->name, entry->aid, entry->set);
+               }
+
+               kfree(entry);
+       }
+}
+
+
+static void prism2_clear_set_tim_queue(local_info_t *local)
+{
+       struct list_head *ptr, *n;
+
+       list_for_each_safe(ptr, n, &local->set_tim_list) {
+               struct set_tim_data *entry;
+               entry = list_entry(ptr, struct set_tim_data, list);
+               list_del(&entry->list);
+               kfree(entry);
+       }
+}
+
+
+static struct net_device *
+prism2_init_local_data(struct prism2_helper_functions *funcs, int card_idx,
+                      struct device *sdev)
+{
+       struct net_device *dev;
+       struct hostap_interface *iface;
+       struct local_info *local;
+       int len, i, ret;
+
+       if (funcs == NULL)
+               return NULL;
+
+       len = strlen(dev_template);
+       if (len >= IFNAMSIZ || strstr(dev_template, "%d") == NULL) {
+               printk(KERN_WARNING "hostap: Invalid dev_template='%s'\n",
+                      dev_template);
+               return NULL;
+       }
+
+       len = sizeof(struct hostap_interface) +
+               3 + sizeof(struct local_info) +
+               3 + sizeof(struct ap_data);
+
+       dev = alloc_etherdev(len);
+       if (dev == NULL)
+               return NULL;
+
+       iface = netdev_priv(dev);
+       local = (struct local_info *) ((((long) (iface + 1)) + 3) & ~3);
+       local->ap = (struct ap_data *) ((((long) (local + 1)) + 3) & ~3);
+       local->dev = iface->dev = dev;
+       iface->local = local;
+       iface->type = HOSTAP_INTERFACE_MASTER;
+       INIT_LIST_HEAD(&local->hostap_interfaces);
+
+       local->hw_module = THIS_MODULE;
+
+#ifdef PRISM2_IO_DEBUG
+       local->io_debug_enabled = 1;
+#endif /* PRISM2_IO_DEBUG */
+
+       local->func = funcs;
+       local->func->cmd = hfa384x_cmd;
+       local->func->read_regs = hfa384x_read_regs;
+       local->func->get_rid = hfa384x_get_rid;
+       local->func->set_rid = hfa384x_set_rid;
+       local->func->hw_enable = prism2_hw_enable;
+       local->func->hw_config = prism2_hw_config;
+       local->func->hw_reset = prism2_hw_reset;
+       local->func->hw_shutdown = prism2_hw_shutdown;
+       local->func->reset_port = prism2_reset_port;
+       local->func->schedule_reset = prism2_schedule_reset;
+#ifdef PRISM2_DOWNLOAD_SUPPORT
+       local->func->read_aux = prism2_download_aux_dump;
+       local->func->download = prism2_download;
+#endif /* PRISM2_DOWNLOAD_SUPPORT */
+       local->func->tx = prism2_tx_80211;
+       local->func->set_tim = prism2_set_tim;
+       local->func->need_tx_headroom = 0; /* no need to add txdesc in
+                                           * skb->data (FIX: maybe for DMA bus
+                                           * mastering? */
+
+       local->mtu = mtu;
+
+       rwlock_init(&local->iface_lock);
+       spin_lock_init(&local->txfidlock);
+       spin_lock_init(&local->cmdlock);
+       spin_lock_init(&local->baplock);
+       spin_lock_init(&local->lock);
+       init_MUTEX(&local->rid_bap_sem);
+
+       if (card_idx < 0 || card_idx >= MAX_PARM_DEVICES)
+               card_idx = 0;
+       local->card_idx = card_idx;
+
+       len = strlen(essid);
+       memcpy(local->essid, essid,
+              len > MAX_SSID_LEN ? MAX_SSID_LEN : len);
+       local->essid[MAX_SSID_LEN] = '\0';
+       i = GET_INT_PARM(iw_mode, card_idx);
+       if ((i >= IW_MODE_ADHOC && i <= IW_MODE_REPEAT) ||
+           i == IW_MODE_MONITOR) {
+               local->iw_mode = i;
+       } else {
+               printk(KERN_WARNING "prism2: Unknown iw_mode %d; using "
+                      "IW_MODE_MASTER\n", i);
+               local->iw_mode = IW_MODE_MASTER;
+       }
+       local->channel = GET_INT_PARM(channel, card_idx);
+       local->beacon_int = GET_INT_PARM(beacon_int, card_idx);
+       local->dtim_period = GET_INT_PARM(dtim_period, card_idx);
+       local->wds_max_connections = 16;
+       local->tx_control = HFA384X_TX_CTRL_FLAGS;
+       local->manual_retry_count = -1;
+       local->rts_threshold = 2347;
+       local->fragm_threshold = 2346;
+       local->rssi_to_dBm = 100; /* default; to be overriden by
+                                  * cnfDbmAdjust, if available */
+       local->auth_algs = PRISM2_AUTH_OPEN | PRISM2_AUTH_SHARED_KEY;
+       local->sram_type = -1;
+       local->scan_channel_mask = 0xffff;
+
+       /* Initialize task queue structures */
+       INIT_WORK(&local->reset_queue, handle_reset_queue, local);
+       INIT_WORK(&local->set_multicast_list_queue,
+                 hostap_set_multicast_list_queue, local->dev);
+
+       INIT_WORK(&local->set_tim_queue, handle_set_tim_queue, local);
+       INIT_LIST_HEAD(&local->set_tim_list);
+       spin_lock_init(&local->set_tim_lock);
+
+       INIT_WORK(&local->comms_qual_update, handle_comms_qual_update, local);
+
+       /* Initialize tasklets for handling hardware IRQ related operations
+        * outside hw IRQ handler */
+#define HOSTAP_TASKLET_INIT(q, f, d) \
+do { memset((q), 0, sizeof(*(q))); (q)->func = (f); (q)->data = (d); } \
+while (0)
+       HOSTAP_TASKLET_INIT(&local->bap_tasklet, hostap_bap_tasklet,
+                           (unsigned long) local);
+
+       HOSTAP_TASKLET_INIT(&local->info_tasklet, hostap_info_tasklet,
+                           (unsigned long) local);
+       hostap_info_init(local);
+
+       HOSTAP_TASKLET_INIT(&local->rx_tasklet,
+                           hostap_rx_tasklet, (unsigned long) local);
+       skb_queue_head_init(&local->rx_list);
+
+       HOSTAP_TASKLET_INIT(&local->sta_tx_exc_tasklet,
+                           hostap_sta_tx_exc_tasklet, (unsigned long) local);
+       skb_queue_head_init(&local->sta_tx_exc_list);
+
+       INIT_LIST_HEAD(&local->cmd_queue);
+       init_waitqueue_head(&local->hostscan_wq);
+       INIT_LIST_HEAD(&local->crypt_deinit_list);
+       init_timer(&local->crypt_deinit_timer);
+       local->crypt_deinit_timer.data = (unsigned long) local;
+       local->crypt_deinit_timer.function = prism2_crypt_deinit_handler;
+
+       init_timer(&local->passive_scan_timer);
+       local->passive_scan_timer.data = (unsigned long) local;
+       local->passive_scan_timer.function = hostap_passive_scan;
+
+       init_timer(&local->tick_timer);
+       local->tick_timer.data = (unsigned long) local;
+       local->tick_timer.function = hostap_tick_timer;
+       local->tick_timer.expires = jiffies + 2 * HZ;
+       add_timer(&local->tick_timer);
+
+       INIT_LIST_HEAD(&local->bss_list);
+
+       hostap_setup_dev(dev, local, 1);
+       local->saved_eth_header_parse = dev->hard_header_parse;
+
+       dev->hard_start_xmit = hostap_master_start_xmit;
+       dev->type = ARPHRD_IEEE80211;
+       dev->hard_header_parse = hostap_80211_header_parse;
+
+       rtnl_lock();
+       ret = dev_alloc_name(dev, "wifi%d");
+       SET_NETDEV_DEV(dev, sdev);
+       if (ret >= 0)
+               ret = register_netdevice(dev);
+       rtnl_unlock();
+       if (ret < 0) {
+               printk(KERN_WARNING "%s: register netdevice failed!\n",
+                      dev_info);
+               goto fail;
+       }
+       printk(KERN_INFO "%s: Registered netdevice %s\n", dev_info, dev->name);
+
+#ifndef PRISM2_NO_PROCFS_DEBUG
+       create_proc_read_entry("registers", 0, local->proc,
+                              prism2_registers_proc_read, local);
+#endif /* PRISM2_NO_PROCFS_DEBUG */
+
+       hostap_init_data(local);
+       return dev;
+
+ fail:
+       free_netdev(dev);
+       return NULL;
+}
+
+
+static int hostap_hw_ready(struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       struct local_info *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+       local->ddev = hostap_add_interface(local, HOSTAP_INTERFACE_MAIN, 0,
+                                          "", dev_template);
+
+       if (local->ddev) {
+               if (local->iw_mode == IW_MODE_INFRA ||
+                   local->iw_mode == IW_MODE_ADHOC) {
+                       netif_carrier_off(local->dev);
+                       netif_carrier_off(local->ddev);
+               }
+               hostap_init_proc(local);
+               hostap_init_ap_proc(local);
+               return 0;
+       }
+
+       return -1;
+}
+
+
+static void prism2_free_local_data(struct net_device *dev)
+{
+       struct hostap_tx_callback_info *tx_cb, *tx_cb_prev;
+       int i;
+       struct hostap_interface *iface;
+       struct local_info *local;
+       struct list_head *ptr, *n;
+
+       if (dev == NULL)
+               return;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       flush_scheduled_work();
+
+       if (timer_pending(&local->crypt_deinit_timer))
+               del_timer(&local->crypt_deinit_timer);
+       prism2_crypt_deinit_entries(local, 1);
+
+       if (timer_pending(&local->passive_scan_timer))
+               del_timer(&local->passive_scan_timer);
+
+       if (timer_pending(&local->tick_timer))
+               del_timer(&local->tick_timer);
+
+       prism2_clear_cmd_queue(local);
+
+       skb_queue_purge(&local->info_list);
+       skb_queue_purge(&local->rx_list);
+       skb_queue_purge(&local->sta_tx_exc_list);
+
+       if (local->dev_enabled)
+               prism2_callback(local, PRISM2_CALLBACK_DISABLE);
+
+       for (i = 0; i < WEP_KEYS; i++) {
+               struct ieee80211_crypt_data *crypt = local->crypt[i];
+               if (crypt) {
+                       if (crypt->ops)
+                               crypt->ops->deinit(crypt->priv);
+                       kfree(crypt);
+                       local->crypt[i] = NULL;
+               }
+       }
+
+       if (local->ap != NULL)
+               hostap_free_data(local->ap);
+
+#ifndef PRISM2_NO_PROCFS_DEBUG
+       if (local->proc != NULL)
+               remove_proc_entry("registers", local->proc);
+#endif /* PRISM2_NO_PROCFS_DEBUG */
+       hostap_remove_proc(local);
+
+       tx_cb = local->tx_callback;
+       while (tx_cb != NULL) {
+               tx_cb_prev = tx_cb;
+               tx_cb = tx_cb->next;
+               kfree(tx_cb_prev);
+       }
+
+       hostap_set_hostapd(local, 0, 0);
+       hostap_set_hostapd_sta(local, 0, 0);
+
+       for (i = 0; i < PRISM2_FRAG_CACHE_LEN; i++) {
+               if (local->frag_cache[i].skb != NULL)
+                       dev_kfree_skb(local->frag_cache[i].skb);
+       }
+
+#ifdef PRISM2_DOWNLOAD_SUPPORT
+       prism2_download_free_data(local->dl_pri);
+       prism2_download_free_data(local->dl_sec);
+#endif /* PRISM2_DOWNLOAD_SUPPORT */
+
+       list_for_each_safe(ptr, n, &local->hostap_interfaces) {
+               iface = list_entry(ptr, struct hostap_interface, list);
+               if (iface->type == HOSTAP_INTERFACE_MASTER) {
+                       /* special handling for this interface below */
+                       continue;
+               }
+               hostap_remove_interface(iface->dev, 0, 1);
+       }
+
+       prism2_clear_set_tim_queue(local);
+
+       list_for_each_safe(ptr, n, &local->bss_list) {
+               struct hostap_bss_info *bss =
+                       list_entry(ptr, struct hostap_bss_info, list);
+               kfree(bss);
+       }
+
+       kfree(local->pda);
+       kfree(local->last_scan_results);
+       kfree(local->generic_elem);
+
+       unregister_netdev(local->dev);
+       free_netdev(local->dev);
+}
+
+
+#ifndef PRISM2_PLX
+static void prism2_suspend(struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       struct local_info *local;
+       union iwreq_data wrqu;
+
+       iface = dev->priv;
+       local = iface->local;
+
+       /* Send disconnect event, e.g., to trigger reassociation after resume
+        * if wpa_supplicant is used. */
+       memset(&wrqu, 0, sizeof(wrqu));
+       wrqu.ap_addr.sa_family = ARPHRD_ETHER;
+       wireless_send_event(local->dev, SIOCGIWAP, &wrqu, NULL);
+
+       /* Disable hardware and firmware */
+       prism2_hw_shutdown(dev, 0);
+}
+#endif /* PRISM2_PLX */
+
+
+/* These might at some point be compiled separately and used as separate
+ * kernel modules or linked into one */
+#ifdef PRISM2_DOWNLOAD_SUPPORT
+#include "hostap_download.c"
+#endif /* PRISM2_DOWNLOAD_SUPPORT */
+
+#ifdef PRISM2_CALLBACK
+/* External hostap_callback.c file can be used to, e.g., blink activity led.
+ * This can use platform specific code and must define prism2_callback()
+ * function (if PRISM2_CALLBACK is not defined, these function calls are not
+ * used. */
+#include "hostap_callback.c"
+#endif /* PRISM2_CALLBACK */
diff --git a/drivers/net/wireless/hostap/hostap_info.c b/drivers/net/wireless/hostap/hostap_info.c
new file mode 100644 (file)
index 0000000..5aa998f
--- /dev/null
@@ -0,0 +1,499 @@
+/* Host AP driver Info Frame processing (part of hostap.o module) */
+
+
+/* Called only as a tasklet (software IRQ) */
+static void prism2_info_commtallies16(local_info_t *local, unsigned char *buf,
+                                     int left)
+{
+       struct hfa384x_comm_tallies *tallies;
+
+       if (left < sizeof(struct hfa384x_comm_tallies)) {
+               printk(KERN_DEBUG "%s: too short (len=%d) commtallies "
+                      "info frame\n", local->dev->name, left);
+               return;
+       }
+
+       tallies = (struct hfa384x_comm_tallies *) buf;
+#define ADD_COMM_TALLIES(name) \
+local->comm_tallies.name += le16_to_cpu(tallies->name)
+       ADD_COMM_TALLIES(tx_unicast_frames);
+       ADD_COMM_TALLIES(tx_multicast_frames);
+       ADD_COMM_TALLIES(tx_fragments);
+       ADD_COMM_TALLIES(tx_unicast_octets);
+       ADD_COMM_TALLIES(tx_multicast_octets);
+       ADD_COMM_TALLIES(tx_deferred_transmissions);
+       ADD_COMM_TALLIES(tx_single_retry_frames);
+       ADD_COMM_TALLIES(tx_multiple_retry_frames);
+       ADD_COMM_TALLIES(tx_retry_limit_exceeded);
+       ADD_COMM_TALLIES(tx_discards);
+       ADD_COMM_TALLIES(rx_unicast_frames);
+       ADD_COMM_TALLIES(rx_multicast_frames);
+       ADD_COMM_TALLIES(rx_fragments);
+       ADD_COMM_TALLIES(rx_unicast_octets);
+       ADD_COMM_TALLIES(rx_multicast_octets);
+       ADD_COMM_TALLIES(rx_fcs_errors);
+       ADD_COMM_TALLIES(rx_discards_no_buffer);
+       ADD_COMM_TALLIES(tx_discards_wrong_sa);
+       ADD_COMM_TALLIES(rx_discards_wep_undecryptable);
+       ADD_COMM_TALLIES(rx_message_in_msg_fragments);
+       ADD_COMM_TALLIES(rx_message_in_bad_msg_fragments);
+#undef ADD_COMM_TALLIES
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static void prism2_info_commtallies32(local_info_t *local, unsigned char *buf,
+                                     int left)
+{
+       struct hfa384x_comm_tallies32 *tallies;
+
+       if (left < sizeof(struct hfa384x_comm_tallies32)) {
+               printk(KERN_DEBUG "%s: too short (len=%d) commtallies32 "
+                      "info frame\n", local->dev->name, left);
+               return;
+       }
+
+       tallies = (struct hfa384x_comm_tallies32 *) buf;
+#define ADD_COMM_TALLIES(name) \
+local->comm_tallies.name += le32_to_cpu(tallies->name)
+       ADD_COMM_TALLIES(tx_unicast_frames);
+       ADD_COMM_TALLIES(tx_multicast_frames);
+       ADD_COMM_TALLIES(tx_fragments);
+       ADD_COMM_TALLIES(tx_unicast_octets);
+       ADD_COMM_TALLIES(tx_multicast_octets);
+       ADD_COMM_TALLIES(tx_deferred_transmissions);
+       ADD_COMM_TALLIES(tx_single_retry_frames);
+       ADD_COMM_TALLIES(tx_multiple_retry_frames);
+       ADD_COMM_TALLIES(tx_retry_limit_exceeded);
+       ADD_COMM_TALLIES(tx_discards);
+       ADD_COMM_TALLIES(rx_unicast_frames);
+       ADD_COMM_TALLIES(rx_multicast_frames);
+       ADD_COMM_TALLIES(rx_fragments);
+       ADD_COMM_TALLIES(rx_unicast_octets);
+       ADD_COMM_TALLIES(rx_multicast_octets);
+       ADD_COMM_TALLIES(rx_fcs_errors);
+       ADD_COMM_TALLIES(rx_discards_no_buffer);
+       ADD_COMM_TALLIES(tx_discards_wrong_sa);
+       ADD_COMM_TALLIES(rx_discards_wep_undecryptable);
+       ADD_COMM_TALLIES(rx_message_in_msg_fragments);
+       ADD_COMM_TALLIES(rx_message_in_bad_msg_fragments);
+#undef ADD_COMM_TALLIES
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static void prism2_info_commtallies(local_info_t *local, unsigned char *buf,
+                                   int left)
+{
+       if (local->tallies32)
+               prism2_info_commtallies32(local, buf, left);
+       else
+               prism2_info_commtallies16(local, buf, left);
+}
+
+
+#ifndef PRISM2_NO_STATION_MODES
+#ifndef PRISM2_NO_DEBUG
+static const char* hfa384x_linkstatus_str(u16 linkstatus)
+{
+       switch (linkstatus) {
+       case HFA384X_LINKSTATUS_CONNECTED:
+               return "Connected";
+       case HFA384X_LINKSTATUS_DISCONNECTED:
+               return "Disconnected";
+       case HFA384X_LINKSTATUS_AP_CHANGE:
+               return "Access point change";
+       case HFA384X_LINKSTATUS_AP_OUT_OF_RANGE:
+               return "Access point out of range";
+       case HFA384X_LINKSTATUS_AP_IN_RANGE:
+               return "Access point in range";
+       case HFA384X_LINKSTATUS_ASSOC_FAILED:
+               return "Association failed";
+       default:
+               return "Unknown";
+       }
+}
+#endif /* PRISM2_NO_DEBUG */
+
+
+/* Called only as a tasklet (software IRQ) */
+static void prism2_info_linkstatus(local_info_t *local, unsigned char *buf,
+                                   int left)
+{
+       u16 val;
+       int non_sta_mode;
+
+       /* Alloc new JoinRequests to occur since LinkStatus for the previous
+        * has been received */
+       local->last_join_time = 0;
+
+       if (left != 2) {
+               printk(KERN_DEBUG "%s: invalid linkstatus info frame "
+                      "length %d\n", local->dev->name, left);
+               return;
+       }
+
+       non_sta_mode = local->iw_mode == IW_MODE_MASTER ||
+               local->iw_mode == IW_MODE_REPEAT ||
+               local->iw_mode == IW_MODE_MONITOR;
+
+       val = buf[0] | (buf[1] << 8);
+       if (!non_sta_mode || val != HFA384X_LINKSTATUS_DISCONNECTED) {
+               PDEBUG(DEBUG_EXTRA, "%s: LinkStatus=%d (%s)\n",
+                      local->dev->name, val, hfa384x_linkstatus_str(val));
+       }
+
+       if (non_sta_mode) {
+               netif_carrier_on(local->dev);
+               netif_carrier_on(local->ddev);
+               return;
+       }
+
+       /* Get current BSSID later in scheduled task */
+       set_bit(PRISM2_INFO_PENDING_LINKSTATUS, &local->pending_info);
+       local->prev_link_status = val;
+       schedule_work(&local->info_queue);
+}
+
+
+static void prism2_host_roaming(local_info_t *local)
+{
+       struct hfa384x_join_request req;
+       struct net_device *dev = local->dev;
+       struct hfa384x_hostscan_result *selected, *entry;
+       int i;
+       unsigned long flags;
+
+       if (local->last_join_time &&
+           time_before(jiffies, local->last_join_time + 10 * HZ)) {
+               PDEBUG(DEBUG_EXTRA, "%s: last join request has not yet been "
+                      "completed - waiting for it before issuing new one\n",
+                      dev->name);
+               return;
+       }
+
+       /* ScanResults are sorted: first ESS results in decreasing signal
+        * quality then IBSS results in similar order.
+        * Trivial roaming policy: just select the first entry.
+        * This could probably be improved by adding hysteresis to limit
+        * number of handoffs, etc.
+        *
+        * Could do periodic RID_SCANREQUEST or Inquire F101 to get new
+        * ScanResults */
+       spin_lock_irqsave(&local->lock, flags);
+       if (local->last_scan_results == NULL ||
+           local->last_scan_results_count == 0) {
+               spin_unlock_irqrestore(&local->lock, flags);
+               PDEBUG(DEBUG_EXTRA, "%s: no scan results for host roaming\n",
+                      dev->name);
+               return;
+       }
+
+       selected = &local->last_scan_results[0];
+
+       if (local->preferred_ap[0] || local->preferred_ap[1] ||
+           local->preferred_ap[2] || local->preferred_ap[3] ||
+           local->preferred_ap[4] || local->preferred_ap[5]) {
+               /* Try to find preferred AP */
+               PDEBUG(DEBUG_EXTRA, "%s: Preferred AP BSSID " MACSTR "\n",
+                      dev->name, MAC2STR(local->preferred_ap));
+               for (i = 0; i < local->last_scan_results_count; i++) {
+                       entry = &local->last_scan_results[i];
+                       if (memcmp(local->preferred_ap, entry->bssid, 6) == 0)
+                       {
+                               PDEBUG(DEBUG_EXTRA, "%s: using preferred AP "
+                                      "selection\n", dev->name);
+                               selected = entry;
+                               break;
+                       }
+               }
+       }
+
+       memcpy(req.bssid, selected->bssid, 6);
+       req.channel = selected->chid;
+       spin_unlock_irqrestore(&local->lock, flags);
+
+       PDEBUG(DEBUG_EXTRA, "%s: JoinRequest: BSSID=" MACSTR " channel=%d\n",
+              dev->name, MAC2STR(req.bssid), le16_to_cpu(req.channel));
+       if (local->func->set_rid(dev, HFA384X_RID_JOINREQUEST, &req,
+                                sizeof(req))) {
+               printk(KERN_DEBUG "%s: JoinRequest failed\n", dev->name);
+       }
+       local->last_join_time = jiffies;
+}
+
+
+static void hostap_report_scan_complete(local_info_t *local)
+{
+       union iwreq_data wrqu;
+
+       /* Inform user space about new scan results (just empty event,
+        * SIOCGIWSCAN can be used to fetch data */
+       wrqu.data.length = 0;
+       wrqu.data.flags = 0;
+       wireless_send_event(local->dev, SIOCGIWSCAN, &wrqu, NULL);
+
+       /* Allow SIOCGIWSCAN handling to occur since we have received
+        * scanning result */
+       local->scan_timestamp = 0;
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static void prism2_info_scanresults(local_info_t *local, unsigned char *buf,
+                                   int left)
+{
+       u16 *pos;
+       int new_count, i;
+       unsigned long flags;
+       struct hfa384x_scan_result *res;
+       struct hfa384x_hostscan_result *results, *prev;
+
+       if (left < 4) {
+               printk(KERN_DEBUG "%s: invalid scanresult info frame "
+                      "length %d\n", local->dev->name, left);
+               return;
+       }
+
+       pos = (u16 *) buf;
+       pos++;
+       pos++;
+       left -= 4;
+
+       new_count = left / sizeof(struct hfa384x_scan_result);
+       results = kmalloc(new_count * sizeof(struct hfa384x_hostscan_result),
+                         GFP_ATOMIC);
+       if (results == NULL)
+               return;
+
+       /* Convert to hostscan result format. */
+       res = (struct hfa384x_scan_result *) pos;
+       for (i = 0; i < new_count; i++) {
+               memcpy(&results[i], &res[i],
+                      sizeof(struct hfa384x_scan_result));
+               results[i].atim = 0;
+       }
+
+       spin_lock_irqsave(&local->lock, flags);
+       local->last_scan_type = PRISM2_SCAN;
+       prev = local->last_scan_results;
+       local->last_scan_results = results;
+       local->last_scan_results_count = new_count;
+       spin_unlock_irqrestore(&local->lock, flags);
+       kfree(prev);
+
+       hostap_report_scan_complete(local);
+
+       /* Perform rest of ScanResults handling later in scheduled task */
+       set_bit(PRISM2_INFO_PENDING_SCANRESULTS, &local->pending_info);
+       schedule_work(&local->info_queue);
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static void prism2_info_hostscanresults(local_info_t *local,
+                                       unsigned char *buf, int left)
+{
+       int i, result_size, copy_len, new_count;
+       struct hfa384x_hostscan_result *results, *prev;
+       unsigned long flags;
+       u16 *pos;
+       u8 *ptr;
+
+       wake_up_interruptible(&local->hostscan_wq);
+
+       if (left < 4) {
+               printk(KERN_DEBUG "%s: invalid hostscanresult info frame "
+                      "length %d\n", local->dev->name, left);
+               return;
+       }
+
+       pos = (u16 *) buf;
+       copy_len = result_size = le16_to_cpu(*pos);
+       if (result_size == 0) {
+               printk(KERN_DEBUG "%s: invalid result_size (0) in "
+                      "hostscanresults\n", local->dev->name);
+               return;
+       }
+       if (copy_len > sizeof(struct hfa384x_hostscan_result))
+               copy_len = sizeof(struct hfa384x_hostscan_result);
+
+       pos++;
+       pos++;
+       left -= 4;
+       ptr = (u8 *) pos;
+
+       new_count = left / result_size;
+       results = kmalloc(new_count * sizeof(struct hfa384x_hostscan_result),
+                         GFP_ATOMIC);
+       if (results == NULL)
+               return;
+       memset(results, 0, new_count * sizeof(struct hfa384x_hostscan_result));
+
+       for (i = 0; i < new_count; i++) {
+               memcpy(&results[i], ptr, copy_len);
+               ptr += result_size;
+               left -= result_size;
+       }
+
+       if (left) {
+               printk(KERN_DEBUG "%s: short HostScan result entry (%d/%d)\n",
+                      local->dev->name, left, result_size);
+       }
+
+       spin_lock_irqsave(&local->lock, flags);
+       local->last_scan_type = PRISM2_HOSTSCAN;
+       prev = local->last_scan_results;
+       local->last_scan_results = results;
+       local->last_scan_results_count = new_count;
+       spin_unlock_irqrestore(&local->lock, flags);
+       kfree(prev);
+
+       hostap_report_scan_complete(local);
+}
+#endif /* PRISM2_NO_STATION_MODES */
+
+
+/* Called only as a tasklet (software IRQ) */
+void hostap_info_process(local_info_t *local, struct sk_buff *skb)
+{
+       struct hfa384x_info_frame *info;
+       unsigned char *buf;
+       int left;
+#ifndef PRISM2_NO_DEBUG
+       int i;
+#endif /* PRISM2_NO_DEBUG */
+
+       info = (struct hfa384x_info_frame *) skb->data;
+       buf = skb->data + sizeof(*info);
+       left = skb->len - sizeof(*info);
+
+       switch (info->type) {
+       case HFA384X_INFO_COMMTALLIES:
+               prism2_info_commtallies(local, buf, left);
+               break;
+
+#ifndef PRISM2_NO_STATION_MODES
+       case HFA384X_INFO_LINKSTATUS:
+               prism2_info_linkstatus(local, buf, left);
+               break;
+
+       case HFA384X_INFO_SCANRESULTS:
+               prism2_info_scanresults(local, buf, left);
+               break;
+
+       case HFA384X_INFO_HOSTSCANRESULTS:
+               prism2_info_hostscanresults(local, buf, left);
+               break;
+#endif /* PRISM2_NO_STATION_MODES */
+
+#ifndef PRISM2_NO_DEBUG
+       default:
+               PDEBUG(DEBUG_EXTRA, "%s: INFO - len=%d type=0x%04x\n",
+                      local->dev->name, info->len, info->type);
+               PDEBUG(DEBUG_EXTRA, "Unknown info frame:");
+               for (i = 0; i < (left < 100 ? left : 100); i++)
+                       PDEBUG2(DEBUG_EXTRA, " %02x", buf[i]);
+               PDEBUG2(DEBUG_EXTRA, "\n");
+               break;
+#endif /* PRISM2_NO_DEBUG */
+       }
+}
+
+
+#ifndef PRISM2_NO_STATION_MODES
+static void handle_info_queue_linkstatus(local_info_t *local)
+{
+       int val = local->prev_link_status;
+       int connected;
+       union iwreq_data wrqu;
+
+       connected =
+               val == HFA384X_LINKSTATUS_CONNECTED ||
+               val == HFA384X_LINKSTATUS_AP_CHANGE ||
+               val == HFA384X_LINKSTATUS_AP_IN_RANGE;
+
+       if (local->func->get_rid(local->dev, HFA384X_RID_CURRENTBSSID,
+                                local->bssid, ETH_ALEN, 1) < 0) {
+               printk(KERN_DEBUG "%s: could not read CURRENTBSSID after "
+                      "LinkStatus event\n", local->dev->name);
+       } else {
+               PDEBUG(DEBUG_EXTRA, "%s: LinkStatus: BSSID=" MACSTR "\n",
+                      local->dev->name,
+                      MAC2STR((unsigned char *) local->bssid));
+               if (local->wds_type & HOSTAP_WDS_AP_CLIENT)
+                       hostap_add_sta(local->ap, local->bssid);
+       }
+
+       /* Get BSSID if we have a valid AP address */
+       if (connected) {
+               netif_carrier_on(local->dev);
+               netif_carrier_on(local->ddev);
+               memcpy(wrqu.ap_addr.sa_data, local->bssid, ETH_ALEN);
+       } else {
+               netif_carrier_off(local->dev);
+               netif_carrier_off(local->ddev);
+               memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
+       }
+       wrqu.ap_addr.sa_family = ARPHRD_ETHER;
+
+       /*
+        * Filter out sequential disconnect events in order not to cause a
+        * flood of SIOCGIWAP events that have a race condition with EAPOL
+        * frames and can confuse wpa_supplicant about the current association
+        * status.
+        */
+       if (connected || local->prev_linkstatus_connected)
+               wireless_send_event(local->dev, SIOCGIWAP, &wrqu, NULL);
+       local->prev_linkstatus_connected = connected;
+}
+
+
+static void handle_info_queue_scanresults(local_info_t *local)
+{
+       if (local->host_roaming == 1 && local->iw_mode == IW_MODE_INFRA)
+               prism2_host_roaming(local);
+
+       if (local->host_roaming == 2 && local->iw_mode == IW_MODE_INFRA &&
+           memcmp(local->preferred_ap, "\x00\x00\x00\x00\x00\x00",
+                  ETH_ALEN) != 0) {
+               /*
+                * Firmware seems to be getting into odd state in host_roaming
+                * mode 2 when hostscan is used without join command, so try
+                * to fix this by re-joining the current AP. This does not
+                * actually trigger a new association if the current AP is
+                * still in the scan results.
+                */
+               prism2_host_roaming(local);
+       }
+}
+
+
+/* Called only as scheduled task after receiving info frames (used to avoid
+ * pending too much time in HW IRQ handler). */
+static void handle_info_queue(void *data)
+{
+       local_info_t *local = (local_info_t *) data;
+
+       if (test_and_clear_bit(PRISM2_INFO_PENDING_LINKSTATUS,
+                              &local->pending_info))
+               handle_info_queue_linkstatus(local);
+
+       if (test_and_clear_bit(PRISM2_INFO_PENDING_SCANRESULTS,
+                              &local->pending_info))
+               handle_info_queue_scanresults(local);
+}
+#endif /* PRISM2_NO_STATION_MODES */
+
+
+void hostap_info_init(local_info_t *local)
+{
+       skb_queue_head_init(&local->info_list);
+#ifndef PRISM2_NO_STATION_MODES
+       INIT_WORK(&local->info_queue, handle_info_queue, local);
+#endif /* PRISM2_NO_STATION_MODES */
+}
+
+
+EXPORT_SYMBOL(hostap_info_init);
+EXPORT_SYMBOL(hostap_info_process);
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c
new file mode 100644 (file)
index 0000000..e720369
--- /dev/null
@@ -0,0 +1,4102 @@
+/* ioctl() (mostly Linux Wireless Extensions) routines for Host AP driver */
+
+#ifdef in_atomic
+/* Get kernel_locked() for in_atomic() */
+#include <linux/smp_lock.h>
+#endif
+#include <linux/ethtool.h>
+
+
+static struct iw_statistics *hostap_get_wireless_stats(struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       struct iw_statistics *wstats;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       /* Why are we doing that ? Jean II */
+       if (iface->type != HOSTAP_INTERFACE_MAIN)
+               return NULL;
+
+       wstats = &local->wstats;
+
+       wstats->status = 0;
+       wstats->discard.code =
+               local->comm_tallies.rx_discards_wep_undecryptable;
+       wstats->discard.misc =
+               local->comm_tallies.rx_fcs_errors +
+               local->comm_tallies.rx_discards_no_buffer +
+               local->comm_tallies.tx_discards_wrong_sa;
+
+       wstats->discard.retries =
+               local->comm_tallies.tx_retry_limit_exceeded;
+       wstats->discard.fragment =
+               local->comm_tallies.rx_message_in_bad_msg_fragments;
+
+       if (local->iw_mode != IW_MODE_MASTER &&
+           local->iw_mode != IW_MODE_REPEAT) {
+               int update = 1;
+#ifdef in_atomic
+               /* RID reading might sleep and it must not be called in
+                * interrupt context or while atomic. However, this
+                * function seems to be called while atomic (at least in Linux
+                * 2.5.59). Update signal quality values only if in suitable
+                * context. Otherwise, previous values read from tick timer
+                * will be used. */
+               if (in_atomic())
+                       update = 0;
+#endif /* in_atomic */
+
+               if (update && prism2_update_comms_qual(dev) == 0)
+                       wstats->qual.updated = 7;
+
+               wstats->qual.qual = local->comms_qual;
+               wstats->qual.level = local->avg_signal;
+               wstats->qual.noise = local->avg_noise;
+       } else {
+               wstats->qual.qual = 0;
+               wstats->qual.level = 0;
+               wstats->qual.noise = 0;
+               wstats->qual.updated = 0;
+       }
+
+       return wstats;
+}
+
+
+static int prism2_get_datarates(struct net_device *dev, u8 *rates)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       u8 buf[12];
+       int len;
+       u16 val;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       len = local->func->get_rid(dev, HFA384X_RID_SUPPORTEDDATARATES, buf,
+                                  sizeof(buf), 0);
+       if (len < 2)
+               return 0;
+
+       val = le16_to_cpu(*(u16 *) buf); /* string length */
+
+       if (len - 2 < val || val > 10)
+               return 0;
+
+       memcpy(rates, buf + 2, val);
+       return val;
+}
+
+
+static int prism2_get_name(struct net_device *dev,
+                          struct iw_request_info *info,
+                          char *name, char *extra)
+{
+       u8 rates[10];
+       int len, i, over2 = 0;
+
+       len = prism2_get_datarates(dev, rates);
+
+       for (i = 0; i < len; i++) {
+               if (rates[i] == 0x0b || rates[i] == 0x16) {
+                       over2 = 1;
+                       break;
+               }
+       }
+
+       strcpy(name, over2 ? "IEEE 802.11b" : "IEEE 802.11-DS");
+
+       return 0;
+}
+
+
+static void prism2_crypt_delayed_deinit(local_info_t *local,
+                                       struct ieee80211_crypt_data **crypt)
+{
+       struct ieee80211_crypt_data *tmp;
+       unsigned long flags;
+
+       tmp = *crypt;
+       *crypt = NULL;
+
+       if (tmp == NULL)
+               return;
+
+       /* must not run ops->deinit() while there may be pending encrypt or
+        * decrypt operations. Use a list of delayed deinits to avoid needing
+        * locking. */
+
+       spin_lock_irqsave(&local->lock, flags);
+       list_add(&tmp->list, &local->crypt_deinit_list);
+       if (!timer_pending(&local->crypt_deinit_timer)) {
+               local->crypt_deinit_timer.expires = jiffies + HZ;
+               add_timer(&local->crypt_deinit_timer);
+       }
+       spin_unlock_irqrestore(&local->lock, flags);
+}
+
+
+static int prism2_ioctl_siwencode(struct net_device *dev,
+                                 struct iw_request_info *info,
+                                 struct iw_point *erq, char *keybuf)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int i;
+       struct ieee80211_crypt_data **crypt;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       i = erq->flags & IW_ENCODE_INDEX;
+       if (i < 1 || i > 4)
+               i = local->tx_keyidx;
+       else
+               i--;
+       if (i < 0 || i >= WEP_KEYS)
+               return -EINVAL;
+
+       crypt = &local->crypt[i];
+
+       if (erq->flags & IW_ENCODE_DISABLED) {
+               if (*crypt)
+                       prism2_crypt_delayed_deinit(local, crypt);
+               goto done;
+       }
+
+       if (*crypt != NULL && (*crypt)->ops != NULL &&
+           strcmp((*crypt)->ops->name, "WEP") != 0) {
+               /* changing to use WEP; deinit previously used algorithm */
+               prism2_crypt_delayed_deinit(local, crypt);
+       }
+
+       if (*crypt == NULL) {
+               struct ieee80211_crypt_data *new_crypt;
+
+               /* take WEP into use */
+               new_crypt = (struct ieee80211_crypt_data *)
+                       kmalloc(sizeof(struct ieee80211_crypt_data),
+                               GFP_KERNEL);
+               if (new_crypt == NULL)
+                       return -ENOMEM;
+               memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
+               new_crypt->ops = ieee80211_get_crypto_ops("WEP");
+               if (!new_crypt->ops) {
+                       request_module("ieee80211_crypt_wep");
+                       new_crypt->ops = ieee80211_get_crypto_ops("WEP");
+               }
+               if (new_crypt->ops)
+                       new_crypt->priv = new_crypt->ops->init(i);
+               if (!new_crypt->ops || !new_crypt->priv) {
+                       kfree(new_crypt);
+                       new_crypt = NULL;
+
+                       printk(KERN_WARNING "%s: could not initialize WEP: "
+                              "load module hostap_crypt_wep.o\n",
+                              dev->name);
+                       return -EOPNOTSUPP;
+               }
+               *crypt = new_crypt;
+       }
+
+       if (erq->length > 0) {
+               int len = erq->length <= 5 ? 5 : 13;
+               int first = 1, j;
+               if (len > erq->length)
+                       memset(keybuf + erq->length, 0, len - erq->length);
+               (*crypt)->ops->set_key(keybuf, len, NULL, (*crypt)->priv);
+               for (j = 0; j < WEP_KEYS; j++) {
+                       if (j != i && local->crypt[j]) {
+                               first = 0;
+                               break;
+                       }
+               }
+               if (first)
+                       local->tx_keyidx = i;
+       } else {
+               /* No key data - just set the default TX key index */
+               local->tx_keyidx = i;
+       }
+
+ done:
+       local->open_wep = erq->flags & IW_ENCODE_OPEN;
+
+       if (hostap_set_encryption(local)) {
+               printk(KERN_DEBUG "%s: set_encryption failed\n", dev->name);
+               return -EINVAL;
+       }
+
+       /* Do not reset port0 if card is in Managed mode since resetting will
+        * generate new IEEE 802.11 authentication which may end up in looping
+        * with IEEE 802.1X. Prism2 documentation seem to require port reset
+        * after WEP configuration. However, keys are apparently changed at
+        * least in Managed mode. */
+       if (local->iw_mode != IW_MODE_INFRA && local->func->reset_port(dev)) {
+               printk(KERN_DEBUG "%s: reset_port failed\n", dev->name);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+
+static int prism2_ioctl_giwencode(struct net_device *dev,
+                                 struct iw_request_info *info,
+                                 struct iw_point *erq, char *key)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int i, len;
+       u16 val;
+       struct ieee80211_crypt_data *crypt;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       i = erq->flags & IW_ENCODE_INDEX;
+       if (i < 1 || i > 4)
+               i = local->tx_keyidx;
+       else
+               i--;
+       if (i < 0 || i >= WEP_KEYS)
+               return -EINVAL;
+
+       crypt = local->crypt[i];
+       erq->flags = i + 1;
+
+       if (crypt == NULL || crypt->ops == NULL) {
+               erq->length = 0;
+               erq->flags |= IW_ENCODE_DISABLED;
+               return 0;
+       }
+
+       if (strcmp(crypt->ops->name, "WEP") != 0) {
+               /* only WEP is supported with wireless extensions, so just
+                * report that encryption is used */
+               erq->length = 0;
+               erq->flags |= IW_ENCODE_ENABLED;
+               return 0;
+       }
+
+       /* Reads from HFA384X_RID_CNFDEFAULTKEY* return bogus values, so show
+        * the keys from driver buffer */
+       len = crypt->ops->get_key(key, WEP_KEY_LEN, NULL, crypt->priv);
+       erq->length = (len >= 0 ? len : 0);
+
+       if (local->func->get_rid(dev, HFA384X_RID_CNFWEPFLAGS, &val, 2, 1) < 0)
+       {
+               printk("CNFWEPFLAGS reading failed\n");
+               return -EOPNOTSUPP;
+       }
+       le16_to_cpus(&val);
+       if (val & HFA384X_WEPFLAGS_PRIVACYINVOKED)
+               erq->flags |= IW_ENCODE_ENABLED;
+       else
+               erq->flags |= IW_ENCODE_DISABLED;
+       if (val & HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED)
+               erq->flags |= IW_ENCODE_RESTRICTED;
+       else
+               erq->flags |= IW_ENCODE_OPEN;
+
+       return 0;
+}
+
+
+static int hostap_set_rate(struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int ret, basic_rates;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       basic_rates = local->basic_rates & local->tx_rate_control;
+       if (!basic_rates || basic_rates != local->basic_rates) {
+               printk(KERN_INFO "%s: updating basic rate set automatically "
+                      "to match with the new supported rate set\n",
+                      dev->name);
+               if (!basic_rates)
+                       basic_rates = local->tx_rate_control;
+
+               local->basic_rates = basic_rates;
+               if (hostap_set_word(dev, HFA384X_RID_CNFBASICRATES,
+                                   basic_rates))
+                       printk(KERN_WARNING "%s: failed to set "
+                              "cnfBasicRates\n", dev->name);
+       }
+
+       ret = (hostap_set_word(dev, HFA384X_RID_TXRATECONTROL,
+                              local->tx_rate_control) ||
+              hostap_set_word(dev, HFA384X_RID_CNFSUPPORTEDRATES,
+                              local->tx_rate_control) ||
+              local->func->reset_port(dev));
+
+       if (ret) {
+               printk(KERN_WARNING "%s: TXRateControl/cnfSupportedRates "
+                      "setting to 0x%x failed\n",
+                      dev->name, local->tx_rate_control);
+       }
+
+       /* Update TX rate configuration for all STAs based on new operational
+        * rate set. */
+       hostap_update_rates(local);
+
+       return ret;
+}
+
+
+static int prism2_ioctl_siwrate(struct net_device *dev,
+                               struct iw_request_info *info,
+                               struct iw_param *rrq, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (rrq->fixed) {
+               switch (rrq->value) {
+               case 11000000:
+                       local->tx_rate_control = HFA384X_RATES_11MBPS;
+                       break;
+               case 5500000:
+                       local->tx_rate_control = HFA384X_RATES_5MBPS;
+                       break;
+               case 2000000:
+                       local->tx_rate_control = HFA384X_RATES_2MBPS;
+                       break;
+               case 1000000:
+                       local->tx_rate_control = HFA384X_RATES_1MBPS;
+                       break;
+               default:
+                       local->tx_rate_control = HFA384X_RATES_1MBPS |
+                               HFA384X_RATES_2MBPS | HFA384X_RATES_5MBPS |
+                               HFA384X_RATES_11MBPS;
+                       break;
+               }
+       } else {
+               switch (rrq->value) {
+               case 11000000:
+                       local->tx_rate_control = HFA384X_RATES_1MBPS |
+                               HFA384X_RATES_2MBPS | HFA384X_RATES_5MBPS |
+                               HFA384X_RATES_11MBPS;
+                       break;
+               case 5500000:
+                       local->tx_rate_control = HFA384X_RATES_1MBPS |
+                               HFA384X_RATES_2MBPS | HFA384X_RATES_5MBPS;
+                       break;
+               case 2000000:
+                       local->tx_rate_control = HFA384X_RATES_1MBPS |
+                               HFA384X_RATES_2MBPS;
+                       break;
+               case 1000000:
+                       local->tx_rate_control = HFA384X_RATES_1MBPS;
+                       break;
+               default:
+                       local->tx_rate_control = HFA384X_RATES_1MBPS |
+                               HFA384X_RATES_2MBPS | HFA384X_RATES_5MBPS |
+                               HFA384X_RATES_11MBPS;
+                       break;
+               }
+       }
+
+       return hostap_set_rate(dev);
+}
+
+
+static int prism2_ioctl_giwrate(struct net_device *dev,
+                               struct iw_request_info *info,
+                               struct iw_param *rrq, char *extra)
+{
+       u16 val;
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int ret = 0;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (local->func->get_rid(dev, HFA384X_RID_TXRATECONTROL, &val, 2, 1) <
+           0)
+               return -EINVAL;
+
+       if ((val & 0x1) && (val > 1))
+               rrq->fixed = 0;
+       else
+               rrq->fixed = 1;
+
+       if (local->iw_mode == IW_MODE_MASTER && local->ap != NULL &&
+           !local->fw_tx_rate_control) {
+               /* HFA384X_RID_CURRENTTXRATE seems to always be 2 Mbps in
+                * Host AP mode, so use the recorded TX rate of the last sent
+                * frame */
+               rrq->value = local->ap->last_tx_rate > 0 ?
+                       local->ap->last_tx_rate * 100000 : 11000000;
+               return 0;
+       }
+
+       if (local->func->get_rid(dev, HFA384X_RID_CURRENTTXRATE, &val, 2, 1) <
+           0)
+               return -EINVAL;
+
+       switch (val) {
+       case HFA384X_RATES_1MBPS:
+               rrq->value = 1000000;
+               break;
+       case HFA384X_RATES_2MBPS:
+               rrq->value = 2000000;
+               break;
+       case HFA384X_RATES_5MBPS:
+               rrq->value = 5500000;
+               break;
+       case HFA384X_RATES_11MBPS:
+               rrq->value = 11000000;
+               break;
+       default:
+               /* should not happen */
+               rrq->value = 11000000;
+               ret = -EINVAL;
+               break;
+       }
+
+       return ret;
+}
+
+
+static int prism2_ioctl_siwsens(struct net_device *dev,
+                               struct iw_request_info *info,
+                               struct iw_param *sens, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       /* Set the desired AP density */
+       if (sens->value < 1 || sens->value > 3)
+               return -EINVAL;
+
+       if (hostap_set_word(dev, HFA384X_RID_CNFSYSTEMSCALE, sens->value) ||
+           local->func->reset_port(dev))
+               return -EINVAL;
+
+       return 0;
+}
+
+static int prism2_ioctl_giwsens(struct net_device *dev,
+                               struct iw_request_info *info,
+                               struct iw_param *sens, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       u16 val;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       /* Get the current AP density */
+       if (local->func->get_rid(dev, HFA384X_RID_CNFSYSTEMSCALE, &val, 2, 1) <
+           0)
+               return -EINVAL;
+
+       sens->value = __le16_to_cpu(val);
+       sens->fixed = 1;
+
+       return 0;
+}
+
+
+/* Deprecated in new wireless extension API */
+static int prism2_ioctl_giwaplist(struct net_device *dev,
+                                 struct iw_request_info *info,
+                                 struct iw_point *data, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       struct sockaddr *addr;
+       struct iw_quality *qual;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (local->iw_mode != IW_MODE_MASTER) {
+               printk(KERN_DEBUG "SIOCGIWAPLIST is currently only supported "
+                      "in Host AP mode\n");
+               data->length = 0;
+               return -EOPNOTSUPP;
+       }
+
+       addr = kmalloc(sizeof(struct sockaddr) * IW_MAX_AP, GFP_KERNEL);
+       qual = kmalloc(sizeof(struct iw_quality) * IW_MAX_AP, GFP_KERNEL);
+       if (addr == NULL || qual == NULL) {
+               kfree(addr);
+               kfree(qual);
+               data->length = 0;
+               return -ENOMEM;
+       }
+
+       data->length = prism2_ap_get_sta_qual(local, addr, qual, IW_MAX_AP, 1);
+
+       memcpy(extra, &addr, sizeof(struct sockaddr) * data->length);
+       data->flags = 1; /* has quality information */
+       memcpy(extra + sizeof(struct sockaddr) * data->length, &qual,
+              sizeof(struct iw_quality) * data->length);
+
+       kfree(addr);
+       kfree(qual);
+
+       return 0;
+}
+
+
+static int prism2_ioctl_siwrts(struct net_device *dev,
+                              struct iw_request_info *info,
+                              struct iw_param *rts, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       u16 val;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (rts->disabled)
+               val = __constant_cpu_to_le16(2347);
+       else if (rts->value < 0 || rts->value > 2347)
+               return -EINVAL;
+       else
+               val = __cpu_to_le16(rts->value);
+
+       if (local->func->set_rid(dev, HFA384X_RID_RTSTHRESHOLD, &val, 2) ||
+           local->func->reset_port(dev))
+               return -EINVAL;
+
+       local->rts_threshold = rts->value;
+
+       return 0;
+}
+
+static int prism2_ioctl_giwrts(struct net_device *dev,
+                              struct iw_request_info *info,
+                              struct iw_param *rts, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       u16 val;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (local->func->get_rid(dev, HFA384X_RID_RTSTHRESHOLD, &val, 2, 1) <
+           0)
+               return -EINVAL;
+
+       rts->value = __le16_to_cpu(val);
+       rts->disabled = (rts->value == 2347);
+       rts->fixed = 1;
+
+       return 0;
+}
+
+
+static int prism2_ioctl_siwfrag(struct net_device *dev,
+                               struct iw_request_info *info,
+                               struct iw_param *rts, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       u16 val;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (rts->disabled)
+               val = __constant_cpu_to_le16(2346);
+       else if (rts->value < 256 || rts->value > 2346)
+               return -EINVAL;
+       else
+               val = __cpu_to_le16(rts->value & ~0x1); /* even numbers only */
+
+       local->fragm_threshold = rts->value & ~0x1;
+       if (local->func->set_rid(dev, HFA384X_RID_FRAGMENTATIONTHRESHOLD, &val,
+                                2)
+           || local->func->reset_port(dev))
+               return -EINVAL;
+
+       return 0;
+}
+
+static int prism2_ioctl_giwfrag(struct net_device *dev,
+                               struct iw_request_info *info,
+                               struct iw_param *rts, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       u16 val;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (local->func->get_rid(dev, HFA384X_RID_FRAGMENTATIONTHRESHOLD,
+                                &val, 2, 1) < 0)
+               return -EINVAL;
+
+       rts->value = __le16_to_cpu(val);
+       rts->disabled = (rts->value == 2346);
+       rts->fixed = 1;
+
+       return 0;
+}
+
+
+#ifndef PRISM2_NO_STATION_MODES
+static int hostap_join_ap(struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       struct hfa384x_join_request req;
+       unsigned long flags;
+       int i;
+       struct hfa384x_hostscan_result *entry;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       memcpy(req.bssid, local->preferred_ap, ETH_ALEN);
+       req.channel = 0;
+
+       spin_lock_irqsave(&local->lock, flags);
+       for (i = 0; i < local->last_scan_results_count; i++) {
+               if (!local->last_scan_results)
+                       break;
+               entry = &local->last_scan_results[i];
+               if (memcmp(local->preferred_ap, entry->bssid, ETH_ALEN) == 0) {
+                       req.channel = entry->chid;
+                       break;
+               }
+       }
+       spin_unlock_irqrestore(&local->lock, flags);
+
+       if (local->func->set_rid(dev, HFA384X_RID_JOINREQUEST, &req,
+                                sizeof(req))) {
+               printk(KERN_DEBUG "%s: JoinRequest " MACSTR
+                      " failed\n",
+                      dev->name, MAC2STR(local->preferred_ap));
+               return -1;
+       }
+
+       printk(KERN_DEBUG "%s: Trying to join BSSID " MACSTR "\n",
+              dev->name, MAC2STR(local->preferred_ap));
+
+       return 0;
+}
+#endif /* PRISM2_NO_STATION_MODES */
+
+
+static int prism2_ioctl_siwap(struct net_device *dev,
+                             struct iw_request_info *info,
+                             struct sockaddr *ap_addr, char *extra)
+{
+#ifdef PRISM2_NO_STATION_MODES
+       return -EOPNOTSUPP;
+#else /* PRISM2_NO_STATION_MODES */
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       memcpy(local->preferred_ap, &ap_addr->sa_data, ETH_ALEN);
+
+       if (local->host_roaming == 1 && local->iw_mode == IW_MODE_INFRA) {
+               struct hfa384x_scan_request scan_req;
+               memset(&scan_req, 0, sizeof(scan_req));
+               scan_req.channel_list = __constant_cpu_to_le16(0x3fff);
+               scan_req.txrate = __constant_cpu_to_le16(HFA384X_RATES_1MBPS);
+               if (local->func->set_rid(dev, HFA384X_RID_SCANREQUEST,
+                                        &scan_req, sizeof(scan_req))) {
+                       printk(KERN_DEBUG "%s: ScanResults request failed - "
+                              "preferred AP delayed to next unsolicited "
+                              "scan\n", dev->name);
+               }
+       } else if (local->host_roaming == 2 &&
+                  local->iw_mode == IW_MODE_INFRA) {
+               if (hostap_join_ap(dev))
+                       return -EINVAL;
+       } else {
+               printk(KERN_DEBUG "%s: Preferred AP (SIOCSIWAP) is used only "
+                      "in Managed mode when host_roaming is enabled\n",
+                      dev->name);
+       }
+
+       return 0;
+#endif /* PRISM2_NO_STATION_MODES */
+}
+
+static int prism2_ioctl_giwap(struct net_device *dev,
+                             struct iw_request_info *info,
+                             struct sockaddr *ap_addr, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       ap_addr->sa_family = ARPHRD_ETHER;
+       switch (iface->type) {
+       case HOSTAP_INTERFACE_AP:
+               memcpy(&ap_addr->sa_data, dev->dev_addr, ETH_ALEN);
+               break;
+       case HOSTAP_INTERFACE_STA:
+               memcpy(&ap_addr->sa_data, local->assoc_ap_addr, ETH_ALEN);
+               break;
+       case HOSTAP_INTERFACE_WDS:
+               memcpy(&ap_addr->sa_data, iface->u.wds.remote_addr, ETH_ALEN);
+               break;
+       default:
+               if (local->func->get_rid(dev, HFA384X_RID_CURRENTBSSID,
+                                        &ap_addr->sa_data, ETH_ALEN, 1) < 0)
+                       return -EOPNOTSUPP;
+
+               /* local->bssid is also updated in LinkStatus handler when in
+                * station mode */
+               memcpy(local->bssid, &ap_addr->sa_data, ETH_ALEN);
+               break;
+       }
+
+       return 0;
+}
+
+
+static int prism2_ioctl_siwnickn(struct net_device *dev,
+                                struct iw_request_info *info,
+                                struct iw_point *data, char *nickname)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       memset(local->name, 0, sizeof(local->name));
+       memcpy(local->name, nickname, data->length);
+       local->name_set = 1;
+
+       if (hostap_set_string(dev, HFA384X_RID_CNFOWNNAME, local->name) ||
+           local->func->reset_port(dev))
+               return -EINVAL;
+
+       return 0;
+}
+
+static int prism2_ioctl_giwnickn(struct net_device *dev,
+                                struct iw_request_info *info,
+                                struct iw_point *data, char *nickname)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int len;
+       char name[MAX_NAME_LEN + 3];
+       u16 val;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       len = local->func->get_rid(dev, HFA384X_RID_CNFOWNNAME,
+                                  &name, MAX_NAME_LEN + 2, 0);
+       val = __le16_to_cpu(*(u16 *) name);
+       if (len > MAX_NAME_LEN + 2 || len < 0 || val > MAX_NAME_LEN)
+               return -EOPNOTSUPP;
+
+       name[val + 2] = '\0';
+       data->length = val + 1;
+       memcpy(nickname, name + 2, val + 1);
+
+       return 0;
+}
+
+
+static int prism2_ioctl_siwfreq(struct net_device *dev,
+                               struct iw_request_info *info,
+                               struct iw_freq *freq, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       /* freq => chan. */
+       if (freq->e == 1 &&
+           freq->m / 100000 >= freq_list[0] &&
+           freq->m / 100000 <= freq_list[FREQ_COUNT - 1]) {
+               int ch;
+               int fr = freq->m / 100000;
+               for (ch = 0; ch < FREQ_COUNT; ch++) {
+                       if (fr == freq_list[ch]) {
+                               freq->e = 0;
+                               freq->m = ch + 1;
+                               break;
+                       }
+               }
+       }
+
+       if (freq->e != 0 || freq->m < 1 || freq->m > FREQ_COUNT ||
+           !(local->channel_mask & (1 << (freq->m - 1))))
+               return -EINVAL;
+
+       local->channel = freq->m; /* channel is used in prism2_setup_rids() */
+       if (hostap_set_word(dev, HFA384X_RID_CNFOWNCHANNEL, local->channel) ||
+           local->func->reset_port(dev))
+               return -EINVAL;
+
+       return 0;
+}
+
+static int prism2_ioctl_giwfreq(struct net_device *dev,
+                               struct iw_request_info *info,
+                               struct iw_freq *freq, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       u16 val;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (local->func->get_rid(dev, HFA384X_RID_CURRENTCHANNEL, &val, 2, 1) <
+           0)
+               return -EINVAL;
+
+       le16_to_cpus(&val);
+       if (val < 1 || val > FREQ_COUNT)
+               return -EINVAL;
+
+       freq->m = freq_list[val - 1] * 100000;
+       freq->e = 1;
+
+       return 0;
+}
+
+
+static void hostap_monitor_set_type(local_info_t *local)
+{
+       struct net_device *dev = local->ddev;
+
+       if (dev == NULL)
+               return;
+
+       if (local->monitor_type == PRISM2_MONITOR_PRISM ||
+           local->monitor_type == PRISM2_MONITOR_CAPHDR) {
+               dev->type = ARPHRD_IEEE80211_PRISM;
+               dev->hard_header_parse =
+                       hostap_80211_prism_header_parse;
+       } else {
+               dev->type = ARPHRD_IEEE80211;
+               dev->hard_header_parse = hostap_80211_header_parse;
+       }
+}
+
+
+static int prism2_ioctl_siwessid(struct net_device *dev,
+                                struct iw_request_info *info,
+                                struct iw_point *data, char *ssid)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (iface->type == HOSTAP_INTERFACE_WDS)
+               return -EOPNOTSUPP;
+
+       if (data->flags == 0)
+               ssid[0] = '\0'; /* ANY */
+
+       if (local->iw_mode == IW_MODE_MASTER && ssid[0] == '\0') {
+               /* Setting SSID to empty string seems to kill the card in
+                * Host AP mode */
+               printk(KERN_DEBUG "%s: Host AP mode does not support "
+                      "'Any' essid\n", dev->name);
+               return -EINVAL;
+       }
+
+       memcpy(local->essid, ssid, data->length);
+       local->essid[data->length] = '\0';
+
+       if ((!local->fw_ap &&
+            hostap_set_string(dev, HFA384X_RID_CNFDESIREDSSID, local->essid))
+           || hostap_set_string(dev, HFA384X_RID_CNFOWNSSID, local->essid) ||
+           local->func->reset_port(dev))
+               return -EINVAL;
+
+       return 0;
+}
+
+static int prism2_ioctl_giwessid(struct net_device *dev,
+                                struct iw_request_info *info,
+                                struct iw_point *data, char *essid)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       u16 val;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (iface->type == HOSTAP_INTERFACE_WDS)
+               return -EOPNOTSUPP;
+
+       data->flags = 1; /* active */
+       if (local->iw_mode == IW_MODE_MASTER) {
+               data->length = strlen(local->essid);
+               memcpy(essid, local->essid, IW_ESSID_MAX_SIZE);
+       } else {
+               int len;
+               char ssid[MAX_SSID_LEN + 2];
+               memset(ssid, 0, sizeof(ssid));
+               len = local->func->get_rid(dev, HFA384X_RID_CURRENTSSID,
+                                          &ssid, MAX_SSID_LEN + 2, 0);
+               val = __le16_to_cpu(*(u16 *) ssid);
+               if (len > MAX_SSID_LEN + 2 || len < 0 || val > MAX_SSID_LEN) {
+                       return -EOPNOTSUPP;
+               }
+               data->length = val;
+               memcpy(essid, ssid + 2, IW_ESSID_MAX_SIZE);
+       }
+
+       return 0;
+}
+
+
+static int prism2_ioctl_giwrange(struct net_device *dev,
+                                struct iw_request_info *info,
+                                struct iw_point *data, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       struct iw_range *range = (struct iw_range *) extra;
+       u8 rates[10];
+       u16 val;
+       int i, len, over2;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       data->length = sizeof(struct iw_range);
+       memset(range, 0, sizeof(struct iw_range));
+
+       /* TODO: could fill num_txpower and txpower array with
+        * something; however, there are 128 different values.. */
+
+       range->txpower_capa = IW_TXPOW_DBM;
+
+       if (local->iw_mode == IW_MODE_INFRA || local->iw_mode == IW_MODE_ADHOC)
+       {
+               range->min_pmp = 1 * 1024;
+               range->max_pmp = 65535 * 1024;
+               range->min_pmt = 1 * 1024;
+               range->max_pmt = 1000 * 1024;
+               range->pmp_flags = IW_POWER_PERIOD;
+               range->pmt_flags = IW_POWER_TIMEOUT;
+               range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
+                       IW_POWER_UNICAST_R | IW_POWER_ALL_R;
+       }
+
+       range->we_version_compiled = WIRELESS_EXT;
+       range->we_version_source = 18;
+
+       range->retry_capa = IW_RETRY_LIMIT;
+       range->retry_flags = IW_RETRY_LIMIT;
+       range->min_retry = 0;
+       range->max_retry = 255;
+
+       range->num_channels = FREQ_COUNT;
+
+       val = 0;
+       for (i = 0; i < FREQ_COUNT; i++) {
+               if (local->channel_mask & (1 << i)) {
+                       range->freq[val].i = i + 1;
+                       range->freq[val].m = freq_list[i] * 100000;
+                       range->freq[val].e = 1;
+                       val++;
+               }
+               if (val == IW_MAX_FREQUENCIES)
+                       break;
+       }
+       range->num_frequency = val;
+
+       if (local->sta_fw_ver >= PRISM2_FW_VER(1,3,1)) {
+               range->max_qual.qual = 70; /* what is correct max? This was not
+                                           * documented exactly. At least
+                                           * 69 has been observed. */
+               range->max_qual.level = 0; /* dB */
+               range->max_qual.noise = 0; /* dB */
+
+               /* What would be suitable values for "average/typical" qual? */
+               range->avg_qual.qual = 20;
+               range->avg_qual.level = -60;
+               range->avg_qual.noise = -95;
+       } else {
+               range->max_qual.qual = 92; /* 0 .. 92 */
+               range->max_qual.level = 154; /* 27 .. 154 */
+               range->max_qual.noise = 154; /* 27 .. 154 */
+       }
+       range->sensitivity = 3;
+
+       range->max_encoding_tokens = WEP_KEYS;
+       range->num_encoding_sizes = 2;
+       range->encoding_size[0] = 5;
+       range->encoding_size[1] = 13;
+
+       over2 = 0;
+       len = prism2_get_datarates(dev, rates);
+       range->num_bitrates = 0;
+       for (i = 0; i < len; i++) {
+               if (range->num_bitrates < IW_MAX_BITRATES) {
+                       range->bitrate[range->num_bitrates] =
+                               rates[i] * 500000;
+                       range->num_bitrates++;
+               }
+               if (rates[i] == 0x0b || rates[i] == 0x16)
+                       over2 = 1;
+       }
+       /* estimated maximum TCP throughput values (bps) */
+       range->throughput = over2 ? 5500000 : 1500000;
+
+       range->min_rts = 0;
+       range->max_rts = 2347;
+       range->min_frag = 256;
+       range->max_frag = 2346;
+
+       /* Event capability (kernel + driver) */
+       range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
+                               IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) |
+                               IW_EVENT_CAPA_MASK(SIOCGIWAP) |
+                               IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
+       range->event_capa[1] = IW_EVENT_CAPA_K_1;
+       range->event_capa[4] = (IW_EVENT_CAPA_MASK(IWEVTXDROP) |
+                               IW_EVENT_CAPA_MASK(IWEVCUSTOM) |
+                               IW_EVENT_CAPA_MASK(IWEVREGISTERED) |
+                               IW_EVENT_CAPA_MASK(IWEVEXPIRED));
+
+       range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
+               IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
+
+       return 0;
+}
+
+
+static int hostap_monitor_mode_enable(local_info_t *local)
+{
+       struct net_device *dev = local->dev;
+
+       printk(KERN_DEBUG "Enabling monitor mode\n");
+       hostap_monitor_set_type(local);
+
+       if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE,
+                           HFA384X_PORTTYPE_PSEUDO_IBSS)) {
+               printk(KERN_DEBUG "Port type setting for monitor mode "
+                      "failed\n");
+               return -EOPNOTSUPP;
+       }
+
+       /* Host decrypt is needed to get the IV and ICV fields;
+        * however, monitor mode seems to remove WEP flag from frame
+        * control field */
+       if (hostap_set_word(dev, HFA384X_RID_CNFWEPFLAGS,
+                           HFA384X_WEPFLAGS_HOSTENCRYPT |
+                           HFA384X_WEPFLAGS_HOSTDECRYPT)) {
+               printk(KERN_DEBUG "WEP flags setting failed\n");
+               return -EOPNOTSUPP;
+       }
+
+       if (local->func->reset_port(dev) ||
+           local->func->cmd(dev, HFA384X_CMDCODE_TEST |
+                            (HFA384X_TEST_MONITOR << 8),
+                            0, NULL, NULL)) {
+               printk(KERN_DEBUG "Setting monitor mode failed\n");
+               return -EOPNOTSUPP;
+       }
+
+       return 0;
+}
+
+
+static int hostap_monitor_mode_disable(local_info_t *local)
+{
+       struct net_device *dev = local->ddev;
+
+       if (dev == NULL)
+               return -1;
+
+       printk(KERN_DEBUG "%s: Disabling monitor mode\n", dev->name);
+       dev->type = ARPHRD_ETHER;
+       dev->hard_header_parse = local->saved_eth_header_parse;
+       if (local->func->cmd(dev, HFA384X_CMDCODE_TEST |
+                            (HFA384X_TEST_STOP << 8),
+                            0, NULL, NULL))
+               return -1;
+       return hostap_set_encryption(local);
+}
+
+
+static int prism2_ioctl_siwmode(struct net_device *dev,
+                               struct iw_request_info *info,
+                               __u32 *mode, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int double_reset = 0;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (*mode != IW_MODE_ADHOC && *mode != IW_MODE_INFRA &&
+           *mode != IW_MODE_MASTER && *mode != IW_MODE_REPEAT &&
+           *mode != IW_MODE_MONITOR)
+               return -EOPNOTSUPP;
+
+#ifdef PRISM2_NO_STATION_MODES
+       if (*mode == IW_MODE_ADHOC || *mode == IW_MODE_INFRA)
+               return -EOPNOTSUPP;
+#endif /* PRISM2_NO_STATION_MODES */
+
+       if (*mode == local->iw_mode)
+               return 0;
+
+       if (*mode == IW_MODE_MASTER && local->essid[0] == '\0') {
+               printk(KERN_WARNING "%s: empty SSID not allowed in Master "
+                      "mode\n", dev->name);
+               return -EINVAL;
+       }
+
+       if (local->iw_mode == IW_MODE_MONITOR)
+               hostap_monitor_mode_disable(local);
+
+       if ((local->iw_mode == IW_MODE_ADHOC ||
+            local->iw_mode == IW_MODE_MONITOR) && *mode == IW_MODE_MASTER) {
+               /* There seems to be a firmware bug in at least STA f/w v1.5.6
+                * that leaves beacon frames to use IBSS type when moving from
+                * IBSS to Host AP mode. Doing double Port0 reset seems to be
+                * enough to workaround this. */
+               double_reset = 1;
+       }
+
+       printk(KERN_DEBUG "prism2: %s: operating mode changed "
+              "%d -> %d\n", dev->name, local->iw_mode, *mode);
+       local->iw_mode = *mode;
+
+       if (local->iw_mode == IW_MODE_MONITOR)
+               hostap_monitor_mode_enable(local);
+       else if (local->iw_mode == IW_MODE_MASTER && !local->host_encrypt &&
+                !local->fw_encrypt_ok) {
+               printk(KERN_DEBUG "%s: defaulting to host-based encryption as "
+                      "a workaround for firmware bug in Host AP mode WEP\n",
+                      dev->name);
+               local->host_encrypt = 1;
+       }
+
+       if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE,
+                           hostap_get_porttype(local)))
+               return -EOPNOTSUPP;
+
+       if (local->func->reset_port(dev))
+               return -EINVAL;
+       if (double_reset && local->func->reset_port(dev))
+               return -EINVAL;
+
+       if (local->iw_mode != IW_MODE_INFRA && local->iw_mode != IW_MODE_ADHOC)
+       {
+               /* netif_carrier is used only in client modes for now, so make
+                * sure carrier is on when moving to non-client modes. */
+               netif_carrier_on(local->dev);
+               netif_carrier_on(local->ddev);
+       }
+       return 0;
+}
+
+
+static int prism2_ioctl_giwmode(struct net_device *dev,
+                               struct iw_request_info *info,
+                               __u32 *mode, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       switch (iface->type) {
+       case HOSTAP_INTERFACE_STA:
+               *mode = IW_MODE_INFRA;
+               break;
+       case HOSTAP_INTERFACE_WDS:
+               *mode = IW_MODE_REPEAT;
+               break;
+       default:
+               *mode = local->iw_mode;
+               break;
+       }
+       return 0;
+}
+
+
+static int prism2_ioctl_siwpower(struct net_device *dev,
+                                struct iw_request_info *info,
+                                struct iw_param *wrq, char *extra)
+{
+#ifdef PRISM2_NO_STATION_MODES
+       return -EOPNOTSUPP;
+#else /* PRISM2_NO_STATION_MODES */
+       int ret = 0;
+
+       if (wrq->disabled)
+               return hostap_set_word(dev, HFA384X_RID_CNFPMENABLED, 0);
+
+       switch (wrq->flags & IW_POWER_MODE) {
+       case IW_POWER_UNICAST_R:
+               ret = hostap_set_word(dev, HFA384X_RID_CNFMULTICASTRECEIVE, 0);
+               if (ret)
+                       return ret;
+               ret = hostap_set_word(dev, HFA384X_RID_CNFPMENABLED, 1);
+               if (ret)
+                       return ret;
+               break;
+       case IW_POWER_ALL_R:
+               ret = hostap_set_word(dev, HFA384X_RID_CNFMULTICASTRECEIVE, 1);
+               if (ret)
+                       return ret;
+               ret = hostap_set_word(dev, HFA384X_RID_CNFPMENABLED, 1);
+               if (ret)
+                       return ret;
+               break;
+       case IW_POWER_ON:
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       if (wrq->flags & IW_POWER_TIMEOUT) {
+               ret = hostap_set_word(dev, HFA384X_RID_CNFPMENABLED, 1);
+               if (ret)
+                       return ret;
+               ret = hostap_set_word(dev, HFA384X_RID_CNFPMHOLDOVERDURATION,
+                                     wrq->value / 1024);
+               if (ret)
+                       return ret;
+       }
+       if (wrq->flags & IW_POWER_PERIOD) {
+               ret = hostap_set_word(dev, HFA384X_RID_CNFPMENABLED, 1);
+               if (ret)
+                       return ret;
+               ret = hostap_set_word(dev, HFA384X_RID_CNFMAXSLEEPDURATION,
+                                     wrq->value / 1024);
+               if (ret)
+                       return ret;
+       }
+
+       return ret;
+#endif /* PRISM2_NO_STATION_MODES */
+}
+
+
+static int prism2_ioctl_giwpower(struct net_device *dev,
+                                struct iw_request_info *info,
+                                struct iw_param *rrq, char *extra)
+{
+#ifdef PRISM2_NO_STATION_MODES
+       return -EOPNOTSUPP;
+#else /* PRISM2_NO_STATION_MODES */
+       struct hostap_interface *iface;
+       local_info_t *local;
+       u16 enable, mcast;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (local->func->get_rid(dev, HFA384X_RID_CNFPMENABLED, &enable, 2, 1)
+           < 0)
+               return -EINVAL;
+
+       if (!__le16_to_cpu(enable)) {
+               rrq->disabled = 1;
+               return 0;
+       }
+
+       rrq->disabled = 0;
+
+       if ((rrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
+               u16 timeout;
+               if (local->func->get_rid(dev,
+                                        HFA384X_RID_CNFPMHOLDOVERDURATION,
+                                        &timeout, 2, 1) < 0)
+                       return -EINVAL;
+
+               rrq->flags = IW_POWER_TIMEOUT;
+               rrq->value = __le16_to_cpu(timeout) * 1024;
+       } else {
+               u16 period;
+               if (local->func->get_rid(dev, HFA384X_RID_CNFMAXSLEEPDURATION,
+                                        &period, 2, 1) < 0)
+                       return -EINVAL;
+
+               rrq->flags = IW_POWER_PERIOD;
+               rrq->value = __le16_to_cpu(period) * 1024;
+       }
+
+       if (local->func->get_rid(dev, HFA384X_RID_CNFMULTICASTRECEIVE, &mcast,
+                                2, 1) < 0)
+               return -EINVAL;
+
+       if (__le16_to_cpu(mcast))
+               rrq->flags |= IW_POWER_ALL_R;
+       else
+               rrq->flags |= IW_POWER_UNICAST_R;
+
+       return 0;
+#endif /* PRISM2_NO_STATION_MODES */
+}
+
+
+static int prism2_ioctl_siwretry(struct net_device *dev,
+                                struct iw_request_info *info,
+                                struct iw_param *rrq, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (rrq->disabled)
+               return -EINVAL;
+
+       /* setting retry limits is not supported with the current station
+        * firmware code; simulate this with alternative retry count for now */
+       if (rrq->flags == IW_RETRY_LIMIT) {
+               if (rrq->value < 0) {
+                       /* disable manual retry count setting and use firmware
+                        * defaults */
+                       local->manual_retry_count = -1;
+                       local->tx_control &= ~HFA384X_TX_CTRL_ALT_RTRY;
+               } else {
+                       if (hostap_set_word(dev, HFA384X_RID_CNFALTRETRYCOUNT,
+                                           rrq->value)) {
+                               printk(KERN_DEBUG "%s: Alternate retry count "
+                                      "setting to %d failed\n",
+                                      dev->name, rrq->value);
+                               return -EOPNOTSUPP;
+                       }
+
+                       local->manual_retry_count = rrq->value;
+                       local->tx_control |= HFA384X_TX_CTRL_ALT_RTRY;
+               }
+               return 0;
+       }
+
+       return -EOPNOTSUPP;
+
+#if 0
+       /* what could be done, if firmware would support this.. */
+
+       if (rrq->flags & IW_RETRY_LIMIT) {
+               if (rrq->flags & IW_RETRY_MAX)
+                       HFA384X_RID_LONGRETRYLIMIT = rrq->value;
+               else if (rrq->flags & IW_RETRY_MIN)
+                       HFA384X_RID_SHORTRETRYLIMIT = rrq->value;
+               else {
+                       HFA384X_RID_LONGRETRYLIMIT = rrq->value;
+                       HFA384X_RID_SHORTRETRYLIMIT = rrq->value;
+               }
+
+       }
+
+       if (rrq->flags & IW_RETRY_LIFETIME) {
+               HFA384X_RID_MAXTRANSMITLIFETIME = rrq->value / 1024;
+       }
+
+       return 0;
+#endif /* 0 */
+}
+
+static int prism2_ioctl_giwretry(struct net_device *dev,
+                                struct iw_request_info *info,
+                                struct iw_param *rrq, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       u16 shortretry, longretry, lifetime, altretry;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (local->func->get_rid(dev, HFA384X_RID_SHORTRETRYLIMIT, &shortretry,
+                                2, 1) < 0 ||
+           local->func->get_rid(dev, HFA384X_RID_LONGRETRYLIMIT, &longretry,
+                                2, 1) < 0 ||
+           local->func->get_rid(dev, HFA384X_RID_MAXTRANSMITLIFETIME,
+                                &lifetime, 2, 1) < 0)
+               return -EINVAL;
+
+       le16_to_cpus(&shortretry);
+       le16_to_cpus(&longretry);
+       le16_to_cpus(&lifetime);
+
+       rrq->disabled = 0;
+
+       if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
+               rrq->flags = IW_RETRY_LIFETIME;
+               rrq->value = lifetime * 1024;
+       } else {
+               if (local->manual_retry_count >= 0) {
+                       rrq->flags = IW_RETRY_LIMIT;
+                       if (local->func->get_rid(dev,
+                                                HFA384X_RID_CNFALTRETRYCOUNT,
+                                                &altretry, 2, 1) >= 0)
+                               rrq->value = le16_to_cpu(altretry);
+                       else
+                               rrq->value = local->manual_retry_count;
+               } else if ((rrq->flags & IW_RETRY_MAX)) {
+                       rrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
+                       rrq->value = longretry;
+               } else {
+                       rrq->flags = IW_RETRY_LIMIT;
+                       rrq->value = shortretry;
+                       if (shortretry != longretry)
+                               rrq->flags |= IW_RETRY_MIN;
+               }
+       }
+       return 0;
+}
+
+
+/* Note! This TX power controlling is experimental and should not be used in
+ * production use. It just sets raw power register and does not use any kind of
+ * feedback information from the measured TX power (CR58). This is now
+ * commented out to make sure that it is not used by accident. TX power
+ * configuration will be enabled again after proper algorithm using feedback
+ * has been implemented. */
+
+#ifdef RAW_TXPOWER_SETTING
+/* Map HFA386x's CR31 to and from dBm with some sort of ad hoc mapping..
+ * This version assumes following mapping:
+ * CR31 is 7-bit value with -64 to +63 range.
+ * -64 is mapped into +20dBm and +63 into -43dBm.
+ * This is certainly not an exact mapping for every card, but at least
+ * increasing dBm value should correspond to increasing TX power.
+ */
+
+static int prism2_txpower_hfa386x_to_dBm(u16 val)
+{
+       signed char tmp;
+
+       if (val > 255)
+               val = 255;
+
+       tmp = val;
+       tmp >>= 2;
+
+       return -12 - tmp;
+}
+
+static u16 prism2_txpower_dBm_to_hfa386x(int val)
+{
+       signed char tmp;
+
+       if (val > 20)
+               return 128;
+       else if (val < -43)
+               return 127;
+
+       tmp = val;
+       tmp = -12 - tmp;
+       tmp <<= 2;
+
+       return (unsigned char) tmp;
+}
+#endif /* RAW_TXPOWER_SETTING */
+
+
+static int prism2_ioctl_siwtxpow(struct net_device *dev,
+                                struct iw_request_info *info,
+                                struct iw_param *rrq, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+#ifdef RAW_TXPOWER_SETTING
+       char *tmp;
+#endif
+       u16 val;
+       int ret = 0;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (rrq->disabled) {
+               if (local->txpower_type != PRISM2_TXPOWER_OFF) {
+                       val = 0xff; /* use all standby and sleep modes */
+                       ret = local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
+                                              HFA386X_CR_A_D_TEST_MODES2,
+                                              &val, NULL);
+                       printk(KERN_DEBUG "%s: Turning radio off: %s\n",
+                              dev->name, ret ? "failed" : "OK");
+                       local->txpower_type = PRISM2_TXPOWER_OFF;
+               }
+               return (ret ? -EOPNOTSUPP : 0);
+       }
+
+       if (local->txpower_type == PRISM2_TXPOWER_OFF) {
+               val = 0; /* disable all standby and sleep modes */
+               ret = local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
+                                      HFA386X_CR_A_D_TEST_MODES2, &val, NULL);
+               printk(KERN_DEBUG "%s: Turning radio on: %s\n",
+                      dev->name, ret ? "failed" : "OK");
+               local->txpower_type = PRISM2_TXPOWER_UNKNOWN;
+       }
+
+#ifdef RAW_TXPOWER_SETTING
+       if (!rrq->fixed && local->txpower_type != PRISM2_TXPOWER_AUTO) {
+               printk(KERN_DEBUG "Setting ALC on\n");
+               val = HFA384X_TEST_CFG_BIT_ALC;
+               local->func->cmd(dev, HFA384X_CMDCODE_TEST |
+                                (HFA384X_TEST_CFG_BITS << 8), 1, &val, NULL);
+               local->txpower_type = PRISM2_TXPOWER_AUTO;
+               return 0;
+       }
+
+       if (local->txpower_type != PRISM2_TXPOWER_FIXED) {
+               printk(KERN_DEBUG "Setting ALC off\n");
+               val = HFA384X_TEST_CFG_BIT_ALC;
+               local->func->cmd(dev, HFA384X_CMDCODE_TEST |
+                                (HFA384X_TEST_CFG_BITS << 8), 0, &val, NULL);
+                       local->txpower_type = PRISM2_TXPOWER_FIXED;
+       }
+
+       if (rrq->flags == IW_TXPOW_DBM)
+               tmp = "dBm";
+       else if (rrq->flags == IW_TXPOW_MWATT)
+               tmp = "mW";
+       else
+               tmp = "UNKNOWN";
+       printk(KERN_DEBUG "Setting TX power to %d %s\n", rrq->value, tmp);
+
+       if (rrq->flags != IW_TXPOW_DBM) {
+               printk("SIOCSIWTXPOW with mW is not supported; use dBm\n");
+               return -EOPNOTSUPP;
+       }
+
+       local->txpower = rrq->value;
+       val = prism2_txpower_dBm_to_hfa386x(local->txpower);
+       if (local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
+                            HFA386X_CR_MANUAL_TX_POWER, &val, NULL))
+               ret = -EOPNOTSUPP;
+#else /* RAW_TXPOWER_SETTING */
+       if (rrq->fixed)
+               ret = -EOPNOTSUPP;
+#endif /* RAW_TXPOWER_SETTING */
+
+       return ret;
+}
+
+static int prism2_ioctl_giwtxpow(struct net_device *dev,
+                                struct iw_request_info *info,
+                                struct iw_param *rrq, char *extra)
+{
+#ifdef RAW_TXPOWER_SETTING
+       struct hostap_interface *iface;
+       local_info_t *local;
+       u16 resp0;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       rrq->flags = IW_TXPOW_DBM;
+       rrq->disabled = 0;
+       rrq->fixed = 0;
+
+       if (local->txpower_type == PRISM2_TXPOWER_AUTO) {
+               if (local->func->cmd(dev, HFA384X_CMDCODE_READMIF,
+                                    HFA386X_CR_MANUAL_TX_POWER,
+                                    NULL, &resp0) == 0) {
+                       rrq->value = prism2_txpower_hfa386x_to_dBm(resp0);
+               } else {
+                       /* Could not get real txpower; guess 15 dBm */
+                       rrq->value = 15;
+               }
+       } else if (local->txpower_type == PRISM2_TXPOWER_OFF) {
+               rrq->value = 0;
+               rrq->disabled = 1;
+       } else if (local->txpower_type == PRISM2_TXPOWER_FIXED) {
+               rrq->value = local->txpower;
+               rrq->fixed = 1;
+       } else {
+               printk("SIOCGIWTXPOW - unknown txpower_type=%d\n",
+                      local->txpower_type);
+       }
+       return 0;
+#else /* RAW_TXPOWER_SETTING */
+       return -EOPNOTSUPP;
+#endif /* RAW_TXPOWER_SETTING */
+}
+
+
+#ifndef PRISM2_NO_STATION_MODES
+
+/* HostScan request works with and without host_roaming mode. In addition, it
+ * does not break current association. However, it requires newer station
+ * firmware version (>= 1.3.1) than scan request. */
+static int prism2_request_hostscan(struct net_device *dev,
+                                  u8 *ssid, u8 ssid_len)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       struct hfa384x_hostscan_request scan_req;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       memset(&scan_req, 0, sizeof(scan_req));
+       scan_req.channel_list = cpu_to_le16(local->channel_mask &
+                                           local->scan_channel_mask);
+       scan_req.txrate = __constant_cpu_to_le16(HFA384X_RATES_1MBPS);
+       if (ssid) {
+               if (ssid_len > 32)
+                       return -EINVAL;
+               scan_req.target_ssid_len = cpu_to_le16(ssid_len);
+               memcpy(scan_req.target_ssid, ssid, ssid_len);
+       }
+
+       if (local->func->set_rid(dev, HFA384X_RID_HOSTSCAN, &scan_req,
+                                sizeof(scan_req))) {
+               printk(KERN_DEBUG "%s: HOSTSCAN failed\n", dev->name);
+               return -EINVAL;
+       }
+       return 0;
+}
+
+
+static int prism2_request_scan(struct net_device *dev)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       struct hfa384x_scan_request scan_req;
+       int ret = 0;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       memset(&scan_req, 0, sizeof(scan_req));
+       scan_req.channel_list = cpu_to_le16(local->channel_mask &
+                                           local->scan_channel_mask);
+       scan_req.txrate = __constant_cpu_to_le16(HFA384X_RATES_1MBPS);
+
+       /* FIX:
+        * It seems to be enough to set roaming mode for a short moment to
+        * host-based and then setup scanrequest data and return the mode to
+        * firmware-based.
+        *
+        * Master mode would need to drop to Managed mode for a short while
+        * to make scanning work.. Or sweep through the different channels and
+        * use passive scan based on beacons. */
+
+       if (!local->host_roaming)
+               hostap_set_word(dev, HFA384X_RID_CNFROAMINGMODE,
+                               HFA384X_ROAMING_HOST);
+
+       if (local->func->set_rid(dev, HFA384X_RID_SCANREQUEST, &scan_req,
+                                sizeof(scan_req))) {
+               printk(KERN_DEBUG "SCANREQUEST failed\n");
+               ret = -EINVAL;
+       }
+
+       if (!local->host_roaming)
+               hostap_set_word(dev, HFA384X_RID_CNFROAMINGMODE,
+                               HFA384X_ROAMING_FIRMWARE);
+
+       return 0;
+}
+
+#else /* !PRISM2_NO_STATION_MODES */
+
+static inline int prism2_request_hostscan(struct net_device *dev,
+                                         u8 *ssid, u8 ssid_len)
+{
+       return -EOPNOTSUPP;
+}
+
+
+static inline int prism2_request_scan(struct net_device *dev)
+{
+       return -EOPNOTSUPP;
+}
+
+#endif /* !PRISM2_NO_STATION_MODES */
+
+
+static int prism2_ioctl_siwscan(struct net_device *dev,
+                               struct iw_request_info *info,
+                               struct iw_point *data, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int ret;
+       u8 *ssid = NULL, ssid_len = 0;
+       struct iw_scan_req *req = (struct iw_scan_req *) extra;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (data->length < sizeof(struct iw_scan_req))
+               req = NULL;
+
+       if (local->iw_mode == IW_MODE_MASTER) {
+               /* In master mode, we just return the results of our local
+                * tables, so we don't need to start anything...
+                * Jean II */
+               data->length = 0;
+               return 0;
+       }
+
+       if (!local->dev_enabled)
+               return -ENETDOWN;
+
+       if (req && data->flags & IW_SCAN_THIS_ESSID) {
+               ssid = req->essid;
+               ssid_len = req->essid_len;
+
+               if (ssid_len &&
+                   ((local->iw_mode != IW_MODE_INFRA &&
+                     local->iw_mode != IW_MODE_ADHOC) ||
+                    (local->sta_fw_ver < PRISM2_FW_VER(1,3,1))))
+                       return -EOPNOTSUPP;
+       }
+
+       if (local->sta_fw_ver >= PRISM2_FW_VER(1,3,1))
+               ret = prism2_request_hostscan(dev, ssid, ssid_len);
+       else
+               ret = prism2_request_scan(dev);
+
+       if (ret == 0)
+               local->scan_timestamp = jiffies;
+
+       /* Could inquire F101, F103 or wait for SIOCGIWSCAN and read RID */
+
+       return ret;
+}
+
+
+#ifndef PRISM2_NO_STATION_MODES
+static char * __prism2_translate_scan(local_info_t *local,
+                                     struct hfa384x_hostscan_result *scan,
+                                     struct hostap_bss_info *bss,
+                                     char *current_ev, char *end_buf)
+{
+       int i, chan;
+       struct iw_event iwe;
+       char *current_val;
+       u16 capabilities;
+       u8 *pos;
+       u8 *ssid, *bssid;
+       size_t ssid_len;
+       char *buf;
+
+       if (bss) {
+               ssid = bss->ssid;
+               ssid_len = bss->ssid_len;
+               bssid = bss->bssid;
+       } else {
+               ssid = scan->ssid;
+               ssid_len = le16_to_cpu(scan->ssid_len);
+               bssid = scan->bssid;
+       }
+       if (ssid_len > 32)
+               ssid_len = 32;
+
+       /* First entry *MUST* be the AP MAC address */
+       memset(&iwe, 0, sizeof(iwe));
+       iwe.cmd = SIOCGIWAP;
+       iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
+       memcpy(iwe.u.ap_addr.sa_data, bssid, ETH_ALEN);
+       /* FIX:
+        * I do not know how this is possible, but iwe_stream_add_event
+        * seems to re-order memcpy execution so that len is set only
+        * after copying.. Pre-setting len here "fixes" this, but real
+        * problems should be solved (after which these iwe.len
+        * settings could be removed from this function). */
+       iwe.len = IW_EV_ADDR_LEN;
+       current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
+                                         IW_EV_ADDR_LEN);
+
+       /* Other entries will be displayed in the order we give them */
+
+       memset(&iwe, 0, sizeof(iwe));
+       iwe.cmd = SIOCGIWESSID;
+       iwe.u.data.length = ssid_len;
+       iwe.u.data.flags = 1;
+       iwe.len = IW_EV_POINT_LEN + iwe.u.data.length;
+       current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, ssid);
+
+       memset(&iwe, 0, sizeof(iwe));
+       iwe.cmd = SIOCGIWMODE;
+       if (bss) {
+               capabilities = bss->capab_info;
+       } else {
+               capabilities = le16_to_cpu(scan->capability);
+       }
+       if (capabilities & (WLAN_CAPABILITY_ESS |
+                           WLAN_CAPABILITY_IBSS)) {
+               if (capabilities & WLAN_CAPABILITY_ESS)
+                       iwe.u.mode = IW_MODE_MASTER;
+               else
+                       iwe.u.mode = IW_MODE_ADHOC;
+               iwe.len = IW_EV_UINT_LEN;
+               current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
+                                                 IW_EV_UINT_LEN);
+       }
+
+       memset(&iwe, 0, sizeof(iwe));
+       iwe.cmd = SIOCGIWFREQ;
+       if (scan) {
+               chan = scan->chid;
+       } else if (bss) {
+               chan = bss->chan;
+       } else {
+               chan = 0;
+       }
+
+       if (chan > 0) {
+               iwe.u.freq.m = freq_list[le16_to_cpu(chan - 1)] * 100000;
+               iwe.u.freq.e = 1;
+               iwe.len = IW_EV_FREQ_LEN;
+               current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
+                                                 IW_EV_FREQ_LEN);
+       }
+
+       if (scan) {
+               memset(&iwe, 0, sizeof(iwe));
+               iwe.cmd = IWEVQUAL;
+               if (local->last_scan_type == PRISM2_HOSTSCAN) {
+                       iwe.u.qual.level = le16_to_cpu(scan->sl);
+                       iwe.u.qual.noise = le16_to_cpu(scan->anl);
+               } else {
+                       iwe.u.qual.level =
+                               HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan->sl));
+                       iwe.u.qual.noise =
+                               HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan->anl));
+               }
+               iwe.len = IW_EV_QUAL_LEN;
+               current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
+                                                 IW_EV_QUAL_LEN);
+       }
+
+       memset(&iwe, 0, sizeof(iwe));
+       iwe.cmd = SIOCGIWENCODE;
+       if (capabilities & WLAN_CAPABILITY_PRIVACY)
+               iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
+       else
+               iwe.u.data.flags = IW_ENCODE_DISABLED;
+       iwe.u.data.length = 0;
+       iwe.len = IW_EV_POINT_LEN + iwe.u.data.length;
+       current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, "");
+
+       /* TODO: add SuppRates into BSS table */
+       if (scan) {
+               memset(&iwe, 0, sizeof(iwe));
+               iwe.cmd = SIOCGIWRATE;
+               current_val = current_ev + IW_EV_LCP_LEN;
+               pos = scan->sup_rates;
+               for (i = 0; i < sizeof(scan->sup_rates); i++) {
+                       if (pos[i] == 0)
+                               break;
+                       /* Bit rate given in 500 kb/s units (+ 0x80) */
+                       iwe.u.bitrate.value = ((pos[i] & 0x7f) * 500000);
+                       current_val = iwe_stream_add_value(
+                               current_ev, current_val, end_buf, &iwe,
+                               IW_EV_PARAM_LEN);
+               }
+               /* Check if we added any event */
+               if ((current_val - current_ev) > IW_EV_LCP_LEN)
+                       current_ev = current_val;
+       }
+
+       /* TODO: add BeaconInt,resp_rate,atim into BSS table */
+       buf = kmalloc(MAX_WPA_IE_LEN * 2 + 30, GFP_KERNEL);
+       if (buf && scan) {
+               memset(&iwe, 0, sizeof(iwe));
+               iwe.cmd = IWEVCUSTOM;
+               sprintf(buf, "bcn_int=%d", le16_to_cpu(scan->beacon_interval));
+               iwe.u.data.length = strlen(buf);
+               current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,
+                                                 buf);
+
+               memset(&iwe, 0, sizeof(iwe));
+               iwe.cmd = IWEVCUSTOM;
+               sprintf(buf, "resp_rate=%d", le16_to_cpu(scan->rate));
+               iwe.u.data.length = strlen(buf);
+               current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,
+                                                 buf);
+
+               if (local->last_scan_type == PRISM2_HOSTSCAN &&
+                   (capabilities & WLAN_CAPABILITY_IBSS)) {
+                       memset(&iwe, 0, sizeof(iwe));
+                       iwe.cmd = IWEVCUSTOM;
+                       sprintf(buf, "atim=%d", le16_to_cpu(scan->atim));
+                       iwe.u.data.length = strlen(buf);
+                       current_ev = iwe_stream_add_point(current_ev, end_buf,
+                                                         &iwe, buf);
+               }
+       }
+       kfree(buf);
+
+       if (bss && bss->wpa_ie_len > 0 && bss->wpa_ie_len <= MAX_WPA_IE_LEN) {
+               memset(&iwe, 0, sizeof(iwe));
+               iwe.cmd = IWEVGENIE;
+               iwe.u.data.length = bss->wpa_ie_len;
+               current_ev = iwe_stream_add_point(
+                       current_ev, end_buf, &iwe, bss->wpa_ie);
+       }
+
+       if (bss && bss->rsn_ie_len > 0 && bss->rsn_ie_len <= MAX_WPA_IE_LEN) {
+               memset(&iwe, 0, sizeof(iwe));
+               iwe.cmd = IWEVGENIE;
+               iwe.u.data.length = bss->rsn_ie_len;
+               current_ev = iwe_stream_add_point(
+                       current_ev, end_buf, &iwe, bss->rsn_ie);
+       }
+
+       return current_ev;
+}
+
+
+/* Translate scan data returned from the card to a card independant
+ * format that the Wireless Tools will understand - Jean II */
+static inline int prism2_translate_scan(local_info_t *local,
+                                       char *buffer, int buflen)
+{
+       struct hfa384x_hostscan_result *scan;
+       int entry, hostscan;
+       char *current_ev = buffer;
+       char *end_buf = buffer + buflen;
+       struct list_head *ptr;
+
+       spin_lock_bh(&local->lock);
+
+       list_for_each(ptr, &local->bss_list) {
+               struct hostap_bss_info *bss;
+               bss = list_entry(ptr, struct hostap_bss_info, list);
+               bss->included = 0;
+       }
+
+       hostscan = local->last_scan_type == PRISM2_HOSTSCAN;
+       for (entry = 0; entry < local->last_scan_results_count; entry++) {
+               int found = 0;
+               scan = &local->last_scan_results[entry];
+
+               /* Report every SSID if the AP is using multiple SSIDs. If no
+                * BSS record is found (e.g., when WPA mode is disabled),
+                * report the AP once. */
+               list_for_each(ptr, &local->bss_list) {
+                       struct hostap_bss_info *bss;
+                       bss = list_entry(ptr, struct hostap_bss_info, list);
+                       if (memcmp(bss->bssid, scan->bssid, ETH_ALEN) == 0) {
+                               bss->included = 1;
+                               current_ev = __prism2_translate_scan(
+                                       local, scan, bss, current_ev, end_buf);
+                               found++;
+                       }
+               }
+               if (!found) {
+                       current_ev = __prism2_translate_scan(
+                               local, scan, NULL, current_ev, end_buf);
+               }
+               /* Check if there is space for one more entry */
+               if ((end_buf - current_ev) <= IW_EV_ADDR_LEN) {
+                       /* Ask user space to try again with a bigger buffer */
+                       spin_unlock_bh(&local->lock);
+                       return -E2BIG;
+               }
+       }
+
+       /* Prism2 firmware has limits (32 at least in some versions) for number
+        * of BSSes in scan results. Extend this limit by using local BSS list.
+        */
+       list_for_each(ptr, &local->bss_list) {
+               struct hostap_bss_info *bss;
+               bss = list_entry(ptr, struct hostap_bss_info, list);
+               if (bss->included)
+                       continue;
+               current_ev = __prism2_translate_scan(local, NULL, bss,
+                                                    current_ev, end_buf);
+               /* Check if there is space for one more entry */
+               if ((end_buf - current_ev) <= IW_EV_ADDR_LEN) {
+                       /* Ask user space to try again with a bigger buffer */
+                       spin_unlock_bh(&local->lock);
+                       return -E2BIG;
+               }
+       }
+
+       spin_unlock_bh(&local->lock);
+
+       return current_ev - buffer;
+}
+#endif /* PRISM2_NO_STATION_MODES */
+
+
+static inline int prism2_ioctl_giwscan_sta(struct net_device *dev,
+                                          struct iw_request_info *info,
+                                          struct iw_point *data, char *extra)
+{
+#ifdef PRISM2_NO_STATION_MODES
+       return -EOPNOTSUPP;
+#else /* PRISM2_NO_STATION_MODES */
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int res;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       /* Wait until the scan is finished. We can probably do better
+        * than that - Jean II */
+       if (local->scan_timestamp &&
+           time_before(jiffies, local->scan_timestamp + 3 * HZ)) {
+               /* Important note : we don't want to block the caller
+                * until results are ready for various reasons.
+                * First, managing wait queues is complex and racy
+                * (there may be multiple simultaneous callers).
+                * Second, we grab some rtnetlink lock before comming
+                * here (in dev_ioctl()).
+                * Third, the caller can wait on the Wireless Event
+                * - Jean II */
+               return -EAGAIN;
+       }
+       local->scan_timestamp = 0;
+
+       res = prism2_translate_scan(local, extra, data->length);
+
+       if (res >= 0) {
+               data->length = res;
+               return 0;
+       } else {
+               data->length = 0;
+               return res;
+       }
+#endif /* PRISM2_NO_STATION_MODES */
+}
+
+
+static int prism2_ioctl_giwscan(struct net_device *dev,
+                               struct iw_request_info *info,
+                               struct iw_point *data, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int res;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (local->iw_mode == IW_MODE_MASTER) {
+               /* In MASTER mode, it doesn't make sense to go around
+                * scanning the frequencies and make the stations we serve
+                * wait when what the user is really interested about is the
+                * list of stations and access points we are talking to.
+                * So, just extract results from our cache...
+                * Jean II */
+
+               /* Translate to WE format */
+               res = prism2_ap_translate_scan(dev, extra);
+               if (res >= 0) {
+                       printk(KERN_DEBUG "Scan result translation succeeded "
+                              "(length=%d)\n", res);
+                       data->length = res;
+                       return 0;
+               } else {
+                       printk(KERN_DEBUG
+                              "Scan result translation failed (res=%d)\n",
+                              res);
+                       data->length = 0;
+                       return res;
+               }
+       } else {
+               /* Station mode */
+               return prism2_ioctl_giwscan_sta(dev, info, data, extra);
+       }
+}
+
+
+static const struct iw_priv_args prism2_priv[] = {
+       { PRISM2_IOCTL_MONITOR,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "monitor" },
+       { PRISM2_IOCTL_READMIF,
+         IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1,
+         IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, "readmif" },
+       { PRISM2_IOCTL_WRITEMIF,
+         IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 2, 0, "writemif" },
+       { PRISM2_IOCTL_RESET,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "reset" },
+       { PRISM2_IOCTL_INQUIRE,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "inquire" },
+       { PRISM2_IOCTL_SET_RID_WORD,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "set_rid_word" },
+       { PRISM2_IOCTL_MACCMD,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "maccmd" },
+       { PRISM2_IOCTL_WDS_ADD,
+         IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "wds_add" },
+       { PRISM2_IOCTL_WDS_DEL,
+         IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "wds_del" },
+       { PRISM2_IOCTL_ADDMAC,
+         IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "addmac" },
+       { PRISM2_IOCTL_DELMAC,
+         IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "delmac" },
+       { PRISM2_IOCTL_KICKMAC,
+         IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "kickmac" },
+       /* --- raw access to sub-ioctls --- */
+       { PRISM2_IOCTL_PRISM2_PARAM,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "prism2_param" },
+       { PRISM2_IOCTL_GET_PRISM2_PARAM,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getprism2_param" },
+       /* --- sub-ioctls handlers --- */
+       { PRISM2_IOCTL_PRISM2_PARAM,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
+       { PRISM2_IOCTL_GET_PRISM2_PARAM,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
+       /* --- sub-ioctls definitions --- */
+       { PRISM2_PARAM_TXRATECTRL,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "txratectrl" },
+       { PRISM2_PARAM_TXRATECTRL,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gettxratectrl" },
+       { PRISM2_PARAM_BEACON_INT,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "beacon_int" },
+       { PRISM2_PARAM_BEACON_INT,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getbeacon_int" },
+#ifndef PRISM2_NO_STATION_MODES
+       { PRISM2_PARAM_PSEUDO_IBSS,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "pseudo_ibss" },
+       { PRISM2_PARAM_PSEUDO_IBSS,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getpseudo_ibss" },
+#endif /* PRISM2_NO_STATION_MODES */
+       { PRISM2_PARAM_ALC,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "alc" },
+       { PRISM2_PARAM_ALC,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getalc" },
+       { PRISM2_PARAM_DUMP,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "dump" },
+       { PRISM2_PARAM_DUMP,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getdump" },
+       { PRISM2_PARAM_OTHER_AP_POLICY,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "other_ap_policy" },
+       { PRISM2_PARAM_OTHER_AP_POLICY,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getother_ap_pol" },
+       { PRISM2_PARAM_AP_MAX_INACTIVITY,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "max_inactivity" },
+       { PRISM2_PARAM_AP_MAX_INACTIVITY,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getmax_inactivi" },
+       { PRISM2_PARAM_AP_BRIDGE_PACKETS,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "bridge_packets" },
+       { PRISM2_PARAM_AP_BRIDGE_PACKETS,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getbridge_packe" },
+       { PRISM2_PARAM_DTIM_PERIOD,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "dtim_period" },
+       { PRISM2_PARAM_DTIM_PERIOD,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getdtim_period" },
+       { PRISM2_PARAM_AP_NULLFUNC_ACK,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "nullfunc_ack" },
+       { PRISM2_PARAM_AP_NULLFUNC_ACK,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getnullfunc_ack" },
+       { PRISM2_PARAM_MAX_WDS,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "max_wds" },
+       { PRISM2_PARAM_MAX_WDS,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getmax_wds" },
+       { PRISM2_PARAM_AP_AUTOM_AP_WDS,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "autom_ap_wds" },
+       { PRISM2_PARAM_AP_AUTOM_AP_WDS,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getautom_ap_wds" },
+       { PRISM2_PARAM_AP_AUTH_ALGS,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "ap_auth_algs" },
+       { PRISM2_PARAM_AP_AUTH_ALGS,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getap_auth_algs" },
+       { PRISM2_PARAM_MONITOR_ALLOW_FCSERR,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "allow_fcserr" },
+       { PRISM2_PARAM_MONITOR_ALLOW_FCSERR,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getallow_fcserr" },
+       { PRISM2_PARAM_HOST_ENCRYPT,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "host_encrypt" },
+       { PRISM2_PARAM_HOST_ENCRYPT,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gethost_encrypt" },
+       { PRISM2_PARAM_HOST_DECRYPT,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "host_decrypt" },
+       { PRISM2_PARAM_HOST_DECRYPT,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gethost_decrypt" },
+#ifndef PRISM2_NO_STATION_MODES
+       { PRISM2_PARAM_HOST_ROAMING,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "host_roaming" },
+       { PRISM2_PARAM_HOST_ROAMING,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gethost_roaming" },
+#endif /* PRISM2_NO_STATION_MODES */
+       { PRISM2_PARAM_BCRX_STA_KEY,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "bcrx_sta_key" },
+       { PRISM2_PARAM_BCRX_STA_KEY,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getbcrx_sta_key" },
+       { PRISM2_PARAM_IEEE_802_1X,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "ieee_802_1x" },
+       { PRISM2_PARAM_IEEE_802_1X,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getieee_802_1x" },
+       { PRISM2_PARAM_ANTSEL_TX,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "antsel_tx" },
+       { PRISM2_PARAM_ANTSEL_TX,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getantsel_tx" },
+       { PRISM2_PARAM_ANTSEL_RX,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "antsel_rx" },
+       { PRISM2_PARAM_ANTSEL_RX,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getantsel_rx" },
+       { PRISM2_PARAM_MONITOR_TYPE,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "monitor_type" },
+       { PRISM2_PARAM_MONITOR_TYPE,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getmonitor_type" },
+       { PRISM2_PARAM_WDS_TYPE,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wds_type" },
+       { PRISM2_PARAM_WDS_TYPE,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwds_type" },
+       { PRISM2_PARAM_HOSTSCAN,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hostscan" },
+       { PRISM2_PARAM_HOSTSCAN,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gethostscan" },
+       { PRISM2_PARAM_AP_SCAN,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "ap_scan" },
+       { PRISM2_PARAM_AP_SCAN,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getap_scan" },
+       { PRISM2_PARAM_ENH_SEC,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "enh_sec" },
+       { PRISM2_PARAM_ENH_SEC,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getenh_sec" },
+#ifdef PRISM2_IO_DEBUG
+       { PRISM2_PARAM_IO_DEBUG,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "io_debug" },
+       { PRISM2_PARAM_IO_DEBUG,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getio_debug" },
+#endif /* PRISM2_IO_DEBUG */
+       { PRISM2_PARAM_BASIC_RATES,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "basic_rates" },
+       { PRISM2_PARAM_BASIC_RATES,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getbasic_rates" },
+       { PRISM2_PARAM_OPER_RATES,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "oper_rates" },
+       { PRISM2_PARAM_OPER_RATES,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getoper_rates" },
+       { PRISM2_PARAM_HOSTAPD,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hostapd" },
+       { PRISM2_PARAM_HOSTAPD,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gethostapd" },
+       { PRISM2_PARAM_HOSTAPD_STA,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hostapd_sta" },
+       { PRISM2_PARAM_HOSTAPD_STA,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gethostapd_sta" },
+       { PRISM2_PARAM_WPA,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wpa" },
+       { PRISM2_PARAM_WPA,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwpa" },
+       { PRISM2_PARAM_PRIVACY_INVOKED,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "privacy_invoked" },
+       { PRISM2_PARAM_PRIVACY_INVOKED,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getprivacy_invo" },
+       { PRISM2_PARAM_TKIP_COUNTERMEASURES,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "tkip_countermea" },
+       { PRISM2_PARAM_TKIP_COUNTERMEASURES,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gettkip_counter" },
+       { PRISM2_PARAM_DROP_UNENCRYPTED,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "drop_unencrypte" },
+       { PRISM2_PARAM_DROP_UNENCRYPTED,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getdrop_unencry" },
+       { PRISM2_PARAM_SCAN_CHANNEL_MASK,
+         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "scan_channels" },
+       { PRISM2_PARAM_SCAN_CHANNEL_MASK,
+         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getscan_channel" },
+};
+
+
+static int prism2_ioctl_priv_inquire(struct net_device *dev, int *i)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (local->func->cmd(dev, HFA384X_CMDCODE_INQUIRE, *i, NULL, NULL))
+               return -EOPNOTSUPP;
+
+       return 0;
+}
+
+
+static int prism2_ioctl_priv_prism2_param(struct net_device *dev,
+                                         struct iw_request_info *info,
+                                         void *wrqu, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int *i = (int *) extra;
+       int param = *i;
+       int value = *(i + 1);
+       int ret = 0;
+       u16 val;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       switch (param) {
+       case PRISM2_PARAM_TXRATECTRL:
+               local->fw_tx_rate_control = value;
+               break;
+
+       case PRISM2_PARAM_BEACON_INT:
+               if (hostap_set_word(dev, HFA384X_RID_CNFBEACONINT, value) ||
+                   local->func->reset_port(dev))
+                       ret = -EINVAL;
+               else
+                       local->beacon_int = value;
+               break;
+
+#ifndef PRISM2_NO_STATION_MODES
+       case PRISM2_PARAM_PSEUDO_IBSS:
+               if (value == local->pseudo_adhoc)
+                       break;
+
+               if (value != 0 && value != 1) {
+                       ret = -EINVAL;
+                       break;
+               }
+
+               printk(KERN_DEBUG "prism2: %s: pseudo IBSS change %d -> %d\n",
+                      dev->name, local->pseudo_adhoc, value);
+               local->pseudo_adhoc = value;
+               if (local->iw_mode != IW_MODE_ADHOC)
+                       break;
+
+               if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE,
+                                   hostap_get_porttype(local))) {
+                       ret = -EOPNOTSUPP;
+                       break;
+               }
+
+               if (local->func->reset_port(dev))
+                       ret = -EINVAL;
+               break;
+#endif /* PRISM2_NO_STATION_MODES */
+
+       case PRISM2_PARAM_ALC:
+               printk(KERN_DEBUG "%s: %s ALC\n", dev->name,
+                      value == 0 ? "Disabling" : "Enabling");
+               val = HFA384X_TEST_CFG_BIT_ALC;
+               local->func->cmd(dev, HFA384X_CMDCODE_TEST |
+                                (HFA384X_TEST_CFG_BITS << 8),
+                                value == 0 ? 0 : 1, &val, NULL);
+               break;
+
+       case PRISM2_PARAM_DUMP:
+               local->frame_dump = value;
+               break;
+
+       case PRISM2_PARAM_OTHER_AP_POLICY:
+               if (value < 0 || value > 3) {
+                       ret = -EINVAL;
+                       break;
+               }
+               if (local->ap != NULL)
+                       local->ap->ap_policy = value;
+               break;
+
+       case PRISM2_PARAM_AP_MAX_INACTIVITY:
+               if (value < 0 || value > 7 * 24 * 60 * 60) {
+                       ret = -EINVAL;
+                       break;
+               }
+               if (local->ap != NULL)
+                       local->ap->max_inactivity = value * HZ;
+               break;
+
+       case PRISM2_PARAM_AP_BRIDGE_PACKETS:
+               if (local->ap != NULL)
+                       local->ap->bridge_packets = value;
+               break;
+
+       case PRISM2_PARAM_DTIM_PERIOD:
+               if (value < 0 || value > 65535) {
+                       ret = -EINVAL;
+                       break;
+               }
+               if (hostap_set_word(dev, HFA384X_RID_CNFOWNDTIMPERIOD, value)
+                   || local->func->reset_port(dev))
+                       ret = -EINVAL;
+               else
+                       local->dtim_period = value;
+               break;
+
+       case PRISM2_PARAM_AP_NULLFUNC_ACK:
+               if (local->ap != NULL)
+                       local->ap->nullfunc_ack = value;
+               break;
+
+       case PRISM2_PARAM_MAX_WDS:
+               local->wds_max_connections = value;
+               break;
+
+       case PRISM2_PARAM_AP_AUTOM_AP_WDS:
+               if (local->ap != NULL) {
+                       if (!local->ap->autom_ap_wds && value) {
+                               /* add WDS link to all APs in STA table */
+                               hostap_add_wds_links(local);
+                       }
+                       local->ap->autom_ap_wds = value;
+               }
+               break;
+
+       case PRISM2_PARAM_AP_AUTH_ALGS:
+               local->auth_algs = value;
+               if (hostap_set_auth_algs(local))
+                       ret = -EINVAL;
+               break;
+
+       case PRISM2_PARAM_MONITOR_ALLOW_FCSERR:
+               local->monitor_allow_fcserr = value;
+               break;
+
+       case PRISM2_PARAM_HOST_ENCRYPT:
+               local->host_encrypt = value;
+               if (hostap_set_encryption(local) ||
+                   local->func->reset_port(dev))
+                       ret = -EINVAL;
+               break;
+
+       case PRISM2_PARAM_HOST_DECRYPT:
+               local->host_decrypt = value;
+               if (hostap_set_encryption(local) ||
+                   local->func->reset_port(dev))
+                       ret = -EINVAL;
+               break;
+
+#ifndef PRISM2_NO_STATION_MODES
+       case PRISM2_PARAM_HOST_ROAMING:
+               if (value < 0 || value > 2) {
+                       ret = -EINVAL;
+                       break;
+               }
+               local->host_roaming = value;
+               if (hostap_set_roaming(local) || local->func->reset_port(dev))
+                       ret = -EINVAL;
+               break;
+#endif /* PRISM2_NO_STATION_MODES */
+
+       case PRISM2_PARAM_BCRX_STA_KEY:
+               local->bcrx_sta_key = value;
+               break;
+
+       case PRISM2_PARAM_IEEE_802_1X:
+               local->ieee_802_1x = value;
+               break;
+
+       case PRISM2_PARAM_ANTSEL_TX:
+               if (value < 0 || value > HOSTAP_ANTSEL_HIGH) {
+                       ret = -EINVAL;
+                       break;
+               }
+               local->antsel_tx = value;
+               hostap_set_antsel(local);
+               break;
+
+       case PRISM2_PARAM_ANTSEL_RX:
+               if (value < 0 || value > HOSTAP_ANTSEL_HIGH) {
+                       ret = -EINVAL;
+                       break;
+               }
+               local->antsel_rx = value;
+               hostap_set_antsel(local);
+               break;
+
+       case PRISM2_PARAM_MONITOR_TYPE:
+               if (value != PRISM2_MONITOR_80211 &&
+                   value != PRISM2_MONITOR_CAPHDR &&
+                   value != PRISM2_MONITOR_PRISM) {
+                       ret = -EINVAL;
+                       break;
+               }
+               local->monitor_type = value;
+               if (local->iw_mode == IW_MODE_MONITOR)
+                       hostap_monitor_set_type(local);
+               break;
+
+       case PRISM2_PARAM_WDS_TYPE:
+               local->wds_type = value;
+               break;
+
+       case PRISM2_PARAM_HOSTSCAN:
+       {
+               struct hfa384x_hostscan_request scan_req;
+               u16 rate;
+
+               memset(&scan_req, 0, sizeof(scan_req));
+               scan_req.channel_list = __constant_cpu_to_le16(0x3fff);
+               switch (value) {
+               case 1: rate = HFA384X_RATES_1MBPS; break;
+               case 2: rate = HFA384X_RATES_2MBPS; break;
+               case 3: rate = HFA384X_RATES_5MBPS; break;
+               case 4: rate = HFA384X_RATES_11MBPS; break;
+               default: rate = HFA384X_RATES_1MBPS; break;
+               }
+               scan_req.txrate = cpu_to_le16(rate);
+               /* leave SSID empty to accept all SSIDs */
+
+               if (local->iw_mode == IW_MODE_MASTER) {
+                       if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE,
+                                           HFA384X_PORTTYPE_BSS) ||
+                           local->func->reset_port(dev))
+                               printk(KERN_DEBUG "Leaving Host AP mode "
+                                      "for HostScan failed\n");
+               }
+
+               if (local->func->set_rid(dev, HFA384X_RID_HOSTSCAN, &scan_req,
+                                        sizeof(scan_req))) {
+                       printk(KERN_DEBUG "HOSTSCAN failed\n");
+                       ret = -EINVAL;
+               }
+               if (local->iw_mode == IW_MODE_MASTER) {
+                       wait_queue_t __wait;
+                       init_waitqueue_entry(&__wait, current);
+                       add_wait_queue(&local->hostscan_wq, &__wait);
+                       set_current_state(TASK_INTERRUPTIBLE);
+                       schedule_timeout(HZ);
+                       if (signal_pending(current))
+                               ret = -EINTR;
+                       set_current_state(TASK_RUNNING);
+                       remove_wait_queue(&local->hostscan_wq, &__wait);
+
+                       if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE,
+                                           HFA384X_PORTTYPE_HOSTAP) ||
+                           local->func->reset_port(dev))
+                               printk(KERN_DEBUG "Returning to Host AP mode "
+                                      "after HostScan failed\n");
+               }
+               break;
+       }
+
+       case PRISM2_PARAM_AP_SCAN:
+               local->passive_scan_interval = value;
+               if (timer_pending(&local->passive_scan_timer))
+                       del_timer(&local->passive_scan_timer);
+               if (value > 0) {
+                       local->passive_scan_timer.expires = jiffies +
+                               local->passive_scan_interval * HZ;
+                       add_timer(&local->passive_scan_timer);
+               }
+               break;
+
+       case PRISM2_PARAM_ENH_SEC:
+               if (value < 0 || value > 3) {
+                       ret = -EINVAL;
+                       break;
+               }
+               local->enh_sec = value;
+               if (hostap_set_word(dev, HFA384X_RID_CNFENHSECURITY,
+                                   local->enh_sec) ||
+                   local->func->reset_port(dev)) {
+                       printk(KERN_INFO "%s: cnfEnhSecurity requires STA f/w "
+                              "1.6.3 or newer\n", dev->name);
+                       ret = -EOPNOTSUPP;
+               }
+               break;
+
+#ifdef PRISM2_IO_DEBUG
+       case PRISM2_PARAM_IO_DEBUG:
+               local->io_debug_enabled = value;
+               break;
+#endif /* PRISM2_IO_DEBUG */
+
+       case PRISM2_PARAM_BASIC_RATES:
+               if ((value & local->tx_rate_control) != value || value == 0) {
+                       printk(KERN_INFO "%s: invalid basic rate set - basic "
+                              "rates must be in supported rate set\n",
+                              dev->name);
+                       ret = -EINVAL;
+                       break;
+               }
+               local->basic_rates = value;
+               if (hostap_set_word(dev, HFA384X_RID_CNFBASICRATES,
+                                   local->basic_rates) ||
+                   local->func->reset_port(dev))
+                       ret = -EINVAL;
+               break;
+
+       case PRISM2_PARAM_OPER_RATES:
+               local->tx_rate_control = value;
+               if (hostap_set_rate(dev))
+                       ret = -EINVAL;
+               break;
+
+       case PRISM2_PARAM_HOSTAPD:
+               ret = hostap_set_hostapd(local, value, 1);
+               break;
+
+       case PRISM2_PARAM_HOSTAPD_STA:
+               ret = hostap_set_hostapd_sta(local, value, 1);
+               break;
+
+       case PRISM2_PARAM_WPA:
+               local->wpa = value;
+               if (local->sta_fw_ver < PRISM2_FW_VER(1,7,0))
+                       ret = -EOPNOTSUPP;
+               else if (hostap_set_word(dev, HFA384X_RID_SSNHANDLINGMODE,
+                                        value ? 1 : 0))
+                       ret = -EINVAL;
+               break;
+
+       case PRISM2_PARAM_PRIVACY_INVOKED:
+               local->privacy_invoked = value;
+               if (hostap_set_encryption(local) ||
+                   local->func->reset_port(dev))
+                       ret = -EINVAL;
+               break;
+
+       case PRISM2_PARAM_TKIP_COUNTERMEASURES:
+               local->tkip_countermeasures = value;
+               break;
+
+       case PRISM2_PARAM_DROP_UNENCRYPTED:
+               local->drop_unencrypted = value;
+               break;
+
+       case PRISM2_PARAM_SCAN_CHANNEL_MASK:
+               local->scan_channel_mask = value;
+               break;
+
+       default:
+               printk(KERN_DEBUG "%s: prism2_param: unknown param %d\n",
+                      dev->name, param);
+               ret = -EOPNOTSUPP;
+               break;
+       }
+
+       return ret;
+}
+
+
+static int prism2_ioctl_priv_get_prism2_param(struct net_device *dev,
+                                             struct iw_request_info *info,
+                                             void *wrqu, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int *param = (int *) extra;
+       int ret = 0;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       switch (*param) {
+       case PRISM2_PARAM_TXRATECTRL:
+               *param = local->fw_tx_rate_control;
+               break;
+
+       case PRISM2_PARAM_BEACON_INT:
+               *param = local->beacon_int;
+               break;
+
+       case PRISM2_PARAM_PSEUDO_IBSS:
+               *param = local->pseudo_adhoc;
+               break;
+
+       case PRISM2_PARAM_ALC:
+               ret = -EOPNOTSUPP; /* FIX */
+               break;
+
+       case PRISM2_PARAM_DUMP:
+               *param = local->frame_dump;
+               break;
+
+       case PRISM2_PARAM_OTHER_AP_POLICY:
+               if (local->ap != NULL)
+                       *param = local->ap->ap_policy;
+               else
+                       ret = -EOPNOTSUPP;
+               break;
+
+       case PRISM2_PARAM_AP_MAX_INACTIVITY:
+               if (local->ap != NULL)
+                       *param = local->ap->max_inactivity / HZ;
+               else
+                       ret = -EOPNOTSUPP;
+               break;
+
+       case PRISM2_PARAM_AP_BRIDGE_PACKETS:
+               if (local->ap != NULL)
+                       *param = local->ap->bridge_packets;
+               else
+                       ret = -EOPNOTSUPP;
+               break;
+
+       case PRISM2_PARAM_DTIM_PERIOD:
+               *param = local->dtim_period;
+               break;
+
+       case PRISM2_PARAM_AP_NULLFUNC_ACK:
+               if (local->ap != NULL)
+                       *param = local->ap->nullfunc_ack;
+               else
+                       ret = -EOPNOTSUPP;
+               break;
+
+       case PRISM2_PARAM_MAX_WDS:
+               *param = local->wds_max_connections;
+               break;
+
+       case PRISM2_PARAM_AP_AUTOM_AP_WDS:
+               if (local->ap != NULL)
+                       *param = local->ap->autom_ap_wds;
+               else
+                       ret = -EOPNOTSUPP;
+               break;
+
+       case PRISM2_PARAM_AP_AUTH_ALGS:
+               *param = local->auth_algs;
+               break;
+
+       case PRISM2_PARAM_MONITOR_ALLOW_FCSERR:
+               *param = local->monitor_allow_fcserr;
+               break;
+
+       case PRISM2_PARAM_HOST_ENCRYPT:
+               *param = local->host_encrypt;
+               break;
+
+       case PRISM2_PARAM_HOST_DECRYPT:
+               *param = local->host_decrypt;
+               break;
+
+       case PRISM2_PARAM_HOST_ROAMING:
+               *param = local->host_roaming;
+               break;
+
+       case PRISM2_PARAM_BCRX_STA_KEY:
+               *param = local->bcrx_sta_key;
+               break;
+
+       case PRISM2_PARAM_IEEE_802_1X:
+               *param = local->ieee_802_1x;
+               break;
+
+       case PRISM2_PARAM_ANTSEL_TX:
+               *param = local->antsel_tx;
+               break;
+
+       case PRISM2_PARAM_ANTSEL_RX:
+               *param = local->antsel_rx;
+               break;
+
+       case PRISM2_PARAM_MONITOR_TYPE:
+               *param = local->monitor_type;
+               break;
+
+       case PRISM2_PARAM_WDS_TYPE:
+               *param = local->wds_type;
+               break;
+
+       case PRISM2_PARAM_HOSTSCAN:
+               ret = -EOPNOTSUPP;
+               break;
+
+       case PRISM2_PARAM_AP_SCAN:
+               *param = local->passive_scan_interval;
+               break;
+
+       case PRISM2_PARAM_ENH_SEC:
+               *param = local->enh_sec;
+               break;
+
+#ifdef PRISM2_IO_DEBUG
+       case PRISM2_PARAM_IO_DEBUG:
+               *param = local->io_debug_enabled;
+               break;
+#endif /* PRISM2_IO_DEBUG */
+
+       case PRISM2_PARAM_BASIC_RATES:
+               *param = local->basic_rates;
+               break;
+
+       case PRISM2_PARAM_OPER_RATES:
+               *param = local->tx_rate_control;
+               break;
+
+       case PRISM2_PARAM_HOSTAPD:
+               *param = local->hostapd;
+               break;
+
+       case PRISM2_PARAM_HOSTAPD_STA:
+               *param = local->hostapd_sta;
+               break;
+
+       case PRISM2_PARAM_WPA:
+               if (local->sta_fw_ver < PRISM2_FW_VER(1,7,0))
+                       ret = -EOPNOTSUPP;
+               *param = local->wpa;
+               break;
+
+       case PRISM2_PARAM_PRIVACY_INVOKED:
+               *param = local->privacy_invoked;
+               break;
+
+       case PRISM2_PARAM_TKIP_COUNTERMEASURES:
+               *param = local->tkip_countermeasures;
+               break;
+
+       case PRISM2_PARAM_DROP_UNENCRYPTED:
+               *param = local->drop_unencrypted;
+               break;
+
+       case PRISM2_PARAM_SCAN_CHANNEL_MASK:
+               *param = local->scan_channel_mask;
+               break;
+
+       default:
+               printk(KERN_DEBUG "%s: get_prism2_param: unknown param %d\n",
+                      dev->name, *param);
+               ret = -EOPNOTSUPP;
+               break;
+       }
+
+       return ret;
+}
+
+
+static int prism2_ioctl_priv_readmif(struct net_device *dev,
+                                    struct iw_request_info *info,
+                                    void *wrqu, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       u16 resp0;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       if (local->func->cmd(dev, HFA384X_CMDCODE_READMIF, *extra, NULL,
+                            &resp0))
+               return -EOPNOTSUPP;
+       else
+               *extra = resp0;
+
+       return 0;
+}
+
+
+static int prism2_ioctl_priv_writemif(struct net_device *dev,
+                                     struct iw_request_info *info,
+                                     void *wrqu, char *extra)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       u16 cr, val;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       cr = *extra;
+       val = *(extra + 1);
+       if (local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF, cr, &val, NULL))
+               return -EOPNOTSUPP;
+
+       return 0;
+}
+
+
+static int prism2_ioctl_priv_monitor(struct net_device *dev, int *i)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int ret = 0;
+       u32 mode;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       printk(KERN_DEBUG "%s: process %d (%s) used deprecated iwpriv monitor "
+              "- update software to use iwconfig mode monitor\n",
+              dev->name, current->pid, current->comm);
+
+       /* Backward compatibility code - this can be removed at some point */
+
+       if (*i == 0) {
+               /* Disable monitor mode - old mode was not saved, so go to
+                * Master mode */
+               mode = IW_MODE_MASTER;
+               ret = prism2_ioctl_siwmode(dev, NULL, &mode, NULL);
+       } else if (*i == 1) {
+               /* netlink socket mode is not supported anymore since it did
+                * not separate different devices from each other and was not
+                * best method for delivering large amount of packets to
+                * user space */
+               ret = -EOPNOTSUPP;
+       } else if (*i == 2 || *i == 3) {
+               switch (*i) {
+               case 2:
+                       local->monitor_type = PRISM2_MONITOR_80211;
+                       break;
+               case 3:
+                       local->monitor_type = PRISM2_MONITOR_PRISM;
+                       break;
+               }
+               mode = IW_MODE_MONITOR;
+               ret = prism2_ioctl_siwmode(dev, NULL, &mode, NULL);
+               hostap_monitor_mode_enable(local);
+       } else
+               ret = -EINVAL;
+
+       return ret;
+}
+
+
+static int prism2_ioctl_priv_reset(struct net_device *dev, int *i)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       printk(KERN_DEBUG "%s: manual reset request(%d)\n", dev->name, *i);
+       switch (*i) {
+       case 0:
+               /* Disable and enable card */
+               local->func->hw_shutdown(dev, 1);
+               local->func->hw_config(dev, 0);
+               break;
+
+       case 1:
+               /* COR sreset */
+               local->func->hw_reset(dev);
+               break;
+
+       case 2:
+               /* Disable and enable port 0 */
+               local->func->reset_port(dev);
+               break;
+
+       case 3:
+               prism2_sta_deauth(local, WLAN_REASON_DEAUTH_LEAVING);
+               if (local->func->cmd(dev, HFA384X_CMDCODE_DISABLE, 0, NULL,
+                                    NULL))
+                       return -EINVAL;
+               break;
+
+       case 4:
+               if (local->func->cmd(dev, HFA384X_CMDCODE_ENABLE, 0, NULL,
+                                    NULL))
+                       return -EINVAL;
+               break;
+
+       default:
+               printk(KERN_DEBUG "Unknown reset request %d\n", *i);
+               return -EOPNOTSUPP;
+       }
+
+       return 0;
+}
+
+
+static int prism2_ioctl_priv_set_rid_word(struct net_device *dev, int *i)
+{
+       int rid = *i;
+       int value = *(i + 1);
+
+       printk(KERN_DEBUG "%s: Set RID[0x%X] = %d\n", dev->name, rid, value);
+
+       if (hostap_set_word(dev, rid, value))
+               return -EINVAL;
+
+       return 0;
+}
+
+
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+static int ap_mac_cmd_ioctl(local_info_t *local, int *cmd)
+{
+       int ret = 0;
+
+       switch (*cmd) {
+       case AP_MAC_CMD_POLICY_OPEN:
+               local->ap->mac_restrictions.policy = MAC_POLICY_OPEN;
+               break;
+       case AP_MAC_CMD_POLICY_ALLOW:
+               local->ap->mac_restrictions.policy = MAC_POLICY_ALLOW;
+               break;
+       case AP_MAC_CMD_POLICY_DENY:
+               local->ap->mac_restrictions.policy = MAC_POLICY_DENY;
+               break;
+       case AP_MAC_CMD_FLUSH:
+               ap_control_flush_macs(&local->ap->mac_restrictions);
+               break;
+       case AP_MAC_CMD_KICKALL:
+               ap_control_kickall(local->ap);
+               hostap_deauth_all_stas(local->dev, local->ap, 0);
+               break;
+       default:
+               ret = -EOPNOTSUPP;
+               break;
+       }
+
+       return ret;
+}
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+
+#ifdef PRISM2_DOWNLOAD_SUPPORT
+static int prism2_ioctl_priv_download(local_info_t *local, struct iw_point *p)
+{
+       struct prism2_download_param *param;
+       int ret = 0;
+
+       if (p->length < sizeof(struct prism2_download_param) ||
+           p->length > 1024 || !p->pointer)
+               return -EINVAL;
+
+       param = (struct prism2_download_param *)
+               kmalloc(p->length, GFP_KERNEL);
+       if (param == NULL)
+               return -ENOMEM;
+
+       if (copy_from_user(param, p->pointer, p->length)) {
+               ret = -EFAULT;
+               goto out;
+       }
+
+       if (p->length < sizeof(struct prism2_download_param) +
+           param->num_areas * sizeof(struct prism2_download_area)) {
+               ret = -EINVAL;
+               goto out;
+       }
+
+       ret = local->func->download(local, param);
+
+ out:
+       if (param != NULL)
+               kfree(param);
+
+       return ret;
+}
+#endif /* PRISM2_DOWNLOAD_SUPPORT */
+
+
+static int prism2_set_genericelement(struct net_device *dev, u8 *elem,
+                                    size_t len)
+{
+       struct hostap_interface *iface = dev->priv;
+       local_info_t *local = iface->local;
+       u8 *buf;
+
+       /*
+        * Add 16-bit length in the beginning of the buffer because Prism2 RID
+        * includes it.
+        */
+       buf = kmalloc(len + 2, GFP_KERNEL);
+       if (buf == NULL)
+               return -ENOMEM;
+
+       *((u16 *) buf) = cpu_to_le16(len);
+       memcpy(buf + 2, elem, len);
+
+       kfree(local->generic_elem);
+       local->generic_elem = buf;
+       local->generic_elem_len = len + 2;
+
+       return local->func->set_rid(local->dev, HFA384X_RID_GENERICELEMENT,
+                                   buf, len + 2);
+}
+
+
+static int prism2_ioctl_siwauth(struct net_device *dev,
+                               struct iw_request_info *info,
+                               struct iw_param *data, char *extra)
+{
+       struct hostap_interface *iface = dev->priv;
+       local_info_t *local = iface->local;
+
+       switch (data->flags & IW_AUTH_INDEX) {
+       case IW_AUTH_WPA_VERSION:
+       case IW_AUTH_CIPHER_PAIRWISE:
+       case IW_AUTH_CIPHER_GROUP:
+       case IW_AUTH_KEY_MGMT:
+               /*
+                * Host AP driver does not use these parameters and allows
+                * wpa_supplicant to control them internally.
+                */
+               break;
+       case IW_AUTH_TKIP_COUNTERMEASURES:
+               local->tkip_countermeasures = data->value;
+               break;
+       case IW_AUTH_DROP_UNENCRYPTED:
+               local->drop_unencrypted = data->value;
+               break;
+       case IW_AUTH_80211_AUTH_ALG:
+               local->auth_algs = data->value;
+               break;
+       case IW_AUTH_WPA_ENABLED:
+               if (data->value == 0) {
+                       local->wpa = 0;
+                       if (local->sta_fw_ver < PRISM2_FW_VER(1,7,0))
+                               break;
+                       prism2_set_genericelement(dev, "", 0);
+                       local->host_roaming = 0;
+                       local->privacy_invoked = 0;
+                       if (hostap_set_word(dev, HFA384X_RID_SSNHANDLINGMODE,
+                                           0) ||
+                           hostap_set_roaming(local) ||
+                           hostap_set_encryption(local) ||
+                           local->func->reset_port(dev))
+                               return -EINVAL;
+                       break;
+               }
+               if (local->sta_fw_ver < PRISM2_FW_VER(1,7,0))
+                       return -EOPNOTSUPP;
+               local->host_roaming = 2;
+               local->privacy_invoked = 1;
+               local->wpa = 1;
+               if (hostap_set_word(dev, HFA384X_RID_SSNHANDLINGMODE, 1) ||
+                   hostap_set_roaming(local) ||
+                   hostap_set_encryption(local) ||
+                   local->func->reset_port(dev))
+                       return -EINVAL;
+               break;
+       case IW_AUTH_RX_UNENCRYPTED_EAPOL:
+               local->ieee_802_1x = data->value;
+               break;
+       case IW_AUTH_PRIVACY_INVOKED:
+               local->privacy_invoked = data->value;
+               break;
+       default:
+               return -EOPNOTSUPP;
+       }
+       return 0;
+}
+
+
+static int prism2_ioctl_giwauth(struct net_device *dev,
+                               struct iw_request_info *info,
+                               struct iw_param *data, char *extra)
+{
+       struct hostap_interface *iface = dev->priv;
+       local_info_t *local = iface->local;
+
+       switch (data->flags & IW_AUTH_INDEX) {
+       case IW_AUTH_WPA_VERSION:
+       case IW_AUTH_CIPHER_PAIRWISE:
+       case IW_AUTH_CIPHER_GROUP:
+       case IW_AUTH_KEY_MGMT:
+               /*
+                * Host AP driver does not use these parameters and allows
+                * wpa_supplicant to control them internally.
+                */
+               return -EOPNOTSUPP;
+       case IW_AUTH_TKIP_COUNTERMEASURES:
+               data->value = local->tkip_countermeasures;
+               break;
+       case IW_AUTH_DROP_UNENCRYPTED:
+               data->value = local->drop_unencrypted;
+               break;
+       case IW_AUTH_80211_AUTH_ALG:
+               data->value = local->auth_algs;
+               break;
+       case IW_AUTH_WPA_ENABLED:
+               data->value = local->wpa;
+               break;
+       case IW_AUTH_RX_UNENCRYPTED_EAPOL:
+               data->value = local->ieee_802_1x;
+               break;
+       default:
+               return -EOPNOTSUPP;
+       }
+       return 0;
+}
+
+
+static int prism2_ioctl_siwencodeext(struct net_device *dev,
+                                    struct iw_request_info *info,
+                                    struct iw_point *erq, char *extra)
+{
+       struct hostap_interface *iface = dev->priv;
+       local_info_t *local = iface->local;
+       struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;
+       int i, ret = 0;
+       struct ieee80211_crypto_ops *ops;
+       struct ieee80211_crypt_data **crypt;
+       void *sta_ptr;
+       u8 *addr;
+       const char *alg, *module;
+
+       i = erq->flags & IW_ENCODE_INDEX;
+       if (i > WEP_KEYS)
+               return -EINVAL;
+       if (i < 1 || i > WEP_KEYS)
+               i = local->tx_keyidx;
+       else
+               i--;
+       if (i < 0 || i >= WEP_KEYS)
+               return -EINVAL;
+
+       addr = ext->addr.sa_data;
+       if (addr[0] == 0xff && addr[1] == 0xff && addr[2] == 0xff &&
+           addr[3] == 0xff && addr[4] == 0xff && addr[5] == 0xff) {
+               sta_ptr = NULL;
+               crypt = &local->crypt[i];
+       } else {
+               if (i != 0)
+                       return -EINVAL;
+               sta_ptr = ap_crypt_get_ptrs(local->ap, addr, 0, &crypt);
+               if (sta_ptr == NULL) {
+                       if (local->iw_mode == IW_MODE_INFRA) {
+                               /*
+                                * TODO: add STA entry for the current AP so
+                                * that unicast key can be used. For now, this
+                                * is emulated by using default key idx 0.
+                                */
+                               i = 0;
+                               crypt = &local->crypt[i];
+                       } else
+                               return -EINVAL;
+               }
+       }
+
+       if ((erq->flags & IW_ENCODE_DISABLED) ||
+           ext->alg == IW_ENCODE_ALG_NONE) {
+               if (*crypt)
+                       prism2_crypt_delayed_deinit(local, crypt);
+               goto done;
+       }
+
+       switch (ext->alg) {
+       case IW_ENCODE_ALG_WEP:
+               alg = "WEP";
+               module = "ieee80211_crypt_wep";
+               break;
+       case IW_ENCODE_ALG_TKIP:
+               alg = "TKIP";
+               module = "ieee80211_crypt_tkip";
+               break;
+       case IW_ENCODE_ALG_CCMP:
+               alg = "CCMP";
+               module = "ieee80211_crypt_ccmp";
+               break;
+       default:
+               printk(KERN_DEBUG "%s: unsupported algorithm %d\n",
+                      local->dev->name, ext->alg);
+               ret = -EOPNOTSUPP;
+               goto done;
+       }
+
+       ops = ieee80211_get_crypto_ops(alg);
+       if (ops == NULL) {
+               request_module(module);
+               ops = ieee80211_get_crypto_ops(alg);
+       }
+       if (ops == NULL) {
+               printk(KERN_DEBUG "%s: unknown crypto alg '%s'\n",
+                      local->dev->name, alg);
+               ret = -EOPNOTSUPP;
+               goto done;
+       }
+
+       if (sta_ptr || ext->alg != IW_ENCODE_ALG_WEP) {
+               /*
+                * Per station encryption and other than WEP algorithms
+                * require host-based encryption, so force them on
+                * automatically.
+                */
+               local->host_decrypt = local->host_encrypt = 1;
+       }
+
+       if (*crypt == NULL || (*crypt)->ops != ops) {
+               struct ieee80211_crypt_data *new_crypt;
+
+               prism2_crypt_delayed_deinit(local, crypt);
+
+               new_crypt = (struct ieee80211_crypt_data *)
+                       kmalloc(sizeof(struct ieee80211_crypt_data),
+                               GFP_KERNEL);
+               if (new_crypt == NULL) {
+                       ret = -ENOMEM;
+                       goto done;
+               }
+               memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
+               new_crypt->ops = ops;
+               new_crypt->priv = new_crypt->ops->init(i);
+               if (new_crypt->priv == NULL) {
+                       kfree(new_crypt);
+                       ret = -EINVAL;
+                       goto done;
+               }
+
+               *crypt = new_crypt;
+       }
+
+       /*
+        * TODO: if ext_flags does not have IW_ENCODE_EXT_RX_SEQ_VALID, the
+        * existing seq# should not be changed.
+        * TODO: if ext_flags has IW_ENCODE_EXT_TX_SEQ_VALID, next TX seq#
+        * should be changed to something else than zero.
+        */
+       if ((!(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) || ext->key_len > 0)
+           && (*crypt)->ops->set_key &&
+           (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq,
+                                  (*crypt)->priv) < 0) {
+               printk(KERN_DEBUG "%s: key setting failed\n",
+                      local->dev->name);
+               ret = -EINVAL;
+               goto done;
+       }
+
+       if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
+               if (!sta_ptr)
+                       local->tx_keyidx = i;
+               else if (i) {
+                       ret = -EINVAL;
+                       goto done;
+               }
+       }
+
+
+       if (sta_ptr == NULL && ext->key_len > 0) {
+               int first = 1, j;
+               for (j = 0; j < WEP_KEYS; j++) {
+                       if (j != i && local->crypt[j]) {
+                               first = 0;
+                               break;
+                       }
+               }
+               if (first)
+                       local->tx_keyidx = i;
+       }
+
+ done:
+       if (sta_ptr)
+               hostap_handle_sta_release(sta_ptr);
+
+       local->open_wep = erq->flags & IW_ENCODE_OPEN;
+
+       /*
+        * Do not reset port0 if card is in Managed mode since resetting will
+        * generate new IEEE 802.11 authentication which may end up in looping
+        * with IEEE 802.1X. Prism2 documentation seem to require port reset
+        * after WEP configuration. However, keys are apparently changed at
+        * least in Managed mode.
+        */
+       if (ret == 0 &&
+           (hostap_set_encryption(local) ||
+            (local->iw_mode != IW_MODE_INFRA &&
+             local->func->reset_port(local->dev))))
+               ret = -EINVAL;
+
+       return ret;
+}
+
+
+static int prism2_ioctl_giwencodeext(struct net_device *dev,
+                                    struct iw_request_info *info,
+                                    struct iw_point *erq, char *extra)
+{
+       struct hostap_interface *iface = dev->priv;
+       local_info_t *local = iface->local;
+       struct ieee80211_crypt_data **crypt;
+       void *sta_ptr;
+       int max_key_len, i;
+       struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;
+       u8 *addr;
+
+       max_key_len = erq->length - sizeof(*ext);
+       if (max_key_len < 0)
+               return -EINVAL;
+
+       i = erq->flags & IW_ENCODE_INDEX;
+       if (i < 1 || i > WEP_KEYS)
+               i = local->tx_keyidx;
+       else
+               i--;
+
+       addr = ext->addr.sa_data;
+       if (addr[0] == 0xff && addr[1] == 0xff && addr[2] == 0xff &&
+           addr[3] == 0xff && addr[4] == 0xff && addr[5] == 0xff) {
+               sta_ptr = NULL;
+               crypt = &local->crypt[i];
+       } else {
+               i = 0;
+               sta_ptr = ap_crypt_get_ptrs(local->ap, addr, 0, &crypt);
+               if (sta_ptr == NULL)
+                       return -EINVAL;
+       }
+       erq->flags = i + 1;
+       memset(ext, 0, sizeof(*ext));
+
+       if (*crypt == NULL || (*crypt)->ops == NULL) {
+               ext->alg = IW_ENCODE_ALG_NONE;
+               ext->key_len = 0;
+               erq->flags |= IW_ENCODE_DISABLED;
+       } else {
+               if (strcmp((*crypt)->ops->name, "WEP") == 0)
+                       ext->alg = IW_ENCODE_ALG_WEP;
+               else if (strcmp((*crypt)->ops->name, "TKIP") == 0)
+                       ext->alg = IW_ENCODE_ALG_TKIP;
+               else if (strcmp((*crypt)->ops->name, "CCMP") == 0)
+                       ext->alg = IW_ENCODE_ALG_CCMP;
+               else
+                       return -EINVAL;
+
+               if ((*crypt)->ops->get_key) {
+                       ext->key_len =
+                               (*crypt)->ops->get_key(ext->key,
+                                                      max_key_len,
+                                                      ext->tx_seq,
+                                                      (*crypt)->priv);
+                       if (ext->key_len &&
+                           (ext->alg == IW_ENCODE_ALG_TKIP ||
+                            ext->alg == IW_ENCODE_ALG_CCMP))
+                               ext->ext_flags |= IW_ENCODE_EXT_TX_SEQ_VALID;
+               }
+       }
+
+       if (sta_ptr)
+               hostap_handle_sta_release(sta_ptr);
+
+       return 0;
+}
+
+
+static int prism2_ioctl_set_encryption(local_info_t *local,
+                                      struct prism2_hostapd_param *param,
+                                      int param_len)
+{
+       int ret = 0;
+       struct ieee80211_crypto_ops *ops;
+       struct ieee80211_crypt_data **crypt;
+       void *sta_ptr;
+
+       param->u.crypt.err = 0;
+       param->u.crypt.alg[HOSTAP_CRYPT_ALG_NAME_LEN - 1] = '\0';
+
+       if (param_len !=
+           (int) ((char *) param->u.crypt.key - (char *) param) +
+           param->u.crypt.key_len)
+               return -EINVAL;
+
+       if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
+           param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
+           param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
+               if (param->u.crypt.idx >= WEP_KEYS)
+                       return -EINVAL;
+               sta_ptr = NULL;
+               crypt = &local->crypt[param->u.crypt.idx];
+       } else {
+               if (param->u.crypt.idx)
+                       return -EINVAL;
+               sta_ptr = ap_crypt_get_ptrs(
+                       local->ap, param->sta_addr,
+                       (param->u.crypt.flags & HOSTAP_CRYPT_FLAG_PERMANENT),
+                       &crypt);
+
+               if (sta_ptr == NULL) {
+                       param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR;
+                       return -EINVAL;
+               }
+       }
+
+       if (strcmp(param->u.crypt.alg, "none") == 0) {
+               if (crypt)
+                       prism2_crypt_delayed_deinit(local, crypt);
+               goto done;
+       }
+
+       ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
+       if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) {
+               request_module("ieee80211_crypt_wep");
+               ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
+       } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) {
+               request_module("ieee80211_crypt_tkip");
+               ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
+       } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) {
+               request_module("ieee80211_crypt_ccmp");
+               ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
+       }
+       if (ops == NULL) {
+               printk(KERN_DEBUG "%s: unknown crypto alg '%s'\n",
+                      local->dev->name, param->u.crypt.alg);
+               param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ALG;
+               ret = -EINVAL;
+               goto done;
+       }
+
+       /* station based encryption and other than WEP algorithms require
+        * host-based encryption, so force them on automatically */
+       local->host_decrypt = local->host_encrypt = 1;
+
+       if (*crypt == NULL || (*crypt)->ops != ops) {
+               struct ieee80211_crypt_data *new_crypt;
+
+               prism2_crypt_delayed_deinit(local, crypt);
+
+               new_crypt = (struct ieee80211_crypt_data *)
+                       kmalloc(sizeof(struct ieee80211_crypt_data),
+                               GFP_KERNEL);
+               if (new_crypt == NULL) {
+                       ret = -ENOMEM;
+                       goto done;
+               }
+               memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
+               new_crypt->ops = ops;
+               new_crypt->priv = new_crypt->ops->init(param->u.crypt.idx);
+               if (new_crypt->priv == NULL) {
+                       kfree(new_crypt);
+                       param->u.crypt.err =
+                               HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED;
+                       ret = -EINVAL;
+                       goto done;
+               }
+
+               *crypt = new_crypt;
+       }
+
+       if ((!(param->u.crypt.flags & HOSTAP_CRYPT_FLAG_SET_TX_KEY) ||
+            param->u.crypt.key_len > 0) && (*crypt)->ops->set_key &&
+           (*crypt)->ops->set_key(param->u.crypt.key,
+                                  param->u.crypt.key_len, param->u.crypt.seq,
+                                  (*crypt)->priv) < 0) {
+               printk(KERN_DEBUG "%s: key setting failed\n",
+                      local->dev->name);
+               param->u.crypt.err = HOSTAP_CRYPT_ERR_KEY_SET_FAILED;
+               ret = -EINVAL;
+               goto done;
+       }
+
+       if (param->u.crypt.flags & HOSTAP_CRYPT_FLAG_SET_TX_KEY) {
+               if (!sta_ptr)
+                       local->tx_keyidx = param->u.crypt.idx;
+               else if (param->u.crypt.idx) {
+                       printk(KERN_DEBUG "%s: TX key idx setting failed\n",
+                              local->dev->name);
+                       param->u.crypt.err =
+                               HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED;
+                       ret = -EINVAL;
+                       goto done;
+               }
+       }
+
+ done:
+       if (sta_ptr)
+               hostap_handle_sta_release(sta_ptr);
+
+       /* Do not reset port0 if card is in Managed mode since resetting will
+        * generate new IEEE 802.11 authentication which may end up in looping
+        * with IEEE 802.1X. Prism2 documentation seem to require port reset
+        * after WEP configuration. However, keys are apparently changed at
+        * least in Managed mode. */
+       if (ret == 0 &&
+           (hostap_set_encryption(local) ||
+            (local->iw_mode != IW_MODE_INFRA &&
+             local->func->reset_port(local->dev)))) {
+               param->u.crypt.err = HOSTAP_CRYPT_ERR_CARD_CONF_FAILED;
+               return -EINVAL;
+       }
+
+       return ret;
+}
+
+
+static int prism2_ioctl_get_encryption(local_info_t *local,
+                                      struct prism2_hostapd_param *param,
+                                      int param_len)
+{
+       struct ieee80211_crypt_data **crypt;
+       void *sta_ptr;
+       int max_key_len;
+
+       param->u.crypt.err = 0;
+
+       max_key_len = param_len -
+               (int) ((char *) param->u.crypt.key - (char *) param);
+       if (max_key_len < 0)
+               return -EINVAL;
+
+       if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
+           param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
+           param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
+               sta_ptr = NULL;
+               if (param->u.crypt.idx >= WEP_KEYS)
+                       param->u.crypt.idx = local->tx_keyidx;
+               crypt = &local->crypt[param->u.crypt.idx];
+       } else {
+               param->u.crypt.idx = 0;
+               sta_ptr = ap_crypt_get_ptrs(local->ap, param->sta_addr, 0,
+                                           &crypt);
+
+               if (sta_ptr == NULL) {
+                       param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR;
+                       return -EINVAL;
+               }
+       }
+
+       if (*crypt == NULL || (*crypt)->ops == NULL) {
+               memcpy(param->u.crypt.alg, "none", 5);
+               param->u.crypt.key_len = 0;
+               param->u.crypt.idx = 0xff;
+       } else {
+               strncpy(param->u.crypt.alg, (*crypt)->ops->name,
+                       HOSTAP_CRYPT_ALG_NAME_LEN);
+               param->u.crypt.key_len = 0;
+
+               memset(param->u.crypt.seq, 0, 8);
+               if ((*crypt)->ops->get_key) {
+                       param->u.crypt.key_len =
+                               (*crypt)->ops->get_key(param->u.crypt.key,
+                                                      max_key_len,
+                                                      param->u.crypt.seq,
+                                                      (*crypt)->priv);
+               }
+       }
+
+       if (sta_ptr)
+               hostap_handle_sta_release(sta_ptr);
+
+       return 0;
+}
+
+
+static int prism2_ioctl_get_rid(local_info_t *local,
+                               struct prism2_hostapd_param *param,
+                               int param_len)
+{
+       int max_len, res;
+
+       max_len = param_len - PRISM2_HOSTAPD_RID_HDR_LEN;
+       if (max_len < 0)
+               return -EINVAL;
+
+       res = local->func->get_rid(local->dev, param->u.rid.rid,
+                                  param->u.rid.data, param->u.rid.len, 0);
+       if (res >= 0) {
+               param->u.rid.len = res;
+               return 0;
+       }
+
+       return res;
+}
+
+
+static int prism2_ioctl_set_rid(local_info_t *local,
+                               struct prism2_hostapd_param *param,
+                               int param_len)
+{
+       int max_len;
+
+       max_len = param_len - PRISM2_HOSTAPD_RID_HDR_LEN;
+       if (max_len < 0 || max_len < param->u.rid.len)
+               return -EINVAL;
+
+       return local->func->set_rid(local->dev, param->u.rid.rid,
+                                   param->u.rid.data, param->u.rid.len);
+}
+
+
+static int prism2_ioctl_set_assoc_ap_addr(local_info_t *local,
+                                         struct prism2_hostapd_param *param,
+                                         int param_len)
+{
+       printk(KERN_DEBUG "%ssta: associated as client with AP " MACSTR "\n",
+              local->dev->name, MAC2STR(param->sta_addr));
+       memcpy(local->assoc_ap_addr, param->sta_addr, ETH_ALEN);
+       return 0;
+}
+
+
+static int prism2_ioctl_siwgenie(struct net_device *dev,
+                                struct iw_request_info *info,
+                                struct iw_point *data, char *extra)
+{
+       return prism2_set_genericelement(dev, extra, data->length);
+}
+
+
+static int prism2_ioctl_giwgenie(struct net_device *dev,
+                                struct iw_request_info *info,
+                                struct iw_point *data, char *extra)
+{
+       struct hostap_interface *iface = dev->priv;
+       local_info_t *local = iface->local;
+       int len = local->generic_elem_len - 2;
+
+       if (len <= 0 || local->generic_elem == NULL) {
+               data->length = 0;
+               return 0;
+       }
+
+       if (data->length < len)
+               return -E2BIG;
+
+       data->length = len;
+       memcpy(extra, local->generic_elem + 2, len);
+
+       return 0;
+}
+
+
+static int prism2_ioctl_set_generic_element(local_info_t *local,
+                                           struct prism2_hostapd_param *param,
+                                           int param_len)
+{
+       int max_len, len;
+
+       len = param->u.generic_elem.len;
+       max_len = param_len - PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN;
+       if (max_len < 0 || max_len < len)
+               return -EINVAL;
+
+       return prism2_set_genericelement(local->dev,
+                                        param->u.generic_elem.data, len);
+}
+
+
+static int prism2_ioctl_siwmlme(struct net_device *dev,
+                               struct iw_request_info *info,
+                               struct iw_point *data, char *extra)
+{
+       struct hostap_interface *iface = dev->priv;
+       local_info_t *local = iface->local;
+       struct iw_mlme *mlme = (struct iw_mlme *) extra;
+       u16 reason;
+
+       reason = cpu_to_le16(mlme->reason_code);
+
+       switch (mlme->cmd) {
+       case IW_MLME_DEAUTH:
+               return prism2_sta_send_mgmt(local, mlme->addr.sa_data,
+                                           IEEE80211_STYPE_DEAUTH,
+                                           (u8 *) &reason, 2);
+       case IW_MLME_DISASSOC:
+               return prism2_sta_send_mgmt(local, mlme->addr.sa_data,
+                                           IEEE80211_STYPE_DISASSOC,
+                                           (u8 *) &reason, 2);
+       default:
+               return -EOPNOTSUPP;
+       }
+}
+
+
+static int prism2_ioctl_mlme(local_info_t *local,
+                            struct prism2_hostapd_param *param)
+{
+       u16 reason;
+
+       reason = cpu_to_le16(param->u.mlme.reason_code);
+       switch (param->u.mlme.cmd) {
+       case MLME_STA_DEAUTH:
+               return prism2_sta_send_mgmt(local, param->sta_addr,
+                                           IEEE80211_STYPE_DEAUTH,
+                                           (u8 *) &reason, 2);
+       case MLME_STA_DISASSOC:
+               return prism2_sta_send_mgmt(local, param->sta_addr,
+                                           IEEE80211_STYPE_DISASSOC,
+                                           (u8 *) &reason, 2);
+       default:
+               return -EOPNOTSUPP;
+       }
+}
+
+
+static int prism2_ioctl_scan_req(local_info_t *local,
+                                struct prism2_hostapd_param *param)
+{
+#ifndef PRISM2_NO_STATION_MODES
+       if ((local->iw_mode != IW_MODE_INFRA &&
+            local->iw_mode != IW_MODE_ADHOC) ||
+           (local->sta_fw_ver < PRISM2_FW_VER(1,3,1)))
+               return -EOPNOTSUPP;
+
+       if (!local->dev_enabled)
+               return -ENETDOWN;
+
+       return prism2_request_hostscan(local->dev, param->u.scan_req.ssid,
+                                      param->u.scan_req.ssid_len);
+#else /* PRISM2_NO_STATION_MODES */
+       return -EOPNOTSUPP;
+#endif /* PRISM2_NO_STATION_MODES */
+}
+
+
+static int prism2_ioctl_priv_hostapd(local_info_t *local, struct iw_point *p)
+{
+       struct prism2_hostapd_param *param;
+       int ret = 0;
+       int ap_ioctl = 0;
+
+       if (p->length < sizeof(struct prism2_hostapd_param) ||
+           p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer)
+               return -EINVAL;
+
+       param = (struct prism2_hostapd_param *) kmalloc(p->length, GFP_KERNEL);
+       if (param == NULL)
+               return -ENOMEM;
+
+       if (copy_from_user(param, p->pointer, p->length)) {
+               ret = -EFAULT;
+               goto out;
+       }
+
+       switch (param->cmd) {
+       case PRISM2_SET_ENCRYPTION:
+               ret = prism2_ioctl_set_encryption(local, param, p->length);
+               break;
+       case PRISM2_GET_ENCRYPTION:
+               ret = prism2_ioctl_get_encryption(local, param, p->length);
+               break;
+       case PRISM2_HOSTAPD_GET_RID:
+               ret = prism2_ioctl_get_rid(local, param, p->length);
+               break;
+       case PRISM2_HOSTAPD_SET_RID:
+               ret = prism2_ioctl_set_rid(local, param, p->length);
+               break;
+       case PRISM2_HOSTAPD_SET_ASSOC_AP_ADDR:
+               ret = prism2_ioctl_set_assoc_ap_addr(local, param, p->length);
+               break;
+       case PRISM2_HOSTAPD_SET_GENERIC_ELEMENT:
+               ret = prism2_ioctl_set_generic_element(local, param,
+                                                      p->length);
+               break;
+       case PRISM2_HOSTAPD_MLME:
+               ret = prism2_ioctl_mlme(local, param);
+               break;
+       case PRISM2_HOSTAPD_SCAN_REQ:
+               ret = prism2_ioctl_scan_req(local, param);
+               break;
+       default:
+               ret = prism2_hostapd(local->ap, param);
+               ap_ioctl = 1;
+               break;
+       }
+
+       if (ret == 1 || !ap_ioctl) {
+               if (copy_to_user(p->pointer, param, p->length)) {
+                       ret = -EFAULT;
+                       goto out;
+               } else if (ap_ioctl)
+                       ret = 0;
+       }
+
+ out:
+       if (param != NULL)
+               kfree(param);
+
+       return ret;
+}
+
+
+static void prism2_get_drvinfo(struct net_device *dev,
+                              struct ethtool_drvinfo *info)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       strncpy(info->driver, "hostap", sizeof(info->driver) - 1);
+       strncpy(info->version, PRISM2_VERSION,
+               sizeof(info->version) - 1);
+       snprintf(info->fw_version, sizeof(info->fw_version) - 1,
+                "%d.%d.%d", (local->sta_fw_ver >> 16) & 0xff,
+                (local->sta_fw_ver >> 8) & 0xff,
+                local->sta_fw_ver & 0xff);
+}
+
+static struct ethtool_ops prism2_ethtool_ops = {
+       .get_drvinfo = prism2_get_drvinfo
+};
+
+
+/* Structures to export the Wireless Handlers */
+
+static const iw_handler prism2_handler[] =
+{
+       (iw_handler) NULL,                              /* SIOCSIWCOMMIT */
+       (iw_handler) prism2_get_name,                   /* SIOCGIWNAME */
+       (iw_handler) NULL,                              /* SIOCSIWNWID */
+       (iw_handler) NULL,                              /* SIOCGIWNWID */
+       (iw_handler) prism2_ioctl_siwfreq,              /* SIOCSIWFREQ */
+       (iw_handler) prism2_ioctl_giwfreq,              /* SIOCGIWFREQ */
+       (iw_handler) prism2_ioctl_siwmode,              /* SIOCSIWMODE */
+       (iw_handler) prism2_ioctl_giwmode,              /* SIOCGIWMODE */
+       (iw_handler) prism2_ioctl_siwsens,              /* SIOCSIWSENS */
+       (iw_handler) prism2_ioctl_giwsens,              /* SIOCGIWSENS */
+       (iw_handler) NULL /* not used */,               /* SIOCSIWRANGE */
+       (iw_handler) prism2_ioctl_giwrange,             /* SIOCGIWRANGE */
+       (iw_handler) NULL /* not used */,               /* SIOCSIWPRIV */
+       (iw_handler) NULL /* kernel code */,            /* SIOCGIWPRIV */
+       (iw_handler) NULL /* not used */,               /* SIOCSIWSTATS */
+       (iw_handler) NULL /* kernel code */,            /* SIOCGIWSTATS */
+       iw_handler_set_spy,                             /* SIOCSIWSPY */
+       iw_handler_get_spy,                             /* SIOCGIWSPY */
+       iw_handler_set_thrspy,                          /* SIOCSIWTHRSPY */
+       iw_handler_get_thrspy,                          /* SIOCGIWTHRSPY */
+       (iw_handler) prism2_ioctl_siwap,                /* SIOCSIWAP */
+       (iw_handler) prism2_ioctl_giwap,                /* SIOCGIWAP */
+       (iw_handler) prism2_ioctl_siwmlme,              /* SIOCSIWMLME */
+       (iw_handler) prism2_ioctl_giwaplist,            /* SIOCGIWAPLIST */
+       (iw_handler) prism2_ioctl_siwscan,              /* SIOCSIWSCAN */
+       (iw_handler) prism2_ioctl_giwscan,              /* SIOCGIWSCAN */
+       (iw_handler) prism2_ioctl_siwessid,             /* SIOCSIWESSID */
+       (iw_handler) prism2_ioctl_giwessid,             /* SIOCGIWESSID */
+       (iw_handler) prism2_ioctl_siwnickn,             /* SIOCSIWNICKN */
+       (iw_handler) prism2_ioctl_giwnickn,             /* SIOCGIWNICKN */
+       (iw_handler) NULL,                              /* -- hole -- */
+       (iw_handler) NULL,                              /* -- hole -- */
+       (iw_handler) prism2_ioctl_siwrate,              /* SIOCSIWRATE */
+       (iw_handler) prism2_ioctl_giwrate,              /* SIOCGIWRATE */
+       (iw_handler) prism2_ioctl_siwrts,               /* SIOCSIWRTS */
+       (iw_handler) prism2_ioctl_giwrts,               /* SIOCGIWRTS */
+       (iw_handler) prism2_ioctl_siwfrag,              /* SIOCSIWFRAG */
+       (iw_handler) prism2_ioctl_giwfrag,              /* SIOCGIWFRAG */
+       (iw_handler) prism2_ioctl_siwtxpow,             /* SIOCSIWTXPOW */
+       (iw_handler) prism2_ioctl_giwtxpow,             /* SIOCGIWTXPOW */
+       (iw_handler) prism2_ioctl_siwretry,             /* SIOCSIWRETRY */
+       (iw_handler) prism2_ioctl_giwretry,             /* SIOCGIWRETRY */
+       (iw_handler) prism2_ioctl_siwencode,            /* SIOCSIWENCODE */
+       (iw_handler) prism2_ioctl_giwencode,            /* SIOCGIWENCODE */
+       (iw_handler) prism2_ioctl_siwpower,             /* SIOCSIWPOWER */
+       (iw_handler) prism2_ioctl_giwpower,             /* SIOCGIWPOWER */
+       (iw_handler) NULL,                              /* -- hole -- */
+       (iw_handler) NULL,                              /* -- hole -- */
+       (iw_handler) prism2_ioctl_siwgenie,             /* SIOCSIWGENIE */
+       (iw_handler) prism2_ioctl_giwgenie,             /* SIOCGIWGENIE */
+       (iw_handler) prism2_ioctl_siwauth,              /* SIOCSIWAUTH */
+       (iw_handler) prism2_ioctl_giwauth,              /* SIOCGIWAUTH */
+       (iw_handler) prism2_ioctl_siwencodeext,         /* SIOCSIWENCODEEXT */
+       (iw_handler) prism2_ioctl_giwencodeext,         /* SIOCGIWENCODEEXT */
+       (iw_handler) NULL,                              /* SIOCSIWPMKSA */
+       (iw_handler) NULL,                              /* -- hole -- */
+};
+
+static const iw_handler prism2_private_handler[] =
+{                                                      /* SIOCIWFIRSTPRIV + */
+       (iw_handler) prism2_ioctl_priv_prism2_param,    /* 0 */
+       (iw_handler) prism2_ioctl_priv_get_prism2_param, /* 1 */
+       (iw_handler) prism2_ioctl_priv_writemif,        /* 2 */
+       (iw_handler) prism2_ioctl_priv_readmif,         /* 3 */
+};
+
+static const struct iw_handler_def hostap_iw_handler_def =
+{
+       .num_standard   = sizeof(prism2_handler) / sizeof(iw_handler),
+       .num_private    = sizeof(prism2_private_handler) / sizeof(iw_handler),
+       .num_private_args = sizeof(prism2_priv) / sizeof(struct iw_priv_args),
+       .standard       = (iw_handler *) prism2_handler,
+       .private        = (iw_handler *) prism2_private_handler,
+       .private_args   = (struct iw_priv_args *) prism2_priv,
+       .get_wireless_stats = hostap_get_wireless_stats,
+};
+
+
+int hostap_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+{
+       struct iwreq *wrq = (struct iwreq *) ifr;
+       struct hostap_interface *iface;
+       local_info_t *local;
+       int ret = 0;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       switch (cmd) {
+               /* Private ioctls (iwpriv) that have not yet been converted
+                * into new wireless extensions API */
+
+       case PRISM2_IOCTL_INQUIRE:
+               if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
+               else ret = prism2_ioctl_priv_inquire(dev, (int *) wrq->u.name);
+               break;
+
+       case PRISM2_IOCTL_MONITOR:
+               if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
+               else ret = prism2_ioctl_priv_monitor(dev, (int *) wrq->u.name);
+               break;
+
+       case PRISM2_IOCTL_RESET:
+               if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
+               else ret = prism2_ioctl_priv_reset(dev, (int *) wrq->u.name);
+               break;
+
+       case PRISM2_IOCTL_WDS_ADD:
+               if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
+               else ret = prism2_wds_add(local, wrq->u.ap_addr.sa_data, 1);
+               break;
+
+       case PRISM2_IOCTL_WDS_DEL:
+               if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
+               else ret = prism2_wds_del(local, wrq->u.ap_addr.sa_data, 1, 0);
+               break;
+
+       case PRISM2_IOCTL_SET_RID_WORD:
+               if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
+               else ret = prism2_ioctl_priv_set_rid_word(dev,
+                                                         (int *) wrq->u.name);
+               break;
+
+#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
+       case PRISM2_IOCTL_MACCMD:
+               if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
+               else ret = ap_mac_cmd_ioctl(local, (int *) wrq->u.name);
+               break;
+
+       case PRISM2_IOCTL_ADDMAC:
+               if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
+               else ret = ap_control_add_mac(&local->ap->mac_restrictions,
+                                             wrq->u.ap_addr.sa_data);
+               break;
+       case PRISM2_IOCTL_DELMAC:
+               if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
+               else ret = ap_control_del_mac(&local->ap->mac_restrictions,
+                                             wrq->u.ap_addr.sa_data);
+               break;
+       case PRISM2_IOCTL_KICKMAC:
+               if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
+               else ret = ap_control_kick_mac(local->ap, local->dev,
+                                              wrq->u.ap_addr.sa_data);
+               break;
+#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
+
+
+               /* Private ioctls that are not used with iwpriv;
+                * in SIOCDEVPRIVATE range */
+
+#ifdef PRISM2_DOWNLOAD_SUPPORT
+       case PRISM2_IOCTL_DOWNLOAD:
+               if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
+               else ret = prism2_ioctl_priv_download(local, &wrq->u.data);
+               break;
+#endif /* PRISM2_DOWNLOAD_SUPPORT */
+
+       case PRISM2_IOCTL_HOSTAPD:
+               if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
+               else ret = prism2_ioctl_priv_hostapd(local, &wrq->u.data);
+               break;
+
+       default:
+               ret = -EOPNOTSUPP;
+               break;
+       }
+
+       return ret;
+}
diff --git a/drivers/net/wireless/hostap/hostap_pci.c b/drivers/net/wireless/hostap/hostap_pci.c
new file mode 100644 (file)
index 0000000..025f8cd
--- /dev/null
@@ -0,0 +1,473 @@
+#define PRISM2_PCI
+
+/* Host AP driver's support for Intersil Prism2.5 PCI cards is based on
+ * driver patches from Reyk Floeter <reyk@vantronix.net> and
+ * Andy Warner <andyw@pobox.com> */
+
+#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/if.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/workqueue.h>
+#include <linux/wireless.h>
+#include <net/iw_handler.h>
+
+#include <linux/ioport.h>
+#include <linux/pci.h>
+#include <asm/io.h>
+
+#include "hostap_wlan.h"
+
+
+static char *version = PRISM2_VERSION " (Jouni Malinen <jkmaline@cc.hut.fi>)";
+static char *dev_info = "hostap_pci";
+
+
+MODULE_AUTHOR("Jouni Malinen");
+MODULE_DESCRIPTION("Support for Intersil Prism2.5-based 802.11 wireless LAN "
+                  "PCI cards.");
+MODULE_SUPPORTED_DEVICE("Intersil Prism2.5-based WLAN PCI cards");
+MODULE_LICENSE("GPL");
+MODULE_VERSION(PRISM2_VERSION);
+
+
+/* struct local_info::hw_priv */
+struct hostap_pci_priv {
+       void __iomem *mem_start;
+};
+
+
+/* FIX: do we need mb/wmb/rmb with memory operations? */
+
+
+static struct pci_device_id prism2_pci_id_table[] __devinitdata = {
+       /* Intersil Prism3 ISL3872 11Mb/s WLAN Controller */
+       { 0x1260, 0x3872, PCI_ANY_ID, PCI_ANY_ID },
+       /* Intersil Prism2.5 ISL3874 11Mb/s WLAN Controller */
+       { 0x1260, 0x3873, PCI_ANY_ID, PCI_ANY_ID },
+       /* Samsung MagicLAN SWL-2210P */
+       { 0x167d, 0xa000, PCI_ANY_ID, PCI_ANY_ID },
+       { 0 }
+};
+
+
+#ifdef PRISM2_IO_DEBUG
+
+static inline void hfa384x_outb_debug(struct net_device *dev, int a, u8 v)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       unsigned long flags;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       spin_lock_irqsave(&local->lock, flags);
+       prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTB, a, v);
+       writeb(v, hw_priv->mem_start + a);
+       spin_unlock_irqrestore(&local->lock, flags);
+}
+
+static inline u8 hfa384x_inb_debug(struct net_device *dev, int a)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       unsigned long flags;
+       u8 v;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       spin_lock_irqsave(&local->lock, flags);
+       v = readb(hw_priv->mem_start + a);
+       prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INB, a, v);
+       spin_unlock_irqrestore(&local->lock, flags);
+       return v;
+}
+
+static inline void hfa384x_outw_debug(struct net_device *dev, int a, u16 v)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       unsigned long flags;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       spin_lock_irqsave(&local->lock, flags);
+       prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTW, a, v);
+       writew(v, hw_priv->mem_start + a);
+       spin_unlock_irqrestore(&local->lock, flags);
+}
+
+static inline u16 hfa384x_inw_debug(struct net_device *dev, int a)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       unsigned long flags;
+       u16 v;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       spin_lock_irqsave(&local->lock, flags);
+       v = readw(hw_priv->mem_start + a);
+       prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INW, a, v);
+       spin_unlock_irqrestore(&local->lock, flags);
+       return v;
+}
+
+#define HFA384X_OUTB(v,a) hfa384x_outb_debug(dev, (a), (v))
+#define HFA384X_INB(a) hfa384x_inb_debug(dev, (a))
+#define HFA384X_OUTW(v,a) hfa384x_outw_debug(dev, (a), (v))
+#define HFA384X_INW(a) hfa384x_inw_debug(dev, (a))
+#define HFA384X_OUTW_DATA(v,a) hfa384x_outw_debug(dev, (a), cpu_to_le16((v)))
+#define HFA384X_INW_DATA(a) (u16) le16_to_cpu(hfa384x_inw_debug(dev, (a)))
+
+#else /* PRISM2_IO_DEBUG */
+
+static inline void hfa384x_outb(struct net_device *dev, int a, u8 v)
+{
+       struct hostap_interface *iface;
+       struct hostap_pci_priv *hw_priv;
+       iface = netdev_priv(dev);
+       hw_priv = iface->local->hw_priv;
+       writeb(v, hw_priv->mem_start + a);
+}
+
+static inline u8 hfa384x_inb(struct net_device *dev, int a)
+{
+       struct hostap_interface *iface;
+       struct hostap_pci_priv *hw_priv;
+       iface = netdev_priv(dev);
+       hw_priv = iface->local->hw_priv;
+       return readb(hw_priv->mem_start + a);
+}
+
+static inline void hfa384x_outw(struct net_device *dev, int a, u16 v)
+{
+       struct hostap_interface *iface;
+       struct hostap_pci_priv *hw_priv;
+       iface = netdev_priv(dev);
+       hw_priv = iface->local->hw_priv;
+       writew(v, hw_priv->mem_start + a);
+}
+
+static inline u16 hfa384x_inw(struct net_device *dev, int a)
+{
+       struct hostap_interface *iface;
+       struct hostap_pci_priv *hw_priv;
+       iface = netdev_priv(dev);
+       hw_priv = iface->local->hw_priv;
+       return readw(hw_priv->mem_start + a);
+}
+
+#define HFA384X_OUTB(v,a) hfa384x_outb(dev, (a), (v))
+#define HFA384X_INB(a) hfa384x_inb(dev, (a))
+#define HFA384X_OUTW(v,a) hfa384x_outw(dev, (a), (v))
+#define HFA384X_INW(a) hfa384x_inw(dev, (a))
+#define HFA384X_OUTW_DATA(v,a) hfa384x_outw(dev, (a), cpu_to_le16((v)))
+#define HFA384X_INW_DATA(a) (u16) le16_to_cpu(hfa384x_inw(dev, (a)))
+
+#endif /* PRISM2_IO_DEBUG */
+
+
+static int hfa384x_from_bap(struct net_device *dev, u16 bap, void *buf,
+                           int len)
+{
+       u16 d_off;
+       u16 *pos;
+
+       d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
+       pos = (u16 *) buf;
+
+       for ( ; len > 1; len -= 2)
+               *pos++ = HFA384X_INW_DATA(d_off);
+
+       if (len & 1)
+               *((char *) pos) = HFA384X_INB(d_off);
+
+       return 0;
+}
+
+
+static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len)
+{
+       u16 d_off;
+       u16 *pos;
+
+       d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
+       pos = (u16 *) buf;
+
+       for ( ; len > 1; len -= 2)
+               HFA384X_OUTW_DATA(*pos++, d_off);
+
+       if (len & 1)
+               HFA384X_OUTB(*((char *) pos), d_off);
+
+       return 0;
+}
+
+
+/* FIX: This might change at some point.. */
+#include "hostap_hw.c"
+
+static void prism2_pci_cor_sreset(local_info_t *local)
+{
+       struct net_device *dev = local->dev;
+       u16 reg;
+
+       reg = HFA384X_INB(HFA384X_PCICOR_OFF);
+       printk(KERN_DEBUG "%s: Original COR value: 0x%0x\n", dev->name, reg);
+
+       /* linux-wlan-ng uses extremely long hold and settle times for
+        * COR sreset. A comment in the driver code mentions that the long
+        * delays appear to be necessary. However, at least IBM 22P6901 seems
+        * to work fine with shorter delays.
+        *
+        * Longer delays can be configured by uncommenting following line: */
+/* #define PRISM2_PCI_USE_LONG_DELAYS */
+
+#ifdef PRISM2_PCI_USE_LONG_DELAYS
+       int i;
+
+       HFA384X_OUTW(reg | 0x0080, HFA384X_PCICOR_OFF);
+       mdelay(250);
+
+       HFA384X_OUTW(reg & ~0x0080, HFA384X_PCICOR_OFF);
+       mdelay(500);
+
+       /* Wait for f/w to complete initialization (CMD:BUSY == 0) */
+       i = 2000000 / 10;
+       while ((HFA384X_INW(HFA384X_CMD_OFF) & HFA384X_CMD_BUSY) && --i)
+               udelay(10);
+
+#else /* PRISM2_PCI_USE_LONG_DELAYS */
+
+       HFA384X_OUTW(reg | 0x0080, HFA384X_PCICOR_OFF);
+       mdelay(2);
+       HFA384X_OUTW(reg & ~0x0080, HFA384X_PCICOR_OFF);
+       mdelay(2);
+
+#endif /* PRISM2_PCI_USE_LONG_DELAYS */
+
+       if (HFA384X_INW(HFA384X_CMD_OFF) & HFA384X_CMD_BUSY) {
+               printk(KERN_DEBUG "%s: COR sreset timeout\n", dev->name);
+       }
+}
+
+
+static void prism2_pci_genesis_reset(local_info_t *local, int hcr)
+{
+       struct net_device *dev = local->dev;
+
+       HFA384X_OUTW(0x00C5, HFA384X_PCICOR_OFF);
+       mdelay(10);
+       HFA384X_OUTW(hcr, HFA384X_PCIHCR_OFF);
+       mdelay(10);
+       HFA384X_OUTW(0x0045, HFA384X_PCICOR_OFF);
+       mdelay(10);
+}
+
+
+static struct prism2_helper_functions prism2_pci_funcs =
+{
+       .card_present   = NULL,
+       .cor_sreset     = prism2_pci_cor_sreset,
+       .dev_open       = NULL,
+       .dev_close      = NULL,
+       .genesis_reset  = prism2_pci_genesis_reset,
+       .hw_type        = HOSTAP_HW_PCI,
+};
+
+
+static int prism2_pci_probe(struct pci_dev *pdev,
+                           const struct pci_device_id *id)
+{
+       unsigned long phymem;
+       void __iomem *mem = NULL;
+       local_info_t *local = NULL;
+       struct net_device *dev = NULL;
+       static int cards_found /* = 0 */;
+       int irq_registered = 0;
+       struct hostap_interface *iface;
+       struct hostap_pci_priv *hw_priv;
+
+       hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
+       if (hw_priv == NULL)
+               return -ENOMEM;
+       memset(hw_priv, 0, sizeof(*hw_priv));
+
+       if (pci_enable_device(pdev))
+               return -EIO;
+
+       phymem = pci_resource_start(pdev, 0);
+
+       if (!request_mem_region(phymem, pci_resource_len(pdev, 0), "Prism2")) {
+               printk(KERN_ERR "prism2: Cannot reserve PCI memory region\n");
+               goto err_out_disable;
+       }
+
+       mem = ioremap(phymem, pci_resource_len(pdev, 0));
+       if (mem == NULL) {
+               printk(KERN_ERR "prism2: Cannot remap PCI memory region\n") ;
+               goto fail;
+       }
+
+       dev = prism2_init_local_data(&prism2_pci_funcs, cards_found,
+                                    &pdev->dev);
+       if (dev == NULL)
+               goto fail;
+       iface = netdev_priv(dev);
+       local = iface->local;
+       local->hw_priv = hw_priv;
+       cards_found++;
+
+        dev->irq = pdev->irq;
+        hw_priv->mem_start = mem;
+
+       prism2_pci_cor_sreset(local);
+
+       pci_set_drvdata(pdev, dev);
+
+       if (request_irq(dev->irq, prism2_interrupt, SA_SHIRQ, dev->name,
+                       dev)) {
+               printk(KERN_WARNING "%s: request_irq failed\n", dev->name);
+               goto fail;
+       } else
+               irq_registered = 1;
+
+       if (!local->pri_only && prism2_hw_config(dev, 1)) {
+               printk(KERN_DEBUG "%s: hardware initialization failed\n",
+                      dev_info);
+               goto fail;
+       }
+
+       printk(KERN_INFO "%s: Intersil Prism2.5 PCI: "
+              "mem=0x%lx, irq=%d\n", dev->name, phymem, dev->irq);
+
+       return hostap_hw_ready(dev);
+
+ fail:
+       kfree(hw_priv);
+
+       if (irq_registered && dev)
+               free_irq(dev->irq, dev);
+
+       if (mem)
+               iounmap(mem);
+
+       release_mem_region(phymem, pci_resource_len(pdev, 0));
+
+ err_out_disable:
+       pci_disable_device(pdev);
+       kfree(hw_priv);
+       if (local)
+               local->hw_priv = NULL;
+       prism2_free_local_data(dev);
+
+       return -ENODEV;
+}
+
+
+static void prism2_pci_remove(struct pci_dev *pdev)
+{
+       struct net_device *dev;
+       struct hostap_interface *iface;
+       void __iomem *mem_start;
+       struct hostap_pci_priv *hw_priv;
+
+       dev = pci_get_drvdata(pdev);
+       iface = netdev_priv(dev);
+       hw_priv = iface->local->hw_priv;
+
+       /* Reset the hardware, and ensure interrupts are disabled. */
+       prism2_pci_cor_sreset(iface->local);
+       hfa384x_disable_interrupts(dev);
+
+       if (dev->irq)
+               free_irq(dev->irq, dev);
+
+       mem_start = hw_priv->mem_start;
+       kfree(hw_priv);
+       iface->local->hw_priv = NULL;
+       prism2_free_local_data(dev);
+
+       iounmap(mem_start);
+
+       release_mem_region(pci_resource_start(pdev, 0),
+                          pci_resource_len(pdev, 0));
+       pci_disable_device(pdev);
+}
+
+
+#ifdef CONFIG_PM
+static int prism2_pci_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+       struct net_device *dev = pci_get_drvdata(pdev);
+
+       if (netif_running(dev)) {
+               netif_stop_queue(dev);
+               netif_device_detach(dev);
+       }
+       prism2_suspend(dev);
+       pci_save_state(pdev);
+       pci_disable_device(pdev);
+       pci_set_power_state(pdev, PCI_D3hot);
+
+       return 0;
+}
+
+static int prism2_pci_resume(struct pci_dev *pdev)
+{
+       struct net_device *dev = pci_get_drvdata(pdev);
+
+       pci_enable_device(pdev);
+       pci_restore_state(pdev);
+       prism2_hw_config(dev, 0);
+       if (netif_running(dev)) {
+               netif_device_attach(dev);
+               netif_start_queue(dev);
+       }
+
+       return 0;
+}
+#endif /* CONFIG_PM */
+
+
+MODULE_DEVICE_TABLE(pci, prism2_pci_id_table);
+
+static struct pci_driver prism2_pci_drv_id = {
+       .name           = "prism2_pci",
+       .id_table       = prism2_pci_id_table,
+       .probe          = prism2_pci_probe,
+       .remove         = prism2_pci_remove,
+#ifdef CONFIG_PM
+       .suspend        = prism2_pci_suspend,
+       .resume         = prism2_pci_resume,
+#endif /* CONFIG_PM */
+       /* Linux 2.4.6 added save_state and enable_wake that are not used here
+        */
+};
+
+
+static int __init init_prism2_pci(void)
+{
+       printk(KERN_INFO "%s: %s\n", dev_info, version);
+
+       return pci_register_driver(&prism2_pci_drv_id);
+}
+
+
+static void __exit exit_prism2_pci(void)
+{
+       pci_unregister_driver(&prism2_pci_drv_id);
+       printk(KERN_INFO "%s: Driver unloaded\n", dev_info);
+}
+
+
+module_init(init_prism2_pci);
+module_exit(exit_prism2_pci);
diff --git a/drivers/net/wireless/hostap/hostap_plx.c b/drivers/net/wireless/hostap/hostap_plx.c
new file mode 100644 (file)
index 0000000..474ef83
--- /dev/null
@@ -0,0 +1,645 @@
+#define PRISM2_PLX
+
+/* Host AP driver's support for PC Cards on PCI adapters using PLX9052 is
+ * based on:
+ * - Host AP driver patch from james@madingley.org
+ * - linux-wlan-ng driver, Copyright (C) AbsoluteValue Systems, Inc.
+ */
+
+
+#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/if.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/workqueue.h>
+#include <linux/wireless.h>
+#include <net/iw_handler.h>
+
+#include <linux/ioport.h>
+#include <linux/pci.h>
+#include <asm/io.h>
+
+#include "hostap_wlan.h"
+
+
+static char *version = PRISM2_VERSION " (Jouni Malinen <jkmaline@cc.hut.fi>)";
+static char *dev_info = "hostap_plx";
+
+
+MODULE_AUTHOR("Jouni Malinen");
+MODULE_DESCRIPTION("Support for Intersil Prism2-based 802.11 wireless LAN "
+                  "cards (PLX).");
+MODULE_SUPPORTED_DEVICE("Intersil Prism2-based WLAN cards (PLX)");
+MODULE_LICENSE("GPL");
+MODULE_VERSION(PRISM2_VERSION);
+
+
+static int ignore_cis;
+module_param(ignore_cis, int, 0444);
+MODULE_PARM_DESC(ignore_cis, "Do not verify manfid information in CIS");
+
+
+/* struct local_info::hw_priv */
+struct hostap_plx_priv {
+       void __iomem *attr_mem;
+       unsigned int cor_offset;
+};
+
+
+#define PLX_MIN_ATTR_LEN 512   /* at least 2 x 256 is needed for CIS */
+#define COR_SRESET       0x80
+#define COR_LEVLREQ      0x40
+#define COR_ENABLE_FUNC  0x01
+/* PCI Configuration Registers */
+#define PLX_PCIIPR       0x3d   /* PCI Interrupt Pin */
+/* Local Configuration Registers */
+#define PLX_INTCSR       0x4c   /* Interrupt Control/Status Register */
+#define PLX_INTCSR_PCI_INTEN BIT(6) /* PCI Interrupt Enable */
+#define PLX_CNTRL        0x50
+#define PLX_CNTRL_SERIAL_EEPROM_PRESENT BIT(28)
+
+
+#define PLXDEV(vendor,dev,str) { vendor, dev, PCI_ANY_ID, PCI_ANY_ID }
+
+static struct pci_device_id prism2_plx_id_table[] __devinitdata = {
+       PLXDEV(0x10b7, 0x7770, "3Com AirConnect PCI 777A"),
+       PLXDEV(0x111a, 0x1023, "Siemens SpeedStream SS1023"),
+       PLXDEV(0x126c, 0x8030, "Nortel emobility"),
+       PLXDEV(0x1385, 0x4100, "Netgear MA301"),
+       PLXDEV(0x15e8, 0x0130, "National Datacomm NCP130 (PLX9052)"),
+       PLXDEV(0x15e8, 0x0131, "National Datacomm NCP130 (TMD7160)"),
+       PLXDEV(0x1638, 0x1100, "Eumitcom WL11000"),
+       PLXDEV(0x16ab, 0x1101, "Global Sun Tech GL24110P (?)"),
+       PLXDEV(0x16ab, 0x1102, "Linksys WPC11 with WDT11"),
+       PLXDEV(0x16ab, 0x1103, "Longshine 8031"),
+       PLXDEV(0x16ec, 0x3685, "US Robotics USR2415"),
+       PLXDEV(0xec80, 0xec00, "Belkin F5D6000"),
+       { 0 }
+};
+
+
+/* Array of known Prism2/2.5 PC Card manufactured ids. If your card's manfid
+ * is not listed here, you will need to add it here to get the driver
+ * initialized. */
+static struct prism2_plx_manfid {
+       u16 manfid1, manfid2;
+} prism2_plx_known_manfids[] = {
+       { 0x000b, 0x7110 } /* D-Link DWL-650 Rev. P1 */,
+       { 0x000b, 0x7300 } /* Philips 802.11b WLAN PCMCIA */,
+       { 0x0101, 0x0777 } /* 3Com AirConnect PCI 777A */,
+       { 0x0126, 0x8000 } /* Proxim RangeLAN */,
+       { 0x0138, 0x0002 } /* Compaq WL100 */,
+       { 0x0156, 0x0002 } /* Intersil Prism II Ref. Design (and others) */,
+       { 0x026f, 0x030b } /* Buffalo WLI-CF-S11G */,
+       { 0x0274, 0x1612 } /* Linksys WPC11 Ver 2.5 */,
+       { 0x0274, 0x1613 } /* Linksys WPC11 Ver 3 */,
+       { 0x028a, 0x0002 } /* D-Link DRC-650 */,
+       { 0x0250, 0x0002 } /* Samsung SWL2000-N */,
+       { 0xc250, 0x0002 } /* EMTAC A2424i */,
+       { 0xd601, 0x0002 } /* Z-Com XI300 */,
+       { 0xd601, 0x0005 } /* Zcomax XI-325H 200mW */,
+       { 0, 0}
+};
+
+
+#ifdef PRISM2_IO_DEBUG
+
+static inline void hfa384x_outb_debug(struct net_device *dev, int a, u8 v)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       unsigned long flags;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       spin_lock_irqsave(&local->lock, flags);
+       prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTB, a, v);
+       outb(v, dev->base_addr + a);
+       spin_unlock_irqrestore(&local->lock, flags);
+}
+
+static inline u8 hfa384x_inb_debug(struct net_device *dev, int a)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       unsigned long flags;
+       u8 v;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       spin_lock_irqsave(&local->lock, flags);
+       v = inb(dev->base_addr + a);
+       prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INB, a, v);
+       spin_unlock_irqrestore(&local->lock, flags);
+       return v;
+}
+
+static inline void hfa384x_outw_debug(struct net_device *dev, int a, u16 v)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       unsigned long flags;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       spin_lock_irqsave(&local->lock, flags);
+       prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTW, a, v);
+       outw(v, dev->base_addr + a);
+       spin_unlock_irqrestore(&local->lock, flags);
+}
+
+static inline u16 hfa384x_inw_debug(struct net_device *dev, int a)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       unsigned long flags;
+       u16 v;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       spin_lock_irqsave(&local->lock, flags);
+       v = inw(dev->base_addr + a);
+       prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INW, a, v);
+       spin_unlock_irqrestore(&local->lock, flags);
+       return v;
+}
+
+static inline void hfa384x_outsw_debug(struct net_device *dev, int a,
+                                      u8 *buf, int wc)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       unsigned long flags;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       spin_lock_irqsave(&local->lock, flags);
+       prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTSW, a, wc);
+       outsw(dev->base_addr + a, buf, wc);
+       spin_unlock_irqrestore(&local->lock, flags);
+}
+
+static inline void hfa384x_insw_debug(struct net_device *dev, int a,
+                                     u8 *buf, int wc)
+{
+       struct hostap_interface *iface;
+       local_info_t *local;
+       unsigned long flags;
+
+       iface = netdev_priv(dev);
+       local = iface->local;
+
+       spin_lock_irqsave(&local->lock, flags);
+       prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INSW, a, wc);
+       insw(dev->base_addr + a, buf, wc);
+       spin_unlock_irqrestore(&local->lock, flags);
+}
+
+#define HFA384X_OUTB(v,a) hfa384x_outb_debug(dev, (a), (v))
+#define HFA384X_INB(a) hfa384x_inb_debug(dev, (a))
+#define HFA384X_OUTW(v,a) hfa384x_outw_debug(dev, (a), (v))
+#define HFA384X_INW(a) hfa384x_inw_debug(dev, (a))
+#define HFA384X_OUTSW(a, buf, wc) hfa384x_outsw_debug(dev, (a), (buf), (wc))
+#define HFA384X_INSW(a, buf, wc) hfa384x_insw_debug(dev, (a), (buf), (wc))
+
+#else /* PRISM2_IO_DEBUG */
+
+#define HFA384X_OUTB(v,a) outb((v), dev->base_addr + (a))
+#define HFA384X_INB(a) inb(dev->base_addr + (a))
+#define HFA384X_OUTW(v,a) outw((v), dev->base_addr + (a))
+#define HFA384X_INW(a) inw(dev->base_addr + (a))
+#define HFA384X_INSW(a, buf, wc) insw(dev->base_addr + (a), buf, wc)
+#define HFA384X_OUTSW(a, buf, wc) outsw(dev->base_addr + (a), buf, wc)
+
+#endif /* PRISM2_IO_DEBUG */
+
+
+static int hfa384x_from_bap(struct net_device *dev, u16 bap, void *buf,
+                           int len)
+{
+       u16 d_off;
+       u16 *pos;
+
+       d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
+       pos = (u16 *) buf;
+
+       if (len / 2)
+               HFA384X_INSW(d_off, buf, len / 2);
+       pos += len / 2;
+
+       if (len & 1)
+               *((char *) pos) = HFA384X_INB(d_off);
+
+       return 0;
+}
+
+
+static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len)
+{
+       u16 d_off;
+       u16 *pos;
+
+       d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
+       pos = (u16 *) buf;
+
+       if (len / 2)
+               HFA384X_OUTSW(d_off, buf, len / 2);
+       pos += len / 2;
+
+       if (len & 1)
+               HFA384X_OUTB(*((char *) pos), d_off);
+
+       return 0;
+}
+
+
+/* FIX: This might change at some point.. */
+#include "hostap_hw.c"
+
+
+static void prism2_plx_cor_sreset(local_info_t *local)
+{
+       unsigned char corsave;
+       struct hostap_plx_priv *hw_priv = local->hw_priv;
+
+       printk(KERN_DEBUG "%s: Doing reset via direct COR access.\n",
+              dev_info);
+
+       /* Set sreset bit of COR and clear it after hold time */
+
+       if (hw_priv->attr_mem == NULL) {
+               /* TMD7160 - COR at card's first I/O addr */
+               corsave = inb(hw_priv->cor_offset);
+               outb(corsave | COR_SRESET, hw_priv->cor_offset);
+               mdelay(2);
+               outb(corsave & ~COR_SRESET, hw_priv->cor_offset);
+               mdelay(2);
+       } else {
+               /* PLX9052 */
+               corsave = readb(hw_priv->attr_mem + hw_priv->cor_offset);
+               writeb(corsave | COR_SRESET,
+                      hw_priv->attr_mem + hw_priv->cor_offset);
+               mdelay(2);
+               writeb(corsave & ~COR_SRESET,
+                      hw_priv->attr_mem + hw_priv->cor_offset);
+               mdelay(2);
+       }
+}
+
+
+static void prism2_plx_genesis_reset(local_info_t *local, int hcr)
+{
+       unsigned char corsave;
+       struct hostap_plx_priv *hw_priv = local->hw_priv;
+
+       if (hw_priv->attr_mem == NULL) {
+               /* TMD7160 - COR at card's first I/O addr */
+               corsave = inb(hw_priv->cor_offset);
+               outb(corsave | COR_SRESET, hw_priv->cor_offset);
+               mdelay(10);
+               outb(hcr, hw_priv->cor_offset + 2);
+               mdelay(10);
+               outb(corsave & ~COR_SRESET, hw_priv->cor_offset);
+               mdelay(10);
+       } else {
+               /* PLX9052 */
+               corsave = readb(hw_priv->attr_mem + hw_priv->cor_offset);
+               writeb(corsave | COR_SRESET,
+                      hw_priv->attr_mem + hw_priv->cor_offset);
+               mdelay(10);
+               writeb(hcr, hw_priv->attr_mem + hw_priv->cor_offset + 2);
+               mdelay(10);
+               writeb(corsave & ~COR_SRESET,
+                      hw_priv->attr_mem + hw_priv->cor_offset);
+               mdelay(10);
+       }
+}
+
+
+static struct prism2_helper_functions prism2_plx_funcs =
+{
+       .card_present   = NULL,
+       .cor_sreset     = prism2_plx_cor_sreset,
+       .dev_open       = NULL,
+       .dev_close      = NULL,
+       .genesis_reset  = prism2_plx_genesis_reset,
+       .hw_type        = HOSTAP_HW_PLX,
+};
+
+
+static int prism2_plx_check_cis(void __iomem *attr_mem, int attr_len,
+                               unsigned int *cor_offset,
+                               unsigned int *cor_index)
+{
+#define CISTPL_CONFIG 0x1A
+#define CISTPL_MANFID 0x20
+#define CISTPL_END 0xFF
+#define CIS_MAX_LEN 256
+       u8 *cis;
+       int i, pos;
+       unsigned int rmsz, rasz, manfid1, manfid2;
+       struct prism2_plx_manfid *manfid;
+
+       cis = kmalloc(CIS_MAX_LEN, GFP_KERNEL);
+       if (cis == NULL)
+               return -ENOMEM;
+
+       /* read CIS; it is in even offsets in the beginning of attr_mem */
+       for (i = 0; i < CIS_MAX_LEN; i++)
+               cis[i] = readb(attr_mem + 2 * i);
+       printk(KERN_DEBUG "%s: CIS: %02x %02x %02x %02x %02x %02x ...\n",
+              dev_info, cis[0], cis[1], cis[2], cis[3], cis[4], cis[5]);
+
+       /* set reasonable defaults for Prism2 cards just in case CIS parsing
+        * fails */
+       *cor_offset = 0x3e0;
+       *cor_index = 0x01;
+       manfid1 = manfid2 = 0;
+
+       pos = 0;
+       while (pos < CIS_MAX_LEN - 1 && cis[pos] != CISTPL_END) {
+               if (pos + cis[pos + 1] >= CIS_MAX_LEN)
+                       goto cis_error;
+
+               switch (cis[pos]) {
+               case CISTPL_CONFIG:
+                       if (cis[pos + 1] < 1)
+                               goto cis_error;
+                       rmsz = (cis[pos + 2] & 0x3c) >> 2;
+                       rasz = cis[pos + 2] & 0x03;
+                       if (4 + rasz + rmsz > cis[pos + 1])
+                               goto cis_error;
+                       *cor_index = cis[pos + 3] & 0x3F;
+                       *cor_offset = 0;
+                       for (i = 0; i <= rasz; i++)
+                               *cor_offset += cis[pos + 4 + i] << (8 * i);
+                       printk(KERN_DEBUG "%s: cor_index=0x%x "
+                              "cor_offset=0x%x\n", dev_info,
+                              *cor_index, *cor_offset);
+                       if (*cor_offset > attr_len) {
+                               printk(KERN_ERR "%s: COR offset not within "
+                                      "attr_mem\n", dev_info);
+                               kfree(cis);
+                               return -1;
+                       }
+                       break;
+
+               case CISTPL_MANFID:
+                       if (cis[pos + 1] < 4)
+                               goto cis_error;
+                       manfid1 = cis[pos + 2] + (cis[pos + 3] << 8);
+                       manfid2 = cis[pos + 4] + (cis[pos + 5] << 8);
+                       printk(KERN_DEBUG "%s: manfid=0x%04x, 0x%04x\n",
+                              dev_info, manfid1, manfid2);
+                       break;
+               }
+
+               pos += cis[pos + 1] + 2;
+       }
+
+       if (pos >= CIS_MAX_LEN || cis[pos] != CISTPL_END)
+               goto cis_error;
+
+       for (manfid = prism2_plx_known_manfids; manfid->manfid1 != 0; manfid++)
+               if (manfid1 == manfid->manfid1 && manfid2 == manfid->manfid2) {
+                       kfree(cis);
+                       return 0;
+               }
+
+       printk(KERN_INFO "%s: unknown manfid 0x%04x, 0x%04x - assuming this is"
+              " not supported card\n", dev_info, manfid1, manfid2);
+       goto fail;
+
+ cis_error:
+       printk(KERN_WARNING "%s: invalid CIS data\n", dev_info);
+
+ fail:
+       kfree(cis);
+       if (ignore_cis) {
+               printk(KERN_INFO "%s: ignore_cis parameter set - ignoring "
+                      "errors during CIS verification\n", dev_info);
+               return 0;
+       }
+       return -1;
+}
+
+
+static int prism2_plx_probe(struct pci_dev *pdev,
+                           const struct pci_device_id *id)
+{
+       unsigned int pccard_ioaddr, plx_ioaddr;
+       unsigned long pccard_attr_mem;
+       unsigned int pccard_attr_len;
+       void __iomem *attr_mem = NULL;
+       unsigned int cor_offset, cor_index;
+       u32 reg;
+       local_info_t *local = NULL;
+       struct net_device *dev = NULL;
+       struct hostap_interface *iface;
+       static int cards_found /* = 0 */;
+       int irq_registered = 0;
+       int tmd7160;
+       struct hostap_plx_priv *hw_priv;
+
+       hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
+       if (hw_priv == NULL)
+               return -ENOMEM;
+       memset(hw_priv, 0, sizeof(*hw_priv));
+
+       if (pci_enable_device(pdev))
+               return -EIO;
+
+       /* National Datacomm NCP130 based on TMD7160, not PLX9052. */
+       tmd7160 = (pdev->vendor == 0x15e8) && (pdev->device == 0x0131);
+
+       plx_ioaddr = pci_resource_start(pdev, 1);
+       pccard_ioaddr = pci_resource_start(pdev, tmd7160 ? 2 : 3);
+
+       if (tmd7160) {
+               /* TMD7160 */
+               attr_mem = NULL; /* no access to PC Card attribute memory */
+
+               printk(KERN_INFO "TMD7160 PCI/PCMCIA adapter: io=0x%x, "
+                      "irq=%d, pccard_io=0x%x\n",
+                      plx_ioaddr, pdev->irq, pccard_ioaddr);
+
+               cor_offset = plx_ioaddr;
+               cor_index = 0x04;
+
+               outb(cor_index | COR_LEVLREQ | COR_ENABLE_FUNC, plx_ioaddr);
+               mdelay(1);
+               reg = inb(plx_ioaddr);
+               if (reg != (cor_index | COR_LEVLREQ | COR_ENABLE_FUNC)) {
+                       printk(KERN_ERR "%s: Error setting COR (expected="
+                              "0x%02x, was=0x%02x)\n", dev_info,
+                              cor_index | COR_LEVLREQ | COR_ENABLE_FUNC, reg);
+                       goto fail;
+               }
+       } else {
+               /* PLX9052 */
+               pccard_attr_mem = pci_resource_start(pdev, 2);
+               pccard_attr_len = pci_resource_len(pdev, 2);
+               if (pccard_attr_len < PLX_MIN_ATTR_LEN)
+                       goto fail;
+
+
+               attr_mem = ioremap(pccard_attr_mem, pccard_attr_len);
+               if (attr_mem == NULL) {
+                       printk(KERN_ERR "%s: cannot remap attr_mem\n",
+                              dev_info);
+                       goto fail;
+               }
+
+               printk(KERN_INFO "PLX9052 PCI/PCMCIA adapter: "
+                      "mem=0x%lx, plx_io=0x%x, irq=%d, pccard_io=0x%x\n",
+                      pccard_attr_mem, plx_ioaddr, pdev->irq, pccard_ioaddr);
+
+               if (prism2_plx_check_cis(attr_mem, pccard_attr_len,
+                                        &cor_offset, &cor_index)) {
+                       printk(KERN_INFO "Unknown PC Card CIS - not a "
+                              "Prism2/2.5 card?\n");
+                       goto fail;
+               }
+
+               printk(KERN_DEBUG "Prism2/2.5 PC Card detected in PLX9052 "
+                      "adapter\n");
+
+               /* Write COR to enable PC Card */
+               writeb(cor_index | COR_LEVLREQ | COR_ENABLE_FUNC,
+                      attr_mem + cor_offset);
+
+               /* Enable PCI interrupts if they are not already enabled */
+               reg = inl(plx_ioaddr + PLX_INTCSR);
+               printk(KERN_DEBUG "PLX_INTCSR=0x%x\n", reg);
+               if (!(reg & PLX_INTCSR_PCI_INTEN)) {
+                       outl(reg | PLX_INTCSR_PCI_INTEN,
+                            plx_ioaddr + PLX_INTCSR);
+                       if (!(inl(plx_ioaddr + PLX_INTCSR) &
+                             PLX_INTCSR_PCI_INTEN)) {
+                               printk(KERN_WARNING "%s: Could not enable "
+                                      "Local Interrupts\n", dev_info);
+                               goto fail;
+                       }
+               }
+
+               reg = inl(plx_ioaddr + PLX_CNTRL);
+               printk(KERN_DEBUG "PLX_CNTRL=0x%x (Serial EEPROM "
+                      "present=%d)\n",
+                      reg, (reg & PLX_CNTRL_SERIAL_EEPROM_PRESENT) != 0);
+               /* should set PLX_PCIIPR to 0x01 (INTA#) if Serial EEPROM is
+                * not present; but are there really such cards in use(?) */
+       }
+
+       dev = prism2_init_local_data(&prism2_plx_funcs, cards_found,
+                                    &pdev->dev);
+       if (dev == NULL)
+               goto fail;
+       iface = netdev_priv(dev);
+       local = iface->local;
+       local->hw_priv = hw_priv;
+       cards_found++;
+
+       dev->irq = pdev->irq;
+       dev->base_addr = pccard_ioaddr;
+       hw_priv->attr_mem = attr_mem;
+       hw_priv->cor_offset = cor_offset;
+
+       pci_set_drvdata(pdev, dev);
+
+       if (request_irq(dev->irq, prism2_interrupt, SA_SHIRQ, dev->name,
+                       dev)) {
+               printk(KERN_WARNING "%s: request_irq failed\n", dev->name);
+               goto fail;
+       } else
+               irq_registered = 1;
+
+       if (prism2_hw_config(dev, 1)) {
+               printk(KERN_DEBUG "%s: hardware initialization failed\n",
+                      dev_info);
+               goto fail;
+       }
+
+       return hostap_hw_ready(dev);
+
+ fail:
+       kfree(hw_priv);
+       if (local)
+               local->hw_priv = NULL;
+       prism2_free_local_data(dev);
+
+       if (irq_registered && dev)
+               free_irq(dev->irq, dev);
+
+       if (attr_mem)
+               iounmap(attr_mem);
+
+       pci_disable_device(pdev);
+
+       return -ENODEV;
+}
+
+
+static void prism2_plx_remove(struct pci_dev *pdev)
+{
+       struct net_device *dev;
+       struct hostap_interface *iface;
+       struct hostap_plx_priv *hw_priv;
+
+       dev = pci_get_drvdata(pdev);
+       iface = netdev_priv(dev);
+       hw_priv = iface->local->hw_priv;
+
+       /* Reset the hardware, and ensure interrupts are disabled. */
+       prism2_plx_cor_sreset(iface->local);
+       hfa384x_disable_interrupts(dev);
+
+       if (hw_priv->attr_mem)
+               iounmap(hw_priv->attr_mem);
+       if (dev->irq)
+               free_irq(dev->irq, dev);
+
+       kfree(iface->local->hw_priv);
+       iface->local->hw_priv = NULL;
+       prism2_free_local_data(dev);
+       pci_disable_device(pdev);
+}
+
+
+MODULE_DEVICE_TABLE(pci, prism2_plx_id_table);
+
+static struct pci_driver prism2_plx_drv_id = {
+       .name           = "prism2_plx",
+       .id_table       = prism2_plx_id_table,
+       .probe          = prism2_plx_probe,
+       .remove         = prism2_plx_remove,
+       .suspend        = NULL,
+       .resume         = NULL,
+       .enable_wake    = NULL
+};
+
+
+static int __init init_prism2_plx(void)
+{
+       printk(KERN_INFO "%s: %s\n", dev_info, version);
+
+       return pci_register_driver(&prism2_plx_drv_id);
+}
+
+
+static void __exit exit_prism2_plx(void)
+{
+       pci_unregister_driver(&prism2_plx_drv_id);
+       printk(KERN_INFO "%s: Driver unloaded\n", dev_info);
+}
+
+
+module_init(init_prism2_plx);
+module_exit(exit_prism2_plx);
diff --git a/drivers/net/wireless/hostap/hostap_proc.c b/drivers/net/wireless/hostap/hostap_proc.c
new file mode 100644 (file)
index 0000000..a0a4cbd
--- /dev/null
@@ -0,0 +1,448 @@
+/* /proc routines for Host AP driver */
+
+#define PROC_LIMIT (PAGE_SIZE - 80)
+
+
+#ifndef PRISM2_NO_PROCFS_DEBUG
+static int prism2_debug_proc_read(char *page, char **start, off_t off,
+                                 int count, int *eof, void *data)
+{
+       char *p = page;
+       local_info_t *local = (local_info_t *) data;
+       int i;
+
+       if (off != 0) {
+               *eof = 1;
+               return 0;
+       }
+
+       p += sprintf(p, "next_txfid=%d next_alloc=%d\n",
+                    local->next_txfid, local->next_alloc);
+       for (i = 0; i < PRISM2_TXFID_COUNT; i++)
+               p += sprintf(p, "FID: tx=%04X intransmit=%04X\n",
+                            local->txfid[i], local->intransmitfid[i]);
+       p += sprintf(p, "FW TX rate control: %d\n", local->fw_tx_rate_control);
+       p += sprintf(p, "beacon_int=%d\n", local->beacon_int);
+       p += sprintf(p, "dtim_period=%d\n", local->dtim_period);
+       p += sprintf(p, "wds_max_connections=%d\n",
+                    local->wds_max_connections);
+       p += sprintf(p, "dev_enabled=%d\n", local->dev_enabled);
+       p += sprintf(p, "sw_tick_stuck=%d\n", local->sw_tick_stuck);
+       for (i = 0; i < WEP_KEYS; i++) {
+               if (local->crypt[i] && local->crypt[i]->ops) {
+                       p += sprintf(p, "crypt[%d]=%s\n",
+                                    i, local->crypt[i]->ops->name);
+               }
+       }
+       p += sprintf(p, "pri_only=%d\n", local->pri_only);
+       p += sprintf(p, "pci=%d\n", local->func->hw_type == HOSTAP_HW_PCI);
+       p += sprintf(p, "sram_type=%d\n", local->sram_type);
+       p += sprintf(p, "no_pri=%d\n", local->no_pri);
+
+       return (p - page);
+}
+#endif /* PRISM2_NO_PROCFS_DEBUG */
+
+
+static int prism2_stats_proc_read(char *page, char **start, off_t off,
+                                 int count, int *eof, void *data)
+{
+       char *p = page;
+       local_info_t *local = (local_info_t *) data;
+       struct comm_tallies_sums *sums = (struct comm_tallies_sums *)
+               &local->comm_tallies;
+
+       if (off != 0) {
+               *eof = 1;
+               return 0;
+       }
+
+       p += sprintf(p, "TxUnicastFrames=%u\n", sums->tx_unicast_frames);
+       p += sprintf(p, "TxMulticastframes=%u\n", sums->tx_multicast_frames);
+       p += sprintf(p, "TxFragments=%u\n", sums->tx_fragments);
+       p += sprintf(p, "TxUnicastOctets=%u\n", sums->tx_unicast_octets);
+       p += sprintf(p, "TxMulticastOctets=%u\n", sums->tx_multicast_octets);
+       p += sprintf(p, "TxDeferredTransmissions=%u\n",
+                    sums->tx_deferred_transmissions);
+       p += sprintf(p, "TxSingleRetryFrames=%u\n",
+                    sums->tx_single_retry_frames);
+       p += sprintf(p, "TxMultipleRetryFrames=%u\n",
+                    sums->tx_multiple_retry_frames);
+       p += sprintf(p, "TxRetryLimitExceeded=%u\n",
+                    sums->tx_retry_limit_exceeded);
+       p += sprintf(p, "TxDiscards=%u\n", sums->tx_discards);
+       p += sprintf(p, "RxUnicastFrames=%u\n", sums->rx_unicast_frames);
+       p += sprintf(p, "RxMulticastFrames=%u\n", sums->rx_multicast_frames);
+       p += sprintf(p, "RxFragments=%u\n", sums->rx_fragments);
+       p += sprintf(p, "RxUnicastOctets=%u\n", sums->rx_unicast_octets);
+       p += sprintf(p, "RxMulticastOctets=%u\n", sums->rx_multicast_octets);
+       p += sprintf(p, "RxFCSErrors=%u\n", sums->rx_fcs_errors);
+       p += sprintf(p, "RxDiscardsNoBuffer=%u\n",
+                    sums->rx_discards_no_buffer);
+       p += sprintf(p, "TxDiscardsWrongSA=%u\n", sums->tx_discards_wrong_sa);
+       p += sprintf(p, "RxDiscardsWEPUndecryptable=%u\n",
+                    sums->rx_discards_wep_undecryptable);
+       p += sprintf(p, "RxMessageInMsgFragments=%u\n",
+                    sums->rx_message_in_msg_fragments);
+       p += sprintf(p, "RxMessageInBadMsgFragments=%u\n",
+                    sums->rx_message_in_bad_msg_fragments);
+       /* FIX: this may grow too long for one page(?) */
+
+       return (p - page);
+}
+
+
+static int prism2_wds_proc_read(char *page, char **start, off_t off,
+                               int count, int *eof, void *data)
+{
+       char *p = page;
+       local_info_t *local = (local_info_t *) data;
+       struct list_head *ptr;
+       struct hostap_interface *iface;
+
+       if (off > PROC_LIMIT) {
+               *eof = 1;
+               return 0;
+       }
+
+       read_lock_bh(&local->iface_lock);
+       list_for_each(ptr, &local->hostap_interfaces) {
+               iface = list_entry(ptr, struct hostap_interface, list);
+               if (iface->type != HOSTAP_INTERFACE_WDS)
+                       continue;
+               p += sprintf(p, "%s\t" MACSTR "\n",
+                            iface->dev->name,
+                            MAC2STR(iface->u.wds.remote_addr));
+               if ((p - page) > PROC_LIMIT) {
+                       printk(KERN_DEBUG "%s: wds proc did not fit\n",
+                              local->dev->name);
+                       break;
+               }
+       }
+       read_unlock_bh(&local->iface_lock);
+
+       if ((p - page) <= off) {
+               *eof = 1;
+               return 0;
+       }
+
+       *start = page + off;
+
+       return (p - page - off);
+}
+
+
+static int prism2_bss_list_proc_read(char *page, char **start, off_t off,
+                                    int count, int *eof, void *data)
+{
+       char *p = page;
+       local_info_t *local = (local_info_t *) data;
+       struct list_head *ptr;
+       struct hostap_bss_info *bss;
+       int i;
+
+       if (off > PROC_LIMIT) {
+               *eof = 1;
+               return 0;
+       }
+
+       p += sprintf(p, "#BSSID\tlast_update\tcount\tcapab_info\tSSID(txt)\t"
+                    "SSID(hex)\tWPA IE\n");
+       spin_lock_bh(&local->lock);
+       list_for_each(ptr, &local->bss_list) {
+               bss = list_entry(ptr, struct hostap_bss_info, list);
+               p += sprintf(p, MACSTR "\t%lu\t%u\t0x%x\t",
+                            MAC2STR(bss->bssid), bss->last_update,
+                            bss->count, bss->capab_info);
+               for (i = 0; i < bss->ssid_len; i++) {
+                       p += sprintf(p, "%c",
+                                    bss->ssid[i] >= 32 && bss->ssid[i] < 127 ?
+                                    bss->ssid[i] : '_');
+               }
+               p += sprintf(p, "\t");
+               for (i = 0; i < bss->ssid_len; i++) {
+                       p += sprintf(p, "%02x", bss->ssid[i]);
+               }
+               p += sprintf(p, "\t");
+               for (i = 0; i < bss->wpa_ie_len; i++) {
+                       p += sprintf(p, "%02x", bss->wpa_ie[i]);
+               }
+               p += sprintf(p, "\n");
+               if ((p - page) > PROC_LIMIT) {
+                       printk(KERN_DEBUG "%s: BSS proc did not fit\n",
+                              local->dev->name);
+                       break;
+               }
+       }
+       spin_unlock_bh(&local->lock);
+
+       if ((p - page) <= off) {
+               *eof = 1;
+               return 0;
+       }
+
+       *start = page + off;
+
+       return (p - page - off);
+}
+
+
+static int prism2_crypt_proc_read(char *page, char **start, off_t off,
+                                 int count, int *eof, void *data)
+{
+       char *p = page;
+       local_info_t *local = (local_info_t *) data;
+       int i;
+
+       if (off > PROC_LIMIT) {
+               *eof = 1;
+               return 0;
+       }
+
+       p += sprintf(p, "tx_keyidx=%d\n", local->tx_keyidx);
+       for (i = 0; i < WEP_KEYS; i++) {
+               if (local->crypt[i] && local->crypt[i]->ops &&
+                   local->crypt[i]->ops->print_stats) {
+                       p = local->crypt[i]->ops->print_stats(
+                               p, local->crypt[i]->priv);
+               }
+       }
+
+       if ((p - page) <= off) {
+               *eof = 1;
+               return 0;
+       }
+
+       *start = page + off;
+
+       return (p - page - off);
+}
+
+
+static int prism2_pda_proc_read(char *page, char **start, off_t off,
+                               int count, int *eof, void *data)
+{
+       local_info_t *local = (local_info_t *) data;
+
+       if (local->pda == NULL || off >= PRISM2_PDA_SIZE) {
+               *eof = 1;
+               return 0;
+       }
+
+       if (off + count > PRISM2_PDA_SIZE)
+               count = PRISM2_PDA_SIZE - off;
+
+       memcpy(page, local->pda + off, count);
+       return count;
+}
+
+
+static int prism2_aux_dump_proc_read(char *page, char **start, off_t off,
+                                    int count, int *eof, void *data)
+{
+       local_info_t *local = (local_info_t *) data;
+
+       if (local->func->read_aux == NULL) {
+               *eof = 1;
+               return 0;
+       }
+
+       if (local->func->read_aux(local->dev, off, count, page)) {
+               *eof = 1;
+               return 0;
+       }
+       *start = page;
+
+       return count;
+}
+
+
+#ifdef PRISM2_IO_DEBUG
+static int prism2_io_debug_proc_read(char *page, char **start, off_t off,
+                                    int count, int *eof, void *data)
+{
+       local_info_t *local = (local_info_t *) data;
+       int head = local->io_debug_head;
+       int start_bytes, left, copy, copied;
+
+       if (off + count > PRISM2_IO_DEBUG_SIZE * 4) {
+               *eof = 1;
+               if (off >= PRISM2_IO_DEBUG_SIZE * 4)
+                       return 0;
+               count = PRISM2_IO_DEBUG_SIZE * 4 - off;
+       }
+
+       copied = 0;
+       start_bytes = (PRISM2_IO_DEBUG_SIZE - head) * 4;
+       left = count;
+
+       if (off < start_bytes) {
+               copy = start_bytes - off;
+               if (copy > count)
+                       copy = count;
+               memcpy(page, ((u8 *) &local->io_debug[head]) + off, copy);
+               left -= copy;
+               if (left > 0)
+                       memcpy(&page[copy], local->io_debug, left);
+       } else {
+               memcpy(page, ((u8 *) local->io_debug) + (off - start_bytes),
+                      left);
+       }
+
+       *start = page;
+
+       return count;
+}
+#endif /* PRISM2_IO_DEBUG */
+
+
+#ifndef PRISM2_NO_STATION_MODES
+static int prism2_scan_results_proc_read(char *page, char **start, off_t off,
+                                        int count, int *eof, void *data)
+{
+       char *p = page;
+       local_info_t *local = (local_info_t *) data;
+       int entry, i, len, total = 0;
+       struct hfa384x_hostscan_result *scanres;
+       u8 *pos;
+
+       p += sprintf(p, "CHID ANL SL BcnInt Capab Rate BSSID ATIM SupRates "
+                    "SSID\n");
+
+       spin_lock_bh(&local->lock);
+       for (entry = 0; entry < local->last_scan_results_count; entry++) {
+               scanres = &local->last_scan_results[entry];
+
+               if (total + (p - page) <= off) {
+                       total += p - page;
+                       p = page;
+               }
+               if (total + (p - page) > off + count)
+                       break;
+               if ((p - page) > (PAGE_SIZE - 200))
+                       break;
+
+               p += sprintf(p, "%d %d %d %d 0x%02x %d " MACSTR " %d ",
+                            le16_to_cpu(scanres->chid),
+                            (s16) le16_to_cpu(scanres->anl),
+                            (s16) le16_to_cpu(scanres->sl),
+                            le16_to_cpu(scanres->beacon_interval),
+                            le16_to_cpu(scanres->capability),
+                            le16_to_cpu(scanres->rate),
+                            MAC2STR(scanres->bssid),
+                            le16_to_cpu(scanres->atim));
+
+               pos = scanres->sup_rates;
+               for (i = 0; i < sizeof(scanres->sup_rates); i++) {
+                       if (pos[i] == 0)
+                               break;
+                       p += sprintf(p, "<%02x>", pos[i]);
+               }
+               p += sprintf(p, " ");
+
+               pos = scanres->ssid;
+               len = le16_to_cpu(scanres->ssid_len);
+               if (len > 32)
+                       len = 32;
+               for (i = 0; i < len; i++) {
+                       unsigned char c = pos[i];
+                       if (c >= 32 && c < 127)
+                               p += sprintf(p, "%c", c);
+                       else
+                               p += sprintf(p, "<%02x>", c);
+               }
+               p += sprintf(p, "\n");
+       }
+       spin_unlock_bh(&local->lock);
+
+       total += (p - page);
+       if (total >= off + count)
+               *eof = 1;
+
+       if (total < off) {
+               *eof = 1;
+               return 0;
+       }
+
+       len = total - off;
+       if (len > (p - page))
+               len = p - page;
+       *start = p - len;
+       if (len > count)
+               len = count;
+
+       return len;
+}
+#endif /* PRISM2_NO_STATION_MODES */
+
+
+void hostap_init_proc(local_info_t *local)
+{
+       local->proc = NULL;
+
+       if (hostap_proc == NULL) {
+               printk(KERN_WARNING "%s: hostap proc directory not created\n",
+                      local->dev->name);
+               return;
+       }
+
+       local->proc = proc_mkdir(local->ddev->name, hostap_proc);
+       if (local->proc == NULL) {
+               printk(KERN_INFO "/proc/net/hostap/%s creation failed\n",
+                      local->ddev->name);
+               return;
+       }
+
+#ifndef PRISM2_NO_PROCFS_DEBUG
+       create_proc_read_entry("debug", 0, local->proc,
+                              prism2_debug_proc_read, local);
+#endif /* PRISM2_NO_PROCFS_DEBUG */
+       create_proc_read_entry("stats", 0, local->proc,
+                              prism2_stats_proc_read, local);
+       create_proc_read_entry("wds", 0, local->proc,
+                              prism2_wds_proc_read, local);
+       create_proc_read_entry("pda", 0, local->proc,
+                              prism2_pda_proc_read, local);
+       create_proc_read_entry("aux_dump", 0, local->proc,
+                              prism2_aux_dump_proc_read, local);
+       create_proc_read_entry("bss_list", 0, local->proc,
+                              prism2_bss_list_proc_read, local);
+       create_proc_read_entry("crypt", 0, local->proc,
+                              prism2_crypt_proc_read, local);
+#ifdef PRISM2_IO_DEBUG
+       create_proc_read_entry("io_debug", 0, local->proc,
+                              prism2_io_debug_proc_read, local);
+#endif /* PRISM2_IO_DEBUG */
+#ifndef PRISM2_NO_STATION_MODES
+       create_proc_read_entry("scan_results", 0, local->proc,
+                              prism2_scan_results_proc_read, local);
+#endif /* PRISM2_NO_STATION_MODES */
+}
+
+
+void hostap_remove_proc(local_info_t *local)
+{
+       if (local->proc != NULL) {
+#ifndef PRISM2_NO_STATION_MODES
+               remove_proc_entry("scan_results", local->proc);
+#endif /* PRISM2_NO_STATION_MODES */
+#ifdef PRISM2_IO_DEBUG
+               remove_proc_entry("io_debug", local->proc);
+#endif /* PRISM2_IO_DEBUG */
+               remove_proc_entry("pda", local->proc);
+               remove_proc_entry("aux_dump", local->proc);
+               remove_proc_entry("wds", local->proc);
+               remove_proc_entry("stats", local->proc);
+               remove_proc_entry("bss_list", local->proc);
+               remove_proc_entry("crypt", local->proc);
+#ifndef PRISM2_NO_PROCFS_DEBUG
+               remove_proc_entry("debug", local->proc);
+#endif /* PRISM2_NO_PROCFS_DEBUG */
+               if (hostap_proc != NULL)
+                       remove_proc_entry(local->proc->name, hostap_proc);
+       }
+}
+
+
+EXPORT_SYMBOL(hostap_init_proc);
+EXPORT_SYMBOL(hostap_remove_proc);
diff --git a/drivers/net/wireless/hostap/hostap_wlan.h b/drivers/net/wireless/hostap/hostap_wlan.h
new file mode 100644 (file)
index 0000000..cc061e1
--- /dev/null
@@ -0,0 +1,1033 @@
+#ifndef HOSTAP_WLAN_H
+#define HOSTAP_WLAN_H
+
+#include "hostap_config.h"
+#include "hostap_common.h"
+
+#define MAX_PARM_DEVICES 8
+#define PARM_MIN_MAX "1-" __MODULE_STRING(MAX_PARM_DEVICES)
+#define DEF_INTS -1, -1, -1, -1, -1, -1, -1
+#define GET_INT_PARM(var,idx) var[var[idx] < 0 ? 0 : idx]
+
+
+/* Specific skb->protocol value that indicates that the packet already contains
+ * txdesc header.
+ * FIX: This might need own value that would be allocated especially for Prism2
+ * txdesc; ETH_P_CONTROL is commented as "Card specific control frames".
+ * However, these skb's should have only minimal path in the kernel side since
+ * prism2_send_mgmt() sends these with dev_queue_xmit() to prism2_tx(). */
+#define ETH_P_HOSTAP ETH_P_CONTROL
+
+/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header
+ * (from linux-wlan-ng) */
+struct linux_wlan_ng_val {
+       u32 did;
+       u16 status, len;
+       u32 data;
+} __attribute__ ((packed));
+
+struct linux_wlan_ng_prism_hdr {
+       u32 msgcode, msglen;
+       char devname[16];
+       struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal,
+               noise, rate, istx, frmlen;
+} __attribute__ ((packed));
+
+struct linux_wlan_ng_cap_hdr {
+       u32 version;
+       u32 length;
+       u64 mactime;
+       u64 hosttime;
+       u32 phytype;
+       u32 channel;
+       u32 datarate;
+       u32 antenna;
+       u32 priority;
+       u32 ssi_type;
+       s32 ssi_signal;
+       s32 ssi_noise;
+       u32 preamble;
+       u32 encoding;
+} __attribute__ ((packed));
+
+#define LWNG_CAP_DID_BASE   (4 | (1 << 6)) /* section 4, group 1 */
+#define LWNG_CAPHDR_VERSION 0x80211001
+
+struct hfa384x_rx_frame {
+       /* HFA384X RX frame descriptor */
+       u16 status; /* HFA384X_RX_STATUS_ flags */
+       u32 time; /* timestamp, 1 microsecond resolution */
+       u8 silence; /* 27 .. 154; seems to be 0 */
+       u8 signal; /* 27 .. 154 */
+       u8 rate; /* 10, 20, 55, or 110 */
+       u8 rxflow;
+       u32 reserved;
+
+       /* 802.11 */
+       u16 frame_control;
+       u16 duration_id;
+       u8 addr1[6];
+       u8 addr2[6];
+       u8 addr3[6];
+       u16 seq_ctrl;
+       u8 addr4[6];
+       u16 data_len;
+
+       /* 802.3 */
+       u8 dst_addr[6];
+       u8 src_addr[6];
+       u16 len;
+
+       /* followed by frame data; max 2304 bytes */
+} __attribute__ ((packed));
+
+
+struct hfa384x_tx_frame {
+       /* HFA384X TX frame descriptor */
+       u16 status; /* HFA384X_TX_STATUS_ flags */
+       u16 reserved1;
+       u16 reserved2;
+       u32 sw_support;
+       u8 retry_count; /* not yet implemented */
+       u8 tx_rate; /* Host AP only; 0 = firmware, or 10, 20, 55, 110 */
+       u16 tx_control; /* HFA384X_TX_CTRL_ flags */
+
+       /* 802.11 */
+       u16 frame_control; /* parts not used */
+       u16 duration_id;
+       u8 addr1[6];
+       u8 addr2[6]; /* filled by firmware */
+       u8 addr3[6];
+       u16 seq_ctrl; /* filled by firmware */
+       u8 addr4[6];
+       u16 data_len;
+
+       /* 802.3 */
+       u8 dst_addr[6];
+       u8 src_addr[6];
+       u16 len;
+
+       /* followed by frame data; max 2304 bytes */
+} __attribute__ ((packed));
+
+
+struct hfa384x_rid_hdr
+{
+       u16 len;
+       u16 rid;
+} __attribute__ ((packed));
+
+
+/* Macro for converting signal levels (range 27 .. 154) to wireless ext
+ * dBm value with some accuracy */
+#define HFA384X_LEVEL_TO_dBm(v) 0x100 + (v) * 100 / 255 - 100
+
+#define HFA384X_LEVEL_TO_dBm_sign(v) (v) * 100 / 255 - 100
+
+struct hfa384x_scan_request {
+       u16 channel_list;
+       u16 txrate; /* HFA384X_RATES_* */
+} __attribute__ ((packed));
+
+struct hfa384x_hostscan_request {
+       u16 channel_list;
+       u16 txrate;
+       u16 target_ssid_len;
+       u8 target_ssid[32];
+} __attribute__ ((packed));
+
+struct hfa384x_join_request {
+       u8 bssid[6];
+       u16 channel;
+} __attribute__ ((packed));
+
+struct hfa384x_info_frame {
+       u16 len;
+       u16 type;
+} __attribute__ ((packed));
+
+struct hfa384x_comm_tallies {
+       u16 tx_unicast_frames;
+       u16 tx_multicast_frames;
+       u16 tx_fragments;
+       u16 tx_unicast_octets;
+       u16 tx_multicast_octets;
+       u16 tx_deferred_transmissions;
+       u16 tx_single_retry_frames;
+       u16 tx_multiple_retry_frames;
+       u16 tx_retry_limit_exceeded;
+       u16 tx_discards;
+       u16 rx_unicast_frames;
+       u16 rx_multicast_frames;
+       u16 rx_fragments;
+       u16 rx_unicast_octets;
+       u16 rx_multicast_octets;
+       u16 rx_fcs_errors;
+       u16 rx_discards_no_buffer;
+       u16 tx_discards_wrong_sa;
+       u16 rx_discards_wep_undecryptable;
+       u16 rx_message_in_msg_fragments;
+       u16 rx_message_in_bad_msg_fragments;
+} __attribute__ ((packed));
+
+struct hfa384x_comm_tallies32 {
+       u32 tx_unicast_frames;
+       u32 tx_multicast_frames;
+       u32 tx_fragments;
+       u32 tx_unicast_octets;
+       u32 tx_multicast_octets;
+       u32 tx_deferred_transmissions;
+       u32 tx_single_retry_frames;
+       u32 tx_multiple_retry_frames;
+       u32 tx_retry_limit_exceeded;
+       u32 tx_discards;
+       u32 rx_unicast_frames;
+       u32 rx_multicast_frames;
+       u32 rx_fragments;
+       u32 rx_unicast_octets;
+       u32 rx_multicast_octets;
+       u32 rx_fcs_errors;
+       u32 rx_discards_no_buffer;
+       u32 tx_discards_wrong_sa;
+       u32 rx_discards_wep_undecryptable;
+       u32 rx_message_in_msg_fragments;
+       u32 rx_message_in_bad_msg_fragments;
+} __attribute__ ((packed));
+
+struct hfa384x_scan_result_hdr {
+       u16 reserved;
+       u16 scan_reason;
+#define HFA384X_SCAN_IN_PROGRESS 0 /* no results available yet */
+#define HFA384X_SCAN_HOST_INITIATED 1
+#define HFA384X_SCAN_FIRMWARE_INITIATED 2
+#define HFA384X_SCAN_INQUIRY_FROM_HOST 3
+} __attribute__ ((packed));
+
+#define HFA384X_SCAN_MAX_RESULTS 32
+
+struct hfa384x_scan_result {
+       u16 chid;
+       u16 anl;
+       u16 sl;
+       u8 bssid[6];
+       u16 beacon_interval;
+       u16 capability;
+       u16 ssid_len;
+       u8 ssid[32];
+       u8 sup_rates[10];
+       u16 rate;
+} __attribute__ ((packed));
+
+struct hfa384x_hostscan_result {
+       u16 chid;
+       u16 anl;
+       u16 sl;
+       u8 bssid[6];
+       u16 beacon_interval;
+       u16 capability;
+       u16 ssid_len;
+       u8 ssid[32];
+       u8 sup_rates[10];
+       u16 rate;
+       u16 atim;
+} __attribute__ ((packed));
+
+struct comm_tallies_sums {
+       unsigned int tx_unicast_frames;
+       unsigned int tx_multicast_frames;
+       unsigned int tx_fragments;
+       unsigned int tx_unicast_octets;
+       unsigned int tx_multicast_octets;
+       unsigned int tx_deferred_transmissions;
+       unsigned int tx_single_retry_frames;
+       unsigned int tx_multiple_retry_frames;
+       unsigned int tx_retry_limit_exceeded;
+       unsigned int tx_discards;
+       unsigned int rx_unicast_frames;
+       unsigned int rx_multicast_frames;
+       unsigned int rx_fragments;
+       unsigned int rx_unicast_octets;
+       unsigned int rx_multicast_octets;
+       unsigned int rx_fcs_errors;
+       unsigned int rx_discards_no_buffer;
+       unsigned int tx_discards_wrong_sa;
+       unsigned int rx_discards_wep_undecryptable;
+       unsigned int rx_message_in_msg_fragments;
+       unsigned int rx_message_in_bad_msg_fragments;
+};
+
+
+struct hfa384x_regs {
+       u16 cmd;
+       u16 evstat;
+       u16 offset0;
+       u16 offset1;
+       u16 swsupport0;
+};
+
+
+#if defined(PRISM2_PCCARD) || defined(PRISM2_PLX)
+/* I/O ports for HFA384X Controller access */
+#define HFA384X_CMD_OFF 0x00
+#define HFA384X_PARAM0_OFF 0x02
+#define HFA384X_PARAM1_OFF 0x04
+#define HFA384X_PARAM2_OFF 0x06
+#define HFA384X_STATUS_OFF 0x08
+#define HFA384X_RESP0_OFF 0x0A
+#define HFA384X_RESP1_OFF 0x0C
+#define HFA384X_RESP2_OFF 0x0E
+#define HFA384X_INFOFID_OFF 0x10
+#define HFA384X_CONTROL_OFF 0x14
+#define HFA384X_SELECT0_OFF 0x18
+#define HFA384X_SELECT1_OFF 0x1A
+#define HFA384X_OFFSET0_OFF 0x1C
+#define HFA384X_OFFSET1_OFF 0x1E
+#define HFA384X_RXFID_OFF 0x20
+#define HFA384X_ALLOCFID_OFF 0x22
+#define HFA384X_TXCOMPLFID_OFF 0x24
+#define HFA384X_SWSUPPORT0_OFF 0x28
+#define HFA384X_SWSUPPORT1_OFF 0x2A
+#define HFA384X_SWSUPPORT2_OFF 0x2C
+#define HFA384X_EVSTAT_OFF 0x30
+#define HFA384X_INTEN_OFF 0x32
+#define HFA384X_EVACK_OFF 0x34
+#define HFA384X_DATA0_OFF 0x36
+#define HFA384X_DATA1_OFF 0x38
+#define HFA384X_AUXPAGE_OFF 0x3A
+#define HFA384X_AUXOFFSET_OFF 0x3C
+#define HFA384X_AUXDATA_OFF 0x3E
+#endif /* PRISM2_PCCARD || PRISM2_PLX */
+
+#ifdef PRISM2_PCI
+/* Memory addresses for ISL3874 controller access */
+#define HFA384X_CMD_OFF 0x00
+#define HFA384X_PARAM0_OFF 0x04
+#define HFA384X_PARAM1_OFF 0x08
+#define HFA384X_PARAM2_OFF 0x0C
+#define HFA384X_STATUS_OFF 0x10
+#define HFA384X_RESP0_OFF 0x14
+#define HFA384X_RESP1_OFF 0x18
+#define HFA384X_RESP2_OFF 0x1C
+#define HFA384X_INFOFID_OFF 0x20
+#define HFA384X_CONTROL_OFF 0x28
+#define HFA384X_SELECT0_OFF 0x30
+#define HFA384X_SELECT1_OFF 0x34
+#define HFA384X_OFFSET0_OFF 0x38
+#define HFA384X_OFFSET1_OFF 0x3C
+#define HFA384X_RXFID_OFF 0x40
+#define HFA384X_ALLOCFID_OFF 0x44
+#define HFA384X_TXCOMPLFID_OFF 0x48
+#define HFA384X_PCICOR_OFF 0x4C
+#define HFA384X_SWSUPPORT0_OFF 0x50
+#define HFA384X_SWSUPPORT1_OFF 0x54
+#define HFA384X_SWSUPPORT2_OFF 0x58
+#define HFA384X_PCIHCR_OFF 0x5C
+#define HFA384X_EVSTAT_OFF 0x60
+#define HFA384X_INTEN_OFF 0x64
+#define HFA384X_EVACK_OFF 0x68
+#define HFA384X_DATA0_OFF 0x6C
+#define HFA384X_DATA1_OFF 0x70
+#define HFA384X_AUXPAGE_OFF 0x74
+#define HFA384X_AUXOFFSET_OFF 0x78
+#define HFA384X_AUXDATA_OFF 0x7C
+#define HFA384X_PCI_M0_ADDRH_OFF 0x80
+#define HFA384X_PCI_M0_ADDRL_OFF 0x84
+#define HFA384X_PCI_M0_LEN_OFF 0x88
+#define HFA384X_PCI_M0_CTL_OFF 0x8C
+#define HFA384X_PCI_STATUS_OFF 0x98
+#define HFA384X_PCI_M1_ADDRH_OFF 0xA0
+#define HFA384X_PCI_M1_ADDRL_OFF 0xA4
+#define HFA384X_PCI_M1_LEN_OFF 0xA8
+#define HFA384X_PCI_M1_CTL_OFF 0xAC
+
+/* PCI bus master control bits (these are undocumented; based on guessing and
+ * experimenting..) */
+#define HFA384X_PCI_CTL_FROM_BAP (BIT(5) | BIT(1) | BIT(0))
+#define HFA384X_PCI_CTL_TO_BAP (BIT(5) | BIT(0))
+
+#endif /* PRISM2_PCI */
+
+
+/* Command codes for CMD reg. */
+#define HFA384X_CMDCODE_INIT 0x00
+#define HFA384X_CMDCODE_ENABLE 0x01
+#define HFA384X_CMDCODE_DISABLE 0x02
+#define HFA384X_CMDCODE_ALLOC 0x0A
+#define HFA384X_CMDCODE_TRANSMIT 0x0B
+#define HFA384X_CMDCODE_INQUIRE 0x11
+#define HFA384X_CMDCODE_ACCESS 0x21
+#define HFA384X_CMDCODE_ACCESS_WRITE (0x21 | BIT(8))
+#define HFA384X_CMDCODE_DOWNLOAD 0x22
+#define HFA384X_CMDCODE_READMIF 0x30
+#define HFA384X_CMDCODE_WRITEMIF 0x31
+#define HFA384X_CMDCODE_TEST 0x38
+
+#define HFA384X_CMDCODE_MASK 0x3F
+
+/* Test mode operations */
+#define HFA384X_TEST_CHANGE_CHANNEL 0x08
+#define HFA384X_TEST_MONITOR 0x0B
+#define HFA384X_TEST_STOP 0x0F
+#define HFA384X_TEST_CFG_BITS 0x15
+#define HFA384X_TEST_CFG_BIT_ALC BIT(3)
+
+#define HFA384X_CMD_BUSY BIT(15)
+
+#define HFA384X_CMD_TX_RECLAIM BIT(8)
+
+#define HFA384X_OFFSET_ERR BIT(14)
+#define HFA384X_OFFSET_BUSY BIT(15)
+
+
+/* ProgMode for download command */
+#define HFA384X_PROGMODE_DISABLE 0
+#define HFA384X_PROGMODE_ENABLE_VOLATILE 1
+#define HFA384X_PROGMODE_ENABLE_NON_VOLATILE 2
+#define HFA384X_PROGMODE_PROGRAM_NON_VOLATILE 3
+
+#define HFA384X_AUX_MAGIC0 0xfe01
+#define HFA384X_AUX_MAGIC1 0xdc23
+#define HFA384X_AUX_MAGIC2 0xba45
+
+#define HFA384X_AUX_PORT_DISABLED 0
+#define HFA384X_AUX_PORT_DISABLE BIT(14)
+#define HFA384X_AUX_PORT_ENABLE BIT(15)
+#define HFA384X_AUX_PORT_ENABLED (BIT(14) | BIT(15))
+#define HFA384X_AUX_PORT_MASK (BIT(14) | BIT(15))
+
+#define PRISM2_PDA_SIZE 1024
+
+
+/* Events; EvStat, Interrupt mask (IntEn), and acknowledge bits (EvAck) */
+#define HFA384X_EV_TICK BIT(15)
+#define HFA384X_EV_WTERR BIT(14)
+#define HFA384X_EV_INFDROP BIT(13)
+#ifdef PRISM2_PCI
+#define HFA384X_EV_PCI_M1 BIT(9)
+#define HFA384X_EV_PCI_M0 BIT(8)
+#endif /* PRISM2_PCI */
+#define HFA384X_EV_INFO BIT(7)
+#define HFA384X_EV_DTIM BIT(5)
+#define HFA384X_EV_CMD BIT(4)
+#define HFA384X_EV_ALLOC BIT(3)
+#define HFA384X_EV_TXEXC BIT(2)
+#define HFA384X_EV_TX BIT(1)
+#define HFA384X_EV_RX BIT(0)
+
+
+/* HFA384X Information frames */
+#define HFA384X_INFO_HANDOVERADDR 0xF000 /* AP f/w ? */
+#define HFA384X_INFO_HANDOVERDEAUTHADDR 0xF001 /* AP f/w 1.3.7 */
+#define HFA384X_INFO_COMMTALLIES 0xF100
+#define HFA384X_INFO_SCANRESULTS 0xF101
+#define HFA384X_INFO_CHANNELINFORESULTS 0xF102 /* AP f/w only */
+#define HFA384X_INFO_HOSTSCANRESULTS 0xF103
+#define HFA384X_INFO_LINKSTATUS 0xF200
+#define HFA384X_INFO_ASSOCSTATUS 0xF201 /* ? */
+#define HFA384X_INFO_AUTHREQ 0xF202 /* ? */
+#define HFA384X_INFO_PSUSERCNT 0xF203 /* ? */
+#define HFA384X_INFO_KEYIDCHANGED 0xF204 /* ? */
+
+enum { HFA384X_LINKSTATUS_CONNECTED = 1,
+       HFA384X_LINKSTATUS_DISCONNECTED = 2,
+       HFA384X_LINKSTATUS_AP_CHANGE = 3,
+       HFA384X_LINKSTATUS_AP_OUT_OF_RANGE = 4,
+       HFA384X_LINKSTATUS_AP_IN_RANGE = 5,
+       HFA384X_LINKSTATUS_ASSOC_FAILED = 6 };
+
+enum { HFA384X_PORTTYPE_BSS = 1, HFA384X_PORTTYPE_WDS = 2,
+       HFA384X_PORTTYPE_PSEUDO_IBSS = 3, HFA384X_PORTTYPE_IBSS = 0,
+       HFA384X_PORTTYPE_HOSTAP = 6 };
+
+#define HFA384X_RATES_1MBPS BIT(0)
+#define HFA384X_RATES_2MBPS BIT(1)
+#define HFA384X_RATES_5MBPS BIT(2)
+#define HFA384X_RATES_11MBPS BIT(3)
+
+#define HFA384X_ROAMING_FIRMWARE 1
+#define HFA384X_ROAMING_HOST 2
+#define HFA384X_ROAMING_DISABLED 3
+
+#define HFA384X_WEPFLAGS_PRIVACYINVOKED BIT(0)
+#define HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED BIT(1)
+#define HFA384X_WEPFLAGS_HOSTENCRYPT BIT(4)
+#define HFA384X_WEPFLAGS_HOSTDECRYPT BIT(7)
+
+#define HFA384X_RX_STATUS_MSGTYPE (BIT(15) | BIT(14) | BIT(13))
+#define HFA384X_RX_STATUS_PCF BIT(12)
+#define HFA384X_RX_STATUS_MACPORT (BIT(10) | BIT(9) | BIT(8))
+#define HFA384X_RX_STATUS_UNDECR BIT(1)
+#define HFA384X_RX_STATUS_FCSERR BIT(0)
+
+#define HFA384X_RX_STATUS_GET_MSGTYPE(s) \
+(((s) & HFA384X_RX_STATUS_MSGTYPE) >> 13)
+#define HFA384X_RX_STATUS_GET_MACPORT(s) \
+(((s) & HFA384X_RX_STATUS_MACPORT) >> 8)
+
+enum { HFA384X_RX_MSGTYPE_NORMAL = 0, HFA384X_RX_MSGTYPE_RFC1042 = 1,
+       HFA384X_RX_MSGTYPE_BRIDGETUNNEL = 2, HFA384X_RX_MSGTYPE_MGMT = 4 };
+
+
+#define HFA384X_TX_CTRL_ALT_RTRY BIT(5)
+#define HFA384X_TX_CTRL_802_11 BIT(3)
+#define HFA384X_TX_CTRL_802_3 0
+#define HFA384X_TX_CTRL_TX_EX BIT(2)
+#define HFA384X_TX_CTRL_TX_OK BIT(1)
+
+#define HFA384X_TX_STATUS_RETRYERR BIT(0)
+#define HFA384X_TX_STATUS_AGEDERR BIT(1)
+#define HFA384X_TX_STATUS_DISCON BIT(2)
+#define HFA384X_TX_STATUS_FORMERR BIT(3)
+
+/* HFA3861/3863 (BBP) Control Registers */
+#define HFA386X_CR_TX_CONFIGURE 0x12 /* CR9 */
+#define HFA386X_CR_RX_CONFIGURE 0x14 /* CR10 */
+#define HFA386X_CR_A_D_TEST_MODES2 0x1A /* CR13 */
+#define HFA386X_CR_MANUAL_TX_POWER 0x3E /* CR31 */
+#define HFA386X_CR_MEASURED_TX_POWER 0x74 /* CR58 */
+
+
+#ifdef __KERNEL__
+
+#define PRISM2_TXFID_COUNT 8
+#define PRISM2_DATA_MAXLEN 2304
+#define PRISM2_TXFID_LEN (PRISM2_DATA_MAXLEN + sizeof(struct hfa384x_tx_frame))
+#define PRISM2_TXFID_EMPTY 0xffff
+#define PRISM2_TXFID_RESERVED 0xfffe
+#define PRISM2_DUMMY_FID 0xffff
+#define MAX_SSID_LEN 32
+#define MAX_NAME_LEN 32 /* this is assumed to be equal to MAX_SSID_LEN */
+
+#define PRISM2_DUMP_RX_HDR BIT(0)
+#define PRISM2_DUMP_TX_HDR BIT(1)
+#define PRISM2_DUMP_TXEXC_HDR BIT(2)
+
+struct hostap_tx_callback_info {
+       u16 idx;
+       void (*func)(struct sk_buff *, int ok, void *);
+       void *data;
+       struct hostap_tx_callback_info *next;
+};
+
+
+/* IEEE 802.11 requires that STA supports concurrent reception of at least
+ * three fragmented frames. This define can be increased to support more
+ * concurrent frames, but it should be noted that each entry can consume about
+ * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
+#define PRISM2_FRAG_CACHE_LEN 4
+
+struct prism2_frag_entry {
+       unsigned long first_frag_time;
+       unsigned int seq;
+       unsigned int last_frag;
+       struct sk_buff *skb;
+       u8 src_addr[ETH_ALEN];
+       u8 dst_addr[ETH_ALEN];
+};
+
+
+struct hostap_cmd_queue {
+       struct list_head list;
+       wait_queue_head_t compl;
+       volatile enum { CMD_SLEEP, CMD_CALLBACK, CMD_COMPLETED } type;
+       void (*callback)(struct net_device *dev, long context, u16 resp0,
+                        u16 res);
+       long context;
+       u16 cmd, param0, param1;
+       u16 resp0, res;
+       volatile int issued, issuing;
+
+       atomic_t usecnt;
+       int del_req;
+};
+
+/* options for hw_shutdown */
+#define HOSTAP_HW_NO_DISABLE BIT(0)
+#define HOSTAP_HW_ENABLE_CMDCOMPL BIT(1)
+
+typedef struct local_info local_info_t;
+
+struct prism2_helper_functions {
+       /* these functions are defined in hardware model specific files
+        * (hostap_{cs,plx,pci}.c */
+       int (*card_present)(local_info_t *local);
+       void (*cor_sreset)(local_info_t *local);
+       int (*dev_open)(local_info_t *local);
+       int (*dev_close)(local_info_t *local);
+       void (*genesis_reset)(local_info_t *local, int hcr);
+
+       /* the following functions are from hostap_hw.c, but they may have some
+        * hardware model specific code */
+
+       /* FIX: low-level commands like cmd might disappear at some point to
+        * make it easier to change them if needed (e.g., cmd would be replaced
+        * with write_mif/read_mif/testcmd/inquire); at least get_rid and
+        * set_rid might move to hostap_{cs,plx,pci}.c */
+       int (*cmd)(struct net_device *dev, u16 cmd, u16 param0, u16 *param1,
+                  u16 *resp0);
+       void (*read_regs)(struct net_device *dev, struct hfa384x_regs *regs);
+       int (*get_rid)(struct net_device *dev, u16 rid, void *buf, int len,
+                      int exact_len);
+       int (*set_rid)(struct net_device *dev, u16 rid, void *buf, int len);
+       int (*hw_enable)(struct net_device *dev, int initial);
+       int (*hw_config)(struct net_device *dev, int initial);
+       void (*hw_reset)(struct net_device *dev);
+       void (*hw_shutdown)(struct net_device *dev, int no_disable);
+       int (*reset_port)(struct net_device *dev);
+       void (*schedule_reset)(local_info_t *local);
+       int (*download)(local_info_t *local,
+                       struct prism2_download_param *param);
+       int (*tx)(struct sk_buff *skb, struct net_device *dev);
+       int (*set_tim)(struct net_device *dev, int aid, int set);
+       int (*read_aux)(struct net_device *dev, unsigned addr, int len,
+                       u8 *buf);
+
+       int need_tx_headroom; /* number of bytes of headroom needed before
+                              * IEEE 802.11 header */
+       enum { HOSTAP_HW_PCCARD, HOSTAP_HW_PLX, HOSTAP_HW_PCI } hw_type;
+};
+
+
+struct prism2_download_data {
+       u32 dl_cmd;
+       u32 start_addr;
+       u32 num_areas;
+       struct prism2_download_data_area {
+               u32 addr; /* wlan card address */
+               u32 len;
+               u8 *data; /* allocated data */
+       } data[0];
+};
+
+
+#define HOSTAP_MAX_BSS_COUNT 64
+#define MAX_WPA_IE_LEN 64
+
+struct hostap_bss_info {
+       struct list_head list;
+       unsigned long last_update;
+       unsigned int count;
+       u8 bssid[ETH_ALEN];
+       u16 capab_info;
+       u8 ssid[32];
+       size_t ssid_len;
+       u8 wpa_ie[MAX_WPA_IE_LEN];
+       size_t wpa_ie_len;
+       u8 rsn_ie[MAX_WPA_IE_LEN];
+       size_t rsn_ie_len;
+       int chan;
+       int included;
+};
+
+
+/* Per radio private Host AP data - shared by all net devices interfaces used
+ * by each radio (wlan#, wlan#ap, wlan#sta, WDS).
+ * ((struct hostap_interface *) netdev_priv(dev))->local points to this
+ * structure. */
+struct local_info {
+       struct module *hw_module;
+       int card_idx;
+       int dev_enabled;
+       int master_dev_auto_open; /* was master device opened automatically */
+       int num_dev_open; /* number of open devices */
+       struct net_device *dev; /* master radio device */
+       struct net_device *ddev; /* main data device */
+       struct list_head hostap_interfaces; /* Host AP interface list (contains
+                                            * struct hostap_interface entries)
+                                            */
+       rwlock_t iface_lock; /* hostap_interfaces read lock; use write lock
+                             * when removing entries from the list.
+                             * TX and RX paths can use read lock. */
+       spinlock_t cmdlock, baplock, lock;
+       struct semaphore rid_bap_sem;
+       u16 infofid; /* MAC buffer id for info frame */
+       /* txfid, intransmitfid, next_txtid, and next_alloc are protected by
+        * txfidlock */
+       spinlock_t txfidlock;
+       int txfid_len; /* length of allocated TX buffers */
+       u16 txfid[PRISM2_TXFID_COUNT]; /* buffer IDs for TX frames */
+       /* buffer IDs for intransmit frames or PRISM2_TXFID_EMPTY if
+        * corresponding txfid is free for next TX frame */
+       u16 intransmitfid[PRISM2_TXFID_COUNT];
+       int next_txfid; /* index to the next txfid to be checked for
+                        * availability */
+       int next_alloc; /* index to the next intransmitfid to be checked for
+                        * allocation events */
+
+       /* bitfield for atomic bitops */
+#define HOSTAP_BITS_TRANSMIT 0
+#define HOSTAP_BITS_BAP_TASKLET 1
+#define HOSTAP_BITS_BAP_TASKLET2 2
+       long bits;
+
+       struct ap_data *ap;
+
+       char essid[MAX_SSID_LEN + 1];
+       char name[MAX_NAME_LEN + 1];
+       int name_set;
+       u16 channel_mask; /* mask of allowed channels */
+       u16 scan_channel_mask; /* mask of channels to be scanned */
+       struct comm_tallies_sums comm_tallies;
+       struct net_device_stats stats;
+       struct proc_dir_entry *proc;
+       int iw_mode; /* operating mode (IW_MODE_*) */
+       int pseudo_adhoc; /* 0: IW_MODE_ADHOC is real 802.11 compliant IBSS
+                          * 1: IW_MODE_ADHOC is "pseudo IBSS" */
+       char bssid[ETH_ALEN];
+       int channel;
+       int beacon_int;
+       int dtim_period;
+       int mtu;
+       int frame_dump; /* dump RX/TX frame headers, PRISM2_DUMP_ flags */
+       int fw_tx_rate_control;
+       u16 tx_rate_control;
+       u16 basic_rates;
+       int hw_resetting;
+       int hw_ready;
+       int hw_reset_tries; /* how many times reset has been tried */
+       int hw_downloading;
+       int shutdown;
+       int pri_only;
+       int no_pri; /* no PRI f/w present */
+       int sram_type; /* 8 = x8 SRAM, 16 = x16 SRAM, -1 = unknown */
+
+       enum {
+               PRISM2_TXPOWER_AUTO = 0, PRISM2_TXPOWER_OFF,
+               PRISM2_TXPOWER_FIXED, PRISM2_TXPOWER_UNKNOWN
+       } txpower_type;
+       int txpower; /* if txpower_type == PRISM2_TXPOWER_FIXED */
+
+       /* command queue for hfa384x_cmd(); protected with cmdlock */
+       struct list_head cmd_queue;
+       /* max_len for cmd_queue; in addition, cmd_callback can use two
+        * additional entries to prevent sleeping commands from stopping
+        * transmits */
+#define HOSTAP_CMD_QUEUE_MAX_LEN 16
+       int cmd_queue_len; /* number of entries in cmd_queue */
+
+       /* if card timeout is detected in interrupt context, reset_queue is
+        * used to schedule card reseting to be done in user context */
+       struct work_struct reset_queue;
+
+       /* For scheduling a change of the promiscuous mode RID */
+       int is_promisc;
+       struct work_struct set_multicast_list_queue;
+
+       struct work_struct set_tim_queue;
+       struct list_head set_tim_list;
+       spinlock_t set_tim_lock;
+
+       int wds_max_connections;
+       int wds_connections;
+#define HOSTAP_WDS_BROADCAST_RA BIT(0)
+#define HOSTAP_WDS_AP_CLIENT BIT(1)
+#define HOSTAP_WDS_STANDARD_FRAME BIT(2)
+       u32 wds_type;
+       u16 tx_control; /* flags to be used in TX description */
+       int manual_retry_count; /* -1 = use f/w default; otherwise retry count
+                                * to be used with all frames */
+
+       struct iw_statistics wstats;
+       unsigned long scan_timestamp; /* Time started to scan */
+       enum {
+               PRISM2_MONITOR_80211 = 0, PRISM2_MONITOR_PRISM = 1,
+               PRISM2_MONITOR_CAPHDR = 2
+       } monitor_type;
+       int (*saved_eth_header_parse)(struct sk_buff *skb,
+                                     unsigned char *haddr);
+       int monitor_allow_fcserr;
+
+       int hostapd; /* whether user space daemon, hostapd, is used for AP
+                     * management */
+       int hostapd_sta; /* whether hostapd is used with an extra STA interface
+                         */
+       struct net_device *apdev;
+       struct net_device_stats apdevstats;
+
+       char assoc_ap_addr[ETH_ALEN];
+       struct net_device *stadev;
+       struct net_device_stats stadevstats;
+
+#define WEP_KEYS 4
+#define WEP_KEY_LEN 13
+       struct ieee80211_crypt_data *crypt[WEP_KEYS];
+       int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
+       struct timer_list crypt_deinit_timer;
+       struct list_head crypt_deinit_list;
+
+       int open_wep; /* allow unencrypted frames */
+       int host_encrypt;
+       int host_decrypt;
+       int privacy_invoked; /* force privacy invoked flag even if no keys are
+                             * configured */
+       int fw_encrypt_ok; /* whether firmware-based WEP encrypt is working
+                           * in Host AP mode (STA f/w 1.4.9 or newer) */
+       int bcrx_sta_key; /* use individual keys to override default keys even
+                          * with RX of broad/multicast frames */
+
+       struct prism2_frag_entry frag_cache[PRISM2_FRAG_CACHE_LEN];
+       unsigned int frag_next_idx;
+
+       int ieee_802_1x; /* is IEEE 802.1X used */
+
+       int antsel_tx, antsel_rx;
+       int rts_threshold; /* dot11RTSThreshold */
+       int fragm_threshold; /* dot11FragmentationThreshold */
+       int auth_algs; /* PRISM2_AUTH_ flags */
+
+       int enh_sec; /* cnfEnhSecurity options (broadcast SSID hide/ignore) */
+       int tallies32; /* 32-bit tallies in use */
+
+       struct prism2_helper_functions *func;
+
+       u8 *pda;
+       int fw_ap;
+#define PRISM2_FW_VER(major, minor, variant) \
+(((major) << 16) | ((minor) << 8) | variant)
+       u32 sta_fw_ver;
+
+       /* Tasklets for handling hardware IRQ related operations outside hw IRQ
+        * handler */
+       struct tasklet_struct bap_tasklet;
+
+       struct tasklet_struct info_tasklet;
+       struct sk_buff_head info_list; /* info frames as skb's for
+                                       * info_tasklet */
+
+       struct hostap_tx_callback_info *tx_callback; /* registered TX callbacks
+                                                     */
+
+       struct tasklet_struct rx_tasklet;
+       struct sk_buff_head rx_list;
+
+       struct tasklet_struct sta_tx_exc_tasklet;
+       struct sk_buff_head sta_tx_exc_list;
+
+       int host_roaming;
+       unsigned long last_join_time; /* time of last JoinRequest */
+       struct hfa384x_hostscan_result *last_scan_results;
+       int last_scan_results_count;
+       enum { PRISM2_SCAN, PRISM2_HOSTSCAN } last_scan_type;
+       struct work_struct info_queue;
+       long pending_info; /* bit field of pending info_queue items */
+#define PRISM2_INFO_PENDING_LINKSTATUS 0
+#define PRISM2_INFO_PENDING_SCANRESULTS 1
+       int prev_link_status; /* previous received LinkStatus info */
+       int prev_linkstatus_connected;
+       u8 preferred_ap[6]; /* use this AP if possible */
+
+#ifdef PRISM2_CALLBACK
+       void *callback_data; /* Can be used in callbacks; e.g., allocate
+                             * on enable event and free on disable event.
+                             * Host AP driver code does not touch this. */
+#endif /* PRISM2_CALLBACK */
+
+       wait_queue_head_t hostscan_wq;
+
+       /* Passive scan in Host AP mode */
+       struct timer_list passive_scan_timer;
+       int passive_scan_interval; /* in seconds, 0 = disabled */
+       int passive_scan_channel;
+       enum { PASSIVE_SCAN_WAIT, PASSIVE_SCAN_LISTEN } passive_scan_state;
+
+       struct timer_list tick_timer;
+       unsigned long last_tick_timer;
+       unsigned int sw_tick_stuck;
+
+       /* commsQuality / dBmCommsQuality data from periodic polling; only
+        * valid for Managed and Ad-hoc modes */
+       unsigned long last_comms_qual_update;
+       int comms_qual; /* in some odd unit.. */
+       int avg_signal; /* in dB (note: negative) */
+       int avg_noise; /* in dB (note: negative) */
+       struct work_struct comms_qual_update;
+
+       /* RSSI to dBm adjustment (for RX descriptor fields) */
+       int rssi_to_dBm; /* substract from RSSI to get approximate dBm value */
+
+       /* BSS list / protected by local->lock */
+       struct list_head bss_list;
+       int num_bss_info;
+       int wpa; /* WPA support enabled */
+       int tkip_countermeasures;
+       int drop_unencrypted;
+       /* Generic IEEE 802.11 info element to be added to
+        * ProbeResp/Beacon/(Re)AssocReq */
+       u8 *generic_elem;
+       size_t generic_elem_len;
+
+#ifdef PRISM2_DOWNLOAD_SUPPORT
+       /* Persistent volatile download data */
+       struct prism2_download_data *dl_pri;
+       struct prism2_download_data *dl_sec;
+#endif /* PRISM2_DOWNLOAD_SUPPORT */
+
+#ifdef PRISM2_IO_DEBUG
+#define PRISM2_IO_DEBUG_SIZE 10000
+       u32 io_debug[PRISM2_IO_DEBUG_SIZE];
+       int io_debug_head;
+       int io_debug_enabled;
+#endif /* PRISM2_IO_DEBUG */
+
+       /* Pointer to hardware model specific (cs,pci,plx) private data. */
+       void *hw_priv;
+};
+
+
+/* Per interface private Host AP data
+ * Allocated for each net device that Host AP uses (wlan#, wlan#ap, wlan#sta,
+ * WDS) and netdev_priv(dev) points to this structure. */
+struct hostap_interface {
+       struct list_head list; /* list entry in Host AP interface list */
+       struct net_device *dev; /* pointer to this device */
+       struct local_info *local; /* pointer to shared private data */
+       struct net_device_stats stats;
+       struct iw_spy_data spy_data; /* iwspy support */
+       struct iw_public_data wireless_data;
+
+       enum {
+               HOSTAP_INTERFACE_MASTER,
+               HOSTAP_INTERFACE_MAIN,
+               HOSTAP_INTERFACE_AP,
+               HOSTAP_INTERFACE_STA,
+               HOSTAP_INTERFACE_WDS,
+       } type;
+
+       union {
+               struct hostap_interface_wds {
+                       u8 remote_addr[ETH_ALEN];
+               } wds;
+       } u;
+};
+
+
+#define HOSTAP_SKB_TX_DATA_MAGIC 0xf08a36a2
+
+/*
+ * TX meta data - stored in skb->cb buffer, so this must not be increased over
+ * the 40-byte limit
+ */
+struct hostap_skb_tx_data {
+       u32 magic; /* HOSTAP_SKB_TX_DATA_MAGIC */
+       u8 rate; /* transmit rate */
+#define HOSTAP_TX_FLAGS_WDS BIT(0)
+#define HOSTAP_TX_FLAGS_BUFFERED_FRAME BIT(1)
+#define HOSTAP_TX_FLAGS_ADD_MOREDATA BIT(2)
+       u8 flags; /* HOSTAP_TX_FLAGS_* */
+       u16 tx_cb_idx;
+       struct hostap_interface *iface;
+       unsigned long jiffies; /* queueing timestamp */
+       unsigned short ethertype;
+};
+
+
+#ifndef PRISM2_NO_DEBUG
+
+#define DEBUG_FID BIT(0)
+#define DEBUG_PS BIT(1)
+#define DEBUG_FLOW BIT(2)
+#define DEBUG_AP BIT(3)
+#define DEBUG_HW BIT(4)
+#define DEBUG_EXTRA BIT(5)
+#define DEBUG_EXTRA2 BIT(6)
+#define DEBUG_PS2 BIT(7)
+#define DEBUG_MASK (DEBUG_PS | DEBUG_AP | DEBUG_HW | DEBUG_EXTRA)
+#define PDEBUG(n, args...) \
+do { if ((n) & DEBUG_MASK) printk(KERN_DEBUG args); } while (0)
+#define PDEBUG2(n, args...) \
+do { if ((n) & DEBUG_MASK) printk(args); } while (0)
+
+#else /* PRISM2_NO_DEBUG */
+
+#define PDEBUG(n, args...)
+#define PDEBUG2(n, args...)
+
+#endif /* PRISM2_NO_DEBUG */
+
+enum { BAP0 = 0, BAP1 = 1 };
+
+#define PRISM2_IO_DEBUG_CMD_INB 0
+#define PRISM2_IO_DEBUG_CMD_INW 1
+#define PRISM2_IO_DEBUG_CMD_INSW 2
+#define PRISM2_IO_DEBUG_CMD_OUTB 3
+#define PRISM2_IO_DEBUG_CMD_OUTW 4
+#define PRISM2_IO_DEBUG_CMD_OUTSW 5
+#define PRISM2_IO_DEBUG_CMD_ERROR 6
+#define PRISM2_IO_DEBUG_CMD_INTERRUPT 7
+
+#ifdef PRISM2_IO_DEBUG
+
+#define PRISM2_IO_DEBUG_ENTRY(cmd, reg, value) \
+(((cmd) << 24) | ((reg) << 16) | value)
+
+static inline void prism2_io_debug_add(struct net_device *dev, int cmd,
+                                      int reg, int value)
+{
+       struct hostap_interface *iface = netdev_priv(dev);
+       local_info_t *local = iface->local;
+
+       if (!local->io_debug_enabled)
+               return;
+
+       local->io_debug[local->io_debug_head] = jiffies & 0xffffffff;
+       if (++local->io_debug_head >= PRISM2_IO_DEBUG_SIZE)
+               local->io_debug_head = 0;
+       local->io_debug[local->io_debug_head] =
+               PRISM2_IO_DEBUG_ENTRY(cmd, reg, value);
+       if (++local->io_debug_head >= PRISM2_IO_DEBUG_SIZE)
+               local->io_debug_head = 0;
+}
+
+
+static inline void prism2_io_debug_error(struct net_device *dev, int err)
+{
+       struct hostap_interface *iface = netdev_priv(dev);
+       local_info_t *local = iface->local;
+       unsigned long flags;
+
+       if (!local->io_debug_enabled)
+               return;
+
+       spin_lock_irqsave(&local->lock, flags);
+       prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_ERROR, 0, err);
+       if (local->io_debug_enabled == 1) {
+               local->io_debug_enabled = 0;
+               printk(KERN_DEBUG "%s: I/O debug stopped\n", dev->name);
+       }
+       spin_unlock_irqrestore(&local->lock, flags);
+}
+
+#else /* PRISM2_IO_DEBUG */
+
+static inline void prism2_io_debug_add(struct net_device *dev, int cmd,
+                                      int reg, int value)
+{
+}
+
+static inline void prism2_io_debug_error(struct net_device *dev, int err)
+{
+}
+
+#endif /* PRISM2_IO_DEBUG */
+
+
+#ifdef PRISM2_CALLBACK
+enum {
+       /* Called when card is enabled */
+       PRISM2_CALLBACK_ENABLE,
+
+       /* Called when card is disabled */
+       PRISM2_CALLBACK_DISABLE,
+
+       /* Called when RX/TX starts/ends */
+       PRISM2_CALLBACK_RX_START, PRISM2_CALLBACK_RX_END,
+       PRISM2_CALLBACK_TX_START, PRISM2_CALLBACK_TX_END
+};
+void prism2_callback(local_info_t *local, int event);
+#else /* PRISM2_CALLBACK */
+#define prism2_callback(d, e) do { } while (0)
+#endif /* PRISM2_CALLBACK */
+
+#endif /* __KERNEL__ */
+
+#endif /* HOSTAP_WLAN_H */
diff --git a/drivers/net/wireless/ieee802_11.h b/drivers/net/wireless/ieee802_11.h
deleted file mode 100644 (file)
index 53dd524..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#ifndef _IEEE802_11_H
-#define _IEEE802_11_H
-
-#define IEEE802_11_DATA_LEN            2304
-/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
-   6.2.1.1.2.
-
-   The figure in section 7.1.2 suggests a body size of up to 2312
-   bytes is allowed, which is a bit confusing, I suspect this
-   represents the 2304 bytes of real data, plus a possible 8 bytes of
-   WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
-
-
-#define IEEE802_11_HLEN                        30
-#define IEEE802_11_FRAME_LEN           (IEEE802_11_DATA_LEN + IEEE802_11_HLEN)
-
-struct ieee802_11_hdr {
-       u16 frame_ctl;
-       u16 duration_id;
-       u8 addr1[ETH_ALEN];
-       u8 addr2[ETH_ALEN];
-       u8 addr3[ETH_ALEN];
-       u16 seq_ctl;
-       u8 addr4[ETH_ALEN];
-} __attribute__ ((packed));
-
-/* Frame control field constants */
-#define IEEE802_11_FCTL_VERS           0x0002
-#define IEEE802_11_FCTL_FTYPE          0x000c
-#define IEEE802_11_FCTL_STYPE          0x00f0
-#define IEEE802_11_FCTL_TODS           0x0100
-#define IEEE802_11_FCTL_FROMDS         0x0200
-#define IEEE802_11_FCTL_MOREFRAGS      0x0400
-#define IEEE802_11_FCTL_RETRY          0x0800
-#define IEEE802_11_FCTL_PM             0x1000
-#define IEEE802_11_FCTL_MOREDATA       0x2000
-#define IEEE802_11_FCTL_WEP            0x4000
-#define IEEE802_11_FCTL_ORDER          0x8000
-
-#define IEEE802_11_FTYPE_MGMT          0x0000
-#define IEEE802_11_FTYPE_CTL           0x0004
-#define IEEE802_11_FTYPE_DATA          0x0008
-
-/* management */
-#define IEEE802_11_STYPE_ASSOC_REQ     0x0000
-#define IEEE802_11_STYPE_ASSOC_RESP    0x0010
-#define IEEE802_11_STYPE_REASSOC_REQ   0x0020
-#define IEEE802_11_STYPE_REASSOC_RESP  0x0030
-#define IEEE802_11_STYPE_PROBE_REQ     0x0040
-#define IEEE802_11_STYPE_PROBE_RESP    0x0050
-#define IEEE802_11_STYPE_BEACON                0x0080
-#define IEEE802_11_STYPE_ATIM          0x0090
-#define IEEE802_11_STYPE_DISASSOC      0x00A0
-#define IEEE802_11_STYPE_AUTH          0x00B0
-#define IEEE802_11_STYPE_DEAUTH                0x00C0
-
-/* control */
-#define IEEE802_11_STYPE_PSPOLL                0x00A0
-#define IEEE802_11_STYPE_RTS           0x00B0
-#define IEEE802_11_STYPE_CTS           0x00C0
-#define IEEE802_11_STYPE_ACK           0x00D0
-#define IEEE802_11_STYPE_CFEND         0x00E0
-#define IEEE802_11_STYPE_CFENDACK      0x00F0
-
-/* data */
-#define IEEE802_11_STYPE_DATA          0x0000
-#define IEEE802_11_STYPE_DATA_CFACK    0x0010
-#define IEEE802_11_STYPE_DATA_CFPOLL   0x0020
-#define IEEE802_11_STYPE_DATA_CFACKPOLL        0x0030
-#define IEEE802_11_STYPE_NULLFUNC      0x0040
-#define IEEE802_11_STYPE_CFACK         0x0050
-#define IEEE802_11_STYPE_CFPOLL                0x0060
-#define IEEE802_11_STYPE_CFACKPOLL     0x0070
-
-#define IEEE802_11_SCTL_FRAG           0x000F
-#define IEEE802_11_SCTL_SEQ            0xFFF0
-
-#endif /* _IEEE802_11_H */
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
new file mode 100644 (file)
index 0000000..2414e64
--- /dev/null
@@ -0,0 +1,8680 @@
+/******************************************************************************
+
+  Copyright(c) 2003 - 2005 Intel Corporation. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms of version 2 of the GNU General Public License as
+  published by the Free Software Foundation.
+
+  This program is distributed in the hope that it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc., 59
+  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+  The full GNU General Public License is included in this distribution in the
+  file called LICENSE.
+
+  Contact Information:
+  James P. Ketrenos <ipw2100-admin@linux.intel.com>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+  Portions of this file are based on the sample_* files provided by Wireless
+  Extensions 0.26 package and copyright (c) 1997-2003 Jean Tourrilhes
+  <jt@hpl.hp.com>
+
+  Portions of this file are based on the Host AP project,
+  Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
+    <jkmaline@cc.hut.fi>
+  Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
+
+  Portions of ipw2100_mod_firmware_load, ipw2100_do_mod_firmware_load, and
+  ipw2100_fw_load are loosely based on drivers/sound/sound_firmware.c
+  available in the 2.4.25 kernel sources, and are copyright (c) Alan Cox
+
+******************************************************************************/
+/*
+
+ Initial driver on which this is based was developed by Janusz Gorycki,
+ Maciej Urbaniak, and Maciej Sosnowski.
+
+ Promiscuous mode support added by Jacek Wysoczynski and Maciej Urbaniak.
+
+Theory of Operation
+
+Tx - Commands and Data
+
+Firmware and host share a circular queue of Transmit Buffer Descriptors (TBDs)
+Each TBD contains a pointer to the physical (dma_addr_t) address of data being
+sent to the firmware as well as the length of the data.
+
+The host writes to the TBD queue at the WRITE index.  The WRITE index points
+to the _next_ packet to be written and is advanced when after the TBD has been
+filled.
+
+The firmware pulls from the TBD queue at the READ index.  The READ index points
+to the currently being read entry, and is advanced once the firmware is
+done with a packet.
+
+When data is sent to the firmware, the first TBD is used to indicate to the
+firmware if a Command or Data is being sent.  If it is Command, all of the
+command information is contained within the physical address referred to by the
+TBD.  If it is Data, the first TBD indicates the type of data packet, number
+of fragments, etc.  The next TBD then referrs to the actual packet location.
+
+The Tx flow cycle is as follows:
+
+1) ipw2100_tx() is called by kernel with SKB to transmit
+2) Packet is move from the tx_free_list and appended to the transmit pending
+   list (tx_pend_list)
+3) work is scheduled to move pending packets into the shared circular queue.
+4) when placing packet in the circular queue, the incoming SKB is DMA mapped
+   to a physical address.  That address is entered into a TBD.  Two TBDs are
+   filled out.  The first indicating a data packet, the second referring to the
+   actual payload data.
+5) the packet is removed from tx_pend_list and placed on the end of the
+   firmware pending list (fw_pend_list)
+6) firmware is notified that the WRITE index has
+7) Once the firmware has processed the TBD, INTA is triggered.
+8) For each Tx interrupt received from the firmware, the READ index is checked
+   to see which TBDs are done being processed.
+9) For each TBD that has been processed, the ISR pulls the oldest packet
+   from the fw_pend_list.
+10)The packet structure contained in the fw_pend_list is then used
+   to unmap the DMA address and to free the SKB originally passed to the driver
+   from the kernel.
+11)The packet structure is placed onto the tx_free_list
+
+The above steps are the same for commands, only the msg_free_list/msg_pend_list
+are used instead of tx_free_list/tx_pend_list
+
+...
+
+Critical Sections / Locking :
+
+There are two locks utilized.  The first is the low level lock (priv->low_lock)
+that protects the following:
+
+- Access to the Tx/Rx queue lists via priv->low_lock. The lists are as follows:
+
+  tx_free_list : Holds pre-allocated Tx buffers.
+    TAIL modified in __ipw2100_tx_process()
+    HEAD modified in ipw2100_tx()
+
+  tx_pend_list : Holds used Tx buffers waiting to go into the TBD ring
+    TAIL modified ipw2100_tx()
+    HEAD modified by ipw2100_tx_send_data()
+
+  msg_free_list : Holds pre-allocated Msg (Command) buffers
+    TAIL modified in __ipw2100_tx_process()
+    HEAD modified in ipw2100_hw_send_command()
+
+  msg_pend_list : Holds used Msg buffers waiting to go into the TBD ring
+    TAIL modified in ipw2100_hw_send_command()
+    HEAD modified in ipw2100_tx_send_commands()
+
+  The flow of data on the TX side is as follows:
+
+  MSG_FREE_LIST + COMMAND => MSG_PEND_LIST => TBD => MSG_FREE_LIST
+  TX_FREE_LIST + DATA => TX_PEND_LIST => TBD => TX_FREE_LIST
+
+  The methods that work on the TBD ring are protected via priv->low_lock.
+
+- The internal data state of the device itself
+- Access to the firmware read/write indexes for the BD queues
+  and associated logic
+
+All external entry functions are locked with the priv->action_lock to ensure
+that only one external action is invoked at a time.
+
+
+*/
+
+#include <linux/compiler.h>
+#include <linux/config.h>
+#include <linux/errno.h>
+#include <linux/if_arp.h>
+#include <linux/in6.h>
+#include <linux/in.h>
+#include <linux/ip.h>
+#include <linux/kernel.h>
+#include <linux/kmod.h>
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/ethtool.h>
+#include <linux/pci.h>
+#include <linux/dma-mapping.h>
+#include <linux/proc_fs.h>
+#include <linux/skbuff.h>
+#include <asm/uaccess.h>
+#include <asm/io.h>
+#define __KERNEL_SYSCALLS__
+#include <linux/fs.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/unistd.h>
+#include <linux/stringify.h>
+#include <linux/tcp.h>
+#include <linux/types.h>
+#include <linux/version.h>
+#include <linux/time.h>
+#include <linux/firmware.h>
+#include <linux/acpi.h>
+#include <linux/ctype.h>
+
+#include "ipw2100.h"
+
+#define IPW2100_VERSION "1.1.0"
+
+#define DRV_NAME       "ipw2100"
+#define DRV_VERSION    IPW2100_VERSION
+#define DRV_DESCRIPTION        "Intel(R) PRO/Wireless 2100 Network Driver"
+#define DRV_COPYRIGHT  "Copyright(c) 2003-2004 Intel Corporation"
+
+
+/* Debugging stuff */
+#ifdef CONFIG_IPW_DEBUG
+#define CONFIG_IPW2100_RX_DEBUG   /* Reception debugging */
+#endif
+
+MODULE_DESCRIPTION(DRV_DESCRIPTION);
+MODULE_VERSION(DRV_VERSION);
+MODULE_AUTHOR(DRV_COPYRIGHT);
+MODULE_LICENSE("GPL");
+
+static int debug = 0;
+static int mode = 0;
+static int channel = 0;
+static int associate = 1;
+static int disable = 0;
+#ifdef CONFIG_PM
+static struct ipw2100_fw ipw2100_firmware;
+#endif
+
+#include <linux/moduleparam.h>
+module_param(debug, int, 0444);
+module_param(mode, int, 0444);
+module_param(channel, int, 0444);
+module_param(associate, int, 0444);
+module_param(disable, int, 0444);
+
+MODULE_PARM_DESC(debug, "debug level");
+MODULE_PARM_DESC(mode, "network mode (0=BSS,1=IBSS,2=Monitor)");
+MODULE_PARM_DESC(channel, "channel");
+MODULE_PARM_DESC(associate, "auto associate when scanning (default on)");
+MODULE_PARM_DESC(disable, "manually disable the radio (default 0 [radio on])");
+
+static u32 ipw2100_debug_level = IPW_DL_NONE;
+
+#ifdef CONFIG_IPW_DEBUG
+#define IPW_DEBUG(level, message...) \
+do { \
+       if (ipw2100_debug_level & (level)) { \
+               printk(KERN_DEBUG "ipw2100: %c %s ", \
+                       in_interrupt() ? 'I' : 'U',  __FUNCTION__); \
+               printk(message); \
+       } \
+} while (0)
+#else
+#define IPW_DEBUG(level, message...) do {} while (0)
+#endif /* CONFIG_IPW_DEBUG */
+
+#ifdef CONFIG_IPW_DEBUG
+static const char *command_types[] = {
+       "undefined",
+       "unused", /* HOST_ATTENTION */
+       "HOST_COMPLETE",
+       "unused", /* SLEEP */
+       "unused", /* HOST_POWER_DOWN */
+       "unused",
+       "SYSTEM_CONFIG",
+       "unused", /* SET_IMR */
+       "SSID",
+       "MANDATORY_BSSID",
+       "AUTHENTICATION_TYPE",
+       "ADAPTER_ADDRESS",
+       "PORT_TYPE",
+       "INTERNATIONAL_MODE",
+       "CHANNEL",
+       "RTS_THRESHOLD",
+       "FRAG_THRESHOLD",
+       "POWER_MODE",
+       "TX_RATES",
+       "BASIC_TX_RATES",
+       "WEP_KEY_INFO",
+       "unused",
+       "unused",
+       "unused",
+       "unused",
+       "WEP_KEY_INDEX",
+       "WEP_FLAGS",
+       "ADD_MULTICAST",
+       "CLEAR_ALL_MULTICAST",
+       "BEACON_INTERVAL",
+       "ATIM_WINDOW",
+       "CLEAR_STATISTICS",
+       "undefined",
+       "undefined",
+       "undefined",
+       "undefined",
+       "TX_POWER_INDEX",
+       "undefined",
+       "undefined",
+       "undefined",
+       "undefined",
+       "undefined",
+       "undefined",
+       "BROADCAST_SCAN",
+       "CARD_DISABLE",
+       "PREFERRED_BSSID",
+       "SET_SCAN_OPTIONS",
+       "SCAN_DWELL_TIME",
+       "SWEEP_TABLE",
+       "AP_OR_STATION_TABLE",
+       "GROUP_ORDINALS",
+       "SHORT_RETRY_LIMIT",
+       "LONG_RETRY_LIMIT",
+       "unused", /* SAVE_CALIBRATION */
+       "unused", /* RESTORE_CALIBRATION */
+       "undefined",
+       "undefined",
+       "undefined",
+       "HOST_PRE_POWER_DOWN",
+       "unused", /* HOST_INTERRUPT_COALESCING */
+       "undefined",
+       "CARD_DISABLE_PHY_OFF",
+       "MSDU_TX_RATES"
+       "undefined",
+       "undefined",
+       "SET_STATION_STAT_BITS",
+       "CLEAR_STATIONS_STAT_BITS",
+       "LEAP_ROGUE_MODE",
+       "SET_SECURITY_INFORMATION",
+       "DISASSOCIATION_BSSID",
+       "SET_WPA_ASS_IE"
+};
+#endif
+
+
+/* Pre-decl until we get the code solid and then we can clean it up */
+static void ipw2100_tx_send_commands(struct ipw2100_priv *priv);
+static void ipw2100_tx_send_data(struct ipw2100_priv *priv);
+static int ipw2100_adapter_setup(struct ipw2100_priv *priv);
+
+static void ipw2100_queues_initialize(struct ipw2100_priv *priv);
+static void ipw2100_queues_free(struct ipw2100_priv *priv);
+static int ipw2100_queues_allocate(struct ipw2100_priv *priv);
+
+static int ipw2100_fw_download(struct ipw2100_priv *priv,
+                              struct ipw2100_fw *fw);
+static int ipw2100_get_firmware(struct ipw2100_priv *priv,
+                               struct ipw2100_fw *fw);
+static int ipw2100_get_fwversion(struct ipw2100_priv *priv, char *buf,
+                                size_t max);
+static int ipw2100_get_ucodeversion(struct ipw2100_priv *priv, char *buf,
+                                   size_t max);
+static void ipw2100_release_firmware(struct ipw2100_priv *priv,
+                                    struct ipw2100_fw *fw);
+static int ipw2100_ucode_download(struct ipw2100_priv *priv,
+                                 struct ipw2100_fw *fw);
+static void ipw2100_wx_event_work(struct ipw2100_priv *priv);
+static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev);
+static struct iw_handler_def ipw2100_wx_handler_def;
+
+
+static inline void read_register(struct net_device *dev, u32 reg, u32 *val)
+{
+       *val = readl((void __iomem *)(dev->base_addr + reg));
+       IPW_DEBUG_IO("r: 0x%08X => 0x%08X\n", reg, *val);
+}
+
+static inline void write_register(struct net_device *dev, u32 reg, u32 val)
+{
+       writel(val, (void __iomem *)(dev->base_addr + reg));
+       IPW_DEBUG_IO("w: 0x%08X <= 0x%08X\n", reg, val);
+}
+
+static inline void read_register_word(struct net_device *dev, u32 reg, u16 *val)
+{
+       *val = readw((void __iomem *)(dev->base_addr + reg));
+       IPW_DEBUG_IO("r: 0x%08X => %04X\n", reg, *val);
+}
+
+static inline void read_register_byte(struct net_device *dev, u32 reg, u8 *val)
+{
+       *val = readb((void __iomem *)(dev->base_addr + reg));
+       IPW_DEBUG_IO("r: 0x%08X => %02X\n", reg, *val);
+}
+
+static inline void write_register_word(struct net_device *dev, u32 reg, u16 val)
+{
+       writew(val, (void __iomem *)(dev->base_addr + reg));
+       IPW_DEBUG_IO("w: 0x%08X <= %04X\n", reg, val);
+}
+
+
+static inline void write_register_byte(struct net_device *dev, u32 reg, u8 val)
+{
+       writeb(val, (void __iomem *)(dev->base_addr + reg));
+       IPW_DEBUG_IO("w: 0x%08X =< %02X\n", reg, val);
+}
+
+static inline void read_nic_dword(struct net_device *dev, u32 addr, u32 *val)
+{
+       write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS,
+                      addr & IPW_REG_INDIRECT_ADDR_MASK);
+       read_register(dev, IPW_REG_INDIRECT_ACCESS_DATA, val);
+}
+
+static inline void write_nic_dword(struct net_device *dev, u32 addr, u32 val)
+{
+       write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS,
+                      addr & IPW_REG_INDIRECT_ADDR_MASK);
+       write_register(dev, IPW_REG_INDIRECT_ACCESS_DATA, val);
+}
+
+static inline void read_nic_word(struct net_device *dev, u32 addr, u16 *val)
+{
+       write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS,
+                      addr & IPW_REG_INDIRECT_ADDR_MASK);
+       read_register_word(dev, IPW_REG_INDIRECT_ACCESS_DATA, val);
+}
+
+static inline void write_nic_word(struct net_device *dev, u32 addr, u16 val)
+{
+       write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS,
+                      addr & IPW_REG_INDIRECT_ADDR_MASK);
+       write_register_word(dev, IPW_REG_INDIRECT_ACCESS_DATA, val);
+}
+
+static inline void read_nic_byte(struct net_device *dev, u32 addr, u8 *val)
+{
+       write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS,
+                      addr & IPW_REG_INDIRECT_ADDR_MASK);
+       read_register_byte(dev, IPW_REG_INDIRECT_ACCESS_DATA, val);
+}
+
+static inline void write_nic_byte(struct net_device *dev, u32 addr, u8 val)
+{
+       write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS,
+                      addr & IPW_REG_INDIRECT_ADDR_MASK);
+       write_register_byte(dev, IPW_REG_INDIRECT_ACCESS_DATA, val);
+}
+
+static inline void write_nic_auto_inc_address(struct net_device *dev, u32 addr)
+{
+       write_register(dev, IPW_REG_AUTOINCREMENT_ADDRESS,
+                      addr & IPW_REG_INDIRECT_ADDR_MASK);
+}
+
+static inline void write_nic_dword_auto_inc(struct net_device *dev, u32 val)
+{
+       write_register(dev, IPW_REG_AUTOINCREMENT_DATA, val);
+}
+
+static inline void write_nic_memory(struct net_device *dev, u32 addr, u32 len,
+                                   const u8 *buf)
+{
+       u32 aligned_addr;
+       u32 aligned_len;
+       u32 dif_len;
+       u32 i;
+
+       /* read first nibble byte by byte */
+       aligned_addr = addr & (~0x3);
+       dif_len = addr - aligned_addr;
+       if (dif_len) {
+               /* Start reading at aligned_addr + dif_len */
+               write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS,
+                              aligned_addr);
+               for (i = dif_len; i < 4; i++, buf++)
+                       write_register_byte(
+                               dev, IPW_REG_INDIRECT_ACCESS_DATA + i,
+                               *buf);
+
+               len -= dif_len;
+               aligned_addr += 4;
+       }
+
+       /* read DWs through autoincrement registers */
+       write_register(dev, IPW_REG_AUTOINCREMENT_ADDRESS,
+                      aligned_addr);
+       aligned_len = len & (~0x3);
+       for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4)
+               write_register(
+                       dev, IPW_REG_AUTOINCREMENT_DATA, *(u32 *)buf);
+
+       /* copy the last nibble */
+       dif_len = len - aligned_len;
+       write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS, aligned_addr);
+       for (i = 0; i < dif_len; i++, buf++)
+               write_register_byte(
+                       dev, IPW_REG_INDIRECT_ACCESS_DATA + i, *buf);
+}
+
+static inline void read_nic_memory(struct net_device *dev, u32 addr, u32 len,
+                                  u8 *buf)
+{
+       u32 aligned_addr;
+       u32 aligned_len;
+       u32 dif_len;
+       u32 i;
+
+       /* read first nibble byte by byte */
+       aligned_addr = addr & (~0x3);
+       dif_len = addr - aligned_addr;
+       if (dif_len) {
+               /* Start reading at aligned_addr + dif_len */
+               write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS,
+                              aligned_addr);
+               for (i = dif_len; i < 4; i++, buf++)
+                       read_register_byte(
+                               dev, IPW_REG_INDIRECT_ACCESS_DATA + i, buf);
+
+               len -= dif_len;
+               aligned_addr += 4;
+       }
+
+       /* read DWs through autoincrement registers */
+       write_register(dev, IPW_REG_AUTOINCREMENT_ADDRESS,
+                      aligned_addr);
+       aligned_len = len & (~0x3);
+       for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4)
+               read_register(dev, IPW_REG_AUTOINCREMENT_DATA,
+                             (u32 *)buf);
+
+       /* copy the last nibble */
+       dif_len = len - aligned_len;
+       write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS,
+                      aligned_addr);
+       for (i = 0; i < dif_len; i++, buf++)
+               read_register_byte(dev, IPW_REG_INDIRECT_ACCESS_DATA +
+                                  i, buf);
+}
+
+static inline int ipw2100_hw_is_adapter_in_system(struct net_device *dev)
+{
+       return (dev->base_addr &&
+               (readl((void __iomem *)(dev->base_addr + IPW_REG_DOA_DEBUG_AREA_START))
+                == IPW_DATA_DOA_DEBUG_VALUE));
+}
+
+static int ipw2100_get_ordinal(struct ipw2100_priv *priv, u32 ord,
+                              void *val, u32 *len)
+{
+       struct ipw2100_ordinals *ordinals = &priv->ordinals;
+       u32 addr;
+       u32 field_info;
+       u16 field_len;
+       u16 field_count;
+       u32 total_length;
+
+       if (ordinals->table1_addr == 0) {
+               printk(KERN_WARNING DRV_NAME ": attempt to use fw ordinals "
+                      "before they have been loaded.\n");
+               return -EINVAL;
+       }
+
+       if (IS_ORDINAL_TABLE_ONE(ordinals, ord)) {
+               if (*len < IPW_ORD_TAB_1_ENTRY_SIZE) {
+                       *len = IPW_ORD_TAB_1_ENTRY_SIZE;
+
+                       printk(KERN_WARNING DRV_NAME
+                              ": ordinal buffer length too small, need %zd\n",
+                              IPW_ORD_TAB_1_ENTRY_SIZE);
+
+                       return -EINVAL;
+               }
+
+               read_nic_dword(priv->net_dev, ordinals->table1_addr + (ord << 2),
+                              &addr);
+               read_nic_dword(priv->net_dev, addr, val);
+
+               *len = IPW_ORD_TAB_1_ENTRY_SIZE;
+
+               return 0;
+       }
+
+       if (IS_ORDINAL_TABLE_TWO(ordinals, ord)) {
+
+               ord -= IPW_START_ORD_TAB_2;
+
+               /* get the address of statistic */
+               read_nic_dword(priv->net_dev, ordinals->table2_addr + (ord << 3),
+                              &addr);
+
+               /* get the second DW of statistics ;
+                * two 16-bit words - first is length, second is count */
+               read_nic_dword(priv->net_dev,
+                              ordinals->table2_addr + (ord << 3) + sizeof(u32),
+                              &field_info);
+
+               /* get each entry length */
+               field_len = *((u16 *)&field_info);
+
+               /* get number of entries */
+               field_count = *(((u16 *)&field_info) + 1);
+
+               /* abort if no enought memory */
+               total_length = field_len * field_count;
+               if (total_length > *len) {
+                       *len = total_length;
+                       return -EINVAL;
+               }
+
+               *len = total_length;
+               if (!total_length)
+                       return 0;
+
+               /* read the ordinal data from the SRAM */
+               read_nic_memory(priv->net_dev, addr, total_length, val);
+
+               return 0;
+       }
+
+       printk(KERN_WARNING DRV_NAME ": ordinal %d neither in table 1 nor "
+              "in table 2\n", ord);
+
+       return -EINVAL;
+}
+
+static int ipw2100_set_ordinal(struct ipw2100_priv *priv, u32 ord, u32 *val,
+                              u32 *len)
+{
+       struct ipw2100_ordinals *ordinals = &priv->ordinals;
+       u32 addr;
+
+       if (IS_ORDINAL_TABLE_ONE(ordinals, ord)) {
+               if (*len != IPW_ORD_TAB_1_ENTRY_SIZE) {
+                       *len = IPW_ORD_TAB_1_ENTRY_SIZE;
+                       IPW_DEBUG_INFO("wrong size\n");
+                       return -EINVAL;
+               }
+
+               read_nic_dword(priv->net_dev, ordinals->table1_addr + (ord << 2),
+                              &addr);
+
+               write_nic_dword(priv->net_dev, addr, *val);
+
+               *len = IPW_ORD_TAB_1_ENTRY_SIZE;
+
+               return 0;
+       }
+
+       IPW_DEBUG_INFO("wrong table\n");
+       if (IS_ORDINAL_TABLE_TWO(ordinals, ord))
+               return -EINVAL;
+
+       return -EINVAL;
+}
+
+static char *snprint_line(char *buf, size_t count,
+                         const u8 *data, u32 len, u32 ofs)
+{
+       int out, i, j, l;
+       char c;
+
+       out = snprintf(buf, count, "%08X", ofs);
+
+       for (l = 0, i = 0; i < 2; i++) {
+               out += snprintf(buf + out, count - out, " ");
+               for (j = 0; j < 8 && l < len; j++, l++)
+                       out += snprintf(buf + out, count - out, "%02X ",
+                                       data[(i * 8 + j)]);
+               for (; j < 8; j++)
+                       out += snprintf(buf + out, count - out, "   ");
+       }
+
+       out += snprintf(buf + out, count - out, " ");
+       for (l = 0, i = 0; i < 2; i++) {
+               out += snprintf(buf + out, count - out, " ");
+               for (j = 0; j < 8 && l < len; j++, l++) {
+                       c = data[(i * 8 + j)];
+                       if (!isascii(c) || !isprint(c))
+                               c = '.';
+
+                       out += snprintf(buf + out, count - out, "%c", c);
+               }
+
+               for (; j < 8; j++)
+                       out += snprintf(buf + out, count - out, " ");
+       }
+
+       return buf;
+}
+
+static void printk_buf(int level, const u8 *data, u32 len)
+{
+       char line[81];
+       u32 ofs = 0;
+       if (!(ipw2100_debug_level & level))
+               return;
+
+       while (len) {
+               printk(KERN_DEBUG "%s\n",
+                      snprint_line(line, sizeof(line), &data[ofs],
+                                   min(len, 16U), ofs));
+               ofs += 16;
+               len -= min(len, 16U);
+       }
+}
+
+
+
+#define MAX_RESET_BACKOFF 10
+
+static inline void schedule_reset(struct ipw2100_priv *priv)
+{
+       unsigned long now = get_seconds();
+
+       /* If we haven't received a reset request within the backoff period,
+        * then we can reset the backoff interval so this reset occurs
+        * immediately */
+       if (priv->reset_backoff &&
+           (now - priv->last_reset > priv->reset_backoff))
+               priv->reset_backoff = 0;
+
+       priv->last_reset = get_seconds();
+
+       if (!(priv->status & STATUS_RESET_PENDING)) {
+               IPW_DEBUG_INFO("%s: Scheduling firmware restart (%ds).\n",
+                              priv->net_dev->name, priv->reset_backoff);
+               netif_carrier_off(priv->net_dev);
+               netif_stop_queue(priv->net_dev);
+               priv->status |= STATUS_RESET_PENDING;
+               if (priv->reset_backoff)
+                       queue_delayed_work(priv->workqueue, &priv->reset_work,
+                                          priv->reset_backoff * HZ);
+               else
+                       queue_work(priv->workqueue, &priv->reset_work);
+
+               if (priv->reset_backoff < MAX_RESET_BACKOFF)
+                       priv->reset_backoff++;
+
+               wake_up_interruptible(&priv->wait_command_queue);
+       } else
+               IPW_DEBUG_INFO("%s: Firmware restart already in progress.\n",
+                              priv->net_dev->name);
+
+}
+
+#define HOST_COMPLETE_TIMEOUT (2 * HZ)
+static int ipw2100_hw_send_command(struct ipw2100_priv *priv,
+                                  struct host_command * cmd)
+{
+       struct list_head *element;
+       struct ipw2100_tx_packet *packet;
+       unsigned long flags;
+       int err = 0;
+
+       IPW_DEBUG_HC("Sending %s command (#%d), %d bytes\n",
+                    command_types[cmd->host_command], cmd->host_command,
+                    cmd->host_command_length);
+       printk_buf(IPW_DL_HC, (u8*)cmd->host_command_parameters,
+                  cmd->host_command_length);
+
+       spin_lock_irqsave(&priv->low_lock, flags);
+
+       if (priv->fatal_error) {
+               IPW_DEBUG_INFO("Attempt to send command while hardware in fatal error condition.\n");
+               err = -EIO;
+               goto fail_unlock;
+       }
+
+       if (!(priv->status & STATUS_RUNNING)) {
+               IPW_DEBUG_INFO("Attempt to send command while hardware is not running.\n");
+               err = -EIO;
+               goto fail_unlock;
+       }
+
+       if (priv->status & STATUS_CMD_ACTIVE) {
+               IPW_DEBUG_INFO("Attempt to send command while another command is pending.\n");
+               err = -EBUSY;
+               goto fail_unlock;
+       }
+
+       if (list_empty(&priv->msg_free_list)) {
+               IPW_DEBUG_INFO("no available msg buffers\n");
+               goto fail_unlock;
+       }
+
+       priv->status |= STATUS_CMD_ACTIVE;
+       priv->messages_sent++;
+
+       element = priv->msg_free_list.next;
+
+       packet = list_entry(element, struct ipw2100_tx_packet, list);
+       packet->jiffy_start = jiffies;
+
+       /* initialize the firmware command packet */
+       packet->info.c_struct.cmd->host_command_reg = cmd->host_command;
+       packet->info.c_struct.cmd->host_command_reg1 = cmd->host_command1;
+       packet->info.c_struct.cmd->host_command_len_reg = cmd->host_command_length;
+       packet->info.c_struct.cmd->sequence = cmd->host_command_sequence;
+
+       memcpy(packet->info.c_struct.cmd->host_command_params_reg,
+              cmd->host_command_parameters,
+              sizeof(packet->info.c_struct.cmd->host_command_params_reg));
+
+       list_del(element);
+       DEC_STAT(&priv->msg_free_stat);
+
+       list_add_tail(element, &priv->msg_pend_list);
+       INC_STAT(&priv->msg_pend_stat);
+
+       ipw2100_tx_send_commands(priv);
+       ipw2100_tx_send_data(priv);
+
+       spin_unlock_irqrestore(&priv->low_lock, flags);
+
+       /*
+        * We must wait for this command to complete before another
+        * command can be sent...  but if we wait more than 3 seconds
+        * then there is a problem.
+        */
+
+       err = wait_event_interruptible_timeout(
+               priv->wait_command_queue, !(priv->status & STATUS_CMD_ACTIVE),
+               HOST_COMPLETE_TIMEOUT);
+
+       if (err == 0) {
+               IPW_DEBUG_INFO("Command completion failed out after %dms.\n",
+                              HOST_COMPLETE_TIMEOUT / (HZ / 100));
+               priv->fatal_error = IPW2100_ERR_MSG_TIMEOUT;
+               priv->status &= ~STATUS_CMD_ACTIVE;
+               schedule_reset(priv);
+               return -EIO;
+       }
+
+       if (priv->fatal_error) {
+               printk(KERN_WARNING DRV_NAME ": %s: firmware fatal error\n",
+                      priv->net_dev->name);
+               return -EIO;
+       }
+
+       /* !!!!! HACK TEST !!!!!
+        * When lots of debug trace statements are enabled, the driver
+        * doesn't seem to have as many firmware restart cycles...
+        *
+        * As a test, we're sticking in a 1/100s delay here */
+       set_current_state(TASK_UNINTERRUPTIBLE);
+       schedule_timeout(HZ / 100);
+
+       return 0;
+
+ fail_unlock:
+       spin_unlock_irqrestore(&priv->low_lock, flags);
+
+       return err;
+}
+
+
+/*
+ * Verify the values and data access of the hardware
+ * No locks needed or used.  No functions called.
+ */
+static int ipw2100_verify(struct ipw2100_priv *priv)
+{
+       u32 data1, data2;
+       u32 address;
+
+       u32 val1 = 0x76543210;
+       u32 val2 = 0xFEDCBA98;
+
+       /* Domain 0 check - all values should be DOA_DEBUG */
+       for (address = IPW_REG_DOA_DEBUG_AREA_START;
+            address < IPW_REG_DOA_DEBUG_AREA_END;
+            address += sizeof(u32)) {
+               read_register(priv->net_dev, address, &data1);
+               if (data1 != IPW_DATA_DOA_DEBUG_VALUE)
+                       return -EIO;
+       }
+
+       /* Domain 1 check - use arbitrary read/write compare  */
+       for (address = 0; address < 5; address++) {
+               /* The memory area is not used now */
+               write_register(priv->net_dev, IPW_REG_DOMAIN_1_OFFSET + 0x32,
+                              val1);
+               write_register(priv->net_dev, IPW_REG_DOMAIN_1_OFFSET + 0x36,
+                              val2);
+               read_register(priv->net_dev, IPW_REG_DOMAIN_1_OFFSET + 0x32,
+                             &data1);
+               read_register(priv->net_dev, IPW_REG_DOMAIN_1_OFFSET + 0x36,
+                             &data2);
+               if (val1 == data1 && val2 == data2)
+                       return 0;
+       }
+
+       return -EIO;
+}
+
+/*
+ *
+ * Loop until the CARD_DISABLED bit is the same value as the
+ * supplied parameter
+ *
+ * TODO: See if it would be more efficient to do a wait/wake
+ *       cycle and have the completion event trigger the wakeup
+ *
+ */
+#define IPW_CARD_DISABLE_COMPLETE_WAIT             100 // 100 milli
+static int ipw2100_wait_for_card_state(struct ipw2100_priv *priv, int state)
+{
+       int i;
+       u32 card_state;
+       u32 len = sizeof(card_state);
+       int err;
+
+       for (i = 0; i <= IPW_CARD_DISABLE_COMPLETE_WAIT * 1000; i += 50) {
+               err = ipw2100_get_ordinal(priv, IPW_ORD_CARD_DISABLED,
+                                         &card_state, &len);
+               if (err) {
+                       IPW_DEBUG_INFO("Query of CARD_DISABLED ordinal "
+                                      "failed.\n");
+                       return 0;
+               }
+
+               /* We'll break out if either the HW state says it is
+                * in the state we want, or if HOST_COMPLETE command
+                * finishes */
+               if ((card_state == state) ||
+                   ((priv->status & STATUS_ENABLED) ?
+                    IPW_HW_STATE_ENABLED : IPW_HW_STATE_DISABLED) == state) {
+                       if (state == IPW_HW_STATE_ENABLED)
+                               priv->status |= STATUS_ENABLED;
+                       else
+                               priv->status &= ~STATUS_ENABLED;
+
+                       return 0;
+               }
+
+               udelay(50);
+       }
+
+       IPW_DEBUG_INFO("ipw2100_wait_for_card_state to %s state timed out\n",
+                      state ? "DISABLED" : "ENABLED");
+       return -EIO;
+}
+
+
+/*********************************************************************
+    Procedure   :   sw_reset_and_clock
+    Purpose     :   Asserts s/w reset, asserts clock initialization
+                    and waits for clock stabilization
+ ********************************************************************/
+static int sw_reset_and_clock(struct ipw2100_priv *priv)
+{
+       int i;
+       u32 r;
+
+       // assert s/w reset
+       write_register(priv->net_dev, IPW_REG_RESET_REG,
+                      IPW_AUX_HOST_RESET_REG_SW_RESET);
+
+       // wait for clock stabilization
+       for (i = 0; i < 1000; i++) {
+               udelay(IPW_WAIT_RESET_ARC_COMPLETE_DELAY);
+
+               // check clock ready bit
+               read_register(priv->net_dev, IPW_REG_RESET_REG, &r);
+               if (r & IPW_AUX_HOST_RESET_REG_PRINCETON_RESET)
+                       break;
+       }
+
+       if (i == 1000)
+               return -EIO;    // TODO: better error value
+
+       /* set "initialization complete" bit to move adapter to
+        * D0 state */
+       write_register(priv->net_dev, IPW_REG_GP_CNTRL,
+                      IPW_AUX_HOST_GP_CNTRL_BIT_INIT_DONE);
+
+       /* wait for clock stabilization */
+       for (i = 0; i < 10000; i++) {
+               udelay(IPW_WAIT_CLOCK_STABILIZATION_DELAY * 4);
+
+               /* check clock ready bit */
+               read_register(priv->net_dev, IPW_REG_GP_CNTRL, &r);
+               if (r & IPW_AUX_HOST_GP_CNTRL_BIT_CLOCK_READY)
+                       break;
+       }
+
+       if (i == 10000)
+               return -EIO;    /* TODO: better error value */
+
+       /* set D0 standby bit */
+       read_register(priv->net_dev, IPW_REG_GP_CNTRL, &r);
+       write_register(priv->net_dev, IPW_REG_GP_CNTRL,
+                      r | IPW_AUX_HOST_GP_CNTRL_BIT_HOST_ALLOWS_STANDBY);
+
+       return 0;
+}
+
+/*********************************************************************
+    Procedure   :   ipw2100_download_firmware
+    Purpose     :   Initiaze adapter after power on.
+                    The sequence is:
+                    1. assert s/w reset first!
+                    2. awake clocks & wait for clock stabilization
+                    3. hold ARC (don't ask me why...)
+                    4. load Dino ucode and reset/clock init again
+                    5. zero-out shared mem
+                    6. download f/w
+ *******************************************************************/
+static int ipw2100_download_firmware(struct ipw2100_priv *priv)
+{
+       u32 address;
+       int err;
+
+#ifndef CONFIG_PM
+       /* Fetch the firmware and microcode */
+       struct ipw2100_fw ipw2100_firmware;
+#endif
+
+       if (priv->fatal_error) {
+               IPW_DEBUG_ERROR("%s: ipw2100_download_firmware called after "
+                      "fatal error %d.  Interface must be brought down.\n",
+                      priv->net_dev->name, priv->fatal_error);
+               return -EINVAL;
+       }
+
+#ifdef CONFIG_PM
+       if (!ipw2100_firmware.version) {
+               err = ipw2100_get_firmware(priv, &ipw2100_firmware);
+               if (err) {
+                       IPW_DEBUG_ERROR("%s: ipw2100_get_firmware failed: %d\n",
+                              priv->net_dev->name, err);
+                       priv->fatal_error = IPW2100_ERR_FW_LOAD;
+                       goto fail;
+               }
+       }
+#else
+       err = ipw2100_get_firmware(priv, &ipw2100_firmware);
+       if (err) {
+               IPW_DEBUG_ERROR("%s: ipw2100_get_firmware failed: %d\n",
+                      priv->net_dev->name, err);
+               priv->fatal_error = IPW2100_ERR_FW_LOAD;
+               goto fail;
+       }
+#endif
+       priv->firmware_version = ipw2100_firmware.version;
+
+       /* s/w reset and clock stabilization */
+       err = sw_reset_and_clock(priv);
+       if (err) {
+               IPW_DEBUG_ERROR("%s: sw_reset_and_clock failed: %d\n",
+                      priv->net_dev->name, err);
+               goto fail;
+       }
+
+       err = ipw2100_verify(priv);
+       if (err) {
+               IPW_DEBUG_ERROR("%s: ipw2100_verify failed: %d\n",
+                      priv->net_dev->name, err);
+               goto fail;
+       }
+
+       /* Hold ARC */
+       write_nic_dword(priv->net_dev,
+                       IPW_INTERNAL_REGISTER_HALT_AND_RESET,
+                       0x80000000);
+
+       /* allow ARC to run */
+       write_register(priv->net_dev, IPW_REG_RESET_REG, 0);
+
+       /* load microcode */
+       err = ipw2100_ucode_download(priv, &ipw2100_firmware);
+       if (err) {
+               printk(KERN_ERR DRV_NAME ": %s: Error loading microcode: %d\n",
+                      priv->net_dev->name, err);
+               goto fail;
+       }
+
+       /* release ARC */
+       write_nic_dword(priv->net_dev,
+                       IPW_INTERNAL_REGISTER_HALT_AND_RESET,
+                       0x00000000);
+
+       /* s/w reset and clock stabilization (again!!!) */
+       err = sw_reset_and_clock(priv);
+       if (err) {
+               printk(KERN_ERR DRV_NAME ": %s: sw_reset_and_clock failed: %d\n",
+                      priv->net_dev->name, err);
+               goto fail;
+       }
+
+       /* load f/w */
+       err = ipw2100_fw_download(priv, &ipw2100_firmware);
+       if (err) {
+               IPW_DEBUG_ERROR("%s: Error loading firmware: %d\n",
+                      priv->net_dev->name, err);
+               goto fail;
+       }
+
+#ifndef CONFIG_PM
+       /*
+        * When the .resume method of the driver is called, the other
+        * part of the system, i.e. the ide driver could still stay in
+        * the suspend stage. This prevents us from loading the firmware
+        * from the disk.  --YZ
+        */
+
+       /* free any storage allocated for firmware image */
+       ipw2100_release_firmware(priv, &ipw2100_firmware);
+#endif
+
+       /* zero out Domain 1 area indirectly (Si requirement) */
+       for (address = IPW_HOST_FW_SHARED_AREA0;
+            address < IPW_HOST_FW_SHARED_AREA0_END; address += 4)
+               write_nic_dword(priv->net_dev, address, 0);
+       for (address = IPW_HOST_FW_SHARED_AREA1;
+            address < IPW_HOST_FW_SHARED_AREA1_END; address += 4)
+               write_nic_dword(priv->net_dev, address, 0);
+       for (address = IPW_HOST_FW_SHARED_AREA2;
+            address < IPW_HOST_FW_SHARED_AREA2_END; address += 4)
+               write_nic_dword(priv->net_dev, address, 0);
+       for (address = IPW_HOST_FW_SHARED_AREA3;
+            address < IPW_HOST_FW_SHARED_AREA3_END; address += 4)
+               write_nic_dword(priv->net_dev, address, 0);
+       for (address = IPW_HOST_FW_INTERRUPT_AREA;
+            address < IPW_HOST_FW_INTERRUPT_AREA_END; address += 4)
+               write_nic_dword(priv->net_dev, address, 0);
+
+       return 0;
+
+ fail:
+       ipw2100_release_firmware(priv, &ipw2100_firmware);
+       return err;
+}
+
+static inline void ipw2100_enable_interrupts(struct ipw2100_priv *priv)
+{
+       if (priv->status & STATUS_INT_ENABLED)
+               return;
+       priv->status |= STATUS_INT_ENABLED;
+       write_register(priv->net_dev, IPW_REG_INTA_MASK, IPW_INTERRUPT_MASK);
+}
+
+static inline void ipw2100_disable_interrupts(struct ipw2100_priv *priv)
+{
+       if (!(priv->status & STATUS_INT_ENABLED))
+               return;
+       priv->status &= ~STATUS_INT_ENABLED;
+       write_register(priv->net_dev, IPW_REG_INTA_MASK, 0x0);
+}
+
+
+static void ipw2100_initialize_ordinals(struct ipw2100_priv *priv)
+{
+       struct ipw2100_ordinals *ord = &priv->ordinals;
+
+       IPW_DEBUG_INFO("enter\n");
+
+       read_register(priv->net_dev, IPW_MEM_HOST_SHARED_ORDINALS_TABLE_1,
+                     &ord->table1_addr);
+
+       read_register(priv->net_dev, IPW_MEM_HOST_SHARED_ORDINALS_TABLE_2,
+                     &ord->table2_addr);
+
+       read_nic_dword(priv->net_dev, ord->table1_addr, &ord->table1_size);
+       read_nic_dword(priv->net_dev, ord->table2_addr, &ord->table2_size);
+
+       ord->table2_size &= 0x0000FFFF;
+
+       IPW_DEBUG_INFO("table 1 size: %d\n", ord->table1_size);
+       IPW_DEBUG_INFO("table 2 size: %d\n", ord->table2_size);
+       IPW_DEBUG_INFO("exit\n");
+}
+
+static inline void ipw2100_hw_set_gpio(struct ipw2100_priv *priv)
+{
+       u32 reg = 0;
+       /*
+        * Set GPIO 3 writable by FW; GPIO 1 writable
+        * by driver and enable clock
+        */
+       reg = (IPW_BIT_GPIO_GPIO3_MASK | IPW_BIT_GPIO_GPIO1_ENABLE |
+              IPW_BIT_GPIO_LED_OFF);
+       write_register(priv->net_dev, IPW_REG_GPIO, reg);
+}
+
+static inline int rf_kill_active(struct ipw2100_priv *priv)
+{
+#define MAX_RF_KILL_CHECKS 5
+#define RF_KILL_CHECK_DELAY 40
+
+       unsigned short value = 0;
+       u32 reg = 0;
+       int i;
+
+       if (!(priv->hw_features & HW_FEATURE_RFKILL)) {
+               priv->status &= ~STATUS_RF_KILL_HW;
+               return 0;
+       }
+
+       for (i = 0; i < MAX_RF_KILL_CHECKS; i++) {
+               udelay(RF_KILL_CHECK_DELAY);
+               read_register(priv->net_dev, IPW_REG_GPIO, &reg);
+               value = (value << 1) | ((reg & IPW_BIT_GPIO_RF_KILL) ? 0 : 1);
+       }
+
+       if (value == 0)
+               priv->status |= STATUS_RF_KILL_HW;
+       else
+               priv->status &= ~STATUS_RF_KILL_HW;
+
+       return (value == 0);
+}
+
+static int ipw2100_get_hw_features(struct ipw2100_priv *priv)
+{
+       u32 addr, len;
+       u32 val;
+
+       /*
+        * EEPROM_SRAM_DB_START_ADDRESS using ordinal in ordinal table 1
+        */
+       len = sizeof(addr);
+       if (ipw2100_get_ordinal(
+                   priv, IPW_ORD_EEPROM_SRAM_DB_BLOCK_START_ADDRESS,
+                   &addr, &len)) {
+               IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
+                      __LINE__);
+               return -EIO;
+       }
+
+       IPW_DEBUG_INFO("EEPROM address: %08X\n", addr);
+
+       /*
+        * EEPROM version is the byte at offset 0xfd in firmware
+        * We read 4 bytes, then shift out the byte we actually want */
+       read_nic_dword(priv->net_dev, addr + 0xFC, &val);
+       priv->eeprom_version = (val >> 24) & 0xFF;
+       IPW_DEBUG_INFO("EEPROM version: %d\n", priv->eeprom_version);
+
+        /*
+        *  HW RF Kill enable is bit 0 in byte at offset 0x21 in firmware
+        *
+        *  notice that the EEPROM bit is reverse polarity, i.e.
+        *     bit = 0  signifies HW RF kill switch is supported
+        *     bit = 1  signifies HW RF kill switch is NOT supported
+        */
+       read_nic_dword(priv->net_dev, addr + 0x20, &val);
+       if (!((val >> 24) & 0x01))
+               priv->hw_features |= HW_FEATURE_RFKILL;
+
+       IPW_DEBUG_INFO("HW RF Kill: %ssupported.\n",
+                          (priv->hw_features & HW_FEATURE_RFKILL) ?
+                          "" : "not ");
+
+       return 0;
+}
+
+/*
+ * Start firmware execution after power on and intialization
+ * The sequence is:
+ *  1. Release ARC
+ *  2. Wait for f/w initialization completes;
+ */
+static int ipw2100_start_adapter(struct ipw2100_priv *priv)
+{
+       int i;
+       u32 inta, inta_mask, gpio;
+
+       IPW_DEBUG_INFO("enter\n");
+
+       if (priv->status & STATUS_RUNNING)
+               return 0;
+
+       /*
+        * Initialize the hw - drive adapter to DO state by setting
+        * init_done bit. Wait for clk_ready bit and Download
+        * fw & dino ucode
+        */
+       if (ipw2100_download_firmware(priv)) {
+               printk(KERN_ERR DRV_NAME ": %s: Failed to power on the adapter.\n",
+                      priv->net_dev->name);
+               return -EIO;
+       }
+
+       /* Clear the Tx, Rx and Msg queues and the r/w indexes
+        * in the firmware RBD and TBD ring queue */
+       ipw2100_queues_initialize(priv);
+
+       ipw2100_hw_set_gpio(priv);
+
+       /* TODO -- Look at disabling interrupts here to make sure none
+        * get fired during FW initialization */
+
+       /* Release ARC - clear reset bit */
+       write_register(priv->net_dev, IPW_REG_RESET_REG, 0);
+
+       /* wait for f/w intialization complete */
+       IPW_DEBUG_FW("Waiting for f/w initialization to complete...\n");
+       i = 5000;
+       do {
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(40 * HZ / 1000);
+               /* Todo... wait for sync command ... */
+
+               read_register(priv->net_dev, IPW_REG_INTA, &inta);
+
+               /* check "init done" bit */
+               if (inta & IPW2100_INTA_FW_INIT_DONE) {
+                       /* reset "init done" bit */
+                       write_register(priv->net_dev, IPW_REG_INTA,
+                                      IPW2100_INTA_FW_INIT_DONE);
+                       break;
+               }
+
+               /* check error conditions : we check these after the firmware
+                * check so that if there is an error, the interrupt handler
+                * will see it and the adapter will be reset */
+               if (inta &
+                   (IPW2100_INTA_FATAL_ERROR | IPW2100_INTA_PARITY_ERROR)) {
+                       /* clear error conditions */
+                       write_register(priv->net_dev, IPW_REG_INTA,
+                                      IPW2100_INTA_FATAL_ERROR |
+                                      IPW2100_INTA_PARITY_ERROR);
+               }
+       } while (i--);
+
+       /* Clear out any pending INTAs since we aren't supposed to have
+        * interrupts enabled at this point... */
+       read_register(priv->net_dev, IPW_REG_INTA, &inta);
+       read_register(priv->net_dev, IPW_REG_INTA_MASK, &inta_mask);
+       inta &= IPW_INTERRUPT_MASK;
+       /* Clear out any pending interrupts */
+       if (inta & inta_mask)
+               write_register(priv->net_dev, IPW_REG_INTA, inta);
+
+       IPW_DEBUG_FW("f/w initialization complete: %s\n",
+                    i ? "SUCCESS" : "FAILED");
+
+       if (!i) {
+               printk(KERN_WARNING DRV_NAME ": %s: Firmware did not initialize.\n",
+                      priv->net_dev->name);
+               return -EIO;
+       }
+
+       /* allow firmware to write to GPIO1 & GPIO3 */
+       read_register(priv->net_dev, IPW_REG_GPIO, &gpio);
+
+       gpio |= (IPW_BIT_GPIO_GPIO1_MASK | IPW_BIT_GPIO_GPIO3_MASK);
+
+       write_register(priv->net_dev, IPW_REG_GPIO, gpio);
+
+       /* Ready to receive commands */
+       priv->status |= STATUS_RUNNING;
+
+       /* The adapter has been reset; we are not associated */
+       priv->status &= ~(STATUS_ASSOCIATING | STATUS_ASSOCIATED);
+
+       IPW_DEBUG_INFO("exit\n");
+
+       return 0;
+}
+
+static inline void ipw2100_reset_fatalerror(struct ipw2100_priv *priv)
+{
+       if (!priv->fatal_error)
+               return;
+
+       priv->fatal_errors[priv->fatal_index++] = priv->fatal_error;
+       priv->fatal_index %= IPW2100_ERROR_QUEUE;
+       priv->fatal_error = 0;
+}
+
+
+/* NOTE: Our interrupt is disabled when this method is called */
+static int ipw2100_power_cycle_adapter(struct ipw2100_priv *priv)
+{
+       u32 reg;
+       int i;
+
+       IPW_DEBUG_INFO("Power cycling the hardware.\n");
+
+       ipw2100_hw_set_gpio(priv);
+
+       /* Step 1. Stop Master Assert */
+       write_register(priv->net_dev, IPW_REG_RESET_REG,
+                      IPW_AUX_HOST_RESET_REG_STOP_MASTER);
+
+       /* Step 2. Wait for stop Master Assert
+        *         (not more then 50us, otherwise ret error */
+       i = 5;
+       do {
+               udelay(IPW_WAIT_RESET_MASTER_ASSERT_COMPLETE_DELAY);
+               read_register(priv->net_dev, IPW_REG_RESET_REG, &reg);
+
+               if (reg & IPW_AUX_HOST_RESET_REG_MASTER_DISABLED)
+                       break;
+       }  while(i--);
+
+       priv->status &= ~STATUS_RESET_PENDING;
+
+       if (!i) {
+               IPW_DEBUG_INFO("exit - waited too long for master assert stop\n");
+               return -EIO;
+       }
+
+       write_register(priv->net_dev, IPW_REG_RESET_REG,
+                      IPW_AUX_HOST_RESET_REG_SW_RESET);
+
+
+       /* Reset any fatal_error conditions */
+       ipw2100_reset_fatalerror(priv);
+
+       /* At this point, the adapter is now stopped and disabled */
+       priv->status &= ~(STATUS_RUNNING | STATUS_ASSOCIATING |
+                         STATUS_ASSOCIATED | STATUS_ENABLED);
+
+       return 0;
+}
+
+/*
+ * Send the CARD_DISABLE_PHY_OFF comamnd to the card to disable it
+ *
+ * After disabling, if the card was associated, a STATUS_ASSN_LOST will be sent.
+ *
+ * STATUS_CARD_DISABLE_NOTIFICATION will be sent regardless of
+ * if STATUS_ASSN_LOST is sent.
+ */
+static int ipw2100_hw_phy_off(struct ipw2100_priv *priv)
+{
+
+#define HW_PHY_OFF_LOOP_DELAY (HZ / 5000)
+
+       struct host_command cmd = {
+               .host_command = CARD_DISABLE_PHY_OFF,
+               .host_command_sequence = 0,
+               .host_command_length = 0,
+       };
+       int err, i;
+       u32 val1, val2;
+
+       IPW_DEBUG_HC("CARD_DISABLE_PHY_OFF\n");
+
+       /* Turn off the radio */
+       err = ipw2100_hw_send_command(priv, &cmd);
+       if (err)
+               return err;
+
+       for (i = 0; i < 2500; i++) {
+               read_nic_dword(priv->net_dev, IPW2100_CONTROL_REG, &val1);
+               read_nic_dword(priv->net_dev, IPW2100_COMMAND, &val2);
+
+               if ((val1 & IPW2100_CONTROL_PHY_OFF) &&
+                   (val2 & IPW2100_COMMAND_PHY_OFF))
+                       return 0;
+
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(HW_PHY_OFF_LOOP_DELAY);
+       }
+
+       return -EIO;
+}
+
+
+static int ipw2100_enable_adapter(struct ipw2100_priv *priv)
+{
+       struct host_command cmd = {
+               .host_command = HOST_COMPLETE,
+               .host_command_sequence = 0,
+               .host_command_length = 0
+       };
+       int err = 0;
+
+       IPW_DEBUG_HC("HOST_COMPLETE\n");
+
+       if (priv->status & STATUS_ENABLED)
+               return 0;
+
+       down(&priv->adapter_sem);
+
+       if (rf_kill_active(priv)) {
+               IPW_DEBUG_HC("Command aborted due to RF kill active.\n");
+               goto fail_up;
+       }
+
+       err = ipw2100_hw_send_command(priv, &cmd);
+       if (err) {
+               IPW_DEBUG_INFO("Failed to send HOST_COMPLETE command\n");
+               goto fail_up;
+       }
+
+       err = ipw2100_wait_for_card_state(priv, IPW_HW_STATE_ENABLED);
+       if (err) {
+               IPW_DEBUG_INFO(
+                      "%s: card not responding to init command.\n",
+                      priv->net_dev->name);
+               goto fail_up;
+       }
+
+       if (priv->stop_hang_check) {
+               priv->stop_hang_check = 0;
+               queue_delayed_work(priv->workqueue, &priv->hang_check, HZ / 2);
+       }
+
+fail_up:
+       up(&priv->adapter_sem);
+       return err;
+}
+
+static int ipw2100_hw_stop_adapter(struct ipw2100_priv *priv)
+{
+#define HW_POWER_DOWN_DELAY (HZ / 10)
+
+       struct host_command cmd = {
+               .host_command = HOST_PRE_POWER_DOWN,
+               .host_command_sequence = 0,
+               .host_command_length = 0,
+       };
+       int err, i;
+       u32 reg;
+
+       if (!(priv->status & STATUS_RUNNING))
+               return 0;
+
+       priv->status |= STATUS_STOPPING;
+
+       /* We can only shut down the card if the firmware is operational.  So,
+        * if we haven't reset since a fatal_error, then we can not send the
+        * shutdown commands. */
+       if (!priv->fatal_error) {
+               /* First, make sure the adapter is enabled so that the PHY_OFF
+                * command can shut it down */
+               ipw2100_enable_adapter(priv);
+
+               err = ipw2100_hw_phy_off(priv);
+               if (err)
+                       printk(KERN_WARNING DRV_NAME ": Error disabling radio %d\n", err);
+
+               /*
+                * If in D0-standby mode going directly to D3 may cause a
+                * PCI bus violation.  Therefore we must change out of the D0
+                * state.
+                *
+                * Sending the PREPARE_FOR_POWER_DOWN will restrict the
+                * hardware from going into standby mode and will transition
+                * out of D0-standy if it is already in that state.
+                *
+                * STATUS_PREPARE_POWER_DOWN_COMPLETE will be sent by the
+                * driver upon completion.  Once received, the driver can
+                * proceed to the D3 state.
+                *
+                * Prepare for power down command to fw.  This command would
+                * take HW out of D0-standby and prepare it for D3 state.
+                *
+                * Currently FW does not support event notification for this
+                * event. Therefore, skip waiting for it.  Just wait a fixed
+                * 100ms
+                */
+               IPW_DEBUG_HC("HOST_PRE_POWER_DOWN\n");
+
+               err = ipw2100_hw_send_command(priv, &cmd);
+               if (err)
+                       printk(KERN_WARNING DRV_NAME ": "
+                              "%s: Power down command failed: Error %d\n",
+                              priv->net_dev->name, err);
+               else {
+                       set_current_state(TASK_UNINTERRUPTIBLE);
+                       schedule_timeout(HW_POWER_DOWN_DELAY);
+               }
+       }
+
+       priv->status &= ~STATUS_ENABLED;
+
+       /*
+        * Set GPIO 3 writable by FW; GPIO 1 writable
+        * by driver and enable clock
+        */
+       ipw2100_hw_set_gpio(priv);
+
+       /*
+        * Power down adapter.  Sequence:
+        * 1. Stop master assert (RESET_REG[9]=1)
+        * 2. Wait for stop master (RESET_REG[8]==1)
+        * 3. S/w reset assert (RESET_REG[7] = 1)
+        */
+
+       /* Stop master assert */
+       write_register(priv->net_dev, IPW_REG_RESET_REG,
+                      IPW_AUX_HOST_RESET_REG_STOP_MASTER);
+
+       /* wait stop master not more than 50 usec.
+        * Otherwise return error. */
+       for (i = 5; i > 0; i--) {
+               udelay(10);
+
+               /* Check master stop bit */
+               read_register(priv->net_dev, IPW_REG_RESET_REG, &reg);
+
+               if (reg & IPW_AUX_HOST_RESET_REG_MASTER_DISABLED)
+                       break;
+       }
+
+       if (i == 0)
+               printk(KERN_WARNING DRV_NAME
+                      ": %s: Could now power down adapter.\n",
+                      priv->net_dev->name);
+
+       /* assert s/w reset */
+       write_register(priv->net_dev, IPW_REG_RESET_REG,
+                      IPW_AUX_HOST_RESET_REG_SW_RESET);
+
+       priv->status &= ~(STATUS_RUNNING | STATUS_STOPPING);
+
+       return 0;
+}
+
+
+static int ipw2100_disable_adapter(struct ipw2100_priv *priv)
+{
+       struct host_command cmd = {
+               .host_command = CARD_DISABLE,
+               .host_command_sequence = 0,
+               .host_command_length = 0
+       };
+       int err = 0;
+
+       IPW_DEBUG_HC("CARD_DISABLE\n");
+
+       if (!(priv->status & STATUS_ENABLED))
+               return 0;
+
+       /* Make sure we clear the associated state */
+       priv->status &= ~(STATUS_ASSOCIATED | STATUS_ASSOCIATING);
+
+       if (!priv->stop_hang_check) {
+               priv->stop_hang_check = 1;
+               cancel_delayed_work(&priv->hang_check);
+       }
+
+       down(&priv->adapter_sem);
+
+       err = ipw2100_hw_send_command(priv, &cmd);
+       if (err) {
+               printk(KERN_WARNING DRV_NAME ": exit - failed to send CARD_DISABLE command\n");
+               goto fail_up;
+       }
+
+       err = ipw2100_wait_for_card_state(priv, IPW_HW_STATE_DISABLED);
+       if (err) {
+               printk(KERN_WARNING DRV_NAME ": exit - card failed to change to DISABLED\n");
+               goto fail_up;
+       }
+
+       IPW_DEBUG_INFO("TODO: implement scan state machine\n");
+
+fail_up:
+       up(&priv->adapter_sem);
+       return err;
+}
+
+static int ipw2100_set_scan_options(struct ipw2100_priv *priv)
+{
+       struct host_command cmd = {
+               .host_command = SET_SCAN_OPTIONS,
+               .host_command_sequence = 0,
+               .host_command_length = 8
+       };
+       int err;
+
+       IPW_DEBUG_INFO("enter\n");
+
+       IPW_DEBUG_SCAN("setting scan options\n");
+
+       cmd.host_command_parameters[0] = 0;
+
+       if (!(priv->config & CFG_ASSOCIATE))
+               cmd.host_command_parameters[0] |= IPW_SCAN_NOASSOCIATE;
+       if ((priv->sec.flags & SEC_ENABLED) && priv->sec.enabled)
+               cmd.host_command_parameters[0] |= IPW_SCAN_MIXED_CELL;
+       if (priv->config & CFG_PASSIVE_SCAN)
+               cmd.host_command_parameters[0] |= IPW_SCAN_PASSIVE;
+
+       cmd.host_command_parameters[1] = priv->channel_mask;
+
+       err = ipw2100_hw_send_command(priv, &cmd);
+
+       IPW_DEBUG_HC("SET_SCAN_OPTIONS 0x%04X\n",
+                    cmd.host_command_parameters[0]);
+
+       return err;
+}
+
+static int ipw2100_start_scan(struct ipw2100_priv *priv)
+{
+       struct host_command cmd = {
+               .host_command = BROADCAST_SCAN,
+               .host_command_sequence = 0,
+               .host_command_length = 4
+       };
+       int err;
+
+       IPW_DEBUG_HC("START_SCAN\n");
+
+       cmd.host_command_parameters[0] = 0;
+
+       /* No scanning if in monitor mode */
+       if (priv->ieee->iw_mode == IW_MODE_MONITOR)
+               return 1;
+
+       if (priv->status & STATUS_SCANNING) {
+               IPW_DEBUG_SCAN("Scan requested while already in scan...\n");
+               return 0;
+       }
+
+       IPW_DEBUG_INFO("enter\n");
+
+       /* Not clearing here; doing so makes iwlist always return nothing...
+        *
+        * We should modify the table logic to use aging tables vs. clearing
+        * the table on each scan start.
+        */
+       IPW_DEBUG_SCAN("starting scan\n");
+
+       priv->status |= STATUS_SCANNING;
+       err = ipw2100_hw_send_command(priv, &cmd);
+       if (err)
+               priv->status &= ~STATUS_SCANNING;
+
+       IPW_DEBUG_INFO("exit\n");
+
+       return err;
+}
+
+static int ipw2100_up(struct ipw2100_priv *priv, int deferred)
+{
+       unsigned long flags;
+       int rc = 0;
+       u32 lock;
+       u32 ord_len = sizeof(lock);
+
+       /* Quite if manually disabled. */
+       if (priv->status & STATUS_RF_KILL_SW) {
+               IPW_DEBUG_INFO("%s: Radio is disabled by Manual Disable "
+                              "switch\n", priv->net_dev->name);
+               return 0;
+       }
+
+       /* If the interrupt is enabled, turn it off... */
+       spin_lock_irqsave(&priv->low_lock, flags);
+       ipw2100_disable_interrupts(priv);
+
+       /* Reset any fatal_error conditions */
+       ipw2100_reset_fatalerror(priv);
+       spin_unlock_irqrestore(&priv->low_lock, flags);
+
+       if (priv->status & STATUS_POWERED ||
+           (priv->status & STATUS_RESET_PENDING)) {
+               /* Power cycle the card ... */
+               if (ipw2100_power_cycle_adapter(priv)) {
+                       printk(KERN_WARNING DRV_NAME ": %s: Could not cycle adapter.\n",
+                                         priv->net_dev->name);
+                       rc = 1;
+                       goto exit;
+               }
+       } else
+               priv->status |= STATUS_POWERED;
+
+       /* Load the firmware, start the clocks, etc. */
+       if (ipw2100_start_adapter(priv)) {
+               printk(KERN_ERR DRV_NAME ": %s: Failed to start the firmware.\n",
+                               priv->net_dev->name);
+               rc = 1;
+               goto exit;
+       }
+
+       ipw2100_initialize_ordinals(priv);
+
+       /* Determine capabilities of this particular HW configuration */
+       if (ipw2100_get_hw_features(priv)) {
+               printk(KERN_ERR DRV_NAME ": %s: Failed to determine HW features.\n",
+                               priv->net_dev->name);
+               rc = 1;
+               goto exit;
+       }
+
+       lock = LOCK_NONE;
+       if (ipw2100_set_ordinal(priv, IPW_ORD_PERS_DB_LOCK, &lock, &ord_len)) {
+               printk(KERN_ERR DRV_NAME ": %s: Failed to clear ordinal lock.\n",
+                               priv->net_dev->name);
+               rc = 1;
+               goto exit;
+       }
+
+       priv->status &= ~STATUS_SCANNING;
+
+       if (rf_kill_active(priv)) {
+               printk(KERN_INFO "%s: Radio is disabled by RF switch.\n",
+                      priv->net_dev->name);
+
+               if (priv->stop_rf_kill) {
+                       priv->stop_rf_kill = 0;
+                       queue_delayed_work(priv->workqueue, &priv->rf_kill, HZ);
+               }
+
+               deferred = 1;
+       }
+
+       /* Turn on the interrupt so that commands can be processed */
+       ipw2100_enable_interrupts(priv);
+
+       /* Send all of the commands that must be sent prior to
+        * HOST_COMPLETE */
+       if (ipw2100_adapter_setup(priv)) {
+               printk(KERN_ERR DRV_NAME ": %s: Failed to start the card.\n",
+                               priv->net_dev->name);
+               rc = 1;
+               goto exit;
+       }
+
+       if (!deferred) {
+               /* Enable the adapter - sends HOST_COMPLETE */
+               if (ipw2100_enable_adapter(priv)) {
+                       printk(KERN_ERR DRV_NAME ": "
+                               "%s: failed in call to enable adapter.\n",
+                               priv->net_dev->name);
+                       ipw2100_hw_stop_adapter(priv);
+                       rc = 1;
+                       goto exit;
+               }
+
+
+               /* Start a scan . . . */
+               ipw2100_set_scan_options(priv);
+               ipw2100_start_scan(priv);
+       }
+
+ exit:
+       return rc;
+}
+
+/* Called by register_netdev() */
+static int ipw2100_net_init(struct net_device *dev)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       return ipw2100_up(priv, 1);
+}
+
+static void ipw2100_down(struct ipw2100_priv *priv)
+{
+       unsigned long flags;
+       union iwreq_data wrqu = {
+               .ap_addr = {
+                       .sa_family = ARPHRD_ETHER
+               }
+       };
+       int associated = priv->status & STATUS_ASSOCIATED;
+
+       /* Kill the RF switch timer */
+       if (!priv->stop_rf_kill) {
+               priv->stop_rf_kill = 1;
+               cancel_delayed_work(&priv->rf_kill);
+       }
+
+       /* Kill the firmare hang check timer */
+       if (!priv->stop_hang_check) {
+               priv->stop_hang_check = 1;
+               cancel_delayed_work(&priv->hang_check);
+       }
+
+       /* Kill any pending resets */
+       if (priv->status & STATUS_RESET_PENDING)
+               cancel_delayed_work(&priv->reset_work);
+
+       /* Make sure the interrupt is on so that FW commands will be
+        * processed correctly */
+       spin_lock_irqsave(&priv->low_lock, flags);
+       ipw2100_enable_interrupts(priv);
+       spin_unlock_irqrestore(&priv->low_lock, flags);
+
+       if (ipw2100_hw_stop_adapter(priv))
+               printk(KERN_ERR DRV_NAME ": %s: Error stopping adapter.\n",
+                      priv->net_dev->name);
+
+       /* Do not disable the interrupt until _after_ we disable
+        * the adaptor.  Otherwise the CARD_DISABLE command will never
+        * be ack'd by the firmware */
+       spin_lock_irqsave(&priv->low_lock, flags);
+       ipw2100_disable_interrupts(priv);
+       spin_unlock_irqrestore(&priv->low_lock, flags);
+
+#ifdef ACPI_CSTATE_LIMIT_DEFINED
+       if (priv->config & CFG_C3_DISABLED) {
+               IPW_DEBUG_INFO(DRV_NAME ": Resetting C3 transitions.\n");
+               acpi_set_cstate_limit(priv->cstate_limit);
+               priv->config &= ~CFG_C3_DISABLED;
+       }
+#endif
+
+       /* We have to signal any supplicant if we are disassociating */
+       if (associated)
+               wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL);
+
+       priv->status &= ~(STATUS_ASSOCIATED | STATUS_ASSOCIATING);
+       netif_carrier_off(priv->net_dev);
+       netif_stop_queue(priv->net_dev);
+}
+
+static void ipw2100_reset_adapter(struct ipw2100_priv *priv)
+{
+       unsigned long flags;
+       union iwreq_data wrqu = {
+               .ap_addr = {
+                       .sa_family = ARPHRD_ETHER
+               }
+       };
+       int associated = priv->status & STATUS_ASSOCIATED;
+
+       spin_lock_irqsave(&priv->low_lock, flags);
+       IPW_DEBUG_INFO(DRV_NAME ": %s: Restarting adapter.\n",
+                      priv->net_dev->name);
+       priv->resets++;
+       priv->status &= ~(STATUS_ASSOCIATED | STATUS_ASSOCIATING);
+       priv->status |= STATUS_SECURITY_UPDATED;
+
+       /* Force a power cycle even if interface hasn't been opened
+        * yet */
+       cancel_delayed_work(&priv->reset_work);
+       priv->status |= STATUS_RESET_PENDING;
+       spin_unlock_irqrestore(&priv->low_lock, flags);
+
+       down(&priv->action_sem);
+       /* stop timed checks so that they don't interfere with reset */
+       priv->stop_hang_check = 1;
+       cancel_delayed_work(&priv->hang_check);
+
+       /* We have to signal any supplicant if we are disassociating */
+       if (associated)
+               wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL);
+
+       ipw2100_up(priv, 0);
+       up(&priv->action_sem);
+
+}
+
+
+static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status)
+{
+
+#define MAC_ASSOCIATION_READ_DELAY (HZ)
+       int ret, len, essid_len;
+       char essid[IW_ESSID_MAX_SIZE];
+       u32 txrate;
+       u32 chan;
+       char *txratename;
+       u8 bssid[ETH_ALEN];
+
+       /*
+        * TBD: BSSID is usually 00:00:00:00:00:00 here and not
+        *      an actual MAC of the AP. Seems like FW sets this
+        *      address too late. Read it later and expose through
+        *      /proc or schedule a later task to query and update
+        */
+
+       essid_len = IW_ESSID_MAX_SIZE;
+       ret = ipw2100_get_ordinal(priv, IPW_ORD_STAT_ASSN_SSID,
+                                 essid, &essid_len);
+       if (ret) {
+               IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
+                                  __LINE__);
+               return;
+       }
+
+       len = sizeof(u32);
+       ret = ipw2100_get_ordinal(priv, IPW_ORD_CURRENT_TX_RATE,
+                                 &txrate, &len);
+       if (ret) {
+               IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
+                                  __LINE__);
+               return;
+       }
+
+       len = sizeof(u32);
+       ret = ipw2100_get_ordinal(priv, IPW_ORD_OUR_FREQ, &chan, &len);
+       if (ret) {
+               IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
+                                  __LINE__);
+               return;
+       }
+       len = ETH_ALEN;
+        ipw2100_get_ordinal(priv, IPW_ORD_STAT_ASSN_AP_BSSID, &bssid,  &len);
+       if (ret) {
+               IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
+                                  __LINE__);
+               return;
+       }
+       memcpy(priv->ieee->bssid, bssid, ETH_ALEN);
+
+
+       switch (txrate) {
+       case TX_RATE_1_MBIT:
+               txratename = "1Mbps";
+               break;
+       case TX_RATE_2_MBIT:
+               txratename = "2Mbsp";
+               break;
+       case TX_RATE_5_5_MBIT:
+               txratename = "5.5Mbps";
+               break;
+       case TX_RATE_11_MBIT:
+               txratename = "11Mbps";
+               break;
+       default:
+               IPW_DEBUG_INFO("Unknown rate: %d\n", txrate);
+               txratename = "unknown rate";
+               break;
+       }
+
+       IPW_DEBUG_INFO("%s: Associated with '%s' at %s, channel %d (BSSID="
+                      MAC_FMT ")\n",
+                      priv->net_dev->name, escape_essid(essid, essid_len),
+                      txratename, chan, MAC_ARG(bssid));
+
+       /* now we copy read ssid into dev */
+       if (!(priv->config & CFG_STATIC_ESSID)) {
+               priv->essid_len = min((u8)essid_len, (u8)IW_ESSID_MAX_SIZE);
+               memcpy(priv->essid, essid, priv->essid_len);
+       }
+       priv->channel = chan;
+       memcpy(priv->bssid, bssid, ETH_ALEN);
+
+       priv->status |= STATUS_ASSOCIATING;
+       priv->connect_start = get_seconds();
+
+       queue_delayed_work(priv->workqueue, &priv->wx_event_work, HZ / 10);
+}
+
+
+static int ipw2100_set_essid(struct ipw2100_priv *priv, char *essid,
+                            int length, int batch_mode)
+{
+       int ssid_len = min(length, IW_ESSID_MAX_SIZE);
+       struct host_command cmd = {
+               .host_command = SSID,
+               .host_command_sequence = 0,
+               .host_command_length = ssid_len
+       };
+       int err;
+
+       IPW_DEBUG_HC("SSID: '%s'\n", escape_essid(essid, ssid_len));
+
+       if (ssid_len)
+               memcpy((char*)cmd.host_command_parameters,
+                      essid, ssid_len);
+
+       if (!batch_mode) {
+               err = ipw2100_disable_adapter(priv);
+               if (err)
+                       return err;
+       }
+
+       /* Bug in FW currently doesn't honor bit 0 in SET_SCAN_OPTIONS to
+        * disable auto association -- so we cheat by setting a bogus SSID */
+       if (!ssid_len && !(priv->config & CFG_ASSOCIATE)) {
+               int i;
+               u8 *bogus = (u8*)cmd.host_command_parameters;
+               for (i = 0; i < IW_ESSID_MAX_SIZE; i++)
+                       bogus[i] = 0x18 + i;
+               cmd.host_command_length = IW_ESSID_MAX_SIZE;
+       }
+
+       /* NOTE:  We always send the SSID command even if the provided ESSID is
+        * the same as what we currently think is set. */
+
+       err = ipw2100_hw_send_command(priv, &cmd);
+       if (!err) {
+               memset(priv->essid + ssid_len, 0,
+                      IW_ESSID_MAX_SIZE - ssid_len);
+               memcpy(priv->essid, essid, ssid_len);
+               priv->essid_len = ssid_len;
+       }
+
+       if (!batch_mode) {
+               if (ipw2100_enable_adapter(priv))
+                       err = -EIO;
+       }
+
+       return err;
+}
+
+static void isr_indicate_association_lost(struct ipw2100_priv *priv, u32 status)
+{
+       IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
+                 "disassociated: '%s' " MAC_FMT " \n",
+                 escape_essid(priv->essid, priv->essid_len),
+                 MAC_ARG(priv->bssid));
+
+       priv->status &= ~(STATUS_ASSOCIATED | STATUS_ASSOCIATING);
+
+       if (priv->status & STATUS_STOPPING) {
+               IPW_DEBUG_INFO("Card is stopping itself, discard ASSN_LOST.\n");
+               return;
+       }
+
+       memset(priv->bssid, 0, ETH_ALEN);
+       memset(priv->ieee->bssid, 0, ETH_ALEN);
+
+       netif_carrier_off(priv->net_dev);
+       netif_stop_queue(priv->net_dev);
+
+       if (!(priv->status & STATUS_RUNNING))
+               return;
+
+       if (priv->status & STATUS_SECURITY_UPDATED)
+               queue_work(priv->workqueue, &priv->security_work);
+
+       queue_work(priv->workqueue, &priv->wx_event_work);
+}
+
+static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status)
+{
+       IPW_DEBUG_INFO("%s: RF Kill state changed to radio OFF.\n",
+              priv->net_dev->name);
+
+       /* RF_KILL is now enabled (else we wouldn't be here) */
+       priv->status |= STATUS_RF_KILL_HW;
+
+#ifdef ACPI_CSTATE_LIMIT_DEFINED
+       if (priv->config & CFG_C3_DISABLED) {
+               IPW_DEBUG_INFO(DRV_NAME ": Resetting C3 transitions.\n");
+               acpi_set_cstate_limit(priv->cstate_limit);
+               priv->config &= ~CFG_C3_DISABLED;
+       }
+#endif
+
+       /* Make sure the RF Kill check timer is running */
+       priv->stop_rf_kill = 0;
+       cancel_delayed_work(&priv->rf_kill);
+       queue_delayed_work(priv->workqueue, &priv->rf_kill, HZ);
+}
+
+static void isr_scan_complete(struct ipw2100_priv *priv, u32 status)
+{
+       IPW_DEBUG_SCAN("scan complete\n");
+       /* Age the scan results... */
+       priv->ieee->scans++;
+       priv->status &= ~STATUS_SCANNING;
+}
+
+#ifdef CONFIG_IPW_DEBUG
+#define IPW2100_HANDLER(v, f) { v, f, # v }
+struct ipw2100_status_indicator {
+       int status;
+       void (*cb)(struct ipw2100_priv *priv, u32 status);
+       char *name;
+};
+#else
+#define IPW2100_HANDLER(v, f) { v, f }
+struct ipw2100_status_indicator {
+       int status;
+       void (*cb)(struct ipw2100_priv *priv, u32 status);
+};
+#endif /* CONFIG_IPW_DEBUG */
+
+static void isr_indicate_scanning(struct ipw2100_priv *priv, u32 status)
+{
+       IPW_DEBUG_SCAN("Scanning...\n");
+       priv->status |= STATUS_SCANNING;
+}
+
+static const struct ipw2100_status_indicator status_handlers[] = {
+       IPW2100_HANDLER(IPW_STATE_INITIALIZED, NULL),
+       IPW2100_HANDLER(IPW_STATE_COUNTRY_FOUND, NULL),
+       IPW2100_HANDLER(IPW_STATE_ASSOCIATED, isr_indicate_associated),
+       IPW2100_HANDLER(IPW_STATE_ASSN_LOST, isr_indicate_association_lost),
+       IPW2100_HANDLER(IPW_STATE_ASSN_CHANGED, NULL),
+       IPW2100_HANDLER(IPW_STATE_SCAN_COMPLETE, isr_scan_complete),
+       IPW2100_HANDLER(IPW_STATE_ENTERED_PSP, NULL),
+       IPW2100_HANDLER(IPW_STATE_LEFT_PSP, NULL),
+       IPW2100_HANDLER(IPW_STATE_RF_KILL, isr_indicate_rf_kill),
+       IPW2100_HANDLER(IPW_STATE_DISABLED, NULL),
+       IPW2100_HANDLER(IPW_STATE_POWER_DOWN, NULL),
+       IPW2100_HANDLER(IPW_STATE_SCANNING, isr_indicate_scanning),
+       IPW2100_HANDLER(-1, NULL)
+};
+
+
+static void isr_status_change(struct ipw2100_priv *priv, int status)
+{
+       int i;
+
+       if (status == IPW_STATE_SCANNING &&
+           priv->status & STATUS_ASSOCIATED &&
+           !(priv->status & STATUS_SCANNING)) {
+               IPW_DEBUG_INFO("Scan detected while associated, with "
+                              "no scan request.  Restarting firmware.\n");
+
+               /* Wake up any sleeping jobs */
+               schedule_reset(priv);
+       }
+
+       for (i = 0; status_handlers[i].status != -1; i++) {
+               if (status == status_handlers[i].status) {
+                       IPW_DEBUG_NOTIF("Status change: %s\n",
+                                        status_handlers[i].name);
+                       if (status_handlers[i].cb)
+                               status_handlers[i].cb(priv, status);
+                       priv->wstats.status = status;
+                       return;
+               }
+       }
+
+       IPW_DEBUG_NOTIF("unknown status received: %04x\n", status);
+}
+
+static void isr_rx_complete_command(
+       struct ipw2100_priv *priv,
+       struct ipw2100_cmd_header *cmd)
+{
+#ifdef CONFIG_IPW_DEBUG
+       if (cmd->host_command_reg < ARRAY_SIZE(command_types)) {
+               IPW_DEBUG_HC("Command completed '%s (%d)'\n",
+                            command_types[cmd->host_command_reg],
+                            cmd->host_command_reg);
+       }
+#endif
+       if (cmd->host_command_reg == HOST_COMPLETE)
+               priv->status |= STATUS_ENABLED;
+
+       if (cmd->host_command_reg == CARD_DISABLE)
+               priv->status &= ~STATUS_ENABLED;
+
+       priv->status &= ~STATUS_CMD_ACTIVE;
+
+       wake_up_interruptible(&priv->wait_command_queue);
+}
+
+#ifdef CONFIG_IPW_DEBUG
+static const char *frame_types[] = {
+       "COMMAND_STATUS_VAL",
+       "STATUS_CHANGE_VAL",
+       "P80211_DATA_VAL",
+       "P8023_DATA_VAL",
+       "HOST_NOTIFICATION_VAL"
+};
+#endif
+
+
+static inline int ipw2100_alloc_skb(
+       struct ipw2100_priv *priv,
+       struct ipw2100_rx_packet *packet)
+{
+       packet->skb = dev_alloc_skb(sizeof(struct ipw2100_rx));
+       if (!packet->skb)
+               return -ENOMEM;
+
+       packet->rxp = (struct ipw2100_rx *)packet->skb->data;
+       packet->dma_addr = pci_map_single(priv->pci_dev, packet->skb->data,
+                                         sizeof(struct ipw2100_rx),
+                                         PCI_DMA_FROMDEVICE);
+       /* NOTE: pci_map_single does not return an error code, and 0 is a valid
+        *       dma_addr */
+
+       return 0;
+}
+
+
+#define SEARCH_ERROR   0xffffffff
+#define SEARCH_FAIL    0xfffffffe
+#define SEARCH_SUCCESS 0xfffffff0
+#define SEARCH_DISCARD 0
+#define SEARCH_SNAPSHOT 1
+
+#define SNAPSHOT_ADDR(ofs) (priv->snapshot[((ofs) >> 12) & 0xff] + ((ofs) & 0xfff))
+static inline int ipw2100_snapshot_alloc(struct ipw2100_priv *priv)
+{
+       int i;
+       if (priv->snapshot[0])
+               return 1;
+       for (i = 0; i < 0x30; i++) {
+               priv->snapshot[i] = (u8*)kmalloc(0x1000, GFP_ATOMIC);
+               if (!priv->snapshot[i]) {
+                       IPW_DEBUG_INFO("%s: Error allocating snapshot "
+                              "buffer %d\n", priv->net_dev->name, i);
+                       while (i > 0)
+                               kfree(priv->snapshot[--i]);
+                       priv->snapshot[0] = NULL;
+                       return 0;
+               }
+       }
+
+       return 1;
+}
+
+static inline void ipw2100_snapshot_free(struct ipw2100_priv *priv)
+{
+       int i;
+       if (!priv->snapshot[0])
+               return;
+       for (i = 0; i < 0x30; i++)
+               kfree(priv->snapshot[i]);
+       priv->snapshot[0] = NULL;
+}
+
+static inline u32 ipw2100_match_buf(struct ipw2100_priv *priv, u8 *in_buf,
+                                   size_t len, int mode)
+{
+       u32 i, j;
+       u32 tmp;
+       u8 *s, *d;
+       u32 ret;
+
+       s = in_buf;
+       if (mode == SEARCH_SNAPSHOT) {
+               if (!ipw2100_snapshot_alloc(priv))
+                       mode = SEARCH_DISCARD;
+       }
+
+       for (ret = SEARCH_FAIL, i = 0; i < 0x30000; i += 4) {
+               read_nic_dword(priv->net_dev, i, &tmp);
+               if (mode == SEARCH_SNAPSHOT)
+                       *(u32 *)SNAPSHOT_ADDR(i) = tmp;
+               if (ret == SEARCH_FAIL) {
+                       d = (u8*)&tmp;
+                       for (j = 0; j < 4; j++) {
+                               if (*s != *d) {
+                                       s = in_buf;
+                                       continue;
+                               }
+
+                               s++;
+                               d++;
+
+                               if ((s - in_buf) == len)
+                                       ret = (i + j) - len + 1;
+                       }
+               } else if (mode == SEARCH_DISCARD)
+                       return ret;
+       }
+
+       return ret;
+}
+
+/*
+ *
+ * 0) Disconnect the SKB from the firmware (just unmap)
+ * 1) Pack the ETH header into the SKB
+ * 2) Pass the SKB to the network stack
+ *
+ * When packet is provided by the firmware, it contains the following:
+ *
+ * .  ieee80211_hdr
+ * .  ieee80211_snap_hdr
+ *
+ * The size of the constructed ethernet
+ *
+ */
+#ifdef CONFIG_IPW2100_RX_DEBUG
+static u8 packet_data[IPW_RX_NIC_BUFFER_LENGTH];
+#endif
+
+static inline void ipw2100_corruption_detected(struct ipw2100_priv *priv,
+                                              int i)
+{
+#ifdef CONFIG_IPW_DEBUG_C3
+       struct ipw2100_status *status = &priv->status_queue.drv[i];
+       u32 match, reg;
+       int j;
+#endif
+#ifdef ACPI_CSTATE_LIMIT_DEFINED
+       int limit;
+#endif
+
+       IPW_DEBUG_INFO(DRV_NAME ": PCI latency error detected at "
+                      "0x%04zX.\n", i * sizeof(struct ipw2100_status));
+
+#ifdef ACPI_CSTATE_LIMIT_DEFINED
+       IPW_DEBUG_INFO(DRV_NAME ": Disabling C3 transitions.\n");
+       limit = acpi_get_cstate_limit();
+       if (limit > 2) {
+               priv->cstate_limit = limit;
+               acpi_set_cstate_limit(2);
+               priv->config |= CFG_C3_DISABLED;
+       }
+#endif
+
+#ifdef CONFIG_IPW_DEBUG_C3
+       /* Halt the fimrware so we can get a good image */
+       write_register(priv->net_dev, IPW_REG_RESET_REG,
+                      IPW_AUX_HOST_RESET_REG_STOP_MASTER);
+       j = 5;
+       do {
+               udelay(IPW_WAIT_RESET_MASTER_ASSERT_COMPLETE_DELAY);
+               read_register(priv->net_dev, IPW_REG_RESET_REG, &reg);
+
+               if (reg & IPW_AUX_HOST_RESET_REG_MASTER_DISABLED)
+                       break;
+       }  while (j--);
+
+       match = ipw2100_match_buf(priv, (u8*)status,
+                                 sizeof(struct ipw2100_status),
+                                 SEARCH_SNAPSHOT);
+       if (match < SEARCH_SUCCESS)
+               IPW_DEBUG_INFO("%s: DMA status match in Firmware at "
+                              "offset 0x%06X, length %d:\n",
+                              priv->net_dev->name, match,
+                              sizeof(struct ipw2100_status));
+       else
+               IPW_DEBUG_INFO("%s: No DMA status match in "
+                              "Firmware.\n", priv->net_dev->name);
+
+       printk_buf((u8*)priv->status_queue.drv,
+                  sizeof(struct ipw2100_status) * RX_QUEUE_LENGTH);
+#endif
+
+       priv->fatal_error = IPW2100_ERR_C3_CORRUPTION;
+       priv->ieee->stats.rx_errors++;
+       schedule_reset(priv);
+}
+
+static inline void isr_rx(struct ipw2100_priv *priv, int i,
+                         struct ieee80211_rx_stats *stats)
+{
+       struct ipw2100_status *status = &priv->status_queue.drv[i];
+       struct ipw2100_rx_packet *packet = &priv->rx_buffers[i];
+
+       IPW_DEBUG_RX("Handler...\n");
+
+       if (unlikely(status->frame_size > skb_tailroom(packet->skb))) {
+               IPW_DEBUG_INFO("%s: frame_size (%u) > skb_tailroom (%u)!"
+                              "  Dropping.\n",
+                              priv->net_dev->name,
+                              status->frame_size, skb_tailroom(packet->skb));
+               priv->ieee->stats.rx_errors++;
+               return;
+       }
+
+       if (unlikely(!netif_running(priv->net_dev))) {
+               priv->ieee->stats.rx_errors++;
+               priv->wstats.discard.misc++;
+               IPW_DEBUG_DROP("Dropping packet while interface is not up.\n");
+               return;
+       }
+
+       if (unlikely(priv->ieee->iw_mode == IW_MODE_MONITOR &&
+                    status->flags & IPW_STATUS_FLAG_CRC_ERROR)) {
+               IPW_DEBUG_RX("CRC error in packet.  Dropping.\n");
+               priv->ieee->stats.rx_errors++;
+               return;
+       }
+
+       if (unlikely(priv->ieee->iw_mode != IW_MODE_MONITOR &&
+               !(priv->status & STATUS_ASSOCIATED))) {
+               IPW_DEBUG_DROP("Dropping packet while not associated.\n");
+               priv->wstats.discard.misc++;
+               return;
+       }
+
+
+       pci_unmap_single(priv->pci_dev,
+                        packet->dma_addr,
+                        sizeof(struct ipw2100_rx),
+                        PCI_DMA_FROMDEVICE);
+
+       skb_put(packet->skb, status->frame_size);
+
+#ifdef CONFIG_IPW2100_RX_DEBUG
+       /* Make a copy of the frame so we can dump it to the logs if
+        * ieee80211_rx fails */
+       memcpy(packet_data, packet->skb->data,
+              min_t(u32, status->frame_size, IPW_RX_NIC_BUFFER_LENGTH));
+#endif
+
+       if (!ieee80211_rx(priv->ieee, packet->skb, stats)) {
+#ifdef CONFIG_IPW2100_RX_DEBUG
+               IPW_DEBUG_DROP("%s: Non consumed packet:\n",
+                              priv->net_dev->name);
+               printk_buf(IPW_DL_DROP, packet_data, status->frame_size);
+#endif
+               priv->ieee->stats.rx_errors++;
+
+               /* ieee80211_rx failed, so it didn't free the SKB */
+               dev_kfree_skb_any(packet->skb);
+               packet->skb = NULL;
+       }
+
+       /* We need to allocate a new SKB and attach it to the RDB. */
+       if (unlikely(ipw2100_alloc_skb(priv, packet))) {
+               printk(KERN_WARNING DRV_NAME ": "
+                       "%s: Unable to allocate SKB onto RBD ring - disabling "
+                       "adapter.\n", priv->net_dev->name);
+               /* TODO: schedule adapter shutdown */
+               IPW_DEBUG_INFO("TODO: Shutdown adapter...\n");
+       }
+
+       /* Update the RDB entry */
+       priv->rx_queue.drv[i].host_addr = packet->dma_addr;
+}
+
+static inline int ipw2100_corruption_check(struct ipw2100_priv *priv, int i)
+{
+       struct ipw2100_status *status = &priv->status_queue.drv[i];
+       struct ipw2100_rx *u = priv->rx_buffers[i].rxp;
+       u16 frame_type = status->status_fields & STATUS_TYPE_MASK;
+
+       switch (frame_type) {
+       case COMMAND_STATUS_VAL:
+               return (status->frame_size != sizeof(u->rx_data.command));
+       case STATUS_CHANGE_VAL:
+               return (status->frame_size != sizeof(u->rx_data.status));
+       case HOST_NOTIFICATION_VAL:
+               return (status->frame_size < sizeof(u->rx_data.notification));
+       case P80211_DATA_VAL:
+       case P8023_DATA_VAL:
+#ifdef CONFIG_IPW2100_MONITOR
+               return 0;
+#else
+               switch (WLAN_FC_GET_TYPE(u->rx_data.header.frame_ctl)) {
+               case IEEE80211_FTYPE_MGMT:
+               case IEEE80211_FTYPE_CTL:
+                       return 0;
+               case IEEE80211_FTYPE_DATA:
+                       return (status->frame_size >
+                               IPW_MAX_802_11_PAYLOAD_LENGTH);
+               }
+#endif
+       }
+
+       return 1;
+}
+
+/*
+ * ipw2100 interrupts are disabled at this point, and the ISR
+ * is the only code that calls this method.  So, we do not need
+ * to play with any locks.
+ *
+ * RX Queue works as follows:
+ *
+ * Read index - firmware places packet in entry identified by the
+ *              Read index and advances Read index.  In this manner,
+ *              Read index will always point to the next packet to
+ *              be filled--but not yet valid.
+ *
+ * Write index - driver fills this entry with an unused RBD entry.
+ *               This entry has not filled by the firmware yet.
+ *
+ * In between the W and R indexes are the RBDs that have been received
+ * but not yet processed.
+ *
+ * The process of handling packets will start at WRITE + 1 and advance
+ * until it reaches the READ index.
+ *
+ * The WRITE index is cached in the variable 'priv->rx_queue.next'.
+ *
+ */
+static inline void __ipw2100_rx_process(struct ipw2100_priv *priv)
+{
+       struct ipw2100_bd_queue *rxq = &priv->rx_queue;
+       struct ipw2100_status_queue *sq = &priv->status_queue;
+       struct ipw2100_rx_packet *packet;
+       u16 frame_type;
+       u32 r, w, i, s;
+       struct ipw2100_rx *u;
+       struct ieee80211_rx_stats stats = {
+               .mac_time = jiffies,
+       };
+
+       read_register(priv->net_dev, IPW_MEM_HOST_SHARED_RX_READ_INDEX, &r);
+       read_register(priv->net_dev, IPW_MEM_HOST_SHARED_RX_WRITE_INDEX, &w);
+
+       if (r >= rxq->entries) {
+               IPW_DEBUG_RX("exit - bad read index\n");
+               return;
+       }
+
+       i = (rxq->next + 1) % rxq->entries;
+       s = i;
+       while (i != r) {
+               /* IPW_DEBUG_RX("r = %d : w = %d : processing = %d\n",
+                  r, rxq->next, i); */
+
+               packet = &priv->rx_buffers[i];
+
+               /* Sync the DMA for the STATUS buffer so CPU is sure to get
+                * the correct values */
+               pci_dma_sync_single_for_cpu(
+                       priv->pci_dev,
+                       sq->nic + sizeof(struct ipw2100_status) * i,
+                       sizeof(struct ipw2100_status),
+                       PCI_DMA_FROMDEVICE);
+
+               /* Sync the DMA for the RX buffer so CPU is sure to get
+                * the correct values */
+               pci_dma_sync_single_for_cpu(priv->pci_dev, packet->dma_addr,
+                                           sizeof(struct ipw2100_rx),
+                                           PCI_DMA_FROMDEVICE);
+
+               if (unlikely(ipw2100_corruption_check(priv, i))) {
+                       ipw2100_corruption_detected(priv, i);
+                       goto increment;
+               }
+
+               u = packet->rxp;
+               frame_type = sq->drv[i].status_fields &
+                       STATUS_TYPE_MASK;
+               stats.rssi = sq->drv[i].rssi + IPW2100_RSSI_TO_DBM;
+               stats.len = sq->drv[i].frame_size;
+
+               stats.mask = 0;
+               if (stats.rssi != 0)
+                       stats.mask |= IEEE80211_STATMASK_RSSI;
+               stats.freq = IEEE80211_24GHZ_BAND;
+
+               IPW_DEBUG_RX(
+                       "%s: '%s' frame type received (%d).\n",
+                       priv->net_dev->name, frame_types[frame_type],
+                       stats.len);
+
+               switch (frame_type) {
+               case COMMAND_STATUS_VAL:
+                       /* Reset Rx watchdog */
+                       isr_rx_complete_command(
+                               priv, &u->rx_data.command);
+                       break;
+
+               case STATUS_CHANGE_VAL:
+                       isr_status_change(priv, u->rx_data.status);
+                       break;
+
+               case P80211_DATA_VAL:
+               case P8023_DATA_VAL:
+#ifdef CONFIG_IPW2100_MONITOR
+                       if (priv->ieee->iw_mode == IW_MODE_MONITOR) {
+                               isr_rx(priv, i, &stats);
+                               break;
+                       }
+#endif
+                       if (stats.len < sizeof(u->rx_data.header))
+                               break;
+                       switch (WLAN_FC_GET_TYPE(u->rx_data.header.
+                                                frame_ctl)) {
+                       case IEEE80211_FTYPE_MGMT:
+                               ieee80211_rx_mgt(priv->ieee,
+                                                &u->rx_data.header,
+                                                &stats);
+                               break;
+
+                       case IEEE80211_FTYPE_CTL:
+                               break;
+
+                       case IEEE80211_FTYPE_DATA:
+                               isr_rx(priv, i, &stats);
+                               break;
+
+                       }
+                       break;
+               }
+
+       increment:
+               /* clear status field associated with this RBD */
+               rxq->drv[i].status.info.field = 0;
+
+               i = (i + 1) % rxq->entries;
+       }
+
+       if (i != s) {
+               /* backtrack one entry, wrapping to end if at 0 */
+               rxq->next = (i ? i : rxq->entries) - 1;
+
+               write_register(priv->net_dev,
+                              IPW_MEM_HOST_SHARED_RX_WRITE_INDEX,
+                              rxq->next);
+       }
+}
+
+
+/*
+ * __ipw2100_tx_process
+ *
+ * This routine will determine whether the next packet on
+ * the fw_pend_list has been processed by the firmware yet.
+ *
+ * If not, then it does nothing and returns.
+ *
+ * If so, then it removes the item from the fw_pend_list, frees
+ * any associated storage, and places the item back on the
+ * free list of its source (either msg_free_list or tx_free_list)
+ *
+ * TX Queue works as follows:
+ *
+ * Read index - points to the next TBD that the firmware will
+ *              process.  The firmware will read the data, and once
+ *              done processing, it will advance the Read index.
+ *
+ * Write index - driver fills this entry with an constructed TBD
+ *               entry.  The Write index is not advanced until the
+ *               packet has been configured.
+ *
+ * In between the W and R indexes are the TBDs that have NOT been
+ * processed.  Lagging behind the R index are packets that have
+ * been processed but have not been freed by the driver.
+ *
+ * In order to free old storage, an internal index will be maintained
+ * that points to the next packet to be freed.  When all used
+ * packets have been freed, the oldest index will be the same as the
+ * firmware's read index.
+ *
+ * The OLDEST index is cached in the variable 'priv->tx_queue.oldest'
+ *
+ * Because the TBD structure can not contain arbitrary data, the
+ * driver must keep an internal queue of cached allocations such that
+ * it can put that data back into the tx_free_list and msg_free_list
+ * for use by future command and data packets.
+ *
+ */
+static inline int __ipw2100_tx_process(struct ipw2100_priv *priv)
+{
+       struct ipw2100_bd_queue *txq = &priv->tx_queue;
+        struct ipw2100_bd *tbd;
+       struct list_head *element;
+       struct ipw2100_tx_packet *packet;
+       int descriptors_used;
+       int e, i;
+       u32 r, w, frag_num = 0;
+
+       if (list_empty(&priv->fw_pend_list))
+               return 0;
+
+       element = priv->fw_pend_list.next;
+
+       packet = list_entry(element, struct ipw2100_tx_packet, list);
+        tbd = &txq->drv[packet->index];
+
+       /* Determine how many TBD entries must be finished... */
+       switch (packet->type) {
+       case COMMAND:
+               /* COMMAND uses only one slot; don't advance */
+               descriptors_used = 1;
+               e = txq->oldest;
+               break;
+
+       case DATA:
+               /* DATA uses two slots; advance and loop position. */
+               descriptors_used = tbd->num_fragments;
+                frag_num = tbd->num_fragments - 1;
+               e = txq->oldest + frag_num;
+               e %= txq->entries;
+               break;
+
+       default:
+               printk(KERN_WARNING DRV_NAME ": %s: Bad fw_pend_list entry!\n",
+                                  priv->net_dev->name);
+               return 0;
+       }
+
+       /* if the last TBD is not done by NIC yet, then packet is
+        * not ready to be released.
+        *
+        */
+       read_register(priv->net_dev, IPW_MEM_HOST_SHARED_TX_QUEUE_READ_INDEX,
+                     &r);
+       read_register(priv->net_dev, IPW_MEM_HOST_SHARED_TX_QUEUE_WRITE_INDEX,
+                     &w);
+       if (w != txq->next)
+               printk(KERN_WARNING DRV_NAME ": %s: write index mismatch\n",
+                      priv->net_dev->name);
+
+        /*
+        * txq->next is the index of the last packet written txq->oldest is
+        * the index of the r is the index of the next packet to be read by
+        * firmware
+        */
+
+
+       /*
+        * Quick graphic to help you visualize the following
+        * if / else statement
+        *
+        * ===>|                     s---->|===============
+        *                               e>|
+        * | a | b | c | d | e | f | g | h | i | j | k | l
+        *       r---->|
+        *               w
+        *
+        * w - updated by driver
+        * r - updated by firmware
+        * s - start of oldest BD entry (txq->oldest)
+        * e - end of oldest BD entry
+        *
+        */
+       if (!((r <= w && (e < r || e >= w)) || (e < r && e >= w))) {
+               IPW_DEBUG_TX("exit - no processed packets ready to release.\n");
+               return 0;
+       }
+
+       list_del(element);
+       DEC_STAT(&priv->fw_pend_stat);
+
+#ifdef CONFIG_IPW_DEBUG
+       {
+               int i = txq->oldest;
+               IPW_DEBUG_TX(
+                       "TX%d V=%p P=%04X T=%04X L=%d\n", i,
+                       &txq->drv[i],
+                       (u32)(txq->nic + i * sizeof(struct ipw2100_bd)),
+                       txq->drv[i].host_addr,
+                       txq->drv[i].buf_length);
+
+               if (packet->type == DATA) {
+                       i = (i + 1) % txq->entries;
+
+                       IPW_DEBUG_TX(
+                               "TX%d V=%p P=%04X T=%04X L=%d\n", i,
+                               &txq->drv[i],
+                               (u32)(txq->nic + i *
+                               sizeof(struct ipw2100_bd)),
+                               (u32)txq->drv[i].host_addr,
+                               txq->drv[i].buf_length);
+               }
+       }
+#endif
+
+       switch (packet->type) {
+       case DATA:
+               if (txq->drv[txq->oldest].status.info.fields.txType != 0)
+                       printk(KERN_WARNING DRV_NAME ": %s: Queue mismatch.  "
+                              "Expecting DATA TBD but pulled "
+                              "something else: ids %d=%d.\n",
+                              priv->net_dev->name, txq->oldest, packet->index);
+
+               /* DATA packet; we have to unmap and free the SKB */
+               priv->ieee->stats.tx_packets++;
+               for (i = 0; i < frag_num; i++) {
+                       tbd = &txq->drv[(packet->index + 1 + i) %
+                                       txq->entries];
+
+                       IPW_DEBUG_TX(
+                               "TX%d P=%08x L=%d\n",
+                               (packet->index + 1 + i) % txq->entries,
+                               tbd->host_addr, tbd->buf_length);
+
+                       pci_unmap_single(priv->pci_dev,
+                                        tbd->host_addr,
+                                        tbd->buf_length,
+                                        PCI_DMA_TODEVICE);
+               }
+
+               priv->ieee->stats.tx_bytes += packet->info.d_struct.txb->payload_size;
+               ieee80211_txb_free(packet->info.d_struct.txb);
+               packet->info.d_struct.txb = NULL;
+
+               list_add_tail(element, &priv->tx_free_list);
+               INC_STAT(&priv->tx_free_stat);
+
+               /* We have a free slot in the Tx queue, so wake up the
+                * transmit layer if it is stopped. */
+               if (priv->status & STATUS_ASSOCIATED &&
+                   netif_queue_stopped(priv->net_dev)) {
+                       IPW_DEBUG_INFO(KERN_INFO
+                                          "%s: Waking net queue.\n",
+                                          priv->net_dev->name);
+                       netif_wake_queue(priv->net_dev);
+               }
+
+               /* A packet was processed by the hardware, so update the
+                * watchdog */
+               priv->net_dev->trans_start = jiffies;
+
+               break;
+
+       case COMMAND:
+               if (txq->drv[txq->oldest].status.info.fields.txType != 1)
+                       printk(KERN_WARNING DRV_NAME ": %s: Queue mismatch.  "
+                              "Expecting COMMAND TBD but pulled "
+                              "something else: ids %d=%d.\n",
+                              priv->net_dev->name, txq->oldest, packet->index);
+
+#ifdef CONFIG_IPW_DEBUG
+               if (packet->info.c_struct.cmd->host_command_reg <
+                   sizeof(command_types) / sizeof(*command_types))
+                       IPW_DEBUG_TX(
+                               "Command '%s (%d)' processed: %d.\n",
+                               command_types[packet->info.c_struct.cmd->host_command_reg],
+                               packet->info.c_struct.cmd->host_command_reg,
+                               packet->info.c_struct.cmd->cmd_status_reg);
+#endif
+
+               list_add_tail(element, &priv->msg_free_list);
+               INC_STAT(&priv->msg_free_stat);
+               break;
+       }
+
+       /* advance oldest used TBD pointer to start of next entry */
+       txq->oldest = (e + 1) % txq->entries;
+       /* increase available TBDs number */
+       txq->available += descriptors_used;
+       SET_STAT(&priv->txq_stat, txq->available);
+
+       IPW_DEBUG_TX("packet latency (send to process)  %ld jiffies\n",
+                        jiffies - packet->jiffy_start);
+
+       return (!list_empty(&priv->fw_pend_list));
+}
+
+
+static inline void __ipw2100_tx_complete(struct ipw2100_priv *priv)
+{
+       int i = 0;
+
+       while (__ipw2100_tx_process(priv) && i < 200) i++;
+
+       if (i == 200) {
+               printk(KERN_WARNING DRV_NAME ": "
+                      "%s: Driver is running slow (%d iters).\n",
+                      priv->net_dev->name, i);
+       }
+}
+
+
+static void ipw2100_tx_send_commands(struct ipw2100_priv *priv)
+{
+       struct list_head *element;
+       struct ipw2100_tx_packet *packet;
+       struct ipw2100_bd_queue *txq = &priv->tx_queue;
+       struct ipw2100_bd *tbd;
+       int next = txq->next;
+
+       while (!list_empty(&priv->msg_pend_list)) {
+               /* if there isn't enough space in TBD queue, then
+                * don't stuff a new one in.
+                * NOTE: 3 are needed as a command will take one,
+                *       and there is a minimum of 2 that must be
+                *       maintained between the r and w indexes
+                */
+               if (txq->available <= 3) {
+                       IPW_DEBUG_TX("no room in tx_queue\n");
+                       break;
+               }
+
+               element = priv->msg_pend_list.next;
+               list_del(element);
+               DEC_STAT(&priv->msg_pend_stat);
+
+               packet = list_entry(element,
+                                   struct ipw2100_tx_packet, list);
+
+               IPW_DEBUG_TX("using TBD at virt=%p, phys=%p\n",
+                                &txq->drv[txq->next],
+                                (void*)(txq->nic + txq->next *
+                                        sizeof(struct ipw2100_bd)));
+
+               packet->index = txq->next;
+
+               tbd = &txq->drv[txq->next];
+
+               /* initialize TBD */
+               tbd->host_addr = packet->info.c_struct.cmd_phys;
+               tbd->buf_length = sizeof(struct ipw2100_cmd_header);
+               /* not marking number of fragments causes problems
+                * with f/w debug version */
+               tbd->num_fragments = 1;
+               tbd->status.info.field =
+                       IPW_BD_STATUS_TX_FRAME_COMMAND |
+                       IPW_BD_STATUS_TX_INTERRUPT_ENABLE;
+
+               /* update TBD queue counters */
+               txq->next++;
+               txq->next %= txq->entries;
+               txq->available--;
+               DEC_STAT(&priv->txq_stat);
+
+               list_add_tail(element, &priv->fw_pend_list);
+               INC_STAT(&priv->fw_pend_stat);
+       }
+
+       if (txq->next != next) {
+               /* kick off the DMA by notifying firmware the
+                * write index has moved; make sure TBD stores are sync'd */
+               wmb();
+               write_register(priv->net_dev,
+                              IPW_MEM_HOST_SHARED_TX_QUEUE_WRITE_INDEX,
+                              txq->next);
+       }
+}
+
+
+/*
+ * ipw2100_tx_send_data
+ *
+ */
+static void ipw2100_tx_send_data(struct ipw2100_priv *priv)
+{
+       struct list_head *element;
+       struct ipw2100_tx_packet *packet;
+       struct ipw2100_bd_queue *txq = &priv->tx_queue;
+       struct ipw2100_bd *tbd;
+       int next = txq->next;
+        int i = 0;
+       struct ipw2100_data_header *ipw_hdr;
+       struct ieee80211_hdr *hdr;
+
+       while (!list_empty(&priv->tx_pend_list)) {
+               /* if there isn't enough space in TBD queue, then
+                * don't stuff a new one in.
+                * NOTE: 4 are needed as a data will take two,
+                *       and there is a minimum of 2 that must be
+                *       maintained between the r and w indexes
+                */
+               element = priv->tx_pend_list.next;
+                packet = list_entry(element, struct ipw2100_tx_packet, list);
+
+               if (unlikely(1 + packet->info.d_struct.txb->nr_frags >
+                            IPW_MAX_BDS)) {
+                       /* TODO: Support merging buffers if more than
+                        * IPW_MAX_BDS are used */
+                       IPW_DEBUG_INFO(
+                              "%s: Maximum BD theshold exceeded.  "
+                              "Increase fragmentation level.\n",
+                              priv->net_dev->name);
+               }
+
+               if (txq->available <= 3 +
+                   packet->info.d_struct.txb->nr_frags) {
+                       IPW_DEBUG_TX("no room in tx_queue\n");
+                       break;
+               }
+
+               list_del(element);
+               DEC_STAT(&priv->tx_pend_stat);
+
+               tbd = &txq->drv[txq->next];
+
+               packet->index = txq->next;
+
+               ipw_hdr = packet->info.d_struct.data;
+               hdr = (struct ieee80211_hdr *)packet->info.d_struct.txb->
+                       fragments[0]->data;
+
+               if (priv->ieee->iw_mode == IW_MODE_INFRA) {
+                       /* To DS: Addr1 = BSSID, Addr2 = SA,
+                          Addr3 = DA */
+                       memcpy(ipw_hdr->src_addr, hdr->addr2, ETH_ALEN);
+                       memcpy(ipw_hdr->dst_addr, hdr->addr3, ETH_ALEN);
+               } else if (priv->ieee->iw_mode == IW_MODE_ADHOC) {
+                       /* not From/To DS: Addr1 = DA, Addr2 = SA,
+                          Addr3 = BSSID */
+                       memcpy(ipw_hdr->src_addr, hdr->addr2, ETH_ALEN);
+                       memcpy(ipw_hdr->dst_addr, hdr->addr1, ETH_ALEN);
+               }
+
+               ipw_hdr->host_command_reg = SEND;
+               ipw_hdr->host_command_reg1 = 0;
+
+               /* For now we only support host based encryption */
+               ipw_hdr->needs_encryption = 0;
+               ipw_hdr->encrypted = packet->info.d_struct.txb->encrypted;
+               if (packet->info.d_struct.txb->nr_frags > 1)
+                       ipw_hdr->fragment_size =
+                               packet->info.d_struct.txb->frag_size - IEEE80211_3ADDR_LEN;
+               else
+                       ipw_hdr->fragment_size = 0;
+
+               tbd->host_addr = packet->info.d_struct.data_phys;
+               tbd->buf_length = sizeof(struct ipw2100_data_header);
+               tbd->num_fragments = 1 + packet->info.d_struct.txb->nr_frags;
+               tbd->status.info.field =
+                       IPW_BD_STATUS_TX_FRAME_802_3 |
+                       IPW_BD_STATUS_TX_FRAME_NOT_LAST_FRAGMENT;
+               txq->next++;
+               txq->next %= txq->entries;
+
+               IPW_DEBUG_TX(
+                       "data header tbd TX%d P=%08x L=%d\n",
+                       packet->index, tbd->host_addr,
+                       tbd->buf_length);
+#ifdef CONFIG_IPW_DEBUG
+               if (packet->info.d_struct.txb->nr_frags > 1)
+                       IPW_DEBUG_FRAG("fragment Tx: %d frames\n",
+                                      packet->info.d_struct.txb->nr_frags);
+#endif
+
+                for (i = 0; i < packet->info.d_struct.txb->nr_frags; i++) {
+                       tbd = &txq->drv[txq->next];
+                       if (i == packet->info.d_struct.txb->nr_frags - 1)
+                               tbd->status.info.field =
+                                       IPW_BD_STATUS_TX_FRAME_802_3 |
+                                       IPW_BD_STATUS_TX_INTERRUPT_ENABLE;
+                       else
+                               tbd->status.info.field =
+                                       IPW_BD_STATUS_TX_FRAME_802_3 |
+                                       IPW_BD_STATUS_TX_FRAME_NOT_LAST_FRAGMENT;
+
+                       tbd->buf_length = packet->info.d_struct.txb->
+                               fragments[i]->len - IEEE80211_3ADDR_LEN;
+
+                        tbd->host_addr = pci_map_single(
+                               priv->pci_dev,
+                               packet->info.d_struct.txb->fragments[i]->data +
+                               IEEE80211_3ADDR_LEN,
+                               tbd->buf_length,
+                               PCI_DMA_TODEVICE);
+
+                       IPW_DEBUG_TX(
+                               "data frag tbd TX%d P=%08x L=%d\n",
+                               txq->next, tbd->host_addr, tbd->buf_length);
+
+                       pci_dma_sync_single_for_device(
+                               priv->pci_dev, tbd->host_addr,
+                               tbd->buf_length,
+                               PCI_DMA_TODEVICE);
+
+                       txq->next++;
+                       txq->next %= txq->entries;
+                }
+
+               txq->available -= 1 + packet->info.d_struct.txb->nr_frags;
+               SET_STAT(&priv->txq_stat, txq->available);
+
+               list_add_tail(element, &priv->fw_pend_list);
+               INC_STAT(&priv->fw_pend_stat);
+       }
+
+       if (txq->next != next) {
+               /* kick off the DMA by notifying firmware the
+                * write index has moved; make sure TBD stores are sync'd */
+               write_register(priv->net_dev,
+                              IPW_MEM_HOST_SHARED_TX_QUEUE_WRITE_INDEX,
+                              txq->next);
+       }
+        return;
+}
+
+static void ipw2100_irq_tasklet(struct ipw2100_priv *priv)
+{
+       struct net_device *dev = priv->net_dev;
+       unsigned long flags;
+       u32 inta, tmp;
+
+       spin_lock_irqsave(&priv->low_lock, flags);
+       ipw2100_disable_interrupts(priv);
+
+       read_register(dev, IPW_REG_INTA, &inta);
+
+       IPW_DEBUG_ISR("enter - INTA: 0x%08lX\n",
+                     (unsigned long)inta & IPW_INTERRUPT_MASK);
+
+       priv->in_isr++;
+       priv->interrupts++;
+
+       /* We do not loop and keep polling for more interrupts as this
+        * is frowned upon and doesn't play nicely with other potentially
+        * chained IRQs */
+       IPW_DEBUG_ISR("INTA: 0x%08lX\n",
+                     (unsigned long)inta & IPW_INTERRUPT_MASK);
+
+       if (inta & IPW2100_INTA_FATAL_ERROR) {
+               printk(KERN_WARNING DRV_NAME
+                                 ": Fatal interrupt. Scheduling firmware restart.\n");
+               priv->inta_other++;
+               write_register(
+                       dev, IPW_REG_INTA,
+                       IPW2100_INTA_FATAL_ERROR);
+
+               read_nic_dword(dev, IPW_NIC_FATAL_ERROR, &priv->fatal_error);
+               IPW_DEBUG_INFO("%s: Fatal error value: 0x%08X\n",
+                              priv->net_dev->name, priv->fatal_error);
+
+               read_nic_dword(dev, IPW_ERROR_ADDR(priv->fatal_error), &tmp);
+               IPW_DEBUG_INFO("%s: Fatal error address value: 0x%08X\n",
+                              priv->net_dev->name, tmp);
+
+               /* Wake up any sleeping jobs */
+               schedule_reset(priv);
+       }
+
+       if (inta & IPW2100_INTA_PARITY_ERROR) {
+               printk(KERN_ERR DRV_NAME ": ***** PARITY ERROR INTERRUPT !!!! \n");
+               priv->inta_other++;
+               write_register(
+                       dev, IPW_REG_INTA,
+                       IPW2100_INTA_PARITY_ERROR);
+       }
+
+       if (inta & IPW2100_INTA_RX_TRANSFER) {
+               IPW_DEBUG_ISR("RX interrupt\n");
+
+               priv->rx_interrupts++;
+
+               write_register(
+                       dev, IPW_REG_INTA,
+                       IPW2100_INTA_RX_TRANSFER);
+
+               __ipw2100_rx_process(priv);
+               __ipw2100_tx_complete(priv);
+       }
+
+       if (inta & IPW2100_INTA_TX_TRANSFER) {
+               IPW_DEBUG_ISR("TX interrupt\n");
+
+               priv->tx_interrupts++;
+
+               write_register(dev, IPW_REG_INTA,
+                              IPW2100_INTA_TX_TRANSFER);
+
+               __ipw2100_tx_complete(priv);
+               ipw2100_tx_send_commands(priv);
+               ipw2100_tx_send_data(priv);
+       }
+
+       if (inta & IPW2100_INTA_TX_COMPLETE) {
+               IPW_DEBUG_ISR("TX complete\n");
+               priv->inta_other++;
+               write_register(
+                       dev, IPW_REG_INTA,
+                       IPW2100_INTA_TX_COMPLETE);
+
+               __ipw2100_tx_complete(priv);
+       }
+
+       if (inta & IPW2100_INTA_EVENT_INTERRUPT) {
+               /* ipw2100_handle_event(dev); */
+               priv->inta_other++;
+               write_register(
+                       dev, IPW_REG_INTA,
+                       IPW2100_INTA_EVENT_INTERRUPT);
+       }
+
+       if (inta & IPW2100_INTA_FW_INIT_DONE) {
+               IPW_DEBUG_ISR("FW init done interrupt\n");
+               priv->inta_other++;
+
+               read_register(dev, IPW_REG_INTA, &tmp);
+               if (tmp & (IPW2100_INTA_FATAL_ERROR |
+                          IPW2100_INTA_PARITY_ERROR)) {
+                       write_register(
+                               dev, IPW_REG_INTA,
+                               IPW2100_INTA_FATAL_ERROR |
+                               IPW2100_INTA_PARITY_ERROR);
+               }
+
+               write_register(dev, IPW_REG_INTA,
+                              IPW2100_INTA_FW_INIT_DONE);
+       }
+
+       if (inta & IPW2100_INTA_STATUS_CHANGE) {
+               IPW_DEBUG_ISR("Status change interrupt\n");
+               priv->inta_other++;
+               write_register(
+                       dev, IPW_REG_INTA,
+                       IPW2100_INTA_STATUS_CHANGE);
+       }
+
+       if (inta & IPW2100_INTA_SLAVE_MODE_HOST_COMMAND_DONE) {
+               IPW_DEBUG_ISR("slave host mode interrupt\n");
+               priv->inta_other++;
+               write_register(
+                       dev, IPW_REG_INTA,
+                       IPW2100_INTA_SLAVE_MODE_HOST_COMMAND_DONE);
+       }
+
+       priv->in_isr--;
+       ipw2100_enable_interrupts(priv);
+
+       spin_unlock_irqrestore(&priv->low_lock, flags);
+
+       IPW_DEBUG_ISR("exit\n");
+}
+
+
+static irqreturn_t ipw2100_interrupt(int irq, void *data,
+                                    struct pt_regs *regs)
+{
+       struct ipw2100_priv *priv = data;
+       u32 inta, inta_mask;
+
+       if (!data)
+               return IRQ_NONE;
+
+       spin_lock(&priv->low_lock);
+
+       /* We check to see if we should be ignoring interrupts before
+        * we touch the hardware.  During ucode load if we try and handle
+        * an interrupt we can cause keyboard problems as well as cause
+        * the ucode to fail to initialize */
+       if (!(priv->status & STATUS_INT_ENABLED)) {
+               /* Shared IRQ */
+               goto none;
+       }
+
+       read_register(priv->net_dev, IPW_REG_INTA_MASK, &inta_mask);
+       read_register(priv->net_dev, IPW_REG_INTA, &inta);
+
+       if (inta == 0xFFFFFFFF) {
+               /* Hardware disappeared */
+               printk(KERN_WARNING DRV_NAME ": IRQ INTA == 0xFFFFFFFF\n");
+               goto none;
+       }
+
+       inta &= IPW_INTERRUPT_MASK;
+
+       if (!(inta & inta_mask)) {
+               /* Shared interrupt */
+               goto none;
+       }
+
+       /* We disable the hardware interrupt here just to prevent unneeded
+        * calls to be made.  We disable this again within the actual
+        * work tasklet, so if another part of the code re-enables the
+        * interrupt, that is fine */
+       ipw2100_disable_interrupts(priv);
+
+       tasklet_schedule(&priv->irq_tasklet);
+       spin_unlock(&priv->low_lock);
+
+       return IRQ_HANDLED;
+ none:
+       spin_unlock(&priv->low_lock);
+       return IRQ_NONE;
+}
+
+static int ipw2100_tx(struct ieee80211_txb *txb, struct net_device *dev)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       struct list_head *element;
+       struct ipw2100_tx_packet *packet;
+       unsigned long flags;
+
+       spin_lock_irqsave(&priv->low_lock, flags);
+
+       if (!(priv->status & STATUS_ASSOCIATED)) {
+               IPW_DEBUG_INFO("Can not transmit when not connected.\n");
+               priv->ieee->stats.tx_carrier_errors++;
+               netif_stop_queue(dev);
+               goto fail_unlock;
+       }
+
+       if (list_empty(&priv->tx_free_list))
+               goto fail_unlock;
+
+       element = priv->tx_free_list.next;
+       packet = list_entry(element, struct ipw2100_tx_packet, list);
+
+       packet->info.d_struct.txb = txb;
+
+       IPW_DEBUG_TX("Sending fragment (%d bytes):\n",
+                        txb->fragments[0]->len);
+       printk_buf(IPW_DL_TX, txb->fragments[0]->data,
+                  txb->fragments[0]->len);
+
+       packet->jiffy_start = jiffies;
+
+       list_del(element);
+       DEC_STAT(&priv->tx_free_stat);
+
+       list_add_tail(element, &priv->tx_pend_list);
+       INC_STAT(&priv->tx_pend_stat);
+
+       ipw2100_tx_send_data(priv);
+
+       spin_unlock_irqrestore(&priv->low_lock, flags);
+       return 0;
+
+ fail_unlock:
+       netif_stop_queue(dev);
+       spin_unlock_irqrestore(&priv->low_lock, flags);
+       return 1;
+}
+
+
+static int ipw2100_msg_allocate(struct ipw2100_priv *priv)
+{
+       int i, j, err = -EINVAL;
+       void *v;
+       dma_addr_t p;
+
+       priv->msg_buffers = (struct ipw2100_tx_packet *)kmalloc(
+               IPW_COMMAND_POOL_SIZE * sizeof(struct ipw2100_tx_packet),
+               GFP_KERNEL);
+       if (!priv->msg_buffers) {
+               printk(KERN_ERR DRV_NAME ": %s: PCI alloc failed for msg "
+                      "buffers.\n", priv->net_dev->name);
+               return -ENOMEM;
+       }
+
+       for (i = 0; i < IPW_COMMAND_POOL_SIZE; i++) {
+               v = pci_alloc_consistent(
+                       priv->pci_dev,
+                       sizeof(struct ipw2100_cmd_header),
+                       &p);
+               if (!v) {
+                       printk(KERN_ERR DRV_NAME ": "
+                              "%s: PCI alloc failed for msg "
+                              "buffers.\n",
+                              priv->net_dev->name);
+                       err = -ENOMEM;
+                       break;
+               }
+
+               memset(v, 0, sizeof(struct ipw2100_cmd_header));
+
+               priv->msg_buffers[i].type = COMMAND;
+               priv->msg_buffers[i].info.c_struct.cmd =
+                       (struct ipw2100_cmd_header*)v;
+               priv->msg_buffers[i].info.c_struct.cmd_phys = p;
+       }
+
+       if (i == IPW_COMMAND_POOL_SIZE)
+               return 0;
+
+       for (j = 0; j < i; j++) {
+               pci_free_consistent(
+                       priv->pci_dev,
+                       sizeof(struct ipw2100_cmd_header),
+                       priv->msg_buffers[j].info.c_struct.cmd,
+                       priv->msg_buffers[j].info.c_struct.cmd_phys);
+       }
+
+       kfree(priv->msg_buffers);
+       priv->msg_buffers = NULL;
+
+       return err;
+}
+
+static int ipw2100_msg_initialize(struct ipw2100_priv *priv)
+{
+       int i;
+
+       INIT_LIST_HEAD(&priv->msg_free_list);
+       INIT_LIST_HEAD(&priv->msg_pend_list);
+
+       for (i = 0; i < IPW_COMMAND_POOL_SIZE; i++)
+               list_add_tail(&priv->msg_buffers[i].list, &priv->msg_free_list);
+       SET_STAT(&priv->msg_free_stat, i);
+
+       return 0;
+}
+
+static void ipw2100_msg_free(struct ipw2100_priv *priv)
+{
+       int i;
+
+       if (!priv->msg_buffers)
+               return;
+
+       for (i = 0; i < IPW_COMMAND_POOL_SIZE; i++) {
+               pci_free_consistent(priv->pci_dev,
+                                   sizeof(struct ipw2100_cmd_header),
+                                   priv->msg_buffers[i].info.c_struct.cmd,
+                                   priv->msg_buffers[i].info.c_struct.cmd_phys);
+       }
+
+       kfree(priv->msg_buffers);
+       priv->msg_buffers = NULL;
+}
+
+static ssize_t show_pci(struct device *d, struct device_attribute *attr,
+                       char *buf)
+{
+       struct pci_dev *pci_dev = container_of(d, struct pci_dev, dev);
+       char *out = buf;
+       int i, j;
+       u32 val;
+
+       for (i = 0; i < 16; i++) {
+               out += sprintf(out, "[%08X] ", i * 16);
+               for (j = 0; j < 16; j += 4) {
+                       pci_read_config_dword(pci_dev, i * 16 + j, &val);
+                       out += sprintf(out, "%08X ", val);
+               }
+               out += sprintf(out, "\n");
+       }
+
+       return out - buf;
+}
+static DEVICE_ATTR(pci, S_IRUGO, show_pci, NULL);
+
+static ssize_t show_cfg(struct device *d, struct device_attribute *attr,
+                       char *buf)
+{
+       struct ipw2100_priv *p = d->driver_data;
+       return sprintf(buf, "0x%08x\n", (int)p->config);
+}
+static DEVICE_ATTR(cfg, S_IRUGO, show_cfg, NULL);
+
+static ssize_t show_status(struct device *d, struct device_attribute *attr,
+                       char *buf)
+{
+       struct ipw2100_priv *p = d->driver_data;
+       return sprintf(buf, "0x%08x\n", (int)p->status);
+}
+static DEVICE_ATTR(status, S_IRUGO, show_status, NULL);
+
+static ssize_t show_capability(struct device *d, struct device_attribute *attr,
+                               char *buf)
+{
+       struct ipw2100_priv *p = d->driver_data;
+       return sprintf(buf, "0x%08x\n", (int)p->capability);
+}
+static DEVICE_ATTR(capability, S_IRUGO, show_capability, NULL);
+
+
+#define IPW2100_REG(x) { IPW_ ##x, #x }
+static const struct {
+       u32 addr;
+       const char *name;
+} hw_data[] = {
+       IPW2100_REG(REG_GP_CNTRL),
+       IPW2100_REG(REG_GPIO),
+       IPW2100_REG(REG_INTA),
+       IPW2100_REG(REG_INTA_MASK),
+       IPW2100_REG(REG_RESET_REG),
+};
+#define IPW2100_NIC(x, s) { x, #x, s }
+static const struct {
+       u32 addr;
+       const char *name;
+       size_t size;
+} nic_data[] = {
+       IPW2100_NIC(IPW2100_CONTROL_REG, 2),
+       IPW2100_NIC(0x210014, 1),
+       IPW2100_NIC(0x210000, 1),
+};
+#define IPW2100_ORD(x, d) { IPW_ORD_ ##x, #x, d }
+static const struct {
+       u8 index;
+       const char *name;
+       const char *desc;
+} ord_data[] = {
+       IPW2100_ORD(STAT_TX_HOST_REQUESTS, "requested Host Tx's (MSDU)"),
+       IPW2100_ORD(STAT_TX_HOST_COMPLETE, "successful Host Tx's (MSDU)"),
+       IPW2100_ORD(STAT_TX_DIR_DATA,      "successful Directed Tx's (MSDU)"),
+       IPW2100_ORD(STAT_TX_DIR_DATA1,     "successful Directed Tx's (MSDU) @ 1MB"),
+       IPW2100_ORD(STAT_TX_DIR_DATA2,     "successful Directed Tx's (MSDU) @ 2MB"),
+       IPW2100_ORD(STAT_TX_DIR_DATA5_5,   "successful Directed Tx's (MSDU) @ 5_5MB"),
+       IPW2100_ORD(STAT_TX_DIR_DATA11,    "successful Directed Tx's (MSDU) @ 11MB"),
+       IPW2100_ORD(STAT_TX_NODIR_DATA1,   "successful Non_Directed Tx's (MSDU) @ 1MB"),
+       IPW2100_ORD(STAT_TX_NODIR_DATA2,   "successful Non_Directed Tx's (MSDU) @ 2MB"),
+       IPW2100_ORD(STAT_TX_NODIR_DATA5_5, "successful Non_Directed Tx's (MSDU) @ 5.5MB"),
+       IPW2100_ORD(STAT_TX_NODIR_DATA11,  "successful Non_Directed Tx's (MSDU) @ 11MB"),
+       IPW2100_ORD(STAT_NULL_DATA,        "successful NULL data Tx's"),
+       IPW2100_ORD(STAT_TX_RTS,           "successful Tx RTS"),
+       IPW2100_ORD(STAT_TX_CTS,           "successful Tx CTS"),
+       IPW2100_ORD(STAT_TX_ACK,           "successful Tx ACK"),
+       IPW2100_ORD(STAT_TX_ASSN,          "successful Association Tx's"),
+       IPW2100_ORD(STAT_TX_ASSN_RESP,     "successful Association response Tx's"),
+       IPW2100_ORD(STAT_TX_REASSN,        "successful Reassociation Tx's"),
+       IPW2100_ORD(STAT_TX_REASSN_RESP,   "successful Reassociation response Tx's"),
+       IPW2100_ORD(STAT_TX_PROBE,         "probes successfully transmitted"),
+       IPW2100_ORD(STAT_TX_PROBE_RESP,    "probe responses successfully transmitted"),
+       IPW2100_ORD(STAT_TX_BEACON,        "tx beacon"),
+       IPW2100_ORD(STAT_TX_ATIM,          "Tx ATIM"),
+       IPW2100_ORD(STAT_TX_DISASSN,       "successful Disassociation TX"),
+       IPW2100_ORD(STAT_TX_AUTH,          "successful Authentication Tx"),
+       IPW2100_ORD(STAT_TX_DEAUTH,        "successful Deauthentication TX"),
+       IPW2100_ORD(STAT_TX_TOTAL_BYTES,   "Total successful Tx data bytes"),
+       IPW2100_ORD(STAT_TX_RETRIES,       "Tx retries"),
+       IPW2100_ORD(STAT_TX_RETRY1,        "Tx retries at 1MBPS"),
+       IPW2100_ORD(STAT_TX_RETRY2,        "Tx retries at 2MBPS"),
+       IPW2100_ORD(STAT_TX_RETRY5_5,      "Tx retries at 5.5MBPS"),
+       IPW2100_ORD(STAT_TX_RETRY11,       "Tx retries at 11MBPS"),
+       IPW2100_ORD(STAT_TX_FAILURES,      "Tx Failures"),
+       IPW2100_ORD(STAT_TX_MAX_TRIES_IN_HOP,"times max tries in a hop failed"),
+       IPW2100_ORD(STAT_TX_DISASSN_FAIL,       "times disassociation failed"),
+       IPW2100_ORD(STAT_TX_ERR_CTS,         "missed/bad CTS frames"),
+       IPW2100_ORD(STAT_TX_ERR_ACK,    "tx err due to acks"),
+       IPW2100_ORD(STAT_RX_HOST,       "packets passed to host"),
+       IPW2100_ORD(STAT_RX_DIR_DATA,   "directed packets"),
+       IPW2100_ORD(STAT_RX_DIR_DATA1,  "directed packets at 1MB"),
+       IPW2100_ORD(STAT_RX_DIR_DATA2,  "directed packets at 2MB"),
+       IPW2100_ORD(STAT_RX_DIR_DATA5_5,        "directed packets at 5.5MB"),
+       IPW2100_ORD(STAT_RX_DIR_DATA11, "directed packets at 11MB"),
+       IPW2100_ORD(STAT_RX_NODIR_DATA,"nondirected packets"),
+       IPW2100_ORD(STAT_RX_NODIR_DATA1,        "nondirected packets at 1MB"),
+       IPW2100_ORD(STAT_RX_NODIR_DATA2,        "nondirected packets at 2MB"),
+       IPW2100_ORD(STAT_RX_NODIR_DATA5_5,      "nondirected packets at 5.5MB"),
+       IPW2100_ORD(STAT_RX_NODIR_DATA11,       "nondirected packets at 11MB"),
+       IPW2100_ORD(STAT_RX_NULL_DATA,  "null data rx's"),
+       IPW2100_ORD(STAT_RX_RTS,        "Rx RTS"),
+       IPW2100_ORD(STAT_RX_CTS,        "Rx CTS"),
+       IPW2100_ORD(STAT_RX_ACK,        "Rx ACK"),
+       IPW2100_ORD(STAT_RX_CFEND,      "Rx CF End"),
+       IPW2100_ORD(STAT_RX_CFEND_ACK,  "Rx CF End + CF Ack"),
+       IPW2100_ORD(STAT_RX_ASSN,       "Association Rx's"),
+       IPW2100_ORD(STAT_RX_ASSN_RESP,  "Association response Rx's"),
+       IPW2100_ORD(STAT_RX_REASSN,     "Reassociation Rx's"),
+       IPW2100_ORD(STAT_RX_REASSN_RESP,        "Reassociation response Rx's"),
+       IPW2100_ORD(STAT_RX_PROBE,      "probe Rx's"),
+       IPW2100_ORD(STAT_RX_PROBE_RESP, "probe response Rx's"),
+       IPW2100_ORD(STAT_RX_BEACON,     "Rx beacon"),
+       IPW2100_ORD(STAT_RX_ATIM,       "Rx ATIM"),
+       IPW2100_ORD(STAT_RX_DISASSN,    "disassociation Rx"),
+       IPW2100_ORD(STAT_RX_AUTH,       "authentication Rx"),
+       IPW2100_ORD(STAT_RX_DEAUTH,     "deauthentication Rx"),
+       IPW2100_ORD(STAT_RX_TOTAL_BYTES,"Total rx data bytes received"),
+       IPW2100_ORD(STAT_RX_ERR_CRC,     "packets with Rx CRC error"),
+       IPW2100_ORD(STAT_RX_ERR_CRC1,    "Rx CRC errors at 1MB"),
+       IPW2100_ORD(STAT_RX_ERR_CRC2,    "Rx CRC errors at 2MB"),
+       IPW2100_ORD(STAT_RX_ERR_CRC5_5,  "Rx CRC errors at 5.5MB"),
+       IPW2100_ORD(STAT_RX_ERR_CRC11,   "Rx CRC errors at 11MB"),
+       IPW2100_ORD(STAT_RX_DUPLICATE1, "duplicate rx packets at 1MB"),
+       IPW2100_ORD(STAT_RX_DUPLICATE2,  "duplicate rx packets at 2MB"),
+       IPW2100_ORD(STAT_RX_DUPLICATE5_5,        "duplicate rx packets at 5.5MB"),
+       IPW2100_ORD(STAT_RX_DUPLICATE11,         "duplicate rx packets at 11MB"),
+       IPW2100_ORD(STAT_RX_DUPLICATE, "duplicate rx packets"),
+       IPW2100_ORD(PERS_DB_LOCK,       "locking fw permanent  db"),
+       IPW2100_ORD(PERS_DB_SIZE,       "size of fw permanent  db"),
+       IPW2100_ORD(PERS_DB_ADDR,       "address of fw permanent  db"),
+       IPW2100_ORD(STAT_RX_INVALID_PROTOCOL,   "rx frames with invalid protocol"),
+       IPW2100_ORD(SYS_BOOT_TIME,      "Boot time"),
+       IPW2100_ORD(STAT_RX_NO_BUFFER,  "rx frames rejected due to no buffer"),
+       IPW2100_ORD(STAT_RX_MISSING_FRAG,       "rx frames dropped due to missing fragment"),
+       IPW2100_ORD(STAT_RX_ORPHAN_FRAG,        "rx frames dropped due to non-sequential fragment"),
+       IPW2100_ORD(STAT_RX_ORPHAN_FRAME,       "rx frames dropped due to unmatched 1st frame"),
+       IPW2100_ORD(STAT_RX_FRAG_AGEOUT,        "rx frames dropped due to uncompleted frame"),
+       IPW2100_ORD(STAT_RX_ICV_ERRORS, "ICV errors during decryption"),
+       IPW2100_ORD(STAT_PSP_SUSPENSION,"times adapter suspended"),
+       IPW2100_ORD(STAT_PSP_BCN_TIMEOUT,       "beacon timeout"),
+       IPW2100_ORD(STAT_PSP_POLL_TIMEOUT,      "poll response timeouts"),
+       IPW2100_ORD(STAT_PSP_NONDIR_TIMEOUT, "timeouts waiting for last {broad,multi}cast pkt"),
+       IPW2100_ORD(STAT_PSP_RX_DTIMS,  "PSP DTIMs received"),
+       IPW2100_ORD(STAT_PSP_RX_TIMS,   "PSP TIMs received"),
+       IPW2100_ORD(STAT_PSP_STATION_ID,"PSP Station ID"),
+       IPW2100_ORD(LAST_ASSN_TIME,     "RTC time of last association"),
+       IPW2100_ORD(STAT_PERCENT_MISSED_BCNS,"current calculation of % missed beacons"),
+       IPW2100_ORD(STAT_PERCENT_RETRIES,"current calculation of % missed tx retries"),
+       IPW2100_ORD(ASSOCIATED_AP_PTR,  "0 if not associated, else pointer to AP table entry"),
+       IPW2100_ORD(AVAILABLE_AP_CNT,   "AP's decsribed in the AP table"),
+       IPW2100_ORD(AP_LIST_PTR,        "Ptr to list of available APs"),
+       IPW2100_ORD(STAT_AP_ASSNS,      "associations"),
+       IPW2100_ORD(STAT_ASSN_FAIL,     "association failures"),
+       IPW2100_ORD(STAT_ASSN_RESP_FAIL,"failures due to response fail"),
+       IPW2100_ORD(STAT_FULL_SCANS,    "full scans"),
+       IPW2100_ORD(CARD_DISABLED,      "Card Disabled"),
+       IPW2100_ORD(STAT_ROAM_INHIBIT,  "times roaming was inhibited due to activity"),
+       IPW2100_ORD(RSSI_AT_ASSN,       "RSSI of associated AP at time of association"),
+       IPW2100_ORD(STAT_ASSN_CAUSE1,   "reassociation: no probe response or TX on hop"),
+       IPW2100_ORD(STAT_ASSN_CAUSE2,   "reassociation: poor tx/rx quality"),
+       IPW2100_ORD(STAT_ASSN_CAUSE3,   "reassociation: tx/rx quality (excessive AP load"),
+       IPW2100_ORD(STAT_ASSN_CAUSE4,   "reassociation: AP RSSI level"),
+       IPW2100_ORD(STAT_ASSN_CAUSE5,   "reassociations due to load leveling"),
+       IPW2100_ORD(STAT_AUTH_FAIL,     "times authentication failed"),
+       IPW2100_ORD(STAT_AUTH_RESP_FAIL,"times authentication response failed"),
+       IPW2100_ORD(STATION_TABLE_CNT,  "entries in association table"),
+       IPW2100_ORD(RSSI_AVG_CURR,      "Current avg RSSI"),
+       IPW2100_ORD(POWER_MGMT_MODE,    "Power mode - 0=CAM, 1=PSP"),
+       IPW2100_ORD(COUNTRY_CODE,       "IEEE country code as recv'd from beacon"),
+       IPW2100_ORD(COUNTRY_CHANNELS,   "channels suported by country"),
+       IPW2100_ORD(RESET_CNT,  "adapter resets (warm)"),
+       IPW2100_ORD(BEACON_INTERVAL,    "Beacon interval"),
+       IPW2100_ORD(ANTENNA_DIVERSITY,  "TRUE if antenna diversity is disabled"),
+       IPW2100_ORD(DTIM_PERIOD,        "beacon intervals between DTIMs"),
+       IPW2100_ORD(OUR_FREQ,   "current radio freq lower digits - channel ID"),
+       IPW2100_ORD(RTC_TIME,   "current RTC time"),
+       IPW2100_ORD(PORT_TYPE,  "operating mode"),
+       IPW2100_ORD(CURRENT_TX_RATE,    "current tx rate"),
+       IPW2100_ORD(SUPPORTED_RATES,    "supported tx rates"),
+       IPW2100_ORD(ATIM_WINDOW,        "current ATIM Window"),
+       IPW2100_ORD(BASIC_RATES,        "basic tx rates"),
+       IPW2100_ORD(NIC_HIGHEST_RATE,   "NIC highest tx rate"),
+       IPW2100_ORD(AP_HIGHEST_RATE,    "AP highest tx rate"),
+       IPW2100_ORD(CAPABILITIES,       "Management frame capability field"),
+       IPW2100_ORD(AUTH_TYPE,  "Type of authentication"),
+       IPW2100_ORD(RADIO_TYPE, "Adapter card platform type"),
+       IPW2100_ORD(RTS_THRESHOLD,      "Min packet length for RTS handshaking"),
+       IPW2100_ORD(INT_MODE,   "International mode"),
+       IPW2100_ORD(FRAGMENTATION_THRESHOLD,    "protocol frag threshold"),
+       IPW2100_ORD(EEPROM_SRAM_DB_BLOCK_START_ADDRESS, "EEPROM offset in SRAM"),
+       IPW2100_ORD(EEPROM_SRAM_DB_BLOCK_SIZE,  "EEPROM size in SRAM"),
+       IPW2100_ORD(EEPROM_SKU_CAPABILITY,      "EEPROM SKU Capability"),
+       IPW2100_ORD(EEPROM_IBSS_11B_CHANNELS,   "EEPROM IBSS 11b channel set"),
+       IPW2100_ORD(MAC_VERSION,        "MAC Version"),
+       IPW2100_ORD(MAC_REVISION,       "MAC Revision"),
+       IPW2100_ORD(RADIO_VERSION,      "Radio Version"),
+       IPW2100_ORD(NIC_MANF_DATE_TIME, "MANF Date/Time STAMP"),
+       IPW2100_ORD(UCODE_VERSION,      "Ucode Version"),
+};
+
+
+static ssize_t show_registers(struct device *d, struct device_attribute *attr,
+                               char *buf)
+{
+       int i;
+       struct ipw2100_priv *priv = dev_get_drvdata(d);
+       struct net_device *dev = priv->net_dev;
+       char * out = buf;
+       u32 val = 0;
+
+       out += sprintf(out, "%30s [Address ] : Hex\n", "Register");
+
+       for (i = 0; i < (sizeof(hw_data) / sizeof(*hw_data)); i++) {
+               read_register(dev, hw_data[i].addr, &val);
+               out += sprintf(out, "%30s [%08X] : %08X\n",
+                              hw_data[i].name, hw_data[i].addr, val);
+       }
+
+       return out - buf;
+}
+static DEVICE_ATTR(registers, S_IRUGO, show_registers, NULL);
+
+
+static ssize_t show_hardware(struct device *d, struct device_attribute *attr,
+                               char *buf)
+{
+       struct ipw2100_priv *priv = dev_get_drvdata(d);
+       struct net_device *dev = priv->net_dev;
+       char * out = buf;
+       int i;
+
+       out += sprintf(out, "%30s [Address ] : Hex\n", "NIC entry");
+
+       for (i = 0; i < (sizeof(nic_data) / sizeof(*nic_data)); i++) {
+               u8 tmp8;
+               u16 tmp16;
+               u32 tmp32;
+
+               switch (nic_data[i].size) {
+               case 1:
+                       read_nic_byte(dev, nic_data[i].addr, &tmp8);
+                       out += sprintf(out, "%30s [%08X] : %02X\n",
+                                      nic_data[i].name, nic_data[i].addr,
+                                      tmp8);
+                       break;
+               case 2:
+                       read_nic_word(dev, nic_data[i].addr, &tmp16);
+                       out += sprintf(out, "%30s [%08X] : %04X\n",
+                                      nic_data[i].name, nic_data[i].addr,
+                                      tmp16);
+                       break;
+               case 4:
+                       read_nic_dword(dev, nic_data[i].addr, &tmp32);
+                       out += sprintf(out, "%30s [%08X] : %08X\n",
+                                      nic_data[i].name, nic_data[i].addr,
+                                      tmp32);
+                       break;
+               }
+       }
+       return out - buf;
+}
+static DEVICE_ATTR(hardware, S_IRUGO, show_hardware, NULL);
+
+
+static ssize_t show_memory(struct device *d, struct device_attribute *attr,
+                               char *buf)
+{
+       struct ipw2100_priv *priv = dev_get_drvdata(d);
+       struct net_device *dev = priv->net_dev;
+       static unsigned long loop = 0;
+       int len = 0;
+       u32 buffer[4];
+       int i;
+       char line[81];
+
+       if (loop >= 0x30000)
+               loop = 0;
+
+       /* sysfs provides us PAGE_SIZE buffer */
+       while (len < PAGE_SIZE - 128 && loop < 0x30000) {
+
+               if (priv->snapshot[0]) for (i = 0; i < 4; i++)
+                       buffer[i] = *(u32 *)SNAPSHOT_ADDR(loop + i * 4);
+               else for (i = 0; i < 4; i++)
+                       read_nic_dword(dev, loop + i * 4, &buffer[i]);
+
+               if (priv->dump_raw)
+                       len += sprintf(buf + len,
+                                      "%c%c%c%c"
+                                      "%c%c%c%c"
+                                      "%c%c%c%c"
+                                      "%c%c%c%c",
+                                      ((u8*)buffer)[0x0],
+                                      ((u8*)buffer)[0x1],
+                                      ((u8*)buffer)[0x2],
+                                      ((u8*)buffer)[0x3],
+                                      ((u8*)buffer)[0x4],
+                                      ((u8*)buffer)[0x5],
+                                      ((u8*)buffer)[0x6],
+                                      ((u8*)buffer)[0x7],
+                                      ((u8*)buffer)[0x8],
+                                      ((u8*)buffer)[0x9],
+                                      ((u8*)buffer)[0xa],
+                                      ((u8*)buffer)[0xb],
+                                      ((u8*)buffer)[0xc],
+                                      ((u8*)buffer)[0xd],
+                                      ((u8*)buffer)[0xe],
+                                      ((u8*)buffer)[0xf]);
+               else
+                       len += sprintf(buf + len, "%s\n",
+                                      snprint_line(line, sizeof(line),
+                                                   (u8*)buffer, 16, loop));
+               loop += 16;
+       }
+
+       return len;
+}
+
+static ssize_t store_memory(struct device *d, struct device_attribute *attr,
+                               const char *buf, size_t count)
+{
+       struct ipw2100_priv *priv = dev_get_drvdata(d);
+       struct net_device *dev = priv->net_dev;
+       const char *p = buf;
+
+       if (count < 1)
+               return count;
+
+       if (p[0] == '1' ||
+           (count >= 2 && tolower(p[0]) == 'o' && tolower(p[1]) == 'n')) {
+               IPW_DEBUG_INFO("%s: Setting memory dump to RAW mode.\n",
+                      dev->name);
+               priv->dump_raw = 1;
+
+       } else if (p[0] == '0' || (count >= 2 && tolower(p[0]) == 'o' &&
+                                 tolower(p[1]) == 'f')) {
+               IPW_DEBUG_INFO("%s: Setting memory dump to HEX mode.\n",
+                      dev->name);
+               priv->dump_raw = 0;
+
+       } else if (tolower(p[0]) == 'r') {
+               IPW_DEBUG_INFO("%s: Resetting firmware snapshot.\n",
+                      dev->name);
+               ipw2100_snapshot_free(priv);
+
+       } else
+               IPW_DEBUG_INFO("%s: Usage: 0|on = HEX, 1|off = RAW, "
+                      "reset = clear memory snapshot\n",
+                      dev->name);
+
+       return count;
+}
+static DEVICE_ATTR(memory, S_IWUSR|S_IRUGO, show_memory, store_memory);
+
+
+static ssize_t show_ordinals(struct device *d, struct device_attribute *attr,
+                               char *buf)
+{
+       struct ipw2100_priv *priv = dev_get_drvdata(d);
+       u32 val = 0;
+       int len = 0;
+       u32 val_len;
+       static int loop = 0;
+
+       if (loop >= sizeof(ord_data) / sizeof(*ord_data))
+               loop = 0;
+
+       /* sysfs provides us PAGE_SIZE buffer */
+       while (len < PAGE_SIZE - 128 &&
+              loop < (sizeof(ord_data) / sizeof(*ord_data))) {
+
+               val_len = sizeof(u32);
+
+               if (ipw2100_get_ordinal(priv, ord_data[loop].index, &val,
+                                       &val_len))
+                       len += sprintf(buf + len, "[0x%02X] = ERROR    %s\n",
+                                      ord_data[loop].index,
+                                      ord_data[loop].desc);
+               else
+                       len += sprintf(buf + len, "[0x%02X] = 0x%08X %s\n",
+                                      ord_data[loop].index, val,
+                                      ord_data[loop].desc);
+               loop++;
+       }
+
+       return len;
+}
+static DEVICE_ATTR(ordinals, S_IRUGO, show_ordinals, NULL);
+
+
+static ssize_t show_stats(struct device *d, struct device_attribute *attr,
+                               char *buf)
+{
+       struct ipw2100_priv *priv = dev_get_drvdata(d);
+       char * out = buf;
+
+       out += sprintf(out, "interrupts: %d {tx: %d, rx: %d, other: %d}\n",
+                      priv->interrupts, priv->tx_interrupts,
+                      priv->rx_interrupts, priv->inta_other);
+       out += sprintf(out, "firmware resets: %d\n", priv->resets);
+       out += sprintf(out, "firmware hangs: %d\n", priv->hangs);
+#ifdef CONFIG_IPW_DEBUG
+       out += sprintf(out, "packet mismatch image: %s\n",
+                      priv->snapshot[0] ? "YES" : "NO");
+#endif
+
+       return out - buf;
+}
+static DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL);
+
+
+static int ipw2100_switch_mode(struct ipw2100_priv *priv, u32 mode)
+{
+       int err;
+
+       if (mode == priv->ieee->iw_mode)
+               return 0;
+
+       err = ipw2100_disable_adapter(priv);
+       if (err) {
+               printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n",
+                      priv->net_dev->name, err);
+               return err;
+       }
+
+       switch (mode) {
+       case IW_MODE_INFRA:
+               priv->net_dev->type = ARPHRD_ETHER;
+               break;
+       case IW_MODE_ADHOC:
+               priv->net_dev->type = ARPHRD_ETHER;
+               break;
+#ifdef CONFIG_IPW2100_MONITOR
+       case IW_MODE_MONITOR:
+               priv->last_mode = priv->ieee->iw_mode;
+               priv->net_dev->type = ARPHRD_IEEE80211;
+               break;
+#endif /* CONFIG_IPW2100_MONITOR */
+       }
+
+       priv->ieee->iw_mode = mode;
+
+#ifdef CONFIG_PM
+        /* Indicate ipw2100_download_firmware download firmware
+        * from disk instead of memory. */
+       ipw2100_firmware.version = 0;
+#endif
+
+       printk(KERN_INFO "%s: Reseting on mode change.\n",
+               priv->net_dev->name);
+       priv->reset_backoff = 0;
+       schedule_reset(priv);
+
+       return 0;
+}
+
+static ssize_t show_internals(struct device *d, struct device_attribute *attr,
+                               char *buf)
+{
+       struct ipw2100_priv *priv = dev_get_drvdata(d);
+       int len = 0;
+
+#define DUMP_VAR(x,y) len += sprintf(buf + len, # x ": %" # y "\n", priv-> x)
+
+       if (priv->status & STATUS_ASSOCIATED)
+               len += sprintf(buf + len, "connected: %lu\n",
+                              get_seconds() - priv->connect_start);
+       else
+               len += sprintf(buf + len, "not connected\n");
+
+       DUMP_VAR(ieee->crypt[priv->ieee->tx_keyidx], p);
+       DUMP_VAR(status, 08lx);
+       DUMP_VAR(config, 08lx);
+       DUMP_VAR(capability, 08lx);
+
+       len += sprintf(buf + len, "last_rtc: %lu\n", (unsigned long)priv->last_rtc);
+
+       DUMP_VAR(fatal_error, d);
+       DUMP_VAR(stop_hang_check, d);
+       DUMP_VAR(stop_rf_kill, d);
+       DUMP_VAR(messages_sent, d);
+
+       DUMP_VAR(tx_pend_stat.value, d);
+       DUMP_VAR(tx_pend_stat.hi, d);
+
+       DUMP_VAR(tx_free_stat.value, d);
+       DUMP_VAR(tx_free_stat.lo, d);
+
+       DUMP_VAR(msg_free_stat.value, d);
+       DUMP_VAR(msg_free_stat.lo, d);
+
+       DUMP_VAR(msg_pend_stat.value, d);
+       DUMP_VAR(msg_pend_stat.hi, d);
+
+       DUMP_VAR(fw_pend_stat.value, d);
+       DUMP_VAR(fw_pend_stat.hi, d);
+
+       DUMP_VAR(txq_stat.value, d);
+       DUMP_VAR(txq_stat.lo, d);
+
+       DUMP_VAR(ieee->scans, d);
+       DUMP_VAR(reset_backoff, d);
+
+       return len;
+}
+static DEVICE_ATTR(internals, S_IRUGO, show_internals, NULL);
+
+
+static ssize_t show_bssinfo(struct device *d, struct device_attribute *attr,
+                               char *buf)
+{
+       struct ipw2100_priv *priv = dev_get_drvdata(d);
+       char essid[IW_ESSID_MAX_SIZE + 1];
+       u8 bssid[ETH_ALEN];
+       u32 chan = 0;
+       char * out = buf;
+       int length;
+       int ret;
+
+       memset(essid, 0, sizeof(essid));
+       memset(bssid, 0, sizeof(bssid));
+
+       length = IW_ESSID_MAX_SIZE;
+       ret = ipw2100_get_ordinal(priv, IPW_ORD_STAT_ASSN_SSID, essid, &length);
+       if (ret)
+               IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
+                              __LINE__);
+
+       length = sizeof(bssid);
+       ret = ipw2100_get_ordinal(priv, IPW_ORD_STAT_ASSN_AP_BSSID,
+                                 bssid, &length);
+       if (ret)
+               IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
+                              __LINE__);
+
+       length = sizeof(u32);
+       ret = ipw2100_get_ordinal(priv, IPW_ORD_OUR_FREQ, &chan, &length);
+       if (ret)
+               IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
+                              __LINE__);
+
+       out += sprintf(out, "ESSID: %s\n", essid);
+       out += sprintf(out, "BSSID:   %02x:%02x:%02x:%02x:%02x:%02x\n",
+                      bssid[0], bssid[1], bssid[2],
+                      bssid[3], bssid[4], bssid[5]);
+       out += sprintf(out, "Channel: %d\n", chan);
+
+       return out - buf;
+}
+static DEVICE_ATTR(bssinfo, S_IRUGO, show_bssinfo, NULL);
+
+
+#ifdef CONFIG_IPW_DEBUG
+static ssize_t show_debug_level(struct device_driver *d, char *buf)
+{
+       return sprintf(buf, "0x%08X\n", ipw2100_debug_level);
+}
+
+static ssize_t store_debug_level(struct device_driver *d, const char *buf,
+                                size_t count)
+{
+       char *p = (char *)buf;
+       u32 val;
+
+       if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
+               p++;
+               if (p[0] == 'x' || p[0] == 'X')
+                       p++;
+               val = simple_strtoul(p, &p, 16);
+       } else
+               val = simple_strtoul(p, &p, 10);
+       if (p == buf)
+               IPW_DEBUG_INFO(DRV_NAME
+                      ": %s is not in hex or decimal form.\n", buf);
+       else
+               ipw2100_debug_level = val;
+
+       return strnlen(buf, count);
+}
+static DRIVER_ATTR(debug_level, S_IWUSR | S_IRUGO, show_debug_level,
+                  store_debug_level);
+#endif /* CONFIG_IPW_DEBUG */
+
+
+static ssize_t show_fatal_error(struct device *d,
+                       struct device_attribute *attr, char *buf)
+{
+       struct ipw2100_priv *priv = dev_get_drvdata(d);
+       char *out = buf;
+       int i;
+
+       if (priv->fatal_error)
+               out += sprintf(out, "0x%08X\n",
+                              priv->fatal_error);
+       else
+               out += sprintf(out, "0\n");
+
+       for (i = 1; i <= IPW2100_ERROR_QUEUE; i++) {
+               if (!priv->fatal_errors[(priv->fatal_index - i) %
+                                       IPW2100_ERROR_QUEUE])
+                       continue;
+
+               out += sprintf(out, "%d. 0x%08X\n", i,
+                              priv->fatal_errors[(priv->fatal_index - i) %
+                                                 IPW2100_ERROR_QUEUE]);
+       }
+
+       return out - buf;
+}
+
+static ssize_t store_fatal_error(struct device *d,
+               struct device_attribute *attr, const char *buf, size_t count)
+{
+       struct ipw2100_priv *priv = dev_get_drvdata(d);
+       schedule_reset(priv);
+       return count;
+}
+static DEVICE_ATTR(fatal_error, S_IWUSR|S_IRUGO, show_fatal_error, store_fatal_error);
+
+
+static ssize_t show_scan_age(struct device *d, struct device_attribute *attr,
+                               char *buf)
+{
+       struct ipw2100_priv *priv = dev_get_drvdata(d);
+       return sprintf(buf, "%d\n", priv->ieee->scan_age);
+}
+
+static ssize_t store_scan_age(struct device *d, struct device_attribute *attr,
+                               const char *buf, size_t count)
+{
+       struct ipw2100_priv *priv = dev_get_drvdata(d);
+       struct net_device *dev = priv->net_dev;
+       char buffer[] = "00000000";
+       unsigned long len =
+           (sizeof(buffer) - 1) > count ? count : sizeof(buffer) - 1;
+       unsigned long val;
+       char *p = buffer;
+
+       IPW_DEBUG_INFO("enter\n");
+
+       strncpy(buffer, buf, len);
+       buffer[len] = 0;
+
+       if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
+               p++;
+               if (p[0] == 'x' || p[0] == 'X')
+                       p++;
+               val = simple_strtoul(p, &p, 16);
+       } else
+               val = simple_strtoul(p, &p, 10);
+       if (p == buffer) {
+               IPW_DEBUG_INFO("%s: user supplied invalid value.\n",
+                      dev->name);
+       } else {
+               priv->ieee->scan_age = val;
+               IPW_DEBUG_INFO("set scan_age = %u\n", priv->ieee->scan_age);
+       }
+
+       IPW_DEBUG_INFO("exit\n");
+       return len;
+}
+static DEVICE_ATTR(scan_age, S_IWUSR | S_IRUGO, show_scan_age, store_scan_age);
+
+
+static ssize_t show_rf_kill(struct device *d, struct device_attribute *attr,
+                               char *buf)
+{
+       /* 0 - RF kill not enabled
+          1 - SW based RF kill active (sysfs)
+          2 - HW based RF kill active
+          3 - Both HW and SW baed RF kill active */
+       struct ipw2100_priv *priv = (struct ipw2100_priv *)d->driver_data;
+       int val = ((priv->status & STATUS_RF_KILL_SW) ? 0x1 : 0x0) |
+               (rf_kill_active(priv) ? 0x2 : 0x0);
+       return sprintf(buf, "%i\n", val);
+}
+
+static int ipw_radio_kill_sw(struct ipw2100_priv *priv, int disable_radio)
+{
+       if ((disable_radio ? 1 : 0) ==
+           (priv->status & STATUS_RF_KILL_SW ? 1 : 0))
+               return 0 ;
+
+       IPW_DEBUG_RF_KILL("Manual SW RF Kill set to: RADIO  %s\n",
+                         disable_radio ? "OFF" : "ON");
+
+       down(&priv->action_sem);
+
+       if (disable_radio) {
+               priv->status |= STATUS_RF_KILL_SW;
+               ipw2100_down(priv);
+       } else {
+               priv->status &= ~STATUS_RF_KILL_SW;
+               if (rf_kill_active(priv)) {
+                       IPW_DEBUG_RF_KILL("Can not turn radio back on - "
+                                         "disabled by HW switch\n");
+                       /* Make sure the RF_KILL check timer is running */
+                       priv->stop_rf_kill = 0;
+                       cancel_delayed_work(&priv->rf_kill);
+                       queue_delayed_work(priv->workqueue, &priv->rf_kill,
+                                          HZ);
+               } else
+                       schedule_reset(priv);
+       }
+
+       up(&priv->action_sem);
+       return 1;
+}
+
+static ssize_t store_rf_kill(struct device *d, struct device_attribute *attr,
+                               const char *buf, size_t count)
+{
+       struct ipw2100_priv *priv = dev_get_drvdata(d);
+       ipw_radio_kill_sw(priv, buf[0] == '1');
+       return count;
+}
+static DEVICE_ATTR(rf_kill, S_IWUSR|S_IRUGO, show_rf_kill, store_rf_kill);
+
+
+static struct attribute *ipw2100_sysfs_entries[] = {
+       &dev_attr_hardware.attr,
+       &dev_attr_registers.attr,
+       &dev_attr_ordinals.attr,
+       &dev_attr_pci.attr,
+       &dev_attr_stats.attr,
+       &dev_attr_internals.attr,
+       &dev_attr_bssinfo.attr,
+       &dev_attr_memory.attr,
+       &dev_attr_scan_age.attr,
+       &dev_attr_fatal_error.attr,
+       &dev_attr_rf_kill.attr,
+       &dev_attr_cfg.attr,
+       &dev_attr_status.attr,
+       &dev_attr_capability.attr,
+       NULL,
+};
+
+static struct attribute_group ipw2100_attribute_group = {
+       .attrs = ipw2100_sysfs_entries,
+};
+
+
+static int status_queue_allocate(struct ipw2100_priv *priv, int entries)
+{
+       struct ipw2100_status_queue *q = &priv->status_queue;
+
+       IPW_DEBUG_INFO("enter\n");
+
+       q->size = entries * sizeof(struct ipw2100_status);
+       q->drv = (struct ipw2100_status *)pci_alloc_consistent(
+               priv->pci_dev, q->size, &q->nic);
+       if (!q->drv) {
+               IPW_DEBUG_WARNING(
+                      "Can not allocate status queue.\n");
+               return -ENOMEM;
+       }
+
+       memset(q->drv, 0, q->size);
+
+       IPW_DEBUG_INFO("exit\n");
+
+       return 0;
+}
+
+static void status_queue_free(struct ipw2100_priv *priv)
+{
+       IPW_DEBUG_INFO("enter\n");
+
+       if (priv->status_queue.drv) {
+               pci_free_consistent(
+                       priv->pci_dev, priv->status_queue.size,
+                       priv->status_queue.drv, priv->status_queue.nic);
+               priv->status_queue.drv = NULL;
+       }
+
+       IPW_DEBUG_INFO("exit\n");
+}
+
+static int bd_queue_allocate(struct ipw2100_priv *priv,
+                            struct ipw2100_bd_queue *q, int entries)
+{
+       IPW_DEBUG_INFO("enter\n");
+
+       memset(q, 0, sizeof(struct ipw2100_bd_queue));
+
+       q->entries = entries;
+       q->size = entries * sizeof(struct ipw2100_bd);
+       q->drv = pci_alloc_consistent(priv->pci_dev, q->size, &q->nic);
+       if (!q->drv) {
+               IPW_DEBUG_INFO("can't allocate shared memory for buffer descriptors\n");
+               return -ENOMEM;
+       }
+       memset(q->drv, 0, q->size);
+
+       IPW_DEBUG_INFO("exit\n");
+
+       return 0;
+}
+
+static void bd_queue_free(struct ipw2100_priv *priv,
+                         struct ipw2100_bd_queue *q)
+{
+       IPW_DEBUG_INFO("enter\n");
+
+       if (!q)
+               return;
+
+       if (q->drv) {
+               pci_free_consistent(priv->pci_dev,
+                                   q->size, q->drv, q->nic);
+               q->drv = NULL;
+       }
+
+       IPW_DEBUG_INFO("exit\n");
+}
+
+static void bd_queue_initialize(
+       struct ipw2100_priv *priv, struct ipw2100_bd_queue * q,
+       u32 base, u32 size, u32 r, u32 w)
+{
+       IPW_DEBUG_INFO("enter\n");
+
+       IPW_DEBUG_INFO("initializing bd queue at virt=%p, phys=%08x\n", q->drv, (u32)q->nic);
+
+       write_register(priv->net_dev, base, q->nic);
+       write_register(priv->net_dev, size, q->entries);
+       write_register(priv->net_dev, r, q->oldest);
+       write_register(priv->net_dev, w, q->next);
+
+       IPW_DEBUG_INFO("exit\n");
+}
+
+static void ipw2100_kill_workqueue(struct ipw2100_priv *priv)
+{
+       if (priv->workqueue) {
+               priv->stop_rf_kill = 1;
+               priv->stop_hang_check = 1;
+               cancel_delayed_work(&priv->reset_work);
+               cancel_delayed_work(&priv->security_work);
+               cancel_delayed_work(&priv->wx_event_work);
+               cancel_delayed_work(&priv->hang_check);
+               cancel_delayed_work(&priv->rf_kill);
+               destroy_workqueue(priv->workqueue);
+               priv->workqueue = NULL;
+       }
+}
+
+static int ipw2100_tx_allocate(struct ipw2100_priv *priv)
+{
+       int i, j, err = -EINVAL;
+       void *v;
+       dma_addr_t p;
+
+       IPW_DEBUG_INFO("enter\n");
+
+       err = bd_queue_allocate(priv, &priv->tx_queue, TX_QUEUE_LENGTH);
+       if (err) {
+               IPW_DEBUG_ERROR("%s: failed bd_queue_allocate\n",
+                      priv->net_dev->name);
+               return err;
+       }
+
+       priv->tx_buffers = (struct ipw2100_tx_packet *)kmalloc(
+               TX_PENDED_QUEUE_LENGTH * sizeof(struct ipw2100_tx_packet),
+               GFP_ATOMIC);
+       if (!priv->tx_buffers) {
+               printk(KERN_ERR DRV_NAME ": %s: alloc failed form tx buffers.\n",
+                      priv->net_dev->name);
+               bd_queue_free(priv, &priv->tx_queue);
+               return -ENOMEM;
+       }
+
+       for (i = 0; i < TX_PENDED_QUEUE_LENGTH; i++) {
+               v = pci_alloc_consistent(
+                       priv->pci_dev, sizeof(struct ipw2100_data_header), &p);
+               if (!v) {
+                       printk(KERN_ERR DRV_NAME ": %s: PCI alloc failed for tx "
+                              "buffers.\n", priv->net_dev->name);
+                       err = -ENOMEM;
+                       break;
+               }
+
+               priv->tx_buffers[i].type = DATA;
+               priv->tx_buffers[i].info.d_struct.data = (struct ipw2100_data_header*)v;
+               priv->tx_buffers[i].info.d_struct.data_phys = p;
+               priv->tx_buffers[i].info.d_struct.txb = NULL;
+       }
+
+       if (i == TX_PENDED_QUEUE_LENGTH)
+               return 0;
+
+       for (j = 0; j < i; j++) {
+               pci_free_consistent(
+                       priv->pci_dev,
+                       sizeof(struct ipw2100_data_header),
+                       priv->tx_buffers[j].info.d_struct.data,
+                       priv->tx_buffers[j].info.d_struct.data_phys);
+       }
+
+       kfree(priv->tx_buffers);
+       priv->tx_buffers = NULL;
+
+       return err;
+}
+
+static void ipw2100_tx_initialize(struct ipw2100_priv *priv)
+{
+       int i;
+
+       IPW_DEBUG_INFO("enter\n");
+
+       /*
+        * reinitialize packet info lists
+        */
+       INIT_LIST_HEAD(&priv->fw_pend_list);
+       INIT_STAT(&priv->fw_pend_stat);
+
+       /*
+        * reinitialize lists
+        */
+       INIT_LIST_HEAD(&priv->tx_pend_list);
+       INIT_LIST_HEAD(&priv->tx_free_list);
+       INIT_STAT(&priv->tx_pend_stat);
+       INIT_STAT(&priv->tx_free_stat);
+
+       for (i = 0; i < TX_PENDED_QUEUE_LENGTH; i++) {
+               /* We simply drop any SKBs that have been queued for
+                * transmit */
+               if (priv->tx_buffers[i].info.d_struct.txb) {
+                       ieee80211_txb_free(priv->tx_buffers[i].info.d_struct.txb);
+                       priv->tx_buffers[i].info.d_struct.txb = NULL;
+               }
+
+               list_add_tail(&priv->tx_buffers[i].list, &priv->tx_free_list);
+       }
+
+       SET_STAT(&priv->tx_free_stat, i);
+
+       priv->tx_queue.oldest = 0;
+       priv->tx_queue.available = priv->tx_queue.entries;
+       priv->tx_queue.next = 0;
+       INIT_STAT(&priv->txq_stat);
+       SET_STAT(&priv->txq_stat, priv->tx_queue.available);
+
+       bd_queue_initialize(priv, &priv->tx_queue,
+                           IPW_MEM_HOST_SHARED_TX_QUEUE_BD_BASE,
+                           IPW_MEM_HOST_SHARED_TX_QUEUE_BD_SIZE,
+                           IPW_MEM_HOST_SHARED_TX_QUEUE_READ_INDEX,
+                           IPW_MEM_HOST_SHARED_TX_QUEUE_WRITE_INDEX);
+
+       IPW_DEBUG_INFO("exit\n");
+
+}
+
+static void ipw2100_tx_free(struct ipw2100_priv *priv)
+{
+       int i;
+
+       IPW_DEBUG_INFO("enter\n");
+
+       bd_queue_free(priv, &priv->tx_queue);
+
+       if (!priv->tx_buffers)
+               return;
+
+       for (i = 0; i < TX_PENDED_QUEUE_LENGTH; i++) {
+               if (priv->tx_buffers[i].info.d_struct.txb) {
+                       ieee80211_txb_free(priv->tx_buffers[i].info.d_struct.txb);
+                       priv->tx_buffers[i].info.d_struct.txb = NULL;
+               }
+               if (priv->tx_buffers[i].info.d_struct.data)
+                       pci_free_consistent(
+                               priv->pci_dev,
+                               sizeof(struct ipw2100_data_header),
+                               priv->tx_buffers[i].info.d_struct.data,
+                               priv->tx_buffers[i].info.d_struct.data_phys);
+       }
+
+       kfree(priv->tx_buffers);
+       priv->tx_buffers = NULL;
+
+       IPW_DEBUG_INFO("exit\n");
+}
+
+
+
+static int ipw2100_rx_allocate(struct ipw2100_priv *priv)
+{
+       int i, j, err = -EINVAL;
+
+       IPW_DEBUG_INFO("enter\n");
+
+       err = bd_queue_allocate(priv, &priv->rx_queue, RX_QUEUE_LENGTH);
+       if (err) {
+               IPW_DEBUG_INFO("failed bd_queue_allocate\n");
+               return err;
+       }
+
+       err = status_queue_allocate(priv, RX_QUEUE_LENGTH);
+       if (err) {
+               IPW_DEBUG_INFO("failed status_queue_allocate\n");
+               bd_queue_free(priv, &priv->rx_queue);
+               return err;
+       }
+
+       /*
+        * allocate packets
+        */
+       priv->rx_buffers = (struct ipw2100_rx_packet *)
+           kmalloc(RX_QUEUE_LENGTH * sizeof(struct ipw2100_rx_packet),
+                   GFP_KERNEL);
+       if (!priv->rx_buffers) {
+               IPW_DEBUG_INFO("can't allocate rx packet buffer table\n");
+
+               bd_queue_free(priv, &priv->rx_queue);
+
+               status_queue_free(priv);
+
+               return -ENOMEM;
+       }
+
+       for (i = 0; i < RX_QUEUE_LENGTH; i++) {
+               struct ipw2100_rx_packet *packet = &priv->rx_buffers[i];
+
+               err = ipw2100_alloc_skb(priv, packet);
+               if (unlikely(err)) {
+                       err = -ENOMEM;
+                       break;
+               }
+
+               /* The BD holds the cache aligned address */
+               priv->rx_queue.drv[i].host_addr = packet->dma_addr;
+               priv->rx_queue.drv[i].buf_length = IPW_RX_NIC_BUFFER_LENGTH;
+               priv->status_queue.drv[i].status_fields = 0;
+       }
+
+       if (i == RX_QUEUE_LENGTH)
+               return 0;
+
+       for (j = 0; j < i; j++) {
+               pci_unmap_single(priv->pci_dev, priv->rx_buffers[j].dma_addr,
+                                sizeof(struct ipw2100_rx_packet),
+                                PCI_DMA_FROMDEVICE);
+               dev_kfree_skb(priv->rx_buffers[j].skb);
+       }
+
+       kfree(priv->rx_buffers);
+       priv->rx_buffers = NULL;
+
+       bd_queue_free(priv, &priv->rx_queue);
+
+       status_queue_free(priv);
+
+       return err;
+}
+
+static void ipw2100_rx_initialize(struct ipw2100_priv *priv)
+{
+       IPW_DEBUG_INFO("enter\n");
+
+       priv->rx_queue.oldest = 0;
+       priv->rx_queue.available = priv->rx_queue.entries - 1;
+       priv->rx_queue.next = priv->rx_queue.entries - 1;
+
+       INIT_STAT(&priv->rxq_stat);
+       SET_STAT(&priv->rxq_stat, priv->rx_queue.available);
+
+       bd_queue_initialize(priv, &priv->rx_queue,
+                           IPW_MEM_HOST_SHARED_RX_BD_BASE,
+                           IPW_MEM_HOST_SHARED_RX_BD_SIZE,
+                           IPW_MEM_HOST_SHARED_RX_READ_INDEX,
+                           IPW_MEM_HOST_SHARED_RX_WRITE_INDEX);
+
+       /* set up the status queue */
+       write_register(priv->net_dev, IPW_MEM_HOST_SHARED_RX_STATUS_BASE,
+                      priv->status_queue.nic);
+
+       IPW_DEBUG_INFO("exit\n");
+}
+
+static void ipw2100_rx_free(struct ipw2100_priv *priv)
+{
+       int i;
+
+       IPW_DEBUG_INFO("enter\n");
+
+       bd_queue_free(priv, &priv->rx_queue);
+       status_queue_free(priv);
+
+       if (!priv->rx_buffers)
+               return;
+
+       for (i = 0; i < RX_QUEUE_LENGTH; i++) {
+               if (priv->rx_buffers[i].rxp) {
+                       pci_unmap_single(priv->pci_dev,
+                                        priv->rx_buffers[i].dma_addr,
+                                        sizeof(struct ipw2100_rx),
+                                        PCI_DMA_FROMDEVICE);
+                       dev_kfree_skb(priv->rx_buffers[i].skb);
+               }
+       }
+
+       kfree(priv->rx_buffers);
+       priv->rx_buffers = NULL;
+
+       IPW_DEBUG_INFO("exit\n");
+}
+
+static int ipw2100_read_mac_address(struct ipw2100_priv *priv)
+{
+       u32 length = ETH_ALEN;
+       u8 mac[ETH_ALEN];
+
+       int err;
+
+       err = ipw2100_get_ordinal(priv, IPW_ORD_STAT_ADAPTER_MAC,
+                                 mac, &length);
+       if (err) {
+               IPW_DEBUG_INFO("MAC address read failed\n");
+               return -EIO;
+       }
+       IPW_DEBUG_INFO("card MAC is %02X:%02X:%02X:%02X:%02X:%02X\n",
+              mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+
+       memcpy(priv->net_dev->dev_addr, mac, ETH_ALEN);
+
+       return 0;
+}
+
+/********************************************************************
+ *
+ * Firmware Commands
+ *
+ ********************************************************************/
+
+static int ipw2100_set_mac_address(struct ipw2100_priv *priv, int batch_mode)
+{
+       struct host_command cmd = {
+               .host_command = ADAPTER_ADDRESS,
+               .host_command_sequence = 0,
+               .host_command_length = ETH_ALEN
+       };
+       int err;
+
+       IPW_DEBUG_HC("SET_MAC_ADDRESS\n");
+
+       IPW_DEBUG_INFO("enter\n");
+
+       if (priv->config & CFG_CUSTOM_MAC) {
+               memcpy(cmd.host_command_parameters, priv->mac_addr,
+                      ETH_ALEN);
+               memcpy(priv->net_dev->dev_addr, priv->mac_addr, ETH_ALEN);
+       } else
+               memcpy(cmd.host_command_parameters, priv->net_dev->dev_addr,
+                      ETH_ALEN);
+
+       err = ipw2100_hw_send_command(priv, &cmd);
+
+       IPW_DEBUG_INFO("exit\n");
+       return err;
+}
+
+static int ipw2100_set_port_type(struct ipw2100_priv *priv, u32 port_type,
+                                int batch_mode)
+{
+       struct host_command cmd = {
+               .host_command = PORT_TYPE,
+               .host_command_sequence = 0,
+               .host_command_length = sizeof(u32)
+       };
+       int err;
+
+       switch (port_type) {
+       case IW_MODE_INFRA:
+               cmd.host_command_parameters[0] = IPW_BSS;
+               break;
+       case IW_MODE_ADHOC:
+               cmd.host_command_parameters[0] = IPW_IBSS;
+               break;
+       }
+
+       IPW_DEBUG_HC("PORT_TYPE: %s\n",
+                    port_type == IPW_IBSS ? "Ad-Hoc" : "Managed");
+
+       if (!batch_mode) {
+               err = ipw2100_disable_adapter(priv);
+               if (err) {
+                       printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n",
+                              priv->net_dev->name, err);
+                       return err;
+               }
+       }
+
+       /* send cmd to firmware */
+       err = ipw2100_hw_send_command(priv, &cmd);
+
+       if (!batch_mode)
+               ipw2100_enable_adapter(priv);
+
+       return err;
+}
+
+
+static int ipw2100_set_channel(struct ipw2100_priv *priv, u32 channel,
+                              int batch_mode)
+{
+       struct host_command cmd = {
+               .host_command = CHANNEL,
+               .host_command_sequence = 0,
+               .host_command_length = sizeof(u32)
+       };
+       int err;
+
+       cmd.host_command_parameters[0] = channel;
+
+       IPW_DEBUG_HC("CHANNEL: %d\n", channel);
+
+       /* If BSS then we don't support channel selection */
+       if (priv->ieee->iw_mode == IW_MODE_INFRA)
+               return 0;
+
+       if ((channel != 0) &&
+           ((channel < REG_MIN_CHANNEL) || (channel > REG_MAX_CHANNEL)))
+               return -EINVAL;
+
+       if (!batch_mode) {
+               err = ipw2100_disable_adapter(priv);
+               if (err)
+                       return err;
+       }
+
+       err = ipw2100_hw_send_command(priv, &cmd);
+       if (err) {
+               IPW_DEBUG_INFO("Failed to set channel to %d",
+                              channel);
+               return err;
+       }
+
+       if (channel)
+               priv->config |= CFG_STATIC_CHANNEL;
+       else
+               priv->config &= ~CFG_STATIC_CHANNEL;
+
+       priv->channel = channel;
+
+       if (!batch_mode) {
+               err = ipw2100_enable_adapter(priv);
+               if (err)
+                       return err;
+       }
+
+       return 0;
+}
+
+static int ipw2100_system_config(struct ipw2100_priv *priv, int batch_mode)
+{
+       struct host_command cmd = {
+               .host_command = SYSTEM_CONFIG,
+               .host_command_sequence = 0,
+               .host_command_length = 12,
+       };
+       u32 ibss_mask, len = sizeof(u32);
+       int err;
+
+       /* Set system configuration */
+
+       if (!batch_mode) {
+               err = ipw2100_disable_adapter(priv);
+               if (err)
+                       return err;
+       }
+
+       if (priv->ieee->iw_mode == IW_MODE_ADHOC)
+               cmd.host_command_parameters[0] |= IPW_CFG_IBSS_AUTO_START;
+
+       cmd.host_command_parameters[0] |= IPW_CFG_IBSS_MASK |
+               IPW_CFG_BSS_MASK |
+               IPW_CFG_802_1x_ENABLE;
+
+       if (!(priv->config & CFG_LONG_PREAMBLE))
+               cmd.host_command_parameters[0] |= IPW_CFG_PREAMBLE_AUTO;
+
+       err = ipw2100_get_ordinal(priv,
+                                 IPW_ORD_EEPROM_IBSS_11B_CHANNELS,
+                                 &ibss_mask,  &len);
+       if (err)
+               ibss_mask = IPW_IBSS_11B_DEFAULT_MASK;
+
+       cmd.host_command_parameters[1] = REG_CHANNEL_MASK;
+       cmd.host_command_parameters[2] = REG_CHANNEL_MASK & ibss_mask;
+
+       /* 11b only */
+       /*cmd.host_command_parameters[0] |= DIVERSITY_ANTENNA_A;*/
+
+       err = ipw2100_hw_send_command(priv, &cmd);
+       if (err)
+               return err;
+
+/* If IPv6 is configured in the kernel then we don't want to filter out all
+ * of the multicast packets as IPv6 needs some. */
+#if !defined(CONFIG_IPV6) && !defined(CONFIG_IPV6_MODULE)
+       cmd.host_command = ADD_MULTICAST;
+       cmd.host_command_sequence = 0;
+       cmd.host_command_length = 0;
+
+       ipw2100_hw_send_command(priv, &cmd);
+#endif
+       if (!batch_mode) {
+               err = ipw2100_enable_adapter(priv);
+               if (err)
+                       return err;
+       }
+
+       return 0;
+}
+
+static int ipw2100_set_tx_rates(struct ipw2100_priv *priv, u32 rate,
+                               int batch_mode)
+{
+       struct host_command cmd = {
+               .host_command = BASIC_TX_RATES,
+               .host_command_sequence = 0,
+               .host_command_length = 4
+       };
+       int err;
+
+       cmd.host_command_parameters[0] = rate & TX_RATE_MASK;
+
+       if (!batch_mode) {
+               err = ipw2100_disable_adapter(priv);
+               if (err)
+                       return err;
+       }
+
+       /* Set BASIC TX Rate first */
+       ipw2100_hw_send_command(priv, &cmd);
+
+       /* Set TX Rate */
+       cmd.host_command = TX_RATES;
+       ipw2100_hw_send_command(priv, &cmd);
+
+       /* Set MSDU TX Rate */
+       cmd.host_command = MSDU_TX_RATES;
+       ipw2100_hw_send_command(priv, &cmd);
+
+       if (!batch_mode) {
+               err = ipw2100_enable_adapter(priv);
+               if (err)
+                       return err;
+       }
+
+       priv->tx_rates = rate;
+
+       return 0;
+}
+
+static int ipw2100_set_power_mode(struct ipw2100_priv *priv,
+                                 int power_level)
+{
+       struct host_command cmd = {
+               .host_command = POWER_MODE,
+               .host_command_sequence = 0,
+               .host_command_length = 4
+       };
+       int err;
+
+       cmd.host_command_parameters[0] = power_level;
+
+       err = ipw2100_hw_send_command(priv, &cmd);
+       if (err)
+               return err;
+
+       if (power_level == IPW_POWER_MODE_CAM)
+               priv->power_mode = IPW_POWER_LEVEL(priv->power_mode);
+       else
+               priv->power_mode = IPW_POWER_ENABLED | power_level;
+
+#ifdef CONFIG_IPW2100_TX_POWER
+       if (priv->port_type == IBSS &&
+           priv->adhoc_power != DFTL_IBSS_TX_POWER) {
+               /* Set beacon interval */
+               cmd.host_command = TX_POWER_INDEX;
+               cmd.host_command_parameters[0] = (u32)priv->adhoc_power;
+
+               err = ipw2100_hw_send_command(priv, &cmd);
+               if (err)
+                       return err;
+       }
+#endif
+
+       return 0;
+}
+
+
+static int ipw2100_set_rts_threshold(struct ipw2100_priv *priv, u32 threshold)
+{
+       struct host_command cmd = {
+               .host_command = RTS_THRESHOLD,
+               .host_command_sequence = 0,
+               .host_command_length = 4
+       };
+       int err;
+
+       if (threshold & RTS_DISABLED)
+               cmd.host_command_parameters[0] = MAX_RTS_THRESHOLD;
+       else
+               cmd.host_command_parameters[0] = threshold & ~RTS_DISABLED;
+
+       err = ipw2100_hw_send_command(priv, &cmd);
+       if (err)
+               return err;
+
+       priv->rts_threshold = threshold;
+
+       return 0;
+}
+
+#if 0
+int ipw2100_set_fragmentation_threshold(struct ipw2100_priv *priv,
+                                       u32 threshold, int batch_mode)
+{
+       struct host_command cmd = {
+               .host_command = FRAG_THRESHOLD,
+               .host_command_sequence = 0,
+               .host_command_length = 4,
+               .host_command_parameters[0] = 0,
+       };
+       int err;
+
+       if (!batch_mode) {
+               err = ipw2100_disable_adapter(priv);
+               if (err)
+                       return err;
+       }
+
+       if (threshold == 0)
+               threshold = DEFAULT_FRAG_THRESHOLD;
+       else {
+               threshold = max(threshold, MIN_FRAG_THRESHOLD);
+               threshold = min(threshold, MAX_FRAG_THRESHOLD);
+       }
+
+       cmd.host_command_parameters[0] = threshold;
+
+       IPW_DEBUG_HC("FRAG_THRESHOLD: %u\n", threshold);
+
+       err = ipw2100_hw_send_command(priv, &cmd);
+
+       if (!batch_mode)
+               ipw2100_enable_adapter(priv);
+
+       if (!err)
+               priv->frag_threshold = threshold;
+
+       return err;
+}
+#endif
+
+static int ipw2100_set_short_retry(struct ipw2100_priv *priv, u32 retry)
+{
+       struct host_command cmd = {
+               .host_command = SHORT_RETRY_LIMIT,
+               .host_command_sequence = 0,
+               .host_command_length = 4
+       };
+       int err;
+
+       cmd.host_command_parameters[0] = retry;
+
+       err = ipw2100_hw_send_command(priv, &cmd);
+       if (err)
+               return err;
+
+       priv->short_retry_limit = retry;
+
+       return 0;
+}
+
+static int ipw2100_set_long_retry(struct ipw2100_priv *priv, u32 retry)
+{
+       struct host_command cmd = {
+               .host_command = LONG_RETRY_LIMIT,
+               .host_command_sequence = 0,
+               .host_command_length = 4
+       };
+       int err;
+
+       cmd.host_command_parameters[0] = retry;
+
+       err = ipw2100_hw_send_command(priv, &cmd);
+       if (err)
+               return err;
+
+       priv->long_retry_limit = retry;
+
+       return 0;
+}
+
+
+static int ipw2100_set_mandatory_bssid(struct ipw2100_priv *priv, u8 *bssid,
+                                      int batch_mode)
+{
+       struct host_command cmd = {
+               .host_command = MANDATORY_BSSID,
+               .host_command_sequence = 0,
+               .host_command_length = (bssid == NULL) ? 0 : ETH_ALEN
+       };
+       int err;
+
+#ifdef CONFIG_IPW_DEBUG
+       if (bssid != NULL)
+               IPW_DEBUG_HC(
+                       "MANDATORY_BSSID: %02X:%02X:%02X:%02X:%02X:%02X\n",
+                       bssid[0], bssid[1], bssid[2], bssid[3], bssid[4],
+                       bssid[5]);
+       else
+               IPW_DEBUG_HC("MANDATORY_BSSID: <clear>\n");
+#endif
+       /* if BSSID is empty then we disable mandatory bssid mode */
+       if (bssid != NULL)
+               memcpy((u8 *)cmd.host_command_parameters, bssid, ETH_ALEN);
+
+       if (!batch_mode) {
+               err = ipw2100_disable_adapter(priv);
+               if (err)
+                       return err;
+       }
+
+       err = ipw2100_hw_send_command(priv, &cmd);
+
+       if (!batch_mode)
+               ipw2100_enable_adapter(priv);
+
+       return err;
+}
+
+#ifdef CONFIG_IEEE80211_WPA
+static int ipw2100_disassociate_bssid(struct ipw2100_priv *priv)
+{
+       struct host_command cmd = {
+               .host_command = DISASSOCIATION_BSSID,
+               .host_command_sequence = 0,
+               .host_command_length = ETH_ALEN
+       };
+       int err;
+       int len;
+
+       IPW_DEBUG_HC("DISASSOCIATION_BSSID\n");
+
+       len = ETH_ALEN;
+       /* The Firmware currently ignores the BSSID and just disassociates from
+        * the currently associated AP -- but in the off chance that a future
+        * firmware does use the BSSID provided here, we go ahead and try and
+        * set it to the currently associated AP's BSSID */
+       memcpy(cmd.host_command_parameters, priv->bssid, ETH_ALEN);
+
+       err = ipw2100_hw_send_command(priv, &cmd);
+
+       return err;
+}
+#endif
+
+/*
+ * Pseudo code for setting up wpa_frame:
+ */
+#if 0
+void x(struct ieee80211_assoc_frame *wpa_assoc)
+{
+       struct ipw2100_wpa_assoc_frame frame;
+       frame->fixed_ie_mask = IPW_WPA_CAPABILTIES |
+               IPW_WPA_LISTENINTERVAL |
+               IPW_WPA_AP_ADDRESS;
+       frame->capab_info = wpa_assoc->capab_info;
+       frame->lisen_interval = wpa_assoc->listent_interval;
+       memcpy(frame->current_ap, wpa_assoc->current_ap, ETH_ALEN);
+
+       /* UNKNOWN -- I'm not postivive about this part; don't have any WPA
+        * setup here to test it with.
+        *
+        * Walk the IEs in the wpa_assoc and figure out the total size of all
+        * that data.  Stick that into frame->var_ie_len.  Then memcpy() all of
+        * the IEs from wpa_frame into frame.
+        */
+       frame->var_ie_len = calculate_ie_len(wpa_assoc);
+       memcpy(frame->var_ie,  wpa_assoc->variable, frame->var_ie_len);
+
+       ipw2100_set_wpa_ie(priv, &frame, 0);
+}
+#endif
+
+
+
+
+static int ipw2100_set_wpa_ie(struct ipw2100_priv *,
+                             struct ipw2100_wpa_assoc_frame *, int)
+__attribute__ ((unused));
+
+static int ipw2100_set_wpa_ie(struct ipw2100_priv *priv,
+                             struct ipw2100_wpa_assoc_frame *wpa_frame,
+                             int batch_mode)
+{
+       struct host_command cmd = {
+               .host_command = SET_WPA_IE,
+               .host_command_sequence = 0,
+               .host_command_length = sizeof(struct ipw2100_wpa_assoc_frame),
+       };
+       int err;
+
+       IPW_DEBUG_HC("SET_WPA_IE\n");
+
+       if (!batch_mode) {
+               err = ipw2100_disable_adapter(priv);
+               if (err)
+                       return err;
+       }
+
+       memcpy(cmd.host_command_parameters, wpa_frame,
+              sizeof(struct ipw2100_wpa_assoc_frame));
+
+       err = ipw2100_hw_send_command(priv, &cmd);
+
+       if (!batch_mode) {
+               if (ipw2100_enable_adapter(priv))
+                       err = -EIO;
+       }
+
+       return err;
+}
+
+struct security_info_params {
+       u32 allowed_ciphers;
+       u16 version;
+       u8 auth_mode;
+       u8 replay_counters_number;
+       u8 unicast_using_group;
+} __attribute__ ((packed));
+
+static int ipw2100_set_security_information(struct ipw2100_priv *priv,
+                                           int auth_mode,
+                                           int security_level,
+                                           int unicast_using_group,
+                                           int batch_mode)
+{
+       struct host_command cmd = {
+               .host_command = SET_SECURITY_INFORMATION,
+               .host_command_sequence = 0,
+               .host_command_length = sizeof(struct security_info_params)
+       };
+       struct security_info_params *security =
+               (struct security_info_params *)&cmd.host_command_parameters;
+       int err;
+       memset(security, 0, sizeof(*security));
+
+       /* If shared key AP authentication is turned on, then we need to
+        * configure the firmware to try and use it.
+        *
+        * Actual data encryption/decryption is handled by the host. */
+       security->auth_mode = auth_mode;
+       security->unicast_using_group = unicast_using_group;
+
+       switch (security_level) {
+       default:
+       case SEC_LEVEL_0:
+               security->allowed_ciphers = IPW_NONE_CIPHER;
+               break;
+       case SEC_LEVEL_1:
+               security->allowed_ciphers = IPW_WEP40_CIPHER |
+                       IPW_WEP104_CIPHER;
+               break;
+       case SEC_LEVEL_2:
+               security->allowed_ciphers = IPW_WEP40_CIPHER |
+                       IPW_WEP104_CIPHER | IPW_TKIP_CIPHER;
+               break;
+       case SEC_LEVEL_2_CKIP:
+               security->allowed_ciphers = IPW_WEP40_CIPHER |
+                       IPW_WEP104_CIPHER | IPW_CKIP_CIPHER;
+               break;
+       case SEC_LEVEL_3:
+               security->allowed_ciphers = IPW_WEP40_CIPHER |
+                       IPW_WEP104_CIPHER | IPW_TKIP_CIPHER | IPW_CCMP_CIPHER;
+               break;
+       }
+
+       IPW_DEBUG_HC(
+               "SET_SECURITY_INFORMATION: auth:%d cipher:0x%02X (level %d)\n",
+               security->auth_mode, security->allowed_ciphers, security_level);
+
+       security->replay_counters_number = 0;
+
+       if (!batch_mode) {
+               err = ipw2100_disable_adapter(priv);
+               if (err)
+                       return err;
+       }
+
+       err = ipw2100_hw_send_command(priv, &cmd);
+
+       if (!batch_mode)
+               ipw2100_enable_adapter(priv);
+
+       return err;
+}
+
+static int ipw2100_set_tx_power(struct ipw2100_priv *priv,
+                               u32 tx_power)
+{
+       struct host_command cmd = {
+               .host_command = TX_POWER_INDEX,
+               .host_command_sequence = 0,
+               .host_command_length = 4
+       };
+       int err = 0;
+
+       cmd.host_command_parameters[0] = tx_power;
+
+       if (priv->ieee->iw_mode == IW_MODE_ADHOC)
+               err = ipw2100_hw_send_command(priv, &cmd);
+       if (!err)
+               priv->tx_power = tx_power;
+
+       return 0;
+}
+
+static int ipw2100_set_ibss_beacon_interval(struct ipw2100_priv *priv,
+                                           u32 interval, int batch_mode)
+{
+       struct host_command cmd = {
+               .host_command = BEACON_INTERVAL,
+               .host_command_sequence = 0,
+               .host_command_length = 4
+       };
+       int err;
+
+       cmd.host_command_parameters[0] = interval;
+
+       IPW_DEBUG_INFO("enter\n");
+
+       if (priv->ieee->iw_mode == IW_MODE_ADHOC) {
+               if (!batch_mode) {
+                       err = ipw2100_disable_adapter(priv);
+                       if (err)
+                               return err;
+               }
+
+               ipw2100_hw_send_command(priv, &cmd);
+
+               if (!batch_mode) {
+                       err = ipw2100_enable_adapter(priv);
+                       if (err)
+                               return err;
+               }
+       }
+
+       IPW_DEBUG_INFO("exit\n");
+
+       return 0;
+}
+
+
+void ipw2100_queues_initialize(struct ipw2100_priv *priv)
+{
+       ipw2100_tx_initialize(priv);
+       ipw2100_rx_initialize(priv);
+       ipw2100_msg_initialize(priv);
+}
+
+void ipw2100_queues_free(struct ipw2100_priv *priv)
+{
+       ipw2100_tx_free(priv);
+       ipw2100_rx_free(priv);
+       ipw2100_msg_free(priv);
+}
+
+int ipw2100_queues_allocate(struct ipw2100_priv *priv)
+{
+       if (ipw2100_tx_allocate(priv) ||
+           ipw2100_rx_allocate(priv) ||
+           ipw2100_msg_allocate(priv))
+               goto fail;
+
+       return 0;
+
+ fail:
+       ipw2100_tx_free(priv);
+       ipw2100_rx_free(priv);
+       ipw2100_msg_free(priv);
+       return -ENOMEM;
+}
+
+#define IPW_PRIVACY_CAPABLE 0x0008
+
+static int ipw2100_set_wep_flags(struct ipw2100_priv *priv, u32 flags,
+                                int batch_mode)
+{
+       struct host_command cmd = {
+               .host_command = WEP_FLAGS,
+               .host_command_sequence = 0,
+               .host_command_length = 4
+       };
+       int err;
+
+       cmd.host_command_parameters[0] = flags;
+
+       IPW_DEBUG_HC("WEP_FLAGS: flags = 0x%08X\n", flags);
+
+       if (!batch_mode) {
+               err = ipw2100_disable_adapter(priv);
+               if (err) {
+                       printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n",
+                              priv->net_dev->name, err);
+                       return err;
+               }
+       }
+
+       /* send cmd to firmware */
+       err = ipw2100_hw_send_command(priv, &cmd);
+
+       if (!batch_mode)
+               ipw2100_enable_adapter(priv);
+
+       return err;
+}
+
+struct ipw2100_wep_key {
+       u8 idx;
+       u8 len;
+       u8 key[13];
+};
+
+/* Macros to ease up priting WEP keys */
+#define WEP_FMT_64  "%02X%02X%02X%02X-%02X"
+#define WEP_FMT_128 "%02X%02X%02X%02X-%02X%02X%02X%02X-%02X%02X%02X"
+#define WEP_STR_64(x) x[0],x[1],x[2],x[3],x[4]
+#define WEP_STR_128(x) x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9],x[10]
+
+
+/**
+ * Set a the wep key
+ *
+ * @priv: struct to work on
+ * @idx: index of the key we want to set
+ * @key: ptr to the key data to set
+ * @len: length of the buffer at @key
+ * @batch_mode: FIXME perform the operation in batch mode, not
+ *              disabling the device.
+ *
+ * @returns 0 if OK, < 0 errno code on error.
+ *
+ * Fill out a command structure with the new wep key, length an
+ * index and send it down the wire.
+ */
+static int ipw2100_set_key(struct ipw2100_priv *priv,
+                          int idx, char *key, int len, int batch_mode)
+{
+       int keylen = len ? (len <= 5 ? 5 : 13) : 0;
+       struct host_command cmd = {
+               .host_command = WEP_KEY_INFO,
+               .host_command_sequence = 0,
+               .host_command_length = sizeof(struct ipw2100_wep_key),
+       };
+       struct ipw2100_wep_key *wep_key = (void*)cmd.host_command_parameters;
+       int err;
+
+       IPW_DEBUG_HC("WEP_KEY_INFO: index = %d, len = %d/%d\n",
+                                idx, keylen, len);
+
+       /* NOTE: We don't check cached values in case the firmware was reset
+        * or some other problem is occuring.  If the user is setting the key,
+        * then we push the change */
+
+       wep_key->idx = idx;
+       wep_key->len = keylen;
+
+       if (keylen) {
+               memcpy(wep_key->key, key, len);
+               memset(wep_key->key + len, 0, keylen - len);
+       }
+
+       /* Will be optimized out on debug not being configured in */
+       if (keylen == 0)
+               IPW_DEBUG_WEP("%s: Clearing key %d\n",
+                                 priv->net_dev->name, wep_key->idx);
+       else if (keylen == 5)
+               IPW_DEBUG_WEP("%s: idx: %d, len: %d key: " WEP_FMT_64 "\n",
+                                 priv->net_dev->name, wep_key->idx, wep_key->len,
+                                 WEP_STR_64(wep_key->key));
+       else
+               IPW_DEBUG_WEP("%s: idx: %d, len: %d key: " WEP_FMT_128
+                                 "\n",
+                                 priv->net_dev->name, wep_key->idx, wep_key->len,
+                                 WEP_STR_128(wep_key->key));
+
+       if (!batch_mode) {
+               err = ipw2100_disable_adapter(priv);
+               /* FIXME: IPG: shouldn't this prink be in _disable_adapter()? */
+               if (err) {
+                       printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n",
+                              priv->net_dev->name, err);
+                       return err;
+               }
+       }
+
+       /* send cmd to firmware */
+       err = ipw2100_hw_send_command(priv, &cmd);
+
+       if (!batch_mode) {
+               int err2 = ipw2100_enable_adapter(priv);
+               if (err == 0)
+                       err = err2;
+       }
+       return err;
+}
+
+static int ipw2100_set_key_index(struct ipw2100_priv *priv,
+                                int idx, int batch_mode)
+{
+       struct host_command cmd = {
+               .host_command = WEP_KEY_INDEX,
+               .host_command_sequence = 0,
+               .host_command_length = 4,
+               .host_command_parameters = { idx },
+       };
+       int err;
+
+       IPW_DEBUG_HC("WEP_KEY_INDEX: index = %d\n", idx);
+
+       if (idx < 0 || idx > 3)
+               return -EINVAL;
+
+       if (!batch_mode) {
+               err = ipw2100_disable_adapter(priv);
+               if (err) {
+                       printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n",
+                              priv->net_dev->name, err);
+                       return err;
+               }
+       }
+
+       /* send cmd to firmware */
+       err = ipw2100_hw_send_command(priv, &cmd);
+
+       if (!batch_mode)
+               ipw2100_enable_adapter(priv);
+
+       return err;
+}
+
+
+static int ipw2100_configure_security(struct ipw2100_priv *priv,
+                                     int batch_mode)
+{
+       int i, err, auth_mode, sec_level, use_group;
+
+       if (!(priv->status & STATUS_RUNNING))
+               return 0;
+
+       if (!batch_mode) {
+               err = ipw2100_disable_adapter(priv);
+               if (err)
+                       return err;
+       }
+
+       if (!priv->sec.enabled) {
+               err = ipw2100_set_security_information(
+                       priv, IPW_AUTH_OPEN, SEC_LEVEL_0, 0, 1);
+       } else {
+               auth_mode = IPW_AUTH_OPEN;
+               if ((priv->sec.flags & SEC_AUTH_MODE) &&
+                   (priv->sec.auth_mode == WLAN_AUTH_SHARED_KEY))
+                       auth_mode = IPW_AUTH_SHARED;
+
+               sec_level = SEC_LEVEL_0;
+               if (priv->sec.flags & SEC_LEVEL)
+                       sec_level = priv->sec.level;
+
+               use_group = 0;
+               if (priv->sec.flags & SEC_UNICAST_GROUP)
+                       use_group = priv->sec.unicast_uses_group;
+
+               err = ipw2100_set_security_information(
+                           priv, auth_mode, sec_level, use_group, 1);
+       }
+
+       if (err)
+               goto exit;
+
+       if (priv->sec.enabled) {
+               for (i = 0; i < 4; i++) {
+                       if (!(priv->sec.flags & (1 << i))) {
+                               memset(priv->sec.keys[i], 0, WEP_KEY_LEN);
+                               priv->sec.key_sizes[i] = 0;
+                       } else {
+                               err = ipw2100_set_key(priv, i,
+                                                     priv->sec.keys[i],
+                                                     priv->sec.key_sizes[i],
+                                                     1);
+                               if (err)
+                                       goto exit;
+                       }
+               }
+
+               ipw2100_set_key_index(priv, priv->ieee->tx_keyidx, 1);
+       }
+
+       /* Always enable privacy so the Host can filter WEP packets if
+        * encrypted data is sent up */
+       err = ipw2100_set_wep_flags(
+               priv, priv->sec.enabled ? IPW_PRIVACY_CAPABLE : 0, 1);
+       if (err)
+               goto exit;
+
+       priv->status &= ~STATUS_SECURITY_UPDATED;
+
+ exit:
+       if (!batch_mode)
+               ipw2100_enable_adapter(priv);
+
+       return err;
+}
+
+static void ipw2100_security_work(struct ipw2100_priv *priv)
+{
+       /* If we happen to have reconnected before we get a chance to
+        * process this, then update the security settings--which causes
+        * a disassociation to occur */
+       if (!(priv->status & STATUS_ASSOCIATED) &&
+           priv->status & STATUS_SECURITY_UPDATED)
+               ipw2100_configure_security(priv, 0);
+}
+
+static void shim__set_security(struct net_device *dev,
+                              struct ieee80211_security *sec)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       int i, force_update = 0;
+
+       down(&priv->action_sem);
+       if (!(priv->status & STATUS_INITIALIZED))
+               goto done;
+
+       for (i = 0; i < 4; i++) {
+               if (sec->flags & (1 << i)) {
+                       priv->sec.key_sizes[i] = sec->key_sizes[i];
+                       if (sec->key_sizes[i] == 0)
+                               priv->sec.flags &= ~(1 << i);
+                       else
+                               memcpy(priv->sec.keys[i], sec->keys[i],
+                                      sec->key_sizes[i]);
+                       priv->sec.flags |= (1 << i);
+                       priv->status |= STATUS_SECURITY_UPDATED;
+               }
+       }
+
+       if ((sec->flags & SEC_ACTIVE_KEY) &&
+           priv->sec.active_key != sec->active_key) {
+               if (sec->active_key <= 3) {
+                       priv->sec.active_key = sec->active_key;
+                       priv->sec.flags |= SEC_ACTIVE_KEY;
+               } else
+                       priv->sec.flags &= ~SEC_ACTIVE_KEY;
+
+               priv->status |= STATUS_SECURITY_UPDATED;
+       }
+
+       if ((sec->flags & SEC_AUTH_MODE) &&
+           (priv->sec.auth_mode != sec->auth_mode)) {
+               priv->sec.auth_mode = sec->auth_mode;
+               priv->sec.flags |= SEC_AUTH_MODE;
+               priv->status |= STATUS_SECURITY_UPDATED;
+       }
+
+       if (sec->flags & SEC_ENABLED &&
+           priv->sec.enabled != sec->enabled) {
+               priv->sec.flags |= SEC_ENABLED;
+               priv->sec.enabled = sec->enabled;
+               priv->status |= STATUS_SECURITY_UPDATED;
+               force_update = 1;
+       }
+
+       if (sec->flags & SEC_LEVEL &&
+           priv->sec.level != sec->level) {
+               priv->sec.level = sec->level;
+               priv->sec.flags |= SEC_LEVEL;
+               priv->status |= STATUS_SECURITY_UPDATED;
+       }
+
+       IPW_DEBUG_WEP("Security flags: %c %c%c%c%c %c%c%c%c\n",
+                         priv->sec.flags & (1<<8) ? '1' : '0',
+                         priv->sec.flags & (1<<7) ? '1' : '0',
+                         priv->sec.flags & (1<<6) ? '1' : '0',
+                         priv->sec.flags & (1<<5) ? '1' : '0',
+                         priv->sec.flags & (1<<4) ? '1' : '0',
+                         priv->sec.flags & (1<<3) ? '1' : '0',
+                         priv->sec.flags & (1<<2) ? '1' : '0',
+                         priv->sec.flags & (1<<1) ? '1' : '0',
+                         priv->sec.flags & (1<<0) ? '1' : '0');
+
+/* As a temporary work around to enable WPA until we figure out why
+ * wpa_supplicant toggles the security capability of the driver, which
+ * forces a disassocation with force_update...
+ *
+ *     if (force_update || !(priv->status & STATUS_ASSOCIATED))*/
+       if (!(priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)))
+               ipw2100_configure_security(priv, 0);
+done:
+       up(&priv->action_sem);
+}
+
+static int ipw2100_adapter_setup(struct ipw2100_priv *priv)
+{
+       int err;
+       int batch_mode = 1;
+       u8 *bssid;
+
+       IPW_DEBUG_INFO("enter\n");
+
+       err = ipw2100_disable_adapter(priv);
+       if (err)
+               return err;
+#ifdef CONFIG_IPW2100_MONITOR
+       if (priv->ieee->iw_mode == IW_MODE_MONITOR) {
+               err = ipw2100_set_channel(priv, priv->channel, batch_mode);
+               if (err)
+                       return err;
+
+               IPW_DEBUG_INFO("exit\n");
+
+               return 0;
+       }
+#endif /* CONFIG_IPW2100_MONITOR */
+
+       err = ipw2100_read_mac_address(priv);
+       if (err)
+               return -EIO;
+
+       err = ipw2100_set_mac_address(priv, batch_mode);
+       if (err)
+               return err;
+
+       err = ipw2100_set_port_type(priv, priv->ieee->iw_mode, batch_mode);
+       if (err)
+               return err;
+
+       if (priv->ieee->iw_mode == IW_MODE_ADHOC) {
+               err = ipw2100_set_channel(priv, priv->channel, batch_mode);
+               if (err)
+                       return err;
+       }
+
+       err  = ipw2100_system_config(priv, batch_mode);
+       if (err)
+               return err;
+
+       err = ipw2100_set_tx_rates(priv, priv->tx_rates, batch_mode);
+       if (err)
+               return err;
+
+       /* Default to power mode OFF */
+       err = ipw2100_set_power_mode(priv, IPW_POWER_MODE_CAM);
+       if (err)
+               return err;
+
+       err = ipw2100_set_rts_threshold(priv, priv->rts_threshold);
+       if (err)
+               return err;
+
+       if (priv->config & CFG_STATIC_BSSID)
+               bssid = priv->bssid;
+       else
+               bssid = NULL;
+       err = ipw2100_set_mandatory_bssid(priv, bssid, batch_mode);
+       if (err)
+               return err;
+
+       if (priv->config & CFG_STATIC_ESSID)
+               err = ipw2100_set_essid(priv, priv->essid, priv->essid_len,
+                                       batch_mode);
+       else
+               err = ipw2100_set_essid(priv, NULL, 0, batch_mode);
+       if (err)
+               return err;
+
+       err = ipw2100_configure_security(priv, batch_mode);
+       if (err)
+               return err;
+
+       if (priv->ieee->iw_mode == IW_MODE_ADHOC) {
+               err = ipw2100_set_ibss_beacon_interval(
+                       priv, priv->beacon_interval, batch_mode);
+               if (err)
+                       return err;
+
+               err = ipw2100_set_tx_power(priv, priv->tx_power);
+               if (err)
+                       return err;
+       }
+
+       /*
+         err = ipw2100_set_fragmentation_threshold(
+         priv, priv->frag_threshold, batch_mode);
+         if (err)
+         return err;
+       */
+
+       IPW_DEBUG_INFO("exit\n");
+
+       return 0;
+}
+
+
+/*************************************************************************
+ *
+ * EXTERNALLY CALLED METHODS
+ *
+ *************************************************************************/
+
+/* This method is called by the network layer -- not to be confused with
+ * ipw2100_set_mac_address() declared above called by this driver (and this
+ * method as well) to talk to the firmware */
+static int ipw2100_set_address(struct net_device *dev, void *p)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       struct sockaddr *addr = p;
+       int err = 0;
+
+       if (!is_valid_ether_addr(addr->sa_data))
+               return -EADDRNOTAVAIL;
+
+       down(&priv->action_sem);
+
+       priv->config |= CFG_CUSTOM_MAC;
+       memcpy(priv->mac_addr, addr->sa_data, ETH_ALEN);
+
+       err = ipw2100_set_mac_address(priv, 0);
+       if (err)
+               goto done;
+
+       priv->reset_backoff = 0;
+       up(&priv->action_sem);
+       ipw2100_reset_adapter(priv);
+       return 0;
+
+ done:
+       up(&priv->action_sem);
+       return err;
+}
+
+static int ipw2100_open(struct net_device *dev)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       unsigned long flags;
+       IPW_DEBUG_INFO("dev->open\n");
+
+       spin_lock_irqsave(&priv->low_lock, flags);
+       if (priv->status & STATUS_ASSOCIATED) {
+               netif_carrier_on(dev);
+               netif_start_queue(dev);
+       }
+       spin_unlock_irqrestore(&priv->low_lock, flags);
+
+       return 0;
+}
+
+static int ipw2100_close(struct net_device *dev)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       unsigned long flags;
+       struct list_head *element;
+       struct ipw2100_tx_packet *packet;
+
+       IPW_DEBUG_INFO("enter\n");
+
+       spin_lock_irqsave(&priv->low_lock, flags);
+
+       if (priv->status & STATUS_ASSOCIATED)
+               netif_carrier_off(dev);
+       netif_stop_queue(dev);
+
+       /* Flush the TX queue ... */
+       while (!list_empty(&priv->tx_pend_list)) {
+               element = priv->tx_pend_list.next;
+                packet = list_entry(element, struct ipw2100_tx_packet, list);
+
+               list_del(element);
+               DEC_STAT(&priv->tx_pend_stat);
+
+               ieee80211_txb_free(packet->info.d_struct.txb);
+               packet->info.d_struct.txb = NULL;
+
+               list_add_tail(element, &priv->tx_free_list);
+               INC_STAT(&priv->tx_free_stat);
+       }
+       spin_unlock_irqrestore(&priv->low_lock, flags);
+
+       IPW_DEBUG_INFO("exit\n");
+
+       return 0;
+}
+
+
+
+/*
+ * TODO:  Fix this function... its just wrong
+ */
+static void ipw2100_tx_timeout(struct net_device *dev)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+
+       priv->ieee->stats.tx_errors++;
+
+#ifdef CONFIG_IPW2100_MONITOR
+       if (priv->ieee->iw_mode == IW_MODE_MONITOR)
+               return;
+#endif
+
+       IPW_DEBUG_INFO("%s: TX timed out.  Scheduling firmware restart.\n",
+                      dev->name);
+       schedule_reset(priv);
+}
+
+
+/*
+ * TODO: reimplement it so that it reads statistics
+ *       from the adapter using ordinal tables
+ *       instead of/in addition to collecting them
+ *       in the driver
+ */
+static struct net_device_stats *ipw2100_stats(struct net_device *dev)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+
+       return &priv->ieee->stats;
+}
+
+/* Support for wpa_supplicant. Will be replaced with WEXT once
+ * they get WPA support. */
+#ifdef CONFIG_IEEE80211_WPA
+
+/* following definitions must match definitions in driver_ipw2100.c */
+
+#define IPW2100_IOCTL_WPA_SUPPLICANT           SIOCIWFIRSTPRIV+30
+
+#define IPW2100_CMD_SET_WPA_PARAM              1
+#define        IPW2100_CMD_SET_WPA_IE                  2
+#define IPW2100_CMD_SET_ENCRYPTION             3
+#define IPW2100_CMD_MLME                       4
+
+#define IPW2100_PARAM_WPA_ENABLED              1
+#define IPW2100_PARAM_TKIP_COUNTERMEASURES     2
+#define IPW2100_PARAM_DROP_UNENCRYPTED         3
+#define IPW2100_PARAM_PRIVACY_INVOKED          4
+#define IPW2100_PARAM_AUTH_ALGS                        5
+#define IPW2100_PARAM_IEEE_802_1X              6
+
+#define IPW2100_MLME_STA_DEAUTH                        1
+#define IPW2100_MLME_STA_DISASSOC              2
+
+#define IPW2100_CRYPT_ERR_UNKNOWN_ALG          2
+#define IPW2100_CRYPT_ERR_UNKNOWN_ADDR         3
+#define IPW2100_CRYPT_ERR_CRYPT_INIT_FAILED    4
+#define IPW2100_CRYPT_ERR_KEY_SET_FAILED       5
+#define IPW2100_CRYPT_ERR_TX_KEY_SET_FAILED    6
+#define IPW2100_CRYPT_ERR_CARD_CONF_FAILED     7
+
+#define        IPW2100_CRYPT_ALG_NAME_LEN              16
+
+struct ipw2100_param {
+       u32 cmd;
+       u8 sta_addr[ETH_ALEN];
+        union {
+               struct {
+                       u8 name;
+                       u32 value;
+               } wpa_param;
+               struct {
+                       u32 len;
+                       u8 *data;
+               } wpa_ie;
+               struct{
+                       int command;
+                       int reason_code;
+               } mlme;
+               struct {
+                       u8 alg[IPW2100_CRYPT_ALG_NAME_LEN];
+                       u8 set_tx;
+                       u32 err;
+                       u8 idx;
+                       u8 seq[8]; /* sequence counter (set: RX, get: TX) */
+                       u16 key_len;
+                       u8 key[0];
+               } crypt;
+
+       } u;
+};
+
+/* end of driver_ipw2100.c code */
+
+static int ipw2100_wpa_enable(struct ipw2100_priv *priv, int value){
+
+       struct ieee80211_device *ieee = priv->ieee;
+       struct ieee80211_security sec = {
+               .flags = SEC_LEVEL | SEC_ENABLED,
+       };
+       int ret = 0;
+
+       ieee->wpa_enabled = value;
+
+       if (value){
+               sec.level = SEC_LEVEL_3;
+               sec.enabled = 1;
+       } else {
+               sec.level = SEC_LEVEL_0;
+               sec.enabled = 0;
+       }
+
+       if (ieee->set_security)
+               ieee->set_security(ieee->dev, &sec);
+       else
+               ret = -EOPNOTSUPP;
+
+       return ret;
+}
+
+#define AUTH_ALG_OPEN_SYSTEM                   0x1
+#define AUTH_ALG_SHARED_KEY                    0x2
+
+static int ipw2100_wpa_set_auth_algs(struct ipw2100_priv *priv, int value){
+
+       struct ieee80211_device *ieee = priv->ieee;
+       struct ieee80211_security sec = {
+               .flags = SEC_AUTH_MODE,
+       };
+       int ret = 0;
+
+       if (value & AUTH_ALG_SHARED_KEY){
+               sec.auth_mode = WLAN_AUTH_SHARED_KEY;
+               ieee->open_wep = 0;
+       } else {
+               sec.auth_mode = WLAN_AUTH_OPEN;
+               ieee->open_wep = 1;
+       }
+
+       if (ieee->set_security)
+               ieee->set_security(ieee->dev, &sec);
+       else
+               ret = -EOPNOTSUPP;
+
+       return ret;
+}
+
+
+static int ipw2100_wpa_set_param(struct net_device *dev, u8 name, u32 value){
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       int ret=0;
+
+       switch(name){
+               case IPW2100_PARAM_WPA_ENABLED:
+                       ret = ipw2100_wpa_enable(priv, value);
+                       break;
+
+               case IPW2100_PARAM_TKIP_COUNTERMEASURES:
+                       priv->ieee->tkip_countermeasures=value;
+                       break;
+
+               case IPW2100_PARAM_DROP_UNENCRYPTED:
+                       priv->ieee->drop_unencrypted=value;
+                       break;
+
+               case IPW2100_PARAM_PRIVACY_INVOKED:
+                       priv->ieee->privacy_invoked=value;
+                       break;
+
+               case IPW2100_PARAM_AUTH_ALGS:
+                       ret = ipw2100_wpa_set_auth_algs(priv, value);
+                       break;
+
+               case IPW2100_PARAM_IEEE_802_1X:
+                       priv->ieee->ieee802_1x=value;
+                       break;
+
+               default:
+                       printk(KERN_ERR DRV_NAME ": %s: Unknown WPA param: %d\n",
+                                           dev->name, name);
+                       ret = -EOPNOTSUPP;
+       }
+
+       return ret;
+}
+
+static int ipw2100_wpa_mlme(struct net_device *dev, int command, int reason){
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       int ret=0;
+
+       switch(command){
+               case IPW2100_MLME_STA_DEAUTH:
+                       // silently ignore
+                       break;
+
+               case IPW2100_MLME_STA_DISASSOC:
+                       ipw2100_disassociate_bssid(priv);
+                       break;
+
+               default:
+                       printk(KERN_ERR DRV_NAME ": %s: Unknown MLME request: %d\n",
+                                           dev->name, command);
+                       ret = -EOPNOTSUPP;
+       }
+
+       return ret;
+}
+
+
+void ipw2100_wpa_assoc_frame(struct ipw2100_priv *priv,
+                            char *wpa_ie, int wpa_ie_len){
+
+       struct ipw2100_wpa_assoc_frame frame;
+
+       frame.fixed_ie_mask = 0;
+
+       /* copy WPA IE */
+       memcpy(frame.var_ie, wpa_ie, wpa_ie_len);
+       frame.var_ie_len = wpa_ie_len;
+
+       /* make sure WPA is enabled */
+       ipw2100_wpa_enable(priv, 1);
+       ipw2100_set_wpa_ie(priv, &frame, 0);
+}
+
+
+static int ipw2100_wpa_set_wpa_ie(struct net_device *dev,
+                               struct ipw2100_param *param, int plen){
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       struct ieee80211_device *ieee = priv->ieee;
+       u8 *buf;
+
+       if (! ieee->wpa_enabled)
+           return -EOPNOTSUPP;
+
+       if (param->u.wpa_ie.len > MAX_WPA_IE_LEN ||
+          (param->u.wpa_ie.len &&
+               param->u.wpa_ie.data==NULL))
+               return -EINVAL;
+
+       if (param->u.wpa_ie.len){
+               buf = kmalloc(param->u.wpa_ie.len, GFP_KERNEL);
+               if (buf == NULL)
+                       return -ENOMEM;
+
+               memcpy(buf, param->u.wpa_ie.data, param->u.wpa_ie.len);
+
+               kfree(ieee->wpa_ie);
+               ieee->wpa_ie = buf;
+               ieee->wpa_ie_len = param->u.wpa_ie.len;
+
+       } else {
+               kfree(ieee->wpa_ie);
+               ieee->wpa_ie = NULL;
+               ieee->wpa_ie_len = 0;
+       }
+
+       ipw2100_wpa_assoc_frame(priv, ieee->wpa_ie, ieee->wpa_ie_len);
+
+       return 0;
+}
+
+/* implementation borrowed from hostap driver */
+
+static int ipw2100_wpa_set_encryption(struct net_device *dev,
+                               struct ipw2100_param *param, int param_len){
+
+       int ret = 0;
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       struct ieee80211_device *ieee = priv->ieee;
+       struct ieee80211_crypto_ops *ops;
+       struct ieee80211_crypt_data **crypt;
+
+       struct ieee80211_security sec = {
+               .flags = 0,
+       };
+
+       param->u.crypt.err = 0;
+       param->u.crypt.alg[IPW2100_CRYPT_ALG_NAME_LEN - 1] = '\0';
+
+       if (param_len !=
+           (int) ((char *) param->u.crypt.key - (char *) param) +
+           param->u.crypt.key_len){
+               IPW_DEBUG_INFO("Len mismatch %d, %d\n", param_len, param->u.crypt.key_len);
+               return -EINVAL;
+       }
+       if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
+           param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
+           param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
+               if (param->u.crypt.idx >= WEP_KEYS)
+                       return -EINVAL;
+               crypt = &ieee->crypt[param->u.crypt.idx];
+       } else {
+               return -EINVAL;
+       }
+
+       if (strcmp(param->u.crypt.alg, "none") == 0) {
+               if (crypt){
+                       sec.enabled = 0;
+                       sec.level = SEC_LEVEL_0;
+                       sec.flags |= SEC_ENABLED | SEC_LEVEL;
+                       ieee80211_crypt_delayed_deinit(ieee, crypt);
+               }
+               goto done;
+       }
+       sec.enabled = 1;
+       sec.flags |= SEC_ENABLED;
+
+       ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
+       if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) {
+               request_module("ieee80211_crypt_wep");
+               ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
+       } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) {
+               request_module("ieee80211_crypt_tkip");
+               ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
+       } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) {
+               request_module("ieee80211_crypt_ccmp");
+               ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
+       }
+       if (ops == NULL) {
+               IPW_DEBUG_INFO("%s: unknown crypto alg '%s'\n",
+                      dev->name, param->u.crypt.alg);
+               param->u.crypt.err = IPW2100_CRYPT_ERR_UNKNOWN_ALG;
+               ret = -EINVAL;
+               goto done;
+       }
+
+       if (*crypt == NULL || (*crypt)->ops != ops) {
+               struct ieee80211_crypt_data *new_crypt;
+
+               ieee80211_crypt_delayed_deinit(ieee, crypt);
+
+               new_crypt = (struct ieee80211_crypt_data *)
+                       kmalloc(sizeof(struct ieee80211_crypt_data), GFP_KERNEL);
+               if (new_crypt == NULL) {
+                       ret = -ENOMEM;
+                       goto done;
+               }
+               memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
+               new_crypt->ops = ops;
+               if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
+                       new_crypt->priv = new_crypt->ops->init(param->u.crypt.idx);
+
+               if (new_crypt->priv == NULL) {
+                       kfree(new_crypt);
+                       param->u.crypt.err =
+                               IPW2100_CRYPT_ERR_CRYPT_INIT_FAILED;
+                       ret = -EINVAL;
+                       goto done;
+               }
+
+               *crypt = new_crypt;
+       }
+
+       if (param->u.crypt.key_len > 0 && (*crypt)->ops->set_key &&
+           (*crypt)->ops->set_key(param->u.crypt.key,
+                                  param->u.crypt.key_len, param->u.crypt.seq,
+                                  (*crypt)->priv) < 0) {
+               IPW_DEBUG_INFO("%s: key setting failed\n",
+                      dev->name);
+               param->u.crypt.err = IPW2100_CRYPT_ERR_KEY_SET_FAILED;
+               ret = -EINVAL;
+               goto done;
+       }
+
+       if (param->u.crypt.set_tx){
+               ieee->tx_keyidx = param->u.crypt.idx;
+               sec.active_key = param->u.crypt.idx;
+               sec.flags |= SEC_ACTIVE_KEY;
+       }
+
+       if (ops->name != NULL){
+
+               if (strcmp(ops->name, "WEP") == 0) {
+                       memcpy(sec.keys[param->u.crypt.idx], param->u.crypt.key, param->u.crypt.key_len);
+                       sec.key_sizes[param->u.crypt.idx] = param->u.crypt.key_len;
+                       sec.flags |= (1 << param->u.crypt.idx);
+                       sec.flags |= SEC_LEVEL;
+                       sec.level = SEC_LEVEL_1;
+               } else if (strcmp(ops->name, "TKIP") == 0) {
+                       sec.flags |= SEC_LEVEL;
+                       sec.level = SEC_LEVEL_2;
+               } else if (strcmp(ops->name, "CCMP") == 0) {
+                       sec.flags |= SEC_LEVEL;
+                       sec.level = SEC_LEVEL_3;
+               }
+       }
+ done:
+       if (ieee->set_security)
+               ieee->set_security(ieee->dev, &sec);
+
+       /* Do not reset port if card is in Managed mode since resetting will
+        * generate new IEEE 802.11 authentication which may end up in looping
+        * with IEEE 802.1X.  If your hardware requires a reset after WEP
+        * configuration (for example... Prism2), implement the reset_port in
+        * the callbacks structures used to initialize the 802.11 stack. */
+       if (ieee->reset_on_keychange &&
+           ieee->iw_mode != IW_MODE_INFRA &&
+           ieee->reset_port &&
+           ieee->reset_port(dev)) {
+               IPW_DEBUG_INFO("%s: reset_port failed\n", dev->name);
+               param->u.crypt.err = IPW2100_CRYPT_ERR_CARD_CONF_FAILED;
+               return -EINVAL;
+       }
+
+       return ret;
+}
+
+
+static int ipw2100_wpa_supplicant(struct net_device *dev, struct iw_point *p){
+
+       struct ipw2100_param *param;
+       int ret=0;
+
+       IPW_DEBUG_IOCTL("wpa_supplicant: len=%d\n", p->length);
+
+       if (p->length < sizeof(struct ipw2100_param) || !p->pointer)
+               return -EINVAL;
+
+       param = (struct ipw2100_param *)kmalloc(p->length, GFP_KERNEL);
+       if (param == NULL)
+               return -ENOMEM;
+
+       if (copy_from_user(param, p->pointer, p->length)){
+               kfree(param);
+               return -EFAULT;
+       }
+
+       switch (param->cmd){
+
+       case IPW2100_CMD_SET_WPA_PARAM:
+               ret = ipw2100_wpa_set_param(dev, param->u.wpa_param.name,
+                                           param->u.wpa_param.value);
+               break;
+
+       case IPW2100_CMD_SET_WPA_IE:
+               ret = ipw2100_wpa_set_wpa_ie(dev, param, p->length);
+               break;
+
+       case IPW2100_CMD_SET_ENCRYPTION:
+               ret = ipw2100_wpa_set_encryption(dev, param, p->length);
+               break;
+
+       case IPW2100_CMD_MLME:
+               ret = ipw2100_wpa_mlme(dev, param->u.mlme.command,
+                                      param->u.mlme.reason_code);
+               break;
+
+       default:
+               printk(KERN_ERR DRV_NAME ": %s: Unknown WPA supplicant request: %d\n",
+                               dev->name, param->cmd);
+               ret = -EOPNOTSUPP;
+
+       }
+
+       if (ret == 0 && copy_to_user(p->pointer, param, p->length))
+               ret = -EFAULT;
+
+       kfree(param);
+       return ret;
+}
+#endif /* CONFIG_IEEE80211_WPA */
+
+static int ipw2100_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
+{
+#ifdef CONFIG_IEEE80211_WPA
+       struct iwreq *wrq = (struct iwreq *) rq;
+       int ret=-1;
+       switch (cmd){
+           case IPW2100_IOCTL_WPA_SUPPLICANT:
+               ret = ipw2100_wpa_supplicant(dev, &wrq->u.data);
+               return ret;
+
+           default:
+               return -EOPNOTSUPP;
+       }
+
+#endif /* CONFIG_IEEE80211_WPA */
+
+       return -EOPNOTSUPP;
+}
+
+
+static void ipw_ethtool_get_drvinfo(struct net_device *dev,
+                                   struct ethtool_drvinfo *info)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       char fw_ver[64], ucode_ver[64];
+
+       strcpy(info->driver, DRV_NAME);
+       strcpy(info->version, DRV_VERSION);
+
+       ipw2100_get_fwversion(priv, fw_ver, sizeof(fw_ver));
+       ipw2100_get_ucodeversion(priv, ucode_ver, sizeof(ucode_ver));
+
+       snprintf(info->fw_version, sizeof(info->fw_version), "%s:%d:%s",
+                fw_ver, priv->eeprom_version, ucode_ver);
+
+       strcpy(info->bus_info, pci_name(priv->pci_dev));
+}
+
+static u32 ipw2100_ethtool_get_link(struct net_device *dev)
+{
+    struct ipw2100_priv *priv = ieee80211_priv(dev);
+    return (priv->status & STATUS_ASSOCIATED) ? 1 : 0;
+}
+
+
+static struct ethtool_ops ipw2100_ethtool_ops = {
+    .get_link        = ipw2100_ethtool_get_link,
+    .get_drvinfo     = ipw_ethtool_get_drvinfo,
+};
+
+static void ipw2100_hang_check(void *adapter)
+{
+       struct ipw2100_priv *priv = adapter;
+       unsigned long flags;
+       u32 rtc = 0xa5a5a5a5;
+       u32 len = sizeof(rtc);
+       int restart = 0;
+
+       spin_lock_irqsave(&priv->low_lock, flags);
+
+       if (priv->fatal_error != 0) {
+               /* If fatal_error is set then we need to restart */
+               IPW_DEBUG_INFO("%s: Hardware fatal error detected.\n",
+                              priv->net_dev->name);
+
+               restart = 1;
+       } else if (ipw2100_get_ordinal(priv, IPW_ORD_RTC_TIME, &rtc, &len) ||
+                  (rtc == priv->last_rtc)) {
+               /* Check if firmware is hung */
+               IPW_DEBUG_INFO("%s: Firmware RTC stalled.\n",
+                              priv->net_dev->name);
+
+               restart = 1;
+       }
+
+       if (restart) {
+               /* Kill timer */
+               priv->stop_hang_check = 1;
+               priv->hangs++;
+
+               /* Restart the NIC */
+               schedule_reset(priv);
+       }
+
+       priv->last_rtc = rtc;
+
+       if (!priv->stop_hang_check)
+               queue_delayed_work(priv->workqueue, &priv->hang_check, HZ / 2);
+
+       spin_unlock_irqrestore(&priv->low_lock, flags);
+}
+
+
+static void ipw2100_rf_kill(void *adapter)
+{
+       struct ipw2100_priv *priv = adapter;
+       unsigned long flags;
+
+       spin_lock_irqsave(&priv->low_lock, flags);
+
+       if (rf_kill_active(priv)) {
+               IPW_DEBUG_RF_KILL("RF Kill active, rescheduling GPIO check\n");
+               if (!priv->stop_rf_kill)
+                       queue_delayed_work(priv->workqueue, &priv->rf_kill, HZ);
+               goto exit_unlock;
+       }
+
+       /* RF Kill is now disabled, so bring the device back up */
+
+       if (!(priv->status & STATUS_RF_KILL_MASK)) {
+               IPW_DEBUG_RF_KILL("HW RF Kill no longer active, restarting "
+                                 "device\n");
+               schedule_reset(priv);
+       } else
+               IPW_DEBUG_RF_KILL("HW RF Kill deactivated.  SW RF Kill still "
+                                 "enabled\n");
+
+ exit_unlock:
+       spin_unlock_irqrestore(&priv->low_lock, flags);
+}
+
+static void ipw2100_irq_tasklet(struct ipw2100_priv *priv);
+
+/* Look into using netdev destructor to shutdown ieee80211? */
+
+static struct net_device *ipw2100_alloc_device(
+       struct pci_dev *pci_dev,
+       void __iomem *base_addr,
+       unsigned long mem_start,
+       unsigned long mem_len)
+{
+       struct ipw2100_priv *priv;
+       struct net_device *dev;
+
+       dev = alloc_ieee80211(sizeof(struct ipw2100_priv));
+       if (!dev)
+               return NULL;
+       priv = ieee80211_priv(dev);
+       priv->ieee = netdev_priv(dev);
+       priv->pci_dev = pci_dev;
+       priv->net_dev = dev;
+
+       priv->ieee->hard_start_xmit = ipw2100_tx;
+       priv->ieee->set_security = shim__set_security;
+
+       dev->open = ipw2100_open;
+       dev->stop = ipw2100_close;
+       dev->init = ipw2100_net_init;
+       dev->do_ioctl = ipw2100_ioctl;
+       dev->get_stats = ipw2100_stats;
+       dev->ethtool_ops = &ipw2100_ethtool_ops;
+       dev->tx_timeout = ipw2100_tx_timeout;
+       dev->wireless_handlers = &ipw2100_wx_handler_def;
+       dev->get_wireless_stats = ipw2100_wx_wireless_stats;
+       dev->set_mac_address = ipw2100_set_address;
+       dev->watchdog_timeo = 3*HZ;
+       dev->irq = 0;
+
+       dev->base_addr = (unsigned long)base_addr;
+       dev->mem_start = mem_start;
+       dev->mem_end = dev->mem_start + mem_len - 1;
+
+       /* NOTE: We don't use the wireless_handlers hook
+        * in dev as the system will start throwing WX requests
+        * to us before we're actually initialized and it just
+        * ends up causing problems.  So, we just handle
+        * the WX extensions through the ipw2100_ioctl interface */
+
+
+       /* memset() puts everything to 0, so we only have explicitely set
+        * those values that need to be something else */
+
+       /* If power management is turned on, default to AUTO mode */
+       priv->power_mode = IPW_POWER_AUTO;
+
+
+
+#ifdef CONFIG_IEEE80211_WPA
+       priv->ieee->wpa_enabled = 0;
+       priv->ieee->tkip_countermeasures = 0;
+       priv->ieee->drop_unencrypted = 0;
+       priv->ieee->privacy_invoked = 0;
+       priv->ieee->ieee802_1x = 1;
+#endif /* CONFIG_IEEE80211_WPA */
+
+       /* Set module parameters */
+       switch (mode) {
+       case 1:
+               priv->ieee->iw_mode = IW_MODE_ADHOC;
+               break;
+#ifdef CONFIG_IPW2100_MONITOR
+       case 2:
+               priv->ieee->iw_mode = IW_MODE_MONITOR;
+               break;
+#endif
+       default:
+       case 0:
+               priv->ieee->iw_mode = IW_MODE_INFRA;
+               break;
+       }
+
+       if (disable == 1)
+               priv->status |= STATUS_RF_KILL_SW;
+
+       if (channel != 0 &&
+           ((channel >= REG_MIN_CHANNEL) &&
+            (channel <= REG_MAX_CHANNEL))) {
+               priv->config |= CFG_STATIC_CHANNEL;
+               priv->channel = channel;
+       }
+
+       if (associate)
+               priv->config |= CFG_ASSOCIATE;
+
+       priv->beacon_interval = DEFAULT_BEACON_INTERVAL;
+       priv->short_retry_limit = DEFAULT_SHORT_RETRY_LIMIT;
+       priv->long_retry_limit = DEFAULT_LONG_RETRY_LIMIT;
+       priv->rts_threshold = DEFAULT_RTS_THRESHOLD | RTS_DISABLED;
+       priv->frag_threshold = DEFAULT_FTS | FRAG_DISABLED;
+       priv->tx_power = IPW_TX_POWER_DEFAULT;
+       priv->tx_rates = DEFAULT_TX_RATES;
+
+       strcpy(priv->nick, "ipw2100");
+
+       spin_lock_init(&priv->low_lock);
+       sema_init(&priv->action_sem, 1);
+       sema_init(&priv->adapter_sem, 1);
+
+       init_waitqueue_head(&priv->wait_command_queue);
+
+       netif_carrier_off(dev);
+
+       INIT_LIST_HEAD(&priv->msg_free_list);
+       INIT_LIST_HEAD(&priv->msg_pend_list);
+       INIT_STAT(&priv->msg_free_stat);
+       INIT_STAT(&priv->msg_pend_stat);
+
+       INIT_LIST_HEAD(&priv->tx_free_list);
+       INIT_LIST_HEAD(&priv->tx_pend_list);
+       INIT_STAT(&priv->tx_free_stat);
+       INIT_STAT(&priv->tx_pend_stat);
+
+       INIT_LIST_HEAD(&priv->fw_pend_list);
+       INIT_STAT(&priv->fw_pend_stat);
+
+
+#ifdef CONFIG_SOFTWARE_SUSPEND2
+       priv->workqueue = create_workqueue(DRV_NAME, 0);
+#else
+       priv->workqueue = create_workqueue(DRV_NAME);
+#endif
+       INIT_WORK(&priv->reset_work,
+                 (void (*)(void *))ipw2100_reset_adapter, priv);
+       INIT_WORK(&priv->security_work,
+                 (void (*)(void *))ipw2100_security_work, priv);
+       INIT_WORK(&priv->wx_event_work,
+                 (void (*)(void *))ipw2100_wx_event_work, priv);
+       INIT_WORK(&priv->hang_check, ipw2100_hang_check, priv);
+       INIT_WORK(&priv->rf_kill, ipw2100_rf_kill, priv);
+
+       tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
+                    ipw2100_irq_tasklet, (unsigned long)priv);
+
+       /* NOTE:  We do not start the deferred work for status checks yet */
+       priv->stop_rf_kill = 1;
+       priv->stop_hang_check = 1;
+
+       return dev;
+}
+
+static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
+                               const struct pci_device_id *ent)
+{
+       unsigned long mem_start, mem_len, mem_flags;
+       void __iomem *base_addr = NULL;
+       struct net_device *dev = NULL;
+       struct ipw2100_priv *priv = NULL;
+       int err = 0;
+       int registered = 0;
+       u32 val;
+
+       IPW_DEBUG_INFO("enter\n");
+
+       mem_start = pci_resource_start(pci_dev, 0);
+       mem_len = pci_resource_len(pci_dev, 0);
+       mem_flags = pci_resource_flags(pci_dev, 0);
+
+       if ((mem_flags & IORESOURCE_MEM) != IORESOURCE_MEM) {
+               IPW_DEBUG_INFO("weird - resource type is not memory\n");
+               err = -ENODEV;
+               goto fail;
+       }
+
+       base_addr = ioremap_nocache(mem_start, mem_len);
+       if (!base_addr) {
+               printk(KERN_WARNING DRV_NAME
+                      "Error calling ioremap_nocache.\n");
+               err = -EIO;
+               goto fail;
+       }
+
+       /* allocate and initialize our net_device */
+       dev = ipw2100_alloc_device(pci_dev, base_addr, mem_start, mem_len);
+       if (!dev) {
+               printk(KERN_WARNING DRV_NAME
+                      "Error calling ipw2100_alloc_device.\n");
+               err = -ENOMEM;
+               goto fail;
+       }
+
+       /* set up PCI mappings for device */
+       err = pci_enable_device(pci_dev);
+       if (err) {
+               printk(KERN_WARNING DRV_NAME
+                      "Error calling pci_enable_device.\n");
+               return err;
+       }
+
+       priv = ieee80211_priv(dev);
+
+       pci_set_master(pci_dev);
+       pci_set_drvdata(pci_dev, priv);
+
+       err = pci_set_dma_mask(pci_dev, DMA_32BIT_MASK);
+       if (err) {
+               printk(KERN_WARNING DRV_NAME
+                      "Error calling pci_set_dma_mask.\n");
+               pci_disable_device(pci_dev);
+               return err;
+       }
+
+       err = pci_request_regions(pci_dev, DRV_NAME);
+       if (err) {
+               printk(KERN_WARNING DRV_NAME
+                      "Error calling pci_request_regions.\n");
+               pci_disable_device(pci_dev);
+               return err;
+       }
+
+        /* We disable the RETRY_TIMEOUT register (0x41) to keep
+        * PCI Tx retries from interfering with C3 CPU state */
+       pci_read_config_dword(pci_dev, 0x40, &val);
+       if ((val & 0x0000ff00) != 0)
+               pci_write_config_dword(pci_dev, 0x40, val & 0xffff00ff);
+
+       pci_set_power_state(pci_dev, PCI_D0);
+
+       if (!ipw2100_hw_is_adapter_in_system(dev)) {
+               printk(KERN_WARNING DRV_NAME
+                      "Device not found via register read.\n");
+               err = -ENODEV;
+               goto fail;
+       }
+
+       SET_NETDEV_DEV(dev, &pci_dev->dev);
+
+       /* Force interrupts to be shut off on the device */
+       priv->status |= STATUS_INT_ENABLED;
+       ipw2100_disable_interrupts(priv);
+
+       /* Allocate and initialize the Tx/Rx queues and lists */
+       if (ipw2100_queues_allocate(priv)) {
+               printk(KERN_WARNING DRV_NAME
+                      "Error calilng ipw2100_queues_allocate.\n");
+               err = -ENOMEM;
+               goto fail;
+       }
+       ipw2100_queues_initialize(priv);
+
+       err = request_irq(pci_dev->irq,
+                         ipw2100_interrupt, SA_SHIRQ,
+                         dev->name, priv);
+       if (err) {
+               printk(KERN_WARNING DRV_NAME
+                      "Error calling request_irq: %d.\n",
+                      pci_dev->irq);
+               goto fail;
+       }
+       dev->irq = pci_dev->irq;
+
+       IPW_DEBUG_INFO("Attempting to register device...\n");
+
+       SET_MODULE_OWNER(dev);
+
+       printk(KERN_INFO DRV_NAME
+              ": Detected Intel PRO/Wireless 2100 Network Connection\n");
+
+       /* Bring up the interface.  Pre 0.46, after we registered the
+        * network device we would call ipw2100_up.  This introduced a race
+        * condition with newer hotplug configurations (network was coming
+        * up and making calls before the device was initialized).
+        *
+        * If we called ipw2100_up before we registered the device, then the
+        * device name wasn't registered.  So, we instead use the net_dev->init
+        * member to call a function that then just turns and calls ipw2100_up.
+        * net_dev->init is called after name allocation but before the
+        * notifier chain is called */
+       down(&priv->action_sem);
+       err = register_netdev(dev);
+       if (err) {
+               printk(KERN_WARNING DRV_NAME
+                      "Error calling register_netdev.\n");
+               goto fail_unlock;
+       }
+       registered = 1;
+
+       IPW_DEBUG_INFO("%s: Bound to %s\n", dev->name, pci_name(pci_dev));
+
+       /* perform this after register_netdev so that dev->name is set */
+       sysfs_create_group(&pci_dev->dev.kobj, &ipw2100_attribute_group);
+       netif_carrier_off(dev);
+
+       /* If the RF Kill switch is disabled, go ahead and complete the
+        * startup sequence */
+       if (!(priv->status & STATUS_RF_KILL_MASK)) {
+               /* Enable the adapter - sends HOST_COMPLETE */
+               if (ipw2100_enable_adapter(priv)) {
+                       printk(KERN_WARNING DRV_NAME
+                              ": %s: failed in call to enable adapter.\n",
+                              priv->net_dev->name);
+                       ipw2100_hw_stop_adapter(priv);
+                       err = -EIO;
+                       goto fail_unlock;
+               }
+
+               /* Start a scan . . . */
+               ipw2100_set_scan_options(priv);
+               ipw2100_start_scan(priv);
+       }
+
+       IPW_DEBUG_INFO("exit\n");
+
+       priv->status |= STATUS_INITIALIZED;
+
+       up(&priv->action_sem);
+
+       return 0;
+
+ fail_unlock:
+       up(&priv->action_sem);
+
+ fail:
+       if (dev) {
+               if (registered)
+                       unregister_netdev(dev);
+
+               ipw2100_hw_stop_adapter(priv);
+
+               ipw2100_disable_interrupts(priv);
+
+               if (dev->irq)
+                       free_irq(dev->irq, priv);
+
+               ipw2100_kill_workqueue(priv);
+
+               /* These are safe to call even if they weren't allocated */
+               ipw2100_queues_free(priv);
+               sysfs_remove_group(&pci_dev->dev.kobj, &ipw2100_attribute_group);
+
+               free_ieee80211(dev);
+               pci_set_drvdata(pci_dev, NULL);
+       }
+
+       if (base_addr)
+               iounmap(base_addr);
+
+       pci_release_regions(pci_dev);
+       pci_disable_device(pci_dev);
+
+       return err;
+}
+
+static void __devexit ipw2100_pci_remove_one(struct pci_dev *pci_dev)
+{
+       struct ipw2100_priv *priv = pci_get_drvdata(pci_dev);
+       struct net_device *dev;
+
+       if (priv) {
+               down(&priv->action_sem);
+
+               priv->status &= ~STATUS_INITIALIZED;
+
+               dev = priv->net_dev;
+               sysfs_remove_group(&pci_dev->dev.kobj, &ipw2100_attribute_group);
+
+#ifdef CONFIG_PM
+               if (ipw2100_firmware.version)
+                       ipw2100_release_firmware(priv, &ipw2100_firmware);
+#endif
+               /* Take down the hardware */
+               ipw2100_down(priv);
+
+               /* Release the semaphore so that the network subsystem can
+                * complete any needed calls into the driver... */
+               up(&priv->action_sem);
+
+               /* Unregister the device first - this results in close()
+                * being called if the device is open.  If we free storage
+                * first, then close() will crash. */
+               unregister_netdev(dev);
+
+               /* ipw2100_down will ensure that there is no more pending work
+                * in the workqueue's, so we can safely remove them now. */
+               ipw2100_kill_workqueue(priv);
+
+               ipw2100_queues_free(priv);
+
+               /* Free potential debugging firmware snapshot */
+               ipw2100_snapshot_free(priv);
+
+               if (dev->irq)
+                       free_irq(dev->irq, priv);
+
+               if (dev->base_addr)
+                       iounmap((void __iomem *)dev->base_addr);
+
+               free_ieee80211(dev);
+       }
+
+       pci_release_regions(pci_dev);
+       pci_disable_device(pci_dev);
+
+       IPW_DEBUG_INFO("exit\n");
+}
+
+
+#ifdef CONFIG_PM
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
+static int ipw2100_suspend(struct pci_dev *pci_dev, u32 state)
+#else
+static int ipw2100_suspend(struct pci_dev *pci_dev, pm_message_t state)
+#endif
+{
+       struct ipw2100_priv *priv = pci_get_drvdata(pci_dev);
+       struct net_device *dev = priv->net_dev;
+
+       IPW_DEBUG_INFO("%s: Going into suspend...\n",
+              dev->name);
+
+       down(&priv->action_sem);
+       if (priv->status & STATUS_INITIALIZED) {
+               /* Take down the device; powers it off, etc. */
+               ipw2100_down(priv);
+       }
+
+       /* Remove the PRESENT state of the device */
+       netif_device_detach(dev);
+
+       pci_save_state(pci_dev);
+       pci_disable_device (pci_dev);
+       pci_set_power_state(pci_dev, PCI_D3hot);
+
+       up(&priv->action_sem);
+
+       return 0;
+}
+
+static int ipw2100_resume(struct pci_dev *pci_dev)
+{
+       struct ipw2100_priv *priv = pci_get_drvdata(pci_dev);
+       struct net_device *dev = priv->net_dev;
+       u32 val;
+
+       if (IPW2100_PM_DISABLED)
+               return 0;
+
+       down(&priv->action_sem);
+
+       IPW_DEBUG_INFO("%s: Coming out of suspend...\n",
+              dev->name);
+
+       pci_set_power_state(pci_dev, PCI_D0);
+       pci_enable_device(pci_dev);
+       pci_restore_state(pci_dev);
+
+       /*
+        * Suspend/Resume resets the PCI configuration space, so we have to
+        * re-disable the RETRY_TIMEOUT register (0x41) to keep PCI Tx retries
+        * from interfering with C3 CPU state. pci_restore_state won't help
+        * here since it only restores the first 64 bytes pci config header.
+        */
+       pci_read_config_dword(pci_dev, 0x40, &val);
+       if ((val & 0x0000ff00) != 0)
+               pci_write_config_dword(pci_dev, 0x40, val & 0xffff00ff);
+
+       /* Set the device back into the PRESENT state; this will also wake
+        * the queue of needed */
+       netif_device_attach(dev);
+
+        /* Bring the device back up */
+        if (!(priv->status & STATUS_RF_KILL_SW))
+                ipw2100_up(priv, 0);
+
+       up(&priv->action_sem);
+
+       return 0;
+}
+#endif
+
+
+#define IPW2100_DEV_ID(x) { PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, x }
+
+static struct pci_device_id ipw2100_pci_id_table[] __devinitdata = {
+       IPW2100_DEV_ID(0x2520), /* IN 2100A mPCI 3A */
+       IPW2100_DEV_ID(0x2521), /* IN 2100A mPCI 3B */
+       IPW2100_DEV_ID(0x2524), /* IN 2100A mPCI 3B */
+       IPW2100_DEV_ID(0x2525), /* IN 2100A mPCI 3B */
+       IPW2100_DEV_ID(0x2526), /* IN 2100A mPCI Gen A3 */
+       IPW2100_DEV_ID(0x2522), /* IN 2100 mPCI 3B */
+       IPW2100_DEV_ID(0x2523), /* IN 2100 mPCI 3A */
+       IPW2100_DEV_ID(0x2527), /* IN 2100 mPCI 3B */
+       IPW2100_DEV_ID(0x2528), /* IN 2100 mPCI 3B */
+       IPW2100_DEV_ID(0x2529), /* IN 2100 mPCI 3B */
+       IPW2100_DEV_ID(0x252B), /* IN 2100 mPCI 3A */
+       IPW2100_DEV_ID(0x252C), /* IN 2100 mPCI 3A */
+       IPW2100_DEV_ID(0x252D), /* IN 2100 mPCI 3A */
+
+       IPW2100_DEV_ID(0x2550), /* IB 2100A mPCI 3B */
+       IPW2100_DEV_ID(0x2551), /* IB 2100 mPCI 3B */
+       IPW2100_DEV_ID(0x2553), /* IB 2100 mPCI 3B */
+       IPW2100_DEV_ID(0x2554), /* IB 2100 mPCI 3B */
+       IPW2100_DEV_ID(0x2555), /* IB 2100 mPCI 3B */
+
+       IPW2100_DEV_ID(0x2560), /* DE 2100A mPCI 3A */
+       IPW2100_DEV_ID(0x2562), /* DE 2100A mPCI 3A */
+       IPW2100_DEV_ID(0x2563), /* DE 2100A mPCI 3A */
+       IPW2100_DEV_ID(0x2561), /* DE 2100 mPCI 3A */
+       IPW2100_DEV_ID(0x2565), /* DE 2100 mPCI 3A */
+       IPW2100_DEV_ID(0x2566), /* DE 2100 mPCI 3A */
+       IPW2100_DEV_ID(0x2567), /* DE 2100 mPCI 3A */
+
+       IPW2100_DEV_ID(0x2570), /* GA 2100 mPCI 3B */
+
+       IPW2100_DEV_ID(0x2580), /* TO 2100A mPCI 3B */
+       IPW2100_DEV_ID(0x2582), /* TO 2100A mPCI 3B */
+       IPW2100_DEV_ID(0x2583), /* TO 2100A mPCI 3B */
+       IPW2100_DEV_ID(0x2581), /* TO 2100 mPCI 3B */
+       IPW2100_DEV_ID(0x2585), /* TO 2100 mPCI 3B */
+       IPW2100_DEV_ID(0x2586), /* TO 2100 mPCI 3B */
+       IPW2100_DEV_ID(0x2587), /* TO 2100 mPCI 3B */
+
+       IPW2100_DEV_ID(0x2590), /* SO 2100A mPCI 3B */
+       IPW2100_DEV_ID(0x2592), /* SO 2100A mPCI 3B */
+       IPW2100_DEV_ID(0x2591), /* SO 2100 mPCI 3B */
+       IPW2100_DEV_ID(0x2593), /* SO 2100 mPCI 3B */
+       IPW2100_DEV_ID(0x2596), /* SO 2100 mPCI 3B */
+       IPW2100_DEV_ID(0x2598), /* SO 2100 mPCI 3B */
+
+       IPW2100_DEV_ID(0x25A0), /* HP 2100 mPCI 3B */
+       {0,},
+};
+
+MODULE_DEVICE_TABLE(pci, ipw2100_pci_id_table);
+
+static struct pci_driver ipw2100_pci_driver = {
+       .name = DRV_NAME,
+       .id_table = ipw2100_pci_id_table,
+       .probe = ipw2100_pci_init_one,
+       .remove = __devexit_p(ipw2100_pci_remove_one),
+#ifdef CONFIG_PM
+       .suspend = ipw2100_suspend,
+       .resume = ipw2100_resume,
+#endif
+};
+
+
+/**
+ * Initialize the ipw2100 driver/module
+ *
+ * @returns 0 if ok, < 0 errno node con error.
+ *
+ * Note: we cannot init the /proc stuff until the PCI driver is there,
+ * or we risk an unlikely race condition on someone accessing
+ * uninitialized data in the PCI dev struct through /proc.
+ */
+static int __init ipw2100_init(void)
+{
+       int ret;
+
+       printk(KERN_INFO DRV_NAME ": %s, %s\n", DRV_DESCRIPTION, DRV_VERSION);
+       printk(KERN_INFO DRV_NAME ": %s\n", DRV_COPYRIGHT);
+
+#ifdef CONFIG_IEEE80211_NOWEP
+       IPW_DEBUG_INFO(DRV_NAME ": Compiled with WEP disabled.\n");
+#endif
+
+       ret = pci_module_init(&ipw2100_pci_driver);
+
+#ifdef CONFIG_IPW_DEBUG
+       ipw2100_debug_level = debug;
+       driver_create_file(&ipw2100_pci_driver.driver,
+                          &driver_attr_debug_level);
+#endif
+
+       return ret;
+}
+
+
+/**
+ * Cleanup ipw2100 driver registration
+ */
+static void __exit ipw2100_exit(void)
+{
+       /* FIXME: IPG: check that we have no instances of the devices open */
+#ifdef CONFIG_IPW_DEBUG
+       driver_remove_file(&ipw2100_pci_driver.driver,
+                          &driver_attr_debug_level);
+#endif
+       pci_unregister_driver(&ipw2100_pci_driver);
+}
+
+module_init(ipw2100_init);
+module_exit(ipw2100_exit);
+
+#define WEXT_USECHANNELS 1
+
+static const long ipw2100_frequencies[] = {
+       2412, 2417, 2422, 2427,
+       2432, 2437, 2442, 2447,
+       2452, 2457, 2462, 2467,
+       2472, 2484
+};
+
+#define FREQ_COUNT (sizeof(ipw2100_frequencies) / \
+                    sizeof(ipw2100_frequencies[0]))
+
+static const long ipw2100_rates_11b[] = {
+       1000000,
+       2000000,
+       5500000,
+       11000000
+};
+
+#define RATE_COUNT (sizeof(ipw2100_rates_11b) / sizeof(ipw2100_rates_11b[0]))
+
+static int ipw2100_wx_get_name(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
+{
+       /*
+        * This can be called at any time.  No action lock required
+        */
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       if (!(priv->status & STATUS_ASSOCIATED))
+               strcpy(wrqu->name, "unassociated");
+       else
+               snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11b");
+
+       IPW_DEBUG_WX("Name: %s\n", wrqu->name);
+       return 0;
+}
+
+
+static int ipw2100_wx_set_freq(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       struct iw_freq *fwrq = &wrqu->freq;
+       int err = 0;
+
+       if (priv->ieee->iw_mode == IW_MODE_INFRA)
+               return -EOPNOTSUPP;
+
+       down(&priv->action_sem);
+       if (!(priv->status & STATUS_INITIALIZED)) {
+               err = -EIO;
+               goto done;
+       }
+
+       /* if setting by freq convert to channel */
+       if (fwrq->e == 1) {
+               if ((fwrq->m >= (int) 2.412e8 &&
+                    fwrq->m <= (int) 2.487e8)) {
+                       int f = fwrq->m / 100000;
+                       int c = 0;
+
+                       while ((c < REG_MAX_CHANNEL) &&
+                              (f != ipw2100_frequencies[c]))
+                               c++;
+
+                       /* hack to fall through */
+                       fwrq->e = 0;
+                       fwrq->m = c + 1;
+               }
+       }
+
+       if (fwrq->e > 0 || fwrq->m > 1000)
+               return -EOPNOTSUPP;
+       else { /* Set the channel */
+               IPW_DEBUG_WX("SET Freq/Channel -> %d \n", fwrq->m);
+               err = ipw2100_set_channel(priv, fwrq->m, 0);
+       }
+
+ done:
+       up(&priv->action_sem);
+       return err;
+}
+
+
+static int ipw2100_wx_get_freq(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
+{
+       /*
+        * This can be called at any time.  No action lock required
+        */
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+
+       wrqu->freq.e = 0;
+
+       /* If we are associated, trying to associate, or have a statically
+        * configured CHANNEL then return that; otherwise return ANY */
+       if (priv->config & CFG_STATIC_CHANNEL ||
+           priv->status & STATUS_ASSOCIATED)
+               wrqu->freq.m = priv->channel;
+       else
+               wrqu->freq.m = 0;
+
+       IPW_DEBUG_WX("GET Freq/Channel -> %d \n", priv->channel);
+       return 0;
+
+}
+
+static int ipw2100_wx_set_mode(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       int err = 0;
+
+       IPW_DEBUG_WX("SET Mode -> %d \n", wrqu->mode);
+
+       if (wrqu->mode == priv->ieee->iw_mode)
+               return 0;
+
+       down(&priv->action_sem);
+       if (!(priv->status & STATUS_INITIALIZED)) {
+               err = -EIO;
+               goto done;
+       }
+
+       switch (wrqu->mode) {
+#ifdef CONFIG_IPW2100_MONITOR
+       case IW_MODE_MONITOR:
+               err = ipw2100_switch_mode(priv, IW_MODE_MONITOR);
+               break;
+#endif /* CONFIG_IPW2100_MONITOR */
+       case IW_MODE_ADHOC:
+               err = ipw2100_switch_mode(priv, IW_MODE_ADHOC);
+               break;
+       case IW_MODE_INFRA:
+       case IW_MODE_AUTO:
+       default:
+               err = ipw2100_switch_mode(priv, IW_MODE_INFRA);
+               break;
+       }
+
+done:
+       up(&priv->action_sem);
+       return err;
+}
+
+static int ipw2100_wx_get_mode(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
+{
+       /*
+        * This can be called at any time.  No action lock required
+        */
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+
+       wrqu->mode = priv->ieee->iw_mode;
+       IPW_DEBUG_WX("GET Mode -> %d\n", wrqu->mode);
+
+       return 0;
+}
+
+
+#define POWER_MODES 5
+
+/* Values are in microsecond */
+static const s32 timeout_duration[POWER_MODES] = {
+       350000,
+       250000,
+       75000,
+       37000,
+       25000,
+};
+
+static const s32 period_duration[POWER_MODES] = {
+       400000,
+       700000,
+       1000000,
+       1000000,
+       1000000
+};
+
+static int ipw2100_wx_get_range(struct net_device *dev,
+                               struct iw_request_info *info,
+                               union iwreq_data *wrqu, char *extra)
+{
+       /*
+        * This can be called at any time.  No action lock required
+        */
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       struct iw_range *range = (struct iw_range *)extra;
+       u16 val;
+       int i, level;
+
+       wrqu->data.length = sizeof(*range);
+       memset(range, 0, sizeof(*range));
+
+       /* Let's try to keep this struct in the same order as in
+        * linux/include/wireless.h
+        */
+
+       /* TODO: See what values we can set, and remove the ones we can't
+        * set, or fill them with some default data.
+        */
+
+       /* ~5 Mb/s real (802.11b) */
+       range->throughput = 5 * 1000 * 1000;
+
+//     range->sensitivity;     /* signal level threshold range */
+
+       range->max_qual.qual = 100;
+       /* TODO: Find real max RSSI and stick here */
+       range->max_qual.level = 0;
+       range->max_qual.noise = 0;
+       range->max_qual.updated = 7; /* Updated all three */
+
+       range->avg_qual.qual = 70; /* > 8% missed beacons is 'bad' */
+       /* TODO: Find real 'good' to 'bad' threshol value for RSSI */
+       range->avg_qual.level = 20 + IPW2100_RSSI_TO_DBM;
+       range->avg_qual.noise = 0;
+       range->avg_qual.updated = 7; /* Updated all three */
+
+       range->num_bitrates = RATE_COUNT;
+
+       for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) {
+               range->bitrate[i] = ipw2100_rates_11b[i];
+       }
+
+       range->min_rts = MIN_RTS_THRESHOLD;
+       range->max_rts = MAX_RTS_THRESHOLD;
+       range->min_frag = MIN_FRAG_THRESHOLD;
+       range->max_frag = MAX_FRAG_THRESHOLD;
+
+       range->min_pmp = period_duration[0];    /* Minimal PM period */
+       range->max_pmp = period_duration[POWER_MODES-1];/* Maximal PM period */
+       range->min_pmt = timeout_duration[POWER_MODES-1];       /* Minimal PM timeout */
+       range->max_pmt = timeout_duration[0];/* Maximal PM timeout */
+
+        /* How to decode max/min PM period */
+       range->pmp_flags = IW_POWER_PERIOD;
+        /* How to decode max/min PM period */
+       range->pmt_flags = IW_POWER_TIMEOUT;
+       /* What PM options are supported */
+       range->pm_capa = IW_POWER_TIMEOUT | IW_POWER_PERIOD;
+
+       range->encoding_size[0] = 5;
+       range->encoding_size[1] = 13;           /* Different token sizes */
+       range->num_encoding_sizes = 2;          /* Number of entry in the list */
+       range->max_encoding_tokens = WEP_KEYS;  /* Max number of tokens */
+//     range->encoding_login_index;            /* token index for login token */
+
+       if (priv->ieee->iw_mode == IW_MODE_ADHOC) {
+               range->txpower_capa = IW_TXPOW_DBM;
+               range->num_txpower = IW_MAX_TXPOWER;
+               for (i = 0, level = (IPW_TX_POWER_MAX_DBM * 16); i < IW_MAX_TXPOWER;
+                    i++, level -= ((IPW_TX_POWER_MAX_DBM - IPW_TX_POWER_MIN_DBM) * 16) /
+                            (IW_MAX_TXPOWER - 1))
+                       range->txpower[i] = level / 16;
+       } else {
+               range->txpower_capa = 0;
+               range->num_txpower = 0;
+       }
+
+
+       /* Set the Wireless Extension versions */
+       range->we_version_compiled = WIRELESS_EXT;
+       range->we_version_source = 16;
+
+//     range->retry_capa;      /* What retry options are supported */
+//     range->retry_flags;     /* How to decode max/min retry limit */
+//     range->r_time_flags;    /* How to decode max/min retry life */
+//     range->min_retry;       /* Minimal number of retries */
+//     range->max_retry;       /* Maximal number of retries */
+//     range->min_r_time;      /* Minimal retry lifetime */
+//     range->max_r_time;      /* Maximal retry lifetime */
+
+        range->num_channels = FREQ_COUNT;
+
+       val = 0;
+       for (i = 0; i < FREQ_COUNT; i++) {
+               // TODO: Include only legal frequencies for some countries
+//             if (local->channel_mask & (1 << i)) {
+                       range->freq[val].i = i + 1;
+                       range->freq[val].m = ipw2100_frequencies[i] * 100000;
+                       range->freq[val].e = 1;
+                       val++;
+//             }
+               if (val == IW_MAX_FREQUENCIES)
+               break;
+       }
+       range->num_frequency = val;
+
+       IPW_DEBUG_WX("GET Range\n");
+
+       return 0;
+}
+
+static int ipw2100_wx_set_wap(struct net_device *dev,
+                             struct iw_request_info *info,
+                             union iwreq_data *wrqu, char *extra)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       int err = 0;
+
+       static const unsigned char any[] = {
+               0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+       };
+       static const unsigned char off[] = {
+               0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+       };
+
+       // sanity checks
+       if (wrqu->ap_addr.sa_family != ARPHRD_ETHER)
+               return -EINVAL;
+
+       down(&priv->action_sem);
+       if (!(priv->status & STATUS_INITIALIZED)) {
+               err = -EIO;
+               goto done;
+       }
+
+       if (!memcmp(any, wrqu->ap_addr.sa_data, ETH_ALEN) ||
+           !memcmp(off, wrqu->ap_addr.sa_data, ETH_ALEN)) {
+               /* we disable mandatory BSSID association */
+               IPW_DEBUG_WX("exit - disable mandatory BSSID\n");
+               priv->config &= ~CFG_STATIC_BSSID;
+               err = ipw2100_set_mandatory_bssid(priv, NULL, 0);
+               goto done;
+       }
+
+       priv->config |= CFG_STATIC_BSSID;
+       memcpy(priv->mandatory_bssid_mac, wrqu->ap_addr.sa_data, ETH_ALEN);
+
+       err = ipw2100_set_mandatory_bssid(priv, wrqu->ap_addr.sa_data, 0);
+
+       IPW_DEBUG_WX("SET BSSID -> %02X:%02X:%02X:%02X:%02X:%02X\n",
+                    wrqu->ap_addr.sa_data[0] & 0xff,
+                    wrqu->ap_addr.sa_data[1] & 0xff,
+                    wrqu->ap_addr.sa_data[2] & 0xff,
+                    wrqu->ap_addr.sa_data[3] & 0xff,
+                    wrqu->ap_addr.sa_data[4] & 0xff,
+                    wrqu->ap_addr.sa_data[5] & 0xff);
+
+ done:
+       up(&priv->action_sem);
+       return err;
+}
+
+static int ipw2100_wx_get_wap(struct net_device *dev,
+                             struct iw_request_info *info,
+                             union iwreq_data *wrqu, char *extra)
+{
+       /*
+        * This can be called at any time.  No action lock required
+        */
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+
+       /* If we are associated, trying to associate, or have a statically
+        * configured BSSID then return that; otherwise return ANY */
+       if (priv->config & CFG_STATIC_BSSID ||
+           priv->status & STATUS_ASSOCIATED) {
+               wrqu->ap_addr.sa_family = ARPHRD_ETHER;
+               memcpy(wrqu->ap_addr.sa_data, &priv->bssid, ETH_ALEN);
+       } else
+               memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
+
+       IPW_DEBUG_WX("Getting WAP BSSID: " MAC_FMT "\n",
+                    MAC_ARG(wrqu->ap_addr.sa_data));
+       return 0;
+}
+
+static int ipw2100_wx_set_essid(struct net_device *dev,
+                               struct iw_request_info *info,
+                               union iwreq_data *wrqu, char *extra)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       char *essid = ""; /* ANY */
+       int length = 0;
+       int err = 0;
+
+       down(&priv->action_sem);
+       if (!(priv->status & STATUS_INITIALIZED)) {
+               err = -EIO;
+               goto done;
+       }
+
+       if (wrqu->essid.flags && wrqu->essid.length) {
+               length = wrqu->essid.length - 1;
+               essid = extra;
+       }
+
+       if (length == 0) {
+               IPW_DEBUG_WX("Setting ESSID to ANY\n");
+               priv->config &= ~CFG_STATIC_ESSID;
+               err = ipw2100_set_essid(priv, NULL, 0, 0);
+               goto done;
+       }
+
+       length = min(length, IW_ESSID_MAX_SIZE);
+
+       priv->config |= CFG_STATIC_ESSID;
+
+       if (priv->essid_len == length && !memcmp(priv->essid, extra, length)) {
+               IPW_DEBUG_WX("ESSID set to current ESSID.\n");
+               err = 0;
+               goto done;
+       }
+
+       IPW_DEBUG_WX("Setting ESSID: '%s' (%d)\n", escape_essid(essid, length),
+                    length);
+
+       priv->essid_len = length;
+       memcpy(priv->essid, essid, priv->essid_len);
+
+       err = ipw2100_set_essid(priv, essid, length, 0);
+
+ done:
+       up(&priv->action_sem);
+       return err;
+}
+
+static int ipw2100_wx_get_essid(struct net_device *dev,
+                               struct iw_request_info *info,
+                               union iwreq_data *wrqu, char *extra)
+{
+       /*
+        * This can be called at any time.  No action lock required
+        */
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+
+       /* If we are associated, trying to associate, or have a statically
+        * configured ESSID then return that; otherwise return ANY */
+       if (priv->config & CFG_STATIC_ESSID ||
+           priv->status & STATUS_ASSOCIATED) {
+               IPW_DEBUG_WX("Getting essid: '%s'\n",
+                            escape_essid(priv->essid, priv->essid_len));
+               memcpy(extra, priv->essid, priv->essid_len);
+               wrqu->essid.length = priv->essid_len;
+               wrqu->essid.flags = 1; /* active */
+       } else {
+               IPW_DEBUG_WX("Getting essid: ANY\n");
+               wrqu->essid.length = 0;
+               wrqu->essid.flags = 0; /* active */
+       }
+
+       return 0;
+}
+
+static int ipw2100_wx_set_nick(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
+{
+       /*
+        * This can be called at any time.  No action lock required
+        */
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+
+       if (wrqu->data.length > IW_ESSID_MAX_SIZE)
+               return -E2BIG;
+
+       wrqu->data.length = min((size_t)wrqu->data.length, sizeof(priv->nick));
+       memset(priv->nick, 0, sizeof(priv->nick));
+       memcpy(priv->nick, extra,  wrqu->data.length);
+
+       IPW_DEBUG_WX("SET Nickname -> %s \n", priv->nick);
+
+       return 0;
+}
+
+static int ipw2100_wx_get_nick(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
+{
+       /*
+        * This can be called at any time.  No action lock required
+        */
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+
+       wrqu->data.length = strlen(priv->nick) + 1;
+       memcpy(extra, priv->nick, wrqu->data.length);
+       wrqu->data.flags = 1; /* active */
+
+       IPW_DEBUG_WX("GET Nickname -> %s \n", extra);
+
+       return 0;
+}
+
+static int ipw2100_wx_set_rate(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       u32 target_rate = wrqu->bitrate.value;
+       u32 rate;
+       int err = 0;
+
+       down(&priv->action_sem);
+       if (!(priv->status & STATUS_INITIALIZED)) {
+               err = -EIO;
+               goto done;
+       }
+
+       rate = 0;
+
+       if (target_rate == 1000000 ||
+           (!wrqu->bitrate.fixed && target_rate > 1000000))
+               rate |= TX_RATE_1_MBIT;
+       if (target_rate == 2000000 ||
+           (!wrqu->bitrate.fixed && target_rate > 2000000))
+               rate |= TX_RATE_2_MBIT;
+       if (target_rate == 5500000 ||
+           (!wrqu->bitrate.fixed && target_rate > 5500000))
+               rate |= TX_RATE_5_5_MBIT;
+       if (target_rate == 11000000 ||
+           (!wrqu->bitrate.fixed && target_rate > 11000000))
+               rate |= TX_RATE_11_MBIT;
+       if (rate == 0)
+               rate = DEFAULT_TX_RATES;
+
+       err = ipw2100_set_tx_rates(priv, rate, 0);
+
+       IPW_DEBUG_WX("SET Rate -> %04X \n", rate);
+ done:
+       up(&priv->action_sem);
+       return err;
+}
+
+
+static int ipw2100_wx_get_rate(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       int val;
+       int len = sizeof(val);
+       int err = 0;
+
+       if (!(priv->status & STATUS_ENABLED) ||
+           priv->status & STATUS_RF_KILL_MASK ||
+           !(priv->status & STATUS_ASSOCIATED)) {
+               wrqu->bitrate.value = 0;
+               return 0;
+       }
+
+       down(&priv->action_sem);
+       if (!(priv->status & STATUS_INITIALIZED)) {
+               err = -EIO;
+               goto done;
+       }
+
+       err = ipw2100_get_ordinal(priv, IPW_ORD_CURRENT_TX_RATE, &val, &len);
+       if (err) {
+               IPW_DEBUG_WX("failed querying ordinals.\n");
+               return err;
+       }
+
+       switch (val & TX_RATE_MASK) {
+       case TX_RATE_1_MBIT:
+               wrqu->bitrate.value = 1000000;
+               break;
+       case TX_RATE_2_MBIT:
+               wrqu->bitrate.value = 2000000;
+               break;
+       case TX_RATE_5_5_MBIT:
+               wrqu->bitrate.value = 5500000;
+               break;
+       case TX_RATE_11_MBIT:
+               wrqu->bitrate.value = 11000000;
+               break;
+       default:
+               wrqu->bitrate.value = 0;
+       }
+
+       IPW_DEBUG_WX("GET Rate -> %d \n", wrqu->bitrate.value);
+
+ done:
+       up(&priv->action_sem);
+       return err;
+}
+
+static int ipw2100_wx_set_rts(struct net_device *dev,
+                             struct iw_request_info *info,
+                             union iwreq_data *wrqu, char *extra)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       int value, err;
+
+       /* Auto RTS not yet supported */
+       if (wrqu->rts.fixed == 0)
+               return -EINVAL;
+
+       down(&priv->action_sem);
+       if (!(priv->status & STATUS_INITIALIZED)) {
+               err = -EIO;
+               goto done;
+       }
+
+       if (wrqu->rts.disabled)
+               value = priv->rts_threshold | RTS_DISABLED;
+       else {
+               if (wrqu->rts.value < 1 ||
+                   wrqu->rts.value > 2304) {
+                       err = -EINVAL;
+                       goto done;
+               }
+               value = wrqu->rts.value;
+       }
+
+       err = ipw2100_set_rts_threshold(priv, value);
+
+       IPW_DEBUG_WX("SET RTS Threshold -> 0x%08X \n", value);
+ done:
+       up(&priv->action_sem);
+       return err;
+}
+
+static int ipw2100_wx_get_rts(struct net_device *dev,
+                             struct iw_request_info *info,
+                             union iwreq_data *wrqu, char *extra)
+{
+       /*
+        * This can be called at any time.  No action lock required
+        */
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+
+       wrqu->rts.value = priv->rts_threshold & ~RTS_DISABLED;
+       wrqu->rts.fixed = 1; /* no auto select */
+
+       /* If RTS is set to the default value, then it is disabled */
+       wrqu->rts.disabled = (priv->rts_threshold & RTS_DISABLED) ? 1 : 0;
+
+       IPW_DEBUG_WX("GET RTS Threshold -> 0x%08X \n", wrqu->rts.value);
+
+       return 0;
+}
+
+static int ipw2100_wx_set_txpow(struct net_device *dev,
+                               struct iw_request_info *info,
+                               union iwreq_data *wrqu, char *extra)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       int err = 0, value;
+
+       if (priv->ieee->iw_mode != IW_MODE_ADHOC)
+               return -EINVAL;
+
+       if (wrqu->txpower.disabled == 1 || wrqu->txpower.fixed == 0)
+               value = IPW_TX_POWER_DEFAULT;
+       else {
+               if (wrqu->txpower.value < IPW_TX_POWER_MIN_DBM ||
+                   wrqu->txpower.value > IPW_TX_POWER_MAX_DBM)
+                       return -EINVAL;
+
+               value = (wrqu->txpower.value - IPW_TX_POWER_MIN_DBM) * 16 /
+                       (IPW_TX_POWER_MAX_DBM - IPW_TX_POWER_MIN_DBM);
+       }
+
+       down(&priv->action_sem);
+       if (!(priv->status & STATUS_INITIALIZED)) {
+               err = -EIO;
+               goto done;
+       }
+
+       err = ipw2100_set_tx_power(priv, value);
+
+       IPW_DEBUG_WX("SET TX Power -> %d \n", value);
+
+ done:
+       up(&priv->action_sem);
+       return err;
+}
+
+static int ipw2100_wx_get_txpow(struct net_device *dev,
+                               struct iw_request_info *info,
+                               union iwreq_data *wrqu, char *extra)
+{
+       /*
+        * This can be called at any time.  No action lock required
+        */
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+
+       if (priv->ieee->iw_mode != IW_MODE_ADHOC) {
+               wrqu->power.disabled = 1;
+               return 0;
+       }
+
+       if (priv->tx_power == IPW_TX_POWER_DEFAULT) {
+               wrqu->power.fixed = 0;
+               wrqu->power.value = IPW_TX_POWER_MAX_DBM;
+               wrqu->power.disabled = 1;
+       } else {
+               wrqu->power.disabled = 0;
+               wrqu->power.fixed = 1;
+               wrqu->power.value =
+                       (priv->tx_power *
+                        (IPW_TX_POWER_MAX_DBM - IPW_TX_POWER_MIN_DBM)) /
+                       (IPW_TX_POWER_MAX - IPW_TX_POWER_MIN) +
+                       IPW_TX_POWER_MIN_DBM;
+       }
+
+       wrqu->power.flags = IW_TXPOW_DBM;
+
+       IPW_DEBUG_WX("GET TX Power -> %d \n", wrqu->power.value);
+
+       return 0;
+}
+
+static int ipw2100_wx_set_frag(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
+{
+       /*
+        * This can be called at any time.  No action lock required
+        */
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+
+       if (!wrqu->frag.fixed)
+               return -EINVAL;
+
+       if (wrqu->frag.disabled) {
+               priv->frag_threshold |= FRAG_DISABLED;
+               priv->ieee->fts = DEFAULT_FTS;
+       } else {
+               if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
+                   wrqu->frag.value > MAX_FRAG_THRESHOLD)
+                       return -EINVAL;
+
+               priv->ieee->fts = wrqu->frag.value & ~0x1;
+               priv->frag_threshold = priv->ieee->fts;
+       }
+
+       IPW_DEBUG_WX("SET Frag Threshold -> %d \n", priv->ieee->fts);
+
+       return 0;
+}
+
+static int ipw2100_wx_get_frag(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
+{
+       /*
+        * This can be called at any time.  No action lock required
+        */
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       wrqu->frag.value = priv->frag_threshold & ~FRAG_DISABLED;
+       wrqu->frag.fixed = 0;   /* no auto select */
+       wrqu->frag.disabled = (priv->frag_threshold & FRAG_DISABLED) ? 1 : 0;
+
+       IPW_DEBUG_WX("GET Frag Threshold -> %d \n", wrqu->frag.value);
+
+       return 0;
+}
+
+static int ipw2100_wx_set_retry(struct net_device *dev,
+                               struct iw_request_info *info,
+                               union iwreq_data *wrqu, char *extra)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       int err = 0;
+
+       if (wrqu->retry.flags & IW_RETRY_LIFETIME ||
+           wrqu->retry.disabled)
+               return -EINVAL;
+
+       if (!(wrqu->retry.flags & IW_RETRY_LIMIT))
+               return 0;
+
+       down(&priv->action_sem);
+       if (!(priv->status & STATUS_INITIALIZED)) {
+               err = -EIO;
+               goto done;
+       }
+
+       if (wrqu->retry.flags & IW_RETRY_MIN) {
+               err = ipw2100_set_short_retry(priv, wrqu->retry.value);
+               IPW_DEBUG_WX("SET Short Retry Limit -> %d \n",
+                      wrqu->retry.value);
+               goto done;
+       }
+
+       if (wrqu->retry.flags & IW_RETRY_MAX) {
+               err = ipw2100_set_long_retry(priv, wrqu->retry.value);
+               IPW_DEBUG_WX("SET Long Retry Limit -> %d \n",
+                      wrqu->retry.value);
+               goto done;
+       }
+
+       err = ipw2100_set_short_retry(priv, wrqu->retry.value);
+       if (!err)
+               err = ipw2100_set_long_retry(priv, wrqu->retry.value);
+
+       IPW_DEBUG_WX("SET Both Retry Limits -> %d \n", wrqu->retry.value);
+
+ done:
+       up(&priv->action_sem);
+       return err;
+}
+
+static int ipw2100_wx_get_retry(struct net_device *dev,
+                               struct iw_request_info *info,
+                               union iwreq_data *wrqu, char *extra)
+{
+       /*
+        * This can be called at any time.  No action lock required
+        */
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+
+       wrqu->retry.disabled = 0; /* can't be disabled */
+
+       if ((wrqu->retry.flags & IW_RETRY_TYPE) ==
+           IW_RETRY_LIFETIME)
+               return -EINVAL;
+
+       if (wrqu->retry.flags & IW_RETRY_MAX) {
+               wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX;
+               wrqu->retry.value = priv->long_retry_limit;
+       } else {
+               wrqu->retry.flags =
+                   (priv->short_retry_limit !=
+                    priv->long_retry_limit) ?
+                   IW_RETRY_LIMIT & IW_RETRY_MIN : IW_RETRY_LIMIT;
+
+               wrqu->retry.value = priv->short_retry_limit;
+       }
+
+       IPW_DEBUG_WX("GET Retry -> %d \n", wrqu->retry.value);
+
+       return 0;
+}
+
+static int ipw2100_wx_set_scan(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       int err = 0;
+
+       down(&priv->action_sem);
+       if (!(priv->status & STATUS_INITIALIZED)) {
+               err = -EIO;
+               goto done;
+       }
+
+       IPW_DEBUG_WX("Initiating scan...\n");
+       if (ipw2100_set_scan_options(priv) ||
+           ipw2100_start_scan(priv)) {
+               IPW_DEBUG_WX("Start scan failed.\n");
+
+               /* TODO: Mark a scan as pending so when hardware initialized
+                *       a scan starts */
+       }
+
+ done:
+       up(&priv->action_sem);
+       return err;
+}
+
+static int ipw2100_wx_get_scan(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
+{
+       /*
+        * This can be called at any time.  No action lock required
+        */
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       return ieee80211_wx_get_scan(priv->ieee, info, wrqu, extra);
+}
+
+
+/*
+ * Implementation based on code in hostap-driver v0.1.3 hostap_ioctl.c
+ */
+static int ipw2100_wx_set_encode(struct net_device *dev,
+                                struct iw_request_info *info,
+                                union iwreq_data *wrqu, char *key)
+{
+       /*
+        * No check of STATUS_INITIALIZED required
+        */
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       return ieee80211_wx_set_encode(priv->ieee, info, wrqu, key);
+}
+
+static int ipw2100_wx_get_encode(struct net_device *dev,
+                                struct iw_request_info *info,
+                                union iwreq_data *wrqu, char *key)
+{
+       /*
+        * This can be called at any time.  No action lock required
+        */
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       return ieee80211_wx_get_encode(priv->ieee, info, wrqu, key);
+}
+
+static int ipw2100_wx_set_power(struct net_device *dev,
+                               struct iw_request_info *info,
+                               union iwreq_data *wrqu, char *extra)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       int err = 0;
+
+       down(&priv->action_sem);
+       if (!(priv->status & STATUS_INITIALIZED)) {
+               err = -EIO;
+               goto done;
+       }
+
+       if (wrqu->power.disabled) {
+               priv->power_mode = IPW_POWER_LEVEL(priv->power_mode);
+               err = ipw2100_set_power_mode(priv, IPW_POWER_MODE_CAM);
+               IPW_DEBUG_WX("SET Power Management Mode -> off\n");
+               goto done;
+       }
+
+       switch (wrqu->power.flags & IW_POWER_MODE) {
+       case IW_POWER_ON:    /* If not specified */
+       case IW_POWER_MODE:  /* If set all mask */
+       case IW_POWER_ALL_R: /* If explicitely state all */
+               break;
+       default: /* Otherwise we don't support it */
+               IPW_DEBUG_WX("SET PM Mode: %X not supported.\n",
+                            wrqu->power.flags);
+               err = -EOPNOTSUPP;
+               goto done;
+       }
+
+       /* If the user hasn't specified a power management mode yet, default
+        * to BATTERY */
+       priv->power_mode = IPW_POWER_ENABLED | priv->power_mode;
+       err = ipw2100_set_power_mode(priv, IPW_POWER_LEVEL(priv->power_mode));
+
+       IPW_DEBUG_WX("SET Power Management Mode -> 0x%02X\n",
+                    priv->power_mode);
+
+ done:
+       up(&priv->action_sem);
+       return err;
+
+}
+
+static int ipw2100_wx_get_power(struct net_device *dev,
+                               struct iw_request_info *info,
+                               union iwreq_data *wrqu, char *extra)
+{
+       /*
+        * This can be called at any time.  No action lock required
+        */
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+
+       if (!(priv->power_mode & IPW_POWER_ENABLED)) {
+               wrqu->power.disabled = 1;
+       } else {
+               wrqu->power.disabled = 0;
+               wrqu->power.flags = 0;
+       }
+
+       IPW_DEBUG_WX("GET Power Management Mode -> %02X\n", priv->power_mode);
+
+       return 0;
+}
+
+
+/*
+ *
+ * IWPRIV handlers
+ *
+ */
+#ifdef CONFIG_IPW2100_MONITOR
+static int ipw2100_wx_set_promisc(struct net_device *dev,
+                                 struct iw_request_info *info,
+                                 union iwreq_data *wrqu, char *extra)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       int *parms = (int *)extra;
+       int enable = (parms[0] > 0);
+       int err = 0;
+
+       down(&priv->action_sem);
+       if (!(priv->status & STATUS_INITIALIZED)) {
+               err = -EIO;
+               goto done;
+       }
+
+       if (enable) {
+               if (priv->ieee->iw_mode == IW_MODE_MONITOR) {
+                       err = ipw2100_set_channel(priv, parms[1], 0);
+                       goto done;
+               }
+               priv->channel = parms[1];
+               err = ipw2100_switch_mode(priv, IW_MODE_MONITOR);
+       } else {
+               if (priv->ieee->iw_mode == IW_MODE_MONITOR)
+                       err = ipw2100_switch_mode(priv, priv->last_mode);
+       }
+ done:
+       up(&priv->action_sem);
+       return err;
+}
+
+static int ipw2100_wx_reset(struct net_device *dev,
+                           struct iw_request_info *info,
+                           union iwreq_data *wrqu, char *extra)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       if (priv->status & STATUS_INITIALIZED)
+               schedule_reset(priv);
+       return 0;
+}
+
+#endif
+
+static int ipw2100_wx_set_powermode(struct net_device *dev,
+                                   struct iw_request_info *info,
+                                   union iwreq_data *wrqu, char *extra)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       int err = 0, mode = *(int *)extra;
+
+       down(&priv->action_sem);
+       if (!(priv->status & STATUS_INITIALIZED)) {
+               err = -EIO;
+               goto done;
+       }
+
+       if ((mode < 1) || (mode > POWER_MODES))
+               mode = IPW_POWER_AUTO;
+
+       if (priv->power_mode != mode)
+               err = ipw2100_set_power_mode(priv, mode);
+ done:
+       up(&priv->action_sem);
+       return err;
+}
+
+#define MAX_POWER_STRING 80
+static int ipw2100_wx_get_powermode(struct net_device *dev,
+                                   struct iw_request_info *info,
+                                   union iwreq_data *wrqu, char *extra)
+{
+       /*
+        * This can be called at any time.  No action lock required
+        */
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       int level = IPW_POWER_LEVEL(priv->power_mode);
+       s32 timeout, period;
+
+       if (!(priv->power_mode & IPW_POWER_ENABLED)) {
+               snprintf(extra, MAX_POWER_STRING,
+                        "Power save level: %d (Off)", level);
+       } else {
+               switch (level) {
+               case IPW_POWER_MODE_CAM:
+                       snprintf(extra, MAX_POWER_STRING,
+                                "Power save level: %d (None)", level);
+                       break;
+               case IPW_POWER_AUTO:
+               snprintf(extra, MAX_POWER_STRING,
+                        "Power save level: %d (Auto)", 0);
+                       break;
+               default:
+                       timeout = timeout_duration[level - 1] / 1000;
+                       period = period_duration[level - 1] / 1000;
+                       snprintf(extra, MAX_POWER_STRING,
+                                "Power save level: %d "
+                                "(Timeout %dms, Period %dms)",
+                                level, timeout, period);
+               }
+       }
+
+       wrqu->data.length = strlen(extra) + 1;
+
+       return 0;
+}
+
+
+static int ipw2100_wx_set_preamble(struct net_device *dev,
+                                  struct iw_request_info *info,
+                                  union iwreq_data *wrqu, char *extra)
+{
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       int err, mode = *(int *)extra;
+
+       down(&priv->action_sem);
+       if (!(priv->status & STATUS_INITIALIZED)) {
+               err = -EIO;
+               goto done;
+       }
+
+       if (mode == 1)
+               priv->config |= CFG_LONG_PREAMBLE;
+       else if (mode == 0)
+               priv->config &= ~CFG_LONG_PREAMBLE;
+       else {
+               err = -EINVAL;
+               goto done;
+       }
+
+       err = ipw2100_system_config(priv, 0);
+
+done:
+       up(&priv->action_sem);
+       return err;
+}
+
+static int ipw2100_wx_get_preamble(struct net_device *dev,
+                                   struct iw_request_info *info,
+                                   union iwreq_data *wrqu, char *extra)
+{
+       /*
+        * This can be called at any time.  No action lock required
+        */
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+
+       if (priv->config & CFG_LONG_PREAMBLE)
+               snprintf(wrqu->name, IFNAMSIZ, "long (1)");
+       else
+               snprintf(wrqu->name, IFNAMSIZ, "auto (0)");
+
+       return 0;
+}
+
+static iw_handler ipw2100_wx_handlers[] =
+{
+        NULL,                     /* SIOCSIWCOMMIT */
+        ipw2100_wx_get_name,      /* SIOCGIWNAME */
+        NULL,                     /* SIOCSIWNWID */
+        NULL,                     /* SIOCGIWNWID */
+        ipw2100_wx_set_freq,      /* SIOCSIWFREQ */
+        ipw2100_wx_get_freq,      /* SIOCGIWFREQ */
+        ipw2100_wx_set_mode,      /* SIOCSIWMODE */
+        ipw2100_wx_get_mode,      /* SIOCGIWMODE */
+        NULL,                     /* SIOCSIWSENS */
+        NULL,                     /* SIOCGIWSENS */
+        NULL,                     /* SIOCSIWRANGE */
+        ipw2100_wx_get_range,     /* SIOCGIWRANGE */
+        NULL,                     /* SIOCSIWPRIV */
+        NULL,                     /* SIOCGIWPRIV */
+        NULL,                     /* SIOCSIWSTATS */
+        NULL,                     /* SIOCGIWSTATS */
+        NULL,                     /* SIOCSIWSPY */
+        NULL,                     /* SIOCGIWSPY */
+        NULL,                     /* SIOCGIWTHRSPY */
+        NULL,                     /* SIOCWIWTHRSPY */
+        ipw2100_wx_set_wap,       /* SIOCSIWAP */
+        ipw2100_wx_get_wap,       /* SIOCGIWAP */
+        NULL,                     /* -- hole -- */
+        NULL,                     /* SIOCGIWAPLIST -- deprecated */
+        ipw2100_wx_set_scan,      /* SIOCSIWSCAN */
+        ipw2100_wx_get_scan,      /* SIOCGIWSCAN */
+        ipw2100_wx_set_essid,     /* SIOCSIWESSID */
+        ipw2100_wx_get_essid,     /* SIOCGIWESSID */
+        ipw2100_wx_set_nick,      /* SIOCSIWNICKN */
+        ipw2100_wx_get_nick,      /* SIOCGIWNICKN */
+        NULL,                     /* -- hole -- */
+        NULL,                     /* -- hole -- */
+        ipw2100_wx_set_rate,      /* SIOCSIWRATE */
+        ipw2100_wx_get_rate,      /* SIOCGIWRATE */
+        ipw2100_wx_set_rts,       /* SIOCSIWRTS */
+        ipw2100_wx_get_rts,       /* SIOCGIWRTS */
+        ipw2100_wx_set_frag,      /* SIOCSIWFRAG */
+        ipw2100_wx_get_frag,      /* SIOCGIWFRAG */
+        ipw2100_wx_set_txpow,     /* SIOCSIWTXPOW */
+        ipw2100_wx_get_txpow,     /* SIOCGIWTXPOW */
+        ipw2100_wx_set_retry,     /* SIOCSIWRETRY */
+        ipw2100_wx_get_retry,     /* SIOCGIWRETRY */
+        ipw2100_wx_set_encode,    /* SIOCSIWENCODE */
+        ipw2100_wx_get_encode,    /* SIOCGIWENCODE */
+        ipw2100_wx_set_power,     /* SIOCSIWPOWER */
+        ipw2100_wx_get_power,     /* SIOCGIWPOWER */
+};
+
+#define IPW2100_PRIV_SET_MONITOR       SIOCIWFIRSTPRIV
+#define IPW2100_PRIV_RESET             SIOCIWFIRSTPRIV+1
+#define IPW2100_PRIV_SET_POWER         SIOCIWFIRSTPRIV+2
+#define IPW2100_PRIV_GET_POWER         SIOCIWFIRSTPRIV+3
+#define IPW2100_PRIV_SET_LONGPREAMBLE  SIOCIWFIRSTPRIV+4
+#define IPW2100_PRIV_GET_LONGPREAMBLE  SIOCIWFIRSTPRIV+5
+
+static const struct iw_priv_args ipw2100_private_args[] = {
+
+#ifdef CONFIG_IPW2100_MONITOR
+       {
+               IPW2100_PRIV_SET_MONITOR,
+               IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "monitor"
+       },
+       {
+               IPW2100_PRIV_RESET,
+               IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 0, 0, "reset"
+       },
+#endif /* CONFIG_IPW2100_MONITOR */
+
+       {
+               IPW2100_PRIV_SET_POWER,
+               IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_power"
+       },
+       {
+               IPW2100_PRIV_GET_POWER,
+               0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_POWER_STRING, "get_power"
+       },
+       {
+               IPW2100_PRIV_SET_LONGPREAMBLE,
+               IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_preamble"
+       },
+       {
+               IPW2100_PRIV_GET_LONGPREAMBLE,
+               0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "get_preamble"
+       },
+};
+
+static iw_handler ipw2100_private_handler[] = {
+#ifdef CONFIG_IPW2100_MONITOR
+       ipw2100_wx_set_promisc,
+       ipw2100_wx_reset,
+#else /* CONFIG_IPW2100_MONITOR */
+       NULL,
+       NULL,
+#endif /* CONFIG_IPW2100_MONITOR */
+       ipw2100_wx_set_powermode,
+       ipw2100_wx_get_powermode,
+       ipw2100_wx_set_preamble,
+       ipw2100_wx_get_preamble,
+};
+
+static struct iw_handler_def ipw2100_wx_handler_def =
+{
+       .standard = ipw2100_wx_handlers,
+       .num_standard = sizeof(ipw2100_wx_handlers) / sizeof(iw_handler),
+       .num_private = sizeof(ipw2100_private_handler) / sizeof(iw_handler),
+       .num_private_args = sizeof(ipw2100_private_args) /
+       sizeof(struct iw_priv_args),
+       .private = (iw_handler *)ipw2100_private_handler,
+       .private_args = (struct iw_priv_args *)ipw2100_private_args,
+};
+
+/*
+ * Get wireless statistics.
+ * Called by /proc/net/wireless
+ * Also called by SIOCGIWSTATS
+ */
+static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev)
+{
+       enum {
+               POOR = 30,
+               FAIR = 60,
+               GOOD = 80,
+               VERY_GOOD = 90,
+               EXCELLENT = 95,
+               PERFECT = 100
+       };
+       int rssi_qual;
+       int tx_qual;
+       int beacon_qual;
+
+       struct ipw2100_priv *priv = ieee80211_priv(dev);
+       struct iw_statistics *wstats;
+       u32 rssi, quality, tx_retries, missed_beacons, tx_failures;
+       u32 ord_len = sizeof(u32);
+
+       if (!priv)
+               return (struct iw_statistics *) NULL;
+
+       wstats = &priv->wstats;
+
+       /* if hw is disabled, then ipw2100_get_ordinal() can't be called.
+        * ipw2100_wx_wireless_stats seems to be called before fw is
+        * initialized.  STATUS_ASSOCIATED will only be set if the hw is up
+        * and associated; if not associcated, the values are all meaningless
+        * anyway, so set them all to NULL and INVALID */
+       if (!(priv->status & STATUS_ASSOCIATED)) {
+               wstats->miss.beacon = 0;
+               wstats->discard.retries = 0;
+               wstats->qual.qual = 0;
+               wstats->qual.level = 0;
+               wstats->qual.noise = 0;
+               wstats->qual.updated = 7;
+               wstats->qual.updated |= IW_QUAL_NOISE_INVALID |
+                       IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID;
+               return wstats;
+       }
+
+       if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_PERCENT_MISSED_BCNS,
+                               &missed_beacons, &ord_len))
+               goto fail_get_ordinal;
+
+        /* If we don't have a connection the quality and level is 0*/
+       if (!(priv->status & STATUS_ASSOCIATED)) {
+               wstats->qual.qual = 0;
+               wstats->qual.level = 0;
+       } else {
+               if (ipw2100_get_ordinal(priv, IPW_ORD_RSSI_AVG_CURR,
+                                       &rssi, &ord_len))
+                       goto fail_get_ordinal;
+               wstats->qual.level = rssi + IPW2100_RSSI_TO_DBM;
+               if (rssi < 10)
+                       rssi_qual = rssi * POOR / 10;
+               else if (rssi < 15)
+                       rssi_qual = (rssi - 10) * (FAIR - POOR) / 5 + POOR;
+               else if (rssi < 20)
+                       rssi_qual = (rssi - 15) * (GOOD - FAIR) / 5 + FAIR;
+               else if (rssi < 30)
+                       rssi_qual = (rssi - 20) * (VERY_GOOD - GOOD) /
+                               10 + GOOD;
+               else
+                       rssi_qual = (rssi - 30) * (PERFECT - VERY_GOOD) /
+                               10 + VERY_GOOD;
+
+               if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_PERCENT_RETRIES,
+                                       &tx_retries, &ord_len))
+                       goto fail_get_ordinal;
+
+               if (tx_retries > 75)
+                       tx_qual = (90 - tx_retries) * POOR / 15;
+               else if (tx_retries > 70)
+                       tx_qual = (75 - tx_retries) * (FAIR - POOR) / 5 + POOR;
+               else if (tx_retries > 65)
+                       tx_qual = (70 - tx_retries) * (GOOD - FAIR) / 5 + FAIR;
+               else if (tx_retries > 50)
+                       tx_qual = (65 - tx_retries) * (VERY_GOOD - GOOD) /
+                               15 + GOOD;
+               else
+                       tx_qual = (50 - tx_retries) *
+                               (PERFECT - VERY_GOOD) / 50 + VERY_GOOD;
+
+               if (missed_beacons > 50)
+                       beacon_qual = (60 - missed_beacons) * POOR / 10;
+               else if (missed_beacons > 40)
+                       beacon_qual = (50 - missed_beacons) * (FAIR - POOR) /
+                               10 + POOR;
+               else if (missed_beacons > 32)
+                       beacon_qual = (40 - missed_beacons) * (GOOD - FAIR) /
+                               18 + FAIR;
+               else if (missed_beacons > 20)
+                       beacon_qual = (32 - missed_beacons) *
+                               (VERY_GOOD - GOOD) / 20 + GOOD;
+               else
+                       beacon_qual = (20 - missed_beacons) *
+                               (PERFECT - VERY_GOOD) / 20 + VERY_GOOD;
+
+               quality = min(beacon_qual, min(tx_qual, rssi_qual));
+
+#ifdef CONFIG_IPW_DEBUG
+               if (beacon_qual == quality)
+                       IPW_DEBUG_WX("Quality clamped by Missed Beacons\n");
+               else if (tx_qual == quality)
+                       IPW_DEBUG_WX("Quality clamped by Tx Retries\n");
+               else if (quality != 100)
+                       IPW_DEBUG_WX("Quality clamped by Signal Strength\n");
+               else
+                       IPW_DEBUG_WX("Quality not clamped.\n");
+#endif
+
+               wstats->qual.qual = quality;
+               wstats->qual.level = rssi + IPW2100_RSSI_TO_DBM;
+       }
+
+       wstats->qual.noise = 0;
+       wstats->qual.updated = 7;
+       wstats->qual.updated |= IW_QUAL_NOISE_INVALID;
+
+        /* FIXME: this is percent and not a # */
+       wstats->miss.beacon = missed_beacons;
+
+       if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_TX_FAILURES,
+                               &tx_failures, &ord_len))
+               goto fail_get_ordinal;
+       wstats->discard.retries = tx_failures;
+
+       return wstats;
+
+ fail_get_ordinal:
+       IPW_DEBUG_WX("failed querying ordinals.\n");
+
+       return (struct iw_statistics *) NULL;
+}
+
+static void ipw2100_wx_event_work(struct ipw2100_priv *priv)
+{
+       union iwreq_data wrqu;
+       int len = ETH_ALEN;
+
+       if (priv->status & STATUS_STOPPING)
+               return;
+
+       down(&priv->action_sem);
+
+       IPW_DEBUG_WX("enter\n");
+
+       up(&priv->action_sem);
+
+       wrqu.ap_addr.sa_family = ARPHRD_ETHER;
+
+       /* Fetch BSSID from the hardware */
+       if (!(priv->status & (STATUS_ASSOCIATING | STATUS_ASSOCIATED)) ||
+           priv->status & STATUS_RF_KILL_MASK ||
+           ipw2100_get_ordinal(priv, IPW_ORD_STAT_ASSN_AP_BSSID,
+                               &priv->bssid,  &len)) {
+               memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
+       } else {
+               /* We now have the BSSID, so can finish setting to the full
+                * associated state */
+               memcpy(wrqu.ap_addr.sa_data, priv->bssid, ETH_ALEN);
+               memcpy(&priv->ieee->bssid, priv->bssid, ETH_ALEN);
+               priv->status &= ~STATUS_ASSOCIATING;
+               priv->status |= STATUS_ASSOCIATED;
+               netif_carrier_on(priv->net_dev);
+               if (netif_queue_stopped(priv->net_dev)) {
+                       IPW_DEBUG_INFO("Waking net queue.\n");
+                       netif_wake_queue(priv->net_dev);
+               } else {
+                       IPW_DEBUG_INFO("Starting net queue.\n");
+                       netif_start_queue(priv->net_dev);
+               }
+       }
+
+       if (!(priv->status & STATUS_ASSOCIATED)) {
+               IPW_DEBUG_WX("Configuring ESSID\n");
+               down(&priv->action_sem);
+               /* This is a disassociation event, so kick the firmware to
+                * look for another AP */
+               if (priv->config & CFG_STATIC_ESSID)
+                       ipw2100_set_essid(priv, priv->essid, priv->essid_len, 0);
+               else
+                       ipw2100_set_essid(priv, NULL, 0, 0);
+               up(&priv->action_sem);
+       }
+
+       wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL);
+}
+
+#define IPW2100_FW_MAJOR_VERSION 1
+#define IPW2100_FW_MINOR_VERSION 3
+
+#define IPW2100_FW_MINOR(x) ((x & 0xff) >> 8)
+#define IPW2100_FW_MAJOR(x) (x & 0xff)
+
+#define IPW2100_FW_VERSION ((IPW2100_FW_MINOR_VERSION << 8) | \
+                             IPW2100_FW_MAJOR_VERSION)
+
+#define IPW2100_FW_PREFIX "ipw2100-" __stringify(IPW2100_FW_MAJOR_VERSION) \
+"." __stringify(IPW2100_FW_MINOR_VERSION)
+
+#define IPW2100_FW_NAME(x) IPW2100_FW_PREFIX "" x ".fw"
+
+
+/*
+
+BINARY FIRMWARE HEADER FORMAT
+
+offset      length   desc
+0           2        version
+2           2        mode == 0:BSS,1:IBSS,2:MONITOR
+4           4        fw_len
+8           4        uc_len
+C           fw_len   firmware data
+12 + fw_len uc_len   microcode data
+
+*/
+
+struct ipw2100_fw_header {
+       short version;
+       short mode;
+       unsigned int fw_size;
+       unsigned int uc_size;
+} __attribute__ ((packed));
+
+
+
+static int ipw2100_mod_firmware_load(struct ipw2100_fw *fw)
+{
+       struct ipw2100_fw_header *h =
+               (struct ipw2100_fw_header *)fw->fw_entry->data;
+
+       if (IPW2100_FW_MAJOR(h->version) != IPW2100_FW_MAJOR_VERSION) {
+               printk(KERN_WARNING DRV_NAME ": Firmware image not compatible "
+                      "(detected version id of %u). "
+                      "See Documentation/networking/README.ipw2100\n",
+                      h->version);
+               return 1;
+       }
+
+       fw->version = h->version;
+       fw->fw.data = fw->fw_entry->data + sizeof(struct ipw2100_fw_header);
+       fw->fw.size = h->fw_size;
+       fw->uc.data = fw->fw.data + h->fw_size;
+       fw->uc.size = h->uc_size;
+
+       return 0;
+}
+
+
+static int ipw2100_get_firmware(struct ipw2100_priv *priv,
+                               struct ipw2100_fw *fw)
+{
+       char *fw_name;
+       int rc;
+
+       IPW_DEBUG_INFO("%s: Using hotplug firmware load.\n",
+              priv->net_dev->name);
+
+       switch (priv->ieee->iw_mode) {
+       case IW_MODE_ADHOC:
+               fw_name = IPW2100_FW_NAME("-i");
+               break;
+#ifdef CONFIG_IPW2100_MONITOR
+       case IW_MODE_MONITOR:
+               fw_name = IPW2100_FW_NAME("-p");
+               break;
+#endif
+       case IW_MODE_INFRA:
+       default:
+               fw_name = IPW2100_FW_NAME("");
+               break;
+       }
+
+       rc = request_firmware(&fw->fw_entry, fw_name, &priv->pci_dev->dev);
+
+       if (rc < 0) {
+               printk(KERN_ERR DRV_NAME ": "
+                      "%s: Firmware '%s' not available or load failed.\n",
+                      priv->net_dev->name, fw_name);
+               return rc;
+       }
+       IPW_DEBUG_INFO("firmware data %p size %zd\n", fw->fw_entry->data,
+                          fw->fw_entry->size);
+
+       ipw2100_mod_firmware_load(fw);
+
+       return 0;
+}
+
+static void ipw2100_release_firmware(struct ipw2100_priv *priv,
+                                    struct ipw2100_fw *fw)
+{
+       fw->version = 0;
+       if (fw->fw_entry)
+               release_firmware(fw->fw_entry);
+       fw->fw_entry = NULL;
+}
+
+
+static int ipw2100_get_fwversion(struct ipw2100_priv *priv, char *buf,
+                                size_t max)
+{
+       char ver[MAX_FW_VERSION_LEN];
+       u32 len = MAX_FW_VERSION_LEN;
+       u32 tmp;
+       int i;
+       /* firmware version is an ascii string (max len of 14) */
+       if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_FW_VER_NUM,
+                               ver, &len))
+               return -EIO;
+       tmp = max;
+       if (len >= max)
+               len = max - 1;
+       for (i = 0; i < len; i++)
+               buf[i] = ver[i];
+       buf[i] = '\0';
+       return tmp;
+}
+
+static int ipw2100_get_ucodeversion(struct ipw2100_priv *priv, char *buf,
+                                   size_t max)
+{
+       u32 ver;
+       u32 len = sizeof(ver);
+       /* microcode version is a 32 bit integer */
+       if (ipw2100_get_ordinal(priv, IPW_ORD_UCODE_VERSION,
+                               &ver, &len))
+               return -EIO;
+       return snprintf(buf, max, "%08X", ver);
+}
+
+/*
+ * On exit, the firmware will have been freed from the fw list
+ */
+static int ipw2100_fw_download(struct ipw2100_priv *priv,
+                              struct ipw2100_fw *fw)
+{
+       /* firmware is constructed of N contiguous entries, each entry is
+        * structured as:
+        *
+        * offset    sie         desc
+        * 0         4           address to write to
+        * 4         2           length of data run
+         * 6         length      data
+        */
+       unsigned int addr;
+       unsigned short len;
+
+       const unsigned char *firmware_data = fw->fw.data;
+       unsigned int firmware_data_left = fw->fw.size;
+
+       while (firmware_data_left > 0) {
+               addr = *(u32 *)(firmware_data);
+               firmware_data      += 4;
+               firmware_data_left -= 4;
+
+               len = *(u16 *)(firmware_data);
+               firmware_data      += 2;
+               firmware_data_left -= 2;
+
+               if (len > 32) {
+                       printk(KERN_ERR DRV_NAME ": "
+                              "Invalid firmware run-length of %d bytes\n",
+                              len);
+                       return -EINVAL;
+               }
+
+               write_nic_memory(priv->net_dev, addr, len, firmware_data);
+               firmware_data      += len;
+               firmware_data_left -= len;
+       }
+
+       return 0;
+}
+
+struct symbol_alive_response {
+       u8 cmd_id;
+       u8 seq_num;
+       u8 ucode_rev;
+       u8 eeprom_valid;
+       u16 valid_flags;
+       u8 IEEE_addr[6];
+       u16 flags;
+       u16 pcb_rev;
+       u16 clock_settle_time;  // 1us LSB
+       u16 powerup_settle_time;        // 1us LSB
+       u16 hop_settle_time;    // 1us LSB
+       u8 date[3];             // month, day, year
+       u8 time[2];             // hours, minutes
+       u8 ucode_valid;
+};
+
+static int ipw2100_ucode_download(struct ipw2100_priv *priv,
+                                 struct ipw2100_fw *fw)
+{
+       struct net_device *dev = priv->net_dev;
+       const unsigned char *microcode_data = fw->uc.data;
+       unsigned int microcode_data_left = fw->uc.size;
+       void __iomem *reg = (void __iomem *)dev->base_addr;
+
+       struct symbol_alive_response response;
+       int i, j;
+       u8 data;
+
+       /* Symbol control */
+       write_nic_word(dev, IPW2100_CONTROL_REG, 0x703);
+       readl(reg);
+       write_nic_word(dev, IPW2100_CONTROL_REG, 0x707);
+       readl(reg);
+
+       /* HW config */
+       write_nic_byte(dev, 0x210014, 0x72);    /* fifo width =16 */
+       readl(reg);
+       write_nic_byte(dev, 0x210014, 0x72);    /* fifo width =16 */
+       readl(reg);
+
+       /* EN_CS_ACCESS bit to reset control store pointer */
+       write_nic_byte(dev, 0x210000, 0x40);
+       readl(reg);
+       write_nic_byte(dev, 0x210000, 0x0);
+       readl(reg);
+       write_nic_byte(dev, 0x210000, 0x40);
+       readl(reg);
+
+       /* copy microcode from buffer into Symbol */
+
+       while (microcode_data_left > 0) {
+               write_nic_byte(dev, 0x210010, *microcode_data++);
+               write_nic_byte(dev, 0x210010, *microcode_data++);
+               microcode_data_left -= 2;
+       }
+
+       /* EN_CS_ACCESS bit to reset the control store pointer */
+       write_nic_byte(dev, 0x210000, 0x0);
+       readl(reg);
+
+       /* Enable System (Reg 0)
+        * first enable causes garbage in RX FIFO */
+       write_nic_byte(dev, 0x210000, 0x0);
+       readl(reg);
+       write_nic_byte(dev, 0x210000, 0x80);
+       readl(reg);
+
+       /* Reset External Baseband Reg */
+       write_nic_word(dev, IPW2100_CONTROL_REG, 0x703);
+       readl(reg);
+       write_nic_word(dev, IPW2100_CONTROL_REG, 0x707);
+       readl(reg);
+
+       /* HW Config (Reg 5) */
+       write_nic_byte(dev, 0x210014, 0x72);    // fifo width =16
+       readl(reg);
+       write_nic_byte(dev, 0x210014, 0x72);    // fifo width =16
+       readl(reg);
+
+       /* Enable System (Reg 0)
+        * second enable should be OK */
+       write_nic_byte(dev, 0x210000, 0x00);    // clear enable system
+       readl(reg);
+       write_nic_byte(dev, 0x210000, 0x80);    // set enable system
+
+       /* check Symbol is enabled - upped this from 5 as it wasn't always
+        * catching the update */
+       for (i = 0; i < 10; i++) {
+               udelay(10);
+
+               /* check Dino is enabled bit */
+               read_nic_byte(dev, 0x210000, &data);
+               if (data & 0x1)
+                       break;
+       }
+
+       if (i == 10) {
+               printk(KERN_ERR DRV_NAME ": %s: Error initializing Symbol\n",
+                      dev->name);
+               return -EIO;
+       }
+
+       /* Get Symbol alive response */
+       for (i = 0; i < 30; i++) {
+               /* Read alive response structure */
+               for (j = 0;
+                    j < (sizeof(struct symbol_alive_response) >> 1);
+                    j++)
+                       read_nic_word(dev, 0x210004,
+                                     ((u16 *)&response) + j);
+
+               if ((response.cmd_id == 1) &&
+                   (response.ucode_valid == 0x1))
+                       break;
+               udelay(10);
+       }
+
+       if (i == 30) {
+               printk(KERN_ERR DRV_NAME ": %s: No response from Symbol - hw not alive\n",
+                      dev->name);
+               printk_buf(IPW_DL_ERROR, (u8*)&response, sizeof(response));
+               return -EIO;
+       }
+
+       return 0;
+}
diff --git a/drivers/net/wireless/ipw2100.h b/drivers/net/wireless/ipw2100.h
new file mode 100644 (file)
index 0000000..2a3cdbd
--- /dev/null
@@ -0,0 +1,1167 @@
+/******************************************************************************
+
+  Copyright(c) 2003 - 2005 Intel Corporation. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms of version 2 of the GNU General Public License as
+  published by the Free Software Foundation.
+
+  This program is distributed in the hope that it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc., 59
+  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+  The full GNU General Public License is included in this distribution in the
+  file called LICENSE.
+
+  Contact Information:
+  James P. Ketrenos <ipw2100-admin@linux.intel.com>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+******************************************************************************/
+#ifndef _IPW2100_H
+#define _IPW2100_H
+
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/list.h>
+#include <linux/delay.h>
+#include <linux/skbuff.h>
+#include <asm/io.h>
+#include <linux/socket.h>
+#include <linux/if_arp.h>
+#include <linux/wireless.h>
+#include <linux/version.h>
+#include <net/iw_handler.h>    // new driver API
+
+#include <net/ieee80211.h>
+
+#include <linux/workqueue.h>
+
+struct ipw2100_priv;
+struct ipw2100_tx_packet;
+struct ipw2100_rx_packet;
+
+#define IPW_DL_UNINIT    0x80000000
+#define IPW_DL_NONE      0x00000000
+#define IPW_DL_ALL       0x7FFFFFFF
+
+/*
+ * To use the debug system;
+ *
+ * If you are defining a new debug classification, simply add it to the #define
+ * list here in the form of:
+ *
+ * #define IPW_DL_xxxx VALUE
+ *
+ * shifting value to the left one bit from the previous entry.  xxxx should be
+ * the name of the classification (for example, WEP)
+ *
+ * You then need to either add a IPW2100_xxxx_DEBUG() macro definition for your
+ * classification, or use IPW_DEBUG(IPW_DL_xxxx, ...) whenever you want
+ * to send output to that classification.
+ *
+ * To add your debug level to the list of levels seen when you perform
+ *
+ * % cat /proc/net/ipw2100/debug_level
+ *
+ * you simply need to add your entry to the ipw2100_debug_levels array.
+ *
+ * If you do not see debug_level in /proc/net/ipw2100 then you do not have
+ * CONFIG_IPW_DEBUG defined in your kernel configuration
+ *
+ */
+
+#define IPW_DL_ERROR         (1<<0)
+#define IPW_DL_WARNING       (1<<1)
+#define IPW_DL_INFO          (1<<2)
+#define IPW_DL_WX            (1<<3)
+#define IPW_DL_HC            (1<<5)
+#define IPW_DL_STATE         (1<<6)
+
+#define IPW_DL_NOTIF         (1<<10)
+#define IPW_DL_SCAN          (1<<11)
+#define IPW_DL_ASSOC         (1<<12)
+#define IPW_DL_DROP          (1<<13)
+
+#define IPW_DL_IOCTL         (1<<14)
+#define IPW_DL_RF_KILL       (1<<17)
+
+
+#define IPW_DL_MANAGE        (1<<15)
+#define IPW_DL_FW            (1<<16)
+
+#define IPW_DL_FRAG          (1<<21)
+#define IPW_DL_WEP           (1<<22)
+#define IPW_DL_TX            (1<<23)
+#define IPW_DL_RX            (1<<24)
+#define IPW_DL_ISR           (1<<25)
+#define IPW_DL_IO            (1<<26)
+#define IPW_DL_TRACE         (1<<28)
+
+#define IPW_DEBUG_ERROR(f, a...) printk(KERN_ERR DRV_NAME ": " f, ## a)
+#define IPW_DEBUG_WARNING(f, a...) printk(KERN_WARNING DRV_NAME ": " f, ## a)
+#define IPW_DEBUG_INFO(f...)    IPW_DEBUG(IPW_DL_INFO, ## f)
+#define IPW_DEBUG_WX(f...)     IPW_DEBUG(IPW_DL_WX, ## f)
+#define IPW_DEBUG_SCAN(f...)   IPW_DEBUG(IPW_DL_SCAN, ## f)
+#define IPW_DEBUG_NOTIF(f...) IPW_DEBUG(IPW_DL_NOTIF, ## f)
+#define IPW_DEBUG_TRACE(f...)  IPW_DEBUG(IPW_DL_TRACE, ## f)
+#define IPW_DEBUG_RX(f...)     IPW_DEBUG(IPW_DL_RX, ## f)
+#define IPW_DEBUG_TX(f...)     IPW_DEBUG(IPW_DL_TX, ## f)
+#define IPW_DEBUG_ISR(f...)    IPW_DEBUG(IPW_DL_ISR, ## f)
+#define IPW_DEBUG_MANAGEMENT(f...) IPW_DEBUG(IPW_DL_MANAGE, ## f)
+#define IPW_DEBUG_WEP(f...)    IPW_DEBUG(IPW_DL_WEP, ## f)
+#define IPW_DEBUG_HC(f...) IPW_DEBUG(IPW_DL_HC, ## f)
+#define IPW_DEBUG_FRAG(f...) IPW_DEBUG(IPW_DL_FRAG, ## f)
+#define IPW_DEBUG_FW(f...) IPW_DEBUG(IPW_DL_FW, ## f)
+#define IPW_DEBUG_RF_KILL(f...) IPW_DEBUG(IPW_DL_RF_KILL, ## f)
+#define IPW_DEBUG_DROP(f...) IPW_DEBUG(IPW_DL_DROP, ## f)
+#define IPW_DEBUG_IO(f...) IPW_DEBUG(IPW_DL_IO, ## f)
+#define IPW_DEBUG_IOCTL(f...) IPW_DEBUG(IPW_DL_IOCTL, ## f)
+#define IPW_DEBUG_STATE(f, a...) IPW_DEBUG(IPW_DL_STATE | IPW_DL_ASSOC | IPW_DL_INFO, f, ## a)
+#define IPW_DEBUG_ASSOC(f, a...) IPW_DEBUG(IPW_DL_ASSOC | IPW_DL_INFO, f, ## a)
+
+enum {
+       IPW_HW_STATE_DISABLED = 1,
+       IPW_HW_STATE_ENABLED = 0
+};
+
+struct ssid_context {
+       char ssid[IW_ESSID_MAX_SIZE + 1];
+       int ssid_len;
+       unsigned char bssid[ETH_ALEN];
+       int port_type;
+       int channel;
+
+};
+
+extern const char *port_type_str[];
+extern const char *band_str[];
+
+#define NUMBER_OF_BD_PER_COMMAND_PACKET                1
+#define NUMBER_OF_BD_PER_DATA_PACKET           2
+
+#define IPW_MAX_BDS 6
+#define NUMBER_OF_OVERHEAD_BDS_PER_PACKETR     2
+#define NUMBER_OF_BDS_TO_LEAVE_FOR_COMMANDS    1
+
+#define REQUIRED_SPACE_IN_RING_FOR_COMMAND_PACKET \
+    (IPW_BD_QUEUE_W_R_MIN_SPARE + NUMBER_OF_BD_PER_COMMAND_PACKET)
+
+struct bd_status {
+       union {
+               struct { u8 nlf:1, txType:2, intEnabled:1, reserved:4;} fields;
+               u8 field;
+       } info;
+} __attribute__ ((packed));
+
+struct ipw2100_bd {
+       u32 host_addr;
+       u32 buf_length;
+       struct bd_status status;
+        /* number of fragments for frame (should be set only for
+        * 1st TBD) */
+       u8 num_fragments;
+       u8 reserved[6];
+} __attribute__ ((packed));
+
+#define IPW_BD_QUEUE_LENGTH(n) (1<<n)
+#define IPW_BD_ALIGNMENT(L)    (L*sizeof(struct ipw2100_bd))
+
+#define IPW_BD_STATUS_TX_FRAME_802_3             0x00
+#define IPW_BD_STATUS_TX_FRAME_NOT_LAST_FRAGMENT 0x01
+#define IPW_BD_STATUS_TX_FRAME_COMMAND          0x02
+#define IPW_BD_STATUS_TX_FRAME_802_11           0x04
+#define IPW_BD_STATUS_TX_INTERRUPT_ENABLE       0x08
+
+struct ipw2100_bd_queue {
+       /* driver (virtual) pointer to queue */
+       struct ipw2100_bd *drv;
+
+       /* firmware (physical) pointer to queue */
+       dma_addr_t nic;
+
+       /* Length of phy memory allocated for BDs */
+       u32 size;
+
+       /* Number of BDs in queue (and in array) */
+       u32 entries;
+
+       /* Number of available BDs (invalid for NIC BDs) */
+       u32 available;
+
+       /* Offset of oldest used BD in array (next one to
+        * check for completion) */
+       u32 oldest;
+
+       /* Offset of next available (unused) BD */
+       u32 next;
+};
+
+#define RX_QUEUE_LENGTH 256
+#define TX_QUEUE_LENGTH 256
+#define HW_QUEUE_LENGTH 256
+
+#define TX_PENDED_QUEUE_LENGTH (TX_QUEUE_LENGTH / NUMBER_OF_BD_PER_DATA_PACKET)
+
+#define STATUS_TYPE_MASK       0x0000000f
+#define COMMAND_STATUS_VAL     0
+#define STATUS_CHANGE_VAL      1
+#define P80211_DATA_VAL        2
+#define P8023_DATA_VAL         3
+#define HOST_NOTIFICATION_VAL  4
+
+#define IPW2100_RSSI_TO_DBM (-98)
+
+struct ipw2100_status {
+       u32 frame_size;
+       u16 status_fields;
+       u8 flags;
+#define IPW_STATUS_FLAG_DECRYPTED      (1<<0)
+#define IPW_STATUS_FLAG_WEP_ENCRYPTED  (1<<1)
+#define IPW_STATUS_FLAG_CRC_ERROR       (1<<2)
+       u8 rssi;
+} __attribute__ ((packed));
+
+struct ipw2100_status_queue {
+       /* driver (virtual) pointer to queue */
+       struct ipw2100_status *drv;
+
+       /* firmware (physical) pointer to queue */
+       dma_addr_t nic;
+
+       /* Length of phy memory allocated for BDs */
+       u32 size;
+};
+
+#define HOST_COMMAND_PARAMS_REG_LEN    100
+#define CMD_STATUS_PARAMS_REG_LEN      3
+
+#define IPW_WPA_CAPABILITIES   0x1
+#define IPW_WPA_LISTENINTERVAL 0x2
+#define IPW_WPA_AP_ADDRESS     0x4
+
+#define IPW_MAX_VAR_IE_LEN ((HOST_COMMAND_PARAMS_REG_LEN - 4) * sizeof(u32))
+
+struct ipw2100_wpa_assoc_frame {
+       u16 fixed_ie_mask;
+       struct {
+               u16 capab_info;
+               u16 listen_interval;
+               u8 current_ap[ETH_ALEN];
+       } fixed_ies;
+       u32 var_ie_len;
+       u8 var_ie[IPW_MAX_VAR_IE_LEN];
+};
+
+#define IPW_BSS     1
+#define IPW_MONITOR 2
+#define IPW_IBSS    3
+
+/**
+ * @struct _tx_cmd - HWCommand
+ * @brief H/W command structure.
+ */
+struct ipw2100_cmd_header {
+       u32 host_command_reg;
+       u32 host_command_reg1;
+       u32 sequence;
+       u32 host_command_len_reg;
+       u32 host_command_params_reg[HOST_COMMAND_PARAMS_REG_LEN];
+       u32 cmd_status_reg;
+       u32 cmd_status_params_reg[CMD_STATUS_PARAMS_REG_LEN];
+       u32 rxq_base_ptr;
+       u32 rxq_next_ptr;
+       u32 rxq_host_ptr;
+       u32 txq_base_ptr;
+       u32 txq_next_ptr;
+       u32 txq_host_ptr;
+       u32 tx_status_reg;
+       u32 reserved;
+       u32 status_change_reg;
+       u32 reserved1[3];
+       u32 *ordinal1_ptr;
+       u32 *ordinal2_ptr;
+} __attribute__ ((packed));
+
+struct ipw2100_data_header {
+       u32 host_command_reg;
+       u32 host_command_reg1;
+       u8 encrypted;   // BOOLEAN in win! TRUE if frame is enc by driver
+       u8 needs_encryption;    // BOOLEAN in win! TRUE if frma need to be enc in NIC
+       u8 wep_index;           // 0 no key, 1-4 key index, 0xff immediate key
+       u8 key_size;    // 0 no imm key, 0x5 64bit encr, 0xd 128bit encr, 0x10 128bit encr and 128bit IV
+       u8 key[16];
+       u8 reserved[10];        // f/w reserved
+       u8 src_addr[ETH_ALEN];
+       u8 dst_addr[ETH_ALEN];
+       u16 fragment_size;
+} __attribute__ ((packed));
+
+/* Host command data structure */
+struct host_command {
+       u32 host_command;               // COMMAND ID
+       u32 host_command1;              // COMMAND ID
+       u32 host_command_sequence;      // UNIQUE COMMAND NUMBER (ID)
+       u32 host_command_length;        // LENGTH
+       u32 host_command_parameters[HOST_COMMAND_PARAMS_REG_LEN];       // COMMAND PARAMETERS
+} __attribute__ ((packed));
+
+
+typedef enum {
+       POWER_ON_RESET,
+       EXIT_POWER_DOWN_RESET,
+       SW_RESET,
+       EEPROM_RW,
+       SW_RE_INIT
+} ipw2100_reset_event;
+
+enum {
+       COMMAND = 0xCAFE,
+       DATA,
+       RX
+};
+
+
+struct ipw2100_tx_packet {
+       int type;
+       int index;
+       union {
+               struct { /* COMMAND */
+                       struct ipw2100_cmd_header* cmd;
+                       dma_addr_t cmd_phys;
+               } c_struct;
+               struct { /* DATA */
+                       struct ipw2100_data_header* data;
+                       dma_addr_t data_phys;
+                       struct ieee80211_txb *txb;
+               } d_struct;
+       } info;
+       int jiffy_start;
+
+       struct list_head list;
+};
+
+
+struct ipw2100_rx_packet {
+       struct ipw2100_rx *rxp;
+       dma_addr_t dma_addr;
+       int jiffy_start;
+       struct sk_buff *skb;
+       struct list_head list;
+};
+
+#define FRAG_DISABLED             (1<<31)
+#define RTS_DISABLED              (1<<31)
+#define MAX_RTS_THRESHOLD         2304U
+#define MIN_RTS_THRESHOLD         1U
+#define DEFAULT_RTS_THRESHOLD     1000U
+
+#define DEFAULT_BEACON_INTERVAL   100U
+#define        DEFAULT_SHORT_RETRY_LIMIT 7U
+#define        DEFAULT_LONG_RETRY_LIMIT  4U
+
+struct ipw2100_ordinals {
+       u32 table1_addr;
+       u32 table2_addr;
+       u32 table1_size;
+       u32 table2_size;
+};
+
+/* Host Notification header */
+struct ipw2100_notification {
+       u32 hnhdr_subtype;      /* type of host notification */
+       u32 hnhdr_size;         /* size in bytes of data
+                                  or number of entries, if table.
+                                  Does NOT include header */
+} __attribute__ ((packed));
+
+#define MAX_KEY_SIZE   16
+#define        MAX_KEYS        8
+
+#define IPW2100_WEP_ENABLE     (1<<1)
+#define IPW2100_WEP_DROP_CLEAR (1<<2)
+
+#define IPW_NONE_CIPHER   (1<<0)
+#define IPW_WEP40_CIPHER  (1<<1)
+#define IPW_TKIP_CIPHER   (1<<2)
+#define IPW_CCMP_CIPHER   (1<<4)
+#define IPW_WEP104_CIPHER (1<<5)
+#define IPW_CKIP_CIPHER   (1<<6)
+
+#define        IPW_AUTH_OPEN     0
+#define        IPW_AUTH_SHARED   1
+
+struct statistic {
+       int value;
+       int hi;
+       int lo;
+};
+
+#define INIT_STAT(x) do {  \
+  (x)->value = (x)->hi = 0; \
+  (x)->lo = 0x7fffffff; \
+} while (0)
+#define SET_STAT(x,y) do { \
+  (x)->value = y; \
+  if ((x)->value > (x)->hi) (x)->hi = (x)->value; \
+  if ((x)->value < (x)->lo) (x)->lo = (x)->value; \
+} while (0)
+#define INC_STAT(x) do { if (++(x)->value > (x)->hi) (x)->hi = (x)->value; } \
+while (0)
+#define DEC_STAT(x) do { if (--(x)->value < (x)->lo) (x)->lo = (x)->value; } \
+while (0)
+
+#define IPW2100_ERROR_QUEUE 5
+
+/* Power management code: enable or disable? */
+enum {
+#ifdef CONFIG_PM
+       IPW2100_PM_DISABLED = 0,
+       PM_STATE_SIZE = 16,
+#else
+       IPW2100_PM_DISABLED = 1,
+       PM_STATE_SIZE = 0,
+#endif
+};
+
+#define STATUS_POWERED          (1<<0)
+#define STATUS_CMD_ACTIVE       (1<<1)  /**< host command in progress */
+#define STATUS_RUNNING          (1<<2)  /* Card initialized, but not enabled */
+#define STATUS_ENABLED          (1<<3)  /* Card enabled -- can scan,Tx,Rx */
+#define STATUS_STOPPING         (1<<4)  /* Card is in shutdown phase */
+#define STATUS_INITIALIZED      (1<<5)  /* Card is ready for external calls */
+#define STATUS_ASSOCIATING      (1<<9)  /* Associated, but no BSSID yet */
+#define STATUS_ASSOCIATED       (1<<10) /* Associated and BSSID valid */
+#define STATUS_INT_ENABLED      (1<<11)
+#define STATUS_RF_KILL_HW       (1<<12)
+#define STATUS_RF_KILL_SW       (1<<13)
+#define STATUS_RF_KILL_MASK     (STATUS_RF_KILL_HW | STATUS_RF_KILL_SW)
+#define STATUS_EXIT_PENDING     (1<<14)
+
+#define STATUS_SCAN_PENDING     (1<<23)
+#define STATUS_SCANNING         (1<<24)
+#define STATUS_SCAN_ABORTING    (1<<25)
+#define STATUS_SCAN_COMPLETE    (1<<26)
+#define STATUS_WX_EVENT_PENDING (1<<27)
+#define STATUS_RESET_PENDING    (1<<29)
+#define STATUS_SECURITY_UPDATED (1<<30) /* Security sync needed */
+
+
+
+/* Internal NIC states */
+#define IPW_STATE_INITIALIZED  (1<<0)
+#define IPW_STATE_COUNTRY_FOUND        (1<<1)
+#define IPW_STATE_ASSOCIATED    (1<<2)
+#define IPW_STATE_ASSN_LOST    (1<<3)
+#define IPW_STATE_ASSN_CHANGED         (1<<4)
+#define IPW_STATE_SCAN_COMPLETE        (1<<5)
+#define IPW_STATE_ENTERED_PSP  (1<<6)
+#define IPW_STATE_LEFT_PSP     (1<<7)
+#define IPW_STATE_RF_KILL       (1<<8)
+#define IPW_STATE_DISABLED     (1<<9)
+#define IPW_STATE_POWER_DOWN   (1<<10)
+#define IPW_STATE_SCANNING      (1<<11)
+
+
+
+#define CFG_STATIC_CHANNEL      (1<<0) /* Restrict assoc. to single channel */
+#define CFG_STATIC_ESSID        (1<<1) /* Restrict assoc. to single SSID */
+#define CFG_STATIC_BSSID        (1<<2) /* Restrict assoc. to single BSSID */
+#define CFG_CUSTOM_MAC          (1<<3)
+#define CFG_LONG_PREAMBLE       (1<<4)
+#define CFG_ASSOCIATE           (1<<6)
+#define CFG_FIXED_RATE          (1<<7)
+#define CFG_ADHOC_CREATE        (1<<8)
+#define CFG_C3_DISABLED         (1<<9)
+#define CFG_PASSIVE_SCAN        (1<<10)
+
+#define CAP_SHARED_KEY          (1<<0) /* Off = OPEN */
+#define CAP_PRIVACY_ON          (1<<1) /* Off = No privacy */
+
+struct ipw2100_priv {
+
+       int stop_hang_check; /* Set 1 when shutting down to kill hang_check */
+       int stop_rf_kill; /* Set 1 when shutting down to kill rf_kill */
+
+       struct ieee80211_device *ieee;
+       unsigned long status;
+       unsigned long config;
+       unsigned long capability;
+
+       /* Statistics */
+       int resets;
+       int reset_backoff;
+
+       /* Context */
+       u8 essid[IW_ESSID_MAX_SIZE];
+       u8 essid_len;
+       u8 bssid[ETH_ALEN];
+       u8 channel;
+       int last_mode;
+       int cstate_limit;
+
+       unsigned long connect_start;
+       unsigned long last_reset;
+
+       u32 channel_mask;
+       u32 fatal_error;
+       u32 fatal_errors[IPW2100_ERROR_QUEUE];
+       u32 fatal_index;
+       int eeprom_version;
+       int firmware_version;
+       unsigned long hw_features;
+       int hangs;
+       u32 last_rtc;
+       int dump_raw; /* 1 to dump raw bytes in /sys/.../memory */
+       u8* snapshot[0x30];
+
+       u8 mandatory_bssid_mac[ETH_ALEN];
+       u8 mac_addr[ETH_ALEN];
+
+       int power_mode;
+
+       /* WEP data */
+       struct ieee80211_security sec;
+       int messages_sent;
+
+
+       int short_retry_limit;
+       int long_retry_limit;
+
+       u32 rts_threshold;
+       u32 frag_threshold;
+
+       int in_isr;
+
+       u32 tx_rates;
+       int tx_power;
+       u32 beacon_interval;
+
+       char nick[IW_ESSID_MAX_SIZE + 1];
+
+       struct ipw2100_status_queue status_queue;
+
+       struct statistic txq_stat;
+       struct statistic rxq_stat;
+       struct ipw2100_bd_queue rx_queue;
+       struct ipw2100_bd_queue tx_queue;
+       struct ipw2100_rx_packet *rx_buffers;
+
+       struct statistic fw_pend_stat;
+       struct list_head fw_pend_list;
+
+       struct statistic msg_free_stat;
+       struct statistic msg_pend_stat;
+       struct list_head msg_free_list;
+       struct list_head msg_pend_list;
+       struct ipw2100_tx_packet *msg_buffers;
+
+       struct statistic tx_free_stat;
+       struct statistic tx_pend_stat;
+       struct list_head tx_free_list;
+       struct list_head tx_pend_list;
+       struct ipw2100_tx_packet *tx_buffers;
+
+       struct ipw2100_ordinals ordinals;
+
+       struct pci_dev *pci_dev;
+
+       struct proc_dir_entry *dir_dev;
+
+       struct net_device *net_dev;
+       struct iw_statistics wstats;
+
+       struct tasklet_struct irq_tasklet;
+
+       struct workqueue_struct *workqueue;
+       struct work_struct reset_work;
+       struct work_struct security_work;
+       struct work_struct wx_event_work;
+       struct work_struct hang_check;
+       struct work_struct rf_kill;
+
+       u32 interrupts;
+       int tx_interrupts;
+       int rx_interrupts;
+       int inta_other;
+
+       spinlock_t low_lock;
+       struct semaphore action_sem;
+       struct semaphore adapter_sem;
+
+       wait_queue_head_t wait_command_queue;
+};
+
+
+/*********************************************************
+ * Host Command -> From Driver to FW
+ *********************************************************/
+
+/**
+ * Host command identifiers
+ */
+#define HOST_COMPLETE           2
+#define SYSTEM_CONFIG           6
+#define SSID                    8
+#define MANDATORY_BSSID         9
+#define AUTHENTICATION_TYPE    10
+#define ADAPTER_ADDRESS        11
+#define PORT_TYPE              12
+#define INTERNATIONAL_MODE     13
+#define CHANNEL                14
+#define RTS_THRESHOLD          15
+#define FRAG_THRESHOLD         16
+#define POWER_MODE             17
+#define TX_RATES               18
+#define BASIC_TX_RATES         19
+#define WEP_KEY_INFO           20
+#define WEP_KEY_INDEX          25
+#define WEP_FLAGS              26
+#define ADD_MULTICAST          27
+#define CLEAR_ALL_MULTICAST    28
+#define BEACON_INTERVAL        29
+#define ATIM_WINDOW            30
+#define CLEAR_STATISTICS       31
+#define SEND                  33
+#define TX_POWER_INDEX         36
+#define BROADCAST_SCAN         43
+#define CARD_DISABLE           44
+#define PREFERRED_BSSID        45
+#define SET_SCAN_OPTIONS       46
+#define SCAN_DWELL_TIME        47
+#define SWEEP_TABLE            48
+#define AP_OR_STATION_TABLE    49
+#define GROUP_ORDINALS         50
+#define SHORT_RETRY_LIMIT      51
+#define LONG_RETRY_LIMIT       52
+
+#define HOST_PRE_POWER_DOWN    58
+#define CARD_DISABLE_PHY_OFF   61
+#define MSDU_TX_RATES          62
+
+
+/* Rogue AP Detection */
+#define SET_STATION_STAT_BITS      64
+#define CLEAR_STATIONS_STAT_BITS   65
+#define LEAP_ROGUE_MODE            66  //TODO tbw replaced by CFG_LEAP_ROGUE_AP
+#define SET_SECURITY_INFORMATION   67
+#define DISASSOCIATION_BSSID      68
+#define SET_WPA_IE                 69
+
+
+
+/* system configuration bit mask: */
+#define IPW_CFG_MONITOR               0x00004
+#define IPW_CFG_PREAMBLE_AUTO        0x00010
+#define IPW_CFG_IBSS_AUTO_START     0x00020
+#define IPW_CFG_LOOPBACK            0x00100
+#define IPW_CFG_ANSWER_BCSSID_PROBE 0x00800
+#define IPW_CFG_BT_SIDEBAND_SIGNAL     0x02000
+#define IPW_CFG_802_1x_ENABLE       0x04000
+#define IPW_CFG_BSS_MASK               0x08000
+#define IPW_CFG_IBSS_MASK              0x10000
+
+#define IPW_SCAN_NOASSOCIATE (1<<0)
+#define IPW_SCAN_MIXED_CELL (1<<1)
+/* RESERVED (1<<2) */
+#define IPW_SCAN_PASSIVE (1<<3)
+
+#define IPW_NIC_FATAL_ERROR 0x2A7F0
+#define IPW_ERROR_ADDR(x) (x & 0x3FFFF)
+#define IPW_ERROR_CODE(x) ((x & 0xFF000000) >> 24)
+#define IPW2100_ERR_C3_CORRUPTION (0x10 << 24)
+#define IPW2100_ERR_MSG_TIMEOUT   (0x11 << 24)
+#define IPW2100_ERR_FW_LOAD       (0x12 << 24)
+
+#define IPW_MEM_SRAM_HOST_SHARED_LOWER_BOUND                   0x200
+#define IPW_MEM_SRAM_HOST_INTERRUPT_AREA_LOWER_BOUND   IPW_MEM_SRAM_HOST_SHARED_LOWER_BOUND + 0x0D80
+
+#define IPW_MEM_HOST_SHARED_RX_BD_BASE                  (IPW_MEM_SRAM_HOST_SHARED_LOWER_BOUND + 0x40)
+#define IPW_MEM_HOST_SHARED_RX_STATUS_BASE              (IPW_MEM_SRAM_HOST_SHARED_LOWER_BOUND + 0x44)
+#define IPW_MEM_HOST_SHARED_RX_BD_SIZE                  (IPW_MEM_SRAM_HOST_SHARED_LOWER_BOUND + 0x48)
+#define IPW_MEM_HOST_SHARED_RX_READ_INDEX               (IPW_MEM_SRAM_HOST_SHARED_LOWER_BOUND + 0xa0)
+
+#define IPW_MEM_HOST_SHARED_TX_QUEUE_BD_BASE          (IPW_MEM_SRAM_HOST_SHARED_LOWER_BOUND + 0x00)
+#define IPW_MEM_HOST_SHARED_TX_QUEUE_BD_SIZE          (IPW_MEM_SRAM_HOST_SHARED_LOWER_BOUND + 0x04)
+#define IPW_MEM_HOST_SHARED_TX_QUEUE_READ_INDEX       (IPW_MEM_SRAM_HOST_SHARED_LOWER_BOUND + 0x80)
+
+#define IPW_MEM_HOST_SHARED_RX_WRITE_INDEX \
+    (IPW_MEM_SRAM_HOST_INTERRUPT_AREA_LOWER_BOUND + 0x20)
+
+#define IPW_MEM_HOST_SHARED_TX_QUEUE_WRITE_INDEX \
+    (IPW_MEM_SRAM_HOST_INTERRUPT_AREA_LOWER_BOUND)
+
+#define IPW_MEM_HOST_SHARED_ORDINALS_TABLE_1   (IPW_MEM_SRAM_HOST_SHARED_LOWER_BOUND + 0x180)
+#define IPW_MEM_HOST_SHARED_ORDINALS_TABLE_2   (IPW_MEM_SRAM_HOST_SHARED_LOWER_BOUND + 0x184)
+
+#define IPW2100_INTA_TX_TRANSFER               (0x00000001)    // Bit 0 (LSB)
+#define IPW2100_INTA_RX_TRANSFER               (0x00000002)    // Bit 1
+#define IPW2100_INTA_TX_COMPLETE              (0x00000004)     // Bit 2
+#define IPW2100_INTA_EVENT_INTERRUPT           (0x00000008)     // Bit 3
+#define IPW2100_INTA_STATUS_CHANGE             (0x00000010)    // Bit 4
+#define IPW2100_INTA_BEACON_PERIOD_EXPIRED     (0x00000020)    // Bit 5
+#define IPW2100_INTA_SLAVE_MODE_HOST_COMMAND_DONE  (0x00010000)        // Bit 16
+#define IPW2100_INTA_FW_INIT_DONE              (0x01000000)    // Bit 24
+#define IPW2100_INTA_FW_CALIBRATION_CALC       (0x02000000)    // Bit 25
+#define IPW2100_INTA_FATAL_ERROR               (0x40000000)    // Bit 30
+#define IPW2100_INTA_PARITY_ERROR              (0x80000000)    // Bit 31 (MSB)
+
+#define IPW_AUX_HOST_RESET_REG_PRINCETON_RESET              (0x00000001)
+#define IPW_AUX_HOST_RESET_REG_FORCE_NMI                    (0x00000002)
+#define IPW_AUX_HOST_RESET_REG_PCI_HOST_CLUSTER_FATAL_NMI   (0x00000004)
+#define IPW_AUX_HOST_RESET_REG_CORE_FATAL_NMI               (0x00000008)
+#define IPW_AUX_HOST_RESET_REG_SW_RESET                     (0x00000080)
+#define IPW_AUX_HOST_RESET_REG_MASTER_DISABLED              (0x00000100)
+#define IPW_AUX_HOST_RESET_REG_STOP_MASTER                  (0x00000200)
+
+#define IPW_AUX_HOST_GP_CNTRL_BIT_CLOCK_READY           (0x00000001)   // Bit 0 (LSB)
+#define IPW_AUX_HOST_GP_CNTRL_BIT_HOST_ALLOWS_STANDBY   (0x00000002)   // Bit 1
+#define IPW_AUX_HOST_GP_CNTRL_BIT_INIT_DONE             (0x00000004)   // Bit 2
+#define IPW_AUX_HOST_GP_CNTRL_BITS_SYS_CONFIG           (0x000007c0)   // Bits 6-10
+#define IPW_AUX_HOST_GP_CNTRL_BIT_BUS_TYPE              (0x00000200)   // Bit 9
+#define IPW_AUX_HOST_GP_CNTRL_BIT_BAR0_BLOCK_SIZE       (0x00000400)   // Bit 10
+#define IPW_AUX_HOST_GP_CNTRL_BIT_USB_MODE              (0x20000000)   // Bit 29
+#define IPW_AUX_HOST_GP_CNTRL_BIT_HOST_FORCES_SYS_CLK   (0x40000000)   // Bit 30
+#define IPW_AUX_HOST_GP_CNTRL_BIT_FW_FORCES_SYS_CLK     (0x80000000)   // Bit 31 (MSB)
+
+#define IPW_BIT_GPIO_GPIO1_MASK         0x0000000C
+#define IPW_BIT_GPIO_GPIO3_MASK         0x000000C0
+#define IPW_BIT_GPIO_GPIO1_ENABLE       0x00000008
+#define IPW_BIT_GPIO_RF_KILL            0x00010000
+
+#define IPW_BIT_GPIO_LED_OFF            0x00002000     // Bit 13 = 1
+
+#define IPW_REG_DOMAIN_0_OFFSET        0x0000
+#define IPW_REG_DOMAIN_1_OFFSET        IPW_MEM_SRAM_HOST_SHARED_LOWER_BOUND
+
+#define IPW_REG_INTA                   IPW_REG_DOMAIN_0_OFFSET + 0x0008
+#define IPW_REG_INTA_MASK              IPW_REG_DOMAIN_0_OFFSET + 0x000C
+#define IPW_REG_INDIRECT_ACCESS_ADDRESS        IPW_REG_DOMAIN_0_OFFSET + 0x0010
+#define IPW_REG_INDIRECT_ACCESS_DATA   IPW_REG_DOMAIN_0_OFFSET + 0x0014
+#define IPW_REG_AUTOINCREMENT_ADDRESS  IPW_REG_DOMAIN_0_OFFSET + 0x0018
+#define IPW_REG_AUTOINCREMENT_DATA     IPW_REG_DOMAIN_0_OFFSET + 0x001C
+#define IPW_REG_RESET_REG              IPW_REG_DOMAIN_0_OFFSET + 0x0020
+#define IPW_REG_GP_CNTRL               IPW_REG_DOMAIN_0_OFFSET + 0x0024
+#define IPW_REG_GPIO                   IPW_REG_DOMAIN_0_OFFSET + 0x0030
+#define IPW_REG_FW_TYPE                 IPW_REG_DOMAIN_1_OFFSET + 0x0188
+#define IPW_REG_FW_VERSION             IPW_REG_DOMAIN_1_OFFSET + 0x018C
+#define IPW_REG_FW_COMPATABILITY_VERSION IPW_REG_DOMAIN_1_OFFSET + 0x0190
+
+#define IPW_REG_INDIRECT_ADDR_MASK     0x00FFFFFC
+
+#define IPW_INTERRUPT_MASK             0xC1010013
+
+#define IPW2100_CONTROL_REG             0x220000
+#define IPW2100_CONTROL_PHY_OFF         0x8
+
+#define IPW2100_COMMAND                        0x00300004
+#define IPW2100_COMMAND_PHY_ON         0x0
+#define IPW2100_COMMAND_PHY_OFF                0x1
+
+/* in DEBUG_AREA, values of memory always 0xd55555d5 */
+#define IPW_REG_DOA_DEBUG_AREA_START    IPW_REG_DOMAIN_0_OFFSET + 0x0090
+#define IPW_REG_DOA_DEBUG_AREA_END      IPW_REG_DOMAIN_0_OFFSET + 0x00FF
+#define IPW_DATA_DOA_DEBUG_VALUE        0xd55555d5
+
+#define IPW_INTERNAL_REGISTER_HALT_AND_RESET   0x003000e0
+
+#define IPW_WAIT_CLOCK_STABILIZATION_DELAY         50  // micro seconds
+#define IPW_WAIT_RESET_ARC_COMPLETE_DELAY          10  // micro seconds
+#define IPW_WAIT_RESET_MASTER_ASSERT_COMPLETE_DELAY 10 // micro seconds
+
+// BD ring queue read/write difference
+#define IPW_BD_QUEUE_W_R_MIN_SPARE 2
+
+#define IPW_CACHE_LINE_LENGTH_DEFAULT              0x80
+
+#define IPW_CARD_DISABLE_PHY_OFF_COMPLETE_WAIT     100 // 100 milli
+#define IPW_PREPARE_POWER_DOWN_COMPLETE_WAIT       100 // 100 milli
+
+
+
+
+#define IPW_HEADER_802_11_SIZE          sizeof(struct ieee80211_hdr_3addr)
+#define IPW_MAX_80211_PAYLOAD_SIZE              2304U
+#define IPW_MAX_802_11_PAYLOAD_LENGTH          2312
+#define IPW_MAX_ACCEPTABLE_TX_FRAME_LENGTH     1536
+#define IPW_MIN_ACCEPTABLE_RX_FRAME_LENGTH     60
+#define IPW_MAX_ACCEPTABLE_RX_FRAME_LENGTH \
+       (IPW_MAX_ACCEPTABLE_TX_FRAME_LENGTH + IPW_HEADER_802_11_SIZE - \
+        sizeof(struct ethhdr))
+
+#define IPW_802_11_FCS_LENGTH 4
+#define IPW_RX_NIC_BUFFER_LENGTH \
+        (IPW_MAX_802_11_PAYLOAD_LENGTH + IPW_HEADER_802_11_SIZE + \
+               IPW_802_11_FCS_LENGTH)
+
+#define IPW_802_11_PAYLOAD_OFFSET \
+        (sizeof(struct ieee80211_hdr_3addr) + \
+         sizeof(struct ieee80211_snap_hdr))
+
+struct ipw2100_rx {
+       union {
+               unsigned char payload[IPW_RX_NIC_BUFFER_LENGTH];
+               struct ieee80211_hdr header;
+               u32 status;
+               struct ipw2100_notification notification;
+               struct ipw2100_cmd_header command;
+       } rx_data;
+} __attribute__ ((packed));
+
+/* Bit 0-7 are for 802.11b tx rates - .  Bit 5-7 are reserved */
+#define TX_RATE_1_MBIT              0x0001
+#define TX_RATE_2_MBIT              0x0002
+#define TX_RATE_5_5_MBIT            0x0004
+#define TX_RATE_11_MBIT             0x0008
+#define TX_RATE_MASK                0x000F
+#define DEFAULT_TX_RATES            0x000F
+
+#define IPW_POWER_MODE_CAM           0x00      //(always on)
+#define IPW_POWER_INDEX_1            0x01
+#define IPW_POWER_INDEX_2            0x02
+#define IPW_POWER_INDEX_3            0x03
+#define IPW_POWER_INDEX_4            0x04
+#define IPW_POWER_INDEX_5            0x05
+#define IPW_POWER_AUTO               0x06
+#define IPW_POWER_MASK               0x0F
+#define IPW_POWER_ENABLED            0x10
+#define IPW_POWER_LEVEL(x)           ((x) & IPW_POWER_MASK)
+
+#define IPW_TX_POWER_AUTO            0
+#define IPW_TX_POWER_ENHANCED        1
+
+#define IPW_TX_POWER_DEFAULT         32
+#define IPW_TX_POWER_MIN             0
+#define IPW_TX_POWER_MAX             16
+#define IPW_TX_POWER_MIN_DBM         (-12)
+#define IPW_TX_POWER_MAX_DBM         16
+
+#define FW_SCAN_DONOT_ASSOCIATE     0x0001 // Dont Attempt to Associate after Scan
+#define FW_SCAN_PASSIVE             0x0008 // Force PASSSIVE Scan
+
+#define REG_MIN_CHANNEL             0
+#define REG_MAX_CHANNEL             14
+
+#define REG_CHANNEL_MASK            0x00003FFF
+#define IPW_IBSS_11B_DEFAULT_MASK   0x87ff
+
+#define DIVERSITY_EITHER            0  // Use both antennas
+#define DIVERSITY_ANTENNA_A         1  // Use antenna A
+#define DIVERSITY_ANTENNA_B         2  // Use antenna B
+
+
+#define HOST_COMMAND_WAIT 0
+#define HOST_COMMAND_NO_WAIT 1
+
+#define LOCK_NONE 0
+#define LOCK_DRIVER 1
+#define LOCK_FW 2
+
+#define TYPE_SWEEP_ORD                  0x000D
+#define TYPE_IBSS_STTN_ORD              0x000E
+#define TYPE_BSS_AP_ORD                 0x000F
+#define TYPE_RAW_BEACON_ENTRY           0x0010
+#define TYPE_CALIBRATION_DATA           0x0011
+#define TYPE_ROGUE_AP_DATA              0x0012
+#define TYPE_ASSOCIATION_REQUEST       0x0013
+#define TYPE_REASSOCIATION_REQUEST     0x0014
+
+
+#define HW_FEATURE_RFKILL (0x0001)
+#define RF_KILLSWITCH_OFF (1)
+#define RF_KILLSWITCH_ON  (0)
+
+#define IPW_COMMAND_POOL_SIZE        40
+
+#define IPW_START_ORD_TAB_1                    1
+#define IPW_START_ORD_TAB_2                    1000
+
+#define IPW_ORD_TAB_1_ENTRY_SIZE               sizeof(u32)
+
+#define IS_ORDINAL_TABLE_ONE(mgr,id) \
+    ((id >= IPW_START_ORD_TAB_1) && (id < mgr->table1_size))
+#define IS_ORDINAL_TABLE_TWO(mgr,id) \
+    ((id >= IPW_START_ORD_TAB_2) && (id < (mgr->table2_size + IPW_START_ORD_TAB_2)))
+
+#define BSS_ID_LENGTH               6
+
+// Fixed size data: Ordinal Table 1
+typedef enum _ORDINAL_TABLE_1 {        // NS - means Not Supported by FW
+// Transmit statistics
+       IPW_ORD_STAT_TX_HOST_REQUESTS = 1,// # of requested Host Tx's (MSDU)
+       IPW_ORD_STAT_TX_HOST_COMPLETE,  // # of successful Host Tx's (MSDU)
+       IPW_ORD_STAT_TX_DIR_DATA,       // # of successful Directed Tx's (MSDU)
+
+       IPW_ORD_STAT_TX_DIR_DATA1 = 4,  // # of successful Directed Tx's (MSDU) @ 1MB
+       IPW_ORD_STAT_TX_DIR_DATA2,      // # of successful Directed Tx's (MSDU) @ 2MB
+       IPW_ORD_STAT_TX_DIR_DATA5_5,    // # of successful Directed Tx's (MSDU) @ 5_5MB
+       IPW_ORD_STAT_TX_DIR_DATA11,     // # of successful Directed Tx's (MSDU) @ 11MB
+       IPW_ORD_STAT_TX_DIR_DATA22,     // # of successful Directed Tx's (MSDU) @ 22MB
+
+       IPW_ORD_STAT_TX_NODIR_DATA1 = 13,// # of successful Non_Directed Tx's (MSDU) @ 1MB
+       IPW_ORD_STAT_TX_NODIR_DATA2,    // # of successful Non_Directed Tx's (MSDU) @ 2MB
+       IPW_ORD_STAT_TX_NODIR_DATA5_5,  // # of successful Non_Directed Tx's (MSDU) @ 5.5MB
+       IPW_ORD_STAT_TX_NODIR_DATA11,   // # of successful Non_Directed Tx's (MSDU) @ 11MB
+
+       IPW_ORD_STAT_NULL_DATA = 21,    // # of successful NULL data Tx's
+       IPW_ORD_STAT_TX_RTS,            // # of successful Tx RTS
+       IPW_ORD_STAT_TX_CTS,            // # of successful Tx CTS
+       IPW_ORD_STAT_TX_ACK,            // # of successful Tx ACK
+       IPW_ORD_STAT_TX_ASSN,           // # of successful Association Tx's
+       IPW_ORD_STAT_TX_ASSN_RESP,      // # of successful Association response Tx's
+       IPW_ORD_STAT_TX_REASSN,         // # of successful Reassociation Tx's
+       IPW_ORD_STAT_TX_REASSN_RESP,    // # of successful Reassociation response Tx's
+       IPW_ORD_STAT_TX_PROBE,          // # of probes successfully transmitted
+       IPW_ORD_STAT_TX_PROBE_RESP,     // # of probe responses successfully transmitted
+       IPW_ORD_STAT_TX_BEACON,         // # of tx beacon
+       IPW_ORD_STAT_TX_ATIM,           // # of Tx ATIM
+       IPW_ORD_STAT_TX_DISASSN,        // # of successful Disassociation TX
+       IPW_ORD_STAT_TX_AUTH,           // # of successful Authentication Tx
+       IPW_ORD_STAT_TX_DEAUTH,         // # of successful Deauthentication TX
+
+       IPW_ORD_STAT_TX_TOTAL_BYTES = 41,// Total successful Tx data bytes
+       IPW_ORD_STAT_TX_RETRIES,         // # of Tx retries
+       IPW_ORD_STAT_TX_RETRY1,          // # of Tx retries at 1MBPS
+       IPW_ORD_STAT_TX_RETRY2,          // # of Tx retries at 2MBPS
+       IPW_ORD_STAT_TX_RETRY5_5,        // # of Tx retries at 5.5MBPS
+       IPW_ORD_STAT_TX_RETRY11,         // # of Tx retries at 11MBPS
+
+       IPW_ORD_STAT_TX_FAILURES = 51,  // # of Tx Failures
+       IPW_ORD_STAT_TX_ABORT_AT_HOP,   //NS // # of Tx's aborted at hop time
+       IPW_ORD_STAT_TX_MAX_TRIES_IN_HOP,// # of times max tries in a hop failed
+       IPW_ORD_STAT_TX_ABORT_LATE_DMA, //NS // # of times tx aborted due to late dma setup
+       IPW_ORD_STAT_TX_ABORT_STX,      //NS // # of times backoff aborted
+       IPW_ORD_STAT_TX_DISASSN_FAIL,   // # of times disassociation failed
+       IPW_ORD_STAT_TX_ERR_CTS,         // # of missed/bad CTS frames
+       IPW_ORD_STAT_TX_BPDU,           //NS // # of spanning tree BPDUs sent
+       IPW_ORD_STAT_TX_ERR_ACK,        // # of tx err due to acks
+
+       // Receive statistics
+       IPW_ORD_STAT_RX_HOST = 61,      // # of packets passed to host
+       IPW_ORD_STAT_RX_DIR_DATA,       // # of directed packets
+       IPW_ORD_STAT_RX_DIR_DATA1,      // # of directed packets at 1MB
+       IPW_ORD_STAT_RX_DIR_DATA2,      // # of directed packets at 2MB
+       IPW_ORD_STAT_RX_DIR_DATA5_5,    // # of directed packets at 5.5MB
+       IPW_ORD_STAT_RX_DIR_DATA11,     // # of directed packets at 11MB
+       IPW_ORD_STAT_RX_DIR_DATA22,     // # of directed packets at 22MB
+
+       IPW_ORD_STAT_RX_NODIR_DATA = 71,// # of nondirected packets
+       IPW_ORD_STAT_RX_NODIR_DATA1,    // # of nondirected packets at 1MB
+       IPW_ORD_STAT_RX_NODIR_DATA2,    // # of nondirected packets at 2MB
+       IPW_ORD_STAT_RX_NODIR_DATA5_5,  // # of nondirected packets at 5.5MB
+       IPW_ORD_STAT_RX_NODIR_DATA11,   // # of nondirected packets at 11MB
+
+       IPW_ORD_STAT_RX_NULL_DATA = 80, // # of null data rx's
+       IPW_ORD_STAT_RX_POLL,   //NS // # of poll rx
+       IPW_ORD_STAT_RX_RTS,    // # of Rx RTS
+       IPW_ORD_STAT_RX_CTS,    // # of Rx CTS
+       IPW_ORD_STAT_RX_ACK,    // # of Rx ACK
+       IPW_ORD_STAT_RX_CFEND,  // # of Rx CF End
+       IPW_ORD_STAT_RX_CFEND_ACK,      // # of Rx CF End + CF Ack
+       IPW_ORD_STAT_RX_ASSN,   // # of Association Rx's
+       IPW_ORD_STAT_RX_ASSN_RESP,      // # of Association response Rx's
+       IPW_ORD_STAT_RX_REASSN, // # of Reassociation Rx's
+       IPW_ORD_STAT_RX_REASSN_RESP,    // # of Reassociation response Rx's
+       IPW_ORD_STAT_RX_PROBE,  // # of probe Rx's
+       IPW_ORD_STAT_RX_PROBE_RESP,     // # of probe response Rx's
+       IPW_ORD_STAT_RX_BEACON, // # of Rx beacon
+       IPW_ORD_STAT_RX_ATIM,   // # of Rx ATIM
+       IPW_ORD_STAT_RX_DISASSN,        // # of disassociation Rx
+       IPW_ORD_STAT_RX_AUTH,   // # of authentication Rx
+       IPW_ORD_STAT_RX_DEAUTH, // # of deauthentication Rx
+
+       IPW_ORD_STAT_RX_TOTAL_BYTES = 101,// Total rx data bytes received
+       IPW_ORD_STAT_RX_ERR_CRC,         // # of packets with Rx CRC error
+       IPW_ORD_STAT_RX_ERR_CRC1,        // # of Rx CRC errors at 1MB
+       IPW_ORD_STAT_RX_ERR_CRC2,        // # of Rx CRC errors at 2MB
+       IPW_ORD_STAT_RX_ERR_CRC5_5,      // # of Rx CRC errors at 5.5MB
+       IPW_ORD_STAT_RX_ERR_CRC11,       // # of Rx CRC errors at 11MB
+
+       IPW_ORD_STAT_RX_DUPLICATE1 = 112, // # of duplicate rx packets at 1MB
+       IPW_ORD_STAT_RX_DUPLICATE2,      // # of duplicate rx packets at 2MB
+       IPW_ORD_STAT_RX_DUPLICATE5_5,    // # of duplicate rx packets at 5.5MB
+       IPW_ORD_STAT_RX_DUPLICATE11,     // # of duplicate rx packets at 11MB
+       IPW_ORD_STAT_RX_DUPLICATE = 119, // # of duplicate rx packets
+
+       IPW_ORD_PERS_DB_LOCK = 120,     // # locking fw permanent  db
+       IPW_ORD_PERS_DB_SIZE,   // # size of fw permanent  db
+       IPW_ORD_PERS_DB_ADDR,   // # address of fw permanent  db
+       IPW_ORD_STAT_RX_INVALID_PROTOCOL,       // # of rx frames with invalid protocol
+       IPW_ORD_SYS_BOOT_TIME,  // # Boot time
+       IPW_ORD_STAT_RX_NO_BUFFER,      // # of rx frames rejected due to no buffer
+       IPW_ORD_STAT_RX_ABORT_LATE_DMA, //NS // # of rx frames rejected due to dma setup too late
+       IPW_ORD_STAT_RX_ABORT_AT_HOP,   //NS // # of rx frames aborted due to hop
+       IPW_ORD_STAT_RX_MISSING_FRAG,   // # of rx frames dropped due to missing fragment
+       IPW_ORD_STAT_RX_ORPHAN_FRAG,    // # of rx frames dropped due to non-sequential fragment
+       IPW_ORD_STAT_RX_ORPHAN_FRAME,   // # of rx frames dropped due to unmatched 1st frame
+       IPW_ORD_STAT_RX_FRAG_AGEOUT,    // # of rx frames dropped due to uncompleted frame
+       IPW_ORD_STAT_RX_BAD_SSID,       //NS // Bad SSID (unused)
+       IPW_ORD_STAT_RX_ICV_ERRORS,     // # of ICV errors during decryption
+
+// PSP Statistics
+       IPW_ORD_STAT_PSP_SUSPENSION = 137,// # of times adapter suspended
+       IPW_ORD_STAT_PSP_BCN_TIMEOUT,   // # of beacon timeout
+       IPW_ORD_STAT_PSP_POLL_TIMEOUT,  // # of poll response timeouts
+       IPW_ORD_STAT_PSP_NONDIR_TIMEOUT,// # of timeouts waiting for last broadcast/muticast pkt
+       IPW_ORD_STAT_PSP_RX_DTIMS,      // # of PSP DTIMs received
+       IPW_ORD_STAT_PSP_RX_TIMS,       // # of PSP TIMs received
+       IPW_ORD_STAT_PSP_STATION_ID,    // PSP Station ID
+
+// Association and roaming
+       IPW_ORD_LAST_ASSN_TIME = 147,   // RTC time of last association
+       IPW_ORD_STAT_PERCENT_MISSED_BCNS,// current calculation of % missed beacons
+       IPW_ORD_STAT_PERCENT_RETRIES,   // current calculation of % missed tx retries
+       IPW_ORD_ASSOCIATED_AP_PTR,      // If associated, this is ptr to the associated
+       // AP table entry. set to 0 if not associated
+       IPW_ORD_AVAILABLE_AP_CNT,       // # of AP's decsribed in the AP table
+       IPW_ORD_AP_LIST_PTR,    // Ptr to list of available APs
+       IPW_ORD_STAT_AP_ASSNS,  // # of associations
+       IPW_ORD_STAT_ASSN_FAIL, // # of association failures
+       IPW_ORD_STAT_ASSN_RESP_FAIL,    // # of failuresdue to response fail
+       IPW_ORD_STAT_FULL_SCANS,        // # of full scans
+
+       IPW_ORD_CARD_DISABLED,  // # Card Disabled
+       IPW_ORD_STAT_ROAM_INHIBIT,      // # of times roaming was inhibited due to ongoing activity
+       IPW_FILLER_40,
+       IPW_ORD_RSSI_AT_ASSN = 160,     // RSSI of associated AP at time of association
+       IPW_ORD_STAT_ASSN_CAUSE1,       // # of reassociations due to no tx from AP in last N
+       // hops or no prob_ responses in last 3 minutes
+       IPW_ORD_STAT_ASSN_CAUSE2,       // # of reassociations due to poor tx/rx quality
+       IPW_ORD_STAT_ASSN_CAUSE3,       // # of reassociations due to tx/rx quality with excessive
+       // load at the AP
+       IPW_ORD_STAT_ASSN_CAUSE4,       // # of reassociations due to AP RSSI level fell below
+       // eligible group
+       IPW_ORD_STAT_ASSN_CAUSE5,       // # of reassociations due to load leveling
+       IPW_ORD_STAT_ASSN_CAUSE6,       //NS // # of reassociations due to dropped by Ap
+       IPW_FILLER_41,
+       IPW_FILLER_42,
+       IPW_FILLER_43,
+       IPW_ORD_STAT_AUTH_FAIL, // # of times authentication failed
+       IPW_ORD_STAT_AUTH_RESP_FAIL,    // # of times authentication response failed
+       IPW_ORD_STATION_TABLE_CNT,      // # of entries in association table
+
+// Other statistics
+       IPW_ORD_RSSI_AVG_CURR = 173,    // Current avg RSSI
+       IPW_ORD_STEST_RESULTS_CURR,     //NS // Current self test results word
+       IPW_ORD_STEST_RESULTS_CUM,      //NS // Cummulative self test results word
+       IPW_ORD_SELF_TEST_STATUS,       //NS //
+       IPW_ORD_POWER_MGMT_MODE,        // Power mode - 0=CAM, 1=PSP
+       IPW_ORD_POWER_MGMT_INDEX,       //NS //
+       IPW_ORD_COUNTRY_CODE,   // IEEE country code as recv'd from beacon
+       IPW_ORD_COUNTRY_CHANNELS,       // channels suported by country
+// IPW_ORD_COUNTRY_CHANNELS:
+// For 11b the lower 2-byte are used for channels from 1-14
+//   and the higher 2-byte are not used.
+       IPW_ORD_RESET_CNT,      // # of adapter resets (warm)
+       IPW_ORD_BEACON_INTERVAL,        // Beacon interval
+
+       IPW_ORD_PRINCETON_VERSION = 184,        //NS // Princeton Version
+       IPW_ORD_ANTENNA_DIVERSITY,      // TRUE if antenna diversity is disabled
+       IPW_ORD_CCA_RSSI,       //NS // CCA RSSI value (factory programmed)
+       IPW_ORD_STAT_EEPROM_UPDATE,     //NS // # of times config EEPROM updated
+       IPW_ORD_DTIM_PERIOD,    // # of beacon intervals between DTIMs
+       IPW_ORD_OUR_FREQ,       // current radio freq lower digits - channel ID
+
+       IPW_ORD_RTC_TIME = 190, // current RTC time
+       IPW_ORD_PORT_TYPE,      // operating mode
+       IPW_ORD_CURRENT_TX_RATE,        // current tx rate
+       IPW_ORD_SUPPORTED_RATES,        // Bitmap of supported tx rates
+       IPW_ORD_ATIM_WINDOW,    // current ATIM Window
+       IPW_ORD_BASIC_RATES,    // bitmap of basic tx rates
+       IPW_ORD_NIC_HIGHEST_RATE,       // bitmap of basic tx rates
+       IPW_ORD_AP_HIGHEST_RATE,        // bitmap of basic tx rates
+       IPW_ORD_CAPABILITIES,   // Management frame capability field
+       IPW_ORD_AUTH_TYPE,      // Type of authentication
+       IPW_ORD_RADIO_TYPE,     // Adapter card platform type
+       IPW_ORD_RTS_THRESHOLD = 201,    // Min length of packet after which RTS handshaking is used
+       IPW_ORD_INT_MODE,       // International mode
+       IPW_ORD_FRAGMENTATION_THRESHOLD,        // protocol frag threshold
+       IPW_ORD_EEPROM_SRAM_DB_BLOCK_START_ADDRESS,     // EEPROM offset in SRAM
+       IPW_ORD_EEPROM_SRAM_DB_BLOCK_SIZE,      // EEPROM size in SRAM
+       IPW_ORD_EEPROM_SKU_CAPABILITY,  // EEPROM SKU Capability    206 =
+       IPW_ORD_EEPROM_IBSS_11B_CHANNELS,       // EEPROM IBSS 11b channel set
+
+       IPW_ORD_MAC_VERSION = 209,      // MAC Version
+       IPW_ORD_MAC_REVISION,   // MAC Revision
+       IPW_ORD_RADIO_VERSION,  // Radio Version
+       IPW_ORD_NIC_MANF_DATE_TIME,     // MANF Date/Time STAMP
+       IPW_ORD_UCODE_VERSION,  // Ucode Version
+       IPW_ORD_HW_RF_SWITCH_STATE = 214,       // HW RF Kill Switch State
+} ORDINALTABLE1;
+
+// ordinal table 2
+// Variable length data:
+#define IPW_FIRST_VARIABLE_LENGTH_ORDINAL   1001
+
+typedef enum _ORDINAL_TABLE_2 {        // NS - means Not Supported by FW
+       IPW_ORD_STAT_BASE = 1000,       // contains number of variable ORDs
+       IPW_ORD_STAT_ADAPTER_MAC = 1001,        // 6 bytes: our adapter MAC address
+       IPW_ORD_STAT_PREFERRED_BSSID = 1002,    // 6 bytes: BSSID of the preferred AP
+       IPW_ORD_STAT_MANDATORY_BSSID = 1003,    // 6 bytes: BSSID of the mandatory AP
+       IPW_FILL_1,             //NS //
+       IPW_ORD_STAT_COUNTRY_TEXT = 1005,       // 36 bytes: Country name text, First two bytes are Country code
+       IPW_ORD_STAT_ASSN_SSID = 1006,  // 32 bytes: ESSID String
+       IPW_ORD_STATION_TABLE = 1007,   // ? bytes: Station/AP table (via Direct SSID Scans)
+       IPW_ORD_STAT_SWEEP_TABLE = 1008,        // ? bytes: Sweep/Host Table table (via Broadcast Scans)
+       IPW_ORD_STAT_ROAM_LOG = 1009,   // ? bytes: Roaming log
+       IPW_ORD_STAT_RATE_LOG = 1010,   //NS // 0 bytes: Rate log
+       IPW_ORD_STAT_FIFO = 1011,       //NS // 0 bytes: Fifo buffer data structures
+       IPW_ORD_STAT_FW_VER_NUM = 1012, // 14 bytes: fw version ID string as in (a.bb.ccc; "0.08.011")
+       IPW_ORD_STAT_FW_DATE = 1013,    // 14 bytes: fw date string (mmm dd yyyy; "Mar 13 2002")
+       IPW_ORD_STAT_ASSN_AP_BSSID = 1014,      // 6 bytes: MAC address of associated AP
+       IPW_ORD_STAT_DEBUG = 1015,      //NS // ? bytes:
+       IPW_ORD_STAT_NIC_BPA_NUM = 1016,        // 11 bytes: NIC BPA number in ASCII
+       IPW_ORD_STAT_UCODE_DATE = 1017, // 5 bytes: uCode date
+       IPW_ORD_SECURITY_NGOTIATION_RESULT = 1018,
+} ORDINALTABLE2;               // NS - means Not Supported by FW
+
+#define IPW_LAST_VARIABLE_LENGTH_ORDINAL   1018
+
+#ifndef WIRELESS_SPY
+#define WIRELESS_SPY           // enable iwspy support
+#endif
+
+#define IPW_HOST_FW_SHARED_AREA0       0x0002f200
+#define IPW_HOST_FW_SHARED_AREA0_END   0x0002f510      // 0x310 bytes
+
+#define IPW_HOST_FW_SHARED_AREA1       0x0002f610
+#define IPW_HOST_FW_SHARED_AREA1_END   0x0002f630      // 0x20 bytes
+
+#define IPW_HOST_FW_SHARED_AREA2       0x0002fa00
+#define IPW_HOST_FW_SHARED_AREA2_END   0x0002fa20      // 0x20 bytes
+
+#define IPW_HOST_FW_SHARED_AREA3       0x0002fc00
+#define IPW_HOST_FW_SHARED_AREA3_END   0x0002fc10      // 0x10 bytes
+
+#define IPW_HOST_FW_INTERRUPT_AREA     0x0002ff80
+#define IPW_HOST_FW_INTERRUPT_AREA_END         0x00030000      // 0x80 bytes
+
+struct ipw2100_fw_chunk {
+       unsigned char *buf;
+       long len;
+       long pos;
+       struct list_head list;
+};
+
+struct ipw2100_fw_chunk_set {
+       const void *data;
+       unsigned long size;
+};
+
+struct ipw2100_fw {
+       int version;
+       struct ipw2100_fw_chunk_set fw;
+       struct ipw2100_fw_chunk_set uc;
+       const struct firmware *fw_entry;
+};
+
+#define MAX_FW_VERSION_LEN 14
+
+#endif /* _IPW2100_H */
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
new file mode 100644 (file)
index 0000000..2a3bd60
--- /dev/null
@@ -0,0 +1,7353 @@
+/******************************************************************************
+
+  Copyright(c) 2003 - 2004 Intel Corporation. All rights reserved.
+
+  802.11 status code portion of this file from ethereal-0.10.6:
+    Copyright 2000, Axis Communications AB
+    Ethereal - Network traffic analyzer
+    By Gerald Combs <gerald@ethereal.com>
+    Copyright 1998 Gerald Combs
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms of version 2 of the GNU General Public License as
+  published by the Free Software Foundation.
+
+  This program is distributed in the hope that it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc., 59
+  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+  The full GNU General Public License is included in this distribution in the
+  file called LICENSE.
+
+  Contact Information:
+  James P. Ketrenos <ipw2100-admin@linux.intel.com>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+******************************************************************************/
+
+#include "ipw2200.h"
+
+#define IPW2200_VERSION "1.0.0"
+#define DRV_DESCRIPTION        "Intel(R) PRO/Wireless 2200/2915 Network Driver"
+#define DRV_COPYRIGHT  "Copyright(c) 2003-2004 Intel Corporation"
+#define DRV_VERSION     IPW2200_VERSION
+
+MODULE_DESCRIPTION(DRV_DESCRIPTION);
+MODULE_VERSION(DRV_VERSION);
+MODULE_AUTHOR(DRV_COPYRIGHT);
+MODULE_LICENSE("GPL");
+
+static int debug = 0;
+static int channel = 0;
+static char *ifname;
+static int mode = 0;
+
+static u32 ipw_debug_level;
+static int associate = 1;
+static int auto_create = 1;
+static int disable = 0;
+static const char ipw_modes[] = {
+       'a', 'b', 'g', '?'
+};
+
+static void ipw_rx(struct ipw_priv *priv);
+static int ipw_queue_tx_reclaim(struct ipw_priv *priv,
+                               struct clx2_tx_queue *txq, int qindex);
+static int ipw_queue_reset(struct ipw_priv *priv);
+
+static int ipw_queue_tx_hcmd(struct ipw_priv *priv, int hcmd, void *buf,
+                            int len, int sync);
+
+static void ipw_tx_queue_free(struct ipw_priv *);
+
+static struct ipw_rx_queue *ipw_rx_queue_alloc(struct ipw_priv *);
+static void ipw_rx_queue_free(struct ipw_priv *, struct ipw_rx_queue *);
+static void ipw_rx_queue_replenish(void *);
+
+static int ipw_up(struct ipw_priv *);
+static void ipw_down(struct ipw_priv *);
+static int ipw_config(struct ipw_priv *);
+static int init_supported_rates(struct ipw_priv *priv, struct ipw_supported_rates *prates);
+
+static u8 band_b_active_channel[MAX_B_CHANNELS] = {
+       1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0
+};
+static u8 band_a_active_channel[MAX_A_CHANNELS] = {
+       36, 40, 44, 48, 149, 153, 157, 161, 165, 52, 56, 60, 64, 0
+};
+
+static int is_valid_channel(int mode_mask, int channel)
+{
+       int i;
+
+       if (!channel)
+               return 0;
+
+       if (mode_mask & IEEE_A)
+               for (i = 0; i < MAX_A_CHANNELS; i++)
+                       if (band_a_active_channel[i] == channel)
+                               return IEEE_A;
+
+       if (mode_mask & (IEEE_B | IEEE_G))
+               for (i = 0; i < MAX_B_CHANNELS; i++)
+                       if (band_b_active_channel[i] == channel)
+                               return mode_mask & (IEEE_B | IEEE_G);
+
+       return 0;
+}
+
+static char *snprint_line(char *buf, size_t count,
+                         const u8 *data, u32 len, u32 ofs)
+{
+       int out, i, j, l;
+       char c;
+
+       out = snprintf(buf, count, "%08X", ofs);
+
+       for (l = 0, i = 0; i < 2; i++) {
+               out += snprintf(buf + out, count - out, " ");
+               for (j = 0; j < 8 && l < len; j++, l++)
+                       out += snprintf(buf + out, count - out, "%02X ",
+                                       data[(i * 8 + j)]);
+               for (; j < 8; j++)
+                       out += snprintf(buf + out, count - out, "   ");
+       }
+
+       out += snprintf(buf + out, count - out, " ");
+       for (l = 0, i = 0; i < 2; i++) {
+               out += snprintf(buf + out, count - out, " ");
+               for (j = 0; j < 8 && l < len; j++, l++) {
+                       c = data[(i * 8 + j)];
+                       if (!isascii(c) || !isprint(c))
+                               c = '.';
+
+                       out += snprintf(buf + out, count - out, "%c", c);
+               }
+
+               for (; j < 8; j++)
+                       out += snprintf(buf + out, count - out, " ");
+       }
+
+       return buf;
+}
+
+static void printk_buf(int level, const u8 *data, u32 len)
+{
+       char line[81];
+       u32 ofs = 0;
+       if (!(ipw_debug_level & level))
+               return;
+
+       while (len) {
+               printk(KERN_DEBUG "%s\n",
+                      snprint_line(line, sizeof(line), &data[ofs],
+                                   min(len, 16U), ofs));
+               ofs += 16;
+               len -= min(len, 16U);
+       }
+}
+
+static u32 _ipw_read_reg32(struct ipw_priv *priv, u32 reg);
+#define ipw_read_reg32(a, b) _ipw_read_reg32(a, b)
+
+static u8 _ipw_read_reg8(struct ipw_priv *ipw, u32 reg);
+#define ipw_read_reg8(a, b) _ipw_read_reg8(a, b)
+
+static void _ipw_write_reg8(struct ipw_priv *priv, u32 reg, u8 value);
+static inline void ipw_write_reg8(struct ipw_priv *a, u32 b, u8 c)
+{
+       IPW_DEBUG_IO("%s %d: write_indirect8(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(b), (u32)(c));
+       _ipw_write_reg8(a, b, c);
+}
+
+static void _ipw_write_reg16(struct ipw_priv *priv, u32 reg, u16 value);
+static inline void ipw_write_reg16(struct ipw_priv *a, u32 b, u16 c)
+{
+       IPW_DEBUG_IO("%s %d: write_indirect16(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(b), (u32)(c));
+       _ipw_write_reg16(a, b, c);
+}
+
+static void _ipw_write_reg32(struct ipw_priv *priv, u32 reg, u32 value);
+static inline void ipw_write_reg32(struct ipw_priv *a, u32 b, u32 c)
+{
+       IPW_DEBUG_IO("%s %d: write_indirect32(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(b), (u32)(c));
+       _ipw_write_reg32(a, b, c);
+}
+
+#define _ipw_write8(ipw, ofs, val) writeb((val), (ipw)->hw_base + (ofs))
+#define ipw_write8(ipw, ofs, val) \
+ IPW_DEBUG_IO("%s %d: write_direct8(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(ofs), (u32)(val)); \
+ _ipw_write8(ipw, ofs, val)
+
+#define _ipw_write16(ipw, ofs, val) writew((val), (ipw)->hw_base + (ofs))
+#define ipw_write16(ipw, ofs, val) \
+ IPW_DEBUG_IO("%s %d: write_direct16(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(ofs), (u32)(val)); \
+ _ipw_write16(ipw, ofs, val)
+
+#define _ipw_write32(ipw, ofs, val) writel((val), (ipw)->hw_base + (ofs))
+#define ipw_write32(ipw, ofs, val) \
+ IPW_DEBUG_IO("%s %d: write_direct32(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(ofs), (u32)(val)); \
+ _ipw_write32(ipw, ofs, val)
+
+#define _ipw_read8(ipw, ofs) readb((ipw)->hw_base + (ofs))
+static inline u8 __ipw_read8(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) {
+       IPW_DEBUG_IO("%s %d: read_direct8(0x%08X)\n", f, l, (u32)(ofs));
+       return _ipw_read8(ipw, ofs);
+}
+#define ipw_read8(ipw, ofs) __ipw_read8(__FILE__, __LINE__, ipw, ofs)
+
+#define _ipw_read16(ipw, ofs) readw((ipw)->hw_base + (ofs))
+static inline u16 __ipw_read16(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) {
+       IPW_DEBUG_IO("%s %d: read_direct16(0x%08X)\n", f, l, (u32)(ofs));
+       return _ipw_read16(ipw, ofs);
+}
+#define ipw_read16(ipw, ofs) __ipw_read16(__FILE__, __LINE__, ipw, ofs)
+
+#define _ipw_read32(ipw, ofs) readl((ipw)->hw_base + (ofs))
+static inline u32 __ipw_read32(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) {
+       IPW_DEBUG_IO("%s %d: read_direct32(0x%08X)\n", f, l, (u32)(ofs));
+       return _ipw_read32(ipw, ofs);
+}
+#define ipw_read32(ipw, ofs) __ipw_read32(__FILE__, __LINE__, ipw, ofs)
+
+static void _ipw_read_indirect(struct ipw_priv *, u32, u8 *, int);
+#define ipw_read_indirect(a, b, c, d) \
+       IPW_DEBUG_IO("%s %d: read_inddirect(0x%08X) %d bytes\n", __FILE__, __LINE__, (u32)(b), d); \
+       _ipw_read_indirect(a, b, c, d)
+
+static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 *data, int num);
+#define ipw_write_indirect(a, b, c, d) \
+       IPW_DEBUG_IO("%s %d: write_indirect(0x%08X) %d bytes\n", __FILE__, __LINE__, (u32)(b), d); \
+        _ipw_write_indirect(a, b, c, d)
+
+/* indirect write s */
+static void _ipw_write_reg32(struct ipw_priv *priv, u32 reg,
+                            u32 value)
+{
+       IPW_DEBUG_IO(" %p : reg = 0x%8X : value = 0x%8X\n",
+                    priv, reg, value);
+       _ipw_write32(priv, CX2_INDIRECT_ADDR, reg);
+       _ipw_write32(priv, CX2_INDIRECT_DATA, value);
+}
+
+
+static void _ipw_write_reg8(struct ipw_priv *priv, u32 reg, u8 value)
+{
+       IPW_DEBUG_IO(" reg = 0x%8X : value = 0x%8X\n", reg, value);
+       _ipw_write32(priv, CX2_INDIRECT_ADDR, reg & CX2_INDIRECT_ADDR_MASK);
+       _ipw_write8(priv, CX2_INDIRECT_DATA, value);
+       IPW_DEBUG_IO(" reg = 0x%8lX : value = 0x%8X\n",
+                    (unsigned long)(priv->hw_base + CX2_INDIRECT_DATA),
+                    value);
+}
+
+static void _ipw_write_reg16(struct ipw_priv *priv, u32 reg,
+                            u16 value)
+{
+       IPW_DEBUG_IO(" reg = 0x%8X : value = 0x%8X\n", reg, value);
+       _ipw_write32(priv, CX2_INDIRECT_ADDR, reg & CX2_INDIRECT_ADDR_MASK);
+       _ipw_write16(priv, CX2_INDIRECT_DATA, value);
+}
+
+/* indirect read s */
+
+static u8 _ipw_read_reg8(struct ipw_priv *priv, u32 reg)
+{
+       u32 word;
+       _ipw_write32(priv, CX2_INDIRECT_ADDR, reg & CX2_INDIRECT_ADDR_MASK);
+       IPW_DEBUG_IO(" reg = 0x%8X : \n", reg);
+       word = _ipw_read32(priv, CX2_INDIRECT_DATA);
+       return (word >> ((reg & 0x3)*8)) & 0xff;
+}
+
+static u32 _ipw_read_reg32(struct ipw_priv *priv, u32 reg)
+{
+       u32 value;
+
+       IPW_DEBUG_IO("%p : reg = 0x%08x\n", priv, reg);
+
+       _ipw_write32(priv, CX2_INDIRECT_ADDR, reg);
+       value = _ipw_read32(priv, CX2_INDIRECT_DATA);
+       IPW_DEBUG_IO(" reg = 0x%4X : value = 0x%4x \n", reg, value);
+       return value;
+}
+
+/* iterative/auto-increment 32 bit reads and writes */
+static void _ipw_read_indirect(struct ipw_priv *priv, u32 addr, u8 * buf,
+                              int num)
+{
+       u32 aligned_addr = addr & CX2_INDIRECT_ADDR_MASK;
+       u32 dif_len = addr - aligned_addr;
+       u32 aligned_len;
+       u32 i;
+
+       IPW_DEBUG_IO("addr = %i, buf = %p, num = %i\n", addr, buf, num);
+
+       /* Read the first nibble byte by byte */
+       if (unlikely(dif_len)) {
+               /* Start reading at aligned_addr + dif_len */
+               _ipw_write32(priv, CX2_INDIRECT_ADDR, aligned_addr);
+               for (i = dif_len; i < 4; i++, buf++)
+                       *buf = _ipw_read8(priv, CX2_INDIRECT_DATA + i);
+               num -= dif_len;
+               aligned_addr += 4;
+       }
+
+       /* Read DWs through autoinc register */
+       _ipw_write32(priv, CX2_AUTOINC_ADDR, aligned_addr);
+       aligned_len = num & CX2_INDIRECT_ADDR_MASK;
+       for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4)
+               *(u32*)buf = ipw_read32(priv, CX2_AUTOINC_DATA);
+
+       /* Copy the last nibble */
+       dif_len = num - aligned_len;
+       _ipw_write32(priv, CX2_INDIRECT_ADDR, aligned_addr);
+       for (i = 0; i < dif_len; i++, buf++)
+               *buf = ipw_read8(priv, CX2_INDIRECT_DATA + i);
+}
+
+static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 *buf,
+                               int num)
+{
+       u32 aligned_addr = addr & CX2_INDIRECT_ADDR_MASK;
+       u32 dif_len = addr - aligned_addr;
+       u32 aligned_len;
+       u32 i;
+
+       IPW_DEBUG_IO("addr = %i, buf = %p, num = %i\n", addr, buf, num);
+
+       /* Write the first nibble byte by byte */
+       if (unlikely(dif_len)) {
+               /* Start writing at aligned_addr + dif_len */
+               _ipw_write32(priv, CX2_INDIRECT_ADDR, aligned_addr);
+               for (i = dif_len; i < 4; i++, buf++)
+                       _ipw_write8(priv, CX2_INDIRECT_DATA + i, *buf);
+               num -= dif_len;
+               aligned_addr += 4;
+       }
+
+       /* Write DWs through autoinc register */
+       _ipw_write32(priv, CX2_AUTOINC_ADDR, aligned_addr);
+       aligned_len = num & CX2_INDIRECT_ADDR_MASK;
+       for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4)
+               _ipw_write32(priv, CX2_AUTOINC_DATA, *(u32*)buf);
+
+       /* Copy the last nibble */
+       dif_len = num - aligned_len;
+       _ipw_write32(priv, CX2_INDIRECT_ADDR, aligned_addr);
+       for (i = 0; i < dif_len; i++, buf++)
+               _ipw_write8(priv, CX2_INDIRECT_DATA + i, *buf);
+}
+
+static void ipw_write_direct(struct ipw_priv *priv, u32 addr, void *buf,
+                            int num)
+{
+       memcpy_toio((priv->hw_base + addr), buf, num);
+}
+
+static inline void ipw_set_bit(struct ipw_priv *priv, u32 reg, u32 mask)
+{
+       ipw_write32(priv, reg, ipw_read32(priv, reg) | mask);
+}
+
+static inline void ipw_clear_bit(struct ipw_priv *priv, u32 reg, u32 mask)
+{
+       ipw_write32(priv, reg, ipw_read32(priv, reg) & ~mask);
+}
+
+static inline void ipw_enable_interrupts(struct ipw_priv *priv)
+{
+       if (priv->status & STATUS_INT_ENABLED)
+               return;
+       priv->status |= STATUS_INT_ENABLED;
+       ipw_write32(priv, CX2_INTA_MASK_R, CX2_INTA_MASK_ALL);
+}
+
+static inline void ipw_disable_interrupts(struct ipw_priv *priv)
+{
+       if (!(priv->status & STATUS_INT_ENABLED))
+               return;
+       priv->status &= ~STATUS_INT_ENABLED;
+       ipw_write32(priv, CX2_INTA_MASK_R, ~CX2_INTA_MASK_ALL);
+}
+
+static char *ipw_error_desc(u32 val)
+{
+       switch (val) {
+       case IPW_FW_ERROR_OK:
+               return "ERROR_OK";
+       case IPW_FW_ERROR_FAIL:
+               return "ERROR_FAIL";
+       case IPW_FW_ERROR_MEMORY_UNDERFLOW:
+               return "MEMORY_UNDERFLOW";
+       case IPW_FW_ERROR_MEMORY_OVERFLOW:
+               return "MEMORY_OVERFLOW";
+       case IPW_FW_ERROR_BAD_PARAM:
+               return "ERROR_BAD_PARAM";
+       case IPW_FW_ERROR_BAD_CHECKSUM:
+               return "ERROR_BAD_CHECKSUM";
+       case IPW_FW_ERROR_NMI_INTERRUPT:
+               return "ERROR_NMI_INTERRUPT";
+       case IPW_FW_ERROR_BAD_DATABASE:
+               return "ERROR_BAD_DATABASE";
+       case IPW_FW_ERROR_ALLOC_FAIL:
+               return "ERROR_ALLOC_FAIL";
+       case IPW_FW_ERROR_DMA_UNDERRUN:
+               return "ERROR_DMA_UNDERRUN";
+       case IPW_FW_ERROR_DMA_STATUS:
+               return "ERROR_DMA_STATUS";
+       case IPW_FW_ERROR_DINOSTATUS_ERROR:
+               return "ERROR_DINOSTATUS_ERROR";
+       case IPW_FW_ERROR_EEPROMSTATUS_ERROR:
+               return "ERROR_EEPROMSTATUS_ERROR";
+       case IPW_FW_ERROR_SYSASSERT:
+               return "ERROR_SYSASSERT";
+       case IPW_FW_ERROR_FATAL_ERROR:
+               return "ERROR_FATALSTATUS_ERROR";
+       default:
+               return "UNKNOWNSTATUS_ERROR";
+       }
+}
+
+static void ipw_dump_nic_error_log(struct ipw_priv *priv)
+{
+       u32 desc, time, blink1, blink2, ilink1, ilink2, idata, i, count, base;
+
+       base = ipw_read32(priv, IPWSTATUS_ERROR_LOG);
+       count = ipw_read_reg32(priv, base);
+
+       if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) {
+               IPW_ERROR("Start IPW Error Log Dump:\n");
+               IPW_ERROR("Status: 0x%08X, Config: %08X\n",
+                         priv->status, priv->config);
+       }
+
+       for (i = ERROR_START_OFFSET;
+            i <= count * ERROR_ELEM_SIZE;
+            i += ERROR_ELEM_SIZE) {
+               desc   = ipw_read_reg32(priv, base + i);
+               time   = ipw_read_reg32(priv, base + i + 1*sizeof(u32));
+               blink1 = ipw_read_reg32(priv, base + i + 2*sizeof(u32));
+               blink2 = ipw_read_reg32(priv, base + i + 3*sizeof(u32));
+               ilink1 = ipw_read_reg32(priv, base + i + 4*sizeof(u32));
+               ilink2 = ipw_read_reg32(priv, base + i + 5*sizeof(u32));
+               idata =  ipw_read_reg32(priv, base + i + 6*sizeof(u32));
+
+               IPW_ERROR(
+                       "%s %i 0x%08x  0x%08x  0x%08x  0x%08x  0x%08x\n",
+                       ipw_error_desc(desc), time, blink1, blink2,
+                       ilink1, ilink2, idata);
+       }
+}
+
+static void ipw_dump_nic_event_log(struct ipw_priv *priv)
+{
+       u32 ev, time, data, i, count, base;
+
+       base = ipw_read32(priv, IPW_EVENT_LOG);
+       count = ipw_read_reg32(priv, base);
+
+       if (EVENT_START_OFFSET <= count * EVENT_ELEM_SIZE)
+               IPW_ERROR("Start IPW Event Log Dump:\n");
+
+       for (i = EVENT_START_OFFSET;
+            i <= count * EVENT_ELEM_SIZE;
+            i += EVENT_ELEM_SIZE) {
+               ev = ipw_read_reg32(priv, base + i);
+               time  = ipw_read_reg32(priv, base + i + 1*sizeof(u32));
+               data  = ipw_read_reg32(priv, base + i + 2*sizeof(u32));
+
+#ifdef CONFIG_IPW_DEBUG
+               IPW_ERROR("%i\t0x%08x\t%i\n", time, data, ev);
+#endif
+       }
+}
+
+static int ipw_get_ordinal(struct ipw_priv *priv, u32 ord, void *val,
+                          u32 *len)
+{
+       u32 addr, field_info, field_len, field_count, total_len;
+
+       IPW_DEBUG_ORD("ordinal = %i\n", ord);
+
+       if (!priv || !val || !len) {
+               IPW_DEBUG_ORD("Invalid argument\n");
+               return -EINVAL;
+       }
+
+       /* verify device ordinal tables have been initialized */
+       if (!priv->table0_addr || !priv->table1_addr || !priv->table2_addr) {
+               IPW_DEBUG_ORD("Access ordinals before initialization\n");
+               return -EINVAL;
+       }
+
+       switch (IPW_ORD_TABLE_ID_MASK & ord) {
+       case IPW_ORD_TABLE_0_MASK:
+               /*
+                * TABLE 0: Direct access to a table of 32 bit values
+                *
+                * This is a very simple table with the data directly
+                * read from the table
+                */
+
+               /* remove the table id from the ordinal */
+               ord &= IPW_ORD_TABLE_VALUE_MASK;
+
+               /* boundary check */
+               if (ord > priv->table0_len) {
+                       IPW_DEBUG_ORD("ordinal value (%i) longer then "
+                                     "max (%i)\n", ord, priv->table0_len);
+                       return -EINVAL;
+               }
+
+               /* verify we have enough room to store the value */
+               if (*len < sizeof(u32)) {
+                       IPW_DEBUG_ORD("ordinal buffer length too small, "
+                                     "need %zd\n", sizeof(u32));
+                       return -EINVAL;
+               }
+
+               IPW_DEBUG_ORD("Reading TABLE0[%i] from offset 0x%08x\n",
+                             ord, priv->table0_addr + (ord  << 2));
+
+               *len = sizeof(u32);
+               ord <<= 2;
+               *((u32 *)val) = ipw_read32(priv, priv->table0_addr + ord);
+               break;
+
+       case IPW_ORD_TABLE_1_MASK:
+               /*
+                * TABLE 1: Indirect access to a table of 32 bit values
+                *
+                * This is a fairly large table of u32 values each
+                * representing starting addr for the data (which is
+                * also a u32)
+                */
+
+               /* remove the table id from the ordinal */
+               ord &= IPW_ORD_TABLE_VALUE_MASK;
+
+               /* boundary check */
+               if (ord > priv->table1_len) {
+                       IPW_DEBUG_ORD("ordinal value too long\n");
+                       return -EINVAL;
+               }
+
+               /* verify we have enough room to store the value */
+               if (*len < sizeof(u32)) {
+                       IPW_DEBUG_ORD("ordinal buffer length too small, "
+                                     "need %zd\n", sizeof(u32));
+                       return -EINVAL;
+               }
+
+               *((u32 *)val) = ipw_read_reg32(priv, (priv->table1_addr + (ord << 2)));
+               *len = sizeof(u32);
+               break;
+
+       case IPW_ORD_TABLE_2_MASK:
+               /*
+                * TABLE 2: Indirect access to a table of variable sized values
+                *
+                * This table consist of six values, each containing
+                *     - dword containing the starting offset of the data
+                *     - dword containing the lengh in the first 16bits
+                *       and the count in the second 16bits
+                */
+
+               /* remove the table id from the ordinal */
+               ord &= IPW_ORD_TABLE_VALUE_MASK;
+
+               /* boundary check */
+               if (ord > priv->table2_len) {
+                       IPW_DEBUG_ORD("ordinal value too long\n");
+                       return -EINVAL;
+               }
+
+               /* get the address of statistic */
+               addr = ipw_read_reg32(priv, priv->table2_addr + (ord << 3));
+
+               /* get the second DW of statistics ;
+                * two 16-bit words - first is length, second is count */
+               field_info = ipw_read_reg32(priv, priv->table2_addr + (ord << 3) + sizeof(u32));
+
+               /* get each entry length */
+               field_len = *((u16 *)&field_info);
+
+               /* get number of entries */
+               field_count = *(((u16 *)&field_info) + 1);
+
+               /* abort if not enought memory */
+               total_len = field_len * field_count;
+               if (total_len > *len) {
+                       *len = total_len;
+                       return -EINVAL;
+               }
+
+               *len = total_len;
+               if (!total_len)
+                       return 0;
+
+               IPW_DEBUG_ORD("addr = 0x%08x, total_len = %i, "
+                             "field_info = 0x%08x\n",
+                             addr, total_len, field_info);
+               ipw_read_indirect(priv, addr, val, total_len);
+               break;
+
+       default:
+               IPW_DEBUG_ORD("Invalid ordinal!\n");
+               return -EINVAL;
+
+       }
+
+
+       return 0;
+}
+
+static void ipw_init_ordinals(struct ipw_priv *priv)
+{
+       priv->table0_addr = IPW_ORDINALS_TABLE_LOWER;
+       priv->table0_len = ipw_read32(priv, priv->table0_addr);
+
+       IPW_DEBUG_ORD("table 0 offset at 0x%08x, len = %i\n",
+                     priv->table0_addr, priv->table0_len);
+
+       priv->table1_addr = ipw_read32(priv, IPW_ORDINALS_TABLE_1);
+       priv->table1_len = ipw_read_reg32(priv, priv->table1_addr);
+
+       IPW_DEBUG_ORD("table 1 offset at 0x%08x, len = %i\n",
+                     priv->table1_addr, priv->table1_len);
+
+       priv->table2_addr = ipw_read32(priv, IPW_ORDINALS_TABLE_2);
+       priv->table2_len = ipw_read_reg32(priv, priv->table2_addr);
+       priv->table2_len &= 0x0000ffff; /* use first two bytes */
+
+       IPW_DEBUG_ORD("table 2 offset at 0x%08x, len = %i\n",
+                     priv->table2_addr, priv->table2_len);
+
+}
+
+/*
+ * The following adds a new attribute to the sysfs representation
+ * of this device driver (i.e. a new file in /sys/bus/pci/drivers/ipw/)
+ * used for controling the debug level.
+ *
+ * See the level definitions in ipw for details.
+ */
+static ssize_t show_debug_level(struct device_driver *d, char *buf)
+{
+       return sprintf(buf, "0x%08X\n", ipw_debug_level);
+}
+static ssize_t store_debug_level(struct device_driver *d,
+                               const char *buf, size_t count)
+{
+       char *p = (char *)buf;
+       u32 val;
+
+       if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
+               p++;
+               if (p[0] == 'x' || p[0] == 'X')
+                       p++;
+               val = simple_strtoul(p, &p, 16);
+       } else
+               val = simple_strtoul(p, &p, 10);
+       if (p == buf)
+               printk(KERN_INFO DRV_NAME
+                      ": %s is not in hex or decimal form.\n", buf);
+       else
+               ipw_debug_level = val;
+
+       return strnlen(buf, count);
+}
+
+static DRIVER_ATTR(debug_level, S_IWUSR | S_IRUGO,
+                  show_debug_level, store_debug_level);
+
+static ssize_t show_status(struct device *d,
+                       struct device_attribute *attr, char *buf)
+{
+       struct ipw_priv *p = d->driver_data;
+       return sprintf(buf, "0x%08x\n", (int)p->status);
+}
+static DEVICE_ATTR(status, S_IRUGO, show_status, NULL);
+
+static ssize_t show_cfg(struct device *d, struct device_attribute *attr,
+                       char *buf)
+{
+       struct ipw_priv *p = d->driver_data;
+       return sprintf(buf, "0x%08x\n", (int)p->config);
+}
+static DEVICE_ATTR(cfg, S_IRUGO, show_cfg, NULL);
+
+static ssize_t show_nic_type(struct device *d,
+                       struct device_attribute *attr, char *buf)
+{
+       struct ipw_priv *p = d->driver_data;
+       u8 type = p->eeprom[EEPROM_NIC_TYPE];
+
+       switch (type) {
+       case EEPROM_NIC_TYPE_STANDARD:
+               return sprintf(buf, "STANDARD\n");
+       case EEPROM_NIC_TYPE_DELL:
+               return sprintf(buf, "DELL\n");
+       case EEPROM_NIC_TYPE_FUJITSU:
+               return sprintf(buf, "FUJITSU\n");
+       case EEPROM_NIC_TYPE_IBM:
+               return sprintf(buf, "IBM\n");
+       case EEPROM_NIC_TYPE_HP:
+               return sprintf(buf, "HP\n");
+       }
+
+       return sprintf(buf, "UNKNOWN\n");
+}
+static DEVICE_ATTR(nic_type, S_IRUGO, show_nic_type, NULL);
+
+static ssize_t dump_error_log(struct device *d,
+               struct device_attribute *attr, const char *buf, size_t count)
+{
+       char *p = (char *)buf;
+
+       if (p[0] == '1')
+               ipw_dump_nic_error_log((struct ipw_priv*)d->driver_data);
+
+       return strnlen(buf, count);
+}
+static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, dump_error_log);
+
+static ssize_t dump_event_log(struct device *d,
+               struct device_attribute *attr, const char *buf, size_t count)
+{
+       char *p = (char *)buf;
+
+       if (p[0] == '1')
+               ipw_dump_nic_event_log((struct ipw_priv*)d->driver_data);
+
+       return strnlen(buf, count);
+}
+static DEVICE_ATTR(dump_events, S_IWUSR, NULL, dump_event_log);
+
+static ssize_t show_ucode_version(struct device *d,
+                       struct device_attribute *attr, char *buf)
+{
+       u32 len = sizeof(u32), tmp = 0;
+       struct ipw_priv *p = d->driver_data;
+
+       if(ipw_get_ordinal(p, IPW_ORD_STAT_UCODE_VERSION, &tmp, &len))
+               return 0;
+
+       return sprintf(buf, "0x%08x\n", tmp);
+}
+static DEVICE_ATTR(ucode_version, S_IWUSR|S_IRUGO, show_ucode_version, NULL);
+
+static ssize_t show_rtc(struct device *d, struct device_attribute *attr,
+                       char *buf)
+{
+       u32 len = sizeof(u32), tmp = 0;
+       struct ipw_priv *p = d->driver_data;
+
+       if(ipw_get_ordinal(p, IPW_ORD_STAT_RTC, &tmp, &len))
+               return 0;
+
+       return sprintf(buf, "0x%08x\n", tmp);
+}
+static DEVICE_ATTR(rtc, S_IWUSR|S_IRUGO, show_rtc, NULL);
+
+/*
+ * Add a device attribute to view/control the delay between eeprom
+ * operations.
+ */
+static ssize_t show_eeprom_delay(struct device *d,
+                       struct device_attribute *attr, char *buf)
+{
+       int n = ((struct ipw_priv*)d->driver_data)->eeprom_delay;
+       return sprintf(buf, "%i\n", n);
+}
+static ssize_t store_eeprom_delay(struct device *d,
+                       struct device_attribute *attr, const char *buf,
+                       size_t count)
+{
+       struct ipw_priv *p = d->driver_data;
+       sscanf(buf, "%i", &p->eeprom_delay);
+       return strnlen(buf, count);
+}
+static DEVICE_ATTR(eeprom_delay, S_IWUSR|S_IRUGO,
+                  show_eeprom_delay,store_eeprom_delay);
+
+static ssize_t show_command_event_reg(struct device *d,
+                       struct device_attribute *attr, char *buf)
+{
+       u32 reg = 0;
+       struct ipw_priv *p = d->driver_data;
+
+       reg = ipw_read_reg32(p, CX2_INTERNAL_CMD_EVENT);
+       return sprintf(buf, "0x%08x\n", reg);
+}
+static ssize_t store_command_event_reg(struct device *d,
+                               struct device_attribute *attr, const char *buf,
+                               size_t count)
+{
+       u32 reg;
+       struct ipw_priv *p = d->driver_data;
+
+       sscanf(buf, "%x", &reg);
+       ipw_write_reg32(p, CX2_INTERNAL_CMD_EVENT, reg);
+       return strnlen(buf, count);
+}
+static DEVICE_ATTR(command_event_reg, S_IWUSR|S_IRUGO,
+                  show_command_event_reg,store_command_event_reg);
+
+static ssize_t show_mem_gpio_reg(struct device *d,
+                               struct device_attribute *attr, char *buf)
+{
+       u32 reg = 0;
+       struct ipw_priv *p = d->driver_data;
+
+       reg = ipw_read_reg32(p, 0x301100);
+       return sprintf(buf, "0x%08x\n", reg);
+}
+static ssize_t store_mem_gpio_reg(struct device *d,
+                       struct device_attribute *attr, const char *buf,
+                       size_t count)
+{
+       u32 reg;
+       struct ipw_priv *p = d->driver_data;
+
+       sscanf(buf, "%x", &reg);
+       ipw_write_reg32(p, 0x301100, reg);
+       return strnlen(buf, count);
+}
+static DEVICE_ATTR(mem_gpio_reg, S_IWUSR|S_IRUGO,
+                  show_mem_gpio_reg,store_mem_gpio_reg);
+
+static ssize_t show_indirect_dword(struct device *d,
+                               struct device_attribute *attr, char *buf)
+{
+       u32 reg = 0;
+       struct ipw_priv *priv = d->driver_data;
+       if (priv->status & STATUS_INDIRECT_DWORD)
+               reg = ipw_read_reg32(priv, priv->indirect_dword);
+       else
+               reg = 0;
+
+       return sprintf(buf, "0x%08x\n", reg);
+}
+static ssize_t store_indirect_dword(struct device *d,
+                               struct device_attribute *attr, const char *buf,
+                               size_t count)
+{
+       struct ipw_priv *priv = d->driver_data;
+
+       sscanf(buf, "%x", &priv->indirect_dword);
+       priv->status |= STATUS_INDIRECT_DWORD;
+       return strnlen(buf, count);
+}
+static DEVICE_ATTR(indirect_dword, S_IWUSR|S_IRUGO,
+                  show_indirect_dword,store_indirect_dword);
+
+static ssize_t show_indirect_byte(struct device *d,
+                       struct device_attribute *attr, char *buf)
+{
+       u8 reg = 0;
+       struct ipw_priv *priv = d->driver_data;
+       if (priv->status & STATUS_INDIRECT_BYTE)
+               reg = ipw_read_reg8(priv, priv->indirect_byte);
+       else
+               reg = 0;
+
+       return sprintf(buf, "0x%02x\n", reg);
+}
+static ssize_t store_indirect_byte(struct device *d,
+                               struct device_attribute *attr, const char *buf,
+                               size_t count)
+{
+       struct ipw_priv *priv = d->driver_data;
+
+       sscanf(buf, "%x", &priv->indirect_byte);
+       priv->status |= STATUS_INDIRECT_BYTE;
+       return strnlen(buf, count);
+}
+static DEVICE_ATTR(indirect_byte, S_IWUSR|S_IRUGO,
+                  show_indirect_byte, store_indirect_byte);
+
+static ssize_t show_direct_dword(struct device *d,
+                               struct device_attribute *attr, char *buf)
+{
+       u32 reg = 0;
+       struct ipw_priv *priv = d->driver_data;
+
+       if (priv->status & STATUS_DIRECT_DWORD)
+               reg = ipw_read32(priv, priv->direct_dword);
+       else
+               reg = 0;
+
+       return sprintf(buf, "0x%08x\n", reg);
+}
+static ssize_t store_direct_dword(struct device *d,
+                       struct device_attribute *attr, const char *buf,
+                       size_t count)
+{
+       struct ipw_priv *priv = d->driver_data;
+
+       sscanf(buf, "%x", &priv->direct_dword);
+       priv->status |= STATUS_DIRECT_DWORD;
+       return strnlen(buf, count);
+}
+static DEVICE_ATTR(direct_dword, S_IWUSR|S_IRUGO,
+                  show_direct_dword,store_direct_dword);
+
+
+static inline int rf_kill_active(struct ipw_priv *priv)
+{
+       if (0 == (ipw_read32(priv, 0x30) & 0x10000))
+               priv->status |= STATUS_RF_KILL_HW;
+       else
+               priv->status &= ~STATUS_RF_KILL_HW;
+
+       return (priv->status & STATUS_RF_KILL_HW) ? 1 : 0;
+}
+
+static ssize_t show_rf_kill(struct device *d, struct device_attribute *attr,
+                               char *buf)
+{
+       /* 0 - RF kill not enabled
+          1 - SW based RF kill active (sysfs)
+          2 - HW based RF kill active
+          3 - Both HW and SW baed RF kill active */
+       struct ipw_priv *priv = d->driver_data;
+       int val = ((priv->status & STATUS_RF_KILL_SW) ? 0x1 : 0x0) |
+               (rf_kill_active(priv) ? 0x2 : 0x0);
+       return sprintf(buf, "%i\n", val);
+}
+
+static int ipw_radio_kill_sw(struct ipw_priv *priv, int disable_radio)
+{
+       if ((disable_radio ? 1 : 0) ==
+           (priv->status & STATUS_RF_KILL_SW ? 1 : 0))
+               return 0 ;
+
+       IPW_DEBUG_RF_KILL("Manual SW RF Kill set to: RADIO  %s\n",
+                         disable_radio ? "OFF" : "ON");
+
+       if (disable_radio) {
+               priv->status |= STATUS_RF_KILL_SW;
+
+               if (priv->workqueue) {
+                       cancel_delayed_work(&priv->request_scan);
+               }
+               wake_up_interruptible(&priv->wait_command_queue);
+               queue_work(priv->workqueue, &priv->down);
+       } else {
+               priv->status &= ~STATUS_RF_KILL_SW;
+               if (rf_kill_active(priv)) {
+                       IPW_DEBUG_RF_KILL("Can not turn radio back on - "
+                                         "disabled by HW switch\n");
+                       /* Make sure the RF_KILL check timer is running */
+                       cancel_delayed_work(&priv->rf_kill);
+                       queue_delayed_work(priv->workqueue, &priv->rf_kill,
+                                          2 * HZ);
+               } else
+                       queue_work(priv->workqueue, &priv->up);
+       }
+
+       return 1;
+}
+
+static ssize_t store_rf_kill(struct device *d,  struct device_attribute *attr,
+                               const char *buf, size_t count)
+{
+       struct ipw_priv *priv = d->driver_data;
+
+       ipw_radio_kill_sw(priv, buf[0] == '1');
+
+       return count;
+}
+static DEVICE_ATTR(rf_kill, S_IWUSR|S_IRUGO, show_rf_kill, store_rf_kill);
+
+static void ipw_irq_tasklet(struct ipw_priv *priv)
+{
+       u32 inta, inta_mask, handled = 0;
+       unsigned long flags;
+       int rc = 0;
+
+       spin_lock_irqsave(&priv->lock, flags);
+
+       inta = ipw_read32(priv, CX2_INTA_RW);
+       inta_mask = ipw_read32(priv, CX2_INTA_MASK_R);
+       inta &= (CX2_INTA_MASK_ALL & inta_mask);
+
+       /* Add any cached INTA values that need to be handled */
+       inta |= priv->isr_inta;
+
+       /* handle all the justifications for the interrupt */
+       if (inta & CX2_INTA_BIT_RX_TRANSFER) {
+               ipw_rx(priv);
+               handled |= CX2_INTA_BIT_RX_TRANSFER;
+       }
+
+       if (inta & CX2_INTA_BIT_TX_CMD_QUEUE) {
+               IPW_DEBUG_HC("Command completed.\n");
+               rc = ipw_queue_tx_reclaim( priv, &priv->txq_cmd, -1);
+               priv->status &= ~STATUS_HCMD_ACTIVE;
+               wake_up_interruptible(&priv->wait_command_queue);
+               handled |= CX2_INTA_BIT_TX_CMD_QUEUE;
+       }
+
+       if (inta & CX2_INTA_BIT_TX_QUEUE_1) {
+               IPW_DEBUG_TX("TX_QUEUE_1\n");
+               rc = ipw_queue_tx_reclaim( priv, &priv->txq[0], 0);
+               handled |= CX2_INTA_BIT_TX_QUEUE_1;
+       }
+
+       if (inta & CX2_INTA_BIT_TX_QUEUE_2) {
+               IPW_DEBUG_TX("TX_QUEUE_2\n");
+               rc = ipw_queue_tx_reclaim( priv, &priv->txq[1], 1);
+               handled |= CX2_INTA_BIT_TX_QUEUE_2;
+       }
+
+       if (inta & CX2_INTA_BIT_TX_QUEUE_3) {
+               IPW_DEBUG_TX("TX_QUEUE_3\n");
+               rc = ipw_queue_tx_reclaim( priv, &priv->txq[2], 2);
+               handled |= CX2_INTA_BIT_TX_QUEUE_3;
+       }
+
+       if (inta & CX2_INTA_BIT_TX_QUEUE_4) {
+               IPW_DEBUG_TX("TX_QUEUE_4\n");
+               rc = ipw_queue_tx_reclaim( priv, &priv->txq[3], 3);
+               handled |= CX2_INTA_BIT_TX_QUEUE_4;
+       }
+
+       if (inta & CX2_INTA_BIT_STATUS_CHANGE) {
+               IPW_WARNING("STATUS_CHANGE\n");
+               handled |= CX2_INTA_BIT_STATUS_CHANGE;
+       }
+
+       if (inta & CX2_INTA_BIT_BEACON_PERIOD_EXPIRED) {
+               IPW_WARNING("TX_PERIOD_EXPIRED\n");
+               handled |= CX2_INTA_BIT_BEACON_PERIOD_EXPIRED;
+       }
+
+       if (inta & CX2_INTA_BIT_SLAVE_MODE_HOST_CMD_DONE) {
+               IPW_WARNING("HOST_CMD_DONE\n");
+               handled |= CX2_INTA_BIT_SLAVE_MODE_HOST_CMD_DONE;
+       }
+
+       if (inta & CX2_INTA_BIT_FW_INITIALIZATION_DONE) {
+               IPW_WARNING("FW_INITIALIZATION_DONE\n");
+               handled |= CX2_INTA_BIT_FW_INITIALIZATION_DONE;
+       }
+
+       if (inta & CX2_INTA_BIT_FW_CARD_DISABLE_PHY_OFF_DONE) {
+               IPW_WARNING("PHY_OFF_DONE\n");
+               handled |= CX2_INTA_BIT_FW_CARD_DISABLE_PHY_OFF_DONE;
+       }
+
+       if (inta & CX2_INTA_BIT_RF_KILL_DONE) {
+               IPW_DEBUG_RF_KILL("RF_KILL_DONE\n");
+               priv->status |= STATUS_RF_KILL_HW;
+               wake_up_interruptible(&priv->wait_command_queue);
+               netif_carrier_off(priv->net_dev);
+               netif_stop_queue(priv->net_dev);
+               cancel_delayed_work(&priv->request_scan);
+               queue_delayed_work(priv->workqueue, &priv->rf_kill, 2 * HZ);
+               handled |= CX2_INTA_BIT_RF_KILL_DONE;
+       }
+
+       if (inta & CX2_INTA_BIT_FATAL_ERROR) {
+               IPW_ERROR("Firmware error detected.  Restarting.\n");
+#ifdef CONFIG_IPW_DEBUG
+               if (ipw_debug_level & IPW_DL_FW_ERRORS) {
+                       ipw_dump_nic_error_log(priv);
+                       ipw_dump_nic_event_log(priv);
+               }
+#endif
+               queue_work(priv->workqueue, &priv->adapter_restart);
+               handled |= CX2_INTA_BIT_FATAL_ERROR;
+       }
+
+       if (inta & CX2_INTA_BIT_PARITY_ERROR) {
+               IPW_ERROR("Parity error\n");
+               handled |= CX2_INTA_BIT_PARITY_ERROR;
+       }
+
+       if (handled != inta) {
+               IPW_ERROR("Unhandled INTA bits 0x%08x\n",
+                               inta & ~handled);
+       }
+
+       /* enable all interrupts */
+       ipw_enable_interrupts(priv);
+
+       spin_unlock_irqrestore(&priv->lock, flags);
+}
+
+#ifdef CONFIG_IPW_DEBUG
+#define IPW_CMD(x) case IPW_CMD_ ## x : return #x
+static char *get_cmd_string(u8 cmd)
+{
+       switch (cmd) {
+               IPW_CMD(HOST_COMPLETE);
+               IPW_CMD(POWER_DOWN);
+               IPW_CMD(SYSTEM_CONFIG);
+               IPW_CMD(MULTICAST_ADDRESS);
+               IPW_CMD(SSID);
+               IPW_CMD(ADAPTER_ADDRESS);
+               IPW_CMD(PORT_TYPE);
+               IPW_CMD(RTS_THRESHOLD);
+               IPW_CMD(FRAG_THRESHOLD);
+               IPW_CMD(POWER_MODE);
+               IPW_CMD(WEP_KEY);
+               IPW_CMD(TGI_TX_KEY);
+               IPW_CMD(SCAN_REQUEST);
+               IPW_CMD(SCAN_REQUEST_EXT);
+               IPW_CMD(ASSOCIATE);
+               IPW_CMD(SUPPORTED_RATES);
+               IPW_CMD(SCAN_ABORT);
+               IPW_CMD(TX_FLUSH);
+               IPW_CMD(QOS_PARAMETERS);
+               IPW_CMD(DINO_CONFIG);
+               IPW_CMD(RSN_CAPABILITIES);
+               IPW_CMD(RX_KEY);
+               IPW_CMD(CARD_DISABLE);
+               IPW_CMD(SEED_NUMBER);
+               IPW_CMD(TX_POWER);
+               IPW_CMD(COUNTRY_INFO);
+               IPW_CMD(AIRONET_INFO);
+               IPW_CMD(AP_TX_POWER);
+               IPW_CMD(CCKM_INFO);
+               IPW_CMD(CCX_VER_INFO);
+               IPW_CMD(SET_CALIBRATION);
+               IPW_CMD(SENSITIVITY_CALIB);
+               IPW_CMD(RETRY_LIMIT);
+               IPW_CMD(IPW_PRE_POWER_DOWN);
+               IPW_CMD(VAP_BEACON_TEMPLATE);
+               IPW_CMD(VAP_DTIM_PERIOD);
+               IPW_CMD(EXT_SUPPORTED_RATES);
+               IPW_CMD(VAP_LOCAL_TX_PWR_CONSTRAINT);
+               IPW_CMD(VAP_QUIET_INTERVALS);
+               IPW_CMD(VAP_CHANNEL_SWITCH);
+               IPW_CMD(VAP_MANDATORY_CHANNELS);
+               IPW_CMD(VAP_CELL_PWR_LIMIT);
+               IPW_CMD(VAP_CF_PARAM_SET);
+               IPW_CMD(VAP_SET_BEACONING_STATE);
+               IPW_CMD(MEASUREMENT);
+               IPW_CMD(POWER_CAPABILITY);
+               IPW_CMD(SUPPORTED_CHANNELS);
+               IPW_CMD(TPC_REPORT);
+               IPW_CMD(WME_INFO);
+               IPW_CMD(PRODUCTION_COMMAND);
+       default:
+               return "UNKNOWN";
+       }
+}
+#endif /* CONFIG_IPW_DEBUG */
+
+#define HOST_COMPLETE_TIMEOUT HZ
+static int ipw_send_cmd(struct ipw_priv *priv, struct host_cmd *cmd)
+{
+       int rc = 0;
+
+       if (priv->status & STATUS_HCMD_ACTIVE) {
+               IPW_ERROR("Already sending a command\n");
+               return -1;
+       }
+
+       priv->status |= STATUS_HCMD_ACTIVE;
+
+       IPW_DEBUG_HC("Sending %s command (#%d), %d bytes\n",
+                    get_cmd_string(cmd->cmd), cmd->cmd, cmd->len);
+       printk_buf(IPW_DL_HOST_COMMAND, (u8*)cmd->param, cmd->len);
+
+       rc = ipw_queue_tx_hcmd(priv, cmd->cmd, &cmd->param, cmd->len, 0);
+       if (rc)
+               return rc;
+
+       rc = wait_event_interruptible_timeout(
+               priv->wait_command_queue, !(priv->status & STATUS_HCMD_ACTIVE),
+               HOST_COMPLETE_TIMEOUT);
+       if (rc == 0) {
+               IPW_DEBUG_INFO("Command completion failed out after %dms.\n",
+                              jiffies_to_msecs(HOST_COMPLETE_TIMEOUT));
+               priv->status &= ~STATUS_HCMD_ACTIVE;
+               return -EIO;
+       }
+       if (priv->status & STATUS_RF_KILL_MASK) {
+               IPW_DEBUG_INFO("Command aborted due to RF Kill Switch\n");
+               return -EIO;
+       }
+
+       return 0;
+}
+
+static int ipw_send_host_complete(struct ipw_priv *priv)
+{
+       struct host_cmd cmd = {
+               .cmd = IPW_CMD_HOST_COMPLETE,
+               .len = 0
+       };
+
+       if (!priv) {
+               IPW_ERROR("Invalid args\n");
+               return -1;
+       }
+
+       if (ipw_send_cmd(priv, &cmd)) {
+               IPW_ERROR("failed to send HOST_COMPLETE command\n");
+               return -1;
+       }
+
+       return 0;
+}
+
+static int ipw_send_system_config(struct ipw_priv *priv,
+                                 struct ipw_sys_config *config)
+{
+       struct host_cmd cmd = {
+               .cmd = IPW_CMD_SYSTEM_CONFIG,
+               .len = sizeof(*config)
+       };
+
+       if (!priv || !config) {
+               IPW_ERROR("Invalid args\n");
+               return -1;
+       }
+
+       memcpy(&cmd.param,config,sizeof(*config));
+       if (ipw_send_cmd(priv, &cmd)) {
+               IPW_ERROR("failed to send SYSTEM_CONFIG command\n");
+               return -1;
+       }
+
+       return 0;
+}
+
+static int ipw_send_ssid(struct ipw_priv *priv, u8 *ssid, int len)
+{
+       struct host_cmd cmd = {
+               .cmd = IPW_CMD_SSID,
+               .len = min(len, IW_ESSID_MAX_SIZE)
+       };
+
+       if (!priv || !ssid) {
+               IPW_ERROR("Invalid args\n");
+               return -1;
+       }
+
+       memcpy(&cmd.param, ssid, cmd.len);
+       if (ipw_send_cmd(priv, &cmd)) {
+               IPW_ERROR("failed to send SSID command\n");
+               return -1;
+       }
+
+       return 0;
+}
+
+static int ipw_send_adapter_address(struct ipw_priv *priv, u8 *mac)
+{
+       struct host_cmd cmd = {
+               .cmd = IPW_CMD_ADAPTER_ADDRESS,
+               .len = ETH_ALEN
+       };
+
+       if (!priv || !mac) {
+               IPW_ERROR("Invalid args\n");
+               return -1;
+       }
+
+       IPW_DEBUG_INFO("%s: Setting MAC to " MAC_FMT "\n",
+                      priv->net_dev->name, MAC_ARG(mac));
+
+       memcpy(&cmd.param, mac, ETH_ALEN);
+
+       if (ipw_send_cmd(priv, &cmd)) {
+               IPW_ERROR("failed to send ADAPTER_ADDRESS command\n");
+               return -1;
+       }
+
+       return 0;
+}
+
+static void ipw_adapter_restart(void *adapter)
+{
+       struct ipw_priv *priv = adapter;
+
+       if (priv->status & STATUS_RF_KILL_MASK)
+               return;
+
+       ipw_down(priv);
+       if (ipw_up(priv)) {
+               IPW_ERROR("Failed to up device\n");
+               return;
+       }
+}
+
+
+
+
+#define IPW_SCAN_CHECK_WATCHDOG (5 * HZ)
+
+static void ipw_scan_check(void *data)
+{
+       struct ipw_priv *priv = data;
+       if (priv->status & (STATUS_SCANNING | STATUS_SCAN_ABORTING)) {
+               IPW_DEBUG_SCAN("Scan completion watchdog resetting "
+                              "adapter (%dms).\n",
+                              IPW_SCAN_CHECK_WATCHDOG / 100);
+               ipw_adapter_restart(priv);
+       }
+}
+
+static int ipw_send_scan_request_ext(struct ipw_priv *priv,
+                                    struct ipw_scan_request_ext *request)
+{
+       struct host_cmd cmd = {
+               .cmd = IPW_CMD_SCAN_REQUEST_EXT,
+               .len = sizeof(*request)
+       };
+
+       if (!priv || !request) {
+               IPW_ERROR("Invalid args\n");
+               return -1;
+       }
+
+       memcpy(&cmd.param,request,sizeof(*request));
+       if (ipw_send_cmd(priv, &cmd)) {
+               IPW_ERROR("failed to send SCAN_REQUEST_EXT command\n");
+               return -1;
+       }
+
+       queue_delayed_work(priv->workqueue, &priv->scan_check,
+                          IPW_SCAN_CHECK_WATCHDOG);
+       return 0;
+}
+
+static int ipw_send_scan_abort(struct ipw_priv *priv)
+{
+       struct host_cmd cmd = {
+               .cmd = IPW_CMD_SCAN_ABORT,
+               .len = 0
+       };
+
+       if (!priv) {
+               IPW_ERROR("Invalid args\n");
+               return -1;
+       }
+
+       if (ipw_send_cmd(priv, &cmd)) {
+               IPW_ERROR("failed to send SCAN_ABORT command\n");
+               return -1;
+       }
+
+       return 0;
+}
+
+static int ipw_set_sensitivity(struct ipw_priv *priv, u16 sens)
+{
+       struct host_cmd cmd = {
+               .cmd = IPW_CMD_SENSITIVITY_CALIB,
+               .len = sizeof(struct ipw_sensitivity_calib)
+       };
+       struct ipw_sensitivity_calib *calib = (struct ipw_sensitivity_calib *)
+               &cmd.param;
+       calib->beacon_rssi_raw = sens;
+       if (ipw_send_cmd(priv, &cmd)) {
+               IPW_ERROR("failed to send SENSITIVITY CALIB command\n");
+               return -1;
+       }
+
+       return 0;
+}
+
+static int ipw_send_associate(struct ipw_priv *priv,
+                             struct ipw_associate *associate)
+{
+       struct host_cmd cmd = {
+               .cmd = IPW_CMD_ASSOCIATE,
+               .len = sizeof(*associate)
+       };
+
+       if (!priv || !associate) {
+               IPW_ERROR("Invalid args\n");
+               return -1;
+       }
+
+       memcpy(&cmd.param,associate,sizeof(*associate));
+       if (ipw_send_cmd(priv, &cmd)) {
+               IPW_ERROR("failed to send ASSOCIATE command\n");
+               return -1;
+       }
+
+       return 0;
+}
+
+static int ipw_send_supported_rates(struct ipw_priv *priv,
+                                   struct ipw_supported_rates *rates)
+{
+       struct host_cmd cmd = {
+               .cmd = IPW_CMD_SUPPORTED_RATES,
+               .len = sizeof(*rates)
+       };
+
+       if (!priv || !rates) {
+               IPW_ERROR("Invalid args\n");
+               return -1;
+       }
+
+       memcpy(&cmd.param,rates,sizeof(*rates));
+       if (ipw_send_cmd(priv, &cmd)) {
+               IPW_ERROR("failed to send SUPPORTED_RATES command\n");
+               return -1;
+       }
+
+       return 0;
+}
+
+static int ipw_set_random_seed(struct ipw_priv *priv)
+{
+       struct host_cmd cmd = {
+               .cmd = IPW_CMD_SEED_NUMBER,
+               .len = sizeof(u32)
+       };
+
+       if (!priv) {
+               IPW_ERROR("Invalid args\n");
+               return -1;
+       }
+
+       get_random_bytes(&cmd.param, sizeof(u32));
+
+       if (ipw_send_cmd(priv, &cmd)) {
+               IPW_ERROR("failed to send SEED_NUMBER command\n");
+               return -1;
+       }
+
+       return 0;
+}
+
+#if 0
+static int ipw_send_card_disable(struct ipw_priv *priv, u32 phy_off)
+{
+       struct host_cmd cmd = {
+               .cmd = IPW_CMD_CARD_DISABLE,
+               .len = sizeof(u32)
+       };
+
+       if (!priv) {
+               IPW_ERROR("Invalid args\n");
+               return -1;
+       }
+
+       *((u32*)&cmd.param) = phy_off;
+
+       if (ipw_send_cmd(priv, &cmd)) {
+               IPW_ERROR("failed to send CARD_DISABLE command\n");
+               return -1;
+       }
+
+       return 0;
+}
+#endif
+
+static int ipw_send_tx_power(struct ipw_priv *priv,
+                            struct ipw_tx_power *power)
+{
+       struct host_cmd cmd = {
+               .cmd = IPW_CMD_TX_POWER,
+               .len = sizeof(*power)
+       };
+
+       if (!priv || !power) {
+               IPW_ERROR("Invalid args\n");
+               return -1;
+       }
+
+       memcpy(&cmd.param,power,sizeof(*power));
+       if (ipw_send_cmd(priv, &cmd)) {
+               IPW_ERROR("failed to send TX_POWER command\n");
+               return -1;
+       }
+
+       return 0;
+}
+
+static int ipw_send_rts_threshold(struct ipw_priv *priv, u16 rts)
+{
+       struct ipw_rts_threshold rts_threshold = {
+               .rts_threshold = rts,
+       };
+       struct host_cmd cmd = {
+               .cmd = IPW_CMD_RTS_THRESHOLD,
+               .len = sizeof(rts_threshold)
+       };
+
+       if (!priv) {
+               IPW_ERROR("Invalid args\n");
+               return -1;
+       }
+
+       memcpy(&cmd.param, &rts_threshold, sizeof(rts_threshold));
+       if (ipw_send_cmd(priv, &cmd)) {
+               IPW_ERROR("failed to send RTS_THRESHOLD command\n");
+               return -1;
+       }
+
+       return 0;
+}
+
+static int ipw_send_frag_threshold(struct ipw_priv *priv, u16 frag)
+{
+       struct ipw_frag_threshold frag_threshold = {
+               .frag_threshold = frag,
+       };
+       struct host_cmd cmd = {
+               .cmd = IPW_CMD_FRAG_THRESHOLD,
+               .len = sizeof(frag_threshold)
+       };
+
+       if (!priv) {
+               IPW_ERROR("Invalid args\n");
+               return -1;
+       }
+
+       memcpy(&cmd.param, &frag_threshold, sizeof(frag_threshold));
+       if (ipw_send_cmd(priv, &cmd)) {
+               IPW_ERROR("failed to send FRAG_THRESHOLD command\n");
+               return -1;
+       }
+
+       return 0;
+}
+
+static int ipw_send_power_mode(struct ipw_priv *priv, u32 mode)
+{
+       struct host_cmd cmd = {
+               .cmd = IPW_CMD_POWER_MODE,
+               .len = sizeof(u32)
+       };
+       u32 *param = (u32*)(&cmd.param);
+
+       if (!priv) {
+               IPW_ERROR("Invalid args\n");
+               return -1;
+       }
+
+       /* If on battery, set to 3, if AC set to CAM, else user
+        * level */
+       switch (mode) {
+       case IPW_POWER_BATTERY:
+               *param = IPW_POWER_INDEX_3;
+               break;
+       case IPW_POWER_AC:
+               *param = IPW_POWER_MODE_CAM;
+               break;
+       default:
+               *param = mode;
+               break;
+       }
+
+       if (ipw_send_cmd(priv, &cmd)) {
+               IPW_ERROR("failed to send POWER_MODE command\n");
+               return -1;
+       }
+
+       return 0;
+}
+
+/*
+ * The IPW device contains a Microwire compatible EEPROM that stores
+ * various data like the MAC address.  Usually the firmware has exclusive
+ * access to the eeprom, but during device initialization (before the
+ * device driver has sent the HostComplete command to the firmware) the
+ * device driver has read access to the EEPROM by way of indirect addressing
+ * through a couple of memory mapped registers.
+ *
+ * The following is a simplified implementation for pulling data out of the
+ * the eeprom, along with some helper functions to find information in
+ * the per device private data's copy of the eeprom.
+ *
+ * NOTE: To better understand how these functions work (i.e what is a chip
+ *       select and why do have to keep driving the eeprom clock?), read
+ *       just about any data sheet for a Microwire compatible EEPROM.
+ */
+
+/* write a 32 bit value into the indirect accessor register */
+static inline void eeprom_write_reg(struct ipw_priv *p, u32 data)
+{
+       ipw_write_reg32(p, FW_MEM_REG_EEPROM_ACCESS, data);
+
+       /* the eeprom requires some time to complete the operation */
+       udelay(p->eeprom_delay);
+
+       return;
+}
+
+/* perform a chip select operation */
+static inline void eeprom_cs(struct ipw_priv* priv)
+{
+       eeprom_write_reg(priv,0);
+       eeprom_write_reg(priv,EEPROM_BIT_CS);
+       eeprom_write_reg(priv,EEPROM_BIT_CS|EEPROM_BIT_SK);
+       eeprom_write_reg(priv,EEPROM_BIT_CS);
+}
+
+/* perform a chip select operation */
+static inline void eeprom_disable_cs(struct ipw_priv* priv)
+{
+       eeprom_write_reg(priv,EEPROM_BIT_CS);
+       eeprom_write_reg(priv,0);
+       eeprom_write_reg(priv,EEPROM_BIT_SK);
+}
+
+/* push a single bit down to the eeprom */
+static inline void eeprom_write_bit(struct ipw_priv *p,u8 bit)
+{
+       int d = ( bit ? EEPROM_BIT_DI : 0);
+       eeprom_write_reg(p,EEPROM_BIT_CS|d);
+       eeprom_write_reg(p,EEPROM_BIT_CS|d|EEPROM_BIT_SK);
+}
+
+/* push an opcode followed by an address down to the eeprom */
+static void eeprom_op(struct ipw_priv* priv, u8 op, u8 addr)
+{
+       int i;
+
+       eeprom_cs(priv);
+       eeprom_write_bit(priv,1);
+       eeprom_write_bit(priv,op&2);
+       eeprom_write_bit(priv,op&1);
+       for ( i=7; i>=0; i-- ) {
+               eeprom_write_bit(priv,addr&(1<<i));
+       }
+}
+
+/* pull 16 bits off the eeprom, one bit at a time */
+static u16 eeprom_read_u16(struct ipw_priv* priv, u8 addr)
+{
+       int i;
+       u16 r=0;
+
+       /* Send READ Opcode */
+       eeprom_op(priv,EEPROM_CMD_READ,addr);
+
+       /* Send dummy bit */
+       eeprom_write_reg(priv,EEPROM_BIT_CS);
+
+       /* Read the byte off the eeprom one bit at a time */
+       for ( i=0; i<16; i++ ) {
+               u32 data = 0;
+               eeprom_write_reg(priv,EEPROM_BIT_CS|EEPROM_BIT_SK);
+               eeprom_write_reg(priv,EEPROM_BIT_CS);
+               data = ipw_read_reg32(priv,FW_MEM_REG_EEPROM_ACCESS);
+               r = (r<<1) | ((data & EEPROM_BIT_DO)?1:0);
+       }
+
+       /* Send another dummy bit */
+       eeprom_write_reg(priv,0);
+       eeprom_disable_cs(priv);
+
+       return r;
+}
+
+/* helper function for pulling the mac address out of the private */
+/* data's copy of the eeprom data                                 */
+static void eeprom_parse_mac(struct ipw_priv* priv, u8* mac)
+{
+       u8* ee = (u8*)priv->eeprom;
+       memcpy(mac, &ee[EEPROM_MAC_ADDRESS], 6);
+}
+
+/*
+ * Either the device driver (i.e. the host) or the firmware can
+ * load eeprom data into the designated region in SRAM.  If neither
+ * happens then the FW will shutdown with a fatal error.
+ *
+ * In order to signal the FW to load the EEPROM, the EEPROM_LOAD_DISABLE
+ * bit needs region of shared SRAM needs to be non-zero.
+ */
+static void ipw_eeprom_init_sram(struct ipw_priv *priv)
+{
+       int i;
+       u16 *eeprom = (u16 *)priv->eeprom;
+
+       IPW_DEBUG_TRACE(">>\n");
+
+       /* read entire contents of eeprom into private buffer */
+       for ( i=0; i<128; i++ )
+               eeprom[i] = eeprom_read_u16(priv,(u8)i);
+
+       /*
+          If the data looks correct, then copy it to our private
+          copy.  Otherwise let the firmware know to perform the operation
+          on it's own
+       */
+       if ((priv->eeprom + EEPROM_VERSION) != 0) {
+               IPW_DEBUG_INFO("Writing EEPROM data into SRAM\n");
+
+               /* write the eeprom data to sram */
+               for( i=0; i<CX2_EEPROM_IMAGE_SIZE; i++ )
+                       ipw_write8(priv, IPW_EEPROM_DATA + i,
+                                  priv->eeprom[i]);
+
+               /* Do not load eeprom data on fatal error or suspend */
+               ipw_write32(priv, IPW_EEPROM_LOAD_DISABLE, 0);
+       } else {
+               IPW_DEBUG_INFO("Enabling FW initializationg of SRAM\n");
+
+               /* Load eeprom data on fatal error or suspend */
+               ipw_write32(priv, IPW_EEPROM_LOAD_DISABLE, 1);
+       }
+
+       IPW_DEBUG_TRACE("<<\n");
+}
+
+
+static inline void ipw_zero_memory(struct ipw_priv *priv, u32 start, u32 count)
+{
+       count >>= 2;
+       if (!count) return;
+       _ipw_write32(priv, CX2_AUTOINC_ADDR, start);
+       while (count--)
+               _ipw_write32(priv, CX2_AUTOINC_DATA, 0);
+}
+
+static inline void ipw_fw_dma_reset_command_blocks(struct ipw_priv *priv)
+{
+       ipw_zero_memory(priv, CX2_SHARED_SRAM_DMA_CONTROL,
+                       CB_NUMBER_OF_ELEMENTS_SMALL *
+                       sizeof(struct command_block));
+}
+
+static int ipw_fw_dma_enable(struct ipw_priv *priv)
+{ /* start dma engine but no transfers yet*/
+
+       IPW_DEBUG_FW(">> : \n");
+
+       /* Start the dma */
+       ipw_fw_dma_reset_command_blocks(priv);
+
+       /* Write CB base address */
+       ipw_write_reg32(priv, CX2_DMA_I_CB_BASE, CX2_SHARED_SRAM_DMA_CONTROL);
+
+       IPW_DEBUG_FW("<< : \n");
+       return 0;
+}
+
+static void ipw_fw_dma_abort(struct ipw_priv *priv)
+{
+       u32 control = 0;
+
+       IPW_DEBUG_FW(">> :\n");
+
+       //set the Stop and Abort bit
+       control = DMA_CONTROL_SMALL_CB_CONST_VALUE | DMA_CB_STOP_AND_ABORT;
+       ipw_write_reg32(priv, CX2_DMA_I_DMA_CONTROL, control);
+       priv->sram_desc.last_cb_index = 0;
+
+       IPW_DEBUG_FW("<< \n");
+}
+
+static int ipw_fw_dma_write_command_block(struct ipw_priv *priv, int index, struct command_block *cb)
+{
+       u32 address = CX2_SHARED_SRAM_DMA_CONTROL + (sizeof(struct command_block) * index);
+       IPW_DEBUG_FW(">> :\n");
+
+       ipw_write_indirect(priv, address, (u8*)cb, (int)sizeof(struct command_block));
+
+       IPW_DEBUG_FW("<< :\n");
+       return 0;
+
+}
+
+static int ipw_fw_dma_kick(struct ipw_priv *priv)
+{
+       u32 control = 0;
+       u32 index=0;
+
+       IPW_DEBUG_FW(">> :\n");
+
+       for (index = 0; index < priv->sram_desc.last_cb_index; index++)
+               ipw_fw_dma_write_command_block(priv, index, &priv->sram_desc.cb_list[index]);
+
+       /* Enable the DMA in the CSR register */
+       ipw_clear_bit(priv, CX2_RESET_REG,CX2_RESET_REG_MASTER_DISABLED | CX2_RESET_REG_STOP_MASTER);
+
+        /* Set the Start bit. */
+       control = DMA_CONTROL_SMALL_CB_CONST_VALUE | DMA_CB_START;
+       ipw_write_reg32(priv, CX2_DMA_I_DMA_CONTROL, control);
+
+       IPW_DEBUG_FW("<< :\n");
+       return 0;
+}
+
+static void ipw_fw_dma_dump_command_block(struct ipw_priv *priv)
+{
+       u32 address;
+       u32 register_value=0;
+       u32 cb_fields_address=0;
+
+       IPW_DEBUG_FW(">> :\n");
+       address = ipw_read_reg32(priv,CX2_DMA_I_CURRENT_CB);
+       IPW_DEBUG_FW_INFO("Current CB is 0x%x \n",address);
+
+       /* Read the DMA Controlor register */
+       register_value = ipw_read_reg32(priv, CX2_DMA_I_DMA_CONTROL);
+       IPW_DEBUG_FW_INFO("CX2_DMA_I_DMA_CONTROL is 0x%x \n",register_value);
+
+       /* Print the CB values*/
+       cb_fields_address = address;
+       register_value = ipw_read_reg32(priv, cb_fields_address);
+       IPW_DEBUG_FW_INFO("Current CB ControlField is 0x%x \n",register_value);
+
+       cb_fields_address += sizeof(u32);
+       register_value = ipw_read_reg32(priv, cb_fields_address);
+       IPW_DEBUG_FW_INFO("Current CB Source Field is 0x%x \n",register_value);
+
+       cb_fields_address += sizeof(u32);
+       register_value = ipw_read_reg32(priv, cb_fields_address);
+       IPW_DEBUG_FW_INFO("Current CB Destination Field is 0x%x \n",
+                         register_value);
+
+       cb_fields_address += sizeof(u32);
+       register_value = ipw_read_reg32(priv, cb_fields_address);
+       IPW_DEBUG_FW_INFO("Current CB Status Field is 0x%x \n",register_value);
+
+       IPW_DEBUG_FW(">> :\n");
+}
+
+static int ipw_fw_dma_command_block_index(struct ipw_priv *priv)
+{
+       u32 current_cb_address = 0;
+       u32 current_cb_index = 0;
+
+       IPW_DEBUG_FW("<< :\n");
+       current_cb_address= ipw_read_reg32(priv, CX2_DMA_I_CURRENT_CB);
+
+       current_cb_index = (current_cb_address - CX2_SHARED_SRAM_DMA_CONTROL )/
+               sizeof (struct command_block);
+
+       IPW_DEBUG_FW_INFO("Current CB index 0x%x address = 0x%X \n",
+                         current_cb_index, current_cb_address );
+
+       IPW_DEBUG_FW(">> :\n");
+       return current_cb_index;
+
+}
+
+static int ipw_fw_dma_add_command_block(struct ipw_priv *priv,
+                                       u32 src_address,
+                                       u32 dest_address,
+                                       u32 length,
+                                       int interrupt_enabled,
+                                       int is_last)
+{
+
+       u32 control = CB_VALID | CB_SRC_LE | CB_DEST_LE | CB_SRC_AUTOINC |
+               CB_SRC_IO_GATED | CB_DEST_AUTOINC | CB_SRC_SIZE_LONG |
+               CB_DEST_SIZE_LONG;
+       struct command_block *cb;
+       u32 last_cb_element=0;
+
+       IPW_DEBUG_FW_INFO("src_address=0x%x dest_address=0x%x length=0x%x\n",
+                         src_address, dest_address, length);
+
+       if (priv->sram_desc.last_cb_index >= CB_NUMBER_OF_ELEMENTS_SMALL)
+               return -1;
+
+       last_cb_element = priv->sram_desc.last_cb_index;
+       cb = &priv->sram_desc.cb_list[last_cb_element];
+       priv->sram_desc.last_cb_index++;
+
+       /* Calculate the new CB control word */
+       if (interrupt_enabled )
+               control |= CB_INT_ENABLED;
+
+       if (is_last)
+               control |= CB_LAST_VALID;
+
+       control |= length;
+
+       /* Calculate the CB Element's checksum value */
+       cb->status = control ^src_address ^dest_address;
+
+       /* Copy the Source and Destination addresses */
+       cb->dest_addr = dest_address;
+       cb->source_addr = src_address;
+
+       /* Copy the Control Word last */
+       cb->control = control;
+
+       return 0;
+}
+
+static int ipw_fw_dma_add_buffer(struct ipw_priv *priv,
+                                u32 src_phys,
+                                u32 dest_address,
+                                u32 length)
+{
+       u32 bytes_left = length;
+       u32 src_offset=0;
+       u32 dest_offset=0;
+       int status = 0;
+       IPW_DEBUG_FW(">> \n");
+       IPW_DEBUG_FW_INFO("src_phys=0x%x dest_address=0x%x length=0x%x\n",
+                         src_phys, dest_address, length);
+       while (bytes_left > CB_MAX_LENGTH) {
+               status = ipw_fw_dma_add_command_block( priv,
+                                                      src_phys + src_offset,
+                                                      dest_address + dest_offset,
+                                                      CB_MAX_LENGTH, 0, 0);
+               if (status) {
+                       IPW_DEBUG_FW_INFO(": Failed\n");
+                       return -1;
+               } else
+                       IPW_DEBUG_FW_INFO(": Added new cb\n");
+
+               src_offset += CB_MAX_LENGTH;
+               dest_offset += CB_MAX_LENGTH;
+               bytes_left -= CB_MAX_LENGTH;
+       }
+
+       /* add the buffer tail */
+       if (bytes_left > 0) {
+               status = ipw_fw_dma_add_command_block(
+                       priv, src_phys + src_offset,
+                       dest_address + dest_offset,
+                       bytes_left, 0, 0);
+               if (status) {
+                       IPW_DEBUG_FW_INFO(": Failed on the buffer tail\n");
+                       return -1;
+               } else
+                       IPW_DEBUG_FW_INFO(": Adding new cb - the buffer tail\n");
+       }
+
+
+       IPW_DEBUG_FW("<< \n");
+       return 0;
+}
+
+static int ipw_fw_dma_wait(struct ipw_priv *priv)
+{
+       u32 current_index = 0;
+       u32 watchdog = 0;
+
+       IPW_DEBUG_FW(">> : \n");
+
+       current_index = ipw_fw_dma_command_block_index(priv);
+       IPW_DEBUG_FW_INFO("sram_desc.last_cb_index:0x%8X\n",
+                         (int) priv->sram_desc.last_cb_index);
+
+       while (current_index < priv->sram_desc.last_cb_index) {
+               udelay(50);
+               current_index = ipw_fw_dma_command_block_index(priv);
+
+               watchdog++;
+
+               if (watchdog > 400) {
+                       IPW_DEBUG_FW_INFO("Timeout\n");
+                       ipw_fw_dma_dump_command_block(priv);
+                       ipw_fw_dma_abort(priv);
+                       return -1;
+               }
+       }
+
+       ipw_fw_dma_abort(priv);
+
+       /*Disable the DMA in the CSR register*/
+       ipw_set_bit(priv, CX2_RESET_REG,
+                   CX2_RESET_REG_MASTER_DISABLED | CX2_RESET_REG_STOP_MASTER);
+
+       IPW_DEBUG_FW("<< dmaWaitSync \n");
+       return 0;
+}
+
+static void ipw_remove_current_network(struct ipw_priv *priv)
+{
+       struct list_head *element, *safe;
+       struct ieee80211_network *network = NULL;
+       list_for_each_safe(element, safe, &priv->ieee->network_list) {
+               network = list_entry(element, struct ieee80211_network, list);
+               if (!memcmp(network->bssid, priv->bssid, ETH_ALEN)) {
+                       list_del(element);
+                       list_add_tail(&network->list,
+                                     &priv->ieee->network_free_list);
+               }
+       }
+}
+
+/**
+ * Check that card is still alive.
+ * Reads debug register from domain0.
+ * If card is present, pre-defined value should
+ * be found there.
+ *
+ * @param priv
+ * @return 1 if card is present, 0 otherwise
+ */
+static inline int ipw_alive(struct ipw_priv *priv)
+{
+       return ipw_read32(priv, 0x90) == 0xd55555d5;
+}
+
+static inline int ipw_poll_bit(struct ipw_priv *priv, u32 addr, u32 mask,
+                              int timeout)
+{
+       int i = 0;
+
+       do {
+               if ((ipw_read32(priv, addr) & mask) == mask)
+                       return i;
+               mdelay(10);
+               i += 10;
+       } while (i < timeout);
+
+       return -ETIME;
+}
+
+/* These functions load the firmware and micro code for the operation of
+ * the ipw hardware.  It assumes the buffer has all the bits for the
+ * image and the caller is handling the memory allocation and clean up.
+ */
+
+
+static int ipw_stop_master(struct ipw_priv * priv)
+{
+       int rc;
+
+       IPW_DEBUG_TRACE(">> \n");
+       /* stop master. typical delay - 0 */
+       ipw_set_bit(priv, CX2_RESET_REG, CX2_RESET_REG_STOP_MASTER);
+
+       rc = ipw_poll_bit(priv, CX2_RESET_REG,
+                         CX2_RESET_REG_MASTER_DISABLED, 100);
+       if (rc < 0) {
+               IPW_ERROR("stop master failed in 10ms\n");
+               return -1;
+       }
+
+       IPW_DEBUG_INFO("stop master %dms\n", rc);
+
+       return rc;
+}
+
+static void ipw_arc_release(struct ipw_priv *priv)
+{
+       IPW_DEBUG_TRACE(">> \n");
+       mdelay(5);
+
+       ipw_clear_bit(priv, CX2_RESET_REG, CBD_RESET_REG_PRINCETON_RESET);
+
+       /* no one knows timing, for safety add some delay */
+       mdelay(5);
+}
+
+struct fw_header {
+       u32 version;
+       u32 mode;
+};
+
+struct fw_chunk {
+       u32 address;
+       u32 length;
+};
+
+#define IPW_FW_MAJOR_VERSION 2
+#define IPW_FW_MINOR_VERSION 2
+
+#define IPW_FW_MINOR(x) ((x & 0xff) >> 8)
+#define IPW_FW_MAJOR(x) (x & 0xff)
+
+#define IPW_FW_VERSION ((IPW_FW_MINOR_VERSION << 8) | \
+                         IPW_FW_MAJOR_VERSION)
+
+#define IPW_FW_PREFIX "ipw-" __stringify(IPW_FW_MAJOR_VERSION) \
+"." __stringify(IPW_FW_MINOR_VERSION) "-"
+
+#if IPW_FW_MAJOR_VERSION >= 2 && IPW_FW_MINOR_VERSION > 0
+#define IPW_FW_NAME(x) IPW_FW_PREFIX "" x ".fw"
+#else
+#define IPW_FW_NAME(x) "ipw2200_" x ".fw"
+#endif
+
+static int ipw_load_ucode(struct ipw_priv *priv, u8 * data,
+                         size_t len)
+{
+       int rc = 0, i, addr;
+       u8 cr = 0;
+       u16 *image;
+
+       image = (u16 *)data;
+
+       IPW_DEBUG_TRACE(">> \n");
+
+       rc = ipw_stop_master(priv);
+
+       if (rc < 0)
+               return rc;
+
+//     spin_lock_irqsave(&priv->lock, flags);
+
+       for (addr = CX2_SHARED_LOWER_BOUND;
+            addr < CX2_REGISTER_DOMAIN1_END; addr += 4) {
+               ipw_write32(priv, addr, 0);
+       }
+
+       /* no ucode (yet) */
+       memset(&priv->dino_alive, 0, sizeof(priv->dino_alive));
+       /* destroy DMA queues */
+       /* reset sequence */
+
+       ipw_write_reg32(priv, CX2_MEM_HALT_AND_RESET ,CX2_BIT_HALT_RESET_ON);
+       ipw_arc_release(priv);
+       ipw_write_reg32(priv, CX2_MEM_HALT_AND_RESET, CX2_BIT_HALT_RESET_OFF);
+       mdelay(1);
+
+       /* reset PHY */
+       ipw_write_reg32(priv, CX2_INTERNAL_CMD_EVENT, CX2_BASEBAND_POWER_DOWN);
+       mdelay(1);
+
+       ipw_write_reg32(priv, CX2_INTERNAL_CMD_EVENT, 0);
+       mdelay(1);
+
+       /* enable ucode store */
+       ipw_write_reg8(priv, DINO_CONTROL_REG, 0x0);
+       ipw_write_reg8(priv, DINO_CONTROL_REG, DINO_ENABLE_CS);
+       mdelay(1);
+
+       /* write ucode */
+       /**
+        * @bug
+        * Do NOT set indirect address register once and then
+        * store data to indirect data register in the loop.
+        * It seems very reasonable, but in this case DINO do not
+        * accept ucode. It is essential to set address each time.
+        */
+       /* load new ipw uCode */
+       for (i = 0; i < len / 2; i++)
+               ipw_write_reg16(priv, CX2_BASEBAND_CONTROL_STORE, image[i]);
+
+
+       /* enable DINO */
+       ipw_write_reg8(priv, CX2_BASEBAND_CONTROL_STATUS, 0);
+       ipw_write_reg8(priv, CX2_BASEBAND_CONTROL_STATUS,
+                      DINO_ENABLE_SYSTEM );
+
+       /* this is where the igx / win driver deveates from the VAP driver.*/
+
+       /* wait for alive response */
+       for (i = 0; i < 100; i++) {
+               /* poll for incoming data */
+               cr = ipw_read_reg8(priv, CX2_BASEBAND_CONTROL_STATUS);
+               if (cr & DINO_RXFIFO_DATA)
+                       break;
+               mdelay(1);
+       }
+
+       if (cr & DINO_RXFIFO_DATA) {
+               /* alive_command_responce size is NOT multiple of 4 */
+               u32 response_buffer[(sizeof(priv->dino_alive) + 3) / 4];
+
+               for (i = 0; i < ARRAY_SIZE(response_buffer); i++)
+                       response_buffer[i] =
+                               ipw_read_reg32(priv,
+                                              CX2_BASEBAND_RX_FIFO_READ);
+               memcpy(&priv->dino_alive, response_buffer,
+                      sizeof(priv->dino_alive));
+               if (priv->dino_alive.alive_command == 1
+                   && priv->dino_alive.ucode_valid == 1) {
+                       rc = 0;
+                       IPW_DEBUG_INFO(
+                               "Microcode OK, rev. %d (0x%x) dev. %d (0x%x) "
+                               "of %02d/%02d/%02d %02d:%02d\n",
+                               priv->dino_alive.software_revision,
+                               priv->dino_alive.software_revision,
+                               priv->dino_alive.device_identifier,
+                               priv->dino_alive.device_identifier,
+                               priv->dino_alive.time_stamp[0],
+                               priv->dino_alive.time_stamp[1],
+                               priv->dino_alive.time_stamp[2],
+                               priv->dino_alive.time_stamp[3],
+                               priv->dino_alive.time_stamp[4]);
+               } else {
+                       IPW_DEBUG_INFO("Microcode is not alive\n");
+                       rc = -EINVAL;
+               }
+       } else {
+               IPW_DEBUG_INFO("No alive response from DINO\n");
+               rc = -ETIME;
+       }
+
+       /* disable DINO, otherwise for some reason
+          firmware have problem getting alive resp. */
+       ipw_write_reg8(priv, CX2_BASEBAND_CONTROL_STATUS, 0);
+
+//     spin_unlock_irqrestore(&priv->lock, flags);
+
+       return rc;
+}
+
+static int ipw_load_firmware(struct ipw_priv *priv, u8 * data,
+                            size_t len)
+{
+       int rc = -1;
+       int offset = 0;
+       struct fw_chunk *chunk;
+       dma_addr_t shared_phys;
+       u8 *shared_virt;
+
+       IPW_DEBUG_TRACE("<< : \n");
+       shared_virt = pci_alloc_consistent(priv->pci_dev, len, &shared_phys);
+
+       if (!shared_virt)
+               return -ENOMEM;
+
+       memmove(shared_virt, data, len);
+
+       /* Start the Dma */
+       rc = ipw_fw_dma_enable(priv);
+
+       if (priv->sram_desc.last_cb_index > 0) {
+               /* the DMA is already ready this would be a bug. */
+               BUG();
+               goto out;
+       }
+
+       do {
+               chunk = (struct fw_chunk *)(data + offset);
+               offset += sizeof(struct fw_chunk);
+               /* build DMA packet and queue up for sending */
+               /* dma to chunk->address, the chunk->length bytes from data +
+                * offeset*/
+               /* Dma loading */
+               rc = ipw_fw_dma_add_buffer(priv, shared_phys + offset,
+                                          chunk->address, chunk->length);
+               if (rc) {
+                       IPW_DEBUG_INFO("dmaAddBuffer Failed\n");
+                       goto out;
+               }
+
+               offset += chunk->length;
+       } while (offset < len);
+
+       /* Run the DMA and wait for the answer*/
+       rc = ipw_fw_dma_kick(priv);
+       if (rc) {
+               IPW_ERROR("dmaKick Failed\n");
+               goto out;
+       }
+
+       rc = ipw_fw_dma_wait(priv);
+       if (rc) {
+               IPW_ERROR("dmaWaitSync Failed\n");
+               goto out;
+       }
+ out:
+       pci_free_consistent( priv->pci_dev, len, shared_virt, shared_phys);
+       return rc;
+}
+
+/* stop nic */
+static int ipw_stop_nic(struct ipw_priv *priv)
+{
+       int rc = 0;
+
+       /* stop*/
+       ipw_write32(priv, CX2_RESET_REG, CX2_RESET_REG_STOP_MASTER);
+
+       rc = ipw_poll_bit(priv, CX2_RESET_REG,
+                         CX2_RESET_REG_MASTER_DISABLED, 500);
+       if (rc < 0) {
+               IPW_ERROR("wait for reg master disabled failed\n");
+               return rc;
+       }
+
+       ipw_set_bit(priv, CX2_RESET_REG, CBD_RESET_REG_PRINCETON_RESET);
+
+       return rc;
+}
+
+static void ipw_start_nic(struct ipw_priv *priv)
+{
+       IPW_DEBUG_TRACE(">>\n");
+
+       /* prvHwStartNic  release ARC*/
+       ipw_clear_bit(priv, CX2_RESET_REG,
+                     CX2_RESET_REG_MASTER_DISABLED |
+                     CX2_RESET_REG_STOP_MASTER |
+                     CBD_RESET_REG_PRINCETON_RESET);
+
+       /* enable power management */
+       ipw_set_bit(priv, CX2_GP_CNTRL_RW, CX2_GP_CNTRL_BIT_HOST_ALLOWS_STANDBY);
+
+       IPW_DEBUG_TRACE("<<\n");
+}
+
+static int ipw_init_nic(struct ipw_priv *priv)
+{
+       int rc;
+
+       IPW_DEBUG_TRACE(">>\n");
+       /* reset */
+       /*prvHwInitNic */
+       /* set "initialization complete" bit to move adapter to D0 state */
+       ipw_set_bit(priv, CX2_GP_CNTRL_RW, CX2_GP_CNTRL_BIT_INIT_DONE);
+
+       /* low-level PLL activation */
+       ipw_write32(priv, CX2_READ_INT_REGISTER,  CX2_BIT_INT_HOST_SRAM_READ_INT_REGISTER);
+
+       /* wait for clock stabilization */
+       rc = ipw_poll_bit(priv, CX2_GP_CNTRL_RW,
+                         CX2_GP_CNTRL_BIT_CLOCK_READY, 250);
+       if (rc < 0 )
+               IPW_DEBUG_INFO("FAILED wait for clock stablization\n");
+
+       /* assert SW reset */
+       ipw_set_bit(priv, CX2_RESET_REG, CX2_RESET_REG_SW_RESET);
+
+       udelay(10);
+
+       /* set "initialization complete" bit to move adapter to D0 state */
+       ipw_set_bit(priv, CX2_GP_CNTRL_RW, CX2_GP_CNTRL_BIT_INIT_DONE);
+
+       IPW_DEBUG_TRACE(">>\n");
+       return 0;
+}
+
+
+/* Call this function from process context, it will sleep in request_firmware.
+ * Probe is an ok place to call this from.
+ */
+static int ipw_reset_nic(struct ipw_priv *priv)
+{
+       int rc = 0;
+
+       IPW_DEBUG_TRACE(">>\n");
+
+       rc = ipw_init_nic(priv);
+
+       /* Clear the 'host command active' bit... */
+       priv->status &= ~STATUS_HCMD_ACTIVE;
+       wake_up_interruptible(&priv->wait_command_queue);
+
+       IPW_DEBUG_TRACE("<<\n");
+       return rc;
+}
+
+static int ipw_get_fw(struct ipw_priv *priv,
+                     const struct firmware **fw, const char *name)
+{
+       struct fw_header *header;
+       int rc;
+
+       /* ask firmware_class module to get the boot firmware off disk */
+       rc = request_firmware(fw, name, &priv->pci_dev->dev);
+       if (rc < 0) {
+               IPW_ERROR("%s load failed: Reason %d\n", name, rc);
+               return rc;
+       }
+
+       header = (struct fw_header *)(*fw)->data;
+       if (IPW_FW_MAJOR(header->version) != IPW_FW_MAJOR_VERSION) {
+               IPW_ERROR("'%s' firmware version not compatible (%d != %d)\n",
+                         name,
+                         IPW_FW_MAJOR(header->version), IPW_FW_MAJOR_VERSION);
+               return -EINVAL;
+       }
+
+       IPW_DEBUG_INFO("Loading firmware '%s' file v%d.%d (%zd bytes)\n",
+                      name,
+                      IPW_FW_MAJOR(header->version),
+                      IPW_FW_MINOR(header->version),
+                      (*fw)->size - sizeof(struct fw_header));
+       return 0;
+}
+
+#define CX2_RX_BUF_SIZE (3000)
+
+static inline void ipw_rx_queue_reset(struct ipw_priv *priv,
+                                     struct ipw_rx_queue *rxq)
+{
+       unsigned long flags;
+       int i;
+
+       spin_lock_irqsave(&rxq->lock, flags);
+
+       INIT_LIST_HEAD(&rxq->rx_free);
+       INIT_LIST_HEAD(&rxq->rx_used);
+
+       /* Fill the rx_used queue with _all_ of the Rx buffers */
+       for (i = 0; i < RX_FREE_BUFFERS + RX_QUEUE_SIZE; i++) {
+               /* In the reset function, these buffers may have been allocated
+                * to an SKB, so we need to unmap and free potential storage */
+               if (rxq->pool[i].skb != NULL) {
+                       pci_unmap_single(priv->pci_dev, rxq->pool[i].dma_addr,
+                                        CX2_RX_BUF_SIZE,
+                                        PCI_DMA_FROMDEVICE);
+                       dev_kfree_skb(rxq->pool[i].skb);
+               }
+               list_add_tail(&rxq->pool[i].list, &rxq->rx_used);
+       }
+
+       /* Set us so that we have processed and used all buffers, but have
+        * not restocked the Rx queue with fresh buffers */
+       rxq->read = rxq->write = 0;
+       rxq->processed = RX_QUEUE_SIZE - 1;
+       rxq->free_count = 0;
+       spin_unlock_irqrestore(&rxq->lock, flags);
+}
+
+#ifdef CONFIG_PM
+static int fw_loaded = 0;
+static const struct firmware *bootfw = NULL;
+static const struct firmware *firmware = NULL;
+static const struct firmware *ucode = NULL;
+#endif
+
+static int ipw_load(struct ipw_priv *priv)
+{
+#ifndef CONFIG_PM
+       const struct firmware *bootfw = NULL;
+       const struct firmware *firmware = NULL;
+       const struct firmware *ucode = NULL;
+#endif
+       int rc = 0, retries = 3;
+
+#ifdef CONFIG_PM
+       if (!fw_loaded) {
+#endif
+               rc = ipw_get_fw(priv, &bootfw, IPW_FW_NAME("boot"));
+               if (rc)
+                       goto error;
+
+               switch (priv->ieee->iw_mode) {
+               case IW_MODE_ADHOC:
+                       rc = ipw_get_fw(priv, &ucode,
+                                       IPW_FW_NAME("ibss_ucode"));
+                       if (rc)
+                               goto error;
+
+                       rc = ipw_get_fw(priv, &firmware, IPW_FW_NAME("ibss"));
+                       break;
+
+#ifdef CONFIG_IPW_PROMISC
+               case IW_MODE_MONITOR:
+                       rc = ipw_get_fw(priv, &ucode,
+                                       IPW_FW_NAME("ibss_ucode"));
+                       if (rc)
+                               goto error;
+
+                       rc = ipw_get_fw(priv, &firmware, IPW_FW_NAME("sniffer"));
+                       break;
+#endif
+               case IW_MODE_INFRA:
+                       rc = ipw_get_fw(priv, &ucode,
+                                       IPW_FW_NAME("bss_ucode"));
+                       if (rc)
+                               goto error;
+
+                       rc = ipw_get_fw(priv, &firmware, IPW_FW_NAME("bss"));
+                       break;
+
+               default:
+                       rc = -EINVAL;
+               }
+
+               if (rc)
+                       goto error;
+
+#ifdef CONFIG_PM
+               fw_loaded = 1;
+       }
+#endif
+
+       if (!priv->rxq)
+               priv->rxq = ipw_rx_queue_alloc(priv);
+       else
+               ipw_rx_queue_reset(priv, priv->rxq);
+       if (!priv->rxq) {
+               IPW_ERROR("Unable to initialize Rx queue\n");
+               goto error;
+       }
+
+ retry:
+       /* Ensure interrupts are disabled */
+       ipw_write32(priv, CX2_INTA_MASK_R, ~CX2_INTA_MASK_ALL);
+       priv->status &= ~STATUS_INT_ENABLED;
+
+       /* ack pending interrupts */
+       ipw_write32(priv, CX2_INTA_RW, CX2_INTA_MASK_ALL);
+
+       ipw_stop_nic(priv);
+
+       rc = ipw_reset_nic(priv);
+       if (rc) {
+               IPW_ERROR("Unable to reset NIC\n");
+               goto error;
+       }
+
+       ipw_zero_memory(priv, CX2_NIC_SRAM_LOWER_BOUND,
+                       CX2_NIC_SRAM_UPPER_BOUND - CX2_NIC_SRAM_LOWER_BOUND);
+
+       /* DMA the initial boot firmware into the device */
+       rc = ipw_load_firmware(priv, bootfw->data + sizeof(struct fw_header),
+                              bootfw->size - sizeof(struct fw_header));
+       if (rc < 0) {
+               IPW_ERROR("Unable to load boot firmware\n");
+               goto error;
+       }
+
+       /* kick start the device */
+       ipw_start_nic(priv);
+
+       /* wait for the device to finish it's initial startup sequence */
+       rc = ipw_poll_bit(priv, CX2_INTA_RW,
+                         CX2_INTA_BIT_FW_INITIALIZATION_DONE, 500);
+       if (rc < 0) {
+               IPW_ERROR("device failed to boot initial fw image\n");
+               goto error;
+       }
+       IPW_DEBUG_INFO("initial device response after %dms\n", rc);
+
+       /* ack fw init done interrupt */
+       ipw_write32(priv, CX2_INTA_RW, CX2_INTA_BIT_FW_INITIALIZATION_DONE);
+
+       /* DMA the ucode into the device */
+       rc = ipw_load_ucode(priv, ucode->data + sizeof(struct fw_header),
+                           ucode->size - sizeof(struct fw_header));
+       if (rc < 0) {
+               IPW_ERROR("Unable to load ucode\n");
+               goto error;
+       }
+
+       /* stop nic */
+       ipw_stop_nic(priv);
+
+       /* DMA bss firmware into the device */
+       rc = ipw_load_firmware(priv, firmware->data +
+                              sizeof(struct fw_header),
+                              firmware->size - sizeof(struct fw_header));
+       if (rc < 0 ) {
+               IPW_ERROR("Unable to load firmware\n");
+               goto error;
+       }
+
+       ipw_write32(priv, IPW_EEPROM_LOAD_DISABLE, 0);
+
+       rc = ipw_queue_reset(priv);
+       if (rc) {
+               IPW_ERROR("Unable to initialize queues\n");
+               goto error;
+       }
+
+       /* Ensure interrupts are disabled */
+       ipw_write32(priv, CX2_INTA_MASK_R, ~CX2_INTA_MASK_ALL);
+
+       /* kick start the device */
+       ipw_start_nic(priv);
+
+       if (ipw_read32(priv, CX2_INTA_RW) & CX2_INTA_BIT_PARITY_ERROR) {
+               if (retries > 0) {
+                       IPW_WARNING("Parity error.  Retrying init.\n");
+                       retries--;
+                       goto retry;
+               }
+
+               IPW_ERROR("TODO: Handle parity error -- schedule restart?\n");
+               rc = -EIO;
+               goto error;
+       }
+
+       /* wait for the device */
+       rc = ipw_poll_bit(priv, CX2_INTA_RW,
+                         CX2_INTA_BIT_FW_INITIALIZATION_DONE, 500);
+       if (rc < 0) {
+               IPW_ERROR("device failed to start after 500ms\n");
+               goto error;
+       }
+       IPW_DEBUG_INFO("device response after %dms\n", rc);
+
+       /* ack fw init done interrupt */
+       ipw_write32(priv, CX2_INTA_RW, CX2_INTA_BIT_FW_INITIALIZATION_DONE);
+
+       /* read eeprom data and initialize the eeprom region of sram */
+       priv->eeprom_delay = 1;
+       ipw_eeprom_init_sram(priv);
+
+       /* enable interrupts */
+       ipw_enable_interrupts(priv);
+
+       /* Ensure our queue has valid packets */
+       ipw_rx_queue_replenish(priv);
+
+       ipw_write32(priv, CX2_RX_READ_INDEX, priv->rxq->read);
+
+       /* ack pending interrupts */
+       ipw_write32(priv, CX2_INTA_RW, CX2_INTA_MASK_ALL);
+
+#ifndef CONFIG_PM
+       release_firmware(bootfw);
+       release_firmware(ucode);
+       release_firmware(firmware);
+#endif
+       return 0;
+
+ error:
+       if (priv->rxq) {
+               ipw_rx_queue_free(priv, priv->rxq);
+               priv->rxq = NULL;
+       }
+       ipw_tx_queue_free(priv);
+       if (bootfw)
+               release_firmware(bootfw);
+       if (ucode)
+               release_firmware(ucode);
+       if (firmware)
+               release_firmware(firmware);
+#ifdef CONFIG_PM
+       fw_loaded = 0;
+       bootfw = ucode = firmware = NULL;
+#endif
+
+       return rc;
+}
+
+/**
+ * DMA services
+ *
+ * Theory of operation
+ *
+ * A queue is a circular buffers with 'Read' and 'Write' pointers.
+ * 2 empty entries always kept in the buffer to protect from overflow.
+ *
+ * For Tx queue, there are low mark and high mark limits. If, after queuing
+ * the packet for Tx, free space become < low mark, Tx queue stopped. When
+ * reclaiming packets (on 'tx done IRQ), if free space become > high mark,
+ * Tx queue resumed.
+ *
+ * The IPW operates with six queues, one receive queue in the device's
+ * sram, one transmit queue for sending commands to the device firmware,
+ * and four transmit queues for data.
+ *
+ * The four transmit queues allow for performing quality of service (qos)
+ * transmissions as per the 802.11 protocol.  Currently Linux does not
+ * provide a mechanism to the user for utilizing prioritized queues, so
+ * we only utilize the first data transmit queue (queue1).
+ */
+
+/**
+ * Driver allocates buffers of this size for Rx
+ */
+
+static inline int ipw_queue_space(const struct clx2_queue *q)
+{
+       int s = q->last_used - q->first_empty;
+       if (s <= 0)
+               s += q->n_bd;
+       s -= 2;                 /* keep some reserve to not confuse empty and full situations */
+       if (s < 0)
+               s = 0;
+       return s;
+}
+
+static inline int ipw_queue_inc_wrap(int index, int n_bd)
+{
+       return (++index == n_bd) ? 0 : index;
+}
+
+/**
+ * Initialize common DMA queue structure
+ *
+ * @param q                queue to init
+ * @param count            Number of BD's to allocate. Should be power of 2
+ * @param read_register    Address for 'read' register
+ *                         (not offset within BAR, full address)
+ * @param write_register   Address for 'write' register
+ *                         (not offset within BAR, full address)
+ * @param base_register    Address for 'base' register
+ *                         (not offset within BAR, full address)
+ * @param size             Address for 'size' register
+ *                         (not offset within BAR, full address)
+ */
+static void ipw_queue_init(struct ipw_priv *priv, struct clx2_queue *q,
+                          int count, u32 read, u32 write,
+                          u32 base, u32 size)
+{
+       q->n_bd = count;
+
+       q->low_mark = q->n_bd / 4;
+       if (q->low_mark < 4)
+               q->low_mark = 4;
+
+       q->high_mark = q->n_bd / 8;
+       if (q->high_mark < 2)
+               q->high_mark = 2;
+
+       q->first_empty = q->last_used = 0;
+       q->reg_r = read;
+       q->reg_w = write;
+
+       ipw_write32(priv, base, q->dma_addr);
+       ipw_write32(priv, size, count);
+       ipw_write32(priv, read, 0);
+       ipw_write32(priv, write, 0);
+
+       _ipw_read32(priv, 0x90);
+}
+
+static int ipw_queue_tx_init(struct ipw_priv *priv,
+                            struct clx2_tx_queue *q,
+                            int count, u32 read, u32 write,
+                            u32 base, u32 size)
+{
+       struct pci_dev *dev = priv->pci_dev;
+
+       q->txb = kmalloc(sizeof(q->txb[0]) * count, GFP_KERNEL);
+       if (!q->txb) {
+               IPW_ERROR("vmalloc for auxilary BD structures failed\n");
+               return -ENOMEM;
+       }
+
+       q->bd = pci_alloc_consistent(dev,sizeof(q->bd[0])*count, &q->q.dma_addr);
+       if (!q->bd) {
+               IPW_ERROR("pci_alloc_consistent(%zd) failed\n",
+                               sizeof(q->bd[0]) * count);
+               kfree(q->txb);
+               q->txb = NULL;
+               return -ENOMEM;
+       }
+
+       ipw_queue_init(priv, &q->q, count, read, write, base, size);
+       return 0;
+}
+
+/**
+ * Free one TFD, those at index [txq->q.last_used].
+ * Do NOT advance any indexes
+ *
+ * @param dev
+ * @param txq
+ */
+static void ipw_queue_tx_free_tfd(struct ipw_priv *priv,
+                                 struct clx2_tx_queue *txq)
+{
+       struct tfd_frame *bd = &txq->bd[txq->q.last_used];
+       struct pci_dev *dev = priv->pci_dev;
+       int i;
+
+       /* classify bd */
+       if (bd->control_flags.message_type == TX_HOST_COMMAND_TYPE)
+               /* nothing to cleanup after for host commands */
+               return;
+
+       /* sanity check */
+       if (bd->u.data.num_chunks > NUM_TFD_CHUNKS) {
+               IPW_ERROR("Too many chunks: %i\n", bd->u.data.num_chunks);
+               /** @todo issue fatal error, it is quite serious situation */
+               return;
+       }
+
+       /* unmap chunks if any */
+       for (i = 0; i < bd->u.data.num_chunks; i++) {
+               pci_unmap_single(dev, bd->u.data.chunk_ptr[i],
+                                bd->u.data.chunk_len[i], PCI_DMA_TODEVICE);
+               if (txq->txb[txq->q.last_used]) {
+                       ieee80211_txb_free(txq->txb[txq->q.last_used]);
+                       txq->txb[txq->q.last_used] = NULL;
+               }
+       }
+}
+
+/**
+ * Deallocate DMA queue.
+ *
+ * Empty queue by removing and destroying all BD's.
+ * Free all buffers.
+ *
+ * @param dev
+ * @param q
+ */
+static void ipw_queue_tx_free(struct ipw_priv *priv,
+                           struct clx2_tx_queue *txq)
+{
+       struct clx2_queue *q = &txq->q;
+       struct pci_dev *dev = priv->pci_dev;
+
+       if (q->n_bd == 0)
+               return;
+
+       /* first, empty all BD's */
+       for (; q->first_empty != q->last_used;
+            q->last_used = ipw_queue_inc_wrap(q->last_used, q->n_bd)) {
+               ipw_queue_tx_free_tfd(priv, txq);
+       }
+
+       /* free buffers belonging to queue itself */
+       pci_free_consistent(dev, sizeof(txq->bd[0])*q->n_bd, txq->bd,
+                           q->dma_addr);
+       kfree(txq->txb);
+
+       /* 0 fill whole structure */
+       memset(txq, 0, sizeof(*txq));
+}
+
+
+/**
+ * Destroy all DMA queues and structures
+ *
+ * @param priv
+ */
+static void ipw_tx_queue_free(struct ipw_priv *priv)
+{
+       /* Tx CMD queue */
+       ipw_queue_tx_free(priv, &priv->txq_cmd);
+
+       /* Tx queues */
+       ipw_queue_tx_free(priv, &priv->txq[0]);
+       ipw_queue_tx_free(priv, &priv->txq[1]);
+       ipw_queue_tx_free(priv, &priv->txq[2]);
+       ipw_queue_tx_free(priv, &priv->txq[3]);
+}
+
+static void inline __maybe_wake_tx(struct ipw_priv *priv)
+{
+       if (netif_running(priv->net_dev)) {
+               switch (priv->port_type) {
+               case DCR_TYPE_MU_BSS:
+               case DCR_TYPE_MU_IBSS:
+                       if (!(priv->status & STATUS_ASSOCIATED)) {
+                               return;
+                       }
+               }
+               netif_wake_queue(priv->net_dev);
+       }
+
+}
+
+static inline void ipw_create_bssid(struct ipw_priv *priv, u8 *bssid)
+{
+       /* First 3 bytes are manufacturer */
+       bssid[0] = priv->mac_addr[0];
+       bssid[1] = priv->mac_addr[1];
+       bssid[2] = priv->mac_addr[2];
+
+       /* Last bytes are random */
+        get_random_bytes(&bssid[3], ETH_ALEN-3);
+
+        bssid[0] &= 0xfe;       /* clear multicast bit */
+        bssid[0] |= 0x02;       /* set local assignment bit (IEEE802) */
+}
+
+static inline u8 ipw_add_station(struct ipw_priv *priv, u8 *bssid)
+{
+       struct ipw_station_entry entry;
+       int i;
+
+       for (i = 0; i < priv->num_stations; i++) {
+               if (!memcmp(priv->stations[i], bssid, ETH_ALEN)) {
+                       /* Another node is active in network */
+                       priv->missed_adhoc_beacons = 0;
+                       if (!(priv->config & CFG_STATIC_CHANNEL))
+                               /* when other nodes drop out, we drop out */
+                               priv->config &= ~CFG_ADHOC_PERSIST;
+
+                       return i;
+               }
+       }
+
+       if (i == MAX_STATIONS)
+               return IPW_INVALID_STATION;
+
+       IPW_DEBUG_SCAN("Adding AdHoc station: " MAC_FMT "\n", MAC_ARG(bssid));
+
+       entry.reserved = 0;
+       entry.support_mode = 0;
+       memcpy(entry.mac_addr, bssid, ETH_ALEN);
+       memcpy(priv->stations[i], bssid, ETH_ALEN);
+       ipw_write_direct(priv, IPW_STATION_TABLE_LOWER + i * sizeof(entry),
+                        &entry,
+                        sizeof(entry));
+       priv->num_stations++;
+
+       return i;
+}
+
+static inline u8 ipw_find_station(struct ipw_priv *priv, u8 *bssid)
+{
+       int i;
+
+       for (i = 0; i < priv->num_stations; i++)
+               if (!memcmp(priv->stations[i], bssid, ETH_ALEN))
+                       return i;
+
+       return IPW_INVALID_STATION;
+}
+
+static void ipw_send_disassociate(struct ipw_priv *priv, int quiet)
+{
+       int err;
+
+       if (!(priv->status & (STATUS_ASSOCIATING | STATUS_ASSOCIATED))) {
+               IPW_DEBUG_ASSOC("Disassociating while not associated.\n");
+               return;
+       }
+
+       IPW_DEBUG_ASSOC("Disassocation attempt from " MAC_FMT " "
+                       "on channel %d.\n",
+                       MAC_ARG(priv->assoc_request.bssid),
+                       priv->assoc_request.channel);
+
+       priv->status &= ~(STATUS_ASSOCIATING | STATUS_ASSOCIATED);
+       priv->status |= STATUS_DISASSOCIATING;
+
+       if (quiet)
+               priv->assoc_request.assoc_type = HC_DISASSOC_QUIET;
+       else
+               priv->assoc_request.assoc_type = HC_DISASSOCIATE;
+       err = ipw_send_associate(priv, &priv->assoc_request);
+       if (err) {
+               IPW_DEBUG_HC("Attempt to send [dis]associate command "
+                            "failed.\n");
+               return;
+       }
+
+}
+
+static void ipw_disassociate(void *data)
+{
+       ipw_send_disassociate(data, 0);
+}
+
+static void notify_wx_assoc_event(struct ipw_priv *priv)
+{
+       union iwreq_data wrqu;
+       wrqu.ap_addr.sa_family = ARPHRD_ETHER;
+       if (priv->status & STATUS_ASSOCIATED)
+               memcpy(wrqu.ap_addr.sa_data, priv->bssid, ETH_ALEN);
+       else
+               memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
+       wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL);
+}
+
+struct ipw_status_code {
+       u16 status;
+       const char *reason;
+};
+
+static const struct ipw_status_code ipw_status_codes[] = {
+       {0x00, "Successful"},
+       {0x01, "Unspecified failure"},
+       {0x0A, "Cannot support all requested capabilities in the "
+        "Capability information field"},
+       {0x0B, "Reassociation denied due to inability to confirm that "
+        "association exists"},
+       {0x0C, "Association denied due to reason outside the scope of this "
+        "standard"},
+       {0x0D, "Responding station does not support the specified authentication "
+        "algorithm"},
+       {0x0E, "Received an Authentication frame with authentication sequence "
+        "transaction sequence number out of expected sequence"},
+       {0x0F, "Authentication rejected because of challenge failure"},
+       {0x10, "Authentication rejected due to timeout waiting for next "
+        "frame in sequence"},
+       {0x11, "Association denied because AP is unable to handle additional "
+        "associated stations"},
+       {0x12, "Association denied due to requesting station not supporting all "
+        "of the datarates in the BSSBasicServiceSet Parameter"},
+       {0x13, "Association denied due to requesting station not supporting "
+        "short preamble operation"},
+       {0x14, "Association denied due to requesting station not supporting "
+        "PBCC encoding"},
+       {0x15, "Association denied due to requesting station not supporting "
+        "channel agility"},
+       {0x19, "Association denied due to requesting station not supporting "
+        "short slot operation"},
+       {0x1A, "Association denied due to requesting station not supporting "
+        "DSSS-OFDM operation"},
+       {0x28, "Invalid Information Element"},
+       {0x29, "Group Cipher is not valid"},
+       {0x2A, "Pairwise Cipher is not valid"},
+       {0x2B, "AKMP is not valid"},
+       {0x2C, "Unsupported RSN IE version"},
+       {0x2D, "Invalid RSN IE Capabilities"},
+       {0x2E, "Cipher suite is rejected per security policy"},
+};
+
+#ifdef CONFIG_IPW_DEBUG
+static const char *ipw_get_status_code(u16 status)
+{
+       int i;
+       for (i = 0; i < ARRAY_SIZE(ipw_status_codes); i++)
+               if (ipw_status_codes[i].status == status)
+                       return ipw_status_codes[i].reason;
+       return "Unknown status value.";
+}
+#endif
+
+static void inline average_init(struct average *avg)
+{
+       memset(avg, 0, sizeof(*avg));
+}
+
+static void inline average_add(struct average *avg, s16 val)
+{
+       avg->sum -= avg->entries[avg->pos];
+       avg->sum += val;
+       avg->entries[avg->pos++] = val;
+       if (unlikely(avg->pos == AVG_ENTRIES)) {
+               avg->init = 1;
+               avg->pos = 0;
+       }
+}
+
+static s16 inline average_value(struct average *avg)
+{
+       if (!unlikely(avg->init)) {
+               if (avg->pos)
+                       return avg->sum / avg->pos;
+               return 0;
+       }
+
+       return avg->sum / AVG_ENTRIES;
+}
+
+static void ipw_reset_stats(struct ipw_priv *priv)
+{
+       u32 len = sizeof(u32);
+
+       priv->quality = 0;
+
+       average_init(&priv->average_missed_beacons);
+       average_init(&priv->average_rssi);
+       average_init(&priv->average_noise);
+
+       priv->last_rate = 0;
+       priv->last_missed_beacons = 0;
+       priv->last_rx_packets = 0;
+       priv->last_tx_packets = 0;
+       priv->last_tx_failures = 0;
+
+       /* Firmware managed, reset only when NIC is restarted, so we have to
+        * normalize on the current value */
+       ipw_get_ordinal(priv, IPW_ORD_STAT_RX_ERR_CRC,
+                       &priv->last_rx_err, &len);
+       ipw_get_ordinal(priv, IPW_ORD_STAT_TX_FAILURE,
+                       &priv->last_tx_failures, &len);
+
+       /* Driver managed, reset with each association */
+       priv->missed_adhoc_beacons = 0;
+       priv->missed_beacons = 0;
+       priv->tx_packets = 0;
+       priv->rx_packets = 0;
+
+}
+
+
+static inline u32 ipw_get_max_rate(struct ipw_priv *priv)
+{
+       u32 i = 0x80000000;
+       u32 mask = priv->rates_mask;
+       /* If currently associated in B mode, restrict the maximum
+        * rate match to B rates */
+       if (priv->assoc_request.ieee_mode == IPW_B_MODE)
+               mask &= IEEE80211_CCK_RATES_MASK;
+
+       /* TODO: Verify that the rate is supported by the current rates
+        * list. */
+
+       while (i && !(mask & i)) i >>= 1;
+       switch (i) {
+       case IEEE80211_CCK_RATE_1MB_MASK: return 1000000;
+       case IEEE80211_CCK_RATE_2MB_MASK: return 2000000;
+       case IEEE80211_CCK_RATE_5MB_MASK: return 5500000;
+       case IEEE80211_OFDM_RATE_6MB_MASK: return 6000000;
+       case IEEE80211_OFDM_RATE_9MB_MASK: return 9000000;
+       case IEEE80211_CCK_RATE_11MB_MASK: return 11000000;
+       case IEEE80211_OFDM_RATE_12MB_MASK: return 12000000;
+       case IEEE80211_OFDM_RATE_18MB_MASK: return 18000000;
+       case IEEE80211_OFDM_RATE_24MB_MASK: return 24000000;
+       case IEEE80211_OFDM_RATE_36MB_MASK: return 36000000;
+       case IEEE80211_OFDM_RATE_48MB_MASK: return 48000000;
+       case IEEE80211_OFDM_RATE_54MB_MASK: return 54000000;
+       }
+
+       if (priv->ieee->mode == IEEE_B)
+               return 11000000;
+       else
+               return 54000000;
+}
+
+static u32 ipw_get_current_rate(struct ipw_priv *priv)
+{
+       u32 rate, len = sizeof(rate);
+       int err;
+
+       if (!(priv->status & STATUS_ASSOCIATED))
+               return 0;
+
+       if (priv->tx_packets > IPW_REAL_RATE_RX_PACKET_THRESHOLD) {
+               err = ipw_get_ordinal(priv, IPW_ORD_STAT_TX_CURR_RATE, &rate,
+                                     &len);
+               if (err) {
+                       IPW_DEBUG_INFO("failed querying ordinals.\n");
+                       return 0;
+               }
+       } else
+               return ipw_get_max_rate(priv);
+
+       switch (rate) {
+       case IPW_TX_RATE_1MB:  return  1000000;
+       case IPW_TX_RATE_2MB:  return  2000000;
+       case IPW_TX_RATE_5MB:  return  5500000;
+       case IPW_TX_RATE_6MB:  return  6000000;
+       case IPW_TX_RATE_9MB:  return  9000000;
+       case IPW_TX_RATE_11MB: return 11000000;
+       case IPW_TX_RATE_12MB: return 12000000;
+       case IPW_TX_RATE_18MB: return 18000000;
+       case IPW_TX_RATE_24MB: return 24000000;
+       case IPW_TX_RATE_36MB: return 36000000;
+       case IPW_TX_RATE_48MB: return 48000000;
+       case IPW_TX_RATE_54MB: return 54000000;
+       }
+
+       return 0;
+}
+
+#define PERFECT_RSSI (-50)
+#define WORST_RSSI   (-85)
+#define IPW_STATS_INTERVAL (2 * HZ)
+static void ipw_gather_stats(struct ipw_priv *priv)
+{
+       u32 rx_err, rx_err_delta, rx_packets_delta;
+       u32 tx_failures, tx_failures_delta, tx_packets_delta;
+       u32 missed_beacons_percent, missed_beacons_delta;
+       u32 quality = 0;
+       u32 len = sizeof(u32);
+       s16 rssi;
+       u32 beacon_quality, signal_quality, tx_quality, rx_quality,
+               rate_quality;
+
+       if (!(priv->status & STATUS_ASSOCIATED)) {
+               priv->quality = 0;
+               return;
+       }
+
+       /* Update the statistics */
+       ipw_get_ordinal(priv, IPW_ORD_STAT_MISSED_BEACONS,
+                       &priv->missed_beacons, &len);
+       missed_beacons_delta = priv->missed_beacons -
+               priv->last_missed_beacons;
+       priv->last_missed_beacons = priv->missed_beacons;
+       if (priv->assoc_request.beacon_interval) {
+               missed_beacons_percent = missed_beacons_delta *
+                       (HZ * priv->assoc_request.beacon_interval) /
+                       (IPW_STATS_INTERVAL * 10);
+       } else {
+               missed_beacons_percent = 0;
+       }
+       average_add(&priv->average_missed_beacons, missed_beacons_percent);
+
+       ipw_get_ordinal(priv, IPW_ORD_STAT_RX_ERR_CRC, &rx_err, &len);
+       rx_err_delta = rx_err - priv->last_rx_err;
+       priv->last_rx_err = rx_err;
+
+       ipw_get_ordinal(priv, IPW_ORD_STAT_TX_FAILURE, &tx_failures, &len);
+       tx_failures_delta = tx_failures - priv->last_tx_failures;
+       priv->last_tx_failures = tx_failures;
+
+       rx_packets_delta = priv->rx_packets - priv->last_rx_packets;
+       priv->last_rx_packets = priv->rx_packets;
+
+       tx_packets_delta = priv->tx_packets - priv->last_tx_packets;
+       priv->last_tx_packets = priv->tx_packets;
+
+       /* Calculate quality based on the following:
+        *
+        * Missed beacon: 100% = 0, 0% = 70% missed
+        * Rate: 60% = 1Mbs, 100% = Max
+        * Rx and Tx errors represent a straight % of total Rx/Tx
+        * RSSI: 100% = > -50,  0% = < -80
+        * Rx errors: 100% = 0, 0% = 50% missed
+        *
+        * The lowest computed quality is used.
+        *
+        */
+#define BEACON_THRESHOLD 5
+       beacon_quality = 100 - missed_beacons_percent;
+       if (beacon_quality < BEACON_THRESHOLD)
+               beacon_quality = 0;
+       else
+               beacon_quality = (beacon_quality - BEACON_THRESHOLD) * 100 /
+                       (100 - BEACON_THRESHOLD);
+       IPW_DEBUG_STATS("Missed beacon: %3d%% (%d%%)\n",
+                       beacon_quality, missed_beacons_percent);
+
+       priv->last_rate = ipw_get_current_rate(priv);
+       rate_quality =  priv->last_rate * 40 / priv->last_rate + 60;
+       IPW_DEBUG_STATS("Rate quality : %3d%% (%dMbs)\n",
+                       rate_quality, priv->last_rate / 1000000);
+
+       if (rx_packets_delta > 100 &&
+           rx_packets_delta + rx_err_delta)
+               rx_quality = 100 - (rx_err_delta * 100) /
+                       (rx_packets_delta + rx_err_delta);
+       else
+               rx_quality = 100;
+       IPW_DEBUG_STATS("Rx quality   : %3d%% (%u errors, %u packets)\n",
+                       rx_quality, rx_err_delta, rx_packets_delta);
+
+       if (tx_packets_delta > 100 &&
+           tx_packets_delta + tx_failures_delta)
+               tx_quality = 100 - (tx_failures_delta * 100) /
+                       (tx_packets_delta + tx_failures_delta);
+       else
+               tx_quality = 100;
+       IPW_DEBUG_STATS("Tx quality   : %3d%% (%u errors, %u packets)\n",
+                       tx_quality, tx_failures_delta, tx_packets_delta);
+
+       rssi = average_value(&priv->average_rssi);
+       if (rssi > PERFECT_RSSI)
+               signal_quality = 100;
+       else if (rssi < WORST_RSSI)
+               signal_quality = 0;
+       else
+               signal_quality = (rssi - WORST_RSSI) * 100 /
+                       (PERFECT_RSSI - WORST_RSSI);
+       IPW_DEBUG_STATS("Signal level : %3d%% (%d dBm)\n",
+                       signal_quality, rssi);
+
+       quality = min(beacon_quality,
+                     min(rate_quality,
+                         min(tx_quality, min(rx_quality, signal_quality))));
+       if (quality == beacon_quality)
+               IPW_DEBUG_STATS(
+                       "Quality (%d%%): Clamped to missed beacons.\n",
+                       quality);
+       if (quality == rate_quality)
+               IPW_DEBUG_STATS(
+                       "Quality (%d%%): Clamped to rate quality.\n",
+                       quality);
+       if (quality == tx_quality)
+               IPW_DEBUG_STATS(
+                       "Quality (%d%%): Clamped to Tx quality.\n",
+                       quality);
+       if (quality == rx_quality)
+               IPW_DEBUG_STATS(
+                       "Quality (%d%%): Clamped to Rx quality.\n",
+                       quality);
+       if (quality == signal_quality)
+               IPW_DEBUG_STATS(
+                       "Quality (%d%%): Clamped to signal quality.\n",
+                       quality);
+
+       priv->quality = quality;
+
+       queue_delayed_work(priv->workqueue, &priv->gather_stats,
+                          IPW_STATS_INTERVAL);
+}
+
+/**
+ * Handle host notification packet.
+ * Called from interrupt routine
+ */
+static inline void ipw_rx_notification(struct ipw_priv* priv,
+                                      struct ipw_rx_notification *notif)
+{
+       IPW_DEBUG_NOTIF("type = %i (%d bytes)\n",
+                       notif->subtype, notif->size);
+
+       switch (notif->subtype) {
+       case HOST_NOTIFICATION_STATUS_ASSOCIATED: {
+               struct notif_association *assoc = &notif->u.assoc;
+
+               switch (assoc->state) {
+               case CMAS_ASSOCIATED: {
+                       IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
+                                 "associated: '%s' " MAC_FMT " \n",
+                                 escape_essid(priv->essid, priv->essid_len),
+                                 MAC_ARG(priv->bssid));
+
+                       switch (priv->ieee->iw_mode) {
+                       case IW_MODE_INFRA:
+                               memcpy(priv->ieee->bssid, priv->bssid,
+                                      ETH_ALEN);
+                               break;
+
+                       case IW_MODE_ADHOC:
+                               memcpy(priv->ieee->bssid, priv->bssid,
+                                      ETH_ALEN);
+
+                               /* clear out the station table */
+                               priv->num_stations = 0;
+
+                               IPW_DEBUG_ASSOC("queueing adhoc check\n");
+                               queue_delayed_work(priv->workqueue,
+                                                  &priv->adhoc_check,
+                                                  priv->assoc_request.beacon_interval);
+                               break;
+                       }
+
+                       priv->status &= ~STATUS_ASSOCIATING;
+                       priv->status |= STATUS_ASSOCIATED;
+
+                       netif_carrier_on(priv->net_dev);
+                       if (netif_queue_stopped(priv->net_dev)) {
+                               IPW_DEBUG_NOTIF("waking queue\n");
+                               netif_wake_queue(priv->net_dev);
+                       } else {
+                               IPW_DEBUG_NOTIF("starting queue\n");
+                               netif_start_queue(priv->net_dev);
+                       }
+
+                       ipw_reset_stats(priv);
+                       /* Ensure the rate is updated immediately */
+                       priv->last_rate = ipw_get_current_rate(priv);
+                       schedule_work(&priv->gather_stats);
+                       notify_wx_assoc_event(priv);
+
+/*                     queue_delayed_work(priv->workqueue,
+                                          &priv->request_scan,
+                                          SCAN_ASSOCIATED_INTERVAL);
+*/
+                       break;
+               }
+
+               case CMAS_AUTHENTICATED: {
+                       if (priv->status & (STATUS_ASSOCIATED | STATUS_AUTH)) {
+#ifdef CONFIG_IPW_DEBUG
+                               struct notif_authenticate *auth = &notif->u.auth;
+                               IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
+                                         "deauthenticated: '%s' " MAC_FMT ": (0x%04X) - %s \n",
+                                         escape_essid(priv->essid, priv->essid_len),
+                                         MAC_ARG(priv->bssid),
+                                         ntohs(auth->status),
+                                         ipw_get_status_code(ntohs(auth->status)));
+#endif
+
+                               priv->status &= ~(STATUS_ASSOCIATING |
+                                                 STATUS_AUTH |
+                                                 STATUS_ASSOCIATED);
+
+                               netif_carrier_off(priv->net_dev);
+                               netif_stop_queue(priv->net_dev);
+                               queue_work(priv->workqueue, &priv->request_scan);
+                               notify_wx_assoc_event(priv);
+                               break;
+                       }
+
+                       IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
+                                 "authenticated: '%s' " MAC_FMT "\n",
+                                 escape_essid(priv->essid, priv->essid_len),
+                                 MAC_ARG(priv->bssid));
+                       break;
+               }
+
+               case CMAS_INIT: {
+                       IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
+                                 "disassociated: '%s' " MAC_FMT " \n",
+                                 escape_essid(priv->essid, priv->essid_len),
+                                 MAC_ARG(priv->bssid));
+
+                       priv->status &= ~(
+                               STATUS_DISASSOCIATING |
+                               STATUS_ASSOCIATING |
+                               STATUS_ASSOCIATED |
+                               STATUS_AUTH);
+
+                       netif_stop_queue(priv->net_dev);
+                       if (!(priv->status & STATUS_ROAMING)) {
+                               netif_carrier_off(priv->net_dev);
+                               notify_wx_assoc_event(priv);
+
+                               /* Cancel any queued work ... */
+                               cancel_delayed_work(&priv->request_scan);
+                               cancel_delayed_work(&priv->adhoc_check);
+
+                               /* Queue up another scan... */
+                               queue_work(priv->workqueue,
+                                          &priv->request_scan);
+
+                               cancel_delayed_work(&priv->gather_stats);
+                       } else {
+                               priv->status |= STATUS_ROAMING;
+                               queue_work(priv->workqueue,
+                                          &priv->request_scan);
+                       }
+
+                       ipw_reset_stats(priv);
+                       break;
+               }
+
+               default:
+                       IPW_ERROR("assoc: unknown (%d)\n",
+                                 assoc->state);
+                       break;
+               }
+
+               break;
+       }
+
+       case HOST_NOTIFICATION_STATUS_AUTHENTICATE: {
+               struct notif_authenticate *auth = &notif->u.auth;
+               switch (auth->state) {
+               case CMAS_AUTHENTICATED:
+                       IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE,
+                                 "authenticated: '%s' " MAC_FMT " \n",
+                                 escape_essid(priv->essid, priv->essid_len),
+                                 MAC_ARG(priv->bssid));
+                       priv->status |= STATUS_AUTH;
+                       break;
+
+               case CMAS_INIT:
+                       if (priv->status & STATUS_AUTH) {
+                               IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
+                                         "authentication failed (0x%04X): %s\n",
+                                         ntohs(auth->status),
+                                         ipw_get_status_code(ntohs(auth->status)));
+                       }
+                       IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
+                                 "deauthenticated: '%s' " MAC_FMT "\n",
+                                 escape_essid(priv->essid, priv->essid_len),
+                                 MAC_ARG(priv->bssid));
+
+                       priv->status &= ~(STATUS_ASSOCIATING |
+                                         STATUS_AUTH |
+                                         STATUS_ASSOCIATED);
+
+                       netif_carrier_off(priv->net_dev);
+                       netif_stop_queue(priv->net_dev);
+                       queue_work(priv->workqueue, &priv->request_scan);
+                       notify_wx_assoc_event(priv);
+                       break;
+
+               case CMAS_TX_AUTH_SEQ_1:
+                       IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
+                                 "AUTH_SEQ_1\n");
+                       break;
+               case CMAS_RX_AUTH_SEQ_2:
+                       IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
+                                 "AUTH_SEQ_2\n");
+                       break;
+               case CMAS_AUTH_SEQ_1_PASS:
+                       IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
+                                 "AUTH_SEQ_1_PASS\n");
+                       break;
+               case CMAS_AUTH_SEQ_1_FAIL:
+                       IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
+                                 "AUTH_SEQ_1_FAIL\n");
+                       break;
+               case CMAS_TX_AUTH_SEQ_3:
+                       IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
+                                 "AUTH_SEQ_3\n");
+                       break;
+               case CMAS_RX_AUTH_SEQ_4:
+                       IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
+                                 "RX_AUTH_SEQ_4\n");
+                       break;
+               case CMAS_AUTH_SEQ_2_PASS:
+                       IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
+                                 "AUTH_SEQ_2_PASS\n");
+                       break;
+               case CMAS_AUTH_SEQ_2_FAIL:
+                       IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
+                                 "AUT_SEQ_2_FAIL\n");
+                       break;
+               case CMAS_TX_ASSOC:
+                       IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
+                                 "TX_ASSOC\n");
+                       break;
+               case CMAS_RX_ASSOC_RESP:
+                       IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
+                                 "RX_ASSOC_RESP\n");
+                       break;
+               case CMAS_ASSOCIATED:
+                       IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
+                                 "ASSOCIATED\n");
+                       break;
+               default:
+                       IPW_DEBUG_NOTIF("auth: failure - %d\n", auth->state);
+                       break;
+               }
+               break;
+       }
+
+       case HOST_NOTIFICATION_STATUS_SCAN_CHANNEL_RESULT: {
+               struct notif_channel_result *x = &notif->u.channel_result;
+
+               if (notif->size == sizeof(*x)) {
+                       IPW_DEBUG_SCAN("Scan result for channel %d\n",
+                                      x->channel_num);
+               } else {
+                       IPW_DEBUG_SCAN("Scan result of wrong size %d "
+                                      "(should be %zd)\n",
+                                      notif->size, sizeof(*x));
+               }
+               break;
+       }
+
+       case HOST_NOTIFICATION_STATUS_SCAN_COMPLETED: {
+               struct notif_scan_complete* x = &notif->u.scan_complete;
+               if (notif->size == sizeof(*x)) {
+                       IPW_DEBUG_SCAN("Scan completed: type %d, %d channels, "
+                                      "%d status\n",
+                                      x->scan_type,
+                                      x->num_channels,
+                                      x->status);
+               } else {
+                       IPW_ERROR("Scan completed of wrong size %d "
+                                 "(should be %zd)\n",
+                                 notif->size, sizeof(*x));
+               }
+
+               priv->status &= ~(STATUS_SCANNING | STATUS_SCAN_ABORTING);
+
+               cancel_delayed_work(&priv->scan_check);
+
+               if (!(priv->status & (STATUS_ASSOCIATED |
+                                     STATUS_ASSOCIATING |
+                                     STATUS_ROAMING |
+                                     STATUS_DISASSOCIATING)))
+                       queue_work(priv->workqueue, &priv->associate);
+               else if (priv->status & STATUS_ROAMING) {
+                       /* If a scan completed and we are in roam mode, then
+                        * the scan that completed was the one requested as a
+                        * result of entering roam... so, schedule the
+                        * roam work */
+                       queue_work(priv->workqueue, &priv->roam);
+               } else if (priv->status & STATUS_SCAN_PENDING)
+                       queue_work(priv->workqueue, &priv->request_scan);
+
+               priv->ieee->scans++;
+               break;
+       }
+
+       case HOST_NOTIFICATION_STATUS_FRAG_LENGTH: {
+               struct notif_frag_length *x = &notif->u.frag_len;
+
+               if (notif->size == sizeof(*x)) {
+                       IPW_ERROR("Frag length: %d\n", x->frag_length);
+               } else {
+                       IPW_ERROR("Frag length of wrong size %d "
+                                 "(should be %zd)\n",
+                                 notif->size, sizeof(*x));
+               }
+               break;
+       }
+
+       case HOST_NOTIFICATION_STATUS_LINK_DETERIORATION: {
+               struct notif_link_deterioration *x =
+                       &notif->u.link_deterioration;
+               if (notif->size==sizeof(*x)) {
+                       IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE,
+                                 "link deterioration: '%s' " MAC_FMT " \n",
+                                 escape_essid(priv->essid, priv->essid_len),
+                                 MAC_ARG(priv->bssid));
+                       memcpy(&priv->last_link_deterioration, x, sizeof(*x));
+               } else {
+                       IPW_ERROR("Link Deterioration of wrong size %d "
+                                 "(should be %zd)\n",
+                                 notif->size, sizeof(*x));
+               }
+               break;
+       }
+
+       case HOST_NOTIFICATION_DINO_CONFIG_RESPONSE: {
+               IPW_ERROR("Dino config\n");
+               if (priv->hcmd && priv->hcmd->cmd == HOST_CMD_DINO_CONFIG) {
+                       /* TODO: Do anything special? */
+               } else {
+                       IPW_ERROR("Unexpected DINO_CONFIG_RESPONSE\n");
+               }
+               break;
+       }
+
+       case HOST_NOTIFICATION_STATUS_BEACON_STATE: {
+               struct notif_beacon_state *x = &notif->u.beacon_state;
+               if (notif->size != sizeof(*x)) {
+                       IPW_ERROR("Beacon state of wrong size %d (should "
+                                 "be %zd)\n", notif->size, sizeof(*x));
+                       break;
+               }
+
+               if (x->state == HOST_NOTIFICATION_STATUS_BEACON_MISSING) {
+                       if (priv->status & STATUS_SCANNING) {
+                               /* Stop scan to keep fw from getting
+                                * stuck... */
+                               queue_work(priv->workqueue,
+                                          &priv->abort_scan);
+                       }
+
+                       if (x->number > priv->missed_beacon_threshold &&
+                           priv->status & STATUS_ASSOCIATED) {
+                               IPW_DEBUG(IPW_DL_INFO | IPW_DL_NOTIF |
+                                         IPW_DL_STATE,
+                                         "Missed beacon: %d - disassociate\n",
+                                         x->number);
+                               queue_work(priv->workqueue,
+                                          &priv->disassociate);
+                       } else if (x->number > priv->roaming_threshold) {
+                               IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE,
+                                         "Missed beacon: %d - initiate "
+                                         "roaming\n",
+                                         x->number);
+                               queue_work(priv->workqueue,
+                                          &priv->roam);
+                       } else {
+                               IPW_DEBUG_NOTIF("Missed beacon: %d\n",
+                                               x->number);
+                       }
+
+                       priv->notif_missed_beacons = x->number;
+
+                }
+
+
+               break;
+       }
+
+       case HOST_NOTIFICATION_STATUS_TGI_TX_KEY: {
+               struct notif_tgi_tx_key *x = &notif->u.tgi_tx_key;
+               if (notif->size==sizeof(*x)) {
+                       IPW_ERROR("TGi Tx Key: state 0x%02x sec type "
+                                 "0x%02x station %d\n",
+                                 x->key_state,x->security_type,
+                                 x->station_index);
+                       break;
+               }
+
+               IPW_ERROR("TGi Tx Key of wrong size %d (should be %zd)\n",
+                         notif->size, sizeof(*x));
+               break;
+       }
+
+       case HOST_NOTIFICATION_CALIB_KEEP_RESULTS: {
+               struct notif_calibration *x = &notif->u.calibration;
+
+               if (notif->size == sizeof(*x)) {
+                       memcpy(&priv->calib, x, sizeof(*x));
+                       IPW_DEBUG_INFO("TODO: Calibration\n");
+                       break;
+               }
+
+               IPW_ERROR("Calibration of wrong size %d (should be %zd)\n",
+                         notif->size, sizeof(*x));
+               break;
+       }
+
+       case HOST_NOTIFICATION_NOISE_STATS: {
+               if (notif->size == sizeof(u32)) {
+                       priv->last_noise = (u8)(notif->u.noise.value & 0xff);
+                       average_add(&priv->average_noise, priv->last_noise);
+                       break;
+               }
+
+               IPW_ERROR("Noise stat is wrong size %d (should be %zd)\n",
+                         notif->size, sizeof(u32));
+               break;
+       }
+
+       default:
+               IPW_ERROR("Unknown notification: "
+                         "subtype=%d,flags=0x%2x,size=%d\n",
+                         notif->subtype, notif->flags, notif->size);
+       }
+}
+
+/**
+ * Destroys all DMA structures and initialise them again
+ *
+ * @param priv
+ * @return error code
+ */
+static int ipw_queue_reset(struct ipw_priv *priv)
+{
+       int rc = 0;
+       /** @todo customize queue sizes */
+       int nTx = 64, nTxCmd = 8;
+       ipw_tx_queue_free(priv);
+       /* Tx CMD queue */
+       rc = ipw_queue_tx_init(priv, &priv->txq_cmd, nTxCmd,
+                              CX2_TX_CMD_QUEUE_READ_INDEX,
+                              CX2_TX_CMD_QUEUE_WRITE_INDEX,
+                              CX2_TX_CMD_QUEUE_BD_BASE,
+                              CX2_TX_CMD_QUEUE_BD_SIZE);
+       if (rc) {
+               IPW_ERROR("Tx Cmd queue init failed\n");
+               goto error;
+       }
+       /* Tx queue(s) */
+       rc = ipw_queue_tx_init(priv, &priv->txq[0], nTx,
+                              CX2_TX_QUEUE_0_READ_INDEX,
+                              CX2_TX_QUEUE_0_WRITE_INDEX,
+                              CX2_TX_QUEUE_0_BD_BASE,
+                              CX2_TX_QUEUE_0_BD_SIZE);
+       if (rc) {
+               IPW_ERROR("Tx 0 queue init failed\n");
+               goto error;
+       }
+       rc = ipw_queue_tx_init(priv, &priv->txq[1], nTx,
+                              CX2_TX_QUEUE_1_READ_INDEX,
+                              CX2_TX_QUEUE_1_WRITE_INDEX,
+                              CX2_TX_QUEUE_1_BD_BASE,
+                              CX2_TX_QUEUE_1_BD_SIZE);
+       if (rc) {
+               IPW_ERROR("Tx 1 queue init failed\n");
+               goto error;
+       }
+       rc = ipw_queue_tx_init(priv, &priv->txq[2], nTx,
+                              CX2_TX_QUEUE_2_READ_INDEX,
+                              CX2_TX_QUEUE_2_WRITE_INDEX,
+                              CX2_TX_QUEUE_2_BD_BASE,
+                              CX2_TX_QUEUE_2_BD_SIZE);
+       if (rc) {
+               IPW_ERROR("Tx 2 queue init failed\n");
+               goto error;
+       }
+       rc = ipw_queue_tx_init(priv, &priv->txq[3], nTx,
+                              CX2_TX_QUEUE_3_READ_INDEX,
+                              CX2_TX_QUEUE_3_WRITE_INDEX,
+                              CX2_TX_QUEUE_3_BD_BASE,
+                              CX2_TX_QUEUE_3_BD_SIZE);
+       if (rc) {
+               IPW_ERROR("Tx 3 queue init failed\n");
+               goto error;
+       }
+       /* statistics */
+       priv->rx_bufs_min = 0;
+       priv->rx_pend_max = 0;
+       return rc;
+
+ error:
+       ipw_tx_queue_free(priv);
+       return rc;
+}
+
+/**
+ * Reclaim Tx queue entries no more used by NIC.
+ *
+ * When FW adwances 'R' index, all entries between old and
+ * new 'R' index need to be reclaimed. As result, some free space
+ * forms. If there is enough free space (> low mark), wake Tx queue.
+ *
+ * @note Need to protect against garbage in 'R' index
+ * @param priv
+ * @param txq
+ * @param qindex
+ * @return Number of used entries remains in the queue
+ */
+static int ipw_queue_tx_reclaim(struct ipw_priv *priv,
+                               struct clx2_tx_queue *txq, int qindex)
+{
+       u32 hw_tail;
+       int used;
+       struct clx2_queue *q = &txq->q;
+
+       hw_tail = ipw_read32(priv, q->reg_r);
+       if (hw_tail >= q->n_bd) {
+               IPW_ERROR
+                       ("Read index for DMA queue (%d) is out of range [0-%d)\n",
+                        hw_tail, q->n_bd);
+               goto done;
+       }
+       for (; q->last_used != hw_tail;
+            q->last_used = ipw_queue_inc_wrap(q->last_used, q->n_bd)) {
+               ipw_queue_tx_free_tfd(priv, txq);
+               priv->tx_packets++;
+       }
+ done:
+       if (ipw_queue_space(q) > q->low_mark && qindex >= 0) {
+               __maybe_wake_tx(priv);
+       }
+       used = q->first_empty - q->last_used;
+       if (used < 0)
+               used += q->n_bd;
+
+       return used;
+}
+
+static int ipw_queue_tx_hcmd(struct ipw_priv *priv, int hcmd, void *buf,
+                            int len, int sync)
+{
+       struct clx2_tx_queue *txq = &priv->txq_cmd;
+       struct clx2_queue *q = &txq->q;
+       struct tfd_frame *tfd;
+
+       if (ipw_queue_space(q) < (sync ? 1 : 2)) {
+               IPW_ERROR("No space for Tx\n");
+               return -EBUSY;
+       }
+
+       tfd = &txq->bd[q->first_empty];
+       txq->txb[q->first_empty] = NULL;
+
+       memset(tfd, 0, sizeof(*tfd));
+       tfd->control_flags.message_type = TX_HOST_COMMAND_TYPE;
+       tfd->control_flags.control_bits = TFD_NEED_IRQ_MASK;
+       priv->hcmd_seq++;
+       tfd->u.cmd.index = hcmd;
+       tfd->u.cmd.length = len;
+       memcpy(tfd->u.cmd.payload, buf, len);
+       q->first_empty = ipw_queue_inc_wrap(q->first_empty, q->n_bd);
+       ipw_write32(priv, q->reg_w, q->first_empty);
+       _ipw_read32(priv, 0x90);
+
+       return 0;
+}
+
+
+
+/*
+ * Rx theory of operation
+ *
+ * The host allocates 32 DMA target addresses and passes the host address
+ * to the firmware at register CX2_RFDS_TABLE_LOWER + N * RFD_SIZE where N is
+ * 0 to 31
+ *
+ * Rx Queue Indexes
+ * The host/firmware share two index registers for managing the Rx buffers.
+ *
+ * The READ index maps to the first position that the firmware may be writing
+ * to -- the driver can read up to (but not including) this position and get
+ * good data.
+ * The READ index is managed by the firmware once the card is enabled.
+ *
+ * The WRITE index maps to the last position the driver has read from -- the
+ * position preceding WRITE is the last slot the firmware can place a packet.
+ *
+ * The queue is empty (no good data) if WRITE = READ - 1, and is full if
+ * WRITE = READ.
+ *
+ * During initialization the host sets up the READ queue position to the first
+ * INDEX position, and WRITE to the last (READ - 1 wrapped)
+ *
+ * When the firmware places a packet in a buffer it will advance the READ index
+ * and fire the RX interrupt.  The driver can then query the READ index and
+ * process as many packets as possible, moving the WRITE index forward as it
+ * resets the Rx queue buffers with new memory.
+ *
+ * The management in the driver is as follows:
+ * + A list of pre-allocated SKBs is stored in ipw->rxq->rx_free.  When
+ *   ipw->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled
+ *   to replensish the ipw->rxq->rx_free.
+ * + In ipw_rx_queue_replenish (scheduled) if 'processed' != 'read' then the
+ *   ipw->rxq is replenished and the READ INDEX is updated (updating the
+ *   'processed' and 'read' driver indexes as well)
+ * + A received packet is processed and handed to the kernel network stack,
+ *   detached from the ipw->rxq.  The driver 'processed' index is updated.
+ * + The Host/Firmware ipw->rxq is replenished at tasklet time from the rx_free
+ *   list. If there are no allocated buffers in ipw->rxq->rx_free, the READ
+ *   INDEX is not incremented and ipw->status(RX_STALLED) is set.  If there
+ *   were enough free buffers and RX_STALLED is set it is cleared.
+ *
+ *
+ * Driver sequence:
+ *
+ * ipw_rx_queue_alloc()       Allocates rx_free
+ * ipw_rx_queue_replenish()   Replenishes rx_free list from rx_used, and calls
+ *                            ipw_rx_queue_restock
+ * ipw_rx_queue_restock()     Moves available buffers from rx_free into Rx
+ *                            queue, updates firmware pointers, and updates
+ *                            the WRITE index.  If insufficient rx_free buffers
+ *                            are available, schedules ipw_rx_queue_replenish
+ *
+ * -- enable interrupts --
+ * ISR - ipw_rx()             Detach ipw_rx_mem_buffers from pool up to the
+ *                            READ INDEX, detaching the SKB from the pool.
+ *                            Moves the packet buffer from queue to rx_used.
+ *                            Calls ipw_rx_queue_restock to refill any empty
+ *                            slots.
+ * ...
+ *
+ */
+
+/*
+ * If there are slots in the RX queue that  need to be restocked,
+ * and we have free pre-allocated buffers, fill the ranks as much
+ * as we can pulling from rx_free.
+ *
+ * This moves the 'write' index forward to catch up with 'processed', and
+ * also updates the memory address in the firmware to reference the new
+ * target buffer.
+ */
+static void ipw_rx_queue_restock(struct ipw_priv *priv)
+{
+       struct ipw_rx_queue *rxq = priv->rxq;
+       struct list_head *element;
+       struct ipw_rx_mem_buffer *rxb;
+       unsigned long flags;
+       int write;
+
+       spin_lock_irqsave(&rxq->lock, flags);
+       write = rxq->write;
+       while ((rxq->write != rxq->processed) && (rxq->free_count)) {
+               element = rxq->rx_free.next;
+               rxb = list_entry(element, struct ipw_rx_mem_buffer, list);
+               list_del(element);
+
+               ipw_write32(priv, CX2_RFDS_TABLE_LOWER + rxq->write * RFD_SIZE,
+                           rxb->dma_addr);
+               rxq->queue[rxq->write] = rxb;
+               rxq->write = (rxq->write + 1) % RX_QUEUE_SIZE;
+               rxq->free_count--;
+       }
+       spin_unlock_irqrestore(&rxq->lock, flags);
+
+       /* If the pre-allocated buffer pool is dropping low, schedule to
+        * refill it */
+       if (rxq->free_count <= RX_LOW_WATERMARK)
+               queue_work(priv->workqueue, &priv->rx_replenish);
+
+       /* If we've added more space for the firmware to place data, tell it */
+       if (write != rxq->write)
+               ipw_write32(priv, CX2_RX_WRITE_INDEX, rxq->write);
+}
+
+/*
+ * Move all used packet from rx_used to rx_free, allocating a new SKB for each.
+ * Also restock the Rx queue via ipw_rx_queue_restock.
+ *
+ * This is called as a scheduled work item (except for during intialization)
+ */
+static void ipw_rx_queue_replenish(void *data)
+{
+       struct ipw_priv *priv = data;
+       struct ipw_rx_queue *rxq = priv->rxq;
+       struct list_head *element;
+       struct ipw_rx_mem_buffer *rxb;
+       unsigned long flags;
+
+       spin_lock_irqsave(&rxq->lock, flags);
+       while (!list_empty(&rxq->rx_used)) {
+               element = rxq->rx_used.next;
+               rxb = list_entry(element, struct ipw_rx_mem_buffer, list);
+               rxb->skb = alloc_skb(CX2_RX_BUF_SIZE, GFP_ATOMIC);
+               if (!rxb->skb) {
+                       printk(KERN_CRIT "%s: Can not allocate SKB buffers.\n",
+                              priv->net_dev->name);
+                       /* We don't reschedule replenish work here -- we will
+                        * call the restock method and if it still needs
+                        * more buffers it will schedule replenish */
+                       break;
+               }
+               list_del(element);
+
+               rxb->rxb = (struct ipw_rx_buffer *)rxb->skb->data;
+               rxb->dma_addr = pci_map_single(
+                       priv->pci_dev, rxb->skb->data, CX2_RX_BUF_SIZE,
+                       PCI_DMA_FROMDEVICE);
+
+               list_add_tail(&rxb->list, &rxq->rx_free);
+               rxq->free_count++;
+       }
+       spin_unlock_irqrestore(&rxq->lock, flags);
+
+       ipw_rx_queue_restock(priv);
+}
+
+/* Assumes that the skb field of the buffers in 'pool' is kept accurate.
+ * If an SKB has been detached, the POOL needs to have it's SKB set to NULL
+ * This free routine walks the list of POOL entries and if SKB is set to
+ * non NULL it is unmapped and freed
+ */
+static void ipw_rx_queue_free(struct ipw_priv *priv,
+                             struct ipw_rx_queue *rxq)
+{
+       int i;
+
+       if (!rxq)
+               return;
+
+       for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) {
+               if (rxq->pool[i].skb != NULL) {
+                       pci_unmap_single(priv->pci_dev, rxq->pool[i].dma_addr,
+                                        CX2_RX_BUF_SIZE,
+                                        PCI_DMA_FROMDEVICE);
+                       dev_kfree_skb(rxq->pool[i].skb);
+               }
+       }
+
+       kfree(rxq);
+}
+
+static struct ipw_rx_queue *ipw_rx_queue_alloc(struct ipw_priv *priv)
+{
+       struct ipw_rx_queue *rxq;
+       int i;
+
+       rxq = (struct ipw_rx_queue *)kmalloc(sizeof(*rxq), GFP_KERNEL);
+       memset(rxq, 0, sizeof(*rxq));
+       spin_lock_init(&rxq->lock);
+       INIT_LIST_HEAD(&rxq->rx_free);
+       INIT_LIST_HEAD(&rxq->rx_used);
+
+       /* Fill the rx_used queue with _all_ of the Rx buffers */
+       for (i = 0; i < RX_FREE_BUFFERS + RX_QUEUE_SIZE; i++)
+               list_add_tail(&rxq->pool[i].list, &rxq->rx_used);
+
+       /* Set us so that we have processed and used all buffers, but have
+        * not restocked the Rx queue with fresh buffers */
+       rxq->read = rxq->write = 0;
+       rxq->processed = RX_QUEUE_SIZE - 1;
+       rxq->free_count = 0;
+
+       return rxq;
+}
+
+static int ipw_is_rate_in_mask(struct ipw_priv *priv, int ieee_mode, u8 rate)
+{
+       rate &= ~IEEE80211_BASIC_RATE_MASK;
+       if (ieee_mode == IEEE_A) {
+               switch (rate) {
+               case IEEE80211_OFDM_RATE_6MB:
+                       return priv->rates_mask & IEEE80211_OFDM_RATE_6MB_MASK ?
+                               1 : 0;
+               case IEEE80211_OFDM_RATE_9MB:
+                       return priv->rates_mask & IEEE80211_OFDM_RATE_9MB_MASK ?
+                               1 : 0;
+               case IEEE80211_OFDM_RATE_12MB:
+                       return priv->rates_mask & IEEE80211_OFDM_RATE_12MB_MASK ?
+                               1 : 0;
+               case IEEE80211_OFDM_RATE_18MB:
+                       return priv->rates_mask & IEEE80211_OFDM_RATE_18MB_MASK ?
+                               1 : 0;
+               case IEEE80211_OFDM_RATE_24MB:
+                       return priv->rates_mask & IEEE80211_OFDM_RATE_24MB_MASK ?
+                               1 : 0;
+               case IEEE80211_OFDM_RATE_36MB:
+                       return priv->rates_mask & IEEE80211_OFDM_RATE_36MB_MASK ?
+                               1 : 0;
+               case IEEE80211_OFDM_RATE_48MB:
+                       return priv->rates_mask & IEEE80211_OFDM_RATE_48MB_MASK ?
+                               1 : 0;
+               case IEEE80211_OFDM_RATE_54MB:
+                       return priv->rates_mask & IEEE80211_OFDM_RATE_54MB_MASK ?
+                               1 : 0;
+               default:
+                       return 0;
+               }
+       }
+
+       /* B and G mixed */
+       switch (rate) {
+       case IEEE80211_CCK_RATE_1MB:
+               return priv->rates_mask & IEEE80211_CCK_RATE_1MB_MASK ? 1 : 0;
+       case IEEE80211_CCK_RATE_2MB:
+               return priv->rates_mask & IEEE80211_CCK_RATE_2MB_MASK ? 1 : 0;
+       case IEEE80211_CCK_RATE_5MB:
+               return priv->rates_mask & IEEE80211_CCK_RATE_5MB_MASK ? 1 : 0;
+       case IEEE80211_CCK_RATE_11MB:
+               return priv->rates_mask & IEEE80211_CCK_RATE_11MB_MASK ? 1 : 0;
+       }
+
+       /* If we are limited to B modulations, bail at this point */
+       if (ieee_mode == IEEE_B)
+               return 0;
+
+       /* G */
+       switch (rate) {
+       case IEEE80211_OFDM_RATE_6MB:
+               return priv->rates_mask & IEEE80211_OFDM_RATE_6MB_MASK ? 1 : 0;
+       case IEEE80211_OFDM_RATE_9MB:
+               return priv->rates_mask & IEEE80211_OFDM_RATE_9MB_MASK ? 1 : 0;
+       case IEEE80211_OFDM_RATE_12MB:
+               return priv->rates_mask & IEEE80211_OFDM_RATE_12MB_MASK ? 1 : 0;
+       case IEEE80211_OFDM_RATE_18MB:
+               return priv->rates_mask & IEEE80211_OFDM_RATE_18MB_MASK ? 1 : 0;
+       case IEEE80211_OFDM_RATE_24MB:
+               return priv->rates_mask & IEEE80211_OFDM_RATE_24MB_MASK ? 1 : 0;
+       case IEEE80211_OFDM_RATE_36MB:
+               return priv->rates_mask & IEEE80211_OFDM_RATE_36MB_MASK ? 1 : 0;
+       case IEEE80211_OFDM_RATE_48MB:
+               return priv->rates_mask & IEEE80211_OFDM_RATE_48MB_MASK ? 1 : 0;
+       case IEEE80211_OFDM_RATE_54MB:
+               return priv->rates_mask & IEEE80211_OFDM_RATE_54MB_MASK ? 1 : 0;
+       }
+
+       return 0;
+}
+
+static int ipw_compatible_rates(struct ipw_priv *priv,
+                               const struct ieee80211_network *network,
+                               struct ipw_supported_rates *rates)
+{
+       int num_rates, i;
+
+       memset(rates, 0, sizeof(*rates));
+       num_rates = min(network->rates_len, (u8)IPW_MAX_RATES);
+       rates->num_rates = 0;
+       for (i = 0; i < num_rates; i++) {
+               if (!ipw_is_rate_in_mask(priv, network->mode, network->rates[i])) {
+                       IPW_DEBUG_SCAN("Rate %02X masked : 0x%08X\n",
+                                      network->rates[i], priv->rates_mask);
+                       continue;
+               }
+
+               rates->supported_rates[rates->num_rates++] = network->rates[i];
+       }
+
+       num_rates = min(network->rates_ex_len, (u8)(IPW_MAX_RATES - num_rates));
+       for (i = 0; i < num_rates; i++) {
+               if (!ipw_is_rate_in_mask(priv, network->mode, network->rates_ex[i])) {
+                       IPW_DEBUG_SCAN("Rate %02X masked : 0x%08X\n",
+                                      network->rates_ex[i], priv->rates_mask);
+                       continue;
+               }
+
+               rates->supported_rates[rates->num_rates++] = network->rates_ex[i];
+       }
+
+       return rates->num_rates;
+}
+
+static inline void ipw_copy_rates(struct ipw_supported_rates *dest,
+                                 const struct ipw_supported_rates *src)
+{
+       u8 i;
+       for (i = 0; i < src->num_rates; i++)
+               dest->supported_rates[i] = src->supported_rates[i];
+       dest->num_rates = src->num_rates;
+}
+
+/* TODO: Look at sniffed packets in the air to determine if the basic rate
+ * mask should ever be used -- right now all callers to add the scan rates are
+ * set with the modulation = CCK, so BASIC_RATE_MASK is never set... */
+static void ipw_add_cck_scan_rates(struct ipw_supported_rates *rates,
+                              u8 modulation, u32 rate_mask)
+{
+       u8 basic_mask = (IEEE80211_OFDM_MODULATION == modulation) ?
+               IEEE80211_BASIC_RATE_MASK : 0;
+
+       if (rate_mask & IEEE80211_CCK_RATE_1MB_MASK)
+               rates->supported_rates[rates->num_rates++] =
+                       IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB;
+
+       if (rate_mask & IEEE80211_CCK_RATE_2MB_MASK)
+               rates->supported_rates[rates->num_rates++] =
+                       IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB;
+
+       if (rate_mask & IEEE80211_CCK_RATE_5MB_MASK)
+               rates->supported_rates[rates->num_rates++] = basic_mask |
+                       IEEE80211_CCK_RATE_5MB;
+
+       if (rate_mask & IEEE80211_CCK_RATE_11MB_MASK)
+               rates->supported_rates[rates->num_rates++] = basic_mask |
+                       IEEE80211_CCK_RATE_11MB;
+}
+
+static void ipw_add_ofdm_scan_rates(struct ipw_supported_rates *rates,
+                               u8 modulation, u32 rate_mask)
+{
+       u8 basic_mask = (IEEE80211_OFDM_MODULATION == modulation) ?
+               IEEE80211_BASIC_RATE_MASK : 0;
+
+       if (rate_mask & IEEE80211_OFDM_RATE_6MB_MASK)
+               rates->supported_rates[rates->num_rates++] = basic_mask |
+                       IEEE80211_OFDM_RATE_6MB;
+
+       if (rate_mask & IEEE80211_OFDM_RATE_9MB_MASK)
+               rates->supported_rates[rates->num_rates++] =
+                       IEEE80211_OFDM_RATE_9MB;
+
+       if (rate_mask & IEEE80211_OFDM_RATE_12MB_MASK)
+               rates->supported_rates[rates->num_rates++] = basic_mask |
+                       IEEE80211_OFDM_RATE_12MB;
+
+       if (rate_mask & IEEE80211_OFDM_RATE_18MB_MASK)
+               rates->supported_rates[rates->num_rates++] =
+                       IEEE80211_OFDM_RATE_18MB;
+
+       if (rate_mask & IEEE80211_OFDM_RATE_24MB_MASK)
+               rates->supported_rates[rates->num_rates++] = basic_mask |
+                       IEEE80211_OFDM_RATE_24MB;
+
+       if (rate_mask & IEEE80211_OFDM_RATE_36MB_MASK)
+               rates->supported_rates[rates->num_rates++] =
+                       IEEE80211_OFDM_RATE_36MB;
+
+       if (rate_mask & IEEE80211_OFDM_RATE_48MB_MASK)
+               rates->supported_rates[rates->num_rates++] =
+                       IEEE80211_OFDM_RATE_48MB;
+
+       if (rate_mask & IEEE80211_OFDM_RATE_54MB_MASK)
+               rates->supported_rates[rates->num_rates++] =
+                       IEEE80211_OFDM_RATE_54MB;
+}
+
+struct ipw_network_match {
+       struct ieee80211_network *network;
+       struct ipw_supported_rates rates;
+};
+
+static int ipw_best_network(
+       struct ipw_priv *priv,
+       struct ipw_network_match *match,
+       struct ieee80211_network *network,
+       int roaming)
+{
+       struct ipw_supported_rates rates;
+
+       /* Verify that this network's capability is compatible with the
+        * current mode (AdHoc or Infrastructure) */
+       if ((priv->ieee->iw_mode == IW_MODE_INFRA &&
+            !(network->capability & WLAN_CAPABILITY_ESS)) ||
+           (priv->ieee->iw_mode == IW_MODE_ADHOC &&
+            !(network->capability & WLAN_CAPABILITY_IBSS))) {
+               IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded due to "
+                               "capability mismatch.\n",
+                               escape_essid(network->ssid, network->ssid_len),
+                               MAC_ARG(network->bssid));
+               return 0;
+       }
+
+       /* If we do not have an ESSID for this AP, we can not associate with
+        * it */
+       if (network->flags & NETWORK_EMPTY_ESSID) {
+               IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded "
+                               "because of hidden ESSID.\n",
+                               escape_essid(network->ssid, network->ssid_len),
+                               MAC_ARG(network->bssid));
+               return 0;
+       }
+
+       if (unlikely(roaming)) {
+               /* If we are roaming, then ensure check if this is a valid
+                * network to try and roam to */
+               if ((network->ssid_len != match->network->ssid_len) ||
+                   memcmp(network->ssid, match->network->ssid,
+                          network->ssid_len)) {
+                       IPW_DEBUG_ASSOC("Netowrk '%s (" MAC_FMT ")' excluded "
+                                       "because of non-network ESSID.\n",
+                                       escape_essid(network->ssid,
+                                                    network->ssid_len),
+                                       MAC_ARG(network->bssid));
+                       return 0;
+               }
+       } else {
+               /* If an ESSID has been configured then compare the broadcast
+                * ESSID to ours */
+               if ((priv->config & CFG_STATIC_ESSID) &&
+                   ((network->ssid_len != priv->essid_len) ||
+                    memcmp(network->ssid, priv->essid,
+                           min(network->ssid_len, priv->essid_len)))) {
+                       char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
+                       strncpy(escaped, escape_essid(
+                                       network->ssid, network->ssid_len),
+                               sizeof(escaped));
+                       IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded "
+                                       "because of ESSID mismatch: '%s'.\n",
+                                       escaped, MAC_ARG(network->bssid),
+                                       escape_essid(priv->essid, priv->essid_len));
+                       return 0;
+               }
+       }
+
+       /* If the old network rate is better than this one, don't bother
+        * testing everything else. */
+       if (match->network && match->network->stats.rssi >
+           network->stats.rssi) {
+               char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
+               strncpy(escaped,
+                       escape_essid(network->ssid, network->ssid_len),
+                       sizeof(escaped));
+               IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded because "
+                               "'%s (" MAC_FMT ")' has a stronger signal.\n",
+                               escaped, MAC_ARG(network->bssid),
+                               escape_essid(match->network->ssid,
+                                            match->network->ssid_len),
+                               MAC_ARG(match->network->bssid));
+               return 0;
+       }
+
+       /* If this network has already had an association attempt within the
+        * last 3 seconds, do not try and associate again... */
+       if (network->last_associate &&
+           time_after(network->last_associate + (HZ * 5UL), jiffies)) {
+               IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded "
+                               "because of storming (%lu since last "
+                               "assoc attempt).\n",
+                               escape_essid(network->ssid, network->ssid_len),
+                               MAC_ARG(network->bssid),
+                               (jiffies - network->last_associate) / HZ);
+               return 0;
+       }
+
+       /* Now go through and see if the requested network is valid... */
+       if (priv->ieee->scan_age != 0 &&
+           jiffies - network->last_scanned > priv->ieee->scan_age) {
+               IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded "
+                               "because of age: %lums.\n",
+                               escape_essid(network->ssid, network->ssid_len),
+                               MAC_ARG(network->bssid),
+                               (jiffies - network->last_scanned) / (HZ / 100));
+               return 0;
+       }
+
+       if ((priv->config & CFG_STATIC_CHANNEL) &&
+           (network->channel != priv->channel)) {
+               IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded "
+                               "because of channel mismatch: %d != %d.\n",
+                               escape_essid(network->ssid, network->ssid_len),
+                               MAC_ARG(network->bssid),
+                               network->channel, priv->channel);
+               return 0;
+       }
+
+       /* Verify privacy compatability */
+       if (((priv->capability & CAP_PRIVACY_ON) ? 1 : 0) !=
+           ((network->capability & WLAN_CAPABILITY_PRIVACY) ? 1 : 0)) {
+               IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded "
+                               "because of privacy mismatch: %s != %s.\n",
+                               escape_essid(network->ssid, network->ssid_len),
+                               MAC_ARG(network->bssid),
+                               priv->capability & CAP_PRIVACY_ON ? "on" :
+                               "off",
+                               network->capability &
+                               WLAN_CAPABILITY_PRIVACY ?"on" : "off");
+               return 0;
+       }
+
+       if ((priv->config & CFG_STATIC_BSSID) &&
+           memcmp(network->bssid, priv->bssid, ETH_ALEN)) {
+               IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded "
+                               "because of BSSID mismatch: " MAC_FMT ".\n",
+                               escape_essid(network->ssid, network->ssid_len),
+                               MAC_ARG(network->bssid),
+                               MAC_ARG(priv->bssid));
+               return 0;
+       }
+
+       /* Filter out any incompatible freq / mode combinations */
+       if (!ieee80211_is_valid_mode(priv->ieee, network->mode)) {
+               IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded "
+                               "because of invalid frequency/mode "
+                               "combination.\n",
+                               escape_essid(network->ssid, network->ssid_len),
+                               MAC_ARG(network->bssid));
+               return 0;
+       }
+
+       ipw_compatible_rates(priv, network, &rates);
+       if (rates.num_rates == 0) {
+               IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded "
+                               "because of no compatible rates.\n",
+                               escape_essid(network->ssid, network->ssid_len),
+                               MAC_ARG(network->bssid));
+               return 0;
+       }
+
+       /* TODO: Perform any further minimal comparititive tests.  We do not
+        * want to put too much policy logic here; intelligent scan selection
+        * should occur within a generic IEEE 802.11 user space tool.  */
+
+       /* Set up 'new' AP to this network */
+       ipw_copy_rates(&match->rates, &rates);
+       match->network = network;
+
+       IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' is a viable match.\n",
+                       escape_essid(network->ssid, network->ssid_len),
+                       MAC_ARG(network->bssid));
+
+       return 1;
+}
+
+
+static void ipw_adhoc_create(struct ipw_priv *priv,
+                           struct ieee80211_network *network)
+{
+       /*
+        * For the purposes of scanning, we can set our wireless mode
+        * to trigger scans across combinations of bands, but when it
+        * comes to creating a new ad-hoc network, we have tell the FW
+        * exactly which band to use.
+        *
+        * We also have the possibility of an invalid channel for the
+        * chossen band.  Attempting to create a new ad-hoc network
+        * with an invalid channel for wireless mode will trigger a
+        * FW fatal error.
+        */
+       network->mode = is_valid_channel(priv->ieee->mode, priv->channel);
+       if (network->mode) {
+               network->channel = priv->channel;
+       } else {
+               IPW_WARNING("Overriding invalid channel\n");
+               if (priv->ieee->mode & IEEE_A) {
+                       network->mode = IEEE_A;
+                       priv->channel = band_a_active_channel[0];
+               } else if (priv->ieee->mode & IEEE_G) {
+                       network->mode = IEEE_G;
+                       priv->channel = band_b_active_channel[0];
+               } else {
+                       network->mode = IEEE_B;
+                       priv->channel = band_b_active_channel[0];
+               }
+       }
+
+       network->channel = priv->channel;
+       priv->config |= CFG_ADHOC_PERSIST;
+       ipw_create_bssid(priv, network->bssid);
+       network->ssid_len = priv->essid_len;
+       memcpy(network->ssid, priv->essid, priv->essid_len);
+       memset(&network->stats, 0, sizeof(network->stats));
+       network->capability = WLAN_CAPABILITY_IBSS;
+       if (priv->capability & CAP_PRIVACY_ON)
+               network->capability |= WLAN_CAPABILITY_PRIVACY;
+       network->rates_len = min(priv->rates.num_rates, MAX_RATES_LENGTH);
+       memcpy(network->rates, priv->rates.supported_rates,
+              network->rates_len);
+       network->rates_ex_len = priv->rates.num_rates - network->rates_len;
+       memcpy(network->rates_ex,
+              &priv->rates.supported_rates[network->rates_len],
+              network->rates_ex_len);
+       network->last_scanned = 0;
+       network->flags = 0;
+       network->last_associate = 0;
+       network->time_stamp[0] = 0;
+       network->time_stamp[1] = 0;
+       network->beacon_interval = 100; /* Default */
+       network->listen_interval = 10;  /* Default */
+       network->atim_window = 0;       /* Default */
+#ifdef CONFIG_IEEE80211_WPA
+       network->wpa_ie_len = 0;
+       network->rsn_ie_len = 0;
+#endif /* CONFIG_IEEE80211_WPA */
+}
+
+static void ipw_send_wep_keys(struct ipw_priv *priv)
+{
+       struct ipw_wep_key *key;
+       int i;
+       struct host_cmd cmd = {
+               .cmd = IPW_CMD_WEP_KEY,
+               .len = sizeof(*key)
+       };
+
+       key = (struct ipw_wep_key *)&cmd.param;
+       key->cmd_id = DINO_CMD_WEP_KEY;
+       key->seq_num = 0;
+
+       for (i = 0; i < 4; i++) {
+               key->key_index = i;
+               if (!(priv->sec.flags & (1 << i))) {
+                       key->key_size = 0;
+               } else {
+                       key->key_size = priv->sec.key_sizes[i];
+                       memcpy(key->key, priv->sec.keys[i], key->key_size);
+               }
+
+               if (ipw_send_cmd(priv, &cmd)) {
+                       IPW_ERROR("failed to send WEP_KEY command\n");
+                       return;
+               }
+       }
+}
+
+static void ipw_adhoc_check(void *data)
+{
+       struct ipw_priv *priv = data;
+
+       if (priv->missed_adhoc_beacons++ > priv->missed_beacon_threshold &&
+           !(priv->config & CFG_ADHOC_PERSIST)) {
+               IPW_DEBUG_SCAN("Disassociating due to missed beacons\n");
+               ipw_remove_current_network(priv);
+               ipw_disassociate(priv);
+               return;
+       }
+
+       queue_delayed_work(priv->workqueue, &priv->adhoc_check,
+                          priv->assoc_request.beacon_interval);
+}
+
+#ifdef CONFIG_IPW_DEBUG
+static void ipw_debug_config(struct ipw_priv *priv)
+{
+       IPW_DEBUG_INFO("Scan completed, no valid APs matched "
+                      "[CFG 0x%08X]\n", priv->config);
+       if (priv->config & CFG_STATIC_CHANNEL)
+               IPW_DEBUG_INFO("Channel locked to %d\n",
+                              priv->channel);
+       else
+               IPW_DEBUG_INFO("Channel unlocked.\n");
+       if (priv->config & CFG_STATIC_ESSID)
+               IPW_DEBUG_INFO("ESSID locked to '%s'\n",
+                              escape_essid(priv->essid,
+                                           priv->essid_len));
+       else
+               IPW_DEBUG_INFO("ESSID unlocked.\n");
+       if (priv->config & CFG_STATIC_BSSID)
+               IPW_DEBUG_INFO("BSSID locked to %d\n", priv->channel);
+       else
+               IPW_DEBUG_INFO("BSSID unlocked.\n");
+       if (priv->capability & CAP_PRIVACY_ON)
+               IPW_DEBUG_INFO("PRIVACY on\n");
+       else
+               IPW_DEBUG_INFO("PRIVACY off\n");
+       IPW_DEBUG_INFO("RATE MASK: 0x%08X\n", priv->rates_mask);
+}
+#else
+#define ipw_debug_config(x) do {} while (0)
+#endif
+
+static inline void ipw_set_fixed_rate(struct ipw_priv *priv,
+                                     struct ieee80211_network *network)
+{
+       /* TODO: Verify that this works... */
+       struct ipw_fixed_rate fr = {
+               .tx_rates = priv->rates_mask
+       };
+       u32 reg;
+       u16 mask = 0;
+
+       /* Identify 'current FW band' and match it with the fixed
+        * Tx rates */
+
+       switch (priv->ieee->freq_band) {
+       case IEEE80211_52GHZ_BAND: /* A only */
+               /* IEEE_A */
+               if (priv->rates_mask & ~IEEE80211_OFDM_RATES_MASK) {
+                       /* Invalid fixed rate mask */
+                       fr.tx_rates = 0;
+                       break;
+               }
+
+               fr.tx_rates >>= IEEE80211_OFDM_SHIFT_MASK_A;
+               break;
+
+       default: /* 2.4Ghz or Mixed */
+               /* IEEE_B */
+               if (network->mode == IEEE_B) {
+                       if (fr.tx_rates & ~IEEE80211_CCK_RATES_MASK) {
+                               /* Invalid fixed rate mask */
+                               fr.tx_rates = 0;
+                       }
+                       break;
+               }
+
+               /* IEEE_G */
+               if (fr.tx_rates & ~(IEEE80211_CCK_RATES_MASK |
+                                   IEEE80211_OFDM_RATES_MASK)) {
+                       /* Invalid fixed rate mask */
+                       fr.tx_rates = 0;
+                       break;
+               }
+
+               if (IEEE80211_OFDM_RATE_6MB_MASK & fr.tx_rates) {
+                       mask |= (IEEE80211_OFDM_RATE_6MB_MASK >> 1);
+                       fr.tx_rates &= ~IEEE80211_OFDM_RATE_6MB_MASK;
+               }
+
+               if (IEEE80211_OFDM_RATE_9MB_MASK & fr.tx_rates) {
+                       mask |= (IEEE80211_OFDM_RATE_9MB_MASK >> 1);
+                       fr.tx_rates &= ~IEEE80211_OFDM_RATE_9MB_MASK;
+               }
+
+               if (IEEE80211_OFDM_RATE_12MB_MASK & fr.tx_rates) {
+                       mask |= (IEEE80211_OFDM_RATE_12MB_MASK >> 1);
+                       fr.tx_rates &= ~IEEE80211_OFDM_RATE_12MB_MASK;
+               }
+
+               fr.tx_rates |= mask;
+               break;
+       }
+
+       reg = ipw_read32(priv, IPW_MEM_FIXED_OVERRIDE);
+       ipw_write_reg32(priv, reg, *(u32*)&fr);
+}
+
+static int ipw_associate_network(struct ipw_priv *priv,
+                                struct ieee80211_network *network,
+                                struct ipw_supported_rates *rates,
+                                int roaming)
+{
+       int err;
+
+       if (priv->config & CFG_FIXED_RATE)
+               ipw_set_fixed_rate(priv, network);
+
+       if (!(priv->config & CFG_STATIC_ESSID)) {
+               priv->essid_len = min(network->ssid_len,
+                                     (u8)IW_ESSID_MAX_SIZE);
+               memcpy(priv->essid, network->ssid, priv->essid_len);
+       }
+
+       network->last_associate = jiffies;
+
+       memset(&priv->assoc_request, 0, sizeof(priv->assoc_request));
+       priv->assoc_request.channel = network->channel;
+       if ((priv->capability & CAP_PRIVACY_ON) &&
+           (priv->capability & CAP_SHARED_KEY)) {
+               priv->assoc_request.auth_type = AUTH_SHARED_KEY;
+               priv->assoc_request.auth_key = priv->sec.active_key;
+       } else {
+               priv->assoc_request.auth_type = AUTH_OPEN;
+               priv->assoc_request.auth_key = 0;
+       }
+
+       if (priv->capability & CAP_PRIVACY_ON)
+               ipw_send_wep_keys(priv);
+
+       /*
+        * It is valid for our ieee device to support multiple modes, but
+        * when it comes to associating to a given network we have to choose
+        * just one mode.
+        */
+       if (network->mode & priv->ieee->mode & IEEE_A)
+               priv->assoc_request.ieee_mode = IPW_A_MODE;
+       else if (network->mode & priv->ieee->mode & IEEE_G)
+               priv->assoc_request.ieee_mode = IPW_G_MODE;
+       else if (network->mode & priv->ieee->mode & IEEE_B)
+               priv->assoc_request.ieee_mode = IPW_B_MODE;
+
+       IPW_DEBUG_ASSOC("%sssocation attempt: '%s', channel %d, "
+                       "802.11%c [%d], enc=%s%s%s%c%c\n",
+                       roaming ? "Rea" : "A",
+                       escape_essid(priv->essid, priv->essid_len),
+                       network->channel,
+                       ipw_modes[priv->assoc_request.ieee_mode],
+                       rates->num_rates,
+                       priv->capability & CAP_PRIVACY_ON ? "on " : "off",
+                       priv->capability & CAP_PRIVACY_ON ?
+                       (priv->capability & CAP_SHARED_KEY ? "(shared)" :
+                        "(open)") : "",
+                       priv->capability & CAP_PRIVACY_ON ? " key=" : "",
+                       priv->capability & CAP_PRIVACY_ON ?
+                       '1' + priv->sec.active_key : '.',
+                       priv->capability & CAP_PRIVACY_ON ?
+                       '.' : ' ');
+
+       priv->assoc_request.beacon_interval = network->beacon_interval;
+       if ((priv->ieee->iw_mode == IW_MODE_ADHOC) &&
+           (network->time_stamp[0] == 0) &&
+           (network->time_stamp[1] == 0)) {
+               priv->assoc_request.assoc_type = HC_IBSS_START;
+               priv->assoc_request.assoc_tsf_msw = 0;
+               priv->assoc_request.assoc_tsf_lsw = 0;
+       } else {
+               if (unlikely(roaming))
+                       priv->assoc_request.assoc_type = HC_REASSOCIATE;
+               else
+                       priv->assoc_request.assoc_type = HC_ASSOCIATE;
+               priv->assoc_request.assoc_tsf_msw = network->time_stamp[1];
+               priv->assoc_request.assoc_tsf_lsw = network->time_stamp[0];
+       }
+
+       memcpy(&priv->assoc_request.bssid, network->bssid, ETH_ALEN);
+
+       if (priv->ieee->iw_mode == IW_MODE_ADHOC) {
+               memset(&priv->assoc_request.dest, 0xFF, ETH_ALEN);
+               priv->assoc_request.atim_window = network->atim_window;
+       } else {
+               memcpy(&priv->assoc_request.dest, network->bssid,
+                      ETH_ALEN);
+               priv->assoc_request.atim_window = 0;
+       }
+
+       priv->assoc_request.capability = network->capability;
+       priv->assoc_request.listen_interval = network->listen_interval;
+
+       err = ipw_send_ssid(priv, priv->essid, priv->essid_len);
+       if (err) {
+               IPW_DEBUG_HC("Attempt to send SSID command failed.\n");
+               return err;
+       }
+
+       rates->ieee_mode = priv->assoc_request.ieee_mode;
+       rates->purpose = IPW_RATE_CONNECT;
+       ipw_send_supported_rates(priv, rates);
+
+       if (priv->assoc_request.ieee_mode == IPW_G_MODE)
+               priv->sys_config.dot11g_auto_detection = 1;
+       else
+               priv->sys_config.dot11g_auto_detection = 0;
+       err = ipw_send_system_config(priv, &priv->sys_config);
+       if (err) {
+               IPW_DEBUG_HC("Attempt to send sys config command failed.\n");
+               return err;
+       }
+
+       IPW_DEBUG_ASSOC("Association sensitivity: %d\n", network->stats.rssi);
+       err = ipw_set_sensitivity(priv, network->stats.rssi);
+       if (err) {
+               IPW_DEBUG_HC("Attempt to send associate command failed.\n");
+               return err;
+       }
+
+       /*
+        * If preemption is enabled, it is possible for the association
+        * to complete before we return from ipw_send_associate.  Therefore
+        * we have to be sure and update our priviate data first.
+        */
+       priv->channel = network->channel;
+       memcpy(priv->bssid, network->bssid, ETH_ALEN);
+       priv->status |= STATUS_ASSOCIATING;
+       priv->status &= ~STATUS_SECURITY_UPDATED;
+
+       priv->assoc_network = network;
+
+       err = ipw_send_associate(priv, &priv->assoc_request);
+       if (err) {
+               IPW_DEBUG_HC("Attempt to send associate command failed.\n");
+               return err;
+       }
+
+       IPW_DEBUG(IPW_DL_STATE, "associating: '%s' " MAC_FMT " \n",
+                 escape_essid(priv->essid, priv->essid_len),
+                 MAC_ARG(priv->bssid));
+
+       return 0;
+}
+
+static void ipw_roam(void *data)
+{
+       struct ipw_priv *priv = data;
+       struct ieee80211_network *network = NULL;
+       struct ipw_network_match match = {
+               .network = priv->assoc_network
+       };
+
+       /* The roaming process is as follows:
+        *
+        * 1.  Missed beacon threshold triggers the roaming process by
+        *     setting the status ROAM bit and requesting a scan.
+        * 2.  When the scan completes, it schedules the ROAM work
+        * 3.  The ROAM work looks at all of the known networks for one that
+        *     is a better network than the currently associated.  If none
+        *     found, the ROAM process is over (ROAM bit cleared)
+        * 4.  If a better network is found, a disassociation request is
+        *     sent.
+        * 5.  When the disassociation completes, the roam work is again
+        *     scheduled.  The second time through, the driver is no longer
+        *     associated, and the newly selected network is sent an
+        *     association request.
+        * 6.  At this point ,the roaming process is complete and the ROAM
+        *     status bit is cleared.
+        */
+
+       /* If we are no longer associated, and the roaming bit is no longer
+        * set, then we are not actively roaming, so just return */
+       if (!(priv->status & (STATUS_ASSOCIATED | STATUS_ROAMING)))
+               return;
+
+       if (priv->status & STATUS_ASSOCIATED) {
+               /* First pass through ROAM process -- look for a better
+                * network */
+               u8 rssi = priv->assoc_network->stats.rssi;
+               priv->assoc_network->stats.rssi = -128;
+               list_for_each_entry(network, &priv->ieee->network_list, list) {
+                       if (network != priv->assoc_network)
+                               ipw_best_network(priv, &match, network, 1);
+               }
+               priv->assoc_network->stats.rssi = rssi;
+
+               if (match.network == priv->assoc_network) {
+                       IPW_DEBUG_ASSOC("No better APs in this network to "
+                                       "roam to.\n");
+                       priv->status &= ~STATUS_ROAMING;
+                       ipw_debug_config(priv);
+                       return;
+               }
+
+               ipw_send_disassociate(priv, 1);
+               priv->assoc_network = match.network;
+
+               return;
+       }
+
+       /* Second pass through ROAM process -- request association */
+       ipw_compatible_rates(priv, priv->assoc_network, &match.rates);
+       ipw_associate_network(priv, priv->assoc_network, &match.rates, 1);
+       priv->status &= ~STATUS_ROAMING;
+}
+
+static void ipw_associate(void *data)
+{
+       struct ipw_priv *priv = data;
+
+       struct ieee80211_network *network = NULL;
+       struct ipw_network_match match = {
+               .network = NULL
+       };
+       struct ipw_supported_rates *rates;
+       struct list_head *element;
+
+       if (!(priv->config & CFG_ASSOCIATE) &&
+           !(priv->config & (CFG_STATIC_ESSID |
+                             CFG_STATIC_CHANNEL |
+                             CFG_STATIC_BSSID))) {
+               IPW_DEBUG_ASSOC("Not attempting association (associate=0)\n");
+               return;
+       }
+
+       list_for_each_entry(network, &priv->ieee->network_list, list)
+               ipw_best_network(priv, &match, network, 0);
+
+       network = match.network;
+       rates = &match.rates;
+
+       if (network == NULL &&
+           priv->ieee->iw_mode == IW_MODE_ADHOC &&
+           priv->config & CFG_ADHOC_CREATE &&
+           priv->config & CFG_STATIC_ESSID &&
+           !list_empty(&priv->ieee->network_free_list)) {
+               element = priv->ieee->network_free_list.next;
+               network = list_entry(element, struct ieee80211_network,
+                                    list);
+               ipw_adhoc_create(priv, network);
+               rates = &priv->rates;
+               list_del(element);
+               list_add_tail(&network->list, &priv->ieee->network_list);
+       }
+
+       /* If we reached the end of the list, then we don't have any valid
+        * matching APs */
+       if (!network) {
+               ipw_debug_config(priv);
+
+               queue_delayed_work(priv->workqueue, &priv->request_scan,
+                                  SCAN_INTERVAL);
+
+               return;
+       }
+
+       ipw_associate_network(priv, network, rates, 0);
+}
+
+static inline void ipw_handle_data_packet(struct ipw_priv *priv,
+                                             struct ipw_rx_mem_buffer *rxb,
+                                             struct ieee80211_rx_stats *stats)
+{
+       struct ipw_rx_packet *pkt = (struct ipw_rx_packet *)rxb->skb->data;
+
+       /* We received data from the HW, so stop the watchdog */
+       priv->net_dev->trans_start = jiffies;
+
+       /* We only process data packets if the
+        * interface is open */
+       if (unlikely((pkt->u.frame.length + IPW_RX_FRAME_SIZE) >
+                    skb_tailroom(rxb->skb))) {
+               priv->ieee->stats.rx_errors++;
+               priv->wstats.discard.misc++;
+               IPW_DEBUG_DROP("Corruption detected! Oh no!\n");
+               return;
+       } else if (unlikely(!netif_running(priv->net_dev))) {
+               priv->ieee->stats.rx_dropped++;
+               priv->wstats.discard.misc++;
+               IPW_DEBUG_DROP("Dropping packet while interface is not up.\n");
+               return;
+       }
+
+       /* Advance skb->data to the start of the actual payload */
+       skb_reserve(rxb->skb, offsetof(struct ipw_rx_packet, u.frame.data));
+
+       /* Set the size of the skb to the size of the frame */
+       skb_put(rxb->skb, pkt->u.frame.length);
+
+       IPW_DEBUG_RX("Rx packet of %d bytes.\n", rxb->skb->len);
+
+       if (!ieee80211_rx(priv->ieee, rxb->skb, stats))
+               priv->ieee->stats.rx_errors++;
+       else /* ieee80211_rx succeeded, so it now owns the SKB */
+               rxb->skb = NULL;
+}
+
+
+/*
+ * Main entry function for recieving a packet with 80211 headers.  This
+ * should be called when ever the FW has notified us that there is a new
+ * skb in the recieve queue.
+ */
+static void ipw_rx(struct ipw_priv *priv)
+{
+       struct ipw_rx_mem_buffer *rxb;
+       struct ipw_rx_packet *pkt;
+       struct ieee80211_hdr *header;
+       u32 r, w, i;
+       u8 network_packet;
+
+       r = ipw_read32(priv, CX2_RX_READ_INDEX);
+       w = ipw_read32(priv, CX2_RX_WRITE_INDEX);
+       i = (priv->rxq->processed + 1) % RX_QUEUE_SIZE;
+
+       while (i != r) {
+               rxb = priv->rxq->queue[i];
+#ifdef CONFIG_IPW_DEBUG
+               if (unlikely(rxb == NULL)) {
+                       printk(KERN_CRIT "Queue not allocated!\n");
+                       break;
+               }
+#endif
+               priv->rxq->queue[i] = NULL;
+
+               pci_dma_sync_single_for_cpu(priv->pci_dev, rxb->dma_addr,
+                                           CX2_RX_BUF_SIZE,
+                                           PCI_DMA_FROMDEVICE);
+
+               pkt = (struct ipw_rx_packet *)rxb->skb->data;
+               IPW_DEBUG_RX("Packet: type=%02X seq=%02X bits=%02X\n",
+                            pkt->header.message_type,
+                            pkt->header.rx_seq_num,
+                            pkt->header.control_bits);
+
+               switch (pkt->header.message_type) {
+               case RX_FRAME_TYPE: /* 802.11 frame */ {
+                       struct ieee80211_rx_stats stats = {
+                               .rssi = pkt->u.frame.rssi_dbm -
+                               IPW_RSSI_TO_DBM,
+                               .signal = pkt->u.frame.signal,
+                               .rate = pkt->u.frame.rate,
+                               .mac_time = jiffies,
+                               .received_channel =
+                               pkt->u.frame.received_channel,
+                               .freq = (pkt->u.frame.control & (1<<0)) ?
+                               IEEE80211_24GHZ_BAND : IEEE80211_52GHZ_BAND,
+                               .len = pkt->u.frame.length,
+                       };
+
+                       if (stats.rssi != 0)
+                               stats.mask |= IEEE80211_STATMASK_RSSI;
+                       if (stats.signal != 0)
+                               stats.mask |= IEEE80211_STATMASK_SIGNAL;
+                       if (stats.rate != 0)
+                               stats.mask |= IEEE80211_STATMASK_RATE;
+
+                       priv->rx_packets++;
+
+#ifdef CONFIG_IPW_PROMISC
+                       if (priv->ieee->iw_mode == IW_MODE_MONITOR) {
+                               ipw_handle_data_packet(priv, rxb, &stats);
+                               break;
+                       }
+#endif
+
+                       header = (struct ieee80211_hdr *)(rxb->skb->data +
+                                                         IPW_RX_FRAME_SIZE);
+                               /* TODO: Check Ad-Hoc dest/source and make sure
+                                * that we are actually parsing these packets
+                                * correctly -- we should probably use the
+                                * frame control of the packet and disregard
+                                * the current iw_mode */
+                       switch (priv->ieee->iw_mode) {
+                       case IW_MODE_ADHOC:
+                               network_packet =
+                                       !memcmp(header->addr1,
+                                               priv->net_dev->dev_addr,
+                                               ETH_ALEN) ||
+                                       !memcmp(header->addr3,
+                                               priv->bssid, ETH_ALEN) ||
+                                       is_broadcast_ether_addr(header->addr1) ||
+                                       is_multicast_ether_addr(header->addr1);
+                               break;
+
+                       case IW_MODE_INFRA:
+                       default:
+                               network_packet =
+                                       !memcmp(header->addr3,
+                                               priv->bssid, ETH_ALEN) ||
+                                       !memcmp(header->addr1,
+                                               priv->net_dev->dev_addr,
+                                               ETH_ALEN) ||
+                                       is_broadcast_ether_addr(header->addr1) ||
+                                       is_multicast_ether_addr(header->addr1);
+                               break;
+                       }
+
+                       if (network_packet && priv->assoc_network) {
+                               priv->assoc_network->stats.rssi = stats.rssi;
+                               average_add(&priv->average_rssi,
+                                           stats.rssi);
+                               priv->last_rx_rssi = stats.rssi;
+                       }
+
+                       IPW_DEBUG_RX("Frame: len=%u\n", pkt->u.frame.length);
+
+                       if (pkt->u.frame.length < frame_hdr_len(header)) {
+                               IPW_DEBUG_DROP("Received packet is too small. "
+                                              "Dropping.\n");
+                               priv->ieee->stats.rx_errors++;
+                               priv->wstats.discard.misc++;
+                               break;
+                       }
+
+                       switch (WLAN_FC_GET_TYPE(header->frame_ctl)) {
+                       case IEEE80211_FTYPE_MGMT:
+                               ieee80211_rx_mgt(priv->ieee, header, &stats);
+                               if (priv->ieee->iw_mode == IW_MODE_ADHOC &&
+                                   ((WLAN_FC_GET_STYPE(header->frame_ctl) ==
+                                     IEEE80211_STYPE_PROBE_RESP) ||
+                                    (WLAN_FC_GET_STYPE(header->frame_ctl) ==
+                                     IEEE80211_STYPE_BEACON)) &&
+                                   !memcmp(header->addr3, priv->bssid, ETH_ALEN))
+                                       ipw_add_station(priv, header->addr2);
+                               break;
+
+                       case IEEE80211_FTYPE_CTL:
+                               break;
+
+                       case IEEE80211_FTYPE_DATA:
+                               if (network_packet)
+                                       ipw_handle_data_packet(priv, rxb, &stats);
+                               else
+                                       IPW_DEBUG_DROP("Dropping: " MAC_FMT
+                                                      ", " MAC_FMT ", " MAC_FMT "\n",
+                                                      MAC_ARG(header->addr1), MAC_ARG(header->addr2),
+                                                      MAC_ARG(header->addr3));
+                               break;
+                       }
+                       break;
+               }
+
+               case RX_HOST_NOTIFICATION_TYPE: {
+                       IPW_DEBUG_RX("Notification: subtype=%02X flags=%02X size=%d\n",
+                                    pkt->u.notification.subtype,
+                                    pkt->u.notification.flags,
+                                    pkt->u.notification.size);
+                       ipw_rx_notification(priv, &pkt->u.notification);
+                       break;
+               }
+
+               default:
+                       IPW_DEBUG_RX("Bad Rx packet of type %d\n",
+                                    pkt->header.message_type);
+                       break;
+               }
+
+               /* For now we just don't re-use anything.  We can tweak this
+                * later to try and re-use notification packets and SKBs that
+                * fail to Rx correctly */
+               if (rxb->skb != NULL) {
+                       dev_kfree_skb_any(rxb->skb);
+                       rxb->skb = NULL;
+               }
+
+               pci_unmap_single(priv->pci_dev, rxb->dma_addr,
+                                CX2_RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
+               list_add_tail(&rxb->list, &priv->rxq->rx_used);
+
+               i = (i + 1) % RX_QUEUE_SIZE;
+       }
+
+       /* Backtrack one entry */
+       priv->rxq->processed = (i ? i : RX_QUEUE_SIZE) - 1;
+
+       ipw_rx_queue_restock(priv);
+}
+
+static void ipw_abort_scan(struct ipw_priv *priv)
+{
+       int err;
+
+       if (priv->status & STATUS_SCAN_ABORTING) {
+               IPW_DEBUG_HC("Ignoring concurrent scan abort request.\n");
+               return;
+       }
+       priv->status |= STATUS_SCAN_ABORTING;
+
+       err = ipw_send_scan_abort(priv);
+       if (err)
+               IPW_DEBUG_HC("Request to abort scan failed.\n");
+}
+
+static int ipw_request_scan(struct ipw_priv *priv)
+{
+       struct ipw_scan_request_ext scan;
+       int channel_index = 0;
+       int i, err, scan_type;
+
+       if (priv->status & STATUS_EXIT_PENDING) {
+               IPW_DEBUG_SCAN("Aborting scan due to device shutdown\n");
+               priv->status |= STATUS_SCAN_PENDING;
+               return 0;
+       }
+
+       if (priv->status & STATUS_SCANNING) {
+               IPW_DEBUG_HC("Concurrent scan requested.  Aborting first.\n");
+               priv->status |= STATUS_SCAN_PENDING;
+               ipw_abort_scan(priv);
+               return 0;
+       }
+
+       if (priv->status & STATUS_SCAN_ABORTING) {
+               IPW_DEBUG_HC("Scan request while abort pending.  Queuing.\n");
+               priv->status |= STATUS_SCAN_PENDING;
+               return 0;
+       }
+
+       if (priv->status & STATUS_RF_KILL_MASK) {
+               IPW_DEBUG_HC("Aborting scan due to RF Kill activation\n");
+               priv->status |= STATUS_SCAN_PENDING;
+               return 0;
+       }
+
+       memset(&scan, 0, sizeof(scan));
+
+       scan.dwell_time[IPW_SCAN_ACTIVE_BROADCAST_SCAN] = 20;
+       scan.dwell_time[IPW_SCAN_ACTIVE_BROADCAST_AND_DIRECT_SCAN] = 20;
+       scan.dwell_time[IPW_SCAN_PASSIVE_FULL_DWELL_SCAN] = 20;
+
+       scan.full_scan_index = ieee80211_get_scans(priv->ieee);
+       /* If we are roaming, then make this a directed scan for the current
+        * network.  Otherwise, ensure that every other scan is a fast
+        * channel hop scan */
+       if ((priv->status & STATUS_ROAMING) || (
+                   !(priv->status & STATUS_ASSOCIATED) &&
+                   (priv->config & CFG_STATIC_ESSID) &&
+                   (scan.full_scan_index % 2))) {
+               err = ipw_send_ssid(priv, priv->essid, priv->essid_len);
+               if (err) {
+                       IPW_DEBUG_HC("Attempt to send SSID command failed.\n");
+                       return err;
+               }
+
+               scan_type = IPW_SCAN_ACTIVE_BROADCAST_AND_DIRECT_SCAN;
+       } else {
+               scan_type = IPW_SCAN_ACTIVE_BROADCAST_SCAN;
+       }
+
+        if (priv->ieee->freq_band & IEEE80211_52GHZ_BAND) {
+               int start = channel_index;
+               for (i = 0; i < MAX_A_CHANNELS; i++) {
+                       if (band_a_active_channel[i] == 0)
+                               break;
+                       if ((priv->status & STATUS_ASSOCIATED) &&
+                           band_a_active_channel[i] == priv->channel)
+                               continue;
+                       channel_index++;
+                       scan.channels_list[channel_index] =
+                               band_a_active_channel[i];
+                       ipw_set_scan_type(&scan, channel_index, scan_type);
+               }
+
+               if (start != channel_index) {
+                       scan.channels_list[start] = (u8)(IPW_A_MODE << 6) |
+                               (channel_index - start);
+                       channel_index++;
+               }
+       }
+
+        if (priv->ieee->freq_band & IEEE80211_24GHZ_BAND) {
+               int start = channel_index;
+               for (i = 0; i < MAX_B_CHANNELS; i++) {
+                       if (band_b_active_channel[i] == 0)
+                               break;
+                       if ((priv->status & STATUS_ASSOCIATED) &&
+                           band_b_active_channel[i] == priv->channel)
+                               continue;
+                       channel_index++;
+                       scan.channels_list[channel_index] =
+                               band_b_active_channel[i];
+                       ipw_set_scan_type(&scan, channel_index, scan_type);
+               }
+
+               if (start != channel_index) {
+                       scan.channels_list[start] = (u8)(IPW_B_MODE << 6) |
+                               (channel_index - start);
+               }
+       }
+
+       err = ipw_send_scan_request_ext(priv, &scan);
+       if (err) {
+               IPW_DEBUG_HC("Sending scan command failed: %08X\n",
+                            err);
+               return -EIO;
+       }
+
+       priv->status |= STATUS_SCANNING;
+       priv->status &= ~STATUS_SCAN_PENDING;
+
+       return 0;
+}
+
+/*
+ * This file defines the Wireless Extension handlers.  It does not
+ * define any methods of hardware manipulation and relies on the
+ * functions defined in ipw_main to provide the HW interaction.
+ *
+ * The exception to this is the use of the ipw_get_ordinal()
+ * function used to poll the hardware vs. making unecessary calls.
+ *
+ */
+
+static int ipw_wx_get_name(struct net_device *dev,
+                          struct iw_request_info *info,
+                          union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       if (!(priv->status & STATUS_ASSOCIATED))
+               strcpy(wrqu->name, "unassociated");
+       else
+               snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11%c",
+                        ipw_modes[priv->assoc_request.ieee_mode]);
+       IPW_DEBUG_WX("Name: %s\n", wrqu->name);
+       return 0;
+}
+
+static int ipw_set_channel(struct ipw_priv *priv, u8 channel)
+{
+       if (channel == 0) {
+               IPW_DEBUG_INFO("Setting channel to ANY (0)\n");
+               priv->config &= ~CFG_STATIC_CHANNEL;
+               if (!(priv->status & (STATUS_SCANNING | STATUS_ASSOCIATED |
+                                     STATUS_ASSOCIATING))) {
+                       IPW_DEBUG_ASSOC("Attempting to associate with new "
+                                       "parameters.\n");
+                       ipw_associate(priv);
+               }
+
+               return 0;
+       }
+
+       priv->config |= CFG_STATIC_CHANNEL;
+
+       if (priv->channel == channel) {
+               IPW_DEBUG_INFO(
+                       "Request to set channel to current value (%d)\n",
+                       channel);
+               return 0;
+       }
+
+       IPW_DEBUG_INFO("Setting channel to %i\n", (int)channel);
+       priv->channel = channel;
+
+       /* If we are currently associated, or trying to associate
+        * then see if this is a new channel (causing us to disassociate) */
+       if (priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) {
+               IPW_DEBUG_ASSOC("Disassociating due to channel change.\n");
+               ipw_disassociate(priv);
+       } else {
+               ipw_associate(priv);
+       }
+
+       return 0;
+}
+
+static int ipw_wx_set_freq(struct net_device *dev,
+                          struct iw_request_info *info,
+                          union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       struct iw_freq *fwrq = &wrqu->freq;
+
+       /* if setting by freq convert to channel */
+       if (fwrq->e == 1) {
+               if ((fwrq->m >= (int) 2.412e8 &&
+                    fwrq->m <= (int) 2.487e8)) {
+                       int f = fwrq->m / 100000;
+                       int c = 0;
+
+                       while ((c < REG_MAX_CHANNEL) &&
+                              (f != ipw_frequencies[c]))
+                               c++;
+
+                       /* hack to fall through */
+                       fwrq->e = 0;
+                       fwrq->m = c + 1;
+               }
+       }
+
+       if (fwrq->e > 0 || fwrq->m > 1000)
+               return -EOPNOTSUPP;
+
+       IPW_DEBUG_WX("SET Freq/Channel -> %d \n", fwrq->m);
+       return ipw_set_channel(priv, (u8)fwrq->m);
+
+       return 0;
+}
+
+
+static int ipw_wx_get_freq(struct net_device *dev,
+                          struct iw_request_info *info,
+                          union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+
+       wrqu->freq.e = 0;
+
+       /* If we are associated, trying to associate, or have a statically
+        * configured CHANNEL then return that; otherwise return ANY */
+       if (priv->config & CFG_STATIC_CHANNEL ||
+           priv->status & (STATUS_ASSOCIATING | STATUS_ASSOCIATED))
+               wrqu->freq.m = priv->channel;
+       else
+               wrqu->freq.m = 0;
+
+       IPW_DEBUG_WX("GET Freq/Channel -> %d \n", priv->channel);
+       return 0;
+}
+
+static int ipw_wx_set_mode(struct net_device *dev,
+                          struct iw_request_info *info,
+                          union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       int err = 0;
+
+       IPW_DEBUG_WX("Set MODE: %d\n", wrqu->mode);
+
+       if (wrqu->mode == priv->ieee->iw_mode)
+               return 0;
+
+       switch (wrqu->mode) {
+#ifdef CONFIG_IPW_PROMISC
+       case IW_MODE_MONITOR:
+#endif
+       case IW_MODE_ADHOC:
+       case IW_MODE_INFRA:
+               break;
+       case IW_MODE_AUTO:
+               wrqu->mode = IW_MODE_INFRA;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+#ifdef CONFIG_IPW_PROMISC
+       if (priv->ieee->iw_mode == IW_MODE_MONITOR)
+               priv->net_dev->type = ARPHRD_ETHER;
+
+       if (wrqu->mode == IW_MODE_MONITOR)
+               priv->net_dev->type = ARPHRD_IEEE80211;
+#endif /* CONFIG_IPW_PROMISC */
+
+#ifdef CONFIG_PM
+       /* Free the existing firmware and reset the fw_loaded
+        * flag so ipw_load() will bring in the new firmawre */
+       if (fw_loaded) {
+               fw_loaded = 0;
+       }
+
+       release_firmware(bootfw);
+       release_firmware(ucode);
+       release_firmware(firmware);
+       bootfw = ucode = firmware = NULL;
+#endif
+
+       priv->ieee->iw_mode = wrqu->mode;
+       ipw_adapter_restart(priv);
+
+       return err;
+}
+
+static int ipw_wx_get_mode(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+
+       wrqu->mode = priv->ieee->iw_mode;
+       IPW_DEBUG_WX("Get MODE -> %d\n", wrqu->mode);
+
+       return 0;
+}
+
+
+#define DEFAULT_RTS_THRESHOLD     2304U
+#define MIN_RTS_THRESHOLD         1U
+#define MAX_RTS_THRESHOLD         2304U
+#define DEFAULT_BEACON_INTERVAL   100U
+#define        DEFAULT_SHORT_RETRY_LIMIT 7U
+#define        DEFAULT_LONG_RETRY_LIMIT  4U
+
+/* Values are in microsecond */
+static const s32 timeout_duration[] = {
+       350000,
+       250000,
+       75000,
+       37000,
+       25000,
+};
+
+static const s32 period_duration[] = {
+       400000,
+       700000,
+       1000000,
+       1000000,
+       1000000
+};
+
+static int ipw_wx_get_range(struct net_device *dev,
+                           struct iw_request_info *info,
+                           union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       struct iw_range *range = (struct iw_range *)extra;
+       u16 val;
+       int i;
+
+       wrqu->data.length = sizeof(*range);
+       memset(range, 0, sizeof(*range));
+
+       /* 54Mbs == ~27 Mb/s real (802.11g) */
+       range->throughput = 27 * 1000 * 1000;
+
+       range->max_qual.qual = 100;
+       /* TODO: Find real max RSSI and stick here */
+       range->max_qual.level = 0;
+       range->max_qual.noise = 0;
+       range->max_qual.updated = 7; /* Updated all three */
+
+       range->avg_qual.qual = 70;
+       /* TODO: Find real 'good' to 'bad' threshol value for RSSI */
+       range->avg_qual.level = 0; /* FIXME to real average level */
+       range->avg_qual.noise = 0;
+       range->avg_qual.updated = 7; /* Updated all three */
+
+       range->num_bitrates = min(priv->rates.num_rates, (u8)IW_MAX_BITRATES);
+
+       for (i = 0; i < range->num_bitrates; i++)
+               range->bitrate[i] = (priv->rates.supported_rates[i] & 0x7F) *
+                       500000;
+
+       range->max_rts = DEFAULT_RTS_THRESHOLD;
+       range->min_frag = MIN_FRAG_THRESHOLD;
+       range->max_frag = MAX_FRAG_THRESHOLD;
+
+       range->encoding_size[0] = 5;
+       range->encoding_size[1] = 13;
+       range->num_encoding_sizes = 2;
+       range->max_encoding_tokens = WEP_KEYS;
+
+       /* Set the Wireless Extension versions */
+       range->we_version_compiled = WIRELESS_EXT;
+       range->we_version_source = 16;
+
+        range->num_channels = FREQ_COUNT;
+
+       val = 0;
+       for (i = 0; i < FREQ_COUNT; i++) {
+               range->freq[val].i = i + 1;
+               range->freq[val].m = ipw_frequencies[i] * 100000;
+               range->freq[val].e = 1;
+               val++;
+
+               if (val == IW_MAX_FREQUENCIES)
+                       break;
+       }
+       range->num_frequency = val;
+
+       IPW_DEBUG_WX("GET Range\n");
+       return 0;
+}
+
+static int ipw_wx_set_wap(struct net_device *dev,
+                         struct iw_request_info *info,
+                         union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+
+       static const unsigned char any[] = {
+               0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+       };
+       static const unsigned char off[] = {
+               0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+       };
+
+       if (wrqu->ap_addr.sa_family != ARPHRD_ETHER)
+               return -EINVAL;
+
+       if (!memcmp(any, wrqu->ap_addr.sa_data, ETH_ALEN) ||
+           !memcmp(off, wrqu->ap_addr.sa_data, ETH_ALEN)) {
+               /* we disable mandatory BSSID association */
+               IPW_DEBUG_WX("Setting AP BSSID to ANY\n");
+               priv->config &= ~CFG_STATIC_BSSID;
+               if (!(priv->status & (STATUS_SCANNING | STATUS_ASSOCIATED |
+                                     STATUS_ASSOCIATING))) {
+                       IPW_DEBUG_ASSOC("Attempting to associate with new "
+                                       "parameters.\n");
+                       ipw_associate(priv);
+               }
+
+               return 0;
+       }
+
+       priv->config |= CFG_STATIC_BSSID;
+       if (!memcmp(priv->bssid, wrqu->ap_addr.sa_data, ETH_ALEN)) {
+               IPW_DEBUG_WX("BSSID set to current BSSID.\n");
+               return 0;
+       }
+
+       IPW_DEBUG_WX("Setting mandatory BSSID to " MAC_FMT "\n",
+                    MAC_ARG(wrqu->ap_addr.sa_data));
+
+       memcpy(priv->bssid, wrqu->ap_addr.sa_data, ETH_ALEN);
+
+       /* If we are currently associated, or trying to associate
+        * then see if this is a new BSSID (causing us to disassociate) */
+       if (priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) {
+               IPW_DEBUG_ASSOC("Disassociating due to BSSID change.\n");
+               ipw_disassociate(priv);
+       } else {
+               ipw_associate(priv);
+       }
+
+       return 0;
+}
+
+static int ipw_wx_get_wap(struct net_device *dev,
+                         struct iw_request_info *info,
+                         union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       /* If we are associated, trying to associate, or have a statically
+        * configured BSSID then return that; otherwise return ANY */
+       if (priv->config & CFG_STATIC_BSSID ||
+           priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) {
+               wrqu->ap_addr.sa_family = ARPHRD_ETHER;
+               memcpy(wrqu->ap_addr.sa_data, &priv->bssid, ETH_ALEN);
+       } else
+               memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
+
+       IPW_DEBUG_WX("Getting WAP BSSID: " MAC_FMT "\n",
+                    MAC_ARG(wrqu->ap_addr.sa_data));
+       return 0;
+}
+
+static int ipw_wx_set_essid(struct net_device *dev,
+                           struct iw_request_info *info,
+                           union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       char *essid = ""; /* ANY */
+       int length = 0;
+
+       if (wrqu->essid.flags && wrqu->essid.length) {
+               length = wrqu->essid.length - 1;
+               essid = extra;
+       }
+       if (length == 0) {
+               IPW_DEBUG_WX("Setting ESSID to ANY\n");
+               priv->config &= ~CFG_STATIC_ESSID;
+               if (!(priv->status & (STATUS_SCANNING | STATUS_ASSOCIATED |
+                                     STATUS_ASSOCIATING))) {
+                       IPW_DEBUG_ASSOC("Attempting to associate with new "
+                                       "parameters.\n");
+                       ipw_associate(priv);
+               }
+
+               return 0;
+       }
+
+       length = min(length, IW_ESSID_MAX_SIZE);
+
+       priv->config |= CFG_STATIC_ESSID;
+
+       if (priv->essid_len == length && !memcmp(priv->essid, extra, length)) {
+               IPW_DEBUG_WX("ESSID set to current ESSID.\n");
+               return 0;
+       }
+
+       IPW_DEBUG_WX("Setting ESSID: '%s' (%d)\n", escape_essid(essid, length),
+                    length);
+
+       priv->essid_len = length;
+       memcpy(priv->essid, essid, priv->essid_len);
+
+       /* If we are currently associated, or trying to associate
+        * then see if this is a new ESSID (causing us to disassociate) */
+       if (priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) {
+               IPW_DEBUG_ASSOC("Disassociating due to ESSID change.\n");
+               ipw_disassociate(priv);
+       } else {
+               ipw_associate(priv);
+       }
+
+       return 0;
+}
+
+static int ipw_wx_get_essid(struct net_device *dev,
+                           struct iw_request_info *info,
+                           union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+
+       /* If we are associated, trying to associate, or have a statically
+        * configured ESSID then return that; otherwise return ANY */
+       if (priv->config & CFG_STATIC_ESSID ||
+           priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) {
+               IPW_DEBUG_WX("Getting essid: '%s'\n",
+                            escape_essid(priv->essid, priv->essid_len));
+               memcpy(extra, priv->essid, priv->essid_len);
+               wrqu->essid.length = priv->essid_len;
+               wrqu->essid.flags = 1; /* active */
+       } else {
+               IPW_DEBUG_WX("Getting essid: ANY\n");
+               wrqu->essid.length = 0;
+               wrqu->essid.flags = 0; /* active */
+       }
+
+       return 0;
+}
+
+static int ipw_wx_set_nick(struct net_device *dev,
+                          struct iw_request_info *info,
+                          union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+
+       IPW_DEBUG_WX("Setting nick to '%s'\n", extra);
+       if (wrqu->data.length > IW_ESSID_MAX_SIZE)
+               return -E2BIG;
+
+       wrqu->data.length = min((size_t)wrqu->data.length, sizeof(priv->nick));
+       memset(priv->nick, 0, sizeof(priv->nick));
+       memcpy(priv->nick, extra,  wrqu->data.length);
+       IPW_DEBUG_TRACE("<<\n");
+       return 0;
+
+}
+
+
+static int ipw_wx_get_nick(struct net_device *dev,
+                          struct iw_request_info *info,
+                          union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       IPW_DEBUG_WX("Getting nick\n");
+       wrqu->data.length = strlen(priv->nick) + 1;
+       memcpy(extra, priv->nick, wrqu->data.length);
+       wrqu->data.flags = 1; /* active */
+       return 0;
+}
+
+
+static int ipw_wx_set_rate(struct net_device *dev,
+                          struct iw_request_info *info,
+                          union iwreq_data *wrqu, char *extra)
+{
+       IPW_DEBUG_WX("0x%p, 0x%p, 0x%p\n", dev, info, wrqu);
+       return -EOPNOTSUPP;
+}
+
+static int ipw_wx_get_rate(struct net_device *dev,
+                          struct iw_request_info *info,
+                          union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv * priv = ieee80211_priv(dev);
+       wrqu->bitrate.value = priv->last_rate;
+
+       IPW_DEBUG_WX("GET Rate -> %d \n", wrqu->bitrate.value);
+       return 0;
+}
+
+
+static int ipw_wx_set_rts(struct net_device *dev,
+                         struct iw_request_info *info,
+                         union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+
+       if (wrqu->rts.disabled)
+               priv->rts_threshold = DEFAULT_RTS_THRESHOLD;
+       else {
+               if (wrqu->rts.value < MIN_RTS_THRESHOLD ||
+                   wrqu->rts.value > MAX_RTS_THRESHOLD)
+                       return -EINVAL;
+
+               priv->rts_threshold = wrqu->rts.value;
+       }
+
+       ipw_send_rts_threshold(priv, priv->rts_threshold);
+       IPW_DEBUG_WX("SET RTS Threshold -> %d \n", priv->rts_threshold);
+       return 0;
+}
+
+static int ipw_wx_get_rts(struct net_device *dev,
+                         struct iw_request_info *info,
+                         union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       wrqu->rts.value = priv->rts_threshold;
+       wrqu->rts.fixed = 0;    /* no auto select */
+       wrqu->rts.disabled =
+               (wrqu->rts.value == DEFAULT_RTS_THRESHOLD);
+
+       IPW_DEBUG_WX("GET RTS Threshold -> %d \n", wrqu->rts.value);
+       return 0;
+}
+
+
+static int ipw_wx_set_txpow(struct net_device *dev,
+                           struct iw_request_info *info,
+                           union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       struct ipw_tx_power tx_power;
+       int i;
+
+       if (ipw_radio_kill_sw(priv, wrqu->power.disabled))
+               return -EINPROGRESS;
+
+       if (wrqu->power.flags != IW_TXPOW_DBM)
+               return -EINVAL;
+
+       if ((wrqu->power.value > 20) ||
+           (wrqu->power.value < -12))
+               return -EINVAL;
+
+       priv->tx_power = wrqu->power.value;
+
+       memset(&tx_power, 0, sizeof(tx_power));
+
+       /* configure device for 'G' band */
+       tx_power.ieee_mode = IPW_G_MODE;
+       tx_power.num_channels = 11;
+       for (i = 0; i < 11; i++) {
+               tx_power.channels_tx_power[i].channel_number = i + 1;
+               tx_power.channels_tx_power[i].tx_power = priv->tx_power;
+       }
+       if (ipw_send_tx_power(priv, &tx_power))
+               goto error;
+
+       /* configure device to also handle 'B' band */
+       tx_power.ieee_mode = IPW_B_MODE;
+       if (ipw_send_tx_power(priv, &tx_power))
+               goto error;
+
+       return 0;
+
+ error:
+       return -EIO;
+}
+
+
+static int ipw_wx_get_txpow(struct net_device *dev,
+                           struct iw_request_info *info,
+                           union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+
+       wrqu->power.value = priv->tx_power;
+       wrqu->power.fixed = 1;
+       wrqu->power.flags = IW_TXPOW_DBM;
+       wrqu->power.disabled = (priv->status & STATUS_RF_KILL_MASK) ? 1 : 0;
+
+       IPW_DEBUG_WX("GET TX Power -> %s %d \n",
+                    wrqu->power.disabled ? "ON" : "OFF",
+                    wrqu->power.value);
+
+       return 0;
+}
+
+static int ipw_wx_set_frag(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+
+       if (wrqu->frag.disabled)
+               priv->ieee->fts = DEFAULT_FTS;
+       else {
+               if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
+                   wrqu->frag.value > MAX_FRAG_THRESHOLD)
+                       return -EINVAL;
+
+               priv->ieee->fts = wrqu->frag.value & ~0x1;
+       }
+
+       ipw_send_frag_threshold(priv, wrqu->frag.value);
+       IPW_DEBUG_WX("SET Frag Threshold -> %d \n", wrqu->frag.value);
+       return 0;
+}
+
+static int ipw_wx_get_frag(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       wrqu->frag.value = priv->ieee->fts;
+       wrqu->frag.fixed = 0;   /* no auto select */
+       wrqu->frag.disabled =
+               (wrqu->frag.value == DEFAULT_FTS);
+
+       IPW_DEBUG_WX("GET Frag Threshold -> %d \n", wrqu->frag.value);
+
+       return 0;
+}
+
+static int ipw_wx_set_retry(struct net_device *dev,
+                           struct iw_request_info *info,
+                           union iwreq_data *wrqu, char *extra)
+{
+       IPW_DEBUG_WX("0x%p, 0x%p, 0x%p\n", dev, info, wrqu);
+       return -EOPNOTSUPP;
+}
+
+
+static int ipw_wx_get_retry(struct net_device *dev,
+                           struct iw_request_info *info,
+                           union iwreq_data *wrqu, char *extra)
+{
+       IPW_DEBUG_WX("0x%p, 0x%p, 0x%p\n", dev, info, wrqu);
+       return -EOPNOTSUPP;
+}
+
+
+static int ipw_wx_set_scan(struct net_device *dev,
+                          struct iw_request_info *info,
+                          union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       IPW_DEBUG_WX("Start scan\n");
+       if (ipw_request_scan(priv))
+               return -EIO;
+       return 0;
+}
+
+static int ipw_wx_get_scan(struct net_device *dev,
+                          struct iw_request_info *info,
+                          union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       return ieee80211_wx_get_scan(priv->ieee, info, wrqu, extra);
+}
+
+static int ipw_wx_set_encode(struct net_device *dev,
+                                struct iw_request_info *info,
+                                union iwreq_data *wrqu, char *key)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       return ieee80211_wx_set_encode(priv->ieee, info, wrqu, key);
+}
+
+static int ipw_wx_get_encode(struct net_device *dev,
+                                struct iw_request_info *info,
+                                union iwreq_data *wrqu, char *key)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       return ieee80211_wx_get_encode(priv->ieee, info, wrqu, key);
+}
+
+static int ipw_wx_set_power(struct net_device *dev,
+                               struct iw_request_info *info,
+                               union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       int err;
+
+       if (wrqu->power.disabled) {
+               priv->power_mode = IPW_POWER_LEVEL(priv->power_mode);
+               err = ipw_send_power_mode(priv, IPW_POWER_MODE_CAM);
+               if (err) {
+                       IPW_DEBUG_WX("failed setting power mode.\n");
+                       return err;
+               }
+
+               IPW_DEBUG_WX("SET Power Management Mode -> off\n");
+
+               return 0;
+       }
+
+       switch (wrqu->power.flags & IW_POWER_MODE) {
+       case IW_POWER_ON:    /* If not specified */
+       case IW_POWER_MODE:  /* If set all mask */
+       case IW_POWER_ALL_R: /* If explicitely state all */
+               break;
+       default: /* Otherwise we don't support it */
+               IPW_DEBUG_WX("SET PM Mode: %X not supported.\n",
+                            wrqu->power.flags);
+               return -EOPNOTSUPP;
+       }
+
+       /* If the user hasn't specified a power management mode yet, default
+        * to BATTERY */
+        if (IPW_POWER_LEVEL(priv->power_mode) == IPW_POWER_AC)
+               priv->power_mode = IPW_POWER_ENABLED | IPW_POWER_BATTERY;
+       else
+               priv->power_mode = IPW_POWER_ENABLED | priv->power_mode;
+       err = ipw_send_power_mode(priv, IPW_POWER_LEVEL(priv->power_mode));
+       if (err) {
+               IPW_DEBUG_WX("failed setting power mode.\n");
+               return err;
+       }
+
+       IPW_DEBUG_WX("SET Power Management Mode -> 0x%02X\n",
+                    priv->power_mode);
+
+       return 0;
+}
+
+static int ipw_wx_get_power(struct net_device *dev,
+                               struct iw_request_info *info,
+                               union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+
+       if (!(priv->power_mode & IPW_POWER_ENABLED)) {
+               wrqu->power.disabled = 1;
+       } else {
+               wrqu->power.disabled = 0;
+       }
+
+       IPW_DEBUG_WX("GET Power Management Mode -> %02X\n", priv->power_mode);
+
+       return 0;
+}
+
+static int ipw_wx_set_powermode(struct net_device *dev,
+                                   struct iw_request_info *info,
+                                   union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       int mode = *(int *)extra;
+       int err;
+
+       if ((mode < 1) || (mode > IPW_POWER_LIMIT)) {
+               mode = IPW_POWER_AC;
+               priv->power_mode = mode;
+       } else {
+               priv->power_mode = IPW_POWER_ENABLED | mode;
+       }
+
+       if (priv->power_mode != mode) {
+               err = ipw_send_power_mode(priv, mode);
+
+               if (err) {
+                       IPW_DEBUG_WX("failed setting power mode.\n");
+                       return err;
+               }
+       }
+
+       return 0;
+}
+
+#define MAX_WX_STRING 80
+static int ipw_wx_get_powermode(struct net_device *dev,
+                                   struct iw_request_info *info,
+                                   union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       int level = IPW_POWER_LEVEL(priv->power_mode);
+       char *p = extra;
+
+       p += snprintf(p, MAX_WX_STRING, "Power save level: %d ", level);
+
+       switch (level) {
+       case IPW_POWER_AC:
+               p += snprintf(p, MAX_WX_STRING - (p - extra), "(AC)");
+               break;
+       case IPW_POWER_BATTERY:
+               p += snprintf(p, MAX_WX_STRING - (p - extra), "(BATTERY)");
+               break;
+       default:
+               p += snprintf(p, MAX_WX_STRING - (p - extra),
+                             "(Timeout %dms, Period %dms)",
+                             timeout_duration[level - 1] / 1000,
+                             period_duration[level - 1] / 1000);
+       }
+
+       if (!(priv->power_mode & IPW_POWER_ENABLED))
+               p += snprintf(p, MAX_WX_STRING - (p - extra)," OFF");
+
+       wrqu->data.length = p - extra + 1;
+
+       return 0;
+}
+
+static int ipw_wx_set_wireless_mode(struct net_device *dev,
+                                    struct iw_request_info *info,
+                                    union iwreq_data *wrqu, char *extra)
+{
+        struct ipw_priv *priv = ieee80211_priv(dev);
+       int mode = *(int *)extra;
+       u8 band = 0, modulation = 0;
+
+       if (mode == 0 || mode & ~IEEE_MODE_MASK) {
+               IPW_WARNING("Attempt to set invalid wireless mode: %d\n",
+                           mode);
+               return -EINVAL;
+       }
+
+       if (priv->adapter == IPW_2915ABG) {
+               priv->ieee->abg_ture = 1;
+               if (mode & IEEE_A) {
+                       band |= IEEE80211_52GHZ_BAND;
+                       modulation |= IEEE80211_OFDM_MODULATION;
+               } else
+                       priv->ieee->abg_ture = 0;
+       } else {
+               if (mode & IEEE_A) {
+                       IPW_WARNING("Attempt to set 2200BG into "
+                                   "802.11a mode\n");
+                       return -EINVAL;
+               }
+
+               priv->ieee->abg_ture = 0;
+       }
+
+       if (mode & IEEE_B) {
+               band |= IEEE80211_24GHZ_BAND;
+               modulation |= IEEE80211_CCK_MODULATION;
+       } else
+               priv->ieee->abg_ture = 0;
+
+       if (mode & IEEE_G) {
+               band |= IEEE80211_24GHZ_BAND;
+               modulation |= IEEE80211_OFDM_MODULATION;
+       } else
+               priv->ieee->abg_ture = 0;
+
+       priv->ieee->mode = mode;
+       priv->ieee->freq_band = band;
+       priv->ieee->modulation = modulation;
+       init_supported_rates(priv, &priv->rates);
+
+       /* If we are currently associated, or trying to associate
+         * then see if this is a new configuration (causing us to
+        * disassociate) */
+        if (priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) {
+               /* The resulting association will trigger
+                * the new rates to be sent to the device */
+                IPW_DEBUG_ASSOC("Disassociating due to mode change.\n");
+                ipw_disassociate(priv);
+       } else
+               ipw_send_supported_rates(priv, &priv->rates);
+
+       IPW_DEBUG_WX("PRIV SET MODE: %c%c%c\n",
+                    mode & IEEE_A ? 'a' : '.',
+                    mode & IEEE_B ? 'b' : '.',
+                    mode & IEEE_G ? 'g' : '.');
+       return 0;
+}
+
+static int ipw_wx_get_wireless_mode(struct net_device *dev,
+                                    struct iw_request_info *info,
+                                    union iwreq_data *wrqu, char *extra)
+{
+        struct ipw_priv *priv = ieee80211_priv(dev);
+
+       switch (priv->ieee->freq_band) {
+       case IEEE80211_24GHZ_BAND:
+               switch (priv->ieee->modulation) {
+               case IEEE80211_CCK_MODULATION:
+                       strncpy(extra, "802.11b (2)", MAX_WX_STRING);
+                       break;
+               case IEEE80211_OFDM_MODULATION:
+                       strncpy(extra, "802.11g (4)", MAX_WX_STRING);
+                       break;
+               default:
+                       strncpy(extra, "802.11bg (6)", MAX_WX_STRING);
+                       break;
+               }
+               break;
+
+       case IEEE80211_52GHZ_BAND:
+               strncpy(extra, "802.11a (1)", MAX_WX_STRING);
+               break;
+
+       default: /* Mixed Band */
+               switch (priv->ieee->modulation) {
+               case IEEE80211_CCK_MODULATION:
+                       strncpy(extra, "802.11ab (3)", MAX_WX_STRING);
+                       break;
+               case IEEE80211_OFDM_MODULATION:
+                       strncpy(extra, "802.11ag (5)", MAX_WX_STRING);
+                       break;
+               default:
+                       strncpy(extra, "802.11abg (7)", MAX_WX_STRING);
+                       break;
+               }
+               break;
+       }
+
+       IPW_DEBUG_WX("PRIV GET MODE: %s\n", extra);
+
+        wrqu->data.length = strlen(extra) + 1;
+
+        return 0;
+}
+
+#ifdef CONFIG_IPW_PROMISC
+static int ipw_wx_set_promisc(struct net_device *dev,
+                             struct iw_request_info *info,
+                             union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       int *parms = (int *)extra;
+       int enable = (parms[0] > 0);
+
+       IPW_DEBUG_WX("SET PROMISC: %d %d\n", enable, parms[1]);
+       if (enable) {
+               if (priv->ieee->iw_mode != IW_MODE_MONITOR) {
+                       priv->net_dev->type = ARPHRD_IEEE80211;
+                       ipw_adapter_restart(priv);
+               }
+
+               ipw_set_channel(priv, parms[1]);
+       } else {
+               if (priv->ieee->iw_mode != IW_MODE_MONITOR)
+                       return 0;
+               priv->net_dev->type = ARPHRD_ETHER;
+               ipw_adapter_restart(priv);
+       }
+       return 0;
+}
+
+
+static int ipw_wx_reset(struct net_device *dev,
+                       struct iw_request_info *info,
+                       union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       IPW_DEBUG_WX("RESET\n");
+       ipw_adapter_restart(priv);
+       return 0;
+}
+#endif // CONFIG_IPW_PROMISC
+
+/* Rebase the WE IOCTLs to zero for the handler array */
+#define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT]
+static iw_handler ipw_wx_handlers[] =
+{
+       IW_IOCTL(SIOCGIWNAME)   = ipw_wx_get_name,
+       IW_IOCTL(SIOCSIWFREQ)   = ipw_wx_set_freq,
+       IW_IOCTL(SIOCGIWFREQ)   = ipw_wx_get_freq,
+       IW_IOCTL(SIOCSIWMODE)   = ipw_wx_set_mode,
+       IW_IOCTL(SIOCGIWMODE)   = ipw_wx_get_mode,
+       IW_IOCTL(SIOCGIWRANGE)  = ipw_wx_get_range,
+       IW_IOCTL(SIOCSIWAP)     = ipw_wx_set_wap,
+       IW_IOCTL(SIOCGIWAP)     = ipw_wx_get_wap,
+       IW_IOCTL(SIOCSIWSCAN)   = ipw_wx_set_scan,
+       IW_IOCTL(SIOCGIWSCAN)   = ipw_wx_get_scan,
+       IW_IOCTL(SIOCSIWESSID)  = ipw_wx_set_essid,
+       IW_IOCTL(SIOCGIWESSID)  = ipw_wx_get_essid,
+       IW_IOCTL(SIOCSIWNICKN)  = ipw_wx_set_nick,
+       IW_IOCTL(SIOCGIWNICKN)  = ipw_wx_get_nick,
+       IW_IOCTL(SIOCSIWRATE)   = ipw_wx_set_rate,
+       IW_IOCTL(SIOCGIWRATE)   = ipw_wx_get_rate,
+       IW_IOCTL(SIOCSIWRTS)    = ipw_wx_set_rts,
+       IW_IOCTL(SIOCGIWRTS)    = ipw_wx_get_rts,
+       IW_IOCTL(SIOCSIWFRAG)   = ipw_wx_set_frag,
+       IW_IOCTL(SIOCGIWFRAG)   = ipw_wx_get_frag,
+       IW_IOCTL(SIOCSIWTXPOW)  = ipw_wx_set_txpow,
+       IW_IOCTL(SIOCGIWTXPOW)  = ipw_wx_get_txpow,
+       IW_IOCTL(SIOCSIWRETRY)  = ipw_wx_set_retry,
+       IW_IOCTL(SIOCGIWRETRY)  = ipw_wx_get_retry,
+       IW_IOCTL(SIOCSIWENCODE) = ipw_wx_set_encode,
+       IW_IOCTL(SIOCGIWENCODE) = ipw_wx_get_encode,
+       IW_IOCTL(SIOCSIWPOWER)  = ipw_wx_set_power,
+       IW_IOCTL(SIOCGIWPOWER)  = ipw_wx_get_power,
+};
+
+#define IPW_PRIV_SET_POWER     SIOCIWFIRSTPRIV
+#define IPW_PRIV_GET_POWER     SIOCIWFIRSTPRIV+1
+#define IPW_PRIV_SET_MODE      SIOCIWFIRSTPRIV+2
+#define IPW_PRIV_GET_MODE      SIOCIWFIRSTPRIV+3
+#define IPW_PRIV_SET_PROMISC   SIOCIWFIRSTPRIV+4
+#define IPW_PRIV_RESET         SIOCIWFIRSTPRIV+5
+
+
+static struct iw_priv_args ipw_priv_args[] = {
+       {
+               .cmd = IPW_PRIV_SET_POWER,
+               .set_args = IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
+               .name = "set_power"
+       },
+       {
+               .cmd = IPW_PRIV_GET_POWER,
+               .get_args = IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
+               .name = "get_power"
+       },
+       {
+               .cmd = IPW_PRIV_SET_MODE,
+               .set_args = IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
+               .name = "set_mode"
+       },
+       {
+               .cmd = IPW_PRIV_GET_MODE,
+               .get_args = IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
+               .name = "get_mode"
+       },
+#ifdef CONFIG_IPW_PROMISC
+       {
+               IPW_PRIV_SET_PROMISC,
+               IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "monitor"
+       },
+       {
+               IPW_PRIV_RESET,
+               IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 0, 0, "reset"
+       },
+#endif /* CONFIG_IPW_PROMISC */
+};
+
+static iw_handler ipw_priv_handler[] = {
+       ipw_wx_set_powermode,
+       ipw_wx_get_powermode,
+       ipw_wx_set_wireless_mode,
+       ipw_wx_get_wireless_mode,
+#ifdef CONFIG_IPW_PROMISC
+       ipw_wx_set_promisc,
+       ipw_wx_reset,
+#endif
+};
+
+static struct iw_handler_def ipw_wx_handler_def =
+{
+       .standard       = ipw_wx_handlers,
+       .num_standard   = ARRAY_SIZE(ipw_wx_handlers),
+       .num_private    = ARRAY_SIZE(ipw_priv_handler),
+       .num_private_args = ARRAY_SIZE(ipw_priv_args),
+       .private        = ipw_priv_handler,
+       .private_args   = ipw_priv_args,
+};
+
+
+
+
+/*
+ * Get wireless statistics.
+ * Called by /proc/net/wireless
+ * Also called by SIOCGIWSTATS
+ */
+static struct iw_statistics *ipw_get_wireless_stats(struct net_device * dev)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       struct iw_statistics *wstats;
+
+       wstats = &priv->wstats;
+
+       /* if hw is disabled, then ipw2100_get_ordinal() can't be called.
+        * ipw2100_wx_wireless_stats seems to be called before fw is
+        * initialized.  STATUS_ASSOCIATED will only be set if the hw is up
+        * and associated; if not associcated, the values are all meaningless
+        * anyway, so set them all to NULL and INVALID */
+       if (!(priv->status & STATUS_ASSOCIATED)) {
+               wstats->miss.beacon = 0;
+               wstats->discard.retries = 0;
+               wstats->qual.qual = 0;
+               wstats->qual.level = 0;
+               wstats->qual.noise = 0;
+               wstats->qual.updated = 7;
+               wstats->qual.updated |= IW_QUAL_NOISE_INVALID |
+                       IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID;
+               return wstats;
+       }
+
+       wstats->qual.qual = priv->quality;
+       wstats->qual.level = average_value(&priv->average_rssi);
+       wstats->qual.noise = average_value(&priv->average_noise);
+       wstats->qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED |
+               IW_QUAL_NOISE_UPDATED;
+
+       wstats->miss.beacon = average_value(&priv->average_missed_beacons);
+       wstats->discard.retries = priv->last_tx_failures;
+       wstats->discard.code = priv->ieee->ieee_stats.rx_discards_undecryptable;
+
+/*     if (ipw_get_ordinal(priv, IPW_ORD_STAT_TX_RETRY, &tx_retry, &len))
+       goto fail_get_ordinal;
+       wstats->discard.retries += tx_retry; */
+
+       return wstats;
+}
+
+
+/* net device stuff */
+
+static inline void init_sys_config(struct ipw_sys_config *sys_config)
+{
+        memset(sys_config, 0, sizeof(struct ipw_sys_config));
+       sys_config->bt_coexistence = 1; /* We may need to look into prvStaBtConfig */
+       sys_config->answer_broadcast_ssid_probe = 0;
+       sys_config->accept_all_data_frames = 0;
+       sys_config->accept_non_directed_frames = 1;
+       sys_config->exclude_unicast_unencrypted = 0;
+       sys_config->disable_unicast_decryption = 1;
+       sys_config->exclude_multicast_unencrypted = 0;
+       sys_config->disable_multicast_decryption = 1;
+       sys_config->antenna_diversity = CFG_SYS_ANTENNA_BOTH;
+       sys_config->pass_crc_to_host = 0; /* TODO: See if 1 gives us FCS */
+       sys_config->dot11g_auto_detection = 0;
+       sys_config->enable_cts_to_self = 0;
+       sys_config->bt_coexist_collision_thr = 0;
+       sys_config->pass_noise_stats_to_host = 1;
+}
+
+static int ipw_net_open(struct net_device *dev)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       IPW_DEBUG_INFO("dev->open\n");
+       /* we should be verifying the device is ready to be opened */
+       if (!(priv->status & STATUS_RF_KILL_MASK) &&
+           (priv->status & STATUS_ASSOCIATED))
+               netif_start_queue(dev);
+       return 0;
+}
+
+static int ipw_net_stop(struct net_device *dev)
+{
+       IPW_DEBUG_INFO("dev->close\n");
+       netif_stop_queue(dev);
+       return 0;
+}
+
+/*
+todo:
+
+modify to send one tfd per fragment instead of using chunking.  otherwise
+we need to heavily modify the ieee80211_skb_to_txb.
+*/
+
+static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb)
+{
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)
+               txb->fragments[0]->data;
+       int i = 0;
+       struct tfd_frame *tfd;
+       struct clx2_tx_queue *txq = &priv->txq[0];
+       struct clx2_queue *q = &txq->q;
+       u8 id, hdr_len, unicast;
+       u16 remaining_bytes;
+
+       switch (priv->ieee->iw_mode) {
+       case IW_MODE_ADHOC:
+               hdr_len = IEEE80211_3ADDR_LEN;
+               unicast = !is_broadcast_ether_addr(hdr->addr1) &&
+                       !is_multicast_ether_addr(hdr->addr1);
+               id = ipw_find_station(priv, hdr->addr1);
+               if (id == IPW_INVALID_STATION) {
+                       id = ipw_add_station(priv, hdr->addr1);
+                       if (id == IPW_INVALID_STATION) {
+                               IPW_WARNING("Attempt to send data to "
+                                           "invalid cell: " MAC_FMT "\n",
+                                           MAC_ARG(hdr->addr1));
+                               goto drop;
+                       }
+               }
+               break;
+
+       case IW_MODE_INFRA:
+       default:
+               unicast = !is_broadcast_ether_addr(hdr->addr3) &&
+                       !is_multicast_ether_addr(hdr->addr3);
+               hdr_len = IEEE80211_3ADDR_LEN;
+               id = 0;
+               break;
+       }
+
+       tfd = &txq->bd[q->first_empty];
+       txq->txb[q->first_empty] = txb;
+       memset(tfd, 0, sizeof(*tfd));
+       tfd->u.data.station_number = id;
+
+       tfd->control_flags.message_type = TX_FRAME_TYPE;
+       tfd->control_flags.control_bits = TFD_NEED_IRQ_MASK;
+
+       tfd->u.data.cmd_id = DINO_CMD_TX;
+       tfd->u.data.len = txb->payload_size;
+       remaining_bytes = txb->payload_size;
+       if (unlikely(!unicast))
+               tfd->u.data.tx_flags = DCT_FLAG_NO_WEP;
+       else
+               tfd->u.data.tx_flags = DCT_FLAG_NO_WEP | DCT_FLAG_ACK_REQD;
+
+       if (priv->assoc_request.ieee_mode == IPW_B_MODE)
+               tfd->u.data.tx_flags_ext = DCT_FLAG_EXT_MODE_CCK;
+       else
+               tfd->u.data.tx_flags_ext = DCT_FLAG_EXT_MODE_OFDM;
+
+       if (priv->config & CFG_PREAMBLE)
+               tfd->u.data.tx_flags |= DCT_FLAG_SHORT_PREMBL;
+
+       memcpy(&tfd->u.data.tfd.tfd_24.mchdr, hdr, hdr_len);
+
+       /* payload */
+       tfd->u.data.num_chunks = min((u8)(NUM_TFD_CHUNKS - 2), txb->nr_frags);
+       for (i = 0; i < tfd->u.data.num_chunks; i++) {
+               IPW_DEBUG_TX("Dumping TX packet frag %i of %i (%d bytes):\n",
+                            i, tfd->u.data.num_chunks,
+                            txb->fragments[i]->len - hdr_len);
+               printk_buf(IPW_DL_TX, txb->fragments[i]->data + hdr_len,
+                          txb->fragments[i]->len - hdr_len);
+
+               tfd->u.data.chunk_ptr[i] = pci_map_single(
+                       priv->pci_dev, txb->fragments[i]->data + hdr_len,
+                       txb->fragments[i]->len - hdr_len, PCI_DMA_TODEVICE);
+               tfd->u.data.chunk_len[i] = txb->fragments[i]->len - hdr_len;
+       }
+
+       if (i != txb->nr_frags) {
+               struct sk_buff *skb;
+               u16 remaining_bytes = 0;
+               int j;
+
+               for (j = i; j < txb->nr_frags; j++)
+                       remaining_bytes += txb->fragments[j]->len - hdr_len;
+
+               printk(KERN_INFO "Trying to reallocate for %d bytes\n",
+                      remaining_bytes);
+               skb = alloc_skb(remaining_bytes, GFP_ATOMIC);
+               if (skb != NULL) {
+                       tfd->u.data.chunk_len[i] = remaining_bytes;
+                       for (j = i; j < txb->nr_frags; j++) {
+                               int size = txb->fragments[j]->len - hdr_len;
+                               printk(KERN_INFO "Adding frag %d %d...\n",
+                                       j, size);
+                               memcpy(skb_put(skb, size),
+                                       txb->fragments[j]->data + hdr_len,
+                                       size);
+                       }
+                       dev_kfree_skb_any(txb->fragments[i]);
+                       txb->fragments[i] = skb;
+                       tfd->u.data.chunk_ptr[i] = pci_map_single(
+                               priv->pci_dev, skb->data,
+                               tfd->u.data.chunk_len[i], PCI_DMA_TODEVICE);
+                       tfd->u.data.num_chunks++;
+               }
+       }
+
+       /* kick DMA */
+       q->first_empty = ipw_queue_inc_wrap(q->first_empty, q->n_bd);
+       ipw_write32(priv, q->reg_w, q->first_empty);
+
+       if (ipw_queue_space(q) < q->high_mark)
+               netif_stop_queue(priv->net_dev);
+
+       return;
+
+ drop:
+       IPW_DEBUG_DROP("Silently dropping Tx packet.\n");
+       ieee80211_txb_free(txb);
+}
+
+static int ipw_net_hard_start_xmit(struct ieee80211_txb *txb,
+                                  struct net_device *dev)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       unsigned long flags;
+
+       IPW_DEBUG_TX("dev->xmit(%d bytes)\n", txb->payload_size);
+
+       spin_lock_irqsave(&priv->lock, flags);
+
+       if (!(priv->status & STATUS_ASSOCIATED)) {
+               IPW_DEBUG_INFO("Tx attempt while not associated.\n");
+               priv->ieee->stats.tx_carrier_errors++;
+               netif_stop_queue(dev);
+               goto fail_unlock;
+       }
+
+       ipw_tx_skb(priv, txb);
+
+       spin_unlock_irqrestore(&priv->lock, flags);
+       return 0;
+
+ fail_unlock:
+       spin_unlock_irqrestore(&priv->lock, flags);
+       return 1;
+}
+
+static struct net_device_stats *ipw_net_get_stats(struct net_device *dev)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+
+       priv->ieee->stats.tx_packets = priv->tx_packets;
+       priv->ieee->stats.rx_packets = priv->rx_packets;
+       return &priv->ieee->stats;
+}
+
+static void ipw_net_set_multicast_list(struct net_device *dev)
+{
+
+}
+
+static int ipw_net_set_mac_address(struct net_device *dev, void *p)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       struct sockaddr *addr = p;
+       if (!is_valid_ether_addr(addr->sa_data))
+               return -EADDRNOTAVAIL;
+       priv->config |= CFG_CUSTOM_MAC;
+       memcpy(priv->mac_addr, addr->sa_data, ETH_ALEN);
+       printk(KERN_INFO "%s: Setting MAC to " MAC_FMT "\n",
+              priv->net_dev->name, MAC_ARG(priv->mac_addr));
+       ipw_adapter_restart(priv);
+       return 0;
+}
+
+static void ipw_ethtool_get_drvinfo(struct net_device *dev,
+                                   struct ethtool_drvinfo *info)
+{
+       struct ipw_priv *p = ieee80211_priv(dev);
+       char vers[64];
+       char date[32];
+       u32 len;
+
+       strcpy(info->driver, DRV_NAME);
+       strcpy(info->version, DRV_VERSION);
+
+       len = sizeof(vers);
+       ipw_get_ordinal(p, IPW_ORD_STAT_FW_VERSION, vers, &len);
+       len = sizeof(date);
+       ipw_get_ordinal(p, IPW_ORD_STAT_FW_DATE, date, &len);
+
+       snprintf(info->fw_version, sizeof(info->fw_version),"%s (%s)",
+                vers, date);
+       strcpy(info->bus_info, pci_name(p->pci_dev));
+       info->eedump_len = CX2_EEPROM_IMAGE_SIZE;
+}
+
+static u32 ipw_ethtool_get_link(struct net_device *dev)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       return (priv->status & STATUS_ASSOCIATED) != 0;
+}
+
+static int ipw_ethtool_get_eeprom_len(struct net_device *dev)
+{
+       return CX2_EEPROM_IMAGE_SIZE;
+}
+
+static int ipw_ethtool_get_eeprom(struct net_device *dev,
+                                 struct ethtool_eeprom *eeprom, u8 *bytes)
+{
+       struct ipw_priv *p = ieee80211_priv(dev);
+
+       if (eeprom->offset + eeprom->len > CX2_EEPROM_IMAGE_SIZE)
+               return -EINVAL;
+
+       memcpy(bytes, &((u8 *)p->eeprom)[eeprom->offset], eeprom->len);
+       return 0;
+}
+
+static int ipw_ethtool_set_eeprom(struct net_device *dev,
+                                 struct ethtool_eeprom *eeprom, u8 *bytes)
+{
+       struct ipw_priv *p = ieee80211_priv(dev);
+       int i;
+
+       if (eeprom->offset + eeprom->len > CX2_EEPROM_IMAGE_SIZE)
+               return -EINVAL;
+
+       memcpy(&((u8 *)p->eeprom)[eeprom->offset], bytes, eeprom->len);
+       for (i = IPW_EEPROM_DATA;
+            i < IPW_EEPROM_DATA + CX2_EEPROM_IMAGE_SIZE;
+            i++)
+               ipw_write8(p, i, p->eeprom[i]);
+
+       return 0;
+}
+
+static struct ethtool_ops ipw_ethtool_ops = {
+        .get_link       = ipw_ethtool_get_link,
+        .get_drvinfo    = ipw_ethtool_get_drvinfo,
+        .get_eeprom_len = ipw_ethtool_get_eeprom_len,
+        .get_eeprom     = ipw_ethtool_get_eeprom,
+        .set_eeprom     = ipw_ethtool_set_eeprom,
+};
+
+static irqreturn_t ipw_isr(int irq, void *data, struct pt_regs *regs)
+{
+       struct ipw_priv *priv = data;
+       u32 inta, inta_mask;
+
+       if (!priv)
+               return IRQ_NONE;
+
+       spin_lock(&priv->lock);
+
+       if (!(priv->status & STATUS_INT_ENABLED)) {
+               /* Shared IRQ */
+               goto none;
+       }
+
+       inta = ipw_read32(priv, CX2_INTA_RW);
+       inta_mask = ipw_read32(priv, CX2_INTA_MASK_R);
+
+       if (inta == 0xFFFFFFFF) {
+               /* Hardware disappeared */
+               IPW_WARNING("IRQ INTA == 0xFFFFFFFF\n");
+               goto none;
+       }
+
+       if (!(inta & (CX2_INTA_MASK_ALL & inta_mask))) {
+               /* Shared interrupt */
+               goto none;
+       }
+
+       /* tell the device to stop sending interrupts */
+       ipw_disable_interrupts(priv);
+
+       /* ack current interrupts */
+       inta &= (CX2_INTA_MASK_ALL & inta_mask);
+       ipw_write32(priv, CX2_INTA_RW, inta);
+
+       /* Cache INTA value for our tasklet */
+       priv->isr_inta = inta;
+
+       tasklet_schedule(&priv->irq_tasklet);
+
+       spin_unlock(&priv->lock);
+
+       return IRQ_HANDLED;
+ none:
+       spin_unlock(&priv->lock);
+       return IRQ_NONE;
+}
+
+static void ipw_rf_kill(void *adapter)
+{
+       struct ipw_priv *priv = adapter;
+       unsigned long flags;
+
+       spin_lock_irqsave(&priv->lock, flags);
+
+       if (rf_kill_active(priv)) {
+               IPW_DEBUG_RF_KILL("RF Kill active, rescheduling GPIO check\n");
+               if (priv->workqueue)
+                       queue_delayed_work(priv->workqueue,
+                                          &priv->rf_kill, 2 * HZ);
+               goto exit_unlock;
+       }
+
+       /* RF Kill is now disabled, so bring the device back up */
+
+       if (!(priv->status & STATUS_RF_KILL_MASK)) {
+               IPW_DEBUG_RF_KILL("HW RF Kill no longer active, restarting "
+                                 "device\n");
+
+               /* we can not do an adapter restart while inside an irq lock */
+               queue_work(priv->workqueue, &priv->adapter_restart);
+       } else
+               IPW_DEBUG_RF_KILL("HW RF Kill deactivated.  SW RF Kill still "
+                                 "enabled\n");
+
+ exit_unlock:
+       spin_unlock_irqrestore(&priv->lock, flags);
+}
+
+static int ipw_setup_deferred_work(struct ipw_priv *priv)
+{
+       int ret = 0;
+
+       priv->workqueue = create_workqueue(DRV_NAME);
+       init_waitqueue_head(&priv->wait_command_queue);
+
+       INIT_WORK(&priv->adhoc_check, ipw_adhoc_check, priv);
+       INIT_WORK(&priv->associate, ipw_associate, priv);
+       INIT_WORK(&priv->disassociate, ipw_disassociate, priv);
+       INIT_WORK(&priv->rx_replenish, ipw_rx_queue_replenish, priv);
+       INIT_WORK(&priv->adapter_restart, ipw_adapter_restart, priv);
+       INIT_WORK(&priv->rf_kill, ipw_rf_kill, priv);
+       INIT_WORK(&priv->up, (void (*)(void *))ipw_up, priv);
+       INIT_WORK(&priv->down, (void (*)(void *))ipw_down, priv);
+       INIT_WORK(&priv->request_scan,
+                 (void (*)(void *))ipw_request_scan, priv);
+       INIT_WORK(&priv->gather_stats,
+                 (void (*)(void *))ipw_gather_stats, priv);
+       INIT_WORK(&priv->abort_scan, (void (*)(void *))ipw_abort_scan, priv);
+       INIT_WORK(&priv->roam, ipw_roam, priv);
+       INIT_WORK(&priv->scan_check, ipw_scan_check, priv);
+
+       tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
+                    ipw_irq_tasklet, (unsigned long)priv);
+
+       return ret;
+}
+
+
+static void shim__set_security(struct net_device *dev,
+                              struct ieee80211_security *sec)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       int i;
+
+       for (i = 0; i < 4; i++) {
+               if (sec->flags & (1 << i)) {
+                       priv->sec.key_sizes[i] = sec->key_sizes[i];
+                       if (sec->key_sizes[i] == 0)
+                               priv->sec.flags &= ~(1 << i);
+                       else
+                               memcpy(priv->sec.keys[i], sec->keys[i],
+                                      sec->key_sizes[i]);
+                       priv->sec.flags |= (1 << i);
+                       priv->status |= STATUS_SECURITY_UPDATED;
+               }
+       }
+
+       if ((sec->flags & SEC_ACTIVE_KEY) &&
+           priv->sec.active_key != sec->active_key) {
+               if (sec->active_key <= 3) {
+                       priv->sec.active_key = sec->active_key;
+                       priv->sec.flags |= SEC_ACTIVE_KEY;
+               } else
+                       priv->sec.flags &= ~SEC_ACTIVE_KEY;
+               priv->status |= STATUS_SECURITY_UPDATED;
+       }
+
+       if ((sec->flags & SEC_AUTH_MODE) &&
+           (priv->sec.auth_mode != sec->auth_mode)) {
+               priv->sec.auth_mode = sec->auth_mode;
+               priv->sec.flags |= SEC_AUTH_MODE;
+               if (sec->auth_mode == WLAN_AUTH_SHARED_KEY)
+                       priv->capability |= CAP_SHARED_KEY;
+               else
+                       priv->capability &= ~CAP_SHARED_KEY;
+               priv->status |= STATUS_SECURITY_UPDATED;
+       }
+
+       if (sec->flags & SEC_ENABLED &&
+           priv->sec.enabled != sec->enabled) {
+               priv->sec.flags |= SEC_ENABLED;
+               priv->sec.enabled = sec->enabled;
+               priv->status |= STATUS_SECURITY_UPDATED;
+               if (sec->enabled)
+                       priv->capability |= CAP_PRIVACY_ON;
+               else
+                       priv->capability &= ~CAP_PRIVACY_ON;
+       }
+
+       if (sec->flags & SEC_LEVEL &&
+           priv->sec.level != sec->level) {
+               priv->sec.level = sec->level;
+               priv->sec.flags |= SEC_LEVEL;
+               priv->status |= STATUS_SECURITY_UPDATED;
+       }
+
+       /* To match current functionality of ipw2100 (which works well w/
+        * various supplicants, we don't force a disassociate if the
+        * privacy capability changes ... */
+#if 0
+       if ((priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) &&
+           (((priv->assoc_request.capability &
+              WLAN_CAPABILITY_PRIVACY) && !sec->enabled) ||
+            (!(priv->assoc_request.capability &
+                WLAN_CAPABILITY_PRIVACY) && sec->enabled))) {
+               IPW_DEBUG_ASSOC("Disassociating due to capability "
+                               "change.\n");
+               ipw_disassociate(priv);
+       }
+#endif
+}
+
+static int init_supported_rates(struct ipw_priv *priv,
+                               struct ipw_supported_rates *rates)
+{
+       /* TODO: Mask out rates based on priv->rates_mask */
+
+       memset(rates, 0, sizeof(*rates));
+        /* configure supported rates */
+       switch (priv->ieee->freq_band) {
+       case IEEE80211_52GHZ_BAND:
+               rates->ieee_mode = IPW_A_MODE;
+               rates->purpose = IPW_RATE_CAPABILITIES;
+               ipw_add_ofdm_scan_rates(rates, IEEE80211_CCK_MODULATION,
+                                       IEEE80211_OFDM_DEFAULT_RATES_MASK);
+               break;
+
+       default: /* Mixed or 2.4Ghz */
+               rates->ieee_mode = IPW_G_MODE;
+               rates->purpose = IPW_RATE_CAPABILITIES;
+               ipw_add_cck_scan_rates(rates, IEEE80211_CCK_MODULATION,
+                                      IEEE80211_CCK_DEFAULT_RATES_MASK);
+               if (priv->ieee->modulation & IEEE80211_OFDM_MODULATION) {
+                       ipw_add_ofdm_scan_rates(rates, IEEE80211_CCK_MODULATION,
+                                               IEEE80211_OFDM_DEFAULT_RATES_MASK);
+               }
+               break;
+       }
+
+       return 0;
+}
+
+static int ipw_config(struct ipw_priv *priv)
+{
+       int i;
+       struct ipw_tx_power tx_power;
+
+       memset(&priv->sys_config, 0, sizeof(priv->sys_config));
+       memset(&tx_power, 0, sizeof(tx_power));
+
+       /* This is only called from ipw_up, which resets/reloads the firmware
+          so, we don't need to first disable the card before we configure
+          it */
+
+       /* configure device for 'G' band */
+       tx_power.ieee_mode = IPW_G_MODE;
+       tx_power.num_channels = 11;
+       for (i = 0; i < 11; i++) {
+               tx_power.channels_tx_power[i].channel_number = i + 1;
+               tx_power.channels_tx_power[i].tx_power = priv->tx_power;
+       }
+       if (ipw_send_tx_power(priv, &tx_power))
+               goto error;
+
+       /* configure device to also handle 'B' band */
+       tx_power.ieee_mode = IPW_B_MODE;
+       if (ipw_send_tx_power(priv, &tx_power))
+               goto error;
+
+       /* initialize adapter address */
+       if (ipw_send_adapter_address(priv, priv->net_dev->dev_addr))
+               goto error;
+
+       /* set basic system config settings */
+       init_sys_config(&priv->sys_config);
+       if (ipw_send_system_config(priv, &priv->sys_config))
+               goto error;
+
+        init_supported_rates(priv, &priv->rates);
+        if (ipw_send_supported_rates(priv, &priv->rates))
+               goto error;
+
+       /* Set request-to-send threshold */
+       if (priv->rts_threshold) {
+               if (ipw_send_rts_threshold(priv, priv->rts_threshold))
+                       goto error;
+       }
+
+       if (ipw_set_random_seed(priv))
+               goto error;
+
+       /* final state transition to the RUN state */
+       if (ipw_send_host_complete(priv))
+               goto error;
+
+       /* If configured to try and auto-associate, kick off a scan */
+       if ((priv->config & CFG_ASSOCIATE) && ipw_request_scan(priv))
+               goto error;
+
+       return 0;
+
+ error:
+       return -EIO;
+}
+
+#define MAX_HW_RESTARTS 5
+static int ipw_up(struct ipw_priv *priv)
+{
+       int rc, i;
+
+       if (priv->status & STATUS_EXIT_PENDING)
+               return -EIO;
+
+       for (i = 0; i < MAX_HW_RESTARTS; i++ ) {
+               /* Load the microcode, firmware, and eeprom.
+                * Also start the clocks. */
+               rc = ipw_load(priv);
+               if (rc) {
+                       IPW_ERROR("Unable to load firmware: 0x%08X\n",
+                                       rc);
+                       return rc;
+               }
+
+               ipw_init_ordinals(priv);
+               if (!(priv->config & CFG_CUSTOM_MAC))
+                       eeprom_parse_mac(priv, priv->mac_addr);
+               memcpy(priv->net_dev->dev_addr, priv->mac_addr, ETH_ALEN);
+
+               if (priv->status & STATUS_RF_KILL_MASK)
+                       return 0;
+
+               rc = ipw_config(priv);
+               if (!rc) {
+                       IPW_DEBUG_INFO("Configured device on count %i\n", i);
+                       priv->notif_missed_beacons = 0;
+                       netif_start_queue(priv->net_dev);
+                       return 0;
+               } else {
+                       IPW_DEBUG_INFO("Device configuration failed: 0x%08X\n",
+                                      rc);
+               }
+
+               IPW_DEBUG_INFO("Failed to config device on retry %d of %d\n",
+                              i, MAX_HW_RESTARTS);
+
+               /* We had an error bringing up the hardware, so take it
+                * all the way back down so we can try again */
+               ipw_down(priv);
+       }
+
+       /* tried to restart and config the device for as long as our
+        * patience could withstand */
+       IPW_ERROR("Unable to initialize device after %d attempts.\n",
+                 i);
+       return -EIO;
+}
+
+static void ipw_down(struct ipw_priv *priv)
+{
+       /* Attempt to disable the card */
+#if 0
+       ipw_send_card_disable(priv, 0);
+#endif
+
+       /* tell the device to stop sending interrupts */
+       ipw_disable_interrupts(priv);
+
+       /* Clear all bits but the RF Kill */
+       priv->status &= STATUS_RF_KILL_MASK;
+
+       netif_carrier_off(priv->net_dev);
+       netif_stop_queue(priv->net_dev);
+
+       ipw_stop_nic(priv);
+}
+
+/* Called by register_netdev() */
+static int ipw_net_init(struct net_device *dev)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+
+       if (priv->status & STATUS_RF_KILL_SW) {
+               IPW_WARNING("Radio disabled by module parameter.\n");
+               return 0;
+       } else if (rf_kill_active(priv)) {
+               IPW_WARNING("Radio Frequency Kill Switch is On:\n"
+                           "Kill switch must be turned off for "
+                           "wireless networking to work.\n");
+               queue_delayed_work(priv->workqueue, &priv->rf_kill, 2 * HZ);
+               return 0;
+       }
+
+       if (ipw_up(priv))
+               return -EIO;
+
+       return 0;
+}
+
+/* PCI driver stuff */
+static struct pci_device_id card_ids[] = {
+       {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2701, 0, 0, 0},
+       {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2702, 0, 0, 0},
+       {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2711, 0, 0, 0},
+       {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2712, 0, 0, 0},
+       {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2721, 0, 0, 0},
+       {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2722, 0, 0, 0},
+       {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2731, 0, 0, 0},
+       {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2732, 0, 0, 0},
+       {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2741, 0, 0, 0},
+       {PCI_VENDOR_ID_INTEL, 0x1043, 0x103c, 0x2741, 0, 0, 0},
+       {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2742, 0, 0, 0},
+       {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2751, 0, 0, 0},
+       {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2752, 0, 0, 0},
+       {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2753, 0, 0, 0},
+       {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2754, 0, 0, 0},
+       {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2761, 0, 0, 0},
+       {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2762, 0, 0, 0},
+       {PCI_VENDOR_ID_INTEL, 0x104f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+       {PCI_VENDOR_ID_INTEL, 0x4220, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* BG */
+       {PCI_VENDOR_ID_INTEL, 0x4221, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* 2225BG */
+       {PCI_VENDOR_ID_INTEL, 0x4223, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* ABG */
+       {PCI_VENDOR_ID_INTEL, 0x4224, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* ABG */
+
+       /* required last entry */
+       {0,}
+};
+
+MODULE_DEVICE_TABLE(pci, card_ids);
+
+static struct attribute *ipw_sysfs_entries[] = {
+       &dev_attr_rf_kill.attr,
+       &dev_attr_direct_dword.attr,
+       &dev_attr_indirect_byte.attr,
+       &dev_attr_indirect_dword.attr,
+       &dev_attr_mem_gpio_reg.attr,
+       &dev_attr_command_event_reg.attr,
+       &dev_attr_nic_type.attr,
+       &dev_attr_status.attr,
+       &dev_attr_cfg.attr,
+       &dev_attr_dump_errors.attr,
+       &dev_attr_dump_events.attr,
+       &dev_attr_eeprom_delay.attr,
+       &dev_attr_ucode_version.attr,
+       &dev_attr_rtc.attr,
+       NULL
+};
+
+static struct attribute_group ipw_attribute_group = {
+       .name = NULL,           /* put in device directory */
+       .attrs  = ipw_sysfs_entries,
+};
+
+static int ipw_pci_probe(struct pci_dev *pdev,
+                        const struct pci_device_id *ent)
+{
+       int err = 0;
+       struct net_device *net_dev;
+       void __iomem *base;
+       u32 length, val;
+       struct ipw_priv *priv;
+       int band, modulation;
+
+       net_dev = alloc_ieee80211(sizeof(struct ipw_priv));
+       if (net_dev == NULL) {
+               err = -ENOMEM;
+               goto out;
+       }
+
+       priv = ieee80211_priv(net_dev);
+       priv->ieee = netdev_priv(net_dev);
+       priv->net_dev = net_dev;
+       priv->pci_dev = pdev;
+#ifdef CONFIG_IPW_DEBUG
+       ipw_debug_level = debug;
+#endif
+       spin_lock_init(&priv->lock);
+
+       if (pci_enable_device(pdev)) {
+               err = -ENODEV;
+               goto out_free_ieee80211;
+       }
+
+       pci_set_master(pdev);
+
+       err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
+       if (!err)
+               err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
+       if (err) {
+               printk(KERN_WARNING DRV_NAME ": No suitable DMA available.\n");
+               goto out_pci_disable_device;
+       }
+
+       pci_set_drvdata(pdev, priv);
+
+       err = pci_request_regions(pdev, DRV_NAME);
+       if (err)
+               goto out_pci_disable_device;
+
+       /* We disable the RETRY_TIMEOUT register (0x41) to keep
+        * PCI Tx retries from interfering with C3 CPU state */
+       pci_read_config_dword(pdev, 0x40, &val);
+       if ((val & 0x0000ff00) != 0)
+               pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
+
+       length = pci_resource_len(pdev, 0);
+       priv->hw_len = length;
+
+       base = ioremap_nocache(pci_resource_start(pdev, 0), length);
+       if (!base) {
+               err = -ENODEV;
+               goto out_pci_release_regions;
+       }
+
+       priv->hw_base = base;
+       IPW_DEBUG_INFO("pci_resource_len = 0x%08x\n", length);
+       IPW_DEBUG_INFO("pci_resource_base = %p\n", base);
+
+       err = ipw_setup_deferred_work(priv);
+       if (err) {
+               IPW_ERROR("Unable to setup deferred work\n");
+               goto out_iounmap;
+       }
+
+       /* Initialize module parameter values here */
+       if (ifname)
+               strncpy(net_dev->name, ifname, IFNAMSIZ);
+
+       if (associate)
+               priv->config |= CFG_ASSOCIATE;
+       else
+               IPW_DEBUG_INFO("Auto associate disabled.\n");
+
+       if (auto_create)
+               priv->config |= CFG_ADHOC_CREATE;
+       else
+               IPW_DEBUG_INFO("Auto adhoc creation disabled.\n");
+
+       if (disable) {
+               priv->status |= STATUS_RF_KILL_SW;
+               IPW_DEBUG_INFO("Radio disabled.\n");
+       }
+
+       if (channel != 0) {
+               priv->config |= CFG_STATIC_CHANNEL;
+               priv->channel = channel;
+               IPW_DEBUG_INFO("Bind to static channel %d\n", channel);
+               IPW_DEBUG_INFO("Bind to static channel %d\n", channel);
+               /* TODO: Validate that provided channel is in range */
+       }
+
+       switch (mode) {
+       case 1:
+               priv->ieee->iw_mode = IW_MODE_ADHOC;
+               break;
+#ifdef CONFIG_IPW_PROMISC
+       case 2:
+               priv->ieee->iw_mode = IW_MODE_MONITOR;
+               break;
+#endif
+       default:
+       case 0:
+               priv->ieee->iw_mode = IW_MODE_INFRA;
+               break;
+       }
+
+       if ((priv->pci_dev->device == 0x4223) ||
+           (priv->pci_dev->device == 0x4224)) {
+               printk(KERN_INFO DRV_NAME
+                      ": Detected Intel PRO/Wireless 2915ABG Network "
+                      "Connection\n");
+               priv->ieee->abg_ture = 1;
+               band = IEEE80211_52GHZ_BAND | IEEE80211_24GHZ_BAND;
+               modulation = IEEE80211_OFDM_MODULATION |
+                       IEEE80211_CCK_MODULATION;
+               priv->adapter = IPW_2915ABG;
+               priv->ieee->mode = IEEE_A|IEEE_G|IEEE_B;
+       } else {
+               if (priv->pci_dev->device == 0x4221)
+                       printk(KERN_INFO DRV_NAME
+                              ": Detected Intel PRO/Wireless 2225BG Network "
+                              "Connection\n");
+               else
+                       printk(KERN_INFO DRV_NAME
+                              ": Detected Intel PRO/Wireless 2200BG Network "
+                              "Connection\n");
+
+               priv->ieee->abg_ture = 0;
+               band = IEEE80211_24GHZ_BAND;
+               modulation = IEEE80211_OFDM_MODULATION |
+                       IEEE80211_CCK_MODULATION;
+               priv->adapter = IPW_2200BG;
+               priv->ieee->mode = IEEE_G|IEEE_B;
+       }
+
+       priv->ieee->freq_band = band;
+       priv->ieee->modulation = modulation;
+
+       priv->rates_mask = IEEE80211_DEFAULT_RATES_MASK;
+
+       priv->missed_beacon_threshold = IPW_MB_DISASSOCIATE_THRESHOLD_DEFAULT;
+       priv->roaming_threshold = IPW_MB_ROAMING_THRESHOLD_DEFAULT;
+
+       priv->rts_threshold = DEFAULT_RTS_THRESHOLD;
+
+       /* If power management is turned on, default to AC mode */
+        priv->power_mode = IPW_POWER_AC;
+       priv->tx_power = IPW_DEFAULT_TX_POWER;
+
+       err = request_irq(pdev->irq, ipw_isr, SA_SHIRQ, DRV_NAME,
+                         priv);
+       if (err) {
+               IPW_ERROR("Error allocating IRQ %d\n", pdev->irq);
+               goto out_destroy_workqueue;
+       }
+
+       SET_MODULE_OWNER(net_dev);
+       SET_NETDEV_DEV(net_dev, &pdev->dev);
+
+       priv->ieee->hard_start_xmit = ipw_net_hard_start_xmit;
+       priv->ieee->set_security = shim__set_security;
+
+       net_dev->open = ipw_net_open;
+       net_dev->stop = ipw_net_stop;
+       net_dev->init = ipw_net_init;
+       net_dev->get_stats = ipw_net_get_stats;
+       net_dev->set_multicast_list = ipw_net_set_multicast_list;
+       net_dev->set_mac_address = ipw_net_set_mac_address;
+       net_dev->get_wireless_stats = ipw_get_wireless_stats;
+       net_dev->wireless_handlers = &ipw_wx_handler_def;
+       net_dev->ethtool_ops = &ipw_ethtool_ops;
+       net_dev->irq = pdev->irq;
+       net_dev->base_addr = (unsigned long )priv->hw_base;
+       net_dev->mem_start = pci_resource_start(pdev, 0);
+       net_dev->mem_end = net_dev->mem_start + pci_resource_len(pdev, 0) - 1;
+
+       err = sysfs_create_group(&pdev->dev.kobj, &ipw_attribute_group);
+       if (err) {
+               IPW_ERROR("failed to create sysfs device attributes\n");
+               goto out_release_irq;
+       }
+
+       err = register_netdev(net_dev);
+       if (err) {
+               IPW_ERROR("failed to register network device\n");
+               goto out_remove_group;
+       }
+
+       return 0;
+
+ out_remove_group:
+       sysfs_remove_group(&pdev->dev.kobj, &ipw_attribute_group);
+ out_release_irq:
+       free_irq(pdev->irq, priv);
+ out_destroy_workqueue:
+       destroy_workqueue(priv->workqueue);
+       priv->workqueue = NULL;
+ out_iounmap:
+       iounmap(priv->hw_base);
+ out_pci_release_regions:
+       pci_release_regions(pdev);
+ out_pci_disable_device:
+       pci_disable_device(pdev);
+       pci_set_drvdata(pdev, NULL);
+ out_free_ieee80211:
+       free_ieee80211(priv->net_dev);
+ out:
+       return err;
+}
+
+static void ipw_pci_remove(struct pci_dev *pdev)
+{
+       struct ipw_priv *priv = pci_get_drvdata(pdev);
+       if (!priv)
+               return;
+
+       priv->status |= STATUS_EXIT_PENDING;
+
+       sysfs_remove_group(&pdev->dev.kobj, &ipw_attribute_group);
+
+       ipw_down(priv);
+
+       unregister_netdev(priv->net_dev);
+
+       if (priv->rxq) {
+               ipw_rx_queue_free(priv, priv->rxq);
+               priv->rxq = NULL;
+       }
+       ipw_tx_queue_free(priv);
+
+       /* ipw_down will ensure that there is no more pending work
+        * in the workqueue's, so we can safely remove them now. */
+       if (priv->workqueue) {
+               cancel_delayed_work(&priv->adhoc_check);
+               cancel_delayed_work(&priv->gather_stats);
+               cancel_delayed_work(&priv->request_scan);
+               cancel_delayed_work(&priv->rf_kill);
+               cancel_delayed_work(&priv->scan_check);
+               destroy_workqueue(priv->workqueue);
+               priv->workqueue = NULL;
+       }
+
+       free_irq(pdev->irq, priv);
+       iounmap(priv->hw_base);
+       pci_release_regions(pdev);
+       pci_disable_device(pdev);
+       pci_set_drvdata(pdev, NULL);
+       free_ieee80211(priv->net_dev);
+
+#ifdef CONFIG_PM
+       if (fw_loaded) {
+               release_firmware(bootfw);
+               release_firmware(ucode);
+               release_firmware(firmware);
+               fw_loaded = 0;
+       }
+#endif
+}
+
+
+#ifdef CONFIG_PM
+static int ipw_pci_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+       struct ipw_priv *priv = pci_get_drvdata(pdev);
+       struct net_device *dev = priv->net_dev;
+
+       printk(KERN_INFO "%s: Going into suspend...\n", dev->name);
+
+       /* Take down the device; powers it off, etc. */
+       ipw_down(priv);
+
+       /* Remove the PRESENT state of the device */
+       netif_device_detach(dev);
+
+       pci_save_state(pdev);
+       pci_disable_device(pdev);
+       pci_set_power_state(pdev, pci_choose_state(pdev, state));
+
+       return 0;
+}
+
+static int ipw_pci_resume(struct pci_dev *pdev)
+{
+       struct ipw_priv *priv = pci_get_drvdata(pdev);
+       struct net_device *dev = priv->net_dev;
+       u32 val;
+
+       printk(KERN_INFO "%s: Coming out of suspend...\n", dev->name);
+
+       pci_set_power_state(pdev, 0);
+       pci_enable_device(pdev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
+       pci_restore_state(pdev, priv->pm_state);
+#else
+       pci_restore_state(pdev);
+#endif
+       /*
+        * Suspend/Resume resets the PCI configuration space, so we have to
+        * re-disable the RETRY_TIMEOUT register (0x41) to keep PCI Tx retries
+        * from interfering with C3 CPU state. pci_restore_state won't help
+        * here since it only restores the first 64 bytes pci config header.
+        */
+       pci_read_config_dword(pdev, 0x40, &val);
+       if ((val & 0x0000ff00) != 0)
+               pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
+
+       /* Set the device back into the PRESENT state; this will also wake
+        * the queue of needed */
+       netif_device_attach(dev);
+
+       /* Bring the device back up */
+       queue_work(priv->workqueue, &priv->up);
+
+       return 0;
+}
+#endif
+
+/* driver initialization stuff */
+static struct pci_driver ipw_driver = {
+       .name = DRV_NAME,
+       .id_table = card_ids,
+       .probe = ipw_pci_probe,
+       .remove = __devexit_p(ipw_pci_remove),
+#ifdef CONFIG_PM
+       .suspend = ipw_pci_suspend,
+       .resume = ipw_pci_resume,
+#endif
+};
+
+static int __init ipw_init(void)
+{
+       int ret;
+
+       printk(KERN_INFO DRV_NAME ": " DRV_DESCRIPTION ", " DRV_VERSION "\n");
+       printk(KERN_INFO DRV_NAME ": " DRV_COPYRIGHT "\n");
+
+       ret = pci_module_init(&ipw_driver);
+       if (ret) {
+               IPW_ERROR("Unable to initialize PCI module\n");
+               return ret;
+       }
+
+       ret = driver_create_file(&ipw_driver.driver,
+                                &driver_attr_debug_level);
+       if (ret) {
+               IPW_ERROR("Unable to create driver sysfs file\n");
+               pci_unregister_driver(&ipw_driver);
+               return ret;
+       }
+
+       return ret;
+}
+
+static void __exit ipw_exit(void)
+{
+       driver_remove_file(&ipw_driver.driver, &driver_attr_debug_level);
+       pci_unregister_driver(&ipw_driver);
+}
+
+module_param(disable, int, 0444);
+MODULE_PARM_DESC(disable, "manually disable the radio (default 0 [radio on])");
+
+module_param(associate, int, 0444);
+MODULE_PARM_DESC(associate, "auto associate when scanning (default on)");
+
+module_param(auto_create, int, 0444);
+MODULE_PARM_DESC(auto_create, "auto create adhoc network (default on)");
+
+module_param(debug, int, 0444);
+MODULE_PARM_DESC(debug, "debug output mask");
+
+module_param(channel, int, 0444);
+MODULE_PARM_DESC(channel, "channel to limit associate to (default 0 [ANY])");
+
+module_param(ifname, charp, 0444);
+MODULE_PARM_DESC(ifname, "network device name (default eth%d)");
+
+#ifdef CONFIG_IPW_PROMISC
+module_param(mode, int, 0444);
+MODULE_PARM_DESC(mode, "network mode (0=BSS,1=IBSS,2=Monitor)");
+#else
+module_param(mode, int, 0444);
+MODULE_PARM_DESC(mode, "network mode (0=BSS,1=IBSS)");
+#endif
+
+module_exit(ipw_exit);
+module_init(ipw_init);
diff --git a/drivers/net/wireless/ipw2200.h b/drivers/net/wireless/ipw2200.h
new file mode 100644 (file)
index 0000000..66bb590
--- /dev/null
@@ -0,0 +1,1744 @@
+/******************************************************************************
+
+  Copyright(c) 2003 - 2004 Intel Corporation. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms of version 2 of the GNU General Public License as
+  published by the Free Software Foundation.
+
+  This program is distributed in the hope that it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc., 59
+  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+  The full GNU General Public License is included in this distribution in the
+  file called LICENSE.
+
+  Contact Information:
+  James P. Ketrenos <ipw2100-admin@linux.intel.com>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+******************************************************************************/
+
+#ifndef __ipw2200_h__
+#define __ipw2200_h__
+
+#define WEXT_USECHANNELS 1
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/config.h>
+#include <linux/init.h>
+
+#include <linux/version.h>
+#include <linux/pci.h>
+#include <linux/netdevice.h>
+#include <linux/ethtool.h>
+#include <linux/skbuff.h>
+#include <linux/etherdevice.h>
+#include <linux/delay.h>
+#include <linux/random.h>
+#include <linux/dma-mapping.h>
+
+#include <linux/firmware.h>
+#include <linux/wireless.h>
+#include <linux/dma-mapping.h>
+#include <asm/io.h>
+
+#include <net/ieee80211.h>
+
+#define DRV_NAME       "ipw2200"
+
+#include <linux/workqueue.h>
+
+/* Authentication  and Association States */
+enum connection_manager_assoc_states
+{
+       CMAS_INIT = 0,
+       CMAS_TX_AUTH_SEQ_1,
+       CMAS_RX_AUTH_SEQ_2,
+       CMAS_AUTH_SEQ_1_PASS,
+       CMAS_AUTH_SEQ_1_FAIL,
+       CMAS_TX_AUTH_SEQ_3,
+       CMAS_RX_AUTH_SEQ_4,
+       CMAS_AUTH_SEQ_2_PASS,
+       CMAS_AUTH_SEQ_2_FAIL,
+       CMAS_AUTHENTICATED,
+       CMAS_TX_ASSOC,
+       CMAS_RX_ASSOC_RESP,
+       CMAS_ASSOCIATED,
+       CMAS_LAST
+};
+
+
+#define IPW_WAIT                     (1<<0)
+#define IPW_QUIET                    (1<<1)
+#define IPW_ROAMING                  (1<<2)
+
+#define IPW_POWER_MODE_CAM           0x00      //(always on)
+#define IPW_POWER_INDEX_1            0x01
+#define IPW_POWER_INDEX_2            0x02
+#define IPW_POWER_INDEX_3            0x03
+#define IPW_POWER_INDEX_4            0x04
+#define IPW_POWER_INDEX_5            0x05
+#define IPW_POWER_AC                 0x06
+#define IPW_POWER_BATTERY            0x07
+#define IPW_POWER_LIMIT              0x07
+#define IPW_POWER_MASK               0x0F
+#define IPW_POWER_ENABLED            0x10
+#define IPW_POWER_LEVEL(x)           ((x) & IPW_POWER_MASK)
+
+#define IPW_CMD_HOST_COMPLETE                 2
+#define IPW_CMD_POWER_DOWN                    4
+#define IPW_CMD_SYSTEM_CONFIG                 6
+#define IPW_CMD_MULTICAST_ADDRESS             7
+#define IPW_CMD_SSID                          8
+#define IPW_CMD_ADAPTER_ADDRESS              11
+#define IPW_CMD_PORT_TYPE                    12
+#define IPW_CMD_RTS_THRESHOLD                15
+#define IPW_CMD_FRAG_THRESHOLD               16
+#define IPW_CMD_POWER_MODE                   17
+#define IPW_CMD_WEP_KEY                      18
+#define IPW_CMD_TGI_TX_KEY                   19
+#define IPW_CMD_SCAN_REQUEST                 20
+#define IPW_CMD_ASSOCIATE                    21
+#define IPW_CMD_SUPPORTED_RATES              22
+#define IPW_CMD_SCAN_ABORT                   23
+#define IPW_CMD_TX_FLUSH                     24
+#define IPW_CMD_QOS_PARAMETERS               25
+#define IPW_CMD_SCAN_REQUEST_EXT             26
+#define IPW_CMD_DINO_CONFIG                  30
+#define IPW_CMD_RSN_CAPABILITIES             31
+#define IPW_CMD_RX_KEY                       32
+#define IPW_CMD_CARD_DISABLE                 33
+#define IPW_CMD_SEED_NUMBER                  34
+#define IPW_CMD_TX_POWER                     35
+#define IPW_CMD_COUNTRY_INFO                 36
+#define IPW_CMD_AIRONET_INFO                 37
+#define IPW_CMD_AP_TX_POWER                  38
+#define IPW_CMD_CCKM_INFO                    39
+#define IPW_CMD_CCX_VER_INFO                 40
+#define IPW_CMD_SET_CALIBRATION              41
+#define IPW_CMD_SENSITIVITY_CALIB            42
+#define IPW_CMD_RETRY_LIMIT                  51
+#define IPW_CMD_IPW_PRE_POWER_DOWN           58
+#define IPW_CMD_VAP_BEACON_TEMPLATE          60
+#define IPW_CMD_VAP_DTIM_PERIOD              61
+#define IPW_CMD_EXT_SUPPORTED_RATES          62
+#define IPW_CMD_VAP_LOCAL_TX_PWR_CONSTRAINT  63
+#define IPW_CMD_VAP_QUIET_INTERVALS          64
+#define IPW_CMD_VAP_CHANNEL_SWITCH           65
+#define IPW_CMD_VAP_MANDATORY_CHANNELS       66
+#define IPW_CMD_VAP_CELL_PWR_LIMIT           67
+#define IPW_CMD_VAP_CF_PARAM_SET             68
+#define IPW_CMD_VAP_SET_BEACONING_STATE      69
+#define IPW_CMD_MEASUREMENT                  80
+#define IPW_CMD_POWER_CAPABILITY             81
+#define IPW_CMD_SUPPORTED_CHANNELS           82
+#define IPW_CMD_TPC_REPORT                   83
+#define IPW_CMD_WME_INFO                     84
+#define IPW_CMD_PRODUCTION_COMMAND          85
+#define IPW_CMD_LINKSYS_EOU_INFO             90
+
+#define RFD_SIZE                              4
+#define NUM_TFD_CHUNKS                        6
+
+#define TX_QUEUE_SIZE                        32
+#define RX_QUEUE_SIZE                        32
+
+#define DINO_CMD_WEP_KEY                   0x08
+#define DINO_CMD_TX                        0x0B
+#define DCT_ANTENNA_A                      0x01
+#define DCT_ANTENNA_B                      0x02
+
+#define IPW_A_MODE                         0
+#define IPW_B_MODE                         1
+#define IPW_G_MODE                         2
+
+/*
+ * TX Queue Flag Definitions
+ */
+
+/* abort attempt if mgmt frame is rx'd */
+#define DCT_FLAG_ABORT_MGMT                0x01
+
+/* require CTS */
+#define DCT_FLAG_CTS_REQUIRED              0x02
+
+/* use short preamble */
+#define DCT_FLAG_SHORT_PREMBL              0x04
+
+/* RTS/CTS first */
+#define DCT_FLAG_RTS_REQD                  0x08
+
+/* dont calculate duration field */
+#define DCT_FLAG_DUR_SET                   0x10
+
+/* even if MAC WEP set (allows pre-encrypt) */
+#define DCT_FLAG_NO_WEP              0x20
+
+/* overwrite TSF field */
+#define DCT_FLAG_TSF_REQD                  0x40
+
+/* ACK rx is expected to follow */
+#define DCT_FLAG_ACK_REQD                  0x80
+
+#define DCT_FLAG_EXT_MODE_CCK  0x01
+#define DCT_FLAG_EXT_MODE_OFDM 0x00
+
+
+#define TX_RX_TYPE_MASK                    0xFF
+#define TX_FRAME_TYPE                      0x00
+#define TX_HOST_COMMAND_TYPE               0x01
+#define RX_FRAME_TYPE                      0x09
+#define RX_HOST_NOTIFICATION_TYPE          0x03
+#define RX_HOST_CMD_RESPONSE_TYPE          0x04
+#define RX_TX_FRAME_RESPONSE_TYPE          0x05
+#define TFD_NEED_IRQ_MASK                  0x04
+
+#define HOST_CMD_DINO_CONFIG               30
+
+#define HOST_NOTIFICATION_STATUS_ASSOCIATED             10
+#define HOST_NOTIFICATION_STATUS_AUTHENTICATE           11
+#define HOST_NOTIFICATION_STATUS_SCAN_CHANNEL_RESULT    12
+#define HOST_NOTIFICATION_STATUS_SCAN_COMPLETED         13
+#define HOST_NOTIFICATION_STATUS_FRAG_LENGTH            14
+#define HOST_NOTIFICATION_STATUS_LINK_DETERIORATION     15
+#define HOST_NOTIFICATION_DINO_CONFIG_RESPONSE          16
+#define HOST_NOTIFICATION_STATUS_BEACON_STATE           17
+#define HOST_NOTIFICATION_STATUS_TGI_TX_KEY             18
+#define HOST_NOTIFICATION_TX_STATUS                     19
+#define HOST_NOTIFICATION_CALIB_KEEP_RESULTS            20
+#define HOST_NOTIFICATION_MEASUREMENT_STARTED           21
+#define HOST_NOTIFICATION_MEASUREMENT_ENDED             22
+#define HOST_NOTIFICATION_CHANNEL_SWITCHED              23
+#define HOST_NOTIFICATION_RX_DURING_QUIET_PERIOD        24
+#define HOST_NOTIFICATION_NOISE_STATS                  25
+#define HOST_NOTIFICATION_S36_MEASUREMENT_ACCEPTED      30
+#define HOST_NOTIFICATION_S36_MEASUREMENT_REFUSED       31
+
+#define HOST_NOTIFICATION_STATUS_BEACON_MISSING         1
+#define IPW_MB_DISASSOCIATE_THRESHOLD_DEFAULT           24
+#define IPW_MB_ROAMING_THRESHOLD_DEFAULT                8
+#define IPW_REAL_RATE_RX_PACKET_THRESHOLD               300
+
+#define MACADRR_BYTE_LEN                     6
+
+#define DCR_TYPE_AP                       0x01
+#define DCR_TYPE_WLAP                     0x02
+#define DCR_TYPE_MU_ESS                   0x03
+#define DCR_TYPE_MU_IBSS                  0x04
+#define DCR_TYPE_MU_PIBSS                 0x05
+#define DCR_TYPE_SNIFFER                  0x06
+#define DCR_TYPE_MU_BSS        DCR_TYPE_MU_ESS
+
+/**
+ * Generic queue structure
+ *
+ * Contains common data for Rx and Tx queues
+ */
+struct clx2_queue {
+       int n_bd;                      /**< number of BDs in this queue */
+       int first_empty;               /**< 1-st empty entry (index) */
+       int last_used;                 /**< last used entry (index) */
+       u32 reg_w;                   /**< 'write' reg (queue head), addr in domain 1 */
+       u32 reg_r;                   /**< 'read' reg (queue tail), addr in domain 1 */
+       dma_addr_t dma_addr;            /**< physical addr for BD's */
+       int low_mark;                  /**< low watermark, resume queue if free space more than this */
+       int high_mark;                 /**< high watermark, stop queue if free space less than this */
+} __attribute__ ((packed));
+
+struct machdr32
+{
+       u16 frame_ctl;
+       u16 duration;     // watch out for endians!
+       u8 addr1[ MACADRR_BYTE_LEN ];
+       u8 addr2[ MACADRR_BYTE_LEN ];
+       u8 addr3[ MACADRR_BYTE_LEN ];
+       u16 seq_ctrl;     // more endians!
+       u8 addr4[ MACADRR_BYTE_LEN ];
+       u16 qos_ctrl;
+} __attribute__ ((packed)) ;
+
+struct machdr30
+{
+       u16 frame_ctl;
+       u16 duration;     // watch out for endians!
+       u8 addr1[ MACADRR_BYTE_LEN ];
+       u8 addr2[ MACADRR_BYTE_LEN ];
+       u8 addr3[ MACADRR_BYTE_LEN ];
+       u16 seq_ctrl;     // more endians!
+       u8 addr4[ MACADRR_BYTE_LEN ];
+} __attribute__ ((packed)) ;
+
+struct machdr26
+{
+       u16 frame_ctl;
+       u16 duration;     // watch out for endians!
+       u8 addr1[ MACADRR_BYTE_LEN ];
+       u8 addr2[ MACADRR_BYTE_LEN ];
+       u8 addr3[ MACADRR_BYTE_LEN ];
+       u16 seq_ctrl;     // more endians!
+       u16 qos_ctrl;
+} __attribute__ ((packed)) ;
+
+struct machdr24
+{
+       u16 frame_ctl;
+       u16 duration;     // watch out for endians!
+       u8 addr1[ MACADRR_BYTE_LEN ];
+       u8 addr2[ MACADRR_BYTE_LEN ];
+       u8 addr3[ MACADRR_BYTE_LEN ];
+       u16 seq_ctrl;     // more endians!
+} __attribute__ ((packed)) ;
+
+// TX TFD with 32 byte MAC Header
+struct tx_tfd_32
+{
+       struct machdr32    mchdr;                      // 32
+       u32                uivplaceholder[2];          // 8
+} __attribute__ ((packed)) ;
+
+// TX TFD with 30 byte MAC Header
+struct tx_tfd_30
+{
+       struct machdr30    mchdr;                      // 30
+       u8                 reserved[2];                // 2
+       u32                uivplaceholder[2];          // 8
+} __attribute__ ((packed)) ;
+
+// tx tfd with 26 byte mac header
+struct tx_tfd_26
+{
+       struct machdr26    mchdr;                      // 26
+       u8                 reserved1[2];               // 2
+       u32                uivplaceholder[2];          // 8
+       u8                 reserved2[4];               // 4
+} __attribute__ ((packed)) ;
+
+// tx tfd with 24 byte mac header
+struct tx_tfd_24
+{
+       struct machdr24    mchdr;                      // 24
+       u32                uivplaceholder[2];          // 8
+       u8                 reserved[8];                // 8
+} __attribute__ ((packed)) ;
+
+
+#define DCT_WEP_KEY_FIELD_LENGTH 16
+
+struct tfd_command
+{
+       u8 index;
+       u8 length;
+       u16 reserved;
+       u8 payload[0];
+} __attribute__ ((packed)) ;
+
+struct tfd_data {
+       /* Header */
+       u32 work_area_ptr;
+       u8 station_number; /* 0 for BSS */
+       u8 reserved1;
+       u16 reserved2;
+
+       /* Tx Parameters */
+       u8 cmd_id;
+       u8 seq_num;
+       u16 len;
+       u8 priority;
+       u8 tx_flags;
+       u8 tx_flags_ext;
+       u8 key_index;
+       u8 wepkey[DCT_WEP_KEY_FIELD_LENGTH];
+       u8 rate;
+       u8 antenna;
+       u16 next_packet_duration;
+       u16 next_frag_len;
+       u16 back_off_counter; //////txop;
+       u8 retrylimit;
+       u16 cwcurrent;
+       u8 reserved3;
+
+       /* 802.11 MAC Header */
+       union
+       {
+               struct tx_tfd_24 tfd_24;
+               struct tx_tfd_26 tfd_26;
+               struct tx_tfd_30 tfd_30;
+               struct tx_tfd_32 tfd_32;
+       } tfd;
+
+       /* Payload DMA info */
+       u32 num_chunks;
+       u32 chunk_ptr[NUM_TFD_CHUNKS];
+       u16 chunk_len[NUM_TFD_CHUNKS];
+} __attribute__ ((packed));
+
+struct txrx_control_flags
+{
+       u8 message_type;
+       u8 rx_seq_num;
+       u8 control_bits;
+       u8 reserved;
+} __attribute__ ((packed));
+
+#define  TFD_SIZE                           128
+#define  TFD_CMD_IMMEDIATE_PAYLOAD_LENGTH   (TFD_SIZE - sizeof(struct txrx_control_flags))
+
+struct tfd_frame
+{
+       struct txrx_control_flags control_flags;
+       union {
+               struct tfd_data data;
+               struct tfd_command cmd;
+               u8 raw[TFD_CMD_IMMEDIATE_PAYLOAD_LENGTH];
+       } u;
+} __attribute__ ((packed)) ;
+
+typedef void destructor_func(const void*);
+
+/**
+ * Tx Queue for DMA. Queue consists of circular buffer of
+ * BD's and required locking structures.
+ */
+struct clx2_tx_queue {
+       struct clx2_queue q;
+       struct tfd_frame* bd;
+       struct ieee80211_txb **txb;
+};
+
+/*
+ * RX related structures and functions
+ */
+#define RX_FREE_BUFFERS 32
+#define RX_LOW_WATERMARK 8
+
+#define SUP_RATE_11A_MAX_NUM_CHANNELS  (8)
+#define SUP_RATE_11B_MAX_NUM_CHANNELS  (4)
+#define SUP_RATE_11G_MAX_NUM_CHANNELS  (12)
+
+// Used for passing to driver number of successes and failures per rate
+struct rate_histogram
+{
+       union {
+               u32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
+               u32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
+               u32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
+       } success;
+       union {
+               u32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
+               u32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
+               u32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
+       } failed;
+} __attribute__ ((packed));
+
+/* statistics command response */
+struct ipw_cmd_stats {
+       u8 cmd_id;
+       u8 seq_num;
+       u16 good_sfd;
+       u16 bad_plcp;
+       u16 wrong_bssid;
+       u16 valid_mpdu;
+       u16 bad_mac_header;
+       u16 reserved_frame_types;
+       u16 rx_ina;
+       u16 bad_crc32;
+       u16 invalid_cts;
+       u16 invalid_acks;
+       u16 long_distance_ina_fina;
+       u16 dsp_silence_unreachable;
+       u16 accumulated_rssi;
+       u16 rx_ovfl_frame_tossed;
+       u16 rssi_silence_threshold;
+       u16 rx_ovfl_frame_supplied;
+       u16 last_rx_frame_signal;
+       u16 last_rx_frame_noise;
+       u16 rx_autodetec_no_ofdm;
+       u16 rx_autodetec_no_barker;
+       u16 reserved;
+} __attribute__ ((packed));
+
+struct notif_channel_result {
+       u8 channel_num;
+       struct ipw_cmd_stats stats;
+       u8 uReserved;
+} __attribute__ ((packed));
+
+struct notif_scan_complete {
+       u8 scan_type;
+       u8 num_channels;
+       u8 status;
+       u8 reserved;
+}  __attribute__ ((packed));
+
+struct notif_frag_length {
+       u16 frag_length;
+       u16 reserved;
+}  __attribute__ ((packed));
+
+struct notif_beacon_state {
+       u32 state;
+       u32 number;
+} __attribute__ ((packed));
+
+struct notif_tgi_tx_key {
+       u8 key_state;
+       u8 security_type;
+       u8 station_index;
+       u8 reserved;
+} __attribute__ ((packed));
+
+struct notif_link_deterioration {
+       struct ipw_cmd_stats stats;
+       u8 rate;
+       u8 modulation;
+       struct rate_histogram histogram;
+       u8 reserved1;
+       u16 reserved2;
+} __attribute__ ((packed));
+
+struct notif_association {
+       u8 state;
+} __attribute__ ((packed));
+
+struct notif_authenticate {
+       u8 state;
+       struct machdr24 addr;
+       u16 status;
+} __attribute__ ((packed));
+
+struct notif_calibration {
+       u8 data[104];
+} __attribute__ ((packed));
+
+struct notif_noise {
+       u32 value;
+} __attribute__ ((packed));
+
+struct ipw_rx_notification {
+       u8 reserved[8];
+       u8 subtype;
+       u8 flags;
+       u16 size;
+       union {
+               struct notif_association assoc;
+               struct notif_authenticate auth;
+               struct notif_channel_result channel_result;
+               struct notif_scan_complete scan_complete;
+               struct notif_frag_length frag_len;
+               struct notif_beacon_state beacon_state;
+               struct notif_tgi_tx_key tgi_tx_key;
+               struct notif_link_deterioration link_deterioration;
+               struct notif_calibration calibration;
+               struct notif_noise noise;
+               u8 raw[0];
+       } u;
+} __attribute__ ((packed));
+
+struct ipw_rx_frame {
+       u32 reserved1;
+       u8 parent_tsf[4];     // fw_use[0] is boolean for OUR_TSF_IS_GREATER
+       u8 received_channel;  // The channel that this frame was received on.
+                             // Note that for .11b this does not have to be
+                             // the same as the channel that it was sent.
+                              // Filled by LMAC
+       u8 frameStatus;
+       u8 rate;
+       u8 rssi;
+       u8 agc;
+       u8 rssi_dbm;
+       u16 signal;
+       u16 noise;
+       u8 antennaAndPhy;
+       u8 control;           // control bit should be on in bg
+       u8 rtscts_rate;       // rate of rts or cts (in rts cts sequence rate
+                             // is identical)
+       u8 rtscts_seen;       // 0x1 RTS seen ; 0x2 CTS seen
+       u16 length;
+       u8 data[0];
+} __attribute__ ((packed));
+
+struct ipw_rx_header {
+       u8 message_type;
+       u8 rx_seq_num;
+       u8 control_bits;
+       u8 reserved;
+} __attribute__ ((packed));
+
+struct ipw_rx_packet
+{
+       struct ipw_rx_header header;
+       union {
+               struct ipw_rx_frame frame;
+               struct ipw_rx_notification notification;
+       } u;
+} __attribute__ ((packed));
+
+#define IPW_RX_NOTIFICATION_SIZE sizeof(struct ipw_rx_header) + 12
+#define IPW_RX_FRAME_SIZE        sizeof(struct ipw_rx_header) + \
+                                 sizeof(struct ipw_rx_frame)
+
+struct ipw_rx_mem_buffer {
+       dma_addr_t dma_addr;
+       struct ipw_rx_buffer *rxb;
+       struct sk_buff *skb;
+       struct list_head list;
+}; /* Not transferred over network, so not  __attribute__ ((packed)) */
+
+struct ipw_rx_queue {
+       struct ipw_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS];
+       struct ipw_rx_mem_buffer *queue[RX_QUEUE_SIZE];
+       u32 processed; /* Internal index to last handled Rx packet */
+       u32 read;      /* Shared index to newest available Rx buffer */
+       u32 write;     /* Shared index to oldest written Rx packet */
+       u32 free_count;/* Number of pre-allocated buffers in rx_free */
+       /* Each of these lists is used as a FIFO for ipw_rx_mem_buffers */
+       struct list_head rx_free;  /* Own an SKBs */
+       struct list_head rx_used;  /* No SKB allocated */
+       spinlock_t lock;
+}; /* Not transferred over network, so not  __attribute__ ((packed)) */
+
+
+struct alive_command_responce {
+       u8 alive_command;
+       u8 sequence_number;
+       u16 software_revision;
+       u8 device_identifier;
+       u8 reserved1[5];
+       u16 reserved2;
+       u16 reserved3;
+       u16 clock_settle_time;
+       u16 powerup_settle_time;
+       u16 reserved4;
+       u8 time_stamp[5];       /* month, day, year, hours, minutes */
+       u8 ucode_valid;
+} __attribute__ ((packed));
+
+#define IPW_MAX_RATES 12
+
+struct ipw_rates {
+       u8 num_rates;
+       u8 rates[IPW_MAX_RATES];
+} __attribute__ ((packed));
+
+struct command_block
+{
+       unsigned int control;
+       u32 source_addr;
+       u32 dest_addr;
+       unsigned int status;
+} __attribute__ ((packed));
+
+#define CB_NUMBER_OF_ELEMENTS_SMALL 64
+struct fw_image_desc
+{
+       unsigned long last_cb_index;
+       unsigned long current_cb_index;
+       struct command_block cb_list[CB_NUMBER_OF_ELEMENTS_SMALL];
+       void * v_addr;
+       unsigned long p_addr;
+       unsigned long len;
+};
+
+struct ipw_sys_config
+{
+       u8 bt_coexistence;
+       u8 reserved1;
+       u8 answer_broadcast_ssid_probe;
+       u8 accept_all_data_frames;
+       u8 accept_non_directed_frames;
+       u8 exclude_unicast_unencrypted;
+       u8 disable_unicast_decryption;
+       u8 exclude_multicast_unencrypted;
+       u8 disable_multicast_decryption;
+       u8 antenna_diversity;
+       u8 pass_crc_to_host;
+       u8 dot11g_auto_detection;
+       u8 enable_cts_to_self;
+       u8 enable_multicast_filtering;
+       u8 bt_coexist_collision_thr;
+       u8 reserved2;
+       u8 accept_all_mgmt_bcpr;
+       u8 accept_all_mgtm_frames;
+       u8 pass_noise_stats_to_host;
+       u8 reserved3;
+} __attribute__ ((packed));
+
+struct ipw_multicast_addr
+{
+       u8 num_of_multicast_addresses;
+       u8 reserved[3];
+       u8 mac1[6];
+       u8 mac2[6];
+       u8 mac3[6];
+       u8 mac4[6];
+} __attribute__ ((packed));
+
+struct ipw_wep_key
+{
+       u8 cmd_id;
+       u8 seq_num;
+       u8 key_index;
+       u8 key_size;
+       u8 key[16];
+} __attribute__ ((packed));
+
+struct ipw_tgi_tx_key
+{
+       u8 key_id;
+       u8 security_type;
+       u8 station_index;
+       u8 flags;
+       u8 key[16];
+       u32 tx_counter[2];
+} __attribute__ ((packed));
+
+#define IPW_SCAN_CHANNELS 54
+
+struct ipw_scan_request
+{
+       u8 scan_type;
+       u16 dwell_time;
+       u8 channels_list[IPW_SCAN_CHANNELS];
+       u8 channels_reserved[3];
+} __attribute__ ((packed));
+
+enum {
+       IPW_SCAN_PASSIVE_TILL_FIRST_BEACON_SCAN = 0,
+       IPW_SCAN_PASSIVE_FULL_DWELL_SCAN,
+       IPW_SCAN_ACTIVE_DIRECT_SCAN,
+       IPW_SCAN_ACTIVE_BROADCAST_SCAN,
+       IPW_SCAN_ACTIVE_BROADCAST_AND_DIRECT_SCAN,
+       IPW_SCAN_TYPES
+};
+
+struct ipw_scan_request_ext
+{
+       u32 full_scan_index;
+       u8 channels_list[IPW_SCAN_CHANNELS];
+       u8 scan_type[IPW_SCAN_CHANNELS / 2];
+       u8 reserved;
+       u16 dwell_time[IPW_SCAN_TYPES];
+} __attribute__ ((packed));
+
+extern inline u8 ipw_get_scan_type(struct ipw_scan_request_ext *scan, u8 index)
+{
+       if (index % 2)
+               return scan->scan_type[index / 2] & 0x0F;
+       else
+               return (scan->scan_type[index / 2] & 0xF0) >> 4;
+}
+
+extern inline void ipw_set_scan_type(struct ipw_scan_request_ext *scan,
+                                    u8 index, u8 scan_type)
+{
+       if (index % 2)
+               scan->scan_type[index / 2] =
+                       (scan->scan_type[index / 2] & 0xF0) |
+                       (scan_type & 0x0F);
+       else
+               scan->scan_type[index / 2] =
+                       (scan->scan_type[index / 2] & 0x0F) |
+                       ((scan_type & 0x0F) << 4);
+}
+
+struct ipw_associate
+{
+       u8 channel;
+       u8 auth_type:4,
+          auth_key:4;
+       u8 assoc_type;
+       u8 reserved;
+       u16 policy_support;
+       u8 preamble_length;
+       u8 ieee_mode;
+       u8 bssid[ETH_ALEN];
+       u32 assoc_tsf_msw;
+       u32 assoc_tsf_lsw;
+       u16 capability;
+       u16 listen_interval;
+       u16 beacon_interval;
+       u8 dest[ETH_ALEN];
+       u16 atim_window;
+       u8 smr;
+       u8 reserved1;
+       u16 reserved2;
+} __attribute__ ((packed));
+
+struct ipw_supported_rates
+{
+       u8 ieee_mode;
+       u8 num_rates;
+       u8 purpose;
+       u8 reserved;
+       u8 supported_rates[IPW_MAX_RATES];
+} __attribute__ ((packed));
+
+struct ipw_rts_threshold
+{
+       u16 rts_threshold;
+       u16 reserved;
+} __attribute__ ((packed));
+
+struct ipw_frag_threshold
+{
+       u16 frag_threshold;
+       u16 reserved;
+} __attribute__ ((packed));
+
+struct ipw_retry_limit
+{
+       u8 short_retry_limit;
+       u8 long_retry_limit;
+       u16 reserved;
+} __attribute__ ((packed));
+
+struct ipw_dino_config
+{
+       u32 dino_config_addr;
+       u16 dino_config_size;
+       u8 dino_response;
+       u8 reserved;
+} __attribute__ ((packed));
+
+struct ipw_aironet_info
+{
+       u8 id;
+       u8 length;
+       u16 reserved;
+} __attribute__ ((packed));
+
+struct ipw_rx_key
+{
+       u8 station_index;
+       u8 key_type;
+       u8 key_id;
+       u8 key_flag;
+       u8 key[16];
+       u8 station_address[6];
+       u8 key_index;
+       u8 reserved;
+} __attribute__ ((packed));
+
+struct ipw_country_channel_info
+{
+       u8 first_channel;
+       u8 no_channels;
+       s8 max_tx_power;
+} __attribute__ ((packed));
+
+struct ipw_country_info
+{
+       u8 id;
+       u8 length;
+       u8 country_str[3];
+       struct ipw_country_channel_info groups[7];
+} __attribute__ ((packed));
+
+struct ipw_channel_tx_power
+{
+       u8 channel_number;
+       s8 tx_power;
+} __attribute__ ((packed));
+
+#define SCAN_ASSOCIATED_INTERVAL (HZ)
+#define SCAN_INTERVAL (HZ / 10)
+#define MAX_A_CHANNELS  37
+#define MAX_B_CHANNELS  14
+
+struct ipw_tx_power
+{
+       u8 num_channels;
+       u8 ieee_mode;
+       struct ipw_channel_tx_power channels_tx_power[MAX_A_CHANNELS];
+} __attribute__ ((packed));
+
+struct ipw_qos_parameters
+{
+       u16 cw_min[4];
+       u16 cw_max[4];
+       u8 aifs[4];
+       u8 flag[4];
+       u16 tx_op_limit[4];
+} __attribute__ ((packed));
+
+struct ipw_rsn_capabilities
+{
+       u8 id;
+       u8 length;
+       u16 version;
+} __attribute__ ((packed));
+
+struct ipw_sensitivity_calib
+{
+       u16 beacon_rssi_raw;
+       u16 reserved;
+} __attribute__ ((packed));
+
+/**
+ * Host command structure.
+ *
+ * On input, the following fields should be filled:
+ * - cmd
+ * - len
+ * - status_len
+ * - param (if needed)
+ *
+ * On output,
+ * - \a status contains status;
+ * - \a param filled with status parameters.
+ */
+struct ipw_cmd {
+  u32 cmd;         /**< Host command */
+  u32 status;      /**< Status */
+  u32 status_len;  /**< How many 32 bit parameters in the status */
+  u32 len;         /**< incoming parameters length, bytes */
+  /**
+   * command parameters.
+   * There should be enough space for incoming and
+   * outcoming parameters.
+   * Incoming parameters listed 1-st, followed by outcoming params.
+   * nParams=(len+3)/4+status_len
+   */
+  u32 param[0];
+} __attribute__ ((packed));
+
+#define STATUS_HCMD_ACTIVE      (1<<0)  /**< host command in progress */
+
+#define STATUS_INT_ENABLED      (1<<1)
+#define STATUS_RF_KILL_HW       (1<<2)
+#define STATUS_RF_KILL_SW       (1<<3)
+#define STATUS_RF_KILL_MASK     (STATUS_RF_KILL_HW | STATUS_RF_KILL_SW)
+
+#define STATUS_INIT             (1<<5)
+#define STATUS_AUTH             (1<<6)
+#define STATUS_ASSOCIATED       (1<<7)
+#define STATUS_STATE_MASK       (STATUS_INIT | STATUS_AUTH | STATUS_ASSOCIATED)
+
+#define STATUS_ASSOCIATING      (1<<8)
+#define STATUS_DISASSOCIATING   (1<<9)
+#define STATUS_ROAMING          (1<<10)
+#define STATUS_EXIT_PENDING     (1<<11)
+#define STATUS_DISASSOC_PENDING (1<<12)
+#define STATUS_STATE_PENDING    (1<<13)
+
+#define STATUS_SCAN_PENDING     (1<<20)
+#define STATUS_SCANNING         (1<<21)
+#define STATUS_SCAN_ABORTING    (1<<22)
+
+#define STATUS_INDIRECT_BYTE    (1<<28) /* sysfs entry configured for access */
+#define STATUS_INDIRECT_DWORD   (1<<29) /* sysfs entry configured for access */
+#define STATUS_DIRECT_DWORD     (1<<30) /* sysfs entry configured for access */
+
+#define STATUS_SECURITY_UPDATED (1<<31) /* Security sync needed */
+
+#define CFG_STATIC_CHANNEL      (1<<0) /* Restrict assoc. to single channel */
+#define CFG_STATIC_ESSID        (1<<1) /* Restrict assoc. to single SSID */
+#define CFG_STATIC_BSSID        (1<<2) /* Restrict assoc. to single BSSID */
+#define CFG_CUSTOM_MAC          (1<<3)
+#define CFG_PREAMBLE            (1<<4)
+#define CFG_ADHOC_PERSIST       (1<<5)
+#define CFG_ASSOCIATE           (1<<6)
+#define CFG_FIXED_RATE          (1<<7)
+#define CFG_ADHOC_CREATE        (1<<8)
+
+#define CAP_SHARED_KEY          (1<<0) /* Off = OPEN */
+#define CAP_PRIVACY_ON          (1<<1) /* Off = No privacy */
+
+#define MAX_STATIONS            32
+#define IPW_INVALID_STATION     (0xff)
+
+struct ipw_station_entry {
+       u8 mac_addr[ETH_ALEN];
+       u8 reserved;
+       u8 support_mode;
+};
+
+#define AVG_ENTRIES 8
+struct average {
+       s16 entries[AVG_ENTRIES];
+       u8 pos;
+       u8 init;
+       s32 sum;
+};
+
+struct ipw_priv {
+       /* ieee device used by generic ieee processing code */
+       struct ieee80211_device *ieee;
+       struct ieee80211_security sec;
+
+       /* spinlock */
+       spinlock_t lock;
+
+       /* basic pci-network driver stuff */
+       struct pci_dev *pci_dev;
+       struct net_device *net_dev;
+
+       /* pci hardware address support */
+       void __iomem *hw_base;
+       unsigned long hw_len;
+
+       struct fw_image_desc sram_desc;
+
+       /* result of ucode download */
+       struct alive_command_responce dino_alive;
+
+       wait_queue_head_t wait_command_queue;
+       wait_queue_head_t wait_state;
+
+       /* Rx and Tx DMA processing queues */
+       struct ipw_rx_queue *rxq;
+       struct clx2_tx_queue txq_cmd;
+       struct clx2_tx_queue txq[4];
+       u32 status;
+       u32 config;
+       u32 capability;
+
+       u8 last_rx_rssi;
+       u8 last_noise;
+       struct average average_missed_beacons;
+       struct average average_rssi;
+       struct average average_noise;
+       u32 port_type;
+       int rx_bufs_min;          /**< minimum number of bufs in Rx queue */
+       int rx_pend_max;          /**< maximum pending buffers for one IRQ */
+       u32 hcmd_seq;             /**< sequence number for hcmd */
+       u32 missed_beacon_threshold;
+       u32 roaming_threshold;
+
+       struct ipw_associate assoc_request;
+       struct ieee80211_network *assoc_network;
+
+       unsigned long ts_scan_abort;
+       struct ipw_supported_rates rates;
+       struct ipw_rates phy[3];           /**< PHY restrictions, per band */
+       struct ipw_rates supp;             /**< software defined */
+       struct ipw_rates extended;         /**< use for corresp. IE, AP only */
+
+       struct notif_link_deterioration last_link_deterioration; /** for statistics */
+       struct ipw_cmd* hcmd; /**< host command currently executed */
+
+       wait_queue_head_t hcmd_wq;     /**< host command waits for execution */
+       u32 tsf_bcn[2];              /**< TSF from latest beacon */
+
+       struct notif_calibration calib; /**< last calibration */
+
+       /* ordinal interface with firmware */
+       u32 table0_addr;
+       u32 table0_len;
+       u32 table1_addr;
+       u32 table1_len;
+       u32 table2_addr;
+       u32 table2_len;
+
+       /* context information */
+       u8 essid[IW_ESSID_MAX_SIZE];
+       u8 essid_len;
+       u8 nick[IW_ESSID_MAX_SIZE];
+       u16 rates_mask;
+       u8 channel;
+       struct ipw_sys_config sys_config;
+       u32 power_mode;
+       u8 bssid[ETH_ALEN];
+       u16 rts_threshold;
+       u8 mac_addr[ETH_ALEN];
+       u8 num_stations;
+       u8 stations[MAX_STATIONS][ETH_ALEN];
+
+       u32 notif_missed_beacons;
+
+       /* Statistics and counters normalized with each association */
+       u32 last_missed_beacons;
+       u32 last_tx_packets;
+       u32 last_rx_packets;
+       u32 last_tx_failures;
+       u32 last_rx_err;
+       u32 last_rate;
+
+       u32 missed_adhoc_beacons;
+       u32 missed_beacons;
+       u32 rx_packets;
+       u32 tx_packets;
+       u32 quality;
+
+        /* eeprom */
+       u8 eeprom[0x100];  /* 256 bytes of eeprom */
+       int eeprom_delay;
+
+       struct iw_statistics wstats;
+
+       struct workqueue_struct *workqueue;
+
+       struct work_struct adhoc_check;
+       struct work_struct associate;
+       struct work_struct disassociate;
+       struct work_struct rx_replenish;
+       struct work_struct request_scan;
+       struct work_struct adapter_restart;
+       struct work_struct rf_kill;
+       struct work_struct up;
+       struct work_struct down;
+       struct work_struct gather_stats;
+       struct work_struct abort_scan;
+       struct work_struct roam;
+       struct work_struct scan_check;
+
+       struct tasklet_struct irq_tasklet;
+
+
+#define IPW_2200BG  1
+#define IPW_2915ABG 2
+       u8 adapter;
+
+#define IPW_DEFAULT_TX_POWER 0x14
+       u8 tx_power;
+
+#ifdef CONFIG_PM
+       u32 pm_state[16];
+#endif
+
+       /* network state */
+
+       /* Used to pass the current INTA value from ISR to Tasklet */
+       u32 isr_inta;
+
+       /* debugging info */
+       u32 indirect_dword;
+       u32 direct_dword;
+       u32 indirect_byte;
+};                             /*ipw_priv */
+
+
+/* debug macros */
+
+#ifdef CONFIG_IPW_DEBUG
+#define IPW_DEBUG(level, fmt, args...) \
+do { if (ipw_debug_level & (level)) \
+  printk(KERN_DEBUG DRV_NAME": %c %s " fmt, \
+         in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0)
+#else
+#define IPW_DEBUG(level, fmt, args...) do {} while (0)
+#endif                         /* CONFIG_IPW_DEBUG */
+
+/*
+ * To use the debug system;
+ *
+ * If you are defining a new debug classification, simply add it to the #define
+ * list here in the form of:
+ *
+ * #define IPW_DL_xxxx VALUE
+ *
+ * shifting value to the left one bit from the previous entry.  xxxx should be
+ * the name of the classification (for example, WEP)
+ *
+ * You then need to either add a IPW_xxxx_DEBUG() macro definition for your
+ * classification, or use IPW_DEBUG(IPW_DL_xxxx, ...) whenever you want
+ * to send output to that classification.
+ *
+ * To add your debug level to the list of levels seen when you perform
+ *
+ * % cat /proc/net/ipw/debug_level
+ *
+ * you simply need to add your entry to the ipw_debug_levels array.
+ *
+ * If you do not see debug_level in /proc/net/ipw then you do not have
+ * CONFIG_IPW_DEBUG defined in your kernel configuration
+ *
+ */
+
+#define IPW_DL_ERROR         (1<<0)
+#define IPW_DL_WARNING       (1<<1)
+#define IPW_DL_INFO          (1<<2)
+#define IPW_DL_WX            (1<<3)
+#define IPW_DL_HOST_COMMAND  (1<<5)
+#define IPW_DL_STATE         (1<<6)
+
+#define IPW_DL_NOTIF         (1<<10)
+#define IPW_DL_SCAN          (1<<11)
+#define IPW_DL_ASSOC         (1<<12)
+#define IPW_DL_DROP          (1<<13)
+#define IPW_DL_IOCTL         (1<<14)
+
+#define IPW_DL_MANAGE        (1<<15)
+#define IPW_DL_FW            (1<<16)
+#define IPW_DL_RF_KILL       (1<<17)
+#define IPW_DL_FW_ERRORS     (1<<18)
+
+
+#define IPW_DL_ORD           (1<<20)
+
+#define IPW_DL_FRAG          (1<<21)
+#define IPW_DL_WEP           (1<<22)
+#define IPW_DL_TX            (1<<23)
+#define IPW_DL_RX            (1<<24)
+#define IPW_DL_ISR           (1<<25)
+#define IPW_DL_FW_INFO       (1<<26)
+#define IPW_DL_IO            (1<<27)
+#define IPW_DL_TRACE         (1<<28)
+
+#define IPW_DL_STATS         (1<<29)
+
+
+#define IPW_ERROR(f, a...) printk(KERN_ERR DRV_NAME ": " f, ## a)
+#define IPW_WARNING(f, a...) printk(KERN_WARNING DRV_NAME ": " f, ## a)
+#define IPW_DEBUG_INFO(f, a...)    IPW_DEBUG(IPW_DL_INFO, f, ## a)
+
+#define IPW_DEBUG_WX(f, a...)     IPW_DEBUG(IPW_DL_WX, f, ## a)
+#define IPW_DEBUG_SCAN(f, a...)   IPW_DEBUG(IPW_DL_SCAN, f, ## a)
+#define IPW_DEBUG_STATUS(f, a...) IPW_DEBUG(IPW_DL_STATUS, f, ## a)
+#define IPW_DEBUG_TRACE(f, a...)  IPW_DEBUG(IPW_DL_TRACE, f, ## a)
+#define IPW_DEBUG_RX(f, a...)     IPW_DEBUG(IPW_DL_RX, f, ## a)
+#define IPW_DEBUG_TX(f, a...)     IPW_DEBUG(IPW_DL_TX, f, ## a)
+#define IPW_DEBUG_ISR(f, a...)    IPW_DEBUG(IPW_DL_ISR, f, ## a)
+#define IPW_DEBUG_MANAGEMENT(f, a...) IPW_DEBUG(IPW_DL_MANAGE, f, ## a)
+#define IPW_DEBUG_WEP(f, a...)    IPW_DEBUG(IPW_DL_WEP, f, ## a)
+#define IPW_DEBUG_HC(f, a...) IPW_DEBUG(IPW_DL_HOST_COMMAND, f, ## a)
+#define IPW_DEBUG_FRAG(f, a...) IPW_DEBUG(IPW_DL_FRAG, f, ## a)
+#define IPW_DEBUG_FW(f, a...) IPW_DEBUG(IPW_DL_FW, f, ## a)
+#define IPW_DEBUG_RF_KILL(f, a...) IPW_DEBUG(IPW_DL_RF_KILL, f, ## a)
+#define IPW_DEBUG_DROP(f, a...) IPW_DEBUG(IPW_DL_DROP, f, ## a)
+#define IPW_DEBUG_IO(f, a...) IPW_DEBUG(IPW_DL_IO, f, ## a)
+#define IPW_DEBUG_ORD(f, a...) IPW_DEBUG(IPW_DL_ORD, f, ## a)
+#define IPW_DEBUG_FW_INFO(f, a...) IPW_DEBUG(IPW_DL_FW_INFO, f, ## a)
+#define IPW_DEBUG_NOTIF(f, a...) IPW_DEBUG(IPW_DL_NOTIF, f, ## a)
+#define IPW_DEBUG_STATE(f, a...) IPW_DEBUG(IPW_DL_STATE | IPW_DL_ASSOC | IPW_DL_INFO, f, ## a)
+#define IPW_DEBUG_ASSOC(f, a...) IPW_DEBUG(IPW_DL_ASSOC | IPW_DL_INFO, f, ## a)
+#define IPW_DEBUG_STATS(f, a...) IPW_DEBUG(IPW_DL_STATS, f, ## a)
+
+#include <linux/ctype.h>
+
+/*
+* Register bit definitions
+*/
+
+/* Dino control registers bits */
+
+#define DINO_ENABLE_SYSTEM 0x80
+#define DINO_ENABLE_CS     0x40
+#define DINO_RXFIFO_DATA   0x01
+#define DINO_CONTROL_REG   0x00200000
+
+#define CX2_INTA_RW       0x00000008
+#define CX2_INTA_MASK_R   0x0000000C
+#define CX2_INDIRECT_ADDR 0x00000010
+#define CX2_INDIRECT_DATA 0x00000014
+#define CX2_AUTOINC_ADDR  0x00000018
+#define CX2_AUTOINC_DATA  0x0000001C
+#define CX2_RESET_REG     0x00000020
+#define CX2_GP_CNTRL_RW   0x00000024
+
+#define CX2_READ_INT_REGISTER 0xFF4
+
+#define CX2_GP_CNTRL_BIT_INIT_DONE     0x00000004
+
+#define CX2_REGISTER_DOMAIN1_END        0x00001000
+#define CX2_SRAM_READ_INT_REGISTER     0x00000ff4
+
+#define CX2_SHARED_LOWER_BOUND          0x00000200
+#define CX2_INTERRUPT_AREA_LOWER_BOUND  0x00000f80
+
+#define CX2_NIC_SRAM_LOWER_BOUND        0x00000000
+#define CX2_NIC_SRAM_UPPER_BOUND        0x00030000
+
+#define CX2_BIT_INT_HOST_SRAM_READ_INT_REGISTER (1 << 29)
+#define CX2_GP_CNTRL_BIT_CLOCK_READY    0x00000001
+#define CX2_GP_CNTRL_BIT_HOST_ALLOWS_STANDBY 0x00000002
+
+/*
+ * RESET Register Bit Indexes
+ */
+#define CBD_RESET_REG_PRINCETON_RESET 0x00000001  /* Bit 0 (LSB) */
+#define CX2_RESET_REG_SW_RESET        0x00000080  /* Bit 7       */
+#define CX2_RESET_REG_MASTER_DISABLED 0x00000100  /* Bit 8       */
+#define CX2_RESET_REG_STOP_MASTER     0x00000200  /* Bit 9       */
+#define CX2_ARC_KESHET_CONFIG         0x08000000  /* Bit 27      */
+#define CX2_START_STANDBY             0x00000004  /* Bit 2       */
+
+#define CX2_CSR_CIS_UPPER_BOUND        0x00000200
+#define CX2_DOMAIN_0_END 0x1000
+#define CLX_MEM_BAR_SIZE 0x1000
+
+#define CX2_BASEBAND_CONTROL_STATUS    0X00200000
+#define CX2_BASEBAND_TX_FIFO_WRITE     0X00200004
+#define CX2_BASEBAND_RX_FIFO_READ      0X00200004
+#define CX2_BASEBAND_CONTROL_STORE     0X00200010
+
+#define CX2_INTERNAL_CMD_EVENT         0X00300004
+#define CX2_BASEBAND_POWER_DOWN 0x00000001
+
+#define CX2_MEM_HALT_AND_RESET  0x003000e0
+
+/* defgroup bits_halt_reset MEM_HALT_AND_RESET register bits */
+#define CX2_BIT_HALT_RESET_ON  0x80000000
+#define CX2_BIT_HALT_RESET_OFF         0x00000000
+
+#define CB_LAST_VALID     0x20000000
+#define CB_INT_ENABLED    0x40000000
+#define CB_VALID          0x80000000
+#define CB_SRC_LE         0x08000000
+#define CB_DEST_LE        0x04000000
+#define CB_SRC_AUTOINC    0x00800000
+#define CB_SRC_IO_GATED   0x00400000
+#define CB_DEST_AUTOINC   0x00080000
+#define CB_SRC_SIZE_LONG  0x00200000
+#define CB_DEST_SIZE_LONG 0x00020000
+
+
+/* DMA DEFINES */
+
+#define DMA_CONTROL_SMALL_CB_CONST_VALUE 0x00540000
+#define DMA_CB_STOP_AND_ABORT            0x00000C00
+#define DMA_CB_START                     0x00000100
+
+
+#define CX2_SHARED_SRAM_SIZE               0x00030000
+#define CX2_SHARED_SRAM_DMA_CONTROL        0x00027000
+#define CB_MAX_LENGTH                      0x1FFF
+
+#define CX2_HOST_EEPROM_DATA_SRAM_SIZE 0xA18
+#define CX2_EEPROM_IMAGE_SIZE          0x100
+
+
+/* DMA defs */
+#define CX2_DMA_I_CURRENT_CB  0x003000D0
+#define CX2_DMA_O_CURRENT_CB  0x003000D4
+#define CX2_DMA_I_DMA_CONTROL 0x003000A4
+#define CX2_DMA_I_CB_BASE     0x003000A0
+
+#define CX2_TX_CMD_QUEUE_BD_BASE        (0x00000200)
+#define CX2_TX_CMD_QUEUE_BD_SIZE        (0x00000204)
+#define CX2_TX_QUEUE_0_BD_BASE          (0x00000208)
+#define CX2_TX_QUEUE_0_BD_SIZE          (0x0000020C)
+#define CX2_TX_QUEUE_1_BD_BASE          (0x00000210)
+#define CX2_TX_QUEUE_1_BD_SIZE          (0x00000214)
+#define CX2_TX_QUEUE_2_BD_BASE          (0x00000218)
+#define CX2_TX_QUEUE_2_BD_SIZE          (0x0000021C)
+#define CX2_TX_QUEUE_3_BD_BASE          (0x00000220)
+#define CX2_TX_QUEUE_3_BD_SIZE          (0x00000224)
+#define CX2_RX_BD_BASE                  (0x00000240)
+#define CX2_RX_BD_SIZE                  (0x00000244)
+#define CX2_RFDS_TABLE_LOWER            (0x00000500)
+
+#define CX2_TX_CMD_QUEUE_READ_INDEX     (0x00000280)
+#define CX2_TX_QUEUE_0_READ_INDEX       (0x00000284)
+#define CX2_TX_QUEUE_1_READ_INDEX       (0x00000288)
+#define CX2_TX_QUEUE_2_READ_INDEX       (0x0000028C)
+#define CX2_TX_QUEUE_3_READ_INDEX       (0x00000290)
+#define CX2_RX_READ_INDEX               (0x000002A0)
+
+#define CX2_TX_CMD_QUEUE_WRITE_INDEX    (0x00000F80)
+#define CX2_TX_QUEUE_0_WRITE_INDEX      (0x00000F84)
+#define CX2_TX_QUEUE_1_WRITE_INDEX      (0x00000F88)
+#define CX2_TX_QUEUE_2_WRITE_INDEX      (0x00000F8C)
+#define CX2_TX_QUEUE_3_WRITE_INDEX      (0x00000F90)
+#define CX2_RX_WRITE_INDEX              (0x00000FA0)
+
+/*
+ * EEPROM Related Definitions
+ */
+
+#define IPW_EEPROM_DATA_SRAM_ADDRESS (CX2_SHARED_LOWER_BOUND + 0x814)
+#define IPW_EEPROM_DATA_SRAM_SIZE    (CX2_SHARED_LOWER_BOUND + 0x818)
+#define IPW_EEPROM_LOAD_DISABLE      (CX2_SHARED_LOWER_BOUND + 0x81C)
+#define IPW_EEPROM_DATA              (CX2_SHARED_LOWER_BOUND + 0x820)
+#define IPW_EEPROM_UPPER_ADDRESS     (CX2_SHARED_LOWER_BOUND + 0x9E0)
+
+#define IPW_STATION_TABLE_LOWER      (CX2_SHARED_LOWER_BOUND + 0xA0C)
+#define IPW_STATION_TABLE_UPPER      (CX2_SHARED_LOWER_BOUND + 0xB0C)
+#define IPW_REQUEST_ATIM             (CX2_SHARED_LOWER_BOUND + 0xB0C)
+#define IPW_ATIM_SENT                (CX2_SHARED_LOWER_BOUND + 0xB10)
+#define IPW_WHO_IS_AWAKE             (CX2_SHARED_LOWER_BOUND + 0xB14)
+#define IPW_DURING_ATIM_WINDOW       (CX2_SHARED_LOWER_BOUND + 0xB18)
+
+
+#define MSB                             1
+#define LSB                             0
+#define WORD_TO_BYTE(_word)             ((_word) * sizeof(u16))
+
+#define GET_EEPROM_ADDR(_wordoffset,_byteoffset) \
+    ( WORD_TO_BYTE(_wordoffset) + (_byteoffset) )
+
+/* EEPROM access by BYTE */
+#define EEPROM_PME_CAPABILITY   (GET_EEPROM_ADDR(0x09,MSB))     /* 1 byte   */
+#define EEPROM_MAC_ADDRESS      (GET_EEPROM_ADDR(0x21,LSB))     /* 6 byte   */
+#define EEPROM_VERSION          (GET_EEPROM_ADDR(0x24,MSB))     /* 1 byte   */
+#define EEPROM_NIC_TYPE         (GET_EEPROM_ADDR(0x25,LSB))     /* 1 byte   */
+#define EEPROM_SKU_CAPABILITY   (GET_EEPROM_ADDR(0x25,MSB))     /* 1 byte   */
+#define EEPROM_COUNTRY_CODE     (GET_EEPROM_ADDR(0x26,LSB))     /* 3 bytes  */
+#define EEPROM_IBSS_CHANNELS_BG (GET_EEPROM_ADDR(0x28,LSB))     /* 2 bytes  */
+#define EEPROM_IBSS_CHANNELS_A  (GET_EEPROM_ADDR(0x29,MSB))     /* 5 bytes  */
+#define EEPROM_BSS_CHANNELS_BG  (GET_EEPROM_ADDR(0x2c,LSB))     /* 2 bytes  */
+#define EEPROM_HW_VERSION       (GET_EEPROM_ADDR(0x72,LSB))     /* 2 bytes  */
+
+/* NIC type as found in the one byte EEPROM_NIC_TYPE  offset*/
+#define EEPROM_NIC_TYPE_STANDARD        0
+#define EEPROM_NIC_TYPE_DELL            1
+#define EEPROM_NIC_TYPE_FUJITSU         2
+#define EEPROM_NIC_TYPE_IBM             3
+#define EEPROM_NIC_TYPE_HP              4
+
+#define FW_MEM_REG_LOWER_BOUND          0x00300000
+#define FW_MEM_REG_EEPROM_ACCESS        (FW_MEM_REG_LOWER_BOUND + 0x40)
+
+#define EEPROM_BIT_SK                   (1<<0)
+#define EEPROM_BIT_CS                   (1<<1)
+#define EEPROM_BIT_DI                   (1<<2)
+#define EEPROM_BIT_DO                   (1<<4)
+
+#define EEPROM_CMD_READ                 0x2
+
+/* Interrupts masks */
+#define CX2_INTA_NONE   0x00000000
+
+#define CX2_INTA_BIT_RX_TRANSFER                   0x00000002
+#define CX2_INTA_BIT_STATUS_CHANGE                 0x00000010
+#define CX2_INTA_BIT_BEACON_PERIOD_EXPIRED         0x00000020
+
+//Inta Bits for CF
+#define CX2_INTA_BIT_TX_CMD_QUEUE                  0x00000800
+#define CX2_INTA_BIT_TX_QUEUE_1                    0x00001000
+#define CX2_INTA_BIT_TX_QUEUE_2                    0x00002000
+#define CX2_INTA_BIT_TX_QUEUE_3                    0x00004000
+#define CX2_INTA_BIT_TX_QUEUE_4                    0x00008000
+
+#define CX2_INTA_BIT_SLAVE_MODE_HOST_CMD_DONE      0x00010000
+
+#define CX2_INTA_BIT_PREPARE_FOR_POWER_DOWN        0x00100000
+#define CX2_INTA_BIT_POWER_DOWN                    0x00200000
+
+#define CX2_INTA_BIT_FW_INITIALIZATION_DONE        0x01000000
+#define CX2_INTA_BIT_FW_CARD_DISABLE_PHY_OFF_DONE  0x02000000
+#define CX2_INTA_BIT_RF_KILL_DONE                  0x04000000
+#define CX2_INTA_BIT_FATAL_ERROR             0x40000000
+#define CX2_INTA_BIT_PARITY_ERROR            0x80000000
+
+/* Interrupts enabled at init time. */
+#define CX2_INTA_MASK_ALL                        \
+        (CX2_INTA_BIT_TX_QUEUE_1               | \
+        CX2_INTA_BIT_TX_QUEUE_2               | \
+        CX2_INTA_BIT_TX_QUEUE_3               | \
+        CX2_INTA_BIT_TX_QUEUE_4               | \
+        CX2_INTA_BIT_TX_CMD_QUEUE             | \
+        CX2_INTA_BIT_RX_TRANSFER              | \
+        CX2_INTA_BIT_FATAL_ERROR              | \
+        CX2_INTA_BIT_PARITY_ERROR             | \
+        CX2_INTA_BIT_STATUS_CHANGE            | \
+        CX2_INTA_BIT_FW_INITIALIZATION_DONE   | \
+        CX2_INTA_BIT_BEACON_PERIOD_EXPIRED    | \
+        CX2_INTA_BIT_SLAVE_MODE_HOST_CMD_DONE | \
+        CX2_INTA_BIT_PREPARE_FOR_POWER_DOWN   | \
+        CX2_INTA_BIT_POWER_DOWN               | \
+         CX2_INTA_BIT_RF_KILL_DONE )
+
+#define IPWSTATUS_ERROR_LOG     (CX2_SHARED_LOWER_BOUND + 0x410)
+#define IPW_EVENT_LOG     (CX2_SHARED_LOWER_BOUND + 0x414)
+
+/* FW event log definitions */
+#define EVENT_ELEM_SIZE     (3 * sizeof(u32))
+#define EVENT_START_OFFSET  (1 * sizeof(u32) + 2 * sizeof(u16))
+
+/* FW error log definitions */
+#define ERROR_ELEM_SIZE     (7 * sizeof(u32))
+#define ERROR_START_OFFSET  (1 * sizeof(u32))
+
+enum {
+       IPW_FW_ERROR_OK = 0,
+       IPW_FW_ERROR_FAIL,
+       IPW_FW_ERROR_MEMORY_UNDERFLOW,
+       IPW_FW_ERROR_MEMORY_OVERFLOW,
+       IPW_FW_ERROR_BAD_PARAM,
+       IPW_FW_ERROR_BAD_CHECKSUM,
+       IPW_FW_ERROR_NMI_INTERRUPT,
+       IPW_FW_ERROR_BAD_DATABASE,
+       IPW_FW_ERROR_ALLOC_FAIL,
+       IPW_FW_ERROR_DMA_UNDERRUN,
+       IPW_FW_ERROR_DMA_STATUS,
+       IPW_FW_ERROR_DINOSTATUS_ERROR,
+       IPW_FW_ERROR_EEPROMSTATUS_ERROR,
+       IPW_FW_ERROR_SYSASSERT,
+       IPW_FW_ERROR_FATAL_ERROR
+};
+
+#define AUTH_OPEN       0
+#define AUTH_SHARED_KEY 1
+#define AUTH_IGNORE     3
+
+#define HC_ASSOCIATE      0
+#define HC_REASSOCIATE    1
+#define HC_DISASSOCIATE   2
+#define HC_IBSS_START     3
+#define HC_IBSS_RECONF    4
+#define HC_DISASSOC_QUIET 5
+
+#define IPW_RATE_CAPABILITIES 1
+#define IPW_RATE_CONNECT      0
+
+
+/*
+ * Rate values and masks
+ */
+#define IPW_TX_RATE_1MB  0x0A
+#define IPW_TX_RATE_2MB  0x14
+#define IPW_TX_RATE_5MB  0x37
+#define IPW_TX_RATE_6MB  0x0D
+#define IPW_TX_RATE_9MB  0x0F
+#define IPW_TX_RATE_11MB 0x6E
+#define IPW_TX_RATE_12MB 0x05
+#define IPW_TX_RATE_18MB 0x07
+#define IPW_TX_RATE_24MB 0x09
+#define IPW_TX_RATE_36MB 0x0B
+#define IPW_TX_RATE_48MB 0x01
+#define IPW_TX_RATE_54MB 0x03
+
+#define IPW_ORD_TABLE_ID_MASK             0x0000FF00
+#define IPW_ORD_TABLE_VALUE_MASK          0x000000FF
+
+#define IPW_ORD_TABLE_0_MASK              0x0000F000
+#define IPW_ORD_TABLE_1_MASK              0x0000F100
+#define IPW_ORD_TABLE_2_MASK              0x0000F200
+#define IPW_ORD_TABLE_3_MASK              0x0000F300
+#define IPW_ORD_TABLE_4_MASK              0x0000F400
+#define IPW_ORD_TABLE_5_MASK              0x0000F500
+#define IPW_ORD_TABLE_6_MASK              0x0000F600
+#define IPW_ORD_TABLE_7_MASK              0x0000F700
+
+/*
+ * Table 0 Entries (all entries are 32 bits)
+ */
+enum {
+       IPW_ORD_STAT_TX_CURR_RATE = IPW_ORD_TABLE_0_MASK + 1,
+       IPW_ORD_STAT_FRAG_TRESHOLD,
+       IPW_ORD_STAT_RTS_THRESHOLD,
+       IPW_ORD_STAT_TX_HOST_REQUESTS,
+       IPW_ORD_STAT_TX_HOST_COMPLETE,
+       IPW_ORD_STAT_TX_DIR_DATA,
+       IPW_ORD_STAT_TX_DIR_DATA_B_1,
+       IPW_ORD_STAT_TX_DIR_DATA_B_2,
+       IPW_ORD_STAT_TX_DIR_DATA_B_5_5,
+       IPW_ORD_STAT_TX_DIR_DATA_B_11,
+       /* Hole */
+
+
+
+
+
+
+
+       IPW_ORD_STAT_TX_DIR_DATA_G_1 = IPW_ORD_TABLE_0_MASK + 19,
+       IPW_ORD_STAT_TX_DIR_DATA_G_2,
+       IPW_ORD_STAT_TX_DIR_DATA_G_5_5,
+       IPW_ORD_STAT_TX_DIR_DATA_G_6,
+       IPW_ORD_STAT_TX_DIR_DATA_G_9,
+       IPW_ORD_STAT_TX_DIR_DATA_G_11,
+       IPW_ORD_STAT_TX_DIR_DATA_G_12,
+       IPW_ORD_STAT_TX_DIR_DATA_G_18,
+       IPW_ORD_STAT_TX_DIR_DATA_G_24,
+       IPW_ORD_STAT_TX_DIR_DATA_G_36,
+       IPW_ORD_STAT_TX_DIR_DATA_G_48,
+       IPW_ORD_STAT_TX_DIR_DATA_G_54,
+       IPW_ORD_STAT_TX_NON_DIR_DATA,
+       IPW_ORD_STAT_TX_NON_DIR_DATA_B_1,
+       IPW_ORD_STAT_TX_NON_DIR_DATA_B_2,
+       IPW_ORD_STAT_TX_NON_DIR_DATA_B_5_5,
+       IPW_ORD_STAT_TX_NON_DIR_DATA_B_11,
+       /* Hole */
+
+
+
+
+
+
+
+       IPW_ORD_STAT_TX_NON_DIR_DATA_G_1 = IPW_ORD_TABLE_0_MASK + 44,
+       IPW_ORD_STAT_TX_NON_DIR_DATA_G_2,
+       IPW_ORD_STAT_TX_NON_DIR_DATA_G_5_5,
+       IPW_ORD_STAT_TX_NON_DIR_DATA_G_6,
+       IPW_ORD_STAT_TX_NON_DIR_DATA_G_9,
+       IPW_ORD_STAT_TX_NON_DIR_DATA_G_11,
+       IPW_ORD_STAT_TX_NON_DIR_DATA_G_12,
+       IPW_ORD_STAT_TX_NON_DIR_DATA_G_18,
+       IPW_ORD_STAT_TX_NON_DIR_DATA_G_24,
+       IPW_ORD_STAT_TX_NON_DIR_DATA_G_36,
+       IPW_ORD_STAT_TX_NON_DIR_DATA_G_48,
+       IPW_ORD_STAT_TX_NON_DIR_DATA_G_54,
+       IPW_ORD_STAT_TX_RETRY,
+       IPW_ORD_STAT_TX_FAILURE,
+       IPW_ORD_STAT_RX_ERR_CRC,
+       IPW_ORD_STAT_RX_ERR_ICV,
+       IPW_ORD_STAT_RX_NO_BUFFER,
+       IPW_ORD_STAT_FULL_SCANS,
+       IPW_ORD_STAT_PARTIAL_SCANS,
+       IPW_ORD_STAT_TGH_ABORTED_SCANS,
+       IPW_ORD_STAT_TX_TOTAL_BYTES,
+       IPW_ORD_STAT_CURR_RSSI_RAW,
+       IPW_ORD_STAT_RX_BEACON,
+       IPW_ORD_STAT_MISSED_BEACONS,
+       IPW_ORD_TABLE_0_LAST
+};
+
+#define IPW_RSSI_TO_DBM 112
+
+/* Table 1 Entries
+ */
+enum {
+       IPW_ORD_TABLE_1_LAST = IPW_ORD_TABLE_1_MASK | 1,
+};
+
+/*
+ * Table 2 Entries
+ *
+ * FW_VERSION:    16 byte string
+ * FW_DATE:       16 byte string (only 14 bytes used)
+ * UCODE_VERSION: 4 byte version code
+ * UCODE_DATE:    5 bytes code code
+ * ADDAPTER_MAC:  6 byte MAC address
+ * RTC:           4 byte clock
+ */
+enum {
+       IPW_ORD_STAT_FW_VERSION = IPW_ORD_TABLE_2_MASK | 1,
+       IPW_ORD_STAT_FW_DATE,
+       IPW_ORD_STAT_UCODE_VERSION,
+       IPW_ORD_STAT_UCODE_DATE,
+       IPW_ORD_STAT_ADAPTER_MAC,
+       IPW_ORD_STAT_RTC,
+       IPW_ORD_TABLE_2_LAST
+};
+
+/* Table 3 */
+enum {
+       IPW_ORD_STAT_TX_PACKET = IPW_ORD_TABLE_3_MASK | 0,
+       IPW_ORD_STAT_TX_PACKET_FAILURE,
+       IPW_ORD_STAT_TX_PACKET_SUCCESS,
+       IPW_ORD_STAT_TX_PACKET_ABORTED,
+       IPW_ORD_TABLE_3_LAST
+};
+
+/* Table 4 */
+enum {
+       IPW_ORD_TABLE_4_LAST = IPW_ORD_TABLE_4_MASK
+};
+
+/* Table 5 */
+enum {
+       IPW_ORD_STAT_AVAILABLE_AP_COUNT = IPW_ORD_TABLE_5_MASK,
+       IPW_ORD_STAT_AP_ASSNS,
+       IPW_ORD_STAT_ROAM,
+       IPW_ORD_STAT_ROAM_CAUSE_MISSED_BEACONS,
+       IPW_ORD_STAT_ROAM_CAUSE_UNASSOC,
+       IPW_ORD_STAT_ROAM_CAUSE_RSSI,
+       IPW_ORD_STAT_ROAM_CAUSE_LINK_QUALITY,
+       IPW_ORD_STAT_ROAM_CAUSE_AP_LOAD_BALANCE,
+       IPW_ORD_STAT_ROAM_CAUSE_AP_NO_TX,
+       IPW_ORD_STAT_LINK_UP,
+       IPW_ORD_STAT_LINK_DOWN,
+       IPW_ORD_ANTENNA_DIVERSITY,
+       IPW_ORD_CURR_FREQ,
+       IPW_ORD_TABLE_5_LAST
+};
+
+/* Table 6 */
+enum {
+       IPW_ORD_COUNTRY_CODE = IPW_ORD_TABLE_6_MASK,
+       IPW_ORD_CURR_BSSID,
+       IPW_ORD_CURR_SSID,
+       IPW_ORD_TABLE_6_LAST
+};
+
+/* Table 7 */
+enum {
+       IPW_ORD_STAT_PERCENT_MISSED_BEACONS = IPW_ORD_TABLE_7_MASK,
+       IPW_ORD_STAT_PERCENT_TX_RETRIES,
+       IPW_ORD_STAT_PERCENT_LINK_QUALITY,
+       IPW_ORD_STAT_CURR_RSSI_DBM,
+       IPW_ORD_TABLE_7_LAST
+};
+
+#define IPW_ORDINALS_TABLE_LOWER        (CX2_SHARED_LOWER_BOUND + 0x500)
+#define IPW_ORDINALS_TABLE_0            (CX2_SHARED_LOWER_BOUND + 0x180)
+#define IPW_ORDINALS_TABLE_1            (CX2_SHARED_LOWER_BOUND + 0x184)
+#define IPW_ORDINALS_TABLE_2            (CX2_SHARED_LOWER_BOUND + 0x188)
+#define IPW_MEM_FIXED_OVERRIDE          (CX2_SHARED_LOWER_BOUND + 0x41C)
+
+struct ipw_fixed_rate {
+       u16 tx_rates;
+       u16 reserved;
+} __attribute__ ((packed));
+
+#define CX2_INDIRECT_ADDR_MASK (~0x3ul)
+
+struct host_cmd {
+       u8 cmd;
+       u8 len;
+       u16 reserved;
+       u32 param[TFD_CMD_IMMEDIATE_PAYLOAD_LENGTH];
+} __attribute__ ((packed));
+
+#define CFG_BT_COEXISTENCE_MIN                  0x00
+#define CFG_BT_COEXISTENCE_DEFER                0x02
+#define CFG_BT_COEXISTENCE_KILL                 0x04
+#define CFG_BT_COEXISTENCE_WME_OVER_BT          0x08
+#define CFG_BT_COEXISTENCE_OOB                  0x10
+#define CFG_BT_COEXISTENCE_MAX                  0xFF
+#define CFG_BT_COEXISTENCE_DEF                  0x80 /* read Bt from EEPROM*/
+
+#define CFG_CTS_TO_ITSELF_ENABLED_MIN  0x0
+#define CFG_CTS_TO_ITSELF_ENABLED_MAX  0x1
+#define CFG_CTS_TO_ITSELF_ENABLED_DEF  CFG_CTS_TO_ITSELF_ENABLED_MIN
+
+#define CFG_SYS_ANTENNA_BOTH                      0x000
+#define CFG_SYS_ANTENNA_A                         0x001
+#define CFG_SYS_ANTENNA_B                         0x003
+
+/*
+ * The definitions below were lifted off the ipw2100 driver, which only
+ * supports 'b' mode, so I'm sure these are not exactly correct.
+ *
+ * Somebody fix these!!
+ */
+#define REG_MIN_CHANNEL             0
+#define REG_MAX_CHANNEL             14
+
+#define REG_CHANNEL_MASK            0x00003FFF
+#define IPW_IBSS_11B_DEFAULT_MASK   0x87ff
+
+static const long ipw_frequencies[] = {
+       2412, 2417, 2422, 2427,
+       2432, 2437, 2442, 2447,
+       2452, 2457, 2462, 2467,
+       2472, 2484
+};
+
+#define FREQ_COUNT ARRAY_SIZE(ipw_frequencies)
+
+#define IPW_MAX_CONFIG_RETRIES 10
+
+static inline u32 frame_hdr_len(struct ieee80211_hdr *hdr)
+{
+       u32 retval;
+       u16 fc;
+
+       retval = sizeof(struct ieee80211_hdr);
+       fc = le16_to_cpu(hdr->frame_ctl);
+
+       /*
+        * Function     ToDS    FromDS
+        * IBSS         0       0
+        * To AP        1       0
+        * From AP      0       1
+        * WDS (bridge) 1       1
+        *
+        * Only WDS frames use Address4 among them. --YZ
+        */
+       if (!(fc & IEEE80211_FCTL_TODS) || !(fc & IEEE80211_FCTL_FROMDS))
+               retval -= ETH_ALEN;
+
+       return retval;
+}
+
+#endif /* __ipw2200_h__ */
index 9c2d07cde0101a311c298bedba42d318861a9d34..8de49fe57233504ffdbf62cf310a9c34c22b286e 100644 (file)
@@ -94,6 +94,8 @@
 #include <net/iw_handler.h>
 #include <net/ieee80211.h>
 
+#include <net/ieee80211.h>
+
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/system.h>
 #include "hermes.h"
 #include "hermes_rid.h"
 #include "orinoco.h"
-#include "ieee802_11.h"
 
 /********************************************************************/
 /* Module information                                               */
@@ -150,7 +151,7 @@ static const u8 encaps_hdr[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
 #define ENCAPS_OVERHEAD                (sizeof(encaps_hdr) + 2)
 
 #define ORINOCO_MIN_MTU                256
-#define ORINOCO_MAX_MTU                (IEEE802_11_DATA_LEN - ENCAPS_OVERHEAD)
+#define ORINOCO_MAX_MTU                (IEEE80211_DATA_LEN - ENCAPS_OVERHEAD)
 
 #define SYMBOL_MAX_VER_LEN     (14)
 #define USER_BAP               0
@@ -442,7 +443,7 @@ static int orinoco_change_mtu(struct net_device *dev, int new_mtu)
        if ( (new_mtu < ORINOCO_MIN_MTU) || (new_mtu > ORINOCO_MAX_MTU) )
                return -EINVAL;
 
-       if ( (new_mtu + ENCAPS_OVERHEAD + IEEE802_11_HLEN) >
+       if ( (new_mtu + ENCAPS_OVERHEAD + IEEE80211_HLEN) >
             (priv->nicbuf_size - ETH_HLEN) )
                return -EINVAL;
 
@@ -918,7 +919,7 @@ static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw)
                    data. */
                return;
        }
-       if (length > IEEE802_11_DATA_LEN) {
+       if (length > IEEE80211_DATA_LEN) {
                printk(KERN_WARNING "%s: Oversized frame received (%d bytes)\n",
                       dev->name, length);
                stats->rx_length_errors++;
@@ -1052,8 +1053,9 @@ static void orinoco_join_ap(struct net_device *dev)
                u16 channel;
        } __attribute__ ((packed)) req;
        const int atom_len = offsetof(struct prism2_scan_apinfo, atim);
-       struct prism2_scan_apinfo *atom;
+       struct prism2_scan_apinfo *atom = NULL;
        int offset = 4;
+       int found = 0;
        u8 *buf;
        u16 len;
 
@@ -1088,15 +1090,18 @@ static void orinoco_join_ap(struct net_device *dev)
         * we were requested to join */
        for (; offset + atom_len <= len; offset += atom_len) {
                atom = (struct prism2_scan_apinfo *) (buf + offset);
-               if (memcmp(&atom->bssid, priv->desired_bssid, ETH_ALEN) == 0)
-                       goto found;
+               if (memcmp(&atom->bssid, priv->desired_bssid, ETH_ALEN) == 0) {
+                       found = 1;
+                       break;
+               }
        }
 
-       DEBUG(1, "%s: Requested AP not found in scan results\n",
-             dev->name);
-       goto out;
+       if (! found) {
+               DEBUG(1, "%s: Requested AP not found in scan results\n",
+                     dev->name);
+               goto out;
+       }
 
- found:
        memcpy(req.bssid, priv->desired_bssid, ETH_ALEN);
        req.channel = atom->channel;    /* both are little-endian */
        err = HERMES_WRITE_RECORD(hw, USER_BAP, HERMES_RID_CNFJOINREQUEST,
@@ -1283,8 +1288,10 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
                /* Read scan data */
                err = hermes_bap_pread(hw, IRQ_BAP, (void *) buf, len,
                                       infofid, sizeof(info));
-               if (err)
+               if (err) {
+                       kfree(buf);
                        break;
+               }
 
 #ifdef ORINOCO_DEBUG
                {
@@ -2272,7 +2279,7 @@ static int orinoco_init(struct net_device *dev)
 
        /* No need to lock, the hw_unavailable flag is already set in
         * alloc_orinocodev() */
-       priv->nicbuf_size = IEEE802_11_FRAME_LEN + ETH_HLEN;
+       priv->nicbuf_size = IEEE80211_FRAME_LEN + ETH_HLEN;
 
        /* Initialize the firmware */
        err = orinoco_reinit_firmware(dev);
@@ -4020,7 +4027,8 @@ static int orinoco_ioctl_setscan(struct net_device *dev,
 }
 
 /* Translate scan data returned from the card to a card independant
- * format that the Wireless Tools will understand - Jean II */
+ * format that the Wireless Tools will understand - Jean II
+ * Return message length or -errno for fatal errors */
 static inline int orinoco_translate_scan(struct net_device *dev,
                                         char *buffer,
                                         char *scan,
@@ -4060,13 +4068,19 @@ static inline int orinoco_translate_scan(struct net_device *dev,
                break;
        case FIRMWARE_TYPE_INTERSIL:
                offset = 4;
-               if (priv->has_hostscan)
-                       atom_len = scan[0] + (scan[1] << 8);
-               else
+               if (priv->has_hostscan) {
+                       atom_len = le16_to_cpup((u16 *)scan);
+                       /* Sanity check for atom_len */
+                       if (atom_len < sizeof(struct prism2_scan_apinfo)) {
+                               printk(KERN_ERR "%s: Invalid atom_len in scan data: %d\n",
+                               dev->name, atom_len);
+                               return -EIO;
+                       }
+               } else
                        atom_len = offsetof(struct prism2_scan_apinfo, atim);
                break;
        default:
-               return 0;
+               return -EOPNOTSUPP;
        }
 
        /* Check that we got an whole number of atoms */
@@ -4074,7 +4088,7 @@ static inline int orinoco_translate_scan(struct net_device *dev,
                printk(KERN_ERR "%s: Unexpected scan data length %d, "
                       "atom_len %d, offset %d\n", dev->name, scan_len,
                       atom_len, offset);
-               return 0;
+               return -EIO;
        }
 
        /* Read the entries one by one */
@@ -4209,33 +4223,41 @@ static int orinoco_ioctl_getscan(struct net_device *dev,
                /* We have some results to push back to user space */
 
                /* Translate to WE format */
-               srq->length = orinoco_translate_scan(dev, extra,
-                                                    priv->scan_result,
-                                                    priv->scan_len);
-
-               /* Return flags */
-               srq->flags = (__u16) priv->scan_mode;
+               int ret = orinoco_translate_scan(dev, extra,
+                                                priv->scan_result,
+                                                priv->scan_len);
+
+               if (ret < 0) {
+                       err = ret;
+                       kfree(priv->scan_result);
+                       priv->scan_result = NULL;
+               } else {
+                       srq->length = ret;
 
-               /* Results are here, so scan no longer in progress */
-               priv->scan_inprogress = 0;
+                       /* Return flags */
+                       srq->flags = (__u16) priv->scan_mode;
 
-               /* In any case, Scan results will be cleaned up in the
-                * reset function and when exiting the driver.
-                * The person triggering the scanning may never come to
-                * pick the results, so we need to do it in those places.
-                * Jean II */
+                       /* In any case, Scan results will be cleaned up in the
+                        * reset function and when exiting the driver.
+                        * The person triggering the scanning may never come to
+                        * pick the results, so we need to do it in those places.
+                        * Jean II */
 
 #ifdef SCAN_SINGLE_READ
-               /* If you enable this option, only one client (the first
-                * one) will be able to read the result (and only one
-                * time). If there is multiple concurent clients that
-                * want to read scan results, this behavior is not
-                * advisable - Jean II */
-               kfree(priv->scan_result);
-               priv->scan_result = NULL;
+                       /* If you enable this option, only one client (the first
+                        * one) will be able to read the result (and only one
+                        * time). If there is multiple concurent clients that
+                        * want to read scan results, this behavior is not
+                        * advisable - Jean II */
+                       kfree(priv->scan_result);
+                       priv->scan_result = NULL;
 #endif /* SCAN_SINGLE_READ */
-               /* Here, if too much time has elapsed since last scan,
-                * we may want to clean up scan results... - Jean II */
+                       /* Here, if too much time has elapsed since last scan,
+                        * we may want to clean up scan results... - Jean II */
+               }
+
+               /* Scan is no longer in progress */
+               priv->scan_inprogress = 0;
        }
          
        orinoco_unlock(priv, &flags);
index 1cc1492083c9589630f05914dbbabe3a3ec31d09..d1fb1bab8aa879c2322398f493fba934355bb848 100644 (file)
@@ -604,7 +604,6 @@ static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
 
 static struct pcmcia_device_id orinoco_cs_ids[] = {
        PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300),
-       PCMCIA_DEVICE_MANF_CARD(0x0089, 0x0001),
        PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002),
        PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002),
        PCMCIA_DEVICE_MANF_CARD(0x01eb, 0x080a),
diff --git a/drivers/net/wireless/orinoco_nortel.c b/drivers/net/wireless/orinoco_nortel.c
new file mode 100644 (file)
index 0000000..86fa58e
--- /dev/null
@@ -0,0 +1,324 @@
+/* orinoco_nortel.c
+ * 
+ * Driver for Prism II devices which would usually be driven by orinoco_cs,
+ * but are connected to the PCI bus by a Nortel PCI-PCMCIA-Adapter. 
+ *
+ * Copyright (C) 2002 Tobias Hoffmann
+ *           (C) 2003 Christoph Jungegger <disdos@traum404.de>
+ *
+ * Some of this code is borrowed from orinoco_plx.c
+ *     Copyright (C) 2001 Daniel Barlow
+ * Some of this code is borrowed from orinoco_pci.c 
+ *  Copyright (C) 2001 Jean Tourrilhes
+ * Some of this code is "inspired" by linux-wlan-ng-0.1.10, but nothing
+ * has been copied from it. linux-wlan-ng-0.1.10 is originally :
+ *     Copyright (C) 1999 AbsoluteValue Systems, Inc.  All Rights Reserved.
+ * 
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License
+ * at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the
+ * terms of the GNU General Public License version 2 (the "GPL"), in
+ * which case the provisions of the GPL are applicable instead of the
+ * above.  If you wish to allow the use of your version of this file
+ * only under the terms of the GPL and not to allow others to use your
+ * version of this file under the MPL, indicate your decision by
+ * deleting the provisions above and replace them with the notice and
+ * other provisions required by the GPL.  If you do not delete the
+ * provisions above, a recipient may use your version of this file
+ * under either the MPL or the GPL.
+ */
+
+#define DRIVER_NAME "orinoco_nortel"
+#define PFX DRIVER_NAME ": "
+
+#include <linux/config.h>
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/ptrace.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/timer.h>
+#include <linux/ioport.h>
+#include <asm/uaccess.h>
+#include <asm/io.h>
+#include <asm/system.h>
+#include <linux/netdevice.h>
+#include <linux/if_arp.h>
+#include <linux/etherdevice.h>
+#include <linux/list.h>
+#include <linux/pci.h>
+#include <linux/fcntl.h>
+
+#include <pcmcia/cisreg.h>
+
+#include "hermes.h"
+#include "orinoco.h"
+
+#define COR_OFFSET    (0xe0)   /* COR attribute offset of Prism2 PC card */
+#define COR_VALUE     (COR_LEVEL_REQ | COR_FUNC_ENA)   /* Enable PC card with interrupt in level trigger */
+
+
+/* Nortel specific data */
+struct nortel_pci_card {
+       unsigned long iobase1;
+       unsigned long iobase2;
+};
+
+/*
+ * Do a soft reset of the PCI card using the Configuration Option Register
+ * We need this to get going...
+ * This is the part of the code that is strongly inspired from wlan-ng
+ *
+ * Note bis : Don't try to access HERMES_CMD during the reset phase.
+ * It just won't work !
+ */
+static int nortel_pci_cor_reset(struct orinoco_private *priv)
+{
+       struct nortel_pci_card *card = priv->card;
+
+       /* Assert the reset until the card notice */
+       outw_p(8, card->iobase1 + 2);
+       inw(card->iobase2 + COR_OFFSET);
+       outw_p(0x80, card->iobase2 + COR_OFFSET);
+       mdelay(1);
+
+       /* Give time for the card to recover from this hard effort */
+       outw_p(0, card->iobase2 + COR_OFFSET);
+       outw_p(0, card->iobase2 + COR_OFFSET);
+       mdelay(1);
+
+       /* set COR as usual */
+       outw_p(COR_VALUE, card->iobase2 + COR_OFFSET);
+       outw_p(COR_VALUE, card->iobase2 + COR_OFFSET);
+       mdelay(1);
+
+       outw_p(0x228, card->iobase1 + 2);
+
+       return 0;
+}
+
+int nortel_pci_hw_init(struct nortel_pci_card *card)
+{
+       int i;
+       u32 reg;
+
+       /* setup bridge */
+       if (inw(card->iobase1) & 1) {
+               printk(KERN_ERR PFX "brg1 answer1 wrong\n");
+               return -EBUSY;
+       }
+       outw_p(0x118, card->iobase1 + 2);
+       outw_p(0x108, card->iobase1 + 2);
+       mdelay(30);
+       outw_p(0x8, card->iobase1 + 2);
+       for (i = 0; i < 30; i++) {
+               mdelay(30);
+               if (inw(card->iobase1) & 0x10) {
+                       break;
+               }
+       }
+       if (i == 30) {
+               printk(KERN_ERR PFX "brg1 timed out\n");
+               return -EBUSY;
+       }
+       if (inw(card->iobase2 + 0xe0) & 1) {
+               printk(KERN_ERR PFX "brg2 answer1 wrong\n");
+               return -EBUSY;
+       }
+       if (inw(card->iobase2 + 0xe2) & 1) {
+               printk(KERN_ERR PFX "brg2 answer2 wrong\n");
+               return -EBUSY;
+       }
+       if (inw(card->iobase2 + 0xe4) & 1) {
+               printk(KERN_ERR PFX "brg2 answer3 wrong\n");
+               return -EBUSY;
+       }
+
+       /* set the PCMCIA COR-Register */
+       outw_p(COR_VALUE, card->iobase2 + COR_OFFSET);
+       mdelay(1);
+       reg = inw(card->iobase2 + COR_OFFSET);
+       if (reg != COR_VALUE) {
+               printk(KERN_ERR PFX "Error setting COR value (reg=%x)\n",
+                      reg);
+               return -EBUSY;
+       }
+
+       /* set leds */
+       outw_p(1, card->iobase1 + 10);
+       return 0;
+}
+
+static int nortel_pci_init_one(struct pci_dev *pdev,
+                              const struct pci_device_id *ent)
+{
+       int err;
+       struct orinoco_private *priv;
+       struct nortel_pci_card *card;
+       struct net_device *dev;
+       void __iomem *iomem;
+
+       err = pci_enable_device(pdev);
+       if (err) {
+               printk(KERN_ERR PFX "Cannot enable PCI device\n");
+               return err;
+       }
+
+       err = pci_request_regions(pdev, DRIVER_NAME);
+       if (err != 0) {
+               printk(KERN_ERR PFX "Cannot obtain PCI resources\n");
+               goto fail_resources;
+       }
+
+       iomem = pci_iomap(pdev, 3, 0);
+       if (!iomem) {
+               err = -ENOMEM;
+               goto fail_map_io;
+       }
+
+       /* Allocate network device */
+       dev = alloc_orinocodev(sizeof(*card), nortel_pci_cor_reset);
+       if (!dev) {
+               printk(KERN_ERR PFX "Cannot allocate network device\n");
+               err = -ENOMEM;
+               goto fail_alloc;
+       }
+
+       priv = netdev_priv(dev);
+       card = priv->card;
+       card->iobase1 = pci_resource_start(pdev, 0);
+       card->iobase2 = pci_resource_start(pdev, 1);
+       dev->base_addr = pci_resource_start(pdev, 2);
+       SET_MODULE_OWNER(dev);
+       SET_NETDEV_DEV(dev, &pdev->dev);
+
+       hermes_struct_init(&priv->hw, iomem, HERMES_16BIT_REGSPACING);
+
+       printk(KERN_DEBUG PFX "Detected Nortel PCI device at %s irq:%d, "
+              "io addr:0x%lx\n", pci_name(pdev), pdev->irq, dev->base_addr);
+
+       err = request_irq(pdev->irq, orinoco_interrupt, SA_SHIRQ,
+                         dev->name, dev);
+       if (err) {
+               printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq);
+               err = -EBUSY;
+               goto fail_irq;
+       }
+       dev->irq = pdev->irq;
+
+       err = nortel_pci_hw_init(card);
+       if (err) {
+               printk(KERN_ERR PFX "Hardware initialization failed\n");
+               goto fail;
+       }
+
+       err = nortel_pci_cor_reset(priv);
+       if (err) {
+               printk(KERN_ERR PFX "Initial reset failed\n");
+               goto fail;
+       }
+
+
+       err = register_netdev(dev);
+       if (err) {
+               printk(KERN_ERR PFX "Cannot register network device\n");
+               goto fail;
+       }
+
+       pci_set_drvdata(pdev, dev);
+
+       return 0;
+
+ fail:
+       free_irq(pdev->irq, dev);
+
+ fail_irq:
+       pci_set_drvdata(pdev, NULL);
+       free_orinocodev(dev);
+
+ fail_alloc:
+       pci_iounmap(pdev, iomem);
+
+ fail_map_io:
+       pci_release_regions(pdev);
+
+ fail_resources:
+       pci_disable_device(pdev);
+
+       return err;
+}
+
+static void __devexit nortel_pci_remove_one(struct pci_dev *pdev)
+{
+       struct net_device *dev = pci_get_drvdata(pdev);
+       struct orinoco_private *priv = netdev_priv(dev);
+       struct nortel_pci_card *card = priv->card;
+
+       /* clear leds */
+       outw_p(0, card->iobase1 + 10);
+
+       unregister_netdev(dev);
+       free_irq(dev->irq, dev);
+       pci_set_drvdata(pdev, NULL);
+       free_orinocodev(dev);
+       pci_iounmap(pdev, priv->hw.iobase);
+       pci_release_regions(pdev);
+       pci_disable_device(pdev);
+}
+
+
+static struct pci_device_id nortel_pci_id_table[] = {
+       /* Nortel emobility PCI */
+       {0x126c, 0x8030, PCI_ANY_ID, PCI_ANY_ID,},
+       {0,},
+};
+
+MODULE_DEVICE_TABLE(pci, nortel_pci_id_table);
+
+static struct pci_driver nortel_pci_driver = {
+       .name = DRIVER_NAME,
+       .id_table = nortel_pci_id_table,
+       .probe = nortel_pci_init_one,
+       .remove = __devexit_p(nortel_pci_remove_one),
+};
+
+static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
+       " (Tobias Hoffmann & Christoph Jungegger <disdos@traum404.de>)";
+MODULE_AUTHOR("Christoph Jungegger <disdos@traum404.de>");
+MODULE_DESCRIPTION
+    ("Driver for wireless LAN cards using the Nortel PCI bridge");
+MODULE_LICENSE("Dual MPL/GPL");
+
+static int __init nortel_pci_init(void)
+{
+       printk(KERN_DEBUG "%s\n", version);
+       return pci_module_init(&nortel_pci_driver);
+}
+
+static void __exit nortel_pci_exit(void)
+{
+       pci_unregister_driver(&nortel_pci_driver);
+       ssleep(1);
+}
+
+module_init(nortel_pci_init);
+module_exit(nortel_pci_exit);
+
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ *  tab-width: 8
+ * End:
+ */
index 7a6f52ea7faa306ac5f4af3525528d5754a5fe4e..42e03438291b8e3ad7967ea93198c996211434ed 100644 (file)
@@ -301,8 +301,6 @@ static int orinoco_pci_suspend(struct pci_dev *pdev, pm_message_t state)
        unsigned long flags;
        int err;
        
-       printk(KERN_DEBUG "%s: Orinoco-PCI entering sleep mode (state=%d)\n",
-              dev->name, state);
 
        err = orinoco_lock(priv, &flags);
        if (err) {
index c17391d947f31a30460d50b6ae56a072dd24b5aa..dc040caab7d746e61a8c4c87c6149f33924e07cc 100644 (file)
@@ -267,8 +267,6 @@ prism54_suspend(struct pci_dev *pdev, pm_message_t state)
        islpci_private *priv = ndev ? netdev_priv(ndev) : NULL;
        BUG_ON(!priv);
 
-       printk(KERN_NOTICE "%s: got suspend request (state %d)\n",
-              ndev->name, state);
 
        pci_save_state(pdev);
 
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
new file mode 100644 (file)
index 0000000..39c6cdf
--- /dev/null
@@ -0,0 +1,1120 @@
+/*
+ * Driver for 802.11b cards using RAM-loadable Symbol firmware, such as
+ * Symbol Wireless Networker LA4100, CompactFlash cards by Socket
+ * Communications and Intel PRO/Wireless 2011B.
+ *
+ * The driver implements Symbol firmware download.  The rest is handled
+ * in hermes.c and orinoco.c.
+ *
+ * Utilities for downloading the Symbol firmware are available at
+ * http://sourceforge.net/projects/orinoco/
+ *
+ * Copyright (C) 2002-2005 Pavel Roskin <proski@gnu.org>
+ * Portions based on orinoco_cs.c:
+ *     Copyright (C) David Gibson, Linuxcare Australia
+ * Portions based on Spectrum24tDnld.c from original spectrum24 driver:
+ *     Copyright (C) Symbol Technologies.
+ *
+ * See copyright notice in file orinoco.c.
+ */
+
+#define DRIVER_NAME "spectrum_cs"
+#define PFX DRIVER_NAME ": "
+
+#include <linux/config.h>
+#ifdef  __IN_PCMCIA_PACKAGE__
+#include <pcmcia/k_compat.h>
+#endif /* __IN_PCMCIA_PACKAGE__ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/ptrace.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/ioport.h>
+#include <linux/netdevice.h>
+#include <linux/if_arp.h>
+#include <linux/etherdevice.h>
+#include <linux/wireless.h>
+
+#include <pcmcia/cs_types.h>
+#include <pcmcia/cs.h>
+#include <pcmcia/cistpl.h>
+#include <pcmcia/cisreg.h>
+#include <pcmcia/ds.h>
+
+#include <asm/uaccess.h>
+#include <asm/io.h>
+#include <asm/system.h>
+
+#include "orinoco.h"
+
+/*
+ * If SPECTRUM_FW_INCLUDED is defined, the firmware is hardcoded into
+ * the driver.  Use get_symbol_fw script to generate spectrum_fw.h and
+ * copy it to the same directory as spectrum_cs.c.
+ *
+ * If SPECTRUM_FW_INCLUDED is not defined, the firmware is loaded at the
+ * runtime using hotplug.  Use the same get_symbol_fw script to generate
+ * files symbol_sp24t_prim_fw symbol_sp24t_sec_fw, copy them to the
+ * hotplug firmware directory (typically /usr/lib/hotplug/firmware) and
+ * make sure that you have hotplug installed and enabled in the kernel.
+ */
+/* #define SPECTRUM_FW_INCLUDED 1 */
+
+#ifdef SPECTRUM_FW_INCLUDED
+/* Header with the firmware */
+#include "spectrum_fw.h"
+#else  /* !SPECTRUM_FW_INCLUDED */
+#include <linux/firmware.h>
+static unsigned char *primsym;
+static unsigned char *secsym;
+static const char primary_fw_name[] = "symbol_sp24t_prim_fw";
+static const char secondary_fw_name[] = "symbol_sp24t_sec_fw";
+#endif /* !SPECTRUM_FW_INCLUDED */
+
+/********************************************************************/
+/* Module stuff                                                            */
+/********************************************************************/
+
+MODULE_AUTHOR("Pavel Roskin <proski@gnu.org>");
+MODULE_DESCRIPTION("Driver for Symbol Spectrum24 Trilogy cards with firmware downloader");
+MODULE_LICENSE("Dual MPL/GPL");
+
+/* Module parameters */
+
+/* Some D-Link cards have buggy CIS. They do work at 5v properly, but
+ * don't have any CIS entry for it. This workaround it... */
+static int ignore_cis_vcc; /* = 0 */
+module_param(ignore_cis_vcc, int, 0);
+MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket");
+
+/********************************************************************/
+/* Magic constants                                                 */
+/********************************************************************/
+
+/*
+ * The dev_info variable is the "key" that is used to match up this
+ * device driver with appropriate cards, through the card
+ * configuration database.
+ */
+static dev_info_t dev_info = DRIVER_NAME;
+
+/********************************************************************/
+/* Data structures                                                 */
+/********************************************************************/
+
+/* PCMCIA specific device information (goes in the card field of
+ * struct orinoco_private */
+struct orinoco_pccard {
+       dev_link_t link;
+       dev_node_t node;
+};
+
+/*
+ * A linked list of "instances" of the device.  Each actual PCMCIA
+ * card corresponds to one device instance, and is described by one
+ * dev_link_t structure (defined in ds.h).
+ */
+static dev_link_t *dev_list; /* = NULL */
+
+/********************************************************************/
+/* Function prototypes                                             */
+/********************************************************************/
+
+/* device methods */
+static int spectrum_cs_hard_reset(struct orinoco_private *priv);
+
+/* PCMCIA gumpf */
+static void spectrum_cs_config(dev_link_t * link);
+static void spectrum_cs_release(dev_link_t * link);
+static int spectrum_cs_event(event_t event, int priority,
+                           event_callback_args_t * args);
+
+static dev_link_t *spectrum_cs_attach(void);
+static void spectrum_cs_detach(dev_link_t *);
+
+/********************************************************************/
+/* Firmware downloader                                             */
+/********************************************************************/
+
+/* Position of PDA in the adapter memory */
+#define EEPROM_ADDR    0x3000
+#define EEPROM_LEN     0x200
+#define PDA_OFFSET     0x100
+
+#define PDA_ADDR       (EEPROM_ADDR + PDA_OFFSET)
+#define PDA_WORDS      ((EEPROM_LEN - PDA_OFFSET) / 2)
+
+/* Constants for the CISREG_CCSR register */
+#define HCR_RUN                0x07    /* run firmware after reset */
+#define HCR_IDLE       0x0E    /* don't run firmware after reset */
+#define HCR_MEM16      0x10    /* memory width bit, should be preserved */
+
+/*
+ * AUX port access.  To unlock the AUX port write the access keys to the
+ * PARAM0-2 registers, then write HERMES_AUX_ENABLE to the HERMES_CONTROL
+ * register.  Then read it and make sure it's HERMES_AUX_ENABLED.
+ */
+#define HERMES_AUX_ENABLE      0x8000  /* Enable auxiliary port access */
+#define HERMES_AUX_DISABLE     0x4000  /* Disable to auxiliary port access */
+#define HERMES_AUX_ENABLED     0xC000  /* Auxiliary port is open */
+
+#define HERMES_AUX_PW0 0xFE01
+#define HERMES_AUX_PW1 0xDC23
+#define HERMES_AUX_PW2 0xBA45
+
+/* End markers */
+#define PDI_END                0x00000000      /* End of PDA */
+#define BLOCK_END      0xFFFFFFFF      /* Last image block */
+#define TEXT_END       0x1A            /* End of text header */
+
+/*
+ * The following structures have little-endian fields denoted by
+ * the leading underscore.  Don't access them directly - use inline
+ * functions defined below.
+ */
+
+/*
+ * The binary image to be downloaded consists of series of data blocks.
+ * Each block has the following structure.
+ */
+struct dblock {
+       u32 _addr;              /* adapter address where to write the block */
+       u16 _len;               /* length of the data only, in bytes */
+       char data[0];           /* data to be written */
+} __attribute__ ((packed));
+
+/*
+ * Plug Data References are located in in the image after the last data
+ * block.  They refer to areas in the adapter memory where the plug data
+ * items with matching ID should be written.
+ */
+struct pdr {
+       u32 _id;                /* record ID */
+       u32 _addr;              /* adapter address where to write the data */
+       u32 _len;               /* expected length of the data, in bytes */
+       char next[0];           /* next PDR starts here */
+} __attribute__ ((packed));
+
+
+/*
+ * Plug Data Items are located in the EEPROM read from the adapter by
+ * primary firmware.  They refer to the device-specific data that should
+ * be plugged into the secondary firmware.
+ */
+struct pdi {
+       u16 _len;               /* length of ID and data, in words */
+       u16 _id;                /* record ID */
+       char data[0];           /* plug data */
+} __attribute__ ((packed));;
+
+
+/* Functions for access to little-endian data */
+static inline u32
+dblock_addr(const struct dblock *blk)
+{
+       return le32_to_cpu(blk->_addr);
+}
+
+static inline u32
+dblock_len(const struct dblock *blk)
+{
+       return le16_to_cpu(blk->_len);
+}
+
+static inline u32
+pdr_id(const struct pdr *pdr)
+{
+       return le32_to_cpu(pdr->_id);
+}
+
+static inline u32
+pdr_addr(const struct pdr *pdr)
+{
+       return le32_to_cpu(pdr->_addr);
+}
+
+static inline u32
+pdr_len(const struct pdr *pdr)
+{
+       return le32_to_cpu(pdr->_len);
+}
+
+static inline u32
+pdi_id(const struct pdi *pdi)
+{
+       return le16_to_cpu(pdi->_id);
+}
+
+/* Return length of the data only, in bytes */
+static inline u32
+pdi_len(const struct pdi *pdi)
+{
+       return 2 * (le16_to_cpu(pdi->_len) - 1);
+}
+
+
+/* Set address of the auxiliary port */
+static inline void
+spectrum_aux_setaddr(hermes_t *hw, u32 addr)
+{
+       hermes_write_reg(hw, HERMES_AUXPAGE, (u16) (addr >> 7));
+       hermes_write_reg(hw, HERMES_AUXOFFSET, (u16) (addr & 0x7F));
+}
+
+
+/* Open access to the auxiliary port */
+static int
+spectrum_aux_open(hermes_t *hw)
+{
+       int i;
+
+       /* Already open? */
+       if (hermes_read_reg(hw, HERMES_CONTROL) == HERMES_AUX_ENABLED)
+               return 0;
+
+       hermes_write_reg(hw, HERMES_PARAM0, HERMES_AUX_PW0);
+       hermes_write_reg(hw, HERMES_PARAM1, HERMES_AUX_PW1);
+       hermes_write_reg(hw, HERMES_PARAM2, HERMES_AUX_PW2);
+       hermes_write_reg(hw, HERMES_CONTROL, HERMES_AUX_ENABLE);
+
+       for (i = 0; i < 20; i++) {
+               udelay(10);
+               if (hermes_read_reg(hw, HERMES_CONTROL) ==
+                   HERMES_AUX_ENABLED)
+                       return 0;
+       }
+
+       return -EBUSY;
+}
+
+
+#define CS_CHECK(fn, ret) \
+  do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
+
+/*
+ * Reset the card using configuration registers COR and CCSR.
+ * If IDLE is 1, stop the firmware, so that it can be safely rewritten.
+ */
+static int
+spectrum_reset(dev_link_t *link, int idle)
+{
+       int last_ret, last_fn;
+       conf_reg_t reg;
+       u_int save_cor;
+
+       /* Doing it if hardware is gone is guaranteed crash */
+       if (!(link->state & DEV_CONFIG))
+               return -ENODEV;
+
+       /* Save original COR value */
+       reg.Function = 0;
+       reg.Action = CS_READ;
+       reg.Offset = CISREG_COR;
+       CS_CHECK(AccessConfigurationRegister,
+                pcmcia_access_configuration_register(link->handle, &reg));
+       save_cor = reg.Value;
+
+       /* Soft-Reset card */
+       reg.Action = CS_WRITE;
+       reg.Offset = CISREG_COR;
+       reg.Value = (save_cor | COR_SOFT_RESET);
+       CS_CHECK(AccessConfigurationRegister,
+                pcmcia_access_configuration_register(link->handle, &reg));
+       udelay(1000);
+
+       /* Read CCSR */
+       reg.Action = CS_READ;
+       reg.Offset = CISREG_CCSR;
+       CS_CHECK(AccessConfigurationRegister,
+                pcmcia_access_configuration_register(link->handle, &reg));
+
+       /*
+        * Start or stop the firmware.  Memory width bit should be
+        * preserved from the value we've just read.
+        */
+       reg.Action = CS_WRITE;
+       reg.Offset = CISREG_CCSR;
+       reg.Value = (idle ? HCR_IDLE : HCR_RUN) | (reg.Value & HCR_MEM16);
+       CS_CHECK(AccessConfigurationRegister,
+                pcmcia_access_configuration_register(link->handle, &reg));
+       udelay(1000);
+
+       /* Restore original COR configuration index */
+       reg.Action = CS_WRITE;
+       reg.Offset = CISREG_COR;
+       reg.Value = (save_cor & ~COR_SOFT_RESET);
+       CS_CHECK(AccessConfigurationRegister,
+                pcmcia_access_configuration_register(link->handle, &reg));
+       udelay(1000);
+       return 0;
+
+      cs_failed:
+       cs_error(link->handle, last_fn, last_ret);
+       return -ENODEV;
+}
+
+
+/*
+ * Scan PDR for the record with the specified RECORD_ID.
+ * If it's not found, return NULL.
+ */
+static struct pdr *
+spectrum_find_pdr(struct pdr *first_pdr, u32 record_id)
+{
+       struct pdr *pdr = first_pdr;
+
+       while (pdr_id(pdr) != PDI_END) {
+               /*
+                * PDR area is currently not terminated by PDI_END.
+                * It's followed by CRC records, which have the type
+                * field where PDR has length.  The type can be 0 or 1.
+                */
+               if (pdr_len(pdr) < 2)
+                       return NULL;
+
+               /* If the record ID matches, we are done */
+               if (pdr_id(pdr) == record_id)
+                       return pdr;
+
+               pdr = (struct pdr *) pdr->next;
+       }
+       return NULL;
+}
+
+
+/* Process one Plug Data Item - find corresponding PDR and plug it */
+static int
+spectrum_plug_pdi(hermes_t *hw, struct pdr *first_pdr, struct pdi *pdi)
+{
+       struct pdr *pdr;
+
+       /* Find the PDI corresponding to this PDR */
+       pdr = spectrum_find_pdr(first_pdr, pdi_id(pdi));
+
+       /* No match is found, safe to ignore */
+       if (!pdr)
+               return 0;
+
+       /* Lengths of the data in PDI and PDR must match */
+       if (pdi_len(pdi) != pdr_len(pdr))
+               return -EINVAL;
+
+       /* do the actual plugging */
+       spectrum_aux_setaddr(hw, pdr_addr(pdr));
+       hermes_write_words(hw, HERMES_AUXDATA, pdi->data,
+                          pdi_len(pdi) / 2);
+
+       return 0;
+}
+
+
+/* Read PDA from the adapter */
+static int
+spectrum_read_pda(hermes_t *hw, u16 *pda, int pda_len)
+{
+       int ret;
+       int pda_size;
+
+       /* Issue command to read EEPROM */
+       ret = hermes_docmd_wait(hw, HERMES_CMD_READMIF, 0, NULL);
+       if (ret)
+               return ret;
+
+       /* Open auxiliary port */
+       ret = spectrum_aux_open(hw);
+       if (ret)
+               return ret;
+
+       /* read PDA from EEPROM */
+       spectrum_aux_setaddr(hw, PDA_ADDR);
+       hermes_read_words(hw, HERMES_AUXDATA, pda, pda_len / 2);
+
+       /* Check PDA length */
+       pda_size = le16_to_cpu(pda[0]);
+       if (pda_size > pda_len)
+               return -EINVAL;
+
+       return 0;
+}
+
+
+/* Parse PDA and write the records into the adapter */
+static int
+spectrum_apply_pda(hermes_t *hw, const struct dblock *first_block,
+                  u16 *pda)
+{
+       int ret;
+       struct pdi *pdi;
+       struct pdr *first_pdr;
+       const struct dblock *blk = first_block;
+
+       /* Skip all blocks to locate Plug Data References */
+       while (dblock_addr(blk) != BLOCK_END)
+               blk = (struct dblock *) &blk->data[dblock_len(blk)];
+
+       first_pdr = (struct pdr *) blk;
+
+       /* Go through every PDI and plug them into the adapter */
+       pdi = (struct pdi *) (pda + 2);
+       while (pdi_id(pdi) != PDI_END) {
+               ret = spectrum_plug_pdi(hw, first_pdr, pdi);
+               if (ret)
+                       return ret;
+
+               /* Increment to the next PDI */
+               pdi = (struct pdi *) &pdi->data[pdi_len(pdi)];
+       }
+       return 0;
+}
+
+
+/* Load firmware blocks into the adapter */
+static int
+spectrum_load_blocks(hermes_t *hw, const struct dblock *first_block)
+{
+       const struct dblock *blk;
+       u32 blkaddr;
+       u32 blklen;
+
+       blk = first_block;
+       blkaddr = dblock_addr(blk);
+       blklen = dblock_len(blk);
+
+       while (dblock_addr(blk) != BLOCK_END) {
+               spectrum_aux_setaddr(hw, blkaddr);
+               hermes_write_words(hw, HERMES_AUXDATA, blk->data,
+                                  blklen / 2);
+
+               blk = (struct dblock *) &blk->data[blklen];
+               blkaddr = dblock_addr(blk);
+               blklen = dblock_len(blk);
+       }
+       return 0;
+}
+
+
+/*
+ * Process a firmware image - stop the card, load the firmware, reset
+ * the card and make sure it responds.  For the secondary firmware take
+ * care of the PDA - read it and then write it on top of the firmware.
+ */
+static int
+spectrum_dl_image(hermes_t *hw, dev_link_t *link,
+                 const unsigned char *image)
+{
+       int ret;
+       const unsigned char *ptr;
+       const struct dblock *first_block;
+
+       /* Plug Data Area (PDA) */
+       u16 pda[PDA_WORDS];
+
+       /* Binary block begins after the 0x1A marker */
+       ptr = image;
+       while (*ptr++ != TEXT_END);
+       first_block = (const struct dblock *) ptr;
+
+       /* Read the PDA */
+       if (image != primsym) {
+               ret = spectrum_read_pda(hw, pda, sizeof(pda));
+               if (ret)
+                       return ret;
+       }
+
+       /* Stop the firmware, so that it can be safely rewritten */
+       ret = spectrum_reset(link, 1);
+       if (ret)
+               return ret;
+
+       /* Program the adapter with new firmware */
+       ret = spectrum_load_blocks(hw, first_block);
+       if (ret)
+               return ret;
+
+       /* Write the PDA to the adapter */
+       if (image != primsym) {
+               ret = spectrum_apply_pda(hw, first_block, pda);
+               if (ret)
+                       return ret;
+       }
+
+       /* Run the firmware */
+       ret = spectrum_reset(link, 0);
+       if (ret)
+               return ret;
+
+       /* Reset hermes chip and make sure it responds */
+       ret = hermes_init(hw);
+
+       /* hermes_reset() should return 0 with the secondary firmware */
+       if (image != primsym && ret != 0)
+               return -ENODEV;
+
+       /* And this should work with any firmware */
+       if (!hermes_present(hw))
+               return -ENODEV;
+
+       return 0;
+}
+
+
+/*
+ * Download the firmware into the card, this also does a PCMCIA soft
+ * reset on the card, to make sure it's in a sane state.
+ */
+static int
+spectrum_dl_firmware(hermes_t *hw, dev_link_t *link)
+{
+       int ret;
+       client_handle_t handle = link->handle;
+
+#ifndef SPECTRUM_FW_INCLUDED
+       const struct firmware *fw_entry;
+
+       if (request_firmware(&fw_entry, primary_fw_name,
+                            &handle_to_dev(handle)) == 0) {
+               primsym = fw_entry->data;
+       } else {
+               printk(KERN_ERR PFX "Cannot find firmware: %s\n",
+                      primary_fw_name);
+               return -ENOENT;
+       }
+
+       if (request_firmware(&fw_entry, secondary_fw_name,
+                            &handle_to_dev(handle)) == 0) {
+               secsym = fw_entry->data;
+       } else {
+               printk(KERN_ERR PFX "Cannot find firmware: %s\n",
+                      secondary_fw_name);
+               return -ENOENT;
+       }
+#endif
+
+       /* Load primary firmware */
+       ret = spectrum_dl_image(hw, link, primsym);
+       if (ret) {
+               printk(KERN_ERR PFX "Primary firmware download failed\n");
+               return ret;
+       }
+
+       /* Load secondary firmware */
+       ret = spectrum_dl_image(hw, link, secsym);
+
+       if (ret) {
+               printk(KERN_ERR PFX "Secondary firmware download failed\n");
+       }
+
+       return ret;
+}
+
+/********************************************************************/
+/* Device methods                                                  */
+/********************************************************************/
+
+static int
+spectrum_cs_hard_reset(struct orinoco_private *priv)
+{
+       struct orinoco_pccard *card = priv->card;
+       dev_link_t *link = &card->link;
+       int err;
+
+       if (!hermes_present(&priv->hw)) {
+               /* The firmware needs to be reloaded */
+               if (spectrum_dl_firmware(&priv->hw, &card->link) != 0) {
+                       printk(KERN_ERR PFX "Firmware download failed\n");
+                       err = -ENODEV;
+               }
+       } else {
+               /* Soft reset using COR and HCR */
+               spectrum_reset(link, 0);
+       }
+
+       return 0;
+}
+
+/********************************************************************/
+/* PCMCIA stuff                                                    */
+/********************************************************************/
+
+/*
+ * This creates an "instance" of the driver, allocating local data
+ * structures for one device.  The device is registered with Card
+ * Services.
+ * 
+ * The dev_link structure is initialized, but we don't actually
+ * configure the card at this point -- we wait until we receive a card
+ * insertion event.  */
+static dev_link_t *
+spectrum_cs_attach(void)
+{
+       struct net_device *dev;
+       struct orinoco_private *priv;
+       struct orinoco_pccard *card;
+       dev_link_t *link;
+       client_reg_t client_reg;
+       int ret;
+
+       dev = alloc_orinocodev(sizeof(*card), spectrum_cs_hard_reset);
+       if (! dev)
+               return NULL;
+       priv = netdev_priv(dev);
+       card = priv->card;
+
+       /* Link both structures together */
+       link = &card->link;
+       link->priv = dev;
+
+       /* Interrupt setup */
+       link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
+       link->irq.IRQInfo1 = IRQ_LEVEL_ID;
+       link->irq.Handler = orinoco_interrupt;
+       link->irq.Instance = dev; 
+
+       /* General socket configuration defaults can go here.  In this
+        * client, we assume very little, and rely on the CIS for
+        * almost everything.  In most clients, many details (i.e.,
+        * number, sizes, and attributes of IO windows) are fixed by
+        * the nature of the device, and can be hard-wired here. */
+       link->conf.Attributes = 0;
+       link->conf.IntType = INT_MEMORY_AND_IO;
+
+       /* Register with Card Services */
+       /* FIXME: need a lock? */
+       link->next = dev_list;
+       dev_list = link;
+
+       client_reg.dev_info = &dev_info;
+       client_reg.Version = 0x0210; /* FIXME: what does this mean? */
+       client_reg.event_callback_args.client_data = link;
+
+       ret = pcmcia_register_client(&link->handle, &client_reg);
+       if (ret != CS_SUCCESS) {
+               cs_error(link->handle, RegisterClient, ret);
+               spectrum_cs_detach(link);
+               return NULL;
+       }
+
+       return link;
+}                              /* spectrum_cs_attach */
+
+/*
+ * This deletes a driver "instance".  The device is de-registered with
+ * Card Services.  If it has been released, all local data structures
+ * are freed.  Otherwise, the structures will be freed when the device
+ * is released.
+ */
+static void spectrum_cs_detach(dev_link_t *link)
+{
+       dev_link_t **linkp;
+       struct net_device *dev = link->priv;
+
+       /* Locate device structure */
+       for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
+               if (*linkp == link)
+                       break;
+
+       BUG_ON(*linkp == NULL);
+
+       if (link->state & DEV_CONFIG)
+               spectrum_cs_release(link);
+
+       /* Break the link with Card Services */
+       if (link->handle)
+               pcmcia_deregister_client(link->handle);
+
+       /* Unlink device structure, and free it */
+       *linkp = link->next;
+       DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev);
+       if (link->dev) {
+               DEBUG(0, PFX "About to unregister net device %p\n",
+                     dev);
+               unregister_netdev(dev);
+       }
+       free_orinocodev(dev);
+}                              /* spectrum_cs_detach */
+
+/*
+ * spectrum_cs_config() is scheduled to run after a CARD_INSERTION
+ * event is received, to configure the PCMCIA socket, and to make the
+ * device available to the system.
+ */
+
+static void
+spectrum_cs_config(dev_link_t *link)
+{
+       struct net_device *dev = link->priv;
+       client_handle_t handle = link->handle;
+       struct orinoco_private *priv = netdev_priv(dev);
+       struct orinoco_pccard *card = priv->card;
+       hermes_t *hw = &priv->hw;
+       int last_fn, last_ret;
+       u_char buf[64];
+       config_info_t conf;
+       cisinfo_t info;
+       tuple_t tuple;
+       cisparse_t parse;
+       void __iomem *mem;
+
+       CS_CHECK(ValidateCIS, pcmcia_validate_cis(handle, &info));
+
+       /*
+        * This reads the card's CONFIG tuple to find its
+        * configuration registers.
+        */
+       tuple.DesiredTuple = CISTPL_CONFIG;
+       tuple.Attributes = 0;
+       tuple.TupleData = buf;
+       tuple.TupleDataMax = sizeof(buf);
+       tuple.TupleOffset = 0;
+       CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+       CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+       CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
+       link->conf.ConfigBase = parse.config.base;
+       link->conf.Present = parse.config.rmask[0];
+
+       /* Configure card */
+       link->state |= DEV_CONFIG;
+
+       /* Look up the current Vcc */
+       CS_CHECK(GetConfigurationInfo,
+                pcmcia_get_configuration_info(handle, &conf));
+       link->conf.Vcc = conf.Vcc;
+
+       /*
+        * In this loop, we scan the CIS for configuration table
+        * entries, each of which describes a valid card
+        * configuration, including voltage, IO window, memory window,
+        * and interrupt settings.
+        *
+        * We make no assumptions about the card to be configured: we
+        * use just the information available in the CIS.  In an ideal
+        * world, this would work for any PCMCIA card, but it requires
+        * a complete and accurate CIS.  In practice, a driver usually
+        * "knows" most of these things without consulting the CIS,
+        * and most client drivers will only use the CIS to fill in
+        * implementation-defined details.
+        */
+       tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
+       CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+       while (1) {
+               cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
+               cistpl_cftable_entry_t dflt = { .index = 0 };
+
+               if ( (pcmcia_get_tuple_data(handle, &tuple) != 0)
+                   || (pcmcia_parse_tuple(handle, &tuple, &parse) != 0))
+                       goto next_entry;
+
+               if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
+                       dflt = *cfg;
+               if (cfg->index == 0)
+                       goto next_entry;
+               link->conf.ConfigIndex = cfg->index;
+
+               /* Does this card need audio output? */
+               if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
+                       link->conf.Attributes |= CONF_ENABLE_SPKR;
+                       link->conf.Status = CCSR_AUDIO_ENA;
+               }
+
+               /* Use power settings for Vcc and Vpp if present */
+               /* Note that the CIS values need to be rescaled */
+               if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
+                       if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) {
+                               DEBUG(2, "spectrum_cs_config: Vcc mismatch (conf.Vcc = %d, CIS = %d)\n",  conf.Vcc, cfg->vcc.param[CISTPL_POWER_VNOM] / 10000);
+                               if (!ignore_cis_vcc)
+                                       goto next_entry;
+                       }
+               } else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) {
+                       if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] / 10000) {
+                               DEBUG(2, "spectrum_cs_config: Vcc mismatch (conf.Vcc = %d, CIS = %d)\n",  conf.Vcc, dflt.vcc.param[CISTPL_POWER_VNOM] / 10000);
+                               if(!ignore_cis_vcc)
+                                       goto next_entry;
+                       }
+               }
+
+               if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
+                       link->conf.Vpp1 = link->conf.Vpp2 =
+                           cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
+               else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM))
+                       link->conf.Vpp1 = link->conf.Vpp2 =
+                           dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000;
+               
+               /* Do we need to allocate an interrupt? */
+               link->conf.Attributes |= CONF_ENABLE_IRQ;
+
+               /* IO window settings */
+               link->io.NumPorts1 = link->io.NumPorts2 = 0;
+               if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
+                       cistpl_io_t *io =
+                           (cfg->io.nwin) ? &cfg->io : &dflt.io;
+                       link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
+                       if (!(io->flags & CISTPL_IO_8BIT))
+                               link->io.Attributes1 =
+                                   IO_DATA_PATH_WIDTH_16;
+                       if (!(io->flags & CISTPL_IO_16BIT))
+                               link->io.Attributes1 =
+                                   IO_DATA_PATH_WIDTH_8;
+                       link->io.IOAddrLines =
+                           io->flags & CISTPL_IO_LINES_MASK;
+                       link->io.BasePort1 = io->win[0].base;
+                       link->io.NumPorts1 = io->win[0].len;
+                       if (io->nwin > 1) {
+                               link->io.Attributes2 =
+                                   link->io.Attributes1;
+                               link->io.BasePort2 = io->win[1].base;
+                               link->io.NumPorts2 = io->win[1].len;
+                       }
+
+                       /* This reserves IO space but doesn't actually enable it */
+                       if (pcmcia_request_io(link->handle, &link->io) != 0)
+                               goto next_entry;
+               }
+
+
+               /* If we got this far, we're cool! */
+
+               break;
+               
+       next_entry:
+               if (link->io.NumPorts1)
+                       pcmcia_release_io(link->handle, &link->io);
+               last_ret = pcmcia_get_next_tuple(handle, &tuple);
+               if (last_ret  == CS_NO_MORE_ITEMS) {
+                       printk(KERN_ERR PFX "GetNextTuple(): No matching "
+                              "CIS configuration.  Maybe you need the "
+                              "ignore_cis_vcc=1 parameter.\n");
+                       goto cs_failed;
+               }
+       }
+
+       /*
+        * Allocate an interrupt line.  Note that this does not assign
+        * a handler to the interrupt, unless the 'Handler' member of
+        * the irq structure is initialized.
+        */
+       CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
+
+       /* We initialize the hermes structure before completing PCMCIA
+        * configuration just in case the interrupt handler gets
+        * called. */
+       mem = ioport_map(link->io.BasePort1, link->io.NumPorts1);
+       if (!mem)
+               goto cs_failed;
+
+       hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING);
+
+       /*
+        * This actually configures the PCMCIA socket -- setting up
+        * the I/O windows and the interrupt mapping, and putting the
+        * card and host interface into "Memory and IO" mode.
+        */
+       CS_CHECK(RequestConfiguration,
+                pcmcia_request_configuration(link->handle, &link->conf));
+
+       /* Ok, we have the configuration, prepare to register the netdev */
+       dev->base_addr = link->io.BasePort1;
+       dev->irq = link->irq.AssignedIRQ;
+       SET_MODULE_OWNER(dev);
+       card->node.major = card->node.minor = 0;
+
+       /* Reset card and download firmware */
+       if (spectrum_cs_hard_reset(priv) != 0) {
+               goto failed;
+       }
+
+       SET_NETDEV_DEV(dev, &handle_to_dev(handle));
+       /* Tell the stack we exist */
+       if (register_netdev(dev) != 0) {
+               printk(KERN_ERR PFX "register_netdev() failed\n");
+               goto failed;
+       }
+
+       /* At this point, the dev_node_t structure(s) needs to be
+        * initialized and arranged in a linked list at link->dev. */
+       strcpy(card->node.dev_name, dev->name);
+       link->dev = &card->node; /* link->dev being non-NULL is also
+                                    used to indicate that the
+                                    net_device has been registered */
+       link->state &= ~DEV_CONFIG_PENDING;
+
+       /* Finally, report what we've done */
+       printk(KERN_DEBUG "%s: index 0x%02x: Vcc %d.%d",
+              dev->name, link->conf.ConfigIndex,
+              link->conf.Vcc / 10, link->conf.Vcc % 10);
+       if (link->conf.Vpp1)
+               printk(", Vpp %d.%d", link->conf.Vpp1 / 10,
+                      link->conf.Vpp1 % 10);
+       printk(", irq %d", link->irq.AssignedIRQ);
+       if (link->io.NumPorts1)
+               printk(", io 0x%04x-0x%04x", link->io.BasePort1,
+                      link->io.BasePort1 + link->io.NumPorts1 - 1);
+       if (link->io.NumPorts2)
+               printk(" & 0x%04x-0x%04x", link->io.BasePort2,
+                      link->io.BasePort2 + link->io.NumPorts2 - 1);
+       printk("\n");
+
+       return;
+
+ cs_failed:
+       cs_error(link->handle, last_fn, last_ret);
+
+ failed:
+       spectrum_cs_release(link);
+}                              /* spectrum_cs_config */
+
+/*
+ * After a card is removed, spectrum_cs_release() will unregister the
+ * device, and release the PCMCIA configuration.  If the device is
+ * still open, this will be postponed until it is closed.
+ */
+static void
+spectrum_cs_release(dev_link_t *link)
+{
+       struct net_device *dev = link->priv;
+       struct orinoco_private *priv = netdev_priv(dev);
+       unsigned long flags;
+
+       /* We're committed to taking the device away now, so mark the
+        * hardware as unavailable */
+       spin_lock_irqsave(&priv->lock, flags);
+       priv->hw_unavailable++;
+       spin_unlock_irqrestore(&priv->lock, flags);
+
+       /* Don't bother checking to see if these succeed or not */
+       pcmcia_release_configuration(link->handle);
+       if (link->io.NumPorts1)
+               pcmcia_release_io(link->handle, &link->io);
+       if (link->irq.AssignedIRQ)
+               pcmcia_release_irq(link->handle, &link->irq);
+       link->state &= ~DEV_CONFIG;
+       if (priv->hw.iobase)
+               ioport_unmap(priv->hw.iobase);
+}                              /* spectrum_cs_release */
+
+/*
+ * The card status event handler.  Mostly, this schedules other stuff
+ * to run after an event is received.
+ */
+static int
+spectrum_cs_event(event_t event, int priority,
+                      event_callback_args_t * args)
+{
+       dev_link_t *link = args->client_data;
+       struct net_device *dev = link->priv;
+       struct orinoco_private *priv = netdev_priv(dev);
+       int err = 0;
+       unsigned long flags;
+
+       switch (event) {
+       case CS_EVENT_CARD_REMOVAL:
+               link->state &= ~DEV_PRESENT;
+               if (link->state & DEV_CONFIG) {
+                       unsigned long flags;
+
+                       spin_lock_irqsave(&priv->lock, flags);
+                       netif_device_detach(dev);
+                       priv->hw_unavailable++;
+                       spin_unlock_irqrestore(&priv->lock, flags);
+               }
+               break;
+
+       case CS_EVENT_CARD_INSERTION:
+               link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
+               spectrum_cs_config(link);
+               break;
+
+       case CS_EVENT_PM_SUSPEND:
+               link->state |= DEV_SUSPEND;
+               /* Fall through... */
+       case CS_EVENT_RESET_PHYSICAL:
+               /* Mark the device as stopped, to block IO until later */
+               if (link->state & DEV_CONFIG) {
+                       /* This is probably racy, but I can't think of
+                           a better way, short of rewriting the PCMCIA
+                           layer to not suck :-( */
+                       spin_lock_irqsave(&priv->lock, flags);
+
+                       err = __orinoco_down(dev);
+                       if (err)
+                               printk(KERN_WARNING "%s: %s: Error %d downing interface\n",
+                                      dev->name,
+                                      event == CS_EVENT_PM_SUSPEND ? "SUSPEND" : "RESET_PHYSICAL",
+                                      err);
+
+                       netif_device_detach(dev);
+                       priv->hw_unavailable++;
+
+                       spin_unlock_irqrestore(&priv->lock, flags);
+
+                       pcmcia_release_configuration(link->handle);
+               }
+               break;
+
+       case CS_EVENT_PM_RESUME:
+               link->state &= ~DEV_SUSPEND;
+               /* Fall through... */
+       case CS_EVENT_CARD_RESET:
+               if (link->state & DEV_CONFIG) {
+                       /* FIXME: should we double check that this is
+                        * the same card as we had before */
+                       pcmcia_request_configuration(link->handle, &link->conf);
+                       netif_device_attach(dev);
+                       priv->hw_unavailable--;
+                       schedule_work(&priv->reset_work);
+               }
+               break;
+       }
+
+       return err;
+}                              /* spectrum_cs_event */
+
+/********************************************************************/
+/* Module initialization                                           */
+/********************************************************************/
+
+/* Can't be declared "const" or the whole __initdata section will
+ * become const */
+static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
+       " (Pavel Roskin <proski@gnu.org>,"
+       " David Gibson <hermes@gibson.dropbear.id.au>, et al)";
+
+static struct pcmcia_device_id spectrum_cs_ids[] = {
+       PCMCIA_DEVICE_MANF_CARD(0x026c, 0x0001), /* Symbol Spectrum24 LA4100 */
+       PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0001), /* Socket Communications CF */
+       PCMCIA_DEVICE_MANF_CARD(0x0089, 0x0001), /* Intel PRO/Wireless 2011B */
+       PCMCIA_DEVICE_NULL,
+};
+MODULE_DEVICE_TABLE(pcmcia, spectrum_cs_ids);
+
+static struct pcmcia_driver orinoco_driver = {
+       .owner          = THIS_MODULE,
+       .drv            = {
+               .name   = DRIVER_NAME,
+       },
+       .attach         = spectrum_cs_attach,
+       .event          = spectrum_cs_event,
+       .detach         = spectrum_cs_detach,
+       .id_table       = spectrum_cs_ids,
+};
+
+static int __init
+init_spectrum_cs(void)
+{
+       printk(KERN_DEBUG "%s\n", version);
+
+       return pcmcia_register_driver(&orinoco_driver);
+}
+
+static void __exit
+exit_spectrum_cs(void)
+{
+       pcmcia_unregister_driver(&orinoco_driver);
+       BUG_ON(dev_list != NULL);
+}
+
+module_init(init_spectrum_cs);
+module_exit(exit_spectrum_cs);
index 6c42b573a95a9138fb407df50eb5ef12ad797b57..4b0acae22b0d67e01d11f3b1c2f3ee991222d9f4 100644 (file)
@@ -209,7 +209,7 @@ enum {
        NoStructure = 0,        /* Really old firmware */
        StructuredMessages = 1, /* Parsable AT response msgs */
        ChecksummedMessages = 2 /* Parsable AT response msgs with checksums */
-} FirmwareLevel;
+};
 
 struct strip {
        int magic;
index f6130a53b7966fe7f9ba5d267b120c9b4f08eff5..183c4732ef65ca0eb24e99c79d1b43197a3f8930 100644 (file)
 /* Do *NOT* add other headers here, you are guaranteed to be wrong - Jean II */
 #include "wavelan_cs.p.h"              /* Private header */
 
+#ifdef WAVELAN_ROAMING
+static void wl_cell_expiry(unsigned long data);
+static void wl_del_wavepoint(wavepoint_history *wavepoint, struct net_local *lp);
+static void wv_nwid_filter(unsigned char mode, net_local *lp);
+#endif  /*  WAVELAN_ROAMING  */
+
 /************************* MISC SUBROUTINES **************************/
 /*
  * Subroutines which won't fit in one of the following category
@@ -500,9 +506,9 @@ fee_write(u_long    base,   /* i/o port of the card */
 
 #ifdef WAVELAN_ROAMING /* Conditional compile, see wavelan_cs.h */
 
-unsigned char WAVELAN_BEACON_ADDRESS[]= {0x09,0x00,0x0e,0x20,0x03,0x00};
+static unsigned char WAVELAN_BEACON_ADDRESS[] = {0x09,0x00,0x0e,0x20,0x03,0x00};
   
-void wv_roam_init(struct net_device *dev)
+static void wv_roam_init(struct net_device *dev)
 {
   net_local  *lp= netdev_priv(dev);
 
@@ -531,7 +537,7 @@ void wv_roam_init(struct net_device *dev)
   printk(KERN_DEBUG "WaveLAN: Roaming enabled on device %s\n",dev->name);
 }
  
-void wv_roam_cleanup(struct net_device *dev)
+static void wv_roam_cleanup(struct net_device *dev)
 {
   wavepoint_history *ptr,*old_ptr;
   net_local *lp= netdev_priv(dev);
@@ -550,7 +556,7 @@ void wv_roam_cleanup(struct net_device *dev)
 }
 
 /* Enable/Disable NWID promiscuous mode on a given device */
-void wv_nwid_filter(unsigned char mode, net_local *lp)
+static void wv_nwid_filter(unsigned char mode, net_local *lp)
 {
   mm_t                  m;
   unsigned long         flags;
@@ -575,7 +581,7 @@ void wv_nwid_filter(unsigned char mode, net_local *lp)
 }
 
 /* Find a record in the WavePoint table matching a given NWID */
-wavepoint_history *wl_roam_check(unsigned short nwid, net_local *lp)
+static wavepoint_history *wl_roam_check(unsigned short nwid, net_local *lp)
 {
   wavepoint_history    *ptr=lp->wavepoint_table.head;
   
@@ -588,7 +594,7 @@ wavepoint_history *wl_roam_check(unsigned short nwid, net_local *lp)
 }
 
 /* Create a new wavepoint table entry */
-wavepoint_history *wl_new_wavepoint(unsigned short nwid, unsigned char seq, net_local* lp)
+static wavepoint_history *wl_new_wavepoint(unsigned short nwid, unsigned char seq, net_local* lp)
 {
   wavepoint_history *new_wavepoint;
 
@@ -624,7 +630,7 @@ wavepoint_history *wl_new_wavepoint(unsigned short nwid, unsigned char seq, net_
 }
 
 /* Remove a wavepoint entry from WavePoint table */
-void wl_del_wavepoint(wavepoint_history *wavepoint, struct net_local *lp)
+static void wl_del_wavepoint(wavepoint_history *wavepoint, struct net_local *lp)
 {
   if(wavepoint==NULL)
     return;
@@ -646,7 +652,7 @@ void wl_del_wavepoint(wavepoint_history *wavepoint, struct net_local *lp)
 }
 
 /* Timer callback function - checks WavePoint table for stale entries */ 
-void wl_cell_expiry(unsigned long data)
+static void wl_cell_expiry(unsigned long data)
 {
   net_local *lp=(net_local *)data;
   wavepoint_history *wavepoint=lp->wavepoint_table.head,*old_point;
@@ -686,7 +692,7 @@ void wl_cell_expiry(unsigned long data)
 }
 
 /* Update SNR history of a wavepoint */
-void wl_update_history(wavepoint_history *wavepoint, unsigned char sigqual, unsigned char seq) 
+static void wl_update_history(wavepoint_history *wavepoint, unsigned char sigqual, unsigned char seq)  
 {
   int i=0,num_missed=0,ptr=0;
   int average_fast=0,average_slow=0;
@@ -723,7 +729,7 @@ void wl_update_history(wavepoint_history *wavepoint, unsigned char sigqual, unsi
 }
 
 /* Perform a handover to a new WavePoint */
-void wv_roam_handover(wavepoint_history *wavepoint, net_local *lp)
+static void wv_roam_handover(wavepoint_history *wavepoint, net_local *lp)
 {
   kio_addr_t           base = lp->dev->base_addr;
   mm_t                  m;
index 29cff6daf860af6c8c5b8ec1ef190a0f750762fe..fabc63ee153c7c8de715dc51f212055f35de8efa 100644 (file)
@@ -62,7 +62,7 @@
  * like DEC RoamAbout, or Digital Ocean, Epson, ...), you must modify this
  * part to accommodate your hardware...
  */
-const unsigned char    MAC_ADDRESSES[][3] =
+static const unsigned char     MAC_ADDRESSES[][3] =
 {
   { 0x08, 0x00, 0x0E },                /* AT&T Wavelan (standard) & DEC RoamAbout */
   { 0x08, 0x00, 0x6A },                /* AT&T Wavelan (alternate) */
@@ -79,14 +79,14 @@ const unsigned char MAC_ADDRESSES[][3] =
  * (as read in the offset register of the dac area).
  * Used to map channel numbers used by `wfreqsel' to frequencies
  */
-const short    channel_bands[] = { 0x30, 0x58, 0x64, 0x7A, 0x80, 0xA8,
+static const short     channel_bands[] = { 0x30, 0x58, 0x64, 0x7A, 0x80, 0xA8,
                                    0xD0, 0xF0, 0xF8, 0x150 };
 
 /* Frequencies of the 1.0 modem (fixed frequencies).
  * Use to map the PSA `subband' to a frequency
  * Note : all frequencies apart from the first one need to be multiplied by 10
  */
-const int      fixed_bands[] = { 915e6, 2.425e8, 2.46e8, 2.484e8, 2.4305e8 };
+static const int       fixed_bands[] = { 915e6, 2.425e8, 2.46e8, 2.484e8, 2.4305e8 };
 
 
 /*************************** PC INTERFACE ****************************/
index 677ff71883cb826a1e81eafdc4b8d9e9befabfad..01d882be8790c1b9c8d2b81d71fcc64248210dad 100644 (file)
@@ -647,23 +647,6 @@ struct net_local
   void __iomem *mem;
 };
 
-/**************************** PROTOTYPES ****************************/
-
-#ifdef WAVELAN_ROAMING
-/* ---------------------- ROAMING SUBROUTINES -----------------------*/
-
-wavepoint_history *wl_roam_check(unsigned short nwid, net_local *lp);
-wavepoint_history *wl_new_wavepoint(unsigned short nwid, unsigned char seq, net_local *lp);
-void wl_del_wavepoint(wavepoint_history *wavepoint, net_local *lp);
-void wl_cell_expiry(unsigned long data);
-wavepoint_history *wl_best_sigqual(int fast_search, net_local *lp);
-void wl_update_history(wavepoint_history *wavepoint, unsigned char sigqual, unsigned char seq);
-void wv_roam_handover(wavepoint_history *wavepoint, net_local *lp);
-void wv_nwid_filter(unsigned char mode, net_local *lp);
-void wv_roam_init(struct net_device *dev);
-void wv_roam_cleanup(struct net_device *dev);
-#endif /* WAVELAN_ROAMING */
-
 /* ----------------- MODEM MANAGEMENT SUBROUTINES ----------------- */
 static inline u_char           /* data */
        hasr_read(u_long);      /* Read the host interface : base address */
index 8636d93067854bbeb30ce0868369f0cd121e625a..b5719437e981a680ec655863e89bed5ce88379ec 100644 (file)
@@ -2,7 +2,7 @@
 #define __WL3501_H__
 
 #include <linux/spinlock.h>
-#include "ieee802_11.h"
+#include <net/ieee80211.h>
 
 /* define for WLA 2.0 */
 #define WL3501_BLKSZ 256
@@ -548,7 +548,7 @@ struct wl3501_80211_tx_plcp_hdr {
 
 struct wl3501_80211_tx_hdr {
        struct wl3501_80211_tx_plcp_hdr pclp_hdr;
-       struct ieee802_11_hdr           mac_hdr;
+       struct ieee80211_hdr            mac_hdr;
 } __attribute__ ((packed));
 
 /*
index dd902126d0183aec8f5439a834e4d8ba51b3b3cd..7cc5edbf6edee7f4c41bfd8503319801c19a208c 100644 (file)
@@ -296,7 +296,8 @@ static int wl3501_get_flash_mac_addr(struct wl3501_card *this)
  *
  * Move 'size' bytes from PC to card. (Shouldn't be interrupted)
  */
-void wl3501_set_to_wla(struct wl3501_card *this, u16 dest, void *src, int size)
+static void wl3501_set_to_wla(struct wl3501_card *this, u16 dest, void *src,
+                             int size)
 {
        /* switch to SRAM Page 0 */
        wl3501_switch_page(this, (dest & 0x8000) ? WL3501_BSS_SPAGE1 :
@@ -317,8 +318,8 @@ void wl3501_set_to_wla(struct wl3501_card *this, u16 dest, void *src, int size)
  *
  * Move 'size' bytes from card to PC. (Shouldn't be interrupted)
  */
-void wl3501_get_from_wla(struct wl3501_card *this, u16 src, void *dest,
-                        int size)
+static void wl3501_get_from_wla(struct wl3501_card *this, u16 src, void *dest,
+                               int size)
 {
        /* switch to SRAM Page 0 */
        wl3501_switch_page(this, (src & 0x8000) ? WL3501_BSS_SPAGE1 :
@@ -1438,14 +1439,14 @@ fail:
        goto out;
 }
 
-struct net_device_stats *wl3501_get_stats(struct net_device *dev)
+static struct net_device_stats *wl3501_get_stats(struct net_device *dev)
 {
        struct wl3501_card *this = dev->priv;
 
        return &this->stats;
 }
 
-struct iw_statistics *wl3501_get_wireless_stats(struct net_device *dev)
+static struct iw_statistics *wl3501_get_wireless_stats(struct net_device *dev)
 {
        struct wl3501_card *this = dev->priv;
        struct iw_statistics *wstats = &this->wstats;
index 1b34fc56067ed8ae0ba9b32f46679e13068bb86c..c62d2f04339714cbf5380aa68dbdddf4aaba46c0 100644 (file)
@@ -333,13 +333,17 @@ pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state)
        if (platform_pci_choose_state) {
                ret = platform_pci_choose_state(dev, state);
                if (ret >= 0)
-                       state = ret;
+                       state.event = ret;
        }
-       switch (state) {
-       case 0: return PCI_D0;
-       case 3: return PCI_D3hot;
+
+       switch (state.event) {
+       case PM_EVENT_ON:
+               return PCI_D0;
+       case PM_EVENT_FREEZE:
+       case PM_EVENT_SUSPEND:
+               return PCI_D3hot;
        default:
-               printk("They asked me for state %d\n", state);
+               printk("They asked me for state %d\n", state.event);
                BUG();
        }
        return PCI_D0;
index bb36bb69803f44dfee260410aa2f2bf89c712c0c..140354a2aa72a7534281619f5c53dd8b707fd5f1 100644 (file)
@@ -421,6 +421,25 @@ static void __devinit quirk_via_ioapic(struct pci_dev *dev)
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA,     PCI_DEVICE_ID_VIA_82C686,       quirk_via_ioapic );
 
+/*
+ * VIA 8237: Some BIOSs don't set the 'Bypass APIC De-Assert Message' Bit.
+ * This leads to doubled level interrupt rates.
+ * Set this bit to get rid of cycle wastage.
+ * Otherwise uncritical.
+ */
+static void __devinit quirk_via_vt8237_bypass_apic_deassert(struct pci_dev *dev)
+{
+       u8 misc_control2;
+#define BYPASS_APIC_DEASSERT 8
+
+       pci_read_config_byte(dev, 0x5B, &misc_control2);
+       if (!(misc_control2 & BYPASS_APIC_DEASSERT)) {
+               printk(KERN_INFO "PCI: Bypassing VIA 8237 APIC De-Assert Message\n");
+               pci_write_config_byte(dev, 0x5B, misc_control2|BYPASS_APIC_DEASSERT);
+       }
+}
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA,     PCI_DEVICE_ID_VIA_8237,         quirk_via_vt8237_bypass_apic_deassert);
+
 /*
  * The AMD io apic can hang the box when an apic irq is masked.
  * We check all revs >= B0 (yet not in the pre production!) as the bug
index 713c78f3a65d22950adccf6a5111ecc03a328778..49bd21702314ccda11e716c1b99aa2e2d1229ade 100644 (file)
  * between the ROM and other resources, so enabling it may disable access
  * to MMIO registers or other card memory.
  */
-static void pci_enable_rom(struct pci_dev *pdev)
+static int pci_enable_rom(struct pci_dev *pdev)
 {
+       struct resource *res = pdev->resource + PCI_ROM_RESOURCE;
+       struct pci_bus_region region;
        u32 rom_addr;
 
+       if (!res->flags)
+               return -1;
+
+       pcibios_resource_to_bus(pdev, &region, res);
        pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_addr);
-       rom_addr |= PCI_ROM_ADDRESS_ENABLE;
+       rom_addr &= ~PCI_ROM_ADDRESS_MASK;
+       rom_addr |= region.start | PCI_ROM_ADDRESS_ENABLE;
        pci_write_config_dword(pdev, pdev->rom_base_reg, rom_addr);
+       return 0;
 }
 
 /**
@@ -71,19 +79,21 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)
        } else {
                if (res->flags & IORESOURCE_ROM_COPY) {
                        *size = pci_resource_len(pdev, PCI_ROM_RESOURCE);
-                       return (void __iomem *)pci_resource_start(pdev, PCI_ROM_RESOURCE);
+                       return (void __iomem *)pci_resource_start(pdev,
+                                                            PCI_ROM_RESOURCE);
                } else {
                        /* assign the ROM an address if it doesn't have one */
-                       if (res->parent == NULL)
-                               pci_assign_resource(pdev, PCI_ROM_RESOURCE);
-
+                       if (res->parent == NULL &&
+                           pci_assign_resource(pdev,PCI_ROM_RESOURCE))
+                               return NULL;
                        start = pci_resource_start(pdev, PCI_ROM_RESOURCE);
                        *size = pci_resource_len(pdev, PCI_ROM_RESOURCE);
                        if (*size == 0)
                                return NULL;
 
                        /* Enable ROM space decodes */
-                       pci_enable_rom(pdev);
+                       if (pci_enable_rom(pdev))
+                               return NULL;
                }
        }
 
index 3e23cd461fb1e48b5ccaffbaf9efd75a81ec4f41..325c992f7d8f3804726e5024d85101919225a3cb 100644 (file)
@@ -246,7 +246,7 @@ static void __exit pxa2xx_pcmcia_exit(void)
        driver_unregister(&pxa2xx_pcmcia_driver);
 }
 
-module_init(pxa2xx_pcmcia_init);
+fs_initcall(pxa2xx_pcmcia_init);
 module_exit(pxa2xx_pcmcia_exit);
 
 MODULE_AUTHOR("Stefan Eletzhofer <stefan.eletzhofer@inquant.de> and Ian Molton <spyro@f2s.com>");
index 5309734e16875ece7ddf48974e2f1ec59049d4e4..bbe69b07ce50406a1ab6fb3b23901cdca40b90ec 100644 (file)
@@ -196,7 +196,7 @@ static void __exit mst_pcmcia_exit(void)
        platform_device_unregister(mst_pcmcia_device);
 }
 
-module_init(mst_pcmcia_init);
+fs_initcall(mst_pcmcia_init);
 module_exit(mst_pcmcia_exit);
 
 MODULE_LICENSE("GPL");
index 42efe218867a19d0fc4c8737711e37f409ea4c09..a1178a600e3c13540577df7b3eb3f268557f324b 100644 (file)
 
 #include <asm/hardware.h>
 #include <asm/irq.h>
-
 #include <asm/hardware/scoop.h>
-#include <asm/arch/corgi.h>
 #include <asm/arch/pxa-regs.h>
 
 #include "soc_common.h"
 
 #define        NO_KEEP_VS 0x0001
 
-static unsigned char keep_vs;
-static unsigned char keep_rd;
-
-static struct pcmcia_irqs irqs[] = {
-       { 0, CORGI_IRQ_GPIO_CF_CD, "PCMCIA0 CD"},
-};
-
-static void sharpsl_pcmcia_init_reset(void)
+static void sharpsl_pcmcia_init_reset(struct scoop_pcmcia_dev *scoopdev)
 {
-       reset_scoop(&corgiscoop_device.dev);
-       keep_vs = NO_KEEP_VS;
-       keep_rd = 0;
+       reset_scoop(scoopdev->dev);
+       scoopdev->keep_vs = NO_KEEP_VS;
+       scoopdev->keep_rd = 0;
 }
 
 static int sharpsl_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
@@ -71,29 +62,35 @@ static int sharpsl_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
        pxa_gpio_mode(GPIO57_nIOIS16_MD);
 
        /* Register interrupts */
-       ret = soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
-
-       if (ret) {
-               printk(KERN_ERR "Request for Compact Flash IRQ failed\n");
-               return ret;
+       if (scoop_devs[skt->nr].cd_irq >= 0) {
+               struct pcmcia_irqs cd_irq;
+
+               cd_irq.sock = skt->nr;
+               cd_irq.irq  = scoop_devs[skt->nr].cd_irq;
+               cd_irq.str  = scoop_devs[skt->nr].cd_irq_str;
+               ret = soc_pcmcia_request_irqs(skt, &cd_irq, 1);
+
+               if (ret) {
+                       printk(KERN_ERR "Request for Compact Flash IRQ failed\n");
+                       return ret;
+               }
        }
 
-       /* Enable interrupt */
-       write_scoop_reg(&corgiscoop_device.dev, SCOOP_IMR, 0x00C0);
-       write_scoop_reg(&corgiscoop_device.dev, SCOOP_MCR, 0x0101);
-       keep_vs = NO_KEEP_VS;
-
-       skt->irq = CORGI_IRQ_GPIO_CF_IRQ;
+       skt->irq = scoop_devs[skt->nr].irq;
 
        return 0;
 }
 
 static void sharpsl_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
 {
-       soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
+       if (scoop_devs[skt->nr].cd_irq >= 0) {
+               struct pcmcia_irqs cd_irq;
 
-       /* CF_BUS_OFF */
-       sharpsl_pcmcia_init_reset();
+               cd_irq.sock = skt->nr;
+               cd_irq.irq  = scoop_devs[skt->nr].cd_irq;
+               cd_irq.str  = scoop_devs[skt->nr].cd_irq_str;
+               soc_pcmcia_free_irqs(skt, &cd_irq, 1);
+       }
 }
 
 
@@ -101,31 +98,32 @@ static void sharpsl_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
                                    struct pcmcia_state *state)
 {
        unsigned short cpr, csr;
+       struct device *scoop = scoop_devs[skt->nr].dev;
 
-       cpr = read_scoop_reg(&corgiscoop_device.dev, SCOOP_CPR);
+       cpr = read_scoop_reg(scoop_devs[skt->nr].dev, SCOOP_CPR);
 
-       write_scoop_reg(&corgiscoop_device.dev, SCOOP_IRM, 0x00FF);
-       write_scoop_reg(&corgiscoop_device.dev, SCOOP_ISR, 0x0000);
-       write_scoop_reg(&corgiscoop_device.dev, SCOOP_IRM, 0x0000);
-       csr = read_scoop_reg(&corgiscoop_device.dev, SCOOP_CSR);
+       write_scoop_reg(scoop, SCOOP_IRM, 0x00FF);
+       write_scoop_reg(scoop, SCOOP_ISR, 0x0000);
+       write_scoop_reg(scoop, SCOOP_IRM, 0x0000);
+       csr = read_scoop_reg(scoop, SCOOP_CSR);
        if (csr & 0x0004) {
                /* card eject */
-               write_scoop_reg(&corgiscoop_device.dev, SCOOP_CDR, 0x0000);
-               keep_vs = NO_KEEP_VS;
+               write_scoop_reg(scoop, SCOOP_CDR, 0x0000);
+               scoop_devs[skt->nr].keep_vs = NO_KEEP_VS;
        }
-       else if (!(keep_vs & NO_KEEP_VS)) {
+       else if (!(scoop_devs[skt->nr].keep_vs & NO_KEEP_VS)) {
                /* keep vs1,vs2 */
-               write_scoop_reg(&corgiscoop_device.dev, SCOOP_CDR, 0x0000);
-               csr |= keep_vs;
+               write_scoop_reg(scoop, SCOOP_CDR, 0x0000);
+               csr |= scoop_devs[skt->nr].keep_vs;
        }
        else if (cpr & 0x0003) {
                /* power on */
-               write_scoop_reg(&corgiscoop_device.dev, SCOOP_CDR, 0x0000);
-               keep_vs = (csr & 0x00C0);
+               write_scoop_reg(scoop, SCOOP_CDR, 0x0000);
+               scoop_devs[skt->nr].keep_vs = (csr & 0x00C0);
        }
        else {
                /* card detect */
-               write_scoop_reg(&corgiscoop_device.dev, SCOOP_CDR, 0x0002);
+               write_scoop_reg(scoop, SCOOP_CDR, 0x0002);
        }
 
        state->detect = (csr & 0x0004) ? 0 : 1;
@@ -147,6 +145,7 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
                                       const socket_state_t *state)
 {
        unsigned long flags;
+       struct device *scoop = scoop_devs[skt->nr].dev;
 
        unsigned short cpr, ncpr, ccr, nccr, mcr, nmcr, imr, nimr;
 
@@ -166,10 +165,10 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
 
        local_irq_save(flags);
 
-       nmcr = (mcr = read_scoop_reg(&corgiscoop_device.dev, SCOOP_MCR)) & ~0x0010;
-       ncpr = (cpr = read_scoop_reg(&corgiscoop_device.dev, SCOOP_CPR)) & ~0x0083;
-       nccr = (ccr = read_scoop_reg(&corgiscoop_device.dev, SCOOP_CCR)) & ~0x0080;
-       nimr = (imr = read_scoop_reg(&corgiscoop_device.dev, SCOOP_IMR)) & ~0x003E;
+       nmcr = (mcr = read_scoop_reg(scoop, SCOOP_MCR)) & ~0x0010;
+       ncpr = (cpr = read_scoop_reg(scoop, SCOOP_CPR)) & ~0x0083;
+       nccr = (ccr = read_scoop_reg(scoop, SCOOP_CCR)) & ~0x0080;
+       nimr = (imr = read_scoop_reg(scoop, SCOOP_IMR)) & ~0x003E;
 
        ncpr |= (state->Vcc == 33) ? 0x0001 :
                                (state->Vcc == 50) ? 0x0002 : 0;
@@ -184,22 +183,22 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
                        ((skt->status&SS_WRPROT) ? 0x0008 : 0);
 
        if (!(ncpr & 0x0003)) {
-               keep_rd = 0;
-       } else if (!keep_rd) {
+               scoop_devs[skt->nr].keep_rd = 0;
+       } else if (!scoop_devs[skt->nr].keep_rd) {
                if (nccr & 0x0080)
-                       keep_rd = 1;
+                       scoop_devs[skt->nr].keep_rd = 1;
                else
                        nccr |= 0x0080;
        }
 
        if (mcr != nmcr)
-               write_scoop_reg(&corgiscoop_device.dev, SCOOP_MCR, nmcr);
+               write_scoop_reg(scoop, SCOOP_MCR, nmcr);
        if (cpr != ncpr)
-               write_scoop_reg(&corgiscoop_device.dev, SCOOP_CPR, ncpr);
+               write_scoop_reg(scoop, SCOOP_CPR, ncpr);
        if (ccr != nccr)
-               write_scoop_reg(&corgiscoop_device.dev, SCOOP_CCR, nccr);
+               write_scoop_reg(scoop, SCOOP_CCR, nccr);
        if (imr != nimr)
-               write_scoop_reg(&corgiscoop_device.dev, SCOOP_IMR, nimr);
+               write_scoop_reg(scoop, SCOOP_IMR, nimr);
 
        local_irq_restore(flags);
 
@@ -208,10 +207,18 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
 
 static void sharpsl_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
 {
+       sharpsl_pcmcia_init_reset(&scoop_devs[skt->nr]);
+
+       /* Enable interrupt */
+       write_scoop_reg(scoop_devs[skt->nr].dev, SCOOP_IMR, 0x00C0);
+       write_scoop_reg(scoop_devs[skt->nr].dev, SCOOP_MCR, 0x0101);
+       scoop_devs[skt->nr].keep_vs = NO_KEEP_VS;
 }
 
 static void sharpsl_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
 {
+       /* CF_BUS_OFF */
+       sharpsl_pcmcia_init_reset(&scoop_devs[skt->nr]);
 }
 
 static struct pcmcia_low_level sharpsl_pcmcia_ops = {
@@ -223,7 +230,7 @@ static struct pcmcia_low_level sharpsl_pcmcia_ops = {
        .socket_init            = sharpsl_pcmcia_socket_init,
        .socket_suspend         = sharpsl_pcmcia_socket_suspend,
        .first                          = 0,
-       .nr                                     = 1,
+       .nr                                     = 0,
 };
 
 static struct platform_device *sharpsl_pcmcia_device;
@@ -232,12 +239,15 @@ static int __init sharpsl_pcmcia_init(void)
 {
        int ret;
 
+       sharpsl_pcmcia_ops.nr=scoop_num;
        sharpsl_pcmcia_device = kmalloc(sizeof(*sharpsl_pcmcia_device), GFP_KERNEL);
        if (!sharpsl_pcmcia_device)
                return -ENOMEM;
+
        memset(sharpsl_pcmcia_device, 0, sizeof(*sharpsl_pcmcia_device));
        sharpsl_pcmcia_device->name = "pxa2xx-pcmcia";
        sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops;
+       sharpsl_pcmcia_device->dev.parent=scoop_devs[0].dev;
 
        ret = platform_device_register(sharpsl_pcmcia_device);
        if (ret)
@@ -257,7 +267,7 @@ static void __exit sharpsl_pcmcia_exit(void)
        platform_device_unregister(sharpsl_pcmcia_device);
 }
 
-module_init(sharpsl_pcmcia_init);
+fs_initcall(sharpsl_pcmcia_init);
 module_exit(sharpsl_pcmcia_exit);
 
 MODULE_DESCRIPTION("Sharp SL Series PCMCIA Support");
index e98bb3d80e7c30f086f1c7346128cc744793cbf8..d4ed508b38be5ea07f2ca96e0064a27e3896136b 100644 (file)
@@ -126,5 +126,5 @@ MODULE_AUTHOR("John Dorsey <john+@cs.cmu.edu>");
 MODULE_DESCRIPTION("Linux PCMCIA Card Services: SA-11x0 Socket Controller");
 MODULE_LICENSE("Dual MPL/GPL");
 
-module_init(sa11x0_pcmcia_init);
+fs_initcall(sa11x0_pcmcia_init);
 module_exit(sa11x0_pcmcia_exit);
index b441f43a6a55fdd00917fa1b281de6a4509d428b..bb90a1448a53d0995b3067c07cd10015c8e3754a 100644 (file)
@@ -189,7 +189,7 @@ static void __exit sa1111_drv_pcmcia_exit(void)
        sa1111_driver_unregister(&pcmcia_driver);
 }
 
-module_init(sa1111_drv_pcmcia_init);
+fs_initcall(sa1111_drv_pcmcia_init);
 module_exit(sa1111_drv_pcmcia_exit);
 
 MODULE_DESCRIPTION("SA1111 PCMCIA card socket driver");
index db04ffb6f68c564cca51f335c81b92686229364e..59c5d968e9f67c00111dcf25f9aacc8802acbb06 100644 (file)
@@ -189,7 +189,7 @@ static int __init sa11xx_pcmcia_init(void)
 {
        return 0;
 }
-module_init(sa11xx_pcmcia_init);
+fs_initcall(sa11xx_pcmcia_init);
 
 static void __exit sa11xx_pcmcia_exit(void) {}
 
index dc1c89dbdb8f57a470cd1bb811ac889654087231..6e7d7b06421d233f1521568656bd193a6b9f7bee 100644 (file)
@@ -49,7 +49,7 @@ config DASD_FBA
 
 config DASD_DIAG
        tristate "Support for DIAG access to Disks"
-       depends on DASD && ARCH_S390X = 'n'
+       depends on DASD && ( ARCH_S390X = 'n' || EXPERIMENTAL)
        help
          Select this option if you want to use Diagnose250 command to access
          Disks under VM.  If you are not running under VM or unsure what it is,
index d5f53980749b5cabf8f9ba4dc4d8120e0d0d79b9..8fc891a9d47f569b823c02ed7dc85855f464fd0c 100644 (file)
@@ -7,7 +7,7 @@
  * Bugreports.to..: <Linux390@de.ibm.com>
  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
  *
- * $Revision: 1.165 $
+ * $Revision: 1.167 $
  */
 
 #include <linux/config.h>
@@ -1131,17 +1131,13 @@ __dasd_process_blk_queue(struct dasd_device * device)
        request_queue_t *queue;
        struct request *req;
        struct dasd_ccw_req *cqr;
-       int nr_queued, feature_ro;
+       int nr_queued;
 
        queue = device->request_queue;
        /* No queue ? Then there is nothing to do. */
        if (queue == NULL)
                return;
 
-       feature_ro = dasd_get_feature(device->cdev, DASD_FEATURE_READONLY);
-       if (feature_ro < 0)     /* no devmap */
-               return;
-
        /*
         * We requeue request from the block device queue to the ccw
         * queue only in two states. In state DASD_STATE_READY the
@@ -1162,7 +1158,8 @@ __dasd_process_blk_queue(struct dasd_device * device)
                nr_queued < DASD_CHANQ_MAX_SIZE) {
                req = elv_next_request(queue);
 
-               if (feature_ro && rq_data_dir(req) == WRITE) {
+               if (device->features & DASD_FEATURE_READONLY &&
+                   rq_data_dir(req) == WRITE) {
                        DBF_DEV_EVENT(DBF_ERR, device,
                                      "Rejecting write request %p",
                                      req);
@@ -1814,17 +1811,13 @@ dasd_generic_set_online (struct ccw_device *cdev,
 
 {
        struct dasd_device *device;
-       int feature_diag, rc;
+       int rc;
 
        device = dasd_create_device(cdev);
        if (IS_ERR(device))
                return PTR_ERR(device);
 
-       feature_diag = dasd_get_feature(cdev, DASD_FEATURE_USEDIAG);
-       if (feature_diag < 0)
-               return feature_diag;
-
-       if (feature_diag) {
+       if (device->features & DASD_FEATURE_USEDIAG) {
                if (!dasd_diag_discipline_pointer) {
                        printk (KERN_WARNING
                                "dasd_generic couldn't online device %s "
index d948566bb24a32e211797259d92af82fed6f50b1..bda896d9d788f3b4ab83a694324c641a8b02223d 100644 (file)
@@ -11,7 +11,7 @@
  * functions may not be called from interrupt context. In particular
  * dasd_get_device is a no-no from interrupt context.
  *
- * $Revision: 1.40 $
+ * $Revision: 1.43 $
  */
 
 #include <linux/config.h>
@@ -513,6 +513,7 @@ dasd_create_device(struct ccw_device *cdev)
        if (!devmap->device) {
                devmap->device = device;
                device->devindex = devmap->devindex;
+               device->features = devmap->features;
                get_device(&cdev->dev);
                device->cdev = cdev;
                rc = 0;
@@ -643,6 +644,8 @@ dasd_ro_store(struct device *dev, struct device_attribute *attr, const char *buf
                devmap->features |= DASD_FEATURE_READONLY;
        else
                devmap->features &= ~DASD_FEATURE_READONLY;
+       if (devmap->device)
+               devmap->device->features = devmap->features;
        if (devmap->device && devmap->device->gdp)
                set_disk_ro(devmap->device->gdp, ro_flag);
        spin_unlock(&dasd_devmap_lock);
@@ -758,7 +761,8 @@ dasd_set_feature(struct ccw_device *cdev, int feature, int flag)
                devmap->features |= feature;
        else
                devmap->features &= ~feature;
-
+       if (devmap->device)
+               devmap->device->features = devmap->features;
        spin_unlock(&dasd_devmap_lock);
        return 0;
 }
index 127699830fa18a46ee98836af72ebdbf16d89f1e..7478423b53bb2e6b1ae09f4296466c0998344e08 100644 (file)
@@ -6,17 +6,18 @@
  * Bugreports.to..: <Linux390@de.ibm.com>
  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
  *
- * $Revision: 1.42 $
+ * $Revision: 1.49 $
  */
 
 #include <linux/config.h>
 #include <linux/stddef.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
-#include <linux/hdreg.h>       /* HDIO_GETGEO                      */
+#include <linux/hdreg.h>
 #include <linux/bio.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/jiffies.h>
 
 #include <asm/dasd.h>
 #include <asm/debug.h>
 #include "dasd_int.h"
 #include "dasd_diag.h"
 
-#ifdef PRINTK_HEADER
-#undef PRINTK_HEADER
-#endif                         /* PRINTK_HEADER */
 #define PRINTK_HEADER "dasd(diag):"
 
 MODULE_LICENSE("GPL");
 
+/* The maximum number of blocks per request (max_blocks) is dependent on the
+ * amount of storage that is available in the static I/O buffer for each
+ * device. Currently each device gets 2 pages. We want to fit two requests
+ * into the available memory so that we can immediately start the next if one
+ * finishes. */
+#define DIAG_MAX_BLOCKS        (((2 * PAGE_SIZE - sizeof(struct dasd_ccw_req) - \
+                          sizeof(struct dasd_diag_req)) / \
+                          sizeof(struct dasd_diag_bio)) / 2)
+#define DIAG_MAX_RETRIES       32
+#define DIAG_TIMEOUT           50 * HZ
+
 struct dasd_discipline dasd_diag_discipline;
 
 struct dasd_diag_private {
        struct dasd_diag_characteristics rdc_data;
        struct dasd_diag_rw_io iob;
        struct dasd_diag_init_io iib;
-       unsigned int pt_block;
+       blocknum_t pt_block;
 };
 
 struct dasd_diag_req {
-       int block_count;
+       unsigned int block_count;
        struct dasd_diag_bio bio[0];
 };
 
+static const u8 DASD_DIAG_CMS1[] = { 0xc3, 0xd4, 0xe2, 0xf1 };/* EBCDIC CMS1 */
+
+/* Perform DIAG250 call with block I/O parameter list iob (input and output)
+ * and function code cmd.
+ * In case of an exception return 3. Otherwise return result of bitwise OR of
+ * resulting condition code and DIAG return code. */
 static __inline__ int
 dia250(void *iob, int cmd)
 {
+       typedef struct {
+               char _[max(sizeof (struct dasd_diag_init_io),
+                          sizeof (struct dasd_diag_rw_io))];
+       } addr_type;
        int rc;
 
-       __asm__ __volatile__("    lhi   %0,3\n"
-                            "    lr    0,%2\n"
-                            "    diag  0,%1,0x250\n"
-                            "0:  ipm   %0\n"
-                            "    srl   %0,28\n"
-                            "    or    %0,1\n"
-                            "1:\n"
-#ifndef CONFIG_ARCH_S390X
-                            ".section __ex_table,\"a\"\n"
-                            "    .align 4\n"
-                            "    .long 0b,1b\n"
-                            ".previous\n"
+       __asm__ __volatile__(
+#ifdef CONFIG_ARCH_S390X
+               "       lghi    %0,3\n"
+               "       lgr     0,%3\n"
+               "       diag    0,%2,0x250\n"
+               "0:     ipm     %0\n"
+               "       srl     %0,28\n"
+               "       or      %0,1\n"
+               "1:\n"
+               ".section __ex_table,\"a\"\n"
+               "       .align 8\n"
+               "       .quad  0b,1b\n"
+               ".previous\n"
 #else
-                            ".section __ex_table,\"a\"\n"
-                            "    .align 8\n"
-                            "    .quad  0b,1b\n"
-                            ".previous\n"
+               "       lhi     %0,3\n"
+               "       lr      0,%3\n"
+               "       diag    0,%2,0x250\n"
+               "0:     ipm     %0\n"
+               "       srl     %0,28\n"
+               "       or      %0,1\n"
+               "1:\n"
+               ".section __ex_table,\"a\"\n"
+               "       .align 4\n"
+               "       .long 0b,1b\n"
+               ".previous\n"
 #endif
-                            : "=&d" (rc)
-                            : "d" (cmd), "d" ((void *) __pa(iob))
-                            : "0", "1", "cc");
+               : "=&d" (rc), "=m" (*(addr_type *) iob)
+               : "d" (cmd), "d" (iob), "m" (*(addr_type *) iob)
+               : "0", "1", "cc");
        return rc;
 }
 
+/* Initialize block I/O to DIAG device using the specified blocksize and
+ * block offset. On success, return zero and set end_block to contain the
+ * number of blocks on the device minus the specified offset. Return non-zero
+ * otherwise. */
 static __inline__ int
-mdsk_init_io(struct dasd_device * device, int blocksize, int offset, int size)
+mdsk_init_io(struct dasd_device *device, unsigned int blocksize,
+            blocknum_t offset, blocknum_t *end_block)
 {
        struct dasd_diag_private *private;
        struct dasd_diag_init_io *iib;
@@ -92,14 +124,18 @@ mdsk_init_io(struct dasd_device * device, int blocksize, int offset, int size)
        iib->dev_nr = _ccw_device_get_device_number(device->cdev);
        iib->block_size = blocksize;
        iib->offset = offset;
-       iib->start_block = 0;
-       iib->end_block = size;
+       iib->flaga = DASD_DIAG_FLAGA_DEFAULT;
 
        rc = dia250(iib, INIT_BIO);
 
-       return rc & 3;
+       if ((rc & 3) == 0 && end_block)
+               *end_block = iib->end_block;
+
+       return rc;
 }
 
+/* Remove block I/O environment for device. Return zero on success, non-zero
+ * otherwise. */
 static __inline__ int
 mdsk_term_io(struct dasd_device * device)
 {
@@ -112,9 +148,25 @@ mdsk_term_io(struct dasd_device * device)
        memset(iib, 0, sizeof (struct dasd_diag_init_io));
        iib->dev_nr = _ccw_device_get_device_number(device->cdev);
        rc = dia250(iib, TERM_BIO);
-       return rc & 3;
+       return rc;
+}
+
+/* Error recovery for failed DIAG requests - try to reestablish the DIAG
+ * environment. */
+static void
+dasd_diag_erp(struct dasd_device *device)
+{
+       int rc;
+
+       mdsk_term_io(device);
+       rc = mdsk_init_io(device, device->bp_block, 0, NULL);
+       if (rc)
+               DEV_MESSAGE(KERN_WARNING, device, "DIAG ERP unsuccessful, "
+                           "rc=%d", rc);
 }
 
+/* Start a given request at the device. Return zero on success, non-zero
+ * otherwise. */
 static int
 dasd_start_diag(struct dasd_ccw_req * cqr)
 {
@@ -124,32 +176,66 @@ dasd_start_diag(struct dasd_ccw_req * cqr)
        int rc;
 
        device = cqr->device;
+       if (cqr->retries < 0) {
+               DEV_MESSAGE(KERN_WARNING, device, "DIAG start_IO: request %p "
+                           "- no retry left)", cqr);
+               cqr->status = DASD_CQR_FAILED;
+               return -EIO;
+       }
        private = (struct dasd_diag_private *) device->private;
        dreq = (struct dasd_diag_req *) cqr->data;
 
        private->iob.dev_nr = _ccw_device_get_device_number(device->cdev);
        private->iob.key = 0;
-       private->iob.flags = 2; /* do asynchronous io */
+       private->iob.flags = DASD_DIAG_RWFLAG_ASYNC;
        private->iob.block_count = dreq->block_count;
-       private->iob.interrupt_params = (u32)(addr_t) cqr;
+       private->iob.interrupt_params = (addr_t) cqr;
        private->iob.bio_list = __pa(dreq->bio);
+       private->iob.flaga = DASD_DIAG_FLAGA_DEFAULT;
 
        cqr->startclk = get_clock();
+       cqr->starttime = jiffies;
+       cqr->retries--;
 
        rc = dia250(&private->iob, RW_BIO);
-       if (rc > 8) {
-               DEV_MESSAGE(KERN_WARNING, device, "dia250 returned CC %d", rc);
-               cqr->status = DASD_CQR_ERROR;
-       } else if (rc == 0) {
+       switch (rc) {
+       case 0: /* Synchronous I/O finished successfully */
+               cqr->stopclk = get_clock();
                cqr->status = DASD_CQR_DONE;
-               dasd_schedule_bh(device);
-       } else {
+               /* Indicate to calling function that only a dasd_schedule_bh()
+                  and no timer is needed */
+                rc = -EACCES;
+               break;
+       case 8: /* Asynchronous I/O was started */
                cqr->status = DASD_CQR_IN_IO;
                rc = 0;
+               break;
+       default: /* Error condition */
+               cqr->status = DASD_CQR_QUEUED;
+               DEV_MESSAGE(KERN_WARNING, device, "dia250 returned rc=%d", rc);
+               dasd_diag_erp(device);
+               rc = -EIO;
+               break;
        }
        return rc;
 }
 
+/* Terminate given request at the device. */
+static int
+dasd_diag_term_IO(struct dasd_ccw_req * cqr)
+{
+       struct dasd_device *device;
+
+       device = cqr->device;
+       mdsk_term_io(device);
+       mdsk_init_io(device, device->bp_block, 0, NULL);
+       cqr->status = DASD_CQR_CLEAR;
+       cqr->stopclk = get_clock();
+       dasd_schedule_bh(device);
+       return 0;
+}
+
+/* Handle external interruption. */
 static void
 dasd_ext_handler(struct pt_regs *regs, __u16 code)
 {
@@ -157,25 +243,27 @@ dasd_ext_handler(struct pt_regs *regs, __u16 code)
        struct dasd_device *device;
        unsigned long long expires;
        unsigned long flags;
-       char status;
-       int ip;
-
-       /*
-        * Get the external interruption subcode. VM stores
-        * this in the 'cpu address' field associated with
-        * the external interrupt. For diag 250 the subcode
-        * needs to be 3.
-        */
-       if ((S390_lowcore.cpu_addr & 0xff00) != 0x0300)
-               return;
-       status = *((char *) &S390_lowcore.ext_params + 5);
-       ip = S390_lowcore.ext_params;
+       u8 int_code, status;
+       addr_t ip;
+       int rc;
 
+       int_code = *((u8 *) DASD_DIAG_LC_INT_CODE);
+       status = *((u8 *) DASD_DIAG_LC_INT_STATUS);
+       switch (int_code) {
+       case DASD_DIAG_CODE_31BIT:
+               ip = (addr_t) *((u32 *) DASD_DIAG_LC_INT_PARM_31BIT);
+               break;
+       case DASD_DIAG_CODE_64BIT:
+               ip = (addr_t) *((u64 *) DASD_DIAG_LC_INT_PARM_64BIT);
+               break;
+       default:
+               return;
+       }
        if (!ip) {              /* no intparm: unsolicited interrupt */
                MESSAGE(KERN_DEBUG, "%s", "caught unsolicited interrupt");
                return;
        }
-       cqr = (struct dasd_ccw_req *)(addr_t) ip;
+       cqr = (struct dasd_ccw_req *) ip;
        device = (struct dasd_device *) cqr->device;
        if (strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) {
                DEV_MESSAGE(KERN_WARNING, device,
@@ -188,6 +276,15 @@ dasd_ext_handler(struct pt_regs *regs, __u16 code)
        /* get irq lock to modify request queue */
        spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
 
+       /* Check for a pending clear operation */
+       if (cqr->status == DASD_CQR_CLEAR) {
+               cqr->status = DASD_CQR_QUEUED;
+               dasd_clear_timer(device);
+               dasd_schedule_bh(device);
+               spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
+               return;
+       }
+
        cqr->stopclk = get_clock();
 
        expires = 0;
@@ -198,16 +295,22 @@ dasd_ext_handler(struct pt_regs *regs, __u16 code)
                        next = list_entry(device->ccw_queue.next,
                                          struct dasd_ccw_req, list);
                        if (next->status == DASD_CQR_QUEUED) {
-                               if (dasd_start_diag(next) == 0)
+                               rc = dasd_start_diag(next);
+                               if (rc == 0)
                                        expires = next->expires;
-                               else
+                               else if (rc != -EACCES)
                                        DEV_MESSAGE(KERN_WARNING, device, "%s",
                                                    "Interrupt fastpath "
                                                    "failed!");
                        }
                }
-       } else 
-               cqr->status = DASD_CQR_FAILED;
+       } else {
+               cqr->status = DASD_CQR_QUEUED;
+               DEV_MESSAGE(KERN_WARNING, device, "interrupt status for "
+                           "request %p was %d (%d retries left)", cqr, status,
+                           cqr->retries);
+               dasd_diag_erp(device);
+       }
 
        if (expires != 0)
                dasd_set_timer(device, expires);
@@ -218,14 +321,17 @@ dasd_ext_handler(struct pt_regs *regs, __u16 code)
        spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
 }
 
+/* Check whether device can be controlled by DIAG discipline. Return zero on
+ * success, non-zero otherwise. */
 static int
 dasd_diag_check_device(struct dasd_device *device)
 {
        struct dasd_diag_private *private;
        struct dasd_diag_characteristics *rdc_data;
        struct dasd_diag_bio bio;
-       long *label;
-       int sb, bsize;
+       struct dasd_diag_cms_label *label;
+       blocknum_t end_block;
+       unsigned int sb, bsize;
        int rc;
 
        private = (struct dasd_diag_private *) device->private;
@@ -244,8 +350,11 @@ dasd_diag_check_device(struct dasd_device *device)
        rdc_data->rdc_len = sizeof (struct dasd_diag_characteristics);
 
        rc = diag210((struct diag210 *) rdc_data);
-       if (rc)
+       if (rc) {
+               DEV_MESSAGE(KERN_WARNING, device, "failed to retrieve device "
+                           "information (rc=%d)", rc);
                return -ENOTSUPP;
+       }
 
        /* Figure out position of label block */
        switch (private->rdc_data.vdev_class) {
@@ -256,6 +365,8 @@ dasd_diag_check_device(struct dasd_device *device)
                private->pt_block = 2;
                break;
        default:
+               DEV_MESSAGE(KERN_WARNING, device, "unsupported device class "
+                           "(class=%d)", private->rdc_data.vdev_class);
                return -ENOTSUPP;
        }
 
@@ -269,15 +380,17 @@ dasd_diag_check_device(struct dasd_device *device)
        mdsk_term_io(device);
 
        /* figure out blocksize of device */
-       label = (long *) get_zeroed_page(GFP_KERNEL);
+       label = (struct dasd_diag_cms_label *) get_zeroed_page(GFP_KERNEL);
        if (label == NULL)  {
                DEV_MESSAGE(KERN_WARNING, device, "%s",
                            "No memory to allocate initialization request");
                return -ENOMEM;
        }
+       rc = 0;
+       end_block = 0;
        /* try all sizes - needed for ECKD devices */
        for (bsize = 512; bsize <= PAGE_SIZE; bsize <<= 1) {
-               mdsk_init_io(device, bsize, 0, 64);
+               mdsk_init_io(device, bsize, 0, &end_block);
                memset(&bio, 0, sizeof (struct dasd_diag_bio));
                bio.type = MDSK_READ_REQ;
                bio.block_number = private->pt_block + 1;
@@ -289,37 +402,45 @@ dasd_diag_check_device(struct dasd_device *device)
                private->iob.block_count = 1;
                private->iob.interrupt_params = 0;
                private->iob.bio_list = __pa(&bio);
-               if (dia250(&private->iob, RW_BIO) == 0)
+               private->iob.flaga = DASD_DIAG_FLAGA_DEFAULT;
+               rc = dia250(&private->iob, RW_BIO);
+               if (rc == 0 || rc == 3)
                        break;
                mdsk_term_io(device);
        }
-       if (bsize <= PAGE_SIZE && label[0] == 0xc3d4e2f1) {
-               /* get formatted blocksize from label block */
-               bsize = (int) label[3];
-               device->blocks = label[7];
+       if (rc == 3) {
+               DEV_MESSAGE(KERN_WARNING, device, "%s", "DIAG call failed");
+               rc = -EOPNOTSUPP;
+       } else if (rc != 0) {
+               DEV_MESSAGE(KERN_WARNING, device, "device access failed "
+                           "(rc=%d)", rc);
+               rc = -EIO;
+       } else {
+               if (memcmp(label->label_id, DASD_DIAG_CMS1,
+                         sizeof(DASD_DIAG_CMS1)) == 0) {
+                       /* get formatted blocksize from label block */
+                       bsize = (unsigned int) label->block_size;
+                       device->blocks = (unsigned long) label->block_count;
+               } else
+                       device->blocks = end_block;
                device->bp_block = bsize;
                device->s2b_shift = 0;  /* bits to shift 512 to get a block */
                for (sb = 512; sb < bsize; sb = sb << 1)
                        device->s2b_shift++;
                
                DEV_MESSAGE(KERN_INFO, device,
-                           "capacity (%dkB blks): %ldkB",
-                           (device->bp_block >> 10),
-                           (device->blocks << device->s2b_shift) >> 1);
+                           "(%ld B/blk): %ldkB",
+                           (unsigned long) device->bp_block,
+                           (unsigned long) (device->blocks <<
+                               device->s2b_shift) >> 1);
                rc = 0;
-       } else {
-               if (bsize > PAGE_SIZE)
-                       DEV_MESSAGE(KERN_WARNING, device, "%s",
-                                   "DIAG access failed");
-               else
-                       DEV_MESSAGE(KERN_WARNING, device, "%s",
-                                   "volume is not CMS formatted");
-               rc = -EMEDIUMTYPE;
        }
        free_page((long) label);
        return rc;
 }
 
+/* Fill in virtual disk geometry for device. Return zero on success, non-zero
+ * otherwise. */
 static int
 dasd_diag_fill_geometry(struct dasd_device *device, struct hd_geometry *geo)
 {
@@ -349,6 +470,8 @@ dasd_diag_erp_postaction(struct dasd_ccw_req * cqr)
        return dasd_default_erp_postaction;
 }
 
+/* Create DASD request from block device request. Return pointer to new
+ * request on success, ERR_PTR otherwise. */
 static struct dasd_ccw_req *
 dasd_diag_build_cp(struct dasd_device * device, struct request *req)
 {
@@ -358,9 +481,9 @@ dasd_diag_build_cp(struct dasd_device * device, struct request *req)
        struct bio *bio;
        struct bio_vec *bv;
        char *dst;
-       int count, datasize;
+       unsigned int count, datasize;
        sector_t recid, first_rec, last_rec;
-       unsigned blksize, off;
+       unsigned int blksize, off;
        unsigned char rw_cmd;
        int i;
 
@@ -413,13 +536,16 @@ dasd_diag_build_cp(struct dasd_device * device, struct request *req)
                        }
                }
        }
+       cqr->retries = DIAG_MAX_RETRIES;
        cqr->buildclk = get_clock();
        cqr->device = device;
-       cqr->expires = 50 * HZ; /* 50 seconds */
+       cqr->expires = DIAG_TIMEOUT;
        cqr->status = DASD_CQR_FILLED;
        return cqr;
 }
 
+/* Release DASD request. Return non-zero if request was successful, zero
+ * otherwise. */
 static int
 dasd_diag_free_cp(struct dasd_ccw_req *cqr, struct request *req)
 {
@@ -430,6 +556,7 @@ dasd_diag_free_cp(struct dasd_ccw_req *cqr, struct request *req)
        return status;
 }
 
+/* Fill in IOCTL data for device. */
 static int
 dasd_diag_fill_info(struct dasd_device * device,
                    struct dasd_information2_t * info)
@@ -437,7 +564,7 @@ dasd_diag_fill_info(struct dasd_device * device,
        struct dasd_diag_private *private;
 
        private = (struct dasd_diag_private *) device->private;
-       info->label_block = private->pt_block;
+       info->label_block = (unsigned int) private->pt_block;
        info->FBA_layout = 1;
        info->format = DASD_FORMAT_LDL;
        info->characteristics_size = sizeof (struct dasd_diag_characteristics);
@@ -456,26 +583,15 @@ dasd_diag_dump_sense(struct dasd_device *device, struct dasd_ccw_req * req,
                    "dump sense not available for DIAG data");
 }
 
-/*
- * max_blocks is dependent on the amount of storage that is available
- * in the static io buffer for each device. Currently each device has
- * 8192 bytes (=2 pages). dasd diag is only relevant for 31 bit.
- * The struct dasd_ccw_req has 96 bytes, the struct dasd_diag_req has
- * 8 bytes and the struct dasd_diag_bio for each block has 16 bytes. 
- * That makes:
- * (8192 - 96 - 8) / 16 = 505.5 blocks at maximum.
- * We want to fit two into the available memory so that we can immediately
- * start the next request if one finishes off. That makes 252.75 blocks
- * for one request. Give a little safety and the result is 240.
- */
 struct dasd_discipline dasd_diag_discipline = {
        .owner = THIS_MODULE,
        .name = "DIAG",
        .ebcname = "DIAG",
-       .max_blocks = 240,
+       .max_blocks = DIAG_MAX_BLOCKS,
        .check_device = dasd_diag_check_device,
        .fill_geometry = dasd_diag_fill_geometry,
        .start_IO = dasd_start_diag,
+       .term_IO = dasd_diag_term_IO,
        .examine_error = dasd_diag_examine_error,
        .erp_action = dasd_diag_erp_action,
        .erp_postaction = dasd_diag_erp_postaction,
@@ -493,7 +609,7 @@ dasd_diag_init(void)
                            "Machine is not VM: %s "
                            "discipline not initializing",
                            dasd_diag_discipline.name);
-               return -EINVAL;
+               return -ENODEV;
        }
        ASCEBC(dasd_diag_discipline.ebcname, 4);
 
@@ -506,13 +622,6 @@ dasd_diag_init(void)
 static void __exit
 dasd_diag_cleanup(void)
 {
-       if (!MACHINE_IS_VM) {
-               MESSAGE_LOG(KERN_INFO,
-                           "Machine is not VM: %s "
-                           "discipline not cleaned",
-                           dasd_diag_discipline.name);
-               return;
-       }
        unregister_external_interrupt(0x2603, dasd_ext_handler);
        ctl_clear_bit(0, 9);
        dasd_diag_discipline_pointer = NULL;
@@ -520,22 +629,3 @@ dasd_diag_cleanup(void)
 
 module_init(dasd_diag_init);
 module_exit(dasd_diag_cleanup);
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-indent-level: 4 
- * c-brace-imaginary-offset: 0
- * c-brace-offset: -4
- * c-argdecl-indent: 4
- * c-label-offset: -4
- * c-continued-statement-offset: 4
- * c-continued-brace-offset: 0
- * indent-tabs-mode: 1
- * tab-width: 8
- * End:
- */
index a0c38e3039798527cc5ffbf13065af9a2c555b67..b26eb28df4bf093e4b6816275ba46d91d4236896 100644 (file)
@@ -6,7 +6,7 @@
  * Bugreports.to..: <Linux390@de.ibm.com>
  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
  *
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
  */
 
 #define MDSK_WRITE_REQ 0x01
 #define DEV_CLASS_FBA  0x01
 #define DEV_CLASS_ECKD 0x04
 
+#define DASD_DIAG_LC_INT_CODE          132
+#define DASD_DIAG_LC_INT_STATUS                133
+#define DASD_DIAG_LC_INT_PARM_31BIT    128
+#define DASD_DIAG_LC_INT_PARM_64BIT    4536
+#define DASD_DIAG_CODE_31BIT           0x03
+#define DASD_DIAG_CODE_64BIT           0x07
+
+#define DASD_DIAG_RWFLAG_ASYNC         0x02
+#define DASD_DIAG_RWFLAG_NOCACHE       0x01
+
+#define DASD_DIAG_FLAGA_FORMAT_64BIT   0x80
+
 struct dasd_diag_characteristics {
        u16 dev_nr;
        u16 rdc_len;
@@ -32,35 +44,106 @@ struct dasd_diag_characteristics {
        u8 rdev_features;
 } __attribute__ ((packed, aligned(4)));
 
+struct dasd_diag_cms_label {
+       u8 label_id[4];
+       u8 vol_id[6];
+       u16 version_id;
+       u32 block_size;
+       u32 origin_ptr;
+       u32 usable_count;
+       u32 formatted_count;
+       u32 block_count;
+       u32 used_count;
+       u32 fst_size;
+       u32 fst_count;
+       u8 format_date[6];
+       u8 reserved1[2];
+       u32 disk_offset;
+       u32 map_block;
+       u32 hblk_disp;
+       u32 user_disp;
+       u8 reserved2[4];
+       u8 segment_name[8];
+} __attribute__ ((packed));
+
+#ifdef CONFIG_ARCH_S390X
+#define DASD_DIAG_FLAGA_DEFAULT                DASD_DIAG_FLAGA_FORMAT_64BIT
+
+typedef u64 blocknum_t;
+typedef s64 sblocknum_t;
+
+struct dasd_diag_bio {
+       u8 type;
+       u8 status;
+       u8 spare1[2];
+       u32 alet;
+       blocknum_t block_number;
+       u64 buffer;
+} __attribute__ ((packed, aligned(8)));
+
+struct dasd_diag_init_io {
+       u16 dev_nr;
+       u8 flaga;
+       u8 spare1[21];
+       u32 block_size;
+       u8 spare2[4];
+       blocknum_t offset;
+       sblocknum_t start_block;
+       blocknum_t end_block;
+       u8  spare3[8];
+} __attribute__ ((packed, aligned(8)));
+
+struct dasd_diag_rw_io {
+       u16 dev_nr;
+       u8  flaga;
+       u8  spare1[21];
+       u8  key;
+       u8  flags;
+       u8  spare2[2];
+       u32 block_count;
+       u32 alet;
+       u8  spare3[4];
+       u64 interrupt_params;
+       u64 bio_list;
+       u8  spare4[8];
+} __attribute__ ((packed, aligned(8)));
+#else /* CONFIG_ARCH_S390X */
+#define DASD_DIAG_FLAGA_DEFAULT                0x0
+
+typedef u32 blocknum_t;
+typedef s32 sblocknum_t;
+
 struct dasd_diag_bio {
        u8 type;
        u8 status;
        u16 spare1;
-       u32 block_number;
+       blocknum_t block_number;
        u32 alet;
        u32 buffer;
 } __attribute__ ((packed, aligned(8)));
 
 struct dasd_diag_init_io {
        u16 dev_nr;
-       u16 spare1[11];
+       u8 flaga;
+       u8 spare1[21];
        u32 block_size;
-       u32 offset;
-       u32 start_block;
-       u32 end_block;
-       u32 spare2[6];
+       blocknum_t offset;
+       sblocknum_t start_block;
+       blocknum_t end_block;
+       u8 spare2[24];
 } __attribute__ ((packed, aligned(8)));
 
 struct dasd_diag_rw_io {
        u16 dev_nr;
-       u16 spare1[11];
+       u8 flaga;
+       u8 spare1[21];
        u8 key;
        u8 flags;
-       u16 spare2;
+       u8 spare2[2];
        u32 block_count;
        u32 alet;
        u32 bio_list;
        u32 interrupt_params;
-       u32 spare3[5];
+       u8 spare3[20];
 } __attribute__ ((packed, aligned(8)));
-
+#endif /* CONFIG_ARCH_S390X */
index 96c49349701f9f092b71e226bbf6bf5f4dde03b4..a601c9a33541cb7362223fee666de8f5a54d7284 100644 (file)
@@ -9,7 +9,7 @@
  *
  * gendisk related functions for the dasd driver.
  *
- * $Revision: 1.50 $
+ * $Revision: 1.51 $
  */
 
 #include <linux/config.h>
@@ -31,16 +31,12 @@ int
 dasd_gendisk_alloc(struct dasd_device *device)
 {
        struct gendisk *gdp;
-       int len, feature_ro;
+       int len;
 
        /* Make sure the minor for this device exists. */
        if (device->devindex >= DASD_PER_MAJOR)
                return -EBUSY;
 
-       feature_ro = dasd_get_feature(device->cdev, DASD_FEATURE_READONLY);
-       if (feature_ro < 0)
-               return feature_ro;
-
        gdp = alloc_disk(1 << DASD_PARTN_BITS);
        if (!gdp)
                return -ENOMEM;
@@ -75,7 +71,7 @@ dasd_gendisk_alloc(struct dasd_device *device)
 
        sprintf(gdp->devfs_name, "dasd/%s", device->cdev->dev.bus_id);
 
-       if (feature_ro)
+       if (device->features & DASD_FEATURE_READONLY)
                set_disk_ro(gdp, 1);
        gdp->private_data = device;
        gdp->queue = device->request_queue;
index a9f38b235981897ac73b35cb5f3e261fe1203ed5..9fab04f3056d6742fe7be6c68a4e2b8719f471ab 100644 (file)
@@ -6,7 +6,7 @@
  * Bugreports.to..: <Linux390@de.ibm.com>
  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
  *
- * $Revision: 1.64 $
+ * $Revision: 1.65 $
  */
 
 #ifndef DASD_INT_H
@@ -286,6 +286,7 @@ struct dasd_device {
        unsigned int bp_block;          /* bytes per block */
        unsigned int s2b_shift;         /* log2 (bp_block/512) */
        unsigned long flags;            /* per device flags */
+       unsigned short features;        /* copy of devmap-features (read-only!) */
 
        /* Device discipline stuff. */
        struct dasd_discipline *discipline;
index 980c555aa538791687d7c1c8d26d7ddb9e080db0..789595b3fa09ced145a698bfbd11f83fceb848ef 100644 (file)
@@ -7,7 +7,7 @@
  * Bugreports.to..: <Linux390@de.ibm.com>
  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
  *
- * $Revision: 1.45 $
+ * $Revision: 1.47 $
  *
  * i/o controls for the dasd driver.
  */
@@ -296,7 +296,6 @@ dasd_ioctl_format(struct block_device *bdev, int no, long args)
 {
        struct dasd_device *device;
        struct format_data_t fdata;
-       int feature_ro;
 
        if (!capable(CAP_SYS_ADMIN))
                return -EACCES;
@@ -308,10 +307,7 @@ dasd_ioctl_format(struct block_device *bdev, int no, long args)
        if (device == NULL)
                return -ENODEV;
 
-       feature_ro = dasd_get_feature(device->cdev, DASD_FEATURE_READONLY);
-       if (feature_ro < 0)
-               return feature_ro;
-       if (feature_ro)
+       if (device->features & DASD_FEATURE_READONLY)
                return -EROFS;
        if (copy_from_user(&fdata, (void __user *) args,
                           sizeof (struct format_data_t)))
@@ -384,7 +380,7 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
        struct dasd_device *device;
        struct dasd_information2_t *dasd_info;
        unsigned long flags;
-       int rc, feature_ro;
+       int rc;
        struct ccw_device *cdev;
 
        device = bdev->bd_disk->private_data;
@@ -394,10 +390,6 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
        if (!device->discipline->fill_info)
                return -EINVAL;
 
-       feature_ro = dasd_get_feature(device->cdev, DASD_FEATURE_READONLY);
-       if (feature_ro < 0)
-               return feature_ro;
-
        dasd_info = kmalloc(sizeof(struct dasd_information2_t), GFP_KERNEL);
        if (dasd_info == NULL)
                return -ENOMEM;
@@ -427,7 +419,8 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
            (dasd_check_blocksize(device->bp_block)))
                dasd_info->format = DASD_FORMAT_NONE;
 
-       dasd_info->features |= feature_ro;
+       dasd_info->features |=
+               ((device->features & DASD_FEATURE_READONLY) != 0);
 
        if (device->discipline)
                memcpy(dasd_info->type, device->discipline->name, 4);
index 43c34f8c5e685336daeaf87021d4a683720adaa8..fff9020d48866bd2910fad640f105a9ccd0032e4 100644 (file)
@@ -9,7 +9,7 @@
  *
  * /proc interface for the dasd driver.
  *
- * $Revision: 1.32 $
+ * $Revision: 1.33 $
  */
 
 #include <linux/config.h>
@@ -55,7 +55,6 @@ dasd_devices_show(struct seq_file *m, void *v)
 {
        struct dasd_device *device;
        char *substr;
-       int feature;
 
        device = dasd_device_from_devindex((unsigned long) v - 1);
        if (IS_ERR(device))
@@ -79,10 +78,7 @@ dasd_devices_show(struct seq_file *m, void *v)
        else
                seq_printf(m, " is ????????");
        /* Print devices features. */
-       feature = dasd_get_feature(device->cdev, DASD_FEATURE_READONLY);
-       if (feature < 0)
-               return 0;
-       substr = feature ? "(ro)" : " ";
+       substr = (device->features & DASD_FEATURE_READONLY) ? "(ro)" : " ";
        seq_printf(m, "%4s: ", substr);
        /* Print device status information. */
        switch ((device != NULL) ? device->state : -1) {
index d5eefeaba50ca209834c4d9c10879b9fe23f4c7f..328d9cbc56a37f0b064c94ceb61b7f37a81921bb 100644 (file)
@@ -632,12 +632,9 @@ __raw3270_size_device(struct raw3270 *rp)
        raw3270_init_request.ccw.cda = (__u32) __pa(raw3270_init_data);
 
        rc = raw3270_start_init(rp, &raw3270_init_view, &raw3270_init_request);
-       if (rc) {
+       if (rc)
                /* Check error cases: -ERESTARTSYS, -EIO and -EOPNOTSUPP */
-               if (rc == -EOPNOTSUPP && MACHINE_IS_VM)
-                       return __raw3270_size_device_vm(rp);
                return rc;
-       }
 
        /* Wait for attention interrupt. */
 #ifdef CONFIG_TN3270_CONSOLE
@@ -695,7 +692,10 @@ raw3270_size_device(struct raw3270 *rp)
        down(&raw3270_init_sem);
        rp->view = &raw3270_init_view;
        raw3270_init_view.dev = rp;
-       rc = __raw3270_size_device(rp);
+       if (MACHINE_IS_VM)
+               rc = __raw3270_size_device_vm(rp);
+       else
+               rc = __raw3270_size_device(rp);
        raw3270_init_view.dev = 0;
        rp->view = 0;
        up(&raw3270_init_sem);
@@ -710,6 +710,12 @@ raw3270_size_device(struct raw3270 *rp)
                        rp->model = 4;
                if (rp->rows == 27 && rp->cols == 132)
                        rp->model = 5;
+       } else {
+               /* Couldn't detect size. Use default model 2. */
+               rp->model = 2;
+               rp->rows = 24;
+               rp->cols = 80;
+               return 0;
        }
        return rc;
 }
index ea813bdce1d63a8617ddb2881b98a679bfb17445..185bc73c3ecde9c64717729a40b2591260302d25 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  drivers/s390/cio/cio.c
  *   S/390 common I/O routines -- low level i/o calls
- *   $Revision: 1.134 $
+ *   $Revision: 1.135 $
  *
  *    Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
  *                           IBM Corporation
@@ -815,8 +815,9 @@ __clear_subchannel_easy(unsigned int schid)
                struct tpi_info ti;
 
                if (tpi(&ti)) {
-                       tsch(schid, (struct irb *)__LC_IRB);
-                       return 0;
+                       tsch(ti.irq, (struct irb *)__LC_IRB);
+                       if (ti.irq == schid)
+                               return 0;
                }
                udelay(100);
        }
index ee7a05e0c3baf60a5e0effd52ca5c9b26b8989ea..fbe4202a3f6f462e2104e7acf84368f5cd15198f 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/init.h>
 
 #include <asm/ccwdev.h>
-#include <asm/qdio.h>
+#include <asm/cio.h>
 
 #include "cio.h"
 #include "cio_debug.h"
@@ -21,7 +21,6 @@
 #include "device.h"
 #include "chsc.h"
 #include "ioasm.h"
-#include "qdio.h"
 
 int
 device_is_online(struct subchannel *sch)
index 02d01a0de16c4e476e415cac49fc584726ab132a..ad3fe5aeb663a01d3f034cba4db8a879ec65e374 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  drivers/s390/cio/device_ops.c
  *
- *   $Revision: 1.56 $
+ *   $Revision: 1.57 $
  *
  *    Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
  *                      IBM Corporation
 
 #include <asm/ccwdev.h>
 #include <asm/idals.h>
-#include <asm/qdio.h>
 
 #include "cio.h"
 #include "cio_debug.h"
 #include "css.h"
 #include "chsc.h"
 #include "device.h"
-#include "qdio.h"
 
 int
 ccw_device_set_options(struct ccw_device *cdev, unsigned long flags)
index c874607d9a806ec9fccbe908a5569198c0351ae3..45480a2bc4c0ab534f2b156f8f71bcf66ae411c3 100644 (file)
@@ -21,7 +21,7 @@ struct tpi_info {
  * Some S390 specific IO instructions as inline
  */
 
-extern __inline__ int stsch(int irq, volatile struct schib *addr)
+static inline int stsch(int irq, volatile struct schib *addr)
 {
        int ccode;
 
@@ -36,7 +36,7 @@ extern __inline__ int stsch(int irq, volatile struct schib *addr)
        return ccode;
 }
 
-extern __inline__ int msch(int irq, volatile struct schib *addr)
+static inline int msch(int irq, volatile struct schib *addr)
 {
        int ccode;
 
@@ -51,7 +51,7 @@ extern __inline__ int msch(int irq, volatile struct schib *addr)
        return ccode;
 }
 
-extern __inline__ int msch_err(int irq, volatile struct schib *addr)
+static inline int msch_err(int irq, volatile struct schib *addr)
 {
        int ccode;
 
@@ -79,7 +79,7 @@ extern __inline__ int msch_err(int irq, volatile struct schib *addr)
        return ccode;
 }
 
-extern __inline__ int tsch(int irq, volatile struct irb *addr)
+static inline int tsch(int irq, volatile struct irb *addr)
 {
        int ccode;
 
@@ -94,7 +94,7 @@ extern __inline__ int tsch(int irq, volatile struct irb *addr)
        return ccode;
 }
 
-extern __inline__ int tpi( volatile struct tpi_info *addr)
+static inline int tpi( volatile struct tpi_info *addr)
 {
        int ccode;
 
@@ -108,7 +108,7 @@ extern __inline__ int tpi( volatile struct tpi_info *addr)
        return ccode;
 }
 
-extern __inline__ int ssch(int irq, volatile struct orb *addr)
+static inline int ssch(int irq, volatile struct orb *addr)
 {
        int ccode;
 
@@ -123,7 +123,7 @@ extern __inline__ int ssch(int irq, volatile struct orb *addr)
        return ccode;
 }
 
-extern __inline__ int rsch(int irq)
+static inline int rsch(int irq)
 {
        int ccode;
 
@@ -138,7 +138,7 @@ extern __inline__ int rsch(int irq)
        return ccode;
 }
 
-extern __inline__ int csch(int irq)
+static inline int csch(int irq)
 {
        int ccode;
 
@@ -153,7 +153,7 @@ extern __inline__ int csch(int irq)
        return ccode;
 }
 
-extern __inline__ int hsch(int irq)
+static inline int hsch(int irq)
 {
        int ccode;
 
@@ -168,7 +168,7 @@ extern __inline__ int hsch(int irq)
        return ccode;
 }
 
-extern __inline__ int xsch(int irq)
+static inline int xsch(int irq)
 {
        int ccode;
 
@@ -183,7 +183,7 @@ extern __inline__ int xsch(int irq)
        return ccode;
 }
 
-extern __inline__ int chsc(void *chsc_area)
+static inline int chsc(void *chsc_area)
 {
        int cc;
 
@@ -198,7 +198,7 @@ extern __inline__ int chsc(void *chsc_area)
        return cc;
 }
 
-extern __inline__ int iac( void)
+static inline int iac( void)
 {
        int ccode;
 
@@ -210,7 +210,7 @@ extern __inline__ int iac( void)
        return ccode;
 }
 
-extern __inline__ int rchp(int chpid)
+static inline int rchp(int chpid)
 {
        int ccode;
 
index bcabac7a7c460960f865c73ac2a723e170ac9df2..e319e78b5ea2374a26fd9894f6c3732796beb31d 100644 (file)
@@ -27,7 +27,7 @@
 #ifndef _Z90COMMON_H_
 #define _Z90COMMON_H_
 
-#define VERSION_Z90COMMON_H "$Revision: 1.16 $"
+#define VERSION_Z90COMMON_H "$Revision: 1.17 $"
 
 
 #define RESPBUFFSIZE 256
@@ -164,5 +164,4 @@ struct CPRBX {
 #define UMIN(a,b) ((a) < (b) ? (a) : (b))
 #define IS_EVEN(x) ((x) == (2 * ((x) / 2)))
 
-
 #endif
index beb6a5e0da2267508a70d845c6e81643ca41825b..c215e088973625087daf5985afd5cb97e0794976 100644 (file)
@@ -32,7 +32,7 @@
 #include "z90crypt.h"
 #include "z90common.h"
 
-#define VERSION_Z90HARDWARE_C "$Revision: 1.33 $"
+#define VERSION_Z90HARDWARE_C "$Revision: 1.34 $"
 
 char z90hardware_version[] __initdata =
        "z90hardware.o (" VERSION_Z90HARDWARE_C "/"
@@ -283,48 +283,6 @@ struct type6_msg {
        struct CPRB      CPRB;
 };
 
-union request_msg {
-       union  type4_msg t4msg;
-       struct type6_msg t6msg;
-};
-
-struct request_msg_ext {
-       int               q_nr;
-       unsigned char     *psmid;
-       union request_msg reqMsg;
-};
-
-struct type82_hdr {
-       unsigned char reserved1;
-       unsigned char type;
-       unsigned char reserved2[2];
-       unsigned char reply_code;
-       unsigned char reserved3[3];
-};
-
-#define TYPE82_RSP_CODE 0x82
-
-#define REPLY_ERROR_MACHINE_FAILURE  0x10
-#define REPLY_ERROR_PREEMPT_FAILURE  0x12
-#define REPLY_ERROR_CHECKPT_FAILURE  0x14
-#define REPLY_ERROR_MESSAGE_TYPE     0x20
-#define REPLY_ERROR_INVALID_COMM_CD  0x21
-#define REPLY_ERROR_INVALID_MSG_LEN  0x23
-#define REPLY_ERROR_RESERVD_FIELD    0x24
-#define REPLY_ERROR_FORMAT_FIELD     0x29
-#define REPLY_ERROR_INVALID_COMMAND  0x30
-#define REPLY_ERROR_MALFORMED_MSG    0x40
-#define REPLY_ERROR_RESERVED_FIELDO  0x50
-#define REPLY_ERROR_WORD_ALIGNMENT   0x60
-#define REPLY_ERROR_MESSAGE_LENGTH   0x80
-#define REPLY_ERROR_OPERAND_INVALID  0x82
-#define REPLY_ERROR_OPERAND_SIZE     0x84
-#define REPLY_ERROR_EVEN_MOD_IN_OPND 0x85
-#define REPLY_ERROR_RESERVED_FIELD   0x88
-#define REPLY_ERROR_TRANSPORT_FAIL   0x90
-#define REPLY_ERROR_PACKET_TRUNCATED 0xA0
-#define REPLY_ERROR_ZERO_BUFFER_LEN  0xB0
-
 struct type86_hdr {
        unsigned char reserved1;
        unsigned char type;
@@ -338,7 +296,7 @@ struct type86_hdr {
 #define TYPE86_FMT2    0x02
 
 struct type86_fmt2_msg {
-       struct type86_hdr hdr;
+       struct type86_hdr header;
        unsigned char     reserved[4];
        unsigned char     apfs[4];
        unsigned int      count1;
@@ -538,6 +496,8 @@ static struct function_and_rules_block static_pke_function_and_rulesX = {
        {'M','R','P',' ',' ',' ',' ',' '}
 };
 
+static unsigned char static_PKE_function_code[2] = {0x50, 0x4B};
+
 struct T6_keyBlock_hdrX {
        unsigned short blen;
        unsigned short ulen;
@@ -688,9 +648,38 @@ static struct cca_public_sec static_cca_pub_sec = {
 #define RESPONSE_CPRB_SIZE  0x000006B8
 #define RESPONSE_CPRBX_SIZE 0x00000724
 
-#define CALLER_HEADER 12
+struct error_hdr {
+       unsigned char reserved1;
+       unsigned char type;
+       unsigned char reserved2[2];
+       unsigned char reply_code;
+       unsigned char reserved3[3];
+};
 
-static unsigned char static_PKE_function_code[2] = {0x50, 0x4B};
+#define TYPE82_RSP_CODE 0x82
+
+#define REP82_ERROR_MACHINE_FAILURE  0x10
+#define REP82_ERROR_PREEMPT_FAILURE  0x12
+#define REP82_ERROR_CHECKPT_FAILURE  0x14
+#define REP82_ERROR_MESSAGE_TYPE     0x20
+#define REP82_ERROR_INVALID_COMM_CD  0x21
+#define REP82_ERROR_INVALID_MSG_LEN  0x23
+#define REP82_ERROR_RESERVD_FIELD    0x24
+#define REP82_ERROR_FORMAT_FIELD     0x29
+#define REP82_ERROR_INVALID_COMMAND  0x30
+#define REP82_ERROR_MALFORMED_MSG    0x40
+#define REP82_ERROR_RESERVED_FIELDO  0x50
+#define REP82_ERROR_WORD_ALIGNMENT   0x60
+#define REP82_ERROR_MESSAGE_LENGTH   0x80
+#define REP82_ERROR_OPERAND_INVALID  0x82
+#define REP82_ERROR_OPERAND_SIZE     0x84
+#define REP82_ERROR_EVEN_MOD_IN_OPND 0x85
+#define REP82_ERROR_RESERVED_FIELD   0x88
+#define REP82_ERROR_TRANSPORT_FAIL   0x90
+#define REP82_ERROR_PACKET_TRUNCATED 0xA0
+#define REP82_ERROR_ZERO_BUFFER_LEN  0xB0
+
+#define CALLER_HEADER 12
 
 static inline int
 testq(int q_nr, int *q_depth, int *dev_type, struct ap_status_word *stat)
@@ -1212,9 +1201,9 @@ send_to_AP(int dev_nr, int cdx, int msg_len, unsigned char *msg_ext)
        struct ap_status_word stat_word;
        enum devstat stat;
        int ccode;
+       u32 *q_nr_p = (u32 *)msg_ext;
 
-       ((struct request_msg_ext *) msg_ext)->q_nr =
-               (dev_nr << SKIP_BITL) + cdx;
+       *q_nr_p = (dev_nr << SKIP_BITL) + cdx;
        PDEBUG("msg_len passed to sen: %d\n", msg_len);
        PDEBUG("q number passed to sen: %02x%02x%02x%02x\n",
               msg_ext[0], msg_ext[1], msg_ext[2], msg_ext[3]);
@@ -2104,7 +2093,7 @@ convert_response(unsigned char *response, unsigned char *buffer,
                 int *respbufflen_p, unsigned char *resp_buff)
 {
        struct ica_rsa_modexpo *icaMsg_p = (struct ica_rsa_modexpo *) buffer;
-       struct type82_hdr *t82h_p = (struct type82_hdr *) response;
+       struct error_hdr *errh_p = (struct error_hdr *) response;
        struct type84_hdr *t84h_p = (struct type84_hdr *) response;
        struct type86_fmt2_msg *t86m_p =  (struct type86_fmt2_msg *) response;
        int reply_code, service_rc, service_rs, src_l;
@@ -2117,12 +2106,13 @@ convert_response(unsigned char *response, unsigned char *buffer,
        service_rc = 0;
        service_rs = 0;
        src_l = 0;
-       switch (t82h_p->type) {
+       switch (errh_p->type) {
        case TYPE82_RSP_CODE:
-               reply_code = t82h_p->reply_code;
-               src_p = (unsigned char *)t82h_p;
-               PRINTK("Hardware error: Type 82 Message Header: "
+               reply_code = errh_p->reply_code;
+               src_p = (unsigned char *)errh_p;
+               PRINTK("Hardware error: Type %02X Message Header: "
                       "%02x%02x%02x%02x%02x%02x%02x%02x\n",
+                      errh_p->type,
                       src_p[0], src_p[1], src_p[2], src_p[3],
                       src_p[4], src_p[5], src_p[6], src_p[7]);
                break;
@@ -2131,7 +2121,7 @@ convert_response(unsigned char *response, unsigned char *buffer,
                src_p = response + (int)t84h_p->len - src_l;
                break;
        case TYPE86_RSP_CODE:
-               reply_code = t86m_p->hdr.reply_code;
+               reply_code = t86m_p->header.reply_code;
                if (reply_code != 0)
                        break;
                cprb_p = (struct CPRB *)
@@ -2143,6 +2133,9 @@ convert_response(unsigned char *response, unsigned char *buffer,
                                le2toI(cprb_p->ccp_rscode, &service_rs);
                                if ((service_rc == 8) && (service_rs == 66))
                                        PDEBUG("Bad block format on PCICC\n");
+                               else if ((service_rc == 8) && (service_rs == 65))
+                                       PDEBUG("Probably an even modulus on "
+                                              "PCICC\n");
                                else if ((service_rc == 8) && (service_rs == 770)) {
                                        PDEBUG("Invalid key length on PCICC\n");
                                        unset_ext_bitlens();
@@ -2155,7 +2148,7 @@ convert_response(unsigned char *response, unsigned char *buffer,
                                        return REC_USE_PCICA;
                                }
                                else
-                                       PRINTK("service rc/rs: %d/%d\n",
+                                       PRINTK("service rc/rs (PCICC): %d/%d\n",
                                               service_rc, service_rs);
                                return REC_OPERAND_INV;
                        }
@@ -2169,7 +2162,10 @@ convert_response(unsigned char *response, unsigned char *buffer,
                        if (service_rc != 0) {
                                service_rs = (int) cprbx_p->ccp_rscode;
                                if ((service_rc == 8) && (service_rs == 66))
-                                       PDEBUG("Bad block format on PCXICC\n");
+                                       PDEBUG("Bad block format on PCIXCC\n");
+                               else if ((service_rc == 8) && (service_rs == 65))
+                                       PDEBUG("Probably an even modulus on "
+                                              "PCIXCC\n");
                                else if ((service_rc == 8) && (service_rs == 770)) {
                                        PDEBUG("Invalid key length on PCIXCC\n");
                                        unset_ext_bitlens();
@@ -2182,7 +2178,7 @@ convert_response(unsigned char *response, unsigned char *buffer,
                                        return REC_USE_PCICA;
                                }
                                else
-                                       PRINTK("service rc/rs: %d/%d\n",
+                                       PRINTK("service rc/rs (PCIXCC): %d/%d\n",
                                               service_rc, service_rs);
                                return REC_OPERAND_INV;
                        }
@@ -2195,20 +2191,25 @@ convert_response(unsigned char *response, unsigned char *buffer,
                }
                break;
        default:
+               src_p = (unsigned char *)errh_p;
+               PRINTK("Unrecognized Message Header: "
+                      "%02x%02x%02x%02x%02x%02x%02x%02x\n",
+                      src_p[0], src_p[1], src_p[2], src_p[3],
+                      src_p[4], src_p[5], src_p[6], src_p[7]);
                return REC_BAD_MESSAGE;
        }
 
        if (reply_code)
                switch (reply_code) {
-               case REPLY_ERROR_OPERAND_INVALID:
+               case REP82_ERROR_OPERAND_INVALID:
                        return REC_OPERAND_INV;
-               case REPLY_ERROR_OPERAND_SIZE:
+               case REP82_ERROR_OPERAND_SIZE:
                        return REC_OPERAND_SIZE;
-               case REPLY_ERROR_EVEN_MOD_IN_OPND:
+               case REP82_ERROR_EVEN_MOD_IN_OPND:
                        return REC_EVEN_MOD;
-               case REPLY_ERROR_MESSAGE_TYPE:
+               case REP82_ERROR_MESSAGE_TYPE:
                        return WRONG_DEVICE_TYPE;
-               case REPLY_ERROR_TRANSPORT_FAIL:
+               case REP82_ERROR_TRANSPORT_FAIL:
                        PRINTKW("Transport failed (APFS = %02X%02X%02X%02X)\n",
                                t86m_p->apfs[0], t86m_p->apfs[1],
                                t86m_p->apfs[2], t86m_p->apfs[3]);
@@ -2229,7 +2230,7 @@ convert_response(unsigned char *response, unsigned char *buffer,
        PDEBUG("Length returned = %d\n", src_l);
        tgt_p = resp_buff + icaMsg_p->outputdatalength - src_l;
        memcpy(tgt_p, src_p, src_l);
-       if ((t82h_p->type == TYPE86_RSP_CODE) && (resp_buff < tgt_p)) {
+       if ((errh_p->type == TYPE86_RSP_CODE) && (resp_buff < tgt_p)) {
                memset(resp_buff, 0, icaMsg_p->outputdatalength - src_l);
                if (pad_msg(resp_buff, icaMsg_p->outputdatalength, src_l))
                        return REC_INVALID_PAD;
index 9ec29bb41b28b522bd7eab5d2e08b72b98221f18..6aeef3bacc3345407c1fa0b061585feb003722b9 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>   // for tasklets
 #include <linux/ioctl32.h>
+#include <linux/miscdevice.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/kobject_uevent.h>
 #include <linux/version.h>
 #include "z90crypt.h"
 #include "z90common.h"
-#ifndef Z90CRYPT_USE_HOTPLUG
-#include <linux/miscdevice.h>
-#endif
-
-#define VERSION_CODE(vers, rel, seq) (((vers)<<16) | ((rel)<<8) | (seq))
-#if LINUX_VERSION_CODE < VERSION_CODE(2,4,0) /* version < 2.4 */
-#  error "This kernel is too old: not supported"
-#endif
-#if LINUX_VERSION_CODE > VERSION_CODE(2,7,0) /* version > 2.6 */
-#  error "This kernel is too recent: not supported by this file"
-#endif
 
-#define VERSION_Z90MAIN_C "$Revision: 1.57 $"
+#define VERSION_Z90MAIN_C "$Revision: 1.62 $"
 
 static char z90main_version[] __initdata =
        "z90main.o (" VERSION_Z90MAIN_C "/"
@@ -63,21 +53,12 @@ extern char z90hardware_version[];
  * Defaults that may be modified.
  */
 
-#ifndef Z90CRYPT_USE_HOTPLUG
 /**
  * You can specify a different minor at compile time.
  */
 #ifndef Z90CRYPT_MINOR
 #define Z90CRYPT_MINOR MISC_DYNAMIC_MINOR
 #endif
-#else
-/**
- * You can specify a different major at compile time.
- */
-#ifndef Z90CRYPT_MAJOR
-#define Z90CRYPT_MAJOR 0
-#endif
-#endif
 
 /**
  * You can specify a different domain at compile time or on the insmod
@@ -97,7 +78,7 @@ extern char z90hardware_version[];
  * older than CLEANUPTIME seconds in the past.
  */
 #ifndef CLEANUPTIME
-#define CLEANUPTIME 20
+#define CLEANUPTIME 15
 #endif
 
 /**
@@ -298,6 +279,10 @@ struct z90crypt {
  * it contains the request; at READ, the response. The function
  * send_to_crypto_device converts the request to device-dependent
  * form and use the caller's OPEN-allocated buffer for the response.
+ *
+ * For the contents of caller_dev_dep_req and caller_dev_dep_req_p
+ * because that points to it, see the discussion in z90hardware.c.
+ * Search for "extended request message block".
  */
 struct caller {
        int              caller_buf_l;           // length of original request
@@ -397,25 +382,10 @@ static int z90crypt_status(char *, char **, off_t, int, int *, void *);
 static int z90crypt_status_write(struct file *, const char __user *,
                                 unsigned long, void *);
 
-/**
- * Hotplug support
- */
-
-#ifdef Z90CRYPT_USE_HOTPLUG
-#define Z90CRYPT_HOTPLUG_ADD    1
-#define Z90CRYPT_HOTPLUG_REMOVE         2
-
-static void z90crypt_hotplug_event(int, int, int);
-#endif
-
 /**
  * Storage allocated at initialization and used throughout the life of
  * this insmod
  */
-#ifdef Z90CRYPT_USE_HOTPLUG
-static int z90crypt_major = Z90CRYPT_MAJOR;
-#endif
-
 static int domain = DOMAIN_INDEX;
 static struct z90crypt z90crypt;
 static int quiesce_z90crypt;
@@ -444,14 +414,12 @@ static struct file_operations z90crypt_fops = {
        .release        = z90crypt_release
 };
 
-#ifndef Z90CRYPT_USE_HOTPLUG
 static struct miscdevice z90crypt_misc_device = {
        .minor      = Z90CRYPT_MINOR,
        .name       = DEV_NAME,
        .fops       = &z90crypt_fops,
        .devfs_name = DEV_NAME
 };
-#endif
 
 /**
  * Documentation values.
@@ -603,7 +571,6 @@ z90crypt_init_module(void)
                return -EINVAL;
        }
 
-#ifndef Z90CRYPT_USE_HOTPLUG
        /* Register as misc device with given minor (or get a dynamic one). */
        result = misc_register(&z90crypt_misc_device);
        if (result < 0) {
@@ -611,18 +578,6 @@ z90crypt_init_module(void)
                        z90crypt_misc_device.minor, result);
                return result;
        }
-#else
-       /* Register the major (or get a dynamic one). */
-       result = register_chrdev(z90crypt_major, REG_NAME, &z90crypt_fops);
-       if (result < 0) {
-               PRINTKW("register_chrdev (major %d) failed with %d.\n",
-                       z90crypt_major, result);
-               return result;
-       }
-
-       if (z90crypt_major == 0)
-               z90crypt_major = result;
-#endif
 
        PDEBUG("Registered " DEV_NAME " with result %d\n", result);
 
@@ -645,11 +600,6 @@ z90crypt_init_module(void)
        } else
                PRINTK("No devices at startup\n");
 
-#ifdef Z90CRYPT_USE_HOTPLUG
-       /* generate hotplug event for device node generation */
-       z90crypt_hotplug_event(z90crypt_major, 0, Z90CRYPT_HOTPLUG_ADD);
-#endif
-
        /* Initialize globals. */
        spin_lock_init(&queuespinlock);
 
@@ -701,17 +651,10 @@ z90crypt_init_module(void)
        return 0; // success
 
 init_module_cleanup:
-#ifndef Z90CRYPT_USE_HOTPLUG
        if ((nresult = misc_deregister(&z90crypt_misc_device)))
                PRINTK("misc_deregister failed with %d.\n", nresult);
        else
                PDEBUG("misc_deregister successful.\n");
-#else
-       if ((nresult = unregister_chrdev(z90crypt_major, REG_NAME)))
-               PRINTK("unregister_chrdev failed with %d.\n", nresult);
-       else
-               PDEBUG("unregister_chrdev successful.\n");
-#endif
 
        return result; // failure
 }
@@ -728,19 +671,10 @@ z90crypt_cleanup_module(void)
 
        remove_proc_entry("driver/z90crypt", 0);
 
-#ifndef Z90CRYPT_USE_HOTPLUG
        if ((nresult = misc_deregister(&z90crypt_misc_device)))
                PRINTK("misc_deregister failed with %d.\n", nresult);
        else
                PDEBUG("misc_deregister successful.\n");
-#else
-       z90crypt_hotplug_event(z90crypt_major, 0, Z90CRYPT_HOTPLUG_REMOVE);
-
-       if ((nresult = unregister_chrdev(z90crypt_major, REG_NAME)))
-               PRINTK("unregister_chrdev failed with %d.\n", nresult);
-       else
-               PDEBUG("unregister_chrdev successful.\n");
-#endif
 
        /* Remove the tasks */
        tasklet_kill(&reader_tasklet);
@@ -748,6 +682,9 @@ z90crypt_cleanup_module(void)
        del_timer(&config_timer);
        del_timer(&cleanup_timer);
 
+       if (z90_device_work)
+               destroy_workqueue(z90_device_work);
+
        destroy_z90crypt();
 
        PRINTKN("Unloaded.\n");
@@ -766,8 +703,6 @@ z90crypt_cleanup_module(void)
  *     z90crypt_status_write
  *      disable_card
  *      enable_card
- *      scan_char
- *      scan_string
  *
  * Helper functions:
  *     z90crypt_rsa
@@ -1057,9 +992,10 @@ remove_device(struct device *device_p)
  * The MCL must be applied and the newer bitlengths enabled for these to work.
  *
  * Card Type    Old limit    New limit
+ * PCICA          ??-2048     same (the lower limit is less than 128 bit...)
  * PCICC         512-1024     512-2048
- * PCIXCC_MCL2   512-2048     no change (applying this MCL == card is MCL3+)
- * PCIXCC_MCL3   512-2048     128-2048
+ * PCIXCC_MCL2   512-2048     ----- (applying any GA LIC will make an MCL3 card)
+ * PCIXCC_MCL3   -----        128-2048
  * CEX2C         512-2048     128-2048
  *
  * ext_bitlens (extended bitlengths) is a global, since you should not apply an
@@ -1104,7 +1040,7 @@ select_device_type(int *dev_type_p, int bytelength)
        if (PCICA_avail || PCIXCC_MCL3_avail || CEX2C_avail) {
                /**
                 * bitlength is a factor, PCICA is the most capable, even with
-                * the new MCL.
+                * the new MCL for PCIXCC.
                 */
                if ((bytelength < PCIXCC_MIN_MOD_SIZE) ||
                    (!ext_bitlens && (bytelength < OLD_PCIXCC_MIN_MOD_SIZE))) {
@@ -2144,73 +2080,15 @@ enable_card(int card_index)
        z90crypt.hdware_info->type_mask[devp->dev_type].user_disabled_count--;
 }
 
-static inline int
-scan_char(unsigned char *bf, unsigned int len,
-         unsigned int *offs, unsigned int *p_eof, unsigned char c)
-{
-       unsigned int i, found;
-
-       found = 0;
-       for (i = 0; i < len; i++) {
-               if (bf[i] == c) {
-                       found = 1;
-                       break;
-               }
-               if (bf[i] == '\0') {
-                       *p_eof = 1;
-                       break;
-               }
-               if (bf[i] == '\n') {
-                       break;
-               }
-       }
-       *offs = i+1;
-       return found;
-}
-
-static inline int
-scan_string(unsigned char *bf, unsigned int len,
-           unsigned int *offs, unsigned int *p_eof, unsigned char *s)
-{
-       unsigned int temp_len, temp_offs, found, eof;
-
-       temp_len = temp_offs = found = eof = 0;
-       while (!eof && !found) {
-               found = scan_char(bf+temp_len, len-temp_len,
-                                 &temp_offs, &eof, *s);
-
-               temp_len += temp_offs;
-               if (eof) {
-                       found = 0;
-                       break;
-               }
-
-               if (found) {
-                       if (len >= temp_offs+strlen(s)) {
-                               found = !strncmp(bf+temp_len-1, s, strlen(s));
-                               if (found) {
-                                       *offs = temp_len+strlen(s)-1;
-                                       break;
-                               }
-                       } else {
-                               found = 0;
-                               *p_eof = 1;
-                               break;
-                       }
-               }
-       }
-       return found;
-}
-
 static int
 z90crypt_status_write(struct file *file, const char __user *buffer,
                      unsigned long count, void *data)
 {
-       int i, j, len, offs, found, eof;
-       unsigned char *lbuf;
+       int j, eol;
+       unsigned char *lbuf, *ptr;
        unsigned int local_count;
 
-#define LBUFSIZE 600
+#define LBUFSIZE 1200
        lbuf = kmalloc(LBUFSIZE, GFP_KERNEL);
        if (!lbuf) {
                PRINTK("kmalloc failed!\n");
@@ -2227,49 +2105,46 @@ z90crypt_status_write(struct file *file, const char __user *buffer,
                return -EFAULT;
        }
 
-       lbuf[local_count-1] = '\0';
+       lbuf[local_count] = '\0';
 
-       len = 0;
-       eof = 0;
-       found = 0;
-       while (!eof) {
-               found = scan_string(lbuf+len, local_count-len, &offs, &eof,
-                                   "Online devices");
-               len += offs;
-               if (found == 1)
-                       break;
+       ptr = strstr(lbuf, "Online devices");
+       if (ptr == 0) {
+               PRINTK("Unable to parse data (missing \"Online devices\")\n");
+               kfree(lbuf);
+               return count;
        }
 
-       if (eof) {
+       ptr = strstr(ptr, "\n");
+       if (ptr == 0) {
+               PRINTK("Unable to parse data (missing newline after \"Online devices\")\n");
                kfree(lbuf);
                return count;
        }
+       ptr++;
 
-       if (found)
-               found = scan_char(lbuf+len, local_count-len, &offs, &eof, '\n');
-
-       if (!found || eof) {
+       if (strstr(ptr, "Waiting work element counts") == NULL) {
+               PRINTK("Unable to parse data (missing \"Waiting work element counts\")\n");
                kfree(lbuf);
                return count;
        }
 
-       len += offs;
        j = 0;
-       for (i = 0; i < 80; i++) {
-               switch (*(lbuf+len+i)) {
+       eol = 0;
+       while ((j < 64) && (*ptr != '\0')) {
+               switch (*ptr) {
                case '\t':
                case ' ':
                        break;
                case '\n':
                default:
-                       eof = 1;
+                       eol = 1;
                        break;
-               case '0':
-               case '1':
-               case '2':
-               case '3':
-               case '4':
-               case '5':
+               case '0':       // no device
+               case '1':       // PCICA
+               case '2':       // PCICC
+               case '3':       // PCIXCC_MCL2
+               case '4':       // PCIXCC_MCL3
+               case '5':       // CEX2C
                        j++;
                        break;
                case 'd':
@@ -2283,8 +2158,9 @@ z90crypt_status_write(struct file *file, const char __user *buffer,
                        j++;
                        break;
                }
-               if (eof)
+               if (eol)
                        break;
+               ptr++;
        }
 
        kfree(lbuf);
@@ -3479,45 +3355,5 @@ probe_PCIXCC_type(struct device *devPtr)
        return rv;
 }
 
-#ifdef Z90CRYPT_USE_HOTPLUG
-static void
-z90crypt_hotplug_event(int dev_major, int dev_minor, int action)
-{
-#ifdef CONFIG_HOTPLUG
-       char *argv[3];
-       char *envp[6];
-       char  major[20];
-       char  minor[20];
-
-       sprintf(major, "MAJOR=%d", dev_major);
-       sprintf(minor, "MINOR=%d", dev_minor);
-
-       argv[0] = hotplug_path;
-       argv[1] = "z90crypt";
-       argv[2] = 0;
-
-       envp[0] = "HOME=/";
-       envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
-
-       switch (action) {
-       case Z90CRYPT_HOTPLUG_ADD:
-               envp[2] = "ACTION=add";
-               break;
-       case Z90CRYPT_HOTPLUG_REMOVE:
-               envp[2] = "ACTION=remove";
-               break;
-       default:
-               BUG();
-               break;
-       }
-       envp[3] = major;
-       envp[4] = minor;
-       envp[5] = 0;
-
-       call_usermodehelper(argv[0], argv, envp, 0);
-#endif
-}
-#endif
-
 module_init(z90crypt_init_module);
 module_exit(z90crypt_cleanup_module);
index 5bb255e02acc653f9f93b0ba1e0bcc4392aa83d1..4191fd9d4d11b564ae6e92e862b5623c7d55d77d 100644 (file)
@@ -240,7 +240,7 @@ s390_revalidate_registers(struct mci *mci)
                         * Floating point control register can't be restored.
                         * Task will be terminated.
                         */
-                       asm volatile ("lfpc 0(%0)" : : "a" (&zero));
+                       asm volatile ("lfpc 0(%0)" : : "a" (&zero), "m" (zero));
                        kill_task = 1;
 
                }
index a41778a490d600e9de43829e927430c9ea849f7b..3a8152906bf64edb7f343282269d6ead81614e18 100644 (file)
@@ -69,11 +69,40 @@ config SUN_JSFLASH
          If you say Y here, you will be able to boot from your JavaStation's
          Flash memory.
 
-# XXX Why don't we do "source drivers/char/Config.in" somewhere?
-# no shit
-config RTC
-       tristate "PC-style Real Time Clock Support"
-       depends on PCI && EXPERIMENTAL && SPARC32
+config BBC_I2C
+       tristate "UltraSPARC-III bootbus i2c controller driver"
+       depends on PCI && SPARC64
+       help
+         The BBC devices on the UltraSPARC III have two I2C controllers.  The
+         first I2C controller connects mainly to configuration PROMs (NVRAM,
+         CPU configuration, DIMM types, etc.).  The second I2C controller
+         connects to environmental control devices such as fans and
+         temperature sensors.  The second controller also connects to the
+         smartcard reader, if present.  Say Y to enable support for these.
+
+config ENVCTRL
+       tristate "SUNW, envctrl support"
+       depends on PCI && SPARC64
+       help
+         Kernel support for temperature and fan monitoring on Sun SME
+         machines.
+
+         To compile this driver as a module, choose M here: the
+         module will be called envctrl.
+
+config DISPLAY7SEG
+       tristate "7-Segment Display support"
+       depends on PCI && SPARC64
+       ---help---
+         This is the driver for the 7-segment display and LED present on
+         Sun Microsystems CompactPCI models CP1400 and CP1500.
+
+         To compile this driver as a module, choose M here: the
+         module will be called display7seg.
+
+         If you do not have a CompactPCI model CP1400 or CP1500, or
+         another UltraSPARC-IIi-cEngine boardset with a 7-segment display,
+         you should say N to this option.
 
 endmenu
 
index 12c208fb18c516de702cb575cf82c8348480b53c..787ad00a2b739fd19232fe3ac6f9916a91759584 100644 (file)
@@ -250,7 +250,7 @@ config SCSI_DECNCR
 
 config SCSI_DECSII
        tristate "DEC SII Scsi Driver"
-       depends on MACH_DECSTATION && SCSI && MIPS32
+       depends on MACH_DECSTATION && SCSI && 32BIT
 
 config BLK_DEV_3W_XXXX_RAID
        tristate "3ware 5/6/7/8xxx ATA-RAID support"
index 179c95c878acd73f2f24cec0e7504ba599c22c57..31065261de8e2c0b7656b86cef7e183b6aa76488 100644 (file)
@@ -189,7 +189,6 @@ static void ahci_irq_clear(struct ata_port *ap);
 static void ahci_eng_timeout(struct ata_port *ap);
 static int ahci_port_start(struct ata_port *ap);
 static void ahci_port_stop(struct ata_port *ap);
-static void ahci_host_stop(struct ata_host_set *host_set);
 static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
 static void ahci_qc_prep(struct ata_queued_cmd *qc);
 static u8 ahci_check_status(struct ata_port *ap);
@@ -242,7 +241,6 @@ static struct ata_port_operations ahci_ops = {
 
        .port_start             = ahci_port_start,
        .port_stop              = ahci_port_stop,
-       .host_stop              = ahci_host_stop,
 };
 
 static struct ata_port_info ahci_port_info[] = {
@@ -296,17 +294,9 @@ static inline unsigned long ahci_port_base_ul (unsigned long base, unsigned int
        return base + 0x100 + (port * 0x80);
 }
 
-static inline void *ahci_port_base (void *base, unsigned int port)
+static inline void __iomem *ahci_port_base (void __iomem *base, unsigned int port)
 {
-       return (void *) ahci_port_base_ul((unsigned long)base, port);
-}
-
-static void ahci_host_stop(struct ata_host_set *host_set)
-{
-       struct ahci_host_priv *hpriv = host_set->private_data;
-       kfree(hpriv);
-
-       ata_host_stop(host_set);
+       return (void __iomem *) ahci_port_base_ul((unsigned long)base, port);
 }
 
 static int ahci_port_start(struct ata_port *ap)
@@ -314,8 +304,9 @@ static int ahci_port_start(struct ata_port *ap)
        struct device *dev = ap->host_set->dev;
        struct ahci_host_priv *hpriv = ap->host_set->private_data;
        struct ahci_port_priv *pp;
-       void *mem, *mmio = ap->host_set->mmio_base;
-       void *port_mmio = ahci_port_base(mmio, ap->port_no);
+       void __iomem *mmio = ap->host_set->mmio_base;
+       void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
+       void *mem;
        dma_addr_t mem_dma;
 
        pp = kmalloc(sizeof(*pp), GFP_KERNEL);
@@ -383,8 +374,8 @@ static void ahci_port_stop(struct ata_port *ap)
 {
        struct device *dev = ap->host_set->dev;
        struct ahci_port_priv *pp = ap->private_data;
-       void *mmio = ap->host_set->mmio_base;
-       void *port_mmio = ahci_port_base(mmio, ap->port_no);
+       void __iomem *mmio = ap->host_set->mmio_base;
+       void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
        u32 tmp;
 
        tmp = readl(port_mmio + PORT_CMD);
@@ -546,8 +537,8 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc)
 
 static void ahci_intr_error(struct ata_port *ap, u32 irq_stat)
 {
-       void *mmio = ap->host_set->mmio_base;
-       void *port_mmio = ahci_port_base(mmio, ap->port_no);
+       void __iomem *mmio = ap->host_set->mmio_base;
+       void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
        u32 tmp;
        int work;
 
@@ -595,8 +586,8 @@ static void ahci_intr_error(struct ata_port *ap, u32 irq_stat)
 static void ahci_eng_timeout(struct ata_port *ap)
 {
        struct ata_host_set *host_set = ap->host_set;
-       void *mmio = host_set->mmio_base;
-       void *port_mmio = ahci_port_base(mmio, ap->port_no);
+       void __iomem *mmio = host_set->mmio_base;
+       void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
        struct ata_queued_cmd *qc;
        unsigned long flags;
 
@@ -626,8 +617,8 @@ static void ahci_eng_timeout(struct ata_port *ap)
 
 static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc)
 {
-       void *mmio = ap->host_set->mmio_base;
-       void *port_mmio = ahci_port_base(mmio, ap->port_no);
+       void __iomem *mmio = ap->host_set->mmio_base;
+       void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
        u32 status, serr, ci;
 
        serr = readl(port_mmio + PORT_SCR_ERR);
@@ -663,7 +654,7 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *
        struct ata_host_set *host_set = dev_instance;
        struct ahci_host_priv *hpriv;
        unsigned int i, handled = 0;
-       void *mmio;
+       void __iomem *mmio;
        u32 irq_stat, irq_ack = 0;
 
        VPRINTK("ENTER\n");
@@ -709,7 +700,7 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *
 static int ahci_qc_issue(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
-       void *port_mmio = (void *) ap->ioaddr.cmd_addr;
+       void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
 
        writel(1, port_mmio + PORT_CMD_ISSUE);
        readl(port_mmio + PORT_CMD_ISSUE);      /* flush */
@@ -894,7 +885,7 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent)
 {
        struct ahci_host_priv *hpriv = probe_ent->private_data;
        struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
-       void *mmio = probe_ent->mmio_base;
+       void __iomem *mmio = probe_ent->mmio_base;
        u32 vers, cap, impl, speed;
        const char *speed_s;
        u16 cc;
@@ -967,7 +958,7 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        struct ata_probe_ent *probe_ent = NULL;
        struct ahci_host_priv *hpriv;
        unsigned long base;
-       void *mmio_base;
+       void __iomem *mmio_base;
        unsigned int board_idx = (unsigned int) ent->driver_data;
        int have_msi, pci_dev_busy = 0;
        int rc;
@@ -1004,8 +995,7 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        probe_ent->dev = pci_dev_to_dev(pdev);
        INIT_LIST_HEAD(&probe_ent->node);
 
-       mmio_base = ioremap(pci_resource_start(pdev, AHCI_PCI_BAR),
-                           pci_resource_len(pdev, AHCI_PCI_BAR));
+       mmio_base = pci_iomap(pdev, AHCI_PCI_BAR, 0);
        if (mmio_base == NULL) {
                rc = -ENOMEM;
                goto err_out_free_ent;
@@ -1049,7 +1039,7 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 err_out_hpriv:
        kfree(hpriv);
 err_out_iounmap:
-       iounmap(mmio_base);
+       pci_iounmap(pdev, mmio_base);
 err_out_free_ent:
        kfree(probe_ent);
 err_out_msi:
@@ -1089,7 +1079,8 @@ static void ahci_remove_one (struct pci_dev *pdev)
                scsi_host_put(ap->host);
        }
 
-       host_set->ops->host_stop(host_set);
+       kfree(hpriv);
+       pci_iounmap(pdev, host_set->mmio_base);
        kfree(host_set);
 
        if (have_msi)
@@ -1106,7 +1097,6 @@ static int __init ahci_init(void)
        return pci_module_init(&ahci_pci_driver);
 }
 
-
 static void __exit ahci_exit(void)
 {
        pci_unregister_driver(&ahci_pci_driver);
index fb28c1261848c5f0ee66fbbfa09b22dec095456a..deec0cef88d92bcb007c9b28c514948b3c700758 100644 (file)
@@ -583,8 +583,7 @@ static void pci_enable_intx(struct pci_dev *pdev)
 #define AHCI_ENABLE (1 << 31)
 static int piix_disable_ahci(struct pci_dev *pdev)
 {
-       void *mmio;
-       unsigned long addr;
+       void __iomem *mmio;
        u32 tmp;
        int rc = 0;
 
@@ -592,11 +591,11 @@ static int piix_disable_ahci(struct pci_dev *pdev)
         * works because this device is usually set up by BIOS.
         */
 
-       addr = pci_resource_start(pdev, AHCI_PCI_BAR);
-       if (!addr || !pci_resource_len(pdev, AHCI_PCI_BAR))
+       if (!pci_resource_start(pdev, AHCI_PCI_BAR) ||
+           !pci_resource_len(pdev, AHCI_PCI_BAR))
                return 0;
 
-       mmio = ioremap(addr, 64);
+       mmio = pci_iomap(pdev, AHCI_PCI_BAR, 64);
        if (!mmio)
                return -ENOMEM;
 
@@ -610,7 +609,7 @@ static int piix_disable_ahci(struct pci_dev *pdev)
                        rc = -EIO;
        }
 
-       iounmap(mmio);
+       pci_iounmap(pdev, mmio);
        return rc;
 }
 
index dee4b12b034261f4bbdf28e9b956dcb8d0d23ead..9fb9814525a35781a8d9086d701e6bd28012b48b 100644 (file)
@@ -75,6 +75,10 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc);
 static unsigned int ata_unique_id = 1;
 static struct workqueue_struct *ata_wq;
 
+int atapi_enabled = 0;
+module_param(atapi_enabled, int, 0444);
+MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)");
+
 MODULE_AUTHOR("Jeff Garzik");
 MODULE_DESCRIPTION("Library module for ATA devices");
 MODULE_LICENSE("GPL");
@@ -4200,6 +4204,15 @@ ata_probe_ent_alloc(struct device *dev, struct ata_port_info *port)
 
 
 
+#ifdef CONFIG_PCI
+
+void ata_pci_host_stop (struct ata_host_set *host_set)
+{
+       struct pci_dev *pdev = to_pci_dev(host_set->dev);
+
+       pci_iounmap(pdev, host_set->mmio_base);
+}
+
 /**
  *     ata_pci_init_native_mode - Initialize native-mode driver
  *     @pdev:  pci device to be initialized
@@ -4212,7 +4225,6 @@ ata_probe_ent_alloc(struct device *dev, struct ata_port_info *port)
  *     ata_probe_ent structure should then be freed with kfree().
  */
 
-#ifdef CONFIG_PCI
 struct ata_probe_ent *
 ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port)
 {
@@ -4595,6 +4607,7 @@ EXPORT_SYMBOL_GPL(ata_scsi_simulate);
 
 #ifdef CONFIG_PCI
 EXPORT_SYMBOL_GPL(pci_test_config_bits);
+EXPORT_SYMBOL_GPL(ata_pci_host_stop);
 EXPORT_SYMBOL_GPL(ata_pci_init_native_mode);
 EXPORT_SYMBOL_GPL(ata_pci_init_one);
 EXPORT_SYMBOL_GPL(ata_pci_remove_one);
index 346eb36b1e31e0c5665269077e65ef4f11149644..104fd9a63e734ddc752f68de92215a208242a0d1 100644 (file)
@@ -1470,10 +1470,10 @@ ata_scsi_find_dev(struct ata_port *ap, struct scsi_device *scsidev)
        if (unlikely(!ata_dev_present(dev)))
                return NULL;
 
-#ifndef ATA_ENABLE_ATAPI
-       if (unlikely(dev->class == ATA_DEV_ATAPI))
-               return NULL;
-#endif
+       if (!atapi_enabled) {
+               if (unlikely(dev->class == ATA_DEV_ATAPI))
+                       return NULL;
+       }
 
        return dev;
 }
index 809c634afbcda8792bd1ec9f07c0e4593251ad93..d608b3a0f6fe6897d108cd8f6557c8e4d53c1820 100644 (file)
@@ -38,6 +38,7 @@ struct ata_scsi_args {
 };
 
 /* libata-core.c */
+extern int atapi_enabled;
 extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
                                      struct ata_device *dev);
 extern void ata_qc_free(struct ata_queued_cmd *qc);
index ff1933298da682c5f1b0704cbee9c4b81f6d083a..a4857db4f9b8033f2ff16785dc94244e997489a6 100644 (file)
@@ -1766,7 +1766,7 @@ static int mesh_suspend(struct macio_dev *mdev, pm_message_t state)
        struct mesh_state *ms = (struct mesh_state *)macio_get_drvdata(mdev);
        unsigned long flags;
 
-       if (state == mdev->ofdev.dev.power.power_state || state < 2)
+       if (state.event == mdev->ofdev.dev.power.power_state.event || state.event < 2)
                return 0;
 
        scsi_block_requests(ms->host);
@@ -1791,7 +1791,7 @@ static int mesh_resume(struct macio_dev *mdev)
        struct mesh_state *ms = (struct mesh_state *)macio_get_drvdata(mdev);
        unsigned long flags;
 
-       if (mdev->ofdev.dev.power.power_state == 0)
+       if (mdev->ofdev.dev.power.power_state.event == PM_EVENT_ON)
                return 0;
 
        set_mesh_power(ms, 1);
@@ -1802,7 +1802,7 @@ static int mesh_resume(struct macio_dev *mdev)
        enable_irq(ms->meshintr);
        scsi_unblock_requests(ms->host);
 
-       mdev->ofdev.dev.power.power_state = 0;
+       mdev->ofdev.dev.power.power_state.event = PM_EVENT_ON;
 
        return 0;
 }
index 03d9bc6e69dfafddda8dc2f39b10953ad00fc6af..a1d62dee3be640d43b2315146a73b6401705cb3b 100644 (file)
@@ -351,6 +351,7 @@ static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
 static void nv_host_stop (struct ata_host_set *host_set)
 {
        struct nv_host *host = host_set->private_data;
+       struct pci_dev *pdev = to_pci_dev(host_set->dev);
 
        // Disable hotplug event interrupts.
        if (host->host_desc->disable_hotplug)
@@ -358,7 +359,8 @@ static void nv_host_stop (struct ata_host_set *host_set)
 
        kfree(host);
 
-       ata_host_stop(host_set);
+       if (host_set->mmio_base)
+               pci_iounmap(pdev, host_set->mmio_base);
 }
 
 static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
@@ -420,8 +422,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) {
                unsigned long base;
 
-               probe_ent->mmio_base = ioremap(pci_resource_start(pdev, 5),
-                               pci_resource_len(pdev, 5));
+               probe_ent->mmio_base = pci_iomap(pdev, 5, 0);
                if (probe_ent->mmio_base == NULL) {
                        rc = -EIO;
                        goto err_out_free_host;
@@ -457,7 +458,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 
 err_out_iounmap:
        if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO)
-               iounmap(probe_ent->mmio_base);
+               pci_iounmap(pdev, probe_ent->mmio_base);
 err_out_free_host:
        kfree(host);
 err_out_free_ent:
index 7c4f6ecc1cc9bb218f4e91a50a414f7bc36d2690..538ad727bd2eb897c32cad017dcad8e11701d6bf 100644 (file)
@@ -92,6 +92,7 @@ static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf);
 static void pdc_irq_clear(struct ata_port *ap);
 static int pdc_qc_issue_prot(struct ata_queued_cmd *qc);
 
+
 static Scsi_Host_Template pdc_ata_sht = {
        .module                 = THIS_MODULE,
        .name                   = DRV_NAME,
@@ -132,7 +133,7 @@ static struct ata_port_operations pdc_sata_ops = {
        .scr_write              = pdc_sata_scr_write,
        .port_start             = pdc_port_start,
        .port_stop              = pdc_port_stop,
-       .host_stop              = ata_host_stop,
+       .host_stop              = ata_pci_host_stop,
 };
 
 static struct ata_port_operations pdc_pata_ops = {
@@ -153,7 +154,7 @@ static struct ata_port_operations pdc_pata_ops = {
 
        .port_start             = pdc_port_start,
        .port_stop              = pdc_port_stop,
-       .host_stop              = ata_host_stop,
+       .host_stop              = ata_pci_host_stop,
 };
 
 static struct ata_port_info pdc_port_info[] = {
@@ -282,7 +283,7 @@ static void pdc_port_stop(struct ata_port *ap)
 
 static void pdc_reset_port(struct ata_port *ap)
 {
-       void *mmio = (void *) ap->ioaddr.cmd_addr + PDC_CTLSTAT;
+       void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_CTLSTAT;
        unsigned int i;
        u32 tmp;
 
@@ -418,7 +419,7 @@ static inline unsigned int pdc_host_intr( struct ata_port *ap,
        u8 status;
        unsigned int handled = 0, have_err = 0;
        u32 tmp;
-       void *mmio = (void *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL;
+       void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL;
 
        tmp = readl(mmio);
        if (tmp & PDC_ERR_MASK) {
@@ -447,7 +448,7 @@ static inline unsigned int pdc_host_intr( struct ata_port *ap,
 static void pdc_irq_clear(struct ata_port *ap)
 {
        struct ata_host_set *host_set = ap->host_set;
-       void *mmio = host_set->mmio_base;
+       void __iomem *mmio = host_set->mmio_base;
 
        readl(mmio + PDC_INT_SEQMASK);
 }
@@ -459,7 +460,7 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *r
        u32 mask = 0;
        unsigned int i, tmp;
        unsigned int handled = 0;
-       void *mmio_base;
+       void __iomem *mmio_base;
 
        VPRINTK("ENTER\n");
 
@@ -581,7 +582,7 @@ static void pdc_ata_setup_port(struct ata_ioports *port, unsigned long base)
 
 static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe)
 {
-       void *mmio = pe->mmio_base;
+       void __iomem *mmio = pe->mmio_base;
        u32 tmp;
 
        /*
@@ -624,7 +625,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
        static int printed_version;
        struct ata_probe_ent *probe_ent = NULL;
        unsigned long base;
-       void *mmio_base;
+       void __iomem *mmio_base;
        unsigned int board_idx = (unsigned int) ent->driver_data;
        int pci_dev_busy = 0;
        int rc;
@@ -663,8 +664,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
        probe_ent->dev = pci_dev_to_dev(pdev);
        INIT_LIST_HEAD(&probe_ent->node);
 
-       mmio_base = ioremap(pci_resource_start(pdev, 3),
-                           pci_resource_len(pdev, 3));
+       mmio_base = pci_iomap(pdev, 3, 0);
        if (mmio_base == NULL) {
                rc = -ENOMEM;
                goto err_out_free_ent;
index 9c99ab433bd3650750bc4df43996bd3b4384d81a..029c2482e12770bca69a5ef53b6572d8825526aa 100644 (file)
@@ -538,11 +538,12 @@ static void qs_port_stop(struct ata_port *ap)
 static void qs_host_stop(struct ata_host_set *host_set)
 {
        void __iomem *mmio_base = host_set->mmio_base;
+       struct pci_dev *pdev = to_pci_dev(host_set->dev);
 
        writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */
        writeb(QS_CNFG3_GSRST, mmio_base + QS_HCF_CNFG3); /* global reset */
 
-       ata_host_stop(host_set);
+       pci_iounmap(pdev, mmio_base);
 }
 
 static void qs_host_init(unsigned int chip_id, struct ata_probe_ent *pe)
@@ -646,8 +647,7 @@ static int qs_ata_init_one(struct pci_dev *pdev,
                goto err_out_regions;
        }
 
-       mmio_base = ioremap(pci_resource_start(pdev, 4),
-                           pci_resource_len(pdev, 4));
+       mmio_base = pci_iomap(pdev, 4, 0);
        if (mmio_base == NULL) {
                rc = -ENOMEM;
                goto err_out_regions;
@@ -697,7 +697,7 @@ static int qs_ata_init_one(struct pci_dev *pdev,
        return 0;
 
 err_out_iounmap:
-       iounmap(mmio_base);
+       pci_iounmap(pdev, mmio_base);
 err_out_regions:
        pci_release_regions(pdev);
 err_out:
index 71d49548f0a36223cfb1aaa060cd77be52e9a9f5..ba98a175ee3a8f9e227917689b9678285df586c3 100644 (file)
@@ -86,6 +86,7 @@ static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg);
 static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
 static void sil_post_set_mode (struct ata_port *ap);
 
+
 static struct pci_device_id sil_pci_tbl[] = {
        { 0x1095, 0x3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w },
        { 0x1095, 0x0240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w },
@@ -172,7 +173,7 @@ static struct ata_port_operations sil_ops = {
        .scr_write              = sil_scr_write,
        .port_start             = ata_port_start,
        .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
+       .host_stop              = ata_pci_host_stop,
 };
 
 static struct ata_port_info sil_port_info[] = {
@@ -231,6 +232,7 @@ MODULE_LICENSE("GPL");
 MODULE_DEVICE_TABLE(pci, sil_pci_tbl);
 MODULE_VERSION(DRV_VERSION);
 
+
 static unsigned char sil_get_device_cache_line(struct pci_dev *pdev)
 {
        u8 cache_line = 0;
@@ -242,7 +244,8 @@ static void sil_post_set_mode (struct ata_port *ap)
 {
        struct ata_host_set *host_set = ap->host_set;
        struct ata_device *dev;
-       void *addr = host_set->mmio_base + sil_port[ap->port_no].xfer_mode;
+       void __iomem *addr =
+               host_set->mmio_base + sil_port[ap->port_no].xfer_mode;
        u32 tmp, dev_mode[2];
        unsigned int i;
 
@@ -375,7 +378,7 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        static int printed_version;
        struct ata_probe_ent *probe_ent = NULL;
        unsigned long base;
-       void *mmio_base;
+       void __iomem *mmio_base;
        int rc;
        unsigned int i;
        int pci_dev_busy = 0;
@@ -425,8 +428,7 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
                probe_ent->irq_flags = SA_SHIRQ;
        probe_ent->host_flags = sil_port_info[ent->driver_data].host_flags;
 
-       mmio_base = ioremap(pci_resource_start(pdev, 5),
-                           pci_resource_len(pdev, 5));
+       mmio_base = pci_iomap(pdev, 5, 0);
        if (mmio_base == NULL) {
                rc = -ENOMEM;
                goto err_out_free_ent;
index 19d3bb3b0fb659f27f484b75952be3adfa0fed1f..d89d968bedace68ad91771a168455b0164b12bb0 100644 (file)
@@ -318,7 +318,7 @@ static struct ata_port_operations k2_sata_ops = {
        .scr_write              = k2_sata_scr_write,
        .port_start             = ata_port_start,
        .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
+       .host_stop              = ata_pci_host_stop,
 };
 
 static void k2_sata_setup_port(struct ata_ioports *port, unsigned long base)
@@ -346,7 +346,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
        static int printed_version;
        struct ata_probe_ent *probe_ent = NULL;
        unsigned long base;
-       void *mmio_base;
+       void __iomem *mmio_base;
        int pci_dev_busy = 0;
        int rc;
        int i;
@@ -392,8 +392,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
        probe_ent->dev = pci_dev_to_dev(pdev);
        INIT_LIST_HEAD(&probe_ent->node);
 
-       mmio_base = ioremap(pci_resource_start(pdev, 5),
-                           pci_resource_len(pdev, 5));
+       mmio_base = pci_iomap(pdev, 5, 0);
        if (mmio_base == NULL) {
                rc = -ENOMEM;
                goto err_out_free_ent;
index c72fcc46f0fa82bf6c3a4c5aaf45fb282d5db3b6..540a851911723b5329e67f6f63981acba6975339 100644 (file)
@@ -245,13 +245,14 @@ static struct pci_driver pdc_sata_pci_driver = {
 
 static void pdc20621_host_stop(struct ata_host_set *host_set)
 {
+       struct pci_dev *pdev = to_pci_dev(host_set->dev);
        struct pdc_host_priv *hpriv = host_set->private_data;
        void *dimm_mmio = hpriv->dimm_mmio;
 
-       iounmap(dimm_mmio);
+       pci_iounmap(pdev, dimm_mmio);
        kfree(hpriv);
 
-       ata_host_stop(host_set);
+       pci_iounmap(pdev, host_set->mmio_base);
 }
 
 static int pdc_port_start(struct ata_port *ap)
@@ -451,9 +452,9 @@ static void pdc20621_dma_prep(struct ata_queued_cmd *qc)
        struct scatterlist *sg = qc->sg;
        struct ata_port *ap = qc->ap;
        struct pdc_port_priv *pp = ap->private_data;
-       void *mmio = ap->host_set->mmio_base;
+       void __iomem *mmio = ap->host_set->mmio_base;
        struct pdc_host_priv *hpriv = ap->host_set->private_data;
-       void *dimm_mmio = hpriv->dimm_mmio;
+       void __iomem *dimm_mmio = hpriv->dimm_mmio;
        unsigned int portno = ap->port_no;
        unsigned int i, last, idx, total_len = 0, sgt_len;
        u32 *buf = (u32 *) &pp->dimm_buf[PDC_DIMM_HEADER_SZ];
@@ -513,9 +514,9 @@ static void pdc20621_nodata_prep(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
        struct pdc_port_priv *pp = ap->private_data;
-       void *mmio = ap->host_set->mmio_base;
+       void __iomem *mmio = ap->host_set->mmio_base;
        struct pdc_host_priv *hpriv = ap->host_set->private_data;
-       void *dimm_mmio = hpriv->dimm_mmio;
+       void __iomem *dimm_mmio = hpriv->dimm_mmio;
        unsigned int portno = ap->port_no;
        unsigned int i;
 
@@ -565,7 +566,7 @@ static void __pdc20621_push_hdma(struct ata_queued_cmd *qc,
 {
        struct ata_port *ap = qc->ap;
        struct ata_host_set *host_set = ap->host_set;
-       void *mmio = host_set->mmio_base;
+       void __iomem *mmio = host_set->mmio_base;
 
        /* hard-code chip #0 */
        mmio += PDC_CHIP0_OFS;
@@ -639,7 +640,7 @@ static void pdc20621_packet_start(struct ata_queued_cmd *qc)
        struct ata_port *ap = qc->ap;
        struct ata_host_set *host_set = ap->host_set;
        unsigned int port_no = ap->port_no;
-       void *mmio = host_set->mmio_base;
+       void __iomem *mmio = host_set->mmio_base;
        unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
        u8 seq = (u8) (port_no + 1);
        unsigned int port_ofs;
@@ -699,7 +700,7 @@ static int pdc20621_qc_issue_prot(struct ata_queued_cmd *qc)
 static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
                                           struct ata_queued_cmd *qc,
                                          unsigned int doing_hdma,
-                                         void *mmio)
+                                         void __iomem *mmio)
 {
        unsigned int port_no = ap->port_no;
        unsigned int port_ofs =
@@ -778,7 +779,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
 static void pdc20621_irq_clear(struct ata_port *ap)
 {
        struct ata_host_set *host_set = ap->host_set;
-       void *mmio = host_set->mmio_base;
+       void __iomem *mmio = host_set->mmio_base;
 
        mmio += PDC_CHIP0_OFS;
 
@@ -792,7 +793,7 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_re
        u32 mask = 0;
        unsigned int i, tmp, port_no;
        unsigned int handled = 0;
-       void *mmio_base;
+       void __iomem *mmio_base;
 
        VPRINTK("ENTER\n");
 
@@ -940,9 +941,9 @@ static void pdc20621_get_from_dimm(struct ata_probe_ent *pe, void *psource,
        u16 idx;
        u8 page_mask;
        long dist;
-       void *mmio = pe->mmio_base;
+       void __iomem *mmio = pe->mmio_base;
        struct pdc_host_priv *hpriv = pe->private_data;
-       void *dimm_mmio = hpriv->dimm_mmio;
+       void __iomem *dimm_mmio = hpriv->dimm_mmio;
 
        /* hard-code chip #0 */
        mmio += PDC_CHIP0_OFS;
@@ -996,9 +997,9 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource,
        u16 idx;
        u8 page_mask;
        long dist;
-       void *mmio = pe->mmio_base;
+       void __iomem *mmio = pe->mmio_base;
        struct pdc_host_priv *hpriv = pe->private_data;
-       void *dimm_mmio = hpriv->dimm_mmio;
+       void __iomem *dimm_mmio = hpriv->dimm_mmio;
 
        /* hard-code chip #0 */
        mmio += PDC_CHIP0_OFS;
@@ -1044,7 +1045,7 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource,
 static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, u32 device,
                                      u32 subaddr, u32 *pdata)
 {
-       void *mmio = pe->mmio_base;
+       void __iomem *mmio = pe->mmio_base;
        u32 i2creg  = 0;
        u32 status;
        u32 count =0;
@@ -1103,7 +1104,7 @@ static int pdc20621_prog_dimm0(struct ata_probe_ent *pe)
        u32 data = 0;
        int size, i;
        u8 bdimmsize;
-       void *mmio = pe->mmio_base;
+       void __iomem *mmio = pe->mmio_base;
        static const struct {
                unsigned int reg;
                unsigned int ofs;
@@ -1166,7 +1167,7 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_probe_ent *pe)
 {
        u32 data, spd0;
        int error, i;
-       void *mmio = pe->mmio_base;
+       void __iomem *mmio = pe->mmio_base;
 
        /* hard-code chip #0 */
        mmio += PDC_CHIP0_OFS;
@@ -1220,7 +1221,7 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe)
        u32 ticks=0;
        u32 clock=0;
        u32 fparam=0;
-       void *mmio = pe->mmio_base;
+       void __iomem *mmio = pe->mmio_base;
 
        /* hard-code chip #0 */
        mmio += PDC_CHIP0_OFS;
@@ -1344,7 +1345,7 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe)
 static void pdc_20621_init(struct ata_probe_ent *pe)
 {
        u32 tmp;
-       void *mmio = pe->mmio_base;
+       void __iomem *mmio = pe->mmio_base;
 
        /* hard-code chip #0 */
        mmio += PDC_CHIP0_OFS;
@@ -1377,7 +1378,8 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
        static int printed_version;
        struct ata_probe_ent *probe_ent = NULL;
        unsigned long base;
-       void *mmio_base, *dimm_mmio = NULL;
+       void __iomem *mmio_base;
+       void __iomem *dimm_mmio = NULL;
        struct pdc_host_priv *hpriv = NULL;
        unsigned int board_idx = (unsigned int) ent->driver_data;
        int pci_dev_busy = 0;
@@ -1417,8 +1419,7 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
        probe_ent->dev = pci_dev_to_dev(pdev);
        INIT_LIST_HEAD(&probe_ent->node);
 
-       mmio_base = ioremap(pci_resource_start(pdev, 3),
-                           pci_resource_len(pdev, 3));
+       mmio_base = pci_iomap(pdev, 3, 0);
        if (mmio_base == NULL) {
                rc = -ENOMEM;
                goto err_out_free_ent;
@@ -1432,8 +1433,7 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
        }
        memset(hpriv, 0, sizeof(*hpriv));
 
-       dimm_mmio = ioremap(pci_resource_start(pdev, 4),
-                           pci_resource_len(pdev, 4));
+       dimm_mmio = pci_iomap(pdev, 4, 0);
        if (!dimm_mmio) {
                kfree(hpriv);
                rc = -ENOMEM;
@@ -1480,9 +1480,9 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
 
 err_out_iounmap_dimm:          /* only get to this label if 20621 */
        kfree(hpriv);
-       iounmap(dimm_mmio);
+       pci_iounmap(pdev, dimm_mmio);
 err_out_iounmap:
-       iounmap(mmio_base);
+       pci_iounmap(pdev, mmio_base);
 err_out_free_ent:
        kfree(probe_ent);
 err_out_regions:
index 3985f344da4d84061dddeff72800f91502bce41c..cf94e0158a8df5820a28214c92bcf35842fdb33f 100644 (file)
@@ -252,7 +252,7 @@ static struct ata_port_operations vsc_sata_ops = {
        .scr_write              = vsc_sata_scr_write,
        .port_start             = ata_port_start,
        .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
+       .host_stop              = ata_pci_host_stop,
 };
 
 static void __devinit vsc_sata_setup_port(struct ata_ioports *port, unsigned long base)
@@ -326,8 +326,7 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d
        probe_ent->dev = pci_dev_to_dev(pdev);
        INIT_LIST_HEAD(&probe_ent->node);
 
-       mmio_base = ioremap(pci_resource_start(pdev, 0),
-                           pci_resource_len(pdev, 0));
+       mmio_base = pci_iomap(pdev, 0, 0);
        if (mmio_base == NULL) {
                rc = -ENOMEM;
                goto err_out_free_ent;
index 0b10169961ebfe2898efecb192a00c5a47c4b1df..aec39fb261cae9c6b14ada4e5608d67c8b4b672f 100644 (file)
@@ -58,8 +58,7 @@ static const char serial21285_name[] = "Footbridge UART";
  *  int((BAUD_BASE - (baud >> 1)) / baud)
  */
 
-static void
-serial21285_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void serial21285_stop_tx(struct uart_port *port)
 {
        if (tx_enabled(port)) {
                disable_irq(IRQ_CONTX);
@@ -67,8 +66,7 @@ serial21285_stop_tx(struct uart_port *port, unsigned int tty_stop)
        }
 }
 
-static void
-serial21285_start_tx(struct uart_port *port, unsigned int tty_start)
+static void serial21285_start_tx(struct uart_port *port)
 {
        if (!tx_enabled(port)) {
                enable_irq(IRQ_CONTX);
@@ -148,7 +146,7 @@ static irqreturn_t serial21285_tx_chars(int irq, void *dev_id, struct pt_regs *r
                goto out;
        }
        if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
-               serial21285_stop_tx(port, 0);
+               serial21285_stop_tx(port);
                goto out;
        }
 
@@ -164,7 +162,7 @@ static irqreturn_t serial21285_tx_chars(int irq, void *dev_id, struct pt_regs *r
                uart_write_wakeup(port);
 
        if (uart_circ_empty(xmit))
-               serial21285_stop_tx(port, 0);
+               serial21285_stop_tx(port);
 
  out:
        return IRQ_HANDLED;
index 7e8fc7c1d4cc79768b3eb53da4f338ba09d80dc4..30a0a3d1014527b991025958b7a2d36ab98cdac7 100644 (file)
@@ -1001,7 +1001,7 @@ static inline void __stop_tx(struct uart_8250_port *p)
        }
 }
 
-static void serial8250_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void serial8250_stop_tx(struct uart_port *port)
 {
        struct uart_8250_port *up = (struct uart_8250_port *)port;
 
@@ -1018,7 +1018,7 @@ static void serial8250_stop_tx(struct uart_port *port, unsigned int tty_stop)
 
 static void transmit_chars(struct uart_8250_port *up);
 
-static void serial8250_start_tx(struct uart_port *port, unsigned int tty_start)
+static void serial8250_start_tx(struct uart_port *port)
 {
        struct uart_8250_port *up = (struct uart_8250_port *)port;
 
@@ -1158,7 +1158,11 @@ static _INLINE_ void transmit_chars(struct uart_8250_port *up)
                up->port.x_char = 0;
                return;
        }
-       if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) {
+       if (uart_tx_stopped(&up->port)) {
+               serial8250_stop_tx(&up->port);
+               return;
+       }
+       if (uart_circ_empty(xmit)) {
                __stop_tx(up);
                return;
        }
@@ -2586,82 +2590,3 @@ module_param_array(probe_rsa, ulong, &probe_rsa_count, 0444);
 MODULE_PARM_DESC(probe_rsa, "Probe I/O ports for RSA");
 #endif
 MODULE_ALIAS_CHARDEV_MAJOR(TTY_MAJOR);
-
-/**
- *     register_serial - configure a 16x50 serial port at runtime
- *     @req: request structure
- *
- *     Configure the serial port specified by the request. If the
- *     port exists and is in use an error is returned. If the port
- *     is not currently in the table it is added.
- *
- *     The port is then probed and if necessary the IRQ is autodetected
- *     If this fails an error is returned.
- *
- *     On success the port is ready to use and the line number is returned.
- *
- *     Note: this function is deprecated - use serial8250_register_port
- *     instead.
- */
-int register_serial(struct serial_struct *req)
-{
-       struct uart_port port;
-
-       port.iobase   = req->port;
-       port.membase  = req->iomem_base;
-       port.irq      = req->irq;
-       port.uartclk  = req->baud_base * 16;
-       port.fifosize = req->xmit_fifo_size;
-       port.regshift = req->iomem_reg_shift;
-       port.iotype   = req->io_type;
-       port.flags    = req->flags | UPF_BOOT_AUTOCONF;
-       port.mapbase  = req->iomap_base;
-       port.dev      = NULL;
-
-       if (share_irqs)
-               port.flags |= UPF_SHARE_IRQ;
-
-       if (HIGH_BITS_OFFSET)
-               port.iobase |= (long) req->port_high << HIGH_BITS_OFFSET;
-
-       /*
-        * If a clock rate wasn't specified by the low level driver, then
-        * default to the standard clock rate.  This should be 115200 (*16)
-        * and should not depend on the architecture's BASE_BAUD definition.
-        * However, since this API will be deprecated, it's probably a
-        * better idea to convert the drivers to use the new API
-        * (serial8250_register_port and serial8250_unregister_port).
-        */
-       if (port.uartclk == 0) {
-               printk(KERN_WARNING
-                      "Serial: registering port at [%08x,%08lx,%p] irq %d with zero baud_base\n",
-                      port.iobase, port.mapbase, port.membase, port.irq);
-               printk(KERN_WARNING "Serial: see %s:%d for more information\n",
-                      __FILE__, __LINE__);
-               dump_stack();
-
-               /*
-                * Fix it up for now, but this is only a temporary measure.
-                */
-               port.uartclk = BASE_BAUD * 16;
-       }
-
-       return serial8250_register_port(&port);
-}
-EXPORT_SYMBOL(register_serial);
-
-/**
- *     unregister_serial - remove a 16x50 serial port at runtime
- *     @line: serial line number
- *
- *     Remove one serial port.  This may not be called from interrupt
- *     context.  We hand the port back to our local PM control.
- *
- *     Note: this function is deprecated - use serial8250_unregister_port
- *     instead.
- */
-void unregister_serial(int line)
-{
-       serial8250_unregister_port(line);
-}
-EXPORT_SYMBOL(unregister_serial);
index 9225c82faeb8e13b7b88b8a7b5e81a409c72aca3..b1b459efda524fa27f2743b848497d48c3bf953a 100644 (file)
  */
 
 #include <linux/config.h>
-
-int serial8250_register_port(struct uart_port *);
-void serial8250_unregister_port(int line);
-void serial8250_suspend_port(int line);
-void serial8250_resume_port(int line);
+#include <linux/serial_8250.h>
 
 struct old_serial_port {
        unsigned int uart;
index d5797618a3b918cc41e89187780d8d641fe49207..e39818a34a0754a824df7bb2e3e46878704e18cd 100644 (file)
@@ -308,7 +308,7 @@ config SERIAL_S3C2410_CONSOLE
 
 config SERIAL_DZ
        bool "DECstation DZ serial driver"
-       depends on MACH_DECSTATION && MIPS32
+       depends on MACH_DECSTATION && 32BIT
        select SERIAL_CORE
        help
          DZ11-family serial controllers for VAXstations, including the
@@ -830,7 +830,7 @@ config SERIAL_M32R_PLDSIO
 
 config SERIAL_TXX9
        bool "TMPTX39XX/49XX SIO support"
-       depends HAS_TXX9_SERIAL
+       depends HAS_TXX9_SERIAL && BROKEN
        select SERIAL_CORE
        default y
 
index 2884b310e54d2d01f50d012d4394343b08b5717a..978e12437e617df488ccd32352e41a457516961b 100644 (file)
@@ -105,7 +105,7 @@ struct uart_amba_port {
        unsigned int            old_status;
 };
 
-static void pl010_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void pl010_stop_tx(struct uart_port *port)
 {
        unsigned int cr;
 
@@ -114,7 +114,7 @@ static void pl010_stop_tx(struct uart_port *port, unsigned int tty_stop)
        UART_PUT_CR(port, cr);
 }
 
-static void pl010_start_tx(struct uart_port *port, unsigned int tty_start)
+static void pl010_start_tx(struct uart_port *port)
 {
        unsigned int cr;
 
@@ -219,7 +219,7 @@ static void pl010_tx_chars(struct uart_port *port)
                return;
        }
        if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
-               pl010_stop_tx(port, 0);
+               pl010_stop_tx(port);
                return;
        }
 
@@ -236,7 +236,7 @@ static void pl010_tx_chars(struct uart_port *port)
                uart_write_wakeup(port);
 
        if (uart_circ_empty(xmit))
-               pl010_stop_tx(port, 0);
+               pl010_stop_tx(port);
 }
 
 static void pl010_modem_status(struct uart_port *port)
index 7db88ee18f75fb1f138f71921c05d833aa935a51..56071309744c526322bc404f52159e8eae95738d 100644 (file)
@@ -74,7 +74,7 @@ struct uart_amba_port {
        unsigned int            old_status;
 };
 
-static void pl011_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void pl011_stop_tx(struct uart_port *port)
 {
        struct uart_amba_port *uap = (struct uart_amba_port *)port;
 
@@ -82,7 +82,7 @@ static void pl011_stop_tx(struct uart_port *port, unsigned int tty_stop)
        writew(uap->im, uap->port.membase + UART011_IMSC);
 }
 
-static void pl011_start_tx(struct uart_port *port, unsigned int tty_start)
+static void pl011_start_tx(struct uart_port *port)
 {
        struct uart_amba_port *uap = (struct uart_amba_port *)port;
 
@@ -184,7 +184,7 @@ static void pl011_tx_chars(struct uart_amba_port *uap)
                return;
        }
        if (uart_circ_empty(xmit) || uart_tx_stopped(&uap->port)) {
-               pl011_stop_tx(&uap->port, 0);
+               pl011_stop_tx(&uap->port);
                return;
        }
 
@@ -201,7 +201,7 @@ static void pl011_tx_chars(struct uart_amba_port *uap)
                uart_write_wakeup(&uap->port);
 
        if (uart_circ_empty(xmit))
-               pl011_stop_tx(&uap->port, 0);
+               pl011_stop_tx(&uap->port);
 }
 
 static void pl011_modem_status(struct uart_amba_port *uap)
index 6104aeef12439e156928a16f77267d2215b19d6f..a274ebf256a190fb6de6e94883a8807bbf31f752 100644 (file)
@@ -200,7 +200,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
        DEBUG_AUTOCONF("type=%s\n", uart_config[up->port.type].name);
 }
 
-static void serial8250_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void serial8250_stop_tx(struct uart_port *port)
 {
        struct uart_8250_port *up = (struct uart_8250_port *)port;
 
@@ -210,7 +210,7 @@ static void serial8250_stop_tx(struct uart_port *port, unsigned int tty_stop)
        }
 }
 
-static void serial8250_start_tx(struct uart_port *port, unsigned int tty_start)
+static void serial8250_start_tx(struct uart_port *port)
 {
        struct uart_8250_port *up = (struct uart_8250_port *)port;
 
@@ -337,7 +337,7 @@ static _INLINE_ void transmit_chars(struct uart_8250_port *up)
                return;
        }
        if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) {
-               serial8250_stop_tx(&up->port, 0);
+               serial8250_stop_tx(&up->port);
                return;
        }
 
@@ -356,7 +356,7 @@ static _INLINE_ void transmit_chars(struct uart_8250_port *up)
        DEBUG_INTR("THRE...");
 
        if (uart_circ_empty(xmit))
-               serial8250_stop_tx(&up->port, 0);
+               serial8250_stop_tx(&up->port);
 }
 
 static _INLINE_ void check_modem_status(struct uart_8250_port *up)
index e92522b33c48e9e4e283b8fbd498d4e8b7e45c12..d822896b488c80c45f68738f237a000e5af76b50 100644 (file)
@@ -69,8 +69,7 @@
 
 #define tx_enabled(port)       ((port)->unused[0])
 
-static void
-clps711xuart_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void clps711xuart_stop_tx(struct uart_port *port)
 {
        if (tx_enabled(port)) {
                disable_irq(TX_IRQ(port));
@@ -78,8 +77,7 @@ clps711xuart_stop_tx(struct uart_port *port, unsigned int tty_stop)
        }
 }
 
-static void
-clps711xuart_start_tx(struct uart_port *port, unsigned int tty_start)
+static void clps711xuart_start_tx(struct uart_port *port)
 {
        if (!tx_enabled(port)) {
                enable_irq(TX_IRQ(port));
@@ -165,7 +163,7 @@ static irqreturn_t clps711xuart_int_tx(int irq, void *dev_id, struct pt_regs *re
                return IRQ_HANDLED;
        }
        if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
-               clps711xuart_stop_tx(port, 0);
+               clps711xuart_stop_tx(port);
                return IRQ_HANDLED;
        }
 
@@ -182,7 +180,7 @@ static irqreturn_t clps711xuart_int_tx(int irq, void *dev_id, struct pt_regs *re
                uart_write_wakeup(port);
 
        if (uart_circ_empty(xmit))
-               clps711xuart_stop_tx(port, 0);
+               clps711xuart_stop_tx(port);
 
        return IRQ_HANDLED;
 }
index d639ac92a117c73eec982310534d7b2b4d908df8..25825f2aba2279abc005ab49c11cfd59c9ab5390 100644 (file)
@@ -124,7 +124,7 @@ static unsigned int cpm_uart_get_mctrl(struct uart_port *port)
 /*
  * Stop transmitter
  */
-static void cpm_uart_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void cpm_uart_stop_tx(struct uart_port *port)
 {
        struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
        volatile smc_t *smcp = pinfo->smcp;
@@ -141,7 +141,7 @@ static void cpm_uart_stop_tx(struct uart_port *port, unsigned int tty_stop)
 /*
  * Start transmitter
  */
-static void cpm_uart_start_tx(struct uart_port *port, unsigned int tty_start)
+static void cpm_uart_start_tx(struct uart_port *port)
 {
        struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
        volatile smc_t *smcp = pinfo->smcp;
@@ -403,10 +403,8 @@ static int cpm_uart_startup(struct uart_port *port)
 
 inline void cpm_uart_wait_until_send(struct uart_cpm_port *pinfo)
 {
-       unsigned long target_jiffies = jiffies + pinfo->wait_closing;
-
-       while (!time_after(jiffies, target_jiffies))
-               schedule();
+       set_current_state(TASK_UNINTERRUPTIBLE);
+       schedule_timeout(pinfo->wait_closing);
 }
 
 /*
@@ -425,9 +423,12 @@ static void cpm_uart_shutdown(struct uart_port *port)
        /* If the port is not the console, disable Rx and Tx. */
        if (!(pinfo->flags & FLAG_CONSOLE)) {
                /* Wait for all the BDs marked sent */
-               while(!cpm_uart_tx_empty(port))
+               while(!cpm_uart_tx_empty(port)) {
+                       set_current_state(TASK_UNINTERRUPTIBLE);
                        schedule_timeout(2);
-               if(pinfo->wait_closing)
+               }
+
+               if (pinfo->wait_closing)
                        cpm_uart_wait_until_send(pinfo);
 
                /* Stop uarts */
@@ -623,7 +624,7 @@ static int cpm_uart_tx_pump(struct uart_port *port)
        }
 
        if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
-               cpm_uart_stop_tx(port, 0);
+               cpm_uart_stop_tx(port);
                return 0;
        }
 
@@ -656,7 +657,7 @@ static int cpm_uart_tx_pump(struct uart_port *port)
                uart_write_wakeup(port);
 
        if (uart_circ_empty(xmit)) {
-               cpm_uart_stop_tx(port, 0);
+               cpm_uart_stop_tx(port);
                return 0;
        }
 
index c4c8f4b44f53820a8a4ae3d3431f7c3da984b1ee..15ad58d94889f431bfc4899dea71a65b1d2f7e86 100644 (file)
@@ -142,12 +142,21 @@ void scc2_lineif(struct uart_cpm_port *pinfo)
         * be supported in a sane fashion.
         */
 #ifndef CONFIG_STX_GP3
+#ifdef CONFIG_MPC8560_ADS
+       volatile iop_cpm2_t *io = &cpm2_immr->im_ioport;
+       io->iop_ppard |= 0x00000018;
+       io->iop_psord &= ~0x00000008;   /* Rx */
+       io->iop_psord &= ~0x00000010;   /* Tx */
+       io->iop_pdird &= ~0x00000008;   /* Rx */
+       io->iop_pdird |= 0x00000010;    /* Tx */
+#else
        volatile iop_cpm2_t *io = &cpm2_immr->im_ioport;
        io->iop_pparb |= 0x008b0000;
        io->iop_pdirb |= 0x00880000;
        io->iop_psorb |= 0x00880000;
        io->iop_pdirb &= ~0x00030000;
        io->iop_psorb &= ~0x00030000;
+#endif
 #endif
        cpm2_immr->im_cpmux.cmx_scr &= 0xff00ffff;
        cpm2_immr->im_cpmux.cmx_scr |= 0x00090000;
@@ -257,6 +266,7 @@ int cpm_uart_init_portdesc(void)
        cpm_uart_ports[UART_SMC1].smcp = (smc_t *) & cpm2_immr->im_smc[0];
        cpm_uart_ports[UART_SMC1].smcup =
            (smc_uart_t *) & cpm2_immr->im_dprambase[PROFF_SMC1];
+       *(u16 *)(&cpm2_immr->im_dprambase[PROFF_SMC1_BASE]) = PROFF_SMC1;
        cpm_uart_ports[UART_SMC1].port.mapbase =
            (unsigned long)&cpm2_immr->im_smc[0];
        cpm_uart_ports[UART_SMC1].smcp->smc_smcm |= (SMCM_RX | SMCM_TX);
@@ -269,6 +279,7 @@ int cpm_uart_init_portdesc(void)
        cpm_uart_ports[UART_SMC2].smcp = (smc_t *) & cpm2_immr->im_smc[1];
        cpm_uart_ports[UART_SMC2].smcup =
            (smc_uart_t *) & cpm2_immr->im_dprambase[PROFF_SMC2];
+       *(u16 *)(&cpm2_immr->im_dprambase[PROFF_SMC2_BASE]) = PROFF_SMC2;
        cpm_uart_ports[UART_SMC2].port.mapbase =
            (unsigned long)&cpm2_immr->im_smc[1];
        cpm_uart_ports[UART_SMC2].smcp->smc_smcm |= (SMCM_RX | SMCM_TX);
index 23b8871e74cc1cdee8869d3a6043d7eff92a23f5..5690594b257bb4f7aabc64b9cc82ea41e1a6de1b 100644 (file)
@@ -5041,17 +5041,3 @@ rs_init(void)
 /* this makes sure that rs_init is called during kernel boot */
 
 module_init(rs_init);
-
-/*
- * register_serial and unregister_serial allows for serial ports to be
- * configured at run-time, to support PCMCIA modems.
- */
-int
-register_serial(struct serial_struct *req)
-{
-       return -1;
-}
-
-void unregister_serial(int line)
-{
-}
index 97824eeeafae51bdeb93cda017b21e223b7c8c9e..e63b9dffc8d7304ecd6fcfaa2b363ffd07838131 100644 (file)
@@ -112,7 +112,7 @@ static inline void dz_out(struct dz_port *dport, unsigned offset,
  * ------------------------------------------------------------
  */
 
-static void dz_stop_tx(struct uart_port *uport, unsigned int tty_stop)
+static void dz_stop_tx(struct uart_port *uport)
 {
        struct dz_port *dport = (struct dz_port *)uport;
        unsigned short tmp, mask = 1 << dport->port.line;
@@ -125,7 +125,7 @@ static void dz_stop_tx(struct uart_port *uport, unsigned int tty_stop)
        spin_unlock_irqrestore(&dport->port.lock, flags);
 }
 
-static void dz_start_tx(struct uart_port *uport, unsigned int tty_start)
+static void dz_start_tx(struct uart_port *uport)
 {
        struct dz_port *dport = (struct dz_port *)uport;
        unsigned short tmp, mask = 1 << dport->port.line;
@@ -290,7 +290,7 @@ static inline void dz_transmit_chars(struct dz_port *dport)
        }
        /* if nothing to do or stopped or hardware stopped */
        if (uart_circ_empty(xmit) || uart_tx_stopped(&dport->port)) {
-               dz_stop_tx(&dport->port, 0);
+               dz_stop_tx(&dport->port);
                return;
        }
 
@@ -308,7 +308,7 @@ static inline void dz_transmit_chars(struct dz_port *dport)
 
        /* Are we done */
        if (uart_circ_empty(xmit))
-               dz_stop_tx(&dport->port, 0);
+               dz_stop_tx(&dport->port);
 }
 
 /*
@@ -440,7 +440,7 @@ static int dz_startup(struct uart_port *uport)
  */
 static void dz_shutdown(struct uart_port *uport)
 {
-       dz_stop_tx(uport, 0);
+       dz_stop_tx(uport);
 }
 
 /*
index c112b32764e8ceb3045ebcbe7933d25eb7d3aa22..79f8df4d66b799e06625ea9218371eacd268224b 100644 (file)
@@ -989,18 +989,16 @@ static unsigned int icom_get_mctrl(struct uart_port *port)
        return result;
 }
 
-static void icom_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void icom_stop_tx(struct uart_port *port)
 {
        unsigned char cmdReg;
 
-       if (tty_stop) {
-               trace(ICOM_PORT, "STOP", 0);
-               cmdReg = readb(&ICOM_PORT->dram->CmdReg);
-               writeb(cmdReg | CMD_HOLD_XMIT, &ICOM_PORT->dram->CmdReg);
-       }
+       trace(ICOM_PORT, "STOP", 0);
+       cmdReg = readb(&ICOM_PORT->dram->CmdReg);
+       writeb(cmdReg | CMD_HOLD_XMIT, &ICOM_PORT->dram->CmdReg);
 }
 
-static void icom_start_tx(struct uart_port *port, unsigned int tty_start)
+static void icom_start_tx(struct uart_port *port)
 {
        unsigned char cmdReg;
 
index 01a8726a3f97289b9a85e21eeab51c1703aaac8d..4c985e6b3784b0b611413c74deba61a98c086997 100644 (file)
@@ -124,7 +124,7 @@ static void imx_timeout(unsigned long data)
 /*
  * interrupts disabled on entry
  */
-static void imx_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void imx_stop_tx(struct uart_port *port)
 {
        struct imx_port *sport = (struct imx_port *)port;
        UCR1((u32)sport->port.membase) &= ~UCR1_TXMPTYEN;
@@ -165,13 +165,13 @@ static inline void imx_transmit_buffer(struct imx_port *sport)
        } while (!(UTS((u32)sport->port.membase) & UTS_TXFULL));
 
        if (uart_circ_empty(xmit))
-               imx_stop_tx(&sport->port, 0);
+               imx_stop_tx(&sport->port);
 }
 
 /*
  * interrupts disabled on entry
  */
-static void imx_start_tx(struct uart_port *port, unsigned int tty_start)
+static void imx_start_tx(struct uart_port *port)
 {
        struct imx_port *sport = (struct imx_port *)port;
 
@@ -196,7 +196,7 @@ static irqreturn_t imx_txint(int irq, void *dev_id, struct pt_regs *regs)
        }
 
        if (uart_circ_empty(xmit) || uart_tx_stopped(&sport->port)) {
-               imx_stop_tx(&sport->port, 0);
+               imx_stop_tx(&sport->port);
                goto out;
        }
 
@@ -291,13 +291,31 @@ static unsigned int imx_tx_empty(struct uart_port *port)
        return USR2((u32)sport->port.membase) & USR2_TXDC ?  TIOCSER_TEMT : 0;
 }
 
+/*
+ * We have a modem side uart, so the meanings of RTS and CTS are inverted.
+ */
 static unsigned int imx_get_mctrl(struct uart_port *port)
 {
-       return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
+        struct imx_port *sport = (struct imx_port *)port;
+        unsigned int tmp = TIOCM_DSR | TIOCM_CAR;
+
+        if (USR1((u32)sport->port.membase) & USR1_RTSS)
+                tmp |= TIOCM_CTS;
+
+        if (UCR2((u32)sport->port.membase) & UCR2_CTS)
+                tmp |= TIOCM_RTS;
+
+        return tmp;
 }
 
 static void imx_set_mctrl(struct uart_port *port, unsigned int mctrl)
 {
+        struct imx_port *sport = (struct imx_port *)port;
+
+        if (mctrl & TIOCM_RTS)
+                UCR2((u32)sport->port.membase) |= UCR2_CTS;
+        else
+                UCR2((u32)sport->port.membase) &= ~UCR2_CTS;
 }
 
 /*
index 793c3a7cbe477c868f65d1ddf224cd64b629e889..0c5c96a582b340cec9ea60f12c71262e2ddea2cc 100644 (file)
@@ -2373,10 +2373,9 @@ static unsigned int ic4_tx_empty(struct uart_port *the_port)
 /**
  * ic4_stop_tx - stop the transmitter
  * @port: Port to operate on
- * @tty_stop: Set to 1 if called via uart_stop
  *
  */
-static void ic4_stop_tx(struct uart_port *the_port, unsigned int tty_stop)
+static void ic4_stop_tx(struct uart_port *the_port)
 {
 }
 
@@ -2471,10 +2470,9 @@ static unsigned int ic4_get_mctrl(struct uart_port *the_port)
 /**
  * ic4_start_tx - Start transmitter, flush any output
  * @port: Port to operate on
- * @tty_stop: Set to 1 if called via uart_start
  *
  */
-static void ic4_start_tx(struct uart_port *the_port, unsigned int tty_stop)
+static void ic4_start_tx(struct uart_port *the_port)
 {
        struct ioc4_port *port = get_ioc4_port(the_port);
        unsigned long flags;
index ea5bf4d4daa3016db79933b268ae5240fa63e952..ef132349f310d8325122458bea12b52b039d696e 100644 (file)
@@ -592,7 +592,7 @@ static void ip22zilog_set_mctrl(struct uart_port *port, unsigned int mctrl)
 }
 
 /* The port lock is held and interrupts are disabled.  */
-static void ip22zilog_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void ip22zilog_stop_tx(struct uart_port *port)
 {
        struct uart_ip22zilog_port *up = (struct uart_ip22zilog_port *) port;
 
@@ -600,7 +600,7 @@ static void ip22zilog_stop_tx(struct uart_port *port, unsigned int tty_stop)
 }
 
 /* The port lock is held and interrupts are disabled.  */
-static void ip22zilog_start_tx(struct uart_port *port, unsigned int tty_start)
+static void ip22zilog_start_tx(struct uart_port *port)
 {
        struct uart_ip22zilog_port *up = (struct uart_ip22zilog_port *) port;
        struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(port);
index 98de2258fd06e731a88fc0e9a7e2277ca1ffaa18..6fa0d62d6f686269eadf52abacf56e516f7be3f8 100644 (file)
@@ -113,7 +113,7 @@ static void jsm_tty_set_mctrl(struct uart_port *port, unsigned int mctrl)
        udelay(10);
 }
 
-static void jsm_tty_start_tx(struct uart_port *port, unsigned int tty_start)
+static void jsm_tty_start_tx(struct uart_port *port)
 {
        struct jsm_channel *channel = (struct jsm_channel *)port;
 
@@ -125,7 +125,7 @@ static void jsm_tty_start_tx(struct uart_port *port, unsigned int tty_start)
        jsm_printk(IOCTL, INFO, &channel->ch_bd->pci_dev, "finish\n");
 }
 
-static void jsm_tty_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void jsm_tty_stop_tx(struct uart_port *port)
 {
        struct jsm_channel *channel = (struct jsm_channel *)port;
 
index 9b50560b9d1625d36658f3015424e7099b438ea5..b0ecc7537ce5de9bbd3328a8cd44dc53453690e7 100644 (file)
@@ -275,7 +275,7 @@ serial_out(struct uart_sio_port *up, int offset, int value)
        __sio_out(value, offset);
 }
 
-static void m32r_sio_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void m32r_sio_stop_tx(struct uart_port *port)
 {
        struct uart_sio_port *up = (struct uart_sio_port *)port;
 
@@ -285,7 +285,7 @@ static void m32r_sio_stop_tx(struct uart_port *port, unsigned int tty_stop)
        }
 }
 
-static void m32r_sio_start_tx(struct uart_port *port, unsigned int tty_start)
+static void m32r_sio_start_tx(struct uart_port *port)
 {
 #ifdef CONFIG_SERIAL_M32R_PLDSIO
        struct uart_sio_port *up = (struct uart_sio_port *)port;
@@ -425,7 +425,7 @@ static _INLINE_ void transmit_chars(struct uart_sio_port *up)
                return;
        }
        if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) {
-               m32r_sio_stop_tx(&up->port, 0);
+               m32r_sio_stop_tx(&up->port);
                return;
        }
 
@@ -446,7 +446,7 @@ static _INLINE_ void transmit_chars(struct uart_sio_port *up)
        DEBUG_INTR("THRE...");
 
        if (uart_circ_empty(xmit))
-               m32r_sio_stop_tx(&up->port, 0);
+               m32r_sio_stop_tx(&up->port);
 }
 
 /*
index 2a5cf174ca30d949a6888273d70081913b6ffab0..a3cd0ee8486d42fb9a6d757841b9b140059182a5 100644 (file)
@@ -119,7 +119,7 @@ mpc52xx_uart_get_mctrl(struct uart_port *port)
 }
 
 static void 
-mpc52xx_uart_stop_tx(struct uart_port *port, unsigned int tty_stop)
+mpc52xx_uart_stop_tx(struct uart_port *port)
 {
        /* port->lock taken by caller */
        port->read_status_mask &= ~MPC52xx_PSC_IMR_TXRDY;
@@ -127,7 +127,7 @@ mpc52xx_uart_stop_tx(struct uart_port *port, unsigned int tty_stop)
 }
 
 static void 
-mpc52xx_uart_start_tx(struct uart_port *port, unsigned int tty_start)
+mpc52xx_uart_start_tx(struct uart_port *port)
 {
        /* port->lock taken by caller */
        port->read_status_mask |= MPC52xx_PSC_IMR_TXRDY;
@@ -485,7 +485,7 @@ mpc52xx_uart_int_tx_chars(struct uart_port *port)
 
        /* Nothing to do ? */
        if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
-               mpc52xx_uart_stop_tx(port,0);
+               mpc52xx_uart_stop_tx(port);
                return 0;
        }
 
@@ -504,7 +504,7 @@ mpc52xx_uart_int_tx_chars(struct uart_port *port)
 
        /* Maybe we're done after all */
        if (uart_circ_empty(xmit)) {
-               mpc52xx_uart_stop_tx(port,0);
+               mpc52xx_uart_stop_tx(port);
                return 0;
        }
 
index e43276c6a954d611021745375b5e2344bc85d266..efe79b1fd431b8f13c98cdf5150f4aef49759f0b 100644 (file)
@@ -1072,18 +1072,18 @@ mpsc_get_mctrl(struct uart_port *port)
 }
 
 static void
-mpsc_stop_tx(struct uart_port *port, uint tty_start)
+mpsc_stop_tx(struct uart_port *port)
 {
        struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
 
-       pr_debug("mpsc_stop_tx[%d]: tty_start: %d\n", port->line, tty_start);
+       pr_debug("mpsc_stop_tx[%d]\n", port->line);
 
        mpsc_freeze(pi);
        return;
 }
 
 static void
-mpsc_start_tx(struct uart_port *port, uint tty_start)
+mpsc_start_tx(struct uart_port *port)
 {
        struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
 
@@ -1091,7 +1091,7 @@ mpsc_start_tx(struct uart_port *port, uint tty_start)
        mpsc_copy_tx_data(pi);
        mpsc_sdma_start_tx(pi);
 
-       pr_debug("mpsc_start_tx[%d]: tty_start: %d\n", port->line, tty_start);
+       pr_debug("mpsc_start_tx[%d]\n", port->line);
        return;
 }
 
index dadd7e19714e1c91cc20a704fd87049c65f8898c..189064607709d9ae717cdb70646062b768ba2c0d 100644 (file)
@@ -111,22 +111,20 @@ static unsigned int mux_get_mctrl(struct uart_port *port)
 /**
  * mux_stop_tx - Stop transmitting characters.
  * @port: Ptr to the uart_port.
- * @tty_stop: tty layer issue this command?
  *
  * The Serial MUX does not support this function.
  */
-static void mux_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void mux_stop_tx(struct uart_port *port)
 {
 }
 
 /**
  * mux_start_tx - Start transmitting characters.
  * @port: Ptr to the uart_port.
- * @tty_start: tty layer issue this command?
  *
  * The Serial Mux does not support this function.
  */
-static void mux_start_tx(struct uart_port *port, unsigned int tty_start)
+static void mux_start_tx(struct uart_port *port)
 {
 }
 
@@ -181,7 +179,7 @@ static void mux_write(struct uart_port *port)
        }
 
        if(uart_circ_empty(xmit) || uart_tx_stopped(port)) {
-               mux_stop_tx(port, 0);
+               mux_stop_tx(port);
                return;
        }
 
@@ -202,7 +200,7 @@ static void mux_write(struct uart_port *port)
                uart_write_wakeup(port);
 
        if (uart_circ_empty(xmit))
-               mux_stop_tx(port, 0);
+               mux_stop_tx(port);
 }
 
 /**
index 7db2f37532cf368e7d1ce1d1a11d7af34f31b445..5ddd8ab1f108afb3af7b3acd0e38bc142c026c5f 100644 (file)
@@ -630,11 +630,10 @@ static unsigned int pmz_get_mctrl(struct uart_port *port)
 
 /* 
  * Stop TX side. Dealt like sunzilog at next Tx interrupt,
- * though for DMA, we will have to do a bit more. What is
- * the meaning of the tty_stop bit ? XXX
+ * though for DMA, we will have to do a bit more.
  * The port lock is held and interrupts are disabled.
  */
-static void pmz_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void pmz_stop_tx(struct uart_port *port)
 {
        to_pmz(port)->flags |= PMACZILOG_FLAG_TX_STOPPED;
 }
@@ -643,7 +642,7 @@ static void pmz_stop_tx(struct uart_port *port, unsigned int tty_stop)
  * Kick the Tx side.
  * The port lock is held and interrupts are disabled.
  */
-static void pmz_start_tx(struct uart_port *port, unsigned int tty_start)
+static void pmz_start_tx(struct uart_port *port)
 {
        struct uart_pmac_port *uap = to_pmz(port);
        unsigned char status;
@@ -1601,7 +1600,7 @@ static int pmz_suspend(struct macio_dev *mdev, pm_message_t pm_state)
                return 0;
        }
 
-       if (pm_state == mdev->ofdev.dev.power.power_state || pm_state < 2)
+       if (pm_state.event == mdev->ofdev.dev.power.power_state.event)
                return 0;
 
        pmz_debug("suspend, switching to state %d\n", pm_state);
@@ -1661,7 +1660,7 @@ static int pmz_resume(struct macio_dev *mdev)
        if (uap == NULL)
                return 0;
 
-       if (mdev->ofdev.dev.power.power_state == 0)
+       if (mdev->ofdev.dev.power.power_state.event == PM_EVENT_ON)
                return 0;
        
        pmz_debug("resume, switching to state 0\n");
@@ -1714,7 +1713,7 @@ static int pmz_resume(struct macio_dev *mdev)
 
        pmz_debug("resume, switching complete\n");
 
-       mdev->ofdev.dev.power.power_state = 0;
+       mdev->ofdev.dev.power.power_state.event = PM_EVENT_ON;
 
        return 0;
 }
index 461c81c93207809381c0f2bc9afe5ecfa23d8d9e..eaa0af8352907da7f6ea4f18a8d9df7f7c096edb 100644 (file)
@@ -80,7 +80,7 @@ static void serial_pxa_enable_ms(struct uart_port *port)
        serial_out(up, UART_IER, up->ier);
 }
 
-static void serial_pxa_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void serial_pxa_stop_tx(struct uart_port *port)
 {
        struct uart_pxa_port *up = (struct uart_pxa_port *)port;
 
@@ -185,7 +185,7 @@ static void transmit_chars(struct uart_pxa_port *up)
                return;
        }
        if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) {
-               serial_pxa_stop_tx(&up->port, 0);
+               serial_pxa_stop_tx(&up->port);
                return;
        }
 
@@ -203,10 +203,10 @@ static void transmit_chars(struct uart_pxa_port *up)
 
 
        if (uart_circ_empty(xmit))
-               serial_pxa_stop_tx(&up->port, 0);
+               serial_pxa_stop_tx(&up->port);
 }
 
-static void serial_pxa_start_tx(struct uart_port *port, unsigned int tty_start)
+static void serial_pxa_start_tx(struct uart_port *port)
 {
        struct uart_pxa_port *up = (struct uart_pxa_port *)port;
 
index 7365d4b50b954d2729ce1051acb461cc4ac35cc9..c361c6fb08092135171a7165876bb52c27313f19 100644 (file)
@@ -246,8 +246,7 @@ static void s3c24xx_serial_rx_disable(struct uart_port *port)
        spin_unlock_irqrestore(&port->lock, flags);
 }
 
-static void
-s3c24xx_serial_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void s3c24xx_serial_stop_tx(struct uart_port *port)
 {
        if (tx_enabled(port)) {
                disable_irq(TX_IRQ(port));
@@ -257,8 +256,7 @@ s3c24xx_serial_stop_tx(struct uart_port *port, unsigned int tty_stop)
        }
 }
 
-static void
-s3c24xx_serial_start_tx(struct uart_port *port, unsigned int tty_start)
+static void s3c24xx_serial_start_tx(struct uart_port *port)
 {
        if (!tx_enabled(port)) {
                if (port->flags & UPF_CONS_FLOW)
@@ -424,7 +422,7 @@ static irqreturn_t s3c24xx_serial_tx_chars(int irq, void *id, struct pt_regs *re
        */
 
        if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
-               s3c24xx_serial_stop_tx(port, 0);
+               s3c24xx_serial_stop_tx(port);
                goto out;
        }
 
@@ -443,7 +441,7 @@ static irqreturn_t s3c24xx_serial_tx_chars(int irq, void *id, struct pt_regs *re
                uart_write_wakeup(port);
 
        if (uart_circ_empty(xmit))
-               s3c24xx_serial_stop_tx(port, 0);
+               s3c24xx_serial_stop_tx(port);
 
  out:
        return IRQ_HANDLED;
index 98641c3f5ab9dedb9de0dd1be2eb1806469fb692..1225b14f6e9d4bb7469bb1f6019bf877936f1b54 100644 (file)
@@ -145,7 +145,7 @@ static void sa1100_timeout(unsigned long data)
 /*
  * interrupts disabled on entry
  */
-static void sa1100_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void sa1100_stop_tx(struct uart_port *port)
 {
        struct sa1100_port *sport = (struct sa1100_port *)port;
        u32 utcr3;
@@ -158,7 +158,7 @@ static void sa1100_stop_tx(struct uart_port *port, unsigned int tty_stop)
 /*
  * interrupts may not be disabled on entry
  */
-static void sa1100_start_tx(struct uart_port *port, unsigned int tty_start)
+static void sa1100_start_tx(struct uart_port *port)
 {
        struct sa1100_port *sport = (struct sa1100_port *)port;
        unsigned long flags;
@@ -264,7 +264,7 @@ static void sa1100_tx_chars(struct sa1100_port *sport)
        sa1100_mctrl_check(sport);
 
        if (uart_circ_empty(xmit) || uart_tx_stopped(&sport->port)) {
-               sa1100_stop_tx(&sport->port, 0);
+               sa1100_stop_tx(&sport->port);
                return;
        }
 
@@ -284,7 +284,7 @@ static void sa1100_tx_chars(struct sa1100_port *sport)
                uart_write_wakeup(&sport->port);
 
        if (uart_circ_empty(xmit))
-               sa1100_stop_tx(&sport->port, 0);
+               sa1100_stop_tx(&sport->port);
 }
 
 static irqreturn_t sa1100_int(int irq, void *dev_id, struct pt_regs *regs)
index 54699c3a00ab4e48c1b6c6b196b24ddd80626bc2..2d8622eef7019caffee46cfe2949898e8d7174b0 100644 (file)
@@ -80,7 +80,7 @@ static void uart_stop(struct tty_struct *tty)
        unsigned long flags;
 
        spin_lock_irqsave(&port->lock, flags);
-       port->ops->stop_tx(port, 1);
+       port->ops->stop_tx(port);
        spin_unlock_irqrestore(&port->lock, flags);
 }
 
@@ -91,7 +91,7 @@ static void __uart_start(struct tty_struct *tty)
 
        if (!uart_circ_empty(&state->info->xmit) && state->info->xmit.buf &&
            !tty->stopped && !tty->hw_stopped)
-               port->ops->start_tx(port, 1);
+               port->ops->start_tx(port);
 }
 
 static void uart_start(struct tty_struct *tty)
@@ -542,7 +542,7 @@ static void uart_send_xchar(struct tty_struct *tty, char ch)
                port->x_char = ch;
                if (ch) {
                        spin_lock_irqsave(&port->lock, flags);
-                       port->ops->start_tx(port, 0);
+                       port->ops->start_tx(port);
                        spin_unlock_irqrestore(&port->lock, flags);
                }
        }
@@ -1146,7 +1146,7 @@ static void uart_set_termios(struct tty_struct *tty, struct termios *old_termios
                spin_lock_irqsave(&state->port->lock, flags);
                if (!(state->port->ops->get_mctrl(state->port) & TIOCM_CTS)) {
                        tty->hw_stopped = 1;
-                       state->port->ops->stop_tx(state->port, 0);
+                       state->port->ops->stop_tx(state->port);
                }
                spin_unlock_irqrestore(&state->port->lock, flags);
        }
@@ -1869,7 +1869,7 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *port)
                struct uart_ops *ops = port->ops;
 
                spin_lock_irq(&port->lock);
-               ops->stop_tx(port, 0);
+               ops->stop_tx(port);
                ops->set_mctrl(port, 0);
                ops->stop_rx(port);
                spin_unlock_irq(&port->lock);
@@ -1935,7 +1935,7 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *port)
                uart_change_speed(state, NULL);
                spin_lock_irq(&port->lock);
                ops->set_mctrl(port, port->mctrl);
-               ops->start_tx(port, 0);
+               ops->start_tx(port);
                spin_unlock_irq(&port->lock);
        }
 
@@ -1947,21 +1947,29 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *port)
 static inline void
 uart_report_port(struct uart_driver *drv, struct uart_port *port)
 {
-       printk("%s%d", drv->dev_name, port->line);
-       printk(" at ");
+       char address[64];
+
        switch (port->iotype) {
        case UPIO_PORT:
-               printk("I/O 0x%x", port->iobase);
+               snprintf(address, sizeof(address),
+                        "I/O 0x%x", port->iobase);
                break;
        case UPIO_HUB6:
-               printk("I/O 0x%x offset 0x%x", port->iobase, port->hub6);
+               snprintf(address, sizeof(address),
+                        "I/O 0x%x offset 0x%x", port->iobase, port->hub6);
                break;
        case UPIO_MEM:
        case UPIO_MEM32:
-               printk("MMIO 0x%lx", port->mapbase);
+               snprintf(address, sizeof(address),
+                        "MMIO 0x%lx", port->mapbase);
+               break;
+       default:
+               strlcpy(address, "*unknown*", sizeof(address));
                break;
        }
-       printk(" (irq = %d) is a %s\n", port->irq, uart_type(port));
+
+       printk(KERN_INFO "%s%d at %s (irq = %d) is a %s\n",
+              drv->dev_name, port->line, address, port->irq, uart_type(port));
 }
 
 static void
@@ -2289,143 +2297,11 @@ int uart_match_port(struct uart_port *port1, struct uart_port *port2)
 }
 EXPORT_SYMBOL(uart_match_port);
 
-/*
- *     Try to find an unused uart_state slot for a port.
- */
-static struct uart_state *
-uart_find_match_or_unused(struct uart_driver *drv, struct uart_port *port)
-{
-       int i;
-
-       /*
-        * First, find a port entry which matches.  Note: if we do
-        * find a matching entry, and it has a non-zero use count,
-        * then we can't register the port.
-        */
-       for (i = 0; i < drv->nr; i++)
-               if (uart_match_port(drv->state[i].port, port))
-                       return &drv->state[i];
-
-       /*
-        * We didn't find a matching entry, so look for the first
-        * free entry.  We look for one which hasn't been previously
-        * used (indicated by zero iobase).
-        */
-       for (i = 0; i < drv->nr; i++)
-               if (drv->state[i].port->type == PORT_UNKNOWN &&
-                   drv->state[i].port->iobase == 0 &&
-                   drv->state[i].count == 0)
-                       return &drv->state[i];
-
-       /*
-        * That also failed.  Last resort is to find any currently
-        * entry which doesn't have a real port associated with it.
-        */
-       for (i = 0; i < drv->nr; i++)
-               if (drv->state[i].port->type == PORT_UNKNOWN &&
-                   drv->state[i].count == 0)
-                       return &drv->state[i];
-
-       return NULL;
-}
-
-/**
- *     uart_register_port: register uart settings with a port
- *     @drv: pointer to the uart low level driver structure for this port
- *     @port: uart port structure describing the port
- *
- *     Register UART settings with the specified low level driver.  Detect
- *     the type of the port if UPF_BOOT_AUTOCONF is set, and detect the
- *     IRQ if UPF_AUTO_IRQ is set.
- *
- *     We try to pick the same port for the same IO base address, so that
- *     when a modem is plugged in, unplugged and plugged back in, it gets
- *     allocated the same port.
- *
- *     Returns negative error, or positive line number.
- */
-int uart_register_port(struct uart_driver *drv, struct uart_port *port)
-{
-       struct uart_state *state;
-       int ret;
-
-       down(&port_sem);
-
-       state = uart_find_match_or_unused(drv, port);
-
-       if (state) {
-               /*
-                * Ok, we've found a line that we can use.
-                *
-                * If we find a port that matches this one, and it appears
-                * to be in-use (even if it doesn't have a type) we shouldn't
-                * alter it underneath itself - the port may be open and
-                * trying to do useful work.
-                */
-               if (uart_users(state) != 0) {
-                       ret = -EBUSY;
-                       goto out;
-               }
-
-               /*
-                * If the port is already initialised, don't touch it.
-                */
-               if (state->port->type == PORT_UNKNOWN) {
-                       state->port->iobase   = port->iobase;
-                       state->port->membase  = port->membase;
-                       state->port->irq      = port->irq;
-                       state->port->uartclk  = port->uartclk;
-                       state->port->fifosize = port->fifosize;
-                       state->port->regshift = port->regshift;
-                       state->port->iotype   = port->iotype;
-                       state->port->flags    = port->flags;
-                       state->port->line     = state - drv->state;
-                       state->port->mapbase  = port->mapbase;
-
-                       uart_configure_port(drv, state, state->port);
-               }
-
-               ret = state->port->line;
-       } else
-               ret = -ENOSPC;
- out:
-       up(&port_sem);
-       return ret;
-}
-
-/**
- *     uart_unregister_port - de-allocate a port
- *     @drv: pointer to the uart low level driver structure for this port
- *     @line: line index previously returned from uart_register_port()
- *
- *     Hang up the specified line associated with the low level driver,
- *     and mark the port as unused.
- */
-void uart_unregister_port(struct uart_driver *drv, int line)
-{
-       struct uart_state *state;
-
-       if (line < 0 || line >= drv->nr) {
-               printk(KERN_ERR "Attempt to unregister ");
-               printk("%s%d", drv->dev_name, line);
-               printk("\n");
-               return;
-       }
-
-       state = drv->state + line;
-
-       down(&port_sem);
-       uart_unconfigure_port(drv, state);
-       up(&port_sem);
-}
-
 EXPORT_SYMBOL(uart_write_wakeup);
 EXPORT_SYMBOL(uart_register_driver);
 EXPORT_SYMBOL(uart_unregister_driver);
 EXPORT_SYMBOL(uart_suspend_port);
 EXPORT_SYMBOL(uart_resume_port);
-EXPORT_SYMBOL(uart_register_port);
-EXPORT_SYMBOL(uart_unregister_port);
 EXPORT_SYMBOL(uart_add_one_port);
 EXPORT_SYMBOL(uart_remove_one_port);
 
index 56f269b6bfb12c53fb323c66dcab126010888bee..32f808d157a15ee8a57f3a73645cc5024e054c90 100644 (file)
@@ -112,13 +112,12 @@ struct uart_port_lh7a40x {
        unsigned int statusPrev; /* Most recently read modem status */
 };
 
-static void lh7a40xuart_stop_tx (struct uart_port* port, unsigned int tty_stop)
+static void lh7a40xuart_stop_tx (struct uart_port* port)
 {
        BIT_CLR (port, UART_R_INTEN, TxInt);
 }
 
-static void lh7a40xuart_start_tx (struct uart_port* port,
-                                 unsigned int tty_start)
+static void lh7a40xuart_start_tx (struct uart_port* port)
 {
        BIT_SET (port, UART_R_INTEN, TxInt);
 
index d085030df70ba5bd321a0fd5716df8ab31af39e1..49afadbe461b2875ad5b6f0c913cf9906551b5f0 100644 (file)
@@ -253,7 +253,7 @@ sio_quot_set(struct uart_txx9_port *up, int quot)
                sio_out(up, TXX9_SIBGR, 0xff | TXX9_SIBGR_BCLK_T6);
 }
 
-static void serial_txx9_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void serial_txx9_stop_tx(struct uart_port *port)
 {
        struct uart_txx9_port *up = (struct uart_txx9_port *)port;
        unsigned long flags;
@@ -263,7 +263,7 @@ static void serial_txx9_stop_tx(struct uart_port *port, unsigned int tty_stop)
        spin_unlock_irqrestore(&up->port.lock, flags);
 }
 
-static void serial_txx9_start_tx(struct uart_port *port, unsigned int tty_start)
+static void serial_txx9_start_tx(struct uart_port *port)
 {
        struct uart_txx9_port *up = (struct uart_txx9_port *)port;
        unsigned long flags;
@@ -372,7 +372,7 @@ static inline void transmit_chars(struct uart_txx9_port *up)
                return;
        }
        if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) {
-               serial_txx9_stop_tx(&up->port, 0);
+               serial_txx9_stop_tx(&up->port);
                return;
        }
 
@@ -389,7 +389,7 @@ static inline void transmit_chars(struct uart_txx9_port *up)
                uart_write_wakeup(&up->port);
 
        if (uart_circ_empty(xmit))
-               serial_txx9_stop_tx(&up->port, 0);
+               serial_txx9_stop_tx(&up->port);
 }
 
 static irqreturn_t serial_txx9_interrupt(int irq, void *dev_id, struct pt_regs *regs)
index ad5b776d779b3ca56a8db712ddd89defefe2dbce..512266307866d5c99784499b7d025eab47294b49 100644 (file)
@@ -79,8 +79,8 @@ static struct sci_port *serial_console_port = 0;
 #endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */
 
 /* Function prototypes */
-static void sci_stop_tx(struct uart_port *port, unsigned int tty_stop);
-static void sci_start_tx(struct uart_port *port, unsigned int tty_start);
+static void sci_stop_tx(struct uart_port *port);
+static void sci_start_tx(struct uart_port *port);
 static void sci_start_rx(struct uart_port *port, unsigned int tty_start);
 static void sci_stop_rx(struct uart_port *port);
 static int sci_request_irq(struct sci_port *port);
@@ -455,7 +455,7 @@ static void sci_transmit_chars(struct uart_port *port)
        if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
                uart_write_wakeup(port);
        if (uart_circ_empty(xmit)) {
-               sci_stop_tx(port, 0);
+               sci_stop_tx(port);
        } else {
                local_irq_save(flags);
                ctrl = sci_in(port, SCSCR);
@@ -900,7 +900,7 @@ static unsigned int sci_get_mctrl(struct uart_port *port)
        return TIOCM_DTR | TIOCM_RTS | TIOCM_DSR;
 }
 
-static void sci_start_tx(struct uart_port *port, unsigned int tty_start)
+static void sci_start_tx(struct uart_port *port)
 {
        struct sci_port *s = &sci_ports[port->line];
 
@@ -909,7 +909,7 @@ static void sci_start_tx(struct uart_port *port, unsigned int tty_start)
        enable_irq(s->irqs[SCIx_TXI_IRQ]);
 }
 
-static void sci_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void sci_stop_tx(struct uart_port *port)
 {
        unsigned long flags;
        unsigned short ctrl;
@@ -978,7 +978,7 @@ static void sci_shutdown(struct uart_port *port)
        struct sci_port *s = &sci_ports[port->line];
 
        sci_stop_rx(port);
-       sci_stop_tx(port, 1);
+       sci_stop_tx(port);
        sci_free_irq(s);
 
 #if defined(__H8300S__)
index 12d1f14e78ce3a036da34e508fc513b28ce2af1f..313f9df24a2de97426df92de3c439af9d07dda91 100644 (file)
@@ -259,10 +259,9 @@ static unsigned int snp_tx_empty(struct uart_port *port)
 /**
  * snp_stop_tx - stop the transmitter - no-op for us
  * @port: Port to operat eon - we ignore - no-op function
- * @tty_stop: Set to 1 if called via uart_stop
  *
  */
-static void snp_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void snp_stop_tx(struct uart_port *port)
 {
 }
 
@@ -325,10 +324,9 @@ static void snp_stop_rx(struct uart_port *port)
 /**
  * snp_start_tx - Start transmitter
  * @port: Port to operate on
- * @tty_stop: Set to 1 if called via uart_start
  *
  */
-static void snp_start_tx(struct uart_port *port, unsigned int tty_stop)
+static void snp_start_tx(struct uart_port *port)
 {
        if (sal_console_port.sc_ops->sal_wakeup_transmit)
                sal_console_port.sc_ops->sal_wakeup_transmit(&sal_console_port,
@@ -615,7 +613,7 @@ static void sn_transmit_chars(struct sn_cons_port *port, int raw)
                uart_write_wakeup(&port->sc_port);
 
        if (uart_circ_empty(xmit))
-               snp_stop_tx(&port->sc_port, 0); /* no-op for us */
+               snp_stop_tx(&port->sc_port);    /* no-op for us */
 }
 
 /**
index 8d198880756a6a3aef034eb55ca6ca7ea5a212e5..e971156daa60c49e94fcf26ae1ddc3a3b3e387ad 100644 (file)
@@ -245,7 +245,7 @@ receive_chars(struct uart_sunsab_port *up,
        return tty;
 }
 
-static void sunsab_stop_tx(struct uart_port *, unsigned int);
+static void sunsab_stop_tx(struct uart_port *);
 static void sunsab_tx_idle(struct uart_sunsab_port *);
 
 static void transmit_chars(struct uart_sunsab_port *up,
@@ -301,7 +301,7 @@ static void transmit_chars(struct uart_sunsab_port *up,
                uart_write_wakeup(&up->port);
 
        if (uart_circ_empty(xmit))
-               sunsab_stop_tx(&up->port, 0);
+               sunsab_stop_tx(&up->port);
 }
 
 static void check_status(struct uart_sunsab_port *up,
@@ -448,7 +448,7 @@ static unsigned int sunsab_get_mctrl(struct uart_port *port)
 }
 
 /* port->lock held by caller.  */
-static void sunsab_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void sunsab_stop_tx(struct uart_port *port)
 {
        struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
 
@@ -476,7 +476,7 @@ static void sunsab_tx_idle(struct uart_sunsab_port *up)
 }
 
 /* port->lock held by caller.  */
-static void sunsab_start_tx(struct uart_port *port, unsigned int tty_start)
+static void sunsab_start_tx(struct uart_port *port)
 {
        struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
        struct circ_buf *xmit = &up->port.info->xmit;
index d57a3553aea359ac7a3123ae62261f2ed9abbb0d..5959e6755a8149d4fd440592b2d6ae57fe25b929 100644 (file)
@@ -255,21 +255,30 @@ static void disable_rsa(struct uart_sunsu_port *up)
 }
 #endif /* CONFIG_SERIAL_8250_RSA */
 
-static void sunsu_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static inline void __stop_tx(struct uart_sunsu_port *p)
+{
+       if (p->ier & UART_IER_THRI) {
+               p->ier &= ~UART_IER_THRI;
+               serial_out(p, UART_IER, p->ier);
+       }
+}
+
+static void sunsu_stop_tx(struct uart_port *port)
 {
        struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
 
-       if (up->ier & UART_IER_THRI) {
-               up->ier &= ~UART_IER_THRI;
-               serial_out(up, UART_IER, up->ier);
-       }
-       if (up->port.type == PORT_16C950 && tty_stop) {
+       __stop_tx(up);
+
+       /*
+        * We really want to stop the transmitter from sending.
+        */
+       if (up->port.type == PORT_16C950) {
                up->acr |= UART_ACR_TXDIS;
                serial_icr_write(up, UART_ACR, up->acr);
        }
 }
 
-static void sunsu_start_tx(struct uart_port *port, unsigned int tty_start)
+static void sunsu_start_tx(struct uart_port *port)
 {
        struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
 
@@ -277,10 +286,11 @@ static void sunsu_start_tx(struct uart_port *port, unsigned int tty_start)
                up->ier |= UART_IER_THRI;
                serial_out(up, UART_IER, up->ier);
        }
+
        /*
-        * We only do this from uart_start
+        * Re-enable the transmitter if we disabled it.
         */
-       if (tty_start && up->port.type == PORT_16C950) {
+       if (up->port.type == PORT_16C950 && up->acr & UART_ACR_TXDIS) {
                up->acr &= ~UART_ACR_TXDIS;
                serial_icr_write(up, UART_ACR, up->acr);
        }
@@ -413,8 +423,12 @@ static _INLINE_ void transmit_chars(struct uart_sunsu_port *up)
                up->port.x_char = 0;
                return;
        }
-       if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) {
-               sunsu_stop_tx(&up->port, 0);
+       if (uart_tx_stopped(&up->port)) {
+               sunsu_stop_tx(&up->port);
+               return;
+       }
+       if (uart_circ_empty(xmit)) {
+               __stop_tx(up);
                return;
        }
 
@@ -431,7 +445,7 @@ static _INLINE_ void transmit_chars(struct uart_sunsu_port *up)
                uart_write_wakeup(&up->port);
 
        if (uart_circ_empty(xmit))
-               sunsu_stop_tx(&up->port, 0);
+               __stop_tx(up);
 }
 
 static _INLINE_ void check_modem_status(struct uart_sunsu_port *up)
index bff42a7b89d0ec6e02862fcd656a12500ccc144b..d75445738c881d4ef442455e5b0b9e3a335be5bd 100644 (file)
@@ -684,7 +684,7 @@ static void sunzilog_set_mctrl(struct uart_port *port, unsigned int mctrl)
 }
 
 /* The port lock is held and interrupts are disabled.  */
-static void sunzilog_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void sunzilog_stop_tx(struct uart_port *port)
 {
        struct uart_sunzilog_port *up = (struct uart_sunzilog_port *) port;
 
@@ -692,7 +692,7 @@ static void sunzilog_stop_tx(struct uart_port *port, unsigned int tty_stop)
 }
 
 /* The port lock is held and interrupts are disabled.  */
-static void sunzilog_start_tx(struct uart_port *port, unsigned int tty_start)
+static void sunzilog_start_tx(struct uart_port *port)
 {
        struct uart_sunzilog_port *up = (struct uart_sunzilog_port *) port;
        struct zilog_channel __iomem *channel = ZILOG_CHANNEL_FROM_PORT(port);
index 186f1300cead9524a54e54bf7823c42492bd2dc3..47b504ff38b2e00b565deeba6698ff70b114d31b 100644 (file)
@@ -87,7 +87,7 @@
 #define UART_TX_READY(s)       (((s) & UART_TSR_TX_LEVEL_MSK) < 15)
 //#define UART_TX_EMPTY(p)     ((UART_GET_FR(p) & UART00_UARTFR_TMSK) == 0)
 
-static void uart00_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void uart00_stop_tx(struct uart_port *port)
 {
        UART_PUT_IEC(port, UART_IEC_TIE_MSK);
 }
@@ -199,7 +199,7 @@ static void uart00_tx_chars(struct uart_port *port)
                return;
        }
        if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
-               uart00_stop_tx(port, 0);
+               uart00_stop_tx(port);
                return;
        }
 
@@ -218,10 +218,10 @@ static void uart00_tx_chars(struct uart_port *port)
                uart_write_wakeup(port);
 
        if (uart_circ_empty(xmit))
-               uart00_stop_tx(port, 0);
+               uart00_stop_tx(port);
 }
 
-static void uart00_start_tx(struct uart_port *port, unsigned int tty_start)
+static void uart00_start_tx(struct uart_port *port)
 {
        UART_PUT_IES(port, UART_IES_TIE_MSK);
        uart00_tx_chars(port);
index bb482780a41d97c8452705825bdd4a31790fb208..9378895a8d56e9506a8e3569173087138089b832 100644 (file)
@@ -240,7 +240,7 @@ console_initcall(v850e_uart_console_init);
 \f
 /* TX/RX interrupt handlers.  */
 
-static void v850e_uart_stop_tx (struct uart_port *port, unsigned tty_stop);
+static void v850e_uart_stop_tx (struct uart_port *port);
 
 void v850e_uart_tx (struct uart_port *port)
 {
@@ -339,14 +339,14 @@ static unsigned v850e_uart_get_mctrl (struct uart_port *port)
        return mctrl;
 }
 
-static void v850e_uart_start_tx (struct uart_port *port, unsigned tty_start)
+static void v850e_uart_start_tx (struct uart_port *port)
 {
        v850e_intc_disable_irq (V850E_UART_TX_IRQ (port->line));
        v850e_uart_tx (port);
        v850e_intc_enable_irq (V850E_UART_TX_IRQ (port->line));
 }
 
-static void v850e_uart_stop_tx (struct uart_port *port, unsigned tty_stop)
+static void v850e_uart_stop_tx (struct uart_port *port)
 {
        v850e_intc_disable_irq (V850E_UART_TX_IRQ (port->line));
 }
index 1f985327b0d485ec8b4648073ef39a80d25d28f1..0c5d65a08f6e01e4d84e33d8adc042a85ed58b6e 100644 (file)
@@ -284,7 +284,7 @@ static unsigned int siu_get_mctrl(struct uart_port *port)
        return mctrl;
 }
 
-static void siu_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void siu_stop_tx(struct uart_port *port)
 {
        unsigned long flags;
        uint8_t ier;
@@ -298,7 +298,7 @@ static void siu_stop_tx(struct uart_port *port, unsigned int tty_stop)
        spin_unlock_irqrestore(&port->lock, flags);
 }
 
-static void siu_start_tx(struct uart_port *port, unsigned int tty_start)
+static void siu_start_tx(struct uart_port *port)
 {
        unsigned long flags;
        uint8_t ier;
@@ -458,7 +458,7 @@ static inline void transmit_chars(struct uart_port *port)
        }
 
        if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
-               siu_stop_tx(port, 0);
+               siu_stop_tx(port);
                return;
        }
 
@@ -474,7 +474,7 @@ static inline void transmit_chars(struct uart_port *port)
                uart_write_wakeup(port);
 
        if (uart_circ_empty(xmit))
-               siu_stop_tx(port, 0);
+               siu_stop_tx(port);
 }
 
 static irqreturn_t siu_interrupt(int irq, void *dev_id, struct pt_regs *regs)
index 79422a3b07bc4bce769e6cc8ac7f08c6b3d17f95..9f44e83c6a6903f3dfb02a89088d1667cbe19812 100644 (file)
@@ -782,7 +782,7 @@ static int usb_register_bus(struct usb_bus *bus)
                return -E2BIG;
        }
 
-       bus->class_dev = class_device_create(usb_host_class, MKDEV(0,0), bus->controller, "usb%d", busnum);
+       bus->class_dev = class_device_create(usb_host_class, MKDEV(0,0), bus->controller, "usb_host%d", busnum);
        if (IS_ERR(bus->class_dev)) {
                clear_bit(busnum, busmap.busmap);
                up(&usb_bus_list_lock);
index c3e46d24a37ed0a93c8f1c2d39c27c30617b4435..c9412daff682431a820d11c3595cde972929377d 100644 (file)
@@ -1570,7 +1570,7 @@ static int __usb_suspend_device (struct usb_device *udev, int port1,
                        struct usb_driver       *driver;
 
                        intf = udev->actconfig->interface[i];
-                       if (state <= intf->dev.power.power_state)
+                       if (state.event <= intf->dev.power.power_state.event)
                                continue;
                        if (!intf->dev.driver)
                                continue;
@@ -1578,11 +1578,11 @@ static int __usb_suspend_device (struct usb_device *udev, int port1,
 
                        if (driver->suspend) {
                                status = driver->suspend(intf, state);
-                               if (intf->dev.power.power_state != state
+                               if (intf->dev.power.power_state.event != state.event
                                                || status)
                                        dev_err(&intf->dev,
                                                "suspend %d fail, code %d\n",
-                                               state, status);
+                                               state.event, status);
                        }
 
                        /* only drivers with suspend() can ever resume();
@@ -1595,7 +1595,7 @@ static int __usb_suspend_device (struct usb_device *udev, int port1,
                         * since we know every driver's probe/disconnect works
                         * even for drivers that can't suspend.
                         */
-                       if (!driver->suspend || state > PM_SUSPEND_MEM) {
+                       if (!driver->suspend || state.event > PM_EVENT_FREEZE) {
 #if 1
                                dev_warn(&intf->dev, "resume is unsafe!\n");
 #else
@@ -1616,7 +1616,7 @@ static int __usb_suspend_device (struct usb_device *udev, int port1,
         * policies (when HNP doesn't apply) once we have mechanisms to
         * turn power back on!  (Likely not before 2.7...)
         */
-       if (state > PM_SUSPEND_MEM) {
+       if (state.event > PM_EVENT_FREEZE) {
                dev_warn(&udev->dev, "no poweroff yet, suspending instead\n");
        }
 
@@ -1733,7 +1733,7 @@ static int finish_port_resume(struct usb_device *udev)
                        struct usb_driver       *driver;
 
                        intf = udev->actconfig->interface[i];
-                       if (intf->dev.power.power_state == PMSG_ON)
+                       if (intf->dev.power.power_state.event == PM_EVENT_ON)
                                continue;
                        if (!intf->dev.driver) {
                                /* FIXME maybe force to alt 0 */
@@ -1747,11 +1747,11 @@ static int finish_port_resume(struct usb_device *udev)
 
                        /* can we do better than just logging errors? */
                        status = driver->resume(intf);
-                       if (intf->dev.power.power_state != PMSG_ON
+                       if (intf->dev.power.power_state.event != PM_EVENT_ON
                                        || status)
                                dev_dbg(&intf->dev,
                                        "resume fail, state %d code %d\n",
-                                       intf->dev.power.power_state, status);
+                                       intf->dev.power.power_state.event, status);
                }
                status = 0;
 
@@ -1934,7 +1934,7 @@ static int hub_resume(struct usb_interface *intf)
        unsigned                port1;
        int                     status;
 
-       if (intf->dev.power.power_state == PM_SUSPEND_ON)
+       if (intf->dev.power.power_state.event == PM_EVENT_ON)
                return 0;
 
        for (port1 = 1; port1 <= hdev->maxchild; port1++) {
index 99c85d2f92daaf115df6cbe902a8f7a266fa3f66..2cddd8a00437b8bede3f9814a66dc73a2190886a 100644 (file)
@@ -1400,7 +1400,7 @@ static int usb_generic_suspend(struct device *dev, pm_message_t message)
        driver = to_usb_driver(dev->driver);
 
        /* there's only one USB suspend state */
-       if (intf->dev.power.power_state)
+       if (intf->dev.power.power_state.event)
                return 0;
 
        if (driver->suspend)
index b01efb6b36f6767e7e492af441421a7d27ce631e..65ac9fef3a7c1dfc382ef2c8aaf5a089fdb7a7ad 100644 (file)
@@ -641,7 +641,7 @@ show_registers (struct class_device *class_dev, char *buf)
 
        spin_lock_irqsave (&ehci->lock, flags);
 
-       if (bus->controller->power.power_state) {
+       if (bus->controller->power.power_state.event) {
                size = scnprintf (next, size,
                        "bus %s, device %s (driver " DRIVER_VERSION ")\n"
                        "%s\n"
index c58408c95c3d26666fb86482b03274dd0b2b241b..447f488f5d937f85de1e7c75348e04bf8400a040 100644 (file)
@@ -631,7 +631,7 @@ show_registers (struct class_device *class_dev, char *buf)
                hcd->product_desc,
                hcd_name);
 
-       if (bus->controller->power.power_state) {
+       if (bus->controller->power.power_state.event) {
                size -= scnprintf (next, size,
                        "SUSPENDED (no register access)\n");
                goto done;
index 7a890a65f55dc53664b8dd130ee3b4a6b048ffa7..80eaf659c1984b0921acd9b956600bcdc0a5b348 100644 (file)
@@ -1781,9 +1781,9 @@ sl811h_suspend(struct device *dev, pm_message_t state, u32 phase)
        if (phase != SUSPEND_POWER_DOWN)
                return retval;
 
-       if (state <= PM_SUSPEND_MEM)
+       if (state.event == PM_EVENT_FREEZE)
                retval = sl811h_hub_suspend(hcd);
-       else
+       else if (state.event == PM_EVENT_SUSPEND)
                port_power(sl811, 0);
        if (retval == 0)
                dev->power.power_state = state;
@@ -1802,7 +1802,7 @@ sl811h_resume(struct device *dev, u32 phase)
        /* with no "check to see if VBUS is still powered" board hook,
         * let's assume it'd only be powered to enable remote wakeup.
         */
-       if (dev->power.power_state > PM_SUSPEND_MEM
+       if (dev->power.power_state.event == PM_EVENT_SUSPEND
                        || !hcd->can_wakeup) {
                sl811->port1 = 0;
                port_power(sl811, 1);
index ca9f3a30634fef6eb3f9fb2aed8d319b33aa660b..f36c0b6c6e36cd3db2665863f001c93606f9f1c0 100644 (file)
@@ -1523,7 +1523,6 @@ static u32 w9968cf_i2c_func(struct i2c_adapter* adap)
 static int w9968cf_i2c_attach_inform(struct i2c_client* client)
 {
        struct w9968cf_device* cam = i2c_get_adapdata(client->adapter);
-       const char* clientname = i2c_clientname(client);
        int id = client->driver->id, err = 0;
 
        if (id == I2C_DRIVERID_OVCAMCHIP) {
@@ -1535,12 +1534,12 @@ static int w9968cf_i2c_attach_inform(struct i2c_client* client)
                }
        } else {
                DBG(4, "Rejected client [%s] with driver [%s]", 
-                   clientname, client->driver->name)
+                   client->name, client->driver->name)
                return -EINVAL;
        }
 
        DBG(5, "I2C attach client [%s] with driver [%s]",
-           clientname, client->driver->name)
+           client->name, client->driver->name)
 
        return 0;
 }
@@ -1549,12 +1548,11 @@ static int w9968cf_i2c_attach_inform(struct i2c_client* client)
 static int w9968cf_i2c_detach_inform(struct i2c_client* client)
 {
        struct w9968cf_device* cam = i2c_get_adapdata(client->adapter);
-       const char* clientname = i2c_clientname(client);
 
        if (cam->sensor_client == client)
                cam->sensor_client = NULL;
 
-       DBG(5, "I2C detach client [%s]", clientname)
+       DBG(5, "I2C detach client [%s]", client->name)
 
        return 0;
 }
@@ -1573,15 +1571,13 @@ static int w9968cf_i2c_init(struct w9968cf_device* cam)
        int err = 0;
 
        static struct i2c_algorithm algo = {
-               .name =          "W996[87]CF algorithm",
-               .id =            I2C_ALGO_SMBUS,
                .smbus_xfer =    w9968cf_i2c_smbus_xfer,
                .algo_control =  w9968cf_i2c_control,
                .functionality = w9968cf_i2c_func,
        };
 
        static struct i2c_adapter adap = {
-               .id =                I2C_ALGO_SMBUS | I2C_HW_SMBUS_W9968CF,
+               .id =                I2C_HW_SMBUS_W9968CF,
                .class =             I2C_CLASS_CAM_DIGITAL,
                .owner =             THIS_MODULE,
                .client_register =   w9968cf_i2c_attach_inform,
index cda7249a90b285225df15bb99b2d3af6e5b91589..fd7fb98e4b2029c752fa94d86f8b8d26e775779e 100644 (file)
@@ -1533,7 +1533,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
        if (down_interruptible (&dev->sem))
                return -ERESTARTSYS;
 
-       if (intf->dev.power.power_state != PMSG_ON) {
+       if (intf->dev.power.power_state.event != PM_EVENT_ON) {
                up (&dev->sem);
                return -EHOSTUNREACH;
        }
index 16f352195512e1d972be935e81b9e9cbf160f37d..fe3fd4115e1e31608745a070aded61063eaba818 100644 (file)
@@ -8,5 +8,3 @@ obj-$(CONFIG_USB_PEGASUS)       += pegasus.o
 obj-$(CONFIG_USB_RTL8150)      += rtl8150.o
 obj-$(CONFIG_USB_USBNET)       += usbnet.o
 obj-$(CONFIG_USB_ZD1201)       += zd1201.o
-
-CFLAGS_zd1201.o = -Idrivers/net/wireless/
index e32a80b39182b5dbbc06d15b2f96abf1897f9e7f..fc013978837e21fd756a594d53b6d52326b2646f 100644 (file)
@@ -21,7 +21,7 @@
 #include <linux/string.h>
 #include <linux/if_arp.h>
 #include <linux/firmware.h>
-#include <ieee802_11.h>
+#include <net/ieee80211.h>
 #include "zd1201.h"
 
 static struct usb_device_id zd1201_table[] = {
@@ -338,24 +338,24 @@ static void zd1201_usbrx(struct urb *urb, struct pt_regs *regs)
                        goto resubmit;
                }
                        
-               if ((seq & IEEE802_11_SCTL_FRAG) ||
-                   (fc & IEEE802_11_FCTL_MOREFRAGS)) {
+               if ((seq & IEEE80211_SCTL_FRAG) ||
+                   (fc & IEEE80211_FCTL_MOREFRAGS)) {
                        struct zd1201_frag *frag = NULL;
                        char *ptr;
 
                        if (datalen<14)
                                goto resubmit;
-                       if ((seq & IEEE802_11_SCTL_FRAG) == 0) {
+                       if ((seq & IEEE80211_SCTL_FRAG) == 0) {
                                frag = kmalloc(sizeof(*frag), GFP_ATOMIC);
                                if (!frag)
                                        goto resubmit;
-                               skb = dev_alloc_skb(IEEE802_11_DATA_LEN +14+2);
+                               skb = dev_alloc_skb(IEEE80211_DATA_LEN +14+2);
                                if (!skb) {
                                        kfree(frag);
                                        goto resubmit;
                                }
                                frag->skb = skb;
-                               frag->seq = seq & IEEE802_11_SCTL_SEQ;
+                               frag->seq = seq & IEEE80211_SCTL_SEQ;
                                skb_reserve(skb, 2);
                                memcpy(skb_put(skb, 12), &data[datalen-14], 12);
                                memcpy(skb_put(skb, 2), &data[6], 2);
@@ -364,7 +364,7 @@ static void zd1201_usbrx(struct urb *urb, struct pt_regs *regs)
                                goto resubmit;
                        }
                        hlist_for_each_entry(frag, node, &zd->fraglist, fnode)
-                               if(frag->seq == (seq&IEEE802_11_SCTL_SEQ))
+                               if(frag->seq == (seq&IEEE80211_SCTL_SEQ))
                                        break;
                        if (!frag)
                                goto resubmit;
@@ -372,7 +372,7 @@ static void zd1201_usbrx(struct urb *urb, struct pt_regs *regs)
                        ptr = skb_put(skb, len);
                        if (ptr)
                                memcpy(ptr, data+8, len);
-                       if (fc & IEEE802_11_FCTL_MOREFRAGS)
+                       if (fc & IEEE80211_FCTL_MOREFRAGS)
                                goto resubmit;
                        hlist_del_init(&frag->fnode);
                        kfree(frag);
index 7bc1d44d88147d5368e2301a78254dba1f25f4bd..b0eba3ac6420f61e692118075fa5baf8bce2be4f 100644 (file)
@@ -2323,17 +2323,16 @@ static int aty128_pci_suspend(struct pci_dev *pdev, pm_message_t state)
         * can properly take care of D3 ? Also, with swsusp, we
         * know we'll be rebooted, ...
         */
-#ifdef CONFIG_PPC_PMAC
+#ifndef CONFIG_PPC_PMAC
        /* HACK ALERT ! Once I find a proper way to say to each driver
         * individually what will happen with it's PCI slot, I'll change
         * that. On laptops, the AGP slot is just unclocked, so D2 is
         * expected, while on desktops, the card is powered off
         */
-       if (state >= 3)
-               state = 2;
+       return 0;
 #endif /* CONFIG_PPC_PMAC */
         
-       if (state != 2 || state == pdev->dev.power.power_state)
+       if (state.event == pdev->dev.power.power_state.event)
                return 0;
 
        printk(KERN_DEBUG "aty128fb: suspending...\n");
@@ -2367,7 +2366,7 @@ static int aty128_pci_suspend(struct pci_dev *pdev, pm_message_t state)
         * used dummy fb ops, 2.5 need proper support for this at the
         * fbdev level
         */
-       if (state == 2)
+       if (state.event != PM_EVENT_ON)
                aty128_set_suspend(par, 1);
 
        release_console_sem();
@@ -2382,12 +2381,11 @@ static int aty128_do_resume(struct pci_dev *pdev)
        struct fb_info *info = pci_get_drvdata(pdev);
        struct aty128fb_par *par = info->par;
 
-       if (pdev->dev.power.power_state == 0)
+       if (pdev->dev.power.power_state.event == PM_EVENT_ON)
                return 0;
 
        /* Wakeup chip */
-       if (pdev->dev.power.power_state == 2)
-               aty128_set_suspend(par, 0);
+       aty128_set_suspend(par, 0);
        par->asleep = 0;
 
        /* Restore display & engine */
index 8c42538dc8c12db3ff65be3721bf6f3935e0533e..3e10bd837d9e8382a9f5bf5b0ac7073bb85bdd92 100644 (file)
@@ -2022,17 +2022,16 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
        struct fb_info *info = pci_get_drvdata(pdev);
        struct atyfb_par *par = (struct atyfb_par *) info->par;
 
-#ifdef CONFIG_PPC_PMAC
+#ifndef CONFIG_PPC_PMAC
        /* HACK ALERT ! Once I find a proper way to say to each driver
         * individually what will happen with it's PCI slot, I'll change
         * that. On laptops, the AGP slot is just unclocked, so D2 is
         * expected, while on desktops, the card is powered off
         */
-       if (state >= 3)
-               state = 2;
+       return 0;
 #endif /* CONFIG_PPC_PMAC */
 
-       if (state != 2 || state == pdev->dev.power.power_state)
+       if (state.event == pdev->dev.power.power_state.event)
                return 0;
 
        acquire_console_sem();
@@ -2071,12 +2070,12 @@ static int atyfb_pci_resume(struct pci_dev *pdev)
        struct fb_info *info = pci_get_drvdata(pdev);
        struct atyfb_par *par = (struct atyfb_par *) info->par;
 
-       if (pdev->dev.power.power_state == 0)
+       if (pdev->dev.power.power_state.event == PM_EVENT_ON)
                return 0;
 
        acquire_console_sem();
 
-       if (pdev->dev.power.power_state == 2)
+       if (pdev->dev.power.power_state.event == 2)
                aty_power_mgmt(0, par);
        par->asleep = 0;
 
index 762244164c81a95f00f9d9728f1b9a47858e01fe..a9d0414e4655a0ad2885cbaa807494ef0f757fc3 100644 (file)
@@ -75,7 +75,7 @@ static int radeon_setup_i2c_bus(struct radeon_i2c_chan *chan, const char *name)
 
        strcpy(chan->adapter.name, name);
        chan->adapter.owner             = THIS_MODULE;
-       chan->adapter.id                = I2C_ALGO_ATI;
+       chan->adapter.id                = I2C_HW_B_RADEON;
        chan->adapter.algo_data         = &chan->algo;
        chan->adapter.dev.parent        = &chan->rinfo->pdev->dev;
        chan->algo.setsda               = radeon_gpio_setsda;
index 98352af393255d44907ad92270b4f236cc3210ac..59a1b6f85067863a87749913911b2386827ff898 100644 (file)
@@ -2526,18 +2526,18 @@ int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
         struct radeonfb_info *rinfo = info->par;
        int i;
 
-       if (state == pdev->dev.power.power_state)
+       if (state.event == pdev->dev.power.power_state.event)
                return 0;
 
        printk(KERN_DEBUG "radeonfb (%s): suspending to state: %d...\n",
-              pci_name(pdev), state);
+              pci_name(pdev), state.event);
 
        /* For suspend-to-disk, we cheat here. We don't suspend anything and
         * let fbcon continue drawing until we are all set. That shouldn't
         * really cause any problem at this point, provided that the wakeup
         * code knows that any state in memory may not match the HW
         */
-       if (state != PM_SUSPEND_MEM)
+       if (state.event == PM_EVENT_FREEZE)
                goto done;
 
        acquire_console_sem();
@@ -2616,7 +2616,7 @@ int radeonfb_pci_resume(struct pci_dev *pdev)
         struct radeonfb_info *rinfo = info->par;
        int rc = 0;
 
-       if (pdev->dev.power.power_state == 0)
+       if (pdev->dev.power.power_state.event == PM_EVENT_ON)
                return 0;
 
        if (rinfo->no_schedule) {
@@ -2626,7 +2626,7 @@ int radeonfb_pci_resume(struct pci_dev *pdev)
                acquire_console_sem();
 
        printk(KERN_DEBUG "radeonfb (%s): resuming from state: %d...\n",
-              pci_name(pdev), pdev->dev.power.power_state);
+              pci_name(pdev), pdev->dev.power.power_state.event);
 
 
        if (pci_enable_device(pdev)) {
@@ -2637,7 +2637,7 @@ int radeonfb_pci_resume(struct pci_dev *pdev)
        }
        pci_set_master(pdev);
 
-       if (pdev->dev.power.power_state == PM_SUSPEND_MEM) {
+       if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
                /* Wakeup chip. Check from config space if we were powered off
                 * (todo: additionally, check CLK_PIN_CNTL too)
                 */
index e75a965ec760324ff3ebe5705ebdeb4fb4c97ac6..4131243cfdf85e621263f547b7ebe6baf01985ca 100644 (file)
@@ -462,9 +462,9 @@ static int chipsfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 {
         struct fb_info *p = pci_get_drvdata(pdev);
 
-       if (state == pdev->dev.power.power_state)
+       if (state.event == pdev->dev.power.power_state.event)
                return 0;
-       if (state != PM_SUSPEND_MEM)
+       if (state.event != PM_SUSPEND_MEM)
                goto done;
 
        acquire_console_sem();
index 7513fb9b19cf739cc41afaf888efb0edae722587..6db183462b9200ff642b364492bb39c971ad1d4d 100644 (file)
@@ -1506,12 +1506,12 @@ static int i810fb_suspend(struct pci_dev *dev, pm_message_t state)
        struct i810fb_par *par = (struct i810fb_par *) info->par;
        int blank = 0, prev_state = par->cur_state;
 
-       if (state == prev_state)
+       if (state.event == prev_state)
                return 0;
 
-       par->cur_state = state;
+       par->cur_state = state.event;
 
-       switch (state) {
+       switch (state.event) {
        case 1:
                blank = VESA_VSYNC_SUSPEND;
                break;
index 67f85344f0cc3d3e70edd617e76080788ddfef04..ad60bbb16cdf0dedd14d69333c025dd19718f2a3 100644 (file)
@@ -1271,7 +1271,7 @@ ERROR0:;
 }
 
 static int maven_attach_adapter(struct i2c_adapter* adapter) {
-       if (adapter->id == (I2C_ALGO_BIT | I2C_HW_B_G400))
+       if (adapter->id == I2C_HW_B_G400)
                return i2c_probe(adapter, &addr_data, &maven_detect_client);
        return 0;
 }
index 3757c1407c190144a1dd2190fc92c3b2d0bc7362..1a91bffdda26b78b6cbc38256c856b6f1b0264a9 100644 (file)
@@ -90,14 +90,13 @@ static int nvidia_gpio_getsda(void *data)
        return val;
 }
 
-#define I2C_ALGO_NVIDIA   0x0e0000
 static int nvidia_setup_i2c_bus(struct nvidia_i2c_chan *chan, const char *name)
 {
        int rc;
 
        strcpy(chan->adapter.name, name);
        chan->adapter.owner = THIS_MODULE;
-       chan->adapter.id = I2C_ALGO_NVIDIA;
+       chan->adapter.id = I2C_HW_B_NVIDIA;
        chan->adapter.algo_data = &chan->algo;
        chan->adapter.dev.parent = &chan->par->pci_dev->dev;
        chan->algo.setsda = nvidia_gpio_setsda;
index 3e00ad7f2e3179496086053639fc8ace2716fdf5..28d1fe5fe34007fcdf9996cb0216154732e74f1e 100644 (file)
@@ -413,7 +413,7 @@ static struct fb_ops aafb_ops = {
 
 static int __init init_one(int slot)
 {
-       unsigned long base_addr = get_tc_base_addr(slot);
+       unsigned long base_addr = CKSEG1ADDR(get_tc_base_addr(slot));
        struct aafb_info *ip = &my_fb_info[slot];
 
        memset(ip, 0, sizeof(struct aafb_info));
index f8095588e99d075b88e6056750833a3ccb9f7478..c98f1c8d7dc27b6127fc430ceea517772b1de11d 100644 (file)
@@ -1,57 +1,55 @@
 /*
- *      linux/drivers/video/pmag-ba-fb.c
+ *     linux/drivers/video/pmag-ba-fb.c
  *
- *     PMAG-BA TurboChannel framebuffer card support ... derived from:
+ *     PMAG-BA TURBOchannel Color Frame Buffer (CFB) card support,
+ *     derived from:
  *     "HP300 Topcat framebuffer support (derived from macfb of all things)
  *     Phil Blundell <philb@gnu.org> 1998", the original code can be
- *      found in the file hpfb.c in the same directory.
+ *     found in the file hpfb.c in the same directory.
  *
  *     Based on digital document:
  *     "PMAG-BA TURBOchannel Color Frame Buffer
  *      Functional Specification", Revision 1.2, August 27, 1990
  *
- *      DECstation related code Copyright (C) 1999, 2000, 2001 by
- *      Michael Engel <engel@unix-ag.org>, 
- *      Karsten Merker <merker@linuxtag.org> and
+ *     DECstation related code Copyright (C) 1999, 2000, 2001 by
+ *     Michael Engel <engel@unix-ag.org>,
+ *     Karsten Merker <merker@linuxtag.org> and
  *     Harald Koerfgen.
- *      This file is subject to the terms and conditions of the GNU General
- *      Public License.  See the file COPYING in the main directory of this
- *      archive for more details.
+ *     Copyright (c) 2005  Maciej W. Rozycki
  *
+ *     This file is subject to the terms and conditions of the GNU General
+ *     Public License.  See the file COPYING in the main directory of this
+ *     archive for more details.
  */
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
+
+#include <linux/compiler.h>
 #include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/timer.h>
-#include <linux/mm.h>
-#include <linux/tty.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/init.h>
 #include <linux/fb.h>
-#include <asm/bootinfo.h>
-#include <asm/dec/machtype.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/types.h>
+
+#include <asm/bug.h>
+#include <asm/io.h>
+#include <asm/system.h>
+
 #include <asm/dec/tc.h>
+
 #include <video/pmag-ba-fb.h>
 
-struct pmag_ba_ramdac_regs {
-       unsigned char addr_low;
-       unsigned char pad0[3];
-       unsigned char addr_hi;
-       unsigned char pad1[3];
-       unsigned char data;
-       unsigned char pad2[3];
-       unsigned char cmap;
+
+struct pmagbafb_par {
+       struct fb_info *next;
+       volatile void __iomem *mmio;
+       volatile u32 __iomem *dac;
+       int slot;
 };
 
-/*
- * Max 3 TURBOchannel slots -> max 3 PMAG-BA :)
- */
-static struct fb_info pmagba_fb_info[3];
 
-static struct fb_var_screeninfo pmagbafb_defined = {
+static struct fb_info *root_pmagbafb_dev;
+
+static struct fb_var_screeninfo pmagbafb_defined __initdata = {
        .xres           = 1024,
        .yres           = 864,
        .xres_virtual   = 1024,
@@ -61,58 +59,71 @@ static struct fb_var_screeninfo pmagbafb_defined = {
        .green.length   = 8,
        .blue.length    = 8,
        .activate       = FB_ACTIVATE_NOW,
-       .height         = 274,
-       .width          = 195,
-       .accel          = FB_ACCEL_NONE,
+       .height         = -1,
+       .width          = -1,
+       .accel_flags    = FB_ACCEL_NONE,
+       .pixclock       = 14452,
+       .left_margin    = 116,
+       .right_margin   = 12,
+       .upper_margin   = 34,
+       .lower_margin   = 12,
+       .hsync_len      = 128,
+       .vsync_len      = 3,
+       .sync           = FB_SYNC_ON_GREEN,
        .vmode          = FB_VMODE_NONINTERLACED,
 };
 
-static struct fb_fix_screeninfo pmagbafb_fix = {
+static struct fb_fix_screeninfo pmagbafb_fix __initdata = {
        .id             = "PMAG-BA",
-       .smem_len       = (1024 * 864),
+       .smem_len       = (1024 * 1024),
        .type           = FB_TYPE_PACKED_PIXELS,
        .visual         = FB_VISUAL_PSEUDOCOLOR,
        .line_length    = 1024,
+       .mmio_len       = PMAG_BA_SIZE - PMAG_BA_BT459,
 };
 
-/*
- * Turn hardware cursor off
- */
-void pmagbafb_erase_cursor(struct pmag_ba_ramdac_regs *bt459_regs)
+
+static inline void dac_write(struct pmagbafb_par *par, unsigned int reg, u8 v)
 {
-       bt459_regs->addr_low = 0;
-       bt459_regs->addr_hi = 3;
-       bt459_regs->data = 0;
+       writeb(v, par->dac + reg / 4);
 }
 
+static inline u8 dac_read(struct pmagbafb_par *par, unsigned int reg)
+{
+       return readb(par->dac + reg / 4);
+}
+
+
 /*
- * Set the palette. 
+ * Set the palette.
  */
-static int pmagbafb_setcolreg(unsigned regno, unsigned red, unsigned green,
-                             unsigned blue, unsigned transp,
-                             struct fb_info *info)
+static int pmagbafb_setcolreg(unsigned int regno, unsigned int red,
+                             unsigned int green, unsigned int blue,
+                             unsigned int transp, struct fb_info *info)
 {
-       struct pmag_ba_ramdac_regs *bt459_regs = (struct pmag_ba_ramdac_regs *) info->par;
+       struct pmagbafb_par *par = info->par;
 
-       if (regno >= info->cmap.len)
-               return 1;
+       BUG_ON(regno >= info->cmap.len);
 
        red   >>= 8;    /* The cmap fields are 16 bits    */
-       green >>= 8;    /* wide, but the harware colormap */
+       green >>= 8;    /* wide, but the hardware colormap */
        blue  >>= 8;    /* registers are only 8 bits wide */
 
-       bt459_regs->addr_low = (__u8) regno;
-       bt459_regs->addr_hi = 0;
-       bt459_regs->cmap = red;
-       bt459_regs->cmap = green;
-       bt459_regs->cmap = blue;
+       mb();
+       dac_write(par, BT459_ADDR_LO, regno);
+       dac_write(par, BT459_ADDR_HI, 0x00);
+       wmb();
+       dac_write(par, BT459_CMAP, red);
+       wmb();
+       dac_write(par, BT459_CMAP, green);
+       wmb();
+       dac_write(par, BT459_CMAP, blue);
+
        return 0;
 }
 
 static struct fb_ops pmagbafb_ops = {
        .owner          = THIS_MODULE,
-       .fb_get_fix     = gen_get_fix,
-       .fb_get_var     = gen_get_var,
        .fb_setcolreg   = pmagbafb_setcolreg,
        .fb_fillrect    = cfb_fillrect,
        .fb_copyarea    = cfb_copyarea,
@@ -120,63 +131,133 @@ static struct fb_ops pmagbafb_ops = {
        .fb_cursor      = soft_cursor,
 };
 
-int __init pmagbafb_init_one(int slot)
+
+/*
+ * Turn the hardware cursor off.
+ */
+static void __init pmagbafb_erase_cursor(struct fb_info *info)
+{
+       struct pmagbafb_par *par = info->par;
+
+       mb();
+       dac_write(par, BT459_ADDR_LO, 0x00);
+       dac_write(par, BT459_ADDR_HI, 0x03);
+       wmb();
+       dac_write(par, BT459_DATA, 0x00);
+}
+
+
+static int __init pmagbafb_init_one(int slot)
 {
-       unsigned long base_addr = get_tc_base_addr(slot);
-       struct fb_info *info = &pmagba_fb_info[slot]; 
-       struct display *disp = &pmagba_disp[slot];
-
-       printk("PMAG-BA framebuffer in slot %d\n", slot);
-       /*
-        * Framebuffer display memory base address and friends
-        */
-       pmagbafb_fix.smem_start = base_addr + PMAG_BA_ONBOARD_FBMEM_OFFSET;
-       info->par = (base_addr + PMAG_BA_BT459_OFFSET);
-
-       /*
-        * Configure the Bt459 RAM DAC
-        */
-       pmagbafb_erase_cursor((struct pmag_ba_ramdac_regs *) info->par);
-
-       /*
-        *      Let there be consoles..
-        */
+       struct fb_info *info;
+       struct pmagbafb_par *par;
+       unsigned long base_addr;
+
+       info = framebuffer_alloc(sizeof(struct pmagbafb_par), NULL);
+       if (!info)
+               return -ENOMEM;
+
+       par = info->par;
+       par->slot = slot;
+       claim_tc_card(par->slot);
+
+       base_addr = get_tc_base_addr(par->slot);
+
+       par->next = root_pmagbafb_dev;
+       root_pmagbafb_dev = info;
+
+       if (fb_alloc_cmap(&info->cmap, 256, 0) < 0)
+               goto err_alloc;
+
        info->fbops = &pmagbafb_ops;
+       info->fix = pmagbafb_fix;
        info->var = pmagbafb_defined;
-       info->fix = pmagbafb_fix; 
-       info->screen_base = pmagbafb_fix.smem_start;
        info->flags = FBINFO_DEFAULT;
 
-       fb_alloc_cmap(&fb_info.cmap, 256, 0);
+       /* MMIO mapping setup.  */
+       info->fix.mmio_start = base_addr;
+       par->mmio = ioremap_nocache(info->fix.mmio_start, info->fix.mmio_len);
+       if (!par->mmio)
+               goto err_cmap;
+       par->dac = par->mmio + PMAG_BA_BT459;
+
+       /* Frame buffer mapping setup.  */
+       info->fix.smem_start = base_addr + PMAG_BA_FBMEM;
+       info->screen_base = ioremap_nocache(info->fix.smem_start,
+                                           info->fix.smem_len);
+       if (!info->screen_base)
+               goto err_mmio_map;
+       info->screen_size = info->fix.smem_len;
+
+       pmagbafb_erase_cursor(info);
 
        if (register_framebuffer(info) < 0)
-               return 1;
+               goto err_smem_map;
+
+       pr_info("fb%d: %s frame buffer device in slot %d\n",
+               info->node, info->fix.id, par->slot);
+
        return 0;
+
+
+err_smem_map:
+       iounmap(info->screen_base);
+
+err_mmio_map:
+       iounmap(par->mmio);
+
+err_cmap:
+       fb_dealloc_cmap(&info->cmap);
+
+err_alloc:
+       root_pmagbafb_dev = par->next;
+       release_tc_card(par->slot);
+       framebuffer_release(info);
+       return -ENXIO;
 }
 
-/* 
- * Initialise the framebuffer
- */
+static void __exit pmagbafb_exit_one(void)
+{
+       struct fb_info *info = root_pmagbafb_dev;
+       struct pmagbafb_par *par = info->par;
 
-int __init pmagbafb_init(void)
+       unregister_framebuffer(info);
+       iounmap(info->screen_base);
+       iounmap(par->mmio);
+       fb_dealloc_cmap(&info->cmap);
+       root_pmagbafb_dev = par->next;
+       release_tc_card(par->slot);
+       framebuffer_release(info);
+}
+
+
+/*
+ * Initialise the framebuffer.
+ */
+static int __init pmagbafb_init(void)
 {
-       int sid;
-       int found = 0;
+       int count = 0;
+       int slot;
 
        if (fb_get_options("pmagbafb", NULL))
-               return -ENODEV;
-
-       if (TURBOCHANNEL) {
-               while ((sid = search_tc_card("PMAG-BA")) >= 0) {
-                       found = 1;
-                       claim_tc_card(sid);
-                       pmagbafb_init_one(sid);
-               }
-               return found ? 0 : -ENODEV;
-       } else {
-               return -ENODEV;
+               return -ENXIO;
+
+       while ((slot = search_tc_card("PMAG-BA")) >= 0) {
+               if (pmagbafb_init_one(slot) < 0)
+                       break;
+               count++;
        }
+       return (count > 0) ? 0 : -ENXIO;
 }
 
+static void __exit pmagbafb_exit(void)
+{
+       while (root_pmagbafb_dev)
+               pmagbafb_exit_one();
+}
+
+
 module_init(pmagbafb_init);
+module_exit(pmagbafb_exit);
+
 MODULE_LICENSE("GPL");
index d14eaee91cfffd63d9ddd171e4f466a4a4d5640e..a483b13e117b71f93eab7b0e042075b481adf547 100644 (file)
 /*
- *      linux/drivers/video/pmagb-b-fb.c
+ *     linux/drivers/video/pmagb-b-fb.c
  *
- *     PMAGB-B TurboChannel framebuffer card support ... derived from:
+ *     PMAGB-B TURBOchannel Smart Frame Buffer (SFB) card support,
+ *     derived from:
  *     "HP300 Topcat framebuffer support (derived from macfb of all things)
  *     Phil Blundell <philb@gnu.org> 1998", the original code can be
- *      found in the file hpfb.c in the same directory.
+ *     found in the file hpfb.c in the same directory.
  *
- *      DECstation related code Copyright (C) 1999, 2000, 2001 by
- *      Michael Engel <engel@unix-ag.org>,
- *      Karsten Merker <merker@linuxtag.org> and 
+ *     DECstation related code Copyright (C) 1999, 2000, 2001 by
+ *     Michael Engel <engel@unix-ag.org>,
+ *     Karsten Merker <merker@linuxtag.org> and
  *     Harald Koerfgen.
- *      This file is subject to the terms and conditions of the GNU General
- *      Public License.  See the file COPYING in the main directory of this
- *      archive for more details.
+ *     Copyright (c) 2005  Maciej W. Rozycki
  *
+ *     This file is subject to the terms and conditions of the GNU General
+ *     Public License.  See the file COPYING in the main directory of this
+ *     archive for more details.
  */
 
-/*
- *      We currently only support the PMAGB-B in high resolution mode
- *      as I know of no way to detect low resolution mode set via jumper.
- *      KM, 2001/01/07
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/timer.h>
-#include <linux/mm.h>
-#include <linux/tty.h>
-#include <linux/slab.h>
+#include <linux/compiler.h>
 #include <linux/delay.h>
-#include <linux/init.h>
+#include <linux/errno.h>
 #include <linux/fb.h>
-#include <asm/bootinfo.h>
-#include <asm/dec/machtype.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/types.h>
+
+#include <asm/bug.h>
+#include <asm/io.h>
+#include <asm/system.h>
+
 #include <asm/dec/tc.h>
+
 #include <video/pmagb-b-fb.h>
 
-struct pmagb_b_ramdac_regs {
-       unsigned char addr_low;
-       unsigned char pad0[3];
-       unsigned char addr_hi;
-       unsigned char pad1[3];
-       unsigned char data;
-       unsigned char pad2[3];
-       unsigned char cmap;
+
+struct pmagbbfb_par {
+       struct fb_info *next;
+       volatile void __iomem *mmio;
+       volatile void __iomem *smem;
+       volatile u32 __iomem *sfb;
+       volatile u32 __iomem *dac;
+       unsigned int osc0;
+       unsigned int osc1;
+       int slot;
 };
 
-/*
- * Max 3 TURBOchannel slots -> max 3 PMAGB-B :)
- */
-static struct fb_info pmagbb_fb_info[3];
 
-static struct fb_var_screeninfo pmagbbfb_defined = {
-       .xres           = 1280,
-       .yres           = 1024,
-       .xres_virtual   = 1280,
-       .yres_virtual   = 1024,
+static struct fb_info *root_pmagbbfb_dev;
+
+static struct fb_var_screeninfo pmagbbfb_defined __initdata = {
        .bits_per_pixel = 8,
        .red.length     = 8,
        .green.length   = 8,
        .blue.length    = 8,
        .activate       = FB_ACTIVATE_NOW,
-       .height         = 274,
-       .width          = 195,
+       .height         = -1,
+       .width          = -1,
        .accel_flags    = FB_ACCEL_NONE,
+       .sync           = FB_SYNC_ON_GREEN,
        .vmode          = FB_VMODE_NONINTERLACED,
 };
 
-static struct fb_fix_screeninfo pmagbafb_fix = {
+static struct fb_fix_screeninfo pmagbbfb_fix __initdata = {
        .id             = "PMAGB-BA",
-       .smem_len       = (1280 * 1024),
+       .smem_len       = (2048 * 1024),
        .type           = FB_TYPE_PACKED_PIXELS,
        .visual         = FB_VISUAL_PSEUDOCOLOR,
-       .line_length    = 1280,
+       .mmio_len       = PMAGB_B_FBMEM,
+};
+
+
+static inline void sfb_write(struct pmagbbfb_par *par, unsigned int reg, u32 v)
+{
+       writel(v, par->sfb + reg / 4);
 }
 
-/*
- * Turn hardware cursor off
- */
-void pmagbbfb_erase_cursor(struct pmagb_b_ramdac_regs *bt459_regs)
+static inline u32 sfb_read(struct pmagbbfb_par *par, unsigned int reg)
+{
+       return readl(par->sfb + reg / 4);
+}
+
+static inline void dac_write(struct pmagbbfb_par *par, unsigned int reg, u8 v)
 {
-       bt459_regs->addr_low = 0;
-       bt459_regs->addr_hi = 3;
-       bt459_regs->data = 0;
+       writeb(v, par->dac + reg / 4);
 }
 
+static inline u8 dac_read(struct pmagbbfb_par *par, unsigned int reg)
+{
+       return readb(par->dac + reg / 4);
+}
+
+static inline void gp0_write(struct pmagbbfb_par *par, u32 v)
+{
+       writel(v, par->mmio + PMAGB_B_GP0);
+}
+
+
 /*
- * Set the palette. 
+ * Set the palette.
  */
-static int pmagbbfb_setcolreg(unsigned regno, unsigned red, unsigned green,
-                              unsigned blue, unsigned transp,
-                              struct fb_info *info)
+static int pmagbbfb_setcolreg(unsigned int regno, unsigned int red,
+                             unsigned int green, unsigned int blue,
+                             unsigned int transp, struct fb_info *info)
 {
-       struct pmagb_b_ramdac_regs *bt459_regs = (struct pmagb_b_ramdac_regs *) info->par;
-       
-       if (regno >= info->cmap.len)
-               return 1;
+       struct pmagbbfb_par *par = info->par;
+
+       BUG_ON(regno >= info->cmap.len);
 
        red   >>= 8;    /* The cmap fields are 16 bits    */
-       green >>= 8;    /* wide, but the harware colormap */
+       green >>= 8;    /* wide, but the hardware colormap */
        blue  >>= 8;    /* registers are only 8 bits wide */
 
-       bt459_regs->addr_low = (__u8) regno;
-       bt459_regs->addr_hi = 0;
-       bt459_regs->cmap = red;
-       bt459_regs->cmap = green;
-       bt459_regs->cmap = blue;
+       mb();
+       dac_write(par, BT459_ADDR_LO, regno);
+       dac_write(par, BT459_ADDR_HI, 0x00);
+       wmb();
+       dac_write(par, BT459_CMAP, red);
+       wmb();
+       dac_write(par, BT459_CMAP, green);
+       wmb();
+       dac_write(par, BT459_CMAP, blue);
+
        return 0;
 }
 
@@ -121,62 +135,247 @@ static struct fb_ops pmagbbfb_ops = {
        .fb_cursor      = soft_cursor,
 };
 
-int __init pmagbbfb_init_one(int slot)
+
+/*
+ * Turn the hardware cursor off.
+ */
+static void __init pmagbbfb_erase_cursor(struct fb_info *info)
+{
+       struct pmagbbfb_par *par = info->par;
+
+       mb();
+       dac_write(par, BT459_ADDR_LO, 0x00);
+       dac_write(par, BT459_ADDR_HI, 0x03);
+       wmb();
+       dac_write(par, BT459_DATA, 0x00);
+}
+
+/*
+ * Set up screen parameters.
+ */
+static void __init pmagbbfb_screen_setup(struct fb_info *info)
+{
+       struct pmagbbfb_par *par = info->par;
+
+       info->var.xres = ((sfb_read(par, SFB_REG_VID_HOR) >>
+                          SFB_VID_HOR_PIX_SHIFT) & SFB_VID_HOR_PIX_MASK) * 4;
+       info->var.xres_virtual = info->var.xres;
+       info->var.yres = (sfb_read(par, SFB_REG_VID_VER) >>
+                         SFB_VID_VER_SL_SHIFT) & SFB_VID_VER_SL_MASK;
+       info->var.yres_virtual = info->var.yres;
+       info->var.left_margin = ((sfb_read(par, SFB_REG_VID_HOR) >>
+                                 SFB_VID_HOR_BP_SHIFT) &
+                                SFB_VID_HOR_BP_MASK) * 4;
+       info->var.right_margin = ((sfb_read(par, SFB_REG_VID_HOR) >>
+                                  SFB_VID_HOR_FP_SHIFT) &
+                                 SFB_VID_HOR_FP_MASK) * 4;
+       info->var.upper_margin = (sfb_read(par, SFB_REG_VID_VER) >>
+                                 SFB_VID_VER_BP_SHIFT) & SFB_VID_VER_BP_MASK;
+       info->var.lower_margin = (sfb_read(par, SFB_REG_VID_VER) >>
+                                 SFB_VID_VER_FP_SHIFT) & SFB_VID_VER_FP_MASK;
+       info->var.hsync_len = ((sfb_read(par, SFB_REG_VID_HOR) >>
+                               SFB_VID_HOR_SYN_SHIFT) &
+                              SFB_VID_HOR_SYN_MASK) * 4;
+       info->var.vsync_len = (sfb_read(par, SFB_REG_VID_VER) >>
+                              SFB_VID_VER_SYN_SHIFT) & SFB_VID_VER_SYN_MASK;
+
+       info->fix.line_length = info->var.xres;
+};
+
+/*
+ * Determine oscillator configuration.
+ */
+static void __init pmagbbfb_osc_setup(struct fb_info *info)
 {
-       unsigned long base_addr = get_tc_base_addr(slot);
-       struct fb_info *info = &pmagbb_fb_info[slot];
-
-       printk("PMAGB-BA framebuffer in slot %d\n", slot);
-       /*
-        * Framebuffer display memory base address and friends
-        */
-       pmagbbfb_fix.smem_start = base_addr + PMAGB_B_ONBOARD_FBMEM_OFFSET;
-       info->par = (base_addr + PMAGB_B_BT459_OFFSET); 
-       
-       /*
-        * Configure the Bt459 RAM DAC
-        */
-       pmagbbfb_erase_cursor((struct pmagb_b_ramdac_regs *) info->par);
-
-       /*
-        *      Let there be consoles..
-        */
+       static unsigned int pmagbbfb_freqs[] __initdata = {
+               130808, 119843, 104000, 92980, 74367, 72800,
+               69197, 66000, 65000, 50350, 36000, 32000, 25175
+       };
+       struct pmagbbfb_par *par = info->par;
+       u32 count0 = 8, count1 = 8, counttc = 16 * 256 + 8;
+       u32 freq0, freq1, freqtc = get_tc_speed() / 250;
+       int i, j;
+
+       gp0_write(par, 0);                              /* select Osc0 */
+       for (j = 0; j < 16; j++) {
+               mb();
+               sfb_write(par, SFB_REG_TCCLK_COUNT, 0);
+               mb();
+               for (i = 0; i < 100; i++) {     /* nominally max. 20.5us */
+                       if (sfb_read(par, SFB_REG_TCCLK_COUNT) == 0)
+                               break;
+                       udelay(1);
+               }
+               count0 += sfb_read(par, SFB_REG_VIDCLK_COUNT);
+       }
+
+       gp0_write(par, 1);                              /* select Osc1 */
+       for (j = 0; j < 16; j++) {
+               mb();
+               sfb_write(par, SFB_REG_TCCLK_COUNT, 0);
+
+               for (i = 0; i < 100; i++) {     /* nominally max. 20.5us */
+                       if (sfb_read(par, SFB_REG_TCCLK_COUNT) == 0)
+                               break;
+                       udelay(1);
+               }
+               count1 += sfb_read(par, SFB_REG_VIDCLK_COUNT);
+       }
+
+       freq0 = (freqtc * count0 + counttc / 2) / counttc;
+       par->osc0 = freq0;
+       if (freq0 >= pmagbbfb_freqs[0] - (pmagbbfb_freqs[0] + 32) / 64 &&
+           freq0 <= pmagbbfb_freqs[0] + (pmagbbfb_freqs[0] + 32) / 64)
+               par->osc0 = pmagbbfb_freqs[0];
+
+       freq1 = (par->osc0 * count1 + count0 / 2) / count0;
+       par->osc1 = freq1;
+       for (i = 0; i < sizeof(pmagbbfb_freqs) / sizeof(*pmagbbfb_freqs); i++)
+               if (freq1 >= pmagbbfb_freqs[i] -
+                            (pmagbbfb_freqs[i] + 128) / 256 &&
+                   freq1 <= pmagbbfb_freqs[i] +
+                            (pmagbbfb_freqs[i] + 128) / 256) {
+                       par->osc1 = pmagbbfb_freqs[i];
+                       break;
+               }
+
+       if (par->osc0 - par->osc1 <= (par->osc0 + par->osc1 + 256) / 512 ||
+           par->osc1 - par->osc0 <= (par->osc0 + par->osc1 + 256) / 512)
+               par->osc1 = 0;
+
+       gp0_write(par, par->osc1 != 0);                 /* reselect OscX */
+
+       info->var.pixclock = par->osc1 ?
+                            (1000000000 + par->osc1 / 2) / par->osc1 :
+                            (1000000000 + par->osc0 / 2) / par->osc0;
+};
+
+
+static int __init pmagbbfb_init_one(int slot)
+{
+       char freq0[12], freq1[12];
+       struct fb_info *info;
+       struct pmagbbfb_par *par;
+       unsigned long base_addr;
+       u32 vid_base;
+
+       info = framebuffer_alloc(sizeof(struct pmagbbfb_par), NULL);
+       if (!info)
+               return -ENOMEM;
+
+       par = info->par;
+       par->slot = slot;
+       claim_tc_card(par->slot);
+
+       base_addr = get_tc_base_addr(par->slot);
+
+       par->next = root_pmagbbfb_dev;
+       root_pmagbbfb_dev = info;
+
+       if (fb_alloc_cmap(&info->cmap, 256, 0) < 0)
+               goto err_alloc;
+
        info->fbops = &pmagbbfb_ops;
-       info->var = pmagbbfb_defined;
        info->fix = pmagbbfb_fix;
-       info->screen_base = pmagbbfb_fix.smem_start; 
+       info->var = pmagbbfb_defined;
        info->flags = FBINFO_DEFAULT;
 
-       fb_alloc_cmap(&fb_info.cmap, 256, 0);
+       /* MMIO mapping setup.  */
+       info->fix.mmio_start = base_addr;
+       par->mmio = ioremap_nocache(info->fix.mmio_start, info->fix.mmio_len);
+       if (!par->mmio)
+               goto err_cmap;
+       par->sfb = par->mmio + PMAGB_B_SFB;
+       par->dac = par->mmio + PMAGB_B_BT459;
+
+       /* Frame buffer mapping setup.  */
+       info->fix.smem_start = base_addr + PMAGB_B_FBMEM;
+       par->smem = ioremap_nocache(info->fix.smem_start, info->fix.smem_len);
+       if (!par->smem)
+               goto err_mmio_map;
+       vid_base = sfb_read(par, SFB_REG_VID_BASE);
+       info->screen_base = (void __iomem *)par->smem + vid_base * 0x1000;
+       info->screen_size = info->fix.smem_len - 2 * vid_base * 0x1000;
+
+       pmagbbfb_erase_cursor(info);
+       pmagbbfb_screen_setup(info);
+       pmagbbfb_osc_setup(info);
 
        if (register_framebuffer(info) < 0)
-               return 1;
+               goto err_smem_map;
+
+       snprintf(freq0, sizeof(freq0), "%u.%03uMHz",
+                par->osc0 / 1000, par->osc0 % 1000);
+       snprintf(freq1, sizeof(freq1), "%u.%03uMHz",
+                par->osc1 / 1000, par->osc1 % 1000);
+
+       pr_info("fb%d: %s frame buffer device in slot %d\n",
+               info->node, info->fix.id, par->slot);
+       pr_info("fb%d: Osc0: %s, Osc1: %s, Osc%u selected\n",
+               info->node, freq0, par->osc1 ? freq1 : "disabled",
+               par->osc1 != 0);
+
        return 0;
+
+
+err_smem_map:
+       iounmap(par->smem);
+
+err_mmio_map:
+       iounmap(par->mmio);
+
+err_cmap:
+       fb_dealloc_cmap(&info->cmap);
+
+err_alloc:
+       root_pmagbbfb_dev = par->next;
+       release_tc_card(par->slot);
+       framebuffer_release(info);
+       return -ENXIO;
 }
 
-/* 
- * Initialise the framebuffer
- */
+static void __exit pmagbbfb_exit_one(void)
+{
+       struct fb_info *info = root_pmagbbfb_dev;
+       struct pmagbbfb_par *par = info->par;
+
+       unregister_framebuffer(info);
+       iounmap(par->smem);
+       iounmap(par->mmio);
+       fb_dealloc_cmap(&info->cmap);
+       root_pmagbbfb_dev = par->next;
+       release_tc_card(par->slot);
+       framebuffer_release(info);
+}
 
-int __init pmagbbfb_init(void)
+
+/*
+ * Initialise the framebuffer.
+ */
+static int __init pmagbbfb_init(void)
 {
-       int sid;
-       int found = 0;
+       int count = 0;
+       int slot;
 
        if (fb_get_options("pmagbbfb", NULL))
-               return -ENODEV;
+               return -ENXIO;
 
-       if (TURBOCHANNEL) {
-               while ((sid = search_tc_card("PMAGB-BA")) >= 0) {
-                       found = 1;
-                       claim_tc_card(sid);
-                       pmagbbfb_init_one(sid);
-               }
-               return found ? 0 : -ENODEV;
-       } else {
-               return -ENODEV;
+       while ((slot = search_tc_card("PMAGB-BA")) >= 0) {
+               if (pmagbbfb_init_one(slot) < 0)
+                       break;
+               count++;
        }
+       return (count > 0) ? 0 : -ENXIO;
+}
+
+static void __exit pmagbbfb_exit(void)
+{
+       while (root_pmagbbfb_dev)
+               pmagbbfb_exit_one();
 }
 
+
 module_init(pmagbbfb_init);
+module_exit(pmagbbfb_exit);
+
 MODULE_LICENSE("GPL");
index da1334dfd51d3e4ceb493055846b4aca92e4b700..77151d8e076661d4a44fd92cd9d8737190725987 100644 (file)
@@ -92,14 +92,13 @@ static int riva_gpio_getsda(void* data)
        return val;
 }
 
-#define I2C_ALGO_RIVA   0x0e0000
 static int riva_setup_i2c_bus(struct riva_i2c_chan *chan, const char *name)
 {
        int rc;
 
        strcpy(chan->adapter.name, name);
        chan->adapter.owner             = THIS_MODULE;
-       chan->adapter.id                = I2C_ALGO_RIVA;
+       chan->adapter.id                = I2C_HW_B_RIVA;
        chan->adapter.algo_data         = &chan->algo;
        chan->adapter.dev.parent        = &chan->par->pdev->dev;
        chan->algo.setsda               = riva_gpio_setsda;
index 3848be2b9d2d6e9a30194dd693f368c70d1d1dfa..fa98d91c42eb2cd858b516fdcc384833094672b1 100644 (file)
@@ -655,7 +655,7 @@ bail:
 }
 
 #ifdef CONFIG_PM
-static int s1d13xxxfb_suspend(struct device *dev, u32 state, u32 level)
+static int s1d13xxxfb_suspend(struct device *dev, pm_message_t state, u32 level)
 {
        struct fb_info *info = dev_get_drvdata(dev);
        struct s1d13xxxfb_par *s1dfb = info->par;
index 024a0cecff1563770c8be6b6709cfa5c15ec41d5..847698b5cfe7d3b2c1e518eedc5f910d451db452 100644 (file)
@@ -137,7 +137,6 @@ static int prosavage_gpio_getsda(void* data)
        return (0 != (GET_CR_DATA(chan->ioaddr) & PROSAVAGE_I2C_SDA_IN));
 }
 
-#define I2C_ALGO_SAVAGE   0x0f0000
 static int savage_setup_i2c_bus(struct savagefb_i2c_chan *chan,
                                const char *name)
 {
@@ -147,7 +146,7 @@ static int savage_setup_i2c_bus(struct savagefb_i2c_chan *chan,
        if (add_bus && chan->par) {
                strcpy(chan->adapter.name, name);
                chan->adapter.owner             = THIS_MODULE;
-               chan->adapter.id                = I2C_ALGO_SAVAGE;
+               chan->adapter.id                = I2C_HW_B_SAVAGE;
                chan->adapter.algo_data         = &chan->algo;
                chan->adapter.dev.parent        = &chan->par->pcidev->dev;
                chan->algo.udelay               = 40;
index f4633d1891f121070b68ae5c4cb4f53cf0d76ddc..117ad42f120d9c867599a36bcd0a804045732246 100644 (file)
@@ -2110,7 +2110,6 @@ static int savagefb_suspend (struct pci_dev* dev, pm_message_t state)
        struct savagefb_par *par = (struct savagefb_par *)info->par;
 
        DBG("savagefb_suspend");
-       printk(KERN_DEBUG "state: %u\n", state);
 
        acquire_console_sem();
        fb_set_suspend(info, pci_choose_state(dev, state));
index e54be7058359e0beee537f4f5d21d7544148c687..ed78d24ee4263fcfc2495b7f0efbdd6af561c10d 100644 (file)
@@ -783,28 +783,6 @@ config SYSFS
 
        Designers of embedded systems may wish to say N here to conserve space.
 
-config DEVPTS_FS_XATTR
-       bool "/dev/pts Extended Attributes"
-       depends on UNIX98_PTYS
-       help
-         Extended attributes are name:value pairs associated with inodes by
-         the kernel or by users (see the attr(5) manual page, or visit
-         <http://acl.bestbits.at/> for details).
-
-         If unsure, say N.
-
-config DEVPTS_FS_SECURITY
-       bool "/dev/pts Security Labels"
-       depends on DEVPTS_FS_XATTR
-       help
-         Security labels support alternative access control models
-         implemented by security modules like SELinux.  This option
-         enables an extended attribute handler for file security
-         labels in the /dev/pts filesystem.
-
-         If you are not using a security module that requires using
-         extended attributes for file security labels, say N.
-
 config TMPFS
        bool "Virtual memory file system support (former shm fs)"
        help
@@ -817,27 +795,6 @@ config TMPFS
 
          See <file:Documentation/filesystems/tmpfs.txt> for details.
 
-config TMPFS_XATTR
-       bool "tmpfs Extended Attributes"
-       depends on TMPFS
-       help
-         Extended attributes are name:value pairs associated with inodes by
-         the kernel or by users (see the attr(5) manual page, or visit
-         <http://acl.bestbits.at/> for details).
-
-         If unsure, say N.
-
-config TMPFS_SECURITY
-       bool "tmpfs Security Labels"
-       depends on TMPFS_XATTR
-       help
-         Security labels support alternative access control models
-         implemented by security modules like SELinux.  This option
-         enables an extended attribute handler for file security
-         labels in the tmpfs filesystem.
-         If you are not using a security module that requires using
-         extended attributes for file security labels, say N.
-
 config HUGETLBFS
        bool "HugeTLB file system support"
        depends X86 || IA64 || PPC64 || SPARC64 || SUPERH || X86_64 || BROKEN
index 06d7d4390fe7dd8562e8433ce3a29b2b9ee4e241..4f641abac3c0927f2036f81f3f70106a57a09e22 100644 (file)
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -567,6 +567,10 @@ static void use_mm(struct mm_struct *mm)
        atomic_inc(&mm->mm_count);
        tsk->mm = mm;
        tsk->active_mm = mm;
+       /*
+        * Note that on UML this *requires* PF_BORROWED_MM to be set, otherwise
+        * it won't work. Update it accordingly if you change it here
+        */
        activate_mm(active_mm, mm);
        task_unlock(tsk);
 
index c8998dc668824df41ef382e65af0b76124d41536..7974efa107bce19795f0889da79955416db41adb 100644 (file)
@@ -520,7 +520,7 @@ static int load_flat_file(struct linux_binprm * bprm,
                DBG_FLT("BINFMT_FLAT: ROM mapping of file (we hope)\n");
 
                down_write(&current->mm->mmap_sem);
-               textpos = do_mmap(bprm->file, 0, text_len, PROT_READ|PROT_EXEC, MAP_SHARED, 0);
+               textpos = do_mmap(bprm->file, 0, text_len, PROT_READ|PROT_EXEC, MAP_PRIVATE, 0);
                up_write(&current->mm->mmap_sem);
                if (!textpos  || textpos >= (unsigned long) -4096) {
                        if (!textpos)
index 5800df2e50c8e6b922a7ee7c326dc83b7e209b7b..236696efcbac7b9564ce4d8c9557f6c86226ca3a 100644 (file)
@@ -5,4 +5,3 @@
 obj-$(CONFIG_UNIX98_PTYS)              += devpts.o
 
 devpts-$(CONFIG_UNIX98_PTYS)           := inode.o
-devpts-$(CONFIG_DEVPTS_FS_SECURITY)    += xattr_security.o
index 1571c8d6c2322368ef0a8d57e753a3944c2390cf..f2be44d4491ffcf978e2e12e09484735360e9ebd 100644 (file)
 #include <linux/mount.h>
 #include <linux/tty.h>
 #include <linux/devpts_fs.h>
-#include <linux/xattr.h>
 
 #define DEVPTS_SUPER_MAGIC 0x1cd1
 
-extern struct xattr_handler devpts_xattr_security_handler;
-
-static struct xattr_handler *devpts_xattr_handlers[] = {
-#ifdef CONFIG_DEVPTS_FS_SECURITY
-       &devpts_xattr_security_handler,
-#endif
-       NULL
-};
-
-static struct inode_operations devpts_file_inode_operations = {
-#ifdef CONFIG_DEVPTS_FS_XATTR
-       .setxattr       = generic_setxattr,
-       .getxattr       = generic_getxattr,
-       .listxattr      = generic_listxattr,
-       .removexattr    = generic_removexattr,
-#endif
-};
-
 static struct vfsmount *devpts_mnt;
 static struct dentry *devpts_root;
 
@@ -102,7 +83,6 @@ devpts_fill_super(struct super_block *s, void *data, int silent)
        s->s_blocksize_bits = 10;
        s->s_magic = DEVPTS_SUPER_MAGIC;
        s->s_op = &devpts_sops;
-       s->s_xattr = devpts_xattr_handlers;
        s->s_time_gran = 1;
 
        inode = new_inode(s);
@@ -175,7 +155,6 @@ int devpts_pty_new(struct tty_struct *tty)
        inode->i_gid = config.setgid ? config.gid : current->fsgid;
        inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
        init_special_inode(inode, S_IFCHR|config.mode, device);
-       inode->i_op = &devpts_file_inode_operations;
        inode->u.generic_ip = tty;
 
        dentry = get_node(number);
diff --git a/fs/devpts/xattr_security.c b/fs/devpts/xattr_security.c
deleted file mode 100644 (file)
index 864cb5c..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Security xattr support for devpts.
- *
- * Author: Stephen Smalley <sds@epoch.ncsc.mil>
- * Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-#include <linux/string.h>
-#include <linux/fs.h>
-#include <linux/security.h>
-#include <linux/xattr.h>
-
-static size_t
-devpts_xattr_security_list(struct inode *inode, char *list, size_t list_len,
-                          const char *name, size_t name_len)
-{
-       return security_inode_listsecurity(inode, list, list_len);
-}
-
-static int
-devpts_xattr_security_get(struct inode *inode, const char *name,
-                         void *buffer, size_t size)
-{
-       if (strcmp(name, "") == 0)
-               return -EINVAL;
-       return security_inode_getsecurity(inode, name, buffer, size);
-}
-
-static int
-devpts_xattr_security_set(struct inode *inode, const char *name,
-                         const void *value, size_t size, int flags)
-{
-       if (strcmp(name, "") == 0)
-               return -EINVAL;
-       return security_inode_setsecurity(inode, name, value, size, flags);
-}
-
-struct xattr_handler devpts_xattr_security_handler = {
-       .prefix = XATTR_SECURITY_PREFIX,
-       .list   = devpts_xattr_security_list,
-       .get    = devpts_xattr_security_get,
-       .set    = devpts_xattr_security_set,
-};
index 57ed50fe7f8568be7f4408b292ee36a3d1a8ab4e..954cf893d50c34513c8c7167173a479dc9eb026d 100644 (file)
@@ -93,7 +93,7 @@ nfs4_make_rec_clidname(char *dname, struct xdr_netobj *clname)
 
        dprintk("NFSD: nfs4_make_rec_clidname for %.*s\n",
                        clname->len, clname->data);
-       tfm = crypto_alloc_tfm("md5", 0);
+       tfm = crypto_alloc_tfm("md5", CRYPTO_TFM_REQ_MAY_SLEEP);
        if (tfm == NULL)
                goto out;
        cksum.len = crypto_tfm_alg_digestsize(tfm);
@@ -114,8 +114,7 @@ nfs4_make_rec_clidname(char *dname, struct xdr_netobj *clname)
        kfree(cksum.data);
        status = nfs_ok;
 out:
-       if (tfm)
-               crypto_free_tfm(tfm);
+       crypto_free_tfm(tfm);
        return status;
 }
 
index 491f2d9f89acd93fabb0d0067ee76f329bc14c2b..520978e49e92474f428054785c6c68a1978138a5 100644 (file)
  *  go into icache. We cache the reference to task_struct upon lookup too.
  *  Eventually it should become a filesystem in its own. We don't use the
  *  rest of procfs anymore.
+ *
+ *
+ *  Changelog:
+ *  17-Jan-2005
+ *  Allan Bezerra
+ *  Bruna Moreira <bruna.moreira@indt.org.br>
+ *  Edjard Mota <edjard.mota@indt.org.br>
+ *  Ilias Biris <ilias.biris@indt.org.br>
+ *  Mauricio Lin <mauricio.lin@indt.org.br>
+ *
+ *  Embedded Linux Lab - 10LE Instituto Nokia de Tecnologia - INdT
+ *
+ *  A new process specific entry (smaps) included in /proc. It shows the
+ *  size of rss for each memory area. The maps entry lacks information
+ *  about physical memory size (rss) for each mapped file, i.e.,
+ *  rss information for executables and library files.
+ *  This additional information is useful for any tools that need to know
+ *  about physical memory consumption for a process specific library.
+ *
+ *  Changelog:
+ *  21-Feb-2005
+ *  Embedded Linux Lab - 10LE Instituto Nokia de Tecnologia - INdT
+ *  Pud inclusion in the page table walking.
+ *
+ *  ChangeLog:
+ *  10-Mar-2005
+ *  10LE Instituto Nokia de Tecnologia - INdT:
+ *  A better way to walks through the page table as suggested by Hugh Dickins.
+ *
+ *  Simo Piiroinen <simo.piiroinen@nokia.com>:
+ *  Smaps information related to shared, private, clean and dirty pages.
+ *
+ *  Paul Mundt <paul.mundt@nokia.com>:
+ *  Overall revision about smaps.
  */
 
 #include <asm/uaccess.h>
@@ -65,8 +99,10 @@ enum pid_directory_inos {
        PROC_TGID_STAT,
        PROC_TGID_STATM,
        PROC_TGID_MAPS,
+       PROC_TGID_NUMA_MAPS,
        PROC_TGID_MOUNTS,
        PROC_TGID_WCHAN,
+       PROC_TGID_SMAPS,
 #ifdef CONFIG_SCHEDSTATS
        PROC_TGID_SCHEDSTAT,
 #endif
@@ -102,8 +138,10 @@ enum pid_directory_inos {
        PROC_TID_STAT,
        PROC_TID_STATM,
        PROC_TID_MAPS,
+       PROC_TID_NUMA_MAPS,
        PROC_TID_MOUNTS,
        PROC_TID_WCHAN,
+       PROC_TID_SMAPS,
 #ifdef CONFIG_SCHEDSTATS
        PROC_TID_SCHEDSTAT,
 #endif
@@ -144,6 +182,9 @@ static struct pid_entry tgid_base_stuff[] = {
        E(PROC_TGID_STAT,      "stat",    S_IFREG|S_IRUGO),
        E(PROC_TGID_STATM,     "statm",   S_IFREG|S_IRUGO),
        E(PROC_TGID_MAPS,      "maps",    S_IFREG|S_IRUGO),
+#ifdef CONFIG_NUMA
+       E(PROC_TGID_NUMA_MAPS, "numa_maps", S_IFREG|S_IRUGO),
+#endif
        E(PROC_TGID_MEM,       "mem",     S_IFREG|S_IRUSR|S_IWUSR),
 #ifdef CONFIG_SECCOMP
        E(PROC_TGID_SECCOMP,   "seccomp", S_IFREG|S_IRUSR|S_IWUSR),
@@ -152,6 +193,7 @@ static struct pid_entry tgid_base_stuff[] = {
        E(PROC_TGID_ROOT,      "root",    S_IFLNK|S_IRWXUGO),
        E(PROC_TGID_EXE,       "exe",     S_IFLNK|S_IRWXUGO),
        E(PROC_TGID_MOUNTS,    "mounts",  S_IFREG|S_IRUGO),
+       E(PROC_TGID_SMAPS,     "smaps",   S_IFREG|S_IRUGO),
 #ifdef CONFIG_SECURITY
        E(PROC_TGID_ATTR,      "attr",    S_IFDIR|S_IRUGO|S_IXUGO),
 #endif
@@ -180,6 +222,9 @@ static struct pid_entry tid_base_stuff[] = {
        E(PROC_TID_STAT,       "stat",    S_IFREG|S_IRUGO),
        E(PROC_TID_STATM,      "statm",   S_IFREG|S_IRUGO),
        E(PROC_TID_MAPS,       "maps",    S_IFREG|S_IRUGO),
+#ifdef CONFIG_NUMA
+       E(PROC_TID_NUMA_MAPS,  "numa_maps",    S_IFREG|S_IRUGO),
+#endif
        E(PROC_TID_MEM,        "mem",     S_IFREG|S_IRUSR|S_IWUSR),
 #ifdef CONFIG_SECCOMP
        E(PROC_TID_SECCOMP,    "seccomp", S_IFREG|S_IRUSR|S_IWUSR),
@@ -188,6 +233,7 @@ static struct pid_entry tid_base_stuff[] = {
        E(PROC_TID_ROOT,       "root",    S_IFLNK|S_IRWXUGO),
        E(PROC_TID_EXE,        "exe",     S_IFLNK|S_IRWXUGO),
        E(PROC_TID_MOUNTS,     "mounts",  S_IFREG|S_IRUGO),
+       E(PROC_TID_SMAPS,      "smaps",   S_IFREG|S_IRUGO),
 #ifdef CONFIG_SECURITY
        E(PROC_TID_ATTR,       "attr",    S_IFDIR|S_IRUGO|S_IXUGO),
 #endif
@@ -515,6 +561,46 @@ static struct file_operations proc_maps_operations = {
        .release        = seq_release,
 };
 
+#ifdef CONFIG_NUMA
+extern struct seq_operations proc_pid_numa_maps_op;
+static int numa_maps_open(struct inode *inode, struct file *file)
+{
+       struct task_struct *task = proc_task(inode);
+       int ret = seq_open(file, &proc_pid_numa_maps_op);
+       if (!ret) {
+               struct seq_file *m = file->private_data;
+               m->private = task;
+       }
+       return ret;
+}
+
+static struct file_operations proc_numa_maps_operations = {
+       .open           = numa_maps_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = seq_release,
+};
+#endif
+
+extern struct seq_operations proc_pid_smaps_op;
+static int smaps_open(struct inode *inode, struct file *file)
+{
+       struct task_struct *task = proc_task(inode);
+       int ret = seq_open(file, &proc_pid_smaps_op);
+       if (!ret) {
+               struct seq_file *m = file->private_data;
+               m->private = task;
+       }
+       return ret;
+}
+
+static struct file_operations proc_smaps_operations = {
+       .open           = smaps_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = seq_release,
+};
+
 extern struct seq_operations mounts_op;
 static int mounts_open(struct inode *inode, struct file *file)
 {
@@ -1524,6 +1610,12 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
                case PROC_TGID_MAPS:
                        inode->i_fop = &proc_maps_operations;
                        break;
+#ifdef CONFIG_NUMA
+               case PROC_TID_NUMA_MAPS:
+               case PROC_TGID_NUMA_MAPS:
+                       inode->i_fop = &proc_numa_maps_operations;
+                       break;
+#endif
                case PROC_TID_MEM:
                case PROC_TGID_MEM:
                        inode->i_op = &proc_mem_inode_operations;
@@ -1539,6 +1631,10 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
                case PROC_TGID_MOUNTS:
                        inode->i_fop = &proc_mounts_operations;
                        break;
+               case PROC_TID_SMAPS:
+               case PROC_TGID_SMAPS:
+                       inode->i_fop = &proc_smaps_operations;
+                       break;
 #ifdef CONFIG_SECURITY
                case PROC_TID_ATTR:
                        inode->i_nlink = 2;
index 28b4a0253a92161fff797dcfae5f79585fafd022..c7ef3e48e35bae1433c18a4736979e0949a59009 100644 (file)
@@ -2,8 +2,13 @@
 #include <linux/hugetlb.h>
 #include <linux/mount.h>
 #include <linux/seq_file.h>
+#include <linux/highmem.h>
+#include <linux/pagemap.h>
+#include <linux/mempolicy.h>
+
 #include <asm/elf.h>
 #include <asm/uaccess.h>
+#include <asm/tlbflush.h>
 #include "internal.h"
 
 char *task_mem(struct mm_struct *mm, char *buffer)
@@ -87,49 +92,58 @@ static void pad_len_spaces(struct seq_file *m, int len)
        seq_printf(m, "%*c", len, ' ');
 }
 
-static int show_map(struct seq_file *m, void *v)
+struct mem_size_stats
+{
+       unsigned long resident;
+       unsigned long shared_clean;
+       unsigned long shared_dirty;
+       unsigned long private_clean;
+       unsigned long private_dirty;
+};
+
+static int show_map_internal(struct seq_file *m, void *v, struct mem_size_stats *mss)
 {
        struct task_struct *task = m->private;
-       struct vm_area_struct *map = v;
-       struct mm_struct *mm = map->vm_mm;
-       struct file *file = map->vm_file;
-       int flags = map->vm_flags;
+       struct vm_area_struct *vma = v;
+       struct mm_struct *mm = vma->vm_mm;
+       struct file *file = vma->vm_file;
+       int flags = vma->vm_flags;
        unsigned long ino = 0;
        dev_t dev = 0;
        int len;
 
        if (file) {
-               struct inode *inode = map->vm_file->f_dentry->d_inode;
+               struct inode *inode = vma->vm_file->f_dentry->d_inode;
                dev = inode->i_sb->s_dev;
                ino = inode->i_ino;
        }
 
        seq_printf(m, "%08lx-%08lx %c%c%c%c %08lx %02x:%02x %lu %n",
-                       map->vm_start,
-                       map->vm_end,
+                       vma->vm_start,
+                       vma->vm_end,
                        flags & VM_READ ? 'r' : '-',
                        flags & VM_WRITE ? 'w' : '-',
                        flags & VM_EXEC ? 'x' : '-',
                        flags & VM_MAYSHARE ? 's' : 'p',
-                       map->vm_pgoff << PAGE_SHIFT,
+                       vma->vm_pgoff << PAGE_SHIFT,
                        MAJOR(dev), MINOR(dev), ino, &len);
 
        /*
         * Print the dentry name for named mappings, and a
         * special [heap] marker for the heap:
         */
-       if (map->vm_file) {
+       if (file) {
                pad_len_spaces(m, len);
-               seq_path(m, file->f_vfsmnt, file->f_dentry, "");
+               seq_path(m, file->f_vfsmnt, file->f_dentry, "\n");
        } else {
                if (mm) {
-                       if (map->vm_start <= mm->start_brk &&
-                                               map->vm_end >= mm->brk) {
+                       if (vma->vm_start <= mm->start_brk &&
+                                               vma->vm_end >= mm->brk) {
                                pad_len_spaces(m, len);
                                seq_puts(m, "[heap]");
                        } else {
-                               if (map->vm_start <= mm->start_stack &&
-                                       map->vm_end >= mm->start_stack) {
+                               if (vma->vm_start <= mm->start_stack &&
+                                       vma->vm_end >= mm->start_stack) {
 
                                        pad_len_spaces(m, len);
                                        seq_puts(m, "[stack]");
@@ -141,24 +155,146 @@ static int show_map(struct seq_file *m, void *v)
                }
        }
        seq_putc(m, '\n');
-       if (m->count < m->size)  /* map is copied successfully */
-               m->version = (map != get_gate_vma(task))? map->vm_start: 0;
+
+       if (mss)
+               seq_printf(m,
+                          "Size:          %8lu kB\n"
+                          "Rss:           %8lu kB\n"
+                          "Shared_Clean:  %8lu kB\n"
+                          "Shared_Dirty:  %8lu kB\n"
+                          "Private_Clean: %8lu kB\n"
+                          "Private_Dirty: %8lu kB\n",
+                          (vma->vm_end - vma->vm_start) >> 10,
+                          mss->resident >> 10,
+                          mss->shared_clean  >> 10,
+                          mss->shared_dirty  >> 10,
+                          mss->private_clean >> 10,
+                          mss->private_dirty >> 10);
+
+       if (m->count < m->size)  /* vma is copied successfully */
+               m->version = (vma != get_gate_vma(task))? vma->vm_start: 0;
        return 0;
 }
 
+static int show_map(struct seq_file *m, void *v)
+{
+       return show_map_internal(m, v, 0);
+}
+
+static void smaps_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
+                               unsigned long addr, unsigned long end,
+                               struct mem_size_stats *mss)
+{
+       pte_t *pte, ptent;
+       unsigned long pfn;
+       struct page *page;
+
+       pte = pte_offset_map(pmd, addr);
+       do {
+               ptent = *pte;
+               if (pte_none(ptent) || !pte_present(ptent))
+                       continue;
+
+               mss->resident += PAGE_SIZE;
+               pfn = pte_pfn(ptent);
+               if (!pfn_valid(pfn))
+                       continue;
+
+               page = pfn_to_page(pfn);
+               if (page_count(page) >= 2) {
+                       if (pte_dirty(ptent))
+                               mss->shared_dirty += PAGE_SIZE;
+                       else
+                               mss->shared_clean += PAGE_SIZE;
+               } else {
+                       if (pte_dirty(ptent))
+                               mss->private_dirty += PAGE_SIZE;
+                       else
+                               mss->private_clean += PAGE_SIZE;
+               }
+       } while (pte++, addr += PAGE_SIZE, addr != end);
+       pte_unmap(pte - 1);
+       cond_resched_lock(&vma->vm_mm->page_table_lock);
+}
+
+static inline void smaps_pmd_range(struct vm_area_struct *vma, pud_t *pud,
+                               unsigned long addr, unsigned long end,
+                               struct mem_size_stats *mss)
+{
+       pmd_t *pmd;
+       unsigned long next;
+
+       pmd = pmd_offset(pud, addr);
+       do {
+               next = pmd_addr_end(addr, end);
+               if (pmd_none_or_clear_bad(pmd))
+                       continue;
+               smaps_pte_range(vma, pmd, addr, next, mss);
+       } while (pmd++, addr = next, addr != end);
+}
+
+static inline void smaps_pud_range(struct vm_area_struct *vma, pgd_t *pgd,
+                               unsigned long addr, unsigned long end,
+                               struct mem_size_stats *mss)
+{
+       pud_t *pud;
+       unsigned long next;
+
+       pud = pud_offset(pgd, addr);
+       do {
+               next = pud_addr_end(addr, end);
+               if (pud_none_or_clear_bad(pud))
+                       continue;
+               smaps_pmd_range(vma, pud, addr, next, mss);
+       } while (pud++, addr = next, addr != end);
+}
+
+static inline void smaps_pgd_range(struct vm_area_struct *vma,
+                               unsigned long addr, unsigned long end,
+                               struct mem_size_stats *mss)
+{
+       pgd_t *pgd;
+       unsigned long next;
+
+       pgd = pgd_offset(vma->vm_mm, addr);
+       do {
+               next = pgd_addr_end(addr, end);
+               if (pgd_none_or_clear_bad(pgd))
+                       continue;
+               smaps_pud_range(vma, pgd, addr, next, mss);
+       } while (pgd++, addr = next, addr != end);
+}
+
+static int show_smap(struct seq_file *m, void *v)
+{
+       struct vm_area_struct *vma = v;
+       struct mm_struct *mm = vma->vm_mm;
+       struct mem_size_stats mss;
+
+       memset(&mss, 0, sizeof mss);
+
+       if (mm) {
+               spin_lock(&mm->page_table_lock);
+               smaps_pgd_range(vma, vma->vm_start, vma->vm_end, &mss);
+               spin_unlock(&mm->page_table_lock);
+       }
+
+       return show_map_internal(m, v, &mss);
+}
+
 static void *m_start(struct seq_file *m, loff_t *pos)
 {
        struct task_struct *task = m->private;
        unsigned long last_addr = m->version;
        struct mm_struct *mm;
-       struct vm_area_struct *map, *tail_map;
+       struct vm_area_struct *vma, *tail_vma;
        loff_t l = *pos;
 
        /*
         * We remember last_addr rather than next_addr to hit with
         * mmap_cache most of the time. We have zero last_addr at
-        * the begining and also after lseek. We will have -1 last_addr
-        * after the end of the maps.
+        * the beginning and also after lseek. We will have -1 last_addr
+        * after the end of the vmas.
         */
 
        if (last_addr == -1UL)
@@ -168,47 +304,47 @@ static void *m_start(struct seq_file *m, loff_t *pos)
        if (!mm)
                return NULL;
 
-       tail_map = get_gate_vma(task);
+       tail_vma = get_gate_vma(task);
        down_read(&mm->mmap_sem);
 
        /* Start with last addr hint */
-       if (last_addr && (map = find_vma(mm, last_addr))) {
-               map = map->vm_next;
+       if (last_addr && (vma = find_vma(mm, last_addr))) {
+               vma = vma->vm_next;
                goto out;
        }
 
        /*
-        * Check the map index is within the range and do
+        * Check the vma index is within the range and do
         * sequential scan until m_index.
         */
-       map = NULL;
+       vma = NULL;
        if ((unsigned long)l < mm->map_count) {
-               map = mm->mmap;
-               while (l-- && map)
-                       map = map->vm_next;
+               vma = mm->mmap;
+               while (l-- && vma)
+                       vma = vma->vm_next;
                goto out;
        }
 
        if (l != mm->map_count)
-               tail_map = NULL; /* After gate map */
+               tail_vma = NULL; /* After gate vma */
 
 out:
-       if (map)
-               return map;
+       if (vma)
+               return vma;
 
-       /* End of maps has reached */
-       m->version = (tail_map != NULL)? 0: -1UL;
+       /* End of vmas has been reached */
+       m->version = (tail_vma != NULL)? 0: -1UL;
        up_read(&mm->mmap_sem);
        mmput(mm);
-       return tail_map;
+       return tail_vma;
 }
 
 static void m_stop(struct seq_file *m, void *v)
 {
        struct task_struct *task = m->private;
-       struct vm_area_struct *map = v;
-       if (map && map != get_gate_vma(task)) {
-               struct mm_struct *mm = map->vm_mm;
+       struct vm_area_struct *vma = v;
+       if (vma && vma != get_gate_vma(task)) {
+               struct mm_struct *mm = vma->vm_mm;
                up_read(&mm->mmap_sem);
                mmput(mm);
        }
@@ -217,14 +353,14 @@ static void m_stop(struct seq_file *m, void *v)
 static void *m_next(struct seq_file *m, void *v, loff_t *pos)
 {
        struct task_struct *task = m->private;
-       struct vm_area_struct *map = v;
-       struct vm_area_struct *tail_map = get_gate_vma(task);
+       struct vm_area_struct *vma = v;
+       struct vm_area_struct *tail_vma = get_gate_vma(task);
 
        (*pos)++;
-       if (map && (map != tail_map) && map->vm_next)
-               return map->vm_next;
+       if (vma && (vma != tail_vma) && vma->vm_next)
+               return vma->vm_next;
        m_stop(m, v);
-       return (map != tail_map)? tail_map: NULL;
+       return (vma != tail_vma)? tail_vma: NULL;
 }
 
 struct seq_operations proc_pid_maps_op = {
@@ -233,3 +369,140 @@ struct seq_operations proc_pid_maps_op = {
        .stop   = m_stop,
        .show   = show_map
 };
+
+struct seq_operations proc_pid_smaps_op = {
+       .start  = m_start,
+       .next   = m_next,
+       .stop   = m_stop,
+       .show   = show_smap
+};
+
+#ifdef CONFIG_NUMA
+
+struct numa_maps {
+       unsigned long pages;
+       unsigned long anon;
+       unsigned long mapped;
+       unsigned long mapcount_max;
+       unsigned long node[MAX_NUMNODES];
+};
+
+/*
+ * Calculate numa node maps for a vma
+ */
+static struct numa_maps *get_numa_maps(const struct vm_area_struct *vma)
+{
+       struct page *page;
+       unsigned long vaddr;
+       struct mm_struct *mm = vma->vm_mm;
+       int i;
+       struct numa_maps *md = kmalloc(sizeof(struct numa_maps), GFP_KERNEL);
+
+       if (!md)
+               return NULL;
+       md->pages = 0;
+       md->anon = 0;
+       md->mapped = 0;
+       md->mapcount_max = 0;
+       for_each_node(i)
+               md->node[i] =0;
+
+       spin_lock(&mm->page_table_lock);
+       for (vaddr = vma->vm_start; vaddr < vma->vm_end; vaddr += PAGE_SIZE) {
+               page = follow_page(mm, vaddr, 0);
+               if (page) {
+                       int count = page_mapcount(page);
+
+                       if (count)
+                               md->mapped++;
+                       if (count > md->mapcount_max)
+                               md->mapcount_max = count;
+                       md->pages++;
+                       if (PageAnon(page))
+                               md->anon++;
+                       md->node[page_to_nid(page)]++;
+               }
+       }
+       spin_unlock(&mm->page_table_lock);
+       return md;
+}
+
+static int show_numa_map(struct seq_file *m, void *v)
+{
+       struct task_struct *task = m->private;
+       struct vm_area_struct *vma = v;
+       struct mempolicy *pol;
+       struct numa_maps *md;
+       struct zone **z;
+       int n;
+       int first;
+
+       if (!vma->vm_mm)
+               return 0;
+
+       md = get_numa_maps(vma);
+       if (!md)
+               return 0;
+
+       seq_printf(m, "%08lx", vma->vm_start);
+       pol = get_vma_policy(task, vma, vma->vm_start);
+       /* Print policy */
+       switch (pol->policy) {
+       case MPOL_PREFERRED:
+               seq_printf(m, " prefer=%d", pol->v.preferred_node);
+               break;
+       case MPOL_BIND:
+               seq_printf(m, " bind={");
+               first = 1;
+               for (z = pol->v.zonelist->zones; *z; z++) {
+
+                       if (!first)
+                               seq_putc(m, ',');
+                       else
+                               first = 0;
+                       seq_printf(m, "%d/%s", (*z)->zone_pgdat->node_id,
+                                       (*z)->name);
+               }
+               seq_putc(m, '}');
+               break;
+       case MPOL_INTERLEAVE:
+               seq_printf(m, " interleave={");
+               first = 1;
+               for_each_node(n) {
+                       if (test_bit(n, pol->v.nodes)) {
+                               if (!first)
+                                       seq_putc(m,',');
+                               else
+                                       first = 0;
+                               seq_printf(m, "%d",n);
+                       }
+               }
+               seq_putc(m, '}');
+               break;
+       default:
+               seq_printf(m," default");
+               break;
+       }
+       seq_printf(m, " MaxRef=%lu Pages=%lu Mapped=%lu",
+                       md->mapcount_max, md->pages, md->mapped);
+       if (md->anon)
+               seq_printf(m," Anon=%lu",md->anon);
+
+       for_each_online_node(n) {
+               if (md->node[n])
+                       seq_printf(m, " N%d=%lu", n, md->node[n]);
+       }
+       seq_putc(m, '\n');
+       kfree(md);
+       if (m->count < m->size)  /* vma is copied successfully */
+               m->version = (vma != get_gate_vma(task)) ? vma->vm_start : 0;
+       return 0;
+}
+
+struct seq_operations proc_pid_numa_maps_op = {
+       .start  = m_start,
+       .next   = m_next,
+       .stop   = m_stop,
+       .show   = show_numa_map
+};
+#endif
index 6acd5c63da9113613132492dea834d8304554fd8..dc8bc7624f26be341900d900340cb0e7bcb6ce60 100644 (file)
@@ -51,20 +51,29 @@ setxattr(struct dentry *d, char __user *name, void __user *value,
                }
        }
 
+       down(&d->d_inode->i_sem);
+       error = security_inode_setxattr(d, kname, kvalue, size, flags);
+       if (error)
+               goto out;
        error = -EOPNOTSUPP;
        if (d->d_inode->i_op && d->d_inode->i_op->setxattr) {
-               down(&d->d_inode->i_sem);
-               error = security_inode_setxattr(d, kname, kvalue, size, flags);
-               if (error)
-                       goto out;
-               error = d->d_inode->i_op->setxattr(d, kname, kvalue, size, flags);
+               error = d->d_inode->i_op->setxattr(d, kname, kvalue,
+                                                  size, flags);
                if (!error) {
                        fsnotify_xattr(d);
-                       security_inode_post_setxattr(d, kname, kvalue, size, flags);
+                       security_inode_post_setxattr(d, kname, kvalue,
+                                                    size, flags);
                }
-out:
-               up(&d->d_inode->i_sem);
+       } else if (!strncmp(kname, XATTR_SECURITY_PREFIX,
+                           sizeof XATTR_SECURITY_PREFIX - 1)) {
+               const char *suffix = kname + sizeof XATTR_SECURITY_PREFIX - 1;
+               error = security_inode_setsecurity(d->d_inode, suffix, kvalue,
+                                                  size, flags);
+               if (!error)
+                       fsnotify_xattr(d);
        }
+out:
+       up(&d->d_inode->i_sem);
        if (kvalue)
                kfree(kvalue);
        return error;
@@ -139,20 +148,25 @@ getxattr(struct dentry *d, char __user *name, void __user *value, size_t size)
                        return -ENOMEM;
        }
 
+       error = security_inode_getxattr(d, kname);
+       if (error)
+               goto out;
        error = -EOPNOTSUPP;
-       if (d->d_inode->i_op && d->d_inode->i_op->getxattr) {
-               error = security_inode_getxattr(d, kname);
-               if (error)
-                       goto out;
+       if (d->d_inode->i_op && d->d_inode->i_op->getxattr)
                error = d->d_inode->i_op->getxattr(d, kname, kvalue, size);
-               if (error > 0) {
-                       if (size && copy_to_user(value, kvalue, error))
-                               error = -EFAULT;
-               } else if (error == -ERANGE && size >= XATTR_SIZE_MAX) {
-                       /* The file system tried to returned a value bigger
-                          than XATTR_SIZE_MAX bytes. Not possible. */
-                       error = -E2BIG;
-               }
+       else if (!strncmp(kname, XATTR_SECURITY_PREFIX,
+                         sizeof XATTR_SECURITY_PREFIX - 1)) {
+               const char *suffix = kname + sizeof XATTR_SECURITY_PREFIX - 1;
+               error = security_inode_getsecurity(d->d_inode, suffix, kvalue,
+                                                  size);
+       }
+       if (error > 0) {
+               if (size && copy_to_user(value, kvalue, error))
+                       error = -EFAULT;
+       } else if (error == -ERANGE && size >= XATTR_SIZE_MAX) {
+               /* The file system tried to returned a value bigger
+                  than XATTR_SIZE_MAX bytes. Not possible. */
+               error = -E2BIG;
        }
 out:
        if (kvalue)
@@ -221,20 +235,24 @@ listxattr(struct dentry *d, char __user *list, size_t size)
                        return -ENOMEM;
        }
 
+       error = security_inode_listxattr(d);
+       if (error)
+               goto out;
        error = -EOPNOTSUPP;
        if (d->d_inode->i_op && d->d_inode->i_op->listxattr) {
-               error = security_inode_listxattr(d);
-               if (error)
-                       goto out;
                error = d->d_inode->i_op->listxattr(d, klist, size);
-               if (error > 0) {
-                       if (size && copy_to_user(list, klist, error))
-                               error = -EFAULT;
-               } else if (error == -ERANGE && size >= XATTR_LIST_MAX) {
-                       /* The file system tried to returned a list bigger
-                          than XATTR_LIST_MAX bytes. Not possible. */
-                       error = -E2BIG;
-               }
+       } else {
+               error = security_inode_listsecurity(d->d_inode, klist, size);
+               if (size && error >= size)
+                       error = -ERANGE;
+       }
+       if (error > 0) {
+               if (size && copy_to_user(list, klist, error))
+                       error = -EFAULT;
+       } else if (error == -ERANGE && size >= XATTR_LIST_MAX) {
+               /* The file system tried to returned a list bigger
+                  than XATTR_LIST_MAX bytes. Not possible. */
+               error = -E2BIG;
        }
 out:
        if (klist)
index 0577daffc720f8b2cbf63df0bdff9845d12e495a..fa0b41b164a76f04aa52481a10ac0b83d0884026 100644 (file)
@@ -63,20 +63,6 @@ typedef unsigned long pgprot_t;
 
 #endif /* STRICT_MM_TYPECHECKS */
 
-/* Pure 2^n version of get_order */
-extern __inline__ int get_order(unsigned long size)
-{
-       int order;
-
-       size = (size-1) >> (PAGE_SHIFT-1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-       return order;
-}
-
 #ifdef USE_48_BIT_KSEG
 #define PAGE_OFFSET            0xffff800000000000UL
 #else
@@ -112,4 +98,6 @@ extern __inline__ int get_order(unsigned long size)
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _ALPHA_PAGE_H */
index 43264d21924656fdc5b623367d83c7eccf105090..f5716139ec8987216d954858dfe6229ecd542488 100644 (file)
@@ -56,8 +56,6 @@ typedef unsigned long u64;
 typedef u64 dma_addr_t;
 typedef u64 dma64_addr_t;
 
-typedef unsigned short kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 #endif /* __KERNEL__ */
 #endif /* _ALPHA_TYPES_H */
index 7495026e2c18bd5c8fd9daa5c237f39e046c2867..e350dcb544e82a2dc94034a35807f8d850347991 100644 (file)
@@ -383,39 +383,45 @@ __ixp4xx_insl(u32 io_addr, u32 *vaddr, u32 count)
                *vaddr++ = inl(io_addr);
 }
 
-#define        __is_io_address(p)      (((unsigned long)p >= 0x0) && \
-                                       ((unsigned long)p <= 0x0000ffff))
+#define PIO_OFFSET      0x10000UL
+#define PIO_MASK        0x0ffffUL
+
+#define        __is_io_address(p)      (((unsigned long)p >= PIO_OFFSET) && \
+                                       ((unsigned long)p <= (PIO_MASK + PIO_OFFSET)))
 static inline unsigned int
-__ixp4xx_ioread8(void __iomem *port)
+__ixp4xx_ioread8(void __iomem *addr)
 {
+       unsigned long port = (unsigned long __force)addr;
        if (__is_io_address(port))
-               return  (unsigned int)__ixp4xx_inb((unsigned int)port);
+               return  (unsigned int)__ixp4xx_inb(port & PIO_MASK);
        else
 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
-               return (unsigned int)__raw_readb((u32)port);
+               return (unsigned int)__raw_readb(port);
 #else
-               return (unsigned int)__ixp4xx_readb((u32)port);
+               return (unsigned int)__ixp4xx_readb(port);
 #endif
 }
 
 static inline void
-__ixp4xx_ioread8_rep(u32 port, u8 *vaddr, u32 count)
+__ixp4xx_ioread8_rep(void __iomem *addr, void *vaddr, u32 count)
 {
+       unsigned long port = (unsigned long __force)addr;
        if (__is_io_address(port))
-               __ixp4xx_insb(port, vaddr, count);
+               __ixp4xx_insb(port & PIO_MASK, vaddr, count);
        else
 #ifndef        CONFIG_IXP4XX_INDIRECT_PCI
-               __raw_readsb((void __iomem *)port, vaddr, count);
+               __raw_readsb(addr, vaddr, count);
 #else
                __ixp4xx_readsb(port, vaddr, count);
 #endif
 }
 
 static inline unsigned int
-__ixp4xx_ioread16(void __iomem *port)
+__ixp4xx_ioread16(void __iomem *addr)
 {
+       unsigned long port = (unsigned long __force)addr;
        if (__is_io_address(port))
-               return  (unsigned int)__ixp4xx_inw((unsigned int)port);
+               return  (unsigned int)__ixp4xx_inw(port & PIO_MASK);
        else
 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
                return le16_to_cpu(__raw_readw((u32)port));
@@ -425,23 +431,25 @@ __ixp4xx_ioread16(void __iomem *port)
 }
 
 static inline void
-__ixp4xx_ioread16_rep(u32 port, u16 *vaddr, u32 count)
+__ixp4xx_ioread16_rep(void __iomem *addr, void *vaddr, u32 count)
 {
+       unsigned long port = (unsigned long __force)addr;
        if (__is_io_address(port))
-               __ixp4xx_insw(port, vaddr, count);
+               __ixp4xx_insw(port & PIO_MASK, vaddr, count);
        else
 #ifndef        CONFIG_IXP4XX_INDIRECT_PCI
-               __raw_readsw((void __iomem *)port, vaddr, count);
+               __raw_readsw(addr, vaddr, count);
 #else
                __ixp4xx_readsw(port, vaddr, count);
 #endif
 }
 
 static inline unsigned int
-__ixp4xx_ioread32(void __iomem *port)
+__ixp4xx_ioread32(void __iomem *addr)
 {
+       unsigned long port = (unsigned long __force)addr;
        if (__is_io_address(port))
-               return  (unsigned int)__ixp4xx_inl((unsigned int)port);
+               return  (unsigned int)__ixp4xx_inl(port & PIO_MASK);
        else {
 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
                return le32_to_cpu(__raw_readl((u32)port));
@@ -452,90 +460,100 @@ __ixp4xx_ioread32(void __iomem *port)
 }
 
 static inline void
-__ixp4xx_ioread32_rep(u32 port, u32 *vaddr, u32 count)
+__ixp4xx_ioread32_rep(void __iomem *addr, void *vaddr, u32 count)
 {
+       unsigned long port = (unsigned long __force)addr;
        if (__is_io_address(port))
-               __ixp4xx_insl(port, vaddr, count);
+               __ixp4xx_insl(port & PIO_MASK, vaddr, count);
        else
 #ifndef        CONFIG_IXP4XX_INDIRECT_PCI
-               __raw_readsl((void __iomem *)port, vaddr, count);
+               __raw_readsl(addr, vaddr, count);
 #else
                __ixp4xx_readsl(port, vaddr, count);
 #endif
 }
 
 static inline void
-__ixp4xx_iowrite8(u8 value, void __iomem *port)
+__ixp4xx_iowrite8(u8 value, void __iomem *addr)
 {
+       unsigned long port = (unsigned long __force)addr;
        if (__is_io_address(port))
-               __ixp4xx_outb(value, (unsigned int)port);
+               __ixp4xx_outb(value, port & PIO_MASK);
        else
 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
-               __raw_writeb(value, (u32)port);
+               __raw_writeb(value, port);
 #else
-               __ixp4xx_writeb(value, (u32)port);
+               __ixp4xx_writeb(value, port);
 #endif
 }
 
 static inline void
-__ixp4xx_iowrite8_rep(u32 port, u8 *vaddr, u32 count)
+__ixp4xx_iowrite8_rep(void __iomem *addr, const void *vaddr, u32 count)
 {
+       unsigned long port = (unsigned long __force)addr;
        if (__is_io_address(port))
-               __ixp4xx_outsb(port, vaddr, count);
+               __ixp4xx_outsb(port & PIO_MASK, vaddr, count);
+       else
 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
-               __raw_writesb((void __iomem *)port, vaddr, count);
+               __raw_writesb(addr, vaddr, count);
 #else
                __ixp4xx_writesb(port, vaddr, count);
 #endif
 }
 
 static inline void
-__ixp4xx_iowrite16(u16 value, void __iomem *port)
+__ixp4xx_iowrite16(u16 value, void __iomem *addr)
 {
+       unsigned long port = (unsigned long __force)addr;
        if (__is_io_address(port))
-               __ixp4xx_outw(value, (unsigned int)port);
+               __ixp4xx_outw(value, port & PIO_MASK);
        else
 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
-               __raw_writew(cpu_to_le16(value), (u32)port);
+               __raw_writew(cpu_to_le16(value), addr);
 #else
-               __ixp4xx_writew(value, (u32)port);
+               __ixp4xx_writew(value, port);
 #endif
 }
 
 static inline void
-__ixp4xx_iowrite16_rep(u32 port, u16 *vaddr, u32 count)
+__ixp4xx_iowrite16_rep(void __iomem *addr, const void *vaddr, u32 count)
 {
+       unsigned long port = (unsigned long __force)addr;
        if (__is_io_address(port))
-               __ixp4xx_outsw(port, vaddr, count);
+               __ixp4xx_outsw(port & PIO_MASK, vaddr, count);
+       else
 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
-               __raw_readsw((void __iomem *)port, vaddr, count);
+               __raw_writesw(addr, vaddr, count);
 #else
                __ixp4xx_writesw(port, vaddr, count);
 #endif
 }
 
 static inline void
-__ixp4xx_iowrite32(u32 value, void __iomem *port)
+__ixp4xx_iowrite32(u32 value, void __iomem *addr)
 {
+       unsigned long port = (unsigned long __force)addr;
        if (__is_io_address(port))
-               __ixp4xx_outl(value, (unsigned int)port);
+               __ixp4xx_outl(value, port & PIO_MASK);
        else
 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
-               __raw_writel(cpu_to_le32(value), (u32)port);
+               __raw_writel(cpu_to_le32(value), port);
 #else
-               __ixp4xx_writel(value, (u32)port);
+               __ixp4xx_writel(value, port);
 #endif
 }
 
 static inline void
-__ixp4xx_iowrite32_rep(u32 port, u32 *vaddr, u32 count)
+__ixp4xx_iowrite32_rep(void __iomem *addr, const void *vaddr, u32 count)
 {
+       unsigned long port = (unsigned long __force)addr;
        if (__is_io_address(port))
-               __ixp4xx_outsl(port, vaddr, count);
+               __ixp4xx_outsl(port & PIO_MASK, vaddr, count);
+       else
 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
-               __raw_readsl((void __iomem *)port, vaddr, count);
+               __raw_writesl(addr, vaddr, count);
 #else
-               __ixp4xx_outsl(port, vaddr, count);
+               __ixp4xx_writesl(port, vaddr, count);
 #endif
 }
 
@@ -555,7 +573,7 @@ __ixp4xx_iowrite32_rep(u32 port, u32 *vaddr, u32 count)
 #define        iowrite16_rep(p, v, c)          __ixp4xx_iowrite16_rep(p, v, c)
 #define        iowrite32_rep(p, v, c)          __ixp4xx_iowrite32_rep(p, v, c)
 
-#define        ioport_map(port, nr)            ((void __iomem*)port)
+#define        ioport_map(port, nr)            ((void __iomem*)(port + PIO_OFFSET))
 #define        ioport_unmap(addr)
 
 #endif //  __ASM_ARM_ARCH_IO_H
index 3a626c03ea2665915df82795616edc06606843ea..d13ee7f78c70a93b6528b06874971fdf4961cb49 100644 (file)
@@ -83,17 +83,6 @@ extern struct pci_bus *ixp4xx_scan_bus(int nr, struct pci_sys_data *sys);
 #define IXP4XX_GPIO_OUT                0x1
 #define IXP4XX_GPIO_IN                 0x2
 
-#define IXP4XX_GPIO_INTSTYLE_MASK      0x7C  /* Bits [6:2] define interrupt style */
-
-/* 
- * GPIO interrupt types.
- */
-#define IXP4XX_GPIO_ACTIVE_HIGH                0x4 /* Default */
-#define IXP4XX_GPIO_ACTIVE_LOW         0x8
-#define IXP4XX_GPIO_RISING_EDGE                0x10
-#define IXP4XX_GPIO_FALLING_EDGE       0x20
-#define IXP4XX_GPIO_TRANSITIONAL       0x40
-
 /* GPIO signal types */
 #define IXP4XX_GPIO_LOW                        0
 #define IXP4XX_GPIO_HIGH               1
@@ -102,7 +91,13 @@ extern struct pci_bus *ixp4xx_scan_bus(int nr, struct pci_sys_data *sys);
 #define IXP4XX_GPIO_CLK_0              14
 #define IXP4XX_GPIO_CLK_1              15
 
-extern void gpio_line_config(u8 line, u32 style);
+static inline void gpio_line_config(u8 line, u32 direction)
+{
+       if (direction == IXP4XX_GPIO_OUT)
+               *IXP4XX_GPIO_GPOER |= (1 << line);
+       else
+               *IXP4XX_GPIO_GPOER &= ~(1 << line);
+}
 
 static inline void gpio_line_get(u8 line, int *value)
 {
index 51f0fe0ac165bb4a6ee64f69faeaa2576994fce8..939d9e5020a0915f5c7ac7e5a50c49533187904f 100644 (file)
 #define UDCOTGICR_IEIDF        (1 << 0)        /* OTG ID Change Falling Edge
                                           Interrupt Enable */
 
+#define UP2OCR           __REG(0x40600020)  /* USB Port 2 Output Control register */
+
+#define UP2OCR_CPVEN   (1 << 0)        /* Charge Pump Vbus Enable */
+#define UP2OCR_CPVPE   (1 << 1)        /* Charge Pump Vbus Pulse Enable */
+#define UP2OCR_DPPDE   (1 << 2)        /* Host Port 2 Transceiver D+ Pull Down Enable */
+#define UP2OCR_DMPDE   (1 << 3)        /* Host Port 2 Transceiver D- Pull Down Enable */
+#define UP2OCR_DPPUE   (1 << 4)        /* Host Port 2 Transceiver D+ Pull Up Enable */
+#define UP2OCR_DMPUE   (1 << 5)        /* Host Port 2 Transceiver D- Pull Up Enable */
+#define UP2OCR_DPPUBE  (1 << 6)        /* Host Port 2 Transceiver D+ Pull Up Bypass Enable */
+#define UP2OCR_DMPUBE  (1 << 7)        /* Host Port 2 Transceiver D- Pull Up Bypass Enable */
+#define UP2OCR_EXSP            (1 << 8)        /* External Transceiver Speed Control */
+#define UP2OCR_EXSUS   (1 << 9)        /* External Transceiver Speed Enable */
+#define UP2OCR_IDON            (1 << 10)       /* OTG ID Read Enable */
+#define UP2OCR_HXS             (1 << 16)       /* Host Port 2 Transceiver Output Select */
+#define UP2OCR_HXOE            (1 << 17)       /* Host Port 2 Transceiver Output Enable */
+#define UP2OCR_SEOS            (1 << 24)       /* Single-Ended Output Select */
+
 #define UDCCSN(x)      __REG2(0x40600100, (x) << 2)
 #define UDCCSR0         __REG(0x40600100) /* UDC Control/Status register - Endpoint 0 */
 #define UDCCSR0_SA     (1 << 7)        /* Setup Active */
 #define GPIO84_NSSP_RX         (84 | GPIO_ALT_FN_2_IN)
 #define GPIO85_nPCE_1_MD       (85 | GPIO_ALT_FN_1_OUT)
 #define GPIO92_MMCDAT0_MD      (92 | GPIO_ALT_FN_1_OUT)
+#define GPIO104_pSKTSEL_MD     (104 | GPIO_ALT_FN_1_OUT)
 #define GPIO109_MMCDAT1_MD     (109 | GPIO_ALT_FN_1_OUT)
 #define GPIO110_MMCDAT2_MD     (110 | GPIO_ALT_FN_1_OUT)
 #define GPIO110_MMCCS0_MD      (110 | GPIO_ALT_FN_1_OUT)
 #define PSSR_BFS       (1 << 1)        /* Battery Fault Status */
 #define PSSR_SSS       (1 << 0)        /* Software Sleep Status */
 
+#define PSLR_SL_ROD    (1 << 20)       /* Sleep-Mode/Depp-Sleep Mode nRESET_OUT Disable */
+
 #define PCFR_RO                (1 << 15)       /* RDH Override */
 #define PCFR_PO                (1 << 14)       /* PH Override */
 #define PCFR_GPROD     (1 << 12)       /* GPIO nRESET_OUT Disable */
 #define PCFR_FVC       (1 << 10)       /* Frequency/Voltage Change */
 #define PCFR_DC_EN     (1 << 7)        /* Sleep/deep-sleep DC-DC Converter Enable */
 #define PCFR_PI2CEN    (1 << 6)        /* Enable PI2C controller */
+#define PCFR_GPR_EN    (1 << 4)        /* nRESET_GPIO Pin Enable */
 #define PCFR_DS                (1 << 3)        /* Deep Sleep Mode */
 #define PCFR_FS                (1 << 2)        /* Float Static Chip Selects */
 #define PCFR_FP                (1 << 1)        /* Float PCMCIA controls */
 #define LCCR0_PDD_S    12
 #define LCCR0_BM       (1 << 20)       /* Branch mask */
 #define LCCR0_OUM      (1 << 21)       /* Output FIFO underrun mask */
+#define LCCR0_LCDT      (1 << 22)       /* LCD panel type */
+#define LCCR0_RDSTM     (1 << 23)       /* Read status interrupt mask */
+#define LCCR0_CMDIM     (1 << 24)       /* Command interrupt mask */
+#define LCCR0_OUC       (1 << 25)       /* Overlay Underlay control bit */
+#define LCCR0_LDDALT    (1 << 26)       /* LDD alternate mapping control */
 
 #define LCCR1_PPL       Fld (10, 0)      /* Pixels Per Line - 1 */
 #define LCCR1_DisWdth(Pixel)            /* Display Width [1..800 pix.]  */ \
 #define UHCFMN         __REG(0x4C00003C) /* UHC Frame Number */
 #define UHCPERS                __REG(0x4C000040) /* UHC Periodic Start */
 #define UHCLS          __REG(0x4C000044) /* UHC Low Speed Threshold */
+
 #define UHCRHDA                __REG(0x4C000048) /* UHC Root Hub Descriptor A */
+#define UHCRHDA_NOCP   (1 << 12)       /* No over current protection */
+
 #define UHCRHDB                __REG(0x4C00004C) /* UHC Root Hub Descriptor B */
 #define UHCRHS         __REG(0x4C000050) /* UHC Root Hub Status */
 #define UHCRHPS1       __REG(0x4C000054) /* UHC Root Hub Port 1 Status */
index e5e938b79accf555747e88008d86d17a50d056d9..16f4c3cc1388bd70ce8bfe9a93b16d34a5b5dabf 100644 (file)
@@ -1,7 +1,7 @@
 /* linux/include/asm/arch-s3c2410/regs-clock.h
  *
- * Copyright (c) 2003,2004 Simtec Electronics <linux@simtec.co.uk>
- *                   http://www.simtec.co.uk/products/SWLINUX/
+ * Copyright (c) 2003,2004,2005 Simtec Electronics <linux@simtec.co.uk>
+ *                   http://armlinux.simtec.co.uk/
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -17,6 +17,7 @@
  *    29-Sep-2004 Ben Dooks        Fixed usage for assembly inclusion
  *    10-Feb-2005 Ben Dooks        Fixed CAMDIVN address (Guillaume Gourat)
  *    10-Mar-2005 Lucas Villa Real  Changed S3C2410_VA to S3C24XX_VA
+ *    27-Aug-2005 Ben Dooks        Add clock-slow info
  */
 
 #ifndef __ASM_ARM_REGS_CLOCK
 #define S3C2410_CLKDIVN_PDIVN       (1<<0)
 #define S3C2410_CLKDIVN_HDIVN       (1<<1)
 
+#define S3C2410_CLKSLOW_UCLK_OFF       (1<<7)
+#define S3C2410_CLKSLOW_MPLL_OFF       (1<<5)
+#define S3C2410_CLKSLOW_SLOW           (1<<4)
+#define S3C2410_CLKSLOW_SLOWVAL(x)     (x)
+#define S3C2410_CLKSLOW_GET_SLOWVAL(x) ((x) & 7)
+
 #ifndef __ASSEMBLY__
 
 static inline unsigned int
index 7ea771ff61449457677f276baf5c5ce1bbe24521..527404b5a8df4fab7843dc0ab2c8e8372a5cf5ed 100644 (file)
@@ -40,6 +40,19 @@ struct scoop_config {
        unsigned short io_dir;
 };
 
+/* Structure for linking scoop devices to PCMCIA sockets */
+struct scoop_pcmcia_dev {
+       struct device *dev;     /* Pointer to this socket's scoop device */
+       int     irq;                /* irq for socket */
+       int cd_irq;
+       const char *cd_irq_str;
+       unsigned char keep_vs;
+       unsigned char keep_rd;
+};
+
+extern int scoop_num;
+extern struct scoop_pcmcia_dev *scoop_devs;
+
 void reset_scoop(struct device *dev);
 unsigned short set_scoop_gpio(struct device *dev, unsigned short bit);
 unsigned short reset_scoop_gpio(struct device *dev, unsigned short bit);
index a43a353f6c7bd701c7e6570692ffb575e89e833f..0ce6ca588d8c0b89b43a765d35b294cf0cdad9f4 100644 (file)
@@ -42,11 +42,11 @@ struct irqchip {
        /*
         * Set the type of the IRQ.
         */
-       int (*type)(unsigned int, unsigned int);
+       int (*set_type)(unsigned int, unsigned int);
        /*
         * Set wakeup-enable on the selected IRQ
         */
-       int (*wake)(unsigned int, unsigned int);
+       int (*set_wake)(unsigned int, unsigned int);
 
 #ifdef CONFIG_SMP
        /*
@@ -91,6 +91,14 @@ struct irqdesc {
 
 extern struct irqdesc irq_desc[];
 
+/*
+ * Helpful inline function for calling irq descriptor handlers.
+ */
+static inline void desc_handle_irq(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
+{
+       desc->handle(irq, desc, regs);
+}
+
 /*
  * This is internal.  Do not use it.
  */
index 2cf279a4401773e009cb163ecb32ea1cb477ecad..96c6db7dd0e1928e25b96e9b0e87fb64c7f113ce 100644 (file)
@@ -47,9 +47,7 @@ struct sys_timer {
 
 #ifdef CONFIG_NO_IDLE_HZ
 
-#define DYN_TICK_SKIPPING      (1 << 2)
 #define DYN_TICK_ENABLED       (1 << 1)
-#define DYN_TICK_SUITABLE      (1 << 0)
 
 struct dyn_tick_timer {
        unsigned int    state;                  /* Current state */
index 019c45d7573053a9af19088f2df4af8cb4c5e95a..4da1d532cbebd751ecba5ead32ba866ca8f9f7db 100644 (file)
@@ -163,20 +163,6 @@ typedef unsigned long pgprot_t;
 /* the upper-most page table pointer */
 extern pmd_t *top_pmd;
 
-/* Pure 2^n version of get_order */
-static inline int get_order(unsigned long size)
-{
-       int order;
-
-       size = (size-1) >> (PAGE_SHIFT-1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-       return order;
-}
-
 #include <asm/memory.h>
 
 #endif /* !__ASSEMBLY__ */
@@ -186,4 +172,6 @@ static inline int get_order(unsigned long size)
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif
index f4c92e4c8c0219a31b69f8d59367c105d5767fef..22992ee0627ac3fb5c87bfa4c297184b8bfd1628 100644 (file)
@@ -52,8 +52,6 @@ typedef unsigned long long u64;
 typedef u32 dma_addr_t;
 typedef u32 dma64_addr_t;
 
-typedef unsigned int kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
index abb36e54c966b4cbed6c1b8f7fef60a60ab5e81b..278de61224d1c82ca667ebee87f62a536bc06986 100644 (file)
 #define __NR_fstatfs64                 (__NR_SYSCALL_BASE+267)
 #define __NR_tgkill                    (__NR_SYSCALL_BASE+268)
 #define __NR_utimes                    (__NR_SYSCALL_BASE+269)
-#define __NR_fadvise64_64              (__NR_SYSCALL_BASE+270)
+#define __NR_arm_fadvise64_64          (__NR_SYSCALL_BASE+270)
 #define __NR_pciconfig_iobase          (__NR_SYSCALL_BASE+271)
 #define __NR_pciconfig_read            (__NR_SYSCALL_BASE+272)
 #define __NR_pciconfig_write           (__NR_SYSCALL_BASE+273)
@@ -515,7 +515,6 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6
 #define __ARCH_WANT_SYS_TIME
 #define __ARCH_WANT_SYS_UTIME
 #define __ARCH_WANT_SYS_SOCKETCALL
-#define __ARCH_WANT_SYS_FADVISE64
 #define __ARCH_WANT_SYS_GETPGRP
 #define __ARCH_WANT_SYS_LLSEEK
 #define __ARCH_WANT_SYS_NICE
index c334079b082b267e12998da8151e84f4aa1003ed..d3f23ac4d468fc748c3f366dbd383b2196ace705 100644 (file)
@@ -89,20 +89,6 @@ typedef unsigned long pgprot_t;
 #ifdef __KERNEL__
 #ifndef __ASSEMBLY__
 
-/* Pure 2^n version of get_order */
-static inline int get_order(unsigned long size)
-{
-       int order;
-
-       size = (size-1) >> (PAGE_SHIFT-1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-       return order;
-}
-
 #include <asm/memory.h>
 
 #endif /* !__ASSEMBLY__ */
@@ -112,4 +98,6 @@ static inline int get_order(unsigned long size)
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif
index 56cbe573a2349e8aac93d334def241763a9cd5cb..81bd357ada02b931a04f93c9405e139b64d4cde9 100644 (file)
@@ -52,8 +52,6 @@ typedef unsigned long long u64;
 typedef u32 dma_addr_t;
 typedef u32 dma64_addr_t;
 
-typedef unsigned int kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
index bbf17bd3938523c81e178a5aec94cbfe424a771a..c99c478c482f77d4568206a15952435b11e0d887 100644 (file)
@@ -70,19 +70,6 @@ typedef struct { unsigned long pgprot; } pgprot_t;
 
 #ifndef __ASSEMBLY__
 
-/* Pure 2^n version of get_order */
-static inline int get_order(unsigned long size)
-{
-       int order;
-
-       size = (size-1) >> (PAGE_SHIFT-1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-       return order;
-}
 #endif /* __ASSEMBLY__ */
 
 #define VM_DATA_DEFAULT_FLAGS  (VM_READ | VM_WRITE | VM_EXEC | \
@@ -90,5 +77,7 @@ static inline int get_order(unsigned long size)
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _CRIS_PAGE_H */
 
index 8fa6d6c7afce5f19de6c0bac4abbffd0f4bdd646..84557c9bac93e4ef7993eae2c0576644a601719b 100644 (file)
@@ -52,8 +52,6 @@ typedef unsigned long long u64;
 typedef u32 dma_addr_t;
 typedef u32 dma64_addr_t;
 
-typedef unsigned short kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
index f7914f1782b0329b2d70cd6c8d172d1f2282d224..4feba567e7fd7bd47601f3199285ba15e7ed9815 100644 (file)
@@ -45,21 +45,6 @@ typedef struct { unsigned long       pgprot; } pgprot_t;
 /* to align the pointer to the (next) page boundary */
 #define PAGE_ALIGN(addr)       (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
 
-/* Pure 2^n version of get_order */
-static inline int get_order(unsigned long size) __attribute_const__;
-static inline int get_order(unsigned long size)
-{
-       int order;
-
-       size = (size - 1) >> (PAGE_SHIFT - 1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-       return order;
-}
-
 #define devmem_is_allowed(pfn) 1
 
 #define __pa(vaddr)            virt_to_phys((void *) vaddr)
@@ -102,4 +87,6 @@ extern unsigned long max_pfn;
 #define WANT_PAGE_VIRTUAL      1
 #endif
 
+#include <asm-generic/page.h>
+
 #endif /* _ASM_PAGE_H */
index 1a5b6546bb411fe404f22a0af1337e7faa7d0632..50605df6d8acbc024adcba5f4c7aabe1ac57ca14 100644 (file)
@@ -65,8 +65,6 @@ typedef u64 u_quad_t;
 
 typedef u32 dma_addr_t;
 
-typedef unsigned short kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff --git a/include/asm-generic/page.h b/include/asm-generic/page.h
new file mode 100644 (file)
index 0000000..a96b5d9
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef _ASM_GENERIC_PAGE_H
+#define _ASM_GENERIC_PAGE_H
+
+#ifdef __KERNEL__
+#ifndef __ASSEMBLY__
+
+#include <linux/compiler.h>
+
+/* Pure 2^n version of get_order */
+static __inline__ __attribute_const__ int get_order(unsigned long size)
+{
+       int order;
+
+       size = (size - 1) >> (PAGE_SHIFT - 1);
+       order = -1;
+       do {
+               size >>= 1;
+               order++;
+       } while (size);
+       return order;
+}
+
+#endif /* __ASSEMBLY__ */
+#endif /* __KERNEL__ */
+
+#endif /* _ASM_GENERIC_PAGE_H */
index f40593565173939c5755adda6bee419d90a24635..f86c1e549466a0809c02fecc750cb5627ed08027 100644 (file)
@@ -101,6 +101,22 @@ do {                                                                         \
 })
 #endif
 
+#ifndef __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL
+#define ptep_get_and_clear_full(__mm, __address, __ptep, __full)       \
+({                                                                     \
+       pte_t __pte;                                                    \
+       __pte = ptep_get_and_clear((__mm), (__address), (__ptep));      \
+       __pte;                                                          \
+})
+#endif
+
+#ifndef __HAVE_ARCH_PTE_CLEAR_FULL
+#define pte_clear_full(__mm, __address, __ptep, __full)                        \
+do {                                                                   \
+       pte_clear((__mm), (__address), (__ptep));                       \
+} while (0)
+#endif
+
 #ifndef __HAVE_ARCH_PTEP_CLEAR_FLUSH
 #define ptep_clear_flush(__vma, __address, __ptep)                     \
 ({                                                                     \
index b3bb326ae5b618a74cc3ca79d158f6d8b92c5743..3fa94288aa9329473e7eda8d7f8d5893dd5c99ba 100644 (file)
@@ -6,6 +6,9 @@
 #define VMLINUX_SYMBOL(_sym_) _sym_
 #endif
 
+/* Align . to a 8 byte boundary equals to maximum function alignment. */
+#define ALIGN_FUNCTION()  . = ALIGN(8)
+
 #define RODATA                                                         \
        .rodata           : AT(ADDR(.rodata) - LOAD_OFFSET) {           \
                *(.rodata) *(.rodata.*)                                 \
                VMLINUX_SYMBOL(__security_initcall_end) = .;            \
        }
 
+/* sched.text is aling to function alignment to secure we have same
+ * address even at second ld pass when generating System.map */
 #define SCHED_TEXT                                                     \
+               ALIGN_FUNCTION();                                       \
                VMLINUX_SYMBOL(__sched_text_start) = .;                 \
                *(.sched.text)                                          \
                VMLINUX_SYMBOL(__sched_text_end) = .;
 
+/* spinlock.text is aling to function alignment to secure we have same
+ * address even at second ld pass when generating System.map */
 #define LOCK_TEXT                                                      \
+               ALIGN_FUNCTION();                                       \
                VMLINUX_SYMBOL(__lock_text_start) = .;                  \
                *(.spinlock.text)                                       \
                VMLINUX_SYMBOL(__lock_text_end) = .;
index e3b7960d445bcbb02cdf5901d429d99d9bcfd25d..e8c02b8c2d99bb2d138ca200008bf5467d105fd1 100644 (file)
@@ -54,20 +54,6 @@ typedef struct { unsigned long pgprot; } pgprot_t;
 /* to align the pointer to the (next) page boundary */
 #define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
 
-/* Pure 2^n version of get_order */
-extern __inline__ int get_order(unsigned long size)
-{
-       int order;
-
-       size = (size-1) >> (PAGE_SHIFT-1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-       return order;
-}
-
 extern unsigned long memory_start;
 extern unsigned long memory_end;
 
@@ -101,4 +87,6 @@ extern unsigned long memory_end;
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _H8300_PAGE_H */
index 21f4fc07ac0e45ae6fa9c07ce671887fdaf52eb6..bf91e0d4dde77775a46650f29f107096c2914147 100644 (file)
@@ -58,8 +58,6 @@ typedef u32 dma_addr_t;
 #define HAVE_SECTOR_T
 typedef u64 sector_t;
 
-typedef unsigned int kmem_bufctl_t;
-
 #endif /* __KERNEL__ */
 
 #endif /* __ASSEMBLY__ */
index b82f5f3ab887b4307fa2e248c2122bdfe8d32bfc..9075083bab76bd2ed3cd26daaaaa63887dbf5255 100644 (file)
@@ -19,7 +19,7 @@ int unmap_page_from_agp(struct page *page);
 /* Could use CLFLUSH here if the cpu supports it. But then it would
    need to be called for each cacheline of the whole page so it may not be 
    worth it. Would need a page for it. */
-#define flush_agp_cache() asm volatile("wbinvd":::"memory")
+#define flush_agp_cache() wbinvd()
 
 /* Convert a physical address to an address suitable for the GART. */
 #define phys_to_gart(x) (x)
index a96a8f48fbfcea171f9a65a22cc0f1b2a022649d..03185cef8e0a3977de51cb2467943d59f31dabd6 100644 (file)
@@ -16,6 +16,7 @@
 #define                        GET_APIC_VERSION(x)     ((x)&0xFF)
 #define                        GET_APIC_MAXLVT(x)      (((x)>>16)&0xFF)
 #define                        APIC_INTEGRATED(x)      ((x)&0xF0)
+#define                        APIC_XAPIC(x)           ((x) >= 0x14)
 #define                APIC_TASKPRI    0x80
 #define                        APIC_TPRI_MASK          0xFF
 #define                APIC_ARBPRI     0x90
index 6789fc275da36cc3f5da7da3efc03609662f7bdb..ea54540638d211f2bb99fc4693e603a664b48dad 100644 (file)
@@ -118,7 +118,10 @@ static void __init check_hlt(void)
                printk("disabled\n");
                return;
        }
-       __asm__ __volatile__("hlt ; hlt ; hlt ; hlt");
+       halt();
+       halt();
+       halt();
+       halt();
        printk("OK.\n");
 }
 
index 11e67811a9901b5c6b31ef361dfb6d03667c3ca3..6df1a53c190e48716c46e1c4deabdd5020930950 100644 (file)
@@ -27,8 +27,18 @@ struct Xgt_desc_struct {
 
 extern struct Xgt_desc_struct idt_descr, cpu_gdt_descr[NR_CPUS];
 
-#define load_TR_desc() __asm__ __volatile__("ltr %%ax"::"a" (GDT_ENTRY_TSS*8))
-#define load_LDT_desc() __asm__ __volatile__("lldt %%ax"::"a" (GDT_ENTRY_LDT*8))
+#define load_TR_desc() __asm__ __volatile__("ltr %w0"::"q" (GDT_ENTRY_TSS*8))
+#define load_LDT_desc() __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8))
+
+#define load_gdt(dtr) __asm__ __volatile("lgdt %0"::"m" (*dtr))
+#define load_idt(dtr) __asm__ __volatile("lidt %0"::"m" (*dtr))
+#define load_tr(tr) __asm__ __volatile("ltr %0"::"mr" (tr))
+#define load_ldt(ldt) __asm__ __volatile("lldt %0"::"mr" (ldt))
+
+#define store_gdt(dtr) __asm__ ("sgdt %0":"=m" (*dtr))
+#define store_idt(dtr) __asm__ ("sidt %0":"=m" (*dtr))
+#define store_tr(tr) __asm__ ("str %0":"=mr" (tr))
+#define store_ldt(ldt) __asm__ ("sldt %0":"=mr" (ldt))
 
 /*
  * This is the ldt that every process will get unless we need
@@ -39,14 +49,14 @@ extern void set_intr_gate(unsigned int irq, void * addr);
 
 #define _set_tssldt_desc(n,addr,limit,type) \
 __asm__ __volatile__ ("movw %w3,0(%2)\n\t" \
-       "movw %%ax,2(%2)\n\t" \
-       "rorl $16,%%eax\n\t" \
-       "movb %%al,4(%2)\n\t" \
+       "movw %w1,2(%2)\n\t" \
+       "rorl $16,%1\n\t" \
+       "movb %b1,4(%2)\n\t" \
        "movb %4,5(%2)\n\t" \
        "movb $0,6(%2)\n\t" \
-       "movb %%ah,7(%2)\n\t" \
-       "rorl $16,%%eax" \
-       : "=m"(*(n)) : "a" (addr), "r"(n), "ir"(limit), "i"(type))
+       "movb %h1,7(%2)\n\t" \
+       "rorl $16,%1" \
+       : "=m"(*(n)) : "q" (addr), "r"(n), "ir"(limit), "i"(type))
 
 static inline void __set_tss_desc(unsigned int cpu, unsigned int entry, void *addr)
 {
@@ -86,6 +96,13 @@ static inline void set_ldt_desc(unsigned int cpu, void *addr, unsigned int size)
        (info)->seg_not_present == 1    && \
        (info)->useable         == 0    )
 
+static inline void write_ldt_entry(void *ldt, int entry, __u32 entry_a, __u32 entry_b)
+{
+       __u32 *lp = (__u32 *)((char *)ldt + entry*8);
+       *lp = entry_a;
+       *(lp+1) = entry_b;
+}
+
 #if TLS_SIZE != 24
 # error update this code.
 #endif
index b3f8d5f59d5d8fc02cc1c5f88bce01921c641496..316138e89910743f3a1b265ca4f04741bdffdc98 100644 (file)
@@ -41,9 +41,16 @@ enum die_val {
        DIE_PAGE_FAULT,
 };
 
-static inline int notify_die(enum die_val val,char *str,struct pt_regs *regs,long err,int trap, int sig)
+static inline int notify_die(enum die_val val, const char *str,
+                       struct pt_regs *regs, long err, int trap, int sig)
 {
-       struct die_args args = { .regs=regs, .str=str, .err=err, .trapnr=trap,.signr=sig };
+       struct die_args args = {
+               .regs = regs,
+               .str = str,
+               .err = err,
+               .trapnr = trap,
+               .signr = sig
+       };
        return notifier_call_chain(&i386die_chain, val, &args);
 }
 
index 85809e0898d7d3cf93f9ae414cd091bc5097f5e8..28a84f6185a789834bdf753dc4e17e1bba8636c8 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __ASM_MACH_MPPARSE_H
 #define __ASM_MACH_MPPARSE_H
 
+#include <linux/acpi.h>
+
 static inline void mpc_oem_bus_info(struct mpc_config_bus *m, char *name, 
                                struct mpc_config_translation *translation)
 {
@@ -12,8 +14,9 @@ static inline void mpc_oem_pci_bus(struct mpc_config_bus *m,
 {
 }
 
-extern int parse_unisys_oem (char *oemptr, int oem_entries);
-extern int find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length);
+extern int parse_unisys_oem (char *oemptr);
+extern int find_unisys_acpi_oem_table(unsigned long *oem_addr);
+extern void setup_unisys();
 
 static inline int mps_oem_check(struct mp_config_table *mpc, char *oem,
                char *productid)
@@ -22,18 +25,33 @@ static inline int mps_oem_check(struct mp_config_table *mpc, char *oem,
                struct mp_config_oemtable *oem_table = 
                        (struct mp_config_oemtable *)mpc->mpc_oemptr;
                if (!strncmp(oem, "UNISYS", 6))
-                       return parse_unisys_oem((char *)oem_table, oem_table->oem_length);
+                       return parse_unisys_oem((char *)oem_table);
        }
        return 0;
 }
 
+static inline int es7000_check_dsdt()
+{
+       struct acpi_table_header *header = NULL;
+       if(!acpi_get_table_header_early(ACPI_DSDT, &header))
+               acpi_table_print(header, 0);
+       if (!strncmp(header->oem_id, "UNISYS", 6))
+               return 1;
+       return 0;
+}
+
 /* Hook from generic ACPI tables.c */
 static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id)
 {
        unsigned long oem_addr; 
-       int oem_entries;
-       if (!find_unisys_acpi_oem_table(&oem_addr, &oem_entries))
-               return parse_unisys_oem((char *)oem_addr, oem_entries);
+       if (!find_unisys_acpi_oem_table(&oem_addr)) {
+               if (es7000_check_dsdt())
+                       return parse_unisys_oem((char *)oem_addr);
+               else {
+                       setup_unisys();
+                       return 1;
+               }
+       }
        return 0;
 }
 
index b13767a4e9345211eaa68a5c1439ee59f82e6cdc..d9dc039da94a3a12b4902d477bb48c0e6d8f205e 100644 (file)
@@ -28,4 +28,6 @@
 #define enable_apic_mode (genapic->enable_apic_mode)
 #define phys_pkg_id (genapic->phys_pkg_id)
 
+extern void generic_bigsmp_probe(void);
+
 #endif /* __ASM_MACH_APIC_H */
index d9fafba075bc41852dfeccb90d32a24182da41a5..d84a9c326c2238e70cdc3159d18dd864a481fd01 100644 (file)
@@ -11,6 +11,7 @@ extern int mp_bus_id_to_local [MAX_MP_BUSSES];
 extern int quad_local_to_mp_bus_id [NR_CPUS/4][4];
 extern int mp_bus_id_to_pci_bus [MAX_MP_BUSSES];
 
+extern unsigned int def_to_bigsmp;
 extern unsigned int boot_cpu_physical_apicid;
 extern int smp_found_config;
 extern void find_smp_config (void);
index c76fce8badbbb32333691d293b4c1b172b7f3e58..62b76cd96957da8ddfca0a0d1a1508b373be8ab5 100644 (file)
@@ -47,6 +47,21 @@ static inline void wrmsrl (unsigned long msr, unsigned long long val)
                     : "c" (msr), "0" (a), "d" (b), "i" (-EFAULT));\
        ret__; })
 
+/* rdmsr with exception handling */
+#define rdmsr_safe(msr,a,b) ({ int ret__;                                              \
+       asm volatile("2: rdmsr ; xorl %0,%0\n"                                          \
+                    "1:\n\t"                                                           \
+                    ".section .fixup,\"ax\"\n\t"                                       \
+                    "3:  movl %4,%0 ; jmp 1b\n\t"                                      \
+                    ".previous\n\t"                                                    \
+                    ".section __ex_table,\"a\"\n"                                      \
+                    "   .align 4\n\t"                                                  \
+                    "   .long  2b,3b\n\t"                                              \
+                    ".previous"                                                        \
+                    : "=r" (ret__), "=a" (*(a)), "=d" (*(b))                           \
+                    : "c" (msr), "i" (-EFAULT));\
+       ret__; })
+
 #define rdtsc(low,high) \
      __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
 
index 8d93f732d72d0586dc1598542ffa354893351808..73296d9924fb36ac196937e2d9d63e32f978aa2c 100644 (file)
@@ -68,7 +68,6 @@ typedef struct { unsigned long pgprot; } pgprot_t;
 #define HPAGE_MASK     (~(HPAGE_SIZE - 1))
 #define HUGETLB_PAGE_ORDER     (HPAGE_SHIFT - PAGE_SHIFT)
 #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
-#define ARCH_HAS_HUGETLB_CLEAN_STALE_PGTABLE
 #endif
 
 #define pgd_val(x)     ((x).pgd)
@@ -104,20 +103,6 @@ typedef struct { unsigned long pgprot; } pgprot_t;
  */
 extern unsigned int __VMALLOC_RESERVE;
 
-/* Pure 2^n version of get_order */
-static __inline__ int get_order(unsigned long size)
-{
-       int order;
-
-       size = (size-1) >> (PAGE_SHIFT-1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-       return order;
-}
-
 extern int sysctl_legacy_va_layout;
 
 extern int page_is_ram(unsigned long pagenr);
@@ -156,4 +141,6 @@ extern int page_is_ram(unsigned long pagenr);
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _I386_PAGE_H */
index d609f9c2c1f0324a790df9eef00a30ce53254c79..2e3f4a344a2d61e001f82131592830c3e967d547 100644 (file)
@@ -64,7 +64,7 @@ static inline void set_pte(pte_t *ptep, pte_t pte)
 #define set_pmd(pmdptr,pmdval) \
                set_64bit((unsigned long long *)(pmdptr),pmd_val(pmdval))
 #define set_pud(pudptr,pudval) \
-               set_64bit((unsigned long long *)(pudptr),pud_val(pudval))
+               (*(pudptr) = (pudval))
 
 /*
  * Pentium-II erratum A13: in PAE mode we explicitly have to flush
index 77c6497f416ed07905ea6d9ae847c9b907cdabfd..47bc1ffa3d4cfb42321cec3bf25d9da23ccc8486 100644 (file)
@@ -86,9 +86,7 @@ void paging_init(void);
 #endif
 
 /*
- * The 4MB page is guessing..  Detailed in the infamous "Chapter H"
- * of the Pentium details, but assuming intel did the straightforward
- * thing, this bit set in the page directory entry just means that
+ * _PAGE_PSE set in the page directory entry just means that
  * the page directory entry points directly to a 4MB-aligned block of
  * memory. 
  */
@@ -119,8 +117,10 @@ void paging_init(void);
 #define _PAGE_UNUSED2  0x400
 #define _PAGE_UNUSED3  0x800
 
-#define _PAGE_FILE     0x040   /* set:pagecache unset:swap */
-#define _PAGE_PROTNONE 0x080   /* If not present */
+/* If _PAGE_PRESENT is clear, we use these: */
+#define _PAGE_FILE     0x040   /* nonlinear file mapping, saved PTE; unset:swap */
+#define _PAGE_PROTNONE 0x080   /* if the user mapped it with PROT_NONE;
+                                  pte_present gives true */
 #ifdef CONFIG_X86_PAE
 #define _PAGE_NX       (1ULL<<_PAGE_BIT_NX)
 #else
@@ -215,11 +215,13 @@ extern unsigned long pg0[];
  * The following only work if pte_present() is true.
  * Undefined behaviour if not..
  */
+#define __LARGE_PTE (_PAGE_PSE | _PAGE_PRESENT)
 static inline int pte_user(pte_t pte)          { return (pte).pte_low & _PAGE_USER; }
 static inline int pte_read(pte_t pte)          { return (pte).pte_low & _PAGE_USER; }
 static inline int pte_dirty(pte_t pte)         { return (pte).pte_low & _PAGE_DIRTY; }
 static inline int pte_young(pte_t pte)         { return (pte).pte_low & _PAGE_ACCESSED; }
 static inline int pte_write(pte_t pte)         { return (pte).pte_low & _PAGE_RW; }
+static inline int pte_huge(pte_t pte)          { return ((pte).pte_low & __LARGE_PTE) == __LARGE_PTE; }
 
 /*
  * The following only works if pte_present() is not true.
@@ -236,7 +238,7 @@ static inline pte_t pte_mkexec(pte_t pte)   { (pte).pte_low |= _PAGE_USER; return
 static inline pte_t pte_mkdirty(pte_t pte)     { (pte).pte_low |= _PAGE_DIRTY; return pte; }
 static inline pte_t pte_mkyoung(pte_t pte)     { (pte).pte_low |= _PAGE_ACCESSED; return pte; }
 static inline pte_t pte_mkwrite(pte_t pte)     { (pte).pte_low |= _PAGE_RW; return pte; }
-static inline pte_t pte_mkhuge(pte_t pte)      { (pte).pte_low |= _PAGE_PRESENT | _PAGE_PSE; return pte; }
+static inline pte_t pte_mkhuge(pte_t pte)      { (pte).pte_low |= __LARGE_PTE; return pte; }
 
 #ifdef CONFIG_X86_PAE
 # include <asm/pgtable-3level.h>
@@ -258,11 +260,38 @@ static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned
        return test_and_clear_bit(_PAGE_BIT_ACCESSED, &ptep->pte_low);
 }
 
+static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long addr, pte_t *ptep, int full)
+{
+       pte_t pte;
+       if (full) {
+               pte = *ptep;
+               *ptep = __pte(0);
+       } else {
+               pte = ptep_get_and_clear(mm, addr, ptep);
+       }
+       return pte;
+}
+
 static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
        clear_bit(_PAGE_BIT_RW, &ptep->pte_low);
 }
 
+/*
+ * clone_pgd_range(pgd_t *dst, pgd_t *src, int count);
+ *
+ *  dst - pointer to pgd range anwhere on a pgd page
+ *  src - ""
+ *  count - the number of pgds to copy.
+ *
+ * dst and src can be on the same page, but the range must not overlap,
+ * and must not cross a page boundary.
+ */
+static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
+{
+       memcpy(dst, src, count * sizeof(pgd_t));
+}
+
 /*
  * Macro to mark a page protection value as "uncacheable".  On processors which do not support
  * it, this is a no-op.
@@ -415,6 +444,7 @@ extern void noexec_setup(const char *str);
 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
+#define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL
 #define __HAVE_ARCH_PTEP_SET_WRPROTECT
 #define __HAVE_ARCH_PTE_SAME
 #include <asm-generic/pgtable.h>
index d0d8b0160090427328fc384baed9ab77872ecb88..37bef8ed7bed12bd33bf3670ccf7991516aa7484 100644 (file)
@@ -203,9 +203,7 @@ static inline unsigned int cpuid_edx(unsigned int op)
        return edx;
 }
 
-#define load_cr3(pgdir) \
-       asm volatile("movl %0,%%cr3": :"r" (__pa(pgdir)))
-
+#define load_cr3(pgdir) write_cr3(__pa(pgdir))
 
 /*
  * Intel CPU features in CR4
@@ -232,22 +230,20 @@ extern unsigned long mmu_cr4_features;
 
 static inline void set_in_cr4 (unsigned long mask)
 {
+       unsigned cr4;
        mmu_cr4_features |= mask;
-       __asm__("movl %%cr4,%%eax\n\t"
-               "orl %0,%%eax\n\t"
-               "movl %%eax,%%cr4\n"
-               : : "irg" (mask)
-               :"ax");
+       cr4 = read_cr4();
+       cr4 |= mask;
+       write_cr4(cr4);
 }
 
 static inline void clear_in_cr4 (unsigned long mask)
 {
+       unsigned cr4;
        mmu_cr4_features &= ~mask;
-       __asm__("movl %%cr4,%%eax\n\t"
-               "andl %0,%%eax\n\t"
-               "movl %%eax,%%cr4\n"
-               : : "irg" (~mask)
-               :"ax");
+       cr4 = read_cr4();
+       cr4 &= ~mask;
+       write_cr4(cr4);
 }
 
 /*
@@ -281,6 +277,11 @@ static inline void clear_in_cr4 (unsigned long mask)
        outb((data), 0x23); \
 } while (0)
 
+static inline void serialize_cpu(void)
+{
+        __asm__ __volatile__ ("cpuid" : : : "ax", "bx", "cx", "dx");
+}
+
 static inline void __monitor(const void *eax, unsigned long ecx,
                unsigned long edx)
 {
@@ -454,6 +455,7 @@ struct thread_struct {
        unsigned int            saved_fs, saved_gs;
 /* IO permissions */
        unsigned long   *io_bitmap_ptr;
+       unsigned long   iopl;
 /* max allowed port in the bitmap, in bytes: */
        unsigned long   io_bitmap_max;
 };
@@ -474,7 +476,6 @@ struct thread_struct {
        .esp0           = sizeof(init_stack) + (long)&init_stack,       \
        .ss0            = __KERNEL_DS,                                  \
        .ss1            = __KERNEL_CS,                                  \
-       .ldt            = GDT_ENTRY_LDT,                                \
        .io_bitmap_base = INVALID_IO_BITMAP_OFFSET,                     \
        .io_bitmap      = { [ 0 ... IO_BITMAP_LONGS] = ~0 },            \
 }
@@ -511,6 +512,21 @@ static inline void load_esp0(struct tss_struct *tss, struct thread_struct *threa
                        : /* no output */                       \
                        :"r" (value))
 
+/*
+ * Set IOPL bits in EFLAGS from given mask
+ */
+static inline void set_iopl_mask(unsigned mask)
+{
+       unsigned int reg;
+       __asm__ __volatile__ ("pushfl;"
+                             "popl %0;"
+                             "andl %1, %0;"
+                             "orl %2, %0;"
+                             "pushl %0;"
+                             "popfl"
+                               : "=&r" (reg)
+                               : "i" (~X86_EFLAGS_IOPL), "r" (mask));
+}
 
 /* Forward declaration, a strange C thing */
 struct task_struct;
index 05532875e39e2846a7d757f242617990d039d279..7e0f2945d17d48587dadf5a6b6b5d027b9869b0a 100644 (file)
@@ -61,6 +61,13 @@ struct pt_regs {
 struct task_struct;
 extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code);
 
+/*
+ * user_mode_vm(regs) determines whether a register set came from user mode.
+ * This is true if V8086 mode was enabled OR if the register set was from
+ * protected mode with RPL-3 CS value.  This tricky test checks that with
+ * one comparison.  Many places in the kernel can bypass this full check
+ * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
+ */
 static inline int user_mode(struct pt_regs *regs)
 {
        return (regs->xcs & 3) != 0;
index 7a32184d54bf414522d10976d9a7a7a0b4d47a1b..826a8ca50ac801dd6960e2396d9a55e02e1ba2a4 100644 (file)
@@ -44,7 +44,7 @@ extern unsigned char boot_params[PARAM_SIZE];
 #define EFI_SYSTAB ((efi_system_table_t *) *((unsigned long *)(PARAM+0x1c4)))
 #define EFI_MEMDESC_SIZE (*((unsigned long *) (PARAM+0x1c8)))
 #define EFI_MEMDESC_VERSION (*((unsigned long *) (PARAM+0x1cc)))
-#define EFI_MEMMAP ((efi_memory_desc_t *) *((unsigned long *)(PARAM+0x1d0)))
+#define EFI_MEMMAP ((void *) *((unsigned long *)(PARAM+0x1d0)))
 #define EFI_MEMMAP_SIZE (*((unsigned long *) (PARAM+0x1d4)))
 #define MOUNT_ROOT_RDONLY (*(unsigned short *) (PARAM+0x1F2))
 #define RAMDISK_FLAGS (*(unsigned short *) (PARAM+0x1F8))
index a283738b80b30bbc9defb338b16c4f70971d7ffc..13250199976d581901aeb87d216150d721492e9b 100644 (file)
@@ -59,7 +59,7 @@ extern void cpu_uninit(void);
 
 extern cpumask_t cpu_callout_map;
 extern cpumask_t cpu_callin_map;
-#define cpu_possible_map cpu_callout_map
+extern cpumask_t cpu_possible_map;
 
 /* We don't mark CPUs online until __cpu_up(), so we need another measure */
 static inline int num_booting_cpus(void)
index 3db717a244f0c4df75a06102c522e6cdf19f82b1..acd5c26b69ba68f9a2964b59cdf01b86daab9fda 100644 (file)
@@ -14,8 +14,7 @@ extern struct task_struct * FASTCALL(__switch_to(struct task_struct *prev, struc
 
 #define switch_to(prev,next,last) do {                                 \
        unsigned long esi,edi;                                          \
-       asm volatile("pushfl\n\t"                                       \
-                    "pushl %%ebp\n\t"                                  \
+       asm volatile("pushl %%ebp\n\t"                                  \
                     "movl %%esp,%0\n\t"        /* save ESP */          \
                     "movl %5,%%esp\n\t"        /* restore ESP */       \
                     "movl $1f,%1\n\t"          /* save EIP */          \
@@ -23,7 +22,6 @@ extern struct task_struct * FASTCALL(__switch_to(struct task_struct *prev, struc
                     "jmp __switch_to\n"                                \
                     "1:\t"                                             \
                     "popl %%ebp\n\t"                                   \
-                    "popfl"                                            \
                     :"=m" (prev->thread.esp),"=m" (prev->thread.eip),  \
                      "=a" (last),"=S" (esi),"=D" (edi)                 \
                     :"m" (next->thread.esp),"m" (next->thread.eip),    \
@@ -93,13 +91,13 @@ static inline unsigned long _get_base(char * addr)
                ".align 4\n\t"                  \
                ".long 1b,3b\n"                 \
                ".previous"                     \
-               : :"m" (value))
+               : :"rm" (value))
 
 /*
  * Save a segment register away
  */
 #define savesegment(seg, value) \
-       asm volatile("mov %%" #seg ",%0":"=m" (value))
+       asm volatile("mov %%" #seg ",%0":"=rm" (value))
 
 /*
  * Clear and set 'TS' bit respectively
@@ -107,13 +105,33 @@ static inline unsigned long _get_base(char * addr)
 #define clts() __asm__ __volatile__ ("clts")
 #define read_cr0() ({ \
        unsigned int __dummy; \
-       __asm__( \
+       __asm__ __volatile__( \
                "movl %%cr0,%0\n\t" \
                :"=r" (__dummy)); \
        __dummy; \
 })
 #define write_cr0(x) \
-       __asm__("movl %0,%%cr0": :"r" (x));
+       __asm__ __volatile__("movl %0,%%cr0": :"r" (x));
+
+#define read_cr2() ({ \
+       unsigned int __dummy; \
+       __asm__ __volatile__( \
+               "movl %%cr2,%0\n\t" \
+               :"=r" (__dummy)); \
+       __dummy; \
+})
+#define write_cr2(x) \
+       __asm__ __volatile__("movl %0,%%cr2": :"r" (x));
+
+#define read_cr3() ({ \
+       unsigned int __dummy; \
+       __asm__ ( \
+               "movl %%cr3,%0\n\t" \
+               :"=r" (__dummy)); \
+       __dummy; \
+})
+#define write_cr3(x) \
+       __asm__ __volatile__("movl %0,%%cr3": :"r" (x));
 
 #define read_cr4() ({ \
        unsigned int __dummy; \
@@ -123,7 +141,7 @@ static inline unsigned long _get_base(char * addr)
        __dummy; \
 })
 #define write_cr4(x) \
-       __asm__("movl %0,%%cr4": :"r" (x));
+       __asm__ __volatile__("movl %0,%%cr4": :"r" (x));
 #define stts() write_cr0(8 | read_cr0())
 
 #endif /* __KERNEL__ */
@@ -447,6 +465,8 @@ struct alt_instr {
 #define local_irq_enable()     __asm__ __volatile__("sti": : :"memory")
 /* used in the idle loop; sti takes one instruction cycle to complete */
 #define safe_halt()            __asm__ __volatile__("sti; hlt": : :"memory")
+/* used when interrupts are already enabled or to shutdown the processor */
+#define halt()                 __asm__ __volatile__("hlt": : :"memory")
 
 #define irqs_disabled()                        \
 ({                                     \
index 95add81237eab1342737431cd7c7134d1d2f9985..e2cb9fa6f563db415e494dae49b0173fa3e2b7c6 100644 (file)
@@ -139,6 +139,7 @@ register unsigned long current_stack_pointer asm("esp") __attribute_used__;
 #define TIF_NEED_RESCHED       3       /* rescheduling necessary */
 #define TIF_SINGLESTEP         4       /* restore singlestep on return to user mode */
 #define TIF_IRET               5       /* return with iret */
+#define TIF_SYSCALL_EMU                6       /* syscall emulation active */
 #define TIF_SYSCALL_AUDIT      7       /* syscall auditing active */
 #define TIF_SECCOMP            8       /* secure computing */
 #define TIF_POLLING_NRFLAG     16      /* true if poll_idle() is polling TIF_NEED_RESCHED */
@@ -150,13 +151,15 @@ register unsigned long current_stack_pointer asm("esp") __attribute_used__;
 #define _TIF_NEED_RESCHED      (1<<TIF_NEED_RESCHED)
 #define _TIF_SINGLESTEP                (1<<TIF_SINGLESTEP)
 #define _TIF_IRET              (1<<TIF_IRET)
+#define _TIF_SYSCALL_EMU       (1<<TIF_SYSCALL_EMU)
 #define _TIF_SYSCALL_AUDIT     (1<<TIF_SYSCALL_AUDIT)
 #define _TIF_SECCOMP           (1<<TIF_SECCOMP)
 #define _TIF_POLLING_NRFLAG    (1<<TIF_POLLING_NRFLAG)
 
 /* work to do on interrupt/exception return */
 #define _TIF_WORK_MASK \
-  (0x0000FFFF & ~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP|_TIF_SECCOMP))
+  (0x0000FFFF & ~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP|\
+                 _TIF_SECCOMP|_TIF_SYSCALL_EMU))
 /* work to do on any return to u-space */
 #define _TIF_ALLWORK_MASK      (0x0000FFFF & ~_TIF_SECCOMP)
 
index dcf1e07db08a7802629cfe39fb433fc4e02af68d..aed16437479d91ecf5d2a3b87be996c39573316c 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef _ASMi386_TIMER_H
 #define _ASMi386_TIMER_H
 #include <linux/init.h>
+#include <linux/pm.h>
 
 /**
  * struct timer_ops - used to define a timer source
@@ -23,6 +24,8 @@ struct timer_opts {
        unsigned long long (*monotonic_clock)(void);
        void (*delay)(unsigned long);
        unsigned long (*read_timer)(void);
+       int (*suspend)(pm_message_t state);
+       int (*resume)(void);
 };
 
 struct init_timer_opts {
index 901b77c42b8a70e860c95766641904b6fb5468d5..ced00fe8fe61c0667840795158b234c58fa35ebc 100644 (file)
@@ -63,8 +63,6 @@ typedef u64 sector_t;
 #define HAVE_SECTOR_T
 #endif
 
-typedef unsigned short kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
index f80e2dbe1b56a541fc1be0e37dff529ffb46a08c..23c86cef3b258a8611e765bd168e1c89054a19f6 100644 (file)
@@ -535,14 +535,14 @@ static struct xor_block_template xor_block_p5_mmx = {
 
 #define XMMS_SAVE do {                         \
        preempt_disable();                      \
+       cr0 = read_cr0();                       \
+       clts();                                 \
        __asm__ __volatile__ (                  \
-               "movl %%cr0,%0          ;\n\t"  \
-               "clts                   ;\n\t"  \
-               "movups %%xmm0,(%1)     ;\n\t"  \
-               "movups %%xmm1,0x10(%1) ;\n\t"  \
-               "movups %%xmm2,0x20(%1) ;\n\t"  \
-               "movups %%xmm3,0x30(%1) ;\n\t"  \
-               : "=&r" (cr0)                   \
+               "movups %%xmm0,(%0)     ;\n\t"  \
+               "movups %%xmm1,0x10(%0) ;\n\t"  \
+               "movups %%xmm2,0x20(%0) ;\n\t"  \
+               "movups %%xmm3,0x30(%0) ;\n\t"  \
+               :                               \
                : "r" (xmm_save)                \
                : "memory");                    \
 } while(0)
@@ -550,14 +550,14 @@ static struct xor_block_template xor_block_p5_mmx = {
 #define XMMS_RESTORE do {                      \
        __asm__ __volatile__ (                  \
                "sfence                 ;\n\t"  \
-               "movups (%1),%%xmm0     ;\n\t"  \
-               "movups 0x10(%1),%%xmm1 ;\n\t"  \
-               "movups 0x20(%1),%%xmm2 ;\n\t"  \
-               "movups 0x30(%1),%%xmm3 ;\n\t"  \
-               "movl   %0,%%cr0        ;\n\t"  \
+               "movups (%0),%%xmm0     ;\n\t"  \
+               "movups 0x10(%0),%%xmm1 ;\n\t"  \
+               "movups 0x20(%0),%%xmm2 ;\n\t"  \
+               "movups 0x30(%0),%%xmm3 ;\n\t"  \
                :                               \
-               : "r" (cr0), "r" (xmm_save)     \
+               : "r" (xmm_save)                \
                : "memory");                    \
+       write_cr0(cr0);                         \
        preempt_enable();                       \
 } while(0)
 
index 4c06d455139c776f0cc2f78838dfcbeb2e24d48c..3a544ffc500860f5f1c166e3e2b9bff57e7e11b5 100644 (file)
@@ -116,6 +116,11 @@ extern int __initdata nid_to_pxm_map[MAX_NUMNODES];
 
 extern u16 ia64_acpiid_to_sapicid[];
 
+/*
+ * Refer Intel ACPI _PDC support document for bit definitions
+ */
+#define ACPI_PDC_EST_CAPABILITY_SMP     0x8
+
 #endif /*__KERNEL__*/
 
 #endif /*_ASM_ACPI_H*/
index c9f8d835d0cc0860345312eff324beebdf7becd4..cee16ea1780aa6e9046bd2982ad9694b2188018d 100644 (file)
@@ -81,6 +81,7 @@ struct flock {
 
 #define F_LINUX_SPECIFIC_BASE  1024
 
-#define force_o_largefile() ( ! (current->personality & PER_LINUX32) )
+#define force_o_largefile()    \
+               (personality(current->personality) != PER_LINUX32)
 
 #endif /* _ASM_IA64_FCNTL_H */
index 54e7637a326c4e1ffb6aab9835abab5f384e3be0..cf772a67f858763719a615f03ea8b8d117501973 100644 (file)
@@ -23,7 +23,7 @@
 #define __SLOW_DOWN_IO do { } while (0)
 #define SLOW_DOWN_IO   do { } while (0)
 
-#define __IA64_UNCACHED_OFFSET 0xc000000000000000UL    /* region 6 */
+#define __IA64_UNCACHED_OFFSET RGN_BASE(RGN_UNCACHED)
 
 /*
  * The legacy I/O space defined by the ia64 architecture supports only 65536 ports, but
@@ -41,7 +41,7 @@
 #define IO_SPACE_BASE(space)           ((space) << IO_SPACE_BITS)
 #define IO_SPACE_PORT(port)            ((port) & (IO_SPACE_SIZE - 1))
 
-#define IO_SPACE_SPARSE_ENCODING(p)    ((((p) >> 2) << 12) | (p & 0xfff))
+#define IO_SPACE_SPARSE_ENCODING(p)    ((((p) >> 2) << 12) | ((p) & 0xfff))
 
 struct io_space {
        unsigned long mmio_base;        /* base in MMIO space */
index ae1525352a25fb569c3243e475aafde7e53e81c2..611432ba579c0d91f64c402c2fc115f0ef1fe487 100644 (file)
@@ -2,10 +2,12 @@
 #define __MMU_H
 
 /*
- * Type for a context number.  We declare it volatile to ensure proper ordering when it's
- * accessed outside of spinlock'd critical sections (e.g., as done in activate_mm() and
- * init_new_context()).
+ * Type for a context number.  We declare it volatile to ensure proper
+ * ordering when it's accessed outside of spinlock'd critical sections
+ * (e.g., as done in activate_mm() and init_new_context()).
  */
 typedef volatile unsigned long mm_context_t;
 
+typedef unsigned long nv_mm_context_t;
+
 #endif
index e3e5fededb04c4c63301afd1e309c1f022d749b0..8d6e72f7b08efce6251952c7e69241ce243f8e28 100644 (file)
@@ -19,6 +19,7 @@
 
 #define ia64_rid(ctx,addr)     (((ctx) << 3) | (addr >> 61))
 
+# include <asm/page.h>
 # ifndef __ASSEMBLY__
 
 #include <linux/compiler.h>
@@ -55,34 +56,46 @@ static inline void
 delayed_tlb_flush (void)
 {
        extern void local_flush_tlb_all (void);
+       unsigned long flags;
 
        if (unlikely(__ia64_per_cpu_var(ia64_need_tlb_flush))) {
-               local_flush_tlb_all();
-               __ia64_per_cpu_var(ia64_need_tlb_flush) = 0;
+               spin_lock_irqsave(&ia64_ctx.lock, flags);
+               {
+                       if (__ia64_per_cpu_var(ia64_need_tlb_flush)) {
+                               local_flush_tlb_all();
+                               __ia64_per_cpu_var(ia64_need_tlb_flush) = 0;
+                       }
+               }
+               spin_unlock_irqrestore(&ia64_ctx.lock, flags);
        }
 }
 
-static inline mm_context_t
+static inline nv_mm_context_t
 get_mmu_context (struct mm_struct *mm)
 {
        unsigned long flags;
-       mm_context_t context = mm->context;
-
-       if (context)
-               return context;
-
-       spin_lock_irqsave(&ia64_ctx.lock, flags);
-       {
-               /* re-check, now that we've got the lock: */
-               context = mm->context;
-               if (context == 0) {
-                       cpus_clear(mm->cpu_vm_mask);
-                       if (ia64_ctx.next >= ia64_ctx.limit)
-                               wrap_mmu_context(mm);
-                       mm->context = context = ia64_ctx.next++;
+       nv_mm_context_t context = mm->context;
+
+       if (unlikely(!context)) {
+               spin_lock_irqsave(&ia64_ctx.lock, flags);
+               {
+                       /* re-check, now that we've got the lock: */
+                       context = mm->context;
+                       if (context == 0) {
+                               cpus_clear(mm->cpu_vm_mask);
+                               if (ia64_ctx.next >= ia64_ctx.limit)
+                                       wrap_mmu_context(mm);
+                               mm->context = context = ia64_ctx.next++;
+                       }
                }
+               spin_unlock_irqrestore(&ia64_ctx.lock, flags);
        }
-       spin_unlock_irqrestore(&ia64_ctx.lock, flags);
+       /*
+        * Ensure we're not starting to use "context" before any old
+        * uses of it are gone from our TLB.
+        */
+       delayed_tlb_flush();
+
        return context;
 }
 
@@ -104,13 +117,13 @@ destroy_context (struct mm_struct *mm)
 }
 
 static inline void
-reload_context (mm_context_t context)
+reload_context (nv_mm_context_t context)
 {
        unsigned long rid;
        unsigned long rid_incr = 0;
        unsigned long rr0, rr1, rr2, rr3, rr4, old_rr4;
 
-       old_rr4 = ia64_get_rr(0x8000000000000000UL);
+       old_rr4 = ia64_get_rr(RGN_BASE(RGN_HPAGE));
        rid = context << 3;     /* make space for encoding the region number */
        rid_incr = 1 << 8;
 
@@ -122,6 +135,10 @@ reload_context (mm_context_t context)
        rr4 = rr0 + 4*rid_incr;
 #ifdef  CONFIG_HUGETLB_PAGE
        rr4 = (rr4 & (~(0xfcUL))) | (old_rr4 & 0xfc);
+
+#  if RGN_HPAGE != 4
+#    error "reload_context assumes RGN_HPAGE is 4"
+#  endif
 #endif
 
        ia64_set_rr(0x0000000000000000UL, rr0);
@@ -138,7 +155,7 @@ reload_context (mm_context_t context)
 static inline void
 activate_context (struct mm_struct *mm)
 {
-       mm_context_t context;
+       nv_mm_context_t context;
 
        do {
                context = get_mmu_context(mm);
@@ -157,8 +174,6 @@ activate_context (struct mm_struct *mm)
 static inline void
 activate_mm (struct mm_struct *prev, struct mm_struct *next)
 {
-       delayed_tlb_flush();
-
        /*
         * We may get interrupts here, but that's OK because interrupt handlers cannot
         * touch user-space.
index 08894f73abf0384df70d33888228ee389be33bcb..9edffad8c28b730b301a9725d2af79463be57bde 100644 (file)
 #include <asm/intrinsics.h>
 #include <asm/types.h>
 
+/*
+ * The top three bits of an IA64 address are its Region Number.
+ * Different regions are assigned to different purposes.
+ */
+#define RGN_SHIFT      (61)
+#define RGN_BASE(r)    (__IA64_UL_CONST(r)<<RGN_SHIFT)
+#define RGN_BITS       (RGN_BASE(-1))
+
+#define RGN_KERNEL     7       /* Identity mapped region */
+#define RGN_UNCACHED    6      /* Identity mapped I/O region */
+#define RGN_GATE       5       /* Gate page, Kernel text, etc */
+#define RGN_HPAGE      4       /* For Huge TLB pages */
+
 /*
  * PAGE_SHIFT determines the actual kernel page size.
  */
 
 #define RGN_MAP_LIMIT  ((1UL << (4*PAGE_SHIFT - 12)) - PAGE_SIZE)      /* per region addr limit */
 
+
 #ifdef CONFIG_HUGETLB_PAGE
-# define REGION_HPAGE          (4UL)   /* note: this is hardcoded in reload_context()!*/
-# define REGION_SHIFT          61
-# define HPAGE_REGION_BASE     (REGION_HPAGE << REGION_SHIFT)
+# define HPAGE_REGION_BASE     RGN_BASE(RGN_HPAGE)
 # define HPAGE_SHIFT           hpage_shift
 # define HPAGE_SHIFT_DEFAULT   28      /* check ia64 SDM for architecture supported size */
 # define HPAGE_SIZE            (__IA64_UL_CONST(1) << HPAGE_SHIFT)
@@ -130,16 +142,13 @@ typedef union ia64_va {
 #define REGION_NUMBER(x)       ({ia64_va _v; _v.l = (long) (x); _v.f.reg;})
 #define REGION_OFFSET(x)       ({ia64_va _v; _v.l = (long) (x); _v.f.off;})
 
-#define REGION_SIZE            REGION_NUMBER(1)
-#define REGION_KERNEL          7
-
 #ifdef CONFIG_HUGETLB_PAGE
 # define htlbpage_to_page(x)   (((unsigned long) REGION_NUMBER(x) << 61)                       \
                                 | (REGION_OFFSET(x) >> (HPAGE_SHIFT-PAGE_SHIFT)))
 # define HUGETLB_PAGE_ORDER    (HPAGE_SHIFT - PAGE_SHIFT)
 # define is_hugepage_only_range(mm, addr, len)         \
-        (REGION_NUMBER(addr) == REGION_HPAGE &&        \
-         REGION_NUMBER((addr)+(len)-1) == REGION_HPAGE)
+        (REGION_NUMBER(addr) == RGN_HPAGE &&   \
+         REGION_NUMBER((addr)+(len)-1) == RGN_HPAGE)
 extern unsigned int hpage_shift;
 #endif
 
@@ -197,7 +206,7 @@ get_order (unsigned long size)
 # define __pgprot(x)   (x)
 #endif /* !STRICT_MM_TYPECHECKS */
 
-#define PAGE_OFFSET                    __IA64_UL_CONST(0xe000000000000000)
+#define PAGE_OFFSET                    RGN_BASE(RGN_KERNEL)
 
 #define VM_DATA_DEFAULT_FLAGS          (VM_READ | VM_WRITE |                                   \
                                         VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC |                \
index 2303a10ee595405455d4f4520d3a334fd2fdfe56..e828377ad295cec5d77dd3a06b1bbdf06f014737 100644 (file)
@@ -75,6 +75,8 @@
 #define PAL_CACHE_READ         259     /* read tag & data of cacheline for diagnostic testing */
 #define PAL_CACHE_WRITE                260     /* write tag & data of cacheline for diagnostic testing */
 #define PAL_VM_TR_READ         261     /* read contents of translation register */
+#define PAL_GET_PSTATE         262     /* get the current P-state */
+#define PAL_SET_PSTATE         263     /* set the P-state */
 
 #ifndef __ASSEMBLY__
 
@@ -1111,6 +1113,25 @@ ia64_pal_halt_info (pal_power_mgmt_info_u_t *power_buf)
        return iprv.status;
 }
 
+/* Get the current P-state information */
+static inline s64
+ia64_pal_get_pstate (u64 *pstate_index)
+{
+       struct ia64_pal_retval iprv;
+       PAL_CALL_STK(iprv, PAL_GET_PSTATE, 0, 0, 0);
+       *pstate_index = iprv.v0;
+       return iprv.status;
+}
+
+/* Set the P-state */
+static inline s64
+ia64_pal_set_pstate (u64 pstate_index)
+{
+       struct ia64_pal_retval iprv;
+       PAL_CALL_STK(iprv, PAL_SET_PSTATE, pstate_index, 0, 0);
+       return iprv.status;
+}
+
 /* Cause the processor to enter LIGHT HALT state, where prefetching and execution are
  * suspended, but cache and TLB coherency is maintained.
  */
index 48586e08f432b5cc2793d0d4952869497e11d7bf..2e34c06e677795268249609786ceb012e81e4f84 100644 (file)
@@ -204,21 +204,18 @@ ia64_phys_addr_valid (unsigned long addr)
 #define set_pte(ptep, pteval)  (*(ptep) = (pteval))
 #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 
-#define RGN_SIZE       (1UL << 61)
-#define RGN_KERNEL     7
-
-#define VMALLOC_START          0xa000000200000000UL
+#define VMALLOC_START          (RGN_BASE(RGN_GATE) + 0x200000000UL)
 #ifdef CONFIG_VIRTUAL_MEM_MAP
-# define VMALLOC_END_INIT      (0xa000000000000000UL + (1UL << (4*PAGE_SHIFT - 9)))
+# define VMALLOC_END_INIT      (RGN_BASE(RGN_GATE) + (1UL << (4*PAGE_SHIFT - 9)))
 # define VMALLOC_END           vmalloc_end
   extern unsigned long vmalloc_end;
 #else
-# define VMALLOC_END           (0xa000000000000000UL + (1UL << (4*PAGE_SHIFT - 9)))
+# define VMALLOC_END           (RGN_BASE(RGN_GATE) + (1UL << (4*PAGE_SHIFT - 9)))
 #endif
 
 /* fs/proc/kcore.c */
-#define        kc_vaddr_to_offset(v) ((v) - 0xa000000000000000UL)
-#define        kc_offset_to_vaddr(o) ((o) + 0xa000000000000000UL)
+#define        kc_vaddr_to_offset(v) ((v) - RGN_BASE(RGN_GATE))
+#define        kc_offset_to_vaddr(o) ((o) + RGN_BASE(RGN_GATE))
 
 /*
  * Conversion functions: convert page frame number (pfn) and a protection value to a page
index 6ece5061dc1904256c13f062bb1de4679b4e8511..e18b5ab0cb75c0cd6ee7014260cf23bdd79a59a6 100644 (file)
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 2003 Ken Chen <kenneth.w.chen@intel.com>
  * Copyright (C) 2003 Asit Mallick <asit.k.mallick@intel.com>
+ * Copyright (C) 2005 Christoph Lameter <clameter@sgi.com>
  *
  * Based on asm-i386/rwsem.h and other architecture implementation.
  *
@@ -11,9 +12,9 @@
  *
  * The lock count is initialized to 0 (no active and no waiting lockers).
  *
- * When a writer subtracts WRITE_BIAS, it'll get 0xffff0001 for the case
- * of an uncontended lock. Readers increment by 1 and see a positive value
- * when uncontended, negative if there are writers (and maybe) readers
+ * When a writer subtracts WRITE_BIAS, it'll get 0xffffffff00000001 for
+ * the case of an uncontended lock. Readers increment by 1 and see a positive
+ * value when uncontended, negative if there are writers (and maybe) readers
  * waiting (in which case it goes to sleep).
  */
 
@@ -29,7 +30,7 @@
  * the semaphore definition
  */
 struct rw_semaphore {
-       signed int              count;
+       signed long             count;
        spinlock_t              wait_lock;
        struct list_head        wait_list;
 #if RWSEM_DEBUG
@@ -37,10 +38,10 @@ struct rw_semaphore {
 #endif
 };
 
-#define RWSEM_UNLOCKED_VALUE           0x00000000
-#define RWSEM_ACTIVE_BIAS              0x00000001
-#define RWSEM_ACTIVE_MASK              0x0000ffff
-#define RWSEM_WAITING_BIAS             (-0x00010000)
+#define RWSEM_UNLOCKED_VALUE           __IA64_UL_CONST(0x0000000000000000)
+#define RWSEM_ACTIVE_BIAS              __IA64_UL_CONST(0x0000000000000001)
+#define RWSEM_ACTIVE_MASK              __IA64_UL_CONST(0x00000000ffffffff)
+#define RWSEM_WAITING_BIAS             -__IA64_UL_CONST(0x0000000100000000)
 #define RWSEM_ACTIVE_READ_BIAS         RWSEM_ACTIVE_BIAS
 #define RWSEM_ACTIVE_WRITE_BIAS                (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS)
 
@@ -83,7 +84,7 @@ init_rwsem (struct rw_semaphore *sem)
 static inline void
 __down_read (struct rw_semaphore *sem)
 {
-       int result = ia64_fetchadd4_acq((unsigned int *)&sem->count, 1);
+       long result = ia64_fetchadd8_acq((unsigned long *)&sem->count, 1);
 
        if (result < 0)
                rwsem_down_read_failed(sem);
@@ -95,7 +96,7 @@ __down_read (struct rw_semaphore *sem)
 static inline void
 __down_write (struct rw_semaphore *sem)
 {
-       int old, new;
+       long old, new;
 
        do {
                old = sem->count;
@@ -112,7 +113,7 @@ __down_write (struct rw_semaphore *sem)
 static inline void
 __up_read (struct rw_semaphore *sem)
 {
-       int result = ia64_fetchadd4_rel((unsigned int *)&sem->count, -1);
+       long result = ia64_fetchadd8_rel((unsigned long *)&sem->count, -1);
 
        if (result < 0 && (--result & RWSEM_ACTIVE_MASK) == 0)
                rwsem_wake(sem);
@@ -124,7 +125,7 @@ __up_read (struct rw_semaphore *sem)
 static inline void
 __up_write (struct rw_semaphore *sem)
 {
-       int old, new;
+       long old, new;
 
        do {
                old = sem->count;
@@ -141,7 +142,7 @@ __up_write (struct rw_semaphore *sem)
 static inline int
 __down_read_trylock (struct rw_semaphore *sem)
 {
-       int tmp;
+       long tmp;
        while ((tmp = sem->count) >= 0) {
                if (tmp == cmpxchg_acq(&sem->count, tmp, tmp+1)) {
                        return 1;
@@ -156,7 +157,7 @@ __down_read_trylock (struct rw_semaphore *sem)
 static inline int
 __down_write_trylock (struct rw_semaphore *sem)
 {
-       int tmp = cmpxchg_acq(&sem->count, RWSEM_UNLOCKED_VALUE,
+       long tmp = cmpxchg_acq(&sem->count, RWSEM_UNLOCKED_VALUE,
                              RWSEM_ACTIVE_WRITE_BIAS);
        return tmp == RWSEM_UNLOCKED_VALUE;
 }
@@ -167,7 +168,7 @@ __down_write_trylock (struct rw_semaphore *sem)
 static inline void
 __downgrade_write (struct rw_semaphore *sem)
 {
-       int old, new;
+       long old, new;
 
        do {
                old = sem->count;
@@ -182,7 +183,7 @@ __downgrade_write (struct rw_semaphore *sem)
  * Implement atomic add functionality.  These used to be "inline" functions, but GCC v3.1
  * doesn't quite optimize this stuff right and ends up with bad calls to fetchandadd.
  */
-#define rwsem_atomic_add(delta, sem)   atomic_add(delta, (atomic_t *)(&(sem)->count))
-#define rwsem_atomic_update(delta, sem)        atomic_add_return(delta, (atomic_t *)(&(sem)->count))
+#define rwsem_atomic_add(delta, sem)   atomic64_add(delta, (atomic64_t *)(&(sem)->count))
+#define rwsem_atomic_update(delta, sem)        atomic64_add_return(delta, (atomic64_t *)(&(sem)->count))
 
 #endif /* _ASM_IA64_RWSEM_H */
index 103d745dc5f2f9fc8eda359854310424cd63545c..2c32e4b77b54051e1237fb99a55825555c8b71cf 100644 (file)
@@ -3,7 +3,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (c) 1992-1999,2001-2004 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (c) 1992-1999,2001-2005 Silicon Graphics, Inc. All rights reserved.
  */
 
 #ifndef _ASM_IA64_SN_ADDRS_H
@@ -65,7 +65,6 @@
 
 #define NASID_MASK              ((u64)NASID_BITMASK << NASID_SHIFT)
 #define AS_MASK                        ((u64)AS_BITMASK << AS_SHIFT)
-#define REGION_BITS            0xe000000000000000UL
 
 
 /*
 #define AS_CAC_SPACE           (AS_CAC_VAL << AS_SHIFT)
 
 
-/*
- * Base addresses for various address ranges.
- */
-#define CACHED                 0xe000000000000000UL
-#define UNCACHED                0xc000000000000000UL
-#define UNCACHED_PHYS           0x8000000000000000UL
-
-
 /* 
  * Virtual Mode Local & Global MMR space.  
  */
 #define SH1_LOCAL_MMR_OFFSET   0x8000000000UL
 #define SH2_LOCAL_MMR_OFFSET   0x0200000000UL
 #define LOCAL_MMR_OFFSET       (is_shub2() ? SH2_LOCAL_MMR_OFFSET : SH1_LOCAL_MMR_OFFSET)
-#define LOCAL_MMR_SPACE                (UNCACHED | LOCAL_MMR_OFFSET)
-#define LOCAL_PHYS_MMR_SPACE   (UNCACHED_PHYS | LOCAL_MMR_OFFSET)
+#define LOCAL_MMR_SPACE                (__IA64_UNCACHED_OFFSET | LOCAL_MMR_OFFSET)
+#define LOCAL_PHYS_MMR_SPACE   (RGN_BASE(RGN_HPAGE) | LOCAL_MMR_OFFSET)
 
 #define SH1_GLOBAL_MMR_OFFSET  0x0800000000UL
 #define SH2_GLOBAL_MMR_OFFSET  0x0300000000UL
 #define GLOBAL_MMR_OFFSET      (is_shub2() ? SH2_GLOBAL_MMR_OFFSET : SH1_GLOBAL_MMR_OFFSET)
-#define GLOBAL_MMR_SPACE       (UNCACHED | GLOBAL_MMR_OFFSET)
+#define GLOBAL_MMR_SPACE       (__IA64_UNCACHED_OFFSET | GLOBAL_MMR_OFFSET)
 
 /*
  * Physical mode addresses
  */
-#define GLOBAL_PHYS_MMR_SPACE  (UNCACHED_PHYS | GLOBAL_MMR_OFFSET)
+#define GLOBAL_PHYS_MMR_SPACE  (RGN_BASE(RGN_HPAGE) | GLOBAL_MMR_OFFSET)
 
 
 /*
  * Clear region & AS bits.
  */
-#define TO_PHYS_MASK           (~(REGION_BITS | AS_MASK))
+#define TO_PHYS_MASK           (~(RGN_BITS | AS_MASK))
 
 
 /*
 #define GLOBAL_MMR_PHYS_ADDR(n,a) (GLOBAL_PHYS_MMR_SPACE | REMOTE_ADDR(n,a))
 #define GLOBAL_CAC_ADDR(n,a)   (CAC_BASE | REMOTE_ADDR(n,a))
 #define CHANGE_NASID(n,x)      ((void *)(((u64)(x) & ~NASID_MASK) | NASID_SPACE(n)))
+#define IS_TIO_NASID(n)                ((n) & 1)
 
 
 /* non-II mmr's start at top of big window space (4G) */
 /*
  * general address defines
  */
-#define CAC_BASE               (CACHED   | AS_CAC_SPACE)
-#define AMO_BASE               (UNCACHED | AS_AMO_SPACE)
-#define AMO_PHYS_BASE          (UNCACHED_PHYS | AS_AMO_SPACE)
-#define GET_BASE               (CACHED   | AS_GET_SPACE)
+#define CAC_BASE               (PAGE_OFFSET | AS_CAC_SPACE)
+#define AMO_BASE               (__IA64_UNCACHED_OFFSET | AS_AMO_SPACE)
+#define AMO_PHYS_BASE          (RGN_BASE(RGN_HPAGE) | AS_AMO_SPACE)
+#define GET_BASE               (PAGE_OFFSET | AS_GET_SPACE)
 
 /*
  * Convert Memory addresses between various addressing modes.
  *           the chiplet id is zero.  If we implement TIO-TIO dma, we might need
  *           to insert a chiplet id into this macro.  However, it is our belief
  *           right now that this chiplet id will be ICE, which is also zero.
- *           Nasid starts on bit 40.
  */
-#define PHYS_TO_TIODMA(x)      ( (((u64)(NASID_GET(x))) << 40) | NODE_OFFSET(x))
-#define PHYS_TO_DMA(x)          ( (((u64)(x) & NASID_MASK) >> 2) | NODE_OFFSET(x))
+#define SH1_TIO_PHYS_TO_DMA(x)                                                 \
+       ((((u64)(NASID_GET(x))) << 40) | NODE_OFFSET(x))
+
+#define SH2_NETWORK_BANK_OFFSET(x)                                     \
+        ((u64)(x) & ((1UL << (sn_hub_info->nasid_shift - 4)) -1))
+
+#define SH2_NETWORK_BANK_SELECT(x)                                     \
+        ((((u64)(x) & (0x3UL << (sn_hub_info->nasid_shift - 4)))       \
+               >> (sn_hub_info->nasid_shift - 4)) << 36)
+
+#define SH2_NETWORK_ADDRESS(x)                                                 \
+       (SH2_NETWORK_BANK_OFFSET(x) | SH2_NETWORK_BANK_SELECT(x))
+
+#define SH2_TIO_PHYS_TO_DMA(x)                                                 \
+        (((u64)(NASID_GET(x)) << 40) |         SH2_NETWORK_ADDRESS(x))
+
+#define PHYS_TO_TIODMA(x)                                              \
+       (is_shub1() ? SH1_TIO_PHYS_TO_DMA(x) : SH2_TIO_PHYS_TO_DMA(x))
+
+#define PHYS_TO_DMA(x)                                                 \
+       ((((u64)(x) & NASID_MASK) >> 2) | NODE_OFFSET(x))
 
 
 /*
  * Macros to test for address type.
  */
-#define IS_AMO_ADDRESS(x)      (((u64)(x) & (REGION_BITS | AS_MASK)) == AMO_BASE)
-#define IS_AMO_PHYS_ADDRESS(x) (((u64)(x) & (REGION_BITS | AS_MASK)) == AMO_PHYS_BASE)
+#define IS_AMO_ADDRESS(x)      (((u64)(x) & (RGN_BITS | AS_MASK)) == AMO_BASE)
+#define IS_AMO_PHYS_ADDRESS(x) (((u64)(x) & (RGN_BITS | AS_MASK)) == AMO_PHYS_BASE)
 
 
 /*
 #define TIO_SWIN_BASE(n, w)            (TIO_IO_BASE(n) + \
                                            ((u64) (w) << TIO_SWIN_SIZE_BITS))
 #define NODE_IO_BASE(n)                        (GLOBAL_MMR_SPACE | NASID_SPACE(n))
-#define TIO_IO_BASE(n)                  (UNCACHED | NASID_SPACE(n))
+#define TIO_IO_BASE(n)                  (__IA64_UNCACHED_OFFSET | NASID_SPACE(n))
 #define BWIN_SIZE                      (1UL << BWIN_SIZE_BITS)
 #define NODE_BWIN_BASE0(n)             (NODE_IO_BASE(n) + BWIN_SIZE)
 #define NODE_BWIN_BASE(n, w)           (NODE_BWIN_BASE0(n) + ((u64) (w) << BWIN_SIZE_BITS))
 #define RAW_NODE_SWIN_BASE(n, w)       (NODE_IO_BASE(n) + ((u64) (w) << SWIN_SIZE_BITS))
 #define BWIN_WIDGET_MASK               0x7
 #define BWIN_WINDOWNUM(x)              (((x) >> BWIN_SIZE_BITS) & BWIN_WIDGET_MASK)
+#define SH1_IS_BIG_WINDOW_ADDR(x)      ((x) & BWIN_TOP)
 
 #define TIO_BWIN_WINDOW_SELECT_MASK    0x7
 #define TIO_BWIN_WINDOWNUM(x)          (((x) >> TIO_BWIN_SIZE_BITS) & TIO_BWIN_WINDOW_SELECT_MASK)
 
-
+#define TIO_HWIN_SHIFT_BITS            33
+#define TIO_HWIN(x)                    (NODE_OFFSET(x) >> TIO_HWIN_SHIFT_BITS)
 
 /*
  * The following definitions pertain to the IO special address
 #define TIO_SWIN_WIDGETNUM(x)          (((x)  >> TIO_SWIN_SIZE_BITS) & TIO_SWIN_WIDGET_MASK)
 
 
-#define TIO_IOSPACE_ADDR(n,x)                                  \
-       /* Move in the Chiplet ID for TIO Local Block MMR */    \
-       (REMOTE_ADDR(n,x) | 1UL << (NASID_SHIFT - 2))
-
 /*
  * The following macros produce the correct base virtual address for
  * the hub registers. The REMOTE_HUB_* macro produce
  *     Otherwise, the recommended approach is to use *_HUB_L() and *_HUB_S().
  *     They're always safe.
  */
+/* Shub1 TIO & MMR addressing macros */
+#define SH1_TIO_IOSPACE_ADDR(n,x)                                      \
+       GLOBAL_MMR_ADDR(n,x)
+
+#define SH1_REMOTE_BWIN_MMR(n,x)                                       \
+       GLOBAL_MMR_ADDR(n,x)
+
+#define SH1_REMOTE_SWIN_MMR(n,x)                                       \
+       (NODE_SWIN_BASE(n,1) + 0x800000UL + (x))
+
+#define SH1_REMOTE_MMR(n,x)                                            \
+       (SH1_IS_BIG_WINDOW_ADDR(x) ? SH1_REMOTE_BWIN_MMR(n,x) :         \
+               SH1_REMOTE_SWIN_MMR(n,x))
+
+/* Shub1 TIO & MMR addressing macros */
+#define SH2_TIO_IOSPACE_ADDR(n,x)                                      \
+       ((__IA64_UNCACHED_OFFSET | REMOTE_ADDR(n,x) | 1UL << (NASID_SHIFT - 2)))
+
+#define SH2_REMOTE_MMR(n,x)                                            \
+       GLOBAL_MMR_ADDR(n,x)
+
+
+/* TIO & MMR addressing macros that work on both shub1 & shub2 */
+#define TIO_IOSPACE_ADDR(n,x)                                          \
+       ((u64 *)(is_shub1() ? SH1_TIO_IOSPACE_ADDR(n,x) :               \
+                SH2_TIO_IOSPACE_ADDR(n,x)))
+
+#define SH_REMOTE_MMR(n,x)                                             \
+       (is_shub1() ? SH1_REMOTE_MMR(n,x) : SH2_REMOTE_MMR(n,x))
+
 #define REMOTE_HUB_ADDR(n,x)                                           \
-       ((n & 1) ?                                                      \
-       /* TIO: */                                                      \
-       (is_shub2() ?                                                   \
-       /* TIO on Shub2 */                                              \
-       (volatile u64 *)(TIO_IOSPACE_ADDR(n,x))                         \
-       : /* TIO on shub1 */                                            \
-       (volatile u64 *)(GLOBAL_MMR_ADDR(n,x)))                         \
-                                                                       \
-       : /* SHUB1 and SHUB2 MMRs: */                                   \
-       (((x) & BWIN_TOP) ? ((volatile u64 *)(GLOBAL_MMR_ADDR(n,x)))    \
-       : ((volatile u64 *)(NODE_SWIN_BASE(n,1) + 0x800000 + (x)))))
+       (IS_TIO_NASID(n) ?  ((volatile u64*)TIO_IOSPACE_ADDR(n,x)) :    \
+        ((volatile u64*)SH_REMOTE_MMR(n,x)))
+
 
 #define HUB_L(x)                       (*((volatile typeof(*x) *)x))
 #define        HUB_S(x,d)                      (*((volatile typeof(*x) *)x) = (d))
index 84b254603b8d18ed2a046c98f083873ab9e8ce54..f083c94340663319cda9ccccdcfbcc8a8409875d 100644 (file)
@@ -3,7 +3,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1992 - 1997, 2000-2004 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 1992 - 1997, 2000-2005 Silicon Graphics, Inc. All rights reserved.
  */
 
 #ifndef _ASM_IA64_SN_GEO_H
@@ -108,7 +108,6 @@ typedef union geoid_u {
 #define INVALID_SLAB            (slabid_t)-1
 #define INVALID_SLOT            (slotid_t)-1
 #define INVALID_MODULE          ((moduleid_t)-1)
-#define INVALID_PARTID          ((partid_t)-1)
 
 static inline slabid_t geo_slab(geoid_t g)
 {
index e190dd4213d56233938104e66cd1b93958abd99e..e35074f526d9fb8c146dcc6f97be49ca094d7d25 100644 (file)
 #include <linux/rcupdate.h>
 
 #define SGI_UART_VECTOR                (0xe9)
-#define SGI_PCIBR_ERROR                (0x33)
 
 /* Reserved IRQs : Note, not to exceed IA64_SN2_FIRST_DEVICE_VECTOR */
 #define SGI_XPC_ACTIVATE                (0x30)
 #define SGI_II_ERROR                    (0x31)
 #define SGI_XBOW_ERROR                  (0x32)
-#define SGI_PCIBR_ERROR                 (0x33)
+#define SGI_PCIASIC_ERROR               (0x33)
 #define SGI_ACPI_SCI_INT                (0x34)
 #define SGI_TIOCA_ERROR                 (0x35)
 #define SGI_TIO_ERROR                   (0x36)
index 7138b1eafd6b46d48a5f83f10fc7606eb1885ef7..47bb8100fd00e93a972511f7612a6999e92badfb 100644 (file)
@@ -37,7 +37,6 @@ struct phys_cpuid {
 
 struct nodepda_s {
        void            *pdinfo;        /* Platform-dependent per-node info */
-       spinlock_t              bist_lock;
 
        /*
         * The BTEs on this node are shared by the local cpus
@@ -55,6 +54,8 @@ struct nodepda_s {
         * Array of physical cpu identifiers. Indexed by cpuid.
         */
        struct phys_cpuid       phys_cpuid[NR_CPUS];
+       spinlock_t              ptc_lock ____cacheline_aligned_in_smp;
+       spinlock_t              bist_lock;
 };
 
 typedef struct nodepda_s nodepda_t;
index 976f5eff0539ff283809c53ae304efbf37a156a3..ad0e8e8ae53fef47a2a6abaa3a5efaebf2090cce 100644 (file)
@@ -18,8 +18,9 @@
 #define PCIIO_ASIC_TYPE_PIC    2
 #define PCIIO_ASIC_TYPE_TIOCP  3
 #define PCIIO_ASIC_TYPE_TIOCA  4
+#define PCIIO_ASIC_TYPE_TIOCE  5
 
-#define PCIIO_ASIC_MAX_TYPES   5
+#define PCIIO_ASIC_MAX_TYPES   6
 
 /*
  * Common pciio bus provider data.  There should be one of these as the
@@ -30,7 +31,8 @@
 struct pcibus_bussoft {
        uint32_t                bs_asic_type;   /* chipset type */
        uint32_t                bs_xid;         /* xwidget id */
-       uint64_t                bs_persist_busnum; /* Persistent Bus Number */
+       uint32_t                bs_persist_busnum; /* Persistent Bus Number */
+       uint32_t                bs_persist_segment; /* Segment Number */
        uint64_t                bs_legacy_io;   /* legacy io pio addr */
        uint64_t                bs_legacy_mem;  /* legacy mem pio addr */
        uint64_t                bs_base;        /* widget base */
@@ -47,6 +49,8 @@ struct sn_pcibus_provider {
        dma_addr_t      (*dma_map_consistent)(struct pci_dev *, unsigned long, size_t);
        void            (*dma_unmap)(struct pci_dev *, dma_addr_t, int);
        void *          (*bus_fixup)(struct pcibus_bussoft *, struct pci_controller *);
+       void            (*force_interrupt)(struct sn_irq_info *);
+       void            (*target_interrupt)(struct sn_irq_info *);
 };
 
 extern struct sn_pcibus_provider *sn_pci_provider[];
index ea5590c76ca48eafc3505ced25ef048d1d8d1b0e..1c5108d44d8bf9f4ced5a99577546e650dfc95d2 100644 (file)
@@ -39,7 +39,6 @@ typedef struct pda_s {
        unsigned long pio_write_status_val;
        volatile unsigned long *pio_shub_war_cam_addr;
 
-       unsigned long   sn_soft_irr[4];
        unsigned long   sn_in_service_ivecs[4];
        int             sn_lb_int_war_ticks;
        int             sn_last_irq;
index df75f4c4aec3bfce3385f8f5cefe1eaafc3dd1d3..291ef3d69da225983ebf85dfd2c81523e77e5396 100644 (file)
@@ -43,6 +43,7 @@ struct sn_hwperf_object_info {
 
 /* macros for object classification */
 #define SN_HWPERF_IS_NODE(x)           ((x) && strstr((x)->name, "SHub"))
+#define SN_HWPERF_IS_NODE_SHUB2(x)     ((x) && strstr((x)->name, "SHub 2."))
 #define SN_HWPERF_IS_IONODE(x)         ((x) && strstr((x)->name, "TIO"))
 #define SN_HWPERF_IS_ROUTER(x)         ((x) && strstr((x)->name, "Router"))
 #define SN_HWPERF_IS_NL3ROUTER(x)      ((x) && strstr((x)->name, "NL3Router"))
@@ -214,6 +215,15 @@ struct sn_hwperf_ioctl_args {
  */
 #define SN_HWPERF_GET_NODE_NASID       (102|SN_HWPERF_OP_MEM_COPYOUT)
 
+/*
+ * Given a node id, determine the id of the nearest node with CPUs
+ * and the id of the nearest node that has memory. The argument
+ * node would normally be a "headless" node, e.g. an "IO node".
+ * Return 0 on success.
+ */
+extern int sn_hwperf_get_nearest_node(cnodeid_t node,
+       cnodeid_t *near_mem, cnodeid_t *near_cpu);
+
 /* return codes */
 #define SN_HWPERF_OP_OK                        0
 #define SN_HWPERF_OP_NOMEM             1
index 27976d22318657e56fcdc48833cf993a887309b1..e67825ad1930cee26dca3971b5c674f1e21c79e1 100644 (file)
@@ -55,7 +55,6 @@
 #define  SN_SAL_BUS_CONFIG                        0x02000037
 #define  SN_SAL_SYS_SERIAL_GET                    0x02000038
 #define  SN_SAL_PARTITION_SERIAL_GET              0x02000039
-#define  SN_SAL_SYSCTL_PARTITION_GET              0x0200003a
 #define  SN_SAL_SYSTEM_POWER_DOWN                 0x0200003b
 #define  SN_SAL_GET_MASTER_BASEIO_NASID                   0x0200003c
 #define  SN_SAL_COHERENCE                          0x0200003d
@@ -78,7 +77,8 @@
 
 #define SN_SAL_HUB_ERROR_INTERRUPT                0x02000060
 #define SN_SAL_BTE_RECOVER                        0x02000061
-#define SN_SAL_IOIF_GET_PCI_TOPOLOGY              0x02000062
+#define SN_SAL_RESERVED_DO_NOT_USE                0x02000062
+#define SN_SAL_IOIF_GET_PCI_TOPOLOGY              0x02000064
 
 /*
  * Service-specific constants
@@ -585,35 +585,6 @@ sn_partition_serial_number_val(void) {
        return sn_partition_serial_number;
 }
 
-/*
- * Returns the partition id of the nasid passed in as an argument,
- * or INVALID_PARTID if the partition id cannot be retrieved.
- */
-static inline partid_t
-ia64_sn_sysctl_partition_get(nasid_t nasid)
-{
-       struct ia64_sal_retval ret_stuff;
-       ia64_sal_oemcall_nolock(&ret_stuff, SN_SAL_SYSCTL_PARTITION_GET, nasid,
-                               0, 0, 0, 0, 0, 0);
-       if (ret_stuff.status != 0)
-           return INVALID_PARTID;
-       return ((partid_t)ret_stuff.v0);
-}
-
-/*
- * Returns the partition id of the current processor.
- */
-
-extern partid_t sn_partid;
-
-static inline partid_t
-sn_local_partid(void) {
-       if (unlikely(sn_partid < 0)) {
-               sn_partid = ia64_sn_sysctl_partition_get(cpuid_to_nasid(smp_processor_id()));
-       }
-       return sn_partid;
-}
-
 /*
  * Returns the physical address of the partition's reserved page through
  * an iterative number of calls.
@@ -749,7 +720,8 @@ ia64_sn_power_down(void)
 {
        struct ia64_sal_retval ret_stuff;
        SAL_CALL(ret_stuff, SN_SAL_SYSTEM_POWER_DOWN, 0, 0, 0, 0, 0, 0, 0);
-       while(1);
+       while(1)
+               cpu_relax();
        /* never returns */
 }
 
@@ -1018,24 +990,6 @@ ia64_sn_get_sn_info(int fc, u8 *shubtype, u16 *nasid_bitmask, u8 *nasid_shift,
        ret_stuff.v2 = 0;
        SAL_CALL_NOLOCK(ret_stuff, SN_SAL_GET_SN_INFO, fc, 0, 0, 0, 0, 0, 0);
 
-/***** BEGIN HACK - temp til old proms no longer supported ********/
-       if (ret_stuff.status == SALRET_NOT_IMPLEMENTED) {
-               int nasid = get_sapicid() & 0xfff;;
-#define SH_SHUB_ID_NODES_PER_BIT_MASK 0x001f000000000000UL                                               
-#define SH_SHUB_ID_NODES_PER_BIT_SHFT 48                                                               
-               if (shubtype) *shubtype = 0;
-               if (nasid_bitmask) *nasid_bitmask = 0x7ff;
-               if (nasid_shift) *nasid_shift = 38;
-               if (systemsize) *systemsize = 11;
-               if (sharing_domain_size) *sharing_domain_size = 9;
-               if (partid) *partid = ia64_sn_sysctl_partition_get(nasid);
-               if (coher) *coher = nasid >> 9;
-               if (reg) *reg = (HUB_L((u64 *) LOCAL_MMR_ADDR(SH1_SHUB_ID)) & SH_SHUB_ID_NODES_PER_BIT_MASK) >>
-                       SH_SHUB_ID_NODES_PER_BIT_SHFT;
-               return 0;
-       }
-/***** END HACK *******/
-
        if (ret_stuff.status < 0)
                return ret_stuff.status;
 
@@ -1068,12 +1022,10 @@ ia64_sn_hwperf_op(nasid_t nasid, u64 opcode, u64 a0, u64 a1, u64 a2,
 }
 
 static inline int
-ia64_sn_ioif_get_pci_topology(u64 rack, u64 bay, u64 slot, u64 slab,
-                             u64 buf, u64 len)
+ia64_sn_ioif_get_pci_topology(u64 buf, u64 len)
 {
        struct ia64_sal_retval rv;
-       SAL_CALL_NOLOCK(rv, SN_SAL_IOIF_GET_PCI_TOPOLOGY,
-               rack, bay, slot, slab, buf, len, 0);
+       SAL_CALL_NOLOCK(rv, SN_SAL_IOIF_GET_PCI_TOPOLOGY, buf, len, 0, 0, 0, 0, 0);
        return (int) rv.status;
 }
 
diff --git a/include/asm-ia64/sn/tioce.h b/include/asm-ia64/sn/tioce.h
new file mode 100644 (file)
index 0000000..2287985
--- /dev/null
@@ -0,0 +1,740 @@
+/**************************************************************************
+ *                                                                        *
+ *  Unpublished copyright (c) 2005, Silicon Graphics, Inc.                *
+ *  THIS IS UNPUBLISHED CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF SGI.  *
+ *                                                                        *
+ *  The copyright notice above does  not evidence any actual or intended  *
+ *  publication  or  disclosure  of  this source  code,  which  includes  *
+ *  information that is confidential  and/or proprietary, and is a trade  *
+ *  secret, of  Silicon Graphics, Inc.   ANY REPRODUCTION, MODIFICATION,  *
+ *  DISTRIBUTION, PUBLIC  PERFORMANCE, OR  PUBLIC DISPLAY OF  OR THROUGH  *
+ *  USE  OF THIS  SOURCE CODE  WITHOUT  THE EXPRESS  WRITTEN CONSENT  OF  *
+ *  SILICON GRAPHICS, INC.  IS  STRICTLY PROHIBITED, AND IN VIOLATION OF  *
+ *  APPLICABLE  LAWS   AND  INTERNATIONAL  TREATIES.    THE  RECEIPT  OR  *
+ *  POSSESSION OF  THIS SOURCE CODE AND/OR RELATED  INFORMATION DOES NOT  *
+ *  CONVEY OR IMPLY ANY RIGHTS  TO REPRODUCE, DISCLOSE OR DISTRIBUTE ITS  *
+ *  CONTENTS,  OR TO  MANUFACTURE, USE,  OR  SELL ANYTHING  THAT IT  MAY  *
+ *  DESCRIBE, IN WHOLE OR IN PART.                                        *
+ *                                                                        *
+ **************************************************************************/
+
+#ifndef __ASM_IA64_SN_TIOCE_H__
+#define __ASM_IA64_SN_TIOCE_H__
+
+/* CE ASIC part & mfgr information  */
+#define TIOCE_PART_NUM                 0xCE00
+#define TIOCE_MFGR_NUM                 0x36
+#define TIOCE_REV_A                    0x1
+
+/* CE Virtual PPB Vendor/Device IDs */
+#define CE_VIRT_PPB_VENDOR_ID          0x10a9
+#define CE_VIRT_PPB_DEVICE_ID          0x4002
+
+/* CE Host Bridge Vendor/Device IDs */
+#define CE_HOST_BRIDGE_VENDOR_ID       0x10a9
+#define CE_HOST_BRIDGE_DEVICE_ID       0x4003
+
+
+#define TIOCE_NUM_M40_ATES             4096
+#define TIOCE_NUM_M3240_ATES           2048
+#define TIOCE_NUM_PORTS                        2
+
+/*
+ * Register layout for TIOCE.  MMR offsets are shown at the far right of the
+ * structure definition.
+ */
+typedef volatile struct tioce {
+       /*
+        * ADMIN : Administration Registers
+        */
+       uint64_t        ce_adm_id;                              /* 0x000000 */
+       uint64_t        ce_pad_000008;                          /* 0x000008 */
+       uint64_t        ce_adm_dyn_credit_status;               /* 0x000010 */
+       uint64_t        ce_adm_last_credit_status;              /* 0x000018 */
+       uint64_t        ce_adm_credit_limit;                    /* 0x000020 */
+       uint64_t        ce_adm_force_credit;                    /* 0x000028 */
+       uint64_t        ce_adm_control;                         /* 0x000030 */
+       uint64_t        ce_adm_mmr_chn_timeout;                 /* 0x000038 */
+       uint64_t        ce_adm_ssp_ure_timeout;                 /* 0x000040 */
+       uint64_t        ce_adm_ssp_dre_timeout;                 /* 0x000048 */
+       uint64_t        ce_adm_ssp_debug_sel;                   /* 0x000050 */
+       uint64_t        ce_adm_int_status;                      /* 0x000058 */
+       uint64_t        ce_adm_int_status_alias;                /* 0x000060 */
+       uint64_t        ce_adm_int_mask;                        /* 0x000068 */
+       uint64_t        ce_adm_int_pending;                     /* 0x000070 */
+       uint64_t        ce_adm_force_int;                       /* 0x000078 */
+       uint64_t        ce_adm_ure_ups_buf_barrier_flush;       /* 0x000080 */
+       uint64_t        ce_adm_int_dest[15];        /* 0x000088 -- 0x0000F8 */
+       uint64_t        ce_adm_error_summary;                   /* 0x000100 */
+       uint64_t        ce_adm_error_summary_alias;             /* 0x000108 */
+       uint64_t        ce_adm_error_mask;                      /* 0x000110 */
+       uint64_t        ce_adm_first_error;                     /* 0x000118 */
+       uint64_t        ce_adm_error_overflow;                  /* 0x000120 */
+       uint64_t        ce_adm_error_overflow_alias;            /* 0x000128 */
+       uint64_t        ce_pad_000130[2];           /* 0x000130 -- 0x000138 */
+       uint64_t        ce_adm_tnum_error;                      /* 0x000140 */
+       uint64_t        ce_adm_mmr_err_detail;                  /* 0x000148 */
+       uint64_t        ce_adm_msg_sram_perr_detail;            /* 0x000150 */
+       uint64_t        ce_adm_bap_sram_perr_detail;            /* 0x000158 */
+       uint64_t        ce_adm_ce_sram_perr_detail;             /* 0x000160 */
+       uint64_t        ce_adm_ce_credit_oflow_detail;          /* 0x000168 */
+       uint64_t        ce_adm_tx_link_idle_max_timer;          /* 0x000170 */
+       uint64_t        ce_adm_pcie_debug_sel;                  /* 0x000178 */
+       uint64_t        ce_pad_000180[16];          /* 0x000180 -- 0x0001F8 */
+
+       uint64_t        ce_adm_pcie_debug_sel_top;              /* 0x000200 */
+       uint64_t        ce_adm_pcie_debug_lat_sel_lo_top;       /* 0x000208 */
+       uint64_t        ce_adm_pcie_debug_lat_sel_hi_top;       /* 0x000210 */
+       uint64_t        ce_adm_pcie_debug_trig_sel_top;         /* 0x000218 */
+       uint64_t        ce_adm_pcie_debug_trig_lat_sel_lo_top;  /* 0x000220 */
+       uint64_t        ce_adm_pcie_debug_trig_lat_sel_hi_top;  /* 0x000228 */
+       uint64_t        ce_adm_pcie_trig_compare_top;           /* 0x000230 */
+       uint64_t        ce_adm_pcie_trig_compare_en_top;        /* 0x000238 */
+       uint64_t        ce_adm_ssp_debug_sel_top;               /* 0x000240 */
+       uint64_t        ce_adm_ssp_debug_lat_sel_lo_top;        /* 0x000248 */
+       uint64_t        ce_adm_ssp_debug_lat_sel_hi_top;        /* 0x000250 */
+       uint64_t        ce_adm_ssp_debug_trig_sel_top;          /* 0x000258 */
+       uint64_t        ce_adm_ssp_debug_trig_lat_sel_lo_top;   /* 0x000260 */
+       uint64_t        ce_adm_ssp_debug_trig_lat_sel_hi_top;   /* 0x000268 */
+       uint64_t        ce_adm_ssp_trig_compare_top;            /* 0x000270 */
+       uint64_t        ce_adm_ssp_trig_compare_en_top;         /* 0x000278 */
+       uint64_t        ce_pad_000280[48];          /* 0x000280 -- 0x0003F8 */
+
+       uint64_t        ce_adm_bap_ctrl;                        /* 0x000400 */
+       uint64_t        ce_pad_000408[127];         /* 0x000408 -- 0x0007F8 */
+
+       uint64_t        ce_msg_buf_data63_0[35];    /* 0x000800 -- 0x000918 */
+       uint64_t        ce_pad_000920[29];          /* 0x000920 -- 0x0009F8 */
+
+       uint64_t        ce_msg_buf_data127_64[35];  /* 0x000A00 -- 0x000B18 */
+       uint64_t        ce_pad_000B20[29];          /* 0x000B20 -- 0x000BF8 */
+
+       uint64_t        ce_msg_buf_parity[35];      /* 0x000C00 -- 0x000D18 */
+       uint64_t        ce_pad_000D20[29];          /* 0x000D20 -- 0x000DF8 */
+
+       uint64_t        ce_pad_000E00[576];         /* 0x000E00 -- 0x001FF8 */
+
+       /*
+        * LSI : LSI's PCI Express Link Registers (Link#1 and Link#2)
+        * Link#1 MMRs at start at 0x002000, Link#2 MMRs at 0x003000
+        * NOTE: the comment offsets at far right: let 'z' = {2 or 3}
+        */
+       #define ce_lsi(link_num)        ce_lsi[link_num-1]
+       struct ce_lsi_reg {
+               uint64_t        ce_lsi_lpu_id;                  /* 0x00z000 */
+               uint64_t        ce_lsi_rst;                     /* 0x00z008 */
+               uint64_t        ce_lsi_dbg_stat;                /* 0x00z010 */
+               uint64_t        ce_lsi_dbg_cfg;                 /* 0x00z018 */
+               uint64_t        ce_lsi_ltssm_ctrl;              /* 0x00z020 */
+               uint64_t        ce_lsi_lk_stat;                 /* 0x00z028 */
+               uint64_t        ce_pad_00z030[2];   /* 0x00z030 -- 0x00z038 */
+               uint64_t        ce_lsi_int_and_stat;            /* 0x00z040 */
+               uint64_t        ce_lsi_int_mask;                /* 0x00z048 */
+               uint64_t        ce_pad_00z050[22];  /* 0x00z050 -- 0x00z0F8 */
+               uint64_t        ce_lsi_lk_perf_cnt_sel;         /* 0x00z100 */
+               uint64_t        ce_pad_00z108;                  /* 0x00z108 */
+               uint64_t        ce_lsi_lk_perf_cnt_ctrl;        /* 0x00z110 */
+               uint64_t        ce_pad_00z118;                  /* 0x00z118 */
+               uint64_t        ce_lsi_lk_perf_cnt1;            /* 0x00z120 */
+               uint64_t        ce_lsi_lk_perf_cnt1_test;       /* 0x00z128 */
+               uint64_t        ce_lsi_lk_perf_cnt2;            /* 0x00z130 */
+               uint64_t        ce_lsi_lk_perf_cnt2_test;       /* 0x00z138 */
+               uint64_t        ce_pad_00z140[24];  /* 0x00z140 -- 0x00z1F8 */
+               uint64_t        ce_lsi_lk_lyr_cfg;              /* 0x00z200 */
+               uint64_t        ce_lsi_lk_lyr_status;           /* 0x00z208 */
+               uint64_t        ce_lsi_lk_lyr_int_stat;         /* 0x00z210 */
+               uint64_t        ce_lsi_lk_ly_int_stat_test;     /* 0x00z218 */
+               uint64_t        ce_lsi_lk_ly_int_stat_mask;     /* 0x00z220 */
+               uint64_t        ce_pad_00z228[3];   /* 0x00z228 -- 0x00z238 */
+               uint64_t        ce_lsi_fc_upd_ctl;              /* 0x00z240 */
+               uint64_t        ce_pad_00z248[3];   /* 0x00z248 -- 0x00z258 */
+               uint64_t        ce_lsi_flw_ctl_upd_to_timer;    /* 0x00z260 */
+               uint64_t        ce_lsi_flw_ctl_upd_timer0;      /* 0x00z268 */
+               uint64_t        ce_lsi_flw_ctl_upd_timer1;      /* 0x00z270 */
+               uint64_t        ce_pad_00z278[49];  /* 0x00z278 -- 0x00z3F8 */
+               uint64_t        ce_lsi_freq_nak_lat_thrsh;      /* 0x00z400 */
+               uint64_t        ce_lsi_ack_nak_lat_tmr;         /* 0x00z408 */
+               uint64_t        ce_lsi_rply_tmr_thr;            /* 0x00z410 */
+               uint64_t        ce_lsi_rply_tmr;                /* 0x00z418 */
+               uint64_t        ce_lsi_rply_num_stat;           /* 0x00z420 */
+               uint64_t        ce_lsi_rty_buf_max_addr;        /* 0x00z428 */
+               uint64_t        ce_lsi_rty_fifo_ptr;            /* 0x00z430 */
+               uint64_t        ce_lsi_rty_fifo_rd_wr_ptr;      /* 0x00z438 */
+               uint64_t        ce_lsi_rty_fifo_cred;           /* 0x00z440 */
+               uint64_t        ce_lsi_seq_cnt;                 /* 0x00z448 */
+               uint64_t        ce_lsi_ack_sent_seq_num;        /* 0x00z450 */
+               uint64_t        ce_lsi_seq_cnt_fifo_max_addr;   /* 0x00z458 */
+               uint64_t        ce_lsi_seq_cnt_fifo_ptr;        /* 0x00z460 */
+               uint64_t        ce_lsi_seq_cnt_rd_wr_ptr;       /* 0x00z468 */
+               uint64_t        ce_lsi_tx_lk_ts_ctl;            /* 0x00z470 */
+               uint64_t        ce_pad_00z478;                  /* 0x00z478 */
+               uint64_t        ce_lsi_mem_addr_ctl;            /* 0x00z480 */
+               uint64_t        ce_lsi_mem_d_ld0;               /* 0x00z488 */
+               uint64_t        ce_lsi_mem_d_ld1;               /* 0x00z490 */
+               uint64_t        ce_lsi_mem_d_ld2;               /* 0x00z498 */
+               uint64_t        ce_lsi_mem_d_ld3;               /* 0x00z4A0 */
+               uint64_t        ce_lsi_mem_d_ld4;               /* 0x00z4A8 */
+               uint64_t        ce_pad_00z4B0[2];   /* 0x00z4B0 -- 0x00z4B8 */
+               uint64_t        ce_lsi_rty_d_cnt;               /* 0x00z4C0 */
+               uint64_t        ce_lsi_seq_buf_cnt;             /* 0x00z4C8 */
+               uint64_t        ce_lsi_seq_buf_bt_d;            /* 0x00z4D0 */
+               uint64_t        ce_pad_00z4D8;                  /* 0x00z4D8 */
+               uint64_t        ce_lsi_ack_lat_thr;             /* 0x00z4E0 */
+               uint64_t        ce_pad_00z4E8[3];   /* 0x00z4E8 -- 0x00z4F8 */
+               uint64_t        ce_lsi_nxt_rcv_seq_1_cntr;      /* 0x00z500 */
+               uint64_t        ce_lsi_unsp_dllp_rcvd;          /* 0x00z508 */
+               uint64_t        ce_lsi_rcv_lk_ts_ctl;           /* 0x00z510 */
+               uint64_t        ce_pad_00z518[29];  /* 0x00z518 -- 0x00z5F8 */
+               uint64_t        ce_lsi_phy_lyr_cfg;             /* 0x00z600 */
+               uint64_t        ce_pad_00z608;                  /* 0x00z608 */
+               uint64_t        ce_lsi_phy_lyr_int_stat;        /* 0x00z610 */
+               uint64_t        ce_lsi_phy_lyr_int_stat_test;   /* 0x00z618 */
+               uint64_t        ce_lsi_phy_lyr_int_mask;        /* 0x00z620 */
+               uint64_t        ce_pad_00z628[11];  /* 0x00z628 -- 0x00z678 */
+               uint64_t        ce_lsi_rcv_phy_cfg;             /* 0x00z680 */
+               uint64_t        ce_lsi_rcv_phy_stat1;           /* 0x00z688 */
+               uint64_t        ce_lsi_rcv_phy_stat2;           /* 0x00z690 */
+               uint64_t        ce_lsi_rcv_phy_stat3;           /* 0x00z698 */
+               uint64_t        ce_lsi_rcv_phy_int_stat;        /* 0x00z6A0 */
+               uint64_t        ce_lsi_rcv_phy_int_stat_test;   /* 0x00z6A8 */
+               uint64_t        ce_lsi_rcv_phy_int_mask;        /* 0x00z6B0 */
+               uint64_t        ce_pad_00z6B8[9];   /* 0x00z6B8 -- 0x00z6F8 */
+               uint64_t        ce_lsi_tx_phy_cfg;              /* 0x00z700 */
+               uint64_t        ce_lsi_tx_phy_stat;             /* 0x00z708 */
+               uint64_t        ce_lsi_tx_phy_int_stat;         /* 0x00z710 */
+               uint64_t        ce_lsi_tx_phy_int_stat_test;    /* 0x00z718 */
+               uint64_t        ce_lsi_tx_phy_int_mask;         /* 0x00z720 */
+               uint64_t        ce_lsi_tx_phy_stat2;            /* 0x00z728 */
+               uint64_t        ce_pad_00z730[10];  /* 0x00z730 -- 0x00z77F */
+               uint64_t        ce_lsi_ltssm_cfg1;              /* 0x00z780 */
+               uint64_t        ce_lsi_ltssm_cfg2;              /* 0x00z788 */
+               uint64_t        ce_lsi_ltssm_cfg3;              /* 0x00z790 */
+               uint64_t        ce_lsi_ltssm_cfg4;              /* 0x00z798 */
+               uint64_t        ce_lsi_ltssm_cfg5;              /* 0x00z7A0 */
+               uint64_t        ce_lsi_ltssm_stat1;             /* 0x00z7A8 */
+               uint64_t        ce_lsi_ltssm_stat2;             /* 0x00z7B0 */
+               uint64_t        ce_lsi_ltssm_int_stat;          /* 0x00z7B8 */
+               uint64_t        ce_lsi_ltssm_int_stat_test;     /* 0x00z7C0 */
+               uint64_t        ce_lsi_ltssm_int_mask;          /* 0x00z7C8 */
+               uint64_t        ce_lsi_ltssm_stat_wr_en;        /* 0x00z7D0 */
+               uint64_t        ce_pad_00z7D8[5];   /* 0x00z7D8 -- 0x00z7F8 */
+               uint64_t        ce_lsi_gb_cfg1;                 /* 0x00z800 */
+               uint64_t        ce_lsi_gb_cfg2;                 /* 0x00z808 */
+               uint64_t        ce_lsi_gb_cfg3;                 /* 0x00z810 */
+               uint64_t        ce_lsi_gb_cfg4;                 /* 0x00z818 */
+               uint64_t        ce_lsi_gb_stat;                 /* 0x00z820 */
+               uint64_t        ce_lsi_gb_int_stat;             /* 0x00z828 */
+               uint64_t        ce_lsi_gb_int_stat_test;        /* 0x00z830 */
+               uint64_t        ce_lsi_gb_int_mask;             /* 0x00z838 */
+               uint64_t        ce_lsi_gb_pwr_dn1;              /* 0x00z840 */
+               uint64_t        ce_lsi_gb_pwr_dn2;              /* 0x00z848 */
+               uint64_t        ce_pad_00z850[246]; /* 0x00z850 -- 0x00zFF8 */
+       } ce_lsi[2];
+
+       uint64_t        ce_pad_004000[10];          /* 0x004000 -- 0x004048 */
+
+       /*
+        * CRM: Coretalk Receive Module Registers
+        */
+       uint64_t        ce_crm_debug_mux;                       /* 0x004050 */
+       uint64_t        ce_pad_004058;                          /* 0x004058 */
+       uint64_t        ce_crm_ssp_err_cmd_wrd;                 /* 0x004060 */
+       uint64_t        ce_crm_ssp_err_addr;                    /* 0x004068 */
+       uint64_t        ce_crm_ssp_err_syn;                     /* 0x004070 */
+
+       uint64_t        ce_pad_004078[499];         /* 0x004078 -- 0x005008 */
+
+       /*
+         * CXM: Coretalk Xmit Module Registers
+         */
+       uint64_t        ce_cxm_dyn_credit_status;               /* 0x005010 */
+       uint64_t        ce_cxm_last_credit_status;              /* 0x005018 */
+       uint64_t        ce_cxm_credit_limit;                    /* 0x005020 */
+       uint64_t        ce_cxm_force_credit;                    /* 0x005028 */
+       uint64_t        ce_cxm_disable_bypass;                  /* 0x005030 */
+       uint64_t        ce_pad_005038[3];           /* 0x005038 -- 0x005048 */
+       uint64_t        ce_cxm_debug_mux;                       /* 0x005050 */
+
+        uint64_t        ce_pad_005058[501];         /* 0x005058 -- 0x005FF8 */
+
+       /*
+        * DTL: Downstream Transaction Layer Regs (Link#1 and Link#2)
+        * DTL: Link#1 MMRs at start at 0x006000, Link#2 MMRs at 0x008000
+        * DTL: the comment offsets at far right: let 'y' = {6 or 8}
+        *
+        * UTL: Downstream Transaction Layer Regs (Link#1 and Link#2)
+        * UTL: Link#1 MMRs at start at 0x007000, Link#2 MMRs at 0x009000
+        * UTL: the comment offsets at far right: let 'z' = {7 or 9}
+        */
+       #define ce_dtl(link_num)        ce_dtl_utl[link_num-1]
+       #define ce_utl(link_num)        ce_dtl_utl[link_num-1]
+       struct ce_dtl_utl_reg {
+               /* DTL */
+               uint64_t        ce_dtl_dtdr_credit_limit;       /* 0x00y000 */
+               uint64_t        ce_dtl_dtdr_credit_force;       /* 0x00y008 */
+               uint64_t        ce_dtl_dyn_credit_status;       /* 0x00y010 */
+               uint64_t        ce_dtl_dtl_last_credit_stat;    /* 0x00y018 */
+               uint64_t        ce_dtl_dtl_ctrl;                /* 0x00y020 */
+               uint64_t        ce_pad_00y028[5];   /* 0x00y028 -- 0x00y048 */
+               uint64_t        ce_dtl_debug_sel;               /* 0x00y050 */
+               uint64_t        ce_pad_00y058[501]; /* 0x00y058 -- 0x00yFF8 */
+
+               /* UTL */
+               uint64_t        ce_utl_utl_ctrl;                /* 0x00z000 */
+               uint64_t        ce_utl_debug_sel;               /* 0x00z008 */
+               uint64_t        ce_pad_00z010[510]; /* 0x00z010 -- 0x00zFF8 */
+       } ce_dtl_utl[2];
+
+       uint64_t        ce_pad_00A000[514];         /* 0x00A000 -- 0x00B008 */
+
+       /*
+        * URE: Upstream Request Engine
+         */
+       uint64_t        ce_ure_dyn_credit_status;               /* 0x00B010 */
+       uint64_t        ce_ure_last_credit_status;              /* 0x00B018 */
+       uint64_t        ce_ure_credit_limit;                    /* 0x00B020 */
+       uint64_t        ce_pad_00B028;                          /* 0x00B028 */
+       uint64_t        ce_ure_control;                         /* 0x00B030 */
+       uint64_t        ce_ure_status;                          /* 0x00B038 */
+       uint64_t        ce_pad_00B040[2];           /* 0x00B040 -- 0x00B048 */
+       uint64_t        ce_ure_debug_sel;                       /* 0x00B050 */
+       uint64_t        ce_ure_pcie_debug_sel;                  /* 0x00B058 */
+       uint64_t        ce_ure_ssp_err_cmd_wrd;                 /* 0x00B060 */
+       uint64_t        ce_ure_ssp_err_addr;                    /* 0x00B068 */
+       uint64_t        ce_ure_page_map;                        /* 0x00B070 */
+       uint64_t        ce_ure_dir_map[TIOCE_NUM_PORTS];        /* 0x00B078 */
+       uint64_t        ce_ure_pipe_sel1;                       /* 0x00B088 */
+       uint64_t        ce_ure_pipe_mask1;                      /* 0x00B090 */
+       uint64_t        ce_ure_pipe_sel2;                       /* 0x00B098 */
+       uint64_t        ce_ure_pipe_mask2;                      /* 0x00B0A0 */
+       uint64_t        ce_ure_pcie1_credits_sent;              /* 0x00B0A8 */
+       uint64_t        ce_ure_pcie1_credits_used;              /* 0x00B0B0 */
+       uint64_t        ce_ure_pcie1_credit_limit;              /* 0x00B0B8 */
+       uint64_t        ce_ure_pcie2_credits_sent;              /* 0x00B0C0 */
+       uint64_t        ce_ure_pcie2_credits_used;              /* 0x00B0C8 */
+       uint64_t        ce_ure_pcie2_credit_limit;              /* 0x00B0D0 */
+       uint64_t        ce_ure_pcie_force_credit;               /* 0x00B0D8 */
+       uint64_t        ce_ure_rd_tnum_val;                     /* 0x00B0E0 */
+       uint64_t        ce_ure_rd_tnum_rsp_rcvd;                /* 0x00B0E8 */
+       uint64_t        ce_ure_rd_tnum_esent_timer;             /* 0x00B0F0 */
+       uint64_t        ce_ure_rd_tnum_error;                   /* 0x00B0F8 */
+       uint64_t        ce_ure_rd_tnum_first_cl;                /* 0x00B100 */
+       uint64_t        ce_ure_rd_tnum_link_buf;                /* 0x00B108 */
+       uint64_t        ce_ure_wr_tnum_val;                     /* 0x00B110 */
+       uint64_t        ce_ure_sram_err_addr0;                  /* 0x00B118 */
+       uint64_t        ce_ure_sram_err_addr1;                  /* 0x00B120 */
+       uint64_t        ce_ure_sram_err_addr2;                  /* 0x00B128 */
+       uint64_t        ce_ure_sram_rd_addr0;                   /* 0x00B130 */
+       uint64_t        ce_ure_sram_rd_addr1;                   /* 0x00B138 */
+       uint64_t        ce_ure_sram_rd_addr2;                   /* 0x00B140 */
+       uint64_t        ce_ure_sram_wr_addr0;                   /* 0x00B148 */
+       uint64_t        ce_ure_sram_wr_addr1;                   /* 0x00B150 */
+       uint64_t        ce_ure_sram_wr_addr2;                   /* 0x00B158 */
+       uint64_t        ce_ure_buf_flush10;                     /* 0x00B160 */
+       uint64_t        ce_ure_buf_flush11;                     /* 0x00B168 */
+       uint64_t        ce_ure_buf_flush12;                     /* 0x00B170 */
+       uint64_t        ce_ure_buf_flush13;                     /* 0x00B178 */
+       uint64_t        ce_ure_buf_flush20;                     /* 0x00B180 */
+       uint64_t        ce_ure_buf_flush21;                     /* 0x00B188 */
+       uint64_t        ce_ure_buf_flush22;                     /* 0x00B190 */
+       uint64_t        ce_ure_buf_flush23;                     /* 0x00B198 */
+       uint64_t        ce_ure_pcie_control1;                   /* 0x00B1A0 */
+       uint64_t        ce_ure_pcie_control2;                   /* 0x00B1A8 */
+
+       uint64_t        ce_pad_00B1B0[458];         /* 0x00B1B0 -- 0x00BFF8 */
+
+       /* Upstream Data Buffer, Port1 */
+       struct ce_ure_maint_ups_dat1_data {
+               uint64_t        data63_0[512];      /* 0x00C000 -- 0x00CFF8 */
+               uint64_t        data127_64[512];    /* 0x00D000 -- 0x00DFF8 */
+               uint64_t        parity[512];        /* 0x00E000 -- 0x00EFF8 */
+       } ce_ure_maint_ups_dat1;
+
+       /* Upstream Header Buffer, Port1 */
+       struct ce_ure_maint_ups_hdr1_data {
+               uint64_t        data63_0[512];      /* 0x00F000 -- 0x00FFF8 */
+               uint64_t        data127_64[512];    /* 0x010000 -- 0x010FF8 */
+               uint64_t        parity[512];        /* 0x011000 -- 0x011FF8 */
+       } ce_ure_maint_ups_hdr1;
+
+       /* Upstream Data Buffer, Port2 */
+       struct ce_ure_maint_ups_dat2_data {
+               uint64_t        data63_0[512];      /* 0x012000 -- 0x012FF8 */
+               uint64_t        data127_64[512];    /* 0x013000 -- 0x013FF8 */
+               uint64_t        parity[512];        /* 0x014000 -- 0x014FF8 */
+       } ce_ure_maint_ups_dat2;
+
+       /* Upstream Header Buffer, Port2 */
+       struct ce_ure_maint_ups_hdr2_data {
+               uint64_t        data63_0[512];      /* 0x015000 -- 0x015FF8 */
+               uint64_t        data127_64[512];    /* 0x016000 -- 0x016FF8 */
+               uint64_t        parity[512];        /* 0x017000 -- 0x017FF8 */
+       } ce_ure_maint_ups_hdr2;
+
+       /* Downstream Data Buffer */
+       struct ce_ure_maint_dns_dat_data {
+               uint64_t        data63_0[512];      /* 0x018000 -- 0x018FF8 */
+               uint64_t        data127_64[512];    /* 0x019000 -- 0x019FF8 */
+               uint64_t        parity[512];        /* 0x01A000 -- 0x01AFF8 */
+       } ce_ure_maint_dns_dat;
+
+       /* Downstream Header Buffer */
+       struct  ce_ure_maint_dns_hdr_data {
+               uint64_t        data31_0[64];       /* 0x01B000 -- 0x01B1F8 */
+               uint64_t        data95_32[64];      /* 0x01B200 -- 0x01B3F8 */
+               uint64_t        parity[64];         /* 0x01B400 -- 0x01B5F8 */
+       } ce_ure_maint_dns_hdr;
+
+       /* RCI Buffer Data */
+       struct  ce_ure_maint_rci_data {
+               uint64_t        data41_0[64];       /* 0x01B600 -- 0x01B7F8 */
+               uint64_t        data69_42[64];      /* 0x01B800 -- 0x01B9F8 */
+       } ce_ure_maint_rci;
+
+       /* Response Queue */
+       uint64_t        ce_ure_maint_rspq[64];      /* 0x01BA00 -- 0x01BBF8 */
+
+       uint64_t        ce_pad_01C000[4224];        /* 0x01BC00 -- 0x023FF8 */
+
+       /* Admin Build-a-Packet Buffer */
+       struct  ce_adm_maint_bap_buf_data {
+               uint64_t        data63_0[258];      /* 0x024000 -- 0x024808 */
+               uint64_t        data127_64[258];    /* 0x024810 -- 0x025018 */
+               uint64_t        parity[258];        /* 0x025020 -- 0x025828 */
+       } ce_adm_maint_bap_buf;
+
+       uint64_t        ce_pad_025830[5370];        /* 0x025830 -- 0x02FFF8 */
+
+       /* URE: 40bit PMU ATE Buffer */             /* 0x030000 -- 0x037FF8 */
+       uint64_t        ce_ure_ate40[TIOCE_NUM_M40_ATES];
+
+       /* URE: 32/40bit PMU ATE Buffer */          /* 0x038000 -- 0x03BFF8 */
+       uint64_t        ce_ure_ate3240[TIOCE_NUM_M3240_ATES];
+
+       uint64_t        ce_pad_03C000[2050];        /* 0x03C000 -- 0x040008 */
+
+       /*
+        * DRE: Down Stream Request Engine
+         */
+       uint64_t        ce_dre_dyn_credit_status1;              /* 0x040010 */
+       uint64_t        ce_dre_dyn_credit_status2;              /* 0x040018 */
+       uint64_t        ce_dre_last_credit_status1;             /* 0x040020 */
+       uint64_t        ce_dre_last_credit_status2;             /* 0x040028 */
+       uint64_t        ce_dre_credit_limit1;                   /* 0x040030 */
+       uint64_t        ce_dre_credit_limit2;                   /* 0x040038 */
+       uint64_t        ce_dre_force_credit1;                   /* 0x040040 */
+       uint64_t        ce_dre_force_credit2;                   /* 0x040048 */
+       uint64_t        ce_dre_debug_mux1;                      /* 0x040050 */
+       uint64_t        ce_dre_debug_mux2;                      /* 0x040058 */
+       uint64_t        ce_dre_ssp_err_cmd_wrd;                 /* 0x040060 */
+       uint64_t        ce_dre_ssp_err_addr;                    /* 0x040068 */
+       uint64_t        ce_dre_comp_err_cmd_wrd;                /* 0x040070 */
+       uint64_t        ce_dre_comp_err_addr;                   /* 0x040078 */
+       uint64_t        ce_dre_req_status;                      /* 0x040080 */
+       uint64_t        ce_dre_config1;                         /* 0x040088 */
+       uint64_t        ce_dre_config2;                         /* 0x040090 */
+       uint64_t        ce_dre_config_req_status;               /* 0x040098 */
+       uint64_t        ce_pad_0400A0[12];          /* 0x0400A0 -- 0x0400F8 */
+       uint64_t        ce_dre_dyn_fifo;                        /* 0x040100 */
+       uint64_t        ce_pad_040108[3];           /* 0x040108 -- 0x040118 */
+       uint64_t        ce_dre_last_fifo;                       /* 0x040120 */
+
+       uint64_t        ce_pad_040128[27];          /* 0x040128 -- 0x0401F8 */
+
+       /* DRE Downstream Head Queue */
+       struct  ce_dre_maint_ds_head_queue {
+               uint64_t        data63_0[32];       /* 0x040200 -- 0x0402F8 */
+               uint64_t        data127_64[32];     /* 0x040300 -- 0x0403F8 */
+               uint64_t        parity[32];         /* 0x040400 -- 0x0404F8 */
+       } ce_dre_maint_ds_head_q;
+
+       uint64_t        ce_pad_040500[352];         /* 0x040500 -- 0x040FF8 */
+
+       /* DRE Downstream Data Queue */
+       struct  ce_dre_maint_ds_data_queue {
+               uint64_t        data63_0[256];      /* 0x041000 -- 0x0417F8 */
+               uint64_t        ce_pad_041800[256]; /* 0x041800 -- 0x041FF8 */
+               uint64_t        data127_64[256];    /* 0x042000 -- 0x0427F8 */
+               uint64_t        ce_pad_042800[256]; /* 0x042800 -- 0x042FF8 */
+               uint64_t        parity[256];        /* 0x043000 -- 0x0437F8 */
+               uint64_t        ce_pad_043800[256]; /* 0x043800 -- 0x043FF8 */
+       } ce_dre_maint_ds_data_q;
+
+       /* DRE URE Upstream Response Queue */
+       struct  ce_dre_maint_ure_us_rsp_queue {
+               uint64_t        data63_0[8];        /* 0x044000 -- 0x044038 */
+               uint64_t        ce_pad_044040[24];  /* 0x044040 -- 0x0440F8 */
+               uint64_t        data127_64[8];      /* 0x044100 -- 0x044138 */
+               uint64_t        ce_pad_044140[24];  /* 0x044140 -- 0x0441F8 */
+               uint64_t        parity[8];          /* 0x044200 -- 0x044238 */
+               uint64_t        ce_pad_044240[24];  /* 0x044240 -- 0x0442F8 */
+       } ce_dre_maint_ure_us_rsp_q;
+
+       uint64_t        ce_dre_maint_us_wrt_rsp[32];/* 0x044300 -- 0x0443F8 */
+
+       uint64_t        ce_end_of_struct;                       /* 0x044400 */
+} tioce_t;
+
+
+/* ce_adm_int_mask/ce_adm_int_status register bit defines */
+#define CE_ADM_INT_CE_ERROR_SHFT               0
+#define CE_ADM_INT_LSI1_IP_ERROR_SHFT          1
+#define CE_ADM_INT_LSI2_IP_ERROR_SHFT          2
+#define CE_ADM_INT_PCIE_ERROR_SHFT             3
+#define CE_ADM_INT_PORT1_HOTPLUG_EVENT_SHFT    4
+#define CE_ADM_INT_PORT2_HOTPLUG_EVENT_SHFT    5
+#define CE_ADM_INT_PCIE_PORT1_DEV_A_SHFT       6
+#define CE_ADM_INT_PCIE_PORT1_DEV_B_SHFT       7
+#define CE_ADM_INT_PCIE_PORT1_DEV_C_SHFT       8
+#define CE_ADM_INT_PCIE_PORT1_DEV_D_SHFT       9
+#define CE_ADM_INT_PCIE_PORT2_DEV_A_SHFT       10
+#define CE_ADM_INT_PCIE_PORT2_DEV_B_SHFT       11
+#define CE_ADM_INT_PCIE_PORT2_DEV_C_SHFT       12
+#define CE_ADM_INT_PCIE_PORT2_DEV_D_SHFT       13
+#define CE_ADM_INT_PCIE_MSG_SHFT               14 /*see int_dest_14*/
+#define CE_ADM_INT_PCIE_MSG_SLOT_0_SHFT                14
+#define CE_ADM_INT_PCIE_MSG_SLOT_1_SHFT                15
+#define CE_ADM_INT_PCIE_MSG_SLOT_2_SHFT                16
+#define CE_ADM_INT_PCIE_MSG_SLOT_3_SHFT                17
+#define CE_ADM_INT_PORT1_PM_PME_MSG_SHFT       22
+#define CE_ADM_INT_PORT2_PM_PME_MSG_SHFT       23
+
+/* ce_adm_force_int register bit defines */
+#define CE_ADM_FORCE_INT_PCIE_PORT1_DEV_A_SHFT 0
+#define CE_ADM_FORCE_INT_PCIE_PORT1_DEV_B_SHFT 1
+#define CE_ADM_FORCE_INT_PCIE_PORT1_DEV_C_SHFT 2
+#define CE_ADM_FORCE_INT_PCIE_PORT1_DEV_D_SHFT 3
+#define CE_ADM_FORCE_INT_PCIE_PORT2_DEV_A_SHFT 4
+#define CE_ADM_FORCE_INT_PCIE_PORT2_DEV_B_SHFT 5
+#define CE_ADM_FORCE_INT_PCIE_PORT2_DEV_C_SHFT 6
+#define CE_ADM_FORCE_INT_PCIE_PORT2_DEV_D_SHFT 7
+#define CE_ADM_FORCE_INT_ALWAYS_SHFT           8
+
+/* ce_adm_int_dest register bit masks & shifts */
+#define INTR_VECTOR_SHFT                       56
+
+/* ce_adm_error_mask and ce_adm_error_summary register bit masks */
+#define CE_ADM_ERR_CRM_SSP_REQ_INVALID                 (0x1ULL <<  0)
+#define CE_ADM_ERR_SSP_REQ_HEADER                      (0x1ULL <<  1)
+#define CE_ADM_ERR_SSP_RSP_HEADER                      (0x1ULL <<  2)
+#define CE_ADM_ERR_SSP_PROTOCOL_ERROR                  (0x1ULL <<  3)
+#define CE_ADM_ERR_SSP_SBE                             (0x1ULL <<  4)
+#define CE_ADM_ERR_SSP_MBE                             (0x1ULL <<  5)
+#define CE_ADM_ERR_CXM_CREDIT_OFLOW                    (0x1ULL <<  6)
+#define CE_ADM_ERR_DRE_SSP_REQ_INVAL                   (0x1ULL <<  7)
+#define CE_ADM_ERR_SSP_REQ_LONG                                (0x1ULL <<  8)
+#define CE_ADM_ERR_SSP_REQ_OFLOW                       (0x1ULL <<  9)
+#define CE_ADM_ERR_SSP_REQ_SHORT                       (0x1ULL << 10)
+#define CE_ADM_ERR_SSP_REQ_SIDEBAND                    (0x1ULL << 11)
+#define CE_ADM_ERR_SSP_REQ_ADDR_ERR                    (0x1ULL << 12)
+#define CE_ADM_ERR_SSP_REQ_BAD_BE                      (0x1ULL << 13)
+#define CE_ADM_ERR_PCIE_COMPL_TIMEOUT                  (0x1ULL << 14)
+#define CE_ADM_ERR_PCIE_UNEXP_COMPL                    (0x1ULL << 15)
+#define CE_ADM_ERR_PCIE_ERR_COMPL                      (0x1ULL << 16)
+#define CE_ADM_ERR_DRE_CREDIT_OFLOW                    (0x1ULL << 17)
+#define CE_ADM_ERR_DRE_SRAM_PE                         (0x1ULL << 18)
+#define CE_ADM_ERR_SSP_RSP_INVALID                     (0x1ULL << 19)
+#define CE_ADM_ERR_SSP_RSP_LONG                                (0x1ULL << 20)
+#define CE_ADM_ERR_SSP_RSP_SHORT                       (0x1ULL << 21)
+#define CE_ADM_ERR_SSP_RSP_SIDEBAND                    (0x1ULL << 22)
+#define CE_ADM_ERR_URE_SSP_RSP_UNEXP                   (0x1ULL << 23)
+#define CE_ADM_ERR_URE_SSP_WR_REQ_TIMEOUT              (0x1ULL << 24)
+#define CE_ADM_ERR_URE_SSP_RD_REQ_TIMEOUT              (0x1ULL << 25)
+#define CE_ADM_ERR_URE_ATE3240_PAGE_FAULT              (0x1ULL << 26)
+#define CE_ADM_ERR_URE_ATE40_PAGE_FAULT                        (0x1ULL << 27)
+#define CE_ADM_ERR_URE_CREDIT_OFLOW                    (0x1ULL << 28)
+#define CE_ADM_ERR_URE_SRAM_PE                         (0x1ULL << 29)
+#define CE_ADM_ERR_ADM_SSP_RSP_UNEXP                   (0x1ULL << 30)
+#define CE_ADM_ERR_ADM_SSP_REQ_TIMEOUT                 (0x1ULL << 31)
+#define CE_ADM_ERR_MMR_ACCESS_ERROR                    (0x1ULL << 32)
+#define CE_ADM_ERR_MMR_ADDR_ERROR                      (0x1ULL << 33)
+#define CE_ADM_ERR_ADM_CREDIT_OFLOW                    (0x1ULL << 34)
+#define CE_ADM_ERR_ADM_SRAM_PE                         (0x1ULL << 35)
+#define CE_ADM_ERR_DTL1_MIN_PDATA_CREDIT_ERR           (0x1ULL << 36)
+#define CE_ADM_ERR_DTL1_INF_COMPL_CRED_UPDT_ERR                (0x1ULL << 37)
+#define CE_ADM_ERR_DTL1_INF_POSTED_CRED_UPDT_ERR       (0x1ULL << 38)
+#define CE_ADM_ERR_DTL1_INF_NPOSTED_CRED_UPDT_ERR      (0x1ULL << 39)
+#define CE_ADM_ERR_DTL1_COMP_HD_CRED_MAX_ERR           (0x1ULL << 40)
+#define CE_ADM_ERR_DTL1_COMP_D_CRED_MAX_ERR            (0x1ULL << 41)
+#define CE_ADM_ERR_DTL1_NPOSTED_HD_CRED_MAX_ERR                (0x1ULL << 42)
+#define CE_ADM_ERR_DTL1_NPOSTED_D_CRED_MAX_ERR         (0x1ULL << 43)
+#define CE_ADM_ERR_DTL1_POSTED_HD_CRED_MAX_ERR         (0x1ULL << 44)
+#define CE_ADM_ERR_DTL1_POSTED_D_CRED_MAX_ERR          (0x1ULL << 45)
+#define CE_ADM_ERR_DTL2_MIN_PDATA_CREDIT_ERR           (0x1ULL << 46)
+#define CE_ADM_ERR_DTL2_INF_COMPL_CRED_UPDT_ERR                (0x1ULL << 47)
+#define CE_ADM_ERR_DTL2_INF_POSTED_CRED_UPDT_ERR       (0x1ULL << 48)
+#define CE_ADM_ERR_DTL2_INF_NPOSTED_CRED_UPDT_ERR      (0x1ULL << 49)
+#define CE_ADM_ERR_DTL2_COMP_HD_CRED_MAX_ERR           (0x1ULL << 50)
+#define CE_ADM_ERR_DTL2_COMP_D_CRED_MAX_ERR            (0x1ULL << 51)
+#define CE_ADM_ERR_DTL2_NPOSTED_HD_CRED_MAX_ERR                (0x1ULL << 52)
+#define CE_ADM_ERR_DTL2_NPOSTED_D_CRED_MAX_ERR         (0x1ULL << 53)
+#define CE_ADM_ERR_DTL2_POSTED_HD_CRED_MAX_ERR         (0x1ULL << 54)
+#define CE_ADM_ERR_DTL2_POSTED_D_CRED_MAX_ERR          (0x1ULL << 55)
+#define CE_ADM_ERR_PORT1_PCIE_COR_ERR                  (0x1ULL << 56)
+#define CE_ADM_ERR_PORT1_PCIE_NFAT_ERR                 (0x1ULL << 57)
+#define CE_ADM_ERR_PORT1_PCIE_FAT_ERR                  (0x1ULL << 58)
+#define CE_ADM_ERR_PORT2_PCIE_COR_ERR                  (0x1ULL << 59)
+#define CE_ADM_ERR_PORT2_PCIE_NFAT_ERR                 (0x1ULL << 60)
+#define CE_ADM_ERR_PORT2_PCIE_FAT_ERR                  (0x1ULL << 61)
+
+/* ce_adm_ure_ups_buf_barrier_flush register bit masks and shifts */
+#define FLUSH_SEL_PORT1_PIPE0_SHFT     0
+#define FLUSH_SEL_PORT1_PIPE1_SHFT     4
+#define FLUSH_SEL_PORT1_PIPE2_SHFT     8
+#define FLUSH_SEL_PORT1_PIPE3_SHFT     12
+#define FLUSH_SEL_PORT2_PIPE0_SHFT     16
+#define FLUSH_SEL_PORT2_PIPE1_SHFT     20
+#define FLUSH_SEL_PORT2_PIPE2_SHFT     24
+#define FLUSH_SEL_PORT2_PIPE3_SHFT     28
+
+/* ce_dre_config1 register bit masks and shifts */
+#define CE_DRE_RO_ENABLE               (0x1ULL << 0)
+#define CE_DRE_DYN_RO_ENABLE           (0x1ULL << 1)
+#define CE_DRE_SUP_CONFIG_COMP_ERROR   (0x1ULL << 2)
+#define CE_DRE_SUP_IO_COMP_ERROR       (0x1ULL << 3)
+#define CE_DRE_ADDR_MODE_SHFT          4
+
+/* ce_dre_config_req_status register bit masks */
+#define CE_DRE_LAST_CONFIG_COMPLETION  (0x7ULL << 0)
+#define CE_DRE_DOWNSTREAM_CONFIG_ERROR (0x1ULL << 3)
+#define CE_DRE_CONFIG_COMPLETION_VALID (0x1ULL << 4)
+#define CE_DRE_CONFIG_REQUEST_ACTIVE   (0x1ULL << 5)
+
+/* ce_ure_control register bit masks & shifts */
+#define CE_URE_RD_MRG_ENABLE           (0x1ULL << 0)
+#define CE_URE_WRT_MRG_ENABLE1         (0x1ULL << 4)
+#define CE_URE_WRT_MRG_ENABLE2         (0x1ULL << 5)
+#define CE_URE_RSPQ_BYPASS_DISABLE     (0x1ULL << 24)
+#define CE_URE_UPS_DAT1_PAR_DISABLE    (0x1ULL << 32)
+#define CE_URE_UPS_HDR1_PAR_DISABLE    (0x1ULL << 33)
+#define CE_URE_UPS_DAT2_PAR_DISABLE    (0x1ULL << 34)
+#define CE_URE_UPS_HDR2_PAR_DISABLE    (0x1ULL << 35)
+#define CE_URE_ATE_PAR_DISABLE         (0x1ULL << 36)
+#define CE_URE_RCI_PAR_DISABLE         (0x1ULL << 37)
+#define CE_URE_RSPQ_PAR_DISABLE                (0x1ULL << 38)
+#define CE_URE_DNS_DAT_PAR_DISABLE     (0x1ULL << 39)
+#define CE_URE_DNS_HDR_PAR_DISABLE     (0x1ULL << 40)
+#define CE_URE_MALFORM_DISABLE         (0x1ULL << 44)
+#define CE_URE_UNSUP_DISABLE           (0x1ULL << 45)
+
+/* ce_ure_page_map register bit masks & shifts */
+#define CE_URE_ATE3240_ENABLE          (0x1ULL << 0)
+#define CE_URE_ATE40_ENABLE            (0x1ULL << 1)
+#define CE_URE_PAGESIZE_SHFT           4
+#define CE_URE_PAGESIZE_MASK           (0x7ULL << CE_URE_PAGESIZE_SHFT)
+#define CE_URE_4K_PAGESIZE             (0x0ULL << CE_URE_PAGESIZE_SHFT)
+#define CE_URE_16K_PAGESIZE            (0x1ULL << CE_URE_PAGESIZE_SHFT)
+#define CE_URE_64K_PAGESIZE            (0x2ULL << CE_URE_PAGESIZE_SHFT)
+#define CE_URE_128K_PAGESIZE           (0x3ULL << CE_URE_PAGESIZE_SHFT)
+#define CE_URE_256K_PAGESIZE           (0x4ULL << CE_URE_PAGESIZE_SHFT)
+
+/* ce_ure_pipe_sel register bit masks & shifts */
+#define PKT_TRAFIC_SHRT                        16
+#define BUS_SRC_ID_SHFT                        8
+#define DEV_SRC_ID_SHFT                        3
+#define FNC_SRC_ID_SHFT                        0
+#define CE_URE_TC_MASK                 (0x07ULL << PKT_TRAFIC_SHRT)
+#define CE_URE_BUS_MASK                        (0xFFULL << BUS_SRC_ID_SHFT)
+#define CE_URE_DEV_MASK                        (0x1FULL << DEV_SRC_ID_SHFT)
+#define CE_URE_FNC_MASK                        (0x07ULL << FNC_SRC_ID_SHFT)
+#define CE_URE_PIPE_BUS(b)             (((uint64_t)(b) << BUS_SRC_ID_SHFT) & \
+                                        CE_URE_BUS_MASK)
+#define CE_URE_PIPE_DEV(d)             (((uint64_t)(d) << DEV_SRC_ID_SHFT) & \
+                                        CE_URE_DEV_MASK)
+#define CE_URE_PIPE_FNC(f)             (((uint64_t)(f) << FNC_SRC_ID_SHFT) & \
+                                        CE_URE_FNC_MASK)
+
+#define CE_URE_SEL1_SHFT               0
+#define CE_URE_SEL2_SHFT               20
+#define CE_URE_SEL3_SHFT               40
+#define CE_URE_SEL1_MASK               (0x7FFFFULL << CE_URE_SEL1_SHFT)
+#define CE_URE_SEL2_MASK               (0x7FFFFULL << CE_URE_SEL2_SHFT)
+#define CE_URE_SEL3_MASK               (0x7FFFFULL << CE_URE_SEL3_SHFT)
+
+
+/* ce_ure_pipe_mask register bit masks & shifts */
+#define CE_URE_MASK1_SHFT              0
+#define CE_URE_MASK2_SHFT              20
+#define CE_URE_MASK3_SHFT              40
+#define CE_URE_MASK1_MASK              (0x7FFFFULL << CE_URE_MASK1_SHFT)
+#define CE_URE_MASK2_MASK              (0x7FFFFULL << CE_URE_MASK2_SHFT)
+#define CE_URE_MASK3_MASK              (0x7FFFFULL << CE_URE_MASK3_SHFT)
+
+
+/* ce_ure_pcie_control1 register bit masks & shifts */
+#define CE_URE_SI                      (0x1ULL << 0)
+#define CE_URE_ELAL_SHFT               4
+#define CE_URE_ELAL_MASK               (0x7ULL << CE_URE_ELAL_SHFT)
+#define CE_URE_ELAL1_SHFT              8
+#define CE_URE_ELAL1_MASK              (0x7ULL << CE_URE_ELAL1_SHFT)
+#define CE_URE_SCC                     (0x1ULL << 12)
+#define CE_URE_PN1_SHFT                        16
+#define CE_URE_PN1_MASK                        (0xFFULL << CE_URE_PN1_SHFT)
+#define CE_URE_PN2_SHFT                        24
+#define CE_URE_PN2_MASK                        (0xFFULL << CE_URE_PN2_SHFT)
+#define CE_URE_PN1_SET(n)              (((uint64_t)(n) << CE_URE_PN1_SHFT) & \
+                                        CE_URE_PN1_MASK)
+#define CE_URE_PN2_SET(n)              (((uint64_t)(n) << CE_URE_PN2_SHFT) & \
+                                        CE_URE_PN2_MASK)
+
+/* ce_ure_pcie_control2 register bit masks & shifts */
+#define CE_URE_ABP                     (0x1ULL << 0)
+#define CE_URE_PCP                     (0x1ULL << 1)
+#define CE_URE_MSP                     (0x1ULL << 2)
+#define CE_URE_AIP                     (0x1ULL << 3)
+#define CE_URE_PIP                     (0x1ULL << 4)
+#define CE_URE_HPS                     (0x1ULL << 5)
+#define CE_URE_HPC                     (0x1ULL << 6)
+#define CE_URE_SPLV_SHFT               7
+#define CE_URE_SPLV_MASK               (0xFFULL << CE_URE_SPLV_SHFT)
+#define CE_URE_SPLS_SHFT               15
+#define CE_URE_SPLS_MASK               (0x3ULL << CE_URE_SPLS_SHFT)
+#define CE_URE_PSN1_SHFT               19
+#define CE_URE_PSN1_MASK               (0x1FFFULL << CE_URE_PSN1_SHFT)
+#define CE_URE_PSN2_SHFT               32
+#define CE_URE_PSN2_MASK               (0x1FFFULL << CE_URE_PSN2_SHFT)
+#define CE_URE_PSN1_SET(n)             (((uint64_t)(n) << CE_URE_PSN1_SHFT) & \
+                                        CE_URE_PSN1_MASK)
+#define CE_URE_PSN2_SET(n)             (((uint64_t)(n) << CE_URE_PSN2_SHFT) & \
+                                        CE_URE_PSN2_MASK)
+
+/*
+ * PIO address space ranges for CE
+ */
+
+/* Local CE Registers Space */
+#define CE_PIO_MMR                     0x00000000
+#define CE_PIO_MMR_LEN                 0x04000000
+
+/* PCI Compatible Config Space */
+#define CE_PIO_CONFIG_SPACE            0x04000000
+#define CE_PIO_CONFIG_SPACE_LEN                0x04000000
+
+/* PCI I/O Space Alias */
+#define CE_PIO_IO_SPACE_ALIAS          0x08000000
+#define CE_PIO_IO_SPACE_ALIAS_LEN      0x08000000
+
+/* PCI Enhanced Config Space */
+#define CE_PIO_E_CONFIG_SPACE          0x10000000
+#define CE_PIO_E_CONFIG_SPACE_LEN      0x10000000
+
+/* PCI I/O Space */
+#define CE_PIO_IO_SPACE                        0x100000000
+#define CE_PIO_IO_SPACE_LEN            0x100000000
+
+/* PCI MEM Space */
+#define CE_PIO_MEM_SPACE               0x200000000
+#define CE_PIO_MEM_SPACE_LEN           TIO_HWIN_SIZE
+
+
+/*
+ * CE PCI Enhanced Config Space shifts & masks
+ */
+#define CE_E_CONFIG_BUS_SHFT           20
+#define CE_E_CONFIG_BUS_MASK           (0xFF << CE_E_CONFIG_BUS_SHFT)
+#define CE_E_CONFIG_DEVICE_SHFT                15
+#define CE_E_CONFIG_DEVICE_MASK                (0x1F << CE_E_CONFIG_DEVICE_SHFT)
+#define CE_E_CONFIG_FUNC_SHFT          12
+#define CE_E_CONFIG_FUNC_MASK          (0x7  << CE_E_CONFIG_FUNC_SHFT)
+
+#endif /* __ASM_IA64_SN_TIOCE_H__ */
diff --git a/include/asm-ia64/sn/tioce_provider.h b/include/asm-ia64/sn/tioce_provider.h
new file mode 100644 (file)
index 0000000..7f63dec
--- /dev/null
@@ -0,0 +1,66 @@
+/**************************************************************************
+ *             Copyright (C) 2005, Silicon Graphics, Inc.                 *
+ *                                                                       *
+ *  These coded instructions, statements, and computer programs         contain  *
+ *  unpublished         proprietary  information of Silicon Graphics, Inc., and  *
+ *  are protected by Federal copyright law.  They  may not be disclosed  *
+ *  to third  parties  or copied or duplicated in any form, in whole or  *
+ *  in part, without the prior written consent of Silicon Graphics, Inc.  *
+ *                                                                       *
+ **************************************************************************/
+
+#ifndef _ASM_IA64_SN_CE_PROVIDER_H
+#define _ASM_IA64_SN_CE_PROVIDER_H
+
+#include <asm/sn/pcibus_provider_defs.h>
+#include <asm/sn/tioce.h>
+
+/*
+ * Common TIOCE structure shared between the prom and kernel
+ *
+ * DO NOT CHANGE THIS STRUCT WITHOUT MAKING CORRESPONDING CHANGES TO THE
+ * PROM VERSION.
+ */
+struct tioce_common {
+       struct pcibus_bussoft   ce_pcibus;      /* common pciio header */
+
+       uint32_t                ce_rev;
+       uint64_t                ce_kernel_private;
+       uint64_t                ce_prom_private;
+};
+
+struct tioce_kernel {
+       struct tioce_common     *ce_common;
+       spinlock_t              ce_lock;
+       struct list_head        ce_dmamap_list;
+
+       uint64_t                ce_ate40_shadow[TIOCE_NUM_M40_ATES];
+       uint64_t                ce_ate3240_shadow[TIOCE_NUM_M3240_ATES];
+       uint32_t                ce_ate3240_pagesize;
+
+       uint8_t                 ce_port1_secondary;
+
+       /* per-port resources */
+       struct {
+               int             dirmap_refcnt;
+               uint64_t        dirmap_shadow;
+       } ce_port[TIOCE_NUM_PORTS];
+};
+
+struct tioce_dmamap {
+       struct list_head        ce_dmamap_list; /* headed by tioce_kernel */
+       uint32_t                refcnt;
+
+       uint64_t                nbytes;         /* # bytes mapped */
+
+       uint64_t                ct_start;       /* coretalk start address */
+       uint64_t                pci_start;      /* bus start address */
+
+       uint64_t                *ate_hw;        /* hw ptr of first ate in map */
+       uint64_t                *ate_shadow;    /* shadow ptr of firat ate */
+       uint16_t                ate_count;      /* # ate's in the map */
+};
+
+extern int tioce_init_provider(void);
+
+#endif  /* __ASM_IA64_SN_CE_PROVIDER_H */
index 909936f25512e8ebbc3967d0eb775a12c989dd03..d2430aa0d49db76db4b6c771bc1eb9a9bc402d36 100644 (file)
@@ -93,7 +93,15 @@ _raw_spin_lock_flags (spinlock_t *lock, unsigned long flags)
 # endif /* CONFIG_MCKINLEY */
 #endif
 }
+
 #define _raw_spin_lock(lock) _raw_spin_lock_flags(lock, 0)
+
+/* Unlock by doing an ordered store and releasing the cacheline with nta */
+static inline void _raw_spin_unlock(spinlock_t *x) {
+       barrier();
+       asm volatile ("st4.rel.nta [%0] = r0\n\t" :: "r"(x));
+}
+
 #else /* !ASM_SUPPORTED */
 #define _raw_spin_lock_flags(lock, flags) _raw_spin_lock(lock)
 # define _raw_spin_lock(x)                                                             \
@@ -109,16 +117,16 @@ do {                                                                                      \
                } while (ia64_spinlock_val);                                            \
        }                                                                               \
 } while (0)
+#define _raw_spin_unlock(x)    do { barrier(); ((spinlock_t *) x)->lock = 0; } while (0)
 #endif /* !ASM_SUPPORTED */
 
 #define spin_is_locked(x)      ((x)->lock != 0)
-#define _raw_spin_unlock(x)    do { barrier(); ((spinlock_t *) x)->lock = 0; } while (0)
 #define _raw_spin_trylock(x)   (cmpxchg_acq(&(x)->lock, 0, 1) == 0)
 #define spin_unlock_wait(x)    do { barrier(); } while ((x)->lock)
 
 typedef struct {
-       volatile unsigned int read_counter      : 31;
-       volatile unsigned int write_lock        :  1;
+       volatile unsigned int read_counter      : 24;
+       volatile unsigned int write_lock        :  8;
 #ifdef CONFIG_PREEMPT
        unsigned int break_lock;
 #endif
@@ -174,6 +182,13 @@ do {                                                                               \
        (result == 0);                                                          \
 })
 
+static inline void _raw_write_unlock(rwlock_t *x)
+{
+       u8 *y = (u8 *)x;
+       barrier();
+       asm volatile ("st1.rel.nta [%0] = r0\n\t" :: "r"(y+3) : "memory" );
+}
+
 #else /* !ASM_SUPPORTED */
 
 #define _raw_write_lock(l)                                                             \
@@ -195,14 +210,14 @@ do {                                                                              \
        (ia64_val == 0);                                                \
 })
 
+static inline void _raw_write_unlock(rwlock_t *x)
+{
+       barrier();
+       x->write_lock = 0;
+}
+
 #endif /* !ASM_SUPPORTED */
 
 #define _raw_read_trylock(lock) generic_raw_read_trylock(lock)
 
-#define _raw_write_unlock(x)                                                           \
-({                                                                                     \
-       smp_mb__before_clear_bit();     /* need barrier before releasing lock... */     \
-       clear_bit(31, (x));                                                             \
-})
-
 #endif /*  _ASM_IA64_SPINLOCK_H */
index cd2cf76b2db1d77cb22a69f928f96c4a74d1c59c..33256db4a7cf1b0ad4f82cdcf935b0bd421a42ed 100644 (file)
 #include <asm/pal.h>
 #include <asm/percpu.h>
 
-#define GATE_ADDR              __IA64_UL_CONST(0xa000000000000000)
+#define GATE_ADDR              RGN_BASE(RGN_GATE)
+
 /*
  * 0xa000000000000000+2*PERCPU_PAGE_SIZE
  * - 0xa000000000000000+3*PERCPU_PAGE_SIZE remain unmapped (guard page)
  */
-#define KERNEL_START            __IA64_UL_CONST(0xa000000100000000)
+#define KERNEL_START            (GATE_ADDR+0x100000000)
 #define PERCPU_ADDR            (-PERCPU_PAGE_SIZE)
 
 #ifndef __ASSEMBLY__
index a677565aa95451f13191db59cfb935e9f0808aab..902850d12424daa1a492f569adc701b4596e96cf 100644 (file)
@@ -67,8 +67,6 @@ typedef __u64 u64;
 
 typedef u64 dma_addr_t;
 
-typedef unsigned short kmem_bufctl_t;
-
 # endif /* __KERNEL__ */
 #endif /* !__ASSEMBLY__ */
 
index 1c6abb9f3f1f7475a41ca8c04f6c680260d7fd91..4ab5788763616c2f2b667b08c46dd4562d30a8c5 100644 (file)
@@ -61,25 +61,6 @@ typedef struct { unsigned long pgprot; } pgprot_t;
 
 /* This handles the memory map.. */
 
-#ifndef __ASSEMBLY__
-
-/* Pure 2^n version of get_order */
-static __inline__ int get_order(unsigned long size)
-{
-       int order;
-
-       size = (size - 1) >> (PAGE_SHIFT - 1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-
-       return order;
-}
-
-#endif /* __ASSEMBLY__ */
-
 #define __MEMORY_START  CONFIG_MEMORY_START
 #define __MEMORY_SIZE   CONFIG_MEMORY_SIZE
 
@@ -111,5 +92,7 @@ static __inline__ int get_order(unsigned long size)
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _ASM_M32R_PAGE_H */
 
index ca0a887d2237167e313a6aa59643a59e2ade6287..fcf24c64c3ba4650d001dbf9dfa770583df51bed 100644 (file)
@@ -55,8 +55,6 @@ typedef unsigned long long u64;
 typedef u32 dma_addr_t;
 typedef u64 dma64_addr_t;
 
-typedef unsigned short kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
index e4773946f10dccfb857f5717481c144f9ced12fe..8aba971b13684e8ff0d9c26867a4d12b2af59170 100644 (file)
@@ -130,20 +130,25 @@ static inline void __flush_page_to_ram(void *vaddr)
 #define flush_dcache_mmap_lock(mapping)                do { } while (0)
 #define flush_dcache_mmap_unlock(mapping)      do { } while (0)
 #define flush_icache_page(vma, page)   __flush_page_to_ram(page_address(page))
-#define flush_icache_user_range(vma,pg,adr,len)        do { } while (0)
-
-#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
-       do {                                                    \
-               flush_cache_page(vma, vaddr, page_to_pfn(page));\
-               memcpy(dst, src, len);                          \
-       } while (0)
-
-#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
-       do {                                                    \
-               flush_cache_page(vma, vaddr, page_to_pfn(page));\
-               memcpy(dst, src, len);                          \
-       } while (0)
 
+extern void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
+                                   unsigned long addr, int len);
 extern void flush_icache_range(unsigned long address, unsigned long endaddr);
 
+static inline void copy_to_user_page(struct vm_area_struct *vma,
+                                    struct page *page, unsigned long vaddr,
+                                    void *dst, void *src, int len)
+{
+       flush_cache_page(vma, vaddr, page_to_pfn(page));
+       memcpy(dst, src, len);
+       flush_icache_user_range(vma, page, vaddr, len);
+}
+static inline void copy_from_user_page(struct vm_area_struct *vma,
+                                      struct page *page, unsigned long vaddr,
+                                      void *dst, void *src, int len)
+{
+       flush_cache_page(vma, vaddr, page_to_pfn(page));
+       memcpy(dst, src, len);
+}
+
 #endif /* _M68K_CACHEFLUSH_H */
index 206313e2a817798a3e6eb8d77f52230d19fa59b7..f206dfbc1d486268aff67915433f5f2bf7d54f04 100644 (file)
@@ -107,20 +107,6 @@ typedef struct { unsigned long pgprot; } pgprot_t;
 /* to align the pointer to the (next) page boundary */
 #define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
 
-/* Pure 2^n version of get_order */
-static inline int get_order(unsigned long size)
-{
-       int order;
-
-       size = (size-1) >> (PAGE_SHIFT-1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-       return order;
-}
-
 #endif /* !__ASSEMBLY__ */
 
 #include <asm/page_offset.h>
@@ -192,4 +178,6 @@ static inline void *__va(unsigned long x)
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _M68K_PAGE_H */
index 44def078132a756ec2790e7073d0f33eedf7407a..6c59215b285e0b9ab1d57c69bc582767edb9e483 100644 (file)
@@ -80,43 +80,6 @@ static inline char * strchr(const char * s, int c)
   return( (char *) s);
 }
 
-#if 0
-#define __HAVE_ARCH_STRPBRK
-static inline char *strpbrk(const char *cs,const char *ct)
-{
-  const char *sc1,*sc2;
-
-  for( sc1 = cs; *sc1 != '\0'; ++sc1)
-    for( sc2 = ct; *sc2 != '\0'; ++sc2)
-      if (*sc1 == *sc2)
-       return((char *) sc1);
-  return( NULL );
-}
-#endif
-
-#if 0
-#define __HAVE_ARCH_STRSPN
-static inline size_t strspn(const char *s, const char *accept)
-{
-  const char *p;
-  const char *a;
-  size_t count = 0;
-
-  for (p = s; *p != '\0'; ++p)
-    {
-      for (a = accept; *a != '\0'; ++a)
-        if (*p == *a)
-          break;
-      if (*a == '\0')
-        return count;
-      else
-        ++count;
-    }
-
-  return count;
-}
-#endif
-
 /* strstr !! */
 
 #define __HAVE_ARCH_STRLEN
@@ -173,370 +136,18 @@ static inline int strncmp(const char * cs,const char * ct,size_t count)
 }
 
 #define __HAVE_ARCH_MEMSET
-/*
- * This is really ugly, but its highly optimizatiable by the
- * compiler and is meant as compensation for gcc's missing
- * __builtin_memset(). For the 680[23]0        it might be worth considering
- * the optimal number of misaligned writes compared to the number of
- * tests'n'branches needed to align the destination address. The
- * 680[46]0 doesn't really care due to their copy-back caches.
- *                                             10/09/96 - Jes Sorensen
- */
-static inline void * __memset_g(void * s, int c, size_t count)
-{
-  void *xs = s;
-  size_t temp;
-
-  if (!count)
-    return xs;
-
-  c &= 0xff;
-  c |= c << 8;
-  c |= c << 16;
-
-  if (count < 36){
-         long *ls = s;
-
-         switch(count){
-         case 32: case 33: case 34: case 35:
-                 *ls++ = c;
-         case 28: case 29: case 30: case 31:
-                 *ls++ = c;
-         case 24: case 25: case 26: case 27:
-                 *ls++ = c;
-         case 20: case 21: case 22: case 23:
-                 *ls++ = c;
-         case 16: case 17: case 18: case 19:
-                 *ls++ = c;
-         case 12: case 13: case 14: case 15:
-                 *ls++ = c;
-         case 8: case 9: case 10: case 11:
-                 *ls++ = c;
-         case 4: case 5: case 6: case 7:
-                 *ls++ = c;
-                 break;
-         default:
-                 break;
-         }
-         s = ls;
-         if (count & 0x02){
-                 short *ss = s;
-                 *ss++ = c;
-                 s = ss;
-         }
-         if (count & 0x01){
-                 char *cs = s;
-                 *cs++ = c;
-                 s = cs;
-         }
-         return xs;
-  }
-
-  if ((long) s & 1)
-    {
-      char *cs = s;
-      *cs++ = c;
-      s = cs;
-      count--;
-    }
-  if (count > 2 && (long) s & 2)
-    {
-      short *ss = s;
-      *ss++ = c;
-      s = ss;
-      count -= 2;
-    }
-  temp = count >> 2;
-  if (temp)
-    {
-      long *ls = s;
-      temp--;
-      do
-       *ls++ = c;
-      while (temp--);
-      s = ls;
-    }
-  if (count & 2)
-    {
-      short *ss = s;
-      *ss++ = c;
-      s = ss;
-    }
-  if (count & 1)
-    {
-      char *cs = s;
-      *cs = c;
-    }
-  return xs;
-}
-
-/*
- * __memset_page assumes that data is longword aligned. Most, if not
- * all, of these page sized memsets are performed on page aligned
- * areas, thus we do not need to check if the destination is longword
- * aligned. Of course we suffer a serious performance loss if this is
- * not the case but I think the risk of this ever happening is
- * extremely small. We spend a lot of time clearing pages in
- * get_empty_page() so I think it is worth it anyway. Besides, the
- * 680[46]0 do not really care about misaligned writes due to their
- * copy-back cache.
- *
- * The optimized case for the 680[46]0 is implemented using the move16
- * instruction. My tests showed that this implementation is 35-45%
- * faster than the original implementation using movel, the only
- * caveat is that the destination address must be 16-byte aligned.
- *                                            01/09/96 - Jes Sorensen
- */
-static inline void * __memset_page(void * s,int c,size_t count)
-{
-  unsigned long data, tmp;
-  void *xs = s;
-
-  c = c & 255;
-  data = c | (c << 8);
-  data |= data << 16;
-
-#ifdef CPU_M68040_OR_M68060_ONLY
-
-  if (((unsigned long) s) & 0x0f)
-         __memset_g(s, c, count);
-  else{
-         unsigned long *sp = s;
-         *sp++ = data;
-         *sp++ = data;
-         *sp++ = data;
-         *sp++ = data;
-
-         __asm__ __volatile__("1:\t"
-                              ".chip 68040\n\t"
-                              "move16 %2@+,%0@+\n\t"
-                              ".chip 68k\n\t"
-                              "subqw  #8,%2\n\t"
-                              "subqw  #8,%2\n\t"
-                              "dbra   %1,1b\n\t"
-                              : "=a" (sp), "=d" (tmp)
-                              : "a" (s), "0" (sp), "1" ((count - 16) / 16 - 1)
-                              );
-  }
-
-#else
-  __asm__ __volatile__("1:\t"
-                      "movel %2,%0@+\n\t"
-                      "movel %2,%0@+\n\t"
-                      "movel %2,%0@+\n\t"
-                      "movel %2,%0@+\n\t"
-                      "movel %2,%0@+\n\t"
-                      "movel %2,%0@+\n\t"
-                      "movel %2,%0@+\n\t"
-                      "movel %2,%0@+\n\t"
-                      "dbra  %1,1b\n\t"
-                      : "=a" (s), "=d" (tmp)
-                      : "d" (data), "0" (s), "1" (count / 32 - 1)
-                      );
-#endif
-
-  return xs;
-}
-
-extern void *memset(void *,int,__kernel_size_t);
-
-#define __memset_const(s,c,count) \
-((count==PAGE_SIZE) ? \
-  __memset_page((s),(c),(count)) : \
-  __memset_g((s),(c),(count)))
-
-#define memset(s, c, count) \
-(__builtin_constant_p(count) ? \
- __memset_const((s),(c),(count)) : \
- __memset_g((s),(c),(count)))
+extern void *memset(void *, int, __kernel_size_t);
+#define memset(d, c, n) __builtin_memset(d, c, n)
 
 #define __HAVE_ARCH_MEMCPY
-extern void * memcpy(void *, const void *, size_t );
-/*
- * __builtin_memcpy() does not handle page-sized memcpys very well,
- * thus following the same assumptions as for page-sized memsets, this
- * function copies page-sized areas using an unrolled loop, without
- * considering alignment.
- *
- * For the 680[46]0 only kernels we use the move16 instruction instead
- * as it writes through the data-cache, invalidating the cache-lines
- * touched. In this way we do not use up the entire data-cache (well,
- * half of it on the 68060) by copying a page. An unrolled loop of two
- * move16 instructions seem to the fastest. The only caveat is that
- * both source and destination must be 16-byte aligned, if not we fall
- * back to the generic memcpy function.  - Jes
- */
-static inline void * __memcpy_page(void * to, const void * from, size_t count)
-{
-  unsigned long tmp;
-  void *xto = to;
-
-#ifdef CPU_M68040_OR_M68060_ONLY
-
-  if (((unsigned long) to | (unsigned long) from) & 0x0f)
-         return memcpy(to, from, count);
-
-  __asm__ __volatile__("1:\t"
-                      ".chip 68040\n\t"
-                      "move16 %1@+,%0@+\n\t"
-                      "move16 %1@+,%0@+\n\t"
-                      ".chip 68k\n\t"
-                      "dbra  %2,1b\n\t"
-                      : "=a" (to), "=a" (from), "=d" (tmp)
-                      : "0" (to), "1" (from) , "2" (count / 32 - 1)
-                      );
-#else
-  __asm__ __volatile__("1:\t"
-                      "movel %1@+,%0@+\n\t"
-                      "movel %1@+,%0@+\n\t"
-                      "movel %1@+,%0@+\n\t"
-                      "movel %1@+,%0@+\n\t"
-                      "movel %1@+,%0@+\n\t"
-                      "movel %1@+,%0@+\n\t"
-                      "movel %1@+,%0@+\n\t"
-                      "movel %1@+,%0@+\n\t"
-                      "dbra  %2,1b\n\t"
-                      : "=a" (to), "=a" (from), "=d" (tmp)
-                      : "0" (to), "1" (from) , "2" (count / 32 - 1)
-                      );
-#endif
-  return xto;
-}
-
-#define __memcpy_const(to, from, n) \
-((n==PAGE_SIZE) ? \
-  __memcpy_page((to),(from),(n)) : \
-  __builtin_memcpy((to),(from),(n)))
-
-#define memcpy(to, from, n) \
-(__builtin_constant_p(n) ? \
- __memcpy_const((to),(from),(n)) : \
- memcpy((to),(from),(n)))
+extern void *memcpy(void *, const void *, __kernel_size_t);
+#define memcpy(d, s, n) __builtin_memcpy(d, s, n)
 
 #define __HAVE_ARCH_MEMMOVE
-static inline void * memmove(void * dest,const void * src, size_t n)
-{
-  void *xdest = dest;
-  size_t temp;
-
-  if (!n)
-    return xdest;
-
-  if (dest < src)
-    {
-      if ((long) dest & 1)
-       {
-         char *cdest = dest;
-         const char *csrc = src;
-         *cdest++ = *csrc++;
-         dest = cdest;
-         src = csrc;
-         n--;
-       }
-      if (n > 2 && (long) dest & 2)
-       {
-         short *sdest = dest;
-         const short *ssrc = src;
-         *sdest++ = *ssrc++;
-         dest = sdest;
-         src = ssrc;
-         n -= 2;
-       }
-      temp = n >> 2;
-      if (temp)
-       {
-         long *ldest = dest;
-         const long *lsrc = src;
-         temp--;
-         do
-           *ldest++ = *lsrc++;
-         while (temp--);
-         dest = ldest;
-         src = lsrc;
-       }
-      if (n & 2)
-       {
-         short *sdest = dest;
-         const short *ssrc = src;
-         *sdest++ = *ssrc++;
-         dest = sdest;
-         src = ssrc;
-       }
-      if (n & 1)
-       {
-         char *cdest = dest;
-         const char *csrc = src;
-         *cdest = *csrc;
-       }
-    }
-  else
-    {
-      dest = (char *) dest + n;
-      src = (const char *) src + n;
-      if ((long) dest & 1)
-       {
-         char *cdest = dest;
-         const char *csrc = src;
-         *--cdest = *--csrc;
-         dest = cdest;
-         src = csrc;
-         n--;
-       }
-      if (n > 2 && (long) dest & 2)
-       {
-         short *sdest = dest;
-         const short *ssrc = src;
-         *--sdest = *--ssrc;
-         dest = sdest;
-         src = ssrc;
-         n -= 2;
-       }
-      temp = n >> 2;
-      if (temp)
-       {
-         long *ldest = dest;
-         const long *lsrc = src;
-         temp--;
-         do
-           *--ldest = *--lsrc;
-         while (temp--);
-         dest = ldest;
-         src = lsrc;
-       }
-      if (n & 2)
-       {
-         short *sdest = dest;
-         const short *ssrc = src;
-         *--sdest = *--ssrc;
-         dest = sdest;
-         src = ssrc;
-       }
-      if (n & 1)
-       {
-         char *cdest = dest;
-         const char *csrc = src;
-         *--cdest = *--csrc;
-       }
-    }
-  return xdest;
-}
+extern void *memmove(void *, const void *, __kernel_size_t);
 
 #define __HAVE_ARCH_MEMCMP
-extern int memcmp(const void * ,const void * ,size_t );
-#define memcmp(cs, ct, n) \
-(__builtin_constant_p(n) ? \
- __builtin_memcmp((cs),(ct),(n)) : \
- memcmp((cs),(ct),(n)))
-
-#define __HAVE_ARCH_MEMCHR
-static inline void *memchr(const void *cs, int c, size_t count)
-{
-       /* Someone else can optimize this, I don't care - tonym@mac.linux-m68k.org */
-       unsigned char *ret = (unsigned char *)cs;
-       for(;count>0;count--,ret++)
-               if(*ret == c) return ret;
-
-       return NULL;
-}
+extern int memcmp(const void *, const void *, __kernel_size_t);
+#define memcmp(d, s, n) __builtin_memcmp(d, s, n)
 
 #endif /* _M68K_STRING_H_ */
index f391cbe39b965c68c9fcfdc1301ccc31c21ba897..b5a1febc97d41d2658d6d25552d788ed3f1ce6ca 100644 (file)
@@ -60,8 +60,6 @@ typedef unsigned long long u64;
 typedef u32 dma_addr_t;
 typedef u32 dma64_addr_t;
 
-typedef unsigned short kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
index 05e03df0ec290691d5913fd08fe26933b5dac34d..942dfbead27fa8f80a403b03420aa0543c294da4 100644 (file)
@@ -48,20 +48,6 @@ typedef struct { unsigned long pgprot; } pgprot_t;
 /* to align the pointer to the (next) page boundary */
 #define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
 
-/* Pure 2^n version of get_order */
-extern __inline__ int get_order(unsigned long size)
-{
-       int order;
-
-       size = (size-1) >> (PAGE_SHIFT-1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-       return order;
-}
-
 extern unsigned long memory_start;
 extern unsigned long memory_end;
 
@@ -73,8 +59,8 @@ extern unsigned long memory_end;
 
 #ifndef __ASSEMBLY__
 
-#define __pa(vaddr)            virt_to_phys((void *)vaddr)
-#define __va(paddr)            phys_to_virt((unsigned long)paddr)
+#define __pa(vaddr)            virt_to_phys((void *)(vaddr))
+#define __va(paddr)            phys_to_virt((unsigned long)(paddr))
 
 #define virt_to_pfn(kaddr)     (__pa(kaddr) >> PAGE_SHIFT)
 #define pfn_to_virt(pfn)       __va((pfn) << PAGE_SHIFT)
@@ -84,6 +70,7 @@ extern unsigned long memory_end;
 
 #define pfn_to_page(pfn)       virt_to_page(pfn_to_virt(pfn))
 #define page_to_pfn(page)      virt_to_pfn(page_to_virt(page))
+#define pfn_valid(pfn)         ((pfn) < max_mapnr)
 
 #define        virt_addr_valid(kaddr)  (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
                                ((void *)(kaddr) < (void *)memory_end))
@@ -92,4 +79,6 @@ extern unsigned long memory_end;
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _M68KNOMMU_PAGE_H */
index e42b3093e9038ae7980bf46ae26758334c40abe5..2b3dc3bed4dac632a85114034722d00f9aa51d3b 100644 (file)
@@ -35,10 +35,10 @@ struct exec
 
 #ifdef __KERNEL__
 
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 #define STACK_TOP      TASK_SIZE
 #endif
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 #define STACK_TOP      (current->thread.mflags & MF_32BIT_ADDR ? TASK_SIZE32 : TASK_SIZE)
 #endif
 
index 2caa8c427204721274a90a2c00c661b2e4d662f2..7dc2619f50067be595b725e9b1c0a32eef72fa32 100644 (file)
@@ -48,7 +48,7 @@
 #define CPHYSADDR(a)           ((_ACAST32_ (a)) & 0x1fffffff)
 #define XPHYSADDR(a)            ((_ACAST64_ (a)) & 0x000000ffffffffff)
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 
 /*
  * Memory segments (64bit kernel mode addresses)
index 37a460aa0378e5474d7718934ddf589de2c83ab1..30b18ea6cb1116fd12e86094788c5917fe9f7e99 100644 (file)
@@ -7,14 +7,14 @@
  */
 #ifndef _ASM_ASMMACRO_H
 #define _ASM_ASMMACRO_H
+
 #include <linux/config.h>
 #include <asm/hazards.h>
-#ifdef CONFIG_MIPS32
+
+#ifdef CONFIG_32BIT
 #include <asm/asmmacro-32.h>
 #endif
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 #include <asm/asmmacro-64.h>
 #endif
 
index 7d89e87bc8c6fd9544ef3b247f57421248741396..c0bd8d014e14740a6e49a66d85f60a115a42e951 100644 (file)
@@ -334,7 +334,7 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
  */
 #define atomic_add_negative(i,v) (atomic_add_return(i, (v)) < 0)
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 
 typedef struct { volatile __s64 counter; } atomic64_t;
 
@@ -639,7 +639,7 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
  */
 #define atomic64_add_negative(i,v) (atomic64_add_return(i, (v)) < 0)
 
-#endif /* CONFIG_MIPS64 */
+#endif /* CONFIG_64BIT */
 
 /*
  * atomic*_return operations are serializing but not the non-*_return
index 779d2187a6a4448fdf7db89cb58f630fc06d7b3e..eb8d79dba11ca104710662bf7fd8a2b941729187 100644 (file)
 #define SZLONG_MASK 31UL
 #define __LL   "ll     "
 #define __SC   "sc     "
-#define cpu_to_lelongp(x) cpu_to_le32p((__u32 *) (x)) 
+#define cpu_to_lelongp(x) cpu_to_le32p((__u32 *) (x))
 #elif (_MIPS_SZLONG == 64)
 #define SZLONG_LOG 6
 #define SZLONG_MASK 63UL
 #define __LL   "lld    "
 #define __SC   "scd    "
-#define cpu_to_lelongp(x) cpu_to_le64p((__u64 *) (x)) 
+#define cpu_to_lelongp(x) cpu_to_le64p((__u64 *) (x))
 #endif
 
 #ifdef __KERNEL__
@@ -533,14 +533,14 @@ static inline unsigned long ffz(unsigned long word)
        int b = 0, s;
 
        word = ~word;
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
        s = 16; if (word << 16 != 0) s = 0; b += s; word >>= s;
        s =  8; if (word << 24 != 0) s = 0; b += s; word >>= s;
        s =  4; if (word << 28 != 0) s = 0; b += s; word >>= s;
        s =  2; if (word << 30 != 0) s = 0; b += s; word >>= s;
        s =  1; if (word << 31 != 0) s = 0; b += s;
 #endif
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        s = 32; if (word << 32 != 0) s = 0; b += s; word >>= s;
        s = 16; if (word << 48 != 0) s = 0; b += s; word >>= s;
        s =  8; if (word << 56 != 0) s = 0; b += s; word >>= s;
@@ -683,7 +683,7 @@ found_middle:
  */
 static inline int sched_find_first_bit(const unsigned long *b)
 {
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
        if (unlikely(b[0]))
                return __ffs(b[0]);
        if (unlikely(b[1]))
@@ -694,7 +694,7 @@ static inline int sched_find_first_bit(const unsigned long *b)
                return __ffs(b[3]) + 96;
        return __ffs(b[4]) + 128;
 #endif
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        if (unlikely(b[0]))
                return __ffs(b[0]);
        if (unlikely(b[1]))
index 18cced19cca430ed6a5c666ffe5008089fe847a2..b14b961c2100c4394305023f0621c50caf3fef31 100644 (file)
@@ -15,7 +15,7 @@ extern void check_bugs64(void);
 static inline void check_bugs(void)
 {
        check_bugs32();
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        check_bugs64();
 #endif
 }
index c25cc92b99508b4886aa4e021beafda484926d09..c1ea5a8714f346ef729ed92e0b6b9cfeae592ea6 100644 (file)
@@ -128,7 +128,7 @@ static inline unsigned int csum_tcpudp_nofold(unsigned long saddr,
 {
        __asm__(
        ".set\tnoat\t\t\t# csum_tcpudp_nofold\n\t"
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
        "addu\t%0, %2\n\t"
        "sltu\t$1, %0, %2\n\t"
        "addu\t%0, $1\n\t"
@@ -141,7 +141,7 @@ static inline unsigned int csum_tcpudp_nofold(unsigned long saddr,
        "sltu\t$1, %0, %4\n\t"
        "addu\t%0, $1\n\t"
 #endif
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
        "daddu\t%0, %2\n\t"
        "daddu\t%0, %3\n\t"
        "daddu\t%0, %4\n\t"
index 1df2c299de825089ebf449fbb97e20b58c66fb31..9a2de642eee6376ae239fe7ced039d1d62c54242 100644 (file)
 #define PLAT_TRAMPOLINE_STUFF_LINE     0UL
 #endif
 
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 # ifndef cpu_has_nofpuex
 # define cpu_has_nofpuex       (cpu_data[0].options & MIPS_CPU_NOFPUEX)
 # endif
 # endif
 #endif
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 # ifndef cpu_has_nofpuex
 # define cpu_has_nofpuex               0
 # endif
index ae3e2a38fd5fad5daf620362916e73c9a5511a61..a438548e6ef3b6c9930f7bf52640ba65a23b5e2d 100644 (file)
@@ -247,7 +247,7 @@ extern void ll_vrc5477_irq_disable(int vrc5477_irq);
  *  All PCI irq but INTC are active low.
  */
 
-/* 
+/*
  * irq number block assignment
  */
 
@@ -285,7 +285,7 @@ extern void ll_vrc5477_irq_disable(int vrc5477_irq);
 #define VRC5477_IRQ_IOPCI_INTB (17 + VRC5477_IRQ_BASE)      /* USB-P */
 #define VRC5477_IRQ_IOPCI_INTC (18 + VRC5477_IRQ_BASE)      /* AC97 */
 #define VRC5477_IRQ_IOPCI_INTD (19 + VRC5477_IRQ_BASE)      /* Reserved */
-#define VRC5477_IRQ_UART1      (20 + VRC5477_IRQ_BASE)     
+#define VRC5477_IRQ_UART1      (20 + VRC5477_IRQ_BASE)
 #define VRC5477_IRQ_SPT0       (21 + VRC5477_IRQ_BASE)      /* special purpose timer 0 */
 #define VRC5477_IRQ_GPT0       (22 + VRC5477_IRQ_BASE)      /* general purpose timer 0 */
 #define VRC5477_IRQ_GPT1       (23 + VRC5477_IRQ_BASE)      /* general purpose timer 1 */
@@ -301,7 +301,7 @@ extern void ll_vrc5477_irq_disable(int vrc5477_irq);
 /*
  * i2859 irq assignment
  */
-#define I8259_IRQ_RESERVED_0   (0 + I8259_IRQ_BASE)    
+#define I8259_IRQ_RESERVED_0   (0 + I8259_IRQ_BASE)
 #define I8259_IRQ_KEYBOARD     (1 + I8259_IRQ_BASE)    /* M1543 default */
 #define I8259_IRQ_CASCADE      (2 + I8259_IRQ_BASE)
 #define I8259_IRQ_UART_B       (3 + I8259_IRQ_BASE)    /* M1543 default, may conflict with RTC according to schematic diagram  */
index b63e2f2317d15cf31dd27a9ed17590d8cee2c0a9..a05d6d3395fe49ef8628043eaafb03583fcd5671 100644 (file)
  */
 #define REX_PROM_MAGIC         0x30464354
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 
 #define prom_is_rex(magic)     1       /* KN04 and KN05 are REX PROMs.  */
 
-#else /* !CONFIG_MIPS64 */
+#else /* !CONFIG_64BIT */
 
 #define prom_is_rex(magic)     ((magic) == REX_PROM_MAGIC)
 
-#endif /* !CONFIG_MIPS64 */
+#endif /* !CONFIG_64BIT */
 
 
 /*
@@ -105,7 +105,7 @@ extern int (*__pmax_read)(int, void *, int);
 extern int (*__pmax_close)(int);
 
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 
 /*
  * On MIPS64 we have to call PROM functions via a helper
@@ -138,7 +138,7 @@ int _prom_printf(int (*)(char *, ...), char *, ...) __DEC_PROM_O32;
 #define prom_getenv(x)         _prom_getenv(__prom_getenv, x)
 #define prom_printf(x...)      _prom_printf(__prom_printf, x)
 
-#else /* !CONFIG_MIPS64 */
+#else /* !CONFIG_64BIT */
 
 /*
  * On plain MIPS we just call PROM functions directly.
@@ -160,7 +160,7 @@ int _prom_printf(int (*)(char *, ...), char *, ...) __DEC_PROM_O32;
 #define pmax_read              __pmax_read
 #define pmax_close             __pmax_close
 
-#endif /* !CONFIG_MIPS64 */
+#endif /* !CONFIG_64BIT */
 
 
 extern void prom_meminit(u32);
index d0f68447e5a713ba53fa185e2e44d5c9a009afdf..a606dbee0412a4be05efc66b370a3b1987b10323 100644 (file)
@@ -57,11 +57,11 @@ static inline void __udelay(unsigned long usecs, unsigned long lpj)
         * The common rates of 1000 and 128 are rounded wrongly by the
         * catchall case for 64-bit.  Excessive precission?  Probably ...
         */
-#if defined(CONFIG_MIPS64) && (HZ == 128)
+#if defined(CONFIG_64BIT) && (HZ == 128)
        usecs *= 0x0008637bd05af6c7UL;          /* 2**64 / (1000000 / HZ) */
-#elif defined(CONFIG_MIPS64) && (HZ == 1000)
+#elif defined(CONFIG_64BIT) && (HZ == 1000)
        usecs *= 0x004189374BC6A7f0UL;          /* 2**64 / (1000000 / HZ) */
-#elif defined(CONFIG_MIPS64)
+#elif defined(CONFIG_64BIT)
        usecs *= (0x8000000000000000UL / (500000 / HZ));
 #else /* 32-bit junk follows here */
        usecs *= (unsigned long) (((0x8000000000000000ULL / (500000 / HZ)) +
index 7b92c8045cc24593c513445498466a85e5d00382..e4881144001578c7b9adde069f068d1d746f0dde 100644 (file)
@@ -125,7 +125,7 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 typedef double elf_fpreg_t;
 typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
 
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 
 /*
  * This is used to ensure we don't load something for the wrong architecture.
@@ -153,9 +153,9 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
  */
 #define ELF_CLASS      ELFCLASS32
 
-#endif /* CONFIG_MIPS32 */
+#endif /* CONFIG_32BIT */
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 /*
  * This is used to ensure we don't load something for the wrong architecture.
  */
@@ -177,7 +177,7 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
  */
 #define ELF_CLASS      ELFCLASS64
 
-#endif /* CONFIG_MIPS64 */
+#endif /* CONFIG_64BIT */
 
 /*
  * These are used to set parameters in the core dumps.
@@ -193,7 +193,7 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
 
 #ifdef __KERNEL__
 
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 
 #define SET_PERSONALITY(ex, ibcs2)                     \
 do {                                                   \
@@ -202,9 +202,9 @@ do {                                                        \
        set_personality(PER_LINUX);                     \
 } while (0)
 
-#endif /* CONFIG_MIPS32 */
+#endif /* CONFIG_32BIT */
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 
 #define SET_PERSONALITY(ex, ibcs2)                             \
 do {   current->thread.mflags &= ~MF_ABI_MASK;                 \
@@ -222,7 +222,7 @@ do {        current->thread.mflags &= ~MF_ABI_MASK;                 \
                set_personality(PER_LINUX);                     \
 } while (0)
 
-#endif /* CONFIG_MIPS64 */
+#endif /* CONFIG_64BIT */
 
 extern void dump_regs(elf_greg_t *, struct pt_regs *regs);
 extern int dump_task_fpu(struct task_struct *, elf_fpregset_t *);
index 1d9aa097918110c97bb5e79d0f7a1237ba6b70d0..2b5fddc8f487c82c13bb0d53dc6c36c23eb02694 100644 (file)
@@ -13,7 +13,7 @@
 #define _ASM_FPREGDEF_H
 
 #include <asm/sgidefs.h>
-                                                                                
+
 #if _MIPS_SIM == _MIPS_SIM_ABI32
 
 /*
@@ -56,7 +56,7 @@
 #define fcr31  $31      /* FPU status register */
 
 #endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
-                                                                                
+
 #if _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32
 
 #define fv0    $f0     /* return value */
index 6cb38d5c0407d0c13e1a0e50da60e04201bebea6..ea24e733b1bcf84a74e952258c5527dc9ad8b714 100644 (file)
@@ -82,7 +82,7 @@ do {                                                                  \
 
 static inline int is_fpu_owner(void)
 {
-       return cpu_has_fpu && test_thread_flag(TIF_USEDFPU); 
+       return cpu_has_fpu && test_thread_flag(TIF_USEDFPU);
 }
 
 static inline void own_fpu(void)
@@ -90,7 +90,7 @@ static inline void own_fpu(void)
        if (cpu_has_fpu) {
                __enable_fpu();
                KSTK_STATUS(current) |= ST0_CU1;
-               set_thread_flag(TIF_USEDFPU); 
+               set_thread_flag(TIF_USEDFPU);
        }
 }
 
@@ -98,7 +98,7 @@ static inline void lose_fpu(void)
 {
        if (cpu_has_fpu) {
                KSTK_STATUS(current) &= ~ST0_CU1;
-               clear_thread_flag(TIF_USEDFPU); 
+               clear_thread_flag(TIF_USEDFPU);
                __disable_fpu();
        }
 }
@@ -127,7 +127,7 @@ static inline void restore_fp(struct task_struct *tsk)
 static inline fpureg_t *get_fpu_regs(struct task_struct *tsk)
 {
        if (cpu_has_fpu) {
-               if ((tsk == current) && is_fpu_owner()) 
+               if ((tsk == current) && is_fpu_owner())
                        _save_fp(current);
                return tsk->thread.fpu.hard.fpr;
        }
diff --git a/include/asm-mips/hp-lj/asic.h b/include/asm-mips/hp-lj/asic.h
deleted file mode 100644 (file)
index fc2ca65..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-
-typedef enum { IllegalAsic, UnknownAsic, AndrosAsic, HarmonyAsic } AsicId;
-
-AsicId GetAsicId(void);
-
-const char* const GetAsicName(void);
-
index 2b7b0fdeac194129060a2bc47bfc81dc57f5984a..432011b16c2671eb51af1a5493af229b13cf1e02 100644 (file)
@@ -94,7 +94,7 @@ struct mace_video {
        unsigned long xxx;      /* later... */
 };
 
-/* 
+/*
  * Ethernet interface
  */
 struct mace_ethernet {
@@ -129,7 +129,7 @@ struct mace_ethernet {
        volatile unsigned long rx_fifo;
 };
 
-/* 
+/*
  * Peripherals
  */
 
@@ -251,7 +251,7 @@ struct mace_timers {
        timer_reg audio_out2;
        timer_reg video_in1;
        timer_reg video_in2;
-       timer_reg video_out;    
+       timer_reg video_out;
 };
 
 struct mace_perif {
@@ -272,7 +272,7 @@ struct mace_perif {
 };
 
 
-/* 
+/*
  * ISA peripherals
  */
 
index 21d0fb7cee6435581e786f57a77993279db2408f..9e88c7669c7a5b68da73bcb8c8f1673b85d726c2 100644 (file)
@@ -1,13 +1,13 @@
 #include <asm/lasat/lasat.h>
 
 /* Lasat 100 boards serial configuration */
-#define LASAT_BASE_BAUD_100            ( 7372800 / 16 ) 
+#define LASAT_BASE_BAUD_100            ( 7372800 / 16 )
 #define LASAT_UART_REGS_BASE_100       0x1c8b0000
 #define LASAT_UART_REGS_SHIFT_100      2
 #define LASATINT_UART_100              8
 
 /* * LASAT 200 boards serial configuration */
-#define LASAT_BASE_BAUD_200            (100000000 / 16 / 12) 
+#define LASAT_BASE_BAUD_200            (100000000 / 16 / 12)
 #define LASAT_UART_REGS_BASE_200       (Vrc5074_PHYS_BASE + 0x0300)
 #define LASAT_UART_REGS_SHIFT_200      3
 #define LASATINT_UART_200              13
index 7eb6bf661b8037083e08210780279aad588f1460..c38844f615fc790896faef323b487dbd83c40249 100644 (file)
@@ -5,7 +5,7 @@
 #include <linux/percpu.h>
 #include <asm/atomic.h>
 
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 
 typedef atomic_t local_t;
 
@@ -20,7 +20,7 @@ typedef atomic_t local_t;
 
 #endif
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 
 typedef atomic64_t local_t;
 
index 2b36ea346910d9e3bd36cc6cfeae742bac379a1d..148bae2fa7d32cea726004a915cc074b61b01093 100644 (file)
@@ -1383,7 +1383,7 @@ extern au1xxx_irq_map_t au1xxx_irq_map[];
 #define PCI_IO_START    0
 #define PCI_IO_END      0
 #define PCI_MEM_START   0
-#define PCI_MEM_END     0 
+#define PCI_MEM_END     0
 #define PCI_FIRST_DEVFN 0
 #define PCI_LAST_DEVFN  0
 #endif
index 4691398a414fe40560431957a884edc8744f8c40..efafe65258b6eb664b766e8844b2766a07eb41ae 100644 (file)
@@ -23,7 +23,7 @@
  *
  * ########################################################################
  *
- * 
+ *
  */
 #ifndef __ASM_DB1X00_H
 #define __ASM_DB1X00_H
index 63c0a81c78329ca8728a2d2bc7d5661f51458bd9..5a2c1efb4eb7bf47a3c2212263f69c7bb7337616 100644 (file)
@@ -12,7 +12,7 @@
 
 #include <linux/config.h>
 
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 
 #define CAC_BASE               0x80000000
 #define IO_BASE                        0xa0000000
@@ -32,9 +32,9 @@
 #define HIGHMEM_START          0x20000000UL
 #endif
 
-#endif /* CONFIG_MIPS32 */
+#endif /* CONFIG_32BIT */
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 
 /*
  * This handles the memory map.
@@ -67,6 +67,6 @@
 #define TO_CAC(x)              (CAC_BASE   | ((x) & TO_PHYS_MASK))
 #define TO_UNCAC(x)            (UNCAC_BASE | ((x) & TO_PHYS_MASK))
 
-#endif /* CONFIG_MIPS64 */
+#endif /* CONFIG_64BIT */
 
 #endif /* __ASM_MACH_GENERIC_SPACES_H */
index 30d42fcafe3d8d03b60576d2532704faf2764e91..e96166f27c49282dc557fb2d06d423e6f76b2caf 100644 (file)
@@ -12,7 +12,7 @@
 
 #include <linux/config.h>
 
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 
 #define CAC_BASE               0x80000000
 #define IO_BASE                        0xa0000000
@@ -32,9 +32,9 @@
 #define HIGHMEM_START          0x20000000UL
 #endif
 
-#endif /* CONFIG_MIPS32 */
+#endif /* CONFIG_32BIT */
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 #define PAGE_OFFSET            0xffffffff80000000UL
 
 #ifndef HIGHMEM_START
@@ -50,6 +50,6 @@
 #define TO_CAC(x)              (CAC_BASE   | ((x) & TO_PHYS_MASK))
 #define TO_UNCAC(x)            (UNCAC_BASE | ((x) & TO_PHYS_MASK))
 
-#endif /* CONFIG_MIPS64 */
+#endif /* CONFIG_64BIT */
 
 #endif /* __ASM_MACH_IP22_SPACES_H */
index b932237f2193ffbc874fdb33d261c0cdd9e47ce5..04713973c6c39f6f38ee0f5735719a7fe52e3c7f 100644 (file)
@@ -18,7 +18,7 @@
  * so, for 64bit IP32 kernel we just don't use ll/sc.
  * This does not affect luserland.
  */
-#if defined(CONFIG_CPU_R5000) && defined(CONFIG_MIPS64)
+#if defined(CONFIG_CPU_R5000) && defined(CONFIG_64BIT)
 #define cpu_has_llsc           0
 #else
 #define cpu_has_llsc           1
index 8cf0d042c864f6d8913fa6084535398eeee399b9..c9dad99b12324aaaffa8a55c62367b865740266d 100644 (file)
@@ -92,7 +92,7 @@ static inline int fd_request_irq(void)
        return request_irq(FLOPPY_IRQ, floppy_interrupt,
                           SA_INTERRUPT | SA_SAMPLE_RANDOM, "floppy", NULL);
 }
-                                                                                
+
 static inline void fd_free_irq(void)
 {
        free_irq(FLOPPY_IRQ, NULL);
index d6c779747b3cdd4128e324a18b17f84dd56544b0..ff6d40c87a25b0859e8782d35ca99e089faa25da 100644 (file)
 #define PCI_BOARD_REG             0xAE000010
 #define PCMCIA_BOARD_REG          0xAE000010
   #define PC_DEASSERT_RST               0x80
-  #define PC_DRV_EN                     0x10 
+  #define PC_DRV_EN                     0x10
 #define PB1500_G_CONTROL          0xAE000014
 #define PB1500_RST_VDDI           0xAE00001C
 #define PB1500_LEDS               0xAE000018
-  
+
 #define PB1500_HEX_LED            0xAF000004
 #define PB1500_HEX_LED_BLANK      0xAF000008
 
diff --git a/include/asm-mips/mach-qemu/cpu-feature-overrides.h b/include/asm-mips/mach-qemu/cpu-feature-overrides.h
new file mode 100644 (file)
index 0000000..f4e370e
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2003 Ralf Baechle
+ */
+#ifndef __ASM_MACH_QEMU_CPU_FEATURE_OVERRIDES_H
+#define __ASM_MACH_QEMU_CPU_FEATURE_OVERRIDES_H
+
+/*
+ * QEMU only comes with a hazard-free MIPS32 processor, so things are easy.
+ */
+#define cpu_has_mips16         0
+#define cpu_has_divec          0
+#define cpu_has_cache_cdex_p   0
+#define cpu_has_prefetch       0
+#define cpu_has_mcheck         0
+#define cpu_has_ejtag          0
+
+#define cpu_has_llsc           1
+#define cpu_has_vtag_icache    0
+#define cpu_has_dc_aliases     (PAGE_SIZE < 0x4000)
+#define cpu_has_ic_fills_f_dc  0
+
+#define cpu_has_dsp            0
+
+#define cpu_has_nofpuex                0
+#define cpu_has_64bits         0
+
+#endif /* __ASM_MACH_QEMU_CPU_FEATURE_OVERRIDES_H */
diff --git a/include/asm-mips/mach-qemu/param.h b/include/asm-mips/mach-qemu/param.h
new file mode 100644 (file)
index 0000000..cb30ee4
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2005 by Ralf Baechle
+ */
+#ifndef __ASM_MACH_QEMU_PARAM_H
+#define __ASM_MACH_QEMU_PARAM_H
+
+#define HZ             100             /* Internal kernel timer frequency */
+
+#endif /* __ASM_MACH_QEMU_PARAM_H */
diff --git a/include/asm-mips/mach-vr41xx/timex.h b/include/asm-mips/mach-vr41xx/timex.h
deleted file mode 100644 (file)
index 8d71485..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2003 by Ralf Baechle
- */
-/*
- * Changes:
- *  Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
- *  - CLOCK_TICK_RATE is changed into 32768 from 6144000.
- */
-#ifndef __ASM_MACH_VR41XX_TIMEX_H
-#define __ASM_MACH_VR41XX_TIMEX_H
-
-#define CLOCK_TICK_RATE                32768
-
-#endif /* __ASM_MACH_VR41XX_TIMEX_H */
index 48b77c9fb4f2f8642342f7479a0ca0ab4ef4e7d7..45cd72d172e8caa52a2c23cc3adbc1e7af4b94a8 100644 (file)
@@ -28,17 +28,17 @@ extern unsigned long pgd_current[];
 #define TLBMISS_HANDLER_SETUP_PGD(pgd) \
        pgd_current[smp_processor_id()] = (unsigned long)(pgd)
 
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 #define TLBMISS_HANDLER_SETUP()                                                \
        write_c0_context((unsigned long) smp_processor_id() << 23);     \
        TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir)
 #endif
-#if defined(CONFIG_MIPS64) && !defined(CONFIG_BUILD_ELF64)
+#if defined(CONFIG_64BIT) && !defined(CONFIG_BUILD_ELF64)
 #define TLBMISS_HANDLER_SETUP()                                                \
        write_c0_context((unsigned long) &pgd_current[smp_processor_id()] << 23); \
        TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir)
 #endif
-#if defined(CONFIG_MIPS64) && defined(CONFIG_BUILD_ELF64)
+#if defined(CONFIG_64BIT) && defined(CONFIG_BUILD_ELF64)
 #define TLBMISS_HANDLER_SETUP()                                                \
        write_c0_context((unsigned long) smp_processor_id() << 23);     \
        TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir)
index 90ee24aad955efbeebb29c45f67f9e7ac3c438d9..0be58b2aeb9ffab857d2a739c19c00f990c70b0b 100644 (file)
@@ -25,7 +25,7 @@ typedef struct
   Elf64_Sxword r_addend;               /* Addend.  */
 } Elf64_Mips_Rela;
 
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 
 #define Elf_Shdr       Elf32_Shdr
 #define Elf_Sym                Elf32_Sym
@@ -33,7 +33,7 @@ typedef struct
 
 #endif
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 
 #define Elf_Shdr       Elf64_Shdr
 #define Elf_Sym                Elf64_Sym
index 513b2824838b314c6025283b247d8ce5f70fb9e2..a1533959742e4693f69f1f6b2311db956cc5cd01 100644 (file)
 
 struct msqid64_ds {
        struct ipc64_perm msg_perm;
-#if defined(CONFIG_MIPS32) && !defined(CONFIG_CPU_LITTLE_ENDIAN)
+#if defined(CONFIG_32BIT) && !defined(CONFIG_CPU_LITTLE_ENDIAN)
        unsigned long   __unused1;
 #endif
        __kernel_time_t msg_stime;      /* last msgsnd time */
-#if defined(CONFIG_MIPS32) && defined(CONFIG_CPU_LITTLE_ENDIAN)
+#if defined(CONFIG_32BIT) && defined(CONFIG_CPU_LITTLE_ENDIAN)
        unsigned long   __unused1;
 #endif
-#if defined(CONFIG_MIPS32) && !defined(CONFIG_CPU_LITTLE_ENDIAN)
+#if defined(CONFIG_32BIT) && !defined(CONFIG_CPU_LITTLE_ENDIAN)
        unsigned long   __unused2;
 #endif
        __kernel_time_t msg_rtime;      /* last msgrcv time */
-#if defined(CONFIG_MIPS32) && defined(CONFIG_CPU_LITTLE_ENDIAN)
+#if defined(CONFIG_32BIT) && defined(CONFIG_CPU_LITTLE_ENDIAN)
        unsigned long   __unused2;
 #endif
-#if defined(CONFIG_MIPS32) && !defined(CONFIG_CPU_LITTLE_ENDIAN)
+#if defined(CONFIG_32BIT) && !defined(CONFIG_CPU_LITTLE_ENDIAN)
        unsigned long   __unused3;
 #endif
        __kernel_time_t msg_ctime;      /* last change time */
-#if defined(CONFIG_MIPS32) && defined(CONFIG_CPU_LITTLE_ENDIAN)
+#if defined(CONFIG_32BIT) && defined(CONFIG_CPU_LITTLE_ENDIAN)
        unsigned long   __unused3;
 #endif
        unsigned long  msg_cbytes;      /* current number of bytes on queue */
index 36cec9e31696ecdc12191eec39c1625e51e715ed..309bc3099f68d9904e374168a0b923257333e6c6 100644 (file)
 #include <linux/config.h>
 #include <linux/errno.h>
 
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 #define __PA_ADDR      ".word"
 #endif
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 #define __PA_ADDR      ".dword"
 #endif
 
index 5cae35cd9ba923f76e49754d5a81757fdd2f83ad..652b6d67a57189b8792a8388e94c71e547aad302 100644 (file)
@@ -103,20 +103,6 @@ typedef struct { unsigned long pgprot; } pgprot_t;
 #define __pgd(x)       ((pgd_t) { (x) } )
 #define __pgprot(x)    ((pgprot_t) { (x) } )
 
-/* Pure 2^n version of get_order */
-static __inline__ int get_order(unsigned long size)
-{
-       int order;
-
-       size = (size-1) >> (PAGE_SHIFT-1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-       return order;
-}
-
 #endif /* !__ASSEMBLY__ */
 
 /* to align the pointer to the (next) page boundary */
@@ -148,4 +134,6 @@ static __inline__ int get_order(unsigned long size)
 #define WANT_PAGE_VIRTUAL
 #endif
 
+#include <asm-generic/page.h>
+
 #endif /* _ASM_PAGE_H */
index d70dc355c1f320bf6bdd5a2fb4542a93ff82a481..c9a00ca1c012098931854e96bfe17d9f47c78eeb 100644 (file)
@@ -94,7 +94,7 @@ struct pci_dev;
  */
 extern unsigned int PCI_DMA_BUS_IS_PHYS;
 
-#ifdef CONFIG_MAPPED_DMA_IO
+#ifdef CONFIG_DMA_NEED_PCI_MAP_STATE
 
 /* pci_unmap_{single,page} is not a nop, thus... */
 #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)      dma_addr_t ADDR_NAME;
@@ -104,7 +104,7 @@ extern unsigned int PCI_DMA_BUS_IS_PHYS;
 #define pci_unmap_len(PTR, LEN_NAME)           ((PTR)->LEN_NAME)
 #define pci_unmap_len_set(PTR, LEN_NAME, VAL)  (((PTR)->LEN_NAME) = (VAL))
 
-#else /* CONFIG_MAPPED_DMA_IO  */
+#else /* CONFIG_DMA_NEED_PCI_MAP_STATE  */
 
 /* pci_unmap_{page,single} is a nop so... */
 #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
@@ -114,7 +114,7 @@ extern unsigned int PCI_DMA_BUS_IS_PHYS;
 #define pci_unmap_len(PTR, LEN_NAME)           (0)
 #define pci_unmap_len_set(PTR, LEN_NAME, VAL)  do { } while (0)
 
-#endif /* CONFIG_MAPPED_DMA_IO  */
+#endif /* CONFIG_DMA_NEED_PCI_MAP_STATE  */
 
 /* This is always fine. */
 #define pci_dac_dma_supported(pci_dev, mask)   (1)
@@ -142,6 +142,8 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
 
 extern void pcibios_resource_to_bus(struct pci_dev *dev,
        struct pci_bus_region *region, struct resource *res);
+extern void pcibios_bus_to_resource(struct pci_dev *dev,
+       struct resource *res, struct pci_bus_region *region);
 
 #ifdef CONFIG_PCI_DOMAINS
 
@@ -167,4 +169,17 @@ static inline void pcibios_add_platform_entries(struct pci_dev *dev)
 /* Do platform specific device initialization at pci_enable_device() time */
 extern int pcibios_plat_dev_init(struct pci_dev *dev);
 
+static inline struct resource *
+pcibios_select_root(struct pci_dev *pdev, struct resource *res)
+{
+       struct resource *root = NULL;
+
+       if (res->flags & IORESOURCE_IO)
+               root = &ioport_resource;
+       if (res->flags & IORESOURCE_MEM)
+               root = &iomem_resource;
+
+       return root;
+}
+
 #endif /* _ASM_PCI_H */
index 2d63f5ba403fe24b6568ff73a21b856a50ed62d8..ce57288d43bd5cdbea3d7ea0bc5d18de9d091e9d 100644 (file)
@@ -85,7 +85,7 @@ static inline void pte_free(struct page *pte)
 
 #define __pte_free_tlb(tlb,pte)                tlb_remove_page((tlb),(pte))
 
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 #define pgd_populate(mm, pmd, pte)     BUG()
 
 /*
@@ -97,7 +97,7 @@ static inline void pte_free(struct page *pte)
 #define __pmd_free_tlb(tlb,x)          do { } while (0)
 #endif
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 
 #define pgd_populate(mm, pgd, pmd)     set_pgd(pgd, __pgd(pmd))
 
index e76ccd6e3a5dcc8ef9760d7a48bc62b2414af3d8..dbe13da0bdadbe55affd38c3999ed4e0eb04593b 100644 (file)
 #include <asm-generic/4level-fixup.h>
 
 #include <linux/config.h>
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 #include <asm/pgtable-32.h>
 #endif
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 #include <asm/pgtable-64.h>
 #endif
 
index 13c54d5b3b48a3f258f8dbcdcb227009626e207f..d6466aa09fb7a181a1dd07a52ac646b3c8755c06 100644 (file)
@@ -33,7 +33,7 @@ extern void (*cpu_wait)(void);
 
 extern unsigned int vced_count, vcei_count;
 
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 /*
  * User space process size: 2GB. This is hardcoded into a few places,
  * so don't change it unless you know what you are doing.
@@ -47,7 +47,7 @@ extern unsigned int vced_count, vcei_count;
 #define TASK_UNMAPPED_BASE     (PAGE_ALIGN(TASK_SIZE / 3))
 #endif
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 /*
  * User space process size: 1TB. This is hardcoded into a few places,
  * so don't change it unless you know what you are doing.  TASK_SIZE
index d3c46d6338266f7c29300d54fce0ad9e4c2c1ab6..2b5c624c3d4fe790ec638d94ca2492b31560f0ed 100644 (file)
@@ -28,7 +28,7 @@
  * system call/exception. As usual the registers k0/k1 aren't being saved.
  */
 struct pt_regs {
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
        /* Pad bytes for argument save space on the stack. */
        unsigned long pad0[6];
 #endif
diff --git a/include/asm-mips/qemu.h b/include/asm-mips/qemu.h
new file mode 100644 (file)
index 0000000..905c395
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2005 by Ralf Baechle (ralf@linux-mips.org)
+ */
+#ifndef __ASM_QEMU_H
+#define __ASM_QEMU_H
+
+/*
+ * Interrupt numbers
+ */
+#define Q_PIC_IRQ_BASE         0
+#define Q_COUNT_COMPARE_IRQ    16
+
+/*
+ * Qemu clock rate.  Unlike on real MIPS this has no relation to the
+ * instruction issue rate, so the choosen value is pure fiction, just needs
+ * to match the value in Qemu itself.
+ */
+#define QEMU_C0_COUNTER_CLOCK  100000000
+
+#endif /* __ASM_QEMU_H */
index da03a32c1ca785ed8b1b10d3811f8da8fb41153b..5bea49feec66c85dc32395804e4c6157eaef6607 100644 (file)
@@ -171,11 +171,11 @@ static inline void blast_dcache16(void)
        unsigned long start = INDEX_BASE;
        unsigned long end = start + current_cpu_data.dcache.waysize;
        unsigned long ws_inc = 1UL << current_cpu_data.dcache.waybit;
-       unsigned long ws_end = current_cpu_data.dcache.ways << 
+       unsigned long ws_end = current_cpu_data.dcache.ways <<
                               current_cpu_data.dcache.waybit;
        unsigned long ws, addr;
 
-       for (ws = 0; ws < ws_end; ws += ws_inc) 
+       for (ws = 0; ws < ws_end; ws += ws_inc)
                for (addr = start; addr < end; addr += 0x200)
                        cache16_unroll32(addr|ws,Index_Writeback_Inv_D);
 }
@@ -200,8 +200,8 @@ static inline void blast_dcache16_page_indexed(unsigned long page)
                               current_cpu_data.dcache.waybit;
        unsigned long ws, addr;
 
-       for (ws = 0; ws < ws_end; ws += ws_inc) 
-               for (addr = start; addr < end; addr += 0x200) 
+       for (ws = 0; ws < ws_end; ws += ws_inc)
+               for (addr = start; addr < end; addr += 0x200)
                        cache16_unroll32(addr|ws,Index_Writeback_Inv_D);
 }
 
@@ -214,8 +214,8 @@ static inline void blast_icache16(void)
                               current_cpu_data.icache.waybit;
        unsigned long ws, addr;
 
-       for (ws = 0; ws < ws_end; ws += ws_inc) 
-               for (addr = start; addr < end; addr += 0x200) 
+       for (ws = 0; ws < ws_end; ws += ws_inc)
+               for (addr = start; addr < end; addr += 0x200)
                        cache16_unroll32(addr|ws,Index_Invalidate_I);
 }
 
@@ -239,8 +239,8 @@ static inline void blast_icache16_page_indexed(unsigned long page)
                               current_cpu_data.icache.waybit;
        unsigned long ws, addr;
 
-       for (ws = 0; ws < ws_end; ws += ws_inc) 
-               for (addr = start; addr < end; addr += 0x200) 
+       for (ws = 0; ws < ws_end; ws += ws_inc)
+               for (addr = start; addr < end; addr += 0x200)
                        cache16_unroll32(addr|ws,Index_Invalidate_I);
 }
 
@@ -249,11 +249,11 @@ static inline void blast_scache16(void)
        unsigned long start = INDEX_BASE;
        unsigned long end = start + current_cpu_data.scache.waysize;
        unsigned long ws_inc = 1UL << current_cpu_data.scache.waybit;
-       unsigned long ws_end = current_cpu_data.scache.ways << 
+       unsigned long ws_end = current_cpu_data.scache.ways <<
                               current_cpu_data.scache.waybit;
        unsigned long ws, addr;
 
-       for (ws = 0; ws < ws_end; ws += ws_inc) 
+       for (ws = 0; ws < ws_end; ws += ws_inc)
                for (addr = start; addr < end; addr += 0x200)
                        cache16_unroll32(addr|ws,Index_Writeback_Inv_SD);
 }
@@ -278,8 +278,8 @@ static inline void blast_scache16_page_indexed(unsigned long page)
                               current_cpu_data.scache.waybit;
        unsigned long ws, addr;
 
-       for (ws = 0; ws < ws_end; ws += ws_inc) 
-               for (addr = start; addr < end; addr += 0x200) 
+       for (ws = 0; ws < ws_end; ws += ws_inc)
+               for (addr = start; addr < end; addr += 0x200)
                        cache16_unroll32(addr|ws,Index_Writeback_Inv_SD);
 }
 
@@ -318,8 +318,8 @@ static inline void blast_dcache32(void)
                               current_cpu_data.dcache.waybit;
        unsigned long ws, addr;
 
-       for (ws = 0; ws < ws_end; ws += ws_inc) 
-               for (addr = start; addr < end; addr += 0x400) 
+       for (ws = 0; ws < ws_end; ws += ws_inc)
+               for (addr = start; addr < end; addr += 0x400)
                        cache32_unroll32(addr|ws,Index_Writeback_Inv_D);
 }
 
@@ -343,8 +343,8 @@ static inline void blast_dcache32_page_indexed(unsigned long page)
                               current_cpu_data.dcache.waybit;
        unsigned long ws, addr;
 
-       for (ws = 0; ws < ws_end; ws += ws_inc) 
-               for (addr = start; addr < end; addr += 0x400) 
+       for (ws = 0; ws < ws_end; ws += ws_inc)
+               for (addr = start; addr < end; addr += 0x400)
                        cache32_unroll32(addr|ws,Index_Writeback_Inv_D);
 }
 
@@ -357,8 +357,8 @@ static inline void blast_icache32(void)
                               current_cpu_data.icache.waybit;
        unsigned long ws, addr;
 
-       for (ws = 0; ws < ws_end; ws += ws_inc) 
-               for (addr = start; addr < end; addr += 0x400) 
+       for (ws = 0; ws < ws_end; ws += ws_inc)
+               for (addr = start; addr < end; addr += 0x400)
                        cache32_unroll32(addr|ws,Index_Invalidate_I);
 }
 
@@ -383,7 +383,7 @@ static inline void blast_icache32_page_indexed(unsigned long page)
        unsigned long ws, addr;
 
        for (ws = 0; ws < ws_end; ws += ws_inc)
-               for (addr = start; addr < end; addr += 0x400) 
+               for (addr = start; addr < end; addr += 0x400)
                        cache32_unroll32(addr|ws,Index_Invalidate_I);
 }
 
@@ -392,11 +392,11 @@ static inline void blast_scache32(void)
        unsigned long start = INDEX_BASE;
        unsigned long end = start + current_cpu_data.scache.waysize;
        unsigned long ws_inc = 1UL << current_cpu_data.scache.waybit;
-       unsigned long ws_end = current_cpu_data.scache.ways << 
+       unsigned long ws_end = current_cpu_data.scache.ways <<
                               current_cpu_data.scache.waybit;
        unsigned long ws, addr;
 
-       for (ws = 0; ws < ws_end; ws += ws_inc) 
+       for (ws = 0; ws < ws_end; ws += ws_inc)
                for (addr = start; addr < end; addr += 0x400)
                        cache32_unroll32(addr|ws,Index_Writeback_Inv_SD);
 }
@@ -421,8 +421,8 @@ static inline void blast_scache32_page_indexed(unsigned long page)
                               current_cpu_data.scache.waybit;
        unsigned long ws, addr;
 
-       for (ws = 0; ws < ws_end; ws += ws_inc) 
-               for (addr = start; addr < end; addr += 0x400) 
+       for (ws = 0; ws < ws_end; ws += ws_inc)
+               for (addr = start; addr < end; addr += 0x400)
                        cache32_unroll32(addr|ws,Index_Writeback_Inv_SD);
 }
 
@@ -461,8 +461,8 @@ static inline void blast_icache64(void)
                               current_cpu_data.icache.waybit;
        unsigned long ws, addr;
 
-       for (ws = 0; ws < ws_end; ws += ws_inc) 
-               for (addr = start; addr < end; addr += 0x800) 
+       for (ws = 0; ws < ws_end; ws += ws_inc)
+               for (addr = start; addr < end; addr += 0x800)
                        cache64_unroll32(addr|ws,Index_Invalidate_I);
 }
 
@@ -487,7 +487,7 @@ static inline void blast_icache64_page_indexed(unsigned long page)
        unsigned long ws, addr;
 
        for (ws = 0; ws < ws_end; ws += ws_inc)
-               for (addr = start; addr < end; addr += 0x800) 
+               for (addr = start; addr < end; addr += 0x800)
                        cache64_unroll32(addr|ws,Index_Invalidate_I);
 }
 
@@ -496,11 +496,11 @@ static inline void blast_scache64(void)
        unsigned long start = INDEX_BASE;
        unsigned long end = start + current_cpu_data.scache.waysize;
        unsigned long ws_inc = 1UL << current_cpu_data.scache.waybit;
-       unsigned long ws_end = current_cpu_data.scache.ways << 
+       unsigned long ws_end = current_cpu_data.scache.ways <<
                               current_cpu_data.scache.waybit;
        unsigned long ws, addr;
 
-       for (ws = 0; ws < ws_end; ws += ws_inc) 
+       for (ws = 0; ws < ws_end; ws += ws_inc)
                for (addr = start; addr < end; addr += 0x800)
                        cache64_unroll32(addr|ws,Index_Writeback_Inv_SD);
 }
@@ -525,8 +525,8 @@ static inline void blast_scache64_page_indexed(unsigned long page)
                               current_cpu_data.scache.waybit;
        unsigned long ws, addr;
 
-       for (ws = 0; ws < ws_end; ws += ws_inc) 
-               for (addr = start; addr < end; addr += 0x800) 
+       for (ws = 0; ws < ws_end; ws += ws_inc)
+               for (addr = start; addr < end; addr += 0x800)
                        cache64_unroll32(addr|ws,Index_Writeback_Inv_SD);
 }
 
@@ -561,11 +561,11 @@ static inline void blast_scache128(void)
        unsigned long start = INDEX_BASE;
        unsigned long end = start + current_cpu_data.scache.waysize;
        unsigned long ws_inc = 1UL << current_cpu_data.scache.waybit;
-       unsigned long ws_end = current_cpu_data.scache.ways << 
+       unsigned long ws_end = current_cpu_data.scache.ways <<
                               current_cpu_data.scache.waybit;
        unsigned long ws, addr;
 
-       for (ws = 0; ws < ws_end; ws += ws_inc) 
+       for (ws = 0; ws < ws_end; ws += ws_inc)
                for (addr = start; addr < end; addr += 0x1000)
                        cache128_unroll32(addr|ws,Index_Writeback_Inv_SD);
 }
@@ -590,8 +590,8 @@ static inline void blast_scache128_page_indexed(unsigned long page)
                               current_cpu_data.scache.waybit;
        unsigned long ws, addr;
 
-       for (ws = 0; ws < ws_end; ws += ws_inc) 
-               for (addr = start; addr < end; addr += 0x1000) 
+       for (ws = 0; ws < ws_end; ws += ws_inc)
+               for (addr = start; addr < end; addr += 0x1000)
                        cache128_unroll32(addr|ws,Index_Writeback_Inv_SD);
 }
 
index 7b33bbca95857f8f7fdcbcb7670d3ebb74ac0dea..6173004cc88ec72f443f617fdbf17b3a7ad3a32a 100644 (file)
@@ -14,7 +14,7 @@
 
 #include <linux/config.h>
 
-#if defined(CONFIG_MIPS32) || defined(WANT_COMPAT_REG_H)
+#if defined(CONFIG_32BIT) || defined(WANT_COMPAT_REG_H)
 
 #define EF_R0                  6
 #define EF_R1                  7
@@ -70,7 +70,7 @@
 
 #endif
 
-#if CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 
 #define EF_R0                   0
 #define EF_R1                   1
 
 #define EF_SIZE                        304     /* size in bytes */
 
-#endif /* CONFIG_MIPS64 */
+#endif /* CONFIG_64BIT */
 
 #endif /* __ASM_MIPS_REG_H */
index fd3c6d17a5f63e89aedd39e27c3dd4086c65e795..1fba00c2207714bc83c3911ca393954ec3afb1b1 100644 (file)
@@ -27,7 +27,7 @@
  * but we keep the old value on MIPS32,
  * for compatibility:
  */
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 # define RLIM_INFINITY         0x7fffffffUL
 #endif
 
index 31c0c2347f4f82ead18ab5979d917ea1abf828d6..3c4b637fd925894da65134e0ec82c33d84053f11 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * include/asm-mips/rtc.h 
+ * include/asm-mips/rtc.h
  *
  * (Really an interface for drivers/char/genrtc.c)
  *
index a38d66f9987240058bb263bd69e63d481e9fbe12..889cf028c95d4b2e3e4c39918c01a19bcb2462a3 100644 (file)
@@ -16,7 +16,7 @@
  *
  * The Indigo and Indy have two GIO bus connectors. Indigo2 (all models) have
  * three physical connectors, but only two slots, GFX and EXP0.
- * 
+ *
  * There is 10MB of GIO address space for GIO64 slot devices
  * slot#   slot type address range            size
  * -----   --------- ----------------------- -----
index a5b988d7327ab1a3c765921bf91e7f3ae7cae78a..ac3dfc7af5b0e9b78a4d663e8d8855fe2096eb9c 100644 (file)
@@ -221,7 +221,7 @@ struct hpc3_regs {
 #define HPC3_BESTAT_PIDMASK    0x3f700 /* DMA channel parity identifier */
 
        u32 _unused1[0x14000/4 - 5];    /* padding */
-       
+
        /* Now direct PIO per-HPC3 peripheral access to external regs. */
        volatile u32 scsi0_ext[256];    /* SCSI channel 0 external regs */
        u32 _unused2[0x7c00/4];
@@ -304,7 +304,7 @@ struct hpc3_regs {
        volatile u32 bbram[8192-50-14]; /* Battery backed ram */
 };
 
-/* 
+/*
  * It is possible to have two HPC3's within the address space on
  * one machine, though only having one is more likely on an Indy.
  */
index 169187f53fbc8df39e72de48a14fc1e6de2685bc..f3e3dc9bb73239341d280f0f9eab70d20c2b756e 100644 (file)
@@ -16,7 +16,7 @@
 #include <linux/types.h>
 #include <asm/sgi/pi1.h>
 
-/* 
+/*
  * All registers are 8-bit wide alligned on 32-bit boundary. Bad things
  * happen if you try word access them. You have been warned.
  */
@@ -138,7 +138,7 @@ struct sgioc_regs {
        u8 _sysid[3];
        volatile u8 sysid;
 #define SGIOC_SYSID_FULLHOUSE  0x01
-#define SGIOC_SYSID_BOARDREV(x)        ((x & 0xe0) > 5) 
+#define SGIOC_SYSID_BOARDREV(x)        ((x & 0xe0) > 5)
 #define SGIOC_SYSID_CHIPREV(x) ((x & 0x1e) > 1)
        u32 _unused2;
        u8 _read[3];
index 97d73adb4e40b67b89d268b29de7a444e8fcd8e9..bbfc05c3cab93c26137930b7e5b1fece233f0036 100644 (file)
@@ -12,7 +12,7 @@
 #ifndef _SGI_IP22_H
 #define _SGI_IP22_H
 
-/* 
+/*
  * These are the virtual IRQ numbers, we divide all IRQ's into
  * 'spaces', the 'space' determines where and how to enable/disable
  * that particular IRQ on an SGI machine. HPC DMA and MC DMA interrups
index fd98f930607c12db13e355b2b53516f0b903da2c..c52f7834c7c87e9252d260eaa716d7dd82b761d4 100644 (file)
@@ -182,14 +182,14 @@ struct sgimc_regs {
        volatile u32 dtlb_hi3;
        u32 _unused33;
        volatile u32 dtlb_lo3;
-       
+
        u32 _unused34[0x0392];
-       
+
        u32 _unused35;
        volatile u32 rpsscounter;       /* Chirps at 100ns */
 
        u32 _unused36[0x1000/4-2*4];
-       
+
        u32 _unused37;
        volatile u32 maddronly;         /* Address DMA goes at */
        u32 _unused38;
index 59450335f04982f1000b8b4f818d0b82a73d61a1..722b77a8c5e5a010fe693374ac37644c7a6cd43f 100644 (file)
@@ -367,7 +367,7 @@ struct linux_smonblock {
  * Macros for calling a 32-bit ARC implementation from 64-bit code
  */
 
-#if defined(CONFIG_MIPS64) && defined(CONFIG_ARC32)
+#if defined(CONFIG_64BIT) && defined(CONFIG_ARC32)
 
 #define __arc_clobbers                                                 \
        "$2","$3" /* ... */, "$8","$9","$10","$11",                     \
@@ -476,10 +476,10 @@ struct linux_smonblock {
        __res;                                                          \
 })
 
-#endif /* defined(CONFIG_MIPS64) && defined(CONFIG_ARC32) */
+#endif /* defined(CONFIG_64BIT) && defined(CONFIG_ARC32) */
 
-#if (defined(CONFIG_MIPS32) && defined(CONFIG_ARC32)) ||               \
-    (defined(CONFIG_MIPS64) && defined(CONFIG_ARC64))
+#if (defined(CONFIG_32BIT) && defined(CONFIG_ARC32)) ||                \
+    (defined(CONFIG_64BIT) && defined(CONFIG_ARC64))
 
 #define ARC_CALL0(dest)                                                        \
 ({     long __res;                                                     \
index 7ac5da13ce8a15a7b9ebdd7d4dbd49320bf64471..b5e7dae19f0fc7842d5a10fdc4379af41254dde3 100644 (file)
 
 #define SIBYTE_BOARD_NAME "Carmel"
 
-#define GPIO_PHY_INTERRUPT      2 
-#define GPIO_NONMASKABLE_INT    3 
-#define GPIO_CF_INSERTED        6 
-#define GPIO_MONTEREY_RESET     7 
-#define GPIO_QUADUART_INT       8 
-#define GPIO_CF_INT             9 
+#define GPIO_PHY_INTERRUPT      2
+#define GPIO_NONMASKABLE_INT    3
+#define GPIO_CF_INSERTED        6
+#define GPIO_MONTEREY_RESET     7
+#define GPIO_QUADUART_INT       8
+#define GPIO_CF_INT             9
 #define GPIO_FPGA_CCLK          10
 #define GPIO_FPGA_DOUT          11
 #define GPIO_FPGA_DIN           12
index 96088fb074a4e8103f5090917610fcf53b517623..40ef97c76c8b531f4c523765d7fc710b593ce981 100644 (file)
@@ -1,23 +1,23 @@
 /*  *********************************************************************
     *  SB1250 Board Support Package
-    *  
-    *  Global constants and macros             File: sb1250_defs.h     
-    *  
+    *
+    *  Global constants and macros             File: sb1250_defs.h
+    *
     *  This file contains macros and definitions used by the other
     *  include files.
     *
     *  SB1250 specification level:  User's manual 1/02/02
-    *  
+    *
     *  Author:  Mitch Lichtenberg
-    *  
-    *********************************************************************  
+    *
+    *********************************************************************
     *
     *  Copyright 2000,2001,2002,2003
     *  Broadcom Corporation. All rights reserved.
-    *  
-    *  This program is free software; you can redistribute it and/or 
-    *  modify it under the terms of the GNU General Public License as 
-    *  published by the Free Software Foundation; either version 2 of 
+    *
+    *  This program is free software; you can redistribute it and/or
+    *  modify it under the terms of the GNU General Public License as
+    *  published by the Free Software Foundation; either version 2 of
     *  the License, or (at your option) any later version.
     *
     *  This program is distributed in the hope that it will be useful,
@@ -27,7 +27,7 @@
     *
     *  You should have received a copy of the GNU General Public License
     *  along with this program; if not, write to the Free Software
-    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
     *  MA 02111-1307 USA
     ********************************************************************* */
 
 #define        SIBYTE_HDR_FMASK_112x_ALL               0x0000f00
 #define        SIBYTE_HDR_FMASK_112x_PASS1             0x0000100
 
-/* Bit mask for chip/revision.  (use _ALL for all revisions of a chip).  */ 
+/* Bit mask for chip/revision.  (use _ALL for all revisions of a chip).  */
 #define        SIBYTE_HDR_FMASK(chip, pass)                                    \
     (SIBYTE_HDR_FMASK_ ## chip ## _ ## pass)
 #define        SIBYTE_HDR_FMASK_ALLREVS(chip)                                  \
 
 /*  *********************************************************************
     *  Naming schemes for constants in these files:
-    *  
-    *  M_xxx           MASK constant (identifies bits in a register). 
+    *
+    *  M_xxx           MASK constant (identifies bits in a register).
     *                  For multi-bit fields, all bits in the field will
     *                  be set.
     *
     *  K_xxx           "Code" constant (value for data in a multi-bit
     *                  field).  The value is right justified.
     *
-    *  V_xxx           "Value" constant.  This is the same as the 
+    *  V_xxx           "Value" constant.  This is the same as the
     *                  corresponding "K_xxx" constant, except it is
     *                  shifted to the correct position in the register.
     *
     *  S_xxx           SHIFT constant.  This is the number of bits that
-    *                  a field value (code) needs to be shifted 
+    *                  a field value (code) needs to be shifted
     *                  (towards the left) to put the value in the right
     *                  position for the register.
     *
-    *  A_xxx           ADDRESS constant.  This will be a physical 
+    *  A_xxx           ADDRESS constant.  This will be a physical
     *                  address.  Use the PHYS_TO_K1 macro to generate
     *                  a K1SEG address.
     *
     *  R_xxx           RELATIVE offset constant.  This is an offset from
     *                  an A_xxx constant (usually the first register in
     *                  a group).
-    *  
+    *
     *  G_xxx(X)        GET value.  This macro obtains a multi-bit field
     *                  from a register, masks it, and shifts it to
     *                  the bottom of the register (retrieving a K_xxx
 
 
 /*
- * Cast to 64-bit number.  Presumably the syntax is different in 
+ * Cast to 64-bit number.  Presumably the syntax is different in
  * assembly language.
  *
  * Note: you'll need to define uint32_t and uint64_t in your headers.
index f1b08d32338db002e4794f848d9670dbf135571a..3cdb48f50ed02f594272c6b3ea8c868f17ac68fd 100644 (file)
@@ -1,24 +1,24 @@
 /*  *********************************************************************
     *  SB1250 Board Support Package
-    *  
+    *
     *  DMA definitions                         File: sb1250_dma.h
-    *  
+    *
     *  This module contains constants and macros useful for
     *  programming the SB1250's DMA controllers, both the data mover
     *  and the Ethernet DMA.
-    *  
+    *
     *  SB1250 specification level:  User's manual 1/02/02
-    *  
+    *
     *  Author:  Mitch Lichtenberg
-    *  
-    *********************************************************************  
+    *
+    *********************************************************************
     *
     *  Copyright 2000,2001,2002,2003
     *  Broadcom Corporation. All rights reserved.
-    *  
-    *  This program is free software; you can redistribute it and/or 
-    *  modify it under the terms of the GNU General Public License as 
-    *  published by the Free Software Foundation; either version 2 of 
+    *
+    *  This program is free software; you can redistribute it and/or
+    *  modify it under the terms of the GNU General Public License as
+    *  published by the Free Software Foundation; either version 2 of
     *  the License, or (at your option) any later version.
     *
     *  This program is distributed in the hope that it will be useful,
@@ -28,7 +28,7 @@
     *
     *  You should have received a copy of the GNU General Public License
     *  along with this program; if not, write to the Free Software
-    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
     *  MA 02111-1307 USA
     ********************************************************************* */
 
@@ -43,9 +43,9 @@
     *  DMA Registers
     ********************************************************************* */
 
-/* 
+/*
  * Ethernet and Serial DMA Configuration Register 0  (Table 7-4)
- * Registers: DMA_CONFIG0_MAC_x_RX_CH_0 
+ * Registers: DMA_CONFIG0_MAC_x_RX_CH_0
  * Registers: DMA_CONFIG0_MAC_x_TX_CH_0
  * Registers: DMA_CONFIG0_SER_x_RX
  * Registers: DMA_CONFIG0_SER_x_TX
@@ -98,7 +98,7 @@
 
 /*
  * Ethernet and Serial DMA Configuration Register 1 (Table 7-5)
- * Registers: DMA_CONFIG1_MAC_x_RX_CH_0 
+ * Registers: DMA_CONFIG1_MAC_x_RX_CH_0
  * Registers: DMA_CONFIG1_DMA_x_TX_CH_0
  * Registers: DMA_CONFIG1_SER_x_RX
  * Registers: DMA_CONFIG1_SER_x_TX
 /*
  * DMA Descriptor Count Registers (Table 7-8)
  */
+
 /* No bitfields */
 
 
-/* 
+/*
  * Current Descriptor Address Register (Table 7-11)
  */
 
 #define V_DMA_DSCRB_STATUS(x)       _SB_MAKEVALUE(x,S_DMA_DSCRB_STATUS)
 #define G_DMA_DSCRB_STATUS(x)       _SB_GETVALUE(x,S_DMA_DSCRB_STATUS,M_DMA_DSCRB_STATUS)
 
-/* 
+/*
  * Ethernet Descriptor Status Bits (Table 7-15)
  */
 
 #define M_DMA_ETHRX_BADIP4CS        _SB_MAKEMASK1(51)
 #define M_DMA_ETHRX_DSCRERR        _SB_MAKEMASK1(52)
 
-#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) 
+#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1)
 /* Note: BADTCPCS is actually in DSCR_B options field */
 #define M_DMA_ETHRX_BADTCPCS   _SB_MAKEMASK1(0)
 #endif /* 1250 PASS2 || 112x PASS1 */
 
 #define M_DMA_ETHTX_SOP                    _SB_MAKEMASK1(63)
 
-/* 
+/*
  * Ethernet Transmit Options (Table 7-17)
  */
 
     *  Data Mover Registers
     ********************************************************************* */
 
-/* 
+/*
  * Data Mover Descriptor Base Address Register (Table 7-22)
  * Register: DM_DSCR_BASE_0
  * Register: DM_DSCR_BASE_1
 #define M_DM_DSCR_BASE_ABORT        _SB_MAKEMASK1(62)
 #define M_DM_DSCR_BASE_ENABL        _SB_MAKEMASK1(63)
 
-/* 
+/*
  * Data Mover Descriptor Count Register (Table 7-25)
  */
 
index 0d9dfac3d7db737dc7ee19d7f97d997adde49466..f1f509f295c4dfe66aa8c65667211b6c4878ec32 100644 (file)
@@ -1,23 +1,23 @@
 /*  *********************************************************************
     *  SB1250 Board Support Package
-    *  
+    *
     *  Generic Bus Constants                     File: sb1250_genbus.h
-    *  
-    *  This module contains constants and macros useful for 
+    *
+    *  This module contains constants and macros useful for
     *  manipulating the SB1250's Generic Bus interface
-    *  
+    *
     *  SB1250 specification level:  User's manual 1/02/02
-    *  
+    *
     *  Author:  Mitch Lichtenberg
-    *  
-    *********************************************************************  
+    *
+    *********************************************************************
     *
     *  Copyright 2000,2001,2002,2003
     *  Broadcom Corporation. All rights reserved.
-    *  
-    *  This program is free software; you can redistribute it and/or 
-    *  modify it under the terms of the GNU General Public License as 
-    *  published by the Free Software Foundation; either version 2 of 
+    *
+    *  This program is free software; you can redistribute it and/or
+    *  modify it under the terms of the GNU General Public License as
+    *  published by the Free Software Foundation; either version 2 of
     *  the License, or (at your option) any later version.
     *
     *  This program is distributed in the hope that it will be useful,
@@ -27,7 +27,7 @@
     *
     *  You should have received a copy of the GNU General Public License
     *  along with this program; if not, write to the Free Software
-    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
     *  MA 02111-1307 USA
     ********************************************************************* */
 
index c3f74df211f4bdc67fa7931cd6345071b11afa34..e173e2ea4c981c60630b8e78dcc789344776142a 100644 (file)
@@ -1,23 +1,23 @@
 /*  *********************************************************************
     *  SB1250 Board Support Package
-    *  
+    *
     *  Interrupt Mapper definitions            File: sb1250_int.h
-    *  
+    *
     *  This module contains constants for manipulating the SB1250's
     *  interrupt mapper and definitions for the interrupt sources.
-    *  
+    *
     *  SB1250 specification level:  User's manual 1/02/02
-    *  
+    *
     *  Author:  Mitch Lichtenberg
-    *  
-    *********************************************************************  
+    *
+    *********************************************************************
     *
     *  Copyright 2000,2001,2002,2003
     *  Broadcom Corporation. All rights reserved.
-    *  
-    *  This program is free software; you can redistribute it and/or 
-    *  modify it under the terms of the GNU General Public License as 
-    *  published by the Free Software Foundation; either version 2 of 
+    *
+    *  This program is free software; you can redistribute it and/or
+    *  modify it under the terms of the GNU General Public License as
+    *  published by the Free Software Foundation; either version 2 of
     *  the License, or (at your option) any later version.
     *
     *  This program is distributed in the hope that it will be useful,
@@ -27,7 +27,7 @@
     *
     *  You should have received a copy of the GNU General Public License
     *  along with this program; if not, write to the Free Software
-    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
     *  MA 02111-1307 USA
     ********************************************************************* */
 
@@ -43,7 +43,7 @@
 
 /*
  * Interrupt sources (Table 4-8, UM 0.2)
- * 
+ *
  * First, the interrupt numbers.
  */
 
index 799db828d9632a48c643e44583c0ebc4c636e802..8afe8e01581b3cac16d133ad28208f0a319cd113 100644 (file)
@@ -1,23 +1,23 @@
 /*  *********************************************************************
     *  SB1250 Board Support Package
-    *  
+    *
     *  L2 Cache constants and macros           File: sb1250_l2c.h
-    *  
+    *
     *  This module contains constants useful for manipulating the
     *  level 2 cache.
-    *  
+    *
     *  SB1250 specification level:  User's manual 1/02/02
-    *  
+    *
     *  Author:  Mitch Lichtenberg
-    *  
-    *********************************************************************  
+    *
+    *********************************************************************
     *
     *  Copyright 2000,2001,2002,2003
     *  Broadcom Corporation. All rights reserved.
-    *  
-    *  This program is free software; you can redistribute it and/or 
-    *  modify it under the terms of the GNU General Public License as 
-    *  published by the Free Software Foundation; either version 2 of 
+    *
+    *  This program is free software; you can redistribute it and/or
+    *  modify it under the terms of the GNU General Public License as
+    *  published by the Free Software Foundation; either version 2 of
     *  the License, or (at your option) any later version.
     *
     *  This program is distributed in the hope that it will be useful,
@@ -27,7 +27,7 @@
     *
     *  You should have received a copy of the GNU General Public License
     *  along with this program; if not, write to the Free Software
-    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
     *  MA 02111-1307 USA
     ********************************************************************* */
 
index d8753885df1727ca5f5ae753b72413aeadc2d064..f2617ded0a8f0f80a56fd10bdbbe5297beff6df4 100644 (file)
@@ -1,23 +1,23 @@
 /*  *********************************************************************
     *  SB1250 Board Support Package
-    *  
+    *
     *  LDT constants                           File: sb1250_ldt.h
-    *  
-    *  This module contains constants and macros to describe 
-    *  the LDT interface on the SB1250.  
-    *  
+    *
+    *  This module contains constants and macros to describe
+    *  the LDT interface on the SB1250.
+    *
     *  SB1250 specification level:  User's manual 1/02/02
-    *  
+    *
     *  Author:  Mitch Lichtenberg
-    *  
-    *********************************************************************  
+    *
+    *********************************************************************
     *
     *  Copyright 2000,2001,2002,2003
     *  Broadcom Corporation. All rights reserved.
-    *  
-    *  This program is free software; you can redistribute it and/or 
-    *  modify it under the terms of the GNU General Public License as 
-    *  published by the Free Software Foundation; either version 2 of 
+    *
+    *  This program is free software; you can redistribute it and/or
+    *  modify it under the terms of the GNU General Public License as
+    *  published by the Free Software Foundation; either version 2 of
     *  the License, or (at your option) any later version.
     *
     *  This program is distributed in the hope that it will be useful,
@@ -27,7 +27,7 @@
     *
     *  You should have received a copy of the GNU General Public License
     *  along with this program; if not, write to the Free Software
-    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
     *  MA 02111-1307 USA
     ********************************************************************* */
 
 
 /*
  * LDT Status Register (Table 8-14).  Note that these constants
- * assume you've read the command and status register 
+ * assume you've read the command and status register
  * together (32-bit read at offset 0x04)
  *
  * These bits also apply to the secondary status
 #define M_LDT_STATUS_DETPARERR         _SB_MAKEMASK1_32(31)
 
 /*
- * Bridge Control Register (Table 8-16).  Note that these 
- * constants assume you've read the register as a 32-bit 
+ * Bridge Control Register (Table 8-16).  Note that these
+ * constants assume you've read the register as a 32-bit
  * read (offset 0x3C)
  */
 
index 81f603f03a98ff11dfc8b08f3972d5cfbf6f2142..18e74e43f4a2b7fd34333c03512ebc982d912610 100644 (file)
@@ -1,23 +1,23 @@
 /*  *********************************************************************
     *  SB1250 Board Support Package
-    *  
+    *
     *  MAC constants and macros                        File: sb1250_mac.h
-    *  
+    *
     *  This module contains constants and macros for the SB1250's
     *  ethernet controllers.
-    *  
+    *
     *  SB1250 specification level:  User's manual 1/02/02
-    *  
+    *
     *  Author:  Mitch Lichtenberg
-    *  
-    *********************************************************************  
+    *
+    *********************************************************************
     *
     *  Copyright 2000,2001,2002,2003
     *  Broadcom Corporation. All rights reserved.
-    *  
-    *  This program is free software; you can redistribute it and/or 
-    *  modify it under the terms of the GNU General Public License as 
-    *  published by the Free Software Foundation; either version 2 of 
+    *
+    *  This program is free software; you can redistribute it and/or
+    *  modify it under the terms of the GNU General Public License as
+    *  published by the Free Software Foundation; either version 2 of
     *  the License, or (at your option) any later version.
     *
     *  This program is distributed in the hope that it will be useful,
@@ -27,7 +27,7 @@
     *
     *  You should have received a copy of the GNU General Public License
     *  along with this program; if not, write to the Free Software
-    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
     *  MA 02111-1307 USA
     ********************************************************************* */
 
 
 /*
  * These constants are used to configure the fields within the Frame
- * Configuration Register.  
+ * Configuration Register.
  */
 
 #define K_MAC_IFG_RX_10             _SB_MAKE64(0)      /* See table 176, not used */
  * Register: MAC_INT_MASK_2
  */
 
-/* 
+/*
  * Use these constants to shift the appropriate channel
  * into the CH0 position so the same tests can be used
  * on each channel.
index 93a48334b874cbabb65f2b589ab164849b49f0d1..1dd41c9279965c476bc5ea3d846e7e295488d977 100644 (file)
@@ -1,23 +1,23 @@
 /*  *********************************************************************
     *  SB1250 Board Support Package
-    *  
-    *  Memory Controller constants              File: sb1250_mc.h       
-    *  
+    *
+    *  Memory Controller constants              File: sb1250_mc.h
+    *
     *  This module contains constants and macros useful for
     *  programming the memory controller.
-    *  
+    *
     *  SB1250 specification level:  User's manual 1/02/02
-    *  
+    *
     *  Author:  Mitch Lichtenberg
-    *  
-    *********************************************************************  
+    *
+    *********************************************************************
     *
     *  Copyright 2000,2001,2002,2003
     *  Broadcom Corporation. All rights reserved.
-    *  
-    *  This program is free software; you can redistribute it and/or 
-    *  modify it under the terms of the GNU General Public License as 
-    *  published by the Free Software Foundation; either version 2 of 
+    *
+    *  This program is free software; you can redistribute it and/or
+    *  modify it under the terms of the GNU General Public License as
+    *  published by the Free Software Foundation; either version 2 of
     *  the License, or (at your option) any later version.
     *
     *  This program is distributed in the hope that it will be useful,
@@ -27,7 +27,7 @@
     *
     *  You should have received a copy of the GNU General Public License
     *  along with this program; if not, write to the Free Software
-    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
     *  MA 02111-1307 USA
     ********************************************************************* */
 
 
 #define K_MC_REF_RATE_100MHz         0x62
 #define K_MC_REF_RATE_133MHz         0x81
-#define K_MC_REF_RATE_200MHz         0xC4 
+#define K_MC_REF_RATE_200MHz         0xC4
 
 #define V_MC_REF_RATE_100MHz         V_MC_REF_RATE(K_MC_REF_RATE_100MHz)
 #define V_MC_REF_RATE_133MHz         V_MC_REF_RATE(K_MC_REF_RATE_133MHz)
                                      V_MC_ADDR_DRIVE_DEFAULT | \
                                      V_MC_DATA_DRIVE_DEFAULT | \
                                      V_MC_CLOCK_DRIVE_DEFAULT | \
-                                     V_MC_REF_RATE_DEFAULT 
+                                     V_MC_REF_RATE_DEFAULT
 
 
 
index 5d496c6faba61931e182a2f32a3794c9ad9cee1f..9db80cd13a79f7025d02eee7be4e067d9d45fa3a 100644 (file)
@@ -1,23 +1,23 @@
 /*  *********************************************************************
     *  SB1250 Board Support Package
-    *  
+    *
     *  Register Definitions                     File: sb1250_regs.h
-    *  
+    *
     *  This module contains the addresses of the on-chip peripherals
     *  on the SB1250.
-    *  
+    *
     *  SB1250 specification level:  01/02/2002
-    *  
+    *
     *  Author:  Mitch Lichtenberg
-    *  
-    *********************************************************************  
+    *
+    *********************************************************************
     *
     *  Copyright 2000,2001,2002,2003
     *  Broadcom Corporation. All rights reserved.
-    *  
-    *  This program is free software; you can redistribute it and/or 
-    *  modify it under the terms of the GNU General Public License as 
-    *  published by the Free Software Foundation; either version 2 of 
+    *
+    *  This program is free software; you can redistribute it and/or
+    *  modify it under the terms of the GNU General Public License as
+    *  published by the Free Software Foundation; either version 2 of
     *  the License, or (at your option) any later version.
     *
     *  This program is distributed in the hope that it will be useful,
@@ -27,7 +27,7 @@
     *
     *  You should have received a copy of the GNU General Public License
     *  along with this program; if not, write to the Free Software
-    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
     *  MA 02111-1307 USA
     ********************************************************************* */
 
 
 /*  *********************************************************************
     *  Some general notes:
-    *  
+    *
     *  For the most part, when there is more than one peripheral
     *  of the same type on the SOC, the constants below will be
     *  offsets from the base of each peripheral.  For example,
     *  the MAC registers are described as offsets from the first
     *  MAC register, and there will be a MAC_REGISTER() macro
-    *  to calculate the base address of a given MAC.  
-    *  
+    *  to calculate the base address of a given MAC.
+    *
     *  The information in this file is based on the SB1250 SOC
     *  manual version 0.2, July 2000.
     ********************************************************************* */
 
 
-/*  ********************************************************************* 
+/*  *********************************************************************
     * Memory Controller Registers
     ********************************************************************* */
 
 #define R_MC_TEST_ECC               0x0000000420
 #define R_MC_MCLK_CFG               0x0000000500
 
-/*  ********************************************************************* 
+/*  *********************************************************************
     * L2 Cache Control Registers
     ********************************************************************* */
 
 #define A_L2_EEC_ADDRESS            A_L2_ECC_TAG
 
 
-/*  ********************************************************************* 
+/*  *********************************************************************
     * PCI Interface Registers
     ********************************************************************* */
 
 #define A_PCI_TYPE01_HEADER         0x00DE000800
 
 
-/*  ********************************************************************* 
+/*  *********************************************************************
     * Ethernet DMA and MACs
     ********************************************************************* */
 
             (R_MAC_DMA_CHANNEL_BASE(txrx,chan) +    \
             (reg))
 
-/* 
+/*
  * DMA channel registers, relative to A_MAC_DMA_CHANNEL_BASE
  */
 
 #define MAC_CHMAP_COUNT                        4
 
 
-/*  ********************************************************************* 
+/*  *********************************************************************
     * DUART Registers
     ********************************************************************* */
 
 #endif /* 1250 PASS2 || 112x PASS1 */
 
 
-/*  ********************************************************************* 
+/*  *********************************************************************
     * Synchronous Serial Registers
     ********************************************************************* */
 
             (reg))
 
 
-/* 
+/*
  * DMA channel registers, relative to A_SER_DMA_CHANNEL_BASE
  */
 
 #define R_SER_RMON_RX_ERRORS        0x000001F0
 #define R_SER_RMON_RX_BADADDR       0x000001F8
 
-/*  ********************************************************************* 
+/*  *********************************************************************
     * Generic Bus Registers
     ********************************************************************* */
 
 #define R_IO_PCMCIA_CFG             0x0A60
 #define R_IO_PCMCIA_STATUS          0x0A70
 
-/*  ********************************************************************* 
+/*  *********************************************************************
     * GPIO Registers
     ********************************************************************* */
 
 #define R_GPIO_PIN_CLR              0x30
 #define R_GPIO_PIN_SET              0x38
 
-/*  ********************************************************************* 
+/*  *********************************************************************
     * SMBus Registers
     ********************************************************************* */
 
 #define R_SMB_CONTROL               0x0000000060
 #define R_SMB_PEC                   0x0000000070
 
-/*  ********************************************************************* 
+/*  *********************************************************************
     * Timer Registers
     ********************************************************************* */
 
 #endif /* 1250 PASS2 || 112x PASS1 */
 
 
-/*  ********************************************************************* 
+/*  *********************************************************************
     * System Control Registers
     ********************************************************************* */
 
 #define A_SCD_SYSTEM_CFG            0x0010020008
 #define A_SCD_SYSTEM_MANUF          0x0010038000
 
-/*  ********************************************************************* 
+/*  *********************************************************************
     * System Address Trap Registers
     ********************************************************************* */
 
 #endif /* 1250 PASS2 || 112x PASS1 */
 
 
-/*  ********************************************************************* 
+/*  *********************************************************************
     * System Interrupt Mapper Registers
     ********************************************************************* */
 
 #define R_IMR_INTERRUPT_MAP_BASE        0x0200
 #define R_IMR_INTERRUPT_MAP_COUNT       64
 
-/*  ********************************************************************* 
+/*  *********************************************************************
     * System Performance Counter Registers
     ********************************************************************* */
 
 #define A_SCD_PERF_CNT_2            0x00100204E0
 #define A_SCD_PERF_CNT_3            0x00100204E8
 
-/*  ********************************************************************* 
+/*  *********************************************************************
     * System Bus Watcher Registers
     ********************************************************************* */
 
 #define A_BUS_L2_ERRORS             0x00100208C0
 #define A_BUS_MEM_IO_ERRORS         0x00100208C8
 
-/*  ********************************************************************* 
+/*  *********************************************************************
     * System Debug Controller Registers
     ********************************************************************* */
 
 #define A_SCD_JTAG_BASE             0x0010000000
 
-/*  ********************************************************************* 
+/*  *********************************************************************
     * System Trace Buffer Registers
     ********************************************************************* */
 
 #define A_SCD_TRACE_SEQUENCE_6      0x0010020A90
 #define A_SCD_TRACE_SEQUENCE_7      0x0010020A98
 
-/*  ********************************************************************* 
+/*  *********************************************************************
     * System Generic DMA Registers
     ********************************************************************* */
 
index 22e8041959e26d211fdb4904a92d2028c6fbcd5d..dbbd682fb47e6955a905608ee30f79efaacc5733 100644 (file)
@@ -1,23 +1,23 @@
 /*  *********************************************************************
     *  SB1250 Board Support Package
-    *  
+    *
     *  SCD Constants and Macros                        File: sb1250_scd.h
-    *  
+    *
     *  This module contains constants and macros useful for
     *  manipulating the System Control and Debug module on the 1250.
-    *  
+    *
     *  SB1250 specification level:  User's manual 1/02/02
-    *  
+    *
     *  Author:  Mitch Lichtenberg
-    *  
-    *********************************************************************  
+    *
+    *********************************************************************
     *
     *  Copyright 2000,2001,2002,2003
     *  Broadcom Corporation. All rights reserved.
-    *  
-    *  This program is free software; you can redistribute it and/or 
-    *  modify it under the terms of the GNU General Public License as 
-    *  published by the Free Software Foundation; either version 2 of 
+    *
+    *  This program is free software; you can redistribute it and/or
+    *  modify it under the terms of the GNU General Public License as
+    *  published by the Free Software Foundation; either version 2 of
     *  the License, or (at your option) any later version.
     *
     *  This program is distributed in the hope that it will be useful,
@@ -27,7 +27,7 @@
     *
     *  You should have received a copy of the GNU General Public License
     *  along with this program; if not, write to the Free Software
-    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
     *  MA 02111-1307 USA
     ********************************************************************* */
 
 /* System Manufacturing Register
 * Register: SCD_SYSTEM_MANUF
 */
+
 /* Wafer ID: bits 31:0 */
 #define S_SYS_WAFERID1_200        _SB_MAKE64(0)
 #define M_SYS_WAFERID1_200        _SB_MAKEMASK(32,S_SYS_WAFERID1_200)
 #define V_SYS_WAFERID1_200(x)     _SB_MAKEVALUE(x,S_SYS_WAFERID1_200)
 #define G_SYS_WAFERID1_200(x)     _SB_GETVALUE(x,S_SYS_WAFERID1_200,M_SYS_WAFERID1_200)
+
 #define S_SYS_BIN                 _SB_MAKE64(32)
 #define M_SYS_BIN                 _SB_MAKEMASK(4,S_SYS_BIN)
 #define V_SYS_BIN                 _SB_MAKEVALUE(x,S_SYS_BIN)
 #define G_SYS_BIN                 _SB_GETVALUE(x,S_SYS_BIN,M_SYS_BIN)
+
 /* Wafer ID: bits 39:36 */
 #define S_SYS_WAFERID2_200        _SB_MAKE64(36)
 #define M_SYS_WAFERID2_200        _SB_MAKEMASK(4,S_SYS_WAFERID2_200)
 #define V_SYS_WAFERID2_200(x)     _SB_MAKEVALUE(x,S_SYS_WAFERID2_200)
 #define G_SYS_WAFERID2_200(x)     _SB_GETVALUE(x,S_SYS_WAFERID2_200,M_SYS_WAFERID2_200)
+
 /* Wafer ID: bits 39:0 */
 #define S_SYS_WAFERID_300         _SB_MAKE64(0)
 #define M_SYS_WAFERID_300         _SB_MAKEMASK(40,S_SYS_WAFERID_300)
 #define V_SYS_WAFERID_300(x)      _SB_MAKEVALUE(x,S_SYS_WAFERID_300)
 #define G_SYS_WAFERID_300(x)      _SB_GETVALUE(x,S_SYS_WAFERID_300,M_SYS_WAFERID_300)
+
 #define S_SYS_XPOS                _SB_MAKE64(40)
 #define M_SYS_XPOS                _SB_MAKEMASK(6,S_SYS_XPOS)
 #define V_SYS_XPOS(x)             _SB_MAKEVALUE(x,S_SYS_XPOS)
 #define G_SYS_XPOS(x)             _SB_GETVALUE(x,S_SYS_XPOS,M_SYS_XPOS)
+
 #define S_SYS_YPOS                _SB_MAKE64(46)
 #define M_SYS_YPOS                _SB_MAKEMASK(6,S_SYS_YPOS)
 #define V_SYS_YPOS(x)             _SB_MAKEVALUE(x,S_SYS_YPOS)
 #define G_SYS_YPOS(x)             _SB_GETVALUE(x,S_SYS_YPOS,M_SYS_YPOS)
+
 /*
  * System Config Register (Table 4-2)
  * Register: SCD_SYSTEM_CFG
index 287cbfe9efa2ce48c2034ee6485c024fd91fb0bd..335c53e9293648afe9d132a2e52bb853f2cf0042 100644 (file)
@@ -1,23 +1,23 @@
 /*  *********************************************************************
     *  SB1250 Board Support Package
-    *  
+    *
     *  SMBUS Constants                          File: sb1250_smbus.h
-    *  
-    *  This module contains constants and macros useful for 
+    *
+    *  This module contains constants and macros useful for
     *  manipulating the SB1250's SMbus devices.
-    *  
+    *
     *  SB1250 specification level:  01/02/2002
-    *  
+    *
     *  Author:  Mitch Lichtenberg
-    *  
-    *********************************************************************  
+    *
+    *********************************************************************
     *
     *  Copyright 2000,2001,2002,2003
     *  Broadcom Corporation. All rights reserved.
-    *  
-    *  This program is free software; you can redistribute it and/or 
-    *  modify it under the terms of the GNU General Public License as 
-    *  published by the Free Software Foundation; either version 2 of 
+    *
+    *  This program is free software; you can redistribute it and/or
+    *  modify it under the terms of the GNU General Public License as
+    *  published by the Free Software Foundation; either version 2 of
     *  the License, or (at your option) any later version.
     *
     *  This program is distributed in the hope that it will be useful,
@@ -27,7 +27,7 @@
     *
     *  You should have received a copy of the GNU General Public License
     *  along with this program; if not, write to the Free Software
-    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
     *  MA 02111-1307 USA
     ********************************************************************* */
 
index 8d5e8edd3c4b9f34ac0abc94cceb9cb9d3b9a8d8..fa2760d38b8b1efd34dd51b7d44231f52dce7f12 100644 (file)
@@ -7,17 +7,17 @@
     *  manipulating the SB1250's Synchronous Serial
     *
     *  SB1250 specification level:  User's manual 1/02/02
-    *  
+    *
     *  Author:  Mitch Lichtenberg
     *
     *********************************************************************
     *
     *  Copyright 2000,2001,2002,2003
     *  Broadcom Corporation. All rights reserved.
-    *  
-    *  This program is free software; you can redistribute it and/or 
-    *  modify it under the terms of the GNU General Public License as 
-    *  published by the Free Software Foundation; either version 2 of 
+    *
+    *  This program is free software; you can redistribute it and/or
+    *  modify it under the terms of the GNU General Public License as
+    *  published by the Free Software Foundation; either version 2 of
     *  the License, or (at your option) any later version.
     *
     *  This program is distributed in the hope that it will be useful,
@@ -27,7 +27,7 @@
     *
     *  You should have received a copy of the GNU General Public License
     *  along with this program; if not, write to the Free Software
-    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
     *  MA 02111-1307 USA
     ********************************************************************* */
 
index 7655d6945cca2bd167deece5e9e02e1ccdfe12f4..923ea4f44e0f785df2b5b50d4c9d08ced1214a5d 100644 (file)
@@ -1,23 +1,23 @@
 /*  *********************************************************************
     *  SB1250 Board Support Package
-    *  
+    *
     *  UART Constants                          File: sb1250_uart.h
-    *  
-    *  This module contains constants and macros useful for 
+    *
+    *  This module contains constants and macros useful for
     *  manipulating the SB1250's UARTs
     *
     *  SB1250 specification level:  User's manual 1/02/02
-    *  
+    *
     *  Author:  Mitch Lichtenberg
-    *  
-    *********************************************************************  
+    *
+    *********************************************************************
     *
     *  Copyright 2000,2001,2002,2003
     *  Broadcom Corporation. All rights reserved.
-    *  
-    *  This program is free software; you can redistribute it and/or 
-    *  modify it under the terms of the GNU General Public License as 
-    *  published by the Free Software Foundation; either version 2 of 
+    *
+    *  This program is free software; you can redistribute it and/or
+    *  modify it under the terms of the GNU General Public License as
+    *  published by the Free Software Foundation; either version 2 of
     *  the License, or (at your option) any later version.
     *
     *  This program is distributed in the hope that it will be useful,
@@ -27,7 +27,7 @@
     *
     *  You should have received a copy of the GNU General Public License
     *  along with this program; if not, write to the Free Software
-    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
     *  MA 02111-1307 USA
     ********************************************************************* */
 
@@ -37,7 +37,7 @@
 
 #include "sb1250_defs.h"
 
-/* ********************************************************************** 
+/* **********************************************************************
    * DUART Registers
    ********************************************************************** */
 
 #define V_DUART_MISC_CMD_START_BREAK     V_DUART_MISC_CMD(K_DUART_MISC_CMD_START_BREAK)
 #define V_DUART_MISC_CMD_STOP_BREAK      V_DUART_MISC_CMD(K_DUART_MISC_CMD_STOP_BREAK)
 
-#define M_DUART_CMD_RESERVED             _SB_MAKEMASK1(7) 
+#define M_DUART_CMD_RESERVED             _SB_MAKEMASK1(7)
 
 /*
  * DUART Status Register (Table 10-6)
 
 /*
  * DUART Baud Rate Register (Table 10-7)
- * Register: DUART_CLK_SEL_A 
+ * Register: DUART_CLK_SEL_A
  * Register: DUART_CLK_SEL_B
  */
 
     (chan == 0 ? M_DUART_OUT_PIN_CLR0 : M_DUART_OUT_PIN_CLR1)
 
 #if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1)
-/* 
+/*
  * Full Interrupt Control Register
  */
 
index 18939e84b6f2b13c6149f81ddba80aac0d2940bc..f7fbebaa074483af0d19c2e93d8a18811d82ea1c 100644 (file)
@@ -10,7 +10,7 @@
 #define _ASM_SIGCONTEXT_H
 
 #include <asm/sgidefs.h>
-                                                                                
+
 #if _MIPS_SIM == _MIPS_SIM_ABI32
 
 /*
@@ -38,7 +38,7 @@ struct sigcontext {
 };
 
 #endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
-                                                                                
+
 #if _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32
 
 /*
index a0e26e6c994dbd4ec260cbd7007507beb8b062f4..698becab5a9e2fc1cb4bd58f124ef8006bd9b81f 100644 (file)
@@ -25,10 +25,10 @@ struct siginfo;
 /*
  * Careful to keep union _sifields from shifting ...
  */
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 #define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int))
 #endif
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 #define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
 #endif
 
index 6333169be329e65e385e368d8aa34b3749941578..3ccfe09fa744c0bdc702ac0c9a8e7cbc4d0d9856 100644 (file)
@@ -16,7 +16,7 @@
 #define __str2(x) #x
 #define __str(x) __str2(x)
 
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 
 #define save_static_function(symbol)                                   \
 __asm__ (                                                              \
@@ -42,9 +42,9 @@ __asm__ (                                                             \
 
 #define nabi_no_regargs
 
-#endif /* CONFIG_MIPS32 */
+#endif /* CONFIG_32BIT */
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 
 #define save_static_function(symbol)                                   \
 __asm__ (                                                              \
@@ -78,6 +78,6 @@ __asm__ (                                                             \
        unsigned long __dummy6,                                         \
        unsigned long __dummy7,
 
-#endif /* CONFIG_MIPS64 */
+#endif /* CONFIG_64BIT */
 
 #endif /* _ASM_SIM_H */
index d478a86294ee8344fa8dd6e236589461ec8c4a4b..753b6620e6fa3df5cd91a7ad6d3a23113ce23d26 100644 (file)
@@ -82,7 +82,7 @@ To add: #define SO_REUSEPORT 0x0200   /* Allow local address and port reuse.  */
  * @SOCK_STREAM - stream (connection) socket
  * @SOCK_RAW - raw socket
  * @SOCK_RDM - reliably-delivered message
- * @SOCK_SEQPACKET - sequential packet socket 
+ * @SOCK_SEQPACKET - sequential packet socket
  * @SOCK_PACKET - linux specific way of getting packets at the dev level.
  *               For writing rarp and other similar things on the user level.
  */
index 86283c25fd5bb34718d43a201b7733289b3cd953..fb42f99f85278adffcf6c41aa5f94f1378e7750b 100644 (file)
@@ -26,7 +26,7 @@
 
                .macro  SAVE_TEMP
                mfhi    v1
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
                LONG_S  $8, PT_R8(sp)
                LONG_S  $9, PT_R9(sp)
 #endif
@@ -56,7 +56,7 @@
 
 #ifdef CONFIG_SMP
                .macro  get_saved_sp    /* SMP variation */
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
                mfc0    k0, CP0_CONTEXT
                lui     k1, %hi(kernelsp)
                srl     k0, k0, 23
@@ -64,7 +64,7 @@
                addu    k1, k0
                LONG_L  k1, %lo(kernelsp)(k1)
 #endif
-#if defined(CONFIG_MIPS64) && !defined(CONFIG_BUILD_ELF64)
+#if defined(CONFIG_64BIT) && !defined(CONFIG_BUILD_ELF64)
                MFC0    k1, CP0_CONTEXT
                dsra    k1, 23
                lui     k0, %hi(pgd_current)
@@ -74,7 +74,7 @@
                daddu   k1, k0
                LONG_L  k1, %lo(kernelsp)(k1)
 #endif
-#if defined(CONFIG_MIPS64) && defined(CONFIG_BUILD_ELF64)
+#if defined(CONFIG_64BIT) && defined(CONFIG_BUILD_ELF64)
                MFC0    k1, CP0_CONTEXT
                dsrl    k1, 23
                dsll    k1, k1, 3
                .endm
 
                .macro  set_saved_sp stackp temp temp2
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
                mfc0    \temp, CP0_CONTEXT
                srl     \temp, 23
                sll     \temp, 2
                LONG_S  \stackp, kernelsp(\temp)
 #endif
-#if defined(CONFIG_MIPS64) && !defined(CONFIG_BUILD_ELF64)
+#if defined(CONFIG_64BIT) && !defined(CONFIG_BUILD_ELF64)
                lw      \temp, TI_CPU(gp)
                dsll    \temp, 3
                lui     \temp2, %hi(kernelsp)
                daddu   \temp, \temp2
                LONG_S  \stackp, %lo(kernelsp)(\temp)
 #endif
-#if defined(CONFIG_MIPS64) && defined(CONFIG_BUILD_ELF64)
+#if defined(CONFIG_64BIT) && defined(CONFIG_BUILD_ELF64)
                lw      \temp, TI_CPU(gp)
                dsll    \temp, 3
                LONG_S  \stackp, kernelsp(\temp)
                LONG_S  $6, PT_R6(sp)
                MFC0    v1, CP0_EPC
                LONG_S  $7, PT_R7(sp)
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
                LONG_S  $8, PT_R8(sp)
                LONG_S  $9, PT_R9(sp)
 #endif
 
                .macro  RESTORE_TEMP
                LONG_L  $24, PT_LO(sp)
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
                LONG_L  $8, PT_R8(sp)
                LONG_L  $9, PT_R9(sp)
 #endif
                LONG_L  $31, PT_R31(sp)
                LONG_L  $28, PT_R28(sp)
                LONG_L  $25, PT_R25(sp)
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
                LONG_L  $8, PT_R8(sp)
                LONG_L  $9, PT_R9(sp)
 #endif
                LONG_L  $31, PT_R31(sp)
                LONG_L  $28, PT_R28(sp)
                LONG_L  $25, PT_R25(sp)
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
                LONG_L  $8, PT_R8(sp)
                LONG_L  $9, PT_R9(sp)
 #endif
index 5076fec65780ff39c6f3852f1423c389fedfe5a2..c3ddf973c1c075e805e985f2f9f57ea5329c60e6 100644 (file)
@@ -57,7 +57,7 @@ struct statfs64 {
 };
 
 #endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
+
 #if _MIPS_SIM == _MIPS_SIM_ABI64
 
 struct statfs64 {                      /* Same as struct statfs */
index b18345504f8a870f24677a2c6f02708d770072b1..5a06f6d1389981d3bb8a9c66bf384d15846e98ec 100644 (file)
@@ -16,7 +16,7 @@
  * Most of the inline functions are rather naive implementations so I just
  * didn't bother updating them for 64-bit ...
  */
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 
 #ifndef IN_STRING_C
 
@@ -130,7 +130,7 @@ strncmp(__const__ char *__cs, __const__ char *__ct, size_t __count)
 
        return __res;
 }
-#endif /* CONFIG_MIPS32 */
+#endif /* CONFIG_32BIT */
 
 #define __HAVE_ARCH_MEMSET
 extern void *memset(void *__s, int __c, size_t __count);
@@ -141,7 +141,7 @@ extern void *memcpy(void *__to, __const__ void *__from, size_t __n);
 #define __HAVE_ARCH_MEMMOVE
 extern void *memmove(void *__dest, __const__ void *__src, size_t __n);
 
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 #define __HAVE_ARCH_MEMSCAN
 static __inline__ void *memscan(void *__addr, int __c, size_t __size)
 {
@@ -161,6 +161,6 @@ static __inline__ void *memscan(void *__addr, int __c, size_t __size)
 
        return __addr;
 }
-#endif /* CONFIG_MIPS32 */
+#endif /* CONFIG_32BIT */
 
 #endif /* _ASM_STRING_H */
index 169f3d4265b14fdeec80c30982572938bab81fc1..6663efd49b27a4d5aaa698c82ce7969bc0287c10 100644 (file)
@@ -208,7 +208,7 @@ static inline unsigned long __xchg_u32(volatile int * m, unsigned int val)
        return retval;
 }
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 static inline __u64 __xchg_u64(volatile __u64 * m, __u64 val)
 {
        __u64 retval;
@@ -330,7 +330,7 @@ static inline unsigned long __cmpxchg_u32(volatile int * m, unsigned long old,
        return retval;
 }
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 static inline unsigned long __cmpxchg_u64(volatile int * m, unsigned long old,
        unsigned long new)
 {
index 42fcd6f2c206ac42843361a278def47344d3a4ec..a70cb0854c8aff15c59e76d2e20200f92263a67f 100644 (file)
@@ -62,10 +62,10 @@ register struct thread_info *__current_thread_info __asm__("$28");
 #define current_thread_info()  __current_thread_info
 
 /* thread information allocation */
-#if defined(CONFIG_PAGE_SIZE_4KB) && defined(CONFIG_MIPS32)
+#if defined(CONFIG_PAGE_SIZE_4KB) && defined(CONFIG_32BIT)
 #define THREAD_SIZE_ORDER (1)
 #endif
-#if defined(CONFIG_PAGE_SIZE_4KB) && defined(CONFIG_MIPS64)
+#if defined(CONFIG_PAGE_SIZE_4KB) && defined(CONFIG_64BIT)
 #define THREAD_SIZE_ORDER (2)
 #endif
 #ifdef CONFIG_PAGE_SIZE_8KB
index fd9599e40a0ae4e80da1cb023db5b9a46e896503..fee1908c65d286e2a611314f0bfa9545051d81e9 100644 (file)
@@ -228,4 +228,4 @@ extern unsigned long ocd_base;
 #define RM9K_READ_8(ofs, val)   *(val) = *(volatile u8 *)(RM9000x2_BASE_ADDR+ofs)
 #define RM9K_READ_16(ofs, val)  *(val) = *(volatile u16 *)(RM9000x2_BASE_ADDR+ofs)
 
-#endif 
+#endif
index 5d939db6e220f2fc52ce6accb1d3556a4edfc360..3bb7f0087d68111af56b6086e279c3b586df9227 100644 (file)
 
 
 /* TX4927 SDRAM controller (64-bit registers) */
-#define TX4927_SDRAMC_BASE              0x8000 
-#define TX4927_SDRAMC_SDCCR0            0x8000 
+#define TX4927_SDRAMC_BASE              0x8000
+#define TX4927_SDRAMC_SDCCR0            0x8000
 #define TX4927_SDRAMC_SDCCR1            0x8008
 #define TX4927_SDRAMC_SDCCR2            0x8010
 #define TX4927_SDRAMC_SDCCR3            0x8018
 #define TX4927_SDRAMC_SDCTR             0x8040
 #define TX4927_SDRAMC_SDCMD             0x8058
-#define TX4927_SDRAMC_LIMIT             0x8fff 
+#define TX4927_SDRAMC_LIMIT             0x8fff
 
 
 /* TX4927 external bus controller (64-bit registers) */
 
 
 /* TX4927 serial port 0 (32-bit registers) */
-#define TX4927_SIO0_BASE                         0xf300 
-#define TX4927_SIO0_SILCR0                       0xf300 
+#define TX4927_SIO0_BASE                         0xf300
+#define TX4927_SIO0_SILCR0                       0xf300
 #define TX4927_SIO0_SILCR0_RESERVED_16_31                BM_16_31
 #define TX4927_SIO0_SILCR0_RWUB                          BM_15_15
 #define TX4927_SIO0_SILCR0_TWUB                          BM_14_14
 #define TX4927_SIO0_SILCR0_UMODE_DATA_7_BIT            (~BM_00_01)
 #define TX4927_SIO0_SILCR0_UMODE_DATA_8_BIT_MC           BM_01_01
 #define TX4927_SIO0_SILCR0_UMODE_DATA_7_BIT_MC           BM_00_01
-#define TX4927_SIO0_SIDICR0                      0xf304 
+#define TX4927_SIO0_SIDICR0                      0xf304
 #define TX4927_SIO0_SIDICR0_RESERVED_16_31               BM_16_31
 #define TX4927_SIO0_SIDICR0_TDE                          BM_15_15
 #define TX4927_SIO0_SIDICR0_RDE                          BM_14_14
 #define TX4927_SIO0_SIDICR0_STIE_TRDY                    BM_02_02
 #define TX4927_SIO0_SIDICR0_STIE_TXALS                   BM_01_01
 #define TX4927_SIO0_SIDICR0_STIE_UBRKD                   BM_00_00
-#define TX4927_SIO0_SIDISR0                      0xf308 
+#define TX4927_SIO0_SIDISR0                      0xf308
 #define TX4927_SIO0_SIDISR0_RESERVED_16_31               BM_16_31
 #define TX4927_SIO0_SIDISR0_UBRK                         BM_15_15
 #define TX4927_SIO0_SIDISR0_UVALID                       BM_14_14
 #define TX4927_SIO0_SIDISR0_STIS                         BM_06_06
 #define TX4927_SIO0_SIDISR0_RESERVED_05_05               BM_05_05
 #define TX4927_SIO0_SIDISR0_RFDN                         BM_00_04
-#define TX4927_SIO0_SISCISR0                     0xf30c 
+#define TX4927_SIO0_SISCISR0                     0xf30c
 #define TX4927_SIO0_SISCISR0_RESERVED_06_31              BM_06_31
 #define TX4927_SIO0_SISCISR0_OERS                        BM_05_05
 #define TX4927_SIO0_SISCISR0_CTSS                        BM_04_04
 #define TX4927_SIO0_SISCISR0_TRDY                        BM_02_02
 #define TX4927_SIO0_SISCISR0_TXALS                       BM_01_01
 #define TX4927_SIO0_SISCISR0_UBRKD                       BM_00_00
-#define TX4927_SIO0_SIFCR0                       0xf310 
+#define TX4927_SIO0_SIFCR0                       0xf310
 #define TX4927_SIO0_SIFCR0_RESERVED_16_31                BM_16_31
 #define TX4927_SIO0_SIFCR0_SWRST                         BM_16_31
 #define TX4927_SIO0_SIFCR0_RESERVED_09_14                BM_09_14
 #define TX4927_SIO0_SIFCR0_TFRST                         BM_02_02
 #define TX4927_SIO0_SIFCR0_RFRST                         BM_01_01
 #define TX4927_SIO0_SIFCR0_FRSTE                         BM_00_00
-#define TX4927_SIO0_SIFLCR0                      0xf314 
+#define TX4927_SIO0_SIFLCR0                      0xf314
 #define TX4927_SIO0_SIFLCR0_RESERVED_13_31               BM_13_31
 #define TX4927_SIO0_SIFLCR0_RCS                          BM_12_12
 #define TX4927_SIO0_SIFLCR0_TES                          BM_11_11
 #define TX4927_SIO0_SIFLCR0_RESERVED_05_06               BM_05_06
 #define TX4927_SIO0_SIFLCR0_RTSTL                        BM_01_04
 #define TX4927_SIO0_SIFLCR0_TBRK                         BM_00_00
-#define TX4927_SIO0_SIBGR0                       0xf318 
+#define TX4927_SIO0_SIBGR0                       0xf318
 #define TX4927_SIO0_SIBGR0_RESERVED_10_31                BM_10_31
 #define TX4927_SIO0_SIBGR0_BCLK                          BM_08_09
 #define TX4927_SIO0_SIBGR0_BCLK_T0                     (~BM_08_09)
 #define TX4927_SIO0_SIBGR0_BCLK_T4                       BM_09_09
 #define TX4927_SIO0_SIBGR0_BCLK_T6                       BM_08_09
 #define TX4927_SIO0_SIBGR0_BRD                           BM_00_07
-#define TX4927_SIO0_SITFIF00                     0xf31c 
+#define TX4927_SIO0_SITFIF00                     0xf31c
 #define TX4927_SIO0_SITFIF00_RESERVED_08_31              BM_08_31
 #define TX4927_SIO0_SITFIF00_TXD                         BM_00_07
-#define TX4927_SIO0_SIRFIFO0                     0xf320          
+#define TX4927_SIO0_SIRFIFO0                     0xf320
 #define TX4927_SIO0_SIRFIFO0_RESERVED_08_31              BM_08_31
 #define TX4927_SIO0_SIRFIFO0_RXD                         BM_00_07
-#define TX4927_SIO0_SIRFIFO0                     0xf320          
-#define TX4927_SIO0_LIMIT                        0xf3ff 
+#define TX4927_SIO0_SIRFIFO0                     0xf320
+#define TX4927_SIO0_LIMIT                        0xf3ff
 
 
 /* TX4927 serial port 1 (32-bit registers) */
-#define TX4927_SIO1_BASE                0xf400 
-#define TX4927_SIO1_SILCR1              0xf400 
-#define TX4927_SIO1_SIDICR1             0xf404 
-#define TX4927_SIO1_SIDISR1             0xf408 
-#define TX4927_SIO1_SISCISR1            0xf40c 
-#define TX4927_SIO1_SIFCR1              0xf410 
-#define TX4927_SIO1_SIFLCR1             0xf414 
-#define TX4927_SIO1_SIBGR1              0xf418 
-#define TX4927_SIO1_SITFIF01            0xf41c 
-#define TX4927_SIO1_SIRFIFO1            0xf420 
-#define TX4927_SIO1_LIMIT               0xf4ff 
+#define TX4927_SIO1_BASE                0xf400
+#define TX4927_SIO1_SILCR1              0xf400
+#define TX4927_SIO1_SIDICR1             0xf404
+#define TX4927_SIO1_SIDISR1             0xf408
+#define TX4927_SIO1_SISCISR1            0xf40c
+#define TX4927_SIO1_SIFCR1              0xf410
+#define TX4927_SIO1_SIFLCR1             0xf414
+#define TX4927_SIO1_SIBGR1              0xf418
+#define TX4927_SIO1_SITFIF01            0xf41c
+#define TX4927_SIO1_SIRFIFO1            0xf420
+#define TX4927_SIO1_LIMIT               0xf4ff
 
 
 /* TX4927 parallel port (32-bit registers) */
index 170433492246357fdec8839a3676c8c8867b3b7a..165f6b8b217fe6254e40c76515fb6469af5f3aca 100644 (file)
@@ -5,8 +5,8 @@
  *
  * Copyright (C) 2000-2001 Toshiba Corporation
  */
-#ifndef __ASM_TX4927_TX4927_PCI_H 
-#define __ASM_TX4927_TX4927_PCI_H 
+#ifndef __ASM_TX4927_TX4927_PCI_H
+#define __ASM_TX4927_TX4927_PCI_H
 
 #define TX4927_CCFG_TOE 0x00004000
 
index d2f0c76b00a9f85a817e3e1436243e8eb93d9bfe..421b3aea14cc9425ac30064fa427c068f89f158f 100644 (file)
@@ -78,7 +78,7 @@ typedef unsigned long long u64;
 #endif
 
 #if (defined(CONFIG_HIGHMEM) && defined(CONFIG_64BIT_PHYS_ADDR)) \
-    || defined(CONFIG_MIPS64)
+    || defined(CONFIG_64BIT)
 typedef u64 dma_addr_t;
 #else
 typedef u32 dma_addr_t;
@@ -99,8 +99,6 @@ typedef u64 sector_t;
 #define HAVE_SECTOR_T
 #endif
 
-typedef unsigned short kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
index 07114898e0652fd9a5a7d5df836934f9ef41c5c9..a543ead72ecf5e5c70e7f937a35760536a3b8db0 100644 (file)
@@ -22,7 +22,7 @@
  *
  * For historical reasons, these macros are grossly misnamed.
  */
-#ifdef CONFIG_MIPS32
+#ifdef CONFIG_32BIT
 
 #define __UA_LIMIT     0x80000000UL
 
@@ -32,9 +32,9 @@
 #define __UA_t0                "$8"
 #define __UA_t1                "$9"
 
-#endif /* CONFIG_MIPS32 */
+#endif /* CONFIG_32BIT */
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 
 #define __UA_LIMIT     (- TASK_SIZE)
 
@@ -44,7 +44,7 @@
 #define __UA_t0                "$12"
 #define __UA_t1                "$13"
 
-#endif /* CONFIG_MIPS64 */
+#endif /* CONFIG_64BIT */
 
 /*
  * USER_DS is a bitmask that has the bits set that may not be set in a valid
index 6d21cc964f76c8667bffd788b31dc220f3f4cd40..ad4d48056307ea704f13b2ec0f44053816c7cdb0 100644 (file)
@@ -1124,7 +1124,7 @@ type name (atype a,btype b,ctype c,dtype d,etype e,ftype f) \
 # ifndef __mips64
 #  define __ARCH_WANT_STAT64
 # endif
-# ifdef CONFIG_MIPS32
+# ifdef CONFIG_32BIT
 #  define __ARCH_WANT_SYS_TIME
 # endif
 # ifdef CONFIG_MIPS32_O32
diff --git a/include/asm-mips/vr4181/irq.h b/include/asm-mips/vr4181/irq.h
deleted file mode 100644 (file)
index 4bf0ea9..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Macros for vr4181 IRQ numbers.
- *
- * Copyright (C) 2001 MontaVista Software Inc.
- * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- */
-
-/*
- * Strategy:
- *
- * Vr4181 has conceptually three levels of interrupt controllers:
- *  1. the CPU itself with 8 intr level.
- *  2. system interrupt controller, cascaded from int0 pin in CPU, 32 intrs
- *  3. GPIO interrupts : forwarding external interrupts to sys intr controller
- */
-
-/* decide the irq block assignment */
-#define        VR4181_NUM_CPU_IRQ      8
-#define        VR4181_NUM_SYS_IRQ      32
-#define        VR4181_NUM_GPIO_IRQ     16
-
-#define        VR4181_IRQ_BASE         0
-
-#define        VR4181_CPU_IRQ_BASE     VR4181_IRQ_BASE
-#define        VR4181_SYS_IRQ_BASE     (VR4181_CPU_IRQ_BASE + VR4181_NUM_CPU_IRQ)
-#define        VR4181_GPIO_IRQ_BASE    (VR4181_SYS_IRQ_BASE + VR4181_NUM_SYS_IRQ)
-
-/* CPU interrupts */
-
-/*
-   IP0 - Software interrupt
-   IP1 - Software interrupt
-   IP2 - All but battery, high speed modem, and real time clock
-   IP3 - RTC Long1 (system timer)
-   IP4 - RTC Long2
-   IP5 - High Speed Modem (unused on VR4181)
-   IP6 - Unused
-   IP7 - Timer interrupt from CPO_COMPARE
-*/
-
-#define VR4181_IRQ_SW1       (VR4181_CPU_IRQ_BASE + 0)
-#define VR4181_IRQ_SW2       (VR4181_CPU_IRQ_BASE + 1)
-#define VR4181_IRQ_INT0      (VR4181_CPU_IRQ_BASE + 2)
-#define VR4181_IRQ_INT1      (VR4181_CPU_IRQ_BASE + 3)
-#define VR4181_IRQ_INT2      (VR4181_CPU_IRQ_BASE + 4)
-#define VR4181_IRQ_INT3      (VR4181_CPU_IRQ_BASE + 5)
-#define VR4181_IRQ_INT4      (VR4181_CPU_IRQ_BASE + 6)
-#define VR4181_IRQ_TIMER     (VR4181_CPU_IRQ_BASE + 7)
-
-
-/* Cascaded from VR4181_IRQ_INT0 (ICU mapped interrupts) */
-
-/*
-   IP2 - same as VR4181_IRQ_INT1
-   IP8 - This is a cascade to GPIO IRQ's. Do not use.
-   IP16 - same as VR4181_IRQ_INT2
-   IP18 - CompactFlash
-*/
-
-#define VR4181_IRQ_BATTERY   (VR4181_SYS_IRQ_BASE + 0)
-#define VR4181_IRQ_POWER     (VR4181_SYS_IRQ_BASE + 1)
-#define VR4181_IRQ_RTCL1     (VR4181_SYS_IRQ_BASE + 2)
-#define VR4181_IRQ_ETIMER    (VR4181_SYS_IRQ_BASE + 3)
-#define VR4181_IRQ_RFU12     (VR4181_SYS_IRQ_BASE + 4)
-#define VR4181_IRQ_PIU       (VR4181_SYS_IRQ_BASE + 5)
-#define VR4181_IRQ_AIU       (VR4181_SYS_IRQ_BASE + 6)
-#define VR4181_IRQ_KIU       (VR4181_SYS_IRQ_BASE + 7)
-#define VR4181_IRQ_GIU       (VR4181_SYS_IRQ_BASE + 8)
-#define VR4181_IRQ_SIU       (VR4181_SYS_IRQ_BASE + 9)
-#define VR4181_IRQ_RFU18     (VR4181_SYS_IRQ_BASE + 10)
-#define VR4181_IRQ_SOFT      (VR4181_SYS_IRQ_BASE + 11)
-#define VR4181_IRQ_RFU20     (VR4181_SYS_IRQ_BASE + 12)
-#define VR4181_IRQ_DOZEPIU   (VR4181_SYS_IRQ_BASE + 13)
-#define VR4181_IRQ_RFU22     (VR4181_SYS_IRQ_BASE + 14)
-#define VR4181_IRQ_RFU23     (VR4181_SYS_IRQ_BASE + 15)
-#define VR4181_IRQ_RTCL2     (VR4181_SYS_IRQ_BASE + 16)
-#define VR4181_IRQ_LED       (VR4181_SYS_IRQ_BASE + 17)
-#define VR4181_IRQ_ECU       (VR4181_SYS_IRQ_BASE + 18)
-#define VR4181_IRQ_CSU       (VR4181_SYS_IRQ_BASE + 19)
-#define VR4181_IRQ_USB       (VR4181_SYS_IRQ_BASE + 20)
-#define VR4181_IRQ_DMA       (VR4181_SYS_IRQ_BASE + 21)
-#define VR4181_IRQ_LCD       (VR4181_SYS_IRQ_BASE + 22)
-#define VR4181_IRQ_RFU31     (VR4181_SYS_IRQ_BASE + 23)
-#define VR4181_IRQ_RFU32     (VR4181_SYS_IRQ_BASE + 24)
-#define VR4181_IRQ_RFU33     (VR4181_SYS_IRQ_BASE + 25)
-#define VR4181_IRQ_RFU34     (VR4181_SYS_IRQ_BASE + 26)
-#define VR4181_IRQ_RFU35     (VR4181_SYS_IRQ_BASE + 27)
-#define VR4181_IRQ_RFU36     (VR4181_SYS_IRQ_BASE + 28)
-#define VR4181_IRQ_RFU37     (VR4181_SYS_IRQ_BASE + 29)
-#define VR4181_IRQ_RFU38     (VR4181_SYS_IRQ_BASE + 30)
-#define VR4181_IRQ_RFU39     (VR4181_SYS_IRQ_BASE + 31)
-
-/* Cascaded from VR4181_IRQ_GIU */
-#define VR4181_IRQ_GPIO0     (VR4181_GPIO_IRQ_BASE + 0)
-#define VR4181_IRQ_GPIO1     (VR4181_GPIO_IRQ_BASE + 1)
-#define VR4181_IRQ_GPIO2     (VR4181_GPIO_IRQ_BASE + 2)
-#define VR4181_IRQ_GPIO3     (VR4181_GPIO_IRQ_BASE + 3)
-#define VR4181_IRQ_GPIO4     (VR4181_GPIO_IRQ_BASE + 4)
-#define VR4181_IRQ_GPIO5     (VR4181_GPIO_IRQ_BASE + 5)
-#define VR4181_IRQ_GPIO6     (VR4181_GPIO_IRQ_BASE + 6)
-#define VR4181_IRQ_GPIO7     (VR4181_GPIO_IRQ_BASE + 7)
-#define VR4181_IRQ_GPIO8     (VR4181_GPIO_IRQ_BASE + 8)
-#define VR4181_IRQ_GPIO9     (VR4181_GPIO_IRQ_BASE + 9)
-#define VR4181_IRQ_GPIO10    (VR4181_GPIO_IRQ_BASE + 10)
-#define VR4181_IRQ_GPIO11    (VR4181_GPIO_IRQ_BASE + 11)
-#define VR4181_IRQ_GPIO12    (VR4181_GPIO_IRQ_BASE + 12)
-#define VR4181_IRQ_GPIO13    (VR4181_GPIO_IRQ_BASE + 13)
-#define VR4181_IRQ_GPIO14    (VR4181_GPIO_IRQ_BASE + 14)
-#define VR4181_IRQ_GPIO15    (VR4181_GPIO_IRQ_BASE + 15)
-
-
-// Alternative to above GPIO IRQ defines
-#define VR4181_IRQ_GPIO(pin) ((VR4181_IRQ_GPIO0) + (pin))
-
-#define VR4181_IRQ_MAX       (VR4181_IRQ_BASE + VR4181_NUM_CPU_IRQ + \
-                              VR4181_NUM_SYS_IRQ + VR4181_NUM_GPIO_IRQ)
diff --git a/include/asm-mips/vr4181/vr4181.h b/include/asm-mips/vr4181/vr4181.h
deleted file mode 100644 (file)
index 5c5d607..0000000
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1999 by Michael Klar
- *
- * Copyright 2001 MontaVista Software Inc.
- * Author: jsun@mvista.com or jsun@junsun.net
- *
- */
-#ifndef __ASM_VR4181_VR4181_H
-#define __ASM_VR4181_VR4181_H
-
-#include <asm/addrspace.h>
-
-#include <asm/vr4181/irq.h>
-
-#ifndef __ASSEMBLY__
-#define __preg8                (volatile unsigned char*)
-#define __preg16       (volatile unsigned short*)
-#define __preg32       (volatile unsigned int*)
-#else
-#define __preg8
-#define __preg16
-#define __preg32
-#endif
-
-// Embedded CPU peripheral registers
-// Note that many of the registers have different physical address for VR4181
-
-// Bus Control Unit (BCU)
-#define VR4181_BCUCNTREG1      __preg16(KSEG1 + 0x0A000000)    /* BCU control register 1 (R/W) */
-#define VR4181_CMUCLKMSK       __preg16(KSEG1 + 0x0A000004)    /* Clock mask register (R/W) */
-#define VR4181_CMUCLKMSK_MSKCSUPCLK  0x0040
-#define VR4181_CMUCLKMSK_MSKAIUPCLK  0x0020
-#define VR4181_CMUCLKMSK_MSKPIUPCLK  0x0010
-#define VR4181_CMUCLKMSK_MSKADUPCLK  0x0008
-#define VR4181_CMUCLKMSK_MSKSIU18M   0x0004
-#define VR4181_CMUCLKMSK_MSKADU18M   0x0002
-#define VR4181_CMUCLKMSK_MSKUSB      0x0001
-#define VR4181_CMUCLKMSK_MSKSIU      VR4181_CMUCLKMSK_MSKSIU18M
-#define VR4181_BCUSPEEDREG     __preg16(KSEG1 + 0x0A00000C)    /* BCU access time parameter (R/W) */
-#define VR4181_BCURFCNTREG     __preg16(KSEG1 + 0x0A000010)    /* BCU refresh control register (R/W) */
-#define VR4181_REVIDREG                __preg16(KSEG1 + 0x0A000014)    /* Revision ID register (R) */
-#define VR4181_CLKSPEEDREG     __preg16(KSEG1 + 0x0A000018)    /* Clock speed register (R) */
-#define VR4181_EDOMCYTREG      __preg16(KSEG1 + 0x0A000300)    /* Memory cycle timing register (R/W) */
-#define VR4181_MEMCFG_REG      __preg16(KSEG1 + 0x0A000304)    /* Memory configuration register (R/W) */
-#define VR4181_MODE_REG                __preg16(KSEG1 + 0x0A000308)    /* SDRAM mode register (R/W) */
-#define VR4181_SDTIMINGREG     __preg16(KSEG1 + 0x0A00030C)    /* SDRAM timing register (R/W) */
-
-// DMA Control Unit (DCU)
-#define VR4181_MICDEST1REG1    __preg16(KSEG1 + 0x0A000020)    /* Microphone destination 1 address register 1 (R/W) */
-#define VR4181_MICDEST1REG2    __preg16(KSEG1 + 0x0A000022)    /* Microphone destination 1 address register 2 (R/W) */
-#define VR4181_MICDEST2REG1    __preg16(KSEG1 + 0x0A000024)    /* Microphone destination 2 address register 1 (R/W) */
-#define VR4181_MICDEST2REG2    __preg16(KSEG1 + 0x0A000026)    /* Microphone destination 2 address register 2 (R/W) */
-#define VR4181_SPKRRC1REG1     __preg16(KSEG1 + 0x0A000028)    /* Speaker Source 1 address register 1 (R/W) */
-#define VR4181_SPKRRC1REG2     __preg16(KSEG1 + 0x0A00002A)    /* Speaker Source 1 address register 2 (R/W) */
-#define VR4181_SPKRRC2REG1     __preg16(KSEG1 + 0x0A00002C)    /* Speaker Source 2 address register 1 (R/W) */
-#define VR4181_SPKRRC2REG2     __preg16(KSEG1 + 0x0A00002E)    /* Speaker Source 2 address register 2 (R/W) */
-#define VR4181_DMARSTREG       __preg16(KSEG1 + 0x0A000040)    /* DMA Reset register (R/W) */
-#define VR4181_AIUDMAMSKREG    __preg16(KSEG1 + 0x0A000046)    /* Audio DMA mask register (R/W) */
-#define VR4181_USBDMAMSKREG    __preg16(KSEG1 + 0x0A000600)    /* USB DMA Mask register (R/W) */
-#define VR4181_USBRXS1AREG1    __preg16(KSEG1 + 0x0A000602)    /* USB Rx source 1 address register 1 (R/W) */
-#define VR4181_USBRXS1AREG2    __preg16(KSEG1 + 0x0A000604)    /* USB Rx source 1 address register 2 (R/W) */
-#define VR4181_USBRXS2AREG1    __preg16(KSEG1 + 0x0A000606)    /* USB Rx source 2 address register 1 (R/W) */
-#define VR4181_USBRXS2AREG2    __preg16(KSEG1 + 0x0A000608)    /* USB Rx source 2 address register 2 (R/W) */
-#define VR4181_USBTXS1AREG1    __preg16(KSEG1 + 0x0A00060A)    /* USB Tx source 1 address register 1 (R/W) */
-#define VR4181_USBTXS1AREG2    __preg16(KSEG1 + 0x0A00060C)    /* USB Tx source 1 address register 2 (R/W) */
-#define VR4181_USBTXS2AREG1    __preg16(KSEG1 + 0x0A00060E)    /* USB Tx source 2 address register 1 (R/W) */
-#define VR4181_USBTXS2AREG2    __preg16(KSEG1 + 0x0A000610)    /* USB Tx source 2 address register 2 (R/W) */
-#define VR4181_USBRXD1AREG1    __preg16(KSEG1 + 0x0A00062A)    /* USB Rx destination 1 address register 1 (R/W) */
-#define VR4181_USBRXD1AREG2    __preg16(KSEG1 + 0x0A00062C)    /* USB Rx destination 1 address register 2 (R/W) */
-#define VR4181_USBRXD2AREG1    __preg16(KSEG1 + 0x0A00062E)    /* USB Rx destination 2 address register 1 (R/W) */
-#define VR4181_USBRXD2AREG2    __preg16(KSEG1 + 0x0A000630)    /* USB Rx destination 2 address register 2 (R/W) */
-#define VR4181_USBTXD1AREG1    __preg16(KSEG1 + 0x0A000632)    /* USB Tx destination 1 address register 1 (R/W) */
-#define VR4181_USBTXD1AREG2    __preg16(KSEG1 + 0x0A000634)    /* USB Tx destination 1 address register 2 (R/W) */
-#define VR4181_USBTXD2AREG1    __preg16(KSEG1 + 0x0A000636)    /* USB Tx destination 2 address register 1 (R/W) */
-#define VR4181_USBTXD2AREG2    __preg16(KSEG1 + 0x0A000638)    /* USB Tx destination 2 address register 2 (R/W) */
-#define VR4181_RxRCLENREG      __preg16(KSEG1 + 0x0A000652)    /* USB Rx record length register (R/W) */
-#define VR4181_TxRCLENREG      __preg16(KSEG1 + 0x0A000654)    /* USB Tx record length register (R/W) */
-#define VR4181_MICRCLENREG     __preg16(KSEG1 + 0x0A000658)    /* Microphone record length register (R/W) */
-#define VR4181_SPKRCLENREG     __preg16(KSEG1 + 0x0A00065A)    /* Speaker record length register (R/W) */
-#define VR4181_USBCFGREG       __preg16(KSEG1 + 0x0A00065C)    /* USB configuration register (R/W) */
-#define VR4181_MICDMACFGREG    __preg16(KSEG1 + 0x0A00065E)    /* Microphone DMA configuration register (R/W) */
-#define VR4181_SPKDMACFGREG    __preg16(KSEG1 + 0x0A000660)    /* Speaker DMA configuration register (R/W) */
-#define VR4181_DMAITRQREG      __preg16(KSEG1 + 0x0A000662)    /* DMA interrupt request register (R/W) */
-#define VR4181_DMACLTREG       __preg16(KSEG1 + 0x0A000664)    /* DMA control register (R/W) */
-#define VR4181_DMAITMKREG      __preg16(KSEG1 + 0x0A000666)    /* DMA interrupt mask register (R/W) */
-
-// ISA Bridge
-#define VR4181_ISABRGCTL       __preg16(KSEG1 + 0x0B0002C0)    /* ISA Bridge Control Register (R/W) */
-#define VR4181_ISABRGSTS       __preg16(KSEG1 + 0x0B0002C2)    /* ISA Bridge Status Register (R/W) */
-#define VR4181_XISACTL         __preg16(KSEG1 + 0x0B0002C4)    /* External ISA Control Register (R/W) */
-
-// Clocked Serial Interface (CSI)
-#define VR4181_CSIMODE         __preg16(KSEG1 + 0x0B000900)    /* CSI Mode Register (R/W) */
-#define VR4181_CSIRXDATA       __preg16(KSEG1 + 0x0B000902)    /* CSI Receive Data Register (R) */
-#define VR4181_CSITXDATA       __preg16(KSEG1 + 0x0B000904)    /* CSI Transmit Data Register (R/W) */
-#define VR4181_CSILSTAT                __preg16(KSEG1 + 0x0B000906)    /* CSI Line Status Register (R/W) */
-#define VR4181_CSIINTMSK       __preg16(KSEG1 + 0x0B000908)    /* CSI Interrupt Mask Register (R/W) */
-#define VR4181_CSIINTSTAT      __preg16(KSEG1 + 0x0B00090a)    /* CSI Interrupt Status Register (R/W) */
-#define VR4181_CSITXBLEN       __preg16(KSEG1 + 0x0B00090c)    /* CSI Transmit Burst Length Register (R/W) */
-#define VR4181_CSIRXBLEN       __preg16(KSEG1 + 0x0B00090e)    /* CSI Receive Burst Length Register (R/W) */
-
-// Interrupt Control Unit (ICU)
-#define VR4181_SYSINT1REG      __preg16(KSEG1 + 0x0A000080)    /* Level 1 System interrupt register 1 (R) */
-#define VR4181_MSYSINT1REG     __preg16(KSEG1 + 0x0A00008C)    /* Level 1 mask system interrupt register 1 (R/W) */
-#define VR4181_NMIREG          __preg16(KSEG1 + 0x0A000098)    /* NMI register (R/W) */
-#define VR4181_SOFTINTREG      __preg16(KSEG1 + 0x0A00009A)    /* Software interrupt register (R/W) */
-#define VR4181_SYSINT2REG      __preg16(KSEG1 + 0x0A000200)    /* Level 1 System interrupt register 2 (R) */
-#define VR4181_MSYSINT2REG     __preg16(KSEG1 + 0x0A000206)    /* Level 1 mask system interrupt register 2 (R/W) */
-#define VR4181_PIUINTREGro     __preg16(KSEG1 + 0x0B000082)    /* Level 2 PIU interrupt register (R) */
-#define VR4181_AIUINTREG       __preg16(KSEG1 + 0x0B000084)    /* Level 2 AIU interrupt register (R) */
-#define VR4181_MPIUINTREG      __preg16(KSEG1 + 0x0B00008E)    /* Level 2 mask PIU interrupt register (R/W) */
-#define VR4181_MAIUINTREG      __preg16(KSEG1 + 0x0B000090)    /* Level 2 mask AIU interrupt register (R/W) */
-#define VR4181_MKIUINTREG      __preg16(KSEG1 + 0x0B000092)    /* Level 2 mask KIU interrupt register (R/W) */
-#define VR4181_KIUINTREG       __preg16(KSEG1 + 0x0B000198)    /* Level 2 KIU interrupt register (R) */
-
-// Power Management Unit (PMU)
-#define VR4181_PMUINTREG       __preg16(KSEG1 + 0x0B0000A0)    /* PMU Status Register (R/W) */
-#define VR4181_PMUINT_POWERSW  0x1     /* Power switch */
-#define VR4181_PMUINT_BATT     0x2     /* Low batt during normal operation */
-#define VR4181_PMUINT_DEADMAN  0x4     /* Deadman's switch */
-#define VR4181_PMUINT_RESET    0x8     /* Reset switch */
-#define VR4181_PMUINT_RTCRESET 0x10    /* RTC Reset */
-#define VR4181_PMUINT_TIMEOUT  0x20    /* HAL Timer Reset */
-#define VR4181_PMUINT_BATTLOW  0x100   /* Battery low */
-#define VR4181_PMUINT_RTC      0x200   /* RTC Alarm */
-#define VR4181_PMUINT_DCD      0x400   /* DCD# */
-#define VR4181_PMUINT_GPIO0    0x1000  /* GPIO0 */
-#define VR4181_PMUINT_GPIO1    0x2000  /* GPIO1 */
-#define VR4181_PMUINT_GPIO2    0x4000  /* GPIO2 */
-#define VR4181_PMUINT_GPIO3    0x8000  /* GPIO3 */
-
-#define VR4181_PMUCNTREG       __preg16(KSEG1 + 0x0B0000A2)    /* PMU Control Register (R/W) */
-#define VR4181_PMUWAITREG      __preg16(KSEG1 + 0x0B0000A8)    /* PMU Wait Counter Register (R/W) */
-#define VR4181_PMUDIVREG       __preg16(KSEG1 + 0x0B0000AC)    /* PMU Divide Mode Register (R/W) */
-#define VR4181_DRAMHIBCTL      __preg16(KSEG1 + 0x0B0000B2)    /* DRAM Hibernate Control Register (R/W) */
-
-// Real Time Clock Unit (RTC)
-#define VR4181_ETIMELREG       __preg16(KSEG1 + 0x0B0000C0)    /* Elapsed Time L Register (R/W) */
-#define VR4181_ETIMEMREG       __preg16(KSEG1 + 0x0B0000C2)    /* Elapsed Time M Register (R/W) */
-#define VR4181_ETIMEHREG       __preg16(KSEG1 + 0x0B0000C4)    /* Elapsed Time H Register (R/W) */
-#define VR4181_ECMPLREG                __preg16(KSEG1 + 0x0B0000C8)    /* Elapsed Compare L Register (R/W) */
-#define VR4181_ECMPMREG                __preg16(KSEG1 + 0x0B0000CA)    /* Elapsed Compare M Register (R/W) */
-#define VR4181_ECMPHREG                __preg16(KSEG1 + 0x0B0000CC)    /* Elapsed Compare H Register (R/W) */
-#define VR4181_RTCL1LREG       __preg16(KSEG1 + 0x0B0000D0)    /* RTC Long 1 L Register (R/W) */
-#define VR4181_RTCL1HREG       __preg16(KSEG1 + 0x0B0000D2)    /* RTC Long 1 H Register (R/W) */
-#define VR4181_RTCL1CNTLREG    __preg16(KSEG1 + 0x0B0000D4)    /* RTC Long 1 Count L Register (R) */
-#define VR4181_RTCL1CNTHREG    __preg16(KSEG1 + 0x0B0000D6)    /* RTC Long 1 Count H Register (R) */
-#define VR4181_RTCL2LREG       __preg16(KSEG1 + 0x0B0000D8)    /* RTC Long 2 L Register (R/W) */
-#define VR4181_RTCL2HREG       __preg16(KSEG1 + 0x0B0000DA)    /* RTC Long 2 H Register (R/W) */
-#define VR4181_RTCL2CNTLREG    __preg16(KSEG1 + 0x0B0000DC)    /* RTC Long 2 Count L Register (R) */
-#define VR4181_RTCL2CNTHREG    __preg16(KSEG1 + 0x0B0000DE)    /* RTC Long 2 Count H Register (R) */
-#define VR4181_RTCINTREG       __preg16(KSEG1 + 0x0B0001DE)    /* RTC Interrupt Register (R/W) */
-
-// Deadman's Switch Unit (DSU)
-#define VR4181_DSUCNTREG       __preg16(KSEG1 + 0x0B0000E0)    /* DSU Control Register (R/W) */
-#define VR4181_DSUSETREG       __preg16(KSEG1 + 0x0B0000E2)    /* DSU Dead Time Set Register (R/W) */
-#define VR4181_DSUCLRREG       __preg16(KSEG1 + 0x0B0000E4)    /* DSU Clear Register (W) */
-#define VR4181_DSUTIMREG       __preg16(KSEG1 + 0x0B0000E6)    /* DSU Elapsed Time Register (R/W) */
-
-// General Purpose I/O Unit (GIU)
-#define VR4181_GPMD0REG                __preg16(KSEG1 + 0x0B000300)    /* GPIO Mode 0 Register (R/W) */
-#define VR4181_GPMD1REG                __preg16(KSEG1 + 0x0B000302)    /* GPIO Mode 1 Register (R/W) */
-#define VR4181_GPMD2REG                __preg16(KSEG1 + 0x0B000304)    /* GPIO Mode 2 Register (R/W) */
-#define VR4181_GPMD3REG                __preg16(KSEG1 + 0x0B000306)    /* GPIO Mode 3 Register (R/W) */
-#define VR4181_GPDATHREG       __preg16(KSEG1 + 0x0B000308)    /* GPIO Data High Register (R/W) */
-#define VR4181_GPDATHREG_GPIO16  0x0001
-#define VR4181_GPDATHREG_GPIO17  0x0002
-#define VR4181_GPDATHREG_GPIO18  0x0004
-#define VR4181_GPDATHREG_GPIO19  0x0008
-#define VR4181_GPDATHREG_GPIO20  0x0010
-#define VR4181_GPDATHREG_GPIO21  0x0020
-#define VR4181_GPDATHREG_GPIO22  0x0040
-#define VR4181_GPDATHREG_GPIO23  0x0080
-#define VR4181_GPDATHREG_GPIO24  0x0100
-#define VR4181_GPDATHREG_GPIO25  0x0200
-#define VR4181_GPDATHREG_GPIO26  0x0400
-#define VR4181_GPDATHREG_GPIO27  0x0800
-#define VR4181_GPDATHREG_GPIO28  0x1000
-#define VR4181_GPDATHREG_GPIO29  0x2000
-#define VR4181_GPDATHREG_GPIO30  0x4000
-#define VR4181_GPDATHREG_GPIO31  0x8000
-#define VR4181_GPDATLREG       __preg16(KSEG1 + 0x0B00030A)    /* GPIO Data Low Register (R/W) */
-#define VR4181_GPDATLREG_GPIO0   0x0001
-#define VR4181_GPDATLREG_GPIO1   0x0002
-#define VR4181_GPDATLREG_GPIO2   0x0004
-#define VR4181_GPDATLREG_GPIO3   0x0008
-#define VR4181_GPDATLREG_GPIO4   0x0010
-#define VR4181_GPDATLREG_GPIO5   0x0020
-#define VR4181_GPDATLREG_GPIO6   0x0040
-#define VR4181_GPDATLREG_GPIO7   0x0080
-#define VR4181_GPDATLREG_GPIO8   0x0100
-#define VR4181_GPDATLREG_GPIO9   0x0200
-#define VR4181_GPDATLREG_GPIO10  0x0400
-#define VR4181_GPDATLREG_GPIO11  0x0800
-#define VR4181_GPDATLREG_GPIO12  0x1000
-#define VR4181_GPDATLREG_GPIO13  0x2000
-#define VR4181_GPDATLREG_GPIO14  0x4000
-#define VR4181_GPDATLREG_GPIO15  0x8000
-#define VR4181_GPINTEN         __preg16(KSEG1 + 0x0B00030C)    /* GPIO Interrupt Enable Register (R/W) */
-#define VR4181_GPINTMSK                __preg16(KSEG1 + 0x0B00030E)    /* GPIO Interrupt Mask Register (R/W) */
-#define VR4181_GPINTTYPH       __preg16(KSEG1 + 0x0B000310)    /* GPIO Interrupt Type High Register (R/W) */
-#define VR4181_GPINTTYPL       __preg16(KSEG1 + 0x0B000312)    /* GPIO Interrupt Type Low Register (R/W) */
-#define VR4181_GPINTSTAT       __preg16(KSEG1 + 0x0B000314)    /* GPIO Interrupt Status Register (R/W) */
-#define VR4181_GPHIBSTH                __preg16(KSEG1 + 0x0B000316)    /* GPIO Hibernate Pin State High Register (R/W) */
-#define VR4181_GPHIBSTL                __preg16(KSEG1 + 0x0B000318)    /* GPIO Hibernate Pin State Low Register (R/W) */
-#define VR4181_GPSICTL         __preg16(KSEG1 + 0x0B00031A)    /* GPIO Serial Interface Control Register (R/W) */
-#define VR4181_KEYEN           __preg16(KSEG1 + 0x0B00031C)    /* Keyboard Scan Pin Enable Register (R/W) */
-#define VR4181_PCS0STRA                __preg16(KSEG1 + 0x0B000320)    /* Programmable Chip Select [0] Start Address Register (R/W) */
-#define VR4181_PCS0STPA                __preg16(KSEG1 + 0x0B000322)    /* Programmable Chip Select [0] Stop Address Register (R/W) */
-#define VR4181_PCS0HIA         __preg16(KSEG1 + 0x0B000324)    /* Programmable Chip Select [0] High Address Register (R/W) */
-#define VR4181_PCS1STRA                __preg16(KSEG1 + 0x0B000326)    /* Programmable Chip Select [1] Start Address Register (R/W) */
-#define VR4181_PCS1STPA                __preg16(KSEG1 + 0x0B000328)    /* Programmable Chip Select [1] Stop Address Register (R/W) */
-#define VR4181_PCS1HIA         __preg16(KSEG1 + 0x0B00032A)    /* Programmable Chip Select [1] High Address Register (R/W) */
-#define VR4181_PCSMODE         __preg16(KSEG1 + 0x0B00032C)    /* Programmable Chip Select Mode Register (R/W) */
-#define VR4181_LCDGPMODE       __preg16(KSEG1 + 0x0B00032E)    /* LCD General Purpose Mode Register (R/W) */
-#define VR4181_MISCREG0                __preg16(KSEG1 + 0x0B000330)    /* Misc. R/W Battery Backed Registers for Non-Volatile Storage (R/W) */
-#define VR4181_MISCREG1                __preg16(KSEG1 + 0x0B000332)    /* Misc. R/W Battery Backed Registers for Non-Volatile Storage (R/W) */
-#define VR4181_MISCREG2                __preg16(KSEG1 + 0x0B000334)    /* Misc. R/W Battery Backed Registers for Non-Volatile Storage (R/W) */
-#define VR4181_MISCREG3                __preg16(KSEG1 + 0x0B000336)    /* Misc. R/W Battery Backed Registers for Non-Volatile Storage (R/W) */
-#define VR4181_MISCREG4                __preg16(KSEG1 + 0x0B000338)    /* Misc. R/W Battery Backed Registers for Non-Volatile Storage (R/W) */
-#define VR4181_MISCREG5                __preg16(KSEG1 + 0x0B00033A)    /* Misc. R/W Battery Backed Registers for Non-Volatile Storage (R/W) */
-#define VR4181_MISCREG6                __preg16(KSEG1 + 0x0B00033C)    /* Misc. R/W Battery Backed Registers for Non-Volatile Storage (R/W) */
-#define VR4181_MISCREG7                __preg16(KSEG1 + 0x0B00033D)    /* Misc. R/W Battery Backed Registers for Non-Volatile Storage (R/W) */
-#define VR4181_MISCREG8                __preg16(KSEG1 + 0x0B000340)    /* Misc. R/W Battery Backed Registers for Non-Volatile Storage (R/W) */
-#define VR4181_MISCREG9                __preg16(KSEG1 + 0x0B000342)    /* Misc. R/W Battery Backed Registers for Non-Volatile Storage (R/W) */
-#define VR4181_MISCREG10       __preg16(KSEG1 + 0x0B000344)    /* Misc. R/W Battery Backed Registers for Non-Volatile Storage (R/W) */
-#define VR4181_MISCREG11       __preg16(KSEG1 + 0x0B000346)    /* Misc. R/W Battery Backed Registers for Non-Volatile Storage (R/W) */
-#define VR4181_MISCREG12       __preg16(KSEG1 + 0x0B000348)    /* Misc. R/W Battery Backed Registers for Non-Volatile Storage (R/W) */
-#define VR4181_MISCREG13       __preg16(KSEG1 + 0x0B00034A)    /* Misc. R/W Battery Backed Registers for Non-Volatile Storage (R/W) */
-#define VR4181_MISCREG14       __preg16(KSEG1 + 0x0B00034C)    /* Misc. R/W Battery Backed Registers for Non-Volatile Storage (R/W) */
-#define VR4181_MISCREG15       __preg16(KSEG1 + 0x0B00034E)    /* Misc. R/W Battery Backed Registers for Non-Volatile Storage (R/W) */
-#define VR4181_SECIRQMASKL     VR4181_GPINTEN
-// No SECIRQMASKH for VR4181
-
-// Touch Panel Interface Unit (PIU)
-#define VR4181_PIUCNTREG       __preg16(KSEG1 + 0x0B000122)    /* PIU Control register (R/W) */
-#define VR4181_PIUCNTREG_PIUSEQEN      0x0004
-#define VR4181_PIUCNTREG_PIUPWR                0x0002
-#define VR4181_PIUCNTREG_PADRST                0x0001
-
-#define VR4181_PIUINTREG       __preg16(KSEG1 + 0x0B000124)    /* PIU Interrupt cause register (R/W) */
-#define VR4181_PIUINTREG_OVP           0x8000
-#define VR4181_PIUINTREG_PADCMD                0x0040
-#define VR4181_PIUINTREG_PADADP                0x0020
-#define VR4181_PIUINTREG_PADPAGE1      0x0010
-#define VR4181_PIUINTREG_PADPAGE0      0x0008
-#define VR4181_PIUINTREG_PADDLOST      0x0004
-#define VR4181_PIUINTREG_PENCHG                0x0001
-
-#define VR4181_PIUSIVLREG      __preg16(KSEG1 + 0x0B000126)    /* PIU Data sampling interval register (R/W) */
-#define VR4181_PIUSTBLREG      __preg16(KSEG1 + 0x0B000128)    /* PIU A/D converter start delay register (R/W) */
-#define VR4181_PIUCMDREG       __preg16(KSEG1 + 0x0B00012A)    /* PIU A/D command register (R/W) */
-#define VR4181_PIUASCNREG      __preg16(KSEG1 + 0x0B000130)    /* PIU A/D port scan register (R/W) */
-#define VR4181_PIUAMSKREG      __preg16(KSEG1 + 0x0B000132)    /* PIU A/D scan mask register (R/W) */
-#define VR4181_PIUCIVLREG      __preg16(KSEG1 + 0x0B00013E)    /* PIU Check interval register (R) */
-#define VR4181_PIUPB00REG      __preg16(KSEG1 + 0x0B0002A0)    /* PIU Page 0 Buffer 0 register (R/W) */
-#define VR4181_PIUPB01REG      __preg16(KSEG1 + 0x0B0002A2)    /* PIU Page 0 Buffer 1 register (R/W) */
-#define VR4181_PIUPB02REG      __preg16(KSEG1 + 0x0B0002A4)    /* PIU Page 0 Buffer 2 register (R/W) */
-#define VR4181_PIUPB03REG      __preg16(KSEG1 + 0x0B0002A6)    /* PIU Page 0 Buffer 3 register (R/W) */
-#define VR4181_PIUPB10REG      __preg16(KSEG1 + 0x0B0002A8)    /* PIU Page 1 Buffer 0 register (R/W) */
-#define VR4181_PIUPB11REG      __preg16(KSEG1 + 0x0B0002AA)    /* PIU Page 1 Buffer 1 register (R/W) */
-#define VR4181_PIUPB12REG      __preg16(KSEG1 + 0x0B0002AC)    /* PIU Page 1 Buffer 2 register (R/W) */
-#define VR4181_PIUPB13REG      __preg16(KSEG1 + 0x0B0002AE)    /* PIU Page 1 Buffer 3 register (R/W) */
-#define VR4181_PIUAB0REG       __preg16(KSEG1 + 0x0B0002B0)    /* PIU A/D scan Buffer 0 register (R/W) */
-#define VR4181_PIUAB1REG       __preg16(KSEG1 + 0x0B0002B2)    /* PIU A/D scan Buffer 1 register (R/W) */
-#define VR4181_PIUAB2REG       __preg16(KSEG1 + 0x0B0002B4)    /* PIU A/D scan Buffer 2 register (R/W) */
-#define VR4181_PIUAB3REG       __preg16(KSEG1 + 0x0B0002B6)    /* PIU A/D scan Buffer 3 register (R/W) */
-#define VR4181_PIUPB04REG      __preg16(KSEG1 + 0x0B0002BC)    /* PIU Page 0 Buffer 4 register (R/W) */
-#define VR4181_PIUPB14REG      __preg16(KSEG1 + 0x0B0002BE)    /* PIU Page 1 Buffer 4 register (R/W) */
-
-// Audio Interface Unit (AIU)
-#define VR4181_SODATREG                __preg16(KSEG1 + 0x0B000166)    /* Speaker Output Data Register (R/W) */
-#define VR4181_SCNTREG         __preg16(KSEG1 + 0x0B000168)    /* Speaker Output Control Register (R/W) */
-#define VR4181_MIDATREG                __preg16(KSEG1 + 0x0B000170)    /* Mike Input Data Register (R/W) */
-#define VR4181_MCNTREG         __preg16(KSEG1 + 0x0B000172)    /* Mike Input Control Register (R/W) */
-#define VR4181_DVALIDREG       __preg16(KSEG1 + 0x0B000178)    /* Data Valid Register (R/W) */
-#define VR4181_SEQREG          __preg16(KSEG1 + 0x0B00017A)    /* Sequential Register (R/W) */
-#define VR4181_INTREG          __preg16(KSEG1 + 0x0B00017C)    /* Interrupt Register (R/W) */
-#define VR4181_SDMADATREG      __preg16(KSEG1 + 0x0B000160)    /* Speaker DMA Data Register (R/W) */
-#define VR4181_MDMADATREG      __preg16(KSEG1 + 0x0B000162)    /* Microphone DMA Data Register (R/W) */
-#define VR4181_DAVREF_SETUP    __preg16(KSEG1 + 0x0B000164)    /* DAC Vref setup register (R/W) */
-#define VR4181_SCNVC_END       __preg16(KSEG1 + 0x0B00016E)    /* Speaker sample rate control (R/W) */
-#define VR4181_MIDATREG                __preg16(KSEG1 + 0x0B000170)    /* Microphone Input Data Register (R/W) */
-#define VR4181_MCNTREG         __preg16(KSEG1 + 0x0B000172)    /* Microphone Input Control Register (R/W) */
-#define VR4181_MCNVC_END       __preg16(KSEG1 + 0x0B00017E)    /* Microphone sample rate control (R/W) */
-
-// Keyboard Interface Unit (KIU)
-#define VR4181_KIUDAT0         __preg16(KSEG1 + 0x0B000180)    /* KIU Data0 Register (R/W) */
-#define VR4181_KIUDAT1         __preg16(KSEG1 + 0x0B000182)    /* KIU Data1 Register (R/W) */
-#define VR4181_KIUDAT2         __preg16(KSEG1 + 0x0B000184)    /* KIU Data2 Register (R/W) */
-#define VR4181_KIUDAT3         __preg16(KSEG1 + 0x0B000186)    /* KIU Data3 Register (R/W) */
-#define VR4181_KIUDAT4         __preg16(KSEG1 + 0x0B000188)    /* KIU Data4 Register (R/W) */
-#define VR4181_KIUDAT5         __preg16(KSEG1 + 0x0B00018A)    /* KIU Data5 Register (R/W) */
-#define VR4181_KIUSCANREP      __preg16(KSEG1 + 0x0B000190)    /* KIU Scan/Repeat Register (R/W) */
-#define VR4181_KIUSCANREP_KEYEN      0x8000
-#define VR4181_KIUSCANREP_SCANSTP    0x0008
-#define VR4181_KIUSCANREP_SCANSTART  0x0004
-#define VR4181_KIUSCANREP_ATSTP      0x0002
-#define VR4181_KIUSCANREP_ATSCAN     0x0001
-#define VR4181_KIUSCANS                __preg16(KSEG1 + 0x0B000192)    /* KIU Scan Status Register (R) */
-#define VR4181_KIUWKS          __preg16(KSEG1 + 0x0B000194)    /* KIU Wait Keyscan Stable Register (R/W) */
-#define VR4181_KIUWKI          __preg16(KSEG1 + 0x0B000196)    /* KIU Wait Keyscan Interval Register (R/W) */
-#define VR4181_KIUINT          __preg16(KSEG1 + 0x0B000198)    /* KIU Interrupt Register (R/W) */
-#define VR4181_KIUINT_KDATLOST       0x0004
-#define VR4181_KIUINT_KDATRDY        0x0002
-#define VR4181_KIUINT_SCANINT        0x0001
-#define VR4181_KIUDAT6         __preg16(KSEG1 + 0x0B00018C)    /* Scan Line 6 Key Data Register (R) */
-#define VR4181_KIUDAT7         __preg16(KSEG1 + 0x0B00018E)    /* Scan Line 7 Key Data Register (R) */
-
-// CompactFlash Controller
-#define VR4181_PCCARDINDEX     __preg8(KSEG1 + 0x0B0008E0)     /* PC Card Controller Index Register */
-#define VR4181_PCCARDDATA      __preg8(KSEG1 + 0x0B0008E1)     /* PC Card Controller Data Register */
-#define VR4181_INTSTATREG      __preg16(KSEG1 + 0x0B0008F8)    /* Interrupt Status Register (R/W) */
-#define VR4181_INTMSKREG       __preg16(KSEG1 + 0x0B0008FA)    /* Interrupt Mask Register (R/W) */
-#define VR4181_CFG_REG_1       __preg16(KSEG1 + 0x0B0008FE)    /* Configuration Register 1 */
-
-// LED Control Unit (LED)
-#define VR4181_LEDHTSREG       __preg16(KSEG1 + 0x0B000240)    /* LED H Time Set register (R/W) */
-#define VR4181_LEDLTSREG       __preg16(KSEG1 + 0x0B000242)    /* LED L Time Set register (R/W) */
-#define VR4181_LEDCNTREG       __preg16(KSEG1 + 0x0B000248)    /* LED Control register (R/W) */
-#define VR4181_LEDASTCREG      __preg16(KSEG1 + 0x0B00024A)    /* LED Auto Stop Time Count register (R/W) */
-#define VR4181_LEDINTREG       __preg16(KSEG1 + 0x0B00024C)    /* LED Interrupt register (R/W) */
-
-// Serial Interface Unit (SIU / SIU1 and SIU2)
-#define VR4181_SIURB           __preg8(KSEG1 + 0x0C000010)     /* Receiver Buffer Register (Read) DLAB = 0 (R) */
-#define VR4181_SIUTH           __preg8(KSEG1 + 0x0C000010)     /* Transmitter Holding Register (Write) DLAB = 0 (W) */
-#define VR4181_SIUDLL          __preg8(KSEG1 + 0x0C000010)     /* Divisor Latch (Least Significant Byte) DLAB = 1 (R/W) */
-#define VR4181_SIUIE           __preg8(KSEG1 + 0x0C000011)     /* Interrupt Enable DLAB = 0 (R/W) */
-#define VR4181_SIUDLM          __preg8(KSEG1 + 0x0C000011)     /* Divisor Latch (Most Significant Byte) DLAB = 1 (R/W) */
-#define VR4181_SIUIID          __preg8(KSEG1 + 0x0C000012)     /* Interrupt Identification Register (Read) (R) */
-#define VR4181_SIUFC           __preg8(KSEG1 + 0x0C000012)     /* FIFO Control Register (Write) (W) */
-#define VR4181_SIULC           __preg8(KSEG1 + 0x0C000013)     /* Line Control Register (R/W) */
-#define VR4181_SIUMC           __preg8(KSEG1 + 0x0C000014)     /* MODEM Control Register (R/W) */
-#define VR4181_SIULS           __preg8(KSEG1 + 0x0C000015)     /* Line Status Register (R/W) */
-#define VR4181_SIUMS           __preg8(KSEG1 + 0x0C000016)     /* MODEM Status Register (R/W) */
-#define VR4181_SIUSC           __preg8(KSEG1 + 0x0C000017)     /* Scratch Register (R/W) */
-#define VR4181_SIURESET                __preg8(KSEG1 + 0x0C000019)     /* SIU Reset Register (R/W) */
-#define VR4181_SIUACTMSK       __preg8(KSEG1 + 0x0C00001C)     /* SIU Activity Mask (R/W) */
-#define VR4181_SIUACTTMR       __preg8(KSEG1 + 0x0C00001E)     /* SIU Activity Timer (R/W) */
-#define VR4181_SIURB_2         __preg8(KSEG1 + 0x0C000000)     /* Receive Buffer Register (Read) (R) */
-#define VR4181_SIUTH_2         __preg8(KSEG1 + 0x0C000000)     /* Transmitter Holding Register (Write) (W) */
-#define VR4181_SIUDLL_2                __preg8(KSEG1 + 0x0C000000)     /* Divisor Latch (Least Significant Byte) (R/W) */
-#define VR4181_SIUIE_2         __preg8(KSEG1 + 0x0C000001)     /* Interrupt Enable (DLAB = 0) (R/W) */
-#define VR4181_SIUDLM_2                __preg8(KSEG1 + 0x0C000001)     /* Divisor Latch (Most Significant Byte) (DLAB = 1) (R/W) */
-#define VR4181_SIUIID_2                __preg8(KSEG1 + 0x0C000002)     /* Interrupt Identification Register (Read) (R) */
-#define VR4181_SIUFC_2         __preg8(KSEG1 + 0x0C000002)     /* FIFO Control Register (Write) (W) */
-#define VR4181_SIULC_2         __preg8(KSEG1 + 0x0C000003)     /* Line Control Register (R/W) */
-#define VR4181_SIUMC_2         __preg8(KSEG1 + 0x0C000004)     /* Modem Control Register (R/W) */
-#define VR4181_SIULS_2         __preg8(KSEG1 + 0x0C000005)     /* Line Status Register (R/W) */
-#define VR4181_SIUMS_2         __preg8(KSEG1 + 0x0C000006)     /* Modem Status Register (R/W) */
-#define VR4181_SIUSC_2         __preg8(KSEG1 + 0x0C000007)     /* Scratch Register (R/W) */
-#define VR4181_SIUIRSEL_2      __preg8(KSEG1 + 0x0C000008)     /* SIU IrDA Selectot (R/W) */
-#define VR4181_SIURESET_2      __preg8(KSEG1 + 0x0C000009)     /* SIU Reset Register (R/W) */
-#define VR4181_SIUCSEL_2       __preg8(KSEG1 + 0x0C00000A)     /* IrDA Echo-back Control (R/W) */
-#define VR4181_SIUACTMSK_2     __preg8(KSEG1 + 0x0C00000C)     /* SIU Activity Mask Register (R/W) */
-#define VR4181_SIUACTTMR_2     __preg8(KSEG1 + 0x0C00000E)     /* SIU Activity Timer Register (R/W) */
-
-
-// USB Module
-#define VR4181_USBINFIFO       __preg16(KSEG1 + 0x0B000780)    /* USB Bulk Input FIFO (Bulk In End Point) (W) */
-#define VR4181_USBOUTFIFO      __preg16(KSEG1 + 0x0B000782)    /* USB Bulk Output FIFO (Bulk Out End Point) (R) */
-#define VR4181_USBCTLFIFO      __preg16(KSEG1 + 0x0B000784)    /* USB Control FIFO (Control End Point) (W) */
-#define VR4181_USBSTAT         __preg16(KSEG1 + 0x0B000786)    /* Interrupt Status Register (R/W) */
-#define VR4181_USBINTMSK       __preg16(KSEG1 + 0x0B000788)    /* Interrupt Mask Register (R/W) */
-#define VR4181_USBCTLREG       __preg16(KSEG1 + 0x0B00078A)    /* Control Register (R/W) */
-#define VR4181_USBSTPREG       __preg16(KSEG1 + 0x0B00078C)    /* USB Transfer Stop Register (R/W) */
-
-// LCD Controller
-#define VR4181_HRTOTALREG      __preg16(KSEG1 + 0x0A000400)    /* Horizontal total Register (R/W) */
-#define VR4181_HRVISIBREG      __preg16(KSEG1 + 0x0A000402)    /* Horizontal Visible Register (R/W) */
-#define VR4181_LDCLKSTREG      __preg16(KSEG1 + 0x0A000404)    /* Load clock start Register (R/W) */
-#define VR4181_LDCLKNDREG      __preg16(KSEG1 + 0x0A000406)    /* Load clock end Register (R/W) */
-#define VR4181_VRTOTALREG      __preg16(KSEG1 + 0x0A000408)    /* Vertical Total Register (R/W) */
-#define VR4181_VRVISIBREG      __preg16(KSEG1 + 0x0A00040A)    /* Vertical Visible Register (R/W) */
-#define VR4181_FVSTARTREG      __preg16(KSEG1 + 0x0A00040C)    /* FLM vertical start Register (R/W) */
-#define VR4181_FVENDREG                __preg16(KSEG1 + 0x0A00040E)    /* FLM vertical end Register (R/W) */
-#define VR4181_LCDCTRLREG      __preg16(KSEG1 + 0x0A000410)    /* LCD control Register (R/W) */
-#define VR4181_LCDINRQREG      __preg16(KSEG1 + 0x0A000412)    /* LCD Interrupt request Register (R/W) */
-#define VR4181_LCDCFGREG0      __preg16(KSEG1 + 0x0A000414)    /* LCD Configuration Register 0 (R/W) */
-#define VR4181_LCDCFGREG1      __preg16(KSEG1 + 0x0A000416)    /* LCD Configuration Register 1 (R/W) */
-#define VR4181_FBSTAD1REG      __preg16(KSEG1 + 0x0A000418)    /* Frame Buffer Start Address 1 Register (R/W) */
-#define VR4181_FBSTAD2REG      __preg16(KSEG1 + 0x0A00041A)    /* Frame Buffer Start Address 2 Register (R/W) */
-#define VR4181_FBNDAD1REG      __preg16(KSEG1 + 0x0A000420)    /* Frame Buffer End Address 1 Register (R/W) */
-#define VR4181_FBNDAD2REG      __preg16(KSEG1 + 0x0A000422)    /* Frame Buffer End Address 2 register (R/W) */
-#define VR4181_FHSTARTREG      __preg16(KSEG1 + 0x0A000424)    /* FLM horizontal Start Register (R/W) */
-#define VR4181_FHENDREG                __preg16(KSEG1 + 0x0A000426)    /* FLM horizontal End Register (R/W) */
-#define VR4181_PWRCONREG1      __preg16(KSEG1 + 0x0A000430)    /* Power Control register 1 (R/W) */
-#define VR4181_PWRCONREG2      __preg16(KSEG1 + 0x0A000432)    /* Power Control register 2 (R/W) */
-#define VR4181_LCDIMSKREG      __preg16(KSEG1 + 0x0A000434)    /* LCD Interrupt Mask register (R/W) */
-#define VR4181_CPINDCTREG      __preg16(KSEG1 + 0x0A00047E)    /* Color palette Index and control Register (R/W) */
-#define VR4181_CPALDATREG      __preg32(KSEG1 + 0x0A000480)    /* Color palette data register (32bits Register) (R/W) */
-
-// physical address spaces
-#define VR4181_LCD             0x0a000000
-#define VR4181_INTERNAL_IO_2   0x0b000000
-#define VR4181_INTERNAL_IO_1   0x0c000000
-#define VR4181_ISA_MEM         0x10000000
-#define VR4181_ISA_IO          0x14000000
-#define VR4181_ROM             0x18000000
-
-// This is the base address for IO port decoding to which the 16 bit IO port address
-// is added.  Defining it to 0 will usually cause a kernel oops any time port IO is
-// attempted, which can be handy for turning up parts of the kernel that make
-// incorrect architecture assumptions (by assuming that everything acts like a PC),
-// but we need it correctly defined to use the PCMCIA/CF controller:
-#define VR4181_PORT_BASE       (KSEG1 + VR4181_ISA_IO)
-#define VR4181_ISAMEM_BASE     (KSEG1 + VR4181_ISA_MEM)
-
-#endif /* __ASM_VR4181_VR4181_H */
index 7d41e44463f954ee6edcbf93a88efe8d33684d7d..bd2723c309011461e27196f18746114be264dcce 100644 (file)
@@ -7,7 +7,7 @@
  * Copyright (C) 2001, 2002 Paul Mundt
  * Copyright (C) 2002 MontaVista Software, Inc.
  * Copyright (C) 2002 TimeSys Corp.
- * Copyright (C) 2003-2004 Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
+ * Copyright (C) 2003-2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -79,11 +79,11 @@ extern void vr41xx_mask_clock(vr41xx_clock_t clock);
 #define MIPS_CPU_IRQ(x)                (MIPS_CPU_IRQ_BASE + (x))
 #define MIPS_SOFTINT0_IRQ      MIPS_CPU_IRQ(0)
 #define MIPS_SOFTINT1_IRQ      MIPS_CPU_IRQ(1)
-#define INT0_CASCADE_IRQ       MIPS_CPU_IRQ(2)
-#define INT1_CASCADE_IRQ       MIPS_CPU_IRQ(3)
-#define INT2_CASCADE_IRQ       MIPS_CPU_IRQ(4)
-#define INT3_CASCADE_IRQ       MIPS_CPU_IRQ(5)
-#define INT4_CASCADE_IRQ       MIPS_CPU_IRQ(6)
+#define INT0_IRQ               MIPS_CPU_IRQ(2)
+#define INT1_IRQ               MIPS_CPU_IRQ(3)
+#define INT2_IRQ               MIPS_CPU_IRQ(4)
+#define INT3_IRQ               MIPS_CPU_IRQ(5)
+#define INT4_IRQ               MIPS_CPU_IRQ(6)
 #define TIMER_IRQ              MIPS_CPU_IRQ(7)
 
 /* SYINT1 Interrupt Numbers */
@@ -97,7 +97,7 @@ extern void vr41xx_mask_clock(vr41xx_clock_t clock);
 #define PIU_IRQ                        SYSINT1_IRQ(5)
 #define AIU_IRQ                        SYSINT1_IRQ(6)
 #define KIU_IRQ                        SYSINT1_IRQ(7)
-#define GIUINT_CASCADE_IRQ     SYSINT1_IRQ(8)
+#define GIUINT_IRQ             SYSINT1_IRQ(8)
 #define SIU_IRQ                        SYSINT1_IRQ(9)
 #define BUSERR_IRQ             SYSINT1_IRQ(10)
 #define SOFTINT_IRQ            SYSINT1_IRQ(11)
@@ -128,7 +128,7 @@ extern void vr41xx_mask_clock(vr41xx_clock_t clock);
 #define GIU_IRQ_LAST           GIU_IRQ(31)
 
 extern int vr41xx_set_intassign(unsigned int irq, unsigned char intassign);
-extern int vr41xx_cascade_irq(unsigned int irq, int (*get_irq_number)(int irq));
+extern int cascade_irq(unsigned int irq, int (*get_irq)(unsigned int, struct pt_regs *));
 
 #define PIUINT_COMMAND         0x0040
 #define PIUINT_DATA            0x0020
index 58e193c51b45ac370f7fbb9f88c2dc513c5c0fa0..bb7a85c186e4c7d663c7798b6f25d453f2c4a6a3 100644 (file)
@@ -21,8 +21,8 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-#ifndef __NEC_VRC4173_H 
-#define __NEC_VRC4173_H 
+#ifndef __NEC_VRC4173_H
+#define __NEC_VRC4173_H
 
 #include <linux/config.h>
 #include <asm/io.h>
index c4a70412134327a586b46acc7f00b385b14d8f0f..04ee53b34c2e76a70a45d14ed8c5da9df6a7084b 100644 (file)
  */
 #define BCM1250_M3_WAR 1
 
-/* 
+/*
  * This is a DUART workaround related to glitches around register accesses
  */
 #define SIBYTE_1956_WAR 1
 
 /*
  * Fill buffers not flushed on CACHE instructions
- * 
+ *
  * Hit_Invalidate_I cacheops invalidate an icache line but the refill
  * for that line can get stale data from the fill buffer instead of
  * accessing memory if the previous icache miss was also to that line.
index 75c0ddfeca13e21cce645ff7c168f254f1a4cf3b..4d84a90b0f200c53c268a8f363063a4dac9deae0 100644 (file)
@@ -22,7 +22,7 @@
  *
  * ########################################################################
  *
- * 
+ *
  */
 #ifndef __ASM_XXS1500_H
 #define __ASM_XXS1500_H
index 4a12692f94b4659c5d10769416cddebb34421f88..44eae9f8274d8029786a81aa1fcad4ff9e022b95 100644 (file)
@@ -74,20 +74,6 @@ typedef struct { unsigned long pgprot; } pgprot_t;
 #define __pgd(x)       ((pgd_t) { (x) } )
 #define __pgprot(x)    ((pgprot_t) { (x) } )
 
-/* Pure 2^n version of get_order */
-extern __inline__ int get_order(unsigned long size)
-{
-       int order;
-
-       size = (size-1) >> (PAGE_SHIFT-1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-       return order;
-}
-
 typedef struct __physmem_range {
        unsigned long start_pfn;
        unsigned long pages;       /* PAGE_SIZE pages */
@@ -159,4 +145,6 @@ extern int npmem_ranges;
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _PARISC_PAGE_H */
index 8fe7a44ea205d4a3059b61c089ed0c4a747ee31b..d21b9d0d63eabc37485671c951a7fc2dee470775 100644 (file)
@@ -56,8 +56,6 @@ typedef unsigned long long u64;
 typedef u32 dma_addr_t;
 typedef u64 dma64_addr_t;
 
-typedef unsigned int kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/bugs.h b/include/asm-powerpc/bugs.h
new file mode 100644 (file)
index 0000000..310187d
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef _POWERPC_BUGS_H
+#define _POWERPC_BUGS_H
+
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+/*
+ * This file is included by 'init/main.c' to check for
+ * architecture-dependent bugs.
+ */
+
+extern void check_bugs(void);
+
+#endif /* _POWERPC_BUGS_H */
similarity index 84%
rename from include/asm-ppc64/mc146818rtc.h
rename to include/asm-powerpc/mc146818rtc.h
index f713e1bbb533fb80d844ef8d7e125a8a4b55dc53..a5619a2a1393b3c532f2f4b4199eb5556523b33f 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _POWERPC_MC146818RTC_H
+#define _POWERPC_MC146818RTC_H
+
 /*
  * Machine dependent access functions for RTC registers.
  *
@@ -6,8 +9,8 @@
  * as published by the Free Software Foundation; either version
  * 2 of the License, or (at your option) any later version.
  */
-#ifndef __ASM_PPC64_MC146818RTC_H
-#define __ASM_PPC64_MC146818RTC_H
+
+#ifdef __KERNEL__
 
 #include <asm/io.h>
 
@@ -29,4 +32,5 @@ outb_p((addr),RTC_PORT(0)); \
 outb_p((val),RTC_PORT(1)); \
 })
 
-#endif /* __ASM_PPC64_MC146818RTC_H */
+#endif /* __KERNEL__ */
+#endif /* _POWERPC_MC146818RTC_H */
similarity index 96%
rename from include/asm-ppc64/mman.h
rename to include/asm-powerpc/mman.h
index d4f93446a52c75e8278c8b7faf7920493f693801..f2d55988d749db110f974266f624d6b89bf447e3 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __PPC64_MMAN_H__
-#define __PPC64_MMAN_H__
+#ifndef _POWERPC_MMAN_H
+#define _POWERPC_MMAN_H
 
 /*
  * This program is free software; you can redistribute it and/or
@@ -49,4 +49,4 @@
 #define MAP_ANON       MAP_ANONYMOUS
 #define MAP_FILE       0
 
-#endif /* __PPC64_MMAN_H__ */
+#endif /* _POWERPC_MMAN_H */
diff --git a/include/asm-powerpc/module.h b/include/asm-powerpc/module.h
new file mode 100644 (file)
index 0000000..4438f4f
--- /dev/null
@@ -0,0 +1,77 @@
+#ifndef _POWERPC_MODULE_H
+#define _POWERPC_MODULE_H
+
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/list.h>
+#include <asm/bug.h>
+
+
+#ifndef __powerpc64__
+/*
+ * Thanks to Paul M for explaining this.
+ *
+ * PPC can only do rel jumps += 32MB, and often the kernel and other
+ * modules are furthur away than this.  So, we jump to a table of
+ * trampolines attached to the module (the Procedure Linkage Table)
+ * whenever that happens.
+ */
+
+struct ppc_plt_entry {
+       /* 16 byte jump instruction sequence (4 instructions) */
+       unsigned int jump[4];
+};
+#endif /* __powerpc64__ */
+
+
+struct mod_arch_specific {
+#ifdef __powerpc64__
+       unsigned int stubs_section;     /* Index of stubs section in module */
+       unsigned int toc_section;       /* What section is the TOC? */
+#else
+       /* Indices of PLT sections within module. */
+       unsigned int core_plt_section;
+       unsigned int init_plt_section;
+#endif
+
+       /* List of BUG addresses, source line numbers and filenames */
+       struct list_head bug_list;
+       struct bug_entry *bug_table;
+       unsigned int num_bugs;
+};
+
+extern struct bug_entry *module_find_bug(unsigned long bugaddr);
+
+/*
+ * Select ELF headers.
+ * Make empty section for module_frob_arch_sections to expand.
+ */
+
+#ifdef __powerpc64__
+#    define Elf_Shdr   Elf64_Shdr
+#    define Elf_Sym    Elf64_Sym
+#    define Elf_Ehdr   Elf64_Ehdr
+#    ifdef MODULE
+       asm(".section .stubs,\"ax\",@nobits; .align 3; .previous");
+#    endif
+#else
+#    define Elf_Shdr   Elf32_Shdr
+#    define Elf_Sym    Elf32_Sym
+#    define Elf_Ehdr   Elf32_Ehdr
+#    ifdef MODULE
+       asm(".section .plt,\"ax\",@nobits; .align 3; .previous");
+       asm(".section .init.plt,\"ax\",@nobits; .align 3; .previous");
+#    endif     /* MODULE */
+#endif
+
+
+struct exception_table_entry;
+void sort_ex_table(struct exception_table_entry *start,
+                  struct exception_table_entry *finish);
+
+#endif /* _POWERPC_MODULE_H */
similarity index 62%
rename from include/asm-ppc64/sembuf.h
rename to include/asm-powerpc/sembuf.h
index 172e590007675b63d8c8d3ec8657f99125100eda..c98fc18fe805f491c14808df0baba1fe2954bcf8 100644 (file)
@@ -1,27 +1,36 @@
-#ifndef _PPC64_SEMBUF_H
-#define _PPC64_SEMBUF_H
+#ifndef _POWERPC_SEMBUF_H
+#define _POWERPC_SEMBUF_H
 
-/* 
- * The semid64_ds structure for PPC architecture.
- *
- *
+/*
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version
  * 2 of the License, or (at your option) any later version.
+ */
+
+/*
+ * The semid64_ds structure for PPC architecture.
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
  *
  * Pad space is left for:
- * - 2 miscellaneous 64-bit values
+ * - 64-bit time_t to solve y2038 problem
+ * - 2 miscellaneous 32-bit values
  */
 
 struct semid64_ds {
        struct ipc64_perm sem_perm;     /* permissions .. see ipc.h */
+#ifndef __powerpc64__
+       unsigned long   __unused1;
+#endif
        __kernel_time_t sem_otime;      /* last semop time */
+#ifndef __powerpc64__
+       unsigned long   __unused2;
+#endif
        __kernel_time_t sem_ctime;      /* last change time */
        unsigned long   sem_nsems;      /* no. of semaphores in array */
-
-       unsigned long   __unused1;
-       unsigned long   __unused2;
+       unsigned long   __unused3;
+       unsigned long   __unused4;
 };
 
-#endif /* _PPC64_SEMBUF_H */
+#endif /* _POWERPC_SEMBUF_H */
similarity index 72%
rename from include/asm-ppc64/shmbuf.h
rename to include/asm-powerpc/shmbuf.h
index 02e99d6ec925eb03ba003b00b5284cd1d4ad8c0b..29632db3b1788634528fee93eacf06234671a067 100644 (file)
@@ -1,31 +1,47 @@
-#ifndef _PPC64_SHMBUF_H
-#define _PPC64_SHMBUF_H
+#ifndef _POWERPC_SHMBUF_H
+#define _POWERPC_SHMBUF_H
 
-/* 
- * The shmid64_ds structure for PPC64 architecture.
- * Note extra padding because this structure is passed back and forth
- * between kernel and user space.
- *
- * Pad space is left for:
- * - 2 miscellaneous 64-bit values
- *
+/*
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version
  * 2 of the License, or (at your option) any later version.
  */
 
+/*
+ * The shmid64_ds structure for PPC architecture.
+ *
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
+ *
+ * Pad space is left for:
+ * - 64-bit time_t to solve y2038 problem
+ * - 2 miscellaneous 32-bit values
+ */
+
 struct shmid64_ds {
        struct ipc64_perm       shm_perm;       /* operation perms */
+#ifndef __power64__
+       unsigned long           __unused1;
+#endif
        __kernel_time_t         shm_atime;      /* last attach time */
+#ifndef __power64__
+       unsigned long           __unused2;
+#endif
        __kernel_time_t         shm_dtime;      /* last detach time */
+#ifndef __power64__
+       unsigned long           __unused3;
+#endif
        __kernel_time_t         shm_ctime;      /* last change time */
+#ifndef __power64__
+       unsigned long           __unused4;
+#endif
        size_t                  shm_segsz;      /* size of segment (bytes) */
        __kernel_pid_t          shm_cpid;       /* pid of creator */
        __kernel_pid_t          shm_lpid;       /* pid of last operator */
        unsigned long           shm_nattch;     /* no. of current attaches */
-       unsigned long           __unused1;
-       unsigned long           __unused2;
+       unsigned long           __unused5;
+       unsigned long           __unused6;
 };
 
 struct shminfo64 {
@@ -40,4 +56,4 @@ struct shminfo64 {
        unsigned long   __unused4;
 };
 
-#endif /* _PPC64_SHMBUF_H */
+#endif /* _POWERPC_SHMBUF_H */
similarity index 56%
rename from include/asm-ppc64/siginfo.h
rename to include/asm-powerpc/siginfo.h
index 3a7c23dcb5aaa557cc29fbe949692d2bc3c3c8be..ae70b8010b199da3ea9cabde0ad0e1283343ff28 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef _PPC64_SIGINFO_H
-#define _PPC64_SIGINFO_H
+#ifndef _POWERPC_SIGINFO_H
+#define _POWERPC_SIGINFO_H
 
 /*
  * This program is free software; you can redistribute it and/or
@@ -8,9 +8,11 @@
  * 2 of the License, or (at your option) any later version.
  */
 
-#define __ARCH_SI_PREAMBLE_SIZE        (4 * sizeof(int))
-#define SI_PAD_SIZE32          ((SI_MAX_SIZE/sizeof(int)) - 3)
+#ifdef __powerpc64__
+#    define __ARCH_SI_PREAMBLE_SIZE    (4 * sizeof(int))
+#    define SI_PAD_SIZE32              ((SI_MAX_SIZE/sizeof(int)) - 3)
+#endif
 
 #include <asm-generic/siginfo.h>
 
-#endif /* _PPC64_SIGINFO_H */
+#endif /* _POWERPC_SIGINFO_H */
similarity index 88%
rename from include/asm-ppc64/socket.h
rename to include/asm-powerpc/socket.h
index 9e1af8eb2d965be984631ee2654060d0a7a997fb..51a0cf5ee9f0e054b02b5f7dc36fda5c26ae16a2 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef _ASM_SOCKET_H
-#define _ASM_SOCKET_H
+#ifndef _POWERPC_SOCKET_H
+#define _POWERPC_SOCKET_H
 
 /*
  * This program is free software; you can redistribute it and/or
@@ -10,7 +10,7 @@
 
 #include <asm/sockios.h>
 
-/* For setsockoptions(2) */
+/* For setsockopt(2) */
 #define SOL_SOCKET     1
 
 #define SO_DEBUG       1
@@ -52,8 +52,8 @@
 #define SO_TIMESTAMP           29
 #define SCM_TIMESTAMP          SO_TIMESTAMP
 
-#define SO_ACCEPTCONN           30
+#define SO_ACCEPTCONN          30
 
-#define SO_PEERSEC             31
+#define SO_PEERSEC             31
 
-#endif /* _ASM_SOCKET_H */
+#endif /* _POWERPC_SOCKET_H */
similarity index 83%
rename from include/asm-ppc64/sockios.h
rename to include/asm-powerpc/sockios.h
index 6bd1a22af4f68df096471be107a090990c38fd1d..ef7ff664167e894e8a8851c4f5e383fc44ca7189 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef _ASM_PPC64_SOCKIOS_H
-#define _ASM_PPC64_SOCKIOS_H
+#ifndef _POWERPC_SOCKIOS_H
+#define _POWERPC_SOCKIOS_H
 
 /*
  * This program is free software; you can redistribute it and/or
@@ -16,4 +16,4 @@
 #define SIOCATMARK     0x8905
 #define SIOCGSTAMP     0x8906          /* Get stamp */
 
-#endif /* _ASM_PPC64_SOCKIOS_H */
+#endif /* _POWERPC_SOCKIOS_H */
similarity index 97%
rename from include/asm-ppc64/termbits.h
rename to include/asm-powerpc/termbits.h
index d1a2bee10cefa5270e0a863cf9899919a1695447..2c5bf85a8c3c2c30a8a36ea8b0ccba15e0b26d03 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef _PPC64_TERMBITS_H
-#define _PPC64_TERMBITS_H
+#ifndef _POWERPC_TERMBITS_H
+#define _POWERPC_TERMBITS_H
 
 /*
  * This program is free software; you can redistribute it and/or
@@ -8,8 +8,6 @@
  * 2 of the License, or (at your option) any later version.
  */
 
-#include <linux/posix_types.h>
-
 typedef unsigned char  cc_t;
 typedef unsigned int   speed_t;
 typedef unsigned int   tcflag_t;
@@ -190,4 +188,4 @@ struct termios {
 #define        TCSADRAIN       1
 #define        TCSAFLUSH       2
 
-#endif /* _PPC64_TERMBITS_H */
+#endif /* _POWERPC_TERMBITS_H */
similarity index 98%
rename from include/asm-ppc64/termios.h
rename to include/asm-powerpc/termios.h
index 02c3d283aa62bc1b4d7c5d1b22ce03ee4b8771eb..237533bb0e9f1a3e640c4906d8b350deafd315b9 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef _PPC64_TERMIOS_H
-#define _PPC64_TERMIOS_H
+#ifndef _POWERPC_TERMIOS_H
+#define _POWERPC_TERMIOS_H
 
 /*
  * Liberally adapted from alpha/termios.h.  In particular, the c_cc[]
@@ -87,6 +87,7 @@ struct termio {
 #define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
 #define N_HDLC         13      /* synchronous HDLC */
 #define N_SYNC_PPP     14
+#define N_HCI          15  /* Bluetooth HCI UART */
 
 #ifdef __KERNEL__
 /*                   ^C  ^\ del  ^U  ^D   1   0   0   0   0  ^W  ^R  ^Z  ^Q  ^S  ^V  ^U  */
@@ -232,4 +233,4 @@ struct termio {
 
 #endif /* __KERNEL__ */
 
-#endif /* _PPC64_TERMIOS_H */
+#endif /* _POWERPC_TERMIOS_H */
diff --git a/include/asm-ppc/bugs.h b/include/asm-ppc/bugs.h
deleted file mode 100644 (file)
index 8dce1e2..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-/*
- * This file is included by 'init/main.c'
- */
-
-extern void
-check_bugs(void);
index 6f74f59938d4970d72ac74943f223baacf362669..92b8ee78dcc21b6a959219ec9ef8da7872fb26a7 100644 (file)
@@ -60,7 +60,8 @@ static inline int dma_set_mask(struct device *dev, u64 dma_mask)
 }
 
 static inline void *dma_alloc_coherent(struct device *dev, size_t size,
-                                      dma_addr_t * dma_handle, int gfp)
+                                      dma_addr_t * dma_handle,
+                                      unsigned int __nocast gfp)
 {
 #ifdef CONFIG_NOT_COHERENT_CACHE
        return __dma_alloc_coherent(size, dma_handle, gfp);
index e807be96e9814761b9033d55da6332320c287e31..e992369cb8e9b476fd64306bbc92a846a5bb074f 100644 (file)
 
 #ifdef CONFIG_40x
 
-#if defined(CONFIG_ASH)
-#include <platforms/4xx/ash.h>
-#endif
-
 #if defined(CONFIG_BUBINGA)
 #include <platforms/4xx/bubinga.h>
 #endif
 #include <platforms/4xx/ep405.h>
 #endif
 
-#if defined(CONFIG_OAK)
-#include <platforms/4xx/oak.h>
-#endif
-
-#if defined(CONFIG_REDWOOD_4)
-#include <platforms/4xx/redwood.h>
-#endif
-
 #if defined(CONFIG_REDWOOD_5)
 #include <platforms/4xx/redwood5.h>
 #endif
index 3f7b5669e6d52c852727e4c7791dd78d89a16abf..bd7656fa20266d0efa7cedf8f1f78231e754ad8a 100644 (file)
@@ -67,6 +67,7 @@ struct ocp_func_emac_data {
        int     phy_mode;       /* PHY type or configurable mode */
        u8      mac_addr[6];    /* EMAC mac address */
        u32     phy_map;        /* EMAC phy map */
+       u32     phy_feat_exc;   /* Excluded PHY features */
 };
 
 /* Sysfs support */
@@ -100,6 +101,19 @@ void ocp_show_emac_data(struct device *dev)                                \
        device_create_file(dev, &dev_attr_emac_phy_map);                \
 }
 
+/*
+ * PHY mode settings (EMAC <-> ZMII/RGMII bridge <-> PHY)
+ */
+#define PHY_MODE_NA    0
+#define PHY_MODE_MII   1
+#define PHY_MODE_RMII  2
+#define PHY_MODE_SMII  3
+#define PHY_MODE_RGMII 4
+#define PHY_MODE_TBI   5
+#define PHY_MODE_GMII  6
+#define PHY_MODE_RTBI  7
+#define PHY_MODE_SGMII 8
+
 #ifdef CONFIG_40x
 /*
  * Helper function to copy MAC addresses from the bd_t to OCP EMAC
@@ -133,6 +147,7 @@ struct ocp_func_mal_data {
        int     txde_irq;       /* TX Descriptor Error IRQ */
        int     rxde_irq;       /* RX Descriptor Error IRQ */
        int     serr_irq;       /* MAL System Error IRQ    */
+       int     dcr_base;       /* MALx_CFG DCR number   */
 };
 
 #define OCP_SYSFS_MAL_DATA()                                           \
@@ -143,6 +158,7 @@ OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, rxeob_irq)   \
 OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, txde_irq)       \
 OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, rxde_irq)       \
 OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, serr_irq)       \
+OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, dcr_base)       \
                                                                        \
 void ocp_show_mal_data(struct device *dev)                             \
 {                                                                      \
@@ -153,6 +169,7 @@ void ocp_show_mal_data(struct device *dev)                          \
        device_create_file(dev, &dev_attr_mal_txde_irq);                \
        device_create_file(dev, &dev_attr_mal_rxde_irq);                \
        device_create_file(dev, &dev_attr_mal_serr_irq);                \
+       device_create_file(dev, &dev_attr_mal_dcr_base);                \
 }
 
 /*
index a9b33324f56299dfb49704ec5789e2cfd29df686..a244d93ca9537179a7fe6835df81d19eeb9325fb 100644 (file)
@@ -337,6 +337,7 @@ static __inline__ int irq_canonicalize(int irq)
 #define        SIU_INT_IDMA3           ((uint)0x08 + CPM_IRQ_OFFSET)
 #define        SIU_INT_IDMA4           ((uint)0x09 + CPM_IRQ_OFFSET)
 #define        SIU_INT_SDMA            ((uint)0x0a + CPM_IRQ_OFFSET)
+#define        SIU_INT_USB             ((uint)0x0b + CPM_IRQ_OFFSET)
 #define        SIU_INT_TIMER1          ((uint)0x0c + CPM_IRQ_OFFSET)
 #define        SIU_INT_TIMER2          ((uint)0x0d + CPM_IRQ_OFFSET)
 #define        SIU_INT_TIMER3          ((uint)0x0e + CPM_IRQ_OFFSET)
index 2589f182a6addff090f648c89e603a93c7c32be5..6d6fc78731e54627235cee4e4a846bd4bc80a3b0 100644 (file)
@@ -17,6 +17,7 @@ enum km_type {
        KM_SOFTIRQ0,
        KM_SOFTIRQ1,
        KM_PPC_SYNC_PAGE,
+       KM_PPC_SYNC_ICACHE,
        KM_TYPE_NR
 };
 
diff --git a/include/asm-ppc/mc146818rtc.h b/include/asm-ppc/mc146818rtc.h
deleted file mode 100644 (file)
index 227018b..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Machine dependent access functions for RTC registers.
- */
-#ifdef __KERNEL__
-#ifndef __ASM_PPC_MC146818RTC_H
-#define __ASM_PPC_MC146818RTC_H
-
-#include <asm/io.h>
-
-#ifndef RTC_PORT
-#define RTC_PORT(x)    (0x70 + (x))
-#define RTC_ALWAYS_BCD 1       /* RTC operates in binary mode */
-#endif
-
-/*
- * The yet supported machines all access the RTC index register via
- * an ISA port access but the way to access the date register differs ...
- */
-#define CMOS_READ(addr) ({ \
-outb_p((addr),RTC_PORT(0)); \
-inb_p(RTC_PORT(1)); \
-})
-#define CMOS_WRITE(val, addr) ({ \
-outb_p((addr),RTC_PORT(0)); \
-outb_p((val),RTC_PORT(1)); \
-})
-
-#define RTC_IRQ 8
-
-#endif /* __ASM_PPC_MC146818RTC_H */
-#endif /* __KERNEL__ */
diff --git a/include/asm-ppc/mman.h b/include/asm-ppc/mman.h
deleted file mode 100644 (file)
index 5fd19fd..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef __PPC_MMAN_H__
-#define __PPC_MMAN_H__
-
-#define PROT_READ      0x1             /* page can be read */
-#define PROT_WRITE     0x2             /* page can be written */
-#define PROT_EXEC      0x4             /* page can be executed */
-#define PROT_SEM       0x8             /* page may be used for atomic ops */
-#define PROT_NONE      0x0             /* page can not be accessed */
-#define PROT_GROWSDOWN 0x01000000      /* mprotect flag: extend change to start of growsdown vma */
-#define PROT_GROWSUP   0x02000000      /* mprotect flag: extend change to end of growsup vma */
-
-#define MAP_SHARED     0x01            /* Share changes */
-#define MAP_PRIVATE    0x02            /* Changes are private */
-#define MAP_TYPE       0x0f            /* Mask for type of mapping */
-#define MAP_FIXED      0x10            /* Interpret addr exactly */
-#define MAP_ANONYMOUS  0x20            /* don't use a file */
-#define MAP_RENAME      MAP_ANONYMOUS   /* In SunOS terminology */
-#define MAP_NORESERVE   0x40            /* don't reserve swap pages */
-#define MAP_LOCKED     0x80
-
-#define MAP_GROWSDOWN  0x0100          /* stack-like segment */
-#define MAP_DENYWRITE  0x0800          /* ETXTBSY */
-#define MAP_EXECUTABLE 0x1000          /* mark it as an executable */
-#define MAP_POPULATE   0x8000          /* populate (prefault) pagetables */
-#define MAP_NONBLOCK   0x10000         /* do not block on IO */
-
-#define MS_ASYNC       1               /* sync memory asynchronously */
-#define MS_INVALIDATE  2               /* invalidate the caches */
-#define MS_SYNC                4               /* synchronous memory sync */
-
-#define MCL_CURRENT     0x2000          /* lock all currently mapped pages */
-#define MCL_FUTURE      0x4000          /* lock all additions to address space */
-
-#define MADV_NORMAL    0x0             /* default page-in behavior */
-#define MADV_RANDOM    0x1             /* page-in minimum required */
-#define MADV_SEQUENTIAL        0x2             /* read-ahead aggressively */
-#define MADV_WILLNEED  0x3             /* pre-fault pages */
-#define MADV_DONTNEED  0x4             /* discard these pages */
-
-/* compatibility flags */
-#define MAP_ANON       MAP_ANONYMOUS
-#define MAP_FILE       0
-
-#endif /* __PPC_MMAN_H__ */
diff --git a/include/asm-ppc/module.h b/include/asm-ppc/module.h
deleted file mode 100644 (file)
index fb63492..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef _ASM_PPC_MODULE_H
-#define _ASM_PPC_MODULE_H
-/* Module stuff for PPC.  (C) 2001 Rusty Russell */
-
-#include <linux/list.h>
-#include <asm/bug.h>
-
-/* Thanks to Paul M for explaining this.
-
-   PPC can only do rel jumps += 32MB, and often the kernel and other
-   modules are furthur away than this.  So, we jump to a table of
-   trampolines attached to the module (the Procedure Linkage Table)
-   whenever that happens.
-*/
-
-struct ppc_plt_entry
-{
-       /* 16 byte jump instruction sequence (4 instructions) */
-       unsigned int jump[4];
-};
-
-struct mod_arch_specific
-{
-       /* Indices of PLT sections within module. */
-       unsigned int core_plt_section, init_plt_section;
-
-       /* List of BUG addresses, source line numbers and filenames */
-       struct list_head bug_list;
-       struct bug_entry *bug_table;
-       unsigned int num_bugs;
-};
-
-extern struct bug_entry *module_find_bug(unsigned long bugaddr);
-
-#define Elf_Shdr Elf32_Shdr
-#define Elf_Sym Elf32_Sym
-#define Elf_Ehdr Elf32_Ehdr
-
-/* Make empty sections for module_frob_arch_sections to expand. */
-#ifdef MODULE
-asm(".section .plt,\"ax\",@nobits; .align 3; .previous");
-asm(".section .init.plt,\"ax\",@nobits; .align 3; .previous");
-#endif
-#endif /* _ASM_PPC_MODULE_H */
index 89eb8a2ac6934552eeaf74d5ed222690ed504732..9694eca16e92a89ba86391e6a708f2e636dbd9e7 100644 (file)
 #define IO_VIRT_ADDR   IO_PHYS_ADDR
 #endif
 
+enum ppc_sys_devices {
+       MPC82xx_CPM_FCC1,
+       MPC82xx_CPM_FCC2,
+       MPC82xx_CPM_FCC3,
+       MPC82xx_CPM_I2C,
+       MPC82xx_CPM_SCC1,
+       MPC82xx_CPM_SCC2,
+       MPC82xx_CPM_SCC3,
+       MPC82xx_CPM_SCC4,
+       MPC82xx_CPM_SPI,
+       MPC82xx_CPM_MCC1,
+       MPC82xx_CPM_MCC2,
+       MPC82xx_CPM_SMC1,
+       MPC82xx_CPM_SMC2,
+       MPC82xx_CPM_USB,
+       MPC82xx_SEC1,
+};
+
 #ifndef __ASSEMBLY__
 /* The "residual" data board information structure the boot loader
  * hands to us.
index 7c31f2d564a16bb4dd961ff93e4881711719fa51..dc8e59896050150b7b488708517aca0209ec7dd4 100644 (file)
 #include <platforms/tqm8xx.h>
 #endif
 
-#if defined(CONFIG_SPD823TS)
-#include <platforms/spd8xx.h>
-#endif
-
 #if defined(CONFIG_IVMS8) || defined(CONFIG_IVML24)
 #include <platforms/ivms8.h>
 #endif
index cc25b921ad4fa643ccf62c7e88a4e2ab36342a3a..835930d6faa1bf54c2a4c71d5138a03730610183 100644 (file)
@@ -278,6 +278,13 @@ mv64x60_modify(struct mv64x60_handle *bh, u32 offs, u32 data, u32 mask)
 #define        mv64x60_set_bits(bh, offs, bits) mv64x60_modify(bh, offs, ~0, bits)
 #define        mv64x60_clr_bits(bh, offs, bits) mv64x60_modify(bh, offs, 0, bits)
 
+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GT64260)
+#define        MV64XXX_DEV_NAME        "mv64xxx"
+
+struct mv64xxx_pdata {
+       u32     hs_reg_valid;
+};
+#endif
 
 /* Externally visible function prototypes */
 int mv64x60_init(struct mv64x60_handle *bh, struct mv64x60_setup_info *si);
index 2f428746c02ba1cf07964a870d72935753ace5e3..f8f7f16b9b5359293e9c6c7a8152070cd998ffae 100644 (file)
 /*
  *****************************************************************************
  *
- *     SRAM Cotnroller Registers
+ *     SRAM Controller Registers
  *
  *****************************************************************************
  */
 /*
  *****************************************************************************
  *
- *     SDRAM/MEM Cotnroller Registers
+ *     SDRAM/MEM Controller Registers
  *
  *****************************************************************************
  */
 /* SDRAM Control Registers */
 #define MV64360_D_UNIT_CONTROL_LOW             0x1404
 #define MV64360_D_UNIT_CONTROL_HIGH            0x1424
+#define MV64460_D_UNIT_MMASK                   0x14b0
 
 /* SDRAM Error Report Registers (64360) */
 #define        MV64360_SDRAM_ERR_DATA_LO               0x1444
 /*
  *****************************************************************************
  *
- *     Device/BOOT Cotnroller Registers
+ *     Device/BOOT Controller Registers
  *
  *****************************************************************************
  */
 #define        MV64x60_PCI1_SLAVE_P2P_IO_REMAP         0x0dec
 #define        MV64x60_PCI1_SLAVE_CPU_REMAP            0x0df0
 
+#define        MV64360_PCICFG_CPCI_HOTSWAP             0x68
+
 /*
  *****************************************************************************
  *
index b24a4e37196a7d8242bb086061295ce1f7771bc1..6198b1657a455fd30b4ebfe31b6b3382db77953b 100644 (file)
@@ -1,8 +1,10 @@
 #ifndef _ASM_PPC_PARAM_H
 #define _ASM_PPC_PARAM_H
 
+#include <linux/config.h>
+
 #ifdef __KERNEL__
-#define HZ             1000            /* internal timer frequency */
+#define HZ             CONFIG_HZ       /* internal timer frequency */
 #define USER_HZ                100             /* for user interfaces in "ticks" */
 #define CLOCKS_PER_SEC (USER_HZ)       /* frequency at which times() counts */
 #endif /* __KERNEL__ */
index 8beb162873f4d07fc331b0319baf649f5c685a36..e9683bcff19bcec68c3b5ab16d9ee50f18299bd4 100644 (file)
@@ -32,6 +32,7 @@
 #define __PPC_ASM_PMAC_FEATURE_H
 
 #include <asm/macio.h>
+#include <asm/machdep.h>
 
 /*
  * Known Mac motherboard models
index 8ea6245662312f644aef30cf26c204e99e4512a2..048f7c8596eefb3e5042db3bfc9449dbac3009f5 100644 (file)
@@ -21,7 +21,9 @@
 #include <linux/device.h>
 #include <linux/types.h>
 
-#if defined(CONFIG_83xx)
+#if defined(CONFIG_8260)
+#include <asm/mpc8260.h>
+#elif defined(CONFIG_83xx)
 #include <asm/mpc83xx.h>
 #elif defined(CONFIG_85xx)
 #include <asm/mpc85xx.h>
@@ -50,6 +52,7 @@ extern struct ppc_sys_spec *cur_ppc_sys_spec;
 /* determine which specific SOC we are */
 extern void identify_ppc_sys_by_id(u32 id) __init;
 extern void identify_ppc_sys_by_name(char *name) __init;
+extern void identify_ppc_sys_by_name_and_id(char *name, u32 id) __init;
 
 /* describes all devices that may exist in a given family of processors */
 extern struct platform_device ppc_sys_platform_devices[];
diff --git a/include/asm-ppc/sembuf.h b/include/asm-ppc/sembuf.h
deleted file mode 100644 (file)
index 883f682..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef _PPC_SEMBUF_H
-#define _PPC_SEMBUF_H
-
-/*
- * The semid64_ds structure for PPC architecture.
- */
-
-struct semid64_ds {
-       struct ipc64_perm sem_perm;             /* permissions .. see ipc.h */
-       unsigned int    __unused1;
-       __kernel_time_t sem_otime;              /* last semop time */
-       unsigned int    __unused2;
-       __kernel_time_t sem_ctime;              /* last change time */
-       unsigned long   sem_nsems;              /* no. of semaphores in array */
-       unsigned long   __unused3;
-       unsigned long   __unused4;
-};
-
-#endif /* _PPC_SEMBUF_H */
index 6d47438be58c25735e7c570bdd525d109efedf6b..485a924e4d06b83b97d97d85c61c80dedc8b1184 100644 (file)
@@ -18,8 +18,6 @@
 #include <platforms/powerpmc250.h>
 #elif defined(CONFIG_LOPEC)
 #include <platforms/lopec.h>
-#elif defined(CONFIG_MCPN765)
-#include <platforms/mcpn765.h>
 #elif defined(CONFIG_MVME5100)
 #include <platforms/mvme5100.h>
 #elif defined(CONFIG_PAL4)
diff --git a/include/asm-ppc/shmbuf.h b/include/asm-ppc/shmbuf.h
deleted file mode 100644 (file)
index 7ac0bd3..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef _PPC_SHMBUF_H
-#define _PPC_SHMBUF_H
-
-/*
- * The shmid64_ds structure for PPC architecture.
- */
-
-struct shmid64_ds {
-       struct ipc64_perm       shm_perm;       /* operation perms */
-       unsigned int            __unused1;
-       __kernel_time_t         shm_atime;      /* last attach time */
-       unsigned int            __unused2;
-       __kernel_time_t         shm_dtime;      /* last detach time */
-       unsigned int            __unused3;
-       __kernel_time_t         shm_ctime;      /* last change time */
-       unsigned int            __unused4;
-       size_t                  shm_segsz;      /* size of segment (bytes) */
-       __kernel_pid_t          shm_cpid;       /* pid of creator */
-       __kernel_pid_t          shm_lpid;       /* pid of last operator */
-       unsigned long           shm_nattch;     /* no. of current attaches */
-       unsigned long           __unused5;
-       unsigned long           __unused6;
-};
-
-struct shminfo64 {
-       unsigned long   shmmax;
-       unsigned long   shmmin;
-       unsigned long   shmmni;
-       unsigned long   shmseg;
-       unsigned long   shmall;
-       unsigned long   __unused1;
-       unsigned long   __unused2;
-       unsigned long   __unused3;
-       unsigned long   __unused4;
-};
-
-#endif /* _PPC_SHMBUF_H */
diff --git a/include/asm-ppc/siginfo.h b/include/asm-ppc/siginfo.h
deleted file mode 100644 (file)
index 4b9435b..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _PPC_SIGINFO_H
-#define _PPC_SIGINFO_H
-
-#include <asm-generic/siginfo.h>
-
-#endif
diff --git a/include/asm-ppc/socket.h b/include/asm-ppc/socket.h
deleted file mode 100644 (file)
index 296e1a3..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef _ASM_SOCKET_H
-#define _ASM_SOCKET_H
-
-/* Socket-level I/O control calls. */
-#define FIOSETOWN      0x8901
-#define SIOCSPGRP      0x8902
-#define FIOGETOWN      0x8903
-#define SIOCGPGRP      0x8904
-#define SIOCATMARK     0x8905
-#define SIOCGSTAMP     0x8906          /* Get stamp */
-
-/* For setsockopt(2) */
-#define SOL_SOCKET     1
-
-#define SO_DEBUG       1
-#define SO_REUSEADDR   2
-#define SO_TYPE                3
-#define SO_ERROR       4
-#define SO_DONTROUTE   5
-#define SO_BROADCAST   6
-#define SO_SNDBUF      7
-#define SO_RCVBUF      8
-#define SO_SNDBUFFORCE 32
-#define SO_RCVBUFFORCE 33
-#define SO_KEEPALIVE   9
-#define SO_OOBINLINE   10
-#define SO_NO_CHECK    11
-#define SO_PRIORITY    12
-#define SO_LINGER      13
-#define SO_BSDCOMPAT   14
-/* To add :#define SO_REUSEPORT 15 */
-#define SO_RCVLOWAT    16
-#define SO_SNDLOWAT    17
-#define SO_RCVTIMEO    18
-#define SO_SNDTIMEO    19
-#define SO_PASSCRED    20
-#define SO_PEERCRED    21
-
-/* Security levels - as per NRL IPv6 - don't actually do anything */
-#define SO_SECURITY_AUTHENTICATION             22
-#define SO_SECURITY_ENCRYPTION_TRANSPORT       23
-#define SO_SECURITY_ENCRYPTION_NETWORK         24
-
-#define SO_BINDTODEVICE        25
-
-/* Socket filtering */
-#define SO_ATTACH_FILTER       26
-#define SO_DETACH_FILTER       27
-
-#define SO_PEERNAME            28
-#define SO_TIMESTAMP           29
-#define SCM_TIMESTAMP          SO_TIMESTAMP
-
-#define SO_ACCEPTCONN          30
-
-#define SO_PEERSEC             31
-
-#endif /* _ASM_SOCKET_H */
diff --git a/include/asm-ppc/sockios.h b/include/asm-ppc/sockios.h
deleted file mode 100644 (file)
index 385aedc..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef _ASM_PPC_SOCKIOS_H
-#define _ASM_PPC_SOCKIOS_H
-
-#if 0 /* These are defined this way on Alpha - maybe later. */
-/* Socket-level I/O control calls. */
-
-#define FIOGETOWN      _IOR('f', 123, int)
-#define FIOSETOWN      _IOW('f', 124, int)
-
-#define SIOCATMARK     _IOR('s', 7, int)
-#define SIOCSPGRP      _IOW('s', 8, pid_t)
-#define SIOCGPGRP      _IOR('s', 9, pid_t)
-
-#define SIOCGSTAMP     0x8906          /* Get stamp - linux-specific */
-#endif
-
-#endif /* _ASM_PPC_SOCKIOS_H */
index 82395f30004b7ba30cdec4d4e82c05c8ab9272a9..513a334c581032ec21ddc33819d7e25dad5b4bd0 100644 (file)
@@ -84,9 +84,14 @@ extern void cvt_fd(float *from, double *to, unsigned long *fpscr);
 extern void cvt_df(double *from, float *to, unsigned long *fpscr);
 extern int call_rtas(const char *, int, int, unsigned long *, ...);
 extern void cacheable_memzero(void *p, unsigned int nb);
+extern void *cacheable_memcpy(void *, const void *, unsigned int);
 extern int do_page_fault(struct pt_regs *, unsigned long, unsigned long);
 extern void bad_page_fault(struct pt_regs *, unsigned long, int);
 extern void die(const char *, struct pt_regs *, long);
+#ifdef CONFIG_BOOKE_WDT
+extern u32 booke_wdt_enabled;
+extern u32 booke_wdt_period;
+#endif /* CONFIG_BOOKE_WDT */
 
 struct device_node;
 extern void note_scsi_host(struct device_node *, void *);
diff --git a/include/asm-ppc/termbits.h b/include/asm-ppc/termbits.h
deleted file mode 100644 (file)
index c343fb7..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-#ifndef _PPC_TERMBITS_H
-#define _PPC_TERMBITS_H
-
-typedef unsigned char  cc_t;
-typedef unsigned int   speed_t;
-typedef unsigned int   tcflag_t;
-
-/*
- * termios type and macro definitions.  Be careful about adding stuff
- * to this file since it's used in GNU libc and there are strict rules
- * concerning namespace pollution.
- */
-
-#define NCCS 19
-struct termios {
-       tcflag_t c_iflag;               /* input mode flags */
-       tcflag_t c_oflag;               /* output mode flags */
-       tcflag_t c_cflag;               /* control mode flags */
-       tcflag_t c_lflag;               /* local mode flags */
-       cc_t c_cc[NCCS];                /* control characters */
-       cc_t c_line;                    /* line discipline (== c_cc[19]) */
-       speed_t c_ispeed;               /* input speed */
-       speed_t c_ospeed;               /* output speed */
-};
-
-/* c_cc characters */
-#define VINTR  0
-#define VQUIT  1
-#define VERASE         2
-#define VKILL  3
-#define VEOF   4
-#define VMIN   5
-#define VEOL   6
-#define VTIME  7
-#define VEOL2  8
-#define VSWTC  9
-
-#define VWERASE        10
-#define VREPRINT       11
-#define VSUSP          12
-#define VSTART         13
-#define VSTOP          14
-#define VLNEXT         15
-#define VDISCARD       16
-
-/* c_iflag bits */
-#define IGNBRK 0000001
-#define BRKINT 0000002
-#define IGNPAR 0000004
-#define PARMRK 0000010
-#define INPCK  0000020
-#define ISTRIP 0000040
-#define INLCR  0000100
-#define IGNCR  0000200
-#define ICRNL  0000400
-#define IXON   0001000
-#define IXOFF  0002000
-#define IXANY          0004000
-#define IUCLC          0010000
-#define IMAXBEL        0020000
-#define IUTF8  0040000
-
-/* c_oflag bits */
-#define OPOST  0000001
-#define ONLCR  0000002
-#define OLCUC  0000004
-
-#define OCRNL  0000010
-#define ONOCR  0000020
-#define ONLRET 0000040
-
-#define OFILL  00000100
-#define OFDEL  00000200
-#define NLDLY  00001400
-#define   NL0  00000000
-#define   NL1  00000400
-#define   NL2  00001000
-#define   NL3  00001400
-#define TABDLY 00006000
-#define   TAB0 00000000
-#define   TAB1 00002000
-#define   TAB2 00004000
-#define   TAB3 00006000
-#define   XTABS        00006000        /* required by POSIX to == TAB3 */
-#define CRDLY  00030000
-#define   CR0  00000000
-#define   CR1  00010000
-#define   CR2  00020000
-#define   CR3  00030000
-#define FFDLY  00040000
-#define   FF0  00000000
-#define   FF1  00040000
-#define BSDLY  00100000
-#define   BS0  00000000
-#define   BS1  00100000
-#define VTDLY  00200000
-#define   VT0  00000000
-#define   VT1  00200000
-
-/* c_cflag bit meaning */
-#define CBAUD  0000377
-#define  B0    0000000         /* hang up */
-#define  B50   0000001
-#define  B75   0000002
-#define  B110  0000003
-#define  B134  0000004
-#define  B150  0000005
-#define  B200  0000006
-#define  B300  0000007
-#define  B600  0000010
-#define  B1200 0000011
-#define  B1800 0000012
-#define  B2400 0000013
-#define  B4800 0000014
-#define  B9600 0000015
-#define  B19200        0000016
-#define  B38400        0000017
-#define EXTA B19200
-#define EXTB B38400
-#define CBAUDEX 0000000
-#define  B57600   00020
-#define  B115200  00021
-#define  B230400  00022
-#define  B460800  00023
-#define  B500000  00024
-#define  B576000  00025
-#define  B921600  00026
-#define B1000000  00027
-#define B1152000  00030
-#define B1500000  00031
-#define B2000000  00032
-#define B2500000  00033
-#define B3000000  00034
-#define B3500000  00035
-#define B4000000  00036
-
-#define CSIZE  00001400
-#define   CS5  00000000
-#define   CS6  00000400
-#define   CS7  00001000
-#define   CS8  00001400
-
-#define CSTOPB 00002000
-#define CREAD  00004000
-#define PARENB 00010000
-#define PARODD 00020000
-#define HUPCL  00040000
-
-#define CLOCAL 00100000
-#define CRTSCTS          020000000000          /* flow control */
-
-/* c_lflag bits */
-#define ISIG   0x00000080
-#define ICANON 0x00000100
-#define XCASE  0x00004000
-#define ECHO   0x00000008
-#define ECHOE  0x00000002
-#define ECHOK  0x00000004
-#define ECHONL 0x00000010
-#define NOFLSH 0x80000000
-#define TOSTOP 0x00400000
-#define ECHOCTL        0x00000040
-#define ECHOPRT        0x00000020
-#define ECHOKE 0x00000001
-#define FLUSHO 0x00800000
-#define PENDIN 0x20000000
-#define IEXTEN 0x00000400
-
-/* Values for the ACTION argument to `tcflow'.  */
-#define        TCOOFF          0
-#define        TCOON           1
-#define        TCIOFF          2
-#define        TCION           3
-
-/* Values for the QUEUE_SELECTOR argument to `tcflush'.  */
-#define        TCIFLUSH        0
-#define        TCOFLUSH        1
-#define        TCIOFLUSH       2
-
-/* Values for the OPTIONAL_ACTIONS argument to `tcsetattr'.  */
-#define        TCSANOW         0
-#define        TCSADRAIN       1
-#define        TCSAFLUSH       2
-
-#endif /* _PPC_TERMBITS_H */
diff --git a/include/asm-ppc/termios.h b/include/asm-ppc/termios.h
deleted file mode 100644 (file)
index 97c6287..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
-#ifndef _PPC_TERMIOS_H
-#define _PPC_TERMIOS_H
-
-/*
- * Liberally adapted from alpha/termios.h.  In particular, the c_cc[]
- * fields have been reordered so that termio & termios share the
- * common subset in the same order (for brain dead programs that don't
- * know or care about the differences).
- */
-
-#include <asm/ioctls.h>
-#include <asm/termbits.h>
-
-struct sgttyb {
-       char    sg_ispeed;
-       char    sg_ospeed;
-       char    sg_erase;
-       char    sg_kill;
-       short   sg_flags;
-};
-
-struct tchars {
-       char    t_intrc;
-       char    t_quitc;
-       char    t_startc;
-       char    t_stopc;
-       char    t_eofc;
-       char    t_brkc;
-};
-
-struct ltchars {
-       char    t_suspc;
-       char    t_dsuspc;
-       char    t_rprntc;
-       char    t_flushc;
-       char    t_werasc;
-       char    t_lnextc;
-};
-
-#define FIOCLEX                _IO('f', 1)
-#define FIONCLEX       _IO('f', 2)
-#define FIOASYNC       _IOW('f', 125, int)
-#define FIONBIO                _IOW('f', 126, int)
-#define FIONREAD       _IOR('f', 127, int)
-#define TIOCINQ                FIONREAD
-#define FIOQSIZE       _IOR('f', 128, loff_t)
-
-#define TIOCGETP       _IOR('t', 8, struct sgttyb)
-#define TIOCSETP       _IOW('t', 9, struct sgttyb)
-#define TIOCSETN       _IOW('t', 10, struct sgttyb)    /* TIOCSETP wo flush */
-
-#define TIOCSETC       _IOW('t', 17, struct tchars)
-#define TIOCGETC       _IOR('t', 18, struct tchars)
-#define TCGETS         _IOR('t', 19, struct termios)
-#define TCSETS         _IOW('t', 20, struct termios)
-#define TCSETSW                _IOW('t', 21, struct termios)
-#define TCSETSF                _IOW('t', 22, struct termios)
-
-#define TCGETA         _IOR('t', 23, struct termio)
-#define TCSETA         _IOW('t', 24, struct termio)
-#define TCSETAW                _IOW('t', 25, struct termio)
-#define TCSETAF                _IOW('t', 28, struct termio)
-
-#define TCSBRK         _IO('t', 29)
-#define TCXONC         _IO('t', 30)
-#define TCFLSH         _IO('t', 31)
-
-#define TIOCSWINSZ     _IOW('t', 103, struct winsize)
-#define TIOCGWINSZ     _IOR('t', 104, struct winsize)
-#define        TIOCSTART       _IO('t', 110)           /* start output, like ^Q */
-#define        TIOCSTOP        _IO('t', 111)           /* stop output, like ^S */
-#define TIOCOUTQ        _IOR('t', 115, int)     /* output queue size */
-
-#define TIOCGLTC       _IOR('t', 116, struct ltchars)
-#define TIOCSLTC       _IOW('t', 117, struct ltchars)
-#define TIOCSPGRP      _IOW('t', 118, int)
-#define TIOCGPGRP      _IOR('t', 119, int)
-
-#define TIOCEXCL       0x540C
-#define TIOCNXCL       0x540D
-#define TIOCSCTTY      0x540E
-
-#define TIOCSTI                0x5412
-#define TIOCMGET       0x5415
-#define TIOCMBIS       0x5416
-#define TIOCMBIC       0x5417
-#define TIOCMSET       0x5418
-#define TIOCGSOFTCAR   0x5419
-#define TIOCSSOFTCAR   0x541A
-#define TIOCLINUX      0x541C
-#define TIOCCONS       0x541D
-#define TIOCGSERIAL    0x541E
-#define TIOCSSERIAL    0x541F
-#define TIOCPKT                0x5420
-
-#define TIOCNOTTY      0x5422
-#define TIOCSETD       0x5423
-#define TIOCGETD       0x5424
-#define TCSBRKP                0x5425  /* Needed for POSIX tcsendbreak() */
-
-#define TIOCSERCONFIG  0x5453
-#define TIOCSERGWILD   0x5454
-#define TIOCSERSWILD   0x5455
-#define TIOCGLCKTRMIOS 0x5456
-#define TIOCSLCKTRMIOS 0x5457
-#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
-#define TIOCSERGETLSR   0x5459 /* Get line status register */
-#define TIOCSERGETMULTI 0x545A /* Get multiport config  */
-#define TIOCSERSETMULTI 0x545B /* Set multiport config */
-
-#define TIOCMIWAIT     0x545C  /* wait for a change on serial input line(s) */
-#define TIOCGICOUNT    0x545D  /* read serial port inline interrupt counts */
-
-/* Used for packet mode */
-#define TIOCPKT_DATA            0
-#define TIOCPKT_FLUSHREAD       1
-#define TIOCPKT_FLUSHWRITE      2
-#define TIOCPKT_STOP            4
-#define TIOCPKT_START           8
-#define TIOCPKT_NOSTOP         16
-#define TIOCPKT_DOSTOP         32
-
-struct winsize {
-       unsigned short ws_row;
-       unsigned short ws_col;
-       unsigned short ws_xpixel;
-       unsigned short ws_ypixel;
-};
-
-#define NCC 10
-struct termio {
-       unsigned short c_iflag;         /* input mode flags */
-       unsigned short c_oflag;         /* output mode flags */
-       unsigned short c_cflag;         /* control mode flags */
-       unsigned short c_lflag;         /* local mode flags */
-       unsigned char c_line;           /* line discipline */
-       unsigned char c_cc[NCC];        /* control characters */
-};
-
-/* c_cc characters */
-#define _VINTR 0
-#define _VQUIT 1
-#define _VERASE        2
-#define _VKILL 3
-#define _VEOF  4
-#define _VMIN  5
-#define _VEOL  6
-#define _VTIME 7
-#define _VEOL2 8
-#define _VSWTC 9
-
-#ifdef __KERNEL__
-/*                   ^C  ^\ del  ^U  ^D   1   0   0   0   0  ^W  ^R  ^Z  ^Q  ^S  ^V  ^U  */
-#define INIT_C_CC "\003\034\177\025\004\001\000\000\000\000\027\022\032\021\023\026\025"
-#endif /* __KERNEL__ */
-
-/* modem lines */
-#define TIOCM_LE       0x001
-#define TIOCM_DTR      0x002
-#define TIOCM_RTS      0x004
-#define TIOCM_ST       0x008
-#define TIOCM_SR       0x010
-#define TIOCM_CTS      0x020
-#define TIOCM_CAR      0x040
-#define TIOCM_RNG      0x080
-#define TIOCM_DSR      0x100
-#define TIOCM_CD       TIOCM_CAR
-#define TIOCM_RI       TIOCM_RNG
-#define TIOCM_OUT1     0x2000
-#define TIOCM_OUT2     0x4000
-#define TIOCM_LOOP     0x8000
-
-/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
-#define TIOCSER_TEMT    0x01   /* Transmitter physically empty */
-
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6       /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IrDa - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14
-#define N_HCI          15  /* Bluetooth HCI UART */
-
-#ifdef __KERNEL__
-
-/*
- * Translate a "termio" structure into a "termios". Ugh.
- */
-#define SET_LOW_TERMIOS_BITS(termios, termio, x) { \
-       unsigned short __tmp; \
-       get_user(__tmp,&(termio)->x); \
-       (termios)->x = (0xffff0000 & (termios)->x) | __tmp; \
-}
-
-#define user_termio_to_kernel_termios(termios, termio) \
-({ \
-       SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \
-       SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \
-       SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \
-       SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \
-       copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
-})
-
-/*
- * Translate a "termios" structure into a "termio". Ugh.
- */
-#define kernel_termios_to_user_termio(termio, termios) \
-({ \
-       put_user((termios)->c_iflag, &(termio)->c_iflag); \
-       put_user((termios)->c_oflag, &(termio)->c_oflag); \
-       put_user((termios)->c_cflag, &(termio)->c_cflag); \
-       put_user((termios)->c_lflag, &(termio)->c_lflag); \
-       put_user((termios)->c_line,  &(termio)->c_line); \
-       copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
-})
-
-#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios))
-#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios))
-
-#endif /* __KERNEL__ */
-
-#endif /* _PPC_TERMIOS_H */
index a787bc0325879dbc6e1bf649fbb6ec8b4867aeea..77dc24d7d2ad1910151cb23d48279e7ef3a6abd0 100644 (file)
@@ -62,8 +62,6 @@ typedef u64 sector_t;
 #define HAVE_SECTOR_T
 #endif
 
-typedef unsigned int kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff --git a/include/asm-ppc64/bugs.h b/include/asm-ppc64/bugs.h
deleted file mode 100644 (file)
index 861074b..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * This file is included by 'init/main.c' to check for architecture-dependent
- * bugs.
- *
- */
-#ifndef _ASM_PPC64_BUGS_H
-#define _ASM_PPC64_BUGS_H
-
-static void check_bugs(void) {
-}
-
-#endif /* _ASM_PPC64_BUGS_H */
index ae6cf3830108c0d59e22a637378e9ed100ddbdb2..acc9b4d6c16846a46d7f0f8120d36819c911e60e 100644 (file)
@@ -36,6 +36,7 @@
  * via the mkdefs mechanism.
  */
 struct cpu_spec;
+struct op_ppc64_model;
 
 typedef        void (*cpu_setup_t)(unsigned long offset, struct cpu_spec* spec);
 
@@ -52,10 +53,19 @@ struct cpu_spec {
        unsigned int    icache_bsize;
        unsigned int    dcache_bsize;
 
+       /* number of performance monitor counters */
+       unsigned int    num_pmcs;
+
        /* this is called to initialize various CPU bits like L1 cache,
         * BHT, SPD, etc... from head.S before branching to identify_machine
         */
        cpu_setup_t     cpu_setup;
+
+       /* Used by oprofile userspace to select the right counters */
+       char            *oprofile_cpu_type;
+
+       /* Processor specific oprofile operations */
+       struct op_ppc64_model *oprofile_model;
 };
 
 extern struct cpu_spec         cpu_specs[];
@@ -95,7 +105,7 @@ static inline unsigned long cpu_has_feature(unsigned long feature)
 #define CPU_FTR_NODSISRALIGN           ASM_CONST(0x0000001000000000)
 #define CPU_FTR_IABR                   ASM_CONST(0x0000002000000000)
 #define CPU_FTR_MMCRA                          ASM_CONST(0x0000004000000000)
-#define CPU_FTR_PMC8                   ASM_CONST(0x0000008000000000)
+/* unused                              ASM_CONST(0x0000008000000000) */
 #define CPU_FTR_SMT                    ASM_CONST(0x0000010000000000)
 #define CPU_FTR_COHERENT_ICACHE        ASM_CONST(0x0000020000000000)
 #define CPU_FTR_LOCKLESS_TLBIE         ASM_CONST(0x0000040000000000)
index cb368bf0f264306decc6b7e00618a6bfb5f52174..de91e034bd986e8d7da853aa28ca752a41b878b8 100644 (file)
@@ -56,4 +56,26 @@ extern void lmb_dump_all(void);
 
 extern unsigned long io_hole_start;
 
+static inline unsigned long
+lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
+{
+       return type->region[region_nr].size;
+}
+static inline unsigned long
+lmb_size_pages(struct lmb_region *type, unsigned long region_nr)
+{
+       return lmb_size_bytes(type, region_nr) >> PAGE_SHIFT;
+}
+static inline unsigned long
+lmb_start_pfn(struct lmb_region *type, unsigned long region_nr)
+{
+       return type->region[region_nr].base >> PAGE_SHIFT;
+}
+static inline unsigned long
+lmb_end_pfn(struct lmb_region *type, unsigned long region_nr)
+{
+       return lmb_start_pfn(type, region_nr) +
+              lmb_size_pages(type, region_nr);
+}
+
 #endif /* _PPC64_LMB_H */
index 70766b5f26c1a91db3ae19bf60c5f0f4028a2c6a..9e2a6c0649a025467dc8c139e6a07ccb8154be1a 100644 (file)
@@ -108,7 +108,7 @@ struct lppaca
        volatile u32 virtual_decr;      // Virtual DECR for shared procsx78-x7B
        u16     slb_count;              // # of SLBs to maintain        x7C-x7D
        u8      idle;                   // Indicate OS is idle          x7E
-       u8      reserved5;              // Reserved                     x7F
+       u8      vmxregs_in_use;         // VMX registers in use         x7F
 
 
 //=============================================================================
index ff2c9287d3b6bda6ea9cc5a01d35a5ee02f63e5c..9a1ef4427ed2dfa0b2923f99ef2f8c4098cf4011 100644 (file)
@@ -103,11 +103,6 @@ struct machdep_calls {
 
        void            (*progress)(char *, unsigned short);
 
-       /* Debug interface.  Low level I/O to some terminal device */
-       void            (*udbg_putc)(unsigned char c);
-       unsigned char   (*udbg_getc)(void);
-       int             (*udbg_getc_poll)(void);
-
        /* Interface for platform error logging */
        void            (*log_error)(char *buf, unsigned int err_type, int fatal);
 
index ad36bb28de2983c92750a8072195b34cc5db4c5f..7bc42eb087adb777df01b69350ada386055c97a7 100644 (file)
@@ -54,8 +54,10 @@ extern char initial_stab[];
 #define SLB_VSID_C             ASM_CONST(0x0000000000000080) /* class */
 #define SLB_VSID_LS            ASM_CONST(0x0000000000000070) /* size of largepage */
  
-#define SLB_VSID_KERNEL                (SLB_VSID_KP|SLB_VSID_C)
-#define SLB_VSID_USER          (SLB_VSID_KP|SLB_VSID_KS)
+#define SLB_VSID_KERNEL                (SLB_VSID_KP)
+#define SLB_VSID_USER          (SLB_VSID_KP|SLB_VSID_KS|SLB_VSID_C)
+
+#define SLBIE_C                        (0x08000000)
 
 /*
  * Hash table
diff --git a/include/asm-ppc64/module.h b/include/asm-ppc64/module.h
deleted file mode 100644 (file)
index 0581607..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef _ASM_PPC64_MODULE_H
-#define _ASM_PPC64_MODULE_H
-
-#include <linux/list.h>
-#include <asm/bug.h>
-
-struct mod_arch_specific
-{
-       /* Index of stubs section within module. */
-       unsigned int stubs_section;
-
-       /* What section is the TOC? */
-       unsigned int toc_section;
-
-       /* List of BUG addresses, source line numbers and filenames */
-       struct list_head bug_list;
-       struct bug_entry *bug_table;
-       unsigned int num_bugs;
-};
-
-extern struct bug_entry *module_find_bug(unsigned long bugaddr);
-
-#define Elf_Shdr Elf64_Shdr
-#define Elf_Sym Elf64_Sym
-#define Elf_Ehdr Elf64_Ehdr
-
-/* Make empty section for module_frob_arch_sections to expand. */
-#ifdef MODULE
-asm(".section .stubs,\"ax\",@nobits; .align 3; .previous");
-#endif
-
-struct exception_table_entry;
-void sort_ex_table(struct exception_table_entry *start,
-                       struct exception_table_entry *finish);
-
-#endif /* _ASM_PPC64_MODULE_H */
similarity index 95%
rename from arch/ppc64/oprofile/op_impl.h
rename to include/asm-ppc64/oprofile_impl.h
index 7fa7eaabc035113452be4e1efcf08bd9b2558cda..b04f1dfb14219a9ac96a392db582bd22eecf9b69 100644 (file)
@@ -49,6 +49,9 @@ struct op_ppc64_model {
        int num_counters;
 };
 
+extern struct op_ppc64_model op_model_rs64;
+extern struct op_ppc64_model op_model_power4;
+
 static inline unsigned int ctr_read(unsigned int i)
 {
        switch(i) {
index a79a08df62bd8c89740c5a3a4db6a6ad29d54519..a15422bcf30d2c054b3cc915feb9d025d0b592cc 100644 (file)
@@ -172,20 +172,6 @@ typedef unsigned long pgprot_t;
 
 #endif
 
-/* Pure 2^n version of get_order */
-static inline int get_order(unsigned long size)
-{
-       int order;
-
-       size = (size-1) >> (PAGE_SHIFT-1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-       return order;
-}
-
 #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
 
 extern int page_is_ram(unsigned long pfn);
@@ -270,4 +256,7 @@ extern u64 ppc64_pft_size;          /* Log 2 of page table size */
         VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
 
 #endif /* __KERNEL__ */
+
+#include <asm-generic/page.h>
+
 #endif /* _PPC64_PAGE_H */
index b9e1835351e98d7874f1c9f06cc7a4fccc3f4904..c0396428cc3c0c908bb723c111adff2a1d44ebac 100644 (file)
@@ -158,7 +158,7 @@ static inline int __is_processor(unsigned long pv)
  * is more like most of the other architectures.
  */
 static __inline__ unsigned long
-__xchg_u32(volatile int *m, unsigned long val)
+__xchg_u32(volatile unsigned int *m, unsigned long val)
 {
        unsigned long dummy;
 
@@ -200,7 +200,7 @@ __xchg_u64(volatile long *m, unsigned long val)
 extern void __xchg_called_with_bad_pointer(void);
 
 static __inline__ unsigned long
-__xchg(volatile void *ptr, unsigned long x, int size)
+__xchg(volatile void *ptr, unsigned long x, unsigned int size)
 {
        switch (size) {
        case 4:
@@ -223,7 +223,7 @@ __xchg(volatile void *ptr, unsigned long x, int size)
 #define __HAVE_ARCH_CMPXCHG    1
 
 static __inline__ unsigned long
-__cmpxchg_u32(volatile int *p, int old, int new)
+__cmpxchg_u32(volatile unsigned int *p, unsigned long old, unsigned long new)
 {
        unsigned int prev;
 
@@ -271,7 +271,8 @@ __cmpxchg_u64(volatile long *p, unsigned long old, unsigned long new)
 extern void __cmpxchg_called_with_bad_pointer(void);
 
 static __inline__ unsigned long
-__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
+__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new,
+         unsigned int size)
 {
        switch (size) {
        case 4:
@@ -283,13 +284,9 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
        return old;
 }
 
-#define cmpxchg(ptr,o,n)                                                \
-  ({                                                                    \
-     __typeof__(*(ptr)) _o_ = (o);                                      \
-     __typeof__(*(ptr)) _n_ = (n);                                      \
-     (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_,          \
-                                   (unsigned long)_n_, sizeof(*(ptr))); \
-  })
+#define cmpxchg(ptr,o,n)\
+       ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\
+       (unsigned long)(n),sizeof(*(ptr))))
 
 /*
  * We handle most unaligned accesses in hardware. On the other hand 
index 5b8c2cfa11382248105b00937eec2d245411ac3c..bf294c1761b235817eeaad8a97c75311ac11b371 100644 (file)
@@ -72,7 +72,6 @@ typedef struct {
        unsigned long env;
 } func_descr_t;
 
-typedef unsigned int kmem_bufctl_t;
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
index a6e04d014b2b6bf9cdac8d7fd7e34dfc302b637f..c786604aef02efcc28319c71f1ffe9fc7ab00ce7 100644 (file)
@@ -2,6 +2,7 @@
 #define __UDBG_HDR
 
 #include <linux/compiler.h>
+#include <linux/init.h>
 
 /*
  * c 2001 PPC 64 Team, IBM Corp
  * 2 of the License, or (at your option) any later version.
  */
 
-void udbg_init_uart(void __iomem *comport, unsigned int speed);
-void udbg_putc(unsigned char c);
-unsigned char udbg_getc(void);
-int udbg_getc_poll(void);
-void udbg_puts(const char *s);
-int udbg_write(const char *s, int n);
-int udbg_read(char *buf, int buflen);
-struct console;
-void udbg_console_write(struct console *con, const char *s, unsigned int n);
-void udbg_printf(const char *fmt, ...);
-void udbg_ppcdbg(unsigned long flags, const char *fmt, ...);
-unsigned long udbg_ifdebug(unsigned long flags);
+extern void (*udbg_putc)(unsigned char c);
+extern unsigned char (*udbg_getc)(void);
+extern int (*udbg_getc_poll)(void);
 
+extern void udbg_puts(const char *s);
+extern int udbg_write(const char *s, int n);
+extern int udbg_read(char *buf, int buflen);
+
+extern void register_early_udbg_console(void);
+extern void udbg_printf(const char *fmt, ...);
+extern void udbg_ppcdbg(unsigned long flags, const char *fmt, ...);
+extern unsigned long udbg_ifdebug(unsigned long flags);
+extern void __init ppcdbg_initialize(void);
+
+extern void udbg_init_uart(void __iomem *comport, unsigned int speed);
 #endif
index 92360d90144bc698618f1dbf09da1dae22a202d7..7127030ae162c1253380fe01b114ea3ccf595d47 100644 (file)
@@ -52,8 +52,6 @@ struct __debug_entry{
 #define DEBUG_DATA(entry) (char*)(entry + 1) /* data is stored behind */
                                              /* the entry information */
 
-#define STCK(x)        asm volatile ("STCK 0(%1)" : "=m" (x) : "a" (&(x)) : "cc")
-
 typedef struct __debug_entry debug_entry_t;
 
 struct debug_view;
index afe6a9f9b0aed53f454ca8f5c65e278cfe40d4f9..c6f51c9ce3ffb89daa43903f0a6f00b9a23574d5 100644 (file)
@@ -68,6 +68,7 @@
 #define __LC_SYSTEM_TIMER              0x270
 #define __LC_LAST_UPDATE_CLOCK         0x278
 #define __LC_STEAL_CLOCK               0x280
+#define __LC_RETURN_MCCK_PSW            0x288
 #define __LC_KERNEL_STACK               0xC40
 #define __LC_THREAD_INFO               0xC44
 #define __LC_ASYNC_STACK                0xC48
@@ -90,6 +91,7 @@
 #define __LC_SYSTEM_TIMER              0x278
 #define __LC_LAST_UPDATE_CLOCK         0x280
 #define __LC_STEAL_CLOCK               0x288
+#define __LC_RETURN_MCCK_PSW            0x290
 #define __LC_KERNEL_STACK               0xD40
 #define __LC_THREAD_INFO               0xD48
 #define __LC_ASYNC_STACK                0xD50
@@ -196,7 +198,8 @@ struct _lowcore
        __u64        system_timer;             /* 0x270 */
        __u64        last_update_clock;        /* 0x278 */
        __u64        steal_clock;              /* 0x280 */
-       __u8         pad8[0xc00-0x288];        /* 0x288 */
+        psw_t        return_mcck_psw;          /* 0x288 */
+       __u8         pad8[0xc00-0x290];        /* 0x290 */
 
         /* System info area */
        __u32        save_area[16];            /* 0xc00 */
@@ -285,7 +288,8 @@ struct _lowcore
        __u64        system_timer;             /* 0x278 */
        __u64        last_update_clock;        /* 0x280 */
        __u64        steal_clock;              /* 0x288 */
-        __u8         pad8[0xc00-0x290];        /* 0x290 */
+        psw_t        return_mcck_psw;          /* 0x290 */
+        __u8         pad8[0xc00-0x2a0];        /* 0x2a0 */
         /* System info area */
        __u64        save_area[16];            /* 0xc00 */
         __u8         pad9[0xd40-0xc80];        /* 0xc80 */
index 2be287b9df8822a0ca072e188c74fd9d84390f65..2430c561e021fe781951b5e51ea548a34567fff9 100644 (file)
@@ -111,20 +111,6 @@ static inline void copy_page(void *to, void *from)
 #define alloc_zeroed_user_highpage(vma, vaddr) alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO, vma, vaddr)
 #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
 
-/* Pure 2^n version of get_order */
-extern __inline__ int get_order(unsigned long size)
-{
-        int order;
-
-        size = (size-1) >> (PAGE_SHIFT-1);
-        order = -1;
-        do {
-                size >>= 1;
-                order++;
-        } while (size);
-        return order;
-}
-
 /*
  * These are used to make use of C type-checking..
  */
@@ -207,4 +193,6 @@ page_get_storage_key(unsigned long addr)
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _S390_PAGE_H */
index 8ff10300f7ee7afbf69f2ada83d387846aa60187..321b23bba1ecf16987b724e45f79319f55972159 100644 (file)
@@ -47,7 +47,7 @@ extern int _raw_spin_trylock_retry(spinlock_t *lp, unsigned int pc);
 
 static inline void _raw_spin_lock(spinlock_t *lp)
 {
-       unsigned long pc = (unsigned long) __builtin_return_address(0);
+       unsigned long pc = 1 | (unsigned long) __builtin_return_address(0);
 
        if (unlikely(_raw_compare_and_swap(&lp->lock, 0, pc) != 0))
                _raw_spin_lock_wait(lp, pc);
@@ -55,7 +55,7 @@ static inline void _raw_spin_lock(spinlock_t *lp)
 
 static inline int _raw_spin_trylock(spinlock_t *lp)
 {
-       unsigned long pc = (unsigned long) __builtin_return_address(0);
+       unsigned long pc = 1 | (unsigned long) __builtin_return_address(0);
 
        if (likely(_raw_compare_and_swap(&lp->lock, 0, pc) == 0))
                return 1;
index 3fefd61416a515e2459cd3b39edf2079cf682137..d0be3e477013de865a513c84096753eb9b1e6bfb 100644 (file)
@@ -79,8 +79,6 @@ typedef unsigned  long u64;
 
 typedef u32 dma_addr_t;
 
-typedef unsigned int kmem_bufctl_t;
-
 #ifndef __s390x__
 typedef union {
        unsigned long long pair;
index 180467be8e7bb84c7f4f41397697bfc503b2ef98..324e6cc5ecf71c90d66fa90fe459e944791f6c86 100644 (file)
@@ -122,24 +122,8 @@ typedef struct { unsigned long pgprot; } pgprot_t;
 #define VM_DATA_DEFAULT_FLAGS  (VM_READ | VM_WRITE | VM_EXEC | \
                                 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
-#ifndef __ASSEMBLY__
-
-/* Pure 2^n version of get_order */
-static __inline__ int get_order(unsigned long size)
-{
-       int order;
-
-       size = (size-1) >> (PAGE_SHIFT-1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-       return order;
-}
-
-#endif
-
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* __ASM_SH_PAGE_H */
index c4dc126c56211cac02e2b92c06b4151cc555bf73..cb7e183a0a6beabbec8b1b0dd14d3fd53886caaa 100644 (file)
@@ -58,8 +58,6 @@ typedef u64 sector_t;
 #define HAVE_SECTOR_T
 #endif
 
-typedef unsigned int kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
index d6167f1c0e99ef10f86877259441bfb7c5e4e908..c86df90f7cbd879b0f5d63c5831b40a789a898a4 100644 (file)
@@ -115,24 +115,8 @@ typedef struct { unsigned long pgprot; } pgprot_t;
 #define VM_DATA_DEFAULT_FLAGS  (VM_READ | VM_WRITE | VM_EXEC | \
                                 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
-#ifndef __ASSEMBLY__
-
-/* Pure 2^n version of get_order */
-extern __inline__ int get_order(unsigned long size)
-{
-       int order;
-
-       size = (size-1) >> (PAGE_SHIFT-1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-       return order;
-}
-
-#endif
-
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* __ASM_SH64_PAGE_H */
index 41d4d2f82aa99dbf51f8af1438f1009964f2ba90..8d41db2153b599bcd618a47bff5726bd9d7828bd 100644 (file)
@@ -65,8 +65,6 @@ typedef u32 dma_addr_t;
 #endif
 typedef u64 dma64_addr_t;
 
-typedef unsigned int kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #define BITS_PER_LONG 32
index 383060e90d947793eefb85af52c442e3b3025410..9122684f6c1eb172e7abe440df50b2b2cae054a1 100644 (file)
@@ -132,20 +132,6 @@ BTFIXUPDEF_SETHI(sparc_unmapped_base)
 
 #define TASK_UNMAPPED_BASE     BTFIXUP_SETHI(sparc_unmapped_base)
 
-/* Pure 2^n version of get_order */
-extern __inline__ int get_order(unsigned long size)
-{
-       int order;
-
-       size = (size-1) >> (PAGE_SHIFT-1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-       return order;
-}
-
 #else /* !(__ASSEMBLY__) */
 
 #define __pgprot(x)    (x)
@@ -178,4 +164,6 @@ extern unsigned long pfn_base;
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _SPARC_PAGE_H */
index 40ed30a2b7c6f9f876d4c9a5de094bfdf6bef093..8f4f6a95965130820e03f46e22cfe795721bbfcb 100644 (file)
@@ -435,9 +435,6 @@ extern unsigned long *sparc_valid_addr_bitmap;
 #define kern_addr_valid(addr) \
        (test_bit(__pa((unsigned long)(addr))>>20, sparc_valid_addr_bitmap))
 
-extern int io_remap_page_range(struct vm_area_struct *vma,
-                              unsigned long from, unsigned long to,
-                              unsigned long size, pgprot_t prot, int space);
 extern int io_remap_pfn_range(struct vm_area_struct *vma,
                              unsigned long from, unsigned long pfn,
                              unsigned long size, pgprot_t prot);
index 9eabf6e61ccca66753b3ab213735f6cee7900402..42fc6ed9815690e563fceb6ca1590df9e86f5df4 100644 (file)
@@ -54,8 +54,6 @@ typedef unsigned long long u64;
 typedef u32 dma_addr_t;
 typedef u32 dma64_addr_t;
 
-typedef unsigned short kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
index cc7198aaac505ee25072d5ac26da06df233aef82..9a3a81f1cc58ab7ba06c7e4290fc851a44ed570c 100644 (file)
@@ -1,6 +1,6 @@
 /* cpudata.h: Per-cpu parameters.
  *
- * Copyright (C) 2003 David S. Miller (davem@redhat.com)
+ * Copyright (C) 2003, 2005 David S. Miller (davem@redhat.com)
  */
 
 #ifndef _SPARC64_CPUDATA_H
@@ -10,7 +10,7 @@
 
 typedef struct {
        /* Dcache line 1 */
-       unsigned int    __pad0;         /* bh_count moved to irq_stat for consistency. KAO */
+       unsigned int    __softirq_pending; /* must be 1st, see rtrap.S */
        unsigned int    multiplier;
        unsigned int    counter;
        unsigned int    idle_volume;
index d6db1aed7645d0504b75476536d52010a8843e2f..f0cf71376ec5b11436220f73b06ae1c329cee559 100644 (file)
@@ -1,22 +1,16 @@
 /* hardirq.h: 64-bit Sparc hard IRQ support.
  *
- * Copyright (C) 1997, 1998 David S. Miller (davem@caip.rutgers.edu)
+ * Copyright (C) 1997, 1998, 2005 David S. Miller (davem@davemloft.net)
  */
 
 #ifndef __SPARC64_HARDIRQ_H
 #define __SPARC64_HARDIRQ_H
 
-#include <linux/config.h>
-#include <linux/threads.h>
-#include <linux/spinlock.h>
-#include <linux/cache.h>
+#include <asm/cpudata.h>
 
-/* rtrap.S is sensitive to the offsets of these fields */
-typedef struct {
-       unsigned int __softirq_pending;
-} ____cacheline_aligned irq_cpustat_t;
-
-#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
+#define __ARCH_IRQ_STAT
+#define local_softirq_pending() \
+       (local_cpu_data().__softirq_pending)
 
 #define HARDIRQ_BITS   8
 
index afdcea90707a7a54f004d8e519877e2dab77d3db..0056770e83ada176fc091dba50be956dcaf7841f 100644 (file)
@@ -100,18 +100,41 @@ static __inline__ void _outl(u32 l, unsigned long addr)
 #define inl_p(__addr)          inl(__addr)
 #define outl_p(__l, __addr)    outl(__l, __addr)
 
-extern void outsb(void __iomem *addr, const void *src, unsigned long count);
-extern void outsw(void __iomem *addr, const void *src, unsigned long count);
-extern void outsl(void __iomem *addr, const void *src, unsigned long count);
-extern void insb(void __iomem *addr, void *dst, unsigned long count);
-extern void insw(void __iomem *addr, void *dst, unsigned long count);
-extern void insl(void __iomem *addr, void *dst, unsigned long count);
-#define ioread8_rep(a,d,c)     insb(a,d,c)
-#define ioread16_rep(a,d,c)    insw(a,d,c)
-#define ioread32_rep(a,d,c)    insl(a,d,c)
-#define iowrite8_rep(a,s,c)    outsb(a,s,c)
-#define iowrite16_rep(a,s,c)   outsw(a,s,c)
-#define iowrite32_rep(a,s,c)   outsl(a,s,c)
+extern void outsb(unsigned long, const void *, unsigned long);
+extern void outsw(unsigned long, const void *, unsigned long);
+extern void outsl(unsigned long, const void *, unsigned long);
+extern void insb(unsigned long, void *, unsigned long);
+extern void insw(unsigned long, void *, unsigned long);
+extern void insl(unsigned long, void *, unsigned long);
+
+static inline void ioread8_rep(void __iomem *port, void *buf, unsigned long count)
+{
+       insb((unsigned long __force)port, buf, count);
+}
+static inline void ioread16_rep(void __iomem *port, void *buf, unsigned long count)
+{
+       insw((unsigned long __force)port, buf, count);
+}
+
+static inline void ioread32_rep(void __iomem *port, void *buf, unsigned long count)
+{
+       insl((unsigned long __force)port, buf, count);
+}
+
+static inline void iowrite8_rep(void __iomem *port, const void *buf, unsigned long count)
+{
+       outsb((unsigned long __force)port, buf, count);
+}
+
+static inline void iowrite16_rep(void __iomem *port, const void *buf, unsigned long count)
+{
+       outsw((unsigned long __force)port, buf, count);
+}
+
+static inline void iowrite32_rep(void __iomem *port, const void *buf, unsigned long count)
+{
+       outsl((unsigned long __force)port, buf, count);
+}
 
 /* Memory functions, same as I/O accesses on Ultra. */
 static inline u8 _readb(const volatile void __iomem *addr)
index b87dbbd64bc9ca723e3077521cb5cd87af63906e..c9f8ef208ea52529aea888637e7bc8014df6f975 100644 (file)
@@ -150,20 +150,6 @@ struct sparc_phys_banks {
 
 extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS];
 
-/* Pure 2^n version of get_order */
-static __inline__ int get_order(unsigned long size)
-{
-       int order;
-
-       size = (size-1) >> (PAGE_SHIFT-1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-       return order;
-}
-
 #endif /* !(__ASSEMBLY__) */
 
 #define VM_DATA_DEFAULT_FLAGS  (VM_READ | VM_WRITE | VM_EXEC | \
@@ -171,4 +157,6 @@ static __inline__ int get_order(unsigned long size)
 
 #endif /* !(__KERNEL__) */
 
+#include <asm-generic/page.h>
+
 #endif /* !(_SPARC64_PAGE_H) */
index 1ae00c5087f10d6eb3a0c2ea8c6ade9ff304774b..a2b4f5ed46256c69ffd6597e7bc37b9c1ceb603a 100644 (file)
@@ -410,9 +410,6 @@ extern unsigned long *sparc64_valid_addr_bitmap;
 #define kern_addr_valid(addr)  \
        (test_bit(__pa((unsigned long)(addr))>>22, sparc64_valid_addr_bitmap))
 
-extern int io_remap_page_range(struct vm_area_struct *vma, unsigned long from,
-                              unsigned long offset,
-                              unsigned long size, pgprot_t prot, int space);
 extern int io_remap_pfn_range(struct vm_area_struct *vma, unsigned long from,
                               unsigned long pfn,
                               unsigned long size, pgprot_t prot);
index 6248ed1a9a7a7be2f5822e58d9dce7c75b41a152..d0ee7f105838abadfb8b47504a6d0033d49347b8 100644 (file)
@@ -56,8 +56,6 @@ typedef unsigned long u64;
 typedef u32 dma_addr_t;
 typedef u64 dma64_addr_t;
 
-typedef unsigned short kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
index 095bb627b96a1d52be4cc1291f48c308449f65a1..2edb4f1f789cdb96e0208da409622db6f1eaa70b 100644 (file)
@@ -20,7 +20,15 @@ extern void force_flush_all(void);
 
 static inline void activate_mm(struct mm_struct *old, struct mm_struct *new)
 {
-       if (old != new)
+       /*
+        * This is called by fs/exec.c and fs/aio.c. In the first case, for an
+        * exec, we don't need to do anything as we're called from userspace
+        * and thus going to use a new host PID. In the second, we're called
+        * from a kernel thread, and thus need to go doing the mmap's on the
+        * host. Since they're very expensive, we want to avoid that as far as
+        * possible.
+        */
+       if (old != new && (current->flags & PF_BORROWED_MM))
                force_flush_all();
 }
 
index f58aedadeb4e3d88e222dcfeccfc7745a3cba5d4..bd850a249183d21399465a5b4a612c1f4b56d715 100644 (file)
@@ -116,24 +116,12 @@ extern void *to_virt(unsigned long phys);
 #define pfn_valid(pfn) ((pfn) < max_mapnr)
 #define virt_addr_valid(v) pfn_valid(phys_to_pfn(__pa(v)))
 
-/* Pure 2^n version of get_order */
-static __inline__ int get_order(unsigned long size)
-{
-       int order;
-
-       size = (size-1) >> (PAGE_SHIFT-1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-       return order;
-}
-
 extern struct page *arch_validate(struct page *page, int mask, int order);
 #define HAVE_ARCH_VALIDATE
 
 extern void arch_free_page(struct page *page, int order);
 #define HAVE_ARCH_FREE_PAGE
 
+#include <asm-generic/page.h>
+
 #endif
index 8fcb2fc0a8920ddd54ea2cd90135b1f3ca0994a0..ea49411236dcf71334dc4dafbb152d33e720e6cc 100644 (file)
@@ -42,11 +42,13 @@ static inline void pte_free(struct page *pte)
 #define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
 
 #ifdef CONFIG_3_LEVEL_PGTABLES
-/*
- * In the 3-level case we free the pmds as part of the pgd.
- */
-#define pmd_free(x)                    do { } while (0)
-#define __pmd_free_tlb(tlb,x)          do { } while (0)
+
+extern __inline__ void pmd_free(pmd_t *pmd)
+{
+       free_page((unsigned long)pmd);
+}
+
+#define __pmd_free_tlb(tlb,x)   tlb_remove_page((tlb),virt_to_page(x))
 #endif
 
 #define check_pgt_cache()      do { } while (0)
index 9b3abc01d60e108e1304453f6c2205e90ec16d1d..ffe017f6b64b587f3863e3f3b5c70aec3e714744 100644 (file)
 static inline int pgd_newpage(pgd_t pgd)       { return 0; }
 static inline void pgd_mkuptodate(pgd_t pgd)   { }
 
-#define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE))
-
-static inline pte_t pte_mknewprot(pte_t pte)
-{
-       pte_val(pte) |= _PAGE_NEWPROT;
-       return(pte);
-}
-
-static inline pte_t pte_mknewpage(pte_t pte)
-{
-       pte_val(pte) |= _PAGE_NEWPAGE;
-       return(pte);
-}
-
-static inline void set_pte(pte_t *pteptr, pte_t pteval)
-{
-       /* If it's a swap entry, it needs to be marked _PAGE_NEWPAGE so
-        * fix_range knows to unmap it.  _PAGE_NEWPROT is specific to
-        * mapped pages.
-        */
-       *pteptr = pte_mknewpage(pteval);
-       if(pte_present(*pteptr)) *pteptr = pte_mknewprot(*pteptr);
-}
-#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
-
 #define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval))
 
-#define pte_page(x) pfn_to_page(pte_pfn(x))
-#define pte_none(x) !(pte_val(x) & ~_PAGE_NEWPAGE)
 #define pte_pfn(x) phys_to_pfn(pte_val(x))
 #define pfn_pte(pfn, prot) __pte(pfn_to_phys(pfn) | pgprot_val(prot))
 #define pfn_pmd(pfn, prot) __pmd(pfn_to_phys(pfn) | pgprot_val(prot))
index 65e8bfc55fc415440e8021650b2b8fd39ecc87b1..786c2572728996879e7795fdf49d09bab7584802 100644 (file)
@@ -57,35 +57,6 @@ static inline int pgd_newpage(pgd_t pgd)
 
 static inline void pgd_mkuptodate(pgd_t pgd) { pgd_val(pgd) &= ~_PAGE_NEWPAGE; }
 
-
-#define pte_present(x) pte_get_bits(x, (_PAGE_PRESENT | _PAGE_PROTNONE))
-
-static inline pte_t pte_mknewprot(pte_t pte)
-{
-        pte_set_bits(pte, _PAGE_NEWPROT);
-       return(pte);
-}
-
-static inline pte_t pte_mknewpage(pte_t pte)
-{
-       pte_set_bits(pte, _PAGE_NEWPAGE);
-       return(pte);
-}
-
-static inline void set_pte(pte_t *pteptr, pte_t pteval)
-{
-       pte_copy(*pteptr, pteval);
-
-       /* If it's a swap entry, it needs to be marked _PAGE_NEWPAGE so
-        * fix_range knows to unmap it.  _PAGE_NEWPROT is specific to
-        * mapped pages.
-        */
-
-       *pteptr = pte_mknewpage(*pteptr);
-       if(pte_present(*pteptr)) *pteptr = pte_mknewprot(*pteptr);
-}
-#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
-
 #define set_pmd(pmdptr, pmdval) set_64bit((phys_t *) (pmdptr), pmd_val(pmdval))
 
 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
@@ -98,14 +69,11 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
         return pmd;
 }
 
-static inline void pmd_free(pmd_t *pmd){
-       free_page((unsigned long) pmd);
+extern inline void pud_clear (pud_t *pud)
+{
+        set_pud(pud, __pud(0));
 }
 
-#define __pmd_free_tlb(tlb,x)   do { } while (0)
-
-static inline void pud_clear (pud_t * pud) { }
-
 #define pud_page(pud) \
        ((struct page *) __va(pud_val(pud) & PAGE_MASK))
 
@@ -113,13 +81,6 @@ static inline void pud_clear (pud_t * pud) { }
 #define pmd_offset(pud, address) ((pmd_t *) pud_page(*(pud)) + \
                        pmd_index(address))
 
-#define pte_page(x) pfn_to_page(pte_pfn(x))
-
-static inline int pte_none(pte_t pte)
-{
-       return pte_is_zero(pte);
-}
-
 static inline unsigned long pte_pfn(pte_t pte)
 {
        return phys_to_pfn(pte_val(pte));
index a88040920311e7e7333d65e3610fe574b8ce4259..b48e0966ecd7b8b936a4be2a3e8cf06d9645edec 100644 (file)
 
 #define _PAGE_PRESENT  0x001
 #define _PAGE_NEWPAGE  0x002
-#define _PAGE_NEWPROT   0x004
-#define _PAGE_FILE     0x008   /* set:pagecache unset:swap */
-#define _PAGE_PROTNONE 0x010   /* If not present */
+#define _PAGE_NEWPROT  0x004
 #define _PAGE_RW       0x020
 #define _PAGE_USER     0x040
 #define _PAGE_ACCESSED 0x080
 #define _PAGE_DIRTY    0x100
+/* If _PAGE_PRESENT is clear, we use these: */
+#define _PAGE_FILE     0x008   /* nonlinear file mapping, saved PTE; unset:swap */
+#define _PAGE_PROTNONE 0x010   /* if the user mapped it with PROT_NONE;
+                                  pte_present gives true */
 
 #ifdef CONFIG_3_LEVEL_PGTABLES
 #include "asm/pgtable-3level.h"
@@ -151,10 +153,24 @@ extern unsigned long pg0[1024];
 
 #define pmd_page(pmd) phys_to_page(pmd_val(pmd) & PAGE_MASK)
 
+#define pte_page(x) pfn_to_page(pte_pfn(x))
 #define pte_address(x) (__va(pte_val(x) & PAGE_MASK))
 #define mk_phys(a, r) ((a) + (((unsigned long) r) << REGION_SHIFT))
 #define phys_addr(p) ((p) & ~REGION_MASK)
 
+#define pte_present(x) pte_get_bits(x, (_PAGE_PRESENT | _PAGE_PROTNONE))
+
+/*
+ * =================================
+ * Flags checking section.
+ * =================================
+ */
+
+static inline int pte_none(pte_t pte)
+{
+       return pte_is_zero(pte);
+}
+
 /*
  * The following only work if pte_present() is true.
  * Undefined behaviour if not..
@@ -210,6 +226,18 @@ static inline int pte_newprot(pte_t pte)
        return(pte_present(pte) && (pte_get_bits(pte, _PAGE_NEWPROT)));
 }
 
+/*
+ * =================================
+ * Flags setting section.
+ * =================================
+ */
+
+static inline pte_t pte_mknewprot(pte_t pte)
+{
+       pte_set_bits(pte, _PAGE_NEWPROT);
+       return(pte);
+}
+
 static inline pte_t pte_rdprotect(pte_t pte)
 { 
        pte_clear_bits(pte, _PAGE_USER);
@@ -278,6 +306,26 @@ static inline pte_t pte_mkuptodate(pte_t pte)
        return(pte); 
 }
 
+static inline pte_t pte_mknewpage(pte_t pte)
+{
+       pte_set_bits(pte, _PAGE_NEWPAGE);
+       return(pte);
+}
+
+static inline void set_pte(pte_t *pteptr, pte_t pteval)
+{
+       pte_copy(*pteptr, pteval);
+
+       /* If it's a swap entry, it needs to be marked _PAGE_NEWPAGE so
+        * fix_range knows to unmap it.  _PAGE_NEWPROT is specific to
+        * mapped pages.
+        */
+
+       *pteptr = pte_mknewpage(*pteptr);
+       if(pte_present(*pteptr)) *pteptr = pte_mknewprot(*pteptr);
+}
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
+
 extern phys_t page_to_phys(struct page *page);
 
 /*
index d6091622935d101df33649bbde47b6a28f7b40da..b4bc85e7b91a1440b0aafe6fc40d055a94498b8a 100644 (file)
@@ -98,25 +98,6 @@ typedef unsigned long pgprot_t;
 #define PAGE_ALIGN(addr)       (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
 
 
-#ifndef __ASSEMBLY__
-
-/* Pure 2^n version of get_order */
-extern __inline__ int get_order (unsigned long size)
-{
-       int order;
-
-       size = (size-1) >> (PAGE_SHIFT-1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-       return order;
-}
-
-#endif /* !__ASSEMBLY__ */
-
-
 /* No current v850 processor has virtual memory.  */
 #define __virt_to_phys(addr)   (addr)
 #define __phys_to_virt(addr)   (addr)
@@ -144,4 +125,6 @@ extern __inline__ int get_order (unsigned long size)
 
 #endif /* KERNEL */
 
+#include <asm-generic/page.h>
+
 #endif /* __V850_PAGE_H__ */
index e7cfe5b33a103252e4f641eb2b9a80813a6bcae8..dcef5719687501bc39ceabff1c95e0d978996243 100644 (file)
@@ -59,8 +59,6 @@ typedef unsigned long long u64;
 
 typedef u32 dma_addr_t;
 
-typedef unsigned int kmem_bufctl_t;
-
 #endif /* !__ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
index 431318764af60da58dae27c150deed7379676198..135ffaa0393b4d8aa5559241d0f512fb61251742 100644 (file)
@@ -28,7 +28,6 @@
 #define HPAGE_SIZE     ((1UL) << HPAGE_SHIFT)
 #define HPAGE_MASK     (~(HPAGE_SIZE - 1))
 #define HUGETLB_PAGE_ORDER     (HPAGE_SHIFT - PAGE_SHIFT)
-#define ARCH_HAS_HUGETLB_CLEAN_STALE_PGTABLE
 
 #ifdef __KERNEL__
 #ifndef __ASSEMBLY__
@@ -92,20 +91,6 @@ typedef struct { unsigned long pgprot; } pgprot_t;
 
 #include <asm/bug.h>
 
-/* Pure 2^n version of get_order */
-extern __inline__ int get_order(unsigned long size)
-{
-       int order;
-
-       size = (size-1) >> (PAGE_SHIFT-1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-       return order;
-}
-
 #endif /* __ASSEMBLY__ */
 
 #define PAGE_OFFSET            ((unsigned long)__PAGE_OFFSET)
@@ -141,4 +126,6 @@ extern __inline__ int get_order(unsigned long size)
 
 #endif /* __KERNEL__ */
 
+#include <asm-generic/page.h>
+
 #endif /* _X86_64_PAGE_H */
index 4e167b5ea8f31e3d4594c0fc56e5465441553264..5e0f2fdab0d35885f75f1177d54d18b4117808ec 100644 (file)
@@ -104,6 +104,19 @@ extern inline void pgd_clear (pgd_t * pgd)
 ((unsigned long) __va(pud_val(pud) & PHYSICAL_PAGE_MASK))
 
 #define ptep_get_and_clear(mm,addr,xp) __pte(xchg(&(xp)->pte, 0))
+
+static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long addr, pte_t *ptep, int full)
+{
+       pte_t pte;
+       if (full) {
+               pte = *ptep;
+               *ptep = __pte(0);
+       } else {
+               pte = ptep_get_and_clear(mm, addr, ptep);
+       }
+       return pte;
+}
+
 #define pte_same(a, b)         ((a).pte == (b).pte)
 
 #define PMD_SIZE       (1UL << PMD_SHIFT)
@@ -143,7 +156,7 @@ extern inline void pgd_clear (pgd_t * pgd)
 #define _PAGE_ACCESSED 0x020
 #define _PAGE_DIRTY    0x040
 #define _PAGE_PSE      0x080   /* 2MB page */
-#define _PAGE_FILE     0x040   /* set:pagecache, unset:swap */
+#define _PAGE_FILE     0x040   /* nonlinear file mapping, saved PTE; unset:swap */
 #define _PAGE_GLOBAL   0x100   /* Global TLB entry */
 
 #define _PAGE_PROTNONE 0x080   /* If not present */
@@ -247,6 +260,7 @@ static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot)
  * The following only work if pte_present() is true.
  * Undefined behaviour if not..
  */
+#define __LARGE_PTE (_PAGE_PSE|_PAGE_PRESENT)
 static inline int pte_user(pte_t pte)          { return pte_val(pte) & _PAGE_USER; }
 extern inline int pte_read(pte_t pte)          { return pte_val(pte) & _PAGE_USER; }
 extern inline int pte_exec(pte_t pte)          { return pte_val(pte) & _PAGE_USER; }
@@ -254,8 +268,8 @@ extern inline int pte_dirty(pte_t pte)              { return pte_val(pte) & _PAGE_DIRTY; }
 extern inline int pte_young(pte_t pte)         { return pte_val(pte) & _PAGE_ACCESSED; }
 extern inline int pte_write(pte_t pte)         { return pte_val(pte) & _PAGE_RW; }
 static inline int pte_file(pte_t pte)          { return pte_val(pte) & _PAGE_FILE; }
+static inline int pte_huge(pte_t pte)          { return (pte_val(pte) & __LARGE_PTE) == __LARGE_PTE; }
 
-#define __LARGE_PTE (_PAGE_PSE|_PAGE_PRESENT)
 extern inline pte_t pte_rdprotect(pte_t pte)   { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_USER)); return pte; }
 extern inline pte_t pte_exprotect(pte_t pte)   { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_USER)); return pte; }
 extern inline pte_t pte_mkclean(pte_t pte)     { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_DIRTY)); return pte; }
@@ -433,6 +447,7 @@ extern int kern_addr_valid(unsigned long addr);
 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
+#define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL
 #define __HAVE_ARCH_PTEP_SET_WRPROTECT
 #define __HAVE_ARCH_PTE_SAME
 #include <asm-generic/pgtable.h>
index 85549e656eeb26aad35a50c973f8ea8b9a441bd2..194160f6a43f2064e8f1561a0111f91d5a084286 100644 (file)
@@ -437,6 +437,11 @@ static inline void prefetchw(void *x)
        outb((data), 0x23); \
 } while (0)
 
+static inline void serialize_cpu(void)
+{
+       __asm__ __volatile__ ("cpuid" : : : "ax", "bx", "cx", "dx");
+}
+
 static inline void __monitor(const void *eax, unsigned long ecx,
                unsigned long edx)
 {
index 32bd1426b523dec2d2e251a9902295f6f628f023..c86c2e6793e2a87b55224a7d17f9dfa077ae75e3 100644 (file)
@@ -51,8 +51,6 @@ typedef u64 dma_addr_t;
 typedef u64 sector_t;
 #define HAVE_SECTOR_T
 
-typedef unsigned short kmem_bufctl_t;
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
index d72bcb32ba4f74ce3d3863559f14170d8937d050..24f86f0e43cfd64c918fbe39b5b8cdb629ea9175 100644 (file)
@@ -66,7 +66,7 @@ typedef struct { volatile int counter; } atomic_t;
  *
  * Atomically adds @i to @v.
  */
-extern __inline__ void atomic_add(int i, atomic_t * v)
+static inline void atomic_add(int i, atomic_t * v)
 {
     unsigned int vval;
 
@@ -90,7 +90,7 @@ extern __inline__ void atomic_add(int i, atomic_t * v)
  *
  * Atomically subtracts @i from @v.
  */
-extern __inline__ void atomic_sub(int i, atomic_t *v)
+static inline void atomic_sub(int i, atomic_t *v)
 {
     unsigned int vval;
 
@@ -111,7 +111,7 @@ extern __inline__ void atomic_sub(int i, atomic_t *v)
  * We use atomic_{add|sub}_return to define other functions.
  */
 
-extern __inline__ int atomic_add_return(int i, atomic_t * v)
+static inline int atomic_add_return(int i, atomic_t * v)
 {
      unsigned int vval;
 
@@ -130,7 +130,7 @@ extern __inline__ int atomic_add_return(int i, atomic_t * v)
     return vval;
 }
 
-extern __inline__ int atomic_sub_return(int i, atomic_t * v)
+static inline int atomic_sub_return(int i, atomic_t * v)
 {
     unsigned int vval;
 
@@ -224,7 +224,7 @@ extern __inline__ int atomic_sub_return(int i, atomic_t * v)
 #define atomic_add_negative(i,v) (atomic_add_return((i),(v)) < 0)
 
 
-extern __inline__ void atomic_clear_mask(unsigned int mask, atomic_t *v)
+static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
 {
     unsigned int all_f = -1;
     unsigned int vval;
@@ -243,7 +243,7 @@ extern __inline__ void atomic_clear_mask(unsigned int mask, atomic_t *v)
        );
 }
 
-extern __inline__ void atomic_set_mask(unsigned int mask, atomic_t *v)
+static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
 {
     unsigned int vval;
 
index 1a00fad19929fa0814457f11a1e3c6daef9fa045..81a797ae3abe1a8a3d4212a6ddb9645b27af3d01 100644 (file)
@@ -47,14 +47,14 @@ asmlinkage unsigned int csum_partial_copy_generic( const char *src, char *dst, i
  *     If you use these functions directly please don't forget the
  *     verify_area().
  */
-extern __inline__
+static inline
 unsigned int csum_partial_copy_nocheck ( const char *src, char *dst,
                                        int len, int sum)
 {
        return csum_partial_copy_generic ( src, dst, len, sum, NULL, NULL);
 }
 
-extern __inline__
+static inline
 unsigned int csum_partial_copy_from_user ( const char *src, char *dst,
                                                int len, int sum, int *err_ptr)
 {
index 0a123d53a636722009633c4908d74925004f8223..1bc601ec3621a0bca23226ab8758f4a94e04cc84 100644 (file)
@@ -18,7 +18,7 @@
 
 extern unsigned long loops_per_jiffy;
 
-extern __inline__ void __delay(unsigned long loops)
+static inline void __delay(unsigned long loops)
 {
   /* 2 cycles per loop. */
   __asm__ __volatile__ ("1: addi %0, %0, -2; bgeui %0, 2, 1b"
index 2c471c42ecfc40030a2185bca07db89695c35a86..c5c13985bbe1f013577fa2d371a086517bab8a7c 100644 (file)
@@ -41,12 +41,12 @@ static inline unsigned int _swapl (unsigned int v)
  * These are trivial on the 1:1 Linux/Xtensa mapping
  */
 
-extern inline unsigned long virt_to_phys(volatile void * address)
+static inline unsigned long virt_to_phys(volatile void * address)
 {
        return PHYSADDR((unsigned long)address);
 }
 
-extern inline void * phys_to_virt(unsigned long address)
+static inline void * phys_to_virt(unsigned long address)
 {
        return (void*) CACHED_ADDR(address);
 }
@@ -55,12 +55,12 @@ extern inline void * phys_to_virt(unsigned long address)
  * IO bus memory addresses are also 1:1 with the physical address
  */
 
-extern inline unsigned long virt_to_bus(volatile void * address)
+static inline unsigned long virt_to_bus(volatile void * address)
 {
        return PHYSADDR((unsigned long)address);
 }
 
-extern inline void * bus_to_virt (unsigned long address)
+static inline void * bus_to_virt (unsigned long address)
 {
        return (void *) CACHED_ADDR(address);
 }
@@ -69,17 +69,17 @@ extern inline void * bus_to_virt (unsigned long address)
  * Change "struct page" to physical address.
  */
 
-extern inline void *ioremap(unsigned long offset, unsigned long size)
+static inline void *ioremap(unsigned long offset, unsigned long size)
 {
         return (void *) CACHED_ADDR_IO(offset);
 }
 
-extern inline void *ioremap_nocache(unsigned long offset, unsigned long size)
+static inline void *ioremap_nocache(unsigned long offset, unsigned long size)
 {
         return (void *) BYPASS_ADDR_IO(offset);
 }
 
-extern inline void iounmap(void *addr)
+static inline void iounmap(void *addr)
 {
 }
 
index 1b0801548cd90ca5e30437b0d764f465bcd49d6e..364a7b057bfaa60b2e2336e7573e29193e4c451b 100644 (file)
@@ -199,13 +199,13 @@ extern pgd_t *current_pgd;
 #define ASID_FIRST_VERSION                                             \
        ((unsigned long)(~ASID_VERSION_MASK) + 1 + ASID_FIRST_NONRESERVED)
 
-extern inline void set_rasid_register (unsigned long val)
+static inline void set_rasid_register (unsigned long val)
 {
        __asm__ __volatile__ (" wsr %0, "__stringify(RASID)"\n\t"
                              " isync\n" : : "a" (val));
 }
 
-extern inline unsigned long get_rasid_register (void)
+static inline unsigned long get_rasid_register (void)
 {
        unsigned long tmp;
        __asm__ __volatile__ (" rsr %0, "__stringify(RASID)"\n\t" : "=a" (tmp));
@@ -215,7 +215,7 @@ extern inline unsigned long get_rasid_register (void)
 
 #if ((XCHAL_MMU_ASID_INVALID == 0) && (XCHAL_MMU_ASID_KERNEL == 1))
 
-extern inline void
+static inline void
 get_new_mmu_context(struct mm_struct *mm, unsigned long asid)
 {
        extern void flush_tlb_all(void);
@@ -234,7 +234,7 @@ get_new_mmu_context(struct mm_struct *mm, unsigned long asid)
 /* XCHAL_MMU_ASID_INVALID == 0 and XCHAL_MMU_ASID_KERNEL ==1 are
    really the best, but if you insist... */
 
-extern inline int validate_asid (unsigned long asid)
+static inline int validate_asid (unsigned long asid)
 {
        switch (asid) {
        case XCHAL_MMU_ASID_INVALID:
@@ -247,7 +247,7 @@ extern inline int validate_asid (unsigned long asid)
        return 1; /* valid */
 }
 
-extern inline void
+static inline void
 get_new_mmu_context(struct mm_struct *mm, unsigned long asid)
 {
        extern void flush_tlb_all(void);
@@ -274,14 +274,14 @@ get_new_mmu_context(struct mm_struct *mm, unsigned long asid)
  * instance.
  */
 
-extern inline int
+static inline int
 init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 {
        mm->context = NO_CONTEXT;
        return 0;
 }
 
-extern inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
+static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
                              struct task_struct *tsk)
 {
        unsigned long asid = asid_cache;
@@ -301,7 +301,7 @@ extern inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
  * Destroy context related info for an mm_struct that is about
  * to be put to rest.
  */
-extern inline void destroy_context(struct mm_struct *mm)
+static inline void destroy_context(struct mm_struct *mm)
 {
        /* Nothing to do. */
 }
@@ -310,7 +310,7 @@ extern inline void destroy_context(struct mm_struct *mm)
  * After we have set current->mm to a new value, this activates
  * the context for the new mm so we see the new mappings.
  */
-extern inline void
+static inline void
 activate_mm(struct mm_struct *prev, struct mm_struct *next)
 {
        /* Unconditionally get a new ASID.  */
index b495e5b5a9427bddae499243a634d6583711b9ae..8ded36f255a2847a12f629e38db3c3ab2dab0921 100644 (file)
@@ -55,7 +55,7 @@ typedef struct { unsigned long pgprot; } pgprot_t;
  * Pure 2^n version of get_order
  */
 
-extern __inline__ int get_order(unsigned long size)
+static inline int get_order(unsigned long size)
 {
        int order;
 #ifndef XCHAL_HAVE_NSU
diff --git a/include/asm-xtensa/page.h.n b/include/asm-xtensa/page.h.n
deleted file mode 100644 (file)
index 546cc66..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * linux/include/asm-xtensa/page.h
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version2 as
- * published by the Free Software Foundation.
- *
- * Copyright (C) 2001 - 2005 Tensilica Inc.
- */
-
-#ifndef _XTENSA_PAGE_H
-#define _XTENSA_PAGE_H
-
-#ifdef __KERNEL__
-
-#include <asm/processor.h>
-#include <linux/config.h>
-
-/*
- * PAGE_SHIFT determines the page size
- * PAGE_ALIGN(x) aligns the pointer to the (next) page boundary
- */
-#define PAGE_SHIFT             XCHAL_MMU_MIN_PTE_PAGE_SIZE
-#define PAGE_SIZE              (1 << PAGE_SHIFT)
-#define PAGE_MASK              (~(PAGE_SIZE-1))
-#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE - 1) & PAGE_MASK)
-
-#define DCACHE_WAY_SIZE                (XCHAL_DCACHE_SIZE / XCHAL_DCACHE_WAYS)
-#define PAGE_OFFSET            XCHAL_KSEG_CACHED_VADDR
-
-#ifdef __ASSEMBLY__
-
-#define __pgprot(x)    (x)
-
-#else
-
-
-/*
- * These are used to make use of C type-checking..
- */
-typedef struct { unsigned long pte; } pte_t;           /* page table entry */
-typedef struct { unsigned long pmd; } pmd_t;           /* PMD table entry */
-typedef struct { unsigned long pgd; } pgd_t;           /* PGD table entry */
-typedef struct { unsigned long pgprot; } pgprot_t;
-
-#define pte_val(x)     ((x).pte)
-#define pmd_val(x)     ((x).pmd)
-#define pgd_val(x)     ((x).pgd)
-#define pgprot_val(x)  ((x).pgprot)
-
-#define __pte(x)       ((pte_t) { (x) } )
-#define __pmd(x)       ((pmd_t) { (x) } )
-#define __pgd(x)       ((pgd_t) { (x) } )
-#define __pgprot(x)    ((pgprot_t) { (x) } )
-
-/*
- * Pure 2^n version of get_order
- */
-extern __inline__ int get_order(unsigned long size)
-{
-       int order;
-#ifndef XCHAL_HAVE_NSU
-       unsigned long x1, x2, x4, x8, x16;
-
-       size = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
-       x1  = size & 0xAAAAAAAA;
-       x2  = size & 0xCCCCCCCC;
-       x4  = size & 0xF0F0F0F0;
-       x8  = size & 0xFF00FF00;
-       x16 = size & 0xFFFF0000;
-       order = x2 ? 2 : 0;
-       order += (x16 != 0) * 16;
-       order += (x8 != 0) * 8;
-       order += (x4 != 0) * 4;
-       order += (x1 != 0);
-
-       return order;
-#else
-       size = (size - 1) >> PAGE_SHIFT;
-       asm ("nsau %0, %1" : "=r" (order) : "r" (size));
-       return 32 - order;
-#endif
-}
-
-
-struct page;
-extern void clear_page(void *page);
-extern void copy_page(void *to, void *from);
-
-/*
- * If we have cache aliasing and writeback caches, we might have to do
- * some extra work
- */
-
-#if (DCACHE_WAY_SIZE > PAGE_SIZE) && XCHAL_DCACHE_IS_WRITEBACK
-void clear_user_page(void *addr, unsigned long vaddr, struct page* page);
-void copy_user_page(void *to, void* from, unsigned long vaddr, struct page* page);
-#else
-# define clear_user_page(page,vaddr,pg)                clear_page(page)
-# define copy_user_page(to, from, vaddr, pg)   copy_page(to, from)
-#endif
-
-
-/*
- * This handles the memory map.  We handle pages at
- * XCHAL_KSEG_CACHED_VADDR for kernels with 32 bit address space.
- * These macros are for conversion of kernel address, not user
- * addresses.
- */
-
-#define __pa(x)                        ((unsigned long) (x) - PAGE_OFFSET)
-#define __va(x)                        ((void *)((unsigned long) (x) + PAGE_OFFSET))
-#define pfn_valid(pfn)         ((unsigned long)pfn < max_mapnr)
-#ifndef CONFIG_DISCONTIGMEM
-# define pfn_to_page(pfn)      (mem_map + (pfn))
-# define page_to_pfn(page)     ((unsigned long)((page) - mem_map))
-#else
-# error CONFIG_DISCONTIGMEM not supported
-#endif
-
-#define virt_to_page(kaddr)    pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
-#define page_to_virt(page)     __va(page_to_pfn(page) << PAGE_SHIFT)
-#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
-#define page_to_phys(page)     (page_to_pfn(page) << PAGE_SHIFT)
-
-#define WANT_PAGE_VIRTUAL
-
-
-#endif /* __ASSEMBLY__ */
-
-#define VM_DATA_DEFAULT_FLAGS  (VM_READ | VM_WRITE | VM_EXEC | \
-                                VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
-
-#endif /* __KERNEL__ */
-#endif /* _XTENSA_PAGE_H */
index 6817742301c22fa73697c6ffe837609a062f28ab..24eb7fc25da830c8fc4f74ac1b0c11efe1a677b8 100644 (file)
 
 extern struct pci_controller* pcibios_alloc_controller(void);
 
-extern inline void pcibios_set_master(struct pci_dev *dev)
+static inline void pcibios_set_master(struct pci_dev *dev)
 {
        /* No special bus mastering setup handling */
 }
 
-extern inline void pcibios_penalize_isa_irq(int irq)
+static inline void pcibios_penalize_isa_irq(int irq)
 {
        /* We don't do dynamic PCI IRQ allocation */
 }
index 0bb6416ae2660bcaafd39d92fe9cf90b19e799ab..883ebc2d75d69090f0c044e2556b7df9b324d965 100644 (file)
@@ -260,7 +260,7 @@ static inline pte_t pte_mkwrite(pte_t pte)  { pte_val(pte) |= _PAGE_RW; return pt
 #define pfn_pte(pfn, prot)     __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
 #define mk_pte(page, prot)     pfn_pte(page_to_pfn(page), prot)
 
-extern inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
+static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
        return __pte((pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot));
 }
@@ -278,14 +278,14 @@ static inline void update_pte(pte_t *ptep, pte_t pteval)
 #endif
 }
 
-extern inline void
+static inline void
 set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pteval)
 {
        update_pte(ptep, pteval);
 }
 
 
-extern inline void
+static inline void
 set_pmd(pmd_t *pmdp, pmd_t pmdval)
 {
        *pmdp = pmdval;
index c8a7574a9a57bc00e570e3910b325f21d06ef33b..db740b8bc6f058d006e09c96316a15ca4f8aa53b 100644 (file)
@@ -47,7 +47,7 @@ struct semaphore {
 #define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
 #define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
 
-extern inline void sema_init (struct semaphore *sem, int val)
+static inline void sema_init (struct semaphore *sem, int val)
 {
 /*
  *     *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
@@ -79,7 +79,7 @@ asmlinkage void __up(struct semaphore * sem);
 
 extern spinlock_t semaphore_wake_lock;
 
-extern __inline__ void down(struct semaphore * sem)
+static inline void down(struct semaphore * sem)
 {
 #if WAITQUEUE_DEBUG
        CHECK_MAGIC(sem->__magic);
@@ -89,7 +89,7 @@ extern __inline__ void down(struct semaphore * sem)
                __down(sem);
 }
 
-extern __inline__ int down_interruptible(struct semaphore * sem)
+static inline int down_interruptible(struct semaphore * sem)
 {
        int ret = 0;
 #if WAITQUEUE_DEBUG
@@ -101,7 +101,7 @@ extern __inline__ int down_interruptible(struct semaphore * sem)
        return ret;
 }
 
-extern __inline__ int down_trylock(struct semaphore * sem)
+static inline int down_trylock(struct semaphore * sem)
 {
        int ret = 0;
 #if WAITQUEUE_DEBUG
@@ -117,7 +117,7 @@ extern __inline__ int down_trylock(struct semaphore * sem)
  * Note! This is subtle. We jump to wake people up only if
  * the semaphore was negative (== somebody was waiting on it).
  */
-extern __inline__ void up(struct semaphore * sem)
+static inline void up(struct semaphore * sem)
 {
 #if WAITQUEUE_DEBUG
        CHECK_MAGIC(sem->__magic);
index 3f81b27d98091e1e94eacf1f098fa2b670d61c75..5fb8c27cbef58dd98cb3847e2bc1b286fdad1cd3 100644 (file)
@@ -16,7 +16,7 @@
 #define _XTENSA_STRING_H
 
 #define __HAVE_ARCH_STRCPY
-extern __inline__ char *strcpy(char *__dest, const char *__src)
+static inline char *strcpy(char *__dest, const char *__src)
 {
        register char *__xdest = __dest;
        unsigned long __dummy;
@@ -35,7 +35,7 @@ extern __inline__ char *strcpy(char *__dest, const char *__src)
 }
 
 #define __HAVE_ARCH_STRNCPY
-extern __inline__ char *strncpy(char *__dest, const char *__src, size_t __n)
+static inline char *strncpy(char *__dest, const char *__src, size_t __n)
 {
        register char *__xdest = __dest;
        unsigned long __dummy;
@@ -60,7 +60,7 @@ extern __inline__ char *strncpy(char *__dest, const char *__src, size_t __n)
 }
 
 #define __HAVE_ARCH_STRCMP
-extern __inline__ int strcmp(const char *__cs, const char *__ct)
+static inline int strcmp(const char *__cs, const char *__ct)
 {
        register int __res;
        unsigned long __dummy;
@@ -82,7 +82,7 @@ extern __inline__ int strcmp(const char *__cs, const char *__ct)
 }
 
 #define __HAVE_ARCH_STRNCMP
-extern __inline__ int strncmp(const char *__cs, const char *__ct, size_t __n)
+static inline int strncmp(const char *__cs, const char *__ct, size_t __n)
 {
        register int __res;
        unsigned long __dummy;
index 690fe325e67116861518bc059fe4ccd43ade27ef..f09393232e5e9c58dad7c84258f076b1d3414933 100644 (file)
@@ -56,7 +56,7 @@ static inline int irqs_disabled(void)
 
 #define clear_cpenable() __clear_cpenable()
 
-extern __inline__ void __clear_cpenable(void)
+static inline void __clear_cpenable(void)
 {
 #if XCHAL_HAVE_CP
        unsigned long i = 0;
@@ -64,7 +64,7 @@ extern __inline__ void __clear_cpenable(void)
 #endif
 }
 
-extern __inline__ void enable_coprocessor(int i)
+static inline void enable_coprocessor(int i)
 {
 #if XCHAL_HAVE_CP
        int cp;
@@ -74,7 +74,7 @@ extern __inline__ void enable_coprocessor(int i)
 #endif
 }
 
-extern __inline__ void disable_coprocessor(int i)
+static inline void disable_coprocessor(int i)
 {
 #if XCHAL_HAVE_CP
        int cp;
@@ -123,7 +123,7 @@ do {                                                \
  * cmpxchg
  */
 
-extern __inline__ unsigned long
+static inline unsigned long
 __cmpxchg_u32(volatile int *p, int old, int new)
 {
   __asm__ __volatile__("rsil    a15, "__stringify(LOCKLEVEL)"\n\t"
@@ -173,7 +173,7 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
  * where no register reference will cause an overflow.
  */
 
-extern __inline__ unsigned long xchg_u32(volatile int * m, unsigned long val)
+static inline unsigned long xchg_u32(volatile int * m, unsigned long val)
 {
   unsigned long tmp;
   __asm__ __volatile__("rsil    a15, "__stringify(LOCKLEVEL)"\n\t"
index 23bfe9db45f5de0dd4e664566b98d4ab91a06214..43f6ec859af92fccd699bcc918f01a3467fa63d4 100644 (file)
@@ -39,7 +39,7 @@ extern void flush_tlb_range(struct vm_area_struct*,unsigned long,unsigned long);
  * page-table pages.
  */
 
-extern inline void flush_tlb_pgtables(struct mm_struct *mm,
+static inline void flush_tlb_pgtables(struct mm_struct *mm,
                                       unsigned long start, unsigned long end)
 {
 }
@@ -51,26 +51,26 @@ extern inline void flush_tlb_pgtables(struct mm_struct *mm,
 #define ITLB_PROBE_SUCCESS  (1 << ITLB_WAYS_LOG2)
 #define DTLB_PROBE_SUCCESS  (1 << DTLB_WAYS_LOG2)
 
-extern inline unsigned long itlb_probe(unsigned long addr)
+static inline unsigned long itlb_probe(unsigned long addr)
 {
        unsigned long tmp;
        __asm__ __volatile__("pitlb  %0, %1\n\t" : "=a" (tmp) : "a" (addr));
        return tmp;
 }
 
-extern inline unsigned long dtlb_probe(unsigned long addr)
+static inline unsigned long dtlb_probe(unsigned long addr)
 {
        unsigned long tmp;
        __asm__ __volatile__("pdtlb  %0, %1\n\t" : "=a" (tmp) : "a" (addr));
        return tmp;
 }
 
-extern inline void invalidate_itlb_entry (unsigned long probe)
+static inline void invalidate_itlb_entry (unsigned long probe)
 {
        __asm__ __volatile__("iitlb  %0; isync\n\t" : : "a" (probe));
 }
 
-extern inline void invalidate_dtlb_entry (unsigned long probe)
+static inline void invalidate_dtlb_entry (unsigned long probe)
 {
        __asm__ __volatile__("idtlb  %0; dsync\n\t" : : "a" (probe));
 }
@@ -80,68 +80,68 @@ extern inline void invalidate_dtlb_entry (unsigned long probe)
  * caller must follow up with an 'isync', which can be relatively
  * expensive on some Xtensa implementations.
  */
-extern inline void invalidate_itlb_entry_no_isync (unsigned entry)
+static inline void invalidate_itlb_entry_no_isync (unsigned entry)
 {
        /* Caller must follow up with 'isync'. */
        __asm__ __volatile__ ("iitlb  %0\n" : : "a" (entry) );
 }
 
-extern inline void invalidate_dtlb_entry_no_isync (unsigned entry)
+static inline void invalidate_dtlb_entry_no_isync (unsigned entry)
 {
        /* Caller must follow up with 'isync'. */
        __asm__ __volatile__ ("idtlb  %0\n" : : "a" (entry) );
 }
 
-extern inline void set_itlbcfg_register (unsigned long val)
+static inline void set_itlbcfg_register (unsigned long val)
 {
        __asm__ __volatile__("wsr  %0, "__stringify(ITLBCFG)"\n\t" "isync\n\t"
                             : : "a" (val));
 }
 
-extern inline void set_dtlbcfg_register (unsigned long val)
+static inline void set_dtlbcfg_register (unsigned long val)
 {
        __asm__ __volatile__("wsr  %0, "__stringify(DTLBCFG)"; dsync\n\t"
                             : : "a" (val));
 }
 
-extern inline void set_ptevaddr_register (unsigned long val)
+static inline void set_ptevaddr_register (unsigned long val)
 {
        __asm__ __volatile__(" wsr  %0, "__stringify(PTEVADDR)"; isync\n"
                             : : "a" (val));
 }
 
-extern inline unsigned long read_ptevaddr_register (void)
+static inline unsigned long read_ptevaddr_register (void)
 {
        unsigned long tmp;
        __asm__ __volatile__("rsr  %0, "__stringify(PTEVADDR)"\n\t" : "=a" (tmp));
        return tmp;
 }
 
-extern inline void write_dtlb_entry (pte_t entry, int way)
+static inline void write_dtlb_entry (pte_t entry, int way)
 {
        __asm__ __volatile__("wdtlb  %1, %0; dsync\n\t"
                             : : "r" (way), "r" (entry) );
 }
 
-extern inline void write_itlb_entry (pte_t entry, int way)
+static inline void write_itlb_entry (pte_t entry, int way)
 {
        __asm__ __volatile__("witlb  %1, %0; isync\n\t"
                             : : "r" (way), "r" (entry) );
 }
 
-extern inline void invalidate_page_directory (void)
+static inline void invalidate_page_directory (void)
 {
        invalidate_dtlb_entry (DTLB_WAY_PGTABLE);
 }
 
-extern inline void invalidate_itlb_mapping (unsigned address)
+static inline void invalidate_itlb_mapping (unsigned address)
 {
        unsigned long tlb_entry;
        while ((tlb_entry = itlb_probe (address)) & ITLB_PROBE_SUCCESS)
                invalidate_itlb_entry (tlb_entry);
 }
 
-extern inline void invalidate_dtlb_mapping (unsigned address)
+static inline void invalidate_dtlb_mapping (unsigned address)
 {
        unsigned long tlb_entry;
        while ((tlb_entry = dtlb_probe (address)) & DTLB_PROBE_SUCCESS)
@@ -165,28 +165,28 @@ extern inline void invalidate_dtlb_mapping (unsigned address)
  *      as[07..00] contain the asid
  */
 
-extern inline unsigned long read_dtlb_virtual (int way)
+static inline unsigned long read_dtlb_virtual (int way)
 {
        unsigned long tmp;
        __asm__ __volatile__("rdtlb0  %0, %1\n\t" : "=a" (tmp), "+a" (way));
        return tmp;
 }
 
-extern inline unsigned long read_dtlb_translation (int way)
+static inline unsigned long read_dtlb_translation (int way)
 {
        unsigned long tmp;
        __asm__ __volatile__("rdtlb1  %0, %1\n\t" : "=a" (tmp), "+a" (way));
        return tmp;
 }
 
-extern inline unsigned long read_itlb_virtual (int way)
+static inline unsigned long read_itlb_virtual (int way)
 {
        unsigned long tmp;
        __asm__ __volatile__("ritlb0  %0, %1\n\t" : "=a" (tmp), "+a" (way));
        return tmp;
 }
 
-extern inline unsigned long read_itlb_translation (int way)
+static inline unsigned long read_itlb_translation (int way)
 {
        unsigned long tmp;
        __asm__ __volatile__("ritlb1  %0, %1\n\t" : "=a" (tmp), "+a" (way));
index ebac004698520fab778f8a9c2298208a606395e6..9d99a8e9e337101af6fc2bb6881cabc85103915d 100644 (file)
@@ -58,8 +58,6 @@ typedef unsigned long long u64;
 
 typedef u32 dma_addr_t;
 
-typedef unsigned int kmem_bufctl_t;
-
 #endif /* __KERNEL__ */
 #endif
 
index 35576b25c7b2fe31ec6d1ef92c9cb9eea64b0034..fc268ac923c0b9a22200515fcb54e49329a09002 100644 (file)
 #define __access_ok(addr,size) (__kernel_ok || __user_ok((addr),(size)))
 #define access_ok(type,addr,size) __access_ok((unsigned long)(addr),(size))
 
-extern inline int verify_area(int type, const void * addr, unsigned long size)
+static inline int verify_area(int type, const void * addr, unsigned long size)
 {
        return access_ok(type,addr,size) ? 0 : -EFAULT;
 }
@@ -464,7 +464,7 @@ __generic_copy_from_user(void *to, const void *from, unsigned long n)
  * success.
  */
 
-extern inline unsigned long
+static inline unsigned long
 __xtensa_clear_user(void *addr, unsigned long size)
 {
        if ( ! memset(addr, 0, size) )
@@ -472,7 +472,7 @@ __xtensa_clear_user(void *addr, unsigned long size)
        return 0;
 }
 
-extern inline unsigned long
+static inline unsigned long
 clear_user(void *addr, unsigned long size)
 {
        if (access_ok(VERIFY_WRITE, addr, size))
@@ -486,7 +486,7 @@ clear_user(void *addr, unsigned long size)
 extern long __strncpy_user(char *, const char *, long);
 #define __strncpy_from_user __strncpy_user
 
-extern inline long
+static inline long
 strncpy_from_user(char *dst, const char *src, long count)
 {
        if (access_ok(VERIFY_READ, src, 1))
@@ -502,7 +502,7 @@ strncpy_from_user(char *dst, const char *src, long count)
  */
 extern long __strnlen_user(const char *, long);
 
-extern inline long strnlen_user(const char *str, long len)
+static inline long strnlen_user(const char *str, long len)
 {
        unsigned long top = __kernel_ok ? ~0UL : TASK_SIZE - 1;
 
index 8d139f4acf23beb9f7d92274f4b96f14d3f09f37..6b4618902d3dd3f9fcb6298326a757dac415fb87 100644 (file)
@@ -233,6 +233,7 @@ typedef __u32 kernel_cap_t;
 /* Allow enabling/disabling tagged queuing on SCSI controllers and sending
    arbitrary SCSI commands */
 /* Allow setting encryption key on loopback filesystem */
+/* Allow setting zone reclaim policy */
 
 #define CAP_SYS_ADMIN        21
 
index e8904c0da686e0f347c5fe35a8603fa6e581de31..86980c68234aad549fd7d7252da7df5a72139403 100644 (file)
@@ -8,7 +8,7 @@
  * Basic handling of the devices is done in drivers/base/cpu.c
  * and system devices are handled in drivers/base/sys.c. 
  *
- * CPUs are exported via driverfs in the class/cpu/devices/
+ * CPUs are exported via sysfs in the class/cpu/devices/
  * directory. 
  *
  * Per-cpu interfaces can be implemented using a struct device_interface. 
index 5e2bcc636a02fd4d7a383e661b7661d6ac916169..3c89df6e7768451acf625236790753f2ab7f5139 100644 (file)
@@ -45,6 +45,7 @@
 #define CRYPTO_TFM_MODE_CTR            0x00000008
 
 #define CRYPTO_TFM_REQ_WEAK_KEY                0x00000100
+#define CRYPTO_TFM_REQ_MAY_SLEEP       0x00000200
 #define CRYPTO_TFM_RES_WEAK_KEY                0x00100000
 #define CRYPTO_TFM_RES_BAD_KEY_LEN     0x00200000
 #define CRYPTO_TFM_RES_BAD_KEY_SCHED   0x00400000
index 73781ec165b40a96e92f98c6701daa27393ea3f3..c7c5dd3161820caca202022ca92acdf2b397cd9c 100644 (file)
@@ -91,11 +91,6 @@ typedef      struct {
 
 #define EFI_PAGE_SHIFT         12
 
-/*
- * For current x86 implementations of EFI, there is
- * additional padding in the mem descriptors.  This is not
- * the case in ia64.  Need to have this fixed in the f/w.
- */
 typedef struct {
        u32 type;
        u32 pad;
@@ -103,9 +98,6 @@ typedef struct {
        u64 virt_addr;
        u64 num_pages;
        u64 attribute;
-#if defined (__i386__)
-       u64 pad1;
-#endif
 } efi_memory_desc_t;
 
 typedef int (*efi_freemem_callback_t) (unsigned long start, unsigned long end, void *arg);
@@ -240,10 +232,12 @@ typedef struct {
 } efi_system_table_t;
 
 struct efi_memory_map {
-       efi_memory_desc_t *phys_map;
-       efi_memory_desc_t *map;
+       void *phys_map;
+       void *map;
+       void *map_end;
        int nr_map;
        unsigned long desc_version;
+       unsigned long desc_size;
 };
 
 /*
index ce8518e658b6a0c2219071ed0fbfb0e462fb9115..4522c7186bf378de1c4162b042ad8a3b78fc09ac 100644 (file)
@@ -69,6 +69,12 @@ static inline int is_multicast_ether_addr(const u8 *addr)
        return ((addr[0] != 0xff) && (0x01 & addr[0]));
 }
 
+static inline int is_broadcast_ether_addr(const u8 *addr)
+{
+        return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&  
+               (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
+}
+
 /**
  * is_valid_ether_addr - Determine if the given Ethernet address is valid
  * @addr: Pointer to a six-byte array containing the Ethernet address
index f529d144281521552491058d1b5ed66d47bc8d71..e670b0d13fe02af741f0f881058bcfb0d43639df 100644 (file)
@@ -70,12 +70,6 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
 void hugetlb_prefault_arch_hook(struct mm_struct *mm);
 #endif
 
-#ifndef ARCH_HAS_HUGETLB_CLEAN_STALE_PGTABLE
-#define hugetlb_clean_stale_pgtable(pte)       BUG()
-#else
-void hugetlb_clean_stale_pgtable(pte_t *pte);
-#endif
-
 #else /* !CONFIG_HUGETLB_PAGE */
 
 static inline int is_vm_hugetlb_page(struct vm_area_struct *vma)
index 1b5018a965f58bdb98b909b70583836fe9008e94..7eb4004b36011b2188835751053195d0e1f7b047 100644 (file)
@@ -33,4 +33,19 @@ struct sensor_device_attribute sensor_dev_attr_##_name = {   \
        .index =        _index,                                 \
 }
 
+struct sensor_device_attribute_2 {
+       struct device_attribute dev_attr;
+       u8 index;
+       u8 nr;
+};
+#define to_sensor_dev_attr_2(_dev_attr) \
+       container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
+
+#define SENSOR_DEVICE_ATTR_2(_name,_mode,_show,_store,_nr,_index)      \
+struct sensor_device_attribute_2 sensor_dev_attr_##_name = {   \
+       .dev_attr =     __ATTR(_name,_mode,_show,_store),       \
+       .index =        _index,                                 \
+       .nr =           _nr,                                    \
+}
+
 #endif /* _LINUX_HWMON_SYSFS_H */
diff --git a/include/linux/hwmon-vid.h b/include/linux/hwmon-vid.h
new file mode 100644 (file)
index 0000000..cd4b7a0
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+    hwmon-vid.h - VID/VRM/VRD voltage conversions
+
+    Originally part of lm_sensors
+    Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com>
+    With assistance from Trent Piepho <xyzzy@speakeasy.org>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef _LINUX_HWMON_VID_H
+#define _LINUX_HWMON_VID_H
+
+int vid_from_reg(int val, int vrm);
+int vid_which_vrm(void);
+
+/* vrm is the VRM/VRD document version multiplied by 10.
+   val is in mV to avoid floating point in the kernel.
+   Returned value is the 4-, 5- or 6-bit VID code.
+   Note that only VRM 9.x is supported for now. */
+static inline int vid_to_reg(int val, int vrm)
+{
+       switch (vrm) {
+       case 91:                /* VRM 9.1 */
+       case 90:                /* VRM 9.0 */
+               return ((val >= 1100) && (val <= 1850) ?
+                       ((18499 - val * 10) / 25 + 5) / 10 : -1);
+       default:
+               return -1;
+       }
+}
+
+#endif /* _LINUX_HWMON_VID_H */
diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h
new file mode 100644 (file)
index 0000000..0efd994
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+    hwmon.h - part of lm_sensors, Linux kernel modules for hardware monitoring
+
+    This file declares helper functions for the sysfs class "hwmon",
+    for use by sensors drivers.
+
+    Copyright (C) 2005 Mark M. Hoffman <mhoffman@lightlink.com>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; version 2 of the License.
+*/
+
+#ifndef _HWMON_H_
+#define _HWMON_H_
+
+#include <linux/device.h>
+
+struct class_device *hwmon_device_register(struct device *dev);
+
+void hwmon_device_unregister(struct class_device *cdev);
+
+/* Scale user input to sensible values */
+static inline int SENSORS_LIMIT(long value, long low, long high)
+{
+       if (value < low)
+               return low;
+       else if (value > high)
+               return high;
+       else
+               return value;
+}
+
+#endif
+
index 33f08258f22b4077e4c247e5196b59fa01c14c2c..44f30876a1c9b194287f22226a24ed63d2e0fa69 100644 (file)
@@ -1,6 +1,6 @@
 /* ------------------------------------------------------------------------- */
 /*                                                                          */
-/* i2c.h - definitions for the i2c-bus interface                            */
+/* i2c-id.h - identifier values for i2c drivers and adapters                */
 /*                                                                          */
 /* ------------------------------------------------------------------------- */
 /*   Copyright (C) 1995-1999 Simon G. Vogl
 #ifndef LINUX_I2C_ID_H
 #define LINUX_I2C_ID_H
 
-/*
- * This file is part of the i2c-bus package and contains the identifier
- * values for drivers, adapters and other folk populating these serial
- * worlds. 
- *
- * These will change often (i.e. additions) , therefore this has been 
- * separated from the functional interface definitions of the i2c api.
- *
- */
-
 /*
  * ---- Driver types -----------------------------------------------------
  *       device id name + number        function description, i2c address(es)
 
 /*
  * ---- Adapter types ----------------------------------------------------
- *
- * First, we distinguish between several algorithms to access the hardware
- * interface types, as a PCF 8584 needs other care than a bit adapter.
- */
-
-#define I2C_ALGO_NONE  0x000000
-#define I2C_ALGO_BIT   0x010000        /* bit style adapters           */
-#define I2C_ALGO_PCF   0x020000        /* PCF 8584 style adapters      */
-#define I2C_ALGO_ATI   0x030000        /* ATI video card               */
-#define I2C_ALGO_SMBUS 0x040000
-#define I2C_ALGO_ISA   0x050000        /* lm_sensors ISA pseudo-adapter */
-#define I2C_ALGO_SAA7146 0x060000      /* SAA 7146 video decoder bus   */
-#define I2C_ALGO_ACB   0x070000        /* ACCESS.bus algorithm         */
-#define I2C_ALGO_IIC    0x080000       /* ITE IIC bus */
-#define I2C_ALGO_SAA7134 0x090000
-#define I2C_ALGO_MPC824X 0x0a0000      /* Motorola 8240 / 8245         */
-#define I2C_ALGO_IPMI  0x0b0000        /* IPMI dummy adapter */
-#define I2C_ALGO_IPMB  0x0c0000        /* IPMB adapter */
-#define I2C_ALGO_MPC107 0x0d0000
-#define I2C_ALGO_EC     0x100000        /* ACPI embedded controller     */
-
-#define I2C_ALGO_MPC8XX 0x110000       /* MPC8xx PowerPC I2C algorithm */
-#define I2C_ALGO_OCP    0x120000       /* IBM or otherwise On-chip I2C algorithm */
-#define I2C_ALGO_BITHS 0x130000        /* enhanced bit style adapters  */
-#define I2C_ALGO_IOP3XX        0x140000        /* XSCALE IOP3XX On-chip I2C alg */
-#define I2C_ALGO_SIBYTE 0x150000       /* Broadcom SiByte SOCs         */
-#define I2C_ALGO_SGI   0x160000        /* SGI algorithm                */
-
-#define I2C_ALGO_USB   0x170000        /* USB algorithm                */
-#define I2C_ALGO_VIRT  0x180000        /* Virtual bus adapter          */
-
-#define I2C_ALGO_MV64XXX 0x190000      /* Marvell mv64xxx i2c ctlr     */
-#define I2C_ALGO_PCA   0x1a0000        /* PCA 9564 style adapters      */
-#define I2C_ALGO_AU1550        0x1b0000        /* Au1550 PSC algorithm         */
-
-#define I2C_ALGO_EXP   0x800000        /* experimental                 */
-
-#define I2C_ALGO_MASK  0xff0000        /* Mask for algorithms          */
-#define I2C_ALGO_SHIFT 0x10    /* right shift to get index values      */
-
-#define I2C_HW_ADAPS   0x10000         /* # adapter types              */
-#define I2C_HW_MASK    0xffff          
-
-
-/* hw specific modules that are defined per algorithm layer
  */
 
 /* --- Bit algorithm adapters                                          */
-#define I2C_HW_B_LP    0x00    /* Parallel port Philips style adapter  */
-#define I2C_HW_B_LPC   0x01    /* Parallel port, over control reg.     */
-#define I2C_HW_B_SER   0x02    /* Serial line interface                */
-#define I2C_HW_B_ELV   0x03    /* ELV Card                             */
-#define I2C_HW_B_VELLE 0x04    /* Vellemann K8000                      */
-#define I2C_HW_B_BT848 0x05    /* BT848 video boards                   */
-#define I2C_HW_B_WNV   0x06    /* Winnov Videums                       */
-#define I2C_HW_B_VIA   0x07    /* Via vt82c586b                        */
-#define I2C_HW_B_HYDRA 0x08    /* Apple Hydra Mac I/O                  */
-#define I2C_HW_B_G400  0x09    /* Matrox G400                          */
-#define I2C_HW_B_I810  0x0a    /* Intel I810                           */
-#define I2C_HW_B_VOO   0x0b    /* 3dfx Voodoo 3 / Banshee              */
-#define I2C_HW_B_PPORT  0x0c   /* Primitive parallel port adapter      */
-#define I2C_HW_B_SAVG  0x0d    /* Savage 4                             */
-#define I2C_HW_B_SCX200        0x0e    /* Nat'l Semi SCx200 I2C                */
-#define I2C_HW_B_RIVA  0x10    /* Riva based graphics cards            */
-#define I2C_HW_B_IOC   0x11    /* IOC bit-wiggling                     */
-#define I2C_HW_B_TSUNA  0x12   /* DEC Tsunami chipset                  */
-#define I2C_HW_B_FRODO  0x13    /* 2d3D, Inc. SA-1110 Development Board */
-#define I2C_HW_B_OMAHA  0x14    /* Omaha I2C interface (ARM)           */
-#define I2C_HW_B_GUIDE  0x15    /* Guide bit-basher                    */
-#define I2C_HW_B_IXP2000 0x16  /* GPIO on IXP2000 systems              */
-#define I2C_HW_B_IXP4XX 0x17   /* GPIO on IXP4XX systems               */
-#define I2C_HW_B_S3VIA 0x18    /* S3Via ProSavage adapter              */
-#define I2C_HW_B_ZR36067 0x19  /* Zoran-36057/36067 based boards       */
-#define I2C_HW_B_PCILYNX 0x1a  /* TI PCILynx I2C adapter               */
-#define I2C_HW_B_CX2388x 0x1b  /* connexant 2388x based tv cards       */
+#define I2C_HW_B_LP            0x010000 /* Parallel port Philips style */
+#define I2C_HW_B_LPC           0x010001 /* Parallel port control reg. */
+#define I2C_HW_B_SER           0x010002 /* Serial line interface */
+#define I2C_HW_B_ELV           0x010003 /* ELV Card */
+#define I2C_HW_B_VELLE         0x010004 /* Vellemann K8000 */
+#define I2C_HW_B_BT848         0x010005 /* BT848 video boards */
+#define I2C_HW_B_WNV           0x010006 /* Winnov Videums */
+#define I2C_HW_B_VIA           0x010007 /* Via vt82c586b */
+#define I2C_HW_B_HYDRA         0x010008 /* Apple Hydra Mac I/O */
+#define I2C_HW_B_G400          0x010009 /* Matrox G400 */
+#define I2C_HW_B_I810          0x01000a /* Intel I810 */
+#define I2C_HW_B_VOO           0x01000b /* 3dfx Voodoo 3 / Banshee */
+#define I2C_HW_B_PPORT         0x01000c /* Primitive parallel port adapter */
+#define I2C_HW_B_SAVG          0x01000d /* Savage 4 */
+#define I2C_HW_B_SCX200                0x01000e /* Nat'l Semi SCx200 I2C */
+#define I2C_HW_B_RIVA          0x010010 /* Riva based graphics cards */
+#define I2C_HW_B_IOC           0x010011 /* IOC bit-wiggling */
+#define I2C_HW_B_TSUNA         0x010012 /* DEC Tsunami chipset */
+#define I2C_HW_B_FRODO         0x010013 /* 2d3D SA-1110 Development Board */
+#define I2C_HW_B_OMAHA         0x010014 /* Omaha I2C interface (ARM) */
+#define I2C_HW_B_GUIDE         0x010015 /* Guide bit-basher */
+#define I2C_HW_B_IXP2000       0x010016 /* GPIO on IXP2000 systems */
+#define I2C_HW_B_IXP4XX                0x010017 /* GPIO on IXP4XX systems */
+#define I2C_HW_B_S3VIA         0x010018 /* S3Via ProSavage adapter */
+#define I2C_HW_B_ZR36067       0x010019 /* Zoran-36057/36067 based boards */
+#define I2C_HW_B_PCILYNX       0x01001a /* TI PCILynx I2C adapter */
+#define I2C_HW_B_CX2388x       0x01001b /* connexant 2388x based tv cards */
+#define I2C_HW_B_NVIDIA                0x01001c /* nvidia framebuffer driver */
+#define I2C_HW_B_SAVAGE                0x01001d /* savage framebuffer driver */
+#define I2C_HW_B_RADEON                0x01001e /* radeon framebuffer driver */
 
 /* --- PCF 8584 based algorithms                                       */
-#define I2C_HW_P_LP    0x00    /* Parallel port interface              */
-#define I2C_HW_P_ISA   0x01    /* generic ISA Bus inteface card        */
-#define I2C_HW_P_ELEK  0x02    /* Elektor ISA Bus inteface card        */
+#define I2C_HW_P_LP            0x020000 /* Parallel port interface */
+#define I2C_HW_P_ISA           0x020001 /* generic ISA Bus inteface card */
+#define I2C_HW_P_ELEK          0x020002 /* Elektor ISA Bus inteface card */
 
 /* --- PCA 9564 based algorithms */
-#define I2C_HW_A_ISA   0x00    /* generic ISA Bus interface card       */
+#define I2C_HW_A_ISA           0x1a0000 /* generic ISA Bus interface card */
 
 /* --- ACPI Embedded controller algorithms                              */
-#define I2C_HW_ACPI_EC          0x00
+#define I2C_HW_ACPI_EC          0x1f0000
 
 /* --- MPC824x PowerPC adapters                                                */
-#define I2C_HW_MPC824X 0x00    /* Motorola 8240 / 8245                 */
+#define I2C_HW_MPC824X         0x100001 /* Motorola 8240 / 8245 */
 
 /* --- MPC8xx PowerPC adapters                                         */
-#define I2C_HW_MPC8XX_EPON 0x00        /* Eponymous MPC8xx I2C adapter         */
+#define I2C_HW_MPC8XX_EPON     0x110000 /* Eponymous MPC8xx I2C adapter */
 
 /* --- ITE based algorithms                                            */
-#define I2C_HW_I_IIC   0x00    /* controller on the ITE */
+#define I2C_HW_I_IIC           0x080000 /* controller on the ITE */
 
 /* --- PowerPC on-chip adapters                                                */
-#define I2C_HW_OCP 0x00        /* IBM on-chip I2C adapter      */
+#define I2C_HW_OCP             0x120000 /* IBM on-chip I2C adapter */
 
 /* --- Broadcom SiByte adapters                                                */
-#define I2C_HW_SIBYTE  0x00
+#define I2C_HW_SIBYTE          0x150000
 
 /* --- SGI adapters                                                    */
-#define I2C_HW_SGI_VINO        0x00
-#define I2C_HW_SGI_MACE        0x01
+#define I2C_HW_SGI_VINO                0x160000
+#define I2C_HW_SGI_MACE                0x160001
 
 /* --- XSCALE on-chip adapters                          */
-#define I2C_HW_IOP3XX 0x00
+#define I2C_HW_IOP3XX          0x140000
 
 /* --- Au1550 PSC adapters adapters                                    */
-#define I2C_HW_AU1550_PSC      0x00
+#define I2C_HW_AU1550_PSC      0x1b0000
 
 /* --- SMBus only adapters                                             */
-#define I2C_HW_SMBUS_PIIX4     0x00
-#define I2C_HW_SMBUS_ALI15X3   0x01
-#define I2C_HW_SMBUS_VIA2      0x02
-#define I2C_HW_SMBUS_VOODOO3   0x03
-#define I2C_HW_SMBUS_I801      0x04
-#define I2C_HW_SMBUS_AMD756    0x05
-#define I2C_HW_SMBUS_SIS5595   0x06
-#define I2C_HW_SMBUS_ALI1535   0x07
-#define I2C_HW_SMBUS_SIS630    0x08
-#define I2C_HW_SMBUS_SIS96X    0x09
-#define I2C_HW_SMBUS_AMD8111   0x0a
-#define I2C_HW_SMBUS_SCX200    0x0b
-#define I2C_HW_SMBUS_NFORCE2   0x0c
-#define I2C_HW_SMBUS_W9968CF   0x0d
-#define I2C_HW_SMBUS_OV511     0x0e    /* OV511(+) USB 1.1 webcam ICs  */
-#define I2C_HW_SMBUS_OV518     0x0f    /* OV518(+) USB 1.1 webcam ICs  */
-#define I2C_HW_SMBUS_OV519     0x10    /* OV519 USB 1.1 webcam IC      */
-#define I2C_HW_SMBUS_OVFX2     0x11    /* Cypress/OmniVision FX2 webcam */
+#define I2C_HW_SMBUS_PIIX4     0x040000
+#define I2C_HW_SMBUS_ALI15X3   0x040001
+#define I2C_HW_SMBUS_VIA2      0x040002
+#define I2C_HW_SMBUS_VOODOO3   0x040003
+#define I2C_HW_SMBUS_I801      0x040004
+#define I2C_HW_SMBUS_AMD756    0x040005
+#define I2C_HW_SMBUS_SIS5595   0x040006
+#define I2C_HW_SMBUS_ALI1535   0x040007
+#define I2C_HW_SMBUS_SIS630    0x040008
+#define I2C_HW_SMBUS_SIS96X    0x040009
+#define I2C_HW_SMBUS_AMD8111   0x04000a
+#define I2C_HW_SMBUS_SCX200    0x04000b
+#define I2C_HW_SMBUS_NFORCE2   0x04000c
+#define I2C_HW_SMBUS_W9968CF   0x04000d
+#define I2C_HW_SMBUS_OV511     0x04000e /* OV511(+) USB 1.1 webcam ICs */
+#define I2C_HW_SMBUS_OV518     0x04000f /* OV518(+) USB 1.1 webcam ICs */
+#define I2C_HW_SMBUS_OV519     0x040010 /* OV519 USB 1.1 webcam IC */
+#define I2C_HW_SMBUS_OVFX2     0x040011 /* Cypress/OmniVision FX2 webcam */
 
 /* --- ISA pseudo-adapter                                              */
-#define I2C_HW_ISA 0x00
+#define I2C_HW_ISA             0x050000
 
 /* --- IPMI pseudo-adapter                                             */
-#define I2C_HW_IPMI 0x00
+#define I2C_HW_IPMI            0x0b0000
 
 /* --- IPMB adapter                                            */
-#define I2C_HW_IPMB 0x00
+#define I2C_HW_IPMB            0x0c0000
 
 /* --- MCP107 adapter */
-#define I2C_HW_MPC107 0x00
+#define I2C_HW_MPC107          0x0d0000
 
 /* --- Marvell mv64xxx i2c adapter */
-#define I2C_HW_MV64XXX 0x00
+#define I2C_HW_MV64XXX         0x190000
+
+/* --- Miscellaneous adapters */
+#define I2C_HW_SAA7146         0x060000 /* SAA7146 video decoder bus */
+#define I2C_HW_SAA7134         0x090000 /* SAA7134 video decoder bus */
 
 #endif /* LINUX_I2C_ID_H */
diff --git a/include/linux/i2c-isa.h b/include/linux/i2c-isa.h
new file mode 100644 (file)
index 0000000..67e3598
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * i2c-isa.h - definitions for the i2c-isa pseudo-i2c-adapter interface
+ *
+ * Copyright (C) 2005 Jean Delvare <khali@linux-fr.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _LINUX_I2C_ISA_H
+#define _LINUX_I2C_ISA_H
+
+#include <linux/i2c.h>
+
+extern int i2c_isa_add_driver(struct i2c_driver *driver);
+extern int i2c_isa_del_driver(struct i2c_driver *driver);
+
+/* Detect whether we are on the isa bus. This is only useful to hybrid
+   (i2c+isa) drivers. */
+#define i2c_is_isa_adapter(adapptr) \
+        ((adapptr)->id == I2C_HW_ISA)
+#define i2c_is_isa_client(clientptr) \
+        i2c_is_isa_adapter((clientptr)->adapter)
+
+#endif /* _LINUX_I2C_ISA_H */
diff --git a/include/linux/i2c-sensor.h b/include/linux/i2c-sensor.h
deleted file mode 100644 (file)
index 21b6252..0000000
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
-    i2c-sensor.h - Part of the i2c package
-    was originally sensors.h - Part of lm_sensors, Linux kernel modules
-                               for hardware monitoring
-    Copyright (c) 1998, 1999  Frodo Looijaard <frodol@dds.nl>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _LINUX_I2C_SENSOR_H
-#define _LINUX_I2C_SENSOR_H
-
-/* A structure containing detect information.
-   Force variables overrule all other variables; they force a detection on
-   that place. If a specific chip is given, the module blindly assumes this
-   chip type is present; if a general force (kind == 0) is given, the module
-   will still try to figure out what type of chip is present. This is useful
-   if for some reasons the detect for SMBus or ISA address space filled
-   fails.
-   probe: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END values.
-     A list of pairs. The first value is a bus number (ANY_I2C_ISA_BUS for
-     the ISA bus, -1 for any I2C bus), the second is the address. 
-   kind: The kind of chip. 0 equals any chip.
-*/
-struct i2c_force_data {
-       unsigned short *force;
-       unsigned short kind;
-};
-
-/* A structure containing the detect information.
-   normal_i2c: filled in by the module writer. Terminated by I2C_CLIENT_ISA_END.
-     A list of I2C addresses which should normally be examined.
-   normal_isa: filled in by the module writer. Terminated by SENSORS_ISA_END.
-     A list of ISA addresses which should normally be examined.
-   probe: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END values.
-     A list of pairs. The first value is a bus number (ANY_I2C_ISA_BUS for
-     the ISA bus, -1 for any I2C bus), the second is the address. These
-     addresses are also probed, as if they were in the 'normal' list.
-   ignore: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END values.
-     A list of pairs. The first value is a bus number (ANY_I2C_ISA_BUS for
-     the ISA bus, -1 for any I2C bus), the second is the I2C address. These
-     addresses are never probed. This parameter overrules 'normal' and 
-     'probe', but not the 'force' lists.
-   force_data: insmod parameters. A list, ending with an element of which
-     the force field is NULL.
-*/
-struct i2c_address_data {
-       unsigned short *normal_i2c;
-       unsigned int *normal_isa;
-       unsigned short *probe;
-       unsigned short *ignore;
-       struct i2c_force_data *forces;
-};
-
-#define SENSORS_MODULE_PARM_FORCE(name) \
-  I2C_CLIENT_MODULE_PARM(force_ ## name, \
-                      "List of adapter,address pairs which are unquestionably" \
-                      " assumed to contain a `" # name "' chip")
-
-
-/* This defines several insmod variables, and the addr_data structure */
-#define SENSORS_INSMOD \
-  I2C_CLIENT_MODULE_PARM(probe, \
-                      "List of adapter,address pairs to scan additionally"); \
-  I2C_CLIENT_MODULE_PARM(ignore, \
-                      "List of adapter,address pairs not to scan"); \
-       static struct i2c_address_data addr_data = {                    \
-                       .normal_i2c =           normal_i2c,             \
-                       .normal_isa =           normal_isa,             \
-                       .probe =                probe,                  \
-                       .ignore =               ignore,                 \
-                       .forces =               forces,                 \
-               }
-
-/* The following functions create an enum with the chip names as elements. 
-   The first element of the enum is any_chip. These are the only macros
-   a module will want to use. */
-
-#define SENSORS_INSMOD_0 \
-  enum chips { any_chip }; \
-  I2C_CLIENT_MODULE_PARM(force, \
-                      "List of adapter,address pairs to boldly assume " \
-                      "to be present"); \
-  static struct i2c_force_data forces[] = {{force,any_chip},{NULL}}; \
-  SENSORS_INSMOD
-
-#define SENSORS_INSMOD_1(chip1) \
-  enum chips { any_chip, chip1 }; \
-  I2C_CLIENT_MODULE_PARM(force, \
-                      "List of adapter,address pairs to boldly assume " \
-                      "to be present"); \
-  SENSORS_MODULE_PARM_FORCE(chip1); \
-  static struct i2c_force_data forces[] = {{force,any_chip},\
-                                                 {force_ ## chip1,chip1}, \
-                                                 {NULL}}; \
-  SENSORS_INSMOD
-
-#define SENSORS_INSMOD_2(chip1,chip2) \
-  enum chips { any_chip, chip1, chip2 }; \
-  I2C_CLIENT_MODULE_PARM(force, \
-                      "List of adapter,address pairs to boldly assume " \
-                      "to be present"); \
-  SENSORS_MODULE_PARM_FORCE(chip1); \
-  SENSORS_MODULE_PARM_FORCE(chip2); \
-  static struct i2c_force_data forces[] = {{force,any_chip}, \
-                                                 {force_ ## chip1,chip1}, \
-                                                 {force_ ## chip2,chip2}, \
-                                                 {NULL}}; \
-  SENSORS_INSMOD
-
-#define SENSORS_INSMOD_3(chip1,chip2,chip3) \
-  enum chips { any_chip, chip1, chip2, chip3 }; \
-  I2C_CLIENT_MODULE_PARM(force, \
-                      "List of adapter,address pairs to boldly assume " \
-                      "to be present"); \
-  SENSORS_MODULE_PARM_FORCE(chip1); \
-  SENSORS_MODULE_PARM_FORCE(chip2); \
-  SENSORS_MODULE_PARM_FORCE(chip3); \
-  static struct i2c_force_data forces[] = {{force,any_chip}, \
-                                                 {force_ ## chip1,chip1}, \
-                                                 {force_ ## chip2,chip2}, \
-                                                 {force_ ## chip3,chip3}, \
-                                                 {NULL}}; \
-  SENSORS_INSMOD
-
-#define SENSORS_INSMOD_4(chip1,chip2,chip3,chip4) \
-  enum chips { any_chip, chip1, chip2, chip3, chip4 }; \
-  I2C_CLIENT_MODULE_PARM(force, \
-                      "List of adapter,address pairs to boldly assume " \
-                      "to be present"); \
-  SENSORS_MODULE_PARM_FORCE(chip1); \
-  SENSORS_MODULE_PARM_FORCE(chip2); \
-  SENSORS_MODULE_PARM_FORCE(chip3); \
-  SENSORS_MODULE_PARM_FORCE(chip4); \
-  static struct i2c_force_data forces[] = {{force,any_chip}, \
-                                                 {force_ ## chip1,chip1}, \
-                                                 {force_ ## chip2,chip2}, \
-                                                 {force_ ## chip3,chip3}, \
-                                                 {force_ ## chip4,chip4}, \
-                                                 {NULL}}; \
-  SENSORS_INSMOD
-
-#define SENSORS_INSMOD_5(chip1,chip2,chip3,chip4,chip5) \
-  enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \
-  I2C_CLIENT_MODULE_PARM(force, \
-                      "List of adapter,address pairs to boldly assume " \
-                      "to be present"); \
-  SENSORS_MODULE_PARM_FORCE(chip1); \
-  SENSORS_MODULE_PARM_FORCE(chip2); \
-  SENSORS_MODULE_PARM_FORCE(chip3); \
-  SENSORS_MODULE_PARM_FORCE(chip4); \
-  SENSORS_MODULE_PARM_FORCE(chip5); \
-  static struct i2c_force_data forces[] = {{force,any_chip}, \
-                                                 {force_ ## chip1,chip1}, \
-                                                 {force_ ## chip2,chip2}, \
-                                                 {force_ ## chip3,chip3}, \
-                                                 {force_ ## chip4,chip4}, \
-                                                 {force_ ## chip5,chip5}, \
-                                                 {NULL}}; \
-  SENSORS_INSMOD
-
-#define SENSORS_INSMOD_6(chip1,chip2,chip3,chip4,chip5,chip6) \
-  enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \
-  I2C_CLIENT_MODULE_PARM(force, \
-                      "List of adapter,address pairs to boldly assume " \
-                      "to be present"); \
-  SENSORS_MODULE_PARM_FORCE(chip1); \
-  SENSORS_MODULE_PARM_FORCE(chip2); \
-  SENSORS_MODULE_PARM_FORCE(chip3); \
-  SENSORS_MODULE_PARM_FORCE(chip4); \
-  SENSORS_MODULE_PARM_FORCE(chip5); \
-  SENSORS_MODULE_PARM_FORCE(chip6); \
-  static struct i2c_force_data forces[] = {{force,any_chip}, \
-                                                 {force_ ## chip1,chip1}, \
-                                                 {force_ ## chip2,chip2}, \
-                                                 {force_ ## chip3,chip3}, \
-                                                 {force_ ## chip4,chip4}, \
-                                                 {force_ ## chip5,chip5}, \
-                                                 {force_ ## chip6,chip6}, \
-                                                 {NULL}}; \
-  SENSORS_INSMOD
-
-#define SENSORS_INSMOD_7(chip1,chip2,chip3,chip4,chip5,chip6,chip7) \
-  enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, chip7 }; \
-  I2C_CLIENT_MODULE_PARM(force, \
-                      "List of adapter,address pairs to boldly assume " \
-                      "to be present"); \
-  SENSORS_MODULE_PARM_FORCE(chip1); \
-  SENSORS_MODULE_PARM_FORCE(chip2); \
-  SENSORS_MODULE_PARM_FORCE(chip3); \
-  SENSORS_MODULE_PARM_FORCE(chip4); \
-  SENSORS_MODULE_PARM_FORCE(chip5); \
-  SENSORS_MODULE_PARM_FORCE(chip6); \
-  SENSORS_MODULE_PARM_FORCE(chip7); \
-  static struct i2c_force_data forces[] = {{force,any_chip}, \
-                                                 {force_ ## chip1,chip1}, \
-                                                 {force_ ## chip2,chip2}, \
-                                                 {force_ ## chip3,chip3}, \
-                                                 {force_ ## chip4,chip4}, \
-                                                 {force_ ## chip5,chip5}, \
-                                                 {force_ ## chip6,chip6}, \
-                                                 {force_ ## chip7,chip7}, \
-                                                 {NULL}}; \
-  SENSORS_INSMOD
-
-#define SENSORS_INSMOD_8(chip1,chip2,chip3,chip4,chip5,chip6,chip7,chip8) \
-  enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8 }; \
-  I2C_CLIENT_MODULE_PARM(force, \
-                      "List of adapter,address pairs to boldly assume " \
-                      "to be present"); \
-  SENSORS_MODULE_PARM_FORCE(chip1); \
-  SENSORS_MODULE_PARM_FORCE(chip2); \
-  SENSORS_MODULE_PARM_FORCE(chip3); \
-  SENSORS_MODULE_PARM_FORCE(chip4); \
-  SENSORS_MODULE_PARM_FORCE(chip5); \
-  SENSORS_MODULE_PARM_FORCE(chip6); \
-  SENSORS_MODULE_PARM_FORCE(chip7); \
-  SENSORS_MODULE_PARM_FORCE(chip8); \
-  static struct i2c_force_data forces[] = {{force,any_chip}, \
-                                                 {force_ ## chip1,chip1}, \
-                                                 {force_ ## chip2,chip2}, \
-                                                 {force_ ## chip3,chip3}, \
-                                                 {force_ ## chip4,chip4}, \
-                                                 {force_ ## chip5,chip5}, \
-                                                 {force_ ## chip6,chip6}, \
-                                                 {force_ ## chip7,chip7}, \
-                                                 {force_ ## chip8,chip8}, \
-                                                 {NULL}}; \
-  SENSORS_INSMOD
-
-/* Detect function. It iterates over all possible addresses itself. For
-   SMBus addresses, it will only call found_proc if some client is connected
-   to the SMBus (unless a 'force' matched); for ISA detections, this is not
-   done. */
-extern int i2c_detect(struct i2c_adapter *adapter,
-                     struct i2c_address_data *address_data,
-                     int (*found_proc) (struct i2c_adapter *, int, int));
-
-
-/* This macro is used to scale user-input to sensible values in almost all
-   chip drivers. */
-static inline int SENSORS_LIMIT(long value, long low, long high)
-{
-       if (value < low)
-               return low;
-       else if (value > high)
-               return high;
-       else
-               return value;
-}
-#endif                         /* def _LINUX_I2C_SENSOR_H */
diff --git a/include/linux/i2c-vid.h b/include/linux/i2c-vid.h
deleted file mode 100644 (file)
index 41d0635..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
-    i2c-vid.h - Part of lm_sensors, Linux kernel modules for hardware
-                monitoring
-    Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com>
-    With assistance from Trent Piepho <xyzzy@speakeasy.org>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-/*
-    This file contains common code for decoding VID pins.
-    This file is #included in various chip drivers in this directory.
-    As the user is unlikely to load more than one driver which
-    includes this code we don't worry about the wasted space.
-    Reference: VRM x.y DC-DC Converter Design Guidelines,
-    available at http://developer.intel.com
-*/
-
-/*
-    AMD Opteron processors don't follow the Intel VRM spec.
-    I'm going to "make up" 2.4 as the VRM spec for the Opterons.
-    No good reason just a mnemonic for the 24x Opteron processor
-    series
-
-    Opteron VID encoding is:
-
-       00000  =  1.550 V
-       00001  =  1.525 V
-        . . . .
-       11110  =  0.800 V
-       11111  =  0.000 V (off)
- */
-
-/*
-    Legal val values 0x00 - 0x1f; except for VRD 10.0, 0x00 - 0x3f.
-    vrm is the Intel VRM document version.
-    Note: vrm version is scaled by 10 and the return value is scaled by 1000
-    to avoid floating point in the kernel.
-*/
-
-int i2c_which_vrm(void);
-
-#define DEFAULT_VRM    82
-
-static inline int vid_from_reg(int val, int vrm)
-{
-       int vid;
-
-       switch(vrm) {
-
-       case  0:
-               return 0;
-
-       case 100:               /* VRD 10.0 */
-               if((val & 0x1f) == 0x1f)
-                       return 0;
-               if((val & 0x1f) <= 0x09 || val == 0x0a)
-                       vid = 10875 - (val & 0x1f) * 250;
-               else
-                       vid = 18625 - (val & 0x1f) * 250;
-               if(val & 0x20)
-                       vid -= 125;
-               vid /= 10;      /* only return 3 dec. places for now */
-               return vid;
-
-       case 24:                /* Opteron processor */
-               return(val == 0x1f ? 0 : 1550 - val * 25);
-
-       case 91:                /* VRM 9.1 */
-       case 90:                /* VRM 9.0 */
-               return(val == 0x1f ? 0 :
-                                      1850 - val * 25);
-
-       case 85:                /* VRM 8.5 */
-               return((val & 0x10  ? 25 : 0) +
-                      ((val & 0x0f) > 0x04 ? 2050 : 1250) -
-                      ((val & 0x0f) * 50));
-
-       case 84:                /* VRM 8.4 */
-               val &= 0x0f;
-                               /* fall through */
-       default:                /* VRM 8.2 */
-               return(val == 0x1f ? 0 :
-                      val & 0x10  ? 5100 - (val) * 100 :
-                                    2050 - (val) * 50);
-       }
-}
-
-static inline int vid_to_reg(int val, int vrm)
-{
-       switch (vrm) {
-       case 91:                /* VRM 9.1 */
-       case 90:                /* VRM 9.0 */
-               return ((val >= 1100) && (val <= 1850) ?
-                       ((18499 - val * 10) / 25 + 5) / 10 : -1);
-       default:
-               return -1;
-       }
-}
index be837b13f2978d027156ee7459c8453da6cdee15..be35332b67e64689f89094400d25fb0bce346b3a 100644 (file)
 #include <linux/device.h>      /* for struct device */
 #include <asm/semaphore.h>
 
+/* --- For i2c-isa ---------------------------------------------------- */
+
+extern void i2c_adapter_dev_release(struct device *dev);
+extern struct device_driver i2c_adapter_driver;
+extern struct class i2c_adapter_class;
+extern struct bus_type i2c_bus_type;
+
 /* --- General options ------------------------------------------------        */
 
 struct i2c_msg;
@@ -41,7 +48,6 @@ struct i2c_algorithm;
 struct i2c_adapter;
 struct i2c_client;
 struct i2c_driver;
-struct i2c_client_address_data;
 union i2c_smbus_data;
 
 /*
@@ -143,12 +149,9 @@ struct i2c_driver {
  */
 struct i2c_client {
        unsigned int flags;             /* div., see below              */
-       unsigned int addr;              /* chip address - NOTE: 7bit    */
+       unsigned short addr;            /* chip address - NOTE: 7bit    */
                                        /* addresses are stored in the  */
-                                       /* _LOWER_ 7 bits of this char  */
-       /* addr: unsigned int to make lm_sensors i2c-isa adapter work
-         more cleanly. It does not take any more memory space, due to
-         alignment considerations */
+                                       /* _LOWER_ 7 bits               */
        struct i2c_adapter *adapter;    /* the adapter we sit on        */
        struct i2c_driver *driver;      /* and our access routines      */
        int usage_count;                /* How many accesses currently  */
@@ -160,6 +163,11 @@ struct i2c_client {
 };
 #define to_i2c_client(d) container_of(d, struct i2c_client, dev)
 
+static inline struct i2c_client *kobj_to_i2c_client(struct kobject *kobj)
+{
+       return to_i2c_client(container_of(kobj, struct device, kobj));
+}
+
 static inline void *i2c_get_clientdata (struct i2c_client *dev)
 {
        return dev_get_drvdata (&dev->dev);
@@ -170,13 +178,6 @@ static inline void i2c_set_clientdata (struct i2c_client *dev, void *data)
        dev_set_drvdata (&dev->dev, data);
 }
 
-#define I2C_DEVNAME(str)       .name = str
-
-static inline char *i2c_clientname(struct i2c_client *c)
-{
-       return &c->name[0];
-}
-
 /*
  * The following structs are for those who like to implement new bus drivers:
  * i2c_algorithm is the interface to a class of hardware solutions which can
@@ -184,9 +185,6 @@ static inline char *i2c_clientname(struct i2c_client *c)
  * to name two of the most common.
  */
 struct i2c_algorithm {
-       char name[32];                          /* textual description  */
-       unsigned int id;
-
        /* If an adapter algorithm can't do I2C-level access, set master_xfer
           to NULL. If an adapter algorithm can do SMBus access, set 
           smbus_xfer. If set to NULL, the SMBus protocol is simulated
@@ -214,8 +212,7 @@ struct i2c_algorithm {
  */
 struct i2c_adapter {
        struct module *owner;
-       unsigned int id;/* == is algo->id | hwdep.struct->id,           */
-                       /* for registered values see below              */
+       unsigned int id;
        unsigned int class;
        struct i2c_algorithm *algo;/* the algorithm to access the bus   */
        void *algo_data;
@@ -292,12 +289,11 @@ struct i2c_client_address_data {
        unsigned short *normal_i2c;
        unsigned short *probe;
        unsigned short *ignore;
-       unsigned short *force;
+       unsigned short **forces;
 };
 
 /* Internal numbers to terminate lists */
 #define I2C_CLIENT_END         0xfffeU
-#define I2C_CLIENT_ISA_END     0xfffefffeU
 
 /* The numbers to use to set I2C bus address */
 #define ANY_I2C_BUS            0xffff
@@ -356,10 +352,6 @@ extern int i2c_probe(struct i2c_adapter *adapter,
  */
 extern int i2c_control(struct i2c_client *,unsigned int, unsigned long);
 
-/* This call returns a unique low identifier for each registered adapter,
- * or -1 if the adapter was not registered. 
- */
-extern int i2c_adapter_id(struct i2c_adapter *adap);
 extern struct i2c_adapter* i2c_get_adapter(int id);
 extern void i2c_put_adapter(struct i2c_adapter *adap);
 
@@ -376,6 +368,12 @@ static inline int i2c_check_functionality(struct i2c_adapter *adap, u32 func)
        return (func & i2c_get_functionality(adap)) == func;
 }
 
+/* Return id number for a specific adapter */
+static inline int i2c_adapter_id(struct i2c_adapter *adap)
+{
+       return adap->nr;
+}
+
 /*
  * I2C Message - used for pure i2c transaction, also from /dev interface
  */
@@ -510,9 +508,6 @@ union i2c_smbus_data {
 #define I2C_FUNCS      0x0705  /* Get the adapter functionality */
 #define I2C_RDWR       0x0707  /* Combined R/W transfer (one stop only)*/
 #define I2C_PEC                0x0708  /* != 0 for SMBus PEC                   */
-#if 0
-#define I2C_ACK_TEST   0x0710  /* See if a slave is at a specific address */
-#endif
 
 #define I2C_SMBUS      0x0720  /* SMBus-level access */
 
@@ -556,27 +551,148 @@ union i2c_smbus_data {
   module_param_array(var, short, &var##_num, 0); \
   MODULE_PARM_DESC(var,desc)
 
-/* This is the one you want to use in your own modules */
+#define I2C_CLIENT_MODULE_PARM_FORCE(name)                             \
+I2C_CLIENT_MODULE_PARM(force_##name,                                   \
+                      "List of adapter,address pairs which are "       \
+                      "unquestionably assumed to contain a `"          \
+                      # name "' chip")
+
+
+#define I2C_CLIENT_INSMOD_COMMON                                       \
+I2C_CLIENT_MODULE_PARM(probe, "List of adapter,address pairs to scan " \
+                      "additionally");                                 \
+I2C_CLIENT_MODULE_PARM(ignore, "List of adapter,address pairs not to " \
+                      "scan");                                         \
+static struct i2c_client_address_data addr_data = {                    \
+       .normal_i2c     = normal_i2c,                                   \
+       .probe          = probe,                                        \
+       .ignore         = ignore,                                       \
+       .forces         = forces,                                       \
+}
+
+/* These are the ones you want to use in your own drivers. Pick the one
+   which matches the number of devices the driver differenciates between. */
 #define I2C_CLIENT_INSMOD \
-  I2C_CLIENT_MODULE_PARM(probe, \
-                      "List of adapter,address pairs to scan additionally"); \
-  I2C_CLIENT_MODULE_PARM(ignore, \
-                      "List of adapter,address pairs not to scan"); \
   I2C_CLIENT_MODULE_PARM(force, \
                       "List of adapter,address pairs to boldly assume " \
                       "to be present"); \
-       static struct i2c_client_address_data addr_data = {             \
-                       .normal_i2c =           normal_i2c,             \
-                       .probe =                probe,                  \
-                       .ignore =               ignore,                 \
-                       .force =                force,                  \
-               }
-
-/* Detect whether we are on the isa bus. If this returns true, all i2c
-   access will fail! */
-#define i2c_is_isa_client(clientptr) \
-        ((clientptr)->adapter->algo->id == I2C_ALGO_ISA)
-#define i2c_is_isa_adapter(adapptr) \
-        ((adapptr)->algo->id == I2C_ALGO_ISA)
+       static unsigned short *forces[] = {                             \
+                       force,                                          \
+                       NULL                                            \
+               };                                                      \
+I2C_CLIENT_INSMOD_COMMON
+
+#define I2C_CLIENT_INSMOD_1(chip1)                                     \
+enum chips { any_chip, chip1 };                                                \
+I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to "      \
+                      "boldly assume to be present");                  \
+I2C_CLIENT_MODULE_PARM_FORCE(chip1);                                   \
+static unsigned short *forces[] = { force, force_##chip1, NULL };      \
+I2C_CLIENT_INSMOD_COMMON
+
+#define I2C_CLIENT_INSMOD_2(chip1, chip2)                              \
+enum chips { any_chip, chip1, chip2 };                                 \
+I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to "      \
+                      "boldly assume to be present");                  \
+I2C_CLIENT_MODULE_PARM_FORCE(chip1);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip2);                                   \
+static unsigned short *forces[] = { force, force_##chip1,              \
+                                   force_##chip2, NULL };              \
+I2C_CLIENT_INSMOD_COMMON
+
+#define I2C_CLIENT_INSMOD_3(chip1, chip2, chip3)                       \
+enum chips { any_chip, chip1, chip2, chip3 };                          \
+I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to "      \
+                      "boldly assume to be present");                  \
+I2C_CLIENT_MODULE_PARM_FORCE(chip1);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip2);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip3);                                   \
+static unsigned short *forces[] = { force, force_##chip1,              \
+                                   force_##chip2, force_##chip3,       \
+                                   NULL };                             \
+I2C_CLIENT_INSMOD_COMMON
+
+#define I2C_CLIENT_INSMOD_4(chip1, chip2, chip3, chip4)                        \
+enum chips { any_chip, chip1, chip2, chip3, chip4 };                   \
+I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to "      \
+                      "boldly assume to be present");                  \
+I2C_CLIENT_MODULE_PARM_FORCE(chip1);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip2);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip3);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip4);                                   \
+static unsigned short *forces[] = { force, force_##chip1,              \
+                                   force_##chip2, force_##chip3,       \
+                                   force_##chip4, NULL};               \
+I2C_CLIENT_INSMOD_COMMON
+
+#define I2C_CLIENT_INSMOD_5(chip1, chip2, chip3, chip4, chip5)         \
+enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 };            \
+I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to "      \
+                      "boldly assume to be present");                  \
+I2C_CLIENT_MODULE_PARM_FORCE(chip1);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip2);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip3);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip4);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip5);                                   \
+static unsigned short *forces[] = { force, force_##chip1,              \
+                                   force_##chip2, force_##chip3,       \
+                                   force_##chip4, force_##chip5,       \
+                                   NULL };                             \
+I2C_CLIENT_INSMOD_COMMON
+
+#define I2C_CLIENT_INSMOD_6(chip1, chip2, chip3, chip4, chip5, chip6)  \
+enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 };     \
+I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to "      \
+                      "boldly assume to be present");                  \
+I2C_CLIENT_MODULE_PARM_FORCE(chip1);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip2);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip3);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip4);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip5);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip6);                                   \
+static unsigned short *forces[] = { force, force_##chip1,              \
+                                   force_##chip2, force_##chip3,       \
+                                   force_##chip4, force_##chip5,       \
+                                   force_##chip6, NULL };              \
+I2C_CLIENT_INSMOD_COMMON
+
+#define I2C_CLIENT_INSMOD_7(chip1, chip2, chip3, chip4, chip5, chip6, chip7) \
+enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6,       \
+            chip7 };                                                   \
+I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to "      \
+                      "boldly assume to be present");                  \
+I2C_CLIENT_MODULE_PARM_FORCE(chip1);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip2);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip3);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip4);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip5);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip6);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip7);                                   \
+static unsigned short *forces[] = { force, force_##chip1,              \
+                                   force_##chip2, force_##chip3,       \
+                                   force_##chip4, force_##chip5,       \
+                                   force_##chip6, force_##chip7,       \
+                                   NULL };                             \
+I2C_CLIENT_INSMOD_COMMON
+
+#define I2C_CLIENT_INSMOD_8(chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8) \
+enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6,       \
+            chip7, chip8 };                                            \
+I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to "      \
+                      "boldly assume to be present");                  \
+I2C_CLIENT_MODULE_PARM_FORCE(chip1);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip2);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip3);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip4);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip5);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip6);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip7);                                   \
+I2C_CLIENT_MODULE_PARM_FORCE(chip8);                                   \
+static unsigned short *forces[] = { force, force_##chip1,              \
+                                   force_##chip2, force_##chip3,       \
+                                   force_##chip4, force_##chip5,       \
+                                   force_##chip6, force_##chip7,       \
+                                   force_##chip8, NULL };              \
+I2C_CLIENT_INSMOD_COMMON
 
 #endif /* _LINUX_I2C_H */
index 096a85a58ae5e4919e8379c8763d2c0f50e5887c..88aef7b86ef43be6b5b2408aa233f559fa88c115 100644 (file)
@@ -77,6 +77,7 @@ struct tun_struct {
 #define TUNSETIFF     _IOW('T', 202, int) 
 #define TUNSETPERSIST _IOW('T', 203, int) 
 #define TUNSETOWNER   _IOW('T', 204, int)
+#define TUNSETLINK    _IOW('T', 205, int)
 
 /* TUNSETIFF ifr flags */
 #define IFF_TUN                0x0001
index eebf5e5696ec3b31323303a354026507b54ded52..c4d1fae4dd89a5a74ba95b1f8b8d6cd21a9edb1f 100644 (file)
@@ -9,6 +9,9 @@
  *     This file is rleased under the GPL v2.
  */
 
+#ifndef _LINUX_KLIST_H
+#define _LINUX_KLIST_H
+
 #include <linux/spinlock.h>
 #include <linux/completion.h>
 #include <linux/kref.h>
@@ -31,8 +34,8 @@ struct klist_node {
        struct completion       n_removed;
 };
 
-extern void klist_add_tail(struct klist * k, struct klist_node * n);
-extern void klist_add_head(struct klist * k, struct klist_node * n);
+extern void klist_add_tail(struct klist_node * n, struct klist * k);
+extern void klist_add_head(struct klist_node * n, struct klist * k);
 
 extern void klist_del(struct klist_node * n);
 extern void klist_remove(struct klist_node * n);
@@ -53,3 +56,4 @@ extern void klist_iter_init_node(struct klist * k, struct klist_iter * i,
 extern void klist_iter_exit(struct klist_iter * i);
 extern struct klist_node * klist_next(struct klist_iter * i);
 
+#endif
index fc05a989928898c91b4800647aa21d228cd5e5a7..022105c745fcca5cf9de0322f7dc9b69fe3940a4 100644 (file)
@@ -40,7 +40,6 @@
 #undef ATA_VERBOSE_DEBUG       /* yet more debugging output */
 #undef ATA_IRQ_TRAP            /* define to ack screaming irqs */
 #undef ATA_NDEBUG              /* define to disable quick runtime checks */
-#undef ATA_ENABLE_ATAPI                /* define to enable ATAPI support */
 #undef ATA_ENABLE_PATA         /* define to enable PATA support in some
                                 * low-level drivers */
 #undef ATAPI_ENABLE_DMADIR     /* enables ATAPI DMADIR bridge support */
@@ -450,6 +449,7 @@ struct pci_bits {
        unsigned long           val;
 };
 
+extern void ata_pci_host_stop (struct ata_host_set *host_set);
 extern struct ata_probe_ent *
 ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port);
 extern int pci_test_config_bits(struct pci_dev *pdev, struct pci_bits *bits);
index 8480aef10e62fa41d986751a651ffd090db4ceb7..94a46f38c5326f8a337c256e7ba6d209951e7a6b 100644 (file)
@@ -150,6 +150,9 @@ void mpol_free_shared_policy(struct shared_policy *p);
 struct mempolicy *mpol_shared_policy_lookup(struct shared_policy *sp,
                                            unsigned long idx);
 
+struct mempolicy *get_vma_policy(struct task_struct *task,
+                       struct vm_area_struct *vma, unsigned long addr);
+
 extern void numa_default_policy(void);
 extern void numa_policy_init(void);
 
index 9a0893f3249e8b2869d24c6e52e7c1799c8ff7bb..30f68c0c8c6ebfa5b3c2cfe9b51aca76c86159fa 100644 (file)
@@ -46,6 +46,12 @@ struct mmc_ios {
 #define MMC_BUSMODE_OPENDRAIN  1
 #define MMC_BUSMODE_PUSHPULL   2
 
+       unsigned char   chip_select;            /* SPI chip select */
+
+#define MMC_CS_DONTCARE                0
+#define MMC_CS_HIGH            1
+#define MMC_CS_LOW             2
+
        unsigned char   power_mode;             /* power supply mode */
 
 #define MMC_POWER_OFF          0
index 6c90461ed99fd5707c178d3b4fbf922b367b55b0..5ed471b58f4f0c83904101ee6cb734bb104a47ad 100644 (file)
@@ -487,11 +487,27 @@ struct mem_section {
        unsigned long section_mem_map;
 };
 
-extern struct mem_section mem_section[NR_MEM_SECTIONS];
+#ifdef CONFIG_SPARSEMEM_EXTREME
+#define SECTIONS_PER_ROOT       (PAGE_SIZE / sizeof (struct mem_section))
+#else
+#define SECTIONS_PER_ROOT      1
+#endif
+
+#define SECTION_NR_TO_ROOT(sec)        ((sec) / SECTIONS_PER_ROOT)
+#define NR_SECTION_ROOTS       (NR_MEM_SECTIONS / SECTIONS_PER_ROOT)
+#define SECTION_ROOT_MASK      (SECTIONS_PER_ROOT - 1)
+
+#ifdef CONFIG_SPARSEMEM_EXTREME
+extern struct mem_section *mem_section[NR_SECTION_ROOTS];
+#else
+extern struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT];
+#endif
 
 static inline struct mem_section *__nr_to_section(unsigned long nr)
 {
-       return &mem_section[nr];
+       if (!mem_section[SECTION_NR_TO_ROOT(nr)])
+               return NULL;
+       return &mem_section[SECTION_NR_TO_ROOT(nr)][nr & SECTION_ROOT_MASK];
 }
 
 /*
@@ -513,12 +529,12 @@ static inline struct page *__section_mem_map_addr(struct mem_section *section)
 
 static inline int valid_section(struct mem_section *section)
 {
-       return (section->section_mem_map & SECTION_MARKED_PRESENT);
+       return (section && (section->section_mem_map & SECTION_MARKED_PRESENT));
 }
 
 static inline int section_has_mem_map(struct mem_section *section)
 {
-       return (section->section_mem_map & SECTION_HAS_MEM_MAP);
+       return (section && (section->section_mem_map & SECTION_HAS_MEM_MAP));
 }
 
 static inline int valid_section_nr(unsigned long nr)
@@ -572,6 +588,7 @@ static inline int pfn_valid(unsigned long pfn)
 void sparse_init(void);
 #else
 #define sparse_init()  do {} while (0)
+#define sparse_index_init(_sec, _nid)  do {} while (0)
 #endif /* CONFIG_SPARSEMEM */
 
 #ifdef CONFIG_NODES_SPAN_OTHER_NODES
index 5773ea42f6e445b406e44abe9197370be24dc132..0b08cd6922012589a938209b240a27f7bb898580 100644 (file)
 /* I2C Registers                        */
 /****************************************/
 
-#define MV64XXX_I2C_CTLR_NAME                                  "mv64xxx i2c"
+#define MV64XXX_I2C_CTLR_NAME                                  "mv64xxx_i2c"
 #define MV64XXX_I2C_OFFSET                                          0xc000
 #define MV64XXX_I2C_REG_BLOCK_SIZE                                  0x0020
 
index f5a6695d4d21335dddf2aa0da868c31fad454270..f34767c5fc79e7a5ecee1676e72b4ebf84296aa2 100644 (file)
@@ -134,6 +134,7 @@ struct page_state {
 };
 
 extern void get_page_state(struct page_state *ret);
+extern void get_page_state_node(struct page_state *ret, int node);
 extern void get_full_page_state(struct page_state *ret);
 extern unsigned long __read_page_state(unsigned long offset);
 extern void __mod_page_state(unsigned long offset, unsigned long delta);
@@ -194,6 +195,7 @@ extern void __mod_page_state(unsigned long offset, unsigned long delta);
 #define SetPageDirty(page)     set_bit(PG_dirty, &(page)->flags)
 #define TestSetPageDirty(page) test_and_set_bit(PG_dirty, &(page)->flags)
 #define ClearPageDirty(page)   clear_bit(PG_dirty, &(page)->flags)
+#define __ClearPageDirty(page) __clear_bit(PG_dirty, &(page)->flags)
 #define TestClearPageDirty(page) test_and_clear_bit(PG_dirty, &(page)->flags)
 
 #define SetPageLRU(page)       set_bit(PG_lru, &(page)->flags)
index d513c1634006bb1d6eb2c6b30f10a871edff164d..95c941f8c747cd37e83264096e81a27776f2101c 100644 (file)
 #define PCI_DEVICE_ID_ENE_1420         0x1420
 #define PCI_VENDOR_ID_CHELSIO          0x1425
 
+#define PCI_VENDOR_ID_MIPS             0x153f
+#define PCI_DEVICE_ID_SOC_IT           0x0001
+
 #define PCI_VENDOR_ID_SYBA             0x1592
 #define PCI_DEVICE_ID_SYBA_2P_EPP      0x0782
 #define PCI_DEVICE_ID_SYBA_1P_ECP      0x0783
index 7aeb208ed71357ad3a15891ea536021545fba48d..5cfb07648eca1c999403bc17e2f15ea14e125286 100644 (file)
@@ -186,7 +186,9 @@ extern int pm_suspend(suspend_state_t state);
 
 struct device;
 
-typedef u32 __bitwise pm_message_t;
+typedef struct pm_message {
+       int event;
+} pm_message_t;
 
 /*
  * There are 4 important states driver can be in:
@@ -207,9 +209,13 @@ typedef u32 __bitwise pm_message_t;
  * or something similar soon.
  */
 
-#define PMSG_FREEZE    ((__force pm_message_t) 3)
-#define PMSG_SUSPEND   ((__force pm_message_t) 3)
-#define PMSG_ON                ((__force pm_message_t) 0)
+#define PM_EVENT_ON 0
+#define PM_EVENT_FREEZE 1
+#define PM_EVENT_SUSPEND 2
+
+#define PMSG_FREEZE    ((struct pm_message){ .event = PM_EVENT_FREEZE, })
+#define PMSG_SUSPEND   ((struct pm_message){ .event = PM_EVENT_SUSPEND, })
+#define PMSG_ON                ((struct pm_message){ .event = PM_EVENT_ON, })
 
 struct dev_pm_info {
        pm_message_t            power_state;
index a373fc254df29431c52c2a879a67e766d9e3133c..2afdafb62123c212d0b6366a210078d38760ba81 100644 (file)
@@ -20,6 +20,8 @@
 #define PTRACE_DETACH          0x11
 
 #define PTRACE_SYSCALL           24
+#define PTRACE_SYSEMU            31
+#define PTRACE_SYSEMU_SINGLESTEP  32
 
 /* 0x4200-0x4300 are reserved for architecture-independent additions.  */
 #define PTRACE_SETOPTIONS      0x4200
index 9f2d85284d0b78f95cba741c51d63f9545a61be1..12cd9cf65e8ffe3b6a2b58042336a8e11d5092ef 100644 (file)
@@ -176,10 +176,6 @@ struct serial_icounter_struct {
 #ifdef __KERNEL__
 #include <linux/compiler.h>
 
-/* Export to allow PCMCIA to use this - Dave Hinds */
-extern int __deprecated register_serial(struct serial_struct *req);
-extern void __deprecated unregister_serial(int line);
-
 /* Allow architectures to override entries in serial8250_ports[] at run time: */
 struct uart_port;      /* forward declaration */
 extern int early_serial_setup(struct uart_port *port);
index 3e3c1fa35b06cc2eafa509f2cf1d2b4dcf04e7e4..d8a023d804d4606810e5f79b969cc2fad14c69e9 100644 (file)
@@ -14,6 +14,9 @@
 #include <linux/serial_core.h>
 #include <linux/device.h>
 
+/*
+ * This is the platform device platform_data structure
+ */
 struct plat_serial8250_port {
        unsigned long   iobase;         /* io base address */
        void __iomem    *membase;       /* ioremap cookie or NULL */
@@ -26,4 +29,17 @@ struct plat_serial8250_port {
        unsigned int    flags;          /* UPF_* flags */
 };
 
+/*
+ * This should be used by drivers which want to register
+ * their own 8250 ports without registering their own
+ * platform device.  Using these will make your driver
+ * dependent on the 8250 driver.
+ */
+struct uart_port;
+
+int serial8250_register_port(struct uart_port *);
+void serial8250_unregister_port(int line);
+void serial8250_suspend_port(int line);
+void serial8250_resume_port(int line);
+
 #endif
index f6fca8f2f3cac00fd24c0774ebcd8891e6c043d3..cf0f64ea2bc0d36eb742c41c7db0e966525a0685 100644 (file)
@@ -142,8 +142,8 @@ struct uart_ops {
        unsigned int    (*tx_empty)(struct uart_port *);
        void            (*set_mctrl)(struct uart_port *, unsigned int mctrl);
        unsigned int    (*get_mctrl)(struct uart_port *);
-       void            (*stop_tx)(struct uart_port *, unsigned int tty_stop);
-       void            (*start_tx)(struct uart_port *, unsigned int tty_start);
+       void            (*stop_tx)(struct uart_port *);
+       void            (*start_tx)(struct uart_port *);
        void            (*send_xchar)(struct uart_port *, char ch);
        void            (*stop_rx)(struct uart_port *);
        void            (*enable_ms)(struct uart_port *);
@@ -360,8 +360,6 @@ struct tty_driver *uart_console_device(struct console *co, int *index);
  */
 int uart_register_driver(struct uart_driver *uart);
 void uart_unregister_driver(struct uart_driver *uart);
-void __deprecated uart_unregister_port(struct uart_driver *reg, int line);
-int __deprecated uart_register_port(struct uart_driver *reg, struct uart_port *port);
 int uart_add_one_port(struct uart_driver *reg, struct uart_port *port);
 int uart_remove_one_port(struct uart_driver *reg, struct uart_port *port);
 int uart_match_port(struct uart_port *port1, struct uart_port *port2);
@@ -468,13 +466,13 @@ uart_handle_cts_change(struct uart_port *port, unsigned int status)
                if (tty->hw_stopped) {
                        if (status) {
                                tty->hw_stopped = 0;
-                               port->ops->start_tx(port, 0);
+                               port->ops->start_tx(port);
                                uart_write_wakeup(port);
                        }
                } else {
                        if (!status) {
                                tty->hw_stopped = 1;
-                               port->ops->stop_tx(port, 0);
+                               port->ops->stop_tx(port);
                        }
                }
        }
index bfe3e763ccf283d6bc680877aa2f11a658c04afd..3c9ff00481533a77b11561f9b11db877ac937343 100644 (file)
@@ -107,6 +107,8 @@ enum {
        SWP_USED        = (1 << 0),     /* is slot in swap_info[] used? */
        SWP_WRITEOK     = (1 << 1),     /* ok to write to this swap?    */
        SWP_ACTIVE      = (SWP_USED | SWP_WRITEOK),
+                                       /* add others here before... */
+       SWP_SCANNING    = (1 << 8),     /* refcount in scan_swap_map */
 };
 
 #define SWAP_CLUSTER_MAX 32
@@ -116,16 +118,13 @@ enum {
 
 /*
  * The in-memory structure used to track swap areas.
- * extent_list.prev points at the lowest-index extent.  That list is
- * sorted.
  */
 struct swap_info_struct {
        unsigned int flags;
-       spinlock_t sdev_lock;
+       int prio;                       /* swap priority */
        struct file *swap_file;
        struct block_device *bdev;
        struct list_head extent_list;
-       int nr_extents;
        struct swap_extent *curr_swap_extent;
        unsigned old_block_size;
        unsigned short * swap_map;
@@ -133,10 +132,9 @@ struct swap_info_struct {
        unsigned int highest_bit;
        unsigned int cluster_next;
        unsigned int cluster_nr;
-       int prio;                       /* swap priority */
-       int pages;
-       unsigned long max;
-       unsigned long inuse_pages;
+       unsigned int pages;
+       unsigned int max;
+       unsigned int inuse_pages;
        int next;                       /* next entry on swap list */
 };
 
@@ -222,13 +220,7 @@ extern int can_share_swap_page(struct page *);
 extern int remove_exclusive_swap_page(struct page *);
 struct backing_dev_info;
 
-extern struct swap_list_t swap_list;
-extern spinlock_t swaplock;
-
-#define swap_list_lock()       spin_lock(&swaplock)
-#define swap_list_unlock()     spin_unlock(&swaplock)
-#define swap_device_lock(p)    spin_lock(&p->sdev_lock)
-#define swap_device_unlock(p)  spin_unlock(&p->sdev_lock)
+extern spinlock_t swap_lock;
 
 /* linux/mm/thrash.c */
 extern struct mm_struct * swap_token_mm;
index d4c7db35e7081495cc556eb7b4dae17a6380e1b9..87b9d14c710db69217e2eac3a18c903ca772a254 100644 (file)
@@ -4,7 +4,7 @@
  * the low-order bits.
  *
  * We arrange the `type' and `offset' fields so that `type' is at the five
- * high-order bits of the smp_entry_t and `offset' is right-aligned in the
+ * high-order bits of the swp_entry_t and `offset' is right-aligned in the
  * remaining bits.
  *
  * swp_entry_t's are *never* stored anywhere in their arch-dependent format.
index 6409d9cf59659d8377d140e205a4a6099e8b4277..b244f69ef682e2d4f8bd4d768584990bc64dff34 100644 (file)
 #define VM_MAP         0x00000004      /* vmap()ed pages */
 /* bits [20..32] reserved for arch specific ioremap internals */
 
+/*
+ * Maximum alignment for ioremap() regions.
+ * Can be overriden by arch-specific value.
+ */
+#ifndef IOREMAP_MAX_ORDER
+#define IOREMAP_MAX_ORDER      (7 + PAGE_SHIFT)        /* 128 pages */
+#endif
+
 struct vm_struct {
        void                    *addr;
        unsigned long           size;
index a39a6423914bc553f8b79e9139ba7221c0710380..801ddef301aa374e16008b29ab139f165fd3def3 100644 (file)
@@ -34,8 +34,3 @@
 #ifndef  I2C_DRIVERID_SAA6752HS
 # define I2C_DRIVERID_SAA6752HS I2C_DRIVERID_EXP0+8
 #endif
-
-/* algorithms */
-#ifndef I2C_ALGO_SAA7134
-# define I2C_ALGO_SAA7134 0x090000
-#endif
index db09580ad14b8031ee17cce1e38272453817b877..dc36b1be6745ac7c8b2e8e28810b9b99bc49de66 100644 (file)
  */
 #ifndef IEEE80211_H
 #define IEEE80211_H
-
 #include <linux/if_ether.h> /* ETH_ALEN */
 #include <linux/kernel.h>   /* ARRAY_SIZE */
-
-#if WIRELESS_EXT < 17
-#define IW_QUAL_QUAL_INVALID   0x10
-#define IW_QUAL_LEVEL_INVALID  0x20
-#define IW_QUAL_NOISE_INVALID  0x40
-#define IW_QUAL_QUAL_UPDATED   0x1
-#define IW_QUAL_LEVEL_UPDATED  0x2
-#define IW_QUAL_NOISE_UPDATED  0x4
-#endif
+#include <linux/wireless.h>
 
 #define IEEE80211_DATA_LEN             2304
 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
 #define IEEE80211_FRAME_LEN            (IEEE80211_DATA_LEN + IEEE80211_HLEN)
 
 struct ieee80211_hdr {
-       u16 frame_ctl;
-       u16 duration_id;
+       __le16 frame_ctl;
+       __le16 duration_id;
        u8 addr1[ETH_ALEN];
        u8 addr2[ETH_ALEN];
        u8 addr3[ETH_ALEN];
-       u16 seq_ctl;
+       __le16 seq_ctl;
        u8 addr4[ETH_ALEN];
 } __attribute__ ((packed));
 
 struct ieee80211_hdr_3addr {
-       u16 frame_ctl;
-       u16 duration_id;
+       __le16 frame_ctl;
+       __le16 duration_id;
        u8 addr1[ETH_ALEN];
        u8 addr2[ETH_ALEN];
        u8 addr3[ETH_ALEN];
-       u16 seq_ctl;
-} __attribute__ ((packed));
-
-enum eap_type {
-       EAP_PACKET = 0,
-       EAPOL_START,
-       EAPOL_LOGOFF,
-       EAPOL_KEY,
-       EAPOL_ENCAP_ASF_ALERT
-};
-
-static const char *eap_types[] = {
-       [EAP_PACKET]            = "EAP-Packet",
-       [EAPOL_START]           = "EAPOL-Start",
-       [EAPOL_LOGOFF]          = "EAPOL-Logoff",
-       [EAPOL_KEY]             = "EAPOL-Key",
-       [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
-};
-
-static inline const char *eap_get_type(int type)
-{
-       return (type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type];
-}
-
-struct eapol {
-       u8 snap[6];
-       u16 ethertype;
-       u8 version;
-       u8 type;
-       u16 length;
+       __le16 seq_ctl;
 } __attribute__ ((packed));
 
 #define IEEE80211_1ADDR_LEN 10
@@ -104,7 +66,7 @@ struct eapol {
 #define        MAX_FRAG_THRESHOLD     2346U
 
 /* Frame control field constants */
-#define IEEE80211_FCTL_VERS            0x0002
+#define IEEE80211_FCTL_VERS            0x0003
 #define IEEE80211_FCTL_FTYPE           0x000c
 #define IEEE80211_FCTL_STYPE           0x00f0
 #define IEEE80211_FCTL_TODS            0x0100
@@ -112,8 +74,8 @@ struct eapol {
 #define IEEE80211_FCTL_MOREFRAGS       0x0400
 #define IEEE80211_FCTL_RETRY           0x0800
 #define IEEE80211_FCTL_PM              0x1000
-#define IEEE80211_FCTL_MOREDATA        0x2000
-#define IEEE80211_FCTL_WEP             0x4000
+#define IEEE80211_FCTL_MOREDATA                0x2000
+#define IEEE80211_FCTL_PROTECTED       0x4000
 #define IEEE80211_FCTL_ORDER           0x8000
 
 #define IEEE80211_FTYPE_MGMT           0x0000
@@ -132,6 +94,7 @@ struct eapol {
 #define IEEE80211_STYPE_DISASSOC       0x00A0
 #define IEEE80211_STYPE_AUTH           0x00B0
 #define IEEE80211_STYPE_DEAUTH         0x00C0
+#define IEEE80211_STYPE_ACTION         0x00D0
 
 /* control */
 #define IEEE80211_STYPE_PSPOLL         0x00A0
@@ -167,8 +130,19 @@ do { if (ieee80211_debug_level & (level)) \
 #define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
 #endif /* CONFIG_IEEE80211_DEBUG */
 
+
+/* debug macros not dependent on CONFIG_IEEE80211_DEBUG */
+
+#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
+#define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
+
+/* escape_essid() is intended to be used in debug (and possibly error)
+ * messages. It should never be used for passing essid to user space. */
+const char *escape_essid(const char *essid, u8 essid_len);
+
+
 /*
- * To use the debug system;
+ * To use the debug system:
  *
  * If you are defining a new debug classification, simply add it to the #define
  * list here in the form of:
@@ -184,11 +158,11 @@ do { if (ieee80211_debug_level & (level)) \
  *
  * To add your debug level to the list of levels seen when you perform
  *
- * % cat /proc/net/ipw/debug_level
+ * % cat /proc/net/ieee80211/debug_level
  *
- * you simply need to add your entry to the ipw_debug_levels array.
+ * you simply need to add your entry to the ieee80211_debug_level array.
  *
- * If you do not see debug_level in /proc/net/ipw then you do not have
+ * If you do not see debug_level in /proc/net/ieee80211 then you do not have
  * CONFIG_IEEE80211_DEBUG defined in your kernel configuration
  *
  */
@@ -199,7 +173,6 @@ do { if (ieee80211_debug_level & (level)) \
 #define IEEE80211_DL_STATE         (1<<3)
 #define IEEE80211_DL_MGMT          (1<<4)
 #define IEEE80211_DL_FRAG          (1<<5)
-#define IEEE80211_DL_EAP           (1<<6)
 #define IEEE80211_DL_DROP          (1<<7)
 
 #define IEEE80211_DL_TX            (1<<8)
@@ -214,7 +187,6 @@ do { if (ieee80211_debug_level & (level)) \
 #define IEEE80211_DEBUG_STATE(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a)
 #define IEEE80211_DEBUG_MGMT(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a)
 #define IEEE80211_DEBUG_FRAG(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a)
-#define IEEE80211_DEBUG_EAP(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_EAP, f, ## a)
 #define IEEE80211_DEBUG_DROP(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a)
 #define IEEE80211_DEBUG_TX(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a)
 #define IEEE80211_DEBUG_RX(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
@@ -223,9 +195,9 @@ do { if (ieee80211_debug_level & (level)) \
 #include <linux/if_arp.h> /* ARPHRD_ETHER */
 
 #ifndef WIRELESS_SPY
-#define WIRELESS_SPY           // enable iwspy support
+#define WIRELESS_SPY           /* enable iwspy support */
 #endif
-#include <net/iw_handler.h>    // new driver API
+#include <net/iw_handler.h>    /* new driver API */
 
 #ifndef ETH_P_PAE
 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
@@ -252,6 +224,7 @@ struct ieee80211_snap_hdr {
 
 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
 
+#define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
 
@@ -264,7 +237,7 @@ struct ieee80211_snap_hdr {
 
 #define WLAN_AUTH_CHALLENGE_LEN 128
 
-#define WLAN_CAPABILITY_BSS (1<<0)
+#define WLAN_CAPABILITY_ESS (1<<0)
 #define WLAN_CAPABILITY_IBSS (1<<1)
 #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
 #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
@@ -272,34 +245,72 @@ struct ieee80211_snap_hdr {
 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
 #define WLAN_CAPABILITY_PBCC (1<<6)
 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
+#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
+#define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
+#define WLAN_CAPABILITY_OSSS_OFDM (1<<13)
 
 /* Status codes */
-#define WLAN_STATUS_SUCCESS 0
-#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
-#define WLAN_STATUS_CAPS_UNSUPPORTED 10
-#define WLAN_STATUS_REASSOC_NO_ASSOC 11
-#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
-#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
-#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
-#define WLAN_STATUS_CHALLENGE_FAIL 15
-#define WLAN_STATUS_AUTH_TIMEOUT 16
-#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
-#define WLAN_STATUS_ASSOC_DENIED_RATES 18
-/* 802.11b */
-#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
-#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
-#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
+enum ieee80211_statuscode {
+       WLAN_STATUS_SUCCESS = 0,
+       WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
+       WLAN_STATUS_CAPS_UNSUPPORTED = 10,
+       WLAN_STATUS_REASSOC_NO_ASSOC = 11,
+       WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
+       WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
+       WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
+       WLAN_STATUS_CHALLENGE_FAIL = 15,
+       WLAN_STATUS_AUTH_TIMEOUT = 16,
+       WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
+       WLAN_STATUS_ASSOC_DENIED_RATES = 18,
+       /* 802.11b */
+       WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
+       WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
+       WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
+       /* 802.11h */
+       WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
+       WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
+       WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
+       /* 802.11g */
+       WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
+       WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
+       /* 802.11i */
+       WLAN_STATUS_INVALID_IE = 40,
+       WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
+       WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
+       WLAN_STATUS_INVALID_AKMP = 43,
+       WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
+       WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
+       WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
+};
 
 /* Reason codes */
-#define WLAN_REASON_UNSPECIFIED 1
-#define WLAN_REASON_PREV_AUTH_NOT_VALID 2
-#define WLAN_REASON_DEAUTH_LEAVING 3
-#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
-#define WLAN_REASON_DISASSOC_AP_BUSY 5
-#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
-#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
-#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
-#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
+enum ieee80211_reasoncode {
+       WLAN_REASON_UNSPECIFIED = 1,
+       WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
+       WLAN_REASON_DEAUTH_LEAVING = 3,
+       WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
+       WLAN_REASON_DISASSOC_AP_BUSY = 5,
+       WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
+       WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
+       WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
+       WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
+       /* 802.11h */
+       WLAN_REASON_DISASSOC_BAD_POWER = 10,
+       WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
+       /* 802.11i */
+       WLAN_REASON_INVALID_IE = 13,
+       WLAN_REASON_MIC_FAILURE = 14,
+       WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
+       WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
+       WLAN_REASON_IE_DIFFERENT = 17,
+       WLAN_REASON_INVALID_GROUP_CIPHER = 18,
+       WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
+       WLAN_REASON_INVALID_AKMP = 20,
+       WLAN_REASON_UNSUPP_RSN_VERSION = 21,
+       WLAN_REASON_INVALID_RSN_IE_CAP = 22,
+       WLAN_REASON_IEEE8021X_FAILED = 23,
+       WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
+};
 
 
 #define IEEE80211_STATMASK_SIGNAL (1<<0)
@@ -426,9 +437,7 @@ struct ieee80211_stats {
 
 struct ieee80211_device;
 
-#if 0 /* for later */
 #include "ieee80211_crypt.h"
-#endif
 
 #define SEC_KEY_1         (1<<0)
 #define SEC_KEY_2         (1<<1)
@@ -480,17 +489,34 @@ Total: 28-2340 bytes
 #define BEACON_PROBE_SSID_ID_POSITION 12
 
 /* Management Frame Information Element Types */
-#define MFIE_TYPE_SSID       0
-#define MFIE_TYPE_RATES      1
-#define MFIE_TYPE_FH_SET     2
-#define MFIE_TYPE_DS_SET     3
-#define MFIE_TYPE_CF_SET     4
-#define MFIE_TYPE_TIM        5
-#define MFIE_TYPE_IBSS_SET   6
-#define MFIE_TYPE_CHALLENGE  16
-#define MFIE_TYPE_RSN       48
-#define MFIE_TYPE_RATES_EX   50
-#define MFIE_TYPE_GENERIC    221
+enum ieee80211_mfie {
+       MFIE_TYPE_SSID = 0,
+       MFIE_TYPE_RATES = 1,
+       MFIE_TYPE_FH_SET = 2,
+       MFIE_TYPE_DS_SET = 3,
+       MFIE_TYPE_CF_SET =  4,
+       MFIE_TYPE_TIM = 5,
+       MFIE_TYPE_IBSS_SET = 6,
+       MFIE_TYPE_COUNTRY = 7,
+       MFIE_TYPE_HOP_PARAMS = 8,
+       MFIE_TYPE_HOP_TABLE = 9,
+       MFIE_TYPE_REQUEST = 10,
+       MFIE_TYPE_CHALLENGE = 16,
+       MFIE_TYPE_POWER_CONSTRAINT = 32,
+       MFIE_TYPE_POWER_CAPABILITY = 33,
+       MFIE_TYPE_TPC_REQUEST = 34,
+       MFIE_TYPE_TPC_REPORT = 35,
+       MFIE_TYPE_SUPP_CHANNELS = 36,
+       MFIE_TYPE_CSA = 37,
+       MFIE_TYPE_MEASURE_REQUEST = 38,
+       MFIE_TYPE_MEASURE_REPORT = 39,
+       MFIE_TYPE_QUIET = 40,
+       MFIE_TYPE_IBSS_DFS = 41,
+       MFIE_TYPE_ERP_INFO = 42,
+       MFIE_TYPE_RSN = 48,
+       MFIE_TYPE_RATES_EX = 50,
+       MFIE_TYPE_GENERIC = 221,
+};
 
 struct ieee80211_info_element_hdr {
        u8 id;
@@ -522,9 +548,9 @@ struct ieee80211_info_element {
 
 struct ieee80211_authentication {
        struct ieee80211_hdr_3addr header;
-       u16 algorithm;
-       u16 transaction;
-       u16 status;
+       __le16 algorithm;
+       __le16 transaction;
+       __le16 status;
        struct ieee80211_info_element info_element;
 } __attribute__ ((packed));
 
@@ -532,23 +558,23 @@ struct ieee80211_authentication {
 struct ieee80211_probe_response {
        struct ieee80211_hdr_3addr header;
        u32 time_stamp[2];
-       u16 beacon_interval;
-       u16 capability;
+       __le16 beacon_interval;
+       __le16 capability;
        struct ieee80211_info_element info_element;
 } __attribute__ ((packed));
 
 struct ieee80211_assoc_request_frame {
-       u16 capability;
-       u16 listen_interval;
+       __le16 capability;
+       __le16 listen_interval;
        u8 current_ap[ETH_ALEN];
        struct ieee80211_info_element info_element;
 } __attribute__ ((packed));
 
 struct ieee80211_assoc_response_frame {
        struct ieee80211_hdr_3addr header;
-       u16 capability;
-       u16 status;
-       u16 aid;
+       __le16 capability;
+       __le16 status;
+       __le16 aid;
        struct ieee80211_info_element info_element; /* supported rates */
 } __attribute__ ((packed));
 
@@ -563,7 +589,7 @@ struct ieee80211_txb {
 };
 
 
-/* SWEEP TABLE ENTRIES NUMBER*/
+/* SWEEP TABLE ENTRIES NUMBER */
 #define MAX_SWEEP_TAB_ENTRIES            42
 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET  7
 /* MAX_RATES_LENGTH needs to be 12.  The spec says 8, and many APs
@@ -624,8 +650,6 @@ enum ieee80211_state {
 
 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
 #define DEFAULT_FTS 2346
-#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
-#define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
 
 
 #define CFG_IEEE80211_RESERVE_FCS (1<<0)
@@ -793,8 +817,6 @@ extern struct net_device *alloc_ieee80211(int sizeof_priv);
 extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
 
 /* ieee80211_tx.c */
-
-
 extern int ieee80211_xmit(struct sk_buff *skb,
                          struct net_device *dev);
 extern void ieee80211_txb_free(struct ieee80211_txb *);
@@ -807,7 +829,7 @@ extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
                             struct ieee80211_hdr *header,
                             struct ieee80211_rx_stats *stats);
 
-/* iee80211_wx.c */
+/* ieee80211_wx.c */
 extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
                                 struct iw_request_info *info,
                                 union iwreq_data *wrqu, char *key);
@@ -829,28 +851,5 @@ extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
        return ieee->scans;
 }
 
-static inline const char *escape_essid(const char *essid, u8 essid_len) {
-       static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
-       const char *s = essid;
-       char *d = escaped;
-
-       if (ieee80211_is_empty_essid(essid, essid_len)) {
-               memcpy(escaped, "<hidden>", sizeof("<hidden>"));
-               return escaped;
-       }
-
-       essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE);
-       while (essid_len--) {
-               if (*s == '\0') {
-                       *d++ = '\\';
-                       *d++ = '0';
-                       s++;
-               } else {
-                       *d++ = *s++;
-               }
-       }
-       *d = '\0';
-       return escaped;
-}
 
 #endif /* IEEE80211_H */
diff --git a/include/net/ieee80211_crypt.h b/include/net/ieee80211_crypt.h
new file mode 100644 (file)
index 0000000..b58a3bc
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Original code based on Host AP (software wireless LAN access point) driver
+ * for Intersil Prism2/2.5/3.
+ *
+ * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
+ * <jkmaline@cc.hut.fi>
+ * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
+ *
+ * Adaption to a generic IEEE 802.11 stack by James Ketrenos
+ * <jketreno@linux.intel.com>
+ *
+ * Copyright (c) 2004, Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. See README and COPYING for
+ * more details.
+ */
+
+/*
+ * This file defines the interface to the ieee80211 crypto module.
+ */
+#ifndef IEEE80211_CRYPT_H
+#define IEEE80211_CRYPT_H
+
+#include <linux/skbuff.h>
+
+struct ieee80211_crypto_ops {
+       const char *name;
+
+       /* init new crypto context (e.g., allocate private data space,
+        * select IV, etc.); returns NULL on failure or pointer to allocated
+        * private data on success */
+       void * (*init)(int keyidx);
+
+       /* deinitialize crypto context and free allocated private data */
+       void (*deinit)(void *priv);
+
+       /* encrypt/decrypt return < 0 on error or >= 0 on success. The return
+        * value from decrypt_mpdu is passed as the keyidx value for
+        * decrypt_msdu. skb must have enough head and tail room for the
+        * encryption; if not, error will be returned; these functions are
+        * called for all MPDUs (i.e., fragments).
+        */
+       int (*encrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv);
+       int (*decrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv);
+
+       /* These functions are called for full MSDUs, i.e. full frames.
+        * These can be NULL if full MSDU operations are not needed. */
+       int (*encrypt_msdu)(struct sk_buff *skb, int hdr_len, void *priv);
+       int (*decrypt_msdu)(struct sk_buff *skb, int keyidx, int hdr_len,
+                           void *priv);
+
+       int (*set_key)(void *key, int len, u8 *seq, void *priv);
+       int (*get_key)(void *key, int len, u8 *seq, void *priv);
+
+       /* procfs handler for printing out key information and possible
+        * statistics */
+       char * (*print_stats)(char *p, void *priv);
+
+       /* maximum number of bytes added by encryption; encrypt buf is
+        * allocated with extra_prefix_len bytes, copy of in_buf, and
+        * extra_postfix_len; encrypt need not use all this space, but
+        * the result must start at the beginning of the buffer and correct
+        * length must be returned */
+       int extra_prefix_len, extra_postfix_len;
+
+       struct module *owner;
+};
+
+struct ieee80211_crypt_data {
+       struct list_head list; /* delayed deletion list */
+       struct ieee80211_crypto_ops *ops;
+       void *priv;
+       atomic_t refcnt;
+};
+
+int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops);
+int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops);
+struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name);
+void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int);
+void ieee80211_crypt_deinit_handler(unsigned long);
+void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
+                                   struct ieee80211_crypt_data **crypt);
+
+#endif
index 7a3c43711a17a1848c44e4d02d2514f2056ca9f5..e426641c519f4e4fcf4dd70a9bda3090cd612037 100644 (file)
@@ -958,7 +958,7 @@ static __inline__ int ip_vs_todrop(void)
  */
 #define IP_VS_FWD_METHOD(cp)  (cp->flags & IP_VS_CONN_F_FWD_MASK)
 
-extern __inline__ char ip_vs_fwd_tag(struct ip_vs_conn *cp)
+static inline char ip_vs_fwd_tag(struct ip_vs_conn *cp)
 {
        char fwd;
 
index 3afeb6c94ea4b31337f14275133105aaa83c4177..492dedaa8ac16dacd4cbab84484293a61e636f72 100644 (file)
@@ -28,6 +28,6 @@
 void irlan_check_command_param(struct irlan_cb *self, char *param, 
                               char *value);
 void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb);
-int irlan_print_filter(struct seq_file *seq, int filter_type);
+void irlan_print_filter(struct seq_file *seq, int filter_type);
 
 #endif /* IRLAN_FILTER_H */
index 312cb25cbd18bf10bc090823aede8a2a0e373758..8c48fbecb7cf8fc9e4828a81fdd9a3ca8bd35457 100644 (file)
@@ -709,6 +709,12 @@ static inline int sk_stream_rmem_schedule(struct sock *sk, struct sk_buff *skb)
                sk_stream_mem_schedule(sk, skb->truesize, 1);
 }
 
+static inline int sk_stream_wmem_schedule(struct sock *sk, int size)
+{
+       return size <= sk->sk_forward_alloc ||
+              sk_stream_mem_schedule(sk, size, 0);
+}
+
 /* Used by processes to "lock" a socket state, so that
  * interrupts and bottom half handlers won't change it
  * from under us. It essentially blocks any incoming
@@ -1203,8 +1209,7 @@ static inline struct sk_buff *sk_stream_alloc_pskb(struct sock *sk,
        skb = alloc_skb_fclone(size + hdr_len, gfp);
        if (skb) {
                skb->truesize += mem;
-               if (sk->sk_forward_alloc >= (int)skb->truesize ||
-                   sk_stream_mem_schedule(sk, skb->truesize, 0)) {
+               if (sk_stream_wmem_schedule(sk, skb->truesize)) {
                        skb_reserve(skb, hdr_len);
                        return skb;
                }
@@ -1227,10 +1232,8 @@ static inline struct page *sk_stream_alloc_page(struct sock *sk)
 {
        struct page *page = NULL;
 
-       if (sk->sk_forward_alloc >= (int)PAGE_SIZE ||
-           sk_stream_mem_schedule(sk, PAGE_SIZE, 0))
-               page = alloc_pages(sk->sk_allocation, 0);
-       else {
+       page = alloc_pages(sk->sk_allocation, 0);
+       if (!page) {
                sk->sk_prot->enter_memory_pressure();
                sk_stream_moderate_sndbuf(sk);
        }
@@ -1374,9 +1377,10 @@ extern void sk_init(void);
 
 #ifdef CONFIG_SYSCTL
 extern struct ctl_table core_table[];
-extern int sysctl_optmem_max;
 #endif
 
+extern int sysctl_optmem_max;
+
 extern __u32 sysctl_wmem_default;
 extern __u32 sysctl_rmem_default;
 
index d6bcf1317a6a90188905249feb0f9773a6d91a3b..97af77c4d0961c5866534f0e40c069905fa4d225 100644 (file)
@@ -454,6 +454,7 @@ extern int tcp_retransmit_skb(struct sock *, struct sk_buff *);
 extern void tcp_xmit_retransmit_queue(struct sock *);
 extern void tcp_simple_retransmit(struct sock *);
 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
+extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
 
 extern void tcp_send_probe0(struct sock *);
 extern void tcp_send_partial(struct sock *);
index cebef073b9a3789948e45a50504568d704774679..fceb6c0f65835eec78b1e61a4c348028120d1d42 100644 (file)
@@ -1,24 +1,27 @@
 /*
- *      linux/drivers/video/pmag-ba-fb.h
+ *     linux/include/video/pmag-ba-fb.h
  *
- *      TurboChannel PMAG-BA framebuffer card support,
- *      Copyright (C) 1999,2000,2001 by
- *      Michael Engel <engel@unix-ag.org>,
- *      Karsten Merker <merker@linuxtag.org>
- *      This file is subject to the terms and conditions of the GNU General
- *      Public License.  See the file COPYING in the main directory of this
- *      archive for more details.
- */
-
-/*
- * Bt459 RAM DAC register base offset (rel. to TC slot base address)
+ *     TURBOchannel PMAG-BA Color Frame Buffer (CFB) card support,
+ *     Copyright (C) 1999, 2000, 2001 by
+ *     Michael Engel <engel@unix-ag.org>,
+ *     Karsten Merker <merker@linuxtag.org>
+ *     Copyright (c) 2005  Maciej W. Rozycki
+ *
+ *     This file is subject to the terms and conditions of the GNU General
+ *     Public License.  See the file COPYING in the main directory of this
+ *     archive for more details.
  */
 
-#define PMAG_BA_BT459_OFFSET                    0x00200000
-
-/*
- * Begin of PMAG-BA framebuffer memory relative to TC slot address,
- * resolution is 1024x864x8
- */
+/* IOmem resource offsets.  */
+#define PMAG_BA_FBMEM          0x000000        /* frame buffer */
+#define PMAG_BA_BT459          0x200000        /* Bt459 RAMDAC */
+#define PMAG_BA_IRQ            0x300000        /* IRQ acknowledge */
+#define PMAG_BA_ROM            0x380000        /* REX option ROM */
+#define PMAG_BA_BT438          0x380000        /* Bt438 clock chip reset */
+#define PMAG_BA_SIZE           0x400000        /* address space size */
 
-#define PMAG_BA_ONBOARD_FBMEM_OFFSET    0x00000000
+/* Bt459 register offsets, byte-wide registers.  */
+#define BT459_ADDR_LO          0x0             /* address low */
+#define BT459_ADDR_HI          0x4             /* address high */
+#define BT459_DATA             0x8             /* data window register */
+#define BT459_CMAP             0xc             /* color map window register */
index 87b81a555139b2c21181f3db9121cc3168f8d768..7539b9087a80ba2b96887b590c106ea3b4fdd6cf 100644 (file)
@@ -1,32 +1,58 @@
 /*
- *      linux/drivers/video/pmagb-b-fb.h
+ *     linux/include/video/pmagb-b-fb.h
  *
- *      TurboChannel PMAGB-B framebuffer card support,
- *      Copyright (C) 1999, 2000, 2001 by
- *      Michael Engel <engel@unix-ag.org> and 
- *      Karsten Merker <merker@linuxtag.org>
- *      This file is subject to the terms and conditions of the GNU General
- *      Public License.  See the file COPYING in the main directory of this
- *      archive for more details.
+ *     TURBOchannel PMAGB-B Smart Frame Buffer (SFB) card support,
+ *     Copyright (C) 1999, 2000, 2001 by
+ *     Michael Engel <engel@unix-ag.org> and
+ *     Karsten Merker <merker@linuxtag.org>
+ *     Copyright (c) 2005  Maciej W. Rozycki
+ *
+ *     This file is subject to the terms and conditions of the GNU General
+ *     Public License.  See the file COPYING in the main directory of this
+ *     archive for more details.
  */
 
+/* IOmem resource offsets.  */
+#define PMAGB_B_ROM            0x000000        /* REX option ROM */
+#define PMAGB_B_SFB            0x100000        /* SFB ASIC */
+#define PMAGB_B_GP0            0x140000        /* general purpose output 0 */
+#define PMAGB_B_GP1            0x180000        /* general purpose output 1 */
+#define PMAGB_B_BT459          0x1c0000        /* Bt459 RAMDAC */
+#define PMAGB_B_FBMEM          0x200000        /* frame buffer */
+#define PMAGB_B_SIZE           0x400000        /* address space size */
 
-/*
- * Bt459 RAM DAC register base offset (rel. to TC slot base address)
- */
-#define PMAGB_B_BT459_OFFSET                   0x001C0000
+/* IOmem register offsets.  */
+#define SFB_REG_VID_HOR                0x64            /* video horizontal setup */
+#define SFB_REG_VID_VER                0x68            /* video vertical setup */
+#define SFB_REG_VID_BASE       0x6c            /* video base address */
+#define SFB_REG_TCCLK_COUNT    0x78            /* TURBOchannel clock count */
+#define SFB_REG_VIDCLK_COUNT   0x7c            /* video clock count */
 
-/*
- * Begin of PMAGB-B framebuffer memory, resolution is configurable:
- * 1024x864x8 or 1280x1024x8, settable by jumper on the card
- */
-#define PMAGB_B_ONBOARD_FBMEM_OFFSET   0x00201000
+/* Video horizontal setup register constants.  All bits are r/w.  */
+#define SFB_VID_HOR_BP_SHIFT   0x15            /* back porch */
+#define SFB_VID_HOR_BP_MASK    0x7f
+#define SFB_VID_HOR_SYN_SHIFT  0x0e            /* sync pulse */
+#define SFB_VID_HOR_SYN_MASK   0x7f
+#define SFB_VID_HOR_FP_SHIFT   0x09            /* front porch */
+#define SFB_VID_HOR_FP_MASK    0x1f
+#define SFB_VID_HOR_PIX_SHIFT  0x00            /* active video */
+#define SFB_VID_HOR_PIX_MASK   0x1ff
 
-/*
- * Bt459 register offsets, byte-wide registers
- */
+/* Video vertical setup register constants.  All bits are r/w.  */
+#define SFB_VID_VER_BP_SHIFT   0x16            /* back porch */
+#define SFB_VID_VER_BP_MASK    0x3f
+#define SFB_VID_VER_SYN_SHIFT  0x10            /* sync pulse */
+#define SFB_VID_VER_SYN_MASK   0x3f
+#define SFB_VID_VER_FP_SHIFT   0x0b            /* front porch */
+#define SFB_VID_VER_FP_MASK    0x1f
+#define SFB_VID_VER_SL_SHIFT   0x00            /* active scan lines */
+#define SFB_VID_VER_SL_MASK    0x7ff
+
+/* Video base address register constants.  All bits are r/w.  */
+#define SFB_VID_BASE_MASK      0x1ff           /* video base row address */
 
-#define BT459_ADR_LOW                  BT459_OFFSET + 0x00     /* addr. low */
-#define BT459_ADR_HIGH                 BT459_OFFSET + 0x04     /* addr. high */
-#define BT459_DATA                     BT459_OFFSET + 0x08     /* r/w data */
-#define BT459_CMAP                     BT459_OFFSET + 0x0C     /* color map */
+/* Bt459 register offsets, byte-wide registers.  */
+#define BT459_ADDR_LO          0x0             /* address low */
+#define BT459_ADDR_HI          0x4             /* address high */
+#define BT459_DATA             0x8             /* data window register */
+#define BT459_CMAP             0xc             /* color map window register */
index 05a75c4f5ce2a230f9193233dd4e05737878b5bf..d5a1a1228fab05632107e53152c954c0033d10f9 100644 (file)
@@ -77,6 +77,22 @@ config LOCALVERSION
          object and source tree, in that order.  Your total string can
          be a maximum of 64 characters.
 
+config LOCALVERSION_AUTO
+       bool "Automatically append version information to the version string"
+       default y
+       help
+         This will try to automatically determine if the current tree is a
+         release tree by looking for git tags that
+         belong to the current top of tree revision.
+
+         A string of the format -gxxxxxxxx will be added to the localversion
+         if a git based tree is found.  The string generated by this will be
+         appended after any matching localversion* files, and after the value
+         set in CONFIG_LOCALVERSION
+
+         Note: This requires Perl, and a git repository, but not necessarily
+         the git or cogito tools to be installed.
+
 config SWAP
        bool "Support for paging of anonymous memory (swap)"
        depends on MMU
@@ -238,6 +254,8 @@ config CPUSETS
 
          Say N if unsure.
 
+source "usr/Kconfig"
+
 menuconfig EMBEDDED
        bool "Configure standard kernel features (for small systems)"
        help
@@ -260,8 +278,8 @@ config KALLSYMS_ALL
        help
           Normally kallsyms only contains the symbols of functions, for nicer
           OOPS messages.  Some debuggers can use kallsyms for other
-          symbols too: say Y here to include all symbols, and you
-          don't care about adding 300k to the size of your kernel.
+          symbols too: say Y here to include all symbols, if you need them 
+          and you don't care about adding 300k to the size of your kernel.
 
           Say N.
 
index 93a53fbdbe79637b4111b73cc54a9d6bec44409e..a2300078f2b7d98f97a603678e40a39d034bdea5 100644 (file)
@@ -25,4 +25,5 @@ $(obj)/version.o: include/linux/compile.h
 
 include/linux/compile.h: FORCE
        @echo '  CHK     $@'
-       @$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CC) $(CFLAGS)"
+       $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \
+       "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" "$(CC) $(CFLAGS)"
index 4e11a9aaf14ab82288e136937de1ec62559c7ac7..b27c11064409a35812d9d35ba359e06f6d8c0ffb 100644 (file)
@@ -127,10 +127,10 @@ fail:
  *        used when disk name of partitioned disk ends on a digit.
  *
  *     If name doesn't have fall into the categories above, we return 0.
- *     Driverfs is used to check if something is a disk name - it has
+ *     Sysfs is used to check if something is a disk name - it has
  *     all known disks under bus/block/devices.  If the disk name
- *     contains slashes, name of driverfs node has them replaced with
- *     bangs.  try_name() does the actual checks, assuming that driverfs
+ *     contains slashes, name of sysfs node has them replaced with
+ *     bangs.  try_name() does the actual checks, assuming that sysfs
  *     is mounted on rootfs /sys.
  */
 
index b65187f0c74e720281ff6f08b98e3bef19e638c4..7e1ead9a6ba453bbfafab739df3690e69684e769 100644 (file)
@@ -994,6 +994,9 @@ static task_t *copy_process(unsigned long clone_flags,
         * of CLONE_PTRACE.
         */
        clear_tsk_thread_flag(p, TIF_SYSCALL_TRACE);
+#ifdef TIF_SYSCALL_EMU
+       clear_tsk_thread_flag(p, TIF_SYSCALL_EMU);
+#endif
 
        /* Our parent execution domain becomes current domain
           These must match for thread signalling to apply */
index 2c7121d9bff11aff162a578bd68d7934c1030104..917066a5767c342663c952d1018806dc67db1167 100644 (file)
@@ -72,6 +72,18 @@ config PM_STD_PARTITION
          suspended image to. It will simply pick the first available swap 
          device.
 
+config SWSUSP_ENCRYPT
+       bool "Encrypt suspend image"
+       depends on SOFTWARE_SUSPEND && CRYPTO=y && (CRYPTO_AES=y || CRYPTO_AES_586=y || CRYPTO_AES_X86_64=y)
+       default ""
+       ---help---
+         To prevent data gathering from swap after resume you can encrypt
+         the suspend image with a temporary key that is deleted on
+         resume.
+
+         Note that the temporary key is stored unencrypted on disk while the
+         system is suspended.
+
 config SUSPEND_SMP
        bool
        depends on HOTPLUG_CPU && X86 && PM
index 664eb0469b6e18230f3daf84fcf78ed09e8f0bcf..2d8bf054d036810766352d66b2fb84ec16361717 100644 (file)
@@ -112,24 +112,12 @@ static inline void platform_finish(void)
        }
 }
 
-static void finish(void)
-{
-       device_resume();
-       platform_finish();
-       thaw_processes();
-       enable_nonboot_cpus();
-       pm_restore_console();
-}
-
-
 static int prepare_processes(void)
 {
        int error;
 
        pm_prepare_console();
-
        sys_sync();
-
        disable_nonboot_cpus();
 
        if (freeze_processes()) {
@@ -162,15 +150,6 @@ static void unprepare_processes(void)
        pm_restore_console();
 }
 
-static int prepare_devices(void)
-{
-       int error;
-
-       if ((error = device_suspend(PMSG_FREEZE)))
-               printk("Some devices failed to suspend\n");
-       return error;
-}
-
 /**
  *     pm_suspend_disk - The granpappy of power management.
  *
@@ -187,17 +166,14 @@ int pm_suspend_disk(void)
        error = prepare_processes();
        if (error)
                return error;
-       error = prepare_devices();
 
+       error = device_suspend(PMSG_FREEZE);
        if (error) {
+               printk("Some devices failed to suspend\n");
                unprepare_processes();
                return error;
        }
 
-       pr_debug("PM: Attempting to suspend to disk.\n");
-       if (pm_disk_mode == PM_DISK_FIRMWARE)
-               return pm_ops->enter(PM_SUSPEND_DISK);
-
        pr_debug("PM: snapshotting memory.\n");
        in_suspend = 1;
        if ((error = swsusp_suspend()))
@@ -208,11 +184,20 @@ int pm_suspend_disk(void)
                error = swsusp_write();
                if (!error)
                        power_down(pm_disk_mode);
+               else {
+               /* swsusp_write can not fail in device_resume,
+                  no need to do second device_resume */
+                       swsusp_free();
+                       unprepare_processes();
+                       return error;
+               }
        } else
                pr_debug("PM: Image restored successfully.\n");
+
        swsusp_free();
  Done:
-       finish();
+       device_resume();
+       unprepare_processes();
        return error;
 }
 
@@ -233,9 +218,12 @@ static int software_resume(void)
 {
        int error;
 
+       down(&pm_sem);
        if (!swsusp_resume_device) {
-               if (!strlen(resume_file))
+               if (!strlen(resume_file)) {
+                       up(&pm_sem);
                        return -ENOENT;
+               }
                swsusp_resume_device = name_to_dev_t(resume_file);
                pr_debug("swsusp: Resume From Partition %s\n", resume_file);
        } else {
@@ -248,6 +236,7 @@ static int software_resume(void)
                 * FIXME: If noresume is specified, we need to find the partition
                 * and reset it back to normal swap space.
                 */
+               up(&pm_sem);
                return 0;
        }
 
@@ -270,20 +259,24 @@ static int software_resume(void)
 
        pr_debug("PM: Preparing devices for restore.\n");
 
-       if ((error = prepare_devices()))
+       if ((error = device_suspend(PMSG_FREEZE))) {
+               printk("Some devices failed to suspend\n");
                goto Free;
+       }
 
        mb();
 
        pr_debug("PM: Restoring saved image.\n");
        swsusp_resume();
        pr_debug("PM: Restore failed, recovering.n");
-       finish();
+       device_resume();
  Free:
        swsusp_free();
  Cleanup:
        unprepare_processes();
  Done:
+       /* For success case, the suspend path will release the lock */
+       up(&pm_sem);
        pr_debug("PM: Resume from disk failed.\n");
        return 0;
 }
@@ -390,7 +383,9 @@ static ssize_t resume_store(struct subsystem * subsys, const char * buf, size_t
        if (sscanf(buf, "%u:%u", &maj, &min) == 2) {
                res = MKDEV(maj,min);
                if (maj == MAJOR(res) && min == MINOR(res)) {
+                       down(&pm_sem);
                        swsusp_resume_device = res;
+                       up(&pm_sem);
                        printk("Attempting manual resume\n");
                        noresume = 0;
                        software_resume();
index 71aa0fd22007d8c5c188a4ce62c516726fd228d2..22bdc93cc03885096a5e29755e5f3f5aeadee68a 100644 (file)
@@ -143,11 +143,12 @@ static void suspend_finish(suspend_state_t state)
 
 
 
-static char * pm_states[] = {
+static char *pm_states[PM_SUSPEND_MAX] = {
        [PM_SUSPEND_STANDBY]    = "standby",
        [PM_SUSPEND_MEM]        = "mem",
+#ifdef CONFIG_SOFTWARE_SUSPEND
        [PM_SUSPEND_DISK]       = "disk",
-       NULL,
+#endif
 };
 
 
index 3bd0d261818f5d7769af8b265544dbe8abf5d519..28de118f7a0b047c6c507a8adbf2113ce52bb21d 100644 (file)
@@ -38,7 +38,6 @@ void refrigerator(void)
           processes around? */
        long save;
        save = current->state;
-       current->state = TASK_UNINTERRUPTIBLE;
        pr_debug("%s entered refrigerator\n", current->comm);
        printk("=");
 
@@ -47,8 +46,10 @@ void refrigerator(void)
        recalc_sigpending(); /* We sent fake signal, clean it up */
        spin_unlock_irq(&current->sighand->siglock);
 
-       while (frozen(current))
+       while (frozen(current)) {
+               current->state = TASK_UNINTERRUPTIBLE;
                schedule();
+       }
        pr_debug("%s left refrigerator\n", current->comm);
        current->state = save;
 }
@@ -80,13 +81,33 @@ int freeze_processes(void)
                } while_each_thread(g, p);
                read_unlock(&tasklist_lock);
                yield();                        /* Yield is okay here */
-               if (time_after(jiffies, start_time + TIMEOUT)) {
+               if (todo && time_after(jiffies, start_time + TIMEOUT)) {
                        printk( "\n" );
                        printk(KERN_ERR " stopping tasks failed (%d tasks remaining)\n", todo );
-                       return todo;
+                       break;
                }
        } while(todo);
 
+       /* This does not unfreeze processes that are already frozen
+        * (we have slightly ugly calling convention in that respect,
+        * and caller must call thaw_processes() if something fails),
+        * but it cleans up leftover PF_FREEZE requests.
+        */
+       if (todo) {
+               read_lock(&tasklist_lock);
+               do_each_thread(g, p)
+                       if (freezing(p)) {
+                               pr_debug("  clean up: %s\n", p->comm);
+                               p->flags &= ~PF_FREEZE;
+                               spin_lock_irqsave(&p->sighand->siglock, flags);
+                               recalc_sigpending_tsk(p);
+                               spin_unlock_irqrestore(&p->sighand->siglock, flags);
+                       }
+               while_each_thread(g, p);
+               read_unlock(&tasklist_lock);
+               return todo;
+       }
+
        printk( "|\n" );
        BUG_ON(in_atomic());
        return 0;
index f2bc71b9fe8be2dd226addc38ea7a7e48783317e..eaacd5cb58895438ac28013968651f0d1752c4c6 100644 (file)
@@ -31,6 +31,9 @@
  * Alex Badea <vampire@go.ro>:
  * Fixed runaway init
  *
+ * Andreas Steinmetz <ast@domdv.de>:
+ * Added encrypted suspend option
+ *
  * More state savers are welcome. Especially for the scsi layer...
  *
  * For TODOs,FIXMEs also look in Documentation/power/swsusp.txt
 #include <asm/tlbflush.h>
 #include <asm/io.h>
 
+#include <linux/random.h>
+#include <linux/crypto.h>
+#include <asm/scatterlist.h>
+
 #include "power.h"
 
+#define CIPHER "aes"
+#define MAXKEY 32
+#define MAXIV  32
+
 /* References to section boundaries */
 extern const void __nosave_begin, __nosave_end;
 
@@ -103,7 +114,8 @@ static suspend_pagedir_t *pagedir_save;
 #define SWSUSP_SIG     "S1SUSPEND"
 
 static struct swsusp_header {
-       char reserved[PAGE_SIZE - 20 - sizeof(swp_entry_t)];
+       char reserved[PAGE_SIZE - 20 - MAXKEY - MAXIV - sizeof(swp_entry_t)];
+       u8 key_iv[MAXKEY+MAXIV];
        swp_entry_t swsusp_info;
        char    orig_sig[10];
        char    sig[10];
@@ -129,6 +141,131 @@ static struct swsusp_info swsusp_info;
 static unsigned short swapfile_used[MAX_SWAPFILES];
 static unsigned short root_swap;
 
+static int write_page(unsigned long addr, swp_entry_t * loc);
+static int bio_read_page(pgoff_t page_off, void * page);
+
+static u8 key_iv[MAXKEY+MAXIV];
+
+#ifdef CONFIG_SWSUSP_ENCRYPT
+
+static int crypto_init(int mode, void **mem)
+{
+       int error = 0;
+       int len;
+       char *modemsg;
+       struct crypto_tfm *tfm;
+
+       modemsg = mode ? "suspend not possible" : "resume not possible";
+
+       tfm = crypto_alloc_tfm(CIPHER, CRYPTO_TFM_MODE_CBC);
+       if(!tfm) {
+               printk(KERN_ERR "swsusp: no tfm, %s\n", modemsg);
+               error = -EINVAL;
+               goto out;
+       }
+
+       if(MAXKEY < crypto_tfm_alg_min_keysize(tfm)) {
+               printk(KERN_ERR "swsusp: key buffer too small, %s\n", modemsg);
+               error = -ENOKEY;
+               goto fail;
+       }
+
+       if (mode)
+               get_random_bytes(key_iv, MAXKEY+MAXIV);
+
+       len = crypto_tfm_alg_max_keysize(tfm);
+       if (len > MAXKEY)
+               len = MAXKEY;
+
+       if (crypto_cipher_setkey(tfm, key_iv, len)) {
+               printk(KERN_ERR "swsusp: key setup failure, %s\n", modemsg);
+               error = -EKEYREJECTED;
+               goto fail;
+       }
+
+       len = crypto_tfm_alg_ivsize(tfm);
+
+       if (MAXIV < len) {
+               printk(KERN_ERR "swsusp: iv buffer too small, %s\n", modemsg);
+               error = -EOVERFLOW;
+               goto fail;
+       }
+
+       crypto_cipher_set_iv(tfm, key_iv+MAXKEY, len);
+
+       *mem=(void *)tfm;
+
+       goto out;
+
+fail:  crypto_free_tfm(tfm);
+out:   return error;
+}
+
+static __inline__ void crypto_exit(void *mem)
+{
+       crypto_free_tfm((struct crypto_tfm *)mem);
+}
+
+static __inline__ int crypto_write(struct pbe *p, void *mem)
+{
+       int error = 0;
+       struct scatterlist src, dst;
+
+       src.page   = virt_to_page(p->address);
+       src.offset = 0;
+       src.length = PAGE_SIZE;
+       dst.page   = virt_to_page((void *)&swsusp_header);
+       dst.offset = 0;
+       dst.length = PAGE_SIZE;
+
+       error = crypto_cipher_encrypt((struct crypto_tfm *)mem, &dst, &src,
+                                       PAGE_SIZE);
+
+       if (!error)
+               error = write_page((unsigned long)&swsusp_header,
+                               &(p->swap_address));
+       return error;
+}
+
+static __inline__ int crypto_read(struct pbe *p, void *mem)
+{
+       int error = 0;
+       struct scatterlist src, dst;
+
+       error = bio_read_page(swp_offset(p->swap_address), (void *)p->address);
+       if (!error) {
+               src.offset = 0;
+               src.length = PAGE_SIZE;
+               dst.offset = 0;
+               dst.length = PAGE_SIZE;
+               src.page = dst.page = virt_to_page((void *)p->address);
+
+               error = crypto_cipher_decrypt((struct crypto_tfm *)mem, &dst,
+                                               &src, PAGE_SIZE);
+       }
+       return error;
+}
+#else
+static __inline__ int crypto_init(int mode, void *mem)
+{
+       return 0;
+}
+
+static __inline__ void crypto_exit(void *mem)
+{
+}
+
+static __inline__ int crypto_write(struct pbe *p, void *mem)
+{
+       return write_page(p->address, &(p->swap_address));
+}
+
+static __inline__ int crypto_read(struct pbe *p, void *mem)
+{
+       return bio_read_page(swp_offset(p->swap_address), (void *)p->address);
+}
+#endif
+
 static int mark_swapfiles(swp_entry_t prev)
 {
        int error;
@@ -140,6 +277,7 @@ static int mark_swapfiles(swp_entry_t prev)
            !memcmp("SWAPSPACE2",swsusp_header.sig, 10)) {
                memcpy(swsusp_header.orig_sig,swsusp_header.sig, 10);
                memcpy(swsusp_header.sig,SWSUSP_SIG, 10);
+               memcpy(swsusp_header.key_iv, key_iv, MAXKEY+MAXIV);
                swsusp_header.swsusp_info = prev;
                error = rw_swap_page_sync(WRITE,
                                          swp_entry(root_swap, 0),
@@ -179,9 +317,9 @@ static int swsusp_swap_check(void) /* This is called before saving image */
        len=strlen(resume_file);
        root_swap = 0xFFFF;
 
-       swap_list_lock();
+       spin_lock(&swap_lock);
        for (i=0; i<MAX_SWAPFILES; i++) {
-               if (swap_info[i].flags == 0) {
+               if (!(swap_info[i].flags & SWP_WRITEOK)) {
                        swapfile_used[i]=SWAPFILE_UNUSED;
                } else {
                        if (!len) {
@@ -202,7 +340,7 @@ static int swsusp_swap_check(void) /* This is called before saving image */
                        }
                }
        }
-       swap_list_unlock();
+       spin_unlock(&swap_lock);
        return (root_swap != 0xffff) ? 0 : -ENODEV;
 }
 
@@ -216,12 +354,12 @@ static void lock_swapdevices(void)
 {
        int i;
 
-       swap_list_lock();
+       spin_lock(&swap_lock);
        for (i = 0; i< MAX_SWAPFILES; i++)
                if (swapfile_used[i] == SWAPFILE_IGNORED) {
-                       swap_info[i].flags ^= 0xFF;
+                       swap_info[i].flags ^= SWP_WRITEOK;
                }
-       swap_list_unlock();
+       spin_unlock(&swap_lock);
 }
 
 /**
@@ -286,6 +424,10 @@ static int data_write(void)
        int error = 0, i = 0;
        unsigned int mod = nr_copy_pages / 100;
        struct pbe *p;
+       void *tfm;
+
+       if ((error = crypto_init(1, &tfm)))
+               return error;
 
        if (!mod)
                mod = 1;
@@ -294,11 +436,14 @@ static int data_write(void)
        for_each_pbe (p, pagedir_nosave) {
                if (!(i%mod))
                        printk( "\b\b\b\b%3d%%", i / mod );
-               if ((error = write_page(p->address, &(p->swap_address))))
+               if ((error = crypto_write(p, tfm))) {
+                       crypto_exit(tfm);
                        return error;
+               }
                i++;
        }
        printk("\b\b\b\bdone\n");
+       crypto_exit(tfm);
        return error;
 }
 
@@ -385,7 +530,6 @@ static int write_pagedir(void)
  *     write_suspend_image - Write entire image and metadata.
  *
  */
-
 static int write_suspend_image(void)
 {
        int error;
@@ -400,6 +544,7 @@ static int write_suspend_image(void)
        if ((error = close_swap()))
                goto FreePagedir;
  Done:
+       memset(key_iv, 0, MAXKEY+MAXIV);
        return error;
  FreePagedir:
        free_pagedir_entries();
@@ -591,18 +736,7 @@ static void copy_data_pages(void)
 
 static int calc_nr(int nr_copy)
 {
-       int extra = 0;
-       int mod = !!(nr_copy % PBES_PER_PAGE);
-       int diff = (nr_copy / PBES_PER_PAGE) + mod;
-
-       do {
-               extra += diff;
-               nr_copy += diff;
-               mod = !!(nr_copy % PBES_PER_PAGE);
-               diff = (nr_copy / PBES_PER_PAGE) + mod - extra;
-       } while (diff > 0);
-
-       return nr_copy;
+       return nr_copy + (nr_copy+PBES_PER_PAGE-2)/(PBES_PER_PAGE-1);
 }
 
 /**
@@ -886,20 +1020,21 @@ int swsusp_suspend(void)
         * at resume time, and evil weirdness ensues.
         */
        if ((error = device_power_down(PMSG_FREEZE))) {
+               printk(KERN_ERR "Some devices failed to power down, aborting suspend\n");
                local_irq_enable();
                return error;
        }
 
        if ((error = swsusp_swap_check())) {
-               printk(KERN_ERR "swsusp: FATAL: cannot find swap device, try "
-                               "swapon -a!\n");
+               printk(KERN_ERR "swsusp: cannot find swap device, try swapon -a.\n");
+               device_power_up();
                local_irq_enable();
                return error;
        }
 
        save_processor_state();
        if ((error = swsusp_arch_suspend()))
-               printk("Error %d suspending\n", error);
+               printk(KERN_ERR "Error %d suspending\n", error);
        /* Restore control flow magically appears here */
        restore_processor_state();
        BUG_ON (nr_copy_pages_check != nr_copy_pages);
@@ -1179,7 +1314,8 @@ static const char * sanity_check(void)
        if (strcmp(swsusp_info.uts.machine,system_utsname.machine))
                return "machine";
 #if 0
-       if(swsusp_info.cpus != num_online_cpus())
+       /* We can't use number of online CPUs when we use hotplug to remove them ;-))) */
+       if (swsusp_info.cpus != num_possible_cpus())
                return "number of cpus";
 #endif
        return NULL;
@@ -1212,13 +1348,14 @@ static int check_sig(void)
                return error;
        if (!memcmp(SWSUSP_SIG, swsusp_header.sig, 10)) {
                memcpy(swsusp_header.sig, swsusp_header.orig_sig, 10);
+               memcpy(key_iv, swsusp_header.key_iv, MAXKEY+MAXIV);
+               memset(swsusp_header.key_iv, 0, MAXKEY+MAXIV);
 
                /*
                 * Reset swap signature now.
                 */
                error = bio_write_page(0, &swsusp_header);
        } else { 
-               printk(KERN_ERR "swsusp: Suspend partition has wrong signature?\n");
                return -EINVAL;
        }
        if (!error)
@@ -1239,6 +1376,10 @@ static int data_read(struct pbe *pblist)
        int error = 0;
        int i = 0;
        int mod = swsusp_info.image_pages / 100;
+       void *tfm;
+
+       if ((error = crypto_init(0, &tfm)))
+               return error;
 
        if (!mod)
                mod = 1;
@@ -1250,14 +1391,15 @@ static int data_read(struct pbe *pblist)
                if (!(i % mod))
                        printk("\b\b\b\b%3d%%", i / mod);
 
-               error = bio_read_page(swp_offset(p->swap_address),
-                                 (void *)p->address);
-               if (error)
+               if ((error = crypto_read(p, tfm))) {
+                       crypto_exit(tfm);
                        return error;
+               }
 
                i++;
        }
        printk("\b\b\b\bdone\n");
+       crypto_exit(tfm);
        return error;
 }
 
@@ -1385,6 +1527,7 @@ int swsusp_read(void)
 
        error = read_suspend_image();
        blkdev_put(resume_bdev);
+       memset(key_iv, 0, MAXKEY+MAXIV);
 
        if (!error)
                pr_debug("swsusp: Reading resume file was successful\n");
index 52f83380f70426600d7f031c54e316cb04151c0a..3e2bd0df23bb4c76d745bdee5b71b97a57dd4c8f 100644 (file)
@@ -18,6 +18,7 @@ endif
 
 lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
 lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
+lib-$(CONFIG_SEMAPHORE_SLEEPERS) += semaphore-sleepers.o
 lib-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o
 obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o
 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
index 738ab810160a85b1c437da82e0389d354c76cf20..a70c836c5c4c2617f6929407034a8706b57c4886 100644 (file)
@@ -79,11 +79,11 @@ static void klist_node_init(struct klist * k, struct klist_node * n)
 
 /**
  *     klist_add_head - Initialize a klist_node and add it to front.
- *     @k:     klist it's going on.
  *     @n:     node we're adding.
+ *     @k:     klist it's going on.
  */
 
-void klist_add_head(struct klist * k, struct klist_node * n)
+void klist_add_head(struct klist_node * n, struct klist * k)
 {
        klist_node_init(k, n);
        add_head(k, n);
@@ -94,11 +94,11 @@ EXPORT_SYMBOL_GPL(klist_add_head);
 
 /**
  *     klist_add_tail - Initialize a klist_node and add it to back.
- *     @k:     klist it's going on.
  *     @n:     node we're adding.
+ *     @k:     klist it's going on.
  */
 
-void klist_add_tail(struct klist * k, struct klist_node * n)
+void klist_add_tail(struct klist_node * n, struct klist * k)
 {
        klist_node_init(k, n);
        add_tail(k, n);
similarity index 94%
rename from arch/x86_64/kernel/semaphore.c
rename to lib/semaphore-sleepers.c
index 48f7c18172b9990d17c6c00fac7940835a8afe0f..4d5f18889fa54c7535dcf8fced756d4344a88afc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * x86_64 semaphore implementation.
+ * i386 and x86-64 semaphore implementation.
  *
  * (C) Copyright 1999 Linus Torvalds
  *
@@ -14,9 +14,8 @@
  */
 #include <linux/config.h>
 #include <linux/sched.h>
+#include <linux/err.h>
 #include <linux/init.h>
-#include <asm/errno.h>
-
 #include <asm/semaphore.h>
 
 /*
  *    we cannot lose wakeup events.
  */
 
-void __up(struct semaphore *sem)
+fastcall void __up(struct semaphore *sem)
 {
        wake_up(&sem->wait);
 }
 
-void __sched __down(struct semaphore * sem)
+fastcall void __sched __down(struct semaphore * sem)
 {
        struct task_struct *tsk = current;
        DECLARE_WAITQUEUE(wait, tsk);
@@ -92,7 +91,7 @@ void __sched __down(struct semaphore * sem)
        tsk->state = TASK_RUNNING;
 }
 
-int __sched __down_interruptible(struct semaphore * sem)
+fastcall int __sched __down_interruptible(struct semaphore * sem)
 {
        int retval = 0;
        struct task_struct *tsk = current;
@@ -155,7 +154,7 @@ int __sched __down_interruptible(struct semaphore * sem)
  * single "cmpxchg" without failure cases,
  * but then it wouldn't work on a 386.
  */
-int __down_trylock(struct semaphore * sem)
+fastcall int __down_trylock(struct semaphore * sem)
 {
        int sleepers;
        unsigned long flags;
@@ -176,5 +175,3 @@ int __down_trylock(struct semaphore * sem)
        spin_unlock_irqrestore(&sem->wait.lock, flags);
        return 1;
 }
-
-
index cd379936cac663eb1c4f1a730460ceda4216c477..4e9937ac3529ae391762f5071e938f8ac5497077 100644 (file)
@@ -89,3 +89,25 @@ config NEED_MULTIPLE_NODES
 config HAVE_MEMORY_PRESENT
        def_bool y
        depends on ARCH_HAVE_MEMORY_PRESENT || SPARSEMEM
+
+#
+# SPARSEMEM_EXTREME (which is the default) does some bootmem
+# allocations when memory_present() is called.  If this can not
+# be done on your architecture, select this option.  However,
+# statically allocating the mem_section[] array can potentially
+# consume vast quantities of .bss, so be careful.
+#
+# This option will also potentially produce smaller runtime code
+# with gcc 3.4 and later.
+#
+config SPARSEMEM_STATIC
+       def_bool n
+
+#
+# Architectecture platforms which require a two level mem_section in SPARSEMEM
+# must select this option. This is usually for architecture platforms with
+# an extremely sparse physical address space.
+#
+config SPARSEMEM_EXTREME
+       def_bool y
+       depends on SPARSEMEM && !SPARSEMEM_STATIC
index c11418dd94e810f4c8d9c4aa7ed2fae6d8aba290..88611928e71fc928a89b5b319044d759ea5f612d 100644 (file)
@@ -54,9 +54,8 @@
  *
  *  ->i_mmap_lock              (vmtruncate)
  *    ->private_lock           (__free_pte->__set_page_dirty_buffers)
- *      ->swap_list_lock
- *        ->swap_device_lock   (exclusive_swap_page, others)
- *          ->mapping->tree_lock
+ *      ->swap_lock            (exclusive_swap_page, others)
+ *        ->mapping->tree_lock
  *
  *  ->i_sem
  *    ->i_mmap_lock            (truncate->unmap_mapping_range)
@@ -86,7 +85,7 @@
  *    ->page_table_lock                (anon_vma_prepare and various)
  *
  *  ->page_table_lock
- *    ->swap_device_lock       (try_to_unmap_one)
+ *    ->swap_lock              (try_to_unmap_one)
  *    ->private_lock           (try_to_unmap_one)
  *    ->tree_lock              (try_to_unmap_one)
  *    ->zone.lru_lock          (follow_page->mark_page_accessed)
@@ -1505,8 +1504,12 @@ repeat:
                return -EINVAL;
 
        page = filemap_getpage(file, pgoff, nonblock);
+
+       /* XXX: This is wrong, a filesystem I/O error may have happened. Fix that as
+        * done in shmem_populate calling shmem_getpage */
        if (!page && !nonblock)
                return -ENOMEM;
+
        if (page) {
                err = install_page(mm, vma, addr, page, prot);
                if (err) {
@@ -1514,6 +1517,9 @@ repeat:
                        return err;
                }
        } else {
+               /* No page was found just because we can't read it in now (being
+                * here implies nonblock != 0), but the page may exist, so set
+                * the PTE to fault it in later. */
                err = install_file_pte(mm, vma, addr, pgoff, prot);
                if (err)
                        return err;
index 6bf720bc662c41983c1208e2aef409d4e0a276ac..901ac523a1c39fc17cc15d626ffb9cc8aa7f083d 100644 (file)
@@ -360,8 +360,6 @@ int hugetlb_prefault(struct address_space *mapping, struct vm_area_struct *vma)
                        ret = -ENOMEM;
                        goto out;
                }
-               if (! pte_none(*pte))
-                       hugetlb_clean_stale_pgtable(pte);
 
                idx = ((addr - vma->vm_start) >> HPAGE_SHIFT)
                        + (vma->vm_pgoff >> (HPAGE_SHIFT - PAGE_SHIFT));
index c8c01a12fea43719b034e6f394d8d72faa1aea16..4454936f87d1b6fb2fde25e1570a2748ea4a16b0 100644 (file)
@@ -37,7 +37,7 @@ static long madvise_behavior(struct vm_area_struct * vma,
 
        if (new_flags == vma->vm_flags) {
                *prev = vma;
-               goto success;
+               goto out;
        }
 
        pgoff = vma->vm_pgoff + ((start - vma->vm_start) >> PAGE_SHIFT);
@@ -62,6 +62,7 @@ static long madvise_behavior(struct vm_area_struct * vma,
                        goto out;
        }
 
+success:
        /*
         * vm_flags is protected by the mmap_sem held in write mode.
         */
@@ -70,7 +71,6 @@ static long madvise_behavior(struct vm_area_struct * vma,
 out:
        if (error == -ENOMEM)
                error = -EAGAIN;
-success:
        return error;
 }
 
@@ -237,8 +237,9 @@ asmlinkage long sys_madvise(unsigned long start, size_t len_in, int behavior)
         * - different from the way of handling in mlock etc.
         */
        vma = find_vma_prev(current->mm, start, &prev);
-       if (!vma && prev)
-               vma = prev->vm_next;
+       if (vma && start > vma->vm_start)
+               prev = vma;
+
        for (;;) {
                /* Still start < end. */
                error = -ENOMEM;
index a596c1172248e56b8fb220408548330ebd1de538..788a628103405e955a7d28f9935be690eb6d021a 100644 (file)
@@ -562,7 +562,8 @@ static void zap_pte_range(struct mmu_gather *tlb, pmd_t *pmd,
                                     page->index > details->last_index))
                                        continue;
                        }
-                       ptent = ptep_get_and_clear(tlb->mm, addr, pte);
+                       ptent = ptep_get_and_clear_full(tlb->mm, addr, pte,
+                                                       tlb->fullmm);
                        tlb_remove_tlb_entry(tlb, pte, addr);
                        if (unlikely(!page))
                                continue;
@@ -590,7 +591,7 @@ static void zap_pte_range(struct mmu_gather *tlb, pmd_t *pmd,
                        continue;
                if (!pte_file(ptent))
                        free_swap_and_cache(pte_to_swp_entry(ptent));
-               pte_clear(tlb->mm, addr, pte);
+               pte_clear_full(tlb->mm, addr, pte, tlb->fullmm);
        } while (pte++, addr += PAGE_SIZE, addr != end);
        pte_unmap(pte - 1);
 }
@@ -1955,7 +1956,7 @@ static int do_file_page(struct mm_struct * mm, struct vm_area_struct * vma,
         * Fall back to the linear mapping if the fs does not support
         * ->populate:
         */
-       if (!vma->vm_ops || !vma->vm_ops->populate || 
+       if (!vma->vm_ops->populate ||
                        (write_access && !(vma->vm_flags & VM_SHARED))) {
                pte_clear(mm, address, pte);
                return do_no_page(mm, vma, address, write_access, pte, pmd);
index b4eababc8198790961ead62cf421b2ac2c21aaf5..13492d66b7c809ff603f6c996f5ea1aafbe51a34 100644 (file)
@@ -664,10 +664,10 @@ asmlinkage long compat_sys_mbind(compat_ulong_t start, compat_ulong_t len,
 #endif
 
 /* Return effective policy for a VMA */
-static struct mempolicy *
-get_vma_policy(struct vm_area_struct *vma, unsigned long addr)
+struct mempolicy *
+get_vma_policy(struct task_struct *task, struct vm_area_struct *vma, unsigned long addr)
 {
-       struct mempolicy *pol = current->mempolicy;
+       struct mempolicy *pol = task->mempolicy;
 
        if (vma) {
                if (vma->vm_ops && vma->vm_ops->get_policy)
@@ -786,7 +786,7 @@ static struct page *alloc_page_interleave(unsigned int __nocast gfp, unsigned or
 struct page *
 alloc_page_vma(unsigned int __nocast gfp, struct vm_area_struct *vma, unsigned long addr)
 {
-       struct mempolicy *pol = get_vma_policy(vma, addr);
+       struct mempolicy *pol = get_vma_policy(current, vma, addr);
 
        cpuset_update_current_mems_allowed();
 
@@ -908,7 +908,7 @@ void __mpol_free(struct mempolicy *p)
 /* Find first node suitable for an allocation */
 int mpol_first_node(struct vm_area_struct *vma, unsigned long addr)
 {
-       struct mempolicy *pol = get_vma_policy(vma, addr);
+       struct mempolicy *pol = get_vma_policy(current, vma, addr);
 
        switch (pol->policy) {
        case MPOL_DEFAULT:
@@ -928,7 +928,7 @@ int mpol_first_node(struct vm_area_struct *vma, unsigned long addr)
 /* Find secondary valid nodes for an allocation */
 int mpol_node_valid(int nid, struct vm_area_struct *vma, unsigned long addr)
 {
-       struct mempolicy *pol = get_vma_policy(vma, addr);
+       struct mempolicy *pol = get_vma_policy(current, vma, addr);
 
        switch (pol->policy) {
        case MPOL_PREFERRED:
index fc45dc9a617b013f4db5aea5fe7898bf6cd677b6..a32fed454bd7c60e15da0c720b1631b55a3f8835 100644 (file)
@@ -141,6 +141,10 @@ move_one_page(struct vm_area_struct *vma, unsigned long old_addr,
                        if (dst) {
                                pte_t pte;
                                pte = ptep_clear_flush(vma, old_addr, src);
+                               /* ZERO_PAGE can be dependant on virtual addr */
+                               if (pfn_valid(pte_pfn(pte)) &&
+                                       pte_page(pte) == ZERO_PAGE(old_addr))
+                                       pte = pte_wrprotect(mk_pte(ZERO_PAGE(new_addr), new_vma->vm_page_prot));
                                set_pte_at(mm, new_addr, dst, pte);
                        } else
                                error = -ENOMEM;
index 8d088371196a559b5baa5a8dc02e2d07253fd50c..b06a9636d971d2a3e89dcab022047b24753d0479 100644 (file)
@@ -329,7 +329,7 @@ static inline void free_pages_check(const char *function, struct page *page)
                        1 << PG_writeback )))
                bad_page(function, page);
        if (PageDirty(page))
-               ClearPageDirty(page);
+               __ClearPageDirty(page);
 }
 
 /*
@@ -1130,19 +1130,20 @@ EXPORT_SYMBOL(nr_pagecache);
 DEFINE_PER_CPU(long, nr_pagecache_local) = 0;
 #endif
 
-void __get_page_state(struct page_state *ret, int nr)
+void __get_page_state(struct page_state *ret, int nr, cpumask_t *cpumask)
 {
        int cpu = 0;
 
        memset(ret, 0, sizeof(*ret));
+       cpus_and(*cpumask, *cpumask, cpu_online_map);
 
-       cpu = first_cpu(cpu_online_map);
+       cpu = first_cpu(*cpumask);
        while (cpu < NR_CPUS) {
                unsigned long *in, *out, off;
 
                in = (unsigned long *)&per_cpu(page_states, cpu);
 
-               cpu = next_cpu(cpu, cpu_online_map);
+               cpu = next_cpu(cpu, *cpumask);
 
                if (cpu < NR_CPUS)
                        prefetch(&per_cpu(page_states, cpu));
@@ -1153,19 +1154,33 @@ void __get_page_state(struct page_state *ret, int nr)
        }
 }
 
+void get_page_state_node(struct page_state *ret, int node)
+{
+       int nr;
+       cpumask_t mask = node_to_cpumask(node);
+
+       nr = offsetof(struct page_state, GET_PAGE_STATE_LAST);
+       nr /= sizeof(unsigned long);
+
+       __get_page_state(ret, nr+1, &mask);
+}
+
 void get_page_state(struct page_state *ret)
 {
        int nr;
+       cpumask_t mask = CPU_MASK_ALL;
 
        nr = offsetof(struct page_state, GET_PAGE_STATE_LAST);
        nr /= sizeof(unsigned long);
 
-       __get_page_state(ret, nr + 1);
+       __get_page_state(ret, nr + 1, &mask);
 }
 
 void get_full_page_state(struct page_state *ret)
 {
-       __get_page_state(ret, sizeof(*ret) / sizeof(unsigned long));
+       cpumask_t mask = CPU_MASK_ALL;
+
+       __get_page_state(ret, sizeof(*ret) / sizeof(unsigned long), &mask);
 }
 
 unsigned long __read_page_state(unsigned long offset)
@@ -1909,7 +1924,7 @@ static void __init free_area_init_core(struct pglist_data *pgdat,
                zone->nr_scan_inactive = 0;
                zone->nr_active = 0;
                zone->nr_inactive = 0;
-               atomic_set(&zone->reclaim_in_progress, -1);
+               atomic_set(&zone->reclaim_in_progress, 0);
                if (!size)
                        continue;
 
index 08ac5c7fa91fa02b42c03515749fb43ff057554e..450f5241b5a525282ae7eb150fe322423b01e570 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -34,9 +34,8 @@
  *       anon_vma->lock
  *         mm->page_table_lock
  *           zone->lru_lock (in mark_page_accessed)
- *           swap_list_lock (in swap_free etc's swap_info_get)
+ *           swap_lock (in swap_duplicate, swap_info_get)
  *             mmlist_lock (in mmput, drain_mmlist and others)
- *             swap_device_lock (in swap_duplicate, swap_info_get)
  *             mapping->private_lock (in __set_page_dirty_buffers)
  *             inode_lock (in set_page_dirty's __mark_inode_dirty)
  *               sb_lock (within inode_lock in fs/fs-writeback.c)
@@ -290,8 +289,6 @@ static int page_referenced_one(struct page *page,
        pte_t *pte;
        int referenced = 0;
 
-       if (!get_mm_counter(mm, rss))
-               goto out;
        address = vma_address(page, vma);
        if (address == -EFAULT)
                goto out;
@@ -442,22 +439,19 @@ int page_referenced(struct page *page, int is_locked, int ignore_token)
 void page_add_anon_rmap(struct page *page,
        struct vm_area_struct *vma, unsigned long address)
 {
-       struct anon_vma *anon_vma = vma->anon_vma;
-       pgoff_t index;
-
        BUG_ON(PageReserved(page));
-       BUG_ON(!anon_vma);
 
        inc_mm_counter(vma->vm_mm, anon_rss);
 
-       anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON;
-       index = (address - vma->vm_start) >> PAGE_SHIFT;
-       index += vma->vm_pgoff;
-       index >>= PAGE_CACHE_SHIFT - PAGE_SHIFT;
-
        if (atomic_inc_and_test(&page->_mapcount)) {
-               page->index = index;
+               struct anon_vma *anon_vma = vma->anon_vma;
+
+               BUG_ON(!anon_vma);
+               anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON;
                page->mapping = (struct address_space *) anon_vma;
+
+               page->index = linear_page_index(vma, address);
+
                inc_page_state(nr_mapped);
        }
        /* else checking page index and mapping is racy */
@@ -518,8 +512,6 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma)
        pte_t pteval;
        int ret = SWAP_AGAIN;
 
-       if (!get_mm_counter(mm, rss))
-               goto out;
        address = vma_address(page, vma);
        if (address == -EFAULT)
                goto out;
@@ -532,6 +524,8 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma)
         * If the page is mlock()d, we cannot swap it out.
         * If it's recently referenced (perhaps page_referenced
         * skipped over this mm) then we should reactivate it.
+        *
+        * Pages belonging to VM_RESERVED regions should not happen here.
         */
        if ((vma->vm_flags & (VM_LOCKED|VM_RESERVED)) ||
                        ptep_clear_flush_young(vma, address, pte)) {
@@ -767,8 +761,7 @@ static int try_to_unmap_file(struct page *page)
                        if (vma->vm_flags & (VM_LOCKED|VM_RESERVED))
                                continue;
                        cursor = (unsigned long) vma->vm_private_data;
-                       while (get_mm_counter(vma->vm_mm, rss) &&
-                               cursor < max_nl_cursor &&
+                       while ( cursor < max_nl_cursor &&
                                cursor < vma->vm_end - vma->vm_start) {
                                try_to_unmap_cluster(cursor, &mapcount, vma);
                                cursor += CLUSTER_SIZE;
index 5a81b1ee4f7a43fc972d7ec762f2d51d7ac8aa42..bdc4bbb6ddbb84f01d625870789695aa8cd61b07 100644 (file)
@@ -45,7 +45,6 @@
 #include <linux/swapops.h>
 #include <linux/mempolicy.h>
 #include <linux/namei.h>
-#include <linux/xattr.h>
 #include <asm/uaccess.h>
 #include <asm/div64.h>
 #include <asm/pgtable.h>
@@ -179,7 +178,6 @@ static struct address_space_operations shmem_aops;
 static struct file_operations shmem_file_operations;
 static struct inode_operations shmem_inode_operations;
 static struct inode_operations shmem_dir_inode_operations;
-static struct inode_operations shmem_special_inode_operations;
 static struct vm_operations_struct shmem_vm_ops;
 
 static struct backing_dev_info shmem_backing_dev_info = {
@@ -1195,6 +1193,7 @@ static int shmem_populate(struct vm_area_struct *vma,
                err = shmem_getpage(inode, pgoff, &page, sgp, NULL);
                if (err)
                        return err;
+               /* Page may still be null, but only if nonblock was set. */
                if (page) {
                        mark_page_accessed(page);
                        err = install_page(mm, vma, addr, page, prot);
@@ -1202,7 +1201,10 @@ static int shmem_populate(struct vm_area_struct *vma,
                                page_cache_release(page);
                                return err;
                        }
-               } else if (nonblock) {
+               } else {
+                       /* No page was found just because we can't read it in
+                        * now (being here implies nonblock != 0), but the page
+                        * may exist, so set the PTE to fault it in later. */
                        err = install_file_pte(mm, vma, addr, pgoff, prot);
                        if (err)
                                return err;
@@ -1296,7 +1298,6 @@ shmem_get_inode(struct super_block *sb, int mode, dev_t dev)
 
                switch (mode & S_IFMT) {
                default:
-                       inode->i_op = &shmem_special_inode_operations;
                        init_special_inode(inode, mode, dev);
                        break;
                case S_IFREG:
@@ -1800,12 +1801,6 @@ static void shmem_put_link(struct dentry *dentry, struct nameidata *nd, void *co
 static struct inode_operations shmem_symlink_inline_operations = {
        .readlink       = generic_readlink,
        .follow_link    = shmem_follow_link_inline,
-#ifdef CONFIG_TMPFS_XATTR
-       .setxattr       = generic_setxattr,
-       .getxattr       = generic_getxattr,
-       .listxattr      = generic_listxattr,
-       .removexattr    = generic_removexattr,
-#endif
 };
 
 static struct inode_operations shmem_symlink_inode_operations = {
@@ -1813,12 +1808,6 @@ static struct inode_operations shmem_symlink_inode_operations = {
        .readlink       = generic_readlink,
        .follow_link    = shmem_follow_link,
        .put_link       = shmem_put_link,
-#ifdef CONFIG_TMPFS_XATTR
-       .setxattr       = generic_setxattr,
-       .getxattr       = generic_getxattr,
-       .listxattr      = generic_listxattr,
-       .removexattr    = generic_removexattr,
-#endif
 };
 
 static int shmem_parse_options(char *options, int *mode, uid_t *uid, gid_t *gid, unsigned long *blocks, unsigned long *inodes)
@@ -1938,12 +1927,6 @@ static void shmem_put_super(struct super_block *sb)
        sb->s_fs_info = NULL;
 }
 
-#ifdef CONFIG_TMPFS_XATTR
-static struct xattr_handler *shmem_xattr_handlers[];
-#else
-#define shmem_xattr_handlers NULL
-#endif
-
 static int shmem_fill_super(struct super_block *sb,
                            void *data, int silent)
 {
@@ -1994,7 +1977,6 @@ static int shmem_fill_super(struct super_block *sb,
        sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
        sb->s_magic = TMPFS_MAGIC;
        sb->s_op = &shmem_ops;
-       sb->s_xattr = shmem_xattr_handlers;
 
        inode = shmem_get_inode(sb, S_IFDIR | mode, 0);
        if (!inode)
@@ -2083,12 +2065,6 @@ static struct file_operations shmem_file_operations = {
 static struct inode_operations shmem_inode_operations = {
        .truncate       = shmem_truncate,
        .setattr        = shmem_notify_change,
-#ifdef CONFIG_TMPFS_XATTR
-       .setxattr       = generic_setxattr,
-       .getxattr       = generic_getxattr,
-       .listxattr      = generic_listxattr,
-       .removexattr    = generic_removexattr,
-#endif
 };
 
 static struct inode_operations shmem_dir_inode_operations = {
@@ -2102,21 +2078,6 @@ static struct inode_operations shmem_dir_inode_operations = {
        .rmdir          = shmem_rmdir,
        .mknod          = shmem_mknod,
        .rename         = shmem_rename,
-#ifdef CONFIG_TMPFS_XATTR
-       .setxattr       = generic_setxattr,
-       .getxattr       = generic_getxattr,
-       .listxattr      = generic_listxattr,
-       .removexattr    = generic_removexattr,
-#endif
-#endif
-};
-
-static struct inode_operations shmem_special_inode_operations = {
-#ifdef CONFIG_TMPFS_XATTR
-       .setxattr       = generic_setxattr,
-       .getxattr       = generic_getxattr,
-       .listxattr      = generic_listxattr,
-       .removexattr    = generic_removexattr,
 #endif
 };
 
@@ -2142,48 +2103,6 @@ static struct vm_operations_struct shmem_vm_ops = {
 };
 
 
-#ifdef CONFIG_TMPFS_SECURITY
-
-static size_t shmem_xattr_security_list(struct inode *inode, char *list, size_t list_len,
-                                       const char *name, size_t name_len)
-{
-       return security_inode_listsecurity(inode, list, list_len);
-}
-
-static int shmem_xattr_security_get(struct inode *inode, const char *name, void *buffer, size_t size)
-{
-       if (strcmp(name, "") == 0)
-               return -EINVAL;
-       return security_inode_getsecurity(inode, name, buffer, size);
-}
-
-static int shmem_xattr_security_set(struct inode *inode, const char *name, const void *value, size_t size, int flags)
-{
-       if (strcmp(name, "") == 0)
-               return -EINVAL;
-       return security_inode_setsecurity(inode, name, value, size, flags);
-}
-
-static struct xattr_handler shmem_xattr_security_handler = {
-       .prefix = XATTR_SECURITY_PREFIX,
-       .list   = shmem_xattr_security_list,
-       .get    = shmem_xattr_security_get,
-       .set    = shmem_xattr_security_set,
-};
-
-#endif /* CONFIG_TMPFS_SECURITY */
-
-#ifdef CONFIG_TMPFS_XATTR
-
-static struct xattr_handler *shmem_xattr_handlers[] = {
-#ifdef CONFIG_TMPFS_SECURITY
-       &shmem_xattr_security_handler,
-#endif
-       NULL
-};
-
-#endif /* CONFIG_TMPFS_XATTR */
-
 static struct super_block *shmem_get_sb(struct file_system_type *fs_type,
        int flags, const char *dev_name, void *data)
 {
index c9e706db46340f81f723e899d45510cdfe78d50c..a9ff4f7f9860b2f1f37891fe4fe8c50a5caa637d 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
  * is less than 512 (PAGE_SIZE<<3), but greater than 256.
  */
 
+typedef unsigned int kmem_bufctl_t;
 #define BUFCTL_END     (((kmem_bufctl_t)(~0U))-0)
 #define BUFCTL_FREE    (((kmem_bufctl_t)(~0U))-1)
 #define        SLAB_LIMIT      (((kmem_bufctl_t)(~0U))-2)
@@ -600,7 +601,7 @@ static inline kmem_cache_t *__find_general_cachep(size_t size,
                csizep++;
 
        /*
-        * Really subtile: The last entry with cs->cs_size==ULONG_MAX
+        * Really subtle: The last entry with cs->cs_size==ULONG_MAX
         * has cs_{dma,}cachep==NULL. Thus no special case
         * for large kmalloc calls required.
         */
@@ -2165,7 +2166,9 @@ static inline void *__cache_alloc(kmem_cache_t *cachep, unsigned int __nocast fl
                objp = cache_alloc_refill(cachep, flags);
        }
        local_irq_restore(save_flags);
-       objp = cache_alloc_debugcheck_after(cachep, flags, objp, __builtin_return_address(0));
+       objp = cache_alloc_debugcheck_after(cachep, flags, objp,
+                                       __builtin_return_address(0));
+       prefetchw(objp);
        return objp;
 }
 
@@ -3073,20 +3076,24 @@ ssize_t slabinfo_write(struct file *file, const char __user *buffer,
 }
 #endif
 
+/**
+ * ksize - get the actual amount of memory allocated for a given object
+ * @objp: Pointer to the object
+ *
+ * kmalloc may internally round up allocations and return more memory
+ * than requested. ksize() can be used to determine the actual amount of
+ * memory allocated. The caller may use this additional memory, even though
+ * a smaller amount of memory was initially specified with the kmalloc call.
+ * The caller must guarantee that objp points to a valid object previously
+ * allocated with either kmalloc() or kmem_cache_alloc(). The object
+ * must not be freed during the duration of the call.
+ */
 unsigned int ksize(const void *objp)
 {
-       kmem_cache_t *c;
-       unsigned long flags;
-       unsigned int size = 0;
-
-       if (likely(objp != NULL)) {
-               local_irq_save(flags);
-               c = GET_PAGE_CACHE(virt_to_page(objp));
-               size = kmem_cache_size(c);
-               local_irq_restore(flags);
-       }
+       if (unlikely(objp == NULL))
+               return 0;
 
-       return size;
+       return obj_reallen(GET_PAGE_CACHE(virt_to_page(objp)));
 }
 
 
index b54e304df4a70c7232dcc9464f69582d68339993..347249a4917afa922f4c8ae5d38fbfe81c189a5a 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/mmzone.h>
 #include <linux/bootmem.h>
 #include <linux/module.h>
+#include <linux/spinlock.h>
 #include <asm/dma.h>
 
 /*
  *
  * 1) mem_section      - memory sections, mem_map's for valid memory
  */
-struct mem_section mem_section[NR_MEM_SECTIONS];
+#ifdef CONFIG_SPARSEMEM_EXTREME
+struct mem_section *mem_section[NR_SECTION_ROOTS]
+       ____cacheline_maxaligned_in_smp;
+#else
+struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT]
+       ____cacheline_maxaligned_in_smp;
+#endif
 EXPORT_SYMBOL(mem_section);
 
+#ifdef CONFIG_SPARSEMEM_EXTREME
+static struct mem_section *sparse_index_alloc(int nid)
+{
+       struct mem_section *section = NULL;
+       unsigned long array_size = SECTIONS_PER_ROOT *
+                                  sizeof(struct mem_section);
+
+       section = alloc_bootmem_node(NODE_DATA(nid), array_size);
+
+       if (section)
+               memset(section, 0, array_size);
+
+       return section;
+}
+
+static int sparse_index_init(unsigned long section_nr, int nid)
+{
+       static spinlock_t index_init_lock = SPIN_LOCK_UNLOCKED;
+       unsigned long root = SECTION_NR_TO_ROOT(section_nr);
+       struct mem_section *section;
+       int ret = 0;
+
+       if (mem_section[root])
+               return -EEXIST;
+
+       section = sparse_index_alloc(nid);
+       /*
+        * This lock keeps two different sections from
+        * reallocating for the same index
+        */
+       spin_lock(&index_init_lock);
+
+       if (mem_section[root]) {
+               ret = -EEXIST;
+               goto out;
+       }
+
+       mem_section[root] = section;
+out:
+       spin_unlock(&index_init_lock);
+       return ret;
+}
+#else /* !SPARSEMEM_EXTREME */
+static inline int sparse_index_init(unsigned long section_nr, int nid)
+{
+       return 0;
+}
+#endif
+
 /* Record a memory area against a node. */
 void memory_present(int nid, unsigned long start, unsigned long end)
 {
@@ -24,8 +80,13 @@ void memory_present(int nid, unsigned long start, unsigned long end)
        start &= PAGE_SECTION_MASK;
        for (pfn = start; pfn < end; pfn += PAGES_PER_SECTION) {
                unsigned long section = pfn_to_section_nr(pfn);
-               if (!mem_section[section].section_mem_map)
-                       mem_section[section].section_mem_map = SECTION_MARKED_PRESENT;
+               struct mem_section *ms;
+
+               sparse_index_init(section, nid);
+
+               ms = __nr_to_section(section);
+               if (!ms->section_mem_map)
+                       ms->section_mem_map = SECTION_MARKED_PRESENT;
        }
 }
 
@@ -85,6 +146,7 @@ static struct page *sparse_early_mem_map_alloc(unsigned long pnum)
 {
        struct page *map;
        int nid = early_pfn_to_nid(section_nr_to_pfn(pnum));
+       struct mem_section *ms = __nr_to_section(pnum);
 
        map = alloc_remap(nid, sizeof(struct page) * PAGES_PER_SECTION);
        if (map)
@@ -96,7 +158,7 @@ static struct page *sparse_early_mem_map_alloc(unsigned long pnum)
                return map;
 
        printk(KERN_WARNING "%s: allocation failed\n", __FUNCTION__);
-       mem_section[pnum].section_mem_map = 0;
+       ms->section_mem_map = 0;
        return NULL;
 }
 
@@ -114,8 +176,9 @@ void sparse_init(void)
                        continue;
 
                map = sparse_early_mem_map_alloc(pnum);
-               if (map)
-                       sparse_init_one_section(&mem_section[pnum], pnum, map);
+               if (!map)
+                       continue;
+               sparse_init_one_section(__nr_to_section(pnum), pnum, map);
        }
 }
 
index 4f251775ef902f3b83c5d680a9caa536773b3a60..029e56eb5e77c342559954e7c18c710a5c51092e 100644 (file)
@@ -124,6 +124,7 @@ void __delete_from_swap_cache(struct page *page)
        BUG_ON(!PageLocked(page));
        BUG_ON(!PageSwapCache(page));
        BUG_ON(PageWriteback(page));
+       BUG_ON(PagePrivate(page));
 
        radix_tree_delete(&swapper_space.page_tree, page->private);
        page->private = 0;
@@ -196,11 +197,6 @@ void delete_from_swap_cache(struct page *page)
 {
        swp_entry_t entry;
 
-       BUG_ON(!PageSwapCache(page));
-       BUG_ON(!PageLocked(page));
-       BUG_ON(PageWriteback(page));
-       BUG_ON(PagePrivate(page));
-  
        entry.val = page->private;
 
        write_lock_irq(&swapper_space.tree_lock);
index 60cd24a55204efc5c84956443d02f9806bd66a9d..4b6e8bf986bcad3080c23b9ad2424d24479d2f35 100644 (file)
@@ -31,7 +31,7 @@
 #include <asm/tlbflush.h>
 #include <linux/swapops.h>
 
-DEFINE_SPINLOCK(swaplock);
+DEFINE_SPINLOCK(swap_lock);
 unsigned int nr_swapfiles;
 long total_swap_pages;
 static int swap_overflow;
@@ -51,13 +51,11 @@ static DECLARE_MUTEX(swapon_sem);
 
 /*
  * We need this because the bdev->unplug_fn can sleep and we cannot
- * hold swap_list_lock while calling the unplug_fn. And swap_list_lock
+ * hold swap_lock while calling the unplug_fn. And swap_lock
  * cannot be turned into a semaphore.
  */
 static DECLARE_RWSEM(swap_unplug_sem);
 
-#define SWAPFILE_CLUSTER 256
-
 void swap_unplug_io_fn(struct backing_dev_info *unused_bdi, struct page *page)
 {
        swp_entry_t entry;
@@ -84,116 +82,135 @@ void swap_unplug_io_fn(struct backing_dev_info *unused_bdi, struct page *page)
        up_read(&swap_unplug_sem);
 }
 
-static inline int scan_swap_map(struct swap_info_struct *si)
+#define SWAPFILE_CLUSTER       256
+#define LATENCY_LIMIT          256
+
+static inline unsigned long scan_swap_map(struct swap_info_struct *si)
 {
-       unsigned long offset;
+       unsigned long offset, last_in_cluster;
+       int latency_ration = LATENCY_LIMIT;
+
        /* 
-        * We try to cluster swap pages by allocating them
-        * sequentially in swap.  Once we've allocated
-        * SWAPFILE_CLUSTER pages this way, however, we resort to
-        * first-free allocation, starting a new cluster.  This
-        * prevents us from scattering swap pages all over the entire
-        * swap partition, so that we reduce overall disk seek times
-        * between swap pages.  -- sct */
-       if (si->cluster_nr) {
-               while (si->cluster_next <= si->highest_bit) {
-                       offset = si->cluster_next++;
+        * We try to cluster swap pages by allocating them sequentially
+        * in swap.  Once we've allocated SWAPFILE_CLUSTER pages this
+        * way, however, we resort to first-free allocation, starting
+        * a new cluster.  This prevents us from scattering swap pages
+        * all over the entire swap partition, so that we reduce
+        * overall disk seek times between swap pages.  -- sct
+        * But we do now try to find an empty cluster.  -Andrea
+        */
+
+       si->flags += SWP_SCANNING;
+       if (unlikely(!si->cluster_nr)) {
+               si->cluster_nr = SWAPFILE_CLUSTER - 1;
+               if (si->pages - si->inuse_pages < SWAPFILE_CLUSTER)
+                       goto lowest;
+               spin_unlock(&swap_lock);
+
+               offset = si->lowest_bit;
+               last_in_cluster = offset + SWAPFILE_CLUSTER - 1;
+
+               /* Locate the first empty (unaligned) cluster */
+               for (; last_in_cluster <= si->highest_bit; offset++) {
                        if (si->swap_map[offset])
-                               continue;
-                       si->cluster_nr--;
-                       goto got_page;
-               }
-       }
-       si->cluster_nr = SWAPFILE_CLUSTER;
-
-       /* try to find an empty (even not aligned) cluster. */
-       offset = si->lowest_bit;
- check_next_cluster:
-       if (offset+SWAPFILE_CLUSTER-1 <= si->highest_bit)
-       {
-               unsigned long nr;
-               for (nr = offset; nr < offset+SWAPFILE_CLUSTER; nr++)
-                       if (si->swap_map[nr])
-                       {
-                               offset = nr+1;
-                               goto check_next_cluster;
+                               last_in_cluster = offset + SWAPFILE_CLUSTER;
+                       else if (offset == last_in_cluster) {
+                               spin_lock(&swap_lock);
+                               si->cluster_next = offset-SWAPFILE_CLUSTER-1;
+                               goto cluster;
                        }
-               /* We found a completly empty cluster, so start
-                * using it.
-                */
-               goto got_page;
+                       if (unlikely(--latency_ration < 0)) {
+                               cond_resched();
+                               latency_ration = LATENCY_LIMIT;
+                       }
+               }
+               spin_lock(&swap_lock);
+               goto lowest;
        }
-       /* No luck, so now go finegrined as usual. -Andrea */
-       for (offset = si->lowest_bit; offset <= si->highest_bit ; offset++) {
-               if (si->swap_map[offset])
-                       continue;
-               si->lowest_bit = offset+1;
-       got_page:
+
+       si->cluster_nr--;
+cluster:
+       offset = si->cluster_next;
+       if (offset > si->highest_bit)
+lowest:                offset = si->lowest_bit;
+checks:        if (!(si->flags & SWP_WRITEOK))
+               goto no_page;
+       if (!si->highest_bit)
+               goto no_page;
+       if (!si->swap_map[offset]) {
                if (offset == si->lowest_bit)
                        si->lowest_bit++;
                if (offset == si->highest_bit)
                        si->highest_bit--;
-               if (si->lowest_bit > si->highest_bit) {
+               si->inuse_pages++;
+               if (si->inuse_pages == si->pages) {
                        si->lowest_bit = si->max;
                        si->highest_bit = 0;
                }
                si->swap_map[offset] = 1;
-               si->inuse_pages++;
-               nr_swap_pages--;
-               si->cluster_next = offset+1;
+               si->cluster_next = offset + 1;
+               si->flags -= SWP_SCANNING;
                return offset;
        }
-       si->lowest_bit = si->max;
-       si->highest_bit = 0;
+
+       spin_unlock(&swap_lock);
+       while (++offset <= si->highest_bit) {
+               if (!si->swap_map[offset]) {
+                       spin_lock(&swap_lock);
+                       goto checks;
+               }
+               if (unlikely(--latency_ration < 0)) {
+                       cond_resched();
+                       latency_ration = LATENCY_LIMIT;
+               }
+       }
+       spin_lock(&swap_lock);
+       goto lowest;
+
+no_page:
+       si->flags -= SWP_SCANNING;
        return 0;
 }
 
 swp_entry_t get_swap_page(void)
 {
-       struct swap_info_struct * p;
-       unsigned long offset;
-       swp_entry_t entry;
-       int type, wrapped = 0;
+       struct swap_info_struct *si;
+       pgoff_t offset;
+       int type, next;
+       int wrapped = 0;
 
-       entry.val = 0;  /* Out of memory */
-       swap_list_lock();
-       type = swap_list.next;
-       if (type < 0)
-               goto out;
+       spin_lock(&swap_lock);
        if (nr_swap_pages <= 0)
-               goto out;
+               goto noswap;
+       nr_swap_pages--;
+
+       for (type = swap_list.next; type >= 0 && wrapped < 2; type = next) {
+               si = swap_info + type;
+               next = si->next;
+               if (next < 0 ||
+                   (!wrapped && si->prio != swap_info[next].prio)) {
+                       next = swap_list.head;
+                       wrapped++;
+               }
 
-       while (1) {
-               p = &swap_info[type];
-               if ((p->flags & SWP_ACTIVE) == SWP_ACTIVE) {
-                       swap_device_lock(p);
-                       offset = scan_swap_map(p);
-                       swap_device_unlock(p);
-                       if (offset) {
-                               entry = swp_entry(type,offset);
-                               type = swap_info[type].next;
-                               if (type < 0 ||
-                                       p->prio != swap_info[type].prio) {
-                                               swap_list.next = swap_list.head;
-                               } else {
-                                       swap_list.next = type;
-                               }
-                               goto out;
-                       }
+               if (!si->highest_bit)
+                       continue;
+               if (!(si->flags & SWP_WRITEOK))
+                       continue;
+
+               swap_list.next = next;
+               offset = scan_swap_map(si);
+               if (offset) {
+                       spin_unlock(&swap_lock);
+                       return swp_entry(type, offset);
                }
-               type = p->next;
-               if (!wrapped) {
-                       if (type < 0 || p->prio != swap_info[type].prio) {
-                               type = swap_list.head;
-                               wrapped = 1;
-                       }
-               } else
-                       if (type < 0)
-                               goto out;       /* out of swap space */
+               next = swap_list.next;
        }
-out:
-       swap_list_unlock();
-       return entry;
+
+       nr_swap_pages++;
+noswap:
+       spin_unlock(&swap_lock);
+       return (swp_entry_t) {0};
 }
 
 static struct swap_info_struct * swap_info_get(swp_entry_t entry)
@@ -214,10 +231,7 @@ static struct swap_info_struct * swap_info_get(swp_entry_t entry)
                goto bad_offset;
        if (!p->swap_map[offset])
                goto bad_free;
-       swap_list_lock();
-       if (p->prio > swap_info[swap_list.next].prio)
-               swap_list.next = type;
-       swap_device_lock(p);
+       spin_lock(&swap_lock);
        return p;
 
 bad_free:
@@ -235,12 +249,6 @@ out:
        return NULL;
 }      
 
-static void swap_info_put(struct swap_info_struct * p)
-{
-       swap_device_unlock(p);
-       swap_list_unlock();
-}
-
 static int swap_entry_free(struct swap_info_struct *p, unsigned long offset)
 {
        int count = p->swap_map[offset];
@@ -253,6 +261,8 @@ static int swap_entry_free(struct swap_info_struct *p, unsigned long offset)
                                p->lowest_bit = offset;
                        if (offset > p->highest_bit)
                                p->highest_bit = offset;
+                       if (p->prio > swap_info[swap_list.next].prio)
+                               swap_list.next = p - swap_info;
                        nr_swap_pages++;
                        p->inuse_pages--;
                }
@@ -271,7 +281,7 @@ void swap_free(swp_entry_t entry)
        p = swap_info_get(entry);
        if (p) {
                swap_entry_free(p, swp_offset(entry));
-               swap_info_put(p);
+               spin_unlock(&swap_lock);
        }
 }
 
@@ -289,7 +299,7 @@ static inline int page_swapcount(struct page *page)
        if (p) {
                /* Subtract the 1 for the swap cache itself */
                count = p->swap_map[swp_offset(entry)] - 1;
-               swap_info_put(p);
+               spin_unlock(&swap_lock);
        }
        return count;
 }
@@ -346,7 +356,7 @@ int remove_exclusive_swap_page(struct page *page)
                }
                write_unlock_irq(&swapper_space.tree_lock);
        }
-       swap_info_put(p);
+       spin_unlock(&swap_lock);
 
        if (retval) {
                swap_free(entry);
@@ -369,7 +379,7 @@ void free_swap_and_cache(swp_entry_t entry)
        if (p) {
                if (swap_entry_free(p, swp_offset(entry)) == 1)
                        page = find_trylock_page(&swapper_space, entry.val);
-               swap_info_put(p);
+               spin_unlock(&swap_lock);
        }
        if (page) {
                int one_user;
@@ -531,17 +541,18 @@ static int unuse_mm(struct mm_struct *mm,
  * Scan swap_map from current position to next entry still in use.
  * Recycle to start on reaching the end, returning 0 when empty.
  */
-static int find_next_to_unuse(struct swap_info_struct *si, int prev)
+static unsigned int find_next_to_unuse(struct swap_info_struct *si,
+                                       unsigned int prev)
 {
-       int max = si->max;
-       int i = prev;
+       unsigned int max = si->max;
+       unsigned int i = prev;
        int count;
 
        /*
-        * No need for swap_device_lock(si) here: we're just looking
+        * No need for swap_lock here: we're just looking
         * for whether an entry is in use, not modifying it; false
         * hits are okay, and sys_swapoff() has already prevented new
-        * allocations from this area (while holding swap_list_lock()).
+        * allocations from this area (while holding swap_lock).
         */
        for (;;) {
                if (++i >= max) {
@@ -577,7 +588,7 @@ static int try_to_unuse(unsigned int type)
        unsigned short swcount;
        struct page *page;
        swp_entry_t entry;
-       int i = 0;
+       unsigned int i = 0;
        int retval = 0;
        int reset_overflow = 0;
        int shmem;
@@ -731,9 +742,9 @@ static int try_to_unuse(unsigned int type)
                 * report them; but do report if we reset SWAP_MAP_MAX.
                 */
                if (*swap_map == SWAP_MAP_MAX) {
-                       swap_device_lock(si);
+                       spin_lock(&swap_lock);
                        *swap_map = 1;
-                       swap_device_unlock(si);
+                       spin_unlock(&swap_lock);
                        reset_overflow = 1;
                }
 
@@ -797,9 +808,9 @@ static int try_to_unuse(unsigned int type)
 }
 
 /*
- * After a successful try_to_unuse, if no swap is now in use, we know we
- * can empty the mmlist.  swap_list_lock must be held on entry and exit.
- * Note that mmlist_lock nests inside swap_list_lock, and an mm must be
+ * After a successful try_to_unuse, if no swap is now in use, we know
+ * we can empty the mmlist.  swap_lock must be held on entry and exit.
+ * Note that mmlist_lock nests inside swap_lock, and an mm must be
  * added to the mmlist just after page_duplicate - before would be racy.
  */
 static void drain_mmlist(void)
@@ -832,9 +843,9 @@ sector_t map_swap_page(struct swap_info_struct *sis, pgoff_t offset)
                                offset < (se->start_page + se->nr_pages)) {
                        return se->start_block + (offset - se->start_page);
                }
-               lh = se->list.prev;
+               lh = se->list.next;
                if (lh == &sis->extent_list)
-                       lh = lh->prev;
+                       lh = lh->next;
                se = list_entry(lh, struct swap_extent, list);
                sis->curr_swap_extent = se;
                BUG_ON(se == start_se);         /* It *must* be present */
@@ -854,15 +865,13 @@ static void destroy_swap_extents(struct swap_info_struct *sis)
                list_del(&se->list);
                kfree(se);
        }
-       sis->nr_extents = 0;
 }
 
 /*
  * Add a block range (and the corresponding page range) into this swapdev's
- * extent list.  The extent list is kept sorted in block order.
+ * extent list.  The extent list is kept sorted in page order.
  *
- * This function rather assumes that it is called in ascending sector_t order.
- * It doesn't look for extent coalescing opportunities.
+ * This function rather assumes that it is called in ascending page order.
  */
 static int
 add_swap_extent(struct swap_info_struct *sis, unsigned long start_page,
@@ -872,16 +881,15 @@ add_swap_extent(struct swap_info_struct *sis, unsigned long start_page,
        struct swap_extent *new_se;
        struct list_head *lh;
 
-       lh = sis->extent_list.next;     /* The highest-addressed block */
-       while (lh != &sis->extent_list) {
+       lh = sis->extent_list.prev;     /* The highest page extent */
+       if (lh != &sis->extent_list) {
                se = list_entry(lh, struct swap_extent, list);
-               if (se->start_block + se->nr_pages == start_block &&
-                   se->start_page  + se->nr_pages == start_page) {
+               BUG_ON(se->start_page + se->nr_pages != start_page);
+               if (se->start_block + se->nr_pages == start_block) {
                        /* Merge it */
                        se->nr_pages += nr_pages;
                        return 0;
                }
-               lh = lh->next;
        }
 
        /*
@@ -894,16 +902,8 @@ add_swap_extent(struct swap_info_struct *sis, unsigned long start_page,
        new_se->nr_pages = nr_pages;
        new_se->start_block = start_block;
 
-       lh = sis->extent_list.prev;     /* The lowest block */
-       while (lh != &sis->extent_list) {
-               se = list_entry(lh, struct swap_extent, list);
-               if (se->start_block > start_block)
-                       break;
-               lh = lh->prev;
-       }
-       list_add_tail(&new_se->list, lh);
-       sis->nr_extents++;
-       return 0;
+       list_add_tail(&new_se->list, &sis->extent_list);
+       return 1;
 }
 
 /*
@@ -926,7 +926,7 @@ add_swap_extent(struct swap_info_struct *sis, unsigned long start_page,
  * requirements, they are simply tossed out - we will never use those blocks
  * for swapping.
  *
- * For S_ISREG swapfiles we hold i_sem across the life of the swapon.  This
+ * For S_ISREG swapfiles we set S_SWAPFILE across the life of the swapon.  This
  * prevents root from shooting her foot off by ftruncating an in-use swapfile,
  * which will scribble on the fs.
  *
@@ -937,7 +937,7 @@ add_swap_extent(struct swap_info_struct *sis, unsigned long start_page,
  * This is extremely effective.  The average number of iterations in
  * map_swap_page() has been measured at about 0.3 per page.  - akpm.
  */
-static int setup_swap_extents(struct swap_info_struct *sis)
+static int setup_swap_extents(struct swap_info_struct *sis, sector_t *span)
 {
        struct inode *inode;
        unsigned blocks_per_page;
@@ -945,11 +945,15 @@ static int setup_swap_extents(struct swap_info_struct *sis)
        unsigned blkbits;
        sector_t probe_block;
        sector_t last_block;
+       sector_t lowest_block = -1;
+       sector_t highest_block = 0;
+       int nr_extents = 0;
        int ret;
 
        inode = sis->swap_file->f_mapping->host;
        if (S_ISBLK(inode->i_mode)) {
                ret = add_swap_extent(sis, 0, sis->max, 0);
+               *span = sis->pages;
                goto done;
        }
 
@@ -994,22 +998,32 @@ static int setup_swap_extents(struct swap_info_struct *sis)
                        }
                }
 
+               first_block >>= (PAGE_SHIFT - blkbits);
+               if (page_no) {  /* exclude the header page */
+                       if (first_block < lowest_block)
+                               lowest_block = first_block;
+                       if (first_block > highest_block)
+                               highest_block = first_block;
+               }
+
                /*
                 * We found a PAGE_SIZE-length, PAGE_SIZE-aligned run of blocks
                 */
-               ret = add_swap_extent(sis, page_no, 1,
-                               first_block >> (PAGE_SHIFT - blkbits));
-               if (ret)
+               ret = add_swap_extent(sis, page_no, 1, first_block);
+               if (ret < 0)
                        goto out;
+               nr_extents += ret;
                page_no++;
                probe_block += blocks_per_page;
 reprobe:
                continue;
        }
-       ret = 0;
+       ret = nr_extents;
+       *span = 1 + highest_block - lowest_block;
        if (page_no == 0)
-               ret = -EINVAL;
+               page_no = 1;    /* force Empty message */
        sis->max = page_no;
+       sis->pages = page_no - 1;
        sis->highest_bit = page_no - 1;
 done:
        sis->curr_swap_extent = list_entry(sis->extent_list.prev,
@@ -1069,7 +1083,7 @@ asmlinkage long sys_swapoff(const char __user * specialfile)
 
        mapping = victim->f_mapping;
        prev = -1;
-       swap_list_lock();
+       spin_lock(&swap_lock);
        for (type = swap_list.head; type >= 0; type = swap_info[type].next) {
                p = swap_info + type;
                if ((p->flags & SWP_ACTIVE) == SWP_ACTIVE) {
@@ -1080,14 +1094,14 @@ asmlinkage long sys_swapoff(const char __user * specialfile)
        }
        if (type < 0) {
                err = -EINVAL;
-               swap_list_unlock();
+               spin_unlock(&swap_lock);
                goto out_dput;
        }
        if (!security_vm_enough_memory(p->pages))
                vm_unacct_memory(p->pages);
        else {
                err = -ENOMEM;
-               swap_list_unlock();
+               spin_unlock(&swap_lock);
                goto out_dput;
        }
        if (prev < 0) {
@@ -1102,18 +1116,15 @@ asmlinkage long sys_swapoff(const char __user * specialfile)
        nr_swap_pages -= p->pages;
        total_swap_pages -= p->pages;
        p->flags &= ~SWP_WRITEOK;
-       swap_list_unlock();
+       spin_unlock(&swap_lock);
+
        current->flags |= PF_SWAPOFF;
        err = try_to_unuse(type);
        current->flags &= ~PF_SWAPOFF;
 
-       /* wait for any unplug function to finish */
-       down_write(&swap_unplug_sem);
-       up_write(&swap_unplug_sem);
-
        if (err) {
                /* re-insert swap space back into swap_list */
-               swap_list_lock();
+               spin_lock(&swap_lock);
                for (prev = -1, i = swap_list.head; i >= 0; prev = i, i = swap_info[i].next)
                        if (p->prio >= swap_info[i].prio)
                                break;
@@ -1125,22 +1136,35 @@ asmlinkage long sys_swapoff(const char __user * specialfile)
                nr_swap_pages += p->pages;
                total_swap_pages += p->pages;
                p->flags |= SWP_WRITEOK;
-               swap_list_unlock();
+               spin_unlock(&swap_lock);
                goto out_dput;
        }
+
+       /* wait for any unplug function to finish */
+       down_write(&swap_unplug_sem);
+       up_write(&swap_unplug_sem);
+
+       destroy_swap_extents(p);
        down(&swapon_sem);
-       swap_list_lock();
+       spin_lock(&swap_lock);
        drain_mmlist();
-       swap_device_lock(p);
+
+       /* wait for anyone still in scan_swap_map */
+       p->highest_bit = 0;             /* cuts scans short */
+       while (p->flags >= SWP_SCANNING) {
+               spin_unlock(&swap_lock);
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(1);
+               spin_lock(&swap_lock);
+       }
+
        swap_file = p->swap_file;
        p->swap_file = NULL;
        p->max = 0;
        swap_map = p->swap_map;
        p->swap_map = NULL;
        p->flags = 0;
-       destroy_swap_extents(p);
-       swap_device_unlock(p);
-       swap_list_unlock();
+       spin_unlock(&swap_lock);
        up(&swapon_sem);
        vfree(swap_map);
        inode = mapping->host;
@@ -1213,7 +1237,7 @@ static int swap_show(struct seq_file *swap, void *v)
 
        file = ptr->swap_file;
        len = seq_path(swap, file->f_vfsmnt, file->f_dentry, " \t\n\\");
-       seq_printf(swap, "%*s%s\t%d\t%ld\t%d\n",
+       seq_printf(swap, "%*s%s\t%u\t%u\t%d\n",
                       len < 40 ? 40 - len : 1, " ",
                       S_ISBLK(file->f_dentry->d_inode->i_mode) ?
                                "partition" : "file\t",
@@ -1272,7 +1296,9 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
        static int least_priority;
        union swap_header *swap_header = NULL;
        int swap_header_version;
-       int nr_good_pages = 0;
+       unsigned int nr_good_pages = 0;
+       int nr_extents = 0;
+       sector_t span;
        unsigned long maxpages = 1;
        int swapfilesize;
        unsigned short *swap_map;
@@ -1282,7 +1308,7 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
 
        if (!capable(CAP_SYS_ADMIN))
                return -EPERM;
-       swap_list_lock();
+       spin_lock(&swap_lock);
        p = swap_info;
        for (type = 0 ; type < nr_swapfiles ; type++,p++)
                if (!(p->flags & SWP_USED))
@@ -1301,14 +1327,13 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
         * swp_entry_t or the architecture definition of a swap pte.
         */
        if (type > swp_type(pte_to_swp_entry(swp_entry_to_pte(swp_entry(~0UL,0))))) {
-               swap_list_unlock();
+               spin_unlock(&swap_lock);
                goto out;
        }
        if (type >= nr_swapfiles)
                nr_swapfiles = type+1;
        INIT_LIST_HEAD(&p->extent_list);
        p->flags = SWP_USED;
-       p->nr_extents = 0;
        p->swap_file = NULL;
        p->old_block_size = 0;
        p->swap_map = NULL;
@@ -1316,7 +1341,6 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
        p->highest_bit = 0;
        p->cluster_nr = 0;
        p->inuse_pages = 0;
-       spin_lock_init(&p->sdev_lock);
        p->next = -1;
        if (swap_flags & SWAP_FLAG_PREFER) {
                p->prio =
@@ -1324,7 +1348,7 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
        } else {
                p->prio = --least_priority;
        }
-       swap_list_unlock();
+       spin_unlock(&swap_lock);
        name = getname(specialfile);
        error = PTR_ERR(name);
        if (IS_ERR(name)) {
@@ -1426,6 +1450,8 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
                }
 
                p->lowest_bit  = 1;
+               p->cluster_next = 1;
+
                /*
                 * Find out how many pages are allowed for a single swap
                 * device. There are two limiting factors: 1) the number of
@@ -1446,6 +1472,10 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
                p->highest_bit = maxpages - 1;
 
                error = -EINVAL;
+               if (!maxpages)
+                       goto bad_swap;
+               if (swap_header->info.nr_badpages && S_ISREG(inode->i_mode))
+                       goto bad_swap;
                if (swap_header->info.nr_badpages > MAX_SWAP_BADPAGES)
                        goto bad_swap;
                
@@ -1470,35 +1500,40 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
                if (error) 
                        goto bad_swap;
        }
-       
+
        if (swapfilesize && maxpages > swapfilesize) {
                printk(KERN_WARNING
                       "Swap area shorter than signature indicates\n");
                error = -EINVAL;
                goto bad_swap;
        }
+       if (nr_good_pages) {
+               p->swap_map[0] = SWAP_MAP_BAD;
+               p->max = maxpages;
+               p->pages = nr_good_pages;
+               nr_extents = setup_swap_extents(p, &span);
+               if (nr_extents < 0) {
+                       error = nr_extents;
+                       goto bad_swap;
+               }
+               nr_good_pages = p->pages;
+       }
        if (!nr_good_pages) {
                printk(KERN_WARNING "Empty swap-file\n");
                error = -EINVAL;
                goto bad_swap;
        }
-       p->swap_map[0] = SWAP_MAP_BAD;
-       p->max = maxpages;
-       p->pages = nr_good_pages;
-
-       error = setup_swap_extents(p);
-       if (error)
-               goto bad_swap;
 
        down(&swapon_sem);
-       swap_list_lock();
-       swap_device_lock(p);
+       spin_lock(&swap_lock);
        p->flags = SWP_ACTIVE;
        nr_swap_pages += nr_good_pages;
        total_swap_pages += nr_good_pages;
-       printk(KERN_INFO "Adding %dk swap on %s.  Priority:%d extents:%d\n",
-               nr_good_pages<<(PAGE_SHIFT-10), name,
-               p->prio, p->nr_extents);
+
+       printk(KERN_INFO "Adding %uk swap on %s.  "
+                       "Priority:%d extents:%d across:%lluk\n",
+               nr_good_pages<<(PAGE_SHIFT-10), name, p->prio,
+               nr_extents, (unsigned long long)span<<(PAGE_SHIFT-10));
 
        /* insert swap space into swap_list: */
        prev = -1;
@@ -1514,8 +1549,7 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
        } else {
                swap_info[prev].next = p - swap_info;
        }
-       swap_device_unlock(p);
-       swap_list_unlock();
+       spin_unlock(&swap_lock);
        up(&swapon_sem);
        error = 0;
        goto out;
@@ -1524,16 +1558,16 @@ bad_swap:
                set_blocksize(bdev, p->old_block_size);
                bd_release(bdev);
        }
+       destroy_swap_extents(p);
 bad_swap_2:
-       swap_list_lock();
+       spin_lock(&swap_lock);
        swap_map = p->swap_map;
        p->swap_file = NULL;
        p->swap_map = NULL;
        p->flags = 0;
        if (!(swap_flags & SWAP_FLAG_PREFER))
                ++least_priority;
-       swap_list_unlock();
-       destroy_swap_extents(p);
+       spin_unlock(&swap_lock);
        vfree(swap_map);
        if (swap_file)
                filp_close(swap_file, NULL);
@@ -1557,7 +1591,7 @@ void si_swapinfo(struct sysinfo *val)
        unsigned int i;
        unsigned long nr_to_be_unused = 0;
 
-       swap_list_lock();
+       spin_lock(&swap_lock);
        for (i = 0; i < nr_swapfiles; i++) {
                if (!(swap_info[i].flags & SWP_USED) ||
                     (swap_info[i].flags & SWP_WRITEOK))
@@ -1566,7 +1600,7 @@ void si_swapinfo(struct sysinfo *val)
        }
        val->freeswap = nr_swap_pages + nr_to_be_unused;
        val->totalswap = total_swap_pages + nr_to_be_unused;
-       swap_list_unlock();
+       spin_unlock(&swap_lock);
 }
 
 /*
@@ -1587,7 +1621,7 @@ int swap_duplicate(swp_entry_t entry)
        p = type + swap_info;
        offset = swp_offset(entry);
 
-       swap_device_lock(p);
+       spin_lock(&swap_lock);
        if (offset < p->max && p->swap_map[offset]) {
                if (p->swap_map[offset] < SWAP_MAP_MAX - 1) {
                        p->swap_map[offset]++;
@@ -1599,7 +1633,7 @@ int swap_duplicate(swp_entry_t entry)
                        result = 1;
                }
        }
-       swap_device_unlock(p);
+       spin_unlock(&swap_lock);
 out:
        return result;
 
@@ -1615,7 +1649,7 @@ get_swap_info_struct(unsigned type)
 }
 
 /*
- * swap_device_lock prevents swap_map being freed. Don't grab an extra
+ * swap_lock prevents swap_map being freed. Don't grab an extra
  * reference on the swaphandle, it doesn't matter if it becomes unused.
  */
 int valid_swaphandles(swp_entry_t entry, unsigned long *offset)
@@ -1631,7 +1665,7 @@ int valid_swaphandles(swp_entry_t entry, unsigned long *offset)
                toff++, i--;
        *offset = toff;
 
-       swap_device_lock(swapdev);
+       spin_lock(&swap_lock);
        do {
                /* Don't read-ahead past the end of the swap area */
                if (toff >= swapdev->max)
@@ -1644,6 +1678,6 @@ int valid_swaphandles(swp_entry_t entry, unsigned long *offset)
                toff++;
                ret++;
        } while (--i);
-       swap_device_unlock(swapdev);
+       spin_unlock(&swap_lock);
        return ret;
 }
index 8ff16a1eee6ad43e5a7bec93a207ee94392c2233..67b358e57ef67af05279196408c6c0bc430180c3 100644 (file)
@@ -158,8 +158,6 @@ int map_vm_area(struct vm_struct *area, pgprot_t prot, struct page ***pages)
        return err;
 }
 
-#define IOREMAP_MAX_ORDER      (7 + PAGE_SHIFT)        /* 128 pages */
-
 struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
                                unsigned long start, unsigned long end)
 {
index cfffe5098d538e6d54d1954c523d455924cbf7fc..0095533cdde963143f7988c048a110519cc50a31 100644 (file)
@@ -822,6 +822,8 @@ shrink_zone(struct zone *zone, struct scan_control *sc)
        unsigned long nr_active;
        unsigned long nr_inactive;
 
+       atomic_inc(&zone->reclaim_in_progress);
+
        /*
         * Add one to `nr_to_scan' just to make sure that the kernel will
         * slowly sift through the active list.
@@ -861,6 +863,8 @@ shrink_zone(struct zone *zone, struct scan_control *sc)
        }
 
        throttle_vm_writeout();
+
+       atomic_dec(&zone->reclaim_in_progress);
 }
 
 /*
@@ -900,9 +904,7 @@ shrink_caches(struct zone **zones, struct scan_control *sc)
                if (zone->all_unreclaimable && sc->priority != DEF_PRIORITY)
                        continue;       /* Let kswapd poll it */
 
-               atomic_inc(&zone->reclaim_in_progress);
                shrink_zone(zone, sc);
-               atomic_dec(&zone->reclaim_in_progress);
        }
 }
  
@@ -1358,14 +1360,13 @@ int zone_reclaim(struct zone *zone, unsigned int gfp_mask, unsigned int order)
                sc.swap_cluster_max = SWAP_CLUSTER_MAX;
 
        /* Don't reclaim the zone if there are other reclaimers active */
-       if (!atomic_inc_and_test(&zone->reclaim_in_progress))
+       if (atomic_read(&zone->reclaim_in_progress) > 0)
                goto out;
 
        shrink_zone(zone, &sc);
        total_reclaimed = sc.nr_reclaimed;
 
  out:
-       atomic_dec(&zone->reclaim_in_progress);
        return total_reclaimed;
 }
 
@@ -1375,6 +1376,9 @@ asmlinkage long sys_set_zone_reclaim(unsigned int node, unsigned int zone,
        struct zone *z;
        int i;
 
+       if (!capable(CAP_SYS_ADMIN))
+               return -EACCES;
+
        if (node >= MAX_NUMNODES || !node_online(node))
                return -EINVAL;
 
index c07aafb59a0fb5a829e68b14bf16c597137d15e3..2bdd5623fdd50889327bd4889e137f82bea6279c 100644 (file)
@@ -215,6 +215,7 @@ endmenu
 source "net/ax25/Kconfig"
 source "net/irda/Kconfig"
 source "net/bluetooth/Kconfig"
+source "net/ieee80211/Kconfig"
 
 endif   # if NET
 endmenu # Networking
index 7e6eff206c813f36d2df224f23d594637f40758b..4aa2f46d2a561f5ccc514a6f19312487cabba807 100644 (file)
@@ -44,6 +44,7 @@ obj-$(CONFIG_ECONET)          += econet/
 obj-$(CONFIG_VLAN_8021Q)       += 8021q/
 obj-$(CONFIG_IP_DCCP)          += dccp/
 obj-$(CONFIG_IP_SCTP)          += sctp/
+obj-$(CONFIG_IEEE80211)                += ieee80211/
 
 ifeq ($(CONFIG_NET),y)
 obj-$(CONFIG_SYSCTL)           += sysctl_net.o
index 4dbb5af34a5ed6bb67fae64501d96cbe04147593..d89056ec44d4ff11a842b045a8403253151cdae4 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "resources.h"
 #include "signaling.h"         /* for WAITING and sigd_attach */
+#include "common.h"
 
 
 static DECLARE_MUTEX(ioctl_mutex);
index 289c1b5a8e4a0bf4c497f999d35d5c4f9ea797e4..404b761e82ce8d712412717b58fb139478ed4b37 100644 (file)
@@ -695,7 +695,7 @@ static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
        return ret;
 }
 
-static int ethtool_get_perm_addr(struct net_device *dev, void *useraddr)
+static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr)
 {
        struct ethtool_perm_addr epaddr;
        u8 *data;
index cd91a24f97202f08944aea961153074d02b91449..079c2edff789e95ccc9fbcec96184c2eb2772e84 100644 (file)
@@ -182,7 +182,7 @@ int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen)
                                A = ntohl(*(u32 *)ptr);
                                continue;
                        }
-                       return 0;
+                       break;
                case BPF_LD|BPF_H|BPF_ABS:
                        k = fentry->k;
  load_h:
@@ -191,7 +191,7 @@ int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen)
                                A = ntohs(*(u16 *)ptr);
                                continue;
                        }
-                       return 0;
+                       break;
                case BPF_LD|BPF_B|BPF_ABS:
                        k = fentry->k;
 load_b:
@@ -200,7 +200,7 @@ load_b:
                                A = *(u8 *)ptr;
                                continue;
                        }
-                       return 0;
+                       break;
                case BPF_LD|BPF_W|BPF_LEN:
                        A = skb->len;
                        continue;
index ccd10fd65682202fd36942105fee17cb25fb8f51..c13594579bfb193009e22e2fbc0635cfd3a0b14b 100644 (file)
@@ -1719,8 +1719,8 @@ EXPORT_SYMBOL(sock_wfree);
 EXPORT_SYMBOL(sock_wmalloc);
 EXPORT_SYMBOL(sock_i_uid);
 EXPORT_SYMBOL(sock_i_ino);
-#ifdef CONFIG_SYSCTL
 EXPORT_SYMBOL(sysctl_optmem_max);
+#ifdef CONFIG_SYSCTL
 EXPORT_SYMBOL(sysctl_rmem_max);
 EXPORT_SYMBOL(sysctl_wmem_max);
 #endif
index 621680f127af940ce48fb3fc4486601f019eb371..348f36b529f741e2f82005f69e86a1d353a63761 100644 (file)
@@ -1876,8 +1876,27 @@ static inline unsigned int dn_current_mss(struct sock *sk, int flags)
        return mss_now;
 }
 
+/* 
+ * N.B. We get the timeout wrong here, but then we always did get it
+ * wrong before and this is another step along the road to correcting
+ * it. It ought to get updated each time we pass through the routine,
+ * but in practise it probably doesn't matter too much for now.
+ */
+static inline struct sk_buff *dn_alloc_send_pskb(struct sock *sk,
+                             unsigned long datalen, int noblock,
+                             int *errcode)
+{
+       struct sk_buff *skb = sock_alloc_send_skb(sk, datalen,
+                                                  noblock, errcode);
+       if (skb) {
+               skb->protocol = __constant_htons(ETH_P_DNA_RT);
+               skb->pkt_type = PACKET_OUTGOING;
+       }
+       return skb;
+}
+
 static int dn_sendmsg(struct kiocb *iocb, struct socket *sock,
-          struct msghdr *msg, size_t size)
+                     struct msghdr *msg, size_t size)
 {
        struct sock *sk = sock->sk;
        struct dn_scp *scp = DN_SK(sk);
@@ -1892,7 +1911,7 @@ static int dn_sendmsg(struct kiocb *iocb, struct socket *sock,
        struct dn_skb_cb *cb;
        size_t len;
        unsigned char fctype;
-       long timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT);
+       long timeo;
 
        if (flags & ~(MSG_TRYHARD|MSG_OOB|MSG_DONTWAIT|MSG_EOR|MSG_NOSIGNAL|MSG_MORE|MSG_CMSG_COMPAT))
                return -EOPNOTSUPP;
@@ -1900,18 +1919,21 @@ static int dn_sendmsg(struct kiocb *iocb, struct socket *sock,
        if (addr_len && (addr_len != sizeof(struct sockaddr_dn)))
                return -EINVAL;
 
+       lock_sock(sk);
+       timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT);
        /*
         * The only difference between stream sockets and sequenced packet
         * sockets is that the stream sockets always behave as if MSG_EOR
         * has been set.
         */
        if (sock->type == SOCK_STREAM) {
-               if (flags & MSG_EOR)
-                       return -EINVAL;
+               if (flags & MSG_EOR) {
+                       err = -EINVAL;
+                       goto out;
+               }
                flags |= MSG_EOR;
        }
 
-       lock_sock(sk);
 
        err = dn_check_state(sk, addr, addr_len, &timeo, flags);
        if (err)
@@ -1980,8 +2002,12 @@ static int dn_sendmsg(struct kiocb *iocb, struct socket *sock,
 
                /*
                 * Get a suitably sized skb.
+                * 64 is a bit of a hack really, but its larger than any
+                * link-layer headers and has served us well as a good
+                * guess as to their real length.
                 */
-               skb = dn_alloc_send_skb(sk, &len, flags & MSG_DONTWAIT, timeo, &err);
+               skb = dn_alloc_send_pskb(sk, len + 64 + DN_MAX_NSP_DATA_HEADER,
+                                        flags & MSG_DONTWAIT, &err);
 
                if (err)
                        break;
@@ -1991,7 +2017,7 @@ static int dn_sendmsg(struct kiocb *iocb, struct socket *sock,
 
                cb = DN_SKB_CB(skb);
 
-               skb_reserve(skb, DN_MAX_NSP_DATA_HEADER);
+               skb_reserve(skb, 64 + DN_MAX_NSP_DATA_HEADER);
 
                if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) {
                        err = -EFAULT;
index e0bebf4bbcadf60998f8d54f429af41eb4cfe08d..53633d352868766f699298754b0c6b192595f7bb 100644 (file)
@@ -136,69 +136,6 @@ struct sk_buff *dn_alloc_skb(struct sock *sk, int size, int pri)
        return skb;
 }
 
-/*
- * Wrapper for the above, for allocs of data skbs. We try and get the
- * whole size thats been asked for (plus 11 bytes of header). If this
- * fails, then we try for any size over 16 bytes for SOCK_STREAMS.
- */
-struct sk_buff *dn_alloc_send_skb(struct sock *sk, size_t *size, int noblock, long timeo, int *err)
-{
-       int space;
-       int len;
-       struct sk_buff *skb = NULL;
-
-       *err = 0;
-
-       while(skb == NULL) {
-               if (signal_pending(current)) {
-                       *err = sock_intr_errno(timeo);
-                       break;
-               }
-
-               if (sk->sk_shutdown & SEND_SHUTDOWN) {
-                       *err = EINVAL;
-                       break;
-               }
-
-               if (sk->sk_err)
-                       break;
-
-               len = *size + 11;
-               space = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc);
-
-               if (space < len) {
-                       if ((sk->sk_socket->type == SOCK_STREAM) &&
-                           (space >= (16 + 11)))
-                               len = space;
-               }
-
-               if (space < len) {
-                       set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
-                       if (noblock) {
-                               *err = EWOULDBLOCK;
-                               break;
-                       }
-
-                       clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags);
-                       SOCK_SLEEP_PRE(sk)
-
-                       if ((sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc)) <
-                           len)
-                               schedule();
-
-                       SOCK_SLEEP_POST(sk)
-                       continue;
-               }
-
-               if ((skb = dn_alloc_skb(sk, len, sk->sk_allocation)) == NULL)
-                       continue;
-
-               *size = len - 11;
-       }
-
-       return skb;
-}
-
 /*
  * Calculate persist timer based upon the smoothed round
  * trip time and the variance. Backoff according to the
diff --git a/net/ieee80211/Kconfig b/net/ieee80211/Kconfig
new file mode 100644 (file)
index 0000000..58ed431
--- /dev/null
@@ -0,0 +1,69 @@
+config IEEE80211
+       tristate "Generic IEEE 802.11 Networking Stack"
+       select NET_RADIO
+       ---help---
+       This option enables the hardware independent IEEE 802.11
+       networking stack.
+
+config IEEE80211_DEBUG
+       bool "Enable full debugging output"
+       depends on IEEE80211
+       ---help---
+         This option will enable debug tracing output for the
+         ieee80211 network stack.
+
+         This will result in the kernel module being ~70k larger.  You
+         can control which debug output is sent to the kernel log by
+         setting the value in
+
+         /proc/net/ieee80211/debug_level
+
+         For example:
+
+         % echo 0x00000FFO > /proc/net/ieee80211/debug_level
+
+         For a list of values you can assign to debug_level, you
+         can look at the bit mask values in <net/ieee80211.h>
+
+         If you are not trying to debug or develop the ieee80211
+         subsystem, you most likely want to say N here.
+
+config IEEE80211_CRYPT_WEP
+       tristate "IEEE 802.11 WEP encryption (802.1x)"
+       depends on IEEE80211
+       select CRYPTO
+       select CRYPTO_ARC4
+       select CRC32
+       ---help---
+       Include software based cipher suites in support of IEEE
+       802.11's WEP.  This is needed for WEP as well as 802.1x.
+
+       This can be compiled as a modules and it will be called
+       "ieee80211_crypt_wep".
+
+config IEEE80211_CRYPT_CCMP
+       tristate "IEEE 802.11i CCMP support"
+       depends on IEEE80211
+       select CRYPTO
+       select CRYPTO_AES
+       ---help---
+       Include software based cipher suites in support of IEEE 802.11i
+       (aka TGi, WPA, WPA2, WPA-PSK, etc.) for use with CCMP enabled
+       networks.
+
+       This can be compiled as a modules and it will be called
+       "ieee80211_crypt_ccmp".
+
+config IEEE80211_CRYPT_TKIP
+       tristate "IEEE 802.11i TKIP encryption"
+       depends on IEEE80211
+       select CRYPTO
+       select CRYPTO_MICHAEL_MIC
+       ---help---
+       Include software based cipher suites in support of IEEE 802.11i
+       (aka TGi, WPA, WPA2, WPA-PSK, etc.) for use with TKIP enabled
+       networks.
+
+       This can be compiled as a modules and it will be called
+       "ieee80211_crypt_tkip".
+
diff --git a/net/ieee80211/Makefile b/net/ieee80211/Makefile
new file mode 100644 (file)
index 0000000..a6ccac5
--- /dev/null
@@ -0,0 +1,11 @@
+obj-$(CONFIG_IEEE80211) += ieee80211.o
+obj-$(CONFIG_IEEE80211) += ieee80211_crypt.o
+obj-$(CONFIG_IEEE80211_CRYPT_WEP) += ieee80211_crypt_wep.o
+obj-$(CONFIG_IEEE80211_CRYPT_CCMP) += ieee80211_crypt_ccmp.o
+obj-$(CONFIG_IEEE80211_CRYPT_TKIP) += ieee80211_crypt_tkip.o
+ieee80211-objs := \
+       ieee80211_module.o \
+       ieee80211_tx.o \
+       ieee80211_rx.o \
+       ieee80211_wx.o
+
diff --git a/net/ieee80211/ieee80211_crypt.c b/net/ieee80211/ieee80211_crypt.c
new file mode 100644 (file)
index 0000000..05a6f2f
--- /dev/null
@@ -0,0 +1,259 @@
+/*
+ * Host AP crypto routines
+ *
+ * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
+ * Portions Copyright (C) 2004, Intel Corporation <jketreno@linux.intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. See README and COPYING for
+ * more details.
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <asm/string.h>
+#include <asm/errno.h>
+
+#include <net/ieee80211.h>
+
+MODULE_AUTHOR("Jouni Malinen");
+MODULE_DESCRIPTION("HostAP crypto");
+MODULE_LICENSE("GPL");
+
+struct ieee80211_crypto_alg {
+       struct list_head list;
+       struct ieee80211_crypto_ops *ops;
+};
+
+
+struct ieee80211_crypto {
+       struct list_head algs;
+       spinlock_t lock;
+};
+
+static struct ieee80211_crypto *hcrypt;
+
+void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee,
+                                          int force)
+{
+       struct list_head *ptr, *n;
+       struct ieee80211_crypt_data *entry;
+
+       for (ptr = ieee->crypt_deinit_list.next, n = ptr->next;
+            ptr != &ieee->crypt_deinit_list; ptr = n, n = ptr->next) {
+               entry = list_entry(ptr, struct ieee80211_crypt_data, list);
+
+               if (atomic_read(&entry->refcnt) != 0 && !force)
+                       continue;
+
+               list_del(ptr);
+
+               if (entry->ops) {
+                       entry->ops->deinit(entry->priv);
+                       module_put(entry->ops->owner);
+               }
+               kfree(entry);
+       }
+}
+
+void ieee80211_crypt_deinit_handler(unsigned long data)
+{
+       struct ieee80211_device *ieee = (struct ieee80211_device *)data;
+       unsigned long flags;
+
+       spin_lock_irqsave(&ieee->lock, flags);
+       ieee80211_crypt_deinit_entries(ieee, 0);
+       if (!list_empty(&ieee->crypt_deinit_list)) {
+               printk(KERN_DEBUG "%s: entries remaining in delayed crypt "
+                      "deletion list\n", ieee->dev->name);
+               ieee->crypt_deinit_timer.expires = jiffies + HZ;
+               add_timer(&ieee->crypt_deinit_timer);
+       }
+       spin_unlock_irqrestore(&ieee->lock, flags);
+
+}
+
+void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
+                                   struct ieee80211_crypt_data **crypt)
+{
+       struct ieee80211_crypt_data *tmp;
+       unsigned long flags;
+
+       if (*crypt == NULL)
+               return;
+
+       tmp = *crypt;
+       *crypt = NULL;
+
+       /* must not run ops->deinit() while there may be pending encrypt or
+        * decrypt operations. Use a list of delayed deinits to avoid needing
+        * locking. */
+
+       spin_lock_irqsave(&ieee->lock, flags);
+       list_add(&tmp->list, &ieee->crypt_deinit_list);
+       if (!timer_pending(&ieee->crypt_deinit_timer)) {
+               ieee->crypt_deinit_timer.expires = jiffies + HZ;
+               add_timer(&ieee->crypt_deinit_timer);
+       }
+       spin_unlock_irqrestore(&ieee->lock, flags);
+}
+
+int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops)
+{
+       unsigned long flags;
+       struct ieee80211_crypto_alg *alg;
+
+       if (hcrypt == NULL)
+               return -1;
+
+       alg = kmalloc(sizeof(*alg), GFP_KERNEL);
+       if (alg == NULL)
+               return -ENOMEM;
+
+       memset(alg, 0, sizeof(*alg));
+       alg->ops = ops;
+
+       spin_lock_irqsave(&hcrypt->lock, flags);
+       list_add(&alg->list, &hcrypt->algs);
+       spin_unlock_irqrestore(&hcrypt->lock, flags);
+
+       printk(KERN_DEBUG "ieee80211_crypt: registered algorithm '%s'\n",
+              ops->name);
+
+       return 0;
+}
+
+int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops)
+{
+       unsigned long flags;
+       struct list_head *ptr;
+       struct ieee80211_crypto_alg *del_alg = NULL;
+
+       if (hcrypt == NULL)
+               return -1;
+
+       spin_lock_irqsave(&hcrypt->lock, flags);
+       for (ptr = hcrypt->algs.next; ptr != &hcrypt->algs; ptr = ptr->next) {
+               struct ieee80211_crypto_alg *alg =
+                       (struct ieee80211_crypto_alg *) ptr;
+               if (alg->ops == ops) {
+                       list_del(&alg->list);
+                       del_alg = alg;
+                       break;
+               }
+       }
+       spin_unlock_irqrestore(&hcrypt->lock, flags);
+
+       if (del_alg) {
+               printk(KERN_DEBUG "ieee80211_crypt: unregistered algorithm "
+                      "'%s'\n", ops->name);
+               kfree(del_alg);
+       }
+
+       return del_alg ? 0 : -1;
+}
+
+
+struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name)
+{
+       unsigned long flags;
+       struct list_head *ptr;
+       struct ieee80211_crypto_alg *found_alg = NULL;
+
+       if (hcrypt == NULL)
+               return NULL;
+
+       spin_lock_irqsave(&hcrypt->lock, flags);
+       for (ptr = hcrypt->algs.next; ptr != &hcrypt->algs; ptr = ptr->next) {
+               struct ieee80211_crypto_alg *alg =
+                       (struct ieee80211_crypto_alg *) ptr;
+               if (strcmp(alg->ops->name, name) == 0) {
+                       found_alg = alg;
+                       break;
+               }
+       }
+       spin_unlock_irqrestore(&hcrypt->lock, flags);
+
+       if (found_alg)
+               return found_alg->ops;
+       else
+               return NULL;
+}
+
+
+static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; }
+static void ieee80211_crypt_null_deinit(void *priv) {}
+
+static struct ieee80211_crypto_ops ieee80211_crypt_null = {
+       .name                   = "NULL",
+       .init                   = ieee80211_crypt_null_init,
+       .deinit                 = ieee80211_crypt_null_deinit,
+       .encrypt_mpdu           = NULL,
+       .decrypt_mpdu           = NULL,
+       .encrypt_msdu           = NULL,
+       .decrypt_msdu           = NULL,
+       .set_key                = NULL,
+       .get_key                = NULL,
+       .extra_prefix_len       = 0,
+       .extra_postfix_len      = 0,
+       .owner                  = THIS_MODULE,
+};
+
+
+static int __init ieee80211_crypto_init(void)
+{
+       int ret = -ENOMEM;
+
+       hcrypt = kmalloc(sizeof(*hcrypt), GFP_KERNEL);
+       if (!hcrypt)
+               goto out;
+
+       memset(hcrypt, 0, sizeof(*hcrypt));
+       INIT_LIST_HEAD(&hcrypt->algs);
+       spin_lock_init(&hcrypt->lock);
+
+       ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null);
+       if (ret < 0) {
+               kfree(hcrypt);
+               hcrypt = NULL;
+       }
+out:
+       return ret;
+}
+
+
+static void __exit ieee80211_crypto_deinit(void)
+{
+       struct list_head *ptr, *n;
+
+       if (hcrypt == NULL)
+               return;
+
+       for (ptr = hcrypt->algs.next, n = ptr->next; ptr != &hcrypt->algs;
+            ptr = n, n = ptr->next) {
+               struct ieee80211_crypto_alg *alg =
+                       (struct ieee80211_crypto_alg *) ptr;
+               list_del(ptr);
+               printk(KERN_DEBUG "ieee80211_crypt: unregistered algorithm "
+                      "'%s' (deinit)\n", alg->ops->name);
+               kfree(alg);
+       }
+
+       kfree(hcrypt);
+}
+
+EXPORT_SYMBOL(ieee80211_crypt_deinit_entries);
+EXPORT_SYMBOL(ieee80211_crypt_deinit_handler);
+EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit);
+
+EXPORT_SYMBOL(ieee80211_register_crypto_ops);
+EXPORT_SYMBOL(ieee80211_unregister_crypto_ops);
+EXPORT_SYMBOL(ieee80211_get_crypto_ops);
+
+module_init(ieee80211_crypto_init);
+module_exit(ieee80211_crypto_deinit);
diff --git a/net/ieee80211/ieee80211_crypt_ccmp.c b/net/ieee80211/ieee80211_crypt_ccmp.c
new file mode 100644 (file)
index 0000000..11d1557
--- /dev/null
@@ -0,0 +1,470 @@
+/*
+ * Host AP crypt: host-based CCMP encryption implementation for Host AP driver
+ *
+ * Copyright (c) 2003-2004, Jouni Malinen <jkmaline@cc.hut.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. See README and COPYING for
+ * more details.
+ */
+
+#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/if_ether.h>
+#include <linux/if_arp.h>
+#include <asm/string.h>
+#include <linux/wireless.h>
+
+#include <net/ieee80211.h>
+
+
+#include <linux/crypto.h>
+#include <asm/scatterlist.h>
+
+MODULE_AUTHOR("Jouni Malinen");
+MODULE_DESCRIPTION("Host AP crypt: CCMP");
+MODULE_LICENSE("GPL");
+
+#define AES_BLOCK_LEN 16
+#define CCMP_HDR_LEN 8
+#define CCMP_MIC_LEN 8
+#define CCMP_TK_LEN 16
+#define CCMP_PN_LEN 6
+
+struct ieee80211_ccmp_data {
+       u8 key[CCMP_TK_LEN];
+       int key_set;
+
+       u8 tx_pn[CCMP_PN_LEN];
+       u8 rx_pn[CCMP_PN_LEN];
+
+       u32 dot11RSNAStatsCCMPFormatErrors;
+       u32 dot11RSNAStatsCCMPReplays;
+       u32 dot11RSNAStatsCCMPDecryptErrors;
+
+       int key_idx;
+
+       struct crypto_tfm *tfm;
+
+       /* scratch buffers for virt_to_page() (crypto API) */
+       u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN],
+               tx_e[AES_BLOCK_LEN], tx_s0[AES_BLOCK_LEN];
+       u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN];
+};
+
+static void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm,
+                                      const u8 pt[16], u8 ct[16])
+{
+       struct scatterlist src, dst;
+
+       src.page = virt_to_page(pt);
+       src.offset = offset_in_page(pt);
+       src.length = AES_BLOCK_LEN;
+
+       dst.page = virt_to_page(ct);
+       dst.offset = offset_in_page(ct);
+       dst.length = AES_BLOCK_LEN;
+
+       crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN);
+}
+
+static void * ieee80211_ccmp_init(int key_idx)
+{
+       struct ieee80211_ccmp_data *priv;
+
+       priv = kmalloc(sizeof(*priv), GFP_ATOMIC);
+       if (priv == NULL)
+               goto fail;
+       memset(priv, 0, sizeof(*priv));
+       priv->key_idx = key_idx;
+
+       priv->tfm = crypto_alloc_tfm("aes", 0);
+       if (priv->tfm == NULL) {
+               printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
+                      "crypto API aes\n");
+               goto fail;
+       }
+
+       return priv;
+
+fail:
+       if (priv) {
+               if (priv->tfm)
+                       crypto_free_tfm(priv->tfm);
+               kfree(priv);
+       }
+
+       return NULL;
+}
+
+
+static void ieee80211_ccmp_deinit(void *priv)
+{
+       struct ieee80211_ccmp_data *_priv = priv;
+       if (_priv && _priv->tfm)
+               crypto_free_tfm(_priv->tfm);
+       kfree(priv);
+}
+
+
+static inline void xor_block(u8 *b, u8 *a, size_t len)
+{
+       int i;
+       for (i = 0; i < len; i++)
+               b[i] ^= a[i];
+}
+
+
+static void ccmp_init_blocks(struct crypto_tfm *tfm,
+                            struct ieee80211_hdr *hdr,
+                            u8 *pn, size_t dlen, u8 *b0, u8 *auth,
+                            u8 *s0)
+{
+       u8 *pos, qc = 0;
+       size_t aad_len;
+       u16 fc;
+       int a4_included, qc_included;
+       u8 aad[2 * AES_BLOCK_LEN];
+
+       fc = le16_to_cpu(hdr->frame_ctl);
+       a4_included = ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
+                      (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS));
+       qc_included = ((WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA) &&
+                      (WLAN_FC_GET_STYPE(fc) & 0x08));
+       aad_len = 22;
+       if (a4_included)
+               aad_len += 6;
+       if (qc_included) {
+               pos = (u8 *) &hdr->addr4;
+               if (a4_included)
+                       pos += 6;
+               qc = *pos & 0x0f;
+               aad_len += 2;
+       }
+
+       /* CCM Initial Block:
+        * Flag (Include authentication header, M=3 (8-octet MIC),
+        *       L=1 (2-octet Dlen))
+        * Nonce: 0x00 | A2 | PN
+        * Dlen */
+       b0[0] = 0x59;
+       b0[1] = qc;
+       memcpy(b0 + 2, hdr->addr2, ETH_ALEN);
+       memcpy(b0 + 8, pn, CCMP_PN_LEN);
+       b0[14] = (dlen >> 8) & 0xff;
+       b0[15] = dlen & 0xff;
+
+       /* AAD:
+        * FC with bits 4..6 and 11..13 masked to zero; 14 is always one
+        * A1 | A2 | A3
+        * SC with bits 4..15 (seq#) masked to zero
+        * A4 (if present)
+        * QC (if present)
+        */
+       pos = (u8 *) hdr;
+       aad[0] = 0; /* aad_len >> 8 */
+       aad[1] = aad_len & 0xff;
+       aad[2] = pos[0] & 0x8f;
+       aad[3] = pos[1] & 0xc7;
+       memcpy(aad + 4, hdr->addr1, 3 * ETH_ALEN);
+       pos = (u8 *) &hdr->seq_ctl;
+       aad[22] = pos[0] & 0x0f;
+       aad[23] = 0; /* all bits masked */
+       memset(aad + 24, 0, 8);
+       if (a4_included)
+               memcpy(aad + 24, hdr->addr4, ETH_ALEN);
+       if (qc_included) {
+               aad[a4_included ? 30 : 24] = qc;
+               /* rest of QC masked */
+       }
+
+       /* Start with the first block and AAD */
+       ieee80211_ccmp_aes_encrypt(tfm, b0, auth);
+       xor_block(auth, aad, AES_BLOCK_LEN);
+       ieee80211_ccmp_aes_encrypt(tfm, auth, auth);
+       xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN);
+       ieee80211_ccmp_aes_encrypt(tfm, auth, auth);
+       b0[0] &= 0x07;
+       b0[14] = b0[15] = 0;
+       ieee80211_ccmp_aes_encrypt(tfm, b0, s0);
+}
+
+
+static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
+{
+       struct ieee80211_ccmp_data *key = priv;
+       int data_len, i, blocks, last, len;
+       u8 *pos, *mic;
+       struct ieee80211_hdr *hdr;
+       u8 *b0 = key->tx_b0;
+       u8 *b = key->tx_b;
+       u8 *e = key->tx_e;
+       u8 *s0 = key->tx_s0;
+
+       if (skb_headroom(skb) < CCMP_HDR_LEN ||
+           skb_tailroom(skb) < CCMP_MIC_LEN ||
+           skb->len < hdr_len)
+               return -1;
+
+       data_len = skb->len - hdr_len;
+       pos = skb_push(skb, CCMP_HDR_LEN);
+       memmove(pos, pos + CCMP_HDR_LEN, hdr_len);
+       pos += hdr_len;
+       mic = skb_put(skb, CCMP_MIC_LEN);
+
+       i = CCMP_PN_LEN - 1;
+       while (i >= 0) {
+               key->tx_pn[i]++;
+               if (key->tx_pn[i] != 0)
+                       break;
+               i--;
+       }
+
+       *pos++ = key->tx_pn[5];
+       *pos++ = key->tx_pn[4];
+       *pos++ = 0;
+       *pos++ = (key->key_idx << 6) | (1 << 5) /* Ext IV included */;
+       *pos++ = key->tx_pn[3];
+       *pos++ = key->tx_pn[2];
+       *pos++ = key->tx_pn[1];
+       *pos++ = key->tx_pn[0];
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0);
+
+       blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
+       last = data_len % AES_BLOCK_LEN;
+
+       for (i = 1; i <= blocks; i++) {
+               len = (i == blocks && last) ? last : AES_BLOCK_LEN;
+               /* Authentication */
+               xor_block(b, pos, len);
+               ieee80211_ccmp_aes_encrypt(key->tfm, b, b);
+               /* Encryption, with counter */
+               b0[14] = (i >> 8) & 0xff;
+               b0[15] = i & 0xff;
+               ieee80211_ccmp_aes_encrypt(key->tfm, b0, e);
+               xor_block(pos, e, len);
+               pos += len;
+       }
+
+       for (i = 0; i < CCMP_MIC_LEN; i++)
+               mic[i] = b[i] ^ s0[i];
+
+       return 0;
+}
+
+
+static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
+{
+       struct ieee80211_ccmp_data *key = priv;
+       u8 keyidx, *pos;
+       struct ieee80211_hdr *hdr;
+       u8 *b0 = key->rx_b0;
+       u8 *b = key->rx_b;
+       u8 *a = key->rx_a;
+       u8 pn[6];
+       int i, blocks, last, len;
+       size_t data_len = skb->len - hdr_len - CCMP_HDR_LEN - CCMP_MIC_LEN;
+       u8 *mic = skb->data + skb->len - CCMP_MIC_LEN;
+
+       if (skb->len < hdr_len + CCMP_HDR_LEN + CCMP_MIC_LEN) {
+               key->dot11RSNAStatsCCMPFormatErrors++;
+               return -1;
+       }
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       pos = skb->data + hdr_len;
+       keyidx = pos[3];
+       if (!(keyidx & (1 << 5))) {
+               if (net_ratelimit()) {
+                       printk(KERN_DEBUG "CCMP: received packet without ExtIV"
+                              " flag from " MAC_FMT "\n", MAC_ARG(hdr->addr2));
+               }
+               key->dot11RSNAStatsCCMPFormatErrors++;
+               return -2;
+       }
+       keyidx >>= 6;
+       if (key->key_idx != keyidx) {
+               printk(KERN_DEBUG "CCMP: RX tkey->key_idx=%d frame "
+                      "keyidx=%d priv=%p\n", key->key_idx, keyidx, priv);
+               return -6;
+       }
+       if (!key->key_set) {
+               if (net_ratelimit()) {
+                       printk(KERN_DEBUG "CCMP: received packet from " MAC_FMT
+                              " with keyid=%d that does not have a configured"
+                              " key\n", MAC_ARG(hdr->addr2), keyidx);
+               }
+               return -3;
+       }
+
+       pn[0] = pos[7];
+       pn[1] = pos[6];
+       pn[2] = pos[5];
+       pn[3] = pos[4];
+       pn[4] = pos[1];
+       pn[5] = pos[0];
+       pos += 8;
+
+       if (memcmp(pn, key->rx_pn, CCMP_PN_LEN) <= 0) {
+               if (net_ratelimit()) {
+                       printk(KERN_DEBUG "CCMP: replay detected: STA=" MAC_FMT
+                              " previous PN %02x%02x%02x%02x%02x%02x "
+                              "received PN %02x%02x%02x%02x%02x%02x\n",
+                              MAC_ARG(hdr->addr2), MAC_ARG(key->rx_pn),
+                              MAC_ARG(pn));
+               }
+               key->dot11RSNAStatsCCMPReplays++;
+               return -4;
+       }
+
+       ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b);
+       xor_block(mic, b, CCMP_MIC_LEN);
+
+       blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
+       last = data_len % AES_BLOCK_LEN;
+
+       for (i = 1; i <= blocks; i++) {
+               len = (i == blocks && last) ? last : AES_BLOCK_LEN;
+               /* Decrypt, with counter */
+               b0[14] = (i >> 8) & 0xff;
+               b0[15] = i & 0xff;
+               ieee80211_ccmp_aes_encrypt(key->tfm, b0, b);
+               xor_block(pos, b, len);
+               /* Authentication */
+               xor_block(a, pos, len);
+               ieee80211_ccmp_aes_encrypt(key->tfm, a, a);
+               pos += len;
+       }
+
+       if (memcmp(mic, a, CCMP_MIC_LEN) != 0) {
+               if (net_ratelimit()) {
+                       printk(KERN_DEBUG "CCMP: decrypt failed: STA="
+                              MAC_FMT "\n", MAC_ARG(hdr->addr2));
+               }
+               key->dot11RSNAStatsCCMPDecryptErrors++;
+               return -5;
+       }
+
+       memcpy(key->rx_pn, pn, CCMP_PN_LEN);
+
+       /* Remove hdr and MIC */
+       memmove(skb->data + CCMP_HDR_LEN, skb->data, hdr_len);
+       skb_pull(skb, CCMP_HDR_LEN);
+       skb_trim(skb, skb->len - CCMP_MIC_LEN);
+
+       return keyidx;
+}
+
+
+static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv)
+{
+       struct ieee80211_ccmp_data *data = priv;
+       int keyidx;
+       struct crypto_tfm *tfm = data->tfm;
+
+       keyidx = data->key_idx;
+       memset(data, 0, sizeof(*data));
+       data->key_idx = keyidx;
+       data->tfm = tfm;
+       if (len == CCMP_TK_LEN) {
+               memcpy(data->key, key, CCMP_TK_LEN);
+               data->key_set = 1;
+               if (seq) {
+                       data->rx_pn[0] = seq[5];
+                       data->rx_pn[1] = seq[4];
+                       data->rx_pn[2] = seq[3];
+                       data->rx_pn[3] = seq[2];
+                       data->rx_pn[4] = seq[1];
+                       data->rx_pn[5] = seq[0];
+               }
+               crypto_cipher_setkey(data->tfm, data->key, CCMP_TK_LEN);
+       } else if (len == 0)
+               data->key_set = 0;
+       else
+               return -1;
+
+       return 0;
+}
+
+
+static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv)
+{
+       struct ieee80211_ccmp_data *data = priv;
+
+       if (len < CCMP_TK_LEN)
+               return -1;
+
+       if (!data->key_set)
+               return 0;
+       memcpy(key, data->key, CCMP_TK_LEN);
+
+       if (seq) {
+               seq[0] = data->tx_pn[5];
+               seq[1] = data->tx_pn[4];
+               seq[2] = data->tx_pn[3];
+               seq[3] = data->tx_pn[2];
+               seq[4] = data->tx_pn[1];
+               seq[5] = data->tx_pn[0];
+       }
+
+       return CCMP_TK_LEN;
+}
+
+
+static char * ieee80211_ccmp_print_stats(char *p, void *priv)
+{
+       struct ieee80211_ccmp_data *ccmp = priv;
+       p += sprintf(p, "key[%d] alg=CCMP key_set=%d "
+                    "tx_pn=%02x%02x%02x%02x%02x%02x "
+                    "rx_pn=%02x%02x%02x%02x%02x%02x "
+                    "format_errors=%d replays=%d decrypt_errors=%d\n",
+                    ccmp->key_idx, ccmp->key_set,
+                    MAC_ARG(ccmp->tx_pn), MAC_ARG(ccmp->rx_pn),
+                    ccmp->dot11RSNAStatsCCMPFormatErrors,
+                    ccmp->dot11RSNAStatsCCMPReplays,
+                    ccmp->dot11RSNAStatsCCMPDecryptErrors);
+
+       return p;
+}
+
+
+static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = {
+       .name                   = "CCMP",
+       .init                   = ieee80211_ccmp_init,
+       .deinit                 = ieee80211_ccmp_deinit,
+       .encrypt_mpdu           = ieee80211_ccmp_encrypt,
+       .decrypt_mpdu           = ieee80211_ccmp_decrypt,
+       .encrypt_msdu           = NULL,
+       .decrypt_msdu           = NULL,
+       .set_key                = ieee80211_ccmp_set_key,
+       .get_key                = ieee80211_ccmp_get_key,
+       .print_stats            = ieee80211_ccmp_print_stats,
+       .extra_prefix_len       = CCMP_HDR_LEN,
+       .extra_postfix_len      = CCMP_MIC_LEN,
+       .owner                  = THIS_MODULE,
+};
+
+
+static int __init ieee80211_crypto_ccmp_init(void)
+{
+       return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp);
+}
+
+
+static void __exit ieee80211_crypto_ccmp_exit(void)
+{
+       ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp);
+}
+
+
+module_init(ieee80211_crypto_ccmp_init);
+module_exit(ieee80211_crypto_ccmp_exit);
diff --git a/net/ieee80211/ieee80211_crypt_tkip.c b/net/ieee80211/ieee80211_crypt_tkip.c
new file mode 100644 (file)
index 0000000..f91d92c
--- /dev/null
@@ -0,0 +1,708 @@
+/*
+ * Host AP crypt: host-based TKIP encryption implementation for Host AP driver
+ *
+ * Copyright (c) 2003-2004, Jouni Malinen <jkmaline@cc.hut.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. See README and COPYING for
+ * more details.
+ */
+
+#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/if_ether.h>
+#include <linux/if_arp.h>
+#include <asm/string.h>
+
+#include <net/ieee80211.h>
+
+
+#include <linux/crypto.h>
+#include <asm/scatterlist.h>
+#include <linux/crc32.h>
+
+MODULE_AUTHOR("Jouni Malinen");
+MODULE_DESCRIPTION("Host AP crypt: TKIP");
+MODULE_LICENSE("GPL");
+
+struct ieee80211_tkip_data {
+#define TKIP_KEY_LEN 32
+       u8 key[TKIP_KEY_LEN];
+       int key_set;
+
+       u32 tx_iv32;
+       u16 tx_iv16;
+       u16 tx_ttak[5];
+       int tx_phase1_done;
+
+       u32 rx_iv32;
+       u16 rx_iv16;
+       u16 rx_ttak[5];
+       int rx_phase1_done;
+       u32 rx_iv32_new;
+       u16 rx_iv16_new;
+
+       u32 dot11RSNAStatsTKIPReplays;
+       u32 dot11RSNAStatsTKIPICVErrors;
+       u32 dot11RSNAStatsTKIPLocalMICFailures;
+
+       int key_idx;
+
+       struct crypto_tfm *tfm_arc4;
+       struct crypto_tfm *tfm_michael;
+
+       /* scratch buffers for virt_to_page() (crypto API) */
+       u8 rx_hdr[16], tx_hdr[16];
+};
+
+static void * ieee80211_tkip_init(int key_idx)
+{
+       struct ieee80211_tkip_data *priv;
+
+       priv = kmalloc(sizeof(*priv), GFP_ATOMIC);
+       if (priv == NULL)
+               goto fail;
+       memset(priv, 0, sizeof(*priv));
+       priv->key_idx = key_idx;
+
+       priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0);
+       if (priv->tfm_arc4 == NULL) {
+               printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
+                      "crypto API arc4\n");
+               goto fail;
+       }
+
+       priv->tfm_michael = crypto_alloc_tfm("michael_mic", 0);
+       if (priv->tfm_michael == NULL) {
+               printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
+                      "crypto API michael_mic\n");
+               goto fail;
+       }
+
+       return priv;
+
+fail:
+       if (priv) {
+               if (priv->tfm_michael)
+                       crypto_free_tfm(priv->tfm_michael);
+               if (priv->tfm_arc4)
+                       crypto_free_tfm(priv->tfm_arc4);
+               kfree(priv);
+       }
+
+       return NULL;
+}
+
+
+static void ieee80211_tkip_deinit(void *priv)
+{
+       struct ieee80211_tkip_data *_priv = priv;
+       if (_priv && _priv->tfm_michael)
+               crypto_free_tfm(_priv->tfm_michael);
+       if (_priv && _priv->tfm_arc4)
+               crypto_free_tfm(_priv->tfm_arc4);
+       kfree(priv);
+}
+
+
+static inline u16 RotR1(u16 val)
+{
+       return (val >> 1) | (val << 15);
+}
+
+
+static inline u8 Lo8(u16 val)
+{
+       return val & 0xff;
+}
+
+
+static inline u8 Hi8(u16 val)
+{
+       return val >> 8;
+}
+
+
+static inline u16 Lo16(u32 val)
+{
+       return val & 0xffff;
+}
+
+
+static inline u16 Hi16(u32 val)
+{
+       return val >> 16;
+}
+
+
+static inline u16 Mk16(u8 hi, u8 lo)
+{
+       return lo | (((u16) hi) << 8);
+}
+
+
+static inline u16 Mk16_le(u16 *v)
+{
+       return le16_to_cpu(*v);
+}
+
+
+static const u16 Sbox[256] =
+{
+       0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154,
+       0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A,
+       0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B,
+       0x41EC, 0xB367, 0x5FFD, 0x45EA, 0x23BF, 0x53F7, 0xE496, 0x9B5B,
+       0x75C2, 0xE11C, 0x3DAE, 0x4C6A, 0x6C5A, 0x7E41, 0xF502, 0x834F,
+       0x685C, 0x51F4, 0xD134, 0xF908, 0xE293, 0xAB73, 0x6253, 0x2A3F,
+       0x080C, 0x9552, 0x4665, 0x9D5E, 0x3028, 0x37A1, 0x0A0F, 0x2FB5,
+       0x0E09, 0x2436, 0x1B9B, 0xDF3D, 0xCD26, 0x4E69, 0x7FCD, 0xEA9F,
+       0x121B, 0x1D9E, 0x5874, 0x342E, 0x362D, 0xDCB2, 0xB4EE, 0x5BFB,
+       0xA4F6, 0x764D, 0xB761, 0x7DCE, 0x527B, 0xDD3E, 0x5E71, 0x1397,
+       0xA6F5, 0xB968, 0x0000, 0xC12C, 0x4060, 0xE31F, 0x79C8, 0xB6ED,
+       0xD4BE, 0x8D46, 0x67D9, 0x724B, 0x94DE, 0x98D4, 0xB0E8, 0x854A,
+       0xBB6B, 0xC52A, 0x4FE5, 0xED16, 0x86C5, 0x9AD7, 0x6655, 0x1194,
+       0x8ACF, 0xE910, 0x0406, 0xFE81, 0xA0F0, 0x7844, 0x25BA, 0x4BE3,
+       0xA2F3, 0x5DFE, 0x80C0, 0x058A, 0x3FAD, 0x21BC, 0x7048, 0xF104,
+       0x63DF, 0x77C1, 0xAF75, 0x4263, 0x2030, 0xE51A, 0xFD0E, 0xBF6D,
+       0x814C, 0x1814, 0x2635, 0xC32F, 0xBEE1, 0x35A2, 0x88CC, 0x2E39,
+       0x9357, 0x55F2, 0xFC82, 0x7A47, 0xC8AC, 0xBAE7, 0x322B, 0xE695,
+       0xC0A0, 0x1998, 0x9ED1, 0xA37F, 0x4466, 0x547E, 0x3BAB, 0x0B83,
+       0x8CCA, 0xC729, 0x6BD3, 0x283C, 0xA779, 0xBCE2, 0x161D, 0xAD76,
+       0xDB3B, 0x6456, 0x744E, 0x141E, 0x92DB, 0x0C0A, 0x486C, 0xB8E4,
+       0x9F5D, 0xBD6E, 0x43EF, 0xC4A6, 0x39A8, 0x31A4, 0xD337, 0xF28B,
+       0xD532, 0x8B43, 0x6E59, 0xDAB7, 0x018C, 0xB164, 0x9CD2, 0x49E0,
+       0xD8B4, 0xACFA, 0xF307, 0xCF25, 0xCAAF, 0xF48E, 0x47E9, 0x1018,
+       0x6FD5, 0xF088, 0x4A6F, 0x5C72, 0x3824, 0x57F1, 0x73C7, 0x9751,
+       0xCB23, 0xA17C, 0xE89C, 0x3E21, 0x96DD, 0x61DC, 0x0D86, 0x0F85,
+       0xE090, 0x7C42, 0x71C4, 0xCCAA, 0x90D8, 0x0605, 0xF701, 0x1C12,
+       0xC2A3, 0x6A5F, 0xAEF9, 0x69D0, 0x1791, 0x9958, 0x3A27, 0x27B9,
+       0xD938, 0xEB13, 0x2BB3, 0x2233, 0xD2BB, 0xA970, 0x0789, 0x33A7,
+       0x2DB6, 0x3C22, 0x1592, 0xC920, 0x8749, 0xAAFF, 0x5078, 0xA57A,
+       0x038F, 0x59F8, 0x0980, 0x1A17, 0x65DA, 0xD731, 0x84C6, 0xD0B8,
+       0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A,
+};
+
+
+static inline u16 _S_(u16 v)
+{
+       u16 t = Sbox[Hi8(v)];
+       return Sbox[Lo8(v)] ^ ((t << 8) | (t >> 8));
+}
+
+
+#define PHASE1_LOOP_COUNT 8
+
+static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32)
+{
+       int i, j;
+
+       /* Initialize the 80-bit TTAK from TSC (IV32) and TA[0..5] */
+       TTAK[0] = Lo16(IV32);
+       TTAK[1] = Hi16(IV32);
+       TTAK[2] = Mk16(TA[1], TA[0]);
+       TTAK[3] = Mk16(TA[3], TA[2]);
+       TTAK[4] = Mk16(TA[5], TA[4]);
+
+       for (i = 0; i < PHASE1_LOOP_COUNT; i++) {
+               j = 2 * (i & 1);
+               TTAK[0] += _S_(TTAK[4] ^ Mk16(TK[1 + j], TK[0 + j]));
+               TTAK[1] += _S_(TTAK[0] ^ Mk16(TK[5 + j], TK[4 + j]));
+               TTAK[2] += _S_(TTAK[1] ^ Mk16(TK[9 + j], TK[8 + j]));
+               TTAK[3] += _S_(TTAK[2] ^ Mk16(TK[13 + j], TK[12 + j]));
+               TTAK[4] += _S_(TTAK[3] ^ Mk16(TK[1 + j], TK[0 + j])) + i;
+       }
+}
+
+
+static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
+                              u16 IV16)
+{
+       /* Make temporary area overlap WEP seed so that the final copy can be
+        * avoided on little endian hosts. */
+       u16 *PPK = (u16 *) &WEPSeed[4];
+
+       /* Step 1 - make copy of TTAK and bring in TSC */
+       PPK[0] = TTAK[0];
+       PPK[1] = TTAK[1];
+       PPK[2] = TTAK[2];
+       PPK[3] = TTAK[3];
+       PPK[4] = TTAK[4];
+       PPK[5] = TTAK[4] + IV16;
+
+       /* Step 2 - 96-bit bijective mixing using S-box */
+       PPK[0] += _S_(PPK[5] ^ Mk16_le((u16 *) &TK[0]));
+       PPK[1] += _S_(PPK[0] ^ Mk16_le((u16 *) &TK[2]));
+       PPK[2] += _S_(PPK[1] ^ Mk16_le((u16 *) &TK[4]));
+       PPK[3] += _S_(PPK[2] ^ Mk16_le((u16 *) &TK[6]));
+       PPK[4] += _S_(PPK[3] ^ Mk16_le((u16 *) &TK[8]));
+       PPK[5] += _S_(PPK[4] ^ Mk16_le((u16 *) &TK[10]));
+
+       PPK[0] += RotR1(PPK[5] ^ Mk16_le((u16 *) &TK[12]));
+       PPK[1] += RotR1(PPK[0] ^ Mk16_le((u16 *) &TK[14]));
+       PPK[2] += RotR1(PPK[1]);
+       PPK[3] += RotR1(PPK[2]);
+       PPK[4] += RotR1(PPK[3]);
+       PPK[5] += RotR1(PPK[4]);
+
+       /* Step 3 - bring in last of TK bits, assign 24-bit WEP IV value
+        * WEPSeed[0..2] is transmitted as WEP IV */
+       WEPSeed[0] = Hi8(IV16);
+       WEPSeed[1] = (Hi8(IV16) | 0x20) & 0x7F;
+       WEPSeed[2] = Lo8(IV16);
+       WEPSeed[3] = Lo8((PPK[5] ^ Mk16_le((u16 *) &TK[0])) >> 1);
+
+#ifdef __BIG_ENDIAN
+       {
+               int i;
+               for (i = 0; i < 6; i++)
+                       PPK[i] = (PPK[i] << 8) | (PPK[i] >> 8);
+       }
+#endif
+}
+
+static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
+{
+       struct ieee80211_tkip_data *tkey = priv;
+       int len;
+       u8 rc4key[16], *pos, *icv;
+       struct ieee80211_hdr *hdr;
+       u32 crc;
+       struct scatterlist sg;
+
+       if (skb_headroom(skb) < 8 || skb_tailroom(skb) < 4 ||
+           skb->len < hdr_len)
+               return -1;
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       if (!tkey->tx_phase1_done) {
+               tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2,
+                                  tkey->tx_iv32);
+               tkey->tx_phase1_done = 1;
+       }
+       tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);
+
+       len = skb->len - hdr_len;
+       pos = skb_push(skb, 8);
+       memmove(pos, pos + 8, hdr_len);
+       pos += hdr_len;
+       icv = skb_put(skb, 4);
+
+       *pos++ = rc4key[0];
+       *pos++ = rc4key[1];
+       *pos++ = rc4key[2];
+       *pos++ = (tkey->key_idx << 6) | (1 << 5) /* Ext IV included */;
+       *pos++ = tkey->tx_iv32 & 0xff;
+       *pos++ = (tkey->tx_iv32 >> 8) & 0xff;
+       *pos++ = (tkey->tx_iv32 >> 16) & 0xff;
+       *pos++ = (tkey->tx_iv32 >> 24) & 0xff;
+
+       crc = ~crc32_le(~0, pos, len);
+       icv[0] = crc;
+       icv[1] = crc >> 8;
+       icv[2] = crc >> 16;
+       icv[3] = crc >> 24;
+
+       crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16);
+       sg.page = virt_to_page(pos);
+       sg.offset = offset_in_page(pos);
+       sg.length = len + 4;
+       crypto_cipher_encrypt(tkey->tfm_arc4, &sg, &sg, len + 4);
+
+       tkey->tx_iv16++;
+       if (tkey->tx_iv16 == 0) {
+               tkey->tx_phase1_done = 0;
+               tkey->tx_iv32++;
+       }
+
+       return 0;
+}
+
+static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
+{
+       struct ieee80211_tkip_data *tkey = priv;
+       u8 rc4key[16];
+       u8 keyidx, *pos;
+       u32 iv32;
+       u16 iv16;
+       struct ieee80211_hdr *hdr;
+       u8 icv[4];
+       u32 crc;
+       struct scatterlist sg;
+       int plen;
+
+       if (skb->len < hdr_len + 8 + 4)
+               return -1;
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       pos = skb->data + hdr_len;
+       keyidx = pos[3];
+       if (!(keyidx & (1 << 5))) {
+               if (net_ratelimit()) {
+                       printk(KERN_DEBUG "TKIP: received packet without ExtIV"
+                              " flag from " MAC_FMT "\n", MAC_ARG(hdr->addr2));
+               }
+               return -2;
+       }
+       keyidx >>= 6;
+       if (tkey->key_idx != keyidx) {
+               printk(KERN_DEBUG "TKIP: RX tkey->key_idx=%d frame "
+                      "keyidx=%d priv=%p\n", tkey->key_idx, keyidx, priv);
+               return -6;
+       }
+       if (!tkey->key_set) {
+               if (net_ratelimit()) {
+                       printk(KERN_DEBUG "TKIP: received packet from " MAC_FMT
+                              " with keyid=%d that does not have a configured"
+                              " key\n", MAC_ARG(hdr->addr2), keyidx);
+               }
+               return -3;
+       }
+       iv16 = (pos[0] << 8) | pos[2];
+       iv32 = pos[4] | (pos[5] << 8) | (pos[6] << 16) | (pos[7] << 24);
+       pos += 8;
+
+       if (iv32 < tkey->rx_iv32 ||
+           (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) {
+               if (net_ratelimit()) {
+                       printk(KERN_DEBUG "TKIP: replay detected: STA=" MAC_FMT
+                              " previous TSC %08x%04x received TSC "
+                              "%08x%04x\n", MAC_ARG(hdr->addr2),
+                              tkey->rx_iv32, tkey->rx_iv16, iv32, iv16);
+               }
+               tkey->dot11RSNAStatsTKIPReplays++;
+               return -4;
+       }
+
+       if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) {
+               tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32);
+               tkey->rx_phase1_done = 1;
+       }
+       tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16);
+
+       plen = skb->len - hdr_len - 12;
+
+       crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16);
+       sg.page = virt_to_page(pos);
+       sg.offset = offset_in_page(pos);
+       sg.length = plen + 4;
+       crypto_cipher_decrypt(tkey->tfm_arc4, &sg, &sg, plen + 4);
+
+       crc = ~crc32_le(~0, pos, plen);
+       icv[0] = crc;
+       icv[1] = crc >> 8;
+       icv[2] = crc >> 16;
+       icv[3] = crc >> 24;
+       if (memcmp(icv, pos + plen, 4) != 0) {
+               if (iv32 != tkey->rx_iv32) {
+                       /* Previously cached Phase1 result was already lost, so
+                        * it needs to be recalculated for the next packet. */
+                       tkey->rx_phase1_done = 0;
+               }
+               if (net_ratelimit()) {
+                       printk(KERN_DEBUG "TKIP: ICV error detected: STA="
+                              MAC_FMT "\n", MAC_ARG(hdr->addr2));
+               }
+               tkey->dot11RSNAStatsTKIPICVErrors++;
+               return -5;
+       }
+
+       /* Update real counters only after Michael MIC verification has
+        * completed */
+       tkey->rx_iv32_new = iv32;
+       tkey->rx_iv16_new = iv16;
+
+       /* Remove IV and ICV */
+       memmove(skb->data + 8, skb->data, hdr_len);
+       skb_pull(skb, 8);
+       skb_trim(skb, skb->len - 4);
+
+       return keyidx;
+}
+
+
+static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr,
+                      u8 *data, size_t data_len, u8 *mic)
+{
+       struct scatterlist sg[2];
+
+       if (tkey->tfm_michael == NULL) {
+               printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n");
+               return -1;
+       }
+       sg[0].page = virt_to_page(hdr);
+       sg[0].offset = offset_in_page(hdr);
+       sg[0].length = 16;
+
+       sg[1].page = virt_to_page(data);
+       sg[1].offset = offset_in_page(data);
+       sg[1].length = data_len;
+
+       crypto_digest_init(tkey->tfm_michael);
+       crypto_digest_setkey(tkey->tfm_michael, key, 8);
+       crypto_digest_update(tkey->tfm_michael, sg, 2);
+       crypto_digest_final(tkey->tfm_michael, mic);
+
+       return 0;
+}
+
+static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr)
+{
+       struct ieee80211_hdr *hdr11;
+
+       hdr11 = (struct ieee80211_hdr *) skb->data;
+       switch (le16_to_cpu(hdr11->frame_ctl) &
+               (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
+       case IEEE80211_FCTL_TODS:
+               memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
+               memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
+               break;
+       case IEEE80211_FCTL_FROMDS:
+               memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
+               memcpy(hdr + ETH_ALEN, hdr11->addr3, ETH_ALEN); /* SA */
+               break;
+       case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
+               memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
+               memcpy(hdr + ETH_ALEN, hdr11->addr4, ETH_ALEN); /* SA */
+               break;
+       case 0:
+               memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
+               memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
+               break;
+       }
+
+       hdr[12] = 0; /* priority */
+       hdr[13] = hdr[14] = hdr[15] = 0; /* reserved */
+}
+
+
+static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv)
+{
+       struct ieee80211_tkip_data *tkey = priv;
+       u8 *pos;
+
+       if (skb_tailroom(skb) < 8 || skb->len < hdr_len) {
+               printk(KERN_DEBUG "Invalid packet for Michael MIC add "
+                      "(tailroom=%d hdr_len=%d skb->len=%d)\n",
+                      skb_tailroom(skb), hdr_len, skb->len);
+               return -1;
+       }
+
+       michael_mic_hdr(skb, tkey->tx_hdr);
+       pos = skb_put(skb, 8);
+       if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr,
+                       skb->data + hdr_len, skb->len - 8 - hdr_len, pos))
+               return -1;
+
+       return 0;
+}
+
+
+#if WIRELESS_EXT >= 18
+static void ieee80211_michael_mic_failure(struct net_device *dev,
+                                      struct ieee80211_hdr *hdr,
+                                      int keyidx)
+{
+       union iwreq_data wrqu;
+       struct iw_michaelmicfailure ev;
+
+       /* TODO: needed parameters: count, keyid, key type, TSC */
+       memset(&ev, 0, sizeof(ev));
+       ev.flags = keyidx & IW_MICFAILURE_KEY_ID;
+       if (hdr->addr1[0] & 0x01)
+               ev.flags |= IW_MICFAILURE_GROUP;
+       else
+               ev.flags |= IW_MICFAILURE_PAIRWISE;
+       ev.src_addr.sa_family = ARPHRD_ETHER;
+       memcpy(ev.src_addr.sa_data, hdr->addr2, ETH_ALEN);
+       memset(&wrqu, 0, sizeof(wrqu));
+       wrqu.data.length = sizeof(ev);
+       wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev);
+}
+#elif WIRELESS_EXT >= 15
+static void ieee80211_michael_mic_failure(struct net_device *dev,
+                                      struct ieee80211_hdr *hdr,
+                                      int keyidx)
+{
+       union iwreq_data wrqu;
+       char buf[128];
+
+       /* TODO: needed parameters: count, keyid, key type, TSC */
+       sprintf(buf, "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr="
+               MAC_FMT ")", keyidx, hdr->addr1[0] & 0x01 ? "broad" : "uni",
+               MAC_ARG(hdr->addr2));
+       memset(&wrqu, 0, sizeof(wrqu));
+       wrqu.data.length = strlen(buf);
+       wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
+}
+#else /* WIRELESS_EXT >= 15 */
+static inline void ieee80211_michael_mic_failure(struct net_device *dev,
+                                             struct ieee80211_hdr *hdr,
+                                             int keyidx)
+{
+}
+#endif /* WIRELESS_EXT >= 15 */
+
+
+static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
+                                    int hdr_len, void *priv)
+{
+       struct ieee80211_tkip_data *tkey = priv;
+       u8 mic[8];
+
+       if (!tkey->key_set)
+               return -1;
+
+       michael_mic_hdr(skb, tkey->rx_hdr);
+       if (michael_mic(tkey, &tkey->key[24], tkey->rx_hdr,
+                       skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
+               return -1;
+       if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) {
+               struct ieee80211_hdr *hdr;
+               hdr = (struct ieee80211_hdr *) skb->data;
+               printk(KERN_DEBUG "%s: Michael MIC verification failed for "
+                      "MSDU from " MAC_FMT " keyidx=%d\n",
+                      skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2),
+                      keyidx);
+               if (skb->dev)
+                       ieee80211_michael_mic_failure(skb->dev, hdr, keyidx);
+               tkey->dot11RSNAStatsTKIPLocalMICFailures++;
+               return -1;
+       }
+
+       /* Update TSC counters for RX now that the packet verification has
+        * completed. */
+       tkey->rx_iv32 = tkey->rx_iv32_new;
+       tkey->rx_iv16 = tkey->rx_iv16_new;
+
+       skb_trim(skb, skb->len - 8);
+
+       return 0;
+}
+
+
+static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv)
+{
+       struct ieee80211_tkip_data *tkey = priv;
+       int keyidx;
+       struct crypto_tfm *tfm = tkey->tfm_michael;
+       struct crypto_tfm *tfm2 = tkey->tfm_arc4;
+
+       keyidx = tkey->key_idx;
+       memset(tkey, 0, sizeof(*tkey));
+       tkey->key_idx = keyidx;
+       tkey->tfm_michael = tfm;
+       tkey->tfm_arc4 = tfm2;
+       if (len == TKIP_KEY_LEN) {
+               memcpy(tkey->key, key, TKIP_KEY_LEN);
+               tkey->key_set = 1;
+               tkey->tx_iv16 = 1; /* TSC is initialized to 1 */
+               if (seq) {
+                       tkey->rx_iv32 = (seq[5] << 24) | (seq[4] << 16) |
+                               (seq[3] << 8) | seq[2];
+                       tkey->rx_iv16 = (seq[1] << 8) | seq[0];
+               }
+       } else if (len == 0)
+               tkey->key_set = 0;
+       else
+               return -1;
+
+       return 0;
+}
+
+
+static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv)
+{
+       struct ieee80211_tkip_data *tkey = priv;
+
+       if (len < TKIP_KEY_LEN)
+               return -1;
+
+       if (!tkey->key_set)
+               return 0;
+       memcpy(key, tkey->key, TKIP_KEY_LEN);
+
+       if (seq) {
+               /* Return the sequence number of the last transmitted frame. */
+               u16 iv16 = tkey->tx_iv16;
+               u32 iv32 = tkey->tx_iv32;
+               if (iv16 == 0)
+                       iv32--;
+               iv16--;
+               seq[0] = tkey->tx_iv16;
+               seq[1] = tkey->tx_iv16 >> 8;
+               seq[2] = tkey->tx_iv32;
+               seq[3] = tkey->tx_iv32 >> 8;
+               seq[4] = tkey->tx_iv32 >> 16;
+               seq[5] = tkey->tx_iv32 >> 24;
+       }
+
+       return TKIP_KEY_LEN;
+}
+
+
+static char * ieee80211_tkip_print_stats(char *p, void *priv)
+{
+       struct ieee80211_tkip_data *tkip = priv;
+       p += sprintf(p, "key[%d] alg=TKIP key_set=%d "
+                    "tx_pn=%02x%02x%02x%02x%02x%02x "
+                    "rx_pn=%02x%02x%02x%02x%02x%02x "
+                    "replays=%d icv_errors=%d local_mic_failures=%d\n",
+                    tkip->key_idx, tkip->key_set,
+                    (tkip->tx_iv32 >> 24) & 0xff,
+                    (tkip->tx_iv32 >> 16) & 0xff,
+                    (tkip->tx_iv32 >> 8) & 0xff,
+                    tkip->tx_iv32 & 0xff,
+                    (tkip->tx_iv16 >> 8) & 0xff,
+                    tkip->tx_iv16 & 0xff,
+                    (tkip->rx_iv32 >> 24) & 0xff,
+                    (tkip->rx_iv32 >> 16) & 0xff,
+                    (tkip->rx_iv32 >> 8) & 0xff,
+                    tkip->rx_iv32 & 0xff,
+                    (tkip->rx_iv16 >> 8) & 0xff,
+                    tkip->rx_iv16 & 0xff,
+                    tkip->dot11RSNAStatsTKIPReplays,
+                    tkip->dot11RSNAStatsTKIPICVErrors,
+                    tkip->dot11RSNAStatsTKIPLocalMICFailures);
+       return p;
+}
+
+
+static struct ieee80211_crypto_ops ieee80211_crypt_tkip = {
+       .name                   = "TKIP",
+       .init                   = ieee80211_tkip_init,
+       .deinit                 = ieee80211_tkip_deinit,
+       .encrypt_mpdu           = ieee80211_tkip_encrypt,
+       .decrypt_mpdu           = ieee80211_tkip_decrypt,
+       .encrypt_msdu           = ieee80211_michael_mic_add,
+       .decrypt_msdu           = ieee80211_michael_mic_verify,
+       .set_key                = ieee80211_tkip_set_key,
+       .get_key                = ieee80211_tkip_get_key,
+       .print_stats            = ieee80211_tkip_print_stats,
+       .extra_prefix_len       = 4 + 4, /* IV + ExtIV */
+       .extra_postfix_len      = 8 + 4, /* MIC + ICV */
+       .owner                  = THIS_MODULE,
+};
+
+
+static int __init ieee80211_crypto_tkip_init(void)
+{
+       return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip);
+}
+
+
+static void __exit ieee80211_crypto_tkip_exit(void)
+{
+       ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip);
+}
+
+
+module_init(ieee80211_crypto_tkip_init);
+module_exit(ieee80211_crypto_tkip_exit);
diff --git a/net/ieee80211/ieee80211_crypt_wep.c b/net/ieee80211/ieee80211_crypt_wep.c
new file mode 100644 (file)
index 0000000..bec1d34
--- /dev/null
@@ -0,0 +1,272 @@
+/*
+ * Host AP crypt: host-based WEP encryption implementation for Host AP driver
+ *
+ * Copyright (c) 2002-2004, Jouni Malinen <jkmaline@cc.hut.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. See README and COPYING for
+ * more details.
+ */
+
+#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+#include <linux/skbuff.h>
+#include <asm/string.h>
+
+#include <net/ieee80211.h>
+
+
+#include <linux/crypto.h>
+#include <asm/scatterlist.h>
+#include <linux/crc32.h>
+
+MODULE_AUTHOR("Jouni Malinen");
+MODULE_DESCRIPTION("Host AP crypt: WEP");
+MODULE_LICENSE("GPL");
+
+
+struct prism2_wep_data {
+       u32 iv;
+#define WEP_KEY_LEN 13
+       u8 key[WEP_KEY_LEN + 1];
+       u8 key_len;
+       u8 key_idx;
+       struct crypto_tfm *tfm;
+};
+
+
+static void * prism2_wep_init(int keyidx)
+{
+       struct prism2_wep_data *priv;
+
+       priv = kmalloc(sizeof(*priv), GFP_ATOMIC);
+       if (priv == NULL)
+               goto fail;
+       memset(priv, 0, sizeof(*priv));
+       priv->key_idx = keyidx;
+
+       priv->tfm = crypto_alloc_tfm("arc4", 0);
+       if (priv->tfm == NULL) {
+               printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
+                      "crypto API arc4\n");
+               goto fail;
+       }
+
+       /* start WEP IV from a random value */
+       get_random_bytes(&priv->iv, 4);
+
+       return priv;
+
+fail:
+       if (priv) {
+               if (priv->tfm)
+                       crypto_free_tfm(priv->tfm);
+               kfree(priv);
+       }
+       return NULL;
+}
+
+
+static void prism2_wep_deinit(void *priv)
+{
+       struct prism2_wep_data *_priv = priv;
+       if (_priv && _priv->tfm)
+               crypto_free_tfm(_priv->tfm);
+       kfree(priv);
+}
+
+
+/* Perform WEP encryption on given skb that has at least 4 bytes of headroom
+ * for IV and 4 bytes of tailroom for ICV. Both IV and ICV will be transmitted,
+ * so the payload length increases with 8 bytes.
+ *
+ * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data))
+ */
+static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
+{
+       struct prism2_wep_data *wep = priv;
+       u32 crc, klen, len;
+       u8 key[WEP_KEY_LEN + 3];
+       u8 *pos, *icv;
+       struct scatterlist sg;
+
+       if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 ||
+           skb->len < hdr_len)
+               return -1;
+
+       len = skb->len - hdr_len;
+       pos = skb_push(skb, 4);
+       memmove(pos, pos + 4, hdr_len);
+       pos += hdr_len;
+
+       klen = 3 + wep->key_len;
+
+       wep->iv++;
+
+       /* Fluhrer, Mantin, and Shamir have reported weaknesses in the key
+        * scheduling algorithm of RC4. At least IVs (KeyByte + 3, 0xff, N)
+        * can be used to speedup attacks, so avoid using them. */
+       if ((wep->iv & 0xff00) == 0xff00) {
+               u8 B = (wep->iv >> 16) & 0xff;
+               if (B >= 3 && B < klen)
+                       wep->iv += 0x0100;
+       }
+
+       /* Prepend 24-bit IV to RC4 key and TX frame */
+       *pos++ = key[0] = (wep->iv >> 16) & 0xff;
+       *pos++ = key[1] = (wep->iv >> 8) & 0xff;
+       *pos++ = key[2] = wep->iv & 0xff;
+       *pos++ = wep->key_idx << 6;
+
+       /* Copy rest of the WEP key (the secret part) */
+       memcpy(key + 3, wep->key, wep->key_len);
+
+       /* Append little-endian CRC32 and encrypt it to produce ICV */
+       crc = ~crc32_le(~0, pos, len);
+       icv = skb_put(skb, 4);
+       icv[0] = crc;
+       icv[1] = crc >> 8;
+       icv[2] = crc >> 16;
+       icv[3] = crc >> 24;
+
+       crypto_cipher_setkey(wep->tfm, key, klen);
+       sg.page = virt_to_page(pos);
+       sg.offset = offset_in_page(pos);
+       sg.length = len + 4;
+       crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4);
+
+       return 0;
+}
+
+
+/* Perform WEP decryption on given buffer. Buffer includes whole WEP part of
+ * the frame: IV (4 bytes), encrypted payload (including SNAP header),
+ * ICV (4 bytes). len includes both IV and ICV.
+ *
+ * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on
+ * failure. If frame is OK, IV and ICV will be removed.
+ */
+static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
+{
+       struct prism2_wep_data *wep = priv;
+       u32 crc, klen, plen;
+       u8 key[WEP_KEY_LEN + 3];
+       u8 keyidx, *pos, icv[4];
+       struct scatterlist sg;
+
+       if (skb->len < hdr_len + 8)
+               return -1;
+
+       pos = skb->data + hdr_len;
+       key[0] = *pos++;
+       key[1] = *pos++;
+       key[2] = *pos++;
+       keyidx = *pos++ >> 6;
+       if (keyidx != wep->key_idx)
+               return -1;
+
+       klen = 3 + wep->key_len;
+
+       /* Copy rest of the WEP key (the secret part) */
+       memcpy(key + 3, wep->key, wep->key_len);
+
+       /* Apply RC4 to data and compute CRC32 over decrypted data */
+       plen = skb->len - hdr_len - 8;
+
+       crypto_cipher_setkey(wep->tfm, key, klen);
+       sg.page = virt_to_page(pos);
+       sg.offset = offset_in_page(pos);
+       sg.length = plen + 4;
+       crypto_cipher_decrypt(wep->tfm, &sg, &sg, plen + 4);
+
+       crc = ~crc32_le(~0, pos, plen);
+       icv[0] = crc;
+       icv[1] = crc >> 8;
+       icv[2] = crc >> 16;
+       icv[3] = crc >> 24;
+       if (memcmp(icv, pos + plen, 4) != 0) {
+               /* ICV mismatch - drop frame */
+               return -2;
+       }
+
+       /* Remove IV and ICV */
+       memmove(skb->data + 4, skb->data, hdr_len);
+       skb_pull(skb, 4);
+       skb_trim(skb, skb->len - 4);
+
+       return 0;
+}
+
+
+static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv)
+{
+       struct prism2_wep_data *wep = priv;
+
+       if (len < 0 || len > WEP_KEY_LEN)
+               return -1;
+
+       memcpy(wep->key, key, len);
+       wep->key_len = len;
+
+       return 0;
+}
+
+
+static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv)
+{
+       struct prism2_wep_data *wep = priv;
+
+       if (len < wep->key_len)
+               return -1;
+
+       memcpy(key, wep->key, wep->key_len);
+
+       return wep->key_len;
+}
+
+
+static char * prism2_wep_print_stats(char *p, void *priv)
+{
+       struct prism2_wep_data *wep = priv;
+       p += sprintf(p, "key[%d] alg=WEP len=%d\n",
+                    wep->key_idx, wep->key_len);
+       return p;
+}
+
+
+static struct ieee80211_crypto_ops ieee80211_crypt_wep = {
+       .name                   = "WEP",
+       .init                   = prism2_wep_init,
+       .deinit                 = prism2_wep_deinit,
+       .encrypt_mpdu           = prism2_wep_encrypt,
+       .decrypt_mpdu           = prism2_wep_decrypt,
+       .encrypt_msdu           = NULL,
+       .decrypt_msdu           = NULL,
+       .set_key                = prism2_wep_set_key,
+       .get_key                = prism2_wep_get_key,
+       .print_stats            = prism2_wep_print_stats,
+       .extra_prefix_len       = 4, /* IV */
+       .extra_postfix_len      = 4, /* ICV */
+       .owner                  = THIS_MODULE,
+};
+
+
+static int __init ieee80211_crypto_wep_init(void)
+{
+       return ieee80211_register_crypto_ops(&ieee80211_crypt_wep);
+}
+
+
+static void __exit ieee80211_crypto_wep_exit(void)
+{
+       ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep);
+}
+
+
+module_init(ieee80211_crypto_wep_init);
+module_exit(ieee80211_crypto_wep_exit);
diff --git a/net/ieee80211/ieee80211_module.c b/net/ieee80211/ieee80211_module.c
new file mode 100644 (file)
index 0000000..553acb2
--- /dev/null
@@ -0,0 +1,299 @@
+/*******************************************************************************
+
+  Copyright(c) 2004 Intel Corporation. All rights reserved.
+
+  Portions of this file are based on the WEP enablement code provided by the
+  Host AP project hostap-drivers v0.1.3
+  Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
+  <jkmaline@cc.hut.fi>
+  Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms of version 2 of the GNU General Public License as
+  published by the Free Software Foundation.
+
+  This program is distributed in the hope that it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc., 59
+  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+  The full GNU General Public License is included in this distribution in the
+  file called LICENSE.
+
+  Contact Information:
+  James P. Ketrenos <ipw2100-admin@linux.intel.com>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+#include <linux/compiler.h>
+#include <linux/config.h>
+#include <linux/errno.h>
+#include <linux/if_arp.h>
+#include <linux/in6.h>
+#include <linux/in.h>
+#include <linux/ip.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/proc_fs.h>
+#include <linux/skbuff.h>
+#include <linux/slab.h>
+#include <linux/tcp.h>
+#include <linux/types.h>
+#include <linux/version.h>
+#include <linux/wireless.h>
+#include <linux/etherdevice.h>
+#include <asm/uaccess.h>
+#include <net/arp.h>
+
+#include <net/ieee80211.h>
+
+MODULE_DESCRIPTION("802.11 data/management/control stack");
+MODULE_AUTHOR("Copyright (C) 2004 Intel Corporation <jketreno@linux.intel.com>");
+MODULE_LICENSE("GPL");
+
+#define DRV_NAME "ieee80211"
+
+static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee)
+{
+       if (ieee->networks)
+               return 0;
+
+       ieee->networks = kmalloc(
+               MAX_NETWORK_COUNT * sizeof(struct ieee80211_network),
+               GFP_KERNEL);
+       if (!ieee->networks) {
+               printk(KERN_WARNING "%s: Out of memory allocating beacons\n",
+                      ieee->dev->name);
+               return -ENOMEM;
+       }
+
+       memset(ieee->networks, 0,
+              MAX_NETWORK_COUNT * sizeof(struct ieee80211_network));
+
+       return 0;
+}
+
+static inline void ieee80211_networks_free(struct ieee80211_device *ieee)
+{
+       if (!ieee->networks)
+               return;
+       kfree(ieee->networks);
+       ieee->networks = NULL;
+}
+
+static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee)
+{
+       int i;
+
+       INIT_LIST_HEAD(&ieee->network_free_list);
+       INIT_LIST_HEAD(&ieee->network_list);
+       for (i = 0; i < MAX_NETWORK_COUNT; i++)
+               list_add_tail(&ieee->networks[i].list, &ieee->network_free_list);
+}
+
+
+struct net_device *alloc_ieee80211(int sizeof_priv)
+{
+       struct ieee80211_device *ieee;
+       struct net_device *dev;
+       int err;
+
+       IEEE80211_DEBUG_INFO("Initializing...\n");
+
+       dev = alloc_etherdev(sizeof(struct ieee80211_device) + sizeof_priv);
+       if (!dev) {
+               IEEE80211_ERROR("Unable to network device.\n");
+               goto failed;
+       }
+       ieee = netdev_priv(dev);
+       dev->hard_start_xmit = ieee80211_xmit;
+
+       ieee->dev = dev;
+
+       err = ieee80211_networks_allocate(ieee);
+       if (err) {
+               IEEE80211_ERROR("Unable to allocate beacon storage: %d\n",
+                               err);
+               goto failed;
+       }
+       ieee80211_networks_initialize(ieee);
+
+       /* Default fragmentation threshold is maximum payload size */
+       ieee->fts = DEFAULT_FTS;
+       ieee->scan_age = DEFAULT_MAX_SCAN_AGE;
+       ieee->open_wep = 1;
+
+       /* Default to enabling full open WEP with host based encrypt/decrypt */
+       ieee->host_encrypt = 1;
+       ieee->host_decrypt = 1;
+       ieee->ieee802_1x = 1; /* Default to supporting 802.1x */
+
+       INIT_LIST_HEAD(&ieee->crypt_deinit_list);
+       init_timer(&ieee->crypt_deinit_timer);
+       ieee->crypt_deinit_timer.data = (unsigned long)ieee;
+       ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler;
+
+       spin_lock_init(&ieee->lock);
+
+       ieee->wpa_enabled = 0;
+       ieee->tkip_countermeasures = 0;
+       ieee->drop_unencrypted = 0;
+       ieee->privacy_invoked = 0;
+       ieee->ieee802_1x = 1;
+
+       return dev;
+
+ failed:
+       if (dev)
+               free_netdev(dev);
+       return NULL;
+}
+
+
+void free_ieee80211(struct net_device *dev)
+{
+       struct ieee80211_device *ieee = netdev_priv(dev);
+
+       int i;
+
+       del_timer_sync(&ieee->crypt_deinit_timer);
+       ieee80211_crypt_deinit_entries(ieee, 1);
+
+       for (i = 0; i < WEP_KEYS; i++) {
+               struct ieee80211_crypt_data *crypt = ieee->crypt[i];
+               if (crypt) {
+                       if (crypt->ops) {
+                               crypt->ops->deinit(crypt->priv);
+                               module_put(crypt->ops->owner);
+                       }
+                       kfree(crypt);
+                       ieee->crypt[i] = NULL;
+               }
+       }
+
+       ieee80211_networks_free(ieee);
+       free_netdev(dev);
+}
+
+#ifdef CONFIG_IEEE80211_DEBUG
+
+static int debug = 0;
+u32 ieee80211_debug_level = 0;
+struct proc_dir_entry *ieee80211_proc = NULL;
+
+static int show_debug_level(char *page, char **start, off_t offset,
+                           int count, int *eof, void *data)
+{
+       return snprintf(page, count, "0x%08X\n", ieee80211_debug_level);
+}
+
+static int store_debug_level(struct file *file, const char __user *buffer,
+                            unsigned long count, void *data)
+{
+       char buf[] = "0x00000000";
+       char *p = (char *)buf;
+       unsigned long val;
+
+       if (count > sizeof(buf) - 1)
+               count = sizeof(buf) - 1;
+
+       if (copy_from_user(buf, buffer, count))
+               return count;
+       buf[count] = 0;
+       /*
+        * what a FPOS...  What, sscanf(buf, "%i", &val) would be too
+        * scary?
+        */
+       if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
+               p++;
+               if (p[0] == 'x' || p[0] == 'X')
+                       p++;
+               val = simple_strtoul(p, &p, 16);
+       } else
+               val = simple_strtoul(p, &p, 10);
+       if (p == buf)
+               printk(KERN_INFO DRV_NAME
+                      ": %s is not in hex or decimal form.\n", buf);
+       else
+               ieee80211_debug_level = val;
+
+       return strlen(buf);
+}
+
+static int __init ieee80211_init(void)
+{
+       struct proc_dir_entry *e;
+
+       ieee80211_debug_level = debug;
+       ieee80211_proc = create_proc_entry(DRV_NAME, S_IFDIR, proc_net);
+       if (ieee80211_proc == NULL) {
+               IEEE80211_ERROR("Unable to create " DRV_NAME
+                               " proc directory\n");
+               return -EIO;
+       }
+       e = create_proc_entry("debug_level", S_IFREG | S_IRUGO | S_IWUSR,
+                             ieee80211_proc);
+       if (!e) {
+               remove_proc_entry(DRV_NAME, proc_net);
+               ieee80211_proc = NULL;
+               return -EIO;
+       }
+       e->read_proc = show_debug_level;
+       e->write_proc = store_debug_level;
+       e->data = NULL;
+
+       return 0;
+}
+
+static void __exit ieee80211_exit(void)
+{
+       if (ieee80211_proc) {
+               remove_proc_entry("debug_level", ieee80211_proc);
+               remove_proc_entry(DRV_NAME, proc_net);
+               ieee80211_proc = NULL;
+       }
+}
+
+#include <linux/moduleparam.h>
+module_param(debug, int, 0444);
+MODULE_PARM_DESC(debug, "debug output mask");
+
+
+module_exit(ieee80211_exit);
+module_init(ieee80211_init);
+#endif
+
+
+const char *escape_essid(const char *essid, u8 essid_len) {
+       static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
+       const char *s = essid;
+       char *d = escaped;
+
+       if (ieee80211_is_empty_essid(essid, essid_len)) {
+               memcpy(escaped, "<hidden>", sizeof("<hidden>"));
+               return escaped;
+       }
+
+       essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE);
+       while (essid_len--) {
+               if (*s == '\0') {
+                       *d++ = '\\';
+                       *d++ = '0';
+                       s++;
+               } else {
+                       *d++ = *s++;
+               }
+       }
+       *d = '\0';
+       return escaped;
+}
+
+EXPORT_SYMBOL(alloc_ieee80211);
+EXPORT_SYMBOL(free_ieee80211);
+EXPORT_SYMBOL(escape_essid);
diff --git a/net/ieee80211/ieee80211_rx.c b/net/ieee80211/ieee80211_rx.c
new file mode 100644 (file)
index 0000000..a5905f5
--- /dev/null
@@ -0,0 +1,1189 @@
+/*
+ * Original code based Host AP (software wireless LAN access point) driver
+ * for Intersil Prism2/2.5/3 - hostap.o module, common routines
+ *
+ * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
+ * <jkmaline@cc.hut.fi>
+ * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
+ * Copyright (c) 2004, Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. See README and COPYING for
+ * more details.
+ */
+
+#include <linux/compiler.h>
+#include <linux/config.h>
+#include <linux/errno.h>
+#include <linux/if_arp.h>
+#include <linux/in6.h>
+#include <linux/in.h>
+#include <linux/ip.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/proc_fs.h>
+#include <linux/skbuff.h>
+#include <linux/slab.h>
+#include <linux/tcp.h>
+#include <linux/types.h>
+#include <linux/version.h>
+#include <linux/wireless.h>
+#include <linux/etherdevice.h>
+#include <asm/uaccess.h>
+#include <linux/ctype.h>
+
+#include <net/ieee80211.h>
+
+static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee,
+                                       struct sk_buff *skb,
+                                       struct ieee80211_rx_stats *rx_stats)
+{
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+       u16 fc = le16_to_cpu(hdr->frame_ctl);
+
+       skb->dev = ieee->dev;
+       skb->mac.raw = skb->data;
+       skb_pull(skb, ieee80211_get_hdrlen(fc));
+       skb->pkt_type = PACKET_OTHERHOST;
+       skb->protocol = __constant_htons(ETH_P_80211_RAW);
+       memset(skb->cb, 0, sizeof(skb->cb));
+       netif_rx(skb);
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static struct ieee80211_frag_entry *
+ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq,
+                         unsigned int frag, u8 *src, u8 *dst)
+{
+       struct ieee80211_frag_entry *entry;
+       int i;
+
+       for (i = 0; i < IEEE80211_FRAG_CACHE_LEN; i++) {
+               entry = &ieee->frag_cache[i];
+               if (entry->skb != NULL &&
+                   time_after(jiffies, entry->first_frag_time + 2 * HZ)) {
+                       IEEE80211_DEBUG_FRAG(
+                               "expiring fragment cache entry "
+                               "seq=%u last_frag=%u\n",
+                               entry->seq, entry->last_frag);
+                       dev_kfree_skb_any(entry->skb);
+                       entry->skb = NULL;
+               }
+
+               if (entry->skb != NULL && entry->seq == seq &&
+                   (entry->last_frag + 1 == frag || frag == -1) &&
+                   memcmp(entry->src_addr, src, ETH_ALEN) == 0 &&
+                   memcmp(entry->dst_addr, dst, ETH_ALEN) == 0)
+                       return entry;
+       }
+
+       return NULL;
+}
+
+/* Called only as a tasklet (software IRQ) */
+static struct sk_buff *
+ieee80211_frag_cache_get(struct ieee80211_device *ieee,
+                        struct ieee80211_hdr *hdr)
+{
+       struct sk_buff *skb = NULL;
+       u16 sc;
+       unsigned int frag, seq;
+       struct ieee80211_frag_entry *entry;
+
+       sc = le16_to_cpu(hdr->seq_ctl);
+       frag = WLAN_GET_SEQ_FRAG(sc);
+       seq = WLAN_GET_SEQ_SEQ(sc);
+
+       if (frag == 0) {
+               /* Reserve enough space to fit maximum frame length */
+               skb = dev_alloc_skb(ieee->dev->mtu +
+                                   sizeof(struct ieee80211_hdr) +
+                                   8 /* LLC */ +
+                                   2 /* alignment */ +
+                                   8 /* WEP */ + ETH_ALEN /* WDS */);
+               if (skb == NULL)
+                       return NULL;
+
+               entry = &ieee->frag_cache[ieee->frag_next_idx];
+               ieee->frag_next_idx++;
+               if (ieee->frag_next_idx >= IEEE80211_FRAG_CACHE_LEN)
+                       ieee->frag_next_idx = 0;
+
+               if (entry->skb != NULL)
+                       dev_kfree_skb_any(entry->skb);
+
+               entry->first_frag_time = jiffies;
+               entry->seq = seq;
+               entry->last_frag = frag;
+               entry->skb = skb;
+               memcpy(entry->src_addr, hdr->addr2, ETH_ALEN);
+               memcpy(entry->dst_addr, hdr->addr1, ETH_ALEN);
+       } else {
+               /* received a fragment of a frame for which the head fragment
+                * should have already been received */
+               entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2,
+                                                 hdr->addr1);
+               if (entry != NULL) {
+                       entry->last_frag = frag;
+                       skb = entry->skb;
+               }
+       }
+
+       return skb;
+}
+
+
+/* Called only as a tasklet (software IRQ) */
+static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee,
+                                          struct ieee80211_hdr *hdr)
+{
+       u16 sc;
+       unsigned int seq;
+       struct ieee80211_frag_entry *entry;
+
+       sc = le16_to_cpu(hdr->seq_ctl);
+       seq = WLAN_GET_SEQ_SEQ(sc);
+
+       entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2,
+                                         hdr->addr1);
+
+       if (entry == NULL) {
+               IEEE80211_DEBUG_FRAG(
+                       "could not invalidate fragment cache "
+                       "entry (seq=%u)\n", seq);
+               return -1;
+       }
+
+       entry->skb = NULL;
+       return 0;
+}
+
+
+#ifdef NOT_YET
+/* ieee80211_rx_frame_mgtmt
+ *
+ * Responsible for handling management control frames
+ *
+ * Called by ieee80211_rx */
+static inline int
+ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
+                       struct ieee80211_rx_stats *rx_stats, u16 type,
+                       u16 stype)
+{
+       if (ieee->iw_mode == IW_MODE_MASTER) {
+               printk(KERN_DEBUG "%s: Master mode not yet suppported.\n",
+                      ieee->dev->name);
+               return 0;
+/*
+  hostap_update_sta_ps(ieee, (struct hostap_ieee80211_hdr *)
+  skb->data);*/
+       }
+
+       if (ieee->hostapd && type == WLAN_FC_TYPE_MGMT) {
+               if (stype == WLAN_FC_STYPE_BEACON &&
+                   ieee->iw_mode == IW_MODE_MASTER) {
+                       struct sk_buff *skb2;
+                       /* Process beacon frames also in kernel driver to
+                        * update STA(AP) table statistics */
+                       skb2 = skb_clone(skb, GFP_ATOMIC);
+                       if (skb2)
+                               hostap_rx(skb2->dev, skb2, rx_stats);
+               }
+
+               /* send management frames to the user space daemon for
+                * processing */
+               ieee->apdevstats.rx_packets++;
+               ieee->apdevstats.rx_bytes += skb->len;
+               prism2_rx_80211(ieee->apdev, skb, rx_stats, PRISM2_RX_MGMT);
+               return 0;
+       }
+
+           if (ieee->iw_mode == IW_MODE_MASTER) {
+               if (type != WLAN_FC_TYPE_MGMT && type != WLAN_FC_TYPE_CTRL) {
+                       printk(KERN_DEBUG "%s: unknown management frame "
+                              "(type=0x%02x, stype=0x%02x) dropped\n",
+                              skb->dev->name, type, stype);
+                       return -1;
+               }
+
+               hostap_rx(skb->dev, skb, rx_stats);
+               return 0;
+       }
+
+       printk(KERN_DEBUG "%s: hostap_rx_frame_mgmt: management frame "
+              "received in non-Host AP mode\n", skb->dev->name);
+       return -1;
+}
+#endif
+
+
+/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
+/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
+static unsigned char rfc1042_header[] =
+{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
+/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
+static unsigned char bridge_tunnel_header[] =
+{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
+/* No encapsulation header if EtherType < 0x600 (=length) */
+
+/* Called by ieee80211_rx_frame_decrypt */
+static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
+                                   struct sk_buff *skb)
+{
+       struct net_device *dev = ieee->dev;
+       u16 fc, ethertype;
+       struct ieee80211_hdr *hdr;
+       u8 *pos;
+
+       if (skb->len < 24)
+               return 0;
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       fc = le16_to_cpu(hdr->frame_ctl);
+
+       /* check that the frame is unicast frame to us */
+       if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
+           IEEE80211_FCTL_TODS &&
+           memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0 &&
+           memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0) {
+               /* ToDS frame with own addr BSSID and DA */
+       } else if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
+                  IEEE80211_FCTL_FROMDS &&
+                  memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0) {
+               /* FromDS frame with own addr as DA */
+       } else
+               return 0;
+
+       if (skb->len < 24 + 8)
+               return 0;
+
+       /* check for port access entity Ethernet type */
+       pos = skb->data + 24;
+       ethertype = (pos[6] << 8) | pos[7];
+       if (ethertype == ETH_P_PAE)
+               return 1;
+
+       return 0;
+}
+
+/* Called only as a tasklet (software IRQ), by ieee80211_rx */
+static inline int
+ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb,
+                          struct ieee80211_crypt_data *crypt)
+{
+       struct ieee80211_hdr *hdr;
+       int res, hdrlen;
+
+       if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
+               return 0;
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
+
+#ifdef CONFIG_IEEE80211_CRYPT_TKIP
+       if (ieee->tkip_countermeasures &&
+           strcmp(crypt->ops->name, "TKIP") == 0) {
+               if (net_ratelimit()) {
+                       printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
+                              "received packet from " MAC_FMT "\n",
+                              ieee->dev->name, MAC_ARG(hdr->addr2));
+               }
+               return -1;
+       }
+#endif
+
+       atomic_inc(&crypt->refcnt);
+       res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
+       atomic_dec(&crypt->refcnt);
+       if (res < 0) {
+               IEEE80211_DEBUG_DROP(
+                       "decryption failed (SA=" MAC_FMT
+                       ") res=%d\n", MAC_ARG(hdr->addr2), res);
+               if (res == -2)
+                       IEEE80211_DEBUG_DROP("Decryption failed ICV "
+                                            "mismatch (key %d)\n",
+                                            skb->data[hdrlen + 3] >> 6);
+               ieee->ieee_stats.rx_discards_undecryptable++;
+               return -1;
+       }
+
+       return res;
+}
+
+
+/* Called only as a tasklet (software IRQ), by ieee80211_rx */
+static inline int
+ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb,
+                            int keyidx, struct ieee80211_crypt_data *crypt)
+{
+       struct ieee80211_hdr *hdr;
+       int res, hdrlen;
+
+       if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
+               return 0;
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
+
+       atomic_inc(&crypt->refcnt);
+       res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
+       atomic_dec(&crypt->refcnt);
+       if (res < 0) {
+               printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed"
+                      " (SA=" MAC_FMT " keyidx=%d)\n",
+                      ieee->dev->name, MAC_ARG(hdr->addr2), keyidx);
+               return -1;
+       }
+
+       return 0;
+}
+
+
+/* All received frames are sent to this function. @skb contains the frame in
+ * IEEE 802.11 format, i.e., in the format it was sent over air.
+ * This function is called only as a tasklet (software IRQ). */
+int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
+                struct ieee80211_rx_stats *rx_stats)
+{
+       struct net_device *dev = ieee->dev;
+       struct ieee80211_hdr *hdr;
+       size_t hdrlen;
+       u16 fc, type, stype, sc;
+       struct net_device_stats *stats;
+       unsigned int frag;
+       u8 *payload;
+       u16 ethertype;
+#ifdef NOT_YET
+       struct net_device *wds = NULL;
+       struct sk_buff *skb2 = NULL;
+       struct net_device *wds = NULL;
+       int frame_authorized = 0;
+       int from_assoc_ap = 0;
+       void *sta = NULL;
+#endif
+       u8 dst[ETH_ALEN];
+       u8 src[ETH_ALEN];
+       struct ieee80211_crypt_data *crypt = NULL;
+       int keyidx = 0;
+
+       hdr = (struct ieee80211_hdr *)skb->data;
+       stats = &ieee->stats;
+
+       if (skb->len < 10) {
+               printk(KERN_INFO "%s: SKB length < 10\n",
+                      dev->name);
+               goto rx_dropped;
+       }
+
+       fc = le16_to_cpu(hdr->frame_ctl);
+       type = WLAN_FC_GET_TYPE(fc);
+       stype = WLAN_FC_GET_STYPE(fc);
+       sc = le16_to_cpu(hdr->seq_ctl);
+       frag = WLAN_GET_SEQ_FRAG(sc);
+       hdrlen = ieee80211_get_hdrlen(fc);
+
+#ifdef NOT_YET
+#if WIRELESS_EXT > 15
+       /* Put this code here so that we avoid duplicating it in all
+        * Rx paths. - Jean II */
+#ifdef IW_WIRELESS_SPY         /* defined in iw_handler.h */
+       /* If spy monitoring on */
+       if (iface->spy_data.spy_number > 0) {
+               struct iw_quality wstats;
+               wstats.level = rx_stats->signal;
+               wstats.noise = rx_stats->noise;
+               wstats.updated = 6;     /* No qual value */
+               /* Update spy records */
+               wireless_spy_update(dev, hdr->addr2, &wstats);
+       }
+#endif /* IW_WIRELESS_SPY */
+#endif /* WIRELESS_EXT > 15 */
+       hostap_update_rx_stats(local->ap, hdr, rx_stats);
+#endif
+
+#if WIRELESS_EXT > 15
+       if (ieee->iw_mode == IW_MODE_MONITOR) {
+               ieee80211_monitor_rx(ieee, skb, rx_stats);
+               stats->rx_packets++;
+               stats->rx_bytes += skb->len;
+               return 1;
+       }
+#endif
+
+       if (ieee->host_decrypt) {
+               int idx = 0;
+               if (skb->len >= hdrlen + 3)
+                       idx = skb->data[hdrlen + 3] >> 6;
+               crypt = ieee->crypt[idx];
+#ifdef NOT_YET
+               sta = NULL;
+
+               /* Use station specific key to override default keys if the
+                * receiver address is a unicast address ("individual RA"). If
+                * bcrx_sta_key parameter is set, station specific key is used
+                * even with broad/multicast targets (this is against IEEE
+                * 802.11, but makes it easier to use different keys with
+                * stations that do not support WEP key mapping). */
+
+               if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key)
+                       (void) hostap_handle_sta_crypto(local, hdr, &crypt,
+                                                       &sta);
+#endif
+
+               /* allow NULL decrypt to indicate an station specific override
+                * for default encryption */
+               if (crypt && (crypt->ops == NULL ||
+                             crypt->ops->decrypt_mpdu == NULL))
+                       crypt = NULL;
+
+               if (!crypt && (fc & IEEE80211_FCTL_PROTECTED)) {
+                       /* This seems to be triggered by some (multicast?)
+                        * frames from other than current BSS, so just drop the
+                        * frames silently instead of filling system log with
+                        * these reports. */
+                       IEEE80211_DEBUG_DROP("Decryption failed (not set)"
+                                            " (SA=" MAC_FMT ")\n",
+                                            MAC_ARG(hdr->addr2));
+                       ieee->ieee_stats.rx_discards_undecryptable++;
+                       goto rx_dropped;
+               }
+       }
+
+#ifdef NOT_YET
+       if (type != WLAN_FC_TYPE_DATA) {
+               if (type == WLAN_FC_TYPE_MGMT && stype == WLAN_FC_STYPE_AUTH &&
+                   fc & IEEE80211_FCTL_PROTECTED && ieee->host_decrypt &&
+                   (keyidx = hostap_rx_frame_decrypt(ieee, skb, crypt)) < 0)
+               {
+                       printk(KERN_DEBUG "%s: failed to decrypt mgmt::auth "
+                              "from " MAC_FMT "\n", dev->name,
+                              MAC_ARG(hdr->addr2));
+                       /* TODO: could inform hostapd about this so that it
+                        * could send auth failure report */
+                       goto rx_dropped;
+               }
+
+               if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype))
+                       goto rx_dropped;
+               else
+                       goto rx_exit;
+       }
+#endif
+
+       /* Data frame - extract src/dst addresses */
+       if (skb->len < IEEE80211_3ADDR_LEN)
+               goto rx_dropped;
+
+       switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
+       case IEEE80211_FCTL_FROMDS:
+               memcpy(dst, hdr->addr1, ETH_ALEN);
+               memcpy(src, hdr->addr3, ETH_ALEN);
+               break;
+       case IEEE80211_FCTL_TODS:
+               memcpy(dst, hdr->addr3, ETH_ALEN);
+               memcpy(src, hdr->addr2, ETH_ALEN);
+               break;
+       case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
+               if (skb->len < IEEE80211_4ADDR_LEN)
+                       goto rx_dropped;
+               memcpy(dst, hdr->addr3, ETH_ALEN);
+               memcpy(src, hdr->addr4, ETH_ALEN);
+               break;
+       case 0:
+               memcpy(dst, hdr->addr1, ETH_ALEN);
+               memcpy(src, hdr->addr2, ETH_ALEN);
+               break;
+       }
+
+#ifdef NOT_YET
+       if (hostap_rx_frame_wds(ieee, hdr, fc, &wds))
+               goto rx_dropped;
+       if (wds) {
+               skb->dev = dev = wds;
+               stats = hostap_get_stats(dev);
+       }
+
+       if (ieee->iw_mode == IW_MODE_MASTER && !wds &&
+           (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) == IEEE80211_FCTL_FROMDS &&
+           ieee->stadev &&
+           memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) {
+               /* Frame from BSSID of the AP for which we are a client */
+               skb->dev = dev = ieee->stadev;
+               stats = hostap_get_stats(dev);
+               from_assoc_ap = 1;
+       }
+#endif
+
+       dev->last_rx = jiffies;
+
+#ifdef NOT_YET
+       if ((ieee->iw_mode == IW_MODE_MASTER ||
+            ieee->iw_mode == IW_MODE_REPEAT) &&
+           !from_assoc_ap) {
+               switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats,
+                                            wds != NULL)) {
+               case AP_RX_CONTINUE_NOT_AUTHORIZED:
+                       frame_authorized = 0;
+                       break;
+               case AP_RX_CONTINUE:
+                       frame_authorized = 1;
+                       break;
+               case AP_RX_DROP:
+                       goto rx_dropped;
+               case AP_RX_EXIT:
+                       goto rx_exit;
+               }
+       }
+#endif
+
+       /* Nullfunc frames may have PS-bit set, so they must be passed to
+        * hostap_handle_sta_rx() before being dropped here. */
+       if (stype != IEEE80211_STYPE_DATA &&
+           stype != IEEE80211_STYPE_DATA_CFACK &&
+           stype != IEEE80211_STYPE_DATA_CFPOLL &&
+           stype != IEEE80211_STYPE_DATA_CFACKPOLL) {
+               if (stype != IEEE80211_STYPE_NULLFUNC)
+                       IEEE80211_DEBUG_DROP(
+                               "RX: dropped data frame "
+                               "with no data (type=0x%02x, "
+                               "subtype=0x%02x, len=%d)\n",
+                               type, stype, skb->len);
+               goto rx_dropped;
+       }
+
+       /* skb: hdr + (possibly fragmented, possibly encrypted) payload */
+
+       if (ieee->host_decrypt && (fc & IEEE80211_FCTL_PROTECTED) &&
+           (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0)
+               goto rx_dropped;
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+
+       /* skb: hdr + (possibly fragmented) plaintext payload */
+       // PR: FIXME: hostap has additional conditions in the "if" below:
+       // ieee->host_decrypt && (fc & IEEE80211_FCTL_PROTECTED) &&
+       if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) {
+               int flen;
+               struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr);
+               IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag);
+
+               if (!frag_skb) {
+                       IEEE80211_DEBUG(IEEE80211_DL_RX | IEEE80211_DL_FRAG,
+                                       "Rx cannot get skb from fragment "
+                                       "cache (morefrag=%d seq=%u frag=%u)\n",
+                                       (fc & IEEE80211_FCTL_MOREFRAGS) != 0,
+                                       WLAN_GET_SEQ_SEQ(sc), frag);
+                       goto rx_dropped;
+               }
+
+               flen = skb->len;
+               if (frag != 0)
+                       flen -= hdrlen;
+
+               if (frag_skb->tail + flen > frag_skb->end) {
+                       printk(KERN_WARNING "%s: host decrypted and "
+                              "reassembled frame did not fit skb\n",
+                              dev->name);
+                       ieee80211_frag_cache_invalidate(ieee, hdr);
+                       goto rx_dropped;
+               }
+
+               if (frag == 0) {
+                       /* copy first fragment (including full headers) into
+                        * beginning of the fragment cache skb */
+                       memcpy(skb_put(frag_skb, flen), skb->data, flen);
+               } else {
+                       /* append frame payload to the end of the fragment
+                        * cache skb */
+                       memcpy(skb_put(frag_skb, flen), skb->data + hdrlen,
+                              flen);
+               }
+               dev_kfree_skb_any(skb);
+               skb = NULL;
+
+               if (fc & IEEE80211_FCTL_MOREFRAGS) {
+                       /* more fragments expected - leave the skb in fragment
+                        * cache for now; it will be delivered to upper layers
+                        * after all fragments have been received */
+                       goto rx_exit;
+               }
+
+               /* this was the last fragment and the frame will be
+                * delivered, so remove skb from fragment cache */
+               skb = frag_skb;
+               hdr = (struct ieee80211_hdr *) skb->data;
+               ieee80211_frag_cache_invalidate(ieee, hdr);
+       }
+
+       /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
+        * encrypted/authenticated */
+       if (ieee->host_decrypt && (fc & IEEE80211_FCTL_PROTECTED) &&
+           ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt))
+               goto rx_dropped;
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep) {
+               if (/*ieee->ieee802_1x &&*/
+                   ieee80211_is_eapol_frame(ieee, skb)) {
+                       /* pass unencrypted EAPOL frames even if encryption is
+                        * configured */
+               } else {
+                       IEEE80211_DEBUG_DROP(
+                               "encryption configured, but RX "
+                               "frame not encrypted (SA=" MAC_FMT ")\n",
+                               MAC_ARG(hdr->addr2));
+                       goto rx_dropped;
+               }
+       }
+
+       if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep &&
+           !ieee80211_is_eapol_frame(ieee, skb)) {
+               IEEE80211_DEBUG_DROP(
+                       "dropped unencrypted RX data "
+                       "frame from " MAC_FMT
+                       " (drop_unencrypted=1)\n",
+                       MAC_ARG(hdr->addr2));
+               goto rx_dropped;
+       }
+
+       /* skb: hdr + (possible reassembled) full plaintext payload */
+
+       payload = skb->data + hdrlen;
+       ethertype = (payload[6] << 8) | payload[7];
+
+#ifdef NOT_YET
+       /* If IEEE 802.1X is used, check whether the port is authorized to send
+        * the received frame. */
+       if (ieee->ieee802_1x && ieee->iw_mode == IW_MODE_MASTER) {
+               if (ethertype == ETH_P_PAE) {
+                       printk(KERN_DEBUG "%s: RX: IEEE 802.1X frame\n",
+                              dev->name);
+                       if (ieee->hostapd && ieee->apdev) {
+                               /* Send IEEE 802.1X frames to the user
+                                * space daemon for processing */
+                               prism2_rx_80211(ieee->apdev, skb, rx_stats,
+                                               PRISM2_RX_MGMT);
+                               ieee->apdevstats.rx_packets++;
+                               ieee->apdevstats.rx_bytes += skb->len;
+                               goto rx_exit;
+                       }
+               } else if (!frame_authorized) {
+                       printk(KERN_DEBUG "%s: dropped frame from "
+                              "unauthorized port (IEEE 802.1X): "
+                              "ethertype=0x%04x\n",
+                              dev->name, ethertype);
+                       goto rx_dropped;
+               }
+       }
+#endif
+
+       /* convert hdr + possible LLC headers into Ethernet header */
+       if (skb->len - hdrlen >= 8 &&
+           ((memcmp(payload, rfc1042_header, SNAP_SIZE) == 0 &&
+             ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
+            memcmp(payload, bridge_tunnel_header, SNAP_SIZE) == 0)) {
+               /* remove RFC1042 or Bridge-Tunnel encapsulation and
+                * replace EtherType */
+               skb_pull(skb, hdrlen + SNAP_SIZE);
+               memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
+               memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
+       } else {
+               u16 len;
+               /* Leave Ethernet header part of hdr and full payload */
+               skb_pull(skb, hdrlen);
+               len = htons(skb->len);
+               memcpy(skb_push(skb, 2), &len, 2);
+               memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
+               memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
+       }
+
+#ifdef NOT_YET
+       if (wds && ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
+                   IEEE80211_FCTL_TODS) &&
+           skb->len >= ETH_HLEN + ETH_ALEN) {
+               /* Non-standard frame: get addr4 from its bogus location after
+                * the payload */
+               memcpy(skb->data + ETH_ALEN,
+                      skb->data + skb->len - ETH_ALEN, ETH_ALEN);
+               skb_trim(skb, skb->len - ETH_ALEN);
+       }
+#endif
+
+       stats->rx_packets++;
+       stats->rx_bytes += skb->len;
+
+#ifdef NOT_YET
+       if (ieee->iw_mode == IW_MODE_MASTER && !wds &&
+           ieee->ap->bridge_packets) {
+               if (dst[0] & 0x01) {
+                       /* copy multicast frame both to the higher layers and
+                        * to the wireless media */
+                       ieee->ap->bridged_multicast++;
+                       skb2 = skb_clone(skb, GFP_ATOMIC);
+                       if (skb2 == NULL)
+                               printk(KERN_DEBUG "%s: skb_clone failed for "
+                                      "multicast frame\n", dev->name);
+               } else if (hostap_is_sta_assoc(ieee->ap, dst)) {
+                       /* send frame directly to the associated STA using
+                        * wireless media and not passing to higher layers */
+                       ieee->ap->bridged_unicast++;
+                       skb2 = skb;
+                       skb = NULL;
+               }
+       }
+
+       if (skb2 != NULL) {
+               /* send to wireless media */
+               skb2->protocol = __constant_htons(ETH_P_802_3);
+               skb2->mac.raw = skb2->nh.raw = skb2->data;
+               /* skb2->nh.raw = skb2->data + ETH_HLEN; */
+               skb2->dev = dev;
+               dev_queue_xmit(skb2);
+       }
+
+#endif
+
+       if (skb) {
+               skb->protocol = eth_type_trans(skb, dev);
+               memset(skb->cb, 0, sizeof(skb->cb));
+               skb->dev = dev;
+               skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
+               netif_rx(skb);
+       }
+
+ rx_exit:
+#ifdef NOT_YET
+       if (sta)
+               hostap_handle_sta_release(sta);
+#endif
+       return 1;
+
+ rx_dropped:
+       stats->rx_dropped++;
+
+       /* Returning 0 indicates to caller that we have not handled the SKB--
+        * so it is still allocated and can be used again by underlying
+        * hardware as a DMA target */
+       return 0;
+}
+
+#define MGMT_FRAME_FIXED_PART_LENGTH           0x24
+
+static inline int ieee80211_is_ofdm_rate(u8 rate)
+{
+       switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
+       case IEEE80211_OFDM_RATE_6MB:
+       case IEEE80211_OFDM_RATE_9MB:
+       case IEEE80211_OFDM_RATE_12MB:
+       case IEEE80211_OFDM_RATE_18MB:
+       case IEEE80211_OFDM_RATE_24MB:
+       case IEEE80211_OFDM_RATE_36MB:
+       case IEEE80211_OFDM_RATE_48MB:
+       case IEEE80211_OFDM_RATE_54MB:
+               return 1;
+       }
+        return 0;
+}
+
+
+static inline int ieee80211_network_init(
+       struct ieee80211_device *ieee,
+       struct ieee80211_probe_response *beacon,
+       struct ieee80211_network *network,
+       struct ieee80211_rx_stats *stats)
+{
+#ifdef CONFIG_IEEE80211_DEBUG
+       char rates_str[64];
+       char *p;
+#endif
+       struct ieee80211_info_element *info_element;
+       u16 left;
+       u8 i;
+
+       /* Pull out fixed field data */
+       memcpy(network->bssid, beacon->header.addr3, ETH_ALEN);
+       network->capability = beacon->capability;
+       network->last_scanned = jiffies;
+       network->time_stamp[0] = beacon->time_stamp[0];
+       network->time_stamp[1] = beacon->time_stamp[1];
+       network->beacon_interval = beacon->beacon_interval;
+       /* Where to pull this? beacon->listen_interval;*/
+       network->listen_interval = 0x0A;
+       network->rates_len = network->rates_ex_len = 0;
+       network->last_associate = 0;
+       network->ssid_len = 0;
+       network->flags = 0;
+       network->atim_window = 0;
+
+       if (stats->freq == IEEE80211_52GHZ_BAND) {
+               /* for A band (No DS info) */
+               network->channel = stats->received_channel;
+       } else
+               network->flags |= NETWORK_HAS_CCK;
+
+       network->wpa_ie_len = 0;
+       network->rsn_ie_len = 0;
+
+       info_element = &beacon->info_element;
+       left = stats->len - ((void *)info_element - (void *)beacon);
+       while (left >= sizeof(struct ieee80211_info_element_hdr)) {
+               if (sizeof(struct ieee80211_info_element_hdr) + info_element->len > left) {
+                       IEEE80211_DEBUG_SCAN("SCAN: parse failed: info_element->len + 2 > left : info_element->len+2=%Zd left=%d.\n",
+                                            info_element->len + sizeof(struct ieee80211_info_element),
+                                            left);
+                       return 1;
+                       }
+
+               switch (info_element->id) {
+               case MFIE_TYPE_SSID:
+                       if (ieee80211_is_empty_essid(info_element->data,
+                                                    info_element->len)) {
+                               network->flags |= NETWORK_EMPTY_ESSID;
+                               break;
+                       }
+
+                       network->ssid_len = min(info_element->len,
+                                               (u8)IW_ESSID_MAX_SIZE);
+                       memcpy(network->ssid, info_element->data, network->ssid_len);
+                       if (network->ssid_len < IW_ESSID_MAX_SIZE)
+                               memset(network->ssid + network->ssid_len, 0,
+                                      IW_ESSID_MAX_SIZE - network->ssid_len);
+
+                       IEEE80211_DEBUG_SCAN("MFIE_TYPE_SSID: '%s' len=%d.\n",
+                                            network->ssid, network->ssid_len);
+                       break;
+
+               case MFIE_TYPE_RATES:
+#ifdef CONFIG_IEEE80211_DEBUG
+                       p = rates_str;
+#endif
+                       network->rates_len = min(info_element->len, MAX_RATES_LENGTH);
+                       for (i = 0; i < network->rates_len; i++) {
+                               network->rates[i] = info_element->data[i];
+#ifdef CONFIG_IEEE80211_DEBUG
+                               p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]);
+#endif
+                               if (ieee80211_is_ofdm_rate(info_element->data[i])) {
+                                       network->flags |= NETWORK_HAS_OFDM;
+                                       if (info_element->data[i] &
+                                           IEEE80211_BASIC_RATE_MASK)
+                                               network->flags &=
+                                                       ~NETWORK_HAS_CCK;
+                               }
+                       }
+
+                       IEEE80211_DEBUG_SCAN("MFIE_TYPE_RATES: '%s' (%d)\n",
+                                            rates_str, network->rates_len);
+                       break;
+
+               case MFIE_TYPE_RATES_EX:
+#ifdef CONFIG_IEEE80211_DEBUG
+                       p = rates_str;
+#endif
+                       network->rates_ex_len = min(info_element->len, MAX_RATES_EX_LENGTH);
+                       for (i = 0; i < network->rates_ex_len; i++) {
+                               network->rates_ex[i] = info_element->data[i];
+#ifdef CONFIG_IEEE80211_DEBUG
+                               p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]);
+#endif
+                               if (ieee80211_is_ofdm_rate(info_element->data[i])) {
+                                       network->flags |= NETWORK_HAS_OFDM;
+                                       if (info_element->data[i] &
+                                           IEEE80211_BASIC_RATE_MASK)
+                                               network->flags &=
+                                                       ~NETWORK_HAS_CCK;
+                               }
+                       }
+
+                       IEEE80211_DEBUG_SCAN("MFIE_TYPE_RATES_EX: '%s' (%d)\n",
+                                            rates_str, network->rates_ex_len);
+                       break;
+
+               case MFIE_TYPE_DS_SET:
+                       IEEE80211_DEBUG_SCAN("MFIE_TYPE_DS_SET: %d\n",
+                                            info_element->data[0]);
+                       if (stats->freq == IEEE80211_24GHZ_BAND)
+                               network->channel = info_element->data[0];
+                       break;
+
+               case MFIE_TYPE_FH_SET:
+                       IEEE80211_DEBUG_SCAN("MFIE_TYPE_FH_SET: ignored\n");
+                       break;
+
+               case MFIE_TYPE_CF_SET:
+                       IEEE80211_DEBUG_SCAN("MFIE_TYPE_CF_SET: ignored\n");
+                       break;
+
+               case MFIE_TYPE_TIM:
+                       IEEE80211_DEBUG_SCAN("MFIE_TYPE_TIM: ignored\n");
+                       break;
+
+               case MFIE_TYPE_IBSS_SET:
+                       IEEE80211_DEBUG_SCAN("MFIE_TYPE_IBSS_SET: ignored\n");
+                       break;
+
+               case MFIE_TYPE_CHALLENGE:
+                       IEEE80211_DEBUG_SCAN("MFIE_TYPE_CHALLENGE: ignored\n");
+                       break;
+
+               case MFIE_TYPE_GENERIC:
+                       IEEE80211_DEBUG_SCAN("MFIE_TYPE_GENERIC: %d bytes\n",
+                                            info_element->len);
+                       if (info_element->len >= 4  &&
+                           info_element->data[0] == 0x00 &&
+                           info_element->data[1] == 0x50 &&
+                           info_element->data[2] == 0xf2 &&
+                           info_element->data[3] == 0x01) {
+                               network->wpa_ie_len = min(info_element->len + 2,
+                                                        MAX_WPA_IE_LEN);
+                               memcpy(network->wpa_ie, info_element,
+                                      network->wpa_ie_len);
+                       }
+                       break;
+
+               case MFIE_TYPE_RSN:
+                       IEEE80211_DEBUG_SCAN("MFIE_TYPE_RSN: %d bytes\n",
+                                            info_element->len);
+                       network->rsn_ie_len = min(info_element->len + 2,
+                                                MAX_WPA_IE_LEN);
+                       memcpy(network->rsn_ie, info_element,
+                              network->rsn_ie_len);
+                       break;
+
+               default:
+                       IEEE80211_DEBUG_SCAN("unsupported IE %d\n",
+                                            info_element->id);
+                        break;
+               }
+
+               left -= sizeof(struct ieee80211_info_element_hdr) +
+                       info_element->len;
+               info_element = (struct ieee80211_info_element *)
+                       &info_element->data[info_element->len];
+       }
+
+       network->mode = 0;
+       if (stats->freq == IEEE80211_52GHZ_BAND)
+               network->mode = IEEE_A;
+       else {
+               if (network->flags & NETWORK_HAS_OFDM)
+                       network->mode |= IEEE_G;
+               if (network->flags & NETWORK_HAS_CCK)
+                       network->mode |= IEEE_B;
+       }
+
+       if (network->mode == 0) {
+               IEEE80211_DEBUG_SCAN("Filtered out '%s (" MAC_FMT ")' "
+                                    "network.\n",
+                                    escape_essid(network->ssid,
+                                                 network->ssid_len),
+                                    MAC_ARG(network->bssid));
+               return 1;
+       }
+
+       if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
+               network->flags |= NETWORK_EMPTY_ESSID;
+
+       memcpy(&network->stats, stats, sizeof(network->stats));
+
+       return 0;
+}
+
+static inline int is_same_network(struct ieee80211_network *src,
+                                 struct ieee80211_network *dst)
+{
+       /* A network is only a duplicate if the channel, BSSID, and ESSID
+        * all match.  We treat all <hidden> with the same BSSID and channel
+        * as one network */
+       return ((src->ssid_len == dst->ssid_len) &&
+               (src->channel == dst->channel) &&
+               !memcmp(src->bssid, dst->bssid, ETH_ALEN) &&
+               !memcmp(src->ssid, dst->ssid, src->ssid_len));
+}
+
+static inline void update_network(struct ieee80211_network *dst,
+                                 struct ieee80211_network *src)
+{
+       memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats));
+       dst->capability = src->capability;
+       memcpy(dst->rates, src->rates, src->rates_len);
+       dst->rates_len = src->rates_len;
+       memcpy(dst->rates_ex, src->rates_ex, src->rates_ex_len);
+       dst->rates_ex_len = src->rates_ex_len;
+
+       dst->mode = src->mode;
+       dst->flags = src->flags;
+       dst->time_stamp[0] = src->time_stamp[0];
+       dst->time_stamp[1] = src->time_stamp[1];
+
+       dst->beacon_interval = src->beacon_interval;
+       dst->listen_interval = src->listen_interval;
+       dst->atim_window = src->atim_window;
+
+       memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len);
+       dst->wpa_ie_len = src->wpa_ie_len;
+       memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len);
+       dst->rsn_ie_len = src->rsn_ie_len;
+
+       dst->last_scanned = jiffies;
+       /* dst->last_associate is not overwritten */
+}
+
+static inline void ieee80211_process_probe_response(
+       struct ieee80211_device *ieee,
+       struct ieee80211_probe_response *beacon,
+       struct ieee80211_rx_stats *stats)
+{
+       struct ieee80211_network network;
+       struct ieee80211_network *target;
+       struct ieee80211_network *oldest = NULL;
+#ifdef CONFIG_IEEE80211_DEBUG
+       struct ieee80211_info_element *info_element = &beacon->info_element;
+#endif
+       unsigned long flags;
+
+       IEEE80211_DEBUG_SCAN(
+               "'%s' (" MAC_FMT "): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
+               escape_essid(info_element->data, info_element->len),
+               MAC_ARG(beacon->header.addr3),
+               (beacon->capability & (1<<0xf)) ? '1' : '0',
+               (beacon->capability & (1<<0xe)) ? '1' : '0',
+               (beacon->capability & (1<<0xd)) ? '1' : '0',
+               (beacon->capability & (1<<0xc)) ? '1' : '0',
+               (beacon->capability & (1<<0xb)) ? '1' : '0',
+               (beacon->capability & (1<<0xa)) ? '1' : '0',
+               (beacon->capability & (1<<0x9)) ? '1' : '0',
+               (beacon->capability & (1<<0x8)) ? '1' : '0',
+               (beacon->capability & (1<<0x7)) ? '1' : '0',
+               (beacon->capability & (1<<0x6)) ? '1' : '0',
+               (beacon->capability & (1<<0x5)) ? '1' : '0',
+               (beacon->capability & (1<<0x4)) ? '1' : '0',
+               (beacon->capability & (1<<0x3)) ? '1' : '0',
+               (beacon->capability & (1<<0x2)) ? '1' : '0',
+               (beacon->capability & (1<<0x1)) ? '1' : '0',
+               (beacon->capability & (1<<0x0)) ? '1' : '0');
+
+       if (ieee80211_network_init(ieee, beacon, &network, stats)) {
+               IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n",
+                                    escape_essid(info_element->data,
+                                                 info_element->len),
+                                    MAC_ARG(beacon->header.addr3),
+                                    WLAN_FC_GET_STYPE(beacon->header.frame_ctl) ==
+                                    IEEE80211_STYPE_PROBE_RESP ?
+                                    "PROBE RESPONSE" : "BEACON");
+               return;
+       }
+
+       /* The network parsed correctly -- so now we scan our known networks
+        * to see if we can find it in our list.
+        *
+        * NOTE:  This search is definitely not optimized.  Once its doing
+        *        the "right thing" we'll optimize it for efficiency if
+        *        necessary */
+
+       /* Search for this entry in the list and update it if it is
+        * already there. */
+
+       spin_lock_irqsave(&ieee->lock, flags);
+
+       list_for_each_entry(target, &ieee->network_list, list) {
+               if (is_same_network(target, &network))
+                       break;
+
+               if ((oldest == NULL) ||
+                   (target->last_scanned < oldest->last_scanned))
+                       oldest = target;
+       }
+
+       /* If we didn't find a match, then get a new network slot to initialize
+        * with this beacon's information */
+       if (&target->list == &ieee->network_list) {
+               if (list_empty(&ieee->network_free_list)) {
+                       /* If there are no more slots, expire the oldest */
+                       list_del(&oldest->list);
+                       target = oldest;
+                       IEEE80211_DEBUG_SCAN("Expired '%s' (" MAC_FMT ") from "
+                                            "network list.\n",
+                                            escape_essid(target->ssid,
+                                                         target->ssid_len),
+                                            MAC_ARG(target->bssid));
+               } else {
+                       /* Otherwise just pull from the free list */
+                       target = list_entry(ieee->network_free_list.next,
+                                           struct ieee80211_network, list);
+                       list_del(ieee->network_free_list.next);
+               }
+
+
+#ifdef CONFIG_IEEE80211_DEBUG
+               IEEE80211_DEBUG_SCAN("Adding '%s' (" MAC_FMT ") via %s.\n",
+                                    escape_essid(network.ssid,
+                                                 network.ssid_len),
+                                    MAC_ARG(network.bssid),
+                                    WLAN_FC_GET_STYPE(beacon->header.frame_ctl) ==
+                                    IEEE80211_STYPE_PROBE_RESP ?
+                                    "PROBE RESPONSE" : "BEACON");
+#endif
+               memcpy(target, &network, sizeof(*target));
+               list_add_tail(&target->list, &ieee->network_list);
+       } else {
+               IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n",
+                                    escape_essid(target->ssid,
+                                                 target->ssid_len),
+                                    MAC_ARG(target->bssid),
+                                    WLAN_FC_GET_STYPE(beacon->header.frame_ctl) ==
+                                    IEEE80211_STYPE_PROBE_RESP ?
+                                    "PROBE RESPONSE" : "BEACON");
+               update_network(target, &network);
+       }
+
+       spin_unlock_irqrestore(&ieee->lock, flags);
+}
+
+void ieee80211_rx_mgt(struct ieee80211_device *ieee,
+                     struct ieee80211_hdr *header,
+                     struct ieee80211_rx_stats *stats)
+{
+       switch (WLAN_FC_GET_STYPE(header->frame_ctl)) {
+       case IEEE80211_STYPE_ASSOC_RESP:
+               IEEE80211_DEBUG_MGMT("received ASSOCIATION RESPONSE (%d)\n",
+                                    WLAN_FC_GET_STYPE(header->frame_ctl));
+               break;
+
+       case IEEE80211_STYPE_REASSOC_RESP:
+               IEEE80211_DEBUG_MGMT("received REASSOCIATION RESPONSE (%d)\n",
+                                    WLAN_FC_GET_STYPE(header->frame_ctl));
+               break;
+
+       case IEEE80211_STYPE_PROBE_RESP:
+               IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
+                                    WLAN_FC_GET_STYPE(header->frame_ctl));
+               IEEE80211_DEBUG_SCAN("Probe response\n");
+               ieee80211_process_probe_response(
+                       ieee, (struct ieee80211_probe_response *)header, stats);
+               break;
+
+       case IEEE80211_STYPE_BEACON:
+               IEEE80211_DEBUG_MGMT("received BEACON (%d)\n",
+                                    WLAN_FC_GET_STYPE(header->frame_ctl));
+               IEEE80211_DEBUG_SCAN("Beacon\n");
+               ieee80211_process_probe_response(
+                       ieee, (struct ieee80211_probe_response *)header, stats);
+               break;
+
+       default:
+               IEEE80211_DEBUG_MGMT("received UNKNOWN (%d)\n",
+                                    WLAN_FC_GET_STYPE(header->frame_ctl));
+               IEEE80211_WARNING("%s: Unknown management packet: %d\n",
+                                 ieee->dev->name,
+                                 WLAN_FC_GET_STYPE(header->frame_ctl));
+               break;
+       }
+}
+
+
+EXPORT_SYMBOL(ieee80211_rx_mgt);
+EXPORT_SYMBOL(ieee80211_rx);
diff --git a/net/ieee80211/ieee80211_tx.c b/net/ieee80211/ieee80211_tx.c
new file mode 100644 (file)
index 0000000..b7ea3e2
--- /dev/null
@@ -0,0 +1,438 @@
+/******************************************************************************
+
+  Copyright(c) 2003 - 2004 Intel Corporation. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms of version 2 of the GNU General Public License as
+  published by the Free Software Foundation.
+
+  This program is distributed in the hope that it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc., 59
+  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+  The full GNU General Public License is included in this distribution in the
+  file called LICENSE.
+
+  Contact Information:
+  James P. Ketrenos <ipw2100-admin@linux.intel.com>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+******************************************************************************/
+#include <linux/compiler.h>
+#include <linux/config.h>
+#include <linux/errno.h>
+#include <linux/if_arp.h>
+#include <linux/in6.h>
+#include <linux/in.h>
+#include <linux/ip.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/proc_fs.h>
+#include <linux/skbuff.h>
+#include <linux/slab.h>
+#include <linux/tcp.h>
+#include <linux/types.h>
+#include <linux/version.h>
+#include <linux/wireless.h>
+#include <linux/etherdevice.h>
+#include <asm/uaccess.h>
+
+#include <net/ieee80211.h>
+
+
+/*
+
+
+802.11 Data Frame
+
+      ,-------------------------------------------------------------------.
+Bytes |  2   |  2   |    6    |    6    |    6    |  2   | 0..2312 |   4  |
+      |------|------|---------|---------|---------|------|---------|------|
+Desc. | ctrl | dura |  DA/RA  |   TA    |    SA   | Sequ |  Frame  |  fcs |
+      |      | tion | (BSSID) |         |         | ence |  data   |      |
+      `--------------------------------------------------|         |------'
+Total: 28 non-data bytes                                 `----.----'
+                                                              |
+       .- 'Frame data' expands to <---------------------------'
+       |
+       V
+      ,---------------------------------------------------.
+Bytes |  1   |  1   |    1    |    3     |  2   |  0-2304 |
+      |------|------|---------|----------|------|---------|
+Desc. | SNAP | SNAP | Control |Eth Tunnel| Type | IP      |
+      | DSAP | SSAP |         |          |      | Packet  |
+      | 0xAA | 0xAA |0x03 (UI)|0x00-00-F8|      |         |
+      `-----------------------------------------|         |
+Total: 8 non-data bytes                         `----.----'
+                                                     |
+       .- 'IP Packet' expands, if WEP enabled, to <--'
+       |
+       V
+      ,-----------------------.
+Bytes |  4  |   0-2296  |  4  |
+      |-----|-----------|-----|
+Desc. | IV  | Encrypted | ICV |
+      |     | IP Packet |     |
+      `-----------------------'
+Total: 8 non-data bytes
+
+
+802.3 Ethernet Data Frame
+
+      ,-----------------------------------------.
+Bytes |   6   |   6   |  2   |  Variable |   4  |
+      |-------|-------|------|-----------|------|
+Desc. | Dest. | Source| Type | IP Packet |  fcs |
+      |  MAC  |  MAC  |      |           |      |
+      `-----------------------------------------'
+Total: 18 non-data bytes
+
+In the event that fragmentation is required, the incoming payload is split into
+N parts of size ieee->fts.  The first fragment contains the SNAP header and the
+remaining packets are just data.
+
+If encryption is enabled, each fragment payload size is reduced by enough space
+to add the prefix and postfix (IV and ICV totalling 8 bytes in the case of WEP)
+So if you have 1500 bytes of payload with ieee->fts set to 500 without
+encryption it will take 3 frames.  With WEP it will take 4 frames as the
+payload of each frame is reduced to 492 bytes.
+
+* SKB visualization
+*
+*  ,- skb->data
+* |
+* |    ETHERNET HEADER        ,-<-- PAYLOAD
+* |                           |     14 bytes from skb->data
+* |  2 bytes for Type --> ,T. |     (sizeof ethhdr)
+* |                       | | |
+* |,-Dest.--. ,--Src.---. | | |
+* |  6 bytes| | 6 bytes | | | |
+* v         | |         | | | |
+* 0         | v       1 | v | v           2
+* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+*     ^     | ^         | ^ |
+*     |     | |         | | |
+*     |     | |         | `T' <---- 2 bytes for Type
+*     |     | |         |
+*     |     | '---SNAP--' <-------- 6 bytes for SNAP
+*     |     |
+*     `-IV--' <-------------------- 4 bytes for IV (WEP)
+*
+*      SNAP HEADER
+*
+*/
+
+static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
+static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
+
+static inline int ieee80211_put_snap(u8 *data, u16 h_proto)
+{
+       struct ieee80211_snap_hdr *snap;
+       u8 *oui;
+
+       snap = (struct ieee80211_snap_hdr *)data;
+       snap->dsap = 0xaa;
+       snap->ssap = 0xaa;
+       snap->ctrl = 0x03;
+
+       if (h_proto == 0x8137 || h_proto == 0x80f3)
+               oui = P802_1H_OUI;
+       else
+               oui = RFC1042_OUI;
+       snap->oui[0] = oui[0];
+       snap->oui[1] = oui[1];
+       snap->oui[2] = oui[2];
+
+       *(u16 *)(data + SNAP_SIZE) = htons(h_proto);
+
+       return SNAP_SIZE + sizeof(u16);
+}
+
+static inline int ieee80211_encrypt_fragment(
+       struct ieee80211_device *ieee,
+       struct sk_buff *frag,
+       int hdr_len)
+{
+       struct ieee80211_crypt_data* crypt = ieee->crypt[ieee->tx_keyidx];
+       int res;
+
+#ifdef CONFIG_IEEE80211_CRYPT_TKIP
+       struct ieee80211_hdr *header;
+
+       if (ieee->tkip_countermeasures &&
+           crypt && crypt->ops && strcmp(crypt->ops->name, "TKIP") == 0) {
+               header = (struct ieee80211_hdr *) frag->data;
+               if (net_ratelimit()) {
+                       printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
+                              "TX packet to " MAC_FMT "\n",
+                              ieee->dev->name, MAC_ARG(header->addr1));
+               }
+               return -1;
+       }
+#endif
+       /* To encrypt, frame format is:
+        * IV (4 bytes), clear payload (including SNAP), ICV (4 bytes) */
+
+       // PR: FIXME: Copied from hostap. Check fragmentation/MSDU/MPDU encryption.
+       /* Host-based IEEE 802.11 fragmentation for TX is not yet supported, so
+        * call both MSDU and MPDU encryption functions from here. */
+       atomic_inc(&crypt->refcnt);
+       res = 0;
+       if (crypt->ops->encrypt_msdu)
+               res = crypt->ops->encrypt_msdu(frag, hdr_len, crypt->priv);
+       if (res == 0 && crypt->ops->encrypt_mpdu)
+               res = crypt->ops->encrypt_mpdu(frag, hdr_len, crypt->priv);
+
+       atomic_dec(&crypt->refcnt);
+       if (res < 0) {
+               printk(KERN_INFO "%s: Encryption failed: len=%d.\n",
+                      ieee->dev->name, frag->len);
+               ieee->ieee_stats.tx_discards++;
+               return -1;
+       }
+
+       return 0;
+}
+
+
+void ieee80211_txb_free(struct ieee80211_txb *txb) {
+       int i;
+       if (unlikely(!txb))
+               return;
+       for (i = 0; i < txb->nr_frags; i++)
+               if (txb->fragments[i])
+                       dev_kfree_skb_any(txb->fragments[i]);
+       kfree(txb);
+}
+
+static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
+                                                int gfp_mask)
+{
+       struct ieee80211_txb *txb;
+       int i;
+       txb = kmalloc(
+               sizeof(struct ieee80211_txb) + (sizeof(u8*) * nr_frags),
+               gfp_mask);
+       if (!txb)
+               return NULL;
+
+       memset(txb, 0, sizeof(struct ieee80211_txb));
+       txb->nr_frags = nr_frags;
+       txb->frag_size = txb_size;
+
+       for (i = 0; i < nr_frags; i++) {
+               txb->fragments[i] = dev_alloc_skb(txb_size);
+               if (unlikely(!txb->fragments[i])) {
+                       i--;
+                       break;
+               }
+       }
+       if (unlikely(i != nr_frags)) {
+               while (i >= 0)
+                       dev_kfree_skb_any(txb->fragments[i--]);
+               kfree(txb);
+               return NULL;
+       }
+       return txb;
+}
+
+/* SKBs are added to the ieee->tx_queue. */
+int ieee80211_xmit(struct sk_buff *skb,
+                  struct net_device *dev)
+{
+       struct ieee80211_device *ieee = netdev_priv(dev);
+       struct ieee80211_txb *txb = NULL;
+       struct ieee80211_hdr *frag_hdr;
+       int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size;
+       unsigned long flags;
+       struct net_device_stats *stats = &ieee->stats;
+       int ether_type, encrypt;
+       int bytes, fc, hdr_len;
+       struct sk_buff *skb_frag;
+       struct ieee80211_hdr header = { /* Ensure zero initialized */
+               .duration_id = 0,
+               .seq_ctl = 0
+       };
+       u8 dest[ETH_ALEN], src[ETH_ALEN];
+
+       struct ieee80211_crypt_data* crypt;
+
+       spin_lock_irqsave(&ieee->lock, flags);
+
+       /* If there is no driver handler to take the TXB, dont' bother
+        * creating it... */
+       if (!ieee->hard_start_xmit) {
+               printk(KERN_WARNING "%s: No xmit handler.\n",
+                      ieee->dev->name);
+               goto success;
+       }
+
+       if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) {
+               printk(KERN_WARNING "%s: skb too small (%d).\n",
+                      ieee->dev->name, skb->len);
+               goto success;
+       }
+
+       ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto);
+
+       crypt = ieee->crypt[ieee->tx_keyidx];
+
+       encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) &&
+               ieee->host_encrypt && crypt && crypt->ops;
+
+       if (!encrypt && ieee->ieee802_1x &&
+           ieee->drop_unencrypted && ether_type != ETH_P_PAE) {
+               stats->tx_dropped++;
+               goto success;
+       }
+
+       /* Save source and destination addresses */
+       memcpy(&dest, skb->data, ETH_ALEN);
+       memcpy(&src, skb->data+ETH_ALEN, ETH_ALEN);
+
+       /* Advance the SKB to the start of the payload */
+       skb_pull(skb, sizeof(struct ethhdr));
+
+       /* Determine total amount of storage required for TXB packets */
+       bytes = skb->len + SNAP_SIZE + sizeof(u16);
+
+       if (encrypt)
+               fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA |
+                       IEEE80211_FCTL_PROTECTED;
+       else
+               fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA;
+
+       if (ieee->iw_mode == IW_MODE_INFRA) {
+               fc |= IEEE80211_FCTL_TODS;
+               /* To DS: Addr1 = BSSID, Addr2 = SA,
+                  Addr3 = DA */
+               memcpy(&header.addr1, ieee->bssid, ETH_ALEN);
+               memcpy(&header.addr2, &src, ETH_ALEN);
+               memcpy(&header.addr3, &dest, ETH_ALEN);
+       } else if (ieee->iw_mode == IW_MODE_ADHOC) {
+               /* not From/To DS: Addr1 = DA, Addr2 = SA,
+                  Addr3 = BSSID */
+               memcpy(&header.addr1, dest, ETH_ALEN);
+               memcpy(&header.addr2, src, ETH_ALEN);
+               memcpy(&header.addr3, ieee->bssid, ETH_ALEN);
+       }
+       header.frame_ctl = cpu_to_le16(fc);
+       hdr_len = IEEE80211_3ADDR_LEN;
+
+       /* Determine fragmentation size based on destination (multicast
+        * and broadcast are not fragmented) */
+       if (is_multicast_ether_addr(dest) ||
+           is_broadcast_ether_addr(dest))
+               frag_size = MAX_FRAG_THRESHOLD;
+       else
+               frag_size = ieee->fts;
+
+       /* Determine amount of payload per fragment.  Regardless of if
+        * this stack is providing the full 802.11 header, one will
+        * eventually be affixed to this fragment -- so we must account for
+        * it when determining the amount of payload space. */
+       bytes_per_frag = frag_size - IEEE80211_3ADDR_LEN;
+       if (ieee->config &
+           (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
+               bytes_per_frag -= IEEE80211_FCS_LEN;
+
+       /* Each fragment may need to have room for encryptiong pre/postfix */
+       if (encrypt)
+               bytes_per_frag -= crypt->ops->extra_prefix_len +
+                       crypt->ops->extra_postfix_len;
+
+       /* Number of fragments is the total bytes_per_frag /
+        * payload_per_fragment */
+       nr_frags = bytes / bytes_per_frag;
+       bytes_last_frag = bytes % bytes_per_frag;
+       if (bytes_last_frag)
+               nr_frags++;
+       else
+               bytes_last_frag = bytes_per_frag;
+
+       /* When we allocate the TXB we allocate enough space for the reserve
+        * and full fragment bytes (bytes_per_frag doesn't include prefix,
+        * postfix, header, FCS, etc.) */
+       txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC);
+       if (unlikely(!txb)) {
+               printk(KERN_WARNING "%s: Could not allocate TXB\n",
+                      ieee->dev->name);
+               goto failed;
+       }
+       txb->encrypted = encrypt;
+       txb->payload_size = bytes;
+
+       for (i = 0; i < nr_frags; i++) {
+               skb_frag = txb->fragments[i];
+
+               if (encrypt)
+                       skb_reserve(skb_frag, crypt->ops->extra_prefix_len);
+
+               frag_hdr = (struct ieee80211_hdr *)skb_put(skb_frag, hdr_len);
+               memcpy(frag_hdr, &header, hdr_len);
+
+               /* If this is not the last fragment, then add the MOREFRAGS
+                * bit to the frame control */
+               if (i != nr_frags - 1) {
+                       frag_hdr->frame_ctl = cpu_to_le16(
+                               fc | IEEE80211_FCTL_MOREFRAGS);
+                       bytes = bytes_per_frag;
+               } else {
+                       /* The last fragment takes the remaining length */
+                       bytes = bytes_last_frag;
+               }
+
+               /* Put a SNAP header on the first fragment */
+               if (i == 0) {
+                       ieee80211_put_snap(
+                               skb_put(skb_frag, SNAP_SIZE + sizeof(u16)),
+                               ether_type);
+                       bytes -= SNAP_SIZE + sizeof(u16);
+               }
+
+               memcpy(skb_put(skb_frag, bytes), skb->data, bytes);
+
+               /* Advance the SKB... */
+               skb_pull(skb, bytes);
+
+               /* Encryption routine will move the header forward in order
+                * to insert the IV between the header and the payload */
+               if (encrypt)
+                       ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len);
+               if (ieee->config &
+                   (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
+                       skb_put(skb_frag, 4);
+       }
+
+
+ success:
+       spin_unlock_irqrestore(&ieee->lock, flags);
+
+       dev_kfree_skb_any(skb);
+
+       if (txb) {
+               if ((*ieee->hard_start_xmit)(txb, dev) == 0) {
+                       stats->tx_packets++;
+                       stats->tx_bytes += txb->payload_size;
+                       return 0;
+               }
+               ieee80211_txb_free(txb);
+       }
+
+       return 0;
+
+ failed:
+       spin_unlock_irqrestore(&ieee->lock, flags);
+       netif_stop_queue(dev);
+       stats->tx_errors++;
+       return 1;
+
+}
+
+EXPORT_SYMBOL(ieee80211_txb_free);
diff --git a/net/ieee80211/ieee80211_wx.c b/net/ieee80211/ieee80211_wx.c
new file mode 100644 (file)
index 0000000..2cd571c
--- /dev/null
@@ -0,0 +1,471 @@
+/******************************************************************************
+
+  Copyright(c) 2004 Intel Corporation. All rights reserved.
+
+  Portions of this file are based on the WEP enablement code provided by the
+  Host AP project hostap-drivers v0.1.3
+  Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
+  <jkmaline@cc.hut.fi>
+  Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms of version 2 of the GNU General Public License as
+  published by the Free Software Foundation.
+
+  This program is distributed in the hope that it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc., 59
+  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+  The full GNU General Public License is included in this distribution in the
+  file called LICENSE.
+
+  Contact Information:
+  James P. Ketrenos <ipw2100-admin@linux.intel.com>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+******************************************************************************/
+#include <linux/wireless.h>
+#include <linux/version.h>
+#include <linux/kmod.h>
+#include <linux/module.h>
+
+#include <net/ieee80211.h>
+static const char *ieee80211_modes[] = {
+       "?", "a", "b", "ab", "g", "ag", "bg", "abg"
+};
+
+#define MAX_CUSTOM_LEN 64
+static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee,
+                                          char *start, char *stop,
+                                          struct ieee80211_network *network)
+{
+       char custom[MAX_CUSTOM_LEN];
+       char *p;
+       struct iw_event iwe;
+       int i, j;
+       u8 max_rate, rate;
+
+       /* First entry *MUST* be the AP MAC address */
+       iwe.cmd = SIOCGIWAP;
+       iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
+       memcpy(iwe.u.ap_addr.sa_data, network->bssid, ETH_ALEN);
+       start = iwe_stream_add_event(start, stop, &iwe, IW_EV_ADDR_LEN);
+
+       /* Remaining entries will be displayed in the order we provide them */
+
+       /* Add the ESSID */
+       iwe.cmd = SIOCGIWESSID;
+       iwe.u.data.flags = 1;
+       if (network->flags & NETWORK_EMPTY_ESSID) {
+               iwe.u.data.length = sizeof("<hidden>");
+               start = iwe_stream_add_point(start, stop, &iwe, "<hidden>");
+       } else {
+               iwe.u.data.length = min(network->ssid_len, (u8)32);
+               start = iwe_stream_add_point(start, stop, &iwe, network->ssid);
+       }
+
+       /* Add the protocol name */
+       iwe.cmd = SIOCGIWNAME;
+       snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11%s", ieee80211_modes[network->mode]);
+       start = iwe_stream_add_event(start, stop, &iwe, IW_EV_CHAR_LEN);
+
+        /* Add mode */
+        iwe.cmd = SIOCGIWMODE;
+        if (network->capability &
+           (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) {
+               if (network->capability & WLAN_CAPABILITY_ESS)
+                       iwe.u.mode = IW_MODE_MASTER;
+               else
+                       iwe.u.mode = IW_MODE_ADHOC;
+
+               start = iwe_stream_add_event(start, stop, &iwe,
+                                            IW_EV_UINT_LEN);
+       }
+
+        /* Add frequency/channel */
+       iwe.cmd = SIOCGIWFREQ;
+/*     iwe.u.freq.m = ieee80211_frequency(network->channel, network->mode);
+       iwe.u.freq.e = 3; */
+       iwe.u.freq.m = network->channel;
+       iwe.u.freq.e = 0;
+       iwe.u.freq.i = 0;
+       start = iwe_stream_add_event(start, stop, &iwe, IW_EV_FREQ_LEN);
+
+       /* Add encryption capability */
+       iwe.cmd = SIOCGIWENCODE;
+       if (network->capability & WLAN_CAPABILITY_PRIVACY)
+               iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
+       else
+               iwe.u.data.flags = IW_ENCODE_DISABLED;
+       iwe.u.data.length = 0;
+       start = iwe_stream_add_point(start, stop, &iwe, network->ssid);
+
+       /* Add basic and extended rates */
+       max_rate = 0;
+       p = custom;
+       p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): ");
+       for (i = 0, j = 0; i < network->rates_len; ) {
+               if (j < network->rates_ex_len &&
+                   ((network->rates_ex[j] & 0x7F) <
+                    (network->rates[i] & 0x7F)))
+                       rate = network->rates_ex[j++] & 0x7F;
+               else
+                       rate = network->rates[i++] & 0x7F;
+               if (rate > max_rate)
+                       max_rate = rate;
+               p += snprintf(p, MAX_CUSTOM_LEN - (p - custom),
+                             "%d%s ", rate >> 1, (rate & 1) ? ".5" : "");
+       }
+       for (; j < network->rates_ex_len; j++) {
+               rate = network->rates_ex[j] & 0x7F;
+               p += snprintf(p, MAX_CUSTOM_LEN - (p - custom),
+                             "%d%s ", rate >> 1, (rate & 1) ? ".5" : "");
+               if (rate > max_rate)
+                       max_rate = rate;
+       }
+
+       iwe.cmd = SIOCGIWRATE;
+       iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
+       iwe.u.bitrate.value = max_rate * 500000;
+       start = iwe_stream_add_event(start, stop, &iwe,
+                                    IW_EV_PARAM_LEN);
+
+       iwe.cmd = IWEVCUSTOM;
+       iwe.u.data.length = p - custom;
+       if (iwe.u.data.length)
+               start = iwe_stream_add_point(start, stop, &iwe, custom);
+
+       /* Add quality statistics */
+       /* TODO: Fix these values... */
+       iwe.cmd = IWEVQUAL;
+       iwe.u.qual.qual = network->stats.signal;
+       iwe.u.qual.level = network->stats.rssi;
+       iwe.u.qual.noise = network->stats.noise;
+       iwe.u.qual.updated = network->stats.mask & IEEE80211_STATMASK_WEMASK;
+       if (!(network->stats.mask & IEEE80211_STATMASK_RSSI))
+               iwe.u.qual.updated |= IW_QUAL_LEVEL_INVALID;
+       if (!(network->stats.mask & IEEE80211_STATMASK_NOISE))
+               iwe.u.qual.updated |= IW_QUAL_NOISE_INVALID;
+       if (!(network->stats.mask & IEEE80211_STATMASK_SIGNAL))
+               iwe.u.qual.updated |= IW_QUAL_QUAL_INVALID;
+
+       start = iwe_stream_add_event(start, stop, &iwe, IW_EV_QUAL_LEN);
+
+       iwe.cmd = IWEVCUSTOM;
+       p = custom;
+
+       iwe.u.data.length = p - custom;
+       if (iwe.u.data.length)
+               start = iwe_stream_add_point(start, stop, &iwe, custom);
+
+       if (ieee->wpa_enabled && network->wpa_ie_len){
+               char buf[MAX_WPA_IE_LEN * 2 + 30];
+
+               u8 *p = buf;
+               p += sprintf(p, "wpa_ie=");
+               for (i = 0; i < network->wpa_ie_len; i++) {
+                       p += sprintf(p, "%02x", network->wpa_ie[i]);
+               }
+
+               memset(&iwe, 0, sizeof(iwe));
+               iwe.cmd = IWEVCUSTOM;
+               iwe.u.data.length = strlen(buf);
+               start = iwe_stream_add_point(start, stop, &iwe, buf);
+       }
+
+       if (ieee->wpa_enabled && network->rsn_ie_len){
+               char buf[MAX_WPA_IE_LEN * 2 + 30];
+
+               u8 *p = buf;
+               p += sprintf(p, "rsn_ie=");
+               for (i = 0; i < network->rsn_ie_len; i++) {
+                       p += sprintf(p, "%02x", network->rsn_ie[i]);
+               }
+
+               memset(&iwe, 0, sizeof(iwe));
+               iwe.cmd = IWEVCUSTOM;
+               iwe.u.data.length = strlen(buf);
+               start = iwe_stream_add_point(start, stop, &iwe, buf);
+       }
+
+       /* Add EXTRA: Age to display seconds since last beacon/probe response
+        * for given network. */
+       iwe.cmd = IWEVCUSTOM;
+       p = custom;
+       p += snprintf(p, MAX_CUSTOM_LEN - (p - custom),
+                     " Last beacon: %lums ago", (jiffies - network->last_scanned) / (HZ / 100));
+       iwe.u.data.length = p - custom;
+       if (iwe.u.data.length)
+               start = iwe_stream_add_point(start, stop, &iwe, custom);
+
+
+       return start;
+}
+
+int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
+                         struct iw_request_info *info,
+                         union iwreq_data *wrqu, char *extra)
+{
+       struct ieee80211_network *network;
+       unsigned long flags;
+
+       char *ev = extra;
+       char *stop = ev + IW_SCAN_MAX_DATA;
+       int i = 0;
+
+       IEEE80211_DEBUG_WX("Getting scan\n");
+
+       spin_lock_irqsave(&ieee->lock, flags);
+
+       list_for_each_entry(network, &ieee->network_list, list) {
+               i++;
+               if (ieee->scan_age == 0 ||
+                   time_after(network->last_scanned + ieee->scan_age, jiffies))
+                       ev = ipw2100_translate_scan(ieee, ev, stop, network);
+               else
+                       IEEE80211_DEBUG_SCAN(
+                               "Not showing network '%s ("
+                               MAC_FMT ")' due to age (%lums).\n",
+                               escape_essid(network->ssid,
+                                            network->ssid_len),
+                               MAC_ARG(network->bssid),
+                               (jiffies - network->last_scanned) / (HZ / 100));
+       }
+
+       spin_unlock_irqrestore(&ieee->lock, flags);
+
+       wrqu->data.length = ev -  extra;
+       wrqu->data.flags = 0;
+
+       IEEE80211_DEBUG_WX("exit: %d networks returned.\n", i);
+
+       return 0;
+}
+
+int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
+                           struct iw_request_info *info,
+                           union iwreq_data *wrqu, char *keybuf)
+{
+       struct iw_point *erq = &(wrqu->encoding);
+       struct net_device *dev = ieee->dev;
+       struct ieee80211_security sec = {
+               .flags = 0
+       };
+       int i, key, key_provided, len;
+       struct ieee80211_crypt_data **crypt;
+
+       IEEE80211_DEBUG_WX("SET_ENCODE\n");
+
+       key = erq->flags & IW_ENCODE_INDEX;
+       if (key) {
+               if (key > WEP_KEYS)
+                       return -EINVAL;
+               key--;
+               key_provided = 1;
+       } else {
+               key_provided = 0;
+               key = ieee->tx_keyidx;
+       }
+
+       IEEE80211_DEBUG_WX("Key: %d [%s]\n", key, key_provided ?
+                          "provided" : "default");
+
+       crypt = &ieee->crypt[key];
+
+       if (erq->flags & IW_ENCODE_DISABLED) {
+               if (key_provided && *crypt) {
+                       IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n",
+                                          key);
+                       ieee80211_crypt_delayed_deinit(ieee, crypt);
+               } else
+                       IEEE80211_DEBUG_WX("Disabling encryption.\n");
+
+               /* Check all the keys to see if any are still configured,
+                * and if no key index was provided, de-init them all */
+               for (i = 0; i < WEP_KEYS; i++) {
+                       if (ieee->crypt[i] != NULL) {
+                               if (key_provided)
+                                       break;
+                               ieee80211_crypt_delayed_deinit(
+                                       ieee, &ieee->crypt[i]);
+                       }
+               }
+
+               if (i == WEP_KEYS) {
+                       sec.enabled = 0;
+                       sec.level = SEC_LEVEL_0;
+                       sec.flags |= SEC_ENABLED | SEC_LEVEL;
+               }
+
+               goto done;
+       }
+
+
+
+       sec.enabled = 1;
+       sec.flags |= SEC_ENABLED;
+
+       if (*crypt != NULL && (*crypt)->ops != NULL &&
+           strcmp((*crypt)->ops->name, "WEP") != 0) {
+               /* changing to use WEP; deinit previously used algorithm
+                * on this key */
+               ieee80211_crypt_delayed_deinit(ieee, crypt);
+       }
+
+       if (*crypt == NULL) {
+               struct ieee80211_crypt_data *new_crypt;
+
+               /* take WEP into use */
+               new_crypt = kmalloc(sizeof(struct ieee80211_crypt_data),
+                                   GFP_KERNEL);
+               if (new_crypt == NULL)
+                       return -ENOMEM;
+               memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
+               new_crypt->ops = ieee80211_get_crypto_ops("WEP");
+               if (!new_crypt->ops) {
+                       request_module("ieee80211_crypt_wep");
+                       new_crypt->ops = ieee80211_get_crypto_ops("WEP");
+               }
+
+               if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
+                       new_crypt->priv = new_crypt->ops->init(key);
+
+               if (!new_crypt->ops || !new_crypt->priv) {
+                       kfree(new_crypt);
+                       new_crypt = NULL;
+
+                       printk(KERN_WARNING "%s: could not initialize WEP: "
+                              "load module ieee80211_crypt_wep\n",
+                              dev->name);
+                       return -EOPNOTSUPP;
+               }
+               *crypt = new_crypt;
+       }
+
+       /* If a new key was provided, set it up */
+       if (erq->length > 0) {
+               len = erq->length <= 5 ? 5 : 13;
+               memcpy(sec.keys[key], keybuf, erq->length);
+               if (len > erq->length)
+                       memset(sec.keys[key] + erq->length, 0,
+                              len - erq->length);
+               IEEE80211_DEBUG_WX("Setting key %d to '%s' (%d:%d bytes)\n",
+                                  key, escape_essid(sec.keys[key], len),
+                                  erq->length, len);
+               sec.key_sizes[key] = len;
+               (*crypt)->ops->set_key(sec.keys[key], len, NULL,
+                                      (*crypt)->priv);
+               sec.flags |= (1 << key);
+               /* This ensures a key will be activated if no key is
+                * explicitely set */
+               if (key == sec.active_key)
+                       sec.flags |= SEC_ACTIVE_KEY;
+       } else {
+               len = (*crypt)->ops->get_key(sec.keys[key], WEP_KEY_LEN,
+                                            NULL, (*crypt)->priv);
+               if (len == 0) {
+                       /* Set a default key of all 0 */
+                       IEEE80211_DEBUG_WX("Setting key %d to all zero.\n",
+                                          key);
+                       memset(sec.keys[key], 0, 13);
+                       (*crypt)->ops->set_key(sec.keys[key], 13, NULL,
+                                              (*crypt)->priv);
+                       sec.key_sizes[key] = 13;
+                       sec.flags |= (1 << key);
+               }
+
+               /* No key data - just set the default TX key index */
+               if (key_provided) {
+                       IEEE80211_DEBUG_WX(
+                               "Setting key %d to default Tx key.\n", key);
+                       ieee->tx_keyidx = key;
+                       sec.active_key = key;
+                       sec.flags |= SEC_ACTIVE_KEY;
+               }
+       }
+
+ done:
+       ieee->open_wep = !(erq->flags & IW_ENCODE_RESTRICTED);
+       sec.auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY;
+       sec.flags |= SEC_AUTH_MODE;
+       IEEE80211_DEBUG_WX("Auth: %s\n", sec.auth_mode == WLAN_AUTH_OPEN ?
+                          "OPEN" : "SHARED KEY");
+
+       /* For now we just support WEP, so only set that security level...
+        * TODO: When WPA is added this is one place that needs to change */
+       sec.flags |= SEC_LEVEL;
+       sec.level = SEC_LEVEL_1; /* 40 and 104 bit WEP */
+
+       if (ieee->set_security)
+               ieee->set_security(dev, &sec);
+
+       /* Do not reset port if card is in Managed mode since resetting will
+        * generate new IEEE 802.11 authentication which may end up in looping
+        * with IEEE 802.1X.  If your hardware requires a reset after WEP
+        * configuration (for example... Prism2), implement the reset_port in
+        * the callbacks structures used to initialize the 802.11 stack. */
+       if (ieee->reset_on_keychange &&
+           ieee->iw_mode != IW_MODE_INFRA &&
+           ieee->reset_port && ieee->reset_port(dev)) {
+               printk(KERN_DEBUG "%s: reset_port failed\n", dev->name);
+               return -EINVAL;
+       }
+       return 0;
+}
+
+int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
+                           struct iw_request_info *info,
+                           union iwreq_data *wrqu, char *keybuf)
+{
+       struct iw_point *erq = &(wrqu->encoding);
+       int len, key;
+       struct ieee80211_crypt_data *crypt;
+
+       IEEE80211_DEBUG_WX("GET_ENCODE\n");
+
+       key = erq->flags & IW_ENCODE_INDEX;
+       if (key) {
+               if (key > WEP_KEYS)
+                       return -EINVAL;
+               key--;
+       } else
+               key = ieee->tx_keyidx;
+
+       crypt = ieee->crypt[key];
+       erq->flags = key + 1;
+
+       if (crypt == NULL || crypt->ops == NULL) {
+               erq->length = 0;
+               erq->flags |= IW_ENCODE_DISABLED;
+               return 0;
+       }
+
+       if (strcmp(crypt->ops->name, "WEP") != 0) {
+               /* only WEP is supported with wireless extensions, so just
+                * report that encryption is used */
+               erq->length = 0;
+               erq->flags |= IW_ENCODE_ENABLED;
+               return 0;
+       }
+
+       len = crypt->ops->get_key(keybuf, WEP_KEY_LEN, NULL, crypt->priv);
+       erq->length = (len >= 0 ? len : 0);
+
+       erq->flags |= IW_ENCODE_ENABLED;
+
+       if (ieee->open_wep)
+               erq->flags |= IW_ENCODE_OPEN;
+       else
+               erq->flags |= IW_ENCODE_RESTRICTED;
+
+       return 0;
+}
+
+EXPORT_SYMBOL(ieee80211_wx_get_scan);
+EXPORT_SYMBOL(ieee80211_wx_set_encode);
+EXPORT_SYMBOL(ieee80211_wx_get_encode);
index 514c85b2631a3332187141c2afdd7ed7825314cb..035ad2c9e1bad3cdc9fd1382004bfcca2da966eb 100644 (file)
@@ -263,10 +263,8 @@ static int ah_init_state(struct xfrm_state *x)
 
 error:
        if (ahp) {
-               if (ahp->work_icv)
-                       kfree(ahp->work_icv);
-               if (ahp->tfm)
-                       crypto_free_tfm(ahp->tfm);
+               kfree(ahp->work_icv);
+               crypto_free_tfm(ahp->tfm);
                kfree(ahp);
        }
        return -EINVAL;
@@ -279,14 +277,10 @@ static void ah_destroy(struct xfrm_state *x)
        if (!ahp)
                return;
 
-       if (ahp->work_icv) {
-               kfree(ahp->work_icv);
-               ahp->work_icv = NULL;
-       }
-       if (ahp->tfm) {
-               crypto_free_tfm(ahp->tfm);
-               ahp->tfm = NULL;
-       }
+       kfree(ahp->work_icv);
+       ahp->work_icv = NULL;
+       crypto_free_tfm(ahp->tfm);
+       ahp->tfm = NULL;
        kfree(ahp);
 }
 
index b31ffc5053d2efd36c5e4e149c644d1e6c9f1235..1b5a09d1b90b77ca26b03210e974746f7b316218 100644 (file)
@@ -343,22 +343,14 @@ static void esp_destroy(struct xfrm_state *x)
        if (!esp)
                return;
 
-       if (esp->conf.tfm) {
-               crypto_free_tfm(esp->conf.tfm);
-               esp->conf.tfm = NULL;
-       }
-       if (esp->conf.ivec) {
-               kfree(esp->conf.ivec);
-               esp->conf.ivec = NULL;
-       }
-       if (esp->auth.tfm) {
-               crypto_free_tfm(esp->auth.tfm);
-               esp->auth.tfm = NULL;
-       }
-       if (esp->auth.work_icv) {
-               kfree(esp->auth.work_icv);
-               esp->auth.work_icv = NULL;
-       }
+       crypto_free_tfm(esp->conf.tfm);
+       esp->conf.tfm = NULL;
+       kfree(esp->conf.ivec);
+       esp->conf.ivec = NULL;
+       crypto_free_tfm(esp->auth.tfm);
+       esp->auth.tfm = NULL;
+       kfree(esp->auth.work_icv);
+       esp->auth.work_icv = NULL;
        kfree(esp);
 }
 
index dcb7ee6c4858c4395444b7cb83c9f29a73823091..fc718df17b40d9b1a0719d39798331cf30a2fca3 100644 (file)
@@ -345,8 +345,7 @@ static void ipcomp_free_tfms(struct crypto_tfm **tfms)
 
        for_each_cpu(cpu) {
                struct crypto_tfm *tfm = *per_cpu_ptr(tfms, cpu);
-               if (tfm)
-                       crypto_free_tfm(tfm);
+               crypto_free_tfm(tfm);
        }
        free_percpu(tfms);
 }
index 63e106605f289a1503e63105f68ad8520e8bc36a..953129d392d21cc97f551f93c519b491cb0190cc 100644 (file)
@@ -54,6 +54,7 @@
 #include <linux/major.h>
 #include <linux/root_dev.h>
 #include <linux/delay.h>
+#include <linux/nfs_fs.h>
 #include <net/arp.h>
 #include <net/ip.h>
 #include <net/ipconfig.h>
index 2d05cafec22120ecae24351e31f4a5f17431433a..7d38913754b1a5ca44771248d4f7548f19ad9921 100644 (file)
@@ -144,7 +144,7 @@ clusterip_config_init(struct ipt_clusterip_tgt_info *i, u_int32_t ip,
        memcpy(&c->clustermac, &i->clustermac, ETH_ALEN);
        c->num_total_nodes = i->num_total_nodes;
        c->num_local_nodes = i->num_local_nodes;
-       memcpy(&c->local_nodes, &i->local_nodes, sizeof(&c->local_nodes));
+       memcpy(&c->local_nodes, &i->local_nodes, sizeof(c->local_nodes));
        c->hash_mode = i->hash_mode;
        c->hash_initval = i->hash_initval;
        atomic_set(&c->refcount, 1);
index 02fdda68718d0c98d60d1d8de42fc87689e9991c..f3f0013a95804808d1522e89192b0beaefa91a30 100644 (file)
@@ -552,8 +552,7 @@ new_segment:
                        tcp_mark_push(tp, skb);
                        goto new_segment;
                }
-               if (sk->sk_forward_alloc < copy &&
-                   !sk_stream_mem_schedule(sk, copy, 0))
+               if (!sk_stream_wmem_schedule(sk, copy))
                        goto wait_for_memory;
                
                if (can_coalesce) {
@@ -770,19 +769,23 @@ new_segment:
                                        if (off == PAGE_SIZE) {
                                                put_page(page);
                                                TCP_PAGE(sk) = page = NULL;
+                                               off = 0;
                                        }
-                               }
+                               } else
+                                       off = 0;
+
+                               if (copy > PAGE_SIZE - off)
+                                       copy = PAGE_SIZE - off;
+
+                               if (!sk_stream_wmem_schedule(sk, copy))
+                                       goto wait_for_memory;
 
                                if (!page) {
                                        /* Allocate new cache page. */
                                        if (!(page = sk_stream_alloc_page(sk)))
                                                goto wait_for_memory;
-                                       off = 0;
                                }
 
-                               if (copy > PAGE_SIZE - off)
-                                       copy = PAGE_SIZE - off;
-
                                /* Time to copy data. We are close to
                                 * the end! */
                                err = skb_copy_to_page(sk, from, skb, page,
index 1afb080bdf0cca2956808c26830aaa0b006af0ac..29222b964951ce4d2d505a3d3d9bed0ca762e025 100644 (file)
@@ -923,14 +923,6 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
        int flag = 0;
        int i;
 
-       /* So, SACKs for already sent large segments will be lost.
-        * Not good, but alternative is to resegment the queue. */
-       if (sk->sk_route_caps & NETIF_F_TSO) {
-               sk->sk_route_caps &= ~NETIF_F_TSO;
-               sock_set_flag(sk, SOCK_NO_LARGESEND);
-               tp->mss_cache = tp->mss_cache;
-       }
-
        if (!tp->sacked_out)
                tp->fackets_out = 0;
        prior_fackets = tp->fackets_out;
@@ -978,20 +970,40 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
                        flag |= FLAG_DATA_LOST;
 
                sk_stream_for_retrans_queue(skb, sk) {
-                       u8 sacked = TCP_SKB_CB(skb)->sacked;
-                       int in_sack;
+                       int in_sack, pcount;
+                       u8 sacked;
 
                        /* The retransmission queue is always in order, so
                         * we can short-circuit the walk early.
                         */
-                       if(!before(TCP_SKB_CB(skb)->seq, end_seq))
+                       if (!before(TCP_SKB_CB(skb)->seq, end_seq))
                                break;
 
-                       fack_count += tcp_skb_pcount(skb);
+                       pcount = tcp_skb_pcount(skb);
+
+                       if (pcount > 1 &&
+                           (after(start_seq, TCP_SKB_CB(skb)->seq) ||
+                            before(end_seq, TCP_SKB_CB(skb)->end_seq))) {
+                               unsigned int pkt_len;
+
+                               if (after(start_seq, TCP_SKB_CB(skb)->seq))
+                                       pkt_len = (start_seq -
+                                                  TCP_SKB_CB(skb)->seq);
+                               else
+                                       pkt_len = (end_seq -
+                                                  TCP_SKB_CB(skb)->seq);
+                               if (tcp_fragment(sk, skb, pkt_len, skb_shinfo(skb)->tso_size))
+                                       break;
+                               pcount = tcp_skb_pcount(skb);
+                       }
+
+                       fack_count += pcount;
 
                        in_sack = !after(start_seq, TCP_SKB_CB(skb)->seq) &&
                                !before(end_seq, TCP_SKB_CB(skb)->end_seq);
 
+                       sacked = TCP_SKB_CB(skb)->sacked;
+
                        /* Account D-SACK for retransmitted packet. */
                        if ((dup_sack && in_sack) &&
                            (sacked & TCPCB_RETRANS) &&
index 75b68116682ae2912ca8e0dd4faf84eb4993e6bd..6094db5e11be798631ff7699396f551314374ee2 100644 (file)
@@ -428,11 +428,11 @@ static void tcp_set_skb_tso_segs(struct sock *sk, struct sk_buff *skb, unsigned
  * packet to the list.  This won't be called frequently, I hope. 
  * Remember, these are still headerless SKBs at this point.
  */
-static int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss_now)
+int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss_now)
 {
        struct tcp_sock *tp = tcp_sk(sk);
        struct sk_buff *buff;
-       int nsize;
+       int nsize, old_factor;
        u16 flags;
 
        nsize = skb_headlen(skb) - len;
@@ -490,18 +490,29 @@ static int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned
                tp->left_out -= tcp_skb_pcount(skb);
        }
 
+       old_factor = tcp_skb_pcount(skb);
+
        /* Fix up tso_factor for both original and new SKB.  */
        tcp_set_skb_tso_segs(sk, skb, mss_now);
        tcp_set_skb_tso_segs(sk, buff, mss_now);
 
-       if (TCP_SKB_CB(skb)->sacked & TCPCB_LOST) {
-               tp->lost_out += tcp_skb_pcount(skb);
-               tp->left_out += tcp_skb_pcount(skb);
-       }
+       /* If this packet has been sent out already, we must
+        * adjust the various packet counters.
+        */
+       if (after(tp->snd_nxt, TCP_SKB_CB(buff)->end_seq)) {
+               int diff = old_factor - tcp_skb_pcount(skb) -
+                       tcp_skb_pcount(buff);
 
-       if (TCP_SKB_CB(buff)->sacked&TCPCB_LOST) {
-               tp->lost_out += tcp_skb_pcount(buff);
-               tp->left_out += tcp_skb_pcount(buff);
+               tp->packets_out -= diff;
+               if (TCP_SKB_CB(skb)->sacked & TCPCB_LOST) {
+                       tp->lost_out -= diff;
+                       tp->left_out -= diff;
+               }
+               if (diff > 0) {
+                       tp->fackets_out -= diff;
+                       if ((int)tp->fackets_out < 0)
+                               tp->fackets_out = 0;
+               }
        }
 
        /* Link BUFF into the send queue. */
@@ -1350,12 +1361,6 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
        if (before(TCP_SKB_CB(skb)->seq, tp->snd_una)) {
                if (before(TCP_SKB_CB(skb)->end_seq, tp->snd_una))
                        BUG();
-
-               if (sk->sk_route_caps & NETIF_F_TSO) {
-                       sk->sk_route_caps &= ~NETIF_F_TSO;
-                       sock_set_flag(sk, SOCK_NO_LARGESEND);
-               }
-
                if (tcp_trim_head(sk, skb, tp->snd_una - TCP_SKB_CB(skb)->seq))
                        return -ENOMEM;
        }
@@ -1370,22 +1375,8 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
                return -EAGAIN;
 
        if (skb->len > cur_mss) {
-               int old_factor = tcp_skb_pcount(skb);
-               int diff;
-
                if (tcp_fragment(sk, skb, cur_mss, cur_mss))
                        return -ENOMEM; /* We'll try again later. */
-
-               /* New SKB created, account for it. */
-               diff = old_factor - tcp_skb_pcount(skb) -
-                      tcp_skb_pcount(skb->next);
-               tp->packets_out -= diff;
-
-               if (diff > 0) {
-                       tp->fackets_out -= diff;
-                       if ((int)tp->fackets_out < 0)
-                               tp->fackets_out = 0;
-               }
        }
 
        /* Collapse two adjacent packets if worthwhile and we can. */
@@ -1993,12 +1984,6 @@ int tcp_write_wakeup(struct sock *sk)
                                TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_PSH;
                                if (tcp_fragment(sk, skb, seg_size, mss))
                                        return -1;
-                               /* SWS override triggered forced fragmentation.
-                                * Disable TSO, the connection is too sick. */
-                               if (sk->sk_route_caps & NETIF_F_TSO) {
-                                       sock_set_flag(sk, SOCK_NO_LARGESEND);
-                                       sk->sk_route_caps &= ~NETIF_F_TSO;
-                               }
                        } else if (!tcp_skb_pcount(skb))
                                tcp_set_skb_tso_segs(sk, skb, mss);
 
index 937ad32db77c182f35f5e4b4c7cd0530e0750fb8..6d6fb74f3b5291bc2639b250f284905c048de30a 100644 (file)
@@ -3593,10 +3593,8 @@ void __exit addrconf_cleanup(void)
        rtnl_unlock();
 
 #ifdef CONFIG_IPV6_PRIVACY
-       if (likely(md5_tfm != NULL)) {
-               crypto_free_tfm(md5_tfm);
-               md5_tfm = NULL;
-       }
+       crypto_free_tfm(md5_tfm);
+       md5_tfm = NULL;
 #endif
 
 #ifdef CONFIG_PROC_FS
index 0ebfad907a039824deb6d9974fba131a4365034e..f3629730eb157950c9adc0caec507d1a28379e15 100644 (file)
@@ -401,10 +401,8 @@ static int ah6_init_state(struct xfrm_state *x)
 
 error:
        if (ahp) {
-               if (ahp->work_icv)
-                       kfree(ahp->work_icv);
-               if (ahp->tfm)
-                       crypto_free_tfm(ahp->tfm);
+               kfree(ahp->work_icv);
+               crypto_free_tfm(ahp->tfm);
                kfree(ahp);
        }
        return -EINVAL;
@@ -417,14 +415,10 @@ static void ah6_destroy(struct xfrm_state *x)
        if (!ahp)
                return;
 
-       if (ahp->work_icv) {
-               kfree(ahp->work_icv);
-               ahp->work_icv = NULL;
-       }
-       if (ahp->tfm) {
-               crypto_free_tfm(ahp->tfm);
-               ahp->tfm = NULL;
-       }
+       kfree(ahp->work_icv);
+       ahp->work_icv = NULL;
+       crypto_free_tfm(ahp->tfm);
+       ahp->tfm = NULL;
        kfree(ahp);
 }
 
index e8bff9d3d96c8bd6fcef20eae749964713bf6461..9b27460f0cc703412e3fb71bba690553cdf799da 100644 (file)
@@ -276,22 +276,14 @@ static void esp6_destroy(struct xfrm_state *x)
        if (!esp)
                return;
 
-       if (esp->conf.tfm) {
-               crypto_free_tfm(esp->conf.tfm);
-               esp->conf.tfm = NULL;
-       }
-       if (esp->conf.ivec) {
-               kfree(esp->conf.ivec);
-               esp->conf.ivec = NULL;
-       }
-       if (esp->auth.tfm) {
-               crypto_free_tfm(esp->auth.tfm);
-               esp->auth.tfm = NULL;
-       }
-       if (esp->auth.work_icv) {
-               kfree(esp->auth.work_icv);
-               esp->auth.work_icv = NULL;
-       }
+       crypto_free_tfm(esp->conf.tfm);
+       esp->conf.tfm = NULL;
+       kfree(esp->conf.ivec);
+       esp->conf.ivec = NULL;
+       crypto_free_tfm(esp->auth.tfm);
+       esp->auth.tfm = NULL;
+       kfree(esp->auth.work_icv);
+       esp->auth.work_icv = NULL;
        kfree(esp);
 }
 
index 5176fc655ea907084f814c17590eccccadfabdf4..fa8f1bb0aa52926d4fe1808cedb81a611fbf2885 100644 (file)
@@ -549,7 +549,7 @@ static void icmpv6_notify(struct sk_buff *skb, int type, int code, u32 info)
        read_lock(&raw_v6_lock);
        if ((sk = sk_head(&raw_v6_htable[hash])) != NULL) {
                while((sk = __raw_v6_lookup(sk, nexthdr, daddr, saddr,
-                                           skb->dev->ifindex))) {
+                                           IP6CB(skb)->iif))) {
                        rawv6_err(sk, skb, NULL, type, code, inner_offset, info);
                        sk = sk_next(sk);
                }
index 135383ef538f5a33573d745d17962237af3ae082..85bfbc69b2c3dc716618f6e528dfcb63658e96b5 100644 (file)
@@ -341,8 +341,7 @@ static void ipcomp6_free_tfms(struct crypto_tfm **tfms)
 
        for_each_cpu(cpu) {
                struct crypto_tfm *tfm = *per_cpu_ptr(tfms, cpu);
-               if (tfm)
-                       crypto_free_tfm(tfm);
+               crypto_free_tfm(tfm);
        }
        free_percpu(tfms);
 }
index 7a5863298f3f8efe49977a9a7d39edf5fba71442..ed3a76b30fd932db9153b0fd31ea405ff97cc15a 100644 (file)
@@ -166,7 +166,7 @@ int ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
        if (sk == NULL)
                goto out;
 
-       sk = __raw_v6_lookup(sk, nexthdr, daddr, saddr, skb->dev->ifindex);
+       sk = __raw_v6_lookup(sk, nexthdr, daddr, saddr, IP6CB(skb)->iif);
 
        while (sk) {
                delivered = 1;
@@ -178,7 +178,7 @@ int ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
                                rawv6_rcv(sk, clone);
                }
                sk = __raw_v6_lookup(sk_next(sk), nexthdr, daddr, saddr,
-                                    skb->dev->ifindex);
+                                    IP6CB(skb)->iif);
        }
 out:
        read_unlock(&raw_v6_lock);
index 343c5d4a1a1de4cdc09b80432b45dae6e6b01c9e..ca7d358dab523866d32f67813d6a13781adaff67 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/seq_file.h>
 
 #include <net/irda/irlan_common.h>
+#include <net/irda/irlan_filter.h>
 
 /*
  * Function irlan_filter_request (self, skb)
index df732d56cc577177b1b348b11158ea913c8c108e..ddfb5c502a90468fcc25651080708fd287bfdee5 100644 (file)
@@ -37,6 +37,7 @@
 #include <net/irda/parameters.h>
 #include <net/irda/qos.h>
 #include <net/irda/irlap.h>
+#include <net/irda/irlap_frame.h>
 
 /*
  * Maximum values of the baud rate we negociate with the other end.
index e089f17bb8032768dddb2fe8ffd400becd19fea4..49a3900e3d32b24d9ad91dc03340d62364d0ff25 100644 (file)
@@ -344,14 +344,14 @@ static void nfnetlink_rcv(struct sock *sk, int len)
        } while(nfnl && nfnl->sk_receive_queue.qlen);
 }
 
-void __exit nfnetlink_exit(void)
+static void __exit nfnetlink_exit(void)
 {
        printk("Removing netfilter NETLINK layer.\n");
        sock_release(nfnl->sk_socket);
        return;
 }
 
-int __init nfnetlink_init(void)
+static int __init nfnetlink_init(void)
 {
        printk("Netfilter messages via NETLINK v%s.\n", nfversion);
 
index e3a5285329af5535377f110c62aa004f4c07452a..249bddb28acd9057bccac1b89960ecc8994041b3 100644 (file)
@@ -76,17 +76,6 @@ typedef int (*nfqnl_cmpfn)(struct nfqnl_queue_entry *, unsigned long);
 
 static DEFINE_RWLOCK(instances_lock);
 
-u_int64_t htonll(u_int64_t in)
-{
-       u_int64_t out;
-       int i;
-
-       for (i = 0; i < sizeof(u_int64_t); i++)
-               ((u_int8_t *)&out)[sizeof(u_int64_t)-1] = ((u_int8_t *)&in)[i];
-
-       return out;
-}
-
 #define INSTANCE_BUCKETS       16
 static struct hlist_head instance_table[INSTANCE_BUCKETS];
 
@@ -497,8 +486,8 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
        if (entry->skb->tstamp.off_sec) {
                struct nfqnl_msg_packet_timestamp ts;
 
-               ts.sec = htonll(skb_tv_base.tv_sec + entry->skb->tstamp.off_sec);
-               ts.usec = htonll(skb_tv_base.tv_usec + entry->skb->tstamp.off_usec);
+               ts.sec = cpu_to_be64(skb_tv_base.tv_sec + entry->skb->tstamp.off_sec);
+               ts.usec = cpu_to_be64(skb_tv_base.tv_usec + entry->skb->tstamp.off_usec);
 
                NFA_PUT(skb, NFQA_TIMESTAMP, sizeof(ts), &ts);
        }
index e47ac0d1a6d64f679bf963113b1989d93e4d4c44..e22ccd6559658592179505b6572246ad9ee37fc1 100644 (file)
@@ -193,8 +193,7 @@ static void sctp_endpoint_destroy(struct sctp_endpoint *ep)
        sctp_unhash_endpoint(ep);
 
        /* Free up the HMAC transform. */
-       if (sctp_sk(ep->base.sk)->hmac)
-               sctp_crypto_free_tfm(sctp_sk(ep->base.sk)->hmac);
+       sctp_crypto_free_tfm(sctp_sk(ep->base.sk)->hmac);
 
        /* Cleanup. */
        sctp_inq_free(&ep->base.inqueue);
index 4454afe4727ef2bb95778a5a8193c8b74df6dcd9..91ec8c9369135ade53002ff4a5bdebc139e7a80a 100644 (file)
@@ -4194,8 +4194,7 @@ out:
        sctp_release_sock(sk);
        return err;
 cleanup:
-       if (tfm)
-               sctp_crypto_free_tfm(tfm);
+       sctp_crypto_free_tfm(tfm);
        goto out;
 }
 
index dc4893474f186e68b93225cdba82ba71000f9831..75b28dd634fe3e0c06b0a556716b7c4755b7c816 100644 (file)
@@ -42,6 +42,7 @@
  */
 
 #include <net/sctp/structs.h>
+#include <net/sctp/sctp.h>
 #include <linux/sysctl.h>
 
 static ctl_handler sctp_sysctl_jiffies_ms;
index 5a7265aeaf839c160ee047d9f319b0763fdefe82..ee6ae74cd1b226b2bb7d39655f2a1862e4507c21 100644 (file)
@@ -160,7 +160,7 @@ make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
                                " unsupported checksum %d", cksumtype);
                        goto out;
        }
-       if (!(tfm = crypto_alloc_tfm(cksumname, 0)))
+       if (!(tfm = crypto_alloc_tfm(cksumname, CRYPTO_TFM_REQ_MAY_SLEEP)))
                goto out;
        cksum->len = crypto_tfm_alg_digestsize(tfm);
        if ((cksum->data = kmalloc(cksum->len, GFP_KERNEL)) == NULL)
@@ -199,8 +199,7 @@ make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
        crypto_digest_final(tfm, cksum->data);
        code = 0;
 out:
-       if (tfm)
-               crypto_free_tfm(tfm);
+       crypto_free_tfm(tfm);
        return code;
 }
 
index cf726510df8e5ad2d6075b8547245f85666d59eb..606a8a82cafbedc84545ec73def5ff2e54054b5c 100644 (file)
@@ -185,12 +185,9 @@ static void
 gss_delete_sec_context_kerberos(void *internal_ctx) {
        struct krb5_ctx *kctx = internal_ctx;
 
-       if (kctx->seq)
-               crypto_free_tfm(kctx->seq);
-       if (kctx->enc)
-               crypto_free_tfm(kctx->enc);
-       if (kctx->mech_used.data)
-               kfree(kctx->mech_used.data);
+       crypto_free_tfm(kctx->seq);
+       crypto_free_tfm(kctx->enc);
+       kfree(kctx->mech_used.data);
        kfree(kctx);
 }
 
index dad05994c3eb3f934c5446460404a92101e3b7c8..6c97d61baa9bfa3a819fa079a132eb745babd081 100644 (file)
@@ -214,14 +214,10 @@ static void
 gss_delete_sec_context_spkm3(void *internal_ctx) {
        struct spkm3_ctx *sctx = internal_ctx;
 
-       if(sctx->derived_integ_key)
-               crypto_free_tfm(sctx->derived_integ_key);
-       if(sctx->derived_conf_key)
-               crypto_free_tfm(sctx->derived_conf_key);
-       if(sctx->share_key.data)
-               kfree(sctx->share_key.data);
-       if(sctx->mech_used.data)
-               kfree(sctx->mech_used.data);
+       crypto_free_tfm(sctx->derived_integ_key);
+       crypto_free_tfm(sctx->derived_conf_key);
+       kfree(sctx->share_key.data);
+       kfree(sctx->mech_used.data);
        kfree(sctx);
 }
 
index fe1a73ce6cffef7e639c1bebbc62e82fb010469d..ded6c63f11ec968263890ebded1f65ea31f1f674 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Userland/kernel interface for rpcauth_gss.
  * Code shamelessly plagiarized from fs/nfsd/nfsctl.c
- * and fs/driverfs/inode.c
+ * and fs/sysfs/inode.c
  *
  * Copyright (c) 2002, Trond Myklebust <trond.myklebust@fys.uio.no>
  *
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
new file mode 100644 (file)
index 0000000..9087273
--- /dev/null
@@ -0,0 +1,96 @@
+####
+# kbuild: Generic definitions
+
+# Convinient variables
+comma   := ,
+empty   :=
+space   := $(empty) $(empty)
+
+###
+# The temporary file to save gcc -MD generated dependencies must not
+# contain a comma
+depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
+
+###
+# filechk is used to check if the content of a generated file is updated.
+# Sample usage:
+# define filechk_sample
+#      echo $KERNELRELEASE
+# endef
+# version.h : Makefile
+#      $(call filechk,sample)
+# The rule defined shall write to stdout the content of the new file.
+# The existing file will be compared with the new one.
+# - If no file exist it is created
+# - If the content differ the new file is used
+# - If they are equal no change, and no timestamp update
+# - stdin is piped in from the first prerequisite ($<) so one has
+#   to specify a valid file as first prerequisite (often the kbuild file)
+define filechk
+       $(Q)set -e;                             \
+       echo '  CHK     $@';                    \
+       mkdir -p $(dir $@);                     \
+       $(filechk_$(1)) < $< > $@.tmp;          \
+       if [ -r $@ ] && cmp -s $@ $@.tmp; then  \
+               rm -f $@.tmp;                   \
+       else                                    \
+               echo '  UPD     $@';            \
+               mv -f $@.tmp $@;                \
+       fi
+endef
+
+###
+# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
+# Usage:
+# $(Q)$(MAKE) $(build)=dir
+build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
+
+# If quiet is set, only print short version of command
+cmd = @$(if $($(quiet)cmd_$(1)),\
+      echo '  $(subst ','\'',$($(quiet)cmd_$(1)))' &&) $(cmd_$(1))
+
+###
+# if_changed      - execute command if any prerequisite is newer than 
+#                   target, or command line has changed
+# if_changed_dep  - as if_changed, but uses fixdep to reveal dependencies
+#                   including used config symbols
+# if_changed_rule - as if_changed but execute rule instead
+# See Documentation/kbuild/makefiles.txt for more info
+
+ifneq ($(KBUILD_NOCMDDEP),1)
+# Check if both arguments has same arguments. Result in empty string if equal
+# User may override this check using make KBUILD_NOCMDDEP=1
+arg-check = $(strip $(filter-out $(1), $(2)) $(filter-out $(2), $(1)) )
+endif
+
+# echo command. Short version is $(quiet) equals quiet, otherwise full command
+echo-cmd = $(if $($(quiet)cmd_$(1)), \
+       echo '  $(subst ','\'',$($(quiet)cmd_$(1)))';)
+
+# function to only execute the passed command if necessary
+# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file
+# note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars
+# 
+if_changed = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
+       @set -e; \
+       $(echo-cmd) \
+       $(cmd_$(1)); \
+       echo 'cmd_$@ := $(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).cmd)
+
+# execute the command and also postprocess generated .d dependencies
+# file
+if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\
+       $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),                  \
+       @set -e; \
+       $(echo-cmd) \
+       $(cmd_$(1)); \
+       scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \
+       rm -f $(depfile); \
+       mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
+
+# Usage: $(call if_changed_rule,foo)
+# will check if $(cmd_foo) changed, or any of the prequisites changed,
+# and if so will execute $(rule_foo)
+if_changed_rule = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\
+                       @set -e; \
+                       $(rule_$(1)))
index 76ba6be3dfc9cd51888b57ef54c9aea8e8d19e81..506e3f3befe3104b35d2518fd42af7fb53048f67 100644 (file)
@@ -10,8 +10,11 @@ __build:
 # Read .config if it exist, otherwise ignore
 -include .config
 
-include $(if $(wildcard $(obj)/Kbuild), $(obj)/Kbuild, $(obj)/Makefile)
+# The filename Kbuild has precedence over Makefile
+kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
+include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)
 
+include scripts/Kbuild.include
 include scripts/Makefile.lib
 
 ifdef host-progs
@@ -169,7 +172,7 @@ cmd_modversions =                                                   \
                        -T $(@D)/.tmp_$(@F:.o=.ver);                    \
                rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver);        \
        else                                                            \
-               mv $(@D)/.tmp_$(@F) $@;                                 \
+               mv -f $(@D)/.tmp_$(@F) $@;                              \
        fi;
 endif
 
index ff3e87dbf387412448f8f1d1359120a997636234..8974ea5fc878896fac077f274af8a6c60c91568d 100644 (file)
@@ -7,7 +7,14 @@ src := $(obj)
 .PHONY: __clean
 __clean:
 
-include $(if $(wildcard $(obj)/Kbuild), $(obj)/Kbuild, $(obj)/Makefile)
+# Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir
+# Usage:
+# $(Q)$(MAKE) $(clean)=dir
+clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
+
+# The filename Kbuild has precedence over Makefile
+kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
+include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)
 
 # Figure out what we need to build from the various variables
 # ==========================================================================
@@ -87,8 +94,3 @@ $(subdir-ymn):
 # If quiet is set, only print short version of command
 
 cmd = @$(if $($(quiet)cmd_$(1)),echo '  $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
-
-# Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir
-# Usage:
-# $(Q)$(MAKE) $(clean)=dir
-clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
index 2821a2b83bbb3c73a8d8b1be91ade4f517e64e49..2d519704b8fd7993775bfc75cd40520631b06d39 100644 (file)
@@ -98,7 +98,8 @@ hostcxx_flags  = -Wp,-MD,$(depfile) $(__hostcxx_flags)
 # Create executable from a single .c file
 # host-csingle -> Executable
 quiet_cmd_host-csingle         = HOSTCC  $@
-      cmd_host-csingle = $(HOSTCC) $(hostc_flags) $(HOST_LOADLIBES) -o $@ $<
+      cmd_host-csingle = $(HOSTCC) $(hostc_flags) -o $@ $< \
+               $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
 $(host-csingle): %: %.c FORCE
        $(call if_changed_dep,host-csingle)
 
index 7cf75cc4f849dfe8a75a05a604809c2ec5a19bed..0f81dcfd6909aec0f873fdef797fec5fca75f44a 100644 (file)
@@ -1,13 +1,3 @@
-# ===========================================================================
-# kbuild: Generic definitions
-# ===========================================================================
-
-# Standard vars
-
-comma   := ,
-empty   :=
-space   := $(empty) $(empty)
-
 # Backward compatibility - to be removed...
 extra-y        += $(EXTRA_TARGETS)
 # Figure out what we need to build from the various variables
@@ -84,10 +74,6 @@ multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m))
 subdir-ym      := $(addprefix $(obj)/,$(subdir-ym))
 obj-dirs       := $(addprefix $(obj)/,$(obj-dirs))
 
-# The temporary file to save gcc -MD generated dependencies must not
-# contain a comma
-depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
-
 # These flags are needed for modversions and compiling, so we define them here
 # already
 # $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will 
@@ -179,89 +165,4 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
 quiet_cmd_gzip = GZIP    $@
 cmd_gzip = gzip -f -9 < $< > $@
 
-# ===========================================================================
-# Generic stuff
-# ===========================================================================
-
-ifneq ($(KBUILD_NOCMDDEP),1)
-# Check if both arguments has same arguments. Result in empty string if equal
-# User may override this check using make KBUILD_NOCMDDEP=1
-arg-check = $(strip $(filter-out $(1), $(2)) $(filter-out $(2), $(1)) )
-
-endif
-
-# echo command. Short version is $(quiet) equals quiet, otherwise full command
-echo-cmd = $(if $($(quiet)cmd_$(1)), \
-       echo '  $(subst ','\'',$($(quiet)cmd_$(1)))';)
-
-# function to only execute the passed command if necessary
-# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file
-# note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars
-# 
-if_changed = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
-       @set -e; \
-       $(echo-cmd) \
-       $(cmd_$(1)); \
-       echo 'cmd_$@ := $(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).cmd)
-
-
-# execute the command and also postprocess generated .d dependencies
-# file
-
-if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\
-       $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),                  \
-       @set -e; \
-       $(echo-cmd) \
-       $(cmd_$(1)); \
-       scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \
-       rm -f $(depfile); \
-       mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
-
-# Usage: $(call if_changed_rule,foo)
-# will check if $(cmd_foo) changed, or any of the prequisites changed,
-# and if so will execute $(rule_foo)
-
-if_changed_rule = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\
-                       @set -e; \
-                       $(rule_$(1)))
-
-# If quiet is set, only print short version of command
-
-cmd = @$(if $($(quiet)cmd_$(1)),echo '  $(subst ','\'',$($(quiet)cmd_$(1)))' &&) $(cmd_$(1))
-
-#      $(call descend,<dir>,<target>)
-#      Recursively call a sub-make in <dir> with target <target> 
-# Usage is deprecated, because make do not see this as an invocation of make.
-descend =$(Q)$(MAKE) -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj=$(1) $(2)
-
-# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
-# Usage:
-# $(Q)$(MAKE) $(build)=dir
-build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
-
-# filechk is used to check if the content of a generated file is updated.
-# Sample usage:
-# define filechk_sample
-#      echo $KERNELRELEASE
-# endef
-# version.h : Makefile
-#      $(call filechk,sample)
-# The rule defined shall write to stdout the content of the new file.
-# The existing file will be compared with the new one.
-# - If no file exist it is created
-# - If the content differ the new file is used
-# - If they are equal no change, and no timestamp update
-
-define filechk
-       $(Q)set -e;                             \
-       echo '  CHK     $@';                    \
-       mkdir -p $(dir $@);                     \
-       $(filechk_$(1)) $(2) > $@.tmp;          \
-       if [ -r $@ ] && cmp -s $@ $@.tmp; then  \
-               rm -f $@.tmp;                   \
-       else                                    \
-               echo '  UPD     $@';            \
-               mv -f $@.tmp $@;                \
-       fi
-endef
 
index 85d6494e3c24a3c8e3b3b603f7122e90cea3b83a..23fd1bdc25cebe7a3ddaa1a96c147f6121befc33 100644 (file)
@@ -5,7 +5,7 @@
 .PHONY: __modinst
 __modinst:
 
-include scripts/Makefile.lib
+include scripts/Kbuild.include
 
 #
 
index 94b550e21be8d8bc67a8ebf51b7c5621045aa4a3..0c4f3a9f2ea95e9d863c9063eefce6806cb11e60 100644 (file)
@@ -36,6 +36,7 @@
 _modpost: __modpost
 
 include .config
+include scripts/Kbuild.include
 include scripts/Makefile.lib
 
 symverfile := $(objtree)/Module.symvers
index 93dd23f21ec96b5736f205bdf38e6b1ad787c557..e0c6891a9ad4f5b35c7bb96b381a171f32887d99 100644 (file)
@@ -33,7 +33,7 @@ void usage(char *argv0)
 
 int getunicode(char **p0)
 {
-  unsigned char *p = *p0;
+  char *p = *p0;
 
   while (*p == ' ' || *p == '\t')
     p++;
index d3d2e5341051809b01d13b75b352ed3d41f01d5c..9be41a9f5aff77b319f388917fcd384d67361ed7 100644 (file)
@@ -207,9 +207,9 @@ symbol_valid(struct sym_entry *s)
                 * move then they may get dropped in pass 2, which breaks the
                 * kallsyms rules.
                 */
-               if ((s->addr == _etext && strcmp(s->sym + offset, "_etext")) ||
-                   (s->addr == _einittext && strcmp(s->sym + offset, "_einittext")) ||
-                   (s->addr == _eextratext && strcmp(s->sym + offset, "_eextratext")))
+               if ((s->addr == _etext && strcmp((char*)s->sym + offset, "_etext")) ||
+                   (s->addr == _einittext && strcmp((char*)s->sym + offset, "_einittext")) ||
+                   (s->addr == _eextratext && strcmp((char*)s->sym + offset, "_eextratext")))
                        return 0;
        }
 
index 09abb891d11f2eb5741b41a66307a13fe2d8a203..2fcb244a9e180abe89d5783f189d3b09a18bc2a7 100644 (file)
@@ -27,8 +27,20 @@ update-po-config: $(obj)/kxgettext
        xgettext --default-domain=linux \
           --add-comments --keyword=_ --keyword=N_ \
           --files-from=scripts/kconfig/POTFILES.in \
-       -o scripts/kconfig/linux.pot
-       scripts/kconfig/kxgettext arch/$(ARCH)/Kconfig >> scripts/kconfig/linux.pot
+          --output scripts/kconfig/config.pot
+       $(Q)ln -fs Kconfig_i386 arch/um/Kconfig_arch
+       $(Q)for i in `ls arch/`; \
+       do \
+         scripts/kconfig/kxgettext arch/$$i/Kconfig \
+           | msguniq -o scripts/kconfig/linux_$${i}.pot; \
+       done
+       $(Q)msgcat scripts/kconfig/config.pot \
+         `find scripts/kconfig/ -type f -name linux_*.pot` \
+         --output scripts/kconfig/linux_raw.pot
+       $(Q)msguniq --sort-by-file scripts/kconfig/linux_raw.pot \
+           --output scripts/kconfig/linux.pot
+       $(Q)rm -f arch/um/Kconfig_arch
+       $(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot
 
 .PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig
 
index 1c88d7c6d5a718ca9850bab1bf410f2439c51fab..abee55ca6174ca8527476899c9ce87b5bf4a0020 100644 (file)
@@ -14,6 +14,11 @@ static char *escape(const char* text, char *bf, int len)
 {
        char *bfp = bf;
        int multiline = strchr(text, '\n') != NULL;
+       int eol = 0;
+       int textlen = strlen(text);
+
+       if ((textlen > 0) && (text[textlen-1] == '\n'))
+               eol = 1;
 
        *bfp++ = '"';
        --len;
@@ -43,7 +48,7 @@ next:
                --len;
        }
 
-       if (multiline)
+       if (multiline && eol)
                bfp -= 3;
 
        *bfp++ = '"';
@@ -179,7 +184,11 @@ static void message__print_file_lineno(struct message *self)
 {
        struct file_line *fl = self->files;
 
-       printf("\n#: %s:%d", fl->file, fl->lineno);
+       putchar('\n');
+       if (self->option != NULL)
+               printf("# %s:00000\n", self->option);
+
+       printf("#: %s:%d", fl->file, fl->lineno);
        fl = fl->next;
 
        while (fl != NULL) {
@@ -187,9 +196,6 @@ static void message__print_file_lineno(struct message *self)
                fl = fl->next;
        }
 
-       if (self->option != NULL)
-               printf(", %s:00000", self->option);
-
        putchar('\n');
 }
 
index 8b84c42b49b5bdd0e191b044434c488e5e9af064..c3d25786a64dcec385e437867682069bcf18deda 100644 (file)
@@ -59,7 +59,7 @@ void menu_add_entry(struct symbol *sym);
 void menu_end_entry(void);
 void menu_add_dep(struct expr *dep);
 struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep);
-void menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
+struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
 void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
 void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
 void menu_finalize(struct menu *parent);
index 8c59b212722dc21bb66e695ebdef09bf339f5e72..5cfa6c405cf074f369b8ea1766ea549287560279 100644 (file)
@@ -136,9 +136,9 @@ struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *e
        return prop;
 }
 
-void menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep)
+struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep)
 {
-       menu_add_prop(type, prompt, NULL, dep);
+       return menu_add_prop(type, prompt, NULL, dep);
 }
 
 void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep)
index f163d8d2d9ef2e91bb193fce5032d7265b182e54..ff4fcc09720ecbd5303ab4c13a37efdde3eb0c98 100644 (file)
@@ -1531,7 +1531,7 @@ yyreduce:
 
     {
        menu_add_entry(NULL);
-       menu_add_prop(P_MENU, yyvsp[-1].string, NULL, NULL);
+       menu_add_prompt(P_MENU, yyvsp[-1].string, NULL);
        printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
 ;}
     break;
@@ -1586,7 +1586,7 @@ yyreduce:
 
     {
        menu_add_entry(NULL);
-       menu_add_prop(P_COMMENT, yyvsp[-1].string, NULL, NULL);
+       menu_add_prompt(P_COMMENT, yyvsp[-1].string, NULL);
        printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno());
 ;}
     break;
@@ -1640,7 +1640,7 @@ yyreduce:
   case 86:
 
     {
-       menu_add_prop(P_PROMPT, yyvsp[-1].string, NULL, yyvsp[0].expr);
+       menu_add_prompt(P_PROMPT, yyvsp[-1].string, yyvsp[0].expr);
 ;}
     break;
 
@@ -1925,7 +1925,7 @@ void conf_parse(const char *name)
        sym_init();
        menu_init();
        modules_sym = sym_lookup("MODULES", 0);
-       rootmenu.prompt = menu_add_prop(P_MENU, "Linux Kernel Configuration", NULL, NULL);
+       rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
 
        //zconfdebug = 1;
        zconfparse();
index 54460f8d3696b2bd9ee1895ff35d3e5a845a32de..e1a0f455d4a8decb163ff3196a0725b738279bb1 100644 (file)
@@ -342,7 +342,7 @@ if_block:
 menu: T_MENU prompt T_EOL
 {
        menu_add_entry(NULL);
-       menu_add_prop(P_MENU, $2, NULL, NULL);
+       menu_add_prompt(P_MENU, $2, NULL);
        printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
 };
 
@@ -392,7 +392,7 @@ source_stmt: source
 comment: T_COMMENT prompt T_EOL
 {
        menu_add_entry(NULL);
-       menu_add_prop(P_COMMENT, $2, NULL, NULL);
+       menu_add_prompt(P_COMMENT, $2, NULL);
        printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno());
 };
 
@@ -443,7 +443,7 @@ prompt_stmt_opt:
          /* empty */
        | prompt if_expr
 {
-       menu_add_prop(P_PROMPT, $1, NULL, $2);
+       menu_add_prompt(P_PROMPT, $1, $2);
 };
 
 prompt:          T_WORD
@@ -487,7 +487,7 @@ void conf_parse(const char *name)
        sym_init();
        menu_init();
        modules_sym = sym_lookup("MODULES", 0);
-       rootmenu.prompt = menu_add_prop(P_MENU, "Linux Kernel Configuration", NULL, NULL);
+       rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
 
        //zconfdebug = 1;
        zconfparse();
index 0835dc2a8aa9f4070167faa2b27905c126049616..8aaf74e64183ff46972acb0ac1d312aed4c16bfb 100755 (executable)
@@ -1665,11 +1665,17 @@ sub xml_escape($) {
 }
 
 sub process_file($) {
-    my ($file) = "$ENV{'SRCTREE'}@_";
+    my $file;
     my $identifier;
     my $func;
     my $initial_section_counter = $section_counter;
 
+    if (defined($ENV{'SRCTREE'})) {
+       $file = "$ENV{'SRCTREE'}" . "/" . "@_";
+    }
+    else {
+       $file = "@_";
+    }
     if (defined($source_map{$file})) {
        $file = $source_map{$file};
     }
index c571548daa8200add713dd605239c09c2b8f60d0..eb63e1bb63a3beb084f75eceb7fafb7b14c2217e 100644 (file)
@@ -163,7 +163,7 @@ int dialog_menu (const char *title, const char *prompt, int height, int width,
 int dialog_checklist (const char *title, const char *prompt, int height,
                int width, int list_height, int item_no,
                const char * const * items, int flag);
-extern unsigned char dialog_input_result[];
+extern char dialog_input_result[];
 int dialog_inputbox (const char *title, const char *prompt, int height,
                int width, const char *init);
 
index fa7bebc693b932d36c86cb8c6d19d3fd8a5bd999..074d2d68bd31fbcc35d5c785db79f72977d4dfb1 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "dialog.h"
 
-unsigned char dialog_input_result[MAX_LEN + 1];
+char dialog_input_result[MAX_LEN + 1];
 
 /*
  *  Print the termination buttons
@@ -48,7 +48,7 @@ dialog_inputbox (const char *title, const char *prompt, int height, int width,
 {
     int i, x, y, box_y, box_x, box_width;
     int input_x = 0, scroll = 0, key = 0, button = -1;
-    unsigned char *instr = dialog_input_result;
+    char *instr = dialog_input_result;
     WINDOW *dialog;
 
     /* center dialog box on screen */
index 8d118d1819508cf9a14d252086a89108cb8f4e0d..d7b8a384b4a7991960d33c7c01c60d6f58f92fd6 100755 (executable)
@@ -1,7 +1,8 @@
 TARGET=$1
 ARCH=$2
 SMP=$3
-CC=$4
+PREEMPT=$4
+CC=$5
 
 # If compile.h exists already and we don't own autoconf.h
 # (i.e. we're not the same user who did make *config), don't
@@ -26,8 +27,10 @@ fi
 
 
 UTS_VERSION="#$VERSION"
-if [ -n "$SMP" ] ; then UTS_VERSION="$UTS_VERSION SMP"; fi
-UTS_VERSION="$UTS_VERSION `LC_ALL=C LANG=C date`"
+CONFIG_FLAGS=""
+if [ -n "$SMP" ] ; then CONFIG_FLAGS="SMP"; fi
+if [ -n "$PREEMPT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT"; fi
+UTS_VERSION="$UTS_VERSION $CONFIG_FLAGS `LC_ALL=C LANG=C date`"
 
 # Truncate to maximum length
 
@@ -37,7 +40,8 @@ UTS_TRUNCATE="sed -e s/\(.\{1,$UTS_LEN\}\).*/\1/"
 # Generate a temporary compile.h
 
 ( echo /\* This file is auto generated, version $VERSION \*/
-
+  if [ -n "$CONFIG_FLAGS" ] ; then echo "/* $CONFIG_FLAGS */"; fi
+  
   echo \#define UTS_MACHINE \"$ARCH\"
 
   echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\"
index 1112347245c024f612c4ee1eea8e65dedc58a861..43271a1ca01ec82017f7f6a40fd7c6b79c9d7987 100644 (file)
@@ -252,9 +252,9 @@ static int parse_comment(const char *file, unsigned long len)
 }
 
 /* FIXME: Handle .s files differently (eg. # starts comments) --RR */
-static int parse_file(const signed char *fname, struct md4_ctx *md)
+static int parse_file(const char *fname, struct md4_ctx *md)
 {
-       signed char *file;
+       char *file;
        unsigned long i, len;
 
        file = grab_file(fname, &len);
@@ -332,7 +332,7 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md)
           Sum all files in the same dir or subdirs.
        */
        while ((line = get_next_line(&pos, file, flen)) != NULL) {
-               signed char* p = line;
+               char* p = line;
                if (strncmp(line, "deps_", sizeof("deps_")-1) == 0) {
                        check_files = 1;
                        continue;
@@ -458,7 +458,7 @@ out:
        close(fd);
 }
 
-static int strip_rcs_crap(signed char *version)
+static int strip_rcs_crap(char *version)
 {
        unsigned int len, full_len;
 
index 3b1f2eff258448c2230e6ffe94484720795aff96..f3e7e8e4a500fe8e6ae0438cd09ebd148067b3bd 100644 (file)
@@ -59,7 +59,7 @@ $(objtree)/binkernel.spec: $(MKSPEC) $(srctree)/Makefile
        $(CONFIG_SHELL) $(MKSPEC) prebuilt > $@
        
 binrpm-pkg: $(objtree)/binkernel.spec
-       $(MAKE)
+       $(MAKE) KBUILD_SRC=
        set -e; \
        $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
        set -e; \
@@ -74,16 +74,30 @@ clean-files += $(objtree)/binkernel.spec
 #
 .PHONY: deb-pkg
 deb-pkg:
-       $(MAKE)
+       $(MAKE) KBUILD_SRC=
        $(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
 
 clean-dirs += $(objtree)/debian/
 
 
+# tarball targets
+# ---------------------------------------------------------------------------
+.PHONY: tar%pkg
+tar%pkg:
+       $(MAKE)
+       $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@
+
+clean-dirs += $(objtree)/tar-install/
+
+
 # Help text displayed when executing 'make help'
 # ---------------------------------------------------------------------------
 help:
-       @echo  '  rpm-pkg         - Build the kernel as an RPM package'
-       @echo  '  binrpm-pkg      - Build an rpm package containing the compiled kernel & modules'
-       @echo  '  deb-pkg         - Build the kernel as an deb package'
+       @echo '  rpm-pkg         - Build the kernel as an RPM package'
+       @echo '  binrpm-pkg      - Build an rpm package containing the compiled kernel'
+       @echo '                    and modules'
+       @echo '  deb-pkg         - Build the kernel as an deb package'
+       @echo '  tar-pkg         - Build the kernel as an uncompressed tarball'
+       @echo '  targz-pkg       - Build the kernel as a gzip compressed tarball'
+       @echo '  tarbz2-pkg      - Build the kernel as a bzip2 compressed tarball'
 
index c279b6310f02f11bc88c0d2d0c7f10c94b690764..6edb29f2b4a6c8aa056a748168a70583897a9d3c 100644 (file)
@@ -14,18 +14,38 @@ set -e
 # Some variables and settings used throughout the script
 version=$KERNELRELEASE
 tmpdir="$objtree/debian/tmp"
+packagename=linux-$version
+
+if [ "$ARCH" == "um" ] ; then
+       packagename=user-mode-linux-$version
+fi
 
 # Setup the directory structure
 rm -rf "$tmpdir"
 mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot"
+if [ "$ARCH" == "um" ] ; then
+       mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/share/doc/$packagename" "$tmpdir/usr/bin"
+fi
 
 # Build and install the kernel
-cp System.map "$tmpdir/boot/System.map-$version"
-cp .config "$tmpdir/boot/config-$version"
-cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version"
+if [ "$ARCH" == "um" ] ; then
+       $MAKE linux
+       cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map"
+       cp .config "$tmpdir/usr/share/doc/$packagename/config"
+       gzip "$tmpdir/usr/share/doc/$packagename/config"
+       cp $KBUILD_IMAGE "$tmpdir/usr/bin/linux-$version"
+else 
+       cp System.map "$tmpdir/boot/System.map-$version"
+       cp .config "$tmpdir/boot/config-$version"
+       cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version"
+fi
 
 if grep -q '^CONFIG_MODULES=y' .config ; then
-       INSTALL_MOD_PATH="$tmpdir" make modules_install
+       INSTALL_MOD_PATH="$tmpdir" make KBUILD_SRC= modules_install
+       if [ "$ARCH" == "um" ] ; then
+               mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/"
+               rmdir "$tmpdir/lib/modules/$version"
+       fi
 fi
 
 # Install the maintainer scripts
@@ -53,6 +73,8 @@ linux ($version) unstable; urgency=low
 EOF
 
 # Generate a control file
+if [ "$ARCH" == "um" ]; then
+
 cat <<EOF > debian/control
 Source: linux
 Section: base
@@ -60,12 +82,34 @@ Priority: optional
 Maintainer: $name
 Standards-Version: 3.6.1
 
-Package: linux-$version
+Package: $packagename
+Architecture: any
+Description: User Mode Linux kernel, version $version
+ User-mode Linux is a port of the Linux kernel to its own system call
+ interface.  It provides a kind of virtual machine, which runs Linux
+ as a user process under another Linux kernel.  This is useful for
+ kernel development, sandboxes, jails, experimentation, and
+ many other things.
+ .
+ This package contains the Linux kernel, modules and corresponding other
+ files version $version
+EOF
+
+else
+cat <<EOF > debian/control
+Source: linux
+Section: base
+Priority: optional
+Maintainer: $name
+Standards-Version: 3.6.1
+
+Package: $packagename
 Architecture: any
 Description: Linux kernel, version $version
  This package contains the Linux kernel, modules and corresponding other
- files version $version.
+ files version $version
 EOF
+fi
 
 # Fix some ownership and permissions
 chown -R root:root "$tmpdir"
diff --git a/scripts/package/buildtar b/scripts/package/buildtar
new file mode 100644 (file)
index 0000000..d8fffe6
--- /dev/null
@@ -0,0 +1,111 @@
+#!/bin/sh
+
+#
+# buildtar 0.0.3
+#
+# (C) 2004-2005 by Jan-Benedict Glaw <jbglaw@lug-owl.de>
+#
+# This script is used to compile a tarball from the currently
+# prepared kernel. Based upon the builddeb script from
+# Wichert Akkerman <wichert@wiggy.net>.
+#
+
+set -e
+
+#
+# Some variables and settings used throughout the script
+#
+version="${VERSION}.${PATCHLEVEL}.${SUBLEVEL}${EXTRAVERSION}${EXTRANAME}"
+tmpdir="${objtree}/tar-install"
+tarball="${objtree}/linux-${version}.tar"
+
+
+#
+# Figure out how to compress, if requested at all
+#
+case "${1}" in
+       tar-pkg)
+               compress="cat"
+               file_ext=""
+               ;;
+       targz-pkg)
+               compress="gzip -c9"
+               file_ext=".gz"
+               ;;
+       tarbz2-pkg)
+               compress="bzip2 -c9"
+               file_ext=".bz2"
+               ;;
+       *)
+               echo "Unknown tarball target \"${1}\" requested, please add it to ${0}." >&2
+               exit 1
+               ;;
+esac
+
+
+#
+# Clean-up and re-create the temporary directory
+#
+rm -rf -- "${tmpdir}"
+mkdir -p -- "${tmpdir}/boot"
+
+
+#
+# Try to install modules
+#
+if ! make INSTALL_MOD_PATH="${tmpdir}" modules_install; then
+       echo "" >&2
+       echo "Ignoring error at module_install time, since that could be" >&2
+       echo "a result of missing local modutils/module-init-tools," >&2
+       echo "or you just didn't compile in module support at all..." >&2
+       echo "" >&2
+fi
+
+
+#
+# Install basic kernel files
+#
+cp -v -- System.map "${tmpdir}/boot/System.map-${version}"
+cp -v -- .config "${tmpdir}/boot/config-${version}"
+cp -v -- vmlinux "${tmpdir}/boot/vmlinux-${version}"
+
+
+#
+# Install arch-specific kernel image(s)
+#
+case "${ARCH}" in
+       i386)
+               [ -f arch/i386/boot/bzImage ] && cp -v -- arch/i386/boot/bzImage "${tmpdir}/boot/vmlinuz-${version}"
+               ;;
+       alpha)
+               [ -f arch/alpha/boot/vmlinux.gz ] && cp -v -- arch/alpha/boot/vmlinux.gz "${tmpdir}/boot/vmlinuz-${version}"
+               ;;
+       vax)
+               [ -f vmlinux.SYS ] && cp -v -- vmlinux.SYS "${tmpdir}/boot/vmlinux-${version}.SYS"
+               [ -f vmlinux.dsk ] && cp -v -- vmlinux.dsk "${tmpdir}/boot/vmlinux-${version}.dsk"
+               ;;
+       *)
+               [ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${version}"
+               echo "" >&2
+               echo '** ** **  WARNING  ** ** **' >&2
+               echo "" >&2
+               echo "Your architecture did not define any architecture-dependant files" >&2
+               echo "to be placed into the tarball. Please add those to ${0} ..." >&2
+               echo "" >&2
+               sleep 5
+               ;;
+esac
+
+
+#
+# Create the tarball
+#
+(
+       cd "${tmpdir}"
+       tar cf - . | ${compress} > "${tarball}${file_ext}"
+)
+
+echo "Tarball successfully created in ${tarball}${file_ext}"
+
+exit 0
+
index 6e7a58f145adfadce753997cd40c89161944469d..0b10387375480eb70f05e4ba57a1baa5e0143275 100755 (executable)
@@ -62,10 +62,19 @@ echo ""
 fi
 
 echo "%install"
+echo "%ifarch ia64"
+echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib $RPM_BUILD_ROOT/lib/modules'
+echo "%else"
 echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib $RPM_BUILD_ROOT/lib/modules'
+echo "%endif"
 
 echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{_smp_mflags} modules_install'
+echo "%ifarch ia64"
+echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE"
+echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/"
+echo "%else"
 echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
+echo "%endif"
 
 echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE"
 
index d5cabb81bd1be5617a3afdd1cabf6c7e04f6cfde..f04f6273685161dc45c98e11f8d1065660ca0a0f 100644 (file)
@@ -96,6 +96,7 @@ foreach $object (keys(%object)) {
                     $from !~ /\.debug_ranges$/ &&
                     $from !~ /\.debug_line$/ &&
                     $from !~ /\.debug_frame$/ &&
+                    $from !~ /\.debug_loc$/ &&
                     $from !~ /\.exitcall\.exit$/ &&
                     $from !~ /\.eh_frame$/ &&
                     $from !~ /\.stab$/)) {
index 9a240845386958c574cabe4b6ca5b88a94a443ac..7f6960b175a2132f661839a807b8a9b9f3d91410 100644 (file)
@@ -98,6 +98,7 @@ foreach $object (sort(keys(%object))) {
                     $from !~ /\.pdr$/ &&
                     $from !~ /\__param$/ &&
                     $from !~ /\.altinstructions/ &&
+                    $from !~ /\.eh_frame/ &&
                     $from !~ /\.debug_/)) {
                        printf("Error: %s %s refers to %s\n", $object, $from, $line);
                }
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
new file mode 100644 (file)
index 0000000..7c805c8
--- /dev/null
@@ -0,0 +1,56 @@
+#!/usr/bin/perl
+# Copyright 2004 - Ryan Anderson <ryan@michonline.com>  GPL v2
+
+use strict;
+use warnings;
+use Digest::MD5;
+require 5.006;
+
+if (@ARGV != 1) {
+       print <<EOT;
+Usage: setlocalversion <srctree>
+EOT
+       exit(1);
+}
+
+my ($srctree) = @ARGV;
+chdir($srctree);
+
+my @LOCALVERSIONS = ();
+
+# We are going to use the following commands to try and determine if this
+# repository is at a Version boundary (i.e, 2.6.10 vs 2.6.10 + some patches) We
+# currently assume that all meaningful version boundaries are marked by a tag.
+# We don't care what the tag is, just that something exists.
+
+# Git/Cogito store the top-of-tree "commit" in .git/HEAD
+# A list of known tags sits in .git/refs/tags/
+#
+# The simple trick here is to just compare the two of these, and if we get a
+# match, return nothing, otherwise, return a subset of the SHA-1 hash in
+# .git/HEAD
+
+sub do_git_checks {
+       open(H,"<.git/HEAD") or return;
+       my $head = <H>;
+       chomp $head;
+       close(H);
+
+       opendir(D,".git/refs/tags") or return;
+       foreach my $tagfile (grep !/^\.{1,2}$/, readdir(D)) {
+               open(F,"<.git/refs/tags/" . $tagfile) or return;
+               my $tag = <F>;
+               chomp $tag;
+               close(F);
+               return if ($tag eq $head);
+       }
+       closedir(D);
+
+       push @LOCALVERSIONS, "g" . substr($head,0,8);
+}
+
+if ( -d ".git") {
+       do_git_checks();
+}
+
+printf "-%s\n", join("-",@LOCALVERSIONS) if (scalar @LOCALVERSIONS > 0);
index c8e87b22c9bdcca5e9d26593b383441109381ce7..96b1f2122f67bdac673a18fab792ea56e8d236ab 100644 (file)
@@ -321,7 +321,7 @@ plaintext_to_sha1(unsigned char *hash, const char *plaintext, int len)
                              "bytes.\n", len, PAGE_SIZE);
                return -ENOMEM;
        }
-       tfm = crypto_alloc_tfm("sha1", 0);
+       tfm = crypto_alloc_tfm("sha1", CRYPTO_TFM_REQ_MAY_SLEEP);
        if (tfm == NULL) {
                seclvl_printk(0, KERN_ERR,
                              "Failed to load transform for SHA1\n");
index 451502467a9b882ffda85c3626dd9a832522c880..cf6020f85403e54e23660e7c86c7e0f30e4750f4 100644 (file)
@@ -490,7 +490,7 @@ out:
 }
 
 static inline void avc_print_ipv6_addr(struct audit_buffer *ab,
-                                      struct in6_addr *addr, u16 port,
+                                      struct in6_addr *addr, __be16 port,
                                       char *name1, char *name2)
 {
        if (!ipv6_addr_any(addr))
@@ -501,7 +501,7 @@ static inline void avc_print_ipv6_addr(struct audit_buffer *ab,
 }
 
 static inline void avc_print_ipv4_addr(struct audit_buffer *ab, u32 addr,
-                                      u16 port, char *name1, char *name2)
+                                      __be16 port, char *name1, char *name2)
 {
        if (addr)
                audit_log_format(ab, " %s=%d.%d.%d.%d", name1, NIPQUAD(addr));
index 71c0a19c97538da142962be9a458b259205c1d80..5f016c98056f53e35491c779fcb3dd2dc23c54c9 100644 (file)
 #define POLICYDB_VERSION_NLCLASS       18
 #define POLICYDB_VERSION_VALIDATETRANS 19
 #define POLICYDB_VERSION_MLS           19
+#define POLICYDB_VERSION_AVTAB         20
 
 /* Range of policy versions we understand*/
 #define POLICYDB_VERSION_MIN   POLICYDB_VERSION_BASE
-#define POLICYDB_VERSION_MAX   POLICYDB_VERSION_MLS
+#define POLICYDB_VERSION_MAX   POLICYDB_VERSION_AVTAB
 
 #ifdef CONFIG_SECURITY_SELINUX_BOOTPARAM
 extern int selinux_enabled;
index f238c034c44e22e882dbccd71844ffb0224818dc..dde094feb20dfb5976b8e215db975b61f14df1c3 100644 (file)
@@ -58,6 +58,7 @@ static int avtab_insert(struct avtab *h, struct avtab_key *key, struct avtab_dat
 {
        int hvalue;
        struct avtab_node *prev, *cur, *newnode;
+       u16 specified = key->specified & ~(AVTAB_ENABLED|AVTAB_ENABLED_OLD);
 
        if (!h)
                return -EINVAL;
@@ -69,7 +70,7 @@ static int avtab_insert(struct avtab *h, struct avtab_key *key, struct avtab_dat
                if (key->source_type == cur->key.source_type &&
                    key->target_type == cur->key.target_type &&
                    key->target_class == cur->key.target_class &&
-                   (datum->specified & cur->datum.specified))
+                   (specified & cur->key.specified))
                        return -EEXIST;
                if (key->source_type < cur->key.source_type)
                        break;
@@ -98,6 +99,7 @@ avtab_insert_nonunique(struct avtab * h, struct avtab_key * key, struct avtab_da
 {
        int hvalue;
        struct avtab_node *prev, *cur, *newnode;
+       u16 specified = key->specified & ~(AVTAB_ENABLED|AVTAB_ENABLED_OLD);
 
        if (!h)
                return NULL;
@@ -108,7 +110,7 @@ avtab_insert_nonunique(struct avtab * h, struct avtab_key * key, struct avtab_da
                if (key->source_type == cur->key.source_type &&
                    key->target_type == cur->key.target_type &&
                    key->target_class == cur->key.target_class &&
-                   (datum->specified & cur->datum.specified))
+                   (specified & cur->key.specified))
                        break;
                if (key->source_type < cur->key.source_type)
                        break;
@@ -125,10 +127,11 @@ avtab_insert_nonunique(struct avtab * h, struct avtab_key * key, struct avtab_da
        return newnode;
 }
 
-struct avtab_datum *avtab_search(struct avtab *h, struct avtab_key *key, int specified)
+struct avtab_datum *avtab_search(struct avtab *h, struct avtab_key *key)
 {
        int hvalue;
        struct avtab_node *cur;
+       u16 specified = key->specified & ~(AVTAB_ENABLED|AVTAB_ENABLED_OLD);
 
        if (!h)
                return NULL;
@@ -138,7 +141,7 @@ struct avtab_datum *avtab_search(struct avtab *h, struct avtab_key *key, int spe
                if (key->source_type == cur->key.source_type &&
                    key->target_type == cur->key.target_type &&
                    key->target_class == cur->key.target_class &&
-                   (specified & cur->datum.specified))
+                   (specified & cur->key.specified))
                        return &cur->datum;
 
                if (key->source_type < cur->key.source_type)
@@ -159,10 +162,11 @@ struct avtab_datum *avtab_search(struct avtab *h, struct avtab_key *key, int spe
  * conjunction with avtab_search_next_node()
  */
 struct avtab_node*
-avtab_search_node(struct avtab *h, struct avtab_key *key, int specified)
+avtab_search_node(struct avtab *h, struct avtab_key *key)
 {
        int hvalue;
        struct avtab_node *cur;
+       u16 specified = key->specified & ~(AVTAB_ENABLED|AVTAB_ENABLED_OLD);
 
        if (!h)
                return NULL;
@@ -172,7 +176,7 @@ avtab_search_node(struct avtab *h, struct avtab_key *key, int specified)
                if (key->source_type == cur->key.source_type &&
                    key->target_type == cur->key.target_type &&
                    key->target_class == cur->key.target_class &&
-                   (specified & cur->datum.specified))
+                   (specified & cur->key.specified))
                        return cur;
 
                if (key->source_type < cur->key.source_type)
@@ -196,11 +200,12 @@ avtab_search_node_next(struct avtab_node *node, int specified)
        if (!node)
                return NULL;
 
+       specified &= ~(AVTAB_ENABLED|AVTAB_ENABLED_OLD);
        for (cur = node->next; cur; cur = cur->next) {
                if (node->key.source_type == cur->key.source_type &&
                    node->key.target_type == cur->key.target_type &&
                    node->key.target_class == cur->key.target_class &&
-                   (specified & cur->datum.specified))
+                   (specified & cur->key.specified))
                        return cur;
 
                if (node->key.source_type < cur->key.source_type)
@@ -278,76 +283,129 @@ void avtab_hash_eval(struct avtab *h, char *tag)
               max_chain_len);
 }
 
-int avtab_read_item(void *fp, struct avtab_datum *avdatum, struct avtab_key *avkey)
+static uint16_t spec_order[] = {
+       AVTAB_ALLOWED,
+       AVTAB_AUDITDENY,
+       AVTAB_AUDITALLOW,
+       AVTAB_TRANSITION,
+       AVTAB_CHANGE,
+       AVTAB_MEMBER
+};
+
+int avtab_read_item(void *fp, u32 vers, struct avtab *a,
+                   int (*insertf)(struct avtab *a, struct avtab_key *k,
+                                  struct avtab_datum *d, void *p),
+                   void *p)
 {
-       u32 buf[7];
-       u32 items, items2;
-       int rc;
+       __le16 buf16[4];
+       u16 enabled;
+       __le32 buf32[7];
+       u32 items, items2, val;
+       struct avtab_key key;
+       struct avtab_datum datum;
+       int i, rc;
+
+       memset(&key, 0, sizeof(struct avtab_key));
+       memset(&datum, 0, sizeof(struct avtab_datum));
+
+       if (vers < POLICYDB_VERSION_AVTAB) {
+               rc = next_entry(buf32, fp, sizeof(u32));
+               if (rc < 0) {
+                       printk(KERN_ERR "security: avtab: truncated entry\n");
+                       return -1;
+               }
+               items2 = le32_to_cpu(buf32[0]);
+               if (items2 > ARRAY_SIZE(buf32)) {
+                       printk(KERN_ERR "security: avtab: entry overflow\n");
+                       return -1;
 
-       memset(avkey, 0, sizeof(struct avtab_key));
-       memset(avdatum, 0, sizeof(struct avtab_datum));
+               }
+               rc = next_entry(buf32, fp, sizeof(u32)*items2);
+               if (rc < 0) {
+                       printk(KERN_ERR "security: avtab: truncated entry\n");
+                       return -1;
+               }
+               items = 0;
 
-       rc = next_entry(buf, fp, sizeof(u32));
-       if (rc < 0) {
-               printk(KERN_ERR "security: avtab: truncated entry\n");
-               goto bad;
-       }
-       items2 = le32_to_cpu(buf[0]);
-       if (items2 > ARRAY_SIZE(buf)) {
-               printk(KERN_ERR "security: avtab: entry overflow\n");
-               goto bad;
+               val = le32_to_cpu(buf32[items++]);
+               key.source_type = (u16)val;
+               if (key.source_type != val) {
+                       printk("security: avtab: truncated source type\n");
+                       return -1;
+               }
+               val = le32_to_cpu(buf32[items++]);
+               key.target_type = (u16)val;
+               if (key.target_type != val) {
+                       printk("security: avtab: truncated target type\n");
+                       return -1;
+               }
+               val = le32_to_cpu(buf32[items++]);
+               key.target_class = (u16)val;
+               if (key.target_class != val) {
+                       printk("security: avtab: truncated target class\n");
+                       return -1;
+               }
+
+               val = le32_to_cpu(buf32[items++]);
+               enabled = (val & AVTAB_ENABLED_OLD) ? AVTAB_ENABLED : 0;
+
+               if (!(val & (AVTAB_AV | AVTAB_TYPE))) {
+                       printk("security: avtab: null entry\n");
+                       return -1;
+               }
+               if ((val & AVTAB_AV) &&
+                   (val & AVTAB_TYPE)) {
+                       printk("security: avtab: entry has both access vectors and types\n");
+                       return -1;
+               }
+
+               for (i = 0; i < sizeof(spec_order)/sizeof(u16); i++) {
+                       if (val & spec_order[i]) {
+                               key.specified = spec_order[i] | enabled;
+                               datum.data = le32_to_cpu(buf32[items++]);
+                               rc = insertf(a, &key, &datum, p);
+                               if (rc) return rc;
+                       }
+               }
+
+               if (items != items2) {
+                       printk("security: avtab: entry only had %d items, expected %d\n", items2, items);
+                       return -1;
+               }
+               return 0;
        }
-       rc = next_entry(buf, fp, sizeof(u32)*items2);
+
+       rc = next_entry(buf16, fp, sizeof(u16)*4);
        if (rc < 0) {
-               printk(KERN_ERR "security: avtab: truncated entry\n");
-               goto bad;
+               printk("security: avtab: truncated entry\n");
+               return -1;
        }
+
        items = 0;
-       avkey->source_type = le32_to_cpu(buf[items++]);
-       avkey->target_type = le32_to_cpu(buf[items++]);
-       avkey->target_class = le32_to_cpu(buf[items++]);
-       avdatum->specified = le32_to_cpu(buf[items++]);
-       if (!(avdatum->specified & (AVTAB_AV | AVTAB_TYPE))) {
-               printk(KERN_ERR "security: avtab: null entry\n");
-               goto bad;
-       }
-       if ((avdatum->specified & AVTAB_AV) &&
-           (avdatum->specified & AVTAB_TYPE)) {
-               printk(KERN_ERR "security: avtab: entry has both access vectors and types\n");
-               goto bad;
-       }
-       if (avdatum->specified & AVTAB_AV) {
-               if (avdatum->specified & AVTAB_ALLOWED)
-                       avtab_allowed(avdatum) = le32_to_cpu(buf[items++]);
-               if (avdatum->specified & AVTAB_AUDITDENY)
-                       avtab_auditdeny(avdatum) = le32_to_cpu(buf[items++]);
-               if (avdatum->specified & AVTAB_AUDITALLOW)
-                       avtab_auditallow(avdatum) = le32_to_cpu(buf[items++]);
-       } else {
-               if (avdatum->specified & AVTAB_TRANSITION)
-                       avtab_transition(avdatum) = le32_to_cpu(buf[items++]);
-               if (avdatum->specified & AVTAB_CHANGE)
-                       avtab_change(avdatum) = le32_to_cpu(buf[items++]);
-               if (avdatum->specified & AVTAB_MEMBER)
-                       avtab_member(avdatum) = le32_to_cpu(buf[items++]);
-       }
-       if (items != items2) {
-               printk(KERN_ERR "security: avtab: entry only had %d items, expected %d\n",
-                      items2, items);
-               goto bad;
+       key.source_type = le16_to_cpu(buf16[items++]);
+       key.target_type = le16_to_cpu(buf16[items++]);
+       key.target_class = le16_to_cpu(buf16[items++]);
+       key.specified = le16_to_cpu(buf16[items++]);
+
+       rc = next_entry(buf32, fp, sizeof(u32));
+       if (rc < 0) {
+               printk("security: avtab: truncated entry\n");
+               return -1;
        }
+       datum.data = le32_to_cpu(*buf32);
+       return insertf(a, &key, &datum, p);
+}
 
-       return 0;
-bad:
-       return -1;
+static int avtab_insertf(struct avtab *a, struct avtab_key *k,
+                        struct avtab_datum *d, void *p)
+{
+       return avtab_insert(a, k, d);
 }
 
-int avtab_read(struct avtab *a, void *fp, u32 config)
+int avtab_read(struct avtab *a, void *fp, u32 vers)
 {
        int rc;
-       struct avtab_key avkey;
-       struct avtab_datum avdatum;
-       u32 buf[1];
+       __le32 buf[1];
        u32 nel, i;
 
 
@@ -363,16 +421,14 @@ int avtab_read(struct avtab *a, void *fp, u32 config)
                goto bad;
        }
        for (i = 0; i < nel; i++) {
-               if (avtab_read_item(fp, &avdatum, &avkey)) {
-                       rc = -EINVAL;
-                       goto bad;
-               }
-               rc = avtab_insert(a, &avkey, &avdatum);
+               rc = avtab_read_item(fp,vers, a, avtab_insertf, NULL);
                if (rc) {
                        if (rc == -ENOMEM)
                                printk(KERN_ERR "security: avtab: out of memory\n");
-                       if (rc == -EEXIST)
+                       else if (rc == -EEXIST)
                                printk(KERN_ERR "security: avtab: duplicate entry\n");
+                       else
+                               rc = -EINVAL;
                        goto bad;
                }
        }
index 519d4f6dc655e0cce267a15a0f93880fabeafa11..0a90d939af93f8b17167fbef67dbab34b8f2bd04 100644 (file)
 #define _SS_AVTAB_H_
 
 struct avtab_key {
-       u32 source_type;        /* source type */
-       u32 target_type;        /* target type */
-       u32 target_class;       /* target object class */
-};
-
-struct avtab_datum {
+       u16 source_type;        /* source type */
+       u16 target_type;        /* target type */
+       u16 target_class;       /* target object class */
 #define AVTAB_ALLOWED     1
 #define AVTAB_AUDITALLOW  2
 #define AVTAB_AUDITDENY   4
@@ -35,15 +32,13 @@ struct avtab_datum {
 #define AVTAB_MEMBER     32
 #define AVTAB_CHANGE     64
 #define AVTAB_TYPE       (AVTAB_TRANSITION | AVTAB_MEMBER | AVTAB_CHANGE)
-#define AVTAB_ENABLED    0x80000000 /* reserved for used in cond_avtab */
-       u32 specified;  /* what fields are specified */
-       u32 data[3];    /* access vectors or types */
-#define avtab_allowed(x) (x)->data[0]
-#define avtab_auditdeny(x) (x)->data[1]
-#define avtab_auditallow(x) (x)->data[2]
-#define avtab_transition(x) (x)->data[0]
-#define avtab_change(x) (x)->data[1]
-#define avtab_member(x) (x)->data[2]
+#define AVTAB_ENABLED_OLD    0x80000000 /* reserved for used in cond_avtab */
+#define AVTAB_ENABLED    0x8000 /* reserved for used in cond_avtab */
+       u16 specified;  /* what field is specified */
+};
+
+struct avtab_datum {
+       u32 data; /* access vector or type value */
 };
 
 struct avtab_node {
@@ -58,17 +53,21 @@ struct avtab {
 };
 
 int avtab_init(struct avtab *);
-struct avtab_datum *avtab_search(struct avtab *h, struct avtab_key *k, int specified);
+struct avtab_datum *avtab_search(struct avtab *h, struct avtab_key *k);
 void avtab_destroy(struct avtab *h);
 void avtab_hash_eval(struct avtab *h, char *tag);
 
-int avtab_read_item(void *fp, struct avtab_datum *avdatum, struct avtab_key *avkey);
-int avtab_read(struct avtab *a, void *fp, u32 config);
+int avtab_read_item(void *fp, uint32_t vers, struct avtab *a,
+                   int (*insert)(struct avtab *a, struct avtab_key *k,
+                                 struct avtab_datum *d, void *p),
+                   void *p);
+
+int avtab_read(struct avtab *a, void *fp, u32 vers);
 
 struct avtab_node *avtab_insert_nonunique(struct avtab *h, struct avtab_key *key,
                                          struct avtab_datum *datum);
 
-struct avtab_node *avtab_search_node(struct avtab *h, struct avtab_key *key, int specified);
+struct avtab_node *avtab_search_node(struct avtab *h, struct avtab_key *key);
 
 struct avtab_node *avtab_search_node_next(struct avtab_node *node, int specified);
 
index e2057f5a411a470372efcf919bfa502daa5149d9..daf2880074607fd535080ed6a08bebd3a36a3082 100644 (file)
@@ -100,18 +100,18 @@ int evaluate_cond_node(struct policydb *p, struct cond_node *node)
                /* turn the rules on or off */
                for (cur = node->true_list; cur != NULL; cur = cur->next) {
                        if (new_state <= 0) {
-                               cur->node->datum.specified &= ~AVTAB_ENABLED;
+                               cur->node->key.specified &= ~AVTAB_ENABLED;
                        } else {
-                               cur->node->datum.specified |= AVTAB_ENABLED;
+                               cur->node->key.specified |= AVTAB_ENABLED;
                        }
                }
 
                for (cur = node->false_list; cur != NULL; cur = cur->next) {
                        /* -1 or 1 */
                        if (new_state) {
-                               cur->node->datum.specified &= ~AVTAB_ENABLED;
+                               cur->node->key.specified &= ~AVTAB_ENABLED;
                        } else {
-                               cur->node->datum.specified |= AVTAB_ENABLED;
+                               cur->node->key.specified |= AVTAB_ENABLED;
                        }
                }
        }
@@ -216,7 +216,8 @@ int cond_read_bool(struct policydb *p, struct hashtab *h, void *fp)
 {
        char *key = NULL;
        struct cond_bool_datum *booldatum;
-       u32 buf[3], len;
+       __le32 buf[3];
+       u32 len;
        int rc;
 
        booldatum = kmalloc(sizeof(struct cond_bool_datum), GFP_KERNEL);
@@ -252,104 +253,127 @@ err:
        return -1;
 }
 
-static int cond_read_av_list(struct policydb *p, void *fp, struct cond_av_list **ret_list,
-                            struct cond_av_list *other)
+struct cond_insertf_data
 {
-       struct cond_av_list *list, *last = NULL, *cur;
-       struct avtab_key key;
-       struct avtab_datum datum;
+       struct policydb *p;
+       struct cond_av_list *other;
+       struct cond_av_list *head;
+       struct cond_av_list *tail;
+};
+
+static int cond_insertf(struct avtab *a, struct avtab_key *k, struct avtab_datum *d, void *ptr)
+{
+       struct cond_insertf_data *data = ptr;
+       struct policydb *p = data->p;
+       struct cond_av_list *other = data->other, *list, *cur;
        struct avtab_node *node_ptr;
-       int rc;
-       u32 buf[1], i, len;
        u8 found;
 
-       *ret_list = NULL;
-
-       len = 0;
-       rc = next_entry(buf, fp, sizeof buf);
-       if (rc < 0)
-               return -1;
-
-       len = le32_to_cpu(buf[0]);
-       if (len == 0) {
-               return 0;
-       }
 
-       for (i = 0; i < len; i++) {
-               if (avtab_read_item(fp, &datum, &key))
+       /*
+        * For type rules we have to make certain there aren't any
+        * conflicting rules by searching the te_avtab and the
+        * cond_te_avtab.
+        */
+       if (k->specified & AVTAB_TYPE) {
+               if (avtab_search(&p->te_avtab, k)) {
+                       printk("security: type rule already exists outside of a conditional.");
                        goto err;
-
+               }
                /*
-                * For type rules we have to make certain there aren't any
-                * conflicting rules by searching the te_avtab and the
-                * cond_te_avtab.
+                * If we are reading the false list other will be a pointer to
+                * the true list. We can have duplicate entries if there is only
+                * 1 other entry and it is in our true list.
+                *
+                * If we are reading the true list (other == NULL) there shouldn't
+                * be any other entries.
                 */
-               if (datum.specified & AVTAB_TYPE) {
-                       if (avtab_search(&p->te_avtab, &key, AVTAB_TYPE)) {
-                               printk("security: type rule already exists outside of a conditional.");
-                               goto err;
-                       }
-                       /*
-                        * If we are reading the false list other will be a pointer to
-                        * the true list. We can have duplicate entries if there is only
-                        * 1 other entry and it is in our true list.
-                        *
-                        * If we are reading the true list (other == NULL) there shouldn't
-                        * be any other entries.
-                        */
-                       if (other) {
-                               node_ptr = avtab_search_node(&p->te_cond_avtab, &key, AVTAB_TYPE);
-                               if (node_ptr) {
-                                       if (avtab_search_node_next(node_ptr, AVTAB_TYPE)) {
-                                               printk("security: too many conflicting type rules.");
-                                               goto err;
-                                       }
-                                       found = 0;
-                                       for (cur = other; cur != NULL; cur = cur->next) {
-                                               if (cur->node == node_ptr) {
-                                                       found = 1;
-                                                       break;
-                                               }
-                                       }
-                                       if (!found) {
-                                               printk("security: conflicting type rules.");
-                                               goto err;
+               if (other) {
+                       node_ptr = avtab_search_node(&p->te_cond_avtab, k);
+                       if (node_ptr) {
+                               if (avtab_search_node_next(node_ptr, k->specified)) {
+                                       printk("security: too many conflicting type rules.");
+                                       goto err;
+                               }
+                               found = 0;
+                               for (cur = other; cur != NULL; cur = cur->next) {
+                                       if (cur->node == node_ptr) {
+                                               found = 1;
+                                               break;
                                        }
                                }
-                       } else {
-                               if (avtab_search(&p->te_cond_avtab, &key, AVTAB_TYPE)) {
-                                       printk("security: conflicting type rules when adding type rule for true.");
+                               if (!found) {
+                                       printk("security: conflicting type rules.\n");
                                        goto err;
                                }
                        }
+               } else {
+                       if (avtab_search(&p->te_cond_avtab, k)) {
+                               printk("security: conflicting type rules when adding type rule for true.\n");
+                               goto err;
+                       }
                }
-               node_ptr = avtab_insert_nonunique(&p->te_cond_avtab, &key, &datum);
-               if (!node_ptr) {
-                       printk("security: could not insert rule.");
-                       goto err;
-               }
-
-               list = kmalloc(sizeof(struct cond_av_list), GFP_KERNEL);
-               if (!list)
-                       goto err;
-               memset(list, 0, sizeof(struct cond_av_list));
-
-               list->node = node_ptr;
-               if (i == 0)
-                       *ret_list = list;
-               else
-                       last->next = list;
-               last = list;
+       }
 
+       node_ptr = avtab_insert_nonunique(&p->te_cond_avtab, k, d);
+       if (!node_ptr) {
+               printk("security: could not insert rule.");
+               goto err;
        }
 
+       list = kmalloc(sizeof(struct cond_av_list), GFP_KERNEL);
+       if (!list)
+               goto err;
+       memset(list, 0, sizeof(*list));
+
+       list->node = node_ptr;
+       if (!data->head)
+               data->head = list;
+       else
+               data->tail->next = list;
+       data->tail = list;
        return 0;
+
 err:
-       cond_av_list_destroy(*ret_list);
-       *ret_list = NULL;
+       cond_av_list_destroy(data->head);
+       data->head = NULL;
        return -1;
 }
 
+static int cond_read_av_list(struct policydb *p, void *fp, struct cond_av_list **ret_list, struct cond_av_list *other)
+{
+       int i, rc;
+       __le32 buf[1];
+       u32 len;
+       struct cond_insertf_data data;
+
+       *ret_list = NULL;
+
+       len = 0;
+       rc = next_entry(buf, fp, sizeof(u32));
+       if (rc < 0)
+               return -1;
+
+       len = le32_to_cpu(buf[0]);
+       if (len == 0) {
+               return 0;
+       }
+
+       data.p = p;
+       data.other = other;
+       data.head = NULL;
+       data.tail = NULL;
+       for (i = 0; i < len; i++) {
+               rc = avtab_read_item(fp, p->policyvers, &p->te_cond_avtab, cond_insertf, &data);
+               if (rc)
+                       return rc;
+
+       }
+
+       *ret_list = data.head;
+       return 0;
+}
+
 static int expr_isvalid(struct policydb *p, struct cond_expr *expr)
 {
        if (expr->expr_type <= 0 || expr->expr_type > COND_LAST) {
@@ -366,7 +390,8 @@ static int expr_isvalid(struct policydb *p, struct cond_expr *expr)
 
 static int cond_read_node(struct policydb *p, struct cond_node *node, void *fp)
 {
-       u32 buf[2], len, i;
+       __le32 buf[2];
+       u32 len, i;
        int rc;
        struct cond_expr *expr = NULL, *last = NULL;
 
@@ -424,7 +449,8 @@ err:
 int cond_read_list(struct policydb *p, void *fp)
 {
        struct cond_node *node, *last = NULL;
-       u32 buf[1], i, len;
+       __le32 buf[1];
+       u32 i, len;
        int rc;
 
        rc = next_entry(buf, fp, sizeof buf);
@@ -452,6 +478,7 @@ int cond_read_list(struct policydb *p, void *fp)
        return 0;
 err:
        cond_list_destroy(p->cond_list);
+       p->cond_list = NULL;
        return -1;
 }
 
@@ -465,22 +492,22 @@ void cond_compute_av(struct avtab *ctab, struct avtab_key *key, struct av_decisi
        if(!ctab || !key || !avd)
                return;
 
-       for(node = avtab_search_node(ctab, key, AVTAB_AV); node != NULL;
-                               node = avtab_search_node_next(node, AVTAB_AV)) {
-               if ( (__u32) (AVTAB_ALLOWED|AVTAB_ENABLED) ==
-                    (node->datum.specified & (AVTAB_ALLOWED|AVTAB_ENABLED)))
-                       avd->allowed |= avtab_allowed(&node->datum);
-               if ( (__u32) (AVTAB_AUDITDENY|AVTAB_ENABLED) ==
-                    (node->datum.specified & (AVTAB_AUDITDENY|AVTAB_ENABLED)))
+       for(node = avtab_search_node(ctab, key); node != NULL;
+                               node = avtab_search_node_next(node, key->specified)) {
+               if ( (u16) (AVTAB_ALLOWED|AVTAB_ENABLED) ==
+                    (node->key.specified & (AVTAB_ALLOWED|AVTAB_ENABLED)))
+                       avd->allowed |= node->datum.data;
+               if ( (u16) (AVTAB_AUDITDENY|AVTAB_ENABLED) ==
+                    (node->key.specified & (AVTAB_AUDITDENY|AVTAB_ENABLED)))
                        /* Since a '0' in an auditdeny mask represents a
                         * permission we do NOT want to audit (dontaudit), we use
                         * the '&' operand to ensure that all '0's in the mask
                         * are retained (much unlike the allow and auditallow cases).
                         */
-                       avd->auditdeny &= avtab_auditdeny(&node->datum);
-               if ( (__u32) (AVTAB_AUDITALLOW|AVTAB_ENABLED) ==
-                    (node->datum.specified & (AVTAB_AUDITALLOW|AVTAB_ENABLED)))
-                       avd->auditallow |= avtab_auditallow(&node->datum);
+                       avd->auditdeny &= node->datum.data;
+               if ( (u16) (AVTAB_AUDITALLOW|AVTAB_ENABLED) ==
+                    (node->key.specified & (AVTAB_AUDITALLOW|AVTAB_ENABLED)))
+                       avd->auditallow |= node->datum.data;
        }
        return;
 }
index d8ce9cc0b9f15042c50bc7abf2b3bea9202031bb..d515154128cc613bcdc916191f44936a411029fc 100644 (file)
@@ -196,8 +196,9 @@ int ebitmap_read(struct ebitmap *e, void *fp)
 {
        int rc;
        struct ebitmap_node *n, *l;
-       u32 buf[3], mapsize, count, i;
-       u64 map;
+       __le32 buf[3];
+       u32 mapsize, count, i;
+       __le64 map;
 
        ebitmap_init(e);
 
index 471370233fd9e93a1467bb6b3ebaa85b9194b1da..8bf41055a6cb7303c7a781e8b77513c1ecbbe5a8 100644 (file)
@@ -32,11 +32,41 @@ struct ebitmap {
 #define ebitmap_length(e) ((e)->highbit)
 #define ebitmap_startbit(e) ((e)->node ? (e)->node->startbit : 0)
 
+static inline unsigned int ebitmap_start(struct ebitmap *e,
+                                        struct ebitmap_node **n)
+{
+       *n = e->node;
+       return ebitmap_startbit(e);
+}
+
 static inline void ebitmap_init(struct ebitmap *e)
 {
        memset(e, 0, sizeof(*e));
 }
 
+static inline unsigned int ebitmap_next(struct ebitmap_node **n,
+                                       unsigned int bit)
+{
+       if ((bit == ((*n)->startbit + MAPSIZE - 1)) &&
+           (*n)->next) {
+               *n = (*n)->next;
+               return (*n)->startbit;
+       }
+
+       return (bit+1);
+}
+
+static inline int ebitmap_node_get_bit(struct ebitmap_node * n,
+                                      unsigned int bit)
+{
+       if (n->map & (MAPBIT << (bit - n->startbit)))
+               return 1;
+       return 0;
+}
+
+#define ebitmap_for_each_bit(e, n, bit) \
+       for (bit = ebitmap_start(e, &n); bit < ebitmap_length(e); bit = ebitmap_next(&n, bit)) \
+
 int ebitmap_cmp(struct ebitmap *e1, struct ebitmap *e2);
 int ebitmap_cpy(struct ebitmap *dst, struct ebitmap *src);
 int ebitmap_contains(struct ebitmap *e1, struct ebitmap *e2);
index d4c32c39ccc9db9533eb1fb60f495edeb94fe77d..aaefac2921f1d94cedbd33f29afa631796e28503 100644 (file)
@@ -27,6 +27,7 @@
 int mls_compute_context_len(struct context * context)
 {
        int i, l, len, range;
+       struct ebitmap_node *node;
 
        if (!selinux_mls_enabled)
                return 0;
@@ -36,24 +37,24 @@ int mls_compute_context_len(struct context * context)
                range = 0;
                len += strlen(policydb.p_sens_val_to_name[context->range.level[l].sens - 1]);
 
-               for (i = 1; i <= ebitmap_length(&context->range.level[l].cat); i++) {
-                       if (ebitmap_get_bit(&context->range.level[l].cat, i - 1)) {
+               ebitmap_for_each_bit(&context->range.level[l].cat, node, i) {
+                       if (ebitmap_node_get_bit(node, i)) {
                                if (range) {
                                        range++;
                                        continue;
                                }
 
-                               len += strlen(policydb.p_cat_val_to_name[i - 1]) + 1;
+                               len += strlen(policydb.p_cat_val_to_name[i]) + 1;
                                range++;
                        } else {
                                if (range > 1)
-                                       len += strlen(policydb.p_cat_val_to_name[i - 2]) + 1;
+                                       len += strlen(policydb.p_cat_val_to_name[i - 1]) + 1;
                                range = 0;
                        }
                }
                /* Handle case where last category is the end of range */
                if (range > 1)
-                       len += strlen(policydb.p_cat_val_to_name[i - 2]) + 1;
+                       len += strlen(policydb.p_cat_val_to_name[i - 1]) + 1;
 
                if (l == 0) {
                        if (mls_level_eq(&context->range.level[0],
@@ -77,6 +78,7 @@ void mls_sid_to_context(struct context *context,
 {
        char *scontextp;
        int i, l, range, wrote_sep;
+       struct ebitmap_node *node;
 
        if (!selinux_mls_enabled)
                return;
@@ -94,8 +96,8 @@ void mls_sid_to_context(struct context *context,
                scontextp += strlen(policydb.p_sens_val_to_name[context->range.level[l].sens - 1]);
 
                /* categories */
-               for (i = 1; i <= ebitmap_length(&context->range.level[l].cat); i++) {
-                       if (ebitmap_get_bit(&context->range.level[l].cat, i - 1)) {
+               ebitmap_for_each_bit(&context->range.level[l].cat, node, i) {
+                       if (ebitmap_node_get_bit(node, i)) {
                                if (range) {
                                        range++;
                                        continue;
@@ -106,8 +108,8 @@ void mls_sid_to_context(struct context *context,
                                        wrote_sep = 1;
                                } else
                                        *scontextp++ = ',';
-                               strcpy(scontextp, policydb.p_cat_val_to_name[i - 1]);
-                               scontextp += strlen(policydb.p_cat_val_to_name[i - 1]);
+                               strcpy(scontextp, policydb.p_cat_val_to_name[i]);
+                               scontextp += strlen(policydb.p_cat_val_to_name[i]);
                                range++;
                        } else {
                                if (range > 1) {
@@ -116,8 +118,8 @@ void mls_sid_to_context(struct context *context,
                                        else
                                                *scontextp++ = ',';
 
-                                       strcpy(scontextp, policydb.p_cat_val_to_name[i - 2]);
-                                       scontextp += strlen(policydb.p_cat_val_to_name[i - 2]);
+                                       strcpy(scontextp, policydb.p_cat_val_to_name[i - 1]);
+                                       scontextp += strlen(policydb.p_cat_val_to_name[i - 1]);
                                }
                                range = 0;
                        }
@@ -130,8 +132,8 @@ void mls_sid_to_context(struct context *context,
                        else
                                *scontextp++ = ',';
 
-                       strcpy(scontextp, policydb.p_cat_val_to_name[i - 2]);
-                       scontextp += strlen(policydb.p_cat_val_to_name[i - 2]);
+                       strcpy(scontextp, policydb.p_cat_val_to_name[i - 1]);
+                       scontextp += strlen(policydb.p_cat_val_to_name[i - 1]);
                }
 
                if (l == 0) {
@@ -157,6 +159,7 @@ int mls_context_isvalid(struct policydb *p, struct context *c)
 {
        struct level_datum *levdatum;
        struct user_datum *usrdatum;
+       struct ebitmap_node *node;
        int i, l;
 
        if (!selinux_mls_enabled)
@@ -179,11 +182,11 @@ int mls_context_isvalid(struct policydb *p, struct context *c)
                if (!levdatum)
                        return 0;
 
-               for (i = 1; i <= ebitmap_length(&c->range.level[l].cat); i++) {
-                       if (ebitmap_get_bit(&c->range.level[l].cat, i - 1)) {
+               ebitmap_for_each_bit(&c->range.level[l].cat, node, i) {
+                       if (ebitmap_node_get_bit(node, i)) {
                                if (i > p->p_cats.nprim)
                                        return 0;
-                               if (!ebitmap_get_bit(&levdatum->level->cat, i - 1))
+                               if (!ebitmap_get_bit(&levdatum->level->cat, i))
                                        /*
                                         * Category may not be associated with
                                         * sensitivity in low level.
@@ -468,6 +471,7 @@ int mls_convert_context(struct policydb *oldp,
        struct level_datum *levdatum;
        struct cat_datum *catdatum;
        struct ebitmap bitmap;
+       struct ebitmap_node *node;
        int l, i;
 
        if (!selinux_mls_enabled)
@@ -482,12 +486,12 @@ int mls_convert_context(struct policydb *oldp,
                c->range.level[l].sens = levdatum->level->sens;
 
                ebitmap_init(&bitmap);
-               for (i = 1; i <= ebitmap_length(&c->range.level[l].cat); i++) {
-                       if (ebitmap_get_bit(&c->range.level[l].cat, i - 1)) {
+               ebitmap_for_each_bit(&c->range.level[l].cat, node, i) {
+                       if (ebitmap_node_get_bit(node, i)) {
                                int rc;
 
                                catdatum = hashtab_search(newp->p_cats.table,
-                                               oldp->p_cat_val_to_name[i - 1]);
+                                               oldp->p_cat_val_to_name[i]);
                                if (!catdatum)
                                        return -EINVAL;
                                rc = ebitmap_set_bit(&bitmap, catdatum->value - 1, 1);
index 785c33cf486491afc6b2d50d568d5db884b31723..0a758323a9cf61b10678d7308a87fc05316129cf 100644 (file)
@@ -91,6 +91,11 @@ static struct policydb_compat_info policydb_compat[] = {
                .sym_num        = SYM_NUM,
                .ocon_num       = OCON_NUM,
        },
+       {
+               .version        = POLICYDB_VERSION_AVTAB,
+               .sym_num        = SYM_NUM,
+               .ocon_num       = OCON_NUM,
+       },
 };
 
 static struct policydb_compat_info *policydb_lookup_compat(int version)
@@ -584,6 +589,9 @@ void policydb_destroy(struct policydb *p)
        struct ocontext *c, *ctmp;
        struct genfs *g, *gtmp;
        int i;
+       struct role_allow *ra, *lra = NULL;
+       struct role_trans *tr, *ltr = NULL;
+       struct range_trans *rt, *lrt = NULL;
 
        for (i = 0; i < SYM_NUM; i++) {
                hashtab_map(p->symtab[i].table, destroy_f[i], NULL);
@@ -624,6 +632,28 @@ void policydb_destroy(struct policydb *p)
 
        cond_policydb_destroy(p);
 
+       for (tr = p->role_tr; tr; tr = tr->next) {
+               if (ltr) kfree(ltr);
+               ltr = tr;
+       }
+       if (ltr) kfree(ltr);
+
+       for (ra = p->role_allow; ra; ra = ra -> next) {
+               if (lra) kfree(lra);
+               lra = ra;
+       }
+       if (lra) kfree(lra);
+
+       for (rt = p->range_tr; rt; rt = rt -> next) {
+               if (lrt) kfree(lrt);
+               lrt = rt;
+       }
+       if (lrt) kfree(lrt);
+
+       for (i = 0; i < p->p_types.nprim; i++)
+               ebitmap_destroy(&p->type_attr_map[i]);
+       kfree(p->type_attr_map);
+
        return;
 }
 
@@ -714,7 +744,8 @@ int policydb_context_isvalid(struct policydb *p, struct context *c)
  */
 static int mls_read_range_helper(struct mls_range *r, void *fp)
 {
-       u32 buf[2], items;
+       __le32 buf[2];
+       u32 items;
        int rc;
 
        rc = next_entry(buf, fp, sizeof(u32));
@@ -775,7 +806,7 @@ static int context_read_and_validate(struct context *c,
                                     struct policydb *p,
                                     void *fp)
 {
-       u32 buf[3];
+       __le32 buf[3];
        int rc;
 
        rc = next_entry(buf, fp, sizeof buf);
@@ -815,7 +846,8 @@ static int perm_read(struct policydb *p, struct hashtab *h, void *fp)
        char *key = NULL;
        struct perm_datum *perdatum;
        int rc;
-       u32 buf[2], len;
+       __le32 buf[2];
+       u32 len;
 
        perdatum = kmalloc(sizeof(*perdatum), GFP_KERNEL);
        if (!perdatum) {
@@ -855,7 +887,8 @@ static int common_read(struct policydb *p, struct hashtab *h, void *fp)
 {
        char *key = NULL;
        struct common_datum *comdatum;
-       u32 buf[4], len, nel;
+       __le32 buf[4];
+       u32 len, nel;
        int i, rc;
 
        comdatum = kmalloc(sizeof(*comdatum), GFP_KERNEL);
@@ -909,7 +942,8 @@ static int read_cons_helper(struct constraint_node **nodep, int ncons,
 {
        struct constraint_node *c, *lc;
        struct constraint_expr *e, *le;
-       u32 buf[3], nexpr;
+       __le32 buf[3];
+       u32 nexpr;
        int rc, i, j, depth;
 
        lc = NULL;
@@ -993,7 +1027,8 @@ static int class_read(struct policydb *p, struct hashtab *h, void *fp)
 {
        char *key = NULL;
        struct class_datum *cladatum;
-       u32 buf[6], len, len2, ncons, nel;
+       __le32 buf[6];
+       u32 len, len2, ncons, nel;
        int i, rc;
 
        cladatum = kmalloc(sizeof(*cladatum), GFP_KERNEL);
@@ -1087,7 +1122,8 @@ static int role_read(struct policydb *p, struct hashtab *h, void *fp)
        char *key = NULL;
        struct role_datum *role;
        int rc;
-       u32 buf[2], len;
+       __le32 buf[2];
+       u32 len;
 
        role = kmalloc(sizeof(*role), GFP_KERNEL);
        if (!role) {
@@ -1147,7 +1183,8 @@ static int type_read(struct policydb *p, struct hashtab *h, void *fp)
        char *key = NULL;
        struct type_datum *typdatum;
        int rc;
-       u32 buf[3], len;
+       __le32 buf[3];
+       u32 len;
 
        typdatum = kmalloc(sizeof(*typdatum),GFP_KERNEL);
        if (!typdatum) {
@@ -1191,7 +1228,7 @@ bad:
  */
 static int mls_read_level(struct mls_level *lp, void *fp)
 {
-       u32 buf[1];
+       __le32 buf[1];
        int rc;
 
        memset(lp, 0, sizeof(*lp));
@@ -1219,7 +1256,8 @@ static int user_read(struct policydb *p, struct hashtab *h, void *fp)
        char *key = NULL;
        struct user_datum *usrdatum;
        int rc;
-       u32 buf[2], len;
+       __le32 buf[2];
+       u32 len;
 
        usrdatum = kmalloc(sizeof(*usrdatum), GFP_KERNEL);
        if (!usrdatum) {
@@ -1273,7 +1311,8 @@ static int sens_read(struct policydb *p, struct hashtab *h, void *fp)
        char *key = NULL;
        struct level_datum *levdatum;
        int rc;
-       u32 buf[2], len;
+       __le32 buf[2];
+       u32 len;
 
        levdatum = kmalloc(sizeof(*levdatum), GFP_ATOMIC);
        if (!levdatum) {
@@ -1324,7 +1363,8 @@ static int cat_read(struct policydb *p, struct hashtab *h, void *fp)
        char *key = NULL;
        struct cat_datum *catdatum;
        int rc;
-       u32 buf[3], len;
+       __le32 buf[3];
+       u32 len;
 
        catdatum = kmalloc(sizeof(*catdatum), GFP_ATOMIC);
        if (!catdatum) {
@@ -1387,7 +1427,8 @@ int policydb_read(struct policydb *p, void *fp)
        struct ocontext *l, *c, *newc;
        struct genfs *genfs_p, *genfs, *newgenfs;
        int i, j, rc;
-       u32 buf[8], len, len2, config, nprim, nel, nel2;
+       __le32 buf[8];
+       u32 len, len2, config, nprim, nel, nel2;
        char *policydb_str;
        struct policydb_compat_info *info;
        struct range_trans *rt, *lrt;
@@ -1403,17 +1444,14 @@ int policydb_read(struct policydb *p, void *fp)
        if (rc < 0)
                goto bad;
 
-       for (i = 0; i < 2; i++)
-               buf[i] = le32_to_cpu(buf[i]);
-
-       if (buf[0] != POLICYDB_MAGIC) {
+       if (le32_to_cpu(buf[0]) != POLICYDB_MAGIC) {
                printk(KERN_ERR "security:  policydb magic number 0x%x does "
                       "not match expected magic number 0x%x\n",
-                      buf[0], POLICYDB_MAGIC);
+                      le32_to_cpu(buf[0]), POLICYDB_MAGIC);
                goto bad;
        }
 
-       len = buf[1];
+       len = le32_to_cpu(buf[1]);
        if (len != strlen(POLICYDB_STRING)) {
                printk(KERN_ERR "security:  policydb string length %d does not "
                       "match expected length %Zu\n",
@@ -1448,19 +1486,17 @@ int policydb_read(struct policydb *p, void *fp)
        rc = next_entry(buf, fp, sizeof(u32)*4);
        if (rc < 0)
                goto bad;
-       for (i = 0; i < 4; i++)
-               buf[i] = le32_to_cpu(buf[i]);
 
-       p->policyvers = buf[0];
+       p->policyvers = le32_to_cpu(buf[0]);
        if (p->policyvers < POLICYDB_VERSION_MIN ||
            p->policyvers > POLICYDB_VERSION_MAX) {
                printk(KERN_ERR "security:  policydb version %d does not match "
                       "my version range %d-%d\n",
-                      buf[0], POLICYDB_VERSION_MIN, POLICYDB_VERSION_MAX);
+                      le32_to_cpu(buf[0]), POLICYDB_VERSION_MIN, POLICYDB_VERSION_MAX);
                goto bad;
        }
 
-       if ((buf[1] & POLICYDB_CONFIG_MLS)) {
+       if ((le32_to_cpu(buf[1]) & POLICYDB_CONFIG_MLS)) {
                if (ss_initialized && !selinux_mls_enabled) {
                        printk(KERN_ERR "Cannot switch between non-MLS and MLS "
                               "policies\n");
@@ -1489,9 +1525,11 @@ int policydb_read(struct policydb *p, void *fp)
                goto bad;
        }
 
-       if (buf[2] != info->sym_num || buf[3] != info->ocon_num) {
+       if (le32_to_cpu(buf[2]) != info->sym_num ||
+               le32_to_cpu(buf[3]) != info->ocon_num) {
                printk(KERN_ERR "security:  policydb table sizes (%d,%d) do "
-                      "not match mine (%d,%d)\n", buf[2], buf[3],
+                      "not match mine (%d,%d)\n", le32_to_cpu(buf[2]),
+                       le32_to_cpu(buf[3]),
                       info->sym_num, info->ocon_num);
                goto bad;
        }
@@ -1511,7 +1549,7 @@ int policydb_read(struct policydb *p, void *fp)
                p->symtab[i].nprim = nprim;
        }
 
-       rc = avtab_read(&p->te_avtab, fp, config);
+       rc = avtab_read(&p->te_avtab, fp, p->policyvers);
        if (rc)
                goto bad;
 
@@ -1825,6 +1863,21 @@ int policydb_read(struct policydb *p, void *fp)
                }
        }
 
+       p->type_attr_map = kmalloc(p->p_types.nprim*sizeof(struct ebitmap), GFP_KERNEL);
+       if (!p->type_attr_map)
+               goto bad;
+
+       for (i = 0; i < p->p_types.nprim; i++) {
+               ebitmap_init(&p->type_attr_map[i]);
+               if (p->policyvers >= POLICYDB_VERSION_AVTAB) {
+                       if (ebitmap_read(&p->type_attr_map[i], fp))
+                               goto bad;
+               }
+               /* add the type itself as the degenerate case */
+               if (ebitmap_set_bit(&p->type_attr_map[i], i, 1))
+                               goto bad;
+       }
+
        rc = 0;
 out:
        return rc;
index 2470e2a1a1c3cab1c18a38617025025f82e7a5b1..b1340711f721b71954806a4f858e60d99d0617cd 100644 (file)
@@ -237,6 +237,9 @@ struct policydb {
        /* range transitions */
        struct range_trans *range_tr;
 
+       /* type -> attribute reverse mapping */
+       struct ebitmap *type_attr_map;
+
        unsigned int policyvers;
 };
 
index 014120474e69915f48aee0d99243b8817e7aed9d..92b89dc99bcd72a5e3bc51ee24795b434475317f 100644 (file)
@@ -266,8 +266,11 @@ static int context_struct_compute_av(struct context *scontext,
        struct constraint_node *constraint;
        struct role_allow *ra;
        struct avtab_key avkey;
-       struct avtab_datum *avdatum;
+       struct avtab_node *node;
        struct class_datum *tclass_datum;
+       struct ebitmap *sattr, *tattr;
+       struct ebitmap_node *snode, *tnode;
+       unsigned int i, j;
 
        /*
         * Remap extended Netlink classes for old policy versions.
@@ -300,21 +303,34 @@ static int context_struct_compute_av(struct context *scontext,
         * If a specific type enforcement rule was defined for
         * this permission check, then use it.
         */
-       avkey.source_type = scontext->type;
-       avkey.target_type = tcontext->type;
        avkey.target_class = tclass;
-       avdatum = avtab_search(&policydb.te_avtab, &avkey, AVTAB_AV);
-       if (avdatum) {
-               if (avdatum->specified & AVTAB_ALLOWED)
-                       avd->allowed = avtab_allowed(avdatum);
-               if (avdatum->specified & AVTAB_AUDITDENY)
-                       avd->auditdeny = avtab_auditdeny(avdatum);
-               if (avdatum->specified & AVTAB_AUDITALLOW)
-                       avd->auditallow = avtab_auditallow(avdatum);
-       }
+       avkey.specified = AVTAB_AV;
+       sattr = &policydb.type_attr_map[scontext->type - 1];
+       tattr = &policydb.type_attr_map[tcontext->type - 1];
+       ebitmap_for_each_bit(sattr, snode, i) {
+               if (!ebitmap_node_get_bit(snode, i))
+                       continue;
+               ebitmap_for_each_bit(tattr, tnode, j) {
+                       if (!ebitmap_node_get_bit(tnode, j))
+                               continue;
+                       avkey.source_type = i + 1;
+                       avkey.target_type = j + 1;
+                       for (node = avtab_search_node(&policydb.te_avtab, &avkey);
+                            node != NULL;
+                            node = avtab_search_node_next(node, avkey.specified)) {
+                               if (node->key.specified == AVTAB_ALLOWED)
+                                       avd->allowed |= node->datum.data;
+                               else if (node->key.specified == AVTAB_AUDITALLOW)
+                                       avd->auditallow |= node->datum.data;
+                               else if (node->key.specified == AVTAB_AUDITDENY)
+                                       avd->auditdeny &= node->datum.data;
+                       }
 
-       /* Check conditional av table for additional permissions */
-       cond_compute_av(&policydb.te_cond_avtab, &avkey, avd);
+                       /* Check conditional av table for additional permissions */
+                       cond_compute_av(&policydb.te_cond_avtab, &avkey, avd);
+
+               }
+       }
 
        /*
         * Remove any permissions prohibited by a constraint (this includes
@@ -797,7 +813,6 @@ static int security_compute_sid(u32 ssid,
        struct avtab_key avkey;
        struct avtab_datum *avdatum;
        struct avtab_node *node;
-       unsigned int type_change = 0;
        int rc = 0;
 
        if (!ss_initialized) {
@@ -862,33 +877,23 @@ static int security_compute_sid(u32 ssid,
        avkey.source_type = scontext->type;
        avkey.target_type = tcontext->type;
        avkey.target_class = tclass;
-       avdatum = avtab_search(&policydb.te_avtab, &avkey, AVTAB_TYPE);
+       avkey.specified = specified;
+       avdatum = avtab_search(&policydb.te_avtab, &avkey);
 
        /* If no permanent rule, also check for enabled conditional rules */
        if(!avdatum) {
-               node = avtab_search_node(&policydb.te_cond_avtab, &avkey, specified);
+               node = avtab_search_node(&policydb.te_cond_avtab, &avkey);
                for (; node != NULL; node = avtab_search_node_next(node, specified)) {
-                       if (node->datum.specified & AVTAB_ENABLED) {
+                       if (node->key.specified & AVTAB_ENABLED) {
                                avdatum = &node->datum;
                                break;
                        }
                }
        }
 
-       type_change = (avdatum && (avdatum->specified & specified));
-       if (type_change) {
+       if (avdatum) {
                /* Use the type from the type transition/member/change rule. */
-               switch (specified) {
-               case AVTAB_TRANSITION:
-                       newcontext.type = avtab_transition(avdatum);
-                       break;
-               case AVTAB_MEMBER:
-                       newcontext.type = avtab_member(avdatum);
-                       break;
-               case AVTAB_CHANGE:
-                       newcontext.type = avtab_change(avdatum);
-                       break;
-               }
+               newcontext.type = avdatum->data;
        }
 
        /* Check for class-specific changes. */
@@ -1502,6 +1507,7 @@ int security_get_user_sids(u32 fromsid,
        struct user_datum *user;
        struct role_datum *role;
        struct av_decision avd;
+       struct ebitmap_node *rnode, *tnode;
        int rc = 0, i, j;
 
        if (!ss_initialized) {
@@ -1532,13 +1538,13 @@ int security_get_user_sids(u32 fromsid,
        }
        memset(mysids, 0, maxnel*sizeof(*mysids));
 
-       for (i = ebitmap_startbit(&user->roles); i < ebitmap_length(&user->roles); i++) {
-               if (!ebitmap_get_bit(&user->roles, i))
+       ebitmap_for_each_bit(&user->roles, rnode, i) {
+               if (!ebitmap_node_get_bit(rnode, i))
                        continue;
                role = policydb.role_val_to_struct[i];
                usercon.role = i+1;
-               for (j = ebitmap_startbit(&role->types); j < ebitmap_length(&role->types); j++) {
-                       if (!ebitmap_get_bit(&role->types, j))
+               ebitmap_for_each_bit(&role->types, tnode, j) {
+                       if (!ebitmap_node_get_bit(tnode, j))
                                continue;
                        usercon.type = j+1;
 
index 904d17394e1c595593f0a60beec7a4f41c493e31..188df085b7ee5d4ae21903bebd1b6381b48cdc6a 100644 (file)
@@ -1427,7 +1427,7 @@ static int snd_atiixp_suspend(snd_card_t *card, pm_message_t state)
        snd_atiixp_aclink_down(chip);
        snd_atiixp_chip_stop(chip);
 
-       pci_set_power_state(chip->pci, 3);
+       pci_set_power_state(chip->pci, PCI_D3hot);
        pci_disable_device(chip->pci);
        return 0;
 }
@@ -1438,7 +1438,7 @@ static int snd_atiixp_resume(snd_card_t *card)
        int i;
 
        pci_enable_device(chip->pci);
-       pci_set_power_state(chip->pci, 0);
+       pci_set_power_state(chip->pci, PCI_D0);
        pci_set_master(chip->pci);
 
        snd_atiixp_aclink_reset(chip);
diff --git a/usr/Kconfig b/usr/Kconfig
new file mode 100644 (file)
index 0000000..07727f3
--- /dev/null
@@ -0,0 +1,46 @@
+#
+# Configuration for initramfs
+#
+
+config INITRAMFS_SOURCE
+       string "Initramfs source file(s)"
+       default ""
+       help
+         This can be either a single cpio archive with a .cpio suffix or a
+         space-separated list of directories and files for building the
+         initramfs image.  A cpio archive should contain a filesystem archive
+         to be used as an initramfs image.  Directories should contain a
+         filesystem layout to be included in the initramfs image.  Files
+         should contain entries according to the format described by the
+         "usr/gen_init_cpio" program in the kernel tree.
+
+         When multiple directories and files are specified then the
+         initramfs image will be the aggregate of all of them.
+
+         See <file:Documentation/early-userspace/README for more details.
+
+         If you are not sure, leave it blank.
+
+config INITRAMFS_ROOT_UID
+       int "User ID to map to 0 (user root)"
+       depends on INITRAMFS_SOURCE!=""
+       default "0"
+       help
+         This setting is only meaningful if the INITRAMFS_SOURCE is
+         contains a directory.  Setting this user ID (UID) to something
+         other than "0" will cause all files owned by that UID to be
+         owned by user root in the initial ramdisk image.
+
+         If you are not sure, leave it set to "0".
+
+config INITRAMFS_ROOT_GID
+       int "Group ID to map to 0 (group root)"
+       depends on INITRAMFS_SOURCE!=""
+       default "0"
+       help
+         This setting is only meaningful if the INITRAMFS_SOURCE is
+         contains a directory.  Setting this group ID (GID) to something
+         other than "0" will cause all files owned by that GID to be
+         owned by group root in the initial ramdisk image.
+
+         If you are not sure, leave it set to "0".
index 248d5551029d5e78823f8c93835685946e46675c..e2129cb570bba89a6790afaa045e7aad65300f34 100644 (file)
@@ -27,7 +27,7 @@ quotefixed_initramfs_source := $(shell echo $(CONFIG_INITRAMFS_SOURCE))
 filechk_initramfs_list = $(CONFIG_SHELL) \
  $(srctree)/scripts/gen_initramfs_list.sh $(gen_initramfs_args) $(quotefixed_initramfs_source)
 
-$(obj)/initramfs_list: FORCE
+$(obj)/initramfs_list: $(obj)/Makefile FORCE
        $(call filechk,initramfs_list)
 
 quiet_cmd_cpio = CPIO    $@