aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/android.txt121
-rw-r--r--Documentation/cgroups/cgroups.txt9
-rw-r--r--Documentation/cgroups/cpuacct.txt7
-rw-r--r--Documentation/cpu-freq/governors.txt75
-rw-r--r--Documentation/hid/uhid.txt169
-rw-r--r--Documentation/power/runtime_pm.txt1
-rw-r--r--MAINTAINERS7
-rw-r--r--arch/arm/Kconfig9
-rw-r--r--arch/arm/boot/compressed/head.S3
-rw-r--r--arch/arm/common/Kconfig50
-rw-r--r--arch/arm/common/Makefile2
-rw-r--r--arch/arm/common/fiq_debugger.c1196
-rw-r--r--arch/arm/common/fiq_debugger_ringbuf.h94
-rw-r--r--arch/arm/common/fiq_glue.S111
-rw-r--r--arch/arm/common/fiq_glue_setup.c100
-rw-r--r--arch/arm/include/asm/fiq_debugger.h64
-rw-r--r--arch/arm/include/asm/fiq_glue.h30
-rw-r--r--arch/arm/include/asm/hardirq.h2
-rw-r--r--arch/arm/include/asm/hardware/cache-l2x0.h3
-rw-r--r--arch/arm/include/asm/hardware/coresight.h26
-rw-r--r--arch/arm/include/asm/irq.h3
-rw-r--r--arch/arm/include/asm/mach/mmc.h28
-rw-r--r--arch/arm/include/asm/smp.h2
-rw-r--r--arch/arm/kernel/entry-armv.S2
-rw-r--r--arch/arm/kernel/etm.c473
-rw-r--r--arch/arm/kernel/leds.c27
-rw-r--r--arch/arm/kernel/process.c129
-rw-r--r--arch/arm/kernel/smp.c81
-rw-r--r--arch/arm/mm/cache-l2x0.c66
-rw-r--r--arch/arm/mm/cache-v6.S17
-rw-r--r--arch/arm/vfp/entry.S3
-rw-r--r--arch/arm/vfp/vfphw.S20
-rw-r--r--arch/arm/vfp/vfpmodule.c42
-rw-r--r--arch/x86/include/asm/idle.h7
-rw-r--r--arch/x86/kernel/process_32.c2
-rw-r--r--arch/x86/kernel/process_64.c18
-rw-r--r--block/genhd.c17
-rw-r--r--drivers/Kconfig2
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/base/Kconfig26
-rw-r--r--drivers/base/Makefile3
-rw-r--r--drivers/base/power/main.c46
-rw-r--r--drivers/base/power/runtime.c9
-rw-r--r--drivers/base/sw_sync.c256
-rw-r--r--drivers/base/sync.c801
-rw-r--r--drivers/char/Kconfig17
-rw-r--r--drivers/char/Makefile1
-rw-r--r--drivers/char/dcc_tty.c326
-rw-r--r--drivers/char/mem.c17
-rw-r--r--drivers/cpufreq/Kconfig27
-rw-r--r--drivers/cpufreq/Makefile1
-rw-r--r--drivers/cpufreq/cpufreq_interactive.c1066
-rw-r--r--drivers/cpufreq/cpufreq_stats.c25
-rw-r--r--drivers/cpuidle/governors/menu.c7
-rw-r--r--drivers/gpu/Makefile2
-rw-r--r--drivers/gpu/ion/Kconfig12
-rw-r--r--drivers/gpu/ion/Makefile2
-rw-r--r--drivers/gpu/ion/ion.c1186
-rw-r--r--drivers/gpu/ion/ion_carveout_heap.c162
-rw-r--r--drivers/gpu/ion/ion_heap.c72
-rw-r--r--drivers/gpu/ion/ion_priv.h184
-rw-r--r--drivers/gpu/ion/ion_system_heap.c198
-rw-r--r--drivers/gpu/ion/ion_system_mapper.c114
-rw-r--r--drivers/gpu/ion/tegra/Makefile1
-rw-r--r--drivers/gpu/ion/tegra/tegra_ion.c96
-rw-r--r--drivers/hid/Kconfig21
-rw-r--r--drivers/hid/Makefile1
-rw-r--r--drivers/hid/hid-debug.c5
-rw-r--r--drivers/hid/hid-input.c7
-rw-r--r--drivers/hid/hid-magicmouse.c13
-rw-r--r--drivers/hid/hid-multitouch.c10
-rw-r--r--drivers/hid/uhid.c572
-rw-r--r--drivers/input/Kconfig9
-rw-r--r--drivers/input/Makefile1
-rw-r--r--drivers/input/evdev.c78
-rw-r--r--drivers/input/keyreset.c239
-rw-r--r--drivers/input/misc/Kconfig16
-rw-r--r--drivers/input/misc/Makefile2
-rw-r--r--drivers/input/misc/gpio_axis.c192
-rw-r--r--drivers/input/misc/gpio_event.c260
-rw-r--r--drivers/input/misc/gpio_input.c376
-rw-r--r--drivers/input/misc/gpio_matrix.c441
-rw-r--r--drivers/input/misc/gpio_output.c97
-rw-r--r--drivers/input/misc/keychord.c387
-rw-r--r--drivers/input/touchscreen/Kconfig6
-rw-r--r--drivers/input/touchscreen/Makefile1
-rw-r--r--drivers/input/touchscreen/synaptics_i2c_rmi.c675
-rw-r--r--drivers/leds/Kconfig6
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/leds/ledtrig-sleep.c80
-rw-r--r--drivers/misc/Kconfig35
-rw-r--r--drivers/misc/Makefile4
-rw-r--r--drivers/misc/akm8975.c732
-rw-r--r--drivers/misc/apanic.c606
-rw-r--r--drivers/misc/uid_stat.c156
-rw-r--r--drivers/misc/wl127x-rfkill.c121
-rw-r--r--drivers/mmc/card/Kconfig9
-rw-r--r--drivers/mmc/card/block.c308
-rw-r--r--drivers/mmc/core/Kconfig17
-rw-r--r--drivers/mmc/core/bus.c24
-rw-r--r--drivers/mmc/core/core.c94
-rw-r--r--drivers/mmc/core/host.c10
-rw-r--r--drivers/mmc/core/sd.c86
-rw-r--r--drivers/mmc/core/sdio.c148
-rw-r--r--drivers/mmc/core/sdio_bus.c13
-rwxr-xr-x[-rw-r--r--]drivers/mmc/core/sdio_io.c33
-rw-r--r--drivers/mmc/host/sdhci.c2
-rw-r--r--drivers/mtd/nand/Kconfig24
-rw-r--r--drivers/mtd/nand/nand_base.c39
-rw-r--r--drivers/net/Kconfig17
-rw-r--r--drivers/net/Makefile2
-rw-r--r--drivers/net/pppolac.c449
-rw-r--r--drivers/net/pppopns.c428
-rw-r--r--drivers/net/tun.c6
-rw-r--r--drivers/net/wireless/Kconfig7
-rw-r--r--drivers/net/wireless/Makefile3
-rw-r--r--drivers/net/wireless/bcm4329/Kconfig27
-rw-r--r--drivers/net/wireless/bcm4329/Makefile21
-rw-r--r--drivers/net/wireless/bcm4329/aiutils.c686
-rw-r--r--drivers/net/wireless/bcm4329/bcmpcispi.c630
-rw-r--r--drivers/net/wireless/bcm4329/bcmsdh.c652
-rw-r--r--drivers/net/wireless/bcm4329/bcmsdh_linux.c735
-rw-r--r--drivers/net/wireless/bcm4329/bcmsdh_sdmmc.c1304
-rw-r--r--drivers/net/wireless/bcm4329/bcmsdh_sdmmc_linux.c269
-rw-r--r--drivers/net/wireless/bcm4329/bcmsdspi.c1596
-rw-r--r--drivers/net/wireless/bcm4329/bcmsdspi_linux.c252
-rw-r--r--drivers/net/wireless/bcm4329/bcmsdstd.c3127
-rw-r--r--drivers/net/wireless/bcm4329/bcmsdstd_linux.c251
-rw-r--r--drivers/net/wireless/bcm4329/bcmutils.c1838
-rw-r--r--drivers/net/wireless/bcm4329/bcmwifi.c199
-rw-r--r--drivers/net/wireless/bcm4329/dhd.h465
-rw-r--r--drivers/net/wireless/bcm4329/dhd_bus.h93
-rw-r--r--drivers/net/wireless/bcm4329/dhd_cdc.c535
-rw-r--r--drivers/net/wireless/bcm4329/dhd_common.c2461
-rw-r--r--drivers/net/wireless/bcm4329/dhd_custom_gpio.c272
-rw-r--r--drivers/net/wireless/bcm4329/dhd_dbg.h100
-rw-r--r--drivers/net/wireless/bcm4329/dhd_linux.c3442
-rw-r--r--drivers/net/wireless/bcm4329/dhd_linux_sched.c38
-rw-r--r--drivers/net/wireless/bcm4329/dhd_proto.h102
-rw-r--r--drivers/net/wireless/bcm4329/dhd_sdio.c5824
-rw-r--r--drivers/net/wireless/bcm4329/dngl_stats.h43
-rw-r--r--drivers/net/wireless/bcm4329/hndpmu.c131
-rw-r--r--drivers/net/wireless/bcm4329/include/Makefile21
-rw-r--r--drivers/net/wireless/bcm4329/include/aidmp.h368
-rw-r--r--drivers/net/wireless/bcm4329/include/bcmcdc.h100
-rw-r--r--drivers/net/wireless/bcm4329/include/bcmdefs.h114
-rw-r--r--drivers/net/wireless/bcm4329/include/bcmdevs.h124
-rw-r--r--drivers/net/wireless/bcm4329/include/bcmendian.h205
-rw-r--r--drivers/net/wireless/bcm4329/include/bcmpcispi.h205
-rw-r--r--drivers/net/wireless/bcm4329/include/bcmperf.h36
-rw-r--r--drivers/net/wireless/bcm4329/include/bcmsdbus.h117
-rw-r--r--drivers/net/wireless/bcm4329/include/bcmsdh.h208
-rw-r--r--drivers/net/wireless/bcm4329/include/bcmsdh_sdmmc.h122
-rw-r--r--drivers/net/wireless/bcm4329/include/bcmsdpcm.h263
-rw-r--r--drivers/net/wireless/bcm4329/include/bcmsdspi.h131
-rw-r--r--drivers/net/wireless/bcm4329/include/bcmsdstd.h223
-rw-r--r--drivers/net/wireless/bcm4329/include/bcmspi.h36
-rw-r--r--drivers/net/wireless/bcm4329/include/bcmutils.h637
-rw-r--r--drivers/net/wireless/bcm4329/include/bcmwifi.h154
-rw-r--r--drivers/net/wireless/bcm4329/include/dhdioctl.h123
-rw-r--r--drivers/net/wireless/bcm4329/include/epivers.h48
-rw-r--r--drivers/net/wireless/bcm4329/include/hndpmu.h34
-rw-r--r--drivers/net/wireless/bcm4329/include/hndrte_armtrap.h88
-rw-r--r--drivers/net/wireless/bcm4329/include/hndrte_cons.h63
-rw-r--r--drivers/net/wireless/bcm4329/include/hndsoc.h195
-rw-r--r--drivers/net/wireless/bcm4329/include/linux_osl.h322
-rw-r--r--drivers/net/wireless/bcm4329/include/linuxver.h447
-rw-r--r--drivers/net/wireless/bcm4329/include/miniopt.h77
-rw-r--r--drivers/net/wireless/bcm4329/include/msgtrace.h72
-rw-r--r--drivers/net/wireless/bcm4329/include/osl.h55
-rw-r--r--drivers/net/wireless/bcm4329/include/packed_section_end.h54
-rw-r--r--drivers/net/wireless/bcm4329/include/packed_section_start.h61
-rw-r--r--drivers/net/wireless/bcm4329/include/pcicfg.h52
-rw-r--r--drivers/net/wireless/bcm4329/include/proto/802.11.h1433
-rw-r--r--drivers/net/wireless/bcm4329/include/proto/802.11e.h131
-rw-r--r--drivers/net/wireless/bcm4329/include/proto/802.1d.h49
-rw-r--r--drivers/net/wireless/bcm4329/include/proto/bcmeth.h83
-rw-r--r--drivers/net/wireless/bcm4329/include/proto/bcmevent.h212
-rw-r--r--drivers/net/wireless/bcm4329/include/proto/bcmip.h157
-rw-r--r--drivers/net/wireless/bcm4329/include/proto/eapol.h172
-rw-r--r--drivers/net/wireless/bcm4329/include/proto/ethernet.h148
-rw-r--r--drivers/net/wireless/bcm4329/include/proto/sdspi.h71
-rw-r--r--drivers/net/wireless/bcm4329/include/proto/vlan.h63
-rw-r--r--drivers/net/wireless/bcm4329/include/proto/wpa.h159
-rw-r--r--drivers/net/wireless/bcm4329/include/sbchipc.h1026
-rw-r--r--drivers/net/wireless/bcm4329/include/sbconfig.h276
-rw-r--r--drivers/net/wireless/bcm4329/include/sbhnddma.h294
-rw-r--r--drivers/net/wireless/bcm4329/include/sbpcmcia.h109
-rw-r--r--drivers/net/wireless/bcm4329/include/sbsdio.h166
-rw-r--r--drivers/net/wireless/bcm4329/include/sbsdpcmdev.h288
-rw-r--r--drivers/net/wireless/bcm4329/include/sbsocram.h150
-rw-r--r--drivers/net/wireless/bcm4329/include/sdio.h566
-rw-r--r--drivers/net/wireless/bcm4329/include/sdioh.h299
-rw-r--r--drivers/net/wireless/bcm4329/include/sdiovar.h58
-rw-r--r--drivers/net/wireless/bcm4329/include/siutils.h235
-rw-r--r--drivers/net/wireless/bcm4329/include/trxhdr.h46
-rw-r--r--drivers/net/wireless/bcm4329/include/typedefs.h303
-rw-r--r--drivers/net/wireless/bcm4329/include/wlioctl.h1673
-rw-r--r--drivers/net/wireless/bcm4329/linux_osl.c625
-rw-r--r--drivers/net/wireless/bcm4329/miniopt.c163
-rw-r--r--drivers/net/wireless/bcm4329/sbutils.c1004
-rw-r--r--drivers/net/wireless/bcm4329/siutils.c1527
-rw-r--r--drivers/net/wireless/bcm4329/siutils_priv.h213
-rw-r--r--drivers/net/wireless/bcm4329/wl_iw.c8455
-rw-r--r--drivers/net/wireless/bcm4329/wl_iw.h309
-rw-r--r--drivers/net/wireless/bcmdhd/Kconfig54
-rw-r--r--drivers/net/wireless/bcmdhd/Makefile40
-rw-r--r--drivers/net/wireless/bcmdhd/aiutils.c675
-rw-r--r--drivers/net/wireless/bcmdhd/bcmevent.c127
-rw-r--r--drivers/net/wireless/bcmdhd/bcmsdh.c691
-rw-r--r--drivers/net/wireless/bcmdhd/bcmsdh_linux.c736
-rw-r--r--drivers/net/wireless/bcmdhd/bcmsdh_sdmmc.c1421
-rw-r--r--drivers/net/wireless/bcmdhd/bcmsdh_sdmmc_linux.c366
-rw-r--r--drivers/net/wireless/bcmdhd/bcmutils.c1965
-rw-r--r--drivers/net/wireless/bcmdhd/bcmwifi.c274
-rw-r--r--drivers/net/wireless/bcmdhd/dhd.h788
-rw-r--r--drivers/net/wireless/bcmdhd/dhd_bta.c335
-rw-r--r--drivers/net/wireless/bcmdhd/dhd_bta.h39
-rw-r--r--drivers/net/wireless/bcmdhd/dhd_bus.h99
-rw-r--r--drivers/net/wireless/bcmdhd/dhd_cdc.c2534
-rw-r--r--drivers/net/wireless/bcmdhd/dhd_cfg80211.c660
-rw-r--r--drivers/net/wireless/bcmdhd/dhd_cfg80211.h45
-rw-r--r--drivers/net/wireless/bcmdhd/dhd_common.c2471
-rw-r--r--drivers/net/wireless/bcmdhd/dhd_custom_gpio.c293
-rw-r--r--drivers/net/wireless/bcmdhd/dhd_dbg.h105
-rw-r--r--drivers/net/wireless/bcmdhd/dhd_linux.c5486
-rw-r--r--drivers/net/wireless/bcmdhd/dhd_linux_sched.c39
-rw-r--r--drivers/net/wireless/bcmdhd/dhd_proto.h105
-rw-r--r--drivers/net/wireless/bcmdhd/dhd_sdio.c6361
-rw-r--r--drivers/net/wireless/bcmdhd/dhd_wlfc.h276
-rw-r--r--drivers/net/wireless/bcmdhd/dngl_stats.h43
-rw-r--r--drivers/net/wireless/bcmdhd/dngl_wlhdr.h40
-rw-r--r--drivers/net/wireless/bcmdhd/hndpmu.c196
-rw-r--r--drivers/net/wireless/bcmdhd/include/Makefile53
-rw-r--r--drivers/net/wireless/bcmdhd/include/aidmp.h377
-rw-r--r--drivers/net/wireless/bcmdhd/include/bcmcdc.h121
-rw-r--r--drivers/net/wireless/bcmdhd/include/bcmdefs.h231
-rw-r--r--drivers/net/wireless/bcmdhd/include/bcmdevs.h747
-rw-r--r--drivers/net/wireless/bcmdhd/include/bcmendian.h279
-rw-r--r--drivers/net/wireless/bcmdhd/include/bcmpcispi.h181
-rw-r--r--drivers/net/wireless/bcmdhd/include/bcmperf.h36
-rw-r--r--drivers/net/wireless/bcmdhd/include/bcmsdbus.h128
-rw-r--r--drivers/net/wireless/bcmdhd/include/bcmsdh.h219
-rw-r--r--drivers/net/wireless/bcmdhd/include/bcmsdh_sdmmc.h123
-rw-r--r--drivers/net/wireless/bcmdhd/include/bcmsdpcm.h274
-rw-r--r--drivers/net/wireless/bcmdhd/include/bcmsdspi.h135
-rw-r--r--drivers/net/wireless/bcmdhd/include/bcmsdstd.h248
-rw-r--r--drivers/net/wireless/bcmdhd/include/bcmspi.h40
-rw-r--r--drivers/net/wireless/bcmdhd/include/bcmutils.h722
-rw-r--r--drivers/net/wireless/bcmdhd/include/bcmwifi.h165
-rw-r--r--drivers/net/wireless/bcmdhd/include/dhdioctl.h131
-rw-r--r--drivers/net/wireless/bcmdhd/include/epivers.h49
-rw-r--r--drivers/net/wireless/bcmdhd/include/hndpmu.h37
-rw-r--r--drivers/net/wireless/bcmdhd/include/hndrte_armtrap.h88
-rw-r--r--drivers/net/wireless/bcmdhd/include/hndrte_cons.h68
-rw-r--r--drivers/net/wireless/bcmdhd/include/hndsoc.h207
-rw-r--r--drivers/net/wireless/bcmdhd/include/htsf.h74
-rw-r--r--drivers/net/wireless/bcmdhd/include/linux_osl.h431
-rw-r--r--drivers/net/wireless/bcmdhd/include/linuxver.h614
-rw-r--r--drivers/net/wireless/bcmdhd/include/miniopt.h77
-rw-r--r--drivers/net/wireless/bcmdhd/include/msgtrace.h74
-rw-r--r--drivers/net/wireless/bcmdhd/include/osl.h66
-rw-r--r--drivers/net/wireless/bcmdhd/include/packed_section_end.h54
-rw-r--r--drivers/net/wireless/bcmdhd/include/packed_section_start.h61
-rw-r--r--drivers/net/wireless/bcmdhd/include/pcicfg.h78
-rw-r--r--drivers/net/wireless/bcmdhd/include/proto/802.11.h2032
-rw-r--r--drivers/net/wireless/bcmdhd/include/proto/802.11_bta.h45
-rw-r--r--drivers/net/wireless/bcmdhd/include/proto/802.11e.h131
-rw-r--r--drivers/net/wireless/bcmdhd/include/proto/802.1d.h49
-rw-r--r--drivers/net/wireless/bcmdhd/include/proto/bcmeth.h83
-rw-r--r--drivers/net/wireless/bcmdhd/include/proto/bcmevent.h317
-rw-r--r--drivers/net/wireless/bcmdhd/include/proto/bcmip.h154
-rw-r--r--drivers/net/wireless/bcmdhd/include/proto/bt_amp_hci.h442
-rw-r--r--drivers/net/wireless/bcmdhd/include/proto/eapol.h173
-rw-r--r--drivers/net/wireless/bcmdhd/include/proto/ethernet.h163
-rw-r--r--drivers/net/wireless/bcmdhd/include/proto/p2p.h512
-rw-r--r--drivers/net/wireless/bcmdhd/include/proto/sdspi.h76
-rw-r--r--drivers/net/wireless/bcmdhd/include/proto/vlan.h70
-rw-r--r--drivers/net/wireless/bcmdhd/include/proto/wpa.h168
-rw-r--r--drivers/net/wireless/bcmdhd/include/sbchipc.h1783
-rw-r--r--drivers/net/wireless/bcmdhd/include/sbconfig.h276
-rw-r--r--drivers/net/wireless/bcmdhd/include/sbhnddma.h327
-rw-r--r--drivers/net/wireless/bcmdhd/include/sbpcmcia.h109
-rw-r--r--drivers/net/wireless/bcmdhd/include/sbsdio.h166
-rw-r--r--drivers/net/wireless/bcmdhd/include/sbsdpcmdev.h293
-rw-r--r--drivers/net/wireless/bcmdhd/include/sbsocram.h186
-rw-r--r--drivers/net/wireless/bcmdhd/include/sdio.h612
-rw-r--r--drivers/net/wireless/bcmdhd/include/sdioh.h446
-rw-r--r--drivers/net/wireless/bcmdhd/include/sdiovar.h58
-rw-r--r--drivers/net/wireless/bcmdhd/include/siutils.h277
-rw-r--r--drivers/net/wireless/bcmdhd/include/trxhdr.h53
-rw-r--r--drivers/net/wireless/bcmdhd/include/typedefs.h312
-rw-r--r--drivers/net/wireless/bcmdhd/include/wlfc_proto.h198
-rw-r--r--drivers/net/wireless/bcmdhd/include/wlioctl.h2763
-rw-r--r--drivers/net/wireless/bcmdhd/linux_osl.c924
-rw-r--r--drivers/net/wireless/bcmdhd/sbutils.c992
-rw-r--r--drivers/net/wireless/bcmdhd/siutils.c1915
-rw-r--r--drivers/net/wireless/bcmdhd/siutils_priv.h235
-rw-r--r--drivers/net/wireless/bcmdhd/uamp_api.h176
-rw-r--r--drivers/net/wireless/bcmdhd/wl_android.c858
-rw-r--r--drivers/net/wireless/bcmdhd/wl_android.h57
-rw-r--r--drivers/net/wireless/bcmdhd/wl_cfg80211.c7885
-rw-r--r--drivers/net/wireless/bcmdhd/wl_cfg80211.h693
-rw-r--r--drivers/net/wireless/bcmdhd/wl_cfgp2p.c2033
-rw-r--r--drivers/net/wireless/bcmdhd/wl_cfgp2p.h288
-rw-r--r--drivers/net/wireless/bcmdhd/wl_dbg.h49
-rw-r--r--drivers/net/wireless/bcmdhd/wl_iw.c8894
-rw-r--r--drivers/net/wireless/bcmdhd/wl_iw.h319
-rw-r--r--drivers/net/wireless/bcmdhd/wl_linux_mon.c409
-rw-r--r--drivers/net/wireless/bcmdhd/wldev_common.c424
-rw-r--r--drivers/net/wireless/bcmdhd/wldev_common.h113
-rw-r--r--drivers/power/pda_power.c71
-rw-r--r--drivers/power/power_supply_core.c30
-rw-r--r--drivers/rtc/Kconfig18
-rw-r--r--drivers/rtc/Makefile2
-rw-r--r--drivers/rtc/alarm-dev.c286
-rw-r--r--drivers/rtc/alarm.c590
-rw-r--r--drivers/rtc/class.c69
-rw-r--r--drivers/staging/Kconfig2
-rw-r--r--drivers/staging/Makefile1
-rw-r--r--drivers/staging/android/Kconfig95
-rw-r--r--drivers/staging/android/Makefile6
-rw-r--r--drivers/staging/android/binder.c3600
-rw-r--r--drivers/staging/android/binder.h330
-rw-r--r--drivers/staging/android/logger.c761
-rw-r--r--drivers/staging/android/logger.h70
-rw-r--r--drivers/staging/android/lowmemorykiller.c213
-rw-r--r--drivers/staging/android/ram_console.c443
-rw-r--r--drivers/staging/android/timed_gpio.c176
-rw-r--r--drivers/staging/android/timed_gpio.h33
-rw-r--r--drivers/staging/android/timed_output.c123
-rw-r--r--drivers/staging/android/timed_output.h37
-rw-r--r--drivers/switch/Kconfig15
-rw-r--r--drivers/switch/Makefile4
-rw-r--r--drivers/switch/switch_class.c179
-rw-r--r--drivers/switch/switch_gpio.c172
-rw-r--r--drivers/tty/serial/serial_core.c3
-rw-r--r--drivers/usb/gadget/Kconfig8
-rw-r--r--drivers/usb/gadget/Makefile2
-rw-r--r--drivers/usb/gadget/android.c1349
-rw-r--r--drivers/usb/gadget/composite.c62
-rw-r--r--drivers/usb/gadget/f_accessory.c1176
-rw-r--r--drivers/usb/gadget/f_acm.c21
-rw-r--r--drivers/usb/gadget/f_adb.c614
-rw-r--r--drivers/usb/gadget/f_audio_source.c821
-rw-r--r--drivers/usb/gadget/f_mass_storage.c2
-rw-r--r--drivers/usb/gadget/f_mtp.c1267
-rw-r--r--drivers/usb/gadget/f_rndis.c46
-rw-r--r--drivers/usb/gadget/rndis.c11
-rw-r--r--drivers/usb/gadget/storage_common.c6
-rw-r--r--drivers/usb/gadget/u_ether.c23
-rw-r--r--drivers/usb/gadget/u_ether.h9
-rw-r--r--drivers/usb/gadget/u_serial.c6
-rw-r--r--drivers/usb/host/ehci-q.c18
-rw-r--r--drivers/usb/host/ehci.h17
-rw-r--r--drivers/usb/otg/Kconfig8
-rw-r--r--drivers/usb/otg/Makefile2
-rw-r--r--drivers/usb/otg/otg-wakelock.c169
-rw-r--r--drivers/usb/otg/otg_id.c205
-rw-r--r--drivers/video/Kconfig2
-rw-r--r--fs/Kconfig4
-rw-r--r--fs/Makefile3
-rw-r--r--fs/fat/dir.c9
-rw-r--r--fs/fat/fat.h1
-rw-r--r--fs/fat/inode.c9
-rw-r--r--fs/fs-writeback.c2
-rw-r--r--fs/fuse/dev.c6
-rw-r--r--fs/partitions/check.c11
-rw-r--r--fs/proc/base.c49
-rw-r--r--fs/yaffs2/Kconfig161
-rw-r--r--fs/yaffs2/Makefile17
-rw-r--r--fs/yaffs2/yaffs_allocator.c396
-rw-r--r--fs/yaffs2/yaffs_allocator.h30
-rw-r--r--fs/yaffs2/yaffs_attribs.c124
-rw-r--r--fs/yaffs2/yaffs_attribs.h28
-rw-r--r--fs/yaffs2/yaffs_bitmap.c98
-rw-r--r--fs/yaffs2/yaffs_bitmap.h33
-rw-r--r--fs/yaffs2/yaffs_checkptrw.c415
-rw-r--r--fs/yaffs2/yaffs_checkptrw.h33
-rw-r--r--fs/yaffs2/yaffs_ecc.c298
-rw-r--r--fs/yaffs2/yaffs_ecc.h44
-rw-r--r--fs/yaffs2/yaffs_getblockinfo.h35
-rw-r--r--fs/yaffs2/yaffs_guts.c5164
-rw-r--r--fs/yaffs2/yaffs_guts.h915
-rw-r--r--fs/yaffs2/yaffs_linux.h41
-rw-r--r--fs/yaffs2/yaffs_mtdif.c54
-rw-r--r--fs/yaffs2/yaffs_mtdif.h23
-rw-r--r--fs/yaffs2/yaffs_mtdif1.c330
-rw-r--r--fs/yaffs2/yaffs_mtdif1.h29
-rw-r--r--fs/yaffs2/yaffs_mtdif2.c225
-rw-r--r--fs/yaffs2/yaffs_mtdif2.h29
-rw-r--r--fs/yaffs2/yaffs_nameval.c201
-rw-r--r--fs/yaffs2/yaffs_nameval.h28
-rw-r--r--fs/yaffs2/yaffs_nand.c127
-rw-r--r--fs/yaffs2/yaffs_nand.h38
-rw-r--r--fs/yaffs2/yaffs_packedtags1.c53
-rw-r--r--fs/yaffs2/yaffs_packedtags1.h39
-rw-r--r--fs/yaffs2/yaffs_packedtags2.c196
-rw-r--r--fs/yaffs2/yaffs_packedtags2.h47
-rw-r--r--fs/yaffs2/yaffs_tagscompat.c422
-rw-r--r--fs/yaffs2/yaffs_tagscompat.h36
-rw-r--r--fs/yaffs2/yaffs_tagsvalidity.c27
-rw-r--r--fs/yaffs2/yaffs_tagsvalidity.h23
-rw-r--r--fs/yaffs2/yaffs_trace.h57
-rw-r--r--fs/yaffs2/yaffs_verify.c535
-rw-r--r--fs/yaffs2/yaffs_verify.h43
-rw-r--r--fs/yaffs2/yaffs_vfs.c2792
-rw-r--r--fs/yaffs2/yaffs_yaffs1.c433
-rw-r--r--fs/yaffs2/yaffs_yaffs1.h22
-rw-r--r--fs/yaffs2/yaffs_yaffs2.c1598
-rw-r--r--fs/yaffs2/yaffs_yaffs2.h39
-rw-r--r--fs/yaffs2/yportenv.h70
-rw-r--r--include/linux/Kbuild1
-rw-r--r--include/linux/akm8975.h87
-rw-r--r--include/linux/amba/mmci.h12
-rw-r--r--include/linux/android_aid.h28
-rw-r--r--include/linux/android_alarm.h106
-rw-r--r--include/linux/ashmem.h48
-rw-r--r--include/linux/cgroup.h14
-rw-r--r--include/linux/cpu.h7
-rw-r--r--include/linux/cpuacct.h43
-rw-r--r--include/linux/cpufreq.h3
-rwxr-xr-xinclude/linux/earlysuspend.h56
-rw-r--r--include/linux/gpio_event.h170
-rw-r--r--include/linux/hid.h4
-rw-r--r--include/linux/if_pppolac.h33
-rw-r--r--include/linux/if_pppopns.h32
-rw-r--r--include/linux/if_pppox.h27
-rw-r--r--include/linux/input.h3
-rw-r--r--include/linux/ion.h344
-rw-r--r--include/linux/kernel.h3
-rw-r--r--include/linux/keychord.h52
-rw-r--r--include/linux/keyreset.h28
-rw-r--r--include/linux/mm.h1
-rw-r--r--include/linux/mmc/host.h35
-rw-r--r--include/linux/mmc/mmc.h10
-rw-r--r--include/linux/mmc/pm.h1
-rwxr-xr-x[-rw-r--r--]include/linux/mmc/sdio_func.h10
-rw-r--r--include/linux/msdos_fs.h12
-rw-r--r--include/linux/netfilter/xt_IDLETIMER.h8
-rw-r--r--include/linux/netfilter/xt_qtaguid.h13
-rw-r--r--include/linux/netfilter/xt_quota2.h25
-rw-r--r--include/linux/netfilter/xt_socket.h6
-rw-r--r--include/linux/netlink.h1
-rw-r--r--include/linux/nl80211.h310
-rw-r--r--include/linux/pda_power.h2
-rw-r--r--include/linux/platform_data/ram_console.h22
-rw-r--r--include/linux/plist.h55
-rw-r--r--include/linux/power_supply.h4
-rw-r--r--include/linux/rtmutex.h4
-rw-r--r--include/linux/sched.h3
-rw-r--r--include/linux/serial_core.h1
-rw-r--r--include/linux/sockios.h1
-rw-r--r--include/linux/sw_sync.h58
-rw-r--r--include/linux/switch.h53
-rw-r--r--include/linux/synaptics_i2c_rmi.h55
-rw-r--r--include/linux/sync.h390
-rw-r--r--include/linux/uhid.h104
-rw-r--r--include/linux/uid_stat.h29
-rw-r--r--include/linux/usb/composite.h3
-rw-r--r--include/linux/usb/f_accessory.h146
-rw-r--r--include/linux/usb/f_mtp.h75
-rw-r--r--include/linux/usb/otg_id.h58
-rwxr-xr-xinclude/linux/wakelock.h91
-rw-r--r--include/linux/wifi_tiwlan.h27
-rw-r--r--include/linux/wl127x-rfkill.h35
-rw-r--r--include/linux/wlan_plat.h27
-rw-r--r--include/net/activity_stats.h25
-rw-r--r--include/net/addrconf.h2
-rw-r--r--include/net/bluetooth/bluetooth.h27
-rw-r--r--include/net/bluetooth/hci.h86
-rw-r--r--include/net/bluetooth/hci_core.h101
-rw-r--r--include/net/bluetooth/l2cap.h121
-rw-r--r--include/net/bluetooth/mgmt.h12
-rw-r--r--include/net/bluetooth/rfcomm.h9
-rw-r--r--include/net/bluetooth/sco.h4
-rw-r--r--include/net/bluetooth/smp.h47
-rw-r--r--include/net/cfg80211.h186
-rw-r--r--include/net/if_inet6.h1
-rw-r--r--include/net/tcp.h2
-rw-r--r--include/trace/events/cpufreq_interactive.h112
-rw-r--r--init/Kconfig15
-rw-r--r--kernel/cgroup.c212
-rw-r--r--kernel/cpu.c20
-rw-r--r--kernel/fork.c18
-rw-r--r--kernel/futex.c2
-rw-r--r--kernel/irq/pm.c7
-rw-r--r--kernel/panic.c13
-rw-r--r--kernel/pm_qos_params.c6
-rw-r--r--kernel/power/Kconfig74
-rw-r--r--kernel/power/Makefile6
-rw-r--r--kernel/power/consoleearlysuspend.c78
-rw-r--r--kernel/power/earlysuspend.c187
-rw-r--r--kernel/power/fbearlysuspend.c153
-rw-r--r--kernel/power/main.c20
-rw-r--r--kernel/power/power.h24
-rw-r--r--kernel/power/process.c27
-rw-r--r--kernel/power/suspend.c3
-rw-r--r--kernel/power/suspend_time.c111
-rw-r--r--kernel/power/userwakelock.c219
-rw-r--r--kernel/power/wakelock.c634
-rw-r--r--kernel/printk.c56
-rw-r--r--kernel/rtmutex.c2
-rw-r--r--kernel/sched.c101
-rw-r--r--kernel/sysctl.c8
-rw-r--r--kernel/time/Makefile2
-rw-r--r--kernel/time/timekeeping.c2
-rw-r--r--lib/Kconfig.debug3
-rw-r--r--lib/plist.c7
-rw-r--r--mm/Makefile1
-rw-r--r--mm/ashmem.c748
-rw-r--r--mm/page_alloc.c25
-rw-r--r--mm/shmem.c15
-rw-r--r--net/Kconfig16
-rw-r--r--net/Makefile1
-rw-r--r--net/activity_stats.c115
-rw-r--r--net/bluetooth/Kconfig9
-rw-r--r--net/bluetooth/Makefile2
-rw-r--r--net/bluetooth/af_bluetooth.c44
-rw-r--r--net/bluetooth/bnep/bnep.h1
-rw-r--r--net/bluetooth/bnep/core.c13
-rw-r--r--net/bluetooth/cmtp/capi.c3
-rw-r--r--net/bluetooth/hci_conn.c132
-rw-r--r--net/bluetooth/hci_core.c266
-rwxr-xr-x[-rw-r--r--]net/bluetooth/hci_event.c311
-rw-r--r--net/bluetooth/hci_sock.c70
-rw-r--r--net/bluetooth/hidp/core.c19
-rw-r--r--net/bluetooth/l2cap_core.c1043
-rw-r--r--net/bluetooth/l2cap_sock.c472
-rw-r--r--net/bluetooth/lib.c23
-rw-r--r--net/bluetooth/mgmt.c283
-rw-r--r--net/bluetooth/rfcomm/core.c18
-rw-r--r--net/bluetooth/rfcomm/sock.c33
-rw-r--r--net/bluetooth/sco.c86
-rw-r--r--net/bluetooth/smp.c702
-rw-r--r--net/bridge/br_device.c11
-rw-r--r--net/ipv4/Makefile1
-rw-r--r--net/ipv4/af_inet.c18
-rw-r--r--net/ipv4/devinet.c8
-rw-r--r--net/ipv4/fib_semantics.c2
-rw-r--r--net/ipv4/netfilter/Kconfig12
-rw-r--r--net/ipv4/netfilter/ipt_REJECT.c8
-rw-r--r--net/ipv4/route.c7
-rw-r--r--net/ipv4/sysfs_net_ipv4.c88
-rw-r--r--net/ipv4/tcp.c121
-rw-r--r--net/ipv6/addrconf.c69
-rw-r--r--net/ipv6/af_inet6.c34
-rw-r--r--net/ipv6/netfilter/Kconfig12
-rw-r--r--net/ipv6/netfilter/ip6_tables.c14
-rw-r--r--net/ipv6/netfilter/ip6t_REJECT.c9
-rw-r--r--net/ipv6/route.c7
-rw-r--r--net/mac80211/sta_info.c1
-rw-r--r--net/netfilter/Kconfig42
-rw-r--r--net/netfilter/Makefile2
-rw-r--r--net/netfilter/xt_IDLETIMER.c79
-rw-r--r--net/netfilter/xt_qtaguid.c2990
-rw-r--r--net/netfilter/xt_qtaguid_internal.h352
-rw-r--r--net/netfilter/xt_qtaguid_print.c566
-rw-r--r--net/netfilter/xt_qtaguid_print.h120
-rw-r--r--net/netfilter/xt_quota2.c381
-rw-r--r--net/netfilter/xt_socket.c70
-rw-r--r--net/rfkill/Kconfig5
-rw-r--r--net/rfkill/core.c4
-rw-r--r--net/wireless/Kconfig11
-rw-r--r--net/wireless/core.c8
-rw-r--r--net/wireless/core.h2
-rw-r--r--net/wireless/mlme.c38
-rw-r--r--net/wireless/nl80211.c616
-rw-r--r--net/wireless/nl80211.h11
-rw-r--r--net/wireless/reg.c5
-rw-r--r--net/wireless/scan.c2
-rw-r--r--net/wireless/sme.c6
-rw-r--r--net/xfrm/xfrm_policy.c10
-rw-r--r--samples/uhid/Makefile10
-rw-r--r--samples/uhid/uhid-example.c381
-rw-r--r--security/commoncap.c9
576 files changed, 178779 insertions, 1796 deletions
diff --git a/Documentation/android.txt b/Documentation/android.txt
new file mode 100644
index 00000000000..72a62afdf20
--- /dev/null
+++ b/Documentation/android.txt
@@ -0,0 +1,121 @@
1 =============
2 A N D R O I D
3 =============
4
5Copyright (C) 2009 Google, Inc.
6Written by Mike Chan <mike@android.com>
7
8CONTENTS:
9---------
10
111. Android
12 1.1 Required enabled config options
13 1.2 Required disabled config options
14 1.3 Recommended enabled config options
152. Contact
16
17
181. Android
19==========
20
21Android (www.android.com) is an open source operating system for mobile devices.
22This document describes configurations needed to run the Android framework on
23top of the Linux kernel.
24
25To see a working defconfig look at msm_defconfig or goldfish_defconfig
26which can be found at http://android.git.kernel.org in kernel/common.git
27and kernel/msm.git
28
29
301.1 Required enabled config options
31-----------------------------------
32After building a standard defconfig, ensure that these options are enabled in
33your .config or defconfig if they are not already. Based off the msm_defconfig.
34You should keep the rest of the default options enabled in the defconfig
35unless you know what you are doing.
36
37ANDROID_PARANOID_NETWORK
38ASHMEM
39CONFIG_FB_MODE_HELPERS
40CONFIG_FONT_8x16
41CONFIG_FONT_8x8
42CONFIG_YAFFS_SHORT_NAMES_IN_RAM
43DAB
44EARLYSUSPEND
45FB
46FB_CFB_COPYAREA
47FB_CFB_FILLRECT
48FB_CFB_IMAGEBLIT
49FB_DEFERRED_IO
50FB_TILEBLITTING
51HIGH_RES_TIMERS
52INOTIFY
53INOTIFY_USER
54INPUT_EVDEV
55INPUT_GPIO
56INPUT_MISC
57LEDS_CLASS
58LEDS_GPIO
59LOCK_KERNEL
60LkOGGER
61LOW_MEMORY_KILLER
62MISC_DEVICES
63NEW_LEDS
64NO_HZ
65POWER_SUPPLY
66PREEMPT
67RAMFS
68RTC_CLASS
69RTC_LIB
70SWITCH
71SWITCH_GPIO
72TMPFS
73UID_STAT
74UID16
75USB_FUNCTION
76USB_FUNCTION_ADB
77USER_WAKELOCK
78VIDEO_OUTPUT_CONTROL
79WAKELOCK
80YAFFS_AUTO_YAFFS2
81YAFFS_FS
82YAFFS_YAFFS1
83YAFFS_YAFFS2
84
85
861.2 Required disabled config options
87------------------------------------
88CONFIG_YAFFS_DISABLE_LAZY_LOAD
89DNOTIFY
90
91
921.3 Recommended enabled config options
93------------------------------
94ANDROID_PMEM
95ANDROID_RAM_CONSOLE
96ANDROID_RAM_CONSOLE_ERROR_CORRECTION
97SCHEDSTATS
98DEBUG_PREEMPT
99DEBUG_MUTEXES
100DEBUG_SPINLOCK_SLEEP
101DEBUG_INFO
102FRAME_POINTER
103CPU_FREQ
104CPU_FREQ_TABLE
105CPU_FREQ_DEFAULT_GOV_ONDEMAND
106CPU_FREQ_GOV_ONDEMAND
107CRC_CCITT
108EMBEDDED
109INPUT_TOUCHSCREEN
110I2C
111I2C_BOARDINFO
112LOG_BUF_SHIFT=17
113SERIAL_CORE
114SERIAL_CORE_CONSOLE
115
116
1172. Contact
118==========
119website: http://android.git.kernel.org
120
121mailing-lists: android-kernel@googlegroups.com
diff --git a/Documentation/cgroups/cgroups.txt b/Documentation/cgroups/cgroups.txt
index cd67e90003c..60d82e1e498 100644
--- a/Documentation/cgroups/cgroups.txt
+++ b/Documentation/cgroups/cgroups.txt
@@ -593,6 +593,15 @@ there are not tasks in the cgroup. If pre_destroy() returns error code,
593rmdir() will fail with it. From this behavior, pre_destroy() can be 593rmdir() will fail with it. From this behavior, pre_destroy() can be
594called multiple times against a cgroup. 594called multiple times against a cgroup.
595 595
596int allow_attach(struct cgroup *cgrp, struct task_struct *task)
597(cgroup_mutex held by caller)
598
599Called prior to moving a task into a cgroup; if the subsystem
600returns an error, this will abort the attach operation. Used
601to extend the permission checks - if all subsystems in a cgroup
602return 0, the attach will be allowed to proceed, even if the
603default permission check (root or same user) fails.
604
596int can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, 605int can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
597 struct task_struct *task) 606 struct task_struct *task)
598(cgroup_mutex held by caller) 607(cgroup_mutex held by caller)
diff --git a/Documentation/cgroups/cpuacct.txt b/Documentation/cgroups/cpuacct.txt
index 9ad85df4b98..34197079f18 100644
--- a/Documentation/cgroups/cpuacct.txt
+++ b/Documentation/cgroups/cpuacct.txt
@@ -39,6 +39,13 @@ system: Time spent by tasks of the cgroup in kernel mode.
39 39
40user and system are in USER_HZ unit. 40user and system are in USER_HZ unit.
41 41
42cpuacct.cpufreq file gives CPU time (in nanoseconds) spent at each CPU
43frequency. Platform hooks must be implemented inorder to properly track
44time at each CPU frequency.
45
46cpuacct.power file gives CPU power consumed (in milliWatt seconds). Platform
47must provide and implement power callback functions.
48
42cpuacct controller uses percpu_counter interface to collect user and 49cpuacct controller uses percpu_counter interface to collect user and
43system times. This has two side effects: 50system times. This has two side effects:
44 51
diff --git a/Documentation/cpu-freq/governors.txt b/Documentation/cpu-freq/governors.txt
index e74d0a2eb1c..1eebdbfcd77 100644
--- a/Documentation/cpu-freq/governors.txt
+++ b/Documentation/cpu-freq/governors.txt
@@ -28,6 +28,7 @@ Contents:
282.3 Userspace 282.3 Userspace
292.4 Ondemand 292.4 Ondemand
302.5 Conservative 302.5 Conservative
312.6 Interactive
31 32
323. The Governor Interface in the CPUfreq Core 333. The Governor Interface in the CPUfreq Core
33 34
@@ -193,6 +194,80 @@ governor but for the opposite direction. For example when set to its
193default value of '20' it means that if the CPU usage needs to be below 194default value of '20' it means that if the CPU usage needs to be below
19420% between samples to have the frequency decreased. 19520% between samples to have the frequency decreased.
195 196
197
1982.6 Interactive
199---------------
200
201The CPUfreq governor "interactive" is designed for latency-sensitive,
202interactive workloads. This governor sets the CPU speed depending on
203usage, similar to "ondemand" and "conservative" governors, but with a
204different set of configurable behaviors.
205
206The tuneable values for this governor are:
207
208target_loads: CPU load values used to adjust speed to influence the
209current CPU load toward that value. In general, the lower the target
210load, the more often the governor will raise CPU speeds to bring load
211below the target. The format is a single target load, optionally
212followed by pairs of CPU speeds and CPU loads to target at or above
213those speeds. Colons can be used between the speeds and associated
214target loads for readability. For example:
215
216 85 1000000:90 1700000:99
217
218targets CPU load 85% below speed 1GHz, 90% at or above 1GHz, until
2191.7GHz and above, at which load 99% is targeted. If speeds are
220specified these must appear in ascending order. Higher target load
221values are typically specified for higher speeds, that is, target load
222values also usually appear in an ascending order. The default is
223target load 90% for all speeds.
224
225min_sample_time: The minimum amount of time to spend at the current
226frequency before ramping down. Default is 80000 uS.
227
228hispeed_freq: An intermediate "hi speed" at which to initially ramp
229when CPU load hits the value specified in go_hispeed_load. If load
230stays high for the amount of time specified in above_hispeed_delay,
231then speed may be bumped higher. Default is the maximum speed
232allowed by the policy at governor initialization time.
233
234go_hispeed_load: The CPU load at which to ramp to hispeed_freq.
235Default is 99%.
236
237above_hispeed_delay: When speed is at or above hispeed_freq, wait for
238this long before raising speed in response to continued high load.
239Default is 20000 uS.
240
241timer_rate: Sample rate for reevaluating CPU load when the CPU is not
242idle. A deferrable timer is used, such that the CPU will not be woken
243from idle to service this timer until something else needs to run.
244(The maximum time to allow deferring this timer when not running at
245minimum speed is configurable via timer_slack.) Default is 20000 uS.
246
247timer_slack: Maximum additional time to defer handling the governor
248sampling timer beyond timer_rate when running at speeds above the
249minimum. For platforms that consume additional power at idle when
250CPUs are running at speeds greater than minimum, this places an upper
251bound on how long the timer will be deferred prior to re-evaluating
252load and dropping speed. For example, if timer_rate is 20000uS and
253timer_slack is 10000uS then timers will be deferred for up to 30msec
254when not at lowest speed. A value of -1 means defer timers
255indefinitely at all speeds. Default is 80000 uS.
256
257boost: If non-zero, immediately boost speed of all CPUs to at least
258hispeed_freq until zero is written to this attribute. If zero, allow
259CPU speeds to drop below hispeed_freq according to load as usual.
260Default is zero.
261
262boostpulse: On each write, immediately boost speed of all CPUs to
263hispeed_freq for at least the period of time specified by
264boostpulse_duration, after which speeds are allowed to drop below
265hispeed_freq according to load as usual.
266
267boostpulse_duration: Length of time to hold CPU speed at hispeed_freq
268on a write to boostpulse, before allowing speed to drop according to
269load as usual. Default is 80000 uS.
270
1963. The Governor Interface in the CPUfreq Core 2713. The Governor Interface in the CPUfreq Core
197============================================= 272=============================================
198 273
diff --git a/Documentation/hid/uhid.txt b/Documentation/hid/uhid.txt
new file mode 100644
index 00000000000..4627c4241ec
--- /dev/null
+++ b/Documentation/hid/uhid.txt
@@ -0,0 +1,169 @@
1 UHID - User-space I/O driver support for HID subsystem
2 ========================================================
3
4The HID subsystem needs two kinds of drivers. In this document we call them:
5
6 1. The "HID I/O Driver" is the driver that performs raw data I/O to the
7 low-level device. Internally, they register an hid_ll_driver structure with
8 the HID core. They perform device setup, read raw data from the device and
9 push it into the HID subsystem and they provide a callback so the HID
10 subsystem can send data to the device.
11
12 2. The "HID Device Driver" is the driver that parses HID reports and reacts on
13 them. There are generic drivers like "generic-usb" and "generic-bluetooth"
14 which adhere to the HID specification and provide the standardizes features.
15 But there may be special drivers and quirks for each non-standard device out
16 there. Internally, they use the hid_driver structure.
17
18Historically, the USB stack was the first subsystem to provide an HID I/O
19Driver. However, other standards like Bluetooth have adopted the HID specs and
20may provide HID I/O Drivers, too. The UHID driver allows to implement HID I/O
21Drivers in user-space and feed the data into the kernel HID-subsystem.
22
23This allows user-space to operate on the same level as USB-HID, Bluetooth-HID
24and similar. It does not provide a way to write HID Device Drivers, though. Use
25hidraw for this purpose.
26
27There is an example user-space application in ./samples/uhid/uhid-example.c
28
29The UHID API
30------------
31
32UHID is accessed through a character misc-device. The minor-number is allocated
33dynamically so you need to rely on udev (or similar) to create the device node.
34This is /dev/uhid by default.
35
36If a new device is detected by your HID I/O Driver and you want to register this
37device with the HID subsystem, then you need to open /dev/uhid once for each
38device you want to register. All further communication is done by read()'ing or
39write()'ing "struct uhid_event" objects. Non-blocking operations are supported
40by setting O_NONBLOCK.
41
42struct uhid_event {
43 __u32 type;
44 union {
45 struct uhid_create_req create;
46 struct uhid_data_req data;
47 ...
48 } u;
49};
50
51The "type" field contains the ID of the event. Depending on the ID different
52payloads are sent. You must not split a single event across multiple read()'s or
53multiple write()'s. A single event must always be sent as a whole. Furthermore,
54only a single event can be sent per read() or write(). Pending data is ignored.
55If you want to handle multiple events in a single syscall, then use vectored
56I/O with readv()/writev().
57
58The first thing you should do is sending an UHID_CREATE event. This will
59register the device. UHID will respond with an UHID_START event. You can now
60start sending data to and reading data from UHID. However, unless UHID sends the
61UHID_OPEN event, the internally attached HID Device Driver has no user attached.
62That is, you might put your device asleep unless you receive the UHID_OPEN
63event. If you receive the UHID_OPEN event, you should start I/O. If the last
64user closes the HID device, you will receive an UHID_CLOSE event. This may be
65followed by an UHID_OPEN event again and so on. There is no need to perform
66reference-counting in user-space. That is, you will never receive multiple
67UHID_OPEN events without an UHID_CLOSE event. The HID subsystem performs
68ref-counting for you.
69You may decide to ignore UHID_OPEN/UHID_CLOSE, though. I/O is allowed even
70though the device may have no users.
71
72If you want to send data to the HID subsystem, you send an HID_INPUT event with
73your raw data payload. If the kernel wants to send data to the device, you will
74read an UHID_OUTPUT or UHID_OUTPUT_EV event.
75
76If your device disconnects, you should send an UHID_DESTROY event. This will
77unregister the device. You can now send UHID_CREATE again to register a new
78device.
79If you close() the fd, the device is automatically unregistered and destroyed
80internally.
81
82write()
83-------
84write() allows you to modify the state of the device and feed input data into
85the kernel. The following types are supported: UHID_CREATE, UHID_DESTROY and
86UHID_INPUT. The kernel will parse the event immediately and if the event ID is
87not supported, it will return -EOPNOTSUPP. If the payload is invalid, then
88-EINVAL is returned, otherwise, the amount of data that was read is returned and
89the request was handled successfully.
90
91 UHID_CREATE:
92 This creates the internal HID device. No I/O is possible until you send this
93 event to the kernel. The payload is of type struct uhid_create_req and
94 contains information about your device. You can start I/O now.
95
96 UHID_DESTROY:
97 This destroys the internal HID device. No further I/O will be accepted. There
98 may still be pending messages that you can receive with read() but no further
99 UHID_INPUT events can be sent to the kernel.
100 You can create a new device by sending UHID_CREATE again. There is no need to
101 reopen the character device.
102
103 UHID_INPUT:
104 You must send UHID_CREATE before sending input to the kernel! This event
105 contains a data-payload. This is the raw data that you read from your device.
106 The kernel will parse the HID reports and react on it.
107
108 UHID_FEATURE_ANSWER:
109 If you receive a UHID_FEATURE request you must answer with this request. You
110 must copy the "id" field from the request into the answer. Set the "err" field
111 to 0 if no error occured or to EIO if an I/O error occurred.
112 If "err" is 0 then you should fill the buffer of the answer with the results
113 of the feature request and set "size" correspondingly.
114
115read()
116------
117read() will return a queued ouput report. These output reports can be of type
118UHID_START, UHID_STOP, UHID_OPEN, UHID_CLOSE, UHID_OUTPUT or UHID_OUTPUT_EV. No
119reaction is required to any of them but you should handle them according to your
120needs. Only UHID_OUTPUT and UHID_OUTPUT_EV have payloads.
121
122 UHID_START:
123 This is sent when the HID device is started. Consider this as an answer to
124 UHID_CREATE. This is always the first event that is sent.
125
126 UHID_STOP:
127 This is sent when the HID device is stopped. Consider this as an answer to
128 UHID_DESTROY.
129 If the kernel HID device driver closes the device manually (that is, you
130 didn't send UHID_DESTROY) then you should consider this device closed and send
131 an UHID_DESTROY event. You may want to reregister your device, though. This is
132 always the last message that is sent to you unless you reopen the device with
133 UHID_CREATE.
134
135 UHID_OPEN:
136 This is sent when the HID device is opened. That is, the data that the HID
137 device provides is read by some other process. You may ignore this event but
138 it is useful for power-management. As long as you haven't received this event
139 there is actually no other process that reads your data so there is no need to
140 send UHID_INPUT events to the kernel.
141
142 UHID_CLOSE:
143 This is sent when there are no more processes which read the HID data. It is
144 the counterpart of UHID_OPEN and you may as well ignore this event.
145
146 UHID_OUTPUT:
147 This is sent if the HID device driver wants to send raw data to the I/O
148 device. You should read the payload and forward it to the device. The payload
149 is of type "struct uhid_data_req".
150 This may be received even though you haven't received UHID_OPEN, yet.
151
152 UHID_OUTPUT_EV:
153 Same as UHID_OUTPUT but this contains a "struct input_event" as payload. This
154 is called for force-feedback, LED or similar events which are received through
155 an input device by the HID subsystem. You should convert this into raw reports
156 and send them to your device similar to events of type UHID_OUTPUT.
157
158 UHID_FEATURE:
159 This event is sent if the kernel driver wants to perform a feature request as
160 described in the HID specs. The report-type and report-number are available in
161 the payload.
162 The kernel serializes feature requests so there will never be two in parallel.
163 However, if you fail to respond with a UHID_FEATURE_ANSWER in a time-span of 5
164 seconds, then the requests will be dropped and a new one might be sent.
165 Therefore, the payload also contains an "id" field that identifies every
166 request.
167
168Document by:
169 David Herrmann <dh.herrmann@googlemail.com>
diff --git a/Documentation/power/runtime_pm.txt b/Documentation/power/runtime_pm.txt
index 6ade987ecb6..a6b34307dec 100644
--- a/Documentation/power/runtime_pm.txt
+++ b/Documentation/power/runtime_pm.txt
@@ -469,6 +469,7 @@ pm_runtime_autosuspend()
469pm_runtime_resume() 469pm_runtime_resume()
470pm_runtime_get_sync() 470pm_runtime_get_sync()
471pm_runtime_put_sync_suspend() 471pm_runtime_put_sync_suspend()
472pm_runtime_put_sync_autosuspend()
472 473
4735. Run-time PM Initialization, Device Probing and Removal 4745. Run-time PM Initialization, Device Probing and Removal
474 475
diff --git a/MAINTAINERS b/MAINTAINERS
index 9b893d75d85..105683a48f9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6358,6 +6358,13 @@ S: Maintained
6358F: Documentation/filesystems/ufs.txt 6358F: Documentation/filesystems/ufs.txt
6359F: fs/ufs/ 6359F: fs/ufs/
6360 6360
6361UHID USERSPACE HID IO DRIVER:
6362M: David Herrmann <dh.herrmann@googlemail.com>
6363L: linux-input@vger.kernel.org
6364S: Maintained
6365F: drivers/hid/uhid.c
6366F: include/linux/uhid.h
6367
6361ULTRA-WIDEBAND (UWB) SUBSYSTEM: 6368ULTRA-WIDEBAND (UWB) SUBSYSTEM:
6362L: linux-usb@vger.kernel.org 6369L: linux-usb@vger.kernel.org
6363S: Orphan 6370S: Orphan
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 17d179cb074..b9d60775cb8 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1707,6 +1707,15 @@ config DEPRECATED_PARAM_STRUCT
1707 This was deprecated in 2001 and announced to live on for 5 years. 1707 This was deprecated in 2001 and announced to live on for 5 years.
1708 Some old boot loaders still use this way. 1708 Some old boot loaders still use this way.
1709 1709
1710config ARM_FLUSH_CONSOLE_ON_RESTART
1711 bool "Force flush the console on restart"
1712 help
1713 If the console is locked while the system is rebooted, the messages
1714 in the temporary logbuffer would not have propogated to all the
1715 console drivers. This option forces the console lock to be
1716 released if it failed to be acquired, which will cause all the
1717 pending messages to be flushed.
1718
1710endmenu 1719endmenu
1711 1720
1712menu "Boot options" 1721menu "Boot options"
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 4d1f07d5fa9..caddb9d35b7 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -657,6 +657,8 @@ proc_types:
657@ b __arm6_mmu_cache_off 657@ b __arm6_mmu_cache_off
658@ b __armv3_mmu_cache_flush 658@ b __armv3_mmu_cache_flush
659 659
660#if !defined(CONFIG_CPU_V7)
661 /* This collides with some V7 IDs, preventing correct detection */
660 .word 0x00000000 @ old ARM ID 662 .word 0x00000000 @ old ARM ID
661 .word 0x0000f000 663 .word 0x0000f000
662 mov pc, lr 664 mov pc, lr
@@ -665,6 +667,7 @@ proc_types:
665 THUMB( nop ) 667 THUMB( nop )
666 mov pc, lr 668 mov pc, lr
667 THUMB( nop ) 669 THUMB( nop )
670#endif
668 671
669 .word 0x41007000 @ ARM7/710 672 .word 0x41007000 @ ARM7/710
670 .word 0xfff8fe00 673 .word 0xfff8fe00
diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig
index 4b71766fb21..638256600ff 100644
--- a/arch/arm/common/Kconfig
+++ b/arch/arm/common/Kconfig
@@ -39,3 +39,53 @@ config SHARP_PARAM
39 39
40config SHARP_SCOOP 40config SHARP_SCOOP
41 bool 41 bool
42
43config FIQ_GLUE
44 bool
45 select FIQ
46
47config FIQ_DEBUGGER
48 bool "FIQ Mode Serial Debugger"
49 select FIQ
50 select FIQ_GLUE
51 default n
52 help
53 The FIQ serial debugger can accept commands even when the
54 kernel is unresponsive due to being stuck with interrupts
55 disabled.
56
57
58config FIQ_DEBUGGER_NO_SLEEP
59 bool "Keep serial debugger active"
60 depends on FIQ_DEBUGGER
61 default n
62 help
63 Enables the serial debugger at boot. Passing
64 fiq_debugger.no_sleep on the kernel commandline will
65 override this config option.
66
67config FIQ_DEBUGGER_WAKEUP_IRQ_ALWAYS_ON
68 bool "Don't disable wakeup IRQ when debugger is active"
69 depends on FIQ_DEBUGGER
70 default n
71 help
72 Don't disable the wakeup irq when enabling the uart clock. This will
73 cause extra interrupts, but it makes the serial debugger usable with
74 on some MSM radio builds that ignore the uart clock request in power
75 collapse.
76
77config FIQ_DEBUGGER_CONSOLE
78 bool "Console on FIQ Serial Debugger port"
79 depends on FIQ_DEBUGGER
80 default n
81 help
82 Enables a console so that printk messages are displayed on
83 the debugger serial port as the occur.
84
85config FIQ_DEBUGGER_CONSOLE_DEFAULT_ENABLE
86 bool "Put the FIQ debugger into console mode by default"
87 depends on FIQ_DEBUGGER_CONSOLE
88 default n
89 help
90 If enabled, this puts the fiq debugger into console mode by default.
91 Otherwise, the fiq debugger will start out in debug mode.
diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
index 6ea9b6f3607..3ab5d765fed 100644
--- a/arch/arm/common/Makefile
+++ b/arch/arm/common/Makefile
@@ -17,3 +17,5 @@ obj-$(CONFIG_ARCH_IXP2000) += uengine.o
17obj-$(CONFIG_ARCH_IXP23XX) += uengine.o 17obj-$(CONFIG_ARCH_IXP23XX) += uengine.o
18obj-$(CONFIG_PCI_HOST_ITE8152) += it8152.o 18obj-$(CONFIG_PCI_HOST_ITE8152) += it8152.o
19obj-$(CONFIG_ARM_TIMER_SP804) += timer-sp.o 19obj-$(CONFIG_ARM_TIMER_SP804) += timer-sp.o
20obj-$(CONFIG_FIQ_GLUE) += fiq_glue.o fiq_glue_setup.o
21obj-$(CONFIG_FIQ_DEBUGGER) += fiq_debugger.o
diff --git a/arch/arm/common/fiq_debugger.c b/arch/arm/common/fiq_debugger.c
new file mode 100644
index 00000000000..3ed18ae2ed8
--- /dev/null
+++ b/arch/arm/common/fiq_debugger.c
@@ -0,0 +1,1196 @@
1/*
2 * arch/arm/common/fiq_debugger.c
3 *
4 * Serial Debugger Interface accessed through an FIQ interrupt.
5 *
6 * Copyright (C) 2008 Google, Inc.
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
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
18#include <stdarg.h>
19#include <linux/module.h>
20#include <linux/io.h>
21#include <linux/console.h>
22#include <linux/interrupt.h>
23#include <linux/clk.h>
24#include <linux/platform_device.h>
25#include <linux/kernel_stat.h>
26#include <linux/irq.h>
27#include <linux/delay.h>
28#include <linux/sched.h>
29#include <linux/slab.h>
30#include <linux/smp.h>
31#include <linux/timer.h>
32#include <linux/tty.h>
33#include <linux/tty_flip.h>
34#include <linux/wakelock.h>
35
36#include <asm/fiq_debugger.h>
37#include <asm/fiq_glue.h>
38#include <asm/stacktrace.h>
39
40#include <mach/system.h>
41
42#include <linux/uaccess.h>
43
44#include "fiq_debugger_ringbuf.h"
45
46#define DEBUG_MAX 64
47#define MAX_UNHANDLED_FIQ_COUNT 1000000
48
49#define THREAD_INFO(sp) ((struct thread_info *) \
50 ((unsigned long)(sp) & ~(THREAD_SIZE - 1)))
51
52struct fiq_debugger_state {
53 struct fiq_glue_handler handler;
54
55 int fiq;
56 int uart_irq;
57 int signal_irq;
58 int wakeup_irq;
59 bool wakeup_irq_no_set_wake;
60 struct clk *clk;
61 struct fiq_debugger_pdata *pdata;
62 struct platform_device *pdev;
63
64 char debug_cmd[DEBUG_MAX];
65 int debug_busy;
66 int debug_abort;
67
68 char debug_buf[DEBUG_MAX];
69 int debug_count;
70
71 bool no_sleep;
72 bool debug_enable;
73 bool ignore_next_wakeup_irq;
74 struct timer_list sleep_timer;
75 spinlock_t sleep_timer_lock;
76 bool uart_enabled;
77 struct wake_lock debugger_wake_lock;
78 bool console_enable;
79 int current_cpu;
80 atomic_t unhandled_fiq_count;
81 bool in_fiq;
82
83#ifdef CONFIG_FIQ_DEBUGGER_CONSOLE
84 struct console console;
85 struct tty_driver *tty_driver;
86 struct tty_struct *tty;
87 int tty_open_count;
88 struct fiq_debugger_ringbuf *tty_rbuf;
89 bool syslog_dumping;
90#endif
91
92 unsigned int last_irqs[NR_IRQS];
93 unsigned int last_local_timer_irqs[NR_CPUS];
94};
95
96#ifdef CONFIG_FIQ_DEBUGGER_NO_SLEEP
97static bool initial_no_sleep = true;
98#else
99static bool initial_no_sleep;
100#endif
101
102#ifdef CONFIG_FIQ_DEBUGGER_CONSOLE_DEFAULT_ENABLE
103static bool initial_debug_enable = true;
104static bool initial_console_enable = true;
105#else
106static bool initial_debug_enable;
107static bool initial_console_enable;
108#endif
109
110module_param_named(no_sleep, initial_no_sleep, bool, 0644);
111module_param_named(debug_enable, initial_debug_enable, bool, 0644);
112module_param_named(console_enable, initial_console_enable, bool, 0644);
113
114#ifdef CONFIG_FIQ_DEBUGGER_WAKEUP_IRQ_ALWAYS_ON
115static inline void enable_wakeup_irq(struct fiq_debugger_state *state) {}
116static inline void disable_wakeup_irq(struct fiq_debugger_state *state) {}
117#else
118static inline void enable_wakeup_irq(struct fiq_debugger_state *state)
119{
120 if (state->wakeup_irq < 0)
121 return;
122 enable_irq(state->wakeup_irq);
123 if (!state->wakeup_irq_no_set_wake)
124 enable_irq_wake(state->wakeup_irq);
125}
126static inline void disable_wakeup_irq(struct fiq_debugger_state *state)
127{
128 if (state->wakeup_irq < 0)
129 return;
130 disable_irq_nosync(state->wakeup_irq);
131 if (!state->wakeup_irq_no_set_wake)
132 disable_irq_wake(state->wakeup_irq);
133}
134#endif
135
136static bool inline debug_have_fiq(struct fiq_debugger_state *state)
137{
138 return (state->fiq >= 0);
139}
140
141static void debug_force_irq(struct fiq_debugger_state *state)
142{
143 unsigned int irq = state->signal_irq;
144
145 if (WARN_ON(!debug_have_fiq(state)))
146 return;
147 if (state->pdata->force_irq) {
148 state->pdata->force_irq(state->pdev, irq);
149 } else {
150 struct irq_chip *chip = irq_get_chip(irq);
151 if (chip && chip->irq_retrigger)
152 chip->irq_retrigger(irq_get_irq_data(irq));
153 }
154}
155
156static void debug_uart_enable(struct fiq_debugger_state *state)
157{
158 if (state->clk)
159 clk_enable(state->clk);
160 if (state->pdata->uart_enable)
161 state->pdata->uart_enable(state->pdev);
162}
163
164static void debug_uart_disable(struct fiq_debugger_state *state)
165{
166 if (state->pdata->uart_disable)
167 state->pdata->uart_disable(state->pdev);
168 if (state->clk)
169 clk_disable(state->clk);
170}
171
172static void debug_uart_flush(struct fiq_debugger_state *state)
173{
174 if (state->pdata->uart_flush)
175 state->pdata->uart_flush(state->pdev);
176}
177
178static void debug_puts(struct fiq_debugger_state *state, char *s)
179{
180 unsigned c;
181 while ((c = *s++)) {
182 if (c == '\n')
183 state->pdata->uart_putc(state->pdev, '\r');
184 state->pdata->uart_putc(state->pdev, c);
185 }
186}
187
188static void debug_prompt(struct fiq_debugger_state *state)
189{
190 debug_puts(state, "debug> ");
191}
192
193int log_buf_copy(char *dest, int idx, int len);
194static void dump_kernel_log(struct fiq_debugger_state *state)
195{
196 char buf[1024];
197 int idx = 0;
198 int ret;
199 int saved_oip;
200
201 /* setting oops_in_progress prevents log_buf_copy()
202 * from trying to take a spinlock which will make it
203 * very unhappy in some cases...
204 */
205 saved_oip = oops_in_progress;
206 oops_in_progress = 1;
207 for (;;) {
208 ret = log_buf_copy(buf, idx, 1023);
209 if (ret <= 0)
210 break;
211 buf[ret] = 0;
212 debug_puts(state, buf);
213 idx += ret;
214 }
215 oops_in_progress = saved_oip;
216}
217
218static char *mode_name(unsigned cpsr)
219{
220 switch (cpsr & MODE_MASK) {
221 case USR_MODE: return "USR";
222 case FIQ_MODE: return "FIQ";
223 case IRQ_MODE: return "IRQ";
224 case SVC_MODE: return "SVC";
225 case ABT_MODE: return "ABT";
226 case UND_MODE: return "UND";
227 case SYSTEM_MODE: return "SYS";
228 default: return "???";
229 }
230}
231
232static int debug_printf(void *cookie, const char *fmt, ...)
233{
234 struct fiq_debugger_state *state = cookie;
235 char buf[256];
236 va_list ap;
237
238 va_start(ap, fmt);
239 vsnprintf(buf, sizeof(buf), fmt, ap);
240 va_end(ap);
241
242 debug_puts(state, buf);
243 return state->debug_abort;
244}
245
246/* Safe outside fiq context */
247static int debug_printf_nfiq(void *cookie, const char *fmt, ...)
248{
249 struct fiq_debugger_state *state = cookie;
250 char buf[256];
251 va_list ap;
252 unsigned long irq_flags;
253
254 va_start(ap, fmt);
255 vsnprintf(buf, 128, fmt, ap);
256 va_end(ap);
257
258 local_irq_save(irq_flags);
259 debug_puts(state, buf);
260 debug_uart_flush(state);
261 local_irq_restore(irq_flags);
262 return state->debug_abort;
263}
264
265static void dump_regs(struct fiq_debugger_state *state, unsigned *regs)
266{
267 debug_printf(state, " r0 %08x r1 %08x r2 %08x r3 %08x\n",
268 regs[0], regs[1], regs[2], regs[3]);
269 debug_printf(state, " r4 %08x r5 %08x r6 %08x r7 %08x\n",
270 regs[4], regs[5], regs[6], regs[7]);
271 debug_printf(state, " r8 %08x r9 %08x r10 %08x r11 %08x mode %s\n",
272 regs[8], regs[9], regs[10], regs[11],
273 mode_name(regs[16]));
274 if ((regs[16] & MODE_MASK) == USR_MODE)
275 debug_printf(state, " ip %08x sp %08x lr %08x pc %08x "
276 "cpsr %08x\n", regs[12], regs[13], regs[14],
277 regs[15], regs[16]);
278 else
279 debug_printf(state, " ip %08x sp %08x lr %08x pc %08x "
280 "cpsr %08x spsr %08x\n", regs[12], regs[13],
281 regs[14], regs[15], regs[16], regs[17]);
282}
283
284struct mode_regs {
285 unsigned long sp_svc;
286 unsigned long lr_svc;
287 unsigned long spsr_svc;
288
289 unsigned long sp_abt;
290 unsigned long lr_abt;
291 unsigned long spsr_abt;
292
293 unsigned long sp_und;
294 unsigned long lr_und;
295 unsigned long spsr_und;
296
297 unsigned long sp_irq;
298 unsigned long lr_irq;
299 unsigned long spsr_irq;
300
301 unsigned long r8_fiq;
302 unsigned long r9_fiq;
303 unsigned long r10_fiq;
304 unsigned long r11_fiq;
305 unsigned long r12_fiq;
306 unsigned long sp_fiq;
307 unsigned long lr_fiq;
308 unsigned long spsr_fiq;
309};
310
311void __naked get_mode_regs(struct mode_regs *regs)
312{
313 asm volatile (
314 "mrs r1, cpsr\n"
315 "msr cpsr_c, #0xd3 @(SVC_MODE | PSR_I_BIT | PSR_F_BIT)\n"
316 "stmia r0!, {r13 - r14}\n"
317 "mrs r2, spsr\n"
318 "msr cpsr_c, #0xd7 @(ABT_MODE | PSR_I_BIT | PSR_F_BIT)\n"
319 "stmia r0!, {r2, r13 - r14}\n"
320 "mrs r2, spsr\n"
321 "msr cpsr_c, #0xdb @(UND_MODE | PSR_I_BIT | PSR_F_BIT)\n"
322 "stmia r0!, {r2, r13 - r14}\n"
323 "mrs r2, spsr\n"
324 "msr cpsr_c, #0xd2 @(IRQ_MODE | PSR_I_BIT | PSR_F_BIT)\n"
325 "stmia r0!, {r2, r13 - r14}\n"
326 "mrs r2, spsr\n"
327 "msr cpsr_c, #0xd1 @(FIQ_MODE | PSR_I_BIT | PSR_F_BIT)\n"
328 "stmia r0!, {r2, r8 - r14}\n"
329 "mrs r2, spsr\n"
330 "stmia r0!, {r2}\n"
331 "msr cpsr_c, r1\n"
332 "bx lr\n");
333}
334
335
336static void dump_allregs(struct fiq_debugger_state *state, unsigned *regs)
337{
338 struct mode_regs mode_regs;
339 dump_regs(state, regs);
340 get_mode_regs(&mode_regs);
341 debug_printf(state, " svc: sp %08x lr %08x spsr %08x\n",
342 mode_regs.sp_svc, mode_regs.lr_svc, mode_regs.spsr_svc);
343 debug_printf(state, " abt: sp %08x lr %08x spsr %08x\n",
344 mode_regs.sp_abt, mode_regs.lr_abt, mode_regs.spsr_abt);
345 debug_printf(state, " und: sp %08x lr %08x spsr %08x\n",
346 mode_regs.sp_und, mode_regs.lr_und, mode_regs.spsr_und);
347 debug_printf(state, " irq: sp %08x lr %08x spsr %08x\n",
348 mode_regs.sp_irq, mode_regs.lr_irq, mode_regs.spsr_irq);
349 debug_printf(state, " fiq: r8 %08x r9 %08x r10 %08x r11 %08x "
350 "r12 %08x\n",
351 mode_regs.r8_fiq, mode_regs.r9_fiq, mode_regs.r10_fiq,
352 mode_regs.r11_fiq, mode_regs.r12_fiq);
353 debug_printf(state, " fiq: sp %08x lr %08x spsr %08x\n",
354 mode_regs.sp_fiq, mode_regs.lr_fiq, mode_regs.spsr_fiq);
355}
356
357static void dump_irqs(struct fiq_debugger_state *state)
358{
359 int n;
360 unsigned int cpu;
361
362 debug_printf(state, "irqnr total since-last status name\n");
363 for (n = 0; n < NR_IRQS; n++) {
364 struct irqaction *act = irq_desc[n].action;
365 if (!act && !kstat_irqs(n))
366 continue;
367 debug_printf(state, "%5d: %10u %11u %8x %s\n", n,
368 kstat_irqs(n),
369 kstat_irqs(n) - state->last_irqs[n],
370 irq_desc[n].status_use_accessors,
371 (act && act->name) ? act->name : "???");
372 state->last_irqs[n] = kstat_irqs(n);
373 }
374
375 for (cpu = 0; cpu < NR_CPUS; cpu++) {
376
377 debug_printf(state, "LOC %d: %10u %11u\n", cpu,
378 __IRQ_STAT(cpu, local_timer_irqs),
379 __IRQ_STAT(cpu, local_timer_irqs) -
380 state->last_local_timer_irqs[cpu]);
381 state->last_local_timer_irqs[cpu] =
382 __IRQ_STAT(cpu, local_timer_irqs);
383 }
384}
385
386struct stacktrace_state {
387 struct fiq_debugger_state *state;
388 unsigned int depth;
389};
390
391static int report_trace(struct stackframe *frame, void *d)
392{
393 struct stacktrace_state *sts = d;
394
395 if (sts->depth) {
396 debug_printf(sts->state,
397 " pc: %p (%pF), lr %p (%pF), sp %p, fp %p\n",
398 frame->pc, frame->pc, frame->lr, frame->lr,
399 frame->sp, frame->fp);
400 sts->depth--;
401 return 0;
402 }
403 debug_printf(sts->state, " ...\n");
404
405 return sts->depth == 0;
406}
407
408struct frame_tail {
409 struct frame_tail *fp;
410 unsigned long sp;
411 unsigned long lr;
412} __attribute__((packed));
413
414static struct frame_tail *user_backtrace(struct fiq_debugger_state *state,
415 struct frame_tail *tail)
416{
417 struct frame_tail buftail[2];
418
419 /* Also check accessibility of one struct frame_tail beyond */
420 if (!access_ok(VERIFY_READ, tail, sizeof(buftail))) {
421 debug_printf(state, " invalid frame pointer %p\n", tail);
422 return NULL;
423 }
424 if (__copy_from_user_inatomic(buftail, tail, sizeof(buftail))) {
425 debug_printf(state,
426 " failed to copy frame pointer %p\n", tail);
427 return NULL;
428 }
429
430 debug_printf(state, " %p\n", buftail[0].lr);
431
432 /* frame pointers should strictly progress back up the stack
433 * (towards higher addresses) */
434 if (tail >= buftail[0].fp)
435 return NULL;
436
437 return buftail[0].fp-1;
438}
439
440void dump_stacktrace(struct fiq_debugger_state *state,
441 struct pt_regs * const regs, unsigned int depth, void *ssp)
442{
443 struct frame_tail *tail;
444 struct thread_info *real_thread_info = THREAD_INFO(ssp);
445 struct stacktrace_state sts;
446
447 sts.depth = depth;
448 sts.state = state;
449 *current_thread_info() = *real_thread_info;
450
451 if (!current)
452 debug_printf(state, "current NULL\n");
453 else
454 debug_printf(state, "pid: %d comm: %s\n",
455 current->pid, current->comm);
456 dump_regs(state, (unsigned *)regs);
457
458 if (!user_mode(regs)) {
459 struct stackframe frame;
460 frame.fp = regs->ARM_fp;
461 frame.sp = regs->ARM_sp;
462 frame.lr = regs->ARM_lr;
463 frame.pc = regs->ARM_pc;
464 debug_printf(state,
465 " pc: %p (%pF), lr %p (%pF), sp %p, fp %p\n",
466 regs->ARM_pc, regs->ARM_pc, regs->ARM_lr, regs->ARM_lr,
467 regs->ARM_sp, regs->ARM_fp);
468 walk_stackframe(&frame, report_trace, &sts);
469 return;
470 }
471
472 tail = ((struct frame_tail *) regs->ARM_fp) - 1;
473 while (depth-- && tail && !((unsigned long) tail & 3))
474 tail = user_backtrace(state, tail);
475}
476
477static void do_ps(struct fiq_debugger_state *state)
478{
479 struct task_struct *g;
480 struct task_struct *p;
481 unsigned task_state;
482 static const char stat_nam[] = "RSDTtZX";
483
484 debug_printf(state, "pid ppid prio task pc\n");
485 read_lock(&tasklist_lock);
486 do_each_thread(g, p) {
487 task_state = p->state ? __ffs(p->state) + 1 : 0;
488 debug_printf(state,
489 "%5d %5d %4d ", p->pid, p->parent->pid, p->prio);
490 debug_printf(state, "%-13.13s %c", p->comm,
491 task_state >= sizeof(stat_nam) ? '?' : stat_nam[task_state]);
492 if (task_state == TASK_RUNNING)
493 debug_printf(state, " running\n");
494 else
495 debug_printf(state, " %08lx\n", thread_saved_pc(p));
496 } while_each_thread(g, p);
497 read_unlock(&tasklist_lock);
498}
499
500#ifdef CONFIG_FIQ_DEBUGGER_CONSOLE
501static void begin_syslog_dump(struct fiq_debugger_state *state)
502{
503 state->syslog_dumping = true;
504}
505
506static void end_syslog_dump(struct fiq_debugger_state *state)
507{
508 state->syslog_dumping = false;
509}
510#else
511extern int do_syslog(int type, char __user *bug, int count);
512static void begin_syslog_dump(struct fiq_debugger_state *state)
513{
514 do_syslog(5 /* clear */, NULL, 0);
515}
516
517static void end_syslog_dump(struct fiq_debugger_state *state)
518{
519 char buf[128];
520 int ret;
521 int idx = 0;
522
523 while (1) {
524 ret = log_buf_copy(buf, idx, sizeof(buf) - 1);
525 if (ret <= 0)
526 break;
527 buf[ret] = 0;
528 debug_printf(state, "%s", buf);
529 idx += ret;
530 }
531}
532#endif
533
534static void do_sysrq(struct fiq_debugger_state *state, char rq)
535{
536 begin_syslog_dump(state);
537 handle_sysrq(rq);
538 end_syslog_dump(state);
539}
540
541/* This function CANNOT be called in FIQ context */
542static void debug_irq_exec(struct fiq_debugger_state *state, char *cmd)
543{
544 if (!strcmp(cmd, "ps"))
545 do_ps(state);
546 if (!strcmp(cmd, "sysrq"))
547 do_sysrq(state, 'h');
548 if (!strncmp(cmd, "sysrq ", 6))
549 do_sysrq(state, cmd[6]);
550}
551
552static void debug_help(struct fiq_debugger_state *state)
553{
554 debug_printf(state, "FIQ Debugger commands:\n"
555 " pc PC status\n"
556 " regs Register dump\n"
557 " allregs Extended Register dump\n"
558 " bt Stack trace\n"
559 " reboot Reboot\n"
560 " irqs Interupt status\n"
561 " kmsg Kernel log\n"
562 " version Kernel version\n");
563 debug_printf(state, " sleep Allow sleep while in FIQ\n"
564 " nosleep Disable sleep while in FIQ\n"
565 " console Switch terminal to console\n"
566 " cpu Current CPU\n"
567 " cpu <number> Switch to CPU<number>\n");
568 debug_printf(state, " ps Process list\n"
569 " sysrq sysrq options\n"
570 " sysrq <param> Execute sysrq with <param>\n");
571}
572
573static void take_affinity(void *info)
574{
575 struct fiq_debugger_state *state = info;
576 struct cpumask cpumask;
577
578 cpumask_clear(&cpumask);
579 cpumask_set_cpu(get_cpu(), &cpumask);
580
581 irq_set_affinity(state->uart_irq, &cpumask);
582}
583
584static void switch_cpu(struct fiq_debugger_state *state, int cpu)
585{
586 if (!debug_have_fiq(state))
587 smp_call_function_single(cpu, take_affinity, state, false);
588 state->current_cpu = cpu;
589}
590
591static bool debug_fiq_exec(struct fiq_debugger_state *state,
592 const char *cmd, unsigned *regs, void *svc_sp)
593{
594 bool signal_helper = false;
595
596 if (!strcmp(cmd, "help") || !strcmp(cmd, "?")) {
597 debug_help(state);
598 } else if (!strcmp(cmd, "pc")) {
599 debug_printf(state, " pc %08x cpsr %08x mode %s\n",
600 regs[15], regs[16], mode_name(regs[16]));
601 } else if (!strcmp(cmd, "regs")) {
602 dump_regs(state, regs);
603 } else if (!strcmp(cmd, "allregs")) {
604 dump_allregs(state, regs);
605 } else if (!strcmp(cmd, "bt")) {
606 dump_stacktrace(state, (struct pt_regs *)regs, 100, svc_sp);
607 } else if (!strcmp(cmd, "reboot")) {
608 arch_reset(0, 0);
609 } else if (!strcmp(cmd, "irqs")) {
610 dump_irqs(state);
611 } else if (!strcmp(cmd, "kmsg")) {
612 dump_kernel_log(state);
613 } else if (!strcmp(cmd, "version")) {
614 debug_printf(state, "%s\n", linux_banner);
615 } else if (!strcmp(cmd, "sleep")) {
616 state->no_sleep = false;
617 debug_printf(state, "enabling sleep\n");
618 } else if (!strcmp(cmd, "nosleep")) {
619 state->no_sleep = true;
620 debug_printf(state, "disabling sleep\n");
621 } else if (!strcmp(cmd, "console")) {
622 state->console_enable = true;
623 debug_printf(state, "console mode\n");
624 } else if (!strcmp(cmd, "cpu")) {
625 debug_printf(state, "cpu %d\n", state->current_cpu);
626 } else if (!strncmp(cmd, "cpu ", 4)) {
627 unsigned long cpu = 0;
628 if (strict_strtoul(cmd + 4, 10, &cpu) == 0)
629 switch_cpu(state, cpu);
630 else
631 debug_printf(state, "invalid cpu\n");
632 debug_printf(state, "cpu %d\n", state->current_cpu);
633 } else {
634 if (state->debug_busy) {
635 debug_printf(state,
636 "command processor busy. trying to abort.\n");
637 state->debug_abort = -1;
638 } else {
639 strcpy(state->debug_cmd, cmd);
640 state->debug_busy = 1;
641 }
642
643 return true;
644 }
645 if (!state->console_enable)
646 debug_prompt(state);
647
648 return signal_helper;
649}
650
651static void sleep_timer_expired(unsigned long data)
652{
653 struct fiq_debugger_state *state = (struct fiq_debugger_state *)data;
654 unsigned long flags;
655
656 spin_lock_irqsave(&state->sleep_timer_lock, flags);
657 if (state->uart_enabled && !state->no_sleep) {
658 if (state->debug_enable && !state->console_enable) {
659 state->debug_enable = false;
660 debug_printf_nfiq(state, "suspending fiq debugger\n");
661 }
662 state->ignore_next_wakeup_irq = true;
663 debug_uart_disable(state);
664 state->uart_enabled = false;
665 enable_wakeup_irq(state);
666 }
667 wake_unlock(&state->debugger_wake_lock);
668 spin_unlock_irqrestore(&state->sleep_timer_lock, flags);
669}
670
671static void handle_wakeup(struct fiq_debugger_state *state)
672{
673 unsigned long flags;
674
675 spin_lock_irqsave(&state->sleep_timer_lock, flags);
676 if (state->wakeup_irq >= 0 && state->ignore_next_wakeup_irq) {
677 state->ignore_next_wakeup_irq = false;
678 } else if (!state->uart_enabled) {
679 wake_lock(&state->debugger_wake_lock);
680 debug_uart_enable(state);
681 state->uart_enabled = true;
682 disable_wakeup_irq(state);
683 mod_timer(&state->sleep_timer, jiffies + HZ / 2);
684 }
685 spin_unlock_irqrestore(&state->sleep_timer_lock, flags);
686}
687
688static irqreturn_t wakeup_irq_handler(int irq, void *dev)
689{
690 struct fiq_debugger_state *state = dev;
691
692 if (!state->no_sleep)
693 debug_puts(state, "WAKEUP\n");
694 handle_wakeup(state);
695
696 return IRQ_HANDLED;
697}
698
699
700static void debug_handle_irq_context(struct fiq_debugger_state *state)
701{
702 if (!state->no_sleep) {
703 unsigned long flags;
704
705 spin_lock_irqsave(&state->sleep_timer_lock, flags);
706 wake_lock(&state->debugger_wake_lock);
707 mod_timer(&state->sleep_timer, jiffies + HZ * 5);
708 spin_unlock_irqrestore(&state->sleep_timer_lock, flags);
709 }
710#if defined(CONFIG_FIQ_DEBUGGER_CONSOLE)
711 if (state->tty) {
712 int i;
713 int count = fiq_debugger_ringbuf_level(state->tty_rbuf);
714 for (i = 0; i < count; i++) {
715 int c = fiq_debugger_ringbuf_peek(state->tty_rbuf, 0);
716 tty_insert_flip_char(state->tty, c, TTY_NORMAL);
717 if (!fiq_debugger_ringbuf_consume(state->tty_rbuf, 1))
718 pr_warn("fiq tty failed to consume byte\n");
719 }
720 tty_flip_buffer_push(state->tty);
721 }
722#endif
723 if (state->debug_busy) {
724 debug_irq_exec(state, state->debug_cmd);
725 debug_prompt(state);
726 state->debug_busy = 0;
727 }
728}
729
730static int debug_getc(struct fiq_debugger_state *state)
731{
732 return state->pdata->uart_getc(state->pdev);
733}
734
735static bool debug_handle_uart_interrupt(struct fiq_debugger_state *state,
736 int this_cpu, void *regs, void *svc_sp)
737{
738 int c;
739 static int last_c;
740 int count = 0;
741 bool signal_helper = false;
742
743 if (this_cpu != state->current_cpu) {
744 if (state->in_fiq)
745 return false;
746
747 if (atomic_inc_return(&state->unhandled_fiq_count) !=
748 MAX_UNHANDLED_FIQ_COUNT)
749 return false;
750
751 debug_printf(state, "fiq_debugger: cpu %d not responding, "
752 "reverting to cpu %d\n", state->current_cpu,
753 this_cpu);
754
755 atomic_set(&state->unhandled_fiq_count, 0);
756 switch_cpu(state, this_cpu);
757 return false;
758 }
759
760 state->in_fiq = true;
761
762 while ((c = debug_getc(state)) != FIQ_DEBUGGER_NO_CHAR) {
763 count++;
764 if (!state->debug_enable) {
765 if ((c == 13) || (c == 10)) {
766 state->debug_enable = true;
767 state->debug_count = 0;
768 debug_prompt(state);
769 }
770 } else if (c == FIQ_DEBUGGER_BREAK) {
771 state->console_enable = false;
772 debug_puts(state, "fiq debugger mode\n");
773 state->debug_count = 0;
774 debug_prompt(state);
775#ifdef CONFIG_FIQ_DEBUGGER_CONSOLE
776 } else if (state->console_enable && state->tty_rbuf) {
777 fiq_debugger_ringbuf_push(state->tty_rbuf, c);
778 signal_helper = true;
779#endif
780 } else if ((c >= ' ') && (c < 127)) {
781 if (state->debug_count < (DEBUG_MAX - 1)) {
782 state->debug_buf[state->debug_count++] = c;
783 state->pdata->uart_putc(state->pdev, c);
784 }
785 } else if ((c == 8) || (c == 127)) {
786 if (state->debug_count > 0) {
787 state->debug_count--;
788 state->pdata->uart_putc(state->pdev, 8);
789 state->pdata->uart_putc(state->pdev, ' ');
790 state->pdata->uart_putc(state->pdev, 8);
791 }
792 } else if ((c == 13) || (c == 10)) {
793 if (c == '\r' || (c == '\n' && last_c != '\r')) {
794 state->pdata->uart_putc(state->pdev, '\r');
795 state->pdata->uart_putc(state->pdev, '\n');
796 }
797 if (state->debug_count) {
798 state->debug_buf[state->debug_count] = 0;
799 state->debug_count = 0;
800 signal_helper |=
801 debug_fiq_exec(state, state->debug_buf,
802 regs, svc_sp);
803 } else {
804 debug_prompt(state);
805 }
806 }
807 last_c = c;
808 }
809 debug_uart_flush(state);
810 if (state->pdata->fiq_ack)
811 state->pdata->fiq_ack(state->pdev, state->fiq);
812
813 /* poke sleep timer if necessary */
814 if (state->debug_enable && !state->no_sleep)
815 signal_helper = true;
816
817 atomic_set(&state->unhandled_fiq_count, 0);
818 state->in_fiq = false;
819
820 return signal_helper;
821}
822
823static void debug_fiq(struct fiq_glue_handler *h, void *regs, void *svc_sp)
824{
825 struct fiq_debugger_state *state =
826 container_of(h, struct fiq_debugger_state, handler);
827 unsigned int this_cpu = THREAD_INFO(svc_sp)->cpu;
828 bool need_irq;
829
830 need_irq = debug_handle_uart_interrupt(state, this_cpu, regs, svc_sp);
831 if (need_irq)
832 debug_force_irq(state);
833}
834
835/*
836 * When not using FIQs, we only use this single interrupt as an entry point.
837 * This just effectively takes over the UART interrupt and does all the work
838 * in this context.
839 */
840static irqreturn_t debug_uart_irq(int irq, void *dev)
841{
842 struct fiq_debugger_state *state = dev;
843 bool not_done;
844
845 handle_wakeup(state);
846
847 /* handle the debugger irq in regular context */
848 not_done = debug_handle_uart_interrupt(state, smp_processor_id(),
849 get_irq_regs(),
850 current_thread_info());
851 if (not_done)
852 debug_handle_irq_context(state);
853
854 return IRQ_HANDLED;
855}
856
857/*
858 * If FIQs are used, not everything can happen in fiq context.
859 * FIQ handler does what it can and then signals this interrupt to finish the
860 * job in irq context.
861 */
862static irqreturn_t debug_signal_irq(int irq, void *dev)
863{
864 struct fiq_debugger_state *state = dev;
865
866 if (state->pdata->force_irq_ack)
867 state->pdata->force_irq_ack(state->pdev, state->signal_irq);
868
869 debug_handle_irq_context(state);
870
871 return IRQ_HANDLED;
872}
873
874static void debug_resume(struct fiq_glue_handler *h)
875{
876 struct fiq_debugger_state *state =
877 container_of(h, struct fiq_debugger_state, handler);
878 if (state->pdata->uart_resume)
879 state->pdata->uart_resume(state->pdev);
880}
881
882#if defined(CONFIG_FIQ_DEBUGGER_CONSOLE)
883struct tty_driver *debug_console_device(struct console *co, int *index)
884{
885 struct fiq_debugger_state *state;
886 state = container_of(co, struct fiq_debugger_state, console);
887 *index = 0;
888 return state->tty_driver;
889}
890
891static void debug_console_write(struct console *co,
892 const char *s, unsigned int count)
893{
894 struct fiq_debugger_state *state;
895
896 state = container_of(co, struct fiq_debugger_state, console);
897
898 if (!state->console_enable && !state->syslog_dumping)
899 return;
900
901 debug_uart_enable(state);
902 while (count--) {
903 if (*s == '\n')
904 state->pdata->uart_putc(state->pdev, '\r');
905 state->pdata->uart_putc(state->pdev, *s++);
906 }
907 debug_uart_flush(state);
908 debug_uart_disable(state);
909}
910
911static struct console fiq_debugger_console = {
912 .name = "ttyFIQ",
913 .device = debug_console_device,
914 .write = debug_console_write,
915 .flags = CON_PRINTBUFFER | CON_ANYTIME | CON_ENABLED,
916};
917
918int fiq_tty_open(struct tty_struct *tty, struct file *filp)
919{
920 struct fiq_debugger_state *state = tty->driver->driver_state;
921 if (state->tty_open_count++)
922 return 0;
923
924 tty->driver_data = state;
925 state->tty = tty;
926 return 0;
927}
928
929void fiq_tty_close(struct tty_struct *tty, struct file *filp)
930{
931 struct fiq_debugger_state *state = tty->driver_data;
932 if (--state->tty_open_count)
933 return;
934 state->tty = NULL;
935}
936
937int fiq_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)
938{
939 int i;
940 struct fiq_debugger_state *state = tty->driver_data;
941
942 if (!state->console_enable)
943 return count;
944
945 debug_uart_enable(state);
946 for (i = 0; i < count; i++)
947 state->pdata->uart_putc(state->pdev, *buf++);
948 debug_uart_disable(state);
949
950 return count;
951}
952
953int fiq_tty_write_room(struct tty_struct *tty)
954{
955 return 1024;
956}
957
958static const struct tty_operations fiq_tty_driver_ops = {
959 .write = fiq_tty_write,
960 .write_room = fiq_tty_write_room,
961 .open = fiq_tty_open,
962 .close = fiq_tty_close,
963};
964
965static int fiq_debugger_tty_init(struct fiq_debugger_state *state)
966{
967 int ret = -EINVAL;
968
969 state->tty_driver = alloc_tty_driver(1);
970 if (!state->tty_driver) {
971 pr_err("Failed to allocate fiq debugger tty\n");
972 return -ENOMEM;
973 }
974
975 state->tty_driver->owner = THIS_MODULE;
976 state->tty_driver->driver_name = "fiq-debugger";
977 state->tty_driver->name = "ttyFIQ";
978 state->tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
979 state->tty_driver->subtype = SERIAL_TYPE_NORMAL;
980 state->tty_driver->init_termios = tty_std_termios;
981 state->tty_driver->init_termios.c_cflag =
982 B115200 | CS8 | CREAD | HUPCL | CLOCAL;
983 state->tty_driver->init_termios.c_ispeed =
984 state->tty_driver->init_termios.c_ospeed = 115200;
985 state->tty_driver->flags = TTY_DRIVER_REAL_RAW;
986 tty_set_operations(state->tty_driver, &fiq_tty_driver_ops);
987 state->tty_driver->driver_state = state;
988
989 ret = tty_register_driver(state->tty_driver);
990 if (ret) {
991 pr_err("Failed to register fiq tty: %d\n", ret);
992 goto err;
993 }
994
995 state->tty_rbuf = fiq_debugger_ringbuf_alloc(1024);
996 if (!state->tty_rbuf) {
997 pr_err("Failed to allocate fiq debugger ringbuf\n");
998 ret = -ENOMEM;
999 goto err;
1000 }
1001
1002 pr_info("Registered FIQ tty driver %p\n", state->tty_driver);
1003 return 0;
1004
1005err:
1006 fiq_debugger_ringbuf_free(state->tty_rbuf);
1007 state->tty_rbuf = NULL;
1008 put_tty_driver(state->tty_driver);
1009 return ret;
1010}
1011#endif
1012
1013static int fiq_debugger_dev_suspend(struct device *dev)
1014{
1015 struct platform_device *pdev = to_platform_device(dev);
1016 struct fiq_debugger_state *state = platform_get_drvdata(pdev);
1017
1018 if (state->pdata->uart_dev_suspend)
1019 return state->pdata->uart_dev_suspend(pdev);
1020 return 0;
1021}
1022
1023static int fiq_debugger_dev_resume(struct device *dev)
1024{
1025 struct platform_device *pdev = to_platform_device(dev);
1026 struct fiq_debugger_state *state = platform_get_drvdata(pdev);
1027
1028 if (state->pdata->uart_dev_resume)
1029 return state->pdata->uart_dev_resume(pdev);
1030 return 0;
1031}
1032
1033static int fiq_debugger_probe(struct platform_device *pdev)
1034{
1035 int ret;
1036 struct fiq_debugger_pdata *pdata = dev_get_platdata(&pdev->dev);
1037 struct fiq_debugger_state *state;
1038 int fiq;
1039 int uart_irq;
1040
1041 if (!pdata->uart_getc || !pdata->uart_putc)
1042 return -EINVAL;
1043 if ((pdata->uart_enable && !pdata->uart_disable) ||
1044 (!pdata->uart_enable && pdata->uart_disable))
1045 return -EINVAL;
1046
1047 fiq = platform_get_irq_byname(pdev, "fiq");
1048 uart_irq = platform_get_irq_byname(pdev, "uart_irq");
1049
1050 /* uart_irq mode and fiq mode are mutually exclusive, but one of them
1051 * is required */
1052 if ((uart_irq < 0 && fiq < 0) || (uart_irq >= 0 && fiq >= 0))
1053 return -EINVAL;
1054 if (fiq >= 0 && !pdata->fiq_enable)
1055 return -EINVAL;
1056
1057 state = kzalloc(sizeof(*state), GFP_KERNEL);
1058 setup_timer(&state->sleep_timer, sleep_timer_expired,
1059 (unsigned long)state);
1060 state->pdata = pdata;
1061 state->pdev = pdev;
1062 state->no_sleep = initial_no_sleep;
1063 state->debug_enable = initial_debug_enable;
1064 state->console_enable = initial_console_enable;
1065
1066 state->fiq = fiq;
1067 state->uart_irq = uart_irq;
1068 state->signal_irq = platform_get_irq_byname(pdev, "signal");
1069 state->wakeup_irq = platform_get_irq_byname(pdev, "wakeup");
1070
1071 platform_set_drvdata(pdev, state);
1072
1073 spin_lock_init(&state->sleep_timer_lock);
1074
1075 if (state->wakeup_irq < 0 && debug_have_fiq(state))
1076 state->no_sleep = true;
1077 state->ignore_next_wakeup_irq = !state->no_sleep;
1078
1079 wake_lock_init(&state->debugger_wake_lock,
1080 WAKE_LOCK_SUSPEND, "serial-debug");
1081
1082 state->clk = clk_get(&pdev->dev, NULL);
1083 if (IS_ERR(state->clk))
1084 state->clk = NULL;
1085
1086 /* do not call pdata->uart_enable here since uart_init may still
1087 * need to do some initialization before uart_enable can work.
1088 * So, only try to manage the clock during init.
1089 */
1090 if (state->clk)
1091 clk_enable(state->clk);
1092
1093 if (pdata->uart_init) {
1094 ret = pdata->uart_init(pdev);
1095 if (ret)
1096 goto err_uart_init;
1097 }
1098
1099 debug_printf_nfiq(state, "<hit enter %sto activate fiq debugger>\n",
1100 state->no_sleep ? "" : "twice ");
1101
1102 if (debug_have_fiq(state)) {
1103 state->handler.fiq = debug_fiq;
1104 state->handler.resume = debug_resume;
1105 ret = fiq_glue_register_handler(&state->handler);
1106 if (ret) {
1107 pr_err("%s: could not install fiq handler\n", __func__);
1108 goto err_register_fiq;
1109 }
1110
1111 pdata->fiq_enable(pdev, state->fiq, 1);
1112 } else {
1113 ret = request_irq(state->uart_irq, debug_uart_irq,
1114 IRQF_NO_SUSPEND, "debug", state);
1115 if (ret) {
1116 pr_err("%s: could not install irq handler\n", __func__);
1117 goto err_register_irq;
1118 }
1119
1120 /* for irq-only mode, we want this irq to wake us up, if it
1121 * can.
1122 */
1123 enable_irq_wake(state->uart_irq);
1124 }
1125
1126 if (state->clk)
1127 clk_disable(state->clk);
1128
1129 if (state->signal_irq >= 0) {
1130 ret = request_irq(state->signal_irq, debug_signal_irq,
1131 IRQF_TRIGGER_RISING, "debug-signal", state);
1132 if (ret)
1133 pr_err("serial_debugger: could not install signal_irq");
1134 }
1135
1136 if (state->wakeup_irq >= 0) {
1137 ret = request_irq(state->wakeup_irq, wakeup_irq_handler,
1138 IRQF_TRIGGER_FALLING | IRQF_DISABLED,
1139 "debug-wakeup", state);
1140 if (ret) {
1141 pr_err("serial_debugger: "
1142 "could not install wakeup irq\n");
1143 state->wakeup_irq = -1;
1144 } else {
1145 ret = enable_irq_wake(state->wakeup_irq);
1146 if (ret) {
1147 pr_err("serial_debugger: "
1148 "could not enable wakeup\n");
1149 state->wakeup_irq_no_set_wake = true;
1150 }
1151 }
1152 }
1153 if (state->no_sleep)
1154 handle_wakeup(state);
1155
1156#if defined(CONFIG_FIQ_DEBUGGER_CONSOLE)
1157 state->console = fiq_debugger_console;
1158 register_console(&state->console);
1159 fiq_debugger_tty_init(state);
1160#endif
1161 return 0;
1162
1163err_register_irq:
1164err_register_fiq:
1165 if (pdata->uart_free)
1166 pdata->uart_free(pdev);
1167err_uart_init:
1168 if (state->clk)
1169 clk_disable(state->clk);
1170 if (state->clk)
1171 clk_put(state->clk);
1172 wake_lock_destroy(&state->debugger_wake_lock);
1173 platform_set_drvdata(pdev, NULL);
1174 kfree(state);
1175 return ret;
1176}
1177
1178static const struct dev_pm_ops fiq_debugger_dev_pm_ops = {
1179 .suspend = fiq_debugger_dev_suspend,
1180 .resume = fiq_debugger_dev_resume,
1181};
1182
1183static struct platform_driver fiq_debugger_driver = {
1184 .probe = fiq_debugger_probe,
1185 .driver = {
1186 .name = "fiq_debugger",
1187 .pm = &fiq_debugger_dev_pm_ops,
1188 },
1189};
1190
1191static int __init fiq_debugger_init(void)
1192{
1193 return platform_driver_register(&fiq_debugger_driver);
1194}
1195
1196postcore_initcall(fiq_debugger_init);
diff --git a/arch/arm/common/fiq_debugger_ringbuf.h b/arch/arm/common/fiq_debugger_ringbuf.h
new file mode 100644
index 00000000000..2649b558108
--- /dev/null
+++ b/arch/arm/common/fiq_debugger_ringbuf.h
@@ -0,0 +1,94 @@
1/*
2 * arch/arm/common/fiq_debugger_ringbuf.c
3 *
4 * simple lockless ringbuffer
5 *
6 * Copyright (C) 2010 Google, Inc.
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
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
18#include <linux/kernel.h>
19#include <linux/slab.h>
20
21struct fiq_debugger_ringbuf {
22 int len;
23 int head;
24 int tail;
25 u8 buf[];
26};
27
28
29static inline struct fiq_debugger_ringbuf *fiq_debugger_ringbuf_alloc(int len)
30{
31 struct fiq_debugger_ringbuf *rbuf;
32
33 rbuf = kzalloc(sizeof(*rbuf) + len, GFP_KERNEL);
34 if (rbuf == NULL)
35 return NULL;
36
37 rbuf->len = len;
38 rbuf->head = 0;
39 rbuf->tail = 0;
40 smp_mb();
41
42 return rbuf;
43}
44
45static inline void fiq_debugger_ringbuf_free(struct fiq_debugger_ringbuf *rbuf)
46{
47 kfree(rbuf);
48}
49
50static inline int fiq_debugger_ringbuf_level(struct fiq_debugger_ringbuf *rbuf)
51{
52 int level = rbuf->head - rbuf->tail;
53
54 if (level < 0)
55 level = rbuf->len + level;
56
57 return level;
58}
59
60static inline int fiq_debugger_ringbuf_room(struct fiq_debugger_ringbuf *rbuf)
61{
62 return rbuf->len - fiq_debugger_ringbuf_level(rbuf) - 1;
63}
64
65static inline u8
66fiq_debugger_ringbuf_peek(struct fiq_debugger_ringbuf *rbuf, int i)
67{
68 return rbuf->buf[(rbuf->tail + i) % rbuf->len];
69}
70
71static inline int
72fiq_debugger_ringbuf_consume(struct fiq_debugger_ringbuf *rbuf, int count)
73{
74 count = min(count, fiq_debugger_ringbuf_level(rbuf));
75
76 rbuf->tail = (rbuf->tail + count) % rbuf->len;
77 smp_mb();
78
79 return count;
80}
81
82static inline int
83fiq_debugger_ringbuf_push(struct fiq_debugger_ringbuf *rbuf, u8 datum)
84{
85 if (fiq_debugger_ringbuf_room(rbuf) == 0)
86 return 0;
87
88 rbuf->buf[rbuf->head] = datum;
89 smp_mb();
90 rbuf->head = (rbuf->head + 1) % rbuf->len;
91 smp_mb();
92
93 return 1;
94}
diff --git a/arch/arm/common/fiq_glue.S b/arch/arm/common/fiq_glue.S
new file mode 100644
index 00000000000..9e3455a09f8
--- /dev/null
+++ b/arch/arm/common/fiq_glue.S
@@ -0,0 +1,111 @@
1/*
2 * Copyright (C) 2008 Google, Inc.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15#include <linux/linkage.h>
16#include <asm/assembler.h>
17
18 .text
19
20 .global fiq_glue_end
21
22 /* fiq stack: r0-r15,cpsr,spsr of interrupted mode */
23
24ENTRY(fiq_glue)
25 /* store pc, cpsr from previous mode */
26 mrs r12, spsr
27 sub r11, lr, #4
28 subs r10, #1
29 bne nested_fiq
30
31 stmfd sp!, {r11-r12, lr}
32
33 /* store r8-r14 from previous mode */
34 sub sp, sp, #(7 * 4)
35 stmia sp, {r8-r14}^
36 nop
37
38 /* store r0-r7 from previous mode */
39 stmfd sp!, {r0-r7}
40
41 /* setup func(data,regs) arguments */
42 mov r0, r9
43 mov r1, sp
44 mov r3, r8
45
46 mov r7, sp
47
48 /* Get sp and lr from non-user modes */
49 and r4, r12, #MODE_MASK
50 cmp r4, #USR_MODE
51 beq fiq_from_usr_mode
52
53 mov r7, sp
54 orr r4, r4, #(PSR_I_BIT | PSR_F_BIT)
55 msr cpsr_c, r4
56 str sp, [r7, #(4 * 13)]
57 str lr, [r7, #(4 * 14)]
58 mrs r5, spsr
59 str r5, [r7, #(4 * 17)]
60
61 cmp r4, #(SVC_MODE | PSR_I_BIT | PSR_F_BIT)
62 /* use fiq stack if we reenter this mode */
63 subne sp, r7, #(4 * 3)
64
65fiq_from_usr_mode:
66 msr cpsr_c, #(SVC_MODE | PSR_I_BIT | PSR_F_BIT)
67 mov r2, sp
68 sub sp, r7, #12
69 stmfd sp!, {r2, ip, lr}
70 /* call func(data,regs) */
71 blx r3
72 ldmfd sp, {r2, ip, lr}
73 mov sp, r2
74
75 /* restore/discard saved state */
76 cmp r4, #USR_MODE
77 beq fiq_from_usr_mode_exit
78
79 msr cpsr_c, r4
80 ldr sp, [r7, #(4 * 13)]
81 ldr lr, [r7, #(4 * 14)]
82 msr spsr_cxsf, r5
83
84fiq_from_usr_mode_exit:
85 msr cpsr_c, #(FIQ_MODE | PSR_I_BIT | PSR_F_BIT)
86
87 ldmfd sp!, {r0-r7}
88 add sp, sp, #(7 * 4)
89 ldmfd sp!, {r11-r12, lr}
90exit_fiq:
91 msr spsr_cxsf, r12
92 add r10, #1
93 movs pc, r11
94
95nested_fiq:
96 orr r12, r12, #(PSR_F_BIT)
97 b exit_fiq
98
99fiq_glue_end:
100
101ENTRY(fiq_glue_setup) /* func, data, sp */
102 mrs r3, cpsr
103 msr cpsr_c, #(FIQ_MODE | PSR_I_BIT | PSR_F_BIT)
104 movs r8, r0
105 mov r9, r1
106 mov sp, r2
107 moveq r10, #0
108 movne r10, #1
109 msr cpsr_c, r3
110 bx lr
111
diff --git a/arch/arm/common/fiq_glue_setup.c b/arch/arm/common/fiq_glue_setup.c
new file mode 100644
index 00000000000..4044c7db95c
--- /dev/null
+++ b/arch/arm/common/fiq_glue_setup.c
@@ -0,0 +1,100 @@
1/*
2 * Copyright (C) 2010 Google, Inc.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <linux/kernel.h>
15#include <linux/percpu.h>
16#include <linux/slab.h>
17#include <asm/fiq.h>
18#include <asm/fiq_glue.h>
19
20extern unsigned char fiq_glue, fiq_glue_end;
21extern void fiq_glue_setup(void *func, void *data, void *sp);
22
23static struct fiq_handler fiq_debbuger_fiq_handler = {
24 .name = "fiq_glue",
25};
26DEFINE_PER_CPU(void *, fiq_stack);
27static struct fiq_glue_handler *current_handler;
28static DEFINE_MUTEX(fiq_glue_lock);
29
30static void fiq_glue_setup_helper(void *info)
31{
32 struct fiq_glue_handler *handler = info;
33 fiq_glue_setup(handler->fiq, handler,
34 __get_cpu_var(fiq_stack) + THREAD_START_SP);
35}
36
37int fiq_glue_register_handler(struct fiq_glue_handler *handler)
38{
39 int ret;
40 int cpu;
41
42 if (!handler || !handler->fiq)
43 return -EINVAL;
44
45 mutex_lock(&fiq_glue_lock);
46 if (fiq_stack) {
47 ret = -EBUSY;
48 goto err_busy;
49 }
50
51 for_each_possible_cpu(cpu) {
52 void *stack;
53 stack = (void *)__get_free_pages(GFP_KERNEL, THREAD_SIZE_ORDER);
54 if (WARN_ON(!stack)) {
55 ret = -ENOMEM;
56 goto err_alloc_fiq_stack;
57 }
58 per_cpu(fiq_stack, cpu) = stack;
59 }
60
61 ret = claim_fiq(&fiq_debbuger_fiq_handler);
62 if (WARN_ON(ret))
63 goto err_claim_fiq;
64
65 current_handler = handler;
66 on_each_cpu(fiq_glue_setup_helper, handler, true);
67 set_fiq_handler(&fiq_glue, &fiq_glue_end - &fiq_glue);
68
69 mutex_unlock(&fiq_glue_lock);
70 return 0;
71
72err_claim_fiq:
73err_alloc_fiq_stack:
74 for_each_possible_cpu(cpu) {
75 __free_pages(per_cpu(fiq_stack, cpu), THREAD_SIZE_ORDER);
76 per_cpu(fiq_stack, cpu) = NULL;
77 }
78err_busy:
79 mutex_unlock(&fiq_glue_lock);
80 return ret;
81}
82
83/**
84 * fiq_glue_resume - Restore fiqs after suspend or low power idle states
85 *
86 * This must be called before calling local_fiq_enable after returning from a
87 * power state where the fiq mode registers were lost. If a driver provided
88 * a resume hook when it registered the handler it will be called.
89 */
90
91void fiq_glue_resume(void)
92{
93 if (!current_handler)
94 return;
95 fiq_glue_setup(current_handler->fiq, current_handler,
96 __get_cpu_var(fiq_stack) + THREAD_START_SP);
97 if (current_handler->resume)
98 current_handler->resume(current_handler);
99}
100
diff --git a/arch/arm/include/asm/fiq_debugger.h b/arch/arm/include/asm/fiq_debugger.h
new file mode 100644
index 00000000000..4d274883ba6
--- /dev/null
+++ b/arch/arm/include/asm/fiq_debugger.h
@@ -0,0 +1,64 @@
1/*
2 * arch/arm/include/asm/fiq_debugger.h
3 *
4 * Copyright (C) 2010 Google, Inc.
5 * Author: Colin Cross <ccross@android.com>
6 *
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 */
17
18#ifndef _ARCH_ARM_MACH_TEGRA_FIQ_DEBUGGER_H_
19#define _ARCH_ARM_MACH_TEGRA_FIQ_DEBUGGER_H_
20
21#include <linux/serial_core.h>
22
23#define FIQ_DEBUGGER_NO_CHAR NO_POLL_CHAR
24#define FIQ_DEBUGGER_BREAK 0x00ff0100
25
26#define FIQ_DEBUGGER_FIQ_IRQ_NAME "fiq"
27#define FIQ_DEBUGGER_SIGNAL_IRQ_NAME "signal"
28#define FIQ_DEBUGGER_WAKEUP_IRQ_NAME "wakeup"
29
30/**
31 * struct fiq_debugger_pdata - fiq debugger platform data
32 * @uart_resume: used to restore uart state right before enabling
33 * the fiq.
34 * @uart_enable: Do the work necessary to communicate with the uart
35 * hw (enable clocks, etc.). This must be ref-counted.
36 * @uart_disable: Do the work necessary to disable the uart hw
37 * (disable clocks, etc.). This must be ref-counted.
38 * @uart_dev_suspend: called during PM suspend, generally not needed
39 * for real fiq mode debugger.
40 * @uart_dev_resume: called during PM resume, generally not needed
41 * for real fiq mode debugger.
42 */
43struct fiq_debugger_pdata {
44 int (*uart_init)(struct platform_device *pdev);
45 void (*uart_free)(struct platform_device *pdev);
46 int (*uart_resume)(struct platform_device *pdev);
47 int (*uart_getc)(struct platform_device *pdev);
48 void (*uart_putc)(struct platform_device *pdev, unsigned int c);
49 void (*uart_flush)(struct platform_device *pdev);
50 void (*uart_enable)(struct platform_device *pdev);
51 void (*uart_disable)(struct platform_device *pdev);
52
53 int (*uart_dev_suspend)(struct platform_device *pdev);
54 int (*uart_dev_resume)(struct platform_device *pdev);
55
56 void (*fiq_enable)(struct platform_device *pdev, unsigned int fiq,
57 bool enable);
58 void (*fiq_ack)(struct platform_device *pdev, unsigned int fiq);
59
60 void (*force_irq)(struct platform_device *pdev, unsigned int irq);
61 void (*force_irq_ack)(struct platform_device *pdev, unsigned int irq);
62};
63
64#endif
diff --git a/arch/arm/include/asm/fiq_glue.h b/arch/arm/include/asm/fiq_glue.h
new file mode 100644
index 00000000000..d54c29db97a
--- /dev/null
+++ b/arch/arm/include/asm/fiq_glue.h
@@ -0,0 +1,30 @@
1/*
2 * Copyright (C) 2010 Google, Inc.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#ifndef __ASM_FIQ_GLUE_H
15#define __ASM_FIQ_GLUE_H
16
17struct fiq_glue_handler {
18 void (*fiq)(struct fiq_glue_handler *h, void *regs, void *svc_sp);
19 void (*resume)(struct fiq_glue_handler *h);
20};
21
22int fiq_glue_register_handler(struct fiq_glue_handler *handler);
23
24#ifdef CONFIG_FIQ_GLUE
25void fiq_glue_resume(void);
26#else
27static inline void fiq_glue_resume(void) {}
28#endif
29
30#endif
diff --git a/arch/arm/include/asm/hardirq.h b/arch/arm/include/asm/hardirq.h
index 89ad1805e57..2635c8b5bf5 100644
--- a/arch/arm/include/asm/hardirq.h
+++ b/arch/arm/include/asm/hardirq.h
@@ -5,7 +5,7 @@
5#include <linux/threads.h> 5#include <linux/threads.h>
6#include <asm/irq.h> 6#include <asm/irq.h>
7 7
8#define NR_IPI 5 8#define NR_IPI 6
9 9
10typedef struct { 10typedef struct {
11 unsigned int __softirq_pending; 11 unsigned int __softirq_pending;
diff --git a/arch/arm/include/asm/hardware/cache-l2x0.h b/arch/arm/include/asm/hardware/cache-l2x0.h
index bfa706ffd96..2a20876ee3d 100644
--- a/arch/arm/include/asm/hardware/cache-l2x0.h
+++ b/arch/arm/include/asm/hardware/cache-l2x0.h
@@ -57,6 +57,7 @@
57#define L2X0_STNDBY_MODE_EN (1 << 0) 57#define L2X0_STNDBY_MODE_EN (1 << 0)
58 58
59/* Registers shifts and masks */ 59/* Registers shifts and masks */
60#define L2X0_CACHE_ID_REV_MASK (0x3f)
60#define L2X0_CACHE_ID_PART_MASK (0xf << 6) 61#define L2X0_CACHE_ID_PART_MASK (0xf << 6)
61#define L2X0_CACHE_ID_PART_L210 (1 << 6) 62#define L2X0_CACHE_ID_PART_L210 (1 << 6)
62#define L2X0_CACHE_ID_PART_L310 (3 << 6) 63#define L2X0_CACHE_ID_PART_L310 (3 << 6)
@@ -72,6 +73,8 @@
72#define L2X0_AUX_CTRL_INSTR_PREFETCH_SHIFT 29 73#define L2X0_AUX_CTRL_INSTR_PREFETCH_SHIFT 29
73#define L2X0_AUX_CTRL_EARLY_BRESP_SHIFT 30 74#define L2X0_AUX_CTRL_EARLY_BRESP_SHIFT 30
74 75
76#define REV_PL310_R2P0 4
77
75#ifndef __ASSEMBLY__ 78#ifndef __ASSEMBLY__
76extern void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask); 79extern void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask);
77#endif 80#endif
diff --git a/arch/arm/include/asm/hardware/coresight.h b/arch/arm/include/asm/hardware/coresight.h
index 7ecd793b8f5..6643d6c4f35 100644
--- a/arch/arm/include/asm/hardware/coresight.h
+++ b/arch/arm/include/asm/hardware/coresight.h
@@ -17,15 +17,17 @@
17#define TRACER_ACCESSED_BIT 0 17#define TRACER_ACCESSED_BIT 0
18#define TRACER_RUNNING_BIT 1 18#define TRACER_RUNNING_BIT 1
19#define TRACER_CYCLE_ACC_BIT 2 19#define TRACER_CYCLE_ACC_BIT 2
20#define TRACER_TRACE_DATA_BIT 3
20#define TRACER_ACCESSED BIT(TRACER_ACCESSED_BIT) 21#define TRACER_ACCESSED BIT(TRACER_ACCESSED_BIT)
21#define TRACER_RUNNING BIT(TRACER_RUNNING_BIT) 22#define TRACER_RUNNING BIT(TRACER_RUNNING_BIT)
22#define TRACER_CYCLE_ACC BIT(TRACER_CYCLE_ACC_BIT) 23#define TRACER_CYCLE_ACC BIT(TRACER_CYCLE_ACC_BIT)
24#define TRACER_TRACE_DATA BIT(TRACER_TRACE_DATA_BIT)
23 25
24#define TRACER_TIMEOUT 10000 26#define TRACER_TIMEOUT 10000
25 27
26#define etm_writel(t, v, x) \ 28#define etm_writel(t, id, v, x) \
27 (__raw_writel((v), (t)->etm_regs + (x))) 29 (__raw_writel((v), (t)->etm_regs[(id)] + (x)))
28#define etm_readl(t, x) (__raw_readl((t)->etm_regs + (x))) 30#define etm_readl(t, id, x) (__raw_readl((t)->etm_regs[(id)] + (x)))
29 31
30/* CoreSight Management Registers */ 32/* CoreSight Management Registers */
31#define CSMR_LOCKACCESS 0xfb0 33#define CSMR_LOCKACCESS 0xfb0
@@ -113,11 +115,19 @@
113#define ETMR_TRACEENCTRL 0x24 115#define ETMR_TRACEENCTRL 0x24
114#define ETMTE_INCLEXCL BIT(24) 116#define ETMTE_INCLEXCL BIT(24)
115#define ETMR_TRACEENEVT 0x20 117#define ETMR_TRACEENEVT 0x20
118
119#define ETMR_VIEWDATAEVT 0x30
120#define ETMR_VIEWDATACTRL1 0x34
121#define ETMR_VIEWDATACTRL2 0x38
122#define ETMR_VIEWDATACTRL3 0x3c
123#define ETMVDC3_EXCLONLY BIT(16)
124
116#define ETMCTRL_OPTS (ETMCTRL_DO_CPRT | \ 125#define ETMCTRL_OPTS (ETMCTRL_DO_CPRT | \
117 ETMCTRL_DATA_DO_ADDR | \
118 ETMCTRL_BRANCH_OUTPUT | \ 126 ETMCTRL_BRANCH_OUTPUT | \
119 ETMCTRL_DO_CONTEXTID) 127 ETMCTRL_DO_CONTEXTID)
120 128
129#define ETMR_TRACEIDR 0x200
130
121/* ETM management registers, "ETM Architecture", 3.5.24 */ 131/* ETM management registers, "ETM Architecture", 3.5.24 */
122#define ETMMR_OSLAR 0x300 132#define ETMMR_OSLAR 0x300
123#define ETMMR_OSLSR 0x304 133#define ETMMR_OSLSR 0x304
@@ -140,14 +150,16 @@
140#define ETBFF_TRIGIN BIT(8) 150#define ETBFF_TRIGIN BIT(8)
141#define ETBFF_TRIGEVT BIT(9) 151#define ETBFF_TRIGEVT BIT(9)
142#define ETBFF_TRIGFL BIT(10) 152#define ETBFF_TRIGFL BIT(10)
153#define ETBFF_STOPFL BIT(12)
143 154
144#define etb_writel(t, v, x) \ 155#define etb_writel(t, v, x) \
145 (__raw_writel((v), (t)->etb_regs + (x))) 156 (__raw_writel((v), (t)->etb_regs + (x)))
146#define etb_readl(t, x) (__raw_readl((t)->etb_regs + (x))) 157#define etb_readl(t, x) (__raw_readl((t)->etb_regs + (x)))
147 158
148#define etm_lock(t) do { etm_writel((t), 0, CSMR_LOCKACCESS); } while (0) 159#define etm_lock(t, id) \
149#define etm_unlock(t) \ 160 do { etm_writel((t), (id), 0, CSMR_LOCKACCESS); } while (0)
150 do { etm_writel((t), UNLOCK_MAGIC, CSMR_LOCKACCESS); } while (0) 161#define etm_unlock(t, id) \
162 do { etm_writel((t), (id), UNLOCK_MAGIC, CSMR_LOCKACCESS); } while (0)
151 163
152#define etb_lock(t) do { etb_writel((t), 0, CSMR_LOCKACCESS); } while (0) 164#define etb_lock(t) do { etb_writel((t), 0, CSMR_LOCKACCESS); } while (0)
153#define etb_unlock(t) \ 165#define etb_unlock(t) \
diff --git a/arch/arm/include/asm/irq.h b/arch/arm/include/asm/irq.h
index 2721a5814cb..28810c6be9d 100644
--- a/arch/arm/include/asm/irq.h
+++ b/arch/arm/include/asm/irq.h
@@ -25,6 +25,9 @@ extern void migrate_irqs(void);
25extern void asm_do_IRQ(unsigned int, struct pt_regs *); 25extern void asm_do_IRQ(unsigned int, struct pt_regs *);
26void init_IRQ(void); 26void init_IRQ(void);
27 27
28void arch_trigger_all_cpu_backtrace(void);
29#define arch_trigger_all_cpu_backtrace arch_trigger_all_cpu_backtrace
30
28#endif 31#endif
29 32
30#endif 33#endif
diff --git a/arch/arm/include/asm/mach/mmc.h b/arch/arm/include/asm/mach/mmc.h
new file mode 100644
index 00000000000..bca864ac945
--- /dev/null
+++ b/arch/arm/include/asm/mach/mmc.h
@@ -0,0 +1,28 @@
1/*
2 * arch/arm/include/asm/mach/mmc.h
3 */
4#ifndef ASMARM_MACH_MMC_H
5#define ASMARM_MACH_MMC_H
6
7#include <linux/mmc/host.h>
8#include <linux/mmc/card.h>
9#include <linux/mmc/sdio_func.h>
10
11struct embedded_sdio_data {
12 struct sdio_cis cis;
13 struct sdio_cccr cccr;
14 struct sdio_embedded_func *funcs;
15 int num_funcs;
16};
17
18struct mmc_platform_data {
19 unsigned int ocr_mask; /* available voltages */
20 int built_in; /* built-in device flag */
21 int card_present; /* card detect state */
22 u32 (*translate_vdd)(struct device *, unsigned int);
23 unsigned int (*status)(struct device *);
24 struct embedded_sdio_data *embedded_sdio;
25 int (*register_status_notify)(void (*callback)(int card_present, void *dev_id), void *dev_id);
26};
27
28#endif
diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
index e42d96a45d3..74f288f4802 100644
--- a/arch/arm/include/asm/smp.h
+++ b/arch/arm/include/asm/smp.h
@@ -93,4 +93,6 @@ extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
93 */ 93 */
94extern void show_local_irqs(struct seq_file *, int); 94extern void show_local_irqs(struct seq_file *, int);
95 95
96extern void smp_send_all_cpu_backtrace(void);
97
96#endif /* ifndef __ASM_ARM_SMP_H */ 98#endif /* ifndef __ASM_ARM_SMP_H */
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 90c62cd51ca..2cd00764016 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -496,7 +496,7 @@ __und_usr:
496 blo __und_usr_unknown 496 blo __und_usr_unknown
4973: ldrht r0, [r4] 4973: ldrht r0, [r4]
498 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4 498 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
499 orr r0, r0, r5, lsl #16 499 orr r0, r0, r5, lsl #16
500#else 500#else
501 b __und_usr_unknown 501 b __und_usr_unknown
502#endif 502#endif
diff --git a/arch/arm/kernel/etm.c b/arch/arm/kernel/etm.c
index 1bec8b5f22f..496b8b84e45 100644
--- a/arch/arm/kernel/etm.c
+++ b/arch/arm/kernel/etm.c
@@ -15,6 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/types.h> 16#include <linux/types.h>
17#include <linux/io.h> 17#include <linux/io.h>
18#include <linux/slab.h>
18#include <linux/sysrq.h> 19#include <linux/sysrq.h>
19#include <linux/device.h> 20#include <linux/device.h>
20#include <linux/clk.h> 21#include <linux/clk.h>
@@ -36,26 +37,36 @@ MODULE_AUTHOR("Alexander Shishkin");
36struct tracectx { 37struct tracectx {
37 unsigned int etb_bufsz; 38 unsigned int etb_bufsz;
38 void __iomem *etb_regs; 39 void __iomem *etb_regs;
39 void __iomem *etm_regs; 40 void __iomem **etm_regs;
41 int etm_regs_count;
40 unsigned long flags; 42 unsigned long flags;
41 int ncmppairs; 43 int ncmppairs;
42 int etm_portsz; 44 int etm_portsz;
45 u32 etb_fc;
46 unsigned long range_start;
47 unsigned long range_end;
48 unsigned long data_range_start;
49 unsigned long data_range_end;
50 bool dump_initial_etb;
43 struct device *dev; 51 struct device *dev;
44 struct clk *emu_clk; 52 struct clk *emu_clk;
45 struct mutex mutex; 53 struct mutex mutex;
46}; 54};
47 55
48static struct tracectx tracer; 56static struct tracectx tracer = {
57 .range_start = (unsigned long)_stext,
58 .range_end = (unsigned long)_etext,
59};
49 60
50static inline bool trace_isrunning(struct tracectx *t) 61static inline bool trace_isrunning(struct tracectx *t)
51{ 62{
52 return !!(t->flags & TRACER_RUNNING); 63 return !!(t->flags & TRACER_RUNNING);
53} 64}
54 65
55static int etm_setup_address_range(struct tracectx *t, int n, 66static int etm_setup_address_range(struct tracectx *t, int id, int n,
56 unsigned long start, unsigned long end, int exclude, int data) 67 unsigned long start, unsigned long end, int exclude, int data)
57{ 68{
58 u32 flags = ETMAAT_ARM | ETMAAT_IGNCONTEXTID | ETMAAT_NSONLY | \ 69 u32 flags = ETMAAT_ARM | ETMAAT_IGNCONTEXTID | ETMAAT_IGNSECURITY |
59 ETMAAT_NOVALCMP; 70 ETMAAT_NOVALCMP;
60 71
61 if (n < 1 || n > t->ncmppairs) 72 if (n < 1 || n > t->ncmppairs)
@@ -71,95 +82,155 @@ static int etm_setup_address_range(struct tracectx *t, int n,
71 flags |= ETMAAT_IEXEC; 82 flags |= ETMAAT_IEXEC;
72 83
73 /* first comparator for the range */ 84 /* first comparator for the range */
74 etm_writel(t, flags, ETMR_COMP_ACC_TYPE(n * 2)); 85 etm_writel(t, id, flags, ETMR_COMP_ACC_TYPE(n * 2));
75 etm_writel(t, start, ETMR_COMP_VAL(n * 2)); 86 etm_writel(t, id, start, ETMR_COMP_VAL(n * 2));
76 87
77 /* second comparator is right next to it */ 88 /* second comparator is right next to it */
78 etm_writel(t, flags, ETMR_COMP_ACC_TYPE(n * 2 + 1)); 89 etm_writel(t, id, flags, ETMR_COMP_ACC_TYPE(n * 2 + 1));
79 etm_writel(t, end, ETMR_COMP_VAL(n * 2 + 1)); 90 etm_writel(t, id, end, ETMR_COMP_VAL(n * 2 + 1));
80 91
81 flags = exclude ? ETMTE_INCLEXCL : 0; 92 if (data) {
82 etm_writel(t, flags | (1 << n), ETMR_TRACEENCTRL); 93 flags = exclude ? ETMVDC3_EXCLONLY : 0;
94 if (exclude)
95 n += 8;
96 etm_writel(t, id, flags | BIT(n), ETMR_VIEWDATACTRL3);
97 } else {
98 flags = exclude ? ETMTE_INCLEXCL : 0;
99 etm_writel(t, id, flags | (1 << n), ETMR_TRACEENCTRL);
100 }
83 101
84 return 0; 102 return 0;
85} 103}
86 104
87static int trace_start(struct tracectx *t) 105static int trace_start_etm(struct tracectx *t, int id)
88{ 106{
89 u32 v; 107 u32 v;
90 unsigned long timeout = TRACER_TIMEOUT; 108 unsigned long timeout = TRACER_TIMEOUT;
91 109
92 etb_unlock(t);
93
94 etb_writel(t, 0, ETBR_FORMATTERCTRL);
95 etb_writel(t, 1, ETBR_CTRL);
96
97 etb_lock(t);
98
99 /* configure etm */
100 v = ETMCTRL_OPTS | ETMCTRL_PROGRAM | ETMCTRL_PORTSIZE(t->etm_portsz); 110 v = ETMCTRL_OPTS | ETMCTRL_PROGRAM | ETMCTRL_PORTSIZE(t->etm_portsz);
101 111
102 if (t->flags & TRACER_CYCLE_ACC) 112 if (t->flags & TRACER_CYCLE_ACC)
103 v |= ETMCTRL_CYCLEACCURATE; 113 v |= ETMCTRL_CYCLEACCURATE;
104 114
105 etm_unlock(t); 115 if (t->flags & TRACER_TRACE_DATA)
116 v |= ETMCTRL_DATA_DO_ADDR;
117
118 etm_unlock(t, id);
106 119
107 etm_writel(t, v, ETMR_CTRL); 120 etm_writel(t, id, v, ETMR_CTRL);
108 121
109 while (!(etm_readl(t, ETMR_CTRL) & ETMCTRL_PROGRAM) && --timeout) 122 while (!(etm_readl(t, id, ETMR_CTRL) & ETMCTRL_PROGRAM) && --timeout)
110 ; 123 ;
111 if (!timeout) { 124 if (!timeout) {
112 dev_dbg(t->dev, "Waiting for progbit to assert timed out\n"); 125 dev_dbg(t->dev, "Waiting for progbit to assert timed out\n");
113 etm_lock(t); 126 etm_lock(t, id);
114 return -EFAULT; 127 return -EFAULT;
115 } 128 }
116 129
117 etm_setup_address_range(t, 1, (unsigned long)_stext, 130 if (t->range_start || t->range_end)
118 (unsigned long)_etext, 0, 0); 131 etm_setup_address_range(t, id, 1,
119 etm_writel(t, 0, ETMR_TRACEENCTRL2); 132 t->range_start, t->range_end, 0, 0);
120 etm_writel(t, 0, ETMR_TRACESSCTRL); 133 else
121 etm_writel(t, 0x6f, ETMR_TRACEENEVT); 134 etm_writel(t, id, ETMTE_INCLEXCL, ETMR_TRACEENCTRL);
135
136 etm_writel(t, id, 0, ETMR_TRACEENCTRL2);
137 etm_writel(t, id, 0, ETMR_TRACESSCTRL);
138 etm_writel(t, id, 0x6f, ETMR_TRACEENEVT);
139
140 etm_writel(t, id, 0, ETMR_VIEWDATACTRL1);
141 etm_writel(t, id, 0, ETMR_VIEWDATACTRL2);
142
143 if (t->data_range_start || t->data_range_end)
144 etm_setup_address_range(t, id, 2, t->data_range_start,
145 t->data_range_end, 0, 1);
146 else
147 etm_writel(t, id, ETMVDC3_EXCLONLY, ETMR_VIEWDATACTRL3);
148
149 etm_writel(t, id, 0x6f, ETMR_VIEWDATAEVT);
122 150
123 v &= ~ETMCTRL_PROGRAM; 151 v &= ~ETMCTRL_PROGRAM;
124 v |= ETMCTRL_PORTSEL; 152 v |= ETMCTRL_PORTSEL;
125 153
126 etm_writel(t, v, ETMR_CTRL); 154 etm_writel(t, id, v, ETMR_CTRL);
127 155
128 timeout = TRACER_TIMEOUT; 156 timeout = TRACER_TIMEOUT;
129 while (etm_readl(t, ETMR_CTRL) & ETMCTRL_PROGRAM && --timeout) 157 while (etm_readl(t, id, ETMR_CTRL) & ETMCTRL_PROGRAM && --timeout)
130 ; 158 ;
131 if (!timeout) { 159 if (!timeout) {
132 dev_dbg(t->dev, "Waiting for progbit to deassert timed out\n"); 160 dev_dbg(t->dev, "Waiting for progbit to deassert timed out\n");
133 etm_lock(t); 161 etm_lock(t, id);
134 return -EFAULT; 162 return -EFAULT;
135 } 163 }
136 164
137 etm_lock(t); 165 etm_lock(t, id);
166 return 0;
167}
168
169static int trace_start(struct tracectx *t)
170{
171 int ret;
172 int id;
173 u32 etb_fc = t->etb_fc;
174
175 etb_unlock(t);
176
177 t->dump_initial_etb = false;
178 etb_writel(t, 0, ETBR_WRITEADDR);
179 etb_writel(t, etb_fc, ETBR_FORMATTERCTRL);
180 etb_writel(t, 1, ETBR_CTRL);
181
182 etb_lock(t);
183
184 /* configure etm(s) */
185 for (id = 0; id < t->etm_regs_count; id++) {
186 ret = trace_start_etm(t, id);
187 if (ret)
188 return ret;
189 }
138 190
139 t->flags |= TRACER_RUNNING; 191 t->flags |= TRACER_RUNNING;
140 192
141 return 0; 193 return 0;
142} 194}
143 195
144static int trace_stop(struct tracectx *t) 196static int trace_stop_etm(struct tracectx *t, int id)
145{ 197{
146 unsigned long timeout = TRACER_TIMEOUT; 198 unsigned long timeout = TRACER_TIMEOUT;
147 199
148 etm_unlock(t); 200 etm_unlock(t, id);
149 201
150 etm_writel(t, 0x440, ETMR_CTRL); 202 etm_writel(t, id, 0x441, ETMR_CTRL);
151 while (!(etm_readl(t, ETMR_CTRL) & ETMCTRL_PROGRAM) && --timeout) 203 while (!(etm_readl(t, id, ETMR_CTRL) & ETMCTRL_PROGRAM) && --timeout)
152 ; 204 ;
153 if (!timeout) { 205 if (!timeout) {
154 dev_dbg(t->dev, "Waiting for progbit to assert timed out\n"); 206 dev_dbg(t->dev, "Waiting for progbit to assert timed out\n");
155 etm_lock(t); 207 etm_lock(t, id);
156 return -EFAULT; 208 return -EFAULT;
157 } 209 }
158 210
159 etm_lock(t); 211 etm_lock(t, id);
212 return 0;
213}
214
215static int trace_stop(struct tracectx *t)
216{
217 int id;
218 int ret;
219 unsigned long timeout = TRACER_TIMEOUT;
220 u32 etb_fc = t->etb_fc;
221
222 for (id = 0; id < t->etm_regs_count; id++) {
223 ret = trace_stop_etm(t, id);
224 if (ret)
225 return ret;
226 }
160 227
161 etb_unlock(t); 228 etb_unlock(t);
162 etb_writel(t, ETBFF_MANUAL_FLUSH, ETBR_FORMATTERCTRL); 229 if (etb_fc) {
230 etb_fc |= ETBFF_STOPFL;
231 etb_writel(t, t->etb_fc, ETBR_FORMATTERCTRL);
232 }
233 etb_writel(t, etb_fc | ETBFF_MANUAL_FLUSH, ETBR_FORMATTERCTRL);
163 234
164 timeout = TRACER_TIMEOUT; 235 timeout = TRACER_TIMEOUT;
165 while (etb_readl(t, ETBR_FORMATTERCTRL) & 236 while (etb_readl(t, ETBR_FORMATTERCTRL) &
@@ -184,24 +255,15 @@ static int trace_stop(struct tracectx *t)
184static int etb_getdatalen(struct tracectx *t) 255static int etb_getdatalen(struct tracectx *t)
185{ 256{
186 u32 v; 257 u32 v;
187 int rp, wp; 258 int wp;
188 259
189 v = etb_readl(t, ETBR_STATUS); 260 v = etb_readl(t, ETBR_STATUS);
190 261
191 if (v & 1) 262 if (v & 1)
192 return t->etb_bufsz; 263 return t->etb_bufsz;
193 264
194 rp = etb_readl(t, ETBR_READADDR);
195 wp = etb_readl(t, ETBR_WRITEADDR); 265 wp = etb_readl(t, ETBR_WRITEADDR);
196 266 return wp;
197 if (rp > wp) {
198 etb_writel(t, 0, ETBR_READADDR);
199 etb_writel(t, 0, ETBR_WRITEADDR);
200
201 return 0;
202 }
203
204 return wp - rp;
205} 267}
206 268
207/* sysrq+v will always stop the running trace and leave it at that */ 269/* sysrq+v will always stop the running trace and leave it at that */
@@ -234,21 +296,18 @@ static void etm_dump(void)
234 printk("%08x", cpu_to_be32(etb_readl(t, ETBR_READMEM))); 296 printk("%08x", cpu_to_be32(etb_readl(t, ETBR_READMEM)));
235 printk(KERN_INFO "\n--- ETB buffer end ---\n"); 297 printk(KERN_INFO "\n--- ETB buffer end ---\n");
236 298
237 /* deassert the overflow bit */
238 etb_writel(t, 1, ETBR_CTRL);
239 etb_writel(t, 0, ETBR_CTRL);
240
241 etb_writel(t, 0, ETBR_TRIGGERCOUNT);
242 etb_writel(t, 0, ETBR_READADDR);
243 etb_writel(t, 0, ETBR_WRITEADDR);
244
245 etb_lock(t); 299 etb_lock(t);
246} 300}
247 301
248static void sysrq_etm_dump(int key) 302static void sysrq_etm_dump(int key)
249{ 303{
304 if (!mutex_trylock(&tracer.mutex)) {
305 printk(KERN_INFO "Tracing hardware busy\n");
306 return;
307 }
250 dev_dbg(tracer.dev, "Dumping ETB buffer\n"); 308 dev_dbg(tracer.dev, "Dumping ETB buffer\n");
251 etm_dump(); 309 etm_dump();
310 mutex_unlock(&tracer.mutex);
252} 311}
253 312
254static struct sysrq_key_op sysrq_etm_op = { 313static struct sysrq_key_op sysrq_etm_op = {
@@ -275,6 +334,10 @@ static ssize_t etb_read(struct file *file, char __user *data,
275 struct tracectx *t = file->private_data; 334 struct tracectx *t = file->private_data;
276 u32 first = 0; 335 u32 first = 0;
277 u32 *buf; 336 u32 *buf;
337 int wpos;
338 int skip;
339 long wlength;
340 loff_t pos = *ppos;
278 341
279 mutex_lock(&t->mutex); 342 mutex_lock(&t->mutex);
280 343
@@ -286,31 +349,39 @@ static ssize_t etb_read(struct file *file, char __user *data,
286 etb_unlock(t); 349 etb_unlock(t);
287 350
288 total = etb_getdatalen(t); 351 total = etb_getdatalen(t);
352 if (total == 0 && t->dump_initial_etb)
353 total = t->etb_bufsz;
289 if (total == t->etb_bufsz) 354 if (total == t->etb_bufsz)
290 first = etb_readl(t, ETBR_WRITEADDR); 355 first = etb_readl(t, ETBR_WRITEADDR);
291 356