aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/feature-removal-schedule.txt7
-rw-r--r--Documentation/md.txt72
-rw-r--r--Documentation/spinlocks.txt184
-rw-r--r--Documentation/sysctl/kernel.txt31
-rw-r--r--MAINTAINERS1
-rw-r--r--arch/arm/Kconfig5
-rw-r--r--arch/arm/Kconfig.debug8
-rw-r--r--arch/arm/configs/zeus_defconfig2032
-rw-r--r--arch/arm/kernel/Makefile1
-rw-r--r--arch/arm/kernel/early_printk.c57
-rw-r--r--arch/arm/kernel/smp_twd.c1
-rw-r--r--arch/arm/mach-clps711x/include/mach/memory.h2
-rw-r--r--arch/arm/mach-footbridge/common.c22
-rw-r--r--arch/arm/mach-footbridge/include/mach/memory.h15
-rw-r--r--arch/arm/mach-integrator/include/mach/memory.h3
-rw-r--r--arch/arm/mach-ixp2000/include/mach/memory.h12
-rw-r--r--arch/arm/mach-ixp23xx/include/mach/memory.h19
-rw-r--r--arch/arm/mach-lh7a40x/clocks.c8
-rw-r--r--arch/arm/mach-omap2/board-2430sdp.c2
-rw-r--r--arch/arm/mach-omap2/board-3430sdp.c2
-rw-r--r--arch/arm/mach-omap2/board-ldp.c2
-rw-r--r--arch/arm/mach-omap2/board-omap3beagle.c2
-rw-r--r--arch/arm/mach-omap2/board-omap3pandora.c2
-rw-r--r--arch/arm/mach-omap2/board-overo.c2
-rw-r--r--arch/arm/mach-omap2/board-rx51-peripherals.c118
-rw-r--r--arch/arm/mach-pxa/Kconfig14
-rw-r--r--arch/arm/mach-pxa/Makefile1
-rw-r--r--arch/arm/mach-pxa/em-x270.c11
-rw-r--r--arch/arm/mach-pxa/include/mach/arcom-pcmcia.h11
-rw-r--r--arch/arm/mach-pxa/include/mach/viper.h2
-rw-r--r--arch/arm/mach-pxa/include/mach/zeus.h82
-rw-r--r--arch/arm/mach-pxa/viper.c20
-rw-r--r--arch/arm/mach-pxa/zeus.c820
-rw-r--r--arch/arm/mach-realview/Kconfig2
-rw-r--r--arch/arm/mach-s3c24a0/include/mach/memory.h2
-rw-r--r--arch/arm/mach-sa1100/Kconfig13
-rw-r--r--arch/arm/mach-sa1100/generic.c12
-rw-r--r--arch/arm/mach-w90x900/include/mach/nuc900_spi.h35
-rw-r--r--arch/arm/plat-omap/include/plat/irqs.h16
-rw-r--r--arch/arm/vfp/vfpmodule.c83
-rw-r--r--arch/ia64/Kconfig3
-rw-r--r--arch/ia64/include/asm/meminit.h2
-rw-r--r--arch/ia64/include/asm/pgtable.h3
-rw-r--r--arch/ia64/include/asm/processor.h6
-rw-r--r--arch/ia64/kernel/acpi.c33
-rw-r--r--arch/ia64/kernel/head.S4
-rw-r--r--arch/ia64/kernel/ia64_ksyms.c2
-rw-r--r--arch/ia64/kernel/mca_asm.S2
-rw-r--r--arch/ia64/kernel/relocate_kernel.S2
-rw-r--r--arch/ia64/kernel/setup.c27
-rw-r--r--arch/ia64/kernel/vmlinux.lds.S11
-rw-r--r--arch/ia64/mm/contig.c99
-rw-r--r--arch/ia64/mm/discontig.c129
-rw-r--r--arch/ia64/mm/init.c4
-rw-r--r--arch/ia64/sn/kernel/sn2/sn2_smp.c8
-rw-r--r--arch/ia64/xen/irq_xen.c131
-rw-r--r--arch/ia64/xen/time.c22
-rw-r--r--arch/m68k/include/asm/pgtable_mm.h4
-rw-r--r--arch/m68k/sun3/mmu_emu.c8
-rw-r--r--arch/microblaze/Kconfig19
-rw-r--r--arch/microblaze/Kconfig.debug3
-rw-r--r--arch/microblaze/Makefile2
-rw-r--r--arch/microblaze/boot/Makefile15
-rw-r--r--arch/microblaze/include/asm/cache.h16
-rw-r--r--arch/microblaze/include/asm/cacheflush.h123
-rw-r--r--arch/microblaze/include/asm/cpuinfo.h5
-rw-r--r--arch/microblaze/include/asm/device.h12
-rw-r--r--arch/microblaze/include/asm/ftrace.h25
-rw-r--r--arch/microblaze/include/asm/futex.h127
-rw-r--r--arch/microblaze/include/asm/irqflags.h112
-rw-r--r--arch/microblaze/include/asm/page.h3
-rw-r--r--arch/microblaze/include/asm/pgalloc.h9
-rw-r--r--arch/microblaze/include/asm/pvr.h30
-rw-r--r--arch/microblaze/include/asm/setup.h2
-rw-r--r--arch/microblaze/include/asm/system.h2
-rw-r--r--arch/microblaze/include/asm/uaccess.h12
-rw-r--r--arch/microblaze/kernel/Makefile14
-rw-r--r--arch/microblaze/kernel/cpu/Makefile4
-rw-r--r--arch/microblaze/kernel/cpu/cache.c663
-rw-r--r--arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c15
-rw-r--r--arch/microblaze/kernel/cpu/cpuinfo-static.c17
-rw-r--r--arch/microblaze/kernel/cpu/cpuinfo.c7
-rw-r--r--arch/microblaze/kernel/cpu/mb.c8
-rw-r--r--arch/microblaze/kernel/cpu/pvr.c2
-rw-r--r--arch/microblaze/kernel/entry-nommu.S2
-rw-r--r--arch/microblaze/kernel/entry.S19
-rw-r--r--arch/microblaze/kernel/ftrace.c237
-rw-r--r--arch/microblaze/kernel/heartbeat.c15
-rw-r--r--arch/microblaze/kernel/intc.c10
-rw-r--r--arch/microblaze/kernel/mcount.S170
-rw-r--r--arch/microblaze/kernel/microblaze_ksyms.c5
-rw-r--r--arch/microblaze/kernel/process.c1
-rw-r--r--arch/microblaze/kernel/reset.c140
-rw-r--r--arch/microblaze/kernel/setup.c40
-rw-r--r--arch/microblaze/kernel/signal.c35
-rw-r--r--arch/microblaze/kernel/stacktrace.c65
-rw-r--r--arch/microblaze/kernel/syscall_table.S4
-rw-r--r--arch/microblaze/kernel/timer.c28
-rw-r--r--arch/microblaze/kernel/vmlinux.lds.S6
-rw-r--r--arch/microblaze/lib/uaccess.c7
-rw-r--r--arch/microblaze/mm/init.c1
-rw-r--r--arch/microblaze/mm/pgtable.c10
-rw-r--r--arch/microblaze/oprofile/Makefile13
-rw-r--r--arch/microblaze/oprofile/microblaze_oprofile.c22
-rw-r--r--arch/microblaze/platform/Kconfig.platform21
-rw-r--r--arch/microblaze/platform/generic/Kconfig.auto29
-rw-r--r--arch/microblaze/platform/generic/system.dts38
-rw-r--r--arch/microblaze/platform/platform.c2
-rw-r--r--arch/mn10300/kernel/kprobes.c61
-rw-r--r--arch/powerpc/include/asm/smp.h2
-rw-r--r--arch/powerpc/kernel/perf_callchain.c4
-rw-r--r--arch/powerpc/kernel/setup-common.c4
-rw-r--r--arch/powerpc/kernel/smp.c2
-rw-r--r--arch/powerpc/platforms/cell/interrupt.c14
-rw-r--r--arch/powerpc/platforms/pseries/dtl.c4
-rw-r--r--arch/sparc/kernel/nmi.c8
-rw-r--r--arch/x86/include/asm/irq_vectors.h2
-rw-r--r--arch/x86/include/asm/msr.h3
-rw-r--r--arch/x86/include/asm/percpu.h104
-rw-r--r--arch/x86/include/asm/trampoline.h1
-rw-r--r--arch/x86/kernel/aperture_64.c11
-rw-r--r--arch/x86/kernel/apic/apic.c2
-rw-r--r--arch/x86/kernel/apic/nmi.c8
-rw-r--r--arch/x86/kernel/cpu/addon_cpuid_features.c15
-rw-r--r--arch/x86/kernel/cpu/amd.c2
-rw-r--r--arch/x86/kernel/cpu/common.c16
-rw-r--r--arch/x86/kernel/cpu/cpu_debug.c30
-rw-r--r--arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c28
-rw-r--r--arch/x86/kernel/cpu/intel.c2
-rw-r--r--arch/x86/kernel/cpu/intel_cacheinfo.c67
-rw-r--r--arch/x86/kernel/cpu/mcheck/therm_throt.c20
-rw-r--r--arch/x86/kernel/ds.c4
-rw-r--r--arch/x86/kernel/e820.c11
-rw-r--r--arch/x86/kernel/head32.c2
-rw-r--r--arch/x86/kernel/head64.c2
-rw-r--r--arch/x86/kernel/mpparse.c3
-rw-r--r--arch/x86/kernel/pci-dma.c5
-rw-r--r--arch/x86/kernel/pci-gart_64.c3
-rw-r--r--arch/x86/kernel/setup.c13
-rw-r--r--arch/x86/kernel/smpboot.c45
-rw-r--r--arch/x86/kernel/trampoline.c20
-rw-r--r--arch/x86/kvm/svm.c64
-rw-r--r--arch/x86/lib/msr.c26
-rw-r--r--arch/x86/mm/mmio-mod.c2
-rw-r--r--arch/x86/xen/smp.c41
-rw-r--r--arch/x86/xen/time.c24
-rw-r--r--crypto/cryptd.c2
-rw-r--r--drivers/base/cpu.c2
-rw-r--r--drivers/char/nvram.c14
-rw-r--r--drivers/cpufreq/cpufreq.c16
-rw-r--r--drivers/cpufreq/freq_table.c12
-rw-r--r--drivers/crypto/padlock-aes.c12
-rw-r--r--drivers/dma/dmaengine.c36
-rw-r--r--drivers/edac/amd64_edac.c46
-rw-r--r--drivers/gpio/adp5520-gpio.c36
-rw-r--r--drivers/gpio/twl4030-gpio.c20
-rw-r--r--drivers/gpio/wm831x-gpio.c17
-rw-r--r--drivers/infiniband/hw/ehca/ehca_irq.c3
-rw-r--r--drivers/input/keyboard/Kconfig10
-rw-r--r--drivers/input/keyboard/Makefile1
-rw-r--r--drivers/input/keyboard/adp5520-keys.c220
-rw-r--r--drivers/input/keyboard/twl4030_keypad.c6
-rw-r--r--drivers/input/misc/pcf50633-input.c7
-rw-r--r--drivers/input/misc/twl4030-pwrbutton.c4
-rw-r--r--drivers/isdn/hardware/avm/avm_cs.c3
-rw-r--r--drivers/isdn/hisax/avma1_cs.c3
-rw-r--r--drivers/isdn/hisax/elsa_cs.c2
-rw-r--r--drivers/isdn/hisax/sedlbauer_cs.c2
-rw-r--r--drivers/isdn/hisax/teles_cs.c2
-rw-r--r--drivers/lguest/x86/core.c6
-rw-r--r--drivers/md/Kconfig9
-rw-r--r--drivers/md/bitmap.c449
-rw-r--r--drivers/md/bitmap.h19
-rw-r--r--drivers/md/faulty.c1
-rw-r--r--drivers/md/linear.c3
-rw-r--r--drivers/md/md.c393
-rw-r--r--drivers/md/md.h51
-rw-r--r--drivers/md/multipath.c3
-rw-r--r--drivers/md/raid0.c3
-rw-r--r--drivers/md/raid1.c217
-rw-r--r--drivers/md/raid1.h5
-rw-r--r--drivers/md/raid10.c116
-rw-r--r--drivers/md/raid5.c63
-rw-r--r--drivers/md/raid6algos.c20
-rw-r--r--drivers/mfd/88pm8607.c302
-rw-r--r--drivers/mfd/Kconfig41
-rw-r--r--drivers/mfd/Makefile6
-rw-r--r--drivers/mfd/ab3100-core.c3
-rw-r--r--drivers/mfd/ab4500-core.c208
-rw-r--r--drivers/mfd/adp5520.c379
-rw-r--r--drivers/mfd/asic3.c2
-rw-r--r--drivers/mfd/ezx-pcap.c1
-rw-r--r--drivers/mfd/mc13783-core.c757
-rw-r--r--drivers/mfd/pcf50633-adc.c5
-rw-r--r--drivers/mfd/pcf50633-core.c76
-rw-r--r--drivers/mfd/tps65010.c30
-rw-r--r--drivers/mfd/twl-core.c (renamed from drivers/mfd/twl4030-core.c)385
-rw-r--r--drivers/mfd/twl4030-irq.c158
-rw-r--r--drivers/mfd/twl4030-power.c126
-rw-r--r--drivers/mfd/twl6030-irq.c299
-rw-r--r--drivers/mfd/wm831x-core.c223
-rw-r--r--drivers/mfd/wm831x-irq.c209
-rw-r--r--drivers/mfd/wm8350-core.c771
-rw-r--r--drivers/mfd/wm8350-irq.c529
-rw-r--r--drivers/mfd/wm8350-regmap.c8
-rw-r--r--drivers/net/chelsio/sge.c5
-rw-r--r--drivers/net/loopback.c2
-rw-r--r--drivers/net/pcmcia/axnet_cs.c2
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c2
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c2
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c2
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c2
-rw-r--r--drivers/net/veth.c7
-rw-r--r--drivers/oprofile/cpu_buffer.c19
-rw-r--r--drivers/oprofile/cpu_buffer.h4
-rw-r--r--drivers/oprofile/oprofile_stats.c4
-rw-r--r--drivers/pcmcia/Kconfig8
-rw-r--r--drivers/pcmcia/Makefile2
-rw-r--r--drivers/pcmcia/cardbus.c23
-rw-r--r--drivers/pcmcia/cistpl.c181
-rw-r--r--drivers/pcmcia/cs.c12
-rw-r--r--drivers/pcmcia/ds.c66
-rw-r--r--drivers/pcmcia/pcmcia_ioctl.c45
-rw-r--r--drivers/pcmcia/pcmcia_resource.c37
-rw-r--r--drivers/pcmcia/pxa2xx_base.c19
-rw-r--r--drivers/pcmcia/pxa2xx_base.h3
-rw-r--r--drivers/pcmcia/pxa2xx_palmtc.c2
-rw-r--r--drivers/pcmcia/pxa2xx_stargate2.c2
-rw-r--r--drivers/pcmcia/pxa2xx_viper.c119
-rw-r--r--drivers/pcmcia/rsrc_mgr.c14
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c315
-rw-r--r--drivers/pcmcia/socket_sysfs.c6
-rw-r--r--drivers/pcmcia/yenta_socket.c147
-rw-r--r--drivers/power/pcf50633-charger.c3
-rw-r--r--drivers/power/wm8350_power.c63
-rw-r--r--drivers/regulator/Kconfig2
-rw-r--r--drivers/regulator/Makefile2
-rw-r--r--drivers/regulator/pcf50633-regulator.c5
-rw-r--r--drivers/regulator/twl-regulator.c (renamed from drivers/regulator/twl4030-regulator.c)287
-rw-r--r--drivers/regulator/wm8350-regulator.c10
-rw-r--r--drivers/rtc/Kconfig6
-rw-r--r--drivers/rtc/Makefile2
-rw-r--r--drivers/rtc/rtc-pcf50633.c5
-rw-r--r--drivers/rtc/rtc-twl.c (renamed from drivers/rtc/rtc-twl4030.c)284
-rw-r--r--drivers/rtc/rtc-wm8350.c25
-rw-r--r--drivers/s390/net/netiucv.c8
-rw-r--r--drivers/spi/Kconfig40
-rw-r--r--drivers/spi/Makefile5
-rw-r--r--drivers/spi/au1550_spi.c10
-rw-r--r--drivers/spi/mpc52xx_spi.c86
-rw-r--r--drivers/spi/omap_spi_100k.c635
-rw-r--r--drivers/spi/spi_imx.c35
-rw-r--r--drivers/spi/spi_mpc8xxx.c2
-rw-r--r--drivers/spi/spi_nuc900.c504
-rw-r--r--drivers/spi/spi_sh_msiof.c691
-rw-r--r--drivers/spi/spidev.c6
-rw-r--r--drivers/spi/xilinx_spi.c355
-rw-r--r--drivers/spi/xilinx_spi.h32
-rw-r--r--drivers/spi/xilinx_spi_of.c134
-rw-r--r--drivers/spi/xilinx_spi_pltfm.c102
-rw-r--r--drivers/usb/otg/twl4030-usb.c38
-rw-r--r--drivers/video/backlight/adp5520_bl.c123
-rw-r--r--drivers/video/omap/lcd_2430sdp.c4
-rw-r--r--drivers/watchdog/twl4030_wdt.c4
-rw-r--r--fs/compat_ioctl.c18
-rw-r--r--fs/ext4/mballoc.c2
-rw-r--r--fs/nfs/callback.c13
-rw-r--r--fs/nfs/callback.h16
-rw-r--r--fs/nfs/callback_proc.c64
-rw-r--r--fs/nfs/callback_xdr.c34
-rw-r--r--fs/nfs/client.c14
-rw-r--r--fs/nfs/delegation.c77
-rw-r--r--fs/nfs/delegation.h7
-rw-r--r--fs/nfs/dir.c67
-rw-r--r--fs/nfs/dns_resolve.c4
-rw-r--r--fs/nfs/internal.h54
-rw-r--r--fs/nfs/iostat.h24
-rw-r--r--fs/nfs/nfs4_fs.h12
-rw-r--r--fs/nfs/nfs4proc.c458
-rw-r--r--fs/nfs/nfs4state.c225
-rw-r--r--fs/nfs/nfs4xdr.c135
-rw-r--r--fs/nfs/read.c12
-rw-r--r--fs/nfs/super.c104
-rw-r--r--fs/nfs/unlink.c2
-rw-r--r--fs/nfs/write.c8
-rw-r--r--fs/udf/balloc.c2
-rw-r--r--fs/udf/file.c1
-rw-r--r--fs/udf/inode.c24
-rw-r--r--fs/udf/namei.c38
-rw-r--r--fs/udf/super.c32
-rw-r--r--fs/xfs/xfs_mount.c12
-rw-r--r--include/asm-generic/percpu.h5
-rw-r--r--include/linux/hw_breakpoint.h2
-rw-r--r--include/linux/i2c/tps65010.h19
-rw-r--r--include/linux/i2c/twl.h (renamed from include/linux/i2c/twl4030.h)209
-rw-r--r--include/linux/mfd/88pm8607.h217
-rw-r--r--include/linux/mfd/ab4500.h262
-rw-r--r--include/linux/mfd/adp5520.h299
-rw-r--r--include/linux/mfd/ezx-pcap.h3
-rw-r--r--include/linux/mfd/mc13783-private.h208
-rw-r--r--include/linux/mfd/mc13783.h120
-rw-r--r--include/linux/mfd/pcf50633/core.h10
-rw-r--r--include/linux/mfd/wm831x/core.h43
-rw-r--r--include/linux/mfd/wm831x/pdata.h1
-rw-r--r--include/linux/mfd/wm8350/core.h14
-rw-r--r--include/linux/mfd/wm8350/gpio.h18
-rw-r--r--include/linux/nfs4.h3
-rw-r--r--include/linux/nfs_fs_sb.h1
-rw-r--r--include/linux/nfs_xdr.h13
-rw-r--r--include/linux/pci.h2
-rw-r--r--include/linux/percpu-defs.h1
-rw-r--r--include/linux/percpu.h434
-rw-r--r--include/linux/raid/pq.h19
-rw-r--r--include/linux/slab_def.h4
-rw-r--r--include/linux/slub_def.h4
-rw-r--r--include/linux/spi/mpc52xx_spi.h10
-rw-r--r--include/linux/spi/sh_msiof.h10
-rw-r--r--include/linux/spi/xilinx_spi.h20
-rw-r--r--include/linux/sunrpc/sched.h2
-rw-r--r--include/linux/vmstat.h10
-rw-r--r--include/net/neighbour.h7
-rw-r--r--include/net/netfilter/nf_conntrack.h4
-rw-r--r--include/net/snmp.h50
-rw-r--r--include/pcmcia/cs.h4
-rw-r--r--include/pcmcia/ds.h6
-rw-r--r--include/pcmcia/mem_op.h2
-rw-r--r--include/pcmcia/ss.h12
-rw-r--r--kernel/lockdep.c11
-rw-r--r--kernel/module.c150
-rw-r--r--kernel/rcutorture.c8
-rw-r--r--kernel/sched.c8
-rw-r--r--kernel/softirq.c4
-rw-r--r--kernel/softlockup.c54
-rw-r--r--kernel/time/timer_stats.c11
-rw-r--r--kernel/trace/trace.c12
-rw-r--r--kernel/trace/trace.h2
-rw-r--r--kernel/trace/trace_functions_graph.c4
-rw-r--r--kernel/trace/trace_hw_branches.c51
-rw-r--r--mm/Makefile4
-rw-r--r--mm/allocpercpu.c177
-rw-r--r--mm/migrate.c2
-rw-r--r--mm/percpu.c24
-rw-r--r--mm/slab.c30
-rw-r--r--mm/slub.c4
-rw-r--r--mm/vmalloc.c4
-rw-r--r--mm/vmstat.c7
-rw-r--r--net/sunrpc/addr.c10
-rw-r--r--net/sunrpc/auth.c39
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c6
-rw-r--r--net/sunrpc/clnt.c54
-rw-r--r--net/sunrpc/rpcb_clnt.c104
-rw-r--r--net/sunrpc/sunrpc_syms.c3
-rw-r--r--net/sunrpc/xprt.c4
-rw-r--r--net/sunrpc/xprtsock.c2
-rwxr-xr-xscripts/recordmcount.pl3
-rw-r--r--sound/pcmcia/pdaudiocf/pdaudiocf.c3
-rw-r--r--sound/soc/codecs/twl4030.c10
-rw-r--r--sound/soc/codecs/wm8350.c25
-rw-r--r--tools/perf/Makefile9
-rw-r--r--tools/perf/bench/sched-messaging.c8
-rw-r--r--tools/perf/bench/sched-pipe.c11
-rw-r--r--tools/perf/builtin-annotate.c15
-rw-r--r--tools/perf/builtin-bench.c57
-rw-r--r--tools/perf/builtin-buildid-list.c55
-rw-r--r--tools/perf/builtin-kmem.c15
-rw-r--r--tools/perf/builtin-record.c25
-rw-r--r--tools/perf/builtin-report.c20
-rw-r--r--tools/perf/builtin-sched.c13
-rw-r--r--tools/perf/builtin-timechart.c15
-rw-r--r--tools/perf/builtin-trace.c20
-rw-r--r--tools/perf/perf.h12
-rw-r--r--tools/perf/util/data_map.c71
-rw-r--r--tools/perf/util/data_map.h9
-rw-r--r--tools/perf/util/event.c11
-rw-r--r--tools/perf/util/event.h7
-rw-r--r--tools/perf/util/header.c28
-rw-r--r--tools/perf/util/header.h4
-rw-r--r--tools/perf/util/map.c87
-rw-r--r--tools/perf/util/session.c80
-rw-r--r--tools/perf/util/session.h16
-rw-r--r--tools/perf/util/symbol.c268
-rw-r--r--tools/perf/util/symbol.h17
-rw-r--r--tools/perf/util/thread.c63
-rw-r--r--tools/perf/util/thread.h42
384 files changed, 17588 insertions, 5715 deletions
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 2a4d77946c7d..eb2c138c277c 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -291,13 +291,6 @@ Who: Michael Buesch <mb@bu3sch.de>
291 291
292--------------------------- 292---------------------------
293 293
294What: usedac i386 kernel parameter
295When: 2.6.27
296Why: replaced by allowdac and no dac combination
297Who: Glauber Costa <gcosta@redhat.com>
298
299---------------------------
300
301What: print_fn_descriptor_symbol() 294What: print_fn_descriptor_symbol()
302When: October 2009 295When: October 2009
303Why: The %pF vsprintf format provides the same functionality in a 296Why: The %pF vsprintf format provides the same functionality in a
diff --git a/Documentation/md.txt b/Documentation/md.txt
index 4edd39ec7db9..188f4768f1d5 100644
--- a/Documentation/md.txt
+++ b/Documentation/md.txt
@@ -233,9 +233,9 @@ All md devices contain:
233 233
234 resync_start 234 resync_start
235 The point at which resync should start. If no resync is needed, 235 The point at which resync should start. If no resync is needed,
236 this will be a very large number. At array creation it will 236 this will be a very large number (or 'none' since 2.6.30-rc1). At
237 default to 0, though starting the array as 'clean' will 237 array creation it will default to 0, though starting the array as
238 set it much larger. 238 'clean' will set it much larger.
239 239
240 new_dev 240 new_dev
241 This file can be written but not read. The value written should 241 This file can be written but not read. The value written should
@@ -296,6 +296,51 @@ All md devices contain:
296 active-idle 296 active-idle
297 like active, but no writes have been seen for a while (safe_mode_delay). 297 like active, but no writes have been seen for a while (safe_mode_delay).
298 298
299 bitmap/location
300 This indicates where the write-intent bitmap for the array is
301 stored.
302 It can be one of "none", "file" or "[+-]N".
303 "file" may later be extended to "file:/file/name"
304 "[+-]N" means that many sectors from the start of the metadata.
305 This is replicated on all devices. For arrays with externally
306 managed metadata, the offset is from the beginning of the
307 device.
308 bitmap/chunksize
309 The size, in bytes, of the chunk which will be represented by a
310 single bit. For RAID456, it is a portion of an individual
311 device. For RAID10, it is a portion of the array. For RAID1, it
312 is both (they come to the same thing).
313 bitmap/time_base
314 The time, in seconds, between looking for bits in the bitmap to
315 be cleared. In the current implementation, a bit will be cleared
316 between 2 and 3 times "time_base" after all the covered blocks
317 are known to be in-sync.
318 bitmap/backlog
319 When write-mostly devices are active in a RAID1, write requests
320 to those devices proceed in the background - the filesystem (or
321 other user of the device) does not have to wait for them.
322 'backlog' sets a limit on the number of concurrent background
323 writes. If there are more than this, new writes will by
324 synchronous.
325 bitmap/metadata
326 This can be either 'internal' or 'external'.
327 'internal' is the default and means the metadata for the bitmap
328 is stored in the first 256 bytes of the allocated space and is
329 managed by the md module.
330 'external' means that bitmap metadata is managed externally to
331 the kernel (i.e. by some userspace program)
332 bitmap/can_clear
333 This is either 'true' or 'false'. If 'true', then bits in the
334 bitmap will be cleared when the corresponding blocks are thought
335 to be in-sync. If 'false', bits will never be cleared.
336 This is automatically set to 'false' if a write happens on a
337 degraded array, or if the array becomes degraded during a write.
338 When metadata is managed externally, it should be set to true
339 once the array becomes non-degraded, and this fact has been
340 recorded in the metadata.
341
342
343
299 344
300As component devices are added to an md array, they appear in the 'md' 345As component devices are added to an md array, they appear in the 'md'
301directory as new directories named 346directory as new directories named
@@ -334,8 +379,9 @@ Each directory contains:
334 Writing "writemostly" sets the writemostly flag. 379 Writing "writemostly" sets the writemostly flag.
335 Writing "-writemostly" clears the writemostly flag. 380 Writing "-writemostly" clears the writemostly flag.
336 Writing "blocked" sets the "blocked" flag. 381 Writing "blocked" sets the "blocked" flag.
337 Writing "-blocked" clear the "blocked" flag and allows writes 382 Writing "-blocked" clears the "blocked" flag and allows writes
338 to complete. 383 to complete.
384 Writing "in_sync" sets the in_sync flag.
339 385
340 This file responds to select/poll. Any change to 'faulty' 386 This file responds to select/poll. Any change to 'faulty'
341 or 'blocked' causes an event. 387 or 'blocked' causes an event.
@@ -372,6 +418,24 @@ Each directory contains:
372 array. If a value less than the current component_size is 418 array. If a value less than the current component_size is
373 written, it will be rejected. 419 written, it will be rejected.
374 420
421 recovery_start
422
423 When the device is not 'in_sync', this records the number of
424 sectors from the start of the device which are known to be
425 correct. This is normally zero, but during a recovery
426 operation is will steadily increase, and if the recovery is
427 interrupted, restoring this value can cause recovery to
428 avoid repeating the earlier blocks. With v1.x metadata, this
429 value is saved and restored automatically.
430
431 This can be set whenever the device is not an active member of
432 the array, either before the array is activated, or before
433 the 'slot' is set.
434
435 Setting this to 'none' is equivalent to setting 'in_sync'.
436 Setting to any other value also clears the 'in_sync' flag.
437
438
375 439
376An active md device will also contain and entry for each active device 440An active md device will also contain and entry for each active device
377in the array. These are named 441in the array. These are named
diff --git a/Documentation/spinlocks.txt b/Documentation/spinlocks.txt
index 619699dde593..178c831b907d 100644
--- a/Documentation/spinlocks.txt
+++ b/Documentation/spinlocks.txt
@@ -1,73 +1,8 @@
1SPIN_LOCK_UNLOCKED and RW_LOCK_UNLOCKED defeat lockdep state tracking and 1Lesson 1: Spin locks
2are hence deprecated.
3 2
4Please use DEFINE_SPINLOCK()/DEFINE_RWLOCK() or 3The most basic primitive for locking is spinlock.
5__SPIN_LOCK_UNLOCKED()/__RW_LOCK_UNLOCKED() as appropriate for static
6initialization.
7
8Most of the time, you can simply turn:
9
10 static spinlock_t xxx_lock = SPIN_LOCK_UNLOCKED;
11
12into:
13
14 static DEFINE_SPINLOCK(xxx_lock);
15
16Static structure member variables go from:
17
18 struct foo bar {
19 .lock = SPIN_LOCK_UNLOCKED;
20 };
21
22to:
23
24 struct foo bar {
25 .lock = __SPIN_LOCK_UNLOCKED(bar.lock);
26 };
27
28Declaration of static rw_locks undergo a similar transformation.
29
30Dynamic initialization, when necessary, may be performed as
31demonstrated below.
32
33 spinlock_t xxx_lock;
34 rwlock_t xxx_rw_lock;
35
36 static int __init xxx_init(void)
37 {
38 spin_lock_init(&xxx_lock);
39 rwlock_init(&xxx_rw_lock);
40 ...
41 }
42
43 module_init(xxx_init);
44
45The following discussion is still valid, however, with the dynamic
46initialization of spinlocks or with DEFINE_SPINLOCK, etc., used
47instead of SPIN_LOCK_UNLOCKED.
48
49-----------------------
50
51On Fri, 2 Jan 1998, Doug Ledford wrote:
52>
53> I'm working on making the aic7xxx driver more SMP friendly (as well as
54> importing the latest FreeBSD sequencer code to have 7895 support) and wanted
55> to get some info from you. The goal here is to make the various routines
56> SMP safe as well as UP safe during interrupts and other manipulating
57> routines. So far, I've added a spin_lock variable to things like my queue
58> structs. Now, from what I recall, there are some spin lock functions I can
59> use to lock these spin locks from other use as opposed to a (nasty)
60> save_flags(); cli(); stuff; restore_flags(); construct. Where do I find
61> these routines and go about making use of them? Do they only lock on a
62> per-processor basis or can they also lock say an interrupt routine from
63> mucking with a queue if the queue routine was manipulating it when the
64> interrupt occurred, or should I still use a cli(); based construct on that
65> one?
66
67See <asm/spinlock.h>. The basic version is:
68
69 spinlock_t xxx_lock = SPIN_LOCK_UNLOCKED;
70 4
5static DEFINE_SPINLOCK(xxx_lock);
71 6
72 unsigned long flags; 7 unsigned long flags;
73 8
@@ -75,13 +10,11 @@ See <asm/spinlock.h>. The basic version is:
75 ... critical section here .. 10 ... critical section here ..
76 spin_unlock_irqrestore(&xxx_lock, flags); 11 spin_unlock_irqrestore(&xxx_lock, flags);
77 12
78and the above is always safe. It will disable interrupts _locally_, but the 13The above is always safe. It will disable interrupts _locally_, but the
79spinlock itself will guarantee the global lock, so it will guarantee that 14spinlock itself will guarantee the global lock, so it will guarantee that
80there is only one thread-of-control within the region(s) protected by that 15there is only one thread-of-control within the region(s) protected by that
81lock. 16lock. This works well even under UP. The above sequence under UP
82 17essentially is just the same as doing
83Note that it works well even under UP - the above sequence under UP
84essentially is just the same as doing a
85 18
86 unsigned long flags; 19 unsigned long flags;
87 20
@@ -91,15 +24,13 @@ essentially is just the same as doing a
91 24
92so the code does _not_ need to worry about UP vs SMP issues: the spinlocks 25so the code does _not_ need to worry about UP vs SMP issues: the spinlocks
93work correctly under both (and spinlocks are actually more efficient on 26work correctly under both (and spinlocks are actually more efficient on
94architectures that allow doing the "save_flags + cli" in one go because I 27architectures that allow doing the "save_flags + cli" in one operation).
95don't export that interface normally). 28
29 NOTE! Implications of spin_locks for memory are further described in:
96 30
97NOTE NOTE NOTE! The reason the spinlock is so much faster than a global 31 Documentation/memory-barriers.txt
98interrupt lock under SMP is exactly because it disables interrupts only on 32 (5) LOCK operations.
99the local CPU. The spin-lock is safe only when you _also_ use the lock 33 (6) UNLOCK operations.
100itself to do locking across CPU's, which implies that EVERYTHING that
101touches a shared variable has to agree about the spinlock they want to
102use.
103 34
104The above is usually pretty simple (you usually need and want only one 35The above is usually pretty simple (you usually need and want only one
105spinlock for most things - using more than one spinlock can make things a 36spinlock for most things - using more than one spinlock can make things a
@@ -120,20 +51,24 @@ and another sequence that does
120then they are NOT mutually exclusive, and the critical regions can happen 51then they are NOT mutually exclusive, and the critical regions can happen
121at the same time on two different CPU's. That's fine per se, but the 52at the same time on two different CPU's. That's fine per se, but the
122critical regions had better be critical for different things (ie they 53critical regions had better be critical for different things (ie they
123can't stomp on each other). 54can't stomp on each other).
124 55
125The above is a problem mainly if you end up mixing code - for example the 56The above is a problem mainly if you end up mixing code - for example the
126routines in ll_rw_block() tend to use cli/sti to protect the atomicity of 57routines in ll_rw_block() tend to use cli/sti to protect the atomicity of
127their actions, and if a driver uses spinlocks instead then you should 58their actions, and if a driver uses spinlocks instead then you should
128think about issues like the above.. 59think about issues like the above.
129 60
130This is really the only really hard part about spinlocks: once you start 61This is really the only really hard part about spinlocks: once you start
131using spinlocks they tend to expand to areas you might not have noticed 62using spinlocks they tend to expand to areas you might not have noticed
132before, because you have to make sure the spinlocks correctly protect the 63before, because you have to make sure the spinlocks correctly protect the
133shared data structures _everywhere_ they are used. The spinlocks are most 64shared data structures _everywhere_ they are used. The spinlocks are most
134easily added to places that are completely independent of other code (ie 65easily added to places that are completely independent of other code (for
135internal driver data structures that nobody else ever touches, for 66example, internal driver data structures that nobody else ever touches).
136example). 67
68 NOTE! The spin-lock is safe only when you _also_ use the lock itself
69 to do locking across CPU's, which implies that EVERYTHING that
70 touches a shared variable has to agree about the spinlock they want
71 to use.
137 72
138---- 73----
139 74
@@ -141,13 +76,17 @@ Lesson 2: reader-writer spinlocks.
141 76
142If your data accesses have a very natural pattern where you usually tend 77If your data accesses have a very natural pattern where you usually tend
143to mostly read from the shared variables, the reader-writer locks 78to mostly read from the shared variables, the reader-writer locks
144(rw_lock) versions of the spinlocks are often nicer. They allow multiple 79(rw_lock) versions of the spinlocks are sometimes useful. They allow multiple
145readers to be in the same critical region at once, but if somebody wants 80readers to be in the same critical region at once, but if somebody wants
146to change the variables it has to get an exclusive write lock. The 81to change the variables it has to get an exclusive write lock.
147routines look the same as above:
148 82
149 rwlock_t xxx_lock = RW_LOCK_UNLOCKED; 83 NOTE! reader-writer locks require more atomic memory operations than
84 simple spinlocks. Unless the reader critical section is long, you
85 are better off just using spinlocks.
150 86
87The routines look the same as above:
88
89 rwlock_t xxx_lock = RW_LOCK_UNLOCKED;
151 90
152 unsigned long flags; 91 unsigned long flags;
153 92
@@ -159,18 +98,21 @@ routines look the same as above:
159 .. read and write exclusive access to the info ... 98 .. read and write exclusive access to the info ...
160 write_unlock_irqrestore(&xxx_lock, flags); 99 write_unlock_irqrestore(&xxx_lock, flags);
161 100
162The above kind of lock is useful for complex data structures like linked 101The above kind of lock may be useful for complex data structures like
163lists etc, especially when you know that most of the work is to just 102linked lists, especially searching for entries without changing the list
164traverse the list searching for entries without changing the list itself, 103itself. The read lock allows many concurrent readers. Anything that
165for example. Then you can use the read lock for that kind of list 104_changes_ the list will have to get the write lock.
166traversal, which allows many concurrent readers. Anything that _changes_ 105
167the list will have to get the write lock. 106 NOTE! RCU is better for list traversal, but requires careful
107 attention to design detail (see Documentation/RCU/listRCU.txt).
168 108
169Note: you cannot "upgrade" a read-lock to a write-lock, so if you at _any_ 109Also, you cannot "upgrade" a read-lock to a write-lock, so if you at _any_
170time need to do any changes (even if you don't do it every time), you have 110time need to do any changes (even if you don't do it every time), you have
171to get the write-lock at the very beginning. I could fairly easily add a 111to get the write-lock at the very beginning.
172primitive to create a "upgradeable" read-lock, but it hasn't been an issue 112
173yet. Tell me if you'd want one. 113 NOTE! We are working hard to remove reader-writer spinlocks in most
114 cases, so please don't add a new one without consensus. (Instead, see
115 Documentation/RCU/rcu.txt for complete information.)
174 116
175---- 117----
176 118
@@ -233,4 +175,46 @@ indeed), while write-locks need to protect themselves against interrupts.
233 175
234 Linus 176 Linus
235 177
178----
179
180Reference information:
181
182For dynamic initialization, use spin_lock_init() or rwlock_init() as
183appropriate:
184
185 spinlock_t xxx_lock;
186 rwlock_t xxx_rw_lock;
187
188 static int __init xxx_init(void)
189 {
190 spin_lock_init(&xxx_lock);
191 rwlock_init(&xxx_rw_lock);
192 ...
193 }
194
195 module_init(xxx_init);
196
197For static initialization, use DEFINE_SPINLOCK() / DEFINE_RWLOCK() or
198__SPIN_LOCK_UNLOCKED() / __RW_LOCK_UNLOCKED() as appropriate.
199
200SPIN_LOCK_UNLOCKED and RW_LOCK_UNLOCKED are deprecated. These interfere
201with lockdep state tracking.
202
203Most of the time, you can simply turn:
204 static spinlock_t xxx_lock = SPIN_LOCK_UNLOCKED;
205into:
206 static DEFINE_SPINLOCK(xxx_lock);
207
208Static structure member variables go from:
209
210 struct foo bar {
211 .lock = SPIN_LOCK_UNLOCKED;
212 };
213
214to:
236 215
216 struct foo bar {
217 .lock = __SPIN_LOCK_UNLOCKED(bar.lock);
218 };
219
220Declaration of static rw_locks undergo a similar transformation.
diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
index 8f7a0e73ef44..3894eaa23486 100644
--- a/Documentation/sysctl/kernel.txt
+++ b/Documentation/sysctl/kernel.txt
@@ -19,6 +19,8 @@ Currently, these files might (depending on your configuration)
19show up in /proc/sys/kernel: 19show up in /proc/sys/kernel:
20- acpi_video_flags 20- acpi_video_flags
21- acct 21- acct
22- bootloader_type [ X86 only ]
23- bootloader_version [ X86 only ]
22- callhome [ S390 only ] 24- callhome [ S390 only ]
23- auto_msgmni 25- auto_msgmni
24- core_pattern 26- core_pattern
@@ -93,6 +95,35 @@ valid for 30 seconds.
93 95
94============================================================== 96==============================================================
95 97
98bootloader_type:
99
100x86 bootloader identification
101
102This gives the bootloader type number as indicated by the bootloader,
103shifted left by 4, and OR'd with the low four bits of the bootloader
104version. The reason for this encoding is that this used to match the
105type_of_loader field in the kernel header; the encoding is kept for
106backwards compatibility. That is, if the full bootloader type number
107is 0x15 and the full version number is 0x234, this file will contain
108the value 340 = 0x154.
109
110See the type_of_loader and ext_loader_type fields in
111Documentation/x86/boot.txt for additional information.
112
113==============================================================
114
115bootloader_version:
116
117x86 bootloader version
118
119The complete bootloader version number. In the example above, this
120file will contain the value 564 = 0x234.
121
122See the type_of_loader and ext_loader_ver fields in
123Documentation/x86/boot.txt for additional information.
124
125==============================================================
126
96callhome: 127callhome:
97 128
98Controls the kernel's callhome behavior in case of a kernel panic. 129Controls the kernel's callhome behavior in case of a kernel panic.
diff --git a/MAINTAINERS b/MAINTAINERS
index cff133be42c6..1f21c34124db 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5080,6 +5080,7 @@ F: drivers/char/specialix*
5080 5080
5081SPI SUBSYSTEM 5081SPI SUBSYSTEM
5082M: David Brownell <dbrownell@users.sourceforge.net> 5082M: David Brownell <dbrownell@users.sourceforge.net>
5083M: Grant Likely <grant.likely@secretlab.ca>
5083L: spi-devel-general@lists.sourceforge.net 5084L: spi-devel-general@lists.sourceforge.net
5084S: Maintained 5085S: Maintained
5085F: Documentation/spi/ 5086F: Documentation/spi/
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index cf8a99f19dc4..233a222752c0 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -603,6 +603,7 @@ config ARCH_SA1100
603 select ARCH_SPARSEMEM_ENABLE 603 select ARCH_SPARSEMEM_ENABLE
604 select ARCH_MTD_XIP 604 select ARCH_MTD_XIP
605 select ARCH_HAS_CPUFREQ 605 select ARCH_HAS_CPUFREQ
606 select CPU_FREQ
606 select GENERIC_GPIO 607 select GENERIC_GPIO
607 select GENERIC_TIME 608 select GENERIC_TIME
608 select GENERIC_CLOCKEVENTS 609 select GENERIC_CLOCKEVENTS
@@ -1359,13 +1360,9 @@ source "drivers/cpufreq/Kconfig"
1359 1360
1360config CPU_FREQ_SA1100 1361config CPU_FREQ_SA1100
1361 bool 1362 bool
1362 depends on CPU_FREQ && (SA1100_H3100 || SA1100_H3600 || SA1100_LART || SA1100_PLEB || SA1100_BADGE4 || SA1100_HACKKIT)
1363 default y
1364 1363
1365config CPU_FREQ_SA1110 1364config CPU_FREQ_SA1110
1366 bool 1365 bool
1367 depends on CPU_FREQ && (SA1100_ASSABET || SA1100_CERF || SA1100_PT_SYSTEM3)
1368 default y
1369 1366
1370config CPU_FREQ_INTEGRATOR 1367config CPU_FREQ_INTEGRATOR
1371 tristate "CPUfreq driver for ARM Integrator CPUs" 1368 tristate "CPUfreq driver for ARM Integrator CPUs"
diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index ff54c23d085e..5cb9326df7a7 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -71,6 +71,14 @@ config DEBUG_LL
71 in the kernel. This is helpful if you are debugging code that 71 in the kernel. This is helpful if you are debugging code that
72 executes before the console is initialized. 72 executes before the console is initialized.
73 73
74config EARLY_PRINTK
75 bool "Early printk"
76 depends on DEBUG_LL
77 help
78 Say Y here if you want to have an early console using the
79 kernel low-level debugging functions. Add earlyprintk to your
80 kernel parameters to enable this console.
81
74config DEBUG_ICEDCC 82config DEBUG_ICEDCC
75 bool "Kernel low-level debugging via EmbeddedICE DCC channel" 83 bool "Kernel low-level debugging via EmbeddedICE DCC channel"
76 depends on DEBUG_LL 84 depends on DEBUG_LL
diff --git a/arch/arm/configs/zeus_defconfig b/arch/arm/configs/zeus_defconfig
new file mode 100644
index 000000000000..823b11e7091a
--- /dev/null
+++ b/arch/arm/configs/zeus_defconfig
@@ -0,0 +1,2032 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.32
4# Tue Dec 8 20:27:05 2009
5#
6CONFIG_ARM=y
7CONFIG_SYS_SUPPORTS_APM_EMULATION=y
8CONFIG_GENERIC_GPIO=y
9CONFIG_GENERIC_TIME=y
10CONFIG_GENERIC_CLOCKEVENTS=y
11CONFIG_GENERIC_HARDIRQS=y
12CONFIG_STACKTRACE_SUPPORT=y
13CONFIG_HAVE_LATENCYTOP_SUPPORT=y
14CONFIG_LOCKDEP_SUPPORT=y
15CONFIG_TRACE_IRQFLAGS_SUPPORT=y
16CONFIG_HARDIRQS_SW_RESEND=y
17CONFIG_GENERIC_IRQ_PROBE=y
18CONFIG_RWSEM_GENERIC_SPINLOCK=y
19CONFIG_ARCH_HAS_CPUFREQ=y
20CONFIG_GENERIC_HWEIGHT=y
21CONFIG_GENERIC_CALIBRATE_DELAY=y
22CONFIG_ARCH_MTD_XIP=y
23CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
24CONFIG_VECTORS_BASE=0xffff0000
25CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
26CONFIG_CONSTRUCTORS=y
27
28#
29# General setup
30#
31CONFIG_EXPERIMENTAL=y
32CONFIG_BROKEN_ON_SMP=y
33CONFIG_INIT_ENV_ARG_LIMIT=32
34CONFIG_LOCALVERSION=""
35CONFIG_LOCALVERSION_AUTO=y
36CONFIG_SWAP=y
37CONFIG_SYSVIPC=y
38CONFIG_SYSVIPC_SYSCTL=y
39# CONFIG_POSIX_MQUEUE is not set
40# CONFIG_BSD_PROCESS_ACCT is not set
41# CONFIG_TASKSTATS is not set
42# CONFIG_AUDIT is not set
43
44#
45# RCU Subsystem
46#
47# CONFIG_TREE_RCU is not set
48# CONFIG_TREE_PREEMPT_RCU is not set
49CONFIG_TINY_RCU=y
50# CONFIG_TREE_RCU_TRACE is not set
51# CONFIG_IKCONFIG is not set
52CONFIG_LOG_BUF_SHIFT=13
53# CONFIG_GROUP_SCHED is not set
54# CONFIG_CGROUPS is not set
55# CONFIG_SYSFS_DEPRECATED_V2 is not set
56# CONFIG_RELAY is not set
57CONFIG_NAMESPACES=y
58# CONFIG_UTS_NS is not set
59# CONFIG_IPC_NS is not set
60# CONFIG_USER_NS is not set
61# CONFIG_PID_NS is not set
62# CONFIG_NET_NS is not set
63# CONFIG_BLK_DEV_INITRD is not set
64CONFIG_CC_OPTIMIZE_FOR_SIZE=y
65CONFIG_SYSCTL=y
66CONFIG_ANON_INODES=y
67# CONFIG_EMBEDDED is not set
68CONFIG_UID16=y
69CONFIG_SYSCTL_SYSCALL=y
70CONFIG_KALLSYMS=y
71# CONFIG_KALLSYMS_ALL is not set
72# CONFIG_KALLSYMS_EXTRA_PASS is not set
73CONFIG_HOTPLUG=y
74CONFIG_PRINTK=y
75CONFIG_BUG=y
76CONFIG_ELF_CORE=y
77CONFIG_BASE_FULL=y
78CONFIG_FUTEX=y
79CONFIG_EPOLL=y
80CONFIG_SIGNALFD=y
81CONFIG_TIMERFD=y
82CONFIG_EVENTFD=y
83CONFIG_SHMEM=y
84CONFIG_AIO=y
85
86#
87# Kernel Performance Events And Counters
88#
89CONFIG_VM_EVENT_COUNTERS=y
90CONFIG_SLUB_DEBUG=y
91CONFIG_COMPAT_BRK=y
92# CONFIG_SLAB is not set
93CONFIG_SLUB=y
94# CONFIG_SLOB is not set
95# CONFIG_PROFILING is not set
96CONFIG_HAVE_OPROFILE=y
97# CONFIG_KPROBES is not set
98CONFIG_HAVE_KPROBES=y
99CONFIG_HAVE_KRETPROBES=y
100CONFIG_HAVE_CLK=y
101
102#
103# GCOV-based kernel profiling
104#
105# CONFIG_SLOW_WORK is not set
106CONFIG_HAVE_GENERIC_DMA_COHERENT=y
107CONFIG_SLABINFO=y
108CONFIG_RT_MUTEXES=y
109CONFIG_BASE_SMALL=0
110CONFIG_MODULES=y
111# CONFIG_MODULE_FORCE_LOAD is not set
112CONFIG_MODULE_UNLOAD=y
113# CONFIG_MODULE_FORCE_UNLOAD is not set
114# CONFIG_MODVERSIONS is not set
115# CONFIG_MODULE_SRCVERSION_ALL is not set
116CONFIG_BLOCK=y
117CONFIG_LBDAF=y
118# CONFIG_BLK_DEV_BSG is not set
119# CONFIG_BLK_DEV_INTEGRITY is not set
120
121#
122# IO Schedulers
123#
124CONFIG_IOSCHED_NOOP=y
125CONFIG_IOSCHED_DEADLINE=y
126# CONFIG_IOSCHED_CFQ is not set
127CONFIG_DEFAULT_DEADLINE=y
128# CONFIG_DEFAULT_CFQ is not set
129# CONFIG_DEFAULT_NOOP is not set
130CONFIG_DEFAULT_IOSCHED="deadline"
131# CONFIG_INLINE_SPIN_TRYLOCK is not set
132# CONFIG_INLINE_SPIN_TRYLOCK_BH is not set
133# CONFIG_INLINE_SPIN_LOCK is not set
134# CONFIG_INLINE_SPIN_LOCK_BH is not set
135# CONFIG_INLINE_SPIN_LOCK_IRQ is not set
136# CONFIG_INLINE_SPIN_LOCK_IRQSAVE is not set
137CONFIG_INLINE_SPIN_UNLOCK=y
138# CONFIG_INLINE_SPIN_UNLOCK_BH is not set
139CONFIG_INLINE_SPIN_UNLOCK_IRQ=y
140# CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE is not set
141# CONFIG_INLINE_READ_TRYLOCK is not set
142# CONFIG_INLINE_READ_LOCK is not set
143# CONFIG_INLINE_READ_LOCK_BH is not set
144# CONFIG_INLINE_READ_LOCK_IRQ is not set
145# CONFIG_INLINE_READ_LOCK_IRQSAVE is not set
146CONFIG_INLINE_READ_UNLOCK=y
147# CONFIG_INLINE_READ_UNLOCK_BH is not set
148CONFIG_INLINE_READ_UNLOCK_IRQ=y
149# CONFIG_INLINE_READ_UNLOCK_IRQRESTORE is not set
150# CONFIG_INLINE_WRITE_TRYLOCK is not set
151# CONFIG_INLINE_WRITE_LOCK is not set
152# CONFIG_INLINE_WRITE_LOCK_BH is not set
153# CONFIG_INLINE_WRITE_LOCK_IRQ is not set
154# CONFIG_INLINE_WRITE_LOCK_IRQSAVE is not set
155CONFIG_INLINE_WRITE_UNLOCK=y
156# CONFIG_INLINE_WRITE_UNLOCK_BH is not set
157CONFIG_INLINE_WRITE_UNLOCK_IRQ=y
158# CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE is not set
159# CONFIG_MUTEX_SPIN_ON_OWNER is not set
160CONFIG_FREEZER=y
161
162#
163# System Type
164#
165CONFIG_MMU=y
166# CONFIG_ARCH_AAEC2000 is not set
167# CONFIG_ARCH_INTEGRATOR is not set
168# CONFIG_ARCH_REALVIEW is not set
169# CONFIG_ARCH_VERSATILE is not set
170# CONFIG_ARCH_AT91 is not set
171# CONFIG_ARCH_CLPS711X is not set
172# CONFIG_ARCH_GEMINI is not set
173# CONFIG_ARCH_EBSA110 is not set
174# CONFIG_ARCH_EP93XX is not set
175# CONFIG_ARCH_FOOTBRIDGE is not set
176# CONFIG_ARCH_MXC is not set
177# CONFIG_ARCH_STMP3XXX is not set
178# CONFIG_ARCH_NETX is not set
179# CONFIG_ARCH_H720X is not set
180# CONFIG_ARCH_NOMADIK is not set
181# CONFIG_ARCH_IOP13XX is not set
182# CONFIG_ARCH_IOP32X is not set
183# CONFIG_ARCH_IOP33X is not set
184# CONFIG_ARCH_IXP23XX is not set
185# CONFIG_ARCH_IXP2000 is not set
186# CONFIG_ARCH_IXP4XX is not set
187# CONFIG_ARCH_L7200 is not set
188# CONFIG_ARCH_DOVE is not set
189# CONFIG_ARCH_KIRKWOOD is not set
190# CONFIG_ARCH_LOKI is not set
191# CONFIG_ARCH_MV78XX0 is not set
192# CONFIG_ARCH_ORION5X is not set
193# CONFIG_ARCH_MMP is not set
194# CONFIG_ARCH_KS8695 is not set
195# CONFIG_ARCH_NS9XXX is not set
196# CONFIG_ARCH_W90X900 is not set
197# CONFIG_ARCH_PNX4008 is not set
198CONFIG_ARCH_PXA=y
199# CONFIG_ARCH_MSM is not set
200# CONFIG_ARCH_RPC is not set
201# CONFIG_ARCH_SA1100 is not set
202# CONFIG_ARCH_S3C2410 is not set
203# CONFIG_ARCH_S3C64XX is not set
204# CONFIG_ARCH_S5PC1XX is not set
205# CONFIG_ARCH_SHARK is not set
206# CONFIG_ARCH_LH7A40X is not set
207# CONFIG_ARCH_U300 is not set
208# CONFIG_ARCH_DAVINCI is not set
209# CONFIG_ARCH_OMAP is not set
210# CONFIG_ARCH_BCMRING is not set
211# CONFIG_ARCH_U8500 is not set
212
213#
214# Intel PXA2xx/PXA3xx Implementations
215#
216
217#
218# Intel/Marvell Dev Platforms (sorted by hardware release time)
219#
220# CONFIG_ARCH_LUBBOCK is not set
221# CONFIG_MACH_MAINSTONE is not set
222# CONFIG_MACH_ZYLONITE300 is not set
223# CONFIG_MACH_ZYLONITE320 is not set
224# CONFIG_MACH_LITTLETON is not set
225# CONFIG_MACH_TAVOREVB is not set
226# CONFIG_MACH_SAAR is not set
227
228#
229# Third Party Dev Platforms (sorted by vendor name)
230#
231# CONFIG_ARCH_PXA_IDP is not set
232# CONFIG_ARCH_VIPER is not set
233CONFIG_MACH_ARCOM_ZEUS=y
234# CONFIG_MACH_BALLOON3 is not set
235# CONFIG_MACH_CSB726 is not set
236# CONFIG_MACH_ARMCORE is not set
237# CONFIG_MACH_EM_X270 is not set
238# CONFIG_MACH_EXEDA is not set
239# CONFIG_MACH_CM_X300 is not set
240# CONFIG_ARCH_GUMSTIX is not set
241# CONFIG_MACH_INTELMOTE2 is not set
242# CONFIG_MACH_STARGATE2 is not set
243# CONFIG_MACH_XCEP is not set
244# CONFIG_TRIZEPS_PXA is not set
245CONFIG_ARCOM_PCMCIA=y
246# CONFIG_MACH_LOGICPD_PXA270 is not set
247# CONFIG_MACH_PCM027 is not set
248# CONFIG_MACH_COLIBRI is not set
249# CONFIG_MACH_COLIBRI300 is not set
250# CONFIG_MACH_COLIBRI320 is not set
251
252#
253# End-user Products (sorted by vendor name)
254#
255# CONFIG_MACH_H4700 is not set
256# CONFIG_MACH_H5000 is not set
257# CONFIG_MACH_HIMALAYA is not set
258# CONFIG_MACH_MAGICIAN is not set
259# CONFIG_MACH_MIOA701 is not set
260# CONFIG_PXA_EZX is not set
261# CONFIG_MACH_MP900C is not set
262# CONFIG_ARCH_PXA_PALM is not set
263# CONFIG_PXA_SHARPSL is not set
264# CONFIG_ARCH_PXA_ESERIES is not set
265CONFIG_PXA27x=y
266CONFIG_PXA_SSP=y
267CONFIG_PXA_HAVE_BOARD_IRQS=y
268CONFIG_PXA_HAVE_ISA_IRQS=y
269CONFIG_PLAT_PXA=y
270
271#
272# Processor Type
273#
274CONFIG_CPU_32=y
275CONFIG_CPU_XSCALE=y
276CONFIG_CPU_32v5=y
277CONFIG_CPU_ABRT_EV5T=y
278CONFIG_CPU_PABRT_LEGACY=y
279CONFIG_CPU_CACHE_VIVT=y
280CONFIG_CPU_TLB_V4WBI=y
281CONFIG_CPU_CP15=y
282CONFIG_CPU_CP15_MMU=y
283
284#
285# Processor Features
286#
287CONFIG_ARM_THUMB=y
288# CONFIG_CPU_DCACHE_DISABLE is not set
289CONFIG_ARM_L1_CACHE_SHIFT=5
290CONFIG_IWMMXT=y
291CONFIG_XSCALE_PMU=y
292CONFIG_COMMON_CLKDEV=y
293
294#
295# Bus support
296#
297CONFIG_ISA=y
298# CONFIG_PCI_SYSCALL is not set
299# CONFIG_ARCH_SUPPORTS_MSI is not set
300CONFIG_PCCARD=m
301CONFIG_PCMCIA=m
302CONFIG_PCMCIA_LOAD_CIS=y
303CONFIG_PCMCIA_IOCTL=y
304
305#
306# PC-card bridges
307#
308# CONFIG_I82365 is not set
309# CONFIG_TCIC is not set
310CONFIG_PCMCIA_SOC_COMMON=m
311CONFIG_PCMCIA_PXA2XX=m
312# CONFIG_PCMCIA_DEBUG is not set
313CONFIG_PCMCIA_PROBE=y
314
315#
316# Kernel Features
317#
318CONFIG_TICK_ONESHOT=y
319# CONFIG_NO_HZ is not set
320# CONFIG_HIGH_RES_TIMERS is not set
321CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
322CONFIG_VMSPLIT_3G=y
323# CONFIG_VMSPLIT_2G is not set
324# CONFIG_VMSPLIT_1G is not set
325CONFIG_PAGE_OFFSET=0xC0000000
326CONFIG_PREEMPT_NONE=y
327# CONFIG_PREEMPT_VOLUNTARY is not set
328# CONFIG_PREEMPT is not set
329CONFIG_HZ=100
330CONFIG_AEABI=y
331CONFIG_OABI_COMPAT=y
332# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set
333# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set
334# CONFIG_HIGHMEM is not set
335CONFIG_SELECT_MEMORY_MODEL=y
336CONFIG_FLATMEM_MANUAL=y
337# CONFIG_DISCONTIGMEM_MANUAL is not set
338# CONFIG_SPARSEMEM_MANUAL is not set
339CONFIG_FLATMEM=y
340CONFIG_FLAT_NODE_MEM_MAP=y
341CONFIG_PAGEFLAGS_EXTENDED=y
342CONFIG_SPLIT_PTLOCK_CPUS=4096
343# CONFIG_PHYS_ADDR_T_64BIT is not set
344CONFIG_ZONE_DMA_FLAG=0
345CONFIG_VIRT_TO_BUS=y
346CONFIG_HAVE_MLOCK=y
347CONFIG_HAVE_MLOCKED_PAGE_BIT=y
348# CONFIG_KSM is not set
349CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
350CONFIG_ALIGNMENT_TRAP=y
351# CONFIG_UACCESS_WITH_MEMCPY is not set
352
353#
354# Boot options
355#
356CONFIG_ZBOOT_ROM_TEXT=0x0
357CONFIG_ZBOOT_ROM_BSS=0x0
358CONFIG_CMDLINE="root=31:02 rootfstype=jffs2 ro console=ttyS0,115200"
359# CONFIG_XIP_KERNEL is not set
360# CONFIG_KEXEC is not set
361
362#
363# CPU Power Management
364#
365CONFIG_CPU_FREQ=y
366CONFIG_CPU_FREQ_TABLE=y
367# CONFIG_CPU_FREQ_DEBUG is not set
368CONFIG_CPU_FREQ_STAT=y
369# CONFIG_CPU_FREQ_STAT_DETAILS is not set
370CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
371# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
372# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
373# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
374# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
375CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
376CONFIG_CPU_FREQ_GOV_POWERSAVE=m
377CONFIG_CPU_FREQ_GOV_USERSPACE=m
378CONFIG_CPU_FREQ_GOV_ONDEMAND=m
379CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
380# CONFIG_CPU_IDLE is not set
381
382#
383# Floating point emulation
384#
385
386#
387# At least one emulation must be selected
388#
389CONFIG_FPE_NWFPE=y
390# CONFIG_FPE_NWFPE_XP is not set
391# CONFIG_FPE_FASTFPE is not set
392
393#
394# Userspace binary formats
395#
396CONFIG_BINFMT_ELF=y
397# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
398CONFIG_HAVE_AOUT=y
399# CONFIG_BINFMT_AOUT is not set
400# CONFIG_BINFMT_MISC is not set
401
402#
403# Power management options
404#
405CONFIG_PM=y
406# CONFIG_PM_DEBUG is not set
407CONFIG_PM_SLEEP=y
408CONFIG_SUSPEND=y
409CONFIG_SUSPEND_FREEZER=y
410CONFIG_APM_EMULATION=y
411# CONFIG_PM_RUNTIME is not set
412CONFIG_ARCH_SUSPEND_POSSIBLE=y
413CONFIG_NET=y
414
415#
416# Networking options
417#
418CONFIG_PACKET=y
419# CONFIG_PACKET_MMAP is not set
420CONFIG_UNIX=y
421CONFIG_XFRM=y
422# CONFIG_XFRM_USER is not set
423# CONFIG_XFRM_SUB_POLICY is not set
424# CONFIG_XFRM_MIGRATE is not set
425# CONFIG_XFRM_STATISTICS is not set
426# CONFIG_NET_KEY is not set
427CONFIG_INET=y
428# CONFIG_IP_MULTICAST is not set
429# CONFIG_IP_ADVANCED_ROUTER is not set
430CONFIG_IP_FIB_HASH=y
431CONFIG_IP_PNP=y
432CONFIG_IP_PNP_DHCP=y
433# CONFIG_IP_PNP_BOOTP is not set
434# CONFIG_IP_PNP_RARP is not set
435# CONFIG_NET_IPIP is not set
436# CONFIG_NET_IPGRE is not set
437# CONFIG_ARPD is not set
438CONFIG_SYN_COOKIES=y
439# CONFIG_INET_AH is not set
440# CONFIG_INET_ESP is not set
441# CONFIG_INET_IPCOMP is not set
442# CONFIG_INET_XFRM_TUNNEL is not set
443# CONFIG_INET_TUNNEL is not set
444CONFIG_INET_XFRM_MODE_TRANSPORT=y
445CONFIG_INET_XFRM_MODE_TUNNEL=y
446CONFIG_INET_XFRM_MODE_BEET=y
447# CONFIG_INET_LRO is not set
448CONFIG_INET_DIAG=y
449CONFIG_INET_TCP_DIAG=y
450# CONFIG_TCP_CONG_ADVANCED is not set
451CONFIG_TCP_CONG_CUBIC=y
452CONFIG_DEFAULT_TCP_CONG="cubic"
453# CONFIG_TCP_MD5SIG is not set
454# CONFIG_IPV6 is not set
455# CONFIG_NETWORK_SECMARK is not set
456# CONFIG_NETFILTER is not set
457# CONFIG_IP_DCCP is not set
458# CONFIG_IP_SCTP is not set
459# CONFIG_RDS is not set
460# CONFIG_TIPC is not set
461# CONFIG_ATM is not set
462# CONFIG_BRIDGE is not set
463# CONFIG_NET_DSA is not set
464# CONFIG_VLAN_8021Q is not set
465# CONFIG_DECNET is not set
466# CONFIG_LLC2 is not set
467# CONFIG_IPX is not set
468# CONFIG_ATALK is not set
469# CONFIG_X25 is not set
470# CONFIG_LAPB is not set
471# CONFIG_ECONET is not set
472# CONFIG_WAN_ROUTER is not set
473# CONFIG_PHONET is not set
474# CONFIG_IEEE802154 is not set
475# CONFIG_NET_SCHED is not set
476# CONFIG_DCB is not set
477
478#
479# Network testing
480#
481# CONFIG_NET_PKTGEN is not set
482# CONFIG_HAMRADIO is not set
483# CONFIG_CAN is not set
484# CONFIG_IRDA is not set
485CONFIG_BT=m
486CONFIG_BT_L2CAP=m
487# CONFIG_BT_SCO is not set
488CONFIG_BT_RFCOMM=m
489CONFIG_BT_RFCOMM_TTY=y
490CONFIG_BT_BNEP=m
491# CONFIG_BT_BNEP_MC_FILTER is not set
492# CONFIG_BT_BNEP_PROTO_FILTER is not set
493# CONFIG_BT_HIDP is not set
494
495#
496# Bluetooth device drivers
497#
498# CONFIG_BT_HCIBTUSB is not set
499# CONFIG_BT_HCIBTSDIO is not set
500CONFIG_BT_HCIUART=m
501CONFIG_BT_HCIUART_H4=y
502CONFIG_BT_HCIUART_BCSP=y
503# CONFIG_BT_HCIUART_LL is not set
504# CONFIG_BT_HCIBCM203X is not set
505# CONFIG_BT_HCIBPA10X is not set
506# CONFIG_BT_HCIBFUSB is not set
507# CONFIG_BT_HCIDTL1 is not set
508# CONFIG_BT_HCIBT3C is not set
509# CONFIG_BT_HCIBLUECARD is not set
510# CONFIG_BT_HCIBTUART is not set
511# CONFIG_BT_HCIVHCI is not set
512# CONFIG_BT_MRVL is not set
513# CONFIG_AF_RXRPC is not set
514CONFIG_WIRELESS=y
515CONFIG_WIRELESS_EXT=y
516CONFIG_WEXT_CORE=y
517CONFIG_WEXT_PROC=y
518CONFIG_WEXT_SPY=y
519CONFIG_WEXT_PRIV=y
520CONFIG_CFG80211=m
521# CONFIG_NL80211_TESTMODE is not set
522# CONFIG_CFG80211_DEVELOPER_WARNINGS is not set
523# CONFIG_CFG80211_REG_DEBUG is not set
524CONFIG_CFG80211_DEFAULT_PS=y
525# CONFIG_WIRELESS_OLD_REGULATORY is not set
526CONFIG_CFG80211_WEXT=y
527CONFIG_WIRELESS_EXT_SYSFS=y
528CONFIG_LIB80211=m
529# CONFIG_LIB80211_DEBUG is not set
530CONFIG_MAC80211=m
531CONFIG_MAC80211_RC_MINSTREL=y
532# CONFIG_MAC80211_RC_DEFAULT_PID is not set
533CONFIG_MAC80211_RC_DEFAULT_MINSTREL=y
534CONFIG_MAC80211_RC_DEFAULT="minstrel"
535# CONFIG_MAC80211_MESH is not set
536# CONFIG_MAC80211_LEDS is not set
537# CONFIG_MAC80211_DEBUG_MENU is not set
538# CONFIG_WIMAX is not set
539# CONFIG_RFKILL is not set
540# CONFIG_NET_9P is not set
541
542#
543# Device Drivers
544#
545
546#
547# Generic Driver Options
548#
549CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
550# CONFIG_DEVTMPFS is not set
551CONFIG_STANDALONE=y
552CONFIG_PREVENT_FIRMWARE_BUILD=y
553CONFIG_FW_LOADER=y
554CONFIG_FIRMWARE_IN_KERNEL=y
555CONFIG_EXTRA_FIRMWARE=""
556# CONFIG_DEBUG_DRIVER is not set
557# CONFIG_DEBUG_DEVRES is not set
558# CONFIG_SYS_HYPERVISOR is not set
559# CONFIG_CONNECTOR is not set
560CONFIG_MTD=y
561# CONFIG_MTD_DEBUG is not set
562# CONFIG_MTD_TESTS is not set
563# CONFIG_MTD_CONCAT is not set
564CONFIG_MTD_PARTITIONS=y
565CONFIG_MTD_REDBOOT_PARTS=y
566CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
567# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
568CONFIG_MTD_REDBOOT_PARTS_READONLY=y
569# CONFIG_MTD_CMDLINE_PARTS is not set
570# CONFIG_MTD_AFS_PARTS is not set
571# CONFIG_MTD_AR7_PARTS is not set
572
573#
574# User Modules And Translation Layers
575#
576CONFIG_MTD_CHAR=m
577CONFIG_MTD_BLKDEVS=y
578CONFIG_MTD_BLOCK=y
579# CONFIG_FTL is not set
580# CONFIG_NFTL is not set
581# CONFIG_INFTL is not set
582# CONFIG_RFD_FTL is not set
583# CONFIG_SSFDC is not set
584# CONFIG_MTD_OOPS is not set
585
586#
587# RAM/ROM/Flash chip drivers
588#
589CONFIG_MTD_CFI=y
590CONFIG_MTD_JEDECPROBE=y
591CONFIG_MTD_GEN_PROBE=y
592CONFIG_MTD_CFI_ADV_OPTIONS=y
593CONFIG_MTD_CFI_NOSWAP=y
594# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
595# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
596CONFIG_MTD_CFI_GEOMETRY=y
597CONFIG_MTD_MAP_BANK_WIDTH_1=y
598CONFIG_MTD_MAP_BANK_WIDTH_2=y
599# CONFIG_MTD_MAP_BANK_WIDTH_4 is not set
600# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
601# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
602# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
603CONFIG_MTD_CFI_I1=y
604# CONFIG_MTD_CFI_I2 is not set
605# CONFIG_MTD_CFI_I4 is not set
606# CONFIG_MTD_CFI_I8 is not set
607# CONFIG_MTD_OTP is not set
608CONFIG_MTD_CFI_INTELEXT=y
609CONFIG_MTD_CFI_AMDSTD=y
610# CONFIG_MTD_CFI_STAA is not set
611CONFIG_MTD_CFI_UTIL=y
612CONFIG_MTD_RAM=y
613# CONFIG_MTD_ROM is not set
614# CONFIG_MTD_ABSENT is not set
615# CONFIG_MTD_XIP is not set
616
617#
618# Mapping drivers for chip access
619#
620CONFIG_MTD_COMPLEX_MAPPINGS=y
621CONFIG_MTD_PHYSMAP=y
622# CONFIG_MTD_PHYSMAP_COMPAT is not set
623CONFIG_MTD_PXA2XX=y
624# CONFIG_MTD_ARM_INTEGRATOR is not set
625# CONFIG_MTD_IMPA7 is not set
626# CONFIG_MTD_GPIO_ADDR is not set
627# CONFIG_MTD_PLATRAM is not set
628
629#
630# Self-contained MTD device drivers
631#
632# CONFIG_MTD_DATAFLASH is not set
633# CONFIG_MTD_M25P80 is not set
634# CONFIG_MTD_SST25L is not set
635# CONFIG_MTD_SLRAM is not set
636# CONFIG_MTD_PHRAM is not set
637# CONFIG_MTD_MTDRAM is not set
638# CONFIG_MTD_BLOCK2MTD is not set
639
640#
641# Disk-On-Chip Device Drivers
642#
643# CONFIG_MTD_DOC2000 is not set
644# CONFIG_MTD_DOC2001 is not set
645# CONFIG_MTD_DOC2001PLUS is not set
646# CONFIG_MTD_NAND is not set
647# CONFIG_MTD_ONENAND is not set
648
649#
650# LPDDR flash memory drivers
651#
652# CONFIG_MTD_LPDDR is not set
653
654#
655# UBI - Unsorted block images
656#
657# CONFIG_MTD_UBI is not set
658# CONFIG_PARPORT is not set
659# CONFIG_PNP is not set
660CONFIG_BLK_DEV=y
661# CONFIG_BLK_DEV_COW_COMMON is not set
662CONFIG_BLK_DEV_LOOP=m
663# CONFIG_BLK_DEV_CRYPTOLOOP is not set
664
665#
666# DRBD disabled because PROC_FS, INET or CONNECTOR not selected
667#
668# CONFIG_BLK_DEV_NBD is not set
669# CONFIG_BLK_DEV_UB is not set
670# CONFIG_BLK_DEV_RAM is not set
671# CONFIG_CDROM_PKTCDVD is not set
672# CONFIG_ATA_OVER_ETH is not set
673# CONFIG_MG_DISK is not set
674CONFIG_MISC_DEVICES=y
675# CONFIG_ICS932S401 is not set
676# CONFIG_ENCLOSURE_SERVICES is not set
677# CONFIG_ISL29003 is not set
678# CONFIG_DS1682 is not set
679# CONFIG_C2PORT is not set
680
681#
682# EEPROM support
683#
684CONFIG_EEPROM_AT24=m
685# CONFIG_EEPROM_AT25 is not set
686# CONFIG_EEPROM_LEGACY is not set
687# CONFIG_EEPROM_MAX6875 is not set
688# CONFIG_EEPROM_93CX6 is not set
689# CONFIG_IWMC3200TOP is not set
690CONFIG_HAVE_IDE=y
691# CONFIG_IDE is not set
692
693#
694# SCSI device support
695#
696# CONFIG_RAID_ATTRS is not set
697CONFIG_SCSI=m
698CONFIG_SCSI_DMA=y
699# CONFIG_SCSI_TGT is not set
700# CONFIG_SCSI_NETLINK is not set
701# CONFIG_SCSI_PROC_FS is not set
702
703#
704# SCSI support type (disk, tape, CD-ROM)
705#
706CONFIG_BLK_DEV_SD=m
707# CONFIG_CHR_DEV_ST is not set
708# CONFIG_CHR_DEV_OSST is not set
709# CONFIG_BLK_DEV_SR is not set
710# CONFIG_CHR_DEV_SG is not set
711# CONFIG_CHR_DEV_SCH is not set
712# CONFIG_SCSI_MULTI_LUN is not set
713# CONFIG_SCSI_CONSTANTS is not set
714# CONFIG_SCSI_LOGGING is not set
715# CONFIG_SCSI_SCAN_ASYNC is not set
716CONFIG_SCSI_WAIT_SCAN=m
717
718#
719# SCSI Transports
720#
721# CONFIG_SCSI_SPI_ATTRS is not set
722# CONFIG_SCSI_FC_ATTRS is not set
723# CONFIG_SCSI_ISCSI_ATTRS is not set
724# CONFIG_SCSI_SAS_LIBSAS is not set
725# CONFIG_SCSI_SRP_ATTRS is not set
726CONFIG_SCSI_LOWLEVEL=y
727# CONFIG_ISCSI_TCP is not set
728# CONFIG_SCSI_AHA152X is not set
729# CONFIG_SCSI_AIC7XXX_OLD is not set
730# CONFIG_SCSI_ADVANSYS is not set
731# CONFIG_SCSI_IN2000 is not set
732# CONFIG_LIBFC is not set
733# CONFIG_LIBFCOE is not set
734# CONFIG_SCSI_DTC3280 is not set
735# CONFIG_SCSI_FUTURE_DOMAIN is not set
736# CONFIG_SCSI_GENERIC_NCR5380 is not set
737# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
738# CONFIG_SCSI_NCR53C406A is not set
739# CONFIG_SCSI_PAS16 is not set
740# CONFIG_SCSI_QLOGIC_FAS is not set
741# CONFIG_SCSI_SYM53C416 is not set
742# CONFIG_SCSI_T128 is not set
743# CONFIG_SCSI_DEBUG is not set
744# CONFIG_SCSI_LOWLEVEL_PCMCIA is not set
745# CONFIG_SCSI_DH is not set
746# CONFIG_SCSI_OSD_INITIATOR is not set
747CONFIG_ATA=m
748# CONFIG_ATA_NONSTANDARD is not set
749CONFIG_ATA_VERBOSE_ERROR=y
750# CONFIG_SATA_PMP is not set
751CONFIG_ATA_SFF=y
752# CONFIG_SATA_MV is not set
753# CONFIG_PATA_LEGACY is not set
754CONFIG_PATA_PCMCIA=m
755# CONFIG_PATA_QDI is not set
756# CONFIG_PATA_WINBOND_VLB is not set
757# CONFIG_MD is not set
758CONFIG_NETDEVICES=y
759# CONFIG_DUMMY is not set
760# CONFIG_BONDING is not set
761# CONFIG_MACVLAN is not set
762# CONFIG_EQUALIZER is not set
763# CONFIG_TUN is not set
764# CONFIG_VETH is not set
765# CONFIG_ARCNET is not set
766# CONFIG_PHYLIB is not set
767CONFIG_NET_ETHERNET=y
768CONFIG_MII=y
769# CONFIG_AX88796 is not set
770# CONFIG_NET_VENDOR_3COM is not set
771# CONFIG_NET_VENDOR_SMC is not set
772# CONFIG_SMC91X is not set
773CONFIG_DM9000=y
774CONFIG_DM9000_DEBUGLEVEL=4
775# CONFIG_DM9000_FORCE_SIMPLE_PHY_POLL is not set
776# CONFIG_ENC28J60 is not set
777# CONFIG_ETHOC is not set
778# CONFIG_SMC911X is not set
779# CONFIG_SMSC911X is not set
780# CONFIG_NET_VENDOR_RACAL is not set
781# CONFIG_DNET is not set
782# CONFIG_AT1700 is not set
783# CONFIG_DEPCA is not set
784# CONFIG_HP100 is not set
785# CONFIG_NET_ISA is not set
786# CONFIG_IBM_NEW_EMAC_ZMII is not set
787# CONFIG_IBM_NEW_EMAC_RGMII is not set
788# CONFIG_IBM_NEW_EMAC_TAH is not set
789# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
790# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
791# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
792# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
793# CONFIG_NET_PCI is not set
794# CONFIG_B44 is not set
795# CONFIG_CS89x0 is not set
796# CONFIG_KS8842 is not set
797# CONFIG_KS8851 is not set
798# CONFIG_KS8851_MLL is not set
799# CONFIG_NETDEV_1000 is not set
800# CONFIG_NETDEV_10000 is not set
801# CONFIG_TR is not set
802CONFIG_WLAN=y
803# CONFIG_PCMCIA_RAYCS is not set
804# CONFIG_LIBERTAS_THINFIRM is not set
805# CONFIG_ATMEL is not set
806# CONFIG_AT76C50X_USB is not set
807# CONFIG_AIRO_CS is not set
808# CONFIG_PCMCIA_WL3501 is not set
809# CONFIG_USB_ZD1201 is not set
810# CONFIG_USB_NET_RNDIS_WLAN is not set
811# CONFIG_RTL8187 is not set
812# CONFIG_MAC80211_HWSIM is not set
813# CONFIG_ATH_COMMON is not set
814# CONFIG_B43 is not set
815# CONFIG_B43LEGACY is not set
816# CONFIG_HOSTAP is not set
817# CONFIG_IWM is not set
818# CONFIG_LIBERTAS is not set
819CONFIG_HERMES=m
820CONFIG_HERMES_CACHE_FW_ON_INIT=y
821CONFIG_PCMCIA_HERMES=m
822# CONFIG_PCMCIA_SPECTRUM is not set
823# CONFIG_P54_COMMON is not set
824CONFIG_RT2X00=m
825# CONFIG_RT2500USB is not set
826CONFIG_RT73USB=m
827# CONFIG_RT2800USB is not set
828CONFIG_RT2X00_LIB_USB=m
829CONFIG_RT2X00_LIB=m
830CONFIG_RT2X00_LIB_FIRMWARE=y
831CONFIG_RT2X00_LIB_CRYPTO=y
832CONFIG_RT2X00_LIB_LEDS=y
833# CONFIG_RT2X00_DEBUG is not set
834# CONFIG_WL12XX is not set
835# CONFIG_ZD1211RW is not set
836
837#
838# Enable WiMAX (Networking options) to see the WiMAX drivers
839#
840
841#
842# USB Network Adapters
843#
844# CONFIG_USB_CATC is not set
845# CONFIG_USB_KAWETH is not set
846# CONFIG_USB_PEGASUS is not set
847# CONFIG_USB_RTL8150 is not set
848# CONFIG_USB_USBNET is not set
849CONFIG_NET_PCMCIA=y
850# CONFIG_PCMCIA_3C589 is not set
851# CONFIG_PCMCIA_3C574 is not set
852# CONFIG_PCMCIA_FMVJ18X is not set
853# CONFIG_PCMCIA_PCNET is not set
854# CONFIG_PCMCIA_NMCLAN is not set
855# CONFIG_PCMCIA_SMC91C92 is not set
856# CONFIG_PCMCIA_XIRC2PS is not set
857# CONFIG_PCMCIA_AXNET is not set
858# CONFIG_WAN is not set
859CONFIG_PPP=m
860# CONFIG_PPP_MULTILINK is not set
861# CONFIG_PPP_FILTER is not set
862CONFIG_PPP_ASYNC=m
863# CONFIG_PPP_SYNC_TTY is not set
864CONFIG_PPP_DEFLATE=m
865CONFIG_PPP_BSDCOMP=m
866# CONFIG_PPP_MPPE is not set
867# CONFIG_PPPOE is not set
868# CONFIG_PPPOL2TP is not set
869# CONFIG_SLIP is not set
870CONFIG_SLHC=m
871# CONFIG_NETCONSOLE is not set
872# CONFIG_NETPOLL is not set
873# CONFIG_NET_POLL_CONTROLLER is not set
874# CONFIG_ISDN is not set
875# CONFIG_PHONE is not set
876
877#
878# Input device support
879#
880CONFIG_INPUT=y
881# CONFIG_INPUT_FF_MEMLESS is not set
882# CONFIG_INPUT_POLLDEV is not set
883
884#
885# Userland interfaces
886#
887CONFIG_INPUT_MOUSEDEV=y
888# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
889CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
890CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
891# CONFIG_INPUT_JOYDEV is not set
892CONFIG_INPUT_EVDEV=m
893# CONFIG_INPUT_EVBUG is not set
894
895#
896# Input Device Drivers
897#
898# CONFIG_INPUT_KEYBOARD is not set
899# CONFIG_INPUT_MOUSE is not set
900# CONFIG_INPUT_JOYSTICK is not set
901# CONFIG_INPUT_TABLET is not set
902CONFIG_INPUT_TOUCHSCREEN=y
903# CONFIG_TOUCHSCREEN_ADS7846 is not set
904# CONFIG_TOUCHSCREEN_AD7877 is not set
905# CONFIG_TOUCHSCREEN_AD7879_I2C is not set
906# CONFIG_TOUCHSCREEN_AD7879_SPI is not set
907# CONFIG_TOUCHSCREEN_AD7879 is not set
908# CONFIG_TOUCHSCREEN_EETI is not set
909CONFIG_TOUCHSCREEN_FUJITSU=m
910# CONFIG_TOUCHSCREEN_GUNZE is not set
911CONFIG_TOUCHSCREEN_ELO=m
912# CONFIG_TOUCHSCREEN_WACOM_W8001 is not set
913# CONFIG_TOUCHSCREEN_MCS5000 is not set
914CONFIG_TOUCHSCREEN_MTOUCH=m
915CONFIG_TOUCHSCREEN_INEXIO=m
916# CONFIG_TOUCHSCREEN_MK712 is not set
917CONFIG_TOUCHSCREEN_HTCPEN=m
918CONFIG_TOUCHSCREEN_PENMOUNT=m
919CONFIG_TOUCHSCREEN_TOUCHRIGHT=m
920CONFIG_TOUCHSCREEN_TOUCHWIN=m
921# CONFIG_TOUCHSCREEN_WM97XX is not set
922# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set
923CONFIG_TOUCHSCREEN_TOUCHIT213=m
924# CONFIG_TOUCHSCREEN_TSC2007 is not set
925# CONFIG_TOUCHSCREEN_W90X900 is not set
926CONFIG_INPUT_MISC=y
927# CONFIG_INPUT_ATI_REMOTE is not set
928# CONFIG_INPUT_ATI_REMOTE2 is not set
929# CONFIG_INPUT_KEYSPAN_REMOTE is not set
930# CONFIG_INPUT_POWERMATE is not set
931# CONFIG_INPUT_YEALINK is not set
932# CONFIG_INPUT_CM109 is not set
933CONFIG_INPUT_UINPUT=m
934# CONFIG_INPUT_GPIO_ROTARY_ENCODER is not set
935
936#
937# Hardware I/O ports
938#
939CONFIG_SERIO=y
940CONFIG_SERIO_SERPORT=y
941# CONFIG_SERIO_RAW is not set
942# CONFIG_GAMEPORT is not set
943
944#
945# Character devices
946#
947CONFIG_VT=y
948CONFIG_CONSOLE_TRANSLATIONS=y
949CONFIG_VT_CONSOLE=y
950CONFIG_HW_CONSOLE=y
951# CONFIG_VT_HW_CONSOLE_BINDING is not set
952CONFIG_DEVKMEM=y
953# CONFIG_SERIAL_NONSTANDARD is not set
954
955#
956# Serial drivers
957#
958CONFIG_SERIAL_8250=y
959CONFIG_SERIAL_8250_CONSOLE=y
960# CONFIG_SERIAL_8250_CS is not set
961CONFIG_SERIAL_8250_NR_UARTS=7
962CONFIG_SERIAL_8250_RUNTIME_UARTS=7
963# CONFIG_SERIAL_8250_EXTENDED is not set
964
965#
966# Non-8250 serial port support
967#
968# CONFIG_SERIAL_MAX3100 is not set
969# CONFIG_SERIAL_PXA is not set
970CONFIG_SERIAL_CORE=y
971CONFIG_SERIAL_CORE_CONSOLE=y
972CONFIG_UNIX98_PTYS=y
973# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
974# CONFIG_LEGACY_PTYS is not set
975# CONFIG_IPMI_HANDLER is not set
976CONFIG_HW_RANDOM=m
977# CONFIG_HW_RANDOM_TIMERIOMEM is not set
978# CONFIG_DTLK is not set
979# CONFIG_R3964 is not set
980
981#
982# PCMCIA character devices
983#
984# CONFIG_SYNCLINK_CS is not set
985# CONFIG_CARDMAN_4000 is not set
986# CONFIG_CARDMAN_4040 is not set
987# CONFIG_IPWIRELESS is not set
988# CONFIG_RAW_DRIVER is not set
989# CONFIG_TCG_TPM is not set
990CONFIG_DEVPORT=y
991CONFIG_I2C=y
992CONFIG_I2C_BOARDINFO=y
993CONFIG_I2C_COMPAT=y
994CONFIG_I2C_CHARDEV=y
995# CONFIG_I2C_HELPER_AUTO is not set
996
997#
998# I2C Algorithms
999#
1000CONFIG_I2C_ALGOBIT=y
1001# CONFIG_I2C_ALGOPCF is not set
1002# CONFIG_I2C_ALGOPCA is not set
1003
1004#
1005# I2C Hardware Bus support
1006#
1007
1008#
1009# I2C system bus drivers (mostly embedded / system-on-chip)
1010#
1011# CONFIG_I2C_DESIGNWARE is not set
1012CONFIG_I2C_GPIO=y
1013# CONFIG_I2C_OCORES is not set
1014CONFIG_I2C_PXA=y
1015# CONFIG_I2C_PXA_SLAVE is not set
1016# CONFIG_I2C_SIMTEC is not set
1017
1018#
1019# External I2C/SMBus adapter drivers
1020#
1021# CONFIG_I2C_PARPORT_LIGHT is not set
1022# CONFIG_I2C_TAOS_EVM is not set
1023# CONFIG_I2C_TINY_USB is not set
1024
1025#
1026# Other I2C/SMBus bus drivers
1027#
1028# CONFIG_I2C_ELEKTOR is not set
1029# CONFIG_I2C_PCA_ISA is not set
1030# CONFIG_I2C_PCA_PLATFORM is not set
1031# CONFIG_I2C_STUB is not set
1032
1033#
1034# Miscellaneous I2C Chip support
1035#
1036# CONFIG_SENSORS_TSL2550 is not set
1037# CONFIG_I2C_DEBUG_CORE is not set
1038# CONFIG_I2C_DEBUG_ALGO is not set
1039# CONFIG_I2C_DEBUG_BUS is not set
1040# CONFIG_I2C_DEBUG_CHIP is not set
1041CONFIG_SPI=y
1042# CONFIG_SPI_DEBUG is not set
1043CONFIG_SPI_MASTER=y
1044
1045#
1046# SPI Master Controller Drivers
1047#
1048# CONFIG_SPI_BITBANG is not set
1049# CONFIG_SPI_GPIO is not set
1050CONFIG_SPI_PXA2XX=y
1051
1052#
1053# SPI Protocol Masters
1054#
1055# CONFIG_SPI_SPIDEV is not set
1056# CONFIG_SPI_TLE62X0 is not set
1057
1058#
1059# PPS support
1060#
1061# CONFIG_PPS is not set
1062CONFIG_ARCH_REQUIRE_GPIOLIB=y
1063CONFIG_GPIOLIB=y
1064# CONFIG_DEBUG_GPIO is not set
1065CONFIG_GPIO_SYSFS=y
1066
1067#
1068# Memory mapped GPIO expanders:
1069#
1070
1071#
1072# I2C GPIO expanders:
1073#
1074# CONFIG_GPIO_MAX732X is not set
1075CONFIG_GPIO_PCA953X=y
1076# CONFIG_GPIO_PCF857X is not set
1077
1078#
1079# PCI GPIO expanders:
1080#
1081
1082#
1083# SPI GPIO expanders:
1084#
1085# CONFIG_GPIO_MAX7301 is not set
1086# CONFIG_GPIO_MCP23S08 is not set
1087# CONFIG_GPIO_MC33880 is not set
1088
1089#
1090# AC97 GPIO expanders:
1091#
1092# CONFIG_W1 is not set
1093# CONFIG_POWER_SUPPLY is not set
1094CONFIG_HWMON=y
1095# CONFIG_HWMON_VID is not set
1096# CONFIG_HWMON_DEBUG_CHIP is not set
1097
1098#
1099# Native drivers
1100#
1101# CONFIG_SENSORS_AD7414 is not set
1102# CONFIG_SENSORS_AD7418 is not set
1103# CONFIG_SENSORS_ADCXX is not set
1104# CONFIG_SENSORS_ADM1021 is not set
1105# CONFIG_SENSORS_ADM1025 is not set
1106# CONFIG_SENSORS_ADM1026 is not set
1107# CONFIG_SENSORS_ADM1029 is not set
1108# CONFIG_SENSORS_ADM1031 is not set
1109# CONFIG_SENSORS_ADM9240 is not set
1110# CONFIG_SENSORS_ADT7462 is not set
1111# CONFIG_SENSORS_ADT7470 is not set
1112# CONFIG_SENSORS_ADT7473 is not set
1113# CONFIG_SENSORS_ADT7475 is not set
1114# CONFIG_SENSORS_ATXP1 is not set
1115# CONFIG_SENSORS_DS1621 is not set
1116# CONFIG_SENSORS_F71805F is not set
1117# CONFIG_SENSORS_F71882FG is not set
1118# CONFIG_SENSORS_F75375S is not set
1119# CONFIG_SENSORS_G760A is not set
1120# CONFIG_SENSORS_GL518SM is not set
1121# CONFIG_SENSORS_GL520SM is not set
1122# CONFIG_SENSORS_IT87 is not set
1123# CONFIG_SENSORS_LM63 is not set
1124# CONFIG_SENSORS_LM70 is not set
1125CONFIG_SENSORS_LM75=m
1126# CONFIG_SENSORS_LM77 is not set
1127# CONFIG_SENSORS_LM78 is not set
1128# CONFIG_SENSORS_LM80 is not set
1129# CONFIG_SENSORS_LM83 is not set
1130# CONFIG_SENSORS_LM85 is not set
1131# CONFIG_SENSORS_LM87 is not set
1132# CONFIG_SENSORS_LM90 is not set
1133# CONFIG_SENSORS_LM92 is not set
1134# CONFIG_SENSORS_LM93 is not set
1135# CONFIG_SENSORS_LTC4215 is not set
1136# CONFIG_SENSORS_LTC4245 is not set
1137# CONFIG_SENSORS_LM95241 is not set
1138# CONFIG_SENSORS_MAX1111 is not set
1139# CONFIG_SENSORS_MAX1619 is not set
1140# CONFIG_SENSORS_MAX6650 is not set
1141# CONFIG_SENSORS_PC87360 is not set
1142# CONFIG_SENSORS_PC87427 is not set
1143# CONFIG_SENSORS_PCF8591 is not set
1144# CONFIG_SENSORS_SHT15 is not set
1145# CONFIG_SENSORS_DME1737 is not set
1146# CONFIG_SENSORS_SMSC47M1 is not set
1147# CONFIG_SENSORS_SMSC47M192 is not set
1148# CONFIG_SENSORS_SMSC47B397 is not set
1149# CONFIG_SENSORS_ADS7828 is not set
1150# CONFIG_SENSORS_THMC50 is not set
1151# CONFIG_SENSORS_TMP401 is not set
1152# CONFIG_SENSORS_TMP421 is not set
1153# CONFIG_SENSORS_VT1211 is not set
1154# CONFIG_SENSORS_W83781D is not set
1155# CONFIG_SENSORS_W83791D is not set
1156# CONFIG_SENSORS_W83792D is not set
1157# CONFIG_SENSORS_W83793 is not set
1158# CONFIG_SENSORS_W83L785TS is not set
1159# CONFIG_SENSORS_W83L786NG is not set
1160# CONFIG_SENSORS_W83627HF is not set
1161# CONFIG_SENSORS_W83627EHF is not set
1162# CONFIG_SENSORS_LIS3_SPI is not set
1163# CONFIG_THERMAL is not set
1164CONFIG_WATCHDOG=y
1165# CONFIG_WATCHDOG_NOWAYOUT is not set
1166
1167#
1168# Watchdog Device Drivers
1169#
1170# CONFIG_SOFT_WATCHDOG is not set
1171# CONFIG_SA1100_WATCHDOG is not set
1172
1173#
1174# ISA-based Watchdog Cards
1175#
1176# CONFIG_PCWATCHDOG is not set
1177# CONFIG_MIXCOMWD is not set
1178# CONFIG_WDT is not set
1179
1180#
1181# USB-based Watchdog Cards
1182#
1183# CONFIG_USBPCWATCHDOG is not set
1184CONFIG_SSB_POSSIBLE=y
1185
1186#
1187# Sonics Silicon Backplane
1188#
1189# CONFIG_SSB is not set
1190
1191#
1192# Multifunction device drivers
1193#
1194# CONFIG_MFD_CORE is not set
1195# CONFIG_MFD_SM501 is not set
1196# CONFIG_MFD_ASIC3 is not set
1197# CONFIG_HTC_EGPIO is not set
1198# CONFIG_HTC_PASIC3 is not set
1199# CONFIG_UCB1400_CORE is not set
1200# CONFIG_TPS65010 is not set
1201# CONFIG_TWL4030_CORE is not set
1202# CONFIG_MFD_TMIO is not set
1203# CONFIG_MFD_T7L66XB is not set
1204# CONFIG_MFD_TC6387XB is not set
1205# CONFIG_MFD_TC6393XB is not set
1206# CONFIG_PMIC_DA903X is not set
1207# CONFIG_MFD_WM8400 is not set
1208# CONFIG_MFD_WM831X is not set
1209# CONFIG_MFD_WM8350_I2C is not set
1210# CONFIG_MFD_PCF50633 is not set
1211# CONFIG_MFD_MC13783 is not set
1212# CONFIG_AB3100_CORE is not set
1213# CONFIG_EZX_PCAP is not set
1214# CONFIG_REGULATOR is not set
1215# CONFIG_MEDIA_SUPPORT is not set
1216
1217#
1218# Graphics support
1219#
1220# CONFIG_VGASTATE is not set
1221# CONFIG_VIDEO_OUTPUT_CONTROL is not set
1222CONFIG_FB=y
1223# CONFIG_FIRMWARE_EDID is not set
1224# CONFIG_FB_DDC is not set
1225# CONFIG_FB_BOOT_VESA_SUPPORT is not set
1226CONFIG_FB_CFB_FILLRECT=m
1227CONFIG_FB_CFB_COPYAREA=m
1228CONFIG_FB_CFB_IMAGEBLIT=m
1229# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
1230# CONFIG_FB_SYS_FILLRECT is not set
1231# CONFIG_FB_SYS_COPYAREA is not set
1232# CONFIG_FB_SYS_IMAGEBLIT is not set
1233# CONFIG_FB_FOREIGN_ENDIAN is not set
1234# CONFIG_FB_SYS_FOPS is not set
1235# CONFIG_FB_SVGALIB is not set
1236# CONFIG_FB_MACMODES is not set
1237# CONFIG_FB_BACKLIGHT is not set
1238# CONFIG_FB_MODE_HELPERS is not set
1239# CONFIG_FB_TILEBLITTING is not set
1240
1241#
1242# Frame buffer hardware drivers
1243#
1244# CONFIG_FB_S1D13XXX is not set
1245CONFIG_FB_PXA=m
1246# CONFIG_FB_PXA_OVERLAY is not set
1247# CONFIG_FB_PXA_SMARTPANEL is not set
1248CONFIG_FB_PXA_PARAMETERS=y
1249# CONFIG_FB_MBX is not set
1250# CONFIG_FB_W100 is not set
1251# CONFIG_FB_VIRTUAL is not set
1252# CONFIG_FB_METRONOME is not set
1253# CONFIG_FB_MB862XX is not set
1254# CONFIG_FB_BROADSHEET is not set
1255CONFIG_BACKLIGHT_LCD_SUPPORT=y
1256CONFIG_LCD_CLASS_DEVICE=m
1257# CONFIG_LCD_LMS283GF05 is not set
1258# CONFIG_LCD_LTV350QV is not set
1259# CONFIG_LCD_ILI9320 is not set
1260# CONFIG_LCD_TDO24M is not set
1261# CONFIG_LCD_VGG2432A4 is not set
1262# CONFIG_LCD_PLATFORM is not set
1263CONFIG_BACKLIGHT_CLASS_DEVICE=m
1264CONFIG_BACKLIGHT_GENERIC=m
1265
1266#
1267# Display device support
1268#
1269# CONFIG_DISPLAY_SUPPORT is not set
1270
1271#
1272# Console display driver support
1273#
1274# CONFIG_VGA_CONSOLE is not set
1275# CONFIG_MDA_CONSOLE is not set
1276CONFIG_DUMMY_CONSOLE=y
1277CONFIG_FRAMEBUFFER_CONSOLE=m
1278# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
1279# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
1280# CONFIG_FONTS is not set
1281CONFIG_FONT_8x8=y
1282CONFIG_FONT_8x16=y
1283CONFIG_LOGO=y
1284CONFIG_LOGO_LINUX_MONO=y
1285CONFIG_LOGO_LINUX_VGA16=y
1286CONFIG_LOGO_LINUX_CLUT224=y
1287CONFIG_SOUND=m
1288CONFIG_SOUND_OSS_CORE=y
1289CONFIG_SOUND_OSS_CORE_PRECLAIM=y
1290CONFIG_SND=m
1291CONFIG_SND_TIMER=m
1292CONFIG_SND_PCM=m
1293CONFIG_SND_JACK=y
1294# CONFIG_SND_SEQUENCER is not set
1295CONFIG_SND_OSSEMUL=y
1296CONFIG_SND_MIXER_OSS=m
1297CONFIG_SND_PCM_OSS=m
1298CONFIG_SND_PCM_OSS_PLUGINS=y
1299# CONFIG_SND_DYNAMIC_MINORS is not set
1300# CONFIG_SND_SUPPORT_OLD_API is not set
1301CONFIG_SND_VERBOSE_PROCFS=y
1302# CONFIG_SND_VERBOSE_PRINTK is not set
1303# CONFIG_SND_DEBUG is not set
1304CONFIG_SND_VMASTER=y
1305# CONFIG_SND_RAWMIDI_SEQ is not set
1306# CONFIG_SND_OPL3_LIB_SEQ is not set
1307# CONFIG_SND_OPL4_LIB_SEQ is not set
1308# CONFIG_SND_SBAWE_SEQ is not set
1309# CONFIG_SND_EMU10K1_SEQ is not set
1310CONFIG_SND_AC97_CODEC=m
1311CONFIG_SND_DRIVERS=y
1312# CONFIG_SND_DUMMY is not set
1313# CONFIG_SND_MTPAV is not set
1314# CONFIG_SND_SERIAL_U16550 is not set
1315# CONFIG_SND_MPU401 is not set
1316# CONFIG_SND_AC97_POWER_SAVE is not set
1317CONFIG_SND_ARM=y
1318CONFIG_SND_PXA2XX_PCM=m
1319CONFIG_SND_PXA2XX_LIB=m
1320CONFIG_SND_PXA2XX_LIB_AC97=y
1321CONFIG_SND_PXA2XX_AC97=m
1322# CONFIG_SND_SPI is not set
1323CONFIG_SND_USB=y
1324# CONFIG_SND_USB_AUDIO is not set
1325# CONFIG_SND_USB_CAIAQ is not set
1326# CONFIG_SND_PCMCIA is not set
1327CONFIG_SND_SOC=m
1328CONFIG_SND_PXA2XX_SOC=m
1329CONFIG_SND_SOC_I2C_AND_SPI=m
1330# CONFIG_SND_SOC_ALL_CODECS is not set
1331# CONFIG_SOUND_PRIME is not set
1332CONFIG_AC97_BUS=m
1333# CONFIG_HID_SUPPORT is not set
1334CONFIG_USB_SUPPORT=y
1335CONFIG_USB_ARCH_HAS_HCD=y
1336CONFIG_USB_ARCH_HAS_OHCI=y
1337# CONFIG_USB_ARCH_HAS_EHCI is not set
1338CONFIG_USB=m
1339# CONFIG_USB_DEBUG is not set
1340# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
1341
1342#
1343# Miscellaneous USB options
1344#
1345CONFIG_USB_DEVICEFS=y
1346CONFIG_USB_DEVICE_CLASS=y
1347# CONFIG_USB_DYNAMIC_MINORS is not set
1348CONFIG_USB_SUSPEND=y
1349# CONFIG_USB_OTG is not set
1350# CONFIG_USB_MON is not set
1351# CONFIG_USB_WUSB is not set
1352# CONFIG_USB_WUSB_CBAF is not set
1353
1354#
1355# USB Host Controller Drivers
1356#
1357# CONFIG_USB_C67X00_HCD is not set
1358# CONFIG_USB_OXU210HP_HCD is not set
1359# CONFIG_USB_ISP116X_HCD is not set
1360# CONFIG_USB_ISP1760_HCD is not set
1361# CONFIG_USB_ISP1362_HCD is not set
1362CONFIG_USB_OHCI_HCD=m
1363# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
1364# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
1365CONFIG_USB_OHCI_LITTLE_ENDIAN=y
1366# CONFIG_USB_SL811_HCD is not set
1367# CONFIG_USB_R8A66597_HCD is not set
1368# CONFIG_USB_HWA_HCD is not set
1369# CONFIG_USB_MUSB_HDRC is not set
1370# CONFIG_USB_GADGET_MUSB_HDRC is not set
1371
1372#
1373# USB Device Class drivers
1374#
1375CONFIG_USB_ACM=m
1376# CONFIG_USB_PRINTER is not set
1377# CONFIG_USB_WDM is not set
1378# CONFIG_USB_TMC is not set
1379
1380#
1381# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
1382#
1383
1384#
1385# also be needed; see USB_STORAGE Help for more info
1386#
1387CONFIG_USB_STORAGE=m
1388# CONFIG_USB_STORAGE_DEBUG is not set
1389# CONFIG_USB_STORAGE_DATAFAB is not set
1390# CONFIG_USB_STORAGE_FREECOM is not set
1391# CONFIG_USB_STORAGE_ISD200 is not set
1392# CONFIG_USB_STORAGE_USBAT is not set
1393# CONFIG_USB_STORAGE_SDDR09 is not set
1394# CONFIG_USB_STORAGE_SDDR55 is not set
1395# CONFIG_USB_STORAGE_JUMPSHOT is not set
1396# CONFIG_USB_STORAGE_ALAUDA is not set
1397# CONFIG_USB_STORAGE_ONETOUCH is not set
1398# CONFIG_USB_STORAGE_KARMA is not set
1399# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
1400# CONFIG_USB_LIBUSUAL is not set
1401
1402#
1403# USB Imaging devices
1404#
1405# CONFIG_USB_MDC800 is not set
1406# CONFIG_USB_MICROTEK is not set
1407
1408#
1409# USB port drivers
1410#
1411CONFIG_USB_SERIAL=m
1412# CONFIG_USB_EZUSB is not set
1413CONFIG_USB_SERIAL_GENERIC=y
1414# CONFIG_USB_SERIAL_AIRCABLE is not set
1415# CONFIG_USB_SERIAL_ARK3116 is not set
1416# CONFIG_USB_SERIAL_BELKIN is not set
1417# CONFIG_USB_SERIAL_CH341 is not set
1418# CONFIG_USB_SERIAL_WHITEHEAT is not set
1419# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
1420# CONFIG_USB_SERIAL_CP210X is not set
1421# CONFIG_USB_SERIAL_CYPRESS_M8 is not set
1422# CONFIG_USB_SERIAL_EMPEG is not set
1423# CONFIG_USB_SERIAL_FTDI_SIO is not set
1424# CONFIG_USB_SERIAL_FUNSOFT is not set
1425# CONFIG_USB_SERIAL_VISOR is not set
1426# CONFIG_USB_SERIAL_IPAQ is not set
1427# CONFIG_USB_SERIAL_IR is not set
1428# CONFIG_USB_SERIAL_EDGEPORT is not set
1429# CONFIG_USB_SERIAL_EDGEPORT_TI is not set
1430# CONFIG_USB_SERIAL_GARMIN is not set
1431# CONFIG_USB_SERIAL_IPW is not set
1432# CONFIG_USB_SERIAL_IUU is not set
1433# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
1434# CONFIG_USB_SERIAL_KEYSPAN is not set
1435# CONFIG_USB_SERIAL_KLSI is not set
1436# CONFIG_USB_SERIAL_KOBIL_SCT is not set
1437CONFIG_USB_SERIAL_MCT_U232=m
1438# CONFIG_USB_SERIAL_MOS7720 is not set
1439# CONFIG_USB_SERIAL_MOS7840 is not set
1440# CONFIG_USB_SERIAL_MOTOROLA is not set
1441# CONFIG_USB_SERIAL_NAVMAN is not set
1442# CONFIG_USB_SERIAL_PL2303 is not set
1443# CONFIG_USB_SERIAL_OTI6858 is not set
1444# CONFIG_USB_SERIAL_QUALCOMM is not set
1445# CONFIG_USB_SERIAL_SPCP8X5 is not set
1446# CONFIG_USB_SERIAL_HP4X is not set
1447# CONFIG_USB_SERIAL_SAFE is not set
1448# CONFIG_USB_SERIAL_SIEMENS_MPI is not set
1449# CONFIG_USB_SERIAL_SIERRAWIRELESS is not set
1450# CONFIG_USB_SERIAL_SYMBOL is not set
1451# CONFIG_USB_SERIAL_TI is not set
1452# CONFIG_USB_SERIAL_CYBERJACK is not set
1453# CONFIG_USB_SERIAL_XIRCOM is not set
1454# CONFIG_USB_SERIAL_OPTION is not set
1455# CONFIG_USB_SERIAL_OMNINET is not set
1456# CONFIG_USB_SERIAL_OPTICON is not set
1457# CONFIG_USB_SERIAL_DEBUG is not set
1458
1459#
1460# USB Miscellaneous drivers
1461#
1462# CONFIG_USB_EMI62 is not set
1463# CONFIG_USB_EMI26 is not set
1464# CONFIG_USB_ADUTUX is not set
1465# CONFIG_USB_SEVSEG is not set
1466# CONFIG_USB_RIO500 is not set
1467# CONFIG_USB_LEGOTOWER is not set
1468# CONFIG_USB_LCD is not set
1469# CONFIG_USB_BERRY_CHARGE is not set
1470# CONFIG_USB_LED is not set
1471# CONFIG_USB_CYPRESS_CY7C63 is not set
1472# CONFIG_USB_CYTHERM is not set
1473# CONFIG_USB_IDMOUSE is not set
1474# CONFIG_USB_FTDI_ELAN is not set
1475# CONFIG_USB_APPLEDISPLAY is not set
1476# CONFIG_USB_LD is not set
1477# CONFIG_USB_TRANCEVIBRATOR is not set
1478# CONFIG_USB_IOWARRIOR is not set
1479# CONFIG_USB_TEST is not set
1480# CONFIG_USB_ISIGHTFW is not set
1481# CONFIG_USB_VST is not set
1482CONFIG_USB_GADGET=m
1483# CONFIG_USB_GADGET_DEBUG is not set
1484# CONFIG_USB_GADGET_DEBUG_FILES is not set
1485CONFIG_USB_GADGET_VBUS_DRAW=2
1486CONFIG_USB_GADGET_SELECTED=y
1487# CONFIG_USB_GADGET_AT91 is not set
1488# CONFIG_USB_GADGET_ATMEL_USBA is not set
1489# CONFIG_USB_GADGET_FSL_USB2 is not set
1490# CONFIG_USB_GADGET_LH7A40X is not set
1491# CONFIG_USB_GADGET_OMAP is not set
1492# CONFIG_USB_GADGET_PXA25X is not set
1493# CONFIG_USB_GADGET_R8A66597 is not set
1494CONFIG_USB_GADGET_PXA27X=y
1495CONFIG_USB_PXA27X=m
1496# CONFIG_USB_GADGET_S3C_HSOTG is not set
1497# CONFIG_USB_GADGET_IMX is not set
1498# CONFIG_USB_GADGET_S3C2410 is not set
1499# CONFIG_USB_GADGET_M66592 is not set
1500# CONFIG_USB_GADGET_AMD5536UDC is not set
1501# CONFIG_USB_GADGET_FSL_QE is not set
1502# CONFIG_USB_GADGET_CI13XXX is not set
1503# CONFIG_USB_GADGET_NET2280 is not set
1504# CONFIG_USB_GADGET_GOKU is not set
1505# CONFIG_USB_GADGET_LANGWELL is not set
1506# CONFIG_USB_GADGET_DUMMY_HCD is not set
1507# CONFIG_USB_GADGET_DUALSPEED is not set
1508# CONFIG_USB_ZERO is not set
1509# CONFIG_USB_AUDIO is not set
1510CONFIG_USB_ETH=m
1511CONFIG_USB_ETH_RNDIS=y
1512# CONFIG_USB_ETH_EEM is not set
1513CONFIG_USB_GADGETFS=m
1514CONFIG_USB_FILE_STORAGE=m
1515# CONFIG_USB_FILE_STORAGE_TEST is not set
1516CONFIG_USB_G_SERIAL=m
1517# CONFIG_USB_MIDI_GADGET is not set
1518CONFIG_USB_G_PRINTER=m
1519# CONFIG_USB_CDC_COMPOSITE is not set
1520
1521#
1522# OTG and related infrastructure
1523#
1524CONFIG_USB_OTG_UTILS=y
1525# CONFIG_USB_GPIO_VBUS is not set
1526# CONFIG_NOP_USB_XCEIV is not set
1527CONFIG_MMC=y
1528# CONFIG_MMC_DEBUG is not set
1529# CONFIG_MMC_UNSAFE_RESUME is not set
1530
1531#
1532# MMC/SD/SDIO Card Drivers
1533#
1534CONFIG_MMC_BLOCK=y
1535# CONFIG_MMC_BLOCK_BOUNCE is not set
1536# CONFIG_SDIO_UART is not set
1537# CONFIG_MMC_TEST is not set
1538
1539#
1540# MMC/SD/SDIO Host Controller Drivers
1541#
1542CONFIG_MMC_PXA=y
1543# CONFIG_MMC_SDHCI is not set
1544# CONFIG_MMC_AT91 is not set
1545# CONFIG_MMC_ATMELMCI is not set
1546# CONFIG_MMC_SPI is not set
1547# CONFIG_MEMSTICK is not set
1548CONFIG_NEW_LEDS=y
1549CONFIG_LEDS_CLASS=m
1550
1551#
1552# LED drivers
1553#
1554# CONFIG_LEDS_PCA9532 is not set
1555CONFIG_LEDS_GPIO=m
1556CONFIG_LEDS_GPIO_PLATFORM=y
1557# CONFIG_LEDS_LP3944 is not set
1558# CONFIG_LEDS_PCA955X is not set
1559# CONFIG_LEDS_DAC124S085 is not set
1560# CONFIG_LEDS_BD2802 is not set
1561
1562#
1563# LED Triggers
1564#
1565CONFIG_LEDS_TRIGGERS=y
1566CONFIG_LEDS_TRIGGER_TIMER=m
1567CONFIG_LEDS_TRIGGER_HEARTBEAT=m
1568CONFIG_LEDS_TRIGGER_BACKLIGHT=m
1569CONFIG_LEDS_TRIGGER_GPIO=m
1570CONFIG_LEDS_TRIGGER_DEFAULT_ON=m
1571
1572#
1573# iptables trigger is under Netfilter config (LED target)
1574#
1575# CONFIG_ACCESSIBILITY is not set
1576CONFIG_RTC_LIB=y
1577CONFIG_RTC_CLASS=m
1578
1579#
1580# RTC interfaces
1581#
1582CONFIG_RTC_INTF_SYSFS=y
1583CONFIG_RTC_INTF_PROC=y
1584CONFIG_RTC_INTF_DEV=y
1585# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
1586# CONFIG_RTC_DRV_TEST is not set
1587
1588#
1589# I2C RTC drivers
1590#
1591# CONFIG_RTC_DRV_DS1307 is not set
1592# CONFIG_RTC_DRV_DS1374 is not set
1593# CONFIG_RTC_DRV_DS1672 is not set
1594# CONFIG_RTC_DRV_MAX6900 is not set
1595# CONFIG_RTC_DRV_RS5C372 is not set
1596CONFIG_RTC_DRV_ISL1208=m
1597# CONFIG_RTC_DRV_X1205 is not set
1598# CONFIG_RTC_DRV_PCF8563 is not set
1599# CONFIG_RTC_DRV_PCF8583 is not set
1600# CONFIG_RTC_DRV_M41T80 is not set
1601# CONFIG_RTC_DRV_S35390A is not set
1602# CONFIG_RTC_DRV_FM3130 is not set
1603# CONFIG_RTC_DRV_RX8581 is not set
1604# CONFIG_RTC_DRV_RX8025 is not set
1605
1606#
1607# SPI RTC drivers
1608#
1609# CONFIG_RTC_DRV_M41T94 is not set
1610# CONFIG_RTC_DRV_DS1305 is not set
1611# CONFIG_RTC_DRV_DS1390 is not set
1612# CONFIG_RTC_DRV_MAX6902 is not set
1613# CONFIG_RTC_DRV_R9701 is not set
1614# CONFIG_RTC_DRV_RS5C348 is not set
1615# CONFIG_RTC_DRV_DS3234 is not set
1616# CONFIG_RTC_DRV_PCF2123 is not set
1617
1618#
1619# Platform RTC drivers
1620#
1621# CONFIG_RTC_DRV_CMOS is not set
1622# CONFIG_RTC_DRV_DS1286 is not set
1623# CONFIG_RTC_DRV_DS1511 is not set
1624# CONFIG_RTC_DRV_DS1553 is not set
1625# CONFIG_RTC_DRV_DS1742 is not set
1626# CONFIG_RTC_DRV_STK17TA8 is not set
1627# CONFIG_RTC_DRV_M48T86 is not set
1628# CONFIG_RTC_DRV_M48T35 is not set
1629# CONFIG_RTC_DRV_M48T59 is not set
1630# CONFIG_RTC_DRV_MSM6242 is not set
1631# CONFIG_RTC_DRV_BQ4802 is not set
1632# CONFIG_RTC_DRV_RP5C01 is not set
1633# CONFIG_RTC_DRV_V3020 is not set
1634
1635#
1636# on-CPU RTC drivers
1637#
1638# CONFIG_RTC_DRV_SA1100 is not set
1639CONFIG_RTC_DRV_PXA=m
1640# CONFIG_DMADEVICES is not set
1641# CONFIG_AUXDISPLAY is not set
1642# CONFIG_UIO is not set
1643
1644#
1645# TI VLYNQ
1646#
1647# CONFIG_STAGING is not set
1648
1649#
1650# File systems
1651#
1652CONFIG_EXT2_FS=y
1653# CONFIG_EXT2_FS_XATTR is not set
1654# CONFIG_EXT2_FS_XIP is not set
1655CONFIG_EXT3_FS=y
1656# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
1657# CONFIG_EXT3_FS_XATTR is not set
1658# CONFIG_EXT4_FS is not set
1659CONFIG_JBD=y
1660# CONFIG_REISERFS_FS is not set
1661# CONFIG_JFS_FS is not set
1662# CONFIG_FS_POSIX_ACL is not set
1663# CONFIG_XFS_FS is not set
1664# CONFIG_GFS2_FS is not set
1665# CONFIG_OCFS2_FS is not set
1666# CONFIG_BTRFS_FS is not set
1667# CONFIG_NILFS2_FS is not set
1668CONFIG_FILE_LOCKING=y
1669CONFIG_FSNOTIFY=y
1670# CONFIG_DNOTIFY is not set
1671CONFIG_INOTIFY=y
1672CONFIG_INOTIFY_USER=y
1673# CONFIG_QUOTA is not set
1674# CONFIG_AUTOFS_FS is not set
1675# CONFIG_AUTOFS4_FS is not set
1676# CONFIG_FUSE_FS is not set
1677
1678#
1679# Caches
1680#
1681# CONFIG_FSCACHE is not set
1682
1683#
1684# CD-ROM/DVD Filesystems
1685#
1686# CONFIG_ISO9660_FS is not set
1687# CONFIG_UDF_FS is not set
1688
1689#
1690# DOS/FAT/NT Filesystems
1691#
1692CONFIG_FAT_FS=m
1693# CONFIG_MSDOS_FS is not set
1694CONFIG_VFAT_FS=m
1695CONFIG_FAT_DEFAULT_CODEPAGE=437
1696CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1697# CONFIG_NTFS_FS is not set
1698
1699#
1700# Pseudo filesystems
1701#
1702CONFIG_PROC_FS=y
1703CONFIG_PROC_SYSCTL=y
1704CONFIG_PROC_PAGE_MONITOR=y
1705CONFIG_SYSFS=y
1706CONFIG_TMPFS=y
1707# CONFIG_TMPFS_POSIX_ACL is not set
1708# CONFIG_HUGETLB_PAGE is not set
1709# CONFIG_CONFIGFS_FS is not set
1710CONFIG_MISC_FILESYSTEMS=y
1711# CONFIG_ADFS_FS is not set
1712# CONFIG_AFFS_FS is not set
1713# CONFIG_HFS_FS is not set
1714# CONFIG_HFSPLUS_FS is not set
1715# CONFIG_BEFS_FS is not set
1716# CONFIG_BFS_FS is not set
1717# CONFIG_EFS_FS is not set
1718CONFIG_JFFS2_FS=y
1719CONFIG_JFFS2_FS_DEBUG=0
1720CONFIG_JFFS2_FS_WRITEBUFFER=y
1721# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
1722# CONFIG_JFFS2_SUMMARY is not set
1723# CONFIG_JFFS2_FS_XATTR is not set
1724# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
1725CONFIG_JFFS2_ZLIB=y
1726# CONFIG_JFFS2_LZO is not set
1727CONFIG_JFFS2_RTIME=y
1728# CONFIG_JFFS2_RUBIN is not set
1729# CONFIG_CRAMFS is not set
1730# CONFIG_SQUASHFS is not set
1731# CONFIG_VXFS_FS is not set
1732# CONFIG_MINIX_FS is not set
1733# CONFIG_OMFS_FS is not set
1734# CONFIG_HPFS_FS is not set
1735# CONFIG_QNX4FS_FS is not set
1736# CONFIG_ROMFS_FS is not set
1737# CONFIG_SYSV_FS is not set
1738# CONFIG_UFS_FS is not set
1739CONFIG_NETWORK_FILESYSTEMS=y
1740CONFIG_NFS_FS=y
1741CONFIG_NFS_V3=y
1742# CONFIG_NFS_V3_ACL is not set
1743# CONFIG_NFS_V4 is not set
1744CONFIG_ROOT_NFS=y
1745CONFIG_NFSD=m
1746CONFIG_NFSD_V3=y
1747# CONFIG_NFSD_V3_ACL is not set
1748# CONFIG_NFSD_V4 is not set
1749CONFIG_LOCKD=y
1750CONFIG_LOCKD_V4=y
1751CONFIG_EXPORTFS=m
1752CONFIG_NFS_COMMON=y
1753CONFIG_SUNRPC=y
1754# CONFIG_RPCSEC_GSS_KRB5 is not set
1755# CONFIG_RPCSEC_GSS_SPKM3 is not set
1756# CONFIG_SMB_FS is not set
1757# CONFIG_CIFS is not set
1758# CONFIG_NCP_FS is not set
1759# CONFIG_CODA_FS is not set
1760# CONFIG_AFS_FS is not set
1761
1762#
1763# Partition Types
1764#
1765CONFIG_PARTITION_ADVANCED=y
1766# CONFIG_ACORN_PARTITION is not set
1767# CONFIG_OSF_PARTITION is not set
1768# CONFIG_AMIGA_PARTITION is not set
1769# CONFIG_ATARI_PARTITION is not set
1770# CONFIG_MAC_PARTITION is not set
1771CONFIG_MSDOS_PARTITION=y
1772# CONFIG_BSD_DISKLABEL is not set
1773# CONFIG_MINIX_SUBPARTITION is not set
1774# CONFIG_SOLARIS_X86_PARTITION is not set
1775# CONFIG_UNIXWARE_DISKLABEL is not set
1776# CONFIG_LDM_PARTITION is not set
1777# CONFIG_SGI_PARTITION is not set
1778# CONFIG_ULTRIX_PARTITION is not set
1779# CONFIG_SUN_PARTITION is not set
1780# CONFIG_KARMA_PARTITION is not set
1781# CONFIG_EFI_PARTITION is not set
1782# CONFIG_SYSV68_PARTITION is not set
1783CONFIG_NLS=m
1784CONFIG_NLS_DEFAULT="iso8859-1"
1785CONFIG_NLS_CODEPAGE_437=m
1786# CONFIG_NLS_CODEPAGE_737 is not set
1787# CONFIG_NLS_CODEPAGE_775 is not set
1788CONFIG_NLS_CODEPAGE_850=m
1789# CONFIG_NLS_CODEPAGE_852 is not set
1790# CONFIG_NLS_CODEPAGE_855 is not set
1791# CONFIG_NLS_CODEPAGE_857 is not set
1792# CONFIG_NLS_CODEPAGE_860 is not set
1793# CONFIG_NLS_CODEPAGE_861 is not set
1794# CONFIG_NLS_CODEPAGE_862 is not set
1795# CONFIG_NLS_CODEPAGE_863 is not set
1796# CONFIG_NLS_CODEPAGE_864 is not set
1797# CONFIG_NLS_CODEPAGE_865 is not set
1798# CONFIG_NLS_CODEPAGE_866 is not set
1799# CONFIG_NLS_CODEPAGE_869 is not set
1800# CONFIG_NLS_CODEPAGE_936 is not set
1801# CONFIG_NLS_CODEPAGE_950 is not set
1802# CONFIG_NLS_CODEPAGE_932 is not set
1803# CONFIG_NLS_CODEPAGE_949 is not set
1804# CONFIG_NLS_CODEPAGE_874 is not set
1805# CONFIG_NLS_ISO8859_8 is not set
1806# CONFIG_NLS_CODEPAGE_1250 is not set
1807# CONFIG_NLS_CODEPAGE_1251 is not set
1808# CONFIG_NLS_ASCII is not set
1809CONFIG_NLS_ISO8859_1=m
1810# CONFIG_NLS_ISO8859_2 is not set
1811# CONFIG_NLS_ISO8859_3 is not set
1812# CONFIG_NLS_ISO8859_4 is not set
1813# CONFIG_NLS_ISO8859_5 is not set
1814# CONFIG_NLS_ISO8859_6 is not set
1815# CONFIG_NLS_ISO8859_7 is not set
1816# CONFIG_NLS_ISO8859_9 is not set
1817# CONFIG_NLS_ISO8859_13 is not set
1818# CONFIG_NLS_ISO8859_14 is not set
1819CONFIG_NLS_ISO8859_15=m
1820# CONFIG_NLS_KOI8_R is not set
1821# CONFIG_NLS_KOI8_U is not set
1822CONFIG_NLS_UTF8=m
1823# CONFIG_DLM is not set
1824
1825#
1826# Kernel hacking
1827#
1828# CONFIG_PRINTK_TIME is not set
1829CONFIG_ENABLE_WARN_DEPRECATED=y
1830CONFIG_ENABLE_MUST_CHECK=y
1831CONFIG_FRAME_WARN=1024
1832CONFIG_MAGIC_SYSRQ=y
1833# CONFIG_STRIP_ASM_SYMS is not set
1834# CONFIG_UNUSED_SYMBOLS is not set
1835# CONFIG_DEBUG_FS is not set
1836# CONFIG_HEADERS_CHECK is not set
1837CONFIG_DEBUG_KERNEL=y
1838# CONFIG_DEBUG_SHIRQ is not set
1839CONFIG_DETECT_SOFTLOCKUP=y
1840# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
1841CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
1842CONFIG_DETECT_HUNG_TASK=y
1843# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
1844CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
1845CONFIG_SCHED_DEBUG=y
1846# CONFIG_SCHEDSTATS is not set
1847# CONFIG_TIMER_STATS is not set
1848# CONFIG_DEBUG_OBJECTS is not set
1849# CONFIG_SLUB_DEBUG_ON is not set
1850# CONFIG_SLUB_STATS is not set
1851# CONFIG_DEBUG_KMEMLEAK is not set
1852# CONFIG_DEBUG_RT_MUTEXES is not set
1853# CONFIG_RT_MUTEX_TESTER is not set
1854# CONFIG_DEBUG_SPINLOCK is not set
1855CONFIG_DEBUG_MUTEXES=y
1856# CONFIG_DEBUG_LOCK_ALLOC is not set
1857# CONFIG_PROVE_LOCKING is not set
1858# CONFIG_LOCK_STAT is not set
1859# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1860# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1861# CONFIG_DEBUG_KOBJECT is not set
1862CONFIG_DEBUG_BUGVERBOSE=y
1863# CONFIG_DEBUG_INFO is not set
1864# CONFIG_DEBUG_VM is not set
1865# CONFIG_DEBUG_WRITECOUNT is not set
1866CONFIG_DEBUG_MEMORY_INIT=y
1867# CONFIG_DEBUG_LIST is not set
1868# CONFIG_DEBUG_SG is not set
1869# CONFIG_DEBUG_NOTIFIERS is not set
1870# CONFIG_DEBUG_CREDENTIALS is not set
1871# CONFIG_BOOT_PRINTK_DELAY is not set
1872# CONFIG_RCU_TORTURE_TEST is not set
1873# CONFIG_BACKTRACE_SELF_TEST is not set
1874# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
1875# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
1876# CONFIG_FAULT_INJECTION is not set
1877# CONFIG_LATENCYTOP is not set
1878CONFIG_SYSCTL_SYSCALL_CHECK=y
1879# CONFIG_PAGE_POISONING is not set
1880CONFIG_HAVE_FUNCTION_TRACER=y
1881CONFIG_TRACING_SUPPORT=y
1882CONFIG_FTRACE=y
1883# CONFIG_FUNCTION_TRACER is not set
1884# CONFIG_IRQSOFF_TRACER is not set
1885# CONFIG_SCHED_TRACER is not set
1886# CONFIG_ENABLE_DEFAULT_TRACERS is not set
1887# CONFIG_BOOT_TRACER is not set
1888CONFIG_BRANCH_PROFILE_NONE=y
1889# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
1890# CONFIG_PROFILE_ALL_BRANCHES is not set
1891# CONFIG_STACK_TRACER is not set
1892# CONFIG_KMEMTRACE is not set
1893# CONFIG_WORKQUEUE_TRACER is not set
1894# CONFIG_BLK_DEV_IO_TRACE is not set
1895# CONFIG_SAMPLES is not set
1896CONFIG_HAVE_ARCH_KGDB=y
1897# CONFIG_KGDB is not set
1898CONFIG_ARM_UNWIND=y
1899# CONFIG_DEBUG_USER is not set
1900CONFIG_DEBUG_ERRORS=y
1901# CONFIG_DEBUG_STACK_USAGE is not set
1902# CONFIG_DEBUG_LL is not set
1903# CONFIG_OC_ETM is not set
1904
1905#
1906# Security options
1907#
1908# CONFIG_KEYS is not set
1909# CONFIG_SECURITY is not set
1910# CONFIG_SECURITYFS is not set
1911# CONFIG_DEFAULT_SECURITY_SELINUX is not set
1912# CONFIG_DEFAULT_SECURITY_SMACK is not set
1913# CONFIG_DEFAULT_SECURITY_TOMOYO is not set
1914CONFIG_DEFAULT_SECURITY_DAC=y
1915CONFIG_DEFAULT_SECURITY=""
1916CONFIG_CRYPTO=y
1917
1918#
1919# Crypto core or helper
1920#
1921CONFIG_CRYPTO_ALGAPI=m
1922CONFIG_CRYPTO_ALGAPI2=m
1923CONFIG_CRYPTO_AEAD2=m
1924CONFIG_CRYPTO_BLKCIPHER=m
1925CONFIG_CRYPTO_BLKCIPHER2=m
1926CONFIG_CRYPTO_HASH=m
1927CONFIG_CRYPTO_HASH2=m
1928CONFIG_CRYPTO_RNG2=m
1929CONFIG_CRYPTO_PCOMP=m
1930CONFIG_CRYPTO_MANAGER=m
1931CONFIG_CRYPTO_MANAGER2=m
1932# CONFIG_CRYPTO_GF128MUL is not set
1933# CONFIG_CRYPTO_NULL is not set
1934CONFIG_CRYPTO_WORKQUEUE=m
1935# CONFIG_CRYPTO_CRYPTD is not set
1936# CONFIG_CRYPTO_AUTHENC is not set
1937# CONFIG_CRYPTO_TEST is not set
1938
1939#
1940# Authenticated Encryption with Associated Data
1941#
1942# CONFIG_CRYPTO_CCM is not set
1943# CONFIG_CRYPTO_GCM is not set
1944# CONFIG_CRYPTO_SEQIV is not set
1945
1946#
1947# Block modes
1948#
1949# CONFIG_CRYPTO_CBC is not set
1950# CONFIG_CRYPTO_CTR is not set
1951# CONFIG_CRYPTO_CTS is not set
1952CONFIG_CRYPTO_ECB=m
1953# CONFIG_CRYPTO_LRW is not set
1954# CONFIG_CRYPTO_PCBC is not set
1955# CONFIG_CRYPTO_XTS is not set
1956
1957#
1958# Hash modes
1959#
1960# CONFIG_CRYPTO_HMAC is not set
1961# CONFIG_CRYPTO_XCBC is not set
1962# CONFIG_CRYPTO_VMAC is not set
1963
1964#
1965# Digest
1966#
1967# CONFIG_CRYPTO_CRC32C is not set
1968# CONFIG_CRYPTO_GHASH is not set
1969# CONFIG_CRYPTO_MD4 is not set
1970# CONFIG_CRYPTO_MD5 is not set
1971CONFIG_CRYPTO_MICHAEL_MIC=m
1972# CONFIG_CRYPTO_RMD128 is not set
1973# CONFIG_CRYPTO_RMD160 is not set
1974# CONFIG_CRYPTO_RMD256 is not set
1975# CONFIG_CRYPTO_RMD320 is not set
1976# CONFIG_CRYPTO_SHA1 is not set
1977# CONFIG_CRYPTO_SHA256 is not set
1978# CONFIG_CRYPTO_SHA512 is not set
1979# CONFIG_CRYPTO_TGR192 is not set
1980# CONFIG_CRYPTO_WP512 is not set
1981
1982#
1983# Ciphers
1984#
1985CONFIG_CRYPTO_AES=m
1986# CONFIG_CRYPTO_ANUBIS is not set
1987CONFIG_CRYPTO_ARC4=m
1988# CONFIG_CRYPTO_BLOWFISH is not set
1989# CONFIG_CRYPTO_CAMELLIA is not set
1990# CONFIG_CRYPTO_CAST5 is not set
1991# CONFIG_CRYPTO_CAST6 is not set
1992# CONFIG_CRYPTO_DES is not set
1993# CONFIG_CRYPTO_FCRYPT is not set
1994# CONFIG_CRYPTO_KHAZAD is not set
1995# CONFIG_CRYPTO_SALSA20 is not set
1996# CONFIG_CRYPTO_SEED is not set
1997# CONFIG_CRYPTO_SERPENT is not set
1998# CONFIG_CRYPTO_TEA is not set
1999# CONFIG_CRYPTO_TWOFISH is not set
2000
2001#
2002# Compression
2003#
2004# CONFIG_CRYPTO_DEFLATE is not set
2005# CONFIG_CRYPTO_ZLIB is not set
2006# CONFIG_CRYPTO_LZO is not set
2007
2008#
2009# Random Number Generation
2010#
2011# CONFIG_CRYPTO_ANSI_CPRNG is not set
2012CONFIG_CRYPTO_HW=y
2013# CONFIG_BINARY_PRINTF is not set
2014
2015#
2016# Library routines
2017#
2018CONFIG_BITREVERSE=y
2019CONFIG_GENERIC_FIND_LAST_BIT=y
2020CONFIG_CRC_CCITT=m
2021CONFIG_CRC16=m
2022CONFIG_CRC_T10DIF=m
2023CONFIG_CRC_ITU_T=m
2024CONFIG_CRC32=y
2025# CONFIG_CRC7 is not set
2026# CONFIG_LIBCRC32C is not set
2027CONFIG_ZLIB_INFLATE=y
2028CONFIG_ZLIB_DEFLATE=y
2029CONFIG_HAS_IOMEM=y
2030CONFIG_HAS_IOPORT=y
2031CONFIG_HAS_DMA=y
2032CONFIG_NLATTR=y
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index e7ccf7e697ce..dd00f747e2ad 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -54,5 +54,6 @@ endif
54 54
55head-y := head$(MMUEXT).o 55head-y := head$(MMUEXT).o
56obj-$(CONFIG_DEBUG_LL) += debug.o 56obj-$(CONFIG_DEBUG_LL) += debug.o
57obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
57 58
58extra-y := $(head-y) init_task.o vmlinux.lds 59extra-y := $(head-y) init_task.o vmlinux.lds
diff --git a/arch/arm/kernel/early_printk.c b/arch/arm/kernel/early_printk.c
new file mode 100644
index 000000000000..85aa2b292692
--- /dev/null
+++ b/arch/arm/kernel/early_printk.c
@@ -0,0 +1,57 @@
1/*
2 * linux/arch/arm/kernel/early_printk.c
3 *
4 * Copyright (C) 2009 Sascha Hauer <s.hauer@pengutronix.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/kernel.h>
12#include <linux/console.h>
13#include <linux/init.h>
14
15extern void printch(int);
16
17static void early_write(const char *s, unsigned n)
18{
19 while (n-- > 0) {
20 if (*s == '\n')
21 printch('\r');
22 printch(*s);
23 s++;
24 }
25}
26
27static void early_console_write(struct console *con, const char *s, unsigned n)
28{
29 early_write(s, n);
30}
31
32static struct console early_console = {
33 .name = "earlycon",
34 .write = early_console_write,
35 .flags = CON_PRINTBUFFER | CON_BOOT,
36 .index = -1,
37};
38
39asmlinkage void early_printk(const char *fmt, ...)
40{
41 char buf[512];
42 int n;
43 va_list ap;
44
45 va_start(ap, fmt);
46 n = vscnprintf(buf, sizeof(buf), fmt, ap);
47 early_write(buf, n);
48 va_end(ap);
49}
50
51static int __init setup_early_printk(char *buf)
52{
53 register_console(&early_console);
54 return 0;
55}
56
57early_param("earlyprintk", setup_early_printk);
diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c
index a73a34dccf2a..ea02a7b1c244 100644
--- a/arch/arm/kernel/smp_twd.c
+++ b/arch/arm/kernel/smp_twd.c
@@ -160,6 +160,7 @@ void __cpuinit twd_timer_setup(struct clock_event_device *clk)
160 160
161 /* Make sure our local interrupt controller has this enabled */ 161 /* Make sure our local interrupt controller has this enabled */
162 local_irq_save(flags); 162 local_irq_save(flags);
163 irq_to_desc(clk->irq)->status |= IRQ_NOPROBE;
163 get_irq_chip(clk->irq)->unmask(clk->irq); 164 get_irq_chip(clk->irq)->unmask(clk->irq);
164 local_irq_restore(flags); 165 local_irq_restore(flags);
165 166
diff --git a/arch/arm/mach-clps711x/include/mach/memory.h b/arch/arm/mach-clps711x/include/mach/memory.h
index e522b20bcbc2..f70d52be48a2 100644
--- a/arch/arm/mach-clps711x/include/mach/memory.h
+++ b/arch/arm/mach-clps711x/include/mach/memory.h
@@ -30,6 +30,8 @@
30 30
31#define __virt_to_bus(x) ((x) - PAGE_OFFSET) 31#define __virt_to_bus(x) ((x) - PAGE_OFFSET)
32#define __bus_to_virt(x) ((x) + PAGE_OFFSET) 32#define __bus_to_virt(x) ((x) + PAGE_OFFSET)
33#define __pfn_to_bus(x) (__pfn_to_phys(x) - PHYS_OFFSET)
34#define __bus_to_pfn(x) __phys_to_pfn((x) + PHYS_OFFSET)
33 35
34#endif 36#endif
35 37
diff --git a/arch/arm/mach-footbridge/common.c b/arch/arm/mach-footbridge/common.c
index b97f529e58e8..41febc796b1c 100644
--- a/arch/arm/mach-footbridge/common.c
+++ b/arch/arm/mach-footbridge/common.c
@@ -201,6 +201,11 @@ void __init footbridge_map_io(void)
201 201
202#ifdef CONFIG_FOOTBRIDGE_ADDIN 202#ifdef CONFIG_FOOTBRIDGE_ADDIN
203 203
204static inline unsigned long fb_bus_sdram_offset(void)
205{
206 return *CSR_PCISDRAMBASE & 0xfffffff0;
207}
208
204/* 209/*
205 * These two functions convert virtual addresses to PCI addresses and PCI 210 * These two functions convert virtual addresses to PCI addresses and PCI
206 * addresses to virtual addresses. Note that it is only legal to use these 211 * addresses to virtual addresses. Note that it is only legal to use these
@@ -210,14 +215,13 @@ unsigned long __virt_to_bus(unsigned long res)
210{ 215{
211 WARN_ON(res < PAGE_OFFSET || res >= (unsigned long)high_memory); 216 WARN_ON(res < PAGE_OFFSET || res >= (unsigned long)high_memory);
212 217
213 return (res - PAGE_OFFSET) + (*CSR_PCISDRAMBASE & 0xfffffff0); 218 return res + (fb_bus_sdram_offset() - PAGE_OFFSET);
214} 219}
215EXPORT_SYMBOL(__virt_to_bus); 220EXPORT_SYMBOL(__virt_to_bus);
216 221
217unsigned long __bus_to_virt(unsigned long res) 222unsigned long __bus_to_virt(unsigned long res)
218{ 223{
219 res -= (*CSR_PCISDRAMBASE & 0xfffffff0); 224 res = res - (fb_bus_sdram_offset() - PAGE_OFFSET);
220 res += PAGE_OFFSET;
221 225
222 WARN_ON(res < PAGE_OFFSET || res >= (unsigned long)high_memory); 226 WARN_ON(res < PAGE_OFFSET || res >= (unsigned long)high_memory);
223 227
@@ -225,4 +229,16 @@ unsigned long __bus_to_virt(unsigned long res)
225} 229}
226EXPORT_SYMBOL(__bus_to_virt); 230EXPORT_SYMBOL(__bus_to_virt);
227 231
232unsigned long __pfn_to_bus(unsigned long pfn)
233{
234 return __pfn_to_phys(pfn) + (fb_bus_sdram_offset() - PHYS_OFFSET));
235}
236EXPORT_SYMBOL(__pfn_to_bus);
237
238unsigned long __bus_to_pfn(unsigned long bus)
239{
240 return __phys_to_pfn(bus - (fb_bus_sdram_offset() - PHYS_OFFSET));
241}
242EXPORT_SYMBOL(__bus_to_pfn);
243
228#endif 244#endif
diff --git a/arch/arm/mach-footbridge/include/mach/memory.h b/arch/arm/mach-footbridge/include/mach/memory.h
index cb16e59d87b6..8d64f4574087 100644
--- a/arch/arm/mach-footbridge/include/mach/memory.h
+++ b/arch/arm/mach-footbridge/include/mach/memory.h
@@ -29,6 +29,8 @@
29#ifndef __ASSEMBLY__ 29#ifndef __ASSEMBLY__
30extern unsigned long __virt_to_bus(unsigned long); 30extern unsigned long __virt_to_bus(unsigned long);
31extern unsigned long __bus_to_virt(unsigned long); 31extern unsigned long __bus_to_virt(unsigned long);
32extern unsigned long __pfn_to_bus(unsigned long);
33extern unsigned long __bus_to_pfn(unsigned long);
32#endif 34#endif
33#define __virt_to_bus __virt_to_bus 35#define __virt_to_bus __virt_to_bus
34#define __bus_to_virt __bus_to_virt 36#define __bus_to_virt __bus_to_virt
@@ -36,14 +38,15 @@ extern unsigned long __bus_to_virt(unsigned long);
36#elif defined(CONFIG_FOOTBRIDGE_HOST) 38#elif defined(CONFIG_FOOTBRIDGE_HOST)
37 39
38/* 40/*
39 * The footbridge is programmed to expose the system RAM at the corresponding 41 * The footbridge is programmed to expose the system RAM at 0xe0000000.
40 * address. So, if PAGE_OFFSET is 0xc0000000, RAM appears at 0xe0000000. 42 * The requirement is that the RAM isn't placed at bus address 0, which
41 * If 0x80000000, then its exposed at 0xa0000000 on the bus. etc.
42 * The only requirement is that the RAM isn't placed at bus address 0 which
43 * would clash with VGA cards. 43 * would clash with VGA cards.
44 */ 44 */
45#define __virt_to_bus(x) ((x) - 0xe0000000) 45#define BUS_OFFSET 0xe0000000
46#define __bus_to_virt(x) ((x) + 0xe0000000) 46#define __virt_to_bus(x) ((x) + (BUS_OFFSET - PAGE_OFFSET))
47#define __bus_to_virt(x) ((x) - (BUS_OFFSET - PAGE_OFFSET))
48#define __pfn_to_bus(x) (__pfn_to_phys(x) + (BUS_OFFSET - PHYS_OFFSET))
49#define __bus_to_pfn(x) __phys_to_pfn((x) - (BUS_OFFSET - PHYS_OFFSET))
47 50
48#else 51#else
49 52
diff --git a/arch/arm/mach-integrator/include/mach/memory.h b/arch/arm/mach-integrator/include/mach/memory.h
index 4891828454f5..991f24d2c115 100644
--- a/arch/arm/mach-integrator/include/mach/memory.h
+++ b/arch/arm/mach-integrator/include/mach/memory.h
@@ -28,6 +28,7 @@
28#define BUS_OFFSET UL(0x80000000) 28#define BUS_OFFSET UL(0x80000000)
29#define __virt_to_bus(x) ((x) - PAGE_OFFSET + BUS_OFFSET) 29#define __virt_to_bus(x) ((x) - PAGE_OFFSET + BUS_OFFSET)
30#define __bus_to_virt(x) ((x) - BUS_OFFSET + PAGE_OFFSET) 30#define __bus_to_virt(x) ((x) - BUS_OFFSET + PAGE_OFFSET)
31#define __pfn_to_bus(x) (((x) << PAGE_SHIFT) + BUS_OFFSET) 31#define __pfn_to_bus(x) (__pfn_to_phys(x) + (BUS_OFFSET - PHYS_OFFSET))
32#define __bus_to_pfn(x) __phys_to_pfn((x) - (BUS_OFFSET - PHYS_OFFSET))
32 33
33#endif 34#endif
diff --git a/arch/arm/mach-ixp2000/include/mach/memory.h b/arch/arm/mach-ixp2000/include/mach/memory.h
index aee7eb8a71b2..98e3471be15b 100644
--- a/arch/arm/mach-ixp2000/include/mach/memory.h
+++ b/arch/arm/mach-ixp2000/include/mach/memory.h
@@ -17,11 +17,15 @@
17 17
18#include <mach/ixp2000-regs.h> 18#include <mach/ixp2000-regs.h>
19 19
20#define __virt_to_bus(v) \ 20#define IXP2000_PCI_SDRAM_OFFSET (*IXP2000_PCI_SDRAM_BAR & 0xfffffff0)
21 (((__virt_to_phys(v) - 0x0) + (*IXP2000_PCI_SDRAM_BAR & 0xfffffff0)))
22 21
23#define __bus_to_virt(b) \ 22#define __phys_to_bus(x) ((x) + (IXP2000_PCI_SDRAM_OFFSET - PHYS_OFFSET))
24 __phys_to_virt((((b - (*IXP2000_PCI_SDRAM_BAR & 0xfffffff0)) + 0x0))) 23#define __bus_to_phys(x) ((x) - (IXP2000_PCI_SDRAM_OFFSET - PHYS_OFFSET))
24
25#define __virt_to_bus(v) __phys_to_bus(__virt_to_phys(v))
26#define __bus_to_virt(b) __phys_to_virt(__bus_to_phys(b))
27#define __pfn_to_bus(p) __phys_to_bus(__pfn_to_phys(p))
28#define __bus_to_pfn(b) __phys_to_pfn(__bus_to_phys(b))
25 29
26#endif 30#endif
27 31
diff --git a/arch/arm/mach-ixp23xx/include/mach/memory.h b/arch/arm/mach-ixp23xx/include/mach/memory.h
index fdd138706c70..94a3a86cfeb8 100644
--- a/arch/arm/mach-ixp23xx/include/mach/memory.h
+++ b/arch/arm/mach-ixp23xx/include/mach/memory.h
@@ -19,16 +19,15 @@
19 */ 19 */
20#define PHYS_OFFSET (0x00000000) 20#define PHYS_OFFSET (0x00000000)
21 21
22#define __virt_to_bus(v) \ 22#define IXP23XX_PCI_SDRAM_OFFSET (*((volatile int *)IXP23XX_PCI_SDRAM_BAR) & 0xfffffff0))
23 ({ unsigned int ret; \ 23
24 ret = ((__virt_to_phys(v) - 0x00000000) + \ 24#define __phys_to_bus(x) ((x) + (IXP23XX_PCI_SDRAM_OFFSET - PHYS_OFFSET))
25 (*((volatile int *)IXP23XX_PCI_SDRAM_BAR) & 0xfffffff0)); \ 25#define __bus_to_phys(x) ((x) - (IXP23XX_PCI_SDRAM_OFFSET - PHYS_OFFSET))
26 ret; }) 26
27 27#define __virt_to_bus(v) __phys_to_bus(__virt_to_phys(v))
28#define __bus_to_virt(b) \ 28#define __bus_to_virt(b) __phys_to_virt(__bus_to_phys(b))
29 ({ unsigned int data; \ 29#define __pfn_to_bus(p) __phys_to_bus(__pfn_to_phys(p))
30 data = *((volatile int *)IXP23XX_PCI_SDRAM_BAR); \ 30#define __bus_to_pfn(b) __phys_to_pfn(__bus_to_phys(b))
31 __phys_to_virt((((b - (data & 0xfffffff0)) + 0x00000000))); })
32 31
33#define arch_is_coherent() 1 32#define arch_is_coherent() 1
34 33
diff --git a/arch/arm/mach-lh7a40x/clocks.c b/arch/arm/mach-lh7a40x/clocks.c
index 6182f5410b4d..fcaf876f19b6 100644
--- a/arch/arm/mach-lh7a40x/clocks.c
+++ b/arch/arm/mach-lh7a40x/clocks.c
@@ -7,8 +7,6 @@
7 * version 2 as published by the Free Software Foundation. 7 * version 2 as published by the Free Software Foundation.
8 * 8 *
9 */ 9 */
10
11#include <linux/cpufreq.h>
12#include <mach/hardware.h> 10#include <mach/hardware.h>
13#include <mach/clocks.h> 11#include <mach/clocks.h>
14#include <linux/err.h> 12#include <linux/err.h>
@@ -31,12 +29,6 @@ struct clk {
31#define HCLKDIV(c) (((c) >> 0) & 0x02) 29#define HCLKDIV(c) (((c) >> 0) & 0x02)
32#define PCLKDIV(c) (((c) >> 16) & 0x03) 30#define PCLKDIV(c) (((c) >> 16) & 0x03)
33 31
34unsigned int cpufreq_get (unsigned int cpu) /* in kHz */
35{
36 return fclkfreq_get ()/1000;
37}
38EXPORT_SYMBOL(cpufreq_get);
39
40unsigned int fclkfreq_get (void) 32unsigned int fclkfreq_get (void)
41{ 33{
42 unsigned int clkset = CSC_CLKSET; 34 unsigned int clkset = CSC_CLKSET;
diff --git a/arch/arm/mach-omap2/board-2430sdp.c b/arch/arm/mach-omap2/board-2430sdp.c
index db9374bc528b..e508904fb67e 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -19,7 +19,7 @@
19#include <linux/mtd/mtd.h> 19#include <linux/mtd/mtd.h>
20#include <linux/mtd/partitions.h> 20#include <linux/mtd/partitions.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/i2c/twl4030.h> 22#include <linux/i2c/twl.h>
23#include <linux/err.h> 23#include <linux/err.h>
24#include <linux/clk.h> 24#include <linux/clk.h>
25#include <linux/io.h> 25#include <linux/io.h>
diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
index 4cfb7b68dfad..c90b0d0b1927 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -20,7 +20,7 @@
20#include <linux/input/matrix_keypad.h> 20#include <linux/input/matrix_keypad.h>
21#include <linux/spi/spi.h> 21#include <linux/spi/spi.h>
22#include <linux/spi/ads7846.h> 22#include <linux/spi/ads7846.h>
23#include <linux/i2c/twl4030.h> 23#include <linux/i2c/twl.h>
24#include <linux/regulator/machine.h> 24#include <linux/regulator/machine.h>
25#include <linux/io.h> 25#include <linux/io.h>
26#include <linux/gpio.h> 26#include <linux/gpio.h>
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index 37431738f1c2..995d4a2b2dfd 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -24,7 +24,7 @@
24#include <linux/spi/spi.h> 24#include <linux/spi/spi.h>
25#include <linux/spi/ads7846.h> 25#include <linux/spi/ads7846.h>
26#include <linux/regulator/machine.h> 26#include <linux/regulator/machine.h>
27#include <linux/i2c/twl4030.h> 27#include <linux/i2c/twl.h>
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/smsc911x.h> 29#include <linux/smsc911x.h>
30 30
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 6ada8029f9a8..231cb4ec1847 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -29,7 +29,7 @@
29#include <linux/mtd/nand.h> 29#include <linux/mtd/nand.h>
30 30
31#include <linux/regulator/machine.h> 31#include <linux/regulator/machine.h>
32#include <linux/i2c/twl4030.h> 32#include <linux/i2c/twl.h>
33 33
34#include <mach/hardware.h> 34#include <mach/hardware.h>
35#include <asm/mach-types.h> 35#include <asm/mach-types.h>
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index 6f6c601eeab7..ef17cf1ab6d7 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -24,7 +24,7 @@
24#include <linux/spi/spi.h> 24#include <linux/spi/spi.h>
25#include <linux/spi/ads7846.h> 25#include <linux/spi/ads7846.h>
26#include <linux/regulator/machine.h> 26#include <linux/regulator/machine.h>
27#include <linux/i2c/twl4030.h> 27#include <linux/i2c/twl.h>
28#include <linux/leds.h> 28#include <linux/leds.h>
29#include <linux/input.h> 29#include <linux/input.h>
30#include <linux/input/matrix_keypad.h> 30#include <linux/input/matrix_keypad.h>
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
index 5b78a87217e0..d192dd98a591 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -26,7 +26,7 @@
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/i2c/twl4030.h> 29#include <linux/i2c/twl.h>
30#include <linux/regulator/machine.h> 30#include <linux/regulator/machine.h>
31 31
32#include <linux/mtd/mtd.h> 32#include <linux/mtd/mtd.h>
diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index bf26ad31f9ba..17f3c91231db 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -402,15 +402,9 @@ static struct twl4030_usb_data rx51_usb_data = {
402 402
403static struct twl4030_ins sleep_on_seq[] __initdata = { 403static struct twl4030_ins sleep_on_seq[] __initdata = {
404/* 404/*
405 * Turn off VDD1 and VDD2. 405 * Turn off everything
406 */ 406 */
407 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_OFF), 4}, 407 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_SLEEP), 2},
408 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_OFF), 2},
409/*
410 * And also turn off the OMAP3 PLLs and the sysclk output.
411 */
412 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_OFF), 3},
413 {MSG_SINGULAR(DEV_GRP_P1, 0x17, RES_STATE_OFF), 3},
414}; 408};
415 409
416static struct twl4030_script sleep_on_script __initdata = { 410static struct twl4030_script sleep_on_script __initdata = {
@@ -421,14 +415,9 @@ static struct twl4030_script sleep_on_script __initdata = {
421 415
422static struct twl4030_ins wakeup_seq[] __initdata = { 416static struct twl4030_ins wakeup_seq[] __initdata = {
423/* 417/*
424 * Reenable the OMAP3 PLLs. 418 * Reenable everything
425 * Wakeup VDD1 and VDD2.
426 * Reenable sysclk output.
427 */ 419 */
428 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_ACTIVE), 0x30}, 420 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_ACTIVE), 2},
429 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 0x30},
430 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 0x37},
431 {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 3},
432}; 421};
433 422
434static struct twl4030_script wakeup_script __initdata = { 423static struct twl4030_script wakeup_script __initdata = {
@@ -439,10 +428,9 @@ static struct twl4030_script wakeup_script __initdata = {
439 428
440static struct twl4030_ins wakeup_p3_seq[] __initdata = { 429static struct twl4030_ins wakeup_p3_seq[] __initdata = {
441/* 430/*
442 * Wakeup VDD1 (dummy to be able to insert a delay) 431 * Reenable everything
443 * Enable CLKEN
444 */ 432 */
445 {MSG_SINGULAR(DEV_GRP_P1, 0x17, RES_STATE_ACTIVE), 3}, 433 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_ACTIVE), 2},
446}; 434};
447 435
448static struct twl4030_script wakeup_p3_script __initdata = { 436static struct twl4030_script wakeup_p3_script __initdata = {
@@ -463,12 +451,11 @@ static struct twl4030_ins wrst_seq[] __initdata = {
463 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2}, 451 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2},
464 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 0, 1, RES_STATE_ACTIVE), 452 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 0, 1, RES_STATE_ACTIVE),
465 0x13}, 453 0x13},
466 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 2, RES_STATE_WRST), 0x13},
467 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 3, RES_STATE_OFF), 0x13}, 454 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 3, RES_STATE_OFF), 0x13},
468 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD1, RES_STATE_WRST), 0x13}, 455 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD1, RES_STATE_WRST), 0x13},
469 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD2, RES_STATE_WRST), 0x13}, 456 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD2, RES_STATE_WRST), 0x13},
470 {MSG_SINGULAR(DEV_GRP_NULL, RES_VPLL1, RES_STATE_WRST), 0x35}, 457 {MSG_SINGULAR(DEV_GRP_NULL, RES_VPLL1, RES_STATE_WRST), 0x35},
471 {MSG_SINGULAR(DEV_GRP_P1, RES_HFCLKOUT, RES_STATE_ACTIVE), 2}, 458 {MSG_SINGULAR(DEV_GRP_P3, RES_HFCLKOUT, RES_STATE_ACTIVE), 2},
472 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_ACTIVE), 2}, 459 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_ACTIVE), 2},
473}; 460};
474 461
@@ -490,22 +477,81 @@ static struct twl4030_script *twl4030_scripts[] __initdata = {
490}; 477};
491 478
492static struct twl4030_resconfig twl4030_rconfig[] __initdata = { 479static struct twl4030_resconfig twl4030_rconfig[] __initdata = {
493 { .resource = RES_VINTANA1, .devgroup = -1, .type = -1, .type2 = 1 }, 480 { .resource = RES_VDD1, .devgroup = -1,
494 { .resource = RES_VINTANA2, .devgroup = -1, .type = -1, .type2 = 1 }, 481 .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
495 { .resource = RES_VINTDIG, .devgroup = -1, .type = -1, .type2 = 1 }, 482 .remap_sleep = RES_STATE_OFF
496 { .resource = RES_VMMC1, .devgroup = -1, .type = -1, .type2 = 3}, 483 },
497 { .resource = RES_VMMC2, .devgroup = DEV_GRP_NULL, .type = -1, 484 { .resource = RES_VDD2, .devgroup = -1,
498 .type2 = 3}, 485 .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
499 { .resource = RES_VAUX1, .devgroup = -1, .type = -1, .type2 = 3}, 486 .remap_sleep = RES_STATE_OFF
500 { .resource = RES_VAUX2, .devgroup = -1, .type = -1, .type2 = 3}, 487 },
501 { .resource = RES_VAUX3, .devgroup = -1, .type = -1, .type2 = 3}, 488 { .resource = RES_VPLL1, .devgroup = -1,
502 { .resource = RES_VAUX4, .devgroup = -1, .type = -1, .type2 = 3}, 489 .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
503 { .resource = RES_VPLL2, .devgroup = -1, .type = -1, .type2 = 3}, 490 .remap_sleep = RES_STATE_OFF
504 { .resource = RES_VDAC, .devgroup = -1, .type = -1, .type2 = 3}, 491 },
505 { .resource = RES_VSIM, .devgroup = DEV_GRP_NULL, .type = -1, 492 { .resource = RES_VPLL2, .devgroup = -1,
506 .type2 = 3}, 493 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
507 { .resource = RES_CLKEN, .devgroup = DEV_GRP_P3, .type = -1, 494 },
508 .type2 = 1 }, 495 { .resource = RES_VAUX1, .devgroup = -1,
496 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
497 },
498 { .resource = RES_VAUX2, .devgroup = -1,
499 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
500 },
501 { .resource = RES_VAUX3, .devgroup = -1,
502 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
503 },
504 { .resource = RES_VAUX4, .devgroup = -1,
505 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
506 },
507 { .resource = RES_VMMC1, .devgroup = -1,
508 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
509 },
510 { .resource = RES_VMMC2, .devgroup = -1,
511 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
512 },
513 { .resource = RES_VDAC, .devgroup = -1,
514 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
515 },
516 { .resource = RES_VSIM, .devgroup = -1,
517 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
518 },
519 { .resource = RES_VINTANA1, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
520 .type = -1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
521 },
522 { .resource = RES_VINTANA2, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
523 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
524 },
525 { .resource = RES_VINTDIG, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
526 .type = -1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
527 },
528 { .resource = RES_VIO, .devgroup = DEV_GRP_P3,
529 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
530 },
531 { .resource = RES_CLKEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
532 .type = 1, .type2 = -1 , .remap_off = -1, .remap_sleep = -1
533 },
534 { .resource = RES_REGEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
535 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
536 },
537 { .resource = RES_NRES_PWRON, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
538 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
539 },
540 { .resource = RES_SYSEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
541 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
542 },
543 { .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3,
544 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
545 },
546 { .resource = RES_32KCLKOUT, .devgroup = -1,
547 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
548 },
549 { .resource = RES_RESET, .devgroup = -1,
550 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
551 },
552 { .resource = RES_Main_Ref, .devgroup = -1,
553 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
554 },
509 { 0, 0}, 555 { 0, 0},
510}; 556};
511 557
diff --git a/arch/arm/mach-pxa/Kconfig b/arch/arm/mach-pxa/Kconfig
index d89c6adbe8bc..e6d8e10ae5d1 100644
--- a/arch/arm/mach-pxa/Kconfig
+++ b/arch/arm/mach-pxa/Kconfig
@@ -63,6 +63,15 @@ config ARCH_VIPER
63 select HAVE_PWM 63 select HAVE_PWM
64 select PXA_HAVE_BOARD_IRQS 64 select PXA_HAVE_BOARD_IRQS
65 select PXA_HAVE_ISA_IRQS 65 select PXA_HAVE_ISA_IRQS
66 select ARCOM_PCMCIA
67
68config MACH_ARCOM_ZEUS
69 bool "Arcom/Eurotech ZEUS SBC"
70 select PXA27x
71 select ISA
72 select PXA_HAVE_BOARD_IRQS
73 select PXA_HAVE_ISA_IRQS
74 select ARCOM_PCMCIA
66 75
67config MACH_BALLOON3 76config MACH_BALLOON3
68 bool "Balloon 3 board" 77 bool "Balloon 3 board"
@@ -179,6 +188,11 @@ config MACH_TRIZEPS_ANY
179 188
180endchoice 189endchoice
181 190
191config ARCOM_PCMCIA
192 bool
193 help
194 Generic option for Arcom Viper/Zeus PCMCIA
195
182config TRIZEPS_PCMCIA 196config TRIZEPS_PCMCIA
183 bool 197 bool
184 help 198 help
diff --git a/arch/arm/mach-pxa/Makefile b/arch/arm/mach-pxa/Makefile
index b5d29e60a341..f64afda7e6f6 100644
--- a/arch/arm/mach-pxa/Makefile
+++ b/arch/arm/mach-pxa/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_MACH_SAAR) += saar.o
38# 3rd Party Dev Platforms 38# 3rd Party Dev Platforms
39obj-$(CONFIG_ARCH_PXA_IDP) += idp.o 39obj-$(CONFIG_ARCH_PXA_IDP) += idp.o
40obj-$(CONFIG_ARCH_VIPER) += viper.o 40obj-$(CONFIG_ARCH_VIPER) += viper.o
41obj-$(CONFIG_MACH_ARCOM_ZEUS) += zeus.o
41obj-$(CONFIG_MACH_BALLOON3) += balloon3.o 42obj-$(CONFIG_MACH_BALLOON3) += balloon3.o
42obj-$(CONFIG_MACH_CSB726) += csb726.o 43obj-$(CONFIG_MACH_CSB726) += csb726.o
43obj-$(CONFIG_CSB726_CSB701) += csb701.o 44obj-$(CONFIG_CSB726_CSB701) += csb701.o
diff --git a/arch/arm/mach-pxa/em-x270.c b/arch/arm/mach-pxa/em-x270.c
index 1c0de808b54d..c8a01bc85fde 100644
--- a/arch/arm/mach-pxa/em-x270.c
+++ b/arch/arm/mach-pxa/em-x270.c
@@ -497,16 +497,15 @@ static int em_x270_usb_hub_init(void)
497 goto err_free_vbus_gpio; 497 goto err_free_vbus_gpio;
498 498
499 /* USB Hub power-on and reset */ 499 /* USB Hub power-on and reset */
500 gpio_direction_output(usb_hub_reset, 0); 500 gpio_direction_output(usb_hub_reset, 1);
501 gpio_direction_output(GPIO9_USB_VBUS_EN, 0);
501 regulator_enable(em_x270_usb_ldo); 502 regulator_enable(em_x270_usb_ldo);
502 gpio_set_value(usb_hub_reset, 1);
503 gpio_set_value(usb_hub_reset, 0); 503 gpio_set_value(usb_hub_reset, 0);
504 gpio_set_value(usb_hub_reset, 1);
504 regulator_disable(em_x270_usb_ldo); 505 regulator_disable(em_x270_usb_ldo);
505 regulator_enable(em_x270_usb_ldo); 506 regulator_enable(em_x270_usb_ldo);
506 gpio_set_value(usb_hub_reset, 1); 507 gpio_set_value(usb_hub_reset, 0);
507 508 gpio_set_value(GPIO9_USB_VBUS_EN, 1);
508 /* enable VBUS */
509 gpio_direction_output(GPIO9_USB_VBUS_EN, 1);
510 509
511 return 0; 510 return 0;
512 511
diff --git a/arch/arm/mach-pxa/include/mach/arcom-pcmcia.h b/arch/arm/mach-pxa/include/mach/arcom-pcmcia.h
new file mode 100644
index 000000000000..d428be4db44c
--- /dev/null
+++ b/arch/arm/mach-pxa/include/mach/arcom-pcmcia.h
@@ -0,0 +1,11 @@
1#ifndef __ARCOM_PCMCIA_H
2#define __ARCOM_PCMCIA_H
3
4struct arcom_pcmcia_pdata {
5 int cd_gpio;
6 int rdy_gpio;
7 int pwr_gpio;
8 void (*reset)(int state);
9};
10
11#endif
diff --git a/arch/arm/mach-pxa/include/mach/viper.h b/arch/arm/mach-pxa/include/mach/viper.h
index 10988c270ca3..5f5fbf1f6489 100644
--- a/arch/arm/mach-pxa/include/mach/viper.h
+++ b/arch/arm/mach-pxa/include/mach/viper.h
@@ -85,8 +85,6 @@
85/* Interrupt and Configuration Register (VIPER_ICR) */ 85/* Interrupt and Configuration Register (VIPER_ICR) */
86/* This is a write only register. Only CF_RST is used under Linux */ 86/* This is a write only register. Only CF_RST is used under Linux */
87 87
88extern void viper_cf_rst(int state);
89
90#define VIPER_ICR_RETRIG (1 << 0) 88#define VIPER_ICR_RETRIG (1 << 0)
91#define VIPER_ICR_AUTO_CLR (1 << 1) 89#define VIPER_ICR_AUTO_CLR (1 << 1)
92#define VIPER_ICR_R_DIS (1 << 2) 90#define VIPER_ICR_R_DIS (1 << 2)
diff --git a/arch/arm/mach-pxa/include/mach/zeus.h b/arch/arm/mach-pxa/include/mach/zeus.h
new file mode 100644
index 000000000000..c387046d2f28
--- /dev/null
+++ b/arch/arm/mach-pxa/include/mach/zeus.h
@@ -0,0 +1,82 @@
1/*
2 * arch/arm/mach-pxa/include/mach/zeus.h
3 *
4 * Author: David Vrabel
5 * Created: Sept 28, 2005
6 * Copyright: Arcom Control Systems Ltd.
7 *
8 * Maintained by: Marc Zyngier <maz@misterjones.org>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#ifndef _MACH_ZEUS_H
16#define _MACH_ZEUS_H
17
18/* Physical addresses */
19#define ZEUS_FLASH_PHYS PXA_CS0_PHYS
20#define ZEUS_ETH0_PHYS PXA_CS1_PHYS
21#define ZEUS_ETH1_PHYS PXA_CS2_PHYS
22#define ZEUS_CPLD_PHYS (PXA_CS4_PHYS+0x2000000)
23#define ZEUS_SRAM_PHYS PXA_CS5_PHYS
24#define ZEUS_PC104IO_PHYS (0x30000000)
25
26#define ZEUS_CPLD_VERSION_PHYS (ZEUS_CPLD_PHYS + 0x00000000)
27#define ZEUS_CPLD_ISA_IRQ_PHYS (ZEUS_CPLD_PHYS + 0x00800000)
28#define ZEUS_CPLD_CONTROL_PHYS (ZEUS_CPLD_PHYS + 0x01000000)
29#define ZEUS_CPLD_EXTWDOG_PHYS (ZEUS_CPLD_PHYS + 0x01800000)
30
31/* GPIOs */
32#define ZEUS_AC97_GPIO 0
33#define ZEUS_WAKEUP_GPIO 1
34#define ZEUS_UARTA_GPIO 9
35#define ZEUS_UARTB_GPIO 10
36#define ZEUS_UARTC_GPIO 12
37#define ZEUS_UARTD_GPIO 11
38#define ZEUS_ETH0_GPIO 14
39#define ZEUS_ISA_GPIO 17
40#define ZEUS_BKLEN_GPIO 19
41#define ZEUS_USB2_PWREN_GPIO 22
42#define ZEUS_PTT_GPIO 27
43#define ZEUS_CF_CD_GPIO 35
44#define ZEUS_MMC_WP_GPIO 52
45#define ZEUS_MMC_CD_GPIO 53
46#define ZEUS_EXTGPIO_GPIO 91
47#define ZEUS_CF_PWEN_GPIO 97
48#define ZEUS_CF_RDY_GPIO 99
49#define ZEUS_LCD_EN_GPIO 101
50#define ZEUS_ETH1_GPIO 113
51#define ZEUS_CAN_GPIO 116
52
53#define ZEUS_EXT0_GPIO_BASE 128
54#define ZEUS_EXT1_GPIO_BASE 160
55#define ZEUS_USER_GPIO_BASE 192
56
57#define ZEUS_EXT0_GPIO(x) (ZEUS_EXT0_GPIO_BASE + (x))
58#define ZEUS_EXT1_GPIO(x) (ZEUS_EXT1_GPIO_BASE + (x))
59#define ZEUS_USER_GPIO(x) (ZEUS_USER_GPIO_BASE + (x))
60
61/*
62 * CPLD registers:
63 * Only 4 registers, but spreaded over a 32MB address space.
64 * Be gentle, and remap that over 32kB...
65 */
66
67#define ZEUS_CPLD (0xf0000000)
68#define ZEUS_CPLD_VERSION (ZEUS_CPLD + 0x0000)
69#define ZEUS_CPLD_ISA_IRQ (ZEUS_CPLD + 0x1000)
70#define ZEUS_CPLD_CONTROL (ZEUS_CPLD + 0x2000)
71#define ZEUS_CPLD_EXTWDOG (ZEUS_CPLD + 0x3000)
72
73/* CPLD register bits */
74#define ZEUS_CPLD_CONTROL_CF_RST 0x01
75
76#define ZEUS_PC104IO (0xf1000000)
77
78#define ZEUS_SRAM_SIZE (256 * 1024)
79
80#endif
81
82
diff --git a/arch/arm/mach-pxa/viper.c b/arch/arm/mach-pxa/viper.c
index cf0d71b7797e..5352b4e5a7dd 100644
--- a/arch/arm/mach-pxa/viper.c
+++ b/arch/arm/mach-pxa/viper.c
@@ -47,6 +47,7 @@
47#include <mach/pxafb.h> 47#include <mach/pxafb.h>
48#include <plat/i2c.h> 48#include <plat/i2c.h>
49#include <mach/regs-uart.h> 49#include <mach/regs-uart.h>
50#include <mach/arcom-pcmcia.h>
50#include <mach/viper.h> 51#include <mach/viper.h>
51 52
52#include <asm/setup.h> 53#include <asm/setup.h>
@@ -76,14 +77,28 @@ static void viper_icr_clear_bit(unsigned int bit)
76} 77}
77 78
78/* This function is used from the pcmcia module to reset the CF */ 79/* This function is used from the pcmcia module to reset the CF */
79void viper_cf_rst(int state) 80static void viper_cf_reset(int state)
80{ 81{
81 if (state) 82 if (state)
82 viper_icr_set_bit(VIPER_ICR_CF_RST); 83 viper_icr_set_bit(VIPER_ICR_CF_RST);
83 else 84 else
84 viper_icr_clear_bit(VIPER_ICR_CF_RST); 85 viper_icr_clear_bit(VIPER_ICR_CF_RST);
85} 86}
86EXPORT_SYMBOL(viper_cf_rst); 87
88static struct arcom_pcmcia_pdata viper_pcmcia_info = {
89 .cd_gpio = VIPER_CF_CD_GPIO,
90 .rdy_gpio = VIPER_CF_RDY_GPIO,
91 .pwr_gpio = VIPER_CF_POWER_GPIO,
92 .reset = viper_cf_reset,
93};
94
95static struct platform_device viper_pcmcia_device = {
96 .name = "viper-pcmcia",
97 .id = -1,
98 .dev = {
99 .platform_data = &viper_pcmcia_info,
100 },
101};
87 102
88/* 103/*
89 * The CPLD version register was not present on VIPER boards prior to 104 * The CPLD version register was not present on VIPER boards prior to
@@ -685,6 +700,7 @@ static struct platform_device *viper_devs[] __initdata = {
685 &viper_mtd_devices[0], 700 &viper_mtd_devices[0],
686 &viper_mtd_devices[1], 701 &viper_mtd_devices[1],
687 &viper_backlight_device, 702 &viper_backlight_device,
703 &viper_pcmcia_device,
688}; 704};
689 705
690static mfp_cfg_t viper_pin_config[] __initdata = { 706static mfp_cfg_t viper_pin_config[] __initdata = {
diff --git a/arch/arm/mach-pxa/zeus.c b/arch/arm/mach-pxa/zeus.c
new file mode 100644
index 000000000000..5b986a8bd9e6
--- /dev/null
+++ b/arch/arm/mach-pxa/zeus.c
@@ -0,0 +1,820 @@
1/*
2 * Support for the Arcom ZEUS.
3 *
4 * Copyright (C) 2006 Arcom Control Systems Ltd.
5 *
6 * Loosely based on Arcom's 2.6.16.28.
7 * Maintained by Marc Zyngier <maz@misterjones.org>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#include <linux/cpufreq.h>
15#include <linux/interrupt.h>
16#include <linux/irq.h>
17#include <linux/pm.h>
18#include <linux/gpio.h>
19#include <linux/serial_8250.h>
20#include <linux/dm9000.h>
21#include <linux/mmc/host.h>
22#include <linux/spi/spi.h>
23#include <linux/mtd/mtd.h>
24#include <linux/mtd/partitions.h>
25#include <linux/mtd/physmap.h>
26#include <linux/i2c.h>
27#include <linux/i2c/pca953x.h>
28
29#include <asm/mach-types.h>
30#include <asm/mach/arch.h>
31#include <asm/mach/map.h>
32
33#include <plat/i2c.h>
34
35#include <mach/pxa2xx-regs.h>
36#include <mach/regs-uart.h>
37#include <mach/ohci.h>
38#include <mach/mmc.h>
39#include <mach/pxa27x-udc.h>
40#include <mach/udc.h>
41#include <mach/pxafb.h>
42#include <mach/pxa2xx_spi.h>
43#include <mach/mfp-pxa27x.h>
44#include <mach/pm.h>
45#include <mach/audio.h>
46#include <mach/arcom-pcmcia.h>
47#include <mach/zeus.h>
48
49#include "generic.h"
50
51/*
52 * Interrupt handling
53 */
54
55static unsigned long zeus_irq_enabled_mask;
56static const int zeus_isa_irqs[] = { 3, 4, 5, 6, 7, 10, 11, 12, };
57static const int zeus_isa_irq_map[] = {
58 0, /* ISA irq #0, invalid */
59 0, /* ISA irq #1, invalid */
60 0, /* ISA irq #2, invalid */
61 1 << 0, /* ISA irq #3 */
62 1 << 1, /* ISA irq #4 */
63 1 << 2, /* ISA irq #5 */
64 1 << 3, /* ISA irq #6 */
65 1 << 4, /* ISA irq #7 */
66 0, /* ISA irq #8, invalid */
67 0, /* ISA irq #9, invalid */
68 1 << 5, /* ISA irq #10 */
69 1 << 6, /* ISA irq #11 */
70 1 << 7, /* ISA irq #12 */
71};
72
73static inline int zeus_irq_to_bitmask(unsigned int irq)
74{
75 return zeus_isa_irq_map[irq - PXA_ISA_IRQ(0)];
76}
77
78static inline int zeus_bit_to_irq(int bit)
79{
80 return zeus_isa_irqs[bit] + PXA_ISA_IRQ(0);
81}
82
83static void zeus_ack_irq(unsigned int irq)
84{
85 __raw_writew(zeus_irq_to_bitmask(irq), ZEUS_CPLD_ISA_IRQ);
86}
87
88static void zeus_mask_irq(unsigned int irq)
89{
90 zeus_irq_enabled_mask &= ~(zeus_irq_to_bitmask(irq));
91}
92
93static void zeus_unmask_irq(unsigned int irq)
94{
95 zeus_irq_enabled_mask |= zeus_irq_to_bitmask(irq);
96}
97
98static inline unsigned long zeus_irq_pending(void)
99{
100 return __raw_readw(ZEUS_CPLD_ISA_IRQ) & zeus_irq_enabled_mask;
101}
102
103static void zeus_irq_handler(unsigned int irq, struct irq_desc *desc)
104{
105 unsigned long pending;
106
107 pending = zeus_irq_pending();
108 do {
109 /* we're in a chained irq handler,
110 * so ack the interrupt by hand */
111 desc->chip->ack(gpio_to_irq(ZEUS_ISA_GPIO));
112
113 if (likely(pending)) {
114 irq = zeus_bit_to_irq(__ffs(pending));
115 generic_handle_irq(irq);
116 }
117 pending = zeus_irq_pending();
118 } while (pending);
119}
120
121static struct irq_chip zeus_irq_chip = {
122 .name = "ISA",
123 .ack = zeus_ack_irq,
124 .mask = zeus_mask_irq,
125 .unmask = zeus_unmask_irq,
126};
127
128static void __init zeus_init_irq(void)
129{
130 int level;
131 int isa_irq;
132
133 pxa27x_init_irq();
134
135 /* Peripheral IRQs. It would be nice to move those inside driver
136 configuration, but it is not supported at the moment. */
137 set_irq_type(gpio_to_irq(ZEUS_AC97_GPIO), IRQ_TYPE_EDGE_RISING);
138 set_irq_type(gpio_to_irq(ZEUS_WAKEUP_GPIO), IRQ_TYPE_EDGE_RISING);
139 set_irq_type(gpio_to_irq(ZEUS_PTT_GPIO), IRQ_TYPE_EDGE_RISING);
140 set_irq_type(gpio_to_irq(ZEUS_EXTGPIO_GPIO), IRQ_TYPE_EDGE_FALLING);
141 set_irq_type(gpio_to_irq(ZEUS_CAN_GPIO), IRQ_TYPE_EDGE_FALLING);
142
143 /* Setup ISA IRQs */
144 for (level = 0; level < ARRAY_SIZE(zeus_isa_irqs); level++) {
145 isa_irq = zeus_bit_to_irq(level);
146 set_irq_chip(isa_irq, &zeus_irq_chip);
147 set_irq_handler(isa_irq, handle_edge_irq);
148 set_irq_flags(isa_irq, IRQF_VALID | IRQF_PROBE);
149 }
150
151 set_irq_type(gpio_to_irq(ZEUS_ISA_GPIO), IRQ_TYPE_EDGE_RISING);
152 set_irq_chained_handler(gpio_to_irq(ZEUS_ISA_GPIO), zeus_irq_handler);
153}
154
155
156/*
157 * Platform devices
158 */
159
160/* Flash */
161static struct resource zeus_mtd_resources[] = {
162 [0] = { /* NOR Flash (up to 64MB) */
163 .start = ZEUS_FLASH_PHYS,
164 .end = ZEUS_FLASH_PHYS + SZ_64M - 1,
165 .flags = IORESOURCE_MEM,
166 },
167 [1] = { /* SRAM */
168 .start = ZEUS_SRAM_PHYS,
169 .end = ZEUS_SRAM_PHYS + SZ_512K - 1,
170 .flags = IORESOURCE_MEM,
171 },
172};
173
174static struct physmap_flash_data zeus_flash_data[] = {
175 [0] = {
176 .width = 2,
177 .parts = NULL,
178 .nr_parts = 0,
179 },
180};
181
182static struct platform_device zeus_mtd_devices[] = {
183 [0] = {
184 .name = "physmap-flash",
185 .id = 0,
186 .dev = {
187 .platform_data = &zeus_flash_data[0],
188 },
189 .resource = &zeus_mtd_resources[0],
190 .num_resources = 1,
191 },
192};
193
194/* Serial */
195static struct resource zeus_serial_resources[] = {
196 {
197 .start = 0x10000000,
198 .end = 0x1000000f,
199 .flags = IORESOURCE_MEM,
200 },
201 {
202 .start = 0x10800000,
203 .end = 0x1080000f,
204 .flags = IORESOURCE_MEM,
205 },
206 {
207 .start = 0x11000000,
208 .end = 0x1100000f,
209 .flags = IORESOURCE_MEM,
210 },
211 {
212 .start = 0x40100000,
213 .end = 0x4010001f,
214 .flags = IORESOURCE_MEM,
215 },
216 {
217 .start = 0x40200000,
218 .end = 0x4020001f,
219 .flags = IORESOURCE_MEM,
220 },
221 {
222 .start = 0x40700000,
223 .end = 0x4070001f,
224 .flags = IORESOURCE_MEM,
225 },
226};
227
228static struct plat_serial8250_port serial_platform_data[] = {
229 /* External UARTs */
230 /* FIXME: Shared IRQs on COM1-COM4 will not work properly on v1i1 hardware. */
231 { /* COM1 */
232 .mapbase = 0x10000000,
233 .irq = gpio_to_irq(ZEUS_UARTA_GPIO),
234 .irqflags = IRQF_TRIGGER_RISING,
235 .uartclk = 14745600,
236 .regshift = 1,
237 .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
238 .iotype = UPIO_MEM,
239 },
240 { /* COM2 */
241 .mapbase = 0x10800000,
242 .irq = gpio_to_irq(ZEUS_UARTB_GPIO),
243 .irqflags = IRQF_TRIGGER_RISING,
244 .uartclk = 14745600,
245 .regshift = 1,
246 .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
247 .iotype = UPIO_MEM,
248 },
249 { /* COM3 */
250 .mapbase = 0x11000000,
251 .irq = gpio_to_irq(ZEUS_UARTC_GPIO),
252 .irqflags = IRQF_TRIGGER_RISING,
253 .uartclk = 14745600,
254 .regshift = 1,
255 .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
256 .iotype = UPIO_MEM,
257 },
258 { /* COM4 */
259 .mapbase = 0x11800000,
260 .irq = gpio_to_irq(ZEUS_UARTD_GPIO),
261 .irqflags = IRQF_TRIGGER_RISING,
262 .uartclk = 14745600,
263 .regshift = 1,
264 .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
265 .iotype = UPIO_MEM,
266 },
267 /* Internal UARTs */
268 { /* FFUART */
269 .membase = (void *)&FFUART,
270 .mapbase = __PREG(FFUART),
271 .irq = IRQ_FFUART,
272 .uartclk = 921600 * 16,
273 .regshift = 2,
274 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
275 .iotype = UPIO_MEM,
276 },
277 { /* BTUART */
278 .membase = (void *)&BTUART,
279 .mapbase = __PREG(BTUART),
280 .irq = IRQ_BTUART,
281 .uartclk = 921600 * 16,
282 .regshift = 2,
283 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
284 .iotype = UPIO_MEM,
285 },
286 { /* STUART */
287 .membase = (void *)&STUART,
288 .mapbase = __PREG(STUART),
289 .irq = IRQ_STUART,
290 .uartclk = 921600 * 16,
291 .regshift = 2,
292 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
293 .iotype = UPIO_MEM,
294 },
295 { },
296};
297
298static struct platform_device zeus_serial_device = {
299 .name = "serial8250",
300 .id = PLAT8250_DEV_PLATFORM,
301 .dev = {
302 .platform_data = serial_platform_data,
303 },
304 .num_resources = ARRAY_SIZE(zeus_serial_resources),
305 .resource = zeus_serial_resources,
306};
307
308/* Ethernet */
309static struct resource zeus_dm9k0_resource[] = {
310 [0] = {
311 .start = ZEUS_ETH0_PHYS,
312 .end = ZEUS_ETH0_PHYS + 1,
313 .flags = IORESOURCE_MEM
314 },
315 [1] = {
316 .start = ZEUS_ETH0_PHYS + 2,
317 .end = ZEUS_ETH0_PHYS + 3,
318 .flags = IORESOURCE_MEM
319 },
320 [2] = {
321 .start = gpio_to_irq(ZEUS_ETH0_GPIO),
322 .end = gpio_to_irq(ZEUS_ETH0_GPIO),
323 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
324 },
325};
326
327static struct resource zeus_dm9k1_resource[] = {
328 [0] = {
329 .start = ZEUS_ETH1_PHYS,
330 .end = ZEUS_ETH1_PHYS + 1,
331 .flags = IORESOURCE_MEM
332 },
333 [1] = {
334 .start = ZEUS_ETH1_PHYS + 2,
335 .end = ZEUS_ETH1_PHYS + 3,
336 .flags = IORESOURCE_MEM,
337 },
338 [2] = {
339 .start = gpio_to_irq(ZEUS_ETH1_GPIO),
340 .end = gpio_to_irq(ZEUS_ETH1_GPIO),
341 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
342 },
343};
344
345static struct dm9000_plat_data zeus_dm9k_platdata = {
346 .flags = DM9000_PLATF_16BITONLY,
347};
348
349static struct platform_device zeus_dm9k0_device = {
350 .name = "dm9000",
351 .id = 0,
352 .num_resources = ARRAY_SIZE(zeus_dm9k0_resource),
353 .resource = zeus_dm9k0_resource,
354 .dev = {
355 .platform_data = &zeus_dm9k_platdata,
356 }
357};
358
359static struct platform_device zeus_dm9k1_device = {
360 .name = "dm9000",
361 .id = 1,
362 .num_resources = ARRAY_SIZE(zeus_dm9k1_resource),
363 .resource = zeus_dm9k1_resource,
364 .dev = {
365 .platform_data = &zeus_dm9k_platdata,
366 }
367};
368
369/* External SRAM */
370static struct resource zeus_sram_resource = {
371 .start = ZEUS_SRAM_PHYS,
372 .end = ZEUS_SRAM_PHYS + ZEUS_SRAM_SIZE * 2 - 1,
373 .flags = IORESOURCE_MEM,
374};
375
376static struct platform_device zeus_sram_device = {
377 .name = "pxa2xx-8bit-sram",
378 .id = 0,
379 .num_resources = 1,
380 .resource = &zeus_sram_resource,
381};
382
383/* SPI interface on SSP3 */
384static struct pxa2xx_spi_master pxa2xx_spi_ssp3_master_info = {
385 .num_chipselect = 1,
386 .enable_dma = 1,
387};
388
389static struct platform_device pxa2xx_spi_ssp3_device = {
390 .name = "pxa2xx-spi",
391 .id = 3,
392 .dev = {
393 .platform_data = &pxa2xx_spi_ssp3_master_info,
394 },
395};
396
397/* Leds */
398static struct gpio_led zeus_leds[] = {
399 [0] = {
400 .name = "zeus:yellow:1",
401 .default_trigger = "heartbeat",
402 .gpio = ZEUS_EXT0_GPIO(3),
403 .active_low = 1,
404 },
405 [1] = {
406 .name = "zeus:yellow:2",
407 .default_trigger = "default-on",
408 .gpio = ZEUS_EXT0_GPIO(4),
409 .active_low = 1,
410 },
411 [2] = {
412 .name = "zeus:yellow:3",
413 .default_trigger = "default-on",
414 .gpio = ZEUS_EXT0_GPIO(5),
415 .active_low = 1,
416 },
417};
418
419static struct gpio_led_platform_data zeus_leds_info = {
420 .leds = zeus_leds,
421 .num_leds = ARRAY_SIZE(zeus_leds),
422};
423
424static struct platform_device zeus_leds_device = {
425 .name = "leds-gpio",
426 .id = -1,
427 .dev = {
428 .platform_data = &zeus_leds_info,
429 },
430};
431
432static void zeus_cf_reset(int state)
433{
434 u16 cpld_state = __raw_readw(ZEUS_CPLD_CONTROL);
435
436 if (state)
437 cpld_state |= ZEUS_CPLD_CONTROL_CF_RST;
438 else
439 cpld_state &= ~ZEUS_CPLD_CONTROL_CF_RST;
440
441 __raw_writew(cpld_state, ZEUS_CPLD_CONTROL);
442}
443
444static struct arcom_pcmcia_pdata zeus_pcmcia_info = {
445 .cd_gpio = ZEUS_CF_CD_GPIO,
446 .rdy_gpio = ZEUS_CF_RDY_GPIO,
447 .pwr_gpio = ZEUS_CF_PWEN_GPIO,
448 .reset = zeus_cf_reset,
449};
450
451static struct platform_device zeus_pcmcia_device = {
452 .name = "zeus-pcmcia",
453 .id = -1,
454 .dev = {
455 .platform_data = &zeus_pcmcia_info,
456 },
457};
458
459static struct platform_device *zeus_devices[] __initdata = {
460 &zeus_serial_device,
461 &zeus_mtd_devices[0],
462 &zeus_dm9k0_device,
463 &zeus_dm9k1_device,
464 &zeus_sram_device,
465 &pxa2xx_spi_ssp3_device,
466 &zeus_leds_device,
467 &zeus_pcmcia_device,
468};
469
470/* AC'97 */
471static pxa2xx_audio_ops_t zeus_ac97_info = {
472 .reset_gpio = 95,
473};
474
475
476/*
477 * USB host
478 */
479
480static int zeus_ohci_init(struct device *dev)
481{
482 int err;
483
484 /* Switch on port 2. */
485 if ((err = gpio_request(ZEUS_USB2_PWREN_GPIO, "USB2_PWREN"))) {
486 dev_err(dev, "Can't request USB2_PWREN\n");
487 return err;
488 }
489
490 if ((err = gpio_direction_output(ZEUS_USB2_PWREN_GPIO, 1))) {
491 gpio_free(ZEUS_USB2_PWREN_GPIO);
492 dev_err(dev, "Can't enable USB2_PWREN\n");
493 return err;
494 }
495
496 /* Port 2 is shared between host and client interface. */
497 UP2OCR = UP2OCR_HXOE | UP2OCR_HXS | UP2OCR_DMPDE | UP2OCR_DPPDE;
498
499 return 0;
500}
501
502static void zeus_ohci_exit(struct device *dev)
503{
504 /* Power-off port 2 */
505 gpio_direction_output(ZEUS_USB2_PWREN_GPIO, 0);
506 gpio_free(ZEUS_USB2_PWREN_GPIO);
507}
508
509static struct pxaohci_platform_data zeus_ohci_platform_data = {
510 .port_mode = PMM_NPS_MODE,
511 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
512 .init = zeus_ohci_init,
513 .exit = zeus_ohci_exit,
514};
515
516/*
517 * Flat Panel
518 */
519
520static void zeus_lcd_power(int on, struct fb_var_screeninfo *si)
521{
522 gpio_set_value(ZEUS_LCD_EN_GPIO, on);
523}
524
525static void zeus_backlight_power(int on)
526{
527 gpio_set_value(ZEUS_BKLEN_GPIO, on);
528}
529
530static int zeus_setup_fb_gpios(void)
531{
532 int err;
533
534 if ((err = gpio_request(ZEUS_LCD_EN_GPIO, "LCD_EN")))
535 goto out_err;
536
537 if ((err = gpio_direction_output(ZEUS_LCD_EN_GPIO, 0)))
538 goto out_err_lcd;
539
540 if ((err = gpio_request(ZEUS_BKLEN_GPIO, "BKLEN")))
541 goto out_err_lcd;
542
543 if ((err = gpio_direction_output(ZEUS_BKLEN_GPIO, 0)))
544 goto out_err_bkl;
545
546 return 0;
547
548out_err_bkl:
549 gpio_free(ZEUS_BKLEN_GPIO);
550out_err_lcd:
551 gpio_free(ZEUS_LCD_EN_GPIO);
552out_err:
553 return err;
554}
555
556static struct pxafb_mode_info zeus_fb_mode_info[] = {
557 {
558 .pixclock = 39722,
559
560 .xres = 640,
561 .yres = 480,
562
563 .bpp = 16,
564
565 .hsync_len = 63,
566 .left_margin = 16,
567 .right_margin = 81,
568
569 .vsync_len = 2,
570 .upper_margin = 12,
571 .lower_margin = 31,
572
573 .sync = 0,
574 },
575};
576
577static struct pxafb_mach_info zeus_fb_info = {
578 .modes = zeus_fb_mode_info,
579 .num_modes = 1,
580 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
581 .pxafb_lcd_power = zeus_lcd_power,
582 .pxafb_backlight_power = zeus_backlight_power,
583};
584
585/*
586 * MMC/SD Device
587 *
588 * The card detect interrupt isn't debounced so we delay it by 250ms
589 * to give the card a chance to fully insert/eject.
590 */
591
592static struct pxamci_platform_data zeus_mci_platform_data = {
593 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
594 .detect_delay = HZ/4,
595 .gpio_card_detect = ZEUS_MMC_CD_GPIO,
596 .gpio_card_ro = ZEUS_MMC_WP_GPIO,
597 .gpio_card_ro_invert = 1,
598 .gpio_power = -1
599};
600
601/*
602 * USB Device Controller
603 */
604static void zeus_udc_command(int cmd)
605{
606 switch (cmd) {
607 case PXA2XX_UDC_CMD_DISCONNECT:
608 pr_info("zeus: disconnecting USB client\n");
609 UP2OCR = UP2OCR_HXOE | UP2OCR_HXS | UP2OCR_DMPDE | UP2OCR_DPPDE;
610 break;
611
612 case PXA2XX_UDC_CMD_CONNECT:
613 pr_info("zeus: connecting USB client\n");
614 UP2OCR = UP2OCR_HXOE | UP2OCR_DPPUE;
615 break;
616 }
617}
618
619static struct pxa2xx_udc_mach_info zeus_udc_info = {
620 .udc_command = zeus_udc_command,
621};
622
623static void zeus_power_off(void)
624{
625 local_irq_disable();
626 pxa27x_cpu_suspend(PWRMODE_DEEPSLEEP);
627}
628
629int zeus_get_pcb_info(struct i2c_client *client, unsigned gpio,
630 unsigned ngpio, void *context)
631{
632 int i;
633 u8 pcb_info = 0;
634
635 for (i = 0; i < 8; i++) {
636 int pcb_bit = gpio + i + 8;
637
638 if (gpio_request(pcb_bit, "pcb info")) {
639 dev_err(&client->dev, "Can't request pcb info %d\n", i);
640 continue;
641 }
642
643 if (gpio_direction_input(pcb_bit)) {
644 dev_err(&client->dev, "Can't read pcb info %d\n", i);
645 gpio_free(pcb_bit);
646 continue;
647 }
648
649 pcb_info |= !!gpio_get_value(pcb_bit) << i;
650
651 gpio_free(pcb_bit);
652 }
653
654 dev_info(&client->dev, "Zeus PCB version %d issue %d\n",
655 pcb_info >> 4, pcb_info & 0xf);
656
657 return 0;
658}
659
660static struct pca953x_platform_data zeus_pca953x_pdata[] = {
661 [0] = { .gpio_base = ZEUS_EXT0_GPIO_BASE, },
662 [1] = {
663 .gpio_base = ZEUS_EXT1_GPIO_BASE,
664 .setup = zeus_get_pcb_info,
665 },
666 [2] = { .gpio_base = ZEUS_USER_GPIO_BASE, },
667};
668
669static struct i2c_board_info __initdata zeus_i2c_devices[] = {
670 {
671 I2C_BOARD_INFO("pca9535", 0x21),
672 .platform_data = &zeus_pca953x_pdata[0],
673 },
674 {
675 I2C_BOARD_INFO("pca9535", 0x22),
676 .platform_data = &zeus_pca953x_pdata[1],
677 },
678 {
679 I2C_BOARD_INFO("pca9535", 0x20),
680 .platform_data = &zeus_pca953x_pdata[2],
681 .irq = gpio_to_irq(ZEUS_EXTGPIO_GPIO),
682 },
683 { I2C_BOARD_INFO("lm75a", 0x48) },
684 { I2C_BOARD_INFO("24c01", 0x50) },
685 { I2C_BOARD_INFO("isl1208", 0x6f) },
686};
687
688static mfp_cfg_t zeus_pin_config[] __initdata = {
689 GPIO15_nCS_1,
690 GPIO78_nCS_2,
691 GPIO80_nCS_4,
692 GPIO33_nCS_5,
693
694 GPIO22_GPIO,
695 GPIO32_MMC_CLK,
696 GPIO92_MMC_DAT_0,
697 GPIO109_MMC_DAT_1,
698 GPIO110_MMC_DAT_2,
699 GPIO111_MMC_DAT_3,
700 GPIO112_MMC_CMD,
701
702 GPIO88_USBH1_PWR,
703 GPIO89_USBH1_PEN,
704 GPIO119_USBH2_PWR,
705 GPIO120_USBH2_PEN,
706
707 GPIO86_LCD_LDD_16,
708 GPIO87_LCD_LDD_17,
709
710 GPIO102_GPIO,
711 GPIO104_CIF_DD_2,
712 GPIO105_CIF_DD_1,
713
714 GPIO48_nPOE,
715 GPIO49_nPWE,
716 GPIO50_nPIOR,
717 GPIO51_nPIOW,
718 GPIO85_nPCE_1,
719 GPIO54_nPCE_2,
720 GPIO79_PSKTSEL,
721 GPIO55_nPREG,
722 GPIO56_nPWAIT,
723 GPIO57_nIOIS16,
724 GPIO36_GPIO, /* CF CD */
725 GPIO97_GPIO, /* CF PWREN */
726 GPIO99_GPIO, /* CF RDY */
727};
728
729static void __init zeus_init(void)
730{
731 u16 dm9000_msc = 0xe279;
732
733 system_rev = __raw_readw(ZEUS_CPLD_VERSION);
734 pr_info("Zeus CPLD V%dI%d\n", (system_rev & 0xf0) >> 4, (system_rev & 0x0f));
735
736 /* Fix timings for dm9000s (CS1/CS2)*/
737 MSC0 = (MSC0 & 0xffff) | (dm9000_msc << 16);
738 MSC1 = (MSC1 & 0xffff0000) | dm9000_msc;
739
740 pm_power_off = zeus_power_off;
741
742 pxa2xx_mfp_config(ARRAY_AND_SIZE(zeus_pin_config));
743
744 platform_add_devices(zeus_devices, ARRAY_SIZE(zeus_devices));
745
746 pxa_set_ohci_info(&zeus_ohci_platform_data);
747
748 if (zeus_setup_fb_gpios())
749 pr_err("Failed to setup fb gpios\n");
750 else
751 set_pxa_fb_info(&zeus_fb_info);
752
753 pxa_set_mci_info(&zeus_mci_platform_data);
754 pxa_set_udc_info(&zeus_udc_info);
755 pxa_set_ac97_info(&zeus_ac97_info);
756 pxa_set_i2c_info(NULL);
757 i2c_register_board_info(0, ARRAY_AND_SIZE(zeus_i2c_devices));
758}
759
760static struct map_desc zeus_io_desc[] __initdata = {
761 {
762 .virtual = ZEUS_CPLD_VERSION,
763 .pfn = __phys_to_pfn(ZEUS_CPLD_VERSION_PHYS),
764 .length = 0x1000,
765 .type = MT_DEVICE,
766 },
767 {
768 .virtual = ZEUS_CPLD_ISA_IRQ,
769 .pfn = __phys_to_pfn(ZEUS_CPLD_ISA_IRQ_PHYS),
770 .length = 0x1000,
771 .type = MT_DEVICE,
772 },
773 {
774 .virtual = ZEUS_CPLD_CONTROL,
775 .pfn = __phys_to_pfn(ZEUS_CPLD_CONTROL_PHYS),
776 .length = 0x1000,
777 .type = MT_DEVICE,
778 },
779 {
780 .virtual = ZEUS_CPLD_EXTWDOG,
781 .pfn = __phys_to_pfn(ZEUS_CPLD_EXTWDOG_PHYS),
782 .length = 0x1000,
783 .type = MT_DEVICE,
784 },
785 {
786 .virtual = ZEUS_PC104IO,
787 .pfn = __phys_to_pfn(ZEUS_PC104IO_PHYS),
788 .length = 0x00800000,
789 .type = MT_DEVICE,
790 },
791};
792
793static void __init zeus_map_io(void)
794{
795 pxa_map_io();
796
797 iotable_init(zeus_io_desc, ARRAY_SIZE(zeus_io_desc));
798
799 /* Clear PSPR to ensure a full restart on wake-up. */
800 PMCR = PSPR = 0;
801
802 /* enable internal 32.768Khz oscillator (ignore OSCC_OOK) */
803 OSCC |= OSCC_OON;
804
805 /* Some clock cycles later (from OSCC_ON), programme PCFR (OPDE...).
806 * float chip selects and PCMCIA */
807 PCFR = PCFR_OPDE | PCFR_DC_EN | PCFR_FS | PCFR_FP;
808}
809
810MACHINE_START(ARCOM_ZEUS, "Arcom ZEUS")
811 /* Maintainer: Marc Zyngier <maz@misterjones.org> */
812 .phys_io = 0x40000000,
813 .io_pg_offst = ((io_p2v(0x40000000) >> 18) & 0xfffc),
814 .boot_params = 0xa0000100,
815 .map_io = zeus_map_io,
816 .init_irq = zeus_init_irq,
817 .timer = &pxa_timer,
818 .init_machine = zeus_init,
819MACHINE_END
820
diff --git a/arch/arm/mach-realview/Kconfig b/arch/arm/mach-realview/Kconfig
index c48e1f2c3349..ee5e392430e8 100644
--- a/arch/arm/mach-realview/Kconfig
+++ b/arch/arm/mach-realview/Kconfig
@@ -70,7 +70,7 @@ config MACH_REALVIEW_PBX
70 bool "Support RealView/PBX platform" 70 bool "Support RealView/PBX platform"
71 select ARM_GIC 71 select ARM_GIC
72 select HAVE_PATA_PLATFORM 72 select HAVE_PATA_PLATFORM
73 select ARCH_SPARSEMEM_ENABLE if CPU_V7 && !HIGH_PHYS_OFFSET 73 select ARCH_SPARSEMEM_ENABLE if CPU_V7 && !REALVIEW_HIGH_PHYS_OFFSET
74 select ZONE_DMA if SPARSEMEM 74 select ZONE_DMA if SPARSEMEM
75 help 75 help
76 Include support for the ARM(R) RealView PBX platform. 76 Include support for the ARM(R) RealView PBX platform.
diff --git a/arch/arm/mach-s3c24a0/include/mach/memory.h b/arch/arm/mach-s3c24a0/include/mach/memory.h
index 585211ca0187..7d74fd5c8d66 100644
--- a/arch/arm/mach-s3c24a0/include/mach/memory.h
+++ b/arch/arm/mach-s3c24a0/include/mach/memory.h
@@ -15,5 +15,7 @@
15 15
16#define __virt_to_bus(x) __virt_to_phys(x) 16#define __virt_to_bus(x) __virt_to_phys(x)
17#define __bus_to_virt(x) __phys_to_virt(x) 17#define __bus_to_virt(x) __phys_to_virt(x)
18#define __pfn_to_bus(x) __pfn_to_phys(x)
19#define __bus_to_pfn(x) __phys_to_pfn(x)
18 20
19#endif 21#endif
diff --git a/arch/arm/mach-sa1100/Kconfig b/arch/arm/mach-sa1100/Kconfig
index 03a7f3857c5e..b17d52f7cc48 100644
--- a/arch/arm/mach-sa1100/Kconfig
+++ b/arch/arm/mach-sa1100/Kconfig
@@ -4,6 +4,7 @@ menu "SA11x0 Implementations"
4 4
5config SA1100_ASSABET 5config SA1100_ASSABET
6 bool "Assabet" 6 bool "Assabet"
7 select CPU_FREQ_SA1110
7 help 8 help
8 Say Y here if you are using the Intel(R) StrongARM(R) SA-1110 9 Say Y here if you are using the Intel(R) StrongARM(R) SA-1110
9 Microprocessor Development Board (also known as the Assabet). 10 Microprocessor Development Board (also known as the Assabet).
@@ -19,6 +20,7 @@ config ASSABET_NEPONSET
19 20
20config SA1100_CERF 21config SA1100_CERF
21 bool "CerfBoard" 22 bool "CerfBoard"
23 select CPU_FREQ_SA1110
22 help 24 help
23 The Intrinsyc CerfBoard is based on the StrongARM 1110 (Discontinued). 25 The Intrinsyc CerfBoard is based on the StrongARM 1110 (Discontinued).
24 More information is available at: 26 More information is available at:
@@ -45,6 +47,7 @@ endchoice
45 47
46config SA1100_COLLIE 48config SA1100_COLLIE
47 bool "Sharp Zaurus SL5500" 49 bool "Sharp Zaurus SL5500"
50 # FIXME: select CPU_FREQ_SA11x0
48 select SHARP_LOCOMO 51 select SHARP_LOCOMO
49 select SHARP_SCOOP 52 select SHARP_SCOOP
50 select SHARP_PARAM 53 select SHARP_PARAM
@@ -54,6 +57,7 @@ config SA1100_COLLIE
54config SA1100_H3100 57config SA1100_H3100
55 bool "Compaq iPAQ H3100" 58 bool "Compaq iPAQ H3100"
56 select HTC_EGPIO 59 select HTC_EGPIO
60 select CPU_FREQ_SA1100
57 help 61 help
58 Say Y here if you intend to run this kernel on the Compaq iPAQ 62 Say Y here if you intend to run this kernel on the Compaq iPAQ
59 H3100 handheld computer. Information about this machine and the 63 H3100 handheld computer. Information about this machine and the
@@ -64,6 +68,7 @@ config SA1100_H3100
64config SA1100_H3600 68config SA1100_H3600
65 bool "Compaq iPAQ H3600/H3700" 69 bool "Compaq iPAQ H3600/H3700"
66 select HTC_EGPIO 70 select HTC_EGPIO
71 select CPU_FREQ_SA1100
67 help 72 help
68 Say Y here if you intend to run this kernel on the Compaq iPAQ 73 Say Y here if you intend to run this kernel on the Compaq iPAQ
69 H3600 handheld computer. Information about this machine and the 74 H3600 handheld computer. Information about this machine and the
@@ -74,6 +79,7 @@ config SA1100_H3600
74config SA1100_BADGE4 79config SA1100_BADGE4
75 bool "HP Labs BadgePAD 4" 80 bool "HP Labs BadgePAD 4"
76 select SA1111 81 select SA1111
82 select CPU_FREQ_SA1100
77 help 83 help
78 Say Y here if you want to build a kernel for the HP Laboratories 84 Say Y here if you want to build a kernel for the HP Laboratories
79 BadgePAD 4. 85 BadgePAD 4.
@@ -81,6 +87,7 @@ config SA1100_BADGE4
81config SA1100_JORNADA720 87config SA1100_JORNADA720
82 bool "HP Jornada 720" 88 bool "HP Jornada 720"
83 select SA1111 89 select SA1111
90 # FIXME: select CPU_FREQ_SA11x0
84 help 91 help
85 Say Y here if you want to build a kernel for the HP Jornada 720 92 Say Y here if you want to build a kernel for the HP Jornada 720
86 handheld computer. See <http://www.hp.com/jornada/products/720> 93 handheld computer. See <http://www.hp.com/jornada/products/720>
@@ -98,12 +105,14 @@ config SA1100_JORNADA720_SSP
98 105
99config SA1100_HACKKIT 106config SA1100_HACKKIT
100 bool "HackKit Core CPU Board" 107 bool "HackKit Core CPU Board"
108 select CPU_FREQ_SA1100
101 help 109 help
102 Say Y here to support the HackKit Core CPU Board 110 Say Y here to support the HackKit Core CPU Board
103 <http://hackkit.eletztrick.de>; 111 <http://hackkit.eletztrick.de>;
104 112
105config SA1100_LART 113config SA1100_LART
106 bool "LART" 114 bool "LART"
115 select CPU_FREQ_SA1100
107 help 116 help
108 Say Y here if you are using the Linux Advanced Radio Terminal 117 Say Y here if you are using the Linux Advanced Radio Terminal
109 (also known as the LART). See <http://www.lartmaker.nl/> for 118 (also known as the LART). See <http://www.lartmaker.nl/> for
@@ -111,6 +120,7 @@ config SA1100_LART
111 120
112config SA1100_PLEB 121config SA1100_PLEB
113 bool "PLEB" 122 bool "PLEB"
123 select CPU_FREQ_SA1100
114 help 124 help
115 Say Y here if you are using version 1 of the Portable Linux 125 Say Y here if you are using version 1 of the Portable Linux
116 Embedded Board (also known as PLEB). 126 Embedded Board (also known as PLEB).
@@ -119,6 +129,7 @@ config SA1100_PLEB
119 129
120config SA1100_SHANNON 130config SA1100_SHANNON
121 bool "Shannon" 131 bool "Shannon"
132 select CPU_FREQ_SA1100
122 help 133 help
123 The Shannon (also known as a Tuxscreen, and also as a IS2630) was a 134 The Shannon (also known as a Tuxscreen, and also as a IS2630) was a
124 limited edition webphone produced by Philips. The Shannon is a SA1100 135 limited edition webphone produced by Philips. The Shannon is a SA1100
@@ -127,6 +138,7 @@ config SA1100_SHANNON
127 138
128config SA1100_SIMPAD 139config SA1100_SIMPAD
129 bool "Simpad" 140 bool "Simpad"
141 select CPU_FREQ_SA1110
130 help 142 help
131 The SIEMENS webpad SIMpad is based on the StrongARM 1110. There 143 The SIEMENS webpad SIMpad is based on the StrongARM 1110. There
132 are two different versions CL4 and SL4. CL4 has 32MB RAM and 16MB 144 are two different versions CL4 and SL4. CL4 has 32MB RAM and 16MB
@@ -145,3 +157,4 @@ config SA1100_SSP
145endmenu 157endmenu
146 158
147endif 159endif
160
diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c
index 9faea1511c1f..3c1fcd696714 100644
--- a/arch/arm/mach-sa1100/generic.c
+++ b/arch/arm/mach-sa1100/generic.c
@@ -58,7 +58,6 @@ static const unsigned short cclk_frequency_100khz[NR_FREQS] = {
58 2802 /* 280.2 MHz */ 58 2802 /* 280.2 MHz */
59}; 59};
60 60
61#if defined(CONFIG_CPU_FREQ_SA1100) || defined(CONFIG_CPU_FREQ_SA1110)
62/* rounds up(!) */ 61/* rounds up(!) */
63unsigned int sa11x0_freq_to_ppcr(unsigned int khz) 62unsigned int sa11x0_freq_to_ppcr(unsigned int khz)
64{ 63{
@@ -110,17 +109,6 @@ unsigned int sa11x0_getspeed(unsigned int cpu)
110 return cclk_frequency_100khz[PPCR & 0xf] * 100; 109 return cclk_frequency_100khz[PPCR & 0xf] * 100;
111} 110}
112 111
113#else
114/*
115 * We still need to provide this so building without cpufreq works.
116 */
117unsigned int cpufreq_get(unsigned int cpu)
118{
119 return cclk_frequency_100khz[PPCR & 0xf] * 100;
120}
121EXPORT_SYMBOL(cpufreq_get);
122#endif
123
124/* 112/*
125 * This is the SA11x0 sched_clock implementation. This has 113 * This is the SA11x0 sched_clock implementation. This has
126 * a resolution of 271ns, and a maximum value of 32025597s (370 days). 114 * a resolution of 271ns, and a maximum value of 32025597s (370 days).
diff --git a/arch/arm/mach-w90x900/include/mach/nuc900_spi.h b/arch/arm/mach-w90x900/include/mach/nuc900_spi.h
new file mode 100644
index 000000000000..bd94819e314f
--- /dev/null
+++ b/arch/arm/mach-w90x900/include/mach/nuc900_spi.h
@@ -0,0 +1,35 @@
1/*
2 * arch/arm/mach-w90x900/include/mach/nuc900_spi.h
3 *
4 * Copyright (c) 2009 Nuvoton technology corporation.
5 *
6 * Wan ZongShun <mcuos.com@gmail.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation;version 2 of the License.
11 *
12 */
13
14#ifndef __ASM_ARCH_SPI_H
15#define __ASM_ARCH_SPI_H
16
17extern void mfp_set_groupg(struct device *dev);
18
19struct nuc900_spi_info {
20 unsigned int num_cs;
21 unsigned int lsb;
22 unsigned int txneg;
23 unsigned int rxneg;
24 unsigned int divider;
25 unsigned int sleep;
26 unsigned int txnum;
27 unsigned int txbitlen;
28 int bus_num;
29};
30
31struct nuc900_spi_chip {
32 unsigned char bits_per_word;
33};
34
35#endif /* __ASM_ARCH_SPI_H */
diff --git a/arch/arm/plat-omap/include/plat/irqs.h b/arch/arm/plat-omap/include/plat/irqs.h
index ce5dd2d1dc21..97d6c50c3dcb 100644
--- a/arch/arm/plat-omap/include/plat/irqs.h
+++ b/arch/arm/plat-omap/include/plat/irqs.h
@@ -472,8 +472,22 @@
472#endif 472#endif
473#define TWL4030_GPIO_IRQ_END (TWL4030_GPIO_IRQ_BASE + TWL4030_GPIO_NR_IRQS) 473#define TWL4030_GPIO_IRQ_END (TWL4030_GPIO_IRQ_BASE + TWL4030_GPIO_NR_IRQS)
474 474
475#define TWL6030_IRQ_BASE (OMAP_FPGA_IRQ_END)
476#ifdef CONFIG_TWL4030_CORE
477#define TWL6030_BASE_NR_IRQS 20
478#else
479#define TWL6030_BASE_NR_IRQS 0
480#endif
481#define TWL6030_IRQ_END (TWL6030_IRQ_BASE + TWL6030_BASE_NR_IRQS)
482
475/* Total number of interrupts depends on the enabled blocks above */ 483/* Total number of interrupts depends on the enabled blocks above */
476#define NR_IRQS TWL4030_GPIO_IRQ_END 484#if (TWL4030_GPIO_IRQ_END > TWL6030_IRQ_END)
485#define TWL_IRQ_END TWL4030_GPIO_IRQ_END
486#else
487#define TWL_IRQ_END TWL6030_IRQ_END
488#endif
489
490#define NR_IRQS TWL_IRQ_END
477 491
478#define OMAP_IRQ_BIT(irq) (1 << ((irq) % 32)) 492#define OMAP_IRQ_BIT(irq) (1 << ((irq) % 32))
479 493
diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
index 2d7423af1197..aed05bc3c2ea 100644
--- a/arch/arm/vfp/vfpmodule.c
+++ b/arch/arm/vfp/vfpmodule.c
@@ -38,16 +38,72 @@ union vfp_state *last_VFP_context[NR_CPUS];
38 */ 38 */
39unsigned int VFP_arch; 39unsigned int VFP_arch;
40 40
41/*
42 * Per-thread VFP initialization.
43 */
44static void vfp_thread_flush(struct thread_info *thread)
45{
46 union vfp_state *vfp = &thread->vfpstate;
47 unsigned int cpu;
48
49 memset(vfp, 0, sizeof(union vfp_state));
50
51 vfp->hard.fpexc = FPEXC_EN;
52 vfp->hard.fpscr = FPSCR_ROUND_NEAREST;
53
54 /*
55 * Disable VFP to ensure we initialize it first. We must ensure
56 * that the modification of last_VFP_context[] and hardware disable
57 * are done for the same CPU and without preemption.
58 */
59 cpu = get_cpu();
60 if (last_VFP_context[cpu] == vfp)
61 last_VFP_context[cpu] = NULL;
62 fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN);
63 put_cpu();
64}
65
66static void vfp_thread_release(struct thread_info *thread)
67{
68 /* release case: Per-thread VFP cleanup. */
69 union vfp_state *vfp = &thread->vfpstate;
70 unsigned int cpu = thread->cpu;
71
72 if (last_VFP_context[cpu] == vfp)
73 last_VFP_context[cpu] = NULL;
74}
75
76/*
77 * When this function is called with the following 'cmd's, the following
78 * is true while this function is being run:
79 * THREAD_NOFTIFY_SWTICH:
80 * - the previously running thread will not be scheduled onto another CPU.
81 * - the next thread to be run (v) will not be running on another CPU.
82 * - thread->cpu is the local CPU number
83 * - not preemptible as we're called in the middle of a thread switch
84 * THREAD_NOTIFY_FLUSH:
85 * - the thread (v) will be running on the local CPU, so
86 * v === current_thread_info()
87 * - thread->cpu is the local CPU number at the time it is accessed,
88 * but may change at any time.
89 * - we could be preempted if tree preempt rcu is enabled, so
90 * it is unsafe to use thread->cpu.
91 * THREAD_NOTIFY_RELEASE:
92 * - the thread (v) will not be running on any CPU; it is a dead thread.
93 * - thread->cpu will be the last CPU the thread ran on, which may not
94 * be the current CPU.
95 * - we could be preempted if tree preempt rcu is enabled.
96 */
41static int vfp_notifier(struct notifier_block *self, unsigned long cmd, void *v) 97static int vfp_notifier(struct notifier_block *self, unsigned long cmd, void *v)
42{ 98{
43 struct thread_info *thread = v; 99 struct thread_info *thread = v;
44 union vfp_state *vfp;
45 __u32 cpu = thread->cpu;
46 100
47 if (likely(cmd == THREAD_NOTIFY_SWITCH)) { 101 if (likely(cmd == THREAD_NOTIFY_SWITCH)) {
48 u32 fpexc = fmrx(FPEXC); 102 u32 fpexc = fmrx(FPEXC);
49 103
50#ifdef CONFIG_SMP 104#ifdef CONFIG_SMP
105 unsigned int cpu = thread->cpu;
106
51 /* 107 /*
52 * On SMP, if VFP is enabled, save the old state in 108 * On SMP, if VFP is enabled, save the old state in
53 * case the thread migrates to a different CPU. The 109 * case the thread migrates to a different CPU. The
@@ -74,25 +130,10 @@ static int vfp_notifier(struct notifier_block *self, unsigned long cmd, void *v)
74 return NOTIFY_DONE; 130 return NOTIFY_DONE;
75 } 131 }
76 132
77 vfp = &thread->vfpstate; 133 if (cmd == THREAD_NOTIFY_FLUSH)
78 if (cmd == THREAD_NOTIFY_FLUSH) { 134 vfp_thread_flush(thread);
79 /* 135 else
80 * Per-thread VFP initialisation. 136 vfp_thread_release(thread);
81 */
82 memset(vfp, 0, sizeof(union vfp_state));
83
84 vfp->hard.fpexc = FPEXC_EN;
85 vfp->hard.fpscr = FPSCR_ROUND_NEAREST;
86
87 /*
88 * Disable VFP to ensure we initialise it first.
89 */
90 fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN);
91 }
92
93 /* flush and release case: Per-thread VFP cleanup. */
94 if (last_VFP_context[cpu] == vfp)
95 last_VFP_context[cpu] = NULL;
96 137
97 return NOTIFY_DONE; 138 return NOTIFY_DONE;
98} 139}
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 1ee596cd942f..2d7f56a98e0f 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -87,9 +87,6 @@ config GENERIC_TIME_VSYSCALL
87 bool 87 bool
88 default y 88 default y
89 89
90config HAVE_LEGACY_PER_CPU_AREA
91 def_bool y
92
93config HAVE_SETUP_PER_CPU_AREA 90config HAVE_SETUP_PER_CPU_AREA
94 def_bool y 91 def_bool y
95 92
diff --git a/arch/ia64/include/asm/meminit.h b/arch/ia64/include/asm/meminit.h
index 688a812c017d..61c7b1750b16 100644
--- a/arch/ia64/include/asm/meminit.h
+++ b/arch/ia64/include/asm/meminit.h
@@ -61,7 +61,7 @@ extern int register_active_ranges(u64 start, u64 len, int nid);
61 61
62#ifdef CONFIG_VIRTUAL_MEM_MAP 62#ifdef CONFIG_VIRTUAL_MEM_MAP
63# define LARGE_GAP 0x40000000 /* Use virtual mem map if hole is > than this */ 63# define LARGE_GAP 0x40000000 /* Use virtual mem map if hole is > than this */
64 extern unsigned long vmalloc_end; 64 extern unsigned long VMALLOC_END;
65 extern struct page *vmem_map; 65 extern struct page *vmem_map;
66 extern int find_largest_hole(u64 start, u64 end, void *arg); 66 extern int find_largest_hole(u64 start, u64 end, void *arg);
67 extern int create_mem_map_page_table(u64 start, u64 end, void *arg); 67 extern int create_mem_map_page_table(u64 start, u64 end, void *arg);
diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
index 8840a690d1e7..69bf13857a9f 100644
--- a/arch/ia64/include/asm/pgtable.h
+++ b/arch/ia64/include/asm/pgtable.h
@@ -228,8 +228,7 @@ ia64_phys_addr_valid (unsigned long addr)
228#define VMALLOC_START (RGN_BASE(RGN_GATE) + 0x200000000UL) 228#define VMALLOC_START (RGN_BASE(RGN_GATE) + 0x200000000UL)
229#ifdef CONFIG_VIRTUAL_MEM_MAP 229#ifdef CONFIG_VIRTUAL_MEM_MAP
230# define VMALLOC_END_INIT (RGN_BASE(RGN_GATE) + (1UL << (4*PAGE_SHIFT - 9))) 230# define VMALLOC_END_INIT (RGN_BASE(RGN_GATE) + (1UL << (4*PAGE_SHIFT - 9)))
231# define VMALLOC_END vmalloc_end 231extern unsigned long VMALLOC_END;
232 extern unsigned long vmalloc_end;
233#else 232#else
234#if defined(CONFIG_SPARSEMEM) && defined(CONFIG_SPARSEMEM_VMEMMAP) 233#if defined(CONFIG_SPARSEMEM) && defined(CONFIG_SPARSEMEM_VMEMMAP)
235/* SPARSEMEM_VMEMMAP uses half of vmalloc... */ 234/* SPARSEMEM_VMEMMAP uses half of vmalloc... */
diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h
index 3eaeedf1aef2..7fa90f73f6be 100644
--- a/arch/ia64/include/asm/processor.h
+++ b/arch/ia64/include/asm/processor.h
@@ -229,7 +229,7 @@ struct cpuinfo_ia64 {
229#endif 229#endif
230}; 230};
231 231
232DECLARE_PER_CPU(struct cpuinfo_ia64, cpu_info); 232DECLARE_PER_CPU(struct cpuinfo_ia64, ia64_cpu_info);
233 233
234/* 234/*
235 * The "local" data variable. It refers to the per-CPU data of the currently executing 235 * The "local" data variable. It refers to the per-CPU data of the currently executing
@@ -237,8 +237,8 @@ DECLARE_PER_CPU(struct cpuinfo_ia64, cpu_info);
237 * Do not use the address of local_cpu_data, since it will be different from 237 * Do not use the address of local_cpu_data, since it will be different from
238 * cpu_data(smp_processor_id())! 238 * cpu_data(smp_processor_id())!
239 */ 239 */
240#define local_cpu_data (&__ia64_per_cpu_var(cpu_info)) 240#define local_cpu_data (&__ia64_per_cpu_var(ia64_cpu_info))
241#define cpu_data(cpu) (&per_cpu(cpu_info, cpu)) 241#define cpu_data(cpu) (&per_cpu(ia64_cpu_info, cpu))
242 242
243extern void print_cpu_info (struct cpuinfo_ia64 *); 243extern void print_cpu_info (struct cpuinfo_ia64 *);
244 244
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index baec6f00f7f3..40574ae11401 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -702,11 +702,23 @@ int __init early_acpi_boot_init(void)
702 printk(KERN_ERR PREFIX 702 printk(KERN_ERR PREFIX
703 "Error parsing MADT - no LAPIC entries\n"); 703 "Error parsing MADT - no LAPIC entries\n");
704 704
705#ifdef CONFIG_SMP
706 if (available_cpus == 0) {
707 printk(KERN_INFO "ACPI: Found 0 CPUS; assuming 1\n");
708 printk(KERN_INFO "CPU 0 (0x%04x)", hard_smp_processor_id());
709 smp_boot_data.cpu_phys_id[available_cpus] =
710 hard_smp_processor_id();
711 available_cpus = 1; /* We've got at least one of these, no? */
712 }
713 smp_boot_data.cpu_count = available_cpus;
714#endif
715 /* Make boot-up look pretty */
716 printk(KERN_INFO "%d CPUs available, %d CPUs total\n", available_cpus,
717 total_cpus);
718
705 return 0; 719 return 0;
706} 720}
707 721
708
709
710int __init acpi_boot_init(void) 722int __init acpi_boot_init(void)
711{ 723{
712 724
@@ -769,18 +781,8 @@ int __init acpi_boot_init(void)
769 if (acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt)) 781 if (acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt))
770 printk(KERN_ERR PREFIX "Can't find FADT\n"); 782 printk(KERN_ERR PREFIX "Can't find FADT\n");
771 783
784#ifdef CONFIG_ACPI_NUMA
772#ifdef CONFIG_SMP 785#ifdef CONFIG_SMP
773 if (available_cpus == 0) {
774 printk(KERN_INFO "ACPI: Found 0 CPUS; assuming 1\n");
775 printk(KERN_INFO "CPU 0 (0x%04x)", hard_smp_processor_id());
776 smp_boot_data.cpu_phys_id[available_cpus] =
777 hard_smp_processor_id();
778 available_cpus = 1; /* We've got at least one of these, no? */
779 }
780 smp_boot_data.cpu_count = available_cpus;
781
782 smp_build_cpu_map();
783# ifdef CONFIG_ACPI_NUMA
784 if (srat_num_cpus == 0) { 786 if (srat_num_cpus == 0) {
785 int cpu, i = 1; 787 int cpu, i = 1;
786 for (cpu = 0; cpu < smp_boot_data.cpu_count; cpu++) 788 for (cpu = 0; cpu < smp_boot_data.cpu_count; cpu++)
@@ -789,14 +791,9 @@ int __init acpi_boot_init(void)
789 node_cpuid[i++].phys_id = 791 node_cpuid[i++].phys_id =
790 smp_boot_data.cpu_phys_id[cpu]; 792 smp_boot_data.cpu_phys_id[cpu];
791 } 793 }
792# endif
793#endif 794#endif
794#ifdef CONFIG_ACPI_NUMA
795 build_cpu_to_node_map(); 795 build_cpu_to_node_map();
796#endif 796#endif
797 /* Make boot-up look pretty */
798 printk(KERN_INFO "%d CPUs available, %d CPUs total\n", available_cpus,
799 total_cpus);
800 return 0; 797 return 0;
801} 798}
802 799
diff --git a/arch/ia64/kernel/head.S b/arch/ia64/kernel/head.S
index 696eff28a0c4..17a9fba38930 100644
--- a/arch/ia64/kernel/head.S
+++ b/arch/ia64/kernel/head.S
@@ -1051,7 +1051,7 @@ END(ia64_delay_loop)
1051 * intermediate precision so that we can produce a full 64-bit result. 1051 * intermediate precision so that we can produce a full 64-bit result.
1052 */ 1052 */
1053GLOBAL_ENTRY(ia64_native_sched_clock) 1053GLOBAL_ENTRY(ia64_native_sched_clock)
1054 addl r8=THIS_CPU(cpu_info) + IA64_CPUINFO_NSEC_PER_CYC_OFFSET,r0 1054 addl r8=THIS_CPU(ia64_cpu_info) + IA64_CPUINFO_NSEC_PER_CYC_OFFSET,r0
1055 mov.m r9=ar.itc // fetch cycle-counter (35 cyc) 1055 mov.m r9=ar.itc // fetch cycle-counter (35 cyc)
1056 ;; 1056 ;;
1057 ldf8 f8=[r8] 1057 ldf8 f8=[r8]
@@ -1077,7 +1077,7 @@ sched_clock = ia64_native_sched_clock
1077#ifdef CONFIG_VIRT_CPU_ACCOUNTING 1077#ifdef CONFIG_VIRT_CPU_ACCOUNTING
1078GLOBAL_ENTRY(cycle_to_cputime) 1078GLOBAL_ENTRY(cycle_to_cputime)
1079 alloc r16=ar.pfs,1,0,0,0 1079 alloc r16=ar.pfs,1,0,0,0
1080 addl r8=THIS_CPU(cpu_info) + IA64_CPUINFO_NSEC_PER_CYC_OFFSET,r0 1080 addl r8=THIS_CPU(ia64_cpu_info) + IA64_CPUINFO_NSEC_PER_CYC_OFFSET,r0
1081 ;; 1081 ;;
1082 ldf8 f8=[r8] 1082 ldf8 f8=[r8]
1083 ;; 1083 ;;
diff --git a/arch/ia64/kernel/ia64_ksyms.c b/arch/ia64/kernel/ia64_ksyms.c
index 14d39e300627..461b99902bf6 100644
--- a/arch/ia64/kernel/ia64_ksyms.c
+++ b/arch/ia64/kernel/ia64_ksyms.c
@@ -30,7 +30,7 @@ EXPORT_SYMBOL(max_low_pfn); /* defined by bootmem.c, but not exported by generic
30#endif 30#endif
31 31
32#include <asm/processor.h> 32#include <asm/processor.h>
33EXPORT_SYMBOL(per_cpu__cpu_info); 33EXPORT_SYMBOL(per_cpu__ia64_cpu_info);
34#ifdef CONFIG_SMP 34#ifdef CONFIG_SMP
35EXPORT_SYMBOL(per_cpu__local_per_cpu_offset); 35EXPORT_SYMBOL(per_cpu__local_per_cpu_offset);
36#endif 36#endif
diff --git a/arch/ia64/kernel/mca_asm.S b/arch/ia64/kernel/mca_asm.S
index 7461d2573d41..d5bdf9de36b6 100644
--- a/arch/ia64/kernel/mca_asm.S
+++ b/arch/ia64/kernel/mca_asm.S
@@ -59,7 +59,7 @@
59ia64_do_tlb_purge: 59ia64_do_tlb_purge:
60#define O(member) IA64_CPUINFO_##member##_OFFSET 60#define O(member) IA64_CPUINFO_##member##_OFFSET
61 61
62 GET_THIS_PADDR(r2, cpu_info) // load phys addr of cpu_info into r2 62 GET_THIS_PADDR(r2, ia64_cpu_info) // load phys addr of cpu_info into r2
63 ;; 63 ;;
64 addl r17=O(PTCE_STRIDE),r2 64 addl r17=O(PTCE_STRIDE),r2
65 addl r2=O(PTCE_BASE),r2 65 addl r2=O(PTCE_BASE),r2
diff --git a/arch/ia64/kernel/relocate_kernel.S b/arch/ia64/kernel/relocate_kernel.S
index 32f6fc131fbe..c370e02f0061 100644
--- a/arch/ia64/kernel/relocate_kernel.S
+++ b/arch/ia64/kernel/relocate_kernel.S
@@ -61,7 +61,7 @@ GLOBAL_ENTRY(relocate_new_kernel)
61 61
62 // purge all TC entries 62 // purge all TC entries
63#define O(member) IA64_CPUINFO_##member##_OFFSET 63#define O(member) IA64_CPUINFO_##member##_OFFSET
64 GET_THIS_PADDR(r2, cpu_info) // load phys addr of cpu_info into r2 64 GET_THIS_PADDR(r2, ia64_cpu_info) // load phys addr of cpu_info into r2
65 ;; 65 ;;
66 addl r17=O(PTCE_STRIDE),r2 66 addl r17=O(PTCE_STRIDE),r2
67 addl r2=O(PTCE_BASE),r2 67 addl r2=O(PTCE_BASE),r2
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index 1de86c96801d..a1ea87919777 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -74,7 +74,7 @@ unsigned long __per_cpu_offset[NR_CPUS];
74EXPORT_SYMBOL(__per_cpu_offset); 74EXPORT_SYMBOL(__per_cpu_offset);
75#endif 75#endif
76 76
77DEFINE_PER_CPU(struct cpuinfo_ia64, cpu_info); 77DEFINE_PER_CPU(struct cpuinfo_ia64, ia64_cpu_info);
78DEFINE_PER_CPU(unsigned long, local_per_cpu_offset); 78DEFINE_PER_CPU(unsigned long, local_per_cpu_offset);
79unsigned long ia64_cycles_per_usec; 79unsigned long ia64_cycles_per_usec;
80struct ia64_boot_param *ia64_boot_param; 80struct ia64_boot_param *ia64_boot_param;
@@ -566,19 +566,18 @@ setup_arch (char **cmdline_p)
566 early_acpi_boot_init(); 566 early_acpi_boot_init();
567# ifdef CONFIG_ACPI_NUMA 567# ifdef CONFIG_ACPI_NUMA
568 acpi_numa_init(); 568 acpi_numa_init();
569#ifdef CONFIG_ACPI_HOTPLUG_CPU 569# ifdef CONFIG_ACPI_HOTPLUG_CPU
570 prefill_possible_map(); 570 prefill_possible_map();
571#endif 571# endif
572 per_cpu_scan_finalize((cpus_weight(early_cpu_possible_map) == 0 ? 572 per_cpu_scan_finalize((cpus_weight(early_cpu_possible_map) == 0 ?
573 32 : cpus_weight(early_cpu_possible_map)), 573 32 : cpus_weight(early_cpu_possible_map)),
574 additional_cpus > 0 ? additional_cpus : 0); 574 additional_cpus > 0 ? additional_cpus : 0);
575# endif 575# endif
576#else
577# ifdef CONFIG_SMP
578 smp_build_cpu_map(); /* happens, e.g., with the Ski simulator */
579# endif
580#endif /* CONFIG_APCI_BOOT */ 576#endif /* CONFIG_APCI_BOOT */
581 577
578#ifdef CONFIG_SMP
579 smp_build_cpu_map();
580#endif
582 find_memory(); 581 find_memory();
583 582
584 /* process SAL system table: */ 583 /* process SAL system table: */
@@ -856,18 +855,6 @@ identify_cpu (struct cpuinfo_ia64 *c)
856} 855}
857 856
858/* 857/*
859 * In UP configuration, setup_per_cpu_areas() is defined in
860 * include/linux/percpu.h
861 */
862#ifdef CONFIG_SMP
863void __init
864setup_per_cpu_areas (void)
865{
866 /* start_kernel() requires this... */
867}
868#endif
869
870/*
871 * Do the following calculations: 858 * Do the following calculations:
872 * 859 *
873 * 1. the max. cache line size. 860 * 1. the max. cache line size.
@@ -980,7 +967,7 @@ cpu_init (void)
980 * depends on the data returned by identify_cpu(). We break the dependency by 967 * depends on the data returned by identify_cpu(). We break the dependency by
981 * accessing cpu_data() through the canonical per-CPU address. 968 * accessing cpu_data() through the canonical per-CPU address.
982 */ 969 */
983 cpu_info = cpu_data + ((char *) &__ia64_per_cpu_var(cpu_info) - __per_cpu_start); 970 cpu_info = cpu_data + ((char *) &__ia64_per_cpu_var(ia64_cpu_info) - __per_cpu_start);
984 identify_cpu(cpu_info); 971 identify_cpu(cpu_info);
985 972
986#ifdef CONFIG_MCKINLEY 973#ifdef CONFIG_MCKINLEY
diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
index 0a0c77b2c988..1295ba327f6f 100644
--- a/arch/ia64/kernel/vmlinux.lds.S
+++ b/arch/ia64/kernel/vmlinux.lds.S
@@ -166,6 +166,12 @@ SECTIONS
166 } 166 }
167#endif 167#endif
168 168
169#ifdef CONFIG_SMP
170 . = ALIGN(PERCPU_PAGE_SIZE);
171 __cpu0_per_cpu = .;
172 . = . + PERCPU_PAGE_SIZE; /* cpu0 per-cpu space */
173#endif
174
169 . = ALIGN(PAGE_SIZE); 175 . = ALIGN(PAGE_SIZE);
170 __init_end = .; 176 __init_end = .;
171 177
@@ -198,11 +204,6 @@ SECTIONS
198 data : { } :data 204 data : { } :data
199 .data : AT(ADDR(.data) - LOAD_OFFSET) 205 .data : AT(ADDR(.data) - LOAD_OFFSET)
200 { 206 {
201#ifdef CONFIG_SMP
202 . = ALIGN(PERCPU_PAGE_SIZE);
203 __cpu0_per_cpu = .;
204 . = . + PERCPU_PAGE_SIZE; /* cpu0 per-cpu space */
205#endif
206 INIT_TASK_DATA(PAGE_SIZE) 207 INIT_TASK_DATA(PAGE_SIZE)
207 CACHELINE_ALIGNED_DATA(SMP_CACHE_BYTES) 208 CACHELINE_ALIGNED_DATA(SMP_CACHE_BYTES)
208 READ_MOSTLY_DATA(SMP_CACHE_BYTES) 209 READ_MOSTLY_DATA(SMP_CACHE_BYTES)
diff --git a/arch/ia64/mm/contig.c b/arch/ia64/mm/contig.c
index 2f724d2bf299..54bf54059811 100644
--- a/arch/ia64/mm/contig.c
+++ b/arch/ia64/mm/contig.c
@@ -154,38 +154,99 @@ static void *cpu_data;
154void * __cpuinit 154void * __cpuinit
155per_cpu_init (void) 155per_cpu_init (void)
156{ 156{
157 int cpu; 157 static bool first_time = true;
158 static int first_time=1; 158 void *cpu0_data = __cpu0_per_cpu;
159 unsigned int cpu;
160
161 if (!first_time)
162 goto skip;
163 first_time = false;
159 164
160 /* 165 /*
161 * get_free_pages() cannot be used before cpu_init() done. BSP 166 * get_free_pages() cannot be used before cpu_init() done.
162 * allocates "NR_CPUS" pages for all CPUs to avoid that AP calls 167 * BSP allocates PERCPU_PAGE_SIZE bytes for all possible CPUs
163 * get_zeroed_page(). 168 * to avoid that AP calls get_zeroed_page().
164 */ 169 */
165 if (first_time) { 170 for_each_possible_cpu(cpu) {
166 void *cpu0_data = __cpu0_per_cpu; 171 void *src = cpu == 0 ? cpu0_data : __phys_per_cpu_start;
167 172
168 first_time=0; 173 memcpy(cpu_data, src, __per_cpu_end - __per_cpu_start);
174 __per_cpu_offset[cpu] = (char *)cpu_data - __per_cpu_start;
175 per_cpu(local_per_cpu_offset, cpu) = __per_cpu_offset[cpu];
169 176
170 __per_cpu_offset[0] = (char *) cpu0_data - __per_cpu_start; 177 /*
171 per_cpu(local_per_cpu_offset, 0) = __per_cpu_offset[0]; 178 * percpu area for cpu0 is moved from the __init area
179 * which is setup by head.S and used till this point.
180 * Update ar.k3. This move is ensures that percpu
181 * area for cpu0 is on the correct node and its
182 * virtual address isn't insanely far from other
183 * percpu areas which is important for congruent
184 * percpu allocator.
185 */
186 if (cpu == 0)
187 ia64_set_kr(IA64_KR_PER_CPU_DATA, __pa(cpu_data) -
188 (unsigned long)__per_cpu_start);
172 189
173 for (cpu = 1; cpu < NR_CPUS; cpu++) { 190 cpu_data += PERCPU_PAGE_SIZE;
174 memcpy(cpu_data, __phys_per_cpu_start, __per_cpu_end - __per_cpu_start);
175 __per_cpu_offset[cpu] = (char *) cpu_data - __per_cpu_start;
176 cpu_data += PERCPU_PAGE_SIZE;
177 per_cpu(local_per_cpu_offset, cpu) = __per_cpu_offset[cpu];
178 }
179 } 191 }
192skip:
180 return __per_cpu_start + __per_cpu_offset[smp_processor_id()]; 193 return __per_cpu_start + __per_cpu_offset[smp_processor_id()];
181} 194}
182 195
183static inline void 196static inline void
184alloc_per_cpu_data(void) 197alloc_per_cpu_data(void)
185{ 198{
186 cpu_data = __alloc_bootmem(PERCPU_PAGE_SIZE * NR_CPUS-1, 199 cpu_data = __alloc_bootmem(PERCPU_PAGE_SIZE * num_possible_cpus(),
187 PERCPU_PAGE_SIZE, __pa(MAX_DMA_ADDRESS)); 200 PERCPU_PAGE_SIZE, __pa(MAX_DMA_ADDRESS));
188} 201}
202
203/**
204 * setup_per_cpu_areas - setup percpu areas
205 *
206 * Arch code has already allocated and initialized percpu areas. All
207 * this function has to do is to teach the determined layout to the
208 * dynamic percpu allocator, which happens to be more complex than
209 * creating whole new ones using helpers.
210 */
211void __init
212setup_per_cpu_areas(void)
213{
214 struct pcpu_alloc_info *ai;
215 struct pcpu_group_info *gi;
216 unsigned int cpu;
217 ssize_t static_size, reserved_size, dyn_size;
218 int rc;
219
220 ai = pcpu_alloc_alloc_info(1, num_possible_cpus());
221 if (!ai)
222 panic("failed to allocate pcpu_alloc_info");
223 gi = &ai->groups[0];
224
225 /* units are assigned consecutively to possible cpus */
226 for_each_possible_cpu(cpu)
227 gi->cpu_map[gi->nr_units++] = cpu;
228
229 /* set parameters */
230 static_size = __per_cpu_end - __per_cpu_start;
231 reserved_size = PERCPU_MODULE_RESERVE;
232 dyn_size = PERCPU_PAGE_SIZE - static_size - reserved_size;
233 if (dyn_size < 0)
234 panic("percpu area overflow static=%zd reserved=%zd\n",
235 static_size, reserved_size);
236
237 ai->static_size = static_size;
238 ai->reserved_size = reserved_size;
239 ai->dyn_size = dyn_size;
240 ai->unit_size = PERCPU_PAGE_SIZE;
241 ai->atom_size = PAGE_SIZE;
242 ai->alloc_size = PERCPU_PAGE_SIZE;
243
244 rc = pcpu_setup_first_chunk(ai, __per_cpu_start + __per_cpu_offset[0]);
245 if (rc)
246 panic("failed to setup percpu area (err=%d)", rc);
247
248 pcpu_free_alloc_info(ai);
249}
189#else 250#else
190#define alloc_per_cpu_data() do { } while (0) 251#define alloc_per_cpu_data() do { } while (0)
191#endif /* CONFIG_SMP */ 252#endif /* CONFIG_SMP */
@@ -270,8 +331,8 @@ paging_init (void)
270 331
271 map_size = PAGE_ALIGN(ALIGN(max_low_pfn, MAX_ORDER_NR_PAGES) * 332 map_size = PAGE_ALIGN(ALIGN(max_low_pfn, MAX_ORDER_NR_PAGES) *
272 sizeof(struct page)); 333 sizeof(struct page));
273 vmalloc_end -= map_size; 334 VMALLOC_END -= map_size;
274 vmem_map = (struct page *) vmalloc_end; 335 vmem_map = (struct page *) VMALLOC_END;
275 efi_memmap_walk(create_mem_map_page_table, NULL); 336 efi_memmap_walk(create_mem_map_page_table, NULL);
276 337
277 /* 338 /*
diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index d85ba98d9008..19c4b2195dce 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -143,22 +143,120 @@ static void *per_cpu_node_setup(void *cpu_data, int node)
143 int cpu; 143 int cpu;
144 144
145 for_each_possible_early_cpu(cpu) { 145 for_each_possible_early_cpu(cpu) {
146 if (cpu == 0) { 146 void *src = cpu == 0 ? __cpu0_per_cpu : __phys_per_cpu_start;
147 void *cpu0_data = __cpu0_per_cpu; 147
148 __per_cpu_offset[cpu] = (char*)cpu0_data - 148 if (node != node_cpuid[cpu].nid)
149 __per_cpu_start; 149 continue;
150 } else if (node == node_cpuid[cpu].nid) { 150
151 memcpy(__va(cpu_data), __phys_per_cpu_start, 151 memcpy(__va(cpu_data), src, __per_cpu_end - __per_cpu_start);
152 __per_cpu_end - __per_cpu_start); 152 __per_cpu_offset[cpu] = (char *)__va(cpu_data) -
153 __per_cpu_offset[cpu] = (char*)__va(cpu_data) - 153 __per_cpu_start;
154 __per_cpu_start; 154
155 cpu_data += PERCPU_PAGE_SIZE; 155 /*
156 } 156 * percpu area for cpu0 is moved from the __init area
157 * which is setup by head.S and used till this point.
158 * Update ar.k3. This move is ensures that percpu
159 * area for cpu0 is on the correct node and its
160 * virtual address isn't insanely far from other
161 * percpu areas which is important for congruent
162 * percpu allocator.
163 */
164 if (cpu == 0)
165 ia64_set_kr(IA64_KR_PER_CPU_DATA,
166 (unsigned long)cpu_data -
167 (unsigned long)__per_cpu_start);
168
169 cpu_data += PERCPU_PAGE_SIZE;
157 } 170 }
158#endif 171#endif
159 return cpu_data; 172 return cpu_data;
160} 173}
161 174
175#ifdef CONFIG_SMP
176/**
177 * setup_per_cpu_areas - setup percpu areas
178 *
179 * Arch code has already allocated and initialized percpu areas. All
180 * this function has to do is to teach the determined layout to the
181 * dynamic percpu allocator, which happens to be more complex than
182 * creating whole new ones using helpers.
183 */
184void __init setup_per_cpu_areas(void)
185{
186 struct pcpu_alloc_info *ai;
187 struct pcpu_group_info *uninitialized_var(gi);
188 unsigned int *cpu_map;
189 void *base;
190 unsigned long base_offset;
191 unsigned int cpu;
192 ssize_t static_size, reserved_size, dyn_size;
193 int node, prev_node, unit, nr_units, rc;
194
195 ai = pcpu_alloc_alloc_info(MAX_NUMNODES, nr_cpu_ids);
196 if (!ai)
197 panic("failed to allocate pcpu_alloc_info");
198 cpu_map = ai->groups[0].cpu_map;
199
200 /* determine base */
201 base = (void *)ULONG_MAX;
202 for_each_possible_cpu(cpu)
203 base = min(base,
204 (void *)(__per_cpu_offset[cpu] + __per_cpu_start));
205 base_offset = (void *)__per_cpu_start - base;
206
207 /* build cpu_map, units are grouped by node */
208 unit = 0;
209 for_each_node(node)
210 for_each_possible_cpu(cpu)
211 if (node == node_cpuid[cpu].nid)
212 cpu_map[unit++] = cpu;
213 nr_units = unit;
214
215 /* set basic parameters */
216 static_size = __per_cpu_end - __per_cpu_start;
217 reserved_size = PERCPU_MODULE_RESERVE;
218 dyn_size = PERCPU_PAGE_SIZE - static_size - reserved_size;
219 if (dyn_size < 0)
220 panic("percpu area overflow static=%zd reserved=%zd\n",
221 static_size, reserved_size);
222
223 ai->static_size = static_size;
224 ai->reserved_size = reserved_size;
225 ai->dyn_size = dyn_size;
226 ai->unit_size = PERCPU_PAGE_SIZE;
227 ai->atom_size = PAGE_SIZE;
228 ai->alloc_size = PERCPU_PAGE_SIZE;
229
230 /*
231 * CPUs are put into groups according to node. Walk cpu_map
232 * and create new groups at node boundaries.
233 */
234 prev_node = -1;
235 ai->nr_groups = 0;
236 for (unit = 0; unit < nr_units; unit++) {
237 cpu = cpu_map[unit];
238 node = node_cpuid[cpu].nid;
239
240 if (node == prev_node) {
241 gi->nr_units++;
242 continue;
243 }
244 prev_node = node;
245
246 gi = &ai->groups[ai->nr_groups++];
247 gi->nr_units = 1;
248 gi->base_offset = __per_cpu_offset[cpu] + base_offset;
249 gi->cpu_map = &cpu_map[unit];
250 }
251
252 rc = pcpu_setup_first_chunk(ai, base);
253 if (rc)
254 panic("failed to setup percpu area (err=%d)", rc);
255
256 pcpu_free_alloc_info(ai);
257}
258#endif
259
162/** 260/**
163 * fill_pernode - initialize pernode data. 261 * fill_pernode - initialize pernode data.
164 * @node: the node id. 262 * @node: the node id.
@@ -352,7 +450,8 @@ static void __init initialize_pernode_data(void)
352 /* Set the node_data pointer for each per-cpu struct */ 450 /* Set the node_data pointer for each per-cpu struct */
353 for_each_possible_early_cpu(cpu) { 451 for_each_possible_early_cpu(cpu) {
354 node = node_cpuid[cpu].nid; 452 node = node_cpuid[cpu].nid;
355 per_cpu(cpu_info, cpu).node_data = mem_data[node].node_data; 453 per_cpu(ia64_cpu_info, cpu).node_data =
454 mem_data[node].node_data;
356 } 455 }
357#else 456#else
358 { 457 {
@@ -360,7 +459,7 @@ static void __init initialize_pernode_data(void)
360 cpu = 0; 459 cpu = 0;
361 node = node_cpuid[cpu].nid; 460 node = node_cpuid[cpu].nid;
362 cpu0_cpu_info = (struct cpuinfo_ia64 *)(__phys_per_cpu_start + 461 cpu0_cpu_info = (struct cpuinfo_ia64 *)(__phys_per_cpu_start +
363 ((char *)&per_cpu__cpu_info - __per_cpu_start)); 462 ((char *)&per_cpu__ia64_cpu_info - __per_cpu_start));
364 cpu0_cpu_info->node_data = mem_data[node].node_data; 463 cpu0_cpu_info->node_data = mem_data[node].node_data;
365 } 464 }
366#endif /* CONFIG_SMP */ 465#endif /* CONFIG_SMP */
@@ -666,9 +765,9 @@ void __init paging_init(void)
666 sparse_init(); 765 sparse_init();
667 766
668#ifdef CONFIG_VIRTUAL_MEM_MAP 767#ifdef CONFIG_VIRTUAL_MEM_MAP
669 vmalloc_end -= PAGE_ALIGN(ALIGN(max_low_pfn, MAX_ORDER_NR_PAGES) * 768 VMALLOC_END -= PAGE_ALIGN(ALIGN(max_low_pfn, MAX_ORDER_NR_PAGES) *
670 sizeof(struct page)); 769 sizeof(struct page));
671 vmem_map = (struct page *) vmalloc_end; 770 vmem_map = (struct page *) VMALLOC_END;
672 efi_memmap_walk(create_mem_map_page_table, NULL); 771 efi_memmap_walk(create_mem_map_page_table, NULL);
673 printk("Virtual mem_map starts at 0x%p\n", vmem_map); 772 printk("Virtual mem_map starts at 0x%p\n", vmem_map);
674#endif 773#endif
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 1857766a63c1..b9609c69343a 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -44,8 +44,8 @@ extern void ia64_tlb_init (void);
44unsigned long MAX_DMA_ADDRESS = PAGE_OFFSET + 0x100000000UL; 44unsigned long MAX_DMA_ADDRESS = PAGE_OFFSET + 0x100000000UL;
45 45
46#ifdef CONFIG_VIRTUAL_MEM_MAP 46#ifdef CONFIG_VIRTUAL_MEM_MAP
47unsigned long vmalloc_end = VMALLOC_END_INIT; 47unsigned long VMALLOC_END = VMALLOC_END_INIT;
48EXPORT_SYMBOL(vmalloc_end); 48EXPORT_SYMBOL(VMALLOC_END);
49struct page *vmem_map; 49struct page *vmem_map;
50EXPORT_SYMBOL(vmem_map); 50EXPORT_SYMBOL(vmem_map);
51#endif 51#endif
diff --git a/arch/ia64/sn/kernel/sn2/sn2_smp.c b/arch/ia64/sn/kernel/sn2/sn2_smp.c
index 1176506b2bae..e884ba4e031d 100644
--- a/arch/ia64/sn/kernel/sn2/sn2_smp.c
+++ b/arch/ia64/sn/kernel/sn2/sn2_smp.c
@@ -496,13 +496,13 @@ static int sn2_ptc_seq_show(struct seq_file *file, void *data)
496 seq_printf(file, "cpu %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld\n", cpu, stat->ptc_l, 496 seq_printf(file, "cpu %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld\n", cpu, stat->ptc_l,
497 stat->change_rid, stat->shub_ptc_flushes, stat->nodes_flushed, 497 stat->change_rid, stat->shub_ptc_flushes, stat->nodes_flushed,
498 stat->deadlocks, 498 stat->deadlocks,
499 1000 * stat->lock_itc_clocks / per_cpu(cpu_info, cpu).cyc_per_usec, 499 1000 * stat->lock_itc_clocks / per_cpu(ia64_cpu_info, cpu).cyc_per_usec,
500 1000 * stat->shub_itc_clocks / per_cpu(cpu_info, cpu).cyc_per_usec, 500 1000 * stat->shub_itc_clocks / per_cpu(ia64_cpu_info, cpu).cyc_per_usec,
501 1000 * stat->shub_itc_clocks_max / per_cpu(cpu_info, cpu).cyc_per_usec, 501 1000 * stat->shub_itc_clocks_max / per_cpu(ia64_cpu_info, cpu).cyc_per_usec,
502 stat->shub_ptc_flushes_not_my_mm, 502 stat->shub_ptc_flushes_not_my_mm,
503 stat->deadlocks2, 503 stat->deadlocks2,
504 stat->shub_ipi_flushes, 504 stat->shub_ipi_flushes,
505 1000 * stat->shub_ipi_flushes_itc_clocks / per_cpu(cpu_info, cpu).cyc_per_usec); 505 1000 * stat->shub_ipi_flushes_itc_clocks / per_cpu(ia64_cpu_info, cpu).cyc_per_usec);
506 } 506 }
507 return 0; 507 return 0;
508} 508}
diff --git a/arch/ia64/xen/irq_xen.c b/arch/ia64/xen/irq_xen.c
index f042e192d2fe..a3fb7cf9ae1d 100644
--- a/arch/ia64/xen/irq_xen.c
+++ b/arch/ia64/xen/irq_xen.c
@@ -63,19 +63,19 @@ xen_free_irq_vector(int vector)
63} 63}
64 64
65 65
66static DEFINE_PER_CPU(int, timer_irq) = -1; 66static DEFINE_PER_CPU(int, xen_timer_irq) = -1;
67static DEFINE_PER_CPU(int, ipi_irq) = -1; 67static DEFINE_PER_CPU(int, xen_ipi_irq) = -1;
68static DEFINE_PER_CPU(int, resched_irq) = -1; 68static DEFINE_PER_CPU(int, xen_resched_irq) = -1;
69static DEFINE_PER_CPU(int, cmc_irq) = -1; 69static DEFINE_PER_CPU(int, xen_cmc_irq) = -1;
70static DEFINE_PER_CPU(int, cmcp_irq) = -1; 70static DEFINE_PER_CPU(int, xen_cmcp_irq) = -1;
71static DEFINE_PER_CPU(int, cpep_irq) = -1; 71static DEFINE_PER_CPU(int, xen_cpep_irq) = -1;
72#define NAME_SIZE 15 72#define NAME_SIZE 15
73static DEFINE_PER_CPU(char[NAME_SIZE], timer_name); 73static DEFINE_PER_CPU(char[NAME_SIZE], xen_timer_name);
74static DEFINE_PER_CPU(char[NAME_SIZE], ipi_name); 74static DEFINE_PER_CPU(char[NAME_SIZE], xen_ipi_name);
75static DEFINE_PER_CPU(char[NAME_SIZE], resched_name); 75static DEFINE_PER_CPU(char[NAME_SIZE], xen_resched_name);
76static DEFINE_PER_CPU(char[NAME_SIZE], cmc_name); 76static DEFINE_PER_CPU(char[NAME_SIZE], xen_cmc_name);
77static DEFINE_PER_CPU(char[NAME_SIZE], cmcp_name); 77static DEFINE_PER_CPU(char[NAME_SIZE], xen_cmcp_name);
78static DEFINE_PER_CPU(char[NAME_SIZE], cpep_name); 78static DEFINE_PER_CPU(char[NAME_SIZE], xen_cpep_name);
79#undef NAME_SIZE 79#undef NAME_SIZE
80 80
81struct saved_irq { 81struct saved_irq {
@@ -144,64 +144,64 @@ __xen_register_percpu_irq(unsigned int cpu, unsigned int vec,
144 if (xen_slab_ready) { 144 if (xen_slab_ready) {
145 switch (vec) { 145 switch (vec) {
146 case IA64_TIMER_VECTOR: 146 case IA64_TIMER_VECTOR:
147 snprintf(per_cpu(timer_name, cpu), 147 snprintf(per_cpu(xen_timer_name, cpu),
148 sizeof(per_cpu(timer_name, cpu)), 148 sizeof(per_cpu(xen_timer_name, cpu)),
149 "%s%d", action->name, cpu); 149 "%s%d", action->name, cpu);
150 irq = bind_virq_to_irqhandler(VIRQ_ITC, cpu, 150 irq = bind_virq_to_irqhandler(VIRQ_ITC, cpu,
151 action->handler, action->flags, 151 action->handler, action->flags,
152 per_cpu(timer_name, cpu), action->dev_id); 152 per_cpu(xen_timer_name, cpu), action->dev_id);
153 per_cpu(timer_irq, cpu) = irq; 153 per_cpu(xen_timer_irq, cpu) = irq;
154 break; 154 break;
155 case IA64_IPI_RESCHEDULE: 155 case IA64_IPI_RESCHEDULE:
156 snprintf(per_cpu(resched_name, cpu), 156 snprintf(per_cpu(xen_resched_name, cpu),
157 sizeof(per_cpu(resched_name, cpu)), 157 sizeof(per_cpu(xen_resched_name, cpu)),
158 "%s%d", action->name, cpu); 158 "%s%d", action->name, cpu);
159 irq = bind_ipi_to_irqhandler(XEN_RESCHEDULE_VECTOR, cpu, 159 irq = bind_ipi_to_irqhandler(XEN_RESCHEDULE_VECTOR, cpu,
160 action->handler, action->flags, 160 action->handler, action->flags,
161 per_cpu(resched_name, cpu), action->dev_id); 161 per_cpu(xen_resched_name, cpu), action->dev_id);
162 per_cpu(resched_irq, cpu) = irq; 162 per_cpu(xen_resched_irq, cpu) = irq;
163 break; 163 break;
164 case IA64_IPI_VECTOR: 164 case IA64_IPI_VECTOR:
165 snprintf(per_cpu(ipi_name, cpu), 165 snprintf(per_cpu(xen_ipi_name, cpu),
166 sizeof(per_cpu(ipi_name, cpu)), 166 sizeof(per_cpu(xen_ipi_name, cpu)),
167 "%s%d", action->name, cpu); 167 "%s%d", action->name, cpu);
168 irq = bind_ipi_to_irqhandler(XEN_IPI_VECTOR, cpu, 168 irq = bind_ipi_to_irqhandler(XEN_IPI_VECTOR, cpu,
169 action->handler, action->flags, 169 action->handler, action->flags,
170 per_cpu(ipi_name, cpu), action->dev_id); 170 per_cpu(xen_ipi_name, cpu), action->dev_id);
171 per_cpu(ipi_irq, cpu) = irq; 171 per_cpu(xen_ipi_irq, cpu) = irq;
172 break; 172 break;
173 case IA64_CMC_VECTOR: 173 case IA64_CMC_VECTOR:
174 snprintf(per_cpu(cmc_name, cpu), 174 snprintf(per_cpu(xen_cmc_name, cpu),
175 sizeof(per_cpu(cmc_name, cpu)), 175 sizeof(per_cpu(xen_cmc_name, cpu)),
176 "%s%d", action->name, cpu); 176 "%s%d", action->name, cpu);
177 irq = bind_virq_to_irqhandler(VIRQ_MCA_CMC, cpu, 177 irq = bind_virq_to_irqhandler(VIRQ_MCA_CMC, cpu,
178 action->handler, 178 action->handler,
179 action->flags, 179 action->flags,
180 per_cpu(cmc_name, cpu), 180 per_cpu(xen_cmc_name, cpu),
181 action->dev_id); 181 action->dev_id);
182 per_cpu(cmc_irq, cpu) = irq; 182 per_cpu(xen_cmc_irq, cpu) = irq;
183 break; 183 break;
184 case IA64_CMCP_VECTOR: 184 case IA64_CMCP_VECTOR:
185 snprintf(per_cpu(cmcp_name, cpu), 185 snprintf(per_cpu(xen_cmcp_name, cpu),
186 sizeof(per_cpu(cmcp_name, cpu)), 186 sizeof(per_cpu(xen_cmcp_name, cpu)),
187 "%s%d", action->name, cpu); 187 "%s%d", action->name, cpu);
188 irq = bind_ipi_to_irqhandler(XEN_CMCP_VECTOR, cpu, 188 irq = bind_ipi_to_irqhandler(XEN_CMCP_VECTOR, cpu,
189 action->handler, 189 action->handler,
190 action->flags, 190 action->flags,
191 per_cpu(cmcp_name, cpu), 191 per_cpu(xen_cmcp_name, cpu),
192 action->dev_id); 192 action->dev_id);
193 per_cpu(cmcp_irq, cpu) = irq; 193 per_cpu(xen_cmcp_irq, cpu) = irq;
194 break; 194 break;
195 case IA64_CPEP_VECTOR: 195 case IA64_CPEP_VECTOR:
196 snprintf(per_cpu(cpep_name, cpu), 196 snprintf(per_cpu(xen_cpep_name, cpu),
197 sizeof(per_cpu(cpep_name, cpu)), 197 sizeof(per_cpu(xen_cpep_name, cpu)),
198 "%s%d", action->name, cpu); 198 "%s%d", action->name, cpu);
199 irq = bind_ipi_to_irqhandler(XEN_CPEP_VECTOR, cpu, 199 irq = bind_ipi_to_irqhandler(XEN_CPEP_VECTOR, cpu,
200 action->handler, 200 action->handler,
201 action->flags, 201 action->flags,
202 per_cpu(cpep_name, cpu), 202 per_cpu(xen_cpep_name, cpu),
203 action->dev_id); 203 action->dev_id);
204 per_cpu(cpep_irq, cpu) = irq; 204 per_cpu(xen_cpep_irq, cpu) = irq;
205 break; 205 break;
206 case IA64_CPE_VECTOR: 206 case IA64_CPE_VECTOR:
207 case IA64_MCA_RENDEZ_VECTOR: 207 case IA64_MCA_RENDEZ_VECTOR:
@@ -275,30 +275,33 @@ unbind_evtchn_callback(struct notifier_block *nfb,
275 275
276 if (action == CPU_DEAD) { 276 if (action == CPU_DEAD) {
277 /* Unregister evtchn. */ 277 /* Unregister evtchn. */
278 if (per_cpu(cpep_irq, cpu) >= 0) { 278 if (per_cpu(xen_cpep_irq, cpu) >= 0) {
279 unbind_from_irqhandler(per_cpu(cpep_irq, cpu), NULL); 279 unbind_from_irqhandler(per_cpu(xen_cpep_irq, cpu),
280 per_cpu(cpep_irq, cpu) = -1; 280 NULL);
281 per_cpu(xen_cpep_irq, cpu) = -1;
281 } 282 }
282 if (per_cpu(cmcp_irq, cpu) >= 0) { 283 if (per_cpu(xen_cmcp_irq, cpu) >= 0) {
283 unbind_from_irqhandler(per_cpu(cmcp_irq, cpu), NULL); 284 unbind_from_irqhandler(per_cpu(xen_cmcp_irq, cpu),
284 per_cpu(cmcp_irq, cpu) = -1; 285 NULL);
286 per_cpu(xen_cmcp_irq, cpu) = -1;
285 } 287 }
286 if (per_cpu(cmc_irq, cpu) >= 0) { 288 if (per_cpu(xen_cmc_irq, cpu) >= 0) {
287 unbind_from_irqhandler(per_cpu(cmc_irq, cpu), NULL); 289 unbind_from_irqhandler(per_cpu(xen_cmc_irq, cpu), NULL);
288 per_cpu(cmc_irq, cpu) = -1; 290 per_cpu(xen_cmc_irq, cpu) = -1;
289 } 291 }
290 if (per_cpu(ipi_irq, cpu) >= 0) { 292 if (per_cpu(xen_ipi_irq, cpu) >= 0) {
291 unbind_from_irqhandler(per_cpu(ipi_irq, cpu), NULL); 293 unbind_from_irqhandler(per_cpu(xen_ipi_irq, cpu), NULL);
292 per_cpu(ipi_irq, cpu) = -1; 294 per_cpu(xen_ipi_irq, cpu) = -1;
293 } 295 }
294 if (per_cpu(resched_irq, cpu) >= 0) { 296 if (per_cpu(xen_resched_irq, cpu) >= 0) {
295 unbind_from_irqhandler(per_cpu(resched_irq, cpu), 297 unbind_from_irqhandler(per_cpu(xen_resched_irq, cpu),
296 NULL); 298 NULL);
297 per_cpu(resched_irq, cpu) = -1; 299 per_cpu(xen_resched_irq, cpu) = -1;
298 } 300 }
299 if (per_cpu(timer_irq, cpu) >= 0) { 301 if (per_cpu(xen_timer_irq, cpu) >= 0) {
300 unbind_from_irqhandler(per_cpu(timer_irq, cpu), NULL); 302 unbind_from_irqhandler(per_cpu(xen_timer_irq, cpu),
301 per_cpu(timer_irq, cpu) = -1; 303 NULL);
304 per_cpu(xen_timer_irq, cpu) = -1;
302 } 305 }
303 } 306 }
304 return NOTIFY_OK; 307 return NOTIFY_OK;
diff --git a/arch/ia64/xen/time.c b/arch/ia64/xen/time.c
index dbeadb9c8e20..c1c544513e8d 100644
--- a/arch/ia64/xen/time.c
+++ b/arch/ia64/xen/time.c
@@ -34,15 +34,15 @@
34 34
35#include "../kernel/fsyscall_gtod_data.h" 35#include "../kernel/fsyscall_gtod_data.h"
36 36
37DEFINE_PER_CPU(struct vcpu_runstate_info, runstate); 37static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate);
38DEFINE_PER_CPU(unsigned long, processed_stolen_time); 38static DEFINE_PER_CPU(unsigned long, xen_stolen_time);
39DEFINE_PER_CPU(unsigned long, processed_blocked_time); 39static DEFINE_PER_CPU(unsigned long, xen_blocked_time);
40 40
41/* taken from i386/kernel/time-xen.c */ 41/* taken from i386/kernel/time-xen.c */
42static void xen_init_missing_ticks_accounting(int cpu) 42static void xen_init_missing_ticks_accounting(int cpu)
43{ 43{
44 struct vcpu_register_runstate_memory_area area; 44 struct vcpu_register_runstate_memory_area area;
45 struct vcpu_runstate_info *runstate = &per_cpu(runstate, cpu); 45 struct vcpu_runstate_info *runstate = &per_cpu(xen_runstate, cpu);
46 int rc; 46 int rc;
47 47
48 memset(runstate, 0, sizeof(*runstate)); 48 memset(runstate, 0, sizeof(*runstate));
@@ -52,8 +52,8 @@ static void xen_init_missing_ticks_accounting(int cpu)
52 &area); 52 &area);
53 WARN_ON(rc && rc != -ENOSYS); 53 WARN_ON(rc && rc != -ENOSYS);
54 54
55 per_cpu(processed_blocked_time, cpu) = runstate->time[RUNSTATE_blocked]; 55 per_cpu(xen_blocked_time, cpu) = runstate->time[RUNSTATE_blocked];
56 per_cpu(processed_stolen_time, cpu) = runstate->time[RUNSTATE_runnable] 56 per_cpu(xen_stolen_time, cpu) = runstate->time[RUNSTATE_runnable]
57 + runstate->time[RUNSTATE_offline]; 57 + runstate->time[RUNSTATE_offline];
58} 58}
59 59
@@ -68,7 +68,7 @@ static void get_runstate_snapshot(struct vcpu_runstate_info *res)
68 68
69 BUG_ON(preemptible()); 69 BUG_ON(preemptible());
70 70
71 state = &__get_cpu_var(runstate); 71 state = &__get_cpu_var(xen_runstate);
72 72
73 /* 73 /*
74 * The runstate info is always updated by the hypervisor on 74 * The runstate info is always updated by the hypervisor on
@@ -103,12 +103,12 @@ consider_steal_time(unsigned long new_itm)
103 * This function just checks and reject this effect. 103 * This function just checks and reject this effect.
104 */ 104 */
105 if (!time_after_eq(runstate.time[RUNSTATE_blocked], 105 if (!time_after_eq(runstate.time[RUNSTATE_blocked],
106 per_cpu(processed_blocked_time, cpu))) 106 per_cpu(xen_blocked_time, cpu)))
107 blocked = 0; 107 blocked = 0;
108 108
109 if (!time_after_eq(runstate.time[RUNSTATE_runnable] + 109 if (!time_after_eq(runstate.time[RUNSTATE_runnable] +
110 runstate.time[RUNSTATE_offline], 110 runstate.time[RUNSTATE_offline],
111 per_cpu(processed_stolen_time, cpu))) 111 per_cpu(xen_stolen_time, cpu)))
112 stolen = 0; 112 stolen = 0;
113 113
114 if (!time_after(delta_itm + new_itm, ia64_get_itc())) 114 if (!time_after(delta_itm + new_itm, ia64_get_itc()))
@@ -147,8 +147,8 @@ consider_steal_time(unsigned long new_itm)
147 } else { 147 } else {
148 local_cpu_data->itm_next = delta_itm + new_itm; 148 local_cpu_data->itm_next = delta_itm + new_itm;
149 } 149 }
150 per_cpu(processed_stolen_time, cpu) += NS_PER_TICK * stolen; 150 per_cpu(xen_stolen_time, cpu) += NS_PER_TICK * stolen;
151 per_cpu(processed_blocked_time, cpu) += NS_PER_TICK * blocked; 151 per_cpu(xen_blocked_time, cpu) += NS_PER_TICK * blocked;
152 } 152 }
153 return delta_itm; 153 return delta_itm;
154} 154}
diff --git a/arch/m68k/include/asm/pgtable_mm.h b/arch/m68k/include/asm/pgtable_mm.h
index fe60e1abaee8..aca0e28581c7 100644
--- a/arch/m68k/include/asm/pgtable_mm.h
+++ b/arch/m68k/include/asm/pgtable_mm.h
@@ -83,9 +83,9 @@
83#define VMALLOC_START (((unsigned long) high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)) 83#define VMALLOC_START (((unsigned long) high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
84#define VMALLOC_END KMAP_START 84#define VMALLOC_END KMAP_START
85#else 85#else
86extern unsigned long vmalloc_end; 86extern unsigned long m68k_vmalloc_end;
87#define VMALLOC_START 0x0f800000 87#define VMALLOC_START 0x0f800000
88#define VMALLOC_END vmalloc_end 88#define VMALLOC_END m68k_vmalloc_end
89#endif /* CONFIG_SUN3 */ 89#endif /* CONFIG_SUN3 */
90 90
91/* zero page used for uninitialized stuff */ 91/* zero page used for uninitialized stuff */
diff --git a/arch/m68k/sun3/mmu_emu.c b/arch/m68k/sun3/mmu_emu.c
index 3cd19390aae5..94f81ecfe3f8 100644
--- a/arch/m68k/sun3/mmu_emu.c
+++ b/arch/m68k/sun3/mmu_emu.c
@@ -45,8 +45,8 @@
45** Globals 45** Globals
46*/ 46*/
47 47
48unsigned long vmalloc_end; 48unsigned long m68k_vmalloc_end;
49EXPORT_SYMBOL(vmalloc_end); 49EXPORT_SYMBOL(m68k_vmalloc_end);
50 50
51unsigned long pmeg_vaddr[PMEGS_NUM]; 51unsigned long pmeg_vaddr[PMEGS_NUM];
52unsigned char pmeg_alloc[PMEGS_NUM]; 52unsigned char pmeg_alloc[PMEGS_NUM];
@@ -172,8 +172,8 @@ void mmu_emu_init(unsigned long bootmem_end)
172#endif 172#endif
173 // the lowest mapping here is the end of our 173 // the lowest mapping here is the end of our
174 // vmalloc region 174 // vmalloc region
175 if(!vmalloc_end) 175 if (!m68k_vmalloc_end)
176 vmalloc_end = seg; 176 m68k_vmalloc_end = seg;
177 177
178 // mark the segmap alloc'd, and reserve any 178 // mark the segmap alloc'd, and reserve any
179 // of the first 0xbff pages the hardware is 179 // of the first 0xbff pages the hardware is
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index bbd8327f1890..fd53e500be67 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -6,8 +6,15 @@ mainmenu "Linux/Microblaze Kernel Configuration"
6config MICROBLAZE 6config MICROBLAZE
7 def_bool y 7 def_bool y
8 select HAVE_LMB 8 select HAVE_LMB
9 select HAVE_FUNCTION_TRACER
10 select HAVE_FUNCTION_TRACE_MCOUNT_TEST
11 select HAVE_FUNCTION_GRAPH_TRACER
12 select HAVE_DYNAMIC_FTRACE
13 select HAVE_FTRACE_MCOUNT_RECORD
9 select USB_ARCH_HAS_EHCI 14 select USB_ARCH_HAS_EHCI
10 select ARCH_WANT_OPTIONAL_GPIOLIB 15 select ARCH_WANT_OPTIONAL_GPIOLIB
16 select HAVE_OPROFILE
17 select TRACING_SUPPORT
11 18
12config SWAP 19config SWAP
13 def_bool n 20 def_bool n
@@ -57,12 +64,24 @@ config GENERIC_GPIO
57config GENERIC_CSUM 64config GENERIC_CSUM
58 def_bool y 65 def_bool y
59 66
67config STACKTRACE_SUPPORT
68 def_bool y
69
70config LOCKDEP_SUPPORT
71 def_bool y
72
73config HAVE_LATENCYTOP_SUPPORT
74 def_bool y
75
60config PCI 76config PCI
61 def_bool n 77 def_bool n
62 78
63config NO_DMA 79config NO_DMA
64 def_bool y 80 def_bool y
65 81
82config DTC
83 def_bool y
84
66source "init/Kconfig" 85source "init/Kconfig"
67 86
68source "kernel/Kconfig.freezer" 87source "kernel/Kconfig.freezer"
diff --git a/arch/microblaze/Kconfig.debug b/arch/microblaze/Kconfig.debug
index 242cd35bdb4b..9dc708a7f700 100644
--- a/arch/microblaze/Kconfig.debug
+++ b/arch/microblaze/Kconfig.debug
@@ -3,6 +3,9 @@
3 3
4menu "Kernel hacking" 4menu "Kernel hacking"
5 5
6config TRACE_IRQFLAGS_SUPPORT
7 def_bool y
8
6source "lib/Kconfig.debug" 9source "lib/Kconfig.debug"
7 10
8config EARLY_PRINTK 11config EARLY_PRINTK
diff --git a/arch/microblaze/Makefile b/arch/microblaze/Makefile
index 34187354304a..d2d6cfcb1a30 100644
--- a/arch/microblaze/Makefile
+++ b/arch/microblaze/Makefile
@@ -51,6 +51,8 @@ core-y += arch/microblaze/kernel/
51core-y += arch/microblaze/mm/ 51core-y += arch/microblaze/mm/
52core-y += arch/microblaze/platform/ 52core-y += arch/microblaze/platform/
53 53
54drivers-$(CONFIG_OPROFILE) += arch/microblaze/oprofile/
55
54boot := arch/microblaze/boot 56boot := arch/microblaze/boot
55 57
56# Are we making a simpleImage.<boardname> target? If so, crack out the boardname 58# Are we making a simpleImage.<boardname> target? If so, crack out the boardname
diff --git a/arch/microblaze/boot/Makefile b/arch/microblaze/boot/Makefile
index 21f13322a4ca..902cf9846c3c 100644
--- a/arch/microblaze/boot/Makefile
+++ b/arch/microblaze/boot/Makefile
@@ -2,11 +2,13 @@
2# arch/microblaze/boot/Makefile 2# arch/microblaze/boot/Makefile
3# 3#
4 4
5MKIMAGE := $(srctree)/scripts/mkuboot.sh
6
5obj-y += linked_dtb.o 7obj-y += linked_dtb.o
6 8
7targets := linux.bin linux.bin.gz simpleImage.% 9targets := linux.bin linux.bin.gz simpleImage.%
8 10
9OBJCOPYFLAGS_linux.bin := -O binary 11OBJCOPYFLAGS := -O binary
10 12
11# Where the DTS files live 13# Where the DTS files live
12dtstree := $(srctree)/$(src)/dts 14dtstree := $(srctree)/$(src)/dts
@@ -24,6 +26,7 @@ $(obj)/linux.bin: vmlinux FORCE
24 [ -n $(CONFIG_INITRAMFS_SOURCE) ] && [ ! -e $(CONFIG_INITRAMFS_SOURCE) ] && \ 26 [ -n $(CONFIG_INITRAMFS_SOURCE) ] && [ ! -e $(CONFIG_INITRAMFS_SOURCE) ] && \
25 touch $(CONFIG_INITRAMFS_SOURCE) || echo "No CPIO image" 27 touch $(CONFIG_INITRAMFS_SOURCE) || echo "No CPIO image"
26 $(call if_changed,objcopy) 28 $(call if_changed,objcopy)
29 $(call if_changed,uimage)
27 @echo 'Kernel: $@ is ready' ' (#'`cat .version`')' 30 @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
28 31
29$(obj)/linux.bin.gz: $(obj)/linux.bin FORCE 32$(obj)/linux.bin.gz: $(obj)/linux.bin FORCE
@@ -36,8 +39,16 @@ quiet_cmd_cp = CP $< $@$2
36quiet_cmd_strip = STRIP $@ 39quiet_cmd_strip = STRIP $@
37 cmd_strip = $(STRIP) -K _start -K _end -K __log_buf -K _fdt_start vmlinux -o $@ 40 cmd_strip = $(STRIP) -K _start -K _end -K __log_buf -K _fdt_start vmlinux -o $@
38 41
42quiet_cmd_uimage = UIMAGE $@.ub
43 cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A microblaze -O linux -T kernel \
44 -C none -n 'Linux-$(KERNELRELEASE)' \
45 -a $(CONFIG_KERNEL_BASE_ADDR) -e $(CONFIG_KERNEL_BASE_ADDR) \
46 -d $@ $@.ub
47
39$(obj)/simpleImage.%: vmlinux FORCE 48$(obj)/simpleImage.%: vmlinux FORCE
40 $(call if_changed,cp,.unstrip) 49 $(call if_changed,cp,.unstrip)
50 $(call if_changed,objcopy)
51 $(call if_changed,uimage)
41 $(call if_changed,strip) 52 $(call if_changed,strip)
42 @echo 'Kernel: $@ is ready' ' (#'`cat .version`')' 53 @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
43 54
@@ -53,4 +64,4 @@ $(obj)/%.dtb: $(dtstree)/%.dts FORCE
53 64
54clean-kernel += linux.bin linux.bin.gz simpleImage.* 65clean-kernel += linux.bin linux.bin.gz simpleImage.*
55 66
56clean-files += *.dtb 67clean-files += *.dtb simpleImage.*.unstrip
diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
index c209c47509d5..e52210891d78 100644
--- a/arch/microblaze/include/asm/cache.h
+++ b/arch/microblaze/include/asm/cache.h
@@ -21,20 +21,4 @@
21 21
22#define SMP_CACHE_BYTES L1_CACHE_BYTES 22#define SMP_CACHE_BYTES L1_CACHE_BYTES
23 23
24void _enable_icache(void);
25void _disable_icache(void);
26void _invalidate_icache(unsigned int addr);
27
28#define __enable_icache() _enable_icache()
29#define __disable_icache() _disable_icache()
30#define __invalidate_icache(addr) _invalidate_icache(addr)
31
32void _enable_dcache(void);
33void _disable_dcache(void);
34void _invalidate_dcache(unsigned int addr);
35
36#define __enable_dcache() _enable_dcache()
37#define __disable_dcache() _disable_dcache()
38#define __invalidate_dcache(addr) _invalidate_dcache(addr)
39
40#endif /* _ASM_MICROBLAZE_CACHE_H */ 24#endif /* _ASM_MICROBLAZE_CACHE_H */
diff --git a/arch/microblaze/include/asm/cacheflush.h b/arch/microblaze/include/asm/cacheflush.h
index 088076e657b3..a6edd356cd08 100644
--- a/arch/microblaze/include/asm/cacheflush.h
+++ b/arch/microblaze/include/asm/cacheflush.h
@@ -18,6 +18,8 @@
18/* Somebody depends on this; sigh... */ 18/* Somebody depends on this; sigh... */
19#include <linux/mm.h> 19#include <linux/mm.h>
20 20
21/* Look at Documentation/cachetlb.txt */
22
21/* 23/*
22 * Cache handling functions. 24 * Cache handling functions.
23 * Microblaze has a write-through data cache, meaning that the data cache 25 * Microblaze has a write-through data cache, meaning that the data cache
@@ -27,78 +29,81 @@
27 * instruction cache to make sure we don't fetch old, bad code. 29 * instruction cache to make sure we don't fetch old, bad code.
28 */ 30 */
29 31
32/* struct cache, d=dcache, i=icache, fl = flush, iv = invalidate,
33 * suffix r = range */
34struct scache {
35 /* icache */
36 void (*ie)(void); /* enable */
37 void (*id)(void); /* disable */
38 void (*ifl)(void); /* flush */
39 void (*iflr)(unsigned long a, unsigned long b);
40 void (*iin)(void); /* invalidate */
41 void (*iinr)(unsigned long a, unsigned long b);
42 /* dcache */
43 void (*de)(void); /* enable */
44 void (*dd)(void); /* disable */
45 void (*dfl)(void); /* flush */
46 void (*dflr)(unsigned long a, unsigned long b);
47 void (*din)(void); /* invalidate */
48 void (*dinr)(unsigned long a, unsigned long b);
49};
50
51/* microblaze cache */
52extern struct scache *mbc;
53
54void microblaze_cache_init(void);
55
56#define enable_icache() mbc->ie();
57#define disable_icache() mbc->id();
58#define flush_icache() mbc->ifl();
59#define flush_icache_range(start, end) mbc->iflr(start, end);
60#define invalidate_icache() mbc->iin();
61#define invalidate_icache_range(start, end) mbc->iinr(start, end);
62
63
64#define flush_icache_user_range(vma, pg, adr, len) flush_icache();
65#define flush_icache_page(vma, pg) do { } while (0)
66
67#define enable_dcache() mbc->de();
68#define disable_dcache() mbc->dd();
30/* FIXME for LL-temac driver */ 69/* FIXME for LL-temac driver */
31#define invalidate_dcache_range(start, end) \ 70#define invalidate_dcache() mbc->din();
32 __invalidate_dcache_range(start, end) 71#define invalidate_dcache_range(start, end) mbc->dinr(start, end);
33 72#define flush_dcache() mbc->dfl();
34#define flush_cache_all() __invalidate_cache_all() 73#define flush_dcache_range(start, end) mbc->dflr(start, end);
35#define flush_cache_mm(mm) do { } while (0)
36#define flush_cache_range(vma, start, end) __invalidate_cache_all()
37#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
38 74
39#define flush_dcache_range(start, end) __invalidate_dcache_range(start, end)
40#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 75#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
76/* D-cache aliasing problem can't happen - cache is between MMU and ram */
41#define flush_dcache_page(page) do { } while (0) 77#define flush_dcache_page(page) do { } while (0)
42#define flush_dcache_mmap_lock(mapping) do { } while (0) 78#define flush_dcache_mmap_lock(mapping) do { } while (0)
43#define flush_dcache_mmap_unlock(mapping) do { } while (0) 79#define flush_dcache_mmap_unlock(mapping) do { } while (0)
44 80
45#define flush_icache_range(start, len) __invalidate_icache_range(start, len)
46#define flush_icache_page(vma, pg) do { } while (0)
47
48#ifndef CONFIG_MMU
49# define flush_icache_user_range(start, len) do { } while (0)
50#else
51# define flush_icache_user_range(vma, pg, adr, len) __invalidate_icache_all()
52
53# define flush_page_to_ram(page) do { } while (0)
54 81
55# define flush_icache() __invalidate_icache_all() 82#define flush_cache_dup_mm(mm) do { } while (0)
56# define flush_cache_sigtramp(vaddr) \ 83#define flush_cache_vmap(start, end) do { } while (0)
57 __invalidate_icache_range(vaddr, vaddr + 8) 84#define flush_cache_vunmap(start, end) do { } while (0)
58 85#define flush_cache_mm(mm) do { } while (0)
59# define flush_dcache_mmap_lock(mapping) do { } while (0) 86#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
60# define flush_dcache_mmap_unlock(mapping) do { } while (0)
61 87
62# define flush_cache_dup_mm(mm) do { } while (0) 88/* MS: kgdb code use this macro, wrong len with FLASH */
89#if 0
90#define flush_cache_range(vma, start, len) { \
91 flush_icache_range((unsigned) (start), (unsigned) (start) + (len)); \
92 flush_dcache_range((unsigned) (start), (unsigned) (start) + (len)); \
93}
63#endif 94#endif
64 95
65#define flush_cache_vmap(start, end) do { } while (0) 96#define flush_cache_range(vma, start, len) do { } while (0)
66#define flush_cache_vunmap(start, end) do { } while (0)
67
68struct page;
69struct mm_struct;
70struct vm_area_struct;
71
72/* see arch/microblaze/kernel/cache.c */
73extern void __invalidate_icache_all(void);
74extern void __invalidate_icache_range(unsigned long start, unsigned long end);
75extern void __invalidate_icache_page(struct vm_area_struct *vma,
76 struct page *page);
77extern void __invalidate_icache_user_range(struct vm_area_struct *vma,
78 struct page *page,
79 unsigned long adr, int len);
80extern void __invalidate_cache_sigtramp(unsigned long addr);
81
82extern void __invalidate_dcache_all(void);
83extern void __invalidate_dcache_range(unsigned long start, unsigned long end);
84extern void __invalidate_dcache_page(struct vm_area_struct *vma,
85 struct page *page);
86extern void __invalidate_dcache_user_range(struct vm_area_struct *vma,
87 struct page *page,
88 unsigned long adr, int len);
89
90extern inline void __invalidate_cache_all(void)
91{
92 __invalidate_icache_all();
93 __invalidate_dcache_all();
94}
95 97
96#define copy_to_user_page(vma, page, vaddr, dst, src, len) \ 98#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
97do { memcpy((dst), (src), (len)); \ 99do { \
98 flush_icache_range((unsigned) (dst), (unsigned) (dst) + (len)); \ 100 memcpy((dst), (src), (len)); \
101 flush_icache_range((unsigned) (dst), (unsigned) (dst) + (len)); \
99} while (0) 102} while (0)
100 103
101#define copy_from_user_page(vma, page, vaddr, dst, src, len) \ 104#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
102 memcpy((dst), (src), (len)) 105do { \
106 memcpy((dst), (src), (len)); \
107} while (0)
103 108
104#endif /* _ASM_MICROBLAZE_CACHEFLUSH_H */ 109#endif /* _ASM_MICROBLAZE_CACHEFLUSH_H */
diff --git a/arch/microblaze/include/asm/cpuinfo.h b/arch/microblaze/include/asm/cpuinfo.h
index 52f28f6dc4eb..b4f5ca33aebf 100644
--- a/arch/microblaze/include/asm/cpuinfo.h
+++ b/arch/microblaze/include/asm/cpuinfo.h
@@ -43,7 +43,7 @@ struct cpuinfo {
43 u32 use_icache; 43 u32 use_icache;
44 u32 icache_tagbits; 44 u32 icache_tagbits;
45 u32 icache_write; 45 u32 icache_write;
46 u32 icache_line; 46 u32 icache_line_length;
47 u32 icache_size; 47 u32 icache_size;
48 unsigned long icache_base; 48 unsigned long icache_base;
49 unsigned long icache_high; 49 unsigned long icache_high;
@@ -51,8 +51,9 @@ struct cpuinfo {
51 u32 use_dcache; 51 u32 use_dcache;
52 u32 dcache_tagbits; 52 u32 dcache_tagbits;
53 u32 dcache_write; 53 u32 dcache_write;
54 u32 dcache_line; 54 u32 dcache_line_length;
55 u32 dcache_size; 55 u32 dcache_size;
56 u32 dcache_wb;
56 unsigned long dcache_base; 57 unsigned long dcache_base;
57 unsigned long dcache_high; 58 unsigned long dcache_high;
58 59
diff --git a/arch/microblaze/include/asm/device.h b/arch/microblaze/include/asm/device.h
index 30286db27c1c..78a038452c0f 100644
--- a/arch/microblaze/include/asm/device.h
+++ b/arch/microblaze/include/asm/device.h
@@ -19,6 +19,18 @@ struct dev_archdata {
19struct pdev_archdata { 19struct pdev_archdata {
20}; 20};
21 21
22static inline void dev_archdata_set_node(struct dev_archdata *ad,
23 struct device_node *np)
24{
25 ad->of_node = np;
26}
27
28static inline struct device_node *
29dev_archdata_get_node(const struct dev_archdata *ad)
30{
31 return ad->of_node;
32}
33
22#endif /* _ASM_MICROBLAZE_DEVICE_H */ 34#endif /* _ASM_MICROBLAZE_DEVICE_H */
23 35
24 36
diff --git a/arch/microblaze/include/asm/ftrace.h b/arch/microblaze/include/asm/ftrace.h
index 8b137891791f..fd2fa2eca62f 100644
--- a/arch/microblaze/include/asm/ftrace.h
+++ b/arch/microblaze/include/asm/ftrace.h
@@ -1 +1,26 @@
1#ifndef _ASM_MICROBLAZE_FTRACE
2#define _ASM_MICROBLAZE_FTRACE
1 3
4#ifdef CONFIG_FUNCTION_TRACER
5
6#define MCOUNT_ADDR ((long)(_mcount))
7#define MCOUNT_INSN_SIZE 8 /* sizeof mcount call */
8
9#ifndef __ASSEMBLY__
10extern void _mcount(void);
11extern void ftrace_call_graph(void);
12#endif
13
14#ifdef CONFIG_DYNAMIC_FTRACE
15/* reloction of mcount call site is the same as the address */
16static inline unsigned long ftrace_call_adjust(unsigned long addr)
17{
18 return addr;
19}
20
21struct dyn_arch_ftrace {
22};
23#endif /* CONFIG_DYNAMIC_FTRACE */
24
25#endif /* CONFIG_FUNCTION_TRACER */
26#endif /* _ASM_MICROBLAZE_FTRACE */
diff --git a/arch/microblaze/include/asm/futex.h b/arch/microblaze/include/asm/futex.h
index 0b745828f42b..8dbb6e7a03a2 100644
--- a/arch/microblaze/include/asm/futex.h
+++ b/arch/microblaze/include/asm/futex.h
@@ -1 +1,126 @@
1#include <asm-generic/futex.h> 1#ifndef _ASM_MICROBLAZE_FUTEX_H
2#define _ASM_MICROBLAZE_FUTEX_H
3
4#ifdef __KERNEL__
5
6#include <linux/futex.h>
7#include <linux/uaccess.h>
8#include <asm/errno.h>
9
10#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
11({ \
12 __asm__ __volatile__ ( \
13 "1: lwx %0, %2, r0; " \
14 insn \
15 "2: swx %1, %2, r0; \
16 addic %1, r0, 0; \
17 bnei %1, 1b; \
18 3: \
19 .section .fixup,\"ax\"; \
20 4: brid 3b; \
21 addik %1, r0, %3; \
22 .previous; \
23 .section __ex_table,\"a\"; \
24 .word 1b,4b,2b,4b; \
25 .previous;" \
26 : "=&r" (oldval), "=&r" (ret) \
27 : "b" (uaddr), "i" (-EFAULT), "r" (oparg) \
28 ); \
29})
30
31static inline int
32futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
33{
34 int op = (encoded_op >> 28) & 7;
35 int cmp = (encoded_op >> 24) & 15;
36 int oparg = (encoded_op << 8) >> 20;
37 int cmparg = (encoded_op << 20) >> 20;
38 int oldval = 0, ret;
39 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
40 oparg = 1 << oparg;
41
42 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
43 return -EFAULT;
44
45 pagefault_disable();
46
47 switch (op) {
48 case FUTEX_OP_SET:
49 __futex_atomic_op("or %1,%4,%4;", ret, oldval, uaddr, oparg);
50 break;
51 case FUTEX_OP_ADD:
52 __futex_atomic_op("add %1,%0,%4;", ret, oldval, uaddr, oparg);
53 break;
54 case FUTEX_OP_OR:
55 __futex_atomic_op("or %1,%0,%4;", ret, oldval, uaddr, oparg);
56 break;
57 case FUTEX_OP_ANDN:
58 __futex_atomic_op("and %1,%0,%4;", ret, oldval, uaddr, oparg);
59 break;
60 case FUTEX_OP_XOR:
61 __futex_atomic_op("xor %1,%0,%4;", ret, oldval, uaddr, oparg);
62 break;
63 default:
64 ret = -ENOSYS;
65 }
66
67 pagefault_enable();
68
69 if (!ret) {
70 switch (cmp) {
71 case FUTEX_OP_CMP_EQ:
72 ret = (oldval == cmparg);
73 break;
74 case FUTEX_OP_CMP_NE:
75 ret = (oldval != cmparg);
76 break;
77 case FUTEX_OP_CMP_LT:
78 ret = (oldval < cmparg);
79 break;
80 case FUTEX_OP_CMP_GE:
81 ret = (oldval >= cmparg);
82 break;
83 case FUTEX_OP_CMP_LE:
84 ret = (oldval <= cmparg);
85 break;
86 case FUTEX_OP_CMP_GT:
87 ret = (oldval > cmparg);
88 break;
89 default:
90 ret = -ENOSYS;
91 }
92 }
93 return ret;
94}
95
96static inline int
97futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
98{
99 int prev, cmp;
100
101 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
102 return -EFAULT;
103
104 __asm__ __volatile__ ("1: lwx %0, %2, r0; \
105 cmp %1, %0, %3; \
106 beqi %1, 3f; \
107 2: swx %4, %2, r0; \
108 addic %1, r0, 0; \
109 bnei %1, 1b; \
110 3: \
111 .section .fixup,\"ax\"; \
112 4: brid 3b; \
113 addik %0, r0, %5; \
114 .previous; \
115 .section __ex_table,\"a\"; \
116 .word 1b,4b,2b,4b; \
117 .previous;" \
118 : "=&r" (prev), "=&r"(cmp) \
119 : "r" (uaddr), "r" (oldval), "r" (newval), "i" (-EFAULT));
120
121 return prev;
122}
123
124#endif /* __KERNEL__ */
125
126#endif
diff --git a/arch/microblaze/include/asm/irqflags.h b/arch/microblaze/include/asm/irqflags.h
index dea65645a4f8..2c38c6d80176 100644
--- a/arch/microblaze/include/asm/irqflags.h
+++ b/arch/microblaze/include/asm/irqflags.h
@@ -10,78 +10,73 @@
10#define _ASM_MICROBLAZE_IRQFLAGS_H 10#define _ASM_MICROBLAZE_IRQFLAGS_H
11 11
12#include <linux/irqflags.h> 12#include <linux/irqflags.h>
13#include <asm/registers.h>
13 14
14# if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR 15# if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR
15 16
16# define local_irq_save(flags) \ 17# define raw_local_irq_save(flags) \
17 do { \ 18 do { \
18 asm volatile ("# local_irq_save \n\t" \ 19 asm volatile (" msrclr %0, %1; \
19 "msrclr %0, %1 \n\t" \ 20 nop;" \
20 "nop \n\t" \
21 : "=r"(flags) \ 21 : "=r"(flags) \
22 : "i"(MSR_IE) \ 22 : "i"(MSR_IE) \
23 : "memory"); \ 23 : "memory"); \
24 } while (0) 24 } while (0)
25 25
26# define local_irq_disable() \ 26# define raw_local_irq_disable() \
27 do { \ 27 do { \
28 asm volatile ("# local_irq_disable \n\t" \ 28 asm volatile (" msrclr r0, %0; \
29 "msrclr r0, %0 \n\t" \ 29 nop;" \
30 "nop \n\t" \ 30 : \
31 : \ 31 : "i"(MSR_IE) \
32 : "i"(MSR_IE) \ 32 : "memory"); \
33 : "memory"); \
34 } while (0) 33 } while (0)
35 34
36# define local_irq_enable() \ 35# define raw_local_irq_enable() \
37 do { \ 36 do { \
38 asm volatile ("# local_irq_enable \n\t" \ 37 asm volatile (" msrset r0, %0; \
39 "msrset r0, %0 \n\t" \ 38 nop;" \
40 "nop \n\t" \ 39 : \
41 : \ 40 : "i"(MSR_IE) \
42 : "i"(MSR_IE) \ 41 : "memory"); \
43 : "memory"); \
44 } while (0) 42 } while (0)
45 43
46# else /* CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR == 0 */ 44# else /* CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR == 0 */
47 45
48# define local_irq_save(flags) \ 46# define raw_local_irq_save(flags) \
49 do { \ 47 do { \
50 register unsigned tmp; \ 48 register unsigned tmp; \
51 asm volatile ("# local_irq_save \n\t" \ 49 asm volatile (" mfs %0, rmsr; \
52 "mfs %0, rmsr \n\t" \ 50 nop; \
53 "nop \n\t" \ 51 andi %1, %0, %2; \
54 "andi %1, %0, %2 \n\t" \ 52 mts rmsr, %1; \
55 "mts rmsr, %1 \n\t" \ 53 nop;" \
56 "nop \n\t" \
57 : "=r"(flags), "=r" (tmp) \ 54 : "=r"(flags), "=r" (tmp) \
58 : "i"(~MSR_IE) \ 55 : "i"(~MSR_IE) \
59 : "memory"); \ 56 : "memory"); \
60 } while (0) 57 } while (0)
61 58
62# define local_irq_disable() \ 59# define raw_local_irq_disable() \
63 do { \ 60 do { \
64 register unsigned tmp; \ 61 register unsigned tmp; \
65 asm volatile ("# local_irq_disable \n\t" \ 62 asm volatile (" mfs %0, rmsr; \
66 "mfs %0, rmsr \n\t" \ 63 nop; \
67 "nop \n\t" \ 64 andi %0, %0, %1; \
68 "andi %0, %0, %1 \n\t" \ 65 mts rmsr, %0; \
69 "mts rmsr, %0 \n\t" \ 66 nop;" \
70 "nop \n\t" \
71 : "=r"(tmp) \ 67 : "=r"(tmp) \
72 : "i"(~MSR_IE) \ 68 : "i"(~MSR_IE) \
73 : "memory"); \ 69 : "memory"); \
74 } while (0) 70 } while (0)
75 71
76# define local_irq_enable() \ 72# define raw_local_irq_enable() \
77 do { \ 73 do { \
78 register unsigned tmp; \ 74 register unsigned tmp; \
79 asm volatile ("# local_irq_enable \n\t" \ 75 asm volatile (" mfs %0, rmsr; \
80 "mfs %0, rmsr \n\t" \ 76 nop; \
81 "nop \n\t" \ 77 ori %0, %0, %1; \
82 "ori %0, %0, %1 \n\t" \ 78 mts rmsr, %0; \
83 "mts rmsr, %0 \n\t" \ 79 nop;" \
84 "nop \n\t" \
85 : "=r"(tmp) \ 80 : "=r"(tmp) \
86 : "i"(MSR_IE) \ 81 : "i"(MSR_IE) \
87 : "memory"); \ 82 : "memory"); \
@@ -89,35 +84,28 @@
89 84
90# endif /* CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR */ 85# endif /* CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR */
91 86
92#define local_save_flags(flags) \ 87#define raw_local_irq_restore(flags) \
93 do { \ 88 do { \
94 asm volatile ("# local_save_flags \n\t" \ 89 asm volatile (" mts rmsr, %0; \
95 "mfs %0, rmsr \n\t" \ 90 nop;" \
96 "nop \n\t" \
97 : "=r"(flags) \
98 : \ 91 : \
92 : "r"(flags) \
99 : "memory"); \ 93 : "memory"); \
100 } while (0) 94 } while (0)
101 95
102#define local_irq_restore(flags) \ 96static inline unsigned long get_msr(void)
103 do { \
104 asm volatile ("# local_irq_restore \n\t"\
105 "mts rmsr, %0 \n\t" \
106 "nop \n\t" \
107 : \
108 : "r"(flags) \
109 : "memory"); \
110 } while (0)
111
112static inline int irqs_disabled(void)
113{ 97{
114 unsigned long flags; 98 unsigned long flags;
115 99 asm volatile (" mfs %0, rmsr; \
116 local_save_flags(flags); 100 nop;" \
117 return ((flags & MSR_IE) == 0); 101 : "=r"(flags) \
102 : \
103 : "memory"); \
104 return flags;
118} 105}
119 106
120#define raw_irqs_disabled irqs_disabled 107#define raw_local_save_flags(flags) ((flags) = get_msr())
121#define raw_irqs_disabled_flags(flags) ((flags) == 0) 108#define raw_irqs_disabled() ((get_msr() & MSR_IE) == 0)
109#define raw_irqs_disabled_flags(flags) ((flags & MSR_IE) == 0)
122 110
123#endif /* _ASM_MICROBLAZE_IRQFLAGS_H */ 111#endif /* _ASM_MICROBLAZE_IRQFLAGS_H */
diff --git a/arch/microblaze/include/asm/page.h b/arch/microblaze/include/asm/page.h
index 880c988c2237..9b66c0fa9a32 100644
--- a/arch/microblaze/include/asm/page.h
+++ b/arch/microblaze/include/asm/page.h
@@ -164,7 +164,8 @@ extern int page_is_ram(unsigned long pfn);
164# endif /* CONFIG_MMU */ 164# endif /* CONFIG_MMU */
165 165
166# ifndef CONFIG_MMU 166# ifndef CONFIG_MMU
167# define pfn_valid(pfn) ((pfn) >= min_low_pfn && (pfn) <= max_mapnr) 167# define pfn_valid(pfn) (((pfn) >= min_low_pfn) && \
168 ((pfn) <= (min_low_pfn + max_mapnr)))
168# define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT) 169# define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT)
169# else /* CONFIG_MMU */ 170# else /* CONFIG_MMU */
170# define ARCH_PFN_OFFSET (memory_start >> PAGE_SHIFT) 171# define ARCH_PFN_OFFSET (memory_start >> PAGE_SHIFT)
diff --git a/arch/microblaze/include/asm/pgalloc.h b/arch/microblaze/include/asm/pgalloc.h
index b0131da1387b..7547f5064560 100644
--- a/arch/microblaze/include/asm/pgalloc.h
+++ b/arch/microblaze/include/asm/pgalloc.h
@@ -106,9 +106,6 @@ extern inline void free_pgd_slow(pgd_t *pgd)
106 */ 106 */
107#define pmd_alloc_one_fast(mm, address) ({ BUG(); ((pmd_t *)1); }) 107#define pmd_alloc_one_fast(mm, address) ({ BUG(); ((pmd_t *)1); })
108#define pmd_alloc_one(mm, address) ({ BUG(); ((pmd_t *)2); }) 108#define pmd_alloc_one(mm, address) ({ BUG(); ((pmd_t *)2); })
109/* FIXME two definition - look below */
110#define pmd_free(mm, x) do { } while (0)
111#define pgd_populate(mm, pmd, pte) BUG()
112 109
113static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 110static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
114 unsigned long address) 111 unsigned long address)
@@ -192,14 +189,14 @@ extern inline void pte_free(struct mm_struct *mm, struct page *ptepage)
192 * the pgd will always be present.. 189 * the pgd will always be present..
193 */ 190 */
194#define pmd_alloc_one(mm, address) ({ BUG(); ((pmd_t *)2); }) 191#define pmd_alloc_one(mm, address) ({ BUG(); ((pmd_t *)2); })
195/*#define pmd_free(mm, x) do { } while (0)*/ 192#define pmd_free(mm, x) do { } while (0)
196#define __pmd_free_tlb(tlb, x, addr) do { } while (0) 193#define __pmd_free_tlb(tlb, x, addr) pmd_free((tlb)->mm, x)
197#define pgd_populate(mm, pmd, pte) BUG() 194#define pgd_populate(mm, pmd, pte) BUG()
198 195
199extern int do_check_pgt_cache(int, int); 196extern int do_check_pgt_cache(int, int);
200 197
201#endif /* CONFIG_MMU */ 198#endif /* CONFIG_MMU */
202 199
203#define check_pgt_cache() do {} while (0) 200#define check_pgt_cache() do { } while (0)
204 201
205#endif /* _ASM_MICROBLAZE_PGALLOC_H */ 202#endif /* _ASM_MICROBLAZE_PGALLOC_H */
diff --git a/arch/microblaze/include/asm/pvr.h b/arch/microblaze/include/asm/pvr.h
index 66f1b30dd097..e38abc7714b6 100644
--- a/arch/microblaze/include/asm/pvr.h
+++ b/arch/microblaze/include/asm/pvr.h
@@ -76,20 +76,23 @@ struct pvr_s {
76#define PVR3_FSL_LINKS_MASK 0x00000380 76#define PVR3_FSL_LINKS_MASK 0x00000380
77 77
78/* ICache config PVR masks */ 78/* ICache config PVR masks */
79#define PVR4_USE_ICACHE_MASK 0x80000000 79#define PVR4_USE_ICACHE_MASK 0x80000000 /* ICU */
80#define PVR4_ICACHE_ADDR_TAG_BITS_MASK 0x7C000000 80#define PVR4_ICACHE_ADDR_TAG_BITS_MASK 0x7C000000 /* ICTS */
81#define PVR4_ICACHE_USE_FSL_MASK 0x02000000 81#define PVR4_ICACHE_ALLOW_WR_MASK 0x01000000 /* ICW */
82#define PVR4_ICACHE_ALLOW_WR_MASK 0x01000000 82#define PVR4_ICACHE_LINE_LEN_MASK 0x00E00000 /* ICLL */
83#define PVR4_ICACHE_LINE_LEN_MASK 0x00E00000 83#define PVR4_ICACHE_BYTE_SIZE_MASK 0x001F0000 /* ICBS */
84#define PVR4_ICACHE_BYTE_SIZE_MASK 0x001F0000 84#define PVR4_ICACHE_ALWAYS_USED 0x00008000 /* IAU */
85#define PVR4_ICACHE_INTERFACE 0x00002000 /* ICI */
85 86
86/* DCache config PVR masks */ 87/* DCache config PVR masks */
87#define PVR5_USE_DCACHE_MASK 0x80000000 88#define PVR5_USE_DCACHE_MASK 0x80000000 /* DCU */
88#define PVR5_DCACHE_ADDR_TAG_BITS_MASK 0x7C000000 89#define PVR5_DCACHE_ADDR_TAG_BITS_MASK 0x7C000000 /* DCTS */
89#define PVR5_DCACHE_USE_FSL_MASK 0x02000000 90#define PVR5_DCACHE_ALLOW_WR_MASK 0x01000000 /* DCW */
90#define PVR5_DCACHE_ALLOW_WR_MASK 0x01000000 91#define PVR5_DCACHE_LINE_LEN_MASK 0x00E00000 /* DCLL */
91#define PVR5_DCACHE_LINE_LEN_MASK 0x00E00000 92#define PVR5_DCACHE_BYTE_SIZE_MASK 0x001F0000 /* DCBS */
92#define PVR5_DCACHE_BYTE_SIZE_MASK 0x001F0000 93#define PVR5_DCACHE_ALWAYS_USED 0x00008000 /* DAU */
94#define PVR5_DCACHE_USE_WRITEBACK 0x00004000 /* DWB */
95#define PVR5_DCACHE_INTERFACE 0x00002000 /* DCI */
93 96
94/* ICache base address PVR mask */ 97/* ICache base address PVR mask */
95#define PVR6_ICACHE_BASEADDR_MASK 0xFFFFFFFF 98#define PVR6_ICACHE_BASEADDR_MASK 0xFFFFFFFF
@@ -178,11 +181,14 @@ struct pvr_s {
178 ((pvr.pvr[5] & PVR5_DCACHE_ADDR_TAG_BITS_MASK) >> 26) 181 ((pvr.pvr[5] & PVR5_DCACHE_ADDR_TAG_BITS_MASK) >> 26)
179#define PVR_DCACHE_USE_FSL(pvr) (pvr.pvr[5] & PVR5_DCACHE_USE_FSL_MASK) 182#define PVR_DCACHE_USE_FSL(pvr) (pvr.pvr[5] & PVR5_DCACHE_USE_FSL_MASK)
180#define PVR_DCACHE_ALLOW_WR(pvr) (pvr.pvr[5] & PVR5_DCACHE_ALLOW_WR_MASK) 183#define PVR_DCACHE_ALLOW_WR(pvr) (pvr.pvr[5] & PVR5_DCACHE_ALLOW_WR_MASK)
184/* FIXME two shifts on one line needs any comment */
181#define PVR_DCACHE_LINE_LEN(pvr) \ 185#define PVR_DCACHE_LINE_LEN(pvr) \
182 (1 << ((pvr.pvr[5] & PVR5_DCACHE_LINE_LEN_MASK) >> 21)) 186 (1 << ((pvr.pvr[5] & PVR5_DCACHE_LINE_LEN_MASK) >> 21))
183#define PVR_DCACHE_BYTE_SIZE(pvr) \ 187#define PVR_DCACHE_BYTE_SIZE(pvr) \
184 (1 << ((pvr.pvr[5] & PVR5_DCACHE_BYTE_SIZE_MASK) >> 16)) 188 (1 << ((pvr.pvr[5] & PVR5_DCACHE_BYTE_SIZE_MASK) >> 16))
185 189
190#define PVR_DCACHE_USE_WRITEBACK(pvr) \
191 ((pvr.pvr[5] & PVR5_DCACHE_USE_WRITEBACK) >> 14)
186 192
187#define PVR_ICACHE_BASEADDR(pvr) (pvr.pvr[6] & PVR6_ICACHE_BASEADDR_MASK) 193#define PVR_ICACHE_BASEADDR(pvr) (pvr.pvr[6] & PVR6_ICACHE_BASEADDR_MASK)
188#define PVR_ICACHE_HIGHADDR(pvr) (pvr.pvr[7] & PVR7_ICACHE_HIGHADDR_MASK) 194#define PVR_ICACHE_HIGHADDR(pvr) (pvr.pvr[7] & PVR7_ICACHE_HIGHADDR_MASK)
diff --git a/arch/microblaze/include/asm/setup.h b/arch/microblaze/include/asm/setup.h
index ed67c9ed15b8..7f31394985e0 100644
--- a/arch/microblaze/include/asm/setup.h
+++ b/arch/microblaze/include/asm/setup.h
@@ -35,6 +35,8 @@ extern void mmu_reset(void);
35extern void early_console_reg_tlb_alloc(unsigned int addr); 35extern void early_console_reg_tlb_alloc(unsigned int addr);
36# endif /* CONFIG_MMU */ 36# endif /* CONFIG_MMU */
37 37
38extern void of_platform_reset_gpio_probe(void);
39
38void time_init(void); 40void time_init(void);
39void init_IRQ(void); 41void init_IRQ(void);
40void machine_early_init(const char *cmdline, unsigned int ram, 42void machine_early_init(const char *cmdline, unsigned int ram,
diff --git a/arch/microblaze/include/asm/system.h b/arch/microblaze/include/asm/system.h
index b1ed61590660..157970688b2a 100644
--- a/arch/microblaze/include/asm/system.h
+++ b/arch/microblaze/include/asm/system.h
@@ -16,6 +16,8 @@
16#include <asm-generic/cmpxchg.h> 16#include <asm-generic/cmpxchg.h>
17#include <asm-generic/cmpxchg-local.h> 17#include <asm-generic/cmpxchg-local.h>
18 18
19#define __ARCH_WANT_INTERRUPTS_ON_CTXSW
20
19struct task_struct; 21struct task_struct;
20struct thread_info; 22struct thread_info;
21 23
diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
index 5431b4631a7a..371bd6e56d9a 100644
--- a/arch/microblaze/include/asm/uaccess.h
+++ b/arch/microblaze/include/asm/uaccess.h
@@ -272,8 +272,9 @@ static inline int clear_user(char *to, int size)
272 return size; 272 return size;
273} 273}
274 274
275extern unsigned long __copy_tofrom_user(void __user *to, 275#define __copy_from_user(to, from, n) copy_from_user((to), (from), (n))
276 const void __user *from, unsigned long size); 276#define __copy_from_user_inatomic(to, from, n) \
277 copy_from_user((to), (from), (n))
277 278
278#define copy_to_user(to, from, n) \ 279#define copy_to_user(to, from, n) \
279 (access_ok(VERIFY_WRITE, (to), (n)) ? \ 280 (access_ok(VERIFY_WRITE, (to), (n)) ? \
@@ -290,10 +291,6 @@ extern unsigned long __copy_tofrom_user(void __user *to,
290 (void __user *)(from), (n)) \ 291 (void __user *)(from), (n)) \
291 : -EFAULT) 292 : -EFAULT)
292 293
293#define __copy_from_user(to, from, n) copy_from_user((to), (from), (n))
294#define __copy_from_user_inatomic(to, from, n) \
295 copy_from_user((to), (from), (n))
296
297extern int __strncpy_user(char *to, const char __user *from, int len); 294extern int __strncpy_user(char *to, const char __user *from, int len);
298extern int __strnlen_user(const char __user *sstr, int len); 295extern int __strnlen_user(const char __user *sstr, int len);
299 296
@@ -305,6 +302,9 @@ extern int __strnlen_user(const char __user *sstr, int len);
305 302
306#endif /* CONFIG_MMU */ 303#endif /* CONFIG_MMU */
307 304
305extern unsigned long __copy_tofrom_user(void __user *to,
306 const void __user *from, unsigned long size);
307
308/* 308/*
309 * The exception table consists of pairs of addresses: the first is the 309 * The exception table consists of pairs of addresses: the first is the
310 * address of an instruction that is allowed to fault, and the second is 310 * address of an instruction that is allowed to fault, and the second is
diff --git a/arch/microblaze/kernel/Makefile b/arch/microblaze/kernel/Makefile
index d487729683de..b07594eccf9b 100644
--- a/arch/microblaze/kernel/Makefile
+++ b/arch/microblaze/kernel/Makefile
@@ -2,12 +2,22 @@
2# Makefile 2# Makefile
3# 3#
4 4
5ifdef CONFIG_FUNCTION_TRACER
6# Do not trace early boot code and low level code
7CFLAGS_REMOVE_timer.o = -pg
8CFLAGS_REMOVE_intc.o = -pg
9CFLAGS_REMOVE_early_printk.o = -pg
10CFLAGS_REMOVE_selfmod.o = -pg
11CFLAGS_REMOVE_heartbeat.o = -pg
12CFLAGS_REMOVE_ftrace.o = -pg
13endif
14
5extra-y := head.o vmlinux.lds 15extra-y := head.o vmlinux.lds
6 16
7obj-y += exceptions.o \ 17obj-y += exceptions.o \
8 hw_exception_handler.o init_task.o intc.o irq.o of_device.o \ 18 hw_exception_handler.o init_task.o intc.o irq.o of_device.o \
9 of_platform.o process.o prom.o prom_parse.o ptrace.o \ 19 of_platform.o process.o prom.o prom_parse.o ptrace.o \
10 setup.o signal.o sys_microblaze.o timer.o traps.o 20 setup.o signal.o sys_microblaze.o timer.o traps.o reset.o
11 21
12obj-y += cpu/ 22obj-y += cpu/
13 23
@@ -16,5 +26,7 @@ obj-$(CONFIG_SELFMOD) += selfmod.o
16obj-$(CONFIG_HEART_BEAT) += heartbeat.o 26obj-$(CONFIG_HEART_BEAT) += heartbeat.o
17obj-$(CONFIG_MODULES) += microblaze_ksyms.o module.o 27obj-$(CONFIG_MODULES) += microblaze_ksyms.o module.o
18obj-$(CONFIG_MMU) += misc.o 28obj-$(CONFIG_MMU) += misc.o
29obj-$(CONFIG_STACKTRACE) += stacktrace.o
30obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o mcount.o
19 31
20obj-y += entry$(MMU).o 32obj-y += entry$(MMU).o
diff --git a/arch/microblaze/kernel/cpu/Makefile b/arch/microblaze/kernel/cpu/Makefile
index 20646e549271..59cc7bceaf8c 100644
--- a/arch/microblaze/kernel/cpu/Makefile
+++ b/arch/microblaze/kernel/cpu/Makefile
@@ -2,6 +2,10 @@
2# Build the appropriate CPU version support 2# Build the appropriate CPU version support
3# 3#
4 4
5ifdef CONFIG_FUNCTION_TRACER
6CFLAGS_REMOVE_cache.o = -pg
7endif
8
5EXTRA_CFLAGS += -DCPU_MAJOR=$(CPU_MAJOR) -DCPU_MINOR=$(CPU_MINOR) \ 9EXTRA_CFLAGS += -DCPU_MAJOR=$(CPU_MAJOR) -DCPU_MINOR=$(CPU_MINOR) \
6 -DCPU_REV=$(CPU_REV) 10 -DCPU_REV=$(CPU_REV)
7 11
diff --git a/arch/microblaze/kernel/cpu/cache.c b/arch/microblaze/kernel/cpu/cache.c
index af866a450125..d9d63831cc2f 100644
--- a/arch/microblaze/kernel/cpu/cache.c
+++ b/arch/microblaze/kernel/cpu/cache.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu> 4 * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu>
5 * Copyright (C) 2007-2009 PetaLogix 5 * Copyright (C) 2007-2009 PetaLogix
6 * Copyright (C) 2007 John Williams <john.williams@petalogix.com> 6 * Copyright (C) 2007-2009 John Williams <john.williams@petalogix.com>
7 * 7 *
8 * This file is subject to the terms and conditions of the GNU General 8 * This file is subject to the terms and conditions of the GNU General
9 * Public License. See the file COPYING in the main directory of this 9 * Public License. See the file COPYING in the main directory of this
@@ -13,243 +13,534 @@
13#include <asm/cacheflush.h> 13#include <asm/cacheflush.h>
14#include <linux/cache.h> 14#include <linux/cache.h>
15#include <asm/cpuinfo.h> 15#include <asm/cpuinfo.h>
16#include <asm/pvr.h>
16 17
17/* Exported functions */ 18static inline void __invalidate_flush_icache(unsigned int addr)
19{
20 __asm__ __volatile__ ("wic %0, r0;" \
21 : : "r" (addr));
22}
23
24static inline void __flush_dcache(unsigned int addr)
25{
26 __asm__ __volatile__ ("wdc.flush %0, r0;" \
27 : : "r" (addr));
28}
29
30static inline void __invalidate_dcache(unsigned int baseaddr,
31 unsigned int offset)
32{
33 __asm__ __volatile__ ("wdc.clear %0, %1;" \
34 : : "r" (baseaddr), "r" (offset));
35}
18 36
19void _enable_icache(void) 37static inline void __enable_icache_msr(void)
20{ 38{
21 if (cpuinfo.use_icache) { 39 __asm__ __volatile__ (" msrset r0, %0; \
22#if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR 40 nop; " \
23 __asm__ __volatile__ (" \ 41 : : "i" (MSR_ICE) : "memory");
24 msrset r0, %0; \ 42}
25 nop; " \ 43
26 : \ 44static inline void __disable_icache_msr(void)
27 : "i" (MSR_ICE) \ 45{
46 __asm__ __volatile__ (" msrclr r0, %0; \
47 nop; " \
48 : : "i" (MSR_ICE) : "memory");
49}
50
51static inline void __enable_dcache_msr(void)
52{
53 __asm__ __volatile__ (" msrset r0, %0; \
54 nop; " \
55 : \
56 : "i" (MSR_DCE) \
28 : "memory"); 57 : "memory");
29#else
30 __asm__ __volatile__ (" \
31 mfs r12, rmsr; \
32 nop; \
33 ori r12, r12, %0; \
34 mts rmsr, r12; \
35 nop; " \
36 : \
37 : "i" (MSR_ICE) \
38 : "memory", "r12");
39#endif
40 }
41} 58}
42 59
43void _disable_icache(void) 60static inline void __disable_dcache_msr(void)
44{ 61{
45 if (cpuinfo.use_icache) { 62 __asm__ __volatile__ (" msrclr r0, %0; \
46#if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR 63 nop; " \
47 __asm__ __volatile__ (" \ 64 : \
48 msrclr r0, %0; \ 65 : "i" (MSR_DCE) \
49 nop; " \
50 : \
51 : "i" (MSR_ICE) \
52 : "memory"); 66 : "memory");
53#else 67}
54 __asm__ __volatile__ (" \ 68
55 mfs r12, rmsr; \ 69static inline void __enable_icache_nomsr(void)
56 nop; \ 70{
57 andi r12, r12, ~%0; \ 71 __asm__ __volatile__ (" mfs r12, rmsr; \
58 mts rmsr, r12; \ 72 nop; \
59 nop; " \ 73 ori r12, r12, %0; \
60 : \ 74 mts rmsr, r12; \
61 : "i" (MSR_ICE) \ 75 nop; " \
76 : \
77 : "i" (MSR_ICE) \
62 : "memory", "r12"); 78 : "memory", "r12");
63#endif
64 }
65} 79}
66 80
67void _invalidate_icache(unsigned int addr) 81static inline void __disable_icache_nomsr(void)
68{ 82{
69 if (cpuinfo.use_icache) { 83 __asm__ __volatile__ (" mfs r12, rmsr; \
70 __asm__ __volatile__ (" \ 84 nop; \
71 wic %0, r0" \ 85 andi r12, r12, ~%0; \
72 : \ 86 mts rmsr, r12; \
73 : "r" (addr)); 87 nop; " \
74 } 88 : \
89 : "i" (MSR_ICE) \
90 : "memory", "r12");
75} 91}
76 92
77void _enable_dcache(void) 93static inline void __enable_dcache_nomsr(void)
78{ 94{
79 if (cpuinfo.use_dcache) { 95 __asm__ __volatile__ (" mfs r12, rmsr; \
80#if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR 96 nop; \
81 __asm__ __volatile__ (" \ 97 ori r12, r12, %0; \
82 msrset r0, %0; \ 98 mts rmsr, r12; \
83 nop; " \ 99 nop; " \
84 : \ 100 : \
85 : "i" (MSR_DCE) \ 101 : "i" (MSR_DCE) \
86 : "memory");
87#else
88 __asm__ __volatile__ (" \
89 mfs r12, rmsr; \
90 nop; \
91 ori r12, r12, %0; \
92 mts rmsr, r12; \
93 nop; " \
94 : \
95 : "i" (MSR_DCE) \
96 : "memory", "r12"); 102 : "memory", "r12");
97#endif
98 }
99} 103}
100 104
101void _disable_dcache(void) 105static inline void __disable_dcache_nomsr(void)
102{ 106{
103#if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR 107 __asm__ __volatile__ (" mfs r12, rmsr; \
104 __asm__ __volatile__ (" \ 108 nop; \
105 msrclr r0, %0; \ 109 andi r12, r12, ~%0; \
106 nop; " \ 110 mts rmsr, r12; \
107 : \ 111 nop; " \
108 : "i" (MSR_DCE) \ 112 : \
109 : "memory"); 113 : "i" (MSR_DCE) \
110#else
111 __asm__ __volatile__ (" \
112 mfs r12, rmsr; \
113 nop; \
114 andi r12, r12, ~%0; \
115 mts rmsr, r12; \
116 nop; " \
117 : \
118 : "i" (MSR_DCE) \
119 : "memory", "r12"); 114 : "memory", "r12");
120#endif
121} 115}
122 116
123void _invalidate_dcache(unsigned int addr) 117
118/* Helper macro for computing the limits of cache range loops */
119#define CACHE_LOOP_LIMITS(start, end, cache_line_length, cache_size) \
120do { \
121 int align = ~(cache_line_length - 1); \
122 end = min(start + cache_size, end); \
123 start &= align; \
124 end = ((end & align) + cache_line_length); \
125} while (0);
126
127/*
128 * Helper macro to loop over the specified cache_size/line_length and
129 * execute 'op' on that cacheline
130 */
131#define CACHE_ALL_LOOP(cache_size, line_length, op) \
132do { \
133 unsigned int len = cache_size; \
134 int step = -line_length; \
135 BUG_ON(step >= 0); \
136 \
137 __asm__ __volatile__ (" 1: " #op " %0, r0; \
138 bgtid %0, 1b; \
139 addk %0, %0, %1; \
140 " : : "r" (len), "r" (step) \
141 : "memory"); \
142} while (0);
143
144
145#define CACHE_ALL_LOOP2(cache_size, line_length, op) \
146do { \
147 unsigned int len = cache_size; \
148 int step = -line_length; \
149 BUG_ON(step >= 0); \
150 \
151 __asm__ __volatile__ (" 1: " #op " r0, %0; \
152 bgtid %0, 1b; \
153 addk %0, %0, %1; \
154 " : : "r" (len), "r" (step) \
155 : "memory"); \
156} while (0);
157
158/* for wdc.flush/clear */
159#define CACHE_RANGE_LOOP_2(start, end, line_length, op) \
160do { \
161 int step = -line_length; \
162 int count = end - start; \
163 BUG_ON(count <= 0); \
164 \
165 __asm__ __volatile__ (" 1: " #op " %0, %1; \
166 bgtid %1, 1b; \
167 addk %1, %1, %2; \
168 " : : "r" (start), "r" (count), \
169 "r" (step) : "memory"); \
170} while (0);
171
172/* It is used only first parameter for OP - for wic, wdc */
173#define CACHE_RANGE_LOOP_1(start, end, line_length, op) \
174do { \
175 int step = -line_length; \
176 int count = end - start; \
177 BUG_ON(count <= 0); \
178 \
179 __asm__ __volatile__ (" 1: addk %0, %0, %1; \
180 " #op " %0, r0; \
181 bgtid %1, 1b; \
182 addk %1, %1, %2; \
183 " : : "r" (start), "r" (count), \
184 "r" (step) : "memory"); \
185} while (0);
186
187static void __flush_icache_range_msr_irq(unsigned long start, unsigned long end)
124{ 188{
125 __asm__ __volatile__ (" \ 189 unsigned long flags;
126 wdc %0, r0" \ 190
127 : \ 191 pr_debug("%s: start 0x%x, end 0x%x\n", __func__,
128 : "r" (addr)); 192 (unsigned int)start, (unsigned int) end);
193
194 CACHE_LOOP_LIMITS(start, end,
195 cpuinfo.icache_line_length, cpuinfo.icache_size);
196
197 local_irq_save(flags);
198 __disable_icache_msr();
199
200 CACHE_RANGE_LOOP_1(start, end, cpuinfo.icache_line_length, wic);
201
202 __enable_icache_msr();
203 local_irq_restore(flags);
129} 204}
130 205
131void __invalidate_icache_all(void) 206static void __flush_icache_range_nomsr_irq(unsigned long start,
207 unsigned long end)
132{ 208{
133 unsigned int i; 209 unsigned long flags;
134 unsigned flags;
135 210
136 if (cpuinfo.use_icache) { 211 pr_debug("%s: start 0x%x, end 0x%x\n", __func__,
137 local_irq_save(flags); 212 (unsigned int)start, (unsigned int) end);
138 __disable_icache();
139 213
140 /* Just loop through cache size and invalidate, no need to add 214 CACHE_LOOP_LIMITS(start, end,
141 CACHE_BASE address */ 215 cpuinfo.icache_line_length, cpuinfo.icache_size);
142 for (i = 0; i < cpuinfo.icache_size;
143 i += cpuinfo.icache_line)
144 __invalidate_icache(i);
145 216
146 __enable_icache(); 217 local_irq_save(flags);
147 local_irq_restore(flags); 218 __disable_icache_nomsr();
148 } 219
220 CACHE_RANGE_LOOP_1(start, end, cpuinfo.icache_line_length, wic);
221
222 __enable_icache_nomsr();
223 local_irq_restore(flags);
149} 224}
150 225
151void __invalidate_icache_range(unsigned long start, unsigned long end) 226static void __flush_icache_range_noirq(unsigned long start,
227 unsigned long end)
152{ 228{
153 unsigned int i; 229 pr_debug("%s: start 0x%x, end 0x%x\n", __func__,
154 unsigned flags; 230 (unsigned int)start, (unsigned int) end);
155 unsigned int align; 231
156 232 CACHE_LOOP_LIMITS(start, end,
157 if (cpuinfo.use_icache) { 233 cpuinfo.icache_line_length, cpuinfo.icache_size);
158 /* 234 CACHE_RANGE_LOOP_1(start, end, cpuinfo.icache_line_length, wic);
159 * No need to cover entire cache range, 235}
160 * just cover cache footprint 236
161 */ 237static void __flush_icache_all_msr_irq(void)
162 end = min(start + cpuinfo.icache_size, end); 238{
163 align = ~(cpuinfo.icache_line - 1); 239 unsigned long flags;
164 start &= align; /* Make sure we are aligned */ 240
165 /* Push end up to the next cache line */ 241 pr_debug("%s\n", __func__);
166 end = ((end & align) + cpuinfo.icache_line); 242
167 243 local_irq_save(flags);
168 local_irq_save(flags); 244 __disable_icache_msr();
169 __disable_icache(); 245
170 246 CACHE_ALL_LOOP(cpuinfo.icache_size, cpuinfo.icache_line_length, wic);
171 for (i = start; i < end; i += cpuinfo.icache_line) 247
172 __invalidate_icache(i); 248 __enable_icache_msr();
173 249 local_irq_restore(flags);
174 __enable_icache(); 250}
175 local_irq_restore(flags); 251
176 } 252static void __flush_icache_all_nomsr_irq(void)
253{
254 unsigned long flags;
255
256 pr_debug("%s\n", __func__);
257
258 local_irq_save(flags);
259 __disable_icache_nomsr();
260
261 CACHE_ALL_LOOP(cpuinfo.icache_size, cpuinfo.icache_line_length, wic);
262
263 __enable_icache_nomsr();
264 local_irq_restore(flags);
177} 265}
178 266
179void __invalidate_icache_page(struct vm_area_struct *vma, struct page *page) 267static void __flush_icache_all_noirq(void)
180{ 268{
181 __invalidate_icache_all(); 269 pr_debug("%s\n", __func__);
270 CACHE_ALL_LOOP(cpuinfo.icache_size, cpuinfo.icache_line_length, wic);
182} 271}
183 272
184void __invalidate_icache_user_range(struct vm_area_struct *vma, 273static void __invalidate_dcache_all_msr_irq(void)
185 struct page *page, unsigned long adr,
186 int len)
187{ 274{
188 __invalidate_icache_all(); 275 unsigned long flags;
276
277 pr_debug("%s\n", __func__);
278
279 local_irq_save(flags);
280 __disable_dcache_msr();
281
282 CACHE_ALL_LOOP(cpuinfo.dcache_size, cpuinfo.dcache_line_length, wdc);
283
284 __enable_dcache_msr();
285 local_irq_restore(flags);
189} 286}
190 287
191void __invalidate_cache_sigtramp(unsigned long addr) 288static void __invalidate_dcache_all_nomsr_irq(void)
192{ 289{
193 __invalidate_icache_range(addr, addr + 8); 290 unsigned long flags;
291
292 pr_debug("%s\n", __func__);
293
294 local_irq_save(flags);
295 __disable_dcache_nomsr();
296
297 CACHE_ALL_LOOP(cpuinfo.dcache_size, cpuinfo.dcache_line_length, wdc);
298
299 __enable_dcache_nomsr();
300 local_irq_restore(flags);
194} 301}
195 302
196void __invalidate_dcache_all(void) 303static void __invalidate_dcache_all_noirq_wt(void)
197{ 304{
198 unsigned int i; 305 pr_debug("%s\n", __func__);
199 unsigned flags; 306 CACHE_ALL_LOOP(cpuinfo.dcache_size, cpuinfo.dcache_line_length, wdc)
200
201 if (cpuinfo.use_dcache) {
202 local_irq_save(flags);
203 __disable_dcache();
204
205 /*
206 * Just loop through cache size and invalidate,
207 * no need to add CACHE_BASE address
208 */
209 for (i = 0; i < cpuinfo.dcache_size;
210 i += cpuinfo.dcache_line)
211 __invalidate_dcache(i);
212
213 __enable_dcache();
214 local_irq_restore(flags);
215 }
216} 307}
217 308
218void __invalidate_dcache_range(unsigned long start, unsigned long end) 309/* FIXME this is weird - should be only wdc but not work
310 * MS: I am getting bus errors and other weird things */
311static void __invalidate_dcache_all_wb(void)
219{ 312{
313 pr_debug("%s\n", __func__);
314 CACHE_ALL_LOOP2(cpuinfo.dcache_size, cpuinfo.dcache_line_length,
315 wdc.clear)
316
317#if 0
220 unsigned int i; 318 unsigned int i;
221 unsigned flags; 319
222 unsigned int align; 320 pr_debug("%s\n", __func__);
223 321
224 if (cpuinfo.use_dcache) { 322 /* Just loop through cache size and invalidate it */
225 /* 323 for (i = 0; i < cpuinfo.dcache_size; i += cpuinfo.dcache_line_length)
226 * No need to cover entire cache range, 324 __invalidate_dcache(0, i);
227 * just cover cache footprint 325#endif
228 */ 326}
229 end = min(start + cpuinfo.dcache_size, end); 327
230 align = ~(cpuinfo.dcache_line - 1); 328static void __invalidate_dcache_range_wb(unsigned long start,
231 start &= align; /* Make sure we are aligned */ 329 unsigned long end)
232 /* Push end up to the next cache line */ 330{
233 end = ((end & align) + cpuinfo.dcache_line); 331 pr_debug("%s: start 0x%x, end 0x%x\n", __func__,
234 local_irq_save(flags); 332 (unsigned int)start, (unsigned int) end);
235 __disable_dcache(); 333
236 334 CACHE_LOOP_LIMITS(start, end,
237 for (i = start; i < end; i += cpuinfo.dcache_line) 335 cpuinfo.dcache_line_length, cpuinfo.dcache_size);
238 __invalidate_dcache(i); 336 CACHE_RANGE_LOOP_2(start, end, cpuinfo.dcache_line_length, wdc.clear);
239 337}
240 __enable_dcache(); 338
241 local_irq_restore(flags); 339static void __invalidate_dcache_range_nomsr_wt(unsigned long start,
242 } 340 unsigned long end)
341{
342 pr_debug("%s: start 0x%x, end 0x%x\n", __func__,
343 (unsigned int)start, (unsigned int) end);
344 CACHE_LOOP_LIMITS(start, end,
345 cpuinfo.dcache_line_length, cpuinfo.dcache_size);
346
347 CACHE_RANGE_LOOP_1(start, end, cpuinfo.dcache_line_length, wdc);
243} 348}
244 349
245void __invalidate_dcache_page(struct vm_area_struct *vma, struct page *page) 350static void __invalidate_dcache_range_msr_irq_wt(unsigned long start,
351 unsigned long end)
246{ 352{
247 __invalidate_dcache_all(); 353 unsigned long flags;
354
355 pr_debug("%s: start 0x%x, end 0x%x\n", __func__,
356 (unsigned int)start, (unsigned int) end);
357 CACHE_LOOP_LIMITS(start, end,
358 cpuinfo.dcache_line_length, cpuinfo.dcache_size);
359
360 local_irq_save(flags);
361 __disable_dcache_msr();
362
363 CACHE_RANGE_LOOP_1(start, end, cpuinfo.dcache_line_length, wdc);
364
365 __enable_dcache_msr();
366 local_irq_restore(flags);
367}
368
369static void __invalidate_dcache_range_nomsr_irq(unsigned long start,
370 unsigned long end)
371{
372 unsigned long flags;
373
374 pr_debug("%s: start 0x%x, end 0x%x\n", __func__,
375 (unsigned int)start, (unsigned int) end);
376
377 CACHE_LOOP_LIMITS(start, end,
378 cpuinfo.dcache_line_length, cpuinfo.dcache_size);
379
380 local_irq_save(flags);
381 __disable_dcache_nomsr();
382
383 CACHE_RANGE_LOOP_1(start, end, cpuinfo.dcache_line_length, wdc);
384
385 __enable_dcache_nomsr();
386 local_irq_restore(flags);
387}
388
389static void __flush_dcache_all_wb(void)
390{
391 pr_debug("%s\n", __func__);
392 CACHE_ALL_LOOP(cpuinfo.dcache_size, cpuinfo.dcache_line_length,
393 wdc.flush);
248} 394}
249 395
250void __invalidate_dcache_user_range(struct vm_area_struct *vma, 396static void __flush_dcache_range_wb(unsigned long start, unsigned long end)
251 struct page *page, unsigned long adr,
252 int len)
253{ 397{
254 __invalidate_dcache_all(); 398 pr_debug("%s: start 0x%x, end 0x%x\n", __func__,
399 (unsigned int)start, (unsigned int) end);
400
401 CACHE_LOOP_LIMITS(start, end,
402 cpuinfo.dcache_line_length, cpuinfo.dcache_size);
403 CACHE_RANGE_LOOP_2(start, end, cpuinfo.dcache_line_length, wdc.flush);
404}
405
406/* struct for wb caches and for wt caches */
407struct scache *mbc;
408
409/* new wb cache model */
410const struct scache wb_msr = {
411 .ie = __enable_icache_msr,
412 .id = __disable_icache_msr,
413 .ifl = __flush_icache_all_noirq,
414 .iflr = __flush_icache_range_noirq,
415 .iin = __flush_icache_all_noirq,
416 .iinr = __flush_icache_range_noirq,
417 .de = __enable_dcache_msr,
418 .dd = __disable_dcache_msr,
419 .dfl = __flush_dcache_all_wb,
420 .dflr = __flush_dcache_range_wb,
421 .din = __invalidate_dcache_all_wb,
422 .dinr = __invalidate_dcache_range_wb,
423};
424
425/* There is only difference in ie, id, de, dd functions */
426const struct scache wb_nomsr = {
427 .ie = __enable_icache_nomsr,
428 .id = __disable_icache_nomsr,
429 .ifl = __flush_icache_all_noirq,
430 .iflr = __flush_icache_range_noirq,
431 .iin = __flush_icache_all_noirq,
432 .iinr = __flush_icache_range_noirq,
433 .de = __enable_dcache_nomsr,
434 .dd = __disable_dcache_nomsr,
435 .dfl = __flush_dcache_all_wb,
436 .dflr = __flush_dcache_range_wb,
437 .din = __invalidate_dcache_all_wb,
438 .dinr = __invalidate_dcache_range_wb,
439};
440
441/* Old wt cache model with disabling irq and turn off cache */
442const struct scache wt_msr = {
443 .ie = __enable_icache_msr,
444 .id = __disable_icache_msr,
445 .ifl = __flush_icache_all_msr_irq,
446 .iflr = __flush_icache_range_msr_irq,
447 .iin = __flush_icache_all_msr_irq,
448 .iinr = __flush_icache_range_msr_irq,
449 .de = __enable_dcache_msr,
450 .dd = __disable_dcache_msr,
451 .dfl = __invalidate_dcache_all_msr_irq,
452 .dflr = __invalidate_dcache_range_msr_irq_wt,
453 .din = __invalidate_dcache_all_msr_irq,
454 .dinr = __invalidate_dcache_range_msr_irq_wt,
455};
456
457const struct scache wt_nomsr = {
458 .ie = __enable_icache_nomsr,
459 .id = __disable_icache_nomsr,
460 .ifl = __flush_icache_all_nomsr_irq,
461 .iflr = __flush_icache_range_nomsr_irq,
462 .iin = __flush_icache_all_nomsr_irq,
463 .iinr = __flush_icache_range_nomsr_irq,
464 .de = __enable_dcache_nomsr,
465 .dd = __disable_dcache_nomsr,
466 .dfl = __invalidate_dcache_all_nomsr_irq,
467 .dflr = __invalidate_dcache_range_nomsr_irq,
468 .din = __invalidate_dcache_all_nomsr_irq,
469 .dinr = __invalidate_dcache_range_nomsr_irq,
470};
471
472/* New wt cache model for newer Microblaze versions */
473const struct scache wt_msr_noirq = {
474 .ie = __enable_icache_msr,
475 .id = __disable_icache_msr,
476 .ifl = __flush_icache_all_noirq,
477 .iflr = __flush_icache_range_noirq,
478 .iin = __flush_icache_all_noirq,
479 .iinr = __flush_icache_range_noirq,
480 .de = __enable_dcache_msr,
481 .dd = __disable_dcache_msr,
482 .dfl = __invalidate_dcache_all_noirq_wt,
483 .dflr = __invalidate_dcache_range_nomsr_wt,
484 .din = __invalidate_dcache_all_noirq_wt,
485 .dinr = __invalidate_dcache_range_nomsr_wt,
486};
487
488const struct scache wt_nomsr_noirq = {
489 .ie = __enable_icache_nomsr,
490 .id = __disable_icache_nomsr,
491 .ifl = __flush_icache_all_noirq,
492 .iflr = __flush_icache_range_noirq,
493 .iin = __flush_icache_all_noirq,
494 .iinr = __flush_icache_range_noirq,
495 .de = __enable_dcache_nomsr,
496 .dd = __disable_dcache_nomsr,
497 .dfl = __invalidate_dcache_all_noirq_wt,
498 .dflr = __invalidate_dcache_range_nomsr_wt,
499 .din = __invalidate_dcache_all_noirq_wt,
500 .dinr = __invalidate_dcache_range_nomsr_wt,
501};
502
503/* CPU version code for 7.20.c - see arch/microblaze/kernel/cpu/cpuinfo.c */
504#define CPUVER_7_20_A 0x0c
505#define CPUVER_7_20_D 0x0f
506
507#define INFO(s) printk(KERN_INFO "cache: " s " \n");
508
509void microblaze_cache_init(void)
510{
511 if (cpuinfo.use_instr & PVR2_USE_MSR_INSTR) {
512 if (cpuinfo.dcache_wb) {
513 INFO("wb_msr");
514 mbc = (struct scache *)&wb_msr;
515 if (cpuinfo.ver_code < CPUVER_7_20_D) {
516 /* MS: problem with signal handling - hw bug */
517 INFO("WB won't work properly");
518 }
519 } else {
520 if (cpuinfo.ver_code >= CPUVER_7_20_A) {
521 INFO("wt_msr_noirq");
522 mbc = (struct scache *)&wt_msr_noirq;
523 } else {
524 INFO("wt_msr");
525 mbc = (struct scache *)&wt_msr;
526 }
527 }
528 } else {
529 if (cpuinfo.dcache_wb) {
530 INFO("wb_nomsr");
531 mbc = (struct scache *)&wb_nomsr;
532 if (cpuinfo.ver_code < CPUVER_7_20_D) {
533 /* MS: problem with signal handling - hw bug */
534 INFO("WB won't work properly");
535 }
536 } else {
537 if (cpuinfo.ver_code >= CPUVER_7_20_A) {
538 INFO("wt_nomsr_noirq");
539 mbc = (struct scache *)&wt_nomsr_noirq;
540 } else {
541 INFO("wt_nomsr");
542 mbc = (struct scache *)&wt_nomsr;
543 }
544 }
545 }
255} 546}
diff --git a/arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c b/arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c
index c259786e7faa..f72dbd66c844 100644
--- a/arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c
+++ b/arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c
@@ -21,8 +21,14 @@
21 */ 21 */
22 22
23#define CI(c, p) { ci->c = PVR_##p(pvr); } 23#define CI(c, p) { ci->c = PVR_##p(pvr); }
24
25#if defined(CONFIG_EARLY_PRINTK) && defined(CONFIG_SERIAL_UARTLITE_CONSOLE)
24#define err_printk(x) \ 26#define err_printk(x) \
25 early_printk("ERROR: Microblaze " x "-different for PVR and DTS\n"); 27 early_printk("ERROR: Microblaze " x "-different for PVR and DTS\n");
28#else
29#define err_printk(x) \
30 printk(KERN_INFO "ERROR: Microblaze " x "-different for PVR and DTS\n");
31#endif
26 32
27void set_cpuinfo_pvr_full(struct cpuinfo *ci, struct device_node *cpu) 33void set_cpuinfo_pvr_full(struct cpuinfo *ci, struct device_node *cpu)
28{ 34{
@@ -70,7 +76,7 @@ void set_cpuinfo_pvr_full(struct cpuinfo *ci, struct device_node *cpu)
70 CI(use_icache, USE_ICACHE); 76 CI(use_icache, USE_ICACHE);
71 CI(icache_tagbits, ICACHE_ADDR_TAG_BITS); 77 CI(icache_tagbits, ICACHE_ADDR_TAG_BITS);
72 CI(icache_write, ICACHE_ALLOW_WR); 78 CI(icache_write, ICACHE_ALLOW_WR);
73 CI(icache_line, ICACHE_LINE_LEN); 79 ci->icache_line_length = PVR_ICACHE_LINE_LEN(pvr) << 2;
74 CI(icache_size, ICACHE_BYTE_SIZE); 80 CI(icache_size, ICACHE_BYTE_SIZE);
75 CI(icache_base, ICACHE_BASEADDR); 81 CI(icache_base, ICACHE_BASEADDR);
76 CI(icache_high, ICACHE_HIGHADDR); 82 CI(icache_high, ICACHE_HIGHADDR);
@@ -78,11 +84,16 @@ void set_cpuinfo_pvr_full(struct cpuinfo *ci, struct device_node *cpu)
78 CI(use_dcache, USE_DCACHE); 84 CI(use_dcache, USE_DCACHE);
79 CI(dcache_tagbits, DCACHE_ADDR_TAG_BITS); 85 CI(dcache_tagbits, DCACHE_ADDR_TAG_BITS);
80 CI(dcache_write, DCACHE_ALLOW_WR); 86 CI(dcache_write, DCACHE_ALLOW_WR);
81 CI(dcache_line, DCACHE_LINE_LEN); 87 ci->dcache_line_length = PVR_DCACHE_LINE_LEN(pvr) << 2;
82 CI(dcache_size, DCACHE_BYTE_SIZE); 88 CI(dcache_size, DCACHE_BYTE_SIZE);
83 CI(dcache_base, DCACHE_BASEADDR); 89 CI(dcache_base, DCACHE_BASEADDR);
84 CI(dcache_high, DCACHE_HIGHADDR); 90 CI(dcache_high, DCACHE_HIGHADDR);
85 91
92 temp = PVR_DCACHE_USE_WRITEBACK(pvr);
93 if (ci->dcache_wb != temp)
94 err_printk("DCACHE WB");
95 ci->dcache_wb = temp;
96
86 CI(use_dopb, D_OPB); 97 CI(use_dopb, D_OPB);
87 CI(use_iopb, I_OPB); 98 CI(use_iopb, I_OPB);
88 CI(use_dlmb, D_LMB); 99 CI(use_dlmb, D_LMB);
diff --git a/arch/microblaze/kernel/cpu/cpuinfo-static.c b/arch/microblaze/kernel/cpu/cpuinfo-static.c
index adb448f93d5f..6095aa6b5c88 100644
--- a/arch/microblaze/kernel/cpu/cpuinfo-static.c
+++ b/arch/microblaze/kernel/cpu/cpuinfo-static.c
@@ -72,12 +72,12 @@ void __init set_cpuinfo_static(struct cpuinfo *ci, struct device_node *cpu)
72 ci->use_icache = fcpu(cpu, "xlnx,use-icache"); 72 ci->use_icache = fcpu(cpu, "xlnx,use-icache");
73 ci->icache_tagbits = fcpu(cpu, "xlnx,addr-tag-bits"); 73 ci->icache_tagbits = fcpu(cpu, "xlnx,addr-tag-bits");
74 ci->icache_write = fcpu(cpu, "xlnx,allow-icache-wr"); 74 ci->icache_write = fcpu(cpu, "xlnx,allow-icache-wr");
75 ci->icache_line = fcpu(cpu, "xlnx,icache-line-len") << 2; 75 ci->icache_line_length = fcpu(cpu, "xlnx,icache-line-len") << 2;
76 if (!ci->icache_line) { 76 if (!ci->icache_line_length) {
77 if (fcpu(cpu, "xlnx,icache-use-fsl")) 77 if (fcpu(cpu, "xlnx,icache-use-fsl"))
78 ci->icache_line = 4 << 2; 78 ci->icache_line_length = 4 << 2;
79 else 79 else
80 ci->icache_line = 1 << 2; 80 ci->icache_line_length = 1 << 2;
81 } 81 }
82 ci->icache_size = fcpu(cpu, "i-cache-size"); 82 ci->icache_size = fcpu(cpu, "i-cache-size");
83 ci->icache_base = fcpu(cpu, "i-cache-baseaddr"); 83 ci->icache_base = fcpu(cpu, "i-cache-baseaddr");
@@ -86,16 +86,17 @@ void __init set_cpuinfo_static(struct cpuinfo *ci, struct device_node *cpu)
86 ci->use_dcache = fcpu(cpu, "xlnx,use-dcache"); 86 ci->use_dcache = fcpu(cpu, "xlnx,use-dcache");
87 ci->dcache_tagbits = fcpu(cpu, "xlnx,dcache-addr-tag"); 87 ci->dcache_tagbits = fcpu(cpu, "xlnx,dcache-addr-tag");
88 ci->dcache_write = fcpu(cpu, "xlnx,allow-dcache-wr"); 88 ci->dcache_write = fcpu(cpu, "xlnx,allow-dcache-wr");
89 ci->dcache_line = fcpu(cpu, "xlnx,dcache-line-len") << 2; 89 ci->dcache_line_length = fcpu(cpu, "xlnx,dcache-line-len") << 2;
90 if (!ci->dcache_line) { 90 if (!ci->dcache_line_length) {
91 if (fcpu(cpu, "xlnx,dcache-use-fsl")) 91 if (fcpu(cpu, "xlnx,dcache-use-fsl"))
92 ci->dcache_line = 4 << 2; 92 ci->dcache_line_length = 4 << 2;
93 else 93 else
94 ci->dcache_line = 1 << 2; 94 ci->dcache_line_length = 1 << 2;
95 } 95 }
96 ci->dcache_size = fcpu(cpu, "d-cache-size"); 96 ci->dcache_size = fcpu(cpu, "d-cache-size");
97 ci->dcache_base = fcpu(cpu, "d-cache-baseaddr"); 97 ci->dcache_base = fcpu(cpu, "d-cache-baseaddr");
98 ci->dcache_high = fcpu(cpu, "d-cache-highaddr"); 98 ci->dcache_high = fcpu(cpu, "d-cache-highaddr");
99 ci->dcache_wb = fcpu(cpu, "xlnx,dcache-use-writeback");
99 100
100 ci->use_dopb = fcpu(cpu, "xlnx,d-opb"); 101 ci->use_dopb = fcpu(cpu, "xlnx,d-opb");
101 ci->use_iopb = fcpu(cpu, "xlnx,i-opb"); 102 ci->use_iopb = fcpu(cpu, "xlnx,i-opb");
diff --git a/arch/microblaze/kernel/cpu/cpuinfo.c b/arch/microblaze/kernel/cpu/cpuinfo.c
index 3539babc1c18..991d71311b0e 100644
--- a/arch/microblaze/kernel/cpu/cpuinfo.c
+++ b/arch/microblaze/kernel/cpu/cpuinfo.c
@@ -29,11 +29,8 @@ const struct cpu_ver_key cpu_ver_lookup[] = {
29 {"7.20.a", 0x0c}, 29 {"7.20.a", 0x0c},
30 {"7.20.b", 0x0d}, 30 {"7.20.b", 0x0d},
31 {"7.20.c", 0x0e}, 31 {"7.20.c", 0x0e},
32 /* FIXME There is no keycode defined in MBV for these versions */ 32 {"7.20.d", 0x0f},
33 {"2.10.a", 0x10}, 33 {"7.30.a", 0x10},
34 {"3.00.a", 0x20},
35 {"4.00.a", 0x30},
36 {"4.00.b", 0x40},
37 {NULL, 0}, 34 {NULL, 0},
38}; 35};
39 36
diff --git a/arch/microblaze/kernel/cpu/mb.c b/arch/microblaze/kernel/cpu/mb.c
index 4dcfccdbc364..0c912b2a8e03 100644
--- a/arch/microblaze/kernel/cpu/mb.c
+++ b/arch/microblaze/kernel/cpu/mb.c
@@ -103,11 +103,15 @@ static int show_cpuinfo(struct seq_file *m, void *v)
103 else 103 else
104 count += seq_printf(m, "Icache:\t\tno\n"); 104 count += seq_printf(m, "Icache:\t\tno\n");
105 105
106 if (cpuinfo.use_dcache) 106 if (cpuinfo.use_dcache) {
107 count += seq_printf(m, 107 count += seq_printf(m,
108 "Dcache:\t\t%ukB\n", 108 "Dcache:\t\t%ukB\n",
109 cpuinfo.dcache_size >> 10); 109 cpuinfo.dcache_size >> 10);
110 else 110 if (cpuinfo.dcache_wb)
111 count += seq_printf(m, "\t\twrite-back\n");
112 else
113 count += seq_printf(m, "\t\twrite-through\n");
114 } else
111 count += seq_printf(m, "Dcache:\t\tno\n"); 115 count += seq_printf(m, "Dcache:\t\tno\n");
112 116
113 count += seq_printf(m, 117 count += seq_printf(m,
diff --git a/arch/microblaze/kernel/cpu/pvr.c b/arch/microblaze/kernel/cpu/pvr.c
index c9a4340ddd53..9bee9382bf74 100644
--- a/arch/microblaze/kernel/cpu/pvr.c
+++ b/arch/microblaze/kernel/cpu/pvr.c
@@ -45,7 +45,7 @@
45 45
46int cpu_has_pvr(void) 46int cpu_has_pvr(void)
47{ 47{
48 unsigned flags; 48 unsigned long flags;
49 unsigned pvr0; 49 unsigned pvr0;
50 50
51 local_save_flags(flags); 51 local_save_flags(flags);
diff --git a/arch/microblaze/kernel/entry-nommu.S b/arch/microblaze/kernel/entry-nommu.S
index 9083d85376a4..95b0855802df 100644
--- a/arch/microblaze/kernel/entry-nommu.S
+++ b/arch/microblaze/kernel/entry-nommu.S
@@ -208,8 +208,6 @@ ENTRY(_user_exception)
208 lwi r1, r1, TS_THREAD_INFO /* get the thread info */ 208 lwi r1, r1, TS_THREAD_INFO /* get the thread info */
209 /* calculate kernel stack pointer */ 209 /* calculate kernel stack pointer */
210 addik r1, r1, THREAD_SIZE - PT_SIZE 210 addik r1, r1, THREAD_SIZE - PT_SIZE
211 swi r11, r0, PER_CPU(R11_SAVE) /* temporarily save r11 */
212 lwi r11, r0, PER_CPU(KM) /* load mode indicator */
2132: 2112:
214 swi r11, r1, PT_MODE /* store the mode */ 212 swi r11, r1, PT_MODE /* store the mode */
215 lwi r11, r0, PER_CPU(R11_SAVE) /* reload r11 */ 213 lwi r11, r0, PER_CPU(R11_SAVE) /* reload r11 */
diff --git a/arch/microblaze/kernel/entry.S b/arch/microblaze/kernel/entry.S
index e3ecb36dd554..3bad4ff49471 100644
--- a/arch/microblaze/kernel/entry.S
+++ b/arch/microblaze/kernel/entry.S
@@ -31,6 +31,8 @@
31#include <linux/errno.h> 31#include <linux/errno.h>
32#include <asm/signal.h> 32#include <asm/signal.h>
33 33
34#undef DEBUG
35
34/* The size of a state save frame. */ 36/* The size of a state save frame. */
35#define STATE_SAVE_SIZE (PT_SIZE + STATE_SAVE_ARG_SPACE) 37#define STATE_SAVE_SIZE (PT_SIZE + STATE_SAVE_ARG_SPACE)
36 38
@@ -352,10 +354,12 @@ C_ENTRY(_user_exception):
352 add r12, r12, r12; /* convert num -> ptr */ 354 add r12, r12, r12; /* convert num -> ptr */
353 add r12, r12, r12; 355 add r12, r12, r12;
354 356
357#ifdef DEBUG
355 /* Trac syscalls and stored them to r0_ram */ 358 /* Trac syscalls and stored them to r0_ram */
356 lwi r3, r12, 0x400 + r0_ram 359 lwi r3, r12, 0x400 + r0_ram
357 addi r3, r3, 1 360 addi r3, r3, 1
358 swi r3, r12, 0x400 + r0_ram 361 swi r3, r12, 0x400 + r0_ram
362#endif
359 363
360 # Find and jump into the syscall handler. 364 # Find and jump into the syscall handler.
361 lwi r12, r12, sys_call_table 365 lwi r12, r12, sys_call_table
@@ -496,17 +500,6 @@ C_ENTRY(sys_execve):
496 brid microblaze_execve; /* Do real work (tail-call).*/ 500 brid microblaze_execve; /* Do real work (tail-call).*/
497 nop; 501 nop;
498 502
499C_ENTRY(sys_rt_sigsuspend_wrapper):
500 swi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */
501 swi r4, r1, PTO+PT_R4;
502 la r7, r1, PTO; /* add user context as 3rd arg */
503 brlid r15, sys_rt_sigsuspend; /* Do real work.*/
504 nop;
505 lwi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */
506 lwi r4, r1, PTO+PT_R4;
507 bri ret_from_trap /* fall through will not work here due to align */
508 nop;
509
510C_ENTRY(sys_rt_sigreturn_wrapper): 503C_ENTRY(sys_rt_sigreturn_wrapper):
511 swi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */ 504 swi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */
512 swi r4, r1, PTO+PT_R4; 505 swi r4, r1, PTO+PT_R4;
@@ -711,15 +704,11 @@ C_ENTRY(ret_from_exc):
711 * (in a possibly modified form) after do_signal returns. 704 * (in a possibly modified form) after do_signal returns.
712 * store return registers separately because this macros is use 705 * store return registers separately because this macros is use
713 * for others exceptions */ 706 * for others exceptions */
714 swi r3, r1, PTO + PT_R3;
715 swi r4, r1, PTO + PT_R4;
716 la r5, r1, PTO; /* Arg 1: struct pt_regs *regs */ 707 la r5, r1, PTO; /* Arg 1: struct pt_regs *regs */
717 add r6, r0, r0; /* Arg 2: sigset_t *oldset */ 708 add r6, r0, r0; /* Arg 2: sigset_t *oldset */
718 addi r7, r0, 0; /* Arg 3: int in_syscall */ 709 addi r7, r0, 0; /* Arg 3: int in_syscall */
719 bralid r15, do_signal; /* Handle any signals */ 710 bralid r15, do_signal; /* Handle any signals */
720 nop; 711 nop;
721 lwi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */
722 lwi r4, r1, PTO+PT_R4;
723 712
724/* Finally, return to user state. */ 713/* Finally, return to user state. */
7251: swi r0, r0, PER_CPU(KM); /* Now officially in user state. */ 7141: swi r0, r0, PER_CPU(KM); /* Now officially in user state. */
diff --git a/arch/microblaze/kernel/ftrace.c b/arch/microblaze/kernel/ftrace.c
new file mode 100644
index 000000000000..388b31ca65a1
--- /dev/null
+++ b/arch/microblaze/kernel/ftrace.c
@@ -0,0 +1,237 @@
1/*
2 * Ftrace support for Microblaze.
3 *
4 * Copyright (C) 2009 Michal Simek <monstr@monstr.eu>
5 * Copyright (C) 2009 PetaLogix
6 *
7 * Based on MIPS and PowerPC ftrace code
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 */
13
14#include <asm/cacheflush.h>
15#include <linux/ftrace.h>
16
17#ifdef CONFIG_FUNCTION_GRAPH_TRACER
18/*
19 * Hook the return address and push it in the stack of return addrs
20 * in current thread info.
21 */
22void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
23{
24 unsigned long old;
25 int faulted, err;
26 struct ftrace_graph_ent trace;
27 unsigned long return_hooker = (unsigned long)
28 &return_to_handler;
29
30 if (unlikely(atomic_read(&current->tracing_graph_pause)))
31 return;
32
33 /*
34 * Protect against fault, even if it shouldn't
35 * happen. This tool is too much intrusive to
36 * ignore such a protection.
37 */
38 asm volatile(" 1: lwi %0, %2, 0; \
39 2: swi %3, %2, 0; \
40 addik %1, r0, 0; \
41 3: \
42 .section .fixup, \"ax\"; \
43 4: brid 3b; \
44 addik %1, r0, 1; \
45 .previous; \
46 .section __ex_table,\"a\"; \
47 .word 1b,4b; \
48 .word 2b,4b; \
49 .previous;" \
50 : "=&r" (old), "=r" (faulted)
51 : "r" (parent), "r" (return_hooker)
52 );
53
54 if (unlikely(faulted)) {
55 ftrace_graph_stop();
56 WARN_ON(1);
57 return;
58 }
59
60 err = ftrace_push_return_trace(old, self_addr, &trace.depth, 0);
61 if (err == -EBUSY) {
62 *parent = old;
63 return;
64 }
65
66 trace.func = self_addr;
67 /* Only trace if the calling function expects to */
68 if (!ftrace_graph_entry(&trace)) {
69 current->curr_ret_stack--;
70 *parent = old;
71 }
72}
73#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
74
75#ifdef CONFIG_DYNAMIC_FTRACE
76/* save value to addr - it is save to do it in asm */
77static int ftrace_modify_code(unsigned long addr, unsigned int value)
78{
79 int faulted = 0;
80
81 __asm__ __volatile__(" 1: swi %2, %1, 0; \
82 addik %0, r0, 0; \
83 2: \
84 .section .fixup, \"ax\"; \
85 3: brid 2b; \
86 addik %0, r0, 1; \
87 .previous; \
88 .section __ex_table,\"a\"; \
89 .word 1b,3b; \
90 .previous;" \
91 : "=r" (faulted)
92 : "r" (addr), "r" (value)
93 );
94
95 if (unlikely(faulted))
96 return -EFAULT;
97
98 return 0;
99}
100
101#define MICROBLAZE_NOP 0x80000000
102#define MICROBLAZE_BRI 0xb800000C
103
104static unsigned int recorded; /* if save was or not */
105static unsigned int imm; /* saving whole imm instruction */
106
107/* There are two approaches howto solve ftrace_make nop function - look below */
108#undef USE_FTRACE_NOP
109
110#ifdef USE_FTRACE_NOP
111static unsigned int bralid; /* saving whole bralid instruction */
112#endif
113
114int ftrace_make_nop(struct module *mod,
115 struct dyn_ftrace *rec, unsigned long addr)
116{
117 /* we have this part of code which we are working with
118 * b000c000 imm -16384
119 * b9fc8e30 bralid r15, -29136 // c0008e30 <_mcount>
120 * 80000000 or r0, r0, r0
121 *
122 * The first solution (!USE_FTRACE_NOP-could be called branch solution)
123 * b000c000 bri 12 (0xC - jump to any other instruction)
124 * b9fc8e30 bralid r15, -29136 // c0008e30 <_mcount>
125 * 80000000 or r0, r0, r0
126 * any other instruction
127 *
128 * The second solution (USE_FTRACE_NOP) - no jump just nops
129 * 80000000 or r0, r0, r0
130 * 80000000 or r0, r0, r0
131 * 80000000 or r0, r0, r0
132 */
133 int ret = 0;
134
135 if (recorded == 0) {
136 recorded = 1;
137 imm = *(unsigned int *)rec->ip;
138 pr_debug("%s: imm:0x%x\n", __func__, imm);
139#ifdef USE_FTRACE_NOP
140 bralid = *(unsigned int *)(rec->ip + 4);
141 pr_debug("%s: bralid 0x%x\n", __func__, bralid);
142#endif /* USE_FTRACE_NOP */
143 }
144
145#ifdef USE_FTRACE_NOP
146 ret = ftrace_modify_code(rec->ip, MICROBLAZE_NOP);
147 ret += ftrace_modify_code(rec->ip + 4, MICROBLAZE_NOP);
148#else /* USE_FTRACE_NOP */
149 ret = ftrace_modify_code(rec->ip, MICROBLAZE_BRI);
150#endif /* USE_FTRACE_NOP */
151 return ret;
152}
153
154static int ret_addr; /* initialized as 0 by default */
155
156/* I believe that first is called ftrace_make_nop before this function */
157int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
158{
159 int ret;
160 ret_addr = addr; /* saving where the barrier jump is */
161 pr_debug("%s: addr:0x%x, rec->ip: 0x%x, imm:0x%x\n",
162 __func__, (unsigned int)addr, (unsigned int)rec->ip, imm);
163 ret = ftrace_modify_code(rec->ip, imm);
164#ifdef USE_FTRACE_NOP
165 pr_debug("%s: bralid:0x%x\n", __func__, bralid);
166 ret += ftrace_modify_code(rec->ip + 4, bralid);
167#endif /* USE_FTRACE_NOP */
168 return ret;
169}
170
171int __init ftrace_dyn_arch_init(void *data)
172{
173 /* The return code is retured via data */
174 *(unsigned long *)data = 0;
175
176 return 0;
177}
178
179int ftrace_update_ftrace_func(ftrace_func_t func)
180{
181 unsigned long ip = (unsigned long)(&ftrace_call);
182 unsigned int upper = (unsigned int)func;
183 unsigned int lower = (unsigned int)func;
184 int ret = 0;
185
186 /* create proper saving to ftrace_call poll */
187 upper = 0xb0000000 + (upper >> 16); /* imm func_upper */
188 lower = 0x32800000 + (lower & 0xFFFF); /* addik r20, r0, func_lower */
189
190 pr_debug("%s: func=0x%x, ip=0x%x, upper=0x%x, lower=0x%x\n",
191 __func__, (unsigned int)func, (unsigned int)ip, upper, lower);
192
193 /* save upper and lower code */
194 ret = ftrace_modify_code(ip, upper);
195 ret += ftrace_modify_code(ip + 4, lower);
196
197 /* We just need to remove the rtsd r15, 8 by NOP */
198 BUG_ON(!ret_addr);
199 if (ret_addr)
200 ret += ftrace_modify_code(ret_addr, MICROBLAZE_NOP);
201 else
202 ret = 1; /* fault */
203
204 /* All changes are done - lets do caches consistent */
205 flush_icache();
206 return ret;
207}
208
209#ifdef CONFIG_FUNCTION_GRAPH_TRACER
210unsigned int old_jump; /* saving place for jump instruction */
211
212int ftrace_enable_ftrace_graph_caller(void)
213{
214 unsigned int ret;
215 unsigned long ip = (unsigned long)(&ftrace_call_graph);
216
217 old_jump = *(unsigned int *)ip; /* save jump over instruction */
218 ret = ftrace_modify_code(ip, MICROBLAZE_NOP);
219 flush_icache();
220
221 pr_debug("%s: Replace instruction: 0x%x\n", __func__, old_jump);
222 return ret;
223}
224
225int ftrace_disable_ftrace_graph_caller(void)
226{
227 unsigned int ret;
228 unsigned long ip = (unsigned long)(&ftrace_call_graph);
229
230 ret = ftrace_modify_code(ip, old_jump);
231 flush_icache();
232
233 pr_debug("%s\n", __func__);
234 return ret;
235}
236#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
237#endif /* CONFIG_DYNAMIC_FTRACE */
diff --git a/arch/microblaze/kernel/heartbeat.c b/arch/microblaze/kernel/heartbeat.c
index 1bdf20222b92..522751737cfa 100644
--- a/arch/microblaze/kernel/heartbeat.c
+++ b/arch/microblaze/kernel/heartbeat.c
@@ -45,6 +45,7 @@ void heartbeat(void)
45void setup_heartbeat(void) 45void setup_heartbeat(void)
46{ 46{
47 struct device_node *gpio = NULL; 47 struct device_node *gpio = NULL;
48 int *prop;
48 int j; 49 int j;
49 char *gpio_list[] = { 50 char *gpio_list[] = {
50 "xlnx,xps-gpio-1.00.a", 51 "xlnx,xps-gpio-1.00.a",
@@ -58,10 +59,14 @@ void setup_heartbeat(void)
58 break; 59 break;
59 } 60 }
60 61
61 base_addr = *(int *) of_get_property(gpio, "reg", NULL); 62 if (gpio) {
62 base_addr = (unsigned long) ioremap(base_addr, PAGE_SIZE); 63 base_addr = *(int *) of_get_property(gpio, "reg", NULL);
63 printk(KERN_NOTICE "Heartbeat GPIO at 0x%x\n", base_addr); 64 base_addr = (unsigned long) ioremap(base_addr, PAGE_SIZE);
65 printk(KERN_NOTICE "Heartbeat GPIO at 0x%x\n", base_addr);
64 66
65 if (*(int *) of_get_property(gpio, "xlnx,is-bidir", NULL)) 67 /* GPIO is configured as output */
66 out_be32(base_addr + 4, 0); /* GPIO is configured as output */ 68 prop = (int *) of_get_property(gpio, "xlnx,is-bidir", NULL);
69 if (prop)
70 out_be32(base_addr + 4, 0);
71 }
67} 72}
diff --git a/arch/microblaze/kernel/intc.c b/arch/microblaze/kernel/intc.c
index 6eea6f92b84e..03172c1da770 100644
--- a/arch/microblaze/kernel/intc.c
+++ b/arch/microblaze/kernel/intc.c
@@ -42,8 +42,16 @@ unsigned int nr_irq;
42 42
43static void intc_enable_or_unmask(unsigned int irq) 43static void intc_enable_or_unmask(unsigned int irq)
44{ 44{
45 unsigned long mask = 1 << irq;
45 pr_debug("enable_or_unmask: %d\n", irq); 46 pr_debug("enable_or_unmask: %d\n", irq);
46 out_be32(INTC_BASE + SIE, 1 << irq); 47 out_be32(INTC_BASE + SIE, mask);
48
49 /* ack level irqs because they can't be acked during
50 * ack function since the handle_level_irq function
51 * acks the irq before calling the interrupt handler
52 */
53 if (irq_desc[irq].status & IRQ_LEVEL)
54 out_be32(INTC_BASE + IAR, mask);
47} 55}
48 56
49static void intc_disable_or_mask(unsigned int irq) 57static void intc_disable_or_mask(unsigned int irq)
diff --git a/arch/microblaze/kernel/mcount.S b/arch/microblaze/kernel/mcount.S
new file mode 100644
index 000000000000..e7eaa7a8cbd3
--- /dev/null
+++ b/arch/microblaze/kernel/mcount.S
@@ -0,0 +1,170 @@
1/*
2 * Low-level ftrace handling
3 *
4 * Copyright (C) 2009 Michal Simek <monstr@monstr.eu>
5 * Copyright (C) 2009 PetaLogix
6 *
7 * This file is subject to the terms and conditions of the GNU General
8 * Public License. See the file COPYING in the main directory of this
9 * archive for more details.
10 */
11
12#include <linux/linkage.h>
13
14#define NOALIGN_ENTRY(name) .globl name; name:
15
16/* FIXME MS: I think that I don't need to save all regs */
17#define SAVE_REGS \
18 addik r1, r1, -120; \
19 swi r2, r1, 4; \
20 swi r3, r1, 8; \
21 swi r4, r1, 12; \
22 swi r5, r1, 116; \
23 swi r6, r1, 16; \
24 swi r7, r1, 20; \
25 swi r8, r1, 24; \
26 swi r9, r1, 28; \
27 swi r10, r1, 32; \
28 swi r11, r1, 36; \
29 swi r12, r1, 40; \
30 swi r13, r1, 44; \
31 swi r14, r1, 48; \
32 swi r16, r1, 52; \
33 swi r17, r1, 56; \
34 swi r18, r1, 60; \
35 swi r19, r1, 64; \
36 swi r20, r1, 68; \
37 swi r21, r1, 72; \
38 swi r22, r1, 76; \
39 swi r23, r1, 80; \
40 swi r24, r1, 84; \
41 swi r25, r1, 88; \
42 swi r26, r1, 92; \
43 swi r27, r1, 96; \
44 swi r28, r1, 100; \
45 swi r29, r1, 104; \
46 swi r30, r1, 108; \
47 swi r31, r1, 112;
48
49#define RESTORE_REGS \
50 lwi r2, r1, 4; \
51 lwi r3, r1, 8; \
52 lwi r4, r1, 12; \
53 lwi r5, r1, 116; \
54 lwi r6, r1, 16; \
55 lwi r7, r1, 20; \
56 lwi r8, r1, 24; \
57 lwi r9, r1, 28; \
58 lwi r10, r1, 32; \
59 lwi r11, r1, 36; \
60 lwi r12, r1, 40; \
61 lwi r13, r1, 44; \
62 lwi r14, r1, 48; \
63 lwi r16, r1, 52; \
64 lwi r17, r1, 56; \
65 lwi r18, r1, 60; \
66 lwi r19, r1, 64; \
67 lwi r20, r1, 68; \
68 lwi r21, r1, 72; \
69 lwi r22, r1, 76; \
70 lwi r23, r1, 80; \
71 lwi r24, r1, 84; \
72 lwi r25, r1, 88; \
73 lwi r26, r1, 92; \
74 lwi r27, r1, 96; \
75 lwi r28, r1, 100; \
76 lwi r29, r1, 104; \
77 lwi r30, r1, 108; \
78 lwi r31, r1, 112; \
79 addik r1, r1, 120;
80
81ENTRY(ftrace_stub)
82 rtsd r15, 8;
83 nop;
84
85ENTRY(_mcount)
86#ifdef CONFIG_DYNAMIC_FTRACE
87ENTRY(ftrace_caller)
88 /* MS: It is just barrier which is removed from C code */
89 rtsd r15, 8
90 nop
91#endif /* CONFIG_DYNAMIC_FTRACE */
92 SAVE_REGS
93 swi r15, r1, 0;
94 /* MS: HAVE_FUNCTION_TRACE_MCOUNT_TEST begin of checking */
95 lwi r5, r0, function_trace_stop;
96 bneid r5, end;
97 nop;
98 /* MS: HAVE_FUNCTION_TRACE_MCOUNT_TEST end of checking */
99#ifdef CONFIG_FUNCTION_GRAPH_TRACER
100#ifndef CONFIG_DYNAMIC_FTRACE
101 lwi r5, r0, ftrace_graph_return;
102 addik r6, r0, ftrace_stub; /* asm implementation */
103 cmpu r5, r5, r6; /* ftrace_graph_return != ftrace_stub */
104 beqid r5, end_graph_tracer;
105 nop;
106
107 lwi r6, r0, ftrace_graph_entry;
108 addik r5, r0, ftrace_graph_entry_stub; /* implemented in C */
109 cmpu r5, r5, r6; /* ftrace_graph_entry != ftrace_graph_entry_stub */
110 beqid r5, end_graph_tracer;
111 nop;
112#else /* CONFIG_DYNAMIC_FTRACE */
113NOALIGN_ENTRY(ftrace_call_graph)
114 /* MS: jump over graph function - replaced from C code */
115 bri end_graph_tracer
116#endif /* CONFIG_DYNAMIC_FTRACE */
117 addik r5, r1, 120; /* MS: load parent addr */
118 addik r6, r15, 0; /* MS: load current function addr */
119 bralid r15, prepare_ftrace_return;
120 nop;
121 /* MS: graph was taken that's why - can jump over function trace */
122 brid end;
123 nop;
124end_graph_tracer:
125#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
126#ifndef CONFIG_DYNAMIC_FTRACE
127 /* MS: test function trace if is taken or not */
128 lwi r20, r0, ftrace_trace_function;
129 addik r6, r0, ftrace_stub;
130 cmpu r5, r20, r6; /* ftrace_trace_function != ftrace_stub */
131 beqid r5, end; /* MS: not taken -> jump over */
132 nop;
133#else /* CONFIG_DYNAMIC_FTRACE */
134NOALIGN_ENTRY(ftrace_call)
135/* instruction for setup imm FUNC_part1, addik r20, r0, FUNC_part2 */
136 nop
137 nop
138#endif /* CONFIG_DYNAMIC_FTRACE */
139/* static normal trace */
140 lwi r6, r1, 120; /* MS: load parent addr */
141 addik r5, r15, 0; /* MS: load current function addr */
142 /* MS: here is dependency on previous code */
143 brald r15, r20; /* MS: jump to ftrace handler */
144 nop;
145end:
146 lwi r15, r1, 0;
147 RESTORE_REGS
148
149 rtsd r15, 8; /* MS: jump back */
150 nop;
151
152#ifdef CONFIG_FUNCTION_GRAPH_TRACER
153ENTRY(return_to_handler)
154 nop; /* MS: just barrier for rtsd r15, 8 */
155 nop;
156 SAVE_REGS
157 swi r15, r1, 0;
158
159 /* MS: find out returning address */
160 bralid r15, ftrace_return_to_handler;
161 nop;
162
163 /* MS: return value from ftrace_return_to_handler is my returning addr
164 * must be before restore regs because I have to restore r3 content */
165 addik r15, r3, 0;
166 RESTORE_REGS
167
168 rtsd r15, 8; /* MS: jump back */
169 nop;
170#endif /* CONFIG_FUNCTION_TRACER */
diff --git a/arch/microblaze/kernel/microblaze_ksyms.c b/arch/microblaze/kernel/microblaze_ksyms.c
index 59ff20e33e0c..bc4dcb7d3861 100644
--- a/arch/microblaze/kernel/microblaze_ksyms.c
+++ b/arch/microblaze/kernel/microblaze_ksyms.c
@@ -18,6 +18,7 @@
18#include <linux/io.h> 18#include <linux/io.h>
19#include <asm/page.h> 19#include <asm/page.h>
20#include <asm/system.h> 20#include <asm/system.h>
21#include <linux/ftrace.h>
21#include <linux/uaccess.h> 22#include <linux/uaccess.h>
22 23
23/* 24/*
@@ -47,3 +48,7 @@ extern void __umodsi3(void);
47EXPORT_SYMBOL(__umodsi3); 48EXPORT_SYMBOL(__umodsi3);
48extern char *_ebss; 49extern char *_ebss;
49EXPORT_SYMBOL_GPL(_ebss); 50EXPORT_SYMBOL_GPL(_ebss);
51#ifdef CONFIG_FUNCTION_TRACER
52extern void _mcount(void);
53EXPORT_SYMBOL(_mcount);
54#endif
diff --git a/arch/microblaze/kernel/process.c b/arch/microblaze/kernel/process.c
index c592d475b3d8..812f1bf06c9e 100644
--- a/arch/microblaze/kernel/process.c
+++ b/arch/microblaze/kernel/process.c
@@ -15,6 +15,7 @@
15#include <linux/bitops.h> 15#include <linux/bitops.h>
16#include <asm/system.h> 16#include <asm/system.h>
17#include <asm/pgalloc.h> 17#include <asm/pgalloc.h>
18#include <asm/cacheflush.h>
18 19
19void show_regs(struct pt_regs *regs) 20void show_regs(struct pt_regs *regs)
20{ 21{
diff --git a/arch/microblaze/kernel/reset.c b/arch/microblaze/kernel/reset.c
new file mode 100644
index 000000000000..a1721a33042e
--- /dev/null
+++ b/arch/microblaze/kernel/reset.c
@@ -0,0 +1,140 @@
1/*
2 * Copyright (C) 2009 Michal Simek <monstr@monstr.eu>
3 * Copyright (C) 2009 PetaLogix
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 */
9
10#include <linux/init.h>
11#include <linux/of_platform.h>
12#include <asm/prom.h>
13
14/* Trigger specific functions */
15#ifdef CONFIG_GPIOLIB
16
17#include <linux/of_gpio.h>
18
19static int handle; /* reset pin handle */
20static unsigned int reset_val;
21
22static int of_reset_gpio_handle(void)
23{
24 int ret; /* variable which stored handle reset gpio pin */
25 struct device_node *root; /* root node */
26 struct device_node *gpio; /* gpio node */
27 struct of_gpio_chip *of_gc = NULL;
28 enum of_gpio_flags flags ;
29 const void *gpio_spec;
30
31 /* find out root node */
32 root = of_find_node_by_path("/");
33
34 /* give me handle for gpio node to be possible allocate pin */
35 ret = of_parse_phandles_with_args(root, "hard-reset-gpios",
36 "#gpio-cells", 0, &gpio, &gpio_spec);
37 if (ret) {
38 pr_debug("%s: can't parse gpios property\n", __func__);
39 goto err0;
40 }
41
42 of_gc = gpio->data;
43 if (!of_gc) {
44 pr_debug("%s: gpio controller %s isn't registered\n",
45 root->full_name, gpio->full_name);
46 ret = -ENODEV;
47 goto err1;
48 }
49
50 ret = of_gc->xlate(of_gc, root, gpio_spec, &flags);
51 if (ret < 0)
52 goto err1;
53
54 ret += of_gc->gc.base;
55err1:
56 of_node_put(gpio);
57err0:
58 pr_debug("%s exited with status %d\n", __func__, ret);
59 return ret;
60}
61
62void of_platform_reset_gpio_probe(void)
63{
64 int ret;
65 handle = of_reset_gpio_handle();
66
67 if (!gpio_is_valid(handle)) {
68 printk(KERN_INFO "Skipping unavailable RESET gpio %d (%s)\n",
69 handle, "reset");
70 }
71
72 ret = gpio_request(handle, "reset");
73 if (ret < 0) {
74 printk(KERN_INFO "GPIO pin is already allocated\n");
75 return;
76 }
77
78 /* get current setup value */
79 reset_val = gpio_get_value(handle);
80 /* FIXME maybe worth to perform any action */
81 pr_debug("Reset: Gpio output state: 0x%x\n", reset_val);
82
83 /* Setup GPIO as output */
84 ret = gpio_direction_output(handle, 0);
85 if (ret < 0)
86 goto err;
87
88 /* Setup output direction */
89 gpio_set_value(handle, 0);
90
91 printk(KERN_INFO "RESET: Registered gpio device: %d, current val: %d\n",
92 handle, reset_val);
93 return;
94err:
95 gpio_free(handle);
96 return;
97}
98
99
100static void gpio_system_reset(void)
101{
102 gpio_set_value(handle, 1 - reset_val);
103}
104#else
105#define gpio_system_reset() do {} while (0)
106void of_platform_reset_gpio_probe(void)
107{
108 return;
109}
110#endif
111
112void machine_restart(char *cmd)
113{
114 printk(KERN_NOTICE "Machine restart...\n");
115 gpio_system_reset();
116 dump_stack();
117 while (1)
118 ;
119}
120
121void machine_shutdown(void)
122{
123 printk(KERN_NOTICE "Machine shutdown...\n");
124 while (1)
125 ;
126}
127
128void machine_halt(void)
129{
130 printk(KERN_NOTICE "Machine halt...\n");
131 while (1)
132 ;
133}
134
135void machine_power_off(void)
136{
137 printk(KERN_NOTICE "Machine power off...\n");
138 while (1)
139 ;
140}
diff --git a/arch/microblaze/kernel/setup.c b/arch/microblaze/kernel/setup.c
index 8c1e0f4dcf18..5372b24ad049 100644
--- a/arch/microblaze/kernel/setup.c
+++ b/arch/microblaze/kernel/setup.c
@@ -52,13 +52,12 @@ void __init setup_arch(char **cmdline_p)
52 /* irq_early_init(); */ 52 /* irq_early_init(); */
53 setup_cpuinfo(); 53 setup_cpuinfo();
54 54
55 __invalidate_icache_all(); 55 microblaze_cache_init();
56 __enable_icache();
57 56
58 __invalidate_dcache_all(); 57 enable_dcache();
59 __enable_dcache();
60 58
61 panic_timeout = 120; 59 invalidate_icache();
60 enable_icache();
62 61
63 setup_memory(); 62 setup_memory();
64 63
@@ -131,6 +130,8 @@ void __init machine_early_init(const char *cmdline, unsigned int ram,
131 strlcpy(cmd_line, cmdline, COMMAND_LINE_SIZE); 130 strlcpy(cmd_line, cmdline, COMMAND_LINE_SIZE);
132#endif 131#endif
133 132
133 lockdep_init();
134
134/* initialize device tree for usage in early_printk */ 135/* initialize device tree for usage in early_printk */
135 early_init_devtree((void *)_fdt_start); 136 early_init_devtree((void *)_fdt_start);
136 137
@@ -186,32 +187,3 @@ static int microblaze_debugfs_init(void)
186} 187}
187arch_initcall(microblaze_debugfs_init); 188arch_initcall(microblaze_debugfs_init);
188#endif 189#endif
189
190void machine_restart(char *cmd)
191{
192 printk(KERN_NOTICE "Machine restart...\n");
193 dump_stack();
194 while (1)
195 ;
196}
197
198void machine_shutdown(void)
199{
200 printk(KERN_NOTICE "Machine shutdown...\n");
201 while (1)
202 ;
203}
204
205void machine_halt(void)
206{
207 printk(KERN_NOTICE "Machine halt...\n");
208 while (1)
209 ;
210}
211
212void machine_power_off(void)
213{
214 printk(KERN_NOTICE "Machine power off...\n");
215 while (1)
216 ;
217}
diff --git a/arch/microblaze/kernel/signal.c b/arch/microblaze/kernel/signal.c
index 1c80e4fc40ce..d8d3bb396cd6 100644
--- a/arch/microblaze/kernel/signal.c
+++ b/arch/microblaze/kernel/signal.c
@@ -44,7 +44,6 @@
44 44
45asmlinkage int do_signal(struct pt_regs *regs, sigset_t *oldset, int in_sycall); 45asmlinkage int do_signal(struct pt_regs *regs, sigset_t *oldset, int in_sycall);
46 46
47
48asmlinkage long 47asmlinkage long
49sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss, 48sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
50 struct pt_regs *regs) 49 struct pt_regs *regs)
@@ -176,6 +175,11 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
176 struct rt_sigframe __user *frame; 175 struct rt_sigframe __user *frame;
177 int err = 0; 176 int err = 0;
178 int signal; 177 int signal;
178 unsigned long address = 0;
179#ifdef CONFIG_MMU
180 pmd_t *pmdp;
181 pte_t *ptep;
182#endif
179 183
180 frame = get_sigframe(ka, regs, sizeof(*frame)); 184 frame = get_sigframe(ka, regs, sizeof(*frame));
181 185
@@ -216,8 +220,29 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
216 Negative 8 offset because return is rtsd r15, 8 */ 220 Negative 8 offset because return is rtsd r15, 8 */
217 regs->r15 = ((unsigned long)frame->tramp)-8; 221 regs->r15 = ((unsigned long)frame->tramp)-8;
218 222
219 __invalidate_cache_sigtramp((unsigned long)frame->tramp); 223 address = ((unsigned long)frame->tramp);
220 224#ifdef CONFIG_MMU
225 pmdp = pmd_offset(pud_offset(
226 pgd_offset(current->mm, address),
227 address), address);
228
229 preempt_disable();
230 ptep = pte_offset_map(pmdp, address);
231 if (pte_present(*ptep)) {
232 address = (unsigned long) page_address(pte_page(*ptep));
233 /* MS: I need add offset in page */
234 address += ((unsigned long)frame->tramp) & ~PAGE_MASK;
235 /* MS address is virtual */
236 address = virt_to_phys(address);
237 invalidate_icache_range(address, address + 8);
238 flush_dcache_range(address, address + 8);
239 }
240 pte_unmap(ptep);
241 preempt_enable();
242#else
243 flush_icache_range(address, address + 8);
244 flush_dcache_range(address, address + 8);
245#endif
221 if (err) 246 if (err)
222 goto give_sigsegv; 247 goto give_sigsegv;
223 248
@@ -233,6 +258,10 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
233 258
234 set_fs(USER_DS); 259 set_fs(USER_DS);
235 260
261 /* the tracer may want to single-step inside the handler */
262 if (test_thread_flag(TIF_SINGLESTEP))
263 ptrace_notify(SIGTRAP);
264
236#ifdef DEBUG_SIG 265#ifdef DEBUG_SIG
237 printk(KERN_INFO "SIG deliver (%s:%d): sp=%p pc=%08lx\n", 266 printk(KERN_INFO "SIG deliver (%s:%d): sp=%p pc=%08lx\n",
238 current->comm, current->pid, frame, regs->pc); 267 current->comm, current->pid, frame, regs->pc);
diff --git a/arch/microblaze/kernel/stacktrace.c b/arch/microblaze/kernel/stacktrace.c
new file mode 100644
index 000000000000..123692f22647
--- /dev/null
+++ b/arch/microblaze/kernel/stacktrace.c
@@ -0,0 +1,65 @@
1/*
2 * Stack trace support for Microblaze.
3 *
4 * Copyright (C) 2009 Michal Simek <monstr@monstr.eu>
5 * Copyright (C) 2009 PetaLogix
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 */
11
12#include <linux/sched.h>
13#include <linux/stacktrace.h>
14#include <linux/thread_info.h>
15#include <linux/ptrace.h>
16#include <linux/module.h>
17
18/* FIXME initial support */
19void save_stack_trace(struct stack_trace *trace)
20{
21 unsigned long *sp;
22 unsigned long addr;
23 asm("addik %0, r1, 0" : "=r" (sp));
24
25 while (!kstack_end(sp)) {
26 addr = *sp++;
27 if (__kernel_text_address(addr)) {
28 if (trace->skip > 0)
29 trace->skip--;
30 else
31 trace->entries[trace->nr_entries++] = addr;
32
33 if (trace->nr_entries >= trace->max_entries)
34 break;
35 }
36 }
37}
38EXPORT_SYMBOL_GPL(save_stack_trace);
39
40void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
41{
42 unsigned int *sp;
43 unsigned long addr;
44
45 struct thread_info *ti = task_thread_info(tsk);
46
47 if (tsk == current)
48 asm("addik %0, r1, 0" : "=r" (sp));
49 else
50 sp = (unsigned int *)ti->cpu_context.r1;
51
52 while (!kstack_end(sp)) {
53 addr = *sp++;
54 if (__kernel_text_address(addr)) {
55 if (trace->skip > 0)
56 trace->skip--;
57 else
58 trace->entries[trace->nr_entries++] = addr;
59
60 if (trace->nr_entries >= trace->max_entries)
61 break;
62 }
63 }
64}
65EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
diff --git a/arch/microblaze/kernel/syscall_table.S b/arch/microblaze/kernel/syscall_table.S
index b96f365ea6b1..4088be7d4e29 100644
--- a/arch/microblaze/kernel/syscall_table.S
+++ b/arch/microblaze/kernel/syscall_table.S
@@ -183,7 +183,7 @@ ENTRY(sys_call_table)
183 .long sys_rt_sigpending 183 .long sys_rt_sigpending
184 .long sys_rt_sigtimedwait 184 .long sys_rt_sigtimedwait
185 .long sys_rt_sigqueueinfo 185 .long sys_rt_sigqueueinfo
186 .long sys_rt_sigsuspend_wrapper 186 .long sys_rt_sigsuspend
187 .long sys_pread64 /* 180 */ 187 .long sys_pread64 /* 180 */
188 .long sys_pwrite64 188 .long sys_pwrite64
189 .long sys_chown 189 .long sys_chown
@@ -303,7 +303,7 @@ ENTRY(sys_call_table)
303 .long sys_mkdirat 303 .long sys_mkdirat
304 .long sys_mknodat 304 .long sys_mknodat
305 .long sys_fchownat 305 .long sys_fchownat
306 .long sys_ni_syscall 306 .long sys_futimesat
307 .long sys_fstatat64 /* 300 */ 307 .long sys_fstatat64 /* 300 */
308 .long sys_unlinkat 308 .long sys_unlinkat
309 .long sys_renameat 309 .long sys_renameat
diff --git a/arch/microblaze/kernel/timer.c b/arch/microblaze/kernel/timer.c
index 5499deae7fa6..ed61b2f17719 100644
--- a/arch/microblaze/kernel/timer.c
+++ b/arch/microblaze/kernel/timer.c
@@ -183,6 +183,31 @@ static cycle_t microblaze_read(struct clocksource *cs)
183 return (cycle_t) (in_be32(TIMER_BASE + TCR1)); 183 return (cycle_t) (in_be32(TIMER_BASE + TCR1));
184} 184}
185 185
186static struct timecounter microblaze_tc = {
187 .cc = NULL,
188};
189
190static cycle_t microblaze_cc_read(const struct cyclecounter *cc)
191{
192 return microblaze_read(NULL);
193}
194
195static struct cyclecounter microblaze_cc = {
196 .read = microblaze_cc_read,
197 .mask = CLOCKSOURCE_MASK(32),
198 .shift = 24,
199};
200
201int __init init_microblaze_timecounter(void)
202{
203 microblaze_cc.mult = div_sc(cpuinfo.cpu_clock_freq, NSEC_PER_SEC,
204 microblaze_cc.shift);
205
206 timecounter_init(&microblaze_tc, &microblaze_cc, sched_clock());
207
208 return 0;
209}
210
186static struct clocksource clocksource_microblaze = { 211static struct clocksource clocksource_microblaze = {
187 .name = "microblaze_clocksource", 212 .name = "microblaze_clocksource",
188 .rating = 300, 213 .rating = 300,
@@ -204,6 +229,9 @@ static int __init microblaze_clocksource_init(void)
204 out_be32(TIMER_BASE + TCSR1, in_be32(TIMER_BASE + TCSR1) & ~TCSR_ENT); 229 out_be32(TIMER_BASE + TCSR1, in_be32(TIMER_BASE + TCSR1) & ~TCSR_ENT);
205 /* start timer1 - up counting without interrupt */ 230 /* start timer1 - up counting without interrupt */
206 out_be32(TIMER_BASE + TCSR1, TCSR_TINT|TCSR_ENT|TCSR_ARHT); 231 out_be32(TIMER_BASE + TCSR1, TCSR_TINT|TCSR_ENT|TCSR_ARHT);
232
233 /* register timecounter - for ftrace support */
234 init_microblaze_timecounter();
207 return 0; 235 return 0;
208} 236}
209 237
diff --git a/arch/microblaze/kernel/vmlinux.lds.S b/arch/microblaze/kernel/vmlinux.lds.S
index e704188d7855..5ef619aad634 100644
--- a/arch/microblaze/kernel/vmlinux.lds.S
+++ b/arch/microblaze/kernel/vmlinux.lds.S
@@ -26,11 +26,12 @@ SECTIONS {
26 _stext = . ; 26 _stext = . ;
27 *(.text .text.*) 27 *(.text .text.*)
28 *(.fixup) 28 *(.fixup)
29 EXIT_TEXT 29 EXIT_TEXT
30 EXIT_CALL 30 EXIT_CALL
31 SCHED_TEXT 31 SCHED_TEXT
32 LOCK_TEXT 32 LOCK_TEXT
33 KPROBES_TEXT 33 KPROBES_TEXT
34 IRQENTRY_TEXT
34 . = ALIGN (4) ; 35 . = ALIGN (4) ;
35 _etext = . ; 36 _etext = . ;
36 } 37 }
@@ -86,6 +87,7 @@ SECTIONS {
86 _KERNEL_SDA_BASE_ = _ssro + (_ssro_size / 2) ; 87 _KERNEL_SDA_BASE_ = _ssro + (_ssro_size / 2) ;
87 } 88 }
88 89
90 . = ALIGN(PAGE_SIZE);
89 __init_begin = .; 91 __init_begin = .;
90 92
91 INIT_TEXT_SECTION(PAGE_SIZE) 93 INIT_TEXT_SECTION(PAGE_SIZE)
diff --git a/arch/microblaze/lib/uaccess.c b/arch/microblaze/lib/uaccess.c
index 8eb9df5a26c9..a853fe089c44 100644
--- a/arch/microblaze/lib/uaccess.c
+++ b/arch/microblaze/lib/uaccess.c
@@ -39,3 +39,10 @@ long strncpy_from_user(char *dst, const char __user *src, long count)
39 __do_strncpy_from_user(dst, src, count, res); 39 __do_strncpy_from_user(dst, src, count, res);
40 return res; 40 return res;
41} 41}
42
43unsigned long __copy_tofrom_user(void __user *to,
44 const void __user *from, unsigned long size)
45{
46 memcpy(to, from, size);
47 return 0;
48}
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index a44892e7cd5b..a57cedf36715 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -41,6 +41,7 @@ char *klimit = _end;
41 * have available. 41 * have available.
42 */ 42 */
43unsigned long memory_start; 43unsigned long memory_start;
44EXPORT_SYMBOL(memory_start);
44unsigned long memory_end; /* due to mm/nommu.c */ 45unsigned long memory_end; /* due to mm/nommu.c */
45unsigned long memory_size; 46unsigned long memory_size;
46 47
diff --git a/arch/microblaze/mm/pgtable.c b/arch/microblaze/mm/pgtable.c
index 46c4ca5d15c5..2820081b21ab 100644
--- a/arch/microblaze/mm/pgtable.c
+++ b/arch/microblaze/mm/pgtable.c
@@ -144,7 +144,6 @@ int map_page(unsigned long va, phys_addr_t pa, int flags)
144 pmd_t *pd; 144 pmd_t *pd;
145 pte_t *pg; 145 pte_t *pg;
146 int err = -ENOMEM; 146 int err = -ENOMEM;
147 /* spin_lock(&init_mm.page_table_lock); */
148 /* Use upper 10 bits of VA to index the first level map */ 147 /* Use upper 10 bits of VA to index the first level map */
149 pd = pmd_offset(pgd_offset_k(va), va); 148 pd = pmd_offset(pgd_offset_k(va), va);
150 /* Use middle 10 bits of VA to index the second-level map */ 149 /* Use middle 10 bits of VA to index the second-level map */
@@ -158,9 +157,7 @@ int map_page(unsigned long va, phys_addr_t pa, int flags)
158 if (mem_init_done) 157 if (mem_init_done)
159 flush_HPTE(0, va, pmd_val(*pd)); 158 flush_HPTE(0, va, pmd_val(*pd));
160 /* flush_HPTE(0, va, pg); */ 159 /* flush_HPTE(0, va, pg); */
161
162 } 160 }
163 /* spin_unlock(&init_mm.page_table_lock); */
164 return err; 161 return err;
165} 162}
166 163
@@ -182,12 +179,6 @@ void __init adjust_total_lowmem(void)
182#endif 179#endif
183} 180}
184 181
185static void show_tmem(unsigned long tmem)
186{
187 volatile unsigned long a;
188 a = a + tmem;
189}
190
191/* 182/*
192 * Map in all of physical memory starting at CONFIG_KERNEL_START. 183 * Map in all of physical memory starting at CONFIG_KERNEL_START.
193 */ 184 */
@@ -197,7 +188,6 @@ void __init mapin_ram(void)
197 188
198 v = CONFIG_KERNEL_START; 189 v = CONFIG_KERNEL_START;
199 p = memory_start; 190 p = memory_start;
200 show_tmem(memory_size);
201 for (s = 0; s < memory_size; s += PAGE_SIZE) { 191 for (s = 0; s < memory_size; s += PAGE_SIZE) {
202 f = _PAGE_PRESENT | _PAGE_ACCESSED | 192 f = _PAGE_PRESENT | _PAGE_ACCESSED |
203 _PAGE_SHARED | _PAGE_HWEXEC; 193 _PAGE_SHARED | _PAGE_HWEXEC;
diff --git a/arch/microblaze/oprofile/Makefile b/arch/microblaze/oprofile/Makefile
new file mode 100644
index 000000000000..0d0348c8af97
--- /dev/null
+++ b/arch/microblaze/oprofile/Makefile
@@ -0,0 +1,13 @@
1#
2# arch/microblaze/oprofile/Makefile
3#
4
5obj-$(CONFIG_OPROFILE) += oprofile.o
6
7DRIVER_OBJS := $(addprefix ../../../drivers/oprofile/, \
8 oprof.o cpu_buffer.o buffer_sync.o \
9 event_buffer.o oprofile_files.o \
10 oprofilefs.o oprofile_stats.o \
11 timer_int.o )
12
13oprofile-y := $(DRIVER_OBJS) microblaze_oprofile.o
diff --git a/arch/microblaze/oprofile/microblaze_oprofile.c b/arch/microblaze/oprofile/microblaze_oprofile.c
new file mode 100644
index 000000000000..def17e59888e
--- /dev/null
+++ b/arch/microblaze/oprofile/microblaze_oprofile.c
@@ -0,0 +1,22 @@
1/*
2 * Microblaze oprofile code
3 *
4 * Copyright (C) 2009 Michal Simek <monstr@monstr.eu>
5 * Copyright (C) 2009 PetaLogix
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 */
11
12#include <linux/oprofile.h>
13#include <linux/init.h>
14
15int __init oprofile_arch_init(struct oprofile_operations *ops)
16{
17 return -1;
18}
19
20void oprofile_arch_exit(void)
21{
22}
diff --git a/arch/microblaze/platform/Kconfig.platform b/arch/microblaze/platform/Kconfig.platform
index 8e9b4752d3ff..669c7eec293e 100644
--- a/arch/microblaze/platform/Kconfig.platform
+++ b/arch/microblaze/platform/Kconfig.platform
@@ -53,31 +53,12 @@ config OPT_LIB_FUNCTION
53 53
54config OPT_LIB_ASM 54config OPT_LIB_ASM
55 bool "Optimalized lib function ASM" 55 bool "Optimalized lib function ASM"
56 depends on OPT_LIB_FUNCTION 56 depends on OPT_LIB_FUNCTION && (XILINX_MICROBLAZE0_USE_BARREL = 1)
57 default n 57 default n
58 help 58 help
59 Allows turn on optimalized library function (memcpy and memmove). 59 Allows turn on optimalized library function (memcpy and memmove).
60 Function are written in asm code. 60 Function are written in asm code.
61 61
62# This is still a bit broken - disabling for now JW 20070504
63config ALLOW_EDIT_AUTO
64 bool "Permit Display/edit of Kconfig.auto platform settings"
65 default n
66 help
67 Allows the editing of auto-generated platform settings from
68 the Kconfig.auto file. Obviously this does not change the
69 underlying hardware, so be very careful if you go editing
70 these settings.
71
72 Also, if you enable this, and edit various Kconfig.auto
73 settings, YOUR CHANGES WILL BE LOST if you then disable it
74 again. You have been warned!
75
76 If unsure, say no.
77
78comment "Automatic platform settings from Kconfig.auto"
79 depends on ALLOW_EDIT_AUTO
80
81if PLATFORM_GENERIC=y 62if PLATFORM_GENERIC=y
82 source "arch/microblaze/platform/generic/Kconfig.auto" 63 source "arch/microblaze/platform/generic/Kconfig.auto"
83endif 64endif
diff --git a/arch/microblaze/platform/generic/Kconfig.auto b/arch/microblaze/platform/generic/Kconfig.auto
index fbca22d9c8b9..5d86fc19029d 100644
--- a/arch/microblaze/platform/generic/Kconfig.auto
+++ b/arch/microblaze/platform/generic/Kconfig.auto
@@ -21,7 +21,6 @@
21 21
22# Definitions for MICROBLAZE0 22# Definitions for MICROBLAZE0
23comment "Definitions for MICROBLAZE0" 23comment "Definitions for MICROBLAZE0"
24 depends on ALLOW_EDIT_AUTO
25 24
26config KERNEL_BASE_ADDR 25config KERNEL_BASE_ADDR
27 hex "Physical address where Linux Kernel is" 26 hex "Physical address where Linux Kernel is"
@@ -30,33 +29,33 @@ config KERNEL_BASE_ADDR
30 BASE Address for kernel 29 BASE Address for kernel
31 30
32config XILINX_MICROBLAZE0_FAMILY 31config XILINX_MICROBLAZE0_FAMILY
33 string "Targetted FPGA family" if ALLOW_EDIT_AUTO 32 string "Targetted FPGA family"
34 default "virtex5" 33 default "virtex5"
35 34
36config XILINX_MICROBLAZE0_USE_MSR_INSTR 35config XILINX_MICROBLAZE0_USE_MSR_INSTR
37 int "USE_MSR_INSTR range (0:1)" if ALLOW_EDIT_AUTO 36 int "USE_MSR_INSTR range (0:1)"
38 default 1 37 default 0
39 38
40config XILINX_MICROBLAZE0_USE_PCMP_INSTR 39config XILINX_MICROBLAZE0_USE_PCMP_INSTR
41 int "USE_PCMP_INSTR range (0:1)" if ALLOW_EDIT_AUTO 40 int "USE_PCMP_INSTR range (0:1)"
42 default 1 41 default 0
43 42
44config XILINX_MICROBLAZE0_USE_BARREL 43config XILINX_MICROBLAZE0_USE_BARREL
45 int "USE_BARREL range (0:1)" if ALLOW_EDIT_AUTO 44 int "USE_BARREL range (0:1)"
46 default 1 45 default 0
47 46
48config XILINX_MICROBLAZE0_USE_DIV 47config XILINX_MICROBLAZE0_USE_DIV
49 int "USE_DIV range (0:1)" if ALLOW_EDIT_AUTO 48 int "USE_DIV range (0:1)"
50 default 1 49 default 0
51 50
52config XILINX_MICROBLAZE0_USE_HW_MUL 51config XILINX_MICROBLAZE0_USE_HW_MUL
53 int "USE_HW_MUL values (0=NONE, 1=MUL32, 2=MUL64)" if ALLOW_EDIT_AUTO 52 int "USE_HW_MUL values (0=NONE, 1=MUL32, 2=MUL64)"
54 default 2 53 default 0
55 54
56config XILINX_MICROBLAZE0_USE_FPU 55config XILINX_MICROBLAZE0_USE_FPU
57 int "USE_FPU values (0=NONE, 1=BASIC, 2=EXTENDED)" if ALLOW_EDIT_AUTO 56 int "USE_FPU values (0=NONE, 1=BASIC, 2=EXTENDED)"
58 default 2 57 default 0
59 58
60config XILINX_MICROBLAZE0_HW_VER 59config XILINX_MICROBLAZE0_HW_VER
61 string "Core version number" if ALLOW_EDIT_AUTO 60 string "Core version number"
62 default 7.10.d 61 default 7.10.d
diff --git a/arch/microblaze/platform/generic/system.dts b/arch/microblaze/platform/generic/system.dts
index 29993f62b30a..2d5c41767cd0 100644
--- a/arch/microblaze/platform/generic/system.dts
+++ b/arch/microblaze/platform/generic/system.dts
@@ -32,11 +32,16 @@
32 #address-cells = <1>; 32 #address-cells = <1>;
33 #size-cells = <1>; 33 #size-cells = <1>;
34 compatible = "xlnx,microblaze"; 34 compatible = "xlnx,microblaze";
35 hard-reset-gpios = <&LEDs_8Bit 2 1>;
35 model = "testing"; 36 model = "testing";
36 DDR2_SDRAM: memory@90000000 { 37 DDR2_SDRAM: memory@90000000 {
37 device_type = "memory"; 38 device_type = "memory";
38 reg = < 0x90000000 0x10000000 >; 39 reg = < 0x90000000 0x10000000 >;
39 } ; 40 } ;
41 aliases {
42 ethernet0 = &Hard_Ethernet_MAC;
43 serial0 = &RS232_Uart_1;
44 } ;
40 chosen { 45 chosen {
41 bootargs = "console=ttyUL0,115200 highres=on"; 46 bootargs = "console=ttyUL0,115200 highres=on";
42 linux,stdout-path = "/plb@0/serial@84000000"; 47 linux,stdout-path = "/plb@0/serial@84000000";
@@ -127,7 +132,7 @@
127 mb_plb: plb@0 { 132 mb_plb: plb@0 {
128 #address-cells = <1>; 133 #address-cells = <1>;
129 #size-cells = <1>; 134 #size-cells = <1>;
130 compatible = "xlnx,plb-v46-1.03.a", "simple-bus"; 135 compatible = "xlnx,plb-v46-1.03.a", "xlnx,plb-v46-1.00.a", "simple-bus";
131 ranges ; 136 ranges ;
132 FLASH: flash@a0000000 { 137 FLASH: flash@a0000000 {
133 bank-width = <2>; 138 bank-width = <2>;
@@ -214,12 +219,12 @@
214 #size-cells = <1>; 219 #size-cells = <1>;
215 compatible = "xlnx,compound"; 220 compatible = "xlnx,compound";
216 ethernet@81c00000 { 221 ethernet@81c00000 {
217 compatible = "xlnx,xps-ll-temac-1.01.b"; 222 compatible = "xlnx,xps-ll-temac-1.01.b", "xlnx,xps-ll-temac-1.00.a";
218 device_type = "network"; 223 device_type = "network";
219 interrupt-parent = <&xps_intc_0>; 224 interrupt-parent = <&xps_intc_0>;
220 interrupts = < 5 2 >; 225 interrupts = < 5 2 >;
221 llink-connected = <&PIM3>; 226 llink-connected = <&PIM3>;
222 local-mac-address = [ 02 00 00 00 00 00 ]; 227 local-mac-address = [ 00 0a 35 00 00 00 ];
223 reg = < 0x81c00000 0x40 >; 228 reg = < 0x81c00000 0x40 >;
224 xlnx,bus2core-clk-ratio = <0x1>; 229 xlnx,bus2core-clk-ratio = <0x1>;
225 xlnx,phy-type = <0x1>; 230 xlnx,phy-type = <0x1>;
@@ -261,6 +266,33 @@
261 xlnx,is-dual = <0x0>; 266 xlnx,is-dual = <0x0>;
262 xlnx,tri-default = <0xffffffff>; 267 xlnx,tri-default = <0xffffffff>;
263 xlnx,tri-default-2 = <0xffffffff>; 268 xlnx,tri-default-2 = <0xffffffff>;
269 #gpio-cells = <2>;
270 gpio-controller;
271 } ;
272
273 gpio-leds {
274 compatible = "gpio-leds";
275
276 heartbeat {
277 label = "Heartbeat";
278 gpios = <&LEDs_8Bit 4 1>;
279 linux,default-trigger = "heartbeat";
280 };
281
282 yellow {
283 label = "Yellow";
284 gpios = <&LEDs_8Bit 5 1>;
285 };
286
287 red {
288 label = "Red";
289 gpios = <&LEDs_8Bit 6 1>;
290 };
291
292 green {
293 label = "Green";
294 gpios = <&LEDs_8Bit 7 1>;
295 };
264 } ; 296 } ;
265 RS232_Uart_1: serial@84000000 { 297 RS232_Uart_1: serial@84000000 {
266 clock-frequency = <125000000>; 298 clock-frequency = <125000000>;
diff --git a/arch/microblaze/platform/platform.c b/arch/microblaze/platform/platform.c
index 56e0234fa34b..5b89b58c5aed 100644
--- a/arch/microblaze/platform/platform.c
+++ b/arch/microblaze/platform/platform.c
@@ -13,6 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/of_platform.h> 14#include <linux/of_platform.h>
15#include <asm/prom.h> 15#include <asm/prom.h>
16#include <asm/setup.h>
16 17
17static struct of_device_id xilinx_of_bus_ids[] __initdata = { 18static struct of_device_id xilinx_of_bus_ids[] __initdata = {
18 { .compatible = "simple-bus", }, 19 { .compatible = "simple-bus", },
@@ -26,6 +27,7 @@ static struct of_device_id xilinx_of_bus_ids[] __initdata = {
26static int __init microblaze_device_probe(void) 27static int __init microblaze_device_probe(void)
27{ 28{
28 of_platform_bus_probe(NULL, xilinx_of_bus_ids, NULL); 29 of_platform_bus_probe(NULL, xilinx_of_bus_ids, NULL);
30 of_platform_reset_gpio_probe();
29 return 0; 31 return 0;
30} 32}
31device_initcall(microblaze_device_probe); 33device_initcall(microblaze_device_probe);
diff --git a/arch/mn10300/kernel/kprobes.c b/arch/mn10300/kernel/kprobes.c
index dacafab00eb2..67e6389d625a 100644
--- a/arch/mn10300/kernel/kprobes.c
+++ b/arch/mn10300/kernel/kprobes.c
@@ -31,13 +31,13 @@ const int kretprobe_blacklist_size = ARRAY_SIZE(kretprobe_blacklist);
31#define KPROBE_HIT_ACTIVE 0x00000001 31#define KPROBE_HIT_ACTIVE 0x00000001
32#define KPROBE_HIT_SS 0x00000002 32#define KPROBE_HIT_SS 0x00000002
33 33
34static struct kprobe *current_kprobe; 34static struct kprobe *cur_kprobe;
35static unsigned long current_kprobe_orig_pc; 35static unsigned long cur_kprobe_orig_pc;
36static unsigned long current_kprobe_next_pc; 36static unsigned long cur_kprobe_next_pc;
37static int current_kprobe_ss_flags; 37static int cur_kprobe_ss_flags;
38static unsigned long kprobe_status; 38static unsigned long kprobe_status;
39static kprobe_opcode_t current_kprobe_ss_buf[MAX_INSN_SIZE + 2]; 39static kprobe_opcode_t cur_kprobe_ss_buf[MAX_INSN_SIZE + 2];
40static unsigned long current_kprobe_bp_addr; 40static unsigned long cur_kprobe_bp_addr;
41 41
42DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; 42DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
43 43
@@ -399,26 +399,25 @@ void __kprobes prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
399{ 399{
400 unsigned long nextpc; 400 unsigned long nextpc;
401 401
402 current_kprobe_orig_pc = regs->pc; 402 cur_kprobe_orig_pc = regs->pc;
403 memcpy(current_kprobe_ss_buf, &p->ainsn.insn[0], MAX_INSN_SIZE); 403 memcpy(cur_kprobe_ss_buf, &p->ainsn.insn[0], MAX_INSN_SIZE);
404 regs->pc = (unsigned long) current_kprobe_ss_buf; 404 regs->pc = (unsigned long) cur_kprobe_ss_buf;
405 405
406 nextpc = find_nextpc(regs, &current_kprobe_ss_flags); 406 nextpc = find_nextpc(regs, &cur_kprobe_ss_flags);
407 if (current_kprobe_ss_flags & SINGLESTEP_PCREL) 407 if (cur_kprobe_ss_flags & SINGLESTEP_PCREL)
408 current_kprobe_next_pc = 408 cur_kprobe_next_pc = cur_kprobe_orig_pc + (nextpc - regs->pc);
409 current_kprobe_orig_pc + (nextpc - regs->pc);
410 else 409 else
411 current_kprobe_next_pc = nextpc; 410 cur_kprobe_next_pc = nextpc;
412 411
413 /* branching instructions need special handling */ 412 /* branching instructions need special handling */
414 if (current_kprobe_ss_flags & SINGLESTEP_BRANCH) 413 if (cur_kprobe_ss_flags & SINGLESTEP_BRANCH)
415 nextpc = singlestep_branch_setup(regs); 414 nextpc = singlestep_branch_setup(regs);
416 415
417 current_kprobe_bp_addr = nextpc; 416 cur_kprobe_bp_addr = nextpc;
418 417
419 *(u8 *) nextpc = BREAKPOINT_INSTRUCTION; 418 *(u8 *) nextpc = BREAKPOINT_INSTRUCTION;
420 mn10300_dcache_flush_range2((unsigned) current_kprobe_ss_buf, 419 mn10300_dcache_flush_range2((unsigned) cur_kprobe_ss_buf,
421 sizeof(current_kprobe_ss_buf)); 420 sizeof(cur_kprobe_ss_buf));
422 mn10300_icache_inv(); 421 mn10300_icache_inv();
423} 422}
424 423
@@ -440,7 +439,7 @@ static inline int __kprobes kprobe_handler(struct pt_regs *regs)
440 disarm_kprobe(p, regs); 439 disarm_kprobe(p, regs);
441 ret = 1; 440 ret = 1;
442 } else { 441 } else {
443 p = current_kprobe; 442 p = cur_kprobe;
444 if (p->break_handler && p->break_handler(p, regs)) 443 if (p->break_handler && p->break_handler(p, regs))
445 goto ss_probe; 444 goto ss_probe;
446 } 445 }
@@ -464,7 +463,7 @@ static inline int __kprobes kprobe_handler(struct pt_regs *regs)
464 } 463 }
465 464
466 kprobe_status = KPROBE_HIT_ACTIVE; 465 kprobe_status = KPROBE_HIT_ACTIVE;
467 current_kprobe = p; 466 cur_kprobe = p;
468 if (p->pre_handler(p, regs)) { 467 if (p->pre_handler(p, regs)) {
469 /* handler has already set things up, so skip ss setup */ 468 /* handler has already set things up, so skip ss setup */
470 return 1; 469 return 1;
@@ -491,8 +490,8 @@ no_kprobe:
491static void __kprobes resume_execution(struct kprobe *p, struct pt_regs *regs) 490static void __kprobes resume_execution(struct kprobe *p, struct pt_regs *regs)
492{ 491{
493 /* we may need to fixup regs/stack after singlestepping a call insn */ 492 /* we may need to fixup regs/stack after singlestepping a call insn */
494 if (current_kprobe_ss_flags & SINGLESTEP_BRANCH) { 493 if (cur_kprobe_ss_flags & SINGLESTEP_BRANCH) {
495 regs->pc = current_kprobe_orig_pc; 494 regs->pc = cur_kprobe_orig_pc;
496 switch (p->ainsn.insn[0]) { 495 switch (p->ainsn.insn[0]) {
497 case 0xcd: /* CALL (d16,PC) */ 496 case 0xcd: /* CALL (d16,PC) */
498 *(unsigned *) regs->sp = regs->mdr = regs->pc + 5; 497 *(unsigned *) regs->sp = regs->mdr = regs->pc + 5;
@@ -523,8 +522,8 @@ static void __kprobes resume_execution(struct kprobe *p, struct pt_regs *regs)
523 } 522 }
524 } 523 }
525 524
526 regs->pc = current_kprobe_next_pc; 525 regs->pc = cur_kprobe_next_pc;
527 current_kprobe_bp_addr = 0; 526 cur_kprobe_bp_addr = 0;
528} 527}
529 528
530static inline int __kprobes post_kprobe_handler(struct pt_regs *regs) 529static inline int __kprobes post_kprobe_handler(struct pt_regs *regs)
@@ -532,10 +531,10 @@ static inline int __kprobes post_kprobe_handler(struct pt_regs *regs)
532 if (!kprobe_running()) 531 if (!kprobe_running())
533 return 0; 532 return 0;
534 533
535 if (current_kprobe->post_handler) 534 if (cur_kprobe->post_handler)
536 current_kprobe->post_handler(current_kprobe, regs, 0); 535 cur_kprobe->post_handler(cur_kprobe, regs, 0);
537 536
538 resume_execution(current_kprobe, regs); 537 resume_execution(cur_kprobe, regs);
539 reset_current_kprobe(); 538 reset_current_kprobe();
540 preempt_enable_no_resched(); 539 preempt_enable_no_resched();
541 return 1; 540 return 1;
@@ -545,12 +544,12 @@ static inline int __kprobes post_kprobe_handler(struct pt_regs *regs)
545static inline 544static inline
546int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr) 545int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
547{ 546{
548 if (current_kprobe->fault_handler && 547 if (cur_kprobe->fault_handler &&
549 current_kprobe->fault_handler(current_kprobe, regs, trapnr)) 548 cur_kprobe->fault_handler(cur_kprobe, regs, trapnr))
550 return 1; 549 return 1;
551 550
552 if (kprobe_status & KPROBE_HIT_SS) { 551 if (kprobe_status & KPROBE_HIT_SS) {
553 resume_execution(current_kprobe, regs); 552 resume_execution(cur_kprobe, regs);
554 reset_current_kprobe(); 553 reset_current_kprobe();
555 preempt_enable_no_resched(); 554 preempt_enable_no_resched();
556 } 555 }
@@ -567,7 +566,7 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
567 566
568 switch (val) { 567 switch (val) {
569 case DIE_BREAKPOINT: 568 case DIE_BREAKPOINT:
570 if (current_kprobe_bp_addr != args->regs->pc) { 569 if (cur_kprobe_bp_addr != args->regs->pc) {
571 if (kprobe_handler(args->regs)) 570 if (kprobe_handler(args->regs))
572 return NOTIFY_STOP; 571 return NOTIFY_STOP;
573 } else { 572 } else {
diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
index d9ea8d39c342..1d3b270d3083 100644
--- a/arch/powerpc/include/asm/smp.h
+++ b/arch/powerpc/include/asm/smp.h
@@ -37,7 +37,7 @@ extern void cpu_die(void);
37extern void smp_send_debugger_break(int cpu); 37extern void smp_send_debugger_break(int cpu);
38extern void smp_message_recv(int); 38extern void smp_message_recv(int);
39 39
40DECLARE_PER_CPU(unsigned int, pvr); 40DECLARE_PER_CPU(unsigned int, cpu_pvr);
41 41
42#ifdef CONFIG_HOTPLUG_CPU 42#ifdef CONFIG_HOTPLUG_CPU
43extern void fixup_irqs(cpumask_t map); 43extern void fixup_irqs(cpumask_t map);
diff --git a/arch/powerpc/kernel/perf_callchain.c b/arch/powerpc/kernel/perf_callchain.c
index 936f04dbfc6f..a3c11cac3d71 100644
--- a/arch/powerpc/kernel/perf_callchain.c
+++ b/arch/powerpc/kernel/perf_callchain.c
@@ -487,11 +487,11 @@ static void perf_callchain_user_32(struct pt_regs *regs,
487 * Since we can't get PMU interrupts inside a PMU interrupt handler, 487 * Since we can't get PMU interrupts inside a PMU interrupt handler,
488 * we don't need separate irq and nmi entries here. 488 * we don't need separate irq and nmi entries here.
489 */ 489 */
490static DEFINE_PER_CPU(struct perf_callchain_entry, callchain); 490static DEFINE_PER_CPU(struct perf_callchain_entry, cpu_perf_callchain);
491 491
492struct perf_callchain_entry *perf_callchain(struct pt_regs *regs) 492struct perf_callchain_entry *perf_callchain(struct pt_regs *regs)
493{ 493{
494 struct perf_callchain_entry *entry = &__get_cpu_var(callchain); 494 struct perf_callchain_entry *entry = &__get_cpu_var(cpu_perf_callchain);
495 495
496 entry->nr = 0; 496 entry->nr = 0;
497 497
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 845c72ab7357..03dd6a248198 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -157,7 +157,7 @@ extern u32 cpu_temp_both(unsigned long cpu);
157#endif /* CONFIG_TAU */ 157#endif /* CONFIG_TAU */
158 158
159#ifdef CONFIG_SMP 159#ifdef CONFIG_SMP
160DEFINE_PER_CPU(unsigned int, pvr); 160DEFINE_PER_CPU(unsigned int, cpu_pvr);
161#endif 161#endif
162 162
163static int show_cpuinfo(struct seq_file *m, void *v) 163static int show_cpuinfo(struct seq_file *m, void *v)
@@ -209,7 +209,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
209 } 209 }
210 210
211#ifdef CONFIG_SMP 211#ifdef CONFIG_SMP
212 pvr = per_cpu(pvr, cpu_id); 212 pvr = per_cpu(cpu_pvr, cpu_id);
213#else 213#else
214 pvr = mfspr(SPRN_PVR); 214 pvr = mfspr(SPRN_PVR);
215#endif 215#endif
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 97196eefef3e..a521fb8a40ee 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -235,7 +235,7 @@ struct thread_info *current_set[NR_CPUS];
235 235
236static void __devinit smp_store_cpu_info(int id) 236static void __devinit smp_store_cpu_info(int id)
237{ 237{
238 per_cpu(pvr, id) = mfspr(SPRN_PVR); 238 per_cpu(cpu_pvr, id) = mfspr(SPRN_PVR);
239} 239}
240 240
241static void __init smp_create_idle(unsigned int cpu) 241static void __init smp_create_idle(unsigned int cpu)
diff --git a/arch/powerpc/platforms/cell/interrupt.c b/arch/powerpc/platforms/cell/interrupt.c
index f9dbf76a763f..7267effc8078 100644
--- a/arch/powerpc/platforms/cell/interrupt.c
+++ b/arch/powerpc/platforms/cell/interrupt.c
@@ -54,7 +54,7 @@ struct iic {
54 struct device_node *node; 54 struct device_node *node;
55}; 55};
56 56
57static DEFINE_PER_CPU(struct iic, iic); 57static DEFINE_PER_CPU(struct iic, cpu_iic);
58#define IIC_NODE_COUNT 2 58#define IIC_NODE_COUNT 2
59static struct irq_host *iic_host; 59static struct irq_host *iic_host;
60 60
@@ -82,7 +82,7 @@ static void iic_unmask(unsigned int irq)
82 82
83static void iic_eoi(unsigned int irq) 83static void iic_eoi(unsigned int irq)
84{ 84{
85 struct iic *iic = &__get_cpu_var(iic); 85 struct iic *iic = &__get_cpu_var(cpu_iic);
86 out_be64(&iic->regs->prio, iic->eoi_stack[--iic->eoi_ptr]); 86 out_be64(&iic->regs->prio, iic->eoi_stack[--iic->eoi_ptr]);
87 BUG_ON(iic->eoi_ptr < 0); 87 BUG_ON(iic->eoi_ptr < 0);
88} 88}
@@ -146,7 +146,7 @@ static unsigned int iic_get_irq(void)
146 struct iic *iic; 146 struct iic *iic;
147 unsigned int virq; 147 unsigned int virq;
148 148
149 iic = &__get_cpu_var(iic); 149 iic = &__get_cpu_var(cpu_iic);
150 *(unsigned long *) &pending = 150 *(unsigned long *) &pending =
151 in_be64((u64 __iomem *) &iic->regs->pending_destr); 151 in_be64((u64 __iomem *) &iic->regs->pending_destr);
152 if (!(pending.flags & CBE_IIC_IRQ_VALID)) 152 if (!(pending.flags & CBE_IIC_IRQ_VALID))
@@ -161,12 +161,12 @@ static unsigned int iic_get_irq(void)
161 161
162void iic_setup_cpu(void) 162void iic_setup_cpu(void)
163{ 163{
164 out_be64(&__get_cpu_var(iic).regs->prio, 0xff); 164 out_be64(&__get_cpu_var(cpu_iic).regs->prio, 0xff);
165} 165}
166 166
167u8 iic_get_target_id(int cpu) 167u8 iic_get_target_id(int cpu)
168{ 168{
169 return per_cpu(iic, cpu).target_id; 169 return per_cpu(cpu_iic, cpu).target_id;
170} 170}
171 171
172EXPORT_SYMBOL_GPL(iic_get_target_id); 172EXPORT_SYMBOL_GPL(iic_get_target_id);
@@ -181,7 +181,7 @@ static inline int iic_ipi_to_irq(int ipi)
181 181
182void iic_cause_IPI(int cpu, int mesg) 182void iic_cause_IPI(int cpu, int mesg)
183{ 183{
184 out_be64(&per_cpu(iic, cpu).regs->generate, (0xf - mesg) << 4); 184 out_be64(&per_cpu(cpu_iic, cpu).regs->generate, (0xf - mesg) << 4);
185} 185}
186 186
187struct irq_host *iic_get_irq_host(int node) 187struct irq_host *iic_get_irq_host(int node)
@@ -348,7 +348,7 @@ static void __init init_one_iic(unsigned int hw_cpu, unsigned long addr,
348 /* XXX FIXME: should locate the linux CPU number from the HW cpu 348 /* XXX FIXME: should locate the linux CPU number from the HW cpu
349 * number properly. We are lucky for now 349 * number properly. We are lucky for now
350 */ 350 */
351 struct iic *iic = &per_cpu(iic, hw_cpu); 351 struct iic *iic = &per_cpu(cpu_iic, hw_cpu);
352 352
353 iic->regs = ioremap(addr, sizeof(struct cbe_iic_thread_regs)); 353 iic->regs = ioremap(addr, sizeof(struct cbe_iic_thread_regs));
354 BUG_ON(iic->regs == NULL); 354 BUG_ON(iic->regs == NULL);
diff --git a/arch/powerpc/platforms/pseries/dtl.c b/arch/powerpc/platforms/pseries/dtl.c
index 937a544a236d..c5f3116b6ca5 100644
--- a/arch/powerpc/platforms/pseries/dtl.c
+++ b/arch/powerpc/platforms/pseries/dtl.c
@@ -54,7 +54,7 @@ struct dtl {
54 int buf_entries; 54 int buf_entries;
55 u64 last_idx; 55 u64 last_idx;
56}; 56};
57static DEFINE_PER_CPU(struct dtl, dtl); 57static DEFINE_PER_CPU(struct dtl, cpu_dtl);
58 58
59/* 59/*
60 * Dispatch trace log event mask: 60 * Dispatch trace log event mask:
@@ -261,7 +261,7 @@ static int dtl_init(void)
261 261
262 /* set up the per-cpu log structures */ 262 /* set up the per-cpu log structures */
263 for_each_possible_cpu(i) { 263 for_each_possible_cpu(i) {
264 struct dtl *dtl = &per_cpu(dtl, i); 264 struct dtl *dtl = &per_cpu(cpu_dtl, i);
265 dtl->cpu = i; 265 dtl->cpu = i;
266 266
267 rc = dtl_setup_file(dtl); 267 rc = dtl_setup_file(dtl);
diff --git a/arch/sparc/kernel/nmi.c b/arch/sparc/kernel/nmi.c
index b129611590a4..f30f4a1ead23 100644
--- a/arch/sparc/kernel/nmi.c
+++ b/arch/sparc/kernel/nmi.c
@@ -47,7 +47,7 @@ static DEFINE_PER_CPU(short, wd_enabled);
47static int endflag __initdata; 47static int endflag __initdata;
48 48
49static DEFINE_PER_CPU(unsigned int, last_irq_sum); 49static DEFINE_PER_CPU(unsigned int, last_irq_sum);
50static DEFINE_PER_CPU(local_t, alert_counter); 50static DEFINE_PER_CPU(long, alert_counter);
51static DEFINE_PER_CPU(int, nmi_touch); 51static DEFINE_PER_CPU(int, nmi_touch);
52 52
53void touch_nmi_watchdog(void) 53void touch_nmi_watchdog(void)
@@ -112,13 +112,13 @@ notrace __kprobes void perfctr_irq(int irq, struct pt_regs *regs)
112 touched = 1; 112 touched = 1;
113 } 113 }
114 if (!touched && __get_cpu_var(last_irq_sum) == sum) { 114 if (!touched && __get_cpu_var(last_irq_sum) == sum) {
115 local_inc(&__get_cpu_var(alert_counter)); 115 __this_cpu_inc(per_cpu_var(alert_counter));
116 if (local_read(&__get_cpu_var(alert_counter)) == 30 * nmi_hz) 116 if (__this_cpu_read(per_cpu_var(alert_counter)) == 30 * nmi_hz)
117 die_nmi("BUG: NMI Watchdog detected LOCKUP", 117 die_nmi("BUG: NMI Watchdog detected LOCKUP",
118 regs, panic_on_timeout); 118 regs, panic_on_timeout);
119 } else { 119 } else {
120 __get_cpu_var(last_irq_sum) = sum; 120 __get_cpu_var(last_irq_sum) = sum;
121 local_set(&__get_cpu_var(alert_counter), 0); 121 __this_cpu_write(per_cpu_var(alert_counter), 0);
122 } 122 }
123 if (__get_cpu_var(wd_enabled)) { 123 if (__get_cpu_var(wd_enabled)) {
124 write_pic(picl_value(nmi_hz)); 124 write_pic(picl_value(nmi_hz));
diff --git a/arch/x86/include/asm/irq_vectors.h b/arch/x86/include/asm/irq_vectors.h
index 6a635bd39867..4611f085cd43 100644
--- a/arch/x86/include/asm/irq_vectors.h
+++ b/arch/x86/include/asm/irq_vectors.h
@@ -113,7 +113,7 @@
113 */ 113 */
114#define LOCAL_PENDING_VECTOR 0xec 114#define LOCAL_PENDING_VECTOR 0xec
115 115
116#define UV_BAU_MESSAGE 0xec 116#define UV_BAU_MESSAGE 0xea
117 117
118/* 118/*
119 * Self IPI vector for machine checks 119 * Self IPI vector for machine checks
diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
index 5bef931f8b14..2d228fc9b4b7 100644
--- a/arch/x86/include/asm/msr.h
+++ b/arch/x86/include/asm/msr.h
@@ -244,6 +244,9 @@ do { \
244 244
245#define write_rdtscp_aux(val) wrmsr(0xc0000103, (val), 0) 245#define write_rdtscp_aux(val) wrmsr(0xc0000103, (val), 0)
246 246
247struct msr *msrs_alloc(void);
248void msrs_free(struct msr *msrs);
249
247#ifdef CONFIG_SMP 250#ifdef CONFIG_SMP
248int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); 251int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
249int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); 252int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h);
diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index b65a36defeb7..0c44196b78ac 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -74,31 +74,31 @@ extern void __bad_percpu_size(void);
74 74
75#define percpu_to_op(op, var, val) \ 75#define percpu_to_op(op, var, val) \
76do { \ 76do { \
77 typedef typeof(var) T__; \ 77 typedef typeof(var) pto_T__; \
78 if (0) { \ 78 if (0) { \
79 T__ tmp__; \ 79 pto_T__ pto_tmp__; \
80 tmp__ = (val); \ 80 pto_tmp__ = (val); \
81 } \ 81 } \
82 switch (sizeof(var)) { \ 82 switch (sizeof(var)) { \
83 case 1: \ 83 case 1: \
84 asm(op "b %1,"__percpu_arg(0) \ 84 asm(op "b %1,"__percpu_arg(0) \
85 : "+m" (var) \ 85 : "+m" (var) \
86 : "qi" ((T__)(val))); \ 86 : "qi" ((pto_T__)(val))); \
87 break; \ 87 break; \
88 case 2: \ 88 case 2: \
89 asm(op "w %1,"__percpu_arg(0) \ 89 asm(op "w %1,"__percpu_arg(0) \
90 : "+m" (var) \ 90 : "+m" (var) \
91 : "ri" ((T__)(val))); \ 91 : "ri" ((pto_T__)(val))); \
92 break; \ 92 break; \
93 case 4: \ 93 case 4: \
94 asm(op "l %1,"__percpu_arg(0) \ 94 asm(op "l %1,"__percpu_arg(0) \
95 : "+m" (var) \ 95 : "+m" (var) \
96 : "ri" ((T__)(val))); \ 96 : "ri" ((pto_T__)(val))); \
97 break; \ 97 break; \
98 case 8: \ 98 case 8: \
99 asm(op "q %1,"__percpu_arg(0) \ 99 asm(op "q %1,"__percpu_arg(0) \
100 : "+m" (var) \ 100 : "+m" (var) \
101 : "re" ((T__)(val))); \ 101 : "re" ((pto_T__)(val))); \
102 break; \ 102 break; \
103 default: __bad_percpu_size(); \ 103 default: __bad_percpu_size(); \
104 } \ 104 } \
@@ -106,31 +106,31 @@ do { \
106 106
107#define percpu_from_op(op, var, constraint) \ 107#define percpu_from_op(op, var, constraint) \
108({ \ 108({ \
109 typeof(var) ret__; \ 109 typeof(var) pfo_ret__; \
110 switch (sizeof(var)) { \ 110 switch (sizeof(var)) { \
111 case 1: \ 111 case 1: \
112 asm(op "b "__percpu_arg(1)",%0" \ 112 asm(op "b "__percpu_arg(1)",%0" \
113 : "=q" (ret__) \ 113 : "=q" (pfo_ret__) \
114 : constraint); \ 114 : constraint); \
115 break; \ 115 break; \
116 case 2: \ 116 case 2: \
117 asm(op "w "__percpu_arg(1)",%0" \ 117 asm(op "w "__percpu_arg(1)",%0" \
118 : "=r" (ret__) \ 118 : "=r" (pfo_ret__) \
119 : constraint); \ 119 : constraint); \
120 break; \ 120 break; \
121 case 4: \ 121 case 4: \
122 asm(op "l "__percpu_arg(1)",%0" \ 122 asm(op "l "__percpu_arg(1)",%0" \
123 : "=r" (ret__) \ 123 : "=r" (pfo_ret__) \
124 : constraint); \ 124 : constraint); \
125 break; \ 125 break; \
126 case 8: \ 126 case 8: \
127 asm(op "q "__percpu_arg(1)",%0" \ 127 asm(op "q "__percpu_arg(1)",%0" \
128 : "=r" (ret__) \ 128 : "=r" (pfo_ret__) \
129 : constraint); \ 129 : constraint); \
130 break; \ 130 break; \
131 default: __bad_percpu_size(); \ 131 default: __bad_percpu_size(); \
132 } \ 132 } \
133 ret__; \ 133 pfo_ret__; \
134}) 134})
135 135
136/* 136/*
@@ -153,6 +153,84 @@ do { \
153#define percpu_or(var, val) percpu_to_op("or", per_cpu__##var, val) 153#define percpu_or(var, val) percpu_to_op("or", per_cpu__##var, val)
154#define percpu_xor(var, val) percpu_to_op("xor", per_cpu__##var, val) 154#define percpu_xor(var, val) percpu_to_op("xor", per_cpu__##var, val)
155 155
156#define __this_cpu_read_1(pcp) percpu_from_op("mov", (pcp), "m"(pcp))
157#define __this_cpu_read_2(pcp) percpu_from_op("mov", (pcp), "m"(pcp))
158#define __this_cpu_read_4(pcp) percpu_from_op("mov", (pcp), "m"(pcp))
159
160#define __this_cpu_write_1(pcp, val) percpu_to_op("mov", (pcp), val)
161#define __this_cpu_write_2(pcp, val) percpu_to_op("mov", (pcp), val)
162#define __this_cpu_write_4(pcp, val) percpu_to_op("mov", (pcp), val)
163#define __this_cpu_add_1(pcp, val) percpu_to_op("add", (pcp), val)
164#define __this_cpu_add_2(pcp, val) percpu_to_op("add", (pcp), val)
165#define __this_cpu_add_4(pcp, val) percpu_to_op("add", (pcp), val)
166#define __this_cpu_and_1(pcp, val) percpu_to_op("and", (pcp), val)
167#define __this_cpu_and_2(pcp, val) percpu_to_op("and", (pcp), val)
168#define __this_cpu_and_4(pcp, val) percpu_to_op("and", (pcp), val)
169#define __this_cpu_or_1(pcp, val) percpu_to_op("or", (pcp), val)
170#define __this_cpu_or_2(pcp, val) percpu_to_op("or", (pcp), val)
171#define __this_cpu_or_4(pcp, val) percpu_to_op("or", (pcp), val)
172#define __this_cpu_xor_1(pcp, val) percpu_to_op("xor", (pcp), val)
173#define __this_cpu_xor_2(pcp, val) percpu_to_op("xor", (pcp), val)
174#define __this_cpu_xor_4(pcp, val) percpu_to_op("xor", (pcp), val)
175
176#define this_cpu_read_1(pcp) percpu_from_op("mov", (pcp), "m"(pcp))
177#define this_cpu_read_2(pcp) percpu_from_op("mov", (pcp), "m"(pcp))
178#define this_cpu_read_4(pcp) percpu_from_op("mov", (pcp), "m"(pcp))
179#define this_cpu_write_1(pcp, val) percpu_to_op("mov", (pcp), val)
180#define this_cpu_write_2(pcp, val) percpu_to_op("mov", (pcp), val)
181#define this_cpu_write_4(pcp, val) percpu_to_op("mov", (pcp), val)
182#define this_cpu_add_1(pcp, val) percpu_to_op("add", (pcp), val)
183#define this_cpu_add_2(pcp, val) percpu_to_op("add", (pcp), val)
184#define this_cpu_add_4(pcp, val) percpu_to_op("add", (pcp), val)
185#define this_cpu_and_1(pcp, val) percpu_to_op("and", (pcp), val)
186#define this_cpu_and_2(pcp, val) percpu_to_op("and", (pcp), val)
187#define this_cpu_and_4(pcp, val) percpu_to_op("and", (pcp), val)
188#define this_cpu_or_1(pcp, val) percpu_to_op("or", (pcp), val)
189#define this_cpu_or_2(pcp, val) percpu_to_op("or", (pcp), val)
190#define this_cpu_or_4(pcp, val) percpu_to_op("or", (pcp), val)
191#define this_cpu_xor_1(pcp, val) percpu_to_op("xor", (pcp), val)
192#define this_cpu_xor_2(pcp, val) percpu_to_op("xor", (pcp), val)
193#define this_cpu_xor_4(pcp, val) percpu_to_op("xor", (pcp), val)
194
195#define irqsafe_cpu_add_1(pcp, val) percpu_to_op("add", (pcp), val)
196#define irqsafe_cpu_add_2(pcp, val) percpu_to_op("add", (pcp), val)
197#define irqsafe_cpu_add_4(pcp, val) percpu_to_op("add", (pcp), val)
198#define irqsafe_cpu_and_1(pcp, val) percpu_to_op("and", (pcp), val)
199#define irqsafe_cpu_and_2(pcp, val) percpu_to_op("and", (pcp), val)
200#define irqsafe_cpu_and_4(pcp, val) percpu_to_op("and", (pcp), val)
201#define irqsafe_cpu_or_1(pcp, val) percpu_to_op("or", (pcp), val)
202#define irqsafe_cpu_or_2(pcp, val) percpu_to_op("or", (pcp), val)
203#define irqsafe_cpu_or_4(pcp, val) percpu_to_op("or", (pcp), val)
204#define irqsafe_cpu_xor_1(pcp, val) percpu_to_op("xor", (pcp), val)
205#define irqsafe_cpu_xor_2(pcp, val) percpu_to_op("xor", (pcp), val)
206#define irqsafe_cpu_xor_4(pcp, val) percpu_to_op("xor", (pcp), val)
207
208/*
209 * Per cpu atomic 64 bit operations are only available under 64 bit.
210 * 32 bit must fall back to generic operations.
211 */
212#ifdef CONFIG_X86_64
213#define __this_cpu_read_8(pcp) percpu_from_op("mov", (pcp), "m"(pcp))
214#define __this_cpu_write_8(pcp, val) percpu_to_op("mov", (pcp), val)
215#define __this_cpu_add_8(pcp, val) percpu_to_op("add", (pcp), val)
216#define __this_cpu_and_8(pcp, val) percpu_to_op("and", (pcp), val)
217#define __this_cpu_or_8(pcp, val) percpu_to_op("or", (pcp), val)
218#define __this_cpu_xor_8(pcp, val) percpu_to_op("xor", (pcp), val)
219
220#define this_cpu_read_8(pcp) percpu_from_op("mov", (pcp), "m"(pcp))
221#define this_cpu_write_8(pcp, val) percpu_to_op("mov", (pcp), val)
222#define this_cpu_add_8(pcp, val) percpu_to_op("add", (pcp), val)
223#define this_cpu_and_8(pcp, val) percpu_to_op("and", (pcp), val)
224#define this_cpu_or_8(pcp, val) percpu_to_op("or", (pcp), val)
225#define this_cpu_xor_8(pcp, val) percpu_to_op("xor", (pcp), val)
226
227#define irqsafe_cpu_add_8(pcp, val) percpu_to_op("add", (pcp), val)
228#define irqsafe_cpu_and_8(pcp, val) percpu_to_op("and", (pcp), val)
229#define irqsafe_cpu_or_8(pcp, val) percpu_to_op("or", (pcp), val)
230#define irqsafe_cpu_xor_8(pcp, val) percpu_to_op("xor", (pcp), val)
231
232#endif
233
156/* This is not atomic against other CPUs -- CPU preemption needs to be off */ 234/* This is not atomic against other CPUs -- CPU preemption needs to be off */
157#define x86_test_and_clear_bit_percpu(bit, var) \ 235#define x86_test_and_clear_bit_percpu(bit, var) \
158({ \ 236({ \
diff --git a/arch/x86/include/asm/trampoline.h b/arch/x86/include/asm/trampoline.h
index 90f06c25221d..cb507bb05d79 100644
--- a/arch/x86/include/asm/trampoline.h
+++ b/arch/x86/include/asm/trampoline.h
@@ -16,7 +16,6 @@ extern unsigned long initial_code;
16extern unsigned long initial_gs; 16extern unsigned long initial_gs;
17 17
18#define TRAMPOLINE_SIZE roundup(trampoline_end - trampoline_data, PAGE_SIZE) 18#define TRAMPOLINE_SIZE roundup(trampoline_end - trampoline_data, PAGE_SIZE)
19#define TRAMPOLINE_BASE 0x6000
20 19
21extern unsigned long setup_trampoline(void); 20extern unsigned long setup_trampoline(void);
22extern void __init reserve_trampoline_memory(void); 21extern void __init reserve_trampoline_memory(void);
diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c
index e0dfb6856aa2..3704997e8b25 100644
--- a/arch/x86/kernel/aperture_64.c
+++ b/arch/x86/kernel/aperture_64.c
@@ -280,7 +280,8 @@ void __init early_gart_iommu_check(void)
280 * or BIOS forget to put that in reserved. 280 * or BIOS forget to put that in reserved.
281 * try to update e820 to make that region as reserved. 281 * try to update e820 to make that region as reserved.
282 */ 282 */
283 int i, fix, slot; 283 u32 agp_aper_base = 0, agp_aper_order = 0;
284 int i, fix, slot, valid_agp = 0;
284 u32 ctl; 285 u32 ctl;
285 u32 aper_size = 0, aper_order = 0, last_aper_order = 0; 286 u32 aper_size = 0, aper_order = 0, last_aper_order = 0;
286 u64 aper_base = 0, last_aper_base = 0; 287 u64 aper_base = 0, last_aper_base = 0;
@@ -290,6 +291,8 @@ void __init early_gart_iommu_check(void)
290 return; 291 return;
291 292
292 /* This is mostly duplicate of iommu_hole_init */ 293 /* This is mostly duplicate of iommu_hole_init */
294 agp_aper_base = search_agp_bridge(&agp_aper_order, &valid_agp);
295
293 fix = 0; 296 fix = 0;
294 for (i = 0; i < ARRAY_SIZE(bus_dev_ranges); i++) { 297 for (i = 0; i < ARRAY_SIZE(bus_dev_ranges); i++) {
295 int bus; 298 int bus;
@@ -342,10 +345,10 @@ void __init early_gart_iommu_check(void)
342 } 345 }
343 } 346 }
344 347
345 if (!fix) 348 if (valid_agp)
346 return; 349 return;
347 350
348 /* different nodes have different setting, disable them all at first*/ 351 /* disable them all at first */
349 for (i = 0; i < ARRAY_SIZE(bus_dev_ranges); i++) { 352 for (i = 0; i < ARRAY_SIZE(bus_dev_ranges); i++) {
350 int bus; 353 int bus;
351 int dev_base, dev_limit; 354 int dev_base, dev_limit;
@@ -458,8 +461,6 @@ out:
458 461
459 if (aper_alloc) { 462 if (aper_alloc) {
460 /* Got the aperture from the AGP bridge */ 463 /* Got the aperture from the AGP bridge */
461 } else if (!valid_agp) {
462 /* Do nothing */
463 } else if ((!no_iommu && max_pfn > MAX_DMA32_PFN) || 464 } else if ((!no_iommu && max_pfn > MAX_DMA32_PFN) ||
464 force_iommu || 465 force_iommu ||
465 valid_agp || 466 valid_agp ||
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index efb2b9cd132c..aa57c079c98f 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1341,7 +1341,7 @@ void enable_x2apic(void)
1341 1341
1342 rdmsr(MSR_IA32_APICBASE, msr, msr2); 1342 rdmsr(MSR_IA32_APICBASE, msr, msr2);
1343 if (!(msr & X2APIC_ENABLE)) { 1343 if (!(msr & X2APIC_ENABLE)) {
1344 pr_info("Enabling x2apic\n"); 1344 printk_once(KERN_INFO "Enabling x2apic\n");
1345 wrmsr(MSR_IA32_APICBASE, msr | X2APIC_ENABLE, 0); 1345 wrmsr(MSR_IA32_APICBASE, msr | X2APIC_ENABLE, 0);
1346 } 1346 }
1347} 1347}
diff --git a/arch/x86/kernel/apic/nmi.c b/arch/x86/kernel/apic/nmi.c
index 6389432a9dbf..0159a69396cb 100644
--- a/arch/x86/kernel/apic/nmi.c
+++ b/arch/x86/kernel/apic/nmi.c
@@ -361,7 +361,7 @@ void stop_apic_nmi_watchdog(void *unused)
361 */ 361 */
362 362
363static DEFINE_PER_CPU(unsigned, last_irq_sum); 363static DEFINE_PER_CPU(unsigned, last_irq_sum);
364static DEFINE_PER_CPU(local_t, alert_counter); 364static DEFINE_PER_CPU(long, alert_counter);
365static DEFINE_PER_CPU(int, nmi_touch); 365static DEFINE_PER_CPU(int, nmi_touch);
366 366
367void touch_nmi_watchdog(void) 367void touch_nmi_watchdog(void)
@@ -438,8 +438,8 @@ nmi_watchdog_tick(struct pt_regs *regs, unsigned reason)
438 * Ayiee, looks like this CPU is stuck ... 438 * Ayiee, looks like this CPU is stuck ...
439 * wait a few IRQs (5 seconds) before doing the oops ... 439 * wait a few IRQs (5 seconds) before doing the oops ...
440 */ 440 */
441 local_inc(&__get_cpu_var(alert_counter)); 441 __this_cpu_inc(per_cpu_var(alert_counter));
442 if (local_read(&__get_cpu_var(alert_counter)) == 5 * nmi_hz) 442 if (__this_cpu_read(per_cpu_var(alert_counter)) == 5 * nmi_hz)
443 /* 443 /*
444 * die_nmi will return ONLY if NOTIFY_STOP happens.. 444 * die_nmi will return ONLY if NOTIFY_STOP happens..
445 */ 445 */
@@ -447,7 +447,7 @@ nmi_watchdog_tick(struct pt_regs *regs, unsigned reason)
447 regs, panic_on_timeout); 447 regs, panic_on_timeout);
448 } else { 448 } else {
449 __get_cpu_var(last_irq_sum) = sum; 449 __get_cpu_var(last_irq_sum) = sum;
450 local_set(&__get_cpu_var(alert_counter), 0); 450 __this_cpu_write(per_cpu_var(alert_counter), 0);
451 } 451 }
452 452
453 /* see if the nmi watchdog went off */ 453 /* see if the nmi watchdog went off */
diff --git a/arch/x86/kernel/cpu/addon_cpuid_features.c b/arch/x86/kernel/cpu/addon_cpuid_features.c
index c965e5212714..468489b57aae 100644
--- a/arch/x86/kernel/cpu/addon_cpuid_features.c
+++ b/arch/x86/kernel/cpu/addon_cpuid_features.c
@@ -74,6 +74,7 @@ void __cpuinit detect_extended_topology(struct cpuinfo_x86 *c)
74 unsigned int eax, ebx, ecx, edx, sub_index; 74 unsigned int eax, ebx, ecx, edx, sub_index;
75 unsigned int ht_mask_width, core_plus_mask_width; 75 unsigned int ht_mask_width, core_plus_mask_width;
76 unsigned int core_select_mask, core_level_siblings; 76 unsigned int core_select_mask, core_level_siblings;
77 static bool printed;
77 78
78 if (c->cpuid_level < 0xb) 79 if (c->cpuid_level < 0xb)
79 return; 80 return;
@@ -127,12 +128,14 @@ void __cpuinit detect_extended_topology(struct cpuinfo_x86 *c)
127 128
128 c->x86_max_cores = (core_level_siblings / smp_num_siblings); 129 c->x86_max_cores = (core_level_siblings / smp_num_siblings);
129 130
130 131 if (!printed) {
131 printk(KERN_INFO "CPU: Physical Processor ID: %d\n", 132 printk(KERN_INFO "CPU: Physical Processor ID: %d\n",
132 c->phys_proc_id); 133 c->phys_proc_id);
133 if (c->x86_max_cores > 1) 134 if (c->x86_max_cores > 1)
134 printk(KERN_INFO "CPU: Processor Core ID: %d\n", 135 printk(KERN_INFO "CPU: Processor Core ID: %d\n",
135 c->cpu_core_id); 136 c->cpu_core_id);
137 printed = 1;
138 }
136 return; 139 return;
137#endif 140#endif
138} 141}
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 7128b3799cec..8dc3ea145c97 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -375,8 +375,6 @@ static void __cpuinit srat_detect_node(struct cpuinfo_x86 *c)
375 node = nearby_node(apicid); 375 node = nearby_node(apicid);
376 } 376 }
377 numa_set_node(cpu, node); 377 numa_set_node(cpu, node);
378
379 printk(KERN_INFO "CPU %d/0x%x -> Node %d\n", cpu, apicid, node);
380#endif 378#endif
381} 379}
382 380
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index c1afa990a6c8..4868e4a951ee 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -427,6 +427,7 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c)
427#ifdef CONFIG_X86_HT 427#ifdef CONFIG_X86_HT
428 u32 eax, ebx, ecx, edx; 428 u32 eax, ebx, ecx, edx;
429 int index_msb, core_bits; 429 int index_msb, core_bits;
430 static bool printed;
430 431
431 if (!cpu_has(c, X86_FEATURE_HT)) 432 if (!cpu_has(c, X86_FEATURE_HT))
432 return; 433 return;
@@ -442,7 +443,7 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c)
442 smp_num_siblings = (ebx & 0xff0000) >> 16; 443 smp_num_siblings = (ebx & 0xff0000) >> 16;
443 444
444 if (smp_num_siblings == 1) { 445 if (smp_num_siblings == 1) {
445 printk(KERN_INFO "CPU: Hyper-Threading is disabled\n"); 446 printk_once(KERN_INFO "CPU0: Hyper-Threading is disabled\n");
446 goto out; 447 goto out;
447 } 448 }
448 449
@@ -469,11 +470,12 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c)
469 ((1 << core_bits) - 1); 470 ((1 << core_bits) - 1);
470 471
471out: 472out:
472 if ((c->x86_max_cores * smp_num_siblings) > 1) { 473 if (!printed && (c->x86_max_cores * smp_num_siblings) > 1) {
473 printk(KERN_INFO "CPU: Physical Processor ID: %d\n", 474 printk(KERN_INFO "CPU: Physical Processor ID: %d\n",
474 c->phys_proc_id); 475 c->phys_proc_id);
475 printk(KERN_INFO "CPU: Processor Core ID: %d\n", 476 printk(KERN_INFO "CPU: Processor Core ID: %d\n",
476 c->cpu_core_id); 477 c->cpu_core_id);
478 printed = 1;
477 } 479 }
478#endif 480#endif
479} 481}
@@ -1093,7 +1095,7 @@ static void clear_all_debug_regs(void)
1093 1095
1094void __cpuinit cpu_init(void) 1096void __cpuinit cpu_init(void)
1095{ 1097{
1096 struct orig_ist *orig_ist; 1098 struct orig_ist *oist;
1097 struct task_struct *me; 1099 struct task_struct *me;
1098 struct tss_struct *t; 1100 struct tss_struct *t;
1099 unsigned long v; 1101 unsigned long v;
@@ -1102,7 +1104,7 @@ void __cpuinit cpu_init(void)
1102 1104
1103 cpu = stack_smp_processor_id(); 1105 cpu = stack_smp_processor_id();
1104 t = &per_cpu(init_tss, cpu); 1106 t = &per_cpu(init_tss, cpu);
1105 orig_ist = &per_cpu(orig_ist, cpu); 1107 oist = &per_cpu(orig_ist, cpu);
1106 1108
1107#ifdef CONFIG_NUMA 1109#ifdef CONFIG_NUMA
1108 if (cpu != 0 && percpu_read(node_number) == 0 && 1110 if (cpu != 0 && percpu_read(node_number) == 0 &&
@@ -1115,7 +1117,7 @@ void __cpuinit cpu_init(void)
1115 if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) 1117 if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask))
1116 panic("CPU#%d already initialized!\n", cpu); 1118 panic("CPU#%d already initialized!\n", cpu);
1117 1119
1118 printk(KERN_INFO "Initializing CPU#%d\n", cpu); 1120 pr_debug("Initializing CPU#%d\n", cpu);
1119 1121
1120 clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE); 1122 clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
1121 1123
@@ -1143,12 +1145,12 @@ void __cpuinit cpu_init(void)
1143 /* 1145 /*
1144 * set up and load the per-CPU TSS 1146 * set up and load the per-CPU TSS
1145 */ 1147 */
1146 if (!orig_ist->ist[0]) { 1148 if (!oist->ist[0]) {
1147 char *estacks = per_cpu(exception_stacks, cpu); 1149 char *estacks = per_cpu(exception_stacks, cpu);
1148 1150
1149 for (v = 0; v < N_EXCEPTION_STACKS; v++) { 1151 for (v = 0; v < N_EXCEPTION_STACKS; v++) {
1150 estacks += exception_stack_sizes[v]; 1152 estacks += exception_stack_sizes[v];
1151 orig_ist->ist[v] = t->x86_tss.ist[v] = 1153 oist->ist[v] = t->x86_tss.ist[v] =
1152 (unsigned long)estacks; 1154 (unsigned long)estacks;
1153 } 1155 }
1154 } 1156 }
diff --git a/arch/x86/kernel/cpu/cpu_debug.c b/arch/x86/kernel/cpu/cpu_debug.c
index dca325c03999..b368cd862997 100644
--- a/arch/x86/kernel/cpu/cpu_debug.c
+++ b/arch/x86/kernel/cpu/cpu_debug.c
@@ -30,9 +30,9 @@
30#include <asm/apic.h> 30#include <asm/apic.h>
31#include <asm/desc.h> 31#include <asm/desc.h>
32 32
33static DEFINE_PER_CPU(struct cpu_cpuX_base [CPU_REG_ALL_BIT], cpu_arr); 33static DEFINE_PER_CPU(struct cpu_cpuX_base [CPU_REG_ALL_BIT], cpud_arr);
34static DEFINE_PER_CPU(struct cpu_private * [MAX_CPU_FILES], priv_arr); 34static DEFINE_PER_CPU(struct cpu_private * [MAX_CPU_FILES], cpud_priv_arr);
35static DEFINE_PER_CPU(int, cpu_priv_count); 35static DEFINE_PER_CPU(int, cpud_priv_count);
36 36
37static DEFINE_MUTEX(cpu_debug_lock); 37static DEFINE_MUTEX(cpu_debug_lock);
38 38
@@ -531,7 +531,7 @@ static int cpu_create_file(unsigned cpu, unsigned type, unsigned reg,
531 531
532 /* Already intialized */ 532 /* Already intialized */
533 if (file == CPU_INDEX_BIT) 533 if (file == CPU_INDEX_BIT)
534 if (per_cpu(cpu_arr[type].init, cpu)) 534 if (per_cpu(cpud_arr[type].init, cpu))
535 return 0; 535 return 0;
536 536
537 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 537 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
@@ -543,8 +543,8 @@ static int cpu_create_file(unsigned cpu, unsigned type, unsigned reg,
543 priv->reg = reg; 543 priv->reg = reg;
544 priv->file = file; 544 priv->file = file;
545 mutex_lock(&cpu_debug_lock); 545 mutex_lock(&cpu_debug_lock);
546 per_cpu(priv_arr[type], cpu) = priv; 546 per_cpu(cpud_priv_arr[type], cpu) = priv;
547 per_cpu(cpu_priv_count, cpu)++; 547 per_cpu(cpud_priv_count, cpu)++;
548 mutex_unlock(&cpu_debug_lock); 548 mutex_unlock(&cpu_debug_lock);
549 549
550 if (file) 550 if (file)
@@ -552,10 +552,10 @@ static int cpu_create_file(unsigned cpu, unsigned type, unsigned reg,
552 dentry, (void *)priv, &cpu_fops); 552 dentry, (void *)priv, &cpu_fops);
553 else { 553 else {
554 debugfs_create_file(cpu_base[type].name, S_IRUGO, 554 debugfs_create_file(cpu_base[type].name, S_IRUGO,
555 per_cpu(cpu_arr[type].dentry, cpu), 555 per_cpu(cpud_arr[type].dentry, cpu),
556 (void *)priv, &cpu_fops); 556 (void *)priv, &cpu_fops);
557 mutex_lock(&cpu_debug_lock); 557 mutex_lock(&cpu_debug_lock);
558 per_cpu(cpu_arr[type].init, cpu) = 1; 558 per_cpu(cpud_arr[type].init, cpu) = 1;
559 mutex_unlock(&cpu_debug_lock); 559 mutex_unlock(&cpu_debug_lock);
560 } 560 }
561 561
@@ -615,7 +615,7 @@ static int cpu_init_allreg(unsigned cpu, struct dentry *dentry)
615 if (!is_typeflag_valid(cpu, cpu_base[type].flag)) 615 if (!is_typeflag_valid(cpu, cpu_base[type].flag))
616 continue; 616 continue;
617 cpu_dentry = debugfs_create_dir(cpu_base[type].name, dentry); 617 cpu_dentry = debugfs_create_dir(cpu_base[type].name, dentry);
618 per_cpu(cpu_arr[type].dentry, cpu) = cpu_dentry; 618 per_cpu(cpud_arr[type].dentry, cpu) = cpu_dentry;
619 619
620 if (type < CPU_TSS_BIT) 620 if (type < CPU_TSS_BIT)
621 err = cpu_init_msr(cpu, type, cpu_dentry); 621 err = cpu_init_msr(cpu, type, cpu_dentry);
@@ -647,11 +647,11 @@ static int cpu_init_cpu(void)
647 err = cpu_init_allreg(cpu, cpu_dentry); 647 err = cpu_init_allreg(cpu, cpu_dentry);
648 648
649 pr_info("cpu%d(%d) debug files %d\n", 649 pr_info("cpu%d(%d) debug files %d\n",
650 cpu, nr_cpu_ids, per_cpu(cpu_priv_count, cpu)); 650 cpu, nr_cpu_ids, per_cpu(cpud_priv_count, cpu));
651 if (per_cpu(cpu_priv_count, cpu) > MAX_CPU_FILES) { 651 if (per_cpu(cpud_priv_count, cpu) > MAX_CPU_FILES) {
652 pr_err("Register files count %d exceeds limit %d\n", 652 pr_err("Register files count %d exceeds limit %d\n",
653 per_cpu(cpu_priv_count, cpu), MAX_CPU_FILES); 653 per_cpu(cpud_priv_count, cpu), MAX_CPU_FILES);
654 per_cpu(cpu_priv_count, cpu) = MAX_CPU_FILES; 654 per_cpu(cpud_priv_count, cpu) = MAX_CPU_FILES;
655 err = -ENFILE; 655 err = -ENFILE;
656 } 656 }
657 if (err) 657 if (err)
@@ -676,8 +676,8 @@ static void __exit cpu_debug_exit(void)
676 debugfs_remove_recursive(cpu_debugfs_dir); 676 debugfs_remove_recursive(cpu_debugfs_dir);
677 677
678 for (cpu = 0; cpu < nr_cpu_ids; cpu++) 678 for (cpu = 0; cpu < nr_cpu_ids; cpu++)
679 for (i = 0; i < per_cpu(cpu_priv_count, cpu); i++) 679 for (i = 0; i < per_cpu(cpud_priv_count, cpu); i++)
680 kfree(per_cpu(priv_arr[i], cpu)); 680 kfree(per_cpu(cpud_priv_arr[i], cpu));
681} 681}
682 682
683module_init(cpu_debug_init); 683module_init(cpu_debug_init);
diff --git a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
index d2e7c77c1ea4..f28decf8dde3 100644
--- a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -68,9 +68,9 @@ struct acpi_cpufreq_data {
68 unsigned int cpu_feature; 68 unsigned int cpu_feature;
69}; 69};
70 70
71static DEFINE_PER_CPU(struct acpi_cpufreq_data *, drv_data); 71static DEFINE_PER_CPU(struct acpi_cpufreq_data *, acfreq_data);
72 72
73static DEFINE_PER_CPU(struct aperfmperf, old_perf); 73static DEFINE_PER_CPU(struct aperfmperf, acfreq_old_perf);
74 74
75/* acpi_perf_data is a pointer to percpu data. */ 75/* acpi_perf_data is a pointer to percpu data. */
76static struct acpi_processor_performance *acpi_perf_data; 76static struct acpi_processor_performance *acpi_perf_data;
@@ -214,14 +214,14 @@ static u32 get_cur_val(const struct cpumask *mask)
214 if (unlikely(cpumask_empty(mask))) 214 if (unlikely(cpumask_empty(mask)))
215 return 0; 215 return 0;
216 216
217 switch (per_cpu(drv_data, cpumask_first(mask))->cpu_feature) { 217 switch (per_cpu(acfreq_data, cpumask_first(mask))->cpu_feature) {
218 case SYSTEM_INTEL_MSR_CAPABLE: 218 case SYSTEM_INTEL_MSR_CAPABLE:
219 cmd.type = SYSTEM_INTEL_MSR_CAPABLE; 219 cmd.type = SYSTEM_INTEL_MSR_CAPABLE;
220 cmd.addr.msr.reg = MSR_IA32_PERF_STATUS; 220 cmd.addr.msr.reg = MSR_IA32_PERF_STATUS;
221 break; 221 break;
222 case SYSTEM_IO_CAPABLE: 222 case SYSTEM_IO_CAPABLE:
223 cmd.type = SYSTEM_IO_CAPABLE; 223 cmd.type = SYSTEM_IO_CAPABLE;
224 perf = per_cpu(drv_data, cpumask_first(mask))->acpi_data; 224 perf = per_cpu(acfreq_data, cpumask_first(mask))->acpi_data;
225 cmd.addr.io.port = perf->control_register.address; 225 cmd.addr.io.port = perf->control_register.address;
226 cmd.addr.io.bit_width = perf->control_register.bit_width; 226 cmd.addr.io.bit_width = perf->control_register.bit_width;
227 break; 227 break;
@@ -268,8 +268,8 @@ static unsigned int get_measured_perf(struct cpufreq_policy *policy,
268 if (smp_call_function_single(cpu, read_measured_perf_ctrs, &perf, 1)) 268 if (smp_call_function_single(cpu, read_measured_perf_ctrs, &perf, 1))
269 return 0; 269 return 0;
270 270
271 ratio = calc_aperfmperf_ratio(&per_cpu(old_perf, cpu), &perf); 271 ratio = calc_aperfmperf_ratio(&per_cpu(acfreq_old_perf, cpu), &perf);
272 per_cpu(old_perf, cpu) = perf; 272 per_cpu(acfreq_old_perf, cpu) = perf;
273 273
274 retval = (policy->cpuinfo.max_freq * ratio) >> APERFMPERF_SHIFT; 274 retval = (policy->cpuinfo.max_freq * ratio) >> APERFMPERF_SHIFT;
275 275
@@ -278,7 +278,7 @@ static unsigned int get_measured_perf(struct cpufreq_policy *policy,
278 278
279static unsigned int get_cur_freq_on_cpu(unsigned int cpu) 279static unsigned int get_cur_freq_on_cpu(unsigned int cpu)
280{ 280{
281 struct acpi_cpufreq_data *data = per_cpu(drv_data, cpu); 281 struct acpi_cpufreq_data *data = per_cpu(acfreq_data, cpu);
282 unsigned int freq; 282 unsigned int freq;
283 unsigned int cached_freq; 283 unsigned int cached_freq;
284 284
@@ -322,7 +322,7 @@ static unsigned int check_freqs(const struct cpumask *mask, unsigned int freq,
322static int acpi_cpufreq_target(struct cpufreq_policy *policy, 322static int acpi_cpufreq_target(struct cpufreq_policy *policy,
323 unsigned int target_freq, unsigned int relation) 323 unsigned int target_freq, unsigned int relation)
324{ 324{
325 struct acpi_cpufreq_data *data = per_cpu(drv_data, policy->cpu); 325 struct acpi_cpufreq_data *data = per_cpu(acfreq_data, policy->cpu);
326 struct acpi_processor_performance *perf; 326 struct acpi_processor_performance *perf;
327 struct cpufreq_freqs freqs; 327 struct cpufreq_freqs freqs;
328 struct drv_cmd cmd; 328 struct drv_cmd cmd;
@@ -416,7 +416,7 @@ out:
416 416
417static int acpi_cpufreq_verify(struct cpufreq_policy *policy) 417static int acpi_cpufreq_verify(struct cpufreq_policy *policy)
418{ 418{
419 struct acpi_cpufreq_data *data = per_cpu(drv_data, policy->cpu); 419 struct acpi_cpufreq_data *data = per_cpu(acfreq_data, policy->cpu);
420 420
421 dprintk("acpi_cpufreq_verify\n"); 421 dprintk("acpi_cpufreq_verify\n");
422 422
@@ -574,7 +574,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
574 return -ENOMEM; 574 return -ENOMEM;
575 575
576 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu); 576 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
577 per_cpu(drv_data, cpu) = data; 577 per_cpu(acfreq_data, cpu) = data;
578 578
579 if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) 579 if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
580 acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS; 580 acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
@@ -725,20 +725,20 @@ err_unreg:
725 acpi_processor_unregister_performance(perf, cpu); 725 acpi_processor_unregister_performance(perf, cpu);
726err_free: 726err_free:
727 kfree(data); 727 kfree(data);
728 per_cpu(drv_data, cpu) = NULL; 728 per_cpu(acfreq_data, cpu) = NULL;
729 729
730 return result; 730 return result;
731} 731}
732 732
733static int acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy) 733static int acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy)
734{ 734{
735 struct acpi_cpufreq_data *data = per_cpu(drv_data, policy->cpu); 735 struct acpi_cpufreq_data *data = per_cpu(acfreq_data, policy->cpu);
736 736
737 dprintk("acpi_cpufreq_cpu_exit\n"); 737 dprintk("acpi_cpufreq_cpu_exit\n");
738 738
739 if (data) { 739 if (data) {
740 cpufreq_frequency_table_put_attr(policy->cpu); 740 cpufreq_frequency_table_put_attr(policy->cpu);
741 per_cpu(drv_data, policy->cpu) = NULL; 741 per_cpu(acfreq_data, policy->cpu) = NULL;
742 acpi_processor_unregister_performance(data->acpi_data, 742 acpi_processor_unregister_performance(data->acpi_data,
743 policy->cpu); 743 policy->cpu);
744 kfree(data); 744 kfree(data);
@@ -749,7 +749,7 @@ static int acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy)
749 749
750static int acpi_cpufreq_resume(struct cpufreq_policy *policy) 750static int acpi_cpufreq_resume(struct cpufreq_policy *policy)
751{ 751{
752 struct acpi_cpufreq_data *data = per_cpu(drv_data, policy->cpu); 752 struct acpi_cpufreq_data *data = per_cpu(acfreq_data, policy->cpu);
753 753
754 dprintk("acpi_cpufreq_resume\n"); 754 dprintk("acpi_cpufreq_resume\n");
755 755
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index c900b73f9224..9c31e8b09d2c 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -270,8 +270,6 @@ static void __cpuinit srat_detect_node(struct cpuinfo_x86 *c)
270 node = cpu_to_node(cpu); 270 node = cpu_to_node(cpu);
271 } 271 }
272 numa_set_node(cpu, node); 272 numa_set_node(cpu, node);
273
274 printk(KERN_INFO "CPU %d/0x%x -> Node %d\n", cpu, apicid, node);
275#endif 273#endif
276} 274}
277 275
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 6c40f6b5b340..fc6c8ef92dcc 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -499,26 +499,27 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
499#ifdef CONFIG_SYSFS 499#ifdef CONFIG_SYSFS
500 500
501/* pointer to _cpuid4_info array (for each cache leaf) */ 501/* pointer to _cpuid4_info array (for each cache leaf) */
502static DEFINE_PER_CPU(struct _cpuid4_info *, cpuid4_info); 502static DEFINE_PER_CPU(struct _cpuid4_info *, ici_cpuid4_info);
503#define CPUID4_INFO_IDX(x, y) (&((per_cpu(cpuid4_info, x))[y])) 503#define CPUID4_INFO_IDX(x, y) (&((per_cpu(ici_cpuid4_info, x))[y]))
504 504
505#ifdef CONFIG_SMP 505#ifdef CONFIG_SMP
506static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index) 506static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index)
507{ 507{
508 struct _cpuid4_info *this_leaf, *sibling_leaf; 508 struct _cpuid4_info *this_leaf, *sibling_leaf;
509 unsigned long num_threads_sharing; 509 unsigned long num_threads_sharing;
510 int index_msb, i; 510 int index_msb, i, sibling;
511 struct cpuinfo_x86 *c = &cpu_data(cpu); 511 struct cpuinfo_x86 *c = &cpu_data(cpu);
512 512
513 if ((index == 3) && (c->x86_vendor == X86_VENDOR_AMD)) { 513 if ((index == 3) && (c->x86_vendor == X86_VENDOR_AMD)) {
514 struct cpuinfo_x86 *d; 514 for_each_cpu(i, c->llc_shared_map) {
515 for_each_online_cpu(i) { 515 if (!per_cpu(ici_cpuid4_info, i))
516 if (!per_cpu(cpuid4_info, i))
517 continue; 516 continue;
518 d = &cpu_data(i);
519 this_leaf = CPUID4_INFO_IDX(i, index); 517 this_leaf = CPUID4_INFO_IDX(i, index);
520 cpumask_copy(to_cpumask(this_leaf->shared_cpu_map), 518 for_each_cpu(sibling, c->llc_shared_map) {
521 d->llc_shared_map); 519 if (!cpu_online(sibling))
520 continue;
521 set_bit(sibling, this_leaf->shared_cpu_map);
522 }
522 } 523 }
523 return; 524 return;
524 } 525 }
@@ -535,7 +536,7 @@ static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index)
535 c->apicid >> index_msb) { 536 c->apicid >> index_msb) {
536 cpumask_set_cpu(i, 537 cpumask_set_cpu(i,
537 to_cpumask(this_leaf->shared_cpu_map)); 538 to_cpumask(this_leaf->shared_cpu_map));
538 if (i != cpu && per_cpu(cpuid4_info, i)) { 539 if (i != cpu && per_cpu(ici_cpuid4_info, i)) {
539 sibling_leaf = 540 sibling_leaf =
540 CPUID4_INFO_IDX(i, index); 541 CPUID4_INFO_IDX(i, index);
541 cpumask_set_cpu(cpu, to_cpumask( 542 cpumask_set_cpu(cpu, to_cpumask(
@@ -574,8 +575,8 @@ static void __cpuinit free_cache_attributes(unsigned int cpu)
574 for (i = 0; i < num_cache_leaves; i++) 575 for (i = 0; i < num_cache_leaves; i++)
575 cache_remove_shared_cpu_map(cpu, i); 576 cache_remove_shared_cpu_map(cpu, i);
576 577
577 kfree(per_cpu(cpuid4_info, cpu)); 578 kfree(per_cpu(ici_cpuid4_info, cpu));
578 per_cpu(cpuid4_info, cpu) = NULL; 579 per_cpu(ici_cpuid4_info, cpu) = NULL;
579} 580}
580 581
581static int 582static int
@@ -614,15 +615,15 @@ static int __cpuinit detect_cache_attributes(unsigned int cpu)
614 if (num_cache_leaves == 0) 615 if (num_cache_leaves == 0)
615 return -ENOENT; 616 return -ENOENT;
616 617
617 per_cpu(cpuid4_info, cpu) = kzalloc( 618 per_cpu(ici_cpuid4_info, cpu) = kzalloc(
618 sizeof(struct _cpuid4_info) * num_cache_leaves, GFP_KERNEL); 619 sizeof(struct _cpuid4_info) * num_cache_leaves, GFP_KERNEL);
619 if (per_cpu(cpuid4_info, cpu) == NULL) 620 if (per_cpu(ici_cpuid4_info, cpu) == NULL)
620 return -ENOMEM; 621 return -ENOMEM;
621 622
622 smp_call_function_single(cpu, get_cpu_leaves, &retval, true); 623 smp_call_function_single(cpu, get_cpu_leaves, &retval, true);
623 if (retval) { 624 if (retval) {
624 kfree(per_cpu(cpuid4_info, cpu)); 625 kfree(per_cpu(ici_cpuid4_info, cpu));
625 per_cpu(cpuid4_info, cpu) = NULL; 626 per_cpu(ici_cpuid4_info, cpu) = NULL;
626 } 627 }
627 628
628 return retval; 629 return retval;
@@ -634,7 +635,7 @@ static int __cpuinit detect_cache_attributes(unsigned int cpu)
634extern struct sysdev_class cpu_sysdev_class; /* from drivers/base/cpu.c */ 635extern struct sysdev_class cpu_sysdev_class; /* from drivers/base/cpu.c */
635 636
636/* pointer to kobject for cpuX/cache */ 637/* pointer to kobject for cpuX/cache */
637static DEFINE_PER_CPU(struct kobject *, cache_kobject); 638static DEFINE_PER_CPU(struct kobject *, ici_cache_kobject);
638 639
639struct _index_kobject { 640struct _index_kobject {
640 struct kobject kobj; 641 struct kobject kobj;
@@ -643,8 +644,8 @@ struct _index_kobject {
643}; 644};
644 645
645/* pointer to array of kobjects for cpuX/cache/indexY */ 646/* pointer to array of kobjects for cpuX/cache/indexY */
646static DEFINE_PER_CPU(struct _index_kobject *, index_kobject); 647static DEFINE_PER_CPU(struct _index_kobject *, ici_index_kobject);
647#define INDEX_KOBJECT_PTR(x, y) (&((per_cpu(index_kobject, x))[y])) 648#define INDEX_KOBJECT_PTR(x, y) (&((per_cpu(ici_index_kobject, x))[y]))
648 649
649#define show_one_plus(file_name, object, val) \ 650#define show_one_plus(file_name, object, val) \
650static ssize_t show_##file_name \ 651static ssize_t show_##file_name \
@@ -863,10 +864,10 @@ static struct kobj_type ktype_percpu_entry = {
863 864
864static void __cpuinit cpuid4_cache_sysfs_exit(unsigned int cpu) 865static void __cpuinit cpuid4_cache_sysfs_exit(unsigned int cpu)
865{ 866{
866 kfree(per_cpu(cache_kobject, cpu)); 867 kfree(per_cpu(ici_cache_kobject, cpu));
867 kfree(per_cpu(index_kobject, cpu)); 868 kfree(per_cpu(ici_index_kobject, cpu));
868 per_cpu(cache_kobject, cpu) = NULL; 869 per_cpu(ici_cache_kobject, cpu) = NULL;
869 per_cpu(index_kobject, cpu) = NULL; 870 per_cpu(ici_index_kobject, cpu) = NULL;
870 free_cache_attributes(cpu); 871 free_cache_attributes(cpu);
871} 872}
872 873
@@ -882,14 +883,14 @@ static int __cpuinit cpuid4_cache_sysfs_init(unsigned int cpu)
882 return err; 883 return err;
883 884
884 /* Allocate all required memory */ 885 /* Allocate all required memory */
885 per_cpu(cache_kobject, cpu) = 886 per_cpu(ici_cache_kobject, cpu) =
886 kzalloc(sizeof(struct kobject), GFP_KERNEL); 887 kzalloc(sizeof(struct kobject), GFP_KERNEL);
887 if (unlikely(per_cpu(cache_kobject, cpu) == NULL)) 888 if (unlikely(per_cpu(ici_cache_kobject, cpu) == NULL))
888 goto err_out; 889 goto err_out;
889 890
890 per_cpu(index_kobject, cpu) = kzalloc( 891 per_cpu(ici_index_kobject, cpu) = kzalloc(
891 sizeof(struct _index_kobject) * num_cache_leaves, GFP_KERNEL); 892 sizeof(struct _index_kobject) * num_cache_leaves, GFP_KERNEL);
892 if (unlikely(per_cpu(index_kobject, cpu) == NULL)) 893 if (unlikely(per_cpu(ici_index_kobject, cpu) == NULL))
893 goto err_out; 894 goto err_out;
894 895
895 return 0; 896 return 0;
@@ -913,7 +914,7 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
913 if (unlikely(retval < 0)) 914 if (unlikely(retval < 0))
914 return retval; 915 return retval;
915 916
916 retval = kobject_init_and_add(per_cpu(cache_kobject, cpu), 917 retval = kobject_init_and_add(per_cpu(ici_cache_kobject, cpu),
917 &ktype_percpu_entry, 918 &ktype_percpu_entry,
918 &sys_dev->kobj, "%s", "cache"); 919 &sys_dev->kobj, "%s", "cache");
919 if (retval < 0) { 920 if (retval < 0) {
@@ -927,12 +928,12 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
927 this_object->index = i; 928 this_object->index = i;
928 retval = kobject_init_and_add(&(this_object->kobj), 929 retval = kobject_init_and_add(&(this_object->kobj),
929 &ktype_cache, 930 &ktype_cache,
930 per_cpu(cache_kobject, cpu), 931 per_cpu(ici_cache_kobject, cpu),
931 "index%1lu", i); 932 "index%1lu", i);
932 if (unlikely(retval)) { 933 if (unlikely(retval)) {
933 for (j = 0; j < i; j++) 934 for (j = 0; j < i; j++)
934 kobject_put(&(INDEX_KOBJECT_PTR(cpu, j)->kobj)); 935 kobject_put(&(INDEX_KOBJECT_PTR(cpu, j)->kobj));
935 kobject_put(per_cpu(cache_kobject, cpu)); 936 kobject_put(per_cpu(ici_cache_kobject, cpu));
936 cpuid4_cache_sysfs_exit(cpu); 937 cpuid4_cache_sysfs_exit(cpu);
937 return retval; 938 return retval;
938 } 939 }
@@ -940,7 +941,7 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
940 } 941 }
941 cpumask_set_cpu(cpu, to_cpumask(cache_dev_map)); 942 cpumask_set_cpu(cpu, to_cpumask(cache_dev_map));
942 943
943 kobject_uevent(per_cpu(cache_kobject, cpu), KOBJ_ADD); 944 kobject_uevent(per_cpu(ici_cache_kobject, cpu), KOBJ_ADD);
944 return 0; 945 return 0;
945} 946}
946 947
@@ -949,7 +950,7 @@ static void __cpuinit cache_remove_dev(struct sys_device * sys_dev)
949 unsigned int cpu = sys_dev->id; 950 unsigned int cpu = sys_dev->id;
950 unsigned long i; 951 unsigned long i;
951 952
952 if (per_cpu(cpuid4_info, cpu) == NULL) 953 if (per_cpu(ici_cpuid4_info, cpu) == NULL)
953 return; 954 return;
954 if (!cpumask_test_cpu(cpu, to_cpumask(cache_dev_map))) 955 if (!cpumask_test_cpu(cpu, to_cpumask(cache_dev_map)))
955 return; 956 return;
@@ -957,7 +958,7 @@ static void __cpuinit cache_remove_dev(struct sys_device * sys_dev)
957 958
958 for (i = 0; i < num_cache_leaves; i++) 959 for (i = 0; i < num_cache_leaves; i++)
959 kobject_put(&(INDEX_KOBJECT_PTR(cpu, i)->kobj)); 960 kobject_put(&(INDEX_KOBJECT_PTR(cpu, i)->kobj));
960 kobject_put(per_cpu(cache_kobject, cpu)); 961 kobject_put(per_cpu(ici_cache_kobject, cpu));
961 cpuid4_cache_sysfs_exit(cpu); 962 cpuid4_cache_sysfs_exit(cpu);
962} 963}
963 964
diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
index 4fef985fc221..81c499eceb21 100644
--- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
+++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
@@ -256,6 +256,16 @@ asmlinkage void smp_thermal_interrupt(struct pt_regs *regs)
256 ack_APIC_irq(); 256 ack_APIC_irq();
257} 257}
258 258
259/* Thermal monitoring depends on APIC, ACPI and clock modulation */
260static int intel_thermal_supported(struct cpuinfo_x86 *c)
261{
262 if (!cpu_has_apic)
263 return 0;
264 if (!cpu_has(c, X86_FEATURE_ACPI) || !cpu_has(c, X86_FEATURE_ACC))
265 return 0;
266 return 1;
267}
268
259void __init mcheck_intel_therm_init(void) 269void __init mcheck_intel_therm_init(void)
260{ 270{
261 /* 271 /*
@@ -263,8 +273,7 @@ void __init mcheck_intel_therm_init(void)
263 * LVT value on BSP and use that value to restore APs' thermal LVT 273 * LVT value on BSP and use that value to restore APs' thermal LVT
264 * entry BIOS programmed later 274 * entry BIOS programmed later
265 */ 275 */
266 if (cpu_has(&boot_cpu_data, X86_FEATURE_ACPI) && 276 if (intel_thermal_supported(&boot_cpu_data))
267 cpu_has(&boot_cpu_data, X86_FEATURE_ACC))
268 lvtthmr_init = apic_read(APIC_LVTTHMR); 277 lvtthmr_init = apic_read(APIC_LVTTHMR);
269} 278}
270 279
@@ -274,8 +283,7 @@ void intel_init_thermal(struct cpuinfo_x86 *c)
274 int tm2 = 0; 283 int tm2 = 0;
275 u32 l, h; 284 u32 l, h;
276 285
277 /* Thermal monitoring depends on ACPI and clock modulation*/ 286 if (!intel_thermal_supported(c))
278 if (!cpu_has(c, X86_FEATURE_ACPI) || !cpu_has(c, X86_FEATURE_ACC))
279 return; 287 return;
280 288
281 /* 289 /*
@@ -339,8 +347,8 @@ void intel_init_thermal(struct cpuinfo_x86 *c)
339 l = apic_read(APIC_LVTTHMR); 347 l = apic_read(APIC_LVTTHMR);
340 apic_write(APIC_LVTTHMR, l & ~APIC_LVT_MASKED); 348 apic_write(APIC_LVTTHMR, l & ~APIC_LVT_MASKED);
341 349
342 printk(KERN_INFO "CPU%d: Thermal monitoring enabled (%s)\n", 350 printk_once(KERN_INFO "CPU0: Thermal monitoring enabled (%s)\n",
343 cpu, tm2 ? "TM2" : "TM1"); 351 tm2 ? "TM2" : "TM1");
344 352
345 /* enable thermal throttle processing */ 353 /* enable thermal throttle processing */
346 atomic_set(&therm_throt_en, 1); 354 atomic_set(&therm_throt_en, 1);
diff --git a/arch/x86/kernel/ds.c b/arch/x86/kernel/ds.c
index ef42a038f1a6..1c47390dd0e5 100644
--- a/arch/x86/kernel/ds.c
+++ b/arch/x86/kernel/ds.c
@@ -265,13 +265,13 @@ struct ds_context {
265 int cpu; 265 int cpu;
266}; 266};
267 267
268static DEFINE_PER_CPU(struct ds_context *, cpu_context); 268static DEFINE_PER_CPU(struct ds_context *, cpu_ds_context);
269 269
270 270
271static struct ds_context *ds_get_context(struct task_struct *task, int cpu) 271static struct ds_context *ds_get_context(struct task_struct *task, int cpu)
272{ 272{
273 struct ds_context **p_context = 273 struct ds_context **p_context =
274 (task ? &task->thread.ds_ctx : &per_cpu(cpu_context, cpu)); 274 (task ? &task->thread.ds_ctx : &per_cpu(cpu_ds_context, cpu));
275 struct ds_context *context = NULL; 275 struct ds_context *context = NULL;
276 struct ds_context *new_context = NULL; 276 struct ds_context *new_context = NULL;
277 277
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index d17d482a04f4..f50447d961c0 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -732,7 +732,16 @@ struct early_res {
732 char overlap_ok; 732 char overlap_ok;
733}; 733};
734static struct early_res early_res[MAX_EARLY_RES] __initdata = { 734static struct early_res early_res[MAX_EARLY_RES] __initdata = {
735 { 0, PAGE_SIZE, "BIOS data page" }, /* BIOS data page */ 735 { 0, PAGE_SIZE, "BIOS data page", 1 }, /* BIOS data page */
736#ifdef CONFIG_X86_32
737 /*
738 * But first pinch a few for the stack/trampoline stuff
739 * FIXME: Don't need the extra page at 4K, but need to fix
740 * trampoline before removing it. (see the GDT stuff)
741 */
742 { PAGE_SIZE, PAGE_SIZE, "EX TRAMPOLINE", 1 },
743#endif
744
736 {} 745 {}
737}; 746};
738 747
diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
index 4f8e2507e8f3..5051b94c9069 100644
--- a/arch/x86/kernel/head32.c
+++ b/arch/x86/kernel/head32.c
@@ -29,8 +29,6 @@ static void __init i386_default_early_setup(void)
29 29
30void __init i386_start_kernel(void) 30void __init i386_start_kernel(void)
31{ 31{
32 reserve_trampoline_memory();
33
34 reserve_early(__pa_symbol(&_text), __pa_symbol(&__bss_stop), "TEXT DATA BSS"); 32 reserve_early(__pa_symbol(&_text), __pa_symbol(&__bss_stop), "TEXT DATA BSS");
35 33
36#ifdef CONFIG_BLK_DEV_INITRD 34#ifdef CONFIG_BLK_DEV_INITRD
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index 0b06cd778fd9..b5a9896ca1e7 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -98,8 +98,6 @@ void __init x86_64_start_reservations(char *real_mode_data)
98{ 98{
99 copy_bootdata(__va(real_mode_data)); 99 copy_bootdata(__va(real_mode_data));
100 100
101 reserve_trampoline_memory();
102
103 reserve_early(__pa_symbol(&_text), __pa_symbol(&__bss_stop), "TEXT DATA BSS"); 101 reserve_early(__pa_symbol(&_text), __pa_symbol(&__bss_stop), "TEXT DATA BSS");
104 102
105#ifdef CONFIG_BLK_DEV_INITRD 103#ifdef CONFIG_BLK_DEV_INITRD
diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c
index 35a57c963df9..40b54ceb68b5 100644
--- a/arch/x86/kernel/mpparse.c
+++ b/arch/x86/kernel/mpparse.c
@@ -945,9 +945,6 @@ void __init early_reserve_e820_mpc_new(void)
945{ 945{
946 if (enable_update_mptable && alloc_mptable) { 946 if (enable_update_mptable && alloc_mptable) {
947 u64 startt = 0; 947 u64 startt = 0;
948#ifdef CONFIG_X86_TRAMPOLINE
949 startt = TRAMPOLINE_BASE;
950#endif
951 mpc_new_phys = early_reserve_e820(startt, mpc_new_length, 4); 948 mpc_new_phys = early_reserve_e820(startt, mpc_new_length, 4);
952 } 949 }
953} 950}
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index afcc58b69c7c..fcc2f2bfa39c 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -120,11 +120,14 @@ static void __init dma32_free_bootmem(void)
120 120
121void __init pci_iommu_alloc(void) 121void __init pci_iommu_alloc(void)
122{ 122{
123 int use_swiotlb;
124
125 use_swiotlb = pci_swiotlb_init();
123#ifdef CONFIG_X86_64 126#ifdef CONFIG_X86_64
124 /* free the range so iommu could get some range less than 4G */ 127 /* free the range so iommu could get some range less than 4G */
125 dma32_free_bootmem(); 128 dma32_free_bootmem();
126#endif 129#endif
127 if (pci_swiotlb_init()) 130 if (use_swiotlb)
128 return; 131 return;
129 132
130 gart_iommu_hole_init(); 133 gart_iommu_hole_init();
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index e6a0d402f171..56c0e730d3fe 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -710,7 +710,8 @@ static void gart_iommu_shutdown(void)
710 struct pci_dev *dev; 710 struct pci_dev *dev;
711 int i; 711 int i;
712 712
713 if (no_agp) 713 /* don't shutdown it if there is AGP installed */
714 if (!no_agp)
714 return; 715 return;
715 716
716 for (i = 0; i < num_k8_northbridges; i++) { 717 for (i = 0; i < num_k8_northbridges; i++) {
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 946a311a25c9..f7b8b9894b22 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -73,6 +73,7 @@
73 73
74#include <asm/mtrr.h> 74#include <asm/mtrr.h>
75#include <asm/apic.h> 75#include <asm/apic.h>
76#include <asm/trampoline.h>
76#include <asm/e820.h> 77#include <asm/e820.h>
77#include <asm/mpspec.h> 78#include <asm/mpspec.h>
78#include <asm/setup.h> 79#include <asm/setup.h>
@@ -875,6 +876,13 @@ void __init setup_arch(char **cmdline_p)
875 876
876 reserve_brk(); 877 reserve_brk();
877 878
879 /*
880 * Find and reserve possible boot-time SMP configuration:
881 */
882 find_smp_config();
883
884 reserve_trampoline_memory();
885
878#ifdef CONFIG_ACPI_SLEEP 886#ifdef CONFIG_ACPI_SLEEP
879 /* 887 /*
880 * Reserve low memory region for sleep support. 888 * Reserve low memory region for sleep support.
@@ -921,11 +929,6 @@ void __init setup_arch(char **cmdline_p)
921 929
922 early_acpi_boot_init(); 930 early_acpi_boot_init();
923 931
924 /*
925 * Find and reserve possible boot-time SMP configuration:
926 */
927 find_smp_config();
928
929#ifdef CONFIG_ACPI_NUMA 932#ifdef CONFIG_ACPI_NUMA
930 /* 933 /*
931 * Parse SRAT to discover nodes. 934 * Parse SRAT to discover nodes.
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 29e6744f51e3..678d0b8c26f3 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -671,6 +671,26 @@ static void __cpuinit do_fork_idle(struct work_struct *work)
671 complete(&c_idle->done); 671 complete(&c_idle->done);
672} 672}
673 673
674/* reduce the number of lines printed when booting a large cpu count system */
675static void __cpuinit announce_cpu(int cpu, int apicid)
676{
677 static int current_node = -1;
678 int node = cpu_to_node(cpu);
679
680 if (system_state == SYSTEM_BOOTING) {
681 if (node != current_node) {
682 if (current_node > (-1))
683 pr_cont(" Ok.\n");
684 current_node = node;
685 pr_info("Booting Node %3d, Processors ", node);
686 }
687 pr_cont(" #%d%s", cpu, cpu == (nr_cpu_ids - 1) ? " Ok.\n" : "");
688 return;
689 } else
690 pr_info("Booting Node %d Processor %d APIC 0x%x\n",
691 node, cpu, apicid);
692}
693
674/* 694/*
675 * NOTE - on most systems this is a PHYSICAL apic ID, but on multiquad 695 * NOTE - on most systems this is a PHYSICAL apic ID, but on multiquad
676 * (ie clustered apic addressing mode), this is a LOGICAL apic ID. 696 * (ie clustered apic addressing mode), this is a LOGICAL apic ID.
@@ -737,9 +757,8 @@ do_rest:
737 /* start_ip had better be page-aligned! */ 757 /* start_ip had better be page-aligned! */
738 start_ip = setup_trampoline(); 758 start_ip = setup_trampoline();
739 759
740 /* So we see what's up */ 760 /* So we see what's up */
741 printk(KERN_INFO "Booting processor %d APIC 0x%x ip 0x%lx\n", 761 announce_cpu(cpu, apicid);
742 cpu, apicid, start_ip);
743 762
744 /* 763 /*
745 * This grunge runs the startup process for 764 * This grunge runs the startup process for
@@ -788,21 +807,17 @@ do_rest:
788 udelay(100); 807 udelay(100);
789 } 808 }
790 809
791 if (cpumask_test_cpu(cpu, cpu_callin_mask)) { 810 if (cpumask_test_cpu(cpu, cpu_callin_mask))
792 /* number CPUs logically, starting from 1 (BSP is 0) */ 811 pr_debug("CPU%d: has booted.\n", cpu);
793 pr_debug("OK.\n"); 812 else {
794 printk(KERN_INFO "CPU%d: ", cpu);
795 print_cpu_info(&cpu_data(cpu));
796 pr_debug("CPU has booted.\n");
797 } else {
798 boot_error = 1; 813 boot_error = 1;
799 if (*((volatile unsigned char *)trampoline_base) 814 if (*((volatile unsigned char *)trampoline_base)
800 == 0xA5) 815 == 0xA5)
801 /* trampoline started but...? */ 816 /* trampoline started but...? */
802 printk(KERN_ERR "Stuck ??\n"); 817 pr_err("CPU%d: Stuck ??\n", cpu);
803 else 818 else
804 /* trampoline code not run */ 819 /* trampoline code not run */
805 printk(KERN_ERR "Not responding.\n"); 820 pr_err("CPU%d: Not responding.\n", cpu);
806 if (apic->inquire_remote_apic) 821 if (apic->inquire_remote_apic)
807 apic->inquire_remote_apic(apicid); 822 apic->inquire_remote_apic(apicid);
808 } 823 }
@@ -1293,14 +1308,16 @@ void native_cpu_die(unsigned int cpu)
1293 for (i = 0; i < 10; i++) { 1308 for (i = 0; i < 10; i++) {
1294 /* They ack this in play_dead by setting CPU_DEAD */ 1309 /* They ack this in play_dead by setting CPU_DEAD */
1295 if (per_cpu(cpu_state, cpu) == CPU_DEAD) { 1310 if (per_cpu(cpu_state, cpu) == CPU_DEAD) {
1296 printk(KERN_INFO "CPU %d is now offline\n", cpu); 1311 if (system_state == SYSTEM_RUNNING)
1312 pr_info("CPU %u is now offline\n", cpu);
1313
1297 if (1 == num_online_cpus()) 1314 if (1 == num_online_cpus())
1298 alternatives_smp_switch(0); 1315 alternatives_smp_switch(0);
1299 return; 1316 return;
1300 } 1317 }
1301 msleep(100); 1318 msleep(100);
1302 } 1319 }
1303 printk(KERN_ERR "CPU %u didn't die...\n", cpu); 1320 pr_err("CPU %u didn't die...\n", cpu);
1304} 1321}
1305 1322
1306void play_dead_common(void) 1323void play_dead_common(void)
diff --git a/arch/x86/kernel/trampoline.c b/arch/x86/kernel/trampoline.c
index cd022121cab6..c652ef62742d 100644
--- a/arch/x86/kernel/trampoline.c
+++ b/arch/x86/kernel/trampoline.c
@@ -12,21 +12,19 @@
12#endif 12#endif
13 13
14/* ready for x86_64 and x86 */ 14/* ready for x86_64 and x86 */
15unsigned char *__trampinitdata trampoline_base = __va(TRAMPOLINE_BASE); 15unsigned char *__trampinitdata trampoline_base;
16 16
17void __init reserve_trampoline_memory(void) 17void __init reserve_trampoline_memory(void)
18{ 18{
19#ifdef CONFIG_X86_32 19 unsigned long mem;
20 /* 20
21 * But first pinch a few for the stack/trampoline stuff
22 * FIXME: Don't need the extra page at 4K, but need to fix
23 * trampoline before removing it. (see the GDT stuff)
24 */
25 reserve_early(PAGE_SIZE, PAGE_SIZE + PAGE_SIZE, "EX TRAMPOLINE");
26#endif
27 /* Has to be in very low memory so we can execute real-mode AP code. */ 21 /* Has to be in very low memory so we can execute real-mode AP code. */
28 reserve_early(TRAMPOLINE_BASE, TRAMPOLINE_BASE + TRAMPOLINE_SIZE, 22 mem = find_e820_area(0, 1<<20, TRAMPOLINE_SIZE, PAGE_SIZE);
29 "TRAMPOLINE"); 23 if (mem == -1L)
24 panic("Cannot allocate trampoline\n");
25
26 trampoline_base = __va(mem);
27 reserve_early(mem, mem + TRAMPOLINE_SIZE, "TRAMPOLINE");
30} 28}
31 29
32/* 30/*
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 3de0b37ec038..1d9b33843c80 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -316,7 +316,7 @@ static void svm_hardware_disable(void *garbage)
316static int svm_hardware_enable(void *garbage) 316static int svm_hardware_enable(void *garbage)
317{ 317{
318 318
319 struct svm_cpu_data *svm_data; 319 struct svm_cpu_data *sd;
320 uint64_t efer; 320 uint64_t efer;
321 struct descriptor_table gdt_descr; 321 struct descriptor_table gdt_descr;
322 struct desc_struct *gdt; 322 struct desc_struct *gdt;
@@ -331,63 +331,61 @@ static int svm_hardware_enable(void *garbage)
331 me); 331 me);
332 return -EINVAL; 332 return -EINVAL;
333 } 333 }
334 svm_data = per_cpu(svm_data, me); 334 sd = per_cpu(svm_data, me);
335 335
336 if (!svm_data) { 336 if (!sd) {
337 printk(KERN_ERR "svm_hardware_enable: svm_data is NULL on %d\n", 337 printk(KERN_ERR "svm_hardware_enable: svm_data is NULL on %d\n",
338 me); 338 me);
339 return -EINVAL; 339 return -EINVAL;
340 } 340 }
341 341
342 svm_data->asid_generation = 1; 342 sd->asid_generation = 1;
343 svm_data->max_asid = cpuid_ebx(SVM_CPUID_FUNC) - 1; 343 sd->max_asid = cpuid_ebx(SVM_CPUID_FUNC) - 1;
344 svm_data->next_asid = svm_data->max_asid + 1; 344 sd->next_asid = sd->max_asid + 1;
345 345
346 kvm_get_gdt(&gdt_descr); 346 kvm_get_gdt(&gdt_descr);
347 gdt = (struct desc_struct *)gdt_descr.base; 347 gdt = (struct desc_struct *)gdt_descr.base;
348 svm_data->tss_desc = (struct kvm_ldttss_desc *)(gdt + GDT_ENTRY_TSS); 348 sd->tss_desc = (struct kvm_ldttss_desc *)(gdt + GDT_ENTRY_TSS);
349 349
350 wrmsrl(MSR_EFER, efer | EFER_SVME); 350 wrmsrl(MSR_EFER, efer | EFER_SVME);
351 351
352 wrmsrl(MSR_VM_HSAVE_PA, 352 wrmsrl(MSR_VM_HSAVE_PA, page_to_pfn(sd->save_area) << PAGE_SHIFT);
353 page_to_pfn(svm_data->save_area) << PAGE_SHIFT);
354 353
355 return 0; 354 return 0;
356} 355}
357 356
358static void svm_cpu_uninit(int cpu) 357static void svm_cpu_uninit(int cpu)
359{ 358{
360 struct svm_cpu_data *svm_data 359 struct svm_cpu_data *sd = per_cpu(svm_data, raw_smp_processor_id());
361 = per_cpu(svm_data, raw_smp_processor_id());
362 360
363 if (!svm_data) 361 if (!sd)
364 return; 362 return;
365 363
366 per_cpu(svm_data, raw_smp_processor_id()) = NULL; 364 per_cpu(svm_data, raw_smp_processor_id()) = NULL;
367 __free_page(svm_data->save_area); 365 __free_page(sd->save_area);
368 kfree(svm_data); 366 kfree(sd);
369} 367}
370 368
371static int svm_cpu_init(int cpu) 369static int svm_cpu_init(int cpu)
372{ 370{
373 struct svm_cpu_data *svm_data; 371 struct svm_cpu_data *sd;
374 int r; 372 int r;
375 373
376 svm_data = kzalloc(sizeof(struct svm_cpu_data), GFP_KERNEL); 374 sd = kzalloc(sizeof(struct svm_cpu_data), GFP_KERNEL);
377 if (!svm_data) 375 if (!sd)
378 return -ENOMEM; 376 return -ENOMEM;
379 svm_data->cpu = cpu; 377 sd->cpu = cpu;
380 svm_data->save_area = alloc_page(GFP_KERNEL); 378 sd->save_area = alloc_page(GFP_KERNEL);
381 r = -ENOMEM; 379 r = -ENOMEM;
382 if (!svm_data->save_area) 380 if (!sd->save_area)
383 goto err_1; 381 goto err_1;
384 382
385 per_cpu(svm_data, cpu) = svm_data; 383 per_cpu(svm_data, cpu) = sd;
386 384
387 return 0; 385 return 0;
388 386
389err_1: 387err_1:
390 kfree(svm_data); 388 kfree(sd);
391 return r; 389 return r;
392 390
393} 391}
@@ -1092,16 +1090,16 @@ static void save_host_msrs(struct kvm_vcpu *vcpu)
1092#endif 1090#endif
1093} 1091}
1094 1092
1095static void new_asid(struct vcpu_svm *svm, struct svm_cpu_data *svm_data) 1093static void new_asid(struct vcpu_svm *svm, struct svm_cpu_data *sd)
1096{ 1094{
1097 if (svm_data->next_asid > svm_data->max_asid) { 1095 if (sd->next_asid > sd->max_asid) {
1098 ++svm_data->asid_generation; 1096 ++sd->asid_generation;
1099 svm_data->next_asid = 1; 1097 sd->next_asid = 1;
1100 svm->vmcb->control.tlb_ctl = TLB_CONTROL_FLUSH_ALL_ASID; 1098 svm->vmcb->control.tlb_ctl = TLB_CONTROL_FLUSH_ALL_ASID;
1101 } 1099 }
1102 1100
1103 svm->asid_generation = svm_data->asid_generation; 1101 svm->asid_generation = sd->asid_generation;
1104 svm->vmcb->control.asid = svm_data->next_asid++; 1102 svm->vmcb->control.asid = sd->next_asid++;
1105} 1103}
1106 1104
1107static unsigned long svm_get_dr(struct kvm_vcpu *vcpu, int dr) 1105static unsigned long svm_get_dr(struct kvm_vcpu *vcpu, int dr)
@@ -2429,8 +2427,8 @@ static void reload_tss(struct kvm_vcpu *vcpu)
2429{ 2427{
2430 int cpu = raw_smp_processor_id(); 2428 int cpu = raw_smp_processor_id();
2431 2429
2432 struct svm_cpu_data *svm_data = per_cpu(svm_data, cpu); 2430 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
2433 svm_data->tss_desc->type = 9; /* available 32/64-bit TSS */ 2431 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
2434 load_TR_desc(); 2432 load_TR_desc();
2435} 2433}
2436 2434
@@ -2438,12 +2436,12 @@ static void pre_svm_run(struct vcpu_svm *svm)
2438{ 2436{
2439 int cpu = raw_smp_processor_id(); 2437 int cpu = raw_smp_processor_id();
2440 2438
2441 struct svm_cpu_data *svm_data = per_cpu(svm_data, cpu); 2439 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
2442 2440
2443 svm->vmcb->control.tlb_ctl = TLB_CONTROL_DO_NOTHING; 2441 svm->vmcb->control.tlb_ctl = TLB_CONTROL_DO_NOTHING;
2444 /* FIXME: handle wraparound of asid_generation */ 2442 /* FIXME: handle wraparound of asid_generation */
2445 if (svm->asid_generation != svm_data->asid_generation) 2443 if (svm->asid_generation != sd->asid_generation)
2446 new_asid(svm, svm_data); 2444 new_asid(svm, sd);
2447} 2445}
2448 2446
2449static void svm_inject_nmi(struct kvm_vcpu *vcpu) 2447static void svm_inject_nmi(struct kvm_vcpu *vcpu)
diff --git a/arch/x86/lib/msr.c b/arch/x86/lib/msr.c
index 41628b104b9e..872834177937 100644
--- a/arch/x86/lib/msr.c
+++ b/arch/x86/lib/msr.c
@@ -7,7 +7,6 @@ struct msr_info {
7 u32 msr_no; 7 u32 msr_no;
8 struct msr reg; 8 struct msr reg;
9 struct msr *msrs; 9 struct msr *msrs;
10 int off;
11 int err; 10 int err;
12}; 11};
13 12
@@ -18,7 +17,7 @@ static void __rdmsr_on_cpu(void *info)
18 int this_cpu = raw_smp_processor_id(); 17 int this_cpu = raw_smp_processor_id();
19 18
20 if (rv->msrs) 19 if (rv->msrs)
21 reg = &rv->msrs[this_cpu - rv->off]; 20 reg = per_cpu_ptr(rv->msrs, this_cpu);
22 else 21 else
23 reg = &rv->reg; 22 reg = &rv->reg;
24 23
@@ -32,7 +31,7 @@ static void __wrmsr_on_cpu(void *info)
32 int this_cpu = raw_smp_processor_id(); 31 int this_cpu = raw_smp_processor_id();
33 32
34 if (rv->msrs) 33 if (rv->msrs)
35 reg = &rv->msrs[this_cpu - rv->off]; 34 reg = per_cpu_ptr(rv->msrs, this_cpu);
36 else 35 else
37 reg = &rv->reg; 36 reg = &rv->reg;
38 37
@@ -80,7 +79,6 @@ static void __rwmsr_on_cpus(const struct cpumask *mask, u32 msr_no,
80 79
81 memset(&rv, 0, sizeof(rv)); 80 memset(&rv, 0, sizeof(rv));
82 81
83 rv.off = cpumask_first(mask);
84 rv.msrs = msrs; 82 rv.msrs = msrs;
85 rv.msr_no = msr_no; 83 rv.msr_no = msr_no;
86 84
@@ -120,6 +118,26 @@ void wrmsr_on_cpus(const struct cpumask *mask, u32 msr_no, struct msr *msrs)
120} 118}
121EXPORT_SYMBOL(wrmsr_on_cpus); 119EXPORT_SYMBOL(wrmsr_on_cpus);
122 120
121struct msr *msrs_alloc(void)
122{
123 struct msr *msrs = NULL;
124
125 msrs = alloc_percpu(struct msr);
126 if (!msrs) {
127 pr_warning("%s: error allocating msrs\n", __func__);
128 return NULL;
129 }
130
131 return msrs;
132}
133EXPORT_SYMBOL(msrs_alloc);
134
135void msrs_free(struct msr *msrs)
136{
137 free_percpu(msrs);
138}
139EXPORT_SYMBOL(msrs_free);
140
123/* These "safe" variants are slower and should be used when the target MSR 141/* These "safe" variants are slower and should be used when the target MSR
124 may not actually exist. */ 142 may not actually exist. */
125static void __rdmsr_safe_on_cpu(void *info) 143static void __rdmsr_safe_on_cpu(void *info)
diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
index 4c765e9c4664..34a3291ca103 100644
--- a/arch/x86/mm/mmio-mod.c
+++ b/arch/x86/mm/mmio-mod.c
@@ -20,7 +20,7 @@
20 * Derived from the read-mod example from relay-examples by Tom Zanussi. 20 * Derived from the read-mod example from relay-examples by Tom Zanussi.
21 */ 21 */
22 22
23#define pr_fmt(fmt) "mmiotrace: " 23#define pr_fmt(fmt) "mmiotrace: " fmt
24 24
25#define DEBUG 1 25#define DEBUG 1
26 26
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
index 64757c0ba5fc..563d20504988 100644
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -35,10 +35,10 @@
35 35
36cpumask_var_t xen_cpu_initialized_map; 36cpumask_var_t xen_cpu_initialized_map;
37 37
38static DEFINE_PER_CPU(int, resched_irq); 38static DEFINE_PER_CPU(int, xen_resched_irq);
39static DEFINE_PER_CPU(int, callfunc_irq); 39static DEFINE_PER_CPU(int, xen_callfunc_irq);
40static DEFINE_PER_CPU(int, callfuncsingle_irq); 40static DEFINE_PER_CPU(int, xen_callfuncsingle_irq);
41static DEFINE_PER_CPU(int, debug_irq) = -1; 41static DEFINE_PER_CPU(int, xen_debug_irq) = -1;
42 42
43static irqreturn_t xen_call_function_interrupt(int irq, void *dev_id); 43static irqreturn_t xen_call_function_interrupt(int irq, void *dev_id);
44static irqreturn_t xen_call_function_single_interrupt(int irq, void *dev_id); 44static irqreturn_t xen_call_function_single_interrupt(int irq, void *dev_id);
@@ -103,7 +103,7 @@ static int xen_smp_intr_init(unsigned int cpu)
103 NULL); 103 NULL);
104 if (rc < 0) 104 if (rc < 0)
105 goto fail; 105 goto fail;
106 per_cpu(resched_irq, cpu) = rc; 106 per_cpu(xen_resched_irq, cpu) = rc;
107 107
108 callfunc_name = kasprintf(GFP_KERNEL, "callfunc%d", cpu); 108 callfunc_name = kasprintf(GFP_KERNEL, "callfunc%d", cpu);
109 rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_VECTOR, 109 rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_VECTOR,
@@ -114,7 +114,7 @@ static int xen_smp_intr_init(unsigned int cpu)
114 NULL); 114 NULL);
115 if (rc < 0) 115 if (rc < 0)
116 goto fail; 116 goto fail;
117 per_cpu(callfunc_irq, cpu) = rc; 117 per_cpu(xen_callfunc_irq, cpu) = rc;
118 118
119 debug_name = kasprintf(GFP_KERNEL, "debug%d", cpu); 119 debug_name = kasprintf(GFP_KERNEL, "debug%d", cpu);
120 rc = bind_virq_to_irqhandler(VIRQ_DEBUG, cpu, xen_debug_interrupt, 120 rc = bind_virq_to_irqhandler(VIRQ_DEBUG, cpu, xen_debug_interrupt,
@@ -122,7 +122,7 @@ static int xen_smp_intr_init(unsigned int cpu)
122 debug_name, NULL); 122 debug_name, NULL);
123 if (rc < 0) 123 if (rc < 0)
124 goto fail; 124 goto fail;
125 per_cpu(debug_irq, cpu) = rc; 125 per_cpu(xen_debug_irq, cpu) = rc;
126 126
127 callfunc_name = kasprintf(GFP_KERNEL, "callfuncsingle%d", cpu); 127 callfunc_name = kasprintf(GFP_KERNEL, "callfuncsingle%d", cpu);
128 rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_SINGLE_VECTOR, 128 rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_SINGLE_VECTOR,
@@ -133,19 +133,20 @@ static int xen_smp_intr_init(unsigned int cpu)
133 NULL); 133 NULL);
134 if (rc < 0) 134 if (rc < 0)
135 goto fail; 135 goto fail;
136 per_cpu(callfuncsingle_irq, cpu) = rc; 136 per_cpu(xen_callfuncsingle_irq, cpu) = rc;
137 137
138 return 0; 138 return 0;
139 139
140 fail: 140 fail:
141 if (per_cpu(resched_irq, cpu) >= 0) 141 if (per_cpu(xen_resched_irq, cpu) >= 0)
142 unbind_from_irqhandler(per_cpu(resched_irq, cpu), NULL); 142 unbind_from_irqhandler(per_cpu(xen_resched_irq, cpu), NULL);
143 if (per_cpu(callfunc_irq, cpu) >= 0) 143 if (per_cpu(xen_callfunc_irq, cpu) >= 0)
144 unbind_from_irqhandler(per_cpu(callfunc_irq, cpu), NULL); 144 unbind_from_irqhandler(per_cpu(xen_callfunc_irq, cpu), NULL);
145 if (per_cpu(debug_irq, cpu) >= 0) 145 if (per_cpu(xen_debug_irq, cpu) >= 0)
146 unbind_from_irqhandler(per_cpu(debug_irq, cpu), NULL); 146 unbind_from_irqhandler(per_cpu(xen_debug_irq, cpu), NULL);
147 if (per_cpu(callfuncsingle_irq, cpu) >= 0) 147 if (per_cpu(xen_callfuncsingle_irq, cpu) >= 0)
148 unbind_from_irqhandler(per_cpu(callfuncsingle_irq, cpu), NULL); 148 unbind_from_irqhandler(per_cpu(xen_callfuncsingle_irq, cpu),
149 NULL);
149 150
150 return rc; 151 return rc;
151} 152}
@@ -349,10 +350,10 @@ static void xen_cpu_die(unsigned int cpu)
349 current->state = TASK_UNINTERRUPTIBLE; 350 current->state = TASK_UNINTERRUPTIBLE;
350 schedule_timeout(HZ/10); 351 schedule_timeout(HZ/10);
351 } 352 }
352 unbind_from_irqhandler(per_cpu(resched_irq, cpu), NULL); 353 unbind_from_irqhandler(per_cpu(xen_resched_irq, cpu), NULL);
353 unbind_from_irqhandler(per_cpu(callfunc_irq, cpu), NULL); 354 unbind_from_irqhandler(per_cpu(xen_callfunc_irq, cpu), NULL);
354 unbind_from_irqhandler(per_cpu(debug_irq, cpu), NULL); 355 unbind_from_irqhandler(per_cpu(xen_debug_irq, cpu), NULL);
355 unbind_from_irqhandler(per_cpu(callfuncsingle_irq, cpu), NULL); 356 unbind_from_irqhandler(per_cpu(xen_callfuncsingle_irq, cpu), NULL);
356 xen_uninit_lock_cpu(cpu); 357 xen_uninit_lock_cpu(cpu);
357 xen_teardown_timer(cpu); 358 xen_teardown_timer(cpu);
358 359
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 9d1f853120d8..0d3f07cd1b5f 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -31,14 +31,14 @@
31#define NS_PER_TICK (1000000000LL / HZ) 31#define NS_PER_TICK (1000000000LL / HZ)
32 32
33/* runstate info updated by Xen */ 33/* runstate info updated by Xen */
34static DEFINE_PER_CPU(struct vcpu_runstate_info, runstate); 34static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate);
35 35
36/* snapshots of runstate info */ 36/* snapshots of runstate info */
37static DEFINE_PER_CPU(struct vcpu_runstate_info, runstate_snapshot); 37static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate_snapshot);
38 38
39/* unused ns of stolen and blocked time */ 39/* unused ns of stolen and blocked time */
40static DEFINE_PER_CPU(u64, residual_stolen); 40static DEFINE_PER_CPU(u64, xen_residual_stolen);
41static DEFINE_PER_CPU(u64, residual_blocked); 41static DEFINE_PER_CPU(u64, xen_residual_blocked);
42 42
43/* return an consistent snapshot of 64-bit time/counter value */ 43/* return an consistent snapshot of 64-bit time/counter value */
44static u64 get64(const u64 *p) 44static u64 get64(const u64 *p)
@@ -79,7 +79,7 @@ static void get_runstate_snapshot(struct vcpu_runstate_info *res)
79 79
80 BUG_ON(preemptible()); 80 BUG_ON(preemptible());
81 81
82 state = &__get_cpu_var(runstate); 82 state = &__get_cpu_var(xen_runstate);
83 83
84 /* 84 /*
85 * The runstate info is always updated by the hypervisor on 85 * The runstate info is always updated by the hypervisor on
@@ -97,14 +97,14 @@ static void get_runstate_snapshot(struct vcpu_runstate_info *res)
97/* return true when a vcpu could run but has no real cpu to run on */ 97/* return true when a vcpu could run but has no real cpu to run on */
98bool xen_vcpu_stolen(int vcpu) 98bool xen_vcpu_stolen(int vcpu)
99{ 99{
100 return per_cpu(runstate, vcpu).state == RUNSTATE_runnable; 100 return per_cpu(xen_runstate, vcpu).state == RUNSTATE_runnable;
101} 101}
102 102
103void xen_setup_runstate_info(int cpu) 103void xen_setup_runstate_info(int cpu)
104{ 104{
105 struct vcpu_register_runstate_memory_area area; 105 struct vcpu_register_runstate_memory_area area;
106 106
107 area.addr.v = &per_cpu(runstate, cpu); 107 area.addr.v = &per_cpu(xen_runstate, cpu);
108 108
109 if (HYPERVISOR_vcpu_op(VCPUOP_register_runstate_memory_area, 109 if (HYPERVISOR_vcpu_op(VCPUOP_register_runstate_memory_area,
110 cpu, &area)) 110 cpu, &area))
@@ -122,7 +122,7 @@ static void do_stolen_accounting(void)
122 122
123 WARN_ON(state.state != RUNSTATE_running); 123 WARN_ON(state.state != RUNSTATE_running);
124 124
125 snap = &__get_cpu_var(runstate_snapshot); 125 snap = &__get_cpu_var(xen_runstate_snapshot);
126 126
127 /* work out how much time the VCPU has not been runn*ing* */ 127 /* work out how much time the VCPU has not been runn*ing* */
128 blocked = state.time[RUNSTATE_blocked] - snap->time[RUNSTATE_blocked]; 128 blocked = state.time[RUNSTATE_blocked] - snap->time[RUNSTATE_blocked];
@@ -133,24 +133,24 @@ static void do_stolen_accounting(void)
133 133
134 /* Add the appropriate number of ticks of stolen time, 134 /* Add the appropriate number of ticks of stolen time,
135 including any left-overs from last time. */ 135 including any left-overs from last time. */
136 stolen = runnable + offline + __get_cpu_var(residual_stolen); 136 stolen = runnable + offline + __get_cpu_var(xen_residual_stolen);
137 137
138 if (stolen < 0) 138 if (stolen < 0)
139 stolen = 0; 139 stolen = 0;
140 140
141 ticks = iter_div_u64_rem(stolen, NS_PER_TICK, &stolen); 141 ticks = iter_div_u64_rem(stolen, NS_PER_TICK, &stolen);
142 __get_cpu_var(residual_stolen) = stolen; 142 __get_cpu_var(xen_residual_stolen) = stolen;
143 account_steal_ticks(ticks); 143 account_steal_ticks(ticks);
144 144
145 /* Add the appropriate number of ticks of blocked time, 145 /* Add the appropriate number of ticks of blocked time,
146 including any left-overs from last time. */ 146 including any left-overs from last time. */
147 blocked += __get_cpu_var(residual_blocked); 147 blocked += __get_cpu_var(xen_residual_blocked);
148 148
149 if (blocked < 0) 149 if (blocked < 0)
150 blocked = 0; 150 blocked = 0;
151 151
152 ticks = iter_div_u64_rem(blocked, NS_PER_TICK, &blocked); 152 ticks = iter_div_u64_rem(blocked, NS_PER_TICK, &blocked);
153 __get_cpu_var(residual_blocked) = blocked; 153 __get_cpu_var(xen_residual_blocked) = blocked;
154 account_idle_ticks(ticks); 154 account_idle_ticks(ticks);
155} 155}
156 156
diff --git a/crypto/cryptd.c b/crypto/cryptd.c
index f8ae0d94a647..704c14115323 100644
--- a/crypto/cryptd.c
+++ b/crypto/cryptd.c
@@ -99,7 +99,7 @@ static int cryptd_enqueue_request(struct cryptd_queue *queue,
99 struct cryptd_cpu_queue *cpu_queue; 99 struct cryptd_cpu_queue *cpu_queue;
100 100
101 cpu = get_cpu(); 101 cpu = get_cpu();
102 cpu_queue = per_cpu_ptr(queue->cpu_queue, cpu); 102 cpu_queue = this_cpu_ptr(queue->cpu_queue);
103 err = crypto_enqueue_request(&cpu_queue->queue, request); 103 err = crypto_enqueue_request(&cpu_queue->queue, request);
104 queue_work_on(cpu, kcrypto_wq, &cpu_queue->work); 104 queue_work_on(cpu, kcrypto_wq, &cpu_queue->work);
105 put_cpu(); 105 put_cpu();
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 27fd775375b0..958bd1540c30 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -131,7 +131,7 @@ static ssize_t show_crash_notes(struct sys_device *dev, struct sysdev_attribute
131 * boot up and this data does not change there after. Hence this 131 * boot up and this data does not change there after. Hence this
132 * operation should be safe. No locking required. 132 * operation should be safe. No locking required.
133 */ 133 */
134 addr = __pa(per_cpu_ptr(crash_notes, cpunum)); 134 addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpunum));
135 rc = sprintf(buf, "%Lx\n", addr); 135 rc = sprintf(buf, "%Lx\n", addr);
136 return rc; 136 return rc;
137} 137}
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
index 4008e2ce73c1..fdbcc9fd6d31 100644
--- a/drivers/char/nvram.c
+++ b/drivers/char/nvram.c
@@ -264,10 +264,16 @@ static ssize_t nvram_write(struct file *file, const char __user *buf,
264 unsigned char contents[NVRAM_BYTES]; 264 unsigned char contents[NVRAM_BYTES];
265 unsigned i = *ppos; 265 unsigned i = *ppos;
266 unsigned char *tmp; 266 unsigned char *tmp;
267 int len;
268 267
269 len = (NVRAM_BYTES - i) < count ? (NVRAM_BYTES - i) : count; 268 if (i >= NVRAM_BYTES)
270 if (copy_from_user(contents, buf, len)) 269 return 0; /* Past EOF */
270
271 if (count > NVRAM_BYTES - i)
272 count = NVRAM_BYTES - i;
273 if (count > NVRAM_BYTES)
274 return -EFAULT; /* Can't happen, but prove it to gcc */
275
276 if (copy_from_user(contents, buf, count))
271 return -EFAULT; 277 return -EFAULT;
272 278
273 spin_lock_irq(&rtc_lock); 279 spin_lock_irq(&rtc_lock);
@@ -275,7 +281,7 @@ static ssize_t nvram_write(struct file *file, const char __user *buf,
275 if (!__nvram_check_checksum()) 281 if (!__nvram_check_checksum())
276 goto checksum_err; 282 goto checksum_err;
277 283
278 for (tmp = contents; count-- > 0 && i < NVRAM_BYTES; ++i, ++tmp) 284 for (tmp = contents; count--; ++i, ++tmp)
279 __nvram_write_byte(*tmp, i); 285 __nvram_write_byte(*tmp, i);
280 286
281 __nvram_set_checksum(); 287 __nvram_set_checksum();
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index f20668c09ce0..67bc2ece7b4b 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -64,14 +64,14 @@ static DEFINE_SPINLOCK(cpufreq_driver_lock);
64 * - Lock should not be held across 64 * - Lock should not be held across
65 * __cpufreq_governor(data, CPUFREQ_GOV_STOP); 65 * __cpufreq_governor(data, CPUFREQ_GOV_STOP);
66 */ 66 */
67static DEFINE_PER_CPU(int, policy_cpu); 67static DEFINE_PER_CPU(int, cpufreq_policy_cpu);
68static DEFINE_PER_CPU(struct rw_semaphore, cpu_policy_rwsem); 68static DEFINE_PER_CPU(struct rw_semaphore, cpu_policy_rwsem);
69 69
70#define lock_policy_rwsem(mode, cpu) \ 70#define lock_policy_rwsem(mode, cpu) \
71int lock_policy_rwsem_##mode \ 71int lock_policy_rwsem_##mode \
72(int cpu) \ 72(int cpu) \
73{ \ 73{ \
74 int policy_cpu = per_cpu(policy_cpu, cpu); \ 74 int policy_cpu = per_cpu(cpufreq_policy_cpu, cpu); \
75 BUG_ON(policy_cpu == -1); \ 75 BUG_ON(policy_cpu == -1); \
76 down_##mode(&per_cpu(cpu_policy_rwsem, policy_cpu)); \ 76 down_##mode(&per_cpu(cpu_policy_rwsem, policy_cpu)); \
77 if (unlikely(!cpu_online(cpu))) { \ 77 if (unlikely(!cpu_online(cpu))) { \
@@ -90,7 +90,7 @@ EXPORT_SYMBOL_GPL(lock_policy_rwsem_write);
90 90
91void unlock_policy_rwsem_read(int cpu) 91void unlock_policy_rwsem_read(int cpu)
92{ 92{
93 int policy_cpu = per_cpu(policy_cpu, cpu); 93 int policy_cpu = per_cpu(cpufreq_policy_cpu, cpu);
94 BUG_ON(policy_cpu == -1); 94 BUG_ON(policy_cpu == -1);
95 up_read(&per_cpu(cpu_policy_rwsem, policy_cpu)); 95 up_read(&per_cpu(cpu_policy_rwsem, policy_cpu));
96} 96}
@@ -98,7 +98,7 @@ EXPORT_SYMBOL_GPL(unlock_policy_rwsem_read);
98 98
99void unlock_policy_rwsem_write(int cpu) 99void unlock_policy_rwsem_write(int cpu)
100{ 100{
101 int policy_cpu = per_cpu(policy_cpu, cpu); 101 int policy_cpu = per_cpu(cpufreq_policy_cpu, cpu);
102 BUG_ON(policy_cpu == -1); 102 BUG_ON(policy_cpu == -1);
103 up_write(&per_cpu(cpu_policy_rwsem, policy_cpu)); 103 up_write(&per_cpu(cpu_policy_rwsem, policy_cpu));
104} 104}
@@ -818,7 +818,7 @@ static int cpufreq_add_dev_policy(unsigned int cpu,
818 818
819 /* Set proper policy_cpu */ 819 /* Set proper policy_cpu */
820 unlock_policy_rwsem_write(cpu); 820 unlock_policy_rwsem_write(cpu);
821 per_cpu(policy_cpu, cpu) = managed_policy->cpu; 821 per_cpu(cpufreq_policy_cpu, cpu) = managed_policy->cpu;
822 822
823 if (lock_policy_rwsem_write(cpu) < 0) { 823 if (lock_policy_rwsem_write(cpu) < 0) {
824 /* Should not go through policy unlock path */ 824 /* Should not go through policy unlock path */
@@ -932,7 +932,7 @@ static int cpufreq_add_dev_interface(unsigned int cpu,
932 if (!cpu_online(j)) 932 if (!cpu_online(j))
933 continue; 933 continue;
934 per_cpu(cpufreq_cpu_data, j) = policy; 934 per_cpu(cpufreq_cpu_data, j) = policy;
935 per_cpu(policy_cpu, j) = policy->cpu; 935 per_cpu(cpufreq_policy_cpu, j) = policy->cpu;
936 } 936 }
937 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 937 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
938 938
@@ -1020,7 +1020,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
1020 cpumask_copy(policy->cpus, cpumask_of(cpu)); 1020 cpumask_copy(policy->cpus, cpumask_of(cpu));
1021 1021
1022 /* Initially set CPU itself as the policy_cpu */ 1022 /* Initially set CPU itself as the policy_cpu */
1023 per_cpu(policy_cpu, cpu) = cpu; 1023 per_cpu(cpufreq_policy_cpu, cpu) = cpu;
1024 ret = (lock_policy_rwsem_write(cpu) < 0); 1024 ret = (lock_policy_rwsem_write(cpu) < 0);
1025 WARN_ON(ret); 1025 WARN_ON(ret);
1026 1026
@@ -2002,7 +2002,7 @@ static int __init cpufreq_core_init(void)
2002 int cpu; 2002 int cpu;
2003 2003
2004 for_each_possible_cpu(cpu) { 2004 for_each_possible_cpu(cpu) {
2005 per_cpu(policy_cpu, cpu) = -1; 2005 per_cpu(cpufreq_policy_cpu, cpu) = -1;
2006 init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); 2006 init_rwsem(&per_cpu(cpu_policy_rwsem, cpu));
2007 } 2007 }
2008 2008
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index a9bd3a05a684..05432216e224 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -174,7 +174,7 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
174} 174}
175EXPORT_SYMBOL_GPL(cpufreq_frequency_table_target); 175EXPORT_SYMBOL_GPL(cpufreq_frequency_table_target);
176 176
177static DEFINE_PER_CPU(struct cpufreq_frequency_table *, show_table); 177static DEFINE_PER_CPU(struct cpufreq_frequency_table *, cpufreq_show_table);
178/** 178/**
179 * show_available_freqs - show available frequencies for the specified CPU 179 * show_available_freqs - show available frequencies for the specified CPU
180 */ 180 */
@@ -185,10 +185,10 @@ static ssize_t show_available_freqs(struct cpufreq_policy *policy, char *buf)
185 ssize_t count = 0; 185 ssize_t count = 0;
186 struct cpufreq_frequency_table *table; 186 struct cpufreq_frequency_table *table;
187 187
188 if (!per_cpu(show_table, cpu)) 188 if (!per_cpu(cpufreq_show_table, cpu))
189 return -ENODEV; 189 return -ENODEV;
190 190
191 table = per_cpu(show_table, cpu); 191 table = per_cpu(cpufreq_show_table, cpu);
192 192
193 for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { 193 for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
194 if (table[i].frequency == CPUFREQ_ENTRY_INVALID) 194 if (table[i].frequency == CPUFREQ_ENTRY_INVALID)
@@ -217,20 +217,20 @@ void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table,
217 unsigned int cpu) 217 unsigned int cpu)
218{ 218{
219 dprintk("setting show_table for cpu %u to %p\n", cpu, table); 219 dprintk("setting show_table for cpu %u to %p\n", cpu, table);
220 per_cpu(show_table, cpu) = table; 220 per_cpu(cpufreq_show_table, cpu) = table;
221} 221}
222EXPORT_SYMBOL_GPL(cpufreq_frequency_table_get_attr); 222EXPORT_SYMBOL_GPL(cpufreq_frequency_table_get_attr);
223 223
224void cpufreq_frequency_table_put_attr(unsigned int cpu) 224void cpufreq_frequency_table_put_attr(unsigned int cpu)
225{ 225{
226 dprintk("clearing show_table for cpu %u\n", cpu); 226 dprintk("clearing show_table for cpu %u\n", cpu);
227 per_cpu(show_table, cpu) = NULL; 227 per_cpu(cpufreq_show_table, cpu) = NULL;
228} 228}
229EXPORT_SYMBOL_GPL(cpufreq_frequency_table_put_attr); 229EXPORT_SYMBOL_GPL(cpufreq_frequency_table_put_attr);
230 230
231struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu) 231struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu)
232{ 232{
233 return per_cpu(show_table, cpu); 233 return per_cpu(cpufreq_show_table, cpu);
234} 234}
235EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table); 235EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table);
236 236
diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c
index 84c51e177269..8c2f3703ec85 100644
--- a/drivers/crypto/padlock-aes.c
+++ b/drivers/crypto/padlock-aes.c
@@ -64,7 +64,7 @@ struct aes_ctx {
64 u32 *D; 64 u32 *D;
65}; 65};
66 66
67static DEFINE_PER_CPU(struct cword *, last_cword); 67static DEFINE_PER_CPU(struct cword *, paes_last_cword);
68 68
69/* Tells whether the ACE is capable to generate 69/* Tells whether the ACE is capable to generate
70 the extended key for a given key_len. */ 70 the extended key for a given key_len. */
@@ -152,9 +152,9 @@ static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
152 152
153ok: 153ok:
154 for_each_online_cpu(cpu) 154 for_each_online_cpu(cpu)
155 if (&ctx->cword.encrypt == per_cpu(last_cword, cpu) || 155 if (&ctx->cword.encrypt == per_cpu(paes_last_cword, cpu) ||
156 &ctx->cword.decrypt == per_cpu(last_cword, cpu)) 156 &ctx->cword.decrypt == per_cpu(paes_last_cword, cpu))
157 per_cpu(last_cword, cpu) = NULL; 157 per_cpu(paes_last_cword, cpu) = NULL;
158 158
159 return 0; 159 return 0;
160} 160}
@@ -166,7 +166,7 @@ static inline void padlock_reset_key(struct cword *cword)
166{ 166{
167 int cpu = raw_smp_processor_id(); 167 int cpu = raw_smp_processor_id();
168 168
169 if (cword != per_cpu(last_cword, cpu)) 169 if (cword != per_cpu(paes_last_cword, cpu))
170#ifndef CONFIG_X86_64 170#ifndef CONFIG_X86_64
171 asm volatile ("pushfl; popfl"); 171 asm volatile ("pushfl; popfl");
172#else 172#else
@@ -176,7 +176,7 @@ static inline void padlock_reset_key(struct cword *cword)
176 176
177static inline void padlock_store_cword(struct cword *cword) 177static inline void padlock_store_cword(struct cword *cword)
178{ 178{
179 per_cpu(last_cword, raw_smp_processor_id()) = cword; 179 per_cpu(paes_last_cword, raw_smp_processor_id()) = cword;
180} 180}
181 181
182/* 182/*
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 8f99354082ce..6f51a0a7a8bb 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -326,14 +326,7 @@ arch_initcall(dma_channel_table_init);
326 */ 326 */
327struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type) 327struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type)
328{ 328{
329 struct dma_chan *chan; 329 return this_cpu_read(channel_table[tx_type]->chan);
330 int cpu;
331
332 cpu = get_cpu();
333 chan = per_cpu_ptr(channel_table[tx_type], cpu)->chan;
334 put_cpu();
335
336 return chan;
337} 330}
338EXPORT_SYMBOL(dma_find_channel); 331EXPORT_SYMBOL(dma_find_channel);
339 332
@@ -857,7 +850,6 @@ dma_async_memcpy_buf_to_buf(struct dma_chan *chan, void *dest,
857 struct dma_async_tx_descriptor *tx; 850 struct dma_async_tx_descriptor *tx;
858 dma_addr_t dma_dest, dma_src; 851 dma_addr_t dma_dest, dma_src;
859 dma_cookie_t cookie; 852 dma_cookie_t cookie;
860 int cpu;
861 unsigned long flags; 853 unsigned long flags;
862 854
863 dma_src = dma_map_single(dev->dev, src, len, DMA_TO_DEVICE); 855 dma_src = dma_map_single(dev->dev, src, len, DMA_TO_DEVICE);
@@ -876,10 +868,10 @@ dma_async_memcpy_buf_to_buf(struct dma_chan *chan, void *dest,
876 tx->callback = NULL; 868 tx->callback = NULL;
877 cookie = tx->tx_submit(tx); 869 cookie = tx->tx_submit(tx);
878 870
879 cpu = get_cpu(); 871 preempt_disable();
880 per_cpu_ptr(chan->local, cpu)->bytes_transferred += len; 872 __this_cpu_add(chan->local->bytes_transferred, len);
881 per_cpu_ptr(chan->local, cpu)->memcpy_count++; 873 __this_cpu_inc(chan->local->memcpy_count);
882 put_cpu(); 874 preempt_enable();
883 875
884 return cookie; 876 return cookie;
885} 877}
@@ -906,7 +898,6 @@ dma_async_memcpy_buf_to_pg(struct dma_chan *chan, struct page *page,
906 struct dma_async_tx_descriptor *tx; 898 struct dma_async_tx_descriptor *tx;
907 dma_addr_t dma_dest, dma_src; 899 dma_addr_t dma_dest, dma_src;
908 dma_cookie_t cookie; 900 dma_cookie_t cookie;
909 int cpu;
910 unsigned long flags; 901 unsigned long flags;
911 902
912 dma_src = dma_map_single(dev->dev, kdata, len, DMA_TO_DEVICE); 903 dma_src = dma_map_single(dev->dev, kdata, len, DMA_TO_DEVICE);
@@ -923,10 +914,10 @@ dma_async_memcpy_buf_to_pg(struct dma_chan *chan, struct page *page,
923 tx->callback = NULL; 914 tx->callback = NULL;
924 cookie = tx->tx_submit(tx); 915 cookie = tx->tx_submit(tx);
925 916
926 cpu = get_cpu(); 917 preempt_disable();
927 per_cpu_ptr(chan->local, cpu)->bytes_transferred += len; 918 __this_cpu_add(chan->local->bytes_transferred, len);
928 per_cpu_ptr(chan->local, cpu)->memcpy_count++; 919 __this_cpu_inc(chan->local->memcpy_count);
929 put_cpu(); 920 preempt_enable();
930 921
931 return cookie; 922 return cookie;
932} 923}
@@ -955,7 +946,6 @@ dma_async_memcpy_pg_to_pg(struct dma_chan *chan, struct page *dest_pg,
955 struct dma_async_tx_descriptor *tx; 946 struct dma_async_tx_descriptor *tx;
956 dma_addr_t dma_dest, dma_src; 947 dma_addr_t dma_dest, dma_src;
957 dma_cookie_t cookie; 948 dma_cookie_t cookie;
958 int cpu;
959 unsigned long flags; 949 unsigned long flags;
960 950
961 dma_src = dma_map_page(dev->dev, src_pg, src_off, len, DMA_TO_DEVICE); 951 dma_src = dma_map_page(dev->dev, src_pg, src_off, len, DMA_TO_DEVICE);
@@ -973,10 +963,10 @@ dma_async_memcpy_pg_to_pg(struct dma_chan *chan, struct page *dest_pg,
973 tx->callback = NULL; 963 tx->callback = NULL;
974 cookie = tx->tx_submit(tx); 964 cookie = tx->tx_submit(tx);
975 965
976 cpu = get_cpu(); 966 preempt_disable();
977 per_cpu_ptr(chan->local, cpu)->bytes_transferred += len; 967 __this_cpu_add(chan->local->bytes_transferred, len);
978 per_cpu_ptr(chan->local, cpu)->memcpy_count++; 968 __this_cpu_inc(chan->local->memcpy_count);
979 put_cpu(); 969 preempt_enable();
980 970
981 return cookie; 971 return cookie;
982} 972}
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 5fdd6daa40ea..df5b68433f34 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -13,6 +13,8 @@ module_param(report_gart_errors, int, 0644);
13static int ecc_enable_override; 13static int ecc_enable_override;
14module_param(ecc_enable_override, int, 0644); 14module_param(ecc_enable_override, int, 0644);
15 15
16static struct msr *msrs;
17
16/* Lookup table for all possible MC control instances */ 18/* Lookup table for all possible MC control instances */
17struct amd64_pvt; 19struct amd64_pvt;
18static struct mem_ctl_info *mci_lookup[EDAC_MAX_NUMNODES]; 20static struct mem_ctl_info *mci_lookup[EDAC_MAX_NUMNODES];
@@ -2495,8 +2497,7 @@ static void get_cpus_on_this_dct_cpumask(struct cpumask *mask, int nid)
2495static bool amd64_nb_mce_bank_enabled_on_node(int nid) 2497static bool amd64_nb_mce_bank_enabled_on_node(int nid)
2496{ 2498{
2497 cpumask_var_t mask; 2499 cpumask_var_t mask;
2498 struct msr *msrs; 2500 int cpu, nbe;
2499 int cpu, nbe, idx = 0;
2500 bool ret = false; 2501 bool ret = false;
2501 2502
2502 if (!zalloc_cpumask_var(&mask, GFP_KERNEL)) { 2503 if (!zalloc_cpumask_var(&mask, GFP_KERNEL)) {
@@ -2507,32 +2508,22 @@ static bool amd64_nb_mce_bank_enabled_on_node(int nid)
2507 2508
2508 get_cpus_on_this_dct_cpumask(mask, nid); 2509 get_cpus_on_this_dct_cpumask(mask, nid);
2509 2510
2510 msrs = kzalloc(sizeof(struct msr) * cpumask_weight(mask), GFP_KERNEL);
2511 if (!msrs) {
2512 amd64_printk(KERN_WARNING, "%s: error allocating msrs\n",
2513 __func__);
2514 free_cpumask_var(mask);
2515 return false;
2516 }
2517
2518 rdmsr_on_cpus(mask, MSR_IA32_MCG_CTL, msrs); 2511 rdmsr_on_cpus(mask, MSR_IA32_MCG_CTL, msrs);
2519 2512
2520 for_each_cpu(cpu, mask) { 2513 for_each_cpu(cpu, mask) {
2521 nbe = msrs[idx].l & K8_MSR_MCGCTL_NBE; 2514 struct msr *reg = per_cpu_ptr(msrs, cpu);
2515 nbe = reg->l & K8_MSR_MCGCTL_NBE;
2522 2516
2523 debugf0("core: %u, MCG_CTL: 0x%llx, NB MSR is %s\n", 2517 debugf0("core: %u, MCG_CTL: 0x%llx, NB MSR is %s\n",
2524 cpu, msrs[idx].q, 2518 cpu, reg->q,
2525 (nbe ? "enabled" : "disabled")); 2519 (nbe ? "enabled" : "disabled"));
2526 2520
2527 if (!nbe) 2521 if (!nbe)
2528 goto out; 2522 goto out;
2529
2530 idx++;
2531 } 2523 }
2532 ret = true; 2524 ret = true;
2533 2525
2534out: 2526out:
2535 kfree(msrs);
2536 free_cpumask_var(mask); 2527 free_cpumask_var(mask);
2537 return ret; 2528 return ret;
2538} 2529}
@@ -2540,8 +2531,7 @@ out:
2540static int amd64_toggle_ecc_err_reporting(struct amd64_pvt *pvt, bool on) 2531static int amd64_toggle_ecc_err_reporting(struct amd64_pvt *pvt, bool on)
2541{ 2532{
2542 cpumask_var_t cmask; 2533 cpumask_var_t cmask;
2543 struct msr *msrs = NULL; 2534 int cpu;
2544 int cpu, idx = 0;
2545 2535
2546 if (!zalloc_cpumask_var(&cmask, GFP_KERNEL)) { 2536 if (!zalloc_cpumask_var(&cmask, GFP_KERNEL)) {
2547 amd64_printk(KERN_WARNING, "%s: error allocating mask\n", 2537 amd64_printk(KERN_WARNING, "%s: error allocating mask\n",
@@ -2551,34 +2541,27 @@ static int amd64_toggle_ecc_err_reporting(struct amd64_pvt *pvt, bool on)
2551 2541
2552 get_cpus_on_this_dct_cpumask(cmask, pvt->mc_node_id); 2542 get_cpus_on_this_dct_cpumask(cmask, pvt->mc_node_id);
2553 2543
2554 msrs = kzalloc(sizeof(struct msr) * cpumask_weight(cmask), GFP_KERNEL);
2555 if (!msrs) {
2556 amd64_printk(KERN_WARNING, "%s: error allocating msrs\n",
2557 __func__);
2558 return -ENOMEM;
2559 }
2560
2561 rdmsr_on_cpus(cmask, MSR_IA32_MCG_CTL, msrs); 2544 rdmsr_on_cpus(cmask, MSR_IA32_MCG_CTL, msrs);
2562 2545
2563 for_each_cpu(cpu, cmask) { 2546 for_each_cpu(cpu, cmask) {
2564 2547
2548 struct msr *reg = per_cpu_ptr(msrs, cpu);
2549
2565 if (on) { 2550 if (on) {
2566 if (msrs[idx].l & K8_MSR_MCGCTL_NBE) 2551 if (reg->l & K8_MSR_MCGCTL_NBE)
2567 pvt->flags.ecc_report = 1; 2552 pvt->flags.ecc_report = 1;
2568 2553
2569 msrs[idx].l |= K8_MSR_MCGCTL_NBE; 2554 reg->l |= K8_MSR_MCGCTL_NBE;
2570 } else { 2555 } else {
2571 /* 2556 /*
2572 * Turn off ECC reporting only when it was off before 2557 * Turn off ECC reporting only when it was off before
2573 */ 2558 */
2574 if (!pvt->flags.ecc_report) 2559 if (!pvt->flags.ecc_report)
2575 msrs[idx].l &= ~K8_MSR_MCGCTL_NBE; 2560 reg->l &= ~K8_MSR_MCGCTL_NBE;
2576 } 2561 }
2577 idx++;
2578 } 2562 }
2579 wrmsr_on_cpus(cmask, MSR_IA32_MCG_CTL, msrs); 2563 wrmsr_on_cpus(cmask, MSR_IA32_MCG_CTL, msrs);
2580 2564
2581 kfree(msrs);
2582 free_cpumask_var(cmask); 2565 free_cpumask_var(cmask);
2583 2566
2584 return 0; 2567 return 0;
@@ -3036,6 +3019,8 @@ static int __init amd64_edac_init(void)
3036 if (cache_k8_northbridges() < 0) 3019 if (cache_k8_northbridges() < 0)
3037 return err; 3020 return err;
3038 3021
3022 msrs = msrs_alloc();
3023
3039 err = pci_register_driver(&amd64_pci_driver); 3024 err = pci_register_driver(&amd64_pci_driver);
3040 if (err) 3025 if (err)
3041 return err; 3026 return err;
@@ -3071,6 +3056,9 @@ static void __exit amd64_edac_exit(void)
3071 edac_pci_release_generic_ctl(amd64_ctl_pci); 3056 edac_pci_release_generic_ctl(amd64_ctl_pci);
3072 3057
3073 pci_unregister_driver(&amd64_pci_driver); 3058 pci_unregister_driver(&amd64_pci_driver);
3059
3060 msrs_free(msrs);
3061 msrs = NULL;
3074} 3062}
3075 3063
3076module_init(amd64_edac_init); 3064module_init(amd64_edac_init);
diff --git a/drivers/gpio/adp5520-gpio.c b/drivers/gpio/adp5520-gpio.c
index ad05bbc7ffd5..0f93105873cd 100644
--- a/drivers/gpio/adp5520-gpio.c
+++ b/drivers/gpio/adp5520-gpio.c
@@ -34,9 +34,9 @@ static int adp5520_gpio_get_value(struct gpio_chip *chip, unsigned off)
34 */ 34 */
35 35
36 if (test_bit(off, &dev->output)) 36 if (test_bit(off, &dev->output))
37 adp5520_read(dev->master, GPIO_OUT, &reg_val); 37 adp5520_read(dev->master, ADP5520_GPIO_OUT, &reg_val);
38 else 38 else
39 adp5520_read(dev->master, GPIO_IN, &reg_val); 39 adp5520_read(dev->master, ADP5520_GPIO_IN, &reg_val);
40 40
41 return !!(reg_val & dev->lut[off]); 41 return !!(reg_val & dev->lut[off]);
42} 42}
@@ -48,9 +48,9 @@ static void adp5520_gpio_set_value(struct gpio_chip *chip,
48 dev = container_of(chip, struct adp5520_gpio, gpio_chip); 48 dev = container_of(chip, struct adp5520_gpio, gpio_chip);
49 49
50 if (val) 50 if (val)
51 adp5520_set_bits(dev->master, GPIO_OUT, dev->lut[off]); 51 adp5520_set_bits(dev->master, ADP5520_GPIO_OUT, dev->lut[off]);
52 else 52 else
53 adp5520_clr_bits(dev->master, GPIO_OUT, dev->lut[off]); 53 adp5520_clr_bits(dev->master, ADP5520_GPIO_OUT, dev->lut[off]);
54} 54}
55 55
56static int adp5520_gpio_direction_input(struct gpio_chip *chip, unsigned off) 56static int adp5520_gpio_direction_input(struct gpio_chip *chip, unsigned off)
@@ -60,7 +60,8 @@ static int adp5520_gpio_direction_input(struct gpio_chip *chip, unsigned off)
60 60
61 clear_bit(off, &dev->output); 61 clear_bit(off, &dev->output);
62 62
63 return adp5520_clr_bits(dev->master, GPIO_CFG_2, dev->lut[off]); 63 return adp5520_clr_bits(dev->master, ADP5520_GPIO_CFG_2,
64 dev->lut[off]);
64} 65}
65 66
66static int adp5520_gpio_direction_output(struct gpio_chip *chip, 67static int adp5520_gpio_direction_output(struct gpio_chip *chip,
@@ -73,18 +74,21 @@ static int adp5520_gpio_direction_output(struct gpio_chip *chip,
73 set_bit(off, &dev->output); 74 set_bit(off, &dev->output);
74 75
75 if (val) 76 if (val)
76 ret |= adp5520_set_bits(dev->master, GPIO_OUT, dev->lut[off]); 77 ret |= adp5520_set_bits(dev->master, ADP5520_GPIO_OUT,
78 dev->lut[off]);
77 else 79 else
78 ret |= adp5520_clr_bits(dev->master, GPIO_OUT, dev->lut[off]); 80 ret |= adp5520_clr_bits(dev->master, ADP5520_GPIO_OUT,
81 dev->lut[off]);
79 82
80 ret |= adp5520_set_bits(dev->master, GPIO_CFG_2, dev->lut[off]); 83 ret |= adp5520_set_bits(dev->master, ADP5520_GPIO_CFG_2,
84 dev->lut[off]);
81 85
82 return ret; 86 return ret;
83} 87}
84 88
85static int __devinit adp5520_gpio_probe(struct platform_device *pdev) 89static int __devinit adp5520_gpio_probe(struct platform_device *pdev)
86{ 90{
87 struct adp5520_gpio_platfrom_data *pdata = pdev->dev.platform_data; 91 struct adp5520_gpio_platform_data *pdata = pdev->dev.platform_data;
88 struct adp5520_gpio *dev; 92 struct adp5520_gpio *dev;
89 struct gpio_chip *gc; 93 struct gpio_chip *gc;
90 int ret, i, gpios; 94 int ret, i, gpios;
@@ -129,20 +133,20 @@ static int __devinit adp5520_gpio_probe(struct platform_device *pdev)
129 gc->label = pdev->name; 133 gc->label = pdev->name;
130 gc->owner = THIS_MODULE; 134 gc->owner = THIS_MODULE;
131 135
132 ret = adp5520_clr_bits(dev->master, GPIO_CFG_1, 136 ret = adp5520_clr_bits(dev->master, ADP5520_GPIO_CFG_1,
133 pdata->gpio_en_mask); 137 pdata->gpio_en_mask);
134 138
135 if (pdata->gpio_en_mask & GPIO_C3) 139 if (pdata->gpio_en_mask & ADP5520_GPIO_C3)
136 ctl_mask |= C3_MODE; 140 ctl_mask |= ADP5520_C3_MODE;
137 141
138 if (pdata->gpio_en_mask & GPIO_R3) 142 if (pdata->gpio_en_mask & ADP5520_GPIO_R3)
139 ctl_mask |= R3_MODE; 143 ctl_mask |= ADP5520_R3_MODE;
140 144
141 if (ctl_mask) 145 if (ctl_mask)
142 ret = adp5520_set_bits(dev->master, LED_CONTROL, 146 ret = adp5520_set_bits(dev->master, ADP5520_LED_CONTROL,
143 ctl_mask); 147 ctl_mask);
144 148
145 ret |= adp5520_set_bits(dev->master, GPIO_PULLUP, 149 ret |= adp5520_set_bits(dev->master, ADP5520_GPIO_PULLUP,
146 pdata->gpio_pullup_mask); 150 pdata->gpio_pullup_mask);
147 151
148 if (ret) { 152 if (ret) {
diff --git a/drivers/gpio/twl4030-gpio.c b/drivers/gpio/twl4030-gpio.c
index 49384a7c5492..7fe881e2bdfb 100644
--- a/drivers/gpio/twl4030-gpio.c
+++ b/drivers/gpio/twl4030-gpio.c
@@ -34,7 +34,7 @@
34#include <linux/platform_device.h> 34#include <linux/platform_device.h>
35#include <linux/slab.h> 35#include <linux/slab.h>
36 36
37#include <linux/i2c/twl4030.h> 37#include <linux/i2c/twl.h>
38 38
39 39
40/* 40/*
@@ -80,7 +80,7 @@ static unsigned int gpio_usage_count;
80 */ 80 */
81static inline int gpio_twl4030_write(u8 address, u8 data) 81static inline int gpio_twl4030_write(u8 address, u8 data)
82{ 82{
83 return twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, data, address); 83 return twl_i2c_write_u8(TWL4030_MODULE_GPIO, data, address);
84} 84}
85 85
86/*----------------------------------------------------------------------*/ 86/*----------------------------------------------------------------------*/
@@ -117,7 +117,7 @@ static inline int gpio_twl4030_read(u8 address)
117 u8 data; 117 u8 data;
118 int ret = 0; 118 int ret = 0;
119 119
120 ret = twl4030_i2c_read_u8(TWL4030_MODULE_GPIO, &data, address); 120 ret = twl_i2c_read_u8(TWL4030_MODULE_GPIO, &data, address);
121 return (ret < 0) ? ret : data; 121 return (ret < 0) ? ret : data;
122} 122}
123 123
@@ -142,7 +142,7 @@ static void twl4030_led_set_value(int led, int value)
142 cached_leden &= ~mask; 142 cached_leden &= ~mask;
143 else 143 else
144 cached_leden |= mask; 144 cached_leden |= mask;
145 status = twl4030_i2c_write_u8(TWL4030_MODULE_LED, cached_leden, 145 status = twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden,
146 TWL4030_LED_LEDEN); 146 TWL4030_LED_LEDEN);
147 mutex_unlock(&gpio_lock); 147 mutex_unlock(&gpio_lock);
148} 148}
@@ -223,23 +223,23 @@ static int twl_request(struct gpio_chip *chip, unsigned offset)
223 } 223 }
224 224
225 /* initialize PWM to always-drive */ 225 /* initialize PWM to always-drive */
226 status = twl4030_i2c_write_u8(module, 0x7f, 226 status = twl_i2c_write_u8(module, 0x7f,
227 TWL4030_PWMx_PWMxOFF); 227 TWL4030_PWMx_PWMxOFF);
228 if (status < 0) 228 if (status < 0)
229 goto done; 229 goto done;
230 status = twl4030_i2c_write_u8(module, 0x7f, 230 status = twl_i2c_write_u8(module, 0x7f,
231 TWL4030_PWMx_PWMxON); 231 TWL4030_PWMx_PWMxON);
232 if (status < 0) 232 if (status < 0)
233 goto done; 233 goto done;
234 234
235 /* init LED to not-driven (high) */ 235 /* init LED to not-driven (high) */
236 module = TWL4030_MODULE_LED; 236 module = TWL4030_MODULE_LED;
237 status = twl4030_i2c_read_u8(module, &cached_leden, 237 status = twl_i2c_read_u8(module, &cached_leden,
238 TWL4030_LED_LEDEN); 238 TWL4030_LED_LEDEN);
239 if (status < 0) 239 if (status < 0)
240 goto done; 240 goto done;
241 cached_leden &= ~ledclr_mask; 241 cached_leden &= ~ledclr_mask;
242 status = twl4030_i2c_write_u8(module, cached_leden, 242 status = twl_i2c_write_u8(module, cached_leden,
243 TWL4030_LED_LEDEN); 243 TWL4030_LED_LEDEN);
244 if (status < 0) 244 if (status < 0)
245 goto done; 245 goto done;
@@ -370,7 +370,7 @@ static int __devinit gpio_twl4030_pulls(u32 ups, u32 downs)
370 message[i] = bit_mask; 370 message[i] = bit_mask;
371 } 371 }
372 372
373 return twl4030_i2c_write(TWL4030_MODULE_GPIO, message, 373 return twl_i2c_write(TWL4030_MODULE_GPIO, message,
374 REG_GPIOPUPDCTR1, 5); 374 REG_GPIOPUPDCTR1, 5);
375} 375}
376 376
@@ -387,7 +387,7 @@ static int __devinit gpio_twl4030_debounce(u32 debounce, u8 mmc_cd)
387 debounce >>= 8; 387 debounce >>= 8;
388 message[3] = (debounce & 0x03); 388 message[3] = (debounce & 0x03);
389 389
390 return twl4030_i2c_write(TWL4030_MODULE_GPIO, message, 390 return twl_i2c_write(TWL4030_MODULE_GPIO, message,
391 REG_GPIO_DEBEN1, 3); 391 REG_GPIO_DEBEN1, 3);
392} 392}
393 393
diff --git a/drivers/gpio/wm831x-gpio.c b/drivers/gpio/wm831x-gpio.c
index f9c09a54ec7f..b4468b616890 100644
--- a/drivers/gpio/wm831x-gpio.c
+++ b/drivers/gpio/wm831x-gpio.c
@@ -22,8 +22,7 @@
22#include <linux/mfd/wm831x/core.h> 22#include <linux/mfd/wm831x/core.h>
23#include <linux/mfd/wm831x/pdata.h> 23#include <linux/mfd/wm831x/pdata.h>
24#include <linux/mfd/wm831x/gpio.h> 24#include <linux/mfd/wm831x/gpio.h>
25 25#include <linux/mfd/wm831x/irq.h>
26#define WM831X_GPIO_MAX 16
27 26
28struct wm831x_gpio { 27struct wm831x_gpio {
29 struct wm831x *wm831x; 28 struct wm831x *wm831x;
@@ -80,6 +79,17 @@ static void wm831x_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
80 value << offset); 79 value << offset);
81} 80}
82 81
82static int wm831x_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
83{
84 struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
85 struct wm831x *wm831x = wm831x_gpio->wm831x;
86
87 if (!wm831x->irq_base)
88 return -EINVAL;
89
90 return wm831x->irq_base + WM831X_IRQ_GPIO_1 + offset;
91}
92
83#ifdef CONFIG_DEBUG_FS 93#ifdef CONFIG_DEBUG_FS
84static void wm831x_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) 94static void wm831x_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
85{ 95{
@@ -175,6 +185,7 @@ static struct gpio_chip template_chip = {
175 .get = wm831x_gpio_get, 185 .get = wm831x_gpio_get,
176 .direction_output = wm831x_gpio_direction_out, 186 .direction_output = wm831x_gpio_direction_out,
177 .set = wm831x_gpio_set, 187 .set = wm831x_gpio_set,
188 .to_irq = wm831x_gpio_to_irq,
178 .dbg_show = wm831x_gpio_dbg_show, 189 .dbg_show = wm831x_gpio_dbg_show,
179 .can_sleep = 1, 190 .can_sleep = 1,
180}; 191};
@@ -192,7 +203,7 @@ static int __devinit wm831x_gpio_probe(struct platform_device *pdev)
192 203
193 wm831x_gpio->wm831x = wm831x; 204 wm831x_gpio->wm831x = wm831x;
194 wm831x_gpio->gpio_chip = template_chip; 205 wm831x_gpio->gpio_chip = template_chip;
195 wm831x_gpio->gpio_chip.ngpio = WM831X_GPIO_MAX; 206 wm831x_gpio->gpio_chip.ngpio = wm831x->num_gpio;
196 wm831x_gpio->gpio_chip.dev = &pdev->dev; 207 wm831x_gpio->gpio_chip.dev = &pdev->dev;
197 if (pdata && pdata->gpio_base) 208 if (pdata && pdata->gpio_base)
198 wm831x_gpio->gpio_chip.base = pdata->gpio_base; 209 wm831x_gpio->gpio_chip.base = pdata->gpio_base;
diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c
index 4b89b791be6a..42be0b15084b 100644
--- a/drivers/infiniband/hw/ehca/ehca_irq.c
+++ b/drivers/infiniband/hw/ehca/ehca_irq.c
@@ -826,8 +826,7 @@ static void __cpuinit take_over_work(struct ehca_comp_pool *pool, int cpu)
826 cq = list_entry(cct->cq_list.next, struct ehca_cq, entry); 826 cq = list_entry(cct->cq_list.next, struct ehca_cq, entry);
827 827
828 list_del(&cq->entry); 828 list_del(&cq->entry);
829 __queue_comp_task(cq, per_cpu_ptr(pool->cpu_comp_tasks, 829 __queue_comp_task(cq, this_cpu_ptr(pool->cpu_comp_tasks));
830 smp_processor_id()));
831 } 830 }
832 831
833 spin_unlock_irqrestore(&cct->task_lock, flags_cct); 832 spin_unlock_irqrestore(&cct->task_lock, flags_cct);
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 203b88a82b56..02c836e11813 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -24,6 +24,16 @@ config KEYBOARD_AAED2000
24 To compile this driver as a module, choose M here: the 24 To compile this driver as a module, choose M here: the
25 module will be called aaed2000_kbd. 25 module will be called aaed2000_kbd.
26 26
27config KEYBOARD_ADP5520
28 tristate "Keypad Support for ADP5520 PMIC"
29 depends on PMIC_ADP5520
30 help
31 This option enables support for the keypad scan matrix
32 on Analog Devices ADP5520 PMICs.
33
34 To compile this driver as a module, choose M here: the module will
35 be called adp5520-keys.
36
27config KEYBOARD_ADP5588 37config KEYBOARD_ADP5588
28 tristate "ADP5588 I2C QWERTY Keypad and IO Expander" 38 tristate "ADP5588 I2C QWERTY Keypad and IO Expander"
29 depends on I2C 39 depends on I2C
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 68c017235ce9..78654ef65206 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -5,6 +5,7 @@
5# Each configuration option enables a list of files. 5# Each configuration option enables a list of files.
6 6
7obj-$(CONFIG_KEYBOARD_AAED2000) += aaed2000_kbd.o 7obj-$(CONFIG_KEYBOARD_AAED2000) += aaed2000_kbd.o
8obj-$(CONFIG_KEYBOARD_ADP5520) += adp5520-keys.o
8obj-$(CONFIG_KEYBOARD_ADP5588) += adp5588-keys.o 9obj-$(CONFIG_KEYBOARD_ADP5588) += adp5588-keys.o
9obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o 10obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o
10obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o 11obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o
diff --git a/drivers/input/keyboard/adp5520-keys.c b/drivers/input/keyboard/adp5520-keys.c
new file mode 100644
index 000000000000..a7ba27fb4109
--- /dev/null
+++ b/drivers/input/keyboard/adp5520-keys.c
@@ -0,0 +1,220 @@
1/*
2 * Keypad driver for Analog Devices ADP5520 MFD PMICs
3 *
4 * Copyright 2009 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#include <linux/module.h>
10#include <linux/kernel.h>
11#include <linux/init.h>
12#include <linux/platform_device.h>
13#include <linux/input.h>
14#include <linux/mfd/adp5520.h>
15
16struct adp5520_keys {
17 struct input_dev *input;
18 struct notifier_block notifier;
19 struct device *master;
20 unsigned short keycode[ADP5520_KEYMAPSIZE];
21};
22
23static void adp5520_keys_report_event(struct adp5520_keys *dev,
24 unsigned short keymask, int value)
25{
26 int i;
27
28 for (i = 0; i < ADP5520_MAXKEYS; i++)
29 if (keymask & (1 << i))
30 input_report_key(dev->input, dev->keycode[i], value);
31
32 input_sync(dev->input);
33}
34
35static int adp5520_keys_notifier(struct notifier_block *nb,
36 unsigned long event, void *data)
37{
38 struct adp5520_keys *dev;
39 uint8_t reg_val_lo, reg_val_hi;
40 unsigned short keymask;
41
42 dev = container_of(nb, struct adp5520_keys, notifier);
43
44 if (event & ADP5520_KP_INT) {
45 adp5520_read(dev->master, ADP5520_KP_INT_STAT_1, &reg_val_lo);
46 adp5520_read(dev->master, ADP5520_KP_INT_STAT_2, &reg_val_hi);
47
48 keymask = (reg_val_hi << 8) | reg_val_lo;
49 /* Read twice to clear */
50 adp5520_read(dev->master, ADP5520_KP_INT_STAT_1, &reg_val_lo);
51 adp5520_read(dev->master, ADP5520_KP_INT_STAT_2, &reg_val_hi);
52 keymask |= (reg_val_hi << 8) | reg_val_lo;
53 adp5520_keys_report_event(dev, keymask, 1);
54 }
55
56 if (event & ADP5520_KR_INT) {
57 adp5520_read(dev->master, ADP5520_KR_INT_STAT_1, &reg_val_lo);
58 adp5520_read(dev->master, ADP5520_KR_INT_STAT_2, &reg_val_hi);
59
60 keymask = (reg_val_hi << 8) | reg_val_lo;
61 /* Read twice to clear */
62 adp5520_read(dev->master, ADP5520_KR_INT_STAT_1, &reg_val_lo);
63 adp5520_read(dev->master, ADP5520_KR_INT_STAT_2, &reg_val_hi);
64 keymask |= (reg_val_hi << 8) | reg_val_lo;
65 adp5520_keys_report_event(dev, keymask, 0);
66 }
67
68 return 0;
69}
70
71static int __devinit adp5520_keys_probe(struct platform_device *pdev)
72{
73 struct adp5520_keys_platform_data *pdata = pdev->dev.platform_data;
74 struct input_dev *input;
75 struct adp5520_keys *dev;
76 int ret, i;
77 unsigned char en_mask, ctl_mask = 0;
78
79 if (pdev->id != ID_ADP5520) {
80 dev_err(&pdev->dev, "only ADP5520 supports Keypad\n");
81 return -EINVAL;
82 }
83
84 if (pdata == NULL) {
85 dev_err(&pdev->dev, "missing platform data\n");
86 return -EINVAL;
87 }
88
89 if (!(pdata->rows_en_mask && pdata->cols_en_mask))
90 return -EINVAL;
91
92 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
93 if (dev == NULL) {
94 dev_err(&pdev->dev, "failed to alloc memory\n");
95 return -ENOMEM;
96 }
97
98 input = input_allocate_device();
99 if (!input) {
100 ret = -ENOMEM;
101 goto err;
102 }
103
104 dev->master = pdev->dev.parent;
105 dev->input = input;
106
107 input->name = pdev->name;
108 input->phys = "adp5520-keys/input0";
109 input->dev.parent = &pdev->dev;
110
111 input_set_drvdata(input, dev);
112
113 input->id.bustype = BUS_I2C;
114 input->id.vendor = 0x0001;
115 input->id.product = 0x5520;
116 input->id.version = 0x0001;
117
118 input->keycodesize = sizeof(dev->keycode[0]);
119 input->keycodemax = pdata->keymapsize;
120 input->keycode = dev->keycode;
121
122 memcpy(dev->keycode, pdata->keymap,
123 pdata->keymapsize * input->keycodesize);
124
125 /* setup input device */
126 __set_bit(EV_KEY, input->evbit);
127
128 if (pdata->repeat)
129 __set_bit(EV_REP, input->evbit);
130
131 for (i = 0; i < input->keycodemax; i++)
132 __set_bit(dev->keycode[i], input->keybit);
133 __clear_bit(KEY_RESERVED, input->keybit);
134
135 ret = input_register_device(input);
136 if (ret) {
137 dev_err(&pdev->dev, "unable to register input device\n");
138 goto err;
139 }
140
141 en_mask = pdata->rows_en_mask | pdata->cols_en_mask;
142
143 ret = adp5520_set_bits(dev->master, ADP5520_GPIO_CFG_1, en_mask);
144
145 if (en_mask & ADP5520_COL_C3)
146 ctl_mask |= ADP5520_C3_MODE;
147
148 if (en_mask & ADP5520_ROW_R3)
149 ctl_mask |= ADP5520_R3_MODE;
150
151 if (ctl_mask)
152 ret |= adp5520_set_bits(dev->master, ADP5520_LED_CONTROL,
153 ctl_mask);
154
155 ret |= adp5520_set_bits(dev->master, ADP5520_GPIO_PULLUP,
156 pdata->rows_en_mask);
157
158 if (ret) {
159 dev_err(&pdev->dev, "failed to write\n");
160 ret = -EIO;
161 goto err1;
162 }
163
164 dev->notifier.notifier_call = adp5520_keys_notifier;
165 ret = adp5520_register_notifier(dev->master, &dev->notifier,
166 ADP5520_KP_IEN | ADP5520_KR_IEN);
167 if (ret) {
168 dev_err(&pdev->dev, "failed to register notifier\n");
169 goto err1;
170 }
171
172 platform_set_drvdata(pdev, dev);
173 return 0;
174
175err1:
176 input_unregister_device(input);
177 input = NULL;
178err:
179 input_free_device(input);
180 kfree(dev);
181 return ret;
182}
183
184static int __devexit adp5520_keys_remove(struct platform_device *pdev)
185{
186 struct adp5520_keys *dev = platform_get_drvdata(pdev);
187
188 adp5520_unregister_notifier(dev->master, &dev->notifier,
189 ADP5520_KP_IEN | ADP5520_KR_IEN);
190
191 input_unregister_device(dev->input);
192 kfree(dev);
193 return 0;
194}
195
196static struct platform_driver adp5520_keys_driver = {
197 .driver = {
198 .name = "adp5520-keys",
199 .owner = THIS_MODULE,
200 },
201 .probe = adp5520_keys_probe,
202 .remove = __devexit_p(adp5520_keys_remove),
203};
204
205static int __init adp5520_keys_init(void)
206{
207 return platform_driver_register(&adp5520_keys_driver);
208}
209module_init(adp5520_keys_init);
210
211static void __exit adp5520_keys_exit(void)
212{
213 platform_driver_unregister(&adp5520_keys_driver);
214}
215module_exit(adp5520_keys_exit);
216
217MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
218MODULE_DESCRIPTION("Keys ADP5520 Driver");
219MODULE_LICENSE("GPL");
220MODULE_ALIAS("platform:adp5520-keys");
diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c
index 9a2977c21696..eeaa7acb9cfc 100644
--- a/drivers/input/keyboard/twl4030_keypad.c
+++ b/drivers/input/keyboard/twl4030_keypad.c
@@ -31,7 +31,7 @@
31#include <linux/interrupt.h> 31#include <linux/interrupt.h>
32#include <linux/input.h> 32#include <linux/input.h>
33#include <linux/platform_device.h> 33#include <linux/platform_device.h>
34#include <linux/i2c/twl4030.h> 34#include <linux/i2c/twl.h>
35 35
36 36
37/* 37/*
@@ -133,7 +133,7 @@ struct twl4030_keypad {
133static int twl4030_kpread(struct twl4030_keypad *kp, 133static int twl4030_kpread(struct twl4030_keypad *kp,
134 u8 *data, u32 reg, u8 num_bytes) 134 u8 *data, u32 reg, u8 num_bytes)
135{ 135{
136 int ret = twl4030_i2c_read(TWL4030_MODULE_KEYPAD, data, reg, num_bytes); 136 int ret = twl_i2c_read(TWL4030_MODULE_KEYPAD, data, reg, num_bytes);
137 137
138 if (ret < 0) 138 if (ret < 0)
139 dev_warn(kp->dbg_dev, 139 dev_warn(kp->dbg_dev,
@@ -145,7 +145,7 @@ static int twl4030_kpread(struct twl4030_keypad *kp,
145 145
146static int twl4030_kpwrite_u8(struct twl4030_keypad *kp, u8 data, u32 reg) 146static int twl4030_kpwrite_u8(struct twl4030_keypad *kp, u8 data, u32 reg)
147{ 147{
148 int ret = twl4030_i2c_write_u8(TWL4030_MODULE_KEYPAD, data, reg); 148 int ret = twl_i2c_write_u8(TWL4030_MODULE_KEYPAD, data, reg);
149 149
150 if (ret < 0) 150 if (ret < 0)
151 dev_warn(kp->dbg_dev, 151 dev_warn(kp->dbg_dev,
diff --git a/drivers/input/misc/pcf50633-input.c b/drivers/input/misc/pcf50633-input.c
index 039dcb00ebd9..008de0c5834b 100644
--- a/drivers/input/misc/pcf50633-input.c
+++ b/drivers/input/misc/pcf50633-input.c
@@ -55,7 +55,6 @@ pcf50633_input_irq(int irq, void *data)
55static int __devinit pcf50633_input_probe(struct platform_device *pdev) 55static int __devinit pcf50633_input_probe(struct platform_device *pdev)
56{ 56{
57 struct pcf50633_input *input; 57 struct pcf50633_input *input;
58 struct pcf50633_subdev_pdata *pdata = pdev->dev.platform_data;
59 struct input_dev *input_dev; 58 struct input_dev *input_dev;
60 int ret; 59 int ret;
61 60
@@ -71,7 +70,7 @@ static int __devinit pcf50633_input_probe(struct platform_device *pdev)
71 } 70 }
72 71
73 platform_set_drvdata(pdev, input); 72 platform_set_drvdata(pdev, input);
74 input->pcf = pdata->pcf; 73 input->pcf = dev_to_pcf50633(pdev->dev.parent);
75 input->input_dev = input_dev; 74 input->input_dev = input_dev;
76 75
77 input_dev->name = "PCF50633 PMU events"; 76 input_dev->name = "PCF50633 PMU events";
@@ -85,9 +84,9 @@ static int __devinit pcf50633_input_probe(struct platform_device *pdev)
85 kfree(input); 84 kfree(input);
86 return ret; 85 return ret;
87 } 86 }
88 pcf50633_register_irq(pdata->pcf, PCF50633_IRQ_ONKEYR, 87 pcf50633_register_irq(input->pcf, PCF50633_IRQ_ONKEYR,
89 pcf50633_input_irq, input); 88 pcf50633_input_irq, input);
90 pcf50633_register_irq(pdata->pcf, PCF50633_IRQ_ONKEYF, 89 pcf50633_register_irq(input->pcf, PCF50633_IRQ_ONKEYF,
91 pcf50633_input_irq, input); 90 pcf50633_input_irq, input);
92 91
93 return 0; 92 return 0;
diff --git a/drivers/input/misc/twl4030-pwrbutton.c b/drivers/input/misc/twl4030-pwrbutton.c
index f5fc9974a111..bdde5c889035 100644
--- a/drivers/input/misc/twl4030-pwrbutton.c
+++ b/drivers/input/misc/twl4030-pwrbutton.c
@@ -27,7 +27,7 @@
27#include <linux/input.h> 27#include <linux/input.h>
28#include <linux/interrupt.h> 28#include <linux/interrupt.h>
29#include <linux/platform_device.h> 29#include <linux/platform_device.h>
30#include <linux/i2c/twl4030.h> 30#include <linux/i2c/twl.h>
31 31
32#define PWR_PWRON_IRQ (1 << 0) 32#define PWR_PWRON_IRQ (1 << 0)
33 33
@@ -49,7 +49,7 @@ static irqreturn_t powerbutton_irq(int irq, void *_pwr)
49 local_irq_enable(); 49 local_irq_enable();
50#endif 50#endif
51 51
52 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &value, 52 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &value,
53 STS_HW_CONDITIONS); 53 STS_HW_CONDITIONS);
54 if (!err) { 54 if (!err) {
55 input_report_key(pwr, KEY_POWER, value & PWR_PWRON_IRQ); 55 input_report_key(pwr, KEY_POWER, value & PWR_PWRON_IRQ);
diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c
index 5a6ae646a636..94b796d84053 100644
--- a/drivers/isdn/hardware/avm/avm_cs.c
+++ b/drivers/isdn/hardware/avm/avm_cs.c
@@ -108,8 +108,7 @@ static int avmcs_probe(struct pcmcia_device *p_dev)
108 p_dev->io.NumPorts2 = 0; 108 p_dev->io.NumPorts2 = 0;
109 109
110 /* Interrupt setup */ 110 /* Interrupt setup */
111 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 111 p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
112 p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED;
113 112
114 /* General socket configuration */ 113 /* General socket configuration */
115 p_dev->conf.Attributes = CONF_ENABLE_IRQ; 114 p_dev->conf.Attributes = CONF_ENABLE_IRQ;
diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c
index f9bdff39cf4a..e5deb15cf40c 100644
--- a/drivers/isdn/hisax/avma1_cs.c
+++ b/drivers/isdn/hisax/avma1_cs.c
@@ -120,8 +120,7 @@ static int avma1cs_probe(struct pcmcia_device *p_dev)
120 p_dev->io.IOAddrLines = 5; 120 p_dev->io.IOAddrLines = 5;
121 121
122 /* Interrupt setup */ 122 /* Interrupt setup */
123 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 123 p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
124 p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED;
125 124
126 /* General socket configuration */ 125 /* General socket configuration */
127 p_dev->conf.Attributes = CONF_ENABLE_IRQ; 126 p_dev->conf.Attributes = CONF_ENABLE_IRQ;
diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c
index a2f709f53974..c9a30b1c9237 100644
--- a/drivers/isdn/hisax/elsa_cs.c
+++ b/drivers/isdn/hisax/elsa_cs.c
@@ -137,7 +137,7 @@ static int elsa_cs_probe(struct pcmcia_device *link)
137 local->cardnr = -1; 137 local->cardnr = -1;
138 138
139 /* Interrupt setup */ 139 /* Interrupt setup */
140 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; 140 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
141 link->irq.Handler = NULL; 141 link->irq.Handler = NULL;
142 142
143 /* 143 /*
diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c
index af5d393cc2d0..7836ec3c7f86 100644
--- a/drivers/isdn/hisax/sedlbauer_cs.c
+++ b/drivers/isdn/hisax/sedlbauer_cs.c
@@ -144,7 +144,7 @@ static int sedlbauer_probe(struct pcmcia_device *link)
144 link->priv = local; 144 link->priv = local;
145 145
146 /* Interrupt setup */ 146 /* Interrupt setup */
147 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; 147 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
148 link->irq.Handler = NULL; 148 link->irq.Handler = NULL;
149 149
150 /* 150 /*
diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c
index ea705394ce2b..b0c5976cbdb3 100644
--- a/drivers/isdn/hisax/teles_cs.c
+++ b/drivers/isdn/hisax/teles_cs.c
@@ -127,7 +127,7 @@ static int teles_probe(struct pcmcia_device *link)
127 link->priv = local; 127 link->priv = local;
128 128
129 /* Interrupt setup */ 129 /* Interrupt setup */
130 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; 130 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
131 link->irq.Handler = NULL; 131 link->irq.Handler = NULL;
132 132
133 /* 133 /*
diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
index 6ae388849a3b..fb2b7ef7868e 100644
--- a/drivers/lguest/x86/core.c
+++ b/drivers/lguest/x86/core.c
@@ -69,7 +69,7 @@ static struct lguest_pages *lguest_pages(unsigned int cpu)
69 (SWITCHER_ADDR + SHARED_SWITCHER_PAGES*PAGE_SIZE))[cpu]); 69 (SWITCHER_ADDR + SHARED_SWITCHER_PAGES*PAGE_SIZE))[cpu]);
70} 70}
71 71
72static DEFINE_PER_CPU(struct lg_cpu *, last_cpu); 72static DEFINE_PER_CPU(struct lg_cpu *, lg_last_cpu);
73 73
74/*S:010 74/*S:010
75 * We approach the Switcher. 75 * We approach the Switcher.
@@ -90,8 +90,8 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
90 * meanwhile). If that's not the case, we pretend everything in the 90 * meanwhile). If that's not the case, we pretend everything in the
91 * Guest has changed. 91 * Guest has changed.
92 */ 92 */
93 if (__get_cpu_var(last_cpu) != cpu || cpu->last_pages != pages) { 93 if (__get_cpu_var(lg_last_cpu) != cpu || cpu->last_pages != pages) {
94 __get_cpu_var(last_cpu) = cpu; 94 __get_cpu_var(lg_last_cpu) = cpu;
95 cpu->last_pages = pages; 95 cpu->last_pages = pages;
96 cpu->changed = CHANGED_ALL; 96 cpu->changed = CHANGED_ALL;
97 } 97 }
diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig
index 2158377a1359..acb3a4e404ff 100644
--- a/drivers/md/Kconfig
+++ b/drivers/md/Kconfig
@@ -185,11 +185,10 @@ config MD_MULTIPATH
185 tristate "Multipath I/O support" 185 tristate "Multipath I/O support"
186 depends on BLK_DEV_MD 186 depends on BLK_DEV_MD
187 help 187 help
188 Multipath-IO is the ability of certain devices to address the same 188 MD_MULTIPATH provides a simple multi-path personality for use
189 physical disk over multiple 'IO paths'. The code ensures that such 189 the MD framework. It is not under active development. New
190 paths can be defined and handled at runtime, and ensures that a 190 projects should consider using DM_MULTIPATH which has more
191 transparent failover to the backup path(s) happens if a IO errors 191 features and more testing.
192 arrives on the primary path.
193 192
194 If unsure, say N. 193 If unsure, say N.
195 194
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 60e2b322db11..26ac8aad0b19 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -212,7 +212,7 @@ static void bitmap_checkfree(struct bitmap *bitmap, unsigned long page)
212 */ 212 */
213 213
214/* IO operations when bitmap is stored near all superblocks */ 214/* IO operations when bitmap is stored near all superblocks */
215static struct page *read_sb_page(mddev_t *mddev, long offset, 215static struct page *read_sb_page(mddev_t *mddev, loff_t offset,
216 struct page *page, 216 struct page *page,
217 unsigned long index, int size) 217 unsigned long index, int size)
218{ 218{
@@ -287,27 +287,36 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
287 287
288 while ((rdev = next_active_rdev(rdev, mddev)) != NULL) { 288 while ((rdev = next_active_rdev(rdev, mddev)) != NULL) {
289 int size = PAGE_SIZE; 289 int size = PAGE_SIZE;
290 loff_t offset = mddev->bitmap_info.offset;
290 if (page->index == bitmap->file_pages-1) 291 if (page->index == bitmap->file_pages-1)
291 size = roundup(bitmap->last_page_size, 292 size = roundup(bitmap->last_page_size,
292 bdev_logical_block_size(rdev->bdev)); 293 bdev_logical_block_size(rdev->bdev));
293 /* Just make sure we aren't corrupting data or 294 /* Just make sure we aren't corrupting data or
294 * metadata 295 * metadata
295 */ 296 */
296 if (bitmap->offset < 0) { 297 if (mddev->external) {
298 /* Bitmap could be anywhere. */
299 if (rdev->sb_start + offset + (page->index *(PAGE_SIZE/512)) >
300 rdev->data_offset &&
301 rdev->sb_start + offset <
302 rdev->data_offset + mddev->dev_sectors +
303 (PAGE_SIZE/512))
304 goto bad_alignment;
305 } else if (offset < 0) {
297 /* DATA BITMAP METADATA */ 306 /* DATA BITMAP METADATA */
298 if (bitmap->offset 307 if (offset
299 + (long)(page->index * (PAGE_SIZE/512)) 308 + (long)(page->index * (PAGE_SIZE/512))
300 + size/512 > 0) 309 + size/512 > 0)
301 /* bitmap runs in to metadata */ 310 /* bitmap runs in to metadata */
302 goto bad_alignment; 311 goto bad_alignment;
303 if (rdev->data_offset + mddev->dev_sectors 312 if (rdev->data_offset + mddev->dev_sectors
304 > rdev->sb_start + bitmap->offset) 313 > rdev->sb_start + offset)
305 /* data runs in to bitmap */ 314 /* data runs in to bitmap */
306 goto bad_alignment; 315 goto bad_alignment;
307 } else if (rdev->sb_start < rdev->data_offset) { 316 } else if (rdev->sb_start < rdev->data_offset) {
308 /* METADATA BITMAP DATA */ 317 /* METADATA BITMAP DATA */
309 if (rdev->sb_start 318 if (rdev->sb_start
310 + bitmap->offset 319 + offset
311 + page->index*(PAGE_SIZE/512) + size/512 320 + page->index*(PAGE_SIZE/512) + size/512
312 > rdev->data_offset) 321 > rdev->data_offset)
313 /* bitmap runs in to data */ 322 /* bitmap runs in to data */
@@ -316,7 +325,7 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
316 /* DATA METADATA BITMAP - no problems */ 325 /* DATA METADATA BITMAP - no problems */
317 } 326 }
318 md_super_write(mddev, rdev, 327 md_super_write(mddev, rdev,
319 rdev->sb_start + bitmap->offset 328 rdev->sb_start + offset
320 + page->index * (PAGE_SIZE/512), 329 + page->index * (PAGE_SIZE/512),
321 size, 330 size,
322 page); 331 page);
@@ -488,6 +497,8 @@ void bitmap_update_sb(struct bitmap *bitmap)
488 497
489 if (!bitmap || !bitmap->mddev) /* no bitmap for this array */ 498 if (!bitmap || !bitmap->mddev) /* no bitmap for this array */
490 return; 499 return;
500 if (bitmap->mddev->bitmap_info.external)
501 return;
491 spin_lock_irqsave(&bitmap->lock, flags); 502 spin_lock_irqsave(&bitmap->lock, flags);
492 if (!bitmap->sb_page) { /* no superblock */ 503 if (!bitmap->sb_page) { /* no superblock */
493 spin_unlock_irqrestore(&bitmap->lock, flags); 504 spin_unlock_irqrestore(&bitmap->lock, flags);
@@ -501,6 +512,9 @@ void bitmap_update_sb(struct bitmap *bitmap)
501 bitmap->events_cleared = bitmap->mddev->events; 512 bitmap->events_cleared = bitmap->mddev->events;
502 sb->events_cleared = cpu_to_le64(bitmap->events_cleared); 513 sb->events_cleared = cpu_to_le64(bitmap->events_cleared);
503 } 514 }
515 /* Just in case these have been changed via sysfs: */
516 sb->daemon_sleep = cpu_to_le32(bitmap->mddev->bitmap_info.daemon_sleep/HZ);
517 sb->write_behind = cpu_to_le32(bitmap->mddev->bitmap_info.max_write_behind);
504 kunmap_atomic(sb, KM_USER0); 518 kunmap_atomic(sb, KM_USER0);
505 write_page(bitmap, bitmap->sb_page, 1); 519 write_page(bitmap, bitmap->sb_page, 1);
506} 520}
@@ -550,7 +564,8 @@ static int bitmap_read_sb(struct bitmap *bitmap)
550 564
551 bitmap->sb_page = read_page(bitmap->file, 0, bitmap, bytes); 565 bitmap->sb_page = read_page(bitmap->file, 0, bitmap, bytes);
552 } else { 566 } else {
553 bitmap->sb_page = read_sb_page(bitmap->mddev, bitmap->offset, 567 bitmap->sb_page = read_sb_page(bitmap->mddev,
568 bitmap->mddev->bitmap_info.offset,
554 NULL, 569 NULL,
555 0, sizeof(bitmap_super_t)); 570 0, sizeof(bitmap_super_t));
556 } 571 }
@@ -563,7 +578,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
563 sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0); 578 sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
564 579
565 chunksize = le32_to_cpu(sb->chunksize); 580 chunksize = le32_to_cpu(sb->chunksize);
566 daemon_sleep = le32_to_cpu(sb->daemon_sleep); 581 daemon_sleep = le32_to_cpu(sb->daemon_sleep) * HZ;
567 write_behind = le32_to_cpu(sb->write_behind); 582 write_behind = le32_to_cpu(sb->write_behind);
568 583
569 /* verify that the bitmap-specific fields are valid */ 584 /* verify that the bitmap-specific fields are valid */
@@ -576,7 +591,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
576 reason = "bitmap chunksize too small"; 591 reason = "bitmap chunksize too small";
577 else if ((1 << ffz(~chunksize)) != chunksize) 592 else if ((1 << ffz(~chunksize)) != chunksize)
578 reason = "bitmap chunksize not a power of 2"; 593 reason = "bitmap chunksize not a power of 2";
579 else if (daemon_sleep < 1 || daemon_sleep > MAX_SCHEDULE_TIMEOUT / HZ) 594 else if (daemon_sleep < 1 || daemon_sleep > MAX_SCHEDULE_TIMEOUT)
580 reason = "daemon sleep period out of range"; 595 reason = "daemon sleep period out of range";
581 else if (write_behind > COUNTER_MAX) 596 else if (write_behind > COUNTER_MAX)
582 reason = "write-behind limit out of range (0 - 16383)"; 597 reason = "write-behind limit out of range (0 - 16383)";
@@ -610,10 +625,9 @@ static int bitmap_read_sb(struct bitmap *bitmap)
610 } 625 }
611success: 626success:
612 /* assign fields using values from superblock */ 627 /* assign fields using values from superblock */
613 bitmap->chunksize = chunksize; 628 bitmap->mddev->bitmap_info.chunksize = chunksize;
614 bitmap->daemon_sleep = daemon_sleep; 629 bitmap->mddev->bitmap_info.daemon_sleep = daemon_sleep;
615 bitmap->daemon_lastrun = jiffies; 630 bitmap->mddev->bitmap_info.max_write_behind = write_behind;
616 bitmap->max_write_behind = write_behind;
617 bitmap->flags |= le32_to_cpu(sb->state); 631 bitmap->flags |= le32_to_cpu(sb->state);
618 if (le32_to_cpu(sb->version) == BITMAP_MAJOR_HOSTENDIAN) 632 if (le32_to_cpu(sb->version) == BITMAP_MAJOR_HOSTENDIAN)
619 bitmap->flags |= BITMAP_HOSTENDIAN; 633 bitmap->flags |= BITMAP_HOSTENDIAN;
@@ -664,16 +678,26 @@ static int bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits,
664 * general bitmap file operations 678 * general bitmap file operations
665 */ 679 */
666 680
681/*
682 * on-disk bitmap:
683 *
684 * Use one bit per "chunk" (block set). We do the disk I/O on the bitmap
685 * file a page at a time. There's a superblock at the start of the file.
686 */
667/* calculate the index of the page that contains this bit */ 687/* calculate the index of the page that contains this bit */
668static inline unsigned long file_page_index(unsigned long chunk) 688static inline unsigned long file_page_index(struct bitmap *bitmap, unsigned long chunk)
669{ 689{
670 return CHUNK_BIT_OFFSET(chunk) >> PAGE_BIT_SHIFT; 690 if (!bitmap->mddev->bitmap_info.external)
691 chunk += sizeof(bitmap_super_t) << 3;
692 return chunk >> PAGE_BIT_SHIFT;
671} 693}
672 694
673/* calculate the (bit) offset of this bit within a page */ 695/* calculate the (bit) offset of this bit within a page */
674static inline unsigned long file_page_offset(unsigned long chunk) 696static inline unsigned long file_page_offset(struct bitmap *bitmap, unsigned long chunk)
675{ 697{
676 return CHUNK_BIT_OFFSET(chunk) & (PAGE_BITS - 1); 698 if (!bitmap->mddev->bitmap_info.external)
699 chunk += sizeof(bitmap_super_t) << 3;
700 return chunk & (PAGE_BITS - 1);
677} 701}
678 702
679/* 703/*
@@ -686,8 +710,9 @@ static inline unsigned long file_page_offset(unsigned long chunk)
686static inline struct page *filemap_get_page(struct bitmap *bitmap, 710static inline struct page *filemap_get_page(struct bitmap *bitmap,
687 unsigned long chunk) 711 unsigned long chunk)
688{ 712{
689 if (file_page_index(chunk) >= bitmap->file_pages) return NULL; 713 if (file_page_index(bitmap, chunk) >= bitmap->file_pages) return NULL;
690 return bitmap->filemap[file_page_index(chunk) - file_page_index(0)]; 714 return bitmap->filemap[file_page_index(bitmap, chunk)
715 - file_page_index(bitmap, 0)];
691} 716}
692 717
693 718
@@ -710,7 +735,7 @@ static void bitmap_file_unmap(struct bitmap *bitmap)
710 spin_unlock_irqrestore(&bitmap->lock, flags); 735 spin_unlock_irqrestore(&bitmap->lock, flags);
711 736
712 while (pages--) 737 while (pages--)
713 if (map[pages]->index != 0) /* 0 is sb_page, release it below */ 738 if (map[pages] != sb_page) /* 0 is sb_page, release it below */
714 free_buffers(map[pages]); 739 free_buffers(map[pages]);
715 kfree(map); 740 kfree(map);
716 kfree(attr); 741 kfree(attr);
@@ -821,7 +846,7 @@ static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block)
821 846
822 page = filemap_get_page(bitmap, chunk); 847 page = filemap_get_page(bitmap, chunk);
823 if (!page) return; 848 if (!page) return;
824 bit = file_page_offset(chunk); 849 bit = file_page_offset(bitmap, chunk);
825 850
826 /* set the bit */ 851 /* set the bit */
827 kaddr = kmap_atomic(page, KM_USER0); 852 kaddr = kmap_atomic(page, KM_USER0);
@@ -907,7 +932,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
907 chunks = bitmap->chunks; 932 chunks = bitmap->chunks;
908 file = bitmap->file; 933 file = bitmap->file;
909 934
910 BUG_ON(!file && !bitmap->offset); 935 BUG_ON(!file && !bitmap->mddev->bitmap_info.offset);
911 936
912#ifdef INJECT_FAULTS_3 937#ifdef INJECT_FAULTS_3
913 outofdate = 1; 938 outofdate = 1;
@@ -919,14 +944,17 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
919 "recovery\n", bmname(bitmap)); 944 "recovery\n", bmname(bitmap));
920 945
921 bytes = (chunks + 7) / 8; 946 bytes = (chunks + 7) / 8;
947 if (!bitmap->mddev->bitmap_info.external)
948 bytes += sizeof(bitmap_super_t);
922 949
923 num_pages = (bytes + sizeof(bitmap_super_t) + PAGE_SIZE - 1) / PAGE_SIZE; 950
951 num_pages = (bytes + PAGE_SIZE - 1) / PAGE_SIZE;
924 952
925 if (file && i_size_read(file->f_mapping->host) < bytes + sizeof(bitmap_super_t)) { 953 if (file && i_size_read(file->f_mapping->host) < bytes) {
926 printk(KERN_INFO "%s: bitmap file too short %lu < %lu\n", 954 printk(KERN_INFO "%s: bitmap file too short %lu < %lu\n",
927 bmname(bitmap), 955 bmname(bitmap),
928 (unsigned long) i_size_read(file->f_mapping->host), 956 (unsigned long) i_size_read(file->f_mapping->host),
929 bytes + sizeof(bitmap_super_t)); 957 bytes);
930 goto err; 958 goto err;
931 } 959 }
932 960
@@ -947,17 +975,16 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
947 975
948 for (i = 0; i < chunks; i++) { 976 for (i = 0; i < chunks; i++) {
949 int b; 977 int b;
950 index = file_page_index(i); 978 index = file_page_index(bitmap, i);
951 bit = file_page_offset(i); 979 bit = file_page_offset(bitmap, i);
952 if (index != oldindex) { /* this is a new page, read it in */ 980 if (index != oldindex) { /* this is a new page, read it in */
953 int count; 981 int count;
954 /* unmap the old page, we're done with it */ 982 /* unmap the old page, we're done with it */
955 if (index == num_pages-1) 983 if (index == num_pages-1)
956 count = bytes + sizeof(bitmap_super_t) 984 count = bytes - index * PAGE_SIZE;
957 - index * PAGE_SIZE;
958 else 985 else
959 count = PAGE_SIZE; 986 count = PAGE_SIZE;
960 if (index == 0) { 987 if (index == 0 && bitmap->sb_page) {
961 /* 988 /*
962 * if we're here then the superblock page 989 * if we're here then the superblock page
963 * contains some bits (PAGE_SIZE != sizeof sb) 990 * contains some bits (PAGE_SIZE != sizeof sb)
@@ -967,14 +994,15 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
967 offset = sizeof(bitmap_super_t); 994 offset = sizeof(bitmap_super_t);
968 if (!file) 995 if (!file)
969 read_sb_page(bitmap->mddev, 996 read_sb_page(bitmap->mddev,
970 bitmap->offset, 997 bitmap->mddev->bitmap_info.offset,
971 page, 998 page,
972 index, count); 999 index, count);
973 } else if (file) { 1000 } else if (file) {
974 page = read_page(file, index, bitmap, count); 1001 page = read_page(file, index, bitmap, count);
975 offset = 0; 1002 offset = 0;
976 } else { 1003 } else {
977 page = read_sb_page(bitmap->mddev, bitmap->offset, 1004 page = read_sb_page(bitmap->mddev,
1005 bitmap->mddev->bitmap_info.offset,
978 NULL, 1006 NULL,
979 index, count); 1007 index, count);
980 offset = 0; 1008 offset = 0;
@@ -1078,23 +1106,32 @@ static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap,
1078 * out to disk 1106 * out to disk
1079 */ 1107 */
1080 1108
1081void bitmap_daemon_work(struct bitmap *bitmap) 1109void bitmap_daemon_work(mddev_t *mddev)
1082{ 1110{
1111 struct bitmap *bitmap;
1083 unsigned long j; 1112 unsigned long j;
1084 unsigned long flags; 1113 unsigned long flags;
1085 struct page *page = NULL, *lastpage = NULL; 1114 struct page *page = NULL, *lastpage = NULL;
1086 int blocks; 1115 int blocks;
1087 void *paddr; 1116 void *paddr;
1088 1117
1089 if (bitmap == NULL) 1118 /* Use a mutex to guard daemon_work against
1119 * bitmap_destroy.
1120 */
1121 mutex_lock(&mddev->bitmap_info.mutex);
1122 bitmap = mddev->bitmap;
1123 if (bitmap == NULL) {
1124 mutex_unlock(&mddev->bitmap_info.mutex);
1090 return; 1125 return;
1091 if (time_before(jiffies, bitmap->daemon_lastrun + bitmap->daemon_sleep*HZ)) 1126 }
1127 if (time_before(jiffies, bitmap->daemon_lastrun
1128 + bitmap->mddev->bitmap_info.daemon_sleep))
1092 goto done; 1129 goto done;
1093 1130
1094 bitmap->daemon_lastrun = jiffies; 1131 bitmap->daemon_lastrun = jiffies;
1095 if (bitmap->allclean) { 1132 if (bitmap->allclean) {
1096 bitmap->mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT; 1133 bitmap->mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT;
1097 return; 1134 goto done;
1098 } 1135 }
1099 bitmap->allclean = 1; 1136 bitmap->allclean = 1;
1100 1137
@@ -1142,7 +1179,8 @@ void bitmap_daemon_work(struct bitmap *bitmap)
1142 /* We are possibly going to clear some bits, so make 1179 /* We are possibly going to clear some bits, so make
1143 * sure that events_cleared is up-to-date. 1180 * sure that events_cleared is up-to-date.
1144 */ 1181 */
1145 if (bitmap->need_sync) { 1182 if (bitmap->need_sync &&
1183 bitmap->mddev->bitmap_info.external == 0) {
1146 bitmap_super_t *sb; 1184 bitmap_super_t *sb;
1147 bitmap->need_sync = 0; 1185 bitmap->need_sync = 0;
1148 sb = kmap_atomic(bitmap->sb_page, KM_USER0); 1186 sb = kmap_atomic(bitmap->sb_page, KM_USER0);
@@ -1152,7 +1190,8 @@ void bitmap_daemon_work(struct bitmap *bitmap)
1152 write_page(bitmap, bitmap->sb_page, 1); 1190 write_page(bitmap, bitmap->sb_page, 1);
1153 } 1191 }
1154 spin_lock_irqsave(&bitmap->lock, flags); 1192 spin_lock_irqsave(&bitmap->lock, flags);
1155 clear_page_attr(bitmap, page, BITMAP_PAGE_CLEAN); 1193 if (!bitmap->need_sync)
1194 clear_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
1156 } 1195 }
1157 bmc = bitmap_get_counter(bitmap, 1196 bmc = bitmap_get_counter(bitmap,
1158 (sector_t)j << CHUNK_BLOCK_SHIFT(bitmap), 1197 (sector_t)j << CHUNK_BLOCK_SHIFT(bitmap),
@@ -1167,7 +1206,7 @@ void bitmap_daemon_work(struct bitmap *bitmap)
1167 if (*bmc == 2) { 1206 if (*bmc == 2) {
1168 *bmc=1; /* maybe clear the bit next time */ 1207 *bmc=1; /* maybe clear the bit next time */
1169 set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN); 1208 set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
1170 } else if (*bmc == 1) { 1209 } else if (*bmc == 1 && !bitmap->need_sync) {
1171 /* we can clear the bit */ 1210 /* we can clear the bit */
1172 *bmc = 0; 1211 *bmc = 0;
1173 bitmap_count_page(bitmap, 1212 bitmap_count_page(bitmap,
@@ -1177,9 +1216,11 @@ void bitmap_daemon_work(struct bitmap *bitmap)
1177 /* clear the bit */ 1216 /* clear the bit */
1178 paddr = kmap_atomic(page, KM_USER0); 1217 paddr = kmap_atomic(page, KM_USER0);
1179 if (bitmap->flags & BITMAP_HOSTENDIAN) 1218 if (bitmap->flags & BITMAP_HOSTENDIAN)
1180 clear_bit(file_page_offset(j), paddr); 1219 clear_bit(file_page_offset(bitmap, j),
1220 paddr);
1181 else 1221 else
1182 ext2_clear_bit(file_page_offset(j), paddr); 1222 ext2_clear_bit(file_page_offset(bitmap, j),
1223 paddr);
1183 kunmap_atomic(paddr, KM_USER0); 1224 kunmap_atomic(paddr, KM_USER0);
1184 } 1225 }
1185 } else 1226 } else
@@ -1202,7 +1243,9 @@ void bitmap_daemon_work(struct bitmap *bitmap)
1202 1243
1203 done: 1244 done:
1204 if (bitmap->allclean == 0) 1245 if (bitmap->allclean == 0)
1205 bitmap->mddev->thread->timeout = bitmap->daemon_sleep * HZ; 1246 bitmap->mddev->thread->timeout =
1247 bitmap->mddev->bitmap_info.daemon_sleep;
1248 mutex_unlock(&mddev->bitmap_info.mutex);
1206} 1249}
1207 1250
1208static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap, 1251static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap,
@@ -1332,6 +1375,7 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
1332 bitmap->events_cleared < bitmap->mddev->events) { 1375 bitmap->events_cleared < bitmap->mddev->events) {
1333 bitmap->events_cleared = bitmap->mddev->events; 1376 bitmap->events_cleared = bitmap->mddev->events;
1334 bitmap->need_sync = 1; 1377 bitmap->need_sync = 1;
1378 sysfs_notify_dirent(bitmap->sysfs_can_clear);
1335 } 1379 }
1336 1380
1337 if (!success && ! (*bmc & NEEDED_MASK)) 1381 if (!success && ! (*bmc & NEEDED_MASK))
@@ -1470,7 +1514,7 @@ void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector)
1470 return; 1514 return;
1471 } 1515 }
1472 if (time_before(jiffies, (bitmap->last_end_sync 1516 if (time_before(jiffies, (bitmap->last_end_sync
1473 + bitmap->daemon_sleep * HZ))) 1517 + bitmap->mddev->bitmap_info.daemon_sleep)))
1474 return; 1518 return;
1475 wait_event(bitmap->mddev->recovery_wait, 1519 wait_event(bitmap->mddev->recovery_wait,
1476 atomic_read(&bitmap->mddev->recovery_active) == 0); 1520 atomic_read(&bitmap->mddev->recovery_active) == 0);
@@ -1522,6 +1566,12 @@ void bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e)
1522 sector_t sec = (sector_t)chunk << CHUNK_BLOCK_SHIFT(bitmap); 1566 sector_t sec = (sector_t)chunk << CHUNK_BLOCK_SHIFT(bitmap);
1523 bitmap_set_memory_bits(bitmap, sec, 1); 1567 bitmap_set_memory_bits(bitmap, sec, 1);
1524 bitmap_file_set_bit(bitmap, sec); 1568 bitmap_file_set_bit(bitmap, sec);
1569 if (sec < bitmap->mddev->recovery_cp)
1570 /* We are asserting that the array is dirty,
1571 * so move the recovery_cp address back so
1572 * that it is obvious that it is dirty
1573 */
1574 bitmap->mddev->recovery_cp = sec;
1525 } 1575 }
1526} 1576}
1527 1577
@@ -1531,7 +1581,7 @@ void bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e)
1531void bitmap_flush(mddev_t *mddev) 1581void bitmap_flush(mddev_t *mddev)
1532{ 1582{
1533 struct bitmap *bitmap = mddev->bitmap; 1583 struct bitmap *bitmap = mddev->bitmap;
1534 int sleep; 1584 long sleep;
1535 1585
1536 if (!bitmap) /* there was no bitmap */ 1586 if (!bitmap) /* there was no bitmap */
1537 return; 1587 return;
@@ -1539,12 +1589,13 @@ void bitmap_flush(mddev_t *mddev)
1539 /* run the daemon_work three time to ensure everything is flushed 1589 /* run the daemon_work three time to ensure everything is flushed
1540 * that can be 1590 * that can be
1541 */ 1591 */
1542 sleep = bitmap->daemon_sleep; 1592 sleep = mddev->bitmap_info.daemon_sleep * 2;
1543 bitmap->daemon_sleep = 0; 1593 bitmap->daemon_lastrun -= sleep;
1544 bitmap_daemon_work(bitmap); 1594 bitmap_daemon_work(mddev);
1545 bitmap_daemon_work(bitmap); 1595 bitmap->daemon_lastrun -= sleep;
1546 bitmap_daemon_work(bitmap); 1596 bitmap_daemon_work(mddev);
1547 bitmap->daemon_sleep = sleep; 1597 bitmap->daemon_lastrun -= sleep;
1598 bitmap_daemon_work(mddev);
1548 bitmap_update_sb(bitmap); 1599 bitmap_update_sb(bitmap);
1549} 1600}
1550 1601
@@ -1574,6 +1625,7 @@ static void bitmap_free(struct bitmap *bitmap)
1574 kfree(bp); 1625 kfree(bp);
1575 kfree(bitmap); 1626 kfree(bitmap);
1576} 1627}
1628
1577void bitmap_destroy(mddev_t *mddev) 1629void bitmap_destroy(mddev_t *mddev)
1578{ 1630{
1579 struct bitmap *bitmap = mddev->bitmap; 1631 struct bitmap *bitmap = mddev->bitmap;
@@ -1581,10 +1633,15 @@ void bitmap_destroy(mddev_t *mddev)
1581 if (!bitmap) /* there was no bitmap */ 1633 if (!bitmap) /* there was no bitmap */
1582 return; 1634 return;
1583 1635
1636 mutex_lock(&mddev->bitmap_info.mutex);
1584 mddev->bitmap = NULL; /* disconnect from the md device */ 1637 mddev->bitmap = NULL; /* disconnect from the md device */
1638 mutex_unlock(&mddev->bitmap_info.mutex);
1585 if (mddev->thread) 1639 if (mddev->thread)
1586 mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT; 1640 mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT;
1587 1641
1642 if (bitmap->sysfs_can_clear)
1643 sysfs_put(bitmap->sysfs_can_clear);
1644
1588 bitmap_free(bitmap); 1645 bitmap_free(bitmap);
1589} 1646}
1590 1647
@@ -1598,16 +1655,17 @@ int bitmap_create(mddev_t *mddev)
1598 sector_t blocks = mddev->resync_max_sectors; 1655 sector_t blocks = mddev->resync_max_sectors;
1599 unsigned long chunks; 1656 unsigned long chunks;
1600 unsigned long pages; 1657 unsigned long pages;
1601 struct file *file = mddev->bitmap_file; 1658 struct file *file = mddev->bitmap_info.file;
1602 int err; 1659 int err;
1603 sector_t start; 1660 sector_t start;
1661 struct sysfs_dirent *bm;
1604 1662
1605 BUILD_BUG_ON(sizeof(bitmap_super_t) != 256); 1663 BUILD_BUG_ON(sizeof(bitmap_super_t) != 256);
1606 1664
1607 if (!file && !mddev->bitmap_offset) /* bitmap disabled, nothing to do */ 1665 if (!file && !mddev->bitmap_info.offset) /* bitmap disabled, nothing to do */
1608 return 0; 1666 return 0;
1609 1667
1610 BUG_ON(file && mddev->bitmap_offset); 1668 BUG_ON(file && mddev->bitmap_info.offset);
1611 1669
1612 bitmap = kzalloc(sizeof(*bitmap), GFP_KERNEL); 1670 bitmap = kzalloc(sizeof(*bitmap), GFP_KERNEL);
1613 if (!bitmap) 1671 if (!bitmap)
@@ -1620,8 +1678,14 @@ int bitmap_create(mddev_t *mddev)
1620 1678
1621 bitmap->mddev = mddev; 1679 bitmap->mddev = mddev;
1622 1680
1681 bm = sysfs_get_dirent(mddev->kobj.sd, "bitmap");
1682 if (bm) {
1683 bitmap->sysfs_can_clear = sysfs_get_dirent(bm, "can_clear");
1684 sysfs_put(bm);
1685 } else
1686 bitmap->sysfs_can_clear = NULL;
1687
1623 bitmap->file = file; 1688 bitmap->file = file;
1624 bitmap->offset = mddev->bitmap_offset;
1625 if (file) { 1689 if (file) {
1626 get_file(file); 1690 get_file(file);
1627 /* As future accesses to this file will use bmap, 1691 /* As future accesses to this file will use bmap,
@@ -1630,12 +1694,22 @@ int bitmap_create(mddev_t *mddev)
1630 */ 1694 */
1631 vfs_fsync(file, file->f_dentry, 1); 1695 vfs_fsync(file, file->f_dentry, 1);
1632 } 1696 }
1633 /* read superblock from bitmap file (this sets bitmap->chunksize) */ 1697 /* read superblock from bitmap file (this sets mddev->bitmap_info.chunksize) */
1634 err = bitmap_read_sb(bitmap); 1698 if (!mddev->bitmap_info.external)
1699 err = bitmap_read_sb(bitmap);
1700 else {
1701 err = 0;
1702 if (mddev->bitmap_info.chunksize == 0 ||
1703 mddev->bitmap_info.daemon_sleep == 0)
1704 /* chunksize and time_base need to be
1705 * set first. */
1706 err = -EINVAL;
1707 }
1635 if (err) 1708 if (err)
1636 goto error; 1709 goto error;
1637 1710
1638 bitmap->chunkshift = ffz(~bitmap->chunksize); 1711 bitmap->daemon_lastrun = jiffies;
1712 bitmap->chunkshift = ffz(~mddev->bitmap_info.chunksize);
1639 1713
1640 /* now that chunksize and chunkshift are set, we can use these macros */ 1714 /* now that chunksize and chunkshift are set, we can use these macros */
1641 chunks = (blocks + CHUNK_BLOCK_RATIO(bitmap) - 1) >> 1715 chunks = (blocks + CHUNK_BLOCK_RATIO(bitmap) - 1) >>
@@ -1677,7 +1751,8 @@ int bitmap_create(mddev_t *mddev)
1677 1751
1678 mddev->bitmap = bitmap; 1752 mddev->bitmap = bitmap;
1679 1753
1680 mddev->thread->timeout = bitmap->daemon_sleep * HZ; 1754 mddev->thread->timeout = mddev->bitmap_info.daemon_sleep;
1755 md_wakeup_thread(mddev->thread);
1681 1756
1682 bitmap_update_sb(bitmap); 1757 bitmap_update_sb(bitmap);
1683 1758
@@ -1688,6 +1763,264 @@ int bitmap_create(mddev_t *mddev)
1688 return err; 1763 return err;
1689} 1764}
1690 1765
1766static ssize_t
1767location_show(mddev_t *mddev, char *page)
1768{
1769 ssize_t len;
1770 if (mddev->bitmap_info.file) {
1771 len = sprintf(page, "file");
1772 } else if (mddev->bitmap_info.offset) {
1773 len = sprintf(page, "%+lld", (long long)mddev->bitmap_info.offset);
1774 } else
1775 len = sprintf(page, "none");
1776 len += sprintf(page+len, "\n");
1777 return len;
1778}
1779
1780static ssize_t
1781location_store(mddev_t *mddev, const char *buf, size_t len)
1782{
1783
1784 if (mddev->pers) {
1785 if (!mddev->pers->quiesce)
1786 return -EBUSY;
1787 if (mddev->recovery || mddev->sync_thread)
1788 return -EBUSY;
1789 }
1790
1791 if (mddev->bitmap || mddev->bitmap_info.file ||
1792 mddev->bitmap_info.offset) {
1793 /* bitmap already configured. Only option is to clear it */
1794 if (strncmp(buf, "none", 4) != 0)
1795 return -EBUSY;
1796 if (mddev->pers) {
1797 mddev->pers->quiesce(mddev, 1);
1798 bitmap_destroy(mddev);
1799 mddev->pers->quiesce(mddev, 0);
1800 }
1801 mddev->bitmap_info.offset = 0;
1802 if (mddev->bitmap_info.file) {
1803 struct file *f = mddev->bitmap_info.file;
1804 mddev->bitmap_info.file = NULL;
1805 restore_bitmap_write_access(f);
1806 fput(f);
1807 }
1808 } else {
1809 /* No bitmap, OK to set a location */
1810 long long offset;
1811 if (strncmp(buf, "none", 4) == 0)
1812 /* nothing to be done */;
1813 else if (strncmp(buf, "file:", 5) == 0) {
1814 /* Not supported yet */
1815 return -EINVAL;
1816 } else {
1817 int rv;
1818 if (buf[0] == '+')
1819 rv = strict_strtoll(buf+1, 10, &offset);
1820 else
1821 rv = strict_strtoll(buf, 10, &offset);
1822 if (rv)
1823 return rv;
1824 if (offset == 0)
1825 return -EINVAL;
1826 if (mddev->bitmap_info.external == 0 &&
1827 mddev->major_version == 0 &&
1828 offset != mddev->bitmap_info.default_offset)
1829 return -EINVAL;
1830 mddev->bitmap_info.offset = offset;
1831 if (mddev->pers) {
1832 mddev->pers->quiesce(mddev, 1);
1833 rv = bitmap_create(mddev);
1834 if (rv) {
1835 bitmap_destroy(mddev);
1836 mddev->bitmap_info.offset = 0;
1837 }
1838 mddev->pers->quiesce(mddev, 0);
1839 if (rv)
1840 return rv;
1841 }
1842 }
1843 }
1844 if (!mddev->external) {
1845 /* Ensure new bitmap info is stored in
1846 * metadata promptly.
1847 */
1848 set_bit(MD_CHANGE_DEVS, &mddev->flags);
1849 md_wakeup_thread(mddev->thread);
1850 }
1851 return len;
1852}
1853
1854static struct md_sysfs_entry bitmap_location =
1855__ATTR(location, S_IRUGO|S_IWUSR, location_show, location_store);
1856
1857static ssize_t
1858timeout_show(mddev_t *mddev, char *page)
1859{
1860 ssize_t len;
1861 unsigned long secs = mddev->bitmap_info.daemon_sleep / HZ;
1862 unsigned long jifs = mddev->bitmap_info.daemon_sleep % HZ;
1863
1864 len = sprintf(page, "%lu", secs);
1865 if (jifs)
1866 len += sprintf(page+len, ".%03u", jiffies_to_msecs(jifs));
1867 len += sprintf(page+len, "\n");
1868 return len;
1869}
1870
1871static ssize_t
1872timeout_store(mddev_t *mddev, const char *buf, size_t len)
1873{
1874 /* timeout can be set at any time */
1875 unsigned long timeout;
1876 int rv = strict_strtoul_scaled(buf, &timeout, 4);
1877 if (rv)
1878 return rv;
1879
1880 /* just to make sure we don't overflow... */
1881 if (timeout >= LONG_MAX / HZ)
1882 return -EINVAL;
1883
1884 timeout = timeout * HZ / 10000;
1885
1886 if (timeout >= MAX_SCHEDULE_TIMEOUT)
1887 timeout = MAX_SCHEDULE_TIMEOUT-1;
1888 if (timeout < 1)
1889 timeout = 1;
1890 mddev->bitmap_info.daemon_sleep = timeout;
1891 if (mddev->thread) {
1892 /* if thread->timeout is MAX_SCHEDULE_TIMEOUT, then
1893 * the bitmap is all clean and we don't need to
1894 * adjust the timeout right now
1895 */
1896 if (mddev->thread->timeout < MAX_SCHEDULE_TIMEOUT) {
1897 mddev->thread->timeout = timeout;
1898 md_wakeup_thread(mddev->thread);
1899 }
1900 }
1901 return len;
1902}
1903
1904static struct md_sysfs_entry bitmap_timeout =
1905__ATTR(time_base, S_IRUGO|S_IWUSR, timeout_show, timeout_store);
1906
1907static ssize_t
1908backlog_show(mddev_t *mddev, char *page)
1909{
1910 return sprintf(page, "%lu\n", mddev->bitmap_info.max_write_behind);
1911}
1912
1913static ssize_t
1914backlog_store(mddev_t *mddev, const char *buf, size_t len)
1915{
1916 unsigned long backlog;
1917 int rv = strict_strtoul(buf, 10, &backlog);
1918 if (rv)
1919 return rv;
1920 if (backlog > COUNTER_MAX)
1921 return -EINVAL;
1922 mddev->bitmap_info.max_write_behind = backlog;
1923 return len;
1924}
1925
1926static struct md_sysfs_entry bitmap_backlog =
1927__ATTR(backlog, S_IRUGO|S_IWUSR, backlog_show, backlog_store);
1928
1929static ssize_t
1930chunksize_show(mddev_t *mddev, char *page)
1931{
1932 return sprintf(page, "%lu\n", mddev->bitmap_info.chunksize);
1933}
1934
1935static ssize_t
1936chunksize_store(mddev_t *mddev, const char *buf, size_t len)
1937{
1938 /* Can only be changed when no bitmap is active */
1939 int rv;
1940 unsigned long csize;
1941 if (mddev->bitmap)
1942 return -EBUSY;
1943 rv = strict_strtoul(buf, 10, &csize);
1944 if (rv)
1945 return rv;
1946 if (csize < 512 ||
1947 !is_power_of_2(csize))
1948 return -EINVAL;
1949 mddev->bitmap_info.chunksize = csize;
1950 return len;
1951}
1952
1953static struct md_sysfs_entry bitmap_chunksize =
1954__ATTR(chunksize, S_IRUGO|S_IWUSR, chunksize_show, chunksize_store);
1955
1956static ssize_t metadata_show(mddev_t *mddev, char *page)
1957{
1958 return sprintf(page, "%s\n", (mddev->bitmap_info.external
1959 ? "external" : "internal"));
1960}
1961
1962static ssize_t metadata_store(mddev_t *mddev, const char *buf, size_t len)
1963{
1964 if (mddev->bitmap ||
1965 mddev->bitmap_info.file ||
1966 mddev->bitmap_info.offset)
1967 return -EBUSY;
1968 if (strncmp(buf, "external", 8) == 0)
1969 mddev->bitmap_info.external = 1;
1970 else if (strncmp(buf, "internal", 8) == 0)
1971 mddev->bitmap_info.external = 0;
1972 else
1973 return -EINVAL;
1974 return len;
1975}
1976
1977static struct md_sysfs_entry bitmap_metadata =
1978__ATTR(metadata, S_IRUGO|S_IWUSR, metadata_show, metadata_store);
1979
1980static ssize_t can_clear_show(mddev_t *mddev, char *page)
1981{
1982 int len;
1983 if (mddev->bitmap)
1984 len = sprintf(page, "%s\n", (mddev->bitmap->need_sync ?
1985 "false" : "true"));
1986 else
1987 len = sprintf(page, "\n");
1988 return len;
1989}
1990
1991static ssize_t can_clear_store(mddev_t *mddev, const char *buf, size_t len)
1992{
1993 if (mddev->bitmap == NULL)
1994 return -ENOENT;
1995 if (strncmp(buf, "false", 5) == 0)
1996 mddev->bitmap->need_sync = 1;
1997 else if (strncmp(buf, "true", 4) == 0) {
1998 if (mddev->degraded)
1999 return -EBUSY;
2000 mddev->bitmap->need_sync = 0;
2001 } else
2002 return -EINVAL;
2003 return len;
2004}
2005
2006static struct md_sysfs_entry bitmap_can_clear =
2007__ATTR(can_clear, S_IRUGO|S_IWUSR, can_clear_show, can_clear_store);
2008
2009static struct attribute *md_bitmap_attrs[] = {
2010 &bitmap_location.attr,
2011 &bitmap_timeout.attr,
2012 &bitmap_backlog.attr,
2013 &bitmap_chunksize.attr,
2014 &bitmap_metadata.attr,
2015 &bitmap_can_clear.attr,
2016 NULL
2017};
2018struct attribute_group md_bitmap_group = {
2019 .name = "bitmap",
2020 .attrs = md_bitmap_attrs,
2021};
2022
2023
1691/* the bitmap API -- for raid personalities */ 2024/* the bitmap API -- for raid personalities */
1692EXPORT_SYMBOL(bitmap_startwrite); 2025EXPORT_SYMBOL(bitmap_startwrite);
1693EXPORT_SYMBOL(bitmap_endwrite); 2026EXPORT_SYMBOL(bitmap_endwrite);
diff --git a/drivers/md/bitmap.h b/drivers/md/bitmap.h
index e98900671ca9..cb821d76d1b4 100644
--- a/drivers/md/bitmap.h
+++ b/drivers/md/bitmap.h
@@ -106,7 +106,7 @@ typedef __u16 bitmap_counter_t;
106#define BITMAP_BLOCK_SHIFT 9 106#define BITMAP_BLOCK_SHIFT 9
107 107
108/* how many blocks per chunk? (this is variable) */ 108/* how many blocks per chunk? (this is variable) */
109#define CHUNK_BLOCK_RATIO(bitmap) ((bitmap)->chunksize >> BITMAP_BLOCK_SHIFT) 109#define CHUNK_BLOCK_RATIO(bitmap) ((bitmap)->mddev->bitmap_info.chunksize >> BITMAP_BLOCK_SHIFT)
110#define CHUNK_BLOCK_SHIFT(bitmap) ((bitmap)->chunkshift - BITMAP_BLOCK_SHIFT) 110#define CHUNK_BLOCK_SHIFT(bitmap) ((bitmap)->chunkshift - BITMAP_BLOCK_SHIFT)
111#define CHUNK_BLOCK_MASK(bitmap) (CHUNK_BLOCK_RATIO(bitmap) - 1) 111#define CHUNK_BLOCK_MASK(bitmap) (CHUNK_BLOCK_RATIO(bitmap) - 1)
112 112
@@ -118,16 +118,6 @@ typedef __u16 bitmap_counter_t;
118 (CHUNK_BLOCK_SHIFT(bitmap) + PAGE_COUNTER_SHIFT - 1) 118 (CHUNK_BLOCK_SHIFT(bitmap) + PAGE_COUNTER_SHIFT - 1)
119#define PAGEPTR_BLOCK_MASK(bitmap) (PAGEPTR_BLOCK_RATIO(bitmap) - 1) 119#define PAGEPTR_BLOCK_MASK(bitmap) (PAGEPTR_BLOCK_RATIO(bitmap) - 1)
120 120
121/*
122 * on-disk bitmap:
123 *
124 * Use one bit per "chunk" (block set). We do the disk I/O on the bitmap
125 * file a page at a time. There's a superblock at the start of the file.
126 */
127
128/* map chunks (bits) to file pages - offset by the size of the superblock */
129#define CHUNK_BIT_OFFSET(chunk) ((chunk) + (sizeof(bitmap_super_t) << 3))
130
131#endif 121#endif
132 122
133/* 123/*
@@ -209,7 +199,6 @@ struct bitmap {
209 int counter_bits; /* how many bits per block counter */ 199 int counter_bits; /* how many bits per block counter */
210 200
211 /* bitmap chunksize -- how much data does each bit represent? */ 201 /* bitmap chunksize -- how much data does each bit represent? */
212 unsigned long chunksize;
213 unsigned long chunkshift; /* chunksize = 2^chunkshift (for bitops) */ 202 unsigned long chunkshift; /* chunksize = 2^chunkshift (for bitops) */
214 unsigned long chunks; /* total number of data chunks for the array */ 203 unsigned long chunks; /* total number of data chunks for the array */
215 204
@@ -226,7 +215,6 @@ struct bitmap {
226 /* bitmap spinlock */ 215 /* bitmap spinlock */
227 spinlock_t lock; 216 spinlock_t lock;
228 217
229 long offset; /* offset from superblock if file is NULL */
230 struct file *file; /* backing disk file */ 218 struct file *file; /* backing disk file */
231 struct page *sb_page; /* cached copy of the bitmap file superblock */ 219 struct page *sb_page; /* cached copy of the bitmap file superblock */
232 struct page **filemap; /* list of cache pages for the file */ 220 struct page **filemap; /* list of cache pages for the file */
@@ -238,7 +226,6 @@ struct bitmap {
238 226
239 int allclean; 227 int allclean;
240 228
241 unsigned long max_write_behind; /* write-behind mode */
242 atomic_t behind_writes; 229 atomic_t behind_writes;
243 230
244 /* 231 /*
@@ -246,7 +233,6 @@ struct bitmap {
246 * file, cleaning up bits and flushing out pages to disk as necessary 233 * file, cleaning up bits and flushing out pages to disk as necessary
247 */ 234 */
248 unsigned long daemon_lastrun; /* jiffies of last run */ 235 unsigned long daemon_lastrun; /* jiffies of last run */
249 unsigned long daemon_sleep; /* how many seconds between updates? */
250 unsigned long last_end_sync; /* when we lasted called end_sync to 236 unsigned long last_end_sync; /* when we lasted called end_sync to
251 * update bitmap with resync progress */ 237 * update bitmap with resync progress */
252 238
@@ -254,6 +240,7 @@ struct bitmap {
254 wait_queue_head_t write_wait; 240 wait_queue_head_t write_wait;
255 wait_queue_head_t overflow_wait; 241 wait_queue_head_t overflow_wait;
256 242
243 struct sysfs_dirent *sysfs_can_clear;
257}; 244};
258 245
259/* the bitmap API */ 246/* the bitmap API */
@@ -282,7 +269,7 @@ void bitmap_close_sync(struct bitmap *bitmap);
282void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector); 269void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector);
283 270
284void bitmap_unplug(struct bitmap *bitmap); 271void bitmap_unplug(struct bitmap *bitmap);
285void bitmap_daemon_work(struct bitmap *bitmap); 272void bitmap_daemon_work(mddev_t *mddev);
286#endif 273#endif
287 274
288#endif 275#endif
diff --git a/drivers/md/faulty.c b/drivers/md/faulty.c
index 87d88dbb667f..713acd02ab39 100644
--- a/drivers/md/faulty.c
+++ b/drivers/md/faulty.c
@@ -360,6 +360,7 @@ static void raid_exit(void)
360module_init(raid_init); 360module_init(raid_init);
361module_exit(raid_exit); 361module_exit(raid_exit);
362MODULE_LICENSE("GPL"); 362MODULE_LICENSE("GPL");
363MODULE_DESCRIPTION("Fault injection personality for MD");
363MODULE_ALIAS("md-personality-10"); /* faulty */ 364MODULE_ALIAS("md-personality-10"); /* faulty */
364MODULE_ALIAS("md-faulty"); 365MODULE_ALIAS("md-faulty");
365MODULE_ALIAS("md-level--5"); 366MODULE_ALIAS("md-level--5");
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 1ceceb334d5e..00435bd20699 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -292,7 +292,7 @@ static int linear_make_request (struct request_queue *q, struct bio *bio)
292 int cpu; 292 int cpu;
293 293
294 if (unlikely(bio_rw_flagged(bio, BIO_RW_BARRIER))) { 294 if (unlikely(bio_rw_flagged(bio, BIO_RW_BARRIER))) {
295 bio_endio(bio, -EOPNOTSUPP); 295 md_barrier_request(mddev, bio);
296 return 0; 296 return 0;
297 } 297 }
298 298
@@ -383,6 +383,7 @@ static void linear_exit (void)
383module_init(linear_init); 383module_init(linear_init);
384module_exit(linear_exit); 384module_exit(linear_exit);
385MODULE_LICENSE("GPL"); 385MODULE_LICENSE("GPL");
386MODULE_DESCRIPTION("Linear device concatenation personality for MD");
386MODULE_ALIAS("md-personality-1"); /* LINEAR - deprecated*/ 387MODULE_ALIAS("md-personality-1"); /* LINEAR - deprecated*/
387MODULE_ALIAS("md-linear"); 388MODULE_ALIAS("md-linear");
388MODULE_ALIAS("md-level--1"); 389MODULE_ALIAS("md-level--1");
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 5f154ef1e4be..e1f3c1715cca 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -44,6 +44,7 @@
44#include <linux/random.h> 44#include <linux/random.h>
45#include <linux/reboot.h> 45#include <linux/reboot.h>
46#include <linux/file.h> 46#include <linux/file.h>
47#include <linux/compat.h>
47#include <linux/delay.h> 48#include <linux/delay.h>
48#include <linux/raid/md_p.h> 49#include <linux/raid/md_p.h>
49#include <linux/raid/md_u.h> 50#include <linux/raid/md_u.h>
@@ -68,6 +69,12 @@ static DECLARE_WAIT_QUEUE_HEAD(resync_wait);
68#define MD_BUG(x...) { printk("md: bug in file %s, line %d\n", __FILE__, __LINE__); md_print_devices(); } 69#define MD_BUG(x...) { printk("md: bug in file %s, line %d\n", __FILE__, __LINE__); md_print_devices(); }
69 70
70/* 71/*
72 * Default number of read corrections we'll attempt on an rdev
73 * before ejecting it from the array. We divide the read error
74 * count by 2 for every hour elapsed between read errors.
75 */
76#define MD_DEFAULT_MAX_CORRECTED_READ_ERRORS 20
77/*
71 * Current RAID-1,4,5 parallel reconstruction 'guaranteed speed limit' 78 * Current RAID-1,4,5 parallel reconstruction 'guaranteed speed limit'
72 * is 1000 KB/sec, so the extra system load does not show up that much. 79 * is 1000 KB/sec, so the extra system load does not show up that much.
73 * Increase it if you want to have more _guaranteed_ speed. Note that 80 * Increase it if you want to have more _guaranteed_ speed. Note that
@@ -213,12 +220,12 @@ static int md_make_request(struct request_queue *q, struct bio *bio)
213 return 0; 220 return 0;
214 } 221 }
215 rcu_read_lock(); 222 rcu_read_lock();
216 if (mddev->suspended) { 223 if (mddev->suspended || mddev->barrier) {
217 DEFINE_WAIT(__wait); 224 DEFINE_WAIT(__wait);
218 for (;;) { 225 for (;;) {
219 prepare_to_wait(&mddev->sb_wait, &__wait, 226 prepare_to_wait(&mddev->sb_wait, &__wait,
220 TASK_UNINTERRUPTIBLE); 227 TASK_UNINTERRUPTIBLE);
221 if (!mddev->suspended) 228 if (!mddev->suspended && !mddev->barrier)
222 break; 229 break;
223 rcu_read_unlock(); 230 rcu_read_unlock();
224 schedule(); 231 schedule();
@@ -260,10 +267,110 @@ static void mddev_resume(mddev_t *mddev)
260 267
261int mddev_congested(mddev_t *mddev, int bits) 268int mddev_congested(mddev_t *mddev, int bits)
262{ 269{
270 if (mddev->barrier)
271 return 1;
263 return mddev->suspended; 272 return mddev->suspended;
264} 273}
265EXPORT_SYMBOL(mddev_congested); 274EXPORT_SYMBOL(mddev_congested);
266 275
276/*
277 * Generic barrier handling for md
278 */
279
280#define POST_REQUEST_BARRIER ((void*)1)
281
282static void md_end_barrier(struct bio *bio, int err)
283{
284 mdk_rdev_t *rdev = bio->bi_private;
285 mddev_t *mddev = rdev->mddev;
286 if (err == -EOPNOTSUPP && mddev->barrier != POST_REQUEST_BARRIER)
287 set_bit(BIO_EOPNOTSUPP, &mddev->barrier->bi_flags);
288
289 rdev_dec_pending(rdev, mddev);
290
291 if (atomic_dec_and_test(&mddev->flush_pending)) {
292 if (mddev->barrier == POST_REQUEST_BARRIER) {
293 /* This was a post-request barrier */
294 mddev->barrier = NULL;
295 wake_up(&mddev->sb_wait);
296 } else
297 /* The pre-request barrier has finished */
298 schedule_work(&mddev->barrier_work);
299 }
300 bio_put(bio);
301}
302
303static void submit_barriers(mddev_t *mddev)
304{
305 mdk_rdev_t *rdev;
306
307 rcu_read_lock();
308 list_for_each_entry_rcu(rdev, &mddev->disks, same_set)
309 if (rdev->raid_disk >= 0 &&
310 !test_bit(Faulty, &rdev->flags)) {
311 /* Take two references, one is dropped
312 * when request finishes, one after
313 * we reclaim rcu_read_lock
314 */
315 struct bio *bi;
316 atomic_inc(&rdev->nr_pending);
317 atomic_inc(&rdev->nr_pending);
318 rcu_read_unlock();
319 bi = bio_alloc(GFP_KERNEL, 0);
320 bi->bi_end_io = md_end_barrier;
321 bi->bi_private = rdev;
322 bi->bi_bdev = rdev->bdev;
323 atomic_inc(&mddev->flush_pending);
324 submit_bio(WRITE_BARRIER, bi);
325 rcu_read_lock();
326 rdev_dec_pending(rdev, mddev);
327 }
328 rcu_read_unlock();
329}
330
331static void md_submit_barrier(struct work_struct *ws)
332{
333 mddev_t *mddev = container_of(ws, mddev_t, barrier_work);
334 struct bio *bio = mddev->barrier;
335
336 atomic_set(&mddev->flush_pending, 1);
337
338 if (test_bit(BIO_EOPNOTSUPP, &bio->bi_flags))
339 bio_endio(bio, -EOPNOTSUPP);
340 else if (bio->bi_size == 0)
341 /* an empty barrier - all done */
342 bio_endio(bio, 0);
343 else {
344 bio->bi_rw &= ~(1<<BIO_RW_BARRIER);
345 if (mddev->pers->make_request(mddev->queue, bio))
346 generic_make_request(bio);
347 mddev->barrier = POST_REQUEST_BARRIER;
348 submit_barriers(mddev);
349 }
350 if (atomic_dec_and_test(&mddev->flush_pending)) {
351 mddev->barrier = NULL;
352 wake_up(&mddev->sb_wait);
353 }
354}
355
356void md_barrier_request(mddev_t *mddev, struct bio *bio)
357{
358 spin_lock_irq(&mddev->write_lock);
359 wait_event_lock_irq(mddev->sb_wait,
360 !mddev->barrier,
361 mddev->write_lock, /*nothing*/);
362 mddev->barrier = bio;
363 spin_unlock_irq(&mddev->write_lock);
364
365 atomic_set(&mddev->flush_pending, 1);
366 INIT_WORK(&mddev->barrier_work, md_submit_barrier);
367
368 submit_barriers(mddev);
369
370 if (atomic_dec_and_test(&mddev->flush_pending))
371 schedule_work(&mddev->barrier_work);
372}
373EXPORT_SYMBOL(md_barrier_request);
267 374
268static inline mddev_t *mddev_get(mddev_t *mddev) 375static inline mddev_t *mddev_get(mddev_t *mddev)
269{ 376{
@@ -363,6 +470,7 @@ static mddev_t * mddev_find(dev_t unit)
363 470
364 mutex_init(&new->open_mutex); 471 mutex_init(&new->open_mutex);
365 mutex_init(&new->reconfig_mutex); 472 mutex_init(&new->reconfig_mutex);
473 mutex_init(&new->bitmap_info.mutex);
366 INIT_LIST_HEAD(&new->disks); 474 INIT_LIST_HEAD(&new->disks);
367 INIT_LIST_HEAD(&new->all_mddevs); 475 INIT_LIST_HEAD(&new->all_mddevs);
368 init_timer(&new->safemode_timer); 476 init_timer(&new->safemode_timer);
@@ -370,6 +478,7 @@ static mddev_t * mddev_find(dev_t unit)
370 atomic_set(&new->openers, 0); 478 atomic_set(&new->openers, 0);
371 atomic_set(&new->active_io, 0); 479 atomic_set(&new->active_io, 0);
372 spin_lock_init(&new->write_lock); 480 spin_lock_init(&new->write_lock);
481 atomic_set(&new->flush_pending, 0);
373 init_waitqueue_head(&new->sb_wait); 482 init_waitqueue_head(&new->sb_wait);
374 init_waitqueue_head(&new->recovery_wait); 483 init_waitqueue_head(&new->recovery_wait);
375 new->reshape_position = MaxSector; 484 new->reshape_position = MaxSector;
@@ -748,7 +857,7 @@ struct super_type {
748 */ 857 */
749int md_check_no_bitmap(mddev_t *mddev) 858int md_check_no_bitmap(mddev_t *mddev)
750{ 859{
751 if (!mddev->bitmap_file && !mddev->bitmap_offset) 860 if (!mddev->bitmap_info.file && !mddev->bitmap_info.offset)
752 return 0; 861 return 0;
753 printk(KERN_ERR "%s: bitmaps are not supported for %s\n", 862 printk(KERN_ERR "%s: bitmaps are not supported for %s\n",
754 mdname(mddev), mddev->pers->name); 863 mdname(mddev), mddev->pers->name);
@@ -876,8 +985,8 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev)
876 mddev->raid_disks = sb->raid_disks; 985 mddev->raid_disks = sb->raid_disks;
877 mddev->dev_sectors = sb->size * 2; 986 mddev->dev_sectors = sb->size * 2;
878 mddev->events = ev1; 987 mddev->events = ev1;
879 mddev->bitmap_offset = 0; 988 mddev->bitmap_info.offset = 0;
880 mddev->default_bitmap_offset = MD_SB_BYTES >> 9; 989 mddev->bitmap_info.default_offset = MD_SB_BYTES >> 9;
881 990
882 if (mddev->minor_version >= 91) { 991 if (mddev->minor_version >= 91) {
883 mddev->reshape_position = sb->reshape_position; 992 mddev->reshape_position = sb->reshape_position;
@@ -911,8 +1020,9 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev)
911 mddev->max_disks = MD_SB_DISKS; 1020 mddev->max_disks = MD_SB_DISKS;
912 1021
913 if (sb->state & (1<<MD_SB_BITMAP_PRESENT) && 1022 if (sb->state & (1<<MD_SB_BITMAP_PRESENT) &&
914 mddev->bitmap_file == NULL) 1023 mddev->bitmap_info.file == NULL)
915 mddev->bitmap_offset = mddev->default_bitmap_offset; 1024 mddev->bitmap_info.offset =
1025 mddev->bitmap_info.default_offset;
916 1026
917 } else if (mddev->pers == NULL) { 1027 } else if (mddev->pers == NULL) {
918 /* Insist on good event counter while assembling */ 1028 /* Insist on good event counter while assembling */
@@ -1029,7 +1139,7 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1029 sb->layout = mddev->layout; 1139 sb->layout = mddev->layout;
1030 sb->chunk_size = mddev->chunk_sectors << 9; 1140 sb->chunk_size = mddev->chunk_sectors << 9;
1031 1141
1032 if (mddev->bitmap && mddev->bitmap_file == NULL) 1142 if (mddev->bitmap && mddev->bitmap_info.file == NULL)
1033 sb->state |= (1<<MD_SB_BITMAP_PRESENT); 1143 sb->state |= (1<<MD_SB_BITMAP_PRESENT);
1034 1144
1035 sb->disks[0].state = (1<<MD_DISK_REMOVED); 1145 sb->disks[0].state = (1<<MD_DISK_REMOVED);
@@ -1107,7 +1217,7 @@ super_90_rdev_size_change(mdk_rdev_t *rdev, sector_t num_sectors)
1107{ 1217{
1108 if (num_sectors && num_sectors < rdev->mddev->dev_sectors) 1218 if (num_sectors && num_sectors < rdev->mddev->dev_sectors)
1109 return 0; /* component must fit device */ 1219 return 0; /* component must fit device */
1110 if (rdev->mddev->bitmap_offset) 1220 if (rdev->mddev->bitmap_info.offset)
1111 return 0; /* can't move bitmap */ 1221 return 0; /* can't move bitmap */
1112 rdev->sb_start = calc_dev_sboffset(rdev->bdev); 1222 rdev->sb_start = calc_dev_sboffset(rdev->bdev);
1113 if (!num_sectors || num_sectors > rdev->sb_start) 1223 if (!num_sectors || num_sectors > rdev->sb_start)
@@ -1286,8 +1396,8 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
1286 mddev->raid_disks = le32_to_cpu(sb->raid_disks); 1396 mddev->raid_disks = le32_to_cpu(sb->raid_disks);
1287 mddev->dev_sectors = le64_to_cpu(sb->size); 1397 mddev->dev_sectors = le64_to_cpu(sb->size);
1288 mddev->events = ev1; 1398 mddev->events = ev1;
1289 mddev->bitmap_offset = 0; 1399 mddev->bitmap_info.offset = 0;
1290 mddev->default_bitmap_offset = 1024 >> 9; 1400 mddev->bitmap_info.default_offset = 1024 >> 9;
1291 1401
1292 mddev->recovery_cp = le64_to_cpu(sb->resync_offset); 1402 mddev->recovery_cp = le64_to_cpu(sb->resync_offset);
1293 memcpy(mddev->uuid, sb->set_uuid, 16); 1403 memcpy(mddev->uuid, sb->set_uuid, 16);
@@ -1295,8 +1405,9 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
1295 mddev->max_disks = (4096-256)/2; 1405 mddev->max_disks = (4096-256)/2;
1296 1406
1297 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET) && 1407 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET) &&
1298 mddev->bitmap_file == NULL ) 1408 mddev->bitmap_info.file == NULL )
1299 mddev->bitmap_offset = (__s32)le32_to_cpu(sb->bitmap_offset); 1409 mddev->bitmap_info.offset =
1410 (__s32)le32_to_cpu(sb->bitmap_offset);
1300 1411
1301 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE)) { 1412 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE)) {
1302 mddev->reshape_position = le64_to_cpu(sb->reshape_position); 1413 mddev->reshape_position = le64_to_cpu(sb->reshape_position);
@@ -1390,19 +1501,17 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1390 sb->level = cpu_to_le32(mddev->level); 1501 sb->level = cpu_to_le32(mddev->level);
1391 sb->layout = cpu_to_le32(mddev->layout); 1502 sb->layout = cpu_to_le32(mddev->layout);
1392 1503
1393 if (mddev->bitmap && mddev->bitmap_file == NULL) { 1504 if (mddev->bitmap && mddev->bitmap_info.file == NULL) {
1394 sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_offset); 1505 sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_info.offset);
1395 sb->feature_map = cpu_to_le32(MD_FEATURE_BITMAP_OFFSET); 1506 sb->feature_map = cpu_to_le32(MD_FEATURE_BITMAP_OFFSET);
1396 } 1507 }
1397 1508
1398 if (rdev->raid_disk >= 0 && 1509 if (rdev->raid_disk >= 0 &&
1399 !test_bit(In_sync, &rdev->flags)) { 1510 !test_bit(In_sync, &rdev->flags)) {
1400 if (rdev->recovery_offset > 0) { 1511 sb->feature_map |=
1401 sb->feature_map |= 1512 cpu_to_le32(MD_FEATURE_RECOVERY_OFFSET);
1402 cpu_to_le32(MD_FEATURE_RECOVERY_OFFSET); 1513 sb->recovery_offset =
1403 sb->recovery_offset = 1514 cpu_to_le64(rdev->recovery_offset);
1404 cpu_to_le64(rdev->recovery_offset);
1405 }
1406 } 1515 }
1407 1516
1408 if (mddev->reshape_position != MaxSector) { 1517 if (mddev->reshape_position != MaxSector) {
@@ -1436,7 +1545,7 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1436 sb->dev_roles[i] = cpu_to_le16(0xfffe); 1545 sb->dev_roles[i] = cpu_to_le16(0xfffe);
1437 else if (test_bit(In_sync, &rdev2->flags)) 1546 else if (test_bit(In_sync, &rdev2->flags))
1438 sb->dev_roles[i] = cpu_to_le16(rdev2->raid_disk); 1547 sb->dev_roles[i] = cpu_to_le16(rdev2->raid_disk);
1439 else if (rdev2->raid_disk >= 0 && rdev2->recovery_offset > 0) 1548 else if (rdev2->raid_disk >= 0)
1440 sb->dev_roles[i] = cpu_to_le16(rdev2->raid_disk); 1549 sb->dev_roles[i] = cpu_to_le16(rdev2->raid_disk);
1441 else 1550 else
1442 sb->dev_roles[i] = cpu_to_le16(0xffff); 1551 sb->dev_roles[i] = cpu_to_le16(0xffff);
@@ -1458,7 +1567,7 @@ super_1_rdev_size_change(mdk_rdev_t *rdev, sector_t num_sectors)
1458 max_sectors -= rdev->data_offset; 1567 max_sectors -= rdev->data_offset;
1459 if (!num_sectors || num_sectors > max_sectors) 1568 if (!num_sectors || num_sectors > max_sectors)
1460 num_sectors = max_sectors; 1569 num_sectors = max_sectors;
1461 } else if (rdev->mddev->bitmap_offset) { 1570 } else if (rdev->mddev->bitmap_info.offset) {
1462 /* minor version 0 with bitmap we can't move */ 1571 /* minor version 0 with bitmap we can't move */
1463 return 0; 1572 return 0;
1464 } else { 1573 } else {
@@ -2442,12 +2551,49 @@ rdev_size_store(mdk_rdev_t *rdev, const char *buf, size_t len)
2442static struct rdev_sysfs_entry rdev_size = 2551static struct rdev_sysfs_entry rdev_size =
2443__ATTR(size, S_IRUGO|S_IWUSR, rdev_size_show, rdev_size_store); 2552__ATTR(size, S_IRUGO|S_IWUSR, rdev_size_show, rdev_size_store);
2444 2553
2554
2555static ssize_t recovery_start_show(mdk_rdev_t *rdev, char *page)
2556{
2557 unsigned long long recovery_start = rdev->recovery_offset;
2558
2559 if (test_bit(In_sync, &rdev->flags) ||
2560 recovery_start == MaxSector)
2561 return sprintf(page, "none\n");
2562
2563 return sprintf(page, "%llu\n", recovery_start);
2564}
2565
2566static ssize_t recovery_start_store(mdk_rdev_t *rdev, const char *buf, size_t len)
2567{
2568 unsigned long long recovery_start;
2569
2570 if (cmd_match(buf, "none"))
2571 recovery_start = MaxSector;
2572 else if (strict_strtoull(buf, 10, &recovery_start))
2573 return -EINVAL;
2574
2575 if (rdev->mddev->pers &&
2576 rdev->raid_disk >= 0)
2577 return -EBUSY;
2578
2579 rdev->recovery_offset = recovery_start;
2580 if (recovery_start == MaxSector)
2581 set_bit(In_sync, &rdev->flags);
2582 else
2583 clear_bit(In_sync, &rdev->flags);
2584 return len;
2585}
2586
2587static struct rdev_sysfs_entry rdev_recovery_start =
2588__ATTR(recovery_start, S_IRUGO|S_IWUSR, recovery_start_show, recovery_start_store);
2589
2445static struct attribute *rdev_default_attrs[] = { 2590static struct attribute *rdev_default_attrs[] = {
2446 &rdev_state.attr, 2591 &rdev_state.attr,
2447 &rdev_errors.attr, 2592 &rdev_errors.attr,
2448 &rdev_slot.attr, 2593 &rdev_slot.attr,
2449 &rdev_offset.attr, 2594 &rdev_offset.attr,
2450 &rdev_size.attr, 2595 &rdev_size.attr,
2596 &rdev_recovery_start.attr,
2451 NULL, 2597 NULL,
2452}; 2598};
2453static ssize_t 2599static ssize_t
@@ -2549,6 +2695,8 @@ static mdk_rdev_t *md_import_device(dev_t newdev, int super_format, int super_mi
2549 rdev->flags = 0; 2695 rdev->flags = 0;
2550 rdev->data_offset = 0; 2696 rdev->data_offset = 0;
2551 rdev->sb_events = 0; 2697 rdev->sb_events = 0;
2698 rdev->last_read_error.tv_sec = 0;
2699 rdev->last_read_error.tv_nsec = 0;
2552 atomic_set(&rdev->nr_pending, 0); 2700 atomic_set(&rdev->nr_pending, 0);
2553 atomic_set(&rdev->read_errors, 0); 2701 atomic_set(&rdev->read_errors, 0);
2554 atomic_set(&rdev->corrected_errors, 0); 2702 atomic_set(&rdev->corrected_errors, 0);
@@ -2659,6 +2807,47 @@ static void analyze_sbs(mddev_t * mddev)
2659 } 2807 }
2660} 2808}
2661 2809
2810/* Read a fixed-point number.
2811 * Numbers in sysfs attributes should be in "standard" units where
2812 * possible, so time should be in seconds.
2813 * However we internally use a a much smaller unit such as
2814 * milliseconds or jiffies.
2815 * This function takes a decimal number with a possible fractional
2816 * component, and produces an integer which is the result of
2817 * multiplying that number by 10^'scale'.
2818 * all without any floating-point arithmetic.
2819 */
2820int strict_strtoul_scaled(const char *cp, unsigned long *res, int scale)
2821{
2822 unsigned long result = 0;
2823 long decimals = -1;
2824 while (isdigit(*cp) || (*cp == '.' && decimals < 0)) {
2825 if (*cp == '.')
2826 decimals = 0;
2827 else if (decimals < scale) {
2828 unsigned int value;
2829 value = *cp - '0';
2830 result = result * 10 + value;
2831 if (decimals >= 0)
2832 decimals++;
2833 }
2834 cp++;
2835 }
2836 if (*cp == '\n')
2837 cp++;
2838 if (*cp)
2839 return -EINVAL;
2840 if (decimals < 0)
2841 decimals = 0;
2842 while (decimals < scale) {
2843 result *= 10;
2844 decimals ++;
2845 }
2846 *res = result;
2847 return 0;
2848}
2849
2850
2662static void md_safemode_timeout(unsigned long data); 2851static void md_safemode_timeout(unsigned long data);
2663 2852
2664static ssize_t 2853static ssize_t
@@ -2670,31 +2859,10 @@ safe_delay_show(mddev_t *mddev, char *page)
2670static ssize_t 2859static ssize_t
2671safe_delay_store(mddev_t *mddev, const char *cbuf, size_t len) 2860safe_delay_store(mddev_t *mddev, const char *cbuf, size_t len)
2672{ 2861{
2673 int scale=1;
2674 int dot=0;
2675 int i;
2676 unsigned long msec; 2862 unsigned long msec;
2677 char buf[30];
2678 2863
2679 /* remove a period, and count digits after it */ 2864 if (strict_strtoul_scaled(cbuf, &msec, 3) < 0)
2680 if (len >= sizeof(buf))
2681 return -EINVAL;
2682 strlcpy(buf, cbuf, sizeof(buf));
2683 for (i=0; i<len; i++) {
2684 if (dot) {
2685 if (isdigit(buf[i])) {
2686 buf[i-1] = buf[i];
2687 scale *= 10;
2688 }
2689 buf[i] = 0;
2690 } else if (buf[i] == '.') {
2691 dot=1;
2692 buf[i] = 0;
2693 }
2694 }
2695 if (strict_strtoul(buf, 10, &msec) < 0)
2696 return -EINVAL; 2865 return -EINVAL;
2697 msec = (msec * 1000) / scale;
2698 if (msec == 0) 2866 if (msec == 0)
2699 mddev->safemode_delay = 0; 2867 mddev->safemode_delay = 0;
2700 else { 2868 else {
@@ -2970,7 +3138,9 @@ resync_start_store(mddev_t *mddev, const char *buf, size_t len)
2970 3138
2971 if (mddev->pers) 3139 if (mddev->pers)
2972 return -EBUSY; 3140 return -EBUSY;
2973 if (!*buf || (*e && *e != '\n')) 3141 if (cmd_match(buf, "none"))
3142 n = MaxSector;
3143 else if (!*buf || (*e && *e != '\n'))
2974 return -EINVAL; 3144 return -EINVAL;
2975 3145
2976 mddev->recovery_cp = n; 3146 mddev->recovery_cp = n;
@@ -3166,6 +3336,29 @@ static struct md_sysfs_entry md_array_state =
3166__ATTR(array_state, S_IRUGO|S_IWUSR, array_state_show, array_state_store); 3336__ATTR(array_state, S_IRUGO|S_IWUSR, array_state_show, array_state_store);
3167 3337
3168static ssize_t 3338static ssize_t
3339max_corrected_read_errors_show(mddev_t *mddev, char *page) {
3340 return sprintf(page, "%d\n",
3341 atomic_read(&mddev->max_corr_read_errors));
3342}
3343
3344static ssize_t
3345max_corrected_read_errors_store(mddev_t *mddev, const char *buf, size_t len)
3346{
3347 char *e;
3348 unsigned long n = simple_strtoul(buf, &e, 10);
3349
3350 if (*buf && (*e == 0 || *e == '\n')) {
3351 atomic_set(&mddev->max_corr_read_errors, n);
3352 return len;
3353 }
3354 return -EINVAL;
3355}
3356
3357static struct md_sysfs_entry max_corr_read_errors =
3358__ATTR(max_read_errors, S_IRUGO|S_IWUSR, max_corrected_read_errors_show,
3359 max_corrected_read_errors_store);
3360
3361static ssize_t
3169null_show(mddev_t *mddev, char *page) 3362null_show(mddev_t *mddev, char *page)
3170{ 3363{
3171 return -EINVAL; 3364 return -EINVAL;
@@ -3790,6 +3983,7 @@ static struct attribute *md_default_attrs[] = {
3790 &md_array_state.attr, 3983 &md_array_state.attr,
3791 &md_reshape_position.attr, 3984 &md_reshape_position.attr,
3792 &md_array_size.attr, 3985 &md_array_size.attr,
3986 &max_corr_read_errors.attr,
3793 NULL, 3987 NULL,
3794}; 3988};
3795 3989
@@ -3894,6 +4088,7 @@ static void mddev_delayed_delete(struct work_struct *ws)
3894 mddev->sysfs_action = NULL; 4088 mddev->sysfs_action = NULL;
3895 mddev->private = NULL; 4089 mddev->private = NULL;
3896 } 4090 }
4091 sysfs_remove_group(&mddev->kobj, &md_bitmap_group);
3897 kobject_del(&mddev->kobj); 4092 kobject_del(&mddev->kobj);
3898 kobject_put(&mddev->kobj); 4093 kobject_put(&mddev->kobj);
3899} 4094}
@@ -3985,6 +4180,8 @@ static int md_alloc(dev_t dev, char *name)
3985 disk->disk_name); 4180 disk->disk_name);
3986 error = 0; 4181 error = 0;
3987 } 4182 }
4183 if (sysfs_create_group(&mddev->kobj, &md_bitmap_group))
4184 printk(KERN_DEBUG "pointless warning\n");
3988 abort: 4185 abort:
3989 mutex_unlock(&disks_mutex); 4186 mutex_unlock(&disks_mutex);
3990 if (!error) { 4187 if (!error) {
@@ -4206,6 +4403,8 @@ static int do_md_run(mddev_t * mddev)
4206 mddev->ro = 0; 4403 mddev->ro = 0;
4207 4404
4208 atomic_set(&mddev->writes_pending,0); 4405 atomic_set(&mddev->writes_pending,0);
4406 atomic_set(&mddev->max_corr_read_errors,
4407 MD_DEFAULT_MAX_CORRECTED_READ_ERRORS);
4209 mddev->safemode = 0; 4408 mddev->safemode = 0;
4210 mddev->safemode_timer.function = md_safemode_timeout; 4409 mddev->safemode_timer.function = md_safemode_timeout;
4211 mddev->safemode_timer.data = (unsigned long) mddev; 4410 mddev->safemode_timer.data = (unsigned long) mddev;
@@ -4310,7 +4509,7 @@ static int deny_bitmap_write_access(struct file * file)
4310 return 0; 4509 return 0;
4311} 4510}
4312 4511
4313static void restore_bitmap_write_access(struct file *file) 4512void restore_bitmap_write_access(struct file *file)
4314{ 4513{
4315 struct inode *inode = file->f_mapping->host; 4514 struct inode *inode = file->f_mapping->host;
4316 4515
@@ -4405,12 +4604,12 @@ out:
4405 printk(KERN_INFO "md: %s stopped.\n", mdname(mddev)); 4604 printk(KERN_INFO "md: %s stopped.\n", mdname(mddev));
4406 4605
4407 bitmap_destroy(mddev); 4606 bitmap_destroy(mddev);
4408 if (mddev->bitmap_file) { 4607 if (mddev->bitmap_info.file) {
4409 restore_bitmap_write_access(mddev->bitmap_file); 4608 restore_bitmap_write_access(mddev->bitmap_info.file);
4410 fput(mddev->bitmap_file); 4609 fput(mddev->bitmap_info.file);
4411 mddev->bitmap_file = NULL; 4610 mddev->bitmap_info.file = NULL;
4412 } 4611 }
4413 mddev->bitmap_offset = 0; 4612 mddev->bitmap_info.offset = 0;
4414 4613
4415 /* make sure all md_delayed_delete calls have finished */ 4614 /* make sure all md_delayed_delete calls have finished */
4416 flush_scheduled_work(); 4615 flush_scheduled_work();
@@ -4451,6 +4650,11 @@ out:
4451 mddev->degraded = 0; 4650 mddev->degraded = 0;
4452 mddev->barriers_work = 0; 4651 mddev->barriers_work = 0;
4453 mddev->safemode = 0; 4652 mddev->safemode = 0;
4653 mddev->bitmap_info.offset = 0;
4654 mddev->bitmap_info.default_offset = 0;
4655 mddev->bitmap_info.chunksize = 0;
4656 mddev->bitmap_info.daemon_sleep = 0;
4657 mddev->bitmap_info.max_write_behind = 0;
4454 kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE); 4658 kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE);
4455 if (mddev->hold_active == UNTIL_STOP) 4659 if (mddev->hold_active == UNTIL_STOP)
4456 mddev->hold_active = 0; 4660 mddev->hold_active = 0;
@@ -4636,7 +4840,7 @@ static int get_array_info(mddev_t * mddev, void __user * arg)
4636 info.state = 0; 4840 info.state = 0;
4637 if (mddev->in_sync) 4841 if (mddev->in_sync)
4638 info.state = (1<<MD_SB_CLEAN); 4842 info.state = (1<<MD_SB_CLEAN);
4639 if (mddev->bitmap && mddev->bitmap_offset) 4843 if (mddev->bitmap && mddev->bitmap_info.offset)
4640 info.state = (1<<MD_SB_BITMAP_PRESENT); 4844 info.state = (1<<MD_SB_BITMAP_PRESENT);
4641 info.active_disks = insync; 4845 info.active_disks = insync;
4642 info.working_disks = working; 4846 info.working_disks = working;
@@ -4994,23 +5198,23 @@ static int set_bitmap_file(mddev_t *mddev, int fd)
4994 if (fd >= 0) { 5198 if (fd >= 0) {
4995 if (mddev->bitmap) 5199 if (mddev->bitmap)
4996 return -EEXIST; /* cannot add when bitmap is present */ 5200 return -EEXIST; /* cannot add when bitmap is present */
4997 mddev->bitmap_file = fget(fd); 5201 mddev->bitmap_info.file = fget(fd);
4998 5202
4999 if (mddev->bitmap_file == NULL) { 5203 if (mddev->bitmap_info.file == NULL) {
5000 printk(KERN_ERR "%s: error: failed to get bitmap file\n", 5204 printk(KERN_ERR "%s: error: failed to get bitmap file\n",
5001 mdname(mddev)); 5205 mdname(mddev));
5002 return -EBADF; 5206 return -EBADF;
5003 } 5207 }
5004 5208
5005 err = deny_bitmap_write_access(mddev->bitmap_file); 5209 err = deny_bitmap_write_access(mddev->bitmap_info.file);
5006 if (err) { 5210 if (err) {
5007 printk(KERN_ERR "%s: error: bitmap file is already in use\n", 5211 printk(KERN_ERR "%s: error: bitmap file is already in use\n",
5008 mdname(mddev)); 5212 mdname(mddev));
5009 fput(mddev->bitmap_file); 5213 fput(mddev->bitmap_info.file);
5010 mddev->bitmap_file = NULL; 5214 mddev->bitmap_info.file = NULL;
5011 return err; 5215 return err;
5012 } 5216 }
5013 mddev->bitmap_offset = 0; /* file overrides offset */ 5217 mddev->bitmap_info.offset = 0; /* file overrides offset */
5014 } else if (mddev->bitmap == NULL) 5218 } else if (mddev->bitmap == NULL)
5015 return -ENOENT; /* cannot remove what isn't there */ 5219 return -ENOENT; /* cannot remove what isn't there */
5016 err = 0; 5220 err = 0;
@@ -5025,11 +5229,11 @@ static int set_bitmap_file(mddev_t *mddev, int fd)
5025 mddev->pers->quiesce(mddev, 0); 5229 mddev->pers->quiesce(mddev, 0);
5026 } 5230 }
5027 if (fd < 0) { 5231 if (fd < 0) {
5028 if (mddev->bitmap_file) { 5232 if (mddev->bitmap_info.file) {
5029 restore_bitmap_write_access(mddev->bitmap_file); 5233 restore_bitmap_write_access(mddev->bitmap_info.file);
5030 fput(mddev->bitmap_file); 5234 fput(mddev->bitmap_info.file);
5031 } 5235 }
5032 mddev->bitmap_file = NULL; 5236 mddev->bitmap_info.file = NULL;
5033 } 5237 }
5034 5238
5035 return err; 5239 return err;
@@ -5096,8 +5300,8 @@ static int set_array_info(mddev_t * mddev, mdu_array_info_t *info)
5096 mddev->flags = 0; 5300 mddev->flags = 0;
5097 set_bit(MD_CHANGE_DEVS, &mddev->flags); 5301 set_bit(MD_CHANGE_DEVS, &mddev->flags);
5098 5302
5099 mddev->default_bitmap_offset = MD_SB_BYTES >> 9; 5303 mddev->bitmap_info.default_offset = MD_SB_BYTES >> 9;
5100 mddev->bitmap_offset = 0; 5304 mddev->bitmap_info.offset = 0;
5101 5305
5102 mddev->reshape_position = MaxSector; 5306 mddev->reshape_position = MaxSector;
5103 5307
@@ -5197,7 +5401,7 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info)
5197 int state = 0; 5401 int state = 0;
5198 5402
5199 /* calculate expected state,ignoring low bits */ 5403 /* calculate expected state,ignoring low bits */
5200 if (mddev->bitmap && mddev->bitmap_offset) 5404 if (mddev->bitmap && mddev->bitmap_info.offset)
5201 state |= (1 << MD_SB_BITMAP_PRESENT); 5405 state |= (1 << MD_SB_BITMAP_PRESENT);
5202 5406
5203 if (mddev->major_version != info->major_version || 5407 if (mddev->major_version != info->major_version ||
@@ -5256,9 +5460,10 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info)
5256 /* add the bitmap */ 5460 /* add the bitmap */
5257 if (mddev->bitmap) 5461 if (mddev->bitmap)
5258 return -EEXIST; 5462 return -EEXIST;
5259 if (mddev->default_bitmap_offset == 0) 5463 if (mddev->bitmap_info.default_offset == 0)
5260 return -EINVAL; 5464 return -EINVAL;
5261 mddev->bitmap_offset = mddev->default_bitmap_offset; 5465 mddev->bitmap_info.offset =
5466 mddev->bitmap_info.default_offset;
5262 mddev->pers->quiesce(mddev, 1); 5467 mddev->pers->quiesce(mddev, 1);
5263 rv = bitmap_create(mddev); 5468 rv = bitmap_create(mddev);
5264 if (rv) 5469 if (rv)
@@ -5273,7 +5478,7 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info)
5273 mddev->pers->quiesce(mddev, 1); 5478 mddev->pers->quiesce(mddev, 1);
5274 bitmap_destroy(mddev); 5479 bitmap_destroy(mddev);
5275 mddev->pers->quiesce(mddev, 0); 5480 mddev->pers->quiesce(mddev, 0);
5276 mddev->bitmap_offset = 0; 5481 mddev->bitmap_info.offset = 0;
5277 } 5482 }
5278 } 5483 }
5279 md_update_sb(mddev, 1); 5484 md_update_sb(mddev, 1);
@@ -5524,6 +5729,25 @@ done:
5524abort: 5729abort:
5525 return err; 5730 return err;
5526} 5731}
5732#ifdef CONFIG_COMPAT
5733static int md_compat_ioctl(struct block_device *bdev, fmode_t mode,
5734 unsigned int cmd, unsigned long arg)
5735{
5736 switch (cmd) {
5737 case HOT_REMOVE_DISK:
5738 case HOT_ADD_DISK:
5739 case SET_DISK_FAULTY:
5740 case SET_BITMAP_FILE:
5741 /* These take in integer arg, do not convert */
5742 break;
5743 default:
5744 arg = (unsigned long)compat_ptr(arg);
5745 break;
5746 }
5747
5748 return md_ioctl(bdev, mode, cmd, arg);
5749}
5750#endif /* CONFIG_COMPAT */
5527 5751
5528static int md_open(struct block_device *bdev, fmode_t mode) 5752static int md_open(struct block_device *bdev, fmode_t mode)
5529{ 5753{
@@ -5589,6 +5813,9 @@ static const struct block_device_operations md_fops =
5589 .open = md_open, 5813 .open = md_open,
5590 .release = md_release, 5814 .release = md_release,
5591 .ioctl = md_ioctl, 5815 .ioctl = md_ioctl,
5816#ifdef CONFIG_COMPAT
5817 .compat_ioctl = md_compat_ioctl,
5818#endif
5592 .getgeo = md_getgeo, 5819 .getgeo = md_getgeo,
5593 .media_changed = md_media_changed, 5820 .media_changed = md_media_changed,
5594 .revalidate_disk= md_revalidate, 5821 .revalidate_disk= md_revalidate,
@@ -5982,14 +6209,14 @@ static int md_seq_show(struct seq_file *seq, void *v)
5982 unsigned long chunk_kb; 6209 unsigned long chunk_kb;
5983 unsigned long flags; 6210 unsigned long flags;
5984 spin_lock_irqsave(&bitmap->lock, flags); 6211 spin_lock_irqsave(&bitmap->lock, flags);
5985 chunk_kb = bitmap->chunksize >> 10; 6212 chunk_kb = mddev->bitmap_info.chunksize >> 10;
5986 seq_printf(seq, "bitmap: %lu/%lu pages [%luKB], " 6213 seq_printf(seq, "bitmap: %lu/%lu pages [%luKB], "
5987 "%lu%s chunk", 6214 "%lu%s chunk",
5988 bitmap->pages - bitmap->missing_pages, 6215 bitmap->pages - bitmap->missing_pages,
5989 bitmap->pages, 6216 bitmap->pages,
5990 (bitmap->pages - bitmap->missing_pages) 6217 (bitmap->pages - bitmap->missing_pages)
5991 << (PAGE_SHIFT - 10), 6218 << (PAGE_SHIFT - 10),
5992 chunk_kb ? chunk_kb : bitmap->chunksize, 6219 chunk_kb ? chunk_kb : mddev->bitmap_info.chunksize,
5993 chunk_kb ? "KB" : "B"); 6220 chunk_kb ? "KB" : "B");
5994 if (bitmap->file) { 6221 if (bitmap->file) {
5995 seq_printf(seq, ", file: "); 6222 seq_printf(seq, ", file: ");
@@ -6338,12 +6565,14 @@ void md_do_sync(mddev_t *mddev)
6338 /* recovery follows the physical size of devices */ 6565 /* recovery follows the physical size of devices */
6339 max_sectors = mddev->dev_sectors; 6566 max_sectors = mddev->dev_sectors;
6340 j = MaxSector; 6567 j = MaxSector;
6341 list_for_each_entry(rdev, &mddev->disks, same_set) 6568 rcu_read_lock();
6569 list_for_each_entry_rcu(rdev, &mddev->disks, same_set)
6342 if (rdev->raid_disk >= 0 && 6570 if (rdev->raid_disk >= 0 &&
6343 !test_bit(Faulty, &rdev->flags) && 6571 !test_bit(Faulty, &rdev->flags) &&
6344 !test_bit(In_sync, &rdev->flags) && 6572 !test_bit(In_sync, &rdev->flags) &&
6345 rdev->recovery_offset < j) 6573 rdev->recovery_offset < j)
6346 j = rdev->recovery_offset; 6574 j = rdev->recovery_offset;
6575 rcu_read_unlock();
6347 } 6576 }
6348 6577
6349 printk(KERN_INFO "md: %s of RAID array %s\n", desc, mdname(mddev)); 6578 printk(KERN_INFO "md: %s of RAID array %s\n", desc, mdname(mddev));
@@ -6380,6 +6609,7 @@ void md_do_sync(mddev_t *mddev)
6380 desc, mdname(mddev)); 6609 desc, mdname(mddev));
6381 mddev->curr_resync = j; 6610 mddev->curr_resync = j;
6382 } 6611 }
6612 mddev->curr_resync_completed = mddev->curr_resync;
6383 6613
6384 while (j < max_sectors) { 6614 while (j < max_sectors) {
6385 sector_t sectors; 6615 sector_t sectors;
@@ -6512,22 +6742,29 @@ void md_do_sync(mddev_t *mddev)
6512 } else { 6742 } else {
6513 if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery)) 6743 if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery))
6514 mddev->curr_resync = MaxSector; 6744 mddev->curr_resync = MaxSector;
6515 list_for_each_entry(rdev, &mddev->disks, same_set) 6745 rcu_read_lock();
6746 list_for_each_entry_rcu(rdev, &mddev->disks, same_set)
6516 if (rdev->raid_disk >= 0 && 6747 if (rdev->raid_disk >= 0 &&
6517 !test_bit(Faulty, &rdev->flags) && 6748 !test_bit(Faulty, &rdev->flags) &&
6518 !test_bit(In_sync, &rdev->flags) && 6749 !test_bit(In_sync, &rdev->flags) &&
6519 rdev->recovery_offset < mddev->curr_resync) 6750 rdev->recovery_offset < mddev->curr_resync)
6520 rdev->recovery_offset = mddev->curr_resync; 6751 rdev->recovery_offset = mddev->curr_resync;
6752 rcu_read_unlock();
6521 } 6753 }
6522 } 6754 }
6523 set_bit(MD_CHANGE_DEVS, &mddev->flags); 6755 set_bit(MD_CHANGE_DEVS, &mddev->flags);
6524 6756
6525 skip: 6757 skip:
6758 if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery)) {
6759 /* We completed so min/max setting can be forgotten if used. */
6760 if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery))
6761 mddev->resync_min = 0;
6762 mddev->resync_max = MaxSector;
6763 } else if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery))
6764 mddev->resync_min = mddev->curr_resync_completed;
6526 mddev->curr_resync = 0; 6765 mddev->curr_resync = 0;
6527 mddev->curr_resync_completed = 0;
6528 if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery)) 6766 if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery))
6529 /* We completed so max setting can be forgotten. */ 6767 mddev->curr_resync_completed = 0;
6530 mddev->resync_max = MaxSector;
6531 sysfs_notify(&mddev->kobj, NULL, "sync_completed"); 6768 sysfs_notify(&mddev->kobj, NULL, "sync_completed");
6532 wake_up(&resync_wait); 6769 wake_up(&resync_wait);
6533 set_bit(MD_RECOVERY_DONE, &mddev->recovery); 6770 set_bit(MD_RECOVERY_DONE, &mddev->recovery);
@@ -6590,6 +6827,7 @@ static int remove_and_add_spares(mddev_t *mddev)
6590 nm, mdname(mddev)); 6827 nm, mdname(mddev));
6591 spares++; 6828 spares++;
6592 md_new_event(mddev); 6829 md_new_event(mddev);
6830 set_bit(MD_CHANGE_DEVS, &mddev->flags);
6593 } else 6831 } else
6594 break; 6832 break;
6595 } 6833 }
@@ -6625,7 +6863,7 @@ void md_check_recovery(mddev_t *mddev)
6625 6863
6626 6864
6627 if (mddev->bitmap) 6865 if (mddev->bitmap)
6628 bitmap_daemon_work(mddev->bitmap); 6866 bitmap_daemon_work(mddev);
6629 6867
6630 if (mddev->ro) 6868 if (mddev->ro)
6631 return; 6869 return;
@@ -6995,5 +7233,6 @@ EXPORT_SYMBOL(md_unregister_thread);
6995EXPORT_SYMBOL(md_wakeup_thread); 7233EXPORT_SYMBOL(md_wakeup_thread);
6996EXPORT_SYMBOL(md_check_recovery); 7234EXPORT_SYMBOL(md_check_recovery);
6997MODULE_LICENSE("GPL"); 7235MODULE_LICENSE("GPL");
7236MODULE_DESCRIPTION("MD RAID framework");
6998MODULE_ALIAS("md"); 7237MODULE_ALIAS("md");
6999MODULE_ALIAS_BLOCKDEV_MAJOR(MD_MAJOR); 7238MODULE_ALIAS_BLOCKDEV_MAJOR(MD_MAJOR);
diff --git a/drivers/md/md.h b/drivers/md/md.h
index f184b69ef337..8e4c75c00d46 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -97,6 +97,9 @@ struct mdk_rdev_s
97 atomic_t read_errors; /* number of consecutive read errors that 97 atomic_t read_errors; /* number of consecutive read errors that
98 * we have tried to ignore. 98 * we have tried to ignore.
99 */ 99 */
100 struct timespec last_read_error; /* monotonic time since our
101 * last read error
102 */
100 atomic_t corrected_errors; /* number of corrected read errors, 103 atomic_t corrected_errors; /* number of corrected read errors,
101 * for reporting to userspace and storing 104 * for reporting to userspace and storing
102 * in superblock. 105 * in superblock.
@@ -280,17 +283,38 @@ struct mddev_s
280 unsigned int max_write_behind; /* 0 = sync */ 283 unsigned int max_write_behind; /* 0 = sync */
281 284
282 struct bitmap *bitmap; /* the bitmap for the device */ 285 struct bitmap *bitmap; /* the bitmap for the device */
283 struct file *bitmap_file; /* the bitmap file */ 286 struct {
284 long bitmap_offset; /* offset from superblock of 287 struct file *file; /* the bitmap file */
285 * start of bitmap. May be 288 loff_t offset; /* offset from superblock of
286 * negative, but not '0' 289 * start of bitmap. May be
287 */ 290 * negative, but not '0'
288 long default_bitmap_offset; /* this is the offset to use when 291 * For external metadata, offset
289 * hot-adding a bitmap. It should 292 * from start of device.
290 * eventually be settable by sysfs. 293 */
291 */ 294 loff_t default_offset; /* this is the offset to use when
292 295 * hot-adding a bitmap. It should
296 * eventually be settable by sysfs.
297 */
298 struct mutex mutex;
299 unsigned long chunksize;
300 unsigned long daemon_sleep; /* how many seconds between updates? */
301 unsigned long max_write_behind; /* write-behind mode */
302 int external;
303 } bitmap_info;
304
305 atomic_t max_corr_read_errors; /* max read retries */
293 struct list_head all_mddevs; 306 struct list_head all_mddevs;
307
308 /* Generic barrier handling.
309 * If there is a pending barrier request, all other
310 * writes are blocked while the devices are flushed.
311 * The last to finish a flush schedules a worker to
312 * submit the barrier request (without the barrier flag),
313 * then submit more flush requests.
314 */
315 struct bio *barrier;
316 atomic_t flush_pending;
317 struct work_struct barrier_work;
294}; 318};
295 319
296 320
@@ -353,7 +377,7 @@ struct md_sysfs_entry {
353 ssize_t (*show)(mddev_t *, char *); 377 ssize_t (*show)(mddev_t *, char *);
354 ssize_t (*store)(mddev_t *, const char *, size_t); 378 ssize_t (*store)(mddev_t *, const char *, size_t);
355}; 379};
356 380extern struct attribute_group md_bitmap_group;
357 381
358static inline char * mdname (mddev_t * mddev) 382static inline char * mdname (mddev_t * mddev)
359{ 383{
@@ -431,6 +455,7 @@ extern void md_done_sync(mddev_t *mddev, int blocks, int ok);
431extern void md_error(mddev_t *mddev, mdk_rdev_t *rdev); 455extern void md_error(mddev_t *mddev, mdk_rdev_t *rdev);
432 456
433extern int mddev_congested(mddev_t *mddev, int bits); 457extern int mddev_congested(mddev_t *mddev, int bits);
458extern void md_barrier_request(mddev_t *mddev, struct bio *bio);
434extern void md_super_write(mddev_t *mddev, mdk_rdev_t *rdev, 459extern void md_super_write(mddev_t *mddev, mdk_rdev_t *rdev,
435 sector_t sector, int size, struct page *page); 460 sector_t sector, int size, struct page *page);
436extern void md_super_wait(mddev_t *mddev); 461extern void md_super_wait(mddev_t *mddev);
@@ -443,6 +468,8 @@ extern void md_wait_for_blocked_rdev(mdk_rdev_t *rdev, mddev_t *mddev);
443extern void md_set_array_sectors(mddev_t *mddev, sector_t array_sectors); 468extern void md_set_array_sectors(mddev_t *mddev, sector_t array_sectors);
444extern int md_check_no_bitmap(mddev_t *mddev); 469extern int md_check_no_bitmap(mddev_t *mddev);
445extern int md_integrity_register(mddev_t *mddev); 470extern int md_integrity_register(mddev_t *mddev);
446void md_integrity_add_rdev(mdk_rdev_t *rdev, mddev_t *mddev); 471extern void md_integrity_add_rdev(mdk_rdev_t *rdev, mddev_t *mddev);
472extern int strict_strtoul_scaled(const char *cp, unsigned long *res, int scale);
473extern void restore_bitmap_write_access(struct file *file);
447 474
448#endif /* _MD_MD_H */ 475#endif /* _MD_MD_H */
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index ee7646f974a0..32a662fc55c9 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -145,7 +145,7 @@ static int multipath_make_request (struct request_queue *q, struct bio * bio)
145 int cpu; 145 int cpu;
146 146
147 if (unlikely(bio_rw_flagged(bio, BIO_RW_BARRIER))) { 147 if (unlikely(bio_rw_flagged(bio, BIO_RW_BARRIER))) {
148 bio_endio(bio, -EOPNOTSUPP); 148 md_barrier_request(mddev, bio);
149 return 0; 149 return 0;
150 } 150 }
151 151
@@ -581,6 +581,7 @@ static void __exit multipath_exit (void)
581module_init(multipath_init); 581module_init(multipath_init);
582module_exit(multipath_exit); 582module_exit(multipath_exit);
583MODULE_LICENSE("GPL"); 583MODULE_LICENSE("GPL");
584MODULE_DESCRIPTION("simple multi-path personality for MD");
584MODULE_ALIAS("md-personality-7"); /* MULTIPATH */ 585MODULE_ALIAS("md-personality-7"); /* MULTIPATH */
585MODULE_ALIAS("md-multipath"); 586MODULE_ALIAS("md-multipath");
586MODULE_ALIAS("md-level--4"); 587MODULE_ALIAS("md-level--4");
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index d3a4ce06015a..77605cdceaf1 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -453,7 +453,7 @@ static int raid0_make_request(struct request_queue *q, struct bio *bio)
453 int cpu; 453 int cpu;
454 454
455 if (unlikely(bio_rw_flagged(bio, BIO_RW_BARRIER))) { 455 if (unlikely(bio_rw_flagged(bio, BIO_RW_BARRIER))) {
456 bio_endio(bio, -EOPNOTSUPP); 456 md_barrier_request(mddev, bio);
457 return 0; 457 return 0;
458 } 458 }
459 459
@@ -567,6 +567,7 @@ static void raid0_exit (void)
567module_init(raid0_init); 567module_init(raid0_init);
568module_exit(raid0_exit); 568module_exit(raid0_exit);
569MODULE_LICENSE("GPL"); 569MODULE_LICENSE("GPL");
570MODULE_DESCRIPTION("RAID0 (striping) personality for MD");
570MODULE_ALIAS("md-personality-2"); /* RAID0 */ 571MODULE_ALIAS("md-personality-2"); /* RAID0 */
571MODULE_ALIAS("md-raid0"); 572MODULE_ALIAS("md-raid0");
572MODULE_ALIAS("md-level-0"); 573MODULE_ALIAS("md-level-0");
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index e07ce2e033a9..859bd3ffe435 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -677,6 +677,7 @@ static void raise_barrier(conf_t *conf)
677static void lower_barrier(conf_t *conf) 677static void lower_barrier(conf_t *conf)
678{ 678{
679 unsigned long flags; 679 unsigned long flags;
680 BUG_ON(conf->barrier <= 0);
680 spin_lock_irqsave(&conf->resync_lock, flags); 681 spin_lock_irqsave(&conf->resync_lock, flags);
681 conf->barrier--; 682 conf->barrier--;
682 spin_unlock_irqrestore(&conf->resync_lock, flags); 683 spin_unlock_irqrestore(&conf->resync_lock, flags);
@@ -801,6 +802,25 @@ static int make_request(struct request_queue *q, struct bio * bio)
801 802
802 md_write_start(mddev, bio); /* wait on superblock update early */ 803 md_write_start(mddev, bio); /* wait on superblock update early */
803 804
805 if (bio_data_dir(bio) == WRITE &&
806 bio->bi_sector + bio->bi_size/512 > mddev->suspend_lo &&
807 bio->bi_sector < mddev->suspend_hi) {
808 /* As the suspend_* range is controlled by
809 * userspace, we want an interruptible
810 * wait.
811 */
812 DEFINE_WAIT(w);
813 for (;;) {
814 flush_signals(current);
815 prepare_to_wait(&conf->wait_barrier,
816 &w, TASK_INTERRUPTIBLE);
817 if (bio->bi_sector + bio->bi_size/512 <= mddev->suspend_lo ||
818 bio->bi_sector >= mddev->suspend_hi)
819 break;
820 schedule();
821 }
822 finish_wait(&conf->wait_barrier, &w);
823 }
804 if (unlikely(!mddev->barriers_work && 824 if (unlikely(!mddev->barriers_work &&
805 bio_rw_flagged(bio, BIO_RW_BARRIER))) { 825 bio_rw_flagged(bio, BIO_RW_BARRIER))) {
806 if (rw == WRITE) 826 if (rw == WRITE)
@@ -923,7 +943,8 @@ static int make_request(struct request_queue *q, struct bio * bio)
923 943
924 /* do behind I/O ? */ 944 /* do behind I/O ? */
925 if (bitmap && 945 if (bitmap &&
926 atomic_read(&bitmap->behind_writes) < bitmap->max_write_behind && 946 (atomic_read(&bitmap->behind_writes)
947 < mddev->bitmap_info.max_write_behind) &&
927 (behind_pages = alloc_behind_pages(bio)) != NULL) 948 (behind_pages = alloc_behind_pages(bio)) != NULL)
928 set_bit(R1BIO_BehindIO, &r1_bio->state); 949 set_bit(R1BIO_BehindIO, &r1_bio->state);
929 950
@@ -1941,74 +1962,48 @@ static sector_t raid1_size(mddev_t *mddev, sector_t sectors, int raid_disks)
1941 return mddev->dev_sectors; 1962 return mddev->dev_sectors;
1942} 1963}
1943 1964
1944static int run(mddev_t *mddev) 1965static conf_t *setup_conf(mddev_t *mddev)
1945{ 1966{
1946 conf_t *conf; 1967 conf_t *conf;
1947 int i, j, disk_idx; 1968 int i;
1948 mirror_info_t *disk; 1969 mirror_info_t *disk;
1949 mdk_rdev_t *rdev; 1970 mdk_rdev_t *rdev;
1971 int err = -ENOMEM;
1950 1972
1951 if (mddev->level != 1) {
1952 printk("raid1: %s: raid level not set to mirroring (%d)\n",
1953 mdname(mddev), mddev->level);
1954 goto out;
1955 }
1956 if (mddev->reshape_position != MaxSector) {
1957 printk("raid1: %s: reshape_position set but not supported\n",
1958 mdname(mddev));
1959 goto out;
1960 }
1961 /*
1962 * copy the already verified devices into our private RAID1
1963 * bookkeeping area. [whatever we allocate in run(),
1964 * should be freed in stop()]
1965 */
1966 conf = kzalloc(sizeof(conf_t), GFP_KERNEL); 1973 conf = kzalloc(sizeof(conf_t), GFP_KERNEL);
1967 mddev->private = conf;
1968 if (!conf) 1974 if (!conf)
1969 goto out_no_mem; 1975 goto abort;
1970 1976
1971 conf->mirrors = kzalloc(sizeof(struct mirror_info)*mddev->raid_disks, 1977 conf->mirrors = kzalloc(sizeof(struct mirror_info)*mddev->raid_disks,
1972 GFP_KERNEL); 1978 GFP_KERNEL);
1973 if (!conf->mirrors) 1979 if (!conf->mirrors)
1974 goto out_no_mem; 1980 goto abort;
1975 1981
1976 conf->tmppage = alloc_page(GFP_KERNEL); 1982 conf->tmppage = alloc_page(GFP_KERNEL);
1977 if (!conf->tmppage) 1983 if (!conf->tmppage)
1978 goto out_no_mem; 1984 goto abort;
1979 1985
1980 conf->poolinfo = kmalloc(sizeof(*conf->poolinfo), GFP_KERNEL); 1986 conf->poolinfo = kzalloc(sizeof(*conf->poolinfo), GFP_KERNEL);
1981 if (!conf->poolinfo) 1987 if (!conf->poolinfo)
1982 goto out_no_mem; 1988 goto abort;
1983 conf->poolinfo->mddev = NULL;
1984 conf->poolinfo->raid_disks = mddev->raid_disks; 1989 conf->poolinfo->raid_disks = mddev->raid_disks;
1985 conf->r1bio_pool = mempool_create(NR_RAID1_BIOS, r1bio_pool_alloc, 1990 conf->r1bio_pool = mempool_create(NR_RAID1_BIOS, r1bio_pool_alloc,
1986 r1bio_pool_free, 1991 r1bio_pool_free,
1987 conf->poolinfo); 1992 conf->poolinfo);
1988 if (!conf->r1bio_pool) 1993 if (!conf->r1bio_pool)
1989 goto out_no_mem; 1994 goto abort;
1995
1990 conf->poolinfo->mddev = mddev; 1996 conf->poolinfo->mddev = mddev;
1991 1997
1992 spin_lock_init(&conf->device_lock); 1998 spin_lock_init(&conf->device_lock);
1993 mddev->queue->queue_lock = &conf->device_lock;
1994
1995 list_for_each_entry(rdev, &mddev->disks, same_set) { 1999 list_for_each_entry(rdev, &mddev->disks, same_set) {
1996 disk_idx = rdev->raid_disk; 2000 int disk_idx = rdev->raid_disk;
1997 if (disk_idx >= mddev->raid_disks 2001 if (disk_idx >= mddev->raid_disks
1998 || disk_idx < 0) 2002 || disk_idx < 0)
1999 continue; 2003 continue;
2000 disk = conf->mirrors + disk_idx; 2004 disk = conf->mirrors + disk_idx;
2001 2005
2002 disk->rdev = rdev; 2006 disk->rdev = rdev;
2003 disk_stack_limits(mddev->gendisk, rdev->bdev,
2004 rdev->data_offset << 9);
2005 /* as we don't honour merge_bvec_fn, we must never risk
2006 * violating it, so limit ->max_sector to one PAGE, as
2007 * a one page request is never in violation.
2008 */
2009 if (rdev->bdev->bd_disk->queue->merge_bvec_fn &&
2010 queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9))
2011 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
2012 2007
2013 disk->head_position = 0; 2008 disk->head_position = 0;
2014 } 2009 }
@@ -2022,8 +2017,7 @@ static int run(mddev_t *mddev)
2022 bio_list_init(&conf->pending_bio_list); 2017 bio_list_init(&conf->pending_bio_list);
2023 bio_list_init(&conf->flushing_bio_list); 2018 bio_list_init(&conf->flushing_bio_list);
2024 2019
2025 2020 conf->last_used = -1;
2026 mddev->degraded = 0;
2027 for (i = 0; i < conf->raid_disks; i++) { 2021 for (i = 0; i < conf->raid_disks; i++) {
2028 2022
2029 disk = conf->mirrors + i; 2023 disk = conf->mirrors + i;
@@ -2031,38 +2025,97 @@ static int run(mddev_t *mddev)
2031 if (!disk->rdev || 2025 if (!disk->rdev ||
2032 !test_bit(In_sync, &disk->rdev->flags)) { 2026 !test_bit(In_sync, &disk->rdev->flags)) {
2033 disk->head_position = 0; 2027 disk->head_position = 0;
2034 mddev->degraded++;
2035 if (disk->rdev) 2028 if (disk->rdev)
2036 conf->fullsync = 1; 2029 conf->fullsync = 1;
2037 } 2030 } else if (conf->last_used < 0)
2031 /*
2032 * The first working device is used as a
2033 * starting point to read balancing.
2034 */
2035 conf->last_used = i;
2038 } 2036 }
2039 if (mddev->degraded == conf->raid_disks) { 2037
2038 err = -EIO;
2039 if (conf->last_used < 0) {
2040 printk(KERN_ERR "raid1: no operational mirrors for %s\n", 2040 printk(KERN_ERR "raid1: no operational mirrors for %s\n",
2041 mdname(mddev)); 2041 mdname(mddev));
2042 goto out_free_conf; 2042 goto abort;
2043 } 2043 }
2044 if (conf->raid_disks - mddev->degraded == 1) 2044 err = -ENOMEM;
2045 mddev->recovery_cp = MaxSector; 2045 conf->thread = md_register_thread(raid1d, mddev, NULL);
2046 if (!conf->thread) {
2047 printk(KERN_ERR
2048 "raid1: couldn't allocate thread for %s\n",
2049 mdname(mddev));
2050 goto abort;
2051 }
2052
2053 return conf;
2054
2055 abort:
2056 if (conf) {
2057 if (conf->r1bio_pool)
2058 mempool_destroy(conf->r1bio_pool);
2059 kfree(conf->mirrors);
2060 safe_put_page(conf->tmppage);
2061 kfree(conf->poolinfo);
2062 kfree(conf);
2063 }
2064 return ERR_PTR(err);
2065}
2046 2066
2067static int run(mddev_t *mddev)
2068{
2069 conf_t *conf;
2070 int i;
2071 mdk_rdev_t *rdev;
2072
2073 if (mddev->level != 1) {
2074 printk("raid1: %s: raid level not set to mirroring (%d)\n",
2075 mdname(mddev), mddev->level);
2076 return -EIO;
2077 }
2078 if (mddev->reshape_position != MaxSector) {
2079 printk("raid1: %s: reshape_position set but not supported\n",
2080 mdname(mddev));
2081 return -EIO;
2082 }
2047 /* 2083 /*
2048 * find the first working one and use it as a starting point 2084 * copy the already verified devices into our private RAID1
2049 * to read balancing. 2085 * bookkeeping area. [whatever we allocate in run(),
2086 * should be freed in stop()]
2050 */ 2087 */
2051 for (j = 0; j < conf->raid_disks && 2088 if (mddev->private == NULL)
2052 (!conf->mirrors[j].rdev || 2089 conf = setup_conf(mddev);
2053 !test_bit(In_sync, &conf->mirrors[j].rdev->flags)) ; j++) 2090 else
2054 /* nothing */; 2091 conf = mddev->private;
2055 conf->last_used = j;
2056 2092
2093 if (IS_ERR(conf))
2094 return PTR_ERR(conf);
2057 2095
2058 mddev->thread = md_register_thread(raid1d, mddev, NULL); 2096 mddev->queue->queue_lock = &conf->device_lock;
2059 if (!mddev->thread) { 2097 list_for_each_entry(rdev, &mddev->disks, same_set) {
2060 printk(KERN_ERR 2098 disk_stack_limits(mddev->gendisk, rdev->bdev,
2061 "raid1: couldn't allocate thread for %s\n", 2099 rdev->data_offset << 9);
2062 mdname(mddev)); 2100 /* as we don't honour merge_bvec_fn, we must never risk
2063 goto out_free_conf; 2101 * violating it, so limit ->max_sector to one PAGE, as
2102 * a one page request is never in violation.
2103 */
2104 if (rdev->bdev->bd_disk->queue->merge_bvec_fn &&
2105 queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9))
2106 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
2064 } 2107 }
2065 2108
2109 mddev->degraded = 0;
2110 for (i=0; i < conf->raid_disks; i++)
2111 if (conf->mirrors[i].rdev == NULL ||
2112 !test_bit(In_sync, &conf->mirrors[i].rdev->flags) ||
2113 test_bit(Faulty, &conf->mirrors[i].rdev->flags))
2114 mddev->degraded++;
2115
2116 if (conf->raid_disks - mddev->degraded == 1)
2117 mddev->recovery_cp = MaxSector;
2118
2066 if (mddev->recovery_cp != MaxSector) 2119 if (mddev->recovery_cp != MaxSector)
2067 printk(KERN_NOTICE "raid1: %s is not clean" 2120 printk(KERN_NOTICE "raid1: %s is not clean"
2068 " -- starting background reconstruction\n", 2121 " -- starting background reconstruction\n",
@@ -2071,9 +2124,14 @@ static int run(mddev_t *mddev)
2071 "raid1: raid set %s active with %d out of %d mirrors\n", 2124 "raid1: raid set %s active with %d out of %d mirrors\n",
2072 mdname(mddev), mddev->raid_disks - mddev->degraded, 2125 mdname(mddev), mddev->raid_disks - mddev->degraded,
2073 mddev->raid_disks); 2126 mddev->raid_disks);
2127
2074 /* 2128 /*
2075 * Ok, everything is just fine now 2129 * Ok, everything is just fine now
2076 */ 2130 */
2131 mddev->thread = conf->thread;
2132 conf->thread = NULL;
2133 mddev->private = conf;
2134
2077 md_set_array_sectors(mddev, raid1_size(mddev, 0, 0)); 2135 md_set_array_sectors(mddev, raid1_size(mddev, 0, 0));
2078 2136
2079 mddev->queue->unplug_fn = raid1_unplug; 2137 mddev->queue->unplug_fn = raid1_unplug;
@@ -2081,23 +2139,6 @@ static int run(mddev_t *mddev)
2081 mddev->queue->backing_dev_info.congested_data = mddev; 2139 mddev->queue->backing_dev_info.congested_data = mddev;
2082 md_integrity_register(mddev); 2140 md_integrity_register(mddev);
2083 return 0; 2141 return 0;
2084
2085out_no_mem:
2086 printk(KERN_ERR "raid1: couldn't allocate memory for %s\n",
2087 mdname(mddev));
2088
2089out_free_conf:
2090 if (conf) {
2091 if (conf->r1bio_pool)
2092 mempool_destroy(conf->r1bio_pool);
2093 kfree(conf->mirrors);
2094 safe_put_page(conf->tmppage);
2095 kfree(conf->poolinfo);
2096 kfree(conf);
2097 mddev->private = NULL;
2098 }
2099out:
2100 return -EIO;
2101} 2142}
2102 2143
2103static int stop(mddev_t *mddev) 2144static int stop(mddev_t *mddev)
@@ -2271,6 +2312,9 @@ static void raid1_quiesce(mddev_t *mddev, int state)
2271 conf_t *conf = mddev->private; 2312 conf_t *conf = mddev->private;
2272 2313
2273 switch(state) { 2314 switch(state) {
2315 case 2: /* wake for suspend */
2316 wake_up(&conf->wait_barrier);
2317 break;
2274 case 1: 2318 case 1:
2275 raise_barrier(conf); 2319 raise_barrier(conf);
2276 break; 2320 break;
@@ -2280,6 +2324,23 @@ static void raid1_quiesce(mddev_t *mddev, int state)
2280 } 2324 }
2281} 2325}
2282 2326
2327static void *raid1_takeover(mddev_t *mddev)
2328{
2329 /* raid1 can take over:
2330 * raid5 with 2 devices, any layout or chunk size
2331 */
2332 if (mddev->level == 5 && mddev->raid_disks == 2) {
2333 conf_t *conf;
2334 mddev->new_level = 1;
2335 mddev->new_layout = 0;
2336 mddev->new_chunk_sectors = 0;
2337 conf = setup_conf(mddev);
2338 if (!IS_ERR(conf))
2339 conf->barrier = 1;
2340 return conf;
2341 }
2342 return ERR_PTR(-EINVAL);
2343}
2283 2344
2284static struct mdk_personality raid1_personality = 2345static struct mdk_personality raid1_personality =
2285{ 2346{
@@ -2299,6 +2360,7 @@ static struct mdk_personality raid1_personality =
2299 .size = raid1_size, 2360 .size = raid1_size,
2300 .check_reshape = raid1_reshape, 2361 .check_reshape = raid1_reshape,
2301 .quiesce = raid1_quiesce, 2362 .quiesce = raid1_quiesce,
2363 .takeover = raid1_takeover,
2302}; 2364};
2303 2365
2304static int __init raid_init(void) 2366static int __init raid_init(void)
@@ -2314,6 +2376,7 @@ static void raid_exit(void)
2314module_init(raid_init); 2376module_init(raid_init);
2315module_exit(raid_exit); 2377module_exit(raid_exit);
2316MODULE_LICENSE("GPL"); 2378MODULE_LICENSE("GPL");
2379MODULE_DESCRIPTION("RAID1 (mirroring) personality for MD");
2317MODULE_ALIAS("md-personality-3"); /* RAID1 */ 2380MODULE_ALIAS("md-personality-3"); /* RAID1 */
2318MODULE_ALIAS("md-raid1"); 2381MODULE_ALIAS("md-raid1");
2319MODULE_ALIAS("md-level-1"); 2382MODULE_ALIAS("md-level-1");
diff --git a/drivers/md/raid1.h b/drivers/md/raid1.h
index e87b84deff68..5f2d443ae28a 100644
--- a/drivers/md/raid1.h
+++ b/drivers/md/raid1.h
@@ -59,6 +59,11 @@ struct r1_private_data_s {
59 59
60 mempool_t *r1bio_pool; 60 mempool_t *r1bio_pool;
61 mempool_t *r1buf_pool; 61 mempool_t *r1buf_pool;
62
63 /* When taking over an array from a different personality, we store
64 * the new thread here until we fully activate the array.
65 */
66 struct mdk_thread_s *thread;
62}; 67};
63 68
64typedef struct r1_private_data_s conf_t; 69typedef struct r1_private_data_s conf_t;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index c2cb7b87b440..d119b7b75e71 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -804,7 +804,7 @@ static int make_request(struct request_queue *q, struct bio * bio)
804 mdk_rdev_t *blocked_rdev; 804 mdk_rdev_t *blocked_rdev;
805 805
806 if (unlikely(bio_rw_flagged(bio, BIO_RW_BARRIER))) { 806 if (unlikely(bio_rw_flagged(bio, BIO_RW_BARRIER))) {
807 bio_endio(bio, -EOPNOTSUPP); 807 md_barrier_request(mddev, bio);
808 return 0; 808 return 0;
809 } 809 }
810 810
@@ -1432,6 +1432,43 @@ static void recovery_request_write(mddev_t *mddev, r10bio_t *r10_bio)
1432 1432
1433 1433
1434/* 1434/*
1435 * Used by fix_read_error() to decay the per rdev read_errors.
1436 * We halve the read error count for every hour that has elapsed
1437 * since the last recorded read error.
1438 *
1439 */
1440static void check_decay_read_errors(mddev_t *mddev, mdk_rdev_t *rdev)
1441{
1442 struct timespec cur_time_mon;
1443 unsigned long hours_since_last;
1444 unsigned int read_errors = atomic_read(&rdev->read_errors);
1445
1446 ktime_get_ts(&cur_time_mon);
1447
1448 if (rdev->last_read_error.tv_sec == 0 &&
1449 rdev->last_read_error.tv_nsec == 0) {
1450 /* first time we've seen a read error */
1451 rdev->last_read_error = cur_time_mon;
1452 return;
1453 }
1454
1455 hours_since_last = (cur_time_mon.tv_sec -
1456 rdev->last_read_error.tv_sec) / 3600;
1457
1458 rdev->last_read_error = cur_time_mon;
1459
1460 /*
1461 * if hours_since_last is > the number of bits in read_errors
1462 * just set read errors to 0. We do this to avoid
1463 * overflowing the shift of read_errors by hours_since_last.
1464 */
1465 if (hours_since_last >= 8 * sizeof(read_errors))
1466 atomic_set(&rdev->read_errors, 0);
1467 else
1468 atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
1469}
1470
1471/*
1435 * This is a kernel thread which: 1472 * This is a kernel thread which:
1436 * 1473 *
1437 * 1. Retries failed read operations on working mirrors. 1474 * 1. Retries failed read operations on working mirrors.
@@ -1444,6 +1481,43 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
1444 int sect = 0; /* Offset from r10_bio->sector */ 1481 int sect = 0; /* Offset from r10_bio->sector */
1445 int sectors = r10_bio->sectors; 1482 int sectors = r10_bio->sectors;
1446 mdk_rdev_t*rdev; 1483 mdk_rdev_t*rdev;
1484 int max_read_errors = atomic_read(&mddev->max_corr_read_errors);
1485
1486 rcu_read_lock();
1487 {
1488 int d = r10_bio->devs[r10_bio->read_slot].devnum;
1489 char b[BDEVNAME_SIZE];
1490 int cur_read_error_count = 0;
1491
1492 rdev = rcu_dereference(conf->mirrors[d].rdev);
1493 bdevname(rdev->bdev, b);
1494
1495 if (test_bit(Faulty, &rdev->flags)) {
1496 rcu_read_unlock();
1497 /* drive has already been failed, just ignore any
1498 more fix_read_error() attempts */
1499 return;
1500 }
1501
1502 check_decay_read_errors(mddev, rdev);
1503 atomic_inc(&rdev->read_errors);
1504 cur_read_error_count = atomic_read(&rdev->read_errors);
1505 if (cur_read_error_count > max_read_errors) {
1506 rcu_read_unlock();
1507 printk(KERN_NOTICE
1508 "raid10: %s: Raid device exceeded "
1509 "read_error threshold "
1510 "[cur %d:max %d]\n",
1511 b, cur_read_error_count, max_read_errors);
1512 printk(KERN_NOTICE
1513 "raid10: %s: Failing raid "
1514 "device\n", b);
1515 md_error(mddev, conf->mirrors[d].rdev);
1516 return;
1517 }
1518 }
1519 rcu_read_unlock();
1520
1447 while(sectors) { 1521 while(sectors) {
1448 int s = sectors; 1522 int s = sectors;
1449 int sl = r10_bio->read_slot; 1523 int sl = r10_bio->read_slot;
@@ -1488,6 +1562,7 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
1488 /* write it back and re-read */ 1562 /* write it back and re-read */
1489 rcu_read_lock(); 1563 rcu_read_lock();
1490 while (sl != r10_bio->read_slot) { 1564 while (sl != r10_bio->read_slot) {
1565 char b[BDEVNAME_SIZE];
1491 int d; 1566 int d;
1492 if (sl==0) 1567 if (sl==0)
1493 sl = conf->copies; 1568 sl = conf->copies;
@@ -1503,9 +1578,21 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
1503 r10_bio->devs[sl].addr + 1578 r10_bio->devs[sl].addr +
1504 sect + rdev->data_offset, 1579 sect + rdev->data_offset,
1505 s<<9, conf->tmppage, WRITE) 1580 s<<9, conf->tmppage, WRITE)
1506 == 0) 1581 == 0) {
1507 /* Well, this device is dead */ 1582 /* Well, this device is dead */
1583 printk(KERN_NOTICE
1584 "raid10:%s: read correction "
1585 "write failed"
1586 " (%d sectors at %llu on %s)\n",
1587 mdname(mddev), s,
1588 (unsigned long long)(sect+
1589 rdev->data_offset),
1590 bdevname(rdev->bdev, b));
1591 printk(KERN_NOTICE "raid10:%s: failing "
1592 "drive\n",
1593 bdevname(rdev->bdev, b));
1508 md_error(mddev, rdev); 1594 md_error(mddev, rdev);
1595 }
1509 rdev_dec_pending(rdev, mddev); 1596 rdev_dec_pending(rdev, mddev);
1510 rcu_read_lock(); 1597 rcu_read_lock();
1511 } 1598 }
@@ -1526,10 +1613,22 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
1526 if (sync_page_io(rdev->bdev, 1613 if (sync_page_io(rdev->bdev,
1527 r10_bio->devs[sl].addr + 1614 r10_bio->devs[sl].addr +
1528 sect + rdev->data_offset, 1615 sect + rdev->data_offset,
1529 s<<9, conf->tmppage, READ) == 0) 1616 s<<9, conf->tmppage,
1617 READ) == 0) {
1530 /* Well, this device is dead */ 1618 /* Well, this device is dead */
1619 printk(KERN_NOTICE
1620 "raid10:%s: unable to read back "
1621 "corrected sectors"
1622 " (%d sectors at %llu on %s)\n",
1623 mdname(mddev), s,
1624 (unsigned long long)(sect+
1625 rdev->data_offset),
1626 bdevname(rdev->bdev, b));
1627 printk(KERN_NOTICE "raid10:%s: failing drive\n",
1628 bdevname(rdev->bdev, b));
1629
1531 md_error(mddev, rdev); 1630 md_error(mddev, rdev);
1532 else 1631 } else {
1533 printk(KERN_INFO 1632 printk(KERN_INFO
1534 "raid10:%s: read error corrected" 1633 "raid10:%s: read error corrected"
1535 " (%d sectors at %llu on %s)\n", 1634 " (%d sectors at %llu on %s)\n",
@@ -1537,6 +1636,7 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
1537 (unsigned long long)(sect+ 1636 (unsigned long long)(sect+
1538 rdev->data_offset), 1637 rdev->data_offset),
1539 bdevname(rdev->bdev, b)); 1638 bdevname(rdev->bdev, b));
1639 }
1540 1640
1541 rdev_dec_pending(rdev, mddev); 1641 rdev_dec_pending(rdev, mddev);
1542 rcu_read_lock(); 1642 rcu_read_lock();
@@ -2275,13 +2375,6 @@ static void raid10_quiesce(mddev_t *mddev, int state)
2275 lower_barrier(conf); 2375 lower_barrier(conf);
2276 break; 2376 break;
2277 } 2377 }
2278 if (mddev->thread) {
2279 if (mddev->bitmap)
2280 mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
2281 else
2282 mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT;
2283 md_wakeup_thread(mddev->thread);
2284 }
2285} 2378}
2286 2379
2287static struct mdk_personality raid10_personality = 2380static struct mdk_personality raid10_personality =
@@ -2315,6 +2408,7 @@ static void raid_exit(void)
2315module_init(raid_init); 2408module_init(raid_init);
2316module_exit(raid_exit); 2409module_exit(raid_exit);
2317MODULE_LICENSE("GPL"); 2410MODULE_LICENSE("GPL");
2411MODULE_DESCRIPTION("RAID10 (striped mirror) personality for MD");
2318MODULE_ALIAS("md-personality-9"); /* RAID10 */ 2412MODULE_ALIAS("md-personality-9"); /* RAID10 */
2319MODULE_ALIAS("md-raid10"); 2413MODULE_ALIAS("md-raid10");
2320MODULE_ALIAS("md-level-10"); 2414MODULE_ALIAS("md-level-10");
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index d29215d966da..e84204eb12df 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2947,6 +2947,7 @@ static void handle_stripe5(struct stripe_head *sh)
2947 struct r5dev *dev; 2947 struct r5dev *dev;
2948 mdk_rdev_t *blocked_rdev = NULL; 2948 mdk_rdev_t *blocked_rdev = NULL;
2949 int prexor; 2949 int prexor;
2950 int dec_preread_active = 0;
2950 2951
2951 memset(&s, 0, sizeof(s)); 2952 memset(&s, 0, sizeof(s));
2952 pr_debug("handling stripe %llu, state=%#lx cnt=%d, pd_idx=%d check:%d " 2953 pr_debug("handling stripe %llu, state=%#lx cnt=%d, pd_idx=%d check:%d "
@@ -3096,12 +3097,8 @@ static void handle_stripe5(struct stripe_head *sh)
3096 set_bit(STRIPE_INSYNC, &sh->state); 3097 set_bit(STRIPE_INSYNC, &sh->state);
3097 } 3098 }
3098 } 3099 }
3099 if (test_and_clear_bit(STRIPE_PREREAD_ACTIVE, &sh->state)) { 3100 if (test_and_clear_bit(STRIPE_PREREAD_ACTIVE, &sh->state))
3100 atomic_dec(&conf->preread_active_stripes); 3101 dec_preread_active = 1;
3101 if (atomic_read(&conf->preread_active_stripes) <
3102 IO_THRESHOLD)
3103 md_wakeup_thread(conf->mddev->thread);
3104 }
3105 } 3102 }
3106 3103
3107 /* Now to consider new write requests and what else, if anything 3104 /* Now to consider new write requests and what else, if anything
@@ -3208,6 +3205,16 @@ static void handle_stripe5(struct stripe_head *sh)
3208 3205
3209 ops_run_io(sh, &s); 3206 ops_run_io(sh, &s);
3210 3207
3208 if (dec_preread_active) {
3209 /* We delay this until after ops_run_io so that if make_request
3210 * is waiting on a barrier, it won't continue until the writes
3211 * have actually been submitted.
3212 */
3213 atomic_dec(&conf->preread_active_stripes);
3214 if (atomic_read(&conf->preread_active_stripes) <
3215 IO_THRESHOLD)
3216 md_wakeup_thread(conf->mddev->thread);
3217 }
3211 return_io(return_bi); 3218 return_io(return_bi);
3212} 3219}
3213 3220
@@ -3221,6 +3228,7 @@ static void handle_stripe6(struct stripe_head *sh)
3221 struct r6_state r6s; 3228 struct r6_state r6s;
3222 struct r5dev *dev, *pdev, *qdev; 3229 struct r5dev *dev, *pdev, *qdev;
3223 mdk_rdev_t *blocked_rdev = NULL; 3230 mdk_rdev_t *blocked_rdev = NULL;
3231 int dec_preread_active = 0;
3224 3232
3225 pr_debug("handling stripe %llu, state=%#lx cnt=%d, " 3233 pr_debug("handling stripe %llu, state=%#lx cnt=%d, "
3226 "pd_idx=%d, qd_idx=%d\n, check:%d, reconstruct:%d\n", 3234 "pd_idx=%d, qd_idx=%d\n, check:%d, reconstruct:%d\n",
@@ -3358,7 +3366,6 @@ static void handle_stripe6(struct stripe_head *sh)
3358 * completed 3366 * completed
3359 */ 3367 */
3360 if (sh->reconstruct_state == reconstruct_state_drain_result) { 3368 if (sh->reconstruct_state == reconstruct_state_drain_result) {
3361 int qd_idx = sh->qd_idx;
3362 3369
3363 sh->reconstruct_state = reconstruct_state_idle; 3370 sh->reconstruct_state = reconstruct_state_idle;
3364 /* All the 'written' buffers and the parity blocks are ready to 3371 /* All the 'written' buffers and the parity blocks are ready to
@@ -3380,12 +3387,8 @@ static void handle_stripe6(struct stripe_head *sh)
3380 set_bit(STRIPE_INSYNC, &sh->state); 3387 set_bit(STRIPE_INSYNC, &sh->state);
3381 } 3388 }
3382 } 3389 }
3383 if (test_and_clear_bit(STRIPE_PREREAD_ACTIVE, &sh->state)) { 3390 if (test_and_clear_bit(STRIPE_PREREAD_ACTIVE, &sh->state))
3384 atomic_dec(&conf->preread_active_stripes); 3391 dec_preread_active = 1;
3385 if (atomic_read(&conf->preread_active_stripes) <
3386 IO_THRESHOLD)
3387 md_wakeup_thread(conf->mddev->thread);
3388 }
3389 } 3392 }
3390 3393
3391 /* Now to consider new write requests and what else, if anything 3394 /* Now to consider new write requests and what else, if anything
@@ -3494,6 +3497,18 @@ static void handle_stripe6(struct stripe_head *sh)
3494 3497
3495 ops_run_io(sh, &s); 3498 ops_run_io(sh, &s);
3496 3499
3500
3501 if (dec_preread_active) {
3502 /* We delay this until after ops_run_io so that if make_request
3503 * is waiting on a barrier, it won't continue until the writes
3504 * have actually been submitted.
3505 */
3506 atomic_dec(&conf->preread_active_stripes);
3507 if (atomic_read(&conf->preread_active_stripes) <
3508 IO_THRESHOLD)
3509 md_wakeup_thread(conf->mddev->thread);
3510 }
3511
3497 return_io(return_bi); 3512 return_io(return_bi);
3498} 3513}
3499 3514
@@ -3741,7 +3756,7 @@ static int chunk_aligned_read(struct request_queue *q, struct bio * raid_bio)
3741{ 3756{
3742 mddev_t *mddev = q->queuedata; 3757 mddev_t *mddev = q->queuedata;
3743 raid5_conf_t *conf = mddev->private; 3758 raid5_conf_t *conf = mddev->private;
3744 unsigned int dd_idx; 3759 int dd_idx;
3745 struct bio* align_bi; 3760 struct bio* align_bi;
3746 mdk_rdev_t *rdev; 3761 mdk_rdev_t *rdev;
3747 3762
@@ -3866,7 +3881,13 @@ static int make_request(struct request_queue *q, struct bio * bi)
3866 int cpu, remaining; 3881 int cpu, remaining;
3867 3882
3868 if (unlikely(bio_rw_flagged(bi, BIO_RW_BARRIER))) { 3883 if (unlikely(bio_rw_flagged(bi, BIO_RW_BARRIER))) {
3869 bio_endio(bi, -EOPNOTSUPP); 3884 /* Drain all pending writes. We only really need
3885 * to ensure they have been submitted, but this is
3886 * easier.
3887 */
3888 mddev->pers->quiesce(mddev, 1);
3889 mddev->pers->quiesce(mddev, 0);
3890 md_barrier_request(mddev, bi);
3870 return 0; 3891 return 0;
3871 } 3892 }
3872 3893
@@ -3990,6 +4011,9 @@ static int make_request(struct request_queue *q, struct bio * bi)
3990 finish_wait(&conf->wait_for_overlap, &w); 4011 finish_wait(&conf->wait_for_overlap, &w);
3991 set_bit(STRIPE_HANDLE, &sh->state); 4012 set_bit(STRIPE_HANDLE, &sh->state);
3992 clear_bit(STRIPE_DELAYED, &sh->state); 4013 clear_bit(STRIPE_DELAYED, &sh->state);
4014 if (mddev->barrier &&
4015 !test_and_set_bit(STRIPE_PREREAD_ACTIVE, &sh->state))
4016 atomic_inc(&conf->preread_active_stripes);
3993 release_stripe(sh); 4017 release_stripe(sh);
3994 } else { 4018 } else {
3995 /* cannot get stripe for read-ahead, just give-up */ 4019 /* cannot get stripe for read-ahead, just give-up */
@@ -4009,6 +4033,14 @@ static int make_request(struct request_queue *q, struct bio * bi)
4009 4033
4010 bio_endio(bi, 0); 4034 bio_endio(bi, 0);
4011 } 4035 }
4036
4037 if (mddev->barrier) {
4038 /* We need to wait for the stripes to all be handled.
4039 * So: wait for preread_active_stripes to drop to 0.
4040 */
4041 wait_event(mddev->thread->wqueue,
4042 atomic_read(&conf->preread_active_stripes) == 0);
4043 }
4012 return 0; 4044 return 0;
4013} 4045}
4014 4046
@@ -5860,6 +5892,7 @@ static void raid5_exit(void)
5860module_init(raid5_init); 5892module_init(raid5_init);
5861module_exit(raid5_exit); 5893module_exit(raid5_exit);
5862MODULE_LICENSE("GPL"); 5894MODULE_LICENSE("GPL");
5895MODULE_DESCRIPTION("RAID4/5/6 (striping with parity) personality for MD");
5863MODULE_ALIAS("md-personality-4"); /* RAID5 */ 5896MODULE_ALIAS("md-personality-4"); /* RAID5 */
5864MODULE_ALIAS("md-raid5"); 5897MODULE_ALIAS("md-raid5");
5865MODULE_ALIAS("md-raid4"); 5898MODULE_ALIAS("md-raid4");
diff --git a/drivers/md/raid6algos.c b/drivers/md/raid6algos.c
index 866215ac7f25..bffc61bff5ab 100644
--- a/drivers/md/raid6algos.c
+++ b/drivers/md/raid6algos.c
@@ -31,25 +31,6 @@ EXPORT_SYMBOL(raid6_empty_zero_page);
31struct raid6_calls raid6_call; 31struct raid6_calls raid6_call;
32EXPORT_SYMBOL_GPL(raid6_call); 32EXPORT_SYMBOL_GPL(raid6_call);
33 33
34/* Various routine sets */
35extern const struct raid6_calls raid6_intx1;
36extern const struct raid6_calls raid6_intx2;
37extern const struct raid6_calls raid6_intx4;
38extern const struct raid6_calls raid6_intx8;
39extern const struct raid6_calls raid6_intx16;
40extern const struct raid6_calls raid6_intx32;
41extern const struct raid6_calls raid6_mmxx1;
42extern const struct raid6_calls raid6_mmxx2;
43extern const struct raid6_calls raid6_sse1x1;
44extern const struct raid6_calls raid6_sse1x2;
45extern const struct raid6_calls raid6_sse2x1;
46extern const struct raid6_calls raid6_sse2x2;
47extern const struct raid6_calls raid6_sse2x4;
48extern const struct raid6_calls raid6_altivec1;
49extern const struct raid6_calls raid6_altivec2;
50extern const struct raid6_calls raid6_altivec4;
51extern const struct raid6_calls raid6_altivec8;
52
53const struct raid6_calls * const raid6_algos[] = { 34const struct raid6_calls * const raid6_algos[] = {
54 &raid6_intx1, 35 &raid6_intx1,
55 &raid6_intx2, 36 &raid6_intx2,
@@ -169,3 +150,4 @@ static void raid6_exit(void)
169subsys_initcall(raid6_select_algo); 150subsys_initcall(raid6_select_algo);
170module_exit(raid6_exit); 151module_exit(raid6_exit);
171MODULE_LICENSE("GPL"); 152MODULE_LICENSE("GPL");
153MODULE_DESCRIPTION("RAID6 Q-syndrome calculations");
diff --git a/drivers/mfd/88pm8607.c b/drivers/mfd/88pm8607.c
new file mode 100644
index 000000000000..7e3f65907993
--- /dev/null
+++ b/drivers/mfd/88pm8607.c
@@ -0,0 +1,302 @@
1/*
2 * Base driver for Marvell 88PM8607
3 *
4 * Copyright (C) 2009 Marvell International Ltd.
5 * Haojian Zhuang <haojian.zhuang@marvell.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/kernel.h>
13#include <linux/module.h>
14#include <linux/interrupt.h>
15#include <linux/platform_device.h>
16#include <linux/i2c.h>
17#include <linux/mfd/core.h>
18#include <linux/mfd/88pm8607.h>
19
20
21#define PM8607_REG_RESOURCE(_start, _end) \
22{ \
23 .start = PM8607_##_start, \
24 .end = PM8607_##_end, \
25 .flags = IORESOURCE_IO, \
26}
27
28static struct resource pm8607_regulator_resources[] = {
29 PM8607_REG_RESOURCE(BUCK1, BUCK1),
30 PM8607_REG_RESOURCE(BUCK2, BUCK2),
31 PM8607_REG_RESOURCE(BUCK3, BUCK3),
32 PM8607_REG_RESOURCE(LDO1, LDO1),
33 PM8607_REG_RESOURCE(LDO2, LDO2),
34 PM8607_REG_RESOURCE(LDO3, LDO3),
35 PM8607_REG_RESOURCE(LDO4, LDO4),
36 PM8607_REG_RESOURCE(LDO5, LDO5),
37 PM8607_REG_RESOURCE(LDO6, LDO6),
38 PM8607_REG_RESOURCE(LDO7, LDO7),
39 PM8607_REG_RESOURCE(LDO8, LDO8),
40 PM8607_REG_RESOURCE(LDO9, LDO9),
41 PM8607_REG_RESOURCE(LDO10, LDO10),
42 PM8607_REG_RESOURCE(LDO12, LDO12),
43 PM8607_REG_RESOURCE(LDO14, LDO14),
44};
45
46#define PM8607_REG_DEVS(_name, _id) \
47{ \
48 .name = "88pm8607-" #_name, \
49 .num_resources = 1, \
50 .resources = &pm8607_regulator_resources[PM8607_ID_##_id], \
51}
52
53static struct mfd_cell pm8607_devs[] = {
54 PM8607_REG_DEVS(buck1, BUCK1),
55 PM8607_REG_DEVS(buck2, BUCK2),
56 PM8607_REG_DEVS(buck3, BUCK3),
57 PM8607_REG_DEVS(ldo1, LDO1),
58 PM8607_REG_DEVS(ldo2, LDO2),
59 PM8607_REG_DEVS(ldo3, LDO3),
60 PM8607_REG_DEVS(ldo4, LDO4),
61 PM8607_REG_DEVS(ldo5, LDO5),
62 PM8607_REG_DEVS(ldo6, LDO6),
63 PM8607_REG_DEVS(ldo7, LDO7),
64 PM8607_REG_DEVS(ldo8, LDO8),
65 PM8607_REG_DEVS(ldo9, LDO9),
66 PM8607_REG_DEVS(ldo10, LDO10),
67 PM8607_REG_DEVS(ldo12, LDO12),
68 PM8607_REG_DEVS(ldo14, LDO14),
69};
70
71static inline int pm8607_read_device(struct pm8607_chip *chip,
72 int reg, int bytes, void *dest)
73{
74 struct i2c_client *i2c = chip->client;
75 unsigned char data;
76 int ret;
77
78 data = (unsigned char)reg;
79 ret = i2c_master_send(i2c, &data, 1);
80 if (ret < 0)
81 return ret;
82
83 ret = i2c_master_recv(i2c, dest, bytes);
84 if (ret < 0)
85 return ret;
86 return 0;
87}
88
89static inline int pm8607_write_device(struct pm8607_chip *chip,
90 int reg, int bytes, void *src)
91{
92 struct i2c_client *i2c = chip->client;
93 unsigned char buf[bytes + 1];
94 int ret;
95
96 buf[0] = (unsigned char)reg;
97 memcpy(&buf[1], src, bytes);
98
99 ret = i2c_master_send(i2c, buf, bytes + 1);
100 if (ret < 0)
101 return ret;
102 return 0;
103}
104
105int pm8607_reg_read(struct pm8607_chip *chip, int reg)
106{
107 unsigned char data;
108 int ret;
109
110 mutex_lock(&chip->io_lock);
111 ret = chip->read(chip, reg, 1, &data);
112 mutex_unlock(&chip->io_lock);
113
114 if (ret < 0)
115 return ret;
116 else
117 return (int)data;
118}
119EXPORT_SYMBOL(pm8607_reg_read);
120
121int pm8607_reg_write(struct pm8607_chip *chip, int reg,
122 unsigned char data)
123{
124 int ret;
125
126 mutex_lock(&chip->io_lock);
127 ret = chip->write(chip, reg, 1, &data);
128 mutex_unlock(&chip->io_lock);
129
130 return ret;
131}
132EXPORT_SYMBOL(pm8607_reg_write);
133
134int pm8607_bulk_read(struct pm8607_chip *chip, int reg,
135 int count, unsigned char *buf)
136{
137 int ret;
138
139 mutex_lock(&chip->io_lock);
140 ret = chip->read(chip, reg, count, buf);
141 mutex_unlock(&chip->io_lock);
142
143 return ret;
144}
145EXPORT_SYMBOL(pm8607_bulk_read);
146
147int pm8607_bulk_write(struct pm8607_chip *chip, int reg,
148 int count, unsigned char *buf)
149{
150 int ret;
151
152 mutex_lock(&chip->io_lock);
153 ret = chip->write(chip, reg, count, buf);
154 mutex_unlock(&chip->io_lock);
155
156 return ret;
157}
158EXPORT_SYMBOL(pm8607_bulk_write);
159
160int pm8607_set_bits(struct pm8607_chip *chip, int reg,
161 unsigned char mask, unsigned char data)
162{
163 unsigned char value;
164 int ret;
165
166 mutex_lock(&chip->io_lock);
167 ret = chip->read(chip, reg, 1, &value);
168 if (ret < 0)
169 goto out;
170 value &= ~mask;
171 value |= data;
172 ret = chip->write(chip, reg, 1, &value);
173out:
174 mutex_unlock(&chip->io_lock);
175 return ret;
176}
177EXPORT_SYMBOL(pm8607_set_bits);
178
179
180static const struct i2c_device_id pm8607_id_table[] = {
181 { "88PM8607", 0 },
182 {}
183};
184MODULE_DEVICE_TABLE(i2c, pm8607_id_table);
185
186
187static int __devinit pm8607_probe(struct i2c_client *client,
188 const struct i2c_device_id *id)
189{
190 struct pm8607_platform_data *pdata = client->dev.platform_data;
191 struct pm8607_chip *chip;
192 int i, count;
193 int ret;
194
195 chip = kzalloc(sizeof(struct pm8607_chip), GFP_KERNEL);
196 if (chip == NULL)
197 return -ENOMEM;
198
199 chip->client = client;
200 chip->dev = &client->dev;
201 chip->read = pm8607_read_device;
202 chip->write = pm8607_write_device;
203 i2c_set_clientdata(client, chip);
204
205 mutex_init(&chip->io_lock);
206 dev_set_drvdata(chip->dev, chip);
207
208 ret = pm8607_reg_read(chip, PM8607_CHIP_ID);
209 if (ret < 0) {
210 dev_err(chip->dev, "Failed to read CHIP ID: %d\n", ret);
211 goto out;
212 }
213 if ((ret & CHIP_ID_MASK) == CHIP_ID)
214 dev_info(chip->dev, "Marvell 88PM8607 (ID: %02x) detected\n",
215 ret);
216 else {
217 dev_err(chip->dev, "Failed to detect Marvell 88PM8607. "
218 "Chip ID: %02x\n", ret);
219 goto out;
220 }
221 chip->chip_id = ret;
222
223 ret = pm8607_reg_read(chip, PM8607_BUCK3);
224 if (ret < 0) {
225 dev_err(chip->dev, "Failed to read BUCK3 register: %d\n", ret);
226 goto out;
227 }
228 if (ret & PM8607_BUCK3_DOUBLE)
229 chip->buck3_double = 1;
230
231 ret = pm8607_reg_read(chip, PM8607_MISC1);
232 if (ret < 0) {
233 dev_err(chip->dev, "Failed to read MISC1 register: %d\n", ret);
234 goto out;
235 }
236 if (pdata->i2c_port == PI2C_PORT)
237 ret |= PM8607_MISC1_PI2C;
238 else
239 ret &= ~PM8607_MISC1_PI2C;
240 ret = pm8607_reg_write(chip, PM8607_MISC1, ret);
241 if (ret < 0) {
242 dev_err(chip->dev, "Failed to write MISC1 register: %d\n", ret);
243 goto out;
244 }
245
246
247 count = ARRAY_SIZE(pm8607_devs);
248 for (i = 0; i < count; i++) {
249 ret = mfd_add_devices(chip->dev, i, &pm8607_devs[i],
250 1, NULL, 0);
251 if (ret != 0) {
252 dev_err(chip->dev, "Failed to add subdevs\n");
253 goto out;
254 }
255 }
256
257 return 0;
258
259out:
260 i2c_set_clientdata(client, NULL);
261 kfree(chip);
262 return ret;
263}
264
265static int __devexit pm8607_remove(struct i2c_client *client)
266{
267 struct pm8607_chip *chip = i2c_get_clientdata(client);
268
269 mfd_remove_devices(chip->dev);
270 kfree(chip);
271 return 0;
272}
273
274static struct i2c_driver pm8607_driver = {
275 .driver = {
276 .name = "88PM8607",
277 .owner = THIS_MODULE,
278 },
279 .probe = pm8607_probe,
280 .remove = __devexit_p(pm8607_remove),
281 .id_table = pm8607_id_table,
282};
283
284static int __init pm8607_init(void)
285{
286 int ret;
287 ret = i2c_add_driver(&pm8607_driver);
288 if (ret != 0)
289 pr_err("Failed to register 88PM8607 I2C driver: %d\n", ret);
290 return ret;
291}
292subsys_initcall(pm8607_init);
293
294static void __exit pm8607_exit(void)
295{
296 i2c_del_driver(&pm8607_driver);
297}
298module_exit(pm8607_exit);
299
300MODULE_DESCRIPTION("PMIC Driver for Marvell 88PM8607");
301MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
302MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index a296e717e86e..87829789243e 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -103,10 +103,10 @@ config MENELAUS
103 cell phones and PDAs. 103 cell phones and PDAs.
104 104
105config TWL4030_CORE 105config TWL4030_CORE
106 bool "Texas Instruments TWL4030/TPS659x0 Support" 106 bool "Texas Instruments TWL4030/TWL5030/TWL6030/TPS659x0 Support"
107 depends on I2C=y && GENERIC_HARDIRQS 107 depends on I2C=y && GENERIC_HARDIRQS
108 help 108 help
109 Say yes here if you have TWL4030 family chip on your board. 109 Say yes here if you have TWL4030 / TWL6030 family chip on your board.
110 This core driver provides register access and IRQ handling 110 This core driver provides register access and IRQ handling
111 facilities, and registers devices for the various functions 111 facilities, and registers devices for the various functions
112 so that function-specific drivers can bind to them. 112 so that function-specific drivers can bind to them.
@@ -174,6 +174,16 @@ config PMIC_DA903X
174 individual components like LCD backlight, voltage regulators, 174 individual components like LCD backlight, voltage regulators,
175 LEDs and battery-charger under the corresponding menus. 175 LEDs and battery-charger under the corresponding menus.
176 176
177config PMIC_ADP5520
178 bool "Analog Devices ADP5520/01 MFD PMIC Core Support"
179 depends on I2C=y
180 help
181 Say yes here to add support for Analog Devices AD5520 and ADP5501,
182 Multifunction Power Management IC. This includes
183 the I2C driver and the core APIs _only_, you have to select
184 individual components like LCD backlight, LEDs, GPIOs and Kepad
185 under the corresponding menus.
186
177config MFD_WM8400 187config MFD_WM8400
178 tristate "Support Wolfson Microelectronics WM8400" 188 tristate "Support Wolfson Microelectronics WM8400"
179 select MFD_CORE 189 select MFD_CORE
@@ -185,12 +195,12 @@ config MFD_WM8400
185 the functionality of the device. 195 the functionality of the device.
186 196
187config MFD_WM831X 197config MFD_WM831X
188 tristate "Support Wolfson Microelectronics WM831x PMICs" 198 bool "Support Wolfson Microelectronics WM831x/2x PMICs"
189 select MFD_CORE 199 select MFD_CORE
190 depends on I2C 200 depends on I2C=y
191 help 201 help
192 Support for the Wolfson Microelecronics WM831x PMICs. This 202 Support for the Wolfson Microelecronics WM831x and WM832x PMICs.
193 driver provides common support for accessing the device, 203 This driver provides common support for accessing the device,
194 additional drivers must be enabled in order to use the 204 additional drivers must be enabled in order to use the
195 functionality of the device. 205 functionality of the device.
196 206
@@ -319,6 +329,25 @@ config EZX_PCAP
319 This enables the PCAP ASIC present on EZX Phones. This is 329 This enables the PCAP ASIC present on EZX Phones. This is
320 needed for MMC, TouchScreen, Sound, USB, etc.. 330 needed for MMC, TouchScreen, Sound, USB, etc..
321 331
332config MFD_88PM8607
333 bool "Support Marvell 88PM8607"
334 depends on I2C=y
335 select MFD_CORE
336 help
337 This supports for Marvell 88PM8607 Power Management IC. This includes
338 the I2C driver and the core APIs _only_, you have to select
339 individual components like voltage regulators, RTC and
340 battery-charger under the corresponding menus.
341
342config AB4500_CORE
343 tristate "ST-Ericsson's AB4500 Mixed Signal Power management chip"
344 depends on SPI
345 help
346 Select this option to enable access to AB4500 power management
347 chip. This connects to U8500 on the SSP/SPI bus and exports
348 read/write functions for the devices to get access to this chip.
349 This chip embeds various other multimedia funtionalities as well.
350
322endmenu 351endmenu
323 352
324menu "Multimedia Capabilities Port drivers" 353menu "Multimedia Capabilities Port drivers"
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 11350c1d9301..ca2f2c4ff05e 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -19,13 +19,14 @@ obj-$(CONFIG_MFD_WM8400) += wm8400-core.o
19wm831x-objs := wm831x-core.o wm831x-irq.o wm831x-otp.o 19wm831x-objs := wm831x-core.o wm831x-irq.o wm831x-otp.o
20obj-$(CONFIG_MFD_WM831X) += wm831x.o 20obj-$(CONFIG_MFD_WM831X) += wm831x.o
21wm8350-objs := wm8350-core.o wm8350-regmap.o wm8350-gpio.o 21wm8350-objs := wm8350-core.o wm8350-regmap.o wm8350-gpio.o
22wm8350-objs += wm8350-irq.o
22obj-$(CONFIG_MFD_WM8350) += wm8350.o 23obj-$(CONFIG_MFD_WM8350) += wm8350.o
23obj-$(CONFIG_MFD_WM8350_I2C) += wm8350-i2c.o 24obj-$(CONFIG_MFD_WM8350_I2C) += wm8350-i2c.o
24 25
25obj-$(CONFIG_TPS65010) += tps65010.o 26obj-$(CONFIG_TPS65010) += tps65010.o
26obj-$(CONFIG_MENELAUS) += menelaus.o 27obj-$(CONFIG_MENELAUS) += menelaus.o
27 28
28obj-$(CONFIG_TWL4030_CORE) += twl4030-core.o twl4030-irq.o 29obj-$(CONFIG_TWL4030_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o
29obj-$(CONFIG_TWL4030_POWER) += twl4030-power.o 30obj-$(CONFIG_TWL4030_POWER) += twl4030-power.o
30obj-$(CONFIG_TWL4030_CODEC) += twl4030-codec.o 31obj-$(CONFIG_TWL4030_CODEC) += twl4030-codec.o
31 32
@@ -52,3 +53,6 @@ obj-$(CONFIG_PCF50633_ADC) += pcf50633-adc.o
52obj-$(CONFIG_PCF50633_GPIO) += pcf50633-gpio.o 53obj-$(CONFIG_PCF50633_GPIO) += pcf50633-gpio.o
53obj-$(CONFIG_AB3100_CORE) += ab3100-core.o 54obj-$(CONFIG_AB3100_CORE) += ab3100-core.o
54obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o 55obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o
56obj-$(CONFIG_AB4500_CORE) += ab4500-core.o
57obj-$(CONFIG_MFD_88PM8607) += 88pm8607.o
58obj-$(CONFIG_PMIC_ADP5520) += adp5520.o \ No newline at end of file
diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c
index 613481028272..fd42a80e7bf9 100644
--- a/drivers/mfd/ab3100-core.c
+++ b/drivers/mfd/ab3100-core.c
@@ -900,9 +900,6 @@ static int __init ab3100_probe(struct i2c_client *client,
900 goto exit_no_testreg_client; 900 goto exit_no_testreg_client;
901 } 901 }
902 902
903 strlcpy(ab3100->testreg_client->name, id->name,
904 sizeof(ab3100->testreg_client->name));
905
906 err = ab3100_setup(ab3100); 903 err = ab3100_setup(ab3100);
907 if (err) 904 if (err)
908 goto exit_no_setup; 905 goto exit_no_setup;
diff --git a/drivers/mfd/ab4500-core.c b/drivers/mfd/ab4500-core.c
new file mode 100644
index 000000000000..1c44c19e073a
--- /dev/null
+++ b/drivers/mfd/ab4500-core.c
@@ -0,0 +1,208 @@
1/*
2 * Copyright (C) 2009 ST-Ericsson
3 *
4 * Author: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
5 *
6 * This program is free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation.
9 *
10 * AB4500 is a companion power management chip used with U8500.
11 * On this platform, this is interfaced with SSP0 controller
12 * which is a ARM primecell pl022.
13 *
14 * At the moment the module just exports read/write features.
15 * Interrupt management to be added - TODO.
16 */
17#include <linux/kernel.h>
18#include <linux/init.h>
19#include <linux/module.h>
20#include <linux/platform_device.h>
21#include <linux/spi/spi.h>
22#include <linux/mfd/ab4500.h>
23
24/* just required if probe fails, we need to
25 * unregister the device
26 */
27static struct spi_driver ab4500_driver;
28
29/*
30 * This funtion writes to any AB4500 registers using
31 * SPI protocol & before it writes it packs the data
32 * in the below 24 bit frame format
33 *
34 * *|------------------------------------|
35 * *| 23|22...18|17.......10|9|8|7......0|
36 * *| r/w bank adr data |
37 * * ------------------------------------
38 *
39 * This function shouldn't be called from interrupt
40 * context
41 */
42int ab4500_write(struct ab4500 *ab4500, unsigned char block,
43 unsigned long addr, unsigned char data)
44{
45 struct spi_transfer xfer;
46 struct spi_message msg;
47 int err;
48 unsigned long spi_data =
49 block << 18 | addr << 10 | data;
50
51 mutex_lock(&ab4500->lock);
52 ab4500->tx_buf[0] = spi_data;
53 ab4500->rx_buf[0] = 0;
54
55 xfer.tx_buf = ab4500->tx_buf;
56 xfer.rx_buf = NULL;
57 xfer.len = sizeof(unsigned long);
58
59 spi_message_init(&msg);
60 spi_message_add_tail(&xfer, &msg);
61
62 err = spi_sync(ab4500->spi, &msg);
63 mutex_unlock(&ab4500->lock);
64
65 return err;
66}
67EXPORT_SYMBOL(ab4500_write);
68
69int ab4500_read(struct ab4500 *ab4500, unsigned char block,
70 unsigned long addr)
71{
72 struct spi_transfer xfer;
73 struct spi_message msg;
74 unsigned long spi_data =
75 1 << 23 | block << 18 | addr << 10;
76
77 mutex_lock(&ab4500->lock);
78 ab4500->tx_buf[0] = spi_data;
79 ab4500->rx_buf[0] = 0;
80
81 xfer.tx_buf = ab4500->tx_buf;
82 xfer.rx_buf = ab4500->rx_buf;
83 xfer.len = sizeof(unsigned long);
84
85 spi_message_init(&msg);
86 spi_message_add_tail(&xfer, &msg);
87
88 spi_sync(ab4500->spi, &msg);
89 mutex_unlock(&ab4500->lock);
90
91 return ab4500->rx_buf[0];
92}
93EXPORT_SYMBOL(ab4500_read);
94
95/* ref: ab3100 core */
96#define AB4500_DEVICE(devname, devid) \
97static struct platform_device ab4500_##devname##_device = { \
98 .name = devid, \
99 .id = -1, \
100}
101
102/* list of childern devices of ab4500 - all are
103 * not populated here - TODO
104 */
105AB4500_DEVICE(charger, "ab4500-charger");
106AB4500_DEVICE(audio, "ab4500-audio");
107AB4500_DEVICE(usb, "ab4500-usb");
108AB4500_DEVICE(tvout, "ab4500-tvout");
109AB4500_DEVICE(sim, "ab4500-sim");
110AB4500_DEVICE(gpadc, "ab4500-gpadc");
111AB4500_DEVICE(clkmgt, "ab4500-clkmgt");
112AB4500_DEVICE(misc, "ab4500-misc");
113
114static struct platform_device *ab4500_platform_devs[] = {
115 &ab4500_charger_device,
116 &ab4500_audio_device,
117 &ab4500_usb_device,
118 &ab4500_tvout_device,
119 &ab4500_sim_device,
120 &ab4500_gpadc_device,
121 &ab4500_clkmgt_device,
122 &ab4500_misc_device,
123};
124
125static int __init ab4500_probe(struct spi_device *spi)
126{
127 struct ab4500 *ab4500;
128 unsigned char revision;
129 int err = 0;
130 int i;
131
132 ab4500 = kzalloc(sizeof *ab4500, GFP_KERNEL);
133 if (!ab4500) {
134 dev_err(&spi->dev, "could not allocate AB4500\n");
135 err = -ENOMEM;
136 goto not_detect;
137 }
138
139 ab4500->spi = spi;
140 spi_set_drvdata(spi, ab4500);
141
142 mutex_init(&ab4500->lock);
143
144 /* read the revision register */
145 revision = ab4500_read(ab4500, AB4500_MISC, AB4500_REV_REG);
146
147 /* revision id 0x0 is for early drop, 0x10 is for cut1.0 */
148 if (revision == 0x0 || revision == 0x10)
149 dev_info(&spi->dev, "Detected chip: %s, revision = %x\n",
150 ab4500_driver.driver.name, revision);
151 else {
152 dev_err(&spi->dev, "unknown chip: 0x%x\n", revision);
153 goto not_detect;
154 }
155
156 for (i = 0; i < ARRAY_SIZE(ab4500_platform_devs); i++) {
157 ab4500_platform_devs[i]->dev.parent =
158 &spi->dev;
159 platform_set_drvdata(ab4500_platform_devs[i], ab4500);
160 }
161
162 /* register the ab4500 platform devices */
163 platform_add_devices(ab4500_platform_devs,
164 ARRAY_SIZE(ab4500_platform_devs));
165
166 return err;
167
168 not_detect:
169 spi_unregister_driver(&ab4500_driver);
170 kfree(ab4500);
171 return err;
172}
173
174static int __devexit ab4500_remove(struct spi_device *spi)
175{
176 struct ab4500 *ab4500 =
177 spi_get_drvdata(spi);
178
179 kfree(ab4500);
180
181 return 0;
182}
183
184static struct spi_driver ab4500_driver = {
185 .driver = {
186 .name = "ab4500",
187 .owner = THIS_MODULE,
188 },
189 .probe = ab4500_probe,
190 .remove = __devexit_p(ab4500_remove)
191};
192
193static int __devinit ab4500_init(void)
194{
195 return spi_register_driver(&ab4500_driver);
196}
197
198static void __exit ab4500_exit(void)
199{
200 spi_unregister_driver(&ab4500_driver);
201}
202
203subsys_initcall(ab4500_init);
204module_exit(ab4500_exit);
205
206MODULE_AUTHOR("Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com");
207MODULE_DESCRIPTION("AB4500 core driver");
208MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/adp5520.c b/drivers/mfd/adp5520.c
new file mode 100644
index 000000000000..b26644772d02
--- /dev/null
+++ b/drivers/mfd/adp5520.c
@@ -0,0 +1,379 @@
1/*
2 * Base driver for Analog Devices ADP5520/ADP5501 MFD PMICs
3 * LCD Backlight: drivers/video/backlight/adp5520_bl
4 * LEDs : drivers/led/leds-adp5520
5 * GPIO : drivers/gpio/adp5520-gpio (ADP5520 only)
6 * Keys : drivers/input/keyboard/adp5520-keys (ADP5520 only)
7 *
8 * Copyright 2009 Analog Devices Inc.
9 *
10 * Derived from da903x:
11 * Copyright (C) 2008 Compulab, Ltd.
12 * Mike Rapoport <mike@compulab.co.il>
13 *
14 * Copyright (C) 2006-2008 Marvell International Ltd.
15 * Eric Miao <eric.miao@marvell.com>
16 *
17 * Licensed under the GPL-2 or later.
18 */
19
20#include <linux/kernel.h>
21#include <linux/module.h>
22#include <linux/platform_device.h>
23#include <linux/init.h>
24#include <linux/interrupt.h>
25#include <linux/irq.h>
26#include <linux/err.h>
27#include <linux/i2c.h>
28
29#include <linux/mfd/adp5520.h>
30
31struct adp5520_chip {
32 struct i2c_client *client;
33 struct device *dev;
34 struct mutex lock;
35 struct blocking_notifier_head notifier_list;
36 int irq;
37 unsigned long id;
38};
39
40static int __adp5520_read(struct i2c_client *client,
41 int reg, uint8_t *val)
42{
43 int ret;
44
45 ret = i2c_smbus_read_byte_data(client, reg);
46 if (ret < 0) {
47 dev_err(&client->dev, "failed reading at 0x%02x\n", reg);
48 return ret;
49 }
50
51 *val = (uint8_t)ret;
52 return 0;
53}
54
55static int __adp5520_write(struct i2c_client *client,
56 int reg, uint8_t val)
57{
58 int ret;
59
60 ret = i2c_smbus_write_byte_data(client, reg, val);
61 if (ret < 0) {
62 dev_err(&client->dev, "failed writing 0x%02x to 0x%02x\n",
63 val, reg);
64 return ret;
65 }
66 return 0;
67}
68
69static int __adp5520_ack_bits(struct i2c_client *client, int reg,
70 uint8_t bit_mask)
71{
72 struct adp5520_chip *chip = i2c_get_clientdata(client);
73 uint8_t reg_val;
74 int ret;
75
76 mutex_lock(&chip->lock);
77
78 ret = __adp5520_read(client, reg, &reg_val);
79
80 if (!ret) {
81 reg_val |= bit_mask;
82 ret = __adp5520_write(client, reg, reg_val);
83 }
84
85 mutex_unlock(&chip->lock);
86 return ret;
87}
88
89int adp5520_write(struct device *dev, int reg, uint8_t val)
90{
91 return __adp5520_write(to_i2c_client(dev), reg, val);
92}
93EXPORT_SYMBOL_GPL(adp5520_write);
94
95int adp5520_read(struct device *dev, int reg, uint8_t *val)
96{
97 return __adp5520_read(to_i2c_client(dev), reg, val);
98}
99EXPORT_SYMBOL_GPL(adp5520_read);
100
101int adp5520_set_bits(struct device *dev, int reg, uint8_t bit_mask)
102{
103 struct adp5520_chip *chip = dev_get_drvdata(dev);
104 uint8_t reg_val;
105 int ret;
106
107 mutex_lock(&chip->lock);
108
109 ret = __adp5520_read(chip->client, reg, &reg_val);
110
111 if (!ret && ((reg_val & bit_mask) == 0)) {
112 reg_val |= bit_mask;
113 ret = __adp5520_write(chip->client, reg, reg_val);
114 }
115
116 mutex_unlock(&chip->lock);
117 return ret;
118}
119EXPORT_SYMBOL_GPL(adp5520_set_bits);
120
121int adp5520_clr_bits(struct device *dev, int reg, uint8_t bit_mask)
122{
123 struct adp5520_chip *chip = dev_get_drvdata(dev);
124 uint8_t reg_val;
125 int ret;
126
127 mutex_lock(&chip->lock);
128
129 ret = __adp5520_read(chip->client, reg, &reg_val);
130
131 if (!ret && (reg_val & bit_mask)) {
132 reg_val &= ~bit_mask;
133 ret = __adp5520_write(chip->client, reg, reg_val);
134 }
135
136 mutex_unlock(&chip->lock);
137 return ret;
138}
139EXPORT_SYMBOL_GPL(adp5520_clr_bits);
140
141int adp5520_register_notifier(struct device *dev, struct notifier_block *nb,
142 unsigned int events)
143{
144 struct adp5520_chip *chip = dev_get_drvdata(dev);
145
146 if (chip->irq) {
147 adp5520_set_bits(chip->dev, ADP5520_INTERRUPT_ENABLE,
148 events & (ADP5520_KP_IEN | ADP5520_KR_IEN |
149 ADP5520_OVP_IEN | ADP5520_CMPR_IEN));
150
151 return blocking_notifier_chain_register(&chip->notifier_list,
152 nb);
153 }
154
155 return -ENODEV;
156}
157EXPORT_SYMBOL_GPL(adp5520_register_notifier);
158
159int adp5520_unregister_notifier(struct device *dev, struct notifier_block *nb,
160 unsigned int events)
161{
162 struct adp5520_chip *chip = dev_get_drvdata(dev);
163
164 adp5520_clr_bits(chip->dev, ADP5520_INTERRUPT_ENABLE,
165 events & (ADP5520_KP_IEN | ADP5520_KR_IEN |
166 ADP5520_OVP_IEN | ADP5520_CMPR_IEN));
167
168 return blocking_notifier_chain_unregister(&chip->notifier_list, nb);
169}
170EXPORT_SYMBOL_GPL(adp5520_unregister_notifier);
171
172static irqreturn_t adp5520_irq_thread(int irq, void *data)
173{
174 struct adp5520_chip *chip = data;
175 unsigned int events;
176 uint8_t reg_val;
177 int ret;
178
179 ret = __adp5520_read(chip->client, ADP5520_MODE_STATUS, &reg_val);
180 if (ret)
181 goto out;
182
183 events = reg_val & (ADP5520_OVP_INT | ADP5520_CMPR_INT |
184 ADP5520_GPI_INT | ADP5520_KR_INT | ADP5520_KP_INT);
185
186 blocking_notifier_call_chain(&chip->notifier_list, events, NULL);
187 /* ACK, Sticky bits are W1C */
188 __adp5520_ack_bits(chip->client, ADP5520_MODE_STATUS, events);
189
190out:
191 return IRQ_HANDLED;
192}
193
194static int __remove_subdev(struct device *dev, void *unused)
195{
196 platform_device_unregister(to_platform_device(dev));
197 return 0;
198}
199
200static int adp5520_remove_subdevs(struct adp5520_chip *chip)
201{
202 return device_for_each_child(chip->dev, NULL, __remove_subdev);
203}
204
205static int __devinit adp5520_probe(struct i2c_client *client,
206 const struct i2c_device_id *id)
207{
208 struct adp5520_platform_data *pdata = client->dev.platform_data;
209 struct platform_device *pdev;
210 struct adp5520_chip *chip;
211 int ret;
212
213 if (!i2c_check_functionality(client->adapter,
214 I2C_FUNC_SMBUS_BYTE_DATA)) {
215 dev_err(&client->dev, "SMBUS Word Data not Supported\n");
216 return -EIO;
217 }
218
219 if (pdata == NULL) {
220 dev_err(&client->dev, "missing platform data\n");
221 return -ENODEV;
222 }
223
224 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
225 if (!chip)
226 return -ENOMEM;
227
228 i2c_set_clientdata(client, chip);
229 chip->client = client;
230
231 chip->dev = &client->dev;
232 chip->irq = client->irq;
233 chip->id = id->driver_data;
234 mutex_init(&chip->lock);
235
236 if (chip->irq) {
237 BLOCKING_INIT_NOTIFIER_HEAD(&chip->notifier_list);
238
239 ret = request_threaded_irq(chip->irq, NULL, adp5520_irq_thread,
240 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
241 "adp5520", chip);
242 if (ret) {
243 dev_err(&client->dev, "failed to request irq %d\n",
244 chip->irq);
245 goto out_free_chip;
246 }
247 }
248
249 ret = adp5520_write(chip->dev, ADP5520_MODE_STATUS, ADP5520_nSTNBY);
250 if (ret) {
251 dev_err(&client->dev, "failed to write\n");
252 goto out_free_irq;
253 }
254
255 if (pdata->keys) {
256 pdev = platform_device_register_data(chip->dev, "adp5520-keys",
257 chip->id, pdata->keys, sizeof(*pdata->keys));
258 if (IS_ERR(pdev)) {
259 ret = PTR_ERR(pdev);
260 goto out_remove_subdevs;
261 }
262 }
263
264 if (pdata->gpio) {
265 pdev = platform_device_register_data(chip->dev, "adp5520-gpio",
266 chip->id, pdata->gpio, sizeof(*pdata->gpio));
267 if (IS_ERR(pdev)) {
268 ret = PTR_ERR(pdev);
269 goto out_remove_subdevs;
270 }
271 }
272
273 if (pdata->leds) {
274 pdev = platform_device_register_data(chip->dev, "adp5520-led",
275 chip->id, pdata->leds, sizeof(*pdata->leds));
276 if (IS_ERR(pdev)) {
277 ret = PTR_ERR(pdev);
278 goto out_remove_subdevs;
279 }
280 }
281
282 if (pdata->backlight) {
283 pdev = platform_device_register_data(chip->dev,
284 "adp5520-backlight",
285 chip->id,
286 pdata->backlight,
287 sizeof(*pdata->backlight));
288 if (IS_ERR(pdev)) {
289 ret = PTR_ERR(pdev);
290 goto out_remove_subdevs;
291 }
292 }
293
294 return 0;
295
296out_remove_subdevs:
297 adp5520_remove_subdevs(chip);
298
299out_free_irq:
300 if (chip->irq)
301 free_irq(chip->irq, chip);
302
303out_free_chip:
304 i2c_set_clientdata(client, NULL);
305 kfree(chip);
306
307 return ret;
308}
309
310static int __devexit adp5520_remove(struct i2c_client *client)
311{
312 struct adp5520_chip *chip = dev_get_drvdata(&client->dev);
313
314 if (chip->irq)
315 free_irq(chip->irq, chip);
316
317 adp5520_remove_subdevs(chip);
318 adp5520_write(chip->dev, ADP5520_MODE_STATUS, 0);
319 i2c_set_clientdata(client, NULL);
320 kfree(chip);
321 return 0;
322}
323
324#ifdef CONFIG_PM
325static int adp5520_suspend(struct i2c_client *client,
326 pm_message_t state)
327{
328 struct adp5520_chip *chip = dev_get_drvdata(&client->dev);
329
330 adp5520_clr_bits(chip->dev, ADP5520_MODE_STATUS, ADP5520_nSTNBY);
331 return 0;
332}
333
334static int adp5520_resume(struct i2c_client *client)
335{
336 struct adp5520_chip *chip = dev_get_drvdata(&client->dev);
337
338 adp5520_set_bits(chip->dev, ADP5520_MODE_STATUS, ADP5520_nSTNBY);
339 return 0;
340}
341#else
342#define adp5520_suspend NULL
343#define adp5520_resume NULL
344#endif
345
346static const struct i2c_device_id adp5520_id[] = {
347 { "pmic-adp5520", ID_ADP5520 },
348 { "pmic-adp5501", ID_ADP5501 },
349 { }
350};
351MODULE_DEVICE_TABLE(i2c, adp5520_id);
352
353static struct i2c_driver adp5520_driver = {
354 .driver = {
355 .name = "adp5520",
356 .owner = THIS_MODULE,
357 },
358 .probe = adp5520_probe,
359 .remove = __devexit_p(adp5520_remove),
360 .suspend = adp5520_suspend,
361 .resume = adp5520_resume,
362 .id_table = adp5520_id,
363};
364
365static int __init adp5520_init(void)
366{
367 return i2c_add_driver(&adp5520_driver);
368}
369module_init(adp5520_init);
370
371static void __exit adp5520_exit(void)
372{
373 i2c_del_driver(&adp5520_driver);
374}
375module_exit(adp5520_exit);
376
377MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
378MODULE_DESCRIPTION("ADP5520(01) PMIC-MFD Driver");
379MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c
index 63a2a6632106..e22128c3e9a8 100644
--- a/drivers/mfd/asic3.c
+++ b/drivers/mfd/asic3.c
@@ -908,7 +908,7 @@ static int __init asic3_probe(struct platform_device *pdev)
908 return ret; 908 return ret;
909} 909}
910 910
911static int asic3_remove(struct platform_device *pdev) 911static int __devexit asic3_remove(struct platform_device *pdev)
912{ 912{
913 int ret; 913 int ret;
914 struct asic3 *asic = platform_get_drvdata(pdev); 914 struct asic3 *asic = platform_get_drvdata(pdev);
diff --git a/drivers/mfd/ezx-pcap.c b/drivers/mfd/ezx-pcap.c
index 876288917976..df405af968fa 100644
--- a/drivers/mfd/ezx-pcap.c
+++ b/drivers/mfd/ezx-pcap.c
@@ -387,7 +387,6 @@ static int __devinit pcap_add_subdev(struct pcap_chip *pcap,
387 pdev = platform_device_alloc(subdev->name, subdev->id); 387 pdev = platform_device_alloc(subdev->name, subdev->id);
388 pdev->dev.parent = &pcap->spi->dev; 388 pdev->dev.parent = &pcap->spi->dev;
389 pdev->dev.platform_data = subdev->platform_data; 389 pdev->dev.platform_data = subdev->platform_data;
390 platform_set_drvdata(pdev, pcap);
391 390
392 return platform_device_add(pdev); 391 return platform_device_add(pdev);
393} 392}
diff --git a/drivers/mfd/mc13783-core.c b/drivers/mfd/mc13783-core.c
index e354d2912ef1..a1ade2324ea9 100644
--- a/drivers/mfd/mc13783-core.c
+++ b/drivers/mfd/mc13783-core.c
@@ -1,286 +1,549 @@
1/* 1/*
2 * Copyright 2009 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de> 2 * Copyright 2009 Pengutronix
3 * 3 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
4 * This code is in parts based on wm8350-core.c and pcf50633-core.c
5 *
6 * Initial development of this code was funded by
7 * Phytec Messtechnik GmbH, http://www.phytec.de
8 * 4 *
9 * This program is free software; you can redistribute it and/or modify 5 * loosely based on an earlier driver that has
10 * it under the terms of the GNU General Public License as published by 6 * Copyright 2009 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de>
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 * 7 *
19 * You should have received a copy of the GNU General Public License 8 * This program is free software; you can redistribute it and/or modify it under
20 * along with this program; if not, write to the Free Software 9 * the terms of the GNU General Public License version 2 as published by the
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 10 * Free Software Foundation.
22 */ 11 */
23
24#include <linux/mfd/mc13783-private.h>
25#include <linux/platform_device.h>
26#include <linux/mfd/mc13783.h>
27#include <linux/completion.h>
28#include <linux/interrupt.h>
29#include <linux/mfd/core.h>
30#include <linux/spi/spi.h>
31#include <linux/uaccess.h>
32#include <linux/kernel.h>
33#include <linux/module.h> 12#include <linux/module.h>
34#include <linux/init.h> 13#include <linux/spi/spi.h>
35#include <linux/slab.h> 14#include <linux/mfd/core.h>
36#include <linux/irq.h> 15#include <linux/mfd/mc13783-private.h>
16
17#define MC13783_IRQSTAT0 0
18#define MC13783_IRQSTAT0_ADCDONEI (1 << 0)
19#define MC13783_IRQSTAT0_ADCBISDONEI (1 << 1)
20#define MC13783_IRQSTAT0_TSI (1 << 2)
21#define MC13783_IRQSTAT0_WHIGHI (1 << 3)
22#define MC13783_IRQSTAT0_WLOWI (1 << 4)
23#define MC13783_IRQSTAT0_CHGDETI (1 << 6)
24#define MC13783_IRQSTAT0_CHGOVI (1 << 7)
25#define MC13783_IRQSTAT0_CHGREVI (1 << 8)
26#define MC13783_IRQSTAT0_CHGSHORTI (1 << 9)
27#define MC13783_IRQSTAT0_CCCVI (1 << 10)
28#define MC13783_IRQSTAT0_CHGCURRI (1 << 11)
29#define MC13783_IRQSTAT0_BPONI (1 << 12)
30#define MC13783_IRQSTAT0_LOBATLI (1 << 13)
31#define MC13783_IRQSTAT0_LOBATHI (1 << 14)
32#define MC13783_IRQSTAT0_UDPI (1 << 15)
33#define MC13783_IRQSTAT0_USBI (1 << 16)
34#define MC13783_IRQSTAT0_IDI (1 << 19)
35#define MC13783_IRQSTAT0_SE1I (1 << 21)
36#define MC13783_IRQSTAT0_CKDETI (1 << 22)
37#define MC13783_IRQSTAT0_UDMI (1 << 23)
38
39#define MC13783_IRQMASK0 1
40#define MC13783_IRQMASK0_ADCDONEM MC13783_IRQSTAT0_ADCDONEI
41#define MC13783_IRQMASK0_ADCBISDONEM MC13783_IRQSTAT0_ADCBISDONEI
42#define MC13783_IRQMASK0_TSM MC13783_IRQSTAT0_TSI
43#define MC13783_IRQMASK0_WHIGHM MC13783_IRQSTAT0_WHIGHI
44#define MC13783_IRQMASK0_WLOWM MC13783_IRQSTAT0_WLOWI
45#define MC13783_IRQMASK0_CHGDETM MC13783_IRQSTAT0_CHGDETI
46#define MC13783_IRQMASK0_CHGOVM MC13783_IRQSTAT0_CHGOVI
47#define MC13783_IRQMASK0_CHGREVM MC13783_IRQSTAT0_CHGREVI
48#define MC13783_IRQMASK0_CHGSHORTM MC13783_IRQSTAT0_CHGSHORTI
49#define MC13783_IRQMASK0_CCCVM MC13783_IRQSTAT0_CCCVI
50#define MC13783_IRQMASK0_CHGCURRM MC13783_IRQSTAT0_CHGCURRI
51#define MC13783_IRQMASK0_BPONM MC13783_IRQSTAT0_BPONI
52#define MC13783_IRQMASK0_LOBATLM MC13783_IRQSTAT0_LOBATLI
53#define MC13783_IRQMASK0_LOBATHM MC13783_IRQSTAT0_LOBATHI
54#define MC13783_IRQMASK0_UDPM MC13783_IRQSTAT0_UDPI
55#define MC13783_IRQMASK0_USBM MC13783_IRQSTAT0_USBI
56#define MC13783_IRQMASK0_IDM MC13783_IRQSTAT0_IDI
57#define MC13783_IRQMASK0_SE1M MC13783_IRQSTAT0_SE1I
58#define MC13783_IRQMASK0_CKDETM MC13783_IRQSTAT0_CKDETI
59#define MC13783_IRQMASK0_UDMM MC13783_IRQSTAT0_UDMI
60
61#define MC13783_IRQSTAT1 3
62#define MC13783_IRQSTAT1_1HZI (1 << 0)
63#define MC13783_IRQSTAT1_TODAI (1 << 1)
64#define MC13783_IRQSTAT1_ONOFD1I (1 << 3)
65#define MC13783_IRQSTAT1_ONOFD2I (1 << 4)
66#define MC13783_IRQSTAT1_ONOFD3I (1 << 5)
67#define MC13783_IRQSTAT1_SYSRSTI (1 << 6)
68#define MC13783_IRQSTAT1_RTCRSTI (1 << 7)
69#define MC13783_IRQSTAT1_PCI (1 << 8)
70#define MC13783_IRQSTAT1_WARMI (1 << 9)
71#define MC13783_IRQSTAT1_MEMHLDI (1 << 10)
72#define MC13783_IRQSTAT1_PWRRDYI (1 << 11)
73#define MC13783_IRQSTAT1_THWARNLI (1 << 12)
74#define MC13783_IRQSTAT1_THWARNHI (1 << 13)
75#define MC13783_IRQSTAT1_CLKI (1 << 14)
76#define MC13783_IRQSTAT1_SEMAFI (1 << 15)
77#define MC13783_IRQSTAT1_MC2BI (1 << 17)
78#define MC13783_IRQSTAT1_HSDETI (1 << 18)
79#define MC13783_IRQSTAT1_HSLI (1 << 19)
80#define MC13783_IRQSTAT1_ALSPTHI (1 << 20)
81#define MC13783_IRQSTAT1_AHSSHORTI (1 << 21)
82
83#define MC13783_IRQMASK1 4
84#define MC13783_IRQMASK1_1HZM MC13783_IRQSTAT1_1HZI
85#define MC13783_IRQMASK1_TODAM MC13783_IRQSTAT1_TODAI
86#define MC13783_IRQMASK1_ONOFD1M MC13783_IRQSTAT1_ONOFD1I
87#define MC13783_IRQMASK1_ONOFD2M MC13783_IRQSTAT1_ONOFD2I
88#define MC13783_IRQMASK1_ONOFD3M MC13783_IRQSTAT1_ONOFD3I
89#define MC13783_IRQMASK1_SYSRSTM MC13783_IRQSTAT1_SYSRSTI
90#define MC13783_IRQMASK1_RTCRSTM MC13783_IRQSTAT1_RTCRSTI
91#define MC13783_IRQMASK1_PCM MC13783_IRQSTAT1_PCI
92#define MC13783_IRQMASK1_WARMM MC13783_IRQSTAT1_WARMI
93#define MC13783_IRQMASK1_MEMHLDM MC13783_IRQSTAT1_MEMHLDI
94#define MC13783_IRQMASK1_PWRRDYM MC13783_IRQSTAT1_PWRRDYI
95#define MC13783_IRQMASK1_THWARNLM MC13783_IRQSTAT1_THWARNLI
96#define MC13783_IRQMASK1_THWARNHM MC13783_IRQSTAT1_THWARNHI
97#define MC13783_IRQMASK1_CLKM MC13783_IRQSTAT1_CLKI
98#define MC13783_IRQMASK1_SEMAFM MC13783_IRQSTAT1_SEMAFI
99#define MC13783_IRQMASK1_MC2BM MC13783_IRQSTAT1_MC2BI
100#define MC13783_IRQMASK1_HSDETM MC13783_IRQSTAT1_HSDETI
101#define MC13783_IRQMASK1_HSLM MC13783_IRQSTAT1_HSLI
102#define MC13783_IRQMASK1_ALSPTHM MC13783_IRQSTAT1_ALSPTHI
103#define MC13783_IRQMASK1_AHSSHORTM MC13783_IRQSTAT1_AHSSHORTI
104
105#define MC13783_ADC1 44
106#define MC13783_ADC1_ADEN (1 << 0)
107#define MC13783_ADC1_RAND (1 << 1)
108#define MC13783_ADC1_ADSEL (1 << 3)
109#define MC13783_ADC1_ASC (1 << 20)
110#define MC13783_ADC1_ADTRIGIGN (1 << 21)
111
112#define MC13783_NUMREGS 0x3f
113
114void mc13783_lock(struct mc13783 *mc13783)
115{
116 if (!mutex_trylock(&mc13783->lock)) {
117 dev_dbg(&mc13783->spidev->dev, "wait for %s from %pf\n",
118 __func__, __builtin_return_address(0));
119
120 mutex_lock(&mc13783->lock);
121 }
122 dev_dbg(&mc13783->spidev->dev, "%s from %pf\n",
123 __func__, __builtin_return_address(0));
124}
125EXPORT_SYMBOL(mc13783_lock);
37 126
38#define MC13783_MAX_REG_NUM 0x3f 127void mc13783_unlock(struct mc13783 *mc13783)
39#define MC13783_FRAME_MASK 0x00ffffff 128{
40#define MC13783_MAX_REG_NUM 0x3f 129 dev_dbg(&mc13783->spidev->dev, "%s from %pf\n",
41#define MC13783_REG_NUM_SHIFT 0x19 130 __func__, __builtin_return_address(0));
42#define MC13783_WRITE_BIT_SHIFT 31 131 mutex_unlock(&mc13783->lock);
132}
133EXPORT_SYMBOL(mc13783_unlock);
43 134
44static inline int spi_rw(struct spi_device *spi, u8 * buf, size_t len) 135#define MC13783_REGOFFSET_SHIFT 25
136int mc13783_reg_read(struct mc13783 *mc13783, unsigned int offset, u32 *val)
45{ 137{
46 struct spi_transfer t = { 138 struct spi_transfer t;
47 .tx_buf = (const void *)buf,
48 .rx_buf = buf,
49 .len = len,
50 .cs_change = 0,
51 .delay_usecs = 0,
52 };
53 struct spi_message m; 139 struct spi_message m;
140 int ret;
141
142 BUG_ON(!mutex_is_locked(&mc13783->lock));
143
144 if (offset > MC13783_NUMREGS)
145 return -EINVAL;
146
147 *val = offset << MC13783_REGOFFSET_SHIFT;
148
149 memset(&t, 0, sizeof(t));
150
151 t.tx_buf = val;
152 t.rx_buf = val;
153 t.len = sizeof(u32);
54 154
55 spi_message_init(&m); 155 spi_message_init(&m);
56 spi_message_add_tail(&t, &m); 156 spi_message_add_tail(&t, &m);
57 if (spi_sync(spi, &m) != 0 || m.status != 0)
58 return -EINVAL;
59 return len - m.actual_length;
60}
61 157
62static int mc13783_read(struct mc13783 *mc13783, int reg_num, u32 *reg_val) 158 ret = spi_sync(mc13783->spidev, &m);
63{
64 unsigned int frame = 0;
65 int ret = 0;
66 159
67 if (reg_num > MC13783_MAX_REG_NUM) 160 /* error in message.status implies error return from spi_sync */
68 return -EINVAL; 161 BUG_ON(!ret && m.status);
69 162
70 frame |= reg_num << MC13783_REG_NUM_SHIFT; 163 if (ret)
164 return ret;
71 165
72 ret = spi_rw(mc13783->spi_device, (u8 *)&frame, 4); 166 *val &= 0xffffff;
73 167
74 *reg_val = frame & MC13783_FRAME_MASK; 168 dev_vdbg(&mc13783->spidev->dev, "[0x%02x] -> 0x%06x\n", offset, *val);
75 169
76 return ret; 170 return 0;
77} 171}
172EXPORT_SYMBOL(mc13783_reg_read);
78 173
79static int mc13783_write(struct mc13783 *mc13783, int reg_num, u32 reg_val) 174int mc13783_reg_write(struct mc13783 *mc13783, unsigned int offset, u32 val)
80{ 175{
81 unsigned int frame = 0; 176 u32 buf;
177 struct spi_transfer t;
178 struct spi_message m;
179 int ret;
180
181 BUG_ON(!mutex_is_locked(&mc13783->lock));
82 182
83 if (reg_num > MC13783_MAX_REG_NUM) 183 dev_vdbg(&mc13783->spidev->dev, "[0x%02x] <- 0x%06x\n", offset, val);
184
185 if (offset > MC13783_NUMREGS || val > 0xffffff)
84 return -EINVAL; 186 return -EINVAL;
85 187
86 frame |= (1 << MC13783_WRITE_BIT_SHIFT); 188 buf = 1 << 31 | offset << MC13783_REGOFFSET_SHIFT | val;
87 frame |= reg_num << MC13783_REG_NUM_SHIFT; 189
88 frame |= reg_val & MC13783_FRAME_MASK; 190 memset(&t, 0, sizeof(t));
89 191
90 return spi_rw(mc13783->spi_device, (u8 *)&frame, 4); 192 t.tx_buf = &buf;
193 t.rx_buf = &buf;
194 t.len = sizeof(u32);
195
196 spi_message_init(&m);
197 spi_message_add_tail(&t, &m);
198
199 ret = spi_sync(mc13783->spidev, &m);
200
201 BUG_ON(!ret && m.status);
202
203 if (ret)
204 return ret;
205
206 return 0;
91} 207}
208EXPORT_SYMBOL(mc13783_reg_write);
92 209
93int mc13783_reg_read(struct mc13783 *mc13783, int reg_num, u32 *reg_val) 210int mc13783_reg_rmw(struct mc13783 *mc13783, unsigned int offset,
211 u32 mask, u32 val)
94{ 212{
95 int ret; 213 int ret;
214 u32 valread;
96 215
97 mutex_lock(&mc13783->io_lock); 216 BUG_ON(val & ~mask);
98 ret = mc13783_read(mc13783, reg_num, reg_val);
99 mutex_unlock(&mc13783->io_lock);
100 217
101 return ret; 218 ret = mc13783_reg_read(mc13783, offset, &valread);
219 if (ret)
220 return ret;
221
222 valread = (valread & ~mask) | val;
223
224 return mc13783_reg_write(mc13783, offset, valread);
102} 225}
103EXPORT_SYMBOL_GPL(mc13783_reg_read); 226EXPORT_SYMBOL(mc13783_reg_rmw);
104 227
105int mc13783_reg_write(struct mc13783 *mc13783, int reg_num, u32 reg_val) 228int mc13783_mask(struct mc13783 *mc13783, int irq)
106{ 229{
107 int ret; 230 int ret;
231 unsigned int offmask = irq < 24 ? MC13783_IRQMASK0 : MC13783_IRQMASK1;
232 u32 irqbit = 1 << (irq < 24 ? irq : irq - 24);
233 u32 mask;
108 234
109 mutex_lock(&mc13783->io_lock); 235 if (irq < 0 || irq >= MC13783_NUM_IRQ)
110 ret = mc13783_write(mc13783, reg_num, reg_val); 236 return -EINVAL;
111 mutex_unlock(&mc13783->io_lock);
112 237
113 return ret; 238 ret = mc13783_reg_read(mc13783, offmask, &mask);
239 if (ret)
240 return ret;
241
242 if (mask & irqbit)
243 /* already masked */
244 return 0;
245
246 return mc13783_reg_write(mc13783, offmask, mask | irqbit);
114} 247}
115EXPORT_SYMBOL_GPL(mc13783_reg_write); 248EXPORT_SYMBOL(mc13783_mask);
116 249
117/** 250int mc13783_unmask(struct mc13783 *mc13783, int irq)
118 * mc13783_set_bits - Bitmask write
119 *
120 * @mc13783: Pointer to mc13783 control structure
121 * @reg: Register to access
122 * @mask: Mask of bits to change
123 * @val: Value to set for masked bits
124 */
125int mc13783_set_bits(struct mc13783 *mc13783, int reg, u32 mask, u32 val)
126{ 251{
127 u32 tmp;
128 int ret; 252 int ret;
253 unsigned int offmask = irq < 24 ? MC13783_IRQMASK0 : MC13783_IRQMASK1;
254 u32 irqbit = 1 << (irq < 24 ? irq : irq - 24);
255 u32 mask;
129 256
130 mutex_lock(&mc13783->io_lock); 257 if (irq < 0 || irq >= MC13783_NUM_IRQ)
258 return -EINVAL;
131 259
132 ret = mc13783_read(mc13783, reg, &tmp); 260 ret = mc13783_reg_read(mc13783, offmask, &mask);
133 tmp = (tmp & ~mask) | val; 261 if (ret)
134 if (ret == 0) 262 return ret;
135 ret = mc13783_write(mc13783, reg, tmp);
136 263
137 mutex_unlock(&mc13783->io_lock); 264 if (!(mask & irqbit))
265 /* already unmasked */
266 return 0;
138 267
139 return ret; 268 return mc13783_reg_write(mc13783, offmask, mask & ~irqbit);
140} 269}
141EXPORT_SYMBOL_GPL(mc13783_set_bits); 270EXPORT_SYMBOL(mc13783_unmask);
142 271
143int mc13783_register_irq(struct mc13783 *mc13783, int irq, 272int mc13783_irq_request_nounmask(struct mc13783 *mc13783, int irq,
144 void (*handler) (int, void *), void *data) 273 irq_handler_t handler, const char *name, void *dev)
145{ 274{
146 if (irq < 0 || irq > MC13783_NUM_IRQ || !handler) 275 BUG_ON(!mutex_is_locked(&mc13783->lock));
276 BUG_ON(!handler);
277
278 if (irq < 0 || irq >= MC13783_NUM_IRQ)
147 return -EINVAL; 279 return -EINVAL;
148 280
149 if (WARN_ON(mc13783->irq_handler[irq].handler)) 281 if (mc13783->irqhandler[irq])
150 return -EBUSY; 282 return -EBUSY;
151 283
152 mutex_lock(&mc13783->io_lock); 284 mc13783->irqhandler[irq] = handler;
153 mc13783->irq_handler[irq].handler = handler; 285 mc13783->irqdata[irq] = dev;
154 mc13783->irq_handler[irq].data = data;
155 mutex_unlock(&mc13783->io_lock);
156 286
157 return 0; 287 return 0;
158} 288}
159EXPORT_SYMBOL_GPL(mc13783_register_irq); 289EXPORT_SYMBOL(mc13783_irq_request_nounmask);
160 290
161int mc13783_free_irq(struct mc13783 *mc13783, int irq) 291int mc13783_irq_request(struct mc13783 *mc13783, int irq,
292 irq_handler_t handler, const char *name, void *dev)
162{ 293{
163 if (irq < 0 || irq > MC13783_NUM_IRQ) 294 int ret;
295
296 ret = mc13783_irq_request_nounmask(mc13783, irq, handler, name, dev);
297 if (ret)
298 return ret;
299
300 ret = mc13783_unmask(mc13783, irq);
301 if (ret) {
302 mc13783->irqhandler[irq] = NULL;
303 mc13783->irqdata[irq] = NULL;
304 return ret;
305 }
306
307 return 0;
308}
309EXPORT_SYMBOL(mc13783_irq_request);
310
311int mc13783_irq_free(struct mc13783 *mc13783, int irq, void *dev)
312{
313 int ret;
314 BUG_ON(!mutex_is_locked(&mc13783->lock));
315
316 if (irq < 0 || irq >= MC13783_NUM_IRQ || !mc13783->irqhandler[irq] ||
317 mc13783->irqdata[irq] != dev)
164 return -EINVAL; 318 return -EINVAL;
165 319
166 mutex_lock(&mc13783->io_lock); 320 ret = mc13783_mask(mc13783, irq);
167 mc13783->irq_handler[irq].handler = NULL; 321 if (ret)
168 mutex_unlock(&mc13783->io_lock); 322 return ret;
323
324 mc13783->irqhandler[irq] = NULL;
325 mc13783->irqdata[irq] = NULL;
169 326
170 return 0; 327 return 0;
171} 328}
172EXPORT_SYMBOL_GPL(mc13783_free_irq); 329EXPORT_SYMBOL(mc13783_irq_free);
173 330
174static void mc13783_irq_work(struct work_struct *work) 331static inline irqreturn_t mc13783_irqhandler(struct mc13783 *mc13783, int irq)
175{ 332{
176 struct mc13783 *mc13783 = container_of(work, struct mc13783, work); 333 return mc13783->irqhandler[irq](irq, mc13783->irqdata[irq]);
177 int i;
178 unsigned int adc_sts;
179
180 /* check if the adc has finished any completion */
181 mc13783_reg_read(mc13783, MC13783_REG_INTERRUPT_STATUS_0, &adc_sts);
182 mc13783_reg_write(mc13783, MC13783_REG_INTERRUPT_STATUS_0,
183 adc_sts & MC13783_INT_STAT_ADCDONEI);
184
185 if (adc_sts & MC13783_INT_STAT_ADCDONEI)
186 complete_all(&mc13783->adc_done);
187
188 for (i = 0; i < MC13783_NUM_IRQ; i++)
189 if (mc13783->irq_handler[i].handler)
190 mc13783->irq_handler[i].handler(i,
191 mc13783->irq_handler[i].data);
192 enable_irq(mc13783->irq);
193} 334}
194 335
195static irqreturn_t mc13783_interrupt(int irq, void *dev_id) 336int mc13783_ackirq(struct mc13783 *mc13783, int irq)
196{ 337{
197 struct mc13783 *mc13783 = dev_id; 338 unsigned int offstat = irq < 24 ? MC13783_IRQSTAT0 : MC13783_IRQSTAT1;
339 unsigned int val = 1 << (irq < 24 ? irq : irq - 24);
198 340
199 disable_irq_nosync(irq); 341 BUG_ON(irq < 0 || irq >= MC13783_NUM_IRQ);
200 342
201 schedule_work(&mc13783->work); 343 return mc13783_reg_write(mc13783, offstat, val);
202 return IRQ_HANDLED;
203} 344}
345EXPORT_SYMBOL(mc13783_ackirq);
204 346
205/* set adc to ts interrupt mode, which generates touchscreen wakeup interrupt */ 347/*
206static inline void mc13783_adc_set_ts_irq_mode(struct mc13783 *mc13783) 348 * returns: number of handled irqs or negative error
349 * locking: holds mc13783->lock
350 */
351static int mc13783_irq_handle(struct mc13783 *mc13783,
352 unsigned int offstat, unsigned int offmask, int baseirq)
207{ 353{
208 unsigned int reg_adc0, reg_adc1; 354 u32 stat, mask;
355 int ret = mc13783_reg_read(mc13783, offstat, &stat);
356 int num_handled = 0;
357
358 if (ret)
359 return ret;
360
361 ret = mc13783_reg_read(mc13783, offmask, &mask);
362 if (ret)
363 return ret;
364
365 while (stat & ~mask) {
366 int irq = __ffs(stat & ~mask);
367
368 stat &= ~(1 << irq);
369
370 if (likely(mc13783->irqhandler[baseirq + irq])) {
371 irqreturn_t handled;
209 372
210 reg_adc0 = MC13783_ADC0_ADREFEN | MC13783_ADC0_ADREFMODE 373 handled = mc13783_irqhandler(mc13783, baseirq + irq);
211 | MC13783_ADC0_TSMOD0; 374 if (handled == IRQ_HANDLED)
212 reg_adc1 = MC13783_ADC1_ADEN | MC13783_ADC1_ADTRIGIGN; 375 num_handled++;
376 } else {
377 dev_err(&mc13783->spidev->dev,
378 "BUG: irq %u but no handler\n",
379 baseirq + irq);
213 380
214 mc13783_reg_write(mc13783, MC13783_REG_ADC_0, reg_adc0); 381 mask |= 1 << irq;
215 mc13783_reg_write(mc13783, MC13783_REG_ADC_1, reg_adc1); 382
383 ret = mc13783_reg_write(mc13783, offmask, mask);
384 }
385 }
386
387 return num_handled;
216} 388}
217 389
390static irqreturn_t mc13783_irq_thread(int irq, void *data)
391{
392 struct mc13783 *mc13783 = data;
393 irqreturn_t ret;
394 int handled = 0;
395
396 mc13783_lock(mc13783);
397
398 ret = mc13783_irq_handle(mc13783, MC13783_IRQSTAT0,
399 MC13783_IRQMASK0, MC13783_IRQ_ADCDONE);
400 if (ret > 0)
401 handled = 1;
402
403 ret = mc13783_irq_handle(mc13783, MC13783_IRQSTAT1,
404 MC13783_IRQMASK1, MC13783_IRQ_1HZ);
405 if (ret > 0)
406 handled = 1;
407
408 mc13783_unlock(mc13783);
409
410 return IRQ_RETVAL(handled);
411}
412
413#define MC13783_ADC1_CHAN0_SHIFT 5
414#define MC13783_ADC1_CHAN1_SHIFT 8
415
416struct mc13783_adcdone_data {
417 struct mc13783 *mc13783;
418 struct completion done;
419};
420
421static irqreturn_t mc13783_handler_adcdone(int irq, void *data)
422{
423 struct mc13783_adcdone_data *adcdone_data = data;
424
425 mc13783_ackirq(adcdone_data->mc13783, irq);
426
427 complete_all(&adcdone_data->done);
428
429 return IRQ_HANDLED;
430}
431
432#define MC13783_ADC_WORKING (1 << 16)
433
218int mc13783_adc_do_conversion(struct mc13783 *mc13783, unsigned int mode, 434int mc13783_adc_do_conversion(struct mc13783 *mc13783, unsigned int mode,
219 unsigned int channel, unsigned int *sample) 435 unsigned int channel, unsigned int *sample)
220{ 436{
221 unsigned int reg_adc0, reg_adc1; 437 u32 adc0, adc1, old_adc0;
222 int i; 438 int i, ret;
439 struct mc13783_adcdone_data adcdone_data = {
440 .mc13783 = mc13783,
441 };
442 init_completion(&adcdone_data.done);
443
444 dev_dbg(&mc13783->spidev->dev, "%s\n", __func__);
445
446 mc13783_lock(mc13783);
447
448 if (mc13783->flags & MC13783_ADC_WORKING) {
449 ret = -EBUSY;
450 goto out;
451 }
452
453 mc13783->flags |= MC13783_ADC_WORKING;
223 454
224 mutex_lock(&mc13783->adc_conv_lock); 455 mc13783_reg_read(mc13783, MC13783_ADC0, &old_adc0);
225 456
226 /* set up auto incrementing anyway to make quick read */ 457 adc0 = MC13783_ADC0_ADINC1 | MC13783_ADC0_ADINC2;
227 reg_adc0 = MC13783_ADC0_ADINC1 | MC13783_ADC0_ADINC2; 458 adc1 = MC13783_ADC1_ADEN | MC13783_ADC1_ADTRIGIGN | MC13783_ADC1_ASC;
228 /* enable the adc, ignore external triggering and set ASC to trigger
229 * conversion */
230 reg_adc1 = MC13783_ADC1_ADEN | MC13783_ADC1_ADTRIGIGN
231 | MC13783_ADC1_ASC;
232 459
233 /* setup channel number */
234 if (channel > 7) 460 if (channel > 7)
235 reg_adc1 |= MC13783_ADC1_ADSEL; 461 adc1 |= MC13783_ADC1_ADSEL;
236 462
237 switch (mode) { 463 switch (mode) {
238 case MC13783_ADC_MODE_TS: 464 case MC13783_ADC_MODE_TS:
239 /* enables touch screen reference mode and set touchscreen mode 465 adc0 |= MC13783_ADC0_ADREFEN | MC13783_ADC0_TSMOD0 |
240 * to position mode */ 466 MC13783_ADC0_TSMOD1;
241 reg_adc0 |= MC13783_ADC0_ADREFEN | MC13783_ADC0_ADREFMODE 467 adc1 |= 4 << MC13783_ADC1_CHAN1_SHIFT;
242 | MC13783_ADC0_TSMOD0 | MC13783_ADC0_TSMOD1;
243 reg_adc1 |= 4 << MC13783_ADC1_CHAN1_SHIFT;
244 break; 468 break;
469
245 case MC13783_ADC_MODE_SINGLE_CHAN: 470 case MC13783_ADC_MODE_SINGLE_CHAN:
246 reg_adc1 |= (channel & 0x7) << MC13783_ADC1_CHAN0_SHIFT; 471 adc0 |= old_adc0 & MC13783_ADC0_TSMOD_MASK;
247 reg_adc1 |= MC13783_ADC1_RAND; 472 adc1 |= (channel & 0x7) << MC13783_ADC1_CHAN0_SHIFT;
473 adc1 |= MC13783_ADC1_RAND;
248 break; 474 break;
475
249 case MC13783_ADC_MODE_MULT_CHAN: 476 case MC13783_ADC_MODE_MULT_CHAN:
250 reg_adc1 |= 4 << MC13783_ADC1_CHAN1_SHIFT; 477 adc0 |= old_adc0 & MC13783_ADC0_TSMOD_MASK;
478 adc1 |= 4 << MC13783_ADC1_CHAN1_SHIFT;
251 break; 479 break;
480
252 default: 481 default:
482 mc13783_unlock(mc13783);
253 return -EINVAL; 483 return -EINVAL;
254 } 484 }
255 485
256 mc13783_reg_write(mc13783, MC13783_REG_ADC_0, reg_adc0); 486 dev_dbg(&mc13783->spidev->dev, "%s: request irq\n", __func__);
257 mc13783_reg_write(mc13783, MC13783_REG_ADC_1, reg_adc1); 487 mc13783_irq_request(mc13783, MC13783_IRQ_ADCDONE,
488 mc13783_handler_adcdone, __func__, &adcdone_data);
489 mc13783_ackirq(mc13783, MC13783_IRQ_ADCDONE);
258 490
259 wait_for_completion_interruptible(&mc13783->adc_done); 491 mc13783_reg_write(mc13783, MC13783_REG_ADC_0, adc0);
492 mc13783_reg_write(mc13783, MC13783_REG_ADC_1, adc1);
260 493
261 for (i = 0; i < 4; i++) 494 mc13783_unlock(mc13783);
262 mc13783_reg_read(mc13783, MC13783_REG_ADC_2, &sample[i]);
263 495
264 if (mc13783->ts_active) 496 ret = wait_for_completion_interruptible_timeout(&adcdone_data.done, HZ);
265 mc13783_adc_set_ts_irq_mode(mc13783);
266 497
267 mutex_unlock(&mc13783->adc_conv_lock); 498 if (!ret)
499 ret = -ETIMEDOUT;
268 500
269 return 0; 501 mc13783_lock(mc13783);
502
503 mc13783_irq_free(mc13783, MC13783_IRQ_ADCDONE, &adcdone_data);
504
505 if (ret > 0)
506 for (i = 0; i < 4; ++i) {
507 ret = mc13783_reg_read(mc13783,
508 MC13783_REG_ADC_2, &sample[i]);
509 if (ret)
510 break;
511 }
512
513 if (mode == MC13783_ADC_MODE_TS)
514 /* restore TSMOD */
515 mc13783_reg_write(mc13783, MC13783_REG_ADC_0, old_adc0);
516
517 mc13783->flags &= ~MC13783_ADC_WORKING;
518out:
519 mc13783_unlock(mc13783);
520
521 return ret;
270} 522}
271EXPORT_SYMBOL_GPL(mc13783_adc_do_conversion); 523EXPORT_SYMBOL_GPL(mc13783_adc_do_conversion);
272 524
273void mc13783_adc_set_ts_status(struct mc13783 *mc13783, unsigned int status) 525static int mc13783_add_subdevice_pdata(struct mc13783 *mc13783,
526 const char *name, void *pdata, size_t pdata_size)
274{ 527{
275 mc13783->ts_active = status; 528 struct mfd_cell cell = {
529 .name = name,
530 .platform_data = pdata,
531 .data_size = pdata_size,
532 };
533
534 return mfd_add_devices(&mc13783->spidev->dev, -1, &cell, 1, NULL, 0);
535}
536
537static int mc13783_add_subdevice(struct mc13783 *mc13783, const char *name)
538{
539 return mc13783_add_subdevice_pdata(mc13783, name, NULL, 0);
276} 540}
277EXPORT_SYMBOL_GPL(mc13783_adc_set_ts_status);
278 541
279static int mc13783_check_revision(struct mc13783 *mc13783) 542static int mc13783_check_revision(struct mc13783 *mc13783)
280{ 543{
281 u32 rev_id, rev1, rev2, finid, icid; 544 u32 rev_id, rev1, rev2, finid, icid;
282 545
283 mc13783_read(mc13783, MC13783_REG_REVISION, &rev_id); 546 mc13783_reg_read(mc13783, MC13783_REG_REVISION, &rev_id);
284 547
285 rev1 = (rev_id & 0x018) >> 3; 548 rev1 = (rev_id & 0x018) >> 3;
286 rev2 = (rev_id & 0x007); 549 rev2 = (rev_id & 0x007);
@@ -292,38 +555,24 @@ static int mc13783_check_revision(struct mc13783 *mc13783)
292 rev1 = 3; 555 rev1 = 3;
293 556
294 if (rev1 == 0 || icid != 2) { 557 if (rev1 == 0 || icid != 2) {
295 dev_err(mc13783->dev, "No MC13783 detected.\n"); 558 dev_err(&mc13783->spidev->dev, "No MC13783 detected.\n");
296 return -ENODEV; 559 return -ENODEV;
297 } 560 }
298 561
299 mc13783->revision = ((rev1 * 10) + rev2); 562 dev_info(&mc13783->spidev->dev,
300 dev_info(mc13783->dev, "MC13783 Rev %d.%d FinVer %x detected\n", rev1, 563 "MC13783 Rev %d.%d FinVer %x detected\n",
301 rev2, finid); 564 rev1, rev2, finid);
302 565
303 return 0; 566 return 0;
304} 567}
305 568
306/* 569static int mc13783_probe(struct spi_device *spi)
307 * Register a client device. This is non-fatal since there is no need to
308 * fail the entire device init due to a single platform device failing.
309 */
310static void mc13783_client_dev_register(struct mc13783 *mc13783,
311 const char *name)
312{
313 struct mfd_cell cell = {};
314
315 cell.name = name;
316
317 mfd_add_devices(mc13783->dev, -1, &cell, 1, NULL, 0);
318}
319
320static int __devinit mc13783_probe(struct spi_device *spi)
321{ 570{
322 struct mc13783 *mc13783; 571 struct mc13783 *mc13783;
323 struct mc13783_platform_data *pdata = spi->dev.platform_data; 572 struct mc13783_platform_data *pdata = dev_get_platdata(&spi->dev);
324 int ret; 573 int ret;
325 574
326 mc13783 = kzalloc(sizeof(struct mc13783), GFP_KERNEL); 575 mc13783 = kzalloc(sizeof(*mc13783), GFP_KERNEL);
327 if (!mc13783) 576 if (!mc13783)
328 return -ENOMEM; 577 return -ENOMEM;
329 578
@@ -332,96 +581,104 @@ static int __devinit mc13783_probe(struct spi_device *spi)
332 spi->bits_per_word = 32; 581 spi->bits_per_word = 32;
333 spi_setup(spi); 582 spi_setup(spi);
334 583
335 mc13783->spi_device = spi; 584 mc13783->spidev = spi;
336 mc13783->dev = &spi->dev; 585
337 mc13783->irq = spi->irq; 586 mutex_init(&mc13783->lock);
587 mc13783_lock(mc13783);
588
589 ret = mc13783_check_revision(mc13783);
590 if (ret)
591 goto err_revision;
592
593 /* mask all irqs */
594 ret = mc13783_reg_write(mc13783, MC13783_IRQMASK0, 0x00ffffff);
595 if (ret)
596 goto err_mask;
338 597
339 INIT_WORK(&mc13783->work, mc13783_irq_work); 598 ret = mc13783_reg_write(mc13783, MC13783_IRQMASK1, 0x00ffffff);
340 mutex_init(&mc13783->io_lock); 599 if (ret)
341 mutex_init(&mc13783->adc_conv_lock); 600 goto err_mask;
342 init_completion(&mc13783->adc_done); 601
602 ret = request_threaded_irq(spi->irq, NULL, mc13783_irq_thread,
603 IRQF_ONESHOT | IRQF_TRIGGER_HIGH, "mc13783", mc13783);
604
605 if (ret) {
606err_mask:
607err_revision:
608 mutex_unlock(&mc13783->lock);
609 dev_set_drvdata(&spi->dev, NULL);
610 kfree(mc13783);
611 return ret;
612 }
343 613
614 /* This should go away (BEGIN) */
344 if (pdata) { 615 if (pdata) {
345 mc13783->flags = pdata->flags; 616 mc13783->flags = pdata->flags;
346 mc13783->regulators = pdata->regulators; 617 mc13783->regulators = pdata->regulators;
347 mc13783->num_regulators = pdata->num_regulators; 618 mc13783->num_regulators = pdata->num_regulators;
348 } 619 }
620 /* This should go away (END) */
349 621
350 if (mc13783_check_revision(mc13783)) { 622 if (pdata->flags & MC13783_USE_ADC)
351 ret = -ENODEV; 623 mc13783_add_subdevice(mc13783, "mc13783-adc");
352 goto err_out; 624
625 if (pdata->flags & MC13783_USE_CODEC)
626 mc13783_add_subdevice(mc13783, "mc13783-codec");
627
628 if (pdata->flags & MC13783_USE_REGULATOR) {
629 struct mc13783_regulator_platform_data regulator_pdata = {
630 .num_regulators = pdata->num_regulators,
631 .regulators = pdata->regulators,
632 };
633
634 mc13783_add_subdevice_pdata(mc13783, "mc13783-regulator",
635 &regulator_pdata, sizeof(regulator_pdata));
353 } 636 }
354 637
355 /* clear and mask all interrupts */ 638 if (pdata->flags & MC13783_USE_RTC)
356 mc13783_reg_write(mc13783, MC13783_REG_INTERRUPT_STATUS_0, 0x00ffffff); 639 mc13783_add_subdevice(mc13783, "mc13783-rtc");
357 mc13783_reg_write(mc13783, MC13783_REG_INTERRUPT_MASK_0, 0x00ffffff);
358 mc13783_reg_write(mc13783, MC13783_REG_INTERRUPT_STATUS_1, 0x00ffffff);
359 mc13783_reg_write(mc13783, MC13783_REG_INTERRUPT_MASK_1, 0x00ffffff);
360 640
361 /* unmask adcdone interrupts */ 641 if (pdata->flags & MC13783_USE_TOUCHSCREEN)
362 mc13783_set_bits(mc13783, MC13783_REG_INTERRUPT_MASK_0, 642 mc13783_add_subdevice(mc13783, "mc13783-ts");
363 MC13783_INT_MASK_ADCDONEM, 0);
364 643
365 ret = request_irq(mc13783->irq, mc13783_interrupt, 644 mc13783_unlock(mc13783);
366 IRQF_DISABLED | IRQF_TRIGGER_HIGH, "mc13783",
367 mc13783);
368 if (ret)
369 goto err_out;
370
371 if (mc13783->flags & MC13783_USE_CODEC)
372 mc13783_client_dev_register(mc13783, "mc13783-codec");
373 if (mc13783->flags & MC13783_USE_ADC)
374 mc13783_client_dev_register(mc13783, "mc13783-adc");
375 if (mc13783->flags & MC13783_USE_RTC)
376 mc13783_client_dev_register(mc13783, "mc13783-rtc");
377 if (mc13783->flags & MC13783_USE_REGULATOR)
378 mc13783_client_dev_register(mc13783, "mc13783-regulator");
379 if (mc13783->flags & MC13783_USE_TOUCHSCREEN)
380 mc13783_client_dev_register(mc13783, "mc13783-ts");
381 645
382 return 0; 646 return 0;
383
384err_out:
385 kfree(mc13783);
386 return ret;
387} 647}
388 648
389static int __devexit mc13783_remove(struct spi_device *spi) 649static int __devexit mc13783_remove(struct spi_device *spi)
390{ 650{
391 struct mc13783 *mc13783; 651 struct mc13783 *mc13783 = dev_get_drvdata(&spi->dev);
392 652
393 mc13783 = dev_get_drvdata(&spi->dev); 653 free_irq(mc13783->spidev->irq, mc13783);
394
395 free_irq(mc13783->irq, mc13783);
396 654
397 mfd_remove_devices(&spi->dev); 655 mfd_remove_devices(&spi->dev);
398 656
399 return 0; 657 return 0;
400} 658}
401 659
402static struct spi_driver pmic_driver = { 660static struct spi_driver mc13783_driver = {
403 .driver = { 661 .driver = {
404 .name = "mc13783", 662 .name = "mc13783",
405 .bus = &spi_bus_type, 663 .bus = &spi_bus_type,
406 .owner = THIS_MODULE, 664 .owner = THIS_MODULE,
407 }, 665 },
408 .probe = mc13783_probe, 666 .probe = mc13783_probe,
409 .remove = __devexit_p(mc13783_remove), 667 .remove = __devexit_p(mc13783_remove),
410}; 668};
411 669
412static int __init pmic_init(void) 670static int __init mc13783_init(void)
413{ 671{
414 return spi_register_driver(&pmic_driver); 672 return spi_register_driver(&mc13783_driver);
415} 673}
416subsys_initcall(pmic_init); 674subsys_initcall(mc13783_init);
417 675
418static void __exit pmic_exit(void) 676static void __exit mc13783_exit(void)
419{ 677{
420 spi_unregister_driver(&pmic_driver); 678 spi_unregister_driver(&mc13783_driver);
421} 679}
422module_exit(pmic_exit); 680module_exit(mc13783_exit);
423
424MODULE_DESCRIPTION("Core/Protocol driver for Freescale MC13783 PMIC");
425MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
426MODULE_LICENSE("GPL");
427 681
682MODULE_DESCRIPTION("Core driver for Freescale MC13783 PMIC");
683MODULE_AUTHOR("Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>");
684MODULE_LICENSE("GPL v2");
diff --git a/drivers/mfd/pcf50633-adc.c b/drivers/mfd/pcf50633-adc.c
index 3d31e97d6a45..6d2e8466df1d 100644
--- a/drivers/mfd/pcf50633-adc.c
+++ b/drivers/mfd/pcf50633-adc.c
@@ -209,17 +209,16 @@ static void pcf50633_adc_irq(int irq, void *data)
209 209
210static int __devinit pcf50633_adc_probe(struct platform_device *pdev) 210static int __devinit pcf50633_adc_probe(struct platform_device *pdev)
211{ 211{
212 struct pcf50633_subdev_pdata *pdata = pdev->dev.platform_data;
213 struct pcf50633_adc *adc; 212 struct pcf50633_adc *adc;
214 213
215 adc = kzalloc(sizeof(*adc), GFP_KERNEL); 214 adc = kzalloc(sizeof(*adc), GFP_KERNEL);
216 if (!adc) 215 if (!adc)
217 return -ENOMEM; 216 return -ENOMEM;
218 217
219 adc->pcf = pdata->pcf; 218 adc->pcf = dev_to_pcf50633(pdev->dev.parent);
220 platform_set_drvdata(pdev, adc); 219 platform_set_drvdata(pdev, adc);
221 220
222 pcf50633_register_irq(pdata->pcf, PCF50633_IRQ_ADCRDY, 221 pcf50633_register_irq(adc->pcf, PCF50633_IRQ_ADCRDY,
223 pcf50633_adc_irq, adc); 222 pcf50633_adc_irq, adc);
224 223
225 mutex_init(&adc->queue_mutex); 224 mutex_init(&adc->queue_mutex);
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c
index d26d7747175e..03dcc9200707 100644
--- a/drivers/mfd/pcf50633-core.c
+++ b/drivers/mfd/pcf50633-core.c
@@ -290,7 +290,7 @@ out:
290 290
291int pcf50633_irq_mask(struct pcf50633 *pcf, int irq) 291int pcf50633_irq_mask(struct pcf50633 *pcf, int irq)
292{ 292{
293 dev_info(pcf->dev, "Masking IRQ %d\n", irq); 293 dev_dbg(pcf->dev, "Masking IRQ %d\n", irq);
294 294
295 return __pcf50633_irq_mask_set(pcf, irq, 1); 295 return __pcf50633_irq_mask_set(pcf, irq, 1);
296} 296}
@@ -298,7 +298,7 @@ EXPORT_SYMBOL_GPL(pcf50633_irq_mask);
298 298
299int pcf50633_irq_unmask(struct pcf50633 *pcf, int irq) 299int pcf50633_irq_unmask(struct pcf50633 *pcf, int irq)
300{ 300{
301 dev_info(pcf->dev, "Unmasking IRQ %d\n", irq); 301 dev_dbg(pcf->dev, "Unmasking IRQ %d\n", irq);
302 302
303 return __pcf50633_irq_mask_set(pcf, irq, 0); 303 return __pcf50633_irq_mask_set(pcf, irq, 0);
304} 304}
@@ -345,6 +345,9 @@ static void pcf50633_irq_worker(struct work_struct *work)
345 goto out; 345 goto out;
346 } 346 }
347 347
348 /* defeat 8s death from lowsys on A5 */
349 pcf50633_reg_write(pcf, PCF50633_REG_OOCSHDWN, 0x04);
350
348 /* We immediately read the usb and adapter status. We thus make sure 351 /* We immediately read the usb and adapter status. We thus make sure
349 * only of USBINS/USBREM IRQ handlers are called */ 352 * only of USBINS/USBREM IRQ handlers are called */
350 if (pcf_int[0] & (PCF50633_INT1_USBINS | PCF50633_INT1_USBREM)) { 353 if (pcf_int[0] & (PCF50633_INT1_USBINS | PCF50633_INT1_USBREM)) {
@@ -453,7 +456,6 @@ static void
453pcf50633_client_dev_register(struct pcf50633 *pcf, const char *name, 456pcf50633_client_dev_register(struct pcf50633 *pcf, const char *name,
454 struct platform_device **pdev) 457 struct platform_device **pdev)
455{ 458{
456 struct pcf50633_subdev_pdata *subdev_pdata;
457 int ret; 459 int ret;
458 460
459 *pdev = platform_device_alloc(name, -1); 461 *pdev = platform_device_alloc(name, -1);
@@ -462,15 +464,6 @@ pcf50633_client_dev_register(struct pcf50633 *pcf, const char *name,
462 return; 464 return;
463 } 465 }
464 466
465 subdev_pdata = kmalloc(sizeof(*subdev_pdata), GFP_KERNEL);
466 if (!subdev_pdata) {
467 dev_err(pcf->dev, "Error allocating subdev pdata\n");
468 platform_device_put(*pdev);
469 }
470
471 subdev_pdata->pcf = pcf;
472 platform_device_add_data(*pdev, subdev_pdata, sizeof(*subdev_pdata));
473
474 (*pdev)->dev.parent = pcf->dev; 467 (*pdev)->dev.parent = pcf->dev;
475 468
476 ret = platform_device_add(*pdev); 469 ret = platform_device_add(*pdev);
@@ -482,13 +475,13 @@ pcf50633_client_dev_register(struct pcf50633 *pcf, const char *name,
482} 475}
483 476
484#ifdef CONFIG_PM 477#ifdef CONFIG_PM
485static int pcf50633_suspend(struct device *dev, pm_message_t state) 478static int pcf50633_suspend(struct i2c_client *client, pm_message_t state)
486{ 479{
487 struct pcf50633 *pcf; 480 struct pcf50633 *pcf;
488 int ret = 0, i; 481 int ret = 0, i;
489 u8 res[5]; 482 u8 res[5];
490 483
491 pcf = dev_get_drvdata(dev); 484 pcf = i2c_get_clientdata(client);
492 485
493 /* Make sure our interrupt handlers are not called 486 /* Make sure our interrupt handlers are not called
494 * henceforth */ 487 * henceforth */
@@ -523,12 +516,12 @@ out:
523 return ret; 516 return ret;
524} 517}
525 518
526static int pcf50633_resume(struct device *dev) 519static int pcf50633_resume(struct i2c_client *client)
527{ 520{
528 struct pcf50633 *pcf; 521 struct pcf50633 *pcf;
529 int ret; 522 int ret;
530 523
531 pcf = dev_get_drvdata(dev); 524 pcf = i2c_get_clientdata(client);
532 525
533 /* Write the saved mask registers */ 526 /* Write the saved mask registers */
534 ret = pcf50633_write_block(pcf, PCF50633_REG_INT1M, 527 ret = pcf50633_write_block(pcf, PCF50633_REG_INT1M,
@@ -560,9 +553,14 @@ static int __devinit pcf50633_probe(struct i2c_client *client,
560{ 553{
561 struct pcf50633 *pcf; 554 struct pcf50633 *pcf;
562 struct pcf50633_platform_data *pdata = client->dev.platform_data; 555 struct pcf50633_platform_data *pdata = client->dev.platform_data;
563 int i, ret = 0; 556 int i, ret;
564 int version, variant; 557 int version, variant;
565 558
559 if (!client->irq) {
560 dev_err(&client->dev, "Missing IRQ\n");
561 return -ENOENT;
562 }
563
566 pcf = kzalloc(sizeof(*pcf), GFP_KERNEL); 564 pcf = kzalloc(sizeof(*pcf), GFP_KERNEL);
567 if (!pcf) 565 if (!pcf)
568 return -ENOMEM; 566 return -ENOMEM;
@@ -577,6 +575,12 @@ static int __devinit pcf50633_probe(struct i2c_client *client,
577 pcf->irq = client->irq; 575 pcf->irq = client->irq;
578 pcf->work_queue = create_singlethread_workqueue("pcf50633"); 576 pcf->work_queue = create_singlethread_workqueue("pcf50633");
579 577
578 if (!pcf->work_queue) {
579 dev_err(&client->dev, "Failed to alloc workqueue\n");
580 ret = -ENOMEM;
581 goto err_free;
582 }
583
580 INIT_WORK(&pcf->irq_work, pcf50633_irq_worker); 584 INIT_WORK(&pcf->irq_work, pcf50633_irq_worker);
581 585
582 version = pcf50633_reg_read(pcf, 0); 586 version = pcf50633_reg_read(pcf, 0);
@@ -584,7 +588,7 @@ static int __devinit pcf50633_probe(struct i2c_client *client,
584 if (version < 0 || variant < 0) { 588 if (version < 0 || variant < 0) {
585 dev_err(pcf->dev, "Unable to probe pcf50633\n"); 589 dev_err(pcf->dev, "Unable to probe pcf50633\n");
586 ret = -ENODEV; 590 ret = -ENODEV;
587 goto err; 591 goto err_destroy_workqueue;
588 } 592 }
589 593
590 dev_info(pcf->dev, "Probed device version %d variant %d\n", 594 dev_info(pcf->dev, "Probed device version %d variant %d\n",
@@ -598,6 +602,14 @@ static int __devinit pcf50633_probe(struct i2c_client *client,
598 pcf50633_reg_write(pcf, PCF50633_REG_INT4M, 0x00); 602 pcf50633_reg_write(pcf, PCF50633_REG_INT4M, 0x00);
599 pcf50633_reg_write(pcf, PCF50633_REG_INT5M, 0x00); 603 pcf50633_reg_write(pcf, PCF50633_REG_INT5M, 0x00);
600 604
605 ret = request_irq(client->irq, pcf50633_irq,
606 IRQF_TRIGGER_LOW, "pcf50633", pcf);
607
608 if (ret) {
609 dev_err(pcf->dev, "Failed to request IRQ %d\n", ret);
610 goto err_destroy_workqueue;
611 }
612
601 /* Create sub devices */ 613 /* Create sub devices */
602 pcf50633_client_dev_register(pcf, "pcf50633-input", 614 pcf50633_client_dev_register(pcf, "pcf50633-input",
603 &pcf->input_pdev); 615 &pcf->input_pdev);
@@ -613,31 +625,18 @@ static int __devinit pcf50633_probe(struct i2c_client *client,
613 625
614 pdev = platform_device_alloc("pcf50633-regltr", i); 626 pdev = platform_device_alloc("pcf50633-regltr", i);
615 if (!pdev) { 627 if (!pdev) {
616 dev_err(pcf->dev, "Cannot create regulator\n"); 628 dev_err(pcf->dev, "Cannot create regulator %d\n", i);
617 continue; 629 continue;
618 } 630 }
619 631
620 pdev->dev.parent = pcf->dev; 632 pdev->dev.parent = pcf->dev;
621 pdev->dev.platform_data = &pdata->reg_init_data[i]; 633 platform_device_add_data(pdev, &pdata->reg_init_data[i],
622 dev_set_drvdata(&pdev->dev, pcf); 634 sizeof(pdata->reg_init_data[i]));
623 pcf->regulator_pdev[i] = pdev; 635 pcf->regulator_pdev[i] = pdev;
624 636
625 platform_device_add(pdev); 637 platform_device_add(pdev);
626 } 638 }
627 639
628 if (client->irq) {
629 ret = request_irq(client->irq, pcf50633_irq,
630 IRQF_TRIGGER_LOW, "pcf50633", pcf);
631
632 if (ret) {
633 dev_err(pcf->dev, "Failed to request IRQ %d\n", ret);
634 goto err;
635 }
636 } else {
637 dev_err(pcf->dev, "No IRQ configured\n");
638 goto err;
639 }
640
641 if (enable_irq_wake(client->irq) < 0) 640 if (enable_irq_wake(client->irq) < 0)
642 dev_err(pcf->dev, "IRQ %u cannot be enabled as wake-up source" 641 dev_err(pcf->dev, "IRQ %u cannot be enabled as wake-up source"
643 "in this hardware revision", client->irq); 642 "in this hardware revision", client->irq);
@@ -651,9 +650,12 @@ static int __devinit pcf50633_probe(struct i2c_client *client,
651 650
652 return 0; 651 return 0;
653 652
654err: 653err_destroy_workqueue:
655 destroy_workqueue(pcf->work_queue); 654 destroy_workqueue(pcf->work_queue);
655err_free:
656 i2c_set_clientdata(client, NULL);
656 kfree(pcf); 657 kfree(pcf);
658
657 return ret; 659 return ret;
658} 660}
659 661
@@ -686,12 +688,12 @@ static struct i2c_device_id pcf50633_id_table[] = {
686static struct i2c_driver pcf50633_driver = { 688static struct i2c_driver pcf50633_driver = {
687 .driver = { 689 .driver = {
688 .name = "pcf50633", 690 .name = "pcf50633",
689 .suspend = pcf50633_suspend,
690 .resume = pcf50633_resume,
691 }, 691 },
692 .id_table = pcf50633_id_table, 692 .id_table = pcf50633_id_table,
693 .probe = pcf50633_probe, 693 .probe = pcf50633_probe,
694 .remove = __devexit_p(pcf50633_remove), 694 .remove = __devexit_p(pcf50633_remove),
695 .suspend = pcf50633_suspend,
696 .resume = pcf50633_resume,
695}; 697};
696 698
697static int __init pcf50633_init(void) 699static int __init pcf50633_init(void)
diff --git a/drivers/mfd/tps65010.c b/drivers/mfd/tps65010.c
index acf8b9d5f575..e5955306c2fa 100644
--- a/drivers/mfd/tps65010.c
+++ b/drivers/mfd/tps65010.c
@@ -637,7 +637,7 @@ static int tps65010_probe(struct i2c_client *client,
637 tps, DEBUG_FOPS); 637 tps, DEBUG_FOPS);
638 638
639 /* optionally register GPIOs */ 639 /* optionally register GPIOs */
640 if (board && board->base > 0) { 640 if (board && board->base != 0) {
641 tps->outmask = board->outmask; 641 tps->outmask = board->outmask;
642 642
643 tps->chip.label = client->name; 643 tps->chip.label = client->name;
@@ -964,6 +964,34 @@ int tps65010_config_vregs1(unsigned value)
964} 964}
965EXPORT_SYMBOL(tps65010_config_vregs1); 965EXPORT_SYMBOL(tps65010_config_vregs1);
966 966
967int tps65010_config_vdcdc2(unsigned value)
968{
969 struct i2c_client *c;
970 int status;
971
972 if (!the_tps)
973 return -ENODEV;
974
975 c = the_tps->client;
976 mutex_lock(&the_tps->lock);
977
978 pr_debug("%s: vdcdc2 0x%02x\n", DRIVER_NAME,
979 i2c_smbus_read_byte_data(c, TPS_VDCDC2));
980
981 status = i2c_smbus_write_byte_data(c, TPS_VDCDC2, value);
982
983 if (status != 0)
984 printk(KERN_ERR "%s: Failed to write vdcdc2 register\n",
985 DRIVER_NAME);
986 else
987 pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME,
988 i2c_smbus_read_byte_data(c, TPS_VDCDC2));
989
990 mutex_unlock(&the_tps->lock);
991 return status;
992}
993EXPORT_SYMBOL(tps65010_config_vdcdc2);
994
967/*-------------------------------------------------------------------------*/ 995/*-------------------------------------------------------------------------*/
968/* tps65013_set_low_pwr parameter: 996/* tps65013_set_low_pwr parameter:
969 * mode: ON or OFF 997 * mode: ON or OFF
diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl-core.c
index 40449cdf09db..2a7606534196 100644
--- a/drivers/mfd/twl4030-core.c
+++ b/drivers/mfd/twl-core.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * twl4030_core.c - driver for TWL4030/TPS659x0 PM and audio CODEC devices 2 * twl_core.c - driver for TWL4030/TWL5030/TWL60X0/TPS659x0 PM
3 * and audio CODEC devices
3 * 4 *
4 * Copyright (C) 2005-2006 Texas Instruments, Inc. 5 * Copyright (C) 2005-2006 Texas Instruments, Inc.
5 * 6 *
@@ -36,7 +37,7 @@
36#include <linux/regulator/machine.h> 37#include <linux/regulator/machine.h>
37 38
38#include <linux/i2c.h> 39#include <linux/i2c.h>
39#include <linux/i2c/twl4030.h> 40#include <linux/i2c/twl.h>
40 41
41#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) 42#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
42#include <plat/cpu.h> 43#include <plat/cpu.h>
@@ -55,7 +56,7 @@
55 * (and associated registers). 56 * (and associated registers).
56 */ 57 */
57 58
58#define DRIVER_NAME "twl4030" 59#define DRIVER_NAME "twl"
59 60
60#if defined(CONFIG_TWL4030_BCI_BATTERY) || \ 61#if defined(CONFIG_TWL4030_BCI_BATTERY) || \
61 defined(CONFIG_TWL4030_BCI_BATTERY_MODULE) 62 defined(CONFIG_TWL4030_BCI_BATTERY_MODULE)
@@ -125,7 +126,7 @@
125/* Last - for index max*/ 126/* Last - for index max*/
126#define TWL4030_MODULE_LAST TWL4030_MODULE_SECURED_REG 127#define TWL4030_MODULE_LAST TWL4030_MODULE_SECURED_REG
127 128
128#define TWL4030_NUM_SLAVES 4 129#define TWL_NUM_SLAVES 4
129 130
130#if defined(CONFIG_INPUT_TWL4030_PWRBUTTON) \ 131#if defined(CONFIG_INPUT_TWL4030_PWRBUTTON) \
131 || defined(CONFIG_INPUT_TWL4030_PWBUTTON_MODULE) 132 || defined(CONFIG_INPUT_TWL4030_PWBUTTON_MODULE)
@@ -134,6 +135,13 @@
134#define twl_has_pwrbutton() false 135#define twl_has_pwrbutton() false
135#endif 136#endif
136 137
138#define SUB_CHIP_ID0 0
139#define SUB_CHIP_ID1 1
140#define SUB_CHIP_ID2 2
141#define SUB_CHIP_ID3 3
142
143#define TWL_MODULE_LAST TWL4030_MODULE_LAST
144
137/* Base Address defns for twl4030_map[] */ 145/* Base Address defns for twl4030_map[] */
138 146
139/* subchip/slave 0 - USB ID */ 147/* subchip/slave 0 - USB ID */
@@ -158,6 +166,10 @@
158#define TWL4030_BASEADD_PWMB 0x00F1 166#define TWL4030_BASEADD_PWMB 0x00F1
159#define TWL4030_BASEADD_KEYPAD 0x00D2 167#define TWL4030_BASEADD_KEYPAD 0x00D2
160 168
169#define TWL5031_BASEADD_ACCESSORY 0x0074 /* Replaces Main Charge */
170#define TWL5031_BASEADD_INTERRUPTS 0x00B9 /* Different than TWL4030's
171 one */
172
161/* subchip/slave 3 - POWER ID */ 173/* subchip/slave 3 - POWER ID */
162#define TWL4030_BASEADD_BACKUP 0x0014 174#define TWL4030_BASEADD_BACKUP 0x0014
163#define TWL4030_BASEADD_INT 0x002E 175#define TWL4030_BASEADD_INT 0x002E
@@ -169,6 +181,30 @@
169/* Triton Core internal information (END) */ 181/* Triton Core internal information (END) */
170 182
171 183
184/* subchip/slave 0 0x48 - POWER */
185#define TWL6030_BASEADD_RTC 0x0000
186#define TWL6030_BASEADD_MEM 0x0017
187#define TWL6030_BASEADD_PM_MASTER 0x001F
188#define TWL6030_BASEADD_PM_SLAVE_MISC 0x0030 /* PM_RECEIVER */
189#define TWL6030_BASEADD_PM_MISC 0x00E2
190#define TWL6030_BASEADD_PM_PUPD 0x00F0
191
192/* subchip/slave 1 0x49 - FEATURE */
193#define TWL6030_BASEADD_USB 0x0000
194#define TWL6030_BASEADD_GPADC_CTRL 0x002E
195#define TWL6030_BASEADD_AUX 0x0090
196#define TWL6030_BASEADD_PWM 0x00BA
197#define TWL6030_BASEADD_GASGAUGE 0x00C0
198#define TWL6030_BASEADD_PIH 0x00D0
199#define TWL6030_BASEADD_CHARGER 0x00E0
200
201/* subchip/slave 2 0x4A - DFT */
202#define TWL6030_BASEADD_DIEID 0x00C0
203
204/* subchip/slave 3 0x4B - AUDIO */
205#define TWL6030_BASEADD_AUDIO 0x0000
206#define TWL6030_BASEADD_RSV 0x0000
207
172/* Few power values */ 208/* Few power values */
173#define R_CFG_BOOT 0x05 209#define R_CFG_BOOT 0x05
174#define R_PROTECT_KEY 0x0E 210#define R_PROTECT_KEY 0x0E
@@ -183,19 +219,29 @@
183#define HFCLK_FREQ_26_MHZ (2 << 0) 219#define HFCLK_FREQ_26_MHZ (2 << 0)
184#define HFCLK_FREQ_38p4_MHZ (3 << 0) 220#define HFCLK_FREQ_38p4_MHZ (3 << 0)
185#define HIGH_PERF_SQ (1 << 3) 221#define HIGH_PERF_SQ (1 << 3)
222#define CK32K_LOWPWR_EN (1 << 7)
186 223
187 224
188/* chip-specific feature flags, for i2c_device_id.driver_data */ 225/* chip-specific feature flags, for i2c_device_id.driver_data */
189#define TWL4030_VAUX2 BIT(0) /* pre-5030 voltage ranges */ 226#define TWL4030_VAUX2 BIT(0) /* pre-5030 voltage ranges */
190#define TPS_SUBSET BIT(1) /* tps659[23]0 have fewer LDOs */ 227#define TPS_SUBSET BIT(1) /* tps659[23]0 have fewer LDOs */
228#define TWL5031 BIT(2) /* twl5031 has different registers */
229#define TWL6030_CLASS BIT(3) /* TWL6030 class */
191 230
192/*----------------------------------------------------------------------*/ 231/*----------------------------------------------------------------------*/
193 232
194/* is driver active, bound to a chip? */ 233/* is driver active, bound to a chip? */
195static bool inuse; 234static bool inuse;
196 235
197/* Structure for each TWL4030 Slave */ 236static unsigned int twl_id;
198struct twl4030_client { 237unsigned int twl_rev(void)
238{
239 return twl_id;
240}
241EXPORT_SYMBOL(twl_rev);
242
243/* Structure for each TWL4030/TWL6030 Slave */
244struct twl_client {
199 struct i2c_client *client; 245 struct i2c_client *client;
200 u8 address; 246 u8 address;
201 247
@@ -206,19 +252,20 @@ struct twl4030_client {
206 struct mutex xfer_lock; 252 struct mutex xfer_lock;
207}; 253};
208 254
209static struct twl4030_client twl4030_modules[TWL4030_NUM_SLAVES]; 255static struct twl_client twl_modules[TWL_NUM_SLAVES];
210 256
211 257
212/* mapping the module id to slave id and base address */ 258/* mapping the module id to slave id and base address */
213struct twl4030mapping { 259struct twl_mapping {
214 unsigned char sid; /* Slave ID */ 260 unsigned char sid; /* Slave ID */
215 unsigned char base; /* base address */ 261 unsigned char base; /* base address */
216}; 262};
263struct twl_mapping *twl_map;
217 264
218static struct twl4030mapping twl4030_map[TWL4030_MODULE_LAST + 1] = { 265static struct twl_mapping twl4030_map[TWL4030_MODULE_LAST + 1] = {
219 /* 266 /*
220 * NOTE: don't change this table without updating the 267 * NOTE: don't change this table without updating the
221 * <linux/i2c/twl4030.h> defines for TWL4030_MODULE_* 268 * <linux/i2c/twl.h> defines for TWL4030_MODULE_*
222 * so they continue to match the order in this table. 269 * so they continue to match the order in this table.
223 */ 270 */
224 271
@@ -240,6 +287,8 @@ static struct twl4030mapping twl4030_map[TWL4030_MODULE_LAST + 1] = {
240 { 2, TWL4030_BASEADD_PWM1 }, 287 { 2, TWL4030_BASEADD_PWM1 },
241 { 2, TWL4030_BASEADD_PWMA }, 288 { 2, TWL4030_BASEADD_PWMA },
242 { 2, TWL4030_BASEADD_PWMB }, 289 { 2, TWL4030_BASEADD_PWMB },
290 { 2, TWL5031_BASEADD_ACCESSORY },
291 { 2, TWL5031_BASEADD_INTERRUPTS },
243 292
244 { 3, TWL4030_BASEADD_BACKUP }, 293 { 3, TWL4030_BASEADD_BACKUP },
245 { 3, TWL4030_BASEADD_INT }, 294 { 3, TWL4030_BASEADD_INT },
@@ -249,12 +298,46 @@ static struct twl4030mapping twl4030_map[TWL4030_MODULE_LAST + 1] = {
249 { 3, TWL4030_BASEADD_SECURED_REG }, 298 { 3, TWL4030_BASEADD_SECURED_REG },
250}; 299};
251 300
301static struct twl_mapping twl6030_map[] = {
302 /*
303 * NOTE: don't change this table without updating the
304 * <linux/i2c/twl.h> defines for TWL4030_MODULE_*
305 * so they continue to match the order in this table.
306 */
307 { SUB_CHIP_ID1, TWL6030_BASEADD_USB },
308 { SUB_CHIP_ID3, TWL6030_BASEADD_AUDIO },
309 { SUB_CHIP_ID2, TWL6030_BASEADD_DIEID },
310 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
311 { SUB_CHIP_ID1, TWL6030_BASEADD_PIH },
312
313 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
314 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
315 { SUB_CHIP_ID1, TWL6030_BASEADD_GPADC_CTRL },
316 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
317 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
318
319 { SUB_CHIP_ID1, TWL6030_BASEADD_CHARGER },
320 { SUB_CHIP_ID1, TWL6030_BASEADD_GASGAUGE },
321 { SUB_CHIP_ID1, TWL6030_BASEADD_PWM },
322 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
323 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
324
325 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
326 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
327 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
328 { SUB_CHIP_ID0, TWL6030_BASEADD_PM_MASTER },
329 { SUB_CHIP_ID0, TWL6030_BASEADD_PM_SLAVE_MISC },
330
331 { SUB_CHIP_ID0, TWL6030_BASEADD_RTC },
332 { SUB_CHIP_ID0, TWL6030_BASEADD_MEM },
333};
334
252/*----------------------------------------------------------------------*/ 335/*----------------------------------------------------------------------*/
253 336
254/* Exported Functions */ 337/* Exported Functions */
255 338
256/** 339/**
257 * twl4030_i2c_write - Writes a n bit register in TWL4030 340 * twl_i2c_write - Writes a n bit register in TWL4030/TWL5030/TWL60X0
258 * @mod_no: module number 341 * @mod_no: module number
259 * @value: an array of num_bytes+1 containing data to write 342 * @value: an array of num_bytes+1 containing data to write
260 * @reg: register address (just offset will do) 343 * @reg: register address (just offset will do)
@@ -265,19 +348,19 @@ static struct twl4030mapping twl4030_map[TWL4030_MODULE_LAST + 1] = {
265 * 348 *
266 * Returns the result of operation - 0 is success 349 * Returns the result of operation - 0 is success
267 */ 350 */
268int twl4030_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes) 351int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
269{ 352{
270 int ret; 353 int ret;
271 int sid; 354 int sid;
272 struct twl4030_client *twl; 355 struct twl_client *twl;
273 struct i2c_msg *msg; 356 struct i2c_msg *msg;
274 357
275 if (unlikely(mod_no > TWL4030_MODULE_LAST)) { 358 if (unlikely(mod_no > TWL_MODULE_LAST)) {
276 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); 359 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
277 return -EPERM; 360 return -EPERM;
278 } 361 }
279 sid = twl4030_map[mod_no].sid; 362 sid = twl_map[mod_no].sid;
280 twl = &twl4030_modules[sid]; 363 twl = &twl_modules[sid];
281 364
282 if (unlikely(!inuse)) { 365 if (unlikely(!inuse)) {
283 pr_err("%s: client %d is not initialized\n", DRIVER_NAME, sid); 366 pr_err("%s: client %d is not initialized\n", DRIVER_NAME, sid);
@@ -294,19 +377,26 @@ int twl4030_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
294 msg->flags = 0; 377 msg->flags = 0;
295 msg->buf = value; 378 msg->buf = value;
296 /* over write the first byte of buffer with the register address */ 379 /* over write the first byte of buffer with the register address */
297 *value = twl4030_map[mod_no].base + reg; 380 *value = twl_map[mod_no].base + reg;
298 ret = i2c_transfer(twl->client->adapter, twl->xfer_msg, 1); 381 ret = i2c_transfer(twl->client->adapter, twl->xfer_msg, 1);
299 mutex_unlock(&twl->xfer_lock); 382 mutex_unlock(&twl->xfer_lock);
300 383
301 /* i2cTransfer returns num messages.translate it pls.. */ 384 /* i2c_transfer returns number of messages transferred */
302 if (ret >= 0) 385 if (ret != 1) {
303 ret = 0; 386 pr_err("%s: i2c_write failed to transfer all messages\n",
304 return ret; 387 DRIVER_NAME);
388 if (ret < 0)
389 return ret;
390 else
391 return -EIO;
392 } else {
393 return 0;
394 }
305} 395}
306EXPORT_SYMBOL(twl4030_i2c_write); 396EXPORT_SYMBOL(twl_i2c_write);
307 397
308/** 398/**
309 * twl4030_i2c_read - Reads a n bit register in TWL4030 399 * twl_i2c_read - Reads a n bit register in TWL4030/TWL5030/TWL60X0
310 * @mod_no: module number 400 * @mod_no: module number
311 * @value: an array of num_bytes containing data to be read 401 * @value: an array of num_bytes containing data to be read
312 * @reg: register address (just offset will do) 402 * @reg: register address (just offset will do)
@@ -314,20 +404,20 @@ EXPORT_SYMBOL(twl4030_i2c_write);
314 * 404 *
315 * Returns result of operation - num_bytes is success else failure. 405 * Returns result of operation - num_bytes is success else failure.
316 */ 406 */
317int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes) 407int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
318{ 408{
319 int ret; 409 int ret;
320 u8 val; 410 u8 val;
321 int sid; 411 int sid;
322 struct twl4030_client *twl; 412 struct twl_client *twl;
323 struct i2c_msg *msg; 413 struct i2c_msg *msg;
324 414
325 if (unlikely(mod_no > TWL4030_MODULE_LAST)) { 415 if (unlikely(mod_no > TWL_MODULE_LAST)) {
326 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); 416 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
327 return -EPERM; 417 return -EPERM;
328 } 418 }
329 sid = twl4030_map[mod_no].sid; 419 sid = twl_map[mod_no].sid;
330 twl = &twl4030_modules[sid]; 420 twl = &twl_modules[sid];
331 421
332 if (unlikely(!inuse)) { 422 if (unlikely(!inuse)) {
333 pr_err("%s: client %d is not initialized\n", DRIVER_NAME, sid); 423 pr_err("%s: client %d is not initialized\n", DRIVER_NAME, sid);
@@ -339,7 +429,7 @@ int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
339 msg->addr = twl->address; 429 msg->addr = twl->address;
340 msg->len = 1; 430 msg->len = 1;
341 msg->flags = 0; /* Read the register value */ 431 msg->flags = 0; /* Read the register value */
342 val = twl4030_map[mod_no].base + reg; 432 val = twl_map[mod_no].base + reg;
343 msg->buf = &val; 433 msg->buf = &val;
344 /* [MSG2] fill the data rx buffer */ 434 /* [MSG2] fill the data rx buffer */
345 msg = &twl->xfer_msg[1]; 435 msg = &twl->xfer_msg[1];
@@ -350,45 +440,52 @@ int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
350 ret = i2c_transfer(twl->client->adapter, twl->xfer_msg, 2); 440 ret = i2c_transfer(twl->client->adapter, twl->xfer_msg, 2);
351 mutex_unlock(&twl->xfer_lock); 441 mutex_unlock(&twl->xfer_lock);
352 442
353 /* i2cTransfer returns num messages.translate it pls.. */ 443 /* i2c_transfer returns number of messages transferred */
354 if (ret >= 0) 444 if (ret != 2) {
355 ret = 0; 445 pr_err("%s: i2c_read failed to transfer all messages\n",
356 return ret; 446 DRIVER_NAME);
447 if (ret < 0)
448 return ret;
449 else
450 return -EIO;
451 } else {
452 return 0;
453 }
357} 454}
358EXPORT_SYMBOL(twl4030_i2c_read); 455EXPORT_SYMBOL(twl_i2c_read);
359 456
360/** 457/**
361 * twl4030_i2c_write_u8 - Writes a 8 bit register in TWL4030 458 * twl_i2c_write_u8 - Writes a 8 bit register in TWL4030/TWL5030/TWL60X0
362 * @mod_no: module number 459 * @mod_no: module number
363 * @value: the value to be written 8 bit 460 * @value: the value to be written 8 bit
364 * @reg: register address (just offset will do) 461 * @reg: register address (just offset will do)
365 * 462 *
366 * Returns result of operation - 0 is success 463 * Returns result of operation - 0 is success
367 */ 464 */
368int twl4030_i2c_write_u8(u8 mod_no, u8 value, u8 reg) 465int twl_i2c_write_u8(u8 mod_no, u8 value, u8 reg)
369{ 466{
370 467
371 /* 2 bytes offset 1 contains the data offset 0 is used by i2c_write */ 468 /* 2 bytes offset 1 contains the data offset 0 is used by i2c_write */
372 u8 temp_buffer[2] = { 0 }; 469 u8 temp_buffer[2] = { 0 };
373 /* offset 1 contains the data */ 470 /* offset 1 contains the data */
374 temp_buffer[1] = value; 471 temp_buffer[1] = value;
375 return twl4030_i2c_write(mod_no, temp_buffer, reg, 1); 472 return twl_i2c_write(mod_no, temp_buffer, reg, 1);
376} 473}
377EXPORT_SYMBOL(twl4030_i2c_write_u8); 474EXPORT_SYMBOL(twl_i2c_write_u8);
378 475
379/** 476/**
380 * twl4030_i2c_read_u8 - Reads a 8 bit register from TWL4030 477 * twl_i2c_read_u8 - Reads a 8 bit register from TWL4030/TWL5030/TWL60X0
381 * @mod_no: module number 478 * @mod_no: module number
382 * @value: the value read 8 bit 479 * @value: the value read 8 bit
383 * @reg: register address (just offset will do) 480 * @reg: register address (just offset will do)
384 * 481 *
385 * Returns result of operation - 0 is success 482 * Returns result of operation - 0 is success
386 */ 483 */
387int twl4030_i2c_read_u8(u8 mod_no, u8 *value, u8 reg) 484int twl_i2c_read_u8(u8 mod_no, u8 *value, u8 reg)
388{ 485{
389 return twl4030_i2c_read(mod_no, value, reg, 1); 486 return twl_i2c_read(mod_no, value, reg, 1);
390} 487}
391EXPORT_SYMBOL(twl4030_i2c_read_u8); 488EXPORT_SYMBOL(twl_i2c_read_u8);
392 489
393/*----------------------------------------------------------------------*/ 490/*----------------------------------------------------------------------*/
394 491
@@ -398,7 +495,7 @@ add_numbered_child(unsigned chip, const char *name, int num,
398 bool can_wakeup, int irq0, int irq1) 495 bool can_wakeup, int irq0, int irq1)
399{ 496{
400 struct platform_device *pdev; 497 struct platform_device *pdev;
401 struct twl4030_client *twl = &twl4030_modules[chip]; 498 struct twl_client *twl = &twl_modules[chip];
402 int status; 499 int status;
403 500
404 pdev = platform_device_alloc(name, num); 501 pdev = platform_device_alloc(name, num);
@@ -456,6 +553,7 @@ add_regulator_linked(int num, struct regulator_init_data *pdata,
456 struct regulator_consumer_supply *consumers, 553 struct regulator_consumer_supply *consumers,
457 unsigned num_consumers) 554 unsigned num_consumers)
458{ 555{
556 unsigned sub_chip_id;
459 /* regulator framework demands init_data ... */ 557 /* regulator framework demands init_data ... */
460 if (!pdata) 558 if (!pdata)
461 return NULL; 559 return NULL;
@@ -466,7 +564,8 @@ add_regulator_linked(int num, struct regulator_init_data *pdata,
466 } 564 }
467 565
468 /* NOTE: we currently ignore regulator IRQs, e.g. for short circuits */ 566 /* NOTE: we currently ignore regulator IRQs, e.g. for short circuits */
469 return add_numbered_child(3, "twl4030_reg", num, 567 sub_chip_id = twl_map[TWL_MODULE_PM_MASTER].sid;
568 return add_numbered_child(sub_chip_id, "twl_reg", num,
470 pdata, sizeof(*pdata), false, 0, 0); 569 pdata, sizeof(*pdata), false, 0, 0);
471} 570}
472 571
@@ -486,29 +585,32 @@ static int
486add_children(struct twl4030_platform_data *pdata, unsigned long features) 585add_children(struct twl4030_platform_data *pdata, unsigned long features)
487{ 586{
488 struct device *child; 587 struct device *child;
588 unsigned sub_chip_id;
489 589
490 if (twl_has_bci() && pdata->bci && !(features & TPS_SUBSET)) { 590 if (twl_has_bci() && pdata->bci &&
591 !(features & (TPS_SUBSET | TWL5031))) {
491 child = add_child(3, "twl4030_bci", 592 child = add_child(3, "twl4030_bci",
492 pdata->bci, sizeof(*pdata->bci), 593 pdata->bci, sizeof(*pdata->bci),
493 false, 594 false,
494 /* irq0 = CHG_PRES, irq1 = BCI */ 595 /* irq0 = CHG_PRES, irq1 = BCI */
495 pdata->irq_base + 8 + 1, pdata->irq_base + 2); 596 pdata->irq_base + BCI_PRES_INTR_OFFSET,
597 pdata->irq_base + BCI_INTR_OFFSET);
496 if (IS_ERR(child)) 598 if (IS_ERR(child))
497 return PTR_ERR(child); 599 return PTR_ERR(child);
498 } 600 }
499 601
500 if (twl_has_gpio() && pdata->gpio) { 602 if (twl_has_gpio() && pdata->gpio) {
501 child = add_child(1, "twl4030_gpio", 603 child = add_child(SUB_CHIP_ID1, "twl4030_gpio",
502 pdata->gpio, sizeof(*pdata->gpio), 604 pdata->gpio, sizeof(*pdata->gpio),
503 false, pdata->irq_base + 0, 0); 605 false, pdata->irq_base + GPIO_INTR_OFFSET, 0);
504 if (IS_ERR(child)) 606 if (IS_ERR(child))
505 return PTR_ERR(child); 607 return PTR_ERR(child);
506 } 608 }
507 609
508 if (twl_has_keypad() && pdata->keypad) { 610 if (twl_has_keypad() && pdata->keypad) {
509 child = add_child(2, "twl4030_keypad", 611 child = add_child(SUB_CHIP_ID2, "twl4030_keypad",
510 pdata->keypad, sizeof(*pdata->keypad), 612 pdata->keypad, sizeof(*pdata->keypad),
511 true, pdata->irq_base + 1, 0); 613 true, pdata->irq_base + KEYPAD_INTR_OFFSET, 0);
512 if (IS_ERR(child)) 614 if (IS_ERR(child))
513 return PTR_ERR(child); 615 return PTR_ERR(child);
514 } 616 }
@@ -516,7 +618,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
516 if (twl_has_madc() && pdata->madc) { 618 if (twl_has_madc() && pdata->madc) {
517 child = add_child(2, "twl4030_madc", 619 child = add_child(2, "twl4030_madc",
518 pdata->madc, sizeof(*pdata->madc), 620 pdata->madc, sizeof(*pdata->madc),
519 true, pdata->irq_base + 3, 0); 621 true, pdata->irq_base + MADC_INTR_OFFSET, 0);
520 if (IS_ERR(child)) 622 if (IS_ERR(child))
521 return PTR_ERR(child); 623 return PTR_ERR(child);
522 } 624 }
@@ -529,14 +631,15 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
529 * Eventually, Linux might become more aware of such 631 * Eventually, Linux might become more aware of such
530 * HW security concerns, and "least privilege". 632 * HW security concerns, and "least privilege".
531 */ 633 */
532 child = add_child(3, "twl4030_rtc", 634 sub_chip_id = twl_map[TWL_MODULE_RTC].sid;
635 child = add_child(sub_chip_id, "twl_rtc",
533 NULL, 0, 636 NULL, 0,
534 true, pdata->irq_base + 8 + 3, 0); 637 true, pdata->irq_base + RTC_INTR_OFFSET, 0);
535 if (IS_ERR(child)) 638 if (IS_ERR(child))
536 return PTR_ERR(child); 639 return PTR_ERR(child);
537 } 640 }
538 641
539 if (twl_has_usb() && pdata->usb) { 642 if (twl_has_usb() && pdata->usb && twl_class_is_4030()) {
540 643
541 static struct regulator_consumer_supply usb1v5 = { 644 static struct regulator_consumer_supply usb1v5 = {
542 .supply = "usb1v5", 645 .supply = "usb1v5",
@@ -581,7 +684,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
581 pdata->usb, sizeof(*pdata->usb), 684 pdata->usb, sizeof(*pdata->usb),
582 true, 685 true,
583 /* irq0 = USB_PRES, irq1 = USB */ 686 /* irq0 = USB_PRES, irq1 = USB */
584 pdata->irq_base + 8 + 2, pdata->irq_base + 4); 687 pdata->irq_base + USB_PRES_INTR_OFFSET,
688 pdata->irq_base + USB_INTR_OFFSET);
585 689
586 if (IS_ERR(child)) 690 if (IS_ERR(child))
587 return PTR_ERR(child); 691 return PTR_ERR(child);
@@ -615,12 +719,23 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
615 return PTR_ERR(child); 719 return PTR_ERR(child);
616 } 720 }
617 721
618 if (twl_has_regulator()) { 722 /* twl4030 regulators */
619 /* 723 if (twl_has_regulator() && twl_class_is_4030()) {
620 child = add_regulator(TWL4030_REG_VPLL1, pdata->vpll1); 724 child = add_regulator(TWL4030_REG_VPLL1, pdata->vpll1);
621 if (IS_ERR(child)) 725 if (IS_ERR(child))
622 return PTR_ERR(child); 726 return PTR_ERR(child);
623 */ 727
728 child = add_regulator(TWL4030_REG_VIO, pdata->vio);
729 if (IS_ERR(child))
730 return PTR_ERR(child);
731
732 child = add_regulator(TWL4030_REG_VDD1, pdata->vdd1);
733 if (IS_ERR(child))
734 return PTR_ERR(child);
735
736 child = add_regulator(TWL4030_REG_VDD2, pdata->vdd2);
737 if (IS_ERR(child))
738 return PTR_ERR(child);
624 739
625 child = add_regulator(TWL4030_REG_VMMC1, pdata->vmmc1); 740 child = add_regulator(TWL4030_REG_VMMC1, pdata->vmmc1);
626 if (IS_ERR(child)) 741 if (IS_ERR(child))
@@ -636,10 +751,23 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
636 pdata->vaux2); 751 pdata->vaux2);
637 if (IS_ERR(child)) 752 if (IS_ERR(child))
638 return PTR_ERR(child); 753 return PTR_ERR(child);
754
755 child = add_regulator(TWL4030_REG_VINTANA1, pdata->vintana1);
756 if (IS_ERR(child))
757 return PTR_ERR(child);
758
759 child = add_regulator(TWL4030_REG_VINTANA2, pdata->vintana2);
760 if (IS_ERR(child))
761 return PTR_ERR(child);
762
763 child = add_regulator(TWL4030_REG_VINTDIG, pdata->vintdig);
764 if (IS_ERR(child))
765 return PTR_ERR(child);
639 } 766 }
640 767
641 /* maybe add LDOs that are omitted on cost-reduced parts */ 768 /* maybe add LDOs that are omitted on cost-reduced parts */
642 if (twl_has_regulator() && !(features & TPS_SUBSET)) { 769 if (twl_has_regulator() && !(features & TPS_SUBSET)
770 && twl_class_is_4030()) {
643 child = add_regulator(TWL4030_REG_VPLL2, pdata->vpll2); 771 child = add_regulator(TWL4030_REG_VPLL2, pdata->vpll2);
644 if (IS_ERR(child)) 772 if (IS_ERR(child))
645 return PTR_ERR(child); 773 return PTR_ERR(child);
@@ -665,6 +793,49 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
665 return PTR_ERR(child); 793 return PTR_ERR(child);
666 } 794 }
667 795
796 /* twl6030 regulators */
797 if (twl_has_regulator() && twl_class_is_6030()) {
798 child = add_regulator(TWL6030_REG_VMMC, pdata->vmmc);
799 if (IS_ERR(child))
800 return PTR_ERR(child);
801
802 child = add_regulator(TWL6030_REG_VPP, pdata->vpp);
803 if (IS_ERR(child))
804 return PTR_ERR(child);
805
806 child = add_regulator(TWL6030_REG_VUSIM, pdata->vusim);
807 if (IS_ERR(child))
808 return PTR_ERR(child);
809
810 child = add_regulator(TWL6030_REG_VANA, pdata->vana);
811 if (IS_ERR(child))
812 return PTR_ERR(child);
813
814 child = add_regulator(TWL6030_REG_VCXIO, pdata->vcxio);
815 if (IS_ERR(child))
816 return PTR_ERR(child);
817
818 child = add_regulator(TWL6030_REG_VDAC, pdata->vdac);
819 if (IS_ERR(child))
820 return PTR_ERR(child);
821
822 child = add_regulator(TWL6030_REG_VUSB, pdata->vusb);
823 if (IS_ERR(child))
824 return PTR_ERR(child);
825
826 child = add_regulator(TWL6030_REG_VAUX1_6030, pdata->vaux1);
827 if (IS_ERR(child))
828 return PTR_ERR(child);
829
830 child = add_regulator(TWL6030_REG_VAUX2_6030, pdata->vaux2);
831 if (IS_ERR(child))
832 return PTR_ERR(child);
833
834 child = add_regulator(TWL6030_REG_VAUX3_6030, pdata->vaux3);
835 if (IS_ERR(child))
836 return PTR_ERR(child);
837 }
838
668 return 0; 839 return 0;
669} 840}
670 841
@@ -679,7 +850,7 @@ static inline int __init protect_pm_master(void)
679{ 850{
680 int e = 0; 851 int e = 0;
681 852
682 e = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_LOCK, 853 e = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, KEY_LOCK,
683 R_PROTECT_KEY); 854 R_PROTECT_KEY);
684 return e; 855 return e;
685} 856}
@@ -688,14 +859,15 @@ static inline int __init unprotect_pm_master(void)
688{ 859{
689 int e = 0; 860 int e = 0;
690 861
691 e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_UNLOCK1, 862 e |= twl_i2c_write_u8(TWL_MODULE_PM_MASTER, KEY_UNLOCK1,
692 R_PROTECT_KEY); 863 R_PROTECT_KEY);
693 e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_UNLOCK2, 864 e |= twl_i2c_write_u8(TWL_MODULE_PM_MASTER, KEY_UNLOCK2,
694 R_PROTECT_KEY); 865 R_PROTECT_KEY);
695 return e; 866 return e;
696} 867}
697 868
698static void clocks_init(struct device *dev) 869static void clocks_init(struct device *dev,
870 struct twl4030_clock_init_data *clock)
699{ 871{
700 int e = 0; 872 int e = 0;
701 struct clk *osc; 873 struct clk *osc;
@@ -709,7 +881,7 @@ static void clocks_init(struct device *dev)
709 osc = clk_get(dev, "osc_sys_ck"); 881 osc = clk_get(dev, "osc_sys_ck");
710 882
711 if (IS_ERR(osc)) { 883 if (IS_ERR(osc)) {
712 printk(KERN_WARNING "Skipping twl4030 internal clock init and " 884 printk(KERN_WARNING "Skipping twl internal clock init and "
713 "using bootloader value (unknown osc rate)\n"); 885 "using bootloader value (unknown osc rate)\n");
714 return; 886 return;
715 } 887 }
@@ -723,7 +895,7 @@ static void clocks_init(struct device *dev)
723 */ 895 */
724 osc = ERR_PTR(-EIO); 896 osc = ERR_PTR(-EIO);
725 897
726 printk(KERN_WARNING "Skipping twl4030 internal clock init and " 898 printk(KERN_WARNING "Skipping twl internal clock init and "
727 "using bootloader value (unknown osc rate)\n"); 899 "using bootloader value (unknown osc rate)\n");
728 900
729 return; 901 return;
@@ -742,9 +914,12 @@ static void clocks_init(struct device *dev)
742 } 914 }
743 915
744 ctrl |= HIGH_PERF_SQ; 916 ctrl |= HIGH_PERF_SQ;
917 if (clock && clock->ck32k_lowpwr_enable)
918 ctrl |= CK32K_LOWPWR_EN;
919
745 e |= unprotect_pm_master(); 920 e |= unprotect_pm_master();
746 /* effect->MADC+USB ck en */ 921 /* effect->MADC+USB ck en */
747 e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, ctrl, R_CFG_BOOT); 922 e |= twl_i2c_write_u8(TWL_MODULE_PM_MASTER, ctrl, R_CFG_BOOT);
748 e |= protect_pm_master(); 923 e |= protect_pm_master();
749 924
750 if (e < 0) 925 if (e < 0)
@@ -753,24 +928,31 @@ static void clocks_init(struct device *dev)
753 928
754/*----------------------------------------------------------------------*/ 929/*----------------------------------------------------------------------*/
755 930
756int twl_init_irq(int irq_num, unsigned irq_base, unsigned irq_end); 931int twl4030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end);
757int twl_exit_irq(void); 932int twl4030_exit_irq(void);
933int twl4030_init_chip_irq(const char *chip);
934int twl6030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end);
935int twl6030_exit_irq(void);
758 936
759static int twl4030_remove(struct i2c_client *client) 937static int twl_remove(struct i2c_client *client)
760{ 938{
761 unsigned i; 939 unsigned i;
762 int status; 940 int status;
763 941
764 status = twl_exit_irq(); 942 if (twl_class_is_4030())
943 status = twl4030_exit_irq();
944 else
945 status = twl6030_exit_irq();
946
765 if (status < 0) 947 if (status < 0)
766 return status; 948 return status;
767 949
768 for (i = 0; i < TWL4030_NUM_SLAVES; i++) { 950 for (i = 0; i < TWL_NUM_SLAVES; i++) {
769 struct twl4030_client *twl = &twl4030_modules[i]; 951 struct twl_client *twl = &twl_modules[i];
770 952
771 if (twl->client && twl->client != client) 953 if (twl->client && twl->client != client)
772 i2c_unregister_device(twl->client); 954 i2c_unregister_device(twl->client);
773 twl4030_modules[i].client = NULL; 955 twl_modules[i].client = NULL;
774 } 956 }
775 inuse = false; 957 inuse = false;
776 return 0; 958 return 0;
@@ -778,7 +960,7 @@ static int twl4030_remove(struct i2c_client *client)
778 960
779/* NOTE: this driver only handles a single twl4030/tps659x0 chip */ 961/* NOTE: this driver only handles a single twl4030/tps659x0 chip */
780static int __init 962static int __init
781twl4030_probe(struct i2c_client *client, const struct i2c_device_id *id) 963twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
782{ 964{
783 int status; 965 int status;
784 unsigned i; 966 unsigned i;
@@ -799,8 +981,8 @@ twl4030_probe(struct i2c_client *client, const struct i2c_device_id *id)
799 return -EBUSY; 981 return -EBUSY;
800 } 982 }
801 983
802 for (i = 0; i < TWL4030_NUM_SLAVES; i++) { 984 for (i = 0; i < TWL_NUM_SLAVES; i++) {
803 struct twl4030_client *twl = &twl4030_modules[i]; 985 struct twl_client *twl = &twl_modules[i];
804 986
805 twl->address = client->addr + i; 987 twl->address = client->addr + i;
806 if (i == 0) 988 if (i == 0)
@@ -814,15 +996,20 @@ twl4030_probe(struct i2c_client *client, const struct i2c_device_id *id)
814 status = -ENOMEM; 996 status = -ENOMEM;
815 goto fail; 997 goto fail;
816 } 998 }
817 strlcpy(twl->client->name, id->name,
818 sizeof(twl->client->name));
819 } 999 }
820 mutex_init(&twl->xfer_lock); 1000 mutex_init(&twl->xfer_lock);
821 } 1001 }
822 inuse = true; 1002 inuse = true;
1003 if ((id->driver_data) & TWL6030_CLASS) {
1004 twl_id = TWL6030_CLASS_ID;
1005 twl_map = &twl6030_map[0];
1006 } else {
1007 twl_id = TWL4030_CLASS_ID;
1008 twl_map = &twl4030_map[0];
1009 }
823 1010
824 /* setup clock framework */ 1011 /* setup clock framework */
825 clocks_init(&client->dev); 1012 clocks_init(&client->dev, pdata->clock);
826 1013
827 /* load power event scripts */ 1014 /* load power event scripts */
828 if (twl_has_power() && pdata->power) 1015 if (twl_has_power() && pdata->power)
@@ -832,7 +1019,15 @@ twl4030_probe(struct i2c_client *client, const struct i2c_device_id *id)
832 if (client->irq 1019 if (client->irq
833 && pdata->irq_base 1020 && pdata->irq_base
834 && pdata->irq_end > pdata->irq_base) { 1021 && pdata->irq_end > pdata->irq_base) {
835 status = twl_init_irq(client->irq, pdata->irq_base, pdata->irq_end); 1022 if (twl_class_is_4030()) {
1023 twl4030_init_chip_irq(id->name);
1024 status = twl4030_init_irq(client->irq, pdata->irq_base,
1025 pdata->irq_end);
1026 } else {
1027 status = twl6030_init_irq(client->irq, pdata->irq_base,
1028 pdata->irq_end);
1029 }
1030
836 if (status < 0) 1031 if (status < 0)
837 goto fail; 1032 goto fail;
838 } 1033 }
@@ -840,40 +1035,42 @@ twl4030_probe(struct i2c_client *client, const struct i2c_device_id *id)
840 status = add_children(pdata, id->driver_data); 1035 status = add_children(pdata, id->driver_data);
841fail: 1036fail:
842 if (status < 0) 1037 if (status < 0)
843 twl4030_remove(client); 1038 twl_remove(client);
844 return status; 1039 return status;
845} 1040}
846 1041
847static const struct i2c_device_id twl4030_ids[] = { 1042static const struct i2c_device_id twl_ids[] = {
848 { "twl4030", TWL4030_VAUX2 }, /* "Triton 2" */ 1043 { "twl4030", TWL4030_VAUX2 }, /* "Triton 2" */
849 { "twl5030", 0 }, /* T2 updated */ 1044 { "twl5030", 0 }, /* T2 updated */
1045 { "twl5031", TWL5031 }, /* TWL5030 updated */
850 { "tps65950", 0 }, /* catalog version of twl5030 */ 1046 { "tps65950", 0 }, /* catalog version of twl5030 */
851 { "tps65930", TPS_SUBSET }, /* fewer LDOs and DACs; no charger */ 1047 { "tps65930", TPS_SUBSET }, /* fewer LDOs and DACs; no charger */
852 { "tps65920", TPS_SUBSET }, /* fewer LDOs; no codec or charger */ 1048 { "tps65920", TPS_SUBSET }, /* fewer LDOs; no codec or charger */
1049 { "twl6030", TWL6030_CLASS }, /* "Phoenix power chip" */
853 { /* end of list */ }, 1050 { /* end of list */ },
854}; 1051};
855MODULE_DEVICE_TABLE(i2c, twl4030_ids); 1052MODULE_DEVICE_TABLE(i2c, twl_ids);
856 1053
857/* One Client Driver , 4 Clients */ 1054/* One Client Driver , 4 Clients */
858static struct i2c_driver twl4030_driver = { 1055static struct i2c_driver twl_driver = {
859 .driver.name = DRIVER_NAME, 1056 .driver.name = DRIVER_NAME,
860 .id_table = twl4030_ids, 1057 .id_table = twl_ids,
861 .probe = twl4030_probe, 1058 .probe = twl_probe,
862 .remove = twl4030_remove, 1059 .remove = twl_remove,
863}; 1060};
864 1061
865static int __init twl4030_init(void) 1062static int __init twl_init(void)
866{ 1063{
867 return i2c_add_driver(&twl4030_driver); 1064 return i2c_add_driver(&twl_driver);
868} 1065}
869subsys_initcall(twl4030_init); 1066subsys_initcall(twl_init);
870 1067
871static void __exit twl4030_exit(void) 1068static void __exit twl_exit(void)
872{ 1069{
873 i2c_del_driver(&twl4030_driver); 1070 i2c_del_driver(&twl_driver);
874} 1071}
875module_exit(twl4030_exit); 1072module_exit(twl_exit);
876 1073
877MODULE_AUTHOR("Texas Instruments, Inc."); 1074MODULE_AUTHOR("Texas Instruments, Inc.");
878MODULE_DESCRIPTION("I2C Core interface for TWL4030"); 1075MODULE_DESCRIPTION("I2C Core interface for TWL");
879MODULE_LICENSE("GPL"); 1076MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
index fb194fe244c1..20d29bafc9f5 100644
--- a/drivers/mfd/twl4030-irq.c
+++ b/drivers/mfd/twl4030-irq.c
@@ -32,7 +32,7 @@
32#include <linux/irq.h> 32#include <linux/irq.h>
33#include <linux/kthread.h> 33#include <linux/kthread.h>
34 34
35#include <linux/i2c/twl4030.h> 35#include <linux/i2c/twl.h>
36 36
37 37
38/* 38/*
@@ -74,6 +74,8 @@ struct sih {
74 u8 edr_offset; 74 u8 edr_offset;
75 u8 bytes_edr; /* bytelen of EDR */ 75 u8 bytes_edr; /* bytelen of EDR */
76 76
77 u8 irq_lines; /* number of supported irq lines */
78
77 /* SIR ignored -- set interrupt, for testing only */ 79 /* SIR ignored -- set interrupt, for testing only */
78 struct irq_data { 80 struct irq_data {
79 u8 isr_offset; 81 u8 isr_offset;
@@ -82,6 +84,9 @@ struct sih {
82 /* + 2 bytes padding */ 84 /* + 2 bytes padding */
83}; 85};
84 86
87static const struct sih *sih_modules;
88static int nr_sih_modules;
89
85#define SIH_INITIALIZER(modname, nbits) \ 90#define SIH_INITIALIZER(modname, nbits) \
86 .module = TWL4030_MODULE_ ## modname, \ 91 .module = TWL4030_MODULE_ ## modname, \
87 .control_offset = TWL4030_ ## modname ## _SIH_CTRL, \ 92 .control_offset = TWL4030_ ## modname ## _SIH_CTRL, \
@@ -89,6 +94,7 @@ struct sih {
89 .bytes_ixr = DIV_ROUND_UP(nbits, 8), \ 94 .bytes_ixr = DIV_ROUND_UP(nbits, 8), \
90 .edr_offset = TWL4030_ ## modname ## _EDR, \ 95 .edr_offset = TWL4030_ ## modname ## _EDR, \
91 .bytes_edr = DIV_ROUND_UP((2*(nbits)), 8), \ 96 .bytes_edr = DIV_ROUND_UP((2*(nbits)), 8), \
97 .irq_lines = 2, \
92 .mask = { { \ 98 .mask = { { \
93 .isr_offset = TWL4030_ ## modname ## _ISR1, \ 99 .isr_offset = TWL4030_ ## modname ## _ISR1, \
94 .imr_offset = TWL4030_ ## modname ## _IMR1, \ 100 .imr_offset = TWL4030_ ## modname ## _IMR1, \
@@ -107,7 +113,8 @@ struct sih {
107/* Order in this table matches order in PIH_ISR. That is, 113/* Order in this table matches order in PIH_ISR. That is,
108 * BIT(n) in PIH_ISR is sih_modules[n]. 114 * BIT(n) in PIH_ISR is sih_modules[n].
109 */ 115 */
110static const struct sih sih_modules[6] = { 116/* sih_modules_twl4030 is used both in twl4030 and twl5030 */
117static const struct sih sih_modules_twl4030[6] = {
111 [0] = { 118 [0] = {
112 .name = "gpio", 119 .name = "gpio",
113 .module = TWL4030_MODULE_GPIO, 120 .module = TWL4030_MODULE_GPIO,
@@ -118,6 +125,7 @@ static const struct sih sih_modules[6] = {
118 /* Note: *all* of these IRQs default to no-trigger */ 125 /* Note: *all* of these IRQs default to no-trigger */
119 .edr_offset = REG_GPIO_EDR1, 126 .edr_offset = REG_GPIO_EDR1,
120 .bytes_edr = 5, 127 .bytes_edr = 5,
128 .irq_lines = 2,
121 .mask = { { 129 .mask = { {
122 .isr_offset = REG_GPIO_ISR1A, 130 .isr_offset = REG_GPIO_ISR1A,
123 .imr_offset = REG_GPIO_IMR1A, 131 .imr_offset = REG_GPIO_IMR1A,
@@ -140,6 +148,7 @@ static const struct sih sih_modules[6] = {
140 .edr_offset = TWL4030_INTERRUPTS_BCIEDR1, 148 .edr_offset = TWL4030_INTERRUPTS_BCIEDR1,
141 /* Note: most of these IRQs default to no-trigger */ 149 /* Note: most of these IRQs default to no-trigger */
142 .bytes_edr = 3, 150 .bytes_edr = 3,
151 .irq_lines = 2,
143 .mask = { { 152 .mask = { {
144 .isr_offset = TWL4030_INTERRUPTS_BCIISR1A, 153 .isr_offset = TWL4030_INTERRUPTS_BCIISR1A,
145 .imr_offset = TWL4030_INTERRUPTS_BCIIMR1A, 154 .imr_offset = TWL4030_INTERRUPTS_BCIIMR1A,
@@ -164,6 +173,99 @@ static const struct sih sih_modules[6] = {
164 /* there are no SIH modules #6 or #7 ... */ 173 /* there are no SIH modules #6 or #7 ... */
165}; 174};
166 175
176static const struct sih sih_modules_twl5031[8] = {
177 [0] = {
178 .name = "gpio",
179 .module = TWL4030_MODULE_GPIO,
180 .control_offset = REG_GPIO_SIH_CTRL,
181 .set_cor = true,
182 .bits = TWL4030_GPIO_MAX,
183 .bytes_ixr = 3,
184 /* Note: *all* of these IRQs default to no-trigger */
185 .edr_offset = REG_GPIO_EDR1,
186 .bytes_edr = 5,
187 .irq_lines = 2,
188 .mask = { {
189 .isr_offset = REG_GPIO_ISR1A,
190 .imr_offset = REG_GPIO_IMR1A,
191 }, {
192 .isr_offset = REG_GPIO_ISR1B,
193 .imr_offset = REG_GPIO_IMR1B,
194 }, },
195 },
196 [1] = {
197 .name = "keypad",
198 .set_cor = true,
199 SIH_INITIALIZER(KEYPAD_KEYP, 4)
200 },
201 [2] = {
202 .name = "bci",
203 .module = TWL5031_MODULE_INTERRUPTS,
204 .control_offset = TWL5031_INTERRUPTS_BCISIHCTRL,
205 .bits = 7,
206 .bytes_ixr = 1,
207 .edr_offset = TWL5031_INTERRUPTS_BCIEDR1,
208 /* Note: most of these IRQs default to no-trigger */
209 .bytes_edr = 2,
210 .irq_lines = 2,
211 .mask = { {
212 .isr_offset = TWL5031_INTERRUPTS_BCIISR1,
213 .imr_offset = TWL5031_INTERRUPTS_BCIIMR1,
214 }, {
215 .isr_offset = TWL5031_INTERRUPTS_BCIISR2,
216 .imr_offset = TWL5031_INTERRUPTS_BCIIMR2,
217 }, },
218 },
219 [3] = {
220 .name = "madc",
221 SIH_INITIALIZER(MADC, 4)
222 },
223 [4] = {
224 /* USB doesn't use the same SIH organization */
225 .name = "usb",
226 },
227 [5] = {
228 .name = "power",
229 .set_cor = true,
230 SIH_INITIALIZER(INT_PWR, 8)
231 },
232 [6] = {
233 /*
234 * ACI doesn't use the same SIH organization.
235 * For example, it supports only one interrupt line
236 */
237 .name = "aci",
238 .module = TWL5031_MODULE_ACCESSORY,
239 .bits = 9,
240 .bytes_ixr = 2,
241 .irq_lines = 1,
242 .mask = { {
243 .isr_offset = TWL5031_ACIIDR_LSB,
244 .imr_offset = TWL5031_ACIIMR_LSB,
245 }, },
246
247 },
248 [7] = {
249 /* Accessory */
250 .name = "acc",
251 .module = TWL5031_MODULE_ACCESSORY,
252 .control_offset = TWL5031_ACCSIHCTRL,
253 .bits = 2,
254 .bytes_ixr = 1,
255 .edr_offset = TWL5031_ACCEDR1,
256 /* Note: most of these IRQs default to no-trigger */
257 .bytes_edr = 1,
258 .irq_lines = 2,
259 .mask = { {
260 .isr_offset = TWL5031_ACCISR1,
261 .imr_offset = TWL5031_ACCIMR1,
262 }, {
263 .isr_offset = TWL5031_ACCISR2,
264 .imr_offset = TWL5031_ACCIMR2,
265 }, },
266 },
267};
268
167#undef TWL4030_MODULE_KEYPAD_KEYP 269#undef TWL4030_MODULE_KEYPAD_KEYP
168#undef TWL4030_MODULE_INT_PWR 270#undef TWL4030_MODULE_INT_PWR
169#undef TWL4030_INT_PWR_EDR 271#undef TWL4030_INT_PWR_EDR
@@ -194,7 +296,7 @@ static int twl4030_irq_thread(void *data)
194 /* Wait for IRQ, then read PIH irq status (also blocking) */ 296 /* Wait for IRQ, then read PIH irq status (also blocking) */
195 wait_for_completion_interruptible(&irq_event); 297 wait_for_completion_interruptible(&irq_event);
196 298
197 ret = twl4030_i2c_read_u8(TWL4030_MODULE_PIH, &pih_isr, 299 ret = twl_i2c_read_u8(TWL4030_MODULE_PIH, &pih_isr,
198 REG_PIH_ISR_P1); 300 REG_PIH_ISR_P1);
199 if (ret) { 301 if (ret) {
200 pr_warning("twl4030: I2C error %d reading PIH ISR\n", 302 pr_warning("twl4030: I2C error %d reading PIH ISR\n",
@@ -284,13 +386,17 @@ static int twl4030_init_sih_modules(unsigned line)
284 /* disable all interrupts on our line */ 386 /* disable all interrupts on our line */
285 memset(buf, 0xff, sizeof buf); 387 memset(buf, 0xff, sizeof buf);
286 sih = sih_modules; 388 sih = sih_modules;
287 for (i = 0; i < ARRAY_SIZE(sih_modules); i++, sih++) { 389 for (i = 0; i < nr_sih_modules; i++, sih++) {
288 390
289 /* skip USB -- it's funky */ 391 /* skip USB -- it's funky */
290 if (!sih->bytes_ixr) 392 if (!sih->bytes_ixr)
291 continue; 393 continue;
292 394
293 status = twl4030_i2c_write(sih->module, buf, 395 /* Not all the SIH modules support multiple interrupt lines */
396 if (sih->irq_lines <= line)
397 continue;
398
399 status = twl_i2c_write(sih->module, buf,
294 sih->mask[line].imr_offset, sih->bytes_ixr); 400 sih->mask[line].imr_offset, sih->bytes_ixr);
295 if (status < 0) 401 if (status < 0)
296 pr_err("twl4030: err %d initializing %s %s\n", 402 pr_err("twl4030: err %d initializing %s %s\n",
@@ -304,7 +410,7 @@ static int twl4030_init_sih_modules(unsigned line)
304 * And for PWR_INT it's not documented... 410 * And for PWR_INT it's not documented...
305 */ 411 */
306 if (sih->set_cor) { 412 if (sih->set_cor) {
307 status = twl4030_i2c_write_u8(sih->module, 413 status = twl_i2c_write_u8(sih->module,
308 TWL4030_SIH_CTRL_COR_MASK, 414 TWL4030_SIH_CTRL_COR_MASK,
309 sih->control_offset); 415 sih->control_offset);
310 if (status < 0) 416 if (status < 0)
@@ -314,7 +420,7 @@ static int twl4030_init_sih_modules(unsigned line)
314 } 420 }
315 421
316 sih = sih_modules; 422 sih = sih_modules;
317 for (i = 0; i < ARRAY_SIZE(sih_modules); i++, sih++) { 423 for (i = 0; i < nr_sih_modules; i++, sih++) {
318 u8 rxbuf[4]; 424 u8 rxbuf[4];
319 int j; 425 int j;
320 426
@@ -322,20 +428,24 @@ static int twl4030_init_sih_modules(unsigned line)
322 if (!sih->bytes_ixr) 428 if (!sih->bytes_ixr)
323 continue; 429 continue;
324 430
431 /* Not all the SIH modules support multiple interrupt lines */
432 if (sih->irq_lines <= line)
433 continue;
434
325 /* Clear pending interrupt status. Either the read was 435 /* Clear pending interrupt status. Either the read was
326 * enough, or we need to write those bits. Repeat, in 436 * enough, or we need to write those bits. Repeat, in
327 * case an IRQ is pending (PENDDIS=0) ... that's not 437 * case an IRQ is pending (PENDDIS=0) ... that's not
328 * uncommon with PWR_INT.PWRON. 438 * uncommon with PWR_INT.PWRON.
329 */ 439 */
330 for (j = 0; j < 2; j++) { 440 for (j = 0; j < 2; j++) {
331 status = twl4030_i2c_read(sih->module, rxbuf, 441 status = twl_i2c_read(sih->module, rxbuf,
332 sih->mask[line].isr_offset, sih->bytes_ixr); 442 sih->mask[line].isr_offset, sih->bytes_ixr);
333 if (status < 0) 443 if (status < 0)
334 pr_err("twl4030: err %d initializing %s %s\n", 444 pr_err("twl4030: err %d initializing %s %s\n",
335 status, sih->name, "ISR"); 445 status, sih->name, "ISR");
336 446
337 if (!sih->set_cor) 447 if (!sih->set_cor)
338 status = twl4030_i2c_write(sih->module, buf, 448 status = twl_i2c_write(sih->module, buf,
339 sih->mask[line].isr_offset, 449 sih->mask[line].isr_offset,
340 sih->bytes_ixr); 450 sih->bytes_ixr);
341 /* else COR=1 means read sufficed. 451 /* else COR=1 means read sufficed.
@@ -404,7 +514,7 @@ static void twl4030_sih_do_mask(struct work_struct *work)
404 return; 514 return;
405 515
406 /* write the whole mask ... simpler than subsetting it */ 516 /* write the whole mask ... simpler than subsetting it */
407 status = twl4030_i2c_write(sih->module, imr.bytes, 517 status = twl_i2c_write(sih->module, imr.bytes,
408 sih->mask[irq_line].imr_offset, sih->bytes_ixr); 518 sih->mask[irq_line].imr_offset, sih->bytes_ixr);
409 if (status) 519 if (status)
410 pr_err("twl4030: %s, %s --> %d\n", __func__, 520 pr_err("twl4030: %s, %s --> %d\n", __func__,
@@ -435,7 +545,7 @@ static void twl4030_sih_do_edge(struct work_struct *work)
435 * any processor on the other IRQ line, EDR registers are 545 * any processor on the other IRQ line, EDR registers are
436 * shared. 546 * shared.
437 */ 547 */
438 status = twl4030_i2c_read(sih->module, bytes + 1, 548 status = twl_i2c_read(sih->module, bytes + 1,
439 sih->edr_offset, sih->bytes_edr); 549 sih->edr_offset, sih->bytes_edr);
440 if (status) { 550 if (status) {
441 pr_err("twl4030: %s, %s --> %d\n", __func__, 551 pr_err("twl4030: %s, %s --> %d\n", __func__,
@@ -469,7 +579,7 @@ static void twl4030_sih_do_edge(struct work_struct *work)
469 } 579 }
470 580
471 /* Write */ 581 /* Write */
472 status = twl4030_i2c_write(sih->module, bytes, 582 status = twl_i2c_write(sih->module, bytes,
473 sih->edr_offset, sih->bytes_edr); 583 sih->edr_offset, sih->bytes_edr);
474 if (status) 584 if (status)
475 pr_err("twl4030: %s, %s --> %d\n", __func__, 585 pr_err("twl4030: %s, %s --> %d\n", __func__,
@@ -554,7 +664,7 @@ static inline int sih_read_isr(const struct sih *sih)
554 /* FIXME need retry-on-error ... */ 664 /* FIXME need retry-on-error ... */
555 665
556 isr.word = 0; 666 isr.word = 0;
557 status = twl4030_i2c_read(sih->module, isr.bytes, 667 status = twl_i2c_read(sih->module, isr.bytes,
558 sih->mask[irq_line].isr_offset, sih->bytes_ixr); 668 sih->mask[irq_line].isr_offset, sih->bytes_ixr);
559 669
560 return (status < 0) ? status : le32_to_cpu(isr.word); 670 return (status < 0) ? status : le32_to_cpu(isr.word);
@@ -611,7 +721,7 @@ int twl4030_sih_setup(int module)
611 721
612 /* only support modules with standard clear-on-read for now */ 722 /* only support modules with standard clear-on-read for now */
613 for (sih_mod = 0, sih = sih_modules; 723 for (sih_mod = 0, sih = sih_modules;
614 sih_mod < ARRAY_SIZE(sih_modules); 724 sih_mod < nr_sih_modules;
615 sih_mod++, sih++) { 725 sih_mod++, sih++) {
616 if (sih->module == module && sih->set_cor) { 726 if (sih->module == module && sih->set_cor) {
617 if (!WARN((irq_base + sih->bits) > NR_IRQS, 727 if (!WARN((irq_base + sih->bits) > NR_IRQS,
@@ -668,7 +778,7 @@ int twl4030_sih_setup(int module)
668/* FIXME pass in which interrupt line we'll use ... */ 778/* FIXME pass in which interrupt line we'll use ... */
669#define twl_irq_line 0 779#define twl_irq_line 0
670 780
671int twl_init_irq(int irq_num, unsigned irq_base, unsigned irq_end) 781int twl4030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end)
672{ 782{
673 static struct irq_chip twl4030_irq_chip; 783 static struct irq_chip twl4030_irq_chip;
674 784
@@ -728,7 +838,8 @@ int twl_init_irq(int irq_num, unsigned irq_base, unsigned irq_end)
728 goto fail_rqirq; 838 goto fail_rqirq;
729 } 839 }
730 840
731 task = kthread_run(twl4030_irq_thread, (void *)irq_num, "twl4030-irq"); 841 task = kthread_run(twl4030_irq_thread, (void *)(long)irq_num,
842 "twl4030-irq");
732 if (IS_ERR(task)) { 843 if (IS_ERR(task)) {
733 pr_err("twl4030: could not create irq %d thread!\n", irq_num); 844 pr_err("twl4030: could not create irq %d thread!\n", irq_num);
734 status = PTR_ERR(task); 845 status = PTR_ERR(task);
@@ -747,7 +858,7 @@ fail:
747 return status; 858 return status;
748} 859}
749 860
750int twl_exit_irq(void) 861int twl4030_exit_irq(void)
751{ 862{
752 /* FIXME undo twl_init_irq() */ 863 /* FIXME undo twl_init_irq() */
753 if (twl4030_irq_base) { 864 if (twl4030_irq_base) {
@@ -756,3 +867,16 @@ int twl_exit_irq(void)
756 } 867 }
757 return 0; 868 return 0;
758} 869}
870
871int twl4030_init_chip_irq(const char *chip)
872{
873 if (!strcmp(chip, "twl5031")) {
874 sih_modules = sih_modules_twl5031;
875 nr_sih_modules = ARRAY_SIZE(sih_modules_twl5031);
876 } else {
877 sih_modules = sih_modules_twl4030;
878 nr_sih_modules = ARRAY_SIZE(sih_modules_twl4030);
879 }
880
881 return 0;
882}
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index d423e0c4176b..0815292fdafc 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -26,7 +26,7 @@
26 26
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/pm.h> 28#include <linux/pm.h>
29#include <linux/i2c/twl4030.h> 29#include <linux/i2c/twl.h>
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31 31
32#include <asm/mach-types.h> 32#include <asm/mach-types.h>
@@ -67,19 +67,35 @@ static u8 twl4030_start_script_address = 0x2b;
67#define R_KEY_1 0xC0 67#define R_KEY_1 0xC0
68#define R_KEY_2 0x0C 68#define R_KEY_2 0x0C
69 69
70/* resource configuration registers */ 70/* resource configuration registers
71 71 <RESOURCE>_DEV_GRP at address 'n+0'
72#define DEVGROUP_OFFSET 0 72 <RESOURCE>_TYPE at address 'n+1'
73 <RESOURCE>_REMAP at address 'n+2'
74 <RESOURCE>_DEDICATED at address 'n+3'
75*/
76#define DEV_GRP_OFFSET 0
73#define TYPE_OFFSET 1 77#define TYPE_OFFSET 1
78#define REMAP_OFFSET 2
79#define DEDICATED_OFFSET 3
80
81/* Bit positions in the registers */
82
83/* <RESOURCE>_DEV_GRP */
84#define DEV_GRP_SHIFT 5
85#define DEV_GRP_MASK (7 << DEV_GRP_SHIFT)
74 86
75/* Bit positions */ 87/* <RESOURCE>_TYPE */
76#define DEVGROUP_SHIFT 5
77#define DEVGROUP_MASK (7 << DEVGROUP_SHIFT)
78#define TYPE_SHIFT 0 88#define TYPE_SHIFT 0
79#define TYPE_MASK (7 << TYPE_SHIFT) 89#define TYPE_MASK (7 << TYPE_SHIFT)
80#define TYPE2_SHIFT 3 90#define TYPE2_SHIFT 3
81#define TYPE2_MASK (3 << TYPE2_SHIFT) 91#define TYPE2_MASK (3 << TYPE2_SHIFT)
82 92
93/* <RESOURCE>_REMAP */
94#define SLEEP_STATE_SHIFT 0
95#define SLEEP_STATE_MASK (0xf << SLEEP_STATE_SHIFT)
96#define OFF_STATE_SHIFT 4
97#define OFF_STATE_MASK (0xf << OFF_STATE_SHIFT)
98
83static u8 res_config_addrs[] = { 99static u8 res_config_addrs[] = {
84 [RES_VAUX1] = 0x17, 100 [RES_VAUX1] = 0x17,
85 [RES_VAUX2] = 0x1b, 101 [RES_VAUX2] = 0x1b,
@@ -115,11 +131,11 @@ static int __init twl4030_write_script_byte(u8 address, u8 byte)
115{ 131{
116 int err; 132 int err;
117 133
118 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, 134 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
119 R_MEMORY_ADDRESS); 135 R_MEMORY_ADDRESS);
120 if (err) 136 if (err)
121 goto out; 137 goto out;
122 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, byte, 138 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, byte,
123 R_MEMORY_DATA); 139 R_MEMORY_DATA);
124out: 140out:
125 return err; 141 return err;
@@ -176,18 +192,18 @@ static int __init twl4030_config_wakeup3_sequence(u8 address)
176 u8 data; 192 u8 data;
177 193
178 /* Set SLEEP to ACTIVE SEQ address for P3 */ 194 /* Set SLEEP to ACTIVE SEQ address for P3 */
179 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, 195 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
180 R_SEQ_ADD_S2A3); 196 R_SEQ_ADD_S2A3);
181 if (err) 197 if (err)
182 goto out; 198 goto out;
183 199
184 /* P3 LVL_WAKEUP should be on LEVEL */ 200 /* P3 LVL_WAKEUP should be on LEVEL */
185 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data, 201 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data,
186 R_P3_SW_EVENTS); 202 R_P3_SW_EVENTS);
187 if (err) 203 if (err)
188 goto out; 204 goto out;
189 data |= LVL_WAKEUP; 205 data |= LVL_WAKEUP;
190 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data, 206 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data,
191 R_P3_SW_EVENTS); 207 R_P3_SW_EVENTS);
192out: 208out:
193 if (err) 209 if (err)
@@ -201,42 +217,42 @@ static int __init twl4030_config_wakeup12_sequence(u8 address)
201 u8 data; 217 u8 data;
202 218
203 /* Set SLEEP to ACTIVE SEQ address for P1 and P2 */ 219 /* Set SLEEP to ACTIVE SEQ address for P1 and P2 */
204 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, 220 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
205 R_SEQ_ADD_S2A12); 221 R_SEQ_ADD_S2A12);
206 if (err) 222 if (err)
207 goto out; 223 goto out;
208 224
209 /* P1/P2 LVL_WAKEUP should be on LEVEL */ 225 /* P1/P2 LVL_WAKEUP should be on LEVEL */
210 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data, 226 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data,
211 R_P1_SW_EVENTS); 227 R_P1_SW_EVENTS);
212 if (err) 228 if (err)
213 goto out; 229 goto out;
214 230
215 data |= LVL_WAKEUP; 231 data |= LVL_WAKEUP;
216 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data, 232 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data,
217 R_P1_SW_EVENTS); 233 R_P1_SW_EVENTS);
218 if (err) 234 if (err)
219 goto out; 235 goto out;
220 236
221 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data, 237 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data,
222 R_P2_SW_EVENTS); 238 R_P2_SW_EVENTS);
223 if (err) 239 if (err)
224 goto out; 240 goto out;
225 241
226 data |= LVL_WAKEUP; 242 data |= LVL_WAKEUP;
227 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data, 243 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data,
228 R_P2_SW_EVENTS); 244 R_P2_SW_EVENTS);
229 if (err) 245 if (err)
230 goto out; 246 goto out;
231 247
232 if (machine_is_omap_3430sdp() || machine_is_omap_ldp()) { 248 if (machine_is_omap_3430sdp() || machine_is_omap_ldp()) {
233 /* Disabling AC charger effect on sleep-active transitions */ 249 /* Disabling AC charger effect on sleep-active transitions */
234 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data, 250 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data,
235 R_CFG_P1_TRANSITION); 251 R_CFG_P1_TRANSITION);
236 if (err) 252 if (err)
237 goto out; 253 goto out;
238 data &= ~(1<<1); 254 data &= ~(1<<1);
239 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data , 255 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data ,
240 R_CFG_P1_TRANSITION); 256 R_CFG_P1_TRANSITION);
241 if (err) 257 if (err)
242 goto out; 258 goto out;
@@ -254,7 +270,7 @@ static int __init twl4030_config_sleep_sequence(u8 address)
254 int err; 270 int err;
255 271
256 /* Set ACTIVE to SLEEP SEQ address in T2 memory*/ 272 /* Set ACTIVE to SLEEP SEQ address in T2 memory*/
257 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, 273 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
258 R_SEQ_ADD_A2S); 274 R_SEQ_ADD_A2S);
259 275
260 if (err) 276 if (err)
@@ -269,41 +285,41 @@ static int __init twl4030_config_warmreset_sequence(u8 address)
269 u8 rd_data; 285 u8 rd_data;
270 286
271 /* Set WARM RESET SEQ address for P1 */ 287 /* Set WARM RESET SEQ address for P1 */
272 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, 288 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
273 R_SEQ_ADD_WARM); 289 R_SEQ_ADD_WARM);
274 if (err) 290 if (err)
275 goto out; 291 goto out;
276 292
277 /* P1/P2/P3 enable WARMRESET */ 293 /* P1/P2/P3 enable WARMRESET */
278 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data, 294 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data,
279 R_P1_SW_EVENTS); 295 R_P1_SW_EVENTS);
280 if (err) 296 if (err)
281 goto out; 297 goto out;
282 298
283 rd_data |= ENABLE_WARMRESET; 299 rd_data |= ENABLE_WARMRESET;
284 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data, 300 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data,
285 R_P1_SW_EVENTS); 301 R_P1_SW_EVENTS);
286 if (err) 302 if (err)
287 goto out; 303 goto out;
288 304
289 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data, 305 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data,
290 R_P2_SW_EVENTS); 306 R_P2_SW_EVENTS);
291 if (err) 307 if (err)
292 goto out; 308 goto out;
293 309
294 rd_data |= ENABLE_WARMRESET; 310 rd_data |= ENABLE_WARMRESET;
295 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data, 311 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data,
296 R_P2_SW_EVENTS); 312 R_P2_SW_EVENTS);
297 if (err) 313 if (err)
298 goto out; 314 goto out;
299 315
300 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data, 316 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data,
301 R_P3_SW_EVENTS); 317 R_P3_SW_EVENTS);
302 if (err) 318 if (err)
303 goto out; 319 goto out;
304 320
305 rd_data |= ENABLE_WARMRESET; 321 rd_data |= ENABLE_WARMRESET;
306 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data, 322 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data,
307 R_P3_SW_EVENTS); 323 R_P3_SW_EVENTS);
308out: 324out:
309 if (err) 325 if (err)
@@ -317,6 +333,7 @@ static int __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
317 int err; 333 int err;
318 u8 type; 334 u8 type;
319 u8 grp; 335 u8 grp;
336 u8 remap;
320 337
321 if (rconfig->resource > TOTAL_RESOURCES) { 338 if (rconfig->resource > TOTAL_RESOURCES) {
322 pr_err("TWL4030 Resource %d does not exist\n", 339 pr_err("TWL4030 Resource %d does not exist\n",
@@ -327,19 +344,19 @@ static int __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
327 rconfig_addr = res_config_addrs[rconfig->resource]; 344 rconfig_addr = res_config_addrs[rconfig->resource];
328 345
329 /* Set resource group */ 346 /* Set resource group */
330 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &grp, 347 err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &grp,
331 rconfig_addr + DEVGROUP_OFFSET); 348 rconfig_addr + DEV_GRP_OFFSET);
332 if (err) { 349 if (err) {
333 pr_err("TWL4030 Resource %d group could not be read\n", 350 pr_err("TWL4030 Resource %d group could not be read\n",
334 rconfig->resource); 351 rconfig->resource);
335 return err; 352 return err;
336 } 353 }
337 354
338 if (rconfig->devgroup >= 0) { 355 if (rconfig->devgroup != TWL4030_RESCONFIG_UNDEF) {
339 grp &= ~DEVGROUP_MASK; 356 grp &= ~DEV_GRP_MASK;
340 grp |= rconfig->devgroup << DEVGROUP_SHIFT; 357 grp |= rconfig->devgroup << DEV_GRP_SHIFT;
341 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 358 err = twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
342 grp, rconfig_addr + DEVGROUP_OFFSET); 359 grp, rconfig_addr + DEV_GRP_OFFSET);
343 if (err < 0) { 360 if (err < 0) {
344 pr_err("TWL4030 failed to program devgroup\n"); 361 pr_err("TWL4030 failed to program devgroup\n");
345 return err; 362 return err;
@@ -347,7 +364,7 @@ static int __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
347 } 364 }
348 365
349 /* Set resource types */ 366 /* Set resource types */
350 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &type, 367 err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &type,
351 rconfig_addr + TYPE_OFFSET); 368 rconfig_addr + TYPE_OFFSET);
352 if (err < 0) { 369 if (err < 0) {
353 pr_err("TWL4030 Resource %d type could not be read\n", 370 pr_err("TWL4030 Resource %d type could not be read\n",
@@ -355,23 +372,50 @@ static int __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
355 return err; 372 return err;
356 } 373 }
357 374
358 if (rconfig->type >= 0) { 375 if (rconfig->type != TWL4030_RESCONFIG_UNDEF) {
359 type &= ~TYPE_MASK; 376 type &= ~TYPE_MASK;
360 type |= rconfig->type << TYPE_SHIFT; 377 type |= rconfig->type << TYPE_SHIFT;
361 } 378 }
362 379
363 if (rconfig->type2 >= 0) { 380 if (rconfig->type2 != TWL4030_RESCONFIG_UNDEF) {
364 type &= ~TYPE2_MASK; 381 type &= ~TYPE2_MASK;
365 type |= rconfig->type2 << TYPE2_SHIFT; 382 type |= rconfig->type2 << TYPE2_SHIFT;
366 } 383 }
367 384
368 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 385 err = twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
369 type, rconfig_addr + TYPE_OFFSET); 386 type, rconfig_addr + TYPE_OFFSET);
370 if (err < 0) { 387 if (err < 0) {
371 pr_err("TWL4030 failed to program resource type\n"); 388 pr_err("TWL4030 failed to program resource type\n");
372 return err; 389 return err;
373 } 390 }
374 391
392 /* Set remap states */
393 err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &remap,
394 rconfig_addr + REMAP_OFFSET);
395 if (err < 0) {
396 pr_err("TWL4030 Resource %d remap could not be read\n",
397 rconfig->resource);
398 return err;
399 }
400
401 if (rconfig->remap_off != TWL4030_RESCONFIG_UNDEF) {
402 remap &= ~OFF_STATE_MASK;
403 remap |= rconfig->remap_off << OFF_STATE_SHIFT;
404 }
405
406 if (rconfig->remap_sleep != TWL4030_RESCONFIG_UNDEF) {
407 remap &= ~SLEEP_STATE_MASK;
408 remap |= rconfig->remap_off << SLEEP_STATE_SHIFT;
409 }
410
411 err = twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
412 remap,
413 rconfig_addr + REMAP_OFFSET);
414 if (err < 0) {
415 pr_err("TWL4030 failed to program remap\n");
416 return err;
417 }
418
375 return 0; 419 return 0;
376} 420}
377 421
@@ -424,12 +468,12 @@ void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
424 struct twl4030_resconfig *resconfig; 468 struct twl4030_resconfig *resconfig;
425 u8 address = twl4030_start_script_address; 469 u8 address = twl4030_start_script_address;
426 470
427 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, R_KEY_1, 471 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, R_KEY_1,
428 R_PROTECT_KEY); 472 R_PROTECT_KEY);
429 if (err) 473 if (err)
430 goto unlock; 474 goto unlock;
431 475
432 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, R_KEY_2, 476 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, R_KEY_2,
433 R_PROTECT_KEY); 477 R_PROTECT_KEY);
434 if (err) 478 if (err)
435 goto unlock; 479 goto unlock;
@@ -452,7 +496,7 @@ void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
452 } 496 }
453 } 497 }
454 498
455 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, R_PROTECT_KEY); 499 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, R_PROTECT_KEY);
456 if (err) 500 if (err)
457 pr_err("TWL4030 Unable to relock registers\n"); 501 pr_err("TWL4030 Unable to relock registers\n");
458 return; 502 return;
diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
new file mode 100644
index 000000000000..10bf228ad626
--- /dev/null
+++ b/drivers/mfd/twl6030-irq.c
@@ -0,0 +1,299 @@
1/*
2 * twl6030-irq.c - TWL6030 irq support
3 *
4 * Copyright (C) 2005-2009 Texas Instruments, Inc.
5 *
6 * Modifications to defer interrupt handling to a kernel thread:
7 * Copyright (C) 2006 MontaVista Software, Inc.
8 *
9 * Based on tlv320aic23.c:
10 * Copyright (c) by Kai Svahn <kai.svahn@nokia.com>
11 *
12 * Code cleanup and modifications to IRQ handler.
13 * by syed khasim <x0khasim@ti.com>
14 *
15 * TWL6030 specific code and IRQ handling changes by
16 * Jagadeesh Bhaskar Pakaravoor <j-pakaravoor@ti.com>
17 * Balaji T K <balajitk@ti.com>
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 */
33
34#include <linux/init.h>
35#include <linux/interrupt.h>
36#include <linux/irq.h>
37#include <linux/kthread.h>
38#include <linux/i2c/twl.h>
39
40/*
41 * TWL6030 (unlike its predecessors, which had two level interrupt handling)
42 * three interrupt registers INT_STS_A, INT_STS_B and INT_STS_C.
43 * It exposes status bits saying who has raised an interrupt. There are
44 * three mask registers that corresponds to these status registers, that
45 * enables/disables these interrupts.
46 *
47 * We set up IRQs starting at a platform-specified base. An interrupt map table,
48 * specifies mapping between interrupt number and the associated module.
49 *
50 */
51
52static int twl6030_interrupt_mapping[24] = {
53 PWR_INTR_OFFSET, /* Bit 0 PWRON */
54 PWR_INTR_OFFSET, /* Bit 1 RPWRON */
55 PWR_INTR_OFFSET, /* Bit 2 BAT_VLOW */
56 RTC_INTR_OFFSET, /* Bit 3 RTC_ALARM */
57 RTC_INTR_OFFSET, /* Bit 4 RTC_PERIOD */
58 HOTDIE_INTR_OFFSET, /* Bit 5 HOT_DIE */
59 SMPSLDO_INTR_OFFSET, /* Bit 6 VXXX_SHORT */
60 SMPSLDO_INTR_OFFSET, /* Bit 7 VMMC_SHORT */
61
62 SMPSLDO_INTR_OFFSET, /* Bit 8 VUSIM_SHORT */
63 BATDETECT_INTR_OFFSET, /* Bit 9 BAT */
64 SIMDETECT_INTR_OFFSET, /* Bit 10 SIM */
65 MMCDETECT_INTR_OFFSET, /* Bit 11 MMC */
66 RSV_INTR_OFFSET, /* Bit 12 Reserved */
67 MADC_INTR_OFFSET, /* Bit 13 GPADC_RT_EOC */
68 MADC_INTR_OFFSET, /* Bit 14 GPADC_SW_EOC */
69 GASGAUGE_INTR_OFFSET, /* Bit 15 CC_AUTOCAL */
70
71 USBOTG_INTR_OFFSET, /* Bit 16 ID_WKUP */
72 USBOTG_INTR_OFFSET, /* Bit 17 VBUS_WKUP */
73 USBOTG_INTR_OFFSET, /* Bit 18 ID */
74 USBOTG_INTR_OFFSET, /* Bit 19 VBUS */
75 CHARGER_INTR_OFFSET, /* Bit 20 CHRG_CTRL */
76 CHARGER_INTR_OFFSET, /* Bit 21 EXT_CHRG */
77 CHARGER_INTR_OFFSET, /* Bit 22 INT_CHRG */
78 RSV_INTR_OFFSET, /* Bit 23 Reserved */
79};
80/*----------------------------------------------------------------------*/
81
82static unsigned twl6030_irq_base;
83
84static struct completion irq_event;
85
86/*
87 * This thread processes interrupts reported by the Primary Interrupt Handler.
88 */
89static int twl6030_irq_thread(void *data)
90{
91 long irq = (long)data;
92 static unsigned i2c_errors;
93 static const unsigned max_i2c_errors = 100;
94 int ret;
95
96 current->flags |= PF_NOFREEZE;
97
98 while (!kthread_should_stop()) {
99 int i;
100 union {
101 u8 bytes[4];
102 u32 int_sts;
103 } sts;
104
105 /* Wait for IRQ, then read PIH irq status (also blocking) */
106 wait_for_completion_interruptible(&irq_event);
107
108 /* read INT_STS_A, B and C in one shot using a burst read */
109 ret = twl_i2c_read(TWL_MODULE_PIH, sts.bytes,
110 REG_INT_STS_A, 3);
111 if (ret) {
112 pr_warning("twl6030: I2C error %d reading PIH ISR\n",
113 ret);
114 if (++i2c_errors >= max_i2c_errors) {
115 printk(KERN_ERR "Maximum I2C error count"
116 " exceeded. Terminating %s.\n",
117 __func__);
118 break;
119 }
120 complete(&irq_event);
121 continue;
122 }
123
124
125
126 sts.bytes[3] = 0; /* Only 24 bits are valid*/
127
128 for (i = 0; sts.int_sts; sts.int_sts >>= 1, i++) {
129 local_irq_disable();
130 if (sts.int_sts & 0x1) {
131 int module_irq = twl6030_irq_base +
132 twl6030_interrupt_mapping[i];
133 struct irq_desc *d = irq_to_desc(module_irq);
134
135 if (!d) {
136 pr_err("twl6030: Invalid SIH IRQ: %d\n",
137 module_irq);
138 return -EINVAL;
139 }
140
141 /* These can't be masked ... always warn
142 * if we get any surprises.
143 */
144 if (d->status & IRQ_DISABLED)
145 note_interrupt(module_irq, d,
146 IRQ_NONE);
147 else
148 d->handle_irq(module_irq, d);
149
150 }
151 local_irq_enable();
152 }
153 ret = twl_i2c_write(TWL_MODULE_PIH, sts.bytes,
154 REG_INT_STS_A, 3); /* clear INT_STS_A */
155 if (ret)
156 pr_warning("twl6030: I2C error in clearing PIH ISR\n");
157
158 enable_irq(irq);
159 }
160
161 return 0;
162}
163
164/*
165 * handle_twl6030_int() is the desc->handle method for the twl6030 interrupt.
166 * This is a chained interrupt, so there is no desc->action method for it.
167 * Now we need to query the interrupt controller in the twl6030 to determine
168 * which module is generating the interrupt request. However, we can't do i2c
169 * transactions in interrupt context, so we must defer that work to a kernel
170 * thread. All we do here is acknowledge and mask the interrupt and wakeup
171 * the kernel thread.
172 */
173static irqreturn_t handle_twl6030_pih(int irq, void *devid)
174{
175 disable_irq_nosync(irq);
176 complete(devid);
177 return IRQ_HANDLED;
178}
179
180/*----------------------------------------------------------------------*/
181
182static inline void activate_irq(int irq)
183{
184#ifdef CONFIG_ARM
185 /* ARM requires an extra step to clear IRQ_NOREQUEST, which it
186 * sets on behalf of every irq_chip. Also sets IRQ_NOPROBE.
187 */
188 set_irq_flags(irq, IRQF_VALID);
189#else
190 /* same effect on other architectures */
191 set_irq_noprobe(irq);
192#endif
193}
194
195/*----------------------------------------------------------------------*/
196
197static unsigned twl6030_irq_next;
198
199/*----------------------------------------------------------------------*/
200int twl6030_interrupt_unmask(u8 bit_mask, u8 offset)
201{
202 int ret;
203 u8 unmask_value;
204 ret = twl_i2c_read_u8(TWL_MODULE_PIH, &unmask_value,
205 REG_INT_STS_A + offset);
206 unmask_value &= (~(bit_mask));
207 ret |= twl_i2c_write_u8(TWL_MODULE_PIH, unmask_value,
208 REG_INT_STS_A + offset); /* unmask INT_MSK_A/B/C */
209 return ret;
210}
211EXPORT_SYMBOL(twl6030_interrupt_unmask);
212
213int twl6030_interrupt_mask(u8 bit_mask, u8 offset)
214{
215 int ret;
216 u8 mask_value;
217 ret = twl_i2c_read_u8(TWL_MODULE_PIH, &mask_value,
218 REG_INT_STS_A + offset);
219 mask_value |= (bit_mask);
220 ret |= twl_i2c_write_u8(TWL_MODULE_PIH, mask_value,
221 REG_INT_STS_A + offset); /* mask INT_MSK_A/B/C */
222 return ret;
223}
224EXPORT_SYMBOL(twl6030_interrupt_mask);
225
226int twl6030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end)
227{
228
229 int status = 0;
230 int i;
231 struct task_struct *task;
232 int ret;
233 u8 mask[4];
234
235 static struct irq_chip twl6030_irq_chip;
236 mask[1] = 0xFF;
237 mask[2] = 0xFF;
238 mask[3] = 0xFF;
239 ret = twl_i2c_write(TWL_MODULE_PIH, &mask[0],
240 REG_INT_MSK_LINE_A, 3); /* MASK ALL INT LINES */
241 ret = twl_i2c_write(TWL_MODULE_PIH, &mask[0],
242 REG_INT_MSK_STS_A, 3); /* MASK ALL INT STS */
243 ret = twl_i2c_write(TWL_MODULE_PIH, &mask[0],
244 REG_INT_STS_A, 3); /* clear INT_STS_A,B,C */
245
246 twl6030_irq_base = irq_base;
247
248 /* install an irq handler for each of the modules;
249 * clone dummy irq_chip since PIH can't *do* anything
250 */
251 twl6030_irq_chip = dummy_irq_chip;
252 twl6030_irq_chip.name = "twl6030";
253 twl6030_irq_chip.set_type = NULL;
254
255 for (i = irq_base; i < irq_end; i++) {
256 set_irq_chip_and_handler(i, &twl6030_irq_chip,
257 handle_simple_irq);
258 activate_irq(i);
259 }
260
261 twl6030_irq_next = i;
262 pr_info("twl6030: %s (irq %d) chaining IRQs %d..%d\n", "PIH",
263 irq_num, irq_base, twl6030_irq_next - 1);
264
265 /* install an irq handler to demultiplex the TWL6030 interrupt */
266 init_completion(&irq_event);
267 task = kthread_run(twl6030_irq_thread, (void *)irq_num, "twl6030-irq");
268 if (IS_ERR(task)) {
269 pr_err("twl6030: could not create irq %d thread!\n", irq_num);
270 status = PTR_ERR(task);
271 goto fail_kthread;
272 }
273
274 status = request_irq(irq_num, handle_twl6030_pih, IRQF_DISABLED,
275 "TWL6030-PIH", &irq_event);
276 if (status < 0) {
277 pr_err("twl6030: could not claim irq%d: %d\n", irq_num, status);
278 goto fail_irq;
279 }
280 return status;
281fail_irq:
282 free_irq(irq_num, &irq_event);
283
284fail_kthread:
285 for (i = irq_base; i < irq_end; i++)
286 set_irq_chip_and_handler(i, NULL, NULL);
287 return status;
288}
289
290int twl6030_exit_irq(void)
291{
292
293 if (twl6030_irq_base) {
294 pr_err("twl6030: can't yet clean up IRQs?\n");
295 return -ENOSYS;
296 }
297 return 0;
298}
299
diff --git a/drivers/mfd/wm831x-core.c b/drivers/mfd/wm831x-core.c
index 7f27576ca046..223a90c7492f 100644
--- a/drivers/mfd/wm831x-core.c
+++ b/drivers/mfd/wm831x-core.c
@@ -90,9 +90,10 @@ int wm831x_isinkv_values[WM831X_ISINK_MAX_ISEL + 1] = {
90EXPORT_SYMBOL_GPL(wm831x_isinkv_values); 90EXPORT_SYMBOL_GPL(wm831x_isinkv_values);
91 91
92enum wm831x_parent { 92enum wm831x_parent {
93 WM8310 = 0, 93 WM8310 = 0x8310,
94 WM8311 = 1, 94 WM8311 = 0x8311,
95 WM8312 = 2, 95 WM8312 = 0x8312,
96 WM8320 = 0x8320,
96}; 97};
97 98
98static int wm831x_reg_locked(struct wm831x *wm831x, unsigned short reg) 99static int wm831x_reg_locked(struct wm831x *wm831x, unsigned short reg)
@@ -478,6 +479,20 @@ static struct resource wm831x_dcdc4_resources[] = {
478 }, 479 },
479}; 480};
480 481
482static struct resource wm8320_dcdc4_buck_resources[] = {
483 {
484 .start = WM831X_DC4_CONTROL,
485 .end = WM832X_DC4_SLEEP_CONTROL,
486 .flags = IORESOURCE_IO,
487 },
488 {
489 .name = "UV",
490 .start = WM831X_IRQ_UV_DC4,
491 .end = WM831X_IRQ_UV_DC4,
492 .flags = IORESOURCE_IRQ,
493 },
494};
495
481static struct resource wm831x_gpio_resources[] = { 496static struct resource wm831x_gpio_resources[] = {
482 { 497 {
483 .start = WM831X_IRQ_GPIO_1, 498 .start = WM831X_IRQ_GPIO_1,
@@ -1237,6 +1252,137 @@ static struct mfd_cell wm8312_devs[] = {
1237 }, 1252 },
1238}; 1253};
1239 1254
1255static struct mfd_cell wm8320_devs[] = {
1256 {
1257 .name = "wm831x-backup",
1258 },
1259 {
1260 .name = "wm831x-buckv",
1261 .id = 1,
1262 .num_resources = ARRAY_SIZE(wm831x_dcdc1_resources),
1263 .resources = wm831x_dcdc1_resources,
1264 },
1265 {
1266 .name = "wm831x-buckv",
1267 .id = 2,
1268 .num_resources = ARRAY_SIZE(wm831x_dcdc2_resources),
1269 .resources = wm831x_dcdc2_resources,
1270 },
1271 {
1272 .name = "wm831x-buckp",
1273 .id = 3,
1274 .num_resources = ARRAY_SIZE(wm831x_dcdc3_resources),
1275 .resources = wm831x_dcdc3_resources,
1276 },
1277 {
1278 .name = "wm831x-buckp",
1279 .id = 4,
1280 .num_resources = ARRAY_SIZE(wm8320_dcdc4_buck_resources),
1281 .resources = wm8320_dcdc4_buck_resources,
1282 },
1283 {
1284 .name = "wm831x-gpio",
1285 .num_resources = ARRAY_SIZE(wm831x_gpio_resources),
1286 .resources = wm831x_gpio_resources,
1287 },
1288 {
1289 .name = "wm831x-hwmon",
1290 },
1291 {
1292 .name = "wm831x-ldo",
1293 .id = 1,
1294 .num_resources = ARRAY_SIZE(wm831x_ldo1_resources),
1295 .resources = wm831x_ldo1_resources,
1296 },
1297 {
1298 .name = "wm831x-ldo",
1299 .id = 2,
1300 .num_resources = ARRAY_SIZE(wm831x_ldo2_resources),
1301 .resources = wm831x_ldo2_resources,
1302 },
1303 {
1304 .name = "wm831x-ldo",
1305 .id = 3,
1306 .num_resources = ARRAY_SIZE(wm831x_ldo3_resources),
1307 .resources = wm831x_ldo3_resources,
1308 },
1309 {
1310 .name = "wm831x-ldo",
1311 .id = 4,
1312 .num_resources = ARRAY_SIZE(wm831x_ldo4_resources),
1313 .resources = wm831x_ldo4_resources,
1314 },
1315 {
1316 .name = "wm831x-ldo",
1317 .id = 5,
1318 .num_resources = ARRAY_SIZE(wm831x_ldo5_resources),
1319 .resources = wm831x_ldo5_resources,
1320 },
1321 {
1322 .name = "wm831x-ldo",
1323 .id = 6,
1324 .num_resources = ARRAY_SIZE(wm831x_ldo6_resources),
1325 .resources = wm831x_ldo6_resources,
1326 },
1327 {
1328 .name = "wm831x-aldo",
1329 .id = 7,
1330 .num_resources = ARRAY_SIZE(wm831x_ldo7_resources),
1331 .resources = wm831x_ldo7_resources,
1332 },
1333 {
1334 .name = "wm831x-aldo",
1335 .id = 8,
1336 .num_resources = ARRAY_SIZE(wm831x_ldo8_resources),
1337 .resources = wm831x_ldo8_resources,
1338 },
1339 {
1340 .name = "wm831x-aldo",
1341 .id = 9,
1342 .num_resources = ARRAY_SIZE(wm831x_ldo9_resources),
1343 .resources = wm831x_ldo9_resources,
1344 },
1345 {
1346 .name = "wm831x-aldo",
1347 .id = 10,
1348 .num_resources = ARRAY_SIZE(wm831x_ldo10_resources),
1349 .resources = wm831x_ldo10_resources,
1350 },
1351 {
1352 .name = "wm831x-alive-ldo",
1353 .id = 11,
1354 .num_resources = ARRAY_SIZE(wm831x_ldo11_resources),
1355 .resources = wm831x_ldo11_resources,
1356 },
1357 {
1358 .name = "wm831x-on",
1359 .num_resources = ARRAY_SIZE(wm831x_on_resources),
1360 .resources = wm831x_on_resources,
1361 },
1362 {
1363 .name = "wm831x-rtc",
1364 .num_resources = ARRAY_SIZE(wm831x_rtc_resources),
1365 .resources = wm831x_rtc_resources,
1366 },
1367 {
1368 .name = "wm831x-status",
1369 .id = 1,
1370 .num_resources = ARRAY_SIZE(wm831x_status1_resources),
1371 .resources = wm831x_status1_resources,
1372 },
1373 {
1374 .name = "wm831x-status",
1375 .id = 2,
1376 .num_resources = ARRAY_SIZE(wm831x_status2_resources),
1377 .resources = wm831x_status2_resources,
1378 },
1379 {
1380 .name = "wm831x-watchdog",
1381 .num_resources = ARRAY_SIZE(wm831x_wdt_resources),
1382 .resources = wm831x_wdt_resources,
1383 },
1384};
1385
1240static struct mfd_cell backlight_devs[] = { 1386static struct mfd_cell backlight_devs[] = {
1241 { 1387 {
1242 .name = "wm831x-backlight", 1388 .name = "wm831x-backlight",
@@ -1282,50 +1428,37 @@ static int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
1282 goto err; 1428 goto err;
1283 } 1429 }
1284 1430
1431 /* Some engineering samples do not have the ID set, rely on
1432 * the device being registered correctly.
1433 */
1434 if (ret == 0) {
1435 dev_info(wm831x->dev, "Device is an engineering sample\n");
1436 ret = id;
1437 }
1438
1285 switch (ret) { 1439 switch (ret) {
1286 case 0x8310: 1440 case WM8310:
1287 parent = WM8310; 1441 parent = WM8310;
1288 switch (rev) { 1442 wm831x->num_gpio = 16;
1289 case 0: 1443 dev_info(wm831x->dev, "WM8310 revision %c\n", 'A' + rev);
1290 dev_info(wm831x->dev, "WM8310 revision %c\n",
1291 'A' + rev);
1292 break;
1293 }
1294 break; 1444 break;
1295 1445
1296 case 0x8311: 1446 case WM8311:
1297 parent = WM8311; 1447 parent = WM8311;
1298 switch (rev) { 1448 wm831x->num_gpio = 16;
1299 case 0: 1449 dev_info(wm831x->dev, "WM8311 revision %c\n", 'A' + rev);
1300 dev_info(wm831x->dev, "WM8311 revision %c\n",
1301 'A' + rev);
1302 break;
1303 }
1304 break; 1450 break;
1305 1451
1306 case 0x8312: 1452 case WM8312:
1307 parent = WM8312; 1453 parent = WM8312;
1308 switch (rev) { 1454 wm831x->num_gpio = 16;
1309 case 0: 1455 dev_info(wm831x->dev, "WM8312 revision %c\n", 'A' + rev);
1310 dev_info(wm831x->dev, "WM8312 revision %c\n",
1311 'A' + rev);
1312 break;
1313 }
1314 break; 1456 break;
1315 1457
1316 case 0: 1458 case WM8320:
1317 /* Some engineering samples do not have the ID set, 1459 parent = WM8320;
1318 * rely on the device being registered correctly. 1460 wm831x->num_gpio = 12;
1319 * This will need revisiting for future devices with 1461 dev_info(wm831x->dev, "WM8320 revision %c\n", 'A' + rev);
1320 * multiple dies.
1321 */
1322 parent = id;
1323 switch (rev) {
1324 case 0:
1325 dev_info(wm831x->dev, "WM831%d ES revision %c\n",
1326 parent, 'A' + rev);
1327 break;
1328 }
1329 break; 1462 break;
1330 1463
1331 default: 1464 default:
@@ -1338,7 +1471,7 @@ static int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
1338 * current parts. 1471 * current parts.
1339 */ 1472 */
1340 if (parent != id) 1473 if (parent != id)
1341 dev_warn(wm831x->dev, "Device was registered as a WM831%lu\n", 1474 dev_warn(wm831x->dev, "Device was registered as a WM%lx\n",
1342 id); 1475 id);
1343 1476
1344 /* Bootstrap the user key */ 1477 /* Bootstrap the user key */
@@ -1371,18 +1504,24 @@ static int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
1371 case WM8310: 1504 case WM8310:
1372 ret = mfd_add_devices(wm831x->dev, -1, 1505 ret = mfd_add_devices(wm831x->dev, -1,
1373 wm8310_devs, ARRAY_SIZE(wm8310_devs), 1506 wm8310_devs, ARRAY_SIZE(wm8310_devs),
1374 NULL, 0); 1507 NULL, wm831x->irq_base);
1375 break; 1508 break;
1376 1509
1377 case WM8311: 1510 case WM8311:
1378 ret = mfd_add_devices(wm831x->dev, -1, 1511 ret = mfd_add_devices(wm831x->dev, -1,
1379 wm8311_devs, ARRAY_SIZE(wm8311_devs), 1512 wm8311_devs, ARRAY_SIZE(wm8311_devs),
1380 NULL, 0); 1513 NULL, wm831x->irq_base);
1381 break; 1514 break;
1382 1515
1383 case WM8312: 1516 case WM8312:
1384 ret = mfd_add_devices(wm831x->dev, -1, 1517 ret = mfd_add_devices(wm831x->dev, -1,
1385 wm8312_devs, ARRAY_SIZE(wm8312_devs), 1518 wm8312_devs, ARRAY_SIZE(wm8312_devs),
1519 NULL, wm831x->irq_base);
1520 break;
1521
1522 case WM8320:
1523 ret = mfd_add_devices(wm831x->dev, -1,
1524 wm8320_devs, ARRAY_SIZE(wm8320_devs),
1386 NULL, 0); 1525 NULL, 0);
1387 break; 1526 break;
1388 1527
@@ -1399,7 +1538,8 @@ static int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
1399 if (pdata && pdata->backlight) { 1538 if (pdata && pdata->backlight) {
1400 /* Treat errors as non-critical */ 1539 /* Treat errors as non-critical */
1401 ret = mfd_add_devices(wm831x->dev, -1, backlight_devs, 1540 ret = mfd_add_devices(wm831x->dev, -1, backlight_devs,
1402 ARRAY_SIZE(backlight_devs), NULL, 0); 1541 ARRAY_SIZE(backlight_devs), NULL,
1542 wm831x->irq_base);
1403 if (ret < 0) 1543 if (ret < 0)
1404 dev_err(wm831x->dev, "Failed to add backlight: %d\n", 1544 dev_err(wm831x->dev, "Failed to add backlight: %d\n",
1405 ret); 1545 ret);
@@ -1511,6 +1651,7 @@ static const struct i2c_device_id wm831x_i2c_id[] = {
1511 { "wm8310", WM8310 }, 1651 { "wm8310", WM8310 },
1512 { "wm8311", WM8311 }, 1652 { "wm8311", WM8311 },
1513 { "wm8312", WM8312 }, 1653 { "wm8312", WM8312 },
1654 { "wm8320", WM8320 },
1514 { } 1655 { }
1515}; 1656};
1516MODULE_DEVICE_TABLE(i2c, wm831x_i2c_id); 1657MODULE_DEVICE_TABLE(i2c, wm831x_i2c_id);
diff --git a/drivers/mfd/wm831x-irq.c b/drivers/mfd/wm831x-irq.c
index ac056ea6b66e..301327697117 100644
--- a/drivers/mfd/wm831x-irq.c
+++ b/drivers/mfd/wm831x-irq.c
@@ -15,6 +15,7 @@
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/i2c.h> 17#include <linux/i2c.h>
18#include <linux/irq.h>
18#include <linux/mfd/core.h> 19#include <linux/mfd/core.h>
19#include <linux/interrupt.h> 20#include <linux/interrupt.h>
20 21
@@ -339,110 +340,71 @@ static inline int irq_data_to_mask_reg(struct wm831x_irq_data *irq_data)
339 return WM831X_INTERRUPT_STATUS_1_MASK - 1 + irq_data->reg; 340 return WM831X_INTERRUPT_STATUS_1_MASK - 1 + irq_data->reg;
340} 341}
341 342
342static void __wm831x_enable_irq(struct wm831x *wm831x, int irq) 343static inline struct wm831x_irq_data *irq_to_wm831x_irq(struct wm831x *wm831x,
344 int irq)
343{ 345{
344 struct wm831x_irq_data *irq_data = &wm831x_irqs[irq]; 346 return &wm831x_irqs[irq - wm831x->irq_base];
345
346 wm831x->irq_masks[irq_data->reg - 1] &= ~irq_data->mask;
347 wm831x_reg_write(wm831x, irq_data_to_mask_reg(irq_data),
348 wm831x->irq_masks[irq_data->reg - 1]);
349} 347}
350 348
351void wm831x_enable_irq(struct wm831x *wm831x, int irq) 349static void wm831x_irq_lock(unsigned int irq)
352{ 350{
353 mutex_lock(&wm831x->irq_lock); 351 struct wm831x *wm831x = get_irq_chip_data(irq);
354 __wm831x_enable_irq(wm831x, irq);
355 mutex_unlock(&wm831x->irq_lock);
356}
357EXPORT_SYMBOL_GPL(wm831x_enable_irq);
358 352
359static void __wm831x_disable_irq(struct wm831x *wm831x, int irq)
360{
361 struct wm831x_irq_data *irq_data = &wm831x_irqs[irq];
362
363 wm831x->irq_masks[irq_data->reg - 1] |= irq_data->mask;
364 wm831x_reg_write(wm831x, irq_data_to_mask_reg(irq_data),
365 wm831x->irq_masks[irq_data->reg - 1]);
366}
367
368void wm831x_disable_irq(struct wm831x *wm831x, int irq)
369{
370 mutex_lock(&wm831x->irq_lock); 353 mutex_lock(&wm831x->irq_lock);
371 __wm831x_disable_irq(wm831x, irq);
372 mutex_unlock(&wm831x->irq_lock);
373} 354}
374EXPORT_SYMBOL_GPL(wm831x_disable_irq);
375 355
376int wm831x_request_irq(struct wm831x *wm831x, 356static void wm831x_irq_sync_unlock(unsigned int irq)
377 unsigned int irq, irq_handler_t handler,
378 unsigned long flags, const char *name,
379 void *dev)
380{ 357{
381 int ret = 0; 358 struct wm831x *wm831x = get_irq_chip_data(irq);
382 359 int i;
383 if (irq < 0 || irq >= WM831X_NUM_IRQS) 360
384 return -EINVAL; 361 for (i = 0; i < ARRAY_SIZE(wm831x->irq_masks_cur); i++) {
385 362 /* If there's been a change in the mask write it back
386 mutex_lock(&wm831x->irq_lock); 363 * to the hardware. */
387 364 if (wm831x->irq_masks_cur[i] != wm831x->irq_masks_cache[i]) {
388 if (wm831x_irqs[irq].handler) { 365 wm831x->irq_masks_cache[i] = wm831x->irq_masks_cur[i];
389 dev_err(wm831x->dev, "Already have handler for IRQ %d\n", irq); 366 wm831x_reg_write(wm831x,
390 ret = -EINVAL; 367 WM831X_INTERRUPT_STATUS_1_MASK + i,
391 goto out; 368 wm831x->irq_masks_cur[i]);
369 }
392 } 370 }
393 371
394 wm831x_irqs[irq].handler = handler;
395 wm831x_irqs[irq].handler_data = dev;
396
397 __wm831x_enable_irq(wm831x, irq);
398
399out:
400 mutex_unlock(&wm831x->irq_lock); 372 mutex_unlock(&wm831x->irq_lock);
401
402 return ret;
403} 373}
404EXPORT_SYMBOL_GPL(wm831x_request_irq);
405 374
406void wm831x_free_irq(struct wm831x *wm831x, unsigned int irq, void *data) 375static void wm831x_irq_unmask(unsigned int irq)
407{ 376{
408 if (irq < 0 || irq >= WM831X_NUM_IRQS) 377 struct wm831x *wm831x = get_irq_chip_data(irq);
409 return; 378 struct wm831x_irq_data *irq_data = irq_to_wm831x_irq(wm831x, irq);
410
411 mutex_lock(&wm831x->irq_lock);
412 379
413 wm831x_irqs[irq].handler = NULL; 380 wm831x->irq_masks_cur[irq_data->reg - 1] &= ~irq_data->mask;
414 wm831x_irqs[irq].handler_data = NULL;
415
416 __wm831x_disable_irq(wm831x, irq);
417
418 mutex_unlock(&wm831x->irq_lock);
419} 381}
420EXPORT_SYMBOL_GPL(wm831x_free_irq);
421 382
422 383static void wm831x_irq_mask(unsigned int irq)
423static void wm831x_handle_irq(struct wm831x *wm831x, int irq, int status)
424{ 384{
425 struct wm831x_irq_data *irq_data = &wm831x_irqs[irq]; 385 struct wm831x *wm831x = get_irq_chip_data(irq);
426 386 struct wm831x_irq_data *irq_data = irq_to_wm831x_irq(wm831x, irq);
427 if (irq_data->handler) { 387
428 irq_data->handler(irq, irq_data->handler_data); 388 wm831x->irq_masks_cur[irq_data->reg - 1] |= irq_data->mask;
429 wm831x_reg_write(wm831x, irq_data_to_status_reg(irq_data),
430 irq_data->mask);
431 } else {
432 dev_err(wm831x->dev, "Unhandled IRQ %d, masking\n", irq);
433 __wm831x_disable_irq(wm831x, irq);
434 }
435} 389}
436 390
437/* Main interrupt handling occurs in a workqueue since we need 391static struct irq_chip wm831x_irq_chip = {
438 * interrupts enabled to interact with the chip. */ 392 .name = "wm831x",
439static void wm831x_irq_worker(struct work_struct *work) 393 .bus_lock = wm831x_irq_lock,
394 .bus_sync_unlock = wm831x_irq_sync_unlock,
395 .mask = wm831x_irq_mask,
396 .unmask = wm831x_irq_unmask,
397};
398
399/* The processing of the primary interrupt occurs in a thread so that
400 * we can interact with the device over I2C or SPI. */
401static irqreturn_t wm831x_irq_thread(int irq, void *data)
440{ 402{
441 struct wm831x *wm831x = container_of(work, struct wm831x, irq_work); 403 struct wm831x *wm831x = data;
442 unsigned int i; 404 unsigned int i;
443 int primary; 405 int primary;
444 int status_regs[5]; 406 int status_regs[WM831X_NUM_IRQ_REGS] = { 0 };
445 int read[5] = { 0 }; 407 int read[WM831X_NUM_IRQ_REGS] = { 0 };
446 int *status; 408 int *status;
447 409
448 primary = wm831x_reg_read(wm831x, WM831X_SYSTEM_INTERRUPTS); 410 primary = wm831x_reg_read(wm831x, WM831X_SYSTEM_INTERRUPTS);
@@ -452,8 +414,6 @@ static void wm831x_irq_worker(struct work_struct *work)
452 goto out; 414 goto out;
453 } 415 }
454 416
455 mutex_lock(&wm831x->irq_lock);
456
457 for (i = 0; i < ARRAY_SIZE(wm831x_irqs); i++) { 417 for (i = 0; i < ARRAY_SIZE(wm831x_irqs); i++) {
458 int offset = wm831x_irqs[i].reg - 1; 418 int offset = wm831x_irqs[i].reg - 1;
459 419
@@ -471,41 +431,34 @@ static void wm831x_irq_worker(struct work_struct *work)
471 dev_err(wm831x->dev, 431 dev_err(wm831x->dev,
472 "Failed to read IRQ status: %d\n", 432 "Failed to read IRQ status: %d\n",
473 *status); 433 *status);
474 goto out_lock; 434 goto out;
475 } 435 }
476 436
477 /* Mask out the disabled IRQs */
478 *status &= ~wm831x->irq_masks[offset];
479 read[offset] = 1; 437 read[offset] = 1;
480 } 438 }
481 439
482 if (*status & wm831x_irqs[i].mask) 440 /* Report it if it isn't masked, or forget the status. */
483 wm831x_handle_irq(wm831x, i, *status); 441 if ((*status & ~wm831x->irq_masks_cur[offset])
442 & wm831x_irqs[i].mask)
443 handle_nested_irq(wm831x->irq_base + i);
444 else
445 *status &= ~wm831x_irqs[i].mask;
484 } 446 }
485 447
486out_lock:
487 mutex_unlock(&wm831x->irq_lock);
488out: 448out:
489 enable_irq(wm831x->irq); 449 for (i = 0; i < ARRAY_SIZE(status_regs); i++) {
490} 450 if (status_regs[i])
491 451 wm831x_reg_write(wm831x, WM831X_INTERRUPT_STATUS_1 + i,
492 452 status_regs[i]);
493static irqreturn_t wm831x_cpu_irq(int irq, void *data) 453 }
494{
495 struct wm831x *wm831x = data;
496
497 /* Shut the interrupt to the CPU up and schedule the actual
498 * handler; we can't check that the IRQ is asserted. */
499 disable_irq_nosync(irq);
500
501 queue_work(wm831x->irq_wq, &wm831x->irq_work);
502 454
503 return IRQ_HANDLED; 455 return IRQ_HANDLED;
504} 456}
505 457
506int wm831x_irq_init(struct wm831x *wm831x, int irq) 458int wm831x_irq_init(struct wm831x *wm831x, int irq)
507{ 459{
508 int i, ret; 460 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
461 int i, cur_irq, ret;
509 462
510 mutex_init(&wm831x->irq_lock); 463 mutex_init(&wm831x->irq_lock);
511 464
@@ -515,41 +468,53 @@ int wm831x_irq_init(struct wm831x *wm831x, int irq)
515 return 0; 468 return 0;
516 } 469 }
517 470
518 471 if (!pdata || !pdata->irq_base) {
519 wm831x->irq_wq = create_singlethread_workqueue("wm831x-irq"); 472 dev_err(wm831x->dev,
520 if (!wm831x->irq_wq) { 473 "No interrupt base specified, no interrupts\n");
521 dev_err(wm831x->dev, "Failed to allocate IRQ worker\n"); 474 return 0;
522 return -ESRCH;
523 } 475 }
524 476
525 wm831x->irq = irq; 477 wm831x->irq = irq;
526 INIT_WORK(&wm831x->irq_work, wm831x_irq_worker); 478 wm831x->irq_base = pdata->irq_base;
527 479
528 /* Mask the individual interrupt sources */ 480 /* Mask the individual interrupt sources */
529 for (i = 0; i < ARRAY_SIZE(wm831x->irq_masks); i++) { 481 for (i = 0; i < ARRAY_SIZE(wm831x->irq_masks_cur); i++) {
530 wm831x->irq_masks[i] = 0xffff; 482 wm831x->irq_masks_cur[i] = 0xffff;
483 wm831x->irq_masks_cache[i] = 0xffff;
531 wm831x_reg_write(wm831x, WM831X_INTERRUPT_STATUS_1_MASK + i, 484 wm831x_reg_write(wm831x, WM831X_INTERRUPT_STATUS_1_MASK + i,
532 0xffff); 485 0xffff);
533 } 486 }
534 487
535 /* Enable top level interrupts, we mask at secondary level */ 488 /* Register them with genirq */
536 wm831x_reg_write(wm831x, WM831X_SYSTEM_INTERRUPTS_MASK, 0); 489 for (cur_irq = wm831x->irq_base;
490 cur_irq < ARRAY_SIZE(wm831x_irqs) + wm831x->irq_base;
491 cur_irq++) {
492 set_irq_chip_data(cur_irq, wm831x);
493 set_irq_chip_and_handler(cur_irq, &wm831x_irq_chip,
494 handle_edge_irq);
495 set_irq_nested_thread(cur_irq, 1);
496
497 /* ARM needs us to explicitly flag the IRQ as valid
498 * and will set them noprobe when we do so. */
499#ifdef CONFIG_ARM
500 set_irq_flags(cur_irq, IRQF_VALID);
501#else
502 set_irq_noprobe(cur_irq);
503#endif
504 }
537 505
538 /* We're good to go. We set IRQF_SHARED since there's a 506 ret = request_threaded_irq(irq, NULL, wm831x_irq_thread,
539 * chance the driver will interoperate with another driver but 507 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
540 * the need to disable the IRQ while handing via I2C/SPI means 508 "wm831x", wm831x);
541 * that this may break and performance will be impacted. If
542 * this does happen it's a hardware design issue and the only
543 * other alternative would be polling.
544 */
545 ret = request_irq(irq, wm831x_cpu_irq, IRQF_TRIGGER_LOW | IRQF_SHARED,
546 "wm831x", wm831x);
547 if (ret != 0) { 509 if (ret != 0) {
548 dev_err(wm831x->dev, "Failed to request IRQ %d: %d\n", 510 dev_err(wm831x->dev, "Failed to request IRQ %d: %d\n",
549 irq, ret); 511 irq, ret);
550 return ret; 512 return ret;
551 } 513 }
552 514
515 /* Enable top level interrupts, we mask at secondary level */
516 wm831x_reg_write(wm831x, WM831X_SYSTEM_INTERRUPTS_MASK, 0);
517
553 return 0; 518 return 0;
554} 519}
555 520
diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
index ba27c9dc1ad3..8485a7018060 100644
--- a/drivers/mfd/wm8350-core.c
+++ b/drivers/mfd/wm8350-core.c
@@ -337,733 +337,6 @@ int wm8350_reg_unlock(struct wm8350 *wm8350)
337} 337}
338EXPORT_SYMBOL_GPL(wm8350_reg_unlock); 338EXPORT_SYMBOL_GPL(wm8350_reg_unlock);
339 339
340static void wm8350_irq_call_handler(struct wm8350 *wm8350, int irq)
341{
342 mutex_lock(&wm8350->irq_mutex);
343
344 if (wm8350->irq[irq].handler)
345 wm8350->irq[irq].handler(wm8350, irq, wm8350->irq[irq].data);
346 else {
347 dev_err(wm8350->dev, "irq %d nobody cared. now masked.\n",
348 irq);
349 wm8350_mask_irq(wm8350, irq);
350 }
351
352 mutex_unlock(&wm8350->irq_mutex);
353}
354
355/*
356 * This is a threaded IRQ handler so can access I2C/SPI. Since all
357 * interrupts are clear on read the IRQ line will be reasserted and
358 * the physical IRQ will be handled again if another interrupt is
359 * asserted while we run - in the normal course of events this is a
360 * rare occurrence so we save I2C/SPI reads.
361 */
362static irqreturn_t wm8350_irq(int irq, void *data)
363{
364 struct wm8350 *wm8350 = data;
365 u16 level_one, status1, status2, comp;
366
367 /* TODO: Use block reads to improve performance? */
368 level_one = wm8350_reg_read(wm8350, WM8350_SYSTEM_INTERRUPTS)
369 & ~wm8350_reg_read(wm8350, WM8350_SYSTEM_INTERRUPTS_MASK);
370 status1 = wm8350_reg_read(wm8350, WM8350_INT_STATUS_1)
371 & ~wm8350_reg_read(wm8350, WM8350_INT_STATUS_1_MASK);
372 status2 = wm8350_reg_read(wm8350, WM8350_INT_STATUS_2)
373 & ~wm8350_reg_read(wm8350, WM8350_INT_STATUS_2_MASK);
374 comp = wm8350_reg_read(wm8350, WM8350_COMPARATOR_INT_STATUS)
375 & ~wm8350_reg_read(wm8350, WM8350_COMPARATOR_INT_STATUS_MASK);
376
377 /* over current */
378 if (level_one & WM8350_OC_INT) {
379 u16 oc;
380
381 oc = wm8350_reg_read(wm8350, WM8350_OVER_CURRENT_INT_STATUS);
382 oc &= ~wm8350_reg_read(wm8350,
383 WM8350_OVER_CURRENT_INT_STATUS_MASK);
384
385 if (oc & WM8350_OC_LS_EINT) /* limit switch */
386 wm8350_irq_call_handler(wm8350, WM8350_IRQ_OC_LS);
387 }
388
389 /* under voltage */
390 if (level_one & WM8350_UV_INT) {
391 u16 uv;
392
393 uv = wm8350_reg_read(wm8350, WM8350_UNDER_VOLTAGE_INT_STATUS);
394 uv &= ~wm8350_reg_read(wm8350,
395 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK);
396
397 if (uv & WM8350_UV_DC1_EINT)
398 wm8350_irq_call_handler(wm8350, WM8350_IRQ_UV_DC1);
399 if (uv & WM8350_UV_DC2_EINT)
400 wm8350_irq_call_handler(wm8350, WM8350_IRQ_UV_DC2);
401 if (uv & WM8350_UV_DC3_EINT)
402 wm8350_irq_call_handler(wm8350, WM8350_IRQ_UV_DC3);
403 if (uv & WM8350_UV_DC4_EINT)
404 wm8350_irq_call_handler(wm8350, WM8350_IRQ_UV_DC4);
405 if (uv & WM8350_UV_DC5_EINT)
406 wm8350_irq_call_handler(wm8350, WM8350_IRQ_UV_DC5);
407 if (uv & WM8350_UV_DC6_EINT)
408 wm8350_irq_call_handler(wm8350, WM8350_IRQ_UV_DC6);
409 if (uv & WM8350_UV_LDO1_EINT)
410 wm8350_irq_call_handler(wm8350, WM8350_IRQ_UV_LDO1);
411 if (uv & WM8350_UV_LDO2_EINT)
412 wm8350_irq_call_handler(wm8350, WM8350_IRQ_UV_LDO2);
413 if (uv & WM8350_UV_LDO3_EINT)
414 wm8350_irq_call_handler(wm8350, WM8350_IRQ_UV_LDO3);
415 if (uv & WM8350_UV_LDO4_EINT)
416 wm8350_irq_call_handler(wm8350, WM8350_IRQ_UV_LDO4);
417 }
418
419 /* charger, RTC */
420 if (status1) {
421 if (status1 & WM8350_CHG_BAT_HOT_EINT)
422 wm8350_irq_call_handler(wm8350,
423 WM8350_IRQ_CHG_BAT_HOT);
424 if (status1 & WM8350_CHG_BAT_COLD_EINT)
425 wm8350_irq_call_handler(wm8350,
426 WM8350_IRQ_CHG_BAT_COLD);
427 if (status1 & WM8350_CHG_BAT_FAIL_EINT)
428 wm8350_irq_call_handler(wm8350,
429 WM8350_IRQ_CHG_BAT_FAIL);
430 if (status1 & WM8350_CHG_TO_EINT)
431 wm8350_irq_call_handler(wm8350, WM8350_IRQ_CHG_TO);
432 if (status1 & WM8350_CHG_END_EINT)
433 wm8350_irq_call_handler(wm8350, WM8350_IRQ_CHG_END);
434 if (status1 & WM8350_CHG_START_EINT)
435 wm8350_irq_call_handler(wm8350, WM8350_IRQ_CHG_START);
436 if (status1 & WM8350_CHG_FAST_RDY_EINT)
437 wm8350_irq_call_handler(wm8350,
438 WM8350_IRQ_CHG_FAST_RDY);
439 if (status1 & WM8350_CHG_VBATT_LT_3P9_EINT)
440 wm8350_irq_call_handler(wm8350,
441 WM8350_IRQ_CHG_VBATT_LT_3P9);
442 if (status1 & WM8350_CHG_VBATT_LT_3P1_EINT)
443 wm8350_irq_call_handler(wm8350,
444 WM8350_IRQ_CHG_VBATT_LT_3P1);
445 if (status1 & WM8350_CHG_VBATT_LT_2P85_EINT)
446 wm8350_irq_call_handler(wm8350,
447 WM8350_IRQ_CHG_VBATT_LT_2P85);
448 if (status1 & WM8350_RTC_ALM_EINT)
449 wm8350_irq_call_handler(wm8350, WM8350_IRQ_RTC_ALM);
450 if (status1 & WM8350_RTC_SEC_EINT)
451 wm8350_irq_call_handler(wm8350, WM8350_IRQ_RTC_SEC);
452 if (status1 & WM8350_RTC_PER_EINT)
453 wm8350_irq_call_handler(wm8350, WM8350_IRQ_RTC_PER);
454 }
455
456 /* current sink, system, aux adc */
457 if (status2) {
458 if (status2 & WM8350_CS1_EINT)
459 wm8350_irq_call_handler(wm8350, WM8350_IRQ_CS1);
460 if (status2 & WM8350_CS2_EINT)
461 wm8350_irq_call_handler(wm8350, WM8350_IRQ_CS2);
462
463 if (status2 & WM8350_SYS_HYST_COMP_FAIL_EINT)
464 wm8350_irq_call_handler(wm8350,
465 WM8350_IRQ_SYS_HYST_COMP_FAIL);
466 if (status2 & WM8350_SYS_CHIP_GT115_EINT)
467 wm8350_irq_call_handler(wm8350,
468 WM8350_IRQ_SYS_CHIP_GT115);
469 if (status2 & WM8350_SYS_CHIP_GT140_EINT)
470 wm8350_irq_call_handler(wm8350,
471 WM8350_IRQ_SYS_CHIP_GT140);
472 if (status2 & WM8350_SYS_WDOG_TO_EINT)
473 wm8350_irq_call_handler(wm8350,
474 WM8350_IRQ_SYS_WDOG_TO);
475
476 if (status2 & WM8350_AUXADC_DATARDY_EINT)
477 wm8350_irq_call_handler(wm8350,
478 WM8350_IRQ_AUXADC_DATARDY);
479 if (status2 & WM8350_AUXADC_DCOMP4_EINT)
480 wm8350_irq_call_handler(wm8350,
481 WM8350_IRQ_AUXADC_DCOMP4);
482 if (status2 & WM8350_AUXADC_DCOMP3_EINT)
483 wm8350_irq_call_handler(wm8350,
484 WM8350_IRQ_AUXADC_DCOMP3);
485 if (status2 & WM8350_AUXADC_DCOMP2_EINT)
486 wm8350_irq_call_handler(wm8350,
487 WM8350_IRQ_AUXADC_DCOMP2);
488 if (status2 & WM8350_AUXADC_DCOMP1_EINT)
489 wm8350_irq_call_handler(wm8350,
490 WM8350_IRQ_AUXADC_DCOMP1);
491
492 if (status2 & WM8350_USB_LIMIT_EINT)
493 wm8350_irq_call_handler(wm8350, WM8350_IRQ_USB_LIMIT);
494 }
495
496 /* wake, codec, ext */
497 if (comp) {
498 if (comp & WM8350_WKUP_OFF_STATE_EINT)
499 wm8350_irq_call_handler(wm8350,
500 WM8350_IRQ_WKUP_OFF_STATE);
501 if (comp & WM8350_WKUP_HIB_STATE_EINT)
502 wm8350_irq_call_handler(wm8350,
503 WM8350_IRQ_WKUP_HIB_STATE);
504 if (comp & WM8350_WKUP_CONV_FAULT_EINT)
505 wm8350_irq_call_handler(wm8350,
506 WM8350_IRQ_WKUP_CONV_FAULT);
507 if (comp & WM8350_WKUP_WDOG_RST_EINT)
508 wm8350_irq_call_handler(wm8350,
509 WM8350_IRQ_WKUP_WDOG_RST);
510 if (comp & WM8350_WKUP_GP_PWR_ON_EINT)
511 wm8350_irq_call_handler(wm8350,
512 WM8350_IRQ_WKUP_GP_PWR_ON);
513 if (comp & WM8350_WKUP_ONKEY_EINT)
514 wm8350_irq_call_handler(wm8350, WM8350_IRQ_WKUP_ONKEY);
515 if (comp & WM8350_WKUP_GP_WAKEUP_EINT)
516 wm8350_irq_call_handler(wm8350,
517 WM8350_IRQ_WKUP_GP_WAKEUP);
518
519 if (comp & WM8350_CODEC_JCK_DET_L_EINT)
520 wm8350_irq_call_handler(wm8350,
521 WM8350_IRQ_CODEC_JCK_DET_L);
522 if (comp & WM8350_CODEC_JCK_DET_R_EINT)
523 wm8350_irq_call_handler(wm8350,
524 WM8350_IRQ_CODEC_JCK_DET_R);
525 if (comp & WM8350_CODEC_MICSCD_EINT)
526 wm8350_irq_call_handler(wm8350,
527 WM8350_IRQ_CODEC_MICSCD);
528 if (comp & WM8350_CODEC_MICD_EINT)
529 wm8350_irq_call_handler(wm8350, WM8350_IRQ_CODEC_MICD);
530
531 if (comp & WM8350_EXT_USB_FB_EINT)
532 wm8350_irq_call_handler(wm8350, WM8350_IRQ_EXT_USB_FB);
533 if (comp & WM8350_EXT_WALL_FB_EINT)
534 wm8350_irq_call_handler(wm8350,
535 WM8350_IRQ_EXT_WALL_FB);
536 if (comp & WM8350_EXT_BAT_FB_EINT)
537 wm8350_irq_call_handler(wm8350, WM8350_IRQ_EXT_BAT_FB);
538 }
539
540 if (level_one & WM8350_GP_INT) {
541 int i;
542 u16 gpio;
543
544 gpio = wm8350_reg_read(wm8350, WM8350_GPIO_INT_STATUS);
545 gpio &= ~wm8350_reg_read(wm8350,
546 WM8350_GPIO_INT_STATUS_MASK);
547
548 for (i = 0; i < 12; i++) {
549 if (gpio & (1 << i))
550 wm8350_irq_call_handler(wm8350,
551 WM8350_IRQ_GPIO(i));
552 }
553 }
554
555 return IRQ_HANDLED;
556}
557
558int wm8350_register_irq(struct wm8350 *wm8350, int irq,
559 void (*handler) (struct wm8350 *, int, void *),
560 void *data)
561{
562 if (irq < 0 || irq > WM8350_NUM_IRQ || !handler)
563 return -EINVAL;
564
565 if (wm8350->irq[irq].handler)
566 return -EBUSY;
567
568 mutex_lock(&wm8350->irq_mutex);
569 wm8350->irq[irq].handler = handler;
570 wm8350->irq[irq].data = data;
571 mutex_unlock(&wm8350->irq_mutex);
572
573 return 0;
574}
575EXPORT_SYMBOL_GPL(wm8350_register_irq);
576
577int wm8350_free_irq(struct wm8350 *wm8350, int irq)
578{
579 if (irq < 0 || irq > WM8350_NUM_IRQ)
580 return -EINVAL;
581
582 mutex_lock(&wm8350->irq_mutex);
583 wm8350->irq[irq].handler = NULL;
584 mutex_unlock(&wm8350->irq_mutex);
585 return 0;
586}
587EXPORT_SYMBOL_GPL(wm8350_free_irq);
588
589int wm8350_mask_irq(struct wm8350 *wm8350, int irq)
590{
591 switch (irq) {
592 case WM8350_IRQ_CHG_BAT_HOT:
593 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
594 WM8350_IM_CHG_BAT_HOT_EINT);
595 case WM8350_IRQ_CHG_BAT_COLD:
596 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
597 WM8350_IM_CHG_BAT_COLD_EINT);
598 case WM8350_IRQ_CHG_BAT_FAIL:
599 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
600 WM8350_IM_CHG_BAT_FAIL_EINT);
601 case WM8350_IRQ_CHG_TO:
602 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
603 WM8350_IM_CHG_TO_EINT);
604 case WM8350_IRQ_CHG_END:
605 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
606 WM8350_IM_CHG_END_EINT);
607 case WM8350_IRQ_CHG_START:
608 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
609 WM8350_IM_CHG_START_EINT);
610 case WM8350_IRQ_CHG_FAST_RDY:
611 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
612 WM8350_IM_CHG_FAST_RDY_EINT);
613 case WM8350_IRQ_RTC_PER:
614 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
615 WM8350_IM_RTC_PER_EINT);
616 case WM8350_IRQ_RTC_SEC:
617 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
618 WM8350_IM_RTC_SEC_EINT);
619 case WM8350_IRQ_RTC_ALM:
620 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
621 WM8350_IM_RTC_ALM_EINT);
622 case WM8350_IRQ_CHG_VBATT_LT_3P9:
623 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
624 WM8350_IM_CHG_VBATT_LT_3P9_EINT);
625 case WM8350_IRQ_CHG_VBATT_LT_3P1:
626 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
627 WM8350_IM_CHG_VBATT_LT_3P1_EINT);
628 case WM8350_IRQ_CHG_VBATT_LT_2P85:
629 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
630 WM8350_IM_CHG_VBATT_LT_2P85_EINT);
631 case WM8350_IRQ_CS1:
632 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
633 WM8350_IM_CS1_EINT);
634 case WM8350_IRQ_CS2:
635 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
636 WM8350_IM_CS2_EINT);
637 case WM8350_IRQ_USB_LIMIT:
638 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
639 WM8350_IM_USB_LIMIT_EINT);
640 case WM8350_IRQ_AUXADC_DATARDY:
641 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
642 WM8350_IM_AUXADC_DATARDY_EINT);
643 case WM8350_IRQ_AUXADC_DCOMP4:
644 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
645 WM8350_IM_AUXADC_DCOMP4_EINT);
646 case WM8350_IRQ_AUXADC_DCOMP3:
647 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
648 WM8350_IM_AUXADC_DCOMP3_EINT);
649 case WM8350_IRQ_AUXADC_DCOMP2:
650 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
651 WM8350_IM_AUXADC_DCOMP2_EINT);
652 case WM8350_IRQ_AUXADC_DCOMP1:
653 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
654 WM8350_IM_AUXADC_DCOMP1_EINT);
655 case WM8350_IRQ_SYS_HYST_COMP_FAIL:
656 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
657 WM8350_IM_SYS_HYST_COMP_FAIL_EINT);
658 case WM8350_IRQ_SYS_CHIP_GT115:
659 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
660 WM8350_IM_SYS_CHIP_GT115_EINT);
661 case WM8350_IRQ_SYS_CHIP_GT140:
662 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
663 WM8350_IM_SYS_CHIP_GT140_EINT);
664 case WM8350_IRQ_SYS_WDOG_TO:
665 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
666 WM8350_IM_SYS_WDOG_TO_EINT);
667 case WM8350_IRQ_UV_LDO4:
668 return wm8350_set_bits(wm8350,
669 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
670 WM8350_IM_UV_LDO4_EINT);
671 case WM8350_IRQ_UV_LDO3:
672 return wm8350_set_bits(wm8350,
673 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
674 WM8350_IM_UV_LDO3_EINT);
675 case WM8350_IRQ_UV_LDO2:
676 return wm8350_set_bits(wm8350,
677 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
678 WM8350_IM_UV_LDO2_EINT);
679 case WM8350_IRQ_UV_LDO1:
680 return wm8350_set_bits(wm8350,
681 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
682 WM8350_IM_UV_LDO1_EINT);
683 case WM8350_IRQ_UV_DC6:
684 return wm8350_set_bits(wm8350,
685 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
686 WM8350_IM_UV_DC6_EINT);
687 case WM8350_IRQ_UV_DC5:
688 return wm8350_set_bits(wm8350,
689 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
690 WM8350_IM_UV_DC5_EINT);
691 case WM8350_IRQ_UV_DC4:
692 return wm8350_set_bits(wm8350,
693 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
694 WM8350_IM_UV_DC4_EINT);
695 case WM8350_IRQ_UV_DC3:
696 return wm8350_set_bits(wm8350,
697 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
698 WM8350_IM_UV_DC3_EINT);
699 case WM8350_IRQ_UV_DC2:
700 return wm8350_set_bits(wm8350,
701 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
702 WM8350_IM_UV_DC2_EINT);
703 case WM8350_IRQ_UV_DC1:
704 return wm8350_set_bits(wm8350,
705 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
706 WM8350_IM_UV_DC1_EINT);
707 case WM8350_IRQ_OC_LS:
708 return wm8350_set_bits(wm8350,
709 WM8350_OVER_CURRENT_INT_STATUS_MASK,
710 WM8350_IM_OC_LS_EINT);
711 case WM8350_IRQ_EXT_USB_FB:
712 return wm8350_set_bits(wm8350,
713 WM8350_COMPARATOR_INT_STATUS_MASK,
714 WM8350_IM_EXT_USB_FB_EINT);
715 case WM8350_IRQ_EXT_WALL_FB:
716 return wm8350_set_bits(wm8350,
717 WM8350_COMPARATOR_INT_STATUS_MASK,
718 WM8350_IM_EXT_WALL_FB_EINT);
719 case WM8350_IRQ_EXT_BAT_FB:
720 return wm8350_set_bits(wm8350,
721 WM8350_COMPARATOR_INT_STATUS_MASK,
722 WM8350_IM_EXT_BAT_FB_EINT);
723 case WM8350_IRQ_CODEC_JCK_DET_L:
724 return wm8350_set_bits(wm8350,
725 WM8350_COMPARATOR_INT_STATUS_MASK,
726 WM8350_IM_CODEC_JCK_DET_L_EINT);
727 case WM8350_IRQ_CODEC_JCK_DET_R:
728 return wm8350_set_bits(wm8350,
729 WM8350_COMPARATOR_INT_STATUS_MASK,
730 WM8350_IM_CODEC_JCK_DET_R_EINT);
731 case WM8350_IRQ_CODEC_MICSCD:
732 return wm8350_set_bits(wm8350,
733 WM8350_COMPARATOR_INT_STATUS_MASK,
734 WM8350_IM_CODEC_MICSCD_EINT);
735 case WM8350_IRQ_CODEC_MICD:
736 return wm8350_set_bits(wm8350,
737 WM8350_COMPARATOR_INT_STATUS_MASK,
738 WM8350_IM_CODEC_MICD_EINT);
739 case WM8350_IRQ_WKUP_OFF_STATE:
740 return wm8350_set_bits(wm8350,
741 WM8350_COMPARATOR_INT_STATUS_MASK,
742 WM8350_IM_WKUP_OFF_STATE_EINT);
743 case WM8350_IRQ_WKUP_HIB_STATE:
744 return wm8350_set_bits(wm8350,
745 WM8350_COMPARATOR_INT_STATUS_MASK,
746 WM8350_IM_WKUP_HIB_STATE_EINT);
747 case WM8350_IRQ_WKUP_CONV_FAULT:
748 return wm8350_set_bits(wm8350,
749 WM8350_COMPARATOR_INT_STATUS_MASK,
750 WM8350_IM_WKUP_CONV_FAULT_EINT);
751 case WM8350_IRQ_WKUP_WDOG_RST:
752 return wm8350_set_bits(wm8350,
753 WM8350_COMPARATOR_INT_STATUS_MASK,
754 WM8350_IM_WKUP_OFF_STATE_EINT);
755 case WM8350_IRQ_WKUP_GP_PWR_ON:
756 return wm8350_set_bits(wm8350,
757 WM8350_COMPARATOR_INT_STATUS_MASK,
758 WM8350_IM_WKUP_GP_PWR_ON_EINT);
759 case WM8350_IRQ_WKUP_ONKEY:
760 return wm8350_set_bits(wm8350,
761 WM8350_COMPARATOR_INT_STATUS_MASK,
762 WM8350_IM_WKUP_ONKEY_EINT);
763 case WM8350_IRQ_WKUP_GP_WAKEUP:
764 return wm8350_set_bits(wm8350,
765 WM8350_COMPARATOR_INT_STATUS_MASK,
766 WM8350_IM_WKUP_GP_WAKEUP_EINT);
767 case WM8350_IRQ_GPIO(0):
768 return wm8350_set_bits(wm8350,
769 WM8350_GPIO_INT_STATUS_MASK,
770 WM8350_IM_GP0_EINT);
771 case WM8350_IRQ_GPIO(1):
772 return wm8350_set_bits(wm8350,
773 WM8350_GPIO_INT_STATUS_MASK,
774 WM8350_IM_GP1_EINT);
775 case WM8350_IRQ_GPIO(2):
776 return wm8350_set_bits(wm8350,
777 WM8350_GPIO_INT_STATUS_MASK,
778 WM8350_IM_GP2_EINT);
779 case WM8350_IRQ_GPIO(3):
780 return wm8350_set_bits(wm8350,
781 WM8350_GPIO_INT_STATUS_MASK,
782 WM8350_IM_GP3_EINT);
783 case WM8350_IRQ_GPIO(4):
784 return wm8350_set_bits(wm8350,
785 WM8350_GPIO_INT_STATUS_MASK,
786 WM8350_IM_GP4_EINT);
787 case WM8350_IRQ_GPIO(5):
788 return wm8350_set_bits(wm8350,
789 WM8350_GPIO_INT_STATUS_MASK,
790 WM8350_IM_GP5_EINT);
791 case WM8350_IRQ_GPIO(6):
792 return wm8350_set_bits(wm8350,
793 WM8350_GPIO_INT_STATUS_MASK,
794 WM8350_IM_GP6_EINT);
795 case WM8350_IRQ_GPIO(7):
796 return wm8350_set_bits(wm8350,
797 WM8350_GPIO_INT_STATUS_MASK,
798 WM8350_IM_GP7_EINT);
799 case WM8350_IRQ_GPIO(8):
800 return wm8350_set_bits(wm8350,
801 WM8350_GPIO_INT_STATUS_MASK,
802 WM8350_IM_GP8_EINT);
803 case WM8350_IRQ_GPIO(9):
804 return wm8350_set_bits(wm8350,
805 WM8350_GPIO_INT_STATUS_MASK,
806 WM8350_IM_GP9_EINT);
807 case WM8350_IRQ_GPIO(10):
808 return wm8350_set_bits(wm8350,
809 WM8350_GPIO_INT_STATUS_MASK,
810 WM8350_IM_GP10_EINT);
811 case WM8350_IRQ_GPIO(11):
812 return wm8350_set_bits(wm8350,
813 WM8350_GPIO_INT_STATUS_MASK,
814 WM8350_IM_GP11_EINT);
815 case WM8350_IRQ_GPIO(12):
816 return wm8350_set_bits(wm8350,
817 WM8350_GPIO_INT_STATUS_MASK,
818 WM8350_IM_GP12_EINT);
819 default:
820 dev_warn(wm8350->dev, "Attempting to mask unknown IRQ %d\n",
821 irq);
822 return -EINVAL;
823 }
824 return 0;
825}
826EXPORT_SYMBOL_GPL(wm8350_mask_irq);
827
828int wm8350_unmask_irq(struct wm8350 *wm8350, int irq)
829{
830 switch (irq) {
831 case WM8350_IRQ_CHG_BAT_HOT:
832 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
833 WM8350_IM_CHG_BAT_HOT_EINT);
834 case WM8350_IRQ_CHG_BAT_COLD:
835 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
836 WM8350_IM_CHG_BAT_COLD_EINT);
837 case WM8350_IRQ_CHG_BAT_FAIL:
838 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
839 WM8350_IM_CHG_BAT_FAIL_EINT);
840 case WM8350_IRQ_CHG_TO:
841 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
842 WM8350_IM_CHG_TO_EINT);
843 case WM8350_IRQ_CHG_END:
844 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
845 WM8350_IM_CHG_END_EINT);
846 case WM8350_IRQ_CHG_START:
847 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
848 WM8350_IM_CHG_START_EINT);
849 case WM8350_IRQ_CHG_FAST_RDY:
850 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
851 WM8350_IM_CHG_FAST_RDY_EINT);
852 case WM8350_IRQ_RTC_PER:
853 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
854 WM8350_IM_RTC_PER_EINT);
855 case WM8350_IRQ_RTC_SEC:
856 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
857 WM8350_IM_RTC_SEC_EINT);
858 case WM8350_IRQ_RTC_ALM:
859 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
860 WM8350_IM_RTC_ALM_EINT);
861 case WM8350_IRQ_CHG_VBATT_LT_3P9:
862 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
863 WM8350_IM_CHG_VBATT_LT_3P9_EINT);
864 case WM8350_IRQ_CHG_VBATT_LT_3P1:
865 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
866 WM8350_IM_CHG_VBATT_LT_3P1_EINT);
867 case WM8350_IRQ_CHG_VBATT_LT_2P85:
868 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
869 WM8350_IM_CHG_VBATT_LT_2P85_EINT);
870 case WM8350_IRQ_CS1:
871 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
872 WM8350_IM_CS1_EINT);
873 case WM8350_IRQ_CS2:
874 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
875 WM8350_IM_CS2_EINT);
876 case WM8350_IRQ_USB_LIMIT:
877 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
878 WM8350_IM_USB_LIMIT_EINT);
879 case WM8350_IRQ_AUXADC_DATARDY:
880 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
881 WM8350_IM_AUXADC_DATARDY_EINT);
882 case WM8350_IRQ_AUXADC_DCOMP4:
883 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
884 WM8350_IM_AUXADC_DCOMP4_EINT);
885 case WM8350_IRQ_AUXADC_DCOMP3:
886 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
887 WM8350_IM_AUXADC_DCOMP3_EINT);
888 case WM8350_IRQ_AUXADC_DCOMP2:
889 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
890 WM8350_IM_AUXADC_DCOMP2_EINT);
891 case WM8350_IRQ_AUXADC_DCOMP1:
892 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
893 WM8350_IM_AUXADC_DCOMP1_EINT);
894 case WM8350_IRQ_SYS_HYST_COMP_FAIL:
895 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
896 WM8350_IM_SYS_HYST_COMP_FAIL_EINT);
897 case WM8350_IRQ_SYS_CHIP_GT115:
898 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
899 WM8350_IM_SYS_CHIP_GT115_EINT);
900 case WM8350_IRQ_SYS_CHIP_GT140:
901 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
902 WM8350_IM_SYS_CHIP_GT140_EINT);
903 case WM8350_IRQ_SYS_WDOG_TO:
904 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
905 WM8350_IM_SYS_WDOG_TO_EINT);
906 case WM8350_IRQ_UV_LDO4:
907 return wm8350_clear_bits(wm8350,
908 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
909 WM8350_IM_UV_LDO4_EINT);
910 case WM8350_IRQ_UV_LDO3:
911 return wm8350_clear_bits(wm8350,
912 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
913 WM8350_IM_UV_LDO3_EINT);
914 case WM8350_IRQ_UV_LDO2:
915 return wm8350_clear_bits(wm8350,
916 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
917 WM8350_IM_UV_LDO2_EINT);
918 case WM8350_IRQ_UV_LDO1:
919 return wm8350_clear_bits(wm8350,
920 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
921 WM8350_IM_UV_LDO1_EINT);
922 case WM8350_IRQ_UV_DC6:
923 return wm8350_clear_bits(wm8350,
924 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
925 WM8350_IM_UV_DC6_EINT);
926 case WM8350_IRQ_UV_DC5:
927 return wm8350_clear_bits(wm8350,
928 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
929 WM8350_IM_UV_DC5_EINT);
930 case WM8350_IRQ_UV_DC4:
931 return wm8350_clear_bits(wm8350,
932 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
933 WM8350_IM_UV_DC4_EINT);
934 case WM8350_IRQ_UV_DC3:
935 return wm8350_clear_bits(wm8350,
936 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
937 WM8350_IM_UV_DC3_EINT);
938 case WM8350_IRQ_UV_DC2:
939 return wm8350_clear_bits(wm8350,
940 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
941 WM8350_IM_UV_DC2_EINT);
942 case WM8350_IRQ_UV_DC1:
943 return wm8350_clear_bits(wm8350,
944 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
945 WM8350_IM_UV_DC1_EINT);
946 case WM8350_IRQ_OC_LS:
947 return wm8350_clear_bits(wm8350,
948 WM8350_OVER_CURRENT_INT_STATUS_MASK,
949 WM8350_IM_OC_LS_EINT);
950 case WM8350_IRQ_EXT_USB_FB:
951 return wm8350_clear_bits(wm8350,
952 WM8350_COMPARATOR_INT_STATUS_MASK,
953 WM8350_IM_EXT_USB_FB_EINT);
954 case WM8350_IRQ_EXT_WALL_FB:
955 return wm8350_clear_bits(wm8350,
956 WM8350_COMPARATOR_INT_STATUS_MASK,
957 WM8350_IM_EXT_WALL_FB_EINT);
958 case WM8350_IRQ_EXT_BAT_FB:
959 return wm8350_clear_bits(wm8350,
960 WM8350_COMPARATOR_INT_STATUS_MASK,
961 WM8350_IM_EXT_BAT_FB_EINT);
962 case WM8350_IRQ_CODEC_JCK_DET_L:
963 return wm8350_clear_bits(wm8350,
964 WM8350_COMPARATOR_INT_STATUS_MASK,
965 WM8350_IM_CODEC_JCK_DET_L_EINT);
966 case WM8350_IRQ_CODEC_JCK_DET_R:
967 return wm8350_clear_bits(wm8350,
968 WM8350_COMPARATOR_INT_STATUS_MASK,
969 WM8350_IM_CODEC_JCK_DET_R_EINT);
970 case WM8350_IRQ_CODEC_MICSCD:
971 return wm8350_clear_bits(wm8350,
972 WM8350_COMPARATOR_INT_STATUS_MASK,
973 WM8350_IM_CODEC_MICSCD_EINT);
974 case WM8350_IRQ_CODEC_MICD:
975 return wm8350_clear_bits(wm8350,
976 WM8350_COMPARATOR_INT_STATUS_MASK,
977 WM8350_IM_CODEC_MICD_EINT);
978 case WM8350_IRQ_WKUP_OFF_STATE:
979 return wm8350_clear_bits(wm8350,
980 WM8350_COMPARATOR_INT_STATUS_MASK,
981 WM8350_IM_WKUP_OFF_STATE_EINT);
982 case WM8350_IRQ_WKUP_HIB_STATE:
983 return wm8350_clear_bits(wm8350,
984 WM8350_COMPARATOR_INT_STATUS_MASK,
985 WM8350_IM_WKUP_HIB_STATE_EINT);
986 case WM8350_IRQ_WKUP_CONV_FAULT:
987 return wm8350_clear_bits(wm8350,
988 WM8350_COMPARATOR_INT_STATUS_MASK,
989 WM8350_IM_WKUP_CONV_FAULT_EINT);
990 case WM8350_IRQ_WKUP_WDOG_RST:
991 return wm8350_clear_bits(wm8350,
992 WM8350_COMPARATOR_INT_STATUS_MASK,
993 WM8350_IM_WKUP_OFF_STATE_EINT);
994 case WM8350_IRQ_WKUP_GP_PWR_ON:
995 return wm8350_clear_bits(wm8350,
996 WM8350_COMPARATOR_INT_STATUS_MASK,
997 WM8350_IM_WKUP_GP_PWR_ON_EINT);
998 case WM8350_IRQ_WKUP_ONKEY:
999 return wm8350_clear_bits(wm8350,
1000 WM8350_COMPARATOR_INT_STATUS_MASK,
1001 WM8350_IM_WKUP_ONKEY_EINT);
1002 case WM8350_IRQ_WKUP_GP_WAKEUP:
1003 return wm8350_clear_bits(wm8350,
1004 WM8350_COMPARATOR_INT_STATUS_MASK,
1005 WM8350_IM_WKUP_GP_WAKEUP_EINT);
1006 case WM8350_IRQ_GPIO(0):
1007 return wm8350_clear_bits(wm8350,
1008 WM8350_GPIO_INT_STATUS_MASK,
1009 WM8350_IM_GP0_EINT);
1010 case WM8350_IRQ_GPIO(1):
1011 return wm8350_clear_bits(wm8350,
1012 WM8350_GPIO_INT_STATUS_MASK,
1013 WM8350_IM_GP1_EINT);
1014 case WM8350_IRQ_GPIO(2):
1015 return wm8350_clear_bits(wm8350,
1016 WM8350_GPIO_INT_STATUS_MASK,
1017 WM8350_IM_GP2_EINT);
1018 case WM8350_IRQ_GPIO(3):
1019 return wm8350_clear_bits(wm8350,
1020 WM8350_GPIO_INT_STATUS_MASK,
1021 WM8350_IM_GP3_EINT);
1022 case WM8350_IRQ_GPIO(4):
1023 return wm8350_clear_bits(wm8350,
1024 WM8350_GPIO_INT_STATUS_MASK,
1025 WM8350_IM_GP4_EINT);
1026 case WM8350_IRQ_GPIO(5):
1027 return wm8350_clear_bits(wm8350,
1028 WM8350_GPIO_INT_STATUS_MASK,
1029 WM8350_IM_GP5_EINT);
1030 case WM8350_IRQ_GPIO(6):
1031 return wm8350_clear_bits(wm8350,
1032 WM8350_GPIO_INT_STATUS_MASK,
1033 WM8350_IM_GP6_EINT);
1034 case WM8350_IRQ_GPIO(7):
1035 return wm8350_clear_bits(wm8350,
1036 WM8350_GPIO_INT_STATUS_MASK,
1037 WM8350_IM_GP7_EINT);
1038 case WM8350_IRQ_GPIO(8):
1039 return wm8350_clear_bits(wm8350,
1040 WM8350_GPIO_INT_STATUS_MASK,
1041 WM8350_IM_GP8_EINT);
1042 case WM8350_IRQ_GPIO(9):
1043 return wm8350_clear_bits(wm8350,
1044 WM8350_GPIO_INT_STATUS_MASK,
1045 WM8350_IM_GP9_EINT);
1046 case WM8350_IRQ_GPIO(10):
1047 return wm8350_clear_bits(wm8350,
1048 WM8350_GPIO_INT_STATUS_MASK,
1049 WM8350_IM_GP10_EINT);
1050 case WM8350_IRQ_GPIO(11):
1051 return wm8350_clear_bits(wm8350,
1052 WM8350_GPIO_INT_STATUS_MASK,
1053 WM8350_IM_GP11_EINT);
1054 case WM8350_IRQ_GPIO(12):
1055 return wm8350_clear_bits(wm8350,
1056 WM8350_GPIO_INT_STATUS_MASK,
1057 WM8350_IM_GP12_EINT);
1058 default:
1059 dev_warn(wm8350->dev, "Attempting to unmask unknown IRQ %d\n",
1060 irq);
1061 return -EINVAL;
1062 }
1063 return 0;
1064}
1065EXPORT_SYMBOL_GPL(wm8350_unmask_irq);
1066
1067int wm8350_read_auxadc(struct wm8350 *wm8350, int channel, int scale, int vref) 340int wm8350_read_auxadc(struct wm8350 *wm8350, int channel, int scale, int vref)
1068{ 341{
1069 u16 reg, result = 0; 342 u16 reg, result = 0;
@@ -1264,7 +537,7 @@ static void wm8350_client_dev_register(struct wm8350 *wm8350,
1264 int ret; 537 int ret;
1265 538
1266 *pdev = platform_device_alloc(name, -1); 539 *pdev = platform_device_alloc(name, -1);
1267 if (pdev == NULL) { 540 if (*pdev == NULL) {
1268 dev_err(wm8350->dev, "Failed to allocate %s\n", name); 541 dev_err(wm8350->dev, "Failed to allocate %s\n", name);
1269 return; 542 return;
1270 } 543 }
@@ -1409,49 +682,18 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
1409 return ret; 682 return ret;
1410 } 683 }
1411 684
1412 wm8350_reg_write(wm8350, WM8350_SYSTEM_INTERRUPTS_MASK, 0xFFFF);
1413 wm8350_reg_write(wm8350, WM8350_INT_STATUS_1_MASK, 0xFFFF);
1414 wm8350_reg_write(wm8350, WM8350_INT_STATUS_2_MASK, 0xFFFF);
1415 wm8350_reg_write(wm8350, WM8350_UNDER_VOLTAGE_INT_STATUS_MASK, 0xFFFF);
1416 wm8350_reg_write(wm8350, WM8350_GPIO_INT_STATUS_MASK, 0xFFFF);
1417 wm8350_reg_write(wm8350, WM8350_COMPARATOR_INT_STATUS_MASK, 0xFFFF);
1418
1419 mutex_init(&wm8350->auxadc_mutex); 685 mutex_init(&wm8350->auxadc_mutex);
1420 mutex_init(&wm8350->irq_mutex);
1421 if (irq) {
1422 int flags = IRQF_ONESHOT;
1423
1424 if (pdata && pdata->irq_high) {
1425 flags |= IRQF_TRIGGER_HIGH;
1426
1427 wm8350_set_bits(wm8350, WM8350_SYSTEM_CONTROL_1,
1428 WM8350_IRQ_POL);
1429 } else {
1430 flags |= IRQF_TRIGGER_LOW;
1431
1432 wm8350_clear_bits(wm8350, WM8350_SYSTEM_CONTROL_1,
1433 WM8350_IRQ_POL);
1434 }
1435 686
1436 ret = request_threaded_irq(irq, NULL, wm8350_irq, flags, 687 ret = wm8350_irq_init(wm8350, irq, pdata);
1437 "wm8350", wm8350); 688 if (ret < 0)
1438 if (ret != 0) {
1439 dev_err(wm8350->dev, "Failed to request IRQ: %d\n",
1440 ret);
1441 goto err;
1442 }
1443 } else {
1444 dev_err(wm8350->dev, "No IRQ configured\n");
1445 goto err; 689 goto err;
1446 }
1447 wm8350->chip_irq = irq;
1448 690
1449 if (pdata && pdata->init) { 691 if (pdata && pdata->init) {
1450 ret = pdata->init(wm8350); 692 ret = pdata->init(wm8350);
1451 if (ret != 0) { 693 if (ret != 0) {
1452 dev_err(wm8350->dev, "Platform init() failed: %d\n", 694 dev_err(wm8350->dev, "Platform init() failed: %d\n",
1453 ret); 695 ret);
1454 goto err; 696 goto err_irq;
1455 } 697 }
1456 } 698 }
1457 699
@@ -1470,6 +712,8 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
1470 712
1471 return 0; 713 return 0;
1472 714
715err_irq:
716 wm8350_irq_exit(wm8350);
1473err: 717err:
1474 kfree(wm8350->reg_cache); 718 kfree(wm8350->reg_cache);
1475 return ret; 719 return ret;
@@ -1493,7 +737,8 @@ void wm8350_device_exit(struct wm8350 *wm8350)
1493 platform_device_unregister(wm8350->gpio.pdev); 737 platform_device_unregister(wm8350->gpio.pdev);
1494 platform_device_unregister(wm8350->codec.pdev); 738 platform_device_unregister(wm8350->codec.pdev);
1495 739
1496 free_irq(wm8350->chip_irq, wm8350); 740 wm8350_irq_exit(wm8350);
741
1497 kfree(wm8350->reg_cache); 742 kfree(wm8350->reg_cache);
1498} 743}
1499EXPORT_SYMBOL_GPL(wm8350_device_exit); 744EXPORT_SYMBOL_GPL(wm8350_device_exit);
diff --git a/drivers/mfd/wm8350-irq.c b/drivers/mfd/wm8350-irq.c
new file mode 100644
index 000000000000..c8df547c4747
--- /dev/null
+++ b/drivers/mfd/wm8350-irq.c
@@ -0,0 +1,529 @@
1/*
2 * wm8350-irq.c -- IRQ support for Wolfson WM8350
3 *
4 * Copyright 2007, 2008, 2009 Wolfson Microelectronics PLC.
5 *
6 * Author: Liam Girdwood, Mark Brown
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */
14
15#include <linux/kernel.h>
16#include <linux/module.h>
17#include <linux/init.h>
18#include <linux/bug.h>
19#include <linux/device.h>
20#include <linux/interrupt.h>
21#include <linux/workqueue.h>
22
23#include <linux/mfd/wm8350/core.h>
24#include <linux/mfd/wm8350/audio.h>
25#include <linux/mfd/wm8350/comparator.h>
26#include <linux/mfd/wm8350/gpio.h>
27#include <linux/mfd/wm8350/pmic.h>
28#include <linux/mfd/wm8350/rtc.h>
29#include <linux/mfd/wm8350/supply.h>
30#include <linux/mfd/wm8350/wdt.h>
31
32#define WM8350_NUM_IRQ_REGS 7
33
34#define WM8350_INT_OFFSET_1 0
35#define WM8350_INT_OFFSET_2 1
36#define WM8350_POWER_UP_INT_OFFSET 2
37#define WM8350_UNDER_VOLTAGE_INT_OFFSET 3
38#define WM8350_OVER_CURRENT_INT_OFFSET 4
39#define WM8350_GPIO_INT_OFFSET 5
40#define WM8350_COMPARATOR_INT_OFFSET 6
41
42struct wm8350_irq_data {
43 int primary;
44 int reg;
45 int mask;
46 int primary_only;
47};
48
49static struct wm8350_irq_data wm8350_irqs[] = {
50 [WM8350_IRQ_OC_LS] = {
51 .primary = WM8350_OC_INT,
52 .reg = WM8350_OVER_CURRENT_INT_OFFSET,
53 .mask = WM8350_OC_LS_EINT,
54 .primary_only = 1,
55 },
56 [WM8350_IRQ_UV_DC1] = {
57 .primary = WM8350_UV_INT,
58 .reg = WM8350_UNDER_VOLTAGE_INT_OFFSET,
59 .mask = WM8350_UV_DC1_EINT,
60 },
61 [WM8350_IRQ_UV_DC2] = {
62 .primary = WM8350_UV_INT,
63 .reg = WM8350_UNDER_VOLTAGE_INT_OFFSET,
64 .mask = WM8350_UV_DC2_EINT,
65 },
66 [WM8350_IRQ_UV_DC3] = {
67 .primary = WM8350_UV_INT,
68 .reg = WM8350_UNDER_VOLTAGE_INT_OFFSET,
69 .mask = WM8350_UV_DC3_EINT,
70 },
71 [WM8350_IRQ_UV_DC4] = {
72 .primary = WM8350_UV_INT,
73 .reg = WM8350_UNDER_VOLTAGE_INT_OFFSET,
74 .mask = WM8350_UV_DC4_EINT,
75 },
76 [WM8350_IRQ_UV_DC5] = {
77 .primary = WM8350_UV_INT,
78 .reg = WM8350_UNDER_VOLTAGE_INT_OFFSET,
79 .mask = WM8350_UV_DC5_EINT,
80 },
81 [WM8350_IRQ_UV_DC6] = {
82 .primary = WM8350_UV_INT,
83 .reg = WM8350_UNDER_VOLTAGE_INT_OFFSET,
84 .mask = WM8350_UV_DC6_EINT,
85 },
86 [WM8350_IRQ_UV_LDO1] = {
87 .primary = WM8350_UV_INT,
88 .reg = WM8350_UNDER_VOLTAGE_INT_OFFSET,
89 .mask = WM8350_UV_LDO1_EINT,
90 },
91 [WM8350_IRQ_UV_LDO2] = {
92 .primary = WM8350_UV_INT,
93 .reg = WM8350_UNDER_VOLTAGE_INT_OFFSET,
94 .mask = WM8350_UV_LDO2_EINT,
95 },
96 [WM8350_IRQ_UV_LDO3] = {
97 .primary = WM8350_UV_INT,
98 .reg = WM8350_UNDER_VOLTAGE_INT_OFFSET,
99 .mask = WM8350_UV_LDO3_EINT,
100 },
101 [WM8350_IRQ_UV_LDO4] = {
102 .primary = WM8350_UV_INT,
103 .reg = WM8350_UNDER_VOLTAGE_INT_OFFSET,
104 .mask = WM8350_UV_LDO4_EINT,
105 },
106 [WM8350_IRQ_CHG_BAT_HOT] = {
107 .primary = WM8350_CHG_INT,
108 .reg = WM8350_INT_OFFSET_1,
109 .mask = WM8350_CHG_BAT_HOT_EINT,
110 },
111 [WM8350_IRQ_CHG_BAT_COLD] = {
112 .primary = WM8350_CHG_INT,
113 .reg = WM8350_INT_OFFSET_1,
114 .mask = WM8350_CHG_BAT_COLD_EINT,
115 },
116 [WM8350_IRQ_CHG_BAT_FAIL] = {
117 .primary = WM8350_CHG_INT,
118 .reg = WM8350_INT_OFFSET_1,
119 .mask = WM8350_CHG_BAT_FAIL_EINT,
120 },
121 [WM8350_IRQ_CHG_TO] = {
122 .primary = WM8350_CHG_INT,
123 .reg = WM8350_INT_OFFSET_1,
124 .mask = WM8350_CHG_TO_EINT,
125 },
126 [WM8350_IRQ_CHG_END] = {
127 .primary = WM8350_CHG_INT,
128 .reg = WM8350_INT_OFFSET_1,
129 .mask = WM8350_CHG_END_EINT,
130 },
131 [WM8350_IRQ_CHG_START] = {
132 .primary = WM8350_CHG_INT,
133 .reg = WM8350_INT_OFFSET_1,
134 .mask = WM8350_CHG_START_EINT,
135 },
136 [WM8350_IRQ_CHG_FAST_RDY] = {
137 .primary = WM8350_CHG_INT,
138 .reg = WM8350_INT_OFFSET_1,
139 .mask = WM8350_CHG_FAST_RDY_EINT,
140 },
141 [WM8350_IRQ_CHG_VBATT_LT_3P9] = {
142 .primary = WM8350_CHG_INT,
143 .reg = WM8350_INT_OFFSET_1,
144 .mask = WM8350_CHG_VBATT_LT_3P9_EINT,
145 },
146 [WM8350_IRQ_CHG_VBATT_LT_3P1] = {
147 .primary = WM8350_CHG_INT,
148 .reg = WM8350_INT_OFFSET_1,
149 .mask = WM8350_CHG_VBATT_LT_3P1_EINT,
150 },
151 [WM8350_IRQ_CHG_VBATT_LT_2P85] = {
152 .primary = WM8350_CHG_INT,
153 .reg = WM8350_INT_OFFSET_1,
154 .mask = WM8350_CHG_VBATT_LT_2P85_EINT,
155 },
156 [WM8350_IRQ_RTC_ALM] = {
157 .primary = WM8350_RTC_INT,
158 .reg = WM8350_INT_OFFSET_1,
159 .mask = WM8350_RTC_ALM_EINT,
160 },
161 [WM8350_IRQ_RTC_SEC] = {
162 .primary = WM8350_RTC_INT,
163 .reg = WM8350_INT_OFFSET_1,
164 .mask = WM8350_RTC_SEC_EINT,
165 },
166 [WM8350_IRQ_RTC_PER] = {
167 .primary = WM8350_RTC_INT,
168 .reg = WM8350_INT_OFFSET_1,
169 .mask = WM8350_RTC_PER_EINT,
170 },
171 [WM8350_IRQ_CS1] = {
172 .primary = WM8350_CS_INT,
173 .reg = WM8350_INT_OFFSET_2,
174 .mask = WM8350_CS1_EINT,
175 },
176 [WM8350_IRQ_CS2] = {
177 .primary = WM8350_CS_INT,
178 .reg = WM8350_INT_OFFSET_2,
179 .mask = WM8350_CS2_EINT,
180 },
181 [WM8350_IRQ_SYS_HYST_COMP_FAIL] = {
182 .primary = WM8350_SYS_INT,
183 .reg = WM8350_INT_OFFSET_2,
184 .mask = WM8350_SYS_HYST_COMP_FAIL_EINT,
185 },
186 [WM8350_IRQ_SYS_CHIP_GT115] = {
187 .primary = WM8350_SYS_INT,
188 .reg = WM8350_INT_OFFSET_2,
189 .mask = WM8350_SYS_CHIP_GT115_EINT,
190 },
191 [WM8350_IRQ_SYS_CHIP_GT140] = {
192 .primary = WM8350_SYS_INT,
193 .reg = WM8350_INT_OFFSET_2,
194 .mask = WM8350_SYS_CHIP_GT140_EINT,
195 },
196 [WM8350_IRQ_SYS_WDOG_TO] = {
197 .primary = WM8350_SYS_INT,
198 .reg = WM8350_INT_OFFSET_2,
199 .mask = WM8350_SYS_WDOG_TO_EINT,
200 },
201 [WM8350_IRQ_AUXADC_DATARDY] = {
202 .primary = WM8350_AUXADC_INT,
203 .reg = WM8350_INT_OFFSET_2,
204 .mask = WM8350_AUXADC_DATARDY_EINT,
205 },
206 [WM8350_IRQ_AUXADC_DCOMP4] = {
207 .primary = WM8350_AUXADC_INT,
208 .reg = WM8350_INT_OFFSET_2,
209 .mask = WM8350_AUXADC_DCOMP4_EINT,
210 },
211 [WM8350_IRQ_AUXADC_DCOMP3] = {
212 .primary = WM8350_AUXADC_INT,
213 .reg = WM8350_INT_OFFSET_2,
214 .mask = WM8350_AUXADC_DCOMP3_EINT,
215 },
216 [WM8350_IRQ_AUXADC_DCOMP2] = {
217 .primary = WM8350_AUXADC_INT,
218 .reg = WM8350_INT_OFFSET_2,
219 .mask = WM8350_AUXADC_DCOMP2_EINT,
220 },
221 [WM8350_IRQ_AUXADC_DCOMP1] = {
222 .primary = WM8350_AUXADC_INT,
223 .reg = WM8350_INT_OFFSET_2,
224 .mask = WM8350_AUXADC_DCOMP1_EINT,
225 },
226 [WM8350_IRQ_USB_LIMIT] = {
227 .primary = WM8350_USB_INT,
228 .reg = WM8350_INT_OFFSET_2,
229 .mask = WM8350_USB_LIMIT_EINT,
230 .primary_only = 1,
231 },
232 [WM8350_IRQ_WKUP_OFF_STATE] = {
233 .primary = WM8350_WKUP_INT,
234 .reg = WM8350_COMPARATOR_INT_OFFSET,
235 .mask = WM8350_WKUP_OFF_STATE_EINT,
236 },
237 [WM8350_IRQ_WKUP_HIB_STATE] = {
238 .primary = WM8350_WKUP_INT,
239 .reg = WM8350_COMPARATOR_INT_OFFSET,
240 .mask = WM8350_WKUP_HIB_STATE_EINT,
241 },
242 [WM8350_IRQ_WKUP_CONV_FAULT] = {
243 .primary = WM8350_WKUP_INT,
244 .reg = WM8350_COMPARATOR_INT_OFFSET,
245 .mask = WM8350_WKUP_CONV_FAULT_EINT,
246 },
247 [WM8350_IRQ_WKUP_WDOG_RST] = {
248 .primary = WM8350_WKUP_INT,
249 .reg = WM8350_COMPARATOR_INT_OFFSET,
250 .mask = WM8350_WKUP_WDOG_RST_EINT,
251 },
252 [WM8350_IRQ_WKUP_GP_PWR_ON] = {
253 .primary = WM8350_WKUP_INT,
254 .reg = WM8350_COMPARATOR_INT_OFFSET,
255 .mask = WM8350_WKUP_GP_PWR_ON_EINT,
256 },
257 [WM8350_IRQ_WKUP_ONKEY] = {
258 .primary = WM8350_WKUP_INT,
259 .reg = WM8350_COMPARATOR_INT_OFFSET,
260 .mask = WM8350_WKUP_ONKEY_EINT,
261 },
262 [WM8350_IRQ_WKUP_GP_WAKEUP] = {
263 .primary = WM8350_WKUP_INT,
264 .reg = WM8350_COMPARATOR_INT_OFFSET,
265 .mask = WM8350_WKUP_GP_WAKEUP_EINT,
266 },
267 [WM8350_IRQ_CODEC_JCK_DET_L] = {
268 .primary = WM8350_CODEC_INT,
269 .reg = WM8350_COMPARATOR_INT_OFFSET,
270 .mask = WM8350_CODEC_JCK_DET_L_EINT,
271 },
272 [WM8350_IRQ_CODEC_JCK_DET_R] = {
273 .primary = WM8350_CODEC_INT,
274 .reg = WM8350_COMPARATOR_INT_OFFSET,
275 .mask = WM8350_CODEC_JCK_DET_R_EINT,
276 },
277 [WM8350_IRQ_CODEC_MICSCD] = {
278 .primary = WM8350_CODEC_INT,
279 .reg = WM8350_COMPARATOR_INT_OFFSET,
280 .mask = WM8350_CODEC_MICSCD_EINT,
281 },
282 [WM8350_IRQ_CODEC_MICD] = {
283 .primary = WM8350_CODEC_INT,
284 .reg = WM8350_COMPARATOR_INT_OFFSET,
285 .mask = WM8350_CODEC_MICD_EINT,
286 },
287 [WM8350_IRQ_EXT_USB_FB] = {
288 .primary = WM8350_EXT_INT,
289 .reg = WM8350_COMPARATOR_INT_OFFSET,
290 .mask = WM8350_EXT_USB_FB_EINT,
291 },
292 [WM8350_IRQ_EXT_WALL_FB] = {
293 .primary = WM8350_EXT_INT,
294 .reg = WM8350_COMPARATOR_INT_OFFSET,
295 .mask = WM8350_EXT_WALL_FB_EINT,
296 },
297 [WM8350_IRQ_EXT_BAT_FB] = {
298 .primary = WM8350_EXT_INT,
299 .reg = WM8350_COMPARATOR_INT_OFFSET,
300 .mask = WM8350_EXT_BAT_FB_EINT,
301 },
302 [WM8350_IRQ_GPIO(0)] = {
303 .primary = WM8350_GP_INT,
304 .reg = WM8350_GPIO_INT_OFFSET,
305 .mask = WM8350_GP0_EINT,
306 },
307 [WM8350_IRQ_GPIO(1)] = {
308 .primary = WM8350_GP_INT,
309 .reg = WM8350_GPIO_INT_OFFSET,
310 .mask = WM8350_GP1_EINT,
311 },
312 [WM8350_IRQ_GPIO(2)] = {
313 .primary = WM8350_GP_INT,
314 .reg = WM8350_GPIO_INT_OFFSET,
315 .mask = WM8350_GP2_EINT,
316 },
317 [WM8350_IRQ_GPIO(3)] = {
318 .primary = WM8350_GP_INT,
319 .reg = WM8350_GPIO_INT_OFFSET,
320 .mask = WM8350_GP3_EINT,
321 },
322 [WM8350_IRQ_GPIO(4)] = {
323 .primary = WM8350_GP_INT,
324 .reg = WM8350_GPIO_INT_OFFSET,
325 .mask = WM8350_GP4_EINT,
326 },
327 [WM8350_IRQ_GPIO(5)] = {
328 .primary = WM8350_GP_INT,
329 .reg = WM8350_GPIO_INT_OFFSET,
330 .mask = WM8350_GP5_EINT,
331 },
332 [WM8350_IRQ_GPIO(6)] = {
333 .primary = WM8350_GP_INT,
334 .reg = WM8350_GPIO_INT_OFFSET,
335 .mask = WM8350_GP6_EINT,
336 },
337 [WM8350_IRQ_GPIO(7)] = {
338 .primary = WM8350_GP_INT,
339 .reg = WM8350_GPIO_INT_OFFSET,
340 .mask = WM8350_GP7_EINT,
341 },
342 [WM8350_IRQ_GPIO(8)] = {
343 .primary = WM8350_GP_INT,
344 .reg = WM8350_GPIO_INT_OFFSET,
345 .mask = WM8350_GP8_EINT,
346 },
347 [WM8350_IRQ_GPIO(9)] = {
348 .primary = WM8350_GP_INT,
349 .reg = WM8350_GPIO_INT_OFFSET,
350 .mask = WM8350_GP9_EINT,
351 },
352 [WM8350_IRQ_GPIO(10)] = {
353 .primary = WM8350_GP_INT,
354 .reg = WM8350_GPIO_INT_OFFSET,
355 .mask = WM8350_GP10_EINT,
356 },
357 [WM8350_IRQ_GPIO(11)] = {
358 .primary = WM8350_GP_INT,
359 .reg = WM8350_GPIO_INT_OFFSET,
360 .mask = WM8350_GP11_EINT,
361 },
362 [WM8350_IRQ_GPIO(12)] = {
363 .primary = WM8350_GP_INT,
364 .reg = WM8350_GPIO_INT_OFFSET,
365 .mask = WM8350_GP12_EINT,
366 },
367};
368
369static void wm8350_irq_call_handler(struct wm8350 *wm8350, int irq)
370{
371 mutex_lock(&wm8350->irq_mutex);
372
373 if (wm8350->irq[irq].handler)
374 wm8350->irq[irq].handler(irq, wm8350->irq[irq].data);
375 else {
376 dev_err(wm8350->dev, "irq %d nobody cared. now masked.\n",
377 irq);
378 wm8350_mask_irq(wm8350, irq);
379 }
380
381 mutex_unlock(&wm8350->irq_mutex);
382}
383
384/*
385 * This is a threaded IRQ handler so can access I2C/SPI. Since all
386 * interrupts are clear on read the IRQ line will be reasserted and
387 * the physical IRQ will be handled again if another interrupt is
388 * asserted while we run - in the normal course of events this is a
389 * rare occurrence so we save I2C/SPI reads.
390 */
391static irqreturn_t wm8350_irq(int irq, void *irq_data)
392{
393 struct wm8350 *wm8350 = irq_data;
394 u16 level_one;
395 u16 sub_reg[WM8350_NUM_IRQ_REGS];
396 int read_done[WM8350_NUM_IRQ_REGS];
397 struct wm8350_irq_data *data;
398 int i;
399
400 /* TODO: Use block reads to improve performance? */
401 level_one = wm8350_reg_read(wm8350, WM8350_SYSTEM_INTERRUPTS)
402 & ~wm8350_reg_read(wm8350, WM8350_SYSTEM_INTERRUPTS_MASK);
403
404 if (!level_one)
405 return IRQ_NONE;
406
407 memset(&read_done, 0, sizeof(read_done));
408
409 for (i = 0; i < ARRAY_SIZE(wm8350_irqs); i++) {
410 data = &wm8350_irqs[i];
411
412 if (!(level_one & data->primary))
413 continue;
414
415 if (!read_done[data->reg]) {
416 sub_reg[data->reg] =
417 wm8350_reg_read(wm8350, WM8350_INT_STATUS_1 +
418 data->reg);
419 sub_reg[data->reg] &=
420 ~wm8350_reg_read(wm8350,
421 WM8350_INT_STATUS_1_MASK +
422 data->reg);
423 read_done[data->reg] = 1;
424 }
425
426 if (sub_reg[data->reg] & data->mask)
427 wm8350_irq_call_handler(wm8350, i);
428 }
429
430 return IRQ_HANDLED;
431}
432
433int wm8350_register_irq(struct wm8350 *wm8350, int irq,
434 irq_handler_t handler, unsigned long flags,
435 const char *name, void *data)
436{
437 if (irq < 0 || irq > WM8350_NUM_IRQ || !handler)
438 return -EINVAL;
439
440 if (wm8350->irq[irq].handler)
441 return -EBUSY;
442
443 mutex_lock(&wm8350->irq_mutex);
444 wm8350->irq[irq].handler = handler;
445 wm8350->irq[irq].data = data;
446 mutex_unlock(&wm8350->irq_mutex);
447
448 wm8350_unmask_irq(wm8350, irq);
449
450 return 0;
451}
452EXPORT_SYMBOL_GPL(wm8350_register_irq);
453
454int wm8350_free_irq(struct wm8350 *wm8350, int irq)
455{
456 if (irq < 0 || irq > WM8350_NUM_IRQ)
457 return -EINVAL;
458
459 wm8350_mask_irq(wm8350, irq);
460
461 mutex_lock(&wm8350->irq_mutex);
462 wm8350->irq[irq].handler = NULL;
463 mutex_unlock(&wm8350->irq_mutex);
464 return 0;
465}
466EXPORT_SYMBOL_GPL(wm8350_free_irq);
467
468int wm8350_mask_irq(struct wm8350 *wm8350, int irq)
469{
470 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK +
471 wm8350_irqs[irq].reg,
472 wm8350_irqs[irq].mask);
473}
474EXPORT_SYMBOL_GPL(wm8350_mask_irq);
475
476int wm8350_unmask_irq(struct wm8350 *wm8350, int irq)
477{
478 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK +
479 wm8350_irqs[irq].reg,
480 wm8350_irqs[irq].mask);
481}
482EXPORT_SYMBOL_GPL(wm8350_unmask_irq);
483
484int wm8350_irq_init(struct wm8350 *wm8350, int irq,
485 struct wm8350_platform_data *pdata)
486{
487 int ret;
488 int flags = IRQF_ONESHOT;
489
490 if (!irq) {
491 dev_err(wm8350->dev, "No IRQ configured\n");
492 return -EINVAL;
493 }
494
495 wm8350_reg_write(wm8350, WM8350_SYSTEM_INTERRUPTS_MASK, 0xFFFF);
496 wm8350_reg_write(wm8350, WM8350_INT_STATUS_1_MASK, 0xFFFF);
497 wm8350_reg_write(wm8350, WM8350_INT_STATUS_2_MASK, 0xFFFF);
498 wm8350_reg_write(wm8350, WM8350_UNDER_VOLTAGE_INT_STATUS_MASK, 0xFFFF);
499 wm8350_reg_write(wm8350, WM8350_GPIO_INT_STATUS_MASK, 0xFFFF);
500 wm8350_reg_write(wm8350, WM8350_COMPARATOR_INT_STATUS_MASK, 0xFFFF);
501
502 mutex_init(&wm8350->irq_mutex);
503 wm8350->chip_irq = irq;
504
505 if (pdata && pdata->irq_high) {
506 flags |= IRQF_TRIGGER_HIGH;
507
508 wm8350_set_bits(wm8350, WM8350_SYSTEM_CONTROL_1,
509 WM8350_IRQ_POL);
510 } else {
511 flags |= IRQF_TRIGGER_LOW;
512
513 wm8350_clear_bits(wm8350, WM8350_SYSTEM_CONTROL_1,
514 WM8350_IRQ_POL);
515 }
516
517 ret = request_threaded_irq(irq, NULL, wm8350_irq, flags,
518 "wm8350", wm8350);
519 if (ret != 0)
520 dev_err(wm8350->dev, "Failed to request IRQ: %d\n", ret);
521
522 return ret;
523}
524
525int wm8350_irq_exit(struct wm8350 *wm8350)
526{
527 free_irq(wm8350->chip_irq, wm8350);
528 return 0;
529}
diff --git a/drivers/mfd/wm8350-regmap.c b/drivers/mfd/wm8350-regmap.c
index 7ccc1eab98ab..e965139e5cd5 100644
--- a/drivers/mfd/wm8350-regmap.c
+++ b/drivers/mfd/wm8350-regmap.c
@@ -3170,14 +3170,6 @@ const u16 wm8352_mode3_defaults[] = {
3170}; 3170};
3171#endif 3171#endif
3172 3172
3173/* The register defaults for the config mode used must be compiled in but
3174 * due to the impact on kernel size it is possible to disable
3175 */
3176#ifndef WM8350_HAVE_CONFIG_MODE
3177#warning No WM8350 config modes supported - select at least one of the
3178#warning MFD_WM8350_CONFIG_MODE_n options from the board driver.
3179#endif
3180
3181/* 3173/*
3182 * Access masks. 3174 * Access masks.
3183 */ 3175 */
diff --git a/drivers/net/chelsio/sge.c b/drivers/net/chelsio/sge.c
index 8c658cf6f62f..109d2783e4d8 100644
--- a/drivers/net/chelsio/sge.c
+++ b/drivers/net/chelsio/sge.c
@@ -1378,7 +1378,7 @@ static void sge_rx(struct sge *sge, struct freelQ *fl, unsigned int len)
1378 } 1378 }
1379 __skb_pull(skb, sizeof(*p)); 1379 __skb_pull(skb, sizeof(*p));
1380 1380
1381 st = per_cpu_ptr(sge->port_stats[p->iff], smp_processor_id()); 1381 st = this_cpu_ptr(sge->port_stats[p->iff]);
1382 1382
1383 skb->protocol = eth_type_trans(skb, adapter->port[p->iff].dev); 1383 skb->protocol = eth_type_trans(skb, adapter->port[p->iff].dev);
1384 if ((adapter->flags & RX_CSUM_ENABLED) && p->csum == 0xffff && 1384 if ((adapter->flags & RX_CSUM_ENABLED) && p->csum == 0xffff &&
@@ -1780,8 +1780,7 @@ netdev_tx_t t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1780{ 1780{
1781 struct adapter *adapter = dev->ml_priv; 1781 struct adapter *adapter = dev->ml_priv;
1782 struct sge *sge = adapter->sge; 1782 struct sge *sge = adapter->sge;
1783 struct sge_port_stats *st = per_cpu_ptr(sge->port_stats[dev->if_port], 1783 struct sge_port_stats *st = this_cpu_ptr(sge->port_stats[dev->if_port]);
1784 smp_processor_id());
1785 struct cpl_tx_pkt *cpl; 1784 struct cpl_tx_pkt *cpl;
1786 struct sk_buff *orig_skb = skb; 1785 struct sk_buff *orig_skb = skb;
1787 int ret; 1786 int ret;
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index eae4ad749e9d..b9fcc9819837 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -81,7 +81,7 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
81 81
82 /* it's OK to use per_cpu_ptr() because BHs are off */ 82 /* it's OK to use per_cpu_ptr() because BHs are off */
83 pcpu_lstats = dev->ml_priv; 83 pcpu_lstats = dev->ml_priv;
84 lb_stats = per_cpu_ptr(pcpu_lstats, smp_processor_id()); 84 lb_stats = this_cpu_ptr(pcpu_lstats);
85 85
86 len = skb->len; 86 len = skb->len;
87 if (likely(netif_rx(skb) == NET_RX_SUCCESS)) { 87 if (likely(netif_rx(skb) == NET_RX_SUCCESS)) {
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 81bafd578478..d431b59e7d11 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -270,7 +270,7 @@ static int try_io_port(struct pcmcia_device *link)
270 /* for master/slave multifunction cards */ 270 /* for master/slave multifunction cards */
271 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 271 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
272 link->irq.Attributes = 272 link->irq.Attributes =
273 IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; 273 IRQ_TYPE_DYNAMIC_SHARING;
274 } 274 }
275 } else { 275 } else {
276 /* This should be two 16-port windows */ 276 /* This should be two 16-port windows */
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index 8ad8384fc1c0..813aca3fc433 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -426,7 +426,7 @@ static int fmvj18x_config(struct pcmcia_device *link)
426 426
427 if (link->io.NumPorts2 != 0) { 427 if (link->io.NumPorts2 != 0) {
428 link->irq.Attributes = 428 link->irq.Attributes =
429 IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; 429 IRQ_TYPE_DYNAMIC_SHARING;
430 ret = mfc_try_io_port(link); 430 ret = mfc_try_io_port(link);
431 if (ret != 0) goto failed; 431 if (ret != 0) goto failed;
432 } else if (cardtype == UNGERMANN) { 432 } else if (cardtype == UNGERMANN) {
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 2d26b6ca28b9..92ed3fbf89a5 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -490,7 +490,7 @@ static int try_io_port(struct pcmcia_device *link)
490 /* for master/slave multifunction cards */ 490 /* for master/slave multifunction cards */
491 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 491 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
492 link->irq.Attributes = 492 link->irq.Attributes =
493 IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; 493 IRQ_TYPE_DYNAMIC_SHARING;
494 } 494 }
495 } else { 495 } else {
496 /* This should be two 16-port windows */ 496 /* This should be two 16-port windows */
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index cc4853bc0253..6dd486d2977b 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -454,7 +454,7 @@ static int mhz_mfc_config(struct pcmcia_device *link)
454 link->conf.Attributes |= CONF_ENABLE_SPKR; 454 link->conf.Attributes |= CONF_ENABLE_SPKR;
455 link->conf.Status = CCSR_AUDIO_ENA; 455 link->conf.Status = CCSR_AUDIO_ENA;
456 link->irq.Attributes = 456 link->irq.Attributes =
457 IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; 457 IRQ_TYPE_DYNAMIC_SHARING;
458 link->io.IOAddrLines = 16; 458 link->io.IOAddrLines = 16;
459 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 459 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
460 link->io.NumPorts2 = 8; 460 link->io.NumPorts2 = 8;
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index a2eda28f903e..466fc72698c0 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -841,7 +841,7 @@ xirc2ps_config(struct pcmcia_device * link)
841 link->conf.Attributes |= CONF_ENABLE_SPKR; 841 link->conf.Attributes |= CONF_ENABLE_SPKR;
842 link->conf.Status |= CCSR_AUDIO_ENA; 842 link->conf.Status |= CCSR_AUDIO_ENA;
843 } 843 }
844 link->irq.Attributes |= IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED ; 844 link->irq.Attributes |= IRQ_TYPE_DYNAMIC_SHARING;
845 link->io.NumPorts2 = 8; 845 link->io.NumPorts2 = 8;
846 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 846 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
847 if (local->dingo) { 847 if (local->dingo) {
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 63099c58a6dd..3a15de56df9c 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -153,15 +153,14 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
153 struct net_device *rcv = NULL; 153 struct net_device *rcv = NULL;
154 struct veth_priv *priv, *rcv_priv; 154 struct veth_priv *priv, *rcv_priv;
155 struct veth_net_stats *stats, *rcv_stats; 155 struct veth_net_stats *stats, *rcv_stats;
156 int length, cpu; 156 int length;
157 157
158 priv = netdev_priv(dev); 158 priv = netdev_priv(dev);
159 rcv = priv->peer; 159 rcv = priv->peer;
160 rcv_priv = netdev_priv(rcv); 160 rcv_priv = netdev_priv(rcv);
161 161
162 cpu = smp_processor_id(); 162 stats = this_cpu_ptr(priv->stats);
163 stats = per_cpu_ptr(priv->stats, cpu); 163 rcv_stats = this_cpu_ptr(rcv_priv->stats);
164 rcv_stats = per_cpu_ptr(rcv_priv->stats, cpu);
165 164
166 if (!(rcv->flags & IFF_UP)) 165 if (!(rcv->flags & IFF_UP))
167 goto tx_drop; 166 goto tx_drop;
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
index a7aae24f2889..166b67ea622f 100644
--- a/drivers/oprofile/cpu_buffer.c
+++ b/drivers/oprofile/cpu_buffer.c
@@ -47,7 +47,7 @@
47 */ 47 */
48static struct ring_buffer *op_ring_buffer_read; 48static struct ring_buffer *op_ring_buffer_read;
49static struct ring_buffer *op_ring_buffer_write; 49static struct ring_buffer *op_ring_buffer_write;
50DEFINE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer); 50DEFINE_PER_CPU(struct oprofile_cpu_buffer, op_cpu_buffer);
51 51
52static void wq_sync_buffer(struct work_struct *work); 52static void wq_sync_buffer(struct work_struct *work);
53 53
@@ -61,8 +61,7 @@ unsigned long oprofile_get_cpu_buffer_size(void)
61 61
62void oprofile_cpu_buffer_inc_smpl_lost(void) 62void oprofile_cpu_buffer_inc_smpl_lost(void)
63{ 63{
64 struct oprofile_cpu_buffer *cpu_buf 64 struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(op_cpu_buffer);
65 = &__get_cpu_var(cpu_buffer);
66 65
67 cpu_buf->sample_lost_overflow++; 66 cpu_buf->sample_lost_overflow++;
68} 67}
@@ -95,7 +94,7 @@ int alloc_cpu_buffers(void)
95 goto fail; 94 goto fail;
96 95
97 for_each_possible_cpu(i) { 96 for_each_possible_cpu(i) {
98 struct oprofile_cpu_buffer *b = &per_cpu(cpu_buffer, i); 97 struct oprofile_cpu_buffer *b = &per_cpu(op_cpu_buffer, i);
99 98
100 b->last_task = NULL; 99 b->last_task = NULL;
101 b->last_is_kernel = -1; 100 b->last_is_kernel = -1;
@@ -122,7 +121,7 @@ void start_cpu_work(void)
122 work_enabled = 1; 121 work_enabled = 1;
123 122
124 for_each_online_cpu(i) { 123 for_each_online_cpu(i) {
125 struct oprofile_cpu_buffer *b = &per_cpu(cpu_buffer, i); 124 struct oprofile_cpu_buffer *b = &per_cpu(op_cpu_buffer, i);
126 125
127 /* 126 /*
128 * Spread the work by 1 jiffy per cpu so they dont all 127 * Spread the work by 1 jiffy per cpu so they dont all
@@ -139,7 +138,7 @@ void end_cpu_work(void)
139 work_enabled = 0; 138 work_enabled = 0;
140 139
141 for_each_online_cpu(i) { 140 for_each_online_cpu(i) {
142 struct oprofile_cpu_buffer *b = &per_cpu(cpu_buffer, i); 141 struct oprofile_cpu_buffer *b = &per_cpu(op_cpu_buffer, i);
143 142
144 cancel_delayed_work(&b->work); 143 cancel_delayed_work(&b->work);
145 } 144 }
@@ -330,7 +329,7 @@ static inline void
330__oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs, 329__oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs,
331 unsigned long event, int is_kernel) 330 unsigned long event, int is_kernel)
332{ 331{
333 struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(cpu_buffer); 332 struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(op_cpu_buffer);
334 unsigned long backtrace = oprofile_backtrace_depth; 333 unsigned long backtrace = oprofile_backtrace_depth;
335 334
336 /* 335 /*
@@ -375,7 +374,7 @@ oprofile_write_reserve(struct op_entry *entry, struct pt_regs * const regs,
375{ 374{
376 struct op_sample *sample; 375 struct op_sample *sample;
377 int is_kernel = !user_mode(regs); 376 int is_kernel = !user_mode(regs);
378 struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(cpu_buffer); 377 struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(op_cpu_buffer);
379 378
380 cpu_buf->sample_received++; 379 cpu_buf->sample_received++;
381 380
@@ -430,13 +429,13 @@ int oprofile_write_commit(struct op_entry *entry)
430 429
431void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event) 430void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event)
432{ 431{
433 struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(cpu_buffer); 432 struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(op_cpu_buffer);
434 log_sample(cpu_buf, pc, 0, is_kernel, event); 433 log_sample(cpu_buf, pc, 0, is_kernel, event);
435} 434}
436 435
437void oprofile_add_trace(unsigned long pc) 436void oprofile_add_trace(unsigned long pc)
438{ 437{
439 struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(cpu_buffer); 438 struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(op_cpu_buffer);
440 439
441 if (!cpu_buf->tracing) 440 if (!cpu_buf->tracing)
442 return; 441 return;
diff --git a/drivers/oprofile/cpu_buffer.h b/drivers/oprofile/cpu_buffer.h
index 272995d20293..68ea16ab645f 100644
--- a/drivers/oprofile/cpu_buffer.h
+++ b/drivers/oprofile/cpu_buffer.h
@@ -50,7 +50,7 @@ struct oprofile_cpu_buffer {
50 struct delayed_work work; 50 struct delayed_work work;
51}; 51};
52 52
53DECLARE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer); 53DECLARE_PER_CPU(struct oprofile_cpu_buffer, op_cpu_buffer);
54 54
55/* 55/*
56 * Resets the cpu buffer to a sane state. 56 * Resets the cpu buffer to a sane state.
@@ -60,7 +60,7 @@ DECLARE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer);
60 */ 60 */
61static inline void op_cpu_buffer_reset(int cpu) 61static inline void op_cpu_buffer_reset(int cpu)
62{ 62{
63 struct oprofile_cpu_buffer *cpu_buf = &per_cpu(cpu_buffer, cpu); 63 struct oprofile_cpu_buffer *cpu_buf = &per_cpu(op_cpu_buffer, cpu);
64 64
65 cpu_buf->last_is_kernel = -1; 65 cpu_buf->last_is_kernel = -1;
66 cpu_buf->last_task = NULL; 66 cpu_buf->last_task = NULL;
diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
index 61689e814d46..917d28ebeacd 100644
--- a/drivers/oprofile/oprofile_stats.c
+++ b/drivers/oprofile/oprofile_stats.c
@@ -23,7 +23,7 @@ void oprofile_reset_stats(void)
23 int i; 23 int i;
24 24
25 for_each_possible_cpu(i) { 25 for_each_possible_cpu(i) {
26 cpu_buf = &per_cpu(cpu_buffer, i); 26 cpu_buf = &per_cpu(op_cpu_buffer, i);
27 cpu_buf->sample_received = 0; 27 cpu_buf->sample_received = 0;
28 cpu_buf->sample_lost_overflow = 0; 28 cpu_buf->sample_lost_overflow = 0;
29 cpu_buf->backtrace_aborted = 0; 29 cpu_buf->backtrace_aborted = 0;
@@ -51,7 +51,7 @@ void oprofile_create_stats_files(struct super_block *sb, struct dentry *root)
51 return; 51 return;
52 52
53 for_each_possible_cpu(i) { 53 for_each_possible_cpu(i) {
54 cpu_buf = &per_cpu(cpu_buffer, i); 54 cpu_buf = &per_cpu(op_cpu_buffer, i);
55 snprintf(buf, 10, "cpu%d", i); 55 snprintf(buf, 10, "cpu%d", i);
56 cpudir = oprofilefs_mkdir(sb, dir, buf); 56 cpudir = oprofilefs_mkdir(sb, dir, buf);
57 57
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index cd5082d3ca19..9f3adbd9f700 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -64,7 +64,7 @@ config PCMCIA_IOCTL
64 If unsure, say Y. 64 If unsure, say Y.
65 65
66config CARDBUS 66config CARDBUS
67 bool "32-bit CardBus support" 67 bool "32-bit CardBus support"
68 depends on PCI 68 depends on PCI
69 default y 69 default y
70 ---help--- 70 ---help---
@@ -87,8 +87,8 @@ config YENTA
87 select PCCARD_NONSTATIC 87 select PCCARD_NONSTATIC
88 ---help--- 88 ---help---
89 This option enables support for CardBus host bridges. Virtually 89 This option enables support for CardBus host bridges. Virtually
90 all modern PCMCIA bridges are CardBus compatible. A "bridge" is 90 all modern PCMCIA bridges are CardBus compatible. A "bridge" is
91 the hardware inside your computer that PCMCIA cards are plugged 91 the hardware inside your computer that PCMCIA cards are plugged
92 into. 92 into.
93 93
94 To compile this driver as modules, choose M here: the 94 To compile this driver as modules, choose M here: the
@@ -208,7 +208,7 @@ config PCMCIA_PXA2XX
208 depends on ARM && ARCH_PXA && PCMCIA 208 depends on ARM && ARCH_PXA && PCMCIA
209 depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \ 209 depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \
210 || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \ 210 || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \
211 || ARCH_VIPER || ARCH_PXA_ESERIES || MACH_STARGATE2) 211 || ARCOM_PCMCIA || ARCH_PXA_ESERIES || MACH_STARGATE2)
212 select PCMCIA_SOC_COMMON 212 select PCMCIA_SOC_COMMON
213 help 213 help
214 Say Y here to include support for the PXA2xx PCMCIA controller 214 Say Y here to include support for the PXA2xx PCMCIA controller
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index 382938313991..83ff802de544 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -67,7 +67,7 @@ pxa2xx-obj-$(CONFIG_ARCH_LUBBOCK) += pxa2xx_lubbock_cs.o
67pxa2xx-obj-$(CONFIG_MACH_MAINSTONE) += pxa2xx_mainstone.o 67pxa2xx-obj-$(CONFIG_MACH_MAINSTONE) += pxa2xx_mainstone.o
68pxa2xx-obj-$(CONFIG_PXA_SHARPSL) += pxa2xx_sharpsl.o 68pxa2xx-obj-$(CONFIG_PXA_SHARPSL) += pxa2xx_sharpsl.o
69pxa2xx-obj-$(CONFIG_MACH_ARMCORE) += pxa2xx_cm_x2xx_cs.o 69pxa2xx-obj-$(CONFIG_MACH_ARMCORE) += pxa2xx_cm_x2xx_cs.o
70pxa2xx-obj-$(CONFIG_ARCH_VIPER) += pxa2xx_viper.o 70pxa2xx-obj-$(CONFIG_ARCOM_PCMCIA) += pxa2xx_viper.o
71pxa2xx-obj-$(CONFIG_TRIZEPS_PCMCIA) += pxa2xx_trizeps4.o 71pxa2xx-obj-$(CONFIG_TRIZEPS_PCMCIA) += pxa2xx_trizeps4.o
72pxa2xx-obj-$(CONFIG_MACH_PALMTX) += pxa2xx_palmtx.o 72pxa2xx-obj-$(CONFIG_MACH_PALMTX) += pxa2xx_palmtx.o
73pxa2xx-obj-$(CONFIG_MACH_PALMTC) += pxa2xx_palmtc.o 73pxa2xx-obj-$(CONFIG_MACH_PALMTC) += pxa2xx_palmtc.o
diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c
index a73b040ddbfb..cdf50f3bc2df 100644
--- a/drivers/pcmcia/cardbus.c
+++ b/drivers/pcmcia/cardbus.c
@@ -27,8 +27,8 @@
27#include <linux/mm.h> 27#include <linux/mm.h>
28#include <linux/pci.h> 28#include <linux/pci.h>
29#include <linux/ioport.h> 29#include <linux/ioport.h>
30#include <linux/io.h>
30#include <asm/irq.h> 31#include <asm/irq.h>
31#include <asm/io.h>
32 32
33#include <pcmcia/cs_types.h> 33#include <pcmcia/cs_types.h>
34#include <pcmcia/ss.h> 34#include <pcmcia/ss.h>
@@ -58,7 +58,7 @@
58 image number and an offset within that image. xlate_rom_addr() 58 image number and an offset within that image. xlate_rom_addr()
59 converts an image/offset address to an absolute offset from the 59 converts an image/offset address to an absolute offset from the
60 ROM's base address. 60 ROM's base address.
61 61
62=====================================================================*/ 62=====================================================================*/
63 63
64static u_int xlate_rom_addr(void __iomem *b, u_int addr) 64static u_int xlate_rom_addr(void __iomem *b, u_int addr)
@@ -85,10 +85,10 @@ static u_int xlate_rom_addr(void __iomem *b, u_int addr)
85 These are similar to setup_cis_mem and release_cis_mem for 16-bit 85 These are similar to setup_cis_mem and release_cis_mem for 16-bit
86 cards. The "result" that is used externally is the cb_cis_virt 86 cards. The "result" that is used externally is the cb_cis_virt
87 pointer in the struct pcmcia_socket structure. 87 pointer in the struct pcmcia_socket structure.
88 88
89=====================================================================*/ 89=====================================================================*/
90 90
91static void cb_release_cis_mem(struct pcmcia_socket * s) 91static void cb_release_cis_mem(struct pcmcia_socket *s)
92{ 92{
93 if (s->cb_cis_virt) { 93 if (s->cb_cis_virt) {
94 dev_dbg(&s->dev, "cb_release_cis_mem()\n"); 94 dev_dbg(&s->dev, "cb_release_cis_mem()\n");
@@ -98,7 +98,7 @@ static void cb_release_cis_mem(struct pcmcia_socket * s)
98 } 98 }
99} 99}
100 100
101static int cb_setup_cis_mem(struct pcmcia_socket * s, struct resource *res) 101static int cb_setup_cis_mem(struct pcmcia_socket *s, struct resource *res)
102{ 102{
103 unsigned int start, size; 103 unsigned int start, size;
104 104
@@ -124,10 +124,11 @@ static int cb_setup_cis_mem(struct pcmcia_socket * s, struct resource *res)
124 124
125 This is used by the CIS processing code to read CIS information 125 This is used by the CIS processing code to read CIS information
126 from a CardBus device. 126 from a CardBus device.
127 127
128=====================================================================*/ 128=====================================================================*/
129 129
130int read_cb_mem(struct pcmcia_socket * s, int space, u_int addr, u_int len, void *ptr) 130int read_cb_mem(struct pcmcia_socket *s, int space, u_int addr, u_int len,
131 void *ptr)
131{ 132{
132 struct pci_dev *dev; 133 struct pci_dev *dev;
133 struct resource *res; 134 struct resource *res;
@@ -181,7 +182,7 @@ fail:
181 cb_alloc() and cb_free() allocate and free the kernel data 182 cb_alloc() and cb_free() allocate and free the kernel data
182 structures for a Cardbus device, and handle the lowest level PCI 183 structures for a Cardbus device, and handle the lowest level PCI
183 device setup issues. 184 device setup issues.
184 185
185=====================================================================*/ 186=====================================================================*/
186 187
187static void cardbus_config_irq_and_cls(struct pci_bus *bus, int irq) 188static void cardbus_config_irq_and_cls(struct pci_bus *bus, int irq)
@@ -214,14 +215,14 @@ static void cardbus_config_irq_and_cls(struct pci_bus *bus, int irq)
214 } 215 }
215} 216}
216 217
217int __ref cb_alloc(struct pcmcia_socket * s) 218int __ref cb_alloc(struct pcmcia_socket *s)
218{ 219{
219 struct pci_bus *bus = s->cb_dev->subordinate; 220 struct pci_bus *bus = s->cb_dev->subordinate;
220 struct pci_dev *dev; 221 struct pci_dev *dev;
221 unsigned int max, pass; 222 unsigned int max, pass;
222 223
223 s->functions = pci_scan_slot(bus, PCI_DEVFN(0, 0)); 224 s->functions = pci_scan_slot(bus, PCI_DEVFN(0, 0));
224// pcibios_fixup_bus(bus); 225/* pcibios_fixup_bus(bus); */
225 226
226 max = bus->secondary; 227 max = bus->secondary;
227 for (pass = 0; pass < 2; pass++) 228 for (pass = 0; pass < 2; pass++)
@@ -248,7 +249,7 @@ int __ref cb_alloc(struct pcmcia_socket * s)
248 return 0; 249 return 0;
249} 250}
250 251
251void cb_free(struct pcmcia_socket * s) 252void cb_free(struct pcmcia_socket *s)
252{ 253{
253 struct pci_dev *bridge = s->cb_dev; 254 struct pci_dev *bridge = s->cb_dev;
254 255
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
index 8c1b73cf021b..25b1cd219e37 100644
--- a/drivers/pcmcia/cistpl.c
+++ b/drivers/pcmcia/cistpl.c
@@ -23,7 +23,7 @@
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/pci.h> 24#include <linux/pci.h>
25#include <linux/ioport.h> 25#include <linux/ioport.h>
26#include <asm/io.h> 26#include <linux/io.h>
27#include <asm/byteorder.h> 27#include <asm/byteorder.h>
28#include <asm/unaligned.h> 28#include <asm/unaligned.h>
29 29
@@ -125,7 +125,7 @@ set_cis_map(struct pcmcia_socket *s, unsigned int card_offset, unsigned int flag
125 125
126 Low-level functions to read and write CIS memory. I think the 126 Low-level functions to read and write CIS memory. I think the
127 write routine is only useful for writing one-byte registers. 127 write routine is only useful for writing one-byte registers.
128 128
129======================================================================*/ 129======================================================================*/
130 130
131/* Bits in attr field */ 131/* Bits in attr field */
@@ -137,7 +137,7 @@ int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, u_int addr,
137{ 137{
138 void __iomem *sys, *end; 138 void __iomem *sys, *end;
139 unsigned char *buf = ptr; 139 unsigned char *buf = ptr;
140 140
141 dev_dbg(&s->dev, "pcmcia_read_cis_mem(%d, %#x, %u)\n", attr, addr, len); 141 dev_dbg(&s->dev, "pcmcia_read_cis_mem(%d, %#x, %u)\n", attr, addr, len);
142 142
143 if (attr & IS_INDIRECT) { 143 if (attr & IS_INDIRECT) {
@@ -203,7 +203,7 @@ void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr,
203{ 203{
204 void __iomem *sys, *end; 204 void __iomem *sys, *end;
205 unsigned char *buf = ptr; 205 unsigned char *buf = ptr;
206 206
207 dev_dbg(&s->dev, "pcmcia_write_cis_mem(%d, %#x, %u)\n", attr, addr, len); 207 dev_dbg(&s->dev, "pcmcia_write_cis_mem(%d, %#x, %u)\n", attr, addr, len);
208 208
209 if (attr & IS_INDIRECT) { 209 if (attr & IS_INDIRECT) {
@@ -262,7 +262,7 @@ EXPORT_SYMBOL(pcmcia_write_cis_mem);
262 This is a wrapper around read_cis_mem, with the same interface, 262 This is a wrapper around read_cis_mem, with the same interface,
263 but which caches information, for cards whose CIS may not be 263 but which caches information, for cards whose CIS may not be
264 readable all the time. 264 readable all the time.
265 265
266======================================================================*/ 266======================================================================*/
267 267
268static void read_cis_cache(struct pcmcia_socket *s, int attr, u_int addr, 268static void read_cis_cache(struct pcmcia_socket *s, int attr, u_int addr,
@@ -342,7 +342,7 @@ EXPORT_SYMBOL(destroy_cis_cache);
342 342
343 This verifies if the CIS of a card matches what is in the CIS 343 This verifies if the CIS of a card matches what is in the CIS
344 cache. 344 cache.
345 345
346======================================================================*/ 346======================================================================*/
347 347
348int verify_cis_cache(struct pcmcia_socket *s) 348int verify_cis_cache(struct pcmcia_socket *s)
@@ -381,7 +381,7 @@ int verify_cis_cache(struct pcmcia_socket *s)
381 381
382 For really bad cards, we provide a facility for uploading a 382 For really bad cards, we provide a facility for uploading a
383 replacement CIS. 383 replacement CIS.
384 384
385======================================================================*/ 385======================================================================*/
386 386
387int pcmcia_replace_cis(struct pcmcia_socket *s, 387int pcmcia_replace_cis(struct pcmcia_socket *s,
@@ -406,7 +406,7 @@ EXPORT_SYMBOL(pcmcia_replace_cis);
406/*====================================================================== 406/*======================================================================
407 407
408 The high-level CIS tuple services 408 The high-level CIS tuple services
409 409
410======================================================================*/ 410======================================================================*/
411 411
412typedef struct tuple_flags { 412typedef struct tuple_flags {
@@ -421,8 +421,6 @@ typedef struct tuple_flags {
421#define MFC_FN(f) (((tuple_flags *)(&(f)))->mfc_fn) 421#define MFC_FN(f) (((tuple_flags *)(&(f)))->mfc_fn)
422#define SPACE(f) (((tuple_flags *)(&(f)))->space) 422#define SPACE(f) (((tuple_flags *)(&(f)))->space)
423 423
424int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int func, tuple_t *tuple);
425
426int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, tuple_t *tuple) 424int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, tuple_t *tuple)
427{ 425{
428 if (!s) 426 if (!s)
@@ -523,10 +521,11 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_
523 ofs++; continue; 521 ofs++; continue;
524 } 522 }
525 } 523 }
526 524
527 /* End of chain? Follow long link if possible */ 525 /* End of chain? Follow long link if possible */
528 if (link[0] == CISTPL_END) { 526 if (link[0] == CISTPL_END) {
529 if ((ofs = follow_link(s, tuple)) < 0) 527 ofs = follow_link(s, tuple);
528 if (ofs < 0)
530 return -ENOSPC; 529 return -ENOSPC;
531 attr = SPACE(tuple->Flags); 530 attr = SPACE(tuple->Flags);
532 read_cis_cache(s, attr, ofs, 2, link); 531 read_cis_cache(s, attr, ofs, 2, link);
@@ -578,7 +577,7 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_
578 } else 577 } else
579 if (tuple->DesiredTuple == RETURN_FIRST_TUPLE) 578 if (tuple->DesiredTuple == RETURN_FIRST_TUPLE)
580 break; 579 break;
581 580
582 if (link[0] == tuple->DesiredTuple) 581 if (link[0] == tuple->DesiredTuple)
583 break; 582 break;
584 ofs += link[1] + 2; 583 ofs += link[1] + 2;
@@ -587,7 +586,7 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_
587 dev_dbg(&s->dev, "cs: overrun in pcmcia_get_next_tuple\n"); 586 dev_dbg(&s->dev, "cs: overrun in pcmcia_get_next_tuple\n");
588 return -ENOSPC; 587 return -ENOSPC;
589 } 588 }
590 589
591 tuple->TupleCode = link[0]; 590 tuple->TupleCode = link[0];
592 tuple->TupleLink = link[1]; 591 tuple->TupleLink = link[1];
593 tuple->CISOffset = ofs + 2; 592 tuple->CISOffset = ofs + 2;
@@ -623,7 +622,7 @@ EXPORT_SYMBOL(pccard_get_tuple_data);
623/*====================================================================== 622/*======================================================================
624 623
625 Parsing routines for individual tuples 624 Parsing routines for individual tuples
626 625
627======================================================================*/ 626======================================================================*/
628 627
629static int parse_device(tuple_t *tuple, cistpl_device_t *device) 628static int parse_device(tuple_t *tuple, cistpl_device_t *device)
@@ -637,26 +636,37 @@ static int parse_device(tuple_t *tuple, cistpl_device_t *device)
637 636
638 device->ndev = 0; 637 device->ndev = 0;
639 for (i = 0; i < CISTPL_MAX_DEVICES; i++) { 638 for (i = 0; i < CISTPL_MAX_DEVICES; i++) {
640 639
641 if (*p == 0xff) break; 640 if (*p == 0xff)
641 break;
642 device->dev[i].type = (*p >> 4); 642 device->dev[i].type = (*p >> 4);
643 device->dev[i].wp = (*p & 0x08) ? 1 : 0; 643 device->dev[i].wp = (*p & 0x08) ? 1 : 0;
644 switch (*p & 0x07) { 644 switch (*p & 0x07) {
645 case 0: device->dev[i].speed = 0; break; 645 case 0:
646 case 1: device->dev[i].speed = 250; break; 646 device->dev[i].speed = 0;
647 case 2: device->dev[i].speed = 200; break; 647 break;
648 case 3: device->dev[i].speed = 150; break; 648 case 1:
649 case 4: device->dev[i].speed = 100; break; 649 device->dev[i].speed = 250;
650 break;
651 case 2:
652 device->dev[i].speed = 200;
653 break;
654 case 3:
655 device->dev[i].speed = 150;
656 break;
657 case 4:
658 device->dev[i].speed = 100;
659 break;
650 case 7: 660 case 7:
651 if (++p == q)
652 return -EINVAL;
653 device->dev[i].speed = SPEED_CVT(*p);
654 while (*p & 0x80)
655 if (++p == q) 661 if (++p == q)
656 return -EINVAL; 662 return -EINVAL;
657 break; 663 device->dev[i].speed = SPEED_CVT(*p);
664 while (*p & 0x80)
665 if (++p == q)
666 return -EINVAL;
667 break;
658 default: 668 default:
659 return -EINVAL; 669 return -EINVAL;
660 } 670 }
661 671
662 if (++p == q) 672 if (++p == q)
@@ -671,7 +681,7 @@ static int parse_device(tuple_t *tuple, cistpl_device_t *device)
671 if (++p == q) 681 if (++p == q)
672 break; 682 break;
673 } 683 }
674 684
675 return 0; 685 return 0;
676} 686}
677 687
@@ -706,9 +716,9 @@ static int parse_longlink_mfc(tuple_t *tuple,
706{ 716{
707 u_char *p; 717 u_char *p;
708 int i; 718 int i;
709 719
710 p = (u_char *)tuple->TupleData; 720 p = (u_char *)tuple->TupleData;
711 721
712 link->nfn = *p; p++; 722 link->nfn = *p; p++;
713 if (tuple->TupleDataLen <= link->nfn*5) 723 if (tuple->TupleDataLen <= link->nfn*5)
714 return -EINVAL; 724 return -EINVAL;
@@ -737,11 +747,13 @@ static int parse_strings(u_char *p, u_char *q, int max,
737 ns++; 747 ns++;
738 for (;;) { 748 for (;;) {
739 s[j++] = (*p == 0xff) ? '\0' : *p; 749 s[j++] = (*p == 0xff) ? '\0' : *p;
740 if ((*p == '\0') || (*p == 0xff)) break; 750 if ((*p == '\0') || (*p == 0xff))
751 break;
741 if (++p == q) 752 if (++p == q)
742 return -EINVAL; 753 return -EINVAL;
743 } 754 }
744 if ((*p == 0xff) || (++p == q)) break; 755 if ((*p == 0xff) || (++p == q))
756 break;
745 } 757 }
746 if (found) { 758 if (found) {
747 *found = ns; 759 *found = ns;
@@ -756,10 +768,10 @@ static int parse_strings(u_char *p, u_char *q, int max,
756static int parse_vers_1(tuple_t *tuple, cistpl_vers_1_t *vers_1) 768static int parse_vers_1(tuple_t *tuple, cistpl_vers_1_t *vers_1)
757{ 769{
758 u_char *p, *q; 770 u_char *p, *q;
759 771
760 p = (u_char *)tuple->TupleData; 772 p = (u_char *)tuple->TupleData;
761 q = p + tuple->TupleDataLen; 773 q = p + tuple->TupleDataLen;
762 774
763 vers_1->major = *p; p++; 775 vers_1->major = *p; p++;
764 vers_1->minor = *p; p++; 776 vers_1->minor = *p; p++;
765 if (p >= q) 777 if (p >= q)
@@ -774,10 +786,10 @@ static int parse_vers_1(tuple_t *tuple, cistpl_vers_1_t *vers_1)
774static int parse_altstr(tuple_t *tuple, cistpl_altstr_t *altstr) 786static int parse_altstr(tuple_t *tuple, cistpl_altstr_t *altstr)
775{ 787{
776 u_char *p, *q; 788 u_char *p, *q;
777 789
778 p = (u_char *)tuple->TupleData; 790 p = (u_char *)tuple->TupleData;
779 q = p + tuple->TupleDataLen; 791 q = p + tuple->TupleDataLen;
780 792
781 return parse_strings(p, q, CISTPL_MAX_ALTSTR_STRINGS, 793 return parse_strings(p, q, CISTPL_MAX_ALTSTR_STRINGS,
782 altstr->str, altstr->ofs, &altstr->ns); 794 altstr->str, altstr->ofs, &altstr->ns);
783} 795}
@@ -793,7 +805,8 @@ static int parse_jedec(tuple_t *tuple, cistpl_jedec_t *jedec)
793 q = p + tuple->TupleDataLen; 805 q = p + tuple->TupleDataLen;
794 806
795 for (nid = 0; nid < CISTPL_MAX_DEVICES; nid++) { 807 for (nid = 0; nid < CISTPL_MAX_DEVICES; nid++) {
796 if (p > q-2) break; 808 if (p > q-2)
809 break;
797 jedec->id[nid].mfr = p[0]; 810 jedec->id[nid].mfr = p[0];
798 jedec->id[nid].info = p[1]; 811 jedec->id[nid].info = p[1];
799 p += 2; 812 p += 2;
@@ -871,7 +884,7 @@ static int parse_config(tuple_t *tuple, cistpl_config_t *config)
871 884
872 The following routines are all used to parse the nightmarish 885 The following routines are all used to parse the nightmarish
873 config table entries. 886 config table entries.
874 887
875======================================================================*/ 888======================================================================*/
876 889
877static u_char *parse_power(u_char *p, u_char *q, 890static u_char *parse_power(u_char *p, u_char *q,
@@ -880,17 +893,20 @@ static u_char *parse_power(u_char *p, u_char *q,
880 int i; 893 int i;
881 u_int scale; 894 u_int scale;
882 895
883 if (p == q) return NULL; 896 if (p == q)
897 return NULL;
884 pwr->present = *p; 898 pwr->present = *p;
885 pwr->flags = 0; 899 pwr->flags = 0;
886 p++; 900 p++;
887 for (i = 0; i < 7; i++) 901 for (i = 0; i < 7; i++)
888 if (pwr->present & (1<<i)) { 902 if (pwr->present & (1<<i)) {
889 if (p == q) return NULL; 903 if (p == q)
904 return NULL;
890 pwr->param[i] = POWER_CVT(*p); 905 pwr->param[i] = POWER_CVT(*p);
891 scale = POWER_SCALE(*p); 906 scale = POWER_SCALE(*p);
892 while (*p & 0x80) { 907 while (*p & 0x80) {
893 if (++p == q) return NULL; 908 if (++p == q)
909 return NULL;
894 if ((*p & 0x7f) < 100) 910 if ((*p & 0x7f) < 100)
895 pwr->param[i] += (*p & 0x7f) * scale / 100; 911 pwr->param[i] += (*p & 0x7f) * scale / 100;
896 else if (*p == 0x7d) 912 else if (*p == 0x7d)
@@ -914,24 +930,28 @@ static u_char *parse_timing(u_char *p, u_char *q,
914{ 930{
915 u_char scale; 931 u_char scale;
916 932
917 if (p == q) return NULL; 933 if (p == q)
934 return NULL;
918 scale = *p; 935 scale = *p;
919 if ((scale & 3) != 3) { 936 if ((scale & 3) != 3) {
920 if (++p == q) return NULL; 937 if (++p == q)
938 return NULL;
921 timing->wait = SPEED_CVT(*p); 939 timing->wait = SPEED_CVT(*p);
922 timing->waitscale = exponent[scale & 3]; 940 timing->waitscale = exponent[scale & 3];
923 } else 941 } else
924 timing->wait = 0; 942 timing->wait = 0;
925 scale >>= 2; 943 scale >>= 2;
926 if ((scale & 7) != 7) { 944 if ((scale & 7) != 7) {
927 if (++p == q) return NULL; 945 if (++p == q)
946 return NULL;
928 timing->ready = SPEED_CVT(*p); 947 timing->ready = SPEED_CVT(*p);
929 timing->rdyscale = exponent[scale & 7]; 948 timing->rdyscale = exponent[scale & 7];
930 } else 949 } else
931 timing->ready = 0; 950 timing->ready = 0;
932 scale >>= 3; 951 scale >>= 3;
933 if (scale != 7) { 952 if (scale != 7) {
934 if (++p == q) return NULL; 953 if (++p == q)
954 return NULL;
935 timing->reserved = SPEED_CVT(*p); 955 timing->reserved = SPEED_CVT(*p);
936 timing->rsvscale = exponent[scale]; 956 timing->rsvscale = exponent[scale];
937 } else 957 } else
@@ -946,7 +966,8 @@ static u_char *parse_io(u_char *p, u_char *q, cistpl_io_t *io)
946{ 966{
947 int i, j, bsz, lsz; 967 int i, j, bsz, lsz;
948 968
949 if (p == q) return NULL; 969 if (p == q)
970 return NULL;
950 io->flags = *p; 971 io->flags = *p;
951 972
952 if (!(*p & 0x80)) { 973 if (!(*p & 0x80)) {
@@ -955,24 +976,29 @@ static u_char *parse_io(u_char *p, u_char *q, cistpl_io_t *io)
955 io->win[0].len = (1 << (io->flags & CISTPL_IO_LINES_MASK)); 976 io->win[0].len = (1 << (io->flags & CISTPL_IO_LINES_MASK));
956 return p+1; 977 return p+1;
957 } 978 }
958 979
959 if (++p == q) return NULL; 980 if (++p == q)
981 return NULL;
960 io->nwin = (*p & 0x0f) + 1; 982 io->nwin = (*p & 0x0f) + 1;
961 bsz = (*p & 0x30) >> 4; 983 bsz = (*p & 0x30) >> 4;
962 if (bsz == 3) bsz++; 984 if (bsz == 3)
985 bsz++;
963 lsz = (*p & 0xc0) >> 6; 986 lsz = (*p & 0xc0) >> 6;
964 if (lsz == 3) lsz++; 987 if (lsz == 3)
988 lsz++;
965 p++; 989 p++;
966 990
967 for (i = 0; i < io->nwin; i++) { 991 for (i = 0; i < io->nwin; i++) {
968 io->win[i].base = 0; 992 io->win[i].base = 0;
969 io->win[i].len = 1; 993 io->win[i].len = 1;
970 for (j = 0; j < bsz; j++, p++) { 994 for (j = 0; j < bsz; j++, p++) {
971 if (p == q) return NULL; 995 if (p == q)
996 return NULL;
972 io->win[i].base += *p << (j*8); 997 io->win[i].base += *p << (j*8);
973 } 998 }
974 for (j = 0; j < lsz; j++, p++) { 999 for (j = 0; j < lsz; j++, p++) {
975 if (p == q) return NULL; 1000 if (p == q)
1001 return NULL;
976 io->win[i].len += *p << (j*8); 1002 io->win[i].len += *p << (j*8);
977 } 1003 }
978 } 1004 }
@@ -986,27 +1012,32 @@ static u_char *parse_mem(u_char *p, u_char *q, cistpl_mem_t *mem)
986 int i, j, asz, lsz, has_ha; 1012 int i, j, asz, lsz, has_ha;
987 u_int len, ca, ha; 1013 u_int len, ca, ha;
988 1014
989 if (p == q) return NULL; 1015 if (p == q)
1016 return NULL;
990 1017
991 mem->nwin = (*p & 0x07) + 1; 1018 mem->nwin = (*p & 0x07) + 1;
992 lsz = (*p & 0x18) >> 3; 1019 lsz = (*p & 0x18) >> 3;
993 asz = (*p & 0x60) >> 5; 1020 asz = (*p & 0x60) >> 5;
994 has_ha = (*p & 0x80); 1021 has_ha = (*p & 0x80);
995 if (++p == q) return NULL; 1022 if (++p == q)
996 1023 return NULL;
1024
997 for (i = 0; i < mem->nwin; i++) { 1025 for (i = 0; i < mem->nwin; i++) {
998 len = ca = ha = 0; 1026 len = ca = ha = 0;
999 for (j = 0; j < lsz; j++, p++) { 1027 for (j = 0; j < lsz; j++, p++) {
1000 if (p == q) return NULL; 1028 if (p == q)
1029 return NULL;
1001 len += *p << (j*8); 1030 len += *p << (j*8);
1002 } 1031 }
1003 for (j = 0; j < asz; j++, p++) { 1032 for (j = 0; j < asz; j++, p++) {
1004 if (p == q) return NULL; 1033 if (p == q)
1034 return NULL;
1005 ca += *p << (j*8); 1035 ca += *p << (j*8);
1006 } 1036 }
1007 if (has_ha) 1037 if (has_ha)
1008 for (j = 0; j < asz; j++, p++) { 1038 for (j = 0; j < asz; j++, p++) {
1009 if (p == q) return NULL; 1039 if (p == q)
1040 return NULL;
1010 ha += *p << (j*8); 1041 ha += *p << (j*8);
1011 } 1042 }
1012 mem->win[i].len = len << 8; 1043 mem->win[i].len = len << 8;
@@ -1095,7 +1126,7 @@ static int parse_cftable_entry(tuple_t *tuple,
1095 entry->timing.ready = 0; 1126 entry->timing.ready = 0;
1096 entry->timing.reserved = 0; 1127 entry->timing.reserved = 0;
1097 } 1128 }
1098 1129
1099 /* I/O window options */ 1130 /* I/O window options */
1100 if (features & 0x08) { 1131 if (features & 0x08) {
1101 p = parse_io(p, q, &entry->io); 1132 p = parse_io(p, q, &entry->io);
@@ -1103,7 +1134,7 @@ static int parse_cftable_entry(tuple_t *tuple,
1103 return -EINVAL; 1134 return -EINVAL;
1104 } else 1135 } else
1105 entry->io.nwin = 0; 1136 entry->io.nwin = 0;
1106 1137
1107 /* Interrupt options */ 1138 /* Interrupt options */
1108 if (features & 0x10) { 1139 if (features & 0x10) {
1109 p = parse_irq(p, q, &entry->irq); 1140 p = parse_irq(p, q, &entry->irq);
@@ -1153,7 +1184,7 @@ static int parse_cftable_entry(tuple_t *tuple,
1153 } 1184 }
1154 1185
1155 entry->subtuples = q-p; 1186 entry->subtuples = q-p;
1156 1187
1157 return 0; 1188 return 0;
1158} 1189}
1159 1190
@@ -1176,7 +1207,7 @@ static int parse_bar(tuple_t *tuple, cistpl_bar_t *bar)
1176static int parse_config_cb(tuple_t *tuple, cistpl_config_t *config) 1207static int parse_config_cb(tuple_t *tuple, cistpl_config_t *config)
1177{ 1208{
1178 u_char *p; 1209 u_char *p;
1179 1210
1180 p = (u_char *)tuple->TupleData; 1211 p = (u_char *)tuple->TupleData;
1181 if ((*p != 3) || (tuple->TupleDataLen < 6)) 1212 if ((*p != 3) || (tuple->TupleDataLen < 6))
1182 return -EINVAL; 1213 return -EINVAL;
@@ -1231,7 +1262,7 @@ static int parse_cftable_entry_cb(tuple_t *tuple,
1231 entry->io = *p; p++; 1262 entry->io = *p; p++;
1232 } else 1263 } else
1233 entry->io = 0; 1264 entry->io = 0;
1234 1265
1235 /* Interrupt options */ 1266 /* Interrupt options */
1236 if (features & 0x10) { 1267 if (features & 0x10) {
1237 p = parse_irq(p, q, &entry->irq); 1268 p = parse_irq(p, q, &entry->irq);
@@ -1264,7 +1295,7 @@ static int parse_cftable_entry_cb(tuple_t *tuple,
1264 } 1295 }
1265 1296
1266 entry->subtuples = q-p; 1297 entry->subtuples = q-p;
1267 1298
1268 return 0; 1299 return 0;
1269} 1300}
1270 1301
@@ -1281,7 +1312,8 @@ static int parse_device_geo(tuple_t *tuple, cistpl_device_geo_t *geo)
1281 q = p + tuple->TupleDataLen; 1312 q = p + tuple->TupleDataLen;
1282 1313
1283 for (n = 0; n < CISTPL_MAX_DEVICES; n++) { 1314 for (n = 0; n < CISTPL_MAX_DEVICES; n++) {
1284 if (p > q-6) break; 1315 if (p > q-6)
1316 break;
1285 geo->geo[n].buswidth = p[0]; 1317 geo->geo[n].buswidth = p[0];
1286 geo->geo[n].erase_block = 1 << (p[1]-1); 1318 geo->geo[n].erase_block = 1 << (p[1]-1);
1287 geo->geo[n].read_block = 1 << (p[2]-1); 1319 geo->geo[n].read_block = 1 << (p[2]-1);
@@ -1302,13 +1334,13 @@ static int parse_vers_2(tuple_t *tuple, cistpl_vers_2_t *v2)
1302 1334
1303 if (tuple->TupleDataLen < 10) 1335 if (tuple->TupleDataLen < 10)
1304 return -EINVAL; 1336 return -EINVAL;
1305 1337
1306 p = tuple->TupleData; 1338 p = tuple->TupleData;
1307 q = p + tuple->TupleDataLen; 1339 q = p + tuple->TupleDataLen;
1308 1340
1309 v2->vers = p[0]; 1341 v2->vers = p[0];
1310 v2->comply = p[1]; 1342 v2->comply = p[1];
1311 v2->dindex = get_unaligned_le16(p +2 ); 1343 v2->dindex = get_unaligned_le16(p + 2);
1312 v2->vspec8 = p[6]; 1344 v2->vspec8 = p[6];
1313 v2->vspec9 = p[7]; 1345 v2->vspec9 = p[7];
1314 v2->nhdr = p[8]; 1346 v2->nhdr = p[8];
@@ -1322,7 +1354,7 @@ static int parse_org(tuple_t *tuple, cistpl_org_t *org)
1322{ 1354{
1323 u_char *p, *q; 1355 u_char *p, *q;
1324 int i; 1356 int i;
1325 1357
1326 p = tuple->TupleData; 1358 p = tuple->TupleData;
1327 q = p + tuple->TupleDataLen; 1359 q = p + tuple->TupleDataLen;
1328 if (p == q) 1360 if (p == q)
@@ -1332,7 +1364,8 @@ static int parse_org(tuple_t *tuple, cistpl_org_t *org)
1332 return -EINVAL; 1364 return -EINVAL;
1333 for (i = 0; i < 30; i++) { 1365 for (i = 0; i < 30; i++) {
1334 org->desc[i] = *p; 1366 org->desc[i] = *p;
1335 if (*p == '\0') break; 1367 if (*p == '\0')
1368 break;
1336 if (++p == q) 1369 if (++p == q)
1337 return -EINVAL; 1370 return -EINVAL;
1338 } 1371 }
@@ -1363,7 +1396,7 @@ static int parse_format(tuple_t *tuple, cistpl_format_t *fmt)
1363int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse) 1396int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse)
1364{ 1397{
1365 int ret = 0; 1398 int ret = 0;
1366 1399
1367 if (tuple->TupleDataLen > tuple->TupleDataMax) 1400 if (tuple->TupleDataLen > tuple->TupleDataMax)
1368 return -EINVAL; 1401 return -EINVAL;
1369 switch (tuple->TupleCode) { 1402 switch (tuple->TupleCode) {
@@ -1448,7 +1481,7 @@ EXPORT_SYMBOL(pcmcia_parse_tuple);
1448/*====================================================================== 1481/*======================================================================
1449 1482
1450 This is used internally by Card Services to look up CIS stuff. 1483 This is used internally by Card Services to look up CIS stuff.
1451 1484
1452======================================================================*/ 1485======================================================================*/
1453 1486
1454int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t code, void *parse) 1487int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t code, void *parse)
@@ -1550,7 +1583,7 @@ EXPORT_SYMBOL(pccard_loop_tuple);
1550 checks include making sure several critical tuples are present and 1583 checks include making sure several critical tuples are present and
1551 valid; seeing if the total number of tuples is reasonable; and 1584 valid; seeing if the total number of tuples is reasonable; and
1552 looking for tuples that use reserved codes. 1585 looking for tuples that use reserved codes.
1553 1586
1554======================================================================*/ 1587======================================================================*/
1555 1588
1556int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *info) 1589int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *info)
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index 790af87a922f..6d6f82b38a68 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -135,7 +135,7 @@ int pcmcia_socket_dev_resume(struct device *dev)
135EXPORT_SYMBOL(pcmcia_socket_dev_resume); 135EXPORT_SYMBOL(pcmcia_socket_dev_resume);
136 136
137 137
138struct pcmcia_socket * pcmcia_get_socket(struct pcmcia_socket *skt) 138struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt)
139{ 139{
140 struct device *dev = get_device(&skt->dev); 140 struct device *dev = get_device(&skt->dev);
141 if (!dev) 141 if (!dev)
@@ -145,7 +145,7 @@ struct pcmcia_socket * pcmcia_get_socket(struct pcmcia_socket *skt)
145 put_device(&skt->dev); 145 put_device(&skt->dev);
146 return NULL; 146 return NULL;
147 } 147 }
148 return (skt); 148 return skt;
149} 149}
150EXPORT_SYMBOL(pcmcia_get_socket); 150EXPORT_SYMBOL(pcmcia_get_socket);
151 151
@@ -297,7 +297,7 @@ void pcmcia_unregister_socket(struct pcmcia_socket *socket)
297EXPORT_SYMBOL(pcmcia_unregister_socket); 297EXPORT_SYMBOL(pcmcia_unregister_socket);
298 298
299 299
300struct pcmcia_socket * pcmcia_get_socket_by_nr(unsigned int nr) 300struct pcmcia_socket *pcmcia_get_socket_by_nr(unsigned int nr)
301{ 301{
302 struct pcmcia_socket *s; 302 struct pcmcia_socket *s;
303 303
@@ -736,7 +736,7 @@ EXPORT_SYMBOL(pcmcia_parse_events);
736/* register pcmcia_callback */ 736/* register pcmcia_callback */
737int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c) 737int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c)
738{ 738{
739 int ret = 0; 739 int ret = 0;
740 740
741 /* s->skt_mutex also protects s->callback */ 741 /* s->skt_mutex also protects s->callback */
742 mutex_lock(&s->skt_mutex); 742 mutex_lock(&s->skt_mutex);
@@ -848,7 +848,7 @@ EXPORT_SYMBOL(pcmcia_suspend_card);
848int pcmcia_resume_card(struct pcmcia_socket *skt) 848int pcmcia_resume_card(struct pcmcia_socket *skt)
849{ 849{
850 int ret; 850 int ret;
851 851
852 dev_dbg(&skt->dev, "waking up socket\n"); 852 dev_dbg(&skt->dev, "waking up socket\n");
853 853
854 mutex_lock(&skt->skt_mutex); 854 mutex_lock(&skt->skt_mutex);
@@ -876,7 +876,7 @@ EXPORT_SYMBOL(pcmcia_resume_card);
876int pcmcia_eject_card(struct pcmcia_socket *skt) 876int pcmcia_eject_card(struct pcmcia_socket *skt)
877{ 877{
878 int ret; 878 int ret;
879 879
880 dev_dbg(&skt->dev, "user eject request\n"); 880 dev_dbg(&skt->dev, "user eject request\n");
881 881
882 mutex_lock(&skt->skt_mutex); 882 mutex_lock(&skt->skt_mutex);
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 05893d41dd41..1a4a3c49cc15 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -57,7 +57,7 @@ static void pcmcia_check_driver(struct pcmcia_driver *p_drv)
57 "function\n", p_drv->drv.name); 57 "function\n", p_drv->drv.name);
58 58
59 while (did && did->match_flags) { 59 while (did && did->match_flags) {
60 for (i=0; i<4; i++) { 60 for (i = 0; i < 4; i++) {
61 if (!did->prod_id[i]) 61 if (!did->prod_id[i])
62 continue; 62 continue;
63 63
@@ -105,7 +105,7 @@ pcmcia_store_new_id(struct device_driver *driver, const char *buf, size_t count)
105 __u16 match_flags, manf_id, card_id; 105 __u16 match_flags, manf_id, card_id;
106 __u8 func_id, function, device_no; 106 __u8 func_id, function, device_no;
107 __u32 prod_id_hash[4] = {0, 0, 0, 0}; 107 __u32 prod_id_hash[4] = {0, 0, 0, 0};
108 int fields=0; 108 int fields = 0;
109 int retval = 0; 109 int retval = 0;
110 110
111 fields = sscanf(buf, "%hx %hx %hx %hhx %hhx %hhx %x %x %x %x", 111 fields = sscanf(buf, "%hx %hx %hx %hhx %hhx %hhx %x %x %x %x",
@@ -214,7 +214,7 @@ EXPORT_SYMBOL(pcmcia_unregister_driver);
214 214
215/* pcmcia_device handling */ 215/* pcmcia_device handling */
216 216
217struct pcmcia_device * pcmcia_get_dev(struct pcmcia_device *p_dev) 217struct pcmcia_device *pcmcia_get_dev(struct pcmcia_device *p_dev)
218{ 218{
219 struct device *tmp_dev; 219 struct device *tmp_dev;
220 tmp_dev = get_device(&p_dev->dev); 220 tmp_dev = get_device(&p_dev->dev);
@@ -258,7 +258,7 @@ static void pcmcia_add_device_later(struct pcmcia_socket *s, int mfc)
258 return; 258 return;
259} 259}
260 260
261static int pcmcia_device_probe(struct device * dev) 261static int pcmcia_device_probe(struct device *dev)
262{ 262{
263 struct pcmcia_device *p_dev; 263 struct pcmcia_device *p_dev;
264 struct pcmcia_driver *p_drv; 264 struct pcmcia_driver *p_drv;
@@ -325,7 +325,7 @@ put_module:
325put_dev: 325put_dev:
326 if (ret) 326 if (ret)
327 put_device(dev); 327 put_device(dev);
328 return (ret); 328 return ret;
329} 329}
330 330
331 331
@@ -354,7 +354,7 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le
354 354
355 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 355 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
356 list_del(&p_dev->socket_device_list); 356 list_del(&p_dev->socket_device_list);
357 p_dev->_removed=1; 357 p_dev->_removed = 1;
358 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 358 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
359 359
360 dev_dbg(&p_dev->dev, "unregistering device\n"); 360 dev_dbg(&p_dev->dev, "unregistering device\n");
@@ -364,7 +364,7 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le
364 return; 364 return;
365} 365}
366 366
367static int pcmcia_device_remove(struct device * dev) 367static int pcmcia_device_remove(struct device *dev)
368{ 368{
369 struct pcmcia_device *p_dev; 369 struct pcmcia_device *p_dev;
370 struct pcmcia_driver *p_drv; 370 struct pcmcia_driver *p_drv;
@@ -391,7 +391,7 @@ static int pcmcia_device_remove(struct device * dev)
391 return 0; 391 return 0;
392 392
393 if (p_drv->remove) 393 if (p_drv->remove)
394 p_drv->remove(p_dev); 394 p_drv->remove(p_dev);
395 395
396 p_dev->dev_node = NULL; 396 p_dev->dev_node = NULL;
397 397
@@ -499,7 +499,7 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev)
499 */ 499 */
500static DEFINE_MUTEX(device_add_lock); 500static DEFINE_MUTEX(device_add_lock);
501 501
502struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int function) 502struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s, unsigned int function)
503{ 503{
504 struct pcmcia_device *p_dev, *tmp_dev; 504 struct pcmcia_device *p_dev, *tmp_dev;
505 unsigned long flags; 505 unsigned long flags;
@@ -545,8 +545,8 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
545 * Note that this is serialized by the device_add_lock, so that 545 * Note that this is serialized by the device_add_lock, so that
546 * only one such struct will be created. 546 * only one such struct will be created.
547 */ 547 */
548 list_for_each_entry(tmp_dev, &s->devices_list, socket_device_list) 548 list_for_each_entry(tmp_dev, &s->devices_list, socket_device_list)
549 if (p_dev->func == tmp_dev->func) { 549 if (p_dev->func == tmp_dev->func) {
550 p_dev->function_config = tmp_dev->function_config; 550 p_dev->function_config = tmp_dev->function_config;
551 p_dev->io = tmp_dev->io; 551 p_dev->io = tmp_dev->io;
552 p_dev->irq = tmp_dev->irq; 552 p_dev->irq = tmp_dev->irq;
@@ -627,10 +627,10 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
627 no_funcs = 1; 627 no_funcs = 1;
628 s->functions = no_funcs; 628 s->functions = no_funcs;
629 629
630 for (i=0; i < no_funcs; i++) 630 for (i = 0; i < no_funcs; i++)
631 pcmcia_device_add(s, i); 631 pcmcia_device_add(s, i);
632 632
633 return (ret); 633 return ret;
634} 634}
635 635
636 636
@@ -756,7 +756,7 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
756 release: 756 release:
757 release_firmware(fw); 757 release_firmware(fw);
758 758
759 return (ret); 759 return ret;
760} 760}
761 761
762#else /* !CONFIG_PCMCIA_LOAD_CIS */ 762#else /* !CONFIG_PCMCIA_LOAD_CIS */
@@ -852,7 +852,7 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev,
852 852
853 if (did->match_flags & PCMCIA_DEV_ID_MATCH_ANONYMOUS) { 853 if (did->match_flags & PCMCIA_DEV_ID_MATCH_ANONYMOUS) {
854 int i; 854 int i;
855 for (i=0; i<4; i++) 855 for (i = 0; i < 4; i++)
856 if (dev->prod_id[i]) 856 if (dev->prod_id[i])
857 return 0; 857 return 0;
858 if (dev->has_manf_id || dev->has_card_id || dev->has_func_id) 858 if (dev->has_manf_id || dev->has_card_id || dev->has_func_id)
@@ -865,9 +865,10 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev,
865} 865}
866 866
867 867
868static int pcmcia_bus_match(struct device * dev, struct device_driver * drv) { 868static int pcmcia_bus_match(struct device *dev, struct device_driver *drv)
869 struct pcmcia_device * p_dev = to_pcmcia_dev(dev); 869{
870 struct pcmcia_driver * p_drv = to_pcmcia_drv(drv); 870 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
871 struct pcmcia_driver *p_drv = to_pcmcia_drv(drv);
871 struct pcmcia_device_id *did = p_drv->id_table; 872 struct pcmcia_device_id *did = p_drv->id_table;
872 struct pcmcia_dynid *dynid; 873 struct pcmcia_dynid *dynid;
873 874
@@ -917,7 +918,7 @@ static int pcmcia_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
917 p_dev = to_pcmcia_dev(dev); 918 p_dev = to_pcmcia_dev(dev);
918 919
919 /* calculate hashes */ 920 /* calculate hashes */
920 for (i=0; i<4; i++) { 921 for (i = 0; i < 4; i++) {
921 if (!p_dev->prod_id[i]) 922 if (!p_dev->prod_id[i])
922 continue; 923 continue;
923 hash[i] = crc32(0, p_dev->prod_id[i], strlen(p_dev->prod_id[i])); 924 hash[i] = crc32(0, p_dev->prod_id[i], strlen(p_dev->prod_id[i]));
@@ -984,14 +985,14 @@ static void runtime_resume(struct device *dev)
984static ssize_t field##_show (struct device *dev, struct device_attribute *attr, char *buf) \ 985static ssize_t field##_show (struct device *dev, struct device_attribute *attr, char *buf) \
985{ \ 986{ \
986 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); \ 987 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); \
987 return p_dev->test ? sprintf (buf, format, p_dev->field) : -ENODEV; \ 988 return p_dev->test ? sprintf(buf, format, p_dev->field) : -ENODEV; \
988} 989}
989 990
990#define pcmcia_device_stringattr(name, field) \ 991#define pcmcia_device_stringattr(name, field) \
991static ssize_t name##_show (struct device *dev, struct device_attribute *attr, char *buf) \ 992static ssize_t name##_show (struct device *dev, struct device_attribute *attr, char *buf) \
992{ \ 993{ \
993 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); \ 994 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); \
994 return p_dev->field ? sprintf (buf, "%s\n", p_dev->field) : -ENODEV; \ 995 return p_dev->field ? sprintf(buf, "%s\n", p_dev->field) : -ENODEV; \
995} 996}
996 997
997pcmcia_device_attr(func, socket, "0x%02x\n"); 998pcmcia_device_attr(func, socket, "0x%02x\n");
@@ -1020,8 +1021,8 @@ static ssize_t pcmcia_store_pm_state(struct device *dev, struct device_attribute
1020 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 1021 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
1021 int ret = 0; 1022 int ret = 0;
1022 1023
1023 if (!count) 1024 if (!count)
1024 return -EINVAL; 1025 return -EINVAL;
1025 1026
1026 if ((!p_dev->suspended) && !strncmp(buf, "off", 3)) 1027 if ((!p_dev->suspended) && !strncmp(buf, "off", 3))
1027 ret = runtime_suspend(dev); 1028 ret = runtime_suspend(dev);
@@ -1039,10 +1040,11 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
1039 u32 hash[4] = { 0, 0, 0, 0}; 1040 u32 hash[4] = { 0, 0, 0, 0};
1040 1041
1041 /* calculate hashes */ 1042 /* calculate hashes */
1042 for (i=0; i<4; i++) { 1043 for (i = 0; i < 4; i++) {
1043 if (!p_dev->prod_id[i]) 1044 if (!p_dev->prod_id[i])
1044 continue; 1045 continue;
1045 hash[i] = crc32(0,p_dev->prod_id[i],strlen(p_dev->prod_id[i])); 1046 hash[i] = crc32(0, p_dev->prod_id[i],
1047 strlen(p_dev->prod_id[i]));
1046 } 1048 }
1047 return sprintf(buf, "pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02X" 1049 return sprintf(buf, "pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02X"
1048 "pa%08Xpb%08Xpc%08Xpd%08X\n", 1050 "pa%08Xpb%08Xpc%08Xpd%08X\n",
@@ -1091,7 +1093,7 @@ static struct device_attribute pcmcia_dev_attrs[] = {
1091 1093
1092/* PM support, also needed for reset */ 1094/* PM support, also needed for reset */
1093 1095
1094static int pcmcia_dev_suspend(struct device * dev, pm_message_t state) 1096static int pcmcia_dev_suspend(struct device *dev, pm_message_t state)
1095{ 1097{
1096 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 1098 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
1097 struct pcmcia_driver *p_drv = NULL; 1099 struct pcmcia_driver *p_drv = NULL;
@@ -1131,10 +1133,10 @@ static int pcmcia_dev_suspend(struct device * dev, pm_message_t state)
1131} 1133}
1132 1134
1133 1135
1134static int pcmcia_dev_resume(struct device * dev) 1136static int pcmcia_dev_resume(struct device *dev)
1135{ 1137{
1136 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 1138 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
1137 struct pcmcia_driver *p_drv = NULL; 1139 struct pcmcia_driver *p_drv = NULL;
1138 int ret = 0; 1140 int ret = 0;
1139 1141
1140 if (!p_dev->suspended) 1142 if (!p_dev->suspended)
@@ -1211,7 +1213,7 @@ static int pcmcia_bus_suspend(struct pcmcia_socket *skt)
1211/*====================================================================== 1213/*======================================================================
1212 1214
1213 The card status event handler. 1215 The card status event handler.
1214 1216
1215======================================================================*/ 1217======================================================================*/
1216 1218
1217/* Normally, the event is passed to individual drivers after 1219/* Normally, the event is passed to individual drivers after
@@ -1264,7 +1266,7 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
1264} /* ds_event */ 1266} /* ds_event */
1265 1267
1266 1268
1267struct pcmcia_device * pcmcia_dev_present(struct pcmcia_device *_p_dev) 1269struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *_p_dev)
1268{ 1270{
1269 struct pcmcia_device *p_dev; 1271 struct pcmcia_device *p_dev;
1270 struct pcmcia_device *ret = NULL; 1272 struct pcmcia_device *ret = NULL;
@@ -1329,7 +1331,7 @@ static int __devinit pcmcia_bus_add_socket(struct device *dev,
1329 if (ret) { 1331 if (ret) {
1330 dev_printk(KERN_ERR, dev, "PCMCIA registration failed\n"); 1332 dev_printk(KERN_ERR, dev, "PCMCIA registration failed\n");
1331 pcmcia_put_socket(socket); 1333 pcmcia_put_socket(socket);
1332 return (ret); 1334 return ret;
1333 } 1335 }
1334 1336
1335 return 0; 1337 return 0;
@@ -1400,7 +1402,7 @@ static int __init init_pcmcia_bus(void)
1400 1402
1401 return 0; 1403 return 0;
1402} 1404}
1403fs_initcall(init_pcmcia_bus); /* one level after subsys_initcall so that 1405fs_initcall(init_pcmcia_bus); /* one level after subsys_initcall so that
1404 * pcmcia_socket_class is already registered */ 1406 * pcmcia_socket_class is already registered */
1405 1407
1406 1408
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index c4d7908fa37f..f73fd5beaa37 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -88,12 +88,12 @@ static struct pcmcia_driver *get_pcmcia_driver(dev_info_t *dev_info)
88 88
89 p_drv = container_of(drv, struct pcmcia_driver, drv); 89 p_drv = container_of(drv, struct pcmcia_driver, drv);
90 90
91 return (p_drv); 91 return p_drv;
92} 92}
93 93
94 94
95#ifdef CONFIG_PROC_FS 95#ifdef CONFIG_PROC_FS
96static struct proc_dir_entry *proc_pccard = NULL; 96static struct proc_dir_entry *proc_pccard;
97 97
98static int proc_read_drivers_callback(struct device_driver *driver, void *_m) 98static int proc_read_drivers_callback(struct device_driver *driver, void *_m)
99{ 99{
@@ -158,7 +158,8 @@ static int adjust_irq(struct pcmcia_socket *s, adjust_t *adj)
158 158
159#else 159#else
160 160
161static inline int adjust_irq(struct pcmcia_socket *s, adjust_t *adj) { 161static inline int adjust_irq(struct pcmcia_socket *s, adjust_t *adj)
162{
162 return 0; 163 return 0;
163} 164}
164 165
@@ -195,7 +196,7 @@ static int pcmcia_adjust_resource_info(adjust_t *adj)
195 begin = adj->resource.memory.Base; 196 begin = adj->resource.memory.Base;
196 end = adj->resource.memory.Base + adj->resource.memory.Size - 1; 197 end = adj->resource.memory.Base + adj->resource.memory.Size - 1;
197 if (s->resource_ops->add_mem) 198 if (s->resource_ops->add_mem)
198 ret =s->resource_ops->add_mem(s, adj->Action, begin, end); 199 ret = s->resource_ops->add_mem(s, adj->Action, begin, end);
199 case RES_IO_RANGE: 200 case RES_IO_RANGE:
200 begin = adj->resource.io.BasePort; 201 begin = adj->resource.io.BasePort;
201 end = adj->resource.io.BasePort + adj->resource.io.NumPorts - 1; 202 end = adj->resource.io.BasePort + adj->resource.io.NumPorts - 1;
@@ -215,7 +216,7 @@ static int pcmcia_adjust_resource_info(adjust_t *adj)
215 } 216 }
216 up_read(&pcmcia_socket_list_rwsem); 217 up_read(&pcmcia_socket_list_rwsem);
217 218
218 return (ret); 219 return ret;
219} 220}
220 221
221 222
@@ -490,7 +491,7 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info)
490 } 491 }
491 492
492 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 493 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
493 list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { 494 list_for_each_entry(p_dev, &s->devices_list, socket_device_list) {
494 if (p_dev->func == bind_info->function) { 495 if (p_dev->func == bind_info->function) {
495 if ((p_dev->dev.driver == &p_drv->drv)) { 496 if ((p_dev->dev.driver == &p_drv->drv)) {
496 if (p_dev->cardmgr) { 497 if (p_dev->cardmgr) {
@@ -558,7 +559,7 @@ rescan:
558 err_put: 559 err_put:
559 pcmcia_put_socket(s); 560 pcmcia_put_socket(s);
560 561
561 return (ret); 562 return ret;
562} /* bind_request */ 563} /* bind_request */
563 564
564#ifdef CONFIG_CARDBUS 565#ifdef CONFIG_CARDBUS
@@ -655,7 +656,7 @@ static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int
655 656
656 err_put: 657 err_put:
657 pcmcia_put_dev(p_dev); 658 pcmcia_put_dev(p_dev);
658 return (ret); 659 return ret;
659} /* get_device_info */ 660} /* get_device_info */
660 661
661 662
@@ -664,7 +665,7 @@ static int ds_open(struct inode *inode, struct file *file)
664 socket_t i = iminor(inode); 665 socket_t i = iminor(inode);
665 struct pcmcia_socket *s; 666 struct pcmcia_socket *s;
666 user_info_t *user; 667 user_info_t *user;
667 static int warning_printed = 0; 668 static int warning_printed;
668 int ret = 0; 669 int ret = 0;
669 670
670 pr_debug("ds_open(socket %d)\n", i); 671 pr_debug("ds_open(socket %d)\n", i);
@@ -738,12 +739,13 @@ static int ds_release(struct inode *inode, struct file *file)
738 s = user->socket; 739 s = user->socket;
739 740
740 /* Unlink user data structure */ 741 /* Unlink user data structure */
741 if ((file->f_flags & O_ACCMODE) != O_RDONLY) { 742 if ((file->f_flags & O_ACCMODE) != O_RDONLY)
742 s->pcmcia_state.busy = 0; 743 s->pcmcia_state.busy = 0;
743 } 744
744 file->private_data = NULL; 745 file->private_data = NULL;
745 for (link = &s->user; *link; link = &(*link)->next) 746 for (link = &s->user; *link; link = &(*link)->next)
746 if (*link == user) break; 747 if (*link == user)
748 break;
747 if (link == NULL) 749 if (link == NULL)
748 goto out; 750 goto out;
749 *link = user->next; 751 *link = user->next;
@@ -774,7 +776,7 @@ static ssize_t ds_read(struct file *file, char __user *buf,
774 776
775 s = user->socket; 777 s = user->socket;
776 if (s->pcmcia_state.dead) 778 if (s->pcmcia_state.dead)
777 return -EIO; 779 return -EIO;
778 780
779 ret = wait_event_interruptible(s->queue, !queue_empty(user)); 781 ret = wait_event_interruptible(s->queue, !queue_empty(user));
780 if (ret == 0) 782 if (ret == 0)
@@ -824,7 +826,7 @@ static u_int ds_poll(struct file *file, poll_table *wait)
824 826
825/*====================================================================*/ 827/*====================================================================*/
826 828
827static int ds_ioctl(struct inode * inode, struct file * file, 829static int ds_ioctl(struct inode *inode, struct file *file,
828 u_int cmd, u_long arg) 830 u_int cmd, u_long arg)
829{ 831{
830 struct pcmcia_socket *s; 832 struct pcmcia_socket *s;
@@ -842,10 +844,11 @@ static int ds_ioctl(struct inode * inode, struct file * file,
842 844
843 s = user->socket; 845 s = user->socket;
844 if (s->pcmcia_state.dead) 846 if (s->pcmcia_state.dead)
845 return -EIO; 847 return -EIO;
846 848
847 size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT; 849 size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT;
848 if (size > sizeof(ds_ioctl_arg_t)) return -EINVAL; 850 if (size > sizeof(ds_ioctl_arg_t))
851 return -EINVAL;
849 852
850 /* Permission check */ 853 /* Permission check */
851 if (!(cmd & IOC_OUT) && !capable(CAP_SYS_ADMIN)) 854 if (!(cmd & IOC_OUT) && !capable(CAP_SYS_ADMIN))
@@ -1024,8 +1027,8 @@ static int ds_ioctl(struct inode * inode, struct file * file,
1024 } 1027 }
1025 1028
1026 if (cmd & IOC_OUT) { 1029 if (cmd & IOC_OUT) {
1027 if (__copy_to_user(uarg, (char *)buf, size)) 1030 if (__copy_to_user(uarg, (char *)buf, size))
1028 err = -EFAULT; 1031 err = -EFAULT;
1029 } 1032 }
1030 1033
1031free_out: 1034free_out:
@@ -1045,7 +1048,8 @@ static const struct file_operations ds_fops = {
1045 .poll = ds_poll, 1048 .poll = ds_poll,
1046}; 1049};
1047 1050
1048void __init pcmcia_setup_ioctl(void) { 1051void __init pcmcia_setup_ioctl(void)
1052{
1049 int i; 1053 int i;
1050 1054
1051 /* Set up character device for user mode clients */ 1055 /* Set up character device for user mode clients */
@@ -1064,7 +1068,8 @@ void __init pcmcia_setup_ioctl(void) {
1064} 1068}
1065 1069
1066 1070
1067void __exit pcmcia_cleanup_ioctl(void) { 1071void __exit pcmcia_cleanup_ioctl(void)
1072{
1068#ifdef CONFIG_PROC_FS 1073#ifdef CONFIG_PROC_FS
1069 if (proc_pccard) { 1074 if (proc_pccard) {
1070 remove_proc_entry("drivers", proc_pccard); 1075 remove_proc_entry("drivers", proc_pccard);
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index a8bf8c1b45ed..d5db95644b64 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -33,7 +33,7 @@
33 33
34 34
35/* Access speed for IO windows */ 35/* Access speed for IO windows */
36static int io_speed = 0; 36static int io_speed;
37module_param(io_speed, int, 0444); 37module_param(io_speed, int, 0444);
38 38
39 39
@@ -62,7 +62,8 @@ static int alloc_io_space(struct pcmcia_socket *s, u_int attr,
62 num, align); 62 num, align);
63 align = 0; 63 align = 0;
64 } else 64 } else
65 while (align && (align < num)) align <<= 1; 65 while (align && (align < num))
66 align <<= 1;
66 } 67 }
67 if (*base & ~(align-1)) { 68 if (*base & ~(align-1)) {
68 dev_dbg(&s->dev, "odd IO request: base %#x align %#x\n", 69 dev_dbg(&s->dev, "odd IO request: base %#x align %#x\n",
@@ -338,7 +339,7 @@ static int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req)
338 struct pcmcia_socket *s = p_dev->socket; 339 struct pcmcia_socket *s = p_dev->socket;
339 config_t *c = p_dev->function_config; 340 config_t *c = p_dev->function_config;
340 341
341 if (!p_dev->_io ) 342 if (!p_dev->_io)
342 return -EINVAL; 343 return -EINVAL;
343 344
344 p_dev->_io = 0; 345 p_dev->_io = 0;
@@ -362,7 +363,7 @@ static int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req)
362static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req) 363static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req)
363{ 364{
364 struct pcmcia_socket *s = p_dev->socket; 365 struct pcmcia_socket *s = p_dev->socket;
365 config_t *c= p_dev->function_config; 366 config_t *c = p_dev->function_config;
366 367
367 if (!p_dev->_irq) 368 if (!p_dev->_irq)
368 return -EINVAL; 369 return -EINVAL;
@@ -383,9 +384,8 @@ static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req)
383 s->irq.AssignedIRQ = 0; 384 s->irq.AssignedIRQ = 0;
384 } 385 }
385 386
386 if (req->Handler) { 387 if (req->Handler)
387 free_irq(req->AssignedIRQ, p_dev->priv); 388 free_irq(req->AssignedIRQ, p_dev->priv);
388 }
389 389
390#ifdef CONFIG_PCMCIA_PROBE 390#ifdef CONFIG_PCMCIA_PROBE
391 pcmcia_used_irq[req->AssignedIRQ]--; 391 pcmcia_used_irq[req->AssignedIRQ]--;
@@ -656,7 +656,8 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
656 type = IRQF_SHARED; 656 type = IRQF_SHARED;
657 else if (req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) 657 else if (req->Attributes & IRQ_TYPE_DYNAMIC_SHARING)
658 type = IRQF_SHARED; 658 type = IRQF_SHARED;
659 else printk(KERN_WARNING "pcmcia: Driver needs updating to support IRQ sharing.\n"); 659 else
660 printk(KERN_WARNING "pcmcia: Driver needs updating to support IRQ sharing.\n");
660 661
661#ifdef CONFIG_PCMCIA_PROBE 662#ifdef CONFIG_PCMCIA_PROBE
662 663
@@ -788,7 +789,8 @@ int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, window_ha
788 789
789 /* Allocate system memory window */ 790 /* Allocate system memory window */
790 for (w = 0; w < MAX_WIN; w++) 791 for (w = 0; w < MAX_WIN; w++)
791 if (!(s->state & SOCKET_WIN_REQ(w))) break; 792 if (!(s->state & SOCKET_WIN_REQ(w)))
793 break;
792 if (w == MAX_WIN) { 794 if (w == MAX_WIN) {
793 dev_dbg(&s->dev, "all windows are used already\n"); 795 dev_dbg(&s->dev, "all windows are used already\n");
794 return -EINVAL; 796 return -EINVAL;
@@ -826,18 +828,19 @@ int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, window_ha
826 s->state |= SOCKET_WIN_REQ(w); 828 s->state |= SOCKET_WIN_REQ(w);
827 829
828 /* Return window handle */ 830 /* Return window handle */
829 if (s->features & SS_CAP_STATIC_MAP) { 831 if (s->features & SS_CAP_STATIC_MAP)
830 req->Base = win->static_start; 832 req->Base = win->static_start;
831 } else { 833 else
832 req->Base = win->res->start; 834 req->Base = win->res->start;
833 } 835
834 *wh = w + 1; 836 *wh = w + 1;
835 837
836 return 0; 838 return 0;
837} /* pcmcia_request_window */ 839} /* pcmcia_request_window */
838EXPORT_SYMBOL(pcmcia_request_window); 840EXPORT_SYMBOL(pcmcia_request_window);
839 841
840void pcmcia_disable_device(struct pcmcia_device *p_dev) { 842void pcmcia_disable_device(struct pcmcia_device *p_dev)
843{
841 pcmcia_release_configuration(p_dev); 844 pcmcia_release_configuration(p_dev);
842 pcmcia_release_io(p_dev, &p_dev->io); 845 pcmcia_release_io(p_dev, &p_dev->io);
843 pcmcia_release_irq(p_dev, &p_dev->irq); 846 pcmcia_release_irq(p_dev, &p_dev->irq);
@@ -970,7 +973,7 @@ int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code,
970 973
971 return pccard_loop_tuple(p_dev->socket, p_dev->func, code, NULL, 974 return pccard_loop_tuple(p_dev->socket, p_dev->func, code, NULL,
972 &loop, pcmcia_do_loop_tuple); 975 &loop, pcmcia_do_loop_tuple);
973}; 976}
974EXPORT_SYMBOL(pcmcia_loop_tuple); 977EXPORT_SYMBOL(pcmcia_loop_tuple);
975 978
976 979
@@ -1000,7 +1003,7 @@ static int pcmcia_do_get_tuple(struct pcmcia_device *p_dev, tuple_t *tuple,
1000 } else 1003 } else
1001 dev_dbg(&p_dev->dev, "do_get_tuple: out of memory\n"); 1004 dev_dbg(&p_dev->dev, "do_get_tuple: out of memory\n");
1002 return 0; 1005 return 0;
1003}; 1006}
1004 1007
1005/** 1008/**
1006 * pcmcia_get_tuple() - get first tuple from CIS 1009 * pcmcia_get_tuple() - get first tuple from CIS
@@ -1024,7 +1027,7 @@ size_t pcmcia_get_tuple(struct pcmcia_device *p_dev, cisdata_t code,
1024 pcmcia_loop_tuple(p_dev, code, pcmcia_do_get_tuple, &get); 1027 pcmcia_loop_tuple(p_dev, code, pcmcia_do_get_tuple, &get);
1025 1028
1026 return get.len; 1029 return get.len;
1027}; 1030}
1028EXPORT_SYMBOL(pcmcia_get_tuple); 1031EXPORT_SYMBOL(pcmcia_get_tuple);
1029 1032
1030 1033
@@ -1057,7 +1060,7 @@ static int pcmcia_do_get_mac(struct pcmcia_device *p_dev, tuple_t *tuple,
1057 for (i = 0; i < 6; i++) 1060 for (i = 0; i < 6; i++)
1058 dev->dev_addr[i] = tuple->TupleData[i+2]; 1061 dev->dev_addr[i] = tuple->TupleData[i+2];
1059 return 0; 1062 return 0;
1060}; 1063}
1061 1064
1062/** 1065/**
1063 * pcmcia_get_mac_from_cis() - read out MAC address from CISTPL_FUNCE 1066 * pcmcia_get_mac_from_cis() - read out MAC address from CISTPL_FUNCE
@@ -1071,6 +1074,6 @@ static int pcmcia_do_get_mac(struct pcmcia_device *p_dev, tuple_t *tuple,
1071int pcmcia_get_mac_from_cis(struct pcmcia_device *p_dev, struct net_device *dev) 1074int pcmcia_get_mac_from_cis(struct pcmcia_device *p_dev, struct net_device *dev)
1072{ 1075{
1073 return pcmcia_loop_tuple(p_dev, CISTPL_FUNCE, pcmcia_do_get_mac, dev); 1076 return pcmcia_loop_tuple(p_dev, CISTPL_FUNCE, pcmcia_do_get_mac, dev);
1074}; 1077}
1075EXPORT_SYMBOL(pcmcia_get_mac_from_cis); 1078EXPORT_SYMBOL(pcmcia_get_mac_from_cis);
1076 1079
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index 84dde7768ad5..da346eb7e77e 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -214,7 +214,8 @@ static void pxa2xx_configure_sockets(struct device *dev)
214 MECR |= MECR_CIT; 214 MECR |= MECR_CIT;
215 215
216 /* Set MECR:NOS (Number Of Sockets) */ 216 /* Set MECR:NOS (Number Of Sockets) */
217 if ((ops->first + ops->nr) > 1 || machine_is_viper()) 217 if ((ops->first + ops->nr) > 1 ||
218 machine_is_viper() || machine_is_arcom_zeus())
218 MECR |= MECR_NOS; 219 MECR |= MECR_NOS;
219 else 220 else
220 MECR &= ~MECR_NOS; 221 MECR &= ~MECR_NOS;
@@ -252,6 +253,7 @@ int pxa2xx_drv_pcmcia_add_one(struct soc_pcmcia_socket *skt)
252 253
253 return soc_pcmcia_add_one(skt); 254 return soc_pcmcia_add_one(skt);
254} 255}
256EXPORT_SYMBOL(pxa2xx_drv_pcmcia_add_one);
255 257
256void pxa2xx_drv_pcmcia_ops(struct pcmcia_low_level *ops) 258void pxa2xx_drv_pcmcia_ops(struct pcmcia_low_level *ops)
257{ 259{
@@ -261,19 +263,19 @@ void pxa2xx_drv_pcmcia_ops(struct pcmcia_low_level *ops)
261 ops->frequency_change = pxa2xx_pcmcia_frequency_change; 263 ops->frequency_change = pxa2xx_pcmcia_frequency_change;
262#endif 264#endif
263} 265}
266EXPORT_SYMBOL(pxa2xx_drv_pcmcia_ops);
264 267
265int __pxa2xx_drv_pcmcia_probe(struct device *dev) 268static int pxa2xx_drv_pcmcia_probe(struct platform_device *dev)
266{ 269{
267 int i, ret = 0; 270 int i, ret = 0;
268 struct pcmcia_low_level *ops; 271 struct pcmcia_low_level *ops;
269 struct skt_dev_info *sinfo; 272 struct skt_dev_info *sinfo;
270 struct soc_pcmcia_socket *skt; 273 struct soc_pcmcia_socket *skt;
271 274
272 if (!dev || !dev->platform_data) 275 ops = (struct pcmcia_low_level *)dev->dev.platform_data;
276 if (!ops)
273 return -ENODEV; 277 return -ENODEV;
274 278
275 ops = (struct pcmcia_low_level *)dev->platform_data;
276
277 pxa2xx_drv_pcmcia_ops(ops); 279 pxa2xx_drv_pcmcia_ops(ops);
278 280
279 sinfo = kzalloc(SKT_DEV_INFO_SIZE(ops->nr), GFP_KERNEL); 281 sinfo = kzalloc(SKT_DEV_INFO_SIZE(ops->nr), GFP_KERNEL);
@@ -308,13 +310,6 @@ int __pxa2xx_drv_pcmcia_probe(struct device *dev)
308 310
309 return ret; 311 return ret;
310} 312}
311EXPORT_SYMBOL(__pxa2xx_drv_pcmcia_probe);
312
313
314static int pxa2xx_drv_pcmcia_probe(struct platform_device *dev)
315{
316 return __pxa2xx_drv_pcmcia_probe(&dev->dev);
317}
318 313
319static int pxa2xx_drv_pcmcia_remove(struct platform_device *dev) 314static int pxa2xx_drv_pcmcia_remove(struct platform_device *dev)
320{ 315{
diff --git a/drivers/pcmcia/pxa2xx_base.h b/drivers/pcmcia/pxa2xx_base.h
index cb5efaec886f..bb62ea87b8f9 100644
--- a/drivers/pcmcia/pxa2xx_base.h
+++ b/drivers/pcmcia/pxa2xx_base.h
@@ -1,6 +1,3 @@
1/* temporary measure */
2extern int __pxa2xx_drv_pcmcia_probe(struct device *);
3
4int pxa2xx_drv_pcmcia_add_one(struct soc_pcmcia_socket *skt); 1int pxa2xx_drv_pcmcia_add_one(struct soc_pcmcia_socket *skt);
5void pxa2xx_drv_pcmcia_ops(struct pcmcia_low_level *ops); 2void pxa2xx_drv_pcmcia_ops(struct pcmcia_low_level *ops);
6 3
diff --git a/drivers/pcmcia/pxa2xx_palmtc.c b/drivers/pcmcia/pxa2xx_palmtc.c
index 3a8993ed5621..459a232d66be 100644
--- a/drivers/pcmcia/pxa2xx_palmtc.c
+++ b/drivers/pcmcia/pxa2xx_palmtc.c
@@ -67,7 +67,7 @@ static int palmtc_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
67 if (ret) 67 if (ret)
68 goto err7; 68 goto err7;
69 69
70 skt->irq = IRQ_GPIO(GPIO_NR_PALMTC_PCMCIA_READY); 70 skt->socket.pci_irq = IRQ_GPIO(GPIO_NR_PALMTC_PCMCIA_READY);
71 return 0; 71 return 0;
72 72
73err7: 73err7:
diff --git a/drivers/pcmcia/pxa2xx_stargate2.c b/drivers/pcmcia/pxa2xx_stargate2.c
index 490749ea677f..d08802fe35f9 100644
--- a/drivers/pcmcia/pxa2xx_stargate2.c
+++ b/drivers/pcmcia/pxa2xx_stargate2.c
@@ -40,7 +40,7 @@ static struct pcmcia_irqs irqs[] = {
40 40
41static int sg2_pcmcia_hw_init(struct soc_pcmcia_socket *skt) 41static int sg2_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
42{ 42{
43 skt->irq = IRQ_GPIO(SG2_S0_GPIO_READY); 43 skt->socket.pci_irq = IRQ_GPIO(SG2_S0_GPIO_READY);
44 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs)); 44 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
45} 45}
46 46
diff --git a/drivers/pcmcia/pxa2xx_viper.c b/drivers/pcmcia/pxa2xx_viper.c
index 27be2e154df2..a51f2077644a 100644
--- a/drivers/pcmcia/pxa2xx_viper.c
+++ b/drivers/pcmcia/pxa2xx_viper.c
@@ -1,9 +1,8 @@
1/* 1/*
2 * VIPER PCMCIA support 2 * Viper/Zeus PCMCIA support
3 * Copyright 2004 Arcom Control Systems 3 * Copyright 2004 Arcom Control Systems
4 * 4 *
5 * Maintained by Marc Zyngier <maz@misterjones.org> 5 * Maintained by Marc Zyngier <maz@misterjones.org>
6 * <marc.zyngier@altran.com>
7 * 6 *
8 * Based on: 7 * Based on:
9 * iPAQ h2200 PCMCIA support 8 * iPAQ h2200 PCMCIA support
@@ -26,37 +25,47 @@
26 25
27#include <asm/irq.h> 26#include <asm/irq.h>
28 27
29#include <mach/viper.h> 28#include <mach/arcom-pcmcia.h>
30#include <asm/mach-types.h>
31 29
32#include "soc_common.h" 30#include "soc_common.h"
33#include "pxa2xx_base.h" 31#include "pxa2xx_base.h"
34 32
33static struct platform_device *arcom_pcmcia_dev;
34
35static struct pcmcia_irqs irqs[] = { 35static struct pcmcia_irqs irqs[] = {
36 { 0, gpio_to_irq(VIPER_CF_CD_GPIO), "PCMCIA_CD" } 36 {
37 .sock = 0,
38 .str = "PCMCIA_CD",
39 },
37}; 40};
38 41
42static inline struct arcom_pcmcia_pdata *viper_get_pdata(void)
43{
44 return arcom_pcmcia_dev->dev.platform_data;
45}
46
39static int viper_pcmcia_hw_init(struct soc_pcmcia_socket *skt) 47static int viper_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
40{ 48{
49 struct arcom_pcmcia_pdata *pdata = viper_get_pdata();
41 unsigned long flags; 50 unsigned long flags;
42 51
43 skt->socket.pci_irq = gpio_to_irq(VIPER_CF_RDY_GPIO); 52 skt->socket.pci_irq = gpio_to_irq(pdata->rdy_gpio);
53 irqs[0].irq = gpio_to_irq(pdata->cd_gpio);
44 54
45 if (gpio_request(VIPER_CF_CD_GPIO, "CF detect")) 55 if (gpio_request(pdata->cd_gpio, "CF detect"))
46 goto err_request_cd; 56 goto err_request_cd;
47 57
48 if (gpio_request(VIPER_CF_RDY_GPIO, "CF ready")) 58 if (gpio_request(pdata->rdy_gpio, "CF ready"))
49 goto err_request_rdy; 59 goto err_request_rdy;
50 60
51 if (gpio_request(VIPER_CF_POWER_GPIO, "CF power")) 61 if (gpio_request(pdata->pwr_gpio, "CF power"))
52 goto err_request_pwr; 62 goto err_request_pwr;
53 63
54 local_irq_save(flags); 64 local_irq_save(flags);
55 65
56 /* GPIO 82 is the CF power enable line. initially off */ 66 if (gpio_direction_output(pdata->pwr_gpio, 0) ||
57 if (gpio_direction_output(VIPER_CF_POWER_GPIO, 0) || 67 gpio_direction_input(pdata->cd_gpio) ||
58 gpio_direction_input(VIPER_CF_CD_GPIO) || 68 gpio_direction_input(pdata->rdy_gpio)) {
59 gpio_direction_input(VIPER_CF_RDY_GPIO)) {
60 local_irq_restore(flags); 69 local_irq_restore(flags);
61 goto err_dir; 70 goto err_dir;
62 } 71 }
@@ -66,13 +75,13 @@ static int viper_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
66 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs)); 75 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
67 76
68err_dir: 77err_dir:
69 gpio_free(VIPER_CF_POWER_GPIO); 78 gpio_free(pdata->pwr_gpio);
70err_request_pwr: 79err_request_pwr:
71 gpio_free(VIPER_CF_RDY_GPIO); 80 gpio_free(pdata->rdy_gpio);
72err_request_rdy: 81err_request_rdy:
73 gpio_free(VIPER_CF_CD_GPIO); 82 gpio_free(pdata->cd_gpio);
74err_request_cd: 83err_request_cd:
75 printk(KERN_ERR "viper: Failed to setup PCMCIA GPIOs\n"); 84 dev_err(&arcom_pcmcia_dev->dev, "Failed to setup PCMCIA GPIOs\n");
76 return -1; 85 return -1;
77} 86}
78 87
@@ -81,17 +90,21 @@ err_request_cd:
81 */ 90 */
82static void viper_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) 91static void viper_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
83{ 92{
93 struct arcom_pcmcia_pdata *pdata = viper_get_pdata();
94
84 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs)); 95 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
85 gpio_free(VIPER_CF_POWER_GPIO); 96 gpio_free(pdata->pwr_gpio);
86 gpio_free(VIPER_CF_RDY_GPIO); 97 gpio_free(pdata->rdy_gpio);
87 gpio_free(VIPER_CF_CD_GPIO); 98 gpio_free(pdata->cd_gpio);
88} 99}
89 100
90static void viper_pcmcia_socket_state(struct soc_pcmcia_socket *skt, 101static void viper_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
91 struct pcmcia_state *state) 102 struct pcmcia_state *state)
92{ 103{
93 state->detect = gpio_get_value(VIPER_CF_CD_GPIO) ? 0 : 1; 104 struct arcom_pcmcia_pdata *pdata = viper_get_pdata();
94 state->ready = gpio_get_value(VIPER_CF_RDY_GPIO) ? 1 : 0; 105
106 state->detect = !gpio_get_value(pdata->cd_gpio);
107 state->ready = !!gpio_get_value(pdata->rdy_gpio);
95 state->bvd1 = 1; 108 state->bvd1 = 1;
96 state->bvd2 = 1; 109 state->bvd2 = 1;
97 state->wrprot = 0; 110 state->wrprot = 0;
@@ -102,20 +115,21 @@ static void viper_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
102static int viper_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, 115static int viper_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
103 const socket_state_t *state) 116 const socket_state_t *state)
104{ 117{
118 struct arcom_pcmcia_pdata *pdata = viper_get_pdata();
119
105 /* Silently ignore Vpp, output enable, speaker enable. */ 120 /* Silently ignore Vpp, output enable, speaker enable. */
106 viper_cf_rst(state->flags & SS_RESET); 121 pdata->reset(state->flags & SS_RESET);
107 122
108 /* Apply socket voltage */ 123 /* Apply socket voltage */
109 switch (state->Vcc) { 124 switch (state->Vcc) {
110 case 0: 125 case 0:
111 gpio_set_value(VIPER_CF_POWER_GPIO, 0); 126 gpio_set_value(pdata->pwr_gpio, 0);
112 break; 127 break;
113 case 33: 128 case 33:
114 gpio_set_value(VIPER_CF_POWER_GPIO, 1); 129 gpio_set_value(pdata->pwr_gpio, 1);
115 break; 130 break;
116 default: 131 default:
117 printk(KERN_ERR "%s: Unsupported Vcc:%d\n", 132 dev_err(&arcom_pcmcia_dev->dev, "Unsupported Vcc:%d\n", state->Vcc);
118 __func__, state->Vcc);
119 return -1; 133 return -1;
120 } 134 }
121 135
@@ -130,7 +144,7 @@ static void viper_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
130{ 144{
131} 145}
132 146
133static struct pcmcia_low_level viper_pcmcia_ops __initdata = { 147static struct pcmcia_low_level viper_pcmcia_ops = {
134 .owner = THIS_MODULE, 148 .owner = THIS_MODULE,
135 .hw_init = viper_pcmcia_hw_init, 149 .hw_init = viper_pcmcia_hw_init,
136 .hw_shutdown = viper_pcmcia_hw_shutdown, 150 .hw_shutdown = viper_pcmcia_hw_shutdown,
@@ -143,17 +157,25 @@ static struct pcmcia_low_level viper_pcmcia_ops __initdata = {
143 157
144static struct platform_device *viper_pcmcia_device; 158static struct platform_device *viper_pcmcia_device;
145 159
146static int __init viper_pcmcia_init(void) 160static int viper_pcmcia_probe(struct platform_device *pdev)
147{ 161{
148 int ret; 162 int ret;
149 163
150 if (!machine_is_viper()) 164 /* I can't imagine more than one device, but you never know... */
151 return -ENODEV; 165 if (arcom_pcmcia_dev)
166 return -EEXIST;
167
168 if (!pdev->dev.platform_data)
169 return -EINVAL;
152 170
153 viper_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); 171 viper_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
154 if (!viper_pcmcia_device) 172 if (!viper_pcmcia_device)
155 return -ENOMEM; 173 return -ENOMEM;
156 174
175 arcom_pcmcia_dev = pdev;
176
177 viper_pcmcia_device->dev.parent = &pdev->dev;
178
157 ret = platform_device_add_data(viper_pcmcia_device, 179 ret = platform_device_add_data(viper_pcmcia_device,
158 &viper_pcmcia_ops, 180 &viper_pcmcia_ops,
159 sizeof(viper_pcmcia_ops)); 181 sizeof(viper_pcmcia_ops));
@@ -161,18 +183,49 @@ static int __init viper_pcmcia_init(void)
161 if (!ret) 183 if (!ret)
162 ret = platform_device_add(viper_pcmcia_device); 184 ret = platform_device_add(viper_pcmcia_device);
163 185
164 if (ret) 186 if (ret) {
165 platform_device_put(viper_pcmcia_device); 187 platform_device_put(viper_pcmcia_device);
188 arcom_pcmcia_dev = NULL;
189 }
166 190
167 return ret; 191 return ret;
168} 192}
169 193
170static void __exit viper_pcmcia_exit(void) 194static int viper_pcmcia_remove(struct platform_device *pdev)
171{ 195{
172 platform_device_unregister(viper_pcmcia_device); 196 platform_device_unregister(viper_pcmcia_device);
197 arcom_pcmcia_dev = NULL;
198 return 0;
199}
200
201static struct platform_device_id viper_pcmcia_id_table[] = {
202 { .name = "viper-pcmcia", },
203 { .name = "zeus-pcmcia", },
204 { },
205};
206
207static struct platform_driver viper_pcmcia_driver = {
208 .probe = viper_pcmcia_probe,
209 .remove = viper_pcmcia_remove,
210 .driver = {
211 .name = "arcom-pcmcia",
212 .owner = THIS_MODULE,
213 },
214 .id_table = viper_pcmcia_id_table,
215};
216
217static int __init viper_pcmcia_init(void)
218{
219 return platform_driver_register(&viper_pcmcia_driver);
220}
221
222static void __exit viper_pcmcia_exit(void)
223{
224 return platform_driver_unregister(&viper_pcmcia_driver);
173} 225}
174 226
175module_init(viper_pcmcia_init); 227module_init(viper_pcmcia_init);
176module_exit(viper_pcmcia_exit); 228module_exit(viper_pcmcia_exit);
177 229
230MODULE_DEVICE_TABLE(platform, viper_pcmcia_id_table);
178MODULE_LICENSE("GPL"); 231MODULE_LICENSE("GPL");
diff --git a/drivers/pcmcia/rsrc_mgr.c b/drivers/pcmcia/rsrc_mgr.c
index de0e770ce6a3..52db17263d8b 100644
--- a/drivers/pcmcia/rsrc_mgr.c
+++ b/drivers/pcmcia/rsrc_mgr.c
@@ -126,16 +126,16 @@ static void pcmcia_align(void *align_data, struct resource *res,
126 res->start = start; 126 res->start = start;
127 127
128#ifdef CONFIG_X86 128#ifdef CONFIG_X86
129 if (res->flags & IORESOURCE_IO) { 129 if (res->flags & IORESOURCE_IO) {
130 if (start & 0x300) { 130 if (start & 0x300) {
131 start = (start + 0x3ff) & ~0x3ff; 131 start = (start + 0x3ff) & ~0x3ff;
132 res->start = start; 132 res->start = start;
133 } 133 }
134 } 134 }
135#endif 135#endif
136 136
137#ifdef CONFIG_M68K 137#ifdef CONFIG_M68K
138 if (res->flags & IORESOURCE_IO) { 138 if (res->flags & IORESOURCE_IO) {
139 if ((res->start + size - 1) >= 1024) 139 if ((res->start + size - 1) >= 1024)
140 res->start = res->end; 140 res->start = res->end;
141 } 141 }
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index 7039f3cf5b77..9b0dc433a8c3 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -24,9 +24,9 @@
24#include <linux/timer.h> 24#include <linux/timer.h>
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/device.h> 26#include <linux/device.h>
27#include <linux/io.h>
27 28
28#include <asm/irq.h> 29#include <asm/irq.h>
29#include <asm/io.h>
30 30
31#include <pcmcia/cs_types.h> 31#include <pcmcia/cs_types.h>
32#include <pcmcia/ss.h> 32#include <pcmcia/ss.h>
@@ -144,43 +144,44 @@ static int add_interval(struct resource_map *map, u_long base, u_long num)
144 144
145static int sub_interval(struct resource_map *map, u_long base, u_long num) 145static int sub_interval(struct resource_map *map, u_long base, u_long num)
146{ 146{
147 struct resource_map *p, *q; 147 struct resource_map *p, *q;
148 148
149 for (p = map; ; p = q) { 149 for (p = map; ; p = q) {
150 q = p->next; 150 q = p->next;
151 if (q == map) 151 if (q == map)
152 break; 152 break;
153 if ((q->base+q->num > base) && (base+num > q->base)) { 153 if ((q->base+q->num > base) && (base+num > q->base)) {
154 if (q->base >= base) { 154 if (q->base >= base) {
155 if (q->base+q->num <= base+num) { 155 if (q->base+q->num <= base+num) {
156 /* Delete whole block */ 156 /* Delete whole block */
157 p->next = q->next; 157 p->next = q->next;
158 kfree(q); 158 kfree(q);
159 /* don't advance the pointer yet */ 159 /* don't advance the pointer yet */
160 q = p; 160 q = p;
161 } else { 161 } else {
162 /* Cut off bit from the front */ 162 /* Cut off bit from the front */
163 q->num = q->base + q->num - base - num; 163 q->num = q->base + q->num - base - num;
164 q->base = base + num; 164 q->base = base + num;
165 } 165 }
166 } else if (q->base+q->num <= base+num) { 166 } else if (q->base+q->num <= base+num) {
167 /* Cut off bit from the end */ 167 /* Cut off bit from the end */
168 q->num = base - q->base; 168 q->num = base - q->base;
169 } else { 169 } else {
170 /* Split the block into two pieces */ 170 /* Split the block into two pieces */
171 p = kmalloc(sizeof(struct resource_map), GFP_KERNEL); 171 p = kmalloc(sizeof(struct resource_map),
172 if (!p) { 172 GFP_KERNEL);
173 printk(KERN_WARNING "out of memory to update resources\n"); 173 if (!p) {
174 return -ENOMEM; 174 printk(KERN_WARNING "out of memory to update resources\n");
175 return -ENOMEM;
176 }
177 p->base = base+num;
178 p->num = q->base+q->num - p->base;
179 q->num = base - q->base;
180 p->next = q->next ; q->next = p;
181 }
175 } 182 }
176 p->base = base+num;
177 p->num = q->base+q->num - p->base;
178 q->num = base - q->base;
179 p->next = q->next ; q->next = p;
180 }
181 } 183 }
182 } 184 return 0;
183 return 0;
184} 185}
185 186
186/*====================================================================== 187/*======================================================================
@@ -194,69 +195,72 @@ static int sub_interval(struct resource_map *map, u_long base, u_long num)
194static void do_io_probe(struct pcmcia_socket *s, unsigned int base, 195static void do_io_probe(struct pcmcia_socket *s, unsigned int base,
195 unsigned int num) 196 unsigned int num)
196{ 197{
197 struct resource *res; 198 struct resource *res;
198 struct socket_data *s_data = s->resource_data; 199 struct socket_data *s_data = s->resource_data;
199 unsigned int i, j, bad; 200 unsigned int i, j, bad;
200 int any; 201 int any;
201 u_char *b, hole, most; 202 u_char *b, hole, most;
202 203
203 dev_printk(KERN_INFO, &s->dev, "cs: IO port probe %#x-%#x:", 204 dev_printk(KERN_INFO, &s->dev, "cs: IO port probe %#x-%#x:",
204 base, base+num-1); 205 base, base+num-1);
205 206
206 /* First, what does a floating port look like? */ 207 /* First, what does a floating port look like? */
207 b = kzalloc(256, GFP_KERNEL); 208 b = kzalloc(256, GFP_KERNEL);
208 if (!b) { 209 if (!b) {
209 printk("\n"); 210 printk("\n");
210 dev_printk(KERN_ERR, &s->dev, 211 dev_printk(KERN_ERR, &s->dev,
211 "do_io_probe: unable to kmalloc 256 bytes"); 212 "do_io_probe: unable to kmalloc 256 bytes");
212 return; 213 return;
213 }
214 for (i = base, most = 0; i < base+num; i += 8) {
215 res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA IO probe");
216 if (!res)
217 continue;
218 hole = inb(i);
219 for (j = 1; j < 8; j++)
220 if (inb(i+j) != hole) break;
221 free_region(res);
222 if ((j == 8) && (++b[hole] > b[most]))
223 most = hole;
224 if (b[most] == 127) break;
225 }
226 kfree(b);
227
228 bad = any = 0;
229 for (i = base; i < base+num; i += 8) {
230 res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA IO probe");
231 if (!res)
232 continue;
233 for (j = 0; j < 8; j++)
234 if (inb(i+j) != most) break;
235 free_region(res);
236 if (j < 8) {
237 if (!any)
238 printk(" excluding");
239 if (!bad)
240 bad = any = i;
241 } else {
242 if (bad) {
243 sub_interval(&s_data->io_db, bad, i-bad);
244 printk(" %#x-%#x", bad, i-1);
245 bad = 0;
246 }
247 } 214 }
248 } 215 for (i = base, most = 0; i < base+num; i += 8) {
249 if (bad) { 216 res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA ioprobe");
250 if ((num > 16) && (bad == base) && (i == base+num)) { 217 if (!res)
251 printk(" nothing: probe failed.\n"); 218 continue;
252 return; 219 hole = inb(i);
253 } else { 220 for (j = 1; j < 8; j++)
254 sub_interval(&s_data->io_db, bad, i-bad); 221 if (inb(i+j) != hole)
255 printk(" %#x-%#x", bad, i-1); 222 break;
223 free_region(res);
224 if ((j == 8) && (++b[hole] > b[most]))
225 most = hole;
226 if (b[most] == 127)
227 break;
256 } 228 }
257 } 229 kfree(b);
258 230
259 printk(any ? "\n" : " clean.\n"); 231 bad = any = 0;
232 for (i = base; i < base+num; i += 8) {
233 res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA ioprobe");
234 if (!res)
235 continue;
236 for (j = 0; j < 8; j++)
237 if (inb(i+j) != most)
238 break;
239 free_region(res);
240 if (j < 8) {
241 if (!any)
242 printk(" excluding");
243 if (!bad)
244 bad = any = i;
245 } else {
246 if (bad) {
247 sub_interval(&s_data->io_db, bad, i-bad);
248 printk(" %#x-%#x", bad, i-1);
249 bad = 0;
250 }
251 }
252 }
253 if (bad) {
254 if ((num > 16) && (bad == base) && (i == base+num)) {
255 printk(" nothing: probe failed.\n");
256 return;
257 } else {
258 sub_interval(&s_data->io_db, bad, i-bad);
259 printk(" %#x-%#x", bad, i-1);
260 }
261 }
262
263 printk(any ? "\n" : " clean.\n");
260} 264}
261#endif 265#endif
262 266
@@ -327,8 +331,9 @@ cis_readable(struct pcmcia_socket *s, unsigned long base, unsigned long size)
327 unsigned int info1, info2; 331 unsigned int info1, info2;
328 int ret = 0; 332 int ret = 0;
329 333
330 res1 = claim_region(s, base, size/2, IORESOURCE_MEM, "cs memory probe"); 334 res1 = claim_region(s, base, size/2, IORESOURCE_MEM, "PCMCIA memprobe");
331 res2 = claim_region(s, base + size/2, size/2, IORESOURCE_MEM, "cs memory probe"); 335 res2 = claim_region(s, base + size/2, size/2, IORESOURCE_MEM,
336 "PCMCIA memprobe");
332 337
333 if (res1 && res2) { 338 if (res1 && res2) {
334 ret = readable(s, res1, &info1); 339 ret = readable(s, res1, &info1);
@@ -347,8 +352,9 @@ checksum_match(struct pcmcia_socket *s, unsigned long base, unsigned long size)
347 struct resource *res1, *res2; 352 struct resource *res1, *res2;
348 int a = -1, b = -1; 353 int a = -1, b = -1;
349 354
350 res1 = claim_region(s, base, size/2, IORESOURCE_MEM, "cs memory probe"); 355 res1 = claim_region(s, base, size/2, IORESOURCE_MEM, "PCMCIA memprobe");
351 res2 = claim_region(s, base + size/2, size/2, IORESOURCE_MEM, "cs memory probe"); 356 res2 = claim_region(s, base + size/2, size/2, IORESOURCE_MEM,
357 "PCMCIA memprobe");
352 358
353 if (res1 && res2) { 359 if (res1 && res2) {
354 a = checksum(s, res1); 360 a = checksum(s, res1);
@@ -371,42 +377,43 @@ checksum_match(struct pcmcia_socket *s, unsigned long base, unsigned long size)
371 377
372static int do_mem_probe(u_long base, u_long num, struct pcmcia_socket *s) 378static int do_mem_probe(u_long base, u_long num, struct pcmcia_socket *s)
373{ 379{
374 struct socket_data *s_data = s->resource_data; 380 struct socket_data *s_data = s->resource_data;
375 u_long i, j, bad, fail, step; 381 u_long i, j, bad, fail, step;
376 382
377 dev_printk(KERN_INFO, &s->dev, "cs: memory probe 0x%06lx-0x%06lx:", 383 dev_printk(KERN_INFO, &s->dev, "cs: memory probe 0x%06lx-0x%06lx:",
378 base, base+num-1); 384 base, base+num-1);
379 bad = fail = 0; 385 bad = fail = 0;
380 step = (num < 0x20000) ? 0x2000 : ((num>>4) & ~0x1fff); 386 step = (num < 0x20000) ? 0x2000 : ((num>>4) & ~0x1fff);
381 /* don't allow too large steps */ 387 /* don't allow too large steps */
382 if (step > 0x800000) 388 if (step > 0x800000)
383 step = 0x800000; 389 step = 0x800000;
384 /* cis_readable wants to map 2x map_size */ 390 /* cis_readable wants to map 2x map_size */
385 if (step < 2 * s->map_size) 391 if (step < 2 * s->map_size)
386 step = 2 * s->map_size; 392 step = 2 * s->map_size;
387 for (i = j = base; i < base+num; i = j + step) { 393 for (i = j = base; i < base+num; i = j + step) {
388 if (!fail) { 394 if (!fail) {
389 for (j = i; j < base+num; j += step) { 395 for (j = i; j < base+num; j += step) {
390 if (cis_readable(s, j, step)) 396 if (cis_readable(s, j, step))
391 break; 397 break;
392 } 398 }
393 fail = ((i == base) && (j == base+num)); 399 fail = ((i == base) && (j == base+num));
394 } 400 }
395 if (fail) { 401 if (fail) {
396 for (j = i; j < base+num; j += 2*step) 402 for (j = i; j < base+num; j += 2*step)
397 if (checksum_match(s, j, step) && 403 if (checksum_match(s, j, step) &&
398 checksum_match(s, j + step, step)) 404 checksum_match(s, j + step, step))
399 break; 405 break;
400 } 406 }
401 if (i != j) { 407 if (i != j) {
402 if (!bad) printk(" excluding"); 408 if (!bad)
403 printk(" %#05lx-%#05lx", i, j-1); 409 printk(" excluding");
404 sub_interval(&s_data->mem_db, i, j-i); 410 printk(" %#05lx-%#05lx", i, j-1);
405 bad += j-i; 411 sub_interval(&s_data->mem_db, i, j-i);
412 bad += j-i;
413 }
406 } 414 }
407 } 415 printk(bad ? "\n" : " clean.\n");
408 printk(bad ? "\n" : " clean.\n"); 416 return num - bad;
409 return (num - bad);
410} 417}
411 418
412#ifdef CONFIG_PCMCIA_PROBE 419#ifdef CONFIG_PCMCIA_PROBE
@@ -656,7 +663,7 @@ static struct resource *nonstatic_find_io_region(unsigned long base, int num,
656 return res; 663 return res;
657} 664}
658 665
659static struct resource * nonstatic_find_mem_region(u_long base, u_long num, 666static struct resource *nonstatic_find_mem_region(u_long base, u_long num,
660 u_long align, int low, struct pcmcia_socket *s) 667 u_long align, int low, struct pcmcia_socket *s)
661{ 668{
662 struct resource *res = make_resource(0, num, IORESOURCE_MEM, dev_name(&s->dev)); 669 struct resource *res = make_resource(0, num, IORESOURCE_MEM, dev_name(&s->dev));
@@ -794,7 +801,7 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
794 return -EINVAL; 801 return -EINVAL;
795#endif 802#endif
796 803
797 for (i=0; i < PCI_BUS_NUM_RESOURCES; i++) { 804 for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
798 res = s->cb_dev->bus->resource[i]; 805 res = s->cb_dev->bus->resource[i];
799 if (!res) 806 if (!res)
800 continue; 807 continue;
@@ -908,14 +915,14 @@ static ssize_t show_io_db(struct device *dev,
908 for (p = data->io_db.next; p != &data->io_db; p = p->next) { 915 for (p = data->io_db.next; p != &data->io_db; p = p->next) {
909 if (ret > (PAGE_SIZE - 10)) 916 if (ret > (PAGE_SIZE - 10))
910 continue; 917 continue;
911 ret += snprintf (&buf[ret], (PAGE_SIZE - ret - 1), 918 ret += snprintf(&buf[ret], (PAGE_SIZE - ret - 1),
912 "0x%08lx - 0x%08lx\n", 919 "0x%08lx - 0x%08lx\n",
913 ((unsigned long) p->base), 920 ((unsigned long) p->base),
914 ((unsigned long) p->base + p->num - 1)); 921 ((unsigned long) p->base + p->num - 1));
915 } 922 }
916 923
917 mutex_unlock(&rsrc_mutex); 924 mutex_unlock(&rsrc_mutex);
918 return (ret); 925 return ret;
919} 926}
920 927
921static ssize_t store_io_db(struct device *dev, 928static ssize_t store_io_db(struct device *dev,
@@ -927,12 +934,13 @@ static ssize_t store_io_db(struct device *dev,
927 unsigned int add = ADD_MANAGED_RESOURCE; 934 unsigned int add = ADD_MANAGED_RESOURCE;
928 ssize_t ret = 0; 935 ssize_t ret = 0;
929 936
930 ret = sscanf (buf, "+ 0x%lx - 0x%lx", &start_addr, &end_addr); 937 ret = sscanf(buf, "+ 0x%lx - 0x%lx", &start_addr, &end_addr);
931 if (ret != 2) { 938 if (ret != 2) {
932 ret = sscanf (buf, "- 0x%lx - 0x%lx", &start_addr, &end_addr); 939 ret = sscanf(buf, "- 0x%lx - 0x%lx", &start_addr, &end_addr);
933 add = REMOVE_MANAGED_RESOURCE; 940 add = REMOVE_MANAGED_RESOURCE;
934 if (ret != 2) { 941 if (ret != 2) {
935 ret = sscanf (buf, "0x%lx - 0x%lx", &start_addr, &end_addr); 942 ret = sscanf(buf, "0x%lx - 0x%lx", &start_addr,
943 &end_addr);
936 add = ADD_MANAGED_RESOURCE; 944 add = ADD_MANAGED_RESOURCE;
937 if (ret != 2) 945 if (ret != 2)
938 return -EINVAL; 946 return -EINVAL;
@@ -963,14 +971,14 @@ static ssize_t show_mem_db(struct device *dev,
963 for (p = data->mem_db.next; p != &data->mem_db; p = p->next) { 971 for (p = data->mem_db.next; p != &data->mem_db; p = p->next) {
964 if (ret > (PAGE_SIZE - 10)) 972 if (ret > (PAGE_SIZE - 10))
965 continue; 973 continue;
966 ret += snprintf (&buf[ret], (PAGE_SIZE - ret - 1), 974 ret += snprintf(&buf[ret], (PAGE_SIZE - ret - 1),
967 "0x%08lx - 0x%08lx\n", 975 "0x%08lx - 0x%08lx\n",
968 ((unsigned long) p->base), 976 ((unsigned long) p->base),
969 ((unsigned long) p->base + p->num - 1)); 977 ((unsigned long) p->base + p->num - 1));
970 } 978 }
971 979
972 mutex_unlock(&rsrc_mutex); 980 mutex_unlock(&rsrc_mutex);
973 return (ret); 981 return ret;
974} 982}
975 983
976static ssize_t store_mem_db(struct device *dev, 984static ssize_t store_mem_db(struct device *dev,
@@ -982,12 +990,13 @@ static ssize_t store_mem_db(struct device *dev,
982 unsigned int add = ADD_MANAGED_RESOURCE; 990 unsigned int add = ADD_MANAGED_RESOURCE;
983 ssize_t ret = 0; 991 ssize_t ret = 0;
984 992
985 ret = sscanf (buf, "+ 0x%lx - 0x%lx", &start_addr, &end_addr); 993 ret = sscanf(buf, "+ 0x%lx - 0x%lx", &start_addr, &end_addr);
986 if (ret != 2) { 994 if (ret != 2) {
987 ret = sscanf (buf, "- 0x%lx - 0x%lx", &start_addr, &end_addr); 995 ret = sscanf(buf, "- 0x%lx - 0x%lx", &start_addr, &end_addr);
988 add = REMOVE_MANAGED_RESOURCE; 996 add = REMOVE_MANAGED_RESOURCE;
989 if (ret != 2) { 997 if (ret != 2) {
990 ret = sscanf (buf, "0x%lx - 0x%lx", &start_addr, &end_addr); 998 ret = sscanf(buf, "0x%lx - 0x%lx", &start_addr,
999 &end_addr);
991 add = ADD_MANAGED_RESOURCE; 1000 add = ADD_MANAGED_RESOURCE;
992 if (ret != 2) 1001 if (ret != 2)
993 return -EINVAL; 1002 return -EINVAL;
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c
index 78d5aab542f7..7a456000332a 100644
--- a/drivers/pcmcia/socket_sysfs.c
+++ b/drivers/pcmcia/socket_sysfs.c
@@ -164,7 +164,7 @@ static ssize_t pccard_store_irq_mask(struct device *dev,
164 if (!count) 164 if (!count)
165 return -EINVAL; 165 return -EINVAL;
166 166
167 ret = sscanf (buf, "0x%x\n", &mask); 167 ret = sscanf(buf, "0x%x\n", &mask);
168 168
169 if (ret == 1) { 169 if (ret == 1) {
170 s->irq_mask &= mask; 170 s->irq_mask &= mask;
@@ -278,7 +278,7 @@ static ssize_t pccard_extract_cis(struct pcmcia_socket *s, char *buf, loff_t off
278 free_tuple: 278 free_tuple:
279 kfree(tuplebuffer); 279 kfree(tuplebuffer);
280 280
281 return (ret); 281 return ret;
282} 282}
283 283
284static ssize_t pccard_show_cis(struct kobject *kobj, 284static ssize_t pccard_show_cis(struct kobject *kobj,
@@ -308,7 +308,7 @@ static ssize_t pccard_show_cis(struct kobject *kobj,
308 count = pccard_extract_cis(s, buf, off, count); 308 count = pccard_extract_cis(s, buf, off, count);
309 } 309 }
310 310
311 return (count); 311 return count;
312} 312}
313 313
314static ssize_t pccard_store_cis(struct kobject *kobj, 314static ssize_t pccard_store_cis(struct kobject *kobj,
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index 8be4cc447a17..fe02cfd4b5e9 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -6,7 +6,7 @@
6 * Changelog: 6 * Changelog:
7 * Aug 2002: Manfred Spraul <manfred@colorfullife.com> 7 * Aug 2002: Manfred Spraul <manfred@colorfullife.com>
8 * Dynamically adjust the size of the bridge resource 8 * Dynamically adjust the size of the bridge resource
9 * 9 *
10 * May 2003: Dominik Brodowski <linux@brodo.de> 10 * May 2003: Dominik Brodowski <linux@brodo.de>
11 * Merge pci_socket.c and yenta.c into one file 11 * Merge pci_socket.c and yenta.c into one file
12 */ 12 */
@@ -16,13 +16,12 @@
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/io.h>
19 20
20#include <pcmcia/cs_types.h> 21#include <pcmcia/cs_types.h>
21#include <pcmcia/ss.h> 22#include <pcmcia/ss.h>
22#include <pcmcia/cs.h> 23#include <pcmcia/cs.h>
23 24
24#include <asm/io.h>
25
26#include "yenta_socket.h" 25#include "yenta_socket.h"
27#include "i82365.h" 26#include "i82365.h"
28 27
@@ -55,7 +54,7 @@ static int yenta_probe_cb_irq(struct yenta_socket *socket);
55 54
56static unsigned int override_bios; 55static unsigned int override_bios;
57module_param(override_bios, uint, 0000); 56module_param(override_bios, uint, 0000);
58MODULE_PARM_DESC (override_bios, "yenta ignore bios resource allocation"); 57MODULE_PARM_DESC(override_bios, "yenta ignore bios resource allocation");
59 58
60/* 59/*
61 * Generate easy-to-use ways of reading a cardbus sockets 60 * Generate easy-to-use ways of reading a cardbus sockets
@@ -237,24 +236,42 @@ static void yenta_set_power(struct yenta_socket *socket, socket_state_t *state)
237 /* i82365SL-DF style */ 236 /* i82365SL-DF style */
238 if (socket->flags & YENTA_16BIT_POWER_DF) { 237 if (socket->flags & YENTA_16BIT_POWER_DF) {
239 switch (state->Vcc) { 238 switch (state->Vcc) {
240 case 33: reg |= I365_VCC_3V; break; 239 case 33:
241 case 50: reg |= I365_VCC_5V; break; 240 reg |= I365_VCC_3V;
242 default: reg = 0; break; 241 break;
242 case 50:
243 reg |= I365_VCC_5V;
244 break;
245 default:
246 reg = 0;
247 break;
243 } 248 }
244 switch (state->Vpp) { 249 switch (state->Vpp) {
245 case 33: 250 case 33:
246 case 50: reg |= I365_VPP1_5V; break; 251 case 50:
247 case 120: reg |= I365_VPP1_12V; break; 252 reg |= I365_VPP1_5V;
253 break;
254 case 120:
255 reg |= I365_VPP1_12V;
256 break;
248 } 257 }
249 } else { 258 } else {
250 /* i82365SL-B style */ 259 /* i82365SL-B style */
251 switch (state->Vcc) { 260 switch (state->Vcc) {
252 case 50: reg |= I365_VCC_5V; break; 261 case 50:
253 default: reg = 0; break; 262 reg |= I365_VCC_5V;
263 break;
264 default:
265 reg = 0;
266 break;
254 } 267 }
255 switch (state->Vpp) { 268 switch (state->Vpp) {
256 case 50: reg |= I365_VPP1_5V | I365_VPP2_5V; break; 269 case 50:
257 case 120: reg |= I365_VPP1_12V | I365_VPP2_12V; break; 270 reg |= I365_VPP1_5V | I365_VPP2_5V;
271 break;
272 case 120:
273 reg |= I365_VPP1_12V | I365_VPP2_12V;
274 break;
258 } 275 }
259 } 276 }
260 277
@@ -263,14 +280,26 @@ static void yenta_set_power(struct yenta_socket *socket, socket_state_t *state)
263 } else { 280 } else {
264 u32 reg = 0; /* CB_SC_STPCLK? */ 281 u32 reg = 0; /* CB_SC_STPCLK? */
265 switch (state->Vcc) { 282 switch (state->Vcc) {
266 case 33: reg = CB_SC_VCC_3V; break; 283 case 33:
267 case 50: reg = CB_SC_VCC_5V; break; 284 reg = CB_SC_VCC_3V;
268 default: reg = 0; break; 285 break;
286 case 50:
287 reg = CB_SC_VCC_5V;
288 break;
289 default:
290 reg = 0;
291 break;
269 } 292 }
270 switch (state->Vpp) { 293 switch (state->Vpp) {
271 case 33: reg |= CB_SC_VPP_3V; break; 294 case 33:
272 case 50: reg |= CB_SC_VPP_5V; break; 295 reg |= CB_SC_VPP_3V;
273 case 120: reg |= CB_SC_VPP_12V; break; 296 break;
297 case 50:
298 reg |= CB_SC_VPP_5V;
299 break;
300 case 120:
301 reg |= CB_SC_VPP_12V;
302 break;
274 } 303 }
275 if (reg != cb_readl(socket, CB_SOCKET_CONTROL)) 304 if (reg != cb_readl(socket, CB_SOCKET_CONTROL))
276 cb_writel(socket, CB_SOCKET_CONTROL, reg); 305 cb_writel(socket, CB_SOCKET_CONTROL, reg);
@@ -314,23 +343,29 @@ static int yenta_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
314 343
315 reg = exca_readb(socket, I365_POWER) & (I365_VCC_MASK|I365_VPP1_MASK); 344 reg = exca_readb(socket, I365_POWER) & (I365_VCC_MASK|I365_VPP1_MASK);
316 reg |= I365_PWR_NORESET; 345 reg |= I365_PWR_NORESET;
317 if (state->flags & SS_PWR_AUTO) reg |= I365_PWR_AUTO; 346 if (state->flags & SS_PWR_AUTO)
318 if (state->flags & SS_OUTPUT_ENA) reg |= I365_PWR_OUT; 347 reg |= I365_PWR_AUTO;
348 if (state->flags & SS_OUTPUT_ENA)
349 reg |= I365_PWR_OUT;
319 if (exca_readb(socket, I365_POWER) != reg) 350 if (exca_readb(socket, I365_POWER) != reg)
320 exca_writeb(socket, I365_POWER, reg); 351 exca_writeb(socket, I365_POWER, reg);
321 352
322 /* CSC interrupt: no ISA irq for CSC */ 353 /* CSC interrupt: no ISA irq for CSC */
323 reg = I365_CSC_DETECT; 354 reg = I365_CSC_DETECT;
324 if (state->flags & SS_IOCARD) { 355 if (state->flags & SS_IOCARD) {
325 if (state->csc_mask & SS_STSCHG) reg |= I365_CSC_STSCHG; 356 if (state->csc_mask & SS_STSCHG)
357 reg |= I365_CSC_STSCHG;
326 } else { 358 } else {
327 if (state->csc_mask & SS_BATDEAD) reg |= I365_CSC_BVD1; 359 if (state->csc_mask & SS_BATDEAD)
328 if (state->csc_mask & SS_BATWARN) reg |= I365_CSC_BVD2; 360 reg |= I365_CSC_BVD1;
329 if (state->csc_mask & SS_READY) reg |= I365_CSC_READY; 361 if (state->csc_mask & SS_BATWARN)
362 reg |= I365_CSC_BVD2;
363 if (state->csc_mask & SS_READY)
364 reg |= I365_CSC_READY;
330 } 365 }
331 exca_writeb(socket, I365_CSCINT, reg); 366 exca_writeb(socket, I365_CSCINT, reg);
332 exca_readb(socket, I365_CSC); 367 exca_readb(socket, I365_CSC);
333 if(sock->zoom_video) 368 if (sock->zoom_video)
334 sock->zoom_video(sock, state->flags & SS_ZVCARD); 369 sock->zoom_video(sock, state->flags & SS_ZVCARD);
335 } 370 }
336 config_writew(socket, CB_BRIDGE_CONTROL, bridge); 371 config_writew(socket, CB_BRIDGE_CONTROL, bridge);
@@ -368,9 +403,12 @@ static int yenta_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *io
368 exca_writew(socket, I365_IO(map)+I365_W_STOP, io->stop); 403 exca_writew(socket, I365_IO(map)+I365_W_STOP, io->stop);
369 404
370 ioctl = exca_readb(socket, I365_IOCTL) & ~I365_IOCTL_MASK(map); 405 ioctl = exca_readb(socket, I365_IOCTL) & ~I365_IOCTL_MASK(map);
371 if (io->flags & MAP_0WS) ioctl |= I365_IOCTL_0WS(map); 406 if (io->flags & MAP_0WS)
372 if (io->flags & MAP_16BIT) ioctl |= I365_IOCTL_16BIT(map); 407 ioctl |= I365_IOCTL_0WS(map);
373 if (io->flags & MAP_AUTOSZ) ioctl |= I365_IOCTL_IOCS16(map); 408 if (io->flags & MAP_16BIT)
409 ioctl |= I365_IOCTL_16BIT(map);
410 if (io->flags & MAP_AUTOSZ)
411 ioctl |= I365_IOCTL_IOCS16(map);
374 exca_writeb(socket, I365_IOCTL, ioctl); 412 exca_writeb(socket, I365_IOCTL, ioctl);
375 413
376 if (io->flags & MAP_ACTIVE) 414 if (io->flags & MAP_ACTIVE)
@@ -416,10 +454,17 @@ static int yenta_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *
416 454
417 word = (stop >> 12) & 0x0fff; 455 word = (stop >> 12) & 0x0fff;
418 switch (to_cycles(mem->speed)) { 456 switch (to_cycles(mem->speed)) {
419 case 0: break; 457 case 0:
420 case 1: word |= I365_MEM_WS0; break; 458 break;
421 case 2: word |= I365_MEM_WS1; break; 459 case 1:
422 default: word |= I365_MEM_WS1 | I365_MEM_WS0; break; 460 word |= I365_MEM_WS0;
461 break;
462 case 2:
463 word |= I365_MEM_WS1;
464 break;
465 default:
466 word |= I365_MEM_WS1 | I365_MEM_WS0;
467 break;
423 } 468 }
424 exca_writew(socket, I365_MEM(map) + I365_W_STOP, word); 469 exca_writew(socket, I365_MEM(map) + I365_W_STOP, word);
425 470
@@ -547,9 +592,9 @@ static int yenta_sock_suspend(struct pcmcia_socket *sock)
547 * max 4 MB, min 16 kB. We try very hard to not get below 592 * max 4 MB, min 16 kB. We try very hard to not get below
548 * the "ACC" values, though. 593 * the "ACC" values, though.
549 */ 594 */
550#define BRIDGE_MEM_MAX 4*1024*1024 595#define BRIDGE_MEM_MAX (4*1024*1024)
551#define BRIDGE_MEM_ACC 128*1024 596#define BRIDGE_MEM_ACC (128*1024)
552#define BRIDGE_MEM_MIN 16*1024 597#define BRIDGE_MEM_MIN (16*1024)
553 598
554#define BRIDGE_IO_MAX 512 599#define BRIDGE_IO_MAX 512
555#define BRIDGE_IO_ACC 256 600#define BRIDGE_IO_ACC 256
@@ -574,7 +619,7 @@ static int yenta_search_one_res(struct resource *root, struct resource *res,
574 int i; 619 int i;
575 size = BRIDGE_MEM_MAX; 620 size = BRIDGE_MEM_MAX;
576 if (size > avail/8) { 621 if (size > avail/8) {
577 size=(avail+1)/8; 622 size = (avail+1)/8;
578 /* round size down to next power of 2 */ 623 /* round size down to next power of 2 */
579 i = 0; 624 i = 0;
580 while ((size /= 2) != 0) 625 while ((size /= 2) != 0)
@@ -590,7 +635,7 @@ static int yenta_search_one_res(struct resource *root, struct resource *res,
590 635
591 do { 636 do {
592 if (allocate_resource(root, res, size, start, end, align, 637 if (allocate_resource(root, res, size, start, end, align,
593 NULL, NULL)==0) { 638 NULL, NULL) == 0) {
594 return 1; 639 return 1;
595 } 640 }
596 size = size/2; 641 size = size/2;
@@ -605,8 +650,8 @@ static int yenta_search_res(struct yenta_socket *socket, struct resource *res,
605 u32 min) 650 u32 min)
606{ 651{
607 int i; 652 int i;
608 for (i=0; i<PCI_BUS_NUM_RESOURCES; i++) { 653 for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
609 struct resource * root = socket->dev->bus->resource[i]; 654 struct resource *root = socket->dev->bus->resource[i];
610 if (!root) 655 if (!root)
611 continue; 656 continue;
612 657
@@ -704,7 +749,7 @@ static void yenta_allocate_resources(struct yenta_socket *socket)
704static void yenta_free_resources(struct yenta_socket *socket) 749static void yenta_free_resources(struct yenta_socket *socket)
705{ 750{
706 int i; 751 int i;
707 for (i=0;i<4;i++) { 752 for (i = 0; i < 4; i++) {
708 struct resource *res; 753 struct resource *res;
709 res = socket->dev->resource + PCI_BRIDGE_RESOURCES + i; 754 res = socket->dev->resource + PCI_BRIDGE_RESOURCES + i;
710 if (res->start != 0 && res->end != 0) 755 if (res->start != 0 && res->end != 0)
@@ -726,7 +771,7 @@ static void __devexit yenta_close(struct pci_dev *dev)
726 771
727 /* we don't want a dying socket registered */ 772 /* we don't want a dying socket registered */
728 pcmcia_unregister_socket(&sock->socket); 773 pcmcia_unregister_socket(&sock->socket);
729 774
730 /* Disable all events so we don't die in an IRQ storm */ 775 /* Disable all events so we don't die in an IRQ storm */
731 cb_writel(sock, CB_SOCKET_MASK, 0x0); 776 cb_writel(sock, CB_SOCKET_MASK, 0x0);
732 exca_writeb(sock, I365_CSCINT, 0); 777 exca_writeb(sock, I365_CSCINT, 0);
@@ -898,7 +943,7 @@ static irqreturn_t yenta_probe_handler(int irq, void *dev_id)
898{ 943{
899 struct yenta_socket *socket = (struct yenta_socket *) dev_id; 944 struct yenta_socket *socket = (struct yenta_socket *) dev_id;
900 u8 csc; 945 u8 csc;
901 u32 cb_event; 946 u32 cb_event;
902 947
903 /* Clear interrupt status for the event */ 948 /* Clear interrupt status for the event */
904 cb_event = cb_readl(socket, CB_SOCKET_EVENT); 949 cb_event = cb_readl(socket, CB_SOCKET_EVENT);
@@ -1019,7 +1064,7 @@ static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge)
1019{ 1064{
1020 struct list_head *tmp; 1065 struct list_head *tmp;
1021 unsigned char upper_limit; 1066 unsigned char upper_limit;
1022 /* 1067 /*
1023 * We only check and fix the parent bridge: All systems which need 1068 * We only check and fix the parent bridge: All systems which need
1024 * this fixup that have been reviewed are laptops and the only bridge 1069 * this fixup that have been reviewed are laptops and the only bridge
1025 * which needed fixing was the parent bridge of the CardBus bridge: 1070 * which needed fixing was the parent bridge of the CardBus bridge:
@@ -1038,7 +1083,7 @@ static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge)
1038 1083
1039 /* check the bus ranges of all silbling bridges to prevent overlap */ 1084 /* check the bus ranges of all silbling bridges to prevent overlap */
1040 list_for_each(tmp, &bridge_to_fix->parent->children) { 1085 list_for_each(tmp, &bridge_to_fix->parent->children) {
1041 struct pci_bus * silbling = pci_bus_b(tmp); 1086 struct pci_bus *silbling = pci_bus_b(tmp);
1042 /* 1087 /*
1043 * If the silbling has a higher secondary bus number 1088 * If the silbling has a higher secondary bus number
1044 * and it's secondary is equal or smaller than our 1089 * and it's secondary is equal or smaller than our
@@ -1083,7 +1128,7 @@ static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge)
1083 * interrupt, and that we can map the cardbus area. Fill in the 1128 * interrupt, and that we can map the cardbus area. Fill in the
1084 * socket information structure.. 1129 * socket information structure..
1085 */ 1130 */
1086static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_id *id) 1131static int __devinit yenta_probe(struct pci_dev *dev, const struct pci_device_id *id)
1087{ 1132{
1088 struct yenta_socket *socket; 1133 struct yenta_socket *socket;
1089 int ret; 1134 int ret;
@@ -1302,7 +1347,7 @@ static struct dev_pm_ops yenta_pm_ops = {
1302#define YENTA_PM_OPS NULL 1347#define YENTA_PM_OPS NULL
1303#endif 1348#endif
1304 1349
1305#define CB_ID(vend,dev,type) \ 1350#define CB_ID(vend, dev, type) \
1306 { \ 1351 { \
1307 .vendor = vend, \ 1352 .vendor = vend, \
1308 .device = dev, \ 1353 .device = dev, \
@@ -1313,7 +1358,7 @@ static struct dev_pm_ops yenta_pm_ops = {
1313 .driver_data = CARDBUS_TYPE_##type, \ 1358 .driver_data = CARDBUS_TYPE_##type, \
1314 } 1359 }
1315 1360
1316static struct pci_device_id yenta_table [] = { 1361static struct pci_device_id yenta_table[] = {
1317 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1031, TI), 1362 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1031, TI),
1318 1363
1319 /* 1364 /*
@@ -1403,13 +1448,13 @@ static struct pci_driver yenta_cardbus_driver = {
1403 1448
1404static int __init yenta_socket_init(void) 1449static int __init yenta_socket_init(void)
1405{ 1450{
1406 return pci_register_driver (&yenta_cardbus_driver); 1451 return pci_register_driver(&yenta_cardbus_driver);
1407} 1452}
1408 1453
1409 1454
1410static void __exit yenta_socket_exit (void) 1455static void __exit yenta_socket_exit(void)
1411{ 1456{
1412 pci_unregister_driver (&yenta_cardbus_driver); 1457 pci_unregister_driver(&yenta_cardbus_driver);
1413} 1458}
1414 1459
1415 1460
diff --git a/drivers/power/pcf50633-charger.c b/drivers/power/pcf50633-charger.c
index e8b278f71781..6a84a8eb8d7a 100644
--- a/drivers/power/pcf50633-charger.c
+++ b/drivers/power/pcf50633-charger.c
@@ -303,7 +303,6 @@ static const u8 mbc_irq_handlers[] = {
303static int __devinit pcf50633_mbc_probe(struct platform_device *pdev) 303static int __devinit pcf50633_mbc_probe(struct platform_device *pdev)
304{ 304{
305 struct pcf50633_mbc *mbc; 305 struct pcf50633_mbc *mbc;
306 struct pcf50633_subdev_pdata *pdata = pdev->dev.platform_data;
307 int ret; 306 int ret;
308 int i; 307 int i;
309 u8 mbcs1; 308 u8 mbcs1;
@@ -313,7 +312,7 @@ static int __devinit pcf50633_mbc_probe(struct platform_device *pdev)
313 return -ENOMEM; 312 return -ENOMEM;
314 313
315 platform_set_drvdata(pdev, mbc); 314 platform_set_drvdata(pdev, mbc);
316 mbc->pcf = pdata->pcf; 315 mbc->pcf = dev_to_pcf50633(pdev->dev.parent);
317 316
318 /* Set up IRQ handlers */ 317 /* Set up IRQ handlers */
319 for (i = 0; i < ARRAY_SIZE(mbc_irq_handlers); i++) 318 for (i = 0; i < ARRAY_SIZE(mbc_irq_handlers); i++)
diff --git a/drivers/power/wm8350_power.c b/drivers/power/wm8350_power.c
index 28b0299c0043..ad4f071e1287 100644
--- a/drivers/power/wm8350_power.c
+++ b/drivers/power/wm8350_power.c
@@ -184,8 +184,9 @@ static ssize_t charger_state_show(struct device *dev,
184 184
185static DEVICE_ATTR(charger_state, 0444, charger_state_show, NULL); 185static DEVICE_ATTR(charger_state, 0444, charger_state_show, NULL);
186 186
187static void wm8350_charger_handler(struct wm8350 *wm8350, int irq, void *data) 187static irqreturn_t wm8350_charger_handler(int irq, void *data)
188{ 188{
189 struct wm8350 *wm8350 = data;
189 struct wm8350_power *power = &wm8350->power; 190 struct wm8350_power *power = &wm8350->power;
190 struct wm8350_charger_policy *policy = power->policy; 191 struct wm8350_charger_policy *policy = power->policy;
191 192
@@ -238,6 +239,8 @@ static void wm8350_charger_handler(struct wm8350 *wm8350, int irq, void *data)
238 default: 239 default:
239 dev_err(wm8350->dev, "Unknown interrupt %d\n", irq); 240 dev_err(wm8350->dev, "Unknown interrupt %d\n", irq);
240 } 241 }
242
243 return IRQ_HANDLED;
241} 244}
242 245
243/********************************************************************* 246/*********************************************************************
@@ -387,73 +390,55 @@ static void wm8350_init_charger(struct wm8350 *wm8350)
387{ 390{
388 /* register our interest in charger events */ 391 /* register our interest in charger events */
389 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_BAT_HOT, 392 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_BAT_HOT,
390 wm8350_charger_handler, NULL); 393 wm8350_charger_handler, 0, "Battery hot", wm8350);
391 wm8350_unmask_irq(wm8350, WM8350_IRQ_CHG_BAT_HOT);
392 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_BAT_COLD, 394 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_BAT_COLD,
393 wm8350_charger_handler, NULL); 395 wm8350_charger_handler, 0, "Battery cold", wm8350);
394 wm8350_unmask_irq(wm8350, WM8350_IRQ_CHG_BAT_COLD);
395 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_BAT_FAIL, 396 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_BAT_FAIL,
396 wm8350_charger_handler, NULL); 397 wm8350_charger_handler, 0, "Battery fail", wm8350);
397 wm8350_unmask_irq(wm8350, WM8350_IRQ_CHG_BAT_FAIL);
398 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_TO, 398 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_TO,
399 wm8350_charger_handler, NULL); 399 wm8350_charger_handler, 0,
400 wm8350_unmask_irq(wm8350, WM8350_IRQ_CHG_TO); 400 "Charger timeout", wm8350);
401 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_END, 401 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_END,
402 wm8350_charger_handler, NULL); 402 wm8350_charger_handler, 0,
403 wm8350_unmask_irq(wm8350, WM8350_IRQ_CHG_END); 403 "Charge end", wm8350);
404 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_START, 404 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_START,
405 wm8350_charger_handler, NULL); 405 wm8350_charger_handler, 0,
406 wm8350_unmask_irq(wm8350, WM8350_IRQ_CHG_START); 406 "Charge start", wm8350);
407 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_FAST_RDY, 407 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_FAST_RDY,
408 wm8350_charger_handler, NULL); 408 wm8350_charger_handler, 0,
409 wm8350_unmask_irq(wm8350, WM8350_IRQ_CHG_FAST_RDY); 409 "Fast charge ready", wm8350);
410 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P9, 410 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P9,
411 wm8350_charger_handler, NULL); 411 wm8350_charger_handler, 0,
412 wm8350_unmask_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P9); 412 "Battery <3.9V", wm8350);
413 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P1, 413 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P1,
414 wm8350_charger_handler, NULL); 414 wm8350_charger_handler, 0,
415 wm8350_unmask_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P1); 415 "Battery <3.1V", wm8350);
416 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_2P85, 416 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_2P85,
417 wm8350_charger_handler, NULL); 417 wm8350_charger_handler, 0,
418 wm8350_unmask_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_2P85); 418 "Battery <2.85V", wm8350);
419 419
420 /* and supply change events */ 420 /* and supply change events */
421 wm8350_register_irq(wm8350, WM8350_IRQ_EXT_USB_FB, 421 wm8350_register_irq(wm8350, WM8350_IRQ_EXT_USB_FB,
422 wm8350_charger_handler, NULL); 422 wm8350_charger_handler, 0, "USB", wm8350);
423 wm8350_unmask_irq(wm8350, WM8350_IRQ_EXT_USB_FB);
424 wm8350_register_irq(wm8350, WM8350_IRQ_EXT_WALL_FB, 423 wm8350_register_irq(wm8350, WM8350_IRQ_EXT_WALL_FB,
425 wm8350_charger_handler, NULL); 424 wm8350_charger_handler, 0, "Wall", wm8350);
426 wm8350_unmask_irq(wm8350, WM8350_IRQ_EXT_WALL_FB);
427 wm8350_register_irq(wm8350, WM8350_IRQ_EXT_BAT_FB, 425 wm8350_register_irq(wm8350, WM8350_IRQ_EXT_BAT_FB,
428 wm8350_charger_handler, NULL); 426 wm8350_charger_handler, 0, "Battery", wm8350);
429 wm8350_unmask_irq(wm8350, WM8350_IRQ_EXT_BAT_FB);
430} 427}
431 428
432static void free_charger_irq(struct wm8350 *wm8350) 429static void free_charger_irq(struct wm8350 *wm8350)
433{ 430{
434 wm8350_mask_irq(wm8350, WM8350_IRQ_CHG_BAT_HOT);
435 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_BAT_HOT); 431 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_BAT_HOT);
436 wm8350_mask_irq(wm8350, WM8350_IRQ_CHG_BAT_COLD);
437 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_BAT_COLD); 432 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_BAT_COLD);
438 wm8350_mask_irq(wm8350, WM8350_IRQ_CHG_BAT_FAIL);
439 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_BAT_FAIL); 433 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_BAT_FAIL);
440 wm8350_mask_irq(wm8350, WM8350_IRQ_CHG_TO);
441 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_TO); 434 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_TO);
442 wm8350_mask_irq(wm8350, WM8350_IRQ_CHG_END);
443 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_END); 435 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_END);
444 wm8350_mask_irq(wm8350, WM8350_IRQ_CHG_START);
445 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_START); 436 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_START);
446 wm8350_mask_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P9);
447 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P9); 437 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P9);
448 wm8350_mask_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P1);
449 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P1); 438 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P1);
450 wm8350_mask_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_2P85);
451 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_2P85); 439 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_2P85);
452 wm8350_mask_irq(wm8350, WM8350_IRQ_EXT_USB_FB);
453 wm8350_free_irq(wm8350, WM8350_IRQ_EXT_USB_FB); 440 wm8350_free_irq(wm8350, WM8350_IRQ_EXT_USB_FB);
454 wm8350_mask_irq(wm8350, WM8350_IRQ_EXT_WALL_FB);
455 wm8350_free_irq(wm8350, WM8350_IRQ_EXT_WALL_FB); 441 wm8350_free_irq(wm8350, WM8350_IRQ_EXT_WALL_FB);
456 wm8350_mask_irq(wm8350, WM8350_IRQ_EXT_BAT_FB);
457 wm8350_free_irq(wm8350, WM8350_IRQ_EXT_BAT_FB); 442 wm8350_free_irq(wm8350, WM8350_IRQ_EXT_BAT_FB);
458} 443}
459 444
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index bcbb161bde0b..7cfdd65bebb4 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -70,7 +70,7 @@ config REGULATOR_MAX1586
70 for PXA27x chips to control VCC_CORE and VCC_USIM voltages. 70 for PXA27x chips to control VCC_CORE and VCC_USIM voltages.
71 71
72config REGULATOR_TWL4030 72config REGULATOR_TWL4030
73 bool "TI TWL4030/TWL5030/TPS695x0 PMIC" 73 bool "TI TWL4030/TWL5030/TWL6030/TPS695x0 PMIC"
74 depends on TWL4030_CORE 74 depends on TWL4030_CORE
75 help 75 help
76 This driver supports the voltage regulators provided by 76 This driver supports the voltage regulators provided by
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 4257a8683778..9ae3cc44e668 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -11,7 +11,7 @@ obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o
11obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o 11obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o
12obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o 12obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o
13obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o 13obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o
14obj-$(CONFIG_REGULATOR_TWL4030) += twl4030-regulator.o 14obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o
15obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o 15obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o
16obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o 16obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o
17obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o 17obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o
diff --git a/drivers/regulator/pcf50633-regulator.c b/drivers/regulator/pcf50633-regulator.c
index 0803ffe6236d..c8f41dc05b76 100644
--- a/drivers/regulator/pcf50633-regulator.c
+++ b/drivers/regulator/pcf50633-regulator.c
@@ -314,13 +314,15 @@ static int __devinit pcf50633_regulator_probe(struct platform_device *pdev)
314 struct pcf50633 *pcf; 314 struct pcf50633 *pcf;
315 315
316 /* Already set by core driver */ 316 /* Already set by core driver */
317 pcf = platform_get_drvdata(pdev); 317 pcf = dev_to_pcf50633(pdev->dev.parent);
318 318
319 rdev = regulator_register(&regulators[pdev->id], &pdev->dev, 319 rdev = regulator_register(&regulators[pdev->id], &pdev->dev,
320 pdev->dev.platform_data, pcf); 320 pdev->dev.platform_data, pcf);
321 if (IS_ERR(rdev)) 321 if (IS_ERR(rdev))
322 return PTR_ERR(rdev); 322 return PTR_ERR(rdev);
323 323
324 platform_set_drvdata(pdev, rdev);
325
324 if (pcf->pdata->regulator_registered) 326 if (pcf->pdata->regulator_registered)
325 pcf->pdata->regulator_registered(pcf, pdev->id); 327 pcf->pdata->regulator_registered(pcf, pdev->id);
326 328
@@ -331,6 +333,7 @@ static int __devexit pcf50633_regulator_remove(struct platform_device *pdev)
331{ 333{
332 struct regulator_dev *rdev = platform_get_drvdata(pdev); 334 struct regulator_dev *rdev = platform_get_drvdata(pdev);
333 335
336 platform_set_drvdata(pdev, NULL);
334 regulator_unregister(rdev); 337 regulator_unregister(rdev);
335 338
336 return 0; 339 return 0;
diff --git a/drivers/regulator/twl4030-regulator.c b/drivers/regulator/twl-regulator.c
index e2032fb60b55..7ea1c3a31081 100644
--- a/drivers/regulator/twl4030-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * twl4030-regulator.c -- support regulators in twl4030 family chips 2 * twl-regulator.c -- support regulators in twl4030/twl6030 family chips
3 * 3 *
4 * Copyright (C) 2008 David Brownell 4 * Copyright (C) 2008 David Brownell
5 * 5 *
@@ -15,11 +15,11 @@
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/regulator/driver.h> 16#include <linux/regulator/driver.h>
17#include <linux/regulator/machine.h> 17#include <linux/regulator/machine.h>
18#include <linux/i2c/twl4030.h> 18#include <linux/i2c/twl.h>
19 19
20 20
21/* 21/*
22 * The TWL4030/TW5030/TPS659x0 family chips include power management, a 22 * The TWL4030/TW5030/TPS659x0/TWL6030 family chips include power management, a
23 * USB OTG transceiver, an RTC, ADC, PWM, and lots more. Some versions 23 * USB OTG transceiver, an RTC, ADC, PWM, and lots more. Some versions
24 * include an audio codec, battery charger, and more voltage regulators. 24 * include an audio codec, battery charger, and more voltage regulators.
25 * These chips are often used in OMAP-based systems. 25 * These chips are often used in OMAP-based systems.
@@ -33,7 +33,7 @@ struct twlreg_info {
33 /* start of regulator's PM_RECEIVER control register bank */ 33 /* start of regulator's PM_RECEIVER control register bank */
34 u8 base; 34 u8 base;
35 35
36 /* twl4030 resource ID, for resource control state machine */ 36 /* twl resource ID, for resource control state machine */
37 u8 id; 37 u8 id;
38 38
39 /* voltage in mV = table[VSEL]; table_len must be a power-of-two */ 39 /* voltage in mV = table[VSEL]; table_len must be a power-of-two */
@@ -52,27 +52,38 @@ struct twlreg_info {
52 * The first three registers of all power resource banks help hardware to 52 * The first three registers of all power resource banks help hardware to
53 * manage the various resource groups. 53 * manage the various resource groups.
54 */ 54 */
55/* Common offset in TWL4030/6030 */
55#define VREG_GRP 0 56#define VREG_GRP 0
57/* TWL4030 register offsets */
56#define VREG_TYPE 1 58#define VREG_TYPE 1
57#define VREG_REMAP 2 59#define VREG_REMAP 2
58#define VREG_DEDICATED 3 /* LDO control */ 60#define VREG_DEDICATED 3 /* LDO control */
59 61/* TWL6030 register offsets */
62#define VREG_TRANS 1
63#define VREG_STATE 2
64#define VREG_VOLTAGE 3
65/* TWL6030 Misc register offsets */
66#define VREG_BC_ALL 1
67#define VREG_BC_REF 2
68#define VREG_BC_PROC 3
69#define VREG_BC_CLK_RST 4
60 70
61static inline int 71static inline int
62twl4030reg_read(struct twlreg_info *info, unsigned offset) 72twlreg_read(struct twlreg_info *info, unsigned slave_subgp, unsigned offset)
63{ 73{
64 u8 value; 74 u8 value;
65 int status; 75 int status;
66 76
67 status = twl4030_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, 77 status = twl_i2c_read_u8(slave_subgp,
68 &value, info->base + offset); 78 &value, info->base + offset);
69 return (status < 0) ? status : value; 79 return (status < 0) ? status : value;
70} 80}
71 81
72static inline int 82static inline int
73twl4030reg_write(struct twlreg_info *info, unsigned offset, u8 value) 83twlreg_write(struct twlreg_info *info, unsigned slave_subgp, unsigned offset,
84 u8 value)
74{ 85{
75 return twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 86 return twl_i2c_write_u8(slave_subgp,
76 value, info->base + offset); 87 value, info->base + offset);
77} 88}
78 89
@@ -80,59 +91,79 @@ twl4030reg_write(struct twlreg_info *info, unsigned offset, u8 value)
80 91
81/* generic power resource operations, which work on all regulators */ 92/* generic power resource operations, which work on all regulators */
82 93
83static int twl4030reg_grp(struct regulator_dev *rdev) 94static int twlreg_grp(struct regulator_dev *rdev)
84{ 95{
85 return twl4030reg_read(rdev_get_drvdata(rdev), VREG_GRP); 96 return twlreg_read(rdev_get_drvdata(rdev), TWL_MODULE_PM_RECEIVER,
97 VREG_GRP);
86} 98}
87 99
88/* 100/*
89 * Enable/disable regulators by joining/leaving the P1 (processor) group. 101 * Enable/disable regulators by joining/leaving the P1 (processor) group.
90 * We assume nobody else is updating the DEV_GRP registers. 102 * We assume nobody else is updating the DEV_GRP registers.
91 */ 103 */
92 104/* definition for 4030 family */
93#define P3_GRP BIT(7) /* "peripherals" */ 105#define P3_GRP_4030 BIT(7) /* "peripherals" */
94#define P2_GRP BIT(6) /* secondary processor, modem, etc */ 106#define P2_GRP_4030 BIT(6) /* secondary processor, modem, etc */
95#define P1_GRP BIT(5) /* CPU/Linux */ 107#define P1_GRP_4030 BIT(5) /* CPU/Linux */
96 108/* definition for 6030 family */
97static int twl4030reg_is_enabled(struct regulator_dev *rdev) 109#define P3_GRP_6030 BIT(2) /* secondary processor, modem, etc */
110#define P2_GRP_6030 BIT(1) /* "peripherals" */
111#define P1_GRP_6030 BIT(0) /* CPU/Linux */
112
113static int twlreg_is_enabled(struct regulator_dev *rdev)
98{ 114{
99 int state = twl4030reg_grp(rdev); 115 int state = twlreg_grp(rdev);
100 116
101 if (state < 0) 117 if (state < 0)
102 return state; 118 return state;
103 119
104 return (state & P1_GRP) != 0; 120 if (twl_class_is_4030())
121 state &= P1_GRP_4030;
122 else
123 state &= P1_GRP_6030;
124 return state;
105} 125}
106 126
107static int twl4030reg_enable(struct regulator_dev *rdev) 127static int twlreg_enable(struct regulator_dev *rdev)
108{ 128{
109 struct twlreg_info *info = rdev_get_drvdata(rdev); 129 struct twlreg_info *info = rdev_get_drvdata(rdev);
110 int grp; 130 int grp;
111 131
112 grp = twl4030reg_read(info, VREG_GRP); 132 grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP);
113 if (grp < 0) 133 if (grp < 0)
114 return grp; 134 return grp;
115 135
116 grp |= P1_GRP; 136 if (twl_class_is_4030())
117 return twl4030reg_write(info, VREG_GRP, grp); 137 grp |= P1_GRP_4030;
138 else
139 grp |= P1_GRP_6030;
140
141 return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp);
118} 142}
119 143
120static int twl4030reg_disable(struct regulator_dev *rdev) 144static int twlreg_disable(struct regulator_dev *rdev)
121{ 145{
122 struct twlreg_info *info = rdev_get_drvdata(rdev); 146 struct twlreg_info *info = rdev_get_drvdata(rdev);
123 int grp; 147 int grp;
124 148
125 grp = twl4030reg_read(info, VREG_GRP); 149 grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP);
126 if (grp < 0) 150 if (grp < 0)
127 return grp; 151 return grp;
128 152
129 grp &= ~P1_GRP; 153 if (twl_class_is_4030())
130 return twl4030reg_write(info, VREG_GRP, grp); 154 grp &= ~P1_GRP_4030;
155 else
156 grp &= ~P1_GRP_6030;
157
158 return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp);
131} 159}
132 160
133static int twl4030reg_get_status(struct regulator_dev *rdev) 161static int twlreg_get_status(struct regulator_dev *rdev)
134{ 162{
135 int state = twl4030reg_grp(rdev); 163 int state = twlreg_grp(rdev);
164
165 if (twl_class_is_6030())
166 return 0; /* FIXME return for 6030 regulator */
136 167
137 if (state < 0) 168 if (state < 0)
138 return state; 169 return state;
@@ -146,12 +177,15 @@ static int twl4030reg_get_status(struct regulator_dev *rdev)
146 : REGULATOR_STATUS_STANDBY; 177 : REGULATOR_STATUS_STANDBY;
147} 178}
148 179
149static int twl4030reg_set_mode(struct regulator_dev *rdev, unsigned mode) 180static int twlreg_set_mode(struct regulator_dev *rdev, unsigned mode)
150{ 181{
151 struct twlreg_info *info = rdev_get_drvdata(rdev); 182 struct twlreg_info *info = rdev_get_drvdata(rdev);
152 unsigned message; 183 unsigned message;
153 int status; 184 int status;
154 185
186 if (twl_class_is_6030())
187 return 0; /* FIXME return for 6030 regulator */
188
155 /* We can only set the mode through state machine commands... */ 189 /* We can only set the mode through state machine commands... */
156 switch (mode) { 190 switch (mode) {
157 case REGULATOR_MODE_NORMAL: 191 case REGULATOR_MODE_NORMAL:
@@ -165,18 +199,18 @@ static int twl4030reg_set_mode(struct regulator_dev *rdev, unsigned mode)
165 } 199 }
166 200
167 /* Ensure the resource is associated with some group */ 201 /* Ensure the resource is associated with some group */
168 status = twl4030reg_grp(rdev); 202 status = twlreg_grp(rdev);
169 if (status < 0) 203 if (status < 0)
170 return status; 204 return status;
171 if (!(status & (P3_GRP | P2_GRP | P1_GRP))) 205 if (!(status & (P3_GRP_4030 | P2_GRP_4030 | P1_GRP_4030)))
172 return -EACCES; 206 return -EACCES;
173 207
174 status = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 208 status = twl_i2c_write_u8(TWL_MODULE_PM_MASTER,
175 message >> 8, 0x15 /* PB_WORD_MSB */ ); 209 message >> 8, 0x15 /* PB_WORD_MSB */ );
176 if (status >= 0) 210 if (status >= 0)
177 return status; 211 return status;
178 212
179 return twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 213 return twl_i2c_write_u8(TWL_MODULE_PM_MASTER,
180 message, 0x16 /* PB_WORD_LSB */ ); 214 message, 0x16 /* PB_WORD_LSB */ );
181} 215}
182 216
@@ -260,9 +294,31 @@ static const u16 VSIM_VSEL_table[] = {
260static const u16 VDAC_VSEL_table[] = { 294static const u16 VDAC_VSEL_table[] = {
261 1200, 1300, 1800, 1800, 295 1200, 1300, 1800, 1800,
262}; 296};
297static const u16 VAUX1_6030_VSEL_table[] = {
298 1000, 1300, 1800, 2500,
299 2800, 2900, 3000, 3000,
300};
301static const u16 VAUX2_6030_VSEL_table[] = {
302 1200, 1800, 2500, 2750,
303 2800, 2800, 2800, 2800,
304};
305static const u16 VAUX3_6030_VSEL_table[] = {
306 1000, 1200, 1300, 1800,
307 2500, 2800, 3000, 3000,
308};
309static const u16 VMMC_VSEL_table[] = {
310 1200, 1800, 2800, 2900,
311 3000, 3000, 3000, 3000,
312};
313static const u16 VPP_VSEL_table[] = {
314 1800, 1900, 2000, 2100,
315 2200, 2300, 2400, 2500,
316};
317static const u16 VUSIM_VSEL_table[] = {
318 1200, 1800, 2500, 2900,
319};
263 320
264 321static int twlldo_list_voltage(struct regulator_dev *rdev, unsigned index)
265static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
266{ 322{
267 struct twlreg_info *info = rdev_get_drvdata(rdev); 323 struct twlreg_info *info = rdev_get_drvdata(rdev);
268 int mV = info->table[index]; 324 int mV = info->table[index];
@@ -271,7 +327,7 @@ static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
271} 327}
272 328
273static int 329static int
274twl4030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) 330twlldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
275{ 331{
276 struct twlreg_info *info = rdev_get_drvdata(rdev); 332 struct twlreg_info *info = rdev_get_drvdata(rdev);
277 int vsel; 333 int vsel;
@@ -288,16 +344,18 @@ twl4030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
288 344
289 /* use the first in-range value */ 345 /* use the first in-range value */
290 if (min_uV <= uV && uV <= max_uV) 346 if (min_uV <= uV && uV <= max_uV)
291 return twl4030reg_write(info, VREG_DEDICATED, vsel); 347 return twlreg_write(info, TWL_MODULE_PM_RECEIVER,
348 VREG_VOLTAGE, vsel);
292 } 349 }
293 350
294 return -EDOM; 351 return -EDOM;
295} 352}
296 353
297static int twl4030ldo_get_voltage(struct regulator_dev *rdev) 354static int twlldo_get_voltage(struct regulator_dev *rdev)
298{ 355{
299 struct twlreg_info *info = rdev_get_drvdata(rdev); 356 struct twlreg_info *info = rdev_get_drvdata(rdev);
300 int vsel = twl4030reg_read(info, VREG_DEDICATED); 357 int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER,
358 VREG_VOLTAGE);
301 359
302 if (vsel < 0) 360 if (vsel < 0)
303 return vsel; 361 return vsel;
@@ -306,19 +364,19 @@ static int twl4030ldo_get_voltage(struct regulator_dev *rdev)
306 return LDO_MV(info->table[vsel]) * 1000; 364 return LDO_MV(info->table[vsel]) * 1000;
307} 365}
308 366
309static struct regulator_ops twl4030ldo_ops = { 367static struct regulator_ops twlldo_ops = {
310 .list_voltage = twl4030ldo_list_voltage, 368 .list_voltage = twlldo_list_voltage,
311 369
312 .set_voltage = twl4030ldo_set_voltage, 370 .set_voltage = twlldo_set_voltage,
313 .get_voltage = twl4030ldo_get_voltage, 371 .get_voltage = twlldo_get_voltage,
314 372
315 .enable = twl4030reg_enable, 373 .enable = twlreg_enable,
316 .disable = twl4030reg_disable, 374 .disable = twlreg_disable,
317 .is_enabled = twl4030reg_is_enabled, 375 .is_enabled = twlreg_is_enabled,
318 376
319 .set_mode = twl4030reg_set_mode, 377 .set_mode = twlreg_set_mode,
320 378
321 .get_status = twl4030reg_get_status, 379 .get_status = twlreg_get_status,
322}; 380};
323 381
324/*----------------------------------------------------------------------*/ 382/*----------------------------------------------------------------------*/
@@ -326,60 +384,69 @@ static struct regulator_ops twl4030ldo_ops = {
326/* 384/*
327 * Fixed voltage LDOs don't have a VSEL field to update. 385 * Fixed voltage LDOs don't have a VSEL field to update.
328 */ 386 */
329static int twl4030fixed_list_voltage(struct regulator_dev *rdev, unsigned index) 387static int twlfixed_list_voltage(struct regulator_dev *rdev, unsigned index)
330{ 388{
331 struct twlreg_info *info = rdev_get_drvdata(rdev); 389 struct twlreg_info *info = rdev_get_drvdata(rdev);
332 390
333 return info->min_mV * 1000; 391 return info->min_mV * 1000;
334} 392}
335 393
336static int twl4030fixed_get_voltage(struct regulator_dev *rdev) 394static int twlfixed_get_voltage(struct regulator_dev *rdev)
337{ 395{
338 struct twlreg_info *info = rdev_get_drvdata(rdev); 396 struct twlreg_info *info = rdev_get_drvdata(rdev);
339 397
340 return info->min_mV * 1000; 398 return info->min_mV * 1000;
341} 399}
342 400
343static struct regulator_ops twl4030fixed_ops = { 401static struct regulator_ops twlfixed_ops = {
344 .list_voltage = twl4030fixed_list_voltage, 402 .list_voltage = twlfixed_list_voltage,
345 403
346 .get_voltage = twl4030fixed_get_voltage, 404 .get_voltage = twlfixed_get_voltage,
347 405
348 .enable = twl4030reg_enable, 406 .enable = twlreg_enable,
349 .disable = twl4030reg_disable, 407 .disable = twlreg_disable,
350 .is_enabled = twl4030reg_is_enabled, 408 .is_enabled = twlreg_is_enabled,
351 409
352 .set_mode = twl4030reg_set_mode, 410 .set_mode = twlreg_set_mode,
353 411
354 .get_status = twl4030reg_get_status, 412 .get_status = twlreg_get_status,
355}; 413};
356 414
357/*----------------------------------------------------------------------*/ 415/*----------------------------------------------------------------------*/
358 416
359#define TWL_ADJUSTABLE_LDO(label, offset, num) { \ 417#define TWL4030_ADJUSTABLE_LDO(label, offset, num) \
418 TWL_ADJUSTABLE_LDO(label, offset, num, TWL4030)
419#define TWL4030_FIXED_LDO(label, offset, mVolts, num) \
420 TWL_FIXED_LDO(label, offset, mVolts, num, TWL4030)
421#define TWL6030_ADJUSTABLE_LDO(label, offset, num) \
422 TWL_ADJUSTABLE_LDO(label, offset, num, TWL6030)
423#define TWL6030_FIXED_LDO(label, offset, mVolts, num) \
424 TWL_FIXED_LDO(label, offset, mVolts, num, TWL6030)
425
426#define TWL_ADJUSTABLE_LDO(label, offset, num, family) { \
360 .base = offset, \ 427 .base = offset, \
361 .id = num, \ 428 .id = num, \
362 .table_len = ARRAY_SIZE(label##_VSEL_table), \ 429 .table_len = ARRAY_SIZE(label##_VSEL_table), \
363 .table = label##_VSEL_table, \ 430 .table = label##_VSEL_table, \
364 .desc = { \ 431 .desc = { \
365 .name = #label, \ 432 .name = #label, \
366 .id = TWL4030_REG_##label, \ 433 .id = family##_REG_##label, \
367 .n_voltages = ARRAY_SIZE(label##_VSEL_table), \ 434 .n_voltages = ARRAY_SIZE(label##_VSEL_table), \
368 .ops = &twl4030ldo_ops, \ 435 .ops = &twlldo_ops, \
369 .type = REGULATOR_VOLTAGE, \ 436 .type = REGULATOR_VOLTAGE, \
370 .owner = THIS_MODULE, \ 437 .owner = THIS_MODULE, \
371 }, \ 438 }, \
372 } 439 }
373 440
374#define TWL_FIXED_LDO(label, offset, mVolts, num) { \ 441#define TWL_FIXED_LDO(label, offset, mVolts, num, family) { \
375 .base = offset, \ 442 .base = offset, \
376 .id = num, \ 443 .id = num, \
377 .min_mV = mVolts, \ 444 .min_mV = mVolts, \
378 .desc = { \ 445 .desc = { \
379 .name = #label, \ 446 .name = #label, \
380 .id = TWL4030_REG_##label, \ 447 .id = family##_REG_##label, \
381 .n_voltages = 1, \ 448 .n_voltages = 1, \
382 .ops = &twl4030fixed_ops, \ 449 .ops = &twlfixed_ops, \
383 .type = REGULATOR_VOLTAGE, \ 450 .type = REGULATOR_VOLTAGE, \
384 .owner = THIS_MODULE, \ 451 .owner = THIS_MODULE, \
385 }, \ 452 }, \
@@ -389,35 +456,47 @@ static struct regulator_ops twl4030fixed_ops = {
389 * We list regulators here if systems need some level of 456 * We list regulators here if systems need some level of
390 * software control over them after boot. 457 * software control over them after boot.
391 */ 458 */
392static struct twlreg_info twl4030_regs[] = { 459static struct twlreg_info twl_regs[] = {
393 TWL_ADJUSTABLE_LDO(VAUX1, 0x17, 1), 460 TWL4030_ADJUSTABLE_LDO(VAUX1, 0x17, 1),
394 TWL_ADJUSTABLE_LDO(VAUX2_4030, 0x1b, 2), 461 TWL4030_ADJUSTABLE_LDO(VAUX2_4030, 0x1b, 2),
395 TWL_ADJUSTABLE_LDO(VAUX2, 0x1b, 2), 462 TWL4030_ADJUSTABLE_LDO(VAUX2, 0x1b, 2),
396 TWL_ADJUSTABLE_LDO(VAUX3, 0x1f, 3), 463 TWL4030_ADJUSTABLE_LDO(VAUX3, 0x1f, 3),
397 TWL_ADJUSTABLE_LDO(VAUX4, 0x23, 4), 464 TWL4030_ADJUSTABLE_LDO(VAUX4, 0x23, 4),
398 TWL_ADJUSTABLE_LDO(VMMC1, 0x27, 5), 465 TWL4030_ADJUSTABLE_LDO(VMMC1, 0x27, 5),
399 TWL_ADJUSTABLE_LDO(VMMC2, 0x2b, 6), 466 TWL4030_ADJUSTABLE_LDO(VMMC2, 0x2b, 6),
400 /* 467 /*
401 TWL_ADJUSTABLE_LDO(VPLL1, 0x2f, 7), 468 TWL4030_ADJUSTABLE_LDO(VPLL1, 0x2f, 7),
402 */ 469 */
403 TWL_ADJUSTABLE_LDO(VPLL2, 0x33, 8), 470 TWL4030_ADJUSTABLE_LDO(VPLL2, 0x33, 8),
404 TWL_ADJUSTABLE_LDO(VSIM, 0x37, 9), 471 TWL4030_ADJUSTABLE_LDO(VSIM, 0x37, 9),
405 TWL_ADJUSTABLE_LDO(VDAC, 0x3b, 10), 472 TWL4030_ADJUSTABLE_LDO(VDAC, 0x3b, 10),
406 /* 473 /*
407 TWL_ADJUSTABLE_LDO(VINTANA1, 0x3f, 11), 474 TWL4030_ADJUSTABLE_LDO(VINTANA1, 0x3f, 11),
408 TWL_ADJUSTABLE_LDO(VINTANA2, 0x43, 12), 475 TWL4030_ADJUSTABLE_LDO(VINTANA2, 0x43, 12),
409 TWL_ADJUSTABLE_LDO(VINTDIG, 0x47, 13), 476 TWL4030_ADJUSTABLE_LDO(VINTDIG, 0x47, 13),
410 TWL_SMPS(VIO, 0x4b, 14), 477 TWL4030_SMPS(VIO, 0x4b, 14),
411 TWL_SMPS(VDD1, 0x55, 15), 478 TWL4030_SMPS(VDD1, 0x55, 15),
412 TWL_SMPS(VDD2, 0x63, 16), 479 TWL4030_SMPS(VDD2, 0x63, 16),
413 */ 480 */
414 TWL_FIXED_LDO(VUSB1V5, 0x71, 1500, 17), 481 TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17),
415 TWL_FIXED_LDO(VUSB1V8, 0x74, 1800, 18), 482 TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18),
416 TWL_FIXED_LDO(VUSB3V1, 0x77, 3100, 19), 483 TWL4030_FIXED_LDO(VUSB3V1, 0x77, 3100, 19),
417 /* VUSBCP is managed *only* by the USB subchip */ 484 /* VUSBCP is managed *only* by the USB subchip */
485
486 /* 6030 REG with base as PMC Slave Misc : 0x0030 */
487 TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1),
488 TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 2),
489 TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 3),
490 TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 4),
491 TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 5),
492 TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 7),
493 TWL6030_FIXED_LDO(VANA, 0x50, 2100, 15),
494 TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 16),
495 TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 17),
496 TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 18)
418}; 497};
419 498
420static int twl4030reg_probe(struct platform_device *pdev) 499static int twlreg_probe(struct platform_device *pdev)
421{ 500{
422 int i; 501 int i;
423 struct twlreg_info *info; 502 struct twlreg_info *info;
@@ -425,10 +504,10 @@ static int twl4030reg_probe(struct platform_device *pdev)
425 struct regulation_constraints *c; 504 struct regulation_constraints *c;
426 struct regulator_dev *rdev; 505 struct regulator_dev *rdev;
427 506
428 for (i = 0, info = NULL; i < ARRAY_SIZE(twl4030_regs); i++) { 507 for (i = 0, info = NULL; i < ARRAY_SIZE(twl_regs); i++) {
429 if (twl4030_regs[i].desc.id != pdev->id) 508 if (twl_regs[i].desc.id != pdev->id)
430 continue; 509 continue;
431 info = twl4030_regs + i; 510 info = twl_regs + i;
432 break; 511 break;
433 } 512 }
434 if (!info) 513 if (!info)
@@ -466,35 +545,35 @@ static int twl4030reg_probe(struct platform_device *pdev)
466 return 0; 545 return 0;
467} 546}
468 547
469static int __devexit twl4030reg_remove(struct platform_device *pdev) 548static int __devexit twlreg_remove(struct platform_device *pdev)
470{ 549{
471 regulator_unregister(platform_get_drvdata(pdev)); 550 regulator_unregister(platform_get_drvdata(pdev));
472 return 0; 551 return 0;
473} 552}
474 553
475MODULE_ALIAS("platform:twl4030_reg"); 554MODULE_ALIAS("platform:twl_reg");
476 555
477static struct platform_driver twl4030reg_driver = { 556static struct platform_driver twlreg_driver = {
478 .probe = twl4030reg_probe, 557 .probe = twlreg_probe,
479 .remove = __devexit_p(twl4030reg_remove), 558 .remove = __devexit_p(twlreg_remove),
480 /* NOTE: short name, to work around driver model truncation of 559 /* NOTE: short name, to work around driver model truncation of
481 * "twl4030_regulator.12" (and friends) to "twl4030_regulator.1". 560 * "twl_regulator.12" (and friends) to "twl_regulator.1".
482 */ 561 */
483 .driver.name = "twl4030_reg", 562 .driver.name = "twl_reg",
484 .driver.owner = THIS_MODULE, 563 .driver.owner = THIS_MODULE,
485}; 564};
486 565
487static int __init twl4030reg_init(void) 566static int __init twlreg_init(void)
488{ 567{
489 return platform_driver_register(&twl4030reg_driver); 568 return platform_driver_register(&twlreg_driver);
490} 569}
491subsys_initcall(twl4030reg_init); 570subsys_initcall(twlreg_init);
492 571
493static void __exit twl4030reg_exit(void) 572static void __exit twlreg_exit(void)
494{ 573{
495 platform_driver_unregister(&twl4030reg_driver); 574 platform_driver_unregister(&twlreg_driver);
496} 575}
497module_exit(twl4030reg_exit) 576module_exit(twlreg_exit)
498 577
499MODULE_DESCRIPTION("TWL4030 regulator driver"); 578MODULE_DESCRIPTION("TWL regulator driver");
500MODULE_LICENSE("GPL"); 579MODULE_LICENSE("GPL");
diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c
index 768bd0e5b48b..1bbff099a546 100644
--- a/drivers/regulator/wm8350-regulator.c
+++ b/drivers/regulator/wm8350-regulator.c
@@ -1330,9 +1330,10 @@ static struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
1330 }, 1330 },
1331}; 1331};
1332 1332
1333static void pmic_uv_handler(struct wm8350 *wm8350, int irq, void *data) 1333static irqreturn_t pmic_uv_handler(int irq, void *data)
1334{ 1334{
1335 struct regulator_dev *rdev = (struct regulator_dev *)data; 1335 struct regulator_dev *rdev = (struct regulator_dev *)data;
1336 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
1336 1337
1337 mutex_lock(&rdev->mutex); 1338 mutex_lock(&rdev->mutex);
1338 if (irq == WM8350_IRQ_CS1 || irq == WM8350_IRQ_CS2) 1339 if (irq == WM8350_IRQ_CS1 || irq == WM8350_IRQ_CS2)
@@ -1344,6 +1345,8 @@ static void pmic_uv_handler(struct wm8350 *wm8350, int irq, void *data)
1344 REGULATOR_EVENT_UNDER_VOLTAGE, 1345 REGULATOR_EVENT_UNDER_VOLTAGE,
1345 wm8350); 1346 wm8350);
1346 mutex_unlock(&rdev->mutex); 1347 mutex_unlock(&rdev->mutex);
1348
1349 return IRQ_HANDLED;
1347} 1350}
1348 1351
1349static int wm8350_regulator_probe(struct platform_device *pdev) 1352static int wm8350_regulator_probe(struct platform_device *pdev)
@@ -1388,7 +1391,7 @@ static int wm8350_regulator_probe(struct platform_device *pdev)
1388 1391
1389 /* register regulator IRQ */ 1392 /* register regulator IRQ */
1390 ret = wm8350_register_irq(wm8350, wm8350_reg[pdev->id].irq, 1393 ret = wm8350_register_irq(wm8350, wm8350_reg[pdev->id].irq,
1391 pmic_uv_handler, rdev); 1394 pmic_uv_handler, 0, "UV", rdev);
1392 if (ret < 0) { 1395 if (ret < 0) {
1393 regulator_unregister(rdev); 1396 regulator_unregister(rdev);
1394 dev_err(&pdev->dev, "failed to register regulator %s IRQ\n", 1397 dev_err(&pdev->dev, "failed to register regulator %s IRQ\n",
@@ -1396,8 +1399,6 @@ static int wm8350_regulator_probe(struct platform_device *pdev)
1396 return ret; 1399 return ret;
1397 } 1400 }
1398 1401
1399 wm8350_unmask_irq(wm8350, wm8350_reg[pdev->id].irq);
1400
1401 return 0; 1402 return 0;
1402} 1403}
1403 1404
@@ -1406,7 +1407,6 @@ static int wm8350_regulator_remove(struct platform_device *pdev)
1406 struct regulator_dev *rdev = platform_get_drvdata(pdev); 1407 struct regulator_dev *rdev = platform_get_drvdata(pdev);
1407 struct wm8350 *wm8350 = rdev_get_drvdata(rdev); 1408 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
1408 1409
1409 wm8350_mask_irq(wm8350, wm8350_reg[pdev->id].irq);
1410 wm8350_free_irq(wm8350, wm8350_reg[pdev->id].irq); 1410 wm8350_free_irq(wm8350, wm8350_reg[pdev->id].irq);
1411 1411
1412 regulator_unregister(rdev); 1412 regulator_unregister(rdev);
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index f2e1004d12c7..71fbd6e8edf7 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -258,14 +258,14 @@ config RTC_DRV_TWL92330
258 the Menelaus driver; it's not separate module. 258 the Menelaus driver; it's not separate module.
259 259
260config RTC_DRV_TWL4030 260config RTC_DRV_TWL4030
261 tristate "TI TWL4030/TWL5030/TPS659x0" 261 tristate "TI TWL4030/TWL5030/TWL6030/TPS659x0"
262 depends on RTC_CLASS && TWL4030_CORE 262 depends on RTC_CLASS && TWL4030_CORE
263 help 263 help
264 If you say yes here you get support for the RTC on the 264 If you say yes here you get support for the RTC on the
265 TWL4030 family chips, used mostly with OMAP3 platforms. 265 TWL4030/TWL5030/TWL6030 family chips, used mostly with OMAP3 platforms.
266 266
267 This driver can also be built as a module. If so, the module 267 This driver can also be built as a module. If so, the module
268 will be called rtc-twl4030. 268 will be called rtc-twl.
269 269
270config RTC_DRV_S35390A 270config RTC_DRV_S35390A
271 tristate "Seiko Instruments S-35390A" 271 tristate "Seiko Instruments S-35390A"
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index af1ba7ae2857..7da6efb3e953 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -80,7 +80,7 @@ obj-$(CONFIG_RTC_DRV_STK17TA8) += rtc-stk17ta8.o
80obj-$(CONFIG_RTC_DRV_STMP) += rtc-stmp3xxx.o 80obj-$(CONFIG_RTC_DRV_STMP) += rtc-stmp3xxx.o
81obj-$(CONFIG_RTC_DRV_SUN4V) += rtc-sun4v.o 81obj-$(CONFIG_RTC_DRV_SUN4V) += rtc-sun4v.o
82obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o 82obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o
83obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl4030.o 83obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl.o
84obj-$(CONFIG_RTC_DRV_TX4939) += rtc-tx4939.o 84obj-$(CONFIG_RTC_DRV_TX4939) += rtc-tx4939.o
85obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o 85obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o
86obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o 86obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o
diff --git a/drivers/rtc/rtc-pcf50633.c b/drivers/rtc/rtc-pcf50633.c
index 4c5d5d0c4cfc..9b74e9c9151c 100644
--- a/drivers/rtc/rtc-pcf50633.c
+++ b/drivers/rtc/rtc-pcf50633.c
@@ -277,16 +277,13 @@ static void pcf50633_rtc_irq(int irq, void *data)
277 277
278static int __devinit pcf50633_rtc_probe(struct platform_device *pdev) 278static int __devinit pcf50633_rtc_probe(struct platform_device *pdev)
279{ 279{
280 struct pcf50633_subdev_pdata *pdata;
281 struct pcf50633_rtc *rtc; 280 struct pcf50633_rtc *rtc;
282 281
283
284 rtc = kzalloc(sizeof(*rtc), GFP_KERNEL); 282 rtc = kzalloc(sizeof(*rtc), GFP_KERNEL);
285 if (!rtc) 283 if (!rtc)
286 return -ENOMEM; 284 return -ENOMEM;
287 285
288 pdata = pdev->dev.platform_data; 286 rtc->pcf = dev_to_pcf50633(pdev->dev.parent);
289 rtc->pcf = pdata->pcf;
290 platform_set_drvdata(pdev, rtc); 287 platform_set_drvdata(pdev, rtc);
291 rtc->rtc_dev = rtc_device_register("pcf50633-rtc", &pdev->dev, 288 rtc->rtc_dev = rtc_device_register("pcf50633-rtc", &pdev->dev,
292 &pcf50633_rtc_ops, THIS_MODULE); 289 &pcf50633_rtc_ops, THIS_MODULE);
diff --git a/drivers/rtc/rtc-twl4030.c b/drivers/rtc/rtc-twl.c
index 9c8c70c497dc..c6a83a2a722c 100644
--- a/drivers/rtc/rtc-twl4030.c
+++ b/drivers/rtc/rtc-twl.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * rtc-twl4030.c -- TWL4030 Real Time Clock interface 2 * rtc-twl.c -- TWL Real Time Clock interface
3 * 3 *
4 * Copyright (C) 2007 MontaVista Software, Inc 4 * Copyright (C) 2007 MontaVista Software, Inc
5 * Author: Alexandre Rusev <source@mvista.com> 5 * Author: Alexandre Rusev <source@mvista.com>
@@ -28,33 +28,81 @@
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/interrupt.h> 29#include <linux/interrupt.h>
30 30
31#include <linux/i2c/twl4030.h> 31#include <linux/i2c/twl.h>
32 32
33 33
34/* 34/*
35 * RTC block register offsets (use TWL_MODULE_RTC) 35 * RTC block register offsets (use TWL_MODULE_RTC)
36 */ 36 */
37#define REG_SECONDS_REG 0x00 37enum {
38#define REG_MINUTES_REG 0x01 38 REG_SECONDS_REG = 0,
39#define REG_HOURS_REG 0x02 39 REG_MINUTES_REG,
40#define REG_DAYS_REG 0x03 40 REG_HOURS_REG,
41#define REG_MONTHS_REG 0x04 41 REG_DAYS_REG,
42#define REG_YEARS_REG 0x05 42 REG_MONTHS_REG,
43#define REG_WEEKS_REG 0x06 43 REG_YEARS_REG,
44 44 REG_WEEKS_REG,
45#define REG_ALARM_SECONDS_REG 0x07 45
46#define REG_ALARM_MINUTES_REG 0x08 46 REG_ALARM_SECONDS_REG,
47#define REG_ALARM_HOURS_REG 0x09 47 REG_ALARM_MINUTES_REG,
48#define REG_ALARM_DAYS_REG 0x0A 48 REG_ALARM_HOURS_REG,
49#define REG_ALARM_MONTHS_REG 0x0B 49 REG_ALARM_DAYS_REG,
50#define REG_ALARM_YEARS_REG 0x0C 50 REG_ALARM_MONTHS_REG,
51 51 REG_ALARM_YEARS_REG,
52#define REG_RTC_CTRL_REG 0x0D 52
53#define REG_RTC_STATUS_REG 0x0E 53 REG_RTC_CTRL_REG,
54#define REG_RTC_INTERRUPTS_REG 0x0F 54 REG_RTC_STATUS_REG,
55 55 REG_RTC_INTERRUPTS_REG,
56#define REG_RTC_COMP_LSB_REG 0x10 56
57#define REG_RTC_COMP_MSB_REG 0x11 57 REG_RTC_COMP_LSB_REG,
58 REG_RTC_COMP_MSB_REG,
59};
60const static u8 twl4030_rtc_reg_map[] = {
61 [REG_SECONDS_REG] = 0x00,
62 [REG_MINUTES_REG] = 0x01,
63 [REG_HOURS_REG] = 0x02,
64 [REG_DAYS_REG] = 0x03,
65 [REG_MONTHS_REG] = 0x04,
66 [REG_YEARS_REG] = 0x05,
67 [REG_WEEKS_REG] = 0x06,
68
69 [REG_ALARM_SECONDS_REG] = 0x07,
70 [REG_ALARM_MINUTES_REG] = 0x08,
71 [REG_ALARM_HOURS_REG] = 0x09,
72 [REG_ALARM_DAYS_REG] = 0x0A,
73 [REG_ALARM_MONTHS_REG] = 0x0B,
74 [REG_ALARM_YEARS_REG] = 0x0C,
75
76 [REG_RTC_CTRL_REG] = 0x0D,
77 [REG_RTC_STATUS_REG] = 0x0E,
78 [REG_RTC_INTERRUPTS_REG] = 0x0F,
79
80 [REG_RTC_COMP_LSB_REG] = 0x10,
81 [REG_RTC_COMP_MSB_REG] = 0x11,
82};
83const static u8 twl6030_rtc_reg_map[] = {
84 [REG_SECONDS_REG] = 0x00,
85 [REG_MINUTES_REG] = 0x01,
86 [REG_HOURS_REG] = 0x02,
87 [REG_DAYS_REG] = 0x03,
88 [REG_MONTHS_REG] = 0x04,
89 [REG_YEARS_REG] = 0x05,
90 [REG_WEEKS_REG] = 0x06,
91
92 [REG_ALARM_SECONDS_REG] = 0x08,
93 [REG_ALARM_MINUTES_REG] = 0x09,
94 [REG_ALARM_HOURS_REG] = 0x0A,
95 [REG_ALARM_DAYS_REG] = 0x0B,
96 [REG_ALARM_MONTHS_REG] = 0x0C,
97 [REG_ALARM_YEARS_REG] = 0x0D,
98
99 [REG_RTC_CTRL_REG] = 0x10,
100 [REG_RTC_STATUS_REG] = 0x11,
101 [REG_RTC_INTERRUPTS_REG] = 0x12,
102
103 [REG_RTC_COMP_LSB_REG] = 0x13,
104 [REG_RTC_COMP_MSB_REG] = 0x14,
105};
58 106
59/* RTC_CTRL_REG bitfields */ 107/* RTC_CTRL_REG bitfields */
60#define BIT_RTC_CTRL_REG_STOP_RTC_M 0x01 108#define BIT_RTC_CTRL_REG_STOP_RTC_M 0x01
@@ -84,31 +132,32 @@
84#define ALL_TIME_REGS 6 132#define ALL_TIME_REGS 6
85 133
86/*----------------------------------------------------------------------*/ 134/*----------------------------------------------------------------------*/
135static u8 *rtc_reg_map;
87 136
88/* 137/*
89 * Supports 1 byte read from TWL4030 RTC register. 138 * Supports 1 byte read from TWL RTC register.
90 */ 139 */
91static int twl4030_rtc_read_u8(u8 *data, u8 reg) 140static int twl_rtc_read_u8(u8 *data, u8 reg)
92{ 141{
93 int ret; 142 int ret;
94 143
95 ret = twl4030_i2c_read_u8(TWL4030_MODULE_RTC, data, reg); 144 ret = twl_i2c_read_u8(TWL_MODULE_RTC, data, (rtc_reg_map[reg]));
96 if (ret < 0) 145 if (ret < 0)
97 pr_err("twl4030_rtc: Could not read TWL4030" 146 pr_err("twl_rtc: Could not read TWL"
98 "register %X - error %d\n", reg, ret); 147 "register %X - error %d\n", reg, ret);
99 return ret; 148 return ret;
100} 149}
101 150
102/* 151/*
103 * Supports 1 byte write to TWL4030 RTC registers. 152 * Supports 1 byte write to TWL RTC registers.
104 */ 153 */
105static int twl4030_rtc_write_u8(u8 data, u8 reg) 154static int twl_rtc_write_u8(u8 data, u8 reg)
106{ 155{
107 int ret; 156 int ret;
108 157
109 ret = twl4030_i2c_write_u8(TWL4030_MODULE_RTC, data, reg); 158 ret = twl_i2c_write_u8(TWL_MODULE_RTC, data, (rtc_reg_map[reg]));
110 if (ret < 0) 159 if (ret < 0)
111 pr_err("twl4030_rtc: Could not write TWL4030" 160 pr_err("twl_rtc: Could not write TWL"
112 "register %X - error %d\n", reg, ret); 161 "register %X - error %d\n", reg, ret);
113 return ret; 162 return ret;
114} 163}
@@ -129,7 +178,7 @@ static int set_rtc_irq_bit(unsigned char bit)
129 178
130 val = rtc_irq_bits | bit; 179 val = rtc_irq_bits | bit;
131 val &= ~BIT_RTC_INTERRUPTS_REG_EVERY_M; 180 val &= ~BIT_RTC_INTERRUPTS_REG_EVERY_M;
132 ret = twl4030_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG); 181 ret = twl_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG);
133 if (ret == 0) 182 if (ret == 0)
134 rtc_irq_bits = val; 183 rtc_irq_bits = val;
135 184
@@ -145,14 +194,14 @@ static int mask_rtc_irq_bit(unsigned char bit)
145 int ret; 194 int ret;
146 195
147 val = rtc_irq_bits & ~bit; 196 val = rtc_irq_bits & ~bit;
148 ret = twl4030_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG); 197 ret = twl_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG);
149 if (ret == 0) 198 if (ret == 0)
150 rtc_irq_bits = val; 199 rtc_irq_bits = val;
151 200
152 return ret; 201 return ret;
153} 202}
154 203
155static int twl4030_rtc_alarm_irq_enable(struct device *dev, unsigned enabled) 204static int twl_rtc_alarm_irq_enable(struct device *dev, unsigned enabled)
156{ 205{
157 int ret; 206 int ret;
158 207
@@ -164,7 +213,7 @@ static int twl4030_rtc_alarm_irq_enable(struct device *dev, unsigned enabled)
164 return ret; 213 return ret;
165} 214}
166 215
167static int twl4030_rtc_update_irq_enable(struct device *dev, unsigned enabled) 216static int twl_rtc_update_irq_enable(struct device *dev, unsigned enabled)
168{ 217{
169 int ret; 218 int ret;
170 219
@@ -177,7 +226,7 @@ static int twl4030_rtc_update_irq_enable(struct device *dev, unsigned enabled)
177} 226}
178 227
179/* 228/*
180 * Gets current TWL4030 RTC time and date parameters. 229 * Gets current TWL RTC time and date parameters.
181 * 230 *
182 * The RTC's time/alarm representation is not what gmtime(3) requires 231 * The RTC's time/alarm representation is not what gmtime(3) requires
183 * Linux to use: 232 * Linux to use:
@@ -185,24 +234,24 @@ static int twl4030_rtc_update_irq_enable(struct device *dev, unsigned enabled)
185 * - Months are 1..12 vs Linux 0-11 234 * - Months are 1..12 vs Linux 0-11
186 * - Years are 0..99 vs Linux 1900..N (we assume 21st century) 235 * - Years are 0..99 vs Linux 1900..N (we assume 21st century)
187 */ 236 */
188static int twl4030_rtc_read_time(struct device *dev, struct rtc_time *tm) 237static int twl_rtc_read_time(struct device *dev, struct rtc_time *tm)
189{ 238{
190 unsigned char rtc_data[ALL_TIME_REGS + 1]; 239 unsigned char rtc_data[ALL_TIME_REGS + 1];
191 int ret; 240 int ret;
192 u8 save_control; 241 u8 save_control;
193 242
194 ret = twl4030_rtc_read_u8(&save_control, REG_RTC_CTRL_REG); 243 ret = twl_rtc_read_u8(&save_control, REG_RTC_CTRL_REG);
195 if (ret < 0) 244 if (ret < 0)
196 return ret; 245 return ret;
197 246
198 save_control |= BIT_RTC_CTRL_REG_GET_TIME_M; 247 save_control |= BIT_RTC_CTRL_REG_GET_TIME_M;
199 248
200 ret = twl4030_rtc_write_u8(save_control, REG_RTC_CTRL_REG); 249 ret = twl_rtc_write_u8(save_control, REG_RTC_CTRL_REG);
201 if (ret < 0) 250 if (ret < 0)
202 return ret; 251 return ret;
203 252
204 ret = twl4030_i2c_read(TWL4030_MODULE_RTC, rtc_data, 253 ret = twl_i2c_read(TWL_MODULE_RTC, rtc_data,
205 REG_SECONDS_REG, ALL_TIME_REGS); 254 (rtc_reg_map[REG_SECONDS_REG]), ALL_TIME_REGS);
206 255
207 if (ret < 0) { 256 if (ret < 0) {
208 dev_err(dev, "rtc_read_time error %d\n", ret); 257 dev_err(dev, "rtc_read_time error %d\n", ret);
@@ -219,7 +268,7 @@ static int twl4030_rtc_read_time(struct device *dev, struct rtc_time *tm)
219 return ret; 268 return ret;
220} 269}
221 270
222static int twl4030_rtc_set_time(struct device *dev, struct rtc_time *tm) 271static int twl_rtc_set_time(struct device *dev, struct rtc_time *tm)
223{ 272{
224 unsigned char save_control; 273 unsigned char save_control;
225 unsigned char rtc_data[ALL_TIME_REGS + 1]; 274 unsigned char rtc_data[ALL_TIME_REGS + 1];
@@ -233,18 +282,18 @@ static int twl4030_rtc_set_time(struct device *dev, struct rtc_time *tm)
233 rtc_data[6] = bin2bcd(tm->tm_year - 100); 282 rtc_data[6] = bin2bcd(tm->tm_year - 100);
234 283
235 /* Stop RTC while updating the TC registers */ 284 /* Stop RTC while updating the TC registers */
236 ret = twl4030_rtc_read_u8(&save_control, REG_RTC_CTRL_REG); 285 ret = twl_rtc_read_u8(&save_control, REG_RTC_CTRL_REG);
237 if (ret < 0) 286 if (ret < 0)
238 goto out; 287 goto out;
239 288
240 save_control &= ~BIT_RTC_CTRL_REG_STOP_RTC_M; 289 save_control &= ~BIT_RTC_CTRL_REG_STOP_RTC_M;
241 twl4030_rtc_write_u8(save_control, REG_RTC_CTRL_REG); 290 twl_rtc_write_u8(save_control, REG_RTC_CTRL_REG);
242 if (ret < 0) 291 if (ret < 0)
243 goto out; 292 goto out;
244 293
245 /* update all the time registers in one shot */ 294 /* update all the time registers in one shot */
246 ret = twl4030_i2c_write(TWL4030_MODULE_RTC, rtc_data, 295 ret = twl_i2c_write(TWL_MODULE_RTC, rtc_data,
247 REG_SECONDS_REG, ALL_TIME_REGS); 296 (rtc_reg_map[REG_SECONDS_REG]), ALL_TIME_REGS);
248 if (ret < 0) { 297 if (ret < 0) {
249 dev_err(dev, "rtc_set_time error %d\n", ret); 298 dev_err(dev, "rtc_set_time error %d\n", ret);
250 goto out; 299 goto out;
@@ -252,22 +301,22 @@ static int twl4030_rtc_set_time(struct device *dev, struct rtc_time *tm)
252 301
253 /* Start back RTC */ 302 /* Start back RTC */
254 save_control |= BIT_RTC_CTRL_REG_STOP_RTC_M; 303 save_control |= BIT_RTC_CTRL_REG_STOP_RTC_M;
255 ret = twl4030_rtc_write_u8(save_control, REG_RTC_CTRL_REG); 304 ret = twl_rtc_write_u8(save_control, REG_RTC_CTRL_REG);
256 305
257out: 306out:
258 return ret; 307 return ret;
259} 308}
260 309
261/* 310/*
262 * Gets current TWL4030 RTC alarm time. 311 * Gets current TWL RTC alarm time.
263 */ 312 */
264static int twl4030_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) 313static int twl_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
265{ 314{
266 unsigned char rtc_data[ALL_TIME_REGS + 1]; 315 unsigned char rtc_data[ALL_TIME_REGS + 1];
267 int ret; 316 int ret;
268 317
269 ret = twl4030_i2c_read(TWL4030_MODULE_RTC, rtc_data, 318 ret = twl_i2c_read(TWL_MODULE_RTC, rtc_data,
270 REG_ALARM_SECONDS_REG, ALL_TIME_REGS); 319 (rtc_reg_map[REG_ALARM_SECONDS_REG]), ALL_TIME_REGS);
271 if (ret < 0) { 320 if (ret < 0) {
272 dev_err(dev, "rtc_read_alarm error %d\n", ret); 321 dev_err(dev, "rtc_read_alarm error %d\n", ret);
273 return ret; 322 return ret;
@@ -288,12 +337,12 @@ static int twl4030_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
288 return ret; 337 return ret;
289} 338}
290 339
291static int twl4030_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) 340static int twl_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
292{ 341{
293 unsigned char alarm_data[ALL_TIME_REGS + 1]; 342 unsigned char alarm_data[ALL_TIME_REGS + 1];
294 int ret; 343 int ret;
295 344
296 ret = twl4030_rtc_alarm_irq_enable(dev, 0); 345 ret = twl_rtc_alarm_irq_enable(dev, 0);
297 if (ret) 346 if (ret)
298 goto out; 347 goto out;
299 348
@@ -305,20 +354,20 @@ static int twl4030_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
305 alarm_data[6] = bin2bcd(alm->time.tm_year - 100); 354 alarm_data[6] = bin2bcd(alm->time.tm_year - 100);
306 355
307 /* update all the alarm registers in one shot */ 356 /* update all the alarm registers in one shot */
308 ret = twl4030_i2c_write(TWL4030_MODULE_RTC, alarm_data, 357 ret = twl_i2c_write(TWL_MODULE_RTC, alarm_data,
309 REG_ALARM_SECONDS_REG, ALL_TIME_REGS); 358 (rtc_reg_map[REG_ALARM_SECONDS_REG]), ALL_TIME_REGS);
310 if (ret) { 359 if (ret) {
311 dev_err(dev, "rtc_set_alarm error %d\n", ret); 360 dev_err(dev, "rtc_set_alarm error %d\n", ret);
312 goto out; 361 goto out;
313 } 362 }
314 363
315 if (alm->enabled) 364 if (alm->enabled)
316 ret = twl4030_rtc_alarm_irq_enable(dev, 1); 365 ret = twl_rtc_alarm_irq_enable(dev, 1);
317out: 366out:
318 return ret; 367 return ret;
319} 368}
320 369
321static irqreturn_t twl4030_rtc_interrupt(int irq, void *rtc) 370static irqreturn_t twl_rtc_interrupt(int irq, void *rtc)
322{ 371{
323 unsigned long events = 0; 372 unsigned long events = 0;
324 int ret = IRQ_NONE; 373 int ret = IRQ_NONE;
@@ -333,7 +382,7 @@ static irqreturn_t twl4030_rtc_interrupt(int irq, void *rtc)
333 local_irq_enable(); 382 local_irq_enable();
334#endif 383#endif
335 384
336 res = twl4030_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG); 385 res = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG);
337 if (res) 386 if (res)
338 goto out; 387 goto out;
339 /* 388 /*
@@ -347,26 +396,28 @@ static irqreturn_t twl4030_rtc_interrupt(int irq, void *rtc)
347 else 396 else
348 events |= RTC_IRQF | RTC_UF; 397 events |= RTC_IRQF | RTC_UF;
349 398
350 res = twl4030_rtc_write_u8(rd_reg | BIT_RTC_STATUS_REG_ALARM_M, 399 res = twl_rtc_write_u8(rd_reg | BIT_RTC_STATUS_REG_ALARM_M,
351 REG_RTC_STATUS_REG); 400 REG_RTC_STATUS_REG);
352 if (res) 401 if (res)
353 goto out; 402 goto out;
354 403
355 /* Clear on Read enabled. RTC_IT bit of TWL4030_INT_PWR_ISR1 404 if (twl_class_is_4030()) {
356 * needs 2 reads to clear the interrupt. One read is done in 405 /* Clear on Read enabled. RTC_IT bit of TWL4030_INT_PWR_ISR1
357 * do_twl4030_pwrirq(). Doing the second read, to clear 406 * needs 2 reads to clear the interrupt. One read is done in
358 * the bit. 407 * do_twl_pwrirq(). Doing the second read, to clear
359 * 408 * the bit.
360 * FIXME the reason PWR_ISR1 needs an extra read is that 409 *
361 * RTC_IF retriggered until we cleared REG_ALARM_M above. 410 * FIXME the reason PWR_ISR1 needs an extra read is that
362 * But re-reading like this is a bad hack; by doing so we 411 * RTC_IF retriggered until we cleared REG_ALARM_M above.
363 * risk wrongly clearing status for some other IRQ (losing 412 * But re-reading like this is a bad hack; by doing so we
364 * the interrupt). Be smarter about handling RTC_UF ... 413 * risk wrongly clearing status for some other IRQ (losing
365 */ 414 * the interrupt). Be smarter about handling RTC_UF ...
366 res = twl4030_i2c_read_u8(TWL4030_MODULE_INT, 415 */
416 res = twl_i2c_read_u8(TWL4030_MODULE_INT,
367 &rd_reg, TWL4030_INT_PWR_ISR1); 417 &rd_reg, TWL4030_INT_PWR_ISR1);
368 if (res) 418 if (res)
369 goto out; 419 goto out;
420 }
370 421
371 /* Notify RTC core on event */ 422 /* Notify RTC core on event */
372 rtc_update_irq(rtc, 1, events); 423 rtc_update_irq(rtc, 1, events);
@@ -376,18 +427,18 @@ out:
376 return ret; 427 return ret;
377} 428}
378 429
379static struct rtc_class_ops twl4030_rtc_ops = { 430static struct rtc_class_ops twl_rtc_ops = {
380 .read_time = twl4030_rtc_read_time, 431 .read_time = twl_rtc_read_time,
381 .set_time = twl4030_rtc_set_time, 432 .set_time = twl_rtc_set_time,
382 .read_alarm = twl4030_rtc_read_alarm, 433 .read_alarm = twl_rtc_read_alarm,
383 .set_alarm = twl4030_rtc_set_alarm, 434 .set_alarm = twl_rtc_set_alarm,
384 .alarm_irq_enable = twl4030_rtc_alarm_irq_enable, 435 .alarm_irq_enable = twl_rtc_alarm_irq_enable,
385 .update_irq_enable = twl4030_rtc_update_irq_enable, 436 .update_irq_enable = twl_rtc_update_irq_enable,
386}; 437};
387 438
388/*----------------------------------------------------------------------*/ 439/*----------------------------------------------------------------------*/
389 440
390static int __devinit twl4030_rtc_probe(struct platform_device *pdev) 441static int __devinit twl_rtc_probe(struct platform_device *pdev)
391{ 442{
392 struct rtc_device *rtc; 443 struct rtc_device *rtc;
393 int ret = 0; 444 int ret = 0;
@@ -398,7 +449,7 @@ static int __devinit twl4030_rtc_probe(struct platform_device *pdev)
398 return -EINVAL; 449 return -EINVAL;
399 450
400 rtc = rtc_device_register(pdev->name, 451 rtc = rtc_device_register(pdev->name,
401 &pdev->dev, &twl4030_rtc_ops, THIS_MODULE); 452 &pdev->dev, &twl_rtc_ops, THIS_MODULE);
402 if (IS_ERR(rtc)) { 453 if (IS_ERR(rtc)) {
403 ret = PTR_ERR(rtc); 454 ret = PTR_ERR(rtc);
404 dev_err(&pdev->dev, "can't register RTC device, err %ld\n", 455 dev_err(&pdev->dev, "can't register RTC device, err %ld\n",
@@ -409,7 +460,7 @@ static int __devinit twl4030_rtc_probe(struct platform_device *pdev)
409 460
410 platform_set_drvdata(pdev, rtc); 461 platform_set_drvdata(pdev, rtc);
411 462
412 ret = twl4030_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG); 463 ret = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG);
413 if (ret < 0) 464 if (ret < 0)
414 goto out1; 465 goto out1;
415 466
@@ -420,11 +471,11 @@ static int __devinit twl4030_rtc_probe(struct platform_device *pdev)
420 dev_warn(&pdev->dev, "Pending Alarm interrupt detected.\n"); 471 dev_warn(&pdev->dev, "Pending Alarm interrupt detected.\n");
421 472
422 /* Clear RTC Power up reset and pending alarm interrupts */ 473 /* Clear RTC Power up reset and pending alarm interrupts */
423 ret = twl4030_rtc_write_u8(rd_reg, REG_RTC_STATUS_REG); 474 ret = twl_rtc_write_u8(rd_reg, REG_RTC_STATUS_REG);
424 if (ret < 0) 475 if (ret < 0)
425 goto out1; 476 goto out1;
426 477
427 ret = request_irq(irq, twl4030_rtc_interrupt, 478 ret = request_irq(irq, twl_rtc_interrupt,
428 IRQF_TRIGGER_RISING, 479 IRQF_TRIGGER_RISING,
429 dev_name(&rtc->dev), rtc); 480 dev_name(&rtc->dev), rtc);
430 if (ret < 0) { 481 if (ret < 0) {
@@ -432,21 +483,28 @@ static int __devinit twl4030_rtc_probe(struct platform_device *pdev)
432 goto out1; 483 goto out1;
433 } 484 }
434 485
486 if (twl_class_is_6030()) {
487 twl6030_interrupt_unmask(TWL6030_RTC_INT_MASK,
488 REG_INT_MSK_LINE_A);
489 twl6030_interrupt_unmask(TWL6030_RTC_INT_MASK,
490 REG_INT_MSK_STS_A);
491 }
492
435 /* Check RTC module status, Enable if it is off */ 493 /* Check RTC module status, Enable if it is off */
436 ret = twl4030_rtc_read_u8(&rd_reg, REG_RTC_CTRL_REG); 494 ret = twl_rtc_read_u8(&rd_reg, REG_RTC_CTRL_REG);
437 if (ret < 0) 495 if (ret < 0)
438 goto out2; 496 goto out2;
439 497
440 if (!(rd_reg & BIT_RTC_CTRL_REG_STOP_RTC_M)) { 498 if (!(rd_reg & BIT_RTC_CTRL_REG_STOP_RTC_M)) {
441 dev_info(&pdev->dev, "Enabling TWL4030-RTC.\n"); 499 dev_info(&pdev->dev, "Enabling TWL-RTC.\n");
442 rd_reg = BIT_RTC_CTRL_REG_STOP_RTC_M; 500 rd_reg = BIT_RTC_CTRL_REG_STOP_RTC_M;
443 ret = twl4030_rtc_write_u8(rd_reg, REG_RTC_CTRL_REG); 501 ret = twl_rtc_write_u8(rd_reg, REG_RTC_CTRL_REG);
444 if (ret < 0) 502 if (ret < 0)
445 goto out2; 503 goto out2;
446 } 504 }
447 505
448 /* init cached IRQ enable bits */ 506 /* init cached IRQ enable bits */
449 ret = twl4030_rtc_read_u8(&rtc_irq_bits, REG_RTC_INTERRUPTS_REG); 507 ret = twl_rtc_read_u8(&rtc_irq_bits, REG_RTC_INTERRUPTS_REG);
450 if (ret < 0) 508 if (ret < 0)
451 goto out2; 509 goto out2;
452 510
@@ -461,10 +519,10 @@ out0:
461} 519}
462 520
463/* 521/*
464 * Disable all TWL4030 RTC module interrupts. 522 * Disable all TWL RTC module interrupts.
465 * Sets status flag to free. 523 * Sets status flag to free.
466 */ 524 */
467static int __devexit twl4030_rtc_remove(struct platform_device *pdev) 525static int __devexit twl_rtc_remove(struct platform_device *pdev)
468{ 526{
469 /* leave rtc running, but disable irqs */ 527 /* leave rtc running, but disable irqs */
470 struct rtc_device *rtc = platform_get_drvdata(pdev); 528 struct rtc_device *rtc = platform_get_drvdata(pdev);
@@ -472,6 +530,13 @@ static int __devexit twl4030_rtc_remove(struct platform_device *pdev)
472 530
473 mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_ALARM_M); 531 mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_ALARM_M);
474 mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_TIMER_M); 532 mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_TIMER_M);
533 if (twl_class_is_6030()) {
534 twl6030_interrupt_mask(TWL6030_RTC_INT_MASK,
535 REG_INT_MSK_LINE_A);
536 twl6030_interrupt_mask(TWL6030_RTC_INT_MASK,
537 REG_INT_MSK_STS_A);
538 }
539
475 540
476 free_irq(irq, rtc); 541 free_irq(irq, rtc);
477 542
@@ -480,7 +545,7 @@ static int __devexit twl4030_rtc_remove(struct platform_device *pdev)
480 return 0; 545 return 0;
481} 546}
482 547
483static void twl4030_rtc_shutdown(struct platform_device *pdev) 548static void twl_rtc_shutdown(struct platform_device *pdev)
484{ 549{
485 /* mask timer interrupts, but leave alarm interrupts on to enable 550 /* mask timer interrupts, but leave alarm interrupts on to enable
486 power-on when alarm is triggered */ 551 power-on when alarm is triggered */
@@ -491,7 +556,7 @@ static void twl4030_rtc_shutdown(struct platform_device *pdev)
491 556
492static unsigned char irqstat; 557static unsigned char irqstat;
493 558
494static int twl4030_rtc_suspend(struct platform_device *pdev, pm_message_t state) 559static int twl_rtc_suspend(struct platform_device *pdev, pm_message_t state)
495{ 560{
496 irqstat = rtc_irq_bits; 561 irqstat = rtc_irq_bits;
497 562
@@ -499,42 +564,47 @@ static int twl4030_rtc_suspend(struct platform_device *pdev, pm_message_t state)
499 return 0; 564 return 0;
500} 565}
501 566
502static int twl4030_rtc_resume(struct platform_device *pdev) 567static int twl_rtc_resume(struct platform_device *pdev)
503{ 568{
504 set_rtc_irq_bit(irqstat); 569 set_rtc_irq_bit(irqstat);
505 return 0; 570 return 0;
506} 571}
507 572
508#else 573#else
509#define twl4030_rtc_suspend NULL 574#define twl_rtc_suspend NULL
510#define twl4030_rtc_resume NULL 575#define twl_rtc_resume NULL
511#endif 576#endif
512 577
513MODULE_ALIAS("platform:twl4030_rtc"); 578MODULE_ALIAS("platform:twl_rtc");
514 579
515static struct platform_driver twl4030rtc_driver = { 580static struct platform_driver twl4030rtc_driver = {
516 .probe = twl4030_rtc_probe, 581 .probe = twl_rtc_probe,
517 .remove = __devexit_p(twl4030_rtc_remove), 582 .remove = __devexit_p(twl_rtc_remove),
518 .shutdown = twl4030_rtc_shutdown, 583 .shutdown = twl_rtc_shutdown,
519 .suspend = twl4030_rtc_suspend, 584 .suspend = twl_rtc_suspend,
520 .resume = twl4030_rtc_resume, 585 .resume = twl_rtc_resume,
521 .driver = { 586 .driver = {
522 .owner = THIS_MODULE, 587 .owner = THIS_MODULE,
523 .name = "twl4030_rtc", 588 .name = "twl_rtc",
524 }, 589 },
525}; 590};
526 591
527static int __init twl4030_rtc_init(void) 592static int __init twl_rtc_init(void)
528{ 593{
594 if (twl_class_is_4030())
595 rtc_reg_map = (u8 *) twl4030_rtc_reg_map;
596 else
597 rtc_reg_map = (u8 *) twl6030_rtc_reg_map;
598
529 return platform_driver_register(&twl4030rtc_driver); 599 return platform_driver_register(&twl4030rtc_driver);
530} 600}
531module_init(twl4030_rtc_init); 601module_init(twl_rtc_init);
532 602
533static void __exit twl4030_rtc_exit(void) 603static void __exit twl_rtc_exit(void)
534{ 604{
535 platform_driver_unregister(&twl4030rtc_driver); 605 platform_driver_unregister(&twl4030rtc_driver);
536} 606}
537module_exit(twl4030_rtc_exit); 607module_exit(twl_rtc_exit);
538 608
539MODULE_AUTHOR("Texas Instruments, MontaVista Software"); 609MODULE_AUTHOR("Texas Instruments, MontaVista Software");
540MODULE_LICENSE("GPL"); 610MODULE_LICENSE("GPL");
diff --git a/drivers/rtc/rtc-wm8350.c b/drivers/rtc/rtc-wm8350.c
index c91edc572eb6..f16486635a8e 100644
--- a/drivers/rtc/rtc-wm8350.c
+++ b/drivers/rtc/rtc-wm8350.c
@@ -315,9 +315,9 @@ static int wm8350_rtc_update_irq_enable(struct device *dev,
315 return 0; 315 return 0;
316} 316}
317 317
318static void wm8350_rtc_alarm_handler(struct wm8350 *wm8350, int irq, 318static irqreturn_t wm8350_rtc_alarm_handler(int irq, void *data)
319 void *data)
320{ 319{
320 struct wm8350 *wm8350 = data;
321 struct rtc_device *rtc = wm8350->rtc.rtc; 321 struct rtc_device *rtc = wm8350->rtc.rtc;
322 int ret; 322 int ret;
323 323
@@ -330,14 +330,18 @@ static void wm8350_rtc_alarm_handler(struct wm8350 *wm8350, int irq,
330 dev_err(&(wm8350->rtc.pdev->dev), 330 dev_err(&(wm8350->rtc.pdev->dev),
331 "Failed to disable alarm: %d\n", ret); 331 "Failed to disable alarm: %d\n", ret);
332 } 332 }
333
334 return IRQ_HANDLED;
333} 335}
334 336
335static void wm8350_rtc_update_handler(struct wm8350 *wm8350, int irq, 337static irqreturn_t wm8350_rtc_update_handler(int irq, void *data)
336 void *data)
337{ 338{
339 struct wm8350 *wm8350 = data;
338 struct rtc_device *rtc = wm8350->rtc.rtc; 340 struct rtc_device *rtc = wm8350->rtc.rtc;
339 341
340 rtc_update_irq(rtc, 1, RTC_IRQF | RTC_UF); 342 rtc_update_irq(rtc, 1, RTC_IRQF | RTC_UF);
343
344 return IRQ_HANDLED;
341} 345}
342 346
343static const struct rtc_class_ops wm8350_rtc_ops = { 347static const struct rtc_class_ops wm8350_rtc_ops = {
@@ -455,15 +459,14 @@ static int wm8350_rtc_probe(struct platform_device *pdev)
455 return ret; 459 return ret;
456 } 460 }
457 461
458 wm8350_mask_irq(wm8350, WM8350_IRQ_RTC_SEC);
459 wm8350_mask_irq(wm8350, WM8350_IRQ_RTC_PER);
460
461 wm8350_register_irq(wm8350, WM8350_IRQ_RTC_SEC, 462 wm8350_register_irq(wm8350, WM8350_IRQ_RTC_SEC,
462 wm8350_rtc_update_handler, NULL); 463 wm8350_rtc_update_handler, 0,
464 "RTC Seconds", wm8350);
465 wm8350_mask_irq(wm8350, WM8350_IRQ_RTC_SEC);
463 466
464 wm8350_register_irq(wm8350, WM8350_IRQ_RTC_ALM, 467 wm8350_register_irq(wm8350, WM8350_IRQ_RTC_ALM,
465 wm8350_rtc_alarm_handler, NULL); 468 wm8350_rtc_alarm_handler, 0,
466 wm8350_unmask_irq(wm8350, WM8350_IRQ_RTC_ALM); 469 "RTC Alarm", wm8350);
467 470
468 return 0; 471 return 0;
469} 472}
@@ -473,8 +476,6 @@ static int __devexit wm8350_rtc_remove(struct platform_device *pdev)
473 struct wm8350 *wm8350 = platform_get_drvdata(pdev); 476 struct wm8350 *wm8350 = platform_get_drvdata(pdev);
474 struct wm8350_rtc *wm_rtc = &wm8350->rtc; 477 struct wm8350_rtc *wm_rtc = &wm8350->rtc;
475 478
476 wm8350_mask_irq(wm8350, WM8350_IRQ_RTC_SEC);
477
478 wm8350_free_irq(wm8350, WM8350_IRQ_RTC_SEC); 479 wm8350_free_irq(wm8350, WM8350_IRQ_RTC_SEC);
479 wm8350_free_irq(wm8350, WM8350_IRQ_RTC_ALM); 480 wm8350_free_irq(wm8350, WM8350_IRQ_RTC_ALM);
480 481
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index 395c04c2b00f..98c04cac43c1 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -113,11 +113,9 @@ static inline int iucv_dbf_passes(debug_info_t *dbf_grp, int level)
113#define IUCV_DBF_TEXT_(name, level, text...) \ 113#define IUCV_DBF_TEXT_(name, level, text...) \
114 do { \ 114 do { \
115 if (iucv_dbf_passes(iucv_dbf_##name, level)) { \ 115 if (iucv_dbf_passes(iucv_dbf_##name, level)) { \
116 char* iucv_dbf_txt_buf = \ 116 char* __buf = get_cpu_var(iucv_dbf_txt_buf); \
117 get_cpu_var(iucv_dbf_txt_buf); \ 117 sprintf(__buf, text); \
118 sprintf(iucv_dbf_txt_buf, text); \ 118 debug_text_event(iucv_dbf_##name, level, __buf); \
119 debug_text_event(iucv_dbf_##name, level, \
120 iucv_dbf_txt_buf); \
121 put_cpu_var(iucv_dbf_txt_buf); \ 119 put_cpu_var(iucv_dbf_txt_buf); \
122 } \ 120 } \
123 } while (0) 121 } while (0)
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 28fce65b8594..2d9d70359360 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -169,6 +169,12 @@ config SPI_OMAP24XX
169 SPI master controller for OMAP24xx/OMAP34xx Multichannel SPI 169 SPI master controller for OMAP24xx/OMAP34xx Multichannel SPI
170 (McSPI) modules. 170 (McSPI) modules.
171 171
172config SPI_OMAP_100K
173 tristate "OMAP SPI 100K"
174 depends on SPI_MASTER && (ARCH_OMAP850 || ARCH_OMAP730)
175 help
176 OMAP SPI 100K master controller for omap7xx boards.
177
172config SPI_ORION 178config SPI_ORION
173 tristate "Orion SPI master (EXPERIMENTAL)" 179 tristate "Orion SPI master (EXPERIMENTAL)"
174 depends on PLAT_ORION && EXPERIMENTAL 180 depends on PLAT_ORION && EXPERIMENTAL
@@ -220,6 +226,13 @@ config SPI_S3C24XX_GPIO
220 the inbuilt hardware cannot provide the transfer mode, or 226 the inbuilt hardware cannot provide the transfer mode, or
221 where the board is using non hardware connected pins. 227 where the board is using non hardware connected pins.
222 228
229config SPI_SH_MSIOF
230 tristate "SuperH MSIOF SPI controller"
231 depends on SUPERH && HAVE_CLK
232 select SPI_BITBANG
233 help
234 SPI driver for SuperH MSIOF blocks.
235
223config SPI_SH_SCI 236config SPI_SH_SCI
224 tristate "SuperH SCI SPI controller" 237 tristate "SuperH SCI SPI controller"
225 depends on SUPERH 238 depends on SUPERH
@@ -240,15 +253,38 @@ config SPI_TXX9
240 SPI driver for Toshiba TXx9 MIPS SoCs 253 SPI driver for Toshiba TXx9 MIPS SoCs
241 254
242config SPI_XILINX 255config SPI_XILINX
243 tristate "Xilinx SPI controller" 256 tristate "Xilinx SPI controller common module"
244 depends on (XILINX_VIRTEX || MICROBLAZE) && EXPERIMENTAL 257 depends on HAS_IOMEM && EXPERIMENTAL
245 select SPI_BITBANG 258 select SPI_BITBANG
259 select SPI_XILINX_OF if (XILINX_VIRTEX || MICROBLAZE)
246 help 260 help
247 This exposes the SPI controller IP from the Xilinx EDK. 261 This exposes the SPI controller IP from the Xilinx EDK.
248 262
249 See the "OPB Serial Peripheral Interface (SPI) (v1.00e)" 263 See the "OPB Serial Peripheral Interface (SPI) (v1.00e)"
250 Product Specification document (DS464) for hardware details. 264 Product Specification document (DS464) for hardware details.
251 265
266 Or for the DS570, see "XPS Serial Peripheral Interface (SPI) (v2.00b)"
267
268config SPI_XILINX_OF
269 tristate "Xilinx SPI controller OF device"
270 depends on SPI_XILINX && (XILINX_VIRTEX || MICROBLAZE)
271 help
272 This is the OF driver for the SPI controller IP from the Xilinx EDK.
273
274config SPI_XILINX_PLTFM
275 tristate "Xilinx SPI controller platform device"
276 depends on SPI_XILINX
277 help
278 This is the platform driver for the SPI controller IP
279 from the Xilinx EDK.
280
281config SPI_NUC900
282 tristate "Nuvoton NUC900 series SPI"
283 depends on ARCH_W90X900 && EXPERIMENTAL
284 select SPI_BITBANG
285 help
286 SPI driver for Nuvoton NUC900 series ARM SoCs
287
252# 288#
253# Add new SPI master controllers in alphabetical order above this line 289# Add new SPI master controllers in alphabetical order above this line
254# 290#
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index e3f092a9afa5..ed8c1675b52f 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -22,6 +22,7 @@ obj-$(CONFIG_SPI_LM70_LLP) += spi_lm70llp.o
22obj-$(CONFIG_SPI_PXA2XX) += pxa2xx_spi.o 22obj-$(CONFIG_SPI_PXA2XX) += pxa2xx_spi.o
23obj-$(CONFIG_SPI_OMAP_UWIRE) += omap_uwire.o 23obj-$(CONFIG_SPI_OMAP_UWIRE) += omap_uwire.o
24obj-$(CONFIG_SPI_OMAP24XX) += omap2_mcspi.o 24obj-$(CONFIG_SPI_OMAP24XX) += omap2_mcspi.o
25obj-$(CONFIG_SPI_OMAP_100K) += omap_spi_100k.o
25obj-$(CONFIG_SPI_ORION) += orion_spi.o 26obj-$(CONFIG_SPI_ORION) += orion_spi.o
26obj-$(CONFIG_SPI_PL022) += amba-pl022.o 27obj-$(CONFIG_SPI_PL022) += amba-pl022.o
27obj-$(CONFIG_SPI_MPC52xx_PSC) += mpc52xx_psc_spi.o 28obj-$(CONFIG_SPI_MPC52xx_PSC) += mpc52xx_psc_spi.o
@@ -32,8 +33,12 @@ obj-$(CONFIG_SPI_S3C24XX_GPIO) += spi_s3c24xx_gpio.o
32obj-$(CONFIG_SPI_S3C24XX) += spi_s3c24xx.o 33obj-$(CONFIG_SPI_S3C24XX) += spi_s3c24xx.o
33obj-$(CONFIG_SPI_TXX9) += spi_txx9.o 34obj-$(CONFIG_SPI_TXX9) += spi_txx9.o
34obj-$(CONFIG_SPI_XILINX) += xilinx_spi.o 35obj-$(CONFIG_SPI_XILINX) += xilinx_spi.o
36obj-$(CONFIG_SPI_XILINX_OF) += xilinx_spi_of.o
37obj-$(CONFIG_SPI_XILINX_PLTFM) += xilinx_spi_pltfm.o
35obj-$(CONFIG_SPI_SH_SCI) += spi_sh_sci.o 38obj-$(CONFIG_SPI_SH_SCI) += spi_sh_sci.o
39obj-$(CONFIG_SPI_SH_MSIOF) += spi_sh_msiof.o
36obj-$(CONFIG_SPI_STMP3XXX) += spi_stmp.o 40obj-$(CONFIG_SPI_STMP3XXX) += spi_stmp.o
41obj-$(CONFIG_SPI_NUC900) += spi_nuc900.o
37# ... add above this line ... 42# ... add above this line ...
38 43
39# SPI protocol drivers (device/link on bus) 44# SPI protocol drivers (device/link on bus)
diff --git a/drivers/spi/au1550_spi.c b/drivers/spi/au1550_spi.c
index 76cbc1a66598..cfd5ff9508fa 100644
--- a/drivers/spi/au1550_spi.c
+++ b/drivers/spi/au1550_spi.c
@@ -237,8 +237,14 @@ static int au1550_spi_setupxfer(struct spi_device *spi, struct spi_transfer *t)
237 unsigned bpw, hz; 237 unsigned bpw, hz;
238 u32 cfg, stat; 238 u32 cfg, stat;
239 239
240 bpw = t ? t->bits_per_word : spi->bits_per_word; 240 bpw = spi->bits_per_word;
241 hz = t ? t->speed_hz : spi->max_speed_hz; 241 hz = spi->max_speed_hz;
242 if (t) {
243 if (t->bits_per_word)
244 bpw = t->bits_per_word;
245 if (t->speed_hz)
246 hz = t->speed_hz;
247 }
242 248
243 if (bpw < 4 || bpw > 24) { 249 if (bpw < 4 || bpw > 24) {
244 dev_err(&spi->dev, "setupxfer: invalid bits_per_word=%d\n", 250 dev_err(&spi->dev, "setupxfer: invalid bits_per_word=%d\n",
diff --git a/drivers/spi/mpc52xx_spi.c b/drivers/spi/mpc52xx_spi.c
index ef8379b2c172..45bfe6458173 100644
--- a/drivers/spi/mpc52xx_spi.c
+++ b/drivers/spi/mpc52xx_spi.c
@@ -18,9 +18,9 @@
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/spi/spi.h> 20#include <linux/spi/spi.h>
21#include <linux/spi/mpc52xx_spi.h>
22#include <linux/of_spi.h> 21#include <linux/of_spi.h>
23#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/of_gpio.h>
24#include <asm/time.h> 24#include <asm/time.h>
25#include <asm/mpc52xx.h> 25#include <asm/mpc52xx.h>
26 26
@@ -53,7 +53,7 @@ MODULE_LICENSE("GPL");
53/* FSM state return values */ 53/* FSM state return values */
54#define FSM_STOP 0 /* Nothing more for the state machine to */ 54#define FSM_STOP 0 /* Nothing more for the state machine to */
55 /* do. If something interesting happens */ 55 /* do. If something interesting happens */
56 /* then and IRQ will be received */ 56 /* then an IRQ will be received */
57#define FSM_POLL 1 /* need to poll for completion, an IRQ is */ 57#define FSM_POLL 1 /* need to poll for completion, an IRQ is */
58 /* not expected */ 58 /* not expected */
59#define FSM_CONTINUE 2 /* Keep iterating the state machine */ 59#define FSM_CONTINUE 2 /* Keep iterating the state machine */
@@ -61,13 +61,12 @@ MODULE_LICENSE("GPL");
61/* Driver internal data */ 61/* Driver internal data */
62struct mpc52xx_spi { 62struct mpc52xx_spi {
63 struct spi_master *master; 63 struct spi_master *master;
64 u32 sysclk;
65 void __iomem *regs; 64 void __iomem *regs;
66 int irq0; /* MODF irq */ 65 int irq0; /* MODF irq */
67 int irq1; /* SPIF irq */ 66 int irq1; /* SPIF irq */
68 int ipb_freq; 67 unsigned int ipb_freq;
69 68
70 /* Statistics */ 69 /* Statistics; not used now, but will be reintroduced for debugfs */
71 int msg_count; 70 int msg_count;
72 int wcol_count; 71 int wcol_count;
73 int wcol_ticks; 72 int wcol_ticks;
@@ -79,7 +78,6 @@ struct mpc52xx_spi {
79 spinlock_t lock; 78 spinlock_t lock;
80 struct work_struct work; 79 struct work_struct work;
81 80
82
83 /* Details of current transfer (length, and buffer pointers) */ 81 /* Details of current transfer (length, and buffer pointers) */
84 struct spi_message *message; /* current message */ 82 struct spi_message *message; /* current message */
85 struct spi_transfer *transfer; /* current transfer */ 83 struct spi_transfer *transfer; /* current transfer */
@@ -89,6 +87,8 @@ struct mpc52xx_spi {
89 u8 *rx_buf; 87 u8 *rx_buf;
90 const u8 *tx_buf; 88 const u8 *tx_buf;
91 int cs_change; 89 int cs_change;
90 int gpio_cs_count;
91 unsigned int *gpio_cs;
92}; 92};
93 93
94/* 94/*
@@ -96,7 +96,13 @@ struct mpc52xx_spi {
96 */ 96 */
97static void mpc52xx_spi_chipsel(struct mpc52xx_spi *ms, int value) 97static void mpc52xx_spi_chipsel(struct mpc52xx_spi *ms, int value)
98{ 98{
99 out_8(ms->regs + SPI_PORTDATA, value ? 0 : 0x08); 99 int cs;
100
101 if (ms->gpio_cs_count > 0) {
102 cs = ms->message->spi->chip_select;
103 gpio_set_value(ms->gpio_cs[cs], value ? 0 : 1);
104 } else
105 out_8(ms->regs + SPI_PORTDATA, value ? 0 : 0x08);
100} 106}
101 107
102/* 108/*
@@ -221,7 +227,7 @@ static int mpc52xx_spi_fsmstate_transfer(int irq, struct mpc52xx_spi *ms,
221 ms->wcol_tx_timestamp = get_tbl(); 227 ms->wcol_tx_timestamp = get_tbl();
222 data = 0; 228 data = 0;
223 if (ms->tx_buf) 229 if (ms->tx_buf)
224 data = *(ms->tx_buf-1); 230 data = *(ms->tx_buf - 1);
225 out_8(ms->regs + SPI_DATA, data); /* try again */ 231 out_8(ms->regs + SPI_DATA, data); /* try again */
226 return FSM_CONTINUE; 232 return FSM_CONTINUE;
227 } else if (status & SPI_STATUS_MODF) { 233 } else if (status & SPI_STATUS_MODF) {
@@ -390,7 +396,9 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op,
390 struct spi_master *master; 396 struct spi_master *master;
391 struct mpc52xx_spi *ms; 397 struct mpc52xx_spi *ms;
392 void __iomem *regs; 398 void __iomem *regs;
393 int rc; 399 u8 ctrl1;
400 int rc, i = 0;
401 int gpio_cs;
394 402
395 /* MMIO registers */ 403 /* MMIO registers */
396 dev_dbg(&op->dev, "probing mpc5200 SPI device\n"); 404 dev_dbg(&op->dev, "probing mpc5200 SPI device\n");
@@ -399,7 +407,8 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op,
399 return -ENODEV; 407 return -ENODEV;
400 408
401 /* initialize the device */ 409 /* initialize the device */
402 out_8(regs+SPI_CTRL1, SPI_CTRL1_SPIE | SPI_CTRL1_SPE | SPI_CTRL1_MSTR); 410 ctrl1 = SPI_CTRL1_SPIE | SPI_CTRL1_SPE | SPI_CTRL1_MSTR;
411 out_8(regs + SPI_CTRL1, ctrl1);
403 out_8(regs + SPI_CTRL2, 0x0); 412 out_8(regs + SPI_CTRL2, 0x0);
404 out_8(regs + SPI_DATADIR, 0xe); /* Set output pins */ 413 out_8(regs + SPI_DATADIR, 0xe); /* Set output pins */
405 out_8(regs + SPI_PORTDATA, 0x8); /* Deassert /SS signal */ 414 out_8(regs + SPI_PORTDATA, 0x8); /* Deassert /SS signal */
@@ -409,6 +418,8 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op,
409 * on the SPI bus. This fault will also occur if the SPI signals 418 * on the SPI bus. This fault will also occur if the SPI signals
410 * are not connected to any pins (port_config setting) */ 419 * are not connected to any pins (port_config setting) */
411 in_8(regs + SPI_STATUS); 420 in_8(regs + SPI_STATUS);
421 out_8(regs + SPI_CTRL1, ctrl1);
422
412 in_8(regs + SPI_DATA); 423 in_8(regs + SPI_DATA);
413 if (in_8(regs + SPI_STATUS) & SPI_STATUS_MODF) { 424 if (in_8(regs + SPI_STATUS) & SPI_STATUS_MODF) {
414 dev_err(&op->dev, "mode fault; is port_config correct?\n"); 425 dev_err(&op->dev, "mode fault; is port_config correct?\n");
@@ -422,10 +433,12 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op,
422 rc = -ENOMEM; 433 rc = -ENOMEM;
423 goto err_alloc; 434 goto err_alloc;
424 } 435 }
436
425 master->bus_num = -1; 437 master->bus_num = -1;
426 master->num_chipselect = 1;
427 master->setup = mpc52xx_spi_setup; 438 master->setup = mpc52xx_spi_setup;
428 master->transfer = mpc52xx_spi_transfer; 439 master->transfer = mpc52xx_spi_transfer;
440 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;
441
429 dev_set_drvdata(&op->dev, master); 442 dev_set_drvdata(&op->dev, master);
430 443
431 ms = spi_master_get_devdata(master); 444 ms = spi_master_get_devdata(master);
@@ -435,16 +448,51 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op,
435 ms->irq1 = irq_of_parse_and_map(op->node, 1); 448 ms->irq1 = irq_of_parse_and_map(op->node, 1);
436 ms->state = mpc52xx_spi_fsmstate_idle; 449 ms->state = mpc52xx_spi_fsmstate_idle;
437 ms->ipb_freq = mpc5xxx_get_bus_frequency(op->node); 450 ms->ipb_freq = mpc5xxx_get_bus_frequency(op->node);
451 ms->gpio_cs_count = of_gpio_count(op->node);
452 if (ms->gpio_cs_count > 0) {
453 master->num_chipselect = ms->gpio_cs_count;
454 ms->gpio_cs = kmalloc(ms->gpio_cs_count * sizeof(unsigned int),
455 GFP_KERNEL);
456 if (!ms->gpio_cs) {
457 rc = -ENOMEM;
458 goto err_alloc;
459 }
460
461 for (i = 0; i < ms->gpio_cs_count; i++) {
462 gpio_cs = of_get_gpio(op->node, i);
463 if (gpio_cs < 0) {
464 dev_err(&op->dev,
465 "could not parse the gpio field "
466 "in oftree\n");
467 rc = -ENODEV;
468 goto err_gpio;
469 }
470
471 rc = gpio_request(gpio_cs, dev_name(&op->dev));
472 if (rc) {
473 dev_err(&op->dev,
474 "can't request spi cs gpio #%d "
475 "on gpio line %d\n", i, gpio_cs);
476 goto err_gpio;
477 }
478
479 gpio_direction_output(gpio_cs, 1);
480 ms->gpio_cs[i] = gpio_cs;
481 }
482 } else {
483 master->num_chipselect = 1;
484 }
485
438 spin_lock_init(&ms->lock); 486 spin_lock_init(&ms->lock);
439 INIT_LIST_HEAD(&ms->queue); 487 INIT_LIST_HEAD(&ms->queue);
440 INIT_WORK(&ms->work, mpc52xx_spi_wq); 488 INIT_WORK(&ms->work, mpc52xx_spi_wq);
441 489
442 /* Decide if interrupts can be used */ 490 /* Decide if interrupts can be used */
443 if (ms->irq0 && ms->irq1) { 491 if (ms->irq0 && ms->irq1) {
444 rc = request_irq(ms->irq0, mpc52xx_spi_irq, IRQF_SAMPLE_RANDOM, 492 rc = request_irq(ms->irq0, mpc52xx_spi_irq, 0,
445 "mpc5200-spi-modf", ms); 493 "mpc5200-spi-modf", ms);
446 rc |= request_irq(ms->irq1, mpc52xx_spi_irq, IRQF_SAMPLE_RANDOM, 494 rc |= request_irq(ms->irq1, mpc52xx_spi_irq, 0,
447 "mpc5200-spi-spiF", ms); 495 "mpc5200-spi-spif", ms);
448 if (rc) { 496 if (rc) {
449 free_irq(ms->irq0, ms); 497 free_irq(ms->irq0, ms);
450 free_irq(ms->irq1, ms); 498 free_irq(ms->irq1, ms);
@@ -471,6 +519,11 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op,
471 err_register: 519 err_register:
472 dev_err(&ms->master->dev, "initialization failed\n"); 520 dev_err(&ms->master->dev, "initialization failed\n");
473 spi_master_put(master); 521 spi_master_put(master);
522 err_gpio:
523 while (i-- > 0)
524 gpio_free(ms->gpio_cs[i]);
525
526 kfree(ms->gpio_cs);
474 err_alloc: 527 err_alloc:
475 err_init: 528 err_init:
476 iounmap(regs); 529 iounmap(regs);
@@ -481,10 +534,15 @@ static int __devexit mpc52xx_spi_remove(struct of_device *op)
481{ 534{
482 struct spi_master *master = dev_get_drvdata(&op->dev); 535 struct spi_master *master = dev_get_drvdata(&op->dev);
483 struct mpc52xx_spi *ms = spi_master_get_devdata(master); 536 struct mpc52xx_spi *ms = spi_master_get_devdata(master);
537 int i;
484 538
485 free_irq(ms->irq0, ms); 539 free_irq(ms->irq0, ms);
486 free_irq(ms->irq1, ms); 540 free_irq(ms->irq1, ms);
487 541
542 for (i = 0; i < ms->gpio_cs_count; i++)
543 gpio_free(ms->gpio_cs[i]);
544
545 kfree(ms->gpio_cs);
488 spi_unregister_master(master); 546 spi_unregister_master(master);
489 spi_master_put(master); 547 spi_master_put(master);
490 iounmap(ms->regs); 548 iounmap(ms->regs);
diff --git a/drivers/spi/omap_spi_100k.c b/drivers/spi/omap_spi_100k.c
new file mode 100644
index 000000000000..5355d90d1bee
--- /dev/null
+++ b/drivers/spi/omap_spi_100k.c
@@ -0,0 +1,635 @@
1/*
2 * OMAP7xx SPI 100k controller driver
3 * Author: Fabrice Crohas <fcrohas@gmail.com>
4 * from original omap1_mcspi driver
5 *
6 * Copyright (C) 2005, 2006 Nokia Corporation
7 * Author: Samuel Ortiz <samuel.ortiz@nokia.com> and
8 * Juha Yrj�l� <juha.yrjola@nokia.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */
25#include <linux/kernel.h>
26#include <linux/init.h>
27#include <linux/interrupt.h>
28#include <linux/module.h>
29#include <linux/device.h>
30#include <linux/delay.h>
31#include <linux/platform_device.h>
32#include <linux/err.h>
33#include <linux/clk.h>
34#include <linux/io.h>
35#include <linux/gpio.h>
36
37#include <linux/spi/spi.h>
38
39#include <plat/clock.h>
40
41#define OMAP1_SPI100K_MAX_FREQ 48000000
42
43#define ICR_SPITAS (OMAP7XX_ICR_BASE + 0x12)
44
45#define SPI_SETUP1 0x00
46#define SPI_SETUP2 0x02
47#define SPI_CTRL 0x04
48#define SPI_STATUS 0x06
49#define SPI_TX_LSB 0x08
50#define SPI_TX_MSB 0x0a
51#define SPI_RX_LSB 0x0c
52#define SPI_RX_MSB 0x0e
53
54#define SPI_SETUP1_INT_READ_ENABLE (1UL << 5)
55#define SPI_SETUP1_INT_WRITE_ENABLE (1UL << 4)
56#define SPI_SETUP1_CLOCK_DIVISOR(x) ((x) << 1)
57#define SPI_SETUP1_CLOCK_ENABLE (1UL << 0)
58
59#define SPI_SETUP2_ACTIVE_EDGE_FALLING (0UL << 0)
60#define SPI_SETUP2_ACTIVE_EDGE_RISING (1UL << 0)
61#define SPI_SETUP2_NEGATIVE_LEVEL (0UL << 5)
62#define SPI_SETUP2_POSITIVE_LEVEL (1UL << 5)
63#define SPI_SETUP2_LEVEL_TRIGGER (0UL << 10)
64#define SPI_SETUP2_EDGE_TRIGGER (1UL << 10)
65
66#define SPI_CTRL_SEN(x) ((x) << 7)
67#define SPI_CTRL_WORD_SIZE(x) (((x) - 1) << 2)
68#define SPI_CTRL_WR (1UL << 1)
69#define SPI_CTRL_RD (1UL << 0)
70
71#define SPI_STATUS_WE (1UL << 1)
72#define SPI_STATUS_RD (1UL << 0)
73
74#define WRITE 0
75#define READ 1
76
77
78/* use PIO for small transfers, avoiding DMA setup/teardown overhead and
79 * cache operations; better heuristics consider wordsize and bitrate.
80 */
81#define DMA_MIN_BYTES 8
82
83#define SPI_RUNNING 0
84#define SPI_SHUTDOWN 1
85
86struct omap1_spi100k {
87 struct work_struct work;
88
89 /* lock protects queue and registers */
90 spinlock_t lock;
91 struct list_head msg_queue;
92 struct spi_master *master;
93 struct clk *ick;
94 struct clk *fck;
95
96 /* Virtual base address of the controller */
97 void __iomem *base;
98
99 /* State of the SPI */
100 unsigned int state;
101};
102
103struct omap1_spi100k_cs {
104 void __iomem *base;
105 int word_len;
106};
107
108static struct workqueue_struct *omap1_spi100k_wq;
109
110#define MOD_REG_BIT(val, mask, set) do { \
111 if (set) \
112 val |= mask; \
113 else \
114 val &= ~mask; \
115} while (0)
116
117static void spi100k_enable_clock(struct spi_master *master)
118{
119 unsigned int val;
120 struct omap1_spi100k *spi100k = spi_master_get_devdata(master);
121
122 /* enable SPI */
123 val = readw(spi100k->base + SPI_SETUP1);
124 val |= SPI_SETUP1_CLOCK_ENABLE;
125 writew(val, spi100k->base + SPI_SETUP1);
126}
127
128static void spi100k_disable_clock(struct spi_master *master)
129{
130 unsigned int val;
131 struct omap1_spi100k *spi100k = spi_master_get_devdata(master);
132
133 /* disable SPI */
134 val = readw(spi100k->base + SPI_SETUP1);
135 val &= ~SPI_SETUP1_CLOCK_ENABLE;
136 writew(val, spi100k->base + SPI_SETUP1);
137}
138
139static void spi100k_write_data(struct spi_master *master, int len, int data)
140{
141 struct omap1_spi100k *spi100k = spi_master_get_devdata(master);
142
143 /* write 16-bit word */
144 spi100k_enable_clock(master);
145 writew( data , spi100k->base + SPI_TX_MSB);
146
147 writew(SPI_CTRL_SEN(0) |
148 SPI_CTRL_WORD_SIZE(len) |
149 SPI_CTRL_WR,
150 spi100k->base + SPI_CTRL);
151
152 /* Wait for bit ack send change */
153 while((readw(spi100k->base + SPI_STATUS) & SPI_STATUS_WE) != SPI_STATUS_WE);
154 udelay(1000);
155
156 spi100k_disable_clock(master);
157}
158
159static int spi100k_read_data(struct spi_master *master, int len)
160{
161 int dataH,dataL;
162 struct omap1_spi100k *spi100k = spi_master_get_devdata(master);
163
164 spi100k_enable_clock(master);
165 writew(SPI_CTRL_SEN(0) |
166 SPI_CTRL_WORD_SIZE(len) |
167 SPI_CTRL_RD,
168 spi100k->base + SPI_CTRL);
169
170 while((readw(spi100k->base + SPI_STATUS) & SPI_STATUS_RD) != SPI_STATUS_RD);
171 udelay(1000);
172
173 dataL = readw(spi100k->base + SPI_RX_LSB);
174 dataH = readw(spi100k->base + SPI_RX_MSB);
175 spi100k_disable_clock(master);
176
177 return dataL;
178}
179
180static void spi100k_open(struct spi_master *master)
181{
182 /* get control of SPI */
183 struct omap1_spi100k *spi100k = spi_master_get_devdata(master);
184
185 writew(SPI_SETUP1_INT_READ_ENABLE |
186 SPI_SETUP1_INT_WRITE_ENABLE |
187 SPI_SETUP1_CLOCK_DIVISOR(0), spi100k->base + SPI_SETUP1);
188
189 /* configure clock and interrupts */
190 writew(SPI_SETUP2_ACTIVE_EDGE_FALLING |
191 SPI_SETUP2_NEGATIVE_LEVEL |
192 SPI_SETUP2_LEVEL_TRIGGER, spi100k->base + SPI_SETUP2);
193}
194
195static void omap1_spi100k_force_cs(struct omap1_spi100k *spi100k, int enable)
196{
197 if (enable)
198 writew(0x05fc, spi100k->base + SPI_CTRL);
199 else
200 writew(0x05fd, spi100k->base + SPI_CTRL);
201}
202
203static unsigned
204omap1_spi100k_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
205{
206 struct omap1_spi100k *spi100k;
207 struct omap1_spi100k_cs *cs = spi->controller_state;
208 unsigned int count, c;
209 int word_len;
210
211 spi100k = spi_master_get_devdata(spi->master);
212 count = xfer->len;
213 c = count;
214 word_len = cs->word_len;
215
216 /* RX_ONLY mode needs dummy data in TX reg */
217 if (xfer->tx_buf == NULL)
218 spi100k_write_data(spi->master,word_len, 0);
219
220 if (word_len <= 8) {
221 u8 *rx;
222 const u8 *tx;
223
224 rx = xfer->rx_buf;
225 tx = xfer->tx_buf;
226 do {
227 c-=1;
228 if (xfer->tx_buf != NULL)
229 spi100k_write_data(spi->master,word_len, *tx);
230 if (xfer->rx_buf != NULL)
231 *rx = spi100k_read_data(spi->master,word_len);
232 } while(c);
233 } else if (word_len <= 16) {
234 u16 *rx;
235 const u16 *tx;
236
237 rx = xfer->rx_buf;
238 tx = xfer->tx_buf;
239 do {
240 c-=2;
241 if (xfer->tx_buf != NULL)
242 spi100k_write_data(spi->master,word_len, *tx++);
243 if (xfer->rx_buf != NULL)
244 *rx++ = spi100k_read_data(spi->master,word_len);
245 } while(c);
246 } else if (word_len <= 32) {
247 u32 *rx;
248 const u32 *tx;
249
250 rx = xfer->rx_buf;
251 tx = xfer->tx_buf;
252 do {
253 c-=4;
254 if (xfer->tx_buf != NULL)
255 spi100k_write_data(spi->master,word_len, *tx);
256 if (xfer->rx_buf != NULL)
257 *rx = spi100k_read_data(spi->master,word_len);
258 } while(c);
259 }
260 return count - c;
261}
262
263/* called only when no transfer is active to this device */
264static int omap1_spi100k_setup_transfer(struct spi_device *spi,
265 struct spi_transfer *t)
266{
267 struct omap1_spi100k *spi100k = spi_master_get_devdata(spi->master);
268 struct omap1_spi100k_cs *cs = spi->controller_state;
269 u8 word_len = spi->bits_per_word;
270
271 if (t != NULL && t->bits_per_word)
272 word_len = t->bits_per_word;
273 if (!word_len)
274 word_len = 8;
275
276 if (spi->bits_per_word > 32)
277 return -EINVAL;
278 cs->word_len = word_len;
279
280 /* SPI init before transfer */
281 writew(0x3e , spi100k->base + SPI_SETUP1);
282 writew(0x00 , spi100k->base + SPI_STATUS);
283 writew(0x3e , spi100k->base + SPI_CTRL);
284
285 return 0;
286}
287
288/* the spi->mode bits understood by this driver: */
289#define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH)
290
291static int omap1_spi100k_setup(struct spi_device *spi)
292{
293 int ret;
294 struct omap1_spi100k *spi100k;
295 struct omap1_spi100k_cs *cs = spi->controller_state;
296
297 if (spi->bits_per_word < 4 || spi->bits_per_word > 32) {
298 dev_dbg(&spi->dev, "setup: unsupported %d bit words\n",
299 spi->bits_per_word);
300 return -EINVAL;
301 }
302
303 spi100k = spi_master_get_devdata(spi->master);
304
305 if (!cs) {
306 cs = kzalloc(sizeof *cs, GFP_KERNEL);
307 if (!cs)
308 return -ENOMEM;
309 cs->base = spi100k->base + spi->chip_select * 0x14;
310 spi->controller_state = cs;
311 }
312
313 spi100k_open(spi->master);
314
315 clk_enable(spi100k->ick);
316 clk_enable(spi100k->fck);
317
318 ret = omap1_spi100k_setup_transfer(spi, NULL);
319
320 clk_disable(spi100k->ick);
321 clk_disable(spi100k->fck);
322
323 return ret;
324}
325
326static void omap1_spi100k_work(struct work_struct *work)
327{
328 struct omap1_spi100k *spi100k;
329 int status = 0;
330
331 spi100k = container_of(work, struct omap1_spi100k, work);
332 spin_lock_irq(&spi100k->lock);
333
334 clk_enable(spi100k->ick);
335 clk_enable(spi100k->fck);
336
337 /* We only enable one channel at a time -- the one whose message is
338 * at the head of the queue -- although this controller would gladly
339 * arbitrate among multiple channels. This corresponds to "single
340 * channel" master mode. As a side effect, we need to manage the
341 * chipselect with the FORCE bit ... CS != channel enable.
342 */
343 while (!list_empty(&spi100k->msg_queue)) {
344 struct spi_message *m;
345 struct spi_device *spi;
346 struct spi_transfer *t = NULL;
347 int cs_active = 0;
348 struct omap1_spi100k_cs *cs;
349 int par_override = 0;
350
351 m = container_of(spi100k->msg_queue.next, struct spi_message,
352 queue);
353
354 list_del_init(&m->queue);
355 spin_unlock_irq(&spi100k->lock);
356
357 spi = m->spi;
358 cs = spi->controller_state;
359
360 list_for_each_entry(t, &m->transfers, transfer_list) {
361 if (t->tx_buf == NULL && t->rx_buf == NULL && t->len) {
362 status = -EINVAL;
363 break;
364 }
365 if (par_override || t->speed_hz || t->bits_per_word) {
366 par_override = 1;
367 status = omap1_spi100k_setup_transfer(spi, t);
368 if (status < 0)
369 break;
370 if (!t->speed_hz && !t->bits_per_word)
371 par_override = 0;
372 }
373
374 if (!cs_active) {
375 omap1_spi100k_force_cs(spi100k, 1);
376 cs_active = 1;
377 }
378
379 if (t->len) {
380 unsigned count;
381
382 /* RX_ONLY mode needs dummy data in TX reg */
383 if (t->tx_buf == NULL)
384 spi100k_write_data(spi->master, 8, 0);
385
386 count = omap1_spi100k_txrx_pio(spi, t);
387 m->actual_length += count;
388
389 if (count != t->len) {
390 status = -EIO;
391 break;
392 }
393 }
394
395 if (t->delay_usecs)
396 udelay(t->delay_usecs);
397
398 /* ignore the "leave it on after last xfer" hint */
399
400 if (t->cs_change) {
401 omap1_spi100k_force_cs(spi100k, 0);
402 cs_active = 0;
403 }
404 }
405
406 /* Restore defaults if they were overriden */
407 if (par_override) {
408 par_override = 0;
409 status = omap1_spi100k_setup_transfer(spi, NULL);
410 }
411
412 if (cs_active)
413 omap1_spi100k_force_cs(spi100k, 0);
414
415 m->status = status;
416 m->complete(m->context);
417
418 spin_lock_irq(&spi100k->lock);
419 }
420
421 clk_disable(spi100k->ick);
422 clk_disable(spi100k->fck);
423 spin_unlock_irq(&spi100k->lock);
424
425 if (status < 0)
426 printk(KERN_WARNING "spi transfer failed with %d\n", status);
427}
428
429static int omap1_spi100k_transfer(struct spi_device *spi, struct spi_message *m)
430{
431 struct omap1_spi100k *spi100k;
432 unsigned long flags;
433 struct spi_transfer *t;
434
435 m->actual_length = 0;
436 m->status = -EINPROGRESS;
437
438 spi100k = spi_master_get_devdata(spi->master);
439
440 /* Don't accept new work if we're shutting down */
441 if (spi100k->state == SPI_SHUTDOWN)
442 return -ESHUTDOWN;
443
444 /* reject invalid messages and transfers */
445 if (list_empty(&m->transfers) || !m->complete)
446 return -EINVAL;
447
448 list_for_each_entry(t, &m->transfers, transfer_list) {
449 const void *tx_buf = t->tx_buf;
450 void *rx_buf = t->rx_buf;
451 unsigned len = t->len;
452
453 if (t->speed_hz > OMAP1_SPI100K_MAX_FREQ
454 || (len && !(rx_buf || tx_buf))
455 || (t->bits_per_word &&
456 ( t->bits_per_word < 4
457 || t->bits_per_word > 32))) {
458 dev_dbg(&spi->dev, "transfer: %d Hz, %d %s%s, %d bpw\n",
459 t->speed_hz,
460 len,
461 tx_buf ? "tx" : "",
462 rx_buf ? "rx" : "",
463 t->bits_per_word);
464 return -EINVAL;
465 }
466
467 if (t->speed_hz && t->speed_hz < OMAP1_SPI100K_MAX_FREQ/(1<<16)) {
468 dev_dbg(&spi->dev, "%d Hz max exceeds %d\n",
469 t->speed_hz,
470 OMAP1_SPI100K_MAX_FREQ/(1<<16));
471 return -EINVAL;
472 }
473
474 }
475
476 spin_lock_irqsave(&spi100k->lock, flags);
477 list_add_tail(&m->queue, &spi100k->msg_queue);
478 queue_work(omap1_spi100k_wq, &spi100k->work);
479 spin_unlock_irqrestore(&spi100k->lock, flags);
480
481 return 0;
482}
483
484static int __init omap1_spi100k_reset(struct omap1_spi100k *spi100k)
485{
486 return 0;
487}
488
489static int __devinit omap1_spi100k_probe(struct platform_device *pdev)
490{
491 struct spi_master *master;
492 struct omap1_spi100k *spi100k;
493 int status = 0;
494
495 if (!pdev->id)
496 return -EINVAL;
497
498 master = spi_alloc_master(&pdev->dev, sizeof *spi100k);
499 if (master == NULL) {
500 dev_dbg(&pdev->dev, "master allocation failed\n");
501 return -ENOMEM;
502 }
503
504 if (pdev->id != -1)
505 master->bus_num = pdev->id;
506
507 master->setup = omap1_spi100k_setup;
508 master->transfer = omap1_spi100k_transfer;
509 master->cleanup = NULL;
510 master->num_chipselect = 2;
511 master->mode_bits = MODEBITS;
512
513 dev_set_drvdata(&pdev->dev, master);
514
515 spi100k = spi_master_get_devdata(master);
516 spi100k->master = master;
517
518 /*
519 * The memory region base address is taken as the platform_data.
520 * You should allocate this with ioremap() before initializing
521 * the SPI.
522 */
523 spi100k->base = (void __iomem *) pdev->dev.platform_data;
524
525 INIT_WORK(&spi100k->work, omap1_spi100k_work);
526
527 spin_lock_init(&spi100k->lock);
528 INIT_LIST_HEAD(&spi100k->msg_queue);
529 spi100k->ick = clk_get(&pdev->dev, "ick");
530 if (IS_ERR(spi100k->ick)) {
531 dev_dbg(&pdev->dev, "can't get spi100k_ick\n");
532 status = PTR_ERR(spi100k->ick);
533 goto err1;
534 }
535
536 spi100k->fck = clk_get(&pdev->dev, "fck");
537 if (IS_ERR(spi100k->fck)) {
538 dev_dbg(&pdev->dev, "can't get spi100k_fck\n");
539 status = PTR_ERR(spi100k->fck);
540 goto err2;
541 }
542
543 if (omap1_spi100k_reset(spi100k) < 0)
544 goto err3;
545
546 status = spi_register_master(master);
547 if (status < 0)
548 goto err3;
549
550 spi100k->state = SPI_RUNNING;
551
552 return status;
553
554err3:
555 clk_put(spi100k->fck);
556err2:
557 clk_put(spi100k->ick);
558err1:
559 spi_master_put(master);
560 return status;
561}
562
563static int __exit omap1_spi100k_remove(struct platform_device *pdev)
564{
565 struct spi_master *master;
566 struct omap1_spi100k *spi100k;
567 struct resource *r;
568 unsigned limit = 500;
569 unsigned long flags;
570 int status = 0;
571
572 master = dev_get_drvdata(&pdev->dev);
573 spi100k = spi_master_get_devdata(master);
574
575 spin_lock_irqsave(&spi100k->lock, flags);
576
577 spi100k->state = SPI_SHUTDOWN;
578 while (!list_empty(&spi100k->msg_queue) && limit--) {
579 spin_unlock_irqrestore(&spi100k->lock, flags);
580 msleep(10);
581 spin_lock_irqsave(&spi100k->lock, flags);
582 }
583
584 if (!list_empty(&spi100k->msg_queue))
585 status = -EBUSY;
586
587 spin_unlock_irqrestore(&spi100k->lock, flags);
588
589 if (status != 0)
590 return status;
591
592 clk_put(spi100k->fck);
593 clk_put(spi100k->ick);
594
595 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
596
597 spi_unregister_master(master);
598
599 return 0;
600}
601
602static struct platform_driver omap1_spi100k_driver = {
603 .driver = {
604 .name = "omap1_spi100k",
605 .owner = THIS_MODULE,
606 },
607 .remove = __exit_p(omap1_spi100k_remove),
608};
609
610
611static int __init omap1_spi100k_init(void)
612{
613 omap1_spi100k_wq = create_singlethread_workqueue(
614 omap1_spi100k_driver.driver.name);
615
616 if (omap1_spi100k_wq == NULL)
617 return -1;
618
619 return platform_driver_probe(&omap1_spi100k_driver, omap1_spi100k_probe);
620}
621
622static void __exit omap1_spi100k_exit(void)
623{
624 platform_driver_unregister(&omap1_spi100k_driver);
625
626 destroy_workqueue(omap1_spi100k_wq);
627}
628
629module_init(omap1_spi100k_init);
630module_exit(omap1_spi100k_exit);
631
632MODULE_DESCRIPTION("OMAP7xx SPI 100k controller driver");
633MODULE_AUTHOR("Fabrice Crohas <fcrohas@gmail.com>");
634MODULE_LICENSE("GPL");
635
diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
index 89c22efedfb0..1893f1e96dc4 100644
--- a/drivers/spi/spi_imx.c
+++ b/drivers/spi/spi_imx.c
@@ -44,6 +44,9 @@
44#define MXC_CSPIINT 0x0c 44#define MXC_CSPIINT 0x0c
45#define MXC_RESET 0x1c 45#define MXC_RESET 0x1c
46 46
47#define MX3_CSPISTAT 0x14
48#define MX3_CSPISTAT_RR (1 << 3)
49
47/* generic defines to abstract from the different register layouts */ 50/* generic defines to abstract from the different register layouts */
48#define MXC_INT_RR (1 << 0) /* Receive data ready interrupt */ 51#define MXC_INT_RR (1 << 0) /* Receive data ready interrupt */
49#define MXC_INT_TE (1 << 1) /* Transmit FIFO empty interrupt */ 52#define MXC_INT_TE (1 << 1) /* Transmit FIFO empty interrupt */
@@ -205,7 +208,7 @@ static int mx31_config(struct spi_imx_data *spi_imx,
205 208
206 if (cpu_is_mx31()) 209 if (cpu_is_mx31())
207 reg |= (config->bpw - 1) << MX31_CSPICTRL_BC_SHIFT; 210 reg |= (config->bpw - 1) << MX31_CSPICTRL_BC_SHIFT;
208 else if (cpu_is_mx35()) { 211 else if (cpu_is_mx25() || cpu_is_mx35()) {
209 reg |= (config->bpw - 1) << MX35_CSPICTRL_BL_SHIFT; 212 reg |= (config->bpw - 1) << MX35_CSPICTRL_BL_SHIFT;
210 reg |= MX31_CSPICTRL_SSCTL; 213 reg |= MX31_CSPICTRL_SSCTL;
211 } 214 }
@@ -219,7 +222,7 @@ static int mx31_config(struct spi_imx_data *spi_imx,
219 if (config->cs < 0) { 222 if (config->cs < 0) {
220 if (cpu_is_mx31()) 223 if (cpu_is_mx31())
221 reg |= (config->cs + 32) << MX31_CSPICTRL_CS_SHIFT; 224 reg |= (config->cs + 32) << MX31_CSPICTRL_CS_SHIFT;
222 else if (cpu_is_mx35()) 225 else if (cpu_is_mx25() || cpu_is_mx35())
223 reg |= (config->cs + 32) << MX35_CSPICTRL_CS_SHIFT; 226 reg |= (config->cs + 32) << MX35_CSPICTRL_CS_SHIFT;
224 } 227 }
225 228
@@ -481,7 +484,7 @@ static void spi_imx_cleanup(struct spi_device *spi)
481{ 484{
482} 485}
483 486
484static int __init spi_imx_probe(struct platform_device *pdev) 487static int __devinit spi_imx_probe(struct platform_device *pdev)
485{ 488{
486 struct spi_imx_master *mxc_platform_info; 489 struct spi_imx_master *mxc_platform_info;
487 struct spi_master *master; 490 struct spi_master *master;
@@ -489,7 +492,7 @@ static int __init spi_imx_probe(struct platform_device *pdev)
489 struct resource *res; 492 struct resource *res;
490 int i, ret; 493 int i, ret;
491 494
492 mxc_platform_info = (struct spi_imx_master *)pdev->dev.platform_data; 495 mxc_platform_info = dev_get_platdata(&pdev->dev);
493 if (!mxc_platform_info) { 496 if (!mxc_platform_info) {
494 dev_err(&pdev->dev, "can't get the platform data\n"); 497 dev_err(&pdev->dev, "can't get the platform data\n");
495 return -EINVAL; 498 return -EINVAL;
@@ -513,11 +516,12 @@ static int __init spi_imx_probe(struct platform_device *pdev)
513 continue; 516 continue;
514 ret = gpio_request(spi_imx->chipselect[i], DRIVER_NAME); 517 ret = gpio_request(spi_imx->chipselect[i], DRIVER_NAME);
515 if (ret) { 518 if (ret) {
516 i--; 519 while (i > 0) {
517 while (i > 0) 520 i--;
518 if (spi_imx->chipselect[i] >= 0) 521 if (spi_imx->chipselect[i] >= 0)
519 gpio_free(spi_imx->chipselect[i--]); 522 gpio_free(spi_imx->chipselect[i]);
520 dev_err(&pdev->dev, "can't get cs gpios"); 523 }
524 dev_err(&pdev->dev, "can't get cs gpios\n");
521 goto out_master_put; 525 goto out_master_put;
522 } 526 }
523 } 527 }
@@ -551,7 +555,7 @@ static int __init spi_imx_probe(struct platform_device *pdev)
551 } 555 }
552 556
553 spi_imx->irq = platform_get_irq(pdev, 0); 557 spi_imx->irq = platform_get_irq(pdev, 0);
554 if (!spi_imx->irq) { 558 if (spi_imx->irq <= 0) {
555 ret = -EINVAL; 559 ret = -EINVAL;
556 goto out_iounmap; 560 goto out_iounmap;
557 } 561 }
@@ -562,7 +566,7 @@ static int __init spi_imx_probe(struct platform_device *pdev)
562 goto out_iounmap; 566 goto out_iounmap;
563 } 567 }
564 568
565 if (cpu_is_mx31() || cpu_is_mx35()) { 569 if (cpu_is_mx25() || cpu_is_mx31() || cpu_is_mx35()) {
566 spi_imx->intctrl = mx31_intctrl; 570 spi_imx->intctrl = mx31_intctrl;
567 spi_imx->config = mx31_config; 571 spi_imx->config = mx31_config;
568 spi_imx->trigger = mx31_trigger; 572 spi_imx->trigger = mx31_trigger;
@@ -590,9 +594,14 @@ static int __init spi_imx_probe(struct platform_device *pdev)
590 clk_enable(spi_imx->clk); 594 clk_enable(spi_imx->clk);
591 spi_imx->spi_clk = clk_get_rate(spi_imx->clk); 595 spi_imx->spi_clk = clk_get_rate(spi_imx->clk);
592 596
593 if (!cpu_is_mx31() || !cpu_is_mx35()) 597 if (cpu_is_mx1() || cpu_is_mx21() || cpu_is_mx27())
594 writel(1, spi_imx->base + MXC_RESET); 598 writel(1, spi_imx->base + MXC_RESET);
595 599
600 /* drain receive buffer */
601 if (cpu_is_mx25() || cpu_is_mx31() || cpu_is_mx35())
602 while (readl(spi_imx->base + MX3_CSPISTAT) & MX3_CSPISTAT_RR)
603 readl(spi_imx->base + MXC_CSPIRXDATA);
604
596 spi_imx->intctrl(spi_imx, 0); 605 spi_imx->intctrl(spi_imx, 0);
597 606
598 ret = spi_bitbang_start(&spi_imx->bitbang); 607 ret = spi_bitbang_start(&spi_imx->bitbang);
@@ -625,7 +634,7 @@ out_master_put:
625 return ret; 634 return ret;
626} 635}
627 636
628static int __exit spi_imx_remove(struct platform_device *pdev) 637static int __devexit spi_imx_remove(struct platform_device *pdev)
629{ 638{
630 struct spi_master *master = platform_get_drvdata(pdev); 639 struct spi_master *master = platform_get_drvdata(pdev);
631 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 640 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -659,7 +668,7 @@ static struct platform_driver spi_imx_driver = {
659 .owner = THIS_MODULE, 668 .owner = THIS_MODULE,
660 }, 669 },
661 .probe = spi_imx_probe, 670 .probe = spi_imx_probe,
662 .remove = __exit_p(spi_imx_remove), 671 .remove = __devexit_p(spi_imx_remove),
663}; 672};
664 673
665static int __init spi_imx_init(void) 674static int __init spi_imx_init(void)
diff --git a/drivers/spi/spi_mpc8xxx.c b/drivers/spi/spi_mpc8xxx.c
index 930135dc73ba..e9390d747bfc 100644
--- a/drivers/spi/spi_mpc8xxx.c
+++ b/drivers/spi/spi_mpc8xxx.c
@@ -1356,7 +1356,7 @@ static int __devexit plat_mpc8xxx_spi_remove(struct platform_device *pdev)
1356MODULE_ALIAS("platform:mpc8xxx_spi"); 1356MODULE_ALIAS("platform:mpc8xxx_spi");
1357static struct platform_driver mpc8xxx_spi_driver = { 1357static struct platform_driver mpc8xxx_spi_driver = {
1358 .probe = plat_mpc8xxx_spi_probe, 1358 .probe = plat_mpc8xxx_spi_probe,
1359 .remove = __exit_p(plat_mpc8xxx_spi_remove), 1359 .remove = __devexit_p(plat_mpc8xxx_spi_remove),
1360 .driver = { 1360 .driver = {
1361 .name = "mpc8xxx_spi", 1361 .name = "mpc8xxx_spi",
1362 .owner = THIS_MODULE, 1362 .owner = THIS_MODULE,
diff --git a/drivers/spi/spi_nuc900.c b/drivers/spi/spi_nuc900.c
new file mode 100644
index 000000000000..b319f9bf9b9b
--- /dev/null
+++ b/drivers/spi/spi_nuc900.c
@@ -0,0 +1,504 @@
1/* linux/drivers/spi/spi_nuc900.c
2 *
3 * Copyright (c) 2009 Nuvoton technology.
4 * Wan ZongShun <mcuos.com@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10*/
11
12#include <linux/init.h>
13#include <linux/spinlock.h>
14#include <linux/workqueue.h>
15#include <linux/interrupt.h>
16#include <linux/delay.h>
17#include <linux/errno.h>
18#include <linux/err.h>
19#include <linux/clk.h>
20#include <linux/device.h>
21#include <linux/platform_device.h>
22#include <linux/gpio.h>
23#include <linux/io.h>
24
25#include <linux/spi/spi.h>
26#include <linux/spi/spi_bitbang.h>
27
28#include <mach/nuc900_spi.h>
29
30/* usi registers offset */
31#define USI_CNT 0x00
32#define USI_DIV 0x04
33#define USI_SSR 0x08
34#define USI_RX0 0x10
35#define USI_TX0 0x10
36
37/* usi register bit */
38#define ENINT (0x01 << 17)
39#define ENFLG (0x01 << 16)
40#define TXNUM (0x03 << 8)
41#define TXNEG (0x01 << 2)
42#define RXNEG (0x01 << 1)
43#define LSB (0x01 << 10)
44#define SELECTLEV (0x01 << 2)
45#define SELECTPOL (0x01 << 31)
46#define SELECTSLAVE 0x01
47#define GOBUSY 0x01
48
49struct nuc900_spi {
50 struct spi_bitbang bitbang;
51 struct completion done;
52 void __iomem *regs;
53 int irq;
54 int len;
55 int count;
56 const unsigned char *tx;
57 unsigned char *rx;
58 struct clk *clk;
59 struct resource *ioarea;
60 struct spi_master *master;
61 struct spi_device *curdev;
62 struct device *dev;
63 struct nuc900_spi_info *pdata;
64 spinlock_t lock;
65 struct resource *res;
66};
67
68static inline struct nuc900_spi *to_hw(struct spi_device *sdev)
69{
70 return spi_master_get_devdata(sdev->master);
71}
72
73static void nuc900_slave_select(struct spi_device *spi, unsigned int ssr)
74{
75 struct nuc900_spi *hw = to_hw(spi);
76 unsigned int val;
77 unsigned int cs = spi->mode & SPI_CS_HIGH ? 1 : 0;
78 unsigned int cpol = spi->mode & SPI_CPOL ? 1 : 0;
79 unsigned long flags;
80
81 spin_lock_irqsave(&hw->lock, flags);
82
83 val = __raw_readl(hw->regs + USI_SSR);
84
85 if (!cs)
86 val &= ~SELECTLEV;
87 else
88 val |= SELECTLEV;
89
90 if (!ssr)
91 val &= ~SELECTSLAVE;
92 else
93 val |= SELECTSLAVE;
94
95 __raw_writel(val, hw->regs + USI_SSR);
96
97 val = __raw_readl(hw->regs + USI_CNT);
98
99 if (!cpol)
100 val &= ~SELECTPOL;
101 else
102 val |= SELECTPOL;
103
104 __raw_writel(val, hw->regs + USI_CNT);
105
106 spin_unlock_irqrestore(&hw->lock, flags);
107}
108
109static void nuc900_spi_chipsel(struct spi_device *spi, int value)
110{
111 switch (value) {
112 case BITBANG_CS_INACTIVE:
113 nuc900_slave_select(spi, 0);
114 break;
115
116 case BITBANG_CS_ACTIVE:
117 nuc900_slave_select(spi, 1);
118 break;
119 }
120}
121
122static void nuc900_spi_setup_txnum(struct nuc900_spi *hw,
123 unsigned int txnum)
124{
125 unsigned int val;
126 unsigned long flags;
127
128 spin_lock_irqsave(&hw->lock, flags);
129
130 val = __raw_readl(hw->regs + USI_CNT);
131
132 if (!txnum)
133 val &= ~TXNUM;
134 else
135 val |= txnum << 0x08;
136
137 __raw_writel(val, hw->regs + USI_CNT);
138
139 spin_unlock_irqrestore(&hw->lock, flags);
140
141}
142
143static void nuc900_spi_setup_txbitlen(struct nuc900_spi *hw,
144 unsigned int txbitlen)
145{
146 unsigned int val;
147 unsigned long flags;
148
149 spin_lock_irqsave(&hw->lock, flags);
150
151 val = __raw_readl(hw->regs + USI_CNT);
152
153 val |= (txbitlen << 0x03);
154
155 __raw_writel(val, hw->regs + USI_CNT);
156
157 spin_unlock_irqrestore(&hw->lock, flags);
158}
159
160static void nuc900_spi_gobusy(struct nuc900_spi *hw)
161{
162 unsigned int val;
163 unsigned long flags;
164
165 spin_lock_irqsave(&hw->lock, flags);
166
167 val = __raw_readl(hw->regs + USI_CNT);
168
169 val |= GOBUSY;
170
171 __raw_writel(val, hw->regs + USI_CNT);
172
173 spin_unlock_irqrestore(&hw->lock, flags);
174}
175
176static int nuc900_spi_setupxfer(struct spi_device *spi,
177 struct spi_transfer *t)
178{
179 return 0;
180}
181
182static int nuc900_spi_setup(struct spi_device *spi)
183{
184 return 0;
185}
186
187static inline unsigned int hw_txbyte(struct nuc900_spi *hw, int count)
188{
189 return hw->tx ? hw->tx[count] : 0;
190}
191
192static int nuc900_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
193{
194 struct nuc900_spi *hw = to_hw(spi);
195
196 hw->tx = t->tx_buf;
197 hw->rx = t->rx_buf;
198 hw->len = t->len;
199 hw->count = 0;
200
201 __raw_writel(hw_txbyte(hw, 0x0), hw->regs + USI_TX0);
202
203 nuc900_spi_gobusy(hw);
204
205 wait_for_completion(&hw->done);
206
207 return hw->count;
208}
209
210static irqreturn_t nuc900_spi_irq(int irq, void *dev)
211{
212 struct nuc900_spi *hw = dev;
213 unsigned int status;
214 unsigned int count = hw->count;
215
216 status = __raw_readl(hw->regs + USI_CNT);
217 __raw_writel(status, hw->regs + USI_CNT);
218
219 if (status & ENFLG) {
220 hw->count++;
221
222 if (hw->rx)
223 hw->rx[count] = __raw_readl(hw->regs + USI_RX0);
224 count++;
225
226 if (count < hw->len) {
227 __raw_writel(hw_txbyte(hw, count), hw->regs + USI_TX0);
228 nuc900_spi_gobusy(hw);
229 } else {
230 complete(&hw->done);
231 }
232
233 return IRQ_HANDLED;
234 }
235
236 complete(&hw->done);
237 return IRQ_HANDLED;
238}
239
240static void nuc900_tx_edge(struct nuc900_spi *hw, unsigned int edge)
241{
242 unsigned int val;
243 unsigned long flags;
244
245 spin_lock_irqsave(&hw->lock, flags);
246
247 val = __raw_readl(hw->regs + USI_CNT);
248
249 if (edge)
250 val |= TXNEG;
251 else
252 val &= ~TXNEG;
253 __raw_writel(val, hw->regs + USI_CNT);
254
255 spin_unlock_irqrestore(&hw->lock, flags);
256}
257
258static void nuc900_rx_edge(struct nuc900_spi *hw, unsigned int edge)
259{
260 unsigned int val;
261 unsigned long flags;
262
263 spin_lock_irqsave(&hw->lock, flags);
264
265 val = __raw_readl(hw->regs + USI_CNT);
266
267 if (edge)
268 val |= RXNEG;
269 else
270 val &= ~RXNEG;
271 __raw_writel(val, hw->regs + USI_CNT);
272
273 spin_unlock_irqrestore(&hw->lock, flags);
274}
275
276static void nuc900_send_first(struct nuc900_spi *hw, unsigned int lsb)
277{
278 unsigned int val;
279 unsigned long flags;
280
281 spin_lock_irqsave(&hw->lock, flags);
282
283 val = __raw_readl(hw->regs + USI_CNT);
284
285 if (lsb)
286 val |= LSB;
287 else
288 val &= ~LSB;
289 __raw_writel(val, hw->regs + USI_CNT);
290
291 spin_unlock_irqrestore(&hw->lock, flags);
292}
293
294static void nuc900_set_sleep(struct nuc900_spi *hw, unsigned int sleep)
295{
296 unsigned int val;
297 unsigned long flags;
298
299 spin_lock_irqsave(&hw->lock, flags);
300
301 val = __raw_readl(hw->regs + USI_CNT);
302
303 if (sleep)
304 val |= (sleep << 12);
305 else
306 val &= ~(0x0f << 12);
307 __raw_writel(val, hw->regs + USI_CNT);
308
309 spin_unlock_irqrestore(&hw->lock, flags);
310}
311
312static void nuc900_enable_int(struct nuc900_spi *hw)
313{
314 unsigned int val;
315 unsigned long flags;
316
317 spin_lock_irqsave(&hw->lock, flags);
318
319 val = __raw_readl(hw->regs + USI_CNT);
320
321 val |= ENINT;
322
323 __raw_writel(val, hw->regs + USI_CNT);
324
325 spin_unlock_irqrestore(&hw->lock, flags);
326}
327
328static void nuc900_set_divider(struct nuc900_spi *hw)
329{
330 __raw_writel(hw->pdata->divider, hw->regs + USI_DIV);
331}
332
333static void nuc900_init_spi(struct nuc900_spi *hw)
334{
335 clk_enable(hw->clk);
336 spin_lock_init(&hw->lock);
337
338 nuc900_tx_edge(hw, hw->pdata->txneg);
339 nuc900_rx_edge(hw, hw->pdata->rxneg);
340 nuc900_send_first(hw, hw->pdata->lsb);
341 nuc900_set_sleep(hw, hw->pdata->sleep);
342 nuc900_spi_setup_txbitlen(hw, hw->pdata->txbitlen);
343 nuc900_spi_setup_txnum(hw, hw->pdata->txnum);
344 nuc900_set_divider(hw);
345 nuc900_enable_int(hw);
346}
347
348static int __devinit nuc900_spi_probe(struct platform_device *pdev)
349{
350 struct nuc900_spi *hw;
351 struct spi_master *master;
352 int err = 0;
353
354 master = spi_alloc_master(&pdev->dev, sizeof(struct nuc900_spi));
355 if (master == NULL) {
356 dev_err(&pdev->dev, "No memory for spi_master\n");
357 err = -ENOMEM;
358 goto err_nomem;
359 }
360
361 hw = spi_master_get_devdata(master);
362 memset(hw, 0, sizeof(struct nuc900_spi));
363
364 hw->master = spi_master_get(master);
365 hw->pdata = pdev->dev.platform_data;
366 hw->dev = &pdev->dev;
367
368 if (hw->pdata == NULL) {
369 dev_err(&pdev->dev, "No platform data supplied\n");
370 err = -ENOENT;
371 goto err_pdata;
372 }
373
374 platform_set_drvdata(pdev, hw);
375 init_completion(&hw->done);
376
377 master->mode_bits = SPI_MODE_0;
378 master->num_chipselect = hw->pdata->num_cs;
379 master->bus_num = hw->pdata->bus_num;
380 hw->bitbang.master = hw->master;
381 hw->bitbang.setup_transfer = nuc900_spi_setupxfer;
382 hw->bitbang.chipselect = nuc900_spi_chipsel;
383 hw->bitbang.txrx_bufs = nuc900_spi_txrx;
384 hw->bitbang.master->setup = nuc900_spi_setup;
385
386 hw->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
387 if (hw->res == NULL) {
388 dev_err(&pdev->dev, "Cannot get IORESOURCE_MEM\n");
389 err = -ENOENT;
390 goto err_pdata;
391 }
392
393 hw->ioarea = request_mem_region(hw->res->start,
394 resource_size(hw->res), pdev->name);
395
396 if (hw->ioarea == NULL) {
397 dev_err(&pdev->dev, "Cannot reserve region\n");
398 err = -ENXIO;
399 goto err_pdata;
400 }
401
402 hw->regs = ioremap(hw->res->start, resource_size(hw->res));
403 if (hw->regs == NULL) {
404 dev_err(&pdev->dev, "Cannot map IO\n");
405 err = -ENXIO;
406 goto err_iomap;
407 }
408
409 hw->irq = platform_get_irq(pdev, 0);
410 if (hw->irq < 0) {
411 dev_err(&pdev->dev, "No IRQ specified\n");
412 err = -ENOENT;
413 goto err_irq;
414 }
415
416 err = request_irq(hw->irq, nuc900_spi_irq, 0, pdev->name, hw);
417 if (err) {
418 dev_err(&pdev->dev, "Cannot claim IRQ\n");
419 goto err_irq;
420 }
421
422 hw->clk = clk_get(&pdev->dev, "spi");
423 if (IS_ERR(hw->clk)) {
424 dev_err(&pdev->dev, "No clock for device\n");
425 err = PTR_ERR(hw->clk);
426 goto err_clk;
427 }
428
429 mfp_set_groupg(&pdev->dev);
430 nuc900_init_spi(hw);
431
432 err = spi_bitbang_start(&hw->bitbang);
433 if (err) {
434 dev_err(&pdev->dev, "Failed to register SPI master\n");
435 goto err_register;
436 }
437
438 return 0;
439
440err_register:
441 clk_disable(hw->clk);
442 clk_put(hw->clk);
443err_clk:
444 free_irq(hw->irq, hw);
445err_irq:
446 iounmap(hw->regs);
447err_iomap:
448 release_mem_region(hw->res->start, resource_size(hw->res));
449 kfree(hw->ioarea);
450err_pdata:
451 spi_master_put(hw->master);;
452
453err_nomem:
454 return err;
455}
456
457static int __devexit nuc900_spi_remove(struct platform_device *dev)
458{
459 struct nuc900_spi *hw = platform_get_drvdata(dev);
460
461 free_irq(hw->irq, hw);
462
463 platform_set_drvdata(dev, NULL);
464
465 spi_unregister_master(hw->master);
466
467 clk_disable(hw->clk);
468 clk_put(hw->clk);
469
470 iounmap(hw->regs);
471
472 release_mem_region(hw->res->start, resource_size(hw->res));
473 kfree(hw->ioarea);
474
475 spi_master_put(hw->master);
476 return 0;
477}
478
479static struct platform_driver nuc900_spi_driver = {
480 .probe = nuc900_spi_probe,
481 .remove = __devexit_p(nuc900_spi_remove),
482 .driver = {
483 .name = "nuc900-spi",
484 .owner = THIS_MODULE,
485 },
486};
487
488static int __init nuc900_spi_init(void)
489{
490 return platform_driver_register(&nuc900_spi_driver);
491}
492
493static void __exit nuc900_spi_exit(void)
494{
495 platform_driver_unregister(&nuc900_spi_driver);
496}
497
498module_init(nuc900_spi_init);
499module_exit(nuc900_spi_exit);
500
501MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>");
502MODULE_DESCRIPTION("nuc900 spi driver!");
503MODULE_LICENSE("GPL");
504MODULE_ALIAS("platform:nuc900-spi");
diff --git a/drivers/spi/spi_sh_msiof.c b/drivers/spi/spi_sh_msiof.c
new file mode 100644
index 000000000000..51e5e1dfa6e5
--- /dev/null
+++ b/drivers/spi/spi_sh_msiof.c
@@ -0,0 +1,691 @@
1/*
2 * SuperH MSIOF SPI Master Interface
3 *
4 * Copyright (c) 2009 Magnus Damm
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/delay.h>
15#include <linux/interrupt.h>
16#include <linux/platform_device.h>
17#include <linux/completion.h>
18#include <linux/pm_runtime.h>
19#include <linux/gpio.h>
20#include <linux/bitmap.h>
21#include <linux/clk.h>
22#include <linux/io.h>
23
24#include <linux/spi/spi.h>
25#include <linux/spi/spi_bitbang.h>
26#include <linux/spi/sh_msiof.h>
27
28#include <asm/spi.h>
29#include <asm/unaligned.h>
30
31struct sh_msiof_spi_priv {
32 struct spi_bitbang bitbang; /* must be first for spi_bitbang.c */
33 void __iomem *mapbase;
34 struct clk *clk;
35 struct platform_device *pdev;
36 struct sh_msiof_spi_info *info;
37 struct completion done;
38 unsigned long flags;
39 int tx_fifo_size;
40 int rx_fifo_size;
41};
42
43#define TMDR1 0x00
44#define TMDR2 0x04
45#define TMDR3 0x08
46#define RMDR1 0x10
47#define RMDR2 0x14
48#define RMDR3 0x18
49#define TSCR 0x20
50#define RSCR 0x22
51#define CTR 0x28
52#define FCTR 0x30
53#define STR 0x40
54#define IER 0x44
55#define TDR1 0x48
56#define TDR2 0x4c
57#define TFDR 0x50
58#define RDR1 0x58
59#define RDR2 0x5c
60#define RFDR 0x60
61
62#define CTR_TSCKE (1 << 15)
63#define CTR_TFSE (1 << 14)
64#define CTR_TXE (1 << 9)
65#define CTR_RXE (1 << 8)
66
67#define STR_TEOF (1 << 23)
68#define STR_REOF (1 << 7)
69
70static unsigned long sh_msiof_read(struct sh_msiof_spi_priv *p, int reg_offs)
71{
72 switch (reg_offs) {
73 case TSCR:
74 case RSCR:
75 return ioread16(p->mapbase + reg_offs);
76 default:
77 return ioread32(p->mapbase + reg_offs);
78 }
79}
80
81static void sh_msiof_write(struct sh_msiof_spi_priv *p, int reg_offs,
82 unsigned long value)
83{
84 switch (reg_offs) {
85 case TSCR:
86 case RSCR:
87 iowrite16(value, p->mapbase + reg_offs);
88 break;
89 default:
90 iowrite32(value, p->mapbase + reg_offs);
91 break;
92 }
93}
94
95static int sh_msiof_modify_ctr_wait(struct sh_msiof_spi_priv *p,
96 unsigned long clr, unsigned long set)
97{
98 unsigned long mask = clr | set;
99 unsigned long data;
100 int k;
101
102 data = sh_msiof_read(p, CTR);
103 data &= ~clr;
104 data |= set;
105 sh_msiof_write(p, CTR, data);
106
107 for (k = 100; k > 0; k--) {
108 if ((sh_msiof_read(p, CTR) & mask) == set)
109 break;
110
111 udelay(10);
112 }
113
114 return k > 0 ? 0 : -ETIMEDOUT;
115}
116
117static irqreturn_t sh_msiof_spi_irq(int irq, void *data)
118{
119 struct sh_msiof_spi_priv *p = data;
120
121 /* just disable the interrupt and wake up */
122 sh_msiof_write(p, IER, 0);
123 complete(&p->done);
124
125 return IRQ_HANDLED;
126}
127
128static struct {
129 unsigned short div;
130 unsigned short scr;
131} const sh_msiof_spi_clk_table[] = {
132 { 1, 0x0007 },
133 { 2, 0x0000 },
134 { 4, 0x0001 },
135 { 8, 0x0002 },
136 { 16, 0x0003 },
137 { 32, 0x0004 },
138 { 64, 0x1f00 },
139 { 128, 0x1f01 },
140 { 256, 0x1f02 },
141 { 512, 0x1f03 },
142 { 1024, 0x1f04 },
143};
144
145static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p,
146 unsigned long parent_rate,
147 unsigned long spi_hz)
148{
149 unsigned long div = 1024;
150 size_t k;
151
152 if (!WARN_ON(!spi_hz || !parent_rate))
153 div = parent_rate / spi_hz;
154
155 /* TODO: make more fine grained */
156
157 for (k = 0; k < ARRAY_SIZE(sh_msiof_spi_clk_table); k++) {
158 if (sh_msiof_spi_clk_table[k].div >= div)
159 break;
160 }
161
162 k = min_t(int, k, ARRAY_SIZE(sh_msiof_spi_clk_table) - 1);
163
164 sh_msiof_write(p, TSCR, sh_msiof_spi_clk_table[k].scr);
165 sh_msiof_write(p, RSCR, sh_msiof_spi_clk_table[k].scr);
166}
167
168static void sh_msiof_spi_set_pin_regs(struct sh_msiof_spi_priv *p,
169 int cpol, int cpha,
170 int tx_hi_z, int lsb_first)
171{
172 unsigned long tmp;
173 int edge;
174
175 /*
176 * CPOL CPHA TSCKIZ RSCKIZ TEDG REDG(!)
177 * 0 0 10 10 1 0
178 * 0 1 10 10 0 1
179 * 1 0 11 11 0 1
180 * 1 1 11 11 1 0
181 *
182 * (!) Note: REDG is inverted recommended data sheet setting
183 */
184
185 sh_msiof_write(p, FCTR, 0);
186 sh_msiof_write(p, TMDR1, 0xe2000005 | (lsb_first << 24));
187 sh_msiof_write(p, RMDR1, 0x22000005 | (lsb_first << 24));
188
189 tmp = 0xa0000000;
190 tmp |= cpol << 30; /* TSCKIZ */
191 tmp |= cpol << 28; /* RSCKIZ */
192
193 edge = cpol ? cpha : !cpha;
194
195 tmp |= edge << 27; /* TEDG */
196 tmp |= !edge << 26; /* REDG */
197 tmp |= (tx_hi_z ? 2 : 0) << 22; /* TXDIZ */
198 sh_msiof_write(p, CTR, tmp);
199}
200
201static void sh_msiof_spi_set_mode_regs(struct sh_msiof_spi_priv *p,
202 const void *tx_buf, void *rx_buf,
203 int bits, int words)
204{
205 unsigned long dr2;
206
207 dr2 = ((bits - 1) << 24) | ((words - 1) << 16);
208
209 if (tx_buf)
210 sh_msiof_write(p, TMDR2, dr2);
211 else
212 sh_msiof_write(p, TMDR2, dr2 | 1);
213
214 if (rx_buf)
215 sh_msiof_write(p, RMDR2, dr2);
216
217 sh_msiof_write(p, IER, STR_TEOF | STR_REOF);
218}
219
220static void sh_msiof_reset_str(struct sh_msiof_spi_priv *p)
221{
222 sh_msiof_write(p, STR, sh_msiof_read(p, STR));
223}
224
225static void sh_msiof_spi_write_fifo_8(struct sh_msiof_spi_priv *p,
226 const void *tx_buf, int words, int fs)
227{
228 const unsigned char *buf_8 = tx_buf;
229 int k;
230
231 for (k = 0; k < words; k++)
232 sh_msiof_write(p, TFDR, buf_8[k] << fs);
233}
234
235static void sh_msiof_spi_write_fifo_16(struct sh_msiof_spi_priv *p,
236 const void *tx_buf, int words, int fs)
237{
238 const unsigned short *buf_16 = tx_buf;
239 int k;
240
241 for (k = 0; k < words; k++)
242 sh_msiof_write(p, TFDR, buf_16[k] << fs);
243}
244
245static void sh_msiof_spi_write_fifo_16u(struct sh_msiof_spi_priv *p,
246 const void *tx_buf, int words, int fs)
247{
248 const unsigned short *buf_16 = tx_buf;
249 int k;
250
251 for (k = 0; k < words; k++)
252 sh_msiof_write(p, TFDR, get_unaligned(&buf_16[k]) << fs);
253}
254
255static void sh_msiof_spi_write_fifo_32(struct sh_msiof_spi_priv *p,
256 const void *tx_buf, int words, int fs)
257{
258 const unsigned int *buf_32 = tx_buf;
259 int k;
260
261 for (k = 0; k < words; k++)
262 sh_msiof_write(p, TFDR, buf_32[k] << fs);
263}
264
265static void sh_msiof_spi_write_fifo_32u(struct sh_msiof_spi_priv *p,
266 const void *tx_buf, int words, int fs)
267{
268 const unsigned int *buf_32 = tx_buf;
269 int k;
270
271 for (k = 0; k < words; k++)
272 sh_msiof_write(p, TFDR, get_unaligned(&buf_32[k]) << fs);
273}
274
275static void sh_msiof_spi_read_fifo_8(struct sh_msiof_spi_priv *p,
276 void *rx_buf, int words, int fs)
277{
278 unsigned char *buf_8 = rx_buf;
279 int k;
280
281 for (k = 0; k < words; k++)
282 buf_8[k] = sh_msiof_read(p, RFDR) >> fs;
283}
284
285static void sh_msiof_spi_read_fifo_16(struct sh_msiof_spi_priv *p,
286 void *rx_buf, int words, int fs)
287{
288 unsigned short *buf_16 = rx_buf;
289 int k;
290
291 for (k = 0; k < words; k++)
292 buf_16[k] = sh_msiof_read(p, RFDR) >> fs;
293}
294
295static void sh_msiof_spi_read_fifo_16u(struct sh_msiof_spi_priv *p,
296 void *rx_buf, int words, int fs)
297{
298 unsigned short *buf_16 = rx_buf;
299 int k;
300
301 for (k = 0; k < words; k++)
302 put_unaligned(sh_msiof_read(p, RFDR) >> fs, &buf_16[k]);
303}
304
305static void sh_msiof_spi_read_fifo_32(struct sh_msiof_spi_priv *p,
306 void *rx_buf, int words, int fs)
307{
308 unsigned int *buf_32 = rx_buf;
309 int k;
310
311 for (k = 0; k < words; k++)
312 buf_32[k] = sh_msiof_read(p, RFDR) >> fs;
313}
314
315static void sh_msiof_spi_read_fifo_32u(struct sh_msiof_spi_priv *p,
316 void *rx_buf, int words, int fs)
317{
318 unsigned int *buf_32 = rx_buf;
319 int k;
320
321 for (k = 0; k < words; k++)
322 put_unaligned(sh_msiof_read(p, RFDR) >> fs, &buf_32[k]);
323}
324
325static int sh_msiof_spi_bits(struct spi_device *spi, struct spi_transfer *t)
326{
327 int bits;
328
329 bits = t ? t->bits_per_word : 0;
330 bits = bits ? bits : spi->bits_per_word;
331 return bits;
332}
333
334static unsigned long sh_msiof_spi_hz(struct spi_device *spi,
335 struct spi_transfer *t)
336{
337 unsigned long hz;
338
339 hz = t ? t->speed_hz : 0;
340 hz = hz ? hz : spi->max_speed_hz;
341 return hz;
342}
343
344static int sh_msiof_spi_setup_transfer(struct spi_device *spi,
345 struct spi_transfer *t)
346{
347 int bits;
348
349 /* noting to check hz values against since parent clock is disabled */
350
351 bits = sh_msiof_spi_bits(spi, t);
352 if (bits < 8)
353 return -EINVAL;
354 if (bits > 32)
355 return -EINVAL;
356
357 return spi_bitbang_setup_transfer(spi, t);
358}
359
360static void sh_msiof_spi_chipselect(struct spi_device *spi, int is_on)
361{
362 struct sh_msiof_spi_priv *p = spi_master_get_devdata(spi->master);
363 int value;
364
365 /* chip select is active low unless SPI_CS_HIGH is set */
366 if (spi->mode & SPI_CS_HIGH)
367 value = (is_on == BITBANG_CS_ACTIVE) ? 1 : 0;
368 else
369 value = (is_on == BITBANG_CS_ACTIVE) ? 0 : 1;
370
371 if (is_on == BITBANG_CS_ACTIVE) {
372 if (!test_and_set_bit(0, &p->flags)) {
373 pm_runtime_get_sync(&p->pdev->dev);
374 clk_enable(p->clk);
375 }
376
377 /* Configure pins before asserting CS */
378 sh_msiof_spi_set_pin_regs(p, !!(spi->mode & SPI_CPOL),
379 !!(spi->mode & SPI_CPHA),
380 !!(spi->mode & SPI_3WIRE),
381 !!(spi->mode & SPI_LSB_FIRST));
382 }
383
384 /* use spi->controller data for CS (same strategy as spi_gpio) */
385 gpio_set_value((unsigned)spi->controller_data, value);
386
387 if (is_on == BITBANG_CS_INACTIVE) {
388 if (test_and_clear_bit(0, &p->flags)) {
389 clk_disable(p->clk);
390 pm_runtime_put(&p->pdev->dev);
391 }
392 }
393}
394
395static int sh_msiof_spi_txrx_once(struct sh_msiof_spi_priv *p,
396 void (*tx_fifo)(struct sh_msiof_spi_priv *,
397 const void *, int, int),
398 void (*rx_fifo)(struct sh_msiof_spi_priv *,
399 void *, int, int),
400 const void *tx_buf, void *rx_buf,
401 int words, int bits)
402{
403 int fifo_shift;
404 int ret;
405
406 /* limit maximum word transfer to rx/tx fifo size */
407 if (tx_buf)
408 words = min_t(int, words, p->tx_fifo_size);
409 if (rx_buf)
410 words = min_t(int, words, p->rx_fifo_size);
411
412 /* the fifo contents need shifting */
413 fifo_shift = 32 - bits;
414
415 /* setup msiof transfer mode registers */
416 sh_msiof_spi_set_mode_regs(p, tx_buf, rx_buf, bits, words);
417
418 /* write tx fifo */
419 if (tx_buf)
420 tx_fifo(p, tx_buf, words, fifo_shift);
421
422 /* setup clock and rx/tx signals */
423 ret = sh_msiof_modify_ctr_wait(p, 0, CTR_TSCKE);
424 if (rx_buf)
425 ret = ret ? ret : sh_msiof_modify_ctr_wait(p, 0, CTR_RXE);
426 ret = ret ? ret : sh_msiof_modify_ctr_wait(p, 0, CTR_TXE);
427
428 /* start by setting frame bit */
429 INIT_COMPLETION(p->done);
430 ret = ret ? ret : sh_msiof_modify_ctr_wait(p, 0, CTR_TFSE);
431 if (ret) {
432 dev_err(&p->pdev->dev, "failed to start hardware\n");
433 goto err;
434 }
435
436 /* wait for tx fifo to be emptied / rx fifo to be filled */
437 wait_for_completion(&p->done);
438
439 /* read rx fifo */
440 if (rx_buf)
441 rx_fifo(p, rx_buf, words, fifo_shift);
442
443 /* clear status bits */
444 sh_msiof_reset_str(p);
445
446 /* shut down frame, tx/tx and clock signals */
447 ret = sh_msiof_modify_ctr_wait(p, CTR_TFSE, 0);
448 ret = ret ? ret : sh_msiof_modify_ctr_wait(p, CTR_TXE, 0);
449 if (rx_buf)
450 ret = ret ? ret : sh_msiof_modify_ctr_wait(p, CTR_RXE, 0);
451 ret = ret ? ret : sh_msiof_modify_ctr_wait(p, CTR_TSCKE, 0);
452 if (ret) {
453 dev_err(&p->pdev->dev, "failed to shut down hardware\n");
454 goto err;
455 }
456
457 return words;
458
459 err:
460 sh_msiof_write(p, IER, 0);
461 return ret;
462}
463
464static int sh_msiof_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
465{
466 struct sh_msiof_spi_priv *p = spi_master_get_devdata(spi->master);
467 void (*tx_fifo)(struct sh_msiof_spi_priv *, const void *, int, int);
468 void (*rx_fifo)(struct sh_msiof_spi_priv *, void *, int, int);
469 int bits;
470 int bytes_per_word;
471 int bytes_done;
472 int words;
473 int n;
474
475 bits = sh_msiof_spi_bits(spi, t);
476
477 /* setup bytes per word and fifo read/write functions */
478 if (bits <= 8) {
479 bytes_per_word = 1;
480 tx_fifo = sh_msiof_spi_write_fifo_8;
481 rx_fifo = sh_msiof_spi_read_fifo_8;
482 } else if (bits <= 16) {
483 bytes_per_word = 2;
484 if ((unsigned long)t->tx_buf & 0x01)
485 tx_fifo = sh_msiof_spi_write_fifo_16u;
486 else
487 tx_fifo = sh_msiof_spi_write_fifo_16;
488
489 if ((unsigned long)t->rx_buf & 0x01)
490 rx_fifo = sh_msiof_spi_read_fifo_16u;
491 else
492 rx_fifo = sh_msiof_spi_read_fifo_16;
493 } else {
494 bytes_per_word = 4;
495 if ((unsigned long)t->tx_buf & 0x03)
496 tx_fifo = sh_msiof_spi_write_fifo_32u;
497 else
498 tx_fifo = sh_msiof_spi_write_fifo_32;
499
500 if ((unsigned long)t->rx_buf & 0x03)
501 rx_fifo = sh_msiof_spi_read_fifo_32u;
502 else
503 rx_fifo = sh_msiof_spi_read_fifo_32;
504 }
505
506 /* setup clocks (clock already enabled in chipselect()) */
507 sh_msiof_spi_set_clk_regs(p, clk_get_rate(p->clk),
508 sh_msiof_spi_hz(spi, t));
509
510 /* transfer in fifo sized chunks */
511 words = t->len / bytes_per_word;
512 bytes_done = 0;
513
514 while (bytes_done < t->len) {
515 n = sh_msiof_spi_txrx_once(p, tx_fifo, rx_fifo,
516 t->tx_buf + bytes_done,
517 t->rx_buf + bytes_done,
518 words, bits);
519 if (n < 0)
520 break;
521
522 bytes_done += n * bytes_per_word;
523 words -= n;
524 }
525
526 return bytes_done;
527}
528
529static u32 sh_msiof_spi_txrx_word(struct spi_device *spi, unsigned nsecs,
530 u32 word, u8 bits)
531{
532 BUG(); /* unused but needed by bitbang code */
533 return 0;
534}
535
536static int sh_msiof_spi_probe(struct platform_device *pdev)
537{
538 struct resource *r;
539 struct spi_master *master;
540 struct sh_msiof_spi_priv *p;
541 char clk_name[16];
542 int i;
543 int ret;
544
545 master = spi_alloc_master(&pdev->dev, sizeof(struct sh_msiof_spi_priv));
546 if (master == NULL) {
547 dev_err(&pdev->dev, "failed to allocate spi master\n");
548 ret = -ENOMEM;
549 goto err0;
550 }
551
552 p = spi_master_get_devdata(master);
553
554 platform_set_drvdata(pdev, p);
555 p->info = pdev->dev.platform_data;
556 init_completion(&p->done);
557
558 snprintf(clk_name, sizeof(clk_name), "msiof%d", pdev->id);
559 p->clk = clk_get(&pdev->dev, clk_name);
560 if (IS_ERR(p->clk)) {
561 dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name);
562 ret = PTR_ERR(p->clk);
563 goto err1;
564 }
565
566 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
567 i = platform_get_irq(pdev, 0);
568 if (!r || i < 0) {
569 dev_err(&pdev->dev, "cannot get platform resources\n");
570 ret = -ENOENT;
571 goto err2;
572 }
573 p->mapbase = ioremap_nocache(r->start, resource_size(r));
574 if (!p->mapbase) {
575 dev_err(&pdev->dev, "unable to ioremap\n");
576 ret = -ENXIO;
577 goto err2;
578 }
579
580 ret = request_irq(i, sh_msiof_spi_irq, IRQF_DISABLED,
581 dev_name(&pdev->dev), p);
582 if (ret) {
583 dev_err(&pdev->dev, "unable to request irq\n");
584 goto err3;
585 }
586
587 p->pdev = pdev;
588 pm_runtime_enable(&pdev->dev);
589
590 /* The standard version of MSIOF use 64 word FIFOs */
591 p->tx_fifo_size = 64;
592 p->rx_fifo_size = 64;
593
594 /* Platform data may override FIFO sizes */
595 if (p->info->tx_fifo_override)
596 p->tx_fifo_size = p->info->tx_fifo_override;
597 if (p->info->rx_fifo_override)
598 p->rx_fifo_size = p->info->rx_fifo_override;
599
600 /* init master and bitbang code */
601 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
602 master->mode_bits |= SPI_LSB_FIRST | SPI_3WIRE;
603 master->flags = 0;
604 master->bus_num = pdev->id;
605 master->num_chipselect = p->info->num_chipselect;
606 master->setup = spi_bitbang_setup;
607 master->cleanup = spi_bitbang_cleanup;
608
609 p->bitbang.master = master;
610 p->bitbang.chipselect = sh_msiof_spi_chipselect;
611 p->bitbang.setup_transfer = sh_msiof_spi_setup_transfer;
612 p->bitbang.txrx_bufs = sh_msiof_spi_txrx;
613 p->bitbang.txrx_word[SPI_MODE_0] = sh_msiof_spi_txrx_word;
614 p->bitbang.txrx_word[SPI_MODE_1] = sh_msiof_spi_txrx_word;
615 p->bitbang.txrx_word[SPI_MODE_2] = sh_msiof_spi_txrx_word;
616 p->bitbang.txrx_word[SPI_MODE_3] = sh_msiof_spi_txrx_word;
617
618 ret = spi_bitbang_start(&p->bitbang);
619 if (ret == 0)
620 return 0;
621
622 pm_runtime_disable(&pdev->dev);
623 err3:
624 iounmap(p->mapbase);
625 err2:
626 clk_put(p->clk);
627 err1:
628 spi_master_put(master);
629 err0:
630 return ret;
631}
632
633static int sh_msiof_spi_remove(struct platform_device *pdev)
634{
635 struct sh_msiof_spi_priv *p = platform_get_drvdata(pdev);
636 int ret;
637
638 ret = spi_bitbang_stop(&p->bitbang);
639 if (!ret) {
640 pm_runtime_disable(&pdev->dev);
641 free_irq(platform_get_irq(pdev, 0), sh_msiof_spi_irq);
642 iounmap(p->mapbase);
643 clk_put(p->clk);
644 spi_master_put(p->bitbang.master);
645 }
646 return ret;
647}
648
649static int sh_msiof_spi_runtime_nop(struct device *dev)
650{
651 /* Runtime PM callback shared between ->runtime_suspend()
652 * and ->runtime_resume(). Simply returns success.
653 *
654 * This driver re-initializes all registers after
655 * pm_runtime_get_sync() anyway so there is no need
656 * to save and restore registers here.
657 */
658 return 0;
659}
660
661static struct dev_pm_ops sh_msiof_spi_dev_pm_ops = {
662 .runtime_suspend = sh_msiof_spi_runtime_nop,
663 .runtime_resume = sh_msiof_spi_runtime_nop,
664};
665
666static struct platform_driver sh_msiof_spi_drv = {
667 .probe = sh_msiof_spi_probe,
668 .remove = sh_msiof_spi_remove,
669 .driver = {
670 .name = "spi_sh_msiof",
671 .owner = THIS_MODULE,
672 .pm = &sh_msiof_spi_dev_pm_ops,
673 },
674};
675
676static int __init sh_msiof_spi_init(void)
677{
678 return platform_driver_register(&sh_msiof_spi_drv);
679}
680module_init(sh_msiof_spi_init);
681
682static void __exit sh_msiof_spi_exit(void)
683{
684 platform_driver_unregister(&sh_msiof_spi_drv);
685}
686module_exit(sh_msiof_spi_exit);
687
688MODULE_DESCRIPTION("SuperH MSIOF SPI Master Interface Driver");
689MODULE_AUTHOR("Magnus Damm");
690MODULE_LICENSE("GPL v2");
691MODULE_ALIAS("platform:spi_sh_msiof");
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index 20d7322e2f71..9c446e6003d5 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -266,15 +266,15 @@ static int spidev_message(struct spidev_data *spidev,
266 k_tmp->delay_usecs = u_tmp->delay_usecs; 266 k_tmp->delay_usecs = u_tmp->delay_usecs;
267 k_tmp->speed_hz = u_tmp->speed_hz; 267 k_tmp->speed_hz = u_tmp->speed_hz;
268#ifdef VERBOSE 268#ifdef VERBOSE
269 dev_dbg(&spi->dev, 269 dev_dbg(&spidev->spi->dev,
270 " xfer len %zd %s%s%s%dbits %u usec %uHz\n", 270 " xfer len %zd %s%s%s%dbits %u usec %uHz\n",
271 u_tmp->len, 271 u_tmp->len,
272 u_tmp->rx_buf ? "rx " : "", 272 u_tmp->rx_buf ? "rx " : "",
273 u_tmp->tx_buf ? "tx " : "", 273 u_tmp->tx_buf ? "tx " : "",
274 u_tmp->cs_change ? "cs " : "", 274 u_tmp->cs_change ? "cs " : "",
275 u_tmp->bits_per_word ? : spi->bits_per_word, 275 u_tmp->bits_per_word ? : spidev->spi->bits_per_word,
276 u_tmp->delay_usecs, 276 u_tmp->delay_usecs,
277 u_tmp->speed_hz ? : spi->max_speed_hz); 277 u_tmp->speed_hz ? : spidev->spi->max_speed_hz);
278#endif 278#endif
279 spi_message_add_tail(k_tmp, &msg); 279 spi_message_add_tail(k_tmp, &msg);
280 } 280 }
diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c
index 5a143b9f6361..9f386379c169 100644
--- a/drivers/spi/xilinx_spi.c
+++ b/drivers/spi/xilinx_spi.c
@@ -14,22 +14,20 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/platform_device.h>
18
19#include <linux/of_platform.h>
20#include <linux/of_device.h>
21#include <linux/of_spi.h>
22 17
23#include <linux/spi/spi.h> 18#include <linux/spi/spi.h>
24#include <linux/spi/spi_bitbang.h> 19#include <linux/spi/spi_bitbang.h>
25#include <linux/io.h> 20#include <linux/io.h>
26 21
22#include "xilinx_spi.h"
23#include <linux/spi/xilinx_spi.h>
24
27#define XILINX_SPI_NAME "xilinx_spi" 25#define XILINX_SPI_NAME "xilinx_spi"
28 26
29/* Register definitions as per "OPB Serial Peripheral Interface (SPI) (v1.00e) 27/* Register definitions as per "OPB Serial Peripheral Interface (SPI) (v1.00e)
30 * Product Specification", DS464 28 * Product Specification", DS464
31 */ 29 */
32#define XSPI_CR_OFFSET 0x62 /* 16-bit Control Register */ 30#define XSPI_CR_OFFSET 0x60 /* Control Register */
33 31
34#define XSPI_CR_ENABLE 0x02 32#define XSPI_CR_ENABLE 0x02
35#define XSPI_CR_MASTER_MODE 0x04 33#define XSPI_CR_MASTER_MODE 0x04
@@ -40,8 +38,9 @@
40#define XSPI_CR_RXFIFO_RESET 0x40 38#define XSPI_CR_RXFIFO_RESET 0x40
41#define XSPI_CR_MANUAL_SSELECT 0x80 39#define XSPI_CR_MANUAL_SSELECT 0x80
42#define XSPI_CR_TRANS_INHIBIT 0x100 40#define XSPI_CR_TRANS_INHIBIT 0x100
41#define XSPI_CR_LSB_FIRST 0x200
43 42
44#define XSPI_SR_OFFSET 0x67 /* 8-bit Status Register */ 43#define XSPI_SR_OFFSET 0x64 /* Status Register */
45 44
46#define XSPI_SR_RX_EMPTY_MASK 0x01 /* Receive FIFO is empty */ 45#define XSPI_SR_RX_EMPTY_MASK 0x01 /* Receive FIFO is empty */
47#define XSPI_SR_RX_FULL_MASK 0x02 /* Receive FIFO is full */ 46#define XSPI_SR_RX_FULL_MASK 0x02 /* Receive FIFO is full */
@@ -49,8 +48,8 @@
49#define XSPI_SR_TX_FULL_MASK 0x08 /* Transmit FIFO is full */ 48#define XSPI_SR_TX_FULL_MASK 0x08 /* Transmit FIFO is full */
50#define XSPI_SR_MODE_FAULT_MASK 0x10 /* Mode fault error */ 49#define XSPI_SR_MODE_FAULT_MASK 0x10 /* Mode fault error */
51 50
52#define XSPI_TXD_OFFSET 0x6b /* 8-bit Data Transmit Register */ 51#define XSPI_TXD_OFFSET 0x68 /* Data Transmit Register */
53#define XSPI_RXD_OFFSET 0x6f /* 8-bit Data Receive Register */ 52#define XSPI_RXD_OFFSET 0x6c /* Data Receive Register */
54 53
55#define XSPI_SSR_OFFSET 0x70 /* 32-bit Slave Select Register */ 54#define XSPI_SSR_OFFSET 0x70 /* 32-bit Slave Select Register */
56 55
@@ -70,6 +69,7 @@
70#define XSPI_INTR_TX_UNDERRUN 0x08 /* TxFIFO was underrun */ 69#define XSPI_INTR_TX_UNDERRUN 0x08 /* TxFIFO was underrun */
71#define XSPI_INTR_RX_FULL 0x10 /* RxFIFO is full */ 70#define XSPI_INTR_RX_FULL 0x10 /* RxFIFO is full */
72#define XSPI_INTR_RX_OVERRUN 0x20 /* RxFIFO was overrun */ 71#define XSPI_INTR_RX_OVERRUN 0x20 /* RxFIFO was overrun */
72#define XSPI_INTR_TX_HALF_EMPTY 0x40 /* TxFIFO is half empty */
73 73
74#define XIPIF_V123B_RESETR_OFFSET 0x40 /* IPIF reset register */ 74#define XIPIF_V123B_RESETR_OFFSET 0x40 /* IPIF reset register */
75#define XIPIF_V123B_RESET_MASK 0x0a /* the value to write */ 75#define XIPIF_V123B_RESET_MASK 0x0a /* the value to write */
@@ -78,35 +78,85 @@ struct xilinx_spi {
78 /* bitbang has to be first */ 78 /* bitbang has to be first */
79 struct spi_bitbang bitbang; 79 struct spi_bitbang bitbang;
80 struct completion done; 80 struct completion done;
81 81 struct resource mem; /* phys mem */
82 void __iomem *regs; /* virt. address of the control registers */ 82 void __iomem *regs; /* virt. address of the control registers */
83 83
84 u32 irq; 84 u32 irq;
85 85
86 u32 speed_hz; /* SCK has a fixed frequency of speed_hz Hz */
87
88 u8 *rx_ptr; /* pointer in the Tx buffer */ 86 u8 *rx_ptr; /* pointer in the Tx buffer */
89 const u8 *tx_ptr; /* pointer in the Rx buffer */ 87 const u8 *tx_ptr; /* pointer in the Rx buffer */
90 int remaining_bytes; /* the number of bytes left to transfer */ 88 int remaining_bytes; /* the number of bytes left to transfer */
89 u8 bits_per_word;
90 unsigned int (*read_fn) (void __iomem *);
91 void (*write_fn) (u32, void __iomem *);
92 void (*tx_fn) (struct xilinx_spi *);
93 void (*rx_fn) (struct xilinx_spi *);
91}; 94};
92 95
93static void xspi_init_hw(void __iomem *regs_base) 96static void xspi_tx8(struct xilinx_spi *xspi)
97{
98 xspi->write_fn(*xspi->tx_ptr, xspi->regs + XSPI_TXD_OFFSET);
99 xspi->tx_ptr++;
100}
101
102static void xspi_tx16(struct xilinx_spi *xspi)
103{
104 xspi->write_fn(*(u16 *)(xspi->tx_ptr), xspi->regs + XSPI_TXD_OFFSET);
105 xspi->tx_ptr += 2;
106}
107
108static void xspi_tx32(struct xilinx_spi *xspi)
109{
110 xspi->write_fn(*(u32 *)(xspi->tx_ptr), xspi->regs + XSPI_TXD_OFFSET);
111 xspi->tx_ptr += 4;
112}
113
114static void xspi_rx8(struct xilinx_spi *xspi)
115{
116 u32 data = xspi->read_fn(xspi->regs + XSPI_RXD_OFFSET);
117 if (xspi->rx_ptr) {
118 *xspi->rx_ptr = data & 0xff;
119 xspi->rx_ptr++;
120 }
121}
122
123static void xspi_rx16(struct xilinx_spi *xspi)
94{ 124{
125 u32 data = xspi->read_fn(xspi->regs + XSPI_RXD_OFFSET);
126 if (xspi->rx_ptr) {
127 *(u16 *)(xspi->rx_ptr) = data & 0xffff;
128 xspi->rx_ptr += 2;
129 }
130}
131
132static void xspi_rx32(struct xilinx_spi *xspi)
133{
134 u32 data = xspi->read_fn(xspi->regs + XSPI_RXD_OFFSET);
135 if (xspi->rx_ptr) {
136 *(u32 *)(xspi->rx_ptr) = data;
137 xspi->rx_ptr += 4;
138 }
139}
140
141static void xspi_init_hw(struct xilinx_spi *xspi)
142{
143 void __iomem *regs_base = xspi->regs;
144
95 /* Reset the SPI device */ 145 /* Reset the SPI device */
96 out_be32(regs_base + XIPIF_V123B_RESETR_OFFSET, 146 xspi->write_fn(XIPIF_V123B_RESET_MASK,
97 XIPIF_V123B_RESET_MASK); 147 regs_base + XIPIF_V123B_RESETR_OFFSET);
98 /* Disable all the interrupts just in case */ 148 /* Disable all the interrupts just in case */
99 out_be32(regs_base + XIPIF_V123B_IIER_OFFSET, 0); 149 xspi->write_fn(0, regs_base + XIPIF_V123B_IIER_OFFSET);
100 /* Enable the global IPIF interrupt */ 150 /* Enable the global IPIF interrupt */
101 out_be32(regs_base + XIPIF_V123B_DGIER_OFFSET, 151 xspi->write_fn(XIPIF_V123B_GINTR_ENABLE,
102 XIPIF_V123B_GINTR_ENABLE); 152 regs_base + XIPIF_V123B_DGIER_OFFSET);
103 /* Deselect the slave on the SPI bus */ 153 /* Deselect the slave on the SPI bus */
104 out_be32(regs_base + XSPI_SSR_OFFSET, 0xffff); 154 xspi->write_fn(0xffff, regs_base + XSPI_SSR_OFFSET);
105 /* Disable the transmitter, enable Manual Slave Select Assertion, 155 /* Disable the transmitter, enable Manual Slave Select Assertion,
106 * put SPI controller into master mode, and enable it */ 156 * put SPI controller into master mode, and enable it */
107 out_be16(regs_base + XSPI_CR_OFFSET, 157 xspi->write_fn(XSPI_CR_TRANS_INHIBIT | XSPI_CR_MANUAL_SSELECT |
108 XSPI_CR_TRANS_INHIBIT | XSPI_CR_MANUAL_SSELECT 158 XSPI_CR_MASTER_MODE | XSPI_CR_ENABLE | XSPI_CR_TXFIFO_RESET |
109 | XSPI_CR_MASTER_MODE | XSPI_CR_ENABLE); 159 XSPI_CR_RXFIFO_RESET, regs_base + XSPI_CR_OFFSET);
110} 160}
111 161
112static void xilinx_spi_chipselect(struct spi_device *spi, int is_on) 162static void xilinx_spi_chipselect(struct spi_device *spi, int is_on)
@@ -115,16 +165,16 @@ static void xilinx_spi_chipselect(struct spi_device *spi, int is_on)
115 165
116 if (is_on == BITBANG_CS_INACTIVE) { 166 if (is_on == BITBANG_CS_INACTIVE) {
117 /* Deselect the slave on the SPI bus */ 167 /* Deselect the slave on the SPI bus */
118 out_be32(xspi->regs + XSPI_SSR_OFFSET, 0xffff); 168 xspi->write_fn(0xffff, xspi->regs + XSPI_SSR_OFFSET);
119 } else if (is_on == BITBANG_CS_ACTIVE) { 169 } else if (is_on == BITBANG_CS_ACTIVE) {
120 /* Set the SPI clock phase and polarity */ 170 /* Set the SPI clock phase and polarity */
121 u16 cr = in_be16(xspi->regs + XSPI_CR_OFFSET) 171 u16 cr = xspi->read_fn(xspi->regs + XSPI_CR_OFFSET)
122 & ~XSPI_CR_MODE_MASK; 172 & ~XSPI_CR_MODE_MASK;
123 if (spi->mode & SPI_CPHA) 173 if (spi->mode & SPI_CPHA)
124 cr |= XSPI_CR_CPHA; 174 cr |= XSPI_CR_CPHA;
125 if (spi->mode & SPI_CPOL) 175 if (spi->mode & SPI_CPOL)
126 cr |= XSPI_CR_CPOL; 176 cr |= XSPI_CR_CPOL;
127 out_be16(xspi->regs + XSPI_CR_OFFSET, cr); 177 xspi->write_fn(cr, xspi->regs + XSPI_CR_OFFSET);
128 178
129 /* We do not check spi->max_speed_hz here as the SPI clock 179 /* We do not check spi->max_speed_hz here as the SPI clock
130 * frequency is not software programmable (the IP block design 180 * frequency is not software programmable (the IP block design
@@ -132,25 +182,27 @@ static void xilinx_spi_chipselect(struct spi_device *spi, int is_on)
132 */ 182 */
133 183
134 /* Activate the chip select */ 184 /* Activate the chip select */
135 out_be32(xspi->regs + XSPI_SSR_OFFSET, 185 xspi->write_fn(~(0x0001 << spi->chip_select),
136 ~(0x0001 << spi->chip_select)); 186 xspi->regs + XSPI_SSR_OFFSET);
137 } 187 }
138} 188}
139 189
140/* spi_bitbang requires custom setup_transfer() to be defined if there is a 190/* spi_bitbang requires custom setup_transfer() to be defined if there is a
141 * custom txrx_bufs(). We have nothing to setup here as the SPI IP block 191 * custom txrx_bufs(). We have nothing to setup here as the SPI IP block
142 * supports just 8 bits per word, and SPI clock can't be changed in software. 192 * supports 8 or 16 bits per word which cannot be changed in software.
143 * Check for 8 bits per word. Chip select delay calculations could be 193 * SPI clock can't be changed in software either.
194 * Check for correct bits per word. Chip select delay calculations could be
144 * added here as soon as bitbang_work() can be made aware of the delay value. 195 * added here as soon as bitbang_work() can be made aware of the delay value.
145 */ 196 */
146static int xilinx_spi_setup_transfer(struct spi_device *spi, 197static int xilinx_spi_setup_transfer(struct spi_device *spi,
147 struct spi_transfer *t) 198 struct spi_transfer *t)
148{ 199{
200 struct xilinx_spi *xspi = spi_master_get_devdata(spi->master);
149 u8 bits_per_word; 201 u8 bits_per_word;
150 202
151 bits_per_word = (t && t->bits_per_word) 203 bits_per_word = (t && t->bits_per_word)
152 ? t->bits_per_word : spi->bits_per_word; 204 ? t->bits_per_word : spi->bits_per_word;
153 if (bits_per_word != 8) { 205 if (bits_per_word != xspi->bits_per_word) {
154 dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n", 206 dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n",
155 __func__, bits_per_word); 207 __func__, bits_per_word);
156 return -EINVAL; 208 return -EINVAL;
@@ -161,17 +213,16 @@ static int xilinx_spi_setup_transfer(struct spi_device *spi,
161 213
162static int xilinx_spi_setup(struct spi_device *spi) 214static int xilinx_spi_setup(struct spi_device *spi)
163{ 215{
164 struct spi_bitbang *bitbang; 216 /* always return 0, we can not check the number of bits.
165 struct xilinx_spi *xspi; 217 * There are cases when SPI setup is called before any driver is
166 int retval; 218 * there, in that case the SPI core defaults to 8 bits, which we
167 219 * do not support in some cases. But if we return an error, the
168 xspi = spi_master_get_devdata(spi->master); 220 * SPI device would not be registered and no driver can get hold of it
169 bitbang = &xspi->bitbang; 221 * When the driver is there, it will call SPI setup again with the
170 222 * correct number of bits per transfer.
171 retval = xilinx_spi_setup_transfer(spi, NULL); 223 * If a driver setups with the wrong bit number, it will fail when
172 if (retval < 0) 224 * it tries to do a transfer
173 return retval; 225 */
174
175 return 0; 226 return 0;
176} 227}
177 228
@@ -180,15 +231,14 @@ static void xilinx_spi_fill_tx_fifo(struct xilinx_spi *xspi)
180 u8 sr; 231 u8 sr;
181 232
182 /* Fill the Tx FIFO with as many bytes as possible */ 233 /* Fill the Tx FIFO with as many bytes as possible */
183 sr = in_8(xspi->regs + XSPI_SR_OFFSET); 234 sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET);
184 while ((sr & XSPI_SR_TX_FULL_MASK) == 0 && xspi->remaining_bytes > 0) { 235 while ((sr & XSPI_SR_TX_FULL_MASK) == 0 && xspi->remaining_bytes > 0) {
185 if (xspi->tx_ptr) { 236 if (xspi->tx_ptr)
186 out_8(xspi->regs + XSPI_TXD_OFFSET, *xspi->tx_ptr++); 237 xspi->tx_fn(xspi);
187 } else { 238 else
188 out_8(xspi->regs + XSPI_TXD_OFFSET, 0); 239 xspi->write_fn(0, xspi->regs + XSPI_TXD_OFFSET);
189 } 240 xspi->remaining_bytes -= xspi->bits_per_word / 8;
190 xspi->remaining_bytes--; 241 sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET);
191 sr = in_8(xspi->regs + XSPI_SR_OFFSET);
192 } 242 }
193} 243}
194 244
@@ -210,18 +260,19 @@ static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t)
210 /* Enable the transmit empty interrupt, which we use to determine 260 /* Enable the transmit empty interrupt, which we use to determine
211 * progress on the transmission. 261 * progress on the transmission.
212 */ 262 */
213 ipif_ier = in_be32(xspi->regs + XIPIF_V123B_IIER_OFFSET); 263 ipif_ier = xspi->read_fn(xspi->regs + XIPIF_V123B_IIER_OFFSET);
214 out_be32(xspi->regs + XIPIF_V123B_IIER_OFFSET, 264 xspi->write_fn(ipif_ier | XSPI_INTR_TX_EMPTY,
215 ipif_ier | XSPI_INTR_TX_EMPTY); 265 xspi->regs + XIPIF_V123B_IIER_OFFSET);
216 266
217 /* Start the transfer by not inhibiting the transmitter any longer */ 267 /* Start the transfer by not inhibiting the transmitter any longer */
218 cr = in_be16(xspi->regs + XSPI_CR_OFFSET) & ~XSPI_CR_TRANS_INHIBIT; 268 cr = xspi->read_fn(xspi->regs + XSPI_CR_OFFSET) &
219 out_be16(xspi->regs + XSPI_CR_OFFSET, cr); 269 ~XSPI_CR_TRANS_INHIBIT;
270 xspi->write_fn(cr, xspi->regs + XSPI_CR_OFFSET);
220 271
221 wait_for_completion(&xspi->done); 272 wait_for_completion(&xspi->done);
222 273
223 /* Disable the transmit empty interrupt */ 274 /* Disable the transmit empty interrupt */
224 out_be32(xspi->regs + XIPIF_V123B_IIER_OFFSET, ipif_ier); 275 xspi->write_fn(ipif_ier, xspi->regs + XIPIF_V123B_IIER_OFFSET);
225 276
226 return t->len - xspi->remaining_bytes; 277 return t->len - xspi->remaining_bytes;
227} 278}
@@ -238,8 +289,8 @@ static irqreturn_t xilinx_spi_irq(int irq, void *dev_id)
238 u32 ipif_isr; 289 u32 ipif_isr;
239 290
240 /* Get the IPIF interrupts, and clear them immediately */ 291 /* Get the IPIF interrupts, and clear them immediately */
241 ipif_isr = in_be32(xspi->regs + XIPIF_V123B_IISR_OFFSET); 292 ipif_isr = xspi->read_fn(xspi->regs + XIPIF_V123B_IISR_OFFSET);
242 out_be32(xspi->regs + XIPIF_V123B_IISR_OFFSET, ipif_isr); 293 xspi->write_fn(ipif_isr, xspi->regs + XIPIF_V123B_IISR_OFFSET);
243 294
244 if (ipif_isr & XSPI_INTR_TX_EMPTY) { /* Transmission completed */ 295 if (ipif_isr & XSPI_INTR_TX_EMPTY) { /* Transmission completed */
245 u16 cr; 296 u16 cr;
@@ -250,20 +301,15 @@ static irqreturn_t xilinx_spi_irq(int irq, void *dev_id)
250 * transmitter while the Isr refills the transmit register/FIFO, 301 * transmitter while the Isr refills the transmit register/FIFO,
251 * or make sure it is stopped if we're done. 302 * or make sure it is stopped if we're done.
252 */ 303 */
253 cr = in_be16(xspi->regs + XSPI_CR_OFFSET); 304 cr = xspi->read_fn(xspi->regs + XSPI_CR_OFFSET);
254 out_be16(xspi->regs + XSPI_CR_OFFSET, 305 xspi->write_fn(cr | XSPI_CR_TRANS_INHIBIT,
255 cr | XSPI_CR_TRANS_INHIBIT); 306 xspi->regs + XSPI_CR_OFFSET);
256 307
257 /* Read out all the data from the Rx FIFO */ 308 /* Read out all the data from the Rx FIFO */
258 sr = in_8(xspi->regs + XSPI_SR_OFFSET); 309 sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET);
259 while ((sr & XSPI_SR_RX_EMPTY_MASK) == 0) { 310 while ((sr & XSPI_SR_RX_EMPTY_MASK) == 0) {
260 u8 data; 311 xspi->rx_fn(xspi);
261 312 sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET);
262 data = in_8(xspi->regs + XSPI_RXD_OFFSET);
263 if (xspi->rx_ptr) {
264 *xspi->rx_ptr++ = data;
265 }
266 sr = in_8(xspi->regs + XSPI_SR_OFFSET);
267 } 313 }
268 314
269 /* See if there is more data to send */ 315 /* See if there is more data to send */
@@ -272,7 +318,7 @@ static irqreturn_t xilinx_spi_irq(int irq, void *dev_id)
272 /* Start the transfer by not inhibiting the 318 /* Start the transfer by not inhibiting the
273 * transmitter any longer 319 * transmitter any longer
274 */ 320 */
275 out_be16(xspi->regs + XSPI_CR_OFFSET, cr); 321 xspi->write_fn(cr, xspi->regs + XSPI_CR_OFFSET);
276 } else { 322 } else {
277 /* No more data to send. 323 /* No more data to send.
278 * Indicate the transfer is completed. 324 * Indicate the transfer is completed.
@@ -284,40 +330,22 @@ static irqreturn_t xilinx_spi_irq(int irq, void *dev_id)
284 return IRQ_HANDLED; 330 return IRQ_HANDLED;
285} 331}
286 332
287static int __init xilinx_spi_of_probe(struct of_device *ofdev, 333struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
288 const struct of_device_id *match) 334 u32 irq, s16 bus_num)
289{ 335{
290 struct spi_master *master; 336 struct spi_master *master;
291 struct xilinx_spi *xspi; 337 struct xilinx_spi *xspi;
292 struct resource r_irq_struct; 338 struct xspi_platform_data *pdata = dev->platform_data;
293 struct resource r_mem_struct; 339 int ret;
294
295 struct resource *r_irq = &r_irq_struct;
296 struct resource *r_mem = &r_mem_struct;
297 int rc = 0;
298 const u32 *prop;
299 int len;
300
301 /* Get resources(memory, IRQ) associated with the device */
302 master = spi_alloc_master(&ofdev->dev, sizeof(struct xilinx_spi));
303 340
304 if (master == NULL) { 341 if (!pdata) {
305 return -ENOMEM; 342 dev_err(dev, "No platform data attached\n");
343 return NULL;
306 } 344 }
307 345
308 dev_set_drvdata(&ofdev->dev, master); 346 master = spi_alloc_master(dev, sizeof(struct xilinx_spi));
309 347 if (!master)
310 rc = of_address_to_resource(ofdev->node, 0, r_mem); 348 return NULL;
311 if (rc) {
312 dev_warn(&ofdev->dev, "invalid address\n");
313 goto put_master;
314 }
315
316 rc = of_irq_to_resource(ofdev->node, 0, r_irq);
317 if (rc == NO_IRQ) {
318 dev_warn(&ofdev->dev, "no IRQ found\n");
319 goto put_master;
320 }
321 349
322 /* the spi->mode bits understood by this driver: */ 350 /* the spi->mode bits understood by this driver: */
323 master->mode_bits = SPI_CPOL | SPI_CPHA; 351 master->mode_bits = SPI_CPOL | SPI_CPHA;
@@ -330,128 +358,87 @@ static int __init xilinx_spi_of_probe(struct of_device *ofdev,
330 xspi->bitbang.master->setup = xilinx_spi_setup; 358 xspi->bitbang.master->setup = xilinx_spi_setup;
331 init_completion(&xspi->done); 359 init_completion(&xspi->done);
332 360
333 xspi->irq = r_irq->start; 361 if (!request_mem_region(mem->start, resource_size(mem),
334 362 XILINX_SPI_NAME))
335 if (!request_mem_region(r_mem->start,
336 r_mem->end - r_mem->start + 1, XILINX_SPI_NAME)) {
337 rc = -ENXIO;
338 dev_warn(&ofdev->dev, "memory request failure\n");
339 goto put_master; 363 goto put_master;
340 }
341 364
342 xspi->regs = ioremap(r_mem->start, r_mem->end - r_mem->start + 1); 365 xspi->regs = ioremap(mem->start, resource_size(mem));
343 if (xspi->regs == NULL) { 366 if (xspi->regs == NULL) {
344 rc = -ENOMEM; 367 dev_warn(dev, "ioremap failure\n");
345 dev_warn(&ofdev->dev, "ioremap failure\n"); 368 goto map_failed;
346 goto release_mem;
347 } 369 }
348 xspi->irq = r_irq->start;
349
350 /* dynamic bus assignment */
351 master->bus_num = -1;
352 370
353 /* number of slave select bits is required */ 371 master->bus_num = bus_num;
354 prop = of_get_property(ofdev->node, "xlnx,num-ss-bits", &len); 372 master->num_chipselect = pdata->num_chipselect;
355 if (!prop || len < sizeof(*prop)) { 373
356 dev_warn(&ofdev->dev, "no 'xlnx,num-ss-bits' property\n"); 374 xspi->mem = *mem;
357 goto unmap_io; 375 xspi->irq = irq;
376 if (pdata->little_endian) {
377 xspi->read_fn = ioread32;
378 xspi->write_fn = iowrite32;
379 } else {
380 xspi->read_fn = ioread32be;
381 xspi->write_fn = iowrite32be;
358 } 382 }
359 master->num_chipselect = *prop; 383 xspi->bits_per_word = pdata->bits_per_word;
384 if (xspi->bits_per_word == 8) {
385 xspi->tx_fn = xspi_tx8;
386 xspi->rx_fn = xspi_rx8;
387 } else if (xspi->bits_per_word == 16) {
388 xspi->tx_fn = xspi_tx16;
389 xspi->rx_fn = xspi_rx16;
390 } else if (xspi->bits_per_word == 32) {
391 xspi->tx_fn = xspi_tx32;
392 xspi->rx_fn = xspi_rx32;
393 } else
394 goto unmap_io;
395
360 396
361 /* SPI controller initializations */ 397 /* SPI controller initializations */
362 xspi_init_hw(xspi->regs); 398 xspi_init_hw(xspi);
363 399
364 /* Register for SPI Interrupt */ 400 /* Register for SPI Interrupt */
365 rc = request_irq(xspi->irq, xilinx_spi_irq, 0, XILINX_SPI_NAME, xspi); 401 ret = request_irq(xspi->irq, xilinx_spi_irq, 0, XILINX_SPI_NAME, xspi);
366 if (rc != 0) { 402 if (ret)
367 dev_warn(&ofdev->dev, "irq request failure: %d\n", xspi->irq);
368 goto unmap_io; 403 goto unmap_io;
369 }
370 404
371 rc = spi_bitbang_start(&xspi->bitbang); 405 ret = spi_bitbang_start(&xspi->bitbang);
372 if (rc != 0) { 406 if (ret) {
373 dev_err(&ofdev->dev, "spi_bitbang_start FAILED\n"); 407 dev_err(dev, "spi_bitbang_start FAILED\n");
374 goto free_irq; 408 goto free_irq;
375 } 409 }
376 410
377 dev_info(&ofdev->dev, "at 0x%08X mapped to 0x%08X, irq=%d\n", 411 dev_info(dev, "at 0x%08llX mapped to 0x%p, irq=%d\n",
378 (unsigned int)r_mem->start, (u32)xspi->regs, xspi->irq); 412 (unsigned long long)mem->start, xspi->regs, xspi->irq);
379 413 return master;
380 /* Add any subnodes on the SPI bus */
381 of_register_spi_devices(master, ofdev->node);
382
383 return rc;
384 414
385free_irq: 415free_irq:
386 free_irq(xspi->irq, xspi); 416 free_irq(xspi->irq, xspi);
387unmap_io: 417unmap_io:
388 iounmap(xspi->regs); 418 iounmap(xspi->regs);
389release_mem: 419map_failed:
390 release_mem_region(r_mem->start, resource_size(r_mem)); 420 release_mem_region(mem->start, resource_size(mem));
391put_master: 421put_master:
392 spi_master_put(master); 422 spi_master_put(master);
393 return rc; 423 return NULL;
394} 424}
425EXPORT_SYMBOL(xilinx_spi_init);
395 426
396static int __devexit xilinx_spi_remove(struct of_device *ofdev) 427void xilinx_spi_deinit(struct spi_master *master)
397{ 428{
398 struct xilinx_spi *xspi; 429 struct xilinx_spi *xspi;
399 struct spi_master *master;
400 struct resource r_mem;
401 430
402 master = platform_get_drvdata(ofdev);
403 xspi = spi_master_get_devdata(master); 431 xspi = spi_master_get_devdata(master);
404 432
405 spi_bitbang_stop(&xspi->bitbang); 433 spi_bitbang_stop(&xspi->bitbang);
406 free_irq(xspi->irq, xspi); 434 free_irq(xspi->irq, xspi);
407 iounmap(xspi->regs); 435 iounmap(xspi->regs);
408 if (!of_address_to_resource(ofdev->node, 0, &r_mem))
409 release_mem_region(r_mem.start, resource_size(&r_mem));
410 dev_set_drvdata(&ofdev->dev, 0);
411 spi_master_put(xspi->bitbang.master);
412
413 return 0;
414}
415
416/* work with hotplug and coldplug */
417MODULE_ALIAS("platform:" XILINX_SPI_NAME);
418
419static int __exit xilinx_spi_of_remove(struct of_device *op)
420{
421 return xilinx_spi_remove(op);
422}
423 436
424static struct of_device_id xilinx_spi_of_match[] = { 437 release_mem_region(xspi->mem.start, resource_size(&xspi->mem));
425 { .compatible = "xlnx,xps-spi-2.00.a", }, 438 spi_master_put(xspi->bitbang.master);
426 { .compatible = "xlnx,xps-spi-2.00.b", },
427 {}
428};
429
430MODULE_DEVICE_TABLE(of, xilinx_spi_of_match);
431
432static struct of_platform_driver xilinx_spi_of_driver = {
433 .owner = THIS_MODULE,
434 .name = "xilinx-xps-spi",
435 .match_table = xilinx_spi_of_match,
436 .probe = xilinx_spi_of_probe,
437 .remove = __exit_p(xilinx_spi_of_remove),
438 .driver = {
439 .name = "xilinx-xps-spi",
440 .owner = THIS_MODULE,
441 },
442};
443
444static int __init xilinx_spi_init(void)
445{
446 return of_register_platform_driver(&xilinx_spi_of_driver);
447} 439}
448module_init(xilinx_spi_init); 440EXPORT_SYMBOL(xilinx_spi_deinit);
449 441
450static void __exit xilinx_spi_exit(void)
451{
452 of_unregister_platform_driver(&xilinx_spi_of_driver);
453}
454module_exit(xilinx_spi_exit);
455MODULE_AUTHOR("MontaVista Software, Inc. <source@mvista.com>"); 442MODULE_AUTHOR("MontaVista Software, Inc. <source@mvista.com>");
456MODULE_DESCRIPTION("Xilinx SPI driver"); 443MODULE_DESCRIPTION("Xilinx SPI driver");
457MODULE_LICENSE("GPL"); 444MODULE_LICENSE("GPL");
diff --git a/drivers/spi/xilinx_spi.h b/drivers/spi/xilinx_spi.h
new file mode 100644
index 000000000000..d211accf68d2
--- /dev/null
+++ b/drivers/spi/xilinx_spi.h
@@ -0,0 +1,32 @@
1/*
2 * Xilinx SPI device driver API and platform data header file
3 *
4 * Copyright (c) 2009 Intel Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20#ifndef _XILINX_SPI_H_
21#define _XILINX_SPI_H_
22
23#include <linux/spi/spi.h>
24#include <linux/spi/spi_bitbang.h>
25
26#define XILINX_SPI_NAME "xilinx_spi"
27
28struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
29 u32 irq, s16 bus_num);
30
31void xilinx_spi_deinit(struct spi_master *master);
32#endif
diff --git a/drivers/spi/xilinx_spi_of.c b/drivers/spi/xilinx_spi_of.c
new file mode 100644
index 000000000000..71dc3adc0495
--- /dev/null
+++ b/drivers/spi/xilinx_spi_of.c
@@ -0,0 +1,134 @@
1/*
2 * Xilinx SPI OF device driver
3 *
4 * Copyright (c) 2009 Intel Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20/* Supports:
21 * Xilinx SPI devices as OF devices
22 *
23 * Inspired by xilinx_spi.c, 2002-2007 (c) MontaVista Software, Inc.
24 */
25
26#include <linux/module.h>
27#include <linux/init.h>
28#include <linux/interrupt.h>
29#include <linux/io.h>
30
31#include <linux/of_platform.h>
32#include <linux/of_device.h>
33#include <linux/of_spi.h>
34
35#include <linux/spi/xilinx_spi.h>
36#include "xilinx_spi.h"
37
38
39static int __devinit xilinx_spi_of_probe(struct of_device *ofdev,
40 const struct of_device_id *match)
41{
42 struct spi_master *master;
43 struct xspi_platform_data *pdata;
44 struct resource r_mem;
45 struct resource r_irq;
46 int rc = 0;
47 const u32 *prop;
48 int len;
49
50 rc = of_address_to_resource(ofdev->node, 0, &r_mem);
51 if (rc) {
52 dev_warn(&ofdev->dev, "invalid address\n");
53 return rc;
54 }
55
56 rc = of_irq_to_resource(ofdev->node, 0, &r_irq);
57 if (rc == NO_IRQ) {
58 dev_warn(&ofdev->dev, "no IRQ found\n");
59 return -ENODEV;
60 }
61
62 ofdev->dev.platform_data =
63 kzalloc(sizeof(struct xspi_platform_data), GFP_KERNEL);
64 pdata = ofdev->dev.platform_data;
65 if (!pdata)
66 return -ENOMEM;
67
68 /* number of slave select bits is required */
69 prop = of_get_property(ofdev->node, "xlnx,num-ss-bits", &len);
70 if (!prop || len < sizeof(*prop)) {
71 dev_warn(&ofdev->dev, "no 'xlnx,num-ss-bits' property\n");
72 return -EINVAL;
73 }
74 pdata->num_chipselect = *prop;
75 pdata->bits_per_word = 8;
76 master = xilinx_spi_init(&ofdev->dev, &r_mem, r_irq.start, -1);
77 if (!master)
78 return -ENODEV;
79
80 dev_set_drvdata(&ofdev->dev, master);
81
82 /* Add any subnodes on the SPI bus */
83 of_register_spi_devices(master, ofdev->node);
84
85 return 0;
86}
87
88static int __devexit xilinx_spi_remove(struct of_device *ofdev)
89{
90 xilinx_spi_deinit(dev_get_drvdata(&ofdev->dev));
91 dev_set_drvdata(&ofdev->dev, 0);
92 kfree(ofdev->dev.platform_data);
93 ofdev->dev.platform_data = NULL;
94 return 0;
95}
96
97static int __exit xilinx_spi_of_remove(struct of_device *op)
98{
99 return xilinx_spi_remove(op);
100}
101
102static struct of_device_id xilinx_spi_of_match[] = {
103 { .compatible = "xlnx,xps-spi-2.00.a", },
104 { .compatible = "xlnx,xps-spi-2.00.b", },
105 {}
106};
107
108MODULE_DEVICE_TABLE(of, xilinx_spi_of_match);
109
110static struct of_platform_driver xilinx_spi_of_driver = {
111 .match_table = xilinx_spi_of_match,
112 .probe = xilinx_spi_of_probe,
113 .remove = __exit_p(xilinx_spi_of_remove),
114 .driver = {
115 .name = "xilinx-xps-spi",
116 .owner = THIS_MODULE,
117 },
118};
119
120static int __init xilinx_spi_of_init(void)
121{
122 return of_register_platform_driver(&xilinx_spi_of_driver);
123}
124module_init(xilinx_spi_of_init);
125
126static void __exit xilinx_spi_of_exit(void)
127{
128 of_unregister_platform_driver(&xilinx_spi_of_driver);
129}
130module_exit(xilinx_spi_of_exit);
131
132MODULE_AUTHOR("Mocean Laboratories <info@mocean-labs.com>");
133MODULE_DESCRIPTION("Xilinx SPI platform driver");
134MODULE_LICENSE("GPL v2");
diff --git a/drivers/spi/xilinx_spi_pltfm.c b/drivers/spi/xilinx_spi_pltfm.c
new file mode 100644
index 000000000000..24debac646a9
--- /dev/null
+++ b/drivers/spi/xilinx_spi_pltfm.c
@@ -0,0 +1,102 @@
1/*
2 * Support for Xilinx SPI platform devices
3 * Copyright (c) 2009 Intel Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19/* Supports:
20 * Xilinx SPI devices as platform devices
21 *
22 * Inspired by xilinx_spi.c, 2002-2007 (c) MontaVista Software, Inc.
23 */
24
25#include <linux/module.h>
26#include <linux/init.h>
27#include <linux/interrupt.h>
28#include <linux/io.h>
29#include <linux/platform_device.h>
30
31#include <linux/spi/spi.h>
32#include <linux/spi/spi_bitbang.h>
33#include <linux/spi/xilinx_spi.h>
34
35#include "xilinx_spi.h"
36
37static int __devinit xilinx_spi_probe(struct platform_device *dev)
38{
39 struct xspi_platform_data *pdata;
40 struct resource *r;
41 int irq;
42 struct spi_master *master;
43 u8 i;
44
45 pdata = dev->dev.platform_data;
46 if (!pdata)
47 return -ENODEV;
48
49 r = platform_get_resource(dev, IORESOURCE_MEM, 0);
50 if (!r)
51 return -ENODEV;
52
53 irq = platform_get_irq(dev, 0);
54 if (irq < 0)
55 return -ENXIO;
56
57 master = xilinx_spi_init(&dev->dev, r, irq, dev->id);
58 if (!master)
59 return -ENODEV;
60
61 for (i = 0; i < pdata->num_devices; i++)
62 spi_new_device(master, pdata->devices + i);
63
64 platform_set_drvdata(dev, master);
65 return 0;
66}
67
68static int __devexit xilinx_spi_remove(struct platform_device *dev)
69{
70 xilinx_spi_deinit(platform_get_drvdata(dev));
71 platform_set_drvdata(dev, 0);
72
73 return 0;
74}
75
76/* work with hotplug and coldplug */
77MODULE_ALIAS("platform:" XILINX_SPI_NAME);
78
79static struct platform_driver xilinx_spi_driver = {
80 .probe = xilinx_spi_probe,
81 .remove = __devexit_p(xilinx_spi_remove),
82 .driver = {
83 .name = XILINX_SPI_NAME,
84 .owner = THIS_MODULE,
85 },
86};
87
88static int __init xilinx_spi_pltfm_init(void)
89{
90 return platform_driver_register(&xilinx_spi_driver);
91}
92module_init(xilinx_spi_pltfm_init);
93
94static void __exit xilinx_spi_pltfm_exit(void)
95{
96 platform_driver_unregister(&xilinx_spi_driver);
97}
98module_exit(xilinx_spi_pltfm_exit);
99
100MODULE_AUTHOR("Mocean Laboratories <info@mocean-labs.com>");
101MODULE_DESCRIPTION("Xilinx SPI platform driver");
102MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c
index bd9883f41e63..2be9f2fa41f9 100644
--- a/drivers/usb/otg/twl4030-usb.c
+++ b/drivers/usb/otg/twl4030-usb.c
@@ -33,7 +33,7 @@
33#include <linux/io.h> 33#include <linux/io.h>
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <linux/usb/otg.h> 35#include <linux/usb/otg.h>
36#include <linux/i2c/twl4030.h> 36#include <linux/i2c/twl.h>
37#include <linux/regulator/consumer.h> 37#include <linux/regulator/consumer.h>
38#include <linux/err.h> 38#include <linux/err.h>
39 39
@@ -276,16 +276,16 @@ static int twl4030_i2c_write_u8_verify(struct twl4030_usb *twl,
276{ 276{
277 u8 check; 277 u8 check;
278 278
279 if ((twl4030_i2c_write_u8(module, data, address) >= 0) && 279 if ((twl_i2c_write_u8(module, data, address) >= 0) &&
280 (twl4030_i2c_read_u8(module, &check, address) >= 0) && 280 (twl_i2c_read_u8(module, &check, address) >= 0) &&
281 (check == data)) 281 (check == data))
282 return 0; 282 return 0;
283 dev_dbg(twl->dev, "Write%d[%d,0x%x] wrote %02x but read %02x\n", 283 dev_dbg(twl->dev, "Write%d[%d,0x%x] wrote %02x but read %02x\n",
284 1, module, address, check, data); 284 1, module, address, check, data);
285 285
286 /* Failed once: Try again */ 286 /* Failed once: Try again */
287 if ((twl4030_i2c_write_u8(module, data, address) >= 0) && 287 if ((twl_i2c_write_u8(module, data, address) >= 0) &&
288 (twl4030_i2c_read_u8(module, &check, address) >= 0) && 288 (twl_i2c_read_u8(module, &check, address) >= 0) &&
289 (check == data)) 289 (check == data))
290 return 0; 290 return 0;
291 dev_dbg(twl->dev, "Write%d[%d,0x%x] wrote %02x but read %02x\n", 291 dev_dbg(twl->dev, "Write%d[%d,0x%x] wrote %02x but read %02x\n",
@@ -303,7 +303,7 @@ static inline int twl4030_usb_write(struct twl4030_usb *twl,
303{ 303{
304 int ret = 0; 304 int ret = 0;
305 305
306 ret = twl4030_i2c_write_u8(TWL4030_MODULE_USB, data, address); 306 ret = twl_i2c_write_u8(TWL4030_MODULE_USB, data, address);
307 if (ret < 0) 307 if (ret < 0)
308 dev_dbg(twl->dev, 308 dev_dbg(twl->dev,
309 "TWL4030:USB:Write[0x%x] Error %d\n", address, ret); 309 "TWL4030:USB:Write[0x%x] Error %d\n", address, ret);
@@ -315,7 +315,7 @@ static inline int twl4030_readb(struct twl4030_usb *twl, u8 module, u8 address)
315 u8 data; 315 u8 data;
316 int ret = 0; 316 int ret = 0;
317 317
318 ret = twl4030_i2c_read_u8(module, &data, address); 318 ret = twl_i2c_read_u8(module, &data, address);
319 if (ret >= 0) 319 if (ret >= 0)
320 ret = data; 320 ret = data;
321 else 321 else
@@ -462,7 +462,7 @@ static void twl4030_phy_power(struct twl4030_usb *twl, int on)
462 * SLEEP. We work around this by clearing the bit after usv3v1 462 * SLEEP. We work around this by clearing the bit after usv3v1
463 * is re-activated. This ensures that VUSB3V1 is really active. 463 * is re-activated. This ensures that VUSB3V1 is really active.
464 */ 464 */
465 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, 465 twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0,
466 VUSB_DEDICATED2); 466 VUSB_DEDICATED2);
467 regulator_enable(twl->usb1v5); 467 regulator_enable(twl->usb1v5);
468 pwr &= ~PHY_PWR_PHYPWD; 468 pwr &= ~PHY_PWR_PHYPWD;
@@ -505,44 +505,44 @@ static void twl4030_phy_resume(struct twl4030_usb *twl)
505static int twl4030_usb_ldo_init(struct twl4030_usb *twl) 505static int twl4030_usb_ldo_init(struct twl4030_usb *twl)
506{ 506{
507 /* Enable writing to power configuration registers */ 507 /* Enable writing to power configuration registers */
508 twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0xC0, PROTECT_KEY); 508 twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0xC0, PROTECT_KEY);
509 twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0x0C, PROTECT_KEY); 509 twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0x0C, PROTECT_KEY);
510 510
511 /* put VUSB3V1 LDO in active state */ 511 /* put VUSB3V1 LDO in active state */
512 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2); 512 twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);
513 513
514 /* input to VUSB3V1 LDO is from VBAT, not VBUS */ 514 /* input to VUSB3V1 LDO is from VBAT, not VBUS */
515 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x14, VUSB_DEDICATED1); 515 twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x14, VUSB_DEDICATED1);
516 516
517 /* Initialize 3.1V regulator */ 517 /* Initialize 3.1V regulator */
518 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_DEV_GRP); 518 twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_DEV_GRP);
519 519
520 twl->usb3v1 = regulator_get(twl->dev, "usb3v1"); 520 twl->usb3v1 = regulator_get(twl->dev, "usb3v1");
521 if (IS_ERR(twl->usb3v1)) 521 if (IS_ERR(twl->usb3v1))
522 return -ENODEV; 522 return -ENODEV;
523 523
524 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_TYPE); 524 twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_TYPE);
525 525
526 /* Initialize 1.5V regulator */ 526 /* Initialize 1.5V regulator */
527 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V5_DEV_GRP); 527 twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V5_DEV_GRP);
528 528
529 twl->usb1v5 = regulator_get(twl->dev, "usb1v5"); 529 twl->usb1v5 = regulator_get(twl->dev, "usb1v5");
530 if (IS_ERR(twl->usb1v5)) 530 if (IS_ERR(twl->usb1v5))
531 goto fail1; 531 goto fail1;
532 532
533 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V5_TYPE); 533 twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V5_TYPE);
534 534
535 /* Initialize 1.8V regulator */ 535 /* Initialize 1.8V regulator */
536 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V8_DEV_GRP); 536 twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V8_DEV_GRP);
537 537
538 twl->usb1v8 = regulator_get(twl->dev, "usb1v8"); 538 twl->usb1v8 = regulator_get(twl->dev, "usb1v8");
539 if (IS_ERR(twl->usb1v8)) 539 if (IS_ERR(twl->usb1v8))
540 goto fail2; 540 goto fail2;
541 541
542 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V8_TYPE); 542 twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V8_TYPE);
543 543
544 /* disable access to power configuration registers */ 544 /* disable access to power configuration registers */
545 twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, PROTECT_KEY); 545 twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, PROTECT_KEY);
546 546
547 return 0; 547 return 0;
548 548
diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c
index ad05da5ba3c7..4c10edecfb66 100644
--- a/drivers/video/backlight/adp5520_bl.c
+++ b/drivers/video/backlight/adp5520_bl.c
@@ -15,7 +15,7 @@
15 15
16struct adp5520_bl { 16struct adp5520_bl {
17 struct device *master; 17 struct device *master;
18 struct adp5520_backlight_platfrom_data *pdata; 18 struct adp5520_backlight_platform_data *pdata;
19 struct mutex lock; 19 struct mutex lock;
20 unsigned long cached_daylight_max; 20 unsigned long cached_daylight_max;
21 int id; 21 int id;
@@ -31,29 +31,30 @@ static int adp5520_bl_set(struct backlight_device *bl, int brightness)
31 if (data->pdata->en_ambl_sens) { 31 if (data->pdata->en_ambl_sens) {
32 if ((brightness > 0) && (brightness < ADP5020_MAX_BRIGHTNESS)) { 32 if ((brightness > 0) && (brightness < ADP5020_MAX_BRIGHTNESS)) {
33 /* Disable Ambient Light auto adjust */ 33 /* Disable Ambient Light auto adjust */
34 ret |= adp5520_clr_bits(master, BL_CONTROL, 34 ret |= adp5520_clr_bits(master, ADP5520_BL_CONTROL,
35 BL_AUTO_ADJ); 35 ADP5520_BL_AUTO_ADJ);
36 ret |= adp5520_write(master, DAYLIGHT_MAX, brightness); 36 ret |= adp5520_write(master, ADP5520_DAYLIGHT_MAX,
37 brightness);
37 } else { 38 } else {
38 /* 39 /*
39 * MAX_BRIGHTNESS -> Enable Ambient Light auto adjust 40 * MAX_BRIGHTNESS -> Enable Ambient Light auto adjust
40 * restore daylight l3 sysfs brightness 41 * restore daylight l3 sysfs brightness
41 */ 42 */
42 ret |= adp5520_write(master, DAYLIGHT_MAX, 43 ret |= adp5520_write(master, ADP5520_DAYLIGHT_MAX,
43 data->cached_daylight_max); 44 data->cached_daylight_max);
44 ret |= adp5520_set_bits(master, BL_CONTROL, 45 ret |= adp5520_set_bits(master, ADP5520_BL_CONTROL,
45 BL_AUTO_ADJ); 46 ADP5520_BL_AUTO_ADJ);
46 } 47 }
47 } else { 48 } else {
48 ret |= adp5520_write(master, DAYLIGHT_MAX, brightness); 49 ret |= adp5520_write(master, ADP5520_DAYLIGHT_MAX, brightness);
49 } 50 }
50 51
51 if (data->current_brightness && brightness == 0) 52 if (data->current_brightness && brightness == 0)
52 ret |= adp5520_set_bits(master, 53 ret |= adp5520_set_bits(master,
53 MODE_STATUS, DIM_EN); 54 ADP5520_MODE_STATUS, ADP5520_DIM_EN);
54 else if (data->current_brightness == 0 && brightness) 55 else if (data->current_brightness == 0 && brightness)
55 ret |= adp5520_clr_bits(master, 56 ret |= adp5520_clr_bits(master,
56 MODE_STATUS, DIM_EN); 57 ADP5520_MODE_STATUS, ADP5520_DIM_EN);
57 58
58 if (!ret) 59 if (!ret)
59 data->current_brightness = brightness; 60 data->current_brightness = brightness;
@@ -79,7 +80,7 @@ static int adp5520_bl_get_brightness(struct backlight_device *bl)
79 int error; 80 int error;
80 uint8_t reg_val; 81 uint8_t reg_val;
81 82
82 error = adp5520_read(data->master, BL_VALUE, &reg_val); 83 error = adp5520_read(data->master, ADP5520_BL_VALUE, &reg_val);
83 84
84 return error ? data->current_brightness : reg_val; 85 return error ? data->current_brightness : reg_val;
85} 86}
@@ -93,33 +94,46 @@ static int adp5520_bl_setup(struct backlight_device *bl)
93{ 94{
94 struct adp5520_bl *data = bl_get_data(bl); 95 struct adp5520_bl *data = bl_get_data(bl);
95 struct device *master = data->master; 96 struct device *master = data->master;
96 struct adp5520_backlight_platfrom_data *pdata = data->pdata; 97 struct adp5520_backlight_platform_data *pdata = data->pdata;
97 int ret = 0; 98 int ret = 0;
98 99
99 ret |= adp5520_write(master, DAYLIGHT_MAX, pdata->l1_daylight_max); 100 ret |= adp5520_write(master, ADP5520_DAYLIGHT_MAX,
100 ret |= adp5520_write(master, DAYLIGHT_DIM, pdata->l1_daylight_dim); 101 pdata->l1_daylight_max);
102 ret |= adp5520_write(master, ADP5520_DAYLIGHT_DIM,
103 pdata->l1_daylight_dim);
101 104
102 if (pdata->en_ambl_sens) { 105 if (pdata->en_ambl_sens) {
103 data->cached_daylight_max = pdata->l1_daylight_max; 106 data->cached_daylight_max = pdata->l1_daylight_max;
104 ret |= adp5520_write(master, OFFICE_MAX, pdata->l2_office_max); 107 ret |= adp5520_write(master, ADP5520_OFFICE_MAX,
105 ret |= adp5520_write(master, OFFICE_DIM, pdata->l2_office_dim); 108 pdata->l2_office_max);
106 ret |= adp5520_write(master, DARK_MAX, pdata->l3_dark_max); 109 ret |= adp5520_write(master, ADP5520_OFFICE_DIM,
107 ret |= adp5520_write(master, DARK_DIM, pdata->l3_dark_dim); 110 pdata->l2_office_dim);
108 ret |= adp5520_write(master, L2_TRIP, pdata->l2_trip); 111 ret |= adp5520_write(master, ADP5520_DARK_MAX,
109 ret |= adp5520_write(master, L2_HYS, pdata->l2_hyst); 112 pdata->l3_dark_max);
110 ret |= adp5520_write(master, L3_TRIP, pdata->l3_trip); 113 ret |= adp5520_write(master, ADP5520_DARK_DIM,
111 ret |= adp5520_write(master, L3_HYS, pdata->l3_hyst); 114 pdata->l3_dark_dim);
112 ret |= adp5520_write(master, ALS_CMPR_CFG, 115 ret |= adp5520_write(master, ADP5520_L2_TRIP,
113 ALS_CMPR_CFG_VAL(pdata->abml_filt, L3_EN)); 116 pdata->l2_trip);
117 ret |= adp5520_write(master, ADP5520_L2_HYS,
118 pdata->l2_hyst);
119 ret |= adp5520_write(master, ADP5520_L3_TRIP,
120 pdata->l3_trip);
121 ret |= adp5520_write(master, ADP5520_L3_HYS,
122 pdata->l3_hyst);
123 ret |= adp5520_write(master, ADP5520_ALS_CMPR_CFG,
124 ALS_CMPR_CFG_VAL(pdata->abml_filt,
125 ADP5520_L3_EN));
114 } 126 }
115 127
116 ret |= adp5520_write(master, BL_CONTROL, 128 ret |= adp5520_write(master, ADP5520_BL_CONTROL,
117 BL_CTRL_VAL(pdata->fade_led_law, pdata->en_ambl_sens)); 129 BL_CTRL_VAL(pdata->fade_led_law,
130 pdata->en_ambl_sens));
118 131
119 ret |= adp5520_write(master, BL_FADE, FADE_VAL(pdata->fade_in, 132 ret |= adp5520_write(master, ADP5520_BL_FADE, FADE_VAL(pdata->fade_in,
120 pdata->fade_out)); 133 pdata->fade_out));
121 134
122 ret |= adp5520_set_bits(master, MODE_STATUS, BL_EN | DIM_EN); 135 ret |= adp5520_set_bits(master, ADP5520_MODE_STATUS,
136 ADP5520_BL_EN | ADP5520_DIM_EN);
123 137
124 return ret; 138 return ret;
125} 139}
@@ -156,29 +170,31 @@ static ssize_t adp5520_store(struct device *dev, const char *buf,
156} 170}
157 171
158static ssize_t adp5520_bl_dark_max_show(struct device *dev, 172static ssize_t adp5520_bl_dark_max_show(struct device *dev,
159 struct device_attribute *attr, char *buf) 173 struct device_attribute *attr, char *buf)
160{ 174{
161 return adp5520_show(dev, buf, DARK_MAX); 175 return adp5520_show(dev, buf, ADP5520_DARK_MAX);
162} 176}
163 177
164static ssize_t adp5520_bl_dark_max_store(struct device *dev, 178static ssize_t adp5520_bl_dark_max_store(struct device *dev,
165 struct device_attribute *attr, const char *buf, size_t count) 179 struct device_attribute *attr,
180 const char *buf, size_t count)
166{ 181{
167 return adp5520_store(dev, buf, count, DARK_MAX); 182 return adp5520_store(dev, buf, count, ADP5520_DARK_MAX);
168} 183}
169static DEVICE_ATTR(dark_max, 0664, adp5520_bl_dark_max_show, 184static DEVICE_ATTR(dark_max, 0664, adp5520_bl_dark_max_show,
170 adp5520_bl_dark_max_store); 185 adp5520_bl_dark_max_store);
171 186
172static ssize_t adp5520_bl_office_max_show(struct device *dev, 187static ssize_t adp5520_bl_office_max_show(struct device *dev,
173 struct device_attribute *attr, char *buf) 188 struct device_attribute *attr, char *buf)
174{ 189{
175 return adp5520_show(dev, buf, OFFICE_MAX); 190 return adp5520_show(dev, buf, ADP5520_OFFICE_MAX);
176} 191}
177 192
178static ssize_t adp5520_bl_office_max_store(struct device *dev, 193static ssize_t adp5520_bl_office_max_store(struct device *dev,
179 struct device_attribute *attr, const char *buf, size_t count) 194 struct device_attribute *attr,
195 const char *buf, size_t count)
180{ 196{
181 return adp5520_store(dev, buf, count, OFFICE_MAX); 197 return adp5520_store(dev, buf, count, ADP5520_OFFICE_MAX);
182} 198}
183static DEVICE_ATTR(office_max, 0664, adp5520_bl_office_max_show, 199static DEVICE_ATTR(office_max, 0664, adp5520_bl_office_max_show,
184 adp5520_bl_office_max_store); 200 adp5520_bl_office_max_store);
@@ -186,16 +202,17 @@ static DEVICE_ATTR(office_max, 0664, adp5520_bl_office_max_show,
186static ssize_t adp5520_bl_daylight_max_show(struct device *dev, 202static ssize_t adp5520_bl_daylight_max_show(struct device *dev,
187 struct device_attribute *attr, char *buf) 203 struct device_attribute *attr, char *buf)
188{ 204{
189 return adp5520_show(dev, buf, DAYLIGHT_MAX); 205 return adp5520_show(dev, buf, ADP5520_DAYLIGHT_MAX);
190} 206}
191 207
192static ssize_t adp5520_bl_daylight_max_store(struct device *dev, 208static ssize_t adp5520_bl_daylight_max_store(struct device *dev,
193 struct device_attribute *attr, const char *buf, size_t count) 209 struct device_attribute *attr,
210 const char *buf, size_t count)
194{ 211{
195 struct adp5520_bl *data = dev_get_drvdata(dev); 212 struct adp5520_bl *data = dev_get_drvdata(dev);
196 213
197 strict_strtoul(buf, 10, &data->cached_daylight_max); 214 strict_strtoul(buf, 10, &data->cached_daylight_max);
198 return adp5520_store(dev, buf, count, DAYLIGHT_MAX); 215 return adp5520_store(dev, buf, count, ADP5520_DAYLIGHT_MAX);
199} 216}
200static DEVICE_ATTR(daylight_max, 0664, adp5520_bl_daylight_max_show, 217static DEVICE_ATTR(daylight_max, 0664, adp5520_bl_daylight_max_show,
201 adp5520_bl_daylight_max_store); 218 adp5520_bl_daylight_max_store);
@@ -203,14 +220,14 @@ static DEVICE_ATTR(daylight_max, 0664, adp5520_bl_daylight_max_show,
203static ssize_t adp5520_bl_dark_dim_show(struct device *dev, 220static ssize_t adp5520_bl_dark_dim_show(struct device *dev,
204 struct device_attribute *attr, char *buf) 221 struct device_attribute *attr, char *buf)
205{ 222{
206 return adp5520_show(dev, buf, DARK_DIM); 223 return adp5520_show(dev, buf, ADP5520_DARK_DIM);
207} 224}
208 225
209static ssize_t adp5520_bl_dark_dim_store(struct device *dev, 226static ssize_t adp5520_bl_dark_dim_store(struct device *dev,
210 struct device_attribute *attr, 227 struct device_attribute *attr,
211 const char *buf, size_t count) 228 const char *buf, size_t count)
212{ 229{
213 return adp5520_store(dev, buf, count, DARK_DIM); 230 return adp5520_store(dev, buf, count, ADP5520_DARK_DIM);
214} 231}
215static DEVICE_ATTR(dark_dim, 0664, adp5520_bl_dark_dim_show, 232static DEVICE_ATTR(dark_dim, 0664, adp5520_bl_dark_dim_show,
216 adp5520_bl_dark_dim_store); 233 adp5520_bl_dark_dim_store);
@@ -218,29 +235,29 @@ static DEVICE_ATTR(dark_dim, 0664, adp5520_bl_dark_dim_show,
218static ssize_t adp5520_bl_office_dim_show(struct device *dev, 235static ssize_t adp5520_bl_office_dim_show(struct device *dev,
219 struct device_attribute *attr, char *buf) 236 struct device_attribute *attr, char *buf)
220{ 237{
221 return adp5520_show(dev, buf, OFFICE_DIM); 238 return adp5520_show(dev, buf, ADP5520_OFFICE_DIM);
222} 239}
223 240
224static ssize_t adp5520_bl_office_dim_store(struct device *dev, 241static ssize_t adp5520_bl_office_dim_store(struct device *dev,
225 struct device_attribute *attr, 242 struct device_attribute *attr,
226 const char *buf, size_t count) 243 const char *buf, size_t count)
227{ 244{
228 return adp5520_store(dev, buf, count, OFFICE_DIM); 245 return adp5520_store(dev, buf, count, ADP5520_OFFICE_DIM);
229} 246}
230static DEVICE_ATTR(office_dim, 0664, adp5520_bl_office_dim_show, 247static DEVICE_ATTR(office_dim, 0664, adp5520_bl_office_dim_show,
231 adp5520_bl_office_dim_store); 248 adp5520_bl_office_dim_store);
232 249
233static ssize_t adp5520_bl_daylight_dim_show(struct device *dev, 250static ssize_t adp5520_bl_daylight_dim_show(struct device *dev,
234 struct device_attribute *attr, char *buf) 251 struct device_attribute *attr, char *buf)
235{ 252{
236 return adp5520_show(dev, buf, DAYLIGHT_DIM); 253 return adp5520_show(dev, buf, ADP5520_DAYLIGHT_DIM);
237} 254}
238 255
239static ssize_t adp5520_bl_daylight_dim_store(struct device *dev, 256static ssize_t adp5520_bl_daylight_dim_store(struct device *dev,
240 struct device_attribute *attr, 257 struct device_attribute *attr,
241 const char *buf, size_t count) 258 const char *buf, size_t count)
242{ 259{
243 return adp5520_store(dev, buf, count, DAYLIGHT_DIM); 260 return adp5520_store(dev, buf, count, ADP5520_DAYLIGHT_DIM);
244} 261}
245static DEVICE_ATTR(daylight_dim, 0664, adp5520_bl_daylight_dim_show, 262static DEVICE_ATTR(daylight_dim, 0664, adp5520_bl_daylight_dim_show,
246 adp5520_bl_daylight_dim_store); 263 adp5520_bl_daylight_dim_store);
@@ -316,7 +333,7 @@ static int __devexit adp5520_bl_remove(struct platform_device *pdev)
316 struct backlight_device *bl = platform_get_drvdata(pdev); 333 struct backlight_device *bl = platform_get_drvdata(pdev);
317 struct adp5520_bl *data = bl_get_data(bl); 334 struct adp5520_bl *data = bl_get_data(bl);
318 335
319 adp5520_clr_bits(data->master, MODE_STATUS, BL_EN); 336 adp5520_clr_bits(data->master, ADP5520_MODE_STATUS, ADP5520_BL_EN);
320 337
321 if (data->pdata->en_ambl_sens) 338 if (data->pdata->en_ambl_sens)
322 sysfs_remove_group(&bl->dev.kobj, 339 sysfs_remove_group(&bl->dev.kobj,
diff --git a/drivers/video/omap/lcd_2430sdp.c b/drivers/video/omap/lcd_2430sdp.c
index 760645d9dbb6..e3eccc9af78e 100644
--- a/drivers/video/omap/lcd_2430sdp.c
+++ b/drivers/video/omap/lcd_2430sdp.c
@@ -25,7 +25,7 @@
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/gpio.h> 27#include <linux/gpio.h>
28#include <linux/i2c/twl4030.h> 28#include <linux/i2c/twl.h>
29 29
30#include <plat/mux.h> 30#include <plat/mux.h>
31#include <asm/mach-types.h> 31#include <asm/mach-types.h>
@@ -52,7 +52,7 @@ static unsigned enable_gpio;
52#define TWL4030_VPLL2_DEV_GRP 0x33 52#define TWL4030_VPLL2_DEV_GRP 0x33
53#define TWL4030_VPLL2_DEDICATED 0x36 53#define TWL4030_VPLL2_DEDICATED 0x36
54 54
55#define t2_out(c, r, v) twl4030_i2c_write_u8(c, r, v) 55#define t2_out(c, r, v) twl_i2c_write_u8(c, r, v)
56 56
57 57
58static int sdp2430_panel_init(struct lcd_panel *panel, 58static int sdp2430_panel_init(struct lcd_panel *panel,
diff --git a/drivers/watchdog/twl4030_wdt.c b/drivers/watchdog/twl4030_wdt.c
index cb46556f2973..8162a40d1522 100644
--- a/drivers/watchdog/twl4030_wdt.c
+++ b/drivers/watchdog/twl4030_wdt.c
@@ -26,7 +26,7 @@
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/miscdevice.h> 27#include <linux/miscdevice.h>
28#include <linux/uaccess.h> 28#include <linux/uaccess.h>
29#include <linux/i2c/twl4030.h> 29#include <linux/i2c/twl.h>
30 30
31#define TWL4030_WATCHDOG_CFG_REG_OFFS 0x3 31#define TWL4030_WATCHDOG_CFG_REG_OFFS 0x3
32 32
@@ -48,7 +48,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
48 48
49static int twl4030_wdt_write(unsigned char val) 49static int twl4030_wdt_write(unsigned char val)
50{ 50{
51 return twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, val, 51 return twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, val,
52 TWL4030_WATCHDOG_CFG_REG_OFFS); 52 TWL4030_WATCHDOG_CFG_REG_OFFS);
53} 53}
54 54
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 278020d2449c..14cbc831422a 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -979,24 +979,6 @@ COMPATIBLE_IOCTL(FIGETBSZ)
979/* 'X' - originally XFS but some now in the VFS */ 979/* 'X' - originally XFS but some now in the VFS */
980COMPATIBLE_IOCTL(FIFREEZE) 980COMPATIBLE_IOCTL(FIFREEZE)
981COMPATIBLE_IOCTL(FITHAW) 981COMPATIBLE_IOCTL(FITHAW)
982/* RAID */
983COMPATIBLE_IOCTL(RAID_VERSION)
984COMPATIBLE_IOCTL(GET_ARRAY_INFO)
985COMPATIBLE_IOCTL(GET_DISK_INFO)
986COMPATIBLE_IOCTL(PRINT_RAID_DEBUG)
987COMPATIBLE_IOCTL(RAID_AUTORUN)
988COMPATIBLE_IOCTL(CLEAR_ARRAY)
989COMPATIBLE_IOCTL(ADD_NEW_DISK)
990COMPATIBLE_IOCTL(SET_ARRAY_INFO)
991COMPATIBLE_IOCTL(SET_DISK_INFO)
992COMPATIBLE_IOCTL(WRITE_RAID_INFO)
993COMPATIBLE_IOCTL(UNPROTECT_ARRAY)
994COMPATIBLE_IOCTL(PROTECT_ARRAY)
995COMPATIBLE_IOCTL(RUN_ARRAY)
996COMPATIBLE_IOCTL(STOP_ARRAY)
997COMPATIBLE_IOCTL(STOP_ARRAY_RO)
998COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
999COMPATIBLE_IOCTL(GET_BITMAP_FILE)
1000COMPATIBLE_IOCTL(KDGETKEYCODE) 982COMPATIBLE_IOCTL(KDGETKEYCODE)
1001COMPATIBLE_IOCTL(KDSETKEYCODE) 983COMPATIBLE_IOCTL(KDSETKEYCODE)
1002COMPATIBLE_IOCTL(KDGKBTYPE) 984COMPATIBLE_IOCTL(KDGKBTYPE)
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index c1e19d5b5985..b1fd3daadc9c 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -3955,7 +3955,7 @@ static void ext4_mb_group_or_file(struct ext4_allocation_context *ac)
3955 * per cpu locality group is to reduce the contention between block 3955 * per cpu locality group is to reduce the contention between block
3956 * request from multiple CPUs. 3956 * request from multiple CPUs.
3957 */ 3957 */
3958 ac->ac_lg = per_cpu_ptr(sbi->s_locality_groups, raw_smp_processor_id()); 3958 ac->ac_lg = __this_cpu_ptr(sbi->s_locality_groups);
3959 3959
3960 /* we're going to use group allocation */ 3960 /* we're going to use group allocation */
3961 ac->ac_flags |= EXT4_MB_HINT_GROUP_ALLOC; 3961 ac->ac_flags |= EXT4_MB_HINT_GROUP_ALLOC;
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index 293fa0528a6e..73ab220354df 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -78,11 +78,6 @@ nfs4_callback_svc(void *vrqstp)
78 78
79 set_freezable(); 79 set_freezable();
80 80
81 /*
82 * FIXME: do we really need to run this under the BKL? If so, please
83 * add a comment about what it's intended to protect.
84 */
85 lock_kernel();
86 while (!kthread_should_stop()) { 81 while (!kthread_should_stop()) {
87 /* 82 /*
88 * Listen for a request on the socket 83 * Listen for a request on the socket
@@ -104,7 +99,6 @@ nfs4_callback_svc(void *vrqstp)
104 preverr = err; 99 preverr = err;
105 svc_process(rqstp); 100 svc_process(rqstp);
106 } 101 }
107 unlock_kernel();
108 return 0; 102 return 0;
109} 103}
110 104
@@ -160,11 +154,6 @@ nfs41_callback_svc(void *vrqstp)
160 154
161 set_freezable(); 155 set_freezable();
162 156
163 /*
164 * FIXME: do we really need to run this under the BKL? If so, please
165 * add a comment about what it's intended to protect.
166 */
167 lock_kernel();
168 while (!kthread_should_stop()) { 157 while (!kthread_should_stop()) {
169 prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_INTERRUPTIBLE); 158 prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_INTERRUPTIBLE);
170 spin_lock_bh(&serv->sv_cb_lock); 159 spin_lock_bh(&serv->sv_cb_lock);
@@ -183,7 +172,6 @@ nfs41_callback_svc(void *vrqstp)
183 } 172 }
184 finish_wait(&serv->sv_cb_waitq, &wq); 173 finish_wait(&serv->sv_cb_waitq, &wq);
185 } 174 }
186 unlock_kernel();
187 return 0; 175 return 0;
188} 176}
189 177
@@ -397,6 +385,7 @@ static int nfs_callback_authenticate(struct svc_rqst *rqstp)
397 */ 385 */
398static struct svc_version *nfs4_callback_version[] = { 386static struct svc_version *nfs4_callback_version[] = {
399 [1] = &nfs4_callback_version1, 387 [1] = &nfs4_callback_version1,
388 [4] = &nfs4_callback_version4,
400}; 389};
401 390
402static struct svc_stat nfs4_callback_stats; 391static struct svc_stat nfs4_callback_stats;
diff --git a/fs/nfs/callback.h b/fs/nfs/callback.h
index 07baa8254ca1..d4036be0b589 100644
--- a/fs/nfs/callback.h
+++ b/fs/nfs/callback.h
@@ -106,6 +106,19 @@ struct cb_sequenceres {
106extern unsigned nfs4_callback_sequence(struct cb_sequenceargs *args, 106extern unsigned nfs4_callback_sequence(struct cb_sequenceargs *args,
107 struct cb_sequenceres *res); 107 struct cb_sequenceres *res);
108 108
109extern int nfs41_validate_delegation_stateid(struct nfs_delegation *delegation,
110 const nfs4_stateid *stateid);
111
112#define RCA4_TYPE_MASK_RDATA_DLG 0
113#define RCA4_TYPE_MASK_WDATA_DLG 1
114
115struct cb_recallanyargs {
116 struct sockaddr *craa_addr;
117 uint32_t craa_objs_to_keep;
118 uint32_t craa_type_mask;
119};
120
121extern unsigned nfs4_callback_recallany(struct cb_recallanyargs *args, void *dummy);
109#endif /* CONFIG_NFS_V4_1 */ 122#endif /* CONFIG_NFS_V4_1 */
110 123
111extern __be32 nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getattrres *res); 124extern __be32 nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getattrres *res);
@@ -114,8 +127,9 @@ extern __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy);
114#ifdef CONFIG_NFS_V4 127#ifdef CONFIG_NFS_V4
115extern int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt); 128extern int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt);
116extern void nfs_callback_down(int minorversion); 129extern void nfs_callback_down(int minorversion);
130extern int nfs4_validate_delegation_stateid(struct nfs_delegation *delegation,
131 const nfs4_stateid *stateid);
117#endif /* CONFIG_NFS_V4 */ 132#endif /* CONFIG_NFS_V4 */
118
119/* 133/*
120 * nfs41: Callbacks are expected to not cause substantial latency, 134 * nfs41: Callbacks are expected to not cause substantial latency,
121 * so we limit their concurrency to 1 by setting up the maximum number 135 * so we limit their concurrency to 1 by setting up the maximum number
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index b7da1f54da68..defa9b4c470e 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -61,6 +61,16 @@ out:
61 return res->status; 61 return res->status;
62} 62}
63 63
64static int (*nfs_validate_delegation_stateid(struct nfs_client *clp))(struct nfs_delegation *, const nfs4_stateid *)
65{
66#if defined(CONFIG_NFS_V4_1)
67 if (clp->cl_minorversion > 0)
68 return nfs41_validate_delegation_stateid;
69#endif
70 return nfs4_validate_delegation_stateid;
71}
72
73
64__be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy) 74__be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy)
65{ 75{
66 struct nfs_client *clp; 76 struct nfs_client *clp;
@@ -81,7 +91,8 @@ __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy)
81 inode = nfs_delegation_find_inode(clp, &args->fh); 91 inode = nfs_delegation_find_inode(clp, &args->fh);
82 if (inode != NULL) { 92 if (inode != NULL) {
83 /* Set up a helper thread to actually return the delegation */ 93 /* Set up a helper thread to actually return the delegation */
84 switch(nfs_async_inode_return_delegation(inode, &args->stateid)) { 94 switch (nfs_async_inode_return_delegation(inode, &args->stateid,
95 nfs_validate_delegation_stateid(clp))) {
85 case 0: 96 case 0:
86 res = 0; 97 res = 0;
87 break; 98 break;
@@ -102,8 +113,31 @@ out:
102 return res; 113 return res;
103} 114}
104 115
116int nfs4_validate_delegation_stateid(struct nfs_delegation *delegation, const nfs4_stateid *stateid)
117{
118 if (delegation == NULL || memcmp(delegation->stateid.data, stateid->data,
119 sizeof(delegation->stateid.data)) != 0)
120 return 0;
121 return 1;
122}
123
105#if defined(CONFIG_NFS_V4_1) 124#if defined(CONFIG_NFS_V4_1)
106 125
126int nfs41_validate_delegation_stateid(struct nfs_delegation *delegation, const nfs4_stateid *stateid)
127{
128 if (delegation == NULL)
129 return 0;
130
131 /* seqid is 4-bytes long */
132 if (((u32 *) &stateid->data)[0] != 0)
133 return 0;
134 if (memcmp(&delegation->stateid.data[4], &stateid->data[4],
135 sizeof(stateid->data)-4))
136 return 0;
137
138 return 1;
139}
140
107/* 141/*
108 * Validate the sequenceID sent by the server. 142 * Validate the sequenceID sent by the server.
109 * Return success if the sequenceID is one more than what we last saw on 143 * Return success if the sequenceID is one more than what we last saw on
@@ -227,4 +261,32 @@ out:
227 return res->csr_status; 261 return res->csr_status;
228} 262}
229 263
264unsigned nfs4_callback_recallany(struct cb_recallanyargs *args, void *dummy)
265{
266 struct nfs_client *clp;
267 int status;
268 fmode_t flags = 0;
269
270 status = htonl(NFS4ERR_OP_NOT_IN_SESSION);
271 clp = nfs_find_client(args->craa_addr, 4);
272 if (clp == NULL)
273 goto out;
274
275 dprintk("NFS: RECALL_ANY callback request from %s\n",
276 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
277
278 if (test_bit(RCA4_TYPE_MASK_RDATA_DLG, (const unsigned long *)
279 &args->craa_type_mask))
280 flags = FMODE_READ;
281 if (test_bit(RCA4_TYPE_MASK_WDATA_DLG, (const unsigned long *)
282 &args->craa_type_mask))
283 flags |= FMODE_WRITE;
284
285 if (flags)
286 nfs_expire_all_delegation_types(clp, flags);
287 status = htonl(NFS4_OK);
288out:
289 dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
290 return status;
291}
230#endif /* CONFIG_NFS_V4_1 */ 292#endif /* CONFIG_NFS_V4_1 */
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
index 76b0aa0f73bf..8e1a2511c8be 100644
--- a/fs/nfs/callback_xdr.c
+++ b/fs/nfs/callback_xdr.c
@@ -23,6 +23,7 @@
23#if defined(CONFIG_NFS_V4_1) 23#if defined(CONFIG_NFS_V4_1)
24#define CB_OP_SEQUENCE_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ + \ 24#define CB_OP_SEQUENCE_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ + \
25 4 + 1 + 3) 25 4 + 1 + 3)
26#define CB_OP_RECALLANY_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ)
26#endif /* CONFIG_NFS_V4_1 */ 27#endif /* CONFIG_NFS_V4_1 */
27 28
28#define NFSDBG_FACILITY NFSDBG_CALLBACK 29#define NFSDBG_FACILITY NFSDBG_CALLBACK
@@ -326,6 +327,25 @@ out_free:
326 goto out; 327 goto out;
327} 328}
328 329
330static unsigned decode_recallany_args(struct svc_rqst *rqstp,
331 struct xdr_stream *xdr,
332 struct cb_recallanyargs *args)
333{
334 uint32_t *p;
335
336 args->craa_addr = svc_addr(rqstp);
337 p = read_buf(xdr, 4);
338 if (unlikely(p == NULL))
339 return htonl(NFS4ERR_BADXDR);
340 args->craa_objs_to_keep = ntohl(*p++);
341 p = read_buf(xdr, 4);
342 if (unlikely(p == NULL))
343 return htonl(NFS4ERR_BADXDR);
344 args->craa_type_mask = ntohl(*p);
345
346 return 0;
347}
348
329#endif /* CONFIG_NFS_V4_1 */ 349#endif /* CONFIG_NFS_V4_1 */
330 350
331static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) 351static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
@@ -533,6 +553,7 @@ preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op)
533 case OP_CB_GETATTR: 553 case OP_CB_GETATTR:
534 case OP_CB_RECALL: 554 case OP_CB_RECALL:
535 case OP_CB_SEQUENCE: 555 case OP_CB_SEQUENCE:
556 case OP_CB_RECALL_ANY:
536 *op = &callback_ops[op_nr]; 557 *op = &callback_ops[op_nr];
537 break; 558 break;
538 559
@@ -540,7 +561,6 @@ preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op)
540 case OP_CB_NOTIFY_DEVICEID: 561 case OP_CB_NOTIFY_DEVICEID:
541 case OP_CB_NOTIFY: 562 case OP_CB_NOTIFY:
542 case OP_CB_PUSH_DELEG: 563 case OP_CB_PUSH_DELEG:
543 case OP_CB_RECALL_ANY:
544 case OP_CB_RECALLABLE_OBJ_AVAIL: 564 case OP_CB_RECALLABLE_OBJ_AVAIL:
545 case OP_CB_RECALL_SLOT: 565 case OP_CB_RECALL_SLOT:
546 case OP_CB_WANTS_CANCELLED: 566 case OP_CB_WANTS_CANCELLED:
@@ -688,6 +708,11 @@ static struct callback_op callback_ops[] = {
688 .encode_res = (callback_encode_res_t)encode_cb_sequence_res, 708 .encode_res = (callback_encode_res_t)encode_cb_sequence_res,
689 .res_maxsize = CB_OP_SEQUENCE_RES_MAXSZ, 709 .res_maxsize = CB_OP_SEQUENCE_RES_MAXSZ,
690 }, 710 },
711 [OP_CB_RECALL_ANY] = {
712 .process_op = (callback_process_op_t)nfs4_callback_recallany,
713 .decode_args = (callback_decode_arg_t)decode_recallany_args,
714 .res_maxsize = CB_OP_RECALLANY_RES_MAXSZ,
715 },
691#endif /* CONFIG_NFS_V4_1 */ 716#endif /* CONFIG_NFS_V4_1 */
692}; 717};
693 718
@@ -718,3 +743,10 @@ struct svc_version nfs4_callback_version1 = {
718 .vs_dispatch = NULL, 743 .vs_dispatch = NULL,
719}; 744};
720 745
746struct svc_version nfs4_callback_version4 = {
747 .vs_vers = 4,
748 .vs_nproc = ARRAY_SIZE(nfs4_callback_procedures1),
749 .vs_proc = nfs4_callback_procedures1,
750 .vs_xdrsize = NFS4_CALLBACK_XDRSIZE,
751 .vs_dispatch = NULL,
752};
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 99ea196f071f..ee77713ce68b 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1260,10 +1260,20 @@ error:
1260static void nfs4_session_set_rwsize(struct nfs_server *server) 1260static void nfs4_session_set_rwsize(struct nfs_server *server)
1261{ 1261{
1262#ifdef CONFIG_NFS_V4_1 1262#ifdef CONFIG_NFS_V4_1
1263 struct nfs4_session *sess;
1264 u32 server_resp_sz;
1265 u32 server_rqst_sz;
1266
1263 if (!nfs4_has_session(server->nfs_client)) 1267 if (!nfs4_has_session(server->nfs_client))
1264 return; 1268 return;
1265 server->rsize = server->nfs_client->cl_session->fc_attrs.max_resp_sz; 1269 sess = server->nfs_client->cl_session;
1266 server->wsize = server->nfs_client->cl_session->fc_attrs.max_rqst_sz; 1270 server_resp_sz = sess->fc_attrs.max_resp_sz - nfs41_maxread_overhead;
1271 server_rqst_sz = sess->fc_attrs.max_rqst_sz - nfs41_maxwrite_overhead;
1272
1273 if (server->rsize > server_resp_sz)
1274 server->rsize = server_resp_sz;
1275 if (server->wsize > server_rqst_sz)
1276 server->wsize = server_rqst_sz;
1267#endif /* CONFIG_NFS_V4_1 */ 1277#endif /* CONFIG_NFS_V4_1 */
1268} 1278}
1269 1279
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 6dd48a4405b4..2563bebc4c67 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -92,7 +92,7 @@ out:
92 return status; 92 return status;
93} 93}
94 94
95static void nfs_delegation_claim_opens(struct inode *inode, const nfs4_stateid *stateid) 95static int nfs_delegation_claim_opens(struct inode *inode, const nfs4_stateid *stateid)
96{ 96{
97 struct nfs_inode *nfsi = NFS_I(inode); 97 struct nfs_inode *nfsi = NFS_I(inode);
98 struct nfs_open_context *ctx; 98 struct nfs_open_context *ctx;
@@ -116,10 +116,11 @@ again:
116 err = nfs_delegation_claim_locks(ctx, state); 116 err = nfs_delegation_claim_locks(ctx, state);
117 put_nfs_open_context(ctx); 117 put_nfs_open_context(ctx);
118 if (err != 0) 118 if (err != 0)
119 return; 119 return err;
120 goto again; 120 goto again;
121 } 121 }
122 spin_unlock(&inode->i_lock); 122 spin_unlock(&inode->i_lock);
123 return 0;
123} 124}
124 125
125/* 126/*
@@ -261,30 +262,34 @@ static void nfs_msync_inode(struct inode *inode)
261/* 262/*
262 * Basic procedure for returning a delegation to the server 263 * Basic procedure for returning a delegation to the server
263 */ 264 */
264static int __nfs_inode_return_delegation(struct inode *inode, struct nfs_delegation *delegation) 265static int __nfs_inode_return_delegation(struct inode *inode, struct nfs_delegation *delegation, int issync)
265{ 266{
266 struct nfs_inode *nfsi = NFS_I(inode); 267 struct nfs_inode *nfsi = NFS_I(inode);
268 int err;
267 269
268 nfs_msync_inode(inode);
269 /* 270 /*
270 * Guard against new delegated open/lock/unlock calls and against 271 * Guard against new delegated open/lock/unlock calls and against
271 * state recovery 272 * state recovery
272 */ 273 */
273 down_write(&nfsi->rwsem); 274 down_write(&nfsi->rwsem);
274 nfs_delegation_claim_opens(inode, &delegation->stateid); 275 err = nfs_delegation_claim_opens(inode, &delegation->stateid);
275 up_write(&nfsi->rwsem); 276 up_write(&nfsi->rwsem);
276 nfs_msync_inode(inode); 277 if (err)
278 goto out;
277 279
278 return nfs_do_return_delegation(inode, delegation, 1); 280 err = nfs_do_return_delegation(inode, delegation, issync);
281out:
282 return err;
279} 283}
280 284
281/* 285/*
282 * Return all delegations that have been marked for return 286 * Return all delegations that have been marked for return
283 */ 287 */
284void nfs_client_return_marked_delegations(struct nfs_client *clp) 288int nfs_client_return_marked_delegations(struct nfs_client *clp)
285{ 289{
286 struct nfs_delegation *delegation; 290 struct nfs_delegation *delegation;
287 struct inode *inode; 291 struct inode *inode;
292 int err = 0;
288 293
289restart: 294restart:
290 rcu_read_lock(); 295 rcu_read_lock();
@@ -298,12 +303,18 @@ restart:
298 delegation = nfs_detach_delegation_locked(NFS_I(inode), NULL); 303 delegation = nfs_detach_delegation_locked(NFS_I(inode), NULL);
299 spin_unlock(&clp->cl_lock); 304 spin_unlock(&clp->cl_lock);
300 rcu_read_unlock(); 305 rcu_read_unlock();
301 if (delegation != NULL) 306 if (delegation != NULL) {
302 __nfs_inode_return_delegation(inode, delegation); 307 filemap_flush(inode->i_mapping);
308 err = __nfs_inode_return_delegation(inode, delegation, 0);
309 }
303 iput(inode); 310 iput(inode);
304 goto restart; 311 if (!err)
312 goto restart;
313 set_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state);
314 return err;
305 } 315 }
306 rcu_read_unlock(); 316 rcu_read_unlock();
317 return 0;
307} 318}
308 319
309/* 320/*
@@ -338,8 +349,10 @@ int nfs_inode_return_delegation(struct inode *inode)
338 spin_lock(&clp->cl_lock); 349 spin_lock(&clp->cl_lock);
339 delegation = nfs_detach_delegation_locked(nfsi, NULL); 350 delegation = nfs_detach_delegation_locked(nfsi, NULL);
340 spin_unlock(&clp->cl_lock); 351 spin_unlock(&clp->cl_lock);
341 if (delegation != NULL) 352 if (delegation != NULL) {
342 err = __nfs_inode_return_delegation(inode, delegation); 353 nfs_msync_inode(inode);
354 err = __nfs_inode_return_delegation(inode, delegation, 1);
355 }
343 } 356 }
344 return err; 357 return err;
345} 358}
@@ -368,33 +381,47 @@ void nfs_super_return_all_delegations(struct super_block *sb)
368 spin_unlock(&delegation->lock); 381 spin_unlock(&delegation->lock);
369 } 382 }
370 rcu_read_unlock(); 383 rcu_read_unlock();
371 nfs_client_return_marked_delegations(clp); 384 if (nfs_client_return_marked_delegations(clp) != 0)
385 nfs4_schedule_state_manager(clp);
372} 386}
373 387
374static void nfs_client_mark_return_all_delegations(struct nfs_client *clp) 388static
389void nfs_client_mark_return_all_delegation_types(struct nfs_client *clp, fmode_t flags)
375{ 390{
376 struct nfs_delegation *delegation; 391 struct nfs_delegation *delegation;
377 392
378 rcu_read_lock(); 393 rcu_read_lock();
379 list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list) { 394 list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list) {
380 set_bit(NFS_DELEGATION_RETURN, &delegation->flags); 395 if ((delegation->type == (FMODE_READ|FMODE_WRITE)) && !(flags & FMODE_WRITE))
381 set_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state); 396 continue;
397 if (delegation->type & flags)
398 nfs_mark_return_delegation(clp, delegation);
382 } 399 }
383 rcu_read_unlock(); 400 rcu_read_unlock();
384} 401}
385 402
403static void nfs_client_mark_return_all_delegations(struct nfs_client *clp)
404{
405 nfs_client_mark_return_all_delegation_types(clp, FMODE_READ|FMODE_WRITE);
406}
407
386static void nfs_delegation_run_state_manager(struct nfs_client *clp) 408static void nfs_delegation_run_state_manager(struct nfs_client *clp)
387{ 409{
388 if (test_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) 410 if (test_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state))
389 nfs4_schedule_state_manager(clp); 411 nfs4_schedule_state_manager(clp);
390} 412}
391 413
392void nfs_expire_all_delegations(struct nfs_client *clp) 414void nfs_expire_all_delegation_types(struct nfs_client *clp, fmode_t flags)
393{ 415{
394 nfs_client_mark_return_all_delegations(clp); 416 nfs_client_mark_return_all_delegation_types(clp, flags);
395 nfs_delegation_run_state_manager(clp); 417 nfs_delegation_run_state_manager(clp);
396} 418}
397 419
420void nfs_expire_all_delegations(struct nfs_client *clp)
421{
422 nfs_expire_all_delegation_types(clp, FMODE_READ|FMODE_WRITE);
423}
424
398/* 425/*
399 * Return all delegations following an NFS4ERR_CB_PATH_DOWN error. 426 * Return all delegations following an NFS4ERR_CB_PATH_DOWN error.
400 */ 427 */
@@ -413,8 +440,7 @@ static void nfs_client_mark_return_unreferenced_delegations(struct nfs_client *c
413 list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list) { 440 list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list) {
414 if (test_and_clear_bit(NFS_DELEGATION_REFERENCED, &delegation->flags)) 441 if (test_and_clear_bit(NFS_DELEGATION_REFERENCED, &delegation->flags))
415 continue; 442 continue;
416 set_bit(NFS_DELEGATION_RETURN, &delegation->flags); 443 nfs_mark_return_delegation(clp, delegation);
417 set_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state);
418 } 444 }
419 rcu_read_unlock(); 445 rcu_read_unlock();
420} 446}
@@ -428,18 +454,21 @@ void nfs_expire_unreferenced_delegations(struct nfs_client *clp)
428/* 454/*
429 * Asynchronous delegation recall! 455 * Asynchronous delegation recall!
430 */ 456 */
431int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid) 457int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid,
458 int (*validate_stateid)(struct nfs_delegation *delegation,
459 const nfs4_stateid *stateid))
432{ 460{
433 struct nfs_client *clp = NFS_SERVER(inode)->nfs_client; 461 struct nfs_client *clp = NFS_SERVER(inode)->nfs_client;
434 struct nfs_delegation *delegation; 462 struct nfs_delegation *delegation;
435 463
436 rcu_read_lock(); 464 rcu_read_lock();
437 delegation = rcu_dereference(NFS_I(inode)->delegation); 465 delegation = rcu_dereference(NFS_I(inode)->delegation);
438 if (delegation == NULL || memcmp(delegation->stateid.data, stateid->data, 466
439 sizeof(delegation->stateid.data)) != 0) { 467 if (!validate_stateid(delegation, stateid)) {
440 rcu_read_unlock(); 468 rcu_read_unlock();
441 return -ENOENT; 469 return -ENOENT;
442 } 470 }
471
443 nfs_mark_return_delegation(clp, delegation); 472 nfs_mark_return_delegation(clp, delegation);
444 rcu_read_unlock(); 473 rcu_read_unlock();
445 nfs_delegation_run_state_manager(clp); 474 nfs_delegation_run_state_manager(clp);
diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h
index 09f383795174..944b627ec6e1 100644
--- a/fs/nfs/delegation.h
+++ b/fs/nfs/delegation.h
@@ -34,15 +34,18 @@ enum {
34int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); 34int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res);
35void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); 35void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res);
36int nfs_inode_return_delegation(struct inode *inode); 36int nfs_inode_return_delegation(struct inode *inode);
37int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid); 37int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid,
38 int (*validate_stateid)(struct nfs_delegation *delegation,
39 const nfs4_stateid *stateid));
38void nfs_inode_return_delegation_noreclaim(struct inode *inode); 40void nfs_inode_return_delegation_noreclaim(struct inode *inode);
39 41
40struct inode *nfs_delegation_find_inode(struct nfs_client *clp, const struct nfs_fh *fhandle); 42struct inode *nfs_delegation_find_inode(struct nfs_client *clp, const struct nfs_fh *fhandle);
41void nfs_super_return_all_delegations(struct super_block *sb); 43void nfs_super_return_all_delegations(struct super_block *sb);
42void nfs_expire_all_delegations(struct nfs_client *clp); 44void nfs_expire_all_delegations(struct nfs_client *clp);
45void nfs_expire_all_delegation_types(struct nfs_client *clp, fmode_t flags);
43void nfs_expire_unreferenced_delegations(struct nfs_client *clp); 46void nfs_expire_unreferenced_delegations(struct nfs_client *clp);
44void nfs_handle_cb_pathdown(struct nfs_client *clp); 47void nfs_handle_cb_pathdown(struct nfs_client *clp);
45void nfs_client_return_marked_delegations(struct nfs_client *clp); 48int nfs_client_return_marked_delegations(struct nfs_client *clp);
46 49
47void nfs_delegation_mark_reclaim(struct nfs_client *clp); 50void nfs_delegation_mark_reclaim(struct nfs_client *clp);
48void nfs_delegation_reap_unclaimed(struct nfs_client *clp); 51void nfs_delegation_reap_unclaimed(struct nfs_client *clp);
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 7cb298525eef..2c5ace4f00a7 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1579,55 +1579,46 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1579 struct dentry *dentry = NULL, *rehash = NULL; 1579 struct dentry *dentry = NULL, *rehash = NULL;
1580 int error = -EBUSY; 1580 int error = -EBUSY;
1581 1581
1582 /*
1583 * To prevent any new references to the target during the rename,
1584 * we unhash the dentry and free the inode in advance.
1585 */
1586 if (!d_unhashed(new_dentry)) {
1587 d_drop(new_dentry);
1588 rehash = new_dentry;
1589 }
1590
1591 dfprintk(VFS, "NFS: rename(%s/%s -> %s/%s, ct=%d)\n", 1582 dfprintk(VFS, "NFS: rename(%s/%s -> %s/%s, ct=%d)\n",
1592 old_dentry->d_parent->d_name.name, old_dentry->d_name.name, 1583 old_dentry->d_parent->d_name.name, old_dentry->d_name.name,
1593 new_dentry->d_parent->d_name.name, new_dentry->d_name.name, 1584 new_dentry->d_parent->d_name.name, new_dentry->d_name.name,
1594 atomic_read(&new_dentry->d_count)); 1585 atomic_read(&new_dentry->d_count));
1595 1586
1596 /* 1587 /*
1597 * First check whether the target is busy ... we can't 1588 * For non-directories, check whether the target is busy and if so,
1598 * safely do _any_ rename if the target is in use. 1589 * make a copy of the dentry and then do a silly-rename. If the
1599 * 1590 * silly-rename succeeds, the copied dentry is hashed and becomes
1600 * For files, make a copy of the dentry and then do a 1591 * the new target.
1601 * silly-rename. If the silly-rename succeeds, the
1602 * copied dentry is hashed and becomes the new target.
1603 */ 1592 */
1604 if (!new_inode) 1593 if (new_inode && !S_ISDIR(new_inode->i_mode)) {
1605 goto go_ahead; 1594 /*
1606 if (S_ISDIR(new_inode->i_mode)) { 1595 * To prevent any new references to the target during the
1607 error = -EISDIR; 1596 * rename, we unhash the dentry in advance.
1608 if (!S_ISDIR(old_inode->i_mode)) 1597 */
1609 goto out; 1598 if (!d_unhashed(new_dentry)) {
1610 } else if (atomic_read(&new_dentry->d_count) > 2) { 1599 d_drop(new_dentry);
1611 int err; 1600 rehash = new_dentry;
1612 /* copy the target dentry's name */ 1601 }
1613 dentry = d_alloc(new_dentry->d_parent, 1602
1614 &new_dentry->d_name); 1603 if (atomic_read(&new_dentry->d_count) > 2) {
1615 if (!dentry) 1604 int err;
1616 goto out; 1605
1606 /* copy the target dentry's name */
1607 dentry = d_alloc(new_dentry->d_parent,
1608 &new_dentry->d_name);
1609 if (!dentry)
1610 goto out;
1617 1611
1618 /* silly-rename the existing target ... */ 1612 /* silly-rename the existing target ... */
1619 err = nfs_sillyrename(new_dir, new_dentry); 1613 err = nfs_sillyrename(new_dir, new_dentry);
1620 if (!err) { 1614 if (err)
1621 new_dentry = rehash = dentry; 1615 goto out;
1616
1617 new_dentry = dentry;
1622 new_inode = NULL; 1618 new_inode = NULL;
1623 /* instantiate the replacement target */ 1619 }
1624 d_instantiate(new_dentry, NULL);
1625 } else if (atomic_read(&new_dentry->d_count) > 1)
1626 /* dentry still busy? */
1627 goto out;
1628 } 1620 }
1629 1621
1630go_ahead:
1631 /* 1622 /*
1632 * ... prune child dentries and writebacks if needed. 1623 * ... prune child dentries and writebacks if needed.
1633 */ 1624 */
diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c
index f4d54ba97cc6..95e1ca765d47 100644
--- a/fs/nfs/dns_resolve.c
+++ b/fs/nfs/dns_resolve.c
@@ -146,7 +146,7 @@ static int nfs_dns_show(struct seq_file *m, struct cache_detail *cd,
146 return 0; 146 return 0;
147} 147}
148 148
149struct nfs_dns_ent *nfs_dns_lookup(struct cache_detail *cd, 149static struct nfs_dns_ent *nfs_dns_lookup(struct cache_detail *cd,
150 struct nfs_dns_ent *key) 150 struct nfs_dns_ent *key)
151{ 151{
152 struct cache_head *ch; 152 struct cache_head *ch;
@@ -159,7 +159,7 @@ struct nfs_dns_ent *nfs_dns_lookup(struct cache_detail *cd,
159 return container_of(ch, struct nfs_dns_ent, h); 159 return container_of(ch, struct nfs_dns_ent, h);
160} 160}
161 161
162struct nfs_dns_ent *nfs_dns_update(struct cache_detail *cd, 162static struct nfs_dns_ent *nfs_dns_update(struct cache_detail *cd,
163 struct nfs_dns_ent *new, 163 struct nfs_dns_ent *new,
164 struct nfs_dns_ent *key) 164 struct nfs_dns_ent *key)
165{ 165{
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index e21b1bb9972f..29e464d23b32 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -30,6 +30,15 @@ static inline int nfs4_has_session(const struct nfs_client *clp)
30 return 0; 30 return 0;
31} 31}
32 32
33static inline int nfs4_has_persistent_session(const struct nfs_client *clp)
34{
35#ifdef CONFIG_NFS_V4_1
36 if (nfs4_has_session(clp))
37 return (clp->cl_session->flags & SESSION4_PERSIST);
38#endif /* CONFIG_NFS_V4_1 */
39 return 0;
40}
41
33struct nfs_clone_mount { 42struct nfs_clone_mount {
34 const struct super_block *sb; 43 const struct super_block *sb;
35 const struct dentry *dentry; 44 const struct dentry *dentry;
@@ -156,6 +165,7 @@ struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentr
156 165
157/* callback_xdr.c */ 166/* callback_xdr.c */
158extern struct svc_version nfs4_callback_version1; 167extern struct svc_version nfs4_callback_version1;
168extern struct svc_version nfs4_callback_version4;
159 169
160/* pagelist.c */ 170/* pagelist.c */
161extern int __init nfs_init_nfspagecache(void); 171extern int __init nfs_init_nfspagecache(void);
@@ -177,24 +187,14 @@ extern __be32 * nfs_decode_dirent(__be32 *, struct nfs_entry *, int);
177extern struct rpc_procinfo nfs3_procedures[]; 187extern struct rpc_procinfo nfs3_procedures[];
178extern __be32 *nfs3_decode_dirent(__be32 *, struct nfs_entry *, int); 188extern __be32 *nfs3_decode_dirent(__be32 *, struct nfs_entry *, int);
179 189
180/* nfs4proc.c */
181static inline void nfs4_restart_rpc(struct rpc_task *task,
182 const struct nfs_client *clp)
183{
184#ifdef CONFIG_NFS_V4_1
185 if (nfs4_has_session(clp) &&
186 test_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state)) {
187 rpc_restart_call_prepare(task);
188 return;
189 }
190#endif /* CONFIG_NFS_V4_1 */
191 rpc_restart_call(task);
192}
193
194/* nfs4xdr.c */ 190/* nfs4xdr.c */
195#ifdef CONFIG_NFS_V4 191#ifdef CONFIG_NFS_V4
196extern __be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus); 192extern __be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus);
197#endif 193#endif
194#ifdef CONFIG_NFS_V4_1
195extern const u32 nfs41_maxread_overhead;
196extern const u32 nfs41_maxwrite_overhead;
197#endif
198 198
199/* nfs4proc.c */ 199/* nfs4proc.c */
200#ifdef CONFIG_NFS_V4 200#ifdef CONFIG_NFS_V4
@@ -273,20 +273,6 @@ extern int _nfs4_call_sync_session(struct nfs_server *server,
273 struct nfs4_sequence_res *res, 273 struct nfs4_sequence_res *res,
274 int cache_reply); 274 int cache_reply);
275 275
276#ifdef CONFIG_NFS_V4_1
277extern void nfs41_sequence_free_slot(const struct nfs_client *,
278 struct nfs4_sequence_res *res);
279#endif /* CONFIG_NFS_V4_1 */
280
281static inline void nfs4_sequence_free_slot(const struct nfs_client *clp,
282 struct nfs4_sequence_res *res)
283{
284#ifdef CONFIG_NFS_V4_1
285 if (nfs4_has_session(clp))
286 nfs41_sequence_free_slot(clp, res);
287#endif /* CONFIG_NFS_V4_1 */
288}
289
290/* 276/*
291 * Determine the device name as a string 277 * Determine the device name as a string
292 */ 278 */
@@ -380,3 +366,15 @@ unsigned int nfs_page_array_len(unsigned int base, size_t len)
380 return ((unsigned long)len + (unsigned long)base + 366 return ((unsigned long)len + (unsigned long)base +
381 PAGE_SIZE - 1) >> PAGE_SHIFT; 367 PAGE_SIZE - 1) >> PAGE_SHIFT;
382} 368}
369
370/*
371 * Helper for restarting RPC calls in the possible presence of NFSv4.1
372 * sessions.
373 */
374static inline void nfs_restart_rpc(struct rpc_task *task, const struct nfs_client *clp)
375{
376 if (nfs4_has_session(clp))
377 rpc_restart_call_prepare(task);
378 else
379 rpc_restart_call(task);
380}
diff --git a/fs/nfs/iostat.h b/fs/nfs/iostat.h
index ceda50aad73c..46d779abafd3 100644
--- a/fs/nfs/iostat.h
+++ b/fs/nfs/iostat.h
@@ -25,13 +25,7 @@ struct nfs_iostats {
25static inline void nfs_inc_server_stats(const struct nfs_server *server, 25static inline void nfs_inc_server_stats(const struct nfs_server *server,
26 enum nfs_stat_eventcounters stat) 26 enum nfs_stat_eventcounters stat)
27{ 27{
28 struct nfs_iostats *iostats; 28 this_cpu_inc(server->io_stats->events[stat]);
29 int cpu;
30
31 cpu = get_cpu();
32 iostats = per_cpu_ptr(server->io_stats, cpu);
33 iostats->events[stat]++;
34 put_cpu();
35} 29}
36 30
37static inline void nfs_inc_stats(const struct inode *inode, 31static inline void nfs_inc_stats(const struct inode *inode,
@@ -44,13 +38,7 @@ static inline void nfs_add_server_stats(const struct nfs_server *server,
44 enum nfs_stat_bytecounters stat, 38 enum nfs_stat_bytecounters stat,
45 unsigned long addend) 39 unsigned long addend)
46{ 40{
47 struct nfs_iostats *iostats; 41 this_cpu_add(server->io_stats->bytes[stat], addend);
48 int cpu;
49
50 cpu = get_cpu();
51 iostats = per_cpu_ptr(server->io_stats, cpu);
52 iostats->bytes[stat] += addend;
53 put_cpu();
54} 42}
55 43
56static inline void nfs_add_stats(const struct inode *inode, 44static inline void nfs_add_stats(const struct inode *inode,
@@ -65,13 +53,7 @@ static inline void nfs_add_fscache_stats(struct inode *inode,
65 enum nfs_stat_fscachecounters stat, 53 enum nfs_stat_fscachecounters stat,
66 unsigned long addend) 54 unsigned long addend)
67{ 55{
68 struct nfs_iostats *iostats; 56 this_cpu_add(NFS_SERVER(inode)->io_stats->fscache[stat], addend);
69 int cpu;
70
71 cpu = get_cpu();
72 iostats = per_cpu_ptr(NFS_SERVER(inode)->io_stats, cpu);
73 iostats->fscache[stat] += addend;
74 put_cpu();
75} 57}
76#endif 58#endif
77 59
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 6ea07a3c75d4..7e57b04e4014 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -44,7 +44,8 @@ enum nfs4_client_state {
44 NFS4CLNT_RECLAIM_REBOOT, 44 NFS4CLNT_RECLAIM_REBOOT,
45 NFS4CLNT_RECLAIM_NOGRACE, 45 NFS4CLNT_RECLAIM_NOGRACE,
46 NFS4CLNT_DELEGRETURN, 46 NFS4CLNT_DELEGRETURN,
47 NFS4CLNT_SESSION_SETUP, 47 NFS4CLNT_SESSION_RESET,
48 NFS4CLNT_SESSION_DRAINING,
48}; 49};
49 50
50/* 51/*
@@ -180,6 +181,7 @@ struct nfs4_state_recovery_ops {
180 int (*recover_lock)(struct nfs4_state *, struct file_lock *); 181 int (*recover_lock)(struct nfs4_state *, struct file_lock *);
181 int (*establish_clid)(struct nfs_client *, struct rpc_cred *); 182 int (*establish_clid)(struct nfs_client *, struct rpc_cred *);
182 struct rpc_cred * (*get_clid_cred)(struct nfs_client *); 183 struct rpc_cred * (*get_clid_cred)(struct nfs_client *);
184 int (*reclaim_complete)(struct nfs_client *);
183}; 185};
184 186
185struct nfs4_state_maintenance_ops { 187struct nfs4_state_maintenance_ops {
@@ -200,9 +202,11 @@ extern ssize_t nfs4_listxattr(struct dentry *, char *, size_t);
200/* nfs4proc.c */ 202/* nfs4proc.c */
201extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *); 203extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *);
202extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct rpc_cred *); 204extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct rpc_cred *);
205extern int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred);
203extern int nfs4_proc_async_renew(struct nfs_client *, struct rpc_cred *); 206extern int nfs4_proc_async_renew(struct nfs_client *, struct rpc_cred *);
204extern int nfs4_proc_renew(struct nfs_client *, struct rpc_cred *); 207extern int nfs4_proc_renew(struct nfs_client *, struct rpc_cred *);
205extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *); 208extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *);
209extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *);
206extern int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait); 210extern int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait);
207extern struct dentry *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *); 211extern struct dentry *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *);
208extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *); 212extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *);
@@ -218,9 +222,11 @@ extern int nfs4_setup_sequence(struct nfs_client *clp,
218 int cache_reply, struct rpc_task *task); 222 int cache_reply, struct rpc_task *task);
219extern void nfs4_destroy_session(struct nfs4_session *session); 223extern void nfs4_destroy_session(struct nfs4_session *session);
220extern struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp); 224extern struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp);
221extern int nfs4_proc_create_session(struct nfs_client *, int reset); 225extern int nfs4_proc_create_session(struct nfs_client *);
222extern int nfs4_proc_destroy_session(struct nfs4_session *); 226extern int nfs4_proc_destroy_session(struct nfs4_session *);
223extern int nfs4_init_session(struct nfs_server *server); 227extern int nfs4_init_session(struct nfs_server *server);
228extern int nfs4_proc_get_lease_time(struct nfs_client *clp,
229 struct nfs_fsinfo *fsinfo);
224#else /* CONFIG_NFS_v4_1 */ 230#else /* CONFIG_NFS_v4_1 */
225static inline int nfs4_setup_sequence(struct nfs_client *clp, 231static inline int nfs4_setup_sequence(struct nfs_client *clp,
226 struct nfs4_sequence_args *args, struct nfs4_sequence_res *res, 232 struct nfs4_sequence_args *args, struct nfs4_sequence_res *res,
@@ -267,6 +273,7 @@ extern void nfs4_state_set_mode_locked(struct nfs4_state *, fmode_t);
267extern void nfs4_schedule_state_recovery(struct nfs_client *); 273extern void nfs4_schedule_state_recovery(struct nfs_client *);
268extern void nfs4_schedule_state_manager(struct nfs_client *); 274extern void nfs4_schedule_state_manager(struct nfs_client *);
269extern int nfs4_state_mark_reclaim_nograce(struct nfs_client *clp, struct nfs4_state *state); 275extern int nfs4_state_mark_reclaim_nograce(struct nfs_client *clp, struct nfs4_state *state);
276extern void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags);
270extern void nfs4_put_lock_state(struct nfs4_lock_state *lsp); 277extern void nfs4_put_lock_state(struct nfs4_lock_state *lsp);
271extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl); 278extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl);
272extern void nfs4_copy_stateid(nfs4_stateid *, struct nfs4_state *, fl_owner_t); 279extern void nfs4_copy_stateid(nfs4_stateid *, struct nfs4_state *, fl_owner_t);
@@ -287,6 +294,7 @@ struct nfs4_mount_data;
287 294
288/* callback_xdr.c */ 295/* callback_xdr.c */
289extern struct svc_version nfs4_callback_version1; 296extern struct svc_version nfs4_callback_version1;
297extern struct svc_version nfs4_callback_version4;
290 298
291#else 299#else
292 300
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 741a562177fc..9f5f11ecfd93 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -270,11 +270,18 @@ static int nfs4_handle_exception(const struct nfs_server *server, int errorcode,
270 case -NFS4ERR_SEQ_MISORDERED: 270 case -NFS4ERR_SEQ_MISORDERED:
271 dprintk("%s ERROR: %d Reset session\n", __func__, 271 dprintk("%s ERROR: %d Reset session\n", __func__,
272 errorcode); 272 errorcode);
273 set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); 273 nfs4_schedule_state_recovery(clp);
274 exception->retry = 1; 274 exception->retry = 1;
275 /* FALLTHROUGH */ 275 break;
276#endif /* !defined(CONFIG_NFS_V4_1) */ 276#endif /* !defined(CONFIG_NFS_V4_1) */
277 case -NFS4ERR_FILE_OPEN: 277 case -NFS4ERR_FILE_OPEN:
278 if (exception->timeout > HZ) {
279 /* We have retried a decent amount, time to
280 * fail
281 */
282 ret = -EBUSY;
283 break;
284 }
278 case -NFS4ERR_GRACE: 285 case -NFS4ERR_GRACE:
279 case -NFS4ERR_DELAY: 286 case -NFS4ERR_DELAY:
280 ret = nfs4_delay(server->client, &exception->timeout); 287 ret = nfs4_delay(server->client, &exception->timeout);
@@ -311,48 +318,54 @@ static void renew_lease(const struct nfs_server *server, unsigned long timestamp
311 * so we need to scan down from highest_used_slotid to 0 looking for the now 318 * so we need to scan down from highest_used_slotid to 0 looking for the now
312 * highest slotid in use. 319 * highest slotid in use.
313 * If none found, highest_used_slotid is set to -1. 320 * If none found, highest_used_slotid is set to -1.
321 *
322 * Must be called while holding tbl->slot_tbl_lock
314 */ 323 */
315static void 324static void
316nfs4_free_slot(struct nfs4_slot_table *tbl, u8 free_slotid) 325nfs4_free_slot(struct nfs4_slot_table *tbl, u8 free_slotid)
317{ 326{
318 int slotid = free_slotid; 327 int slotid = free_slotid;
319 328
320 spin_lock(&tbl->slot_tbl_lock);
321 /* clear used bit in bitmap */ 329 /* clear used bit in bitmap */
322 __clear_bit(slotid, tbl->used_slots); 330 __clear_bit(slotid, tbl->used_slots);
323 331
324 /* update highest_used_slotid when it is freed */ 332 /* update highest_used_slotid when it is freed */
325 if (slotid == tbl->highest_used_slotid) { 333 if (slotid == tbl->highest_used_slotid) {
326 slotid = find_last_bit(tbl->used_slots, tbl->max_slots); 334 slotid = find_last_bit(tbl->used_slots, tbl->max_slots);
327 if (slotid >= 0 && slotid < tbl->max_slots) 335 if (slotid < tbl->max_slots)
328 tbl->highest_used_slotid = slotid; 336 tbl->highest_used_slotid = slotid;
329 else 337 else
330 tbl->highest_used_slotid = -1; 338 tbl->highest_used_slotid = -1;
331 } 339 }
332 rpc_wake_up_next(&tbl->slot_tbl_waitq);
333 spin_unlock(&tbl->slot_tbl_lock);
334 dprintk("%s: free_slotid %u highest_used_slotid %d\n", __func__, 340 dprintk("%s: free_slotid %u highest_used_slotid %d\n", __func__,
335 free_slotid, tbl->highest_used_slotid); 341 free_slotid, tbl->highest_used_slotid);
336} 342}
337 343
338void nfs41_sequence_free_slot(const struct nfs_client *clp, 344static void nfs41_sequence_free_slot(const struct nfs_client *clp,
339 struct nfs4_sequence_res *res) 345 struct nfs4_sequence_res *res)
340{ 346{
341 struct nfs4_slot_table *tbl; 347 struct nfs4_slot_table *tbl;
342 348
343 if (!nfs4_has_session(clp)) {
344 dprintk("%s: No session\n", __func__);
345 return;
346 }
347 tbl = &clp->cl_session->fc_slot_table; 349 tbl = &clp->cl_session->fc_slot_table;
348 if (res->sr_slotid == NFS4_MAX_SLOT_TABLE) { 350 if (res->sr_slotid == NFS4_MAX_SLOT_TABLE) {
349 dprintk("%s: No slot\n", __func__);
350 /* just wake up the next guy waiting since 351 /* just wake up the next guy waiting since
351 * we may have not consumed a slot after all */ 352 * we may have not consumed a slot after all */
352 rpc_wake_up_next(&tbl->slot_tbl_waitq); 353 dprintk("%s: No slot\n", __func__);
353 return; 354 return;
354 } 355 }
356
357 spin_lock(&tbl->slot_tbl_lock);
355 nfs4_free_slot(tbl, res->sr_slotid); 358 nfs4_free_slot(tbl, res->sr_slotid);
359
360 /* Signal state manager thread if session is drained */
361 if (test_bit(NFS4CLNT_SESSION_DRAINING, &clp->cl_state)) {
362 if (tbl->highest_used_slotid == -1) {
363 dprintk("%s COMPLETE: Session Drained\n", __func__);
364 complete(&clp->cl_session->complete);
365 }
366 } else
367 rpc_wake_up_next(&tbl->slot_tbl_waitq);
368 spin_unlock(&tbl->slot_tbl_lock);
356 res->sr_slotid = NFS4_MAX_SLOT_TABLE; 369 res->sr_slotid = NFS4_MAX_SLOT_TABLE;
357} 370}
358 371
@@ -377,10 +390,10 @@ static void nfs41_sequence_done(struct nfs_client *clp,
377 if (res->sr_slotid == NFS4_MAX_SLOT_TABLE) 390 if (res->sr_slotid == NFS4_MAX_SLOT_TABLE)
378 goto out; 391 goto out;
379 392
380 tbl = &clp->cl_session->fc_slot_table; 393 /* Check the SEQUENCE operation status */
381 slot = tbl->slots + res->sr_slotid;
382
383 if (res->sr_status == 0) { 394 if (res->sr_status == 0) {
395 tbl = &clp->cl_session->fc_slot_table;
396 slot = tbl->slots + res->sr_slotid;
384 /* Update the slot's sequence and clientid lease timer */ 397 /* Update the slot's sequence and clientid lease timer */
385 ++slot->seq_nr; 398 ++slot->seq_nr;
386 timestamp = res->sr_renewal_time; 399 timestamp = res->sr_renewal_time;
@@ -388,7 +401,8 @@ static void nfs41_sequence_done(struct nfs_client *clp,
388 if (time_before(clp->cl_last_renewal, timestamp)) 401 if (time_before(clp->cl_last_renewal, timestamp))
389 clp->cl_last_renewal = timestamp; 402 clp->cl_last_renewal = timestamp;
390 spin_unlock(&clp->cl_lock); 403 spin_unlock(&clp->cl_lock);
391 return; 404 /* Check sequence flags */
405 nfs41_handle_sequence_flag_errors(clp, res->sr_status_flags);
392 } 406 }
393out: 407out:
394 /* The session may be reset by one of the error handlers. */ 408 /* The session may be reset by one of the error handlers. */
@@ -429,24 +443,6 @@ out:
429 return ret_id; 443 return ret_id;
430} 444}
431 445
432static int nfs4_recover_session(struct nfs4_session *session)
433{
434 struct nfs_client *clp = session->clp;
435 unsigned int loop;
436 int ret;
437
438 for (loop = NFS4_MAX_LOOP_ON_RECOVER; loop != 0; loop--) {
439 ret = nfs4_wait_clnt_recover(clp);
440 if (ret != 0)
441 break;
442 if (!test_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state))
443 break;
444 nfs4_schedule_state_manager(clp);
445 ret = -EIO;
446 }
447 return ret;
448}
449
450static int nfs41_setup_sequence(struct nfs4_session *session, 446static int nfs41_setup_sequence(struct nfs4_session *session,
451 struct nfs4_sequence_args *args, 447 struct nfs4_sequence_args *args,
452 struct nfs4_sequence_res *res, 448 struct nfs4_sequence_res *res,
@@ -455,7 +451,6 @@ static int nfs41_setup_sequence(struct nfs4_session *session,
455{ 451{
456 struct nfs4_slot *slot; 452 struct nfs4_slot *slot;
457 struct nfs4_slot_table *tbl; 453 struct nfs4_slot_table *tbl;
458 int status = 0;
459 u8 slotid; 454 u8 slotid;
460 455
461 dprintk("--> %s\n", __func__); 456 dprintk("--> %s\n", __func__);
@@ -468,21 +463,15 @@ static int nfs41_setup_sequence(struct nfs4_session *session,
468 tbl = &session->fc_slot_table; 463 tbl = &session->fc_slot_table;
469 464
470 spin_lock(&tbl->slot_tbl_lock); 465 spin_lock(&tbl->slot_tbl_lock);
471 if (test_bit(NFS4CLNT_SESSION_SETUP, &session->clp->cl_state)) { 466 if (test_bit(NFS4CLNT_SESSION_DRAINING, &session->clp->cl_state)) {
472 if (tbl->highest_used_slotid != -1) { 467 /*
473 rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL); 468 * The state manager will wait until the slot table is empty.
474 spin_unlock(&tbl->slot_tbl_lock); 469 * Schedule the reset thread
475 dprintk("<-- %s: Session reset: draining\n", __func__); 470 */
476 return -EAGAIN; 471 rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL);
477 }
478
479 /* The slot table is empty; start the reset thread */
480 dprintk("%s Session Reset\n", __func__);
481 spin_unlock(&tbl->slot_tbl_lock); 472 spin_unlock(&tbl->slot_tbl_lock);
482 status = nfs4_recover_session(session); 473 dprintk("%s Schedule Session Reset\n", __func__);
483 if (status) 474 return -EAGAIN;
484 return status;
485 spin_lock(&tbl->slot_tbl_lock);
486 } 475 }
487 476
488 slotid = nfs4_find_slot(tbl, task); 477 slotid = nfs4_find_slot(tbl, task);
@@ -527,7 +516,7 @@ int nfs4_setup_sequence(struct nfs_client *clp,
527 goto out; 516 goto out;
528 ret = nfs41_setup_sequence(clp->cl_session, args, res, cache_reply, 517 ret = nfs41_setup_sequence(clp->cl_session, args, res, cache_reply,
529 task); 518 task);
530 if (ret != -EAGAIN) { 519 if (ret && ret != -EAGAIN) {
531 /* terminate rpc task */ 520 /* terminate rpc task */
532 task->tk_status = ret; 521 task->tk_status = ret;
533 task->tk_action = NULL; 522 task->tk_action = NULL;
@@ -561,7 +550,6 @@ static void nfs41_call_sync_done(struct rpc_task *task, void *calldata)
561 struct nfs41_call_sync_data *data = calldata; 550 struct nfs41_call_sync_data *data = calldata;
562 551
563 nfs41_sequence_done(data->clp, data->seq_res, task->tk_status); 552 nfs41_sequence_done(data->clp, data->seq_res, task->tk_status);
564 nfs41_sequence_free_slot(data->clp, data->seq_res);
565} 553}
566 554
567struct rpc_call_ops nfs41_call_sync_ops = { 555struct rpc_call_ops nfs41_call_sync_ops = {
@@ -637,15 +625,6 @@ static void nfs4_sequence_done(const struct nfs_server *server,
637#endif /* CONFIG_NFS_V4_1 */ 625#endif /* CONFIG_NFS_V4_1 */
638} 626}
639 627
640/* no restart, therefore free slot here */
641static void nfs4_sequence_done_free_slot(const struct nfs_server *server,
642 struct nfs4_sequence_res *res,
643 int rpc_status)
644{
645 nfs4_sequence_done(server, res, rpc_status);
646 nfs4_sequence_free_slot(server->nfs_client, res);
647}
648
649static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo) 628static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo)
650{ 629{
651 struct nfs_inode *nfsi = NFS_I(dir); 630 struct nfs_inode *nfsi = NFS_I(dir);
@@ -720,9 +699,15 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct path *path,
720 p->o_arg.bitmask = server->attr_bitmask; 699 p->o_arg.bitmask = server->attr_bitmask;
721 p->o_arg.claim = NFS4_OPEN_CLAIM_NULL; 700 p->o_arg.claim = NFS4_OPEN_CLAIM_NULL;
722 if (flags & O_EXCL) { 701 if (flags & O_EXCL) {
723 u32 *s = (u32 *) p->o_arg.u.verifier.data; 702 if (nfs4_has_persistent_session(server->nfs_client)) {
724 s[0] = jiffies; 703 /* GUARDED */
725 s[1] = current->pid; 704 p->o_arg.u.attrs = &p->attrs;
705 memcpy(&p->attrs, attrs, sizeof(p->attrs));
706 } else { /* EXCLUSIVE4_1 */
707 u32 *s = (u32 *) p->o_arg.u.verifier.data;
708 s[0] = jiffies;
709 s[1] = current->pid;
710 }
726 } else if (flags & O_CREAT) { 711 } else if (flags & O_CREAT) {
727 p->o_arg.u.attrs = &p->attrs; 712 p->o_arg.u.attrs = &p->attrs;
728 memcpy(&p->attrs, attrs, sizeof(p->attrs)); 713 memcpy(&p->attrs, attrs, sizeof(p->attrs));
@@ -776,13 +761,16 @@ static int can_open_cached(struct nfs4_state *state, fmode_t mode, int open_mode
776 goto out; 761 goto out;
777 switch (mode & (FMODE_READ|FMODE_WRITE)) { 762 switch (mode & (FMODE_READ|FMODE_WRITE)) {
778 case FMODE_READ: 763 case FMODE_READ:
779 ret |= test_bit(NFS_O_RDONLY_STATE, &state->flags) != 0; 764 ret |= test_bit(NFS_O_RDONLY_STATE, &state->flags) != 0
765 && state->n_rdonly != 0;
780 break; 766 break;
781 case FMODE_WRITE: 767 case FMODE_WRITE:
782 ret |= test_bit(NFS_O_WRONLY_STATE, &state->flags) != 0; 768 ret |= test_bit(NFS_O_WRONLY_STATE, &state->flags) != 0
769 && state->n_wronly != 0;
783 break; 770 break;
784 case FMODE_READ|FMODE_WRITE: 771 case FMODE_READ|FMODE_WRITE:
785 ret |= test_bit(NFS_O_RDWR_STATE, &state->flags) != 0; 772 ret |= test_bit(NFS_O_RDWR_STATE, &state->flags) != 0
773 && state->n_rdwr != 0;
786 } 774 }
787out: 775out:
788 return ret; 776 return ret;
@@ -1183,6 +1171,14 @@ int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state
1183 case -ENOENT: 1171 case -ENOENT:
1184 case -ESTALE: 1172 case -ESTALE:
1185 goto out; 1173 goto out;
1174 case -NFS4ERR_BADSESSION:
1175 case -NFS4ERR_BADSLOT:
1176 case -NFS4ERR_BAD_HIGH_SLOT:
1177 case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION:
1178 case -NFS4ERR_DEADSESSION:
1179 nfs4_schedule_state_recovery(
1180 server->nfs_client);
1181 goto out;
1186 case -NFS4ERR_STALE_CLIENTID: 1182 case -NFS4ERR_STALE_CLIENTID:
1187 case -NFS4ERR_STALE_STATEID: 1183 case -NFS4ERR_STALE_STATEID:
1188 case -NFS4ERR_EXPIRED: 1184 case -NFS4ERR_EXPIRED:
@@ -1336,8 +1332,8 @@ static void nfs4_open_done(struct rpc_task *task, void *calldata)
1336 1332
1337 data->rpc_status = task->tk_status; 1333 data->rpc_status = task->tk_status;
1338 1334
1339 nfs4_sequence_done_free_slot(data->o_arg.server, &data->o_res.seq_res, 1335 nfs4_sequence_done(data->o_arg.server, &data->o_res.seq_res,
1340 task->tk_status); 1336 task->tk_status);
1341 1337
1342 if (RPC_ASSASSINATED(task)) 1338 if (RPC_ASSASSINATED(task))
1343 return; 1339 return;
@@ -1488,7 +1484,7 @@ static int _nfs4_open_expired(struct nfs_open_context *ctx, struct nfs4_state *s
1488 return ret; 1484 return ret;
1489} 1485}
1490 1486
1491static inline int nfs4_do_open_expired(struct nfs_open_context *ctx, struct nfs4_state *state) 1487static int nfs4_do_open_expired(struct nfs_open_context *ctx, struct nfs4_state *state)
1492{ 1488{
1493 struct nfs_server *server = NFS_SERVER(state->inode); 1489 struct nfs_server *server = NFS_SERVER(state->inode);
1494 struct nfs4_exception exception = { }; 1490 struct nfs4_exception exception = { };
@@ -1496,10 +1492,16 @@ static inline int nfs4_do_open_expired(struct nfs_open_context *ctx, struct nfs4
1496 1492
1497 do { 1493 do {
1498 err = _nfs4_open_expired(ctx, state); 1494 err = _nfs4_open_expired(ctx, state);
1499 if (err != -NFS4ERR_DELAY) 1495 switch (err) {
1500 break; 1496 default:
1501 nfs4_handle_exception(server, err, &exception); 1497 goto out;
1498 case -NFS4ERR_GRACE:
1499 case -NFS4ERR_DELAY:
1500 nfs4_handle_exception(server, err, &exception);
1501 err = 0;
1502 }
1502 } while (exception.retry); 1503 } while (exception.retry);
1504out:
1503 return err; 1505 return err;
1504} 1506}
1505 1507
@@ -1712,6 +1714,18 @@ static void nfs4_free_closedata(void *data)
1712 kfree(calldata); 1714 kfree(calldata);
1713} 1715}
1714 1716
1717static void nfs4_close_clear_stateid_flags(struct nfs4_state *state,
1718 fmode_t fmode)
1719{
1720 spin_lock(&state->owner->so_lock);
1721 if (!(fmode & FMODE_READ))
1722 clear_bit(NFS_O_RDONLY_STATE, &state->flags);
1723 if (!(fmode & FMODE_WRITE))
1724 clear_bit(NFS_O_WRONLY_STATE, &state->flags);
1725 clear_bit(NFS_O_RDWR_STATE, &state->flags);
1726 spin_unlock(&state->owner->so_lock);
1727}
1728
1715static void nfs4_close_done(struct rpc_task *task, void *data) 1729static void nfs4_close_done(struct rpc_task *task, void *data)
1716{ 1730{
1717 struct nfs4_closedata *calldata = data; 1731 struct nfs4_closedata *calldata = data;
@@ -1728,6 +1742,8 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
1728 case 0: 1742 case 0:
1729 nfs_set_open_stateid(state, &calldata->res.stateid, 0); 1743 nfs_set_open_stateid(state, &calldata->res.stateid, 0);
1730 renew_lease(server, calldata->timestamp); 1744 renew_lease(server, calldata->timestamp);
1745 nfs4_close_clear_stateid_flags(state,
1746 calldata->arg.fmode);
1731 break; 1747 break;
1732 case -NFS4ERR_STALE_STATEID: 1748 case -NFS4ERR_STALE_STATEID:
1733 case -NFS4ERR_OLD_STATEID: 1749 case -NFS4ERR_OLD_STATEID:
@@ -1737,11 +1753,10 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
1737 break; 1753 break;
1738 default: 1754 default:
1739 if (nfs4_async_handle_error(task, server, state) == -EAGAIN) { 1755 if (nfs4_async_handle_error(task, server, state) == -EAGAIN) {
1740 nfs4_restart_rpc(task, server->nfs_client); 1756 nfs_restart_rpc(task, server->nfs_client);
1741 return; 1757 return;
1742 } 1758 }
1743 } 1759 }
1744 nfs4_sequence_free_slot(server->nfs_client, &calldata->res.seq_res);
1745 nfs_refresh_inode(calldata->inode, calldata->res.fattr); 1760 nfs_refresh_inode(calldata->inode, calldata->res.fattr);
1746} 1761}
1747 1762
@@ -1749,38 +1764,39 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
1749{ 1764{
1750 struct nfs4_closedata *calldata = data; 1765 struct nfs4_closedata *calldata = data;
1751 struct nfs4_state *state = calldata->state; 1766 struct nfs4_state *state = calldata->state;
1752 int clear_rd, clear_wr, clear_rdwr; 1767 int call_close = 0;
1753 1768
1754 if (nfs_wait_on_sequence(calldata->arg.seqid, task) != 0) 1769 if (nfs_wait_on_sequence(calldata->arg.seqid, task) != 0)
1755 return; 1770 return;
1756 1771
1757 clear_rd = clear_wr = clear_rdwr = 0; 1772 task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE];
1773 calldata->arg.fmode = FMODE_READ|FMODE_WRITE;
1758 spin_lock(&state->owner->so_lock); 1774 spin_lock(&state->owner->so_lock);
1759 /* Calculate the change in open mode */ 1775 /* Calculate the change in open mode */
1760 if (state->n_rdwr == 0) { 1776 if (state->n_rdwr == 0) {
1761 if (state->n_rdonly == 0) { 1777 if (state->n_rdonly == 0) {
1762 clear_rd |= test_and_clear_bit(NFS_O_RDONLY_STATE, &state->flags); 1778 call_close |= test_bit(NFS_O_RDONLY_STATE, &state->flags);
1763 clear_rdwr |= test_and_clear_bit(NFS_O_RDWR_STATE, &state->flags); 1779 call_close |= test_bit(NFS_O_RDWR_STATE, &state->flags);
1780 calldata->arg.fmode &= ~FMODE_READ;
1764 } 1781 }
1765 if (state->n_wronly == 0) { 1782 if (state->n_wronly == 0) {
1766 clear_wr |= test_and_clear_bit(NFS_O_WRONLY_STATE, &state->flags); 1783 call_close |= test_bit(NFS_O_WRONLY_STATE, &state->flags);
1767 clear_rdwr |= test_and_clear_bit(NFS_O_RDWR_STATE, &state->flags); 1784 call_close |= test_bit(NFS_O_RDWR_STATE, &state->flags);
1785 calldata->arg.fmode &= ~FMODE_WRITE;
1768 } 1786 }
1769 } 1787 }
1770 spin_unlock(&state->owner->so_lock); 1788 spin_unlock(&state->owner->so_lock);
1771 if (!clear_rd && !clear_wr && !clear_rdwr) { 1789
1790 if (!call_close) {
1772 /* Note: exit _without_ calling nfs4_close_done */ 1791 /* Note: exit _without_ calling nfs4_close_done */
1773 task->tk_action = NULL; 1792 task->tk_action = NULL;
1774 return; 1793 return;
1775 } 1794 }
1795
1796 if (calldata->arg.fmode == 0)
1797 task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CLOSE];
1798
1776 nfs_fattr_init(calldata->res.fattr); 1799 nfs_fattr_init(calldata->res.fattr);
1777 if (test_bit(NFS_O_RDONLY_STATE, &state->flags) != 0) {
1778 task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE];
1779 calldata->arg.fmode = FMODE_READ;
1780 } else if (test_bit(NFS_O_WRONLY_STATE, &state->flags) != 0) {
1781 task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE];
1782 calldata->arg.fmode = FMODE_WRITE;
1783 }
1784 calldata->timestamp = jiffies; 1800 calldata->timestamp = jiffies;
1785 if (nfs4_setup_sequence((NFS_SERVER(calldata->inode))->nfs_client, 1801 if (nfs4_setup_sequence((NFS_SERVER(calldata->inode))->nfs_client,
1786 &calldata->arg.seq_args, &calldata->res.seq_res, 1802 &calldata->arg.seq_args, &calldata->res.seq_res,
@@ -1981,7 +1997,7 @@ out_drop:
1981 return 0; 1997 return 0;
1982} 1998}
1983 1999
1984void nfs4_close_context(struct nfs_open_context *ctx, int is_sync) 2000static void nfs4_close_context(struct nfs_open_context *ctx, int is_sync)
1985{ 2001{
1986 if (ctx->state == NULL) 2002 if (ctx->state == NULL)
1987 return; 2003 return;
@@ -2532,7 +2548,6 @@ static int nfs4_proc_unlink_done(struct rpc_task *task, struct inode *dir)
2532 nfs4_sequence_done(res->server, &res->seq_res, task->tk_status); 2548 nfs4_sequence_done(res->server, &res->seq_res, task->tk_status);
2533 if (nfs4_async_handle_error(task, res->server, NULL) == -EAGAIN) 2549 if (nfs4_async_handle_error(task, res->server, NULL) == -EAGAIN)
2534 return 0; 2550 return 0;
2535 nfs4_sequence_free_slot(res->server->nfs_client, &res->seq_res);
2536 update_changeattr(dir, &res->cinfo); 2551 update_changeattr(dir, &res->cinfo);
2537 nfs_post_op_update_inode(dir, &res->dir_attr); 2552 nfs_post_op_update_inode(dir, &res->dir_attr);
2538 return 1; 2553 return 1;
@@ -2971,11 +2986,10 @@ static int nfs4_read_done(struct rpc_task *task, struct nfs_read_data *data)
2971 2986
2972 dprintk("--> %s\n", __func__); 2987 dprintk("--> %s\n", __func__);
2973 2988
2974 /* nfs4_sequence_free_slot called in the read rpc_call_done */
2975 nfs4_sequence_done(server, &data->res.seq_res, task->tk_status); 2989 nfs4_sequence_done(server, &data->res.seq_res, task->tk_status);
2976 2990
2977 if (nfs4_async_handle_error(task, server, data->args.context->state) == -EAGAIN) { 2991 if (nfs4_async_handle_error(task, server, data->args.context->state) == -EAGAIN) {
2978 nfs4_restart_rpc(task, server->nfs_client); 2992 nfs_restart_rpc(task, server->nfs_client);
2979 return -EAGAIN; 2993 return -EAGAIN;
2980 } 2994 }
2981 2995
@@ -2995,12 +3009,11 @@ static int nfs4_write_done(struct rpc_task *task, struct nfs_write_data *data)
2995{ 3009{
2996 struct inode *inode = data->inode; 3010 struct inode *inode = data->inode;
2997 3011
2998 /* slot is freed in nfs_writeback_done */
2999 nfs4_sequence_done(NFS_SERVER(inode), &data->res.seq_res, 3012 nfs4_sequence_done(NFS_SERVER(inode), &data->res.seq_res,
3000 task->tk_status); 3013 task->tk_status);
3001 3014
3002 if (nfs4_async_handle_error(task, NFS_SERVER(inode), data->args.context->state) == -EAGAIN) { 3015 if (nfs4_async_handle_error(task, NFS_SERVER(inode), data->args.context->state) == -EAGAIN) {
3003 nfs4_restart_rpc(task, NFS_SERVER(inode)->nfs_client); 3016 nfs_restart_rpc(task, NFS_SERVER(inode)->nfs_client);
3004 return -EAGAIN; 3017 return -EAGAIN;
3005 } 3018 }
3006 if (task->tk_status >= 0) { 3019 if (task->tk_status >= 0) {
@@ -3028,11 +3041,9 @@ static int nfs4_commit_done(struct rpc_task *task, struct nfs_write_data *data)
3028 nfs4_sequence_done(NFS_SERVER(inode), &data->res.seq_res, 3041 nfs4_sequence_done(NFS_SERVER(inode), &data->res.seq_res,
3029 task->tk_status); 3042 task->tk_status);
3030 if (nfs4_async_handle_error(task, NFS_SERVER(inode), NULL) == -EAGAIN) { 3043 if (nfs4_async_handle_error(task, NFS_SERVER(inode), NULL) == -EAGAIN) {
3031 nfs4_restart_rpc(task, NFS_SERVER(inode)->nfs_client); 3044 nfs_restart_rpc(task, NFS_SERVER(inode)->nfs_client);
3032 return -EAGAIN; 3045 return -EAGAIN;
3033 } 3046 }
3034 nfs4_sequence_free_slot(NFS_SERVER(inode)->nfs_client,
3035 &data->res.seq_res);
3036 nfs_refresh_inode(inode, data->res.fattr); 3047 nfs_refresh_inode(inode, data->res.fattr);
3037 return 0; 3048 return 0;
3038} 3049}
@@ -3350,7 +3361,7 @@ _nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server,
3350 case -NFS4ERR_SEQ_MISORDERED: 3361 case -NFS4ERR_SEQ_MISORDERED:
3351 dprintk("%s ERROR %d, Reset session\n", __func__, 3362 dprintk("%s ERROR %d, Reset session\n", __func__,
3352 task->tk_status); 3363 task->tk_status);
3353 set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); 3364 nfs4_schedule_state_recovery(clp);
3354 task->tk_status = 0; 3365 task->tk_status = 0;
3355 return -EAGAIN; 3366 return -EAGAIN;
3356#endif /* CONFIG_NFS_V4_1 */ 3367#endif /* CONFIG_NFS_V4_1 */
@@ -3483,12 +3494,23 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata)
3483{ 3494{
3484 struct nfs4_delegreturndata *data = calldata; 3495 struct nfs4_delegreturndata *data = calldata;
3485 3496
3486 nfs4_sequence_done_free_slot(data->res.server, &data->res.seq_res, 3497 nfs4_sequence_done(data->res.server, &data->res.seq_res,
3487 task->tk_status); 3498 task->tk_status);
3488 3499
3489 data->rpc_status = task->tk_status; 3500 switch (task->tk_status) {
3490 if (data->rpc_status == 0) 3501 case -NFS4ERR_STALE_STATEID:
3502 case -NFS4ERR_EXPIRED:
3503 case 0:
3491 renew_lease(data->res.server, data->timestamp); 3504 renew_lease(data->res.server, data->timestamp);
3505 break;
3506 default:
3507 if (nfs4_async_handle_error(task, data->res.server, NULL) ==
3508 -EAGAIN) {
3509 nfs_restart_rpc(task, data->res.server->nfs_client);
3510 return;
3511 }
3512 }
3513 data->rpc_status = task->tk_status;
3492} 3514}
3493 3515
3494static void nfs4_delegreturn_release(void *calldata) 3516static void nfs4_delegreturn_release(void *calldata)
@@ -3741,11 +3763,9 @@ static void nfs4_locku_done(struct rpc_task *task, void *data)
3741 break; 3763 break;
3742 default: 3764 default:
3743 if (nfs4_async_handle_error(task, calldata->server, NULL) == -EAGAIN) 3765 if (nfs4_async_handle_error(task, calldata->server, NULL) == -EAGAIN)
3744 nfs4_restart_rpc(task, 3766 nfs_restart_rpc(task,
3745 calldata->server->nfs_client); 3767 calldata->server->nfs_client);
3746 } 3768 }
3747 nfs4_sequence_free_slot(calldata->server->nfs_client,
3748 &calldata->res.seq_res);
3749} 3769}
3750 3770
3751static void nfs4_locku_prepare(struct rpc_task *task, void *data) 3771static void nfs4_locku_prepare(struct rpc_task *task, void *data)
@@ -3927,8 +3947,8 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata)
3927 3947
3928 dprintk("%s: begin!\n", __func__); 3948 dprintk("%s: begin!\n", __func__);
3929 3949
3930 nfs4_sequence_done_free_slot(data->server, &data->res.seq_res, 3950 nfs4_sequence_done(data->server, &data->res.seq_res,
3931 task->tk_status); 3951 task->tk_status);
3932 3952
3933 data->rpc_status = task->tk_status; 3953 data->rpc_status = task->tk_status;
3934 if (RPC_ASSASSINATED(task)) 3954 if (RPC_ASSASSINATED(task))
@@ -4049,10 +4069,16 @@ static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request
4049 if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) 4069 if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0)
4050 return 0; 4070 return 0;
4051 err = _nfs4_do_setlk(state, F_SETLK, request, 0); 4071 err = _nfs4_do_setlk(state, F_SETLK, request, 0);
4052 if (err != -NFS4ERR_DELAY) 4072 switch (err) {
4053 break; 4073 default:
4054 nfs4_handle_exception(server, err, &exception); 4074 goto out;
4075 case -NFS4ERR_GRACE:
4076 case -NFS4ERR_DELAY:
4077 nfs4_handle_exception(server, err, &exception);
4078 err = 0;
4079 }
4055 } while (exception.retry); 4080 } while (exception.retry);
4081out:
4056 return err; 4082 return err;
4057} 4083}
4058 4084
@@ -4172,6 +4198,11 @@ int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl)
4172 case -NFS4ERR_EXPIRED: 4198 case -NFS4ERR_EXPIRED:
4173 case -NFS4ERR_STALE_CLIENTID: 4199 case -NFS4ERR_STALE_CLIENTID:
4174 case -NFS4ERR_STALE_STATEID: 4200 case -NFS4ERR_STALE_STATEID:
4201 case -NFS4ERR_BADSESSION:
4202 case -NFS4ERR_BADSLOT:
4203 case -NFS4ERR_BAD_HIGH_SLOT:
4204 case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION:
4205 case -NFS4ERR_DEADSESSION:
4175 nfs4_schedule_state_recovery(server->nfs_client); 4206 nfs4_schedule_state_recovery(server->nfs_client);
4176 goto out; 4207 goto out;
4177 case -ERESTARTSYS: 4208 case -ERESTARTSYS:
@@ -4296,7 +4327,7 @@ int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name,
4296 * NFS4ERR_BADSESSION in the sequence operation, and will therefore 4327 * NFS4ERR_BADSESSION in the sequence operation, and will therefore
4297 * be in some phase of session reset. 4328 * be in some phase of session reset.
4298 */ 4329 */
4299static int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred) 4330int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred)
4300{ 4331{
4301 nfs4_verifier verifier; 4332 nfs4_verifier verifier;
4302 struct nfs41_exchange_id_args args = { 4333 struct nfs41_exchange_id_args args = {
@@ -4318,6 +4349,9 @@ static int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred)
4318 dprintk("--> %s\n", __func__); 4349 dprintk("--> %s\n", __func__);
4319 BUG_ON(clp == NULL); 4350 BUG_ON(clp == NULL);
4320 4351
4352 /* Remove server-only flags */
4353 args.flags &= ~EXCHGID4_FLAG_CONFIRMED_R;
4354
4321 p = (u32 *)verifier.data; 4355 p = (u32 *)verifier.data;
4322 *p++ = htonl((u32)clp->cl_boot_time.tv_sec); 4356 *p++ = htonl((u32)clp->cl_boot_time.tv_sec);
4323 *p = htonl((u32)clp->cl_boot_time.tv_nsec); 4357 *p = htonl((u32)clp->cl_boot_time.tv_nsec);
@@ -4389,10 +4423,9 @@ static void nfs4_get_lease_time_done(struct rpc_task *task, void *calldata)
4389 dprintk("%s Retry: tk_status %d\n", __func__, task->tk_status); 4423 dprintk("%s Retry: tk_status %d\n", __func__, task->tk_status);
4390 rpc_delay(task, NFS4_POLL_RETRY_MIN); 4424 rpc_delay(task, NFS4_POLL_RETRY_MIN);
4391 task->tk_status = 0; 4425 task->tk_status = 0;
4392 nfs4_restart_rpc(task, data->clp); 4426 nfs_restart_rpc(task, data->clp);
4393 return; 4427 return;
4394 } 4428 }
4395 nfs41_sequence_free_slot(data->clp, &data->res->lr_seq_res);
4396 dprintk("<-- %s\n", __func__); 4429 dprintk("<-- %s\n", __func__);
4397} 4430}
4398 4431
@@ -4465,7 +4498,6 @@ static int nfs4_reset_slot_table(struct nfs4_slot_table *tbl, int max_slots,
4465 spin_lock(&tbl->slot_tbl_lock); 4498 spin_lock(&tbl->slot_tbl_lock);
4466 for (i = 0; i < max_slots; ++i) 4499 for (i = 0; i < max_slots; ++i)
4467 tbl->slots[i].seq_nr = ivalue; 4500 tbl->slots[i].seq_nr = ivalue;
4468 tbl->highest_used_slotid = -1;
4469 spin_unlock(&tbl->slot_tbl_lock); 4501 spin_unlock(&tbl->slot_tbl_lock);
4470 dprintk("%s: tbl=%p slots=%p max_slots=%d\n", __func__, 4502 dprintk("%s: tbl=%p slots=%p max_slots=%d\n", __func__,
4471 tbl, tbl->slots, tbl->max_slots); 4503 tbl, tbl->slots, tbl->max_slots);
@@ -4515,7 +4547,6 @@ static void nfs4_destroy_slot_tables(struct nfs4_session *session)
4515static int nfs4_init_slot_table(struct nfs4_slot_table *tbl, 4547static int nfs4_init_slot_table(struct nfs4_slot_table *tbl,
4516 int max_slots, int ivalue) 4548 int max_slots, int ivalue)
4517{ 4549{
4518 int i;
4519 struct nfs4_slot *slot; 4550 struct nfs4_slot *slot;
4520 int ret = -ENOMEM; 4551 int ret = -ENOMEM;
4521 4552
@@ -4526,18 +4557,9 @@ static int nfs4_init_slot_table(struct nfs4_slot_table *tbl,
4526 slot = kcalloc(max_slots, sizeof(struct nfs4_slot), GFP_KERNEL); 4557 slot = kcalloc(max_slots, sizeof(struct nfs4_slot), GFP_KERNEL);
4527 if (!slot) 4558 if (!slot)
4528 goto out; 4559 goto out;
4529 for (i = 0; i < max_slots; ++i)
4530 slot[i].seq_nr = ivalue;
4531 ret = 0; 4560 ret = 0;
4532 4561
4533 spin_lock(&tbl->slot_tbl_lock); 4562 spin_lock(&tbl->slot_tbl_lock);
4534 if (tbl->slots != NULL) {
4535 spin_unlock(&tbl->slot_tbl_lock);
4536 dprintk("%s: slot table already initialized. tbl=%p slots=%p\n",
4537 __func__, tbl, tbl->slots);
4538 WARN_ON(1);
4539 goto out_free;
4540 }
4541 tbl->max_slots = max_slots; 4563 tbl->max_slots = max_slots;
4542 tbl->slots = slot; 4564 tbl->slots = slot;
4543 tbl->highest_used_slotid = -1; /* no slot is currently used */ 4565 tbl->highest_used_slotid = -1; /* no slot is currently used */
@@ -4547,10 +4569,6 @@ static int nfs4_init_slot_table(struct nfs4_slot_table *tbl,
4547out: 4569out:
4548 dprintk("<-- %s: return %d\n", __func__, ret); 4570 dprintk("<-- %s: return %d\n", __func__, ret);
4549 return ret; 4571 return ret;
4550
4551out_free:
4552 kfree(slot);
4553 goto out;
4554} 4572}
4555 4573
4556/* 4574/*
@@ -4558,17 +4576,24 @@ out_free:
4558 */ 4576 */
4559static int nfs4_init_slot_tables(struct nfs4_session *session) 4577static int nfs4_init_slot_tables(struct nfs4_session *session)
4560{ 4578{
4561 int status; 4579 struct nfs4_slot_table *tbl;
4580 int status = 0;
4562 4581
4563 status = nfs4_init_slot_table(&session->fc_slot_table, 4582 tbl = &session->fc_slot_table;
4564 session->fc_attrs.max_reqs, 1); 4583 if (tbl->slots == NULL) {
4565 if (status) 4584 status = nfs4_init_slot_table(tbl,
4566 return status; 4585 session->fc_attrs.max_reqs, 1);
4586 if (status)
4587 return status;
4588 }
4567 4589
4568 status = nfs4_init_slot_table(&session->bc_slot_table, 4590 tbl = &session->bc_slot_table;
4569 session->bc_attrs.max_reqs, 0); 4591 if (tbl->slots == NULL) {
4570 if (status) 4592 status = nfs4_init_slot_table(tbl,
4571 nfs4_destroy_slot_tables(session); 4593 session->bc_attrs.max_reqs, 0);
4594 if (status)
4595 nfs4_destroy_slot_tables(session);
4596 }
4572 4597
4573 return status; 4598 return status;
4574} 4599}
@@ -4582,7 +4607,6 @@ struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp)
4582 if (!session) 4607 if (!session)
4583 return NULL; 4608 return NULL;
4584 4609
4585 set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state);
4586 /* 4610 /*
4587 * The create session reply races with the server back 4611 * The create session reply races with the server back
4588 * channel probe. Mark the client NFS_CS_SESSION_INITING 4612 * channel probe. Mark the client NFS_CS_SESSION_INITING
@@ -4590,12 +4614,15 @@ struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp)
4590 * nfs_client struct 4614 * nfs_client struct
4591 */ 4615 */
4592 clp->cl_cons_state = NFS_CS_SESSION_INITING; 4616 clp->cl_cons_state = NFS_CS_SESSION_INITING;
4617 init_completion(&session->complete);
4593 4618
4594 tbl = &session->fc_slot_table; 4619 tbl = &session->fc_slot_table;
4620 tbl->highest_used_slotid = -1;
4595 spin_lock_init(&tbl->slot_tbl_lock); 4621 spin_lock_init(&tbl->slot_tbl_lock);
4596 rpc_init_wait_queue(&tbl->slot_tbl_waitq, "ForeChannel Slot table"); 4622 rpc_init_wait_queue(&tbl->slot_tbl_waitq, "ForeChannel Slot table");
4597 4623
4598 tbl = &session->bc_slot_table; 4624 tbl = &session->bc_slot_table;
4625 tbl->highest_used_slotid = -1;
4599 spin_lock_init(&tbl->slot_tbl_lock); 4626 spin_lock_init(&tbl->slot_tbl_lock);
4600 rpc_init_wait_queue(&tbl->slot_tbl_waitq, "BackChannel Slot table"); 4627 rpc_init_wait_queue(&tbl->slot_tbl_waitq, "BackChannel Slot table");
4601 4628
@@ -4747,11 +4774,10 @@ static int _nfs4_proc_create_session(struct nfs_client *clp)
4747 * It is the responsibility of the caller to verify the session is 4774 * It is the responsibility of the caller to verify the session is
4748 * expired before calling this routine. 4775 * expired before calling this routine.
4749 */ 4776 */
4750int nfs4_proc_create_session(struct nfs_client *clp, int reset) 4777int nfs4_proc_create_session(struct nfs_client *clp)
4751{ 4778{
4752 int status; 4779 int status;
4753 unsigned *ptr; 4780 unsigned *ptr;
4754 struct nfs_fsinfo fsinfo;
4755 struct nfs4_session *session = clp->cl_session; 4781 struct nfs4_session *session = clp->cl_session;
4756 4782
4757 dprintk("--> %s clp=%p session=%p\n", __func__, clp, session); 4783 dprintk("--> %s clp=%p session=%p\n", __func__, clp, session);
@@ -4760,35 +4786,19 @@ int nfs4_proc_create_session(struct nfs_client *clp, int reset)
4760 if (status) 4786 if (status)
4761 goto out; 4787 goto out;
4762 4788
4763 /* Init or reset the fore channel */ 4789 /* Init and reset the fore channel */
4764 if (reset) 4790 status = nfs4_init_slot_tables(session);
4765 status = nfs4_reset_slot_tables(session); 4791 dprintk("slot table initialization returned %d\n", status);
4766 else 4792 if (status)
4767 status = nfs4_init_slot_tables(session); 4793 goto out;
4768 dprintk("fore channel slot table initialization returned %d\n", status); 4794 status = nfs4_reset_slot_tables(session);
4795 dprintk("slot table reset returned %d\n", status);
4769 if (status) 4796 if (status)
4770 goto out; 4797 goto out;
4771 4798
4772 ptr = (unsigned *)&session->sess_id.data[0]; 4799 ptr = (unsigned *)&session->sess_id.data[0];
4773 dprintk("%s client>seqid %d sessionid %u:%u:%u:%u\n", __func__, 4800 dprintk("%s client>seqid %d sessionid %u:%u:%u:%u\n", __func__,
4774 clp->cl_seqid, ptr[0], ptr[1], ptr[2], ptr[3]); 4801 clp->cl_seqid, ptr[0], ptr[1], ptr[2], ptr[3]);
4775
4776 if (reset)
4777 /* Lease time is aleady set */
4778 goto out;
4779
4780 /* Get the lease time */
4781 status = nfs4_proc_get_lease_time(clp, &fsinfo);
4782 if (status == 0) {
4783 /* Update lease time and schedule renewal */
4784 spin_lock(&clp->cl_lock);
4785 clp->cl_lease_time = fsinfo.lease_time * HZ;
4786 clp->cl_last_renewal = jiffies;
4787 clear_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
4788 spin_unlock(&clp->cl_lock);
4789
4790 nfs4_schedule_state_renewal(clp);
4791 }
4792out: 4802out:
4793 dprintk("<-- %s\n", __func__); 4803 dprintk("<-- %s\n", __func__);
4794 return status; 4804 return status;
@@ -4827,13 +4837,16 @@ int nfs4_proc_destroy_session(struct nfs4_session *session)
4827int nfs4_init_session(struct nfs_server *server) 4837int nfs4_init_session(struct nfs_server *server)
4828{ 4838{
4829 struct nfs_client *clp = server->nfs_client; 4839 struct nfs_client *clp = server->nfs_client;
4840 struct nfs4_session *session;
4830 int ret; 4841 int ret;
4831 4842
4832 if (!nfs4_has_session(clp)) 4843 if (!nfs4_has_session(clp))
4833 return 0; 4844 return 0;
4834 4845
4835 clp->cl_session->fc_attrs.max_rqst_sz = server->wsize; 4846 session = clp->cl_session;
4836 clp->cl_session->fc_attrs.max_resp_sz = server->rsize; 4847 session->fc_attrs.max_rqst_sz = server->wsize + nfs41_maxwrite_overhead;
4848 session->fc_attrs.max_resp_sz = server->rsize + nfs41_maxread_overhead;
4849
4837 ret = nfs4_recover_expired_lease(server); 4850 ret = nfs4_recover_expired_lease(server);
4838 if (!ret) 4851 if (!ret)
4839 ret = nfs4_check_client_ready(clp); 4852 ret = nfs4_check_client_ready(clp);
@@ -4872,11 +4885,10 @@ void nfs41_sequence_call_done(struct rpc_task *task, void *data)
4872 4885
4873 if (_nfs4_async_handle_error(task, NULL, clp, NULL) 4886 if (_nfs4_async_handle_error(task, NULL, clp, NULL)
4874 == -EAGAIN) { 4887 == -EAGAIN) {
4875 nfs4_restart_rpc(task, clp); 4888 nfs_restart_rpc(task, clp);
4876 return; 4889 return;
4877 } 4890 }
4878 } 4891 }
4879 nfs41_sequence_free_slot(clp, task->tk_msg.rpc_resp);
4880 dprintk("%s rpc_cred %p\n", __func__, task->tk_msg.rpc_cred); 4892 dprintk("%s rpc_cred %p\n", __func__, task->tk_msg.rpc_cred);
4881 4893
4882 kfree(task->tk_msg.rpc_argp); 4894 kfree(task->tk_msg.rpc_argp);
@@ -4931,6 +4943,109 @@ static int nfs41_proc_async_sequence(struct nfs_client *clp,
4931 &nfs41_sequence_ops, (void *)clp); 4943 &nfs41_sequence_ops, (void *)clp);
4932} 4944}
4933 4945
4946struct nfs4_reclaim_complete_data {
4947 struct nfs_client *clp;
4948 struct nfs41_reclaim_complete_args arg;
4949 struct nfs41_reclaim_complete_res res;
4950};
4951
4952static void nfs4_reclaim_complete_prepare(struct rpc_task *task, void *data)
4953{
4954 struct nfs4_reclaim_complete_data *calldata = data;
4955
4956 if (nfs4_setup_sequence(calldata->clp, &calldata->arg.seq_args,
4957 &calldata->res.seq_res, 0, task))
4958 return;
4959
4960 rpc_call_start(task);
4961}
4962
4963static void nfs4_reclaim_complete_done(struct rpc_task *task, void *data)
4964{
4965 struct nfs4_reclaim_complete_data *calldata = data;
4966 struct nfs_client *clp = calldata->clp;
4967 struct nfs4_sequence_res *res = &calldata->res.seq_res;
4968
4969 dprintk("--> %s\n", __func__);
4970 nfs41_sequence_done(clp, res, task->tk_status);
4971 switch (task->tk_status) {
4972 case 0:
4973 case -NFS4ERR_COMPLETE_ALREADY:
4974 break;
4975 case -NFS4ERR_BADSESSION:
4976 case -NFS4ERR_DEADSESSION:
4977 /*
4978 * Handle the session error, but do not retry the operation, as
4979 * we have no way of telling whether the clientid had to be
4980 * reset before we got our reply. If reset, a new wave of
4981 * reclaim operations will follow, containing their own reclaim
4982 * complete. We don't want our retry to get on the way of
4983 * recovery by incorrectly indicating to the server that we're
4984 * done reclaiming state since the process had to be restarted.
4985 */
4986 _nfs4_async_handle_error(task, NULL, clp, NULL);
4987 break;
4988 default:
4989 if (_nfs4_async_handle_error(
4990 task, NULL, clp, NULL) == -EAGAIN) {
4991 rpc_restart_call_prepare(task);
4992 return;
4993 }
4994 }
4995
4996 dprintk("<-- %s\n", __func__);
4997}
4998
4999static void nfs4_free_reclaim_complete_data(void *data)
5000{
5001 struct nfs4_reclaim_complete_data *calldata = data;
5002
5003 kfree(calldata);
5004}
5005
5006static const struct rpc_call_ops nfs4_reclaim_complete_call_ops = {
5007 .rpc_call_prepare = nfs4_reclaim_complete_prepare,
5008 .rpc_call_done = nfs4_reclaim_complete_done,
5009 .rpc_release = nfs4_free_reclaim_complete_data,
5010};
5011
5012/*
5013 * Issue a global reclaim complete.
5014 */
5015static int nfs41_proc_reclaim_complete(struct nfs_client *clp)
5016{
5017 struct nfs4_reclaim_complete_data *calldata;
5018 struct rpc_task *task;
5019 struct rpc_message msg = {
5020 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RECLAIM_COMPLETE],
5021 };
5022 struct rpc_task_setup task_setup_data = {
5023 .rpc_client = clp->cl_rpcclient,
5024 .rpc_message = &msg,
5025 .callback_ops = &nfs4_reclaim_complete_call_ops,
5026 .flags = RPC_TASK_ASYNC,
5027 };
5028 int status = -ENOMEM;
5029
5030 dprintk("--> %s\n", __func__);
5031 calldata = kzalloc(sizeof(*calldata), GFP_KERNEL);
5032 if (calldata == NULL)
5033 goto out;
5034 calldata->clp = clp;
5035 calldata->arg.one_fs = 0;
5036 calldata->res.seq_res.sr_slotid = NFS4_MAX_SLOT_TABLE;
5037
5038 msg.rpc_argp = &calldata->arg;
5039 msg.rpc_resp = &calldata->res;
5040 task_setup_data.callback_data = calldata;
5041 task = rpc_run_task(&task_setup_data);
5042 if (IS_ERR(task))
5043 status = PTR_ERR(task);
5044 rpc_put_task(task);
5045out:
5046 dprintk("<-- %s status=%d\n", __func__, status);
5047 return status;
5048}
4934#endif /* CONFIG_NFS_V4_1 */ 5049#endif /* CONFIG_NFS_V4_1 */
4935 5050
4936struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops = { 5051struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops = {
@@ -4948,8 +5063,9 @@ struct nfs4_state_recovery_ops nfs41_reboot_recovery_ops = {
4948 .state_flag_bit = NFS_STATE_RECLAIM_REBOOT, 5063 .state_flag_bit = NFS_STATE_RECLAIM_REBOOT,
4949 .recover_open = nfs4_open_reclaim, 5064 .recover_open = nfs4_open_reclaim,
4950 .recover_lock = nfs4_lock_reclaim, 5065 .recover_lock = nfs4_lock_reclaim,
4951 .establish_clid = nfs4_proc_exchange_id, 5066 .establish_clid = nfs41_init_clientid,
4952 .get_clid_cred = nfs4_get_exchange_id_cred, 5067 .get_clid_cred = nfs4_get_exchange_id_cred,
5068 .reclaim_complete = nfs41_proc_reclaim_complete,
4953}; 5069};
4954#endif /* CONFIG_NFS_V4_1 */ 5070#endif /* CONFIG_NFS_V4_1 */
4955 5071
@@ -4968,7 +5084,7 @@ struct nfs4_state_recovery_ops nfs41_nograce_recovery_ops = {
4968 .state_flag_bit = NFS_STATE_RECLAIM_NOGRACE, 5084 .state_flag_bit = NFS_STATE_RECLAIM_NOGRACE,
4969 .recover_open = nfs4_open_expired, 5085 .recover_open = nfs4_open_expired,
4970 .recover_lock = nfs4_lock_expired, 5086 .recover_lock = nfs4_lock_expired,
4971 .establish_clid = nfs4_proc_exchange_id, 5087 .establish_clid = nfs41_init_clientid,
4972 .get_clid_cred = nfs4_get_exchange_id_cred, 5088 .get_clid_cred = nfs4_get_exchange_id_cred,
4973}; 5089};
4974#endif /* CONFIG_NFS_V4_1 */ 5090#endif /* CONFIG_NFS_V4_1 */
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 2ef4fecf3984..e76427e6346f 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -116,6 +116,68 @@ struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp)
116 116
117#if defined(CONFIG_NFS_V4_1) 117#if defined(CONFIG_NFS_V4_1)
118 118
119static int nfs41_setup_state_renewal(struct nfs_client *clp)
120{
121 int status;
122 struct nfs_fsinfo fsinfo;
123
124 status = nfs4_proc_get_lease_time(clp, &fsinfo);
125 if (status == 0) {
126 /* Update lease time and schedule renewal */
127 spin_lock(&clp->cl_lock);
128 clp->cl_lease_time = fsinfo.lease_time * HZ;
129 clp->cl_last_renewal = jiffies;
130 spin_unlock(&clp->cl_lock);
131
132 nfs4_schedule_state_renewal(clp);
133 }
134
135 return status;
136}
137
138static void nfs41_end_drain_session(struct nfs_client *clp,
139 struct nfs4_session *ses)
140{
141 if (test_and_clear_bit(NFS4CLNT_SESSION_DRAINING, &clp->cl_state))
142 rpc_wake_up(&ses->fc_slot_table.slot_tbl_waitq);
143}
144
145static int nfs41_begin_drain_session(struct nfs_client *clp,
146 struct nfs4_session *ses)
147{
148 struct nfs4_slot_table *tbl = &ses->fc_slot_table;
149
150 spin_lock(&tbl->slot_tbl_lock);
151 set_bit(NFS4CLNT_SESSION_DRAINING, &clp->cl_state);
152 if (tbl->highest_used_slotid != -1) {
153 INIT_COMPLETION(ses->complete);
154 spin_unlock(&tbl->slot_tbl_lock);
155 return wait_for_completion_interruptible(&ses->complete);
156 }
157 spin_unlock(&tbl->slot_tbl_lock);
158 return 0;
159}
160
161int nfs41_init_clientid(struct nfs_client *clp, struct rpc_cred *cred)
162{
163 int status;
164
165 status = nfs41_begin_drain_session(clp, clp->cl_session);
166 if (status != 0)
167 goto out;
168 status = nfs4_proc_exchange_id(clp, cred);
169 if (status != 0)
170 goto out;
171 status = nfs4_proc_create_session(clp);
172 if (status != 0)
173 goto out;
174 nfs41_end_drain_session(clp, clp->cl_session);
175 nfs41_setup_state_renewal(clp);
176 nfs_mark_client_ready(clp, NFS_CS_READY);
177out:
178 return status;
179}
180
119struct rpc_cred *nfs4_get_exchange_id_cred(struct nfs_client *clp) 181struct rpc_cred *nfs4_get_exchange_id_cred(struct nfs_client *clp)
120{ 182{
121 struct rpc_cred *cred; 183 struct rpc_cred *cred;
@@ -877,6 +939,10 @@ static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_
877 case -NFS4ERR_EXPIRED: 939 case -NFS4ERR_EXPIRED:
878 case -NFS4ERR_NO_GRACE: 940 case -NFS4ERR_NO_GRACE:
879 case -NFS4ERR_STALE_CLIENTID: 941 case -NFS4ERR_STALE_CLIENTID:
942 case -NFS4ERR_BADSESSION:
943 case -NFS4ERR_BADSLOT:
944 case -NFS4ERR_BAD_HIGH_SLOT:
945 case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION:
880 goto out; 946 goto out;
881 default: 947 default:
882 printk(KERN_ERR "%s: unhandled error %d. Zeroing state\n", 948 printk(KERN_ERR "%s: unhandled error %d. Zeroing state\n",
@@ -959,6 +1025,10 @@ restart:
959 case -NFS4ERR_NO_GRACE: 1025 case -NFS4ERR_NO_GRACE:
960 nfs4_state_mark_reclaim_nograce(sp->so_client, state); 1026 nfs4_state_mark_reclaim_nograce(sp->so_client, state);
961 case -NFS4ERR_STALE_CLIENTID: 1027 case -NFS4ERR_STALE_CLIENTID:
1028 case -NFS4ERR_BADSESSION:
1029 case -NFS4ERR_BADSLOT:
1030 case -NFS4ERR_BAD_HIGH_SLOT:
1031 case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION:
962 goto out_err; 1032 goto out_err;
963 } 1033 }
964 nfs4_put_open_state(state); 1034 nfs4_put_open_state(state);
@@ -1011,6 +1081,14 @@ static void nfs4_state_start_reclaim_reboot(struct nfs_client *clp)
1011 nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_reboot); 1081 nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_reboot);
1012} 1082}
1013 1083
1084static void nfs4_reclaim_complete(struct nfs_client *clp,
1085 const struct nfs4_state_recovery_ops *ops)
1086{
1087 /* Notify the server we're done reclaiming our state */
1088 if (ops->reclaim_complete)
1089 (void)ops->reclaim_complete(clp);
1090}
1091
1014static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp) 1092static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp)
1015{ 1093{
1016 struct nfs4_state_owner *sp; 1094 struct nfs4_state_owner *sp;
@@ -1020,6 +1098,9 @@ static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp)
1020 if (!test_and_clear_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) 1098 if (!test_and_clear_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state))
1021 return; 1099 return;
1022 1100
1101 nfs4_reclaim_complete(clp,
1102 nfs4_reboot_recovery_ops[clp->cl_minorversion]);
1103
1023 for (pos = rb_first(&clp->cl_state_owners); pos != NULL; pos = rb_next(pos)) { 1104 for (pos = rb_first(&clp->cl_state_owners); pos != NULL; pos = rb_next(pos)) {
1024 sp = rb_entry(pos, struct nfs4_state_owner, so_client_node); 1105 sp = rb_entry(pos, struct nfs4_state_owner, so_client_node);
1025 spin_lock(&sp->so_lock); 1106 spin_lock(&sp->so_lock);
@@ -1046,25 +1127,25 @@ static void nfs4_state_start_reclaim_nograce(struct nfs_client *clp)
1046 nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_nograce); 1127 nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_nograce);
1047} 1128}
1048 1129
1049static void nfs4_state_end_reclaim_nograce(struct nfs_client *clp) 1130static int nfs4_recovery_handle_error(struct nfs_client *clp, int error)
1050{
1051 clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state);
1052}
1053
1054static void nfs4_recovery_handle_error(struct nfs_client *clp, int error)
1055{ 1131{
1056 switch (error) { 1132 switch (error) {
1057 case -NFS4ERR_CB_PATH_DOWN: 1133 case -NFS4ERR_CB_PATH_DOWN:
1058 nfs_handle_cb_pathdown(clp); 1134 nfs_handle_cb_pathdown(clp);
1059 break; 1135 return 0;
1136 case -NFS4ERR_NO_GRACE:
1137 nfs4_state_end_reclaim_reboot(clp);
1138 return 0;
1060 case -NFS4ERR_STALE_CLIENTID: 1139 case -NFS4ERR_STALE_CLIENTID:
1061 case -NFS4ERR_LEASE_MOVED: 1140 case -NFS4ERR_LEASE_MOVED:
1062 set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); 1141 set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
1142 nfs4_state_end_reclaim_reboot(clp);
1063 nfs4_state_start_reclaim_reboot(clp); 1143 nfs4_state_start_reclaim_reboot(clp);
1064 break; 1144 break;
1065 case -NFS4ERR_EXPIRED: 1145 case -NFS4ERR_EXPIRED:
1066 set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); 1146 set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
1067 nfs4_state_start_reclaim_nograce(clp); 1147 nfs4_state_start_reclaim_nograce(clp);
1148 break;
1068 case -NFS4ERR_BADSESSION: 1149 case -NFS4ERR_BADSESSION:
1069 case -NFS4ERR_BADSLOT: 1150 case -NFS4ERR_BADSLOT:
1070 case -NFS4ERR_BAD_HIGH_SLOT: 1151 case -NFS4ERR_BAD_HIGH_SLOT:
@@ -1072,8 +1153,11 @@ static void nfs4_recovery_handle_error(struct nfs_client *clp, int error)
1072 case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: 1153 case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION:
1073 case -NFS4ERR_SEQ_FALSE_RETRY: 1154 case -NFS4ERR_SEQ_FALSE_RETRY:
1074 case -NFS4ERR_SEQ_MISORDERED: 1155 case -NFS4ERR_SEQ_MISORDERED:
1075 set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); 1156 set_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state);
1157 /* Zero session reset errors */
1158 return 0;
1076 } 1159 }
1160 return error;
1077} 1161}
1078 1162
1079static int nfs4_do_reclaim(struct nfs_client *clp, const struct nfs4_state_recovery_ops *ops) 1163static int nfs4_do_reclaim(struct nfs_client *clp, const struct nfs4_state_recovery_ops *ops)
@@ -1093,8 +1177,7 @@ restart:
1093 if (status < 0) { 1177 if (status < 0) {
1094 set_bit(ops->owner_flag_bit, &sp->so_flags); 1178 set_bit(ops->owner_flag_bit, &sp->so_flags);
1095 nfs4_put_state_owner(sp); 1179 nfs4_put_state_owner(sp);
1096 nfs4_recovery_handle_error(clp, status); 1180 return nfs4_recovery_handle_error(clp, status);
1097 return status;
1098 } 1181 }
1099 nfs4_put_state_owner(sp); 1182 nfs4_put_state_owner(sp);
1100 goto restart; 1183 goto restart;
@@ -1124,8 +1207,7 @@ static int nfs4_check_lease(struct nfs_client *clp)
1124 status = ops->renew_lease(clp, cred); 1207 status = ops->renew_lease(clp, cred);
1125 put_rpccred(cred); 1208 put_rpccred(cred);
1126out: 1209out:
1127 nfs4_recovery_handle_error(clp, status); 1210 return nfs4_recovery_handle_error(clp, status);
1128 return status;
1129} 1211}
1130 1212
1131static int nfs4_reclaim_lease(struct nfs_client *clp) 1213static int nfs4_reclaim_lease(struct nfs_client *clp)
@@ -1151,55 +1233,65 @@ static int nfs4_reclaim_lease(struct nfs_client *clp)
1151} 1233}
1152 1234
1153#ifdef CONFIG_NFS_V4_1 1235#ifdef CONFIG_NFS_V4_1
1154static void nfs4_session_recovery_handle_error(struct nfs_client *clp, int err) 1236void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags)
1155{ 1237{
1156 switch (err) { 1238 if (!flags)
1157 case -NFS4ERR_STALE_CLIENTID: 1239 return;
1240 else if (flags & SEQ4_STATUS_RESTART_RECLAIM_NEEDED) {
1158 set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); 1241 set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
1159 set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); 1242 nfs4_state_start_reclaim_reboot(clp);
1160 } 1243 nfs4_schedule_state_recovery(clp);
1244 } else if (flags & (SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED |
1245 SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED |
1246 SEQ4_STATUS_ADMIN_STATE_REVOKED |
1247 SEQ4_STATUS_RECALLABLE_STATE_REVOKED |
1248 SEQ4_STATUS_LEASE_MOVED)) {
1249 set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
1250 nfs4_state_start_reclaim_nograce(clp);
1251 nfs4_schedule_state_recovery(clp);
1252 } else if (flags & (SEQ4_STATUS_CB_PATH_DOWN |
1253 SEQ4_STATUS_BACKCHANNEL_FAULT |
1254 SEQ4_STATUS_CB_PATH_DOWN_SESSION))
1255 nfs_expire_all_delegations(clp);
1161} 1256}
1162 1257
1163static int nfs4_reset_session(struct nfs_client *clp) 1258static int nfs4_reset_session(struct nfs_client *clp)
1164{ 1259{
1260 struct nfs4_session *ses = clp->cl_session;
1165 int status; 1261 int status;
1166 1262
1263 status = nfs41_begin_drain_session(clp, ses);
1264 if (status != 0)
1265 return status;
1266
1167 status = nfs4_proc_destroy_session(clp->cl_session); 1267 status = nfs4_proc_destroy_session(clp->cl_session);
1168 if (status && status != -NFS4ERR_BADSESSION && 1268 if (status && status != -NFS4ERR_BADSESSION &&
1169 status != -NFS4ERR_DEADSESSION) { 1269 status != -NFS4ERR_DEADSESSION) {
1170 nfs4_session_recovery_handle_error(clp, status); 1270 status = nfs4_recovery_handle_error(clp, status);
1171 goto out; 1271 goto out;
1172 } 1272 }
1173 1273
1174 memset(clp->cl_session->sess_id.data, 0, NFS4_MAX_SESSIONID_LEN); 1274 memset(clp->cl_session->sess_id.data, 0, NFS4_MAX_SESSIONID_LEN);
1175 status = nfs4_proc_create_session(clp, 1); 1275 status = nfs4_proc_create_session(clp);
1176 if (status) 1276 if (status)
1177 nfs4_session_recovery_handle_error(clp, status); 1277 status = nfs4_recovery_handle_error(clp, status);
1178 /* fall through*/
1179out:
1180 /* Wake up the next rpc task even on error */
1181 rpc_wake_up_next(&clp->cl_session->fc_slot_table.slot_tbl_waitq);
1182 return status;
1183}
1184
1185static int nfs4_initialize_session(struct nfs_client *clp)
1186{
1187 int status;
1188 1278
1189 status = nfs4_proc_create_session(clp, 0); 1279out:
1190 if (!status) { 1280 /*
1191 nfs_mark_client_ready(clp, NFS_CS_READY); 1281 * Let the state manager reestablish state
1192 } else if (status == -NFS4ERR_STALE_CLIENTID) { 1282 * without waking other tasks yet.
1193 set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); 1283 */
1194 set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); 1284 if (!test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) {
1195 } else { 1285 /* Wake up the next rpc task */
1196 nfs_mark_client_ready(clp, status); 1286 nfs41_end_drain_session(clp, ses);
1287 if (status == 0)
1288 nfs41_setup_state_renewal(clp);
1197 } 1289 }
1198 return status; 1290 return status;
1199} 1291}
1292
1200#else /* CONFIG_NFS_V4_1 */ 1293#else /* CONFIG_NFS_V4_1 */
1201static int nfs4_reset_session(struct nfs_client *clp) { return 0; } 1294static int nfs4_reset_session(struct nfs_client *clp) { return 0; }
1202static int nfs4_initialize_session(struct nfs_client *clp) { return 0; }
1203#endif /* CONFIG_NFS_V4_1 */ 1295#endif /* CONFIG_NFS_V4_1 */
1204 1296
1205/* Set NFS4CLNT_LEASE_EXPIRED for all v4.0 errors and for recoverable errors 1297/* Set NFS4CLNT_LEASE_EXPIRED for all v4.0 errors and for recoverable errors
@@ -1234,7 +1326,8 @@ static void nfs4_state_manager(struct nfs_client *clp)
1234 status = nfs4_reclaim_lease(clp); 1326 status = nfs4_reclaim_lease(clp);
1235 if (status) { 1327 if (status) {
1236 nfs4_set_lease_expired(clp, status); 1328 nfs4_set_lease_expired(clp, status);
1237 if (status == -EAGAIN) 1329 if (test_bit(NFS4CLNT_LEASE_EXPIRED,
1330 &clp->cl_state))
1238 continue; 1331 continue;
1239 if (clp->cl_cons_state == 1332 if (clp->cl_cons_state ==
1240 NFS_CS_SESSION_INITING) 1333 NFS_CS_SESSION_INITING)
@@ -1242,55 +1335,51 @@ static void nfs4_state_manager(struct nfs_client *clp)
1242 goto out_error; 1335 goto out_error;
1243 } 1336 }
1244 clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state); 1337 clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state);
1338 set_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state);
1245 } 1339 }
1246 1340
1247 if (test_and_clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state)) { 1341 if (test_and_clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state)) {
1248 status = nfs4_check_lease(clp); 1342 status = nfs4_check_lease(clp);
1249 if (status != 0) 1343 if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state))
1250 continue; 1344 continue;
1345 if (status < 0 && status != -NFS4ERR_CB_PATH_DOWN)
1346 goto out_error;
1251 } 1347 }
1348
1252 /* Initialize or reset the session */ 1349 /* Initialize or reset the session */
1253 if (test_and_clear_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state) 1350 if (test_and_clear_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state)
1254 && nfs4_has_session(clp)) { 1351 && nfs4_has_session(clp)) {
1255 if (clp->cl_cons_state == NFS_CS_SESSION_INITING) 1352 status = nfs4_reset_session(clp);
1256 status = nfs4_initialize_session(clp); 1353 if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state))
1257 else 1354 continue;
1258 status = nfs4_reset_session(clp); 1355 if (status < 0)
1259 if (status) {
1260 if (status == -NFS4ERR_STALE_CLIENTID)
1261 continue;
1262 goto out_error; 1356 goto out_error;
1263 }
1264 } 1357 }
1358
1265 /* First recover reboot state... */ 1359 /* First recover reboot state... */
1266 if (test_and_clear_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) { 1360 if (test_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) {
1267 status = nfs4_do_reclaim(clp, 1361 status = nfs4_do_reclaim(clp,
1268 nfs4_reboot_recovery_ops[clp->cl_minorversion]); 1362 nfs4_reboot_recovery_ops[clp->cl_minorversion]);
1269 if (status == -NFS4ERR_STALE_CLIENTID) 1363 if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) ||
1270 continue; 1364 test_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state))
1271 if (test_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state))
1272 continue; 1365 continue;
1273 nfs4_state_end_reclaim_reboot(clp); 1366 nfs4_state_end_reclaim_reboot(clp);
1274 continue; 1367 if (test_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state))
1368 continue;
1369 if (status < 0)
1370 goto out_error;
1275 } 1371 }
1276 1372
1277 /* Now recover expired state... */ 1373 /* Now recover expired state... */
1278 if (test_and_clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state)) { 1374 if (test_and_clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state)) {
1279 status = nfs4_do_reclaim(clp, 1375 status = nfs4_do_reclaim(clp,
1280 nfs4_nograce_recovery_ops[clp->cl_minorversion]); 1376 nfs4_nograce_recovery_ops[clp->cl_minorversion]);
1281 if (status < 0) { 1377 if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) ||
1282 set_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state); 1378 test_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state) ||
1283 if (status == -NFS4ERR_STALE_CLIENTID) 1379 test_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state))
1284 continue; 1380 continue;
1285 if (status == -NFS4ERR_EXPIRED) 1381 if (status < 0)
1286 continue;
1287 if (test_bit(NFS4CLNT_SESSION_SETUP,
1288 &clp->cl_state))
1289 continue;
1290 goto out_error; 1382 goto out_error;
1291 } else
1292 nfs4_state_end_reclaim_nograce(clp);
1293 continue;
1294 } 1383 }
1295 1384
1296 if (test_and_clear_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) { 1385 if (test_and_clear_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) {
@@ -1309,8 +1398,6 @@ static void nfs4_state_manager(struct nfs_client *clp)
1309out_error: 1398out_error:
1310 printk(KERN_WARNING "Error: state manager failed on NFSv4 server %s" 1399 printk(KERN_WARNING "Error: state manager failed on NFSv4 server %s"
1311 " with error %d\n", clp->cl_hostname, -status); 1400 " with error %d\n", clp->cl_hostname, -status);
1312 if (test_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state))
1313 nfs4_state_end_reclaim_reboot(clp);
1314 nfs4_clear_state_manager_bit(clp); 1401 nfs4_clear_state_manager_bit(clp);
1315} 1402}
1316 1403
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 20b4e30e6c82..e437fd6a819f 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -46,11 +46,13 @@
46#include <linux/proc_fs.h> 46#include <linux/proc_fs.h>
47#include <linux/kdev_t.h> 47#include <linux/kdev_t.h>
48#include <linux/sunrpc/clnt.h> 48#include <linux/sunrpc/clnt.h>
49#include <linux/sunrpc/msg_prot.h>
49#include <linux/nfs.h> 50#include <linux/nfs.h>
50#include <linux/nfs4.h> 51#include <linux/nfs4.h>
51#include <linux/nfs_fs.h> 52#include <linux/nfs_fs.h>
52#include <linux/nfs_idmap.h> 53#include <linux/nfs_idmap.h>
53#include "nfs4_fs.h" 54#include "nfs4_fs.h"
55#include "internal.h"
54 56
55#define NFSDBG_FACILITY NFSDBG_XDR 57#define NFSDBG_FACILITY NFSDBG_XDR
56 58
@@ -134,7 +136,7 @@ static int nfs4_stat_to_errno(int);
134#define decode_lookup_maxsz (op_decode_hdr_maxsz) 136#define decode_lookup_maxsz (op_decode_hdr_maxsz)
135#define encode_share_access_maxsz \ 137#define encode_share_access_maxsz \
136 (2) 138 (2)
137#define encode_createmode_maxsz (1 + encode_attrs_maxsz) 139#define encode_createmode_maxsz (1 + encode_attrs_maxsz + encode_verifier_maxsz)
138#define encode_opentype_maxsz (1 + encode_createmode_maxsz) 140#define encode_opentype_maxsz (1 + encode_createmode_maxsz)
139#define encode_claim_null_maxsz (1 + nfs4_name_maxsz) 141#define encode_claim_null_maxsz (1 + nfs4_name_maxsz)
140#define encode_open_maxsz (op_encode_hdr_maxsz + \ 142#define encode_open_maxsz (op_encode_hdr_maxsz + \
@@ -299,6 +301,8 @@ static int nfs4_stat_to_errno(int);
299 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4) 301 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4)
300#define decode_sequence_maxsz (op_decode_hdr_maxsz + \ 302#define decode_sequence_maxsz (op_decode_hdr_maxsz + \
301 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) 303 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5)
304#define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4)
305#define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4)
302#else /* CONFIG_NFS_V4_1 */ 306#else /* CONFIG_NFS_V4_1 */
303#define encode_sequence_maxsz 0 307#define encode_sequence_maxsz 0
304#define decode_sequence_maxsz 0 308#define decode_sequence_maxsz 0
@@ -676,6 +680,25 @@ static int nfs4_stat_to_errno(int);
676 decode_sequence_maxsz + \ 680 decode_sequence_maxsz + \
677 decode_putrootfh_maxsz + \ 681 decode_putrootfh_maxsz + \
678 decode_fsinfo_maxsz) 682 decode_fsinfo_maxsz)
683#define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \
684 encode_sequence_maxsz + \
685 encode_reclaim_complete_maxsz)
686#define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \
687 decode_sequence_maxsz + \
688 decode_reclaim_complete_maxsz)
689
690const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH +
691 compound_encode_hdr_maxsz +
692 encode_sequence_maxsz +
693 encode_putfh_maxsz +
694 encode_getattr_maxsz) *
695 XDR_UNIT);
696
697const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH +
698 compound_decode_hdr_maxsz +
699 decode_sequence_maxsz +
700 decode_putfh_maxsz) *
701 XDR_UNIT);
679#endif /* CONFIG_NFS_V4_1 */ 702#endif /* CONFIG_NFS_V4_1 */
680 703
681static const umode_t nfs_type2fmt[] = { 704static const umode_t nfs_type2fmt[] = {
@@ -1140,6 +1163,7 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena
1140static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) 1163static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg)
1141{ 1164{
1142 __be32 *p; 1165 __be32 *p;
1166 struct nfs_client *clp;
1143 1167
1144 p = reserve_space(xdr, 4); 1168 p = reserve_space(xdr, 4);
1145 switch(arg->open_flags & O_EXCL) { 1169 switch(arg->open_flags & O_EXCL) {
@@ -1148,8 +1172,23 @@ static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_op
1148 encode_attrs(xdr, arg->u.attrs, arg->server); 1172 encode_attrs(xdr, arg->u.attrs, arg->server);
1149 break; 1173 break;
1150 default: 1174 default:
1151 *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); 1175 clp = arg->server->nfs_client;
1152 encode_nfs4_verifier(xdr, &arg->u.verifier); 1176 if (clp->cl_minorversion > 0) {
1177 if (nfs4_has_persistent_session(clp)) {
1178 *p = cpu_to_be32(NFS4_CREATE_GUARDED);
1179 encode_attrs(xdr, arg->u.attrs, arg->server);
1180 } else {
1181 struct iattr dummy;
1182
1183 *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1);
1184 encode_nfs4_verifier(xdr, &arg->u.verifier);
1185 dummy.ia_valid = 0;
1186 encode_attrs(xdr, &dummy, arg->server);
1187 }
1188 } else {
1189 *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE);
1190 encode_nfs4_verifier(xdr, &arg->u.verifier);
1191 }
1153 } 1192 }
1154} 1193}
1155 1194
@@ -1592,6 +1631,19 @@ static void encode_destroy_session(struct xdr_stream *xdr,
1592 hdr->nops++; 1631 hdr->nops++;
1593 hdr->replen += decode_destroy_session_maxsz; 1632 hdr->replen += decode_destroy_session_maxsz;
1594} 1633}
1634
1635static void encode_reclaim_complete(struct xdr_stream *xdr,
1636 struct nfs41_reclaim_complete_args *args,
1637 struct compound_hdr *hdr)
1638{
1639 __be32 *p;
1640
1641 p = reserve_space(xdr, 8);
1642 *p++ = cpu_to_be32(OP_RECLAIM_COMPLETE);
1643 *p++ = cpu_to_be32(args->one_fs);
1644 hdr->nops++;
1645 hdr->replen += decode_reclaim_complete_maxsz;
1646}
1595#endif /* CONFIG_NFS_V4_1 */ 1647#endif /* CONFIG_NFS_V4_1 */
1596 1648
1597static void encode_sequence(struct xdr_stream *xdr, 1649static void encode_sequence(struct xdr_stream *xdr,
@@ -2096,7 +2148,7 @@ nfs4_xdr_enc_getacl(struct rpc_rqst *req, __be32 *p,
2096 encode_compound_hdr(&xdr, req, &hdr); 2148 encode_compound_hdr(&xdr, req, &hdr);
2097 encode_sequence(&xdr, &args->seq_args, &hdr); 2149 encode_sequence(&xdr, &args->seq_args, &hdr);
2098 encode_putfh(&xdr, args->fh, &hdr); 2150 encode_putfh(&xdr, args->fh, &hdr);
2099 replen = hdr.replen + nfs4_fattr_bitmap_maxsz + 1; 2151 replen = hdr.replen + op_decode_hdr_maxsz + nfs4_fattr_bitmap_maxsz + 1;
2100 encode_getattr_two(&xdr, FATTR4_WORD0_ACL, 0, &hdr); 2152 encode_getattr_two(&xdr, FATTR4_WORD0_ACL, 0, &hdr);
2101 2153
2102 xdr_inline_pages(&req->rq_rcv_buf, replen << 2, 2154 xdr_inline_pages(&req->rq_rcv_buf, replen << 2,
@@ -2420,6 +2472,26 @@ static int nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, uint32_t *p,
2420 encode_nops(&hdr); 2472 encode_nops(&hdr);
2421 return 0; 2473 return 0;
2422} 2474}
2475
2476/*
2477 * a RECLAIM_COMPLETE request
2478 */
2479static int nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, uint32_t *p,
2480 struct nfs41_reclaim_complete_args *args)
2481{
2482 struct xdr_stream xdr;
2483 struct compound_hdr hdr = {
2484 .minorversion = nfs4_xdr_minorversion(&args->seq_args)
2485 };
2486
2487 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2488 encode_compound_hdr(&xdr, req, &hdr);
2489 encode_sequence(&xdr, &args->seq_args, &hdr);
2490 encode_reclaim_complete(&xdr, args, &hdr);
2491 encode_nops(&hdr);
2492 return 0;
2493}
2494
2423#endif /* CONFIG_NFS_V4_1 */ 2495#endif /* CONFIG_NFS_V4_1 */
2424 2496
2425static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) 2497static void print_overflow_msg(const char *func, const struct xdr_stream *xdr)
@@ -4528,6 +4600,11 @@ static int decode_destroy_session(struct xdr_stream *xdr, void *dummy)
4528{ 4600{
4529 return decode_op_hdr(xdr, OP_DESTROY_SESSION); 4601 return decode_op_hdr(xdr, OP_DESTROY_SESSION);
4530} 4602}
4603
4604static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy)
4605{
4606 return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE);
4607}
4531#endif /* CONFIG_NFS_V4_1 */ 4608#endif /* CONFIG_NFS_V4_1 */
4532 4609
4533static int decode_sequence(struct xdr_stream *xdr, 4610static int decode_sequence(struct xdr_stream *xdr,
@@ -4583,8 +4660,8 @@ static int decode_sequence(struct xdr_stream *xdr,
4583 dummy = be32_to_cpup(p++); 4660 dummy = be32_to_cpup(p++);
4584 /* target highest slot id - currently not processed */ 4661 /* target highest slot id - currently not processed */
4585 dummy = be32_to_cpup(p++); 4662 dummy = be32_to_cpup(p++);
4586 /* result flags - currently not processed */ 4663 /* result flags */
4587 dummy = be32_to_cpup(p); 4664 res->sr_status_flags = be32_to_cpup(p);
4588 status = 0; 4665 status = 0;
4589out_err: 4666out_err:
4590 res->sr_status = status; 4667 res->sr_status = status;
@@ -5309,7 +5386,7 @@ out:
5309} 5386}
5310 5387
5311/* 5388/*
5312 * FSINFO request 5389 * Decode FSINFO response
5313 */ 5390 */
5314static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, __be32 *p, 5391static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, __be32 *p,
5315 struct nfs4_fsinfo_res *res) 5392 struct nfs4_fsinfo_res *res)
@@ -5330,7 +5407,7 @@ static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, __be32 *p,
5330} 5407}
5331 5408
5332/* 5409/*
5333 * PATHCONF request 5410 * Decode PATHCONF response
5334 */ 5411 */
5335static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, __be32 *p, 5412static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, __be32 *p,
5336 struct nfs4_pathconf_res *res) 5413 struct nfs4_pathconf_res *res)
@@ -5351,7 +5428,7 @@ static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, __be32 *p,
5351} 5428}
5352 5429
5353/* 5430/*
5354 * STATFS request 5431 * Decode STATFS response
5355 */ 5432 */
5356static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, __be32 *p, 5433static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, __be32 *p,
5357 struct nfs4_statfs_res *res) 5434 struct nfs4_statfs_res *res)
@@ -5372,7 +5449,7 @@ static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, __be32 *p,
5372} 5449}
5373 5450
5374/* 5451/*
5375 * GETATTR_BITMAP request 5452 * Decode GETATTR_BITMAP response
5376 */ 5453 */
5377static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, __be32 *p, struct nfs4_server_caps_res *res) 5454static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, __be32 *p, struct nfs4_server_caps_res *res)
5378{ 5455{
@@ -5411,7 +5488,7 @@ static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, __be32 *p, void *dummy)
5411} 5488}
5412 5489
5413/* 5490/*
5414 * a SETCLIENTID request 5491 * Decode SETCLIENTID response
5415 */ 5492 */
5416static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p, 5493static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p,
5417 struct nfs_client *clp) 5494 struct nfs_client *clp)
@@ -5428,7 +5505,7 @@ static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p,
5428} 5505}
5429 5506
5430/* 5507/*
5431 * a SETCLIENTID_CONFIRM request 5508 * Decode SETCLIENTID_CONFIRM response
5432 */ 5509 */
5433static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *fsinfo) 5510static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *fsinfo)
5434{ 5511{
@@ -5448,7 +5525,7 @@ static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, __be32 *p, str
5448} 5525}
5449 5526
5450/* 5527/*
5451 * DELEGRETURN request 5528 * Decode DELEGRETURN response
5452 */ 5529 */
5453static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_delegreturnres *res) 5530static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_delegreturnres *res)
5454{ 5531{
@@ -5474,7 +5551,7 @@ out:
5474} 5551}
5475 5552
5476/* 5553/*
5477 * FS_LOCATIONS request 5554 * Decode FS_LOCATIONS response
5478 */ 5555 */
5479static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, __be32 *p, 5556static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, __be32 *p,
5480 struct nfs4_fs_locations_res *res) 5557 struct nfs4_fs_locations_res *res)
@@ -5504,7 +5581,7 @@ out:
5504 5581
5505#if defined(CONFIG_NFS_V4_1) 5582#if defined(CONFIG_NFS_V4_1)
5506/* 5583/*
5507 * EXCHANGE_ID request 5584 * Decode EXCHANGE_ID response
5508 */ 5585 */
5509static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, uint32_t *p, 5586static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, uint32_t *p,
5510 void *res) 5587 void *res)
@@ -5521,7 +5598,7 @@ static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, uint32_t *p,
5521} 5598}
5522 5599
5523/* 5600/*
5524 * a CREATE_SESSION request 5601 * Decode CREATE_SESSION response
5525 */ 5602 */
5526static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, uint32_t *p, 5603static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, uint32_t *p,
5527 struct nfs41_create_session_res *res) 5604 struct nfs41_create_session_res *res)
@@ -5538,7 +5615,7 @@ static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, uint32_t *p,
5538} 5615}
5539 5616
5540/* 5617/*
5541 * a DESTROY_SESSION request 5618 * Decode DESTROY_SESSION response
5542 */ 5619 */
5543static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, uint32_t *p, 5620static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, uint32_t *p,
5544 void *dummy) 5621 void *dummy)
@@ -5555,7 +5632,7 @@ static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, uint32_t *p,
5555} 5632}
5556 5633
5557/* 5634/*
5558 * a SEQUENCE request 5635 * Decode SEQUENCE response
5559 */ 5636 */
5560static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, uint32_t *p, 5637static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, uint32_t *p,
5561 struct nfs4_sequence_res *res) 5638 struct nfs4_sequence_res *res)
@@ -5572,7 +5649,7 @@ static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, uint32_t *p,
5572} 5649}
5573 5650
5574/* 5651/*
5575 * a GET_LEASE_TIME request 5652 * Decode GET_LEASE_TIME response
5576 */ 5653 */
5577static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, uint32_t *p, 5654static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, uint32_t *p,
5578 struct nfs4_get_lease_time_res *res) 5655 struct nfs4_get_lease_time_res *res)
@@ -5591,6 +5668,25 @@ static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, uint32_t *p,
5591 status = decode_fsinfo(&xdr, res->lr_fsinfo); 5668 status = decode_fsinfo(&xdr, res->lr_fsinfo);
5592 return status; 5669 return status;
5593} 5670}
5671
5672/*
5673 * Decode RECLAIM_COMPLETE response
5674 */
5675static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, uint32_t *p,
5676 struct nfs41_reclaim_complete_res *res)
5677{
5678 struct xdr_stream xdr;
5679 struct compound_hdr hdr;
5680 int status;
5681
5682 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5683 status = decode_compound_hdr(&xdr, &hdr);
5684 if (!status)
5685 status = decode_sequence(&xdr, &res->seq_res, rqstp);
5686 if (!status)
5687 status = decode_reclaim_complete(&xdr, (void *)NULL);
5688 return status;
5689}
5594#endif /* CONFIG_NFS_V4_1 */ 5690#endif /* CONFIG_NFS_V4_1 */
5595 5691
5596__be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus) 5692__be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus)
@@ -5767,6 +5863,7 @@ struct rpc_procinfo nfs4_procedures[] = {
5767 PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), 5863 PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session),
5768 PROC(SEQUENCE, enc_sequence, dec_sequence), 5864 PROC(SEQUENCE, enc_sequence, dec_sequence),
5769 PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), 5865 PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time),
5866 PROC(RECLAIM_COMPLETE, enc_reclaim_complete, dec_reclaim_complete),
5770#endif /* CONFIG_NFS_V4_1 */ 5867#endif /* CONFIG_NFS_V4_1 */
5771}; 5868};
5772 5869
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 12c9e66d3f1d..db9b360ae19d 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -356,25 +356,19 @@ static void nfs_readpage_retry(struct rpc_task *task, struct nfs_read_data *data
356 struct nfs_readres *resp = &data->res; 356 struct nfs_readres *resp = &data->res;
357 357
358 if (resp->eof || resp->count == argp->count) 358 if (resp->eof || resp->count == argp->count)
359 goto out; 359 return;
360 360
361 /* This is a short read! */ 361 /* This is a short read! */
362 nfs_inc_stats(data->inode, NFSIOS_SHORTREAD); 362 nfs_inc_stats(data->inode, NFSIOS_SHORTREAD);
363 /* Has the server at least made some progress? */ 363 /* Has the server at least made some progress? */
364 if (resp->count == 0) 364 if (resp->count == 0)
365 goto out; 365 return;
366 366
367 /* Yes, so retry the read at the end of the data */ 367 /* Yes, so retry the read at the end of the data */
368 argp->offset += resp->count; 368 argp->offset += resp->count;
369 argp->pgbase += resp->count; 369 argp->pgbase += resp->count;
370 argp->count -= resp->count; 370 argp->count -= resp->count;
371 nfs4_restart_rpc(task, NFS_SERVER(data->inode)->nfs_client); 371 nfs_restart_rpc(task, NFS_SERVER(data->inode)->nfs_client);
372 return;
373out:
374 nfs4_sequence_free_slot(NFS_SERVER(data->inode)->nfs_client,
375 &data->res.seq_res);
376 return;
377
378} 372}
379 373
380/* 374/*
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 90be551b80c1..ce907efc5508 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -175,14 +175,16 @@ static const match_table_t nfs_mount_option_tokens = {
175}; 175};
176 176
177enum { 177enum {
178 Opt_xprt_udp, Opt_xprt_tcp, Opt_xprt_rdma, 178 Opt_xprt_udp, Opt_xprt_udp6, Opt_xprt_tcp, Opt_xprt_tcp6, Opt_xprt_rdma,
179 179
180 Opt_xprt_err 180 Opt_xprt_err
181}; 181};
182 182
183static const match_table_t nfs_xprt_protocol_tokens = { 183static const match_table_t nfs_xprt_protocol_tokens = {
184 { Opt_xprt_udp, "udp" }, 184 { Opt_xprt_udp, "udp" },
185 { Opt_xprt_udp6, "udp6" },
185 { Opt_xprt_tcp, "tcp" }, 186 { Opt_xprt_tcp, "tcp" },
187 { Opt_xprt_tcp6, "tcp6" },
186 { Opt_xprt_rdma, "rdma" }, 188 { Opt_xprt_rdma, "rdma" },
187 189
188 { Opt_xprt_err, NULL } 190 { Opt_xprt_err, NULL }
@@ -492,6 +494,45 @@ static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour)
492 return sec_flavours[i].str; 494 return sec_flavours[i].str;
493} 495}
494 496
497static void nfs_show_mountd_netid(struct seq_file *m, struct nfs_server *nfss,
498 int showdefaults)
499{
500 struct sockaddr *sap = (struct sockaddr *) &nfss->mountd_address;
501
502 seq_printf(m, ",mountproto=");
503 switch (sap->sa_family) {
504 case AF_INET:
505 switch (nfss->mountd_protocol) {
506 case IPPROTO_UDP:
507 seq_printf(m, RPCBIND_NETID_UDP);
508 break;
509 case IPPROTO_TCP:
510 seq_printf(m, RPCBIND_NETID_TCP);
511 break;
512 default:
513 if (showdefaults)
514 seq_printf(m, "auto");
515 }
516 break;
517 case AF_INET6:
518 switch (nfss->mountd_protocol) {
519 case IPPROTO_UDP:
520 seq_printf(m, RPCBIND_NETID_UDP6);
521 break;
522 case IPPROTO_TCP:
523 seq_printf(m, RPCBIND_NETID_TCP6);
524 break;
525 default:
526 if (showdefaults)
527 seq_printf(m, "auto");
528 }
529 break;
530 default:
531 if (showdefaults)
532 seq_printf(m, "auto");
533 }
534}
535
495static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss, 536static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss,
496 int showdefaults) 537 int showdefaults)
497{ 538{
@@ -505,7 +546,7 @@ static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss,
505 } 546 }
506 case AF_INET6: { 547 case AF_INET6: {
507 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; 548 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
508 seq_printf(m, ",mountaddr=%pI6", &sin6->sin6_addr); 549 seq_printf(m, ",mountaddr=%pI6c", &sin6->sin6_addr);
509 break; 550 break;
510 } 551 }
511 default: 552 default:
@@ -518,17 +559,7 @@ static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss,
518 if (nfss->mountd_port || showdefaults) 559 if (nfss->mountd_port || showdefaults)
519 seq_printf(m, ",mountport=%u", nfss->mountd_port); 560 seq_printf(m, ",mountport=%u", nfss->mountd_port);
520 561
521 switch (nfss->mountd_protocol) { 562 nfs_show_mountd_netid(m, nfss, showdefaults);
522 case IPPROTO_UDP:
523 seq_printf(m, ",mountproto=udp");
524 break;
525 case IPPROTO_TCP:
526 seq_printf(m, ",mountproto=tcp");
527 break;
528 default:
529 if (showdefaults)
530 seq_printf(m, ",mountproto=auto");
531 }
532} 563}
533 564
534/* 565/*
@@ -578,7 +609,7 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
578 seq_puts(m, nfs_infop->nostr); 609 seq_puts(m, nfs_infop->nostr);
579 } 610 }
580 seq_printf(m, ",proto=%s", 611 seq_printf(m, ",proto=%s",
581 rpc_peeraddr2str(nfss->client, RPC_DISPLAY_PROTO)); 612 rpc_peeraddr2str(nfss->client, RPC_DISPLAY_NETID));
582 if (version == 4) { 613 if (version == 4) {
583 if (nfss->port != NFS_PORT) 614 if (nfss->port != NFS_PORT)
584 seq_printf(m, ",port=%u", nfss->port); 615 seq_printf(m, ",port=%u", nfss->port);
@@ -714,8 +745,6 @@ static void nfs_umount_begin(struct super_block *sb)
714 struct nfs_server *server; 745 struct nfs_server *server;
715 struct rpc_clnt *rpc; 746 struct rpc_clnt *rpc;
716 747
717 lock_kernel();
718
719 server = NFS_SB(sb); 748 server = NFS_SB(sb);
720 /* -EIO all pending I/O */ 749 /* -EIO all pending I/O */
721 rpc = server->client_acl; 750 rpc = server->client_acl;
@@ -724,8 +753,6 @@ static void nfs_umount_begin(struct super_block *sb)
724 rpc = server->client; 753 rpc = server->client;
725 if (!IS_ERR(rpc)) 754 if (!IS_ERR(rpc))
726 rpc_killall_tasks(rpc); 755 rpc_killall_tasks(rpc);
727
728 unlock_kernel();
729} 756}
730 757
731static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(unsigned int version) 758static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(unsigned int version)
@@ -734,8 +761,6 @@ static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(unsigned int ve
734 761
735 data = kzalloc(sizeof(*data), GFP_KERNEL); 762 data = kzalloc(sizeof(*data), GFP_KERNEL);
736 if (data) { 763 if (data) {
737 data->rsize = NFS_MAX_FILE_IO_SIZE;
738 data->wsize = NFS_MAX_FILE_IO_SIZE;
739 data->acregmin = NFS_DEF_ACREGMIN; 764 data->acregmin = NFS_DEF_ACREGMIN;
740 data->acregmax = NFS_DEF_ACREGMAX; 765 data->acregmax = NFS_DEF_ACREGMAX;
741 data->acdirmin = NFS_DEF_ACDIRMIN; 766 data->acdirmin = NFS_DEF_ACDIRMIN;
@@ -887,6 +912,8 @@ static int nfs_parse_mount_options(char *raw,
887{ 912{
888 char *p, *string, *secdata; 913 char *p, *string, *secdata;
889 int rc, sloppy = 0, invalid_option = 0; 914 int rc, sloppy = 0, invalid_option = 0;
915 unsigned short protofamily = AF_UNSPEC;
916 unsigned short mountfamily = AF_UNSPEC;
890 917
891 if (!raw) { 918 if (!raw) {
892 dfprintk(MOUNT, "NFS: mount options string was NULL.\n"); 919 dfprintk(MOUNT, "NFS: mount options string was NULL.\n");
@@ -1232,12 +1259,17 @@ static int nfs_parse_mount_options(char *raw,
1232 token = match_token(string, 1259 token = match_token(string,
1233 nfs_xprt_protocol_tokens, args); 1260 nfs_xprt_protocol_tokens, args);
1234 1261
1262 protofamily = AF_INET;
1235 switch (token) { 1263 switch (token) {
1264 case Opt_xprt_udp6:
1265 protofamily = AF_INET6;
1236 case Opt_xprt_udp: 1266 case Opt_xprt_udp:
1237 mnt->flags &= ~NFS_MOUNT_TCP; 1267 mnt->flags &= ~NFS_MOUNT_TCP;
1238 mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; 1268 mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP;
1239 kfree(string); 1269 kfree(string);
1240 break; 1270 break;
1271 case Opt_xprt_tcp6:
1272 protofamily = AF_INET6;
1241 case Opt_xprt_tcp: 1273 case Opt_xprt_tcp:
1242 mnt->flags |= NFS_MOUNT_TCP; 1274 mnt->flags |= NFS_MOUNT_TCP;
1243 mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; 1275 mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
@@ -1265,10 +1297,15 @@ static int nfs_parse_mount_options(char *raw,
1265 nfs_xprt_protocol_tokens, args); 1297 nfs_xprt_protocol_tokens, args);
1266 kfree(string); 1298 kfree(string);
1267 1299
1300 mountfamily = AF_INET;
1268 switch (token) { 1301 switch (token) {
1302 case Opt_xprt_udp6:
1303 mountfamily = AF_INET6;
1269 case Opt_xprt_udp: 1304 case Opt_xprt_udp:
1270 mnt->mount_server.protocol = XPRT_TRANSPORT_UDP; 1305 mnt->mount_server.protocol = XPRT_TRANSPORT_UDP;
1271 break; 1306 break;
1307 case Opt_xprt_tcp6:
1308 mountfamily = AF_INET6;
1272 case Opt_xprt_tcp: 1309 case Opt_xprt_tcp:
1273 mnt->mount_server.protocol = XPRT_TRANSPORT_TCP; 1310 mnt->mount_server.protocol = XPRT_TRANSPORT_TCP;
1274 break; 1311 break;
@@ -1367,8 +1404,33 @@ static int nfs_parse_mount_options(char *raw,
1367 if (!sloppy && invalid_option) 1404 if (!sloppy && invalid_option)
1368 return 0; 1405 return 0;
1369 1406
1407 /*
1408 * verify that any proto=/mountproto= options match the address
1409 * familiies in the addr=/mountaddr= options.
1410 */
1411 if (protofamily != AF_UNSPEC &&
1412 protofamily != mnt->nfs_server.address.ss_family)
1413 goto out_proto_mismatch;
1414
1415 if (mountfamily != AF_UNSPEC) {
1416 if (mnt->mount_server.addrlen) {
1417 if (mountfamily != mnt->mount_server.address.ss_family)
1418 goto out_mountproto_mismatch;
1419 } else {
1420 if (mountfamily != mnt->nfs_server.address.ss_family)
1421 goto out_mountproto_mismatch;
1422 }
1423 }
1424
1370 return 1; 1425 return 1;
1371 1426
1427out_mountproto_mismatch:
1428 printk(KERN_INFO "NFS: mount server address does not match mountproto= "
1429 "option\n");
1430 return 0;
1431out_proto_mismatch:
1432 printk(KERN_INFO "NFS: server address does not match proto= option\n");
1433 return 0;
1372out_invalid_address: 1434out_invalid_address:
1373 printk(KERN_INFO "NFS: bad IP address specified: %s\n", p); 1435 printk(KERN_INFO "NFS: bad IP address specified: %s\n", p);
1374 return 0; 1436 return 0;
@@ -1881,7 +1943,6 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data)
1881 if (data == NULL) 1943 if (data == NULL)
1882 return -ENOMEM; 1944 return -ENOMEM;
1883 1945
1884 lock_kernel();
1885 /* fill out struct with values from existing mount */ 1946 /* fill out struct with values from existing mount */
1886 data->flags = nfss->flags; 1947 data->flags = nfss->flags;
1887 data->rsize = nfss->rsize; 1948 data->rsize = nfss->rsize;
@@ -1907,7 +1968,6 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data)
1907 error = nfs_compare_remount_data(nfss, data); 1968 error = nfs_compare_remount_data(nfss, data);
1908out: 1969out:
1909 kfree(data); 1970 kfree(data);
1910 unlock_kernel();
1911 return error; 1971 return error;
1912} 1972}
1913 1973
diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c
index 1064c91ae810..6da3d3ff6edd 100644
--- a/fs/nfs/unlink.c
+++ b/fs/nfs/unlink.c
@@ -83,7 +83,7 @@ static void nfs_async_unlink_done(struct rpc_task *task, void *calldata)
83 struct inode *dir = data->dir; 83 struct inode *dir = data->dir;
84 84
85 if (!NFS_PROTO(dir)->unlink_done(task, dir)) 85 if (!NFS_PROTO(dir)->unlink_done(task, dir))
86 nfs4_restart_rpc(task, NFS_SERVER(dir)->nfs_client); 86 nfs_restart_rpc(task, NFS_SERVER(dir)->nfs_client);
87} 87}
88 88
89/** 89/**
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index b1ce2ea9b93b..d171696017f4 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1216,7 +1216,7 @@ int nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data)
1216 */ 1216 */
1217 argp->stable = NFS_FILE_SYNC; 1217 argp->stable = NFS_FILE_SYNC;
1218 } 1218 }
1219 nfs4_restart_rpc(task, server->nfs_client); 1219 nfs_restart_rpc(task, server->nfs_client);
1220 return -EAGAIN; 1220 return -EAGAIN;
1221 } 1221 }
1222 if (time_before(complain, jiffies)) { 1222 if (time_before(complain, jiffies)) {
@@ -1228,7 +1228,6 @@ int nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data)
1228 /* Can't do anything about it except throw an error. */ 1228 /* Can't do anything about it except throw an error. */
1229 task->tk_status = -EIO; 1229 task->tk_status = -EIO;
1230 } 1230 }
1231 nfs4_sequence_free_slot(server->nfs_client, &data->res.seq_res);
1232 return 0; 1231 return 0;
1233} 1232}
1234 1233
@@ -1612,15 +1611,16 @@ int nfs_migrate_page(struct address_space *mapping, struct page *newpage,
1612 if (ret) 1611 if (ret)
1613 goto out_unlock; 1612 goto out_unlock;
1614 page_cache_get(newpage); 1613 page_cache_get(newpage);
1614 spin_lock(&mapping->host->i_lock);
1615 req->wb_page = newpage; 1615 req->wb_page = newpage;
1616 SetPagePrivate(newpage); 1616 SetPagePrivate(newpage);
1617 set_page_private(newpage, page_private(page)); 1617 set_page_private(newpage, (unsigned long)req);
1618 ClearPagePrivate(page); 1618 ClearPagePrivate(page);
1619 set_page_private(page, 0); 1619 set_page_private(page, 0);
1620 spin_unlock(&mapping->host->i_lock);
1620 page_cache_release(page); 1621 page_cache_release(page);
1621out_unlock: 1622out_unlock:
1622 nfs_clear_page_tag_locked(req); 1623 nfs_clear_page_tag_locked(req);
1623 nfs_release_request(req);
1624out: 1624out:
1625 return ret; 1625 return ret;
1626} 1626}
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index 1e068535b58b..82372e332f08 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -440,7 +440,7 @@ static void udf_table_free_blocks(struct super_block *sb,
440 (bloc->logicalBlockNum + count) > 440 (bloc->logicalBlockNum + count) >
441 partmap->s_partition_len) { 441 partmap->s_partition_len) {
442 udf_debug("%d < %d || %d + %d > %d\n", 442 udf_debug("%d < %d || %d + %d > %d\n",
443 bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count, 443 bloc->logicalBlockNum, 0, bloc->logicalBlockNum, count,
444 partmap->s_partition_len); 444 partmap->s_partition_len);
445 goto error_return; 445 goto error_return;
446 } 446 }
diff --git a/fs/udf/file.c b/fs/udf/file.c
index b80cbd78833c..f311d509b6a3 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -196,6 +196,7 @@ static int udf_release_file(struct inode *inode, struct file *filp)
196 mutex_lock(&inode->i_mutex); 196 mutex_lock(&inode->i_mutex);
197 lock_kernel(); 197 lock_kernel();
198 udf_discard_prealloc(inode); 198 udf_discard_prealloc(inode);
199 udf_truncate_tail_extent(inode);
199 unlock_kernel(); 200 unlock_kernel();
200 mutex_unlock(&inode->i_mutex); 201 mutex_unlock(&inode->i_mutex);
201 } 202 }
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 6d24c2c63f93..f90231eb2916 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -97,15 +97,17 @@ no_delete:
97 */ 97 */
98void udf_clear_inode(struct inode *inode) 98void udf_clear_inode(struct inode *inode)
99{ 99{
100 struct udf_inode_info *iinfo; 100 struct udf_inode_info *iinfo = UDF_I(inode);
101 if (!(inode->i_sb->s_flags & MS_RDONLY)) { 101
102 lock_kernel(); 102 if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB &&
103 udf_truncate_tail_extent(inode); 103 inode->i_size != iinfo->i_lenExtents) {
104 unlock_kernel(); 104 printk(KERN_WARNING "UDF-fs (%s): Inode %lu (mode %o) has "
105 write_inode_now(inode, 0); 105 "inode size %llu different from extent lenght %llu. "
106 invalidate_inode_buffers(inode); 106 "Filesystem need not be standards compliant.\n",
107 inode->i_sb->s_id, inode->i_ino, inode->i_mode,
108 (unsigned long long)inode->i_size,
109 (unsigned long long)iinfo->i_lenExtents);
107 } 110 }
108 iinfo = UDF_I(inode);
109 kfree(iinfo->i_ext.i_data); 111 kfree(iinfo->i_ext.i_data);
110 iinfo->i_ext.i_data = NULL; 112 iinfo->i_ext.i_data = NULL;
111} 113}
@@ -198,7 +200,6 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block,
198 int newblock; 200 int newblock;
199 struct buffer_head *dbh = NULL; 201 struct buffer_head *dbh = NULL;
200 struct kernel_lb_addr eloc; 202 struct kernel_lb_addr eloc;
201 uint32_t elen;
202 uint8_t alloctype; 203 uint8_t alloctype;
203 struct extent_position epos; 204 struct extent_position epos;
204 205
@@ -273,12 +274,11 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block,
273 eloc.logicalBlockNum = *block; 274 eloc.logicalBlockNum = *block;
274 eloc.partitionReferenceNum = 275 eloc.partitionReferenceNum =
275 iinfo->i_location.partitionReferenceNum; 276 iinfo->i_location.partitionReferenceNum;
276 elen = inode->i_sb->s_blocksize; 277 iinfo->i_lenExtents = inode->i_size;
277 iinfo->i_lenExtents = elen;
278 epos.bh = NULL; 278 epos.bh = NULL;
279 epos.block = iinfo->i_location; 279 epos.block = iinfo->i_location;
280 epos.offset = udf_file_entry_alloc_offset(inode); 280 epos.offset = udf_file_entry_alloc_offset(inode);
281 udf_add_aext(inode, &epos, &eloc, elen, 0); 281 udf_add_aext(inode, &epos, &eloc, inode->i_size, 0);
282 /* UniqueID stuff */ 282 /* UniqueID stuff */
283 283
284 brelse(epos.bh); 284 brelse(epos.bh);
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 21dad8c608f9..cd2115060fdc 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -408,15 +408,6 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
408 } 408 }
409 409
410add: 410add:
411 /* Is there any extent whose size we need to round up? */
412 if (dinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB && elen) {
413 elen = (elen + sb->s_blocksize - 1) & ~(sb->s_blocksize - 1);
414 if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
415 epos.offset -= sizeof(struct short_ad);
416 else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
417 epos.offset -= sizeof(struct long_ad);
418 udf_write_aext(dir, &epos, &eloc, elen, 1);
419 }
420 f_pos += nfidlen; 411 f_pos += nfidlen;
421 412
422 if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB && 413 if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB &&
@@ -439,6 +430,7 @@ add:
439 udf_current_aext(dir, &epos, &eloc, &elen, 1); 430 udf_current_aext(dir, &epos, &eloc, &elen, 1);
440 } 431 }
441 432
433 /* Entry fits into current block? */
442 if (sb->s_blocksize - fibh->eoffset >= nfidlen) { 434 if (sb->s_blocksize - fibh->eoffset >= nfidlen) {
443 fibh->soffset = fibh->eoffset; 435 fibh->soffset = fibh->eoffset;
444 fibh->eoffset += nfidlen; 436 fibh->eoffset += nfidlen;
@@ -462,6 +454,16 @@ add:
462 (fibh->sbh->b_data + fibh->soffset); 454 (fibh->sbh->b_data + fibh->soffset);
463 } 455 }
464 } else { 456 } else {
457 /* Round up last extent in the file */
458 elen = (elen + sb->s_blocksize - 1) & ~(sb->s_blocksize - 1);
459 if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
460 epos.offset -= sizeof(struct short_ad);
461 else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
462 epos.offset -= sizeof(struct long_ad);
463 udf_write_aext(dir, &epos, &eloc, elen, 1);
464 dinfo->i_lenExtents = (dinfo->i_lenExtents + sb->s_blocksize
465 - 1) & ~(sb->s_blocksize - 1);
466
465 fibh->soffset = fibh->eoffset - sb->s_blocksize; 467 fibh->soffset = fibh->eoffset - sb->s_blocksize;
466 fibh->eoffset += nfidlen - sb->s_blocksize; 468 fibh->eoffset += nfidlen - sb->s_blocksize;
467 if (fibh->sbh != fibh->ebh) { 469 if (fibh->sbh != fibh->ebh) {
@@ -508,6 +510,20 @@ add:
508 dir->i_size += nfidlen; 510 dir->i_size += nfidlen;
509 if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) 511 if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB)
510 dinfo->i_lenAlloc += nfidlen; 512 dinfo->i_lenAlloc += nfidlen;
513 else {
514 /* Find the last extent and truncate it to proper size */
515 while (udf_next_aext(dir, &epos, &eloc, &elen, 1) ==
516 (EXT_RECORDED_ALLOCATED >> 30))
517 ;
518 elen -= dinfo->i_lenExtents - dir->i_size;
519 if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
520 epos.offset -= sizeof(struct short_ad);
521 else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
522 epos.offset -= sizeof(struct long_ad);
523 udf_write_aext(dir, &epos, &eloc, elen, 1);
524 dinfo->i_lenExtents = dir->i_size;
525 }
526
511 mark_inode_dirty(dir); 527 mark_inode_dirty(dir);
512 goto out_ok; 528 goto out_ok;
513 } else { 529 } else {
@@ -922,7 +938,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
922 block = udf_get_pblock(inode->i_sb, block, 938 block = udf_get_pblock(inode->i_sb, block,
923 iinfo->i_location.partitionReferenceNum, 939 iinfo->i_location.partitionReferenceNum,
924 0); 940 0);
925 epos.bh = udf_tread(inode->i_sb, block); 941 epos.bh = udf_tgetblk(inode->i_sb, block);
926 lock_buffer(epos.bh); 942 lock_buffer(epos.bh);
927 memset(epos.bh->b_data, 0x00, inode->i_sb->s_blocksize); 943 memset(epos.bh->b_data, 0x00, inode->i_sb->s_blocksize);
928 set_buffer_uptodate(epos.bh); 944 set_buffer_uptodate(epos.bh);
@@ -999,6 +1015,8 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
999 inode->i_size = elen; 1015 inode->i_size = elen;
1000 if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) 1016 if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB)
1001 iinfo->i_lenAlloc = inode->i_size; 1017 iinfo->i_lenAlloc = inode->i_size;
1018 else
1019 udf_truncate_tail_extent(inode);
1002 mark_inode_dirty(inode); 1020 mark_inode_dirty(inode);
1003 1021
1004 fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); 1022 fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err);
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 9d1b8c2e6c45..1e4543cbcd27 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1078,21 +1078,39 @@ static int udf_fill_partdesc_info(struct super_block *sb,
1078 return 0; 1078 return 0;
1079} 1079}
1080 1080
1081static int udf_load_vat(struct super_block *sb, int p_index, int type1_index) 1081static void udf_find_vat_block(struct super_block *sb, int p_index,
1082 int type1_index, sector_t start_block)
1082{ 1083{
1083 struct udf_sb_info *sbi = UDF_SB(sb); 1084 struct udf_sb_info *sbi = UDF_SB(sb);
1084 struct udf_part_map *map = &sbi->s_partmaps[p_index]; 1085 struct udf_part_map *map = &sbi->s_partmaps[p_index];
1086 sector_t vat_block;
1085 struct kernel_lb_addr ino; 1087 struct kernel_lb_addr ino;
1088
1089 /*
1090 * VAT file entry is in the last recorded block. Some broken disks have
1091 * it a few blocks before so try a bit harder...
1092 */
1093 ino.partitionReferenceNum = type1_index;
1094 for (vat_block = start_block;
1095 vat_block >= map->s_partition_root &&
1096 vat_block >= start_block - 3 &&
1097 !sbi->s_vat_inode; vat_block--) {
1098 ino.logicalBlockNum = vat_block - map->s_partition_root;
1099 sbi->s_vat_inode = udf_iget(sb, &ino);
1100 }
1101}
1102
1103static int udf_load_vat(struct super_block *sb, int p_index, int type1_index)
1104{
1105 struct udf_sb_info *sbi = UDF_SB(sb);
1106 struct udf_part_map *map = &sbi->s_partmaps[p_index];
1086 struct buffer_head *bh = NULL; 1107 struct buffer_head *bh = NULL;
1087 struct udf_inode_info *vati; 1108 struct udf_inode_info *vati;
1088 uint32_t pos; 1109 uint32_t pos;
1089 struct virtualAllocationTable20 *vat20; 1110 struct virtualAllocationTable20 *vat20;
1090 sector_t blocks = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits; 1111 sector_t blocks = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits;
1091 1112
1092 /* VAT file entry is in the last recorded block */ 1113 udf_find_vat_block(sb, p_index, type1_index, sbi->s_last_block);
1093 ino.partitionReferenceNum = type1_index;
1094 ino.logicalBlockNum = sbi->s_last_block - map->s_partition_root;
1095 sbi->s_vat_inode = udf_iget(sb, &ino);
1096 if (!sbi->s_vat_inode && 1114 if (!sbi->s_vat_inode &&
1097 sbi->s_last_block != blocks - 1) { 1115 sbi->s_last_block != blocks - 1) {
1098 printk(KERN_NOTICE "UDF-fs: Failed to read VAT inode from the" 1116 printk(KERN_NOTICE "UDF-fs: Failed to read VAT inode from the"
@@ -1100,9 +1118,7 @@ static int udf_load_vat(struct super_block *sb, int p_index, int type1_index)
1100 "block of the device (%lu).\n", 1118 "block of the device (%lu).\n",
1101 (unsigned long)sbi->s_last_block, 1119 (unsigned long)sbi->s_last_block,
1102 (unsigned long)blocks - 1); 1120 (unsigned long)blocks - 1);
1103 ino.partitionReferenceNum = type1_index; 1121 udf_find_vat_block(sb, p_index, type1_index, blocks - 1);
1104 ino.logicalBlockNum = blocks - 1 - map->s_partition_root;
1105 sbi->s_vat_inode = udf_iget(sb, &ino);
1106 } 1122 }
1107 if (!sbi->s_vat_inode) 1123 if (!sbi->s_vat_inode)
1108 return 1; 1124 return 1;
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 66a888a9ad6f..bfffd6334abb 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -2389,12 +2389,12 @@ xfs_icsb_modify_counters(
2389{ 2389{
2390 xfs_icsb_cnts_t *icsbp; 2390 xfs_icsb_cnts_t *icsbp;
2391 long long lcounter; /* long counter for 64 bit fields */ 2391 long long lcounter; /* long counter for 64 bit fields */
2392 int cpu, ret = 0; 2392 int ret = 0;
2393 2393
2394 might_sleep(); 2394 might_sleep();
2395again: 2395again:
2396 cpu = get_cpu(); 2396 preempt_disable();
2397 icsbp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, cpu); 2397 icsbp = this_cpu_ptr(mp->m_sb_cnts);
2398 2398
2399 /* 2399 /*
2400 * if the counter is disabled, go to slow path 2400 * if the counter is disabled, go to slow path
@@ -2438,11 +2438,11 @@ again:
2438 break; 2438 break;
2439 } 2439 }
2440 xfs_icsb_unlock_cntr(icsbp); 2440 xfs_icsb_unlock_cntr(icsbp);
2441 put_cpu(); 2441 preempt_enable();
2442 return 0; 2442 return 0;
2443 2443
2444slow_path: 2444slow_path:
2445 put_cpu(); 2445 preempt_enable();
2446 2446
2447 /* 2447 /*
2448 * serialise with a mutex so we don't burn lots of cpu on 2448 * serialise with a mutex so we don't burn lots of cpu on
@@ -2490,7 +2490,7 @@ slow_path:
2490 2490
2491balance_counter: 2491balance_counter:
2492 xfs_icsb_unlock_cntr(icsbp); 2492 xfs_icsb_unlock_cntr(icsbp);
2493 put_cpu(); 2493 preempt_enable();
2494 2494
2495 /* 2495 /*
2496 * We may have multiple threads here if multiple per-cpu 2496 * We may have multiple threads here if multiple per-cpu
diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h
index 90079c373f1c..8087b90d4673 100644
--- a/include/asm-generic/percpu.h
+++ b/include/asm-generic/percpu.h
@@ -56,6 +56,9 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
56#define __raw_get_cpu_var(var) \ 56#define __raw_get_cpu_var(var) \
57 (*SHIFT_PERCPU_PTR(&per_cpu_var(var), __my_cpu_offset)) 57 (*SHIFT_PERCPU_PTR(&per_cpu_var(var), __my_cpu_offset))
58 58
59#define this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, my_cpu_offset)
60#define __this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset)
61
59 62
60#ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA 63#ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA
61extern void setup_per_cpu_areas(void); 64extern void setup_per_cpu_areas(void);
@@ -66,6 +69,8 @@ extern void setup_per_cpu_areas(void);
66#define per_cpu(var, cpu) (*((void)(cpu), &per_cpu_var(var))) 69#define per_cpu(var, cpu) (*((void)(cpu), &per_cpu_var(var)))
67#define __get_cpu_var(var) per_cpu_var(var) 70#define __get_cpu_var(var) per_cpu_var(var)
68#define __raw_get_cpu_var(var) per_cpu_var(var) 71#define __raw_get_cpu_var(var) per_cpu_var(var)
72#define this_cpu_ptr(ptr) per_cpu_ptr(ptr, 0)
73#define __this_cpu_ptr(ptr) this_cpu_ptr(ptr)
69 74
70#endif /* SMP */ 75#endif /* SMP */
71 76
diff --git a/include/linux/hw_breakpoint.h b/include/linux/hw_breakpoint.h
index 69f07a9f1277..41235c93e4e9 100644
--- a/include/linux/hw_breakpoint.h
+++ b/include/linux/hw_breakpoint.h
@@ -93,7 +93,7 @@ register_user_hw_breakpoint(struct perf_event_attr *attr,
93 struct task_struct *tsk) { return NULL; } 93 struct task_struct *tsk) { return NULL; }
94static inline int 94static inline int
95modify_user_hw_breakpoint(struct perf_event *bp, 95modify_user_hw_breakpoint(struct perf_event *bp,
96 struct perf_event_attr *attr) { return NULL; } 96 struct perf_event_attr *attr) { return -ENOSYS; }
97static inline struct perf_event * 97static inline struct perf_event *
98register_wide_hw_breakpoint_cpu(struct perf_event_attr *attr, 98register_wide_hw_breakpoint_cpu(struct perf_event_attr *attr,
99 perf_overflow_handler_t triggered, 99 perf_overflow_handler_t triggered,
diff --git a/include/linux/i2c/tps65010.h b/include/linux/i2c/tps65010.h
index 918c5354d9b8..08aa92278d71 100644
--- a/include/linux/i2c/tps65010.h
+++ b/include/linux/i2c/tps65010.h
@@ -72,6 +72,21 @@
72#define TPS_VDCDC1 0x0c 72#define TPS_VDCDC1 0x0c
73# define TPS_ENABLE_LP (1 << 3) 73# define TPS_ENABLE_LP (1 << 3)
74#define TPS_VDCDC2 0x0d 74#define TPS_VDCDC2 0x0d
75# define TPS_LP_COREOFF (1 << 7)
76# define TPS_VCORE_1_8V (7<<4)
77# define TPS_VCORE_1_5V (6 << 4)
78# define TPS_VCORE_1_4V (5 << 4)
79# define TPS_VCORE_1_3V (4 << 4)
80# define TPS_VCORE_1_2V (3 << 4)
81# define TPS_VCORE_1_1V (2 << 4)
82# define TPS_VCORE_1_0V (1 << 4)
83# define TPS_VCORE_0_85V (0 << 4)
84# define TPS_VCORE_LP_1_2V (3 << 2)
85# define TPS_VCORE_LP_1_1V (2 << 2)
86# define TPS_VCORE_LP_1_0V (1 << 2)
87# define TPS_VCORE_LP_0_85V (0 << 2)
88# define TPS_VIB (1 << 1)
89# define TPS_VCORE_DISCH (1 << 0)
75#define TPS_VREGS1 0x0e 90#define TPS_VREGS1 0x0e
76# define TPS_LDO2_ENABLE (1 << 7) 91# define TPS_LDO2_ENABLE (1 << 7)
77# define TPS_LDO2_OFF (1 << 6) 92# define TPS_LDO2_OFF (1 << 6)
@@ -152,6 +167,10 @@ extern int tps65010_config_vregs1(unsigned value);
152 */ 167 */
153extern int tps65013_set_low_pwr(unsigned mode); 168extern int tps65013_set_low_pwr(unsigned mode);
154 169
170/* tps65010_set_vdcdc2
171 * value to be written to VDCDC2
172 */
173extern int tps65010_config_vdcdc2(unsigned value);
155 174
156struct i2c_client; 175struct i2c_client;
157 176
diff --git a/include/linux/i2c/twl4030.h b/include/linux/i2c/twl.h
index 5306a759cbde..bf1c5be1f5b6 100644
--- a/include/linux/i2c/twl4030.h
+++ b/include/linux/i2c/twl.h
@@ -22,8 +22,8 @@
22 * 22 *
23 */ 23 */
24 24
25#ifndef __TWL4030_H_ 25#ifndef __TWL_H_
26#define __TWL4030_H_ 26#define __TWL_H_
27 27
28#include <linux/types.h> 28#include <linux/types.h>
29#include <linux/input/matrix_keypad.h> 29#include <linux/input/matrix_keypad.h>
@@ -61,28 +61,112 @@
61#define TWL4030_MODULE_PWMA 0x0E 61#define TWL4030_MODULE_PWMA 0x0E
62#define TWL4030_MODULE_PWMB 0x0F 62#define TWL4030_MODULE_PWMB 0x0F
63 63
64#define TWL5031_MODULE_ACCESSORY 0x10
65#define TWL5031_MODULE_INTERRUPTS 0x11
66
64/* Slave 3 (i2c address 0x4b) */ 67/* Slave 3 (i2c address 0x4b) */
65#define TWL4030_MODULE_BACKUP 0x10 68#define TWL4030_MODULE_BACKUP 0x12
66#define TWL4030_MODULE_INT 0x11 69#define TWL4030_MODULE_INT 0x13
67#define TWL4030_MODULE_PM_MASTER 0x12 70#define TWL4030_MODULE_PM_MASTER 0x14
68#define TWL4030_MODULE_PM_RECEIVER 0x13 71#define TWL4030_MODULE_PM_RECEIVER 0x15
69#define TWL4030_MODULE_RTC 0x14 72#define TWL4030_MODULE_RTC 0x16
70#define TWL4030_MODULE_SECURED_REG 0x15 73#define TWL4030_MODULE_SECURED_REG 0x17
74
75#define TWL_MODULE_USB TWL4030_MODULE_USB
76#define TWL_MODULE_AUDIO_VOICE TWL4030_MODULE_AUDIO_VOICE
77#define TWL_MODULE_PIH TWL4030_MODULE_PIH
78#define TWL_MODULE_MADC TWL4030_MODULE_MADC
79#define TWL_MODULE_MAIN_CHARGE TWL4030_MODULE_MAIN_CHARGE
80#define TWL_MODULE_PM_MASTER TWL4030_MODULE_PM_MASTER
81#define TWL_MODULE_PM_RECEIVER TWL4030_MODULE_PM_RECEIVER
82#define TWL_MODULE_RTC TWL4030_MODULE_RTC
83
84#define GPIO_INTR_OFFSET 0
85#define KEYPAD_INTR_OFFSET 1
86#define BCI_INTR_OFFSET 2
87#define MADC_INTR_OFFSET 3
88#define USB_INTR_OFFSET 4
89#define BCI_PRES_INTR_OFFSET 9
90#define USB_PRES_INTR_OFFSET 10
91#define RTC_INTR_OFFSET 11
92
93/*
94 * Offset from TWL6030_IRQ_BASE / pdata->irq_base
95 */
96#define PWR_INTR_OFFSET 0
97#define HOTDIE_INTR_OFFSET 12
98#define SMPSLDO_INTR_OFFSET 13
99#define BATDETECT_INTR_OFFSET 14
100#define SIMDETECT_INTR_OFFSET 15
101#define MMCDETECT_INTR_OFFSET 16
102#define GASGAUGE_INTR_OFFSET 17
103#define USBOTG_INTR_OFFSET 4
104#define CHARGER_INTR_OFFSET 2
105#define RSV_INTR_OFFSET 0
106
107/* INT register offsets */
108#define REG_INT_STS_A 0x00
109#define REG_INT_STS_B 0x01
110#define REG_INT_STS_C 0x02
111
112#define REG_INT_MSK_LINE_A 0x03
113#define REG_INT_MSK_LINE_B 0x04
114#define REG_INT_MSK_LINE_C 0x05
115
116#define REG_INT_MSK_STS_A 0x06
117#define REG_INT_MSK_STS_B 0x07
118#define REG_INT_MSK_STS_C 0x08
119
120/* MASK INT REG GROUP A */
121#define TWL6030_PWR_INT_MASK 0x07
122#define TWL6030_RTC_INT_MASK 0x18
123#define TWL6030_HOTDIE_INT_MASK 0x20
124#define TWL6030_SMPSLDOA_INT_MASK 0xC0
125
126/* MASK INT REG GROUP B */
127#define TWL6030_SMPSLDOB_INT_MASK 0x01
128#define TWL6030_BATDETECT_INT_MASK 0x02
129#define TWL6030_SIMDETECT_INT_MASK 0x04
130#define TWL6030_MMCDETECT_INT_MASK 0x08
131#define TWL6030_GPADC_INT_MASK 0x60
132#define TWL6030_GASGAUGE_INT_MASK 0x80
133
134/* MASK INT REG GROUP C */
135#define TWL6030_USBOTG_INT_MASK 0x0F
136#define TWL6030_CHARGER_CTRL_INT_MASK 0x10
137#define TWL6030_CHARGER_FAULT_INT_MASK 0x60
138
139
140#define TWL4030_CLASS_ID 0x4030
141#define TWL6030_CLASS_ID 0x6030
142unsigned int twl_rev(void);
143#define GET_TWL_REV (twl_rev())
144#define TWL_CLASS_IS(class, id) \
145static inline int twl_class_is_ ##class(void) \
146{ \
147 return ((id) == (GET_TWL_REV)) ? 1 : 0; \
148}
149
150TWL_CLASS_IS(4030, TWL4030_CLASS_ID)
151TWL_CLASS_IS(6030, TWL6030_CLASS_ID)
71 152
72/* 153/*
73 * Read and write single 8-bit registers 154 * Read and write single 8-bit registers
74 */ 155 */
75int twl4030_i2c_write_u8(u8 mod_no, u8 val, u8 reg); 156int twl_i2c_write_u8(u8 mod_no, u8 val, u8 reg);
76int twl4030_i2c_read_u8(u8 mod_no, u8 *val, u8 reg); 157int twl_i2c_read_u8(u8 mod_no, u8 *val, u8 reg);
77 158
78/* 159/*
79 * Read and write several 8-bit registers at once. 160 * Read and write several 8-bit registers at once.
80 * 161 *
81 * IMPORTANT: For twl4030_i2c_write(), allocate num_bytes + 1 162 * IMPORTANT: For twl_i2c_write(), allocate num_bytes + 1
82 * for the value, and populate your data starting at offset 1. 163 * for the value, and populate your data starting at offset 1.
83 */ 164 */
84int twl4030_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes); 165int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
85int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes); 166int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
167
168int twl6030_interrupt_unmask(u8 bit_mask, u8 offset);
169int twl6030_interrupt_mask(u8 bit_mask, u8 offset);
86 170
87/*----------------------------------------------------------------------*/ 171/*----------------------------------------------------------------------*/
88 172
@@ -221,6 +305,38 @@ int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
221 305
222/*----------------------------------------------------------------------*/ 306/*----------------------------------------------------------------------*/
223 307
308/*
309 * Accessory Interrupts
310 */
311#define TWL5031_ACIIMR_LSB 0x05
312#define TWL5031_ACIIMR_MSB 0x06
313#define TWL5031_ACIIDR_LSB 0x07
314#define TWL5031_ACIIDR_MSB 0x08
315#define TWL5031_ACCISR1 0x0F
316#define TWL5031_ACCIMR1 0x10
317#define TWL5031_ACCISR2 0x11
318#define TWL5031_ACCIMR2 0x12
319#define TWL5031_ACCSIR 0x13
320#define TWL5031_ACCEDR1 0x14
321#define TWL5031_ACCSIHCTRL 0x15
322
323/*----------------------------------------------------------------------*/
324
325/*
326 * Battery Charger Controller
327 */
328
329#define TWL5031_INTERRUPTS_BCIISR1 0x0
330#define TWL5031_INTERRUPTS_BCIIMR1 0x1
331#define TWL5031_INTERRUPTS_BCIISR2 0x2
332#define TWL5031_INTERRUPTS_BCIIMR2 0x3
333#define TWL5031_INTERRUPTS_BCISIR 0x4
334#define TWL5031_INTERRUPTS_BCIEDR1 0x5
335#define TWL5031_INTERRUPTS_BCIEDR2 0x6
336#define TWL5031_INTERRUPTS_BCISIHCTRL 0x7
337
338/*----------------------------------------------------------------------*/
339
224/* Power bus message definitions */ 340/* Power bus message definitions */
225 341
226/* The TWL4030/5030 splits its power-management resources (the various 342/* The TWL4030/5030 splits its power-management resources (the various
@@ -250,6 +366,7 @@ int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
250 366
251#define RES_TYPE_ALL 0x7 367#define RES_TYPE_ALL 0x7
252 368
369/* Resource states */
253#define RES_STATE_WRST 0xF 370#define RES_STATE_WRST 0xF
254#define RES_STATE_ACTIVE 0xE 371#define RES_STATE_ACTIVE 0xE
255#define RES_STATE_SLEEP 0x8 372#define RES_STATE_SLEEP 0x8
@@ -310,8 +427,18 @@ int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
310#define MSG_SINGULAR(devgrp, id, state) \ 427#define MSG_SINGULAR(devgrp, id, state) \
311 ((devgrp) << 13 | 0 << 12 | (id) << 4 | (state)) 428 ((devgrp) << 13 | 0 << 12 | (id) << 4 | (state))
312 429
430#define MSG_BROADCAST_ALL(devgrp, state) \
431 ((devgrp) << 5 | (state))
432
433#define MSG_BROADCAST_REF MSG_BROADCAST_ALL
434#define MSG_BROADCAST_PROV MSG_BROADCAST_ALL
435#define MSG_BROADCAST__CLK_RST MSG_BROADCAST_ALL
313/*----------------------------------------------------------------------*/ 436/*----------------------------------------------------------------------*/
314 437
438struct twl4030_clock_init_data {
439 bool ck32k_lowpwr_enable;
440};
441
315struct twl4030_bci_platform_data { 442struct twl4030_bci_platform_data {
316 int *battery_tmp_tbl; 443 int *battery_tmp_tbl;
317 unsigned int tblsize; 444 unsigned int tblsize;
@@ -391,12 +518,15 @@ struct twl4030_resconfig {
391 u8 devgroup; /* Processor group that Power resource belongs to */ 518 u8 devgroup; /* Processor group that Power resource belongs to */
392 u8 type; /* Power resource addressed, 6 / broadcast message */ 519 u8 type; /* Power resource addressed, 6 / broadcast message */
393 u8 type2; /* Power resource addressed, 3 / broadcast message */ 520 u8 type2; /* Power resource addressed, 3 / broadcast message */
521 u8 remap_off; /* off state remapping */
522 u8 remap_sleep; /* sleep state remapping */
394}; 523};
395 524
396struct twl4030_power_data { 525struct twl4030_power_data {
397 struct twl4030_script **scripts; 526 struct twl4030_script **scripts;
398 unsigned num; 527 unsigned num;
399 struct twl4030_resconfig *resource_config; 528 struct twl4030_resconfig *resource_config;
529#define TWL4030_RESCONFIG_UNDEF ((u8)-1)
400}; 530};
401 531
402extern void twl4030_power_init(struct twl4030_power_data *triton2_scripts); 532extern void twl4030_power_init(struct twl4030_power_data *triton2_scripts);
@@ -421,6 +551,7 @@ struct twl4030_codec_data {
421 551
422struct twl4030_platform_data { 552struct twl4030_platform_data {
423 unsigned irq_base, irq_end; 553 unsigned irq_base, irq_end;
554 struct twl4030_clock_init_data *clock;
424 struct twl4030_bci_platform_data *bci; 555 struct twl4030_bci_platform_data *bci;
425 struct twl4030_gpio_platform_data *gpio; 556 struct twl4030_gpio_platform_data *gpio;
426 struct twl4030_madc_platform_data *madc; 557 struct twl4030_madc_platform_data *madc;
@@ -429,19 +560,31 @@ struct twl4030_platform_data {
429 struct twl4030_power_data *power; 560 struct twl4030_power_data *power;
430 struct twl4030_codec_data *codec; 561 struct twl4030_codec_data *codec;
431 562
432 /* LDO regulators */ 563 /* Common LDO regulators for TWL4030/TWL6030 */
433 struct regulator_init_data *vdac; 564 struct regulator_init_data *vdac;
565 struct regulator_init_data *vaux1;
566 struct regulator_init_data *vaux2;
567 struct regulator_init_data *vaux3;
568 /* TWL4030 LDO regulators */
434 struct regulator_init_data *vpll1; 569 struct regulator_init_data *vpll1;
435 struct regulator_init_data *vpll2; 570 struct regulator_init_data *vpll2;
436 struct regulator_init_data *vmmc1; 571 struct regulator_init_data *vmmc1;
437 struct regulator_init_data *vmmc2; 572 struct regulator_init_data *vmmc2;
438 struct regulator_init_data *vsim; 573 struct regulator_init_data *vsim;
439 struct regulator_init_data *vaux1;
440 struct regulator_init_data *vaux2;
441 struct regulator_init_data *vaux3;
442 struct regulator_init_data *vaux4; 574 struct regulator_init_data *vaux4;
443 575 struct regulator_init_data *vio;
444 /* REVISIT more to come ... _nothing_ should be hard-wired */ 576 struct regulator_init_data *vdd1;
577 struct regulator_init_data *vdd2;
578 struct regulator_init_data *vintana1;
579 struct regulator_init_data *vintana2;
580 struct regulator_init_data *vintdig;
581 /* TWL6030 LDO regulators */
582 struct regulator_init_data *vmmc;
583 struct regulator_init_data *vpp;
584 struct regulator_init_data *vusim;
585 struct regulator_init_data *vana;
586 struct regulator_init_data *vcxio;
587 struct regulator_init_data *vusb;
445}; 588};
446 589
447/*----------------------------------------------------------------------*/ 590/*----------------------------------------------------------------------*/
@@ -473,6 +616,7 @@ int twl4030_sih_setup(int module);
473 * VIO is generally fixed. 616 * VIO is generally fixed.
474 */ 617 */
475 618
619/* TWL4030 SMPS/LDO's */
476/* EXTERNAL dc-to-dc buck converters */ 620/* EXTERNAL dc-to-dc buck converters */
477#define TWL4030_REG_VDD1 0 621#define TWL4030_REG_VDD1 0
478#define TWL4030_REG_VDD2 1 622#define TWL4030_REG_VDD2 1
@@ -499,4 +643,31 @@ int twl4030_sih_setup(int module);
499#define TWL4030_REG_VUSB1V8 18 643#define TWL4030_REG_VUSB1V8 18
500#define TWL4030_REG_VUSB3V1 19 644#define TWL4030_REG_VUSB3V1 19
501 645
646/* TWL6030 SMPS/LDO's */
647/* EXTERNAL dc-to-dc buck convertor contollable via SR */
648#define TWL6030_REG_VDD1 30
649#define TWL6030_REG_VDD2 31
650#define TWL6030_REG_VDD3 32
651
652/* Non SR compliant dc-to-dc buck convertors */
653#define TWL6030_REG_VMEM 33
654#define TWL6030_REG_V2V1 34
655#define TWL6030_REG_V1V29 35
656#define TWL6030_REG_V1V8 36
657
658/* EXTERNAL LDOs */
659#define TWL6030_REG_VAUX1_6030 37
660#define TWL6030_REG_VAUX2_6030 38
661#define TWL6030_REG_VAUX3_6030 39
662#define TWL6030_REG_VMMC 40
663#define TWL6030_REG_VPP 41
664#define TWL6030_REG_VUSIM 42
665#define TWL6030_REG_VANA 43
666#define TWL6030_REG_VCXIO 44
667#define TWL6030_REG_VDAC 45
668#define TWL6030_REG_VUSB 46
669
670/* INTERNAL LDOs */
671#define TWL6030_REG_VRTC 47
672
502#endif /* End of __TWL4030_H */ 673#endif /* End of __TWL4030_H */
diff --git a/include/linux/mfd/88pm8607.h b/include/linux/mfd/88pm8607.h
new file mode 100644
index 000000000000..f41b428d2cec
--- /dev/null
+++ b/include/linux/mfd/88pm8607.h
@@ -0,0 +1,217 @@
1/*
2 * Marvell 88PM8607 Interface
3 *
4 * Copyright (C) 2009 Marvell International Ltd.
5 * Haojian Zhuang <haojian.zhuang@marvell.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef __LINUX_MFD_88PM8607_H
13#define __LINUX_MFD_88PM8607_H
14
15enum {
16 PM8607_ID_BUCK1 = 0,
17 PM8607_ID_BUCK2,
18 PM8607_ID_BUCK3,
19
20 PM8607_ID_LDO1,
21 PM8607_ID_LDO2,
22 PM8607_ID_LDO3,
23 PM8607_ID_LDO4,
24 PM8607_ID_LDO5,
25 PM8607_ID_LDO6,
26 PM8607_ID_LDO7,
27 PM8607_ID_LDO8,
28 PM8607_ID_LDO9,
29 PM8607_ID_LDO10,
30 PM8607_ID_LDO12,
31 PM8607_ID_LDO14,
32
33 PM8607_ID_RG_MAX,
34};
35
36#define CHIP_ID (0x40)
37#define CHIP_ID_MASK (0xF8)
38
39/* Interrupt Registers */
40#define PM8607_STATUS_1 (0x01)
41#define PM8607_STATUS_2 (0x02)
42#define PM8607_INT_STATUS1 (0x03)
43#define PM8607_INT_STATUS2 (0x04)
44#define PM8607_INT_STATUS3 (0x05)
45#define PM8607_INT_MASK_1 (0x06)
46#define PM8607_INT_MASK_2 (0x07)
47#define PM8607_INT_MASK_3 (0x08)
48
49/* Regulator Control Registers */
50#define PM8607_LDO1 (0x10)
51#define PM8607_LDO2 (0x11)
52#define PM8607_LDO3 (0x12)
53#define PM8607_LDO4 (0x13)
54#define PM8607_LDO5 (0x14)
55#define PM8607_LDO6 (0x15)
56#define PM8607_LDO7 (0x16)
57#define PM8607_LDO8 (0x17)
58#define PM8607_LDO9 (0x18)
59#define PM8607_LDO10 (0x19)
60#define PM8607_LDO12 (0x1A)
61#define PM8607_LDO14 (0x1B)
62#define PM8607_SLEEP_MODE1 (0x1C)
63#define PM8607_SLEEP_MODE2 (0x1D)
64#define PM8607_SLEEP_MODE3 (0x1E)
65#define PM8607_SLEEP_MODE4 (0x1F)
66#define PM8607_GO (0x20)
67#define PM8607_SLEEP_BUCK1 (0x21)
68#define PM8607_SLEEP_BUCK2 (0x22)
69#define PM8607_SLEEP_BUCK3 (0x23)
70#define PM8607_BUCK1 (0x24)
71#define PM8607_BUCK2 (0x25)
72#define PM8607_BUCK3 (0x26)
73#define PM8607_BUCK_CONTROLS (0x27)
74#define PM8607_SUPPLIES_EN11 (0x2B)
75#define PM8607_SUPPLIES_EN12 (0x2C)
76#define PM8607_GROUP1 (0x2D)
77#define PM8607_GROUP2 (0x2E)
78#define PM8607_GROUP3 (0x2F)
79#define PM8607_GROUP4 (0x30)
80#define PM8607_GROUP5 (0x31)
81#define PM8607_GROUP6 (0x32)
82#define PM8607_SUPPLIES_EN21 (0x33)
83#define PM8607_SUPPLIES_EN22 (0x34)
84
85/* RTC Control Registers */
86#define PM8607_RTC1 (0xA0)
87#define PM8607_RTC_COUNTER1 (0xA1)
88#define PM8607_RTC_COUNTER2 (0xA2)
89#define PM8607_RTC_COUNTER3 (0xA3)
90#define PM8607_RTC_COUNTER4 (0xA4)
91#define PM8607_RTC_EXPIRE1 (0xA5)
92#define PM8607_RTC_EXPIRE2 (0xA6)
93#define PM8607_RTC_EXPIRE3 (0xA7)
94#define PM8607_RTC_EXPIRE4 (0xA8)
95#define PM8607_RTC_TRIM1 (0xA9)
96#define PM8607_RTC_TRIM2 (0xAA)
97#define PM8607_RTC_TRIM3 (0xAB)
98#define PM8607_RTC_TRIM4 (0xAC)
99#define PM8607_RTC_MISC1 (0xAD)
100#define PM8607_RTC_MISC2 (0xAE)
101#define PM8607_RTC_MISC3 (0xAF)
102
103/* Misc Registers */
104#define PM8607_CHIP_ID (0x00)
105#define PM8607_LDO1 (0x10)
106#define PM8607_DVC3 (0x26)
107#define PM8607_MISC1 (0x40)
108
109/* bit definitions for PM8607 events */
110#define PM8607_EVENT_ONKEY (1 << 0)
111#define PM8607_EVENT_EXTON (1 << 1)
112#define PM8607_EVENT_CHG (1 << 2)
113#define PM8607_EVENT_BAT (1 << 3)
114#define PM8607_EVENT_RTC (1 << 4)
115#define PM8607_EVENT_CC (1 << 5)
116#define PM8607_EVENT_VBAT (1 << 8)
117#define PM8607_EVENT_VCHG (1 << 9)
118#define PM8607_EVENT_VSYS (1 << 10)
119#define PM8607_EVENT_TINT (1 << 11)
120#define PM8607_EVENT_GPADC0 (1 << 12)
121#define PM8607_EVENT_GPADC1 (1 << 13)
122#define PM8607_EVENT_GPADC2 (1 << 14)
123#define PM8607_EVENT_GPADC3 (1 << 15)
124#define PM8607_EVENT_AUDIO_SHORT (1 << 16)
125#define PM8607_EVENT_PEN (1 << 17)
126#define PM8607_EVENT_HEADSET (1 << 18)
127#define PM8607_EVENT_HOOK (1 << 19)
128#define PM8607_EVENT_MICIN (1 << 20)
129#define PM8607_EVENT_CHG_TIMEOUT (1 << 21)
130#define PM8607_EVENT_CHG_DONE (1 << 22)
131#define PM8607_EVENT_CHG_FAULT (1 << 23)
132
133/* bit definitions of Status Query Interface */
134#define PM8607_STATUS_CC (1 << 3)
135#define PM8607_STATUS_PEN (1 << 4)
136#define PM8607_STATUS_HEADSET (1 << 5)
137#define PM8607_STATUS_HOOK (1 << 6)
138#define PM8607_STATUS_MICIN (1 << 7)
139#define PM8607_STATUS_ONKEY (1 << 8)
140#define PM8607_STATUS_EXTON (1 << 9)
141#define PM8607_STATUS_CHG (1 << 10)
142#define PM8607_STATUS_BAT (1 << 11)
143#define PM8607_STATUS_VBUS (1 << 12)
144#define PM8607_STATUS_OV (1 << 13)
145
146/* bit definitions of BUCK3 */
147#define PM8607_BUCK3_DOUBLE (1 << 6)
148
149/* bit definitions of Misc1 */
150#define PM8607_MISC1_PI2C (1 << 0)
151
152/* Interrupt Number in 88PM8607 */
153enum {
154 PM8607_IRQ_ONKEY = 0,
155 PM8607_IRQ_EXTON,
156 PM8607_IRQ_CHG,
157 PM8607_IRQ_BAT,
158 PM8607_IRQ_RTC,
159 PM8607_IRQ_VBAT = 8,
160 PM8607_IRQ_VCHG,
161 PM8607_IRQ_VSYS,
162 PM8607_IRQ_TINT,
163 PM8607_IRQ_GPADC0,
164 PM8607_IRQ_GPADC1,
165 PM8607_IRQ_GPADC2,
166 PM8607_IRQ_GPADC3,
167 PM8607_IRQ_AUDIO_SHORT = 16,
168 PM8607_IRQ_PEN,
169 PM8607_IRQ_HEADSET,
170 PM8607_IRQ_HOOK,
171 PM8607_IRQ_MICIN,
172 PM8607_IRQ_CHG_FAIL,
173 PM8607_IRQ_CHG_DONE,
174 PM8607_IRQ_CHG_FAULT,
175};
176
177enum {
178 PM8607_CHIP_A0 = 0x40,
179 PM8607_CHIP_A1 = 0x41,
180 PM8607_CHIP_B0 = 0x48,
181};
182
183
184struct pm8607_chip {
185 struct device *dev;
186 struct mutex io_lock;
187 struct i2c_client *client;
188
189 int (*read)(struct pm8607_chip *chip, int reg, int bytes, void *dest);
190 int (*write)(struct pm8607_chip *chip, int reg, int bytes, void *src);
191
192 int buck3_double; /* DVC ramp slope double */
193 unsigned char chip_id;
194
195};
196
197#define PM8607_MAX_REGULATOR 15 /* 3 Bucks, 12 LDOs */
198
199enum {
200 GI2C_PORT = 0,
201 PI2C_PORT,
202};
203
204struct pm8607_platform_data {
205 int i2c_port; /* Controlled by GI2C or PI2C */
206 struct regulator_init_data *regulator[PM8607_MAX_REGULATOR];
207};
208
209extern int pm8607_reg_read(struct pm8607_chip *, int);
210extern int pm8607_reg_write(struct pm8607_chip *, int, unsigned char);
211extern int pm8607_bulk_read(struct pm8607_chip *, int, int,
212 unsigned char *);
213extern int pm8607_bulk_write(struct pm8607_chip *, int, int,
214 unsigned char *);
215extern int pm8607_set_bits(struct pm8607_chip *, int, unsigned char,
216 unsigned char);
217#endif /* __LINUX_MFD_88PM8607_H */
diff --git a/include/linux/mfd/ab4500.h b/include/linux/mfd/ab4500.h
new file mode 100644
index 000000000000..a42a7033ae53
--- /dev/null
+++ b/include/linux/mfd/ab4500.h
@@ -0,0 +1,262 @@
1/*
2 * Copyright (C) 2009 ST-Ericsson
3 *
4 * Author: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2, as
8 * published by the Free Software Foundation.
9 *
10 * AB4500 device core funtions, for client access
11 */
12#ifndef MFD_AB4500_H
13#define MFD_AB4500_H
14
15#include <linux/device.h>
16
17/*
18 * AB4500 bank addresses
19 */
20#define AB4500_SYS_CTRL1_BLOCK 0x1
21#define AB4500_SYS_CTRL2_BLOCK 0x2
22#define AB4500_REGU_CTRL1 0x3
23#define AB4500_REGU_CTRL2 0x4
24#define AB4500_USB 0x5
25#define AB4500_TVOUT 0x6
26#define AB4500_DBI 0x7
27#define AB4500_ECI_AV_ACC 0x8
28#define AB4500_RESERVED 0x9
29#define AB4500_GPADC 0xA
30#define AB4500_CHARGER 0xB
31#define AB4500_GAS_GAUGE 0xC
32#define AB4500_AUDIO 0xD
33#define AB4500_INTERRUPT 0xE
34#define AB4500_RTC 0xF
35#define AB4500_MISC 0x10
36#define AB4500_DEBUG 0x12
37#define AB4500_PROD_TEST 0x13
38#define AB4500_OTP_EMUL 0x15
39
40/*
41 * System control 1 register offsets.
42 * Bank = 0x01
43 */
44#define AB4500_TURNON_STAT_REG 0x0100
45#define AB4500_RESET_STAT_REG 0x0101
46#define AB4500_PONKEY1_PRESS_STAT_REG 0x0102
47
48#define AB4500_FSM_STAT1_REG 0x0140
49#define AB4500_FSM_STAT2_REG 0x0141
50#define AB4500_SYSCLK_REQ_STAT_REG 0x0142
51#define AB4500_USB_STAT1_REG 0x0143
52#define AB4500_USB_STAT2_REG 0x0144
53#define AB4500_STATUS_SPARE1_REG 0x0145
54#define AB4500_STATUS_SPARE2_REG 0x0146
55
56#define AB4500_CTRL1_REG 0x0180
57#define AB4500_CTRL2_REG 0x0181
58
59/*
60 * System control 2 register offsets.
61 * bank = 0x02
62 */
63#define AB4500_CTRL3_REG 0x0200
64#define AB4500_MAIN_WDOG_CTRL_REG 0x0201
65#define AB4500_MAIN_WDOG_TIMER_REG 0x0202
66#define AB4500_LOW_BAT_REG 0x0203
67#define AB4500_BATT_OK_REG 0x0204
68#define AB4500_SYSCLK_TIMER_REG 0x0205
69#define AB4500_SMPSCLK_CTRL_REG 0x0206
70#define AB4500_SMPSCLK_SEL1_REG 0x0207
71#define AB4500_SMPSCLK_SEL2_REG 0x0208
72#define AB4500_SMPSCLK_SEL3_REG 0x0209
73#define AB4500_SYSULPCLK_CONF_REG 0x020A
74#define AB4500_SYSULPCLK_CTRL1_REG 0x020B
75#define AB4500_SYSCLK_CTRL_REG 0x020C
76#define AB4500_SYSCLK_REQ1_VALID_REG 0x020D
77#define AB4500_SYSCLK_REQ_VALID_REG 0x020E
78#define AB4500_SYSCTRL_SPARE_REG 0x020F
79#define AB4500_PAD_CONF_REG 0x0210
80
81/*
82 * Regu control1 register offsets
83 * Bank = 0x03
84 */
85#define AB4500_REGU_SERIAL_CTRL1_REG 0x0300
86#define AB4500_REGU_SERIAL_CTRL2_REG 0x0301
87#define AB4500_REGU_SERIAL_CTRL3_REG 0x0302
88#define AB4500_REGU_REQ_CTRL1_REG 0x0303
89#define AB4500_REGU_REQ_CTRL2_REG 0x0304
90#define AB4500_REGU_REQ_CTRL3_REG 0x0305
91#define AB4500_REGU_REQ_CTRL4_REG 0x0306
92#define AB4500_REGU_MISC1_REG 0x0380
93#define AB4500_REGU_OTGSUPPLY_CTRL_REG 0x0381
94#define AB4500_REGU_VUSB_CTRL_REG 0x0382
95#define AB4500_REGU_VAUDIO_SUPPLY_REG 0x0383
96#define AB4500_REGU_CTRL1_SPARE_REG 0x0384
97
98/*
99 * Regu control2 Vmod register offsets
100 */
101#define AB4500_REGU_VMOD_REGU_REG 0x0440
102#define AB4500_REGU_VMOD_SEL1_REG 0x0441
103#define AB4500_REGU_VMOD_SEL2_REG 0x0442
104#define AB4500_REGU_CTRL_DISCH_REG 0x0443
105#define AB4500_REGU_CTRL_DISCH2_REG 0x0444
106
107/*
108 * USB/ULPI register offsets
109 * Bank : 0x5
110 */
111#define AB4500_USB_LINE_STAT_REG 0x0580
112#define AB4500_USB_LINE_CTRL1_REG 0x0581
113#define AB4500_USB_LINE_CTRL2_REG 0x0582
114#define AB4500_USB_LINE_CTRL3_REG 0x0583
115#define AB4500_USB_LINE_CTRL4_REG 0x0584
116#define AB4500_USB_LINE_CTRL5_REG 0x0585
117#define AB4500_USB_OTG_CTRL_REG 0x0587
118#define AB4500_USB_OTG_STAT_REG 0x0588
119#define AB4500_USB_OTG_STAT_REG 0x0588
120#define AB4500_USB_CTRL_SPARE_REG 0x0589
121#define AB4500_USB_PHY_CTRL_REG 0x058A
122
123/*
124 * TVOUT / CTRL register offsets
125 * Bank : 0x06
126 */
127#define AB4500_TVOUT_CTRL_REG 0x0680
128
129/*
130 * DBI register offsets
131 * Bank : 0x07
132 */
133#define AB4500_DBI_REG1_REG 0x0700
134#define AB4500_DBI_REG2_REG 0x0701
135
136/*
137 * ECI regsiter offsets
138 * Bank : 0x08
139 */
140#define AB4500_ECI_CTRL_REG 0x0800
141#define AB4500_ECI_HOOKLEVEL_REG 0x0801
142#define AB4500_ECI_DATAOUT_REG 0x0802
143#define AB4500_ECI_DATAIN_REG 0x0803
144
145/*
146 * AV Connector register offsets
147 * Bank : 0x08
148 */
149#define AB4500_AV_CONN_REG 0x0840
150
151/*
152 * Accessory detection register offsets
153 * Bank : 0x08
154 */
155#define AB4500_ACC_DET_DB1_REG 0x0880
156#define AB4500_ACC_DET_DB2_REG 0x0881
157
158/*
159 * GPADC register offsets
160 * Bank : 0x0A
161 */
162#define AB4500_GPADC_CTRL1_REG 0x0A00
163#define AB4500_GPADC_CTRL2_REG 0x0A01
164#define AB4500_GPADC_CTRL3_REG 0x0A02
165#define AB4500_GPADC_AUTO_TIMER_REG 0x0A03
166#define AB4500_GPADC_STAT_REG 0x0A04
167#define AB4500_GPADC_MANDATAL_REG 0x0A05
168#define AB4500_GPADC_MANDATAH_REG 0x0A06
169#define AB4500_GPADC_AUTODATAL_REG 0x0A07
170#define AB4500_GPADC_AUTODATAH_REG 0x0A08
171#define AB4500_GPADC_MUX_CTRL_REG 0x0A09
172
173/*
174 * Charger / status register offfsets
175 * Bank : 0x0B
176 */
177#define AB4500_CH_STATUS1_REG 0x0B00
178#define AB4500_CH_STATUS2_REG 0x0B01
179#define AB4500_CH_USBCH_STAT1_REG 0x0B02
180#define AB4500_CH_USBCH_STAT2_REG 0x0B03
181#define AB4500_CH_FSM_STAT_REG 0x0B04
182#define AB4500_CH_STAT_REG 0x0B05
183
184/*
185 * Charger / control register offfsets
186 * Bank : 0x0B
187 */
188#define AB4500_CH_VOLT_LVL_REG 0x0B40
189
190/*
191 * Charger / main control register offfsets
192 * Bank : 0x0B
193 */
194#define AB4500_MCH_CTRL1 0x0B80
195#define AB4500_MCH_CTRL2 0x0B81
196#define AB4500_MCH_IPT_CURLVL_REG 0x0B82
197#define AB4500_CH_WD_REG 0x0B83
198
199/*
200 * Charger / USB control register offsets
201 * Bank : 0x0B
202 */
203#define AB4500_USBCH_CTRL1_REG 0x0BC0
204#define AB4500_USBCH_CTRL2_REG 0x0BC1
205#define AB4500_USBCH_IPT_CRNTLVL_REG 0x0BC2
206
207/*
208 * RTC bank register offsets
209 * Bank : 0xF
210 */
211#define AB4500_RTC_SOFF_STAT_REG 0x0F00
212#define AB4500_RTC_CC_CONF_REG 0x0F01
213#define AB4500_RTC_READ_REQ_REG 0x0F02
214#define AB4500_RTC_WATCH_TSECMID_REG 0x0F03
215#define AB4500_RTC_WATCH_TSECHI_REG 0x0F04
216#define AB4500_RTC_WATCH_TMIN_LOW_REG 0x0F05
217#define AB4500_RTC_WATCH_TMIN_MID_REG 0x0F06
218#define AB4500_RTC_WATCH_TMIN_HI_REG 0x0F07
219#define AB4500_RTC_ALRM_MIN_LOW_REG 0x0F08
220#define AB4500_RTC_ALRM_MIN_MID_REG 0x0F09
221#define AB4500_RTC_ALRM_MIN_HI_REG 0x0F0A
222#define AB4500_RTC_STAT_REG 0x0F0B
223#define AB4500_RTC_BKUP_CHG_REG 0x0F0C
224#define AB4500_RTC_FORCE_BKUP_REG 0x0F0D
225#define AB4500_RTC_CALIB_REG 0x0F0E
226#define AB4500_RTC_SWITCH_STAT_REG 0x0F0F
227
228/*
229 * PWM Out generators
230 * Bank: 0x10
231 */
232#define AB4500_PWM_OUT_CTRL1_REG 0x1060
233#define AB4500_PWM_OUT_CTRL2_REG 0x1061
234#define AB4500_PWM_OUT_CTRL3_REG 0x1062
235#define AB4500_PWM_OUT_CTRL4_REG 0x1063
236#define AB4500_PWM_OUT_CTRL5_REG 0x1064
237#define AB4500_PWM_OUT_CTRL6_REG 0x1065
238#define AB4500_PWM_OUT_CTRL7_REG 0x1066
239
240#define AB4500_I2C_PAD_CTRL_REG 0x1067
241#define AB4500_REV_REG 0x1080
242
243/**
244 * struct ab4500
245 * @spi: spi device structure
246 * @tx_buf: transmit buffer
247 * @rx_buf: receive buffer
248 * @lock: sync primitive
249 */
250struct ab4500 {
251 struct spi_device *spi;
252 unsigned long tx_buf[4];
253 unsigned long rx_buf[4];
254 struct mutex lock;
255};
256
257int ab4500_write(struct ab4500 *ab4500, unsigned char block,
258 unsigned long addr, unsigned char data);
259int ab4500_read(struct ab4500 *ab4500, unsigned char block,
260 unsigned long addr);
261
262#endif /* MFD_AB4500_H */
diff --git a/include/linux/mfd/adp5520.h b/include/linux/mfd/adp5520.h
new file mode 100644
index 000000000000..ac37558a4673
--- /dev/null
+++ b/include/linux/mfd/adp5520.h
@@ -0,0 +1,299 @@
1/*
2 * Definitions and platform data for Analog Devices
3 * ADP5520/ADP5501 MFD PMICs (Backlight, LED, GPIO and Keys)
4 *
5 * Copyright 2009 Analog Devices Inc.
6 *
7 * Licensed under the GPL-2 or later.
8 */
9
10
11#ifndef __LINUX_MFD_ADP5520_H
12#define __LINUX_MFD_ADP5520_H
13
14#define ID_ADP5520 5520
15#define ID_ADP5501 5501
16
17/*
18 * ADP5520/ADP5501 Register Map
19 */
20
21#define ADP5520_MODE_STATUS 0x00
22#define ADP5520_INTERRUPT_ENABLE 0x01
23#define ADP5520_BL_CONTROL 0x02
24#define ADP5520_BL_TIME 0x03
25#define ADP5520_BL_FADE 0x04
26#define ADP5520_DAYLIGHT_MAX 0x05
27#define ADP5520_DAYLIGHT_DIM 0x06
28#define ADP5520_OFFICE_MAX 0x07
29#define ADP5520_OFFICE_DIM 0x08
30#define ADP5520_DARK_MAX 0x09
31#define ADP5520_DARK_DIM 0x0A
32#define ADP5520_BL_VALUE 0x0B
33#define ADP5520_ALS_CMPR_CFG 0x0C
34#define ADP5520_L2_TRIP 0x0D
35#define ADP5520_L2_HYS 0x0E
36#define ADP5520_L3_TRIP 0x0F
37#define ADP5520_L3_HYS 0x10
38#define ADP5520_LED_CONTROL 0x11
39#define ADP5520_LED_TIME 0x12
40#define ADP5520_LED_FADE 0x13
41#define ADP5520_LED1_CURRENT 0x14
42#define ADP5520_LED2_CURRENT 0x15
43#define ADP5520_LED3_CURRENT 0x16
44
45/*
46 * ADP5520 Register Map
47 */
48
49#define ADP5520_GPIO_CFG_1 0x17
50#define ADP5520_GPIO_CFG_2 0x18
51#define ADP5520_GPIO_IN 0x19
52#define ADP5520_GPIO_OUT 0x1A
53#define ADP5520_GPIO_INT_EN 0x1B
54#define ADP5520_GPIO_INT_STAT 0x1C
55#define ADP5520_GPIO_INT_LVL 0x1D
56#define ADP5520_GPIO_DEBOUNCE 0x1E
57#define ADP5520_GPIO_PULLUP 0x1F
58#define ADP5520_KP_INT_STAT_1 0x20
59#define ADP5520_KP_INT_STAT_2 0x21
60#define ADP5520_KR_INT_STAT_1 0x22
61#define ADP5520_KR_INT_STAT_2 0x23
62#define ADP5520_KEY_STAT_1 0x24
63#define ADP5520_KEY_STAT_2 0x25
64
65/*
66 * MODE_STATUS bits
67 */
68
69#define ADP5520_nSTNBY (1 << 7)
70#define ADP5520_BL_EN (1 << 6)
71#define ADP5520_DIM_EN (1 << 5)
72#define ADP5520_OVP_INT (1 << 4)
73#define ADP5520_CMPR_INT (1 << 3)
74#define ADP5520_GPI_INT (1 << 2)
75#define ADP5520_KR_INT (1 << 1)
76#define ADP5520_KP_INT (1 << 0)
77
78/*
79 * INTERRUPT_ENABLE bits
80 */
81
82#define ADP5520_AUTO_LD_EN (1 << 4)
83#define ADP5520_CMPR_IEN (1 << 3)
84#define ADP5520_OVP_IEN (1 << 2)
85#define ADP5520_KR_IEN (1 << 1)
86#define ADP5520_KP_IEN (1 << 0)
87
88/*
89 * BL_CONTROL bits
90 */
91
92#define ADP5520_BL_LVL ((x) << 5)
93#define ADP5520_BL_LAW ((x) << 4)
94#define ADP5520_BL_AUTO_ADJ (1 << 3)
95#define ADP5520_OVP_EN (1 << 2)
96#define ADP5520_FOVR (1 << 1)
97#define ADP5520_KP_BL_EN (1 << 0)
98
99/*
100 * ALS_CMPR_CFG bits
101 */
102
103#define ADP5520_L3_OUT (1 << 3)
104#define ADP5520_L2_OUT (1 << 2)
105#define ADP5520_L3_EN (1 << 1)
106
107#define ADP5020_MAX_BRIGHTNESS 0x7F
108
109#define FADE_VAL(in, out) ((0xF & (in)) | ((0xF & (out)) << 4))
110#define BL_CTRL_VAL(law, auto) (((1 & (auto)) << 3) | ((0x3 & (law)) << 4))
111#define ALS_CMPR_CFG_VAL(filt, l3_en) (((0x7 & filt) << 5) | l3_en)
112
113/*
114 * LEDs subdevice bits and masks
115 */
116
117#define ADP5520_01_MAXLEDS 3
118
119#define ADP5520_FLAG_LED_MASK 0x3
120#define ADP5520_FLAG_OFFT_SHIFT 8
121#define ADP5520_FLAG_OFFT_MASK 0x3
122
123#define ADP5520_R3_MODE (1 << 5)
124#define ADP5520_C3_MODE (1 << 4)
125#define ADP5520_LED_LAW (1 << 3)
126#define ADP5520_LED3_EN (1 << 2)
127#define ADP5520_LED2_EN (1 << 1)
128#define ADP5520_LED1_EN (1 << 0)
129
130/*
131 * GPIO subdevice bits and masks
132 */
133
134#define ADP5520_MAXGPIOS 8
135
136#define ADP5520_GPIO_C3 (1 << 7) /* LED2 or GPIO7 aka C3 */
137#define ADP5520_GPIO_C2 (1 << 6)
138#define ADP5520_GPIO_C1 (1 << 5)
139#define ADP5520_GPIO_C0 (1 << 4)
140#define ADP5520_GPIO_R3 (1 << 3) /* LED3 or GPIO3 aka R3 */
141#define ADP5520_GPIO_R2 (1 << 2)
142#define ADP5520_GPIO_R1 (1 << 1)
143#define ADP5520_GPIO_R0 (1 << 0)
144
145struct adp5520_gpio_platform_data {
146 unsigned gpio_start;
147 u8 gpio_en_mask;
148 u8 gpio_pullup_mask;
149};
150
151/*
152 * Keypad subdevice bits and masks
153 */
154
155#define ADP5520_MAXKEYS 16
156
157#define ADP5520_COL_C3 (1 << 7) /* LED2 or GPIO7 aka C3 */
158#define ADP5520_COL_C2 (1 << 6)
159#define ADP5520_COL_C1 (1 << 5)
160#define ADP5520_COL_C0 (1 << 4)
161#define ADP5520_ROW_R3 (1 << 3) /* LED3 or GPIO3 aka R3 */
162#define ADP5520_ROW_R2 (1 << 2)
163#define ADP5520_ROW_R1 (1 << 1)
164#define ADP5520_ROW_R0 (1 << 0)
165
166#define ADP5520_KEY(row, col) (col + row * 4)
167#define ADP5520_KEYMAPSIZE ADP5520_MAXKEYS
168
169struct adp5520_keys_platform_data {
170 int rows_en_mask; /* Number of rows */
171 int cols_en_mask; /* Number of columns */
172 const unsigned short *keymap; /* Pointer to keymap */
173 unsigned short keymapsize; /* Keymap size */
174 unsigned repeat:1; /* Enable key repeat */
175};
176
177
178/*
179 * LEDs subdevice platform data
180 */
181
182#define FLAG_ID_ADP5520_LED1_ADP5501_LED0 1 /* ADP5520 PIN ILED */
183#define FLAG_ID_ADP5520_LED2_ADP5501_LED1 2 /* ADP5520 PIN C3 */
184#define FLAG_ID_ADP5520_LED3_ADP5501_LED2 3 /* ADP5520 PIN R3 */
185
186#define ADP5520_LED_DIS_BLINK (0 << ADP5520_FLAG_OFFT_SHIFT)
187#define ADP5520_LED_OFFT_600ms (1 << ADP5520_FLAG_OFFT_SHIFT)
188#define ADP5520_LED_OFFT_800ms (2 << ADP5520_FLAG_OFFT_SHIFT)
189#define ADP5520_LED_OFFT_1200ms (3 << ADP5520_FLAG_OFFT_SHIFT)
190
191#define ADP5520_LED_ONT_200ms 0
192#define ADP5520_LED_ONT_600ms 1
193#define ADP5520_LED_ONT_800ms 2
194#define ADP5520_LED_ONT_1200ms 3
195
196struct adp5520_leds_platform_data {
197 int num_leds;
198 struct led_info *leds;
199 u8 fade_in; /* Backlight Fade-In Timer */
200 u8 fade_out; /* Backlight Fade-Out Timer */
201 u8 led_on_time;
202};
203
204/*
205 * Backlight subdevice platform data
206 */
207
208#define ADP5520_FADE_T_DIS 0 /* Fade Timer Disabled */
209#define ADP5520_FADE_T_300ms 1 /* 0.3 Sec */
210#define ADP5520_FADE_T_600ms 2
211#define ADP5520_FADE_T_900ms 3
212#define ADP5520_FADE_T_1200ms 4
213#define ADP5520_FADE_T_1500ms 5
214#define ADP5520_FADE_T_1800ms 6
215#define ADP5520_FADE_T_2100ms 7
216#define ADP5520_FADE_T_2400ms 8
217#define ADP5520_FADE_T_2700ms 9
218#define ADP5520_FADE_T_3000ms 10
219#define ADP5520_FADE_T_3500ms 11
220#define ADP5520_FADE_T_4000ms 12
221#define ADP5520_FADE_T_4500ms 13
222#define ADP5520_FADE_T_5000ms 14
223#define ADP5520_FADE_T_5500ms 15 /* 5.5 Sec */
224
225#define ADP5520_BL_LAW_LINEAR 0
226#define ADP5520_BL_LAW_SQUARE 1
227#define ADP5520_BL_LAW_CUBIC1 2
228#define ADP5520_BL_LAW_CUBIC2 3
229
230#define ADP5520_BL_AMBL_FILT_80ms 0 /* Light sensor filter time */
231#define ADP5520_BL_AMBL_FILT_160ms 1
232#define ADP5520_BL_AMBL_FILT_320ms 2
233#define ADP5520_BL_AMBL_FILT_640ms 3
234#define ADP5520_BL_AMBL_FILT_1280ms 4
235#define ADP5520_BL_AMBL_FILT_2560ms 5
236#define ADP5520_BL_AMBL_FILT_5120ms 6
237#define ADP5520_BL_AMBL_FILT_10240ms 7 /* 10.24 sec */
238
239 /*
240 * Blacklight current 0..30mA
241 */
242#define ADP5520_BL_CUR_mA(I) ((I * 127) / 30)
243
244 /*
245 * L2 comparator current 0..1000uA
246 */
247#define ADP5520_L2_COMP_CURR_uA(I) ((I * 255) / 1000)
248
249 /*
250 * L3 comparator current 0..127uA
251 */
252#define ADP5520_L3_COMP_CURR_uA(I) ((I * 255) / 127)
253
254struct adp5520_backlight_platform_data {
255 u8 fade_in; /* Backlight Fade-In Timer */
256 u8 fade_out; /* Backlight Fade-Out Timer */
257 u8 fade_led_law; /* fade-on/fade-off transfer characteristic */
258
259 u8 en_ambl_sens; /* 1 = enable ambient light sensor */
260 u8 abml_filt; /* Light sensor filter time */
261 u8 l1_daylight_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
262 u8 l1_daylight_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
263 u8 l2_office_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
264 u8 l2_office_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
265 u8 l3_dark_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
266 u8 l3_dark_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
267 u8 l2_trip; /* use L2_COMP_CURR_uA(I) 0 <= I <= 1000 uA */
268 u8 l2_hyst; /* use L2_COMP_CURR_uA(I) 0 <= I <= 1000 uA */
269 u8 l3_trip; /* use L3_COMP_CURR_uA(I) 0 <= I <= 127 uA */
270 u8 l3_hyst; /* use L3_COMP_CURR_uA(I) 0 <= I <= 127 uA */
271};
272
273/*
274 * MFD chip platform data
275 */
276
277struct adp5520_platform_data {
278 struct adp5520_keys_platform_data *keys;
279 struct adp5520_gpio_platform_data *gpio;
280 struct adp5520_leds_platform_data *leds;
281 struct adp5520_backlight_platform_data *backlight;
282};
283
284/*
285 * MFD chip functions
286 */
287
288extern int adp5520_read(struct device *dev, int reg, uint8_t *val);
289extern int adp5520_write(struct device *dev, int reg, u8 val);
290extern int adp5520_clr_bits(struct device *dev, int reg, uint8_t bit_mask);
291extern int adp5520_set_bits(struct device *dev, int reg, uint8_t bit_mask);
292
293extern int adp5520_register_notifier(struct device *dev,
294 struct notifier_block *nb, unsigned int events);
295
296extern int adp5520_unregister_notifier(struct device *dev,
297 struct notifier_block *nb, unsigned int events);
298
299#endif /* __LINUX_MFD_ADP5520_H */
diff --git a/include/linux/mfd/ezx-pcap.h b/include/linux/mfd/ezx-pcap.h
index 3402042ddc31..40c372165f3e 100644
--- a/include/linux/mfd/ezx-pcap.h
+++ b/include/linux/mfd/ezx-pcap.h
@@ -231,9 +231,6 @@ void pcap_set_ts_bits(struct pcap_chip *, u32);
231#define PCAP_LED_4MA 1 231#define PCAP_LED_4MA 1
232#define PCAP_LED_5MA 2 232#define PCAP_LED_5MA 2
233#define PCAP_LED_9MA 3 233#define PCAP_LED_9MA 3
234#define PCAP_LED_GPIO_VAL_MASK 0x00ffffff
235#define PCAP_LED_GPIO_EN 0x01000000
236#define PCAP_LED_GPIO_INVERT 0x02000000
237#define PCAP_LED_T_MASK 0xf 234#define PCAP_LED_T_MASK 0xf
238#define PCAP_LED_C_MASK 0x3 235#define PCAP_LED_C_MASK 0x3
239#define PCAP_BL_MASK 0x1f 236#define PCAP_BL_MASK 0x1f
diff --git a/include/linux/mfd/mc13783-private.h b/include/linux/mfd/mc13783-private.h
index 47e698cb0f16..95cf9360553f 100644
--- a/include/linux/mfd/mc13783-private.h
+++ b/include/linux/mfd/mc13783-private.h
@@ -24,52 +24,23 @@
24 24
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/mfd/mc13783.h> 26#include <linux/mfd/mc13783.h>
27#include <linux/workqueue.h>
28#include <linux/mutex.h> 27#include <linux/mutex.h>
29 28#include <linux/interrupt.h>
30struct mc13783_irq {
31 void (*handler)(int, void *);
32 void *data;
33};
34
35#define MC13783_NUM_IRQ 2
36#define MC13783_IRQ_TS 0
37#define MC13783_IRQ_REGULATOR 1
38
39#define MC13783_ADC_MODE_TS 1
40#define MC13783_ADC_MODE_SINGLE_CHAN 2
41#define MC13783_ADC_MODE_MULT_CHAN 3
42 29
43struct mc13783 { 30struct mc13783 {
44 int revision; 31 struct spi_device *spidev;
45 struct device *dev; 32 struct mutex lock;
46 struct spi_device *spi_device;
47
48 int (*read_dev)(void *data, char reg, int count, u32 *dst);
49 int (*write_dev)(void *data, char reg, int count, const u32 *src);
50
51 struct mutex io_lock;
52 void *io_data;
53 int irq; 33 int irq;
54 unsigned int flags; 34 int flags;
55 35
56 struct mc13783_irq irq_handler[MC13783_NUM_IRQ]; 36 irq_handler_t irqhandler[MC13783_NUM_IRQ];
57 struct work_struct work; 37 void *irqdata[MC13783_NUM_IRQ];
58 struct completion adc_done;
59 unsigned int ts_active;
60 struct mutex adc_conv_lock;
61 38
39 /* XXX these should go as platformdata to the regulator subdevice */
62 struct mc13783_regulator_init_data *regulators; 40 struct mc13783_regulator_init_data *regulators;
63 int num_regulators; 41 int num_regulators;
64}; 42};
65 43
66int mc13783_reg_read(struct mc13783 *, int reg_num, u32 *);
67int mc13783_reg_write(struct mc13783 *, int, u32);
68int mc13783_set_bits(struct mc13783 *, int, u32, u32);
69int mc13783_free_irq(struct mc13783 *mc13783, int irq);
70int mc13783_register_irq(struct mc13783 *mc13783, int irq,
71 void (*handler) (int, void *), void *data);
72
73#define MC13783_REG_INTERRUPT_STATUS_0 0 44#define MC13783_REG_INTERRUPT_STATUS_0 0
74#define MC13783_REG_INTERRUPT_MASK_0 1 45#define MC13783_REG_INTERRUPT_MASK_0 1
75#define MC13783_REG_INTERRUPT_SENSE_0 2 46#define MC13783_REG_INTERRUPT_SENSE_0 2
@@ -136,55 +107,6 @@ int mc13783_register_irq(struct mc13783 *mc13783, int irq,
136#define MC13783_REG_TEST_3 63 107#define MC13783_REG_TEST_3 63
137#define MC13783_REG_NB 64 108#define MC13783_REG_NB 64
138 109
139
140/*
141 * Interrupt Status
142 */
143#define MC13783_INT_STAT_ADCDONEI (1 << 0)
144#define MC13783_INT_STAT_ADCBISDONEI (1 << 1)
145#define MC13783_INT_STAT_TSI (1 << 2)
146#define MC13783_INT_STAT_WHIGHI (1 << 3)
147#define MC13783_INT_STAT_WLOWI (1 << 4)
148#define MC13783_INT_STAT_CHGDETI (1 << 6)
149#define MC13783_INT_STAT_CHGOVI (1 << 7)
150#define MC13783_INT_STAT_CHGREVI (1 << 8)
151#define MC13783_INT_STAT_CHGSHORTI (1 << 9)
152#define MC13783_INT_STAT_CCCVI (1 << 10)
153#define MC13783_INT_STAT_CHGCURRI (1 << 11)
154#define MC13783_INT_STAT_BPONI (1 << 12)
155#define MC13783_INT_STAT_LOBATLI (1 << 13)
156#define MC13783_INT_STAT_LOBATHI (1 << 14)
157#define MC13783_INT_STAT_UDPI (1 << 15)
158#define MC13783_INT_STAT_USBI (1 << 16)
159#define MC13783_INT_STAT_IDI (1 << 19)
160#define MC13783_INT_STAT_Unused (1 << 20)
161#define MC13783_INT_STAT_SE1I (1 << 21)
162#define MC13783_INT_STAT_CKDETI (1 << 22)
163#define MC13783_INT_STAT_UDMI (1 << 23)
164
165/*
166 * Interrupt Mask
167 */
168#define MC13783_INT_MASK_ADCDONEM (1 << 0)
169#define MC13783_INT_MASK_ADCBISDONEM (1 << 1)
170#define MC13783_INT_MASK_TSM (1 << 2)
171#define MC13783_INT_MASK_WHIGHM (1 << 3)
172#define MC13783_INT_MASK_WLOWM (1 << 4)
173#define MC13783_INT_MASK_CHGDETM (1 << 6)
174#define MC13783_INT_MASK_CHGOVM (1 << 7)
175#define MC13783_INT_MASK_CHGREVM (1 << 8)
176#define MC13783_INT_MASK_CHGSHORTM (1 << 9)
177#define MC13783_INT_MASK_CCCVM (1 << 10)
178#define MC13783_INT_MASK_CHGCURRM (1 << 11)
179#define MC13783_INT_MASK_BPONM (1 << 12)
180#define MC13783_INT_MASK_LOBATLM (1 << 13)
181#define MC13783_INT_MASK_LOBATHM (1 << 14)
182#define MC13783_INT_MASK_UDPM (1 << 15)
183#define MC13783_INT_MASK_USBM (1 << 16)
184#define MC13783_INT_MASK_IDM (1 << 19)
185#define MC13783_INT_MASK_SE1M (1 << 21)
186#define MC13783_INT_MASK_CKDETM (1 << 22)
187
188/* 110/*
189 * Reg Regulator Mode 0 111 * Reg Regulator Mode 0
190 */ 112 */
@@ -284,113 +206,15 @@ int mc13783_register_irq(struct mc13783 *mc13783, int irq,
284#define MC13783_SWCTRL_SW3_STBY (1 << 21) 206#define MC13783_SWCTRL_SW3_STBY (1 << 21)
285#define MC13783_SWCTRL_SW3_MODE (1 << 22) 207#define MC13783_SWCTRL_SW3_MODE (1 << 22)
286 208
287/* 209static inline int mc13783_set_bits(struct mc13783 *mc13783, unsigned int offset,
288 * ADC/Touch 210 u32 mask, u32 val)
289 */ 211{
290#define MC13783_ADC0_LICELLCON (1 << 0) 212 int ret;
291#define MC13783_ADC0_CHRGICON (1 << 1) 213 mc13783_lock(mc13783);
292#define MC13783_ADC0_BATICON (1 << 2) 214 ret = mc13783_reg_rmw(mc13783, offset, mask, val);
293#define MC13783_ADC0_RTHEN (1 << 3) 215 mc13783_unlock(mc13783);
294#define MC13783_ADC0_DTHEN (1 << 4)
295#define MC13783_ADC0_UIDEN (1 << 5)
296#define MC13783_ADC0_ADOUTEN (1 << 6)
297#define MC13783_ADC0_ADOUTPER (1 << 7)
298#define MC13783_ADC0_ADREFEN (1 << 10)
299#define MC13783_ADC0_ADREFMODE (1 << 11)
300#define MC13783_ADC0_TSMOD0 (1 << 12)
301#define MC13783_ADC0_TSMOD1 (1 << 13)
302#define MC13783_ADC0_TSMOD2 (1 << 14)
303#define MC13783_ADC0_CHRGRAWDIV (1 << 15)
304#define MC13783_ADC0_ADINC1 (1 << 16)
305#define MC13783_ADC0_ADINC2 (1 << 17)
306#define MC13783_ADC0_WCOMP (1 << 18)
307#define MC13783_ADC0_ADCBIS0 (1 << 23)
308
309#define MC13783_ADC1_ADEN (1 << 0)
310#define MC13783_ADC1_RAND (1 << 1)
311#define MC13783_ADC1_ADSEL (1 << 3)
312#define MC13783_ADC1_TRIGMASK (1 << 4)
313#define MC13783_ADC1_ADA10 (1 << 5)
314#define MC13783_ADC1_ADA11 (1 << 6)
315#define MC13783_ADC1_ADA12 (1 << 7)
316#define MC13783_ADC1_ADA20 (1 << 8)
317#define MC13783_ADC1_ADA21 (1 << 9)
318#define MC13783_ADC1_ADA22 (1 << 10)
319#define MC13783_ADC1_ATO0 (1 << 11)
320#define MC13783_ADC1_ATO1 (1 << 12)
321#define MC13783_ADC1_ATO2 (1 << 13)
322#define MC13783_ADC1_ATO3 (1 << 14)
323#define MC13783_ADC1_ATO4 (1 << 15)
324#define MC13783_ADC1_ATO5 (1 << 16)
325#define MC13783_ADC1_ATO6 (1 << 17)
326#define MC13783_ADC1_ATO7 (1 << 18)
327#define MC13783_ADC1_ATOX (1 << 19)
328#define MC13783_ADC1_ASC (1 << 20)
329#define MC13783_ADC1_ADTRIGIGN (1 << 21)
330#define MC13783_ADC1_ADONESHOT (1 << 22)
331#define MC13783_ADC1_ADCBIS1 (1 << 23)
332
333#define MC13783_ADC1_CHAN0_SHIFT 5
334#define MC13783_ADC1_CHAN1_SHIFT 8
335
336#define MC13783_ADC2_ADD10 (1 << 2)
337#define MC13783_ADC2_ADD11 (1 << 3)
338#define MC13783_ADC2_ADD12 (1 << 4)
339#define MC13783_ADC2_ADD13 (1 << 5)
340#define MC13783_ADC2_ADD14 (1 << 6)
341#define MC13783_ADC2_ADD15 (1 << 7)
342#define MC13783_ADC2_ADD16 (1 << 8)
343#define MC13783_ADC2_ADD17 (1 << 9)
344#define MC13783_ADC2_ADD18 (1 << 10)
345#define MC13783_ADC2_ADD19 (1 << 11)
346#define MC13783_ADC2_ADD20 (1 << 14)
347#define MC13783_ADC2_ADD21 (1 << 15)
348#define MC13783_ADC2_ADD22 (1 << 16)
349#define MC13783_ADC2_ADD23 (1 << 17)
350#define MC13783_ADC2_ADD24 (1 << 18)
351#define MC13783_ADC2_ADD25 (1 << 19)
352#define MC13783_ADC2_ADD26 (1 << 20)
353#define MC13783_ADC2_ADD27 (1 << 21)
354#define MC13783_ADC2_ADD28 (1 << 22)
355#define MC13783_ADC2_ADD29 (1 << 23)
356 216
357#define MC13783_ADC3_WHIGH0 (1 << 0) 217 return ret;
358#define MC13783_ADC3_WHIGH1 (1 << 1) 218}
359#define MC13783_ADC3_WHIGH2 (1 << 2)
360#define MC13783_ADC3_WHIGH3 (1 << 3)
361#define MC13783_ADC3_WHIGH4 (1 << 4)
362#define MC13783_ADC3_WHIGH5 (1 << 5)
363#define MC13783_ADC3_ICID0 (1 << 6)
364#define MC13783_ADC3_ICID1 (1 << 7)
365#define MC13783_ADC3_ICID2 (1 << 8)
366#define MC13783_ADC3_WLOW0 (1 << 9)
367#define MC13783_ADC3_WLOW1 (1 << 10)
368#define MC13783_ADC3_WLOW2 (1 << 11)
369#define MC13783_ADC3_WLOW3 (1 << 12)
370#define MC13783_ADC3_WLOW4 (1 << 13)
371#define MC13783_ADC3_WLOW5 (1 << 14)
372#define MC13783_ADC3_ADCBIS2 (1 << 23)
373
374#define MC13783_ADC4_ADDBIS10 (1 << 2)
375#define MC13783_ADC4_ADDBIS11 (1 << 3)
376#define MC13783_ADC4_ADDBIS12 (1 << 4)
377#define MC13783_ADC4_ADDBIS13 (1 << 5)
378#define MC13783_ADC4_ADDBIS14 (1 << 6)
379#define MC13783_ADC4_ADDBIS15 (1 << 7)
380#define MC13783_ADC4_ADDBIS16 (1 << 8)
381#define MC13783_ADC4_ADDBIS17 (1 << 9)
382#define MC13783_ADC4_ADDBIS18 (1 << 10)
383#define MC13783_ADC4_ADDBIS19 (1 << 11)
384#define MC13783_ADC4_ADDBIS20 (1 << 14)
385#define MC13783_ADC4_ADDBIS21 (1 << 15)
386#define MC13783_ADC4_ADDBIS22 (1 << 16)
387#define MC13783_ADC4_ADDBIS23 (1 << 17)
388#define MC13783_ADC4_ADDBIS24 (1 << 18)
389#define MC13783_ADC4_ADDBIS25 (1 << 19)
390#define MC13783_ADC4_ADDBIS26 (1 << 20)
391#define MC13783_ADC4_ADDBIS27 (1 << 21)
392#define MC13783_ADC4_ADDBIS28 (1 << 22)
393#define MC13783_ADC4_ADDBIS29 (1 << 23)
394 219
395#endif /* __LINUX_MFD_MC13783_PRIV_H */ 220#endif /* __LINUX_MFD_MC13783_PRIV_H */
396
diff --git a/include/linux/mfd/mc13783.h b/include/linux/mfd/mc13783.h
index b3a2a7243573..35680409b8cf 100644
--- a/include/linux/mfd/mc13783.h
+++ b/include/linux/mfd/mc13783.h
@@ -1,28 +1,50 @@
1/* 1/*
2 * Copyright 2009 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de> 2 * Copyright 2009 Pengutronix
3 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
3 * 4 *
4 * Initial development of this code was funded by 5 * This program is free software; you can redistribute it and/or modify it under
5 * Phytec Messtechnik GmbH, http://www.phytec.de 6 * the terms of the GNU General Public License version 2 as published by the
6 * 7 * Free Software Foundation.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 8 */
9#ifndef __LINUX_MFD_MC13783_H
10#define __LINUX_MFD_MC13783_H
21 11
22#ifndef __INCLUDE_LINUX_MFD_MC13783_H 12#include <linux/interrupt.h>
23#define __INCLUDE_LINUX_MFD_MC13783_H
24 13
25struct mc13783; 14struct mc13783;
15
16void mc13783_lock(struct mc13783 *mc13783);
17void mc13783_unlock(struct mc13783 *mc13783);
18
19int mc13783_reg_read(struct mc13783 *mc13783, unsigned int offset, u32 *val);
20int mc13783_reg_write(struct mc13783 *mc13783, unsigned int offset, u32 val);
21int mc13783_reg_rmw(struct mc13783 *mc13783, unsigned int offset,
22 u32 mask, u32 val);
23
24int mc13783_irq_request(struct mc13783 *mc13783, int irq,
25 irq_handler_t handler, const char *name, void *dev);
26int mc13783_irq_request_nounmask(struct mc13783 *mc13783, int irq,
27 irq_handler_t handler, const char *name, void *dev);
28int mc13783_irq_free(struct mc13783 *mc13783, int irq, void *dev);
29int mc13783_ackirq(struct mc13783 *mc13783, int irq);
30
31int mc13783_mask(struct mc13783 *mc13783, int irq);
32int mc13783_unmask(struct mc13783 *mc13783, int irq);
33
34#define MC13783_ADC0 43
35#define MC13783_ADC0_ADREFEN (1 << 10)
36#define MC13783_ADC0_ADREFMODE (1 << 11)
37#define MC13783_ADC0_TSMOD0 (1 << 12)
38#define MC13783_ADC0_TSMOD1 (1 << 13)
39#define MC13783_ADC0_TSMOD2 (1 << 14)
40#define MC13783_ADC0_ADINC1 (1 << 16)
41#define MC13783_ADC0_ADINC2 (1 << 17)
42
43#define MC13783_ADC0_TSMOD_MASK (MC13783_ADC0_TSMOD0 | \
44 MC13783_ADC0_TSMOD1 | \
45 MC13783_ADC0_TSMOD2)
46
47/* to be cleaned up */
26struct regulator_init_data; 48struct regulator_init_data;
27 49
28struct mc13783_regulator_init_data { 50struct mc13783_regulator_init_data {
@@ -30,23 +52,30 @@ struct mc13783_regulator_init_data {
30 struct regulator_init_data *init_data; 52 struct regulator_init_data *init_data;
31}; 53};
32 54
33struct mc13783_platform_data { 55struct mc13783_regulator_platform_data {
34 struct mc13783_regulator_init_data *regulators;
35 int num_regulators; 56 int num_regulators;
36 unsigned int flags; 57 struct mc13783_regulator_init_data *regulators;
37}; 58};
38 59
39/* mc13783_platform_data flags */ 60struct mc13783_platform_data {
61 int num_regulators;
62 struct mc13783_regulator_init_data *regulators;
63
40#define MC13783_USE_TOUCHSCREEN (1 << 0) 64#define MC13783_USE_TOUCHSCREEN (1 << 0)
41#define MC13783_USE_CODEC (1 << 1) 65#define MC13783_USE_CODEC (1 << 1)
42#define MC13783_USE_ADC (1 << 2) 66#define MC13783_USE_ADC (1 << 2)
43#define MC13783_USE_RTC (1 << 3) 67#define MC13783_USE_RTC (1 << 3)
44#define MC13783_USE_REGULATOR (1 << 4) 68#define MC13783_USE_REGULATOR (1 << 4)
69 unsigned int flags;
70};
71
72#define MC13783_ADC_MODE_TS 1
73#define MC13783_ADC_MODE_SINGLE_CHAN 2
74#define MC13783_ADC_MODE_MULT_CHAN 3
45 75
46int mc13783_adc_do_conversion(struct mc13783 *mc13783, unsigned int mode, 76int mc13783_adc_do_conversion(struct mc13783 *mc13783, unsigned int mode,
47 unsigned int channel, unsigned int *sample); 77 unsigned int channel, unsigned int *sample);
48 78
49void mc13783_adc_set_ts_status(struct mc13783 *mc13783, unsigned int status);
50 79
51#define MC13783_SW_SW1A 0 80#define MC13783_SW_SW1A 0
52#define MC13783_SW_SW1B 1 81#define MC13783_SW_SW1B 1
@@ -80,5 +109,46 @@ void mc13783_adc_set_ts_status(struct mc13783 *mc13783, unsigned int status);
80#define MC13783_REGU_V3 29 109#define MC13783_REGU_V3 29
81#define MC13783_REGU_V4 30 110#define MC13783_REGU_V4 30
82 111
83#endif /* __INCLUDE_LINUX_MFD_MC13783_H */ 112#define MC13783_IRQ_ADCDONE 0
113#define MC13783_IRQ_ADCBISDONE 1
114#define MC13783_IRQ_TS 2
115#define MC13783_IRQ_WHIGH 3
116#define MC13783_IRQ_WLOW 4
117#define MC13783_IRQ_CHGDET 6
118#define MC13783_IRQ_CHGOV 7
119#define MC13783_IRQ_CHGREV 8
120#define MC13783_IRQ_CHGSHORT 9
121#define MC13783_IRQ_CCCV 10
122#define MC13783_IRQ_CHGCURR 11
123#define MC13783_IRQ_BPON 12
124#define MC13783_IRQ_LOBATL 13
125#define MC13783_IRQ_LOBATH 14
126#define MC13783_IRQ_UDP 15
127#define MC13783_IRQ_USB 16
128#define MC13783_IRQ_ID 19
129#define MC13783_IRQ_SE1 21
130#define MC13783_IRQ_CKDET 22
131#define MC13783_IRQ_UDM 23
132#define MC13783_IRQ_1HZ 24
133#define MC13783_IRQ_TODA 25
134#define MC13783_IRQ_ONOFD1 27
135#define MC13783_IRQ_ONOFD2 28
136#define MC13783_IRQ_ONOFD3 29
137#define MC13783_IRQ_SYSRST 30
138#define MC13783_IRQ_RTCRST 31
139#define MC13783_IRQ_PC 32
140#define MC13783_IRQ_WARM 33
141#define MC13783_IRQ_MEMHLD 34
142#define MC13783_IRQ_PWRRDY 35
143#define MC13783_IRQ_THWARNL 36
144#define MC13783_IRQ_THWARNH 37
145#define MC13783_IRQ_CLK 38
146#define MC13783_IRQ_SEMAF 39
147#define MC13783_IRQ_MC2B 41
148#define MC13783_IRQ_HSDET 42
149#define MC13783_IRQ_HSL 43
150#define MC13783_IRQ_ALSPTH 44
151#define MC13783_IRQ_AHSSHORT 45
152#define MC13783_NUM_IRQ 46
84 153
154#endif /* __LINUX_MFD_MC13783_H */
diff --git a/include/linux/mfd/pcf50633/core.h b/include/linux/mfd/pcf50633/core.h
index 9aba7b779fbc..d9034cc87f18 100644
--- a/include/linux/mfd/pcf50633/core.h
+++ b/include/linux/mfd/pcf50633/core.h
@@ -40,10 +40,6 @@ struct pcf50633_platform_data {
40 u8 resumers[5]; 40 u8 resumers[5];
41}; 41};
42 42
43struct pcf50633_subdev_pdata {
44 struct pcf50633 *pcf;
45};
46
47struct pcf50633_irq { 43struct pcf50633_irq {
48 void (*handler) (int, void *); 44 void (*handler) (int, void *);
49 void *data; 45 void *data;
@@ -217,5 +213,9 @@ enum pcf50633_reg_int5 {
217#define PCF50633_REG_LEDCTL 0x2a 213#define PCF50633_REG_LEDCTL 0x2a
218#define PCF50633_REG_LEDDIM 0x2b 214#define PCF50633_REG_LEDDIM 0x2b
219 215
220#endif 216static inline struct pcf50633 *dev_to_pcf50633(struct device *dev)
217{
218 return dev_get_drvdata(dev);
219}
221 220
221#endif
diff --git a/include/linux/mfd/wm831x/core.h b/include/linux/mfd/wm831x/core.h
index 91eb493bf14c..5184b79c700b 100644
--- a/include/linux/mfd/wm831x/core.h
+++ b/include/linux/mfd/wm831x/core.h
@@ -16,7 +16,6 @@
16#define __MFD_WM831X_CORE_H__ 16#define __MFD_WM831X_CORE_H__
17 17
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/workqueue.h>
20 19
21/* 20/*
22 * Register values. 21 * Register values.
@@ -117,6 +116,7 @@
117#define WM831X_DC3_SLEEP_CONTROL 0x4063 116#define WM831X_DC3_SLEEP_CONTROL 0x4063
118#define WM831X_DC4_CONTROL 0x4064 117#define WM831X_DC4_CONTROL 0x4064
119#define WM831X_DC4_SLEEP_CONTROL 0x4065 118#define WM831X_DC4_SLEEP_CONTROL 0x4065
119#define WM832X_DC4_SLEEP_CONTROL 0x4067
120#define WM831X_EPE1_CONTROL 0x4066 120#define WM831X_EPE1_CONTROL 0x4066
121#define WM831X_EPE2_CONTROL 0x4067 121#define WM831X_EPE2_CONTROL 0x4067
122#define WM831X_LDO1_CONTROL 0x4068 122#define WM831X_LDO1_CONTROL 0x4068
@@ -235,6 +235,8 @@
235 235
236struct regulator_dev; 236struct regulator_dev;
237 237
238#define WM831X_NUM_IRQ_REGS 5
239
238struct wm831x { 240struct wm831x {
239 struct mutex io_lock; 241 struct mutex io_lock;
240 242
@@ -248,10 +250,11 @@ struct wm831x {
248 250
249 int irq; /* Our chip IRQ */ 251 int irq; /* Our chip IRQ */
250 struct mutex irq_lock; 252 struct mutex irq_lock;
251 struct workqueue_struct *irq_wq;
252 struct work_struct irq_work;
253 unsigned int irq_base; 253 unsigned int irq_base;
254 int irq_masks[5]; 254 int irq_masks_cur[WM831X_NUM_IRQ_REGS]; /* Currently active value */
255 int irq_masks_cache[WM831X_NUM_IRQ_REGS]; /* Cached hardware value */
256
257 int num_gpio;
255 258
256 struct mutex auxadc_lock; 259 struct mutex auxadc_lock;
257 260
@@ -278,12 +281,30 @@ int wm831x_bulk_read(struct wm831x *wm831x, unsigned short reg,
278int wm831x_irq_init(struct wm831x *wm831x, int irq); 281int wm831x_irq_init(struct wm831x *wm831x, int irq);
279void wm831x_irq_exit(struct wm831x *wm831x); 282void wm831x_irq_exit(struct wm831x *wm831x);
280 283
281int __must_check wm831x_request_irq(struct wm831x *wm831x, 284static inline int __must_check wm831x_request_irq(struct wm831x *wm831x,
282 unsigned int irq, irq_handler_t handler, 285 unsigned int irq,
283 unsigned long flags, const char *name, 286 irq_handler_t handler,
284 void *dev); 287 unsigned long flags,
285void wm831x_free_irq(struct wm831x *wm831x, unsigned int, void *); 288 const char *name,
286void wm831x_disable_irq(struct wm831x *wm831x, int irq); 289 void *dev)
287void wm831x_enable_irq(struct wm831x *wm831x, int irq); 290{
291 return request_threaded_irq(irq, NULL, handler, flags, name, dev);
292}
293
294static inline void wm831x_free_irq(struct wm831x *wm831x,
295 unsigned int irq, void *dev)
296{
297 free_irq(irq, dev);
298}
299
300static inline void wm831x_disable_irq(struct wm831x *wm831x, int irq)
301{
302 disable_irq(irq);
303}
304
305static inline void wm831x_enable_irq(struct wm831x *wm831x, int irq)
306{
307 enable_irq(irq);
308}
288 309
289#endif 310#endif
diff --git a/include/linux/mfd/wm831x/pdata.h b/include/linux/mfd/wm831x/pdata.h
index 90d820260aad..415c228743d5 100644
--- a/include/linux/mfd/wm831x/pdata.h
+++ b/include/linux/mfd/wm831x/pdata.h
@@ -91,6 +91,7 @@ struct wm831x_pdata {
91 /** Called after subdevices are set up */ 91 /** Called after subdevices are set up */
92 int (*post_init)(struct wm831x *wm831x); 92 int (*post_init)(struct wm831x *wm831x);
93 93
94 int irq_base;
94 int gpio_base; 95 int gpio_base;
95 struct wm831x_backlight_pdata *backlight; 96 struct wm831x_backlight_pdata *backlight;
96 struct wm831x_backup_pdata *backup; 97 struct wm831x_backup_pdata *backup;
diff --git a/include/linux/mfd/wm8350/core.h b/include/linux/mfd/wm8350/core.h
index 1d595de6a055..43868899bf49 100644
--- a/include/linux/mfd/wm8350/core.h
+++ b/include/linux/mfd/wm8350/core.h
@@ -15,7 +15,7 @@
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/mutex.h> 17#include <linux/mutex.h>
18#include <linux/workqueue.h> 18#include <linux/interrupt.h>
19 19
20#include <linux/mfd/wm8350/audio.h> 20#include <linux/mfd/wm8350/audio.h>
21#include <linux/mfd/wm8350/gpio.h> 21#include <linux/mfd/wm8350/gpio.h>
@@ -601,7 +601,7 @@ extern const u16 wm8352_mode3_defaults[];
601struct wm8350; 601struct wm8350;
602 602
603struct wm8350_irq { 603struct wm8350_irq {
604 void (*handler) (struct wm8350 *, int, void *); 604 irq_handler_t handler;
605 void *data; 605 void *data;
606}; 606};
607 607
@@ -646,10 +646,12 @@ struct wm8350 {
646 * @init: Function called during driver initialisation. Should be 646 * @init: Function called during driver initialisation. Should be
647 * used by the platform to configure GPIO functions and similar. 647 * used by the platform to configure GPIO functions and similar.
648 * @irq_high: Set if WM8350 IRQ is active high. 648 * @irq_high: Set if WM8350 IRQ is active high.
649 * @irq_base: Base IRQ for genirq (not currently used).
649 */ 650 */
650struct wm8350_platform_data { 651struct wm8350_platform_data {
651 int (*init)(struct wm8350 *wm8350); 652 int (*init)(struct wm8350 *wm8350);
652 int irq_high; 653 int irq_high;
654 int irq_base;
653}; 655};
654 656
655 657
@@ -676,11 +678,13 @@ int wm8350_block_write(struct wm8350 *wm8350, int reg, int size, u16 *src);
676 * WM8350 internal interrupts 678 * WM8350 internal interrupts
677 */ 679 */
678int wm8350_register_irq(struct wm8350 *wm8350, int irq, 680int wm8350_register_irq(struct wm8350 *wm8350, int irq,
679 void (*handler) (struct wm8350 *, int, void *), 681 irq_handler_t handler, unsigned long flags,
680 void *data); 682 const char *name, void *data);
681int wm8350_free_irq(struct wm8350 *wm8350, int irq); 683int wm8350_free_irq(struct wm8350 *wm8350, int irq);
682int wm8350_mask_irq(struct wm8350 *wm8350, int irq); 684int wm8350_mask_irq(struct wm8350 *wm8350, int irq);
683int wm8350_unmask_irq(struct wm8350 *wm8350, int irq); 685int wm8350_unmask_irq(struct wm8350 *wm8350, int irq);
684 686int wm8350_irq_init(struct wm8350 *wm8350, int irq,
687 struct wm8350_platform_data *pdata);
688int wm8350_irq_exit(struct wm8350 *wm8350);
685 689
686#endif 690#endif
diff --git a/include/linux/mfd/wm8350/gpio.h b/include/linux/mfd/wm8350/gpio.h
index ed91e8f5d298..71af3d6ebe9d 100644
--- a/include/linux/mfd/wm8350/gpio.h
+++ b/include/linux/mfd/wm8350/gpio.h
@@ -173,6 +173,24 @@
173#define WM8350_GPIO_DEBOUNCE_ON 1 173#define WM8350_GPIO_DEBOUNCE_ON 1
174 174
175/* 175/*
176 * R30 (0x1E) - GPIO Interrupt Status
177 */
178#define WM8350_GP12_EINT 0x1000
179#define WM8350_GP11_EINT 0x0800
180#define WM8350_GP10_EINT 0x0400
181#define WM8350_GP9_EINT 0x0200
182#define WM8350_GP8_EINT 0x0100
183#define WM8350_GP7_EINT 0x0080
184#define WM8350_GP6_EINT 0x0040
185#define WM8350_GP5_EINT 0x0020
186#define WM8350_GP4_EINT 0x0010
187#define WM8350_GP3_EINT 0x0008
188#define WM8350_GP2_EINT 0x0004
189#define WM8350_GP1_EINT 0x0002
190#define WM8350_GP0_EINT 0x0001
191
192
193/*
176 * R128 (0x80) - GPIO Debounce 194 * R128 (0x80) - GPIO Debounce
177 */ 195 */
178#define WM8350_GP12_DB 0x1000 196#define WM8350_GP12_DB 0x1000
diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h
index c4c060208109..9b8299af3741 100644
--- a/include/linux/nfs4.h
+++ b/include/linux/nfs4.h
@@ -128,6 +128,8 @@
128#define SEQ4_STATUS_RECALLABLE_STATE_REVOKED 0x00000040 128#define SEQ4_STATUS_RECALLABLE_STATE_REVOKED 0x00000040
129#define SEQ4_STATUS_LEASE_MOVED 0x00000080 129#define SEQ4_STATUS_LEASE_MOVED 0x00000080
130#define SEQ4_STATUS_RESTART_RECLAIM_NEEDED 0x00000100 130#define SEQ4_STATUS_RESTART_RECLAIM_NEEDED 0x00000100
131#define SEQ4_STATUS_CB_PATH_DOWN_SESSION 0x00000200
132#define SEQ4_STATUS_BACKCHANNEL_FAULT 0x00000400
131 133
132#define NFS4_MAX_UINT64 (~(u64)0) 134#define NFS4_MAX_UINT64 (~(u64)0)
133 135
@@ -528,6 +530,7 @@ enum {
528 NFSPROC4_CLNT_DESTROY_SESSION, 530 NFSPROC4_CLNT_DESTROY_SESSION,
529 NFSPROC4_CLNT_SEQUENCE, 531 NFSPROC4_CLNT_SEQUENCE,
530 NFSPROC4_CLNT_GET_LEASE_TIME, 532 NFSPROC4_CLNT_GET_LEASE_TIME,
533 NFSPROC4_CLNT_RECLAIM_COMPLETE,
531}; 534};
532 535
533/* nfs41 types */ 536/* nfs41 types */
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index 320569eabe3b..34fc6be5bfcf 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -209,6 +209,7 @@ struct nfs4_session {
209 unsigned long session_state; 209 unsigned long session_state;
210 u32 hash_alg; 210 u32 hash_alg;
211 u32 ssv_len; 211 u32 ssv_len;
212 struct completion complete;
212 213
213 /* The fore and back channel */ 214 /* The fore and back channel */
214 struct nfs4_channel_attrs fc_attrs; 215 struct nfs4_channel_attrs fc_attrs;
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index 62f63fb0c4c8..51071b335751 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -170,8 +170,9 @@ struct nfs4_sequence_args {
170struct nfs4_sequence_res { 170struct nfs4_sequence_res {
171 struct nfs4_session *sr_session; 171 struct nfs4_session *sr_session;
172 u8 sr_slotid; /* slot used to send request */ 172 u8 sr_slotid; /* slot used to send request */
173 unsigned long sr_renewal_time;
174 int sr_status; /* sequence operation status */ 173 int sr_status; /* sequence operation status */
174 unsigned long sr_renewal_time;
175 u32 sr_status_flags;
175}; 176};
176 177
177struct nfs4_get_lease_time_args { 178struct nfs4_get_lease_time_args {
@@ -938,6 +939,16 @@ struct nfs41_create_session_args {
938struct nfs41_create_session_res { 939struct nfs41_create_session_res {
939 struct nfs_client *client; 940 struct nfs_client *client;
940}; 941};
942
943struct nfs41_reclaim_complete_args {
944 /* In the future extend to include curr_fh for use with migration */
945 unsigned char one_fs:1;
946 struct nfs4_sequence_args seq_args;
947};
948
949struct nfs41_reclaim_complete_res {
950 struct nfs4_sequence_res seq_res;
951};
941#endif /* CONFIG_NFS_V4_1 */ 952#endif /* CONFIG_NFS_V4_1 */
942 953
943struct nfs_page; 954struct nfs_page;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 04771b9c3316..bf1e67080849 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1255,7 +1255,7 @@ extern int pci_pci_problems;
1255 1255
1256extern unsigned long pci_cardbus_io_size; 1256extern unsigned long pci_cardbus_io_size;
1257extern unsigned long pci_cardbus_mem_size; 1257extern unsigned long pci_cardbus_mem_size;
1258extern u8 pci_dfl_cache_line_size; 1258extern u8 __devinitdata pci_dfl_cache_line_size;
1259extern u8 pci_cache_line_size; 1259extern u8 pci_cache_line_size;
1260 1260
1261extern unsigned long pci_hotplug_io_size; 1261extern unsigned long pci_hotplug_io_size;
diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h
index 9bd03193ecd4..5a5d6ce4bd55 100644
--- a/include/linux/percpu-defs.h
+++ b/include/linux/percpu-defs.h
@@ -60,6 +60,7 @@
60 60
61#define DEFINE_PER_CPU_SECTION(type, name, sec) \ 61#define DEFINE_PER_CPU_SECTION(type, name, sec) \
62 __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \ 62 __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \
63 extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
63 __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \ 64 __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
64 __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES __weak \ 65 __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES __weak \
65 __typeof__(type) per_cpu__##name 66 __typeof__(type) per_cpu__##name
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index 878836ca999c..cf5efbcf716c 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -34,8 +34,6 @@
34 34
35#ifdef CONFIG_SMP 35#ifdef CONFIG_SMP
36 36
37#ifndef CONFIG_HAVE_LEGACY_PER_CPU_AREA
38
39/* minimum unit size, also is the maximum supported allocation size */ 37/* minimum unit size, also is the maximum supported allocation size */
40#define PCPU_MIN_UNIT_SIZE PFN_ALIGN(64 << 10) 38#define PCPU_MIN_UNIT_SIZE PFN_ALIGN(64 << 10)
41 39
@@ -130,30 +128,9 @@ extern int __init pcpu_page_first_chunk(size_t reserved_size,
130#define per_cpu_ptr(ptr, cpu) SHIFT_PERCPU_PTR((ptr), per_cpu_offset((cpu))) 128#define per_cpu_ptr(ptr, cpu) SHIFT_PERCPU_PTR((ptr), per_cpu_offset((cpu)))
131 129
132extern void *__alloc_reserved_percpu(size_t size, size_t align); 130extern void *__alloc_reserved_percpu(size_t size, size_t align);
133
134#else /* CONFIG_HAVE_LEGACY_PER_CPU_AREA */
135
136struct percpu_data {
137 void *ptrs[1];
138};
139
140/* pointer disguising messes up the kmemleak objects tracking */
141#ifndef CONFIG_DEBUG_KMEMLEAK
142#define __percpu_disguise(pdata) (struct percpu_data *)~(unsigned long)(pdata)
143#else
144#define __percpu_disguise(pdata) (struct percpu_data *)(pdata)
145#endif
146
147#define per_cpu_ptr(ptr, cpu) \
148({ \
149 struct percpu_data *__p = __percpu_disguise(ptr); \
150 (__typeof__(ptr))__p->ptrs[(cpu)]; \
151})
152
153#endif /* CONFIG_HAVE_LEGACY_PER_CPU_AREA */
154
155extern void *__alloc_percpu(size_t size, size_t align); 131extern void *__alloc_percpu(size_t size, size_t align);
156extern void free_percpu(void *__pdata); 132extern void free_percpu(void *__pdata);
133extern phys_addr_t per_cpu_ptr_to_phys(void *addr);
157 134
158#ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA 135#ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA
159extern void __init setup_per_cpu_areas(void); 136extern void __init setup_per_cpu_areas(void);
@@ -179,6 +156,11 @@ static inline void free_percpu(void *p)
179 kfree(p); 156 kfree(p);
180} 157}
181 158
159static inline phys_addr_t per_cpu_ptr_to_phys(void *addr)
160{
161 return __pa(addr);
162}
163
182static inline void __init setup_per_cpu_areas(void) { } 164static inline void __init setup_per_cpu_areas(void) { }
183 165
184static inline void *pcpu_lpage_remapped(void *kaddr) 166static inline void *pcpu_lpage_remapped(void *kaddr)
@@ -188,8 +170,8 @@ static inline void *pcpu_lpage_remapped(void *kaddr)
188 170
189#endif /* CONFIG_SMP */ 171#endif /* CONFIG_SMP */
190 172
191#define alloc_percpu(type) (type *)__alloc_percpu(sizeof(type), \ 173#define alloc_percpu(type) \
192 __alignof__(type)) 174 (typeof(type) *)__alloc_percpu(sizeof(type), __alignof__(type))
193 175
194/* 176/*
195 * Optional methods for optimized non-lvalue per-cpu variable access. 177 * Optional methods for optimized non-lvalue per-cpu variable access.
@@ -243,4 +225,404 @@ do { \
243# define percpu_xor(var, val) __percpu_generic_to_op(var, (val), ^=) 225# define percpu_xor(var, val) __percpu_generic_to_op(var, (val), ^=)
244#endif 226#endif
245 227
228/*
229 * Branching function to split up a function into a set of functions that
230 * are called for different scalar sizes of the objects handled.
231 */
232
233extern void __bad_size_call_parameter(void);
234
235#define __pcpu_size_call_return(stem, variable) \
236({ typeof(variable) pscr_ret__; \
237 switch(sizeof(variable)) { \
238 case 1: pscr_ret__ = stem##1(variable);break; \
239 case 2: pscr_ret__ = stem##2(variable);break; \
240 case 4: pscr_ret__ = stem##4(variable);break; \
241 case 8: pscr_ret__ = stem##8(variable);break; \
242 default: \
243 __bad_size_call_parameter();break; \
244 } \
245 pscr_ret__; \
246})
247
248#define __pcpu_size_call(stem, variable, ...) \
249do { \
250 switch(sizeof(variable)) { \
251 case 1: stem##1(variable, __VA_ARGS__);break; \
252 case 2: stem##2(variable, __VA_ARGS__);break; \
253 case 4: stem##4(variable, __VA_ARGS__);break; \
254 case 8: stem##8(variable, __VA_ARGS__);break; \
255 default: \
256 __bad_size_call_parameter();break; \
257 } \
258} while (0)
259
260/*
261 * Optimized manipulation for memory allocated through the per cpu
262 * allocator or for addresses of per cpu variables (can be determined
263 * using per_cpu_var(xx).
264 *
265 * These operation guarantee exclusivity of access for other operations
266 * on the *same* processor. The assumption is that per cpu data is only
267 * accessed by a single processor instance (the current one).
268 *
269 * The first group is used for accesses that must be done in a
270 * preemption safe way since we know that the context is not preempt
271 * safe. Interrupts may occur. If the interrupt modifies the variable
272 * too then RMW actions will not be reliable.
273 *
274 * The arch code can provide optimized functions in two ways:
275 *
276 * 1. Override the function completely. F.e. define this_cpu_add().
277 * The arch must then ensure that the various scalar format passed
278 * are handled correctly.
279 *
280 * 2. Provide functions for certain scalar sizes. F.e. provide
281 * this_cpu_add_2() to provide per cpu atomic operations for 2 byte
282 * sized RMW actions. If arch code does not provide operations for
283 * a scalar size then the fallback in the generic code will be
284 * used.
285 */
286
287#define _this_cpu_generic_read(pcp) \
288({ typeof(pcp) ret__; \
289 preempt_disable(); \
290 ret__ = *this_cpu_ptr(&(pcp)); \
291 preempt_enable(); \
292 ret__; \
293})
294
295#ifndef this_cpu_read
296# ifndef this_cpu_read_1
297# define this_cpu_read_1(pcp) _this_cpu_generic_read(pcp)
298# endif
299# ifndef this_cpu_read_2
300# define this_cpu_read_2(pcp) _this_cpu_generic_read(pcp)
301# endif
302# ifndef this_cpu_read_4
303# define this_cpu_read_4(pcp) _this_cpu_generic_read(pcp)
304# endif
305# ifndef this_cpu_read_8
306# define this_cpu_read_8(pcp) _this_cpu_generic_read(pcp)
307# endif
308# define this_cpu_read(pcp) __pcpu_size_call_return(this_cpu_read_, (pcp))
309#endif
310
311#define _this_cpu_generic_to_op(pcp, val, op) \
312do { \
313 preempt_disable(); \
314 *__this_cpu_ptr(&pcp) op val; \
315 preempt_enable(); \
316} while (0)
317
318#ifndef this_cpu_write
319# ifndef this_cpu_write_1
320# define this_cpu_write_1(pcp, val) _this_cpu_generic_to_op((pcp), (val), =)
321# endif
322# ifndef this_cpu_write_2
323# define this_cpu_write_2(pcp, val) _this_cpu_generic_to_op((pcp), (val), =)
324# endif
325# ifndef this_cpu_write_4
326# define this_cpu_write_4(pcp, val) _this_cpu_generic_to_op((pcp), (val), =)
327# endif
328# ifndef this_cpu_write_8
329# define this_cpu_write_8(pcp, val) _this_cpu_generic_to_op((pcp), (val), =)
330# endif
331# define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, (pcp), (val))
332#endif
333
334#ifndef this_cpu_add
335# ifndef this_cpu_add_1
336# define this_cpu_add_1(pcp, val) _this_cpu_generic_to_op((pcp), (val), +=)
337# endif
338# ifndef this_cpu_add_2
339# define this_cpu_add_2(pcp, val) _this_cpu_generic_to_op((pcp), (val), +=)
340# endif
341# ifndef this_cpu_add_4
342# define this_cpu_add_4(pcp, val) _this_cpu_generic_to_op((pcp), (val), +=)
343# endif
344# ifndef this_cpu_add_8
345# define this_cpu_add_8(pcp, val) _this_cpu_generic_to_op((pcp), (val), +=)
346# endif
347# define this_cpu_add(pcp, val) __pcpu_size_call(this_cpu_add_, (pcp), (val))
348#endif
349
350#ifndef this_cpu_sub
351# define this_cpu_sub(pcp, val) this_cpu_add((pcp), -(val))
352#endif
353
354#ifndef this_cpu_inc
355# define this_cpu_inc(pcp) this_cpu_add((pcp), 1)
356#endif
357
358#ifndef this_cpu_dec
359# define this_cpu_dec(pcp) this_cpu_sub((pcp), 1)
360#endif
361
362#ifndef this_cpu_and
363# ifndef this_cpu_and_1
364# define this_cpu_and_1(pcp, val) _this_cpu_generic_to_op((pcp), (val), &=)
365# endif
366# ifndef this_cpu_and_2
367# define this_cpu_and_2(pcp, val) _this_cpu_generic_to_op((pcp), (val), &=)
368# endif
369# ifndef this_cpu_and_4
370# define this_cpu_and_4(pcp, val) _this_cpu_generic_to_op((pcp), (val), &=)
371# endif
372# ifndef this_cpu_and_8
373# define this_cpu_and_8(pcp, val) _this_cpu_generic_to_op((pcp), (val), &=)
374# endif
375# define this_cpu_and(pcp, val) __pcpu_size_call(this_cpu_and_, (pcp), (val))
376#endif
377
378#ifndef this_cpu_or
379# ifndef this_cpu_or_1
380# define this_cpu_or_1(pcp, val) _this_cpu_generic_to_op((pcp), (val), |=)
381# endif
382# ifndef this_cpu_or_2
383# define this_cpu_or_2(pcp, val) _this_cpu_generic_to_op((pcp), (val), |=)
384# endif
385# ifndef this_cpu_or_4
386# define this_cpu_or_4(pcp, val) _this_cpu_generic_to_op((pcp), (val), |=)
387# endif
388# ifndef this_cpu_or_8
389# define this_cpu_or_8(pcp, val) _this_cpu_generic_to_op((pcp), (val), |=)
390# endif
391# define this_cpu_or(pcp, val) __pcpu_size_call(this_cpu_or_, (pcp), (val))
392#endif
393
394#ifndef this_cpu_xor
395# ifndef this_cpu_xor_1
396# define this_cpu_xor_1(pcp, val) _this_cpu_generic_to_op((pcp), (val), ^=)
397# endif
398# ifndef this_cpu_xor_2
399# define this_cpu_xor_2(pcp, val) _this_cpu_generic_to_op((pcp), (val), ^=)
400# endif
401# ifndef this_cpu_xor_4
402# define this_cpu_xor_4(pcp, val) _this_cpu_generic_to_op((pcp), (val), ^=)
403# endif
404# ifndef this_cpu_xor_8
405# define this_cpu_xor_8(pcp, val) _this_cpu_generic_to_op((pcp), (val), ^=)
406# endif
407# define this_cpu_xor(pcp, val) __pcpu_size_call(this_cpu_or_, (pcp), (val))
408#endif
409
410/*
411 * Generic percpu operations that do not require preemption handling.
412 * Either we do not care about races or the caller has the
413 * responsibility of handling preemptions issues. Arch code can still
414 * override these instructions since the arch per cpu code may be more
415 * efficient and may actually get race freeness for free (that is the
416 * case for x86 for example).
417 *
418 * If there is no other protection through preempt disable and/or
419 * disabling interupts then one of these RMW operations can show unexpected
420 * behavior because the execution thread was rescheduled on another processor
421 * or an interrupt occurred and the same percpu variable was modified from
422 * the interrupt context.
423 */
424#ifndef __this_cpu_read
425# ifndef __this_cpu_read_1
426# define __this_cpu_read_1(pcp) (*__this_cpu_ptr(&(pcp)))
427# endif
428# ifndef __this_cpu_read_2
429# define __this_cpu_read_2(pcp) (*__this_cpu_ptr(&(pcp)))
430# endif
431# ifndef __this_cpu_read_4
432# define __this_cpu_read_4(pcp) (*__this_cpu_ptr(&(pcp)))
433# endif
434# ifndef __this_cpu_read_8
435# define __this_cpu_read_8(pcp) (*__this_cpu_ptr(&(pcp)))
436# endif
437# define __this_cpu_read(pcp) __pcpu_size_call_return(__this_cpu_read_, (pcp))
438#endif
439
440#define __this_cpu_generic_to_op(pcp, val, op) \
441do { \
442 *__this_cpu_ptr(&(pcp)) op val; \
443} while (0)
444
445#ifndef __this_cpu_write
446# ifndef __this_cpu_write_1
447# define __this_cpu_write_1(pcp, val) __this_cpu_generic_to_op((pcp), (val), =)
448# endif
449# ifndef __this_cpu_write_2
450# define __this_cpu_write_2(pcp, val) __this_cpu_generic_to_op((pcp), (val), =)
451# endif
452# ifndef __this_cpu_write_4
453# define __this_cpu_write_4(pcp, val) __this_cpu_generic_to_op((pcp), (val), =)
454# endif
455# ifndef __this_cpu_write_8
456# define __this_cpu_write_8(pcp, val) __this_cpu_generic_to_op((pcp), (val), =)
457# endif
458# define __this_cpu_write(pcp, val) __pcpu_size_call(__this_cpu_write_, (pcp), (val))
459#endif
460
461#ifndef __this_cpu_add
462# ifndef __this_cpu_add_1
463# define __this_cpu_add_1(pcp, val) __this_cpu_generic_to_op((pcp), (val), +=)
464# endif
465# ifndef __this_cpu_add_2
466# define __this_cpu_add_2(pcp, val) __this_cpu_generic_to_op((pcp), (val), +=)
467# endif
468# ifndef __this_cpu_add_4
469# define __this_cpu_add_4(pcp, val) __this_cpu_generic_to_op((pcp), (val), +=)
470# endif
471# ifndef __this_cpu_add_8
472# define __this_cpu_add_8(pcp, val) __this_cpu_generic_to_op((pcp), (val), +=)
473# endif
474# define __this_cpu_add(pcp, val) __pcpu_size_call(__this_cpu_add_, (pcp), (val))
475#endif
476
477#ifndef __this_cpu_sub
478# define __this_cpu_sub(pcp, val) __this_cpu_add((pcp), -(val))
479#endif
480
481#ifndef __this_cpu_inc
482# define __this_cpu_inc(pcp) __this_cpu_add((pcp), 1)
483#endif
484
485#ifndef __this_cpu_dec
486# define __this_cpu_dec(pcp) __this_cpu_sub((pcp), 1)
487#endif
488
489#ifndef __this_cpu_and
490# ifndef __this_cpu_and_1
491# define __this_cpu_and_1(pcp, val) __this_cpu_generic_to_op((pcp), (val), &=)
492# endif
493# ifndef __this_cpu_and_2
494# define __this_cpu_and_2(pcp, val) __this_cpu_generic_to_op((pcp), (val), &=)
495# endif
496# ifndef __this_cpu_and_4
497# define __this_cpu_and_4(pcp, val) __this_cpu_generic_to_op((pcp), (val), &=)
498# endif
499# ifndef __this_cpu_and_8
500# define __this_cpu_and_8(pcp, val) __this_cpu_generic_to_op((pcp), (val), &=)
501# endif
502# define __this_cpu_and(pcp, val) __pcpu_size_call(__this_cpu_and_, (pcp), (val))
503#endif
504
505#ifndef __this_cpu_or
506# ifndef __this_cpu_or_1
507# define __this_cpu_or_1(pcp, val) __this_cpu_generic_to_op((pcp), (val), |=)
508# endif
509# ifndef __this_cpu_or_2
510# define __this_cpu_or_2(pcp, val) __this_cpu_generic_to_op((pcp), (val), |=)
511# endif
512# ifndef __this_cpu_or_4
513# define __this_cpu_or_4(pcp, val) __this_cpu_generic_to_op((pcp), (val), |=)
514# endif
515# ifndef __this_cpu_or_8
516# define __this_cpu_or_8(pcp, val) __this_cpu_generic_to_op((pcp), (val), |=)
517# endif
518# define __this_cpu_or(pcp, val) __pcpu_size_call(__this_cpu_or_, (pcp), (val))
519#endif
520
521#ifndef __this_cpu_xor
522# ifndef __this_cpu_xor_1
523# define __this_cpu_xor_1(pcp, val) __this_cpu_generic_to_op((pcp), (val), ^=)
524# endif
525# ifndef __this_cpu_xor_2
526# define __this_cpu_xor_2(pcp, val) __this_cpu_generic_to_op((pcp), (val), ^=)
527# endif
528# ifndef __this_cpu_xor_4
529# define __this_cpu_xor_4(pcp, val) __this_cpu_generic_to_op((pcp), (val), ^=)
530# endif
531# ifndef __this_cpu_xor_8
532# define __this_cpu_xor_8(pcp, val) __this_cpu_generic_to_op((pcp), (val), ^=)
533# endif
534# define __this_cpu_xor(pcp, val) __pcpu_size_call(__this_cpu_xor_, (pcp), (val))
535#endif
536
537/*
538 * IRQ safe versions of the per cpu RMW operations. Note that these operations
539 * are *not* safe against modification of the same variable from another
540 * processors (which one gets when using regular atomic operations)
541 . They are guaranteed to be atomic vs. local interrupts and
542 * preemption only.
543 */
544#define irqsafe_cpu_generic_to_op(pcp, val, op) \
545do { \
546 unsigned long flags; \
547 local_irq_save(flags); \
548 *__this_cpu_ptr(&(pcp)) op val; \
549 local_irq_restore(flags); \
550} while (0)
551
552#ifndef irqsafe_cpu_add
553# ifndef irqsafe_cpu_add_1
554# define irqsafe_cpu_add_1(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), +=)
555# endif
556# ifndef irqsafe_cpu_add_2
557# define irqsafe_cpu_add_2(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), +=)
558# endif
559# ifndef irqsafe_cpu_add_4
560# define irqsafe_cpu_add_4(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), +=)
561# endif
562# ifndef irqsafe_cpu_add_8
563# define irqsafe_cpu_add_8(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), +=)
564# endif
565# define irqsafe_cpu_add(pcp, val) __pcpu_size_call(irqsafe_cpu_add_, (pcp), (val))
566#endif
567
568#ifndef irqsafe_cpu_sub
569# define irqsafe_cpu_sub(pcp, val) irqsafe_cpu_add((pcp), -(val))
570#endif
571
572#ifndef irqsafe_cpu_inc
573# define irqsafe_cpu_inc(pcp) irqsafe_cpu_add((pcp), 1)
574#endif
575
576#ifndef irqsafe_cpu_dec
577# define irqsafe_cpu_dec(pcp) irqsafe_cpu_sub((pcp), 1)
578#endif
579
580#ifndef irqsafe_cpu_and
581# ifndef irqsafe_cpu_and_1
582# define irqsafe_cpu_and_1(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), &=)
583# endif
584# ifndef irqsafe_cpu_and_2
585# define irqsafe_cpu_and_2(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), &=)
586# endif
587# ifndef irqsafe_cpu_and_4
588# define irqsafe_cpu_and_4(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), &=)
589# endif
590# ifndef irqsafe_cpu_and_8
591# define irqsafe_cpu_and_8(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), &=)
592# endif
593# define irqsafe_cpu_and(pcp, val) __pcpu_size_call(irqsafe_cpu_and_, (val))
594#endif
595
596#ifndef irqsafe_cpu_or
597# ifndef irqsafe_cpu_or_1
598# define irqsafe_cpu_or_1(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), |=)
599# endif
600# ifndef irqsafe_cpu_or_2
601# define irqsafe_cpu_or_2(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), |=)
602# endif
603# ifndef irqsafe_cpu_or_4
604# define irqsafe_cpu_or_4(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), |=)
605# endif
606# ifndef irqsafe_cpu_or_8
607# define irqsafe_cpu_or_8(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), |=)
608# endif
609# define irqsafe_cpu_or(pcp, val) __pcpu_size_call(irqsafe_cpu_or_, (val))
610#endif
611
612#ifndef irqsafe_cpu_xor
613# ifndef irqsafe_cpu_xor_1
614# define irqsafe_cpu_xor_1(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), ^=)
615# endif
616# ifndef irqsafe_cpu_xor_2
617# define irqsafe_cpu_xor_2(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), ^=)
618# endif
619# ifndef irqsafe_cpu_xor_4
620# define irqsafe_cpu_xor_4(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), ^=)
621# endif
622# ifndef irqsafe_cpu_xor_8
623# define irqsafe_cpu_xor_8(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), ^=)
624# endif
625# define irqsafe_cpu_xor(pcp, val) __pcpu_size_call(irqsafe_cpu_xor_, (val))
626#endif
627
246#endif /* __LINUX_PERCPU_H */ 628#endif /* __LINUX_PERCPU_H */
diff --git a/include/linux/raid/pq.h b/include/linux/raid/pq.h
index d92480f8285c..1cbbd2c11aa9 100644
--- a/include/linux/raid/pq.h
+++ b/include/linux/raid/pq.h
@@ -78,6 +78,25 @@ struct raid6_calls {
78/* Selected algorithm */ 78/* Selected algorithm */
79extern struct raid6_calls raid6_call; 79extern struct raid6_calls raid6_call;
80 80
81/* Various routine sets */
82extern const struct raid6_calls raid6_intx1;
83extern const struct raid6_calls raid6_intx2;
84extern const struct raid6_calls raid6_intx4;
85extern const struct raid6_calls raid6_intx8;
86extern const struct raid6_calls raid6_intx16;
87extern const struct raid6_calls raid6_intx32;
88extern const struct raid6_calls raid6_mmxx1;
89extern const struct raid6_calls raid6_mmxx2;
90extern const struct raid6_calls raid6_sse1x1;
91extern const struct raid6_calls raid6_sse1x2;
92extern const struct raid6_calls raid6_sse2x1;
93extern const struct raid6_calls raid6_sse2x2;
94extern const struct raid6_calls raid6_sse2x4;
95extern const struct raid6_calls raid6_altivec1;
96extern const struct raid6_calls raid6_altivec2;
97extern const struct raid6_calls raid6_altivec4;
98extern const struct raid6_calls raid6_altivec8;
99
81/* Algorithm list */ 100/* Algorithm list */
82extern const struct raid6_calls * const raid6_algos[]; 101extern const struct raid6_calls * const raid6_algos[];
83int raid6_select_algo(void); 102int raid6_select_algo(void);
diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
index 850d057500de..ca6b2b317991 100644
--- a/include/linux/slab_def.h
+++ b/include/linux/slab_def.h
@@ -110,7 +110,7 @@ extern struct cache_sizes malloc_sizes[];
110void *kmem_cache_alloc(struct kmem_cache *, gfp_t); 110void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
111void *__kmalloc(size_t size, gfp_t flags); 111void *__kmalloc(size_t size, gfp_t flags);
112 112
113#ifdef CONFIG_KMEMTRACE 113#ifdef CONFIG_TRACING
114extern void *kmem_cache_alloc_notrace(struct kmem_cache *cachep, gfp_t flags); 114extern void *kmem_cache_alloc_notrace(struct kmem_cache *cachep, gfp_t flags);
115extern size_t slab_buffer_size(struct kmem_cache *cachep); 115extern size_t slab_buffer_size(struct kmem_cache *cachep);
116#else 116#else
@@ -166,7 +166,7 @@ found:
166extern void *__kmalloc_node(size_t size, gfp_t flags, int node); 166extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
167extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node); 167extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
168 168
169#ifdef CONFIG_KMEMTRACE 169#ifdef CONFIG_TRACING
170extern void *kmem_cache_alloc_node_notrace(struct kmem_cache *cachep, 170extern void *kmem_cache_alloc_node_notrace(struct kmem_cache *cachep,
171 gfp_t flags, 171 gfp_t flags,
172 int nodeid); 172 int nodeid);
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index 5ad70a60fd74..1e14beb23f9b 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -217,7 +217,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
217void *kmem_cache_alloc(struct kmem_cache *, gfp_t); 217void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
218void *__kmalloc(size_t size, gfp_t flags); 218void *__kmalloc(size_t size, gfp_t flags);
219 219
220#ifdef CONFIG_KMEMTRACE 220#ifdef CONFIG_TRACING
221extern void *kmem_cache_alloc_notrace(struct kmem_cache *s, gfp_t gfpflags); 221extern void *kmem_cache_alloc_notrace(struct kmem_cache *s, gfp_t gfpflags);
222#else 222#else
223static __always_inline void * 223static __always_inline void *
@@ -266,7 +266,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
266void *__kmalloc_node(size_t size, gfp_t flags, int node); 266void *__kmalloc_node(size_t size, gfp_t flags, int node);
267void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node); 267void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
268 268
269#ifdef CONFIG_KMEMTRACE 269#ifdef CONFIG_TRACING
270extern void *kmem_cache_alloc_node_notrace(struct kmem_cache *s, 270extern void *kmem_cache_alloc_node_notrace(struct kmem_cache *s,
271 gfp_t gfpflags, 271 gfp_t gfpflags,
272 int node); 272 int node);
diff --git a/include/linux/spi/mpc52xx_spi.h b/include/linux/spi/mpc52xx_spi.h
deleted file mode 100644
index d1004cf09241..000000000000
--- a/include/linux/spi/mpc52xx_spi.h
+++ /dev/null
@@ -1,10 +0,0 @@
1
2#ifndef INCLUDE_MPC5200_SPI_H
3#define INCLUDE_MPC5200_SPI_H
4
5extern void mpc52xx_spi_set_premessage_hook(struct spi_master *master,
6 void (*hook)(struct spi_message *m,
7 void *context),
8 void *hook_context);
9
10#endif
diff --git a/include/linux/spi/sh_msiof.h b/include/linux/spi/sh_msiof.h
new file mode 100644
index 000000000000..2e8db3d2d2e5
--- /dev/null
+++ b/include/linux/spi/sh_msiof.h
@@ -0,0 +1,10 @@
1#ifndef __SPI_SH_MSIOF_H__
2#define __SPI_SH_MSIOF_H__
3
4struct sh_msiof_spi_info {
5 int tx_fifo_override;
6 int rx_fifo_override;
7 u16 num_chipselect;
8};
9
10#endif /* __SPI_SH_MSIOF_H__ */
diff --git a/include/linux/spi/xilinx_spi.h b/include/linux/spi/xilinx_spi.h
new file mode 100644
index 000000000000..6f17278810b0
--- /dev/null
+++ b/include/linux/spi/xilinx_spi.h
@@ -0,0 +1,20 @@
1#ifndef __LINUX_SPI_XILINX_SPI_H
2#define __LINUX_SPI_XILINX_SPI_H
3
4/**
5 * struct xspi_platform_data - Platform data of the Xilinx SPI driver
6 * @num_chipselect: Number of chip select by the IP.
7 * @little_endian: If registers should be accessed little endian or not.
8 * @bits_per_word: Number of bits per word.
9 * @devices: Devices to add when the driver is probed.
10 * @num_devices: Number of devices in the devices array.
11 */
12struct xspi_platform_data {
13 u16 num_chipselect;
14 bool little_endian;
15 u8 bits_per_word;
16 struct spi_board_info *devices;
17 u8 num_devices;
18};
19
20#endif /* __LINUX_SPI_XILINX_SPI_H */
diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
index 401097781fc0..1906782ec86b 100644
--- a/include/linux/sunrpc/sched.h
+++ b/include/linux/sunrpc/sched.h
@@ -130,12 +130,14 @@ struct rpc_task_setup {
130#define RPC_TASK_DYNAMIC 0x0080 /* task was kmalloc'ed */ 130#define RPC_TASK_DYNAMIC 0x0080 /* task was kmalloc'ed */
131#define RPC_TASK_KILLED 0x0100 /* task was killed */ 131#define RPC_TASK_KILLED 0x0100 /* task was killed */
132#define RPC_TASK_SOFT 0x0200 /* Use soft timeouts */ 132#define RPC_TASK_SOFT 0x0200 /* Use soft timeouts */
133#define RPC_TASK_SOFTCONN 0x0400 /* Fail if can't connect */
133 134
134#define RPC_IS_ASYNC(t) ((t)->tk_flags & RPC_TASK_ASYNC) 135#define RPC_IS_ASYNC(t) ((t)->tk_flags & RPC_TASK_ASYNC)
135#define RPC_IS_SWAPPER(t) ((t)->tk_flags & RPC_TASK_SWAPPER) 136#define RPC_IS_SWAPPER(t) ((t)->tk_flags & RPC_TASK_SWAPPER)
136#define RPC_DO_ROOTOVERRIDE(t) ((t)->tk_flags & RPC_TASK_ROOTCREDS) 137#define RPC_DO_ROOTOVERRIDE(t) ((t)->tk_flags & RPC_TASK_ROOTCREDS)
137#define RPC_ASSASSINATED(t) ((t)->tk_flags & RPC_TASK_KILLED) 138#define RPC_ASSASSINATED(t) ((t)->tk_flags & RPC_TASK_KILLED)
138#define RPC_IS_SOFT(t) ((t)->tk_flags & RPC_TASK_SOFT) 139#define RPC_IS_SOFT(t) ((t)->tk_flags & RPC_TASK_SOFT)
140#define RPC_IS_SOFTCONN(t) ((t)->tk_flags & RPC_TASK_SOFTCONN)
139 141
140#define RPC_TASK_RUNNING 0 142#define RPC_TASK_RUNNING 0
141#define RPC_TASK_QUEUED 1 143#define RPC_TASK_QUEUED 1
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index 2d0f222388a8..d85889710f9b 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -76,24 +76,22 @@ DECLARE_PER_CPU(struct vm_event_state, vm_event_states);
76 76
77static inline void __count_vm_event(enum vm_event_item item) 77static inline void __count_vm_event(enum vm_event_item item)
78{ 78{
79 __get_cpu_var(vm_event_states).event[item]++; 79 __this_cpu_inc(per_cpu_var(vm_event_states).event[item]);
80} 80}
81 81
82static inline void count_vm_event(enum vm_event_item item) 82static inline void count_vm_event(enum vm_event_item item)
83{ 83{
84 get_cpu_var(vm_event_states).event[item]++; 84 this_cpu_inc(per_cpu_var(vm_event_states).event[item]);
85 put_cpu();
86} 85}
87 86
88static inline void __count_vm_events(enum vm_event_item item, long delta) 87static inline void __count_vm_events(enum vm_event_item item, long delta)
89{ 88{
90 __get_cpu_var(vm_event_states).event[item] += delta; 89 __this_cpu_add(per_cpu_var(vm_event_states).event[item], delta);
91} 90}
92 91
93static inline void count_vm_events(enum vm_event_item item, long delta) 92static inline void count_vm_events(enum vm_event_item item, long delta)
94{ 93{
95 get_cpu_var(vm_event_states).event[item] += delta; 94 this_cpu_add(per_cpu_var(vm_event_states).event[item], delta);
96 put_cpu();
97} 95}
98 96
99extern void all_vm_events(unsigned long *); 97extern void all_vm_events(unsigned long *);
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 0302f31a2fb7..b0173202cad9 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -88,12 +88,7 @@ struct neigh_statistics {
88 unsigned long unres_discards; /* number of unresolved drops */ 88 unsigned long unres_discards; /* number of unresolved drops */
89}; 89};
90 90
91#define NEIGH_CACHE_STAT_INC(tbl, field) \ 91#define NEIGH_CACHE_STAT_INC(tbl, field) this_cpu_inc((tbl)->stats->field)
92 do { \
93 preempt_disable(); \
94 (per_cpu_ptr((tbl)->stats, smp_processor_id())->field)++; \
95 preempt_enable(); \
96 } while (0)
97 92
98struct neighbour { 93struct neighbour {
99 struct neighbour *next; 94 struct neighbour *next;
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index 5cf7270e3ffc..a0904adfb8f7 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -293,11 +293,11 @@ extern unsigned int nf_conntrack_htable_size;
293extern unsigned int nf_conntrack_max; 293extern unsigned int nf_conntrack_max;
294 294
295#define NF_CT_STAT_INC(net, count) \ 295#define NF_CT_STAT_INC(net, count) \
296 (per_cpu_ptr((net)->ct.stat, raw_smp_processor_id())->count++) 296 __this_cpu_inc((net)->ct.stat->count)
297#define NF_CT_STAT_INC_ATOMIC(net, count) \ 297#define NF_CT_STAT_INC_ATOMIC(net, count) \
298do { \ 298do { \
299 local_bh_disable(); \ 299 local_bh_disable(); \
300 per_cpu_ptr((net)->ct.stat, raw_smp_processor_id())->count++; \ 300 __this_cpu_inc((net)->ct.stat->count); \
301 local_bh_enable(); \ 301 local_bh_enable(); \
302} while (0) 302} while (0)
303 303
diff --git a/include/net/snmp.h b/include/net/snmp.h
index 8c842e06bec8..f0d756f2ac99 100644
--- a/include/net/snmp.h
+++ b/include/net/snmp.h
@@ -136,45 +136,31 @@ struct linux_xfrm_mib {
136#define SNMP_STAT_BHPTR(name) (name[0]) 136#define SNMP_STAT_BHPTR(name) (name[0])
137#define SNMP_STAT_USRPTR(name) (name[1]) 137#define SNMP_STAT_USRPTR(name) (name[1])
138 138
139#define SNMP_INC_STATS_BH(mib, field) \ 139#define SNMP_INC_STATS_BH(mib, field) \
140 (per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field]++) 140 __this_cpu_inc(mib[0]->mibs[field])
141#define SNMP_INC_STATS_USER(mib, field) \ 141#define SNMP_INC_STATS_USER(mib, field) \
142 do { \ 142 this_cpu_inc(mib[1]->mibs[field])
143 per_cpu_ptr(mib[1], get_cpu())->mibs[field]++; \ 143#define SNMP_INC_STATS(mib, field) \
144 put_cpu(); \ 144 this_cpu_inc(mib[!in_softirq()]->mibs[field])
145 } while (0) 145#define SNMP_DEC_STATS(mib, field) \
146#define SNMP_INC_STATS(mib, field) \ 146 this_cpu_dec(mib[!in_softirq()]->mibs[field])
147 do { \ 147#define SNMP_ADD_STATS_BH(mib, field, addend) \
148 per_cpu_ptr(mib[!in_softirq()], get_cpu())->mibs[field]++; \ 148 __this_cpu_add(mib[0]->mibs[field], addend)
149 put_cpu(); \ 149#define SNMP_ADD_STATS_USER(mib, field, addend) \
150 } while (0) 150 this_cpu_add(mib[1]->mibs[field], addend)
151#define SNMP_DEC_STATS(mib, field) \
152 do { \
153 per_cpu_ptr(mib[!in_softirq()], get_cpu())->mibs[field]--; \
154 put_cpu(); \
155 } while (0)
156#define SNMP_ADD_STATS(mib, field, addend) \
157 do { \
158 per_cpu_ptr(mib[!in_softirq()], get_cpu())->mibs[field] += addend; \
159 put_cpu(); \
160 } while (0)
161#define SNMP_ADD_STATS_BH(mib, field, addend) \
162 (per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field] += addend)
163#define SNMP_ADD_STATS_USER(mib, field, addend) \
164 do { \
165 per_cpu_ptr(mib[1], get_cpu())->mibs[field] += addend; \
166 put_cpu(); \
167 } while (0)
168#define SNMP_UPD_PO_STATS(mib, basefield, addend) \ 151#define SNMP_UPD_PO_STATS(mib, basefield, addend) \
169 do { \ 152 do { \
170 __typeof__(mib[0]) ptr = per_cpu_ptr(mib[!in_softirq()], get_cpu());\ 153 __typeof__(mib[0]) ptr; \
154 preempt_disable(); \
155 ptr = this_cpu_ptr((mib)[!in_softirq()]); \
171 ptr->mibs[basefield##PKTS]++; \ 156 ptr->mibs[basefield##PKTS]++; \
172 ptr->mibs[basefield##OCTETS] += addend;\ 157 ptr->mibs[basefield##OCTETS] += addend;\
173 put_cpu(); \ 158 preempt_enable(); \
174 } while (0) 159 } while (0)
175#define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \ 160#define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \
176 do { \ 161 do { \
177 __typeof__(mib[0]) ptr = per_cpu_ptr(mib[!in_softirq()], raw_smp_processor_id());\ 162 __typeof__(mib[0]) ptr = \
163 __this_cpu_ptr((mib)[!in_softirq()]); \
178 ptr->mibs[basefield##PKTS]++; \ 164 ptr->mibs[basefield##PKTS]++; \
179 ptr->mibs[basefield##OCTETS] += addend;\ 165 ptr->mibs[basefield##OCTETS] += addend;\
180 } while (0) 166 } while (0)
diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h
index afc2bfb9e917..75fa3530345b 100644
--- a/include/pcmcia/cs.h
+++ b/include/pcmcia/cs.h
@@ -126,8 +126,8 @@ typedef struct irq_req_t {
126#define IRQ_TYPE_TIME 0x01 126#define IRQ_TYPE_TIME 0x01
127#define IRQ_TYPE_DYNAMIC_SHARING 0x02 127#define IRQ_TYPE_DYNAMIC_SHARING 0x02
128#define IRQ_FORCED_PULSE 0x04 128#define IRQ_FORCED_PULSE 0x04
129#define IRQ_FIRST_SHARED 0x08 129#define IRQ_FIRST_SHARED 0x08 /* unused */
130//#define IRQ_HANDLE_PRESENT 0x10 130#define IRQ_HANDLE_PRESENT 0x10 /* unused */
131#define IRQ_PULSE_ALLOCATED 0x100 131#define IRQ_PULSE_ALLOCATED 0x100
132 132
133/* Bits in IRQInfo1 field */ 133/* Bits in IRQInfo1 field */
diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h
index d403c12f7978..ee148573c114 100644
--- a/include/pcmcia/ds.h
+++ b/include/pcmcia/ds.h
@@ -82,7 +82,7 @@ struct pcmcia_device {
82 /* the hardware "function" device; certain subdevices can 82 /* the hardware "function" device; certain subdevices can
83 * share one hardware "function" device. */ 83 * share one hardware "function" device. */
84 u8 func; 84 u8 func;
85 struct config_t* function_config; 85 struct config_t *function_config;
86 86
87 struct list_head socket_device_list; 87 struct list_head socket_device_list;
88 88
@@ -121,14 +121,14 @@ struct pcmcia_device {
121 u16 manf_id; 121 u16 manf_id;
122 u16 card_id; 122 u16 card_id;
123 123
124 char * prod_id[4]; 124 char *prod_id[4];
125 125
126 u64 dma_mask; 126 u64 dma_mask;
127 struct device dev; 127 struct device dev;
128 128
129#ifdef CONFIG_PCMCIA_IOCTL 129#ifdef CONFIG_PCMCIA_IOCTL
130 /* device driver wanted by cardmgr */ 130 /* device driver wanted by cardmgr */
131 struct pcmcia_driver * cardmgr; 131 struct pcmcia_driver *cardmgr;
132#endif 132#endif
133 133
134 /* data private to drivers */ 134 /* data private to drivers */
diff --git a/include/pcmcia/mem_op.h b/include/pcmcia/mem_op.h
index 8d19b9401a5b..0fa06e5d5376 100644
--- a/include/pcmcia/mem_op.h
+++ b/include/pcmcia/mem_op.h
@@ -15,8 +15,8 @@
15#ifndef _LINUX_MEM_OP_H 15#ifndef _LINUX_MEM_OP_H
16#define _LINUX_MEM_OP_H 16#define _LINUX_MEM_OP_H
17 17
18#include <linux/io.h>
18#include <asm/uaccess.h> 19#include <asm/uaccess.h>
19#include <asm/io.h>
20 20
21/* 21/*
22 If UNSAFE_MEMCPY is defined, we use the (optimized) system routines 22 If UNSAFE_MEMCPY is defined, we use the (optimized) system routines
diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h
index 7c23be706f12..cbfba885eb85 100644
--- a/include/pcmcia/ss.h
+++ b/include/pcmcia/ss.h
@@ -154,7 +154,7 @@ struct pcmcia_socket {
154 struct list_head socket_list; 154 struct list_head socket_list;
155 struct completion socket_released; 155 struct completion socket_released;
156 156
157 /* deprecated */ 157 /* deprecated */
158 unsigned int sock; /* socket number */ 158 unsigned int sock; /* socket number */
159 159
160 160
@@ -164,7 +164,7 @@ struct pcmcia_socket {
164 u_int map_size; 164 u_int map_size;
165 u_int io_offset; 165 u_int io_offset;
166 u_int pci_irq; 166 u_int pci_irq;
167 struct pci_dev * cb_dev; 167 struct pci_dev *cb_dev;
168 168
169 169
170 /* socket setup is done so resources should be able to be allocated. 170 /* socket setup is done so resources should be able to be allocated.
@@ -179,9 +179,9 @@ struct pcmcia_socket {
179 u8 reserved:5; 179 u8 reserved:5;
180 180
181 /* socket operations */ 181 /* socket operations */
182 struct pccard_operations * ops; 182 struct pccard_operations *ops;
183 struct pccard_resource_ops * resource_ops; 183 struct pccard_resource_ops *resource_ops;
184 void * resource_data; 184 void *resource_data;
185 185
186 /* Zoom video behaviour is so chip specific its not worth adding 186 /* Zoom video behaviour is so chip specific its not worth adding
187 this to _ops */ 187 this to _ops */
@@ -245,7 +245,7 @@ struct pcmcia_socket {
245 245
246 /* cardbus (32-bit) */ 246 /* cardbus (32-bit) */
247#ifdef CONFIG_CARDBUS 247#ifdef CONFIG_CARDBUS
248 struct resource * cb_cis_res; 248 struct resource *cb_cis_res;
249 void __iomem *cb_cis_virt; 249 void __iomem *cb_cis_virt;
250#endif /* CONFIG_CARDBUS */ 250#endif /* CONFIG_CARDBUS */
251 251
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 4f8df01dbe51..429540c70d3f 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -140,7 +140,8 @@ static inline struct lock_class *hlock_class(struct held_lock *hlock)
140} 140}
141 141
142#ifdef CONFIG_LOCK_STAT 142#ifdef CONFIG_LOCK_STAT
143static DEFINE_PER_CPU(struct lock_class_stats[MAX_LOCKDEP_KEYS], lock_stats); 143static DEFINE_PER_CPU(struct lock_class_stats[MAX_LOCKDEP_KEYS],
144 cpu_lock_stats);
144 145
145static inline u64 lockstat_clock(void) 146static inline u64 lockstat_clock(void)
146{ 147{
@@ -198,7 +199,7 @@ struct lock_class_stats lock_stats(struct lock_class *class)
198 memset(&stats, 0, sizeof(struct lock_class_stats)); 199 memset(&stats, 0, sizeof(struct lock_class_stats));
199 for_each_possible_cpu(cpu) { 200 for_each_possible_cpu(cpu) {
200 struct lock_class_stats *pcs = 201 struct lock_class_stats *pcs =
201 &per_cpu(lock_stats, cpu)[class - lock_classes]; 202 &per_cpu(cpu_lock_stats, cpu)[class - lock_classes];
202 203
203 for (i = 0; i < ARRAY_SIZE(stats.contention_point); i++) 204 for (i = 0; i < ARRAY_SIZE(stats.contention_point); i++)
204 stats.contention_point[i] += pcs->contention_point[i]; 205 stats.contention_point[i] += pcs->contention_point[i];
@@ -225,7 +226,7 @@ void clear_lock_stats(struct lock_class *class)
225 226
226 for_each_possible_cpu(cpu) { 227 for_each_possible_cpu(cpu) {
227 struct lock_class_stats *cpu_stats = 228 struct lock_class_stats *cpu_stats =
228 &per_cpu(lock_stats, cpu)[class - lock_classes]; 229 &per_cpu(cpu_lock_stats, cpu)[class - lock_classes];
229 230
230 memset(cpu_stats, 0, sizeof(struct lock_class_stats)); 231 memset(cpu_stats, 0, sizeof(struct lock_class_stats));
231 } 232 }
@@ -235,12 +236,12 @@ void clear_lock_stats(struct lock_class *class)
235 236
236static struct lock_class_stats *get_lock_stats(struct lock_class *class) 237static struct lock_class_stats *get_lock_stats(struct lock_class *class)
237{ 238{
238 return &get_cpu_var(lock_stats)[class - lock_classes]; 239 return &get_cpu_var(cpu_lock_stats)[class - lock_classes];
239} 240}
240 241
241static void put_lock_stats(struct lock_class_stats *stats) 242static void put_lock_stats(struct lock_class_stats *stats)
242{ 243{
243 put_cpu_var(lock_stats); 244 put_cpu_var(cpu_lock_stats);
244} 245}
245 246
246static void lock_release_holdtime(struct held_lock *hlock) 247static void lock_release_holdtime(struct held_lock *hlock)
diff --git a/kernel/module.c b/kernel/module.c
index 5842a71cf052..12afc5a3ddd3 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -370,8 +370,6 @@ EXPORT_SYMBOL_GPL(find_module);
370 370
371#ifdef CONFIG_SMP 371#ifdef CONFIG_SMP
372 372
373#ifndef CONFIG_HAVE_LEGACY_PER_CPU_AREA
374
375static void *percpu_modalloc(unsigned long size, unsigned long align, 373static void *percpu_modalloc(unsigned long size, unsigned long align,
376 const char *name) 374 const char *name)
377{ 375{
@@ -395,154 +393,6 @@ static void percpu_modfree(void *freeme)
395 free_percpu(freeme); 393 free_percpu(freeme);
396} 394}
397 395
398#else /* ... CONFIG_HAVE_LEGACY_PER_CPU_AREA */
399
400/* Number of blocks used and allocated. */
401static unsigned int pcpu_num_used, pcpu_num_allocated;
402/* Size of each block. -ve means used. */
403static int *pcpu_size;
404
405static int split_block(unsigned int i, unsigned short size)
406{
407 /* Reallocation required? */
408 if (pcpu_num_used + 1 > pcpu_num_allocated) {
409 int *new;
410
411 new = krealloc(pcpu_size, sizeof(new[0])*pcpu_num_allocated*2,
412 GFP_KERNEL);
413 if (!new)
414 return 0;
415
416 pcpu_num_allocated *= 2;
417 pcpu_size = new;
418 }
419
420 /* Insert a new subblock */
421 memmove(&pcpu_size[i+1], &pcpu_size[i],
422 sizeof(pcpu_size[0]) * (pcpu_num_used - i));
423 pcpu_num_used++;
424
425 pcpu_size[i+1] -= size;
426 pcpu_size[i] = size;
427 return 1;
428}
429
430static inline unsigned int block_size(int val)
431{
432 if (val < 0)
433 return -val;
434 return val;
435}
436
437static void *percpu_modalloc(unsigned long size, unsigned long align,
438 const char *name)
439{
440 unsigned long extra;
441 unsigned int i;
442 void *ptr;
443 int cpu;
444
445 if (align > PAGE_SIZE) {
446 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
447 name, align, PAGE_SIZE);
448 align = PAGE_SIZE;
449 }
450
451 ptr = __per_cpu_start;
452 for (i = 0; i < pcpu_num_used; ptr += block_size(pcpu_size[i]), i++) {
453 /* Extra for alignment requirement. */
454 extra = ALIGN((unsigned long)ptr, align) - (unsigned long)ptr;
455 BUG_ON(i == 0 && extra != 0);
456
457 if (pcpu_size[i] < 0 || pcpu_size[i] < extra + size)
458 continue;
459
460 /* Transfer extra to previous block. */
461 if (pcpu_size[i-1] < 0)
462 pcpu_size[i-1] -= extra;
463 else
464 pcpu_size[i-1] += extra;
465 pcpu_size[i] -= extra;
466 ptr += extra;
467
468 /* Split block if warranted */
469 if (pcpu_size[i] - size > sizeof(unsigned long))
470 if (!split_block(i, size))
471 return NULL;
472
473 /* add the per-cpu scanning areas */
474 for_each_possible_cpu(cpu)
475 kmemleak_alloc(ptr + per_cpu_offset(cpu), size, 0,
476 GFP_KERNEL);
477
478 /* Mark allocated */
479 pcpu_size[i] = -pcpu_size[i];
480 return ptr;
481 }
482
483 printk(KERN_WARNING "Could not allocate %lu bytes percpu data\n",
484 size);
485 return NULL;
486}
487
488static void percpu_modfree(void *freeme)
489{
490 unsigned int i;
491 void *ptr = __per_cpu_start + block_size(pcpu_size[0]);
492 int cpu;
493
494 /* First entry is core kernel percpu data. */
495 for (i = 1; i < pcpu_num_used; ptr += block_size(pcpu_size[i]), i++) {
496 if (ptr == freeme) {
497 pcpu_size[i] = -pcpu_size[i];
498 goto free;
499 }
500 }
501 BUG();
502
503 free:
504 /* remove the per-cpu scanning areas */
505 for_each_possible_cpu(cpu)
506 kmemleak_free(freeme + per_cpu_offset(cpu));
507
508 /* Merge with previous? */
509 if (pcpu_size[i-1] >= 0) {
510 pcpu_size[i-1] += pcpu_size[i];
511 pcpu_num_used--;
512 memmove(&pcpu_size[i], &pcpu_size[i+1],
513 (pcpu_num_used - i) * sizeof(pcpu_size[0]));
514 i--;
515 }
516 /* Merge with next? */
517 if (i+1 < pcpu_num_used && pcpu_size[i+1] >= 0) {
518 pcpu_size[i] += pcpu_size[i+1];
519 pcpu_num_used--;
520 memmove(&pcpu_size[i+1], &pcpu_size[i+2],
521 (pcpu_num_used - (i+1)) * sizeof(pcpu_size[0]));
522 }
523}
524
525static int percpu_modinit(void)
526{
527 pcpu_num_used = 2;
528 pcpu_num_allocated = 2;
529 pcpu_size = kmalloc(sizeof(pcpu_size[0]) * pcpu_num_allocated,
530 GFP_KERNEL);
531 /* Static in-kernel percpu data (used). */
532 pcpu_size[0] = -(__per_cpu_end-__per_cpu_start);
533 /* Free room. */
534 pcpu_size[1] = PERCPU_ENOUGH_ROOM + pcpu_size[0];
535 if (pcpu_size[1] < 0) {
536 printk(KERN_ERR "No per-cpu room for modules.\n");
537 pcpu_num_used = 1;
538 }
539
540 return 0;
541}
542__initcall(percpu_modinit);
543
544#endif /* CONFIG_HAVE_LEGACY_PER_CPU_AREA */
545
546static unsigned int find_pcpusec(Elf_Ehdr *hdr, 396static unsigned int find_pcpusec(Elf_Ehdr *hdr,
547 Elf_Shdr *sechdrs, 397 Elf_Shdr *sechdrs,
548 const char *secstrings) 398 const char *secstrings)
diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
index a621a67ef4e3..9bb52177af02 100644
--- a/kernel/rcutorture.c
+++ b/kernel/rcutorture.c
@@ -763,13 +763,13 @@ static void rcu_torture_timer(unsigned long unused)
763 /* Should not happen, but... */ 763 /* Should not happen, but... */
764 pipe_count = RCU_TORTURE_PIPE_LEN; 764 pipe_count = RCU_TORTURE_PIPE_LEN;
765 } 765 }
766 ++__get_cpu_var(rcu_torture_count)[pipe_count]; 766 __this_cpu_inc(per_cpu_var(rcu_torture_count)[pipe_count]);
767 completed = cur_ops->completed() - completed; 767 completed = cur_ops->completed() - completed;
768 if (completed > RCU_TORTURE_PIPE_LEN) { 768 if (completed > RCU_TORTURE_PIPE_LEN) {
769 /* Should not happen, but... */ 769 /* Should not happen, but... */
770 completed = RCU_TORTURE_PIPE_LEN; 770 completed = RCU_TORTURE_PIPE_LEN;
771 } 771 }
772 ++__get_cpu_var(rcu_torture_batch)[completed]; 772 __this_cpu_inc(per_cpu_var(rcu_torture_batch)[completed]);
773 preempt_enable(); 773 preempt_enable();
774 cur_ops->readunlock(idx); 774 cur_ops->readunlock(idx);
775} 775}
@@ -818,13 +818,13 @@ rcu_torture_reader(void *arg)
818 /* Should not happen, but... */ 818 /* Should not happen, but... */
819 pipe_count = RCU_TORTURE_PIPE_LEN; 819 pipe_count = RCU_TORTURE_PIPE_LEN;
820 } 820 }
821 ++__get_cpu_var(rcu_torture_count)[pipe_count]; 821 __this_cpu_inc(per_cpu_var(rcu_torture_count)[pipe_count]);
822 completed = cur_ops->completed() - completed; 822 completed = cur_ops->completed() - completed;
823 if (completed > RCU_TORTURE_PIPE_LEN) { 823 if (completed > RCU_TORTURE_PIPE_LEN) {
824 /* Should not happen, but... */ 824 /* Should not happen, but... */
825 completed = RCU_TORTURE_PIPE_LEN; 825 completed = RCU_TORTURE_PIPE_LEN;
826 } 826 }
827 ++__get_cpu_var(rcu_torture_batch)[completed]; 827 __this_cpu_inc(per_cpu_var(rcu_torture_batch)[completed]);
828 preempt_enable(); 828 preempt_enable();
829 cur_ops->readunlock(idx); 829 cur_ops->readunlock(idx);
830 schedule(); 830 schedule();
diff --git a/kernel/sched.c b/kernel/sched.c
index ff39cadf621e..fd05861b2111 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -298,7 +298,7 @@ static DEFINE_PER_CPU_SHARED_ALIGNED(struct cfs_rq, init_tg_cfs_rq);
298 298
299#ifdef CONFIG_RT_GROUP_SCHED 299#ifdef CONFIG_RT_GROUP_SCHED
300static DEFINE_PER_CPU(struct sched_rt_entity, init_sched_rt_entity); 300static DEFINE_PER_CPU(struct sched_rt_entity, init_sched_rt_entity);
301static DEFINE_PER_CPU_SHARED_ALIGNED(struct rt_rq, init_rt_rq); 301static DEFINE_PER_CPU_SHARED_ALIGNED(struct rt_rq, init_rt_rq_var);
302#endif /* CONFIG_RT_GROUP_SCHED */ 302#endif /* CONFIG_RT_GROUP_SCHED */
303#else /* !CONFIG_USER_SCHED */ 303#else /* !CONFIG_USER_SCHED */
304#define root_task_group init_task_group 304#define root_task_group init_task_group
@@ -8286,14 +8286,14 @@ enum s_alloc {
8286 */ 8286 */
8287#ifdef CONFIG_SCHED_SMT 8287#ifdef CONFIG_SCHED_SMT
8288static DEFINE_PER_CPU(struct static_sched_domain, cpu_domains); 8288static DEFINE_PER_CPU(struct static_sched_domain, cpu_domains);
8289static DEFINE_PER_CPU(struct static_sched_group, sched_group_cpus); 8289static DEFINE_PER_CPU(struct static_sched_group, sched_groups);
8290 8290
8291static int 8291static int
8292cpu_to_cpu_group(int cpu, const struct cpumask *cpu_map, 8292cpu_to_cpu_group(int cpu, const struct cpumask *cpu_map,
8293 struct sched_group **sg, struct cpumask *unused) 8293 struct sched_group **sg, struct cpumask *unused)
8294{ 8294{
8295 if (sg) 8295 if (sg)
8296 *sg = &per_cpu(sched_group_cpus, cpu).sg; 8296 *sg = &per_cpu(sched_groups, cpu).sg;
8297 return cpu; 8297 return cpu;
8298} 8298}
8299#endif /* CONFIG_SCHED_SMT */ 8299#endif /* CONFIG_SCHED_SMT */
@@ -9583,7 +9583,7 @@ void __init sched_init(void)
9583#elif defined CONFIG_USER_SCHED 9583#elif defined CONFIG_USER_SCHED
9584 init_tg_rt_entry(&root_task_group, &rq->rt, NULL, i, 0, NULL); 9584 init_tg_rt_entry(&root_task_group, &rq->rt, NULL, i, 0, NULL);
9585 init_tg_rt_entry(&init_task_group, 9585 init_tg_rt_entry(&init_task_group,
9586 &per_cpu(init_rt_rq, i), 9586 &per_cpu(init_rt_rq_var, i),
9587 &per_cpu(init_sched_rt_entity, i), i, 1, 9587 &per_cpu(init_sched_rt_entity, i), i, 1,
9588 root_task_group.rt_se[i]); 9588 root_task_group.rt_se[i]);
9589#endif 9589#endif
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 21939d9e830e..a09502e2ef75 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -697,7 +697,7 @@ void __init softirq_init(void)
697 open_softirq(HI_SOFTIRQ, tasklet_hi_action); 697 open_softirq(HI_SOFTIRQ, tasklet_hi_action);
698} 698}
699 699
700static int ksoftirqd(void * __bind_cpu) 700static int run_ksoftirqd(void * __bind_cpu)
701{ 701{
702 set_current_state(TASK_INTERRUPTIBLE); 702 set_current_state(TASK_INTERRUPTIBLE);
703 703
@@ -810,7 +810,7 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
810 switch (action) { 810 switch (action) {
811 case CPU_UP_PREPARE: 811 case CPU_UP_PREPARE:
812 case CPU_UP_PREPARE_FROZEN: 812 case CPU_UP_PREPARE_FROZEN:
813 p = kthread_create(ksoftirqd, hcpu, "ksoftirqd/%d", hotcpu); 813 p = kthread_create(run_ksoftirqd, hcpu, "ksoftirqd/%d", hotcpu);
814 if (IS_ERR(p)) { 814 if (IS_ERR(p)) {
815 printk("ksoftirqd for %i failed\n", hotcpu); 815 printk("ksoftirqd for %i failed\n", hotcpu);
816 return NOTIFY_BAD; 816 return NOTIFY_BAD;
diff --git a/kernel/softlockup.c b/kernel/softlockup.c
index 81324d12eb35..d22579087e27 100644
--- a/kernel/softlockup.c
+++ b/kernel/softlockup.c
@@ -22,9 +22,9 @@
22 22
23static DEFINE_SPINLOCK(print_lock); 23static DEFINE_SPINLOCK(print_lock);
24 24
25static DEFINE_PER_CPU(unsigned long, touch_timestamp); 25static DEFINE_PER_CPU(unsigned long, softlockup_touch_ts); /* touch timestamp */
26static DEFINE_PER_CPU(unsigned long, print_timestamp); 26static DEFINE_PER_CPU(unsigned long, softlockup_print_ts); /* print timestamp */
27static DEFINE_PER_CPU(struct task_struct *, watchdog_task); 27static DEFINE_PER_CPU(struct task_struct *, softlockup_watchdog);
28 28
29static int __read_mostly did_panic; 29static int __read_mostly did_panic;
30int __read_mostly softlockup_thresh = 60; 30int __read_mostly softlockup_thresh = 60;
@@ -70,12 +70,12 @@ static void __touch_softlockup_watchdog(void)
70{ 70{
71 int this_cpu = raw_smp_processor_id(); 71 int this_cpu = raw_smp_processor_id();
72 72
73 __raw_get_cpu_var(touch_timestamp) = get_timestamp(this_cpu); 73 __raw_get_cpu_var(softlockup_touch_ts) = get_timestamp(this_cpu);
74} 74}
75 75
76void touch_softlockup_watchdog(void) 76void touch_softlockup_watchdog(void)
77{ 77{
78 __raw_get_cpu_var(touch_timestamp) = 0; 78 __raw_get_cpu_var(softlockup_touch_ts) = 0;
79} 79}
80EXPORT_SYMBOL(touch_softlockup_watchdog); 80EXPORT_SYMBOL(touch_softlockup_watchdog);
81 81
@@ -85,7 +85,7 @@ void touch_all_softlockup_watchdogs(void)
85 85
86 /* Cause each CPU to re-update its timestamp rather than complain */ 86 /* Cause each CPU to re-update its timestamp rather than complain */
87 for_each_online_cpu(cpu) 87 for_each_online_cpu(cpu)
88 per_cpu(touch_timestamp, cpu) = 0; 88 per_cpu(softlockup_touch_ts, cpu) = 0;
89} 89}
90EXPORT_SYMBOL(touch_all_softlockup_watchdogs); 90EXPORT_SYMBOL(touch_all_softlockup_watchdogs);
91 91
@@ -104,28 +104,28 @@ int proc_dosoftlockup_thresh(struct ctl_table *table, int write,
104void softlockup_tick(void) 104void softlockup_tick(void)
105{ 105{
106 int this_cpu = smp_processor_id(); 106 int this_cpu = smp_processor_id();
107 unsigned long touch_timestamp = per_cpu(touch_timestamp, this_cpu); 107 unsigned long touch_ts = per_cpu(softlockup_touch_ts, this_cpu);
108 unsigned long print_timestamp; 108 unsigned long print_ts;
109 struct pt_regs *regs = get_irq_regs(); 109 struct pt_regs *regs = get_irq_regs();
110 unsigned long now; 110 unsigned long now;
111 111
112 /* Is detection switched off? */ 112 /* Is detection switched off? */
113 if (!per_cpu(watchdog_task, this_cpu) || softlockup_thresh <= 0) { 113 if (!per_cpu(softlockup_watchdog, this_cpu) || softlockup_thresh <= 0) {
114 /* Be sure we don't false trigger if switched back on */ 114 /* Be sure we don't false trigger if switched back on */
115 if (touch_timestamp) 115 if (touch_ts)
116 per_cpu(touch_timestamp, this_cpu) = 0; 116 per_cpu(softlockup_touch_ts, this_cpu) = 0;
117 return; 117 return;
118 } 118 }
119 119
120 if (touch_timestamp == 0) { 120 if (touch_ts == 0) {
121 __touch_softlockup_watchdog(); 121 __touch_softlockup_watchdog();
122 return; 122 return;
123 } 123 }
124 124
125 print_timestamp = per_cpu(print_timestamp, this_cpu); 125 print_ts = per_cpu(softlockup_print_ts, this_cpu);
126 126
127 /* report at most once a second */ 127 /* report at most once a second */
128 if (print_timestamp == touch_timestamp || did_panic) 128 if (print_ts == touch_ts || did_panic)
129 return; 129 return;
130 130
131 /* do not print during early bootup: */ 131 /* do not print during early bootup: */
@@ -140,18 +140,18 @@ void softlockup_tick(void)
140 * Wake up the high-prio watchdog task twice per 140 * Wake up the high-prio watchdog task twice per
141 * threshold timespan. 141 * threshold timespan.
142 */ 142 */
143 if (now > touch_timestamp + softlockup_thresh/2) 143 if (now > touch_ts + softlockup_thresh/2)
144 wake_up_process(per_cpu(watchdog_task, this_cpu)); 144 wake_up_process(per_cpu(softlockup_watchdog, this_cpu));
145 145
146 /* Warn about unreasonable delays: */ 146 /* Warn about unreasonable delays: */
147 if (now <= (touch_timestamp + softlockup_thresh)) 147 if (now <= (touch_ts + softlockup_thresh))
148 return; 148 return;
149 149
150 per_cpu(print_timestamp, this_cpu) = touch_timestamp; 150 per_cpu(softlockup_print_ts, this_cpu) = touch_ts;
151 151
152 spin_lock(&print_lock); 152 spin_lock(&print_lock);
153 printk(KERN_ERR "BUG: soft lockup - CPU#%d stuck for %lus! [%s:%d]\n", 153 printk(KERN_ERR "BUG: soft lockup - CPU#%d stuck for %lus! [%s:%d]\n",
154 this_cpu, now - touch_timestamp, 154 this_cpu, now - touch_ts,
155 current->comm, task_pid_nr(current)); 155 current->comm, task_pid_nr(current));
156 print_modules(); 156 print_modules();
157 print_irqtrace_events(current); 157 print_irqtrace_events(current);
@@ -209,32 +209,32 @@ cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
209 switch (action) { 209 switch (action) {
210 case CPU_UP_PREPARE: 210 case CPU_UP_PREPARE:
211 case CPU_UP_PREPARE_FROZEN: 211 case CPU_UP_PREPARE_FROZEN:
212 BUG_ON(per_cpu(watchdog_task, hotcpu)); 212 BUG_ON(per_cpu(softlockup_watchdog, hotcpu));
213 p = kthread_create(watchdog, hcpu, "watchdog/%d", hotcpu); 213 p = kthread_create(watchdog, hcpu, "watchdog/%d", hotcpu);
214 if (IS_ERR(p)) { 214 if (IS_ERR(p)) {
215 printk(KERN_ERR "watchdog for %i failed\n", hotcpu); 215 printk(KERN_ERR "watchdog for %i failed\n", hotcpu);
216 return NOTIFY_BAD; 216 return NOTIFY_BAD;
217 } 217 }
218 per_cpu(touch_timestamp, hotcpu) = 0; 218 per_cpu(softlockup_touch_ts, hotcpu) = 0;
219 per_cpu(watchdog_task, hotcpu) = p; 219 per_cpu(softlockup_watchdog, hotcpu) = p;
220 kthread_bind(p, hotcpu); 220 kthread_bind(p, hotcpu);
221 break; 221 break;
222 case CPU_ONLINE: 222 case CPU_ONLINE:
223 case CPU_ONLINE_FROZEN: 223 case CPU_ONLINE_FROZEN:
224 wake_up_process(per_cpu(watchdog_task, hotcpu)); 224 wake_up_process(per_cpu(softlockup_watchdog, hotcpu));
225 break; 225 break;
226#ifdef CONFIG_HOTPLUG_CPU 226#ifdef CONFIG_HOTPLUG_CPU
227 case CPU_UP_CANCELED: 227 case CPU_UP_CANCELED:
228 case CPU_UP_CANCELED_FROZEN: 228 case CPU_UP_CANCELED_FROZEN:
229 if (!per_cpu(watchdog_task, hotcpu)) 229 if (!per_cpu(softlockup_watchdog, hotcpu))
230 break; 230 break;
231 /* Unbind so it can run. Fall thru. */ 231 /* Unbind so it can run. Fall thru. */
232 kthread_bind(per_cpu(watchdog_task, hotcpu), 232 kthread_bind(per_cpu(softlockup_watchdog, hotcpu),
233 cpumask_any(cpu_online_mask)); 233 cpumask_any(cpu_online_mask));
234 case CPU_DEAD: 234 case CPU_DEAD:
235 case CPU_DEAD_FROZEN: 235 case CPU_DEAD_FROZEN:
236 p = per_cpu(watchdog_task, hotcpu); 236 p = per_cpu(softlockup_watchdog, hotcpu);
237 per_cpu(watchdog_task, hotcpu) = NULL; 237 per_cpu(softlockup_watchdog, hotcpu) = NULL;
238 kthread_stop(p); 238 kthread_stop(p);
239 break; 239 break;
240#endif /* CONFIG_HOTPLUG_CPU */ 240#endif /* CONFIG_HOTPLUG_CPU */
diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
index ee5681f8d7ec..63b117e9eba1 100644
--- a/kernel/time/timer_stats.c
+++ b/kernel/time/timer_stats.c
@@ -86,7 +86,7 @@ static DEFINE_SPINLOCK(table_lock);
86/* 86/*
87 * Per-CPU lookup locks for fast hash lookup: 87 * Per-CPU lookup locks for fast hash lookup:
88 */ 88 */
89static DEFINE_PER_CPU(spinlock_t, lookup_lock); 89static DEFINE_PER_CPU(spinlock_t, tstats_lookup_lock);
90 90
91/* 91/*
92 * Mutex to serialize state changes with show-stats activities: 92 * Mutex to serialize state changes with show-stats activities:
@@ -245,7 +245,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
245 if (likely(!timer_stats_active)) 245 if (likely(!timer_stats_active))
246 return; 246 return;
247 247
248 lock = &per_cpu(lookup_lock, raw_smp_processor_id()); 248 lock = &per_cpu(tstats_lookup_lock, raw_smp_processor_id());
249 249
250 input.timer = timer; 250 input.timer = timer;
251 input.start_func = startf; 251 input.start_func = startf;
@@ -348,9 +348,10 @@ static void sync_access(void)
348 int cpu; 348 int cpu;
349 349
350 for_each_online_cpu(cpu) { 350 for_each_online_cpu(cpu) {
351 spin_lock_irqsave(&per_cpu(lookup_lock, cpu), flags); 351 spinlock_t *lock = &per_cpu(tstats_lookup_lock, cpu);
352 spin_lock_irqsave(lock, flags);
352 /* nothing */ 353 /* nothing */
353 spin_unlock_irqrestore(&per_cpu(lookup_lock, cpu), flags); 354 spin_unlock_irqrestore(lock, flags);
354 } 355 }
355} 356}
356 357
@@ -408,7 +409,7 @@ void __init init_timer_stats(void)
408 int cpu; 409 int cpu;
409 410
410 for_each_possible_cpu(cpu) 411 for_each_possible_cpu(cpu)
411 spin_lock_init(&per_cpu(lookup_lock, cpu)); 412 spin_lock_init(&per_cpu(tstats_lookup_lock, cpu));
412} 413}
413 414
414static int __init init_tstats_procfs(void) 415static int __init init_tstats_procfs(void)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 88bd9ae2a9ed..c82dfd92fdfd 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -86,17 +86,17 @@ static int dummy_set_flag(u32 old_flags, u32 bit, int set)
86 */ 86 */
87static int tracing_disabled = 1; 87static int tracing_disabled = 1;
88 88
89DEFINE_PER_CPU(local_t, ftrace_cpu_disabled); 89DEFINE_PER_CPU(int, ftrace_cpu_disabled);
90 90
91static inline void ftrace_disable_cpu(void) 91static inline void ftrace_disable_cpu(void)
92{ 92{
93 preempt_disable(); 93 preempt_disable();
94 local_inc(&__get_cpu_var(ftrace_cpu_disabled)); 94 __this_cpu_inc(per_cpu_var(ftrace_cpu_disabled));
95} 95}
96 96
97static inline void ftrace_enable_cpu(void) 97static inline void ftrace_enable_cpu(void)
98{ 98{
99 local_dec(&__get_cpu_var(ftrace_cpu_disabled)); 99 __this_cpu_dec(per_cpu_var(ftrace_cpu_disabled));
100 preempt_enable(); 100 preempt_enable();
101} 101}
102 102
@@ -203,7 +203,7 @@ cycle_t ftrace_now(int cpu)
203 */ 203 */
204static struct trace_array max_tr; 204static struct trace_array max_tr;
205 205
206static DEFINE_PER_CPU(struct trace_array_cpu, max_data); 206static DEFINE_PER_CPU(struct trace_array_cpu, max_tr_data);
207 207
208/* tracer_enabled is used to toggle activation of a tracer */ 208/* tracer_enabled is used to toggle activation of a tracer */
209static int tracer_enabled = 1; 209static int tracer_enabled = 1;
@@ -1085,7 +1085,7 @@ trace_function(struct trace_array *tr,
1085 struct ftrace_entry *entry; 1085 struct ftrace_entry *entry;
1086 1086
1087 /* If we are reading the ring buffer, don't trace */ 1087 /* If we are reading the ring buffer, don't trace */
1088 if (unlikely(local_read(&__get_cpu_var(ftrace_cpu_disabled)))) 1088 if (unlikely(__this_cpu_read(per_cpu_var(ftrace_cpu_disabled))))
1089 return; 1089 return;
1090 1090
1091 event = trace_buffer_lock_reserve(buffer, TRACE_FN, sizeof(*entry), 1091 event = trace_buffer_lock_reserve(buffer, TRACE_FN, sizeof(*entry),
@@ -4454,7 +4454,7 @@ __init static int tracer_alloc_buffers(void)
4454 /* Allocate the first page for all buffers */ 4454 /* Allocate the first page for all buffers */
4455 for_each_tracing_cpu(i) { 4455 for_each_tracing_cpu(i) {
4456 global_trace.data[i] = &per_cpu(global_trace_cpu, i); 4456 global_trace.data[i] = &per_cpu(global_trace_cpu, i);
4457 max_tr.data[i] = &per_cpu(max_data, i); 4457 max_tr.data[i] = &per_cpu(max_tr_data, i);
4458 } 4458 }
4459 4459
4460 trace_init_cmdlines(); 4460 trace_init_cmdlines();
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 7fa33cab6962..a52bed2eedd8 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -443,7 +443,7 @@ extern int DYN_FTRACE_TEST_NAME(void);
443 443
444extern int ring_buffer_expanded; 444extern int ring_buffer_expanded;
445extern bool tracing_selftest_disabled; 445extern bool tracing_selftest_disabled;
446DECLARE_PER_CPU(local_t, ftrace_cpu_disabled); 446DECLARE_PER_CPU(int, ftrace_cpu_disabled);
447 447
448#ifdef CONFIG_FTRACE_STARTUP_TEST 448#ifdef CONFIG_FTRACE_STARTUP_TEST
449extern int trace_selftest_startup_function(struct tracer *trace, 449extern int trace_selftest_startup_function(struct tracer *trace,
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index a43d009c561a..b1342c5d37cf 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -187,7 +187,7 @@ static int __trace_graph_entry(struct trace_array *tr,
187 struct ring_buffer *buffer = tr->buffer; 187 struct ring_buffer *buffer = tr->buffer;
188 struct ftrace_graph_ent_entry *entry; 188 struct ftrace_graph_ent_entry *entry;
189 189
190 if (unlikely(local_read(&__get_cpu_var(ftrace_cpu_disabled)))) 190 if (unlikely(__this_cpu_read(per_cpu_var(ftrace_cpu_disabled))))
191 return 0; 191 return 0;
192 192
193 event = trace_buffer_lock_reserve(buffer, TRACE_GRAPH_ENT, 193 event = trace_buffer_lock_reserve(buffer, TRACE_GRAPH_ENT,
@@ -251,7 +251,7 @@ static void __trace_graph_return(struct trace_array *tr,
251 struct ring_buffer *buffer = tr->buffer; 251 struct ring_buffer *buffer = tr->buffer;
252 struct ftrace_graph_ret_entry *entry; 252 struct ftrace_graph_ret_entry *entry;
253 253
254 if (unlikely(local_read(&__get_cpu_var(ftrace_cpu_disabled)))) 254 if (unlikely(__this_cpu_read(per_cpu_var(ftrace_cpu_disabled))))
255 return; 255 return;
256 256
257 event = trace_buffer_lock_reserve(buffer, TRACE_GRAPH_RET, 257 event = trace_buffer_lock_reserve(buffer, TRACE_GRAPH_RET,
diff --git a/kernel/trace/trace_hw_branches.c b/kernel/trace/trace_hw_branches.c
index 69543a905cd5..7b97000745f5 100644
--- a/kernel/trace/trace_hw_branches.c
+++ b/kernel/trace/trace_hw_branches.c
@@ -20,10 +20,10 @@
20 20
21#define BTS_BUFFER_SIZE (1 << 13) 21#define BTS_BUFFER_SIZE (1 << 13)
22 22
23static DEFINE_PER_CPU(struct bts_tracer *, tracer); 23static DEFINE_PER_CPU(struct bts_tracer *, hwb_tracer);
24static DEFINE_PER_CPU(unsigned char[BTS_BUFFER_SIZE], buffer); 24static DEFINE_PER_CPU(unsigned char[BTS_BUFFER_SIZE], hwb_buffer);
25 25
26#define this_tracer per_cpu(tracer, smp_processor_id()) 26#define this_tracer per_cpu(hwb_tracer, smp_processor_id())
27 27
28static int trace_hw_branches_enabled __read_mostly; 28static int trace_hw_branches_enabled __read_mostly;
29static int trace_hw_branches_suspended __read_mostly; 29static int trace_hw_branches_suspended __read_mostly;
@@ -32,12 +32,13 @@ static struct trace_array *hw_branch_trace __read_mostly;
32 32
33static void bts_trace_init_cpu(int cpu) 33static void bts_trace_init_cpu(int cpu)
34{ 34{
35 per_cpu(tracer, cpu) = 35 per_cpu(hwb_tracer, cpu) =
36 ds_request_bts_cpu(cpu, per_cpu(buffer, cpu), BTS_BUFFER_SIZE, 36 ds_request_bts_cpu(cpu, per_cpu(hwb_buffer, cpu),
37 NULL, (size_t)-1, BTS_KERNEL); 37 BTS_BUFFER_SIZE, NULL, (size_t)-1,
38 BTS_KERNEL);
38 39
39 if (IS_ERR(per_cpu(tracer, cpu))) 40 if (IS_ERR(per_cpu(hwb_tracer, cpu)))
40 per_cpu(tracer, cpu) = NULL; 41 per_cpu(hwb_tracer, cpu) = NULL;
41} 42}
42 43
43static int bts_trace_init(struct trace_array *tr) 44static int bts_trace_init(struct trace_array *tr)
@@ -51,7 +52,7 @@ static int bts_trace_init(struct trace_array *tr)
51 for_each_online_cpu(cpu) { 52 for_each_online_cpu(cpu) {
52 bts_trace_init_cpu(cpu); 53 bts_trace_init_cpu(cpu);
53 54
54 if (likely(per_cpu(tracer, cpu))) 55 if (likely(per_cpu(hwb_tracer, cpu)))
55 trace_hw_branches_enabled = 1; 56 trace_hw_branches_enabled = 1;
56 } 57 }
57 trace_hw_branches_suspended = 0; 58 trace_hw_branches_suspended = 0;
@@ -67,9 +68,9 @@ static void bts_trace_reset(struct trace_array *tr)
67 68
68 get_online_cpus(); 69 get_online_cpus();
69 for_each_online_cpu(cpu) { 70 for_each_online_cpu(cpu) {
70 if (likely(per_cpu(tracer, cpu))) { 71 if (likely(per_cpu(hwb_tracer, cpu))) {
71 ds_release_bts(per_cpu(tracer, cpu)); 72 ds_release_bts(per_cpu(hwb_tracer, cpu));
72 per_cpu(tracer, cpu) = NULL; 73 per_cpu(hwb_tracer, cpu) = NULL;
73 } 74 }
74 } 75 }
75 trace_hw_branches_enabled = 0; 76 trace_hw_branches_enabled = 0;
@@ -83,8 +84,8 @@ static void bts_trace_start(struct trace_array *tr)
83 84
84 get_online_cpus(); 85 get_online_cpus();
85 for_each_online_cpu(cpu) 86 for_each_online_cpu(cpu)
86 if (likely(per_cpu(tracer, cpu))) 87 if (likely(per_cpu(hwb_tracer, cpu)))
87 ds_resume_bts(per_cpu(tracer, cpu)); 88 ds_resume_bts(per_cpu(hwb_tracer, cpu));
88 trace_hw_branches_suspended = 0; 89 trace_hw_branches_suspended = 0;
89 put_online_cpus(); 90 put_online_cpus();
90} 91}
@@ -95,8 +96,8 @@ static void bts_trace_stop(struct trace_array *tr)
95 96
96 get_online_cpus(); 97 get_online_cpus();
97 for_each_online_cpu(cpu) 98 for_each_online_cpu(cpu)
98 if (likely(per_cpu(tracer, cpu))) 99 if (likely(per_cpu(hwb_tracer, cpu)))
99 ds_suspend_bts(per_cpu(tracer, cpu)); 100 ds_suspend_bts(per_cpu(hwb_tracer, cpu));
100 trace_hw_branches_suspended = 1; 101 trace_hw_branches_suspended = 1;
101 put_online_cpus(); 102 put_online_cpus();
102} 103}
@@ -114,16 +115,16 @@ static int __cpuinit bts_hotcpu_handler(struct notifier_block *nfb,
114 bts_trace_init_cpu(cpu); 115 bts_trace_init_cpu(cpu);
115 116
116 if (trace_hw_branches_suspended && 117 if (trace_hw_branches_suspended &&
117 likely(per_cpu(tracer, cpu))) 118 likely(per_cpu(hwb_tracer, cpu)))
118 ds_suspend_bts(per_cpu(tracer, cpu)); 119 ds_suspend_bts(per_cpu(hwb_tracer, cpu));
119 } 120 }
120 break; 121 break;
121 122
122 case CPU_DOWN_PREPARE: 123 case CPU_DOWN_PREPARE:
123 /* The notification is sent with interrupts enabled. */ 124 /* The notification is sent with interrupts enabled. */
124 if (likely(per_cpu(tracer, cpu))) { 125 if (likely(per_cpu(hwb_tracer, cpu))) {
125 ds_release_bts(per_cpu(tracer, cpu)); 126 ds_release_bts(per_cpu(hwb_tracer, cpu));
126 per_cpu(tracer, cpu) = NULL; 127 per_cpu(hwb_tracer, cpu) = NULL;
127 } 128 }
128 } 129 }
129 130
@@ -258,8 +259,8 @@ static void trace_bts_prepare(struct trace_iterator *iter)
258 259
259 get_online_cpus(); 260 get_online_cpus();
260 for_each_online_cpu(cpu) 261 for_each_online_cpu(cpu)
261 if (likely(per_cpu(tracer, cpu))) 262 if (likely(per_cpu(hwb_tracer, cpu)))
262 ds_suspend_bts(per_cpu(tracer, cpu)); 263 ds_suspend_bts(per_cpu(hwb_tracer, cpu));
263 /* 264 /*
264 * We need to collect the trace on the respective cpu since ftrace 265 * We need to collect the trace on the respective cpu since ftrace
265 * implicitly adds the record for the current cpu. 266 * implicitly adds the record for the current cpu.
@@ -268,8 +269,8 @@ static void trace_bts_prepare(struct trace_iterator *iter)
268 on_each_cpu(trace_bts_cpu, iter->tr, 1); 269 on_each_cpu(trace_bts_cpu, iter->tr, 1);
269 270
270 for_each_online_cpu(cpu) 271 for_each_online_cpu(cpu)
271 if (likely(per_cpu(tracer, cpu))) 272 if (likely(per_cpu(hwb_tracer, cpu)))
272 ds_resume_bts(per_cpu(tracer, cpu)); 273 ds_resume_bts(per_cpu(hwb_tracer, cpu));
273 put_online_cpus(); 274 put_online_cpus();
274} 275}
275 276
diff --git a/mm/Makefile b/mm/Makefile
index ebf849042ed3..82131d0f8d85 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -34,11 +34,7 @@ obj-$(CONFIG_FAILSLAB) += failslab.o
34obj-$(CONFIG_MEMORY_HOTPLUG) += memory_hotplug.o 34obj-$(CONFIG_MEMORY_HOTPLUG) += memory_hotplug.o
35obj-$(CONFIG_FS_XIP) += filemap_xip.o 35obj-$(CONFIG_FS_XIP) += filemap_xip.o
36obj-$(CONFIG_MIGRATION) += migrate.o 36obj-$(CONFIG_MIGRATION) += migrate.o
37ifndef CONFIG_HAVE_LEGACY_PER_CPU_AREA
38obj-$(CONFIG_SMP) += percpu.o 37obj-$(CONFIG_SMP) += percpu.o
39else
40obj-$(CONFIG_SMP) += allocpercpu.o
41endif
42obj-$(CONFIG_QUICKLIST) += quicklist.o 38obj-$(CONFIG_QUICKLIST) += quicklist.o
43obj-$(CONFIG_CGROUP_MEM_RES_CTLR) += memcontrol.o page_cgroup.o 39obj-$(CONFIG_CGROUP_MEM_RES_CTLR) += memcontrol.o page_cgroup.o
44obj-$(CONFIG_MEMORY_FAILURE) += memory-failure.o 40obj-$(CONFIG_MEMORY_FAILURE) += memory-failure.o
diff --git a/mm/allocpercpu.c b/mm/allocpercpu.c
deleted file mode 100644
index df34ceae0c67..000000000000
--- a/mm/allocpercpu.c
+++ /dev/null
@@ -1,177 +0,0 @@
1/*
2 * linux/mm/allocpercpu.c
3 *
4 * Separated from slab.c August 11, 2006 Christoph Lameter
5 */
6#include <linux/mm.h>
7#include <linux/module.h>
8#include <linux/bootmem.h>
9#include <asm/sections.h>
10
11#ifndef cache_line_size
12#define cache_line_size() L1_CACHE_BYTES
13#endif
14
15/**
16 * percpu_depopulate - depopulate per-cpu data for given cpu
17 * @__pdata: per-cpu data to depopulate
18 * @cpu: depopulate per-cpu data for this cpu
19 *
20 * Depopulating per-cpu data for a cpu going offline would be a typical
21 * use case. You need to register a cpu hotplug handler for that purpose.
22 */
23static void percpu_depopulate(void *__pdata, int cpu)
24{
25 struct percpu_data *pdata = __percpu_disguise(__pdata);
26
27 kfree(pdata->ptrs[cpu]);
28 pdata->ptrs[cpu] = NULL;
29}
30
31/**
32 * percpu_depopulate_mask - depopulate per-cpu data for some cpu's
33 * @__pdata: per-cpu data to depopulate
34 * @mask: depopulate per-cpu data for cpu's selected through mask bits
35 */
36static void __percpu_depopulate_mask(void *__pdata, const cpumask_t *mask)
37{
38 int cpu;
39 for_each_cpu_mask_nr(cpu, *mask)
40 percpu_depopulate(__pdata, cpu);
41}
42
43#define percpu_depopulate_mask(__pdata, mask) \
44 __percpu_depopulate_mask((__pdata), &(mask))
45
46/**
47 * percpu_populate - populate per-cpu data for given cpu
48 * @__pdata: per-cpu data to populate further
49 * @size: size of per-cpu object
50 * @gfp: may sleep or not etc.
51 * @cpu: populate per-data for this cpu
52 *
53 * Populating per-cpu data for a cpu coming online would be a typical
54 * use case. You need to register a cpu hotplug handler for that purpose.
55 * Per-cpu object is populated with zeroed buffer.
56 */
57static void *percpu_populate(void *__pdata, size_t size, gfp_t gfp, int cpu)
58{
59 struct percpu_data *pdata = __percpu_disguise(__pdata);
60 int node = cpu_to_node(cpu);
61
62 /*
63 * We should make sure each CPU gets private memory.
64 */
65 size = roundup(size, cache_line_size());
66
67 BUG_ON(pdata->ptrs[cpu]);
68 if (node_online(node))
69 pdata->ptrs[cpu] = kmalloc_node(size, gfp|__GFP_ZERO, node);
70 else
71 pdata->ptrs[cpu] = kzalloc(size, gfp);
72 return pdata->ptrs[cpu];
73}
74
75/**
76 * percpu_populate_mask - populate per-cpu data for more cpu's
77 * @__pdata: per-cpu data to populate further
78 * @size: size of per-cpu object
79 * @gfp: may sleep or not etc.
80 * @mask: populate per-cpu data for cpu's selected through mask bits
81 *
82 * Per-cpu objects are populated with zeroed buffers.
83 */
84static int __percpu_populate_mask(void *__pdata, size_t size, gfp_t gfp,
85 cpumask_t *mask)
86{
87 cpumask_t populated;
88 int cpu;
89
90 cpus_clear(populated);
91 for_each_cpu_mask_nr(cpu, *mask)
92 if (unlikely(!percpu_populate(__pdata, size, gfp, cpu))) {
93 __percpu_depopulate_mask(__pdata, &populated);
94 return -ENOMEM;
95 } else
96 cpu_set(cpu, populated);
97 return 0;
98}
99
100#define percpu_populate_mask(__pdata, size, gfp, mask) \
101 __percpu_populate_mask((__pdata), (size), (gfp), &(mask))
102
103/**
104 * alloc_percpu - initial setup of per-cpu data
105 * @size: size of per-cpu object
106 * @align: alignment
107 *
108 * Allocate dynamic percpu area. Percpu objects are populated with
109 * zeroed buffers.
110 */
111void *__alloc_percpu(size_t size, size_t align)
112{
113 /*
114 * We allocate whole cache lines to avoid false sharing
115 */
116 size_t sz = roundup(nr_cpu_ids * sizeof(void *), cache_line_size());
117 void *pdata = kzalloc(sz, GFP_KERNEL);
118 void *__pdata = __percpu_disguise(pdata);
119
120 /*
121 * Can't easily make larger alignment work with kmalloc. WARN
122 * on it. Larger alignment should only be used for module
123 * percpu sections on SMP for which this path isn't used.
124 */
125 WARN_ON_ONCE(align > SMP_CACHE_BYTES);
126
127 if (unlikely(!pdata))
128 return NULL;
129 if (likely(!__percpu_populate_mask(__pdata, size, GFP_KERNEL,
130 &cpu_possible_map)))
131 return __pdata;
132 kfree(pdata);
133 return NULL;
134}
135EXPORT_SYMBOL_GPL(__alloc_percpu);
136
137/**
138 * free_percpu - final cleanup of per-cpu data
139 * @__pdata: object to clean up
140 *
141 * We simply clean up any per-cpu object left. No need for the client to
142 * track and specify through a bis mask which per-cpu objects are to free.
143 */
144void free_percpu(void *__pdata)
145{
146 if (unlikely(!__pdata))
147 return;
148 __percpu_depopulate_mask(__pdata, cpu_possible_mask);
149 kfree(__percpu_disguise(__pdata));
150}
151EXPORT_SYMBOL_GPL(free_percpu);
152
153/*
154 * Generic percpu area setup.
155 */
156#ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA
157unsigned long __per_cpu_offset[NR_CPUS] __read_mostly;
158
159EXPORT_SYMBOL(__per_cpu_offset);
160
161void __init setup_per_cpu_areas(void)
162{
163 unsigned long size, i;
164 char *ptr;
165 unsigned long nr_possible_cpus = num_possible_cpus();
166
167 /* Copy section for each CPU (we discard the original) */
168 size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
169 ptr = alloc_bootmem_pages(size * nr_possible_cpus);
170
171 for_each_possible_cpu(i) {
172 __per_cpu_offset[i] = ptr - __per_cpu_start;
173 memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
174 ptr += size;
175 }
176}
177#endif /* CONFIG_HAVE_SETUP_PER_CPU_AREA */
diff --git a/mm/migrate.c b/mm/migrate.c
index 7dbcb22316d2..0bc640fd68fa 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1044,7 +1044,7 @@ static int do_pages_stat(struct mm_struct *mm, unsigned long nr_pages,
1044 int err; 1044 int err;
1045 1045
1046 for (i = 0; i < nr_pages; i += chunk_nr) { 1046 for (i = 0; i < nr_pages; i += chunk_nr) {
1047 if (chunk_nr + i > nr_pages) 1047 if (chunk_nr > nr_pages - i)
1048 chunk_nr = nr_pages - i; 1048 chunk_nr = nr_pages - i;
1049 1049
1050 err = copy_from_user(chunk_pages, &pages[i], 1050 err = copy_from_user(chunk_pages, &pages[i],
diff --git a/mm/percpu.c b/mm/percpu.c
index 5adfc268b408..442010cc91c6 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -46,8 +46,6 @@
46 * 46 *
47 * To use this allocator, arch code should do the followings. 47 * To use this allocator, arch code should do the followings.
48 * 48 *
49 * - drop CONFIG_HAVE_LEGACY_PER_CPU_AREA
50 *
51 * - define __addr_to_pcpu_ptr() and __pcpu_ptr_to_addr() to translate 49 * - define __addr_to_pcpu_ptr() and __pcpu_ptr_to_addr() to translate
52 * regular address to percpu pointer and back if they need to be 50 * regular address to percpu pointer and back if they need to be
53 * different from the default 51 * different from the default
@@ -74,6 +72,7 @@
74#include <asm/cacheflush.h> 72#include <asm/cacheflush.h>
75#include <asm/sections.h> 73#include <asm/sections.h>
76#include <asm/tlbflush.h> 74#include <asm/tlbflush.h>
75#include <asm/io.h>
77 76
78#define PCPU_SLOT_BASE_SHIFT 5 /* 1-31 shares the same slot */ 77#define PCPU_SLOT_BASE_SHIFT 5 /* 1-31 shares the same slot */
79#define PCPU_DFL_MAP_ALLOC 16 /* start a map with 16 ents */ 78#define PCPU_DFL_MAP_ALLOC 16 /* start a map with 16 ents */
@@ -1302,6 +1301,27 @@ void free_percpu(void *ptr)
1302} 1301}
1303EXPORT_SYMBOL_GPL(free_percpu); 1302EXPORT_SYMBOL_GPL(free_percpu);
1304 1303
1304/**
1305 * per_cpu_ptr_to_phys - convert translated percpu address to physical address
1306 * @addr: the address to be converted to physical address
1307 *
1308 * Given @addr which is dereferenceable address obtained via one of
1309 * percpu access macros, this function translates it into its physical
1310 * address. The caller is responsible for ensuring @addr stays valid
1311 * until this function finishes.
1312 *
1313 * RETURNS:
1314 * The physical address for @addr.
1315 */
1316phys_addr_t per_cpu_ptr_to_phys(void *addr)
1317{
1318 if ((unsigned long)addr < VMALLOC_START ||
1319 (unsigned long)addr >= VMALLOC_END)
1320 return __pa(addr);
1321 else
1322 return page_to_phys(vmalloc_to_page(addr));
1323}
1324
1305static inline size_t pcpu_calc_fc_sizes(size_t static_size, 1325static inline size_t pcpu_calc_fc_sizes(size_t static_size,
1306 size_t reserved_size, 1326 size_t reserved_size,
1307 ssize_t *dyn_sizep) 1327 ssize_t *dyn_sizep)
diff --git a/mm/slab.c b/mm/slab.c
index a6c9166996a9..3f4822938f46 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -490,7 +490,7 @@ static void **dbg_userword(struct kmem_cache *cachep, void *objp)
490 490
491#endif 491#endif
492 492
493#ifdef CONFIG_KMEMTRACE 493#ifdef CONFIG_TRACING
494size_t slab_buffer_size(struct kmem_cache *cachep) 494size_t slab_buffer_size(struct kmem_cache *cachep)
495{ 495{
496 return cachep->buffer_size; 496 return cachep->buffer_size;
@@ -697,7 +697,7 @@ static inline void init_lock_keys(void)
697static DEFINE_MUTEX(cache_chain_mutex); 697static DEFINE_MUTEX(cache_chain_mutex);
698static struct list_head cache_chain; 698static struct list_head cache_chain;
699 699
700static DEFINE_PER_CPU(struct delayed_work, reap_work); 700static DEFINE_PER_CPU(struct delayed_work, slab_reap_work);
701 701
702static inline struct array_cache *cpu_cache_get(struct kmem_cache *cachep) 702static inline struct array_cache *cpu_cache_get(struct kmem_cache *cachep)
703{ 703{
@@ -838,7 +838,7 @@ __setup("noaliencache", noaliencache_setup);
838 * objects freed on different nodes from which they were allocated) and the 838 * objects freed on different nodes from which they were allocated) and the
839 * flushing of remote pcps by calling drain_node_pages. 839 * flushing of remote pcps by calling drain_node_pages.
840 */ 840 */
841static DEFINE_PER_CPU(unsigned long, reap_node); 841static DEFINE_PER_CPU(unsigned long, slab_reap_node);
842 842
843static void init_reap_node(int cpu) 843static void init_reap_node(int cpu)
844{ 844{
@@ -848,17 +848,17 @@ static void init_reap_node(int cpu)
848 if (node == MAX_NUMNODES) 848 if (node == MAX_NUMNODES)
849 node = first_node(node_online_map); 849 node = first_node(node_online_map);
850 850
851 per_cpu(reap_node, cpu) = node; 851 per_cpu(slab_reap_node, cpu) = node;
852} 852}
853 853
854static void next_reap_node(void) 854static void next_reap_node(void)
855{ 855{
856 int node = __get_cpu_var(reap_node); 856 int node = __get_cpu_var(slab_reap_node);
857 857
858 node = next_node(node, node_online_map); 858 node = next_node(node, node_online_map);
859 if (unlikely(node >= MAX_NUMNODES)) 859 if (unlikely(node >= MAX_NUMNODES))
860 node = first_node(node_online_map); 860 node = first_node(node_online_map);
861 __get_cpu_var(reap_node) = node; 861 __get_cpu_var(slab_reap_node) = node;
862} 862}
863 863
864#else 864#else
@@ -875,7 +875,7 @@ static void next_reap_node(void)
875 */ 875 */
876static void __cpuinit start_cpu_timer(int cpu) 876static void __cpuinit start_cpu_timer(int cpu)
877{ 877{
878 struct delayed_work *reap_work = &per_cpu(reap_work, cpu); 878 struct delayed_work *reap_work = &per_cpu(slab_reap_work, cpu);
879 879
880 /* 880 /*
881 * When this gets called from do_initcalls via cpucache_init(), 881 * When this gets called from do_initcalls via cpucache_init(),
@@ -1039,7 +1039,7 @@ static void __drain_alien_cache(struct kmem_cache *cachep,
1039 */ 1039 */
1040static void reap_alien(struct kmem_cache *cachep, struct kmem_list3 *l3) 1040static void reap_alien(struct kmem_cache *cachep, struct kmem_list3 *l3)
1041{ 1041{
1042 int node = __get_cpu_var(reap_node); 1042 int node = __get_cpu_var(slab_reap_node);
1043 1043
1044 if (l3->alien) { 1044 if (l3->alien) {
1045 struct array_cache *ac = l3->alien[node]; 1045 struct array_cache *ac = l3->alien[node];
@@ -1300,9 +1300,9 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
1300 * anything expensive but will only modify reap_work 1300 * anything expensive but will only modify reap_work
1301 * and reschedule the timer. 1301 * and reschedule the timer.
1302 */ 1302 */
1303 cancel_rearming_delayed_work(&per_cpu(reap_work, cpu)); 1303 cancel_rearming_delayed_work(&per_cpu(slab_reap_work, cpu));
1304 /* Now the cache_reaper is guaranteed to be not running. */ 1304 /* Now the cache_reaper is guaranteed to be not running. */
1305 per_cpu(reap_work, cpu).work.func = NULL; 1305 per_cpu(slab_reap_work, cpu).work.func = NULL;
1306 break; 1306 break;
1307 case CPU_DOWN_FAILED: 1307 case CPU_DOWN_FAILED:
1308 case CPU_DOWN_FAILED_FROZEN: 1308 case CPU_DOWN_FAILED_FROZEN:
@@ -3578,7 +3578,7 @@ void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags)
3578} 3578}
3579EXPORT_SYMBOL(kmem_cache_alloc); 3579EXPORT_SYMBOL(kmem_cache_alloc);
3580 3580
3581#ifdef CONFIG_KMEMTRACE 3581#ifdef CONFIG_TRACING
3582void *kmem_cache_alloc_notrace(struct kmem_cache *cachep, gfp_t flags) 3582void *kmem_cache_alloc_notrace(struct kmem_cache *cachep, gfp_t flags)
3583{ 3583{
3584 return __cache_alloc(cachep, flags, __builtin_return_address(0)); 3584 return __cache_alloc(cachep, flags, __builtin_return_address(0));
@@ -3641,7 +3641,7 @@ void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid)
3641} 3641}
3642EXPORT_SYMBOL(kmem_cache_alloc_node); 3642EXPORT_SYMBOL(kmem_cache_alloc_node);
3643 3643
3644#ifdef CONFIG_KMEMTRACE 3644#ifdef CONFIG_TRACING
3645void *kmem_cache_alloc_node_notrace(struct kmem_cache *cachep, 3645void *kmem_cache_alloc_node_notrace(struct kmem_cache *cachep,
3646 gfp_t flags, 3646 gfp_t flags,
3647 int nodeid) 3647 int nodeid)
@@ -3669,7 +3669,7 @@ __do_kmalloc_node(size_t size, gfp_t flags, int node, void *caller)
3669 return ret; 3669 return ret;
3670} 3670}
3671 3671
3672#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_KMEMTRACE) 3672#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_TRACING)
3673void *__kmalloc_node(size_t size, gfp_t flags, int node) 3673void *__kmalloc_node(size_t size, gfp_t flags, int node)
3674{ 3674{
3675 return __do_kmalloc_node(size, flags, node, 3675 return __do_kmalloc_node(size, flags, node,
@@ -3689,7 +3689,7 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
3689 return __do_kmalloc_node(size, flags, node, NULL); 3689 return __do_kmalloc_node(size, flags, node, NULL);
3690} 3690}
3691EXPORT_SYMBOL(__kmalloc_node); 3691EXPORT_SYMBOL(__kmalloc_node);
3692#endif /* CONFIG_DEBUG_SLAB */ 3692#endif /* CONFIG_DEBUG_SLAB || CONFIG_TRACING */
3693#endif /* CONFIG_NUMA */ 3693#endif /* CONFIG_NUMA */
3694 3694
3695/** 3695/**
@@ -3721,7 +3721,7 @@ static __always_inline void *__do_kmalloc(size_t size, gfp_t flags,
3721} 3721}
3722 3722
3723 3723
3724#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_KMEMTRACE) 3724#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_TRACING)
3725void *__kmalloc(size_t size, gfp_t flags) 3725void *__kmalloc(size_t size, gfp_t flags)
3726{ 3726{
3727 return __do_kmalloc(size, flags, __builtin_return_address(0)); 3727 return __do_kmalloc(size, flags, __builtin_return_address(0));
diff --git a/mm/slub.c b/mm/slub.c
index da0ce55965dc..8d71aaf888d7 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1754,7 +1754,7 @@ void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags)
1754} 1754}
1755EXPORT_SYMBOL(kmem_cache_alloc); 1755EXPORT_SYMBOL(kmem_cache_alloc);
1756 1756
1757#ifdef CONFIG_KMEMTRACE 1757#ifdef CONFIG_TRACING
1758void *kmem_cache_alloc_notrace(struct kmem_cache *s, gfp_t gfpflags) 1758void *kmem_cache_alloc_notrace(struct kmem_cache *s, gfp_t gfpflags)
1759{ 1759{
1760 return slab_alloc(s, gfpflags, -1, _RET_IP_); 1760 return slab_alloc(s, gfpflags, -1, _RET_IP_);
@@ -1775,7 +1775,7 @@ void *kmem_cache_alloc_node(struct kmem_cache *s, gfp_t gfpflags, int node)
1775EXPORT_SYMBOL(kmem_cache_alloc_node); 1775EXPORT_SYMBOL(kmem_cache_alloc_node);
1776#endif 1776#endif
1777 1777
1778#ifdef CONFIG_KMEMTRACE 1778#ifdef CONFIG_TRACING
1779void *kmem_cache_alloc_node_notrace(struct kmem_cache *s, 1779void *kmem_cache_alloc_node_notrace(struct kmem_cache *s,
1780 gfp_t gfpflags, 1780 gfp_t gfpflags,
1781 int node) 1781 int node)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 0f551a4a44cd..9b08d790df6f 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -761,7 +761,7 @@ static struct vmap_block *new_vmap_block(gfp_t gfp_mask)
761 spin_lock(&vbq->lock); 761 spin_lock(&vbq->lock);
762 list_add(&vb->free_list, &vbq->free); 762 list_add(&vb->free_list, &vbq->free);
763 spin_unlock(&vbq->lock); 763 spin_unlock(&vbq->lock);
764 put_cpu_var(vmap_cpu_blocks); 764 put_cpu_var(vmap_block_queue);
765 765
766 return vb; 766 return vb;
767} 767}
@@ -826,7 +826,7 @@ again:
826 } 826 }
827 spin_unlock(&vb->lock); 827 spin_unlock(&vb->lock);
828 } 828 }
829 put_cpu_var(vmap_cpu_blocks); 829 put_cpu_var(vmap_block_queue);
830 rcu_read_unlock(); 830 rcu_read_unlock();
831 831
832 if (!addr) { 832 if (!addr) {
diff --git a/mm/vmstat.c b/mm/vmstat.c
index c81321f9feec..dad2327e4580 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -883,11 +883,10 @@ static void vmstat_update(struct work_struct *w)
883 883
884static void __cpuinit start_cpu_timer(int cpu) 884static void __cpuinit start_cpu_timer(int cpu)
885{ 885{
886 struct delayed_work *vmstat_work = &per_cpu(vmstat_work, cpu); 886 struct delayed_work *work = &per_cpu(vmstat_work, cpu);
887 887
888 INIT_DELAYED_WORK_DEFERRABLE(vmstat_work, vmstat_update); 888 INIT_DELAYED_WORK_DEFERRABLE(work, vmstat_update);
889 schedule_delayed_work_on(cpu, vmstat_work, 889 schedule_delayed_work_on(cpu, work, __round_jiffies_relative(HZ, cpu));
890 __round_jiffies_relative(HZ, cpu));
891} 890}
892 891
893/* 892/*
diff --git a/net/sunrpc/addr.c b/net/sunrpc/addr.c
index c7450c8f0a7c..6dcdd2517819 100644
--- a/net/sunrpc/addr.c
+++ b/net/sunrpc/addr.c
@@ -55,16 +55,8 @@ static size_t rpc_ntop6_noscopeid(const struct sockaddr *sap,
55 55
56 /* 56 /*
57 * RFC 4291, Section 2.2.1 57 * RFC 4291, Section 2.2.1
58 *
59 * To keep the result as short as possible, especially
60 * since we don't shorthand, we don't want leading zeros
61 * in each halfword, so avoid %pI6.
62 */ 58 */
63 return snprintf(buf, buflen, "%x:%x:%x:%x:%x:%x:%x:%x", 59 return snprintf(buf, buflen, "%pI6c", addr);
64 ntohs(addr->s6_addr16[0]), ntohs(addr->s6_addr16[1]),
65 ntohs(addr->s6_addr16[2]), ntohs(addr->s6_addr16[3]),
66 ntohs(addr->s6_addr16[4]), ntohs(addr->s6_addr16[5]),
67 ntohs(addr->s6_addr16[6]), ntohs(addr->s6_addr16[7]));
68} 60}
69 61
70static size_t rpc_ntop6(const struct sockaddr *sap, 62static size_t rpc_ntop6(const struct sockaddr *sap,
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index 7535a7bed2fa..f394fc190a49 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -123,16 +123,19 @@ rpcauth_unhash_cred_locked(struct rpc_cred *cred)
123 clear_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags); 123 clear_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags);
124} 124}
125 125
126static void 126static int
127rpcauth_unhash_cred(struct rpc_cred *cred) 127rpcauth_unhash_cred(struct rpc_cred *cred)
128{ 128{
129 spinlock_t *cache_lock; 129 spinlock_t *cache_lock;
130 int ret;
130 131
131 cache_lock = &cred->cr_auth->au_credcache->lock; 132 cache_lock = &cred->cr_auth->au_credcache->lock;
132 spin_lock(cache_lock); 133 spin_lock(cache_lock);
133 if (atomic_read(&cred->cr_count) == 0) 134 ret = atomic_read(&cred->cr_count) == 0;
135 if (ret)
134 rpcauth_unhash_cred_locked(cred); 136 rpcauth_unhash_cred_locked(cred);
135 spin_unlock(cache_lock); 137 spin_unlock(cache_lock);
138 return ret;
136} 139}
137 140
138/* 141/*
@@ -446,31 +449,35 @@ void
446put_rpccred(struct rpc_cred *cred) 449put_rpccred(struct rpc_cred *cred)
447{ 450{
448 /* Fast path for unhashed credentials */ 451 /* Fast path for unhashed credentials */
449 if (test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) 452 if (test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) == 0) {
450 goto need_lock; 453 if (atomic_dec_and_test(&cred->cr_count))
451 454 cred->cr_ops->crdestroy(cred);
452 if (!atomic_dec_and_test(&cred->cr_count))
453 return; 455 return;
454 goto out_destroy; 456 }
455need_lock: 457
456 if (!atomic_dec_and_lock(&cred->cr_count, &rpc_credcache_lock)) 458 if (!atomic_dec_and_lock(&cred->cr_count, &rpc_credcache_lock))
457 return; 459 return;
458 if (!list_empty(&cred->cr_lru)) { 460 if (!list_empty(&cred->cr_lru)) {
459 number_cred_unused--; 461 number_cred_unused--;
460 list_del_init(&cred->cr_lru); 462 list_del_init(&cred->cr_lru);
461 } 463 }
462 if (test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) == 0)
463 rpcauth_unhash_cred(cred);
464 if (test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) { 464 if (test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) {
465 cred->cr_expire = jiffies; 465 if (test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0) {
466 list_add_tail(&cred->cr_lru, &cred_unused); 466 cred->cr_expire = jiffies;
467 number_cred_unused++; 467 list_add_tail(&cred->cr_lru, &cred_unused);
468 spin_unlock(&rpc_credcache_lock); 468 number_cred_unused++;
469 return; 469 goto out_nodestroy;
470 }
471 if (!rpcauth_unhash_cred(cred)) {
472 /* We were hashed and someone looked us up... */
473 goto out_nodestroy;
474 }
470 } 475 }
471 spin_unlock(&rpc_credcache_lock); 476 spin_unlock(&rpc_credcache_lock);
472out_destroy:
473 cred->cr_ops->crdestroy(cred); 477 cred->cr_ops->crdestroy(cred);
478 return;
479out_nodestroy:
480 spin_unlock(&rpc_credcache_lock);
474} 481}
475EXPORT_SYMBOL_GPL(put_rpccred); 482EXPORT_SYMBOL_GPL(put_rpccred);
476 483
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index fc6a43ccd950..3c3c50f38a1c 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -304,7 +304,7 @@ __gss_find_upcall(struct rpc_inode *rpci, uid_t uid)
304 * to that upcall instead of adding the new upcall. 304 * to that upcall instead of adding the new upcall.
305 */ 305 */
306static inline struct gss_upcall_msg * 306static inline struct gss_upcall_msg *
307gss_add_msg(struct gss_auth *gss_auth, struct gss_upcall_msg *gss_msg) 307gss_add_msg(struct gss_upcall_msg *gss_msg)
308{ 308{
309 struct rpc_inode *rpci = gss_msg->inode; 309 struct rpc_inode *rpci = gss_msg->inode;
310 struct inode *inode = &rpci->vfs_inode; 310 struct inode *inode = &rpci->vfs_inode;
@@ -445,7 +445,7 @@ gss_setup_upcall(struct rpc_clnt *clnt, struct gss_auth *gss_auth, struct rpc_cr
445 gss_new = gss_alloc_msg(gss_auth, uid, clnt, gss_cred->gc_machine_cred); 445 gss_new = gss_alloc_msg(gss_auth, uid, clnt, gss_cred->gc_machine_cred);
446 if (IS_ERR(gss_new)) 446 if (IS_ERR(gss_new))
447 return gss_new; 447 return gss_new;
448 gss_msg = gss_add_msg(gss_auth, gss_new); 448 gss_msg = gss_add_msg(gss_new);
449 if (gss_msg == gss_new) { 449 if (gss_msg == gss_new) {
450 struct inode *inode = &gss_new->inode->vfs_inode; 450 struct inode *inode = &gss_new->inode->vfs_inode;
451 int res = rpc_queue_upcall(inode, &gss_new->msg); 451 int res = rpc_queue_upcall(inode, &gss_new->msg);
@@ -485,7 +485,7 @@ gss_refresh_upcall(struct rpc_task *task)
485 dprintk("RPC: %5u gss_refresh_upcall for uid %u\n", task->tk_pid, 485 dprintk("RPC: %5u gss_refresh_upcall for uid %u\n", task->tk_pid,
486 cred->cr_uid); 486 cred->cr_uid);
487 gss_msg = gss_setup_upcall(task->tk_client, gss_auth, cred); 487 gss_msg = gss_setup_upcall(task->tk_client, gss_auth, cred);
488 if (IS_ERR(gss_msg) == -EAGAIN) { 488 if (PTR_ERR(gss_msg) == -EAGAIN) {
489 /* XXX: warning on the first, under the assumption we 489 /* XXX: warning on the first, under the assumption we
490 * shouldn't normally hit this case on a refresh. */ 490 * shouldn't normally hit this case on a refresh. */
491 warn_gssd(); 491 warn_gssd();
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 38829e20500b..154034b675bd 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -79,7 +79,7 @@ static void call_connect_status(struct rpc_task *task);
79 79
80static __be32 *rpc_encode_header(struct rpc_task *task); 80static __be32 *rpc_encode_header(struct rpc_task *task);
81static __be32 *rpc_verify_header(struct rpc_task *task); 81static __be32 *rpc_verify_header(struct rpc_task *task);
82static int rpc_ping(struct rpc_clnt *clnt, int flags); 82static int rpc_ping(struct rpc_clnt *clnt);
83 83
84static void rpc_register_client(struct rpc_clnt *clnt) 84static void rpc_register_client(struct rpc_clnt *clnt)
85{ 85{
@@ -340,7 +340,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
340 return clnt; 340 return clnt;
341 341
342 if (!(args->flags & RPC_CLNT_CREATE_NOPING)) { 342 if (!(args->flags & RPC_CLNT_CREATE_NOPING)) {
343 int err = rpc_ping(clnt, RPC_TASK_SOFT); 343 int err = rpc_ping(clnt);
344 if (err != 0) { 344 if (err != 0) {
345 rpc_shutdown_client(clnt); 345 rpc_shutdown_client(clnt);
346 return ERR_PTR(err); 346 return ERR_PTR(err);
@@ -528,7 +528,7 @@ struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *old,
528 clnt->cl_prog = program->number; 528 clnt->cl_prog = program->number;
529 clnt->cl_vers = version->number; 529 clnt->cl_vers = version->number;
530 clnt->cl_stats = program->stats; 530 clnt->cl_stats = program->stats;
531 err = rpc_ping(clnt, RPC_TASK_SOFT); 531 err = rpc_ping(clnt);
532 if (err != 0) { 532 if (err != 0) {
533 rpc_shutdown_client(clnt); 533 rpc_shutdown_client(clnt);
534 clnt = ERR_PTR(err); 534 clnt = ERR_PTR(err);
@@ -1060,7 +1060,7 @@ call_bind_status(struct rpc_task *task)
1060 goto retry_timeout; 1060 goto retry_timeout;
1061 case -EPFNOSUPPORT: 1061 case -EPFNOSUPPORT:
1062 /* server doesn't support any rpcbind version we know of */ 1062 /* server doesn't support any rpcbind version we know of */
1063 dprintk("RPC: %5u remote rpcbind service unavailable\n", 1063 dprintk("RPC: %5u unrecognized remote rpcbind service\n",
1064 task->tk_pid); 1064 task->tk_pid);
1065 break; 1065 break;
1066 case -EPROTONOSUPPORT: 1066 case -EPROTONOSUPPORT:
@@ -1069,6 +1069,21 @@ call_bind_status(struct rpc_task *task)
1069 task->tk_status = 0; 1069 task->tk_status = 0;
1070 task->tk_action = call_bind; 1070 task->tk_action = call_bind;
1071 return; 1071 return;
1072 case -ECONNREFUSED: /* connection problems */
1073 case -ECONNRESET:
1074 case -ENOTCONN:
1075 case -EHOSTDOWN:
1076 case -EHOSTUNREACH:
1077 case -ENETUNREACH:
1078 case -EPIPE:
1079 dprintk("RPC: %5u remote rpcbind unreachable: %d\n",
1080 task->tk_pid, task->tk_status);
1081 if (!RPC_IS_SOFTCONN(task)) {
1082 rpc_delay(task, 5*HZ);
1083 goto retry_timeout;
1084 }
1085 status = task->tk_status;
1086 break;
1072 default: 1087 default:
1073 dprintk("RPC: %5u unrecognized rpcbind error (%d)\n", 1088 dprintk("RPC: %5u unrecognized rpcbind error (%d)\n",
1074 task->tk_pid, -task->tk_status); 1089 task->tk_pid, -task->tk_status);
@@ -1180,11 +1195,25 @@ static void
1180call_transmit_status(struct rpc_task *task) 1195call_transmit_status(struct rpc_task *task)
1181{ 1196{
1182 task->tk_action = call_status; 1197 task->tk_action = call_status;
1198
1199 /*
1200 * Common case: success. Force the compiler to put this
1201 * test first.
1202 */
1203 if (task->tk_status == 0) {
1204 xprt_end_transmit(task);
1205 rpc_task_force_reencode(task);
1206 return;
1207 }
1208
1183 switch (task->tk_status) { 1209 switch (task->tk_status) {
1184 case -EAGAIN: 1210 case -EAGAIN:
1185 break; 1211 break;
1186 default: 1212 default:
1213 dprint_status(task);
1187 xprt_end_transmit(task); 1214 xprt_end_transmit(task);
1215 rpc_task_force_reencode(task);
1216 break;
1188 /* 1217 /*
1189 * Special cases: if we've been waiting on the 1218 * Special cases: if we've been waiting on the
1190 * socket's write_space() callback, or if the 1219 * socket's write_space() callback, or if the
@@ -1192,11 +1221,16 @@ call_transmit_status(struct rpc_task *task)
1192 * then hold onto the transport lock. 1221 * then hold onto the transport lock.
1193 */ 1222 */
1194 case -ECONNREFUSED: 1223 case -ECONNREFUSED:
1195 case -ECONNRESET:
1196 case -ENOTCONN:
1197 case -EHOSTDOWN: 1224 case -EHOSTDOWN:
1198 case -EHOSTUNREACH: 1225 case -EHOSTUNREACH:
1199 case -ENETUNREACH: 1226 case -ENETUNREACH:
1227 if (RPC_IS_SOFTCONN(task)) {
1228 xprt_end_transmit(task);
1229 rpc_exit(task, task->tk_status);
1230 break;
1231 }
1232 case -ECONNRESET:
1233 case -ENOTCONN:
1200 case -EPIPE: 1234 case -EPIPE:
1201 rpc_task_force_reencode(task); 1235 rpc_task_force_reencode(task);
1202 } 1236 }
@@ -1346,6 +1380,10 @@ call_timeout(struct rpc_task *task)
1346 dprintk("RPC: %5u call_timeout (major)\n", task->tk_pid); 1380 dprintk("RPC: %5u call_timeout (major)\n", task->tk_pid);
1347 task->tk_timeouts++; 1381 task->tk_timeouts++;
1348 1382
1383 if (RPC_IS_SOFTCONN(task)) {
1384 rpc_exit(task, -ETIMEDOUT);
1385 return;
1386 }
1349 if (RPC_IS_SOFT(task)) { 1387 if (RPC_IS_SOFT(task)) {
1350 if (clnt->cl_chatty) 1388 if (clnt->cl_chatty)
1351 printk(KERN_NOTICE "%s: server %s not responding, timed out\n", 1389 printk(KERN_NOTICE "%s: server %s not responding, timed out\n",
@@ -1675,14 +1713,14 @@ static struct rpc_procinfo rpcproc_null = {
1675 .p_decode = rpcproc_decode_null, 1713 .p_decode = rpcproc_decode_null,
1676}; 1714};
1677 1715
1678static int rpc_ping(struct rpc_clnt *clnt, int flags) 1716static int rpc_ping(struct rpc_clnt *clnt)
1679{ 1717{
1680 struct rpc_message msg = { 1718 struct rpc_message msg = {
1681 .rpc_proc = &rpcproc_null, 1719 .rpc_proc = &rpcproc_null,
1682 }; 1720 };
1683 int err; 1721 int err;
1684 msg.rpc_cred = authnull_ops.lookup_cred(NULL, NULL, 0); 1722 msg.rpc_cred = authnull_ops.lookup_cred(NULL, NULL, 0);
1685 err = rpc_call_sync(clnt, &msg, flags); 1723 err = rpc_call_sync(clnt, &msg, RPC_TASK_SOFT | RPC_TASK_SOFTCONN);
1686 put_rpccred(msg.rpc_cred); 1724 put_rpccred(msg.rpc_cred);
1687 return err; 1725 return err;
1688} 1726}
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c
index 830faf4d9997..3e3772d8eb92 100644
--- a/net/sunrpc/rpcb_clnt.c
+++ b/net/sunrpc/rpcb_clnt.c
@@ -20,6 +20,7 @@
20#include <linux/in6.h> 20#include <linux/in6.h>
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/errno.h> 22#include <linux/errno.h>
23#include <linux/mutex.h>
23#include <net/ipv6.h> 24#include <net/ipv6.h>
24 25
25#include <linux/sunrpc/clnt.h> 26#include <linux/sunrpc/clnt.h>
@@ -110,6 +111,9 @@ static void rpcb_getport_done(struct rpc_task *, void *);
110static void rpcb_map_release(void *data); 111static void rpcb_map_release(void *data);
111static struct rpc_program rpcb_program; 112static struct rpc_program rpcb_program;
112 113
114static struct rpc_clnt * rpcb_local_clnt;
115static struct rpc_clnt * rpcb_local_clnt4;
116
113struct rpcbind_args { 117struct rpcbind_args {
114 struct rpc_xprt * r_xprt; 118 struct rpc_xprt * r_xprt;
115 119
@@ -163,21 +167,60 @@ static const struct sockaddr_in rpcb_inaddr_loopback = {
163 .sin_port = htons(RPCBIND_PORT), 167 .sin_port = htons(RPCBIND_PORT),
164}; 168};
165 169
166static struct rpc_clnt *rpcb_create_local(struct sockaddr *addr, 170static DEFINE_MUTEX(rpcb_create_local_mutex);
167 size_t addrlen, u32 version) 171
172/*
173 * Returns zero on success, otherwise a negative errno value
174 * is returned.
175 */
176static int rpcb_create_local(void)
168{ 177{
169 struct rpc_create_args args = { 178 struct rpc_create_args args = {
170 .protocol = XPRT_TRANSPORT_UDP, 179 .protocol = XPRT_TRANSPORT_TCP,
171 .address = addr, 180 .address = (struct sockaddr *)&rpcb_inaddr_loopback,
172 .addrsize = addrlen, 181 .addrsize = sizeof(rpcb_inaddr_loopback),
173 .servername = "localhost", 182 .servername = "localhost",
174 .program = &rpcb_program, 183 .program = &rpcb_program,
175 .version = version, 184 .version = RPCBVERS_2,
176 .authflavor = RPC_AUTH_UNIX, 185 .authflavor = RPC_AUTH_UNIX,
177 .flags = RPC_CLNT_CREATE_NOPING, 186 .flags = RPC_CLNT_CREATE_NOPING,
178 }; 187 };
188 struct rpc_clnt *clnt, *clnt4;
189 int result = 0;
190
191 if (rpcb_local_clnt)
192 return result;
193
194 mutex_lock(&rpcb_create_local_mutex);
195 if (rpcb_local_clnt)
196 goto out;
197
198 clnt = rpc_create(&args);
199 if (IS_ERR(clnt)) {
200 dprintk("RPC: failed to create local rpcbind "
201 "client (errno %ld).\n", PTR_ERR(clnt));
202 result = -PTR_ERR(clnt);
203 goto out;
204 }
179 205
180 return rpc_create(&args); 206 /*
207 * This results in an RPC ping. On systems running portmapper,
208 * the v4 ping will fail. Proceed anyway, but disallow rpcb
209 * v4 upcalls.
210 */
211 clnt4 = rpc_bind_new_program(clnt, &rpcb_program, RPCBVERS_4);
212 if (IS_ERR(clnt4)) {
213 dprintk("RPC: failed to create local rpcbind v4 "
214 "cleint (errno %ld).\n", PTR_ERR(clnt4));
215 clnt4 = NULL;
216 }
217
218 rpcb_local_clnt = clnt;
219 rpcb_local_clnt4 = clnt4;
220
221out:
222 mutex_unlock(&rpcb_create_local_mutex);
223 return result;
181} 224}
182 225
183static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr, 226static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr,
@@ -209,22 +252,13 @@ static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr,
209 return rpc_create(&args); 252 return rpc_create(&args);
210} 253}
211 254
212static int rpcb_register_call(const u32 version, struct rpc_message *msg) 255static int rpcb_register_call(struct rpc_clnt *clnt, struct rpc_message *msg)
213{ 256{
214 struct sockaddr *addr = (struct sockaddr *)&rpcb_inaddr_loopback;
215 size_t addrlen = sizeof(rpcb_inaddr_loopback);
216 struct rpc_clnt *rpcb_clnt;
217 int result, error = 0; 257 int result, error = 0;
218 258
219 msg->rpc_resp = &result; 259 msg->rpc_resp = &result;
220 260
221 rpcb_clnt = rpcb_create_local(addr, addrlen, version); 261 error = rpc_call_sync(clnt, msg, RPC_TASK_SOFTCONN);
222 if (!IS_ERR(rpcb_clnt)) {
223 error = rpc_call_sync(rpcb_clnt, msg, 0);
224 rpc_shutdown_client(rpcb_clnt);
225 } else
226 error = PTR_ERR(rpcb_clnt);
227
228 if (error < 0) { 262 if (error < 0) {
229 dprintk("RPC: failed to contact local rpcbind " 263 dprintk("RPC: failed to contact local rpcbind "
230 "server (errno %d).\n", -error); 264 "server (errno %d).\n", -error);
@@ -279,6 +313,11 @@ int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port)
279 struct rpc_message msg = { 313 struct rpc_message msg = {
280 .rpc_argp = &map, 314 .rpc_argp = &map,
281 }; 315 };
316 int error;
317
318 error = rpcb_create_local();
319 if (error)
320 return error;
282 321
283 dprintk("RPC: %sregistering (%u, %u, %d, %u) with local " 322 dprintk("RPC: %sregistering (%u, %u, %d, %u) with local "
284 "rpcbind\n", (port ? "" : "un"), 323 "rpcbind\n", (port ? "" : "un"),
@@ -288,7 +327,7 @@ int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port)
288 if (port) 327 if (port)
289 msg.rpc_proc = &rpcb_procedures2[RPCBPROC_SET]; 328 msg.rpc_proc = &rpcb_procedures2[RPCBPROC_SET];
290 329
291 return rpcb_register_call(RPCBVERS_2, &msg); 330 return rpcb_register_call(rpcb_local_clnt, &msg);
292} 331}
293 332
294/* 333/*
@@ -313,7 +352,7 @@ static int rpcb_register_inet4(const struct sockaddr *sap,
313 if (port) 352 if (port)
314 msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; 353 msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET];
315 354
316 result = rpcb_register_call(RPCBVERS_4, msg); 355 result = rpcb_register_call(rpcb_local_clnt4, msg);
317 kfree(map->r_addr); 356 kfree(map->r_addr);
318 return result; 357 return result;
319} 358}
@@ -340,7 +379,7 @@ static int rpcb_register_inet6(const struct sockaddr *sap,
340 if (port) 379 if (port)
341 msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; 380 msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET];
342 381
343 result = rpcb_register_call(RPCBVERS_4, msg); 382 result = rpcb_register_call(rpcb_local_clnt4, msg);
344 kfree(map->r_addr); 383 kfree(map->r_addr);
345 return result; 384 return result;
346} 385}
@@ -356,7 +395,7 @@ static int rpcb_unregister_all_protofamilies(struct rpc_message *msg)
356 map->r_addr = ""; 395 map->r_addr = "";
357 msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET]; 396 msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET];
358 397
359 return rpcb_register_call(RPCBVERS_4, msg); 398 return rpcb_register_call(rpcb_local_clnt4, msg);
360} 399}
361 400
362/** 401/**
@@ -414,6 +453,13 @@ int rpcb_v4_register(const u32 program, const u32 version,
414 struct rpc_message msg = { 453 struct rpc_message msg = {
415 .rpc_argp = &map, 454 .rpc_argp = &map,
416 }; 455 };
456 int error;
457
458 error = rpcb_create_local();
459 if (error)
460 return error;
461 if (rpcb_local_clnt4 == NULL)
462 return -EPROTONOSUPPORT;
417 463
418 if (address == NULL) 464 if (address == NULL)
419 return rpcb_unregister_all_protofamilies(&msg); 465 return rpcb_unregister_all_protofamilies(&msg);
@@ -491,7 +537,7 @@ static struct rpc_task *rpcb_call_async(struct rpc_clnt *rpcb_clnt, struct rpcbi
491 .rpc_message = &msg, 537 .rpc_message = &msg,
492 .callback_ops = &rpcb_getport_ops, 538 .callback_ops = &rpcb_getport_ops,
493 .callback_data = map, 539 .callback_data = map,
494 .flags = RPC_TASK_ASYNC, 540 .flags = RPC_TASK_ASYNC | RPC_TASK_SOFTCONN,
495 }; 541 };
496 542
497 return rpc_run_task(&task_setup_data); 543 return rpc_run_task(&task_setup_data);
@@ -1027,3 +1073,15 @@ static struct rpc_program rpcb_program = {
1027 .version = rpcb_version, 1073 .version = rpcb_version,
1028 .stats = &rpcb_stats, 1074 .stats = &rpcb_stats,
1029}; 1075};
1076
1077/**
1078 * cleanup_rpcb_clnt - remove xprtsock's sysctls, unregister
1079 *
1080 */
1081void cleanup_rpcb_clnt(void)
1082{
1083 if (rpcb_local_clnt4)
1084 rpc_shutdown_client(rpcb_local_clnt4);
1085 if (rpcb_local_clnt)
1086 rpc_shutdown_client(rpcb_local_clnt);
1087}
diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c
index 8cce92189019..f438347d817b 100644
--- a/net/sunrpc/sunrpc_syms.c
+++ b/net/sunrpc/sunrpc_syms.c
@@ -24,6 +24,8 @@
24 24
25extern struct cache_detail ip_map_cache, unix_gid_cache; 25extern struct cache_detail ip_map_cache, unix_gid_cache;
26 26
27extern void cleanup_rpcb_clnt(void);
28
27static int __init 29static int __init
28init_sunrpc(void) 30init_sunrpc(void)
29{ 31{
@@ -53,6 +55,7 @@ out:
53static void __exit 55static void __exit
54cleanup_sunrpc(void) 56cleanup_sunrpc(void)
55{ 57{
58 cleanup_rpcb_clnt();
56 rpcauth_remove_module(); 59 rpcauth_remove_module();
57 cleanup_socket_xprt(); 60 cleanup_socket_xprt();
58 svc_cleanup_xprt_sock(); 61 svc_cleanup_xprt_sock();
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index fd46d42afa89..469de292c23c 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -700,6 +700,10 @@ void xprt_connect(struct rpc_task *task)
700 } 700 }
701 if (!xprt_lock_write(xprt, task)) 701 if (!xprt_lock_write(xprt, task))
702 return; 702 return;
703
704 if (test_and_clear_bit(XPRT_CLOSE_WAIT, &xprt->state))
705 xprt->ops->close(xprt);
706
703 if (xprt_connected(xprt)) 707 if (xprt_connected(xprt))
704 xprt_release_write(xprt, task); 708 xprt_release_write(xprt, task);
705 else { 709 else {
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 04732d09013e..3d739e5d15d8 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -2019,7 +2019,7 @@ static void xs_connect(struct rpc_task *task)
2019 if (xprt_test_and_set_connecting(xprt)) 2019 if (xprt_test_and_set_connecting(xprt))
2020 return; 2020 return;
2021 2021
2022 if (transport->sock != NULL) { 2022 if (transport->sock != NULL && !RPC_IS_SOFTCONN(task)) {
2023 dprintk("RPC: xs_connect delayed xprt %p for %lu " 2023 dprintk("RPC: xs_connect delayed xprt %p for %lu "
2024 "seconds\n", 2024 "seconds\n",
2025 xprt, xprt->reestablish_timeout / HZ); 2025 xprt, xprt->reestablish_timeout / HZ);
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index f0d14452632b..9cf0a6fad6ba 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -295,6 +295,9 @@ if ($arch eq "x86_64") {
295 $ld .= " -m elf64_sparc"; 295 $ld .= " -m elf64_sparc";
296 $cc .= " -m64"; 296 $cc .= " -m64";
297 $objcopy .= " -O elf64-sparc"; 297 $objcopy .= " -O elf64-sparc";
298} elsif ($arch eq "microblaze") {
299 # Microblaze calls '_mcount' instead of plain 'mcount'.
300 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$";
298} else { 301} else {
299 die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD"; 302 die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD";
300} 303}
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c
index 7717e01fc071..edaa729126bb 100644
--- a/sound/pcmcia/pdaudiocf/pdaudiocf.c
+++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c
@@ -143,7 +143,8 @@ static int snd_pdacf_probe(struct pcmcia_device *link)
143 link->io.NumPorts1 = 16; 143 link->io.NumPorts1 = 16;
144 144
145 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_FORCED_PULSE; 145 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_FORCED_PULSE;
146 // link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; 146 /* FIXME: This driver should be updated to allow for dynamic IRQ sharing */
147 /* link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_FORCED_PULSE; */
147 148
148 link->irq.Handler = pdacf_interrupt; 149 link->irq.Handler = pdacf_interrupt;
149 link->conf.Attributes = CONF_ENABLE_IRQ; 150 link->conf.Attributes = CONF_ENABLE_IRQ;
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
index 5f1681f6ca76..2a27f7b56726 100644
--- a/sound/soc/codecs/twl4030.c
+++ b/sound/soc/codecs/twl4030.c
@@ -26,7 +26,7 @@
26#include <linux/pm.h> 26#include <linux/pm.h>
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/i2c/twl4030.h> 29#include <linux/i2c/twl.h>
30#include <sound/core.h> 30#include <sound/core.h>
31#include <sound/pcm.h> 31#include <sound/pcm.h>
32#include <sound/pcm_params.h> 32#include <sound/pcm_params.h>
@@ -175,7 +175,7 @@ static int twl4030_write(struct snd_soc_codec *codec,
175{ 175{
176 twl4030_write_reg_cache(codec, reg, value); 176 twl4030_write_reg_cache(codec, reg, value);
177 if (likely(reg < TWL4030_REG_SW_SHADOW)) 177 if (likely(reg < TWL4030_REG_SW_SHADOW))
178 return twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, value, 178 return twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, value,
179 reg); 179 reg);
180 else 180 else
181 return 0; 181 return 0;
@@ -261,7 +261,7 @@ static void twl4030_power_up(struct snd_soc_codec *codec)
261 do { 261 do {
262 /* this takes a little while, so don't slam i2c */ 262 /* this takes a little while, so don't slam i2c */
263 udelay(2000); 263 udelay(2000);
264 twl4030_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, 264 twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte,
265 TWL4030_REG_ANAMICL); 265 TWL4030_REG_ANAMICL);
266 } while ((i++ < 100) && 266 } while ((i++ < 100) &&
267 ((byte & TWL4030_CNCL_OFFSET_START) == 267 ((byte & TWL4030_CNCL_OFFSET_START) ==
@@ -542,7 +542,7 @@ static int pin_name##pga_event(struct snd_soc_dapm_widget *w, \
542 break; \ 542 break; \
543 case SND_SOC_DAPM_POST_PMD: \ 543 case SND_SOC_DAPM_POST_PMD: \
544 reg_val = twl4030_read_reg_cache(w->codec, reg); \ 544 reg_val = twl4030_read_reg_cache(w->codec, reg); \
545 twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, \ 545 twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, \
546 reg_val & (~mask), \ 546 reg_val & (~mask), \
547 reg); \ 547 reg); \
548 break; \ 548 break; \
@@ -679,7 +679,7 @@ static void headset_ramp(struct snd_soc_codec *codec, int ramp)
679 mdelay((ramp_base[(hs_pop & TWL4030_RAMP_DELAY) >> 2] / 679 mdelay((ramp_base[(hs_pop & TWL4030_RAMP_DELAY) >> 2] /
680 twl4030->sysclk) + 1); 680 twl4030->sysclk) + 1);
681 /* Bypass the reg_cache to mute the headset */ 681 /* Bypass the reg_cache to mute the headset */
682 twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, 682 twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
683 hs_gain & (~0x0f), 683 hs_gain & (~0x0f),
684 TWL4030_REG_HS_GAIN_SET); 684 TWL4030_REG_HS_GAIN_SET);
685 685
diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c
index f82125d9e85a..ebbf11b653a4 100644
--- a/sound/soc/codecs/wm8350.c
+++ b/sound/soc/codecs/wm8350.c
@@ -1340,9 +1340,10 @@ static int wm8350_resume(struct platform_device *pdev)
1340 return 0; 1340 return 0;
1341} 1341}
1342 1342
1343static void wm8350_hp_jack_handler(struct wm8350 *wm8350, int irq, void *data) 1343static irqreturn_t wm8350_hp_jack_handler(int irq, void *data)
1344{ 1344{
1345 struct wm8350_data *priv = data; 1345 struct wm8350_data *priv = data;
1346 struct wm8350 *wm8350 = priv->codec.control_data;
1346 u16 reg; 1347 u16 reg;
1347 int report; 1348 int report;
1348 int mask; 1349 int mask;
@@ -1365,7 +1366,7 @@ static void wm8350_hp_jack_handler(struct wm8350 *wm8350, int irq, void *data)
1365 1366
1366 if (!jack->jack) { 1367 if (!jack->jack) {
1367 dev_warn(wm8350->dev, "Jack interrupt called with no jack\n"); 1368 dev_warn(wm8350->dev, "Jack interrupt called with no jack\n");
1368 return; 1369 return IRQ_NONE;
1369 } 1370 }
1370 1371
1371 /* Debounce */ 1372 /* Debounce */
@@ -1378,6 +1379,8 @@ static void wm8350_hp_jack_handler(struct wm8350 *wm8350, int irq, void *data)
1378 report = 0; 1379 report = 0;
1379 1380
1380 snd_soc_jack_report(jack->jack, report, jack->report); 1381 snd_soc_jack_report(jack->jack, report, jack->report);
1382
1383 return IRQ_HANDLED;
1381} 1384}
1382 1385
1383/** 1386/**
@@ -1421,9 +1424,7 @@ int wm8350_hp_jack_detect(struct snd_soc_codec *codec, enum wm8350_jack which,
1421 wm8350_set_bits(wm8350, WM8350_JACK_DETECT, ena); 1424 wm8350_set_bits(wm8350, WM8350_JACK_DETECT, ena);
1422 1425
1423 /* Sync status */ 1426 /* Sync status */
1424 wm8350_hp_jack_handler(wm8350, irq, priv); 1427 wm8350_hp_jack_handler(irq, priv);
1425
1426 wm8350_unmask_irq(wm8350, irq);
1427 1428
1428 return 0; 1429 return 0;
1429} 1430}
@@ -1482,12 +1483,16 @@ static int wm8350_probe(struct platform_device *pdev)
1482 wm8350_set_bits(wm8350, WM8350_ROUT2_VOLUME, 1483 wm8350_set_bits(wm8350, WM8350_ROUT2_VOLUME,
1483 WM8350_OUT2_VU | WM8350_OUT2R_MUTE); 1484 WM8350_OUT2_VU | WM8350_OUT2R_MUTE);
1484 1485
1485 wm8350_mask_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L); 1486 /* Make sure jack detect is disabled to start off with */
1486 wm8350_mask_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R); 1487 wm8350_clear_bits(wm8350, WM8350_JACK_DETECT,
1488 WM8350_JDL_ENA | WM8350_JDR_ENA);
1489
1487 wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, 1490 wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L,
1488 wm8350_hp_jack_handler, priv); 1491 wm8350_hp_jack_handler, 0, "Left jack detect",
1492 priv);
1489 wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, 1493 wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R,
1490 wm8350_hp_jack_handler, priv); 1494 wm8350_hp_jack_handler, 0, "Right jack detect",
1495 priv);
1491 1496
1492 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); 1497 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
1493 if (ret < 0) { 1498 if (ret < 0) {
@@ -1516,8 +1521,6 @@ static int wm8350_remove(struct platform_device *pdev)
1516 WM8350_JDL_ENA | WM8350_JDR_ENA); 1521 WM8350_JDL_ENA | WM8350_JDR_ENA);
1517 wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_4, WM8350_TOCLK_ENA); 1522 wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_4, WM8350_TOCLK_ENA);
1518 1523
1519 wm8350_mask_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L);
1520 wm8350_mask_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R);
1521 wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L); 1524 wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L);
1522 wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R); 1525 wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R);
1523 1526
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 23ec66098bdc..406999668cab 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -237,8 +237,8 @@ lib = lib
237 237
238export prefix bindir sharedir sysconfdir 238export prefix bindir sharedir sysconfdir
239 239
240CC = gcc 240CC = $(CROSS_COMPILE)gcc
241AR = ar 241AR = $(CROSS_COMPILE)ar
242RM = rm -f 242RM = rm -f
243TAR = tar 243TAR = tar
244FIND = find 244FIND = find
@@ -356,7 +356,9 @@ LIB_H += util/parse-options.h
356LIB_H += util/parse-events.h 356LIB_H += util/parse-events.h
357LIB_H += util/quote.h 357LIB_H += util/quote.h
358LIB_H += util/util.h 358LIB_H += util/util.h
359LIB_H += util/header.h
359LIB_H += util/help.h 360LIB_H += util/help.h
361LIB_H += util/session.h
360LIB_H += util/strbuf.h 362LIB_H += util/strbuf.h
361LIB_H += util/string.h 363LIB_H += util/string.h
362LIB_H += util/strlist.h 364LIB_H += util/strlist.h
@@ -405,6 +407,7 @@ LIB_OBJS += util/callchain.o
405LIB_OBJS += util/values.o 407LIB_OBJS += util/values.o
406LIB_OBJS += util/debug.o 408LIB_OBJS += util/debug.o
407LIB_OBJS += util/map.o 409LIB_OBJS += util/map.o
410LIB_OBJS += util/session.o
408LIB_OBJS += util/thread.o 411LIB_OBJS += util/thread.o
409LIB_OBJS += util/trace-event-parse.o 412LIB_OBJS += util/trace-event-parse.o
410LIB_OBJS += util/trace-event-read.o 413LIB_OBJS += util/trace-event-read.o
@@ -492,8 +495,10 @@ else
492 LIB_OBJS += util/probe-finder.o 495 LIB_OBJS += util/probe-finder.o
493endif 496endif
494 497
498ifndef NO_LIBPERL
495PERL_EMBED_LDOPTS = `perl -MExtUtils::Embed -e ldopts 2>/dev/null` 499PERL_EMBED_LDOPTS = `perl -MExtUtils::Embed -e ldopts 2>/dev/null`
496PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` 500PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
501endif
497 502
498ifneq ($(shell sh -c "(echo '\#include <EXTERN.h>'; echo '\#include <perl.h>'; echo 'int main(void) { perl_alloc(); return 0; }') | $(CC) -x c - $(PERL_EMBED_CCOPTS) -o /dev/null $(PERL_EMBED_LDOPTS) > /dev/null 2>&1 && echo y"), y) 503ifneq ($(shell sh -c "(echo '\#include <EXTERN.h>'; echo '\#include <perl.h>'; echo 'int main(void) { perl_alloc(); return 0; }') | $(CC) -x c - $(PERL_EMBED_CCOPTS) -o /dev/null $(PERL_EMBED_LDOPTS) > /dev/null 2>&1 && echo y"), y)
499 BASIC_CFLAGS += -DNO_LIBPERL 504 BASIC_CFLAGS += -DNO_LIBPERL
diff --git a/tools/perf/bench/sched-messaging.c b/tools/perf/bench/sched-messaging.c
index 605a2a959aa8..81cee78181fa 100644
--- a/tools/perf/bench/sched-messaging.c
+++ b/tools/perf/bench/sched-messaging.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * 2 *
3 * builtin-bench-messaging.c 3 * sched-messaging.c
4 * 4 *
5 * messaging: Benchmark for scheduler and IPC mechanisms 5 * messaging: Benchmark for scheduler and IPC mechanisms
6 * 6 *
@@ -320,10 +320,12 @@ int bench_sched_messaging(int argc, const char **argv,
320 num_groups, num_groups * 2 * num_fds, 320 num_groups, num_groups * 2 * num_fds,
321 thread_mode ? "threads" : "processes"); 321 thread_mode ? "threads" : "processes");
322 printf(" %14s: %lu.%03lu [sec]\n", "Total time", 322 printf(" %14s: %lu.%03lu [sec]\n", "Total time",
323 diff.tv_sec, diff.tv_usec/1000); 323 diff.tv_sec,
324 (unsigned long) (diff.tv_usec/1000));
324 break; 325 break;
325 case BENCH_FORMAT_SIMPLE: 326 case BENCH_FORMAT_SIMPLE:
326 printf("%lu.%03lu\n", diff.tv_sec, diff.tv_usec/1000); 327 printf("%lu.%03lu\n", diff.tv_sec,
328 (unsigned long) (diff.tv_usec/1000));
327 break; 329 break;
328 default: 330 default:
329 /* reaching here is something disaster */ 331 /* reaching here is something disaster */
diff --git a/tools/perf/bench/sched-pipe.c b/tools/perf/bench/sched-pipe.c
index 238185f97977..4f77c7c27640 100644
--- a/tools/perf/bench/sched-pipe.c
+++ b/tools/perf/bench/sched-pipe.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * 2 *
3 * builtin-bench-pipe.c 3 * sched-pipe.c
4 * 4 *
5 * pipe: Benchmark for pipe() 5 * pipe: Benchmark for pipe()
6 * 6 *
@@ -87,7 +87,8 @@ int bench_sched_pipe(int argc, const char **argv,
87 if (pid) { 87 if (pid) {
88 retpid = waitpid(pid, &wait_stat, 0); 88 retpid = waitpid(pid, &wait_stat, 0);
89 assert((retpid == pid) && WIFEXITED(wait_stat)); 89 assert((retpid == pid) && WIFEXITED(wait_stat));
90 return 0; 90 } else {
91 exit(0);
91 } 92 }
92 93
93 switch (bench_format) { 94 switch (bench_format) {
@@ -99,7 +100,8 @@ int bench_sched_pipe(int argc, const char **argv,
99 result_usec += diff.tv_usec; 100 result_usec += diff.tv_usec;
100 101
101 printf(" %14s: %lu.%03lu [sec]\n\n", "Total time", 102 printf(" %14s: %lu.%03lu [sec]\n\n", "Total time",
102 diff.tv_sec, diff.tv_usec/1000); 103 diff.tv_sec,
104 (unsigned long) (diff.tv_usec/1000));
103 105
104 printf(" %14lf usecs/op\n", 106 printf(" %14lf usecs/op\n",
105 (double)result_usec / (double)loops); 107 (double)result_usec / (double)loops);
@@ -110,7 +112,8 @@ int bench_sched_pipe(int argc, const char **argv,
110 112
111 case BENCH_FORMAT_SIMPLE: 113 case BENCH_FORMAT_SIMPLE:
112 printf("%lu.%03lu\n", 114 printf("%lu.%03lu\n",
113 diff.tv_sec, diff.tv_usec / 1000); 115 diff.tv_sec,
116 (unsigned long) (diff.tv_usec / 1000));
114 break; 117 break;
115 118
116 default: 119 default:
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 0bf2e8f9af57..21a78d30d53d 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -25,6 +25,7 @@
25#include "util/thread.h" 25#include "util/thread.h"
26#include "util/sort.h" 26#include "util/sort.h"
27#include "util/hist.h" 27#include "util/hist.h"
28#include "util/session.h"
28#include "util/data_map.h" 29#include "util/data_map.h"
29 30
30static char const *input_name = "perf.data"; 31static char const *input_name = "perf.data";
@@ -462,21 +463,23 @@ static struct perf_file_handler file_handler = {
462 463
463static int __cmd_annotate(void) 464static int __cmd_annotate(void)
464{ 465{
465 struct perf_header *header; 466 struct perf_session *session = perf_session__new(input_name, O_RDONLY, force);
466 struct thread *idle; 467 struct thread *idle;
467 int ret; 468 int ret;
468 469
470 if (session == NULL)
471 return -ENOMEM;
472
469 idle = register_idle_thread(); 473 idle = register_idle_thread();
470 register_perf_file_handler(&file_handler); 474 register_perf_file_handler(&file_handler);
471 475
472 ret = mmap_dispatch_perf_file(&header, input_name, 0, 0, 476 ret = perf_session__process_events(session, 0, &event__cwdlen, &event__cwd);
473 &event__cwdlen, &event__cwd);
474 if (ret) 477 if (ret)
475 return ret; 478 goto out_delete;
476 479
477 if (dump_trace) { 480 if (dump_trace) {
478 event__print_totals(); 481 event__print_totals();
479 return 0; 482 goto out_delete;
480 } 483 }
481 484
482 if (verbose > 3) 485 if (verbose > 3)
@@ -489,6 +492,8 @@ static int __cmd_annotate(void)
489 output__resort(event__total[0]); 492 output__resort(event__total[0]);
490 493
491 find_annotations(); 494 find_annotations();
495out_delete:
496 perf_session__delete(session);
492 497
493 return ret; 498 return ret;
494} 499}
diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c
index e043eb83092a..46996774e559 100644
--- a/tools/perf/builtin-bench.c
+++ b/tools/perf/builtin-bench.c
@@ -31,6 +31,9 @@ struct bench_suite {
31 const char *summary; 31 const char *summary;
32 int (*fn)(int, const char **, const char *); 32 int (*fn)(int, const char **, const char *);
33}; 33};
34 \
35/* sentinel: easy for help */
36#define suite_all { "all", "test all suite (pseudo suite)", NULL }
34 37
35static struct bench_suite sched_suites[] = { 38static struct bench_suite sched_suites[] = {
36 { "messaging", 39 { "messaging",
@@ -39,6 +42,7 @@ static struct bench_suite sched_suites[] = {
39 { "pipe", 42 { "pipe",
40 "Flood of communication over pipe() between two processes", 43 "Flood of communication over pipe() between two processes",
41 bench_sched_pipe }, 44 bench_sched_pipe },
45 suite_all,
42 { NULL, 46 { NULL,
43 NULL, 47 NULL,
44 NULL } 48 NULL }
@@ -48,6 +52,7 @@ static struct bench_suite mem_suites[] = {
48 { "memcpy", 52 { "memcpy",
49 "Simple memory copy in various ways", 53 "Simple memory copy in various ways",
50 bench_mem_memcpy }, 54 bench_mem_memcpy },
55 suite_all,
51 { NULL, 56 { NULL,
52 NULL, 57 NULL,
53 NULL } 58 NULL }
@@ -66,6 +71,9 @@ static struct bench_subsys subsystems[] = {
66 { "mem", 71 { "mem",
67 "memory access performance", 72 "memory access performance",
68 mem_suites }, 73 mem_suites },
74 { "all", /* sentinel: easy for help */
75 "test all subsystem (pseudo subsystem)",
76 NULL },
69 { NULL, 77 { NULL,
70 NULL, 78 NULL,
71 NULL } 79 NULL }
@@ -75,11 +83,11 @@ static void dump_suites(int subsys_index)
75{ 83{
76 int i; 84 int i;
77 85
78 printf("List of available suites for %s...\n\n", 86 printf("# List of available suites for %s...\n\n",
79 subsystems[subsys_index].name); 87 subsystems[subsys_index].name);
80 88
81 for (i = 0; subsystems[subsys_index].suites[i].name; i++) 89 for (i = 0; subsystems[subsys_index].suites[i].name; i++)
82 printf("\t%s: %s\n", 90 printf("%14s: %s\n",
83 subsystems[subsys_index].suites[i].name, 91 subsystems[subsys_index].suites[i].name,
84 subsystems[subsys_index].suites[i].summary); 92 subsystems[subsys_index].suites[i].summary);
85 93
@@ -110,10 +118,10 @@ static void print_usage(void)
110 printf("\t%s\n", bench_usage[i]); 118 printf("\t%s\n", bench_usage[i]);
111 printf("\n"); 119 printf("\n");
112 120
113 printf("List of available subsystems...\n\n"); 121 printf("# List of available subsystems...\n\n");
114 122
115 for (i = 0; subsystems[i].name; i++) 123 for (i = 0; subsystems[i].name; i++)
116 printf("\t%s: %s\n", 124 printf("%14s: %s\n",
117 subsystems[i].name, subsystems[i].summary); 125 subsystems[i].name, subsystems[i].summary);
118 printf("\n"); 126 printf("\n");
119} 127}
@@ -131,6 +139,37 @@ static int bench_str2int(char *str)
131 return BENCH_FORMAT_UNKNOWN; 139 return BENCH_FORMAT_UNKNOWN;
132} 140}
133 141
142static void all_suite(struct bench_subsys *subsys) /* FROM HERE */
143{
144 int i;
145 const char *argv[2];
146 struct bench_suite *suites = subsys->suites;
147
148 argv[1] = NULL;
149 /*
150 * TODO:
151 * preparing preset parameters for
152 * embedded, ordinary PC, HPC, etc...
153 * will be helpful
154 */
155 for (i = 0; suites[i].fn; i++) {
156 printf("# Running %s/%s benchmark...\n",
157 subsys->name,
158 suites[i].name);
159
160 argv[1] = suites[i].name;
161 suites[i].fn(1, argv, NULL);
162 printf("\n");
163 }
164}
165
166static void all_subsystem(void)
167{
168 int i;
169 for (i = 0; subsystems[i].suites; i++)
170 all_suite(&subsystems[i]);
171}
172
134int cmd_bench(int argc, const char **argv, const char *prefix __used) 173int cmd_bench(int argc, const char **argv, const char *prefix __used)
135{ 174{
136 int i, j, status = 0; 175 int i, j, status = 0;
@@ -155,6 +194,11 @@ int cmd_bench(int argc, const char **argv, const char *prefix __used)
155 goto end; 194 goto end;
156 } 195 }
157 196
197 if (!strcmp(argv[0], "all")) {
198 all_subsystem();
199 goto end;
200 }
201
158 for (i = 0; subsystems[i].name; i++) { 202 for (i = 0; subsystems[i].name; i++) {
159 if (strcmp(subsystems[i].name, argv[0])) 203 if (strcmp(subsystems[i].name, argv[0]))
160 continue; 204 continue;
@@ -165,6 +209,11 @@ int cmd_bench(int argc, const char **argv, const char *prefix __used)
165 goto end; 209 goto end;
166 } 210 }
167 211
212 if (!strcmp(argv[1], "all")) {
213 all_suite(&subsystems[i]);
214 goto end;
215 }
216
168 for (j = 0; subsystems[i].suites[j].name; j++) { 217 for (j = 0; subsystems[i].suites[j].name; j++) {
169 if (strcmp(subsystems[i].suites[j].name, argv[1])) 218 if (strcmp(subsystems[i].suites[j].name, argv[1]))
170 continue; 219 continue;
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c
index dcb6143a0002..bfd16a1594e4 100644
--- a/tools/perf/builtin-buildid-list.c
+++ b/tools/perf/builtin-buildid-list.c
@@ -11,8 +11,8 @@
11#include "util/cache.h" 11#include "util/cache.h"
12#include "util/data_map.h" 12#include "util/data_map.h"
13#include "util/debug.h" 13#include "util/debug.h"
14#include "util/header.h"
15#include "util/parse-options.h" 14#include "util/parse-options.h"
15#include "util/session.h"
16#include "util/symbol.h" 16#include "util/symbol.h"
17 17
18static char const *input_name = "perf.data"; 18static char const *input_name = "perf.data";
@@ -55,56 +55,17 @@ static int perf_file_section__process_buildids(struct perf_file_section *self,
55static int __cmd_buildid_list(void) 55static int __cmd_buildid_list(void)
56{ 56{
57 int err = -1; 57 int err = -1;
58 struct perf_header *header; 58 struct perf_session *session = perf_session__new(input_name, O_RDONLY, force);
59 struct perf_file_header f_header;
60 struct stat input_stat;
61 int input = open(input_name, O_RDONLY);
62 59
63 if (input < 0) { 60 if (session == NULL)
64 pr_err("failed to open file: %s", input_name); 61 return -1;
65 if (!strcmp(input_name, "perf.data"))
66 pr_err(" (try 'perf record' first)");
67 pr_err("\n");
68 goto out;
69 }
70
71 err = fstat(input, &input_stat);
72 if (err < 0) {
73 perror("failed to stat file");
74 goto out_close;
75 }
76
77 if (!force && input_stat.st_uid && (input_stat.st_uid != geteuid())) {
78 pr_err("file %s not owned by current user or root\n",
79 input_name);
80 goto out_close;
81 }
82
83 if (!input_stat.st_size) {
84 pr_info("zero-sized file, nothing to do!\n");
85 goto out_close;
86 }
87
88 err = -1;
89 header = perf_header__new();
90 if (header == NULL)
91 goto out_close;
92
93 if (perf_file_header__read(&f_header, header, input) < 0) {
94 pr_warning("incompatible file format");
95 goto out_close;
96 }
97 62
98 err = perf_header__process_sections(header, input, 63 err = perf_header__process_sections(&session->header, session->fd,
99 perf_file_section__process_buildids); 64 perf_file_section__process_buildids);
65 if (err >= 0)
66 dsos__fprintf_buildid(stdout);
100 67
101 if (err < 0) 68 perf_session__delete(session);
102 goto out_close;
103
104 dsos__fprintf_buildid(stdout);
105out_close:
106 close(input);
107out:
108 return err; 69 return err;
109} 70}
110 71
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 5f209514f657..2071d2485913 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -6,6 +6,7 @@
6#include "util/symbol.h" 6#include "util/symbol.h"
7#include "util/thread.h" 7#include "util/thread.h"
8#include "util/header.h" 8#include "util/header.h"
9#include "util/session.h"
9 10
10#include "util/parse-options.h" 11#include "util/parse-options.h"
11#include "util/trace-event.h" 12#include "util/trace-event.h"
@@ -20,7 +21,6 @@ typedef int (*sort_fn_t)(struct alloc_stat *, struct alloc_stat *);
20 21
21static char const *input_name = "perf.data"; 22static char const *input_name = "perf.data";
22 23
23static struct perf_header *header;
24static u64 sample_type; 24static u64 sample_type;
25 25
26static int alloc_flag; 26static int alloc_flag;
@@ -367,11 +367,18 @@ static struct perf_file_handler file_handler = {
367 367
368static int read_events(void) 368static int read_events(void)
369{ 369{
370 int err;
371 struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0);
372
373 if (session == NULL)
374 return -ENOMEM;
375
370 register_idle_thread(); 376 register_idle_thread();
371 register_perf_file_handler(&file_handler); 377 register_perf_file_handler(&file_handler);
372 378
373 return mmap_dispatch_perf_file(&header, input_name, 0, 0, 379 err = perf_session__process_events(session, 0, &event__cwdlen, &event__cwd);
374 &event__cwdlen, &event__cwd); 380 perf_session__delete(session);
381 return err;
375} 382}
376 383
377static double fragmentation(unsigned long n_req, unsigned long n_alloc) 384static double fragmentation(unsigned long n_req, unsigned long n_alloc)
@@ -403,7 +410,7 @@ static void __print_result(struct rb_root *root, int n_lines, int is_caller)
403 if (is_caller) { 410 if (is_caller) {
404 addr = data->call_site; 411 addr = data->call_site;
405 if (!raw_ip) 412 if (!raw_ip)
406 sym = thread__find_function(kthread, addr, NULL); 413 sym = map_groups__find_function(kmaps, addr, NULL);
407 } else 414 } else
408 addr = data->ptr; 415 addr = data->ptr;
409 416
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 0e519c667e3a..4decbd14eaed 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -17,6 +17,7 @@
17#include "util/header.h" 17#include "util/header.h"
18#include "util/event.h" 18#include "util/event.h"
19#include "util/debug.h" 19#include "util/debug.h"
20#include "util/session.h"
20#include "util/symbol.h" 21#include "util/symbol.h"
21 22
22#include <unistd.h> 23#include <unistd.h>
@@ -62,7 +63,7 @@ static int nr_cpu = 0;
62 63
63static int file_new = 1; 64static int file_new = 1;
64 65
65struct perf_header *header = NULL; 66static struct perf_session *session;
66 67
67struct mmap_data { 68struct mmap_data {
68 int counter; 69 int counter;
@@ -216,12 +217,12 @@ static struct perf_header_attr *get_header_attr(struct perf_event_attr *a, int n
216{ 217{
217 struct perf_header_attr *h_attr; 218 struct perf_header_attr *h_attr;
218 219
219 if (nr < header->attrs) { 220 if (nr < session->header.attrs) {
220 h_attr = header->attr[nr]; 221 h_attr = session->header.attr[nr];
221 } else { 222 } else {
222 h_attr = perf_header_attr__new(a); 223 h_attr = perf_header_attr__new(a);
223 if (h_attr != NULL) 224 if (h_attr != NULL)
224 if (perf_header__add_attr(header, h_attr) < 0) { 225 if (perf_header__add_attr(&session->header, h_attr) < 0) {
225 perf_header_attr__delete(h_attr); 226 perf_header_attr__delete(h_attr);
226 h_attr = NULL; 227 h_attr = NULL;
227 } 228 }
@@ -395,9 +396,9 @@ static void open_counters(int cpu, pid_t pid)
395 396
396static void atexit_header(void) 397static void atexit_header(void)
397{ 398{
398 header->data_size += bytes_written; 399 session->header.data_size += bytes_written;
399 400
400 perf_header__write(header, output, true); 401 perf_header__write(&session->header, output, true);
401} 402}
402 403
403static int __cmd_record(int argc, const char **argv) 404static int __cmd_record(int argc, const char **argv)
@@ -440,24 +441,24 @@ static int __cmd_record(int argc, const char **argv)
440 exit(-1); 441 exit(-1);
441 } 442 }
442 443
443 header = perf_header__new(); 444 session = perf_session__new(output_name, O_WRONLY, force);
444 if (header == NULL) { 445 if (session == NULL) {
445 pr_err("Not enough memory for reading perf file header\n"); 446 pr_err("Not enough memory for reading perf file header\n");
446 return -1; 447 return -1;
447 } 448 }
448 449
449 if (!file_new) { 450 if (!file_new) {
450 err = perf_header__read(header, output); 451 err = perf_header__read(&session->header, output);
451 if (err < 0) 452 if (err < 0)
452 return err; 453 return err;
453 } 454 }
454 455
455 if (raw_samples) { 456 if (raw_samples) {
456 perf_header__set_feat(header, HEADER_TRACE_INFO); 457 perf_header__set_feat(&session->header, HEADER_TRACE_INFO);
457 } else { 458 } else {
458 for (i = 0; i < nr_counters; i++) { 459 for (i = 0; i < nr_counters; i++) {
459 if (attrs[i].sample_type & PERF_SAMPLE_RAW) { 460 if (attrs[i].sample_type & PERF_SAMPLE_RAW) {
460 perf_header__set_feat(header, HEADER_TRACE_INFO); 461 perf_header__set_feat(&session->header, HEADER_TRACE_INFO);
461 break; 462 break;
462 } 463 }
463 } 464 }
@@ -481,7 +482,7 @@ static int __cmd_record(int argc, const char **argv)
481 } 482 }
482 483
483 if (file_new) { 484 if (file_new) {
484 err = perf_header__write(header, output, false); 485 err = perf_header__write(&session->header, output, false);
485 if (err < 0) 486 if (err < 0)
486 return err; 487 return err;
487 } 488 }
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 2b9eb3a553ed..e2ec49a9b731 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -22,6 +22,7 @@
22#include "perf.h" 22#include "perf.h"
23#include "util/debug.h" 23#include "util/debug.h"
24#include "util/header.h" 24#include "util/header.h"
25#include "util/session.h"
25 26
26#include "util/parse-options.h" 27#include "util/parse-options.h"
27#include "util/parse-events.h" 28#include "util/parse-events.h"
@@ -52,7 +53,7 @@ static int exclude_other = 1;
52 53
53static char callchain_default_opt[] = "fractal,0.5"; 54static char callchain_default_opt[] = "fractal,0.5";
54 55
55static struct perf_header *header; 56static struct perf_session *session;
56 57
57static u64 sample_type; 58static u64 sample_type;
58 59
@@ -701,7 +702,7 @@ static int process_read_event(event_t *event)
701{ 702{
702 struct perf_event_attr *attr; 703 struct perf_event_attr *attr;
703 704
704 attr = perf_header__find_attr(event->read.id, header); 705 attr = perf_header__find_attr(event->read.id, &session->header);
705 706
706 if (show_threads) { 707 if (show_threads) {
707 const char *name = attr ? __event_name(attr->type, attr->config) 708 const char *name = attr ? __event_name(attr->type, attr->config)
@@ -766,6 +767,10 @@ static int __cmd_report(void)
766 struct thread *idle; 767 struct thread *idle;
767 int ret; 768 int ret;
768 769
770 session = perf_session__new(input_name, O_RDONLY, force);
771 if (session == NULL)
772 return -ENOMEM;
773
769 idle = register_idle_thread(); 774 idle = register_idle_thread();
770 thread__comm_adjust(idle); 775 thread__comm_adjust(idle);
771 776
@@ -774,14 +779,14 @@ static int __cmd_report(void)
774 779
775 register_perf_file_handler(&file_handler); 780 register_perf_file_handler(&file_handler);
776 781
777 ret = mmap_dispatch_perf_file(&header, input_name, force, 782 ret = perf_session__process_events(session, full_paths,
778 full_paths, &event__cwdlen, &event__cwd); 783 &event__cwdlen, &event__cwd);
779 if (ret) 784 if (ret)
780 return ret; 785 goto out_delete;
781 786
782 if (dump_trace) { 787 if (dump_trace) {
783 event__print_totals(); 788 event__print_totals();
784 return 0; 789 goto out_delete;
785 } 790 }
786 791
787 if (verbose > 3) 792 if (verbose > 3)
@@ -796,7 +801,8 @@ static int __cmd_report(void)
796 801
797 if (show_threads) 802 if (show_threads)
798 perf_read_values_destroy(&show_threads_values); 803 perf_read_values_destroy(&show_threads_values);
799 804out_delete:
805 perf_session__delete(session);
800 return ret; 806 return ret;
801} 807}
802 808
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 7cca7c15b40a..65021fe1361e 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -6,6 +6,7 @@
6#include "util/symbol.h" 6#include "util/symbol.h"
7#include "util/thread.h" 7#include "util/thread.h"
8#include "util/header.h" 8#include "util/header.h"
9#include "util/session.h"
9 10
10#include "util/parse-options.h" 11#include "util/parse-options.h"
11#include "util/trace-event.h" 12#include "util/trace-event.h"
@@ -21,7 +22,6 @@
21 22
22static char const *input_name = "perf.data"; 23static char const *input_name = "perf.data";
23 24
24static struct perf_header *header;
25static u64 sample_type; 25static u64 sample_type;
26 26
27static char default_sort_order[] = "avg, max, switch, runtime"; 27static char default_sort_order[] = "avg, max, switch, runtime";
@@ -1663,11 +1663,18 @@ static struct perf_file_handler file_handler = {
1663 1663
1664static int read_events(void) 1664static int read_events(void)
1665{ 1665{
1666 int err;
1667 struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0);
1668
1669 if (session == NULL)
1670 return -ENOMEM;
1671
1666 register_idle_thread(); 1672 register_idle_thread();
1667 register_perf_file_handler(&file_handler); 1673 register_perf_file_handler(&file_handler);
1668 1674
1669 return mmap_dispatch_perf_file(&header, input_name, 0, 0, 1675 err = perf_session__process_events(session, 0, &event__cwdlen, &event__cwd);
1670 &event__cwdlen, &event__cwd); 1676 perf_session__delete(session);
1677 return err;
1671} 1678}
1672 1679
1673static void print_bad_events(void) 1680static void print_bad_events(void)
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index f472df9561ee..759dd2b35fdb 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -1059,15 +1059,17 @@ static struct perf_file_handler file_handler = {
1059 1059
1060static int __cmd_timechart(void) 1060static int __cmd_timechart(void)
1061{ 1061{
1062 struct perf_header *header; 1062 struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0);
1063 int ret; 1063 int ret;
1064 1064
1065 if (session == NULL)
1066 return -ENOMEM;
1067
1065 register_perf_file_handler(&file_handler); 1068 register_perf_file_handler(&file_handler);
1066 1069
1067 ret = mmap_dispatch_perf_file(&header, input_name, 0, 0, 1070 ret = perf_session__process_events(session, 0, &event__cwdlen, &event__cwd);
1068 &event__cwdlen, &event__cwd);
1069 if (ret) 1071 if (ret)
1070 return EXIT_FAILURE; 1072 goto out_delete;
1071 1073
1072 process_samples(); 1074 process_samples();
1073 1075
@@ -1079,8 +1081,9 @@ static int __cmd_timechart(void)
1079 1081
1080 pr_info("Written %2.1f seconds of trace to %s.\n", 1082 pr_info("Written %2.1f seconds of trace to %s.\n",
1081 (last_time - first_time) / 1000000000.0, output_name); 1083 (last_time - first_time) / 1000000000.0, output_name);
1082 1084out_delete:
1083 return EXIT_SUCCESS; 1085 perf_session__delete(session);
1086 return ret;
1084} 1087}
1085 1088
1086static const char * const timechart_usage[] = { 1089static const char * const timechart_usage[] = {
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index c2fcc34486f5..0756664666f1 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -7,6 +7,7 @@
7#include "util/header.h" 7#include "util/header.h"
8#include "util/exec_cmd.h" 8#include "util/exec_cmd.h"
9#include "util/trace-event.h" 9#include "util/trace-event.h"
10#include "util/session.h"
10 11
11static char const *script_name; 12static char const *script_name;
12static char const *generate_script_lang; 13static char const *generate_script_lang;
@@ -61,7 +62,7 @@ static int cleanup_scripting(void)
61 62
62static char const *input_name = "perf.data"; 63static char const *input_name = "perf.data";
63 64
64static struct perf_header *header; 65static struct perf_session *session;
65static u64 sample_type; 66static u64 sample_type;
66 67
67static int process_sample_event(event_t *event) 68static int process_sample_event(event_t *event)
@@ -126,11 +127,18 @@ static struct perf_file_handler file_handler = {
126 127
127static int __cmd_trace(void) 128static int __cmd_trace(void)
128{ 129{
130 int err;
131
132 session = perf_session__new(input_name, O_RDONLY, 0);
133 if (session == NULL)
134 return -ENOMEM;
135
129 register_idle_thread(); 136 register_idle_thread();
130 register_perf_file_handler(&file_handler); 137 register_perf_file_handler(&file_handler);
131 138
132 return mmap_dispatch_perf_file(&header, input_name, 139 err = perf_session__process_events(session, 0, &event__cwdlen, &event__cwd);
133 0, 0, &event__cwdlen, &event__cwd); 140 perf_session__delete(session);
141 return err;
134} 142}
135 143
136struct script_spec { 144struct script_spec {
@@ -348,11 +356,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
348 return -1; 356 return -1;
349 } 357 }
350 358
351 header = perf_header__new(); 359 perf_header__read(&session->header, input);
352 if (header == NULL)
353 return -1;
354
355 perf_header__read(header, input);
356 err = scripting_ops->generate_script("perf-trace"); 360 err = scripting_ops->generate_script("perf-trace");
357 goto out; 361 goto out;
358 } 362 }
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 454d5d55f32d..75f941bfba9e 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -59,6 +59,18 @@
59#define cpu_relax() asm volatile ("hint @pause" ::: "memory") 59#define cpu_relax() asm volatile ("hint @pause" ::: "memory")
60#endif 60#endif
61 61
62#ifdef __arm__
63#include "../../arch/arm/include/asm/unistd.h"
64/*
65 * Use the __kuser_memory_barrier helper in the CPU helper page. See
66 * arch/arm/kernel/entry-armv.S in the kernel source for details.
67 */
68#define rmb() asm volatile("mov r0, #0xffff0fff; mov lr, pc;" \
69 "sub pc, r0, #95" ::: "r0", "lr", "cc", \
70 "memory")
71#define cpu_relax() asm volatile("":::"memory")
72#endif
73
62#include <time.h> 74#include <time.h>
63#include <unistd.h> 75#include <unistd.h>
64#include <sys/types.h> 76#include <sys/types.h>
diff --git a/tools/perf/util/data_map.c b/tools/perf/util/data_map.c
index 59b65d0bd7c1..6d46dda53a29 100644
--- a/tools/perf/util/data_map.c
+++ b/tools/perf/util/data_map.c
@@ -129,23 +129,16 @@ out:
129 return err; 129 return err;
130} 130}
131 131
132int mmap_dispatch_perf_file(struct perf_header **pheader, 132int perf_session__process_events(struct perf_session *self,
133 const char *input_name, 133 int full_paths, int *cwdlen, char **cwd)
134 int force,
135 int full_paths,
136 int *cwdlen,
137 char **cwd)
138{ 134{
139 int err; 135 int err;
140 struct perf_header *header;
141 unsigned long head, shift; 136 unsigned long head, shift;
142 unsigned long offset = 0; 137 unsigned long offset = 0;
143 struct stat input_stat;
144 size_t page_size; 138 size_t page_size;
145 u64 sample_type; 139 u64 sample_type;
146 event_t *event; 140 event_t *event;
147 uint32_t size; 141 uint32_t size;
148 int input;
149 char *buf; 142 char *buf;
150 143
151 if (curr_handler == NULL) { 144 if (curr_handler == NULL) {
@@ -155,56 +148,19 @@ int mmap_dispatch_perf_file(struct perf_header **pheader,
155 148
156 page_size = getpagesize(); 149 page_size = getpagesize();
157 150
158 input = open(input_name, O_RDONLY); 151 head = self->header.data_offset;
159 if (input < 0) { 152 sample_type = perf_header__sample_type(&self->header);
160 pr_err("Failed to open file: %s", input_name);
161 if (!strcmp(input_name, "perf.data"))
162 pr_err(" (try 'perf record' first)");
163 pr_err("\n");
164 return -errno;
165 }
166
167 if (fstat(input, &input_stat) < 0) {
168 pr_err("failed to stat file");
169 err = -errno;
170 goto out_close;
171 }
172
173 err = -EACCES;
174 if (!force && input_stat.st_uid && (input_stat.st_uid != geteuid())) {
175 pr_err("file: %s not owned by current user or root\n",
176 input_name);
177 goto out_close;
178 }
179
180 if (input_stat.st_size == 0) {
181 pr_info("zero-sized file, nothing to do!\n");
182 goto done;
183 }
184
185 err = -ENOMEM;
186 header = perf_header__new();
187 if (header == NULL)
188 goto out_close;
189
190 err = perf_header__read(header, input);
191 if (err < 0)
192 goto out_delete;
193 *pheader = header;
194 head = header->data_offset;
195
196 sample_type = perf_header__sample_type(header);
197 153
198 err = -EINVAL; 154 err = -EINVAL;
199 if (curr_handler->sample_type_check && 155 if (curr_handler->sample_type_check &&
200 curr_handler->sample_type_check(sample_type) < 0) 156 curr_handler->sample_type_check(sample_type) < 0)
201 goto out_delete; 157 goto out_err;
202 158
203 if (!full_paths) { 159 if (!full_paths) {
204 if (getcwd(__cwd, sizeof(__cwd)) == NULL) { 160 if (getcwd(__cwd, sizeof(__cwd)) == NULL) {
205 pr_err("failed to get the current directory\n"); 161 pr_err("failed to get the current directory\n");
206 err = -errno; 162 err = -errno;
207 goto out_delete; 163 goto out_err;
208 } 164 }
209 *cwd = __cwd; 165 *cwd = __cwd;
210 *cwdlen = strlen(*cwd); 166 *cwdlen = strlen(*cwd);
@@ -219,11 +175,11 @@ int mmap_dispatch_perf_file(struct perf_header **pheader,
219 175
220remap: 176remap:
221 buf = mmap(NULL, page_size * mmap_window, PROT_READ, 177 buf = mmap(NULL, page_size * mmap_window, PROT_READ,
222 MAP_SHARED, input, offset); 178 MAP_SHARED, self->fd, offset);
223 if (buf == MAP_FAILED) { 179 if (buf == MAP_FAILED) {
224 pr_err("failed to mmap file\n"); 180 pr_err("failed to mmap file\n");
225 err = -errno; 181 err = -errno;
226 goto out_delete; 182 goto out_err;
227 } 183 }
228 184
229more: 185more:
@@ -273,19 +229,14 @@ more:
273 229
274 head += size; 230 head += size;
275 231
276 if (offset + head >= header->data_offset + header->data_size) 232 if (offset + head >= self->header.data_offset + self->header.data_size)
277 goto done; 233 goto done;
278 234
279 if (offset + head < (unsigned long)input_stat.st_size) 235 if (offset + head < self->size)
280 goto more; 236 goto more;
281 237
282done: 238done:
283 err = 0; 239 err = 0;
284out_close: 240out_err:
285 close(input);
286
287 return err; 241 return err;
288out_delete:
289 perf_header__delete(header);
290 goto out_close;
291} 242}
diff --git a/tools/perf/util/data_map.h b/tools/perf/util/data_map.h
index 258a87bcc4fb..98c5b823388c 100644
--- a/tools/perf/util/data_map.h
+++ b/tools/perf/util/data_map.h
@@ -3,6 +3,7 @@
3 3
4#include "event.h" 4#include "event.h"
5#include "header.h" 5#include "header.h"
6#include "session.h"
6 7
7typedef int (*event_type_handler_t)(event_t *); 8typedef int (*event_type_handler_t)(event_t *);
8 9
@@ -21,12 +22,8 @@ struct perf_file_handler {
21}; 22};
22 23
23void register_perf_file_handler(struct perf_file_handler *handler); 24void register_perf_file_handler(struct perf_file_handler *handler);
24int mmap_dispatch_perf_file(struct perf_header **pheader, 25int perf_session__process_events(struct perf_session *self,
25 const char *input_name, 26 int full_paths, int *cwdlen, char **cwd);
26 int force,
27 int full_paths,
28 int *cwdlen,
29 char **cwd);
30int perf_header__read_build_ids(int input, u64 offset, u64 file_size); 27int perf_header__read_build_ids(int input, u64 offset, u64 file_size);
31 28
32#endif 29#endif
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 4dcecafa85dc..ba0de90cd3d4 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -254,13 +254,14 @@ void thread__find_addr_location(struct thread *self, u8 cpumode,
254 struct addr_location *al, 254 struct addr_location *al,
255 symbol_filter_t filter) 255 symbol_filter_t filter)
256{ 256{
257 struct thread *thread = al->thread = self; 257 struct map_groups *mg = &self->mg;
258 258
259 al->thread = self;
259 al->addr = addr; 260 al->addr = addr;
260 261
261 if (cpumode & PERF_RECORD_MISC_KERNEL) { 262 if (cpumode & PERF_RECORD_MISC_KERNEL) {
262 al->level = 'k'; 263 al->level = 'k';
263 thread = kthread; 264 mg = kmaps;
264 } else if (cpumode & PERF_RECORD_MISC_USER) 265 } else if (cpumode & PERF_RECORD_MISC_USER)
265 al->level = '.'; 266 al->level = '.';
266 else { 267 else {
@@ -270,7 +271,7 @@ void thread__find_addr_location(struct thread *self, u8 cpumode,
270 return; 271 return;
271 } 272 }
272try_again: 273try_again:
273 al->map = thread__find_map(thread, type, al->addr); 274 al->map = map_groups__find(mg, type, al->addr);
274 if (al->map == NULL) { 275 if (al->map == NULL) {
275 /* 276 /*
276 * If this is outside of all known maps, and is a negative 277 * If this is outside of all known maps, and is a negative
@@ -281,8 +282,8 @@ try_again:
281 * "[vdso]" dso, but for now lets use the old trick of looking 282 * "[vdso]" dso, but for now lets use the old trick of looking
282 * in the whole kernel symbol list. 283 * in the whole kernel symbol list.
283 */ 284 */
284 if ((long long)al->addr < 0 && thread != kthread) { 285 if ((long long)al->addr < 0 && mg != kmaps) {
285 thread = kthread; 286 mg = kmaps;
286 goto try_again; 287 goto try_again;
287 } 288 }
288 al->sym = NULL; 289 al->sym = NULL;
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index c7a78eef8e52..51a96c2effde 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -103,10 +103,11 @@ void event__print_totals(void);
103 103
104enum map_type { 104enum map_type {
105 MAP__FUNCTION = 0, 105 MAP__FUNCTION = 0,
106 106 MAP__VARIABLE,
107 MAP__NR_TYPES,
108}; 107};
109 108
109#define MAP__NR_TYPES (MAP__VARIABLE + 1)
110
110struct map { 111struct map {
111 union { 112 union {
112 struct rb_node rb_node; 113 struct rb_node rb_node;
@@ -150,6 +151,8 @@ int map__overlap(struct map *l, struct map *r);
150size_t map__fprintf(struct map *self, FILE *fp); 151size_t map__fprintf(struct map *self, FILE *fp);
151struct symbol *map__find_symbol(struct map *self, u64 addr, 152struct symbol *map__find_symbol(struct map *self, u64 addr,
152 symbol_filter_t filter); 153 symbol_filter_t filter);
154struct symbol *map__find_symbol_by_name(struct map *self, const char *name,
155 symbol_filter_t filter);
153void map__fixup_start(struct map *self); 156void map__fixup_start(struct map *self);
154void map__fixup_end(struct map *self); 157void map__fixup_end(struct map *self);
155 158
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 59a9c0b3033e..f2e8d8715111 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -58,35 +58,19 @@ int perf_header_attr__add_id(struct perf_header_attr *self, u64 id)
58 return 0; 58 return 0;
59} 59}
60 60
61/* 61int perf_header__init(struct perf_header *self)
62 * Create new perf.data header:
63 */
64struct perf_header *perf_header__new(void)
65{ 62{
66 struct perf_header *self = zalloc(sizeof(*self)); 63 self->size = 1;
67 64 self->attr = malloc(sizeof(void *));
68 if (self != NULL) { 65 return self->attr == NULL ? -ENOMEM : 0;
69 self->size = 1;
70 self->attr = malloc(sizeof(void *));
71
72 if (self->attr == NULL) {
73 free(self);
74 self = NULL;
75 }
76 }
77
78 return self;
79} 66}
80 67
81void perf_header__delete(struct perf_header *self) 68void perf_header__exit(struct perf_header *self)
82{ 69{
83 int i; 70 int i;
84
85 for (i = 0; i < self->attrs; ++i) 71 for (i = 0; i < self->attrs; ++i)
86 perf_header_attr__delete(self->attr[i]); 72 perf_header_attr__delete(self->attr[i]);
87
88 free(self->attr); 73 free(self->attr);
89 free(self);
90} 74}
91 75
92int perf_header__add_attr(struct perf_header *self, 76int perf_header__add_attr(struct perf_header *self,
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index d1dbe2b79c42..d118d05d3abe 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -55,8 +55,8 @@ struct perf_header {
55 DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS); 55 DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
56}; 56};
57 57
58struct perf_header *perf_header__new(void); 58int perf_header__init(struct perf_header *self);
59void perf_header__delete(struct perf_header *self); 59void perf_header__exit(struct perf_header *self);
60 60
61int perf_header__read(struct perf_header *self, int fd); 61int perf_header__read(struct perf_header *self, int fd);
62int perf_header__write(struct perf_header *self, int fd, bool at_exit); 62int perf_header__write(struct perf_header *self, int fd, bool at_exit);
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 69f94fe9db20..76bdca640a9b 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -104,43 +104,64 @@ void map__fixup_end(struct map *self)
104 104
105#define DSO__DELETED "(deleted)" 105#define DSO__DELETED "(deleted)"
106 106
107struct symbol *map__find_symbol(struct map *self, u64 addr, 107static int map__load(struct map *self, symbol_filter_t filter)
108 symbol_filter_t filter)
109{ 108{
110 if (!dso__loaded(self->dso, self->type)) { 109 const char *name = self->dso->long_name;
111 int nr = dso__load(self->dso, self, filter); 110 int nr = dso__load(self->dso, self, filter);
112 111
113 if (nr < 0) { 112 if (nr < 0) {
114 if (self->dso->has_build_id) { 113 if (self->dso->has_build_id) {
115 char sbuild_id[BUILD_ID_SIZE * 2 + 1]; 114 char sbuild_id[BUILD_ID_SIZE * 2 + 1];
116 115
117 build_id__sprintf(self->dso->build_id, 116 build_id__sprintf(self->dso->build_id,
118 sizeof(self->dso->build_id), 117 sizeof(self->dso->build_id),
119 sbuild_id); 118 sbuild_id);
120 pr_warning("%s with build id %s not found", 119 pr_warning("%s with build id %s not found",
121 self->dso->long_name, sbuild_id); 120 name, sbuild_id);
122 } else 121 } else
123 pr_warning("Failed to open %s", 122 pr_warning("Failed to open %s", name);
124 self->dso->long_name); 123
125 pr_warning(", continuing without symbols\n"); 124 pr_warning(", continuing without symbols\n");
126 return NULL; 125 return -1;
127 } else if (nr == 0) { 126 } else if (nr == 0) {
128 const char *name = self->dso->long_name; 127 const size_t len = strlen(name);
129 const size_t len = strlen(name); 128 const size_t real_len = len - sizeof(DSO__DELETED);
130 const size_t real_len = len - sizeof(DSO__DELETED); 129
131 130 if (len > sizeof(DSO__DELETED) &&
132 if (len > sizeof(DSO__DELETED) && 131 strcmp(name + real_len + 1, DSO__DELETED) == 0) {
133 strcmp(name + real_len + 1, DSO__DELETED) == 0) { 132 pr_warning("%.*s was updated, restart the long "
134 pr_warning("%.*s was updated, restart the long running apps that use it!\n", 133 "running apps that use it!\n",
135 (int)real_len, name); 134 (int)real_len, name);
136 } else { 135 } else {
137 pr_warning("no symbols found in %s, maybe install a debug package?\n", name); 136 pr_warning("no symbols found in %s, maybe install "
138 } 137 "a debug package?\n", name);
139 return NULL;
140 } 138 }
139
140 return -1;
141 } 141 }
142 142
143 return self->dso->find_symbol(self->dso, self->type, addr); 143 return 0;
144}
145
146struct symbol *map__find_symbol(struct map *self, u64 addr,
147 symbol_filter_t filter)
148{
149 if (!dso__loaded(self->dso, self->type) && map__load(self, filter) < 0)
150 return NULL;
151
152 return dso__find_symbol(self->dso, self->type, addr);
153}
154
155struct symbol *map__find_symbol_by_name(struct map *self, const char *name,
156 symbol_filter_t filter)
157{
158 if (!dso__loaded(self->dso, self->type) && map__load(self, filter) < 0)
159 return NULL;
160
161 if (!dso__sorted_by_name(self->dso, self->type))
162 dso__sort_by_name(self->dso, self->type);
163
164 return dso__find_symbol_by_name(self->dso, self->type, name);
144} 165}
145 166
146struct map *map__clone(struct map *self) 167struct map *map__clone(struct map *self)
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
new file mode 100644
index 000000000000..707ce1cb1621
--- /dev/null
+++ b/tools/perf/util/session.c
@@ -0,0 +1,80 @@
1#include <linux/kernel.h>
2
3#include <unistd.h>
4#include <sys/types.h>
5
6#include "session.h"
7#include "util.h"
8
9static int perf_session__open(struct perf_session *self, bool force)
10{
11 struct stat input_stat;
12
13 self->fd = open(self->filename, O_RDONLY);
14 if (self->fd < 0) {
15 pr_err("failed to open file: %s", self->filename);
16 if (!strcmp(self->filename, "perf.data"))
17 pr_err(" (try 'perf record' first)");
18 pr_err("\n");
19 return -errno;
20 }
21
22 if (fstat(self->fd, &input_stat) < 0)
23 goto out_close;
24
25 if (!force && input_stat.st_uid && (input_stat.st_uid != geteuid())) {
26 pr_err("file %s not owned by current user or root\n",
27 self->filename);
28 goto out_close;
29 }
30
31 if (!input_stat.st_size) {
32 pr_info("zero-sized file (%s), nothing to do!\n",
33 self->filename);
34 goto out_close;
35 }
36
37 if (perf_header__read(&self->header, self->fd) < 0) {
38 pr_err("incompatible file format");
39 goto out_close;
40 }
41
42 self->size = input_stat.st_size;
43 return 0;
44
45out_close:
46 close(self->fd);
47 self->fd = -1;
48 return -1;
49}
50
51struct perf_session *perf_session__new(const char *filename, int mode, bool force)
52{
53 size_t len = strlen(filename) + 1;
54 struct perf_session *self = zalloc(sizeof(*self) + len);
55
56 if (self == NULL)
57 goto out;
58
59 if (perf_header__init(&self->header) < 0)
60 goto out_delete;
61
62 memcpy(self->filename, filename, len);
63
64 if (mode == O_RDONLY && perf_session__open(self, force) < 0) {
65 perf_session__delete(self);
66 self = NULL;
67 }
68out:
69 return self;
70out_delete:
71 free(self);
72 return NULL;
73}
74
75void perf_session__delete(struct perf_session *self)
76{
77 perf_header__exit(&self->header);
78 close(self->fd);
79 free(self);
80}
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
new file mode 100644
index 000000000000..f3699c8c8ed4
--- /dev/null
+++ b/tools/perf/util/session.h
@@ -0,0 +1,16 @@
1#ifndef __PERF_SESSION_H
2#define __PERF_SESSION_H
3
4#include "header.h"
5
6struct perf_session {
7 struct perf_header header;
8 unsigned long size;
9 int fd;
10 char filename[0];
11};
12
13struct perf_session *perf_session__new(const char *filename, int mode, bool force);
14void perf_session__delete(struct perf_session *self);
15
16#endif /* __PERF_SESSION_H */
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index e7508ad3450f..d3d9fed74f1d 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -29,11 +29,9 @@ enum dso_origin {
29}; 29};
30 30
31static void dsos__add(struct list_head *head, struct dso *dso); 31static void dsos__add(struct list_head *head, struct dso *dso);
32static struct map *thread__find_map_by_name(struct thread *self, char *name);
33static struct map *map__new2(u64 start, struct dso *dso, enum map_type type); 32static struct map *map__new2(u64 start, struct dso *dso, enum map_type type);
34struct symbol *dso__find_symbol(struct dso *self, enum map_type type, u64 addr);
35static int dso__load_kernel_sym(struct dso *self, struct map *map, 33static int dso__load_kernel_sym(struct dso *self, struct map *map,
36 struct thread *thread, symbol_filter_t filter); 34 struct map_groups *mg, symbol_filter_t filter);
37unsigned int symbol__priv_size; 35unsigned int symbol__priv_size;
38static int vmlinux_path__nr_entries; 36static int vmlinux_path__nr_entries;
39static char **vmlinux_path; 37static char **vmlinux_path;
@@ -43,19 +41,41 @@ static struct symbol_conf symbol_conf__defaults = {
43 .try_vmlinux_path = true, 41 .try_vmlinux_path = true,
44}; 42};
45 43
46static struct thread kthread_mem; 44static struct map_groups kmaps_mem;
47struct thread *kthread = &kthread_mem; 45struct map_groups *kmaps = &kmaps_mem;
48 46
49bool dso__loaded(const struct dso *self, enum map_type type) 47bool dso__loaded(const struct dso *self, enum map_type type)
50{ 48{
51 return self->loaded & (1 << type); 49 return self->loaded & (1 << type);
52} 50}
53 51
52bool dso__sorted_by_name(const struct dso *self, enum map_type type)
53{
54 return self->sorted_by_name & (1 << type);
55}
56
54static void dso__set_loaded(struct dso *self, enum map_type type) 57static void dso__set_loaded(struct dso *self, enum map_type type)
55{ 58{
56 self->loaded |= (1 << type); 59 self->loaded |= (1 << type);
57} 60}
58 61
62static void dso__set_sorted_by_name(struct dso *self, enum map_type type)
63{
64 self->sorted_by_name |= (1 << type);
65}
66
67static bool symbol_type__is_a(char symbol_type, enum map_type map_type)
68{
69 switch (map_type) {
70 case MAP__FUNCTION:
71 return symbol_type == 'T' || symbol_type == 'W';
72 case MAP__VARIABLE:
73 return symbol_type == 'D' || symbol_type == 'd';
74 default:
75 return false;
76 }
77}
78
59static void symbols__fixup_end(struct rb_root *self) 79static void symbols__fixup_end(struct rb_root *self)
60{ 80{
61 struct rb_node *nd, *prevnd = rb_first(self); 81 struct rb_node *nd, *prevnd = rb_first(self);
@@ -79,7 +99,7 @@ static void symbols__fixup_end(struct rb_root *self)
79 curr->end = roundup(curr->start, 4096); 99 curr->end = roundup(curr->start, 4096);
80} 100}
81 101
82static void __thread__fixup_maps_end(struct thread *self, enum map_type type) 102static void __map_groups__fixup_end(struct map_groups *self, enum map_type type)
83{ 103{
84 struct map *prev, *curr; 104 struct map *prev, *curr;
85 struct rb_node *nd, *prevnd = rb_first(&self->maps[type]); 105 struct rb_node *nd, *prevnd = rb_first(&self->maps[type]);
@@ -102,11 +122,11 @@ static void __thread__fixup_maps_end(struct thread *self, enum map_type type)
102 curr->end = ~0UL; 122 curr->end = ~0UL;
103} 123}
104 124
105static void thread__fixup_maps_end(struct thread *self) 125static void map_groups__fixup_end(struct map_groups *self)
106{ 126{
107 int i; 127 int i;
108 for (i = 0; i < MAP__NR_TYPES; ++i) 128 for (i = 0; i < MAP__NR_TYPES; ++i)
109 __thread__fixup_maps_end(self, i); 129 __map_groups__fixup_end(self, i);
110} 130}
111 131
112static struct symbol *symbol__new(u64 start, u64 len, const char *name) 132static struct symbol *symbol__new(u64 start, u64 len, const char *name)
@@ -164,11 +184,11 @@ struct dso *dso__new(const char *name)
164 dso__set_long_name(self, self->name); 184 dso__set_long_name(self, self->name);
165 self->short_name = self->name; 185 self->short_name = self->name;
166 for (i = 0; i < MAP__NR_TYPES; ++i) 186 for (i = 0; i < MAP__NR_TYPES; ++i)
167 self->symbols[i] = RB_ROOT; 187 self->symbols[i] = self->symbol_names[i] = RB_ROOT;
168 self->find_symbol = dso__find_symbol;
169 self->slen_calculated = 0; 188 self->slen_calculated = 0;
170 self->origin = DSO__ORIG_NOT_FOUND; 189 self->origin = DSO__ORIG_NOT_FOUND;
171 self->loaded = 0; 190 self->loaded = 0;
191 self->sorted_by_name = 0;
172 self->has_build_id = 0; 192 self->has_build_id = 0;
173 } 193 }
174 194
@@ -246,11 +266,85 @@ static struct symbol *symbols__find(struct rb_root *self, u64 ip)
246 return NULL; 266 return NULL;
247} 267}
248 268
249struct symbol *dso__find_symbol(struct dso *self, enum map_type type, u64 addr) 269struct symbol_name_rb_node {
270 struct rb_node rb_node;
271 struct symbol sym;
272};
273
274static void symbols__insert_by_name(struct rb_root *self, struct symbol *sym)
275{
276 struct rb_node **p = &self->rb_node;
277 struct rb_node *parent = NULL;
278 struct symbol_name_rb_node *symn = ((void *)sym) - sizeof(*parent), *s;
279
280 while (*p != NULL) {
281 parent = *p;
282 s = rb_entry(parent, struct symbol_name_rb_node, rb_node);
283 if (strcmp(sym->name, s->sym.name) < 0)
284 p = &(*p)->rb_left;
285 else
286 p = &(*p)->rb_right;
287 }
288 rb_link_node(&symn->rb_node, parent, p);
289 rb_insert_color(&symn->rb_node, self);
290}
291
292static void symbols__sort_by_name(struct rb_root *self, struct rb_root *source)
293{
294 struct rb_node *nd;
295
296 for (nd = rb_first(source); nd; nd = rb_next(nd)) {
297 struct symbol *pos = rb_entry(nd, struct symbol, rb_node);
298 symbols__insert_by_name(self, pos);
299 }
300}
301
302static struct symbol *symbols__find_by_name(struct rb_root *self, const char *name)
303{
304 struct rb_node *n;
305
306 if (self == NULL)
307 return NULL;
308
309 n = self->rb_node;
310
311 while (n) {
312 struct symbol_name_rb_node *s;
313 int cmp;
314
315 s = rb_entry(n, struct symbol_name_rb_node, rb_node);
316 cmp = strcmp(name, s->sym.name);
317
318 if (cmp < 0)
319 n = n->rb_left;
320 else if (cmp > 0)
321 n = n->rb_right;
322 else
323 return &s->sym;
324 }
325
326 return NULL;
327}
328
329struct symbol *dso__find_symbol(struct dso *self,
330 enum map_type type, u64 addr)
250{ 331{
251 return symbols__find(&self->symbols[type], addr); 332 return symbols__find(&self->symbols[type], addr);
252} 333}
253 334
335struct symbol *dso__find_symbol_by_name(struct dso *self, enum map_type type,
336 const char *name)
337{
338 return symbols__find_by_name(&self->symbol_names[type], name);
339}
340
341void dso__sort_by_name(struct dso *self, enum map_type type)
342{
343 dso__set_sorted_by_name(self, type);
344 return symbols__sort_by_name(&self->symbol_names[type],
345 &self->symbols[type]);
346}
347
254int build_id__sprintf(u8 *self, int len, char *bf) 348int build_id__sprintf(u8 *self, int len, char *bf)
255{ 349{
256 char *bid = bf; 350 char *bid = bf;
@@ -327,10 +421,7 @@ static int dso__load_all_kallsyms(struct dso *self, struct map *map)
327 continue; 421 continue;
328 422
329 symbol_type = toupper(line[len]); 423 symbol_type = toupper(line[len]);
330 /* 424 if (!symbol_type__is_a(symbol_type, map->type))
331 * We're interested only in code ('T'ext)
332 */
333 if (symbol_type != 'T' && symbol_type != 'W')
334 continue; 425 continue;
335 426
336 symbol_name = line + len + 2; 427 symbol_name = line + len + 2;
@@ -364,8 +455,8 @@ out_failure:
364 * kernel range is broken in several maps, named [kernel].N, as we don't have 455 * kernel range is broken in several maps, named [kernel].N, as we don't have
365 * the original ELF section names vmlinux have. 456 * the original ELF section names vmlinux have.
366 */ 457 */
367static int dso__split_kallsyms(struct dso *self, struct map *map, struct thread *thread, 458static int dso__split_kallsyms(struct dso *self, struct map *map,
368 symbol_filter_t filter) 459 struct map_groups *mg, symbol_filter_t filter)
369{ 460{
370 struct map *curr_map = map; 461 struct map *curr_map = map;
371 struct symbol *pos; 462 struct symbol *pos;
@@ -382,13 +473,13 @@ static int dso__split_kallsyms(struct dso *self, struct map *map, struct thread
382 473
383 module = strchr(pos->name, '\t'); 474 module = strchr(pos->name, '\t');
384 if (module) { 475 if (module) {
385 if (!thread->use_modules) 476 if (!mg->use_modules)
386 goto discard_symbol; 477 goto discard_symbol;
387 478
388 *module++ = '\0'; 479 *module++ = '\0';
389 480
390 if (strcmp(self->name, module)) { 481 if (strcmp(self->name, module)) {
391 curr_map = thread__find_map_by_name(thread, module); 482 curr_map = map_groups__find_by_name(mg, map->type, module);
392 if (curr_map == NULL) { 483 if (curr_map == NULL) {
393 pr_debug("/proc/{kallsyms,modules} " 484 pr_debug("/proc/{kallsyms,modules} "
394 "inconsistency!\n"); 485 "inconsistency!\n");
@@ -419,7 +510,7 @@ static int dso__split_kallsyms(struct dso *self, struct map *map, struct thread
419 } 510 }
420 511
421 curr_map->map_ip = curr_map->unmap_ip = identity__map_ip; 512 curr_map->map_ip = curr_map->unmap_ip = identity__map_ip;
422 __thread__insert_map(thread, curr_map); 513 map_groups__insert(mg, curr_map);
423 ++kernel_range; 514 ++kernel_range;
424 } 515 }
425 516
@@ -440,7 +531,7 @@ discard_symbol: rb_erase(&pos->rb_node, root);
440 531
441 532
442static int dso__load_kallsyms(struct dso *self, struct map *map, 533static int dso__load_kallsyms(struct dso *self, struct map *map,
443 struct thread *thread, symbol_filter_t filter) 534 struct map_groups *mg, symbol_filter_t filter)
444{ 535{
445 if (dso__load_all_kallsyms(self, map) < 0) 536 if (dso__load_all_kallsyms(self, map) < 0)
446 return -1; 537 return -1;
@@ -448,13 +539,13 @@ static int dso__load_kallsyms(struct dso *self, struct map *map,
448 symbols__fixup_end(&self->symbols[map->type]); 539 symbols__fixup_end(&self->symbols[map->type]);
449 self->origin = DSO__ORIG_KERNEL; 540 self->origin = DSO__ORIG_KERNEL;
450 541
451 return dso__split_kallsyms(self, map, thread, filter); 542 return dso__split_kallsyms(self, map, mg, filter);
452} 543}
453 544
454size_t kernel_maps__fprintf(FILE *fp) 545size_t kernel_maps__fprintf(FILE *fp)
455{ 546{
456 size_t printed = fprintf(fp, "Kernel maps:\n"); 547 size_t printed = fprintf(fp, "Kernel maps:\n");
457 printed += thread__fprintf_maps(kthread, fp); 548 printed += map_groups__fprintf_maps(kmaps, fp);
458 return printed + fprintf(fp, "END kernel maps\n"); 549 return printed + fprintf(fp, "END kernel maps\n");
459} 550}
460 551
@@ -544,6 +635,13 @@ static inline int elf_sym__is_function(const GElf_Sym *sym)
544 sym->st_shndx != SHN_UNDEF; 635 sym->st_shndx != SHN_UNDEF;
545} 636}
546 637
638static inline bool elf_sym__is_object(const GElf_Sym *sym)
639{
640 return elf_sym__type(sym) == STT_OBJECT &&
641 sym->st_name != 0 &&
642 sym->st_shndx != SHN_UNDEF;
643}
644
547static inline int elf_sym__is_label(const GElf_Sym *sym) 645static inline int elf_sym__is_label(const GElf_Sym *sym)
548{ 646{
549 return elf_sym__type(sym) == STT_NOTYPE && 647 return elf_sym__type(sym) == STT_NOTYPE &&
@@ -564,6 +662,12 @@ static inline int elf_sec__is_text(const GElf_Shdr *shdr,
564 return strstr(elf_sec__name(shdr, secstrs), "text") != NULL; 662 return strstr(elf_sec__name(shdr, secstrs), "text") != NULL;
565} 663}
566 664
665static inline bool elf_sec__is_data(const GElf_Shdr *shdr,
666 const Elf_Data *secstrs)
667{
668 return strstr(elf_sec__name(shdr, secstrs), "data") != NULL;
669}
670
567static inline const char *elf_sym__name(const GElf_Sym *sym, 671static inline const char *elf_sym__name(const GElf_Sym *sym,
568 const Elf_Data *symstrs) 672 const Elf_Data *symstrs)
569{ 673{
@@ -744,8 +848,32 @@ out:
744 return 0; 848 return 0;
745} 849}
746 850
851static bool elf_sym__is_a(GElf_Sym *self, enum map_type type)
852{
853 switch (type) {
854 case MAP__FUNCTION:
855 return elf_sym__is_function(self);
856 case MAP__VARIABLE:
857 return elf_sym__is_object(self);
858 default:
859 return false;
860 }
861}
862
863static bool elf_sec__is_a(GElf_Shdr *self, Elf_Data *secstrs, enum map_type type)
864{
865 switch (type) {
866 case MAP__FUNCTION:
867 return elf_sec__is_text(self, secstrs);
868 case MAP__VARIABLE:
869 return elf_sec__is_data(self, secstrs);
870 default:
871 return false;
872 }
873}
874
747static int dso__load_sym(struct dso *self, struct map *map, 875static int dso__load_sym(struct dso *self, struct map *map,
748 struct thread *thread, const char *name, int fd, 876 struct map_groups *mg, const char *name, int fd,
749 symbol_filter_t filter, int kernel, int kmodule) 877 symbol_filter_t filter, int kernel, int kmodule)
750{ 878{
751 struct map *curr_map = map; 879 struct map *curr_map = map;
@@ -818,7 +946,7 @@ static int dso__load_sym(struct dso *self, struct map *map,
818 int is_label = elf_sym__is_label(&sym); 946 int is_label = elf_sym__is_label(&sym);
819 const char *section_name; 947 const char *section_name;
820 948
821 if (!is_label && !elf_sym__is_function(&sym)) 949 if (!is_label && !elf_sym__is_a(&sym, map->type))
822 continue; 950 continue;
823 951
824 sec = elf_getscn(elf, sym.st_shndx); 952 sec = elf_getscn(elf, sym.st_shndx);
@@ -827,7 +955,7 @@ static int dso__load_sym(struct dso *self, struct map *map,
827 955
828 gelf_getshdr(sec, &shdr); 956 gelf_getshdr(sec, &shdr);
829 957
830 if (is_label && !elf_sec__is_text(&shdr, secstrs)) 958 if (is_label && !elf_sec__is_a(&shdr, secstrs, map->type))
831 continue; 959 continue;
832 960
833 elf_name = elf_sym__name(&sym, symstrs); 961 elf_name = elf_sym__name(&sym, symstrs);
@@ -849,7 +977,7 @@ static int dso__load_sym(struct dso *self, struct map *map,
849 snprintf(dso_name, sizeof(dso_name), 977 snprintf(dso_name, sizeof(dso_name),
850 "%s%s", self->short_name, section_name); 978 "%s%s", self->short_name, section_name);
851 979
852 curr_map = thread__find_map_by_name(thread, dso_name); 980 curr_map = map_groups__find_by_name(mg, map->type, dso_name);
853 if (curr_map == NULL) { 981 if (curr_map == NULL) {
854 u64 start = sym.st_value; 982 u64 start = sym.st_value;
855 983
@@ -868,7 +996,7 @@ static int dso__load_sym(struct dso *self, struct map *map,
868 curr_map->map_ip = identity__map_ip; 996 curr_map->map_ip = identity__map_ip;
869 curr_map->unmap_ip = identity__map_ip; 997 curr_map->unmap_ip = identity__map_ip;
870 curr_dso->origin = DSO__ORIG_KERNEL; 998 curr_dso->origin = DSO__ORIG_KERNEL;
871 __thread__insert_map(kthread, curr_map); 999 map_groups__insert(kmaps, curr_map);
872 dsos__add(&dsos__kernel, curr_dso); 1000 dsos__add(&dsos__kernel, curr_dso);
873 } else 1001 } else
874 curr_dso = curr_map->dso; 1002 curr_dso = curr_map->dso;
@@ -1094,7 +1222,7 @@ int dso__load(struct dso *self, struct map *map, symbol_filter_t filter)
1094 dso__set_loaded(self, map->type); 1222 dso__set_loaded(self, map->type);
1095 1223
1096 if (self->kernel) 1224 if (self->kernel)
1097 return dso__load_kernel_sym(self, map, kthread, filter); 1225 return dso__load_kernel_sym(self, map, kmaps, filter);
1098 1226
1099 name = malloc(size); 1227 name = malloc(size);
1100 if (!name) 1228 if (!name)
@@ -1180,11 +1308,12 @@ out:
1180 return ret; 1308 return ret;
1181} 1309}
1182 1310
1183static struct map *thread__find_map_by_name(struct thread *self, char *name) 1311struct map *map_groups__find_by_name(struct map_groups *self,
1312 enum map_type type, const char *name)
1184{ 1313{
1185 struct rb_node *nd; 1314 struct rb_node *nd;
1186 1315
1187 for (nd = rb_first(&self->maps[MAP__FUNCTION]); nd; nd = rb_next(nd)) { 1316 for (nd = rb_first(&self->maps[type]); nd; nd = rb_next(nd)) {
1188 struct map *map = rb_entry(nd, struct map, rb_node); 1317 struct map *map = rb_entry(nd, struct map, rb_node);
1189 1318
1190 if (map->dso && strcmp(map->dso->name, name) == 0) 1319 if (map->dso && strcmp(map->dso->name, name) == 0)
@@ -1228,7 +1357,7 @@ static int dsos__set_modules_path_dir(char *dirname)
1228 (int)(dot - dent->d_name), dent->d_name); 1357 (int)(dot - dent->d_name), dent->d_name);
1229 1358
1230 strxfrchar(dso_name, '-', '_'); 1359 strxfrchar(dso_name, '-', '_');
1231 map = thread__find_map_by_name(kthread, dso_name); 1360 map = map_groups__find_by_name(kmaps, MAP__FUNCTION, dso_name);
1232 if (map == NULL) 1361 if (map == NULL)
1233 continue; 1362 continue;
1234 1363
@@ -1281,7 +1410,7 @@ static struct map *map__new2(u64 start, struct dso *dso, enum map_type type)
1281 return self; 1410 return self;
1282} 1411}
1283 1412
1284static int thread__create_module_maps(struct thread *self) 1413static int map_groups__create_module_maps(struct map_groups *self)
1285{ 1414{
1286 char *line = NULL; 1415 char *line = NULL;
1287 size_t n; 1416 size_t n;
@@ -1338,7 +1467,7 @@ static int thread__create_module_maps(struct thread *self)
1338 dso->has_build_id = true; 1467 dso->has_build_id = true;
1339 1468
1340 dso->origin = DSO__ORIG_KMODULE; 1469 dso->origin = DSO__ORIG_KMODULE;
1341 __thread__insert_map(self, map); 1470 map_groups__insert(self, map);
1342 dsos__add(&dsos__kernel, dso); 1471 dsos__add(&dsos__kernel, dso);
1343 } 1472 }
1344 1473
@@ -1353,7 +1482,8 @@ out_failure:
1353 return -1; 1482 return -1;
1354} 1483}
1355 1484
1356static int dso__load_vmlinux(struct dso *self, struct map *map, struct thread *thread, 1485static int dso__load_vmlinux(struct dso *self, struct map *map,
1486 struct map_groups *mg,
1357 const char *vmlinux, symbol_filter_t filter) 1487 const char *vmlinux, symbol_filter_t filter)
1358{ 1488{
1359 int err = -1, fd; 1489 int err = -1, fd;
@@ -1387,14 +1517,14 @@ static int dso__load_vmlinux(struct dso *self, struct map *map, struct thread *t
1387 return -1; 1517 return -1;
1388 1518
1389 dso__set_loaded(self, map->type); 1519 dso__set_loaded(self, map->type);
1390 err = dso__load_sym(self, map, thread, self->long_name, fd, filter, 1, 0); 1520 err = dso__load_sym(self, map, mg, self->long_name, fd, filter, 1, 0);
1391 close(fd); 1521 close(fd);
1392 1522
1393 return err; 1523 return err;
1394} 1524}
1395 1525
1396static int dso__load_kernel_sym(struct dso *self, struct map *map, 1526static int dso__load_kernel_sym(struct dso *self, struct map *map,
1397 struct thread *thread, symbol_filter_t filter) 1527 struct map_groups *mg, symbol_filter_t filter)
1398{ 1528{
1399 int err; 1529 int err;
1400 bool is_kallsyms; 1530 bool is_kallsyms;
@@ -1404,7 +1534,7 @@ static int dso__load_kernel_sym(struct dso *self, struct map *map,
1404 pr_debug("Looking at the vmlinux_path (%d entries long)\n", 1534 pr_debug("Looking at the vmlinux_path (%d entries long)\n",
1405 vmlinux_path__nr_entries); 1535 vmlinux_path__nr_entries);
1406 for (i = 0; i < vmlinux_path__nr_entries; ++i) { 1536 for (i = 0; i < vmlinux_path__nr_entries; ++i) {
1407 err = dso__load_vmlinux(self, map, thread, 1537 err = dso__load_vmlinux(self, map, mg,
1408 vmlinux_path[i], filter); 1538 vmlinux_path[i], filter);
1409 if (err > 0) { 1539 if (err > 0) {
1410 pr_debug("Using %s for symbols\n", 1540 pr_debug("Using %s for symbols\n",
@@ -1420,12 +1550,12 @@ static int dso__load_kernel_sym(struct dso *self, struct map *map,
1420 if (is_kallsyms) 1550 if (is_kallsyms)
1421 goto do_kallsyms; 1551 goto do_kallsyms;
1422 1552
1423 err = dso__load_vmlinux(self, map, thread, self->long_name, filter); 1553 err = dso__load_vmlinux(self, map, mg, self->long_name, filter);
1424 if (err <= 0) { 1554 if (err <= 0) {
1425 pr_info("The file %s cannot be used, " 1555 pr_info("The file %s cannot be used, "
1426 "trying to use /proc/kallsyms...", self->long_name); 1556 "trying to use /proc/kallsyms...", self->long_name);
1427do_kallsyms: 1557do_kallsyms:
1428 err = dso__load_kallsyms(self, map, thread, filter); 1558 err = dso__load_kallsyms(self, map, mg, filter);
1429 if (err > 0 && !is_kallsyms) 1559 if (err > 0 && !is_kallsyms)
1430 dso__set_long_name(self, strdup("[kernel.kallsyms]")); 1560 dso__set_long_name(self, strdup("[kernel.kallsyms]"));
1431 } 1561 }
@@ -1508,42 +1638,59 @@ size_t dsos__fprintf_buildid(FILE *fp)
1508 __dsos__fprintf_buildid(&dsos__user, fp)); 1638 __dsos__fprintf_buildid(&dsos__user, fp));
1509} 1639}
1510 1640
1511static int thread__create_kernel_map(struct thread *self, const char *vmlinux) 1641static struct dso *dsos__create_kernel( const char *vmlinux)
1512{ 1642{
1513 struct map *kmap;
1514 struct dso *kernel = dso__new(vmlinux ?: "[kernel.kallsyms]"); 1643 struct dso *kernel = dso__new(vmlinux ?: "[kernel.kallsyms]");
1515 1644
1516 if (kernel == NULL) 1645 if (kernel == NULL)
1517 return -1; 1646 return NULL;
1518
1519 kmap = map__new2(0, kernel, MAP__FUNCTION);
1520 if (kmap == NULL)
1521 goto out_delete_kernel_dso;
1522 1647
1523 kmap->map_ip = kmap->unmap_ip = identity__map_ip;
1524 kernel->short_name = "[kernel]"; 1648 kernel->short_name = "[kernel]";
1525 kernel->kernel = 1; 1649 kernel->kernel = 1;
1526 1650
1527 vdso = dso__new("[vdso]"); 1651 vdso = dso__new("[vdso]");
1528 if (vdso == NULL) 1652 if (vdso == NULL)
1529 goto out_delete_kernel_map; 1653 goto out_delete_kernel_dso;
1530 dso__set_loaded(vdso, MAP__FUNCTION); 1654 dso__set_loaded(vdso, MAP__FUNCTION);
1531 1655
1532 if (sysfs__read_build_id("/sys/kernel/notes", kernel->build_id, 1656 if (sysfs__read_build_id("/sys/kernel/notes", kernel->build_id,
1533 sizeof(kernel->build_id)) == 0) 1657 sizeof(kernel->build_id)) == 0)
1534 kernel->has_build_id = true; 1658 kernel->has_build_id = true;
1535 1659
1536 __thread__insert_map(self, kmap);
1537 dsos__add(&dsos__kernel, kernel); 1660 dsos__add(&dsos__kernel, kernel);
1538 dsos__add(&dsos__user, vdso); 1661 dsos__add(&dsos__user, vdso);
1539 1662
1540 return 0; 1663 return kernel;
1541 1664
1542out_delete_kernel_map:
1543 map__delete(kmap);
1544out_delete_kernel_dso: 1665out_delete_kernel_dso:
1545 dso__delete(kernel); 1666 dso__delete(kernel);
1546 return -1; 1667 return NULL;
1668}
1669
1670static int map_groups__create_kernel_maps(struct map_groups *self, const char *vmlinux)
1671{
1672 struct map *functions, *variables;
1673 struct dso *kernel = dsos__create_kernel(vmlinux);
1674
1675 if (kernel == NULL)
1676 return -1;
1677
1678 functions = map__new2(0, kernel, MAP__FUNCTION);
1679 if (functions == NULL)
1680 return -1;
1681
1682 variables = map__new2(0, kernel, MAP__VARIABLE);
1683 if (variables == NULL) {
1684 map__delete(functions);
1685 return -1;
1686 }
1687
1688 functions->map_ip = functions->unmap_ip =
1689 variables->map_ip = variables->unmap_ip = identity__map_ip;
1690 map_groups__insert(self, functions);
1691 map_groups__insert(self, variables);
1692
1693 return 0;
1547} 1694}
1548 1695
1549static void vmlinux_path__exit(void) 1696static void vmlinux_path__exit(void)
@@ -1607,23 +1754,26 @@ int symbol__init(struct symbol_conf *conf)
1607 1754
1608 elf_version(EV_CURRENT); 1755 elf_version(EV_CURRENT);
1609 symbol__priv_size = pconf->priv_size; 1756 symbol__priv_size = pconf->priv_size;
1610 thread__init(kthread, 0); 1757 if (pconf->sort_by_name)
1758 symbol__priv_size += (sizeof(struct symbol_name_rb_node) -
1759 sizeof(struct symbol));
1760 map_groups__init(kmaps);
1611 1761
1612 if (pconf->try_vmlinux_path && vmlinux_path__init() < 0) 1762 if (pconf->try_vmlinux_path && vmlinux_path__init() < 0)
1613 return -1; 1763 return -1;
1614 1764
1615 if (thread__create_kernel_map(kthread, pconf->vmlinux_name) < 0) { 1765 if (map_groups__create_kernel_maps(kmaps, pconf->vmlinux_name) < 0) {
1616 vmlinux_path__exit(); 1766 vmlinux_path__exit();
1617 return -1; 1767 return -1;
1618 } 1768 }
1619 1769
1620 kthread->use_modules = pconf->use_modules; 1770 kmaps->use_modules = pconf->use_modules;
1621 if (pconf->use_modules && thread__create_module_maps(kthread) < 0) 1771 if (pconf->use_modules && map_groups__create_module_maps(kmaps) < 0)
1622 pr_debug("Failed to load list of modules in use, " 1772 pr_debug("Failed to load list of modules in use, "
1623 "continuing...\n"); 1773 "continuing...\n");
1624 /* 1774 /*
1625 * Now that we have all the maps created, just set the ->end of them: 1775 * Now that we have all the maps created, just set the ->end of them:
1626 */ 1776 */
1627 thread__fixup_maps_end(kthread); 1777 map_groups__fixup_end(kmaps);
1628 return 0; 1778 return 0;
1629} 1779}
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 17003efa0b39..cf99f88adf39 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -52,7 +52,8 @@ struct symbol {
52struct symbol_conf { 52struct symbol_conf {
53 unsigned short priv_size; 53 unsigned short priv_size;
54 bool try_vmlinux_path, 54 bool try_vmlinux_path,
55 use_modules; 55 use_modules,
56 sort_by_name;
56 const char *vmlinux_name; 57 const char *vmlinux_name;
57}; 58};
58 59
@@ -74,13 +75,13 @@ struct addr_location {
74struct dso { 75struct dso {
75 struct list_head node; 76 struct list_head node;
76 struct rb_root symbols[MAP__NR_TYPES]; 77 struct rb_root symbols[MAP__NR_TYPES];
77 struct symbol *(*find_symbol)(struct dso *self, 78 struct rb_root symbol_names[MAP__NR_TYPES];
78 enum map_type type, u64 addr);
79 u8 adjust_symbols:1; 79 u8 adjust_symbols:1;
80 u8 slen_calculated:1; 80 u8 slen_calculated:1;
81 u8 has_build_id:1; 81 u8 has_build_id:1;
82 u8 kernel:1; 82 u8 kernel:1;
83 unsigned char origin; 83 unsigned char origin;
84 u8 sorted_by_name;
84 u8 loaded; 85 u8 loaded;
85 u8 build_id[BUILD_ID_SIZE]; 86 u8 build_id[BUILD_ID_SIZE];
86 u16 long_name_len; 87 u16 long_name_len;
@@ -93,6 +94,9 @@ struct dso *dso__new(const char *name);
93void dso__delete(struct dso *self); 94void dso__delete(struct dso *self);
94 95
95bool dso__loaded(const struct dso *self, enum map_type type); 96bool dso__loaded(const struct dso *self, enum map_type type);
97bool dso__sorted_by_name(const struct dso *self, enum map_type type);
98
99void dso__sort_by_name(struct dso *self, enum map_type type);
96 100
97struct dso *dsos__findnew(const char *name); 101struct dso *dsos__findnew(const char *name);
98int dso__load(struct dso *self, struct map *map, symbol_filter_t filter); 102int dso__load(struct dso *self, struct map *map, symbol_filter_t filter);
@@ -103,6 +107,9 @@ size_t dso__fprintf_buildid(struct dso *self, FILE *fp);
103size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp); 107size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp);
104char dso__symtab_origin(const struct dso *self); 108char dso__symtab_origin(const struct dso *self);
105void dso__set_build_id(struct dso *self, void *build_id); 109void dso__set_build_id(struct dso *self, void *build_id);
110struct symbol *dso__find_symbol(struct dso *self, enum map_type type, u64 addr);
111struct symbol *dso__find_symbol_by_name(struct dso *self, enum map_type type,
112 const char *name);
106 113
107int filename__read_build_id(const char *filename, void *bf, size_t size); 114int filename__read_build_id(const char *filename, void *bf, size_t size);
108int sysfs__read_build_id(const char *filename, void *bf, size_t size); 115int sysfs__read_build_id(const char *filename, void *bf, size_t size);
@@ -113,8 +120,8 @@ size_t kernel_maps__fprintf(FILE *fp);
113 120
114int symbol__init(struct symbol_conf *conf); 121int symbol__init(struct symbol_conf *conf);
115 122
116struct thread; 123struct map_groups;
117struct thread *kthread; 124struct map_groups *kmaps;
118extern struct list_head dsos__user, dsos__kernel; 125extern struct list_head dsos__user, dsos__kernel;
119extern struct dso *vdso; 126extern struct dso *vdso;
120#endif /* __PERF_SYMBOL */ 127#endif /* __PERF_SYMBOL */
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 603f5610861b..b68a00ea4121 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -9,11 +9,9 @@
9static struct rb_root threads; 9static struct rb_root threads;
10static struct thread *last_match; 10static struct thread *last_match;
11 11
12void thread__init(struct thread *self, pid_t pid) 12void map_groups__init(struct map_groups *self)
13{ 13{
14 int i; 14 int i;
15 self->pid = pid;
16 self->comm = NULL;
17 for (i = 0; i < MAP__NR_TYPES; ++i) { 15 for (i = 0; i < MAP__NR_TYPES; ++i) {
18 self->maps[i] = RB_ROOT; 16 self->maps[i] = RB_ROOT;
19 INIT_LIST_HEAD(&self->removed_maps[i]); 17 INIT_LIST_HEAD(&self->removed_maps[i]);
@@ -25,7 +23,8 @@ static struct thread *thread__new(pid_t pid)
25 struct thread *self = zalloc(sizeof(*self)); 23 struct thread *self = zalloc(sizeof(*self));
26 24
27 if (self != NULL) { 25 if (self != NULL) {
28 thread__init(self, pid); 26 map_groups__init(&self->mg);
27 self->pid = pid;
29 self->comm = malloc(32); 28 self->comm = malloc(32);
30 if (self->comm) 29 if (self->comm)
31 snprintf(self->comm, 32, ":%d", self->pid); 30 snprintf(self->comm, 32, ":%d", self->pid);
@@ -55,10 +54,11 @@ int thread__comm_len(struct thread *self)
55 54
56static const char *map_type__name[MAP__NR_TYPES] = { 55static const char *map_type__name[MAP__NR_TYPES] = {
57 [MAP__FUNCTION] = "Functions", 56 [MAP__FUNCTION] = "Functions",
57 [MAP__VARIABLE] = "Variables",
58}; 58};
59 59
60static size_t __thread__fprintf_maps(struct thread *self, 60static size_t __map_groups__fprintf_maps(struct map_groups *self,
61 enum map_type type, FILE *fp) 61 enum map_type type, FILE *fp)
62{ 62{
63 size_t printed = fprintf(fp, "%s:\n", map_type__name[type]); 63 size_t printed = fprintf(fp, "%s:\n", map_type__name[type]);
64 struct rb_node *nd; 64 struct rb_node *nd;
@@ -76,16 +76,16 @@ static size_t __thread__fprintf_maps(struct thread *self,
76 return printed; 76 return printed;
77} 77}
78 78
79size_t thread__fprintf_maps(struct thread *self, FILE *fp) 79size_t map_groups__fprintf_maps(struct map_groups *self, FILE *fp)
80{ 80{
81 size_t printed = 0, i; 81 size_t printed = 0, i;
82 for (i = 0; i < MAP__NR_TYPES; ++i) 82 for (i = 0; i < MAP__NR_TYPES; ++i)
83 printed += __thread__fprintf_maps(self, i, fp); 83 printed += __map_groups__fprintf_maps(self, i, fp);
84 return printed; 84 return printed;
85} 85}
86 86
87static size_t __thread__fprintf_removed_maps(struct thread *self, 87static size_t __map_groups__fprintf_removed_maps(struct map_groups *self,
88 enum map_type type, FILE *fp) 88 enum map_type type, FILE *fp)
89{ 89{
90 struct map *pos; 90 struct map *pos;
91 size_t printed = 0; 91 size_t printed = 0;
@@ -101,20 +101,25 @@ static size_t __thread__fprintf_removed_maps(struct thread *self,
101 return printed; 101 return printed;
102} 102}
103 103
104static size_t thread__fprintf_removed_maps(struct thread *self, FILE *fp) 104static size_t map_groups__fprintf_removed_maps(struct map_groups *self, FILE *fp)
105{ 105{
106 size_t printed = 0, i; 106 size_t printed = 0, i;
107 for (i = 0; i < MAP__NR_TYPES; ++i) 107 for (i = 0; i < MAP__NR_TYPES; ++i)
108 printed += __thread__fprintf_removed_maps(self, i, fp); 108 printed += __map_groups__fprintf_removed_maps(self, i, fp);
109 return printed; 109 return printed;
110} 110}
111 111
112static size_t thread__fprintf(struct thread *self, FILE *fp) 112static size_t map_groups__fprintf(struct map_groups *self, FILE *fp)
113{ 113{
114 size_t printed = fprintf(fp, "Thread %d %s\n", self->pid, self->comm); 114 size_t printed = map_groups__fprintf_maps(self, fp);
115 printed += thread__fprintf_removed_maps(self, fp);
116 printed += fprintf(fp, "Removed maps:\n"); 115 printed += fprintf(fp, "Removed maps:\n");
117 return printed + thread__fprintf_removed_maps(self, fp); 116 return printed + map_groups__fprintf_removed_maps(self, fp);
117}
118
119static size_t thread__fprintf(struct thread *self, FILE *fp)
120{
121 return fprintf(fp, "Thread %d %s\n", self->pid, self->comm) +
122 map_groups__fprintf(&self->mg, fp);
118} 123}
119 124
120struct thread *threads__findnew(pid_t pid) 125struct thread *threads__findnew(pid_t pid)
@@ -168,7 +173,8 @@ struct thread *register_idle_thread(void)
168 return thread; 173 return thread;
169} 174}
170 175
171static void thread__remove_overlappings(struct thread *self, struct map *map) 176static void map_groups__remove_overlappings(struct map_groups *self,
177 struct map *map)
172{ 178{
173 struct rb_root *root = &self->maps[map->type]; 179 struct rb_root *root = &self->maps[map->type];
174 struct rb_node *next = rb_first(root); 180 struct rb_node *next = rb_first(root);
@@ -238,12 +244,15 @@ struct map *maps__find(struct rb_root *maps, u64 ip)
238 244
239void thread__insert_map(struct thread *self, struct map *map) 245void thread__insert_map(struct thread *self, struct map *map)
240{ 246{
241 thread__remove_overlappings(self, map); 247 map_groups__remove_overlappings(&self->mg, map);
242 maps__insert(&self->maps[map->type], map); 248 map_groups__insert(&self->mg, map);
243} 249}
244 250
245static int thread__clone_maps(struct thread *self, struct thread *parent, 251/*
246 enum map_type type) 252 * XXX This should not really _copy_ te maps, but refcount them.
253 */
254static int map_groups__clone(struct map_groups *self,
255 struct map_groups *parent, enum map_type type)
247{ 256{
248 struct rb_node *nd; 257 struct rb_node *nd;
249 for (nd = rb_first(&parent->maps[type]); nd; nd = rb_next(nd)) { 258 for (nd = rb_first(&parent->maps[type]); nd; nd = rb_next(nd)) {
@@ -251,7 +260,7 @@ static int thread__clone_maps(struct thread *self, struct thread *parent,
251 struct map *new = map__clone(map); 260 struct map *new = map__clone(map);
252 if (new == NULL) 261 if (new == NULL)
253 return -ENOMEM; 262 return -ENOMEM;
254 thread__insert_map(self, new); 263 map_groups__insert(self, new);
255 } 264 }
256 return 0; 265 return 0;
257} 266}
@@ -267,7 +276,7 @@ int thread__fork(struct thread *self, struct thread *parent)
267 return -ENOMEM; 276 return -ENOMEM;
268 277
269 for (i = 0; i < MAP__NR_TYPES; ++i) 278 for (i = 0; i < MAP__NR_TYPES; ++i)
270 if (thread__clone_maps(self, parent, i) < 0) 279 if (map_groups__clone(&self->mg, &parent->mg, i) < 0)
271 return -ENOMEM; 280 return -ENOMEM;
272 return 0; 281 return 0;
273} 282}
@@ -286,11 +295,11 @@ size_t threads__fprintf(FILE *fp)
286 return ret; 295 return ret;
287} 296}
288 297
289struct symbol *thread__find_symbol(struct thread *self, 298struct symbol *map_groups__find_symbol(struct map_groups *self,
290 enum map_type type, u64 addr, 299 enum map_type type, u64 addr,
291 symbol_filter_t filter) 300 symbol_filter_t filter)
292{ 301{
293 struct map *map = thread__find_map(self, type, addr); 302 struct map *map = map_groups__find(self, type, addr);
294 303
295 if (map != NULL) 304 if (map != NULL)
296 return map__find_symbol(map, map->map_ip(map, addr), filter); 305 return map__find_symbol(map, map->map_ip(map, addr), filter);
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index 686d6e914d9e..1751802a09ba 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -5,52 +5,66 @@
5#include <unistd.h> 5#include <unistd.h>
6#include "symbol.h" 6#include "symbol.h"
7 7
8struct thread { 8struct map_groups {
9 struct rb_node rb_node;
10 struct rb_root maps[MAP__NR_TYPES]; 9 struct rb_root maps[MAP__NR_TYPES];
11 struct list_head removed_maps[MAP__NR_TYPES]; 10 struct list_head removed_maps[MAP__NR_TYPES];
12 pid_t pid;
13 bool use_modules; 11 bool use_modules;
12};
13
14struct thread {
15 struct rb_node rb_node;
16 struct map_groups mg;
17 pid_t pid;
14 char shortname[3]; 18 char shortname[3];
15 char *comm; 19 char *comm;
16 int comm_len; 20 int comm_len;
17}; 21};
18 22
19void thread__init(struct thread *self, pid_t pid); 23void map_groups__init(struct map_groups *self);
20int thread__set_comm(struct thread *self, const char *comm); 24int thread__set_comm(struct thread *self, const char *comm);
21int thread__comm_len(struct thread *self); 25int thread__comm_len(struct thread *self);
22struct thread *threads__findnew(pid_t pid); 26struct thread *threads__findnew(pid_t pid);
23struct thread *register_idle_thread(void); 27struct thread *register_idle_thread(void);
24void thread__insert_map(struct thread *self, struct map *map); 28void thread__insert_map(struct thread *self, struct map *map);
25int thread__fork(struct thread *self, struct thread *parent); 29int thread__fork(struct thread *self, struct thread *parent);
26size_t thread__fprintf_maps(struct thread *self, FILE *fp); 30size_t map_groups__fprintf_maps(struct map_groups *self, FILE *fp);
27size_t threads__fprintf(FILE *fp); 31size_t threads__fprintf(FILE *fp);
28 32
29void maps__insert(struct rb_root *maps, struct map *map); 33void maps__insert(struct rb_root *maps, struct map *map);
30struct map *maps__find(struct rb_root *maps, u64 addr); 34struct map *maps__find(struct rb_root *maps, u64 addr);
31 35
32static inline struct map *thread__find_map(struct thread *self, 36static inline void map_groups__insert(struct map_groups *self, struct map *map)
37{
38 maps__insert(&self->maps[map->type], map);
39}
40
41static inline struct map *map_groups__find(struct map_groups *self,
33 enum map_type type, u64 addr) 42 enum map_type type, u64 addr)
34{ 43{
35 return self ? maps__find(&self->maps[type], addr) : NULL; 44 return maps__find(&self->maps[type], addr);
36} 45}
37 46
38static inline void __thread__insert_map(struct thread *self, struct map *map) 47static inline struct map *thread__find_map(struct thread *self,
48 enum map_type type, u64 addr)
39{ 49{
40 maps__insert(&self->maps[map->type], map); 50 return self ? map_groups__find(&self->mg, type, addr) : NULL;
41} 51}
42 52
43void thread__find_addr_location(struct thread *self, u8 cpumode, 53void thread__find_addr_location(struct thread *self, u8 cpumode,
44 enum map_type type, u64 addr, 54 enum map_type type, u64 addr,
45 struct addr_location *al, 55 struct addr_location *al,
46 symbol_filter_t filter); 56 symbol_filter_t filter);
47struct symbol *thread__find_symbol(struct thread *self, 57struct symbol *map_groups__find_symbol(struct map_groups *self,
48 enum map_type type, u64 addr, 58 enum map_type type, u64 addr,
49 symbol_filter_t filter); 59 symbol_filter_t filter);
50 60
51static inline struct symbol * 61static inline struct symbol *
52thread__find_function(struct thread *self, u64 addr, symbol_filter_t filter) 62map_groups__find_function(struct map_groups *self, u64 addr,
63 symbol_filter_t filter)
53{ 64{
54 return thread__find_symbol(self, MAP__FUNCTION, addr, filter); 65 return map_groups__find_symbol(self, MAP__FUNCTION, addr, filter);
55} 66}
67
68struct map *map_groups__find_by_name(struct map_groups *self,
69 enum map_type type, const char *name);
56#endif /* __PERF_THREAD_H */ 70#endif /* __PERF_THREAD_H */