aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2017-05-02 05:02:41 -0400
committerJiri Kosina <jkosina@suse.cz>2017-05-02 05:02:41 -0400
commit4d6ca227c768b50b05cf183974b40abe444e9d0c (patch)
treebf953d8e895281053548b9967a2c4b58d641df00 /Documentation
parent800f3eef8ebc1264e9c135bfa892c8ae41fa4792 (diff)
parentaf22a610bc38508d5ea760507d31be6b6983dfa8 (diff)
Merge branch 'for-4.12/asus' into for-linus
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/00-INDEX4
-rw-r--r--Documentation/ABI/obsolete/sysfs-block-zram119
-rw-r--r--Documentation/ABI/testing/configfs-rdma_cm8
-rw-r--r--Documentation/ABI/testing/sysfs-block-zram101
-rw-r--r--Documentation/ABI/testing/sysfs-bus-i2c-devices-bq32k7
-rw-r--r--Documentation/ABI/testing/sysfs-bus-iio15
-rw-r--r--Documentation/ABI/testing/sysfs-bus-iio-adc-stm3218
-rw-r--r--Documentation/ABI/testing/sysfs-bus-iio-distance-srf0822
-rw-r--r--Documentation/ABI/testing/sysfs-bus-iio-timer-stm3229
-rw-r--r--Documentation/DMA-ISA-LPC.txt2
-rw-r--r--Documentation/DocBook/Makefile11
-rw-r--r--Documentation/DocBook/deviceiobook.tmpl323
-rw-r--r--Documentation/DocBook/iio.tmpl697
-rw-r--r--Documentation/DocBook/kgdb.tmpl8
-rw-r--r--Documentation/DocBook/libata.tmpl2
-rw-r--r--Documentation/DocBook/regulator.tmpl304
-rw-r--r--Documentation/DocBook/uio-howto.tmpl1112
-rw-r--r--Documentation/IPMI.txt2
-rw-r--r--Documentation/Makefile.sphinx34
-rw-r--r--Documentation/PCI/MSI-HOWTO.txt6
-rw-r--r--Documentation/PCI/PCIEBUS-HOWTO.txt33
-rw-r--r--Documentation/PCI/pci-error-recovery.txt24
-rw-r--r--Documentation/PCI/pci.txt24
-rw-r--r--Documentation/PCI/pcieaer-howto.txt2
-rw-r--r--Documentation/acpi/method-customizing.txt2
-rw-r--r--Documentation/acpi/method-tracing.txt2
-rw-r--r--Documentation/admin-guide/README.rst4
-rw-r--r--Documentation/admin-guide/dynamic-debug-howto.rst4
-rw-r--r--Documentation/admin-guide/kernel-parameters.txt32
-rw-r--r--Documentation/admin-guide/md.rst5
-rw-r--r--Documentation/admin-guide/ras.rst2
-rw-r--r--Documentation/arm/sunxi/README8
-rw-r--r--Documentation/arm64/cpu-feature-registers.txt240
-rw-r--r--Documentation/arm64/silicon-errata.txt48
-rw-r--r--Documentation/block/pr.txt2
-rw-r--r--Documentation/blockdev/mflash.txt2
-rw-r--r--Documentation/blockdev/zram.txt74
-rw-r--r--Documentation/cgroup-v1/cpusets.txt2
-rw-r--r--Documentation/cgroup-v1/rdma.txt109
-rw-r--r--Documentation/cgroup-v2.txt104
-rw-r--r--Documentation/conf.py4
-rw-r--r--Documentation/core-api/cpu_hotplug.rst372
-rw-r--r--Documentation/core-api/index.rst1
-rw-r--r--Documentation/cpu-freq/user-guide.txt4
-rw-r--r--Documentation/cpu-hotplug.txt452
-rw-r--r--Documentation/crypto/api-digest.rst2
-rw-r--r--Documentation/crypto/api-skcipher.rst2
-rw-r--r--Documentation/dev-tools/kcov.rst2
-rw-r--r--Documentation/dev-tools/sparse.rst6
-rw-r--r--Documentation/device-mapper/dm-raid.txt2
-rw-r--r--Documentation/devicetree/bindings/arm/amlogic.txt2
-rw-r--r--Documentation/devicetree/bindings/arm/axentia.txt19
-rw-r--r--Documentation/devicetree/bindings/arm/cpus.txt2
-rw-r--r--Documentation/devicetree/bindings/arm/davinci.txt4
-rw-r--r--Documentation/devicetree/bindings/arm/fsl.txt20
-rw-r--r--Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt4
-rw-r--r--Documentation/devicetree/bindings/arm/marvell/98dx3236-resume-ctrl.txt16
-rw-r--r--Documentation/devicetree/bindings/arm/marvell/98dx3236.txt23
-rw-r--r--Documentation/devicetree/bindings/arm/omap/omap.txt3
-rw-r--r--Documentation/devicetree/bindings/arm/shmobile.txt2
-rw-r--r--Documentation/devicetree/bindings/arm/sunxi.txt1
-rw-r--r--Documentation/devicetree/bindings/ata/ahci-da850.txt18
-rw-r--r--Documentation/devicetree/bindings/bus/qcom,ebi2.txt6
-rw-r--r--Documentation/devicetree/bindings/clock/brcm,bcm2835-cprman.txt15
-rw-r--r--Documentation/devicetree/bindings/clock/exynos4415-clock.txt38
-rw-r--r--Documentation/devicetree/bindings/clock/hi3660-clock.txt42
-rw-r--r--Documentation/devicetree/bindings/clock/idt,versaclock5.txt65
-rw-r--r--Documentation/devicetree/bindings/clock/mvebu-corediv-clock.txt1
-rw-r--r--Documentation/devicetree/bindings/clock/mvebu-cpu-clock.txt1
-rw-r--r--Documentation/devicetree/bindings/clock/mvebu-gated-clock.txt2
-rw-r--r--Documentation/devicetree/bindings/clock/qcom,rpmcc.txt1
-rw-r--r--Documentation/devicetree/bindings/clock/qoriq-clock.txt1
-rw-r--r--Documentation/devicetree/bindings/clock/renesas,cpg-mssr.txt6
-rw-r--r--Documentation/devicetree/bindings/clock/rockchip,rk3328-cru.txt57
-rw-r--r--Documentation/devicetree/bindings/clock/rockchip,rk3399-cru.txt6
-rw-r--r--Documentation/devicetree/bindings/clock/st,stm32-rcc.txt37
-rw-r--r--Documentation/devicetree/bindings/clock/stericsson,abx500.txt20
-rw-r--r--Documentation/devicetree/bindings/clock/sun9i-de.txt28
-rw-r--r--Documentation/devicetree/bindings/clock/sun9i-usb.txt24
-rw-r--r--Documentation/devicetree/bindings/clock/sunxi-ccu.txt2
-rw-r--r--Documentation/devicetree/bindings/clock/ti,cdce925.txt15
-rw-r--r--Documentation/devicetree/bindings/clock/zx296718-clk.txt3
-rw-r--r--Documentation/devicetree/bindings/crypto/brcm,spu-crypto.txt22
-rw-r--r--Documentation/devicetree/bindings/crypto/mediatek-crypto.txt27
-rw-r--r--Documentation/devicetree/bindings/display/arm,pl11x.txt2
-rw-r--r--Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt35
-rw-r--r--Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt12
-rw-r--r--Documentation/devicetree/bindings/display/bridge/analogix_dp.txt2
-rw-r--r--Documentation/devicetree/bindings/display/bridge/anx7814.txt (renamed from Documentation/devicetree/bindings/video/bridge/anx7814.txt)0
-rw-r--r--Documentation/devicetree/bindings/display/bridge/dw_hdmi.txt85
-rw-r--r--Documentation/devicetree/bindings/display/bridge/sil-sii8620.txt (renamed from Documentation/devicetree/bindings/video/bridge/sil-sii8620.txt)0
-rw-r--r--Documentation/devicetree/bindings/display/bridge/ti,ths8135.txt46
-rw-r--r--Documentation/devicetree/bindings/display/cirrus,clps711x-fb.txt2
-rw-r--r--Documentation/devicetree/bindings/display/exynos/exynos7-decon.txt4
-rw-r--r--Documentation/devicetree/bindings/display/exynos/samsung-fimd.txt2
-rw-r--r--Documentation/devicetree/bindings/display/hisilicon/hisi-ade.txt2
-rw-r--r--Documentation/devicetree/bindings/display/imx/fsl,imx-fb.txt2
-rw-r--r--Documentation/devicetree/bindings/display/imx/hdmi.txt51
-rw-r--r--Documentation/devicetree/bindings/display/imx/ldb.txt2
-rw-r--r--Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt2
-rw-r--r--Documentation/devicetree/bindings/display/msm/dsi.txt2
-rw-r--r--Documentation/devicetree/bindings/display/msm/edp.txt2
-rw-r--r--Documentation/devicetree/bindings/display/msm/gpu.txt38
-rw-r--r--Documentation/devicetree/bindings/display/msm/hdmi.txt2
-rw-r--r--Documentation/devicetree/bindings/display/multi-inno,mi0283qt.txt27
-rw-r--r--Documentation/devicetree/bindings/display/panel/boe,nv101wxmn51.txt7
-rw-r--r--Documentation/devicetree/bindings/display/panel/netron-dy,e231732.txt7
-rw-r--r--Documentation/devicetree/bindings/display/panel/panel-dpi.txt2
-rw-r--r--Documentation/devicetree/bindings/display/panel/panel.txt4
-rw-r--r--Documentation/devicetree/bindings/display/panel/samsung,ld9040.txt2
-rw-r--r--Documentation/devicetree/bindings/display/panel/samsung,s6e8aa0.txt2
-rw-r--r--Documentation/devicetree/bindings/display/panel/tianma,tm070jdhg30.txt7
-rw-r--r--Documentation/devicetree/bindings/display/rockchip/analogix_dp-rockchip.txt2
-rw-r--r--Documentation/devicetree/bindings/display/rockchip/dw_hdmi-rockchip.txt43
-rw-r--r--Documentation/devicetree/bindings/display/ssd1307fb.txt5
-rw-r--r--Documentation/devicetree/bindings/display/tilcdc/panel.txt2
-rw-r--r--Documentation/devicetree/bindings/display/zte,vou.txt15
-rw-r--r--Documentation/devicetree/bindings/eeprom/eeprom.txt2
-rw-r--r--Documentation/devicetree/bindings/gpio/cortina,gemini-gpio.txt24
-rw-r--r--Documentation/devicetree/bindings/gpio/gpio-pca953x.txt4
-rw-r--r--Documentation/devicetree/bindings/gpio/gpio.txt8
-rw-r--r--Documentation/devicetree/bindings/gpu/arm,mali-utgard.txt81
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt14
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-sh_mobile.txt1
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-stm32.txt33
-rw-r--r--Documentation/devicetree/bindings/i2c/nvidia,tegra186-bpmp-i2c.txt42
-rw-r--r--Documentation/devicetree/bindings/i2c/trivial-devices.txt1
-rw-r--r--Documentation/devicetree/bindings/iio/accel/lis302.txt2
-rw-r--r--Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt32
-rw-r--r--Documentation/devicetree/bindings/iio/adc/avia-hx711.txt18
-rw-r--r--Documentation/devicetree/bindings/iio/adc/max11100.txt18
-rw-r--r--Documentation/devicetree/bindings/iio/adc/qcom,pm8xxx-xoadc.txt149
-rw-r--r--Documentation/devicetree/bindings/iio/adc/renesas,gyroadc.txt99
-rw-r--r--Documentation/devicetree/bindings/iio/adc/st,stm32-adc.txt7
-rw-r--r--Documentation/devicetree/bindings/iio/adc/ti-ads7950.txt23
-rw-r--r--Documentation/devicetree/bindings/iio/imu/bmi160.txt36
-rw-r--r--Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt26
-rw-r--r--Documentation/devicetree/bindings/iio/light/cm3605.txt41
-rw-r--r--Documentation/devicetree/bindings/iio/potentiometer/max5481.txt23
-rw-r--r--Documentation/devicetree/bindings/iio/st-sensors.txt2
-rw-r--r--Documentation/devicetree/bindings/iio/temperature/tmp007.txt35
-rw-r--r--Documentation/devicetree/bindings/iio/timer/stm32-timer-trigger.txt23
-rw-r--r--Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt27
-rw-r--r--Documentation/devicetree/bindings/input/mpr121-touchkey.txt30
-rw-r--r--Documentation/devicetree/bindings/input/pwm-beeper.txt16
-rw-r--r--Documentation/devicetree/bindings/input/touchscreen/zet6223.txt32
-rw-r--r--Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt2
-rw-r--r--Documentation/devicetree/bindings/interrupt-controller/snps,archs-idu-intc.txt24
-rw-r--r--Documentation/devicetree/bindings/iommu/arm,smmu.txt10
-rw-r--r--Documentation/devicetree/bindings/mfd/as3722.txt3
-rw-r--r--Documentation/devicetree/bindings/mfd/aspeed-gfx.txt17
-rw-r--r--Documentation/devicetree/bindings/mfd/aspeed-lpc.txt137
-rw-r--r--Documentation/devicetree/bindings/mfd/mfd.txt12
-rw-r--r--Documentation/devicetree/bindings/mfd/motorola-cpcap.txt31
-rw-r--r--Documentation/devicetree/bindings/mfd/mt6397.txt4
-rw-r--r--Documentation/devicetree/bindings/mfd/omap-usb-host.txt4
-rw-r--r--Documentation/devicetree/bindings/mfd/qcom-rpm.txt2
-rw-r--r--Documentation/devicetree/bindings/mfd/stm32-timers.txt46
-rw-r--r--Documentation/devicetree/bindings/misc/atmel-ssc.txt2
-rw-r--r--Documentation/devicetree/bindings/misc/idt_89hpesx.txt44
-rw-r--r--Documentation/devicetree/bindings/net/brcm,bcm7445-switch-v4.0.txt10
-rw-r--r--Documentation/devicetree/bindings/net/brcm,systemport.txt5
-rw-r--r--Documentation/devicetree/bindings/net/btusb.txt43
-rw-r--r--Documentation/devicetree/bindings/net/cpsw.txt3
-rw-r--r--Documentation/devicetree/bindings/net/dsa/dsa.txt20
-rw-r--r--Documentation/devicetree/bindings/net/dsa/marvell.txt93
-rw-r--r--Documentation/devicetree/bindings/net/ethernet.txt3
-rw-r--r--Documentation/devicetree/bindings/net/marvell,prestera.txt50
-rw-r--r--Documentation/devicetree/bindings/net/marvell-armada-370-neta.txt2
-rw-r--r--Documentation/devicetree/bindings/net/marvell-bt-8xxx.txt (renamed from Documentation/devicetree/bindings/net/marvell-bt-sd8xxx.txt)46
-rw-r--r--Documentation/devicetree/bindings/net/marvell-pp2.txt4
-rw-r--r--Documentation/devicetree/bindings/net/meson-dwmac.txt16
-rw-r--r--Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt10
-rw-r--r--Documentation/devicetree/bindings/net/phy.txt4
-rw-r--r--Documentation/devicetree/bindings/net/rockchip-dwmac.txt1
-rw-r--r--Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt3
-rw-r--r--Documentation/devicetree/bindings/net/stmmac.txt3
-rw-r--r--Documentation/devicetree/bindings/net/wireless/ieee80211.txt24
-rw-r--r--Documentation/devicetree/bindings/nvmem/imx-ocotp.txt6
-rw-r--r--Documentation/devicetree/bindings/opp/opp.txt46
-rw-r--r--Documentation/devicetree/bindings/pci/hisilicon-pcie.txt37
-rw-r--r--Documentation/devicetree/bindings/pci/mvebu-pci.txt3
-rw-r--r--Documentation/devicetree/bindings/pci/pci-iommu.txt6
-rw-r--r--Documentation/devicetree/bindings/pci/rcar-pci.txt1
-rw-r--r--Documentation/devicetree/bindings/pci/rockchip-pcie.txt2
-rw-r--r--Documentation/devicetree/bindings/pci/samsung,exynos5440-pcie.txt29
-rw-r--r--Documentation/devicetree/bindings/phy/brcm,nsp-usb3-phy.txt39
-rw-r--r--Documentation/devicetree/bindings/phy/qcom,usb-hs-phy.txt84
-rw-r--r--Documentation/devicetree/bindings/phy/qcom,usb-hsic-phy.txt65
-rw-r--r--Documentation/devicetree/bindings/phy/samsung-phy.txt17
-rw-r--r--Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt1
-rw-r--r--Documentation/devicetree/bindings/pinctrl/allwinner,sunxi-pinctrl.txt2
-rw-r--r--Documentation/devicetree/bindings/power/pd-samsung.txt7
-rw-r--r--Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt10
-rw-r--r--Documentation/devicetree/bindings/power/reset/qnap-poweroff.txt3
-rw-r--r--Documentation/devicetree/bindings/powerpc/4xx/emac.txt62
-rw-r--r--Documentation/devicetree/bindings/powerpc/fsl/l2cache.txt42
-rw-r--r--Documentation/devicetree/bindings/powerpc/opal/power-mgt.txt118
-rw-r--r--Documentation/devicetree/bindings/pwm/imx-pwm.txt6
-rw-r--r--Documentation/devicetree/bindings/pwm/pwm-stm32.txt35
-rw-r--r--Documentation/devicetree/bindings/regulator/ti-abb-regulator.txt2
-rw-r--r--Documentation/devicetree/bindings/remoteproc/qcom,adsp.txt41
-rw-r--r--Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt4
-rw-r--r--Documentation/devicetree/bindings/reset/hisilicon,hi3660-reset.txt43
-rw-r--r--Documentation/devicetree/bindings/reset/ti-syscon-reset.txt8
-rw-r--r--Documentation/devicetree/bindings/reset/uniphier-reset.txt47
-rw-r--r--Documentation/devicetree/bindings/reset/zte,zx2967-reset.txt20
-rw-r--r--Documentation/devicetree/bindings/rtc/armada-380-rtc.txt8
-rw-r--r--Documentation/devicetree/bindings/rtc/cortina,gemini.txt14
-rw-r--r--Documentation/devicetree/bindings/rtc/imxdi-rtc.txt5
-rw-r--r--Documentation/devicetree/bindings/rtc/maxim,ds3231.txt3
-rw-r--r--Documentation/devicetree/bindings/rtc/pcf8563.txt3
-rw-r--r--Documentation/devicetree/bindings/rtc/st,stm32-rtc.txt27
-rw-r--r--Documentation/devicetree/bindings/rtc/sun6i-rtc.txt10
-rw-r--r--Documentation/devicetree/bindings/serial/8250.txt1
-rw-r--r--Documentation/devicetree/bindings/serial/fsl-imx-uart.txt4
-rw-r--r--Documentation/devicetree/bindings/serial/serial.txt3
-rw-r--r--Documentation/devicetree/bindings/serial/slave-device.txt36
-rw-r--r--Documentation/devicetree/bindings/soc/fsl/qman-portals.txt20
-rw-r--r--Documentation/devicetree/bindings/soc/rockchip/grf.txt8
-rw-r--r--Documentation/devicetree/bindings/soc/rockchip/power_domain.txt3
-rw-r--r--Documentation/devicetree/bindings/soc/zte/pd-2967xx.txt19
-rw-r--r--Documentation/devicetree/bindings/sound/axentia,tse850-pcm5142.txt11
-rw-r--r--Documentation/devicetree/bindings/sound/es8328.txt2
-rw-r--r--Documentation/devicetree/bindings/sound/mt2701-afe-pcm.txt2
-rw-r--r--Documentation/devicetree/bindings/sound/nau8540.txt16
-rw-r--r--Documentation/devicetree/bindings/sound/rockchip,rk3288-hdmi-analog.txt36
-rw-r--r--Documentation/devicetree/bindings/sound/rockchip-i2s.txt4
-rw-r--r--[-rwxr-xr-x]Documentation/devicetree/bindings/sound/rt5665.txt0
-rw-r--r--Documentation/devicetree/bindings/sound/sun4i-codec.txt2
-rw-r--r--Documentation/devicetree/bindings/sound/sun4i-i2s.txt9
-rw-r--r--Documentation/devicetree/bindings/sound/sun8i-a33-codec.txt63
-rw-r--r--Documentation/devicetree/bindings/sound/sunxi,sun4i-spdif.txt1
-rw-r--r--Documentation/devicetree/bindings/sound/zte,zx-i2s.txt14
-rw-r--r--Documentation/devicetree/bindings/sram/sram.txt6
-rw-r--r--Documentation/devicetree/bindings/thermal/qoriq-thermal.txt7
-rw-r--r--Documentation/devicetree/bindings/thermal/rcar-gen3-thermal.txt56
-rw-r--r--Documentation/devicetree/bindings/thermal/zx2967-thermal.txt116
-rw-r--r--Documentation/devicetree/bindings/ufs/ufs-qcom.txt1
-rw-r--r--Documentation/devicetree/bindings/usb/allwinner,sun4i-a10-musb.txt4
-rw-r--r--Documentation/devicetree/bindings/usb/dwc3-st.txt4
-rw-r--r--Documentation/devicetree/bindings/usb/dwc3.txt4
-rw-r--r--Documentation/devicetree/bindings/usb/ehci-omap.txt1
-rw-r--r--Documentation/devicetree/bindings/usb/ehci-st.txt2
-rw-r--r--Documentation/devicetree/bindings/usb/mt8173-mtu3.txt12
-rw-r--r--Documentation/devicetree/bindings/usb/mt8173-xhci.txt14
-rw-r--r--Documentation/devicetree/bindings/usb/qcom,dwc3.txt2
-rw-r--r--Documentation/devicetree/bindings/usb/ulpi.txt20
-rw-r--r--Documentation/devicetree/bindings/usb/usb-xhci.txt1
-rw-r--r--Documentation/devicetree/bindings/usb/usb251xb.txt66
-rw-r--r--Documentation/devicetree/bindings/vendor-prefixes.txt15
-rw-r--r--Documentation/devicetree/bindings/watchdog/cortina,gemin-watchdog.txt17
-rw-r--r--Documentation/devicetree/bindings/watchdog/samsung-wdt.txt9
-rw-r--r--Documentation/devicetree/bindings/watchdog/zte,zx2967-wdt.txt32
-rw-r--r--Documentation/dma-buf-sharing.txt482
-rw-r--r--Documentation/dontdiff7
-rw-r--r--Documentation/driver-api/80211/cfg80211.rst3
-rw-r--r--Documentation/driver-api/device-io.rst201
-rw-r--r--Documentation/driver-api/device_link.rst18
-rw-r--r--Documentation/driver-api/dma-buf.rst92
-rw-r--r--Documentation/driver-api/firmware/built-in-fw.rst38
-rw-r--r--Documentation/driver-api/firmware/core.rst16
-rw-r--r--Documentation/driver-api/firmware/direct-fs-lookup.rst30
-rw-r--r--Documentation/driver-api/firmware/fallback-mechanisms.rst195
-rw-r--r--Documentation/driver-api/firmware/firmware_cache.rst51
-rw-r--r--Documentation/driver-api/firmware/fw_search_path.rst26
-rw-r--r--Documentation/driver-api/firmware/index.rst16
-rw-r--r--Documentation/driver-api/firmware/introduction.rst27
-rw-r--r--Documentation/driver-api/firmware/lookup-order.rst18
-rw-r--r--Documentation/driver-api/firmware/request_firmware.rst56
-rw-r--r--Documentation/driver-api/iio/buffers.rst125
-rw-r--r--Documentation/driver-api/iio/core.rst182
-rw-r--r--Documentation/driver-api/iio/index.rst17
-rw-r--r--Documentation/driver-api/iio/intro.rst33
-rw-r--r--Documentation/driver-api/iio/triggered-buffers.rst69
-rw-r--r--Documentation/driver-api/iio/triggers.rst80
-rw-r--r--Documentation/driver-api/index.rst6
-rw-r--r--Documentation/driver-api/pm/conf.py10
-rw-r--r--Documentation/driver-api/pm/devices.rst736
-rw-r--r--Documentation/driver-api/pm/index.rst16
-rw-r--r--Documentation/driver-api/pm/notifiers.rst70
-rw-r--r--Documentation/driver-api/pm/types.rst5
-rw-r--r--Documentation/driver-api/regulator.rst170
-rw-r--r--Documentation/driver-api/uio-howto.rst705
-rw-r--r--Documentation/extcon/intel-int3496.txt22
-rw-r--r--Documentation/filesystems/Locking3
-rw-r--r--Documentation/filesystems/afs.txt34
-rw-r--r--Documentation/filesystems/autofs4-mount-control.txt1
-rw-r--r--Documentation/filesystems/autofs4.txt39
-rw-r--r--Documentation/filesystems/ceph.txt5
-rw-r--r--Documentation/filesystems/f2fs.txt7
-rw-r--r--Documentation/filesystems/quota.txt2
-rw-r--r--Documentation/filesystems/vfs.txt3
-rw-r--r--Documentation/firmware_class/README128
-rw-r--r--Documentation/fpga/fpga-mgr.txt19
-rw-r--r--Documentation/gpio/driver.txt55
-rw-r--r--Documentation/gpu/drm-kms.rst8
-rw-r--r--Documentation/gpu/drm-mm.rst61
-rw-r--r--Documentation/gpu/drm-uapi.rst25
-rw-r--r--Documentation/gpu/i915.rst112
-rw-r--r--Documentation/gpu/index.rst1
-rw-r--r--Documentation/gpu/introduction.rst15
-rw-r--r--Documentation/gpu/tinydrm.rst42
-rw-r--r--Documentation/hwmon/ds16218
-rw-r--r--Documentation/i2c/busses/i2c-i8011
-rw-r--r--Documentation/i2c/muxes/i2c-mux-gpio20
-rw-r--r--Documentation/index.rst10
-rw-r--r--Documentation/input/input.txt4
-rw-r--r--Documentation/ioctl/botching-up-ioctls.txt2
-rw-r--r--Documentation/ioctl/ioctl-number.txt1
-rw-r--r--Documentation/kselftest.txt16
-rw-r--r--Documentation/livepatch/livepatch.txt2
-rw-r--r--Documentation/md/md-cluster.txt (renamed from Documentation/md-cluster.txt)0
-rw-r--r--Documentation/md/raid5-cache.txt109
-rw-r--r--Documentation/media/Makefile3
-rw-r--r--Documentation/media/dvb-drivers/ci.rst2
-rw-r--r--Documentation/media/uapi/dvb/dvb-frontend-parameters.rst4
-rw-r--r--Documentation/media/v4l-drivers/bttv.rst2
-rw-r--r--Documentation/memory-hotplug.txt4
-rw-r--r--Documentation/networking/cdc_mbim.txt4
-rw-r--r--Documentation/networking/dsa/dsa.txt24
-rw-r--r--Documentation/networking/gtp.txt135
-rw-r--r--Documentation/networking/ip-sysctl.txt50
-rw-r--r--Documentation/networking/kcm.txt2
-rw-r--r--Documentation/networking/netfilter-sysctl.txt10
-rw-r--r--Documentation/networking/packet_mmap.txt9
-rw-r--r--Documentation/networking/regulatory.txt8
-rw-r--r--Documentation/networking/vrf.txt7
-rw-r--r--Documentation/perf/qcom_l2_pmu.txt38
-rw-r--r--Documentation/power/00-INDEX2
-rw-r--r--Documentation/power/devices.txt716
-rw-r--r--Documentation/power/freezing-of-tasks.txt3
-rw-r--r--Documentation/power/notifiers.txt55
-rw-r--r--Documentation/power/pci.txt2
-rw-r--r--Documentation/power/pm_qos_interface.txt13
-rw-r--r--Documentation/power/runtime_pm.txt6
-rw-r--r--Documentation/pps/pps.txt18
-rw-r--r--Documentation/s390/Debugging390.txt2
-rw-r--r--Documentation/scsi/ChangeLog.megaraid_sas2
-rw-r--r--Documentation/security/keys.txt17
-rw-r--r--Documentation/security/self-protection.txt10
-rw-r--r--Documentation/siphash.txt175
-rw-r--r--Documentation/sound/hd-audio/dp-mst.rst17
-rw-r--r--Documentation/sound/hd-audio/notes.rst2
-rw-r--r--Documentation/sparc/console.txt9
-rw-r--r--Documentation/static-keys.txt4
-rw-r--r--Documentation/sysctl/kernel.txt2
-rw-r--r--Documentation/sysctl/net.txt33
-rw-r--r--Documentation/sysctl/vm.txt4
-rw-r--r--Documentation/thermal/nouveau_thermal2
-rw-r--r--Documentation/trace/kprobetrace.txt2
-rw-r--r--Documentation/trace/postprocess/trace-vmscan-postprocess.pl26
-rw-r--r--Documentation/trace/uprobetracer.txt2
-rw-r--r--Documentation/translations/ja_JP/HOWTO2
-rw-r--r--Documentation/translations/ko_KR/howto.rst4
-rw-r--r--Documentation/translations/ko_KR/memory-barriers.txt68
-rw-r--r--Documentation/translations/zh_CN/CodingStyle813
-rw-r--r--Documentation/translations/zh_CN/coding-style.rst950
-rw-r--r--Documentation/translations/zh_CN/index.rst12
-rw-r--r--Documentation/usb/gadget-testing.txt2
-rw-r--r--Documentation/usb/power-management.txt2
-rw-r--r--Documentation/virtual/kvm/api.txt221
-rw-r--r--Documentation/virtual/kvm/devices/arm-vgic-v3.txt11
-rw-r--r--Documentation/virtual/kvm/hypercalls.txt35
-rw-r--r--Documentation/virtual/kvm/locking.txt31
-rw-r--r--Documentation/virtual/uml/UserModeLinux-HOWTO.txt6
-rw-r--r--Documentation/vm/ksm.txt18
-rw-r--r--Documentation/vm/transhuge.txt10
-rw-r--r--Documentation/vm/userfaultfd.txt87
-rw-r--r--Documentation/watchdog/watchdog-kernel-api.txt6
-rw-r--r--Documentation/watchdog/watchdog-parameters.txt5
-rw-r--r--Documentation/x86/intel_rdt_ui.txt114
372 files changed, 10237 insertions, 6212 deletions
diff --git a/Documentation/00-INDEX b/Documentation/00-INDEX
index c8a8eb1a2b11..793acf999e9e 100644
--- a/Documentation/00-INDEX
+++ b/Documentation/00-INDEX
@@ -270,8 +270,8 @@ m68k/
270 - directory with info about Linux on Motorola 68k architecture. 270 - directory with info about Linux on Motorola 68k architecture.
271mailbox.txt 271mailbox.txt
272 - How to write drivers for the common mailbox framework (IPC). 272 - How to write drivers for the common mailbox framework (IPC).
273md-cluster.txt 273md/
274 - info on shared-device RAID MD cluster. 274 - directory with info about Linux Software RAID
275media/ 275media/
276 - info on media drivers: uAPI, kAPI and driver documentation. 276 - info on media drivers: uAPI, kAPI and driver documentation.
277memory-barriers.txt 277memory-barriers.txt
diff --git a/Documentation/ABI/obsolete/sysfs-block-zram b/Documentation/ABI/obsolete/sysfs-block-zram
deleted file mode 100644
index 720ea92cfb2e..000000000000
--- a/Documentation/ABI/obsolete/sysfs-block-zram
+++ /dev/null
@@ -1,119 +0,0 @@
1What: /sys/block/zram<id>/num_reads
2Date: August 2015
3Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
4Description:
5 The num_reads file is read-only and specifies the number of
6 reads (failed or successful) done on this device.
7 Now accessible via zram<id>/stat node.
8
9What: /sys/block/zram<id>/num_writes
10Date: August 2015
11Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
12Description:
13 The num_writes file is read-only and specifies the number of
14 writes (failed or successful) done on this device.
15 Now accessible via zram<id>/stat node.
16
17What: /sys/block/zram<id>/invalid_io
18Date: August 2015
19Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
20Description:
21 The invalid_io file is read-only and specifies the number of
22 non-page-size-aligned I/O requests issued to this device.
23 Now accessible via zram<id>/io_stat node.
24
25What: /sys/block/zram<id>/failed_reads
26Date: August 2015
27Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
28Description:
29 The failed_reads file is read-only and specifies the number of
30 failed reads happened on this device.
31 Now accessible via zram<id>/io_stat node.
32
33What: /sys/block/zram<id>/failed_writes
34Date: August 2015
35Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
36Description:
37 The failed_writes file is read-only and specifies the number of
38 failed writes happened on this device.
39 Now accessible via zram<id>/io_stat node.
40
41What: /sys/block/zram<id>/notify_free
42Date: August 2015
43Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
44Description:
45 The notify_free file is read-only. Depending on device usage
46 scenario it may account a) the number of pages freed because
47 of swap slot free notifications or b) the number of pages freed
48 because of REQ_DISCARD requests sent by bio. The former ones
49 are sent to a swap block device when a swap slot is freed, which
50 implies that this disk is being used as a swap disk. The latter
51 ones are sent by filesystem mounted with discard option,
52 whenever some data blocks are getting discarded.
53 Now accessible via zram<id>/io_stat node.
54
55What: /sys/block/zram<id>/zero_pages
56Date: August 2015
57Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
58Description:
59 The zero_pages file is read-only and specifies number of zero
60 filled pages written to this disk. No memory is allocated for
61 such pages.
62 Now accessible via zram<id>/mm_stat node.
63
64What: /sys/block/zram<id>/orig_data_size
65Date: August 2015
66Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
67Description:
68 The orig_data_size file is read-only and specifies uncompressed
69 size of data stored in this disk. This excludes zero-filled
70 pages (zero_pages) since no memory is allocated for them.
71 Unit: bytes
72 Now accessible via zram<id>/mm_stat node.
73
74What: /sys/block/zram<id>/compr_data_size
75Date: August 2015
76Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
77Description:
78 The compr_data_size file is read-only and specifies compressed
79 size of data stored in this disk. So, compression ratio can be
80 calculated using orig_data_size and this statistic.
81 Unit: bytes
82 Now accessible via zram<id>/mm_stat node.
83
84What: /sys/block/zram<id>/mem_used_total
85Date: August 2015
86Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
87Description:
88 The mem_used_total file is read-only and specifies the amount
89 of memory, including allocator fragmentation and metadata
90 overhead, allocated for this disk. So, allocator space
91 efficiency can be calculated using compr_data_size and this
92 statistic.
93 Unit: bytes
94 Now accessible via zram<id>/mm_stat node.
95
96What: /sys/block/zram<id>/mem_used_max
97Date: August 2015
98Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
99Description:
100 The mem_used_max file is read/write and specifies the amount
101 of maximum memory zram have consumed to store compressed data.
102 For resetting the value, you should write "0". Otherwise,
103 you could see -EINVAL.
104 Unit: bytes
105 Downgraded to write-only node: so it's possible to set new
106 value only; its current value is stored in zram<id>/mm_stat
107 node.
108
109What: /sys/block/zram<id>/mem_limit
110Date: August 2015
111Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
112Description:
113 The mem_limit file is read/write and specifies the maximum
114 amount of memory ZRAM can use to store the compressed data.
115 The limit could be changed in run time and "0" means disable
116 the limit. No limit is the initial state. Unit: bytes
117 Downgraded to write-only node: so it's possible to set new
118 value only; its current value is stored in zram<id>/mm_stat
119 node.
diff --git a/Documentation/ABI/testing/configfs-rdma_cm b/Documentation/ABI/testing/configfs-rdma_cm
index 5c389aaf5291..74f9506f42e7 100644
--- a/Documentation/ABI/testing/configfs-rdma_cm
+++ b/Documentation/ABI/testing/configfs-rdma_cm
@@ -20,3 +20,11 @@ Description: RDMA-CM based connections from HCA <hca> at port <port-num>
20 will be initiated with this RoCE type as default. 20 will be initiated with this RoCE type as default.
21 The possible RoCE types are either "IB/RoCE v1" or "RoCE v2". 21 The possible RoCE types are either "IB/RoCE v1" or "RoCE v2".
22 This parameter has RW access. 22 This parameter has RW access.
23
24What: /config/rdma_cm/<hca>/ports/<port-num>/default_roce_tos
25Date: February 7, 2017
26KernelVersion: 4.11.0
27Description: RDMA-CM QPs from HCA <hca> at port <port-num>
28 will be created with this TOS as default.
29 This can be overridden by using the rdma_set_option API.
30 The possible RoCE TOS values are 0-255.
diff --git a/Documentation/ABI/testing/sysfs-block-zram b/Documentation/ABI/testing/sysfs-block-zram
index 4518d30b8c2e..451b6d882b2c 100644
--- a/Documentation/ABI/testing/sysfs-block-zram
+++ b/Documentation/ABI/testing/sysfs-block-zram
@@ -22,41 +22,6 @@ Description:
22 device. The reset operation frees all the memory associated 22 device. The reset operation frees all the memory associated
23 with this device. 23 with this device.
24 24
25What: /sys/block/zram<id>/num_reads
26Date: August 2010
27Contact: Nitin Gupta <ngupta@vflare.org>
28Description:
29 The num_reads file is read-only and specifies the number of
30 reads (failed or successful) done on this device.
31
32What: /sys/block/zram<id>/num_writes
33Date: August 2010
34Contact: Nitin Gupta <ngupta@vflare.org>
35Description:
36 The num_writes file is read-only and specifies the number of
37 writes (failed or successful) done on this device.
38
39What: /sys/block/zram<id>/invalid_io
40Date: August 2010
41Contact: Nitin Gupta <ngupta@vflare.org>
42Description:
43 The invalid_io file is read-only and specifies the number of
44 non-page-size-aligned I/O requests issued to this device.
45
46What: /sys/block/zram<id>/failed_reads
47Date: February 2014
48Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
49Description:
50 The failed_reads file is read-only and specifies the number of
51 failed reads happened on this device.
52
53What: /sys/block/zram<id>/failed_writes
54Date: February 2014
55Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
56Description:
57 The failed_writes file is read-only and specifies the number of
58 failed writes happened on this device.
59
60What: /sys/block/zram<id>/max_comp_streams 25What: /sys/block/zram<id>/max_comp_streams
61Date: February 2014 26Date: February 2014
62Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> 27Contact: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
@@ -73,74 +38,24 @@ Description:
73 available and selected compression algorithms, change 38 available and selected compression algorithms, change
74 compression algorithm selection. 39 compression algorithm selection.
75 40
76What: /sys/block/zram<id>/notify_free
77Date: August 2010
78Contact: Nitin Gupta <ngupta@vflare.org>
79Description:
80 The notify_free file is read-only. Depending on device usage
81 scenario it may account a) the number of pages freed because
82 of swap slot free notifications or b) the number of pages freed
83 because of REQ_DISCARD requests sent by bio. The former ones
84 are sent to a swap block device when a swap slot is freed, which
85 implies that this disk is being used as a swap disk. The latter
86 ones are sent by filesystem mounted with discard option,
87 whenever some data blocks are getting discarded.
88
89What: /sys/block/zram<id>/zero_pages
90Date: August 2010
91Contact: Nitin Gupta <ngupta@vflare.org>
92Description:
93 The zero_pages file is read-only and specifies number of zero
94 filled pages written to this disk. No memory is allocated for
95 such pages.
96
97What: /sys/block/zram<id>/orig_data_size
98Date: August 2010
99Contact: Nitin Gupta <ngupta@vflare.org>
100Description:
101 The orig_data_size file is read-only and specifies uncompressed
102 size of data stored in this disk. This excludes zero-filled
103 pages (zero_pages) since no memory is allocated for them.
104 Unit: bytes
105
106What: /sys/block/zram<id>/compr_data_size
107Date: August 2010
108Contact: Nitin Gupta <ngupta@vflare.org>
109Description:
110 The compr_data_size file is read-only and specifies compressed
111 size of data stored in this disk. So, compression ratio can be
112 calculated using orig_data_size and this statistic.
113 Unit: bytes
114
115What: /sys/block/zram<id>/mem_used_total
116Date: August 2010
117Contact: Nitin Gupta <ngupta@vflare.org>
118Description:
119 The mem_used_total file is read-only and specifies the amount
120 of memory, including allocator fragmentation and metadata
121 overhead, allocated for this disk. So, allocator space
122 efficiency can be calculated using compr_data_size and this
123 statistic.
124 Unit: bytes
125
126What: /sys/block/zram<id>/mem_used_max 41What: /sys/block/zram<id>/mem_used_max
127Date: August 2014 42Date: August 2014
128Contact: Minchan Kim <minchan@kernel.org> 43Contact: Minchan Kim <minchan@kernel.org>
129Description: 44Description:
130 The mem_used_max file is read/write and specifies the amount 45 The mem_used_max file is write-only and is used to reset
131 of maximum memory zram have consumed to store compressed data. 46 the counter of maximum memory zram have consumed to store
132 For resetting the value, you should write "0". Otherwise, 47 compressed data. For resetting the value, you should write
133 you could see -EINVAL. 48 "0". Otherwise, you could see -EINVAL.
134 Unit: bytes 49 Unit: bytes
135 50
136What: /sys/block/zram<id>/mem_limit 51What: /sys/block/zram<id>/mem_limit
137Date: August 2014 52Date: August 2014
138Contact: Minchan Kim <minchan@kernel.org> 53Contact: Minchan Kim <minchan@kernel.org>
139Description: 54Description:
140 The mem_limit file is read/write and specifies the maximum 55 The mem_limit file is write-only and specifies the maximum
141 amount of memory ZRAM can use to store the compressed data. The 56 amount of memory ZRAM can use to store the compressed data.
142 limit could be changed in run time and "0" means disable the 57 The limit could be changed in run time and "0" means disable
143 limit. No limit is the initial state. Unit: bytes 58 the limit. No limit is the initial state. Unit: bytes
144 59
145What: /sys/block/zram<id>/compact 60What: /sys/block/zram<id>/compact
146Date: August 2015 61Date: August 2015
diff --git a/Documentation/ABI/testing/sysfs-bus-i2c-devices-bq32k b/Documentation/ABI/testing/sysfs-bus-i2c-devices-bq32k
new file mode 100644
index 000000000000..398b258fb770
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-i2c-devices-bq32k
@@ -0,0 +1,7 @@
1What: /sys/bus/i2c/devices/.../trickle_charge_bypass
2Date: Jan 2017
3KernelVersion: 4.11
4Contact: Enric Balletbo i Serra <eballetbo@gmail.com>
5Description: Attribute for enable/disable the trickle charge bypass
6 The trickle_charge_bypass attribute allows the userspace to
7 enable/disable the Trickle charge FET bypass.
diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index b8f220f978dd..530809ccfacf 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -170,6 +170,16 @@ Description:
170 Has all of the equivalent parameters as per voltageY. Units 170 Has all of the equivalent parameters as per voltageY. Units
171 after application of scale and offset are m/s^2. 171 after application of scale and offset are m/s^2.
172 172
173What: /sys/bus/iio/devices/iio:deviceX/in_gravity_x_raw
174What: /sys/bus/iio/devices/iio:deviceX/in_gravity_y_raw
175What: /sys/bus/iio/devices/iio:deviceX/in_gravity_z_raw
176KernelVersion: 4.11
177Contact: linux-iio@vger.kernel.org
178Description:
179 Gravity in direction x, y or z (may be arbitrarily assigned
180 but should match other such assignments on device).
181 Units after application of scale and offset are m/s^2.
182
173What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_x_raw 183What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_x_raw
174What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_y_raw 184What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_y_raw
175What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_z_raw 185What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_z_raw
@@ -805,7 +815,7 @@ Description:
805 attribute. E.g. if in_voltage0_raw_thresh_rising_value is set to 1200 815 attribute. E.g. if in_voltage0_raw_thresh_rising_value is set to 1200
806 and in_voltage0_raw_thresh_rising_hysteresis is set to 50. The event 816 and in_voltage0_raw_thresh_rising_hysteresis is set to 50. The event
807 will get activated once in_voltage0_raw goes above 1200 and will become 817 will get activated once in_voltage0_raw goes above 1200 and will become
808 deactived again once the value falls below 1150. 818 deactivated again once the value falls below 1150.
809 819
810What: /sys/.../events/in_accel_x_raw_roc_rising_value 820What: /sys/.../events/in_accel_x_raw_roc_rising_value
811What: /sys/.../events/in_accel_x_raw_roc_falling_value 821What: /sys/.../events/in_accel_x_raw_roc_falling_value
@@ -1245,7 +1255,8 @@ Description:
1245 reflectivity of infrared or ultrasound emitted. 1255 reflectivity of infrared or ultrasound emitted.
1246 Often these sensors are unit less and as such conversion 1256 Often these sensors are unit less and as such conversion
1247 to SI units is not possible. Higher proximity measurements 1257 to SI units is not possible. Higher proximity measurements
1248 indicate closer objects, and vice versa. 1258 indicate closer objects, and vice versa. Units after
1259 application of scale and offset are meters.
1249 1260
1250What: /sys/.../iio:deviceX/in_illuminance_input 1261What: /sys/.../iio:deviceX/in_illuminance_input
1251What: /sys/.../iio:deviceX/in_illuminance_raw 1262What: /sys/.../iio:deviceX/in_illuminance_raw
diff --git a/Documentation/ABI/testing/sysfs-bus-iio-adc-stm32 b/Documentation/ABI/testing/sysfs-bus-iio-adc-stm32
new file mode 100644
index 000000000000..efe4c85e3c8b
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-iio-adc-stm32
@@ -0,0 +1,18 @@
1What: /sys/bus/iio/devices/triggerX/trigger_polarity
2KernelVersion: 4.11
3Contact: fabrice.gasnier@st.com
4Description:
5 The STM32 ADC can be configured to use external trigger sources
6 (e.g. timers, pwm or exti gpio). Then, it can be tuned to start
7 conversions on external trigger by either:
8 - "rising-edge"
9 - "falling-edge"
10 - "both-edges".
11 Reading returns current trigger polarity.
12 Writing value before enabling conversions sets trigger polarity.
13
14What: /sys/bus/iio/devices/triggerX/trigger_polarity_available
15KernelVersion: 4.11
16Contact: fabrice.gasnier@st.com
17Description:
18 List all available trigger_polarity settings.
diff --git a/Documentation/ABI/testing/sysfs-bus-iio-distance-srf08 b/Documentation/ABI/testing/sysfs-bus-iio-distance-srf08
new file mode 100644
index 000000000000..0a1ca1487fa9
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-iio-distance-srf08
@@ -0,0 +1,22 @@
1What /sys/bus/iio/devices/iio:deviceX/sensor_sensitivity
2Date: January 2017
3KernelVersion: 4.11
4Contact: linux-iio@vger.kernel.org
5Description:
6 Show or set the gain boost of the amp, from 0-31 range.
7 default 31
8
9What /sys/bus/iio/devices/iio:deviceX/sensor_max_range
10Date: January 2017
11KernelVersion: 4.11
12Contact: linux-iio@vger.kernel.org
13Description:
14 Show or set the maximum range between the sensor and the
15 first object echoed in meters. Default value is 6.020.
16 This setting limits the time the driver is waiting for a
17 echo.
18 Showing the range of available values is represented as the
19 minimum value, the step and the maximum value, all enclosed
20 in square brackets.
21 Example:
22 [0.043 0.043 11.008]
diff --git a/Documentation/ABI/testing/sysfs-bus-iio-timer-stm32 b/Documentation/ABI/testing/sysfs-bus-iio-timer-stm32
new file mode 100644
index 000000000000..6534a60037ff
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-iio-timer-stm32
@@ -0,0 +1,29 @@
1What: /sys/bus/iio/devices/triggerX/master_mode_available
2KernelVersion: 4.11
3Contact: benjamin.gaignard@st.com
4Description:
5 Reading returns the list possible master modes which are:
6 - "reset" : The UG bit from the TIMx_EGR register is used as trigger output (TRGO).
7 - "enable" : The Counter Enable signal CNT_EN is used as trigger output.
8 - "update" : The update event is selected as trigger output.
9 For instance a master timer can then be used as a prescaler for a slave timer.
10 - "compare_pulse" : The trigger output send a positive pulse when the CC1IF flag is to be set.
11 - "OC1REF" : OC1REF signal is used as trigger output.
12 - "OC2REF" : OC2REF signal is used as trigger output.
13 - "OC3REF" : OC3REF signal is used as trigger output.
14 - "OC4REF" : OC4REF signal is used as trigger output.
15
16What: /sys/bus/iio/devices/triggerX/master_mode
17KernelVersion: 4.11
18Contact: benjamin.gaignard@st.com
19Description:
20 Reading returns the current master modes.
21 Writing set the master mode
22
23What: /sys/bus/iio/devices/triggerX/sampling_frequency
24KernelVersion: 4.11
25Contact: benjamin.gaignard@st.com
26Description:
27 Reading returns the current sampling frequency.
28 Writing an value different of 0 set and start sampling.
29 Writing 0 stop sampling.
diff --git a/Documentation/DMA-ISA-LPC.txt b/Documentation/DMA-ISA-LPC.txt
index b1a19835e907..c41331398752 100644
--- a/Documentation/DMA-ISA-LPC.txt
+++ b/Documentation/DMA-ISA-LPC.txt
@@ -42,7 +42,7 @@ requirements you pass the flag GFP_DMA to kmalloc.
42 42
43Unfortunately the memory available for ISA DMA is scarce so unless you 43Unfortunately the memory available for ISA DMA is scarce so unless you
44allocate the memory during boot-up it's a good idea to also pass 44allocate the memory during boot-up it's a good idea to also pass
45__GFP_REPEAT and __GFP_NOWARN to make the allocater try a bit harder. 45__GFP_REPEAT and __GFP_NOWARN to make the allocator try a bit harder.
46 46
47(This scarcity also means that you should allocate the buffer as 47(This scarcity also means that you should allocate the buffer as
48early as possible and not release it until the driver is unloaded.) 48early as possible and not release it until the driver is unloaded.)
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index a6eb7dcd4dd5..164c1c76971f 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -7,13 +7,13 @@
7# list of DOCBOOKS. 7# list of DOCBOOKS.
8 8
9DOCBOOKS := z8530book.xml \ 9DOCBOOKS := z8530book.xml \
10 kernel-hacking.xml kernel-locking.xml deviceiobook.xml \ 10 kernel-hacking.xml kernel-locking.xml \
11 writing_usb_driver.xml networking.xml \ 11 writing_usb_driver.xml networking.xml \
12 kernel-api.xml filesystems.xml lsm.xml kgdb.xml \ 12 kernel-api.xml filesystems.xml lsm.xml kgdb.xml \
13 gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \ 13 gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \
14 genericirq.xml s390-drivers.xml uio-howto.xml scsi.xml \ 14 genericirq.xml s390-drivers.xml scsi.xml \
15 sh.xml regulator.xml w1.xml \ 15 sh.xml w1.xml \
16 writing_musb_glue_layer.xml iio.xml 16 writing_musb_glue_layer.xml
17 17
18ifeq ($(DOCBOOKS),) 18ifeq ($(DOCBOOKS),)
19 19
@@ -71,6 +71,7 @@ installmandocs: mandocs
71# no-op for the DocBook toolchain 71# no-op for the DocBook toolchain
72epubdocs: 72epubdocs:
73latexdocs: 73latexdocs:
74linkcheckdocs:
74 75
75### 76###
76#External programs used 77#External programs used
@@ -272,6 +273,6 @@ cleandocs:
272 $(Q)rm -rf $(call objectify, $(clean-dirs)) 273 $(Q)rm -rf $(call objectify, $(clean-dirs))
273 274
274# Declare the contents of the .PHONY variable as phony. We keep that 275# Declare the contents of the .PHONY variable as phony. We keep that
275# information in a variable se we can use it in if_changed and friends. 276# information in a variable so we can use it in if_changed and friends.
276 277
277.PHONY: $(PHONY) 278.PHONY: $(PHONY)
diff --git a/Documentation/DocBook/deviceiobook.tmpl b/Documentation/DocBook/deviceiobook.tmpl
deleted file mode 100644
index 54199a0dcf9a..000000000000
--- a/Documentation/DocBook/deviceiobook.tmpl
+++ /dev/null
@@ -1,323 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
4
5<book id="DoingIO">
6 <bookinfo>
7 <title>Bus-Independent Device Accesses</title>
8
9 <authorgroup>
10 <author>
11 <firstname>Matthew</firstname>
12 <surname>Wilcox</surname>
13 <affiliation>
14 <address>
15 <email>matthew@wil.cx</email>
16 </address>
17 </affiliation>
18 </author>
19 </authorgroup>
20
21 <authorgroup>
22 <author>
23 <firstname>Alan</firstname>
24 <surname>Cox</surname>
25 <affiliation>
26 <address>
27 <email>alan@lxorguk.ukuu.org.uk</email>
28 </address>
29 </affiliation>
30 </author>
31 </authorgroup>
32
33 <copyright>
34 <year>2001</year>
35 <holder>Matthew Wilcox</holder>
36 </copyright>
37
38 <legalnotice>
39 <para>
40 This documentation is free software; you can redistribute
41 it and/or modify it under the terms of the GNU General Public
42 License as published by the Free Software Foundation; either
43 version 2 of the License, or (at your option) any later
44 version.
45 </para>
46
47 <para>
48 This program is distributed in the hope that it will be
49 useful, but WITHOUT ANY WARRANTY; without even the implied
50 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
51 See the GNU General Public License for more details.
52 </para>
53
54 <para>
55 You should have received a copy of the GNU General Public
56 License along with this program; if not, write to the Free
57 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
58 MA 02111-1307 USA
59 </para>
60
61 <para>
62 For more details see the file COPYING in the source
63 distribution of Linux.
64 </para>
65 </legalnotice>
66 </bookinfo>
67
68<toc></toc>
69
70 <chapter id="intro">
71 <title>Introduction</title>
72 <para>
73 Linux provides an API which abstracts performing IO across all busses
74 and devices, allowing device drivers to be written independently of
75 bus type.
76 </para>
77 </chapter>
78
79 <chapter id="bugs">
80 <title>Known Bugs And Assumptions</title>
81 <para>
82 None.
83 </para>
84 </chapter>
85
86 <chapter id="mmio">
87 <title>Memory Mapped IO</title>
88 <sect1 id="getting_access_to_the_device">
89 <title>Getting Access to the Device</title>
90 <para>
91 The most widely supported form of IO is memory mapped IO.
92 That is, a part of the CPU's address space is interpreted
93 not as accesses to memory, but as accesses to a device. Some
94 architectures define devices to be at a fixed address, but most
95 have some method of discovering devices. The PCI bus walk is a
96 good example of such a scheme. This document does not cover how
97 to receive such an address, but assumes you are starting with one.
98 Physical addresses are of type unsigned long.
99 </para>
100
101 <para>
102 This address should not be used directly. Instead, to get an
103 address suitable for passing to the accessor functions described
104 below, you should call <function>ioremap</function>.
105 An address suitable for accessing the device will be returned to you.
106 </para>
107
108 <para>
109 After you've finished using the device (say, in your module's
110 exit routine), call <function>iounmap</function> in order to return
111 the address space to the kernel. Most architectures allocate new
112 address space each time you call <function>ioremap</function>, and
113 they can run out unless you call <function>iounmap</function>.
114 </para>
115 </sect1>
116
117 <sect1 id="accessing_the_device">
118 <title>Accessing the device</title>
119 <para>
120 The part of the interface most used by drivers is reading and
121 writing memory-mapped registers on the device. Linux provides
122 interfaces to read and write 8-bit, 16-bit, 32-bit and 64-bit
123 quantities. Due to a historical accident, these are named byte,
124 word, long and quad accesses. Both read and write accesses are
125 supported; there is no prefetch support at this time.
126 </para>
127
128 <para>
129 The functions are named <function>readb</function>,
130 <function>readw</function>, <function>readl</function>,
131 <function>readq</function>, <function>readb_relaxed</function>,
132 <function>readw_relaxed</function>, <function>readl_relaxed</function>,
133 <function>readq_relaxed</function>, <function>writeb</function>,
134 <function>writew</function>, <function>writel</function> and
135 <function>writeq</function>.
136 </para>
137
138 <para>
139 Some devices (such as framebuffers) would like to use larger
140 transfers than 8 bytes at a time. For these devices, the
141 <function>memcpy_toio</function>, <function>memcpy_fromio</function>
142 and <function>memset_io</function> functions are provided.
143 Do not use memset or memcpy on IO addresses; they
144 are not guaranteed to copy data in order.
145 </para>
146
147 <para>
148 The read and write functions are defined to be ordered. That is the
149 compiler is not permitted to reorder the I/O sequence. When the
150 ordering can be compiler optimised, you can use <function>
151 __readb</function> and friends to indicate the relaxed ordering. Use
152 this with care.
153 </para>
154
155 <para>
156 While the basic functions are defined to be synchronous with respect
157 to each other and ordered with respect to each other the busses the
158 devices sit on may themselves have asynchronicity. In particular many
159 authors are burned by the fact that PCI bus writes are posted
160 asynchronously. A driver author must issue a read from the same
161 device to ensure that writes have occurred in the specific cases the
162 author cares. This kind of property cannot be hidden from driver
163 writers in the API. In some cases, the read used to flush the device
164 may be expected to fail (if the card is resetting, for example). In
165 that case, the read should be done from config space, which is
166 guaranteed to soft-fail if the card doesn't respond.
167 </para>
168
169 <para>
170 The following is an example of flushing a write to a device when
171 the driver would like to ensure the write's effects are visible prior
172 to continuing execution.
173 </para>
174
175<programlisting>
176static inline void
177qla1280_disable_intrs(struct scsi_qla_host *ha)
178{
179 struct device_reg *reg;
180
181 reg = ha->iobase;
182 /* disable risc and host interrupts */
183 WRT_REG_WORD(&amp;reg->ictrl, 0);
184 /*
185 * The following read will ensure that the above write
186 * has been received by the device before we return from this
187 * function.
188 */
189 RD_REG_WORD(&amp;reg->ictrl);
190 ha->flags.ints_enabled = 0;
191}
192</programlisting>
193
194 <para>
195 In addition to write posting, on some large multiprocessing systems
196 (e.g. SGI Challenge, Origin and Altix machines) posted writes won't
197 be strongly ordered coming from different CPUs. Thus it's important
198 to properly protect parts of your driver that do memory-mapped writes
199 with locks and use the <function>mmiowb</function> to make sure they
200 arrive in the order intended. Issuing a regular <function>readX
201 </function> will also ensure write ordering, but should only be used
202 when the driver has to be sure that the write has actually arrived
203 at the device (not that it's simply ordered with respect to other
204 writes), since a full <function>readX</function> is a relatively
205 expensive operation.
206 </para>
207
208 <para>
209 Generally, one should use <function>mmiowb</function> prior to
210 releasing a spinlock that protects regions using <function>writeb
211 </function> or similar functions that aren't surrounded by <function>
212 readb</function> calls, which will ensure ordering and flushing. The
213 following pseudocode illustrates what might occur if write ordering
214 isn't guaranteed via <function>mmiowb</function> or one of the
215 <function>readX</function> functions.
216 </para>
217
218<programlisting>
219CPU A: spin_lock_irqsave(&amp;dev_lock, flags)
220CPU A: ...
221CPU A: writel(newval, ring_ptr);
222CPU A: spin_unlock_irqrestore(&amp;dev_lock, flags)
223 ...
224CPU B: spin_lock_irqsave(&amp;dev_lock, flags)
225CPU B: writel(newval2, ring_ptr);
226CPU B: ...
227CPU B: spin_unlock_irqrestore(&amp;dev_lock, flags)
228</programlisting>
229
230 <para>
231 In the case above, newval2 could be written to ring_ptr before
232 newval. Fixing it is easy though:
233 </para>
234
235<programlisting>
236CPU A: spin_lock_irqsave(&amp;dev_lock, flags)
237CPU A: ...
238CPU A: writel(newval, ring_ptr);
239CPU A: mmiowb(); /* ensure no other writes beat us to the device */
240CPU A: spin_unlock_irqrestore(&amp;dev_lock, flags)
241 ...
242CPU B: spin_lock_irqsave(&amp;dev_lock, flags)
243CPU B: writel(newval2, ring_ptr);
244CPU B: ...
245CPU B: mmiowb();
246CPU B: spin_unlock_irqrestore(&amp;dev_lock, flags)
247</programlisting>
248
249 <para>
250 See tg3.c for a real world example of how to use <function>mmiowb
251 </function>
252 </para>
253
254 <para>
255 PCI ordering rules also guarantee that PIO read responses arrive
256 after any outstanding DMA writes from that bus, since for some devices
257 the result of a <function>readb</function> call may signal to the
258 driver that a DMA transaction is complete. In many cases, however,
259 the driver may want to indicate that the next
260 <function>readb</function> call has no relation to any previous DMA
261 writes performed by the device. The driver can use
262 <function>readb_relaxed</function> for these cases, although only
263 some platforms will honor the relaxed semantics. Using the relaxed
264 read functions will provide significant performance benefits on
265 platforms that support it. The qla2xxx driver provides examples
266 of how to use <function>readX_relaxed</function>. In many cases,
267 a majority of the driver's <function>readX</function> calls can
268 safely be converted to <function>readX_relaxed</function> calls, since
269 only a few will indicate or depend on DMA completion.
270 </para>
271 </sect1>
272
273 </chapter>
274
275 <chapter id="port_space_accesses">
276 <title>Port Space Accesses</title>
277 <sect1 id="port_space_explained">
278 <title>Port Space Explained</title>
279
280 <para>
281 Another form of IO commonly supported is Port Space. This is a
282 range of addresses separate to the normal memory address space.
283 Access to these addresses is generally not as fast as accesses
284 to the memory mapped addresses, and it also has a potentially
285 smaller address space.
286 </para>
287
288 <para>
289 Unlike memory mapped IO, no preparation is required
290 to access port space.
291 </para>
292
293 </sect1>
294 <sect1 id="accessing_port_space">
295 <title>Accessing Port Space</title>
296 <para>
297 Accesses to this space are provided through a set of functions
298 which allow 8-bit, 16-bit and 32-bit accesses; also
299 known as byte, word and long. These functions are
300 <function>inb</function>, <function>inw</function>,
301 <function>inl</function>, <function>outb</function>,
302 <function>outw</function> and <function>outl</function>.
303 </para>
304
305 <para>
306 Some variants are provided for these functions. Some devices
307 require that accesses to their ports are slowed down. This
308 functionality is provided by appending a <function>_p</function>
309 to the end of the function. There are also equivalents to memcpy.
310 The <function>ins</function> and <function>outs</function>
311 functions copy bytes, words or longs to the given port.
312 </para>
313 </sect1>
314
315 </chapter>
316
317 <chapter id="pubfunctions">
318 <title>Public Functions Provided</title>
319!Iarch/x86/include/asm/io.h
320!Elib/pci_iomap.c
321 </chapter>
322
323</book>
diff --git a/Documentation/DocBook/iio.tmpl b/Documentation/DocBook/iio.tmpl
deleted file mode 100644
index e2ab6a1f223e..000000000000
--- a/Documentation/DocBook/iio.tmpl
+++ /dev/null
@@ -1,697 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
4
5<book id="iioid">
6 <bookinfo>
7 <title>Industrial I/O driver developer's guide </title>
8
9 <authorgroup>
10 <author>
11 <firstname>Daniel</firstname>
12 <surname>Baluta</surname>
13 <affiliation>
14 <address>
15 <email>daniel.baluta@intel.com</email>
16 </address>
17 </affiliation>
18 </author>
19 </authorgroup>
20
21 <copyright>
22 <year>2015</year>
23 <holder>Intel Corporation</holder>
24 </copyright>
25
26 <legalnotice>
27 <para>
28 This documentation is free software; you can redistribute
29 it and/or modify it under the terms of the GNU General Public
30 License version 2.
31 </para>
32 </legalnotice>
33 </bookinfo>
34
35 <toc></toc>
36
37 <chapter id="intro">
38 <title>Introduction</title>
39 <para>
40 The main purpose of the Industrial I/O subsystem (IIO) is to provide
41 support for devices that in some sense perform either analog-to-digital
42 conversion (ADC) or digital-to-analog conversion (DAC) or both. The aim
43 is to fill the gap between the somewhat similar hwmon and input
44 subsystems.
45 Hwmon is directed at low sample rate sensors used to monitor and
46 control the system itself, like fan speed control or temperature
47 measurement. Input is, as its name suggests, focused on human interaction
48 input devices (keyboard, mouse, touchscreen). In some cases there is
49 considerable overlap between these and IIO.
50 </para>
51 <para>
52 Devices that fall into this category include:
53 <itemizedlist>
54 <listitem>
55 analog to digital converters (ADCs)
56 </listitem>
57 <listitem>
58 accelerometers
59 </listitem>
60 <listitem>
61 capacitance to digital converters (CDCs)
62 </listitem>
63 <listitem>
64 digital to analog converters (DACs)
65 </listitem>
66 <listitem>
67 gyroscopes
68 </listitem>
69 <listitem>
70 inertial measurement units (IMUs)
71 </listitem>
72 <listitem>
73 color and light sensors
74 </listitem>
75 <listitem>
76 magnetometers
77 </listitem>
78 <listitem>
79 pressure sensors
80 </listitem>
81 <listitem>
82 proximity sensors
83 </listitem>
84 <listitem>
85 temperature sensors
86 </listitem>
87 </itemizedlist>
88 Usually these sensors are connected via SPI or I2C. A common use case of the
89 sensors devices is to have combined functionality (e.g. light plus proximity
90 sensor).
91 </para>
92 </chapter>
93 <chapter id='iiosubsys'>
94 <title>Industrial I/O core</title>
95 <para>
96 The Industrial I/O core offers:
97 <itemizedlist>
98 <listitem>
99 a unified framework for writing drivers for many different types of
100 embedded sensors.
101 </listitem>
102 <listitem>
103 a standard interface to user space applications manipulating sensors.
104 </listitem>
105 </itemizedlist>
106 The implementation can be found under <filename>
107 drivers/iio/industrialio-*</filename>
108 </para>
109 <sect1 id="iiodevice">
110 <title> Industrial I/O devices </title>
111
112!Finclude/linux/iio/iio.h iio_dev
113!Fdrivers/iio/industrialio-core.c iio_device_alloc
114!Fdrivers/iio/industrialio-core.c iio_device_free
115!Fdrivers/iio/industrialio-core.c iio_device_register
116!Fdrivers/iio/industrialio-core.c iio_device_unregister
117
118 <para>
119 An IIO device usually corresponds to a single hardware sensor and it
120 provides all the information needed by a driver handling a device.
121 Let's first have a look at the functionality embedded in an IIO
122 device then we will show how a device driver makes use of an IIO
123 device.
124 </para>
125 <para>
126 There are two ways for a user space application to interact
127 with an IIO driver.
128 <itemizedlist>
129 <listitem>
130 <filename>/sys/bus/iio/iio:deviceX/</filename>, this
131 represents a hardware sensor and groups together the data
132 channels of the same chip.
133 </listitem>
134 <listitem>
135 <filename>/dev/iio:deviceX</filename>, character device node
136 interface used for buffered data transfer and for events information
137 retrieval.
138 </listitem>
139 </itemizedlist>
140 </para>
141 A typical IIO driver will register itself as an I2C or SPI driver and will
142 create two routines, <function> probe </function> and <function> remove
143 </function>. At <function>probe</function>:
144 <itemizedlist>
145 <listitem>call <function>iio_device_alloc</function>, which allocates memory
146 for an IIO device.
147 </listitem>
148 <listitem> initialize IIO device fields with driver specific information
149 (e.g. device name, device channels).
150 </listitem>
151 <listitem>call <function> iio_device_register</function>, this registers the
152 device with the IIO core. After this call the device is ready to accept
153 requests from user space applications.
154 </listitem>
155 </itemizedlist>
156 At <function>remove</function>, we free the resources allocated in
157 <function>probe</function> in reverse order:
158 <itemizedlist>
159 <listitem><function>iio_device_unregister</function>, unregister the device
160 from the IIO core.
161 </listitem>
162 <listitem><function>iio_device_free</function>, free the memory allocated
163 for the IIO device.
164 </listitem>
165 </itemizedlist>
166
167 <sect2 id="iioattr"> <title> IIO device sysfs interface </title>
168 <para>
169 Attributes are sysfs files used to expose chip info and also allowing
170 applications to set various configuration parameters. For device
171 with index X, attributes can be found under
172 <filename>/sys/bus/iio/iio:deviceX/ </filename> directory.
173 Common attributes are:
174 <itemizedlist>
175 <listitem><filename>name</filename>, description of the physical
176 chip.
177 </listitem>
178 <listitem><filename>dev</filename>, shows the major:minor pair
179 associated with <filename>/dev/iio:deviceX</filename> node.
180 </listitem>
181 <listitem><filename>sampling_frequency_available</filename>,
182 available discrete set of sampling frequency values for
183 device.
184 </listitem>
185 </itemizedlist>
186 Available standard attributes for IIO devices are described in the
187 <filename>Documentation/ABI/testing/sysfs-bus-iio </filename> file
188 in the Linux kernel sources.
189 </para>
190 </sect2>
191 <sect2 id="iiochannel"> <title> IIO device channels </title>
192!Finclude/linux/iio/iio.h iio_chan_spec structure.
193 <para>
194 An IIO device channel is a representation of a data channel. An
195 IIO device can have one or multiple channels. For example:
196 <itemizedlist>
197 <listitem>
198 a thermometer sensor has one channel representing the
199 temperature measurement.
200 </listitem>
201 <listitem>
202 a light sensor with two channels indicating the measurements in
203 the visible and infrared spectrum.
204 </listitem>
205 <listitem>
206 an accelerometer can have up to 3 channels representing
207 acceleration on X, Y and Z axes.
208 </listitem>
209 </itemizedlist>
210 An IIO channel is described by the <type> struct iio_chan_spec
211 </type>. A thermometer driver for the temperature sensor in the
212 example above would have to describe its channel as follows:
213 <programlisting>
214 static const struct iio_chan_spec temp_channel[] = {
215 {
216 .type = IIO_TEMP,
217 .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
218 },
219 };
220
221 </programlisting>
222 Channel sysfs attributes exposed to userspace are specified in
223 the form of <emphasis>bitmasks</emphasis>. Depending on their
224 shared info, attributes can be set in one of the following masks:
225 <itemizedlist>
226 <listitem><emphasis>info_mask_separate</emphasis>, attributes will
227 be specific to this channel</listitem>
228 <listitem><emphasis>info_mask_shared_by_type</emphasis>,
229 attributes are shared by all channels of the same type</listitem>
230 <listitem><emphasis>info_mask_shared_by_dir</emphasis>, attributes
231 are shared by all channels of the same direction </listitem>
232 <listitem><emphasis>info_mask_shared_by_all</emphasis>,
233 attributes are shared by all channels</listitem>
234 </itemizedlist>
235 When there are multiple data channels per channel type we have two
236 ways to distinguish between them:
237 <itemizedlist>
238 <listitem> set <emphasis> .modified</emphasis> field of <type>
239 iio_chan_spec</type> to 1. Modifiers are specified using
240 <emphasis>.channel2</emphasis> field of the same
241 <type>iio_chan_spec</type> structure and are used to indicate a
242 physically unique characteristic of the channel such as its direction
243 or spectral response. For example, a light sensor can have two channels,
244 one for infrared light and one for both infrared and visible light.
245 </listitem>
246 <listitem> set <emphasis>.indexed </emphasis> field of
247 <type>iio_chan_spec</type> to 1. In this case the channel is
248 simply another instance with an index specified by the
249 <emphasis>.channel</emphasis> field.
250 </listitem>
251 </itemizedlist>
252 Here is how we can make use of the channel's modifiers:
253 <programlisting>
254 static const struct iio_chan_spec light_channels[] = {
255 {
256 .type = IIO_INTENSITY,
257 .modified = 1,
258 .channel2 = IIO_MOD_LIGHT_IR,
259 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
260 .info_mask_shared = BIT(IIO_CHAN_INFO_SAMP_FREQ),
261 },
262 {
263 .type = IIO_INTENSITY,
264 .modified = 1,
265 .channel2 = IIO_MOD_LIGHT_BOTH,
266 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
267 .info_mask_shared = BIT(IIO_CHAN_INFO_SAMP_FREQ),
268 },
269 {
270 .type = IIO_LIGHT,
271 .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
272 .info_mask_shared = BIT(IIO_CHAN_INFO_SAMP_FREQ),
273 },
274
275 }
276 </programlisting>
277 This channel's definition will generate two separate sysfs files
278 for raw data retrieval:
279 <itemizedlist>
280 <listitem>
281 <filename>/sys/bus/iio/iio:deviceX/in_intensity_ir_raw</filename>
282 </listitem>
283 <listitem>
284 <filename>/sys/bus/iio/iio:deviceX/in_intensity_both_raw</filename>
285 </listitem>
286 </itemizedlist>
287 one file for processed data:
288 <itemizedlist>
289 <listitem>
290 <filename>/sys/bus/iio/iio:deviceX/in_illuminance_input
291 </filename>
292 </listitem>
293 </itemizedlist>
294 and one shared sysfs file for sampling frequency:
295 <itemizedlist>
296 <listitem>
297 <filename>/sys/bus/iio/iio:deviceX/sampling_frequency.
298 </filename>
299 </listitem>
300 </itemizedlist>
301 </para>
302 <para>
303 Here is how we can make use of the channel's indexing:
304 <programlisting>
305 static const struct iio_chan_spec light_channels[] = {
306 {
307 .type = IIO_VOLTAGE,
308 .indexed = 1,
309 .channel = 0,
310 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
311 },
312 {
313 .type = IIO_VOLTAGE,
314 .indexed = 1,
315 .channel = 1,
316 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
317 },
318 }
319 </programlisting>
320 This will generate two separate attributes files for raw data
321 retrieval:
322 <itemizedlist>
323 <listitem>
324 <filename>/sys/bus/iio/devices/iio:deviceX/in_voltage0_raw</filename>,
325 representing voltage measurement for channel 0.
326 </listitem>
327 <listitem>
328 <filename>/sys/bus/iio/devices/iio:deviceX/in_voltage1_raw</filename>,
329 representing voltage measurement for channel 1.
330 </listitem>
331 </itemizedlist>
332 </para>
333 </sect2>
334 </sect1>
335
336 <sect1 id="iiobuffer"> <title> Industrial I/O buffers </title>
337!Finclude/linux/iio/buffer.h iio_buffer
338!Edrivers/iio/industrialio-buffer.c
339
340 <para>
341 The Industrial I/O core offers a way for continuous data capture
342 based on a trigger source. Multiple data channels can be read at once
343 from <filename>/dev/iio:deviceX</filename> character device node,
344 thus reducing the CPU load.
345 </para>
346
347 <sect2 id="iiobuffersysfs">
348 <title>IIO buffer sysfs interface </title>
349 <para>
350 An IIO buffer has an associated attributes directory under <filename>
351 /sys/bus/iio/iio:deviceX/buffer/</filename>. Here are the existing
352 attributes:
353 <itemizedlist>
354 <listitem>
355 <emphasis>length</emphasis>, the total number of data samples
356 (capacity) that can be stored by the buffer.
357 </listitem>
358 <listitem>
359 <emphasis>enable</emphasis>, activate buffer capture.
360 </listitem>
361 </itemizedlist>
362
363 </para>
364 </sect2>
365 <sect2 id="iiobuffersetup"> <title> IIO buffer setup </title>
366 <para>The meta information associated with a channel reading
367 placed in a buffer is called a <emphasis> scan element </emphasis>.
368 The important bits configuring scan elements are exposed to
369 userspace applications via the <filename>
370 /sys/bus/iio/iio:deviceX/scan_elements/</filename> directory. This
371 file contains attributes of the following form:
372 <itemizedlist>
373 <listitem><emphasis>enable</emphasis>, used for enabling a channel.
374 If and only if its attribute is non zero, then a triggered capture
375 will contain data samples for this channel.
376 </listitem>
377 <listitem><emphasis>type</emphasis>, description of the scan element
378 data storage within the buffer and hence the form in which it is
379 read from user space. Format is <emphasis>
380 [be|le]:[s|u]bits/storagebitsXrepeat[>>shift] </emphasis>.
381 <itemizedlist>
382 <listitem> <emphasis>be</emphasis> or <emphasis>le</emphasis>, specifies
383 big or little endian.
384 </listitem>
385 <listitem>
386 <emphasis>s </emphasis>or <emphasis>u</emphasis>, specifies if
387 signed (2's complement) or unsigned.
388 </listitem>
389 <listitem><emphasis>bits</emphasis>, is the number of valid data
390 bits.
391 </listitem>
392 <listitem><emphasis>storagebits</emphasis>, is the number of bits
393 (after padding) that it occupies in the buffer.
394 </listitem>
395 <listitem>
396 <emphasis>shift</emphasis>, if specified, is the shift that needs
397 to be applied prior to masking out unused bits.
398 </listitem>
399 <listitem>
400 <emphasis>repeat</emphasis>, specifies the number of bits/storagebits
401 repetitions. When the repeat element is 0 or 1, then the repeat
402 value is omitted.
403 </listitem>
404 </itemizedlist>
405 </listitem>
406 </itemizedlist>
407 For example, a driver for a 3-axis accelerometer with 12 bit
408 resolution where data is stored in two 8-bits registers as
409 follows:
410 <programlisting>
411 7 6 5 4 3 2 1 0
412 +---+---+---+---+---+---+---+---+
413 |D3 |D2 |D1 |D0 | X | X | X | X | (LOW byte, address 0x06)
414 +---+---+---+---+---+---+---+---+
415
416 7 6 5 4 3 2 1 0
417 +---+---+---+---+---+---+---+---+
418 |D11|D10|D9 |D8 |D7 |D6 |D5 |D4 | (HIGH byte, address 0x07)
419 +---+---+---+---+---+---+---+---+
420 </programlisting>
421
422 will have the following scan element type for each axis:
423 <programlisting>
424 $ cat /sys/bus/iio/devices/iio:device0/scan_elements/in_accel_y_type
425 le:s12/16>>4
426 </programlisting>
427 A user space application will interpret data samples read from the
428 buffer as two byte little endian signed data, that needs a 4 bits
429 right shift before masking out the 12 valid bits of data.
430 </para>
431 <para>
432 For implementing buffer support a driver should initialize the following
433 fields in <type>iio_chan_spec</type> definition:
434 <programlisting>
435 struct iio_chan_spec {
436 /* other members */
437 int scan_index
438 struct {
439 char sign;
440 u8 realbits;
441 u8 storagebits;
442 u8 shift;
443 u8 repeat;
444 enum iio_endian endianness;
445 } scan_type;
446 };
447 </programlisting>
448 The driver implementing the accelerometer described above will
449 have the following channel definition:
450 <programlisting>
451 struct struct iio_chan_spec accel_channels[] = {
452 {
453 .type = IIO_ACCEL,
454 .modified = 1,
455 .channel2 = IIO_MOD_X,
456 /* other stuff here */
457 .scan_index = 0,
458 .scan_type = {
459 .sign = 's',
460 .realbits = 12,
461 .storagebits = 16,
462 .shift = 4,
463 .endianness = IIO_LE,
464 },
465 }
466 /* similar for Y (with channel2 = IIO_MOD_Y, scan_index = 1)
467 * and Z (with channel2 = IIO_MOD_Z, scan_index = 2) axis
468 */
469 }
470 </programlisting>
471 </para>
472 <para>
473 Here <emphasis> scan_index </emphasis> defines the order in which
474 the enabled channels are placed inside the buffer. Channels with a lower
475 scan_index will be placed before channels with a higher index. Each
476 channel needs to have a unique scan_index.
477 </para>
478 <para>
479 Setting scan_index to -1 can be used to indicate that the specific
480 channel does not support buffered capture. In this case no entries will
481 be created for the channel in the scan_elements directory.
482 </para>
483 </sect2>
484 </sect1>
485
486 <sect1 id="iiotrigger"> <title> Industrial I/O triggers </title>
487!Finclude/linux/iio/trigger.h iio_trigger
488!Edrivers/iio/industrialio-trigger.c
489 <para>
490 In many situations it is useful for a driver to be able to
491 capture data based on some external event (trigger) as opposed
492 to periodically polling for data. An IIO trigger can be provided
493 by a device driver that also has an IIO device based on hardware
494 generated events (e.g. data ready or threshold exceeded) or
495 provided by a separate driver from an independent interrupt
496 source (e.g. GPIO line connected to some external system, timer
497 interrupt or user space writing a specific file in sysfs). A
498 trigger may initiate data capture for a number of sensors and
499 also it may be completely unrelated to the sensor itself.
500 </para>
501
502 <sect2 id="iiotrigsysfs"> <title> IIO trigger sysfs interface </title>
503 There are two locations in sysfs related to triggers:
504 <itemizedlist>
505 <listitem><filename>/sys/bus/iio/devices/triggerY</filename>,
506 this file is created once an IIO trigger is registered with
507 the IIO core and corresponds to trigger with index Y. Because
508 triggers can be very different depending on type there are few
509 standard attributes that we can describe here:
510 <itemizedlist>
511 <listitem>
512 <emphasis>name</emphasis>, trigger name that can be later
513 used for association with a device.
514 </listitem>
515 <listitem>
516 <emphasis>sampling_frequency</emphasis>, some timer based
517 triggers use this attribute to specify the frequency for
518 trigger calls.
519 </listitem>
520 </itemizedlist>
521 </listitem>
522 <listitem>
523 <filename>/sys/bus/iio/devices/iio:deviceX/trigger/</filename>, this
524 directory is created once the device supports a triggered
525 buffer. We can associate a trigger with our device by writing
526 the trigger's name in the <filename>current_trigger</filename> file.
527 </listitem>
528 </itemizedlist>
529 </sect2>
530
531 <sect2 id="iiotrigattr"> <title> IIO trigger setup</title>
532
533 <para>
534 Let's see a simple example of how to setup a trigger to be used
535 by a driver.
536
537 <programlisting>
538 struct iio_trigger_ops trigger_ops = {
539 .set_trigger_state = sample_trigger_state,
540 .validate_device = sample_validate_device,
541 }
542
543 struct iio_trigger *trig;
544
545 /* first, allocate memory for our trigger */
546 trig = iio_trigger_alloc(dev, "trig-%s-%d", name, idx);
547
548 /* setup trigger operations field */
549 trig->ops = &amp;trigger_ops;
550
551 /* now register the trigger with the IIO core */
552 iio_trigger_register(trig);
553 </programlisting>
554 </para>
555 </sect2>
556
557 <sect2 id="iiotrigsetup"> <title> IIO trigger ops</title>
558!Finclude/linux/iio/trigger.h iio_trigger_ops
559 <para>
560 Notice that a trigger has a set of operations attached:
561 <itemizedlist>
562 <listitem>
563 <function>set_trigger_state</function>, switch the trigger on/off
564 on demand.
565 </listitem>
566 <listitem>
567 <function>validate_device</function>, function to validate the
568 device when the current trigger gets changed.
569 </listitem>
570 </itemizedlist>
571 </para>
572 </sect2>
573 </sect1>
574 <sect1 id="iiotriggered_buffer">
575 <title> Industrial I/O triggered buffers </title>
576 <para>
577 Now that we know what buffers and triggers are let's see how they
578 work together.
579 </para>
580 <sect2 id="iiotrigbufsetup"> <title> IIO triggered buffer setup</title>
581!Edrivers/iio/buffer/industrialio-triggered-buffer.c
582!Finclude/linux/iio/iio.h iio_buffer_setup_ops
583
584
585 <para>
586 A typical triggered buffer setup looks like this:
587 <programlisting>
588 const struct iio_buffer_setup_ops sensor_buffer_setup_ops = {
589 .preenable = sensor_buffer_preenable,
590 .postenable = sensor_buffer_postenable,
591 .postdisable = sensor_buffer_postdisable,
592 .predisable = sensor_buffer_predisable,
593 };
594
595 irqreturn_t sensor_iio_pollfunc(int irq, void *p)
596 {
597 pf->timestamp = iio_get_time_ns((struct indio_dev *)p);
598 return IRQ_WAKE_THREAD;
599 }
600
601 irqreturn_t sensor_trigger_handler(int irq, void *p)
602 {
603 u16 buf[8];
604 int i = 0;
605
606 /* read data for each active channel */
607 for_each_set_bit(bit, active_scan_mask, masklength)
608 buf[i++] = sensor_get_data(bit)
609
610 iio_push_to_buffers_with_timestamp(indio_dev, buf, timestamp);
611
612 iio_trigger_notify_done(trigger);
613 return IRQ_HANDLED;
614 }
615
616 /* setup triggered buffer, usually in probe function */
617 iio_triggered_buffer_setup(indio_dev, sensor_iio_polfunc,
618 sensor_trigger_handler,
619 sensor_buffer_setup_ops);
620 </programlisting>
621 </para>
622 The important things to notice here are:
623 <itemizedlist>
624 <listitem><function> iio_buffer_setup_ops</function>, the buffer setup
625 functions to be called at predefined points in the buffer configuration
626 sequence (e.g. before enable, after disable). If not specified, the
627 IIO core uses the default <type>iio_triggered_buffer_setup_ops</type>.
628 </listitem>
629 <listitem><function>sensor_iio_pollfunc</function>, the function that
630 will be used as top half of poll function. It should do as little
631 processing as possible, because it runs in interrupt context. The most
632 common operation is recording of the current timestamp and for this reason
633 one can use the IIO core defined <function>iio_pollfunc_store_time
634 </function> function.
635 </listitem>
636 <listitem><function>sensor_trigger_handler</function>, the function that
637 will be used as bottom half of the poll function. This runs in the
638 context of a kernel thread and all the processing takes place here.
639 It usually reads data from the device and stores it in the internal
640 buffer together with the timestamp recorded in the top half.
641 </listitem>
642 </itemizedlist>
643 </sect2>
644 </sect1>
645 </chapter>
646 <chapter id='iioresources'>
647 <title> Resources </title>
648 IIO core may change during time so the best documentation to read is the
649 source code. There are several locations where you should look:
650 <itemizedlist>
651 <listitem>
652 <filename>drivers/iio/</filename>, contains the IIO core plus
653 and directories for each sensor type (e.g. accel, magnetometer,
654 etc.)
655 </listitem>
656 <listitem>
657 <filename>include/linux/iio/</filename>, contains the header
658 files, nice to read for the internal kernel interfaces.
659 </listitem>
660 <listitem>
661 <filename>include/uapi/linux/iio/</filename>, contains files to be
662 used by user space applications.
663 </listitem>
664 <listitem>
665 <filename>tools/iio/</filename>, contains tools for rapidly
666 testing buffers, events and device creation.
667 </listitem>
668 <listitem>
669 <filename>drivers/staging/iio/</filename>, contains code for some
670 drivers or experimental features that are not yet mature enough
671 to be moved out.
672 </listitem>
673 </itemizedlist>
674 <para>
675 Besides the code, there are some good online documentation sources:
676 <itemizedlist>
677 <listitem>
678 <ulink url="http://marc.info/?l=linux-iio"> Industrial I/O mailing
679 list </ulink>
680 </listitem>
681 <listitem>
682 <ulink url="http://wiki.analog.com/software/linux/docs/iio/iio">
683 Analog Device IIO wiki page </ulink>
684 </listitem>
685 <listitem>
686 <ulink url="https://fosdem.org/2015/schedule/event/iiosdr/">
687 Using the Linux IIO framework for SDR, Lars-Peter Clausen's
688 presentation at FOSDEM </ulink>
689 </listitem>
690 </itemizedlist>
691 </para>
692 </chapter>
693</book>
694
695<!--
696vim: softtabstop=2:shiftwidth=2:expandtab:textwidth=72
697-->
diff --git a/Documentation/DocBook/kgdb.tmpl b/Documentation/DocBook/kgdb.tmpl
index f3abca7ec53d..856ac20bf367 100644
--- a/Documentation/DocBook/kgdb.tmpl
+++ b/Documentation/DocBook/kgdb.tmpl
@@ -115,12 +115,12 @@
115 </para> 115 </para>
116 <para> 116 <para>
117 If the architecture that you are using supports the kernel option 117 If the architecture that you are using supports the kernel option
118 CONFIG_DEBUG_RODATA, you should consider turning it off. This 118 CONFIG_STRICT_KERNEL_RWX, you should consider turning it off. This
119 option will prevent the use of software breakpoints because it 119 option will prevent the use of software breakpoints because it
120 marks certain regions of the kernel's memory space as read-only. 120 marks certain regions of the kernel's memory space as read-only.
121 If kgdb supports it for the architecture you are using, you can 121 If kgdb supports it for the architecture you are using, you can
122 use hardware breakpoints if you desire to run with the 122 use hardware breakpoints if you desire to run with the
123 CONFIG_DEBUG_RODATA option turned on, else you need to turn off 123 CONFIG_STRICT_KERNEL_RWX option turned on, else you need to turn off
124 this option. 124 this option.
125 </para> 125 </para>
126 <para> 126 <para>
@@ -135,7 +135,7 @@
135 <para>Here is an example set of .config symbols to enable or 135 <para>Here is an example set of .config symbols to enable or
136 disable for kgdb: 136 disable for kgdb:
137 <itemizedlist> 137 <itemizedlist>
138 <listitem><para># CONFIG_DEBUG_RODATA is not set</para></listitem> 138 <listitem><para># CONFIG_STRICT_KERNEL_RWX is not set</para></listitem>
139 <listitem><para>CONFIG_FRAME_POINTER=y</para></listitem> 139 <listitem><para>CONFIG_FRAME_POINTER=y</para></listitem>
140 <listitem><para>CONFIG_KGDB=y</para></listitem> 140 <listitem><para>CONFIG_KGDB=y</para></listitem>
141 <listitem><para>CONFIG_KGDB_SERIAL_CONSOLE=y</para></listitem> 141 <listitem><para>CONFIG_KGDB_SERIAL_CONSOLE=y</para></listitem>
@@ -166,7 +166,7 @@
166 </para> 166 </para>
167 <para>Here is an example set of .config symbols to enable/disable kdb: 167 <para>Here is an example set of .config symbols to enable/disable kdb:
168 <itemizedlist> 168 <itemizedlist>
169 <listitem><para># CONFIG_DEBUG_RODATA is not set</para></listitem> 169 <listitem><para># CONFIG_STRICT_KERNEL_RWX is not set</para></listitem>
170 <listitem><para>CONFIG_FRAME_POINTER=y</para></listitem> 170 <listitem><para>CONFIG_FRAME_POINTER=y</para></listitem>
171 <listitem><para>CONFIG_KGDB=y</para></listitem> 171 <listitem><para>CONFIG_KGDB=y</para></listitem>
172 <listitem><para>CONFIG_KGDB_SERIAL_CONSOLE=y</para></listitem> 172 <listitem><para>CONFIG_KGDB_SERIAL_CONSOLE=y</para></listitem>
diff --git a/Documentation/DocBook/libata.tmpl b/Documentation/DocBook/libata.tmpl
index d7fcdc5a4379..0320910b866d 100644
--- a/Documentation/DocBook/libata.tmpl
+++ b/Documentation/DocBook/libata.tmpl
@@ -1020,7 +1020,7 @@ and other resources, etc.
1020 </itemizedlist> 1020 </itemizedlist>
1021 1021
1022 <para> 1022 <para>
1023 Of errors detected as above, the followings are not ATA/ATAPI 1023 Of errors detected as above, the following are not ATA/ATAPI
1024 device errors but ATA bus errors and should be handled 1024 device errors but ATA bus errors and should be handled
1025 according to <xref linkend="excatATAbusErr"/>. 1025 according to <xref linkend="excatATAbusErr"/>.
1026 </para> 1026 </para>
diff --git a/Documentation/DocBook/regulator.tmpl b/Documentation/DocBook/regulator.tmpl
deleted file mode 100644
index 3b08a085d2c7..000000000000
--- a/Documentation/DocBook/regulator.tmpl
+++ /dev/null
@@ -1,304 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
4
5<book id="regulator-api">
6 <bookinfo>
7 <title>Voltage and current regulator API</title>
8
9 <authorgroup>
10 <author>
11 <firstname>Liam</firstname>
12 <surname>Girdwood</surname>
13 <affiliation>
14 <address>
15 <email>lrg@slimlogic.co.uk</email>
16 </address>
17 </affiliation>
18 </author>
19 <author>
20 <firstname>Mark</firstname>
21 <surname>Brown</surname>
22 <affiliation>
23 <orgname>Wolfson Microelectronics</orgname>
24 <address>
25 <email>broonie@opensource.wolfsonmicro.com</email>
26 </address>
27 </affiliation>
28 </author>
29 </authorgroup>
30
31 <copyright>
32 <year>2007-2008</year>
33 <holder>Wolfson Microelectronics</holder>
34 </copyright>
35 <copyright>
36 <year>2008</year>
37 <holder>Liam Girdwood</holder>
38 </copyright>
39
40 <legalnotice>
41 <para>
42 This documentation is free software; you can redistribute
43 it and/or modify it under the terms of the GNU General Public
44 License version 2 as published by the Free Software Foundation.
45 </para>
46
47 <para>
48 This program is distributed in the hope that it will be
49 useful, but WITHOUT ANY WARRANTY; without even the implied
50 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
51 See the GNU General Public License for more details.
52 </para>
53
54 <para>
55 You should have received a copy of the GNU General Public
56 License along with this program; if not, write to the Free
57 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
58 MA 02111-1307 USA
59 </para>
60
61 <para>
62 For more details see the file COPYING in the source
63 distribution of Linux.
64 </para>
65 </legalnotice>
66 </bookinfo>
67
68<toc></toc>
69
70 <chapter id="intro">
71 <title>Introduction</title>
72 <para>
73 This framework is designed to provide a standard kernel
74 interface to control voltage and current regulators.
75 </para>
76 <para>
77 The intention is to allow systems to dynamically control
78 regulator power output in order to save power and prolong
79 battery life. This applies to both voltage regulators (where
80 voltage output is controllable) and current sinks (where current
81 limit is controllable).
82 </para>
83 <para>
84 Note that additional (and currently more complete) documentation
85 is available in the Linux kernel source under
86 <filename>Documentation/power/regulator</filename>.
87 </para>
88
89 <sect1 id="glossary">
90 <title>Glossary</title>
91 <para>
92 The regulator API uses a number of terms which may not be
93 familiar:
94 </para>
95 <glossary>
96
97 <glossentry>
98 <glossterm>Regulator</glossterm>
99 <glossdef>
100 <para>
101 Electronic device that supplies power to other devices. Most
102 regulators can enable and disable their output and some can also
103 control their output voltage or current.
104 </para>
105 </glossdef>
106 </glossentry>
107
108 <glossentry>
109 <glossterm>Consumer</glossterm>
110 <glossdef>
111 <para>
112 Electronic device which consumes power provided by a regulator.
113 These may either be static, requiring only a fixed supply, or
114 dynamic, requiring active management of the regulator at
115 runtime.
116 </para>
117 </glossdef>
118 </glossentry>
119
120 <glossentry>
121 <glossterm>Power Domain</glossterm>
122 <glossdef>
123 <para>
124 The electronic circuit supplied by a given regulator, including
125 the regulator and all consumer devices. The configuration of
126 the regulator is shared between all the components in the
127 circuit.
128 </para>
129 </glossdef>
130 </glossentry>
131
132 <glossentry>
133 <glossterm>Power Management Integrated Circuit</glossterm>
134 <acronym>PMIC</acronym>
135 <glossdef>
136 <para>
137 An IC which contains numerous regulators and often also other
138 subsystems. In an embedded system the primary PMIC is often
139 equivalent to a combination of the PSU and southbridge in a
140 desktop system.
141 </para>
142 </glossdef>
143 </glossentry>
144 </glossary>
145 </sect1>
146 </chapter>
147
148 <chapter id="consumer">
149 <title>Consumer driver interface</title>
150 <para>
151 This offers a similar API to the kernel clock framework.
152 Consumer drivers use <link
153 linkend='API-regulator-get'>get</link> and <link
154 linkend='API-regulator-put'>put</link> operations to acquire and
155 release regulators. Functions are
156 provided to <link linkend='API-regulator-enable'>enable</link>
157 and <link linkend='API-regulator-disable'>disable</link> the
158 regulator and to get and set the runtime parameters of the
159 regulator.
160 </para>
161 <para>
162 When requesting regulators consumers use symbolic names for their
163 supplies, such as "Vcc", which are mapped into actual regulator
164 devices by the machine interface.
165 </para>
166 <para>
167 A stub version of this API is provided when the regulator
168 framework is not in use in order to minimise the need to use
169 ifdefs.
170 </para>
171
172 <sect1 id="consumer-enable">
173 <title>Enabling and disabling</title>
174 <para>
175 The regulator API provides reference counted enabling and
176 disabling of regulators. Consumer devices use the <function><link
177 linkend='API-regulator-enable'>regulator_enable</link></function>
178 and <function><link
179 linkend='API-regulator-disable'>regulator_disable</link>
180 </function> functions to enable and disable regulators. Calls
181 to the two functions must be balanced.
182 </para>
183 <para>
184 Note that since multiple consumers may be using a regulator and
185 machine constraints may not allow the regulator to be disabled
186 there is no guarantee that calling
187 <function>regulator_disable</function> will actually cause the
188 supply provided by the regulator to be disabled. Consumer
189 drivers should assume that the regulator may be enabled at all
190 times.
191 </para>
192 </sect1>
193
194 <sect1 id="consumer-config">
195 <title>Configuration</title>
196 <para>
197 Some consumer devices may need to be able to dynamically
198 configure their supplies. For example, MMC drivers may need to
199 select the correct operating voltage for their cards. This may
200 be done while the regulator is enabled or disabled.
201 </para>
202 <para>
203 The <function><link
204 linkend='API-regulator-set-voltage'>regulator_set_voltage</link>
205 </function> and <function><link
206 linkend='API-regulator-set-current-limit'
207 >regulator_set_current_limit</link>
208 </function> functions provide the primary interface for this.
209 Both take ranges of voltages and currents, supporting drivers
210 that do not require a specific value (eg, CPU frequency scaling
211 normally permits the CPU to use a wider range of supply
212 voltages at lower frequencies but does not require that the
213 supply voltage be lowered). Where an exact value is required
214 both minimum and maximum values should be identical.
215 </para>
216 </sect1>
217
218 <sect1 id="consumer-callback">
219 <title>Callbacks</title>
220 <para>
221 Callbacks may also be <link
222 linkend='API-regulator-register-notifier'>registered</link>
223 for events such as regulation failures.
224 </para>
225 </sect1>
226 </chapter>
227
228 <chapter id="driver">
229 <title>Regulator driver interface</title>
230 <para>
231 Drivers for regulator chips <link
232 linkend='API-regulator-register'>register</link> the regulators
233 with the regulator core, providing operations structures to the
234 core. A <link
235 linkend='API-regulator-notifier-call-chain'>notifier</link> interface
236 allows error conditions to be reported to the core.
237 </para>
238 <para>
239 Registration should be triggered by explicit setup done by the
240 platform, supplying a <link
241 linkend='API-struct-regulator-init-data'>struct
242 regulator_init_data</link> for the regulator containing
243 <link linkend='machine-constraint'>constraint</link> and
244 <link linkend='machine-supply'>supply</link> information.
245 </para>
246 </chapter>
247
248 <chapter id="machine">
249 <title>Machine interface</title>
250 <para>
251 This interface provides a way to define how regulators are
252 connected to consumers on a given system and what the valid
253 operating parameters are for the system.
254 </para>
255
256 <sect1 id="machine-supply">
257 <title>Supplies</title>
258 <para>
259 Regulator supplies are specified using <link
260 linkend='API-struct-regulator-consumer-supply'>struct
261 regulator_consumer_supply</link>. This is done at
262 <link linkend='driver'>driver registration
263 time</link> as part of the machine constraints.
264 </para>
265 </sect1>
266
267 <sect1 id="machine-constraint">
268 <title>Constraints</title>
269 <para>
270 As well as defining the connections the machine interface
271 also provides constraints defining the operations that
272 clients are allowed to perform and the parameters that may be
273 set. This is required since generally regulator devices will
274 offer more flexibility than it is safe to use on a given
275 system, for example supporting higher supply voltages than the
276 consumers are rated for.
277 </para>
278 <para>
279 This is done at <link linkend='driver'>driver
280 registration time</link> by providing a <link
281 linkend='API-struct-regulation-constraints'>struct
282 regulation_constraints</link>.
283 </para>
284 <para>
285 The constraints may also specify an initial configuration for the
286 regulator in the constraints, which is particularly useful for
287 use with static consumers.
288 </para>
289 </sect1>
290 </chapter>
291
292 <chapter id="api">
293 <title>API reference</title>
294 <para>
295 Due to limitations of the kernel documentation framework and the
296 existing layout of the source code the entire regulator API is
297 documented here.
298 </para>
299!Iinclude/linux/regulator/consumer.h
300!Iinclude/linux/regulator/machine.h
301!Iinclude/linux/regulator/driver.h
302!Edrivers/regulator/core.c
303 </chapter>
304</book>
diff --git a/Documentation/DocBook/uio-howto.tmpl b/Documentation/DocBook/uio-howto.tmpl
deleted file mode 100644
index 5210f8a577c6..000000000000
--- a/Documentation/DocBook/uio-howto.tmpl
+++ /dev/null
@@ -1,1112 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" []>
4
5<book id="index">
6<bookinfo>
7<title>The Userspace I/O HOWTO</title>
8
9<author>
10 <firstname>Hans-Jürgen</firstname>
11 <surname>Koch</surname>
12 <authorblurb><para>Linux developer, Linutronix</para></authorblurb>
13 <affiliation>
14 <orgname>
15 <ulink url="http://www.linutronix.de">Linutronix</ulink>
16 </orgname>
17
18 <address>
19 <email>hjk@hansjkoch.de</email>
20 </address>
21 </affiliation>
22</author>
23
24<copyright>
25 <year>2006-2008</year>
26 <holder>Hans-Jürgen Koch.</holder>
27</copyright>
28<copyright>
29 <year>2009</year>
30 <holder>Red Hat Inc, Michael S. Tsirkin (mst@redhat.com)</holder>
31</copyright>
32
33<legalnotice>
34<para>
35This documentation is Free Software licensed under the terms of the
36GPL version 2.
37</para>
38</legalnotice>
39
40<pubdate>2006-12-11</pubdate>
41
42<abstract>
43 <para>This HOWTO describes concept and usage of Linux kernel's
44 Userspace I/O system.</para>
45</abstract>
46
47<revhistory>
48 <revision>
49 <revnumber>0.10</revnumber>
50 <date>2016-10-17</date>
51 <authorinitials>sch</authorinitials>
52 <revremark>Added generic hyperv driver
53 </revremark>
54 </revision>
55 <revision>
56 <revnumber>0.9</revnumber>
57 <date>2009-07-16</date>
58 <authorinitials>mst</authorinitials>
59 <revremark>Added generic pci driver
60 </revremark>
61 </revision>
62 <revision>
63 <revnumber>0.8</revnumber>
64 <date>2008-12-24</date>
65 <authorinitials>hjk</authorinitials>
66 <revremark>Added name attributes in mem and portio sysfs directories.
67 </revremark>
68 </revision>
69 <revision>
70 <revnumber>0.7</revnumber>
71 <date>2008-12-23</date>
72 <authorinitials>hjk</authorinitials>
73 <revremark>Added generic platform drivers and offset attribute.</revremark>
74 </revision>
75 <revision>
76 <revnumber>0.6</revnumber>
77 <date>2008-12-05</date>
78 <authorinitials>hjk</authorinitials>
79 <revremark>Added description of portio sysfs attributes.</revremark>
80 </revision>
81 <revision>
82 <revnumber>0.5</revnumber>
83 <date>2008-05-22</date>
84 <authorinitials>hjk</authorinitials>
85 <revremark>Added description of write() function.</revremark>
86 </revision>
87 <revision>
88 <revnumber>0.4</revnumber>
89 <date>2007-11-26</date>
90 <authorinitials>hjk</authorinitials>
91 <revremark>Removed section about uio_dummy.</revremark>
92 </revision>
93 <revision>
94 <revnumber>0.3</revnumber>
95 <date>2007-04-29</date>
96 <authorinitials>hjk</authorinitials>
97 <revremark>Added section about userspace drivers.</revremark>
98 </revision>
99 <revision>
100 <revnumber>0.2</revnumber>
101 <date>2007-02-13</date>
102 <authorinitials>hjk</authorinitials>
103 <revremark>Update after multiple mappings were added.</revremark>
104 </revision>
105 <revision>
106 <revnumber>0.1</revnumber>
107 <date>2006-12-11</date>
108 <authorinitials>hjk</authorinitials>
109 <revremark>First draft.</revremark>
110 </revision>
111</revhistory>
112</bookinfo>
113
114<chapter id="aboutthisdoc">
115<?dbhtml filename="aboutthis.html"?>
116<title>About this document</title>
117
118<sect1 id="translations">
119<?dbhtml filename="translations.html"?>
120<title>Translations</title>
121
122<para>If you know of any translations for this document, or you are
123interested in translating it, please email me
124<email>hjk@hansjkoch.de</email>.
125</para>
126</sect1>
127
128<sect1 id="preface">
129<title>Preface</title>
130 <para>
131 For many types of devices, creating a Linux kernel driver is
132 overkill. All that is really needed is some way to handle an
133 interrupt and provide access to the memory space of the
134 device. The logic of controlling the device does not
135 necessarily have to be within the kernel, as the device does
136 not need to take advantage of any of other resources that the
137 kernel provides. One such common class of devices that are
138 like this are for industrial I/O cards.
139 </para>
140 <para>
141 To address this situation, the userspace I/O system (UIO) was
142 designed. For typical industrial I/O cards, only a very small
143 kernel module is needed. The main part of the driver will run in
144 user space. This simplifies development and reduces the risk of
145 serious bugs within a kernel module.
146 </para>
147 <para>
148 Please note that UIO is not an universal driver interface. Devices
149 that are already handled well by other kernel subsystems (like
150 networking or serial or USB) are no candidates for an UIO driver.
151 Hardware that is ideally suited for an UIO driver fulfills all of
152 the following:
153 </para>
154<itemizedlist>
155<listitem>
156 <para>The device has memory that can be mapped. The device can be
157 controlled completely by writing to this memory.</para>
158</listitem>
159<listitem>
160 <para>The device usually generates interrupts.</para>
161</listitem>
162<listitem>
163 <para>The device does not fit into one of the standard kernel
164 subsystems.</para>
165</listitem>
166</itemizedlist>
167</sect1>
168
169<sect1 id="thanks">
170<title>Acknowledgments</title>
171 <para>I'd like to thank Thomas Gleixner and Benedikt Spranger of
172 Linutronix, who have not only written most of the UIO code, but also
173 helped greatly writing this HOWTO by giving me all kinds of background
174 information.</para>
175</sect1>
176
177<sect1 id="feedback">
178<title>Feedback</title>
179 <para>Find something wrong with this document? (Or perhaps something
180 right?) I would love to hear from you. Please email me at
181 <email>hjk@hansjkoch.de</email>.</para>
182</sect1>
183</chapter>
184
185<chapter id="about">
186<?dbhtml filename="about.html"?>
187<title>About UIO</title>
188
189<para>If you use UIO for your card's driver, here's what you get:</para>
190
191<itemizedlist>
192<listitem>
193 <para>only one small kernel module to write and maintain.</para>
194</listitem>
195<listitem>
196 <para>develop the main part of your driver in user space,
197 with all the tools and libraries you're used to.</para>
198</listitem>
199<listitem>
200 <para>bugs in your driver won't crash the kernel.</para>
201</listitem>
202<listitem>
203 <para>updates of your driver can take place without recompiling
204 the kernel.</para>
205</listitem>
206</itemizedlist>
207
208<sect1 id="how_uio_works">
209<title>How UIO works</title>
210 <para>
211 Each UIO device is accessed through a device file and several
212 sysfs attribute files. The device file will be called
213 <filename>/dev/uio0</filename> for the first device, and
214 <filename>/dev/uio1</filename>, <filename>/dev/uio2</filename>
215 and so on for subsequent devices.
216 </para>
217
218 <para><filename>/dev/uioX</filename> is used to access the
219 address space of the card. Just use
220 <function>mmap()</function> to access registers or RAM
221 locations of your card.
222 </para>
223
224 <para>
225 Interrupts are handled by reading from
226 <filename>/dev/uioX</filename>. A blocking
227 <function>read()</function> from
228 <filename>/dev/uioX</filename> will return as soon as an
229 interrupt occurs. You can also use
230 <function>select()</function> on
231 <filename>/dev/uioX</filename> to wait for an interrupt. The
232 integer value read from <filename>/dev/uioX</filename>
233 represents the total interrupt count. You can use this number
234 to figure out if you missed some interrupts.
235 </para>
236 <para>
237 For some hardware that has more than one interrupt source internally,
238 but not separate IRQ mask and status registers, there might be
239 situations where userspace cannot determine what the interrupt source
240 was if the kernel handler disables them by writing to the chip's IRQ
241 register. In such a case, the kernel has to disable the IRQ completely
242 to leave the chip's register untouched. Now the userspace part can
243 determine the cause of the interrupt, but it cannot re-enable
244 interrupts. Another cornercase is chips where re-enabling interrupts
245 is a read-modify-write operation to a combined IRQ status/acknowledge
246 register. This would be racy if a new interrupt occurred
247 simultaneously.
248 </para>
249 <para>
250 To address these problems, UIO also implements a write() function. It
251 is normally not used and can be ignored for hardware that has only a
252 single interrupt source or has separate IRQ mask and status registers.
253 If you need it, however, a write to <filename>/dev/uioX</filename>
254 will call the <function>irqcontrol()</function> function implemented
255 by the driver. You have to write a 32-bit value that is usually either
256 0 or 1 to disable or enable interrupts. If a driver does not implement
257 <function>irqcontrol()</function>, <function>write()</function> will
258 return with <varname>-ENOSYS</varname>.
259 </para>
260
261 <para>
262 To handle interrupts properly, your custom kernel module can
263 provide its own interrupt handler. It will automatically be
264 called by the built-in handler.
265 </para>
266
267 <para>
268 For cards that don't generate interrupts but need to be
269 polled, there is the possibility to set up a timer that
270 triggers the interrupt handler at configurable time intervals.
271 This interrupt simulation is done by calling
272 <function>uio_event_notify()</function>
273 from the timer's event handler.
274 </para>
275
276 <para>
277 Each driver provides attributes that are used to read or write
278 variables. These attributes are accessible through sysfs
279 files. A custom kernel driver module can add its own
280 attributes to the device owned by the uio driver, but not added
281 to the UIO device itself at this time. This might change in the
282 future if it would be found to be useful.
283 </para>
284
285 <para>
286 The following standard attributes are provided by the UIO
287 framework:
288 </para>
289<itemizedlist>
290<listitem>
291 <para>
292 <filename>name</filename>: The name of your device. It is
293 recommended to use the name of your kernel module for this.
294 </para>
295</listitem>
296<listitem>
297 <para>
298 <filename>version</filename>: A version string defined by your
299 driver. This allows the user space part of your driver to deal
300 with different versions of the kernel module.
301 </para>
302</listitem>
303<listitem>
304 <para>
305 <filename>event</filename>: The total number of interrupts
306 handled by the driver since the last time the device node was
307 read.
308 </para>
309</listitem>
310</itemizedlist>
311<para>
312 These attributes appear under the
313 <filename>/sys/class/uio/uioX</filename> directory. Please
314 note that this directory might be a symlink, and not a real
315 directory. Any userspace code that accesses it must be able
316 to handle this.
317</para>
318<para>
319 Each UIO device can make one or more memory regions available for
320 memory mapping. This is necessary because some industrial I/O cards
321 require access to more than one PCI memory region in a driver.
322</para>
323<para>
324 Each mapping has its own directory in sysfs, the first mapping
325 appears as <filename>/sys/class/uio/uioX/maps/map0/</filename>.
326 Subsequent mappings create directories <filename>map1/</filename>,
327 <filename>map2/</filename>, and so on. These directories will only
328 appear if the size of the mapping is not 0.
329</para>
330<para>
331 Each <filename>mapX/</filename> directory contains four read-only files
332 that show attributes of the memory:
333</para>
334<itemizedlist>
335<listitem>
336 <para>
337 <filename>name</filename>: A string identifier for this mapping. This
338 is optional, the string can be empty. Drivers can set this to make it
339 easier for userspace to find the correct mapping.
340 </para>
341</listitem>
342<listitem>
343 <para>
344 <filename>addr</filename>: The address of memory that can be mapped.
345 </para>
346</listitem>
347<listitem>
348 <para>
349 <filename>size</filename>: The size, in bytes, of the memory
350 pointed to by addr.
351 </para>
352</listitem>
353<listitem>
354 <para>
355 <filename>offset</filename>: The offset, in bytes, that has to be
356 added to the pointer returned by <function>mmap()</function> to get
357 to the actual device memory. This is important if the device's memory
358 is not page aligned. Remember that pointers returned by
359 <function>mmap()</function> are always page aligned, so it is good
360 style to always add this offset.
361 </para>
362</listitem>
363</itemizedlist>
364
365<para>
366 From userspace, the different mappings are distinguished by adjusting
367 the <varname>offset</varname> parameter of the
368 <function>mmap()</function> call. To map the memory of mapping N, you
369 have to use N times the page size as your offset:
370</para>
371<programlisting format="linespecific">
372offset = N * getpagesize();
373</programlisting>
374
375<para>
376 Sometimes there is hardware with memory-like regions that can not be
377 mapped with the technique described here, but there are still ways to
378 access them from userspace. The most common example are x86 ioports.
379 On x86 systems, userspace can access these ioports using
380 <function>ioperm()</function>, <function>iopl()</function>,
381 <function>inb()</function>, <function>outb()</function>, and similar
382 functions.
383</para>
384<para>
385 Since these ioport regions can not be mapped, they will not appear under
386 <filename>/sys/class/uio/uioX/maps/</filename> like the normal memory
387 described above. Without information about the port regions a hardware
388 has to offer, it becomes difficult for the userspace part of the
389 driver to find out which ports belong to which UIO device.
390</para>
391<para>
392 To address this situation, the new directory
393 <filename>/sys/class/uio/uioX/portio/</filename> was added. It only
394 exists if the driver wants to pass information about one or more port
395 regions to userspace. If that is the case, subdirectories named
396 <filename>port0</filename>, <filename>port1</filename>, and so on,
397 will appear underneath
398 <filename>/sys/class/uio/uioX/portio/</filename>.
399</para>
400<para>
401 Each <filename>portX/</filename> directory contains four read-only
402 files that show name, start, size, and type of the port region:
403</para>
404<itemizedlist>
405<listitem>
406 <para>
407 <filename>name</filename>: A string identifier for this port region.
408 The string is optional and can be empty. Drivers can set it to make it
409 easier for userspace to find a certain port region.
410 </para>
411</listitem>
412<listitem>
413 <para>
414 <filename>start</filename>: The first port of this region.
415 </para>
416</listitem>
417<listitem>
418 <para>
419 <filename>size</filename>: The number of ports in this region.
420 </para>
421</listitem>
422<listitem>
423 <para>
424 <filename>porttype</filename>: A string describing the type of port.
425 </para>
426</listitem>
427</itemizedlist>
428
429
430</sect1>
431</chapter>
432
433<chapter id="custom_kernel_module" xreflabel="Writing your own kernel module">
434<?dbhtml filename="custom_kernel_module.html"?>
435<title>Writing your own kernel module</title>
436 <para>
437 Please have a look at <filename>uio_cif.c</filename> as an
438 example. The following paragraphs explain the different
439 sections of this file.
440 </para>
441
442<sect1 id="uio_info">
443<title>struct uio_info</title>
444 <para>
445 This structure tells the framework the details of your driver,
446 Some of the members are required, others are optional.
447 </para>
448
449<itemizedlist>
450<listitem><para>
451<varname>const char *name</varname>: Required. The name of your driver as
452it will appear in sysfs. I recommend using the name of your module for this.
453</para></listitem>
454
455<listitem><para>
456<varname>const char *version</varname>: Required. This string appears in
457<filename>/sys/class/uio/uioX/version</filename>.
458</para></listitem>
459
460<listitem><para>
461<varname>struct uio_mem mem[ MAX_UIO_MAPS ]</varname>: Required if you
462have memory that can be mapped with <function>mmap()</function>. For each
463mapping you need to fill one of the <varname>uio_mem</varname> structures.
464See the description below for details.
465</para></listitem>
466
467<listitem><para>
468<varname>struct uio_port port[ MAX_UIO_PORTS_REGIONS ]</varname>: Required
469if you want to pass information about ioports to userspace. For each port
470region you need to fill one of the <varname>uio_port</varname> structures.
471See the description below for details.
472</para></listitem>
473
474<listitem><para>
475<varname>long irq</varname>: Required. If your hardware generates an
476interrupt, it's your modules task to determine the irq number during
477initialization. If you don't have a hardware generated interrupt but
478want to trigger the interrupt handler in some other way, set
479<varname>irq</varname> to <varname>UIO_IRQ_CUSTOM</varname>.
480If you had no interrupt at all, you could set
481<varname>irq</varname> to <varname>UIO_IRQ_NONE</varname>, though this
482rarely makes sense.
483</para></listitem>
484
485<listitem><para>
486<varname>unsigned long irq_flags</varname>: Required if you've set
487<varname>irq</varname> to a hardware interrupt number. The flags given
488here will be used in the call to <function>request_irq()</function>.
489</para></listitem>
490
491<listitem><para>
492<varname>int (*mmap)(struct uio_info *info, struct vm_area_struct
493*vma)</varname>: Optional. If you need a special
494<function>mmap()</function> function, you can set it here. If this
495pointer is not NULL, your <function>mmap()</function> will be called
496instead of the built-in one.
497</para></listitem>
498
499<listitem><para>
500<varname>int (*open)(struct uio_info *info, struct inode *inode)
501</varname>: Optional. You might want to have your own
502<function>open()</function>, e.g. to enable interrupts only when your
503device is actually used.
504</para></listitem>
505
506<listitem><para>
507<varname>int (*release)(struct uio_info *info, struct inode *inode)
508</varname>: Optional. If you define your own
509<function>open()</function>, you will probably also want a custom
510<function>release()</function> function.
511</para></listitem>
512
513<listitem><para>
514<varname>int (*irqcontrol)(struct uio_info *info, s32 irq_on)
515</varname>: Optional. If you need to be able to enable or disable
516interrupts from userspace by writing to <filename>/dev/uioX</filename>,
517you can implement this function. The parameter <varname>irq_on</varname>
518will be 0 to disable interrupts and 1 to enable them.
519</para></listitem>
520</itemizedlist>
521
522<para>
523Usually, your device will have one or more memory regions that can be mapped
524to user space. For each region, you have to set up a
525<varname>struct uio_mem</varname> in the <varname>mem[]</varname> array.
526Here's a description of the fields of <varname>struct uio_mem</varname>:
527</para>
528
529<itemizedlist>
530<listitem><para>
531<varname>const char *name</varname>: Optional. Set this to help identify
532the memory region, it will show up in the corresponding sysfs node.
533</para></listitem>
534
535<listitem><para>
536<varname>int memtype</varname>: Required if the mapping is used. Set this to
537<varname>UIO_MEM_PHYS</varname> if you you have physical memory on your
538card to be mapped. Use <varname>UIO_MEM_LOGICAL</varname> for logical
539memory (e.g. allocated with <function>kmalloc()</function>). There's also
540<varname>UIO_MEM_VIRTUAL</varname> for virtual memory.
541</para></listitem>
542
543<listitem><para>
544<varname>phys_addr_t addr</varname>: Required if the mapping is used.
545Fill in the address of your memory block. This address is the one that
546appears in sysfs.
547</para></listitem>
548
549<listitem><para>
550<varname>resource_size_t size</varname>: Fill in the size of the
551memory block that <varname>addr</varname> points to. If <varname>size</varname>
552is zero, the mapping is considered unused. Note that you
553<emphasis>must</emphasis> initialize <varname>size</varname> with zero for
554all unused mappings.
555</para></listitem>
556
557<listitem><para>
558<varname>void *internal_addr</varname>: If you have to access this memory
559region from within your kernel module, you will want to map it internally by
560using something like <function>ioremap()</function>. Addresses
561returned by this function cannot be mapped to user space, so you must not
562store it in <varname>addr</varname>. Use <varname>internal_addr</varname>
563instead to remember such an address.
564</para></listitem>
565</itemizedlist>
566
567<para>
568Please do not touch the <varname>map</varname> element of
569<varname>struct uio_mem</varname>! It is used by the UIO framework
570to set up sysfs files for this mapping. Simply leave it alone.
571</para>
572
573<para>
574Sometimes, your device can have one or more port regions which can not be
575mapped to userspace. But if there are other possibilities for userspace to
576access these ports, it makes sense to make information about the ports
577available in sysfs. For each region, you have to set up a
578<varname>struct uio_port</varname> in the <varname>port[]</varname> array.
579Here's a description of the fields of <varname>struct uio_port</varname>:
580</para>
581
582<itemizedlist>
583<listitem><para>
584<varname>char *porttype</varname>: Required. Set this to one of the predefined
585constants. Use <varname>UIO_PORT_X86</varname> for the ioports found in x86
586architectures.
587</para></listitem>
588
589<listitem><para>
590<varname>unsigned long start</varname>: Required if the port region is used.
591Fill in the number of the first port of this region.
592</para></listitem>
593
594<listitem><para>
595<varname>unsigned long size</varname>: Fill in the number of ports in this
596region. If <varname>size</varname> is zero, the region is considered unused.
597Note that you <emphasis>must</emphasis> initialize <varname>size</varname>
598with zero for all unused regions.
599</para></listitem>
600</itemizedlist>
601
602<para>
603Please do not touch the <varname>portio</varname> element of
604<varname>struct uio_port</varname>! It is used internally by the UIO
605framework to set up sysfs files for this region. Simply leave it alone.
606</para>
607
608</sect1>
609
610<sect1 id="adding_irq_handler">
611<title>Adding an interrupt handler</title>
612 <para>
613 What you need to do in your interrupt handler depends on your
614 hardware and on how you want to handle it. You should try to
615 keep the amount of code in your kernel interrupt handler low.
616 If your hardware requires no action that you
617 <emphasis>have</emphasis> to perform after each interrupt,
618 then your handler can be empty.</para> <para>If, on the other
619 hand, your hardware <emphasis>needs</emphasis> some action to
620 be performed after each interrupt, then you
621 <emphasis>must</emphasis> do it in your kernel module. Note
622 that you cannot rely on the userspace part of your driver. Your
623 userspace program can terminate at any time, possibly leaving
624 your hardware in a state where proper interrupt handling is
625 still required.
626 </para>
627
628 <para>
629 There might also be applications where you want to read data
630 from your hardware at each interrupt and buffer it in a piece
631 of kernel memory you've allocated for that purpose. With this
632 technique you could avoid loss of data if your userspace
633 program misses an interrupt.
634 </para>
635
636 <para>
637 A note on shared interrupts: Your driver should support
638 interrupt sharing whenever this is possible. It is possible if
639 and only if your driver can detect whether your hardware has
640 triggered the interrupt or not. This is usually done by looking
641 at an interrupt status register. If your driver sees that the
642 IRQ bit is actually set, it will perform its actions, and the
643 handler returns IRQ_HANDLED. If the driver detects that it was
644 not your hardware that caused the interrupt, it will do nothing
645 and return IRQ_NONE, allowing the kernel to call the next
646 possible interrupt handler.
647 </para>
648
649 <para>
650 If you decide not to support shared interrupts, your card
651 won't work in computers with no free interrupts. As this
652 frequently happens on the PC platform, you can save yourself a
653 lot of trouble by supporting interrupt sharing.
654 </para>
655</sect1>
656
657<sect1 id="using_uio_pdrv">
658<title>Using uio_pdrv for platform devices</title>
659 <para>
660 In many cases, UIO drivers for platform devices can be handled in a
661 generic way. In the same place where you define your
662 <varname>struct platform_device</varname>, you simply also implement
663 your interrupt handler and fill your
664 <varname>struct uio_info</varname>. A pointer to this
665 <varname>struct uio_info</varname> is then used as
666 <varname>platform_data</varname> for your platform device.
667 </para>
668 <para>
669 You also need to set up an array of <varname>struct resource</varname>
670 containing addresses and sizes of your memory mappings. This
671 information is passed to the driver using the
672 <varname>.resource</varname> and <varname>.num_resources</varname>
673 elements of <varname>struct platform_device</varname>.
674 </para>
675 <para>
676 You now have to set the <varname>.name</varname> element of
677 <varname>struct platform_device</varname> to
678 <varname>"uio_pdrv"</varname> to use the generic UIO platform device
679 driver. This driver will fill the <varname>mem[]</varname> array
680 according to the resources given, and register the device.
681 </para>
682 <para>
683 The advantage of this approach is that you only have to edit a file
684 you need to edit anyway. You do not have to create an extra driver.
685 </para>
686</sect1>
687
688<sect1 id="using_uio_pdrv_genirq">
689<title>Using uio_pdrv_genirq for platform devices</title>
690 <para>
691 Especially in embedded devices, you frequently find chips where the
692 irq pin is tied to its own dedicated interrupt line. In such cases,
693 where you can be really sure the interrupt is not shared, we can take
694 the concept of <varname>uio_pdrv</varname> one step further and use a
695 generic interrupt handler. That's what
696 <varname>uio_pdrv_genirq</varname> does.
697 </para>
698 <para>
699 The setup for this driver is the same as described above for
700 <varname>uio_pdrv</varname>, except that you do not implement an
701 interrupt handler. The <varname>.handler</varname> element of
702 <varname>struct uio_info</varname> must remain
703 <varname>NULL</varname>. The <varname>.irq_flags</varname> element
704 must not contain <varname>IRQF_SHARED</varname>.
705 </para>
706 <para>
707 You will set the <varname>.name</varname> element of
708 <varname>struct platform_device</varname> to
709 <varname>"uio_pdrv_genirq"</varname> to use this driver.
710 </para>
711 <para>
712 The generic interrupt handler of <varname>uio_pdrv_genirq</varname>
713 will simply disable the interrupt line using
714 <function>disable_irq_nosync()</function>. After doing its work,
715 userspace can reenable the interrupt by writing 0x00000001 to the UIO
716 device file. The driver already implements an
717 <function>irq_control()</function> to make this possible, you must not
718 implement your own.
719 </para>
720 <para>
721 Using <varname>uio_pdrv_genirq</varname> not only saves a few lines of
722 interrupt handler code. You also do not need to know anything about
723 the chip's internal registers to create the kernel part of the driver.
724 All you need to know is the irq number of the pin the chip is
725 connected to.
726 </para>
727</sect1>
728
729<sect1 id="using-uio_dmem_genirq">
730<title>Using uio_dmem_genirq for platform devices</title>
731 <para>
732 In addition to statically allocated memory ranges, they may also be
733 a desire to use dynamically allocated regions in a user space driver.
734 In particular, being able to access memory made available through the
735 dma-mapping API, may be particularly useful. The
736 <varname>uio_dmem_genirq</varname> driver provides a way to accomplish
737 this.
738 </para>
739 <para>
740 This driver is used in a similar manner to the
741 <varname>"uio_pdrv_genirq"</varname> driver with respect to interrupt
742 configuration and handling.
743 </para>
744 <para>
745 Set the <varname>.name</varname> element of
746 <varname>struct platform_device</varname> to
747 <varname>"uio_dmem_genirq"</varname> to use this driver.
748 </para>
749 <para>
750 When using this driver, fill in the <varname>.platform_data</varname>
751 element of <varname>struct platform_device</varname>, which is of type
752 <varname>struct uio_dmem_genirq_pdata</varname> and which contains the
753 following elements:
754 </para>
755 <itemizedlist>
756 <listitem><para><varname>struct uio_info uioinfo</varname>: The same
757 structure used as the <varname>uio_pdrv_genirq</varname> platform
758 data</para></listitem>
759 <listitem><para><varname>unsigned int *dynamic_region_sizes</varname>:
760 Pointer to list of sizes of dynamic memory regions to be mapped into
761 user space.
762 </para></listitem>
763 <listitem><para><varname>unsigned int num_dynamic_regions</varname>:
764 Number of elements in <varname>dynamic_region_sizes</varname> array.
765 </para></listitem>
766 </itemizedlist>
767 <para>
768 The dynamic regions defined in the platform data will be appended to
769 the <varname> mem[] </varname> array after the platform device
770 resources, which implies that the total number of static and dynamic
771 memory regions cannot exceed <varname>MAX_UIO_MAPS</varname>.
772 </para>
773 <para>
774 The dynamic memory regions will be allocated when the UIO device file,
775 <varname>/dev/uioX</varname> is opened.
776 Similar to static memory resources, the memory region information for
777 dynamic regions is then visible via sysfs at
778 <varname>/sys/class/uio/uioX/maps/mapY/*</varname>.
779 The dynamic memory regions will be freed when the UIO device file is
780 closed. When no processes are holding the device file open, the address
781 returned to userspace is ~0.
782 </para>
783</sect1>
784
785</chapter>
786
787<chapter id="userspace_driver" xreflabel="Writing a driver in user space">
788<?dbhtml filename="userspace_driver.html"?>
789<title>Writing a driver in userspace</title>
790 <para>
791 Once you have a working kernel module for your hardware, you can
792 write the userspace part of your driver. You don't need any special
793 libraries, your driver can be written in any reasonable language,
794 you can use floating point numbers and so on. In short, you can
795 use all the tools and libraries you'd normally use for writing a
796 userspace application.
797 </para>
798
799<sect1 id="getting_uio_information">
800<title>Getting information about your UIO device</title>
801 <para>
802 Information about all UIO devices is available in sysfs. The
803 first thing you should do in your driver is check
804 <varname>name</varname> and <varname>version</varname> to
805 make sure your talking to the right device and that its kernel
806 driver has the version you expect.
807 </para>
808 <para>
809 You should also make sure that the memory mapping you need
810 exists and has the size you expect.
811 </para>
812 <para>
813 There is a tool called <varname>lsuio</varname> that lists
814 UIO devices and their attributes. It is available here:
815 </para>
816 <para>
817 <ulink url="http://www.osadl.org/projects/downloads/UIO/user/">
818 http://www.osadl.org/projects/downloads/UIO/user/</ulink>
819 </para>
820 <para>
821 With <varname>lsuio</varname> you can quickly check if your
822 kernel module is loaded and which attributes it exports.
823 Have a look at the manpage for details.
824 </para>
825 <para>
826 The source code of <varname>lsuio</varname> can serve as an
827 example for getting information about an UIO device.
828 The file <filename>uio_helper.c</filename> contains a lot of
829 functions you could use in your userspace driver code.
830 </para>
831</sect1>
832
833<sect1 id="mmap_device_memory">
834<title>mmap() device memory</title>
835 <para>
836 After you made sure you've got the right device with the
837 memory mappings you need, all you have to do is to call
838 <function>mmap()</function> to map the device's memory
839 to userspace.
840 </para>
841 <para>
842 The parameter <varname>offset</varname> of the
843 <function>mmap()</function> call has a special meaning
844 for UIO devices: It is used to select which mapping of
845 your device you want to map. To map the memory of
846 mapping N, you have to use N times the page size as
847 your offset:
848 </para>
849<programlisting format="linespecific">
850 offset = N * getpagesize();
851</programlisting>
852 <para>
853 N starts from zero, so if you've got only one memory
854 range to map, set <varname>offset = 0</varname>.
855 A drawback of this technique is that memory is always
856 mapped beginning with its start address.
857 </para>
858</sect1>
859
860<sect1 id="wait_for_interrupts">
861<title>Waiting for interrupts</title>
862 <para>
863 After you successfully mapped your devices memory, you
864 can access it like an ordinary array. Usually, you will
865 perform some initialization. After that, your hardware
866 starts working and will generate an interrupt as soon
867 as it's finished, has some data available, or needs your
868 attention because an error occurred.
869 </para>
870 <para>
871 <filename>/dev/uioX</filename> is a read-only file. A
872 <function>read()</function> will always block until an
873 interrupt occurs. There is only one legal value for the
874 <varname>count</varname> parameter of
875 <function>read()</function>, and that is the size of a
876 signed 32 bit integer (4). Any other value for
877 <varname>count</varname> causes <function>read()</function>
878 to fail. The signed 32 bit integer read is the interrupt
879 count of your device. If the value is one more than the value
880 you read the last time, everything is OK. If the difference
881 is greater than one, you missed interrupts.
882 </para>
883 <para>
884 You can also use <function>select()</function> on
885 <filename>/dev/uioX</filename>.
886 </para>
887</sect1>
888
889</chapter>
890
891<chapter id="uio_pci_generic" xreflabel="Using Generic driver for PCI cards">
892<?dbhtml filename="uio_pci_generic.html"?>
893<title>Generic PCI UIO driver</title>
894 <para>
895 The generic driver is a kernel module named uio_pci_generic.
896 It can work with any device compliant to PCI 2.3 (circa 2002) and
897 any compliant PCI Express device. Using this, you only need to
898 write the userspace driver, removing the need to write
899 a hardware-specific kernel module.
900 </para>
901
902<sect1 id="uio_pci_generic_binding">
903<title>Making the driver recognize the device</title>
904 <para>
905Since the driver does not declare any device ids, it will not get loaded
906automatically and will not automatically bind to any devices, you must load it
907and allocate id to the driver yourself. For example:
908 <programlisting>
909 modprobe uio_pci_generic
910 echo &quot;8086 10f5&quot; &gt; /sys/bus/pci/drivers/uio_pci_generic/new_id
911 </programlisting>
912 </para>
913 <para>
914If there already is a hardware specific kernel driver for your device, the
915generic driver still won't bind to it, in this case if you want to use the
916generic driver (why would you?) you'll have to manually unbind the hardware
917specific driver and bind the generic driver, like this:
918 <programlisting>
919 echo -n 0000:00:19.0 &gt; /sys/bus/pci/drivers/e1000e/unbind
920 echo -n 0000:00:19.0 &gt; /sys/bus/pci/drivers/uio_pci_generic/bind
921 </programlisting>
922 </para>
923 <para>
924You can verify that the device has been bound to the driver
925by looking for it in sysfs, for example like the following:
926 <programlisting>
927 ls -l /sys/bus/pci/devices/0000:00:19.0/driver
928 </programlisting>
929Which if successful should print
930 <programlisting>
931 .../0000:00:19.0/driver -&gt; ../../../bus/pci/drivers/uio_pci_generic
932 </programlisting>
933Note that the generic driver will not bind to old PCI 2.2 devices.
934If binding the device failed, run the following command:
935 <programlisting>
936 dmesg
937 </programlisting>
938and look in the output for failure reasons
939 </para>
940</sect1>
941
942<sect1 id="uio_pci_generic_internals">
943<title>Things to know about uio_pci_generic</title>
944 <para>
945Interrupts are handled using the Interrupt Disable bit in the PCI command
946register and Interrupt Status bit in the PCI status register. All devices
947compliant to PCI 2.3 (circa 2002) and all compliant PCI Express devices should
948support these bits. uio_pci_generic detects this support, and won't bind to
949devices which do not support the Interrupt Disable Bit in the command register.
950 </para>
951 <para>
952On each interrupt, uio_pci_generic sets the Interrupt Disable bit.
953This prevents the device from generating further interrupts
954until the bit is cleared. The userspace driver should clear this
955bit before blocking and waiting for more interrupts.
956 </para>
957</sect1>
958<sect1 id="uio_pci_generic_userspace">
959<title>Writing userspace driver using uio_pci_generic</title>
960 <para>
961Userspace driver can use pci sysfs interface, or the
962libpci libray that wraps it, to talk to the device and to
963re-enable interrupts by writing to the command register.
964 </para>
965</sect1>
966<sect1 id="uio_pci_generic_example">
967<title>Example code using uio_pci_generic</title>
968 <para>
969Here is some sample userspace driver code using uio_pci_generic:
970<programlisting>
971#include &lt;stdlib.h&gt;
972#include &lt;stdio.h&gt;
973#include &lt;unistd.h&gt;
974#include &lt;sys/types.h&gt;
975#include &lt;sys/stat.h&gt;
976#include &lt;fcntl.h&gt;
977#include &lt;errno.h&gt;
978
979int main()
980{
981 int uiofd;
982 int configfd;
983 int err;
984 int i;
985 unsigned icount;
986 unsigned char command_high;
987
988 uiofd = open(&quot;/dev/uio0&quot;, O_RDONLY);
989 if (uiofd &lt; 0) {
990 perror(&quot;uio open:&quot;);
991 return errno;
992 }
993 configfd = open(&quot;/sys/class/uio/uio0/device/config&quot;, O_RDWR);
994 if (configfd &lt; 0) {
995 perror(&quot;config open:&quot;);
996 return errno;
997 }
998
999 /* Read and cache command value */
1000 err = pread(configfd, &amp;command_high, 1, 5);
1001 if (err != 1) {
1002 perror(&quot;command config read:&quot;);
1003 return errno;
1004 }
1005 command_high &amp;= ~0x4;
1006
1007 for(i = 0;; ++i) {
1008 /* Print out a message, for debugging. */
1009 if (i == 0)
1010 fprintf(stderr, &quot;Started uio test driver.\n&quot;);
1011 else
1012 fprintf(stderr, &quot;Interrupts: %d\n&quot;, icount);
1013
1014 /****************************************/
1015 /* Here we got an interrupt from the
1016 device. Do something to it. */
1017 /****************************************/
1018
1019 /* Re-enable interrupts. */
1020 err = pwrite(configfd, &amp;command_high, 1, 5);
1021 if (err != 1) {
1022 perror(&quot;config write:&quot;);
1023 break;
1024 }
1025
1026 /* Wait for next interrupt. */
1027 err = read(uiofd, &amp;icount, 4);
1028 if (err != 4) {
1029 perror(&quot;uio read:&quot;);
1030 break;
1031 }
1032
1033 }
1034 return errno;
1035}
1036
1037</programlisting>
1038 </para>
1039</sect1>
1040
1041</chapter>
1042
1043<chapter id="uio_hv_generic" xreflabel="Using Generic driver for Hyper-V VMBUS">
1044<?dbhtml filename="uio_hv_generic.html"?>
1045<title>Generic Hyper-V UIO driver</title>
1046 <para>
1047 The generic driver is a kernel module named uio_hv_generic.
1048 It supports devices on the Hyper-V VMBus similar to uio_pci_generic
1049 on PCI bus.
1050 </para>
1051
1052<sect1 id="uio_hv_generic_binding">
1053<title>Making the driver recognize the device</title>
1054 <para>
1055Since the driver does not declare any device GUID's, it will not get loaded
1056automatically and will not automatically bind to any devices, you must load it
1057and allocate id to the driver yourself. For example, to use the network device
1058GUID:
1059 <programlisting>
1060 modprobe uio_hv_generic
1061 echo &quot;f8615163-df3e-46c5-913f-f2d2f965ed0e&quot; &gt; /sys/bus/vmbus/drivers/uio_hv_generic/new_id
1062 </programlisting>
1063 </para>
1064 <para>
1065If there already is a hardware specific kernel driver for the device, the
1066generic driver still won't bind to it, in this case if you want to use the
1067generic driver (why would you?) you'll have to manually unbind the hardware
1068specific driver and bind the generic driver, like this:
1069 <programlisting>
1070 echo -n vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3 &gt; /sys/bus/vmbus/drivers/hv_netvsc/unbind
1071 echo -n vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3 &gt; /sys/bus/vmbus/drivers/uio_hv_generic/bind
1072 </programlisting>
1073 </para>
1074 <para>
1075You can verify that the device has been bound to the driver
1076by looking for it in sysfs, for example like the following:
1077 <programlisting>
1078 ls -l /sys/bus/vmbus/devices/vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3/driver
1079 </programlisting>
1080Which if successful should print
1081 <programlisting>
1082 .../vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3/driver -&gt; ../../../bus/vmbus/drivers/uio_hv_generic
1083 </programlisting>
1084 </para>
1085</sect1>
1086
1087<sect1 id="uio_hv_generic_internals">
1088<title>Things to know about uio_hv_generic</title>
1089 <para>
1090On each interrupt, uio_hv_generic sets the Interrupt Disable bit.
1091This prevents the device from generating further interrupts
1092until the bit is cleared. The userspace driver should clear this
1093bit before blocking and waiting for more interrupts.
1094 </para>
1095</sect1>
1096</chapter>
1097
1098<appendix id="app1">
1099<title>Further information</title>
1100<itemizedlist>
1101 <listitem><para>
1102 <ulink url="http://www.osadl.org">
1103 OSADL homepage.</ulink>
1104 </para></listitem>
1105 <listitem><para>
1106 <ulink url="http://www.linutronix.de">
1107 Linutronix homepage.</ulink>
1108 </para></listitem>
1109</itemizedlist>
1110</appendix>
1111
1112</book>
diff --git a/Documentation/IPMI.txt b/Documentation/IPMI.txt
index 72292308d0f5..6962cab997ef 100644
--- a/Documentation/IPMI.txt
+++ b/Documentation/IPMI.txt
@@ -257,7 +257,7 @@ and tell you when they come and go.
257 257
258Creating the User 258Creating the User
259 259
260To user the message handler, you must first create a user using 260To use the message handler, you must first create a user using
261ipmi_create_user. The interface number specifies which SMI you want 261ipmi_create_user. The interface number specifies which SMI you want
262to connect to, and you must supply callback functions to be called 262to connect to, and you must supply callback functions to be called
263when data comes in. The callback function can run at interrupt level, 263when data comes in. The callback function can run at interrupt level,
diff --git a/Documentation/Makefile.sphinx b/Documentation/Makefile.sphinx
index 707c65337ebf..bcf529f6cf9b 100644
--- a/Documentation/Makefile.sphinx
+++ b/Documentation/Makefile.sphinx
@@ -43,7 +43,7 @@ ALLSPHINXOPTS = $(KERNELDOC_CONF) $(PAPEROPT_$(PAPER)) $(SPHINXOPTS)
43I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 43I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
44 44
45# commands; the 'cmd' from scripts/Kbuild.include is not *loopable* 45# commands; the 'cmd' from scripts/Kbuild.include is not *loopable*
46loop_cmd = $(echo-cmd) $(cmd_$(1)) 46loop_cmd = $(echo-cmd) $(cmd_$(1)) || exit;
47 47
48# $2 sphinx builder e.g. "html" 48# $2 sphinx builder e.g. "html"
49# $3 name of the build subfolder / e.g. "media", used as: 49# $3 name of the build subfolder / e.g. "media", used as:
@@ -54,7 +54,8 @@ loop_cmd = $(echo-cmd) $(cmd_$(1))
54# e.g. "media" for the linux-tv book-set at ./Documentation/media 54# e.g. "media" for the linux-tv book-set at ./Documentation/media
55 55
56quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4) 56quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
57 cmd_sphinx = $(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/media $2;\ 57 cmd_sphinx = $(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/media $2 && \
58 PYTHONDONTWRITEBYTECODE=1 \
58 BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath $(srctree)/$(src)/$5/$(SPHINX_CONF)) \ 59 BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath $(srctree)/$(src)/$5/$(SPHINX_CONF)) \
59 $(SPHINXBUILD) \ 60 $(SPHINXBUILD) \
60 -b $2 \ 61 -b $2 \
@@ -63,13 +64,16 @@ quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
63 -D version=$(KERNELVERSION) -D release=$(KERNELRELEASE) \ 64 -D version=$(KERNELVERSION) -D release=$(KERNELRELEASE) \
64 $(ALLSPHINXOPTS) \ 65 $(ALLSPHINXOPTS) \
65 $(abspath $(srctree)/$(src)/$5) \ 66 $(abspath $(srctree)/$(src)/$5) \
66 $(abspath $(BUILDDIR)/$3/$4); 67 $(abspath $(BUILDDIR)/$3/$4)
67 68
68htmldocs: 69htmldocs:
69 @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var))) 70 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
71
72linkcheckdocs:
73 @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,linkcheck,$(var),,$(var)))
70 74
71latexdocs: 75latexdocs:
72 @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,latex,$(var),latex,$(var))) 76 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,latex,$(var),latex,$(var)))
73 77
74ifeq ($(HAVE_PDFLATEX),0) 78ifeq ($(HAVE_PDFLATEX),0)
75 79
@@ -80,27 +84,34 @@ pdfdocs:
80else # HAVE_PDFLATEX 84else # HAVE_PDFLATEX
81 85
82pdfdocs: latexdocs 86pdfdocs: latexdocs
83 $(foreach var,$(SPHINXDIRS), $(MAKE) PDFLATEX=$(PDFLATEX) LATEXOPTS="$(LATEXOPTS)" -C $(BUILDDIR)/$(var)/latex;) 87 $(foreach var,$(SPHINXDIRS), $(MAKE) PDFLATEX=$(PDFLATEX) LATEXOPTS="$(LATEXOPTS)" -C $(BUILDDIR)/$(var)/latex || exit;)
84 88
85endif # HAVE_PDFLATEX 89endif # HAVE_PDFLATEX
86 90
87epubdocs: 91epubdocs:
88 @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,epub,$(var),epub,$(var))) 92 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,epub,$(var),epub,$(var)))
89 93
90xmldocs: 94xmldocs:
91 @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,xml,$(var),xml,$(var))) 95 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,xml,$(var),xml,$(var)))
96
97endif # HAVE_SPHINX
98
99# The following targets are independent of HAVE_SPHINX, and the rules should
100# work or silently pass without Sphinx.
92 101
93# no-ops for the Sphinx toolchain 102# no-ops for the Sphinx toolchain
94sgmldocs: 103sgmldocs:
104 @:
95psdocs: 105psdocs:
106 @:
96mandocs: 107mandocs:
108 @:
97installmandocs: 109installmandocs:
110 @:
98 111
99cleandocs: 112cleandocs:
100 $(Q)rm -rf $(BUILDDIR) 113 $(Q)rm -rf $(BUILDDIR)
101 $(Q)$(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) -C Documentation/media clean 114 $(Q)$(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/media clean
102
103endif # HAVE_SPHINX
104 115
105dochelp: 116dochelp:
106 @echo ' Linux kernel internal documentation in different formats (Sphinx):' 117 @echo ' Linux kernel internal documentation in different formats (Sphinx):'
@@ -109,6 +120,7 @@ dochelp:
109 @echo ' pdfdocs - PDF' 120 @echo ' pdfdocs - PDF'
110 @echo ' epubdocs - EPUB' 121 @echo ' epubdocs - EPUB'
111 @echo ' xmldocs - XML' 122 @echo ' xmldocs - XML'
123 @echo ' linkcheckdocs - check for broken external links (will connect to external hosts)'
112 @echo ' cleandocs - clean all generated files' 124 @echo ' cleandocs - clean all generated files'
113 @echo 125 @echo
114 @echo ' make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2' 126 @echo ' make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2'
diff --git a/Documentation/PCI/MSI-HOWTO.txt b/Documentation/PCI/MSI-HOWTO.txt
index cd9c9f6a7cd9..1e37138027a3 100644
--- a/Documentation/PCI/MSI-HOWTO.txt
+++ b/Documentation/PCI/MSI-HOWTO.txt
@@ -162,8 +162,6 @@ The following old APIs to enable and disable MSI or MSI-X interrupts should
162not be used in new code: 162not be used in new code:
163 163
164 pci_enable_msi() /* deprecated */ 164 pci_enable_msi() /* deprecated */
165 pci_enable_msi_range() /* deprecated */
166 pci_enable_msi_exact() /* deprecated */
167 pci_disable_msi() /* deprecated */ 165 pci_disable_msi() /* deprecated */
168 pci_enable_msix_range() /* deprecated */ 166 pci_enable_msix_range() /* deprecated */
169 pci_enable_msix_exact() /* deprecated */ 167 pci_enable_msix_exact() /* deprecated */
@@ -268,5 +266,5 @@ or disabled (0). If 0 is found in any of the msi_bus files belonging
268to bridges between the PCI root and the device, MSIs are disabled. 266to bridges between the PCI root and the device, MSIs are disabled.
269 267
270It is also worth checking the device driver to see whether it supports MSIs. 268It is also worth checking the device driver to see whether it supports MSIs.
271For example, it may contain calls to pci_enable_msi_range() or 269For example, it may contain calls to pci_irq_alloc_vectors() with the
272pci_enable_msix_range(). 270PCI_IRQ_MSI or PCI_IRQ_MSIX flags.
diff --git a/Documentation/PCI/PCIEBUS-HOWTO.txt b/Documentation/PCI/PCIEBUS-HOWTO.txt
index 6bd5f372adec..15f0bb3b5045 100644
--- a/Documentation/PCI/PCIEBUS-HOWTO.txt
+++ b/Documentation/PCI/PCIEBUS-HOWTO.txt
@@ -161,21 +161,13 @@ Since all service drivers of a PCI-PCI Bridge Port device are
161allowed to run simultaneously, below lists a few of possible resource 161allowed to run simultaneously, below lists a few of possible resource
162conflicts with proposed solutions. 162conflicts with proposed solutions.
163 163
1646.1 MSI Vector Resource 1646.1 MSI and MSI-X Vector Resource
165 165
166The MSI capability structure enables a device software driver to call 166Once MSI or MSI-X interrupts are enabled on a device, it stays in this
167pci_enable_msi to request MSI based interrupts. Once MSI interrupts 167mode until they are disabled again. Since service drivers of the same
168are enabled on a device, it stays in this mode until a device driver 168PCI-PCI Bridge port share the same physical device, if an individual
169calls pci_disable_msi to disable MSI interrupts and revert back to 169service driver enables or disables MSI/MSI-X mode it may result
170INTx emulation mode. Since service drivers of the same PCI-PCI Bridge 170unpredictable behavior.
171port share the same physical device, if an individual service driver
172calls pci_enable_msi/pci_disable_msi it may result unpredictable
173behavior. For example, two service drivers run simultaneously on the
174same physical Root Port. Both service drivers call pci_enable_msi to
175request MSI based interrupts. A service driver may not know whether
176any other service drivers have run on this Root Port. If either one
177of them calls pci_disable_msi, it puts the other service driver
178in a wrong interrupt mode.
179 171
180To avoid this situation all service drivers are not permitted to 172To avoid this situation all service drivers are not permitted to
181switch interrupt mode on its device. The PCI Express Port Bus driver 173switch interrupt mode on its device. The PCI Express Port Bus driver
@@ -187,17 +179,6 @@ driver. Service drivers should use (struct pcie_device*)dev->irq to
187call request_irq/free_irq. In addition, the interrupt mode is stored 179call request_irq/free_irq. In addition, the interrupt mode is stored
188in the field interrupt_mode of struct pcie_device. 180in the field interrupt_mode of struct pcie_device.
189 181
1906.2 MSI-X Vector Resources
191
192Similar to the MSI a device driver for an MSI-X capable device can
193call pci_enable_msix to request MSI-X interrupts. All service drivers
194are not permitted to switch interrupt mode on its device. The PCI
195Express Port Bus driver is responsible for determining the interrupt
196mode and this should be transparent to service drivers. Any attempt
197by service driver to call pci_enable_msix/pci_disable_msix may
198result unpredictable behavior. Service drivers should use
199(struct pcie_device*)dev->irq and call request_irq/free_irq.
200
2016.3 PCI Memory/IO Mapped Regions 1826.3 PCI Memory/IO Mapped Regions
202 183
203Service drivers for PCI Express Power Management (PME), Advanced 184Service drivers for PCI Express Power Management (PME), Advanced
diff --git a/Documentation/PCI/pci-error-recovery.txt b/Documentation/PCI/pci-error-recovery.txt
index ac26869c7db4..da3b2176d5da 100644
--- a/Documentation/PCI/pci-error-recovery.txt
+++ b/Documentation/PCI/pci-error-recovery.txt
@@ -78,7 +78,6 @@ struct pci_error_handlers
78{ 78{
79 int (*error_detected)(struct pci_dev *dev, enum pci_channel_state); 79 int (*error_detected)(struct pci_dev *dev, enum pci_channel_state);
80 int (*mmio_enabled)(struct pci_dev *dev); 80 int (*mmio_enabled)(struct pci_dev *dev);
81 int (*link_reset)(struct pci_dev *dev);
82 int (*slot_reset)(struct pci_dev *dev); 81 int (*slot_reset)(struct pci_dev *dev);
83 void (*resume)(struct pci_dev *dev); 82 void (*resume)(struct pci_dev *dev);
84}; 83};
@@ -104,8 +103,7 @@ if it implements any, it must implement error_detected(). If a callback
104is not implemented, the corresponding feature is considered unsupported. 103is not implemented, the corresponding feature is considered unsupported.
105For example, if mmio_enabled() and resume() aren't there, then it 104For example, if mmio_enabled() and resume() aren't there, then it
106is assumed that the driver is not doing any direct recovery and requires 105is assumed that the driver is not doing any direct recovery and requires
107a slot reset. If link_reset() is not implemented, the card is assumed to 106a slot reset. Typically a driver will want to know about
108not care about link resets. Typically a driver will want to know about
109a slot_reset(). 107a slot_reset().
110 108
111The actual steps taken by a platform to recover from a PCI error 109The actual steps taken by a platform to recover from a PCI error
@@ -232,25 +230,9 @@ proceeds to STEP 4 (Slot Reset)
232 230
233STEP 3: Link Reset 231STEP 3: Link Reset
234------------------ 232------------------
235The platform resets the link, and then calls the link_reset() callback 233The platform resets the link. This is a PCI-Express specific step
236on all affected device drivers. This is a PCI-Express specific state
237and is done whenever a non-fatal error has been detected that can be 234and is done whenever a non-fatal error has been detected that can be
238"solved" by resetting the link. This call informs the driver of the 235"solved" by resetting the link.
239reset and the driver should check to see if the device appears to be
240in working condition.
241
242The driver is not supposed to restart normal driver I/O operations
243at this point. It should limit itself to "probing" the device to
244check its recoverability status. If all is right, then the platform
245will call resume() once all drivers have ack'd link_reset().
246
247 Result codes:
248 (identical to STEP 3 (MMIO Enabled)
249
250The platform then proceeds to either STEP 4 (Slot Reset) or STEP 5
251(Resume Operations).
252
253>>> The current powerpc implementation does not implement this callback.
254 236
255STEP 4: Slot Reset 237STEP 4: Slot Reset
256------------------ 238------------------
diff --git a/Documentation/PCI/pci.txt b/Documentation/PCI/pci.txt
index 77f49dc5be23..611a75e4366e 100644
--- a/Documentation/PCI/pci.txt
+++ b/Documentation/PCI/pci.txt
@@ -382,18 +382,18 @@ The fundamental difference between MSI and MSI-X is how multiple
382"vectors" get allocated. MSI requires contiguous blocks of vectors 382"vectors" get allocated. MSI requires contiguous blocks of vectors
383while MSI-X can allocate several individual ones. 383while MSI-X can allocate several individual ones.
384 384
385MSI capability can be enabled by calling pci_enable_msi() or 385MSI capability can be enabled by calling pci_alloc_irq_vectors() with the
386pci_enable_msix() before calling request_irq(). This causes 386PCI_IRQ_MSI and/or PCI_IRQ_MSIX flags before calling request_irq(). This
387the PCI support to program CPU vector data into the PCI device 387causes the PCI support to program CPU vector data into the PCI device
388capability registers. 388capability registers. Many architectures, chip-sets, or BIOSes do NOT
389 389support MSI or MSI-X and a call to pci_alloc_irq_vectors with just
390If your PCI device supports both, try to enable MSI-X first. 390the PCI_IRQ_MSI and PCI_IRQ_MSIX flags will fail, so try to always
391Only one can be enabled at a time. Many architectures, chip-sets, 391specify PCI_IRQ_LEGACY as well.
392or BIOSes do NOT support MSI or MSI-X and the call to pci_enable_msi/msix 392
393will fail. This is important to note since many drivers have 393Drivers that have different interrupt handlers for MSI/MSI-X and
394two (or more) interrupt handlers: one for MSI/MSI-X and another for IRQs. 394legacy INTx should chose the right one based on the msi_enabled
395They choose which handler to register with request_irq() based on the 395and msix_enabled flags in the pci_dev structure after calling
396return value from pci_enable_msi/msix(). 396pci_alloc_irq_vectors.
397 397
398There are (at least) two really good reasons for using MSI: 398There are (at least) two really good reasons for using MSI:
3991) MSI is an exclusive interrupt vector by definition. 3991) MSI is an exclusive interrupt vector by definition.
diff --git a/Documentation/PCI/pcieaer-howto.txt b/Documentation/PCI/pcieaer-howto.txt
index ea8cafba255c..acd0dddd6bb8 100644
--- a/Documentation/PCI/pcieaer-howto.txt
+++ b/Documentation/PCI/pcieaer-howto.txt
@@ -256,7 +256,7 @@ After reboot with new kernel or insert the module, a device file named
256 256
257Then, you need a user space tool named aer-inject, which can be gotten 257Then, you need a user space tool named aer-inject, which can be gotten
258from: 258from:
259 http://www.kernel.org/pub/linux/utils/pci/aer-inject/ 259 https://git.kernel.org/cgit/linux/kernel/git/gong.chen/aer-inject.git/
260 260
261More information about aer-inject can be found in the document comes 261More information about aer-inject can be found in the document comes
262with its source code. 262with its source code.
diff --git a/Documentation/acpi/method-customizing.txt b/Documentation/acpi/method-customizing.txt
index 5f55373dd53b..a3f598e141f2 100644
--- a/Documentation/acpi/method-customizing.txt
+++ b/Documentation/acpi/method-customizing.txt
@@ -57,7 +57,7 @@ Note: To get the ACPI debug object output (Store (AAAA, Debug)),
573. undo your changes 573. undo your changes
58 The "undo" operation is not supported for a new inserted method 58 The "undo" operation is not supported for a new inserted method
59 right now, i.e. we can not remove a method currently. 59 right now, i.e. we can not remove a method currently.
60 For an overrided method, in order to undo your changes, please 60 For an overridden method, in order to undo your changes, please
61 save a copy of the method original ASL code in step c) section 1, 61 save a copy of the method original ASL code in step c) section 1,
62 and redo step c) ~ g) to override the method with the original one. 62 and redo step c) ~ g) to override the method with the original one.
63 63
diff --git a/Documentation/acpi/method-tracing.txt b/Documentation/acpi/method-tracing.txt
index c2505eefc878..0aba14c8f459 100644
--- a/Documentation/acpi/method-tracing.txt
+++ b/Documentation/acpi/method-tracing.txt
@@ -152,7 +152,7 @@ tracing facility.
152 Users can enable/disable this debug tracing feature by executing 152 Users can enable/disable this debug tracing feature by executing
153 the following command: 153 the following command:
154 # echo string > /sys/module/acpi/parameters/trace_state 154 # echo string > /sys/module/acpi/parameters/trace_state
155 Where "string" should be one of the followings: 155 Where "string" should be one of the following:
156 "disable" 156 "disable"
157 Disable the method tracing feature. 157 Disable the method tracing feature.
158 "enable" 158 "enable"
diff --git a/Documentation/admin-guide/README.rst b/Documentation/admin-guide/README.rst
index 1b6dfb2b3adb..697a00ccec25 100644
--- a/Documentation/admin-guide/README.rst
+++ b/Documentation/admin-guide/README.rst
@@ -17,7 +17,7 @@ What is Linux?
17 loading, shared copy-on-write executables, proper memory management, 17 loading, shared copy-on-write executables, proper memory management,
18 and multistack networking including IPv4 and IPv6. 18 and multistack networking including IPv4 and IPv6.
19 19
20 It is distributed under the GNU General Public License - see the 20 It is distributed under the GNU General Public License v2 - see the
21 accompanying COPYING file for more details. 21 accompanying COPYING file for more details.
22 22
23On what hardware does it run? 23On what hardware does it run?
@@ -236,7 +236,7 @@ Configuring the kernel
236 236
237 - Having unnecessary drivers will make the kernel bigger, and can 237 - Having unnecessary drivers will make the kernel bigger, and can
238 under some circumstances lead to problems: probing for a 238 under some circumstances lead to problems: probing for a
239 nonexistent controller card may confuse your other controllers 239 nonexistent controller card may confuse your other controllers.
240 240
241 - A kernel with math-emulation compiled in will still use the 241 - A kernel with math-emulation compiled in will still use the
242 coprocessor if one is present: the math emulation will just 242 coprocessor if one is present: the math emulation will just
diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst
index 88adcfdf5b2b..12278a926370 100644
--- a/Documentation/admin-guide/dynamic-debug-howto.rst
+++ b/Documentation/admin-guide/dynamic-debug-howto.rst
@@ -93,9 +93,9 @@ Command Language Reference
93At the lexical level, a command comprises a sequence of words separated 93At the lexical level, a command comprises a sequence of words separated
94by spaces or tabs. So these are all equivalent:: 94by spaces or tabs. So these are all equivalent::
95 95
96 nullarbor:~ # echo -c 'file svcsock.c line 1603 +p' > 96 nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' >
97 <debugfs>/dynamic_debug/control 97 <debugfs>/dynamic_debug/control
98 nullarbor:~ # echo -c ' file svcsock.c line 1603 +p ' > 98 nullarbor:~ # echo -n ' file svcsock.c line 1603 +p ' >
99 <debugfs>/dynamic_debug/control 99 <debugfs>/dynamic_debug/control
100 nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' > 100 nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' >
101 <debugfs>/dynamic_debug/control 101 <debugfs>/dynamic_debug/control
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 14ffef04113c..0464a41cbf3b 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -653,6 +653,9 @@
653 cpuidle.off=1 [CPU_IDLE] 653 cpuidle.off=1 [CPU_IDLE]
654 disable the cpuidle sub-system 654 disable the cpuidle sub-system
655 655
656 cpufreq.off=1 [CPU_FREQ]
657 disable the cpufreq sub-system
658
656 cpu_init_udelay=N 659 cpu_init_udelay=N
657 [X86] Delay for N microsec between assert and de-assert 660 [X86] Delay for N microsec between assert and de-assert
658 of APIC INIT to start processors. This delay occurs 661 of APIC INIT to start processors. This delay occurs
@@ -957,6 +960,12 @@
957 serial port must already be setup and configured. 960 serial port must already be setup and configured.
958 Options are not yet supported. 961 Options are not yet supported.
959 962
963 lantiq,<addr>
964 Start an early, polled-mode console on a lantiq serial
965 (lqasc) port at the specified address. The serial port
966 must already be setup and configured. Options are not
967 yet supported.
968
960 lpuart,<addr> 969 lpuart,<addr>
961 lpuart32,<addr> 970 lpuart32,<addr>
962 Use early console provided by Freescale LP UART driver 971 Use early console provided by Freescale LP UART driver
@@ -970,9 +979,10 @@
970 address. The serial port must already be setup 979 address. The serial port must already be setup
971 and configured. Options are not yet supported. 980 and configured. Options are not yet supported.
972 981
973 earlyprintk= [X86,SH,BLACKFIN,ARM,M68k] 982 earlyprintk= [X86,SH,BLACKFIN,ARM,M68k,S390]
974 earlyprintk=vga 983 earlyprintk=vga
975 earlyprintk=efi 984 earlyprintk=efi
985 earlyprintk=sclp
976 earlyprintk=xen 986 earlyprintk=xen
977 earlyprintk=serial[,ttySn[,baudrate]] 987 earlyprintk=serial[,ttySn[,baudrate]]
978 earlyprintk=serial[,0x...[,baudrate]] 988 earlyprintk=serial[,0x...[,baudrate]]
@@ -1007,6 +1017,8 @@
1007 1017
1008 The xen output can only be used by Xen PV guests. 1018 The xen output can only be used by Xen PV guests.
1009 1019
1020 The sclp output can only be used on s390.
1021
1010 edac_report= [HW,EDAC] Control how to report EDAC event 1022 edac_report= [HW,EDAC] Control how to report EDAC event
1011 Format: {"on" | "off" | "force"} 1023 Format: {"on" | "off" | "force"}
1012 on: enable EDAC to report H/W event. May be overridden 1024 on: enable EDAC to report H/W event. May be overridden
@@ -1174,6 +1186,12 @@
1174 functions that can be changed at run time by the 1186 functions that can be changed at run time by the
1175 set_graph_notrace file in the debugfs tracing directory. 1187 set_graph_notrace file in the debugfs tracing directory.
1176 1188
1189 ftrace_graph_max_depth=<uint>
1190 [FTRACE] Used with the function graph tracer. This is
1191 the max depth it will trace into a function. This value
1192 can be changed at run time by the max_graph_depth file
1193 in the tracefs tracing directory. default: 0 (no limit)
1194
1177 gamecon.map[2|3]= 1195 gamecon.map[2|3]=
1178 [HW,JOY] Multisystem joystick and NES/SNES/PSX pad 1196 [HW,JOY] Multisystem joystick and NES/SNES/PSX pad
1179 support via parallel port (up to 5 devices per port) 1197 support via parallel port (up to 5 devices per port)
@@ -1192,6 +1210,10 @@
1192 When zero, profiling data is discarded and associated 1210 When zero, profiling data is discarded and associated
1193 debugfs files are removed at module unload time. 1211 debugfs files are removed at module unload time.
1194 1212
1213 goldfish [X86] Enable the goldfish android emulator platform.
1214 Don't use this when you are not running on the
1215 android emulator
1216
1195 gpt [EFI] Forces disk with valid GPT signature but 1217 gpt [EFI] Forces disk with valid GPT signature but
1196 invalid Protective MBR to be treated as GPT. If the 1218 invalid Protective MBR to be treated as GPT. If the
1197 primary GPT is corrupted, it enables the backup/alternate 1219 primary GPT is corrupted, it enables the backup/alternate
@@ -3681,6 +3703,14 @@
3681 last alloc / free. For more information see 3703 last alloc / free. For more information see
3682 Documentation/vm/slub.txt. 3704 Documentation/vm/slub.txt.
3683 3705
3706 slub_memcg_sysfs= [MM, SLUB]
3707 Determines whether to enable sysfs directories for
3708 memory cgroup sub-caches. 1 to enable, 0 to disable.
3709 The default is determined by CONFIG_SLUB_MEMCG_SYSFS_ON.
3710 Enabling this can lead to a very high number of debug
3711 directories and files being created under
3712 /sys/kernel/slub.
3713
3684 slub_max_order= [MM, SLUB] 3714 slub_max_order= [MM, SLUB]
3685 Determines the maximum allowed order for slabs. 3715 Determines the maximum allowed order for slabs.
3686 A high setting may cause OOMs due to memory 3716 A high setting may cause OOMs due to memory
diff --git a/Documentation/admin-guide/md.rst b/Documentation/admin-guide/md.rst
index e449fb5f277c..1e61bf50595c 100644
--- a/Documentation/admin-guide/md.rst
+++ b/Documentation/admin-guide/md.rst
@@ -725,3 +725,8 @@ These currently include:
725 to 1. Setting this to 0 disables bypass accounting and 725 to 1. Setting this to 0 disables bypass accounting and
726 requires preread stripes to wait until all full-width stripe- 726 requires preread stripes to wait until all full-width stripe-
727 writes are complete. Valid values are 0 to stripe_cache_size. 727 writes are complete. Valid values are 0 to stripe_cache_size.
728
729 journal_mode (currently raid5 only)
730 The cache mode for raid5. raid5 could include an extra disk for
731 caching. The mode can be "write-throuth" and "write-back". The
732 default is "write-through".
diff --git a/Documentation/admin-guide/ras.rst b/Documentation/admin-guide/ras.rst
index 9939348bd4a3..1b90c6f00a92 100644
--- a/Documentation/admin-guide/ras.rst
+++ b/Documentation/admin-guide/ras.rst
@@ -81,7 +81,7 @@ That defines some categories of errors:
81 still run, eventually replacing the affected hardware by a hot spare, 81 still run, eventually replacing the affected hardware by a hot spare,
82 if available. 82 if available.
83 83
84 Also, when an error happens on an userspace process, it is also possible to 84 Also, when an error happens on a userspace process, it is also possible to
85 kill such process and let userspace restart it. 85 kill such process and let userspace restart it.
86 86
87The mechanism for handling non-fatal errors is usually complex and may 87The mechanism for handling non-fatal errors is usually complex and may
diff --git a/Documentation/arm/sunxi/README b/Documentation/arm/sunxi/README
index cd0243302bc1..d7b1f016bd62 100644
--- a/Documentation/arm/sunxi/README
+++ b/Documentation/arm/sunxi/README
@@ -63,10 +63,18 @@ SunXi family
63 + User Manual 63 + User Manual
64 http://dl.linux-sunxi.org/A33/A33%20user%20manual%20release%201.1.pdf 64 http://dl.linux-sunxi.org/A33/A33%20user%20manual%20release%201.1.pdf
65 65
66 - Allwinner H2+ (sun8i)
67 + No document available now, but is known to be working properly with
68 H3 drivers and memory map.
69
66 - Allwinner H3 (sun8i) 70 - Allwinner H3 (sun8i)
67 + Datasheet 71 + Datasheet
68 http://dl.linux-sunxi.org/H3/Allwinner_H3_Datasheet_V1.0.pdf 72 http://dl.linux-sunxi.org/H3/Allwinner_H3_Datasheet_V1.0.pdf
69 73
74 - Allwinner V3s (sun8i)
75 + Datasheet
76 http://linux-sunxi.org/File:Allwinner_V3s_Datasheet_V1.0.pdf
77
70 * Quad ARM Cortex-A15, Quad ARM Cortex-A7 based SoCs 78 * Quad ARM Cortex-A15, Quad ARM Cortex-A7 based SoCs
71 - Allwinner A80 79 - Allwinner A80
72 + Datasheet 80 + Datasheet
diff --git a/Documentation/arm64/cpu-feature-registers.txt b/Documentation/arm64/cpu-feature-registers.txt
new file mode 100644
index 000000000000..61ca21ebef1a
--- /dev/null
+++ b/Documentation/arm64/cpu-feature-registers.txt
@@ -0,0 +1,240 @@
1 ARM64 CPU Feature Registers
2 ===========================
3
4Author: Suzuki K Poulose <suzuki.poulose@arm.com>
5
6
7This file describes the ABI for exporting the AArch64 CPU ID/feature
8registers to userspace. The availability of this ABI is advertised
9via the HWCAP_CPUID in HWCAPs.
10
111. Motivation
12---------------
13
14The ARM architecture defines a set of feature registers, which describe
15the capabilities of the CPU/system. Access to these system registers is
16restricted from EL0 and there is no reliable way for an application to
17extract this information to make better decisions at runtime. There is
18limited information available to the application via HWCAPs, however
19there are some issues with their usage.
20
21 a) Any change to the HWCAPs requires an update to userspace (e.g libc)
22 to detect the new changes, which can take a long time to appear in
23 distributions. Exposing the registers allows applications to get the
24 information without requiring updates to the toolchains.
25
26 b) Access to HWCAPs is sometimes limited (e.g prior to libc, or
27 when ld is initialised at startup time).
28
29 c) HWCAPs cannot represent non-boolean information effectively. The
30 architecture defines a canonical format for representing features
31 in the ID registers; this is well defined and is capable of
32 representing all valid architecture variations.
33
34
352. Requirements
36-----------------
37
38 a) Safety :
39 Applications should be able to use the information provided by the
40 infrastructure to run safely across the system. This has greater
41 implications on a system with heterogeneous CPUs.
42 The infrastructure exports a value that is safe across all the
43 available CPU on the system.
44
45 e.g, If at least one CPU doesn't implement CRC32 instructions, while
46 others do, we should report that the CRC32 is not implemented.
47 Otherwise an application could crash when scheduled on the CPU
48 which doesn't support CRC32.
49
50 b) Security :
51 Applications should only be able to receive information that is
52 relevant to the normal operation in userspace. Hence, some of the
53 fields are masked out(i.e, made invisible) and their values are set to
54 indicate the feature is 'not supported'. See Section 4 for the list
55 of visible features. Also, the kernel may manipulate the fields
56 based on what it supports. e.g, If FP is not supported by the
57 kernel, the values could indicate that the FP is not available
58 (even when the CPU provides it).
59
60 c) Implementation Defined Features
61 The infrastructure doesn't expose any register which is
62 IMPLEMENTATION DEFINED as per ARMv8-A Architecture.
63
64 d) CPU Identification :
65 MIDR_EL1 is exposed to help identify the processor. On a
66 heterogeneous system, this could be racy (just like getcpu()). The
67 process could be migrated to another CPU by the time it uses the
68 register value, unless the CPU affinity is set. Hence, there is no
69 guarantee that the value reflects the processor that it is
70 currently executing on. The REVIDR is not exposed due to this
71 constraint, as REVIDR makes sense only in conjunction with the
72 MIDR. Alternately, MIDR_EL1 and REVIDR_EL1 are exposed via sysfs
73 at:
74
75 /sys/devices/system/cpu/cpu$ID/regs/identification/
76 \- midr
77 \- revidr
78
793. Implementation
80--------------------
81
82The infrastructure is built on the emulation of the 'MRS' instruction.
83Accessing a restricted system register from an application generates an
84exception and ends up in SIGILL being delivered to the process.
85The infrastructure hooks into the exception handler and emulates the
86operation if the source belongs to the supported system register space.
87
88The infrastructure emulates only the following system register space:
89 Op0=3, Op1=0, CRn=0, CRm=0,4,5,6,7
90
91(See Table C5-6 'System instruction encodings for non-Debug System
92register accesses' in ARMv8 ARM DDI 0487A.h, for the list of
93registers).
94
95The following rules are applied to the value returned by the
96infrastructure:
97
98 a) The value of an 'IMPLEMENTATION DEFINED' field is set to 0.
99 b) The value of a reserved field is populated with the reserved
100 value as defined by the architecture.
101 c) The value of a 'visible' field holds the system wide safe value
102 for the particular feature (except for MIDR_EL1, see section 4).
103 d) All other fields (i.e, invisible fields) are set to indicate
104 the feature is missing (as defined by the architecture).
105
1064. List of registers with visible features
107-------------------------------------------
108
109 1) ID_AA64ISAR0_EL1 - Instruction Set Attribute Register 0
110 x--------------------------------------------------x
111 | Name | bits | visible |
112 |--------------------------------------------------|
113 | RES0 | [63-32] | n |
114 |--------------------------------------------------|
115 | RDM | [31-28] | y |
116 |--------------------------------------------------|
117 | ATOMICS | [23-20] | y |
118 |--------------------------------------------------|
119 | CRC32 | [19-16] | y |
120 |--------------------------------------------------|
121 | SHA2 | [15-12] | y |
122 |--------------------------------------------------|
123 | SHA1 | [11-8] | y |
124 |--------------------------------------------------|
125 | AES | [7-4] | y |
126 |--------------------------------------------------|
127 | RES0 | [3-0] | n |
128 x--------------------------------------------------x
129
130
131 2) ID_AA64PFR0_EL1 - Processor Feature Register 0
132 x--------------------------------------------------x
133 | Name | bits | visible |
134 |--------------------------------------------------|
135 | RES0 | [63-28] | n |
136 |--------------------------------------------------|
137 | GIC | [27-24] | n |
138 |--------------------------------------------------|
139 | AdvSIMD | [23-20] | y |
140 |--------------------------------------------------|
141 | FP | [19-16] | y |
142 |--------------------------------------------------|
143 | EL3 | [15-12] | n |
144 |--------------------------------------------------|
145 | EL2 | [11-8] | n |
146 |--------------------------------------------------|
147 | EL1 | [7-4] | n |
148 |--------------------------------------------------|
149 | EL0 | [3-0] | n |
150 x--------------------------------------------------x
151
152
153 3) MIDR_EL1 - Main ID Register
154 x--------------------------------------------------x
155 | Name | bits | visible |
156 |--------------------------------------------------|
157 | Implementer | [31-24] | y |
158 |--------------------------------------------------|
159 | Variant | [23-20] | y |
160 |--------------------------------------------------|
161 | Architecture | [19-16] | y |
162 |--------------------------------------------------|
163 | PartNum | [15-4] | y |
164 |--------------------------------------------------|
165 | Revision | [3-0] | y |
166 x--------------------------------------------------x
167
168 NOTE: The 'visible' fields of MIDR_EL1 will contain the value
169 as available on the CPU where it is fetched and is not a system
170 wide safe value.
171
172Appendix I: Example
173---------------------------
174
175/*
176 * Sample program to demonstrate the MRS emulation ABI.
177 *
178 * Copyright (C) 2015-2016, ARM Ltd
179 *
180 * Author: Suzuki K Poulose <suzuki.poulose@arm.com>
181 *
182 * This program is free software; you can redistribute it and/or modify
183 * it under the terms of the GNU General Public License version 2 as
184 * published by the Free Software Foundation.
185 *
186 * This program is distributed in the hope that it will be useful,
187 * but WITHOUT ANY WARRANTY; without even the implied warranty of
188 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
189 * GNU General Public License for more details.
190 * This program is free software; you can redistribute it and/or modify
191 * it under the terms of the GNU General Public License version 2 as
192 * published by the Free Software Foundation.
193 *
194 * This program is distributed in the hope that it will be useful,
195 * but WITHOUT ANY WARRANTY; without even the implied warranty of
196 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
197 * GNU General Public License for more details.
198 */
199
200#include <asm/hwcap.h>
201#include <stdio.h>
202#include <sys/auxv.h>
203
204#define get_cpu_ftr(id) ({ \
205 unsigned long __val; \
206 asm("mrs %0, "#id : "=r" (__val)); \
207 printf("%-20s: 0x%016lx\n", #id, __val); \
208 })
209
210int main(void)
211{
212
213 if (!(getauxval(AT_HWCAP) & HWCAP_CPUID)) {
214 fputs("CPUID registers unavailable\n", stderr);
215 return 1;
216 }
217
218 get_cpu_ftr(ID_AA64ISAR0_EL1);
219 get_cpu_ftr(ID_AA64ISAR1_EL1);
220 get_cpu_ftr(ID_AA64MMFR0_EL1);
221 get_cpu_ftr(ID_AA64MMFR1_EL1);
222 get_cpu_ftr(ID_AA64PFR0_EL1);
223 get_cpu_ftr(ID_AA64PFR1_EL1);
224 get_cpu_ftr(ID_AA64DFR0_EL1);
225 get_cpu_ftr(ID_AA64DFR1_EL1);
226
227 get_cpu_ftr(MIDR_EL1);
228 get_cpu_ftr(MPIDR_EL1);
229 get_cpu_ftr(REVIDR_EL1);
230
231#if 0
232 /* Unexposed register access causes SIGILL */
233 get_cpu_ftr(ID_MMFR0_EL1);
234#endif
235
236 return 0;
237}
238
239
240
diff --git a/Documentation/arm64/silicon-errata.txt b/Documentation/arm64/silicon-errata.txt
index 405da11fc3e4..2f66683500b8 100644
--- a/Documentation/arm64/silicon-errata.txt
+++ b/Documentation/arm64/silicon-errata.txt
@@ -42,24 +42,30 @@ file acts as a registry of software workarounds in the Linux Kernel and
42will be updated when new workarounds are committed and backported to 42will be updated when new workarounds are committed and backported to
43stable kernels. 43stable kernels.
44 44
45| Implementor | Component | Erratum ID | Kconfig | 45| Implementor | Component | Erratum ID | Kconfig |
46+----------------+-----------------+-----------------+-------------------------+ 46+----------------+-----------------+-----------------+-----------------------------+
47| ARM | Cortex-A53 | #826319 | ARM64_ERRATUM_826319 | 47| ARM | Cortex-A53 | #826319 | ARM64_ERRATUM_826319 |
48| ARM | Cortex-A53 | #827319 | ARM64_ERRATUM_827319 | 48| ARM | Cortex-A53 | #827319 | ARM64_ERRATUM_827319 |
49| ARM | Cortex-A53 | #824069 | ARM64_ERRATUM_824069 | 49| ARM | Cortex-A53 | #824069 | ARM64_ERRATUM_824069 |
50| ARM | Cortex-A53 | #819472 | ARM64_ERRATUM_819472 | 50| ARM | Cortex-A53 | #819472 | ARM64_ERRATUM_819472 |
51| ARM | Cortex-A53 | #845719 | ARM64_ERRATUM_845719 | 51| ARM | Cortex-A53 | #845719 | ARM64_ERRATUM_845719 |
52| ARM | Cortex-A53 | #843419 | ARM64_ERRATUM_843419 | 52| ARM | Cortex-A53 | #843419 | ARM64_ERRATUM_843419 |
53| ARM | Cortex-A57 | #832075 | ARM64_ERRATUM_832075 | 53| ARM | Cortex-A57 | #832075 | ARM64_ERRATUM_832075 |
54| ARM | Cortex-A57 | #852523 | N/A | 54| ARM | Cortex-A57 | #852523 | N/A |
55| ARM | Cortex-A57 | #834220 | ARM64_ERRATUM_834220 | 55| ARM | Cortex-A57 | #834220 | ARM64_ERRATUM_834220 |
56| ARM | Cortex-A72 | #853709 | N/A | 56| ARM | Cortex-A72 | #853709 | N/A |
57| ARM | MMU-500 | #841119,#826419 | N/A | 57| ARM | MMU-500 | #841119,#826419 | N/A |
58| | | | | 58| | | | |
59| Cavium | ThunderX ITS | #22375, #24313 | CAVIUM_ERRATUM_22375 | 59| Cavium | ThunderX ITS | #22375, #24313 | CAVIUM_ERRATUM_22375 |
60| Cavium | ThunderX ITS | #23144 | CAVIUM_ERRATUM_23144 | 60| Cavium | ThunderX ITS | #23144 | CAVIUM_ERRATUM_23144 |
61| Cavium | ThunderX GICv3 | #23154 | CAVIUM_ERRATUM_23154 | 61| Cavium | ThunderX GICv3 | #23154 | CAVIUM_ERRATUM_23154 |
62| Cavium | ThunderX Core | #27456 | CAVIUM_ERRATUM_27456 | 62| Cavium | ThunderX Core | #27456 | CAVIUM_ERRATUM_27456 |
63| Cavium | ThunderX SMMUv2 | #27704 | N/A | 63| Cavium | ThunderX SMMUv2 | #27704 | N/A |
64| | | | | 64| | | | |
65| Freescale/NXP | LS2080A/LS1043A | A-008585 | FSL_ERRATUM_A008585 | 65| Freescale/NXP | LS2080A/LS1043A | A-008585 | FSL_ERRATUM_A008585 |
66| | | | |
67| Hisilicon | Hip0{5,6,7} | #161010101 | HISILICON_ERRATUM_161010101 |
68| | | | |
69| Qualcomm Tech. | Falkor v1 | E1003 | QCOM_FALKOR_ERRATUM_1003 |
70| Qualcomm Tech. | Falkor v1 | E1009 | QCOM_FALKOR_ERRATUM_1009 |
71| Qualcomm Tech. | QDF2400 ITS | E0065 | QCOM_QDF2400_ERRATUM_0065 |
diff --git a/Documentation/block/pr.txt b/Documentation/block/pr.txt
index d3eb1ca65051..ac9b8e70e64b 100644
--- a/Documentation/block/pr.txt
+++ b/Documentation/block/pr.txt
@@ -90,7 +90,7 @@ and thus removes any access restriction implied by it.
904. IOC_PR_PREEMPT 904. IOC_PR_PREEMPT
91 91
92This ioctl command releases the existing reservation referred to by 92This ioctl command releases the existing reservation referred to by
93old_key and replaces it with a a new reservation of type for the 93old_key and replaces it with a new reservation of type for the
94reservation key new_key. 94reservation key new_key.
95 95
96 96
diff --git a/Documentation/blockdev/mflash.txt b/Documentation/blockdev/mflash.txt
index 1f610ecf698a..f7e050551487 100644
--- a/Documentation/blockdev/mflash.txt
+++ b/Documentation/blockdev/mflash.txt
@@ -17,7 +17,7 @@ driver and currently works well under standard IDE subsystem. Actually it's
17one chip SSD. IO mode is ATA-like custom mode for the host that doesn't have 17one chip SSD. IO mode is ATA-like custom mode for the host that doesn't have
18IDE interface. 18IDE interface.
19 19
20Followings are brief descriptions about IO mode. 20Following are brief descriptions about IO mode.
21A. IO mode based on ATA protocol and uses some custom command. (read confirm, 21A. IO mode based on ATA protocol and uses some custom command. (read confirm,
22write confirm) 22write confirm)
23B. IO mode uses SRAM bus interface. 23B. IO mode uses SRAM bus interface.
diff --git a/Documentation/blockdev/zram.txt b/Documentation/blockdev/zram.txt
index 0535ae1f73e5..4fced8a21307 100644
--- a/Documentation/blockdev/zram.txt
+++ b/Documentation/blockdev/zram.txt
@@ -161,42 +161,14 @@ Name access description
161disksize RW show and set the device's disk size 161disksize RW show and set the device's disk size
162initstate RO shows the initialization state of the device 162initstate RO shows the initialization state of the device
163reset WO trigger device reset 163reset WO trigger device reset
164num_reads RO the number of reads 164mem_used_max WO reset the `mem_used_max' counter (see later)
165failed_reads RO the number of failed reads 165mem_limit WO specifies the maximum amount of memory ZRAM can use
166num_write RO the number of writes 166 to store the compressed data
167failed_writes RO the number of failed writes
168invalid_io RO the number of non-page-size-aligned I/O requests
169max_comp_streams RW the number of possible concurrent compress operations 167max_comp_streams RW the number of possible concurrent compress operations
170comp_algorithm RW show and change the compression algorithm 168comp_algorithm RW show and change the compression algorithm
171notify_free RO the number of notifications to free pages (either
172 slot free notifications or REQ_DISCARD requests)
173zero_pages RO the number of zero filled pages written to this disk
174orig_data_size RO uncompressed size of data stored in this disk
175compr_data_size RO compressed size of data stored in this disk
176mem_used_total RO the amount of memory allocated for this disk
177mem_used_max RW the maximum amount of memory zram have consumed to
178 store the data (to reset this counter to the actual
179 current value, write 1 to this attribute)
180mem_limit RW the maximum amount of memory ZRAM can use to store
181 the compressed data
182pages_compacted RO the number of pages freed during compaction
183 (available only via zram<id>/mm_stat node)
184compact WO trigger memory compaction 169compact WO trigger memory compaction
185debug_stat RO this file is used for zram debugging purposes 170debug_stat RO this file is used for zram debugging purposes
186 171
187WARNING
188=======
189per-stat sysfs attributes are considered to be deprecated.
190The basic strategy is:
191-- the existing RW nodes will be downgraded to WO nodes (in linux 4.11)
192-- deprecated RO sysfs nodes will eventually be removed (in linux 4.11)
193
194The list of deprecated attributes can be found here:
195Documentation/ABI/obsolete/sysfs-block-zram
196
197Basically, every attribute that has its own read accessible sysfs node
198(e.g. num_reads) *AND* is accessible via one of the stat files (zram<id>/stat
199or zram<id>/io_stat or zram<id>/mm_stat) is considered to be deprecated.
200 172
201User space is advised to use the following files to read the device statistics. 173User space is advised to use the following files to read the device statistics.
202 174
@@ -211,22 +183,40 @@ The stat file represents device's I/O statistics not accounted by block
211layer and, thus, not available in zram<id>/stat file. It consists of a 183layer and, thus, not available in zram<id>/stat file. It consists of a
212single line of text and contains the following stats separated by 184single line of text and contains the following stats separated by
213whitespace: 185whitespace:
214 failed_reads 186 failed_reads the number of failed reads
215 failed_writes 187 failed_writes the number of failed writes
216 invalid_io 188 invalid_io the number of non-page-size-aligned I/O requests
217 notify_free 189 notify_free Depending on device usage scenario it may account
190 a) the number of pages freed because of swap slot free
191 notifications or b) the number of pages freed because of
192 REQ_DISCARD requests sent by bio. The former ones are
193 sent to a swap block device when a swap slot is freed,
194 which implies that this disk is being used as a swap disk.
195 The latter ones are sent by filesystem mounted with
196 discard option, whenever some data blocks are getting
197 discarded.
218 198
219File /sys/block/zram<id>/mm_stat 199File /sys/block/zram<id>/mm_stat
220 200
221The stat file represents device's mm statistics. It consists of a single 201The stat file represents device's mm statistics. It consists of a single
222line of text and contains the following stats separated by whitespace: 202line of text and contains the following stats separated by whitespace:
223 orig_data_size 203 orig_data_size uncompressed size of data stored in this disk.
224 compr_data_size 204 This excludes same-element-filled pages (same_pages) since
225 mem_used_total 205 no memory is allocated for them.
226 mem_limit 206 Unit: bytes
227 mem_used_max 207 compr_data_size compressed size of data stored in this disk
228 zero_pages 208 mem_used_total the amount of memory allocated for this disk. This
229 num_migrated 209 includes allocator fragmentation and metadata overhead,
210 allocated for this disk. So, allocator space efficiency
211 can be calculated using compr_data_size and this statistic.
212 Unit: bytes
213 mem_limit the maximum amount of memory ZRAM can use to store
214 the compressed data
215 mem_used_max the maximum amount of memory zram have consumed to
216 store the data
217 same_pages the number of same element filled pages written to this disk.
218 No memory is allocated for such pages.
219 pages_compacted the number of pages freed during compaction
230 220
2319) Deactivate: 2219) Deactivate:
232 swapoff /dev/zram0 222 swapoff /dev/zram0
diff --git a/Documentation/cgroup-v1/cpusets.txt b/Documentation/cgroup-v1/cpusets.txt
index e5ac5da86682..8402dd6de8df 100644
--- a/Documentation/cgroup-v1/cpusets.txt
+++ b/Documentation/cgroup-v1/cpusets.txt
@@ -615,7 +615,7 @@ to allocate a page of memory for that task.
615 615
616If a cpuset has its 'cpuset.cpus' modified, then each task in that cpuset 616If a cpuset has its 'cpuset.cpus' modified, then each task in that cpuset
617will have its allowed CPU placement changed immediately. Similarly, 617will have its allowed CPU placement changed immediately. Similarly,
618if a task's pid is written to another cpusets 'cpuset.tasks' file, then its 618if a task's pid is written to another cpuset's 'tasks' file, then its
619allowed CPU placement is changed immediately. If such a task had been 619allowed CPU placement is changed immediately. If such a task had been
620bound to some subset of its cpuset using the sched_setaffinity() call, 620bound to some subset of its cpuset using the sched_setaffinity() call,
621the task will be allowed to run on any CPU allowed in its new cpuset, 621the task will be allowed to run on any CPU allowed in its new cpuset,
diff --git a/Documentation/cgroup-v1/rdma.txt b/Documentation/cgroup-v1/rdma.txt
new file mode 100644
index 000000000000..af618171e0eb
--- /dev/null
+++ b/Documentation/cgroup-v1/rdma.txt
@@ -0,0 +1,109 @@
1 RDMA Controller
2 ----------------
3
4Contents
5--------
6
71. Overview
8 1-1. What is RDMA controller?
9 1-2. Why RDMA controller needed?
10 1-3. How is RDMA controller implemented?
112. Usage Examples
12
131. Overview
14
151-1. What is RDMA controller?
16-----------------------------
17
18RDMA controller allows user to limit RDMA/IB specific resources that a given
19set of processes can use. These processes are grouped using RDMA controller.
20
21RDMA controller defines two resources which can be limited for processes of a
22cgroup.
23
241-2. Why RDMA controller needed?
25--------------------------------
26
27Currently user space applications can easily take away all the rdma verb
28specific resources such as AH, CQ, QP, MR etc. Due to which other applications
29in other cgroup or kernel space ULPs may not even get chance to allocate any
30rdma resources. This can leads to service unavailability.
31
32Therefore RDMA controller is needed through which resource consumption
33of processes can be limited. Through this controller different rdma
34resources can be accounted.
35
361-3. How is RDMA controller implemented?
37----------------------------------------
38
39RDMA cgroup allows limit configuration of resources. Rdma cgroup maintains
40resource accounting per cgroup, per device using resource pool structure.
41Each such resource pool is limited up to 64 resources in given resource pool
42by rdma cgroup, which can be extended later if required.
43
44This resource pool object is linked to the cgroup css. Typically there
45are 0 to 4 resource pool instances per cgroup, per device in most use cases.
46But nothing limits to have it more. At present hundreds of RDMA devices per
47single cgroup may not be handled optimally, however there is no
48known use case or requirement for such configuration either.
49
50Since RDMA resources can be allocated from any process and can be freed by any
51of the child processes which shares the address space, rdma resources are
52always owned by the creator cgroup css. This allows process migration from one
53to other cgroup without major complexity of transferring resource ownership;
54because such ownership is not really present due to shared nature of
55rdma resources. Linking resources around css also ensures that cgroups can be
56deleted after processes migrated. This allow progress migration as well with
57active resources, even though that is not a primary use case.
58
59Whenever RDMA resource charging occurs, owner rdma cgroup is returned to
60the caller. Same rdma cgroup should be passed while uncharging the resource.
61This also allows process migrated with active RDMA resource to charge
62to new owner cgroup for new resource. It also allows to uncharge resource of
63a process from previously charged cgroup which is migrated to new cgroup,
64even though that is not a primary use case.
65
66Resource pool object is created in following situations.
67(a) User sets the limit and no previous resource pool exist for the device
68of interest for the cgroup.
69(b) No resource limits were configured, but IB/RDMA stack tries to
70charge the resource. So that it correctly uncharge them when applications are
71running without limits and later on when limits are enforced during uncharging,
72otherwise usage count will drop to negative.
73
74Resource pool is destroyed if all the resource limits are set to max and
75it is the last resource getting deallocated.
76
77User should set all the limit to max value if it intents to remove/unconfigure
78the resource pool for a particular device.
79
80IB stack honors limits enforced by the rdma controller. When application
81query about maximum resource limits of IB device, it returns minimum of
82what is configured by user for a given cgroup and what is supported by
83IB device.
84
85Following resources can be accounted by rdma controller.
86 hca_handle Maximum number of HCA Handles
87 hca_object Maximum number of HCA Objects
88
892. Usage Examples
90-----------------
91
92(a) Configure resource limit:
93echo mlx4_0 hca_handle=2 hca_object=2000 > /sys/fs/cgroup/rdma/1/rdma.max
94echo ocrdma1 hca_handle=3 > /sys/fs/cgroup/rdma/2/rdma.max
95
96(b) Query resource limit:
97cat /sys/fs/cgroup/rdma/2/rdma.max
98#Output:
99mlx4_0 hca_handle=2 hca_object=2000
100ocrdma1 hca_handle=3 hca_object=max
101
102(c) Query current usage:
103cat /sys/fs/cgroup/rdma/2/rdma.current
104#Output:
105mlx4_0 hca_handle=1 hca_object=20
106ocrdma1 hca_handle=1 hca_object=23
107
108(d) Delete resource limit:
109echo echo mlx4_0 hca_handle=max hca_object=max > /sys/fs/cgroup/rdma/1/rdma.max
diff --git a/Documentation/cgroup-v2.txt b/Documentation/cgroup-v2.txt
index 4cc07ce3b8dd..49d7c997fa1e 100644
--- a/Documentation/cgroup-v2.txt
+++ b/Documentation/cgroup-v2.txt
@@ -47,6 +47,12 @@ CONTENTS
47 5-3. IO 47 5-3. IO
48 5-3-1. IO Interface Files 48 5-3-1. IO Interface Files
49 5-3-2. Writeback 49 5-3-2. Writeback
50 5-4. PID
51 5-4-1. PID Interface Files
52 5-5. RDMA
53 5-5-1. RDMA Interface Files
54 5-6. Misc
55 5-6-1. perf_event
506. Namespace 566. Namespace
51 6-1. Basics 57 6-1. Basics
52 6-2. The Root and Views 58 6-2. The Root and Views
@@ -328,14 +334,12 @@ a process with a non-root euid to migrate a target process into a
328cgroup by writing its PID to the "cgroup.procs" file, the following 334cgroup by writing its PID to the "cgroup.procs" file, the following
329conditions must be met. 335conditions must be met.
330 336
331- The writer's euid must match either uid or suid of the target process.
332
333- The writer must have write access to the "cgroup.procs" file. 337- The writer must have write access to the "cgroup.procs" file.
334 338
335- The writer must have write access to the "cgroup.procs" file of the 339- The writer must have write access to the "cgroup.procs" file of the
336 common ancestor of the source and destination cgroups. 340 common ancestor of the source and destination cgroups.
337 341
338The above three constraints ensure that while a delegatee may migrate 342The above two constraints ensure that while a delegatee may migrate
339processes around freely in the delegated sub-hierarchy it can't pull 343processes around freely in the delegated sub-hierarchy it can't pull
340in from or push out to outside the sub-hierarchy. 344in from or push out to outside the sub-hierarchy.
341 345
@@ -350,10 +354,10 @@ all processes under C0 and C1 belong to U0.
350 354
351Let's also say U0 wants to write the PID of a process which is 355Let's also say U0 wants to write the PID of a process which is
352currently in C10 into "C00/cgroup.procs". U0 has write access to the 356currently in C10 into "C00/cgroup.procs". U0 has write access to the
353file and uid match on the process; however, the common ancestor of the 357file; however, the common ancestor of the source cgroup C10 and the
354source cgroup C10 and the destination cgroup C00 is above the points 358destination cgroup C00 is above the points of delegation and U0 would
355of delegation and U0 would not have write access to its "cgroup.procs" 359not have write access to its "cgroup.procs" files and thus the write
356files and thus the write will be denied with -EACCES. 360will be denied with -EACCES.
357 361
358 362
3592-6. Guidelines 3632-6. Guidelines
@@ -1119,6 +1123,92 @@ writeback as follows.
1119 vm.dirty[_background]_ratio. 1123 vm.dirty[_background]_ratio.
1120 1124
1121 1125
11265-4. PID
1127
1128The process number controller is used to allow a cgroup to stop any
1129new tasks from being fork()'d or clone()'d after a specified limit is
1130reached.
1131
1132The number of tasks in a cgroup can be exhausted in ways which other
1133controllers cannot prevent, thus warranting its own controller. For
1134example, a fork bomb is likely to exhaust the number of tasks before
1135hitting memory restrictions.
1136
1137Note that PIDs used in this controller refer to TIDs, process IDs as
1138used by the kernel.
1139
1140
11415-4-1. PID Interface Files
1142
1143 pids.max
1144
1145 A read-write single value file which exists on non-root
1146 cgroups. The default is "max".
1147
1148 Hard limit of number of processes.
1149
1150 pids.current
1151
1152 A read-only single value file which exists on all cgroups.
1153
1154 The number of processes currently in the cgroup and its
1155 descendants.
1156
1157Organisational operations are not blocked by cgroup policies, so it is
1158possible to have pids.current > pids.max. This can be done by either
1159setting the limit to be smaller than pids.current, or attaching enough
1160processes to the cgroup such that pids.current is larger than
1161pids.max. However, it is not possible to violate a cgroup PID policy
1162through fork() or clone(). These will return -EAGAIN if the creation
1163of a new process would cause a cgroup policy to be violated.
1164
1165
11665-5. RDMA
1167
1168The "rdma" controller regulates the distribution and accounting of
1169of RDMA resources.
1170
11715-5-1. RDMA Interface Files
1172
1173 rdma.max
1174 A readwrite nested-keyed file that exists for all the cgroups
1175 except root that describes current configured resource limit
1176 for a RDMA/IB device.
1177
1178 Lines are keyed by device name and are not ordered.
1179 Each line contains space separated resource name and its configured
1180 limit that can be distributed.
1181
1182 The following nested keys are defined.
1183
1184 hca_handle Maximum number of HCA Handles
1185 hca_object Maximum number of HCA Objects
1186
1187 An example for mlx4 and ocrdma device follows.
1188
1189 mlx4_0 hca_handle=2 hca_object=2000
1190 ocrdma1 hca_handle=3 hca_object=max
1191
1192 rdma.current
1193 A read-only file that describes current resource usage.
1194 It exists for all the cgroup except root.
1195
1196 An example for mlx4 and ocrdma device follows.
1197
1198 mlx4_0 hca_handle=1 hca_object=20
1199 ocrdma1 hca_handle=1 hca_object=23
1200
1201
12025-6. Misc
1203
12045-6-1. perf_event
1205
1206perf_event controller, if not mounted on a legacy hierarchy, is
1207automatically enabled on the v2 hierarchy so that perf events can
1208always be filtered by cgroup v2 path. The controller can still be
1209moved to a legacy hierarchy after v2 hierarchy is populated.
1210
1211
11226. Namespace 12126. Namespace
1123 1213
11246-1. Basics 12146-1. Basics
diff --git a/Documentation/conf.py b/Documentation/conf.py
index 1ac958c0333d..7fadb3b83293 100644
--- a/Documentation/conf.py
+++ b/Documentation/conf.py
@@ -58,7 +58,7 @@ master_doc = 'index'
58 58
59# General information about the project. 59# General information about the project.
60project = 'The Linux Kernel' 60project = 'The Linux Kernel'
61copyright = '2016, The kernel development community' 61copyright = 'The kernel development community'
62author = 'The kernel development community' 62author = 'The kernel development community'
63 63
64# The version info for the project you're documenting, acts as replacement for 64# The version info for the project you're documenting, acts as replacement for
@@ -135,7 +135,7 @@ pygments_style = 'sphinx'
135# If true, `todo` and `todoList` produce output, else they produce nothing. 135# If true, `todo` and `todoList` produce output, else they produce nothing.
136todo_include_todos = False 136todo_include_todos = False
137 137
138primary_domain = 'C' 138primary_domain = 'c'
139highlight_language = 'none' 139highlight_language = 'none'
140 140
141# -- Options for HTML output ---------------------------------------------- 141# -- Options for HTML output ----------------------------------------------
diff --git a/Documentation/core-api/cpu_hotplug.rst b/Documentation/core-api/cpu_hotplug.rst
new file mode 100644
index 000000000000..4a50ab7817f7
--- /dev/null
+++ b/Documentation/core-api/cpu_hotplug.rst
@@ -0,0 +1,372 @@
1=========================
2CPU hotplug in the Kernel
3=========================
4
5:Date: December, 2016
6:Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
7 Rusty Russell <rusty@rustcorp.com.au>,
8 Srivatsa Vaddagiri <vatsa@in.ibm.com>,
9 Ashok Raj <ashok.raj@intel.com>,
10 Joel Schopp <jschopp@austin.ibm.com>
11
12Introduction
13============
14
15Modern advances in system architectures have introduced advanced error
16reporting and correction capabilities in processors. There are couple OEMS that
17support NUMA hardware which are hot pluggable as well, where physical node
18insertion and removal require support for CPU hotplug.
19
20Such advances require CPUs available to a kernel to be removed either for
21provisioning reasons, or for RAS purposes to keep an offending CPU off
22system execution path. Hence the need for CPU hotplug support in the
23Linux kernel.
24
25A more novel use of CPU-hotplug support is its use today in suspend resume
26support for SMP. Dual-core and HT support makes even a laptop run SMP kernels
27which didn't support these methods.
28
29
30Command Line Switches
31=====================
32``maxcpus=n``
33 Restrict boot time CPUs to *n*. Say if you have fourV CPUs, using
34 ``maxcpus=2`` will only boot two. You can choose to bring the
35 other CPUs later online.
36
37``nr_cpus=n``
38 Restrict the total amount CPUs the kernel will support. If the number
39 supplied here is lower than the number of physically available CPUs than
40 those CPUs can not be brought online later.
41
42``additional_cpus=n``
43 Use this to limit hotpluggable CPUs. This option sets
44 ``cpu_possible_mask = cpu_present_mask + additional_cpus``
45
46 This option is limited to the IA64 architecture.
47
48``possible_cpus=n``
49 This option sets ``possible_cpus`` bits in ``cpu_possible_mask``.
50
51 This option is limited to the X86 and S390 architecture.
52
53``cede_offline={"off","on"}``
54 Use this option to disable/enable putting offlined processors to an extended
55 ``H_CEDE`` state on supported pseries platforms. If nothing is specified,
56 ``cede_offline`` is set to "on".
57
58 This option is limited to the PowerPC architecture.
59
60``cpu0_hotplug``
61 Allow to shutdown CPU0.
62
63 This option is limited to the X86 architecture.
64
65CPU maps
66========
67
68``cpu_possible_mask``
69 Bitmap of possible CPUs that can ever be available in the
70 system. This is used to allocate some boot time memory for per_cpu variables
71 that aren't designed to grow/shrink as CPUs are made available or removed.
72 Once set during boot time discovery phase, the map is static, i.e no bits
73 are added or removed anytime. Trimming it accurately for your system needs
74 upfront can save some boot time memory.
75
76``cpu_online_mask``
77 Bitmap of all CPUs currently online. Its set in ``__cpu_up()``
78 after a CPU is available for kernel scheduling and ready to receive
79 interrupts from devices. Its cleared when a CPU is brought down using
80 ``__cpu_disable()``, before which all OS services including interrupts are
81 migrated to another target CPU.
82
83``cpu_present_mask``
84 Bitmap of CPUs currently present in the system. Not all
85 of them may be online. When physical hotplug is processed by the relevant
86 subsystem (e.g ACPI) can change and new bit either be added or removed
87 from the map depending on the event is hot-add/hot-remove. There are currently
88 no locking rules as of now. Typical usage is to init topology during boot,
89 at which time hotplug is disabled.
90
91You really don't need to manipulate any of the system CPU maps. They should
92be read-only for most use. When setting up per-cpu resources almost always use
93``cpu_possible_mask`` or ``for_each_possible_cpu()`` to iterate. To macro
94``for_each_cpu()`` can be used to iterate over a custom CPU mask.
95
96Never use anything other than ``cpumask_t`` to represent bitmap of CPUs.
97
98
99Using CPU hotplug
100=================
101The kernel option *CONFIG_HOTPLUG_CPU* needs to be enabled. It is currently
102available on multiple architectures including ARM, MIPS, PowerPC and X86. The
103configuration is done via the sysfs interface: ::
104
105 $ ls -lh /sys/devices/system/cpu
106 total 0
107 drwxr-xr-x 9 root root 0 Dec 21 16:33 cpu0
108 drwxr-xr-x 9 root root 0 Dec 21 16:33 cpu1
109 drwxr-xr-x 9 root root 0 Dec 21 16:33 cpu2
110 drwxr-xr-x 9 root root 0 Dec 21 16:33 cpu3
111 drwxr-xr-x 9 root root 0 Dec 21 16:33 cpu4
112 drwxr-xr-x 9 root root 0 Dec 21 16:33 cpu5
113 drwxr-xr-x 9 root root 0 Dec 21 16:33 cpu6
114 drwxr-xr-x 9 root root 0 Dec 21 16:33 cpu7
115 drwxr-xr-x 2 root root 0 Dec 21 16:33 hotplug
116 -r--r--r-- 1 root root 4.0K Dec 21 16:33 offline
117 -r--r--r-- 1 root root 4.0K Dec 21 16:33 online
118 -r--r--r-- 1 root root 4.0K Dec 21 16:33 possible
119 -r--r--r-- 1 root root 4.0K Dec 21 16:33 present
120
121The files *offline*, *online*, *possible*, *present* represent the CPU masks.
122Each CPU folder contains an *online* file which controls the logical on (1) and
123off (0) state. To logically shutdown CPU4: ::
124
125 $ echo 0 > /sys/devices/system/cpu/cpu4/online
126 smpboot: CPU 4 is now offline
127
128Once the CPU is shutdown, it will be removed from */proc/interrupts*,
129*/proc/cpuinfo* and should also not be shown visible by the *top* command. To
130bring CPU4 back online: ::
131
132 $ echo 1 > /sys/devices/system/cpu/cpu4/online
133 smpboot: Booting Node 0 Processor 4 APIC 0x1
134
135The CPU is usable again. This should work on all CPUs. CPU0 is often special
136and excluded from CPU hotplug. On X86 the kernel option
137*CONFIG_BOOTPARAM_HOTPLUG_CPU0* has to be enabled in order to be able to
138shutdown CPU0. Alternatively the kernel command option *cpu0_hotplug* can be
139used. Some known dependencies of CPU0:
140
141* Resume from hibernate/suspend. Hibernate/suspend will fail if CPU0 is offline.
142* PIC interrupts. CPU0 can't be removed if a PIC interrupt is detected.
143
144Please let Fenghua Yu <fenghua.yu@intel.com> know if you find any dependencies
145on CPU0.
146
147The CPU hotplug coordination
148============================
149
150The offline case
151----------------
152Once a CPU has been logically shutdown the teardown callbacks of registered
153hotplug states will be invoked, starting with ``CPUHP_ONLINE`` and terminating
154at state ``CPUHP_OFFLINE``. This includes:
155
156* If tasks are frozen due to a suspend operation then *cpuhp_tasks_frozen*
157 will be set to true.
158* All processes are migrated away from this outgoing CPU to new CPUs.
159 The new CPU is chosen from each process' current cpuset, which may be
160 a subset of all online CPUs.
161* All interrupts targeted to this CPU are migrated to a new CPU
162* timers are also migrated to a new CPU
163* Once all services are migrated, kernel calls an arch specific routine
164 ``__cpu_disable()`` to perform arch specific cleanup.
165
166Using the hotplug API
167---------------------
168It is possible to receive notifications once a CPU is offline or onlined. This
169might be important to certain drivers which need to perform some kind of setup
170or clean up functions based on the number of available CPUs: ::
171
172 #include <linux/cpuhotplug.h>
173
174 ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "X/Y:online",
175 Y_online, Y_prepare_down);
176
177*X* is the subsystem and *Y* the particular driver. The *Y_online* callback
178will be invoked during registration on all online CPUs. If an error
179occurs during the online callback the *Y_prepare_down* callback will be
180invoked on all CPUs on which the online callback was previously invoked.
181After registration completed, the *Y_online* callback will be invoked
182once a CPU is brought online and *Y_prepare_down* will be invoked when a
183CPU is shutdown. All resources which were previously allocated in
184*Y_online* should be released in *Y_prepare_down*.
185The return value *ret* is negative if an error occurred during the
186registration process. Otherwise a positive value is returned which
187contains the allocated hotplug for dynamically allocated states
188(*CPUHP_AP_ONLINE_DYN*). It will return zero for predefined states.
189
190The callback can be remove by invoking ``cpuhp_remove_state()``. In case of a
191dynamically allocated state (*CPUHP_AP_ONLINE_DYN*) use the returned state.
192During the removal of a hotplug state the teardown callback will be invoked.
193
194Multiple instances
195~~~~~~~~~~~~~~~~~~
196If a driver has multiple instances and each instance needs to perform the
197callback independently then it is likely that a ''multi-state'' should be used.
198First a multi-state state needs to be registered: ::
199
200 ret = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN, "X/Y:online,
201 Y_online, Y_prepare_down);
202 Y_hp_online = ret;
203
204The ``cpuhp_setup_state_multi()`` behaves similar to ``cpuhp_setup_state()``
205except it prepares the callbacks for a multi state and does not invoke
206the callbacks. This is a one time setup.
207Once a new instance is allocated, you need to register this new instance: ::
208
209 ret = cpuhp_state_add_instance(Y_hp_online, &d->node);
210
211This function will add this instance to your previously allocated
212*Y_hp_online* state and invoke the previously registered callback
213(*Y_online*) on all online CPUs. The *node* element is a ``struct
214hlist_node`` member of your per-instance data structure.
215
216On removal of the instance: ::
217 cpuhp_state_remove_instance(Y_hp_online, &d->node)
218
219should be invoked which will invoke the teardown callback on all online
220CPUs.
221
222Manual setup
223~~~~~~~~~~~~
224Usually it is handy to invoke setup and teardown callbacks on registration or
225removal of a state because usually the operation needs to performed once a CPU
226goes online (offline) and during initial setup (shutdown) of the driver. However
227each registration and removal function is also available with a ``_nocalls``
228suffix which does not invoke the provided callbacks if the invocation of the
229callbacks is not desired. During the manual setup (or teardown) the functions
230``get_online_cpus()`` and ``put_online_cpus()`` should be used to inhibit CPU
231hotplug operations.
232
233
234The ordering of the events
235--------------------------
236The hotplug states are defined in ``include/linux/cpuhotplug.h``:
237
238* The states *CPUHP_OFFLINE* … *CPUHP_AP_OFFLINE* are invoked before the
239 CPU is up.
240* The states *CPUHP_AP_OFFLINE* … *CPUHP_AP_ONLINE* are invoked
241 just the after the CPU has been brought up. The interrupts are off and
242 the scheduler is not yet active on this CPU. Starting with *CPUHP_AP_OFFLINE*
243 the callbacks are invoked on the target CPU.
244* The states between *CPUHP_AP_ONLINE_DYN* and *CPUHP_AP_ONLINE_DYN_END* are
245 reserved for the dynamic allocation.
246* The states are invoked in the reverse order on CPU shutdown starting with
247 *CPUHP_ONLINE* and stopping at *CPUHP_OFFLINE*. Here the callbacks are
248 invoked on the CPU that will be shutdown until *CPUHP_AP_OFFLINE*.
249
250A dynamically allocated state via *CPUHP_AP_ONLINE_DYN* is often enough.
251However if an earlier invocation during the bring up or shutdown is required
252then an explicit state should be acquired. An explicit state might also be
253required if the hotplug event requires specific ordering in respect to
254another hotplug event.
255
256Testing of hotplug states
257=========================
258One way to verify whether a custom state is working as expected or not is to
259shutdown a CPU and then put it online again. It is also possible to put the CPU
260to certain state (for instance *CPUHP_AP_ONLINE*) and then go back to
261*CPUHP_ONLINE*. This would simulate an error one state after *CPUHP_AP_ONLINE*
262which would lead to rollback to the online state.
263
264All registered states are enumerated in ``/sys/devices/system/cpu/hotplug/states``: ::
265
266 $ tail /sys/devices/system/cpu/hotplug/states
267 138: mm/vmscan:online
268 139: mm/vmstat:online
269 140: lib/percpu_cnt:online
270 141: acpi/cpu-drv:online
271 142: base/cacheinfo:online
272 143: virtio/net:online
273 144: x86/mce:online
274 145: printk:online
275 168: sched:active
276 169: online
277
278To rollback CPU4 to ``lib/percpu_cnt:online`` and back online just issue: ::
279
280 $ cat /sys/devices/system/cpu/cpu4/hotplug/state
281 169
282 $ echo 140 > /sys/devices/system/cpu/cpu4/hotplug/target
283 $ cat /sys/devices/system/cpu/cpu4/hotplug/state
284 140
285
286It is important to note that the teardown callbac of state 140 have been
287invoked. And now get back online: ::
288
289 $ echo 169 > /sys/devices/system/cpu/cpu4/hotplug/target
290 $ cat /sys/devices/system/cpu/cpu4/hotplug/state
291 169
292
293With trace events enabled, the individual steps are visible, too: ::
294
295 # TASK-PID CPU# TIMESTAMP FUNCTION
296 # | | | | |
297 bash-394 [001] 22.976: cpuhp_enter: cpu: 0004 target: 140 step: 169 (cpuhp_kick_ap_work)
298 cpuhp/4-31 [004] 22.977: cpuhp_enter: cpu: 0004 target: 140 step: 168 (sched_cpu_deactivate)
299 cpuhp/4-31 [004] 22.990: cpuhp_exit: cpu: 0004 state: 168 step: 168 ret: 0
300 cpuhp/4-31 [004] 22.991: cpuhp_enter: cpu: 0004 target: 140 step: 144 (mce_cpu_pre_down)
301 cpuhp/4-31 [004] 22.992: cpuhp_exit: cpu: 0004 state: 144 step: 144 ret: 0
302 cpuhp/4-31 [004] 22.993: cpuhp_multi_enter: cpu: 0004 target: 140 step: 143 (virtnet_cpu_down_prep)
303 cpuhp/4-31 [004] 22.994: cpuhp_exit: cpu: 0004 state: 143 step: 143 ret: 0
304 cpuhp/4-31 [004] 22.995: cpuhp_enter: cpu: 0004 target: 140 step: 142 (cacheinfo_cpu_pre_down)
305 cpuhp/4-31 [004] 22.996: cpuhp_exit: cpu: 0004 state: 142 step: 142 ret: 0
306 bash-394 [001] 22.997: cpuhp_exit: cpu: 0004 state: 140 step: 169 ret: 0
307 bash-394 [005] 95.540: cpuhp_enter: cpu: 0004 target: 169 step: 140 (cpuhp_kick_ap_work)
308 cpuhp/4-31 [004] 95.541: cpuhp_enter: cpu: 0004 target: 169 step: 141 (acpi_soft_cpu_online)
309 cpuhp/4-31 [004] 95.542: cpuhp_exit: cpu: 0004 state: 141 step: 141 ret: 0
310 cpuhp/4-31 [004] 95.543: cpuhp_enter: cpu: 0004 target: 169 step: 142 (cacheinfo_cpu_online)
311 cpuhp/4-31 [004] 95.544: cpuhp_exit: cpu: 0004 state: 142 step: 142 ret: 0
312 cpuhp/4-31 [004] 95.545: cpuhp_multi_enter: cpu: 0004 target: 169 step: 143 (virtnet_cpu_online)
313 cpuhp/4-31 [004] 95.546: cpuhp_exit: cpu: 0004 state: 143 step: 143 ret: 0
314 cpuhp/4-31 [004] 95.547: cpuhp_enter: cpu: 0004 target: 169 step: 144 (mce_cpu_online)
315 cpuhp/4-31 [004] 95.548: cpuhp_exit: cpu: 0004 state: 144 step: 144 ret: 0
316 cpuhp/4-31 [004] 95.549: cpuhp_enter: cpu: 0004 target: 169 step: 145 (console_cpu_notify)
317 cpuhp/4-31 [004] 95.550: cpuhp_exit: cpu: 0004 state: 145 step: 145 ret: 0
318 cpuhp/4-31 [004] 95.551: cpuhp_enter: cpu: 0004 target: 169 step: 168 (sched_cpu_activate)
319 cpuhp/4-31 [004] 95.552: cpuhp_exit: cpu: 0004 state: 168 step: 168 ret: 0
320 bash-394 [005] 95.553: cpuhp_exit: cpu: 0004 state: 169 step: 140 ret: 0
321
322As it an be seen, CPU4 went down until timestamp 22.996 and then back up until
32395.552. All invoked callbacks including their return codes are visible in the
324trace.
325
326Architecture's requirements
327===========================
328The following functions and configurations are required:
329
330``CONFIG_HOTPLUG_CPU``
331 This entry needs to be enabled in Kconfig
332
333``__cpu_up()``
334 Arch interface to bring up a CPU
335
336``__cpu_disable()``
337 Arch interface to shutdown a CPU, no more interrupts can be handled by the
338 kernel after the routine returns. This includes the shutdown of the timer.
339
340``__cpu_die()``
341 This actually supposed to ensure death of the CPU. Actually look at some
342 example code in other arch that implement CPU hotplug. The processor is taken
343 down from the ``idle()`` loop for that specific architecture. ``__cpu_die()``
344 typically waits for some per_cpu state to be set, to ensure the processor dead
345 routine is called to be sure positively.
346
347User Space Notification
348=======================
349After CPU successfully onlined or offline udev events are sent. A udev rule like: ::
350
351 SUBSYSTEM=="cpu", DRIVERS=="processor", DEVPATH=="/devices/system/cpu/*", RUN+="the_hotplug_receiver.sh"
352
353will receive all events. A script like: ::
354
355 #!/bin/sh
356
357 if [ "${ACTION}" = "offline" ]
358 then
359 echo "CPU ${DEVPATH##*/} offline"
360
361 elif [ "${ACTION}" = "online" ]
362 then
363 echo "CPU ${DEVPATH##*/} online"
364
365 fi
366
367can process the event further.
368
369Kernel Inline Documentations Reference
370======================================
371
372.. kernel-doc:: include/linux/cpuhotplug.h
diff --git a/Documentation/core-api/index.rst b/Documentation/core-api/index.rst
index 2872ca1a52f1..0d93d8089136 100644
--- a/Documentation/core-api/index.rst
+++ b/Documentation/core-api/index.rst
@@ -13,6 +13,7 @@ Core utilities
13 13
14 assoc_array 14 assoc_array
15 atomic_ops 15 atomic_ops
16 cpu_hotplug
16 local_ops 17 local_ops
17 workqueue 18 workqueue
18 19
diff --git a/Documentation/cpu-freq/user-guide.txt b/Documentation/cpu-freq/user-guide.txt
index 107f6fdd7d14..391da64e9492 100644
--- a/Documentation/cpu-freq/user-guide.txt
+++ b/Documentation/cpu-freq/user-guide.txt
@@ -82,7 +82,9 @@ UltraSPARC-III
82------- 82-------
83 83
84Several "PowerBook" and "iBook2" notebooks are supported. 84Several "PowerBook" and "iBook2" notebooks are supported.
85 85The following POWER processors are supported in powernv mode:
86POWER8
87POWER9
86 88
871.5 SuperH 891.5 SuperH
88---------- 90----------
diff --git a/Documentation/cpu-hotplug.txt b/Documentation/cpu-hotplug.txt
deleted file mode 100644
index d02e8a451872..000000000000
--- a/Documentation/cpu-hotplug.txt
+++ /dev/null
@@ -1,452 +0,0 @@
1 CPU hotplug Support in Linux(tm) Kernel
2
3 Maintainers:
4 CPU Hotplug Core:
5 Rusty Russell <rusty@rustcorp.com.au>
6 Srivatsa Vaddagiri <vatsa@in.ibm.com>
7 i386:
8 Zwane Mwaikambo <zwanem@gmail.com>
9 ppc64:
10 Nathan Lynch <nathanl@austin.ibm.com>
11 Joel Schopp <jschopp@austin.ibm.com>
12 ia64/x86_64:
13 Ashok Raj <ashok.raj@intel.com>
14 s390:
15 Heiko Carstens <heiko.carstens@de.ibm.com>
16
17Authors: Ashok Raj <ashok.raj@intel.com>
18Lots of feedback: Nathan Lynch <nathanl@austin.ibm.com>,
19 Joel Schopp <jschopp@austin.ibm.com>
20
21Introduction
22
23Modern advances in system architectures have introduced advanced error
24reporting and correction capabilities in processors. CPU architectures permit
25partitioning support, where compute resources of a single CPU could be made
26available to virtual machine environments. There are couple OEMS that
27support NUMA hardware which are hot pluggable as well, where physical
28node insertion and removal require support for CPU hotplug.
29
30Such advances require CPUs available to a kernel to be removed either for
31provisioning reasons, or for RAS purposes to keep an offending CPU off
32system execution path. Hence the need for CPU hotplug support in the
33Linux kernel.
34
35A more novel use of CPU-hotplug support is its use today in suspend
36resume support for SMP. Dual-core and HT support makes even
37a laptop run SMP kernels which didn't support these methods. SMP support
38for suspend/resume is a work in progress.
39
40General Stuff about CPU Hotplug
41--------------------------------
42
43Command Line Switches
44---------------------
45maxcpus=n Restrict boot time cpus to n. Say if you have 4 cpus, using
46 maxcpus=2 will only boot 2. You can choose to bring the
47 other cpus later online, read FAQ's for more info.
48
49additional_cpus=n (*) Use this to limit hotpluggable cpus. This option sets
50 cpu_possible_mask = cpu_present_mask + additional_cpus
51
52cede_offline={"off","on"} Use this option to disable/enable putting offlined
53 processors to an extended H_CEDE state on
54 supported pseries platforms.
55 If nothing is specified,
56 cede_offline is set to "on".
57
58(*) Option valid only for following architectures
59- ia64
60
61ia64 uses the number of disabled local apics in ACPI tables MADT to
62determine the number of potentially hot-pluggable cpus. The implementation
63should only rely on this to count the # of cpus, but *MUST* not rely
64on the apicid values in those tables for disabled apics. In the event
65BIOS doesn't mark such hot-pluggable cpus as disabled entries, one could
66use this parameter "additional_cpus=x" to represent those cpus in the
67cpu_possible_mask.
68
69possible_cpus=n [s390,x86_64] use this to set hotpluggable cpus.
70 This option sets possible_cpus bits in
71 cpu_possible_mask. Thus keeping the numbers of bits set
72 constant even if the machine gets rebooted.
73
74CPU maps and such
75-----------------
76[More on cpumaps and primitive to manipulate, please check
77include/linux/cpumask.h that has more descriptive text.]
78
79cpu_possible_mask: Bitmap of possible CPUs that can ever be available in the
80system. This is used to allocate some boot time memory for per_cpu variables
81that aren't designed to grow/shrink as CPUs are made available or removed.
82Once set during boot time discovery phase, the map is static, i.e no bits
83are added or removed anytime. Trimming it accurately for your system needs
84upfront can save some boot time memory. See below for how we use heuristics
85in x86_64 case to keep this under check.
86
87cpu_online_mask: Bitmap of all CPUs currently online. It's set in __cpu_up()
88after a CPU is available for kernel scheduling and ready to receive
89interrupts from devices. It's cleared when a CPU is brought down using
90__cpu_disable(), before which all OS services including interrupts are
91migrated to another target CPU.
92
93cpu_present_mask: Bitmap of CPUs currently present in the system. Not all
94of them may be online. When physical hotplug is processed by the relevant
95subsystem (e.g ACPI) can change and new bit either be added or removed
96from the map depending on the event is hot-add/hot-remove. There are currently
97no locking rules as of now. Typical usage is to init topology during boot,
98at which time hotplug is disabled.
99
100You really dont need to manipulate any of the system cpu maps. They should
101be read-only for most use. When setting up per-cpu resources almost always use
102cpu_possible_mask/for_each_possible_cpu() to iterate.
103
104Never use anything other than cpumask_t to represent bitmap of CPUs.
105
106 #include <linux/cpumask.h>
107
108 for_each_possible_cpu - Iterate over cpu_possible_mask
109 for_each_online_cpu - Iterate over cpu_online_mask
110 for_each_present_cpu - Iterate over cpu_present_mask
111 for_each_cpu(x,mask) - Iterate over some random collection of cpu mask.
112
113 #include <linux/cpu.h>
114 get_online_cpus() and put_online_cpus():
115
116The above calls are used to inhibit cpu hotplug operations. While the
117cpu_hotplug.refcount is non zero, the cpu_online_mask will not change.
118If you merely need to avoid cpus going away, you could also use
119preempt_disable() and preempt_enable() for those sections.
120Just remember the critical section cannot call any
121function that can sleep or schedule this process away. The preempt_disable()
122will work as long as stop_machine_run() is used to take a cpu down.
123
124CPU Hotplug - Frequently Asked Questions.
125
126Q: How to enable my kernel to support CPU hotplug?
127A: When doing make defconfig, Enable CPU hotplug support
128
129 "Processor type and Features" -> Support for Hotpluggable CPUs
130
131Make sure that you have CONFIG_SMP turned on as well.
132
133You would need to enable CONFIG_HOTPLUG_CPU for SMP suspend/resume support
134as well.
135
136Q: What architectures support CPU hotplug?
137A: As of 2.6.14, the following architectures support CPU hotplug.
138
139i386 (Intel), ppc, ppc64, parisc, s390, ia64 and x86_64
140
141Q: How to test if hotplug is supported on the newly built kernel?
142A: You should now notice an entry in sysfs.
143
144Check if sysfs is mounted, using the "mount" command. You should notice
145an entry as shown below in the output.
146
147 ....
148 none on /sys type sysfs (rw)
149 ....
150
151If this is not mounted, do the following.
152
153 #mkdir /sys
154 #mount -t sysfs sys /sys
155
156Now you should see entries for all present cpu, the following is an example
157in a 8-way system.
158
159 #pwd
160 #/sys/devices/system/cpu
161 #ls -l
162 total 0
163 drwxr-xr-x 10 root root 0 Sep 19 07:44 .
164 drwxr-xr-x 13 root root 0 Sep 19 07:45 ..
165 drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu0
166 drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu1
167 drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu2
168 drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu3
169 drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu4
170 drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu5
171 drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu6
172 drwxr-xr-x 3 root root 0 Sep 19 07:48 cpu7
173
174Under each directory you would find an "online" file which is the control
175file to logically online/offline a processor.
176
177Q: Does hot-add/hot-remove refer to physical add/remove of cpus?
178A: The usage of hot-add/remove may not be very consistently used in the code.
179CONFIG_HOTPLUG_CPU enables logical online/offline capability in the kernel.
180To support physical addition/removal, one would need some BIOS hooks and
181the platform should have something like an attention button in PCI hotplug.
182CONFIG_ACPI_HOTPLUG_CPU enables ACPI support for physical add/remove of CPUs.
183
184Q: How do I logically offline a CPU?
185A: Do the following.
186
187 #echo 0 > /sys/devices/system/cpu/cpuX/online
188
189Once the logical offline is successful, check
190
191 #cat /proc/interrupts
192
193You should now not see the CPU that you removed. Also online file will report
194the state as 0 when a CPU is offline and 1 when it's online.
195
196 #To display the current cpu state.
197 #cat /sys/devices/system/cpu/cpuX/online
198
199Q: Why can't I remove CPU0 on some systems?
200A: Some architectures may have some special dependency on a certain CPU.
201
202For e.g in IA64 platforms we have ability to send platform interrupts to the
203OS. a.k.a Corrected Platform Error Interrupts (CPEI). In current ACPI
204specifications, we didn't have a way to change the target CPU. Hence if the
205current ACPI version doesn't support such re-direction, we disable that CPU
206by making it not-removable.
207
208In such cases you will also notice that the online file is missing under cpu0.
209
210Q: Is CPU0 removable on X86?
211A: Yes. If kernel is compiled with CONFIG_BOOTPARAM_HOTPLUG_CPU0=y, CPU0 is
212removable by default. Otherwise, CPU0 is also removable by kernel option
213cpu0_hotplug.
214
215But some features depend on CPU0. Two known dependencies are:
216
2171. Resume from hibernate/suspend depends on CPU0. Hibernate/suspend will fail if
218CPU0 is offline and you need to online CPU0 before hibernate/suspend can
219continue.
2202. PIC interrupts also depend on CPU0. CPU0 can't be removed if a PIC interrupt
221is detected.
222
223It's said poweroff/reboot may depend on CPU0 on some machines although I haven't
224seen any poweroff/reboot failure so far after CPU0 is offline on a few tested
225machines.
226
227Please let me know if you know or see any other dependencies of CPU0.
228
229If the dependencies are under your control, you can turn on CPU0 hotplug feature
230either by CONFIG_BOOTPARAM_HOTPLUG_CPU0 or by kernel parameter cpu0_hotplug.
231
232--Fenghua Yu <fenghua.yu@intel.com>
233
234Q: How do I find out if a particular CPU is not removable?
235A: Depending on the implementation, some architectures may show this by the
236absence of the "online" file. This is done if it can be determined ahead of
237time that this CPU cannot be removed.
238
239In some situations, this can be a run time check, i.e if you try to remove the
240last CPU, this will not be permitted. You can find such failures by
241investigating the return value of the "echo" command.
242
243Q: What happens when a CPU is being logically offlined?
244A: The following happen, listed in no particular order :-)
245
246- A notification is sent to in-kernel registered modules by sending an event
247 CPU_DOWN_PREPARE or CPU_DOWN_PREPARE_FROZEN, depending on whether or not the
248 CPU is being offlined while tasks are frozen due to a suspend operation in
249 progress
250- All processes are migrated away from this outgoing CPU to new CPUs.
251 The new CPU is chosen from each process' current cpuset, which may be
252 a subset of all online CPUs.
253- All interrupts targeted to this CPU are migrated to a new CPU
254- timers/bottom half/task lets are also migrated to a new CPU
255- Once all services are migrated, kernel calls an arch specific routine
256 __cpu_disable() to perform arch specific cleanup.
257- Once this is successful, an event for successful cleanup is sent by an event
258 CPU_DEAD (or CPU_DEAD_FROZEN if tasks are frozen due to a suspend while the
259 CPU is being offlined).
260
261 "It is expected that each service cleans up when the CPU_DOWN_PREPARE
262 notifier is called, when CPU_DEAD is called it's expected there is nothing
263 running on behalf of this CPU that was offlined"
264
265Q: If I have some kernel code that needs to be aware of CPU arrival and
266 departure, how to i arrange for proper notification?
267A: This is what you would need in your kernel code to receive notifications.
268
269 #include <linux/cpu.h>
270 static int foobar_cpu_callback(struct notifier_block *nfb,
271 unsigned long action, void *hcpu)
272 {
273 unsigned int cpu = (unsigned long)hcpu;
274
275 switch (action) {
276 case CPU_ONLINE:
277 case CPU_ONLINE_FROZEN:
278 foobar_online_action(cpu);
279 break;
280 case CPU_DEAD:
281 case CPU_DEAD_FROZEN:
282 foobar_dead_action(cpu);
283 break;
284 }
285 return NOTIFY_OK;
286 }
287
288 static struct notifier_block foobar_cpu_notifier =
289 {
290 .notifier_call = foobar_cpu_callback,
291 };
292
293You need to call register_cpu_notifier() from your init function.
294Init functions could be of two types:
2951. early init (init function called when only the boot processor is online).
2962. late init (init function called _after_ all the CPUs are online).
297
298For the first case, you should add the following to your init function
299
300 register_cpu_notifier(&foobar_cpu_notifier);
301
302For the second case, you should add the following to your init function
303
304 register_hotcpu_notifier(&foobar_cpu_notifier);
305
306You can fail PREPARE notifiers if something doesn't work to prepare resources.
307This will stop the activity and send a following CANCELED event back.
308
309CPU_DEAD should not be failed, its just a goodness indication, but bad
310things will happen if a notifier in path sent a BAD notify code.
311
312Q: I don't see my action being called for all CPUs already up and running?
313A: Yes, CPU notifiers are called only when new CPUs are on-lined or offlined.
314 If you need to perform some action for each CPU already in the system, then
315 do this:
316
317 for_each_online_cpu(i) {
318 foobar_cpu_callback(&foobar_cpu_notifier, CPU_UP_PREPARE, i);
319 foobar_cpu_callback(&foobar_cpu_notifier, CPU_ONLINE, i);
320 }
321
322 However, if you want to register a hotplug callback, as well as perform
323 some initialization for CPUs that are already online, then do this:
324
325 Version 1: (Correct)
326 ---------
327
328 cpu_notifier_register_begin();
329
330 for_each_online_cpu(i) {
331 foobar_cpu_callback(&foobar_cpu_notifier,
332 CPU_UP_PREPARE, i);
333 foobar_cpu_callback(&foobar_cpu_notifier,
334 CPU_ONLINE, i);
335 }
336
337 /* Note the use of the double underscored version of the API */
338 __register_cpu_notifier(&foobar_cpu_notifier);
339
340 cpu_notifier_register_done();
341
342 Note that the following code is *NOT* the right way to achieve this,
343 because it is prone to an ABBA deadlock between the cpu_add_remove_lock
344 and the cpu_hotplug.lock.
345
346 Version 2: (Wrong!)
347 ---------
348
349 get_online_cpus();
350
351 for_each_online_cpu(i) {
352 foobar_cpu_callback(&foobar_cpu_notifier,
353 CPU_UP_PREPARE, i);
354 foobar_cpu_callback(&foobar_cpu_notifier,
355 CPU_ONLINE, i);
356 }
357
358 register_cpu_notifier(&foobar_cpu_notifier);
359
360 put_online_cpus();
361
362 So always use the first version shown above when you want to register
363 callbacks as well as initialize the already online CPUs.
364
365
366Q: If I would like to develop CPU hotplug support for a new architecture,
367 what do I need at a minimum?
368A: The following are what is required for CPU hotplug infrastructure to work
369 correctly.
370
371 - Make sure you have an entry in Kconfig to enable CONFIG_HOTPLUG_CPU
372 - __cpu_up() - Arch interface to bring up a CPU
373 - __cpu_disable() - Arch interface to shutdown a CPU, no more interrupts
374 can be handled by the kernel after the routine
375 returns. Including local APIC timers etc are
376 shutdown.
377 - __cpu_die() - This actually supposed to ensure death of the CPU.
378 Actually look at some example code in other arch
379 that implement CPU hotplug. The processor is taken
380 down from the idle() loop for that specific
381 architecture. __cpu_die() typically waits for some
382 per_cpu state to be set, to ensure the processor
383 dead routine is called to be sure positively.
384
385Q: I need to ensure that a particular CPU is not removed when there is some
386 work specific to this CPU in progress.
387A: There are two ways. If your code can be run in interrupt context, use
388 smp_call_function_single(), otherwise use work_on_cpu(). Note that
389 work_on_cpu() is slow, and can fail due to out of memory:
390
391 int my_func_on_cpu(int cpu)
392 {
393 int err;
394 get_online_cpus();
395 if (!cpu_online(cpu))
396 err = -EINVAL;
397 else
398#if NEEDS_BLOCKING
399 err = work_on_cpu(cpu, __my_func_on_cpu, NULL);
400#else
401 smp_call_function_single(cpu, __my_func_on_cpu, &err,
402 true);
403#endif
404 put_online_cpus();
405 return err;
406 }
407
408Q: How do we determine how many CPUs are available for hotplug.
409A: There is no clear spec defined way from ACPI that can give us that
410 information today. Based on some input from Natalie of Unisys,
411 that the ACPI MADT (Multiple APIC Description Tables) marks those possible
412 CPUs in a system with disabled status.
413
414 Andi implemented some simple heuristics that count the number of disabled
415 CPUs in MADT as hotpluggable CPUS. In the case there are no disabled CPUS
416 we assume 1/2 the number of CPUs currently present can be hotplugged.
417
418 Caveat: ACPI MADT can only provide 256 entries in systems with only ACPI 2.0c
419 or earlier ACPI version supported, because the apicid field in MADT is only
420 8 bits. From ACPI 3.0, this limitation was removed since the apicid field
421 was extended to 32 bits with x2APIC introduced.
422
423User Space Notification
424
425Hotplug support for devices is common in Linux today. Its being used today to
426support automatic configuration of network, usb and pci devices. A hotplug
427event can be used to invoke an agent script to perform the configuration task.
428
429You can add /etc/hotplug/cpu.agent to handle hotplug notification user space
430scripts.
431
432 #!/bin/bash
433 # $Id: cpu.agent
434 # Kernel hotplug params include:
435 #ACTION=%s [online or offline]
436 #DEVPATH=%s
437 #
438 cd /etc/hotplug
439 . ./hotplug.functions
440
441 case $ACTION in
442 online)
443 echo `date` ":cpu.agent" add cpu >> /tmp/hotplug.txt
444 ;;
445 offline)
446 echo `date` ":cpu.agent" remove cpu >>/tmp/hotplug.txt
447 ;;
448 *)
449 debug_mesg CPU $ACTION event not supported
450 exit 1
451 ;;
452 esac
diff --git a/Documentation/crypto/api-digest.rst b/Documentation/crypto/api-digest.rst
index 07356fa99200..7a1e670d6ce1 100644
--- a/Documentation/crypto/api-digest.rst
+++ b/Documentation/crypto/api-digest.rst
@@ -14,7 +14,7 @@ Asynchronous Message Digest API
14 :doc: Asynchronous Message Digest API 14 :doc: Asynchronous Message Digest API
15 15
16.. kernel-doc:: include/crypto/hash.h 16.. kernel-doc:: include/crypto/hash.h
17 :functions: crypto_alloc_ahash crypto_free_ahash crypto_ahash_init crypto_ahash_digestsize crypto_ahash_reqtfm crypto_ahash_reqsize crypto_ahash_setkey crypto_ahash_finup crypto_ahash_final crypto_ahash_digest crypto_ahash_export crypto_ahash_import 17 :functions: crypto_alloc_ahash crypto_free_ahash crypto_ahash_init crypto_ahash_digestsize crypto_ahash_reqtfm crypto_ahash_reqsize crypto_ahash_statesize crypto_ahash_setkey crypto_ahash_finup crypto_ahash_final crypto_ahash_digest crypto_ahash_export crypto_ahash_import
18 18
19Asynchronous Hash Request Handle 19Asynchronous Hash Request Handle
20-------------------------------- 20--------------------------------
diff --git a/Documentation/crypto/api-skcipher.rst b/Documentation/crypto/api-skcipher.rst
index b20028a361a9..4eec4a93f7e3 100644
--- a/Documentation/crypto/api-skcipher.rst
+++ b/Documentation/crypto/api-skcipher.rst
@@ -59,4 +59,4 @@ Synchronous Block Cipher API - Deprecated
59 :doc: Synchronous Block Cipher API 59 :doc: Synchronous Block Cipher API
60 60
61.. kernel-doc:: include/linux/crypto.h 61.. kernel-doc:: include/linux/crypto.h
62 :functions: crypto_alloc_blkcipher rypto_free_blkcipher crypto_has_blkcipher crypto_blkcipher_name crypto_blkcipher_ivsize crypto_blkcipher_blocksize crypto_blkcipher_setkey crypto_blkcipher_encrypt crypto_blkcipher_encrypt_iv crypto_blkcipher_decrypt crypto_blkcipher_decrypt_iv crypto_blkcipher_set_iv crypto_blkcipher_get_iv 62 :functions: crypto_alloc_blkcipher crypto_free_blkcipher crypto_has_blkcipher crypto_blkcipher_name crypto_blkcipher_ivsize crypto_blkcipher_blocksize crypto_blkcipher_setkey crypto_blkcipher_encrypt crypto_blkcipher_encrypt_iv crypto_blkcipher_decrypt crypto_blkcipher_decrypt_iv crypto_blkcipher_set_iv crypto_blkcipher_get_iv
diff --git a/Documentation/dev-tools/kcov.rst b/Documentation/dev-tools/kcov.rst
index 2c41b713841f..44886c91e112 100644
--- a/Documentation/dev-tools/kcov.rst
+++ b/Documentation/dev-tools/kcov.rst
@@ -10,7 +10,7 @@ Note that kcov does not aim to collect as much coverage as possible. It aims
10to collect more or less stable coverage that is function of syscall inputs. 10to collect more or less stable coverage that is function of syscall inputs.
11To achieve this goal it does not collect coverage in soft/hard interrupts 11To achieve this goal it does not collect coverage in soft/hard interrupts
12and instrumentation of some inherently non-deterministic parts of kernel is 12and instrumentation of some inherently non-deterministic parts of kernel is
13disbled (e.g. scheduler, locking). 13disabled (e.g. scheduler, locking).
14 14
15Usage 15Usage
16----- 16-----
diff --git a/Documentation/dev-tools/sparse.rst b/Documentation/dev-tools/sparse.rst
index 78aa00a604a0..ffdcc97f6f5a 100644
--- a/Documentation/dev-tools/sparse.rst
+++ b/Documentation/dev-tools/sparse.rst
@@ -103,3 +103,9 @@ have already built it.
103 103
104The optional make variable CF can be used to pass arguments to sparse. The 104The optional make variable CF can be used to pass arguments to sparse. The
105build system passes -Wbitwise to sparse automatically. 105build system passes -Wbitwise to sparse automatically.
106
107Checking RCU annotations
108~~~~~~~~~~~~~~~~~~~~~~~~
109
110RCU annotations are not checked by default. To enable RCU annotation
111checks, include -DCONFIG_SPARSE_RCU_POINTER in your CF flags.
diff --git a/Documentation/device-mapper/dm-raid.txt b/Documentation/device-mapper/dm-raid.txt
index 0d199353e477..cd2cb2fc85ea 100644
--- a/Documentation/device-mapper/dm-raid.txt
+++ b/Documentation/device-mapper/dm-raid.txt
@@ -319,7 +319,7 @@ Version History
3191.5.2 'mismatch_cnt' is zero unless [last_]sync_action is "check". 3191.5.2 'mismatch_cnt' is zero unless [last_]sync_action is "check".
3201.6.0 Add discard support (and devices_handle_discard_safely module param). 3201.6.0 Add discard support (and devices_handle_discard_safely module param).
3211.7.0 Add support for MD RAID0 mappings. 3211.7.0 Add support for MD RAID0 mappings.
3221.8.0 Explictely check for compatible flags in the superblock metadata 3221.8.0 Explicitly check for compatible flags in the superblock metadata
323 and reject to start the raid set if any are set by a newer 323 and reject to start the raid set if any are set by a newer
324 target version, thus avoiding data corruption on a raid set 324 target version, thus avoiding data corruption on a raid set
325 with a reshape in progress. 325 with a reshape in progress.
diff --git a/Documentation/devicetree/bindings/arm/amlogic.txt b/Documentation/devicetree/bindings/arm/amlogic.txt
index 9b2b41ab6817..c246cd2730d9 100644
--- a/Documentation/devicetree/bindings/arm/amlogic.txt
+++ b/Documentation/devicetree/bindings/arm/amlogic.txt
@@ -40,6 +40,8 @@ Board compatible values:
40 - "hardkernel,odroid-c2" (Meson gxbb) 40 - "hardkernel,odroid-c2" (Meson gxbb)
41 - "amlogic,p200" (Meson gxbb) 41 - "amlogic,p200" (Meson gxbb)
42 - "amlogic,p201" (Meson gxbb) 42 - "amlogic,p201" (Meson gxbb)
43 - "wetek,hub" (Meson gxbb)
44 - "wetek,play2" (Meson gxbb)
43 - "amlogic,p212" (Meson gxl s905x) 45 - "amlogic,p212" (Meson gxl s905x)
44 - "amlogic,p230" (Meson gxl s905d) 46 - "amlogic,p230" (Meson gxl s905d)
45 - "amlogic,p231" (Meson gxl s905d) 47 - "amlogic,p231" (Meson gxl s905d)
diff --git a/Documentation/devicetree/bindings/arm/axentia.txt b/Documentation/devicetree/bindings/arm/axentia.txt
new file mode 100644
index 000000000000..ea3fb96ae465
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/axentia.txt
@@ -0,0 +1,19 @@
1Device tree bindings for Axentia ARM devices
2============================================
3
4Linea CPU module
5----------------
6
7Required root node properties:
8compatible = "axentia,linea",
9 "atmel,sama5d31", "atmel,sama5d3", "atmel,sama5";
10and following the rules from atmel-at91.txt for a sama5d31 SoC.
11
12
13TSE-850 v3 board
14----------------
15
16Required root node properties:
17compatible = "axentia,tse850v3", "axentia,linea",
18 "atmel,sama5d31", "atmel,sama5d3", "atmel,sama5";
19and following the rules from above for the axentia,linea CPU module.
diff --git a/Documentation/devicetree/bindings/arm/cpus.txt b/Documentation/devicetree/bindings/arm/cpus.txt
index a1bcfeed5f24..698ad1f097fa 100644
--- a/Documentation/devicetree/bindings/arm/cpus.txt
+++ b/Documentation/devicetree/bindings/arm/cpus.txt
@@ -158,6 +158,7 @@ nodes to be present and contain the properties described below.
158 "arm,cortex-a53" 158 "arm,cortex-a53"
159 "arm,cortex-a57" 159 "arm,cortex-a57"
160 "arm,cortex-a72" 160 "arm,cortex-a72"
161 "arm,cortex-a73"
161 "arm,cortex-m0" 162 "arm,cortex-m0"
162 "arm,cortex-m0+" 163 "arm,cortex-m0+"
163 "arm,cortex-m1" 164 "arm,cortex-m1"
@@ -202,6 +203,7 @@ nodes to be present and contain the properties described below.
202 "marvell,armada-380-smp" 203 "marvell,armada-380-smp"
203 "marvell,armada-390-smp" 204 "marvell,armada-390-smp"
204 "marvell,armada-xp-smp" 205 "marvell,armada-xp-smp"
206 "marvell,98dx3236-smp"
205 "mediatek,mt6589-smp" 207 "mediatek,mt6589-smp"
206 "mediatek,mt81xx-tz-smp" 208 "mediatek,mt81xx-tz-smp"
207 "qcom,gcc-msm8660" 209 "qcom,gcc-msm8660"
diff --git a/Documentation/devicetree/bindings/arm/davinci.txt b/Documentation/devicetree/bindings/arm/davinci.txt
index f0841ce725b5..715622c36260 100644
--- a/Documentation/devicetree/bindings/arm/davinci.txt
+++ b/Documentation/devicetree/bindings/arm/davinci.txt
@@ -13,6 +13,10 @@ EnBW AM1808 based CMC board
13Required root node properties: 13Required root node properties:
14 - compatible = "enbw,cmc", "ti,da850; 14 - compatible = "enbw,cmc", "ti,da850;
15 15
16LEGO MINDSTORMS EV3 (AM1808 based)
17Required root node properties:
18 - compatible = "lego,ev3", "ti,da850";
19
16Generic DaVinci Boards 20Generic DaVinci Boards
17---------------------- 21----------------------
18 22
diff --git a/Documentation/devicetree/bindings/arm/fsl.txt b/Documentation/devicetree/bindings/arm/fsl.txt
index d6ee9c6e1dbb..c9c567ae227f 100644
--- a/Documentation/devicetree/bindings/arm/fsl.txt
+++ b/Documentation/devicetree/bindings/arm/fsl.txt
@@ -108,7 +108,7 @@ status.
108 - compatible: Should contain a chip-specific compatible string, 108 - compatible: Should contain a chip-specific compatible string,
109 Chip-specific strings are of the form "fsl,<chip>-scfg", 109 Chip-specific strings are of the form "fsl,<chip>-scfg",
110 The following <chip>s are known to be supported: 110 The following <chip>s are known to be supported:
111 ls1021a, ls1043a, ls1046a, ls2080a. 111 ls1012a, ls1021a, ls1043a, ls1046a, ls2080a.
112 112
113 - reg: should contain base address and length of SCFG memory-mapped registers 113 - reg: should contain base address and length of SCFG memory-mapped registers
114 114
@@ -126,7 +126,7 @@ core start address and release the secondary core from holdoff and startup.
126 - compatible: Should contain a chip-specific compatible string, 126 - compatible: Should contain a chip-specific compatible string,
127 Chip-specific strings are of the form "fsl,<chip>-dcfg", 127 Chip-specific strings are of the form "fsl,<chip>-dcfg",
128 The following <chip>s are known to be supported: 128 The following <chip>s are known to be supported:
129 ls1021a, ls1043a, ls1046a, ls2080a. 129 ls1012a, ls1021a, ls1043a, ls1046a, ls2080a.
130 130
131 - reg : should contain base address and length of DCFG memory-mapped registers 131 - reg : should contain base address and length of DCFG memory-mapped registers
132 132
@@ -139,6 +139,22 @@ Example:
139Freescale ARMv8 based Layerscape SoC family Device Tree Bindings 139Freescale ARMv8 based Layerscape SoC family Device Tree Bindings
140---------------------------------------------------------------- 140----------------------------------------------------------------
141 141
142LS1012A SoC
143Required root node properties:
144 - compatible = "fsl,ls1012a";
145
146LS1012A ARMv8 based RDB Board
147Required root node properties:
148 - compatible = "fsl,ls1012a-rdb", "fsl,ls1012a";
149
150LS1012A ARMv8 based FRDM Board
151Required root node properties:
152 - compatible = "fsl,ls1012a-frdm", "fsl,ls1012a";
153
154LS1012A ARMv8 based QDS Board
155Required root node properties:
156 - compatible = "fsl,ls1012a-qds", "fsl,ls1012a";
157
142LS1043A SoC 158LS1043A SoC
143Required root node properties: 159Required root node properties:
144 - compatible = "fsl,ls1043a"; 160 - compatible = "fsl,ls1043a";
diff --git a/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt b/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
index 7df79a715611..f1c1e21a8110 100644
--- a/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
+++ b/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
@@ -1,5 +1,9 @@
1Hisilicon Platforms Device Tree Bindings 1Hisilicon Platforms Device Tree Bindings
2---------------------------------------------------- 2----------------------------------------------------
3Hi3660 SoC
4Required root node properties:
5 - compatible = "hisilicon,hi3660";
6
3Hi4511 Board 7Hi4511 Board
4Required root node properties: 8Required root node properties:
5 - compatible = "hisilicon,hi3620-hi4511"; 9 - compatible = "hisilicon,hi3620-hi4511";
diff --git a/Documentation/devicetree/bindings/arm/marvell/98dx3236-resume-ctrl.txt b/Documentation/devicetree/bindings/arm/marvell/98dx3236-resume-ctrl.txt
new file mode 100644
index 000000000000..26eb9d3aa630
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/marvell/98dx3236-resume-ctrl.txt
@@ -0,0 +1,16 @@
1Resume Control
2--------------
3Available on Marvell SOCs: 98DX3336 and 98DX4251
4
5Required properties:
6
7- compatible: must be "marvell,98dx3336-resume-ctrl"
8
9- reg: Should contain resume control registers location and length
10
11Example:
12
13resume@20980 {
14 compatible = "marvell,98dx3336-resume-ctrl";
15 reg = <0x20980 0x10>;
16};
diff --git a/Documentation/devicetree/bindings/arm/marvell/98dx3236.txt b/Documentation/devicetree/bindings/arm/marvell/98dx3236.txt
new file mode 100644
index 000000000000..64e8c73fc5ab
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/marvell/98dx3236.txt
@@ -0,0 +1,23 @@
1Marvell 98DX3236, 98DX3336 and 98DX4251 Platforms Device Tree Bindings
2----------------------------------------------------------------------
3
4Boards with a SoC of the Marvell 98DX3236, 98DX3336 and 98DX4251 families
5shall have the following property:
6
7Required root node property:
8
9compatible: must contain "marvell,armadaxp-98dx3236"
10
11In addition, boards using the Marvell 98DX3336 SoC shall have the
12following property:
13
14Required root node property:
15
16compatible: must contain "marvell,armadaxp-98dx3336"
17
18In addition, boards using the Marvell 98DX4251 SoC shall have the
19following property:
20
21Required root node property:
22
23compatible: must contain "marvell,armadaxp-98dx4251"
diff --git a/Documentation/devicetree/bindings/arm/omap/omap.txt b/Documentation/devicetree/bindings/arm/omap/omap.txt
index 05f95c3ed7d4..8219b2c6bb29 100644
--- a/Documentation/devicetree/bindings/arm/omap/omap.txt
+++ b/Documentation/devicetree/bindings/arm/omap/omap.txt
@@ -151,6 +151,9 @@ Boards:
151- AM335X SBC-T335 : single board computer, built around the Sitara AM3352/4 151- AM335X SBC-T335 : single board computer, built around the Sitara AM3352/4
152 compatible = "compulab,sbc-t335", "compulab,cm-t335", "ti,am33xx" 152 compatible = "compulab,sbc-t335", "compulab,cm-t335", "ti,am33xx"
153 153
154- AM335X phyCORE-AM335x: Development kit
155 compatible = "phytec,am335x-pcm-953", "phytec,am335x-phycore-som", "ti,am33xx"
156
154- OMAP5 EVM : Evaluation Module 157- OMAP5 EVM : Evaluation Module
155 compatible = "ti,omap5-evm", "ti,omap5" 158 compatible = "ti,omap5-evm", "ti,omap5"
156 159
diff --git a/Documentation/devicetree/bindings/arm/shmobile.txt b/Documentation/devicetree/bindings/arm/shmobile.txt
index 253bf9b86690..c9502634316d 100644
--- a/Documentation/devicetree/bindings/arm/shmobile.txt
+++ b/Documentation/devicetree/bindings/arm/shmobile.txt
@@ -75,7 +75,7 @@ Boards:
75 compatible = "renesas,rskrza1", "renesas,r7s72100" 75 compatible = "renesas,rskrza1", "renesas,r7s72100"
76 - Salvator-X (RTP0RC7795SIPB0010S) 76 - Salvator-X (RTP0RC7795SIPB0010S)
77 compatible = "renesas,salvator-x", "renesas,r8a7795"; 77 compatible = "renesas,salvator-x", "renesas,r8a7795";
78 - Salvator-X 78 - Salvator-X (RTP0RC7796SIPB0011S)
79 compatible = "renesas,salvator-x", "renesas,r8a7796"; 79 compatible = "renesas,salvator-x", "renesas,r8a7796";
80 - SILK (RTP0RC7794LCB00011S) 80 - SILK (RTP0RC7794LCB00011S)
81 compatible = "renesas,silk", "renesas,r8a7794" 81 compatible = "renesas,silk", "renesas,r8a7794"
diff --git a/Documentation/devicetree/bindings/arm/sunxi.txt b/Documentation/devicetree/bindings/arm/sunxi.txt
index 4d6467cc2aa2..d2c46449b4eb 100644
--- a/Documentation/devicetree/bindings/arm/sunxi.txt
+++ b/Documentation/devicetree/bindings/arm/sunxi.txt
@@ -12,6 +12,7 @@ using one of the following compatible strings:
12 allwinner,sun8i-a23 12 allwinner,sun8i-a23
13 allwinner,sun8i-a33 13 allwinner,sun8i-a33
14 allwinner,sun8i-a83t 14 allwinner,sun8i-a83t
15 allwinner,sun8i-h2-plus
15 allwinner,sun8i-h3 16 allwinner,sun8i-h3
16 allwinner,sun9i-a80 17 allwinner,sun9i-a80
17 allwinner,sun50i-a64 18 allwinner,sun50i-a64
diff --git a/Documentation/devicetree/bindings/ata/ahci-da850.txt b/Documentation/devicetree/bindings/ata/ahci-da850.txt
new file mode 100644
index 000000000000..5f8193417725
--- /dev/null
+++ b/Documentation/devicetree/bindings/ata/ahci-da850.txt
@@ -0,0 +1,18 @@
1Device tree binding for the TI DA850 AHCI SATA Controller
2---------------------------------------------------------
3
4Required properties:
5 - compatible: must be "ti,da850-ahci"
6 - reg: physical base addresses and sizes of the two register regions
7 used by the controller: the register map as defined by the
8 AHCI 1.1 standard and the Power Down Control Register (PWRDN)
9 for enabling/disabling the SATA clock receiver
10 - interrupts: interrupt specifier (refer to the interrupt binding)
11
12Example:
13
14 sata: sata@218000 {
15 compatible = "ti,da850-ahci";
16 reg = <0x218000 0x2000>, <0x22c018 0x4>;
17 interrupts = <67>;
18 };
diff --git a/Documentation/devicetree/bindings/bus/qcom,ebi2.txt b/Documentation/devicetree/bindings/bus/qcom,ebi2.txt
index 920681f552db..5a7d567f6833 100644
--- a/Documentation/devicetree/bindings/bus/qcom,ebi2.txt
+++ b/Documentation/devicetree/bindings/bus/qcom,ebi2.txt
@@ -51,7 +51,7 @@ Required properties:
51- compatible: should be one of: 51- compatible: should be one of:
52 "qcom,msm8660-ebi2" 52 "qcom,msm8660-ebi2"
53 "qcom,apq8060-ebi2" 53 "qcom,apq8060-ebi2"
54- #address-cells: shoule be <2>: the first cell is the chipselect, 54- #address-cells: should be <2>: the first cell is the chipselect,
55 the second cell is the offset inside the memory range 55 the second cell is the offset inside the memory range
56- #size-cells: should be <1> 56- #size-cells: should be <1>
57- ranges: should be set to: 57- ranges: should be set to:
@@ -64,7 +64,7 @@ Required properties:
64- reg: two ranges of registers: EBI2 config and XMEM config areas 64- reg: two ranges of registers: EBI2 config and XMEM config areas
65- reg-names: should be "ebi2", "xmem" 65- reg-names: should be "ebi2", "xmem"
66- clocks: two clocks, EBI_2X and EBI 66- clocks: two clocks, EBI_2X and EBI
67- clock-names: shoule be "ebi2x", "ebi2" 67- clock-names: should be "ebi2x", "ebi2"
68 68
69Optional subnodes: 69Optional subnodes:
70- Nodes inside the EBI2 will be considered device nodes. 70- Nodes inside the EBI2 will be considered device nodes.
@@ -100,7 +100,7 @@ Optional properties arrays for FAST chip selects:
100 assertion, with respect to the cycle where ADV (address valid) is asserted. 100 assertion, with respect to the cycle where ADV (address valid) is asserted.
101 2 means 2 cycles between ADV and OE. Valid values 0, 1, 2 or 3. 101 2 means 2 cycles between ADV and OE. Valid values 0, 1, 2 or 3.
102- qcom,xmem-read-hold-cycles: the length in cycles of the first segment of a 102- qcom,xmem-read-hold-cycles: the length in cycles of the first segment of a
103 read transfer. For a single read trandfer this will be the time from CS 103 read transfer. For a single read transfer this will be the time from CS
104 assertion to OE assertion. Valid values 0 thru 15. 104 assertion to OE assertion. Valid values 0 thru 15.
105 105
106 106
diff --git a/Documentation/devicetree/bindings/clock/brcm,bcm2835-cprman.txt b/Documentation/devicetree/bindings/clock/brcm,bcm2835-cprman.txt
index e56a1df3a9d3..dd906db34b32 100644
--- a/Documentation/devicetree/bindings/clock/brcm,bcm2835-cprman.txt
+++ b/Documentation/devicetree/bindings/clock/brcm,bcm2835-cprman.txt
@@ -16,7 +16,20 @@ Required properties:
16- #clock-cells: Should be <1>. The permitted clock-specifier values can be 16- #clock-cells: Should be <1>. The permitted clock-specifier values can be
17 found in include/dt-bindings/clock/bcm2835.h 17 found in include/dt-bindings/clock/bcm2835.h
18- reg: Specifies base physical address and size of the registers 18- reg: Specifies base physical address and size of the registers
19- clocks: The external oscillator clock phandle 19- clocks: phandles to the parent clocks used as input to the module, in
20 the following order:
21
22 - External oscillator
23 - DSI0 byte clock
24 - DSI0 DDR2 clock
25 - DSI0 DDR clock
26 - DSI1 byte clock
27 - DSI1 DDR2 clock
28 - DSI1 DDR clock
29
30 Only external oscillator is required. The DSI clocks may
31 not be present, in which case their children will be
32 unusable.
20 33
21Example: 34Example:
22 35
diff --git a/Documentation/devicetree/bindings/clock/exynos4415-clock.txt b/Documentation/devicetree/bindings/clock/exynos4415-clock.txt
deleted file mode 100644
index 847d98bae8cf..000000000000
--- a/Documentation/devicetree/bindings/clock/exynos4415-clock.txt
+++ /dev/null
@@ -1,38 +0,0 @@
1* Samsung Exynos4415 Clock Controller
2
3The Exynos4415 clock controller generates and supplies clock to various
4consumer devices within the Exynos4415 SoC.
5
6Required properties:
7
8- compatible: should be one of the following:
9 - "samsung,exynos4415-cmu" - for the main system clocks controller
10 (CMU_LEFTBUS, CMU_RIGHTBUS, CMU_TOP, CMU_CPU clock domains).
11 - "samsung,exynos4415-cmu-dmc" - for the Exynos4415 SoC DRAM Memory
12 Controller (DMC) domain clock controller.
13
14- reg: physical base address of the controller and length of memory mapped
15 region.
16
17- #clock-cells: should be 1.
18
19Each clock is assigned an identifier and client nodes can use this identifier
20to specify the clock which they consume.
21
22All available clocks are defined as preprocessor macros in
23dt-bindings/clock/exynos4415.h header and can be used in device
24tree sources.
25
26Example 1: An example of a clock controller node is listed below.
27
28 cmu: clock-controller@10030000 {
29 compatible = "samsung,exynos4415-cmu";
30 reg = <0x10030000 0x18000>;
31 #clock-cells = <1>;
32 };
33
34 cmu-dmc: clock-controller@105C0000 {
35 compatible = "samsung,exynos4415-cmu-dmc";
36 reg = <0x105C0000 0x3000>;
37 #clock-cells = <1>;
38 };
diff --git a/Documentation/devicetree/bindings/clock/hi3660-clock.txt b/Documentation/devicetree/bindings/clock/hi3660-clock.txt
new file mode 100644
index 000000000000..cc9b86c35758
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/hi3660-clock.txt
@@ -0,0 +1,42 @@
1* Hisilicon Hi3660 Clock Controller
2
3The Hi3660 clock controller generates and supplies clock to various
4controllers within the Hi3660 SoC.
5
6Required Properties:
7
8- compatible: the compatible should be one of the following strings to
9 indicate the clock controller functionality.
10
11 - "hisilicon,hi3660-crgctrl"
12 - "hisilicon,hi3660-pctrl"
13 - "hisilicon,hi3660-pmuctrl"
14 - "hisilicon,hi3660-sctrl"
15 - "hisilicon,hi3660-iomcu"
16
17- reg: physical base address of the controller and length of memory mapped
18 region.
19
20- #clock-cells: should be 1.
21
22Each clock is assigned an identifier and client nodes use this identifier
23to specify the clock which they consume.
24
25All these identifier could be found in <dt-bindings/clock/hi3660-clock.h>.
26
27Examples:
28 crg_ctrl: clock-controller@fff35000 {
29 compatible = "hisilicon,hi3660-crgctrl", "syscon";
30 reg = <0x0 0xfff35000 0x0 0x1000>;
31 #clock-cells = <1>;
32 };
33
34 uart0: serial@fdf02000 {
35 compatible = "arm,pl011", "arm,primecell";
36 reg = <0x0 0xfdf02000 0x0 0x1000>;
37 interrupts = <GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>;
38 clocks = <&crg_ctrl HI3660_CLK_MUX_UART0>,
39 <&crg_ctrl HI3660_PCLK>;
40 clock-names = "uartclk", "apb_pclk";
41 status = "disabled";
42 };
diff --git a/Documentation/devicetree/bindings/clock/idt,versaclock5.txt b/Documentation/devicetree/bindings/clock/idt,versaclock5.txt
new file mode 100644
index 000000000000..87e9c47a89a3
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/idt,versaclock5.txt
@@ -0,0 +1,65 @@
1Binding for IDT VersaClock5 programmable i2c clock generator.
2
3The IDT VersaClock5 are programmable i2c clock generators providing
4from 3 to 12 output clocks.
5
6==I2C device node==
7
8Required properties:
9- compatible: shall be one of "idt,5p49v5923" , "idt,5p49v5933".
10- reg: i2c device address, shall be 0x68 or 0x6a.
11- #clock-cells: from common clock binding; shall be set to 1.
12- clocks: from common clock binding; list of parent clock handles,
13 - 5p49v5923: (required) either or both of XTAL or CLKIN
14 reference clock.
15 - 5p49v5933: (optional) property not present (internal
16 Xtal used) or CLKIN reference
17 clock.
18- clock-names: from common clock binding; clock input names, can be
19 - 5p49v5923: (required) either or both of "xin", "clkin".
20 - 5p49v5933: (optional) property not present or "clkin".
21
22==Mapping between clock specifier and physical pins==
23
24When referencing the provided clock in the DT using phandle and
25clock specifier, the following mapping applies:
26
275P49V5923:
28 0 -- OUT0_SEL_I2CB
29 1 -- OUT1
30 2 -- OUT2
31
325P49V5933:
33 0 -- OUT0_SEL_I2CB
34 1 -- OUT1
35 2 -- OUT4
36
37==Example==
38
39/* 25MHz reference crystal */
40ref25: ref25m {
41 compatible = "fixed-clock";
42 #clock-cells = <0>;
43 clock-frequency = <25000000>;
44};
45
46i2c-master-node {
47
48 /* IDT 5P49V5923 i2c clock generator */
49 vc5: clock-generator@6a {
50 compatible = "idt,5p49v5923";
51 reg = <0x6a>;
52 #clock-cells = <1>;
53
54 /* Connect XIN input to 25MHz reference */
55 clocks = <&ref25m>;
56 clock-names = "xin";
57 };
58};
59
60/* Consumer referencing the 5P49V5923 pin OUT1 */
61consumer {
62 ...
63 clocks = <&vc5 1>;
64 ...
65}
diff --git a/Documentation/devicetree/bindings/clock/mvebu-corediv-clock.txt b/Documentation/devicetree/bindings/clock/mvebu-corediv-clock.txt
index 520562a7dc2a..c7b4e3a6b2c6 100644
--- a/Documentation/devicetree/bindings/clock/mvebu-corediv-clock.txt
+++ b/Documentation/devicetree/bindings/clock/mvebu-corediv-clock.txt
@@ -7,6 +7,7 @@ Required properties:
7- compatible : must be "marvell,armada-370-corediv-clock", 7- compatible : must be "marvell,armada-370-corediv-clock",
8 "marvell,armada-375-corediv-clock", 8 "marvell,armada-375-corediv-clock",
9 "marvell,armada-380-corediv-clock", 9 "marvell,armada-380-corediv-clock",
10 "marvell,mv98dx3236-corediv-clock",
10 11
11- reg : must be the register address of Core Divider control register 12- reg : must be the register address of Core Divider control register
12- #clock-cells : from common clock binding; shall be set to 1 13- #clock-cells : from common clock binding; shall be set to 1
diff --git a/Documentation/devicetree/bindings/clock/mvebu-cpu-clock.txt b/Documentation/devicetree/bindings/clock/mvebu-cpu-clock.txt
index 99c214660bdc..7f28506eaee7 100644
--- a/Documentation/devicetree/bindings/clock/mvebu-cpu-clock.txt
+++ b/Documentation/devicetree/bindings/clock/mvebu-cpu-clock.txt
@@ -3,6 +3,7 @@ Device Tree Clock bindings for cpu clock of Marvell EBU platforms
3Required properties: 3Required properties:
4- compatible : shall be one of the following: 4- compatible : shall be one of the following:
5 "marvell,armada-xp-cpu-clock" - cpu clocks for Armada XP 5 "marvell,armada-xp-cpu-clock" - cpu clocks for Armada XP
6 "marvell,mv98dx3236-cpu-clock" - cpu clocks for 98DX3236 SoC
6- reg : Address and length of the clock complex register set, followed 7- reg : Address and length of the clock complex register set, followed
7 by address and length of the PMU DFS registers 8 by address and length of the PMU DFS registers
8- #clock-cells : should be set to 1. 9- #clock-cells : should be set to 1.
diff --git a/Documentation/devicetree/bindings/clock/mvebu-gated-clock.txt b/Documentation/devicetree/bindings/clock/mvebu-gated-clock.txt
index cb8542d910b3..5142efc8099d 100644
--- a/Documentation/devicetree/bindings/clock/mvebu-gated-clock.txt
+++ b/Documentation/devicetree/bindings/clock/mvebu-gated-clock.txt
@@ -117,7 +117,7 @@ ID Clock Peripheral
11725 tdm Time Division Mplx 11725 tdm Time Division Mplx
11828 xor1 XOR DMA 1 11828 xor1 XOR DMA 1
11929 sata1lnk 11929 sata1lnk
12030 sata1 SATA Host 0 12030 sata1 SATA Host 1
121 121
122The following is a list of provided IDs for Dove: 122The following is a list of provided IDs for Dove:
123ID Clock Peripheral 123ID Clock Peripheral
diff --git a/Documentation/devicetree/bindings/clock/qcom,rpmcc.txt b/Documentation/devicetree/bindings/clock/qcom,rpmcc.txt
index 87d3714b956a..a7235e9e1c97 100644
--- a/Documentation/devicetree/bindings/clock/qcom,rpmcc.txt
+++ b/Documentation/devicetree/bindings/clock/qcom,rpmcc.txt
@@ -11,6 +11,7 @@ Required properties :
11 compatible "qcom,rpmcc" should be also included. 11 compatible "qcom,rpmcc" should be also included.
12 12
13 "qcom,rpmcc-msm8916", "qcom,rpmcc" 13 "qcom,rpmcc-msm8916", "qcom,rpmcc"
14 "qcom,rpmcc-msm8974", "qcom,rpmcc"
14 "qcom,rpmcc-apq8064", "qcom,rpmcc" 15 "qcom,rpmcc-apq8064", "qcom,rpmcc"
15 16
16- #clock-cells : shall contain 1 17- #clock-cells : shall contain 1
diff --git a/Documentation/devicetree/bindings/clock/qoriq-clock.txt b/Documentation/devicetree/bindings/clock/qoriq-clock.txt
index df9cb5ac5f72..aa3526f229a7 100644
--- a/Documentation/devicetree/bindings/clock/qoriq-clock.txt
+++ b/Documentation/devicetree/bindings/clock/qoriq-clock.txt
@@ -31,6 +31,7 @@ Required properties:
31 * "fsl,t4240-clockgen" 31 * "fsl,t4240-clockgen"
32 * "fsl,b4420-clockgen" 32 * "fsl,b4420-clockgen"
33 * "fsl,b4860-clockgen" 33 * "fsl,b4860-clockgen"
34 * "fsl,ls1012a-clockgen"
34 * "fsl,ls1021a-clockgen" 35 * "fsl,ls1021a-clockgen"
35 * "fsl,ls1043a-clockgen" 36 * "fsl,ls1043a-clockgen"
36 * "fsl,ls1046a-clockgen" 37 * "fsl,ls1046a-clockgen"
diff --git a/Documentation/devicetree/bindings/clock/renesas,cpg-mssr.txt b/Documentation/devicetree/bindings/clock/renesas,cpg-mssr.txt
index c46919412953..f4f944d81308 100644
--- a/Documentation/devicetree/bindings/clock/renesas,cpg-mssr.txt
+++ b/Documentation/devicetree/bindings/clock/renesas,cpg-mssr.txt
@@ -42,6 +42,10 @@ Required Properties:
42 Domain bindings in 42 Domain bindings in
43 Documentation/devicetree/bindings/power/power_domain.txt. 43 Documentation/devicetree/bindings/power/power_domain.txt.
44 44
45 - #reset-cells: Must be 1
46 - The single reset specifier cell must be the module number, as defined
47 in the datasheet.
48
45 49
46Examples 50Examples
47-------- 51--------
@@ -55,6 +59,7 @@ Examples
55 clock-names = "extal", "extalr"; 59 clock-names = "extal", "extalr";
56 #clock-cells = <2>; 60 #clock-cells = <2>;
57 #power-domain-cells = <0>; 61 #power-domain-cells = <0>;
62 #reset-cells = <1>;
58 }; 63 };
59 64
60 65
@@ -69,5 +74,6 @@ Examples
69 dmas = <&dmac1 0x13>, <&dmac1 0x12>; 74 dmas = <&dmac1 0x13>, <&dmac1 0x12>;
70 dma-names = "tx", "rx"; 75 dma-names = "tx", "rx";
71 power-domains = <&cpg>; 76 power-domains = <&cpg>;
77 resets = <&cpg 310>;
72 status = "disabled"; 78 status = "disabled";
73 }; 79 };
diff --git a/Documentation/devicetree/bindings/clock/rockchip,rk3328-cru.txt b/Documentation/devicetree/bindings/clock/rockchip,rk3328-cru.txt
new file mode 100644
index 000000000000..e71c675ba5da
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/rockchip,rk3328-cru.txt
@@ -0,0 +1,57 @@
1* Rockchip RK3328 Clock and Reset Unit
2
3The RK3328 clock controller generates and supplies clock to various
4controllers within the SoC and also implements a reset controller for SoC
5peripherals.
6
7Required Properties:
8
9- compatible: should be "rockchip,rk3328-cru"
10- reg: physical base address of the controller and length of memory mapped
11 region.
12- #clock-cells: should be 1.
13- #reset-cells: should be 1.
14
15Optional Properties:
16
17- rockchip,grf: phandle to the syscon managing the "general register files"
18 If missing pll rates are not changeable, due to the missing pll lock status.
19
20Each clock is assigned an identifier and client nodes can use this identifier
21to specify the clock which they consume. All available clocks are defined as
22preprocessor macros in the dt-bindings/clock/rk3328-cru.h headers and can be
23used in device tree sources. Similar macros exist for the reset sources in
24these files.
25
26External clocks:
27
28There are several clocks that are generated outside the SoC. It is expected
29that they are defined using standard clock bindings with following
30clock-output-names:
31 - "xin24m" - crystal input - required,
32 - "clkin_i2s" - external I2S clock - optional,
33 - "gmac_clkin" - external GMAC clock - optional
34 - "phy_50m_out" - output clock of the pll in the mac phy
35
36Example: Clock controller node:
37
38 cru: clock-controller@ff440000 {
39 compatible = "rockchip,rk3328-cru";
40 reg = <0x0 0xff440000 0x0 0x1000>;
41 rockchip,grf = <&grf>;
42
43 #clock-cells = <1>;
44 #reset-cells = <1>;
45 };
46
47Example: UART controller node that consumes the clock generated by the clock
48 controller:
49
50 uart0: serial@ff120000 {
51 compatible = "snps,dw-apb-uart";
52 reg = <0xff120000 0x100>;
53 interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>;
54 reg-shift = <2>;
55 reg-io-width = <4>;
56 clocks = <&cru SCLK_UART0>;
57 };
diff --git a/Documentation/devicetree/bindings/clock/rockchip,rk3399-cru.txt b/Documentation/devicetree/bindings/clock/rockchip,rk3399-cru.txt
index 3888dd33fcbd..3bc56fae90ac 100644
--- a/Documentation/devicetree/bindings/clock/rockchip,rk3399-cru.txt
+++ b/Documentation/devicetree/bindings/clock/rockchip,rk3399-cru.txt
@@ -13,6 +13,12 @@ Required Properties:
13- #clock-cells: should be 1. 13- #clock-cells: should be 1.
14- #reset-cells: should be 1. 14- #reset-cells: should be 1.
15 15
16Optional Properties:
17
18- rockchip,grf: phandle to the syscon managing the "general register files".
19 It is used for GRF muxes, if missing any muxes present in the GRF will not
20 be available.
21
16Each clock is assigned an identifier and client nodes can use this identifier 22Each clock is assigned an identifier and client nodes can use this identifier
17to specify the clock which they consume. All available clocks are defined as 23to specify the clock which they consume. All available clocks are defined as
18preprocessor macros in the dt-bindings/clock/rk3399-cru.h headers and can be 24preprocessor macros in the dt-bindings/clock/rk3399-cru.h headers and can be
diff --git a/Documentation/devicetree/bindings/clock/st,stm32-rcc.txt b/Documentation/devicetree/bindings/clock/st,stm32-rcc.txt
index 0532d815dae3..b240121d2ac9 100644
--- a/Documentation/devicetree/bindings/clock/st,stm32-rcc.txt
+++ b/Documentation/devicetree/bindings/clock/st,stm32-rcc.txt
@@ -10,6 +10,7 @@ Required properties:
10- compatible: Should be: 10- compatible: Should be:
11 "st,stm32f42xx-rcc" 11 "st,stm32f42xx-rcc"
12 "st,stm32f469-rcc" 12 "st,stm32f469-rcc"
13 "st,stm32f746-rcc"
13- reg: should be register base and length as documented in the 14- reg: should be register base and length as documented in the
14 datasheet 15 datasheet
15- #reset-cells: 1, see below 16- #reset-cells: 1, see below
@@ -17,6 +18,9 @@ Required properties:
17 property, containing a phandle to the clock device node, an index selecting 18 property, containing a phandle to the clock device node, an index selecting
18 between gated clocks and other clocks and an index specifying the clock to 19 between gated clocks and other clocks and an index specifying the clock to
19 use. 20 use.
21- clocks: External oscillator clock phandle
22 - high speed external clock signal (HSE)
23 - external I2S clock (I2S_CKIN)
20 24
21Example: 25Example:
22 26
@@ -25,6 +29,7 @@ Example:
25 #clock-cells = <2> 29 #clock-cells = <2>
26 compatible = "st,stm32f42xx-rcc", "st,stm32-rcc"; 30 compatible = "st,stm32f42xx-rcc", "st,stm32-rcc";
27 reg = <0x40023800 0x400>; 31 reg = <0x40023800 0x400>;
32 clocks = <&clk_hse>, <&clk_i2s_ckin>;
28 }; 33 };
29 34
30Specifying gated clocks 35Specifying gated clocks
@@ -66,6 +71,38 @@ The secondary index is bound with the following magic numbers:
66 71
67 0 SYSTICK 72 0 SYSTICK
68 1 FCLK 73 1 FCLK
74 2 CLK_LSI (low-power clock source)
75 3 CLK_LSE (generated from a 32.768 kHz low-speed external
76 crystal or ceramic resonator)
77 4 CLK_HSE_RTC (HSE division factor for RTC clock)
78 5 CLK_RTC (real-time clock)
79 6 PLL_VCO_I2S (vco frequency of I2S pll)
80 7 PLL_VCO_SAI (vco frequency of SAI pll)
81 8 CLK_LCD (LCD-TFT)
82 9 CLK_I2S (I2S clocks)
83 10 CLK_SAI1 (audio clocks)
84 11 CLK_SAI2
85 12 CLK_I2SQ_PDIV (post divisor of pll i2s q divisor)
86 13 CLK_SAIQ_PDIV (post divisor of pll sai q divisor)
87
88 14 CLK_HSI (Internal ocscillator clock)
89 15 CLK_SYSCLK (System Clock)
90 16 CLK_HDMI_CEC (HDMI-CEC clock)
91 17 CLK_SPDIF (SPDIF-Rx clock)
92 18 CLK_USART1 (U(s)arts clocks)
93 19 CLK_USART2
94 20 CLK_USART3
95 21 CLK_UART4
96 22 CLK_UART5
97 23 CLK_USART6
98 24 CLK_UART7
99 25 CLK_UART8
100 26 CLK_I2C1 (I2S clocks)
101 27 CLK_I2C2
102 28 CLK_I2C3
103 29 CLK_I2C4
104 30 CLK_LPTIMER (LPTimer1 clock)
105)
69 106
70Example: 107Example:
71 108
diff --git a/Documentation/devicetree/bindings/clock/stericsson,abx500.txt b/Documentation/devicetree/bindings/clock/stericsson,abx500.txt
new file mode 100644
index 000000000000..dbaa886b223e
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/stericsson,abx500.txt
@@ -0,0 +1,20 @@
1Clock bindings for ST-Ericsson ABx500 clocks
2
3Required properties :
4- compatible : shall contain the following:
5 "stericsson,ab8500-clk"
6- #clock-cells should be <1>
7
8The ABx500 clocks need to be placed as a subnode of an AB8500
9device node, see mfd/ab8500.txt
10
11All available clocks are defined as preprocessor macros in
12dt-bindings/clock/ste-ab8500.h header and can be used in device
13tree sources.
14
15Example:
16
17clock-controller {
18 compatible = "stericsson,ab8500-clk";
19 #clock-cells = <1>;
20};
diff --git a/Documentation/devicetree/bindings/clock/sun9i-de.txt b/Documentation/devicetree/bindings/clock/sun9i-de.txt
new file mode 100644
index 000000000000..fb18f327b97a
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/sun9i-de.txt
@@ -0,0 +1,28 @@
1Allwinner A80 Display Engine Clock Control Binding
2--------------------------------------------------
3
4Required properties :
5- compatible: must contain one of the following compatibles:
6 - "allwinner,sun9i-a80-de-clks"
7
8- reg: Must contain the registers base address and length
9- clocks: phandle to the clocks feeding the display engine subsystem.
10 Three are needed:
11 - "mod": the display engine module clock
12 - "dram": the DRAM bus clock for the system
13 - "bus": the bus clock for the whole display engine subsystem
14- clock-names: Must contain the clock names described just above
15- resets: phandle to the reset control for the display engine subsystem.
16- #clock-cells : must contain 1
17- #reset-cells : must contain 1
18
19Example:
20de_clocks: clock@3000000 {
21 compatible = "allwinner,sun9i-a80-de-clks";
22 reg = <0x03000000 0x30>;
23 clocks = <&ccu CLK_DE>, <&ccu CLK_SDRAM>, <&ccu CLK_BUS_DE>;
24 clock-names = "mod", "dram", "bus";
25 resets = <&ccu RST_BUS_DE>;
26 #clock-cells = <1>;
27 #reset-cells = <1>;
28};
diff --git a/Documentation/devicetree/bindings/clock/sun9i-usb.txt b/Documentation/devicetree/bindings/clock/sun9i-usb.txt
new file mode 100644
index 000000000000..3564bd4f2a20
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/sun9i-usb.txt
@@ -0,0 +1,24 @@
1Allwinner A80 USB Clock Control Binding
2---------------------------------------
3
4Required properties :
5- compatible: must contain one of the following compatibles:
6 - "allwinner,sun9i-a80-usb-clocks"
7
8- reg: Must contain the registers base address and length
9- clocks: phandle to the clocks feeding the USB subsystem. Two are needed:
10 - "bus": the bus clock for the whole USB subsystem
11 - "hosc": the high frequency oscillator (usually at 24MHz)
12- clock-names: Must contain the clock names described just above
13- #clock-cells : must contain 1
14- #reset-cells : must contain 1
15
16Example:
17usb_clocks: clock@a08000 {
18 compatible = "allwinner,sun9i-a80-usb-clks";
19 reg = <0x00a08000 0x8>;
20 clocks = <&ccu CLK_BUS_USB>, <&osc24M>;
21 clock-names = "bus", "hosc";
22 #clock-cells = <1>;
23 #reset-cells = <1>;
24};
diff --git a/Documentation/devicetree/bindings/clock/sunxi-ccu.txt b/Documentation/devicetree/bindings/clock/sunxi-ccu.txt
index 74d44a4273f2..bae5668cf427 100644
--- a/Documentation/devicetree/bindings/clock/sunxi-ccu.txt
+++ b/Documentation/devicetree/bindings/clock/sunxi-ccu.txt
@@ -7,6 +7,8 @@ Required properties :
7 - "allwinner,sun8i-a23-ccu" 7 - "allwinner,sun8i-a23-ccu"
8 - "allwinner,sun8i-a33-ccu" 8 - "allwinner,sun8i-a33-ccu"
9 - "allwinner,sun8i-h3-ccu" 9 - "allwinner,sun8i-h3-ccu"
10 - "allwinner,sun8i-v3s-ccu"
11 - "allwinner,sun9i-a80-ccu"
10 - "allwinner,sun50i-a64-ccu" 12 - "allwinner,sun50i-a64-ccu"
11 13
12- reg: Must contain the registers base address and length 14- reg: Must contain the registers base address and length
diff --git a/Documentation/devicetree/bindings/clock/ti,cdce925.txt b/Documentation/devicetree/bindings/clock/ti,cdce925.txt
index 4c7669ad681b..0d01f2d5cc36 100644
--- a/Documentation/devicetree/bindings/clock/ti,cdce925.txt
+++ b/Documentation/devicetree/bindings/clock/ti,cdce925.txt
@@ -1,15 +1,22 @@
1Binding for TO CDCE925 programmable I2C clock synthesizers. 1Binding for TI CDCE913/925/937/949 programmable I2C clock synthesizers.
2 2
3Reference 3Reference
4This binding uses the common clock binding[1]. 4This binding uses the common clock binding[1].
5 5
6[1] Documentation/devicetree/bindings/clock/clock-bindings.txt 6[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
7[2] http://www.ti.com/product/cdce925 7[2] http://www.ti.com/product/cdce913
8[3] http://www.ti.com/product/cdce925
9[4] http://www.ti.com/product/cdce937
10[5] http://www.ti.com/product/cdce949
8 11
9The driver provides clock sources for each output Y1 through Y5. 12The driver provides clock sources for each output Y1 through Y5.
10 13
11Required properties: 14Required properties:
12 - compatible: Shall be "ti,cdce925" 15 - compatible: Shall be one of the following:
16 - "ti,cdce913": 1-PLL, 3 Outputs
17 - "ti,cdce925": 2-PLL, 5 Outputs
18 - "ti,cdce937": 3-PLL, 7 Outputs
19 - "ti,cdce949": 4-PLL, 9 Outputs
13 - reg: I2C device address. 20 - reg: I2C device address.
14 - clocks: Points to a fixed parent clock that provides the input frequency. 21 - clocks: Points to a fixed parent clock that provides the input frequency.
15 - #clock-cells: From common clock bindings: Shall be 1. 22 - #clock-cells: From common clock bindings: Shall be 1.
@@ -18,7 +25,7 @@ Optional properties:
18 - xtal-load-pf: Crystal load-capacitor value to fine-tune performance on a 25 - xtal-load-pf: Crystal load-capacitor value to fine-tune performance on a
19 board, or to compensate for external influences. 26 board, or to compensate for external influences.
20 27
21For both PLL1 and PLL2 an optional child node can be used to specify spread 28For all PLL1, PLL2, ... an optional child node can be used to specify spread
22spectrum clocking parameters for a board. 29spectrum clocking parameters for a board.
23 - spread-spectrum: SSC mode as defined in the data sheet. 30 - spread-spectrum: SSC mode as defined in the data sheet.
24 - spread-spectrum-center: Use "centered" mode instead of "max" mode. When 31 - spread-spectrum-center: Use "centered" mode instead of "max" mode. When
diff --git a/Documentation/devicetree/bindings/clock/zx296718-clk.txt b/Documentation/devicetree/bindings/clock/zx296718-clk.txt
index 8c18b7b237bf..4ad703808407 100644
--- a/Documentation/devicetree/bindings/clock/zx296718-clk.txt
+++ b/Documentation/devicetree/bindings/clock/zx296718-clk.txt
@@ -13,6 +13,9 @@ Required properties:
13 "zte,zx296718-lsp1crm": 13 "zte,zx296718-lsp1crm":
14 zx296718 device level clock selection and gating 14 zx296718 device level clock selection and gating
15 15
16 "zte,zx296718-audiocrm":
17 zx296718 audio clock selection, divider and gating
18
16- reg: Address and length of the register set 19- reg: Address and length of the register set
17 20
18The clock consumer should specify the desired clock by having the clock 21The clock consumer should specify the desired clock by having the clock
diff --git a/Documentation/devicetree/bindings/crypto/brcm,spu-crypto.txt b/Documentation/devicetree/bindings/crypto/brcm,spu-crypto.txt
new file mode 100644
index 000000000000..29b6007568eb
--- /dev/null
+++ b/Documentation/devicetree/bindings/crypto/brcm,spu-crypto.txt
@@ -0,0 +1,22 @@
1The Broadcom Secure Processing Unit (SPU) hardware supports symmetric
2cryptographic offload for Broadcom SoCs. A SoC may have multiple SPU hardware
3blocks.
4
5Required properties:
6- compatible: Should be one of the following:
7 brcm,spum-crypto - for devices with SPU-M hardware
8 brcm,spu2-crypto - for devices with SPU2 hardware
9 brcm,spu2-v2-crypto - for devices with enhanced SPU2 hardware features like SHA3
10 and Rabin Fingerprint support
11 brcm,spum-nsp-crypto - for the Northstar Plus variant of the SPU-M hardware
12
13- reg: Should contain SPU registers location and length.
14- mboxes: The mailbox channel to be used to communicate with the SPU.
15 Mailbox channels correspond to DMA rings on the device.
16
17Example:
18 crypto@612d0000 {
19 compatible = "brcm,spum-crypto";
20 reg = <0 0x612d0000 0 0x900>;
21 mboxes = <&pdc0 0>;
22 };
diff --git a/Documentation/devicetree/bindings/crypto/mediatek-crypto.txt b/Documentation/devicetree/bindings/crypto/mediatek-crypto.txt
new file mode 100644
index 000000000000..c204725e5873
--- /dev/null
+++ b/Documentation/devicetree/bindings/crypto/mediatek-crypto.txt
@@ -0,0 +1,27 @@
1MediaTek cryptographic accelerators
2
3Required properties:
4- compatible: Should be "mediatek,eip97-crypto"
5- reg: Address and length of the register set for the device
6- interrupts: Should contain the five crypto engines interrupts in numeric
7 order. These are global system and four descriptor rings.
8- clocks: the clock used by the core
9- clock-names: the names of the clock listed in the clocks property. These are
10 "ethif", "cryp"
11- power-domains: Must contain a reference to the PM domain.
12
13
14Example:
15 crypto: crypto@1b240000 {
16 compatible = "mediatek,eip97-crypto";
17 reg = <0 0x1b240000 0 0x20000>;
18 interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_LOW>,
19 <GIC_SPI 83 IRQ_TYPE_LEVEL_LOW>,
20 <GIC_SPI 84 IRQ_TYPE_LEVEL_LOW>,
21 <GIC_SPI 91 IRQ_TYPE_LEVEL_LOW>,
22 <GIC_SPI 97 IRQ_TYPE_LEVEL_LOW>;
23 clocks = <&topckgen CLK_TOP_ETHIF_SEL>,
24 <&ethsys CLK_ETHSYS_CRYPTO>;
25 clock-names = "ethif","cryp";
26 power-domains = <&scpsys MT2701_POWER_DOMAIN_ETH>;
27 };
diff --git a/Documentation/devicetree/bindings/display/arm,pl11x.txt b/Documentation/devicetree/bindings/display/arm,pl11x.txt
index 3e3039a8a253..ef89ab46b2c9 100644
--- a/Documentation/devicetree/bindings/display/arm,pl11x.txt
+++ b/Documentation/devicetree/bindings/display/arm,pl11x.txt
@@ -22,7 +22,7 @@ Required properties:
22 22
23- clocks: contains phandle and clock specifier pairs for the entries 23- clocks: contains phandle and clock specifier pairs for the entries
24 in the clock-names property. See 24 in the clock-names property. See
25 Documentation/devicetree/binding/clock/clock-bindings.txt 25 Documentation/devicetree/bindings/clock/clock-bindings.txt
26 26
27Optional properties: 27Optional properties:
28 28
diff --git a/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt b/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt
index e2768703ac2b..34c7fddcea39 100644
--- a/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt
+++ b/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt
@@ -56,6 +56,18 @@ Required properties for V3D:
56- interrupts: The interrupt number 56- interrupts: The interrupt number
57 See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt 57 See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt
58 58
59Required properties for DSI:
60- compatible: Should be "brcm,bcm2835-dsi0" or "brcm,bcm2835-dsi1"
61- reg: Physical base address and length of the DSI block's registers
62- interrupts: The interrupt number
63 See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt
64- clocks: a) phy: The DSI PLL clock feeding the DSI analog PHY
65 b) escape: The DSI ESC clock from CPRMAN
66 c) pixel: The DSI pixel clock from CPRMAN
67- clock-output-names:
68 The 3 clocks output from the DSI analog PHY: dsi[01]_byte,
69 dsi[01]_ddr2, and dsi[01]_ddr
70
59[1] Documentation/devicetree/bindings/media/video-interfaces.txt 71[1] Documentation/devicetree/bindings/media/video-interfaces.txt
60 72
61Example: 73Example:
@@ -99,6 +111,29 @@ dpi: dpi@7e208000 {
99 }; 111 };
100}; 112};
101 113
114dsi1: dsi@7e700000 {
115 compatible = "brcm,bcm2835-dsi1";
116 reg = <0x7e700000 0x8c>;
117 interrupts = <2 12>;
118 #address-cells = <1>;
119 #size-cells = <0>;
120 #clock-cells = <1>;
121
122 clocks = <&clocks BCM2835_PLLD_DSI1>,
123 <&clocks BCM2835_CLOCK_DSI1E>,
124 <&clocks BCM2835_CLOCK_DSI1P>;
125 clock-names = "phy", "escape", "pixel";
126
127 clock-output-names = "dsi1_byte", "dsi1_ddr2", "dsi1_ddr";
128
129 pitouchscreen: panel@0 {
130 compatible = "raspberrypi,touchscreen";
131 reg = <0>;
132
133 <...>
134 };
135};
136
102vec: vec@7e806000 { 137vec: vec@7e806000 {
103 compatible = "brcm,bcm2835-vec"; 138 compatible = "brcm,bcm2835-vec";
104 reg = <0x7e806000 0x1000>; 139 reg = <0x7e806000 0x1000>;
diff --git a/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt b/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
index 6532a59c9b43..00ea670b8c4d 100644
--- a/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
+++ b/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
@@ -38,10 +38,22 @@ The following input format properties are required except in "rgb 1x" and
38- adi,input-justification: The input bit justification ("left", "evenly", 38- adi,input-justification: The input bit justification ("left", "evenly",
39 "right"). 39 "right").
40 40
41- avdd-supply: A 1.8V supply that powers up the AVDD pin on the chip.
42- dvdd-supply: A 1.8V supply that powers up the DVDD pin on the chip.
43- pvdd-supply: A 1.8V supply that powers up the PVDD pin on the chip.
44- dvdd-3v-supply: A 3.3V supply that powers up the pin called DVDD_3V
45 on the chip.
46- bgvdd-supply: A 1.8V supply that powers up the BGVDD pin. This is
47 needed only for ADV7511.
48
41The following properties are required for ADV7533: 49The following properties are required for ADV7533:
42 50
43- adi,dsi-lanes: Number of DSI data lanes connected to the DSI host. It should 51- adi,dsi-lanes: Number of DSI data lanes connected to the DSI host. It should
44 be one of 1, 2, 3 or 4. 52 be one of 1, 2, 3 or 4.
53- a2vdd-supply: 1.8V supply that powers up the A2VDD pin on the chip.
54- v3p3-supply: A 3.3V supply that powers up the V3P3 pin on the chip.
55- v1p2-supply: A supply that powers up the V1P2 pin on the chip. It can be
56 either 1.2V or 1.8V.
45 57
46Optional properties: 58Optional properties:
47 59
diff --git a/Documentation/devicetree/bindings/display/bridge/analogix_dp.txt b/Documentation/devicetree/bindings/display/bridge/analogix_dp.txt
index 4a0f4f7682ad..0c7473dd0e51 100644
--- a/Documentation/devicetree/bindings/display/bridge/analogix_dp.txt
+++ b/Documentation/devicetree/bindings/display/bridge/analogix_dp.txt
@@ -33,7 +33,7 @@ Optional properties for dp-controller:
33 in Documentation/devicetree/bindings/media/video-interfaces.txt, 33 in Documentation/devicetree/bindings/media/video-interfaces.txt,
34 please refer to the SoC specific binding document: 34 please refer to the SoC specific binding document:
35 * Documentation/devicetree/bindings/display/exynos/exynos_dp.txt 35 * Documentation/devicetree/bindings/display/exynos/exynos_dp.txt
36 * Documentation/devicetree/bindings/video/analogix_dp-rockchip.txt 36 * Documentation/devicetree/bindings/display/rockchip/analogix_dp-rockchip.txt
37 37
38[1]: Documentation/devicetree/bindings/media/video-interfaces.txt 38[1]: Documentation/devicetree/bindings/media/video-interfaces.txt
39------------------------------------------------------------------------------- 39-------------------------------------------------------------------------------
diff --git a/Documentation/devicetree/bindings/video/bridge/anx7814.txt b/Documentation/devicetree/bindings/display/bridge/anx7814.txt
index b2a22c28c9b3..b2a22c28c9b3 100644
--- a/Documentation/devicetree/bindings/video/bridge/anx7814.txt
+++ b/Documentation/devicetree/bindings/display/bridge/anx7814.txt
diff --git a/Documentation/devicetree/bindings/display/bridge/dw_hdmi.txt b/Documentation/devicetree/bindings/display/bridge/dw_hdmi.txt
index 5e9a84d6e5f1..33bf981fbe33 100644
--- a/Documentation/devicetree/bindings/display/bridge/dw_hdmi.txt
+++ b/Documentation/devicetree/bindings/display/bridge/dw_hdmi.txt
@@ -1,52 +1,33 @@
1DesignWare HDMI bridge bindings 1Synopsys DesignWare HDMI TX Encoder
2 2===================================
3Required properties: 3
4- compatible: platform specific such as: 4This document defines device tree properties for the Synopsys DesignWare HDMI
5 * "snps,dw-hdmi-tx" 5TX Encoder (DWC HDMI TX). It doesn't constitue a device tree binding
6 * "fsl,imx6q-hdmi" 6specification by itself but is meant to be referenced by platform-specific
7 * "fsl,imx6dl-hdmi" 7device tree bindings.
8 * "rockchip,rk3288-dw-hdmi" 8
9- reg: Physical base address and length of the controller's registers. 9When referenced from platform device tree bindings the properties defined in
10- interrupts: The HDMI interrupt number 10this document are defined as follows. The platform device tree bindings are
11- clocks, clock-names : must have the phandles to the HDMI iahb and isfr clocks, 11responsible for defining whether each property is required or optional.
12 as described in Documentation/devicetree/bindings/clock/clock-bindings.txt, 12
13 the clocks are soc specific, the clock-names should be "iahb", "isfr" 13- reg: Memory mapped base address and length of the DWC HDMI TX registers.
14-port@[X]: SoC specific port nodes with endpoint definitions as defined 14
15 in Documentation/devicetree/bindings/media/video-interfaces.txt, 15- reg-io-width: Width of the registers specified by the reg property. The
16 please refer to the SoC specific binding document: 16 value is expressed in bytes and must be equal to 1 or 4 if specified. The
17 * Documentation/devicetree/bindings/display/imx/hdmi.txt 17 register width defaults to 1 if the property is not present.
18 * Documentation/devicetree/bindings/display/rockchip/dw_hdmi-rockchip.txt 18
19 19- interrupts: Reference to the DWC HDMI TX interrupt.
20Optional properties 20
21- reg-io-width: the width of the reg:1,4, default set to 1 if not present 21- clocks: References to all the clocks specified in the clock-names property
22- ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing, 22 as specified in Documentation/devicetree/bindings/clock/clock-bindings.txt.
23 if the property is omitted, a functionally reduced I2C bus 23
24 controller on DW HDMI is probed 24- clock-names: The DWC HDMI TX uses the following clocks.
25- clocks, clock-names: phandle to the HDMI CEC clock, name should be "cec" 25
26 26 - "iahb" is the bus clock for either AHB and APB (mandatory).
27Example: 27 - "isfr" is the internal register configuration clock (mandatory).
28 hdmi: hdmi@0120000 { 28 - "cec" is the HDMI CEC controller main clock (optional).
29 compatible = "fsl,imx6q-hdmi"; 29
30 reg = <0x00120000 0x9000>; 30- ports: The connectivity of the DWC HDMI TX with the rest of the system is
31 interrupts = <0 115 0x04>; 31 expressed in using ports as specified in the device graph bindings defined
32 gpr = <&gpr>; 32 in Documentation/devicetree/bindings/graph.txt. The numbering of the ports
33 clocks = <&clks 123>, <&clks 124>; 33 is platform-specific.
34 clock-names = "iahb", "isfr";
35 ddc-i2c-bus = <&i2c2>;
36
37 port@0 {
38 reg = <0>;
39
40 hdmi_mux_0: endpoint {
41 remote-endpoint = <&ipu1_di0_hdmi>;
42 };
43 };
44
45 port@1 {
46 reg = <1>;
47
48 hdmi_mux_1: endpoint {
49 remote-endpoint = <&ipu1_di1_hdmi>;
50 };
51 };
52 };
diff --git a/Documentation/devicetree/bindings/video/bridge/sil-sii8620.txt b/Documentation/devicetree/bindings/display/bridge/sil-sii8620.txt
index 9409d9c6a260..9409d9c6a260 100644
--- a/Documentation/devicetree/bindings/video/bridge/sil-sii8620.txt
+++ b/Documentation/devicetree/bindings/display/bridge/sil-sii8620.txt
diff --git a/Documentation/devicetree/bindings/display/bridge/ti,ths8135.txt b/Documentation/devicetree/bindings/display/bridge/ti,ths8135.txt
new file mode 100644
index 000000000000..6ec1a880ac18
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/bridge/ti,ths8135.txt
@@ -0,0 +1,46 @@
1THS8135 Video DAC
2-----------------
3
4This is the binding for Texas Instruments THS8135 Video DAC bridge.
5
6Required properties:
7
8- compatible: Must be "ti,ths8135"
9
10Required nodes:
11
12This device has two video ports. Their connections are modelled using the OF
13graph bindings specified in Documentation/devicetree/bindings/graph.txt.
14
15- Video port 0 for RGB input
16- Video port 1 for VGA output
17
18Example
19-------
20
21vga-bridge {
22 compatible = "ti,ths8135";
23 #address-cells = <1>;
24 #size-cells = <0>;
25
26 ports {
27 #address-cells = <1>;
28 #size-cells = <0>;
29
30 port@0 {
31 reg = <0>;
32
33 vga_bridge_in: endpoint {
34 remote-endpoint = <&lcdc_out_vga>;
35 };
36 };
37
38 port@1 {
39 reg = <1>;
40
41 vga_bridge_out: endpoint {
42 remote-endpoint = <&vga_con_in>;
43 };
44 };
45 };
46};
diff --git a/Documentation/devicetree/bindings/display/cirrus,clps711x-fb.txt b/Documentation/devicetree/bindings/display/cirrus,clps711x-fb.txt
index e9c65746e2f1..b0e506610400 100644
--- a/Documentation/devicetree/bindings/display/cirrus,clps711x-fb.txt
+++ b/Documentation/devicetree/bindings/display/cirrus,clps711x-fb.txt
@@ -6,7 +6,7 @@ Required properties:
6 location and size of the framebuffer memory. 6 location and size of the framebuffer memory.
7- clocks : phandle + clock specifier pair of the FB reference clock. 7- clocks : phandle + clock specifier pair of the FB reference clock.
8- display : phandle to a display node as described in 8- display : phandle to a display node as described in
9 Documentation/devicetree/bindings/display/display-timing.txt. 9 Documentation/devicetree/bindings/display/panel/display-timing.txt.
10 Additionally, the display node has to define properties: 10 Additionally, the display node has to define properties:
11 - bits-per-pixel: Bits per pixel. 11 - bits-per-pixel: Bits per pixel.
12 - ac-prescale : LCD AC bias frequency. This frequency is the required 12 - ac-prescale : LCD AC bias frequency. This frequency is the required
diff --git a/Documentation/devicetree/bindings/display/exynos/exynos7-decon.txt b/Documentation/devicetree/bindings/display/exynos/exynos7-decon.txt
index 3938caacf11c..9e2e7f6f7609 100644
--- a/Documentation/devicetree/bindings/display/exynos/exynos7-decon.txt
+++ b/Documentation/devicetree/bindings/display/exynos/exynos7-decon.txt
@@ -33,12 +33,12 @@ Required properties:
33- i80-if-timings: timing configuration for lcd i80 interface support. 33- i80-if-timings: timing configuration for lcd i80 interface support.
34 34
35Optional Properties: 35Optional Properties:
36- samsung,power-domain: a phandle to DECON power domain node. 36- power-domains: a phandle to DECON power domain node.
37- display-timings: timing settings for DECON, as described in document [1]. 37- display-timings: timing settings for DECON, as described in document [1].
38 Can be used in case timings cannot be provided otherwise 38 Can be used in case timings cannot be provided otherwise
39 or to override timings provided by the panel. 39 or to override timings provided by the panel.
40 40
41[1]: Documentation/devicetree/bindings/display/display-timing.txt 41[1]: Documentation/devicetree/bindings/display/panel/display-timing.txt
42 42
43Example: 43Example:
44 44
diff --git a/Documentation/devicetree/bindings/display/exynos/samsung-fimd.txt b/Documentation/devicetree/bindings/display/exynos/samsung-fimd.txt
index c7c6b9af87ac..18645e0228b0 100644
--- a/Documentation/devicetree/bindings/display/exynos/samsung-fimd.txt
+++ b/Documentation/devicetree/bindings/display/exynos/samsung-fimd.txt
@@ -83,7 +83,7 @@ in [2]. The following are properties specific to those nodes:
83 3 - for parallel output, 83 3 - for parallel output,
84 4 - for write-back interface 84 4 - for write-back interface
85 85
86[1]: Documentation/devicetree/bindings/display/display-timing.txt 86[1]: Documentation/devicetree/bindings/display/panel/display-timing.txt
87[2]: Documentation/devicetree/bindings/media/video-interfaces.txt 87[2]: Documentation/devicetree/bindings/media/video-interfaces.txt
88 88
89Example: 89Example:
diff --git a/Documentation/devicetree/bindings/display/hisilicon/hisi-ade.txt b/Documentation/devicetree/bindings/display/hisilicon/hisi-ade.txt
index 38dc9d60eef8..305a0e72a900 100644
--- a/Documentation/devicetree/bindings/display/hisilicon/hisi-ade.txt
+++ b/Documentation/devicetree/bindings/display/hisilicon/hisi-ade.txt
@@ -16,7 +16,7 @@ Required properties:
16 "clk_ade_core" for the ADE core clock. 16 "clk_ade_core" for the ADE core clock.
17 "clk_codec_jpeg" for the media NOC QoS clock, which use the same clock with 17 "clk_codec_jpeg" for the media NOC QoS clock, which use the same clock with
18 jpeg codec. 18 jpeg codec.
19 "clk_ade_pix" for the ADE pixel clok. 19 "clk_ade_pix" for the ADE pixel clock.
20- assigned-clocks: Should contain "clk_ade_core" and "clk_codec_jpeg" clocks' 20- assigned-clocks: Should contain "clk_ade_core" and "clk_codec_jpeg" clocks'
21 phandle + clock-specifier pairs. 21 phandle + clock-specifier pairs.
22- assigned-clock-rates: clock rates, one for each entry in assigned-clocks. 22- assigned-clock-rates: clock rates, one for each entry in assigned-clocks.
diff --git a/Documentation/devicetree/bindings/display/imx/fsl,imx-fb.txt b/Documentation/devicetree/bindings/display/imx/fsl,imx-fb.txt
index 00d5f8ea7ec6..7a5c0e204c8e 100644
--- a/Documentation/devicetree/bindings/display/imx/fsl,imx-fb.txt
+++ b/Documentation/devicetree/bindings/display/imx/fsl,imx-fb.txt
@@ -9,7 +9,7 @@ Required properties:
9 9
10Required nodes: 10Required nodes:
11- display: Phandle to a display node as described in 11- display: Phandle to a display node as described in
12 Documentation/devicetree/bindings/display/display-timing.txt 12 Documentation/devicetree/bindings/display/panel/display-timing.txt
13 Additional, the display node has to define properties: 13 Additional, the display node has to define properties:
14 - bits-per-pixel: Bits per pixel 14 - bits-per-pixel: Bits per pixel
15 - fsl,pcr: LCDC PCR value 15 - fsl,pcr: LCDC PCR value
diff --git a/Documentation/devicetree/bindings/display/imx/hdmi.txt b/Documentation/devicetree/bindings/display/imx/hdmi.txt
index 1b756cf9afb0..66a8f86e5d12 100644
--- a/Documentation/devicetree/bindings/display/imx/hdmi.txt
+++ b/Documentation/devicetree/bindings/display/imx/hdmi.txt
@@ -1,29 +1,36 @@
1Device-Tree bindings for HDMI Transmitter 1Freescale i.MX6 DWC HDMI TX Encoder
2===================================
2 3
3HDMI Transmitter 4The HDMI transmitter is a Synopsys DesignWare HDMI 1.4 TX controller IP
4================ 5with a companion PHY IP.
6
7These DT bindings follow the Synopsys DWC HDMI TX bindings defined in
8Documentation/devicetree/bindings/display/bridge/dw_hdmi.txt with the
9following device-specific properties.
5 10
6The HDMI Transmitter is a Synopsys DesignWare HDMI 1.4 TX controller IP
7with accompanying PHY IP.
8 11
9Required properties: 12Required properties:
10 - #address-cells : should be <1> 13
11 - #size-cells : should be <0> 14- compatible : Shall be one of "fsl,imx6q-hdmi" or "fsl,imx6dl-hdmi".
12 - compatible : should be "fsl,imx6q-hdmi" or "fsl,imx6dl-hdmi". 15- reg: See dw_hdmi.txt.
13 - gpr : should be <&gpr>. 16- interrupts: HDMI interrupt number
14 The phandle points to the iomuxc-gpr region containing the HDMI 17- clocks: See dw_hdmi.txt.
15 multiplexer control register. 18- clock-names: Shall contain "iahb" and "isfr" as defined in dw_hdmi.txt.
16 - clocks, clock-names : phandles to the HDMI iahb and isrf clocks, as described 19- ports: See dw_hdmi.txt. The DWC HDMI shall have between one and four ports,
17 in Documentation/devicetree/bindings/clock/clock-bindings.txt and 20 numbered 0 to 3, corresponding to the four inputs of the HDMI multiplexer.
18 Documentation/devicetree/bindings/clock/imx6q-clock.txt. 21 Each port shall have a single endpoint.
19 - port@[0-4]: Up to four port nodes with endpoint definitions as defined in 22- gpr : Shall contain a phandle to the iomuxc-gpr region containing the HDMI
20 Documentation/devicetree/bindings/media/video-interfaces.txt, 23 multiplexer control register.
21 corresponding to the four inputs to the HDMI multiplexer. 24
22 25Optional properties
23Optional properties: 26
24 - ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing 27- ddc-i2c-bus: The HDMI DDC bus can be connected to either a system I2C master
25 28 or the functionally-reduced I2C master contained in the DWC HDMI. When
26example: 29 connected to a system I2C master this property contains a phandle to that
30 I2C master controller.
31
32
33Example:
27 34
28 gpr: iomuxc-gpr@020e0000 { 35 gpr: iomuxc-gpr@020e0000 {
29 /* ... */ 36 /* ... */
diff --git a/Documentation/devicetree/bindings/display/imx/ldb.txt b/Documentation/devicetree/bindings/display/imx/ldb.txt
index a407462c885e..38c637fa39dd 100644
--- a/Documentation/devicetree/bindings/display/imx/ldb.txt
+++ b/Documentation/devicetree/bindings/display/imx/ldb.txt
@@ -64,7 +64,7 @@ Required properties:
64Optional properties (required if display-timings are used): 64Optional properties (required if display-timings are used):
65 - ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing 65 - ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing
66 - display-timings : A node that describes the display timings as defined in 66 - display-timings : A node that describes the display timings as defined in
67 Documentation/devicetree/bindings/display/display-timing.txt. 67 Documentation/devicetree/bindings/display/panel/display-timing.txt.
68 - fsl,data-mapping : should be "spwg" or "jeida" 68 - fsl,data-mapping : should be "spwg" or "jeida"
69 This describes how the color bits are laid out in the 69 This describes how the color bits are laid out in the
70 serialized LVDS signal. 70 serialized LVDS signal.
diff --git a/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt b/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt
index db6e77edbea8..708f5664a316 100644
--- a/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt
+++ b/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt
@@ -55,7 +55,7 @@ Required properties (DMA function blocks):
55 "mediatek,<chip>-disp-rdma" 55 "mediatek,<chip>-disp-rdma"
56 "mediatek,<chip>-disp-wdma" 56 "mediatek,<chip>-disp-wdma"
57- larb: Should contain a phandle pointing to the local arbiter device as defined 57- larb: Should contain a phandle pointing to the local arbiter device as defined
58 in Documentation/devicetree/bindings/soc/mediatek/mediatek,smi-larb.txt 58 in Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.txt
59- iommus: Should point to the respective IOMMU block with master port as 59- iommus: Should point to the respective IOMMU block with master port as
60 argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt 60 argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
61 for details. 61 for details.
diff --git a/Documentation/devicetree/bindings/display/msm/dsi.txt b/Documentation/devicetree/bindings/display/msm/dsi.txt
index 6b1cab17f52d..fa00e62e1cf6 100644
--- a/Documentation/devicetree/bindings/display/msm/dsi.txt
+++ b/Documentation/devicetree/bindings/display/msm/dsi.txt
@@ -108,7 +108,7 @@ Optional properties:
108- qcom,dsi-phy-regulator-ldo-mode: Boolean value indicating if the LDO mode PHY 108- qcom,dsi-phy-regulator-ldo-mode: Boolean value indicating if the LDO mode PHY
109 regulator is wanted. 109 regulator is wanted.
110 110
111[1] Documentation/devicetree/bindings/clocks/clock-bindings.txt 111[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
112[2] Documentation/devicetree/bindings/graph.txt 112[2] Documentation/devicetree/bindings/graph.txt
113[3] Documentation/devicetree/bindings/media/video-interfaces.txt 113[3] Documentation/devicetree/bindings/media/video-interfaces.txt
114[4] Documentation/devicetree/bindings/display/panel/ 114[4] Documentation/devicetree/bindings/display/panel/
diff --git a/Documentation/devicetree/bindings/display/msm/edp.txt b/Documentation/devicetree/bindings/display/msm/edp.txt
index 3a20f6ea5898..e63032be5401 100644
--- a/Documentation/devicetree/bindings/display/msm/edp.txt
+++ b/Documentation/devicetree/bindings/display/msm/edp.txt
@@ -10,7 +10,7 @@ Required properties:
10- interrupts: The interrupt signal from the eDP block. 10- interrupts: The interrupt signal from the eDP block.
11- power-domains: Should be <&mmcc MDSS_GDSC>. 11- power-domains: Should be <&mmcc MDSS_GDSC>.
12- clocks: device clocks 12- clocks: device clocks
13 See Documentation/devicetree/bindings/clocks/clock-bindings.txt for details. 13 See Documentation/devicetree/bindings/clock/clock-bindings.txt for details.
14- clock-names: the following clocks are required: 14- clock-names: the following clocks are required:
15 * "core_clk" 15 * "core_clk"
16 * "iface_clk" 16 * "iface_clk"
diff --git a/Documentation/devicetree/bindings/display/msm/gpu.txt b/Documentation/devicetree/bindings/display/msm/gpu.txt
index 67d0a58dbb77..43fac0fe09bb 100644
--- a/Documentation/devicetree/bindings/display/msm/gpu.txt
+++ b/Documentation/devicetree/bindings/display/msm/gpu.txt
@@ -1,23 +1,19 @@
1Qualcomm adreno/snapdragon GPU 1Qualcomm adreno/snapdragon GPU
2 2
3Required properties: 3Required properties:
4- compatible: "qcom,adreno-3xx" 4- compatible: "qcom,adreno-XYZ.W", "qcom,adreno"
5 for example: "qcom,adreno-306.0", "qcom,adreno"
6 Note that you need to list the less specific "qcom,adreno" (since this
7 is what the device is matched on), in addition to the more specific
8 with the chip-id.
5- reg: Physical base address and length of the controller's registers. 9- reg: Physical base address and length of the controller's registers.
6- interrupts: The interrupt signal from the gpu. 10- interrupts: The interrupt signal from the gpu.
7- clocks: device clocks 11- clocks: device clocks
8 See ../clocks/clock-bindings.txt for details. 12 See ../clocks/clock-bindings.txt for details.
9- clock-names: the following clocks are required: 13- clock-names: the following clocks are required:
10 * "core_clk" 14 * "core"
11 * "iface_clk" 15 * "iface"
12 * "mem_iface_clk" 16 * "mem_iface"
13- qcom,chipid: gpu chip-id. Note this may become optional for future
14 devices if we can reliably read the chipid from hw
15- qcom,gpu-pwrlevels: list of operating points
16 - compatible: "qcom,gpu-pwrlevels"
17 - for each qcom,gpu-pwrlevel:
18 - qcom,gpu-freq: requested gpu clock speed
19 - NOTE: downstream android driver defines additional parameters to
20 configure memory bandwidth scaling per OPP.
21 17
22Example: 18Example:
23 19
@@ -25,28 +21,18 @@ Example:
25 ... 21 ...
26 22
27 gpu: qcom,kgsl-3d0@4300000 { 23 gpu: qcom,kgsl-3d0@4300000 {
28 compatible = "qcom,adreno-3xx"; 24 compatible = "qcom,adreno-320.2", "qcom,adreno";
29 reg = <0x04300000 0x20000>; 25 reg = <0x04300000 0x20000>;
30 reg-names = "kgsl_3d0_reg_memory"; 26 reg-names = "kgsl_3d0_reg_memory";
31 interrupts = <GIC_SPI 80 0>; 27 interrupts = <GIC_SPI 80 0>;
32 interrupt-names = "kgsl_3d0_irq"; 28 interrupt-names = "kgsl_3d0_irq";
33 clock-names = 29 clock-names =
34 "core_clk", 30 "core",
35 "iface_clk", 31 "iface",
36 "mem_iface_clk"; 32 "mem_iface";
37 clocks = 33 clocks =
38 <&mmcc GFX3D_CLK>, 34 <&mmcc GFX3D_CLK>,
39 <&mmcc GFX3D_AHB_CLK>, 35 <&mmcc GFX3D_AHB_CLK>,
40 <&mmcc MMSS_IMEM_AHB_CLK>; 36 <&mmcc MMSS_IMEM_AHB_CLK>;
41 qcom,chipid = <0x03020100>;
42 qcom,gpu-pwrlevels {
43 compatible = "qcom,gpu-pwrlevels";
44 qcom,gpu-pwrlevel@0 {
45 qcom,gpu-freq = <450000000>;
46 };
47 qcom,gpu-pwrlevel@1 {
48 qcom,gpu-freq = <27000000>;
49 };
50 };
51 }; 37 };
52}; 38};
diff --git a/Documentation/devicetree/bindings/display/msm/hdmi.txt b/Documentation/devicetree/bindings/display/msm/hdmi.txt
index 2ad578984fcf..2d306f402d18 100644
--- a/Documentation/devicetree/bindings/display/msm/hdmi.txt
+++ b/Documentation/devicetree/bindings/display/msm/hdmi.txt
@@ -49,7 +49,7 @@ Required properties:
49 * "hdmi_tx_l4" 49 * "hdmi_tx_l4"
50- power-domains: Should be <&mmcc MDSS_GDSC>. 50- power-domains: Should be <&mmcc MDSS_GDSC>.
51- clocks: device clocks 51- clocks: device clocks
52 See Documentation/devicetree/bindings/clocks/clock-bindings.txt for details. 52 See Documentation/devicetree/bindings/clock/clock-bindings.txt for details.
53- core-vdda-supply: phandle to vdda regulator device node 53- core-vdda-supply: phandle to vdda regulator device node
54 54
55Example: 55Example:
diff --git a/Documentation/devicetree/bindings/display/multi-inno,mi0283qt.txt b/Documentation/devicetree/bindings/display/multi-inno,mi0283qt.txt
new file mode 100644
index 000000000000..eed48c3d4875
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/multi-inno,mi0283qt.txt
@@ -0,0 +1,27 @@
1Multi-Inno MI0283QT display panel
2
3Required properties:
4- compatible: "multi-inno,mi0283qt".
5
6The node for this driver must be a child node of a SPI controller, hence
7all mandatory properties described in ../spi/spi-bus.txt must be specified.
8
9Optional properties:
10- dc-gpios: D/C pin. The presence/absence of this GPIO determines
11 the panel interface mode (IM[3:0] pins):
12 - present: IM=x110 4-wire 8-bit data serial interface
13 - absent: IM=x101 3-wire 9-bit data serial interface
14- reset-gpios: Reset pin
15- power-supply: A regulator node for the supply voltage.
16- backlight: phandle of the backlight device attached to the panel
17- rotation: panel rotation in degrees counter clockwise (0,90,180,270)
18
19Example:
20 mi0283qt@0{
21 compatible = "multi-inno,mi0283qt";
22 reg = <0>;
23 spi-max-frequency = <32000000>;
24 rotation = <90>;
25 dc-gpios = <&gpio 25 0>;
26 backlight = <&backlight>;
27 };
diff --git a/Documentation/devicetree/bindings/display/panel/boe,nv101wxmn51.txt b/Documentation/devicetree/bindings/display/panel/boe,nv101wxmn51.txt
new file mode 100644
index 000000000000..b258d6a91ec6
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/boe,nv101wxmn51.txt
@@ -0,0 +1,7 @@
1BOE OPTOELECTRONICS TECHNOLOGY 10.1" WXGA TFT LCD panel
2
3Required properties:
4- compatible: should be "boe,nv101wxmn51"
5
6This binding is compatible with the simple-panel binding, which is specified
7in simple-panel.txt in this directory.
diff --git a/Documentation/devicetree/bindings/display/panel/netron-dy,e231732.txt b/Documentation/devicetree/bindings/display/panel/netron-dy,e231732.txt
new file mode 100644
index 000000000000..c6d06b5eab51
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/netron-dy,e231732.txt
@@ -0,0 +1,7 @@
1Netron-DY E231732 7.0" WSVGA TFT LCD panel
2
3Required properties:
4- compatible: should be "netron-dy,e231732"
5
6This binding is compatible with the simple-panel binding, which is specified
7in simple-panel.txt in this directory.
diff --git a/Documentation/devicetree/bindings/display/panel/panel-dpi.txt b/Documentation/devicetree/bindings/display/panel/panel-dpi.txt
index b52ac52757df..d4add13e592d 100644
--- a/Documentation/devicetree/bindings/display/panel/panel-dpi.txt
+++ b/Documentation/devicetree/bindings/display/panel/panel-dpi.txt
@@ -12,7 +12,7 @@ Optional properties:
12 12
13Required nodes: 13Required nodes:
14- "panel-timing" containing video timings 14- "panel-timing" containing video timings
15 (Documentation/devicetree/bindings/display/display-timing.txt) 15 (Documentation/devicetree/bindings/display/panel/display-timing.txt)
16- Video port for DPI input 16- Video port for DPI input
17 17
18Example 18Example
diff --git a/Documentation/devicetree/bindings/display/panel/panel.txt b/Documentation/devicetree/bindings/display/panel/panel.txt
new file mode 100644
index 000000000000..e2e6867852b8
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/panel.txt
@@ -0,0 +1,4 @@
1Common display properties
2-------------------------
3
4- rotation: Display rotation in degrees counter clockwise (0,90,180,270)
diff --git a/Documentation/devicetree/bindings/display/panel/samsung,ld9040.txt b/Documentation/devicetree/bindings/display/panel/samsung,ld9040.txt
index fc595d9b985b..354d4d1df4ff 100644
--- a/Documentation/devicetree/bindings/display/panel/samsung,ld9040.txt
+++ b/Documentation/devicetree/bindings/display/panel/samsung,ld9040.txt
@@ -20,7 +20,7 @@ The device node can contain one 'port' child node with one child
20'endpoint' node, according to the bindings defined in [3]. This 20'endpoint' node, according to the bindings defined in [3]. This
21node should describe panel's video bus. 21node should describe panel's video bus.
22 22
23[1]: Documentation/devicetree/bindings/display/display-timing.txt 23[1]: Documentation/devicetree/bindings/display/panel/display-timing.txt
24[2]: Documentation/devicetree/bindings/spi/spi-bus.txt 24[2]: Documentation/devicetree/bindings/spi/spi-bus.txt
25[3]: Documentation/devicetree/bindings/media/video-interfaces.txt 25[3]: Documentation/devicetree/bindings/media/video-interfaces.txt
26 26
diff --git a/Documentation/devicetree/bindings/display/panel/samsung,s6e8aa0.txt b/Documentation/devicetree/bindings/display/panel/samsung,s6e8aa0.txt
index 25701c81b5e0..9e766c5f86da 100644
--- a/Documentation/devicetree/bindings/display/panel/samsung,s6e8aa0.txt
+++ b/Documentation/devicetree/bindings/display/panel/samsung,s6e8aa0.txt
@@ -21,7 +21,7 @@ The device node can contain one 'port' child node with one child
21'endpoint' node, according to the bindings defined in [2]. This 21'endpoint' node, according to the bindings defined in [2]. This
22node should describe panel's video bus. 22node should describe panel's video bus.
23 23
24[1]: Documentation/devicetree/bindings/display/display-timing.txt 24[1]: Documentation/devicetree/bindings/display/panel/display-timing.txt
25[2]: Documentation/devicetree/bindings/media/video-interfaces.txt 25[2]: Documentation/devicetree/bindings/media/video-interfaces.txt
26 26
27Example: 27Example:
diff --git a/Documentation/devicetree/bindings/display/panel/tianma,tm070jdhg30.txt b/Documentation/devicetree/bindings/display/panel/tianma,tm070jdhg30.txt
new file mode 100644
index 000000000000..eb9501a82e25
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/tianma,tm070jdhg30.txt
@@ -0,0 +1,7 @@
1Tianma Micro-electronics TM070JDHG30 7.0" WXGA TFT LCD panel
2
3Required properties:
4- compatible: should be "tianma,tm070jdhg30"
5
6This binding is compatible with the simple-panel binding, which is specified
7in simple-panel.txt in this directory.
diff --git a/Documentation/devicetree/bindings/display/rockchip/analogix_dp-rockchip.txt b/Documentation/devicetree/bindings/display/rockchip/analogix_dp-rockchip.txt
index 01cced1c2a18..47665a12786f 100644
--- a/Documentation/devicetree/bindings/display/rockchip/analogix_dp-rockchip.txt
+++ b/Documentation/devicetree/bindings/display/rockchip/analogix_dp-rockchip.txt
@@ -35,7 +35,7 @@ Optional property for different chips:
35 Required elements: "grf" 35 Required elements: "grf"
36 36
37For the below properties, please refer to Analogix DP binding document: 37For the below properties, please refer to Analogix DP binding document:
38 * Documentation/devicetree/bindings/drm/bridge/analogix_dp.txt 38 * Documentation/devicetree/bindings/display/bridge/analogix_dp.txt
39- phys (required) 39- phys (required)
40- phy-names (required) 40- phy-names (required)
41- hpd-gpios (optional) 41- hpd-gpios (optional)
diff --git a/Documentation/devicetree/bindings/display/rockchip/dw_hdmi-rockchip.txt b/Documentation/devicetree/bindings/display/rockchip/dw_hdmi-rockchip.txt
index 668091f27674..046076c6b277 100644
--- a/Documentation/devicetree/bindings/display/rockchip/dw_hdmi-rockchip.txt
+++ b/Documentation/devicetree/bindings/display/rockchip/dw_hdmi-rockchip.txt
@@ -1,24 +1,39 @@
1Rockchip specific extensions to the Synopsys Designware HDMI 1Rockchip DWC HDMI TX Encoder
2================================ 2============================
3
4The HDMI transmitter is a Synopsys DesignWare HDMI 1.4 TX controller IP
5with a companion PHY IP.
6
7These DT bindings follow the Synopsys DWC HDMI TX bindings defined in
8Documentation/devicetree/bindings/display/bridge/dw_hdmi.txt with the
9following device-specific properties.
10
3 11
4Required properties: 12Required properties:
5- compatible: "rockchip,rk3288-dw-hdmi"; 13
6- reg: Physical base address and length of the controller's registers. 14- compatible: Shall contain "rockchip,rk3288-dw-hdmi".
7- clocks: phandle to hdmi iahb and isfr clocks. 15- reg: See dw_hdmi.txt.
8- clock-names: should be "iahb" "isfr" 16- reg-io-width: See dw_hdmi.txt. Shall be 4.
9- rockchip,grf: this soc should set GRF regs to mux vopl/vopb.
10- interrupts: HDMI interrupt number 17- interrupts: HDMI interrupt number
11- ports: contain a port node with endpoint definitions as defined in 18- clocks: See dw_hdmi.txt.
12 Documentation/devicetree/bindings/media/video-interfaces.txt. For 19- clock-names: Shall contain "iahb" and "isfr" as defined in dw_hdmi.txt.
13 vopb,set the reg = <0> and set the reg = <1> for vopl. 20- ports: See dw_hdmi.txt. The DWC HDMI shall have a single port numbered 0
14- reg-io-width: the width of the reg:1,4, the value should be 4 on 21 corresponding to the video input of the controller. The port shall have two
15 rk3288 platform 22 endpoints, numbered 0 and 1, connected respectively to the vopb and vopl.
23- rockchip,grf: Shall reference the GRF to mux vopl/vopb.
16 24
17Optional properties 25Optional properties
18- ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing 26
19- clocks, clock-names: phandle to the HDMI CEC clock, name should be "cec" 27- ddc-i2c-bus: The HDMI DDC bus can be connected to either a system I2C master
28 or the functionally-reduced I2C master contained in the DWC HDMI. When
29 connected to a system I2C master this property contains a phandle to that
30 I2C master controller.
31- clock-names: See dw_hdmi.txt. The "cec" clock is optional.
32- clock-names: May contain "cec" as defined in dw_hdmi.txt.
33
20 34
21Example: 35Example:
36
22hdmi: hdmi@ff980000 { 37hdmi: hdmi@ff980000 {
23 compatible = "rockchip,rk3288-dw-hdmi"; 38 compatible = "rockchip,rk3288-dw-hdmi";
24 reg = <0xff980000 0x20000>; 39 reg = <0xff980000 0x20000>;
diff --git a/Documentation/devicetree/bindings/display/ssd1307fb.txt b/Documentation/devicetree/bindings/display/ssd1307fb.txt
index eb31ed47a283..209d931ef16c 100644
--- a/Documentation/devicetree/bindings/display/ssd1307fb.txt
+++ b/Documentation/devicetree/bindings/display/ssd1307fb.txt
@@ -8,14 +8,15 @@ Required properties:
8 0x3c or 0x3d 8 0x3c or 0x3d
9 - pwm: Should contain the pwm to use according to the OF device tree PWM 9 - pwm: Should contain the pwm to use according to the OF device tree PWM
10 specification [0]. Only required for the ssd1307. 10 specification [0]. Only required for the ssd1307.
11 - reset-gpios: Should contain the GPIO used to reset the OLED display
12 - solomon,height: Height in pixel of the screen driven by the controller 11 - solomon,height: Height in pixel of the screen driven by the controller
13 - solomon,width: Width in pixel of the screen driven by the controller 12 - solomon,width: Width in pixel of the screen driven by the controller
14 - solomon,page-offset: Offset of pages (band of 8 pixels) that the screen is 13 - solomon,page-offset: Offset of pages (band of 8 pixels) that the screen is
15 mapped to. 14 mapped to.
16 15
17Optional properties: 16Optional properties:
18 - reset-active-low: Is the reset gpio is active on physical low? 17 - reset-gpios: The GPIO used to reset the OLED display, if available. See
18 Documentation/devicetree/bindings/gpio/gpio.txt for details.
19 - vbat-supply: The supply for VBAT
19 - solomon,segment-no-remap: Display needs normal (non-inverted) data column 20 - solomon,segment-no-remap: Display needs normal (non-inverted) data column
20 to segment mapping 21 to segment mapping
21 - solomon,com-seq: Display uses sequential COM pin configuration 22 - solomon,com-seq: Display uses sequential COM pin configuration
diff --git a/Documentation/devicetree/bindings/display/tilcdc/panel.txt b/Documentation/devicetree/bindings/display/tilcdc/panel.txt
index f20b31cdc59a..808216310ea2 100644
--- a/Documentation/devicetree/bindings/display/tilcdc/panel.txt
+++ b/Documentation/devicetree/bindings/display/tilcdc/panel.txt
@@ -15,7 +15,7 @@ Required properties:
15 - display-timings: typical videomode of lcd panel. Multiple video modes 15 - display-timings: typical videomode of lcd panel. Multiple video modes
16 can be listed if the panel supports multiple timings, but the 'native-mode' 16 can be listed if the panel supports multiple timings, but the 'native-mode'
17 should be the preferred/default resolution. Refer to 17 should be the preferred/default resolution. Refer to
18 Documentation/devicetree/bindings/display/display-timing.txt for display 18 Documentation/devicetree/bindings/display/panel/display-timing.txt for display
19 timing binding details. 19 timing binding details.
20 20
21Optional properties: 21Optional properties:
diff --git a/Documentation/devicetree/bindings/display/zte,vou.txt b/Documentation/devicetree/bindings/display/zte,vou.txt
index 740e5bd2e4f7..9c356284232b 100644
--- a/Documentation/devicetree/bindings/display/zte,vou.txt
+++ b/Documentation/devicetree/bindings/display/zte,vou.txt
@@ -49,6 +49,15 @@ Required properties:
49 "osc_clk" 49 "osc_clk"
50 "xclk" 50 "xclk"
51 51
52* TV Encoder output device
53
54Required properties:
55 - compatible: should be "zte,zx296718-tvenc"
56 - reg: Physical base address and length of the TVENC device IO region
57 - zte,tvenc-power-control: the phandle to SYSCTRL block followed by two
58 integer cells. The first cell is the offset of SYSCTRL register used
59 to control TV Encoder DAC power, and the second cell is the bit mask.
60
52Example: 61Example:
53 62
54vou: vou@1440000 { 63vou: vou@1440000 {
@@ -81,4 +90,10 @@ vou: vou@1440000 {
81 <&topcrm HDMI_XCLK>; 90 <&topcrm HDMI_XCLK>;
82 clock-names = "osc_cec", "osc_clk", "xclk"; 91 clock-names = "osc_cec", "osc_clk", "xclk";
83 }; 92 };
93
94 tvenc: tvenc@2000 {
95 compatible = "zte,zx296718-tvenc";
96 reg = <0x2000 0x1000>;
97 zte,tvenc-power-control = <&sysctrl 0x170 0x10>;
98 };
84}; 99};
diff --git a/Documentation/devicetree/bindings/eeprom/eeprom.txt b/Documentation/devicetree/bindings/eeprom/eeprom.txt
index 735bc94444bb..5696eb508e95 100644
--- a/Documentation/devicetree/bindings/eeprom/eeprom.txt
+++ b/Documentation/devicetree/bindings/eeprom/eeprom.txt
@@ -10,6 +10,8 @@ Required properties:
10 10
11 "catalyst,24c32" 11 "catalyst,24c32"
12 12
13 "microchip,24c128"
14
13 "ramtron,24c64" 15 "ramtron,24c64"
14 16
15 "renesas,r1ex24002" 17 "renesas,r1ex24002"
diff --git a/Documentation/devicetree/bindings/gpio/cortina,gemini-gpio.txt b/Documentation/devicetree/bindings/gpio/cortina,gemini-gpio.txt
new file mode 100644
index 000000000000..5c9246c054e5
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/cortina,gemini-gpio.txt
@@ -0,0 +1,24 @@
1Cortina Systems Gemini GPIO Controller
2
3Required properties:
4
5- compatible : Must be "cortina,gemini-gpio"
6- reg : Should contain registers location and length
7- interrupts : Should contain the interrupt line for the GPIO block
8- gpio-controller : marks this as a GPIO controller
9- #gpio-cells : Should be 2, see gpio/gpio.txt
10- interrupt-controller : marks this as an interrupt controller
11- #interrupt-cells : a standard two-cell interrupt flag, see
12 interrupt-controller/interrupts.txt
13
14Example:
15
16gpio@4d000000 {
17 compatible = "cortina,gemini-gpio";
18 reg = <0x4d000000 0x100>;
19 interrupts = <22 IRQ_TYPE_LEVEL_HIGH>;
20 gpio-controller;
21 #gpio-cells = <2>;
22 interrupt-controller;
23 #interrupt-cells = <2>;
24};
diff --git a/Documentation/devicetree/bindings/gpio/gpio-pca953x.txt b/Documentation/devicetree/bindings/gpio/gpio-pca953x.txt
index 08dd15f89ba9..e63935710011 100644
--- a/Documentation/devicetree/bindings/gpio/gpio-pca953x.txt
+++ b/Documentation/devicetree/bindings/gpio/gpio-pca953x.txt
@@ -29,6 +29,10 @@ Required properties:
29 onsemi,pca9654 29 onsemi,pca9654
30 exar,xra1202 30 exar,xra1202
31 31
32Optional properties:
33 - reset-gpios: GPIO specification for the RESET input. This is an
34 active low signal to the PCA953x.
35
32Example: 36Example:
33 37
34 38
diff --git a/Documentation/devicetree/bindings/gpio/gpio.txt b/Documentation/devicetree/bindings/gpio/gpio.txt
index 68d28f62a6f4..84ede036f73d 100644
--- a/Documentation/devicetree/bindings/gpio/gpio.txt
+++ b/Documentation/devicetree/bindings/gpio/gpio.txt
@@ -187,10 +187,10 @@ gpio-controller's driver probe function.
187 187
188Each GPIO hog definition is represented as a child node of the GPIO controller. 188Each GPIO hog definition is represented as a child node of the GPIO controller.
189Required properties: 189Required properties:
190- gpio-hog: A property specifying that this child node represent a GPIO hog. 190- gpio-hog: A property specifying that this child node represents a GPIO hog.
191- gpios: Store the GPIO information (id, flags, ...). Shall contain the 191- gpios: Store the GPIO information (id, flags, ...) for each GPIO to
192 number of cells specified in its parent node (GPIO controller 192 affect. Shall contain an integer multiple of the number of cells
193 node). 193 specified in its parent node (GPIO controller node).
194Only one of the following properties scanned in the order shown below. 194Only one of the following properties scanned in the order shown below.
195This means that when multiple properties are present they will be searched 195This means that when multiple properties are present they will be searched
196in the order presented below and the first match is taken as the intended 196in the order presented below and the first match is taken as the intended
diff --git a/Documentation/devicetree/bindings/gpu/arm,mali-utgard.txt b/Documentation/devicetree/bindings/gpu/arm,mali-utgard.txt
new file mode 100644
index 000000000000..476f5ea6c627
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpu/arm,mali-utgard.txt
@@ -0,0 +1,81 @@
1ARM Mali Utgard GPU
2===================
3
4Required properties:
5 - compatible
6 * Must be one of the following:
7 + "arm,mali-300"
8 + "arm,mali-400"
9 + "arm,mali-450"
10 * And, optionally, one of the vendor specific compatible:
11 + allwinner,sun4i-a10-mali
12 + allwinner,sun7i-a20-mali
13 + amlogic,meson-gxbb-mali
14 + amlogic,meson-gxl-mali
15 + stericsson,db8500-mali
16
17 - reg: Physical base address and length of the GPU registers
18
19 - interrupts: an entry for each entry in interrupt-names.
20 See ../interrupt-controller/interrupts.txt for details.
21
22 - interrupt-names:
23 * ppX: Pixel Processor X interrupt (X from 0 to 7)
24 * ppmmuX: Pixel Processor X MMU interrupt (X from 0 to 7)
25 * pp: Pixel Processor broadcast interrupt (mali-450 only)
26 * gp: Geometry Processor interrupt
27 * gpmmu: Geometry Processor MMU interrupt
28
29 - clocks: an entry for each entry in clock-names
30 - clock-names:
31 * bus: bus clock for the GPU
32 * core: clock driving the GPU itself
33
34Optional properties:
35 - interrupt-names and interrupts:
36 * pmu: Power Management Unit interrupt, if implemented in hardware
37
38Vendor-specific bindings
39------------------------
40
41The Mali GPU is integrated very differently from one SoC to
42another. In order to accomodate those differences, you have the option
43to specify one more vendor-specific compatible, among:
44
45 - allwinner,sun4i-a10-mali
46 Required properties:
47 * resets: phandle to the reset line for the GPU
48
49 - allwinner,sun7i-a20-mali
50 Required properties:
51 * resets: phandle to the reset line for the GPU
52
53 - stericsson,db8500-mali
54 Required properties:
55 * interrupt-names and interrupts:
56 + combined: combined interrupt of all of the above lines
57
58Example:
59
60mali: gpu@1c40000 {
61 compatible = "allwinner,sun7i-a20-mali", "arm,mali-400";
62 reg = <0x01c40000 0x10000>;
63 interrupts = <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>,
64 <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>,
65 <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>,
66 <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>,
67 <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>,
68 <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>,
69 <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>;
70 interrupt-names = "gp",
71 "gpmmu",
72 "pp0",
73 "ppmmu0",
74 "pp1",
75 "ppmmu1",
76 "pmu";
77 clocks = <&ccu CLK_BUS_GPU>, <&ccu CLK_GPU>;
78 clock-names = "bus", "core";
79 resets = <&ccu RST_BUS_GPU>;
80};
81
diff --git a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt
index cf53d5fba20a..aa097045a10e 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt
@@ -19,7 +19,14 @@ Optional Properties:
19 - i2c-mux-idle-disconnect: Boolean; if defined, forces mux to disconnect all 19 - i2c-mux-idle-disconnect: Boolean; if defined, forces mux to disconnect all
20 children in idle state. This is necessary for example, if there are several 20 children in idle state. This is necessary for example, if there are several
21 multiplexers on the bus and the devices behind them use same I2C addresses. 21 multiplexers on the bus and the devices behind them use same I2C addresses.
22 22 - interrupt-parent: Phandle for the interrupt controller that services
23 interrupts for this device.
24 - interrupts: Interrupt mapping for IRQ.
25 - interrupt-controller: Marks the device node as an interrupt controller.
26 - #interrupt-cells : Should be two.
27 - first cell is the pin number
28 - second cell is used to specify flags.
29 See also Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
23 30
24Example: 31Example:
25 32
@@ -29,6 +36,11 @@ Example:
29 #size-cells = <0>; 36 #size-cells = <0>;
30 reg = <0x74>; 37 reg = <0x74>;
31 38
39 interrupt-parent = <&ipic>;
40 interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
41 interrupt-controller;
42 #interrupt-cells = <2>;
43
32 i2c@2 { 44 i2c@2 {
33 #address-cells = <1>; 45 #address-cells = <1>;
34 #size-cells = <0>; 46 #size-cells = <0>;
diff --git a/Documentation/devicetree/bindings/i2c/i2c-sh_mobile.txt b/Documentation/devicetree/bindings/i2c/i2c-sh_mobile.txt
index 7716acc55dec..ae9c2a735f39 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-sh_mobile.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-sh_mobile.txt
@@ -10,6 +10,7 @@ Required properties:
10 - "renesas,iic-r8a7793" (R-Car M2-N) 10 - "renesas,iic-r8a7793" (R-Car M2-N)
11 - "renesas,iic-r8a7794" (R-Car E2) 11 - "renesas,iic-r8a7794" (R-Car E2)
12 - "renesas,iic-r8a7795" (R-Car H3) 12 - "renesas,iic-r8a7795" (R-Car H3)
13 - "renesas,iic-r8a7796" (R-Car M3-W)
13 - "renesas,iic-sh73a0" (SH-Mobile AG5) 14 - "renesas,iic-sh73a0" (SH-Mobile AG5)
14 - "renesas,rcar-gen2-iic" (generic R-Car Gen2 compatible device) 15 - "renesas,rcar-gen2-iic" (generic R-Car Gen2 compatible device)
15 - "renesas,rcar-gen3-iic" (generic R-Car Gen3 compatible device) 16 - "renesas,rcar-gen3-iic" (generic R-Car Gen3 compatible device)
diff --git a/Documentation/devicetree/bindings/i2c/i2c-stm32.txt b/Documentation/devicetree/bindings/i2c/i2c-stm32.txt
new file mode 100644
index 000000000000..78eaf7b718ed
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-stm32.txt
@@ -0,0 +1,33 @@
1* I2C controller embedded in STMicroelectronics STM32 I2C platform
2
3Required properties :
4- compatible : Must be "st,stm32f4-i2c"
5- reg : Offset and length of the register set for the device
6- interrupts : Must contain the interrupt id for I2C event and then the
7 interrupt id for I2C error.
8- resets: Must contain the phandle to the reset controller.
9- clocks: Must contain the input clock of the I2C instance.
10- A pinctrl state named "default" must be defined to set pins in mode of
11 operation for I2C transfer
12- #address-cells = <1>;
13- #size-cells = <0>;
14
15Optional properties :
16- clock-frequency : Desired I2C bus clock frequency in Hz. If not specified,
17 the default 100 kHz frequency will be used. As only Normal and Fast modes
18 are supported, possible values are 100000 and 400000.
19
20Example :
21
22 i2c@40005400 {
23 compatible = "st,stm32f4-i2c";
24 #address-cells = <1>;
25 #size-cells = <0>;
26 reg = <0x40005400 0x400>;
27 interrupts = <31>,
28 <32>;
29 resets = <&rcc 277>;
30 clocks = <&rcc 0 149>;
31 pinctrl-0 = <&i2c1_sda_pin>, <&i2c1_scl_pin>;
32 pinctrl-names = "default";
33 };
diff --git a/Documentation/devicetree/bindings/i2c/nvidia,tegra186-bpmp-i2c.txt b/Documentation/devicetree/bindings/i2c/nvidia,tegra186-bpmp-i2c.txt
new file mode 100644
index 000000000000..ab240e10debc
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/nvidia,tegra186-bpmp-i2c.txt
@@ -0,0 +1,42 @@
1NVIDIA Tegra186 BPMP I2C controller
2
3In Tegra186, the BPMP (Boot and Power Management Processor) owns certain HW
4devices, such as the I2C controller for the power management I2C bus. Software
5running on other CPUs must perform IPC to the BPMP in order to execute
6transactions on that I2C bus. This binding describes an I2C bus that is
7accessed in such a fashion.
8
9The BPMP I2C node must be located directly inside the main BPMP node. See
10../firmware/nvidia,tegra186-bpmp.txt for details of the BPMP binding.
11
12This node represents an I2C controller. See ../i2c/i2c.txt for details of the
13core I2C binding.
14
15Required properties:
16- compatible:
17 Array of strings.
18 One of:
19 - "nvidia,tegra186-bpmp-i2c".
20- #address-cells: Address cells for I2C device address.
21 Single-cell integer.
22 Must be <1>.
23- #size-cells:
24 Single-cell integer.
25 Must be <0>.
26- nvidia,bpmp-bus-id:
27 Single-cell integer.
28 Indicates the I2C bus number this DT node represent, as defined by the
29 BPMP firmware.
30
31Example:
32
33bpmp {
34 ...
35
36 i2c {
37 compatible = "nvidia,tegra186-bpmp-i2c";
38 #address-cells = <1>;
39 #size-cells = <0>;
40 nvidia,bpmp-bus-id = <5>;
41 };
42};
diff --git a/Documentation/devicetree/bindings/i2c/trivial-devices.txt b/Documentation/devicetree/bindings/i2c/trivial-devices.txt
index cdd7b48826c3..ad10fbe61562 100644
--- a/Documentation/devicetree/bindings/i2c/trivial-devices.txt
+++ b/Documentation/devicetree/bindings/i2c/trivial-devices.txt
@@ -36,6 +36,7 @@ dallas,ds1775 Tiny Digital Thermometer and Thermostat
36dallas,ds3232 Extremely Accurate I²C RTC with Integrated Crystal and SRAM 36dallas,ds3232 Extremely Accurate I²C RTC with Integrated Crystal and SRAM
37dallas,ds4510 CPU Supervisor with Nonvolatile Memory and Programmable I/O 37dallas,ds4510 CPU Supervisor with Nonvolatile Memory and Programmable I/O
38dallas,ds75 Digital Thermometer and Thermostat 38dallas,ds75 Digital Thermometer and Thermostat
39devantech,srf08 Devantech SRF08 ultrasonic ranger
39dlg,da9053 DA9053: flexible system level PMIC with multicore support 40dlg,da9053 DA9053: flexible system level PMIC with multicore support
40dlg,da9063 DA9063: system PMIC for quad-core application processors 41dlg,da9063 DA9063: system PMIC for quad-core application processors
41domintech,dmard09 DMARD09: 3-axis Accelerometer 42domintech,dmard09 DMARD09: 3-axis Accelerometer
diff --git a/Documentation/devicetree/bindings/iio/accel/lis302.txt b/Documentation/devicetree/bindings/iio/accel/lis302.txt
index 2a19bff9693f..dfdce67826ba 100644
--- a/Documentation/devicetree/bindings/iio/accel/lis302.txt
+++ b/Documentation/devicetree/bindings/iio/accel/lis302.txt
@@ -5,7 +5,7 @@ that apply in on the generic device (independent from the bus).
5 5
6 6
7Required properties for the SPI bindings: 7Required properties for the SPI bindings:
8 - compatible: should be set to "st,lis3lv02d_spi" 8 - compatible: should be set to "st,lis3lv02d-spi"
9 - reg: the chipselect index 9 - reg: the chipselect index
10 - spi-max-frequency: maximal bus speed, should be set to 1000000 unless 10 - spi-max-frequency: maximal bus speed, should be set to 1000000 unless
11 constrained by external circuitry 11 constrained by external circuitry
diff --git a/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt b/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt
new file mode 100644
index 000000000000..f9e3ff2c656e
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt
@@ -0,0 +1,32 @@
1* Amlogic Meson SAR (Successive Approximation Register) A/D converter
2
3Required properties:
4- compatible: depending on the SoC this should be one of:
5 - "amlogic,meson-gxbb-saradc" for GXBB
6 - "amlogic,meson-gxl-saradc" for GXL
7 - "amlogic,meson-gxm-saradc" for GXM
8 along with the generic "amlogic,meson-saradc"
9- reg: the physical base address and length of the registers
10- clocks: phandle and clock identifier (see clock-names)
11- clock-names: mandatory clocks:
12 - "clkin" for the reference clock (typically XTAL)
13 - "core" for the SAR ADC core clock
14 optional clocks:
15 - "sana" for the analog clock
16 - "adc_clk" for the ADC (sampling) clock
17 - "adc_sel" for the ADC (sampling) clock mux
18- vref-supply: the regulator supply for the ADC reference voltage
19- #io-channel-cells: must be 1, see ../iio-bindings.txt
20
21Example:
22 saradc: adc@8680 {
23 compatible = "amlogic,meson-gxl-saradc", "amlogic,meson-saradc";
24 #io-channel-cells = <1>;
25 reg = <0x0 0x8680 0x0 0x34>;
26 clocks = <&xtal>,
27 <&clkc CLKID_SAR_ADC>,
28 <&clkc CLKID_SANA>,
29 <&clkc CLKID_SAR_ADC_CLK>,
30 <&clkc CLKID_SAR_ADC_SEL>;
31 clock-names = "clkin", "core", "sana", "adc_clk", "adc_sel";
32 };
diff --git a/Documentation/devicetree/bindings/iio/adc/avia-hx711.txt b/Documentation/devicetree/bindings/iio/adc/avia-hx711.txt
new file mode 100644
index 000000000000..b3629405f568
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/avia-hx711.txt
@@ -0,0 +1,18 @@
1* AVIA HX711 ADC chip for weight cells
2 Bit-banging driver
3
4Required properties:
5 - compatible: Should be "avia,hx711"
6 - sck-gpios: Definition of the GPIO for the clock
7 - dout-gpios: Definition of the GPIO for data-out
8 See Documentation/devicetree/bindings/gpio/gpio.txt
9 - avdd-supply: Definition of the regulator used as analog supply
10
11Example:
12weight@0 {
13 compatible = "avia,hx711";
14 sck-gpios = <&gpio3 10 GPIO_ACTIVE_HIGH>;
15 dout-gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>;
16 avdd-suppy = <&avdd>;
17};
18
diff --git a/Documentation/devicetree/bindings/iio/adc/max11100.txt b/Documentation/devicetree/bindings/iio/adc/max11100.txt
new file mode 100644
index 000000000000..b7f7177b8aca
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/max11100.txt
@@ -0,0 +1,18 @@
1* Maxim max11100 Analog to Digital Converter (ADC)
2
3Required properties:
4 - compatible: Should be "maxim,max11100"
5 - reg: the adc unit address
6 - vref-supply: phandle to the regulator that provides reference voltage
7
8Optional properties:
9 - spi-max-frequency: SPI maximum frequency
10
11Example:
12
13max11100: adc@0 {
14 compatible = "maxim,max11100";
15 reg = <0>;
16 vref-supply = <&adc0_vref>;
17 spi-max-frequency = <240000>;
18};
diff --git a/Documentation/devicetree/bindings/iio/adc/qcom,pm8xxx-xoadc.txt b/Documentation/devicetree/bindings/iio/adc/qcom,pm8xxx-xoadc.txt
new file mode 100644
index 000000000000..53cd146d8096
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/qcom,pm8xxx-xoadc.txt
@@ -0,0 +1,149 @@
1Qualcomm's PM8xxx voltage XOADC
2
3The Qualcomm PM8xxx PMICs contain a HK/XO ADC (Housekeeping/Crystal
4oscillator ADC) encompassing PM8018, PM8038, PM8058 and PM8921.
5
6Required properties:
7
8- compatible: should be one of:
9 "qcom,pm8018-adc"
10 "qcom,pm8038-adc"
11 "qcom,pm8058-adc"
12 "qcom,pm8921-adc"
13
14- reg: should contain the ADC base address in the PMIC, typically
15 0x197.
16
17- xoadc-ref-supply: should reference a regulator that can supply
18 a reference voltage on demand. The reference voltage may vary
19 with PMIC variant but is typically something like 2.2 or 1.8V.
20
21The following required properties are standard for IO channels, see
22iio-bindings.txt for more details:
23
24- #address-cells: should be set to <1>
25
26- #size-cells: should be set to <0>
27
28- #io-channel-cells: should be set to <1>
29
30- interrupts: should refer to the parent PMIC interrupt controller
31 and reference the proper ADC interrupt.
32
33Required subnodes:
34
35The ADC channels are configured as subnodes of the ADC. Since some of
36them are used for calibrating the ADC, these nodes are compulsory:
37
38adc-channel@c {
39 reg = <0x0c>;
40};
41
42adc-channel@d {
43 reg = <0x0d>;
44};
45
46adc-channel@f {
47 reg = <0x0f>;
48};
49
50These three nodes are used for absolute and ratiometric calibration
51and only need to have these reg values: they are by hardware definition
521:1 ratio converters that sample 625, 1250 and 0 milliV and create
53an interpolation calibration for all other ADCs.
54
55Optional subnodes: any channels other than channel 0x0c, 0x0d and
560x0f are optional.
57
58Required channel node properties:
59
60- reg: should contain the hardware channel number in the range
61 0 .. 0x0f (4 bits). The hardware only supports 16 channels.
62
63Optional channel node properties:
64
65- qcom,decimation:
66 Value type: <u32>
67 Definition: This parameter is used to decrease the ADC sampling rate.
68 Quicker measurements can be made by reducing the decimation ratio.
69 Valid values are 512, 1024, 2048, 4096.
70 If the property is not found, a default value of 512 will be used.
71
72- qcom,ratiometric:
73 Value type: <u32>
74 Definition: Channel calibration type. If this property is specified
75 VADC will use a special voltage references for channel
76 calibration. The available references are specified in the
77 as a u32 value setting (see below) and it is compulsory
78 to also specify this reference if ratiometric calibration
79 is selected.
80
81 If the property is not found, the channel will be
82 calibrated with the 0.625V and 1.25V reference channels, also
83 known as an absolute calibration.
84 The reference voltage pairs when using ratiometric calibration:
85 0 = XO_IN/XOADC_GND
86 1 = PMIC_IN/XOADC_GND
87 2 = PMIC_IN/BMS_CSP
88 3 (invalid)
89 4 = XOADC_GND/XOADC_GND
90 5 = XOADC_VREF/XOADC_GND
91
92Example:
93
94xoadc: xoadc@197 {
95 compatible = "qcom,pm8058-adc";
96 reg = <0x197>;
97 interrupt-parent = <&pm8058>;
98 interrupts = <76 1>;
99 #address-cells = <1>;
100 #size-cells = <0>;
101 #io-channel-cells = <1>;
102
103 vcoin: adc-channel@0 {
104 reg = <0x00>;
105 };
106 vbat: adc-channel@1 {
107 reg = <0x01>;
108 };
109 dcin: adc-channel@2 {
110 reg = <0x02>;
111 };
112 ichg: adc-channel@3 {
113 reg = <0x03>;
114 };
115 vph_pwr: adc-channel@4 {
116 reg = <0x04>;
117 };
118 usb_vbus: adc-channel@a {
119 reg = <0x0a>;
120 };
121 die_temp: adc-channel@b {
122 reg = <0x0b>;
123 };
124 ref_625mv: adc-channel@c {
125 reg = <0x0c>;
126 };
127 ref_1250mv: adc-channel@d {
128 reg = <0x0d>;
129 };
130 ref_325mv: adc-channel@e {
131 reg = <0x0e>;
132 };
133 ref_muxoff: adc-channel@f {
134 reg = <0x0f>;
135 };
136};
137
138
139/* IIO client node */
140iio-hwmon {
141 compatible = "iio-hwmon";
142 io-channels = <&xoadc 0x01>, /* Battery */
143 <&xoadc 0x02>, /* DC in (charger) */
144 <&xoadc 0x04>, /* VPH the main system voltage */
145 <&xoadc 0x0b>, /* Die temperature */
146 <&xoadc 0x0c>, /* Reference voltage 1.25V */
147 <&xoadc 0x0d>, /* Reference voltage 0.625V */
148 <&xoadc 0x0e>; /* Reference voltage 0.325V */
149};
diff --git a/Documentation/devicetree/bindings/iio/adc/renesas,gyroadc.txt b/Documentation/devicetree/bindings/iio/adc/renesas,gyroadc.txt
new file mode 100644
index 000000000000..f5b0adae6010
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/renesas,gyroadc.txt
@@ -0,0 +1,99 @@
1* Renesas RCar GyroADC device driver
2
3The GyroADC block is a reduced SPI block with up to 8 chipselect lines,
4which supports the SPI protocol of a selected few SPI ADCs. The SPI ADCs
5are sampled by the GyroADC block in a round-robin fashion and the result
6presented in the GyroADC registers.
7
8Required properties:
9- compatible: Should be "<soc-specific>", "renesas,rcar-gyroadc".
10 The <soc-specific> should be one of:
11 renesas,r8a7791-gyroadc - for the GyroADC block present
12 in r8a7791 SoC
13 renesas,r8a7792-gyroadc - for the GyroADC with interrupt
14 block present in r8a7792 SoC
15- reg: Address and length of the register set for the device
16- clocks: References to all the clocks specified in the clock-names
17 property as specified in
18 Documentation/devicetree/bindings/clock/clock-bindings.txt.
19- clock-names: Shall contain "fck" and "if". The "fck" is the GyroADC block
20 clock, the "if" is the interface clock.
21- power-domains: Must contain a reference to the PM domain, if available.
22- #address-cells: Should be <1> (setting for the subnodes) for all ADCs
23 except for "fujitsu,mb88101a". Should be <0> (setting for
24 only subnode) for "fujitsu,mb88101a".
25- #size-cells: Should be <0> (setting for the subnodes)
26
27Sub-nodes:
28You must define subnode(s) which select the connected ADC type and reference
29voltage for the GyroADC channels.
30
31Required properties for subnodes:
32- compatible: Should be either of:
33 "fujitsu,mb88101a"
34 - Fujitsu MB88101A compatible mode,
35 12bit sampling, up to 4 channels can be sampled in
36 round-robin fashion. One Fujitsu chip supplies four
37 GyroADC channels with data as it contains four ADCs
38 on the chip and thus for 4-channel operation, single
39 MB88101A is required. The Cx chipselect lines of the
40 MB88101A connect directly to two CHS lines of the
41 GyroADC, no demuxer is required. The data out line
42 of each MB88101A connects to a shared input pin of
43 the GyroADC.
44 "ti,adcs7476" or "ti,adc121" or "adi,ad7476"
45 - TI ADCS7476 / TI ADC121 / ADI AD7476 compatible mode,
46 15bit sampling, up to 8 channels can be sampled in
47 round-robin fashion. One TI/ADI chip supplies single
48 ADC channel with data, thus for 8-channel operation,
49 8 chips are required. A 3:8 chipselect demuxer is
50 required to connect the nCS line of the TI/ADI chips
51 to the GyroADC, while MISO line of each TI/ADI ADC
52 connects to a shared input pin of the GyroADC.
53 "maxim,max1162" or "maxim,max11100"
54 - Maxim MAX1162 / Maxim MAX11100 compatible mode,
55 16bit sampling, up to 8 channels can be sampled in
56 round-robin fashion. One Maxim chip supplies single
57 ADC channel with data, thus for 8-channel operation,
58 8 chips are required. A 3:8 chipselect demuxer is
59 required to connect the nCS line of the MAX chips
60 to the GyroADC, while MISO line of each Maxim ADC
61 connects to a shared input pin of the GyroADC.
62- reg: Should be the number of the analog input. Should be present
63 for all ADCs except "fujitsu,mb88101a".
64- vref-supply: Reference to the channel reference voltage regulator.
65
66Example:
67 vref_max1162: regulator-vref-max1162 {
68 compatible = "regulator-fixed";
69
70 regulator-name = "MAX1162 Vref";
71 regulator-min-microvolt = <4096000>;
72 regulator-max-microvolt = <4096000>;
73 };
74
75 adc@e6e54000 {
76 compatible = "renesas,r8a7791-gyroadc", "renesas,rcar-gyroadc";
77 reg = <0 0xe6e54000 0 64>;
78 clocks = <&mstp9_clks R8A7791_CLK_GYROADC>, <&clk_65m>;
79 clock-names = "fck", "if";
80 power-domains = <&sysc R8A7791_PD_ALWAYS_ON>;
81
82 pinctrl-0 = <&adc_pins>;
83 pinctrl-names = "default";
84
85 #address-cells = <1>;
86 #size-cells = <0>;
87
88 adc@0 {
89 reg = <0>;
90 compatible = "maxim,max1162";
91 vref-supply = <&vref_max1162>;
92 };
93
94 adc@1 {
95 reg = <1>;
96 compatible = "maxim,max1162";
97 vref-supply = <&vref_max1162>;
98 };
99 };
diff --git a/Documentation/devicetree/bindings/iio/adc/st,stm32-adc.txt b/Documentation/devicetree/bindings/iio/adc/st,stm32-adc.txt
index 49ed82e89870..5dfc88ec24a4 100644
--- a/Documentation/devicetree/bindings/iio/adc/st,stm32-adc.txt
+++ b/Documentation/devicetree/bindings/iio/adc/st,stm32-adc.txt
@@ -53,6 +53,11 @@ Required properties:
53- #io-channel-cells = <1>: See the IIO bindings section "IIO consumers" in 53- #io-channel-cells = <1>: See the IIO bindings section "IIO consumers" in
54 Documentation/devicetree/bindings/iio/iio-bindings.txt 54 Documentation/devicetree/bindings/iio/iio-bindings.txt
55 55
56Optional properties:
57- dmas: Phandle to dma channel for this ADC instance.
58 See ../../dma/dma.txt for details.
59- dma-names: Must be "rx" when dmas property is being used.
60
56Example: 61Example:
57 adc: adc@40012000 { 62 adc: adc@40012000 {
58 compatible = "st,stm32f4-adc-core"; 63 compatible = "st,stm32f4-adc-core";
@@ -77,6 +82,8 @@ Example:
77 interrupt-parent = <&adc>; 82 interrupt-parent = <&adc>;
78 interrupts = <0>; 83 interrupts = <0>;
79 st,adc-channels = <8>; 84 st,adc-channels = <8>;
85 dmas = <&dma2 0 0 0x400 0x0>;
86 dma-names = "rx";
80 }; 87 };
81 ... 88 ...
82 other adc child nodes follow... 89 other adc child nodes follow...
diff --git a/Documentation/devicetree/bindings/iio/adc/ti-ads7950.txt b/Documentation/devicetree/bindings/iio/adc/ti-ads7950.txt
new file mode 100644
index 000000000000..e77a6f7e1001
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/ti-ads7950.txt
@@ -0,0 +1,23 @@
1* Texas Instruments ADS7950 family of A/DC chips
2
3Required properties:
4 - compatible: Must be one of "ti,ads7950", "ti,ads7951", "ti,ads7952",
5 "ti,ads7953", "ti,ads7954", "ti,ads7955", "ti,ads7956", "ti,ads7957",
6 "ti,ads7958", "ti,ads7959", "ti,ads7960", or "ti,ads7961"
7 - reg: SPI chip select number for the device
8 - #io-channel-cells: Must be 1 as per ../iio-bindings.txt
9 - vref-supply: phandle to a regulator node that supplies the 2.5V or 5V
10 reference voltage
11
12Recommended properties:
13 - spi-max-frequency: Definition as per
14 Documentation/devicetree/bindings/spi/spi-bus.txt
15
16Example:
17adc@0 {
18 compatible = "ti,ads7957";
19 reg = <0>;
20 #io-channel-cells = <1>;
21 vref-supply = <&refin_supply>;
22 spi-max-frequency = <10000000>;
23};
diff --git a/Documentation/devicetree/bindings/iio/imu/bmi160.txt b/Documentation/devicetree/bindings/iio/imu/bmi160.txt
new file mode 100644
index 000000000000..ae0112c7debc
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/imu/bmi160.txt
@@ -0,0 +1,36 @@
1Bosch BMI160 - Inertial Measurement Unit with Accelerometer, Gyroscope
2and externally connectable Magnetometer
3
4https://www.bosch-sensortec.com/bst/products/all_products/bmi160
5
6Required properties:
7 - compatible : should be "bosch,bmi160"
8 - reg : the I2C address or SPI chip select number of the sensor
9 - spi-max-frequency : set maximum clock frequency (only for SPI)
10
11Optional properties:
12 - interrupt-parent : should be the phandle of the interrupt controller
13 - interrupts : interrupt mapping for IRQ, must be IRQ_TYPE_LEVEL_LOW
14 - interrupt-names : set to "INT1" if INT1 pin should be used as interrupt
15 input, set to "INT2" if INT2 pin should be used instead
16
17Examples:
18
19bmi160@68 {
20 compatible = "bosch,bmi160";
21 reg = <0x68>;
22
23 interrupt-parent = <&gpio4>;
24 interrupts = <12 IRQ_TYPE_LEVEL_LOW>;
25 interrupt-names = "INT1";
26};
27
28bmi160@0 {
29 compatible = "bosch,bmi160";
30 reg = <0>;
31 spi-max-frequency = <10000000>;
32
33 interrupt-parent = <&gpio2>;
34 interrupts = <12 IRQ_TYPE_LEVEL_LOW>;
35 interrupt-names = "INT2";
36};
diff --git a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
new file mode 100644
index 000000000000..cf81afdf7803
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
@@ -0,0 +1,26 @@
1* ST_LSM6DSx driver for STM 6-axis (acc + gyro) imu Mems sensors
2
3Required properties:
4- compatible: must be one of:
5 "st,lsm6ds3"
6 "st,lsm6dsm"
7- reg: i2c address of the sensor / spi cs line
8
9Optional properties:
10- st,drdy-int-pin: the pin on the package that will be used to signal
11 "data ready" (valid values: 1 or 2).
12- interrupt-parent: should be the phandle for the interrupt controller
13- interrupts: interrupt mapping for IRQ. It should be configured with
14 flags IRQ_TYPE_LEVEL_HIGH or IRQ_TYPE_EDGE_RISING.
15
16 Refer to interrupt-controller/interrupts.txt for generic interrupt
17 client node bindings.
18
19Example:
20
21lsm6dsm@6b {
22 compatible = "st,lsm6dsm";
23 reg = <0x6b>;
24 interrupt-parent = <&gpio0>;
25 interrupts = <0 IRQ_TYPE_EDGE_RISING>;
26};
diff --git a/Documentation/devicetree/bindings/iio/light/cm3605.txt b/Documentation/devicetree/bindings/iio/light/cm3605.txt
new file mode 100644
index 000000000000..56331a79f9ab
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/light/cm3605.txt
@@ -0,0 +1,41 @@
1Capella Microsystems CM3605
2Ambient Light and Short Distance Proximity Sensor
3
4The CM3605 is an entirely analog part which however require quite a bit of
5software logic to interface a host operating system.
6
7This ALS and proximity sensor was one of the very first deployed in mobile
8handsets, notably it is used in the very first Nexus One Android phone from
92010.
10
11Required properties:
12- compatible: must be: "capella,cm3605"
13- aset-gpios: GPIO line controlling the ASET line (drive low
14 to activate the ALS, should be flagged GPIO_ACTIVE_LOW)
15- interrupts: the IRQ line (such as a GPIO) that is connected to
16 the POUT (proximity sensor out) line. The edge detection must
17 be set to IRQ_TYPE_EDGE_BOTH so as to detect movements toward
18 and away from the proximity sensor.
19- io-channels: the ADC channel used for converting the voltage from
20 AOUT to a digital representation.
21- io-channel-names: must be "aout"
22
23Optional properties:
24- vdd-supply: regulator supplying VDD power to the component.
25- capella,aset-resistance-ohms: the sensitivity calibration resistance,
26 in Ohms. Valid values are: 50000, 100000, 300000 and 600000,
27 as these are the resistance values that we are supplied with
28 calibration curves for. If not supplied, 100 kOhm will be assumed
29 but it is strongly recommended to supply this.
30
31Example:
32
33cm3605 {
34 compatible = "capella,cm3605";
35 vdd-supply = <&foo_reg>;
36 aset-gpios = <&foo_gpio 1 GPIO_ACTIVE_LOW>;
37 capella,aset-resistance-ohms = <100000>;
38 interrupts = <1 IRQ_TYPE_EDGE_BOTH>;
39 io-channels = <&adc 0x01>;
40 io-channel-names = "aout";
41};
diff --git a/Documentation/devicetree/bindings/iio/potentiometer/max5481.txt b/Documentation/devicetree/bindings/iio/potentiometer/max5481.txt
new file mode 100644
index 000000000000..6a91b106e076
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/potentiometer/max5481.txt
@@ -0,0 +1,23 @@
1* Maxim Linear-Taper Digital Potentiometer MAX5481-MAX5484
2
3The node for this driver must be a child node of a SPI controller, hence
4all mandatory properties described in
5
6 Documentation/devicetree/bindings/spi/spi-bus.txt
7
8must be specified.
9
10Required properties:
11 - compatible: Must be one of the following, depending on the
12 model:
13 "maxim,max5481"
14 "maxim,max5482"
15 "maxim,max5483"
16 "maxim,max5484"
17
18Example:
19max548x: max548x@0 {
20 compatible = "maxim,max5482";
21 spi-max-frequency = <7000000>;
22 reg = <0>; /* chip-select */
23};
diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
index c040c9ad1889..eaa8fbba34e2 100644
--- a/Documentation/devicetree/bindings/iio/st-sensors.txt
+++ b/Documentation/devicetree/bindings/iio/st-sensors.txt
@@ -27,6 +27,8 @@ standard bindings from pinctrl/pinctrl-bindings.txt.
27Valid compatible strings: 27Valid compatible strings:
28 28
29Accelerometers: 29Accelerometers:
30- st,lis3lv02d (deprecated, use st,lis3lv02dl-accel)
31- st,lis302dl-spi (deprecated, use st,lis3lv02dl-accel)
30- st,lis3lv02dl-accel 32- st,lis3lv02dl-accel
31- st,lsm303dlh-accel 33- st,lsm303dlh-accel
32- st,lsm303dlhc-accel 34- st,lsm303dlhc-accel
diff --git a/Documentation/devicetree/bindings/iio/temperature/tmp007.txt b/Documentation/devicetree/bindings/iio/temperature/tmp007.txt
new file mode 100644
index 000000000000..b63aba91ef03
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/temperature/tmp007.txt
@@ -0,0 +1,35 @@
1* TI TMP007 - IR thermopile sensor with integrated math engine
2
3Link to datasheet: http://www.ti.com/lit/ds/symlink/tmp007.pdf
4
5Required properties:
6
7 - compatible: should be "ti,tmp007"
8 - reg: the I2C address of the sensor (changeable via ADR pins)
9 ------------------------------
10 |ADR1 | ADR0 | Device Address|
11 ------------------------------
12 0 0 0x40
13 0 1 0x41
14 0 SDA 0x42
15 0 SCL 0x43
16 1 0 0x44
17 1 1 0x45
18 1 SDA 0x46
19 1 SCL 0x47
20
21Optional properties:
22
23 - interrupt-parent: should be the phandle for the interrupt controller
24
25 - interrupts: interrupt mapping for GPIO IRQ (level active low)
26
27Example:
28
29tmp007@40 {
30 compatible = "ti,tmp007";
31 reg = <0x40>;
32 interrupt-parent = <&gpio0>;
33 interrupts = <5 0x08>;
34};
35
diff --git a/Documentation/devicetree/bindings/iio/timer/stm32-timer-trigger.txt b/Documentation/devicetree/bindings/iio/timer/stm32-timer-trigger.txt
new file mode 100644
index 000000000000..55a653d15303
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/timer/stm32-timer-trigger.txt
@@ -0,0 +1,23 @@
1STMicroelectronics STM32 Timers IIO timer bindings
2
3Must be a sub-node of an STM32 Timers device tree node.
4See ../mfd/stm32-timers.txt for details about the parent node.
5
6Required parameters:
7- compatible: Must be "st,stm32-timer-trigger".
8- reg: Identify trigger hardware block.
9
10Example:
11 timers@40010000 {
12 #address-cells = <1>;
13 #size-cells = <0>;
14 compatible = "st,stm32-timers";
15 reg = <0x40010000 0x400>;
16 clocks = <&rcc 0 160>;
17 clock-names = "clk_int";
18
19 timer@0 {
20 compatible = "st,stm32-timer-trigger";
21 reg = <0>;
22 };
23 };
diff --git a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
new file mode 100644
index 000000000000..635f62c756ee
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
@@ -0,0 +1,27 @@
1Samsung tm2-touchkey
2
3Required properties:
4- compatible: must be "cypress,tm2-touchkey"
5- reg: I2C address of the chip.
6- interrupt-parent: a phandle for the interrupt controller (see interrupt
7 binding[0]).
8- interrupts: interrupt to which the chip is connected (see interrupt
9 binding[0]).
10- vcc-supply : internal regulator output. 1.8V
11- vdd-supply : power supply for IC 3.3V
12
13[0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
14
15Example:
16 &i2c0 {
17 /* ... */
18
19 touchkey@20 {
20 compatible = "cypress,tm2-touchkey";
21 reg = <0x20>;
22 interrupt-parent = <&gpa3>;
23 interrupts = <2 IRQ_TYPE_EDGE_FALLING>;
24 vcc-supply=<&ldo32_reg>;
25 vdd-supply=<&ldo33_reg>;
26 };
27 };
diff --git a/Documentation/devicetree/bindings/input/mpr121-touchkey.txt b/Documentation/devicetree/bindings/input/mpr121-touchkey.txt
new file mode 100644
index 000000000000..b7c61ee5841b
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/mpr121-touchkey.txt
@@ -0,0 +1,30 @@
1* Freescale MPR121 Controllor
2
3Required Properties:
4- compatible: Should be "fsl,mpr121-touchkey"
5- reg: The I2C slave address of the device.
6- interrupts: The interrupt number to the cpu.
7- vdd-supply: Phandle to the Vdd power supply.
8- linux,keycodes: Specifies an array of numeric keycode values to
9 be used for reporting button presses. The array can
10 contain up to 12 entries.
11
12Optional Properties:
13- wakeup-source: Use any event on keypad as wakeup event.
14- autorepeat: Enable autorepeat feature.
15
16Example:
17
18#include "dt-bindings/input/input.h"
19
20 touchkey: mpr121@5a {
21 compatible = "fsl,mpr121-touchkey";
22 reg = <0x5a>;
23 interrupt-parent = <&gpio1>;
24 interrupts = <28 2>;
25 autorepeat;
26 vdd-supply = <&ldo4_reg>;
27 linux,keycodes = <KEY_0>, <KEY_1>, <KEY_2>, <KEY_3>,
28 <KEY_4> <KEY_5>, <KEY_6>, <KEY_7>,
29 <KEY_8>, <KEY_9>, <KEY_A>, <KEY_B>;
30 };
diff --git a/Documentation/devicetree/bindings/input/pwm-beeper.txt b/Documentation/devicetree/bindings/input/pwm-beeper.txt
index be332ae4f2d6..529408b4431a 100644
--- a/Documentation/devicetree/bindings/input/pwm-beeper.txt
+++ b/Documentation/devicetree/bindings/input/pwm-beeper.txt
@@ -5,3 +5,19 @@ Registers a PWM device as beeper.
5Required properties: 5Required properties:
6- compatible: should be "pwm-beeper" 6- compatible: should be "pwm-beeper"
7- pwms: phandle to the physical PWM device 7- pwms: phandle to the physical PWM device
8
9Optional properties:
10- amp-supply: phandle to a regulator that acts as an amplifier for the beeper
11
12Example:
13
14beeper_amp: amplifier {
15 compatible = "fixed-regulator";
16 gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>;
17};
18
19beeper {
20 compatible = "pwm-beeper";
21 pwms = <&pwm0>;
22 amp-supply = <&beeper_amp>;
23};
diff --git a/Documentation/devicetree/bindings/input/touchscreen/zet6223.txt b/Documentation/devicetree/bindings/input/touchscreen/zet6223.txt
new file mode 100644
index 000000000000..fe6a1feef703
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/zet6223.txt
@@ -0,0 +1,32 @@
1Zeitec ZET6223 I2C touchscreen controller
2
3Required properties:
4- compatible : "zeitec,zet6223"
5- reg : I2C slave address of the chip (0x76)
6- interrupt-parent : a phandle pointing to the interrupt controller
7 serving the interrupt for this chip
8- interrupts : interrupt specification for the zet6223 interrupt
9
10Optional properties:
11
12- vio-supply : Specification for VIO supply (1.8V or 3.3V,
13 depending on system interface needs).
14- vcc-supply : Specification for 3.3V VCC supply.
15- touchscreen-size-x : See touchscreen.txt
16- touchscreen-size-y : See touchscreen.txt
17- touchscreen-inverted-x : See touchscreen.txt
18- touchscreen-inverted-y : See touchscreen.txt
19- touchscreen-swapped-x-y : See touchscreen.txt
20
21Example:
22
23i2c@00000000 {
24
25 zet6223: touchscreen@76 {
26 compatible = "zeitec,zet6223";
27 reg = <0x76>;
28 interrupt-parent = <&pio>;
29 interrupts = <6 11 IRQ_TYPE_EDGE_FALLING>
30 };
31
32};
diff --git a/Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt b/Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt
index 5393e2a45a42..560d8a727b8f 100644
--- a/Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt
+++ b/Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt
@@ -111,7 +111,7 @@ Example:
111 #interrupt-cells = <3>; 111 #interrupt-cells = <3>;
112 interrupt-controller; 112 interrupt-controller;
113 reg = <0x2c001000 0x1000>, 113 reg = <0x2c001000 0x1000>,
114 <0x2c002000 0x1000>, 114 <0x2c002000 0x2000>,
115 <0x2c004000 0x2000>, 115 <0x2c004000 0x2000>,
116 <0x2c006000 0x2000>; 116 <0x2c006000 0x2000>;
117 interrupts = <1 9 0xf04>; 117 interrupts = <1 9 0xf04>;
diff --git a/Documentation/devicetree/bindings/interrupt-controller/snps,archs-idu-intc.txt b/Documentation/devicetree/bindings/interrupt-controller/snps,archs-idu-intc.txt
index 944657684d73..8b46a34e05f1 100644
--- a/Documentation/devicetree/bindings/interrupt-controller/snps,archs-idu-intc.txt
+++ b/Documentation/devicetree/bindings/interrupt-controller/snps,archs-idu-intc.txt
@@ -8,15 +8,11 @@ Properties:
8- compatible: "snps,archs-idu-intc" 8- compatible: "snps,archs-idu-intc"
9- interrupt-controller: This is an interrupt controller. 9- interrupt-controller: This is an interrupt controller.
10- interrupt-parent: <reference to parent core intc> 10- interrupt-parent: <reference to parent core intc>
11- #interrupt-cells: Must be <2>. 11- #interrupt-cells: Must be <1>.
12- interrupts: <...> specifies the upstream core irqs
13 12
14 First cell specifies the "common" IRQ from peripheral to IDU 13 Value of the cell specifies the "common" IRQ from peripheral to IDU. Number N
15 Second cell specifies the irq distribution mode to cores 14 of the particular interrupt line of IDU corresponds to the line N+24 of the
16 0=Round Robin; 1=cpu0, 2=cpu1, 4=cpu2, 8=cpu3 15 core interrupt controller.
17
18 The second cell in interrupts property is deprecated and may be ignored by
19 the kernel.
20 16
21 intc accessed via the special ARC AUX register interface, hence "reg" property 17 intc accessed via the special ARC AUX register interface, hence "reg" property
22 is not specified. 18 is not specified.
@@ -32,18 +28,10 @@ Example:
32 compatible = "snps,archs-idu-intc"; 28 compatible = "snps,archs-idu-intc";
33 interrupt-controller; 29 interrupt-controller;
34 interrupt-parent = <&core_intc>; 30 interrupt-parent = <&core_intc>;
35 31 #interrupt-cells = <1>;
36 /*
37 * <hwirq distribution>
38 * distribution: 0=RR; 1=cpu0, 2=cpu1, 4=cpu2, 8=cpu3
39 */
40 #interrupt-cells = <2>;
41
42 /* upstream core irqs: downstream these are "COMMON" irq 0,1.. */
43 interrupts = <24 25 26 27 28 29 30 31>;
44 }; 32 };
45 33
46 some_device: serial@c0fc1000 { 34 some_device: serial@c0fc1000 {
47 interrupt-parent = <&idu_intc>; 35 interrupt-parent = <&idu_intc>;
48 interrupts = <0 0>; /* upstream idu IRQ #24, Round Robin */ 36 interrupts = <0>; /* upstream idu IRQ #24 */
49 }; 37 };
diff --git a/Documentation/devicetree/bindings/iommu/arm,smmu.txt b/Documentation/devicetree/bindings/iommu/arm,smmu.txt
index e862d1485205..6cdf32d037fc 100644
--- a/Documentation/devicetree/bindings/iommu/arm,smmu.txt
+++ b/Documentation/devicetree/bindings/iommu/arm,smmu.txt
@@ -36,15 +36,15 @@ conditions.
36 combined interrupt, it must be listed multiple times. 36 combined interrupt, it must be listed multiple times.
37 37
38- #iommu-cells : See Documentation/devicetree/bindings/iommu/iommu.txt 38- #iommu-cells : See Documentation/devicetree/bindings/iommu/iommu.txt
39 for details. With a value of 1, each "iommus" entry 39 for details. With a value of 1, each IOMMU specifier
40 represents a distinct stream ID emitted by that device 40 represents a distinct stream ID emitted by that device
41 into the relevant SMMU. 41 into the relevant SMMU.
42 42
43 SMMUs with stream matching support and complex masters 43 SMMUs with stream matching support and complex masters
44 may use a value of 2, where the second cell represents 44 may use a value of 2, where the second cell of the
45 an SMR mask to combine with the ID in the first cell. 45 IOMMU specifier represents an SMR mask to combine with
46 Care must be taken to ensure the set of matched IDs 46 the ID in the first cell. Care must be taken to ensure
47 does not result in conflicts. 47 the set of matched IDs does not result in conflicts.
48 48
49** System MMU optional properties: 49** System MMU optional properties:
50 50
diff --git a/Documentation/devicetree/bindings/mfd/as3722.txt b/Documentation/devicetree/bindings/mfd/as3722.txt
index 4f64b2a73169..0b2a6099aa20 100644
--- a/Documentation/devicetree/bindings/mfd/as3722.txt
+++ b/Documentation/devicetree/bindings/mfd/as3722.txt
@@ -122,8 +122,7 @@ Following are properties of regulator subnode.
122 122
123Power-off: 123Power-off:
124========= 124=========
125AS3722 supports the system power off by turning off all its rail. This 125AS3722 supports the system power off by turning off all its rails.
126is provided through pm_power_off.
127The device node should have the following properties to enable this 126The device node should have the following properties to enable this
128functionality 127functionality
129ams,system-power-controller: Boolean, to enable the power off functionality 128ams,system-power-controller: Boolean, to enable the power off functionality
diff --git a/Documentation/devicetree/bindings/mfd/aspeed-gfx.txt b/Documentation/devicetree/bindings/mfd/aspeed-gfx.txt
new file mode 100644
index 000000000000..aea5370efd97
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/aspeed-gfx.txt
@@ -0,0 +1,17 @@
1* Device tree bindings for Aspeed SoC Display Controller (GFX)
2
3The Aspeed SoC Display Controller primarily does as its name suggests, but also
4participates in pinmux requests on the g5 SoCs. It is therefore considered a
5syscon device.
6
7Required properties:
8- compatible: "aspeed,ast2500-gfx", "syscon"
9- reg: contains offset/length value of the GFX memory
10 region.
11
12Example:
13
14gfx: display@1e6e6000 {
15 compatible = "aspeed,ast2500-gfx", "syscon";
16 reg = <0x1e6e6000 0x1000>;
17};
diff --git a/Documentation/devicetree/bindings/mfd/aspeed-lpc.txt b/Documentation/devicetree/bindings/mfd/aspeed-lpc.txt
new file mode 100644
index 000000000000..514d82ced95b
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/aspeed-lpc.txt
@@ -0,0 +1,137 @@
1======================================================================
2Device tree bindings for the Aspeed Low Pin Count (LPC) Bus Controller
3======================================================================
4
5The LPC bus is a means to bridge a host CPU to a number of low-bandwidth
6peripheral devices, replacing the use of the ISA bus in the age of PCI[0]. The
7primary use case of the Aspeed LPC controller is as a slave on the bus
8(typically in a Baseboard Management Controller SoC), but under certain
9conditions it can also take the role of bus master.
10
11The LPC controller is represented as a multi-function device to account for the
12mix of functionality it provides. The principle split is between the register
13layout at the start of the I/O space which is, to quote the Aspeed datasheet,
14"basically compatible with the [LPC registers from the] popular BMC controller
15H8S/2168[1]", and everything else, where everything else is an eclectic
16collection of functions with a esoteric register layout. "Everything else",
17here labeled the "host" portion of the controller, includes, but is not limited
18to:
19
20* An IPMI Block Transfer[2] Controller
21
22* An LPC Host Controller: Manages LPC functions such as host vs slave mode, the
23 physical properties of some LPC pins, configuration of serial IRQs, and
24 APB-to-LPC bridging amonst other functions.
25
26* An LPC Host Interface Controller: Manages functions exposed to the host such
27 as LPC firmware hub cycles, configuration of the LPC-to-AHB mapping, UART
28 management and bus snoop configuration.
29
30* A set of SuperIO[3] scratch registers: Enables implementation of e.g. custom
31 hardware management protocols for handover between the host and baseboard
32 management controller.
33
34Additionally the state of the LPC controller influences the pinmux
35configuration, therefore the host portion of the controller is exposed as a
36syscon as a means to arbitrate access.
37
38[0] http://www.intel.com/design/chipsets/industry/25128901.pdf
39[1] https://www.renesas.com/en-sg/doc/products/mpumcu/001/rej09b0078_h8s2168.pdf?key=7c88837454702128622bee53acbda8f4
40[2] http://www.intel.com/content/dam/www/public/us/en/documents/product-briefs/ipmi-second-gen-interface-spec-v2-rev1-1.pdf
41[3] https://en.wikipedia.org/wiki/Super_I/O
42
43Required properties
44===================
45
46- compatible: One of:
47 "aspeed,ast2400-lpc", "simple-mfd"
48 "aspeed,ast2500-lpc", "simple-mfd"
49
50- reg: contains the physical address and length values of the Aspeed
51 LPC memory region.
52
53- #address-cells: <1>
54- #size-cells: <1>
55- ranges: Maps 0 to the physical address and length of the LPC memory
56 region
57
58Required LPC Child nodes
59========================
60
61BMC Node
62--------
63
64- compatible: One of:
65 "aspeed,ast2400-lpc-bmc"
66 "aspeed,ast2500-lpc-bmc"
67
68- reg: contains the physical address and length values of the
69 H8S/2168-compatible LPC controller memory region
70
71Host Node
72---------
73
74- compatible: One of:
75 "aspeed,ast2400-lpc-host", "simple-mfd", "syscon"
76 "aspeed,ast2500-lpc-host", "simple-mfd", "syscon"
77
78- reg: contains the address and length values of the host-related
79 register space for the Aspeed LPC controller
80
81- #address-cells: <1>
82- #size-cells: <1>
83- ranges: Maps 0 to the address and length of the host-related LPC memory
84 region
85
86Example:
87
88lpc: lpc@1e789000 {
89 compatible = "aspeed,ast2500-lpc", "simple-mfd";
90 reg = <0x1e789000 0x1000>;
91
92 #address-cells = <1>;
93 #size-cells = <1>;
94 ranges = <0x0 0x1e789000 0x1000>;
95
96 lpc_bmc: lpc-bmc@0 {
97 compatible = "aspeed,ast2500-lpc-bmc";
98 reg = <0x0 0x80>;
99 };
100
101 lpc_host: lpc-host@80 {
102 compatible = "aspeed,ast2500-lpc-host", "simple-mfd", "syscon";
103 reg = <0x80 0x1e0>;
104 reg-io-width = <4>;
105
106 #address-cells = <1>;
107 #size-cells = <1>;
108 ranges = <0x0 0x80 0x1e0>;
109 };
110};
111
112Host Node Children
113==================
114
115LPC Host Controller
116-------------------
117
118The Aspeed LPC Host Controller configures the Low Pin Count (LPC) bus behaviour
119between the host and the baseboard management controller. The registers exist
120in the "host" portion of the Aspeed LPC controller, which must be the parent of
121the LPC host controller node.
122
123Required properties:
124
125- compatible: One of:
126 "aspeed,ast2400-lhc";
127 "aspeed,ast2500-lhc";
128
129- reg: contains offset/length values of the LHC memory regions. In the
130 AST2400 and AST2500 there are two regions.
131
132Example:
133
134lhc: lhc@20 {
135 compatible = "aspeed,ast2500-lhc";
136 reg = <0x20 0x24 0x48 0x8>;
137};
diff --git a/Documentation/devicetree/bindings/mfd/mfd.txt b/Documentation/devicetree/bindings/mfd/mfd.txt
index af9d6931a1a2..bcb6abb9d413 100644
--- a/Documentation/devicetree/bindings/mfd/mfd.txt
+++ b/Documentation/devicetree/bindings/mfd/mfd.txt
@@ -19,12 +19,22 @@ Optional properties:
19 19
20- compatible : "simple-mfd" - this signifies that the operating system should 20- compatible : "simple-mfd" - this signifies that the operating system should
21 consider all subnodes of the MFD device as separate devices akin to how 21 consider all subnodes of the MFD device as separate devices akin to how
22 "simple-bus" inidicates when to see subnodes as children for a simple 22 "simple-bus" indicates when to see subnodes as children for a simple
23 memory-mapped bus. For more complex devices, when the nexus driver has to 23 memory-mapped bus. For more complex devices, when the nexus driver has to
24 probe registers to figure out what child devices exist etc, this should not 24 probe registers to figure out what child devices exist etc, this should not
25 be used. In the latter case the child devices will be determined by the 25 be used. In the latter case the child devices will be determined by the
26 operating system. 26 operating system.
27 27
28- ranges: Describes the address mapping relationship to the parent. Should set
29 the child's base address to 0, the physical address within parent's address
30 space, and the length of the address map.
31
32- #address-cells: Specifies the number of cells used to represent physical base
33 addresses. Must be present if ranges is used.
34
35- #size-cells: Specifies the number of cells used to represent the size of an
36 address. Must be present if ranges is used.
37
28Example: 38Example:
29 39
30foo@1000 { 40foo@1000 {
diff --git a/Documentation/devicetree/bindings/mfd/motorola-cpcap.txt b/Documentation/devicetree/bindings/mfd/motorola-cpcap.txt
new file mode 100644
index 000000000000..15bc885f9df4
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/motorola-cpcap.txt
@@ -0,0 +1,31 @@
1Motorola CPCAP PMIC device tree binding
2
3Required properties:
4- compatible : One or both of "motorola,cpcap" or "ste,6556002"
5- reg : SPI chip select
6- interrupt-parent : The parent interrupt controller
7- interrupts : The interrupt line the device is connected to
8- interrupt-controller : Marks the device node as an interrupt controller
9- #interrupt-cells : The number of cells to describe an IRQ, should be 2
10- #address-cells : Child device offset number of cells, should be 1
11- #size-cells : Child device size number of cells, should be 0
12- spi-max-frequency : Typically set to 3000000
13- spi-cs-high : SPI chip select direction
14
15Example:
16
17&mcspi1 {
18 cpcap: pmic@0 {
19 compatible = "motorola,cpcap", "ste,6556002";
20 reg = <0>; /* cs0 */
21 interrupt-parent = <&gpio1>;
22 interrupts = <7 IRQ_TYPE_EDGE_RISING>;
23 interrupt-controller;
24 #interrupt-cells = <2>;
25 #address-cells = <1>;
26 #size-cells = <0>;
27 spi-max-frequency = <3000000>;
28 spi-cs-high;
29 };
30};
31
diff --git a/Documentation/devicetree/bindings/mfd/mt6397.txt b/Documentation/devicetree/bindings/mfd/mt6397.txt
index 949c85f8d02c..c568d52af5af 100644
--- a/Documentation/devicetree/bindings/mfd/mt6397.txt
+++ b/Documentation/devicetree/bindings/mfd/mt6397.txt
@@ -34,6 +34,10 @@ Optional subnodes:
34- clk 34- clk
35 Required properties: 35 Required properties:
36 - compatible: "mediatek,mt6397-clk" 36 - compatible: "mediatek,mt6397-clk"
37- led
38 Required properties:
39 - compatible: "mediatek,mt6323-led"
40 see Documentation/devicetree/bindings/leds/leds-mt6323.txt
37 41
38Example: 42Example:
39 pwrap: pwrap@1000f000 { 43 pwrap: pwrap@1000f000 {
diff --git a/Documentation/devicetree/bindings/mfd/omap-usb-host.txt b/Documentation/devicetree/bindings/mfd/omap-usb-host.txt
index 4721b2d521e4..aa1eaa59581b 100644
--- a/Documentation/devicetree/bindings/mfd/omap-usb-host.txt
+++ b/Documentation/devicetree/bindings/mfd/omap-usb-host.txt
@@ -64,8 +64,8 @@ Required properties if child node exists:
64Properties for children: 64Properties for children:
65 65
66The OMAP HS USB Host subsystem contains EHCI and OHCI controllers. 66The OMAP HS USB Host subsystem contains EHCI and OHCI controllers.
67See Documentation/devicetree/bindings/usb/omap-ehci.txt and 67See Documentation/devicetree/bindings/usb/ehci-omap.txt and
68omap3-ohci.txt 68Documentation/devicetree/bindings/usb/ohci-omap3.txt.
69 69
70Example for OMAP4: 70Example for OMAP4:
71 71
diff --git a/Documentation/devicetree/bindings/mfd/qcom-rpm.txt b/Documentation/devicetree/bindings/mfd/qcom-rpm.txt
index 485bc59fcc48..3c91ad430eea 100644
--- a/Documentation/devicetree/bindings/mfd/qcom-rpm.txt
+++ b/Documentation/devicetree/bindings/mfd/qcom-rpm.txt
@@ -234,7 +234,7 @@ see regulator.txt - with additional custom properties described below:
234- qcom,switch-mode-frequency: 234- qcom,switch-mode-frequency:
235 Usage: required 235 Usage: required
236 Value type: <u32> 236 Value type: <u32>
237 Definition: Frequency (Hz) of the swith mode power supply; 237 Definition: Frequency (Hz) of the switch mode power supply;
238 must be one of: 238 must be one of:
239 19200000, 9600000, 6400000, 4800000, 3840000, 3200000, 239 19200000, 9600000, 6400000, 4800000, 3840000, 3200000,
240 2740000, 2400000, 2130000, 1920000, 1750000, 1600000, 240 2740000, 2400000, 2130000, 1920000, 1750000, 1600000,
diff --git a/Documentation/devicetree/bindings/mfd/stm32-timers.txt b/Documentation/devicetree/bindings/mfd/stm32-timers.txt
new file mode 100644
index 000000000000..bbd083f5600a
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/stm32-timers.txt
@@ -0,0 +1,46 @@
1STM32 Timers driver bindings
2
3This IP provides 3 types of timer along with PWM functionality:
4- advanced-control timers consist of a 16-bit auto-reload counter driven by a programmable
5 prescaler, break input feature, PWM outputs and complementary PWM ouputs channels.
6- general-purpose timers consist of a 16-bit or 32-bit auto-reload counter driven by a
7 programmable prescaler and PWM outputs.
8- basic timers consist of a 16-bit auto-reload counter driven by a programmable prescaler.
9
10Required parameters:
11- compatible: must be "st,stm32-timers"
12
13- reg: Physical base address and length of the controller's
14 registers.
15- clock-names: Set to "int".
16- clocks: Phandle to the clock used by the timer module.
17 For Clk properties, please refer to ../clock/clock-bindings.txt
18
19Optional parameters:
20- resets: Phandle to the parent reset controller.
21 See ../reset/st,stm32-rcc.txt
22
23Optional subnodes:
24- pwm: See ../pwm/pwm-stm32.txt
25- timer: See ../iio/timer/stm32-timer-trigger.txt
26
27Example:
28 timers@40010000 {
29 #address-cells = <1>;
30 #size-cells = <0>;
31 compatible = "st,stm32-timers";
32 reg = <0x40010000 0x400>;
33 clocks = <&rcc 0 160>;
34 clock-names = "clk_int";
35
36 pwm {
37 compatible = "st,stm32-pwm";
38 pinctrl-0 = <&pwm1_pins>;
39 pinctrl-names = "default";
40 };
41
42 timer@0 {
43 compatible = "st,stm32-timer-trigger";
44 reg = <0>;
45 };
46 };
diff --git a/Documentation/devicetree/bindings/misc/atmel-ssc.txt b/Documentation/devicetree/bindings/misc/atmel-ssc.txt
index efc98ea1f23d..f8629bb73945 100644
--- a/Documentation/devicetree/bindings/misc/atmel-ssc.txt
+++ b/Documentation/devicetree/bindings/misc/atmel-ssc.txt
@@ -24,6 +24,8 @@ Optional properties:
24 this parameter to choose where the clock from. 24 this parameter to choose where the clock from.
25 - By default the clock is from TK pin, if the clock from RK pin, this 25 - By default the clock is from TK pin, if the clock from RK pin, this
26 property is needed. 26 property is needed.
27 - #sound-dai-cells: Should contain <0>.
28 - This property makes the SSC into an automatically registered DAI.
27 29
28Examples: 30Examples:
29- PDC transfer: 31- PDC transfer:
diff --git a/Documentation/devicetree/bindings/misc/idt_89hpesx.txt b/Documentation/devicetree/bindings/misc/idt_89hpesx.txt
new file mode 100644
index 000000000000..b9093b79ab7d
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/idt_89hpesx.txt
@@ -0,0 +1,44 @@
1EEPROM / CSR SMBus-slave interface of IDT 89HPESx devices
2
3Required properties:
4 - compatible : should be "<manufacturer>,<type>"
5 Basically there is only one manufacturer: idt, but some
6 compatible devices may be produced in future. Following devices
7 are supported: 89hpes8nt2, 89hpes12nt3, 89hpes24nt6ag2,
8 89hpes32nt8ag2, 89hpes32nt8bg2, 89hpes12nt12g2, 89hpes16nt16g2,
9 89hpes24nt24g2, 89hpes32nt24ag2, 89hpes32nt24bg2;
10 89hpes12n3, 89hpes12n3a, 89hpes24n3, 89hpes24n3a;
11 89hpes32h8, 89hpes32h8g2, 89hpes48h12, 89hpes48h12g2,
12 89hpes48h12ag2, 89hpes16h16, 89hpes22h16, 89hpes22h16g2,
13 89hpes34h16, 89hpes34h16g2, 89hpes64h16, 89hpes64h16g2,
14 89hpes64h16ag2;
15 89hpes12t3g2, 89hpes24t3g2, 89hpes16t4, 89hpes4t4g2,
16 89hpes10t4g2, 89hpes16t4g2, 89hpes16t4ag2, 89hpes5t5,
17 89hpes6t5, 89hpes8t5, 89hpes8t5a, 89hpes24t6, 89hpes6t6g2,
18 89hpes24t6g2, 89hpes16t7, 89hpes32t8, 89hpes32t8g2,
19 89hpes48t12, 89hpes48t12g2.
20 - reg : I2C address of the IDT 89HPESx device.
21
22Optionally there can be EEPROM-compatible subnode:
23 - compatible: There are five EEPROM devices supported: 24c32, 24c64, 24c128,
24 24c256 and 24c512 differed by size.
25 - reg: Custom address of EEPROM device (If not specified IDT 89HPESx
26 (optional) device will try to communicate with EEPROM sited by default
27 address - 0x50)
28 - read-only : Parameterless property disables writes to the EEPROM
29 (optional)
30
31Example:
32 idt@60 {
33 compatible = "idt,89hpes32nt8ag2";
34 reg = <0x74>;
35 #address-cells = <1>;
36 #size-cells = <0>;
37
38 eeprom@50 {
39 compatible = "onsemi,24c64";
40 reg = <0x50>;
41 read-only;
42 };
43 };
44
diff --git a/Documentation/devicetree/bindings/net/brcm,bcm7445-switch-v4.0.txt b/Documentation/devicetree/bindings/net/brcm,bcm7445-switch-v4.0.txt
index fb40891ee606..9a734d808aa7 100644
--- a/Documentation/devicetree/bindings/net/brcm,bcm7445-switch-v4.0.txt
+++ b/Documentation/devicetree/bindings/net/brcm,bcm7445-switch-v4.0.txt
@@ -2,7 +2,7 @@
2 2
3Required properties: 3Required properties:
4 4
5- compatible: should be "brcm,bcm7445-switch-v4.0" 5- compatible: should be "brcm,bcm7445-switch-v4.0" or "brcm,bcm7278-switch-v4.0"
6- reg: addresses and length of the register sets for the device, must be 6 6- reg: addresses and length of the register sets for the device, must be 6
7 pairs of register addresses and lengths 7 pairs of register addresses and lengths
8- interrupts: interrupts for the devices, must be two interrupts 8- interrupts: interrupts for the devices, must be two interrupts
@@ -41,6 +41,13 @@ Optional properties:
41 Admission Control Block supports reporting the number of packets in-flight in a 41 Admission Control Block supports reporting the number of packets in-flight in a
42 switch queue 42 switch queue
43 43
44Port subnodes:
45
46Optional properties:
47
48- brcm,use-bcm-hdr: boolean property, if present, indicates that the switch
49 port has Broadcom tags enabled (per-packet metadata)
50
44Example: 51Example:
45 52
46switch_top@f0b00000 { 53switch_top@f0b00000 {
@@ -114,6 +121,7 @@ switch_top@f0b00000 {
114 port@0 { 121 port@0 {
115 label = "gphy"; 122 label = "gphy";
116 reg = <0>; 123 reg = <0>;
124 brcm,use-bcm-hdr;
117 }; 125 };
118 ... 126 ...
119 }; 127 };
diff --git a/Documentation/devicetree/bindings/net/brcm,systemport.txt b/Documentation/devicetree/bindings/net/brcm,systemport.txt
index 877da34145b0..83f29e0e11ba 100644
--- a/Documentation/devicetree/bindings/net/brcm,systemport.txt
+++ b/Documentation/devicetree/bindings/net/brcm,systemport.txt
@@ -1,7 +1,10 @@
1* Broadcom BCM7xxx Ethernet Systemport Controller (SYSTEMPORT) 1* Broadcom BCM7xxx Ethernet Systemport Controller (SYSTEMPORT)
2 2
3Required properties: 3Required properties:
4- compatible: should be one of "brcm,systemport-v1.00" or "brcm,systemport" 4- compatible: should be one of:
5 "brcm,systemport-v1.00"
6 "brcm,systemportlite-v1.00" or
7 "brcm,systemport"
5- reg: address and length of the register set for the device. 8- reg: address and length of the register set for the device.
6- interrupts: interrupts for the device, first cell must be for the rx 9- interrupts: interrupts for the device, first cell must be for the rx
7 interrupts, and the second cell should be for the transmit queues. An 10 interrupts, and the second cell should be for the transmit queues. An
diff --git a/Documentation/devicetree/bindings/net/btusb.txt b/Documentation/devicetree/bindings/net/btusb.txt
new file mode 100644
index 000000000000..01fa2d4188d4
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/btusb.txt
@@ -0,0 +1,43 @@
1Generic Bluetooth controller over USB (btusb driver)
2---------------------------------------------------
3
4Required properties:
5
6 - compatible : should comply with the format "usbVID,PID" specified in
7 Documentation/devicetree/bindings/usb/usb-device.txt
8 At the time of writing, the only OF supported devices
9 (more may be added later) are:
10
11 "usb1286,204e" (Marvell 8997)
12
13Also, vendors that use btusb may have device additional properties, e.g:
14Documentation/devicetree/bindings/net/marvell-bt-8xxx.txt
15
16Optional properties:
17
18 - interrupt-parent: phandle of the parent interrupt controller
19 - interrupt-names: (see below)
20 - interrupts : The interrupt specified by the name "wakeup" is the interrupt
21 that shall be used for out-of-band wake-on-bt. Driver will
22 request this interrupt for wakeup. During system suspend, the
23 irq will be enabled so that the bluetooth chip can wakeup host
24 platform out of band. During system resume, the irq will be
25 disabled to make sure unnecessary interrupt is not received.
26
27Example:
28
29Following example uses irq pin number 3 of gpio0 for out of band wake-on-bt:
30
31&usb_host1_ehci {
32 status = "okay";
33 #address-cells = <1>;
34 #size-cells = <0>;
35
36 mvl_bt1: bt@1 {
37 compatible = "usb1286,204e";
38 reg = <1>;
39 interrupt-parent = <&gpio0>;
40 interrupt-name = "wakeup";
41 interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
42 };
43};
diff --git a/Documentation/devicetree/bindings/net/cpsw.txt b/Documentation/devicetree/bindings/net/cpsw.txt
index ebda7c93453a..7cc15c96ea95 100644
--- a/Documentation/devicetree/bindings/net/cpsw.txt
+++ b/Documentation/devicetree/bindings/net/cpsw.txt
@@ -23,7 +23,6 @@ Required properties:
23 23
24Optional properties: 24Optional properties:
25- ti,hwmods : Must be "cpgmac0" 25- ti,hwmods : Must be "cpgmac0"
26- no_bd_ram : Must be 0 or 1
27- dual_emac : Specifies Switch to act as Dual EMAC 26- dual_emac : Specifies Switch to act as Dual EMAC
28- syscon : Phandle to the system control device node, which is 27- syscon : Phandle to the system control device node, which is
29 the control module device of the am33x 28 the control module device of the am33x
@@ -70,7 +69,6 @@ Examples:
70 cpdma_channels = <8>; 69 cpdma_channels = <8>;
71 ale_entries = <1024>; 70 ale_entries = <1024>;
72 bd_ram_size = <0x2000>; 71 bd_ram_size = <0x2000>;
73 no_bd_ram = <0>;
74 rx_descs = <64>; 72 rx_descs = <64>;
75 mac_control = <0x20>; 73 mac_control = <0x20>;
76 slaves = <2>; 74 slaves = <2>;
@@ -99,7 +97,6 @@ Examples:
99 cpdma_channels = <8>; 97 cpdma_channels = <8>;
100 ale_entries = <1024>; 98 ale_entries = <1024>;
101 bd_ram_size = <0x2000>; 99 bd_ram_size = <0x2000>;
102 no_bd_ram = <0>;
103 rx_descs = <64>; 100 rx_descs = <64>;
104 mac_control = <0x20>; 101 mac_control = <0x20>;
105 slaves = <2>; 102 slaves = <2>;
diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.txt b/Documentation/devicetree/bindings/net/dsa/dsa.txt
index a4a570fb2494..cfe8f64eca4f 100644
--- a/Documentation/devicetree/bindings/net/dsa/dsa.txt
+++ b/Documentation/devicetree/bindings/net/dsa/dsa.txt
@@ -34,13 +34,9 @@ Required properties:
34 34
35Each port children node must have the following mandatory properties: 35Each port children node must have the following mandatory properties:
36- reg : Describes the port address in the switch 36- reg : Describes the port address in the switch
37- label : Describes the label associated with this port, which
38 will become the netdev name. Special labels are
39 "cpu" to indicate a CPU port and "dsa" to
40 indicate an uplink/downlink port between switches in
41 the cluster.
42 37
43A port labelled "dsa" has the following mandatory property: 38An uplink/downlink port between switches in the cluster has the following
39mandatory property:
44 40
45- link : Should be a list of phandles to other switch's DSA 41- link : Should be a list of phandles to other switch's DSA
46 port. This port is used as the outgoing port 42 port. This port is used as the outgoing port
@@ -48,12 +44,17 @@ A port labelled "dsa" has the following mandatory property:
48 information must be given, not just the one hop 44 information must be given, not just the one hop
49 routes to neighbouring switches. 45 routes to neighbouring switches.
50 46
51A port labelled "cpu" has the following mandatory property: 47A CPU port has the following mandatory property:
52 48
53- ethernet : Should be a phandle to a valid Ethernet device node. 49- ethernet : Should be a phandle to a valid Ethernet device node.
54 This host device is what the switch port is 50 This host device is what the switch port is
55 connected to. 51 connected to.
56 52
53A user port has the following optional property:
54
55- label : Describes the label associated with this port, which
56 will become the netdev name.
57
57Port child nodes may also contain the following optional standardised 58Port child nodes may also contain the following optional standardised
58properties, described in binding documents: 59properties, described in binding documents:
59 60
@@ -107,7 +108,6 @@ linked into one DSA cluster.
107 108
108 switch0port5: port@5 { 109 switch0port5: port@5 {
109 reg = <5>; 110 reg = <5>;
110 label = "dsa";
111 phy-mode = "rgmii-txid"; 111 phy-mode = "rgmii-txid";
112 link = <&switch1port6 112 link = <&switch1port6
113 &switch2port9>; 113 &switch2port9>;
@@ -119,7 +119,6 @@ linked into one DSA cluster.
119 119
120 port@6 { 120 port@6 {
121 reg = <6>; 121 reg = <6>;
122 label = "cpu";
123 ethernet = <&fec1>; 122 ethernet = <&fec1>;
124 fixed-link { 123 fixed-link {
125 speed = <100>; 124 speed = <100>;
@@ -165,7 +164,6 @@ linked into one DSA cluster.
165 164
166 switch1port5: port@5 { 165 switch1port5: port@5 {
167 reg = <5>; 166 reg = <5>;
168 label = "dsa";
169 link = <&switch2port9>; 167 link = <&switch2port9>;
170 phy-mode = "rgmii-txid"; 168 phy-mode = "rgmii-txid";
171 fixed-link { 169 fixed-link {
@@ -176,7 +174,6 @@ linked into one DSA cluster.
176 174
177 switch1port6: port@6 { 175 switch1port6: port@6 {
178 reg = <6>; 176 reg = <6>;
179 label = "dsa";
180 phy-mode = "rgmii-txid"; 177 phy-mode = "rgmii-txid";
181 link = <&switch0port5>; 178 link = <&switch0port5>;
182 fixed-link { 179 fixed-link {
@@ -255,7 +252,6 @@ linked into one DSA cluster.
255 252
256 switch2port9: port@9 { 253 switch2port9: port@9 {
257 reg = <9>; 254 reg = <9>;
258 label = "dsa";
259 phy-mode = "rgmii-txid"; 255 phy-mode = "rgmii-txid";
260 link = <&switch1port5 256 link = <&switch1port5
261 &switch0port5>; 257 &switch0port5>;
diff --git a/Documentation/devicetree/bindings/net/dsa/marvell.txt b/Documentation/devicetree/bindings/net/dsa/marvell.txt
index b3dd6b40e0de..7ef9dbb08957 100644
--- a/Documentation/devicetree/bindings/net/dsa/marvell.txt
+++ b/Documentation/devicetree/bindings/net/dsa/marvell.txt
@@ -14,9 +14,9 @@ The properties described here are those specific to Marvell devices.
14Additional required and optional properties can be found in dsa.txt. 14Additional required and optional properties can be found in dsa.txt.
15 15
16Required properties: 16Required properties:
17- compatible : Should be one of "marvell,mv88e6085" or 17- compatible : Should be one of "marvell,mv88e6085" or
18 "marvell,mv88e6190" 18 "marvell,mv88e6190"
19- reg : Address on the MII bus for the switch. 19- reg : Address on the MII bus for the switch.
20 20
21Optional properties: 21Optional properties:
22 22
@@ -26,30 +26,67 @@ Optional properties:
26- interrupt-controller : Indicates the switch is itself an interrupt 26- interrupt-controller : Indicates the switch is itself an interrupt
27 controller. This is used for the PHY interrupts. 27 controller. This is used for the PHY interrupts.
28#interrupt-cells = <2> : Controller uses two cells, number and flag 28#interrupt-cells = <2> : Controller uses two cells, number and flag
29- mdio : container of PHY and devices on the switches MDIO 29- mdio : Container of PHY and devices on the switches MDIO
30 bus 30 bus.
31- mdio? : Container of PHYs and devices on the external MDIO
32 bus. The node must contains a compatible string of
33 "marvell,mv88e6xxx-mdio-external"
34
31Example: 35Example:
32 36
33 mdio { 37 mdio {
34 #address-cells = <1>; 38 #address-cells = <1>;
35 #size-cells = <0>; 39 #size-cells = <0>;
36 interrupt-parent = <&gpio0>; 40 interrupt-parent = <&gpio0>;
37 interrupts = <27 IRQ_TYPE_LEVEL_LOW>; 41 interrupts = <27 IRQ_TYPE_LEVEL_LOW>;
38 interrupt-controller; 42 interrupt-controller;
39 #interrupt-cells = <2>; 43 #interrupt-cells = <2>;
40 44
41 switch0: switch@0 { 45 switch0: switch@0 {
42 compatible = "marvell,mv88e6085"; 46 compatible = "marvell,mv88e6085";
43 reg = <0>; 47 reg = <0>;
44 reset-gpios = <&gpio5 1 GPIO_ACTIVE_LOW>; 48 reset-gpios = <&gpio5 1 GPIO_ACTIVE_LOW>;
45 }; 49 };
46 mdio { 50 mdio {
47 #address-cells = <1>; 51 #address-cells = <1>;
48 #size-cells = <0>; 52 #size-cells = <0>;
49 switch1phy0: switch1phy0@0 { 53 switch1phy0: switch1phy0@0 {
50 reg = <0>; 54 reg = <0>;
51 interrupt-parent = <&switch0>; 55 interrupt-parent = <&switch0>;
52 interrupts = <0 IRQ_TYPE_LEVEL_HIGH>; 56 interrupts = <0 IRQ_TYPE_LEVEL_HIGH>;
53 }; 57 };
54 }; 58 };
55 }; 59 };
60
61 mdio {
62 #address-cells = <1>;
63 #size-cells = <0>;
64 interrupt-parent = <&gpio0>;
65 interrupts = <27 IRQ_TYPE_LEVEL_LOW>;
66 interrupt-controller;
67 #interrupt-cells = <2>;
68
69 switch0: switch@0 {
70 compatible = "marvell,mv88e6390";
71 reg = <0>;
72 reset-gpios = <&gpio5 1 GPIO_ACTIVE_LOW>;
73 };
74 mdio {
75 #address-cells = <1>;
76 #size-cells = <0>;
77 switch1phy0: switch1phy0@0 {
78 reg = <0>;
79 interrupt-parent = <&switch0>;
80 interrupts = <0 IRQ_TYPE_LEVEL_HIGH>;
81 };
82 };
83
84 mdio1 {
85 compatible = "marvell,mv88e6xxx-mdio-external";
86 #address-cells = <1>;
87 #size-cells = <0>;
88 switch1phy9: switch1phy0@9 {
89 reg = <9>;
90 };
91 };
92 };
diff --git a/Documentation/devicetree/bindings/net/ethernet.txt b/Documentation/devicetree/bindings/net/ethernet.txt
index 05150957ecfd..3a6916909d90 100644
--- a/Documentation/devicetree/bindings/net/ethernet.txt
+++ b/Documentation/devicetree/bindings/net/ethernet.txt
@@ -29,6 +29,9 @@ The following properties are common to the Ethernet controllers:
29 * "smii" 29 * "smii"
30 * "xgmii" 30 * "xgmii"
31 * "trgmii" 31 * "trgmii"
32 * "2000base-x",
33 * "2500base-x",
34 * "rxaui"
32- phy-connection-type: the same as "phy-mode" property but described in ePAPR; 35- phy-connection-type: the same as "phy-mode" property but described in ePAPR;
33- phy-handle: phandle, specifies a reference to a node representing a PHY 36- phy-handle: phandle, specifies a reference to a node representing a PHY
34 device; this property is described in ePAPR and so preferred; 37 device; this property is described in ePAPR and so preferred;
diff --git a/Documentation/devicetree/bindings/net/marvell,prestera.txt b/Documentation/devicetree/bindings/net/marvell,prestera.txt
new file mode 100644
index 000000000000..5fbab29718e8
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/marvell,prestera.txt
@@ -0,0 +1,50 @@
1Marvell Prestera Switch Chip bindings
2-------------------------------------
3
4Required properties:
5- compatible: one of the following
6 "marvell,prestera-98dx3236",
7 "marvell,prestera-98dx3336",
8 "marvell,prestera-98dx4251",
9- reg: address and length of the register set for the device.
10- interrupts: interrupt for the device
11
12Optional properties:
13- dfx: phandle reference to the "DFX Server" node
14
15Example:
16
17switch {
18 compatible = "simple-bus";
19 #address-cells = <1>;
20 #size-cells = <1>;
21 ranges = <0 MBUS_ID(0x03, 0x00) 0 0x100000>;
22
23 packet-processor@0 {
24 compatible = "marvell,prestera-98dx3236";
25 reg = <0 0x4000000>;
26 interrupts = <33>, <34>, <35>;
27 dfx = <&dfx>;
28 };
29};
30
31DFX Server bindings
32-------------------
33
34Required properties:
35- compatible: must be "marvell,dfx-server"
36- reg: address and length of the register set for the device.
37
38Example:
39
40dfx-registers {
41 compatible = "simple-bus";
42 #address-cells = <1>;
43 #size-cells = <1>;
44 ranges = <0 MBUS_ID(0x08, 0x00) 0 0x100000>;
45
46 dfx: dfx@0 {
47 compatible = "marvell,dfx-server";
48 reg = <0 0x100000>;
49 };
50};
diff --git a/Documentation/devicetree/bindings/net/marvell-armada-370-neta.txt b/Documentation/devicetree/bindings/net/marvell-armada-370-neta.txt
index 7aa840c8768d..ae4234ca4ee4 100644
--- a/Documentation/devicetree/bindings/net/marvell-armada-370-neta.txt
+++ b/Documentation/devicetree/bindings/net/marvell-armada-370-neta.txt
@@ -1,7 +1,7 @@
1* Marvell Armada 370 / Armada XP / Armada 3700 Ethernet Controller (NETA) 1* Marvell Armada 370 / Armada XP / Armada 3700 Ethernet Controller (NETA)
2 2
3Required properties: 3Required properties:
4- compatible: could be one of the followings 4- compatible: could be one of the following:
5 "marvell,armada-370-neta" 5 "marvell,armada-370-neta"
6 "marvell,armada-xp-neta" 6 "marvell,armada-xp-neta"
7 "marvell,armada-3700-neta" 7 "marvell,armada-3700-neta"
diff --git a/Documentation/devicetree/bindings/net/marvell-bt-sd8xxx.txt b/Documentation/devicetree/bindings/net/marvell-bt-8xxx.txt
index 6a9a63cb0543..9be1059ff03f 100644
--- a/Documentation/devicetree/bindings/net/marvell-bt-sd8xxx.txt
+++ b/Documentation/devicetree/bindings/net/marvell-bt-8xxx.txt
@@ -1,16 +1,21 @@
1Marvell 8897/8997 (sd8897/sd8997) bluetooth SDIO devices 1Marvell 8897/8997 (sd8897/sd8997) bluetooth devices (SDIO or USB based)
2------ 2------
3The 8997 devices supports multiple interfaces. When used on SDIO interfaces,
4the btmrvl driver is used and when used on USB interface, the btusb driver is
5used.
3 6
4Required properties: 7Required properties:
5 8
6 - compatible : should be one of the following: 9 - compatible : should be one of the following:
7 * "marvell,sd8897-bt" 10 * "marvell,sd8897-bt" (for SDIO)
8 * "marvell,sd8997-bt" 11 * "marvell,sd8997-bt" (for SDIO)
12 * "usb1286,204e" (for USB)
9 13
10Optional properties: 14Optional properties:
11 15
12 - marvell,cal-data: Calibration data downloaded to the device during 16 - marvell,cal-data: Calibration data downloaded to the device during
13 initialization. This is an array of 28 values(u8). 17 initialization. This is an array of 28 values(u8).
18 This is only applicable to SDIO devices.
14 19
15 - marvell,wakeup-pin: It represents wakeup pin number of the bluetooth chip. 20 - marvell,wakeup-pin: It represents wakeup pin number of the bluetooth chip.
16 firmware will use the pin to wakeup host system (u16). 21 firmware will use the pin to wakeup host system (u16).
@@ -18,10 +23,15 @@ Optional properties:
18 platform. The value will be configured to firmware. This 23 platform. The value will be configured to firmware. This
19 is needed to work chip's sleep feature as expected (u16). 24 is needed to work chip's sleep feature as expected (u16).
20 - interrupt-parent: phandle of the parent interrupt controller 25 - interrupt-parent: phandle of the parent interrupt controller
21 - interrupts : interrupt pin number to the cpu. Driver will request an irq based 26 - interrupt-names: Used only for USB based devices (See below)
22 on this interrupt number. During system suspend, the irq will be 27 - interrupts : specifies the interrupt pin number to the cpu. For SDIO, the
23 enabled so that the bluetooth chip can wakeup host platform under 28 driver will use the first interrupt specified in the interrupt
24 certain condition. During system resume, the irq will be disabled 29 array. For USB based devices, the driver will use the interrupt
30 named "wakeup" from the interrupt-names and interrupt arrays.
31 The driver will request an irq based on this interrupt number.
32 During system suspend, the irq will be enabled so that the
33 bluetooth chip can wakeup host platform under certain
34 conditions. During system resume, the irq will be disabled
25 to make sure unnecessary interrupt is not received. 35 to make sure unnecessary interrupt is not received.
26 36
27Example: 37Example:
@@ -29,7 +39,9 @@ Example:
29IRQ pin 119 is used as system wakeup source interrupt. 39IRQ pin 119 is used as system wakeup source interrupt.
30wakeup pin 13 and gap 100ms are configured so that firmware can wakeup host 40wakeup pin 13 and gap 100ms are configured so that firmware can wakeup host
31using this device side pin and wakeup latency. 41using this device side pin and wakeup latency.
32calibration data is also available in below example. 42
43Example for SDIO device follows (calibration data is also available in
44below example).
33 45
34&mmc3 { 46&mmc3 {
35 status = "okay"; 47 status = "okay";
@@ -54,3 +66,21 @@ calibration data is also available in below example.
54 marvell,wakeup-gap-ms = /bits/ 16 <0x64>; 66 marvell,wakeup-gap-ms = /bits/ 16 <0x64>;
55 }; 67 };
56}; 68};
69
70Example for USB device:
71
72&usb_host1_ohci {
73 status = "okay";
74 #address-cells = <1>;
75 #size-cells = <0>;
76
77 mvl_bt1: bt@1 {
78 compatible = "usb1286,204e";
79 reg = <1>;
80 interrupt-parent = <&gpio0>;
81 interrupt-names = "wakeup";
82 interrupts = <119 IRQ_TYPE_LEVEL_LOW>;
83 marvell,wakeup-pin = /bits/ 16 <0x0d>;
84 marvell,wakeup-gap-ms = /bits/ 16 <0x64>;
85 };
86};
diff --git a/Documentation/devicetree/bindings/net/marvell-pp2.txt b/Documentation/devicetree/bindings/net/marvell-pp2.txt
index aa4f4230bfd7..4754364df4c6 100644
--- a/Documentation/devicetree/bindings/net/marvell-pp2.txt
+++ b/Documentation/devicetree/bindings/net/marvell-pp2.txt
@@ -27,9 +27,7 @@ Optional properties (port):
27 27
28- marvell,loopback: port is loopback mode 28- marvell,loopback: port is loopback mode
29- phy: a phandle to a phy node defining the PHY address (as the reg 29- phy: a phandle to a phy node defining the PHY address (as the reg
30 property, a single integer). Note: if this property isn't present, 30 property, a single integer).
31 then fixed link is assumed, and the 'fixed-link' property is
32 mandatory.
33 31
34Example: 32Example:
35 33
diff --git a/Documentation/devicetree/bindings/net/meson-dwmac.txt b/Documentation/devicetree/bindings/net/meson-dwmac.txt
index 89e62ddc69ca..0703ad3f3c1e 100644
--- a/Documentation/devicetree/bindings/net/meson-dwmac.txt
+++ b/Documentation/devicetree/bindings/net/meson-dwmac.txt
@@ -25,6 +25,22 @@ Required properties on Meson8b and newer:
25 - "clkin0" - first parent clock of the internal mux 25 - "clkin0" - first parent clock of the internal mux
26 - "clkin1" - second parent clock of the internal mux 26 - "clkin1" - second parent clock of the internal mux
27 27
28Optional properties on Meson8b and newer:
29- amlogic,tx-delay-ns: The internal RGMII TX clock delay (provided
30 by this driver) in nanoseconds. Allowed values
31 are: 0ns, 2ns, 4ns, 6ns.
32 When phy-mode is set to "rgmii" then the TX
33 delay should be explicitly configured. When
34 not configured a fallback of 2ns is used.
35 When the phy-mode is set to either "rgmii-id"
36 or "rgmii-txid" the TX clock delay is already
37 provided by the PHY. In that case this
38 property should be set to 0ns (which disables
39 the TX clock delay in the MAC to prevent the
40 clock from going off because both PHY and MAC
41 are adding a delay).
42 Any configuration is ignored when the phy-mode
43 is set to "rmii".
28 44
29Example for Meson6: 45Example for Meson6:
30 46
diff --git a/Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt b/Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt
index bdefefc66594..0eedabe22cc3 100644
--- a/Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt
+++ b/Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt
@@ -27,6 +27,14 @@ Optional properties:
27 'vddmac'. 27 'vddmac'.
28 Default value is 0%. 28 Default value is 0%.
29 Ref: Table:1 - Edge rate change (below). 29 Ref: Table:1 - Edge rate change (below).
30- vsc8531,led-0-mode : LED mode. Specify how the LED[0] should behave.
31 Allowed values are define in
32 "include/dt-bindings/net/mscc-phy-vsc8531.h".
33 Default value is VSC8531_LINK_1000_ACTIVITY (1).
34- vsc8531,led-1-mode : LED mode. Specify how the LED[1] should behave.
35 Allowed values are define in
36 "include/dt-bindings/net/mscc-phy-vsc8531.h".
37 Default value is VSC8531_LINK_100_ACTIVITY (2).
30 38
31Table: 1 - Edge rate change 39Table: 1 - Edge rate change
32----------------------------------------------------------------| 40----------------------------------------------------------------|
@@ -60,4 +68,6 @@ Example:
60 compatible = "ethernet-phy-id0007.0570"; 68 compatible = "ethernet-phy-id0007.0570";
61 vsc8531,vddmac = <3300>; 69 vsc8531,vddmac = <3300>;
62 vsc8531,edge-slowdown = <7>; 70 vsc8531,edge-slowdown = <7>;
71 vsc8531,led-0-mode = <LINK_1000_ACTIVITY>;
72 vsc8531,led-1-mode = <LINK_100_ACTIVITY>;
63 }; 73 };
diff --git a/Documentation/devicetree/bindings/net/phy.txt b/Documentation/devicetree/bindings/net/phy.txt
index fb5056b22685..b55857696fc3 100644
--- a/Documentation/devicetree/bindings/net/phy.txt
+++ b/Documentation/devicetree/bindings/net/phy.txt
@@ -39,6 +39,10 @@ Optional Properties:
39- enet-phy-lane-swap: If set, indicates the PHY will swap the TX/RX lanes to 39- enet-phy-lane-swap: If set, indicates the PHY will swap the TX/RX lanes to
40 compensate for the board being designed with the lanes swapped. 40 compensate for the board being designed with the lanes swapped.
41 41
42- enet-phy-lane-no-swap: If set, indicates that PHY will disable swap of the
43 TX/RX lanes. This property allows the PHY to work correcly after e.g. wrong
44 bootstrap configuration caused by issues in PCB layout design.
45
42- eee-broken-100tx: 46- eee-broken-100tx:
43- eee-broken-1000t: 47- eee-broken-1000t:
44- eee-broken-10gt: 48- eee-broken-10gt:
diff --git a/Documentation/devicetree/bindings/net/rockchip-dwmac.txt b/Documentation/devicetree/bindings/net/rockchip-dwmac.txt
index 95383c5131fc..8f427550720a 100644
--- a/Documentation/devicetree/bindings/net/rockchip-dwmac.txt
+++ b/Documentation/devicetree/bindings/net/rockchip-dwmac.txt
@@ -6,6 +6,7 @@ Required properties:
6 - compatible: should be "rockchip,<name>-gamc" 6 - compatible: should be "rockchip,<name>-gamc"
7 "rockchip,rk3228-gmac": found on RK322x SoCs 7 "rockchip,rk3228-gmac": found on RK322x SoCs
8 "rockchip,rk3288-gmac": found on RK3288 SoCs 8 "rockchip,rk3288-gmac": found on RK3288 SoCs
9 "rockchip,rk3328-gmac": found on RK3328 SoCs
9 "rockchip,rk3366-gmac": found on RK3366 SoCs 10 "rockchip,rk3366-gmac": found on RK3366 SoCs
10 "rockchip,rk3368-gmac": found on RK3368 SoCs 11 "rockchip,rk3368-gmac": found on RK3368 SoCs
11 "rockchip,rk3399-gmac": found on RK3399 SoCs 12 "rockchip,rk3399-gmac": found on RK3399 SoCs
diff --git a/Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt b/Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt
index d93f71ce8346..21d27aa4c68c 100644
--- a/Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt
+++ b/Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt
@@ -1,5 +1,8 @@
1* Synopsys DWC Ethernet QoS IP version 4.10 driver (GMAC) 1* Synopsys DWC Ethernet QoS IP version 4.10 driver (GMAC)
2 2
3This binding is deprecated, but it continues to be supported, but new
4features should be preferably added to the stmmac binding document.
5
3This binding supports the Synopsys Designware Ethernet QoS (Quality Of Service) 6This binding supports the Synopsys Designware Ethernet QoS (Quality Of Service)
4IP block. The IP supports multiple options for bus type, clocking and reset 7IP block. The IP supports multiple options for bus type, clocking and reset
5structure, and feature list. Consequently, a number of properties and list 8structure, and feature list. Consequently, a number of properties and list
diff --git a/Documentation/devicetree/bindings/net/stmmac.txt b/Documentation/devicetree/bindings/net/stmmac.txt
index 128da752fec9..d3bfc2b30fb5 100644
--- a/Documentation/devicetree/bindings/net/stmmac.txt
+++ b/Documentation/devicetree/bindings/net/stmmac.txt
@@ -49,6 +49,8 @@ Optional properties:
49- snps,force_sf_dma_mode Force DMA to use the Store and Forward 49- snps,force_sf_dma_mode Force DMA to use the Store and Forward
50 mode for both tx and rx. This flag is 50 mode for both tx and rx. This flag is
51 ignored if force_thresh_dma_mode is set. 51 ignored if force_thresh_dma_mode is set.
52- snps,en-tx-lpi-clockgating Enable gating of the MAC TX clock during
53 TX low-power mode
52- snps,multicast-filter-bins: Number of multicast filter hash bins 54- snps,multicast-filter-bins: Number of multicast filter hash bins
53 supported by this device instance 55 supported by this device instance
54- snps,perfect-filter-entries: Number of perfect filter entries supported 56- snps,perfect-filter-entries: Number of perfect filter entries supported
@@ -65,7 +67,6 @@ Optional properties:
65 - snps,wr_osr_lmt: max write outstanding req. limit 67 - snps,wr_osr_lmt: max write outstanding req. limit
66 - snps,rd_osr_lmt: max read outstanding req. limit 68 - snps,rd_osr_lmt: max read outstanding req. limit
67 - snps,kbbe: do not cross 1KiB boundary. 69 - snps,kbbe: do not cross 1KiB boundary.
68 - snps,axi_all: align address
69 - snps,blen: this is a vector of supported burst length. 70 - snps,blen: this is a vector of supported burst length.
70 - snps,fb: fixed-burst 71 - snps,fb: fixed-burst
71 - snps,mb: mixed-burst 72 - snps,mb: mixed-burst
diff --git a/Documentation/devicetree/bindings/net/wireless/ieee80211.txt b/Documentation/devicetree/bindings/net/wireless/ieee80211.txt
new file mode 100644
index 000000000000..f6442b1397f5
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/wireless/ieee80211.txt
@@ -0,0 +1,24 @@
1Common IEEE 802.11 properties
2
3This provides documentation of common properties that are valid for all wireless
4devices.
5
6Optional properties:
7 - ieee80211-freq-limit : list of supported frequency ranges in KHz. This can be
8 used for devices that in a given config support less channels than
9 normally. It may happen chipset supports a wide wireless band but it is
10 limited to some part of it due to used antennas or power amplifier.
11 An example case for this can be tri-band wireless router with two
12 identical chipsets used for two different 5 GHz subbands. Using them
13 incorrectly could not work or decrease performance noticeably.
14
15Example:
16
17pcie@0,0 {
18 reg = <0x0000 0 0 0 0>;
19 wifi@0,0 {
20 reg = <0x0000 0 0 0 0>;
21 ieee80211-freq-limit = <2402000 2482000>,
22 <5170000 5250000>;
23 };
24};
diff --git a/Documentation/devicetree/bindings/nvmem/imx-ocotp.txt b/Documentation/devicetree/bindings/nvmem/imx-ocotp.txt
index 383d5889e95a..966a72ecc6bd 100644
--- a/Documentation/devicetree/bindings/nvmem/imx-ocotp.txt
+++ b/Documentation/devicetree/bindings/nvmem/imx-ocotp.txt
@@ -1,13 +1,15 @@
1Freescale i.MX6 On-Chip OTP Controller (OCOTP) device tree bindings 1Freescale i.MX6 On-Chip OTP Controller (OCOTP) device tree bindings
2 2
3This binding represents the on-chip eFuse OTP controller found on 3This binding represents the on-chip eFuse OTP controller found on
4i.MX6Q/D, i.MX6DL/S, i.MX6SL, and i.MX6SX SoCs. 4i.MX6Q/D, i.MX6DL/S, i.MX6SL, i.MX6SX and i.MX6UL SoCs.
5 5
6Required properties: 6Required properties:
7- compatible: should be one of 7- compatible: should be one of
8 "fsl,imx6q-ocotp" (i.MX6Q/D/DL/S), 8 "fsl,imx6q-ocotp" (i.MX6Q/D/DL/S),
9 "fsl,imx6sl-ocotp" (i.MX6SL), or 9 "fsl,imx6sl-ocotp" (i.MX6SL), or
10 "fsl,imx6sx-ocotp" (i.MX6SX), followed by "syscon". 10 "fsl,imx6sx-ocotp" (i.MX6SX),
11 "fsl,imx6ul-ocotp" (i.MX6UL),
12 followed by "syscon".
11- reg: Should contain the register base and length. 13- reg: Should contain the register base and length.
12- clocks: Should contain a phandle pointing to the gated peripheral clock. 14- clocks: Should contain a phandle pointing to the gated peripheral clock.
13 15
diff --git a/Documentation/devicetree/bindings/opp/opp.txt b/Documentation/devicetree/bindings/opp/opp.txt
index 9f5ca4457b5f..63725498bd20 100644
--- a/Documentation/devicetree/bindings/opp/opp.txt
+++ b/Documentation/devicetree/bindings/opp/opp.txt
@@ -136,7 +136,7 @@ Optional properties:
136 larger OPP table, based on what version of the hardware we are running on. We 136 larger OPP table, based on what version of the hardware we are running on. We
137 still can't have multiple nodes with the same opp-hz value in OPP table. 137 still can't have multiple nodes with the same opp-hz value in OPP table.
138 138
139 It's an user defined array containing a hierarchy of hardware version numbers, 139 It's a user defined array containing a hierarchy of hardware version numbers,
140 supported by the OPP. For example: a platform with hierarchy of three levels 140 supported by the OPP. For example: a platform with hierarchy of three levels
141 of versions (A, B and C), this field should be like <X Y Z>, where X 141 of versions (A, B and C), this field should be like <X Y Z>, where X
142 corresponds to Version hierarchy A, Y corresponds to version hierarchy B and Z 142 corresponds to Version hierarchy A, Y corresponds to version hierarchy B and Z
@@ -188,14 +188,14 @@ Example 1: Single cluster Dual-core ARM cortex A9, switch DVFS states together.
188 188
189 opp@1000000000 { 189 opp@1000000000 {
190 opp-hz = /bits/ 64 <1000000000>; 190 opp-hz = /bits/ 64 <1000000000>;
191 opp-microvolt = <970000 975000 985000>; 191 opp-microvolt = <975000 970000 985000>;
192 opp-microamp = <70000>; 192 opp-microamp = <70000>;
193 clock-latency-ns = <300000>; 193 clock-latency-ns = <300000>;
194 opp-suspend; 194 opp-suspend;
195 }; 195 };
196 opp@1100000000 { 196 opp@1100000000 {
197 opp-hz = /bits/ 64 <1100000000>; 197 opp-hz = /bits/ 64 <1100000000>;
198 opp-microvolt = <980000 1000000 1010000>; 198 opp-microvolt = <1000000 980000 1010000>;
199 opp-microamp = <80000>; 199 opp-microamp = <80000>;
200 clock-latency-ns = <310000>; 200 clock-latency-ns = <310000>;
201 }; 201 };
@@ -267,14 +267,14 @@ independently.
267 267
268 opp@1000000000 { 268 opp@1000000000 {
269 opp-hz = /bits/ 64 <1000000000>; 269 opp-hz = /bits/ 64 <1000000000>;
270 opp-microvolt = <970000 975000 985000>; 270 opp-microvolt = <975000 970000 985000>;
271 opp-microamp = <70000>; 271 opp-microamp = <70000>;
272 clock-latency-ns = <300000>; 272 clock-latency-ns = <300000>;
273 opp-suspend; 273 opp-suspend;
274 }; 274 };
275 opp@1100000000 { 275 opp@1100000000 {
276 opp-hz = /bits/ 64 <1100000000>; 276 opp-hz = /bits/ 64 <1100000000>;
277 opp-microvolt = <980000 1000000 1010000>; 277 opp-microvolt = <1000000 980000 1010000>;
278 opp-microamp = <80000>; 278 opp-microamp = <80000>;
279 clock-latency-ns = <310000>; 279 clock-latency-ns = <310000>;
280 }; 280 };
@@ -343,14 +343,14 @@ DVFS state together.
343 343
344 opp@1000000000 { 344 opp@1000000000 {
345 opp-hz = /bits/ 64 <1000000000>; 345 opp-hz = /bits/ 64 <1000000000>;
346 opp-microvolt = <970000 975000 985000>; 346 opp-microvolt = <975000 970000 985000>;
347 opp-microamp = <70000>; 347 opp-microamp = <70000>;
348 clock-latency-ns = <300000>; 348 clock-latency-ns = <300000>;
349 opp-suspend; 349 opp-suspend;
350 }; 350 };
351 opp@1100000000 { 351 opp@1100000000 {
352 opp-hz = /bits/ 64 <1100000000>; 352 opp-hz = /bits/ 64 <1100000000>;
353 opp-microvolt = <980000 1000000 1010000>; 353 opp-microvolt = <1000000 980000 1010000>;
354 opp-microamp = <80000>; 354 opp-microamp = <80000>;
355 clock-latency-ns = <310000>; 355 clock-latency-ns = <310000>;
356 }; 356 };
@@ -369,7 +369,7 @@ DVFS state together.
369 369
370 opp@1300000000 { 370 opp@1300000000 {
371 opp-hz = /bits/ 64 <1300000000>; 371 opp-hz = /bits/ 64 <1300000000>;
372 opp-microvolt = <1045000 1050000 1055000>; 372 opp-microvolt = <1050000 1045000 1055000>;
373 opp-microamp = <95000>; 373 opp-microamp = <95000>;
374 clock-latency-ns = <400000>; 374 clock-latency-ns = <400000>;
375 opp-suspend; 375 opp-suspend;
@@ -382,7 +382,7 @@ DVFS state together.
382 }; 382 };
383 opp@1500000000 { 383 opp@1500000000 {
384 opp-hz = /bits/ 64 <1500000000>; 384 opp-hz = /bits/ 64 <1500000000>;
385 opp-microvolt = <1010000 1100000 1110000>; 385 opp-microvolt = <1100000 1010000 1110000>;
386 opp-microamp = <95000>; 386 opp-microamp = <95000>;
387 clock-latency-ns = <400000>; 387 clock-latency-ns = <400000>;
388 turbo-mode; 388 turbo-mode;
@@ -424,9 +424,9 @@ Example 4: Handling multiple regulators
424 424
425 opp@1000000000 { 425 opp@1000000000 {
426 opp-hz = /bits/ 64 <1000000000>; 426 opp-hz = /bits/ 64 <1000000000>;
427 opp-microvolt = <970000 975000 985000>, /* Supply 0 */ 427 opp-microvolt = <975000 970000 985000>, /* Supply 0 */
428 <960000 965000 975000>, /* Supply 1 */ 428 <965000 960000 975000>, /* Supply 1 */
429 <960000 965000 975000>; /* Supply 2 */ 429 <965000 960000 975000>; /* Supply 2 */
430 opp-microamp = <70000>, /* Supply 0 */ 430 opp-microamp = <70000>, /* Supply 0 */
431 <70000>, /* Supply 1 */ 431 <70000>, /* Supply 1 */
432 <70000>; /* Supply 2 */ 432 <70000>; /* Supply 2 */
@@ -437,9 +437,9 @@ Example 4: Handling multiple regulators
437 437
438 opp@1000000000 { 438 opp@1000000000 {
439 opp-hz = /bits/ 64 <1000000000>; 439 opp-hz = /bits/ 64 <1000000000>;
440 opp-microvolt = <970000 975000 985000>, /* Supply 0 */ 440 opp-microvolt = <975000 970000 985000>, /* Supply 0 */
441 <960000 965000 975000>, /* Supply 1 */ 441 <965000 960000 975000>, /* Supply 1 */
442 <960000 965000 975000>; /* Supply 2 */ 442 <965000 960000 975000>; /* Supply 2 */
443 opp-microamp = <70000>, /* Supply 0 */ 443 opp-microamp = <70000>, /* Supply 0 */
444 <0>, /* Supply 1 doesn't need this */ 444 <0>, /* Supply 1 doesn't need this */
445 <70000>; /* Supply 2 */ 445 <70000>; /* Supply 2 */
@@ -474,7 +474,7 @@ Example 5: opp-supported-hw
474 */ 474 */
475 opp-supported-hw = <0xF 0xFFFFFFFF 0xFFFFFFFF> 475 opp-supported-hw = <0xF 0xFFFFFFFF 0xFFFFFFFF>
476 opp-hz = /bits/ 64 <600000000>; 476 opp-hz = /bits/ 64 <600000000>;
477 opp-microvolt = <900000 915000 925000>; 477 opp-microvolt = <915000 900000 925000>;
478 ... 478 ...
479 }; 479 };
480 480
@@ -487,7 +487,7 @@ Example 5: opp-supported-hw
487 */ 487 */
488 opp-supported-hw = <0x20 0xff0000ff 0x0000f4f0> 488 opp-supported-hw = <0x20 0xff0000ff 0x0000f4f0>
489 opp-hz = /bits/ 64 <800000000>; 489 opp-hz = /bits/ 64 <800000000>;
490 opp-microvolt = <900000 915000 925000>; 490 opp-microvolt = <915000 900000 925000>;
491 ... 491 ...
492 }; 492 };
493 }; 493 };
@@ -512,18 +512,18 @@ Example 6: opp-microvolt-<name>, opp-microamp-<name>:
512 512
513 opp@1000000000 { 513 opp@1000000000 {
514 opp-hz = /bits/ 64 <1000000000>; 514 opp-hz = /bits/ 64 <1000000000>;
515 opp-microvolt-slow = <900000 915000 925000>; 515 opp-microvolt-slow = <915000 900000 925000>;
516 opp-microvolt-fast = <970000 975000 985000>; 516 opp-microvolt-fast = <975000 970000 985000>;
517 opp-microamp-slow = <70000>; 517 opp-microamp-slow = <70000>;
518 opp-microamp-fast = <71000>; 518 opp-microamp-fast = <71000>;
519 }; 519 };
520 520
521 opp@1200000000 { 521 opp@1200000000 {
522 opp-hz = /bits/ 64 <1200000000>; 522 opp-hz = /bits/ 64 <1200000000>;
523 opp-microvolt-slow = <900000 915000 925000>, /* Supply vcc0 */ 523 opp-microvolt-slow = <915000 900000 925000>, /* Supply vcc0 */
524 <910000 925000 935000>; /* Supply vcc1 */ 524 <925000 910000 935000>; /* Supply vcc1 */
525 opp-microvolt-fast = <970000 975000 985000>, /* Supply vcc0 */ 525 opp-microvolt-fast = <975000 970000 985000>, /* Supply vcc0 */
526 <960000 965000 975000>; /* Supply vcc1 */ 526 <965000 960000 975000>; /* Supply vcc1 */
527 opp-microamp = <70000>; /* Will be used for both slow/fast */ 527 opp-microamp = <70000>; /* Will be used for both slow/fast */
528 }; 528 };
529 }; 529 };
diff --git a/Documentation/devicetree/bindings/pci/hisilicon-pcie.txt b/Documentation/devicetree/bindings/pci/hisilicon-pcie.txt
index 59c2f47aa303..b7fa3b97986d 100644
--- a/Documentation/devicetree/bindings/pci/hisilicon-pcie.txt
+++ b/Documentation/devicetree/bindings/pci/hisilicon-pcie.txt
@@ -42,3 +42,40 @@ Hip05 Example (note that Hip06 is the same except compatible):
42 0x0 0 0 4 &mbigen_pcie 4 13>; 42 0x0 0 0 4 &mbigen_pcie 4 13>;
43 status = "ok"; 43 status = "ok";
44 }; 44 };
45
46HiSilicon Hip06/Hip07 PCIe host bridge DT (almost-ECAM) description.
47The properties and their meanings are identical to those described in
48host-generic-pci.txt except as listed below.
49
50Properties of the host controller node that differ from
51host-generic-pci.txt:
52
53- compatible : Must be "hisilicon,pcie-almost-ecam"
54
55- reg : Two entries: First the ECAM configuration space for any
56 other bus underneath the root bus. Second, the base
57 and size of the HiSilicon host bridge registers include
58 the RC's own config space.
59
60Example:
61 pcie0: pcie@a0090000 {
62 compatible = "hisilicon,pcie-almost-ecam";
63 reg = <0 0xb0000000 0 0x2000000>, /* ECAM configuration space */
64 <0 0xa0090000 0 0x10000>; /* host bridge registers */
65 bus-range = <0 31>;
66 msi-map = <0x0000 &its_dsa 0x0000 0x2000>;
67 msi-map-mask = <0xffff>;
68 #address-cells = <3>;
69 #size-cells = <2>;
70 device_type = "pci";
71 dma-coherent;
72 ranges = <0x02000000 0 0xb2000000 0x0 0xb2000000 0 0x5ff0000
73 0x01000000 0 0 0 0xb7ff0000 0 0x10000>;
74 #interrupt-cells = <1>;
75 interrupt-map-mask = <0xf800 0 0 7>;
76 interrupt-map = <0x0 0 0 1 &mbigen_pcie0 650 4
77 0x0 0 0 2 &mbigen_pcie0 650 4
78 0x0 0 0 3 &mbigen_pcie0 650 4
79 0x0 0 0 4 &mbigen_pcie0 650 4>;
80 status = "ok";
81 };
diff --git a/Documentation/devicetree/bindings/pci/mvebu-pci.txt b/Documentation/devicetree/bindings/pci/mvebu-pci.txt
index 08c716b2c6b6..2de6f65ecfb1 100644
--- a/Documentation/devicetree/bindings/pci/mvebu-pci.txt
+++ b/Documentation/devicetree/bindings/pci/mvebu-pci.txt
@@ -78,7 +78,8 @@ and the following optional properties:
78 multiple lanes. If this property is not found, we assume that the 78 multiple lanes. If this property is not found, we assume that the
79 value is 0. 79 value is 0.
80- reset-gpios: optional gpio to PERST# 80- reset-gpios: optional gpio to PERST#
81- reset-delay-us: delay in us to wait after reset de-assertion 81- reset-delay-us: delay in us to wait after reset de-assertion, if not
82 specified will default to 100ms, as required by the PCIe specification.
82 83
83Example: 84Example:
84 85
diff --git a/Documentation/devicetree/bindings/pci/pci-iommu.txt b/Documentation/devicetree/bindings/pci/pci-iommu.txt
index 56c829621b9a..0def586fdcdf 100644
--- a/Documentation/devicetree/bindings/pci/pci-iommu.txt
+++ b/Documentation/devicetree/bindings/pci/pci-iommu.txt
@@ -32,17 +32,17 @@ PCI root complex
32Optional properties 32Optional properties
33------------------- 33-------------------
34 34
35- iommu-map: Maps a Requester ID to an IOMMU and associated iommu-specifier 35- iommu-map: Maps a Requester ID to an IOMMU and associated IOMMU specifier
36 data. 36 data.
37 37
38 The property is an arbitrary number of tuples of 38 The property is an arbitrary number of tuples of
39 (rid-base,iommu,iommu-base,length). 39 (rid-base,iommu,iommu-base,length).
40 40
41 Any RID r in the interval [rid-base, rid-base + length) is associated with 41 Any RID r in the interval [rid-base, rid-base + length) is associated with
42 the listed IOMMU, with the iommu-specifier (r - rid-base + iommu-base). 42 the listed IOMMU, with the IOMMU specifier (r - rid-base + iommu-base).
43 43
44- iommu-map-mask: A mask to be applied to each Requester ID prior to being 44- iommu-map-mask: A mask to be applied to each Requester ID prior to being
45 mapped to an iommu-specifier per the iommu-map property. 45 mapped to an IOMMU specifier per the iommu-map property.
46 46
47 47
48Example (1) 48Example (1)
diff --git a/Documentation/devicetree/bindings/pci/rcar-pci.txt b/Documentation/devicetree/bindings/pci/rcar-pci.txt
index eee518db90b9..34712d6fd253 100644
--- a/Documentation/devicetree/bindings/pci/rcar-pci.txt
+++ b/Documentation/devicetree/bindings/pci/rcar-pci.txt
@@ -6,6 +6,7 @@ compatible: "renesas,pcie-r8a7779" for the R8A7779 SoC;
6 "renesas,pcie-r8a7791" for the R8A7791 SoC; 6 "renesas,pcie-r8a7791" for the R8A7791 SoC;
7 "renesas,pcie-r8a7793" for the R8A7793 SoC; 7 "renesas,pcie-r8a7793" for the R8A7793 SoC;
8 "renesas,pcie-r8a7795" for the R8A7795 SoC; 8 "renesas,pcie-r8a7795" for the R8A7795 SoC;
9 "renesas,pcie-r8a7796" for the R8A7796 SoC;
9 "renesas,pcie-rcar-gen2" for a generic R-Car Gen2 compatible device. 10 "renesas,pcie-rcar-gen2" for a generic R-Car Gen2 compatible device.
10 "renesas,pcie-rcar-gen3" for a generic R-Car Gen3 compatible device. 11 "renesas,pcie-rcar-gen3" for a generic R-Car Gen3 compatible device.
11 12
diff --git a/Documentation/devicetree/bindings/pci/rockchip-pcie.txt b/Documentation/devicetree/bindings/pci/rockchip-pcie.txt
index 71aeda1ca055..1453a734c2f5 100644
--- a/Documentation/devicetree/bindings/pci/rockchip-pcie.txt
+++ b/Documentation/devicetree/bindings/pci/rockchip-pcie.txt
@@ -43,6 +43,8 @@ Required properties:
43- interrupt-map-mask and interrupt-map: standard PCI properties 43- interrupt-map-mask and interrupt-map: standard PCI properties
44 44
45Optional Property: 45Optional Property:
46- aspm-no-l0s: RC won't support ASPM L0s. This property is needed if
47 using 24MHz OSC for RC's PHY.
46- ep-gpios: contain the entry for pre-reset gpio 48- ep-gpios: contain the entry for pre-reset gpio
47- num-lanes: number of lanes to use 49- num-lanes: number of lanes to use
48- vpcie3v3-supply: The phandle to the 3.3v regulator to use for PCIe. 50- vpcie3v3-supply: The phandle to the 3.3v regulator to use for PCIe.
diff --git a/Documentation/devicetree/bindings/pci/samsung,exynos5440-pcie.txt b/Documentation/devicetree/bindings/pci/samsung,exynos5440-pcie.txt
index 4f9d23d2ed67..7d3b09474657 100644
--- a/Documentation/devicetree/bindings/pci/samsung,exynos5440-pcie.txt
+++ b/Documentation/devicetree/bindings/pci/samsung,exynos5440-pcie.txt
@@ -7,8 +7,19 @@ Required properties:
7- compatible: "samsung,exynos5440-pcie" 7- compatible: "samsung,exynos5440-pcie"
8- reg: base addresses and lengths of the pcie controller, 8- reg: base addresses and lengths of the pcie controller,
9 the phy controller, additional register for the phy controller. 9 the phy controller, additional register for the phy controller.
10 (Registers for the phy controller are DEPRECATED.
11 Use the PHY framework.)
12- reg-names : First name should be set to "elbi".
13 And use the "config" instead of getting the confgiruation address space
14 from "ranges".
15 NOTE: When use the "config" property, reg-names must be set.
10- interrupts: A list of interrupt outputs for level interrupt, 16- interrupts: A list of interrupt outputs for level interrupt,
11 pulse interrupt, special interrupt. 17 pulse interrupt, special interrupt.
18- phys: From PHY binding. Phandle for the Generic PHY.
19 Refer to Documentation/devicetree/bindings/phy/samsung-phy.txt
20
21Other common properties refer to
22 Documentation/devicetree/binding/pci/designware-pcie.txt
12 23
13Example: 24Example:
14 25
@@ -54,6 +65,24 @@ SoC specific DT Entry:
54 num-lanes = <4>; 65 num-lanes = <4>;
55 }; 66 };
56 67
68With using PHY framework:
69 pcie_phy0: pcie-phy@270000 {
70 ...
71 reg = <0x270000 0x1000>, <0x271000 0x40>;
72 reg-names = "phy", "block";
73 ...
74 };
75
76 pcie@290000 {
77 ...
78 reg = <0x290000 0x1000>, <0x40000000 0x1000>;
79 reg-names = "elbi", "config";
80 phys = <&pcie_phy0>;
81 ranges = <0x81000000 0 0 0x60001000 0 0x00010000
82 0x82000000 0 0x60011000 0x60011000 0 0x1ffef000>;
83 ...
84 };
85
57Board specific DT Entry: 86Board specific DT Entry:
58 87
59 pcie@290000 { 88 pcie@290000 {
diff --git a/Documentation/devicetree/bindings/phy/brcm,nsp-usb3-phy.txt b/Documentation/devicetree/bindings/phy/brcm,nsp-usb3-phy.txt
new file mode 100644
index 000000000000..e68ae5dec9c9
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/brcm,nsp-usb3-phy.txt
@@ -0,0 +1,39 @@
1Broadcom USB3 phy binding for northstar plus SoC
2The USB3 phy is internal to the SoC and is accessed using mdio interface.
3
4Required mdio bus properties:
5- reg: Should be 0x0 for SoC internal USB3 phy
6- #address-cells: must be 1
7- #size-cells: must be 0
8
9Required USB3 PHY properties:
10- compatible: should be "brcm,nsp-usb3-phy"
11- reg: USB3 Phy address on SoC internal MDIO bus and it should be 0x10.
12- usb3-ctrl-syscon: handler of syscon node defining physical address
13 of usb3 control register.
14- #phy-cells: must be 0
15
16Required usb3 control properties:
17- compatible: should be "brcm,nsp-usb3-ctrl"
18- reg: offset and length of the control registers
19
20Example:
21
22 mdio@0 {
23 reg = <0x0>;
24 #address-cells = <1>;
25 #size-cells = <0>;
26
27 usb3_phy: usb-phy@10 {
28 compatible = "brcm,nsp-usb3-phy";
29 reg = <0x10>;
30 usb3-ctrl-syscon = <&usb3_ctrl>;
31 #phy-cells = <0>;
32 status = "disabled";
33 };
34 };
35
36 usb3_ctrl: syscon@104408 {
37 compatible = "brcm,nsp-usb3-ctrl", "syscon";
38 reg = <0x104408 0x3fc>;
39 };
diff --git a/Documentation/devicetree/bindings/phy/qcom,usb-hs-phy.txt b/Documentation/devicetree/bindings/phy/qcom,usb-hs-phy.txt
new file mode 100644
index 000000000000..b3b75c1e6285
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/qcom,usb-hs-phy.txt
@@ -0,0 +1,84 @@
1Qualcomm's USB HS PHY
2
3PROPERTIES
4
5- compatible:
6 Usage: required
7 Value type: <string>
8 Definition: Should contain "qcom,usb-hs-phy" and more specifically one of the
9 following:
10
11 "qcom,usb-hs-phy-apq8064"
12 "qcom,usb-hs-phy-msm8916"
13 "qcom,usb-hs-phy-msm8974"
14
15- #phy-cells:
16 Usage: required
17 Value type: <u32>
18 Definition: Should contain 0
19
20- clocks:
21 Usage: required
22 Value type: <prop-encoded-array>
23 Definition: Should contain clock specifier for the reference and sleep
24 clocks
25
26- clock-names:
27 Usage: required
28 Value type: <stringlist>
29 Definition: Should contain "ref" and "sleep" for the reference and sleep
30 clocks respectively
31
32- resets:
33 Usage: required
34 Value type: <prop-encoded-array>
35 Definition: Should contain the phy and POR resets
36
37- reset-names:
38 Usage: required
39 Value type: <stringlist>
40 Definition: Should contain "phy" and "por" for the phy and POR resets
41 respectively
42
43- v3p3-supply:
44 Usage: required
45 Value type: <phandle>
46 Definition: Should contain a reference to the 3.3V supply
47
48- v1p8-supply:
49 Usage: required
50 Value type: <phandle>
51 Definition: Should contain a reference to the 1.8V supply
52
53- extcon:
54 Usage: optional
55 Value type: <prop-encoded-array>
56 Definition: Should contain the vbus extcon
57
58- qcom,init-seq:
59 Usage: optional
60 Value type: <u8 array>
61 Definition: Should contain a sequence of ULPI address and value pairs to
62 program into the ULPI_EXT_VENDOR_SPECIFIC area. This is related
63 to Device Mode Eye Diagram test. The addresses are offsets
64 from the ULPI_EXT_VENDOR_SPECIFIC address, for example,
65 <0x1 0x53> would mean "write the value 0x53 to address 0x81".
66
67EXAMPLE
68
69otg: usb-controller {
70 ulpi {
71 phy {
72 compatible = "qcom,usb-hs-phy-msm8974", "qcom,usb-hs-phy";
73 #phy-cells = <0>;
74 clocks = <&xo_board>, <&gcc GCC_USB2A_PHY_SLEEP_CLK>;
75 clock-names = "ref", "sleep";
76 resets = <&gcc GCC_USB2A_PHY_BCR>, <&otg 0>;
77 reset-names = "phy", "por";
78 v3p3-supply = <&pm8941_l24>;
79 v1p8-supply = <&pm8941_l6>;
80 extcon = <&smbb>;
81 qcom,init-seq = /bits/ 8 <0x1 0x63>;
82 };
83 };
84};
diff --git a/Documentation/devicetree/bindings/phy/qcom,usb-hsic-phy.txt b/Documentation/devicetree/bindings/phy/qcom,usb-hsic-phy.txt
new file mode 100644
index 000000000000..3c7cb2be4b12
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/qcom,usb-hsic-phy.txt
@@ -0,0 +1,65 @@
1Qualcomm's USB HSIC PHY
2
3PROPERTIES
4
5- compatible:
6 Usage: required
7 Value type: <string>
8 Definition: Should contain "qcom,usb-hsic-phy" and more specifically one of the
9 following:
10
11 "qcom,usb-hsic-phy-mdm9615"
12 "qcom,usb-hsic-phy-msm8974"
13
14- #phy-cells:
15 Usage: required
16 Value type: <u32>
17 Definition: Should contain 0
18
19- clocks:
20 Usage: required
21 Value type: <prop-encoded-array>
22 Definition: Should contain clock specifier for phy, calibration and
23 a calibration sleep clock
24
25- clock-names:
26 Usage: required
27 Value type: <stringlist>
28 Definition: Should contain "phy, "cal" and "cal_sleep"
29
30- pinctrl-names:
31 Usage: required
32 Value type: <stringlist>
33 Definition: Should contain "init" and "default" in that order
34
35- pinctrl-0:
36 Usage: required
37 Value type: <prop-encoded-array>
38 Definition: List of pinctrl settings to apply to keep HSIC pins in a glitch
39 free state
40
41- pinctrl-1:
42 Usage: required
43 Value type: <prop-encoded-array>
44 Definition: List of pinctrl settings to apply to mux out the HSIC pins
45
46EXAMPLE
47
48usb-controller {
49 ulpi {
50 phy {
51 compatible = "qcom,usb-hsic-phy-msm8974",
52 "qcom,usb-hsic-phy";
53 #phy-cells = <0>;
54 pinctrl-names = "init", "default";
55 pinctrl-0 = <&hsic_sleep>;
56 pinctrl-1 = <&hsic_default>;
57 clocks = <&gcc GCC_USB_HSIC_CLK>,
58 <&gcc GCC_USB_HSIC_IO_CAL_CLK>,
59 <&gcc GCC_USB_HSIC_IO_CAL_SLEEP_CLK>;
60 clock-names = "phy", "cal", "cal_sleep";
61 assigned-clocks = <&gcc GCC_USB_HSIC_IO_CAL_CLK>;
62 assigned-clock-rates = <960000>;
63 };
64 };
65};
diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index 9872ba8546bd..ab80bfe31cb3 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -191,3 +191,20 @@ Example:
191 usbdrdphy0 = &usb3_phy0; 191 usbdrdphy0 = &usb3_phy0;
192 usbdrdphy1 = &usb3_phy1; 192 usbdrdphy1 = &usb3_phy1;
193 }; 193 };
194
195Samsung Exynos SoC series PCIe PHY controller
196--------------------------------------------------
197Required properties:
198- compatible : Should be set to "samsung,exynos5440-pcie-phy"
199- #phy-cells : Must be zero
200- reg : a register used by phy driver.
201 - First is for phy register, second is for block register.
202- reg-names : Must be set to "phy" and "block".
203
204Example:
205 pcie_phy0: pcie-phy@270000 {
206 #phy-cells = <0>;
207 compatible = "samsung,exynos5440-pcie-phy";
208 reg = <0x270000 0x1000>, <0x271000 0x40>;
209 reg-names = "phy", "block";
210 };
diff --git a/Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt b/Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt
index 287150db6db4..e42334258185 100644
--- a/Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt
+++ b/Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt
@@ -10,6 +10,7 @@ Required properties:
10 * allwinner,sun8i-a23-usb-phy 10 * allwinner,sun8i-a23-usb-phy
11 * allwinner,sun8i-a33-usb-phy 11 * allwinner,sun8i-a33-usb-phy
12 * allwinner,sun8i-h3-usb-phy 12 * allwinner,sun8i-h3-usb-phy
13 * allwinner,sun8i-v3s-usb-phy
13 * allwinner,sun50i-a64-usb-phy 14 * allwinner,sun50i-a64-usb-phy
14- reg : a list of offset + length pairs 15- reg : a list of offset + length pairs
15- reg-names : 16- reg-names :
diff --git a/Documentation/devicetree/bindings/pinctrl/allwinner,sunxi-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/allwinner,sunxi-pinctrl.txt
index 7c85dca4221a..2fd688c8dbdb 100644
--- a/Documentation/devicetree/bindings/pinctrl/allwinner,sunxi-pinctrl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/allwinner,sunxi-pinctrl.txt
@@ -6,7 +6,7 @@ the first two functions being GPIO in and out. The configuration on
6the pins includes drive strength and pull-up. 6the pins includes drive strength and pull-up.
7 7
8Required properties: 8Required properties:
9- compatible: Should be one of the followings (depending on you SoC): 9- compatible: Should be one of the following (depending on your SoC):
10 "allwinner,sun4i-a10-pinctrl" 10 "allwinner,sun4i-a10-pinctrl"
11 "allwinner,sun5i-a10s-pinctrl" 11 "allwinner,sun5i-a10s-pinctrl"
12 "allwinner,sun5i-a13-pinctrl" 12 "allwinner,sun5i-a13-pinctrl"
diff --git a/Documentation/devicetree/bindings/power/pd-samsung.txt b/Documentation/devicetree/bindings/power/pd-samsung.txt
index 4e947372a693..549f7dee9b9d 100644
--- a/Documentation/devicetree/bindings/power/pd-samsung.txt
+++ b/Documentation/devicetree/bindings/power/pd-samsung.txt
@@ -6,12 +6,15 @@ to gate power to one or more peripherals on the processor.
6Required Properties: 6Required Properties:
7- compatible: should be one of the following. 7- compatible: should be one of the following.
8 * samsung,exynos4210-pd - for exynos4210 type power domain. 8 * samsung,exynos4210-pd - for exynos4210 type power domain.
9 * samsung,exynos5433-pd - for exynos5433 type power domain.
9- reg: physical base address of the controller and length of memory mapped 10- reg: physical base address of the controller and length of memory mapped
10 region. 11 region.
11- #power-domain-cells: number of cells in power domain specifier; 12- #power-domain-cells: number of cells in power domain specifier;
12 must be 0. 13 must be 0.
13 14
14Optional Properties: 15Optional Properties:
16- label: Human readable string with domain name. Will be visible in userspace
17 to let user to distinguish between multiple domains in SoC.
15- clocks: List of clock handles. The parent clocks of the input clocks to the 18- clocks: List of clock handles. The parent clocks of the input clocks to the
16 devices in this power domain are set to oscclk before power gating 19 devices in this power domain are set to oscclk before power gating
17 and restored back after powering on a domain. This is required for 20 and restored back after powering on a domain. This is required for
@@ -20,7 +23,7 @@ Optional Properties:
20- clock-names: The following clocks can be specified: 23- clock-names: The following clocks can be specified:
21 - oscclk: Oscillator clock. 24 - oscclk: Oscillator clock.
22 - clkN: Input clocks to the devices in this power domain. These clocks 25 - clkN: Input clocks to the devices in this power domain. These clocks
23 will be reparented to oscclk before swithing power domain off. 26 will be reparented to oscclk before switching power domain off.
24 Their original parent will be brought back after turning on 27 Their original parent will be brought back after turning on
25 the domain. Maximum of 4 clocks (N = 0 to 3) are supported. 28 the domain. Maximum of 4 clocks (N = 0 to 3) are supported.
26 - asbN: Clocks required by asynchronous bridges (ASB) present in 29 - asbN: Clocks required by asynchronous bridges (ASB) present in
@@ -38,6 +41,7 @@ Example:
38 compatible = "samsung,exynos4210-pd"; 41 compatible = "samsung,exynos4210-pd";
39 reg = <0x10023C00 0x10>; 42 reg = <0x10023C00 0x10>;
40 #power-domain-cells = <0>; 43 #power-domain-cells = <0>;
44 label = "LCD0";
41 }; 45 };
42 46
43 mfc_pd: power-domain@10044060 { 47 mfc_pd: power-domain@10044060 {
@@ -46,6 +50,7 @@ Example:
46 clocks = <&clock CLK_FIN_PLL>, <&clock CLK_MOUT_USER_ACLK333>; 50 clocks = <&clock CLK_FIN_PLL>, <&clock CLK_MOUT_USER_ACLK333>;
47 clock-names = "oscclk", "clk0"; 51 clock-names = "oscclk", "clk0";
48 #power-domain-cells = <0>; 52 #power-domain-cells = <0>;
53 label = "MFC";
49 }; 54 };
50 55
51See Documentation/devicetree/bindings/power/power_domain.txt for description 56See Documentation/devicetree/bindings/power/power_domain.txt for description
diff --git a/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt b/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt
index d4eab9227ea4..e62d53d844cc 100644
--- a/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt
+++ b/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt
@@ -2,12 +2,12 @@ Driver a GPIO line that can be used to turn the power off.
2 2
3The driver supports both level triggered and edge triggered power off. 3The driver supports both level triggered and edge triggered power off.
4At driver load time, the driver will request the given gpio line and 4At driver load time, the driver will request the given gpio line and
5install a pm_power_off handler. If the optional properties 'input' is 5install a handler to power off the system. If the optional properties
6not found, the GPIO line will be driven in the inactive 6'input' is not found, the GPIO line will be driven in the inactive
7state. Otherwise its configured as an input. 7state. Otherwise its configured as an input.
8 8
9When the pm_power_off is called, the gpio is configured as an output, 9When the power-off handler is called, the gpio is configured as an
10and drive active, so triggering a level triggered power off 10output, and drive active, so triggering a level triggered power off
11condition. This will also cause an inactive->active edge condition, so 11condition. This will also cause an inactive->active edge condition, so
12triggering positive edge triggered power off. After a delay of 100ms, 12triggering positive edge triggered power off. After a delay of 100ms,
13the GPIO is set to inactive, thus causing an active->inactive edge, 13the GPIO is set to inactive, thus causing an active->inactive edge,
@@ -24,7 +24,7 @@ Required properties:
24 24
25Optional properties: 25Optional properties:
26- input : Initially configure the GPIO line as an input. Only reconfigure 26- input : Initially configure the GPIO line as an input. Only reconfigure
27 it to an output when the pm_power_off function is called. If this optional 27 it to an output when the power-off handler is called. If this optional
28 property is not specified, the GPIO is initialized as an output in its 28 property is not specified, the GPIO is initialized as an output in its
29 inactive state. 29 inactive state.
30 30
diff --git a/Documentation/devicetree/bindings/power/reset/qnap-poweroff.txt b/Documentation/devicetree/bindings/power/reset/qnap-poweroff.txt
index af25e77c0e0c..c363d7173129 100644
--- a/Documentation/devicetree/bindings/power/reset/qnap-poweroff.txt
+++ b/Documentation/devicetree/bindings/power/reset/qnap-poweroff.txt
@@ -3,8 +3,7 @@
3QNAP NAS devices have a microcontroller controlling the main power 3QNAP NAS devices have a microcontroller controlling the main power
4supply. This microcontroller is connected to UART1 of the Kirkwood and 4supply. This microcontroller is connected to UART1 of the Kirkwood and
5Orion5x SoCs. Sending the character 'A', at 19200 baud, tells the 5Orion5x SoCs. Sending the character 'A', at 19200 baud, tells the
6microcontroller to turn the power off. This driver adds a handler to 6microcontroller to turn the power off.
7pm_power_off which is called to turn the power off.
8 7
9Synology NAS devices use a similar scheme, but a different baud rate, 8Synology NAS devices use a similar scheme, but a different baud rate,
109600, and a different character, '1'. 99600, and a different character, '1'.
diff --git a/Documentation/devicetree/bindings/powerpc/4xx/emac.txt b/Documentation/devicetree/bindings/powerpc/4xx/emac.txt
index 712baf6c3e24..44b842b6ca15 100644
--- a/Documentation/devicetree/bindings/powerpc/4xx/emac.txt
+++ b/Documentation/devicetree/bindings/powerpc/4xx/emac.txt
@@ -71,6 +71,9 @@
71 For Axon it can be absent, though my current driver 71 For Axon it can be absent, though my current driver
72 doesn't handle phy-address yet so for now, keep 72 doesn't handle phy-address yet so for now, keep
73 0x00ffffff in it. 73 0x00ffffff in it.
74 - phy-handle : Used to describe configurations where a external PHY
75 is used. Please refer to:
76 Documentation/devicetree/bindings/net/ethernet.txt
74 - rx-fifo-size-gige : 1 cell, Rx fifo size in bytes for 1000 Mb/sec 77 - rx-fifo-size-gige : 1 cell, Rx fifo size in bytes for 1000 Mb/sec
75 operations (if absent the value is the same as 78 operations (if absent the value is the same as
76 rx-fifo-size). For Axon, either absent or 2048. 79 rx-fifo-size). For Axon, either absent or 2048.
@@ -81,8 +84,22 @@
81 offload, phandle of the TAH device node. 84 offload, phandle of the TAH device node.
82 - tah-channel : 1 cell, optional. If appropriate, channel used on the 85 - tah-channel : 1 cell, optional. If appropriate, channel used on the
83 TAH engine. 86 TAH engine.
87 - fixed-link : Fixed-link subnode describing a link to a non-MDIO
88 managed entity. See
89 Documentation/devicetree/bindings/net/fixed-link.txt
90 for details.
91 - mdio subnode : When the EMAC has a phy connected to its local
92 mdio, which us supported by the kernel's network
93 PHY library in drivers/net/phy, there must be device
94 tree subnode with the following required properties:
95 - #address-cells: Must be <1>.
96 - #size-cells: Must be <0>.
84 97
85 Example: 98 For PHY definitions: Please refer to
99 Documentation/devicetree/bindings/net/phy.txt and
100 Documentation/devicetree/bindings/net/ethernet.txt
101
102 Examples:
86 103
87 EMAC0: ethernet@40000800 { 104 EMAC0: ethernet@40000800 {
88 device_type = "network"; 105 device_type = "network";
@@ -104,6 +121,48 @@
104 zmii-channel = <0>; 121 zmii-channel = <0>;
105 }; 122 };
106 123
124 EMAC1: ethernet@ef600c00 {
125 device_type = "network";
126 compatible = "ibm,emac-apm821xx", "ibm,emac4sync";
127 interrupt-parent = <&EMAC1>;
128 interrupts = <0 1>;
129 #interrupt-cells = <1>;
130 #address-cells = <0>;
131 #size-cells = <0>;
132 interrupt-map = <0 &UIC2 0x10 IRQ_TYPE_LEVEL_HIGH /* Status */
133 1 &UIC2 0x14 IRQ_TYPE_LEVEL_HIGH /* Wake */>;
134 reg = <0xef600c00 0x000000c4>;
135 local-mac-address = [000000000000]; /* Filled in by U-Boot */
136 mal-device = <&MAL0>;
137 mal-tx-channel = <0>;
138 mal-rx-channel = <0>;
139 cell-index = <0>;
140 max-frame-size = <9000>;
141 rx-fifo-size = <16384>;
142 tx-fifo-size = <2048>;
143 fifo-entry-size = <10>;
144 phy-mode = "rgmii";
145 phy-handle = <&phy0>;
146 phy-map = <0x00000000>;
147 rgmii-device = <&RGMII0>;
148 rgmii-channel = <0>;
149 tah-device = <&TAH0>;
150 tah-channel = <0>;
151 has-inverted-stacr-oc;
152 has-new-stacr-staopc;
153
154 mdio {
155 #address-cells = <1>;
156 #size-cells = <0>;
157
158 phy0: ethernet-phy@0 {
159 compatible = "ethernet-phy-ieee802.3-c22";
160 reg = <0>;
161 };
162 };
163 };
164
165
107 ii) McMAL node 166 ii) McMAL node
108 167
109 Required properties: 168 Required properties:
@@ -145,4 +204,3 @@
145 - revision : as provided by the RGMII new version register if 204 - revision : as provided by the RGMII new version register if
146 available. 205 available.
147 For Axon: 0x0000012a 206 For Axon: 0x0000012a
148
diff --git a/Documentation/devicetree/bindings/powerpc/fsl/l2cache.txt b/Documentation/devicetree/bindings/powerpc/fsl/l2cache.txt
index c41b2187eaa8..dc9bb3182525 100644
--- a/Documentation/devicetree/bindings/powerpc/fsl/l2cache.txt
+++ b/Documentation/devicetree/bindings/powerpc/fsl/l2cache.txt
@@ -5,8 +5,46 @@ The cache bindings explained below are ePAPR compliant
5 5
6Required Properties: 6Required Properties:
7 7
8- compatible : Should include "fsl,chip-l2-cache-controller" and "cache" 8- compatible : Should include one of the following:
9 where chip is the processor (bsc9132, npc8572 etc.) 9 "fsl,8540-l2-cache-controller"
10 "fsl,8541-l2-cache-controller"
11 "fsl,8544-l2-cache-controller"
12 "fsl,8548-l2-cache-controller"
13 "fsl,8555-l2-cache-controller"
14 "fsl,8568-l2-cache-controller"
15 "fsl,b4420-l2-cache-controller"
16 "fsl,b4860-l2-cache-controller"
17 "fsl,bsc9131-l2-cache-controller"
18 "fsl,bsc9132-l2-cache-controller"
19 "fsl,c293-l2-cache-controller"
20 "fsl,mpc8536-l2-cache-controller"
21 "fsl,mpc8540-l2-cache-controller"
22 "fsl,mpc8541-l2-cache-controller"
23 "fsl,mpc8544-l2-cache-controller"
24 "fsl,mpc8548-l2-cache-controller"
25 "fsl,mpc8555-l2-cache-controller"
26 "fsl,mpc8560-l2-cache-controller"
27 "fsl,mpc8568-l2-cache-controller"
28 "fsl,mpc8569-l2-cache-controller"
29 "fsl,mpc8572-l2-cache-controller"
30 "fsl,p1010-l2-cache-controller"
31 "fsl,p1011-l2-cache-controller"
32 "fsl,p1012-l2-cache-controller"
33 "fsl,p1013-l2-cache-controller"
34 "fsl,p1014-l2-cache-controller"
35 "fsl,p1015-l2-cache-controller"
36 "fsl,p1016-l2-cache-controller"
37 "fsl,p1020-l2-cache-controller"
38 "fsl,p1021-l2-cache-controller"
39 "fsl,p1022-l2-cache-controller"
40 "fsl,p1023-l2-cache-controller"
41 "fsl,p1024-l2-cache-controller"
42 "fsl,p1025-l2-cache-controller"
43 "fsl,p2010-l2-cache-controller"
44 "fsl,p2020-l2-cache-controller"
45 "fsl,t2080-l2-cache-controller"
46 "fsl,t4240-l2-cache-controller"
47 and "cache".
10- reg : Address and size of L2 cache controller registers 48- reg : Address and size of L2 cache controller registers
11- cache-size : Size of the entire L2 cache 49- cache-size : Size of the entire L2 cache
12- interrupts : Error interrupt of L2 controller 50- interrupts : Error interrupt of L2 controller
diff --git a/Documentation/devicetree/bindings/powerpc/opal/power-mgt.txt b/Documentation/devicetree/bindings/powerpc/opal/power-mgt.txt
new file mode 100644
index 000000000000..9d619e955576
--- /dev/null
+++ b/Documentation/devicetree/bindings/powerpc/opal/power-mgt.txt
@@ -0,0 +1,118 @@
1IBM Power-Management Bindings
2=============================
3
4Linux running on baremetal POWER machines has access to the processor
5idle states. The description of these idle states is exposed via the
6node @power-mgt in the device-tree by the firmware.
7
8Definitions:
9----------------
10Typically each idle state has the following associated properties:
11
12- name: The name of the idle state as defined by the firmware.
13
14- flags: indicating some aspects of this idle states such as the
15 extent of state-loss, whether timebase is stopped on this
16 idle states and so on. The flag bits are as follows:
17
18- exit-latency: The latency involved in transitioning the state of the
19 CPU from idle to running.
20
21- target-residency: The minimum time that the CPU needs to reside in
22 this idle state in order to accrue power-savings
23 benefit.
24
25Properties
26----------------
27The following properties provide details about the idle states. These
28properties are exposed as arrays. Each entry in the property array
29provides the value of that property for the idle state associated with
30the array index of that entry.
31
32If idle-states are defined, then the properties
33"ibm,cpu-idle-state-names" and "ibm,cpu-idle-state-flags" are
34required. The other properties are required unless mentioned
35otherwise. The length of all the property arrays must be the same.
36
37- ibm,cpu-idle-state-names:
38 Array of strings containing the names of the idle states.
39
40- ibm,cpu-idle-state-flags:
41 Array of unsigned 32-bit values containing the values of the
42 flags associated with the the aforementioned idle-states. The
43 flag bits are as follows:
44 0x00000001 /* Decrementer would stop */
45 0x00000002 /* Needs timebase restore */
46 0x00001000 /* Restore GPRs like nap */
47 0x00002000 /* Restore hypervisor resource from PACA pointer */
48 0x00004000 /* Program PORE to restore PACA pointer */
49 0x00010000 /* This is a nap state (POWER7,POWER8) */
50 0x00020000 /* This is a fast-sleep state (POWER8)*/
51 0x00040000 /* This is a winkle state (POWER8) */
52 0x00080000 /* This is a fast-sleep state which requires a */
53 /* software workaround for restoring the */
54 /* timebase (POWER8) */
55 0x00800000 /* This state uses SPR PMICR instruction */
56 /* (POWER8)*/
57 0x00100000 /* This is a fast stop state (POWER9) */
58 0x00200000 /* This is a deep-stop state (POWER9) */
59
60- ibm,cpu-idle-state-latencies-ns:
61 Array of unsigned 32-bit values containing the values of the
62 exit-latencies (in ns) for the idle states in
63 ibm,cpu-idle-state-names.
64
65- ibm,cpu-idle-state-residency-ns:
66 Array of unsigned 32-bit values containing the values of the
67 target-residency (in ns) for the idle states in
68 ibm,cpu-idle-state-names. On POWER8 this is an optional
69 property. If the property is absent, the target residency for
70 the "Nap", "FastSleep" are defined to 10000 and 300000000
71 respectively by the kernel. On POWER9 this property is required.
72
73- ibm,cpu-idle-state-psscr:
74 Array of unsigned 64-bit values containing the values for the
75 PSSCR for each of the idle states in ibm,cpu-idle-state-names.
76 This property is required on POWER9 and absent on POWER8.
77
78- ibm,cpu-idle-state-psscr-mask:
79 Array of unsigned 64-bit values containing the masks
80 indicating which psscr fields are set in the corresponding
81 entries of ibm,cpu-idle-state-psscr. This property is
82 required on POWER9 and absent on POWER8.
83
84 Whenever the firmware sets an entry in
85 ibm,cpu-idle-state-psscr-mask value to 0xf, it implies that
86 only the Requested Level (RL) field of the corresponding entry
87 in ibm,cpu-idle-state-psscr should be considered by the
88 kernel. For such idle states, the kernel would set the
89 remaining fields of the psscr to the following sane-default
90 values.
91
92 - ESL and EC bits are to 1. So wakeup from any stop
93 state will be at vector 0x100.
94
95 - MTL and PSLL are set to the maximum allowed value as
96 per the ISA, i.e. 15.
97
98 - The Transition Rate, TR is set to the Maximum value
99 3.
100
101 For all the other values of the entry in
102 ibm,cpu-idle-state-psscr-mask, the kernel expects all the
103 psscr fields of the corresponding entry in
104 ibm,cpu-idle-state-psscr to be correctly set by the firmware.
105
106- ibm,cpu-idle-state-pmicr:
107 Array of unsigned 64-bit values containing the pmicr values
108 for the idle states in ibm,cpu-idle-state-names. This 64-bit
109 register value is to be set in pmicr for the corresponding
110 state if the flag indicates that pmicr SPR should be set. This
111 is an optional property on POWER8 and is absent on
112 POWER9.
113
114- ibm,cpu-idle-state-pmicr-mask:
115 Array of unsigned 64-bit values containing the mask indicating
116 which of the fields of the PMICR are set in the corresponding
117 entries in ibm,cpu-idle-state-pmicr. This is an optional
118 property on POWER8 and is absent on POWER9.
diff --git a/Documentation/devicetree/bindings/pwm/imx-pwm.txt b/Documentation/devicetree/bindings/pwm/imx-pwm.txt
index e00c2e9f484d..c61bdf8cd41b 100644
--- a/Documentation/devicetree/bindings/pwm/imx-pwm.txt
+++ b/Documentation/devicetree/bindings/pwm/imx-pwm.txt
@@ -6,8 +6,8 @@ Required properties:
6 - "fsl,imx1-pwm" for PWM compatible with the one integrated on i.MX1 6 - "fsl,imx1-pwm" for PWM compatible with the one integrated on i.MX1
7 - "fsl,imx27-pwm" for PWM compatible with the one integrated on i.MX27 7 - "fsl,imx27-pwm" for PWM compatible with the one integrated on i.MX27
8- reg: physical base address and length of the controller's registers 8- reg: physical base address and length of the controller's registers
9- #pwm-cells: should be 2. See pwm.txt in this directory for a description of 9- #pwm-cells: 2 for i.MX1 and 3 for i.MX27 and newer SoCs. See pwm.txt
10 the cells format. 10 in this directory for a description of the cells format.
11- clocks : Clock specifiers for both ipg and per clocks. 11- clocks : Clock specifiers for both ipg and per clocks.
12- clock-names : Clock names should include both "ipg" and "per" 12- clock-names : Clock names should include both "ipg" and "per"
13See the clock consumer binding, 13See the clock consumer binding,
@@ -17,7 +17,7 @@ See the clock consumer binding,
17Example: 17Example:
18 18
19pwm1: pwm@53fb4000 { 19pwm1: pwm@53fb4000 {
20 #pwm-cells = <2>; 20 #pwm-cells = <3>;
21 compatible = "fsl,imx53-pwm", "fsl,imx27-pwm"; 21 compatible = "fsl,imx53-pwm", "fsl,imx27-pwm";
22 reg = <0x53fb4000 0x4000>; 22 reg = <0x53fb4000 0x4000>;
23 clocks = <&clks IMX5_CLK_PWM1_IPG_GATE>, 23 clocks = <&clks IMX5_CLK_PWM1_IPG_GATE>,
diff --git a/Documentation/devicetree/bindings/pwm/pwm-stm32.txt b/Documentation/devicetree/bindings/pwm/pwm-stm32.txt
new file mode 100644
index 000000000000..6dd040363e5e
--- /dev/null
+++ b/Documentation/devicetree/bindings/pwm/pwm-stm32.txt
@@ -0,0 +1,35 @@
1STMicroelectronics STM32 Timers PWM bindings
2
3Must be a sub-node of an STM32 Timers device tree node.
4See ../mfd/stm32-timers.txt for details about the parent node.
5
6Required parameters:
7- compatible: Must be "st,stm32-pwm".
8- pinctrl-names: Set to "default".
9- pinctrl-0: List of phandles pointing to pin configuration nodes for PWM module.
10 For Pinctrl properties see ../pinctrl/pinctrl-bindings.txt
11
12Optional parameters:
13- st,breakinput: One or two <index level filter> to describe break input configurations.
14 "index" indicates on which break input (0 or 1) the configuration
15 should be applied.
16 "level" gives the active level (0=low or 1=high) of the input signal
17 for this configuration.
18 "filter" gives the filtering value to be applied.
19
20Example:
21 timers@40010000 {
22 #address-cells = <1>;
23 #size-cells = <0>;
24 compatible = "st,stm32-timers";
25 reg = <0x40010000 0x400>;
26 clocks = <&rcc 0 160>;
27 clock-names = "clk_int";
28
29 pwm {
30 compatible = "st,stm32-pwm";
31 pinctrl-0 = <&pwm1_pins>;
32 pinctrl-names = "default";
33 st,breakinput = <0 1 5>;
34 };
35 };
diff --git a/Documentation/devicetree/bindings/regulator/ti-abb-regulator.txt b/Documentation/devicetree/bindings/regulator/ti-abb-regulator.txt
index c3f6546ebac7..6a23ad9ac53a 100644
--- a/Documentation/devicetree/bindings/regulator/ti-abb-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/ti-abb-regulator.txt
@@ -45,7 +45,7 @@ Required Properties:
45Optional Properties: 45Optional Properties:
46- reg-names: In addition to the required properties, the following are optional 46- reg-names: In addition to the required properties, the following are optional
47 - "efuse-address" - Contains efuse base address used to pick up ABB info. 47 - "efuse-address" - Contains efuse base address used to pick up ABB info.
48 - "ldo-address" - Contains address of ABB LDO overide register address. 48 - "ldo-address" - Contains address of ABB LDO override register.
49 "efuse-address" is required for this. 49 "efuse-address" is required for this.
50- ti,ldovbb-vset-mask - Required if ldo-address is set, mask for LDO override 50- ti,ldovbb-vset-mask - Required if ldo-address is set, mask for LDO override
51 register to provide override vset value. 51 register to provide override vset value.
diff --git a/Documentation/devicetree/bindings/remoteproc/qcom,adsp.txt b/Documentation/devicetree/bindings/remoteproc/qcom,adsp.txt
index b85885a298d8..75ad7b8df0b1 100644
--- a/Documentation/devicetree/bindings/remoteproc/qcom,adsp.txt
+++ b/Documentation/devicetree/bindings/remoteproc/qcom,adsp.txt
@@ -9,6 +9,7 @@ on the Qualcomm ADSP Hexagon core.
9 Definition: must be one of: 9 Definition: must be one of:
10 "qcom,msm8974-adsp-pil" 10 "qcom,msm8974-adsp-pil"
11 "qcom,msm8996-adsp-pil" 11 "qcom,msm8996-adsp-pil"
12 "qcom,msm8996-slpi-pil"
12 13
13- interrupts-extended: 14- interrupts-extended:
14 Usage: required 15 Usage: required
@@ -24,13 +25,13 @@ on the Qualcomm ADSP Hexagon core.
24- clocks: 25- clocks:
25 Usage: required 26 Usage: required
26 Value type: <prop-encoded-array> 27 Value type: <prop-encoded-array>
27 Definition: reference to the xo clock to be held on behalf of the 28 Definition: reference to the xo clock and optionally aggre2 clock to be
28 booting Hexagon core 29 held on behalf of the booting Hexagon core
29 30
30- clock-names: 31- clock-names:
31 Usage: required 32 Usage: required
32 Value type: <stringlist> 33 Value type: <stringlist>
33 Definition: must be "xo" 34 Definition: must be "xo" and optionally include "aggre2"
34 35
35- cx-supply: 36- cx-supply:
36 Usage: required 37 Usage: required
@@ -38,6 +39,12 @@ on the Qualcomm ADSP Hexagon core.
38 Definition: reference to the regulator to be held on behalf of the 39 Definition: reference to the regulator to be held on behalf of the
39 booting Hexagon core 40 booting Hexagon core
40 41
42- px-supply:
43 Usage: required
44 Value type: <phandle>
45 Definition: reference to the px regulator to be held on behalf of the
46 booting Hexagon core
47
41- memory-region: 48- memory-region:
42 Usage: required 49 Usage: required
43 Value type: <phandle> 50 Value type: <phandle>
@@ -96,3 +103,31 @@ ADSP, as it is found on MSM8974 boards.
96 qcom,smd-edge = <1>; 103 qcom,smd-edge = <1>;
97 }; 104 };
98 }; 105 };
106
107The following example describes the resources needed to boot control the
108SLPI, as it is found on MSM8996 boards.
109
110 slpi {
111 compatible = "qcom,msm8996-slpi-pil";
112 interrupts-extended = <&intc 0 390 IRQ_TYPE_EDGE_RISING>,
113 <&slpi_smp2p_in 0 IRQ_TYPE_EDGE_RISING>,
114 <&slpi_smp2p_in 1 IRQ_TYPE_EDGE_RISING>,
115 <&slpi_smp2p_in 2 IRQ_TYPE_EDGE_RISING>,
116 <&slpi_smp2p_in 3 IRQ_TYPE_EDGE_RISING>;
117 interrupt-names = "wdog",
118 "fatal",
119 "ready",
120 "handover",
121 "stop-ack";
122
123 clocks = <&rpmcc MSM8996_RPM_SMD_XO_CLK_SRC>,
124 <&rpmcc MSM8996_RPM_SMD_AGGR2_NOC_CLK>;
125 clock-names = "xo", "aggre2";
126
127 cx-supply = <&pm8994_l26>;
128 px-supply = <&pm8994_lvs2>;
129
130 memory-region = <&slpi_region>;
131 qcom,smem-states = <&slpi_smp2p_out 0>;
132 qcom,smem-state-names = "stop";
133 };
diff --git a/Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt b/Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt
index 57cb49ec55ca..92347fe6890e 100644
--- a/Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt
+++ b/Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt
@@ -7,7 +7,9 @@ on the Qualcomm Hexagon core.
7 Usage: required 7 Usage: required
8 Value type: <string> 8 Value type: <string>
9 Definition: must be one of: 9 Definition: must be one of:
10 "qcom,q6v5-pil" 10 "qcom,q6v5-pil",
11 "qcom,msm8916-mss-pil",
12 "qcom,msm8974-mss-pil"
11 13
12- reg: 14- reg:
13 Usage: required 15 Usage: required
diff --git a/Documentation/devicetree/bindings/reset/hisilicon,hi3660-reset.txt b/Documentation/devicetree/bindings/reset/hisilicon,hi3660-reset.txt
new file mode 100644
index 000000000000..2bf3344b2a02
--- /dev/null
+++ b/Documentation/devicetree/bindings/reset/hisilicon,hi3660-reset.txt
@@ -0,0 +1,43 @@
1Hisilicon System Reset Controller
2======================================
3
4Please also refer to reset.txt in this directory for common reset
5controller binding usage.
6
7The reset controller registers are part of the system-ctl block on
8hi3660 SoC.
9
10Required properties:
11- compatible: should be
12 "hisilicon,hi3660-reset"
13- hisi,rst-syscon: phandle of the reset's syscon.
14- #reset-cells : Specifies the number of cells needed to encode a
15 reset source. The type shall be a <u32> and the value shall be 2.
16
17 Cell #1 : offset of the reset assert control
18 register from the syscon register base
19 offset + 4: deassert control register
20 offset + 8: status control register
21 Cell #2 : bit position of the reset in the reset control register
22
23Example:
24 iomcu: iomcu@ffd7e000 {
25 compatible = "hisilicon,hi3660-iomcu", "syscon";
26 reg = <0x0 0xffd7e000 0x0 0x1000>;
27 };
28
29 iomcu_rst: iomcu_rst_controller {
30 compatible = "hisilicon,hi3660-reset";
31 hisi,rst-syscon = <&iomcu>;
32 #reset-cells = <2>;
33 };
34
35Specifying reset lines connected to IP modules
36==============================================
37example:
38
39 i2c0: i2c@..... {
40 ...
41 resets = <&iomcu_rst 0x20 3>; /* offset: 0x20; bit: 3 */
42 ...
43 };
diff --git a/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt b/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt
index 164c7f34c451..c516d24959f2 100644
--- a/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt
+++ b/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt
@@ -63,7 +63,7 @@ Example:
63-------- 63--------
64The following example demonstrates a syscon node, the reset controller node 64The following example demonstrates a syscon node, the reset controller node
65using the syscon node, and a consumer (a DSP device) on the TI Keystone 2 65using the syscon node, and a consumer (a DSP device) on the TI Keystone 2
66Edison SoC. 6666AK2E SoC.
67 67
68/ { 68/ {
69 soc { 69 soc {
@@ -71,13 +71,13 @@ Edison SoC.
71 compatible = "syscon", "simple-mfd"; 71 compatible = "syscon", "simple-mfd";
72 reg = <0x02350000 0x1000>; 72 reg = <0x02350000 0x1000>;
73 73
74 pscrst: psc-reset { 74 pscrst: reset-controller {
75 compatible = "ti,k2e-pscrst", "ti,syscon-reset"; 75 compatible = "ti,k2e-pscrst", "ti,syscon-reset";
76 #reset-cells = <1>; 76 #reset-cells = <1>;
77 77
78 ti,reset-bits = < 78 ti,reset-bits = <
79 0xa3c 8 0xa3c 8 0x83c 8 (ASSERT_SET|DEASSERT_CLEAR|STATUS_SET) /* 0: pcrst-dsp0 */ 79 0xa3c 8 0xa3c 8 0x83c 8 (ASSERT_CLEAR | DEASSERT_SET | STATUS_CLEAR) /* 0: dsp0 */
80 0xa40 5 0xa44 3 0 0 (ASSERT_SET|DEASSERT_CLEAR|STATUS_NONE) /* 1: pcrst-example */ 80 0xa40 5 0xa44 3 0 0 (ASSERT_SET | DEASSERT_CLEAR | STATUS_NONE) /* 1: example */
81 >; 81 >;
82 }; 82 };
83 }; 83 };
diff --git a/Documentation/devicetree/bindings/reset/uniphier-reset.txt b/Documentation/devicetree/bindings/reset/uniphier-reset.txt
index 5020524cddeb..83ab0f599c40 100644
--- a/Documentation/devicetree/bindings/reset/uniphier-reset.txt
+++ b/Documentation/devicetree/bindings/reset/uniphier-reset.txt
@@ -6,14 +6,14 @@ System reset
6 6
7Required properties: 7Required properties:
8- compatible: should be one of the following: 8- compatible: should be one of the following:
9 "socionext,uniphier-sld3-reset" - for sLD3 SoC. 9 "socionext,uniphier-sld3-reset" - for sLD3 SoC
10 "socionext,uniphier-ld4-reset" - for LD4 SoC. 10 "socionext,uniphier-ld4-reset" - for LD4 SoC
11 "socionext,uniphier-pro4-reset" - for Pro4 SoC. 11 "socionext,uniphier-pro4-reset" - for Pro4 SoC
12 "socionext,uniphier-sld8-reset" - for sLD8 SoC. 12 "socionext,uniphier-sld8-reset" - for sLD8 SoC
13 "socionext,uniphier-pro5-reset" - for Pro5 SoC. 13 "socionext,uniphier-pro5-reset" - for Pro5 SoC
14 "socionext,uniphier-pxs2-reset" - for PXs2/LD6b SoC. 14 "socionext,uniphier-pxs2-reset" - for PXs2/LD6b SoC
15 "socionext,uniphier-ld11-reset" - for LD11 SoC. 15 "socionext,uniphier-ld11-reset" - for LD11 SoC
16 "socionext,uniphier-ld20-reset" - for LD20 SoC. 16 "socionext,uniphier-ld20-reset" - for LD20 SoC
17- #reset-cells: should be 1. 17- #reset-cells: should be 1.
18 18
19Example: 19Example:
@@ -37,14 +37,15 @@ Media I/O (MIO) reset, SD reset
37 37
38Required properties: 38Required properties:
39- compatible: should be one of the following: 39- compatible: should be one of the following:
40 "socionext,uniphier-sld3-mio-reset" - for sLD3 SoC. 40 "socionext,uniphier-sld3-mio-reset" - for sLD3 SoC
41 "socionext,uniphier-ld4-mio-reset" - for LD4 SoC. 41 "socionext,uniphier-ld4-mio-reset" - for LD4 SoC
42 "socionext,uniphier-pro4-mio-reset" - for Pro4 SoC. 42 "socionext,uniphier-pro4-mio-reset" - for Pro4 SoC
43 "socionext,uniphier-sld8-mio-reset" - for sLD8 SoC. 43 "socionext,uniphier-sld8-mio-reset" - for sLD8 SoC
44 "socionext,uniphier-pro5-sd-reset" - for Pro5 SoC. 44 "socionext,uniphier-pro5-sd-reset" - for Pro5 SoC
45 "socionext,uniphier-pxs2-sd-reset" - for PXs2/LD6b SoC. 45 "socionext,uniphier-pxs2-sd-reset" - for PXs2/LD6b SoC
46 "socionext,uniphier-ld11-mio-reset" - for LD11 SoC. 46 "socionext,uniphier-ld11-mio-reset" - for LD11 SoC (MIO)
47 "socionext,uniphier-ld20-sd-reset" - for LD20 SoC. 47 "socionext,uniphier-ld11-sd-reset" - for LD11 SoC (SD)
48 "socionext,uniphier-ld20-sd-reset" - for LD20 SoC
48- #reset-cells: should be 1. 49- #reset-cells: should be 1.
49 50
50Example: 51Example:
@@ -68,13 +69,13 @@ Peripheral reset
68 69
69Required properties: 70Required properties:
70- compatible: should be one of the following: 71- compatible: should be one of the following:
71 "socionext,uniphier-ld4-peri-reset" - for LD4 SoC. 72 "socionext,uniphier-ld4-peri-reset" - for LD4 SoC
72 "socionext,uniphier-pro4-peri-reset" - for Pro4 SoC. 73 "socionext,uniphier-pro4-peri-reset" - for Pro4 SoC
73 "socionext,uniphier-sld8-peri-reset" - for sLD8 SoC. 74 "socionext,uniphier-sld8-peri-reset" - for sLD8 SoC
74 "socionext,uniphier-pro5-peri-reset" - for Pro5 SoC. 75 "socionext,uniphier-pro5-peri-reset" - for Pro5 SoC
75 "socionext,uniphier-pxs2-peri-reset" - for PXs2/LD6b SoC. 76 "socionext,uniphier-pxs2-peri-reset" - for PXs2/LD6b SoC
76 "socionext,uniphier-ld11-peri-reset" - for LD11 SoC. 77 "socionext,uniphier-ld11-peri-reset" - for LD11 SoC
77 "socionext,uniphier-ld20-peri-reset" - for LD20 SoC. 78 "socionext,uniphier-ld20-peri-reset" - for LD20 SoC
78- #reset-cells: should be 1. 79- #reset-cells: should be 1.
79 80
80Example: 81Example:
diff --git a/Documentation/devicetree/bindings/reset/zte,zx2967-reset.txt b/Documentation/devicetree/bindings/reset/zte,zx2967-reset.txt
new file mode 100644
index 000000000000..b015508f9780
--- /dev/null
+++ b/Documentation/devicetree/bindings/reset/zte,zx2967-reset.txt
@@ -0,0 +1,20 @@
1ZTE zx2967 SoCs Reset Controller
2=======================================
3
4Please also refer to reset.txt in this directory for common reset
5controller binding usage.
6
7Required properties:
8- compatible: should be one of the following.
9 * zte,zx296718-reset
10- reg: physical base address of the controller and length of memory mapped
11 region.
12- #reset-cells: must be 1.
13
14example:
15
16 reset: reset-controller@1461060 {
17 compatible = "zte,zx296718-reset";
18 reg = <0x01461060 0x8>;
19 #reset-cells = <1>;
20 };
diff --git a/Documentation/devicetree/bindings/rtc/armada-380-rtc.txt b/Documentation/devicetree/bindings/rtc/armada-380-rtc.txt
index 2eb9d4ee7dc0..c3c9a1226f9a 100644
--- a/Documentation/devicetree/bindings/rtc/armada-380-rtc.txt
+++ b/Documentation/devicetree/bindings/rtc/armada-380-rtc.txt
@@ -1,9 +1,11 @@
1* Real Time Clock of the Armada 38x SoCs 1* Real Time Clock of the Armada 38x/7K/8K SoCs
2 2
3RTC controller for the Armada 38x SoCs 3RTC controller for the Armada 38x, 7K and 8K SoCs
4 4
5Required properties: 5Required properties:
6- compatible : Should be "marvell,armada-380-rtc" 6- compatible : Should be one of the following:
7 "marvell,armada-380-rtc" for Armada 38x SoC
8 "marvell,armada-8k-rtc" for Aramda 7K/8K SoCs
7- reg: a list of base address and size pairs, one for each entry in 9- reg: a list of base address and size pairs, one for each entry in
8 reg-names 10 reg-names
9- reg names: should contain: 11- reg names: should contain:
diff --git a/Documentation/devicetree/bindings/rtc/cortina,gemini.txt b/Documentation/devicetree/bindings/rtc/cortina,gemini.txt
new file mode 100644
index 000000000000..4ce4e794ddbb
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/cortina,gemini.txt
@@ -0,0 +1,14 @@
1* Cortina Systems Gemini RTC
2
3Gemini SoC real-time clock.
4
5Required properties:
6- compatible : Should be "cortina,gemini-rtc"
7
8Examples:
9
10rtc@45000000 {
11 compatible = "cortina,gemini-rtc";
12 reg = <0x45000000 0x100>;
13 interrupts = <17 IRQ_TYPE_LEVEL_HIGH>;
14};
diff --git a/Documentation/devicetree/bindings/rtc/imxdi-rtc.txt b/Documentation/devicetree/bindings/rtc/imxdi-rtc.txt
index c9d80d7da141..323cf26374cb 100644
--- a/Documentation/devicetree/bindings/rtc/imxdi-rtc.txt
+++ b/Documentation/devicetree/bindings/rtc/imxdi-rtc.txt
@@ -8,10 +8,13 @@ Required properties:
8 region. 8 region.
9- interrupts: rtc alarm interrupt 9- interrupts: rtc alarm interrupt
10 10
11Optional properties:
12- interrupts: dryice security violation interrupt
13
11Example: 14Example:
12 15
13rtc@80056000 { 16rtc@80056000 {
14 compatible = "fsl,imx53-rtc", "fsl,imx25-rtc"; 17 compatible = "fsl,imx53-rtc", "fsl,imx25-rtc";
15 reg = <0x80056000 2000>; 18 reg = <0x80056000 2000>;
16 interrupts = <29>; 19 interrupts = <29 56>;
17}; 20};
diff --git a/Documentation/devicetree/bindings/rtc/maxim,ds3231.txt b/Documentation/devicetree/bindings/rtc/maxim,ds3231.txt
index 1ad4c1c2b3b3..85be53a42180 100644
--- a/Documentation/devicetree/bindings/rtc/maxim,ds3231.txt
+++ b/Documentation/devicetree/bindings/rtc/maxim,ds3231.txt
@@ -1,7 +1,8 @@
1* Maxim DS3231 Real Time Clock 1* Maxim DS3231 Real Time Clock
2 2
3Required properties: 3Required properties:
4see: Documentation/devicetree/bindings/i2c/trivial-admin-guide/devices.rst 4- compatible: Should contain "maxim,ds3231".
5- reg: I2C address for chip.
5 6
6Optional property: 7Optional property:
7- #clock-cells: Should be 1. 8- #clock-cells: Should be 1.
diff --git a/Documentation/devicetree/bindings/rtc/pcf8563.txt b/Documentation/devicetree/bindings/rtc/pcf8563.txt
index 086c998c5561..36984acbb383 100644
--- a/Documentation/devicetree/bindings/rtc/pcf8563.txt
+++ b/Documentation/devicetree/bindings/rtc/pcf8563.txt
@@ -3,7 +3,8 @@
3Philips PCF8563/Epson RTC8564 Real Time Clock 3Philips PCF8563/Epson RTC8564 Real Time Clock
4 4
5Required properties: 5Required properties:
6see: Documentation/devicetree/bindings/i2c/trivial-admin-guide/devices.rst 6- compatible: Should contain "nxp,pcf8563".
7- reg: I2C address for chip.
7 8
8Optional property: 9Optional property:
9- #clock-cells: Should be 0. 10- #clock-cells: Should be 0.
diff --git a/Documentation/devicetree/bindings/rtc/st,stm32-rtc.txt b/Documentation/devicetree/bindings/rtc/st,stm32-rtc.txt
new file mode 100644
index 000000000000..e2837b951237
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/st,stm32-rtc.txt
@@ -0,0 +1,27 @@
1STM32 Real Time Clock
2
3Required properties:
4- compatible: "st,stm32-rtc".
5- reg: address range of rtc register set.
6- clocks: reference to the clock entry ck_rtc.
7- interrupt-parent: phandle for the interrupt controller.
8- interrupts: rtc alarm interrupt.
9- st,syscfg: phandle for pwrcfg, mandatory to disable/enable backup domain
10 (RTC registers) write protection.
11
12Optional properties (to override default ck_rtc parent clock):
13- assigned-clocks: reference to the ck_rtc clock entry.
14- assigned-clock-parents: phandle of the new parent clock of ck_rtc.
15
16Example:
17
18 rtc: rtc@40002800 {
19 compatible = "st,stm32-rtc";
20 reg = <0x40002800 0x400>;
21 clocks = <&rcc 1 CLK_RTC>;
22 assigned-clocks = <&rcc 1 CLK_RTC>;
23 assigned-clock-parents = <&rcc 1 CLK_LSE>;
24 interrupt-parent = <&exti>;
25 interrupts = <17 1>;
26 st,syscfg = <&pwrcfg>;
27 };
diff --git a/Documentation/devicetree/bindings/rtc/sun6i-rtc.txt b/Documentation/devicetree/bindings/rtc/sun6i-rtc.txt
index f007e428a1ab..945934918b71 100644
--- a/Documentation/devicetree/bindings/rtc/sun6i-rtc.txt
+++ b/Documentation/devicetree/bindings/rtc/sun6i-rtc.txt
@@ -8,10 +8,20 @@ Required properties:
8 memory mapped region. 8 memory mapped region.
9- interrupts : IRQ lines for the RTC alarm 0 and alarm 1, in that order. 9- interrupts : IRQ lines for the RTC alarm 0 and alarm 1, in that order.
10 10
11Required properties for new device trees
12- clocks : phandle to the 32kHz external oscillator
13- clock-output-names : name of the LOSC clock created
14- #clock-cells : must be equals to 1. The RTC provides two clocks: the
15 LOSC and its external output, with index 0 and 1
16 respectively.
17
11Example: 18Example:
12 19
13rtc: rtc@01f00000 { 20rtc: rtc@01f00000 {
14 compatible = "allwinner,sun6i-a31-rtc"; 21 compatible = "allwinner,sun6i-a31-rtc";
15 reg = <0x01f00000 0x54>; 22 reg = <0x01f00000 0x54>;
16 interrupts = <0 40 4>, <0 41 4>; 23 interrupts = <0 40 4>, <0 41 4>;
24 clock-output-names = "osc32k";
25 clocks = <&ext_osc32k>;
26 #clock-cells = <1>;
17}; 27};
diff --git a/Documentation/devicetree/bindings/serial/8250.txt b/Documentation/devicetree/bindings/serial/8250.txt
index f86bb06c39e9..10276a46ecef 100644
--- a/Documentation/devicetree/bindings/serial/8250.txt
+++ b/Documentation/devicetree/bindings/serial/8250.txt
@@ -19,6 +19,7 @@ Required properties:
19 - "altr,16550-FIFO128" 19 - "altr,16550-FIFO128"
20 - "fsl,16550-FIFO64" 20 - "fsl,16550-FIFO64"
21 - "fsl,ns16550" 21 - "fsl,ns16550"
22 - "ti,da830-uart"
22 - "serial" if the port type is unknown. 23 - "serial" if the port type is unknown.
23- reg : offset and length of the register set for the device. 24- reg : offset and length of the register set for the device.
24- interrupts : should contain uart interrupt. 25- interrupts : should contain uart interrupt.
diff --git a/Documentation/devicetree/bindings/serial/fsl-imx-uart.txt b/Documentation/devicetree/bindings/serial/fsl-imx-uart.txt
index 1e82802d8e32..574c3a2c77d5 100644
--- a/Documentation/devicetree/bindings/serial/fsl-imx-uart.txt
+++ b/Documentation/devicetree/bindings/serial/fsl-imx-uart.txt
@@ -6,11 +6,13 @@ Required properties:
6- interrupts : Should contain uart interrupt 6- interrupts : Should contain uart interrupt
7 7
8Optional properties: 8Optional properties:
9- uart-has-rtscts : Indicate the uart has rts and cts
10- fsl,irda-mode : Indicate the uart supports irda mode 9- fsl,irda-mode : Indicate the uart supports irda mode
11- fsl,dte-mode : Indicate the uart works in DTE mode. The uart works 10- fsl,dte-mode : Indicate the uart works in DTE mode. The uart works
12 in DCE mode by default. 11 in DCE mode by default.
13 12
13Please check Documentation/devicetree/bindings/serial/serial.txt
14for the complete list of generic properties.
15
14Note: Each uart controller should have an alias correctly numbered 16Note: Each uart controller should have an alias correctly numbered
15in "aliases" node. 17in "aliases" node.
16 18
diff --git a/Documentation/devicetree/bindings/serial/serial.txt b/Documentation/devicetree/bindings/serial/serial.txt
index fd970f76a7b8..b542a0ecf06e 100644
--- a/Documentation/devicetree/bindings/serial/serial.txt
+++ b/Documentation/devicetree/bindings/serial/serial.txt
@@ -23,7 +23,8 @@ Optional properties:
23 they are available for use (wired and enabled by pinmux configuration). 23 they are available for use (wired and enabled by pinmux configuration).
24 This depends on both the UART hardware and the board wiring. 24 This depends on both the UART hardware and the board wiring.
25 Note that this property is mutually-exclusive with "cts-gpios" and 25 Note that this property is mutually-exclusive with "cts-gpios" and
26 "rts-gpios" above. 26 "rts-gpios" above, unless support is provided to switch between modes
27 dynamically.
27 28
28 29
29Examples: 30Examples:
diff --git a/Documentation/devicetree/bindings/serial/slave-device.txt b/Documentation/devicetree/bindings/serial/slave-device.txt
new file mode 100644
index 000000000000..f66037928f5f
--- /dev/null
+++ b/Documentation/devicetree/bindings/serial/slave-device.txt
@@ -0,0 +1,36 @@
1Serial Slave Device DT binding
2
3This documents the binding structure and common properties for serial
4attached devices. Common examples include Bluetooth, WiFi, NFC and GPS
5devices.
6
7Serial attached devices shall be a child node of the host UART device the
8slave device is attached to. It is expected that the attached device is
9the only child node of the UART device. The slave device node name shall
10reflect the generic type of device for the node.
11
12Required Properties:
13
14- compatible : A string reflecting the vendor and specific device the node
15 represents.
16
17Optional Properties:
18
19- max-speed : The maximum baud rate the device operates at. This should
20 only be present if the maximum is less than the slave device
21 can support. For example, a particular board has some signal
22 quality issue or the host processor can't support higher
23 baud rates.
24
25Example:
26
27serial@1234 {
28 compatible = "ns16550a";
29 interrupts = <1>;
30
31 bluetooth {
32 compatible = "brcm,bcm43341-bt";
33 interrupt-parent = <&gpio>;
34 interrupts = <10>;
35 };
36};
diff --git a/Documentation/devicetree/bindings/soc/fsl/qman-portals.txt b/Documentation/devicetree/bindings/soc/fsl/qman-portals.txt
index 47e46ccbc170..5a34f3ab7bea 100644
--- a/Documentation/devicetree/bindings/soc/fsl/qman-portals.txt
+++ b/Documentation/devicetree/bindings/soc/fsl/qman-portals.txt
@@ -5,7 +5,6 @@ Copyright (C) 2008 - 2014 Freescale Semiconductor Inc.
5CONTENTS 5CONTENTS
6 6
7 - QMan Portal 7 - QMan Portal
8 - QMan Pool Channel
9 - Example 8 - Example
10 9
11QMan Portal Node 10QMan Portal Node
@@ -82,25 +81,6 @@ These subnodes should have the following properties:
82 Definition: The phandle to the particular hardware device that this 81 Definition: The phandle to the particular hardware device that this
83 portal is connected to. 82 portal is connected to.
84 83
85DPAA QMan Pool Channel Nodes
86
87Pool Channels are defined with the following properties.
88
89PROPERTIES
90
91- compatible
92 Usage: Required
93 Value type: <stringlist>
94 Definition: Must include "fsl,qman-pool-channel"
95 May include "fsl,<SoC>-qman-pool-channel"
96
97- fsl,qman-channel-id
98 Usage: Required
99 Value type: <u32>
100 Definition: The hardware index of the channel. This can also be
101 determined by dividing any of the channel's 8 work queue
102 IDs by 8
103
104EXAMPLE 84EXAMPLE
105 85
106The example below shows a (P4080) QMan portals container/bus node with two portals 86The example below shows a (P4080) QMan portals container/bus node with two portals
diff --git a/Documentation/devicetree/bindings/soc/rockchip/grf.txt b/Documentation/devicetree/bindings/soc/rockchip/grf.txt
index 013e71a2cdc7..a0685c209218 100644
--- a/Documentation/devicetree/bindings/soc/rockchip/grf.txt
+++ b/Documentation/devicetree/bindings/soc/rockchip/grf.txt
@@ -5,20 +5,24 @@ is composed of many registers for system control.
5 5
6From RK3368 SoCs, the GRF is divided into two sections, 6From RK3368 SoCs, the GRF is divided into two sections,
7- GRF, used for general non-secure system, 7- GRF, used for general non-secure system,
8- SGRF, used for general secure system,
8- PMUGRF, used for always on system 9- PMUGRF, used for always on system
9 10
10Required Properties: 11Required Properties:
11 12
12- compatible: GRF should be one of the followings 13- compatible: GRF should be one of the following:
14 - "rockchip,rk3036-grf", "syscon": for rk3036
13 - "rockchip,rk3066-grf", "syscon": for rk3066 15 - "rockchip,rk3066-grf", "syscon": for rk3066
14 - "rockchip,rk3188-grf", "syscon": for rk3188 16 - "rockchip,rk3188-grf", "syscon": for rk3188
15 - "rockchip,rk3228-grf", "syscon": for rk3228 17 - "rockchip,rk3228-grf", "syscon": for rk3228
16 - "rockchip,rk3288-grf", "syscon": for rk3288 18 - "rockchip,rk3288-grf", "syscon": for rk3288
17 - "rockchip,rk3368-grf", "syscon": for rk3368 19 - "rockchip,rk3368-grf", "syscon": for rk3368
18 - "rockchip,rk3399-grf", "syscon": for rk3399 20 - "rockchip,rk3399-grf", "syscon": for rk3399
19- compatible: PMUGRF should be one of the followings 21- compatible: PMUGRF should be one of the following:
20 - "rockchip,rk3368-pmugrf", "syscon": for rk3368 22 - "rockchip,rk3368-pmugrf", "syscon": for rk3368
21 - "rockchip,rk3399-pmugrf", "syscon": for rk3399 23 - "rockchip,rk3399-pmugrf", "syscon": for rk3399
24- compatible: SGRF should be one of the following
25 - "rockchip,rk3288-sgrf", "syscon": for rk3288
22- reg: physical base address of the controller and length of memory mapped 26- reg: physical base address of the controller and length of memory mapped
23 region. 27 region.
24 28
diff --git a/Documentation/devicetree/bindings/soc/rockchip/power_domain.txt b/Documentation/devicetree/bindings/soc/rockchip/power_domain.txt
index f909ce06afc4..01bfb6745fbd 100644
--- a/Documentation/devicetree/bindings/soc/rockchip/power_domain.txt
+++ b/Documentation/devicetree/bindings/soc/rockchip/power_domain.txt
@@ -6,6 +6,7 @@ powered up/down by software based on different application scenes to save power.
6Required properties for power domain controller: 6Required properties for power domain controller:
7- compatible: Should be one of the following. 7- compatible: Should be one of the following.
8 "rockchip,rk3288-power-controller" - for RK3288 SoCs. 8 "rockchip,rk3288-power-controller" - for RK3288 SoCs.
9 "rockchip,rk3328-power-controller" - for RK3328 SoCs.
9 "rockchip,rk3368-power-controller" - for RK3368 SoCs. 10 "rockchip,rk3368-power-controller" - for RK3368 SoCs.
10 "rockchip,rk3399-power-controller" - for RK3399 SoCs. 11 "rockchip,rk3399-power-controller" - for RK3399 SoCs.
11- #power-domain-cells: Number of cells in a power-domain specifier. 12- #power-domain-cells: Number of cells in a power-domain specifier.
@@ -16,6 +17,7 @@ Required properties for power domain controller:
16Required properties for power domain sub nodes: 17Required properties for power domain sub nodes:
17- reg: index of the power domain, should use macros in: 18- reg: index of the power domain, should use macros in:
18 "include/dt-bindings/power/rk3288-power.h" - for RK3288 type power domain. 19 "include/dt-bindings/power/rk3288-power.h" - for RK3288 type power domain.
20 "include/dt-bindings/power/rk3328-power.h" - for RK3328 type power domain.
19 "include/dt-bindings/power/rk3368-power.h" - for RK3368 type power domain. 21 "include/dt-bindings/power/rk3368-power.h" - for RK3368 type power domain.
20 "include/dt-bindings/power/rk3399-power.h" - for RK3399 type power domain. 22 "include/dt-bindings/power/rk3399-power.h" - for RK3399 type power domain.
21- clocks (optional): phandles to clocks which need to be enabled while power domain 23- clocks (optional): phandles to clocks which need to be enabled while power domain
@@ -90,6 +92,7 @@ containing a phandle to the power device node and an index specifying which
90power domain to use. 92power domain to use.
91The index should use macros in: 93The index should use macros in:
92 "include/dt-bindings/power/rk3288-power.h" - for rk3288 type power domain. 94 "include/dt-bindings/power/rk3288-power.h" - for rk3288 type power domain.
95 "include/dt-bindings/power/rk3328-power.h" - for rk3328 type power domain.
93 "include/dt-bindings/power/rk3368-power.h" - for rk3368 type power domain. 96 "include/dt-bindings/power/rk3368-power.h" - for rk3368 type power domain.
94 "include/dt-bindings/power/rk3399-power.h" - for rk3399 type power domain. 97 "include/dt-bindings/power/rk3399-power.h" - for rk3399 type power domain.
95 98
diff --git a/Documentation/devicetree/bindings/soc/zte/pd-2967xx.txt b/Documentation/devicetree/bindings/soc/zte/pd-2967xx.txt
new file mode 100644
index 000000000000..7629de1c2c72
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/zte/pd-2967xx.txt
@@ -0,0 +1,19 @@
1* ZTE zx2967 family Power Domains
2
3zx2967 family includes support for multiple power domains which are used
4to gate power to one or more peripherals on the processor.
5
6Required Properties:
7 - compatible: should be one of the following.
8 * zte,zx296718-pcu - for zx296718 power domain.
9 - reg: physical base address of the controller and length of memory mapped
10 region.
11 - #power-domain-cells: Must be 1.
12
13Example:
14
15 pcu_domain: pcu@117000 {
16 compatible = "zte,zx296718-pcu";
17 reg = <0x00117000 0x1000>;
18 #power-domain-cells = <1>;
19 };
diff --git a/Documentation/devicetree/bindings/sound/axentia,tse850-pcm5142.txt b/Documentation/devicetree/bindings/sound/axentia,tse850-pcm5142.txt
index 5b9b38f578bb..fdb25b492514 100644
--- a/Documentation/devicetree/bindings/sound/axentia,tse850-pcm5142.txt
+++ b/Documentation/devicetree/bindings/sound/axentia,tse850-pcm5142.txt
@@ -2,8 +2,7 @@ Devicetree bindings for the Axentia TSE-850 audio complex
2 2
3Required properties: 3Required properties:
4 - compatible: "axentia,tse850-pcm5142" 4 - compatible: "axentia,tse850-pcm5142"
5 - axentia,ssc-controller: The phandle of the atmel SSC controller used as 5 - axentia,cpu-dai: The phandle of the cpu dai.
6 cpu dai.
7 - axentia,audio-codec: The phandle of the PCM5142 codec. 6 - axentia,audio-codec: The phandle of the PCM5142 codec.
8 - axentia,add-gpios: gpio specifier that controls the mixer. 7 - axentia,add-gpios: gpio specifier that controls the mixer.
9 - axentia,loop1-gpios: gpio specifier that controls loop relays on channel 1. 8 - axentia,loop1-gpios: gpio specifier that controls loop relays on channel 1.
@@ -43,6 +42,12 @@ the PCM5142 codec.
43 42
44Example: 43Example:
45 44
45 &ssc0 {
46 #sound-dai-cells = <0>;
47
48 status = "okay";
49 };
50
46 &i2c { 51 &i2c {
47 codec: pcm5142@4c { 52 codec: pcm5142@4c {
48 compatible = "ti,pcm5142"; 53 compatible = "ti,pcm5142";
@@ -77,7 +82,7 @@ Example:
77 sound { 82 sound {
78 compatible = "axentia,tse850-pcm5142"; 83 compatible = "axentia,tse850-pcm5142";
79 84
80 axentia,ssc-controller = <&ssc0>; 85 axentia,cpu-dai = <&ssc0>;
81 axentia,audio-codec = <&codec>; 86 axentia,audio-codec = <&codec>;
82 87
83 axentia,add-gpios = <&pioA 8 GPIO_ACTIVE_LOW>; 88 axentia,add-gpios = <&pioA 8 GPIO_ACTIVE_LOW>;
diff --git a/Documentation/devicetree/bindings/sound/es8328.txt b/Documentation/devicetree/bindings/sound/es8328.txt
index 30ea8a318ae9..33fbf058c997 100644
--- a/Documentation/devicetree/bindings/sound/es8328.txt
+++ b/Documentation/devicetree/bindings/sound/es8328.txt
@@ -4,7 +4,7 @@ This device supports both I2C and SPI.
4 4
5Required properties: 5Required properties:
6 6
7 - compatible : "everest,es8328" 7 - compatible : Should be "everest,es8328" or "everest,es8388"
8 - DVDD-supply : Regulator providing digital core supply voltage 1.8 - 3.6V 8 - DVDD-supply : Regulator providing digital core supply voltage 1.8 - 3.6V
9 - AVDD-supply : Regulator providing analog supply voltage 3.3V 9 - AVDD-supply : Regulator providing analog supply voltage 3.3V
10 - PVDD-supply : Regulator providing digital IO supply voltage 1.8 - 3.6V 10 - PVDD-supply : Regulator providing digital IO supply voltage 1.8 - 3.6V
diff --git a/Documentation/devicetree/bindings/sound/mt2701-afe-pcm.txt b/Documentation/devicetree/bindings/sound/mt2701-afe-pcm.txt
index 3e623a724e55..9800a560e0c2 100644
--- a/Documentation/devicetree/bindings/sound/mt2701-afe-pcm.txt
+++ b/Documentation/devicetree/bindings/sound/mt2701-afe-pcm.txt
@@ -4,6 +4,7 @@ Required properties:
4- compatible = "mediatek,mt2701-audio"; 4- compatible = "mediatek,mt2701-audio";
5- reg: register location and size 5- reg: register location and size
6- interrupts: Should contain AFE interrupt 6- interrupts: Should contain AFE interrupt
7- power-domains: should define the power domain
7- clock-names: should have these clock names: 8- clock-names: should have these clock names:
8 "infra_sys_audio_clk", 9 "infra_sys_audio_clk",
9 "top_audio_mux1_sel", 10 "top_audio_mux1_sel",
@@ -58,6 +59,7 @@ Example:
58 <0 0x112A0000 0 0x20000>; 59 <0 0x112A0000 0 0x20000>;
59 interrupts = <GIC_SPI 104 IRQ_TYPE_LEVEL_LOW>, 60 interrupts = <GIC_SPI 104 IRQ_TYPE_LEVEL_LOW>,
60 <GIC_SPI 132 IRQ_TYPE_LEVEL_LOW>; 61 <GIC_SPI 132 IRQ_TYPE_LEVEL_LOW>;
62 power-domains = <&scpsys MT2701_POWER_DOMAIN_IFR_MSC>;
61 clocks = <&infracfg CLK_INFRA_AUDIO>, 63 clocks = <&infracfg CLK_INFRA_AUDIO>,
62 <&topckgen CLK_TOP_AUD_MUX1_SEL>, 64 <&topckgen CLK_TOP_AUD_MUX1_SEL>,
63 <&topckgen CLK_TOP_AUD_MUX2_SEL>, 65 <&topckgen CLK_TOP_AUD_MUX2_SEL>,
diff --git a/Documentation/devicetree/bindings/sound/nau8540.txt b/Documentation/devicetree/bindings/sound/nau8540.txt
new file mode 100644
index 000000000000..307a76528320
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/nau8540.txt
@@ -0,0 +1,16 @@
1NAU85L40 audio CODEC
2
3This device supports I2C only.
4
5Required properties:
6
7 - compatible : "nuvoton,nau8540"
8
9 - reg : the I2C address of the device.
10
11Example:
12
13codec: nau8540@1c {
14 compatible = "nuvoton,nau8540";
15 reg = <0x1c>;
16};
diff --git a/Documentation/devicetree/bindings/sound/rockchip,rk3288-hdmi-analog.txt b/Documentation/devicetree/bindings/sound/rockchip,rk3288-hdmi-analog.txt
new file mode 100644
index 000000000000..2539e1d68107
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/rockchip,rk3288-hdmi-analog.txt
@@ -0,0 +1,36 @@
1ROCKCHIP RK3288 with HDMI and analog audio
2
3Required properties:
4- compatible: "rockchip,rk3288-hdmi-analog"
5- rockchip,model: The user-visible name of this sound complex
6- rockchip,i2s-controller: The phandle of the Rockchip I2S controller that's
7 connected to the CODEC
8- rockchip,audio-codec: The phandle of the analog audio codec.
9- rockchip,routing: A list of the connections between audio components.
10 Each entry is a pair of strings, the first being the
11 connection's sink, the second being the connection's
12 source. For this driver the first string should always be
13 "Analog".
14
15Optionnal properties:
16- rockchip,hp-en-gpios = The phandle of the GPIO that power up/down the
17 headphone (when the analog output is an headphone).
18- rockchip,hp-det-gpios = The phandle of the GPIO that detects the headphone
19 (when the analog output is an headphone).
20- pinctrl-names, pinctrl-0: Please refer to pinctrl-bindings.txt
21
22Example:
23
24sound {
25 compatible = "rockchip,rockchip-audio-es8388";
26 rockchip,model = "Analog audio output";
27 rockchip,i2s-controller = <&i2s>;
28 rockchip,audio-codec = <&es8388>;
29 rockchip,routing = "Analog", "LOUT2",
30 "Analog", "ROUT2";
31 rockchip,hp-en-gpios = <&gpio8 0 GPIO_ACTIVE_HIGH>;
32 rockchip,hp-det-gpios = <&gpio7 7 GPIO_ACTIVE_HIGH>;
33 pinctrl-names = "default";
34 pinctrl-0 = <&headphone>;
35};
36
diff --git a/Documentation/devicetree/bindings/sound/rockchip-i2s.txt b/Documentation/devicetree/bindings/sound/rockchip-i2s.txt
index 4ea29aa9af59..a6600f6dea64 100644
--- a/Documentation/devicetree/bindings/sound/rockchip-i2s.txt
+++ b/Documentation/devicetree/bindings/sound/rockchip-i2s.txt
@@ -5,7 +5,7 @@ audio data transfer between devices in the system.
5 5
6Required properties: 6Required properties:
7 7
8- compatible: should be one of the followings 8- compatible: should be one of the following:
9 - "rockchip,rk3066-i2s": for rk3066 9 - "rockchip,rk3066-i2s": for rk3066
10 - "rockchip,rk3188-i2s", "rockchip,rk3066-i2s": for rk3188 10 - "rockchip,rk3188-i2s", "rockchip,rk3066-i2s": for rk3188
11 - "rockchip,rk3288-i2s", "rockchip,rk3066-i2s": for rk3288 11 - "rockchip,rk3288-i2s", "rockchip,rk3066-i2s": for rk3288
@@ -17,7 +17,7 @@ Required properties:
17 Documentation/devicetree/bindings/dma/dma.txt 17 Documentation/devicetree/bindings/dma/dma.txt
18- dma-names: should include "tx" and "rx". 18- dma-names: should include "tx" and "rx".
19- clocks: a list of phandle + clock-specifer pairs, one for each entry in clock-names. 19- clocks: a list of phandle + clock-specifer pairs, one for each entry in clock-names.
20- clock-names: should contain followings: 20- clock-names: should contain the following:
21 - "i2s_hclk": clock for I2S BUS 21 - "i2s_hclk": clock for I2S BUS
22 - "i2s_clk" : clock for I2S controller 22 - "i2s_clk" : clock for I2S controller
23- rockchip,playback-channels: max playback channels, if not set, 8 channels default. 23- rockchip,playback-channels: max playback channels, if not set, 8 channels default.
diff --git a/Documentation/devicetree/bindings/sound/rt5665.txt b/Documentation/devicetree/bindings/sound/rt5665.txt
index 419c89219681..419c89219681 100755..100644
--- a/Documentation/devicetree/bindings/sound/rt5665.txt
+++ b/Documentation/devicetree/bindings/sound/rt5665.txt
diff --git a/Documentation/devicetree/bindings/sound/sun4i-codec.txt b/Documentation/devicetree/bindings/sound/sun4i-codec.txt
index 3033bd8aab0f..3863531d1e6d 100644
--- a/Documentation/devicetree/bindings/sound/sun4i-codec.txt
+++ b/Documentation/devicetree/bindings/sound/sun4i-codec.txt
@@ -14,7 +14,7 @@ Required properties:
14- dma-names: should include "tx" and "rx". 14- dma-names: should include "tx" and "rx".
15- clocks: a list of phandle + clock-specifer pairs, one for each entry 15- clocks: a list of phandle + clock-specifer pairs, one for each entry
16 in clock-names. 16 in clock-names.
17- clock-names: should contain followings: 17- clock-names: should contain the following:
18 - "apb": the parent APB clock for this controller 18 - "apb": the parent APB clock for this controller
19 - "codec": the parent module clock 19 - "codec": the parent module clock
20 20
diff --git a/Documentation/devicetree/bindings/sound/sun4i-i2s.txt b/Documentation/devicetree/bindings/sound/sun4i-i2s.txt
index 7b526ec64991..ee21da865771 100644
--- a/Documentation/devicetree/bindings/sound/sun4i-i2s.txt
+++ b/Documentation/devicetree/bindings/sound/sun4i-i2s.txt
@@ -5,8 +5,9 @@ audio data transfer between devices in the system.
5 5
6Required properties: 6Required properties:
7 7
8- compatible: should be one of the followings 8- compatible: should be one of the following:
9 - "allwinner,sun4i-a10-i2s" 9 - "allwinner,sun4i-a10-i2s"
10 - "allwinner,sun6i-a31-i2s"
10- reg: physical base address of the controller and length of memory mapped 11- reg: physical base address of the controller and length of memory mapped
11 region. 12 region.
12- interrupts: should contain the I2S interrupt. 13- interrupts: should contain the I2S interrupt.
@@ -14,11 +15,15 @@ Required properties:
14 Documentation/devicetree/bindings/dma/dma.txt 15 Documentation/devicetree/bindings/dma/dma.txt
15- dma-names: should include "tx" and "rx". 16- dma-names: should include "tx" and "rx".
16- clocks: a list of phandle + clock-specifer pairs, one for each entry in clock-names. 17- clocks: a list of phandle + clock-specifer pairs, one for each entry in clock-names.
17- clock-names: should contain followings: 18- clock-names: should contain the following:
18 - "apb" : clock for the I2S bus interface 19 - "apb" : clock for the I2S bus interface
19 - "mod" : module clock for the I2S controller 20 - "mod" : module clock for the I2S controller
20- #sound-dai-cells : Must be equal to 0 21- #sound-dai-cells : Must be equal to 0
21 22
23Required properties for the following compatibles:
24 - "allwinner,sun6i-a31-i2s"
25- resets: phandle to the reset line for this codec
26
22Example: 27Example:
23 28
24i2s0: i2s@01c22400 { 29i2s0: i2s@01c22400 {
diff --git a/Documentation/devicetree/bindings/sound/sun8i-a33-codec.txt b/Documentation/devicetree/bindings/sound/sun8i-a33-codec.txt
new file mode 100644
index 000000000000..399b1b4bae22
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/sun8i-a33-codec.txt
@@ -0,0 +1,63 @@
1Allwinner SUN8I audio codec
2------------------------------------
3
4On Sun8i-A33 SoCs, the audio is separated in different parts:
5 - A DAI driver. It uses the "sun4i-i2s" driver which is
6 documented here:
7 Documentation/devicetree/bindings/sound/sun4i-i2s.txt
8 - An analog part of the codec which is handled as PRCM registers.
9 See Documentation/devicetree/bindings/sound/sun8i-codec-analog.txt
10 - An digital part of the codec which is documented in this current
11 binding documentation.
12 - And finally, an audio card which links all the above components.
13 The simple-audio card will be used.
14 See Documentation/devicetree/bindings/sound/simple-card.txt
15
16This bindings documentation exposes Sun8i codec (digital part).
17
18Required properties:
19- compatible: must be "allwinner,sun8i-a33-codec"
20- reg: must contain the registers location and length
21- interrupts: must contain the codec interrupt
22- clocks: a list of phandle + clock-specifer pairs, one for each entry
23 in clock-names.
24- clock-names: should contain followings:
25 - "bus": the parent APB clock for this controller
26 - "mod": the parent module clock
27
28Here is an example to add a sound card and the codec binding on sun8i SoCs that
29are similar to A33 using simple-card:
30
31 sound {
32 compatible = "simple-audio-card";
33 simple-audio-card,name = "sun8i-a33-audio";
34 simple-audio-card,format = "i2s";
35 simple-audio-card,frame-master = <&link_codec>;
36 simple-audio-card,bitclock-master = <&link_codec>;
37 simple-audio-card,mclk-fs = <512>;
38 simple-audio-card,aux-devs = <&codec_analog>;
39 simple-audio-card,routing =
40 "Left DAC", "Digital Left DAC",
41 "Right DAC", "Digital Right DAC";
42
43 simple-audio-card,cpu {
44 sound-dai = <&dai>;
45 };
46
47 link_codec: simple-audio-card,codec {
48 sound-dai = <&codec>;
49 };
50
51 soc@01c00000 {
52 [...]
53
54 audio-codec@1c22e00 {
55 #sound-dai-cells = <0>;
56 compatible = "allwinner,sun8i-a33-codec";
57 reg = <0x01c22e00 0x400>;
58 interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>;
59 clocks = <&ccu CLK_BUS_CODEC>, <&ccu CLK_AC_DIG>;
60 clock-names = "bus", "mod";
61 };
62 };
63
diff --git a/Documentation/devicetree/bindings/sound/sunxi,sun4i-spdif.txt b/Documentation/devicetree/bindings/sound/sunxi,sun4i-spdif.txt
index 0230c4d20506..fe0a65e6d629 100644
--- a/Documentation/devicetree/bindings/sound/sunxi,sun4i-spdif.txt
+++ b/Documentation/devicetree/bindings/sound/sunxi,sun4i-spdif.txt
@@ -10,6 +10,7 @@ Required properties:
10 - compatible : should be one of the following: 10 - compatible : should be one of the following:
11 - "allwinner,sun4i-a10-spdif": for the Allwinner A10 SoC 11 - "allwinner,sun4i-a10-spdif": for the Allwinner A10 SoC
12 - "allwinner,sun6i-a31-spdif": for the Allwinner A31 SoC 12 - "allwinner,sun6i-a31-spdif": for the Allwinner A31 SoC
13 - "allwinner,sun8i-h3-spdif": for the Allwinner H3 SoC
13 14
14 - reg : Offset and length of the register set for the device. 15 - reg : Offset and length of the register set for the device.
15 16
diff --git a/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt b/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt
index 7e5aa6f6b5a1..292ad5083704 100644
--- a/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt
+++ b/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt
@@ -1,10 +1,12 @@
1ZTE ZX296702 I2S controller 1ZTE ZX296702 I2S controller
2 2
3Required properties: 3Required properties:
4 - compatible : Must be "zte,zx296702-i2s" 4 - compatible : Must be one of:
5 "zte,zx296718-i2s", "zte,zx296702-i2s"
6 "zte,zx296702-i2s"
5 - reg : Must contain I2S core's registers location and length 7 - reg : Must contain I2S core's registers location and length
6 - clocks : Pairs of phandle and specifier referencing the controller's clocks. 8 - clocks : Pairs of phandle and specifier referencing the controller's clocks.
7 - clock-names: "tx" for the clock to the I2S interface. 9 - clock-names: "wclk" for the wclk, "pclk" for the pclk to the I2S interface.
8 - dmas: Pairs of phandle and specifier for the DMA channel that is used by 10 - dmas: Pairs of phandle and specifier for the DMA channel that is used by
9 the core. The core expects two dma channels for transmit. 11 the core. The core expects two dma channels for transmit.
10 - dma-names : Must be "tx" and "rx" 12 - dma-names : Must be "tx" and "rx"
@@ -16,12 +18,12 @@ please check:
16 * dma/dma.txt 18 * dma/dma.txt
17 19
18Example: 20Example:
19 i2s0: i2s0@0b005000 { 21 i2s0: i2s@b005000 {
20 #sound-dai-cells = <0>; 22 #sound-dai-cells = <0>;
21 compatible = "zte,zx296702-i2s"; 23 compatible = "zte,zx296718-i2s", "zte,zx296702-i2s";
22 reg = <0x0b005000 0x1000>; 24 reg = <0x0b005000 0x1000>;
23 clocks = <&lsp0clk ZX296702_I2S0_DIV>; 25 clocks = <&audiocrm AUDIO_I2S0_WCLK>, <&audiocrm AUDIO_I2S0_PCLK>;
24 clock-names = "tx"; 26 clock-names = "wclk", "pclk";
25 interrupts = <GIC_SPI 22 IRQ_TYPE_LEVEL_HIGH>; 27 interrupts = <GIC_SPI 22 IRQ_TYPE_LEVEL_HIGH>;
26 dmas = <&dma 5>, <&dma 6>; 28 dmas = <&dma 5>, <&dma 6>;
27 dma-names = "tx", "rx"; 29 dma-names = "tx", "rx";
diff --git a/Documentation/devicetree/bindings/sram/sram.txt b/Documentation/devicetree/bindings/sram/sram.txt
index 068c2c03c38f..267da4410aef 100644
--- a/Documentation/devicetree/bindings/sram/sram.txt
+++ b/Documentation/devicetree/bindings/sram/sram.txt
@@ -42,6 +42,12 @@ Optional properties in the area nodes:
42 and in use by another device or devices 42 and in use by another device or devices
43- export : indicates that the reserved SRAM area may be accessed outside 43- export : indicates that the reserved SRAM area may be accessed outside
44 of the kernel, e.g. by bootloader or userspace 44 of the kernel, e.g. by bootloader or userspace
45- protect-exec : Same as 'pool' above but with the additional
46 constraint that code wil be run from the region and
47 that the memory is maintained as read-only, executable
48 during code execution. NOTE: This region must be page
49 aligned on start and end in order to properly allow
50 manipulation of the page attributes.
45- label : the name for the reserved partition, if omitted, the label 51- label : the name for the reserved partition, if omitted, the label
46 is taken from the node name excluding the unit address. 52 is taken from the node name excluding the unit address.
47 53
diff --git a/Documentation/devicetree/bindings/thermal/qoriq-thermal.txt b/Documentation/devicetree/bindings/thermal/qoriq-thermal.txt
index 66223d561972..20ca4ef9d776 100644
--- a/Documentation/devicetree/bindings/thermal/qoriq-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/qoriq-thermal.txt
@@ -17,6 +17,12 @@ Required properties:
17 calibration data, as specified by the SoC reference manual. 17 calibration data, as specified by the SoC reference manual.
18 The first cell of each pair is the value to be written to TTCFGR, 18 The first cell of each pair is the value to be written to TTCFGR,
19 and the second is the value to be written to TSCFGR. 19 and the second is the value to be written to TSCFGR.
20- #thermal-sensor-cells : Must be 1. The sensor specifier is the monitoring
21 site ID, and represents the "n" in TRITSRn and TRATSRn.
22
23Optional property:
24- little-endian : If present, the TMU registers are little endian. If absent,
25 the default is big endian.
20 26
21Example: 27Example:
22 28
@@ -60,4 +66,5 @@ tmu@f0000 {
60 66
61 0x00030000 0x00000012 67 0x00030000 0x00000012
62 0x00030001 0x0000001d>; 68 0x00030001 0x0000001d>;
69 #thermal-sensor-cells = <1>;
63}; 70};
diff --git a/Documentation/devicetree/bindings/thermal/rcar-gen3-thermal.txt b/Documentation/devicetree/bindings/thermal/rcar-gen3-thermal.txt
new file mode 100644
index 000000000000..07a9713ae6a7
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/rcar-gen3-thermal.txt
@@ -0,0 +1,56 @@
1* DT bindings for Renesas R-Car Gen3 Thermal Sensor driver
2
3On R-Car Gen3 SoCs, the thermal sensor controllers (TSC) control the thermal
4sensors (THS) which are the analog circuits for measuring temperature (Tj)
5inside the LSI.
6
7Required properties:
8- compatible : "renesas,<soctype>-thermal",
9 Examples with soctypes are:
10 - "renesas,r8a7795-thermal" (R-Car H3)
11 - "renesas,r8a7796-thermal" (R-Car M3-W)
12- reg : Address ranges of the thermal registers. Each sensor
13 needs one address range. Sorting must be done in
14 increasing order according to datasheet, i.e.
15 TSC1, TSC2, ...
16- clocks : Must contain a reference to the functional clock.
17- #thermal-sensor-cells : must be <1>.
18
19Optional properties:
20
21- interrupts : interrupts routed to the TSC (3 for H3 and M3-W)
22- power-domain : Must contain a reference to the power domain. This
23 property is mandatory if the thermal sensor instance
24 is part of a controllable power domain.
25
26Example:
27
28 tsc: thermal@e6198000 {
29 compatible = "renesas,r8a7795-thermal";
30 reg = <0 0xe6198000 0 0x68>,
31 <0 0xe61a0000 0 0x5c>,
32 <0 0xe61a8000 0 0x5c>;
33 interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>,
34 <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>,
35 <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>;
36 clocks = <&cpg CPG_MOD 522>;
37 power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
38 #thermal-sensor-cells = <1>;
39 status = "okay";
40 };
41
42 thermal-zones {
43 sensor_thermal1: sensor-thermal1 {
44 polling-delay-passive = <250>;
45 polling-delay = <1000>;
46 thermal-sensors = <&tsc 0>;
47
48 trips {
49 sensor1_crit: sensor1-crit {
50 temperature = <90000>;
51 hysteresis = <2000>;
52 type = "critical";
53 };
54 };
55 };
56 };
diff --git a/Documentation/devicetree/bindings/thermal/zx2967-thermal.txt b/Documentation/devicetree/bindings/thermal/zx2967-thermal.txt
new file mode 100644
index 000000000000..3dc1c6bf0478
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/zx2967-thermal.txt
@@ -0,0 +1,116 @@
1* ZTE zx2967 family Thermal
2
3Required Properties:
4- compatible: should be one of the following.
5 * zte,zx296718-thermal
6- reg: physical base address of the controller and length of memory mapped
7 region.
8- clocks : Pairs of phandle and specifier referencing the controller's clocks.
9- clock-names: "topcrm" for the topcrm clock.
10 "apb" for the apb clock.
11- #thermal-sensor-cells: must be 0.
12
13Please note: slope coefficient defined in thermal-zones section need to be
14multiplied by 1000.
15
16Example for tempsensor:
17
18 tempsensor: tempsensor@148a000 {
19 compatible = "zte,zx296718-thermal";
20 reg = <0x0148a000 0x20>;
21 clocks = <&topcrm TEMPSENSOR_GATE>, <&audiocrm AUDIO_TS_PCLK>;
22 clock-names = "topcrm", "apb";
23 #thermal-sensor-cells = <0>;
24 };
25
26Example for cooling device:
27
28 cooling_dev: cooling_dev {
29 cluster0_cooling_dev: cluster0-cooling-dev {
30 #cooling-cells = <2>;
31 cpumask = <0xf>;
32 capacitance = <1500>;
33 };
34
35 cluster1_cooling_dev: cluster1-cooling-dev {
36 #cooling-cells = <2>;
37 cpumask = <0x30>;
38 capacitance = <2000>;
39 };
40 };
41
42Example for thermal zones:
43
44 thermal-zones {
45 zx296718_thermal: zx296718_thermal {
46 polling-delay-passive = <500>;
47 polling-delay = <1000>;
48 sustainable-power = <6500>;
49
50 thermal-sensors = <&tempsensor 0>;
51 /*
52 * slope need to be multiplied by 1000.
53 */
54 coefficients = <1951 (-922)>;
55
56 trips {
57 trip0: switch_on_temperature {
58 temperature = <90000>;
59 hysteresis = <2000>;
60 type = "passive";
61 };
62
63 trip1: desired_temperature {
64 temperature = <100000>;
65 hysteresis = <2000>;
66 type = "passive";
67 };
68
69 crit: critical_temperature {
70 temperature = <110000>;
71 hysteresis = <2000>;
72 type = "critical";
73 };
74 };
75
76 cooling-maps {
77 map0 {
78 trip = <&trip0>;
79 cooling-device = <&gpu 2 5>;
80 };
81
82 map1 {
83 trip = <&trip0>;
84 cooling-device = <&cluster0_cooling_dev 1 2>;
85 };
86
87 map2 {
88 trip = <&trip1>;
89 cooling-device = <&cluster0_cooling_dev 1 2>;
90 };
91
92 map3 {
93 trip = <&crit>;
94 cooling-device = <&cluster0_cooling_dev 1 2>;
95 };
96
97 map4 {
98 trip = <&trip0>;
99 cooling-device = <&cluster1_cooling_dev 1 2>;
100 contribution = <9000>;
101 };
102
103 map5 {
104 trip = <&trip1>;
105 cooling-device = <&cluster1_cooling_dev 1 2>;
106 contribution = <4096>;
107 };
108
109 map6 {
110 trip = <&crit>;
111 cooling-device = <&cluster1_cooling_dev 1 2>;
112 contribution = <4096>;
113 };
114 };
115 };
116 };
diff --git a/Documentation/devicetree/bindings/ufs/ufs-qcom.txt b/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
index b6b5130e5f65..1f69ee1a61ea 100644
--- a/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
+++ b/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
@@ -29,7 +29,6 @@ Optional properties:
29- vdda-pll-max-microamp : specifies max. load that can be drawn from pll supply 29- vdda-pll-max-microamp : specifies max. load that can be drawn from pll supply
30- vddp-ref-clk-supply : phandle to UFS device ref_clk pad power supply 30- vddp-ref-clk-supply : phandle to UFS device ref_clk pad power supply
31- vddp-ref-clk-max-microamp : specifies max. load that can be drawn from this supply 31- vddp-ref-clk-max-microamp : specifies max. load that can be drawn from this supply
32- vddp-ref-clk-always-on : specifies if this supply needs to be kept always on
33 32
34Example: 33Example:
35 34
diff --git a/Documentation/devicetree/bindings/usb/allwinner,sun4i-a10-musb.txt b/Documentation/devicetree/bindings/usb/allwinner,sun4i-a10-musb.txt
index 862cd7c79805..d9b42da016f3 100644
--- a/Documentation/devicetree/bindings/usb/allwinner,sun4i-a10-musb.txt
+++ b/Documentation/devicetree/bindings/usb/allwinner,sun4i-a10-musb.txt
@@ -2,8 +2,8 @@ Allwinner sun4i A10 musb DRC/OTG controller
2------------------------------------------- 2-------------------------------------------
3 3
4Required properties: 4Required properties:
5 - compatible : "allwinner,sun4i-a10-musb", "allwinner,sun6i-a31-musb" 5 - compatible : "allwinner,sun4i-a10-musb", "allwinner,sun6i-a31-musb",
6 or "allwinner,sun8i-a33-musb" 6 "allwinner,sun8i-a33-musb" or "allwinner,sun8i-h3-musb"
7 - reg : mmio address range of the musb controller 7 - reg : mmio address range of the musb controller
8 - clocks : clock specifier for the musb controller ahb gate clock 8 - clocks : clock specifier for the musb controller ahb gate clock
9 - reset : reset specifier for the ahb reset (A31 and newer only) 9 - reset : reset specifier for the ahb reset (A31 and newer only)
diff --git a/Documentation/devicetree/bindings/usb/dwc3-st.txt b/Documentation/devicetree/bindings/usb/dwc3-st.txt
index 01c71b1258f4..50dee3b44665 100644
--- a/Documentation/devicetree/bindings/usb/dwc3-st.txt
+++ b/Documentation/devicetree/bindings/usb/dwc3-st.txt
@@ -20,10 +20,10 @@ See: Documentation/devicetree/bindings/reset/reset.txt
20 with 'reg' property 20 with 'reg' property
21 21
22 - pinctl-names : A pinctrl state named "default" must be defined 22 - pinctl-names : A pinctrl state named "default" must be defined
23See: Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt 23See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
24 24
25 - pinctrl-0 : Pin control group 25 - pinctrl-0 : Pin control group
26See: Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt 26See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
27 27
28 - ranges : allows valid 1:1 translation between child's address space and 28 - ranges : allows valid 1:1 translation between child's address space and
29 parent's address space 29 parent's address space
diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt
index e3e6983288e3..f658f394c2d3 100644
--- a/Documentation/devicetree/bindings/usb/dwc3.txt
+++ b/Documentation/devicetree/bindings/usb/dwc3.txt
@@ -56,6 +56,10 @@ Optional properties:
56 56
57 - <DEPRECATED> tx-fifo-resize: determines if the FIFO *has* to be reallocated. 57 - <DEPRECATED> tx-fifo-resize: determines if the FIFO *has* to be reallocated.
58 58
59 - in addition all properties from usb-xhci.txt from the current directory are
60 supported as well
61
62
59This is usually a subnode to DWC3 glue to which it is connected. 63This is usually a subnode to DWC3 glue to which it is connected.
60 64
61dwc3@4a030000 { 65dwc3@4a030000 {
diff --git a/Documentation/devicetree/bindings/usb/ehci-omap.txt b/Documentation/devicetree/bindings/usb/ehci-omap.txt
index 3dc231c832b0..d77e11a975a2 100644
--- a/Documentation/devicetree/bindings/usb/ehci-omap.txt
+++ b/Documentation/devicetree/bindings/usb/ehci-omap.txt
@@ -29,4 +29,3 @@ usbhsehci: ehci@4a064c00 {
29&usbhsehci { 29&usbhsehci {
30 phys = <&hsusb1_phy 0 &hsusb3_phy>; 30 phys = <&hsusb1_phy 0 &hsusb3_phy>;
31}; 31};
32
diff --git a/Documentation/devicetree/bindings/usb/ehci-st.txt b/Documentation/devicetree/bindings/usb/ehci-st.txt
index fb45fa5770bb..410d922cfdd7 100644
--- a/Documentation/devicetree/bindings/usb/ehci-st.txt
+++ b/Documentation/devicetree/bindings/usb/ehci-st.txt
@@ -7,7 +7,7 @@ Required properties:
7 - interrupts : one EHCI interrupt should be described here 7 - interrupts : one EHCI interrupt should be described here
8 - pinctrl-names : a pinctrl state named "default" must be defined 8 - pinctrl-names : a pinctrl state named "default" must be defined
9 - pinctrl-0 : phandle referencing pin configuration of the USB controller 9 - pinctrl-0 : phandle referencing pin configuration of the USB controller
10See: Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt 10See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
11 - clocks : phandle list of usb clocks 11 - clocks : phandle list of usb clocks
12 - clock-names : should be "ic" for interconnect clock and "clk48" 12 - clock-names : should be "ic" for interconnect clock and "clk48"
13See: Documentation/devicetree/bindings/clock/clock-bindings.txt 13See: Documentation/devicetree/bindings/clock/clock-bindings.txt
diff --git a/Documentation/devicetree/bindings/usb/mt8173-mtu3.txt b/Documentation/devicetree/bindings/usb/mt8173-mtu3.txt
index e049d199bf0d..1d7c3bc677f7 100644
--- a/Documentation/devicetree/bindings/usb/mt8173-mtu3.txt
+++ b/Documentation/devicetree/bindings/usb/mt8173-mtu3.txt
@@ -10,7 +10,7 @@ Required properties:
10 - vusb33-supply : regulator of USB avdd3.3v 10 - vusb33-supply : regulator of USB avdd3.3v
11 - clocks : a list of phandle + clock-specifier pairs, one for each 11 - clocks : a list of phandle + clock-specifier pairs, one for each
12 entry in clock-names 12 entry in clock-names
13 - clock-names : must contain "sys_ck" for clock of controller; 13 - clock-names : must contain "sys_ck" and "ref_ck" for clock of controller;
14 "wakeup_deb_p0" and "wakeup_deb_p1" are optional, they are 14 "wakeup_deb_p0" and "wakeup_deb_p1" are optional, they are
15 depends on "mediatek,enable-wakeup" 15 depends on "mediatek,enable-wakeup"
16 - phys : a list of phandle + phy specifier pairs 16 - phys : a list of phandle + phy specifier pairs
@@ -30,7 +30,7 @@ Optional properties:
30 "id_float" and "id_ground" are optinal which depends on 30 "id_float" and "id_ground" are optinal which depends on
31 "mediatek,enable-manual-drd" 31 "mediatek,enable-manual-drd"
32 - pinctrl-0 : pin control group 32 - pinctrl-0 : pin control group
33 See: Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt 33 See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
34 34
35 - maximum-speed : valid arguments are "super-speed", "high-speed" and 35 - maximum-speed : valid arguments are "super-speed", "high-speed" and
36 "full-speed"; refer to usb/generic.txt 36 "full-speed"; refer to usb/generic.txt
@@ -56,10 +56,10 @@ ssusb: usb@11271000 {
56 phys = <&phy_port0 PHY_TYPE_USB3>, 56 phys = <&phy_port0 PHY_TYPE_USB3>,
57 <&phy_port1 PHY_TYPE_USB2>; 57 <&phy_port1 PHY_TYPE_USB2>;
58 power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>; 58 power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
59 clocks = <&topckgen CLK_TOP_USB30_SEL>, 59 clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>,
60 <&pericfg CLK_PERI_USB0>, 60 <&pericfg CLK_PERI_USB0>,
61 <&pericfg CLK_PERI_USB1>; 61 <&pericfg CLK_PERI_USB1>;
62 clock-names = "sys_ck", 62 clock-names = "sys_ck", "ref_ck",
63 "wakeup_deb_p0", 63 "wakeup_deb_p0",
64 "wakeup_deb_p1"; 64 "wakeup_deb_p1";
65 vusb33-supply = <&mt6397_vusb_reg>; 65 vusb33-supply = <&mt6397_vusb_reg>;
@@ -79,8 +79,8 @@ ssusb: usb@11271000 {
79 reg-names = "mac"; 79 reg-names = "mac";
80 interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>; 80 interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
81 power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>; 81 power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
82 clocks = <&topckgen CLK_TOP_USB30_SEL>; 82 clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>;
83 clock-names = "sys_ck"; 83 clock-names = "sys_ck", "ref_ck";
84 vusb33-supply = <&mt6397_vusb_reg>; 84 vusb33-supply = <&mt6397_vusb_reg>;
85 status = "disabled"; 85 status = "disabled";
86 }; 86 };
diff --git a/Documentation/devicetree/bindings/usb/mt8173-xhci.txt b/Documentation/devicetree/bindings/usb/mt8173-xhci.txt
index 2a930bd52b94..0acfc8acbea1 100644
--- a/Documentation/devicetree/bindings/usb/mt8173-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/mt8173-xhci.txt
@@ -23,6 +23,7 @@ Required properties:
23 entry in clock-names 23 entry in clock-names
24 - clock-names : must contain 24 - clock-names : must contain
25 "sys_ck": for clock of xHCI MAC 25 "sys_ck": for clock of xHCI MAC
26 "ref_ck": for reference clock of xHCI MAC
26 "wakeup_deb_p0": for USB wakeup debounce clock of port0 27 "wakeup_deb_p0": for USB wakeup debounce clock of port0
27 "wakeup_deb_p1": for USB wakeup debounce clock of port1 28 "wakeup_deb_p1": for USB wakeup debounce clock of port1
28 29
@@ -37,7 +38,7 @@ Optional properties:
37 - usb3-lpm-capable : supports USB3.0 LPM 38 - usb3-lpm-capable : supports USB3.0 LPM
38 - pinctrl-names : a pinctrl state named "default" must be defined 39 - pinctrl-names : a pinctrl state named "default" must be defined
39 - pinctrl-0 : pin control group 40 - pinctrl-0 : pin control group
40 See: Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt 41 See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
41 42
42Example: 43Example:
43usb30: usb@11270000 { 44usb30: usb@11270000 {
@@ -47,10 +48,10 @@ usb30: usb@11270000 {
47 reg-names = "mac", "ippc"; 48 reg-names = "mac", "ippc";
48 interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>; 49 interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
49 power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>; 50 power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
50 clocks = <&topckgen CLK_TOP_USB30_SEL>, 51 clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>,
51 <&pericfg CLK_PERI_USB0>, 52 <&pericfg CLK_PERI_USB0>,
52 <&pericfg CLK_PERI_USB1>; 53 <&pericfg CLK_PERI_USB1>;
53 clock-names = "sys_ck", 54 clock-names = "sys_ck", "ref_ck",
54 "wakeup_deb_p0", 55 "wakeup_deb_p0",
55 "wakeup_deb_p1"; 56 "wakeup_deb_p1";
56 phys = <&phy_port0 PHY_TYPE_USB3>, 57 phys = <&phy_port0 PHY_TYPE_USB3>,
@@ -67,7 +68,7 @@ usb30: usb@11270000 {
67 68
68In the case, xhci is added as subnode to mtu3. An example and the DT binding 69In the case, xhci is added as subnode to mtu3. An example and the DT binding
69details of mtu3 can be found in: 70details of mtu3 can be found in:
70Documentation/devicetree/bindings/usb/mtu3.txt 71Documentation/devicetree/bindings/usb/mt8173-mtu3.txt
71 72
72Required properties: 73Required properties:
73 - compatible : should contain "mediatek,mt8173-xhci" 74 - compatible : should contain "mediatek,mt8173-xhci"
@@ -82,6 +83,7 @@ Required properties:
82 entry in clock-names 83 entry in clock-names
83 - clock-names : must be 84 - clock-names : must be
84 "sys_ck": for clock of xHCI MAC 85 "sys_ck": for clock of xHCI MAC
86 "ref_ck": for reference clock of xHCI MAC
85 87
86Optional properties: 88Optional properties:
87 - vbus-supply : reference to the VBUS regulator; 89 - vbus-supply : reference to the VBUS regulator;
@@ -94,8 +96,8 @@ usb30: usb@11270000 {
94 reg-names = "mac"; 96 reg-names = "mac";
95 interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>; 97 interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
96 power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>; 98 power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
97 clocks = <&topckgen CLK_TOP_USB30_SEL>; 99 clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>;
98 clock-names = "sys_ck"; 100 clock-names = "sys_ck", "ref_ck";
99 vusb33-supply = <&mt6397_vusb_reg>; 101 vusb33-supply = <&mt6397_vusb_reg>;
100 usb3-lpm-capable; 102 usb3-lpm-capable;
101}; 103};
diff --git a/Documentation/devicetree/bindings/usb/qcom,dwc3.txt b/Documentation/devicetree/bindings/usb/qcom,dwc3.txt
index 39acb084bce9..73cc0963e823 100644
--- a/Documentation/devicetree/bindings/usb/qcom,dwc3.txt
+++ b/Documentation/devicetree/bindings/usb/qcom,dwc3.txt
@@ -18,7 +18,7 @@ A child node must exist to represent the core DWC3 IP block. The name of
18the node is not important. The content of the node is defined in dwc3.txt. 18the node is not important. The content of the node is defined in dwc3.txt.
19 19
20Phy documentation is provided in the following places: 20Phy documentation is provided in the following places:
21Documentation/devicetree/bindings/phy/qcom,dwc3-usb-phy.txt 21Documentation/devicetree/bindings/phy/qcom-dwc3-usb-phy.txt
22 22
23Example device nodes: 23Example device nodes:
24 24
diff --git a/Documentation/devicetree/bindings/usb/ulpi.txt b/Documentation/devicetree/bindings/usb/ulpi.txt
new file mode 100644
index 000000000000..ca179dc4bd50
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ulpi.txt
@@ -0,0 +1,20 @@
1ULPI bus binding
2----------------
3
4Phys that are behind a ULPI connection can be described with the following
5binding. The host controller shall have a "ulpi" named node as a child, and
6that node shall have one enabled node underneath it representing the ulpi
7device on the bus.
8
9EXAMPLE
10-------
11
12usb {
13 compatible = "vendor,usb-controller";
14
15 ulpi {
16 phy {
17 compatible = "vendor,phy";
18 };
19 };
20};
diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 0b7d8576001c..2d80b60eeabe 100644
--- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -27,6 +27,7 @@ Required properties:
27Optional properties: 27Optional properties:
28 - clocks: reference to a clock 28 - clocks: reference to a clock
29 - usb3-lpm-capable: determines if platform is USB3 LPM capable 29 - usb3-lpm-capable: determines if platform is USB3 LPM capable
30 - quirk-broken-port-ped: set if the controller has broken port disable mechanism
30 31
31Example: 32Example:
32 usb@f0931000 { 33 usb@f0931000 {
diff --git a/Documentation/devicetree/bindings/usb/usb251xb.txt b/Documentation/devicetree/bindings/usb/usb251xb.txt
new file mode 100644
index 000000000000..3957d4edaa74
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/usb251xb.txt
@@ -0,0 +1,66 @@
1Microchip USB 2.0 Hi-Speed Hub Controller
2
3The device node for the configuration of a Microchip USB251xB/xBi USB 2.0
4Hi-Speed Controller.
5
6Required properties :
7 - compatible : Should be "microchip,usb251xb" or one of the specific types:
8 "microchip,usb2512b", "microchip,usb2512bi", "microchip,usb2513b",
9 "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi"
10 - reset-gpios : Should specify the gpio for hub reset
11 - reg : I2C address on the selected bus (default is <0x2C>)
12
13Optional properties :
14 - skip-config : Skip Hub configuration, but only send the USB-Attach command
15 - vendor-id : Set USB Vendor ID of the hub (16 bit, default is 0x0424)
16 - product-id : Set USB Product ID of the hub (16 bit, default depends on type)
17 - device-id : Set USB Device ID of the hub (16 bit, default is 0x0bb3)
18 - language-id : Set USB Language ID (16 bit, default is 0x0000)
19 - manufacturer : Set USB Manufacturer string (max 31 characters long)
20 - product : Set USB Product string (max 31 characters long)
21 - serial : Set USB Serial string (max 31 characters long)
22 - {bus,self}-powered : selects between self- and bus-powered operation (default
23 is self-powered)
24 - disable-hi-speed : disable USB Hi-Speed support
25 - {multi,single}-tt : selects between multi- and single-transaction-translator
26 (default is multi-tt)
27 - disable-eop : disable End of Packet generation in full-speed mode
28 - {ganged,individual}-sensing : select over-current sense type in self-powered
29 mode (default is individual)
30 - {ganged,individual}-port-switching : select port power switching mode
31 (default is individual)
32 - dynamic-power-switching : enable auto-switching from self- to bus-powered
33 operation if the local power source is removed or unavailable
34 - oc-delay-us : Delay time (in microseconds) for filtering the over-current
35 sense inputs. Valid values are 100, 4000, 8000 (default) and 16000. If
36 an invalid value is given, the default is used instead.
37 - compound-device : indicate the hub is part of a compound device
38 - port-mapping-mode : enable port mapping mode
39 - string-support : enable string descriptor support (required for manufacturer,
40 product and serial string configuration)
41 - non-removable-ports : Should specify the ports which have a non-removable
42 device connected.
43 - sp-disabled-ports : Specifies the ports which will be self-power disabled
44 - bp-disabled-ports : Specifies the ports which will be bus-power disabled
45 - power-on-time-ms : Specifies the time it takes from the time the host
46 initiates the power-on sequence to a port until the port has adequate
47 power. The value is given in ms in a 0 - 510 range (default is 100ms).
48
49Examples:
50 usb2512b@2c {
51 compatible = "microchip,usb2512b";
52 reg = <0x2c>;
53 reset-gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
54 };
55
56 usb2514b@2c {
57 compatible = "microchip,usb2514b";
58 reg = <0x2c>;
59 reset-gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
60 vendor-id = /bits/ 16 <0x0000>;
61 product-id = /bits/ 16 <0x0000>;
62 string-support;
63 manufacturer = "Foo";
64 product = "Foo-Bar";
65 serial = "1234567890A";
66 };
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 16d3b5e7f5d1..ec0bfb9bbebd 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -40,6 +40,7 @@ atmel Atmel Corporation
40auo AU Optronics Corporation 40auo AU Optronics Corporation
41auvidea Auvidea GmbH 41auvidea Auvidea GmbH
42avago Avago Technologies 42avago Avago Technologies
43avia avia semiconductor
43avic Shanghai AVIC Optoelectronics Co., Ltd. 44avic Shanghai AVIC Optoelectronics Co., Ltd.
44axentia Axentia Technologies AB 45axentia Axentia Technologies AB
45axis Axis Communications AB 46axis Axis Communications AB
@@ -75,6 +76,7 @@ dallas Maxim Integrated Products (formerly Dallas Semiconductor)
75davicom DAVICOM Semiconductor, Inc. 76davicom DAVICOM Semiconductor, Inc.
76delta Delta Electronics, Inc. 77delta Delta Electronics, Inc.
77denx Denx Software Engineering 78denx Denx Software Engineering
79devantech Devantech, Ltd.
78digi Digi International Inc. 80digi Digi International Inc.
79digilent Diglent, Inc. 81digilent Diglent, Inc.
80dlg Dialog Semiconductor 82dlg Dialog Semiconductor
@@ -102,11 +104,13 @@ everest Everest Semiconductor Co. Ltd.
102everspin Everspin Technologies, Inc. 104everspin Everspin Technologies, Inc.
103excito Excito 105excito Excito
104ezchip EZchip Semiconductor 106ezchip EZchip Semiconductor
107faraday Faraday Technology Corporation
105fcs Fairchild Semiconductor 108fcs Fairchild Semiconductor
106firefly Firefly 109firefly Firefly
107focaltech FocalTech Systems Co.,Ltd 110focaltech FocalTech Systems Co.,Ltd
108friendlyarm Guangzhou FriendlyARM Computer Tech Co., Ltd 111friendlyarm Guangzhou FriendlyARM Computer Tech Co., Ltd
109fsl Freescale Semiconductor 112fsl Freescale Semiconductor
113fujitsu Fujitsu Ltd.
110ge General Electric Company 114ge General Electric Company
111geekbuying GeekBuying 115geekbuying GeekBuying
112gef GE Fanuc Intelligent Platforms Embedded Systems, Inc. 116gef GE Fanuc Intelligent Platforms Embedded Systems, Inc.
@@ -118,6 +122,7 @@ gmt Global Mixed-mode Technology, Inc.
118goodix Shenzhen Huiding Technology Co., Ltd. 122goodix Shenzhen Huiding Technology Co., Ltd.
119google Google, Inc. 123google Google, Inc.
120grinn Grinn 124grinn Grinn
125grmn Garmin Limited
121gumstix Gumstix, Inc. 126gumstix Gumstix, Inc.
122gw Gateworks Corporation 127gw Gateworks Corporation
123hannstar HannStar Display Corporation 128hannstar HannStar Display Corporation
@@ -159,11 +164,14 @@ kosagi Sutajio Ko-Usagi PTE Ltd.
159kyo Kyocera Corporation 164kyo Kyocera Corporation
160lacie LaCie 165lacie LaCie
161lantiq Lantiq Semiconductor 166lantiq Lantiq Semiconductor
167lego LEGO Systems A/S
162lenovo Lenovo Group Ltd. 168lenovo Lenovo Group Ltd.
163lg LG Corporation 169lg LG Corporation
170licheepi Lichee Pi
164linux Linux-specific binding 171linux Linux-specific binding
165lltc Linear Technology Corporation 172lltc Linear Technology Corporation
166lsi LSI Corp. (LSI Logic) 173lsi LSI Corp. (LSI Logic)
174lwn Liebherr-Werk Nenzing GmbH
167macnica Macnica Americas 175macnica Macnica Americas
168marvell Marvell Technology Group Ltd. 176marvell Marvell Technology Group Ltd.
169maxim Maxim Integrated Products 177maxim Maxim Integrated Products
@@ -187,6 +195,7 @@ mpl MPL AG
187mqmaker mqmaker Inc. 195mqmaker mqmaker Inc.
188msi Micro-Star International Co. Ltd. 196msi Micro-Star International Co. Ltd.
189mti Imagination Technologies Ltd. (formerly MIPS Technologies Inc.) 197mti Imagination Technologies Ltd. (formerly MIPS Technologies Inc.)
198multi-inno Multi-Inno Technology Co.,Ltd
190mundoreader Mundo Reader S.L. 199mundoreader Mundo Reader S.L.
191murata Murata Manufacturing Co., Ltd. 200murata Murata Manufacturing Co., Ltd.
192mxicy Macronix International Co., Ltd. 201mxicy Macronix International Co., Ltd.
@@ -196,6 +205,7 @@ nec NEC LCD Technologies, Ltd.
196neonode Neonode Inc. 205neonode Neonode Inc.
197netgear NETGEAR 206netgear NETGEAR
198netlogic Broadcom Corporation (formerly NetLogic Microsystems) 207netlogic Broadcom Corporation (formerly NetLogic Microsystems)
208netron-dy Netron DY
199netxeon Shenzhen Netxeon Technology CO., LTD 209netxeon Shenzhen Netxeon Technology CO., LTD
200nexbox Nexbox 210nexbox Nexbox
201newhaven Newhaven Display International 211newhaven Newhaven Display International
@@ -227,6 +237,7 @@ pine64 Pine64
227pixcir PIXCIR MICROELECTRONICS Co., Ltd 237pixcir PIXCIR MICROELECTRONICS Co., Ltd
228plathome Plat'Home Co., Ltd. 238plathome Plat'Home Co., Ltd.
229plda PLDA 239plda PLDA
240poslab Poslab Technology Co., Ltd.
230powervr PowerVR (deprecated, use img) 241powervr PowerVR (deprecated, use img)
231pulsedlight PulsedLight, Inc 242pulsedlight PulsedLight, Inc
232qca Qualcomm Atheros, Inc. 243qca Qualcomm Atheros, Inc.
@@ -296,6 +307,7 @@ technologic Technologic Systems
296terasic Terasic Inc. 307terasic Terasic Inc.
297thine THine Electronics, Inc. 308thine THine Electronics, Inc.
298ti Texas Instruments 309ti Texas Instruments
310tianma Tianma Micro-electronics Co., Ltd.
299tlm Trusted Logic Mobility 311tlm Trusted Logic Mobility
300topeet Topeet 312topeet Topeet
301toradex Toradex AG 313toradex Toradex AG
@@ -320,6 +332,7 @@ virtio Virtual I/O Device Specification, developed by the OASIS consortium
320vivante Vivante Corporation 332vivante Vivante Corporation
321voipac Voipac Technologies s.r.o. 333voipac Voipac Technologies s.r.o.
322wd Western Digital Corp. 334wd Western Digital Corp.
335wetek WeTek Electronics, limited.
323wexler Wexler 336wexler Wexler
324winbond Winbond Electronics corp. 337winbond Winbond Electronics corp.
325wlf Wolfson Microelectronics 338wlf Wolfson Microelectronics
@@ -328,7 +341,9 @@ x-powers X-Powers
328xes Extreme Engineering Solutions (X-ES) 341xes Extreme Engineering Solutions (X-ES)
329xillybus Xillybus Ltd. 342xillybus Xillybus Ltd.
330xlnx Xilinx 343xlnx Xilinx
344xunlong Shenzhen Xunlong Software CO.,Limited
331zarlink Zarlink Semiconductor 345zarlink Zarlink Semiconductor
346zeitec ZEITEC Semiconductor Co., LTD.
332zii Zodiac Inflight Innovations 347zii Zodiac Inflight Innovations
333zte ZTE Corp. 348zte ZTE Corp.
334zyxel ZyXEL Communications Corp. 349zyxel ZyXEL Communications Corp.
diff --git a/Documentation/devicetree/bindings/watchdog/cortina,gemin-watchdog.txt b/Documentation/devicetree/bindings/watchdog/cortina,gemin-watchdog.txt
new file mode 100644
index 000000000000..bc4b865d178b
--- /dev/null
+++ b/Documentation/devicetree/bindings/watchdog/cortina,gemin-watchdog.txt
@@ -0,0 +1,17 @@
1Cortina Systems Gemini SoC Watchdog
2
3Required properties:
4- compatible : must be "cortina,gemini-watchdog"
5- reg : shall contain base register location and length
6- interrupts : shall contain the interrupt for the watchdog
7
8Optional properties:
9- timeout-sec : the default watchdog timeout in seconds.
10
11Example:
12
13watchdog@41000000 {
14 compatible = "cortina,gemini-watchdog";
15 reg = <0x41000000 0x1000>;
16 interrupts = <3 IRQ_TYPE_LEVEL_HIGH>;
17};
diff --git a/Documentation/devicetree/bindings/watchdog/samsung-wdt.txt b/Documentation/devicetree/bindings/watchdog/samsung-wdt.txt
index 8f3d96af81d7..1f6e101e299a 100644
--- a/Documentation/devicetree/bindings/watchdog/samsung-wdt.txt
+++ b/Documentation/devicetree/bindings/watchdog/samsung-wdt.txt
@@ -6,10 +6,11 @@ occurred.
6 6
7Required properties: 7Required properties:
8- compatible : should be one among the following 8- compatible : should be one among the following
9 (a) "samsung,s3c2410-wdt" for Exynos4 and previous SoCs 9 - "samsung,s3c2410-wdt" for S3C2410
10 (b) "samsung,exynos5250-wdt" for Exynos5250 10 - "samsung,s3c6410-wdt" for S3C6410, S5PV210 and Exynos4
11 (c) "samsung,exynos5420-wdt" for Exynos5420 11 - "samsung,exynos5250-wdt" for Exynos5250
12 (c) "samsung,exynos7-wdt" for Exynos7 12 - "samsung,exynos5420-wdt" for Exynos5420
13 - "samsung,exynos7-wdt" for Exynos7
13 14
14- reg : base physical address of the controller and length of memory mapped 15- reg : base physical address of the controller and length of memory mapped
15 region. 16 region.
diff --git a/Documentation/devicetree/bindings/watchdog/zte,zx2967-wdt.txt b/Documentation/devicetree/bindings/watchdog/zte,zx2967-wdt.txt
new file mode 100644
index 000000000000..06ce67766756
--- /dev/null
+++ b/Documentation/devicetree/bindings/watchdog/zte,zx2967-wdt.txt
@@ -0,0 +1,32 @@
1ZTE zx2967 Watchdog timer
2
3Required properties:
4
5- compatible : should be one of the following.
6 * zte,zx296718-wdt
7- reg : Specifies base physical address and size of the registers.
8- clocks : Pairs of phandle and specifier referencing the controller's clocks.
9- resets : Reference to the reset controller controlling the watchdog
10 controller.
11
12Optional properties:
13
14- timeout-sec : Contains the watchdog timeout in seconds.
15- zte,wdt-reset-sysctrl : Directs how to reset system by the watchdog.
16 if we don't want to restart system when watchdog been triggered,
17 it's not required, vice versa.
18 It should include following fields.
19 * phandle of aon-sysctrl.
20 * offset of register that be written, should be 0xb0.
21 * configure value that be written to aon-sysctrl.
22 * bit mask, corresponding bits will be affected.
23
24Example:
25
26wdt: watchdog@1465000 {
27 compatible = "zte,zx296718-wdt";
28 reg = <0x1465000 0x1000>;
29 clocks = <&topcrm WDT_WCLK>;
30 resets = <&toprst 35>;
31 zte,wdt-reset-sysctrl = <&aon_sysctrl 0xb0 1 0x115>;
32};
diff --git a/Documentation/dma-buf-sharing.txt b/Documentation/dma-buf-sharing.txt
deleted file mode 100644
index ca44c5820585..000000000000
--- a/Documentation/dma-buf-sharing.txt
+++ /dev/null
@@ -1,482 +0,0 @@
1 DMA Buffer Sharing API Guide
2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3
4 Sumit Semwal
5 <sumit dot semwal at linaro dot org>
6 <sumit dot semwal at ti dot com>
7
8This document serves as a guide to device-driver writers on what is the dma-buf
9buffer sharing API, how to use it for exporting and using shared buffers.
10
11Any device driver which wishes to be a part of DMA buffer sharing, can do so as
12either the 'exporter' of buffers, or the 'user' of buffers.
13
14Say a driver A wants to use buffers created by driver B, then we call B as the
15exporter, and A as buffer-user.
16
17The exporter
18- implements and manages operations[1] for the buffer
19- allows other users to share the buffer by using dma_buf sharing APIs,
20- manages the details of buffer allocation,
21- decides about the actual backing storage where this allocation happens,
22- takes care of any migration of scatterlist - for all (shared) users of this
23 buffer,
24
25The buffer-user
26- is one of (many) sharing users of the buffer.
27- doesn't need to worry about how the buffer is allocated, or where.
28- needs a mechanism to get access to the scatterlist that makes up this buffer
29 in memory, mapped into its own address space, so it can access the same area
30 of memory.
31
32dma-buf operations for device dma only
33--------------------------------------
34
35The dma_buf buffer sharing API usage contains the following steps:
36
371. Exporter announces that it wishes to export a buffer
382. Userspace gets the file descriptor associated with the exported buffer, and
39 passes it around to potential buffer-users based on use case
403. Each buffer-user 'connects' itself to the buffer
414. When needed, buffer-user requests access to the buffer from exporter
425. When finished with its use, the buffer-user notifies end-of-DMA to exporter
436. when buffer-user is done using this buffer completely, it 'disconnects'
44 itself from the buffer.
45
46
471. Exporter's announcement of buffer export
48
49 The buffer exporter announces its wish to export a buffer. In this, it
50 connects its own private buffer data, provides implementation for operations
51 that can be performed on the exported dma_buf, and flags for the file
52 associated with this buffer. All these fields are filled in struct
53 dma_buf_export_info, defined via the DEFINE_DMA_BUF_EXPORT_INFO macro.
54
55 Interface:
56 DEFINE_DMA_BUF_EXPORT_INFO(exp_info)
57 struct dma_buf *dma_buf_export(struct dma_buf_export_info *exp_info)
58
59 If this succeeds, dma_buf_export allocates a dma_buf structure, and
60 returns a pointer to the same. It also associates an anonymous file with this
61 buffer, so it can be exported. On failure to allocate the dma_buf object,
62 it returns NULL.
63
64 'exp_name' in struct dma_buf_export_info is the name of exporter - to
65 facilitate information while debugging. It is set to KBUILD_MODNAME by
66 default, so exporters don't have to provide a specific name, if they don't
67 wish to.
68
69 DEFINE_DMA_BUF_EXPORT_INFO macro defines the struct dma_buf_export_info,
70 zeroes it out and pre-populates exp_name in it.
71
72
732. Userspace gets a handle to pass around to potential buffer-users
74
75 Userspace entity requests for a file-descriptor (fd) which is a handle to the
76 anonymous file associated with the buffer. It can then share the fd with other
77 drivers and/or processes.
78
79 Interface:
80 int dma_buf_fd(struct dma_buf *dmabuf, int flags)
81
82 This API installs an fd for the anonymous file associated with this buffer;
83 returns either 'fd', or error.
84
853. Each buffer-user 'connects' itself to the buffer
86
87 Each buffer-user now gets a reference to the buffer, using the fd passed to
88 it.
89
90 Interface:
91 struct dma_buf *dma_buf_get(int fd)
92
93 This API will return a reference to the dma_buf, and increment refcount for
94 it.
95
96 After this, the buffer-user needs to attach its device with the buffer, which
97 helps the exporter to know of device buffer constraints.
98
99 Interface:
100 struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
101 struct device *dev)
102
103 This API returns reference to an attachment structure, which is then used
104 for scatterlist operations. It will optionally call the 'attach' dma_buf
105 operation, if provided by the exporter.
106
107 The dma-buf sharing framework does the bookkeeping bits related to managing
108 the list of all attachments to a buffer.
109
110Until this stage, the buffer-exporter has the option to choose not to actually
111allocate the backing storage for this buffer, but wait for the first buffer-user
112to request use of buffer for allocation.
113
114
1154. When needed, buffer-user requests access to the buffer
116
117 Whenever a buffer-user wants to use the buffer for any DMA, it asks for
118 access to the buffer using dma_buf_map_attachment API. At least one attach to
119 the buffer must have happened before map_dma_buf can be called.
120
121 Interface:
122 struct sg_table * dma_buf_map_attachment(struct dma_buf_attachment *,
123 enum dma_data_direction);
124
125 This is a wrapper to dma_buf->ops->map_dma_buf operation, which hides the
126 "dma_buf->ops->" indirection from the users of this interface.
127
128 In struct dma_buf_ops, map_dma_buf is defined as
129 struct sg_table * (*map_dma_buf)(struct dma_buf_attachment *,
130 enum dma_data_direction);
131
132 It is one of the buffer operations that must be implemented by the exporter.
133 It should return the sg_table containing scatterlist for this buffer, mapped
134 into caller's address space.
135
136 If this is being called for the first time, the exporter can now choose to
137 scan through the list of attachments for this buffer, collate the requirements
138 of the attached devices, and choose an appropriate backing storage for the
139 buffer.
140
141 Based on enum dma_data_direction, it might be possible to have multiple users
142 accessing at the same time (for reading, maybe), or any other kind of sharing
143 that the exporter might wish to make available to buffer-users.
144
145 map_dma_buf() operation can return -EINTR if it is interrupted by a signal.
146
147
1485. When finished, the buffer-user notifies end-of-DMA to exporter
149
150 Once the DMA for the current buffer-user is over, it signals 'end-of-DMA' to
151 the exporter using the dma_buf_unmap_attachment API.
152
153 Interface:
154 void dma_buf_unmap_attachment(struct dma_buf_attachment *,
155 struct sg_table *);
156
157 This is a wrapper to dma_buf->ops->unmap_dma_buf() operation, which hides the
158 "dma_buf->ops->" indirection from the users of this interface.
159
160 In struct dma_buf_ops, unmap_dma_buf is defined as
161 void (*unmap_dma_buf)(struct dma_buf_attachment *,
162 struct sg_table *,
163 enum dma_data_direction);
164
165 unmap_dma_buf signifies the end-of-DMA for the attachment provided. Like
166 map_dma_buf, this API also must be implemented by the exporter.
167
168
1696. when buffer-user is done using this buffer, it 'disconnects' itself from the
170 buffer.
171
172 After the buffer-user has no more interest in using this buffer, it should
173 disconnect itself from the buffer:
174
175 - it first detaches itself from the buffer.
176
177 Interface:
178 void dma_buf_detach(struct dma_buf *dmabuf,
179 struct dma_buf_attachment *dmabuf_attach);
180
181 This API removes the attachment from the list in dmabuf, and optionally calls
182 dma_buf->ops->detach(), if provided by exporter, for any housekeeping bits.
183
184 - Then, the buffer-user returns the buffer reference to exporter.
185
186 Interface:
187 void dma_buf_put(struct dma_buf *dmabuf);
188
189 This API then reduces the refcount for this buffer.
190
191 If, as a result of this call, the refcount becomes 0, the 'release' file
192 operation related to this fd is called. It calls the dmabuf->ops->release()
193 operation in turn, and frees the memory allocated for dmabuf when exported.
194
195NOTES:
196- Importance of attach-detach and {map,unmap}_dma_buf operation pairs
197 The attach-detach calls allow the exporter to figure out backing-storage
198 constraints for the currently-interested devices. This allows preferential
199 allocation, and/or migration of pages across different types of storage
200 available, if possible.
201
202 Bracketing of DMA access with {map,unmap}_dma_buf operations is essential
203 to allow just-in-time backing of storage, and migration mid-way through a
204 use-case.
205
206- Migration of backing storage if needed
207 If after
208 - at least one map_dma_buf has happened,
209 - and the backing storage has been allocated for this buffer,
210 another new buffer-user intends to attach itself to this buffer, it might
211 be allowed, if possible for the exporter.
212
213 In case it is allowed by the exporter:
214 if the new buffer-user has stricter 'backing-storage constraints', and the
215 exporter can handle these constraints, the exporter can just stall on the
216 map_dma_buf until all outstanding access is completed (as signalled by
217 unmap_dma_buf).
218 Once all users have finished accessing and have unmapped this buffer, the
219 exporter could potentially move the buffer to the stricter backing-storage,
220 and then allow further {map,unmap}_dma_buf operations from any buffer-user
221 from the migrated backing-storage.
222
223 If the exporter cannot fulfill the backing-storage constraints of the new
224 buffer-user device as requested, dma_buf_attach() would return an error to
225 denote non-compatibility of the new buffer-sharing request with the current
226 buffer.
227
228 If the exporter chooses not to allow an attach() operation once a
229 map_dma_buf() API has been called, it simply returns an error.
230
231Kernel cpu access to a dma-buf buffer object
232--------------------------------------------
233
234The motivation to allow cpu access from the kernel to a dma-buf object from the
235importers side are:
236- fallback operations, e.g. if the devices is connected to a usb bus and the
237 kernel needs to shuffle the data around first before sending it away.
238- full transparency for existing users on the importer side, i.e. userspace
239 should not notice the difference between a normal object from that subsystem
240 and an imported one backed by a dma-buf. This is really important for drm
241 opengl drivers that expect to still use all the existing upload/download
242 paths.
243
244Access to a dma_buf from the kernel context involves three steps:
245
2461. Prepare access, which invalidate any necessary caches and make the object
247 available for cpu access.
2482. Access the object page-by-page with the dma_buf map apis
2493. Finish access, which will flush any necessary cpu caches and free reserved
250 resources.
251
2521. Prepare access
253
254 Before an importer can access a dma_buf object with the cpu from the kernel
255 context, it needs to notify the exporter of the access that is about to
256 happen.
257
258 Interface:
259 int dma_buf_begin_cpu_access(struct dma_buf *dmabuf,
260 enum dma_data_direction direction)
261
262 This allows the exporter to ensure that the memory is actually available for
263 cpu access - the exporter might need to allocate or swap-in and pin the
264 backing storage. The exporter also needs to ensure that cpu access is
265 coherent for the access direction. The direction can be used by the exporter
266 to optimize the cache flushing, i.e. access with a different direction (read
267 instead of write) might return stale or even bogus data (e.g. when the
268 exporter needs to copy the data to temporary storage).
269
270 This step might fail, e.g. in oom conditions.
271
2722. Accessing the buffer
273
274 To support dma_buf objects residing in highmem cpu access is page-based using
275 an api similar to kmap. Accessing a dma_buf is done in aligned chunks of
276 PAGE_SIZE size. Before accessing a chunk it needs to be mapped, which returns
277 a pointer in kernel virtual address space. Afterwards the chunk needs to be
278 unmapped again. There is no limit on how often a given chunk can be mapped
279 and unmapped, i.e. the importer does not need to call begin_cpu_access again
280 before mapping the same chunk again.
281
282 Interfaces:
283 void *dma_buf_kmap(struct dma_buf *, unsigned long);
284 void dma_buf_kunmap(struct dma_buf *, unsigned long, void *);
285
286 There are also atomic variants of these interfaces. Like for kmap they
287 facilitate non-blocking fast-paths. Neither the importer nor the exporter (in
288 the callback) is allowed to block when using these.
289
290 Interfaces:
291 void *dma_buf_kmap_atomic(struct dma_buf *, unsigned long);
292 void dma_buf_kunmap_atomic(struct dma_buf *, unsigned long, void *);
293
294 For importers all the restrictions of using kmap apply, like the limited
295 supply of kmap_atomic slots. Hence an importer shall only hold onto at most 2
296 atomic dma_buf kmaps at the same time (in any given process context).
297
298 dma_buf kmap calls outside of the range specified in begin_cpu_access are
299 undefined. If the range is not PAGE_SIZE aligned, kmap needs to succeed on
300 the partial chunks at the beginning and end but may return stale or bogus
301 data outside of the range (in these partial chunks).
302
303 Note that these calls need to always succeed. The exporter needs to complete
304 any preparations that might fail in begin_cpu_access.
305
306 For some cases the overhead of kmap can be too high, a vmap interface
307 is introduced. This interface should be used very carefully, as vmalloc
308 space is a limited resources on many architectures.
309
310 Interfaces:
311 void *dma_buf_vmap(struct dma_buf *dmabuf)
312 void dma_buf_vunmap(struct dma_buf *dmabuf, void *vaddr)
313
314 The vmap call can fail if there is no vmap support in the exporter, or if it
315 runs out of vmalloc space. Fallback to kmap should be implemented. Note that
316 the dma-buf layer keeps a reference count for all vmap access and calls down
317 into the exporter's vmap function only when no vmapping exists, and only
318 unmaps it once. Protection against concurrent vmap/vunmap calls is provided
319 by taking the dma_buf->lock mutex.
320
3213. Finish access
322
323 When the importer is done accessing the CPU, it needs to announce this to
324 the exporter (to facilitate cache flushing and unpinning of any pinned
325 resources). The result of any dma_buf kmap calls after end_cpu_access is
326 undefined.
327
328 Interface:
329 void dma_buf_end_cpu_access(struct dma_buf *dma_buf,
330 enum dma_data_direction dir);
331
332
333Direct Userspace Access/mmap Support
334------------------------------------
335
336Being able to mmap an export dma-buf buffer object has 2 main use-cases:
337- CPU fallback processing in a pipeline and
338- supporting existing mmap interfaces in importers.
339
3401. CPU fallback processing in a pipeline
341
342 In many processing pipelines it is sometimes required that the cpu can access
343 the data in a dma-buf (e.g. for thumbnail creation, snapshots, ...). To avoid
344 the need to handle this specially in userspace frameworks for buffer sharing
345 it's ideal if the dma_buf fd itself can be used to access the backing storage
346 from userspace using mmap.
347
348 Furthermore Android's ION framework already supports this (and is otherwise
349 rather similar to dma-buf from a userspace consumer side with using fds as
350 handles, too). So it's beneficial to support this in a similar fashion on
351 dma-buf to have a good transition path for existing Android userspace.
352
353 No special interfaces, userspace simply calls mmap on the dma-buf fd, making
354 sure that the cache synchronization ioctl (DMA_BUF_IOCTL_SYNC) is *always*
355 used when the access happens. Note that DMA_BUF_IOCTL_SYNC can fail with
356 -EAGAIN or -EINTR, in which case it must be restarted.
357
358 Some systems might need some sort of cache coherency management e.g. when
359 CPU and GPU domains are being accessed through dma-buf at the same time. To
360 circumvent this problem there are begin/end coherency markers, that forward
361 directly to existing dma-buf device drivers vfunc hooks. Userspace can make
362 use of those markers through the DMA_BUF_IOCTL_SYNC ioctl. The sequence
363 would be used like following:
364 - mmap dma-buf fd
365 - for each drawing/upload cycle in CPU 1. SYNC_START ioctl, 2. read/write
366 to mmap area 3. SYNC_END ioctl. This can be repeated as often as you
367 want (with the new data being consumed by the GPU or say scanout device)
368 - munmap once you don't need the buffer any more
369
370 For correctness and optimal performance, it is always required to use
371 SYNC_START and SYNC_END before and after, respectively, when accessing the
372 mapped address. Userspace cannot rely on coherent access, even when there
373 are systems where it just works without calling these ioctls.
374
3752. Supporting existing mmap interfaces in importers
376
377 Similar to the motivation for kernel cpu access it is again important that
378 the userspace code of a given importing subsystem can use the same interfaces
379 with a imported dma-buf buffer object as with a native buffer object. This is
380 especially important for drm where the userspace part of contemporary OpenGL,
381 X, and other drivers is huge, and reworking them to use a different way to
382 mmap a buffer rather invasive.
383
384 The assumption in the current dma-buf interfaces is that redirecting the
385 initial mmap is all that's needed. A survey of some of the existing
386 subsystems shows that no driver seems to do any nefarious thing like syncing
387 up with outstanding asynchronous processing on the device or allocating
388 special resources at fault time. So hopefully this is good enough, since
389 adding interfaces to intercept pagefaults and allow pte shootdowns would
390 increase the complexity quite a bit.
391
392 Interface:
393 int dma_buf_mmap(struct dma_buf *, struct vm_area_struct *,
394 unsigned long);
395
396 If the importing subsystem simply provides a special-purpose mmap call to set
397 up a mapping in userspace, calling do_mmap with dma_buf->file will equally
398 achieve that for a dma-buf object.
399
4003. Implementation notes for exporters
401
402 Because dma-buf buffers have invariant size over their lifetime, the dma-buf
403 core checks whether a vma is too large and rejects such mappings. The
404 exporter hence does not need to duplicate this check.
405
406 Because existing importing subsystems might presume coherent mappings for
407 userspace, the exporter needs to set up a coherent mapping. If that's not
408 possible, it needs to fake coherency by manually shooting down ptes when
409 leaving the cpu domain and flushing caches at fault time. Note that all the
410 dma_buf files share the same anon inode, hence the exporter needs to replace
411 the dma_buf file stored in vma->vm_file with it's own if pte shootdown is
412 required. This is because the kernel uses the underlying inode's address_space
413 for vma tracking (and hence pte tracking at shootdown time with
414 unmap_mapping_range).
415
416 If the above shootdown dance turns out to be too expensive in certain
417 scenarios, we can extend dma-buf with a more explicit cache tracking scheme
418 for userspace mappings. But the current assumption is that using mmap is
419 always a slower path, so some inefficiencies should be acceptable.
420
421 Exporters that shoot down mappings (for any reasons) shall not do any
422 synchronization at fault time with outstanding device operations.
423 Synchronization is an orthogonal issue to sharing the backing storage of a
424 buffer and hence should not be handled by dma-buf itself. This is explicitly
425 mentioned here because many people seem to want something like this, but if
426 different exporters handle this differently, buffer sharing can fail in
427 interesting ways depending upong the exporter (if userspace starts depending
428 upon this implicit synchronization).
429
430Other Interfaces Exposed to Userspace on the dma-buf FD
431------------------------------------------------------
432
433- Since kernel 3.12 the dma-buf FD supports the llseek system call, but only
434 with offset=0 and whence=SEEK_END|SEEK_SET. SEEK_SET is supported to allow
435 the usual size discover pattern size = SEEK_END(0); SEEK_SET(0). Every other
436 llseek operation will report -EINVAL.
437
438 If llseek on dma-buf FDs isn't support the kernel will report -ESPIPE for all
439 cases. Userspace can use this to detect support for discovering the dma-buf
440 size using llseek.
441
442Miscellaneous notes
443-------------------
444
445- Any exporters or users of the dma-buf buffer sharing framework must have
446 a 'select DMA_SHARED_BUFFER' in their respective Kconfigs.
447
448- In order to avoid fd leaks on exec, the FD_CLOEXEC flag must be set
449 on the file descriptor. This is not just a resource leak, but a
450 potential security hole. It could give the newly exec'd application
451 access to buffers, via the leaked fd, to which it should otherwise
452 not be permitted access.
453
454 The problem with doing this via a separate fcntl() call, versus doing it
455 atomically when the fd is created, is that this is inherently racy in a
456 multi-threaded app[3]. The issue is made worse when it is library code
457 opening/creating the file descriptor, as the application may not even be
458 aware of the fd's.
459
460 To avoid this problem, userspace must have a way to request O_CLOEXEC
461 flag be set when the dma-buf fd is created. So any API provided by
462 the exporting driver to create a dmabuf fd must provide a way to let
463 userspace control setting of O_CLOEXEC flag passed in to dma_buf_fd().
464
465- If an exporter needs to manually flush caches and hence needs to fake
466 coherency for mmap support, it needs to be able to zap all the ptes pointing
467 at the backing storage. Now linux mm needs a struct address_space associated
468 with the struct file stored in vma->vm_file to do that with the function
469 unmap_mapping_range. But the dma_buf framework only backs every dma_buf fd
470 with the anon_file struct file, i.e. all dma_bufs share the same file.
471
472 Hence exporters need to setup their own file (and address_space) association
473 by setting vma->vm_file and adjusting vma->vm_pgoff in the dma_buf mmap
474 callback. In the specific case of a gem driver the exporter could use the
475 shmem file already provided by gem (and set vm_pgoff = 0). Exporters can then
476 zap ptes by unmapping the corresponding range of the struct address_space
477 associated with their own file.
478
479References:
480[1] struct dma_buf_ops in include/linux/dma-buf.h
481[2] All interfaces mentioned above defined in include/linux/dma-buf.h
482[3] https://lwn.net/Articles/236486/
diff --git a/Documentation/dontdiff b/Documentation/dontdiff
index a23edccd2059..77b92221f951 100644
--- a/Documentation/dontdiff
+++ b/Documentation/dontdiff
@@ -116,9 +116,11 @@ crc32table.h*
116cscope.* 116cscope.*
117defkeymap.c 117defkeymap.c
118devlist.h* 118devlist.h*
119devicetable-offsets.h
119dnotify_test 120dnotify_test
120docproc 121docproc
121dslm 122dslm
123dtc
122elf2ecoff 124elf2ecoff
123elfconfig.h* 125elfconfig.h*
124evergreen_reg_safe.h 126evergreen_reg_safe.h
@@ -153,8 +155,8 @@ keywords.c
153ksym.c* 155ksym.c*
154ksym.h* 156ksym.h*
155kxgettext 157kxgettext
156lex.c 158*lex.c
157lex.*.c 159*lex.*.c
158linux 160linux
159logo_*.c 161logo_*.c
160logo_*_clut224.c 162logo_*_clut224.c
@@ -215,6 +217,7 @@ series
215setup 217setup
216setup.bin 218setup.bin
217setup.elf 219setup.elf
220sortextable
218sImage 221sImage
219sm_tbl* 222sm_tbl*
220split-include 223split-include
diff --git a/Documentation/driver-api/80211/cfg80211.rst b/Documentation/driver-api/80211/cfg80211.rst
index b1e149ea6fee..eca534ab6172 100644
--- a/Documentation/driver-api/80211/cfg80211.rst
+++ b/Documentation/driver-api/80211/cfg80211.rst
@@ -45,6 +45,9 @@ Device registration
45 :functions: wiphy_new 45 :functions: wiphy_new
46 46
47.. kernel-doc:: include/net/cfg80211.h 47.. kernel-doc:: include/net/cfg80211.h
48 :functions: wiphy_read_of_freq_limits
49
50.. kernel-doc:: include/net/cfg80211.h
48 :functions: wiphy_register 51 :functions: wiphy_register
49 52
50.. kernel-doc:: include/net/cfg80211.h 53.. kernel-doc:: include/net/cfg80211.h
diff --git a/Documentation/driver-api/device-io.rst b/Documentation/driver-api/device-io.rst
new file mode 100644
index 000000000000..b00b23903078
--- /dev/null
+++ b/Documentation/driver-api/device-io.rst
@@ -0,0 +1,201 @@
1.. Copyright 2001 Matthew Wilcox
2..
3.. This documentation is free software; you can redistribute
4.. it and/or modify it under the terms of the GNU General Public
5.. License as published by the Free Software Foundation; either
6.. version 2 of the License, or (at your option) any later
7.. version.
8
9===============================
10Bus-Independent Device Accesses
11===============================
12
13:Author: Matthew Wilcox
14:Author: Alan Cox
15
16Introduction
17============
18
19Linux provides an API which abstracts performing IO across all busses
20and devices, allowing device drivers to be written independently of bus
21type.
22
23Memory Mapped IO
24================
25
26Getting Access to the Device
27----------------------------
28
29The most widely supported form of IO is memory mapped IO. That is, a
30part of the CPU's address space is interpreted not as accesses to
31memory, but as accesses to a device. Some architectures define devices
32to be at a fixed address, but most have some method of discovering
33devices. The PCI bus walk is a good example of such a scheme. This
34document does not cover how to receive such an address, but assumes you
35are starting with one. Physical addresses are of type unsigned long.
36
37This address should not be used directly. Instead, to get an address
38suitable for passing to the accessor functions described below, you
39should call :c:func:`ioremap()`. An address suitable for accessing
40the device will be returned to you.
41
42After you've finished using the device (say, in your module's exit
43routine), call :c:func:`iounmap()` in order to return the address
44space to the kernel. Most architectures allocate new address space each
45time you call :c:func:`ioremap()`, and they can run out unless you
46call :c:func:`iounmap()`.
47
48Accessing the device
49--------------------
50
51The part of the interface most used by drivers is reading and writing
52memory-mapped registers on the device. Linux provides interfaces to read
53and write 8-bit, 16-bit, 32-bit and 64-bit quantities. Due to a
54historical accident, these are named byte, word, long and quad accesses.
55Both read and write accesses are supported; there is no prefetch support
56at this time.
57
58The functions are named readb(), readw(), readl(), readq(),
59readb_relaxed(), readw_relaxed(), readl_relaxed(), readq_relaxed(),
60writeb(), writew(), writel() and writeq().
61
62Some devices (such as framebuffers) would like to use larger transfers than
638 bytes at a time. For these devices, the :c:func:`memcpy_toio()`,
64:c:func:`memcpy_fromio()` and :c:func:`memset_io()` functions are
65provided. Do not use memset or memcpy on IO addresses; they are not
66guaranteed to copy data in order.
67
68The read and write functions are defined to be ordered. That is the
69compiler is not permitted to reorder the I/O sequence. When the ordering
70can be compiler optimised, you can use __readb() and friends to
71indicate the relaxed ordering. Use this with care.
72
73While the basic functions are defined to be synchronous with respect to
74each other and ordered with respect to each other the busses the devices
75sit on may themselves have asynchronicity. In particular many authors
76are burned by the fact that PCI bus writes are posted asynchronously. A
77driver author must issue a read from the same device to ensure that
78writes have occurred in the specific cases the author cares. This kind
79of property cannot be hidden from driver writers in the API. In some
80cases, the read used to flush the device may be expected to fail (if the
81card is resetting, for example). In that case, the read should be done
82from config space, which is guaranteed to soft-fail if the card doesn't
83respond.
84
85The following is an example of flushing a write to a device when the
86driver would like to ensure the write's effects are visible prior to
87continuing execution::
88
89 static inline void
90 qla1280_disable_intrs(struct scsi_qla_host *ha)
91 {
92 struct device_reg *reg;
93
94 reg = ha->iobase;
95 /* disable risc and host interrupts */
96 WRT_REG_WORD(&reg->ictrl, 0);
97 /*
98 * The following read will ensure that the above write
99 * has been received by the device before we return from this
100 * function.
101 */
102 RD_REG_WORD(&reg->ictrl);
103 ha->flags.ints_enabled = 0;
104 }
105
106In addition to write posting, on some large multiprocessing systems
107(e.g. SGI Challenge, Origin and Altix machines) posted writes won't be
108strongly ordered coming from different CPUs. Thus it's important to
109properly protect parts of your driver that do memory-mapped writes with
110locks and use the :c:func:`mmiowb()` to make sure they arrive in the
111order intended. Issuing a regular readX() will also ensure write ordering,
112but should only be used when the
113driver has to be sure that the write has actually arrived at the device
114(not that it's simply ordered with respect to other writes), since a
115full readX() is a relatively expensive operation.
116
117Generally, one should use :c:func:`mmiowb()` prior to releasing a spinlock
118that protects regions using :c:func:`writeb()` or similar functions that
119aren't surrounded by readb() calls, which will ensure ordering
120and flushing. The following pseudocode illustrates what might occur if
121write ordering isn't guaranteed via :c:func:`mmiowb()` or one of the
122readX() functions::
123
124 CPU A: spin_lock_irqsave(&dev_lock, flags)
125 CPU A: ...
126 CPU A: writel(newval, ring_ptr);
127 CPU A: spin_unlock_irqrestore(&dev_lock, flags)
128 ...
129 CPU B: spin_lock_irqsave(&dev_lock, flags)
130 CPU B: writel(newval2, ring_ptr);
131 CPU B: ...
132 CPU B: spin_unlock_irqrestore(&dev_lock, flags)
133
134In the case above, newval2 could be written to ring_ptr before newval.
135Fixing it is easy though::
136
137 CPU A: spin_lock_irqsave(&dev_lock, flags)
138 CPU A: ...
139 CPU A: writel(newval, ring_ptr);
140 CPU A: mmiowb(); /* ensure no other writes beat us to the device */
141 CPU A: spin_unlock_irqrestore(&dev_lock, flags)
142 ...
143 CPU B: spin_lock_irqsave(&dev_lock, flags)
144 CPU B: writel(newval2, ring_ptr);
145 CPU B: ...
146 CPU B: mmiowb();
147 CPU B: spin_unlock_irqrestore(&dev_lock, flags)
148
149See tg3.c for a real world example of how to use :c:func:`mmiowb()`
150
151PCI ordering rules also guarantee that PIO read responses arrive after any
152outstanding DMA writes from that bus, since for some devices the result of
153a readb() call may signal to the driver that a DMA transaction is
154complete. In many cases, however, the driver may want to indicate that the
155next readb() call has no relation to any previous DMA writes
156performed by the device. The driver can use readb_relaxed() for
157these cases, although only some platforms will honor the relaxed
158semantics. Using the relaxed read functions will provide significant
159performance benefits on platforms that support it. The qla2xxx driver
160provides examples of how to use readX_relaxed(). In many cases, a majority
161of the driver's readX() calls can safely be converted to readX_relaxed()
162calls, since only a few will indicate or depend on DMA completion.
163
164Port Space Accesses
165===================
166
167Port Space Explained
168--------------------
169
170Another form of IO commonly supported is Port Space. This is a range of
171addresses separate to the normal memory address space. Access to these
172addresses is generally not as fast as accesses to the memory mapped
173addresses, and it also has a potentially smaller address space.
174
175Unlike memory mapped IO, no preparation is required to access port
176space.
177
178Accessing Port Space
179--------------------
180
181Accesses to this space are provided through a set of functions which
182allow 8-bit, 16-bit and 32-bit accesses; also known as byte, word and
183long. These functions are :c:func:`inb()`, :c:func:`inw()`,
184:c:func:`inl()`, :c:func:`outb()`, :c:func:`outw()` and
185:c:func:`outl()`.
186
187Some variants are provided for these functions. Some devices require
188that accesses to their ports are slowed down. This functionality is
189provided by appending a ``_p`` to the end of the function.
190There are also equivalents to memcpy. The :c:func:`ins()` and
191:c:func:`outs()` functions copy bytes, words or longs to the given
192port.
193
194Public Functions Provided
195=========================
196
197.. kernel-doc:: arch/x86/include/asm/io.h
198 :internal:
199
200.. kernel-doc:: lib/pci_iomap.c
201 :export:
diff --git a/Documentation/driver-api/device_link.rst b/Documentation/driver-api/device_link.rst
index 5f5713448703..70e328e16aad 100644
--- a/Documentation/driver-api/device_link.rst
+++ b/Documentation/driver-api/device_link.rst
@@ -1,3 +1,6 @@
1.. |struct dev_pm_domain| replace:: :c:type:`struct dev_pm_domain <dev_pm_domain>`
2.. |struct generic_pm_domain| replace:: :c:type:`struct generic_pm_domain <generic_pm_domain>`
3
1============ 4============
2Device links 5Device links
3============ 6============
@@ -120,12 +123,11 @@ Examples
120 is the same as if the MMU was the parent of the master device. 123 is the same as if the MMU was the parent of the master device.
121 124
122 The fact that both devices share the same power domain would normally 125 The fact that both devices share the same power domain would normally
123 suggest usage of a :c:type:`struct dev_pm_domain` or :c:type:`struct 126 suggest usage of a |struct dev_pm_domain| or |struct generic_pm_domain|,
124 generic_pm_domain`, however these are not independent devices that 127 however these are not independent devices that happen to share a power
125 happen to share a power switch, but rather the MMU device serves the 128 switch, but rather the MMU device serves the busmaster device and is
126 busmaster device and is useless without it. A device link creates a 129 useless without it. A device link creates a synthetic hierarchical
127 synthetic hierarchical relationship between the devices and is thus 130 relationship between the devices and is thus more apt.
128 more apt.
129 131
130* A Thunderbolt host controller comprises a number of PCIe hotplug ports 132* A Thunderbolt host controller comprises a number of PCIe hotplug ports
131 and an NHI device to manage the PCIe switch. On resume from system sleep, 133 and an NHI device to manage the PCIe switch. On resume from system sleep,
@@ -157,7 +159,7 @@ Examples
157Alternatives 159Alternatives
158============ 160============
159 161
160* A :c:type:`struct dev_pm_domain` can be used to override the bus, 162* A |struct dev_pm_domain| can be used to override the bus,
161 class or device type callbacks. It is intended for devices sharing 163 class or device type callbacks. It is intended for devices sharing
162 a single on/off switch, however it does not guarantee a specific 164 a single on/off switch, however it does not guarantee a specific
163 suspend/resume ordering, this needs to be implemented separately. 165 suspend/resume ordering, this needs to be implemented separately.
@@ -166,7 +168,7 @@ Alternatives
166 suspended. Furthermore it cannot be used to enforce a specific shutdown 168 suspended. Furthermore it cannot be used to enforce a specific shutdown
167 ordering or a driver presence dependency. 169 ordering or a driver presence dependency.
168 170
169* A :c:type:`struct generic_pm_domain` is a lot more heavyweight than a 171* A |struct generic_pm_domain| is a lot more heavyweight than a
170 device link and does not allow for shutdown ordering or driver presence 172 device link and does not allow for shutdown ordering or driver presence
171 dependencies. It also cannot be used on ACPI systems. 173 dependencies. It also cannot be used on ACPI systems.
172 174
diff --git a/Documentation/driver-api/dma-buf.rst b/Documentation/driver-api/dma-buf.rst
index a9b457a4b949..31671b469627 100644
--- a/Documentation/driver-api/dma-buf.rst
+++ b/Documentation/driver-api/dma-buf.rst
@@ -17,6 +17,98 @@ shared or exclusive fence(s) associated with the buffer.
17Shared DMA Buffers 17Shared DMA Buffers
18------------------ 18------------------
19 19
20This document serves as a guide to device-driver writers on what is the dma-buf
21buffer sharing API, how to use it for exporting and using shared buffers.
22
23Any device driver which wishes to be a part of DMA buffer sharing, can do so as
24either the 'exporter' of buffers, or the 'user' or 'importer' of buffers.
25
26Say a driver A wants to use buffers created by driver B, then we call B as the
27exporter, and A as buffer-user/importer.
28
29The exporter
30
31 - implements and manages operations in :c:type:`struct dma_buf_ops
32 <dma_buf_ops>` for the buffer,
33 - allows other users to share the buffer by using dma_buf sharing APIs,
34 - manages the details of buffer allocation, wrapped int a :c:type:`struct
35 dma_buf <dma_buf>`,
36 - decides about the actual backing storage where this allocation happens,
37 - and takes care of any migration of scatterlist - for all (shared) users of
38 this buffer.
39
40The buffer-user
41
42 - is one of (many) sharing users of the buffer.
43 - doesn't need to worry about how the buffer is allocated, or where.
44 - and needs a mechanism to get access to the scatterlist that makes up this
45 buffer in memory, mapped into its own address space, so it can access the
46 same area of memory. This interface is provided by :c:type:`struct
47 dma_buf_attachment <dma_buf_attachment>`.
48
49Any exporters or users of the dma-buf buffer sharing framework must have a
50'select DMA_SHARED_BUFFER' in their respective Kconfigs.
51
52Userspace Interface Notes
53~~~~~~~~~~~~~~~~~~~~~~~~~
54
55Mostly a DMA buffer file descriptor is simply an opaque object for userspace,
56and hence the generic interface exposed is very minimal. There's a few things to
57consider though:
58
59- Since kernel 3.12 the dma-buf FD supports the llseek system call, but only
60 with offset=0 and whence=SEEK_END|SEEK_SET. SEEK_SET is supported to allow
61 the usual size discover pattern size = SEEK_END(0); SEEK_SET(0). Every other
62 llseek operation will report -EINVAL.
63
64 If llseek on dma-buf FDs isn't support the kernel will report -ESPIPE for all
65 cases. Userspace can use this to detect support for discovering the dma-buf
66 size using llseek.
67
68- In order to avoid fd leaks on exec, the FD_CLOEXEC flag must be set
69 on the file descriptor. This is not just a resource leak, but a
70 potential security hole. It could give the newly exec'd application
71 access to buffers, via the leaked fd, to which it should otherwise
72 not be permitted access.
73
74 The problem with doing this via a separate fcntl() call, versus doing it
75 atomically when the fd is created, is that this is inherently racy in a
76 multi-threaded app[3]. The issue is made worse when it is library code
77 opening/creating the file descriptor, as the application may not even be
78 aware of the fd's.
79
80 To avoid this problem, userspace must have a way to request O_CLOEXEC
81 flag be set when the dma-buf fd is created. So any API provided by
82 the exporting driver to create a dmabuf fd must provide a way to let
83 userspace control setting of O_CLOEXEC flag passed in to dma_buf_fd().
84
85- Memory mapping the contents of the DMA buffer is also supported. See the
86 discussion below on `CPU Access to DMA Buffer Objects`_ for the full details.
87
88- The DMA buffer FD is also pollable, see `Fence Poll Support`_ below for
89 details.
90
91Basic Operation and Device DMA Access
92~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
93
94.. kernel-doc:: drivers/dma-buf/dma-buf.c
95 :doc: dma buf device access
96
97CPU Access to DMA Buffer Objects
98~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99
100.. kernel-doc:: drivers/dma-buf/dma-buf.c
101 :doc: cpu access
102
103Fence Poll Support
104~~~~~~~~~~~~~~~~~~
105
106.. kernel-doc:: drivers/dma-buf/dma-buf.c
107 :doc: fence polling
108
109Kernel Functions and Structures Reference
110~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
111
20.. kernel-doc:: drivers/dma-buf/dma-buf.c 112.. kernel-doc:: drivers/dma-buf/dma-buf.c
21 :export: 113 :export:
22 114
diff --git a/Documentation/driver-api/firmware/built-in-fw.rst b/Documentation/driver-api/firmware/built-in-fw.rst
new file mode 100644
index 000000000000..7300e66857f8
--- /dev/null
+++ b/Documentation/driver-api/firmware/built-in-fw.rst
@@ -0,0 +1,38 @@
1=================
2Built-in firmware
3=================
4
5Firmware can be built-in to the kernel, this means building the firmware
6into vmlinux directly, to enable avoiding having to look for firmware from
7the filesystem. Instead, firmware can be looked for inside the kernel
8directly. You can enable built-in firmware using the kernel configuration
9options:
10
11 * CONFIG_EXTRA_FIRMWARE
12 * CONFIG_EXTRA_FIRMWARE_DIR
13
14This should not be confused with CONFIG_FIRMWARE_IN_KERNEL, this is for drivers
15which enables firmware to be built as part of the kernel build process. This
16option, CONFIG_FIRMWARE_IN_KERNEL, will build all firmware for all drivers
17enabled which ship its firmware inside the Linux kernel source tree.
18
19There are a few reasons why you might want to consider building your firmware
20into the kernel with CONFIG_EXTRA_FIRMWARE though:
21
22* Speed
23* Firmware is needed for accessing the boot device, and the user doesn't
24 want to stuff the firmware into the boot initramfs.
25
26Even if you have these needs there are a few reasons why you may not be
27able to make use of built-in firmware:
28
29* Legalese - firmware is non-GPL compatible
30* Some firmware may be optional
31* Firmware upgrades are possible, therefore a new firmware would implicate
32 a complete kernel rebuild.
33* Some firmware files may be really large in size. The remote-proc subsystem
34 is an example subsystem which deals with these sorts of firmware
35* The firmware may need to be scraped out from some device specific location
36 dynamically, an example is calibration data for for some WiFi chipsets. This
37 calibration data can be unique per sold device.
38
diff --git a/Documentation/driver-api/firmware/core.rst b/Documentation/driver-api/firmware/core.rst
new file mode 100644
index 000000000000..1d1688cbc078
--- /dev/null
+++ b/Documentation/driver-api/firmware/core.rst
@@ -0,0 +1,16 @@
1==========================
2Firmware API core features
3==========================
4
5The firmware API has a rich set of core features available. This section
6documents these features.
7
8.. toctree::
9
10 fw_search_path
11 built-in-fw
12 firmware_cache
13 direct-fs-lookup
14 fallback-mechanisms
15 lookup-order
16
diff --git a/Documentation/driver-api/firmware/direct-fs-lookup.rst b/Documentation/driver-api/firmware/direct-fs-lookup.rst
new file mode 100644
index 000000000000..82b4d585a213
--- /dev/null
+++ b/Documentation/driver-api/firmware/direct-fs-lookup.rst
@@ -0,0 +1,30 @@
1========================
2Direct filesystem lookup
3========================
4
5Direct filesystem lookup is the most common form of firmware lookup performed
6by the kernel. The kernel looks for the firmware directly on the root
7filesystem in the paths documented in the section 'Firmware search paths'.
8The filesystem lookup is implemented in fw_get_filesystem_firmware(), it
9uses common core kernel file loader facility kernel_read_file_from_path().
10The max path allowed is PATH_MAX -- currently this is 4096 characters.
11
12It is recommended you keep /lib/firmware paths on your root filesystem,
13avoid having a separate partition for them in order to avoid possible
14races with lookups and avoid uses of the custom fallback mechanisms
15documented below.
16
17Firmware and initramfs
18----------------------
19
20Drivers which are built-in to the kernel should have the firmware integrated
21also as part of the initramfs used to boot the kernel given that otherwise
22a race is possible with loading the driver and the real rootfs not yet being
23available. Stuffing the firmware into initramfs resolves this race issue,
24however note that using initrd does not suffice to address the same race.
25
26There are circumstances that justify not wanting to include firmware into
27initramfs, such as dealing with large firmware firmware files for the
28remote-proc subsystem. For such cases using a userspace fallback mechanism
29is currently the only viable solution as only userspace can know for sure
30when the real rootfs is ready and mounted.
diff --git a/Documentation/driver-api/firmware/fallback-mechanisms.rst b/Documentation/driver-api/firmware/fallback-mechanisms.rst
new file mode 100644
index 000000000000..d19354794e67
--- /dev/null
+++ b/Documentation/driver-api/firmware/fallback-mechanisms.rst
@@ -0,0 +1,195 @@
1===================
2Fallback mechanisms
3===================
4
5A fallback mechanism is supported to allow to overcome failures to do a direct
6filesystem lookup on the root filesystem or when the firmware simply cannot be
7installed for practical reasons on the root filesystem. The kernel
8configuration options related to supporting the firmware fallback mechanism are:
9
10 * CONFIG_FW_LOADER_USER_HELPER: enables building the firmware fallback
11 mechanism. Most distributions enable this option today. If enabled but
12 CONFIG_FW_LOADER_USER_HELPER_FALLBACK is disabled, only the custom fallback
13 mechanism is available and for the request_firmware_nowait() call.
14 * CONFIG_FW_LOADER_USER_HELPER_FALLBACK: force enables each request to
15 enable the kobject uevent fallback mechanism on all firmware API calls
16 except request_firmware_direct(). Most distributions disable this option
17 today. The call request_firmware_nowait() allows for one alternative
18 fallback mechanism: if this kconfig option is enabled and your second
19 argument to request_firmware_nowait(), uevent, is set to false you are
20 informing the kernel that you have a custom fallback mechanism and it will
21 manually load the firmware. Read below for more details.
22
23Note that this means when having this configuration:
24
25CONFIG_FW_LOADER_USER_HELPER=y
26CONFIG_FW_LOADER_USER_HELPER_FALLBACK=n
27
28the kobject uevent fallback mechanism will never take effect even
29for request_firmware_nowait() when uevent is set to true.
30
31Justifying the firmware fallback mechanism
32==========================================
33
34Direct filesystem lookups may fail for a variety of reasons. Known reasons for
35this are worth itemizing and documenting as it justifies the need for the
36fallback mechanism:
37
38* Race against access with the root filesystem upon bootup.
39
40* Races upon resume from suspend. This is resolved by the firmware cache, but
41 the firmware cache is only supported if you use uevents, and its not
42 supported for request_firmware_into_buf().
43
44* Firmware is not accessible through typical means:
45 * It cannot be installed into the root filesystem
46 * The firmware provides very unique device specific data tailored for
47 the unit gathered with local information. An example is calibration
48 data for WiFi chipsets for mobile devices. This calibration data is
49 not common to all units, but tailored per unit. Such information may
50 be installed on a separate flash partition other than where the root
51 filesystem is provided.
52
53Types of fallback mechanisms
54============================
55
56There are really two fallback mechanisms available using one shared sysfs
57interface as a loading facility:
58
59* Kobject uevent fallback mechanism
60* Custom fallback mechanism
61
62First lets document the shared sysfs loading facility.
63
64Firmware sysfs loading facility
65===============================
66
67In order to help device drivers upload firmware using a fallback mechanism
68the firmware infrastructure creates a sysfs interface to enable userspace
69to load and indicate when firmware is ready. The sysfs directory is created
70via fw_create_instance(). This call creates a new struct device named after
71the firmware requested, and establishes it in the device hierarchy by
72associating the device used to make the request as the device's parent.
73The sysfs directory's file attributes are defined and controlled through
74the new device's class (firmare_class) and group (fw_dev_attr_groups).
75This is actually where the original firmware_class.c file name comes from,
76as originally the only firmware loading mechanism available was the
77mechanism we now use as a fallback mechanism.
78
79To load firmware using the sysfs interface we expose a loading indicator,
80and a file upload firmware into:
81
82 * /sys/$DEVPATH/loading
83 * /sys/$DEVPATH/data
84
85To upload firmware you will echo 1 onto the loading file to indicate
86you are loading firmware. You then cat the firmware into the data file,
87and you notify the kernel the firmware is ready by echo'ing 0 onto
88the loading file.
89
90The firmware device used to help load firmware using sysfs is only created if
91direct firmware loading fails and if the fallback mechanism is enabled for your
92firmware request, this is set up with fw_load_from_user_helper(). It is
93important to re-iterate that no device is created if a direct filesystem lookup
94succeeded.
95
96Using::
97
98 echo 1 > /sys/$DEVPATH/loading
99
100Will clean any previous partial load at once and make the firmware API
101return an error. When loading firmware the firmware_class grows a buffer
102for the firmware in PAGE_SIZE increments to hold the image as it comes in.
103
104firmware_data_read() and firmware_loading_show() are just provided for the
105test_firmware driver for testing, they are not called in normal use or
106expected to be used regularly by userspace.
107
108Firmware kobject uevent fallback mechanism
109==========================================
110
111Since a device is created for the sysfs interface to help load firmware as a
112fallback mechanism userspace can be informed of the addition of the device by
113relying on kobject uevents. The addition of the device into the device
114hierarchy means the fallback mechanism for firmware loading has been initiated.
115For details of implementation refer to _request_firmware_load(), in particular
116on the use of dev_set_uevent_suppress() and kobject_uevent().
117
118The kernel's kobject uevent mechanism is implemented in lib/kobject_uevent.c,
119it issues uevents to userspace. As a supplement to kobject uevents Linux
120distributions could also enable CONFIG_UEVENT_HELPER_PATH, which makes use of
121core kernel's usermode helper (UMH) functionality to call out to a userspace
122helper for kobject uevents. In practice though no standard distribution has
123ever used the CONFIG_UEVENT_HELPER_PATH. If CONFIG_UEVENT_HELPER_PATH is
124enabled this binary would be called each time kobject_uevent_env() gets called
125in the kernel for each kobject uevent triggered.
126
127Different implementations have been supported in userspace to take advantage of
128this fallback mechanism. When firmware loading was only possible using the
129sysfs mechanism the userspace component "hotplug" provided the functionality of
130monitoring for kobject events. Historically this was superseded be systemd's
131udev, however firmware loading support was removed from udev as of systemd
132commit be2ea723b1d0 ("udev: remove userspace firmware loading support")
133as of v217 on August, 2014. This means most Linux distributions today are
134not using or taking advantage of the firmware fallback mechanism provided
135by kobject uevents. This is specially exacerbated due to the fact that most
136distributions today disable CONFIG_FW_LOADER_USER_HELPER_FALLBACK.
137
138Refer to do_firmware_uevent() for details of the kobject event variables
139setup. Variables passwdd with a kobject add event:
140
141* FIRMWARE=firmware name
142* TIMEOUT=timeout value
143* ASYNC=whether or not the API request was asynchronous
144
145By default DEVPATH is set by the internal kernel kobject infrastructure.
146Below is an example simple kobject uevent script::
147
148 # Both $DEVPATH and $FIRMWARE are already provided in the environment.
149 MY_FW_DIR=/lib/firmware/
150 echo 1 > /sys/$DEVPATH/loading
151 cat $MY_FW_DIR/$FIRMWARE > /sys/$DEVPATH/data
152 echo 0 > /sys/$DEVPATH/loading
153
154Firmware custom fallback mechanism
155==================================
156
157Users of the request_firmware_nowait() call have yet another option available
158at their disposal: rely on the sysfs fallback mechanism but request that no
159kobject uevents be issued to userspace. The original logic behind this
160was that utilities other than udev might be required to lookup firmware
161in non-traditional paths -- paths outside of the listing documented in the
162section 'Direct filesystem lookup'. This option is not available to any of
163the other API calls as uevents are always forced for them.
164
165Since uevents are only meaningful if the fallback mechanism is enabled
166in your kernel it would seem odd to enable uevents with kernels that do not
167have the fallback mechanism enabled in their kernels. Unfortunately we also
168rely on the uevent flag which can be disabled by request_firmware_nowait() to
169also setup the firmware cache for firmware requests. As documented above,
170the firmware cache is only set up if uevent is enabled for an API call.
171Although this can disable the firmware cache for request_firmware_nowait()
172calls, users of this API should not use it for the purposes of disabling
173the cache as that was not the original purpose of the flag. Not setting
174the uevent flag means you want to opt-in for the firmware fallback mechanism
175but you want to suppress kobject uevents, as you have a custom solution which
176will monitor for your device addition into the device hierarchy somehow and
177load firmware for you through a custom path.
178
179Firmware fallback timeout
180=========================
181
182The firmware fallback mechanism has a timeout. If firmware is not loaded
183onto the sysfs interface by the timeout value an error is sent to the
184driver. By default the timeout is set to 60 seconds if uevents are
185desirable, otherwise MAX_JIFFY_OFFSET is used (max timeout possible).
186The logic behind using MAX_JIFFY_OFFSET for non-uevents is that a custom
187solution will have as much time as it needs to load firmware.
188
189You can customize the firmware timeout by echo'ing your desired timeout into
190the following file:
191
192* /sys/class/firmware/timeout
193
194If you echo 0 into it means MAX_JIFFY_OFFSET will be used. The data type
195for the timeout is an int.
diff --git a/Documentation/driver-api/firmware/firmware_cache.rst b/Documentation/driver-api/firmware/firmware_cache.rst
new file mode 100644
index 000000000000..2210e5bfb332
--- /dev/null
+++ b/Documentation/driver-api/firmware/firmware_cache.rst
@@ -0,0 +1,51 @@
1==============
2Firmware cache
3==============
4
5When Linux resumes from suspend some device drivers require firmware lookups to
6re-initialize devices. During resume there may be a period of time during which
7firmware lookups are not possible, during this short period of time firmware
8requests will fail. Time is of essence though, and delaying drivers to wait for
9the root filesystem for firmware delays user experience with device
10functionality. In order to support these requirements the firmware
11infrastructure implements a firmware cache for device drivers for most API
12calls, automatically behind the scenes.
13
14The firmware cache makes using certain firmware API calls safe during a device
15driver's suspend and resume callback. Users of these API calls needn't cache
16the firmware by themselves for dealing with firmware loss during system resume.
17
18The firmware cache works by requesting for firmware prior to suspend and
19caching it in memory. Upon resume device drivers using the firmware API will
20have access to the firmware immediately, without having to wait for the root
21filesystem to mount or dealing with possible race issues with lookups as the
22root filesystem mounts.
23
24Some implementation details about the firmware cache setup:
25
26* The firmware cache is setup by adding a devres entry for each device that
27 uses all synchronous call except :c:func:`request_firmware_into_buf`.
28
29* If an asynchronous call is used the firmware cache is only set up for a
30 device if if the second argument (uevent) to request_firmware_nowait() is
31 true. When uevent is true it requests that a kobject uevent be sent to
32 userspace for the firmware request. For details refer to the Fackback
33 mechanism documented below.
34
35* If the firmware cache is determined to be needed as per the above two
36 criteria the firmware cache is setup by adding a devres entry for the
37 device making the firmware request.
38
39* The firmware devres entry is maintained throughout the lifetime of the
40 device. This means that even if you release_firmware() the firmware cache
41 will still be used on resume from suspend.
42
43* The timeout for the fallback mechanism is temporarily reduced to 10 seconds
44 as the firmware cache is set up during suspend, the timeout is set back to
45 the old value you had configured after the cache is set up.
46
47* Upon suspend any pending non-uevent firmware requests are killed to avoid
48 stalling the kernel, this is done with kill_requests_without_uevent(). Kernel
49 calls requiring the non-uevent therefore need to implement their own firmware
50 cache mechanism but must not use the firmware API on suspend.
51
diff --git a/Documentation/driver-api/firmware/fw_search_path.rst b/Documentation/driver-api/firmware/fw_search_path.rst
new file mode 100644
index 000000000000..a360f1009fa3
--- /dev/null
+++ b/Documentation/driver-api/firmware/fw_search_path.rst
@@ -0,0 +1,26 @@
1=====================
2Firmware search paths
3=====================
4
5The following search paths are used to look for firmware on your
6root filesystem.
7
8* fw_path_para - module parameter - default is empty so this is ignored
9* /lib/firmware/updates/UTS_RELEASE/
10* /lib/firmware/updates/
11* /lib/firmware/UTS_RELEASE/
12* /lib/firmware/
13
14The module parameter ''path'' can be passed to the firmware_class module
15to activate the first optional custom fw_path_para. The custom path can
16only be up to 256 characters long. The kernel parameter passed would be:
17
18* 'firmware_class.path=$CUSTOMIZED_PATH'
19
20There is an alternative to customize the path at run time after bootup, you
21can use the file:
22
23* /sys/module/firmware_class/parameters/path
24
25You would echo into it your custom path and firmware requested will be
26searched for there first.
diff --git a/Documentation/driver-api/firmware/index.rst b/Documentation/driver-api/firmware/index.rst
new file mode 100644
index 000000000000..1abe01793031
--- /dev/null
+++ b/Documentation/driver-api/firmware/index.rst
@@ -0,0 +1,16 @@
1==================
2Linux Firmware API
3==================
4
5.. toctree::
6
7 introduction
8 core
9 request_firmware
10
11.. only:: subproject and html
12
13 Indices
14 =======
15
16 * :ref:`genindex`
diff --git a/Documentation/driver-api/firmware/introduction.rst b/Documentation/driver-api/firmware/introduction.rst
new file mode 100644
index 000000000000..211cb44eb972
--- /dev/null
+++ b/Documentation/driver-api/firmware/introduction.rst
@@ -0,0 +1,27 @@
1============
2Introduction
3============
4
5The firmware API enables kernel code to request files required
6for functionality from userspace, the uses vary:
7
8* Microcode for CPU errata
9* Device driver firmware, required to be loaded onto device
10 microcontrollers
11* Device driver information data (calibration data, EEPROM overrides),
12 some of which can be completely optional.
13
14Types of firmware requests
15==========================
16
17There are two types of calls:
18
19* Synchronous
20* Asynchronous
21
22Which one you use vary depending on your requirements, the rule of thumb
23however is you should strive to use the asynchronous APIs unless you also
24are already using asynchronous initialization mechanisms which will not
25stall or delay boot. Even if loading firmware does not take a lot of time
26processing firmware might, and this can still delay boot or initialization,
27as such mechanisms such as asynchronous probe can help supplement drivers.
diff --git a/Documentation/driver-api/firmware/lookup-order.rst b/Documentation/driver-api/firmware/lookup-order.rst
new file mode 100644
index 000000000000..88c81739683c
--- /dev/null
+++ b/Documentation/driver-api/firmware/lookup-order.rst
@@ -0,0 +1,18 @@
1=====================
2Firmware lookup order
3=====================
4
5Different functionality is available to enable firmware to be found.
6Below is chronological order of how firmware will be looked for once
7a driver issues a firmware API call.
8
9* The ''Built-in firmware'' is checked first, if the firmware is present we
10 return it immediately
11* The ''Firmware cache'' is looked at next. If the firmware is found we
12 return it immediately
13* The ''Direct filesystem lookup'' is performed next, if found we
14 return it immediately
15* If no firmware has been found and the fallback mechanism was enabled
16 the sysfs interface is created. After this either a kobject uevent
17 is issued or the custom firmware loading is relied upon for firmware
18 loading up to the timeout value.
diff --git a/Documentation/driver-api/firmware/request_firmware.rst b/Documentation/driver-api/firmware/request_firmware.rst
new file mode 100644
index 000000000000..cc0aea880824
--- /dev/null
+++ b/Documentation/driver-api/firmware/request_firmware.rst
@@ -0,0 +1,56 @@
1====================
2request_firmware API
3====================
4
5You would typically load firmware and then load it into your device somehow.
6The typical firmware work flow is reflected below::
7
8 if(request_firmware(&fw_entry, $FIRMWARE, device) == 0)
9 copy_fw_to_device(fw_entry->data, fw_entry->size);
10 release_firmware(fw_entry);
11
12Synchronous firmware requests
13=============================
14
15Synchronous firmware requests will wait until the firmware is found or until
16an error is returned.
17
18request_firmware
19----------------
20.. kernel-doc:: drivers/base/firmware_class.c
21 :functions: request_firmware
22
23request_firmware_direct
24-----------------------
25.. kernel-doc:: drivers/base/firmware_class.c
26 :functions: request_firmware_direct
27
28request_firmware_into_buf
29-------------------------
30.. kernel-doc:: drivers/base/firmware_class.c
31 :functions: request_firmware_into_buf
32
33Asynchronous firmware requests
34==============================
35
36Asynchronous firmware requests allow driver code to not have to wait
37until the firmware or an error is returned. Function callbacks are
38provided so that when the firmware or an error is found the driver is
39informed through the callback. request_firmware_nowait() cannot be called
40in atomic contexts.
41
42request_firmware_nowait
43-----------------------
44.. kernel-doc:: drivers/base/firmware_class.c
45 :functions: request_firmware_nowait
46
47request firmware API expected driver use
48========================================
49
50Once an API call returns you process the firmware and then release the
51firmware. For example if you used request_firmware() and it returns,
52the driver has the firmware image accessible in fw_entry->{data,size}.
53If something went wrong request_firmware() returns non-zero and fw_entry
54is set to NULL. Once your driver is done with processing the firmware it
55can call call release_firmware(fw_entry) to release the firmware image
56and any related resource.
diff --git a/Documentation/driver-api/iio/buffers.rst b/Documentation/driver-api/iio/buffers.rst
new file mode 100644
index 000000000000..02c99a6bee18
--- /dev/null
+++ b/Documentation/driver-api/iio/buffers.rst
@@ -0,0 +1,125 @@
1=======
2Buffers
3=======
4
5* struct :c:type:`iio_buffer` — general buffer structure
6* :c:func:`iio_validate_scan_mask_onehot` — Validates that exactly one channel
7 is selected
8* :c:func:`iio_buffer_get` — Grab a reference to the buffer
9* :c:func:`iio_buffer_put` — Release the reference to the buffer
10
11The Industrial I/O core offers a way for continuous data capture based on a
12trigger source. Multiple data channels can be read at once from
13:file:`/dev/iio:device{X}` character device node, thus reducing the CPU load.
14
15IIO buffer sysfs interface
16==========================
17An IIO buffer has an associated attributes directory under
18:file:`/sys/bus/iio/iio:device{X}/buffer/*`. Here are some of the existing
19attributes:
20
21* :file:`length`, the total number of data samples (capacity) that can be
22 stored by the buffer.
23* :file:`enable`, activate buffer capture.
24
25IIO buffer setup
26================
27
28The meta information associated with a channel reading placed in a buffer is
29called a scan element . The important bits configuring scan elements are
30exposed to userspace applications via the
31:file:`/sys/bus/iio/iio:device{X}/scan_elements/*` directory. This file contains
32attributes of the following form:
33
34* :file:`enable`, used for enabling a channel. If and only if its attribute
35 is non *zero*, then a triggered capture will contain data samples for this
36 channel.
37* :file:`type`, description of the scan element data storage within the buffer
38 and hence the form in which it is read from user space.
39 Format is [be|le]:[s|u]bits/storagebitsXrepeat[>>shift] .
40 * *be* or *le*, specifies big or little endian.
41 * *s* or *u*, specifies if signed (2's complement) or unsigned.
42 * *bits*, is the number of valid data bits.
43 * *storagebits*, is the number of bits (after padding) that it occupies in the
44 buffer.
45 * *shift*, if specified, is the shift that needs to be applied prior to
46 masking out unused bits.
47 * *repeat*, specifies the number of bits/storagebits repetitions. When the
48 repeat element is 0 or 1, then the repeat value is omitted.
49
50For example, a driver for a 3-axis accelerometer with 12 bit resolution where
51data is stored in two 8-bits registers as follows::
52
53 7 6 5 4 3 2 1 0
54 +---+---+---+---+---+---+---+---+
55 |D3 |D2 |D1 |D0 | X | X | X | X | (LOW byte, address 0x06)
56 +---+---+---+---+---+---+---+---+
57
58 7 6 5 4 3 2 1 0
59 +---+---+---+---+---+---+---+---+
60 |D11|D10|D9 |D8 |D7 |D6 |D5 |D4 | (HIGH byte, address 0x07)
61 +---+---+---+---+---+---+---+---+
62
63will have the following scan element type for each axis::
64
65 $ cat /sys/bus/iio/devices/iio:device0/scan_elements/in_accel_y_type
66 le:s12/16>>4
67
68A user space application will interpret data samples read from the buffer as
69two byte little endian signed data, that needs a 4 bits right shift before
70masking out the 12 valid bits of data.
71
72For implementing buffer support a driver should initialize the following
73fields in iio_chan_spec definition::
74
75 struct iio_chan_spec {
76 /* other members */
77 int scan_index
78 struct {
79 char sign;
80 u8 realbits;
81 u8 storagebits;
82 u8 shift;
83 u8 repeat;
84 enum iio_endian endianness;
85 } scan_type;
86 };
87
88The driver implementing the accelerometer described above will have the
89following channel definition::
90
91 struct struct iio_chan_spec accel_channels[] = {
92 {
93 .type = IIO_ACCEL,
94 .modified = 1,
95 .channel2 = IIO_MOD_X,
96 /* other stuff here */
97 .scan_index = 0,
98 .scan_type = {
99 .sign = 's',
100 .realbits = 12,
101 .storagebits = 16,
102 .shift = 4,
103 .endianness = IIO_LE,
104 },
105 }
106 /* similar for Y (with channel2 = IIO_MOD_Y, scan_index = 1)
107 * and Z (with channel2 = IIO_MOD_Z, scan_index = 2) axis
108 */
109 }
110
111Here **scan_index** defines the order in which the enabled channels are placed
112inside the buffer. Channels with a lower **scan_index** will be placed before
113channels with a higher index. Each channel needs to have a unique
114**scan_index**.
115
116Setting **scan_index** to -1 can be used to indicate that the specific channel
117does not support buffered capture. In this case no entries will be created for
118the channel in the scan_elements directory.
119
120More details
121============
122.. kernel-doc:: include/linux/iio/buffer.h
123.. kernel-doc:: drivers/iio/industrialio-buffer.c
124 :export:
125
diff --git a/Documentation/driver-api/iio/core.rst b/Documentation/driver-api/iio/core.rst
new file mode 100644
index 000000000000..9a34ae03b679
--- /dev/null
+++ b/Documentation/driver-api/iio/core.rst
@@ -0,0 +1,182 @@
1=============
2Core elements
3=============
4
5The Industrial I/O core offers a unified framework for writing drivers for
6many different types of embedded sensors. a standard interface to user space
7applications manipulating sensors. The implementation can be found under
8:file:`drivers/iio/industrialio-*`
9
10Industrial I/O Devices
11----------------------
12
13* struct :c:type:`iio_dev` - industrial I/O device
14* :c:func:`iio_device_alloc()` - alocate an :c:type:`iio_dev` from a driver
15* :c:func:`iio_device_free()` - free an :c:type:`iio_dev` from a driver
16* :c:func:`iio_device_register()` - register a device with the IIO subsystem
17* :c:func:`iio_device_unregister()` - unregister a device from the IIO
18 subsystem
19
20An IIO device usually corresponds to a single hardware sensor and it
21provides all the information needed by a driver handling a device.
22Let's first have a look at the functionality embedded in an IIO device
23then we will show how a device driver makes use of an IIO device.
24
25There are two ways for a user space application to interact with an IIO driver.
26
271. :file:`/sys/bus/iio/iio:device{X}/`, this represents a hardware sensor
28 and groups together the data channels of the same chip.
292. :file:`/dev/iio:device{X}`, character device node interface used for
30 buffered data transfer and for events information retrieval.
31
32A typical IIO driver will register itself as an :doc:`I2C <../i2c>` or
33:doc:`SPI <../spi>` driver and will create two routines, probe and remove.
34
35At probe:
36
371. Call :c:func:`iio_device_alloc()`, which allocates memory for an IIO device.
382. Initialize IIO device fields with driver specific information (e.g.
39 device name, device channels).
403. Call :c:func:`iio_device_register()`, this registers the device with the
41 IIO core. After this call the device is ready to accept requests from user
42 space applications.
43
44At remove, we free the resources allocated in probe in reverse order:
45
461. :c:func:`iio_device_unregister()`, unregister the device from the IIO core.
472. :c:func:`iio_device_free()`, free the memory allocated for the IIO device.
48
49IIO device sysfs interface
50==========================
51
52Attributes are sysfs files used to expose chip info and also allowing
53applications to set various configuration parameters. For device with
54index X, attributes can be found under /sys/bus/iio/iio:deviceX/ directory.
55Common attributes are:
56
57* :file:`name`, description of the physical chip.
58* :file:`dev`, shows the major:minor pair associated with
59 :file:`/dev/iio:deviceX` node.
60* :file:`sampling_frequency_available`, available discrete set of sampling
61 frequency values for device.
62* Available standard attributes for IIO devices are described in the
63 :file:`Documentation/ABI/testing/sysfs-bus-iio` file in the Linux kernel
64 sources.
65
66IIO device channels
67===================
68
69struct :c:type:`iio_chan_spec` - specification of a single channel
70
71An IIO device channel is a representation of a data channel. An IIO device can
72have one or multiple channels. For example:
73
74* a thermometer sensor has one channel representing the temperature measurement.
75* a light sensor with two channels indicating the measurements in the visible
76 and infrared spectrum.
77* an accelerometer can have up to 3 channels representing acceleration on X, Y
78 and Z axes.
79
80An IIO channel is described by the struct :c:type:`iio_chan_spec`.
81A thermometer driver for the temperature sensor in the example above would
82have to describe its channel as follows::
83
84 static const struct iio_chan_spec temp_channel[] = {
85 {
86 .type = IIO_TEMP,
87 .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
88 },
89 };
90
91Channel sysfs attributes exposed to userspace are specified in the form of
92bitmasks. Depending on their shared info, attributes can be set in one of the
93following masks:
94
95* **info_mask_separate**, attributes will be specific to
96 this channel
97* **info_mask_shared_by_type**, attributes are shared by all channels of the
98 same type
99* **info_mask_shared_by_dir**, attributes are shared by all channels of the same
100 direction
101* **info_mask_shared_by_all**, attributes are shared by all channels
102
103When there are multiple data channels per channel type we have two ways to
104distinguish between them:
105
106* set **.modified** field of :c:type:`iio_chan_spec` to 1. Modifiers are
107 specified using **.channel2** field of the same :c:type:`iio_chan_spec`
108 structure and are used to indicate a physically unique characteristic of the
109 channel such as its direction or spectral response. For example, a light
110 sensor can have two channels, one for infrared light and one for both
111 infrared and visible light.
112* set **.indexed** field of :c:type:`iio_chan_spec` to 1. In this case the
113 channel is simply another instance with an index specified by the **.channel**
114 field.
115
116Here is how we can make use of the channel's modifiers::
117
118 static const struct iio_chan_spec light_channels[] = {
119 {
120 .type = IIO_INTENSITY,
121 .modified = 1,
122 .channel2 = IIO_MOD_LIGHT_IR,
123 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
124 .info_mask_shared = BIT(IIO_CHAN_INFO_SAMP_FREQ),
125 },
126 {
127 .type = IIO_INTENSITY,
128 .modified = 1,
129 .channel2 = IIO_MOD_LIGHT_BOTH,
130 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
131 .info_mask_shared = BIT(IIO_CHAN_INFO_SAMP_FREQ),
132 },
133 {
134 .type = IIO_LIGHT,
135 .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
136 .info_mask_shared = BIT(IIO_CHAN_INFO_SAMP_FREQ),
137 },
138 }
139
140This channel's definition will generate two separate sysfs files for raw data
141retrieval:
142
143* :file:`/sys/bus/iio/iio:device{X}/in_intensity_ir_raw`
144* :file:`/sys/bus/iio/iio:device{X}/in_intensity_both_raw`
145
146one file for processed data:
147
148* :file:`/sys/bus/iio/iio:device{X}/in_illuminance_input`
149
150and one shared sysfs file for sampling frequency:
151
152* :file:`/sys/bus/iio/iio:device{X}/sampling_frequency`.
153
154Here is how we can make use of the channel's indexing::
155
156 static const struct iio_chan_spec light_channels[] = {
157 {
158 .type = IIO_VOLTAGE,
159 .indexed = 1,
160 .channel = 0,
161 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
162 },
163 {
164 .type = IIO_VOLTAGE,
165 .indexed = 1,
166 .channel = 1,
167 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
168 },
169 }
170
171This will generate two separate attributes files for raw data retrieval:
172
173* :file:`/sys/bus/iio/devices/iio:device{X}/in_voltage0_raw`, representing
174 voltage measurement for channel 0.
175* :file:`/sys/bus/iio/devices/iio:device{X}/in_voltage1_raw`, representing
176 voltage measurement for channel 1.
177
178More details
179============
180.. kernel-doc:: include/linux/iio/iio.h
181.. kernel-doc:: drivers/iio/industrialio-core.c
182 :export:
diff --git a/Documentation/driver-api/iio/index.rst b/Documentation/driver-api/iio/index.rst
new file mode 100644
index 000000000000..e5c3922d1b6f
--- /dev/null
+++ b/Documentation/driver-api/iio/index.rst
@@ -0,0 +1,17 @@
1.. include:: <isonum.txt>
2
3Industrial I/O
4==============
5
6**Copyright** |copy| 2015 Intel Corporation
7
8Contents:
9
10.. toctree::
11 :maxdepth: 2
12
13 intro
14 core
15 buffers
16 triggers
17 triggered-buffers
diff --git a/Documentation/driver-api/iio/intro.rst b/Documentation/driver-api/iio/intro.rst
new file mode 100644
index 000000000000..3653fbd57069
--- /dev/null
+++ b/Documentation/driver-api/iio/intro.rst
@@ -0,0 +1,33 @@
1.. include:: <isonum.txt>
2
3============
4Introduction
5============
6
7The main purpose of the Industrial I/O subsystem (IIO) is to provide support
8for devices that in some sense perform either
9analog-to-digital conversion (ADC) or digital-to-analog conversion (DAC)
10or both. The aim is to fill the gap between the somewhat similar hwmon and
11:doc:`input <../input>` subsystems. Hwmon is directed at low sample rate
12sensors used to monitor and control the system itself, like fan speed control
13or temperature measurement. :doc:`Input <../input>` is, as its name suggests,
14focused on human interaction input devices (keyboard, mouse, touchscreen).
15In some cases there is considerable overlap between these and IIO.
16
17Devices that fall into this category include:
18
19* analog to digital converters (ADCs)
20* accelerometers
21* capacitance to digital converters (CDCs)
22* digital to analog converters (DACs)
23* gyroscopes
24* inertial measurement units (IMUs)
25* color and light sensors
26* magnetometers
27* pressure sensors
28* proximity sensors
29* temperature sensors
30
31Usually these sensors are connected via :doc:`SPI <../spi>` or
32:doc:`I2C <../i2c>`. A common use case of the sensors devices is to have
33combined functionality (e.g. light plus proximity sensor).
diff --git a/Documentation/driver-api/iio/triggered-buffers.rst b/Documentation/driver-api/iio/triggered-buffers.rst
new file mode 100644
index 000000000000..0db12660cc90
--- /dev/null
+++ b/Documentation/driver-api/iio/triggered-buffers.rst
@@ -0,0 +1,69 @@
1=================
2Triggered Buffers
3=================
4
5Now that we know what buffers and triggers are let's see how they work together.
6
7IIO triggered buffer setup
8==========================
9
10* :c:func:`iio_triggered_buffer_setup` — Setup triggered buffer and pollfunc
11* :c:func:`iio_triggered_buffer_cleanup` — Free resources allocated by
12 :c:func:`iio_triggered_buffer_setup`
13* struct :c:type:`iio_buffer_setup_ops` — buffer setup related callbacks
14
15A typical triggered buffer setup looks like this::
16
17 const struct iio_buffer_setup_ops sensor_buffer_setup_ops = {
18 .preenable = sensor_buffer_preenable,
19 .postenable = sensor_buffer_postenable,
20 .postdisable = sensor_buffer_postdisable,
21 .predisable = sensor_buffer_predisable,
22 };
23
24 irqreturn_t sensor_iio_pollfunc(int irq, void *p)
25 {
26 pf->timestamp = iio_get_time_ns((struct indio_dev *)p);
27 return IRQ_WAKE_THREAD;
28 }
29
30 irqreturn_t sensor_trigger_handler(int irq, void *p)
31 {
32 u16 buf[8];
33 int i = 0;
34
35 /* read data for each active channel */
36 for_each_set_bit(bit, active_scan_mask, masklength)
37 buf[i++] = sensor_get_data(bit)
38
39 iio_push_to_buffers_with_timestamp(indio_dev, buf, timestamp);
40
41 iio_trigger_notify_done(trigger);
42 return IRQ_HANDLED;
43 }
44
45 /* setup triggered buffer, usually in probe function */
46 iio_triggered_buffer_setup(indio_dev, sensor_iio_polfunc,
47 sensor_trigger_handler,
48 sensor_buffer_setup_ops);
49
50The important things to notice here are:
51
52* :c:type:`iio_buffer_setup_ops`, the buffer setup functions to be called at
53 predefined points in the buffer configuration sequence (e.g. before enable,
54 after disable). If not specified, the IIO core uses the default
55 iio_triggered_buffer_setup_ops.
56* **sensor_iio_pollfunc**, the function that will be used as top half of poll
57 function. It should do as little processing as possible, because it runs in
58 interrupt context. The most common operation is recording of the current
59 timestamp and for this reason one can use the IIO core defined
60 :c:func:`iio_pollfunc_store_time` function.
61* **sensor_trigger_handler**, the function that will be used as bottom half of
62 the poll function. This runs in the context of a kernel thread and all the
63 processing takes place here. It usually reads data from the device and
64 stores it in the internal buffer together with the timestamp recorded in the
65 top half.
66
67More details
68============
69.. kernel-doc:: drivers/iio/buffer/industrialio-triggered-buffer.c
diff --git a/Documentation/driver-api/iio/triggers.rst b/Documentation/driver-api/iio/triggers.rst
new file mode 100644
index 000000000000..f89d37e7dd82
--- /dev/null
+++ b/Documentation/driver-api/iio/triggers.rst
@@ -0,0 +1,80 @@
1========
2Triggers
3========
4
5* struct :c:type:`iio_trigger` — industrial I/O trigger device
6* :c:func:`devm_iio_trigger_alloc` — Resource-managed iio_trigger_alloc
7* :c:func:`devm_iio_trigger_free` — Resource-managed iio_trigger_free
8* :c:func:`devm_iio_trigger_register` — Resource-managed iio_trigger_register
9* :c:func:`devm_iio_trigger_unregister` — Resource-managed
10 iio_trigger_unregister
11* :c:func:`iio_trigger_validate_own_device` — Check if a trigger and IIO
12 device belong to the same device
13
14In many situations it is useful for a driver to be able to capture data based
15on some external event (trigger) as opposed to periodically polling for data.
16An IIO trigger can be provided by a device driver that also has an IIO device
17based on hardware generated events (e.g. data ready or threshold exceeded) or
18provided by a separate driver from an independent interrupt source (e.g. GPIO
19line connected to some external system, timer interrupt or user space writing
20a specific file in sysfs). A trigger may initiate data capture for a number of
21sensors and also it may be completely unrelated to the sensor itself.
22
23IIO trigger sysfs interface
24===========================
25
26There are two locations in sysfs related to triggers:
27
28* :file:`/sys/bus/iio/devices/trigger{Y}/*`, this file is created once an
29 IIO trigger is registered with the IIO core and corresponds to trigger
30 with index Y.
31 Because triggers can be very different depending on type there are few
32 standard attributes that we can describe here:
33
34 * :file:`name`, trigger name that can be later used for association with a
35 device.
36 * :file:`sampling_frequency`, some timer based triggers use this attribute to
37 specify the frequency for trigger calls.
38
39* :file:`/sys/bus/iio/devices/iio:device{X}/trigger/*`, this directory is
40 created once the device supports a triggered buffer. We can associate a
41 trigger with our device by writing the trigger's name in the
42 :file:`current_trigger` file.
43
44IIO trigger setup
45=================
46
47Let's see a simple example of how to setup a trigger to be used by a driver::
48
49 struct iio_trigger_ops trigger_ops = {
50 .set_trigger_state = sample_trigger_state,
51 .validate_device = sample_validate_device,
52 }
53
54 struct iio_trigger *trig;
55
56 /* first, allocate memory for our trigger */
57 trig = iio_trigger_alloc(dev, "trig-%s-%d", name, idx);
58
59 /* setup trigger operations field */
60 trig->ops = &trigger_ops;
61
62 /* now register the trigger with the IIO core */
63 iio_trigger_register(trig);
64
65IIO trigger ops
66===============
67
68* struct :c:type:`iio_trigger_ops` — operations structure for an iio_trigger.
69
70Notice that a trigger has a set of operations attached:
71
72* :file:`set_trigger_state`, switch the trigger on/off on demand.
73* :file:`validate_device`, function to validate the device when the current
74 trigger gets changed.
75
76More details
77============
78.. kernel-doc:: include/linux/iio/trigger.h
79.. kernel-doc:: drivers/iio/industrialio-trigger.c
80 :export:
diff --git a/Documentation/driver-api/index.rst b/Documentation/driver-api/index.rst
index 5475a2807e7a..60db00d1532b 100644
--- a/Documentation/driver-api/index.rst
+++ b/Documentation/driver-api/index.rst
@@ -16,11 +16,15 @@ available subsections can be seen below.
16 16
17 basics 17 basics
18 infrastructure 18 infrastructure
19 pm/index
20 device-io
19 dma-buf 21 dma-buf
20 device_link 22 device_link
21 message-based 23 message-based
22 sound 24 sound
23 frame-buffer 25 frame-buffer
26 regulator
27 iio/index
24 input 28 input
25 usb 29 usb
26 spi 30 spi
@@ -30,6 +34,8 @@ available subsections can be seen below.
30 miscellaneous 34 miscellaneous
31 vme 35 vme
32 80211/index 36 80211/index
37 uio-howto
38 firmware/index
33 39
34.. only:: subproject and html 40.. only:: subproject and html
35 41
diff --git a/Documentation/driver-api/pm/conf.py b/Documentation/driver-api/pm/conf.py
new file mode 100644
index 000000000000..a89fac11272f
--- /dev/null
+++ b/Documentation/driver-api/pm/conf.py
@@ -0,0 +1,10 @@
1# -*- coding: utf-8; mode: python -*-
2
3project = "Device Power Management"
4
5tags.add("subproject")
6
7latex_documents = [
8 ('index', 'pm.tex', project,
9 'The kernel development community', 'manual'),
10]
diff --git a/Documentation/driver-api/pm/devices.rst b/Documentation/driver-api/pm/devices.rst
new file mode 100644
index 000000000000..bedd32388dac
--- /dev/null
+++ b/Documentation/driver-api/pm/devices.rst
@@ -0,0 +1,736 @@
1.. |struct dev_pm_ops| replace:: :c:type:`struct dev_pm_ops <dev_pm_ops>`
2.. |struct dev_pm_domain| replace:: :c:type:`struct dev_pm_domain <dev_pm_domain>`
3.. |struct bus_type| replace:: :c:type:`struct bus_type <bus_type>`
4.. |struct device_type| replace:: :c:type:`struct device_type <device_type>`
5.. |struct class| replace:: :c:type:`struct class <class>`
6.. |struct wakeup_source| replace:: :c:type:`struct wakeup_source <wakeup_source>`
7.. |struct device| replace:: :c:type:`struct device <device>`
8
9==============================
10Device Power Management Basics
11==============================
12
13::
14
15 Copyright (c) 2010-2011 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc.
16 Copyright (c) 2010 Alan Stern <stern@rowland.harvard.edu>
17 Copyright (c) 2016 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com>
18
19Most of the code in Linux is device drivers, so most of the Linux power
20management (PM) code is also driver-specific. Most drivers will do very
21little; others, especially for platforms with small batteries (like cell
22phones), will do a lot.
23
24This writeup gives an overview of how drivers interact with system-wide
25power management goals, emphasizing the models and interfaces that are
26shared by everything that hooks up to the driver model core. Read it as
27background for the domain-specific work you'd do with any specific driver.
28
29
30Two Models for Device Power Management
31======================================
32
33Drivers will use one or both of these models to put devices into low-power
34states:
35
36 System Sleep model:
37
38 Drivers can enter low-power states as part of entering system-wide
39 low-power states like "suspend" (also known as "suspend-to-RAM"), or
40 (mostly for systems with disks) "hibernation" (also known as
41 "suspend-to-disk").
42
43 This is something that device, bus, and class drivers collaborate on
44 by implementing various role-specific suspend and resume methods to
45 cleanly power down hardware and software subsystems, then reactivate
46 them without loss of data.
47
48 Some drivers can manage hardware wakeup events, which make the system
49 leave the low-power state. This feature may be enabled or disabled
50 using the relevant :file:`/sys/devices/.../power/wakeup` file (for
51 Ethernet drivers the ioctl interface used by ethtool may also be used
52 for this purpose); enabling it may cost some power usage, but let the
53 whole system enter low-power states more often.
54
55 Runtime Power Management model:
56
57 Devices may also be put into low-power states while the system is
58 running, independently of other power management activity in principle.
59 However, devices are not generally independent of each other (for
60 example, a parent device cannot be suspended unless all of its child
61 devices have been suspended). Moreover, depending on the bus type the
62 device is on, it may be necessary to carry out some bus-specific
63 operations on the device for this purpose. Devices put into low power
64 states at run time may require special handling during system-wide power
65 transitions (suspend or hibernation).
66
67 For these reasons not only the device driver itself, but also the
68 appropriate subsystem (bus type, device type or device class) driver and
69 the PM core are involved in runtime power management. As in the system
70 sleep power management case, they need to collaborate by implementing
71 various role-specific suspend and resume methods, so that the hardware
72 is cleanly powered down and reactivated without data or service loss.
73
74There's not a lot to be said about those low-power states except that they are
75very system-specific, and often device-specific. Also, that if enough devices
76have been put into low-power states (at runtime), the effect may be very similar
77to entering some system-wide low-power state (system sleep) ... and that
78synergies exist, so that several drivers using runtime PM might put the system
79into a state where even deeper power saving options are available.
80
81Most suspended devices will have quiesced all I/O: no more DMA or IRQs (except
82for wakeup events), no more data read or written, and requests from upstream
83drivers are no longer accepted. A given bus or platform may have different
84requirements though.
85
86Examples of hardware wakeup events include an alarm from a real time clock,
87network wake-on-LAN packets, keyboard or mouse activity, and media insertion
88or removal (for PCMCIA, MMC/SD, USB, and so on).
89
90Interfaces for Entering System Sleep States
91===========================================
92
93There are programming interfaces provided for subsystems (bus type, device type,
94device class) and device drivers to allow them to participate in the power
95management of devices they are concerned with. These interfaces cover both
96system sleep and runtime power management.
97
98
99Device Power Management Operations
100----------------------------------
101
102Device power management operations, at the subsystem level as well as at the
103device driver level, are implemented by defining and populating objects of type
104|struct dev_pm_ops| defined in :file:`include/linux/pm.h`. The roles of the
105methods included in it will be explained in what follows. For now, it should be
106sufficient to remember that the last three methods are specific to runtime power
107management while the remaining ones are used during system-wide power
108transitions.
109
110There also is a deprecated "old" or "legacy" interface for power management
111operations available at least for some subsystems. This approach does not use
112|struct dev_pm_ops| objects and it is suitable only for implementing system
113sleep power management methods in a limited way. Therefore it is not described
114in this document, so please refer directly to the source code for more
115information about it.
116
117
118Subsystem-Level Methods
119-----------------------
120
121The core methods to suspend and resume devices reside in
122|struct dev_pm_ops| pointed to by the :c:member:`ops` member of
123|struct dev_pm_domain|, or by the :c:member:`pm` member of |struct bus_type|,
124|struct device_type| and |struct class|. They are mostly of interest to the
125people writing infrastructure for platforms and buses, like PCI or USB, or
126device type and device class drivers. They also are relevant to the writers of
127device drivers whose subsystems (PM domains, device types, device classes and
128bus types) don't provide all power management methods.
129
130Bus drivers implement these methods as appropriate for the hardware and the
131drivers using it; PCI works differently from USB, and so on. Not many people
132write subsystem-level drivers; most driver code is a "device driver" that builds
133on top of bus-specific framework code.
134
135For more information on these driver calls, see the description later;
136they are called in phases for every device, respecting the parent-child
137sequencing in the driver model tree.
138
139
140:file:`/sys/devices/.../power/wakeup` files
141-------------------------------------------
142
143All device objects in the driver model contain fields that control the handling
144of system wakeup events (hardware signals that can force the system out of a
145sleep state). These fields are initialized by bus or device driver code using
146:c:func:`device_set_wakeup_capable()` and :c:func:`device_set_wakeup_enable()`,
147defined in :file:`include/linux/pm_wakeup.h`.
148
149The :c:member:`power.can_wakeup` flag just records whether the device (and its
150driver) can physically support wakeup events. The
151:c:func:`device_set_wakeup_capable()` routine affects this flag. The
152:c:member:`power.wakeup` field is a pointer to an object of type
153|struct wakeup_source| used for controlling whether or not the device should use
154its system wakeup mechanism and for notifying the PM core of system wakeup
155events signaled by the device. This object is only present for wakeup-capable
156devices (i.e. devices whose :c:member:`can_wakeup` flags are set) and is created
157(or removed) by :c:func:`device_set_wakeup_capable()`.
158
159Whether or not a device is capable of issuing wakeup events is a hardware
160matter, and the kernel is responsible for keeping track of it. By contrast,
161whether or not a wakeup-capable device should issue wakeup events is a policy
162decision, and it is managed by user space through a sysfs attribute: the
163:file:`power/wakeup` file. User space can write the "enabled" or "disabled"
164strings to it to indicate whether or not, respectively, the device is supposed
165to signal system wakeup. This file is only present if the
166:c:member:`power.wakeup` object exists for the given device and is created (or
167removed) along with that object, by :c:func:`device_set_wakeup_capable()`.
168Reads from the file will return the corresponding string.
169
170The initial value in the :file:`power/wakeup` file is "disabled" for the
171majority of devices; the major exceptions are power buttons, keyboards, and
172Ethernet adapters whose WoL (wake-on-LAN) feature has been set up with ethtool.
173It should also default to "enabled" for devices that don't generate wakeup
174requests on their own but merely forward wakeup requests from one bus to another
175(like PCI Express ports).
176
177The :c:func:`device_may_wakeup()` routine returns true only if the
178:c:member:`power.wakeup` object exists and the corresponding :file:`power/wakeup`
179file contains the "enabled" string. This information is used by subsystems,
180like the PCI bus type code, to see whether or not to enable the devices' wakeup
181mechanisms. If device wakeup mechanisms are enabled or disabled directly by
182drivers, they also should use :c:func:`device_may_wakeup()` to decide what to do
183during a system sleep transition. Device drivers, however, are not expected to
184call :c:func:`device_set_wakeup_enable()` directly in any case.
185
186It ought to be noted that system wakeup is conceptually different from "remote
187wakeup" used by runtime power management, although it may be supported by the
188same physical mechanism. Remote wakeup is a feature allowing devices in
189low-power states to trigger specific interrupts to signal conditions in which
190they should be put into the full-power state. Those interrupts may or may not
191be used to signal system wakeup events, depending on the hardware design. On
192some systems it is impossible to trigger them from system sleep states. In any
193case, remote wakeup should always be enabled for runtime power management for
194all devices and drivers that support it.
195
196
197:file:`/sys/devices/.../power/control` files
198--------------------------------------------
199
200Each device in the driver model has a flag to control whether it is subject to
201runtime power management. This flag, :c:member:`runtime_auto`, is initialized
202by the bus type (or generally subsystem) code using :c:func:`pm_runtime_allow()`
203or :c:func:`pm_runtime_forbid()`; the default is to allow runtime power
204management.
205
206The setting can be adjusted by user space by writing either "on" or "auto" to
207the device's :file:`power/control` sysfs file. Writing "auto" calls
208:c:func:`pm_runtime_allow()`, setting the flag and allowing the device to be
209runtime power-managed by its driver. Writing "on" calls
210:c:func:`pm_runtime_forbid()`, clearing the flag, returning the device to full
211power if it was in a low-power state, and preventing the
212device from being runtime power-managed. User space can check the current value
213of the :c:member:`runtime_auto` flag by reading that file.
214
215The device's :c:member:`runtime_auto` flag has no effect on the handling of
216system-wide power transitions. In particular, the device can (and in the
217majority of cases should and will) be put into a low-power state during a
218system-wide transition to a sleep state even though its :c:member:`runtime_auto`
219flag is clear.
220
221For more information about the runtime power management framework, refer to
222:file:`Documentation/power/runtime_pm.txt`.
223
224
225Calling Drivers to Enter and Leave System Sleep States
226======================================================
227
228When the system goes into a sleep state, each device's driver is asked to
229suspend the device by putting it into a state compatible with the target
230system state. That's usually some version of "off", but the details are
231system-specific. Also, wakeup-enabled devices will usually stay partly
232functional in order to wake the system.
233
234When the system leaves that low-power state, the device's driver is asked to
235resume it by returning it to full power. The suspend and resume operations
236always go together, and both are multi-phase operations.
237
238For simple drivers, suspend might quiesce the device using class code
239and then turn its hardware as "off" as possible during suspend_noirq. The
240matching resume calls would then completely reinitialize the hardware
241before reactivating its class I/O queues.
242
243More power-aware drivers might prepare the devices for triggering system wakeup
244events.
245
246
247Call Sequence Guarantees
248------------------------
249
250To ensure that bridges and similar links needing to talk to a device are
251available when the device is suspended or resumed, the device hierarchy is
252walked in a bottom-up order to suspend devices. A top-down order is
253used to resume those devices.
254
255The ordering of the device hierarchy is defined by the order in which devices
256get registered: a child can never be registered, probed or resumed before
257its parent; and can't be removed or suspended after that parent.
258
259The policy is that the device hierarchy should match hardware bus topology.
260[Or at least the control bus, for devices which use multiple busses.]
261In particular, this means that a device registration may fail if the parent of
262the device is suspending (i.e. has been chosen by the PM core as the next
263device to suspend) or has already suspended, as well as after all of the other
264devices have been suspended. Device drivers must be prepared to cope with such
265situations.
266
267
268System Power Management Phases
269------------------------------
270
271Suspending or resuming the system is done in several phases. Different phases
272are used for suspend-to-idle, shallow (standby), and deep ("suspend-to-RAM")
273sleep states and the hibernation state ("suspend-to-disk"). Each phase involves
274executing callbacks for every device before the next phase begins. Not all
275buses or classes support all these callbacks and not all drivers use all the
276callbacks. The various phases always run after tasks have been frozen and
277before they are unfrozen. Furthermore, the ``*_noirq phases`` run at a time
278when IRQ handlers have been disabled (except for those marked with the
279IRQF_NO_SUSPEND flag).
280
281All phases use PM domain, bus, type, class or driver callbacks (that is, methods
282defined in ``dev->pm_domain->ops``, ``dev->bus->pm``, ``dev->type->pm``,
283``dev->class->pm`` or ``dev->driver->pm``). These callbacks are regarded by the
284PM core as mutually exclusive. Moreover, PM domain callbacks always take
285precedence over all of the other callbacks and, for example, type callbacks take
286precedence over bus, class and driver callbacks. To be precise, the following
287rules are used to determine which callback to execute in the given phase:
288
289 1. If ``dev->pm_domain`` is present, the PM core will choose the callback
290 provided by ``dev->pm_domain->ops`` for execution.
291
292 2. Otherwise, if both ``dev->type`` and ``dev->type->pm`` are present, the
293 callback provided by ``dev->type->pm`` will be chosen for execution.
294
295 3. Otherwise, if both ``dev->class`` and ``dev->class->pm`` are present,
296 the callback provided by ``dev->class->pm`` will be chosen for
297 execution.
298
299 4. Otherwise, if both ``dev->bus`` and ``dev->bus->pm`` are present, the
300 callback provided by ``dev->bus->pm`` will be chosen for execution.
301
302This allows PM domains and device types to override callbacks provided by bus
303types or device classes if necessary.
304
305The PM domain, type, class and bus callbacks may in turn invoke device- or
306driver-specific methods stored in ``dev->driver->pm``, but they don't have to do
307that.
308
309If the subsystem callback chosen for execution is not present, the PM core will
310execute the corresponding method from the ``dev->driver->pm`` set instead if
311there is one.
312
313
314Entering System Suspend
315-----------------------
316
317When the system goes into the freeze, standby or memory sleep state,
318the phases are: ``prepare``, ``suspend``, ``suspend_late``, ``suspend_noirq``.
319
320 1. The ``prepare`` phase is meant to prevent races by preventing new
321 devices from being registered; the PM core would never know that all the
322 children of a device had been suspended if new children could be
323 registered at will. [By contrast, from the PM core's perspective,
324 devices may be unregistered at any time.] Unlike the other
325 suspend-related phases, during the ``prepare`` phase the device
326 hierarchy is traversed top-down.
327
328 After the ``->prepare`` callback method returns, no new children may be
329 registered below the device. The method may also prepare the device or
330 driver in some way for the upcoming system power transition, but it
331 should not put the device into a low-power state.
332
333 For devices supporting runtime power management, the return value of the
334 prepare callback can be used to indicate to the PM core that it may
335 safely leave the device in runtime suspend (if runtime-suspended
336 already), provided that all of the device's descendants are also left in
337 runtime suspend. Namely, if the prepare callback returns a positive
338 number and that happens for all of the descendants of the device too,
339 and all of them (including the device itself) are runtime-suspended, the
340 PM core will skip the ``suspend``, ``suspend_late`` and
341 ``suspend_noirq`` phases as well as all of the corresponding phases of
342 the subsequent device resume for all of these devices. In that case,
343 the ``->complete`` callback will be invoked directly after the
344 ``->prepare`` callback and is entirely responsible for putting the
345 device into a consistent state as appropriate.
346
347 Note that this direct-complete procedure applies even if the device is
348 disabled for runtime PM; only the runtime-PM status matters. It follows
349 that if a device has system-sleep callbacks but does not support runtime
350 PM, then its prepare callback must never return a positive value. This
351 is because all such devices are initially set to runtime-suspended with
352 runtime PM disabled.
353
354 2. The ``->suspend`` methods should quiesce the device to stop it from
355 performing I/O. They also may save the device registers and put it into
356 the appropriate low-power state, depending on the bus type the device is
357 on, and they may enable wakeup events.
358
359 3. For a number of devices it is convenient to split suspend into the
360 "quiesce device" and "save device state" phases, in which cases
361 ``suspend_late`` is meant to do the latter. It is always executed after
362 runtime power management has been disabled for the device in question.
363
364 4. The ``suspend_noirq`` phase occurs after IRQ handlers have been disabled,
365 which means that the driver's interrupt handler will not be called while
366 the callback method is running. The ``->suspend_noirq`` methods should
367 save the values of the device's registers that weren't saved previously
368 and finally put the device into the appropriate low-power state.
369
370 The majority of subsystems and device drivers need not implement this
371 callback. However, bus types allowing devices to share interrupt
372 vectors, like PCI, generally need it; otherwise a driver might encounter
373 an error during the suspend phase by fielding a shared interrupt
374 generated by some other device after its own device had been set to low
375 power.
376
377At the end of these phases, drivers should have stopped all I/O transactions
378(DMA, IRQs), saved enough state that they can re-initialize or restore previous
379state (as needed by the hardware), and placed the device into a low-power state.
380On many platforms they will gate off one or more clock sources; sometimes they
381will also switch off power supplies or reduce voltages. [Drivers supporting
382runtime PM may already have performed some or all of these steps.]
383
384If :c:func:`device_may_wakeup(dev)` returns ``true``, the device should be
385prepared for generating hardware wakeup signals to trigger a system wakeup event
386when the system is in the sleep state. For example, :c:func:`enable_irq_wake()`
387might identify GPIO signals hooked up to a switch or other external hardware,
388and :c:func:`pci_enable_wake()` does something similar for the PCI PME signal.
389
390If any of these callbacks returns an error, the system won't enter the desired
391low-power state. Instead, the PM core will unwind its actions by resuming all
392the devices that were suspended.
393
394
395Leaving System Suspend
396----------------------
397
398When resuming from freeze, standby or memory sleep, the phases are:
399``resume_noirq``, ``resume_early``, ``resume``, ``complete``.
400
401 1. The ``->resume_noirq`` callback methods should perform any actions
402 needed before the driver's interrupt handlers are invoked. This
403 generally means undoing the actions of the ``suspend_noirq`` phase. If
404 the bus type permits devices to share interrupt vectors, like PCI, the
405 method should bring the device and its driver into a state in which the
406 driver can recognize if the device is the source of incoming interrupts,
407 if any, and handle them correctly.
408
409 For example, the PCI bus type's ``->pm.resume_noirq()`` puts the device
410 into the full-power state (D0 in the PCI terminology) and restores the
411 standard configuration registers of the device. Then it calls the
412 device driver's ``->pm.resume_noirq()`` method to perform device-specific
413 actions.
414
415 2. The ``->resume_early`` methods should prepare devices for the execution
416 of the resume methods. This generally involves undoing the actions of
417 the preceding ``suspend_late`` phase.
418
419 3. The ``->resume`` methods should bring the device back to its operating
420 state, so that it can perform normal I/O. This generally involves
421 undoing the actions of the ``suspend`` phase.
422
423 4. The ``complete`` phase should undo the actions of the ``prepare`` phase.
424 For this reason, unlike the other resume-related phases, during the
425 ``complete`` phase the device hierarchy is traversed bottom-up.
426
427 Note, however, that new children may be registered below the device as
428 soon as the ``->resume`` callbacks occur; it's not necessary to wait
429 until the ``complete`` phase with that.
430
431 Moreover, if the preceding ``->prepare`` callback returned a positive
432 number, the device may have been left in runtime suspend throughout the
433 whole system suspend and resume (the ``suspend``, ``suspend_late``,
434 ``suspend_noirq`` phases of system suspend and the ``resume_noirq``,
435 ``resume_early``, ``resume`` phases of system resume may have been
436 skipped for it). In that case, the ``->complete`` callback is entirely
437 responsible for putting the device into a consistent state after system
438 suspend if necessary. [For example, it may need to queue up a runtime
439 resume request for the device for this purpose.] To check if that is
440 the case, the ``->complete`` callback can consult the device's
441 ``power.direct_complete`` flag. Namely, if that flag is set when the
442 ``->complete`` callback is being run, it has been called directly after
443 the preceding ``->prepare`` and special actions may be required
444 to make the device work correctly afterward.
445
446At the end of these phases, drivers should be as functional as they were before
447suspending: I/O can be performed using DMA and IRQs, and the relevant clocks are
448gated on.
449
450However, the details here may again be platform-specific. For example,
451some systems support multiple "run" states, and the mode in effect at
452the end of resume might not be the one which preceded suspension.
453That means availability of certain clocks or power supplies changed,
454which could easily affect how a driver works.
455
456Drivers need to be able to handle hardware which has been reset since all of the
457suspend methods were called, for example by complete reinitialization.
458This may be the hardest part, and the one most protected by NDA'd documents
459and chip errata. It's simplest if the hardware state hasn't changed since
460the suspend was carried out, but that can only be guaranteed if the target
461system sleep entered was suspend-to-idle. For the other system sleep states
462that may not be the case (and usually isn't for ACPI-defined system sleep
463states, like S3).
464
465Drivers must also be prepared to notice that the device has been removed
466while the system was powered down, whenever that's physically possible.
467PCMCIA, MMC, USB, Firewire, SCSI, and even IDE are common examples of busses
468where common Linux platforms will see such removal. Details of how drivers
469will notice and handle such removals are currently bus-specific, and often
470involve a separate thread.
471
472These callbacks may return an error value, but the PM core will ignore such
473errors since there's nothing it can do about them other than printing them in
474the system log.
475
476
477Entering Hibernation
478--------------------
479
480Hibernating the system is more complicated than putting it into sleep states,
481because it involves creating and saving a system image. Therefore there are
482more phases for hibernation, with a different set of callbacks. These phases
483always run after tasks have been frozen and enough memory has been freed.
484
485The general procedure for hibernation is to quiesce all devices ("freeze"),
486create an image of the system memory while everything is stable, reactivate all
487devices ("thaw"), write the image to permanent storage, and finally shut down
488the system ("power off"). The phases used to accomplish this are: ``prepare``,
489``freeze``, ``freeze_late``, ``freeze_noirq``, ``thaw_noirq``, ``thaw_early``,
490``thaw``, ``complete``, ``prepare``, ``poweroff``, ``poweroff_late``,
491``poweroff_noirq``.
492
493 1. The ``prepare`` phase is discussed in the "Entering System Suspend"
494 section above.
495
496 2. The ``->freeze`` methods should quiesce the device so that it doesn't
497 generate IRQs or DMA, and they may need to save the values of device
498 registers. However the device does not have to be put in a low-power
499 state, and to save time it's best not to do so. Also, the device should
500 not be prepared to generate wakeup events.
501
502 3. The ``freeze_late`` phase is analogous to the ``suspend_late`` phase
503 described earlier, except that the device should not be put into a
504 low-power state and should not be allowed to generate wakeup events.
505
506 4. The ``freeze_noirq`` phase is analogous to the ``suspend_noirq`` phase
507 discussed earlier, except again that the device should not be put into
508 a low-power state and should not be allowed to generate wakeup events.
509
510At this point the system image is created. All devices should be inactive and
511the contents of memory should remain undisturbed while this happens, so that the
512image forms an atomic snapshot of the system state.
513
514 5. The ``thaw_noirq`` phase is analogous to the ``resume_noirq`` phase
515 discussed earlier. The main difference is that its methods can assume
516 the device is in the same state as at the end of the ``freeze_noirq``
517 phase.
518
519 6. The ``thaw_early`` phase is analogous to the ``resume_early`` phase
520 described above. Its methods should undo the actions of the preceding
521 ``freeze_late``, if necessary.
522
523 7. The ``thaw`` phase is analogous to the ``resume`` phase discussed
524 earlier. Its methods should bring the device back to an operating
525 state, so that it can be used for saving the image if necessary.
526
527 8. The ``complete`` phase is discussed in the "Leaving System Suspend"
528 section above.
529
530At this point the system image is saved, and the devices then need to be
531prepared for the upcoming system shutdown. This is much like suspending them
532before putting the system into the suspend-to-idle, shallow or deep sleep state,
533and the phases are similar.
534
535 9. The ``prepare`` phase is discussed above.
536
537 10. The ``poweroff`` phase is analogous to the ``suspend`` phase.
538
539 11. The ``poweroff_late`` phase is analogous to the ``suspend_late`` phase.
540
541 12. The ``poweroff_noirq`` phase is analogous to the ``suspend_noirq`` phase.
542
543The ``->poweroff``, ``->poweroff_late`` and ``->poweroff_noirq`` callbacks
544should do essentially the same things as the ``->suspend``, ``->suspend_late``
545and ``->suspend_noirq`` callbacks, respectively. The only notable difference is
546that they need not store the device register values, because the registers
547should already have been stored during the ``freeze``, ``freeze_late`` or
548``freeze_noirq`` phases.
549
550
551Leaving Hibernation
552-------------------
553
554Resuming from hibernation is, again, more complicated than resuming from a sleep
555state in which the contents of main memory are preserved, because it requires
556a system image to be loaded into memory and the pre-hibernation memory contents
557to be restored before control can be passed back to the image kernel.
558
559Although in principle the image might be loaded into memory and the
560pre-hibernation memory contents restored by the boot loader, in practice this
561can't be done because boot loaders aren't smart enough and there is no
562established protocol for passing the necessary information. So instead, the
563boot loader loads a fresh instance of the kernel, called "the restore kernel",
564into memory and passes control to it in the usual way. Then the restore kernel
565reads the system image, restores the pre-hibernation memory contents, and passes
566control to the image kernel. Thus two different kernel instances are involved
567in resuming from hibernation. In fact, the restore kernel may be completely
568different from the image kernel: a different configuration and even a different
569version. This has important consequences for device drivers and their
570subsystems.
571
572To be able to load the system image into memory, the restore kernel needs to
573include at least a subset of device drivers allowing it to access the storage
574medium containing the image, although it doesn't need to include all of the
575drivers present in the image kernel. After the image has been loaded, the
576devices managed by the boot kernel need to be prepared for passing control back
577to the image kernel. This is very similar to the initial steps involved in
578creating a system image, and it is accomplished in the same way, using
579``prepare``, ``freeze``, and ``freeze_noirq`` phases. However, the devices
580affected by these phases are only those having drivers in the restore kernel;
581other devices will still be in whatever state the boot loader left them.
582
583Should the restoration of the pre-hibernation memory contents fail, the restore
584kernel would go through the "thawing" procedure described above, using the
585``thaw_noirq``, ``thaw_early``, ``thaw``, and ``complete`` phases, and then
586continue running normally. This happens only rarely. Most often the
587pre-hibernation memory contents are restored successfully and control is passed
588to the image kernel, which then becomes responsible for bringing the system back
589to the working state.
590
591To achieve this, the image kernel must restore the devices' pre-hibernation
592functionality. The operation is much like waking up from a sleep state (with
593the memory contents preserved), although it involves different phases:
594``restore_noirq``, ``restore_early``, ``restore``, ``complete``.
595
596 1. The ``restore_noirq`` phase is analogous to the ``resume_noirq`` phase.
597
598 2. The ``restore_early`` phase is analogous to the ``resume_early`` phase.
599
600 3. The ``restore`` phase is analogous to the ``resume`` phase.
601
602 4. The ``complete`` phase is discussed above.
603
604The main difference from ``resume[_early|_noirq]`` is that
605``restore[_early|_noirq]`` must assume the device has been accessed and
606reconfigured by the boot loader or the restore kernel. Consequently, the state
607of the device may be different from the state remembered from the ``freeze``,
608``freeze_late`` and ``freeze_noirq`` phases. The device may even need to be
609reset and completely re-initialized. In many cases this difference doesn't
610matter, so the ``->resume[_early|_noirq]`` and ``->restore[_early|_norq]``
611method pointers can be set to the same routines. Nevertheless, different
612callback pointers are used in case there is a situation where it actually does
613matter.
614
615
616Power Management Notifiers
617==========================
618
619There are some operations that cannot be carried out by the power management
620callbacks discussed above, because the callbacks occur too late or too early.
621To handle these cases, subsystems and device drivers may register power
622management notifiers that are called before tasks are frozen and after they have
623been thawed. Generally speaking, the PM notifiers are suitable for performing
624actions that either require user space to be available, or at least won't
625interfere with user space.
626
627For details refer to :doc:`notifiers`.
628
629
630Device Low-Power (suspend) States
631=================================
632
633Device low-power states aren't standard. One device might only handle
634"on" and "off", while another might support a dozen different versions of
635"on" (how many engines are active?), plus a state that gets back to "on"
636faster than from a full "off".
637
638Some buses define rules about what different suspend states mean. PCI
639gives one example: after the suspend sequence completes, a non-legacy
640PCI device may not perform DMA or issue IRQs, and any wakeup events it
641issues would be issued through the PME# bus signal. Plus, there are
642several PCI-standard device states, some of which are optional.
643
644In contrast, integrated system-on-chip processors often use IRQs as the
645wakeup event sources (so drivers would call :c:func:`enable_irq_wake`) and
646might be able to treat DMA completion as a wakeup event (sometimes DMA can stay
647active too, it'd only be the CPU and some peripherals that sleep).
648
649Some details here may be platform-specific. Systems may have devices that
650can be fully active in certain sleep states, such as an LCD display that's
651refreshed using DMA while most of the system is sleeping lightly ... and
652its frame buffer might even be updated by a DSP or other non-Linux CPU while
653the Linux control processor stays idle.
654
655Moreover, the specific actions taken may depend on the target system state.
656One target system state might allow a given device to be very operational;
657another might require a hard shut down with re-initialization on resume.
658And two different target systems might use the same device in different
659ways; the aforementioned LCD might be active in one product's "standby",
660but a different product using the same SOC might work differently.
661
662
663Device Power Management Domains
664===============================
665
666Sometimes devices share reference clocks or other power resources. In those
667cases it generally is not possible to put devices into low-power states
668individually. Instead, a set of devices sharing a power resource can be put
669into a low-power state together at the same time by turning off the shared
670power resource. Of course, they also need to be put into the full-power state
671together, by turning the shared power resource on. A set of devices with this
672property is often referred to as a power domain. A power domain may also be
673nested inside another power domain. The nested domain is referred to as the
674sub-domain of the parent domain.
675
676Support for power domains is provided through the :c:member:`pm_domain` field of
677|struct device|. This field is a pointer to an object of type
678|struct dev_pm_domain|, defined in :file:`include/linux/pm.h``, providing a set
679of power management callbacks analogous to the subsystem-level and device driver
680callbacks that are executed for the given device during all power transitions,
681instead of the respective subsystem-level callbacks. Specifically, if a
682device's :c:member:`pm_domain` pointer is not NULL, the ``->suspend()`` callback
683from the object pointed to by it will be executed instead of its subsystem's
684(e.g. bus type's) ``->suspend()`` callback and analogously for all of the
685remaining callbacks. In other words, power management domain callbacks, if
686defined for the given device, always take precedence over the callbacks provided
687by the device's subsystem (e.g. bus type).
688
689The support for device power management domains is only relevant to platforms
690needing to use the same device driver power management callbacks in many
691different power domain configurations and wanting to avoid incorporating the
692support for power domains into subsystem-level callbacks, for example by
693modifying the platform bus type. Other platforms need not implement it or take
694it into account in any way.
695
696Devices may be defined as IRQ-safe which indicates to the PM core that their
697runtime PM callbacks may be invoked with disabled interrupts (see
698:file:`Documentation/power/runtime_pm.txt` for more information). If an
699IRQ-safe device belongs to a PM domain, the runtime PM of the domain will be
700disallowed, unless the domain itself is defined as IRQ-safe. However, it
701makes sense to define a PM domain as IRQ-safe only if all the devices in it
702are IRQ-safe. Moreover, if an IRQ-safe domain has a parent domain, the runtime
703PM of the parent is only allowed if the parent itself is IRQ-safe too with the
704additional restriction that all child domains of an IRQ-safe parent must also
705be IRQ-safe.
706
707
708Runtime Power Management
709========================
710
711Many devices are able to dynamically power down while the system is still
712running. This feature is useful for devices that are not being used, and
713can offer significant power savings on a running system. These devices
714often support a range of runtime power states, which might use names such
715as "off", "sleep", "idle", "active", and so on. Those states will in some
716cases (like PCI) be partially constrained by the bus the device uses, and will
717usually include hardware states that are also used in system sleep states.
718
719A system-wide power transition can be started while some devices are in low
720power states due to runtime power management. The system sleep PM callbacks
721should recognize such situations and react to them appropriately, but the
722necessary actions are subsystem-specific.
723
724In some cases the decision may be made at the subsystem level while in other
725cases the device driver may be left to decide. In some cases it may be
726desirable to leave a suspended device in that state during a system-wide power
727transition, but in other cases the device must be put back into the full-power
728state temporarily, for example so that its system wakeup capability can be
729disabled. This all depends on the hardware and the design of the subsystem and
730device driver in question.
731
732During system-wide resume from a sleep state it's easiest to put devices into
733the full-power state, as explained in :file:`Documentation/power/runtime_pm.txt`.
734Refer to that document for more information regarding this particular issue as
735well as for information on the device runtime power management framework in
736general.
diff --git a/Documentation/driver-api/pm/index.rst b/Documentation/driver-api/pm/index.rst
new file mode 100644
index 000000000000..2f6d0e9cf6b7
--- /dev/null
+++ b/Documentation/driver-api/pm/index.rst
@@ -0,0 +1,16 @@
1=======================
2Device Power Management
3=======================
4
5.. toctree::
6
7 devices
8 notifiers
9 types
10
11.. only:: subproject and html
12
13 Indices
14 =======
15
16 * :ref:`genindex`
diff --git a/Documentation/driver-api/pm/notifiers.rst b/Documentation/driver-api/pm/notifiers.rst
new file mode 100644
index 000000000000..62f860026992
--- /dev/null
+++ b/Documentation/driver-api/pm/notifiers.rst
@@ -0,0 +1,70 @@
1=============================
2Suspend/Hibernation Notifiers
3=============================
4
5::
6
7 Copyright (c) 2016 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com>
8
9There are some operations that subsystems or drivers may want to carry out
10before hibernation/suspend or after restore/resume, but they require the system
11to be fully functional, so the drivers' and subsystems' ``->suspend()`` and
12``->resume()`` or even ``->prepare()`` and ``->complete()`` callbacks are not
13suitable for this purpose.
14
15For example, device drivers may want to upload firmware to their devices after
16resume/restore, but they cannot do it by calling :c:func:`request_firmware()`
17from their ``->resume()`` or ``->complete()`` callback routines (user land
18processes are frozen at these points). The solution may be to load the firmware
19into memory before processes are frozen and upload it from there in the
20``->resume()`` routine. A suspend/hibernation notifier may be used for that.
21
22Subsystems or drivers having such needs can register suspend notifiers that
23will be called upon the following events by the PM core:
24
25``PM_HIBERNATION_PREPARE``
26 The system is going to hibernate, tasks will be frozen immediately. This
27 is different from ``PM_SUSPEND_PREPARE`` below, because in this case
28 additional work is done between the notifiers and the invocation of PM
29 callbacks for the "freeze" transition.
30
31``PM_POST_HIBERNATION``
32 The system memory state has been restored from a hibernation image or an
33 error occurred during hibernation. Device restore callbacks have been
34 executed and tasks have been thawed.
35
36``PM_RESTORE_PREPARE``
37 The system is going to restore a hibernation image. If all goes well,
38 the restored image kernel will issue a ``PM_POST_HIBERNATION``
39 notification.
40
41``PM_POST_RESTORE``
42 An error occurred during restore from hibernation. Device restore
43 callbacks have been executed and tasks have been thawed.
44
45``PM_SUSPEND_PREPARE``
46 The system is preparing for suspend.
47
48``PM_POST_SUSPEND``
49 The system has just resumed or an error occurred during suspend. Device
50 resume callbacks have been executed and tasks have been thawed.
51
52It is generally assumed that whatever the notifiers do for
53``PM_HIBERNATION_PREPARE``, should be undone for ``PM_POST_HIBERNATION``.
54Analogously, operations carried out for ``PM_SUSPEND_PREPARE`` should be
55reversed for ``PM_POST_SUSPEND``.
56
57Moreover, if one of the notifiers fails for the ``PM_HIBERNATION_PREPARE`` or
58``PM_SUSPEND_PREPARE`` event, the notifiers that have already succeeded for that
59event will be called for ``PM_POST_HIBERNATION`` or ``PM_POST_SUSPEND``,
60respectively.
61
62The hibernation and suspend notifiers are called with :c:data:`pm_mutex` held.
63They are defined in the usual way, but their last argument is meaningless (it is
64always NULL).
65
66To register and/or unregister a suspend notifier use
67:c:func:`register_pm_notifier()` and :c:func:`unregister_pm_notifier()`,
68respectively (both defined in :file:`include/linux/suspend.h`). If you don't
69need to unregister the notifier, you can also use the :c:func:`pm_notifier()`
70macro defined in :file:`include/linux/suspend.h`.
diff --git a/Documentation/driver-api/pm/types.rst b/Documentation/driver-api/pm/types.rst
new file mode 100644
index 000000000000..3ebdecc54104
--- /dev/null
+++ b/Documentation/driver-api/pm/types.rst
@@ -0,0 +1,5 @@
1==================================
2Device Power Management Data Types
3==================================
4
5.. kernel-doc:: include/linux/pm.h
diff --git a/Documentation/driver-api/regulator.rst b/Documentation/driver-api/regulator.rst
new file mode 100644
index 000000000000..520da0a5251d
--- /dev/null
+++ b/Documentation/driver-api/regulator.rst
@@ -0,0 +1,170 @@
1.. Copyright 2007-2008 Wolfson Microelectronics
2
3.. This documentation is free software; you can redistribute
4.. it and/or modify it under the terms of the GNU General Public
5.. License version 2 as published by the Free Software Foundation.
6
7=================================
8Voltage and current regulator API
9=================================
10
11:Author: Liam Girdwood
12:Author: Mark Brown
13
14Introduction
15============
16
17This framework is designed to provide a standard kernel interface to
18control voltage and current regulators.
19
20The intention is to allow systems to dynamically control regulator power
21output in order to save power and prolong battery life. This applies to
22both voltage regulators (where voltage output is controllable) and
23current sinks (where current limit is controllable).
24
25Note that additional (and currently more complete) documentation is
26available in the Linux kernel source under
27``Documentation/power/regulator``.
28
29Glossary
30--------
31
32The regulator API uses a number of terms which may not be familiar:
33
34Regulator
35
36 Electronic device that supplies power to other devices. Most regulators
37 can enable and disable their output and some can also control their
38 output voltage or current.
39
40Consumer
41
42 Electronic device which consumes power provided by a regulator. These
43 may either be static, requiring only a fixed supply, or dynamic,
44 requiring active management of the regulator at runtime.
45
46Power Domain
47
48 The electronic circuit supplied by a given regulator, including the
49 regulator and all consumer devices. The configuration of the regulator
50 is shared between all the components in the circuit.
51
52Power Management Integrated Circuit (PMIC)
53
54 An IC which contains numerous regulators and often also other
55 subsystems. In an embedded system the primary PMIC is often equivalent
56 to a combination of the PSU and southbridge in a desktop system.
57
58Consumer driver interface
59=========================
60
61This offers a similar API to the kernel clock framework. Consumer
62drivers use `get <#API-regulator-get>`__ and
63`put <#API-regulator-put>`__ operations to acquire and release
64regulators. Functions are provided to `enable <#API-regulator-enable>`__
65and `disable <#API-regulator-disable>`__ the regulator and to get and
66set the runtime parameters of the regulator.
67
68When requesting regulators consumers use symbolic names for their
69supplies, such as "Vcc", which are mapped into actual regulator devices
70by the machine interface.
71
72A stub version of this API is provided when the regulator framework is
73not in use in order to minimise the need to use ifdefs.
74
75Enabling and disabling
76----------------------
77
78The regulator API provides reference counted enabling and disabling of
79regulators. Consumer devices use the :c:func:`regulator_enable()` and
80:c:func:`regulator_disable()` functions to enable and disable
81regulators. Calls to the two functions must be balanced.
82
83Note that since multiple consumers may be using a regulator and machine
84constraints may not allow the regulator to be disabled there is no
85guarantee that calling :c:func:`regulator_disable()` will actually
86cause the supply provided by the regulator to be disabled. Consumer
87drivers should assume that the regulator may be enabled at all times.
88
89Configuration
90-------------
91
92Some consumer devices may need to be able to dynamically configure their
93supplies. For example, MMC drivers may need to select the correct
94operating voltage for their cards. This may be done while the regulator
95is enabled or disabled.
96
97The :c:func:`regulator_set_voltage()` and
98:c:func:`regulator_set_current_limit()` functions provide the primary
99interface for this. Both take ranges of voltages and currents, supporting
100drivers that do not require a specific value (eg, CPU frequency scaling
101normally permits the CPU to use a wider range of supply voltages at lower
102frequencies but does not require that the supply voltage be lowered). Where
103an exact value is required both minimum and maximum values should be
104identical.
105
106Callbacks
107---------
108
109Callbacks may also be registered for events such as regulation failures.
110
111Regulator driver interface
112==========================
113
114Drivers for regulator chips register the regulators with the regulator
115core, providing operations structures to the core. A notifier interface
116allows error conditions to be reported to the core.
117
118Registration should be triggered by explicit setup done by the platform,
119supplying a struct :c:type:`regulator_init_data` for the regulator
120containing constraint and supply information.
121
122Machine interface
123=================
124
125This interface provides a way to define how regulators are connected to
126consumers on a given system and what the valid operating parameters are
127for the system.
128
129Supplies
130--------
131
132Regulator supplies are specified using struct
133:c:type:`regulator_consumer_supply`. This is done at driver registration
134time as part of the machine constraints.
135
136Constraints
137-----------
138
139As well as defining the connections the machine interface also provides
140constraints defining the operations that clients are allowed to perform
141and the parameters that may be set. This is required since generally
142regulator devices will offer more flexibility than it is safe to use on
143a given system, for example supporting higher supply voltages than the
144consumers are rated for.
145
146This is done at driver registration time` by providing a
147struct :c:type:`regulation_constraints`.
148
149The constraints may also specify an initial configuration for the
150regulator in the constraints, which is particularly useful for use with
151static consumers.
152
153API reference
154=============
155
156Due to limitations of the kernel documentation framework and the
157existing layout of the source code the entire regulator API is
158documented here.
159
160.. kernel-doc:: include/linux/regulator/consumer.h
161 :internal:
162
163.. kernel-doc:: include/linux/regulator/machine.h
164 :internal:
165
166.. kernel-doc:: include/linux/regulator/driver.h
167 :internal:
168
169.. kernel-doc:: drivers/regulator/core.c
170 :export:
diff --git a/Documentation/driver-api/uio-howto.rst b/Documentation/driver-api/uio-howto.rst
new file mode 100644
index 000000000000..f73d660b2956
--- /dev/null
+++ b/Documentation/driver-api/uio-howto.rst
@@ -0,0 +1,705 @@
1=======================
2The Userspace I/O HOWTO
3=======================
4
5:Author: Hans-Jürgen Koch Linux developer, Linutronix
6:Date: 2006-12-11
7
8About this document
9===================
10
11Translations
12------------
13
14If you know of any translations for this document, or you are interested
15in translating it, please email me hjk@hansjkoch.de.
16
17Preface
18-------
19
20For many types of devices, creating a Linux kernel driver is overkill.
21All that is really needed is some way to handle an interrupt and provide
22access to the memory space of the device. The logic of controlling the
23device does not necessarily have to be within the kernel, as the device
24does not need to take advantage of any of other resources that the
25kernel provides. One such common class of devices that are like this are
26for industrial I/O cards.
27
28To address this situation, the userspace I/O system (UIO) was designed.
29For typical industrial I/O cards, only a very small kernel module is
30needed. The main part of the driver will run in user space. This
31simplifies development and reduces the risk of serious bugs within a
32kernel module.
33
34Please note that UIO is not an universal driver interface. Devices that
35are already handled well by other kernel subsystems (like networking or
36serial or USB) are no candidates for an UIO driver. Hardware that is
37ideally suited for an UIO driver fulfills all of the following:
38
39- The device has memory that can be mapped. The device can be
40 controlled completely by writing to this memory.
41
42- The device usually generates interrupts.
43
44- The device does not fit into one of the standard kernel subsystems.
45
46Acknowledgments
47---------------
48
49I'd like to thank Thomas Gleixner and Benedikt Spranger of Linutronix,
50who have not only written most of the UIO code, but also helped greatly
51writing this HOWTO by giving me all kinds of background information.
52
53Feedback
54--------
55
56Find something wrong with this document? (Or perhaps something right?) I
57would love to hear from you. Please email me at hjk@hansjkoch.de.
58
59About UIO
60=========
61
62If you use UIO for your card's driver, here's what you get:
63
64- only one small kernel module to write and maintain.
65
66- develop the main part of your driver in user space, with all the
67 tools and libraries you're used to.
68
69- bugs in your driver won't crash the kernel.
70
71- updates of your driver can take place without recompiling the kernel.
72
73How UIO works
74-------------
75
76Each UIO device is accessed through a device file and several sysfs
77attribute files. The device file will be called ``/dev/uio0`` for the
78first device, and ``/dev/uio1``, ``/dev/uio2`` and so on for subsequent
79devices.
80
81``/dev/uioX`` is used to access the address space of the card. Just use
82:c:func:`mmap()` to access registers or RAM locations of your card.
83
84Interrupts are handled by reading from ``/dev/uioX``. A blocking
85:c:func:`read()` from ``/dev/uioX`` will return as soon as an
86interrupt occurs. You can also use :c:func:`select()` on
87``/dev/uioX`` to wait for an interrupt. The integer value read from
88``/dev/uioX`` represents the total interrupt count. You can use this
89number to figure out if you missed some interrupts.
90
91For some hardware that has more than one interrupt source internally,
92but not separate IRQ mask and status registers, there might be
93situations where userspace cannot determine what the interrupt source
94was if the kernel handler disables them by writing to the chip's IRQ
95register. In such a case, the kernel has to disable the IRQ completely
96to leave the chip's register untouched. Now the userspace part can
97determine the cause of the interrupt, but it cannot re-enable
98interrupts. Another cornercase is chips where re-enabling interrupts is
99a read-modify-write operation to a combined IRQ status/acknowledge
100register. This would be racy if a new interrupt occurred simultaneously.
101
102To address these problems, UIO also implements a write() function. It is
103normally not used and can be ignored for hardware that has only a single
104interrupt source or has separate IRQ mask and status registers. If you
105need it, however, a write to ``/dev/uioX`` will call the
106:c:func:`irqcontrol()` function implemented by the driver. You have
107to write a 32-bit value that is usually either 0 or 1 to disable or
108enable interrupts. If a driver does not implement
109:c:func:`irqcontrol()`, :c:func:`write()` will return with
110``-ENOSYS``.
111
112To handle interrupts properly, your custom kernel module can provide its
113own interrupt handler. It will automatically be called by the built-in
114handler.
115
116For cards that don't generate interrupts but need to be polled, there is
117the possibility to set up a timer that triggers the interrupt handler at
118configurable time intervals. This interrupt simulation is done by
119calling :c:func:`uio_event_notify()` from the timer's event
120handler.
121
122Each driver provides attributes that are used to read or write
123variables. These attributes are accessible through sysfs files. A custom
124kernel driver module can add its own attributes to the device owned by
125the uio driver, but not added to the UIO device itself at this time.
126This might change in the future if it would be found to be useful.
127
128The following standard attributes are provided by the UIO framework:
129
130- ``name``: The name of your device. It is recommended to use the name
131 of your kernel module for this.
132
133- ``version``: A version string defined by your driver. This allows the
134 user space part of your driver to deal with different versions of the
135 kernel module.
136
137- ``event``: The total number of interrupts handled by the driver since
138 the last time the device node was read.
139
140These attributes appear under the ``/sys/class/uio/uioX`` directory.
141Please note that this directory might be a symlink, and not a real
142directory. Any userspace code that accesses it must be able to handle
143this.
144
145Each UIO device can make one or more memory regions available for memory
146mapping. This is necessary because some industrial I/O cards require
147access to more than one PCI memory region in a driver.
148
149Each mapping has its own directory in sysfs, the first mapping appears
150as ``/sys/class/uio/uioX/maps/map0/``. Subsequent mappings create
151directories ``map1/``, ``map2/``, and so on. These directories will only
152appear if the size of the mapping is not 0.
153
154Each ``mapX/`` directory contains four read-only files that show
155attributes of the memory:
156
157- ``name``: A string identifier for this mapping. This is optional, the
158 string can be empty. Drivers can set this to make it easier for
159 userspace to find the correct mapping.
160
161- ``addr``: The address of memory that can be mapped.
162
163- ``size``: The size, in bytes, of the memory pointed to by addr.
164
165- ``offset``: The offset, in bytes, that has to be added to the pointer
166 returned by :c:func:`mmap()` to get to the actual device memory.
167 This is important if the device's memory is not page aligned.
168 Remember that pointers returned by :c:func:`mmap()` are always
169 page aligned, so it is good style to always add this offset.
170
171From userspace, the different mappings are distinguished by adjusting
172the ``offset`` parameter of the :c:func:`mmap()` call. To map the
173memory of mapping N, you have to use N times the page size as your
174offset::
175
176 offset = N * getpagesize();
177
178Sometimes there is hardware with memory-like regions that can not be
179mapped with the technique described here, but there are still ways to
180access them from userspace. The most common example are x86 ioports. On
181x86 systems, userspace can access these ioports using
182:c:func:`ioperm()`, :c:func:`iopl()`, :c:func:`inb()`,
183:c:func:`outb()`, and similar functions.
184
185Since these ioport regions can not be mapped, they will not appear under
186``/sys/class/uio/uioX/maps/`` like the normal memory described above.
187Without information about the port regions a hardware has to offer, it
188becomes difficult for the userspace part of the driver to find out which
189ports belong to which UIO device.
190
191To address this situation, the new directory
192``/sys/class/uio/uioX/portio/`` was added. It only exists if the driver
193wants to pass information about one or more port regions to userspace.
194If that is the case, subdirectories named ``port0``, ``port1``, and so
195on, will appear underneath ``/sys/class/uio/uioX/portio/``.
196
197Each ``portX/`` directory contains four read-only files that show name,
198start, size, and type of the port region:
199
200- ``name``: A string identifier for this port region. The string is
201 optional and can be empty. Drivers can set it to make it easier for
202 userspace to find a certain port region.
203
204- ``start``: The first port of this region.
205
206- ``size``: The number of ports in this region.
207
208- ``porttype``: A string describing the type of port.
209
210Writing your own kernel module
211==============================
212
213Please have a look at ``uio_cif.c`` as an example. The following
214paragraphs explain the different sections of this file.
215
216struct uio_info
217---------------
218
219This structure tells the framework the details of your driver, Some of
220the members are required, others are optional.
221
222- ``const char *name``: Required. The name of your driver as it will
223 appear in sysfs. I recommend using the name of your module for this.
224
225- ``const char *version``: Required. This string appears in
226 ``/sys/class/uio/uioX/version``.
227
228- ``struct uio_mem mem[ MAX_UIO_MAPS ]``: Required if you have memory
229 that can be mapped with :c:func:`mmap()`. For each mapping you
230 need to fill one of the ``uio_mem`` structures. See the description
231 below for details.
232
233- ``struct uio_port port[ MAX_UIO_PORTS_REGIONS ]``: Required if you
234 want to pass information about ioports to userspace. For each port
235 region you need to fill one of the ``uio_port`` structures. See the
236 description below for details.
237
238- ``long irq``: Required. If your hardware generates an interrupt, it's
239 your modules task to determine the irq number during initialization.
240 If you don't have a hardware generated interrupt but want to trigger
241 the interrupt handler in some other way, set ``irq`` to
242 ``UIO_IRQ_CUSTOM``. If you had no interrupt at all, you could set
243 ``irq`` to ``UIO_IRQ_NONE``, though this rarely makes sense.
244
245- ``unsigned long irq_flags``: Required if you've set ``irq`` to a
246 hardware interrupt number. The flags given here will be used in the
247 call to :c:func:`request_irq()`.
248
249- ``int (*mmap)(struct uio_info *info, struct vm_area_struct *vma)``:
250 Optional. If you need a special :c:func:`mmap()`
251 function, you can set it here. If this pointer is not NULL, your
252 :c:func:`mmap()` will be called instead of the built-in one.
253
254- ``int (*open)(struct uio_info *info, struct inode *inode)``:
255 Optional. You might want to have your own :c:func:`open()`,
256 e.g. to enable interrupts only when your device is actually used.
257
258- ``int (*release)(struct uio_info *info, struct inode *inode)``:
259 Optional. If you define your own :c:func:`open()`, you will
260 probably also want a custom :c:func:`release()` function.
261
262- ``int (*irqcontrol)(struct uio_info *info, s32 irq_on)``:
263 Optional. If you need to be able to enable or disable interrupts
264 from userspace by writing to ``/dev/uioX``, you can implement this
265 function. The parameter ``irq_on`` will be 0 to disable interrupts
266 and 1 to enable them.
267
268Usually, your device will have one or more memory regions that can be
269mapped to user space. For each region, you have to set up a
270``struct uio_mem`` in the ``mem[]`` array. Here's a description of the
271fields of ``struct uio_mem``:
272
273- ``const char *name``: Optional. Set this to help identify the memory
274 region, it will show up in the corresponding sysfs node.
275
276- ``int memtype``: Required if the mapping is used. Set this to
277 ``UIO_MEM_PHYS`` if you you have physical memory on your card to be
278 mapped. Use ``UIO_MEM_LOGICAL`` for logical memory (e.g. allocated
279 with :c:func:`kmalloc()`). There's also ``UIO_MEM_VIRTUAL`` for
280 virtual memory.
281
282- ``phys_addr_t addr``: Required if the mapping is used. Fill in the
283 address of your memory block. This address is the one that appears in
284 sysfs.
285
286- ``resource_size_t size``: Fill in the size of the memory block that
287 ``addr`` points to. If ``size`` is zero, the mapping is considered
288 unused. Note that you *must* initialize ``size`` with zero for all
289 unused mappings.
290
291- ``void *internal_addr``: If you have to access this memory region
292 from within your kernel module, you will want to map it internally by
293 using something like :c:func:`ioremap()`. Addresses returned by
294 this function cannot be mapped to user space, so you must not store
295 it in ``addr``. Use ``internal_addr`` instead to remember such an
296 address.
297
298Please do not touch the ``map`` element of ``struct uio_mem``! It is
299used by the UIO framework to set up sysfs files for this mapping. Simply
300leave it alone.
301
302Sometimes, your device can have one or more port regions which can not
303be mapped to userspace. But if there are other possibilities for
304userspace to access these ports, it makes sense to make information
305about the ports available in sysfs. For each region, you have to set up
306a ``struct uio_port`` in the ``port[]`` array. Here's a description of
307the fields of ``struct uio_port``:
308
309- ``char *porttype``: Required. Set this to one of the predefined
310 constants. Use ``UIO_PORT_X86`` for the ioports found in x86
311 architectures.
312
313- ``unsigned long start``: Required if the port region is used. Fill in
314 the number of the first port of this region.
315
316- ``unsigned long size``: Fill in the number of ports in this region.
317 If ``size`` is zero, the region is considered unused. Note that you
318 *must* initialize ``size`` with zero for all unused regions.
319
320Please do not touch the ``portio`` element of ``struct uio_port``! It is
321used internally by the UIO framework to set up sysfs files for this
322region. Simply leave it alone.
323
324Adding an interrupt handler
325---------------------------
326
327What you need to do in your interrupt handler depends on your hardware
328and on how you want to handle it. You should try to keep the amount of
329code in your kernel interrupt handler low. If your hardware requires no
330action that you *have* to perform after each interrupt, then your
331handler can be empty.
332
333If, on the other hand, your hardware *needs* some action to be performed
334after each interrupt, then you *must* do it in your kernel module. Note
335that you cannot rely on the userspace part of your driver. Your
336userspace program can terminate at any time, possibly leaving your
337hardware in a state where proper interrupt handling is still required.
338
339There might also be applications where you want to read data from your
340hardware at each interrupt and buffer it in a piece of kernel memory
341you've allocated for that purpose. With this technique you could avoid
342loss of data if your userspace program misses an interrupt.
343
344A note on shared interrupts: Your driver should support interrupt
345sharing whenever this is possible. It is possible if and only if your
346driver can detect whether your hardware has triggered the interrupt or
347not. This is usually done by looking at an interrupt status register. If
348your driver sees that the IRQ bit is actually set, it will perform its
349actions, and the handler returns IRQ_HANDLED. If the driver detects
350that it was not your hardware that caused the interrupt, it will do
351nothing and return IRQ_NONE, allowing the kernel to call the next
352possible interrupt handler.
353
354If you decide not to support shared interrupts, your card won't work in
355computers with no free interrupts. As this frequently happens on the PC
356platform, you can save yourself a lot of trouble by supporting interrupt
357sharing.
358
359Using uio_pdrv for platform devices
360-----------------------------------
361
362In many cases, UIO drivers for platform devices can be handled in a
363generic way. In the same place where you define your
364``struct platform_device``, you simply also implement your interrupt
365handler and fill your ``struct uio_info``. A pointer to this
366``struct uio_info`` is then used as ``platform_data`` for your platform
367device.
368
369You also need to set up an array of ``struct resource`` containing
370addresses and sizes of your memory mappings. This information is passed
371to the driver using the ``.resource`` and ``.num_resources`` elements of
372``struct platform_device``.
373
374You now have to set the ``.name`` element of ``struct platform_device``
375to ``"uio_pdrv"`` to use the generic UIO platform device driver. This
376driver will fill the ``mem[]`` array according to the resources given,
377and register the device.
378
379The advantage of this approach is that you only have to edit a file you
380need to edit anyway. You do not have to create an extra driver.
381
382Using uio_pdrv_genirq for platform devices
383------------------------------------------
384
385Especially in embedded devices, you frequently find chips where the irq
386pin is tied to its own dedicated interrupt line. In such cases, where
387you can be really sure the interrupt is not shared, we can take the
388concept of ``uio_pdrv`` one step further and use a generic interrupt
389handler. That's what ``uio_pdrv_genirq`` does.
390
391The setup for this driver is the same as described above for
392``uio_pdrv``, except that you do not implement an interrupt handler. The
393``.handler`` element of ``struct uio_info`` must remain ``NULL``. The
394``.irq_flags`` element must not contain ``IRQF_SHARED``.
395
396You will set the ``.name`` element of ``struct platform_device`` to
397``"uio_pdrv_genirq"`` to use this driver.
398
399The generic interrupt handler of ``uio_pdrv_genirq`` will simply disable
400the interrupt line using :c:func:`disable_irq_nosync()`. After
401doing its work, userspace can reenable the interrupt by writing
4020x00000001 to the UIO device file. The driver already implements an
403:c:func:`irq_control()` to make this possible, you must not
404implement your own.
405
406Using ``uio_pdrv_genirq`` not only saves a few lines of interrupt
407handler code. You also do not need to know anything about the chip's
408internal registers to create the kernel part of the driver. All you need
409to know is the irq number of the pin the chip is connected to.
410
411Using uio_dmem_genirq for platform devices
412------------------------------------------
413
414In addition to statically allocated memory ranges, they may also be a
415desire to use dynamically allocated regions in a user space driver. In
416particular, being able to access memory made available through the
417dma-mapping API, may be particularly useful. The ``uio_dmem_genirq``
418driver provides a way to accomplish this.
419
420This driver is used in a similar manner to the ``"uio_pdrv_genirq"``
421driver with respect to interrupt configuration and handling.
422
423Set the ``.name`` element of ``struct platform_device`` to
424``"uio_dmem_genirq"`` to use this driver.
425
426When using this driver, fill in the ``.platform_data`` element of
427``struct platform_device``, which is of type
428``struct uio_dmem_genirq_pdata`` and which contains the following
429elements:
430
431- ``struct uio_info uioinfo``: The same structure used as the
432 ``uio_pdrv_genirq`` platform data
433
434- ``unsigned int *dynamic_region_sizes``: Pointer to list of sizes of
435 dynamic memory regions to be mapped into user space.
436
437- ``unsigned int num_dynamic_regions``: Number of elements in
438 ``dynamic_region_sizes`` array.
439
440The dynamic regions defined in the platform data will be appended to the
441`` mem[] `` array after the platform device resources, which implies
442that the total number of static and dynamic memory regions cannot exceed
443``MAX_UIO_MAPS``.
444
445The dynamic memory regions will be allocated when the UIO device file,
446``/dev/uioX`` is opened. Similar to static memory resources, the memory
447region information for dynamic regions is then visible via sysfs at
448``/sys/class/uio/uioX/maps/mapY/*``. The dynamic memory regions will be
449freed when the UIO device file is closed. When no processes are holding
450the device file open, the address returned to userspace is ~0.
451
452Writing a driver in userspace
453=============================
454
455Once you have a working kernel module for your hardware, you can write
456the userspace part of your driver. You don't need any special libraries,
457your driver can be written in any reasonable language, you can use
458floating point numbers and so on. In short, you can use all the tools
459and libraries you'd normally use for writing a userspace application.
460
461Getting information about your UIO device
462-----------------------------------------
463
464Information about all UIO devices is available in sysfs. The first thing
465you should do in your driver is check ``name`` and ``version`` to make
466sure your talking to the right device and that its kernel driver has the
467version you expect.
468
469You should also make sure that the memory mapping you need exists and
470has the size you expect.
471
472There is a tool called ``lsuio`` that lists UIO devices and their
473attributes. It is available here:
474
475http://www.osadl.org/projects/downloads/UIO/user/
476
477With ``lsuio`` you can quickly check if your kernel module is loaded and
478which attributes it exports. Have a look at the manpage for details.
479
480The source code of ``lsuio`` can serve as an example for getting
481information about an UIO device. The file ``uio_helper.c`` contains a
482lot of functions you could use in your userspace driver code.
483
484mmap() device memory
485--------------------
486
487After you made sure you've got the right device with the memory mappings
488you need, all you have to do is to call :c:func:`mmap()` to map the
489device's memory to userspace.
490
491The parameter ``offset`` of the :c:func:`mmap()` call has a special
492meaning for UIO devices: It is used to select which mapping of your
493device you want to map. To map the memory of mapping N, you have to use
494N times the page size as your offset::
495
496 offset = N * getpagesize();
497
498N starts from zero, so if you've got only one memory range to map, set
499``offset = 0``. A drawback of this technique is that memory is always
500mapped beginning with its start address.
501
502Waiting for interrupts
503----------------------
504
505After you successfully mapped your devices memory, you can access it
506like an ordinary array. Usually, you will perform some initialization.
507After that, your hardware starts working and will generate an interrupt
508as soon as it's finished, has some data available, or needs your
509attention because an error occurred.
510
511``/dev/uioX`` is a read-only file. A :c:func:`read()` will always
512block until an interrupt occurs. There is only one legal value for the
513``count`` parameter of :c:func:`read()`, and that is the size of a
514signed 32 bit integer (4). Any other value for ``count`` causes
515:c:func:`read()` to fail. The signed 32 bit integer read is the
516interrupt count of your device. If the value is one more than the value
517you read the last time, everything is OK. If the difference is greater
518than one, you missed interrupts.
519
520You can also use :c:func:`select()` on ``/dev/uioX``.
521
522Generic PCI UIO driver
523======================
524
525The generic driver is a kernel module named uio_pci_generic. It can
526work with any device compliant to PCI 2.3 (circa 2002) and any compliant
527PCI Express device. Using this, you only need to write the userspace
528driver, removing the need to write a hardware-specific kernel module.
529
530Making the driver recognize the device
531--------------------------------------
532
533Since the driver does not declare any device ids, it will not get loaded
534automatically and will not automatically bind to any devices, you must
535load it and allocate id to the driver yourself. For example::
536
537 modprobe uio_pci_generic
538 echo "8086 10f5" > /sys/bus/pci/drivers/uio_pci_generic/new_id
539
540If there already is a hardware specific kernel driver for your device,
541the generic driver still won't bind to it, in this case if you want to
542use the generic driver (why would you?) you'll have to manually unbind
543the hardware specific driver and bind the generic driver, like this::
544
545 echo -n 0000:00:19.0 > /sys/bus/pci/drivers/e1000e/unbind
546 echo -n 0000:00:19.0 > /sys/bus/pci/drivers/uio_pci_generic/bind
547
548You can verify that the device has been bound to the driver by looking
549for it in sysfs, for example like the following::
550
551 ls -l /sys/bus/pci/devices/0000:00:19.0/driver
552
553Which if successful should print::
554
555 .../0000:00:19.0/driver -> ../../../bus/pci/drivers/uio_pci_generic
556
557Note that the generic driver will not bind to old PCI 2.2 devices. If
558binding the device failed, run the following command::
559
560 dmesg
561
562and look in the output for failure reasons.
563
564Things to know about uio_pci_generic
565------------------------------------
566
567Interrupts are handled using the Interrupt Disable bit in the PCI
568command register and Interrupt Status bit in the PCI status register.
569All devices compliant to PCI 2.3 (circa 2002) and all compliant PCI
570Express devices should support these bits. uio_pci_generic detects
571this support, and won't bind to devices which do not support the
572Interrupt Disable Bit in the command register.
573
574On each interrupt, uio_pci_generic sets the Interrupt Disable bit.
575This prevents the device from generating further interrupts until the
576bit is cleared. The userspace driver should clear this bit before
577blocking and waiting for more interrupts.
578
579Writing userspace driver using uio_pci_generic
580------------------------------------------------
581
582Userspace driver can use pci sysfs interface, or the libpci library that
583wraps it, to talk to the device and to re-enable interrupts by writing
584to the command register.
585
586Example code using uio_pci_generic
587----------------------------------
588
589Here is some sample userspace driver code using uio_pci_generic::
590
591 #include <stdlib.h>
592 #include <stdio.h>
593 #include <unistd.h>
594 #include <sys/types.h>
595 #include <sys/stat.h>
596 #include <fcntl.h>
597 #include <errno.h>
598
599 int main()
600 {
601 int uiofd;
602 int configfd;
603 int err;
604 int i;
605 unsigned icount;
606 unsigned char command_high;
607
608 uiofd = open("/dev/uio0", O_RDONLY);
609 if (uiofd < 0) {
610 perror("uio open:");
611 return errno;
612 }
613 configfd = open("/sys/class/uio/uio0/device/config", O_RDWR);
614 if (configfd < 0) {
615 perror("config open:");
616 return errno;
617 }
618
619 /* Read and cache command value */
620 err = pread(configfd, &command_high, 1, 5);
621 if (err != 1) {
622 perror("command config read:");
623 return errno;
624 }
625 command_high &= ~0x4;
626
627 for(i = 0;; ++i) {
628 /* Print out a message, for debugging. */
629 if (i == 0)
630 fprintf(stderr, "Started uio test driver.\n");
631 else
632 fprintf(stderr, "Interrupts: %d\n", icount);
633
634 /****************************************/
635 /* Here we got an interrupt from the
636 device. Do something to it. */
637 /****************************************/
638
639 /* Re-enable interrupts. */
640 err = pwrite(configfd, &command_high, 1, 5);
641 if (err != 1) {
642 perror("config write:");
643 break;
644 }
645
646 /* Wait for next interrupt. */
647 err = read(uiofd, &icount, 4);
648 if (err != 4) {
649 perror("uio read:");
650 break;
651 }
652
653 }
654 return errno;
655 }
656
657Generic Hyper-V UIO driver
658==========================
659
660The generic driver is a kernel module named uio_hv_generic. It
661supports devices on the Hyper-V VMBus similar to uio_pci_generic on
662PCI bus.
663
664Making the driver recognize the device
665--------------------------------------
666
667Since the driver does not declare any device GUID's, it will not get
668loaded automatically and will not automatically bind to any devices, you
669must load it and allocate id to the driver yourself. For example, to use
670the network device GUID::
671
672 modprobe uio_hv_generic
673 echo "f8615163-df3e-46c5-913f-f2d2f965ed0e" > /sys/bus/vmbus/drivers/uio_hv_generic/new_id
674
675If there already is a hardware specific kernel driver for the device,
676the generic driver still won't bind to it, in this case if you want to
677use the generic driver (why would you?) you'll have to manually unbind
678the hardware specific driver and bind the generic driver, like this::
679
680 echo -n vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3 > /sys/bus/vmbus/drivers/hv_netvsc/unbind
681 echo -n vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3 > /sys/bus/vmbus/drivers/uio_hv_generic/bind
682
683You can verify that the device has been bound to the driver by looking
684for it in sysfs, for example like the following::
685
686 ls -l /sys/bus/vmbus/devices/vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3/driver
687
688Which if successful should print::
689
690 .../vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3/driver -> ../../../bus/vmbus/drivers/uio_hv_generic
691
692Things to know about uio_hv_generic
693-----------------------------------
694
695On each interrupt, uio_hv_generic sets the Interrupt Disable bit. This
696prevents the device from generating further interrupts until the bit is
697cleared. The userspace driver should clear this bit before blocking and
698waiting for more interrupts.
699
700Further information
701===================
702
703- `OSADL homepage. <http://www.osadl.org>`_
704
705- `Linutronix homepage. <http://www.linutronix.de>`_
diff --git a/Documentation/extcon/intel-int3496.txt b/Documentation/extcon/intel-int3496.txt
new file mode 100644
index 000000000000..af0b366c25b7
--- /dev/null
+++ b/Documentation/extcon/intel-int3496.txt
@@ -0,0 +1,22 @@
1Intel INT3496 ACPI device extcon driver documentation
2-----------------------------------------------------
3
4The Intel INT3496 ACPI device extcon driver is a driver for ACPI
5devices with an acpi-id of INT3496, such as found for example on
6Intel Baytrail and Cherrytrail tablets.
7
8This ACPI device describes how the OS can read the id-pin of the devices'
9USB-otg port, as well as how it optionally can enable Vbus output on the
10otg port and how it can optionally control the muxing of the data pins
11between an USB host and an USB peripheral controller.
12
13The ACPI devices exposes this functionality by returning an array with up
14to 3 gpio descriptors from its ACPI _CRS (Current Resource Settings) call:
15
16Index 0: The input gpio for the id-pin, this is always present and valid
17Index 1: The output gpio for enabling Vbus output from the device to the otg
18 port, write 1 to enable the Vbus output (this gpio descriptor may
19 be absent or invalid)
20Index 2: The output gpio for muxing of the data pins between the USB host and
21 the USB peripheral controller, write 1 to mux to the peripheral
22 controller
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
index ace63cd7af8c..fdcfdd79682a 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -58,7 +58,8 @@ prototypes:
58 int (*permission) (struct inode *, int, unsigned int); 58 int (*permission) (struct inode *, int, unsigned int);
59 int (*get_acl)(struct inode *, int); 59 int (*get_acl)(struct inode *, int);
60 int (*setattr) (struct dentry *, struct iattr *); 60 int (*setattr) (struct dentry *, struct iattr *);
61 int (*getattr) (struct vfsmount *, struct dentry *, struct kstat *); 61 int (*getattr) (const struct path *, struct dentry *, struct kstat *,
62 u32, unsigned int);
62 ssize_t (*listxattr) (struct dentry *, char *, size_t); 63 ssize_t (*listxattr) (struct dentry *, char *, size_t);
63 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, u64 len); 64 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, u64 len);
64 void (*update_time)(struct inode *, struct timespec *, int); 65 void (*update_time)(struct inode *, struct timespec *, int);
diff --git a/Documentation/filesystems/afs.txt b/Documentation/filesystems/afs.txt
index ffef91c4e0d6..060da408923b 100644
--- a/Documentation/filesystems/afs.txt
+++ b/Documentation/filesystems/afs.txt
@@ -64,8 +64,7 @@ USAGE
64When inserting the driver modules the root cell must be specified along with a 64When inserting the driver modules the root cell must be specified along with a
65list of volume location server IP addresses: 65list of volume location server IP addresses:
66 66
67 modprobe af_rxrpc 67 modprobe rxrpc
68 modprobe rxkad
69 modprobe kafs rootcell=cambridge.redhat.com:172.16.18.73:172.16.18.91 68 modprobe kafs rootcell=cambridge.redhat.com:172.16.18.73:172.16.18.91
70 69
71The first module is the AF_RXRPC network protocol driver. This provides the 70The first module is the AF_RXRPC network protocol driver. This provides the
@@ -214,34 +213,3 @@ If a file is opened with a particular key and then the file descriptor is
214passed to a process that doesn't have that key (perhaps over an AF_UNIX 213passed to a process that doesn't have that key (perhaps over an AF_UNIX
215socket), then the operations on the file will be made with key that was used to 214socket), then the operations on the file will be made with key that was used to
216open the file. 215open the file.
217
218
219========
220EXAMPLES
221========
222
223Here's what I use to test this. Some of the names and IP addresses are local
224to my internal DNS. My "root.afs" partition has a mount point within it for
225some public volumes volumes.
226
227insmod /tmp/rxrpc.o
228insmod /tmp/rxkad.o
229insmod /tmp/kafs.o rootcell=cambridge.redhat.com:172.16.18.91
230
231mount -t afs \%root.afs. /afs
232mount -t afs \%cambridge.redhat.com:root.cell. /afs/cambridge.redhat.com/
233
234echo add grand.central.org 18.9.48.14:128.2.203.61:130.237.48.87 > /proc/fs/afs/cells
235mount -t afs "#grand.central.org:root.cell." /afs/grand.central.org/
236mount -t afs "#grand.central.org:root.archive." /afs/grand.central.org/archive
237mount -t afs "#grand.central.org:root.contrib." /afs/grand.central.org/contrib
238mount -t afs "#grand.central.org:root.doc." /afs/grand.central.org/doc
239mount -t afs "#grand.central.org:root.project." /afs/grand.central.org/project
240mount -t afs "#grand.central.org:root.service." /afs/grand.central.org/service
241mount -t afs "#grand.central.org:root.software." /afs/grand.central.org/software
242mount -t afs "#grand.central.org:root.user." /afs/grand.central.org/user
243
244umount /afs
245rmmod kafs
246rmmod rxkad
247rmmod rxrpc
diff --git a/Documentation/filesystems/autofs4-mount-control.txt b/Documentation/filesystems/autofs4-mount-control.txt
index 50a3e01a36f8..e5177cb31a04 100644
--- a/Documentation/filesystems/autofs4-mount-control.txt
+++ b/Documentation/filesystems/autofs4-mount-control.txt
@@ -179,6 +179,7 @@ struct autofs_dev_ioctl {
179 * including this struct */ 179 * including this struct */
180 __s32 ioctlfd; /* automount command fd */ 180 __s32 ioctlfd; /* automount command fd */
181 181
182 /* Command parameters */
182 union { 183 union {
183 struct args_protover protover; 184 struct args_protover protover;
184 struct args_protosubver protosubver; 185 struct args_protosubver protosubver;
diff --git a/Documentation/filesystems/autofs4.txt b/Documentation/filesystems/autofs4.txt
index 8fac3fe7b8c9..f10dd590f69f 100644
--- a/Documentation/filesystems/autofs4.txt
+++ b/Documentation/filesystems/autofs4.txt
@@ -65,7 +65,7 @@ directory is a mount trap only if the filesystem is mounted *direct*
65and the root is empty. 65and the root is empty.
66 66
67Directories created in the root directory are mount traps only if the 67Directories created in the root directory are mount traps only if the
68filesystem is mounted *indirect* and they are empty. 68filesystem is mounted *indirect* and they are empty.
69 69
70Directories further down the tree depend on the *maxproto* mount 70Directories further down the tree depend on the *maxproto* mount
71option and particularly whether it is less than five or not. 71option and particularly whether it is less than five or not.
@@ -352,7 +352,7 @@ Communicating with autofs: root directory ioctls
352------------------------------------------------ 352------------------------------------------------
353 353
354The root directory of an autofs filesystem will respond to a number of 354The root directory of an autofs filesystem will respond to a number of
355ioctls. The process issuing the ioctl must have the CAP_SYS_ADMIN 355ioctls. The process issuing the ioctl must have the CAP_SYS_ADMIN
356capability, or must be the automount daemon. 356capability, or must be the automount daemon.
357 357
358The available ioctl commands are: 358The available ioctl commands are:
@@ -425,8 +425,20 @@ Each ioctl is passed a pointer to an `autofs_dev_ioctl` structure:
425 * including this struct */ 425 * including this struct */
426 __s32 ioctlfd; /* automount command fd */ 426 __s32 ioctlfd; /* automount command fd */
427 427
428 __u32 arg1; /* Command parameters */ 428 /* Command parameters */
429 __u32 arg2; 429 union {
430 struct args_protover protover;
431 struct args_protosubver protosubver;
432 struct args_openmount openmount;
433 struct args_ready ready;
434 struct args_fail fail;
435 struct args_setpipefd setpipefd;
436 struct args_timeout timeout;
437 struct args_requester requester;
438 struct args_expire expire;
439 struct args_askumount askumount;
440 struct args_ismountpoint ismountpoint;
441 };
430 442
431 char path[0]; 443 char path[0];
432 }; 444 };
@@ -446,25 +458,22 @@ Commands are:
446 set version numbers. 458 set version numbers.
447- **AUTOFS_DEV_IOCTL_OPENMOUNT_CMD**: return an open file descriptor 459- **AUTOFS_DEV_IOCTL_OPENMOUNT_CMD**: return an open file descriptor
448 on the root of an autofs filesystem. The filesystem is identified 460 on the root of an autofs filesystem. The filesystem is identified
449 by name and device number, which is stored in `arg1`. Device 461 by name and device number, which is stored in `openmount.devid`.
450 numbers for existing filesystems can be found in 462 Device numbers for existing filesystems can be found in
451 `/proc/self/mountinfo`. 463 `/proc/self/mountinfo`.
452- **AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD**: same as `close(ioctlfd)`. 464- **AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD**: same as `close(ioctlfd)`.
453- **AUTOFS_DEV_IOCTL_SETPIPEFD_CMD**: if the filesystem is in 465- **AUTOFS_DEV_IOCTL_SETPIPEFD_CMD**: if the filesystem is in
454 catatonic mode, this can provide the write end of a new pipe 466 catatonic mode, this can provide the write end of a new pipe
455 in `arg1` to re-establish communication with a daemon. The 467 in `setpipefd.pipefd` to re-establish communication with a daemon.
456 process group of the calling process is used to identify the 468 The process group of the calling process is used to identify the
457 daemon. 469 daemon.
458- **AUTOFS_DEV_IOCTL_REQUESTER_CMD**: `path` should be a 470- **AUTOFS_DEV_IOCTL_REQUESTER_CMD**: `path` should be a
459 name within the filesystem that has been auto-mounted on. 471 name within the filesystem that has been auto-mounted on.
460 arg1 is the dev number of the underlying autofs. On successful 472 On successful return, `requester.uid` and `requester.gid` will be
461 return, `arg1` and `arg2` will be the UID and GID of the process 473 the UID and GID of the process which triggered that mount.
462 which triggered that mount.
463
464- **AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD**: Check if path is a 474- **AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD**: Check if path is a
465 mountpoint of a particular type - see separate documentation for 475 mountpoint of a particular type - see separate documentation for
466 details. 476 details.
467
468- **AUTOFS_DEV_IOCTL_PROTOVER_CMD**: 477- **AUTOFS_DEV_IOCTL_PROTOVER_CMD**:
469- **AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD**: 478- **AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD**:
470- **AUTOFS_DEV_IOCTL_READY_CMD**: 479- **AUTOFS_DEV_IOCTL_READY_CMD**:
@@ -474,7 +483,7 @@ Commands are:
474- **AUTOFS_DEV_IOCTL_EXPIRE_CMD**: 483- **AUTOFS_DEV_IOCTL_EXPIRE_CMD**:
475- **AUTOFS_DEV_IOCTL_ASKUMOUNT_CMD**: These all have the same 484- **AUTOFS_DEV_IOCTL_ASKUMOUNT_CMD**: These all have the same
476 function as the similarly named **AUTOFS_IOC** ioctls, except 485 function as the similarly named **AUTOFS_IOC** ioctls, except
477 that **FAIL** can be given an explicit error number in `arg1` 486 that **FAIL** can be given an explicit error number in `fail.status`
478 instead of assuming `ENOENT`, and this **EXPIRE** command 487 instead of assuming `ENOENT`, and this **EXPIRE** command
479 corresponds to **AUTOFS_IOC_EXPIRE_MULTI**. 488 corresponds to **AUTOFS_IOC_EXPIRE_MULTI**.
480 489
@@ -512,7 +521,7 @@ always be mounted "shared". e.g.
512 521
513> `mount --make-shared /autofs/mount/point` 522> `mount --make-shared /autofs/mount/point`
514 523
515The automount daemon is only able to mange a single mount location for 524The automount daemon is only able to manage a single mount location for
516an autofs filesystem and if mounts on that are not 'shared', other 525an autofs filesystem and if mounts on that are not 'shared', other
517locations will not behave as expected. In particular access to those 526locations will not behave as expected. In particular access to those
518other locations will likely result in the `ELOOP` error 527other locations will likely result in the `ELOOP` error
diff --git a/Documentation/filesystems/ceph.txt b/Documentation/filesystems/ceph.txt
index f5306ee40ea9..0b302a11718a 100644
--- a/Documentation/filesystems/ceph.txt
+++ b/Documentation/filesystems/ceph.txt
@@ -98,11 +98,10 @@ Mount Options
98 size. 98 size.
99 99
100 rsize=X 100 rsize=X
101 Specify the maximum read size in bytes. By default there is no 101 Specify the maximum read size in bytes. Default: 64 MB.
102 maximum.
103 102
104 rasize=X 103 rasize=X
105 Specify the maximum readahead. 104 Specify the maximum readahead. Default: 8 MB.
106 105
107 mount_timeout=X 106 mount_timeout=X
108 Specify the timeout value for mount (in seconds), in the case 107 Specify the timeout value for mount (in seconds), in the case
diff --git a/Documentation/filesystems/f2fs.txt b/Documentation/filesystems/f2fs.txt
index 753dd4f96afe..4f6531a4701b 100644
--- a/Documentation/filesystems/f2fs.txt
+++ b/Documentation/filesystems/f2fs.txt
@@ -125,13 +125,14 @@ active_logs=%u Support configuring the number of active logs. In the
125disable_ext_identify Disable the extension list configured by mkfs, so f2fs 125disable_ext_identify Disable the extension list configured by mkfs, so f2fs
126 does not aware of cold files such as media files. 126 does not aware of cold files such as media files.
127inline_xattr Enable the inline xattrs feature. 127inline_xattr Enable the inline xattrs feature.
128noinline_xattr Disable the inline xattrs feature.
128inline_data Enable the inline data feature: New created small(<~3.4k) 129inline_data Enable the inline data feature: New created small(<~3.4k)
129 files can be written into inode block. 130 files can be written into inode block.
130inline_dentry Enable the inline dir feature: data in new created 131inline_dentry Enable the inline dir feature: data in new created
131 directory entries can be written into inode block. The 132 directory entries can be written into inode block. The
132 space of inode block which is used to store inline 133 space of inode block which is used to store inline
133 dentries is limited to ~3.4k. 134 dentries is limited to ~3.4k.
134noinline_dentry Diable the inline dentry feature. 135noinline_dentry Disable the inline dentry feature.
135flush_merge Merge concurrent cache_flush commands as much as possible 136flush_merge Merge concurrent cache_flush commands as much as possible
136 to eliminate redundant command issues. If the underlying 137 to eliminate redundant command issues. If the underlying
137 device handles the cache_flush command relatively slowly, 138 device handles the cache_flush command relatively slowly,
@@ -157,6 +158,8 @@ data_flush Enable data flushing before checkpoint in order to
157mode=%s Control block allocation mode which supports "adaptive" 158mode=%s Control block allocation mode which supports "adaptive"
158 and "lfs". In "lfs" mode, there should be no random 159 and "lfs". In "lfs" mode, there should be no random
159 writes towards main area. 160 writes towards main area.
161io_bits=%u Set the bit size of write IO requests. It should be set
162 with "mode=lfs".
160 163
161================================================================================ 164================================================================================
162DEBUGFS ENTRIES 165DEBUGFS ENTRIES
@@ -174,7 +177,7 @@ f2fs. Each file shows the whole f2fs information.
174SYSFS ENTRIES 177SYSFS ENTRIES
175================================================================================ 178================================================================================
176 179
177Information about mounted f2f2 file systems can be found in 180Information about mounted f2fs file systems can be found in
178/sys/fs/f2fs. Each mounted filesystem will have a directory in 181/sys/fs/f2fs. Each mounted filesystem will have a directory in
179/sys/fs/f2fs based on its device name (i.e., /sys/fs/f2fs/sda). 182/sys/fs/f2fs based on its device name (i.e., /sys/fs/f2fs/sda).
180The files in each per-device directory are shown in table below. 183The files in each per-device directory are shown in table below.
diff --git a/Documentation/filesystems/quota.txt b/Documentation/filesystems/quota.txt
index 29fc01552646..32874b06ebe9 100644
--- a/Documentation/filesystems/quota.txt
+++ b/Documentation/filesystems/quota.txt
@@ -6,7 +6,7 @@ Quota subsystem allows system administrator to set limits on used space and
6number of used inodes (inode is a filesystem structure which is associated with 6number of used inodes (inode is a filesystem structure which is associated with
7each file or directory) for users and/or groups. For both used space and number 7each file or directory) for users and/or groups. For both used space and number
8of used inodes there are actually two limits. The first one is called softlimit 8of used inodes there are actually two limits. The first one is called softlimit
9and the second one hardlimit. An user can never exceed a hardlimit for any 9and the second one hardlimit. A user can never exceed a hardlimit for any
10resource (unless he has CAP_SYS_RESOURCE capability). User is allowed to exceed 10resource (unless he has CAP_SYS_RESOURCE capability). User is allowed to exceed
11softlimit but only for limited period of time. This period is called "grace 11softlimit but only for limited period of time. This period is called "grace
12period" or "grace time". When grace time is over, user is not able to allocate 12period" or "grace time". When grace time is over, user is not able to allocate
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index b968084eeac1..569211703721 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -382,7 +382,8 @@ struct inode_operations {
382 int (*permission) (struct inode *, int); 382 int (*permission) (struct inode *, int);
383 int (*get_acl)(struct inode *, int); 383 int (*get_acl)(struct inode *, int);
384 int (*setattr) (struct dentry *, struct iattr *); 384 int (*setattr) (struct dentry *, struct iattr *);
385 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *); 385 int (*getattr) (const struct path *, struct dentry *, struct kstat *,
386 u32, unsigned int);
386 ssize_t (*listxattr) (struct dentry *, char *, size_t); 387 ssize_t (*listxattr) (struct dentry *, char *, size_t);
387 void (*update_time)(struct inode *, struct timespec *, int); 388 void (*update_time)(struct inode *, struct timespec *, int);
388 int (*atomic_open)(struct inode *, struct dentry *, struct file *, 389 int (*atomic_open)(struct inode *, struct dentry *, struct file *,
diff --git a/Documentation/firmware_class/README b/Documentation/firmware_class/README
deleted file mode 100644
index cafdca8b3b15..000000000000
--- a/Documentation/firmware_class/README
+++ /dev/null
@@ -1,128 +0,0 @@
1
2 request_firmware() hotplug interface:
3 ------------------------------------
4 Copyright (C) 2003 Manuel Estrada Sainz
5
6 Why:
7 ---
8
9 Today, the most extended way to use firmware in the Linux kernel is linking
10 it statically in a header file. Which has political and technical issues:
11
12 1) Some firmware is not legal to redistribute.
13 2) The firmware occupies memory permanently, even though it often is just
14 used once.
15 3) Some people, like the Debian crowd, don't consider some firmware free
16 enough and remove entire drivers (e.g.: keyspan).
17
18 High level behavior (mixed):
19 ============================
20
21 1), kernel(driver):
22 - calls request_firmware(&fw_entry, $FIRMWARE, device)
23 - kernel searches the firmware image with name $FIRMWARE directly
24 in the below search path of root filesystem:
25 User customized search path by module parameter 'path'[1]
26 "/lib/firmware/updates/" UTS_RELEASE,
27 "/lib/firmware/updates",
28 "/lib/firmware/" UTS_RELEASE,
29 "/lib/firmware"
30 - If found, goto 7), else goto 2)
31
32 [1], the 'path' is a string parameter which length should be less
33 than 256, user should pass 'firmware_class.path=$CUSTOMIZED_PATH'
34 if firmware_class is built in kernel(the general situation)
35
36 2), userspace:
37 - /sys/class/firmware/xxx/{loading,data} appear.
38 - hotplug gets called with a firmware identifier in $FIRMWARE
39 and the usual hotplug environment.
40 - hotplug: echo 1 > /sys/class/firmware/xxx/loading
41
42 3), kernel: Discard any previous partial load.
43
44 4), userspace:
45 - hotplug: cat appropriate_firmware_image > \
46 /sys/class/firmware/xxx/data
47
48 5), kernel: grows a buffer in PAGE_SIZE increments to hold the image as it
49 comes in.
50
51 6), userspace:
52 - hotplug: echo 0 > /sys/class/firmware/xxx/loading
53
54 7), kernel: request_firmware() returns and the driver has the firmware
55 image in fw_entry->{data,size}. If something went wrong
56 request_firmware() returns non-zero and fw_entry is set to
57 NULL.
58
59 8), kernel(driver): Driver code calls release_firmware(fw_entry) releasing
60 the firmware image and any related resource.
61
62 High level behavior (driver code):
63 ==================================
64
65 if(request_firmware(&fw_entry, $FIRMWARE, device) == 0)
66 copy_fw_to_device(fw_entry->data, fw_entry->size);
67 release_firmware(fw_entry);
68
69 Sample/simple hotplug script:
70 ============================
71
72 # Both $DEVPATH and $FIRMWARE are already provided in the environment.
73
74 HOTPLUG_FW_DIR=/usr/lib/hotplug/firmware/
75
76 echo 1 > /sys/$DEVPATH/loading
77 cat $HOTPLUG_FW_DIR/$FIRMWARE > /sys/$DEVPATH/data
78 echo 0 > /sys/$DEVPATH/loading
79
80 Random notes:
81 ============
82
83 - "echo -1 > /sys/class/firmware/xxx/loading" will cancel the load at
84 once and make request_firmware() return with error.
85
86 - firmware_data_read() and firmware_loading_show() are just provided
87 for testing and completeness, they are not called in normal use.
88
89 - There is also /sys/class/firmware/timeout which holds a timeout in
90 seconds for the whole load operation.
91
92 - request_firmware_nowait() is also provided for convenience in
93 user contexts to request firmware asynchronously, but can't be called
94 in atomic contexts.
95
96
97 about in-kernel persistence:
98 ---------------------------
99 Under some circumstances, as explained below, it would be interesting to keep
100 firmware images in non-swappable kernel memory or even in the kernel image
101 (probably within initramfs).
102
103 Note that this functionality has not been implemented.
104
105 - Why OPTIONAL in-kernel persistence may be a good idea sometimes:
106
107 - If the device that needs the firmware is needed to access the
108 filesystem. When upon some error the device has to be reset and the
109 firmware reloaded, it won't be possible to get it from userspace.
110 e.g.:
111 - A diskless client with a network card that needs firmware.
112 - The filesystem is stored in a disk behind an scsi device
113 that needs firmware.
114 - Replacing buggy DSDT/SSDT ACPI tables on boot.
115 Note: this would require the persistent objects to be included
116 within the kernel image, probably within initramfs.
117
118 And the same device can be needed to access the filesystem or not depending
119 on the setup, so I think that the choice on what firmware to make
120 persistent should be left to userspace.
121
122 about firmware cache:
123 --------------------
124 After firmware cache mechanism is introduced during system sleep,
125 request_firmware can be called safely inside device's suspend and
126 resume callback, and callers needn't cache the firmware by
127 themselves any more for dealing with firmware loss during system
128 resume.
diff --git a/Documentation/fpga/fpga-mgr.txt b/Documentation/fpga/fpga-mgr.txt
index 86ee5078fd03..78f197fadfd1 100644
--- a/Documentation/fpga/fpga-mgr.txt
+++ b/Documentation/fpga/fpga-mgr.txt
@@ -22,7 +22,16 @@ To program the FPGA from a file or from a buffer:
22 struct fpga_image_info *info, 22 struct fpga_image_info *info,
23 const char *buf, size_t count); 23 const char *buf, size_t count);
24 24
25Load the FPGA from an image which exists as a buffer in memory. 25Load the FPGA from an image which exists as a contiguous buffer in
26memory. Allocating contiguous kernel memory for the buffer should be avoided,
27users are encouraged to use the _sg interface instead of this.
28
29 int fpga_mgr_buf_load_sg(struct fpga_manager *mgr,
30 struct fpga_image_info *info,
31 struct sg_table *sgt);
32
33Load the FPGA from an image from non-contiguous in memory. Callers can
34construct a sg_table using alloc_page backed memory.
26 35
27 int fpga_mgr_firmware_load(struct fpga_manager *mgr, 36 int fpga_mgr_firmware_load(struct fpga_manager *mgr,
28 struct fpga_image_info *info, 37 struct fpga_image_info *info,
@@ -166,7 +175,7 @@ success or negative error codes otherwise.
166 175
167The programming sequence is: 176The programming sequence is:
168 1. .write_init 177 1. .write_init
169 2. .write (may be called once or multiple times) 178 2. .write or .write_sg (may be called once or multiple times)
170 3. .write_complete 179 3. .write_complete
171 180
172The .write_init function will prepare the FPGA to receive the image data. The 181The .write_init function will prepare the FPGA to receive the image data. The
@@ -176,7 +185,11 @@ buffer up at least this much before starting.
176 185
177The .write function writes a buffer to the FPGA. The buffer may be contain the 186The .write function writes a buffer to the FPGA. The buffer may be contain the
178whole FPGA image or may be a smaller chunk of an FPGA image. In the latter 187whole FPGA image or may be a smaller chunk of an FPGA image. In the latter
179case, this function is called multiple times for successive chunks. 188case, this function is called multiple times for successive chunks. This interface
189is suitable for drivers which use PIO.
190
191The .write_sg version behaves the same as .write except the input is a sg_table
192scatter list. This interface is suitable for drivers which use DMA.
180 193
181The .write_complete function is called after all the image has been written 194The .write_complete function is called after all the image has been written
182to put the FPGA into operating mode. 195to put the FPGA into operating mode.
diff --git a/Documentation/gpio/driver.txt b/Documentation/gpio/driver.txt
index ad8f0c0cd13f..fc1d2f83564d 100644
--- a/Documentation/gpio/driver.txt
+++ b/Documentation/gpio/driver.txt
@@ -41,34 +41,71 @@ In the gpiolib framework each GPIO controller is packaged as a "struct
41gpio_chip" (see linux/gpio/driver.h for its complete definition) with members 41gpio_chip" (see linux/gpio/driver.h for its complete definition) with members
42common to each controller of that type: 42common to each controller of that type:
43 43
44 - methods to establish GPIO direction 44 - methods to establish GPIO line direction
45 - methods used to access GPIO values 45 - methods used to access GPIO line values
46 - method to return the IRQ number associated to a given GPIO 46 - method to set electrical configuration to a a given GPIO line
47 - method to return the IRQ number associated to a given GPIO line
47 - flag saying whether calls to its methods may sleep 48 - flag saying whether calls to its methods may sleep
49 - optional line names array to identify lines
48 - optional debugfs dump method (showing extra state like pullup config) 50 - optional debugfs dump method (showing extra state like pullup config)
49 - optional base number (will be automatically assigned if omitted) 51 - optional base number (will be automatically assigned if omitted)
50 - label for diagnostics and GPIOs mapping using platform data 52 - optional label for diagnostics and GPIO chip mapping using platform data
51 53
52The code implementing a gpio_chip should support multiple instances of the 54The code implementing a gpio_chip should support multiple instances of the
53controller, possibly using the driver model. That code will configure each 55controller, possibly using the driver model. That code will configure each
54gpio_chip and issue gpiochip_add(). Removing a GPIO controller should be rare; 56gpio_chip and issue gpiochip_add[_data]() or devm_gpiochip_add_data().
55use gpiochip_remove() when it is unavoidable. 57Removing a GPIO controller should be rare; use [devm_]gpiochip_remove() when
58it is unavoidable.
56 59
57Most often a gpio_chip is part of an instance-specific structure with state not 60Often a gpio_chip is part of an instance-specific structure with states not
58exposed by the GPIO interfaces, such as addressing, power management, and more. 61exposed by the GPIO interfaces, such as addressing, power management, and more.
59Chips such as codecs will have complex non-GPIO state. 62Chips such as audio codecs will have complex non-GPIO states.
60 63
61Any debugfs dump method should normally ignore signals which haven't been 64Any debugfs dump method should normally ignore signals which haven't been
62requested as GPIOs. They can use gpiochip_is_requested(), which returns either 65requested as GPIOs. They can use gpiochip_is_requested(), which returns either
63NULL or the label associated with that GPIO when it was requested. 66NULL or the label associated with that GPIO when it was requested.
64 67
65RT_FULL: GPIO driver should not use spinlock_t or any sleepable APIs 68RT_FULL: the GPIO driver should not use spinlock_t or any sleepable APIs
66(like PM runtime) in its gpio_chip implementation (.get/.set and direction 69(like PM runtime) in its gpio_chip implementation (.get/.set and direction
67control callbacks) if it is expected to call GPIO APIs from atomic context 70control callbacks) if it is expected to call GPIO APIs from atomic context
68on -RT (inside hard IRQ handlers and similar contexts). Normally this should 71on -RT (inside hard IRQ handlers and similar contexts). Normally this should
69not be required. 72not be required.
70 73
71 74
75GPIO electrical configuration
76-----------------------------
77
78GPIOs can be configured for several electrical modes of operation by using the
79.set_config() callback. Currently this API supports setting debouncing and
80single-ended modes (open drain/open source). These settings are described
81below.
82
83The .set_config() callback uses the same enumerators and configuration
84semantics as the generic pin control drivers. This is not a coincidence: it is
85possible to assign the .set_config() to the function gpiochip_generic_config()
86which will result in pinctrl_gpio_set_config() being called and eventually
87ending up in the pin control back-end "behind" the GPIO controller, usually
88closer to the actual pins. This way the pin controller can manage the below
89listed GPIO configurations.
90
91
92GPIOs with debounce support
93---------------------------
94
95Debouncing is a configuration set to a pin indicating that it is connected to
96a mechanical switch or button, or similar that may bounce. Bouncing means the
97line is pulled high/low quickly at very short intervals for mechanical
98reasons. This can result in the value being unstable or irqs fireing repeatedly
99unless the line is debounced.
100
101Debouncing in practice involves setting up a timer when something happens on
102the line, wait a little while and then sample the line again, so see if it
103still has the same value (low or high). This could also be repeated by a clever
104state machine, waiting for a line to become stable. In either case, it sets
105a certain number of milliseconds for debouncing, or just "on/off" if that time
106is not configurable.
107
108
72GPIOs with open drain/source support 109GPIOs with open drain/source support
73------------------------------------ 110------------------------------------
74 111
diff --git a/Documentation/gpu/drm-kms.rst b/Documentation/gpu/drm-kms.rst
index 0c9abdc0ee31..4d4068855ec4 100644
--- a/Documentation/gpu/drm-kms.rst
+++ b/Documentation/gpu/drm-kms.rst
@@ -48,11 +48,17 @@ CRTC Abstraction
48================ 48================
49 49
50.. kernel-doc:: drivers/gpu/drm/drm_crtc.c 50.. kernel-doc:: drivers/gpu/drm/drm_crtc.c
51 :export: 51 :doc: overview
52
53CRTC Functions Reference
54--------------------------------
52 55
53.. kernel-doc:: include/drm/drm_crtc.h 56.. kernel-doc:: include/drm/drm_crtc.h
54 :internal: 57 :internal:
55 58
59.. kernel-doc:: drivers/gpu/drm/drm_crtc.c
60 :export:
61
56Frame Buffer Abstraction 62Frame Buffer Abstraction
57======================== 63========================
58 64
diff --git a/Documentation/gpu/drm-mm.rst b/Documentation/gpu/drm-mm.rst
index cb5daffcd6be..f5760b140f13 100644
--- a/Documentation/gpu/drm-mm.rst
+++ b/Documentation/gpu/drm-mm.rst
@@ -34,25 +34,26 @@ TTM initialization
34------------------ 34------------------
35 35
36 **Warning** 36 **Warning**
37
38 This section is outdated. 37 This section is outdated.
39 38
40Drivers wishing to support TTM must fill out a drm_bo_driver 39Drivers wishing to support TTM must pass a filled :c:type:`ttm_bo_driver
41structure. The structure contains several fields with function pointers 40<ttm_bo_driver>` structure to ttm_bo_device_init, together with an
42for initializing the TTM, allocating and freeing memory, waiting for 41initialized global reference to the memory manager. The ttm_bo_driver
43command completion and fence synchronization, and memory migration. See 42structure contains several fields with function pointers for
44the radeon_ttm.c file for an example of usage. 43initializing the TTM, allocating and freeing memory, waiting for command
44completion and fence synchronization, and memory migration.
45 45
46The ttm_global_reference structure is made up of several fields: 46The :c:type:`struct drm_global_reference <drm_global_reference>` is made
47up of several fields:
47 48
48.. code-block:: c 49.. code-block:: c
49 50
50 struct ttm_global_reference { 51 struct drm_global_reference {
51 enum ttm_global_types global_type; 52 enum ttm_global_types global_type;
52 size_t size; 53 size_t size;
53 void *object; 54 void *object;
54 int (*init) (struct ttm_global_reference *); 55 int (*init) (struct drm_global_reference *);
55 void (*release) (struct ttm_global_reference *); 56 void (*release) (struct drm_global_reference *);
56 }; 57 };
57 58
58 59
@@ -76,6 +77,12 @@ ttm_bo_global_release(), respectively. Also, like the previous
76object, ttm_global_item_ref() is used to create an initial reference 77object, ttm_global_item_ref() is used to create an initial reference
77count for the TTM, which will call your initialization function. 78count for the TTM, which will call your initialization function.
78 79
80See the radeon_ttm.c file for an example of usage.
81
82.. kernel-doc:: drivers/gpu/drm/drm_global.c
83 :export:
84
85
79The Graphics Execution Manager (GEM) 86The Graphics Execution Manager (GEM)
80==================================== 87====================================
81 88
@@ -284,10 +291,17 @@ To use :c:func:`drm_gem_mmap()`, drivers must fill the struct
284:c:type:`struct drm_driver <drm_driver>` gem_vm_ops field 291:c:type:`struct drm_driver <drm_driver>` gem_vm_ops field
285with a pointer to VM operations. 292with a pointer to VM operations.
286 293
287struct vm_operations_struct \*gem_vm_ops struct 294The VM operations is a :c:type:`struct vm_operations_struct <vm_operations_struct>`
288vm_operations_struct { void (\*open)(struct vm_area_struct \* area); 295made up of several fields, the more interesting ones being:
289void (\*close)(struct vm_area_struct \* area); int (\*fault)(struct 296
290vm_area_struct \*vma, struct vm_fault \*vmf); }; 297.. code-block:: c
298
299 struct vm_operations_struct {
300 void (*open)(struct vm_area_struct * area);
301 void (*close)(struct vm_area_struct * area);
302 int (*fault)(struct vm_fault *vmf);
303 };
304
291 305
292The open and close operations must update the GEM object reference 306The open and close operations must update the GEM object reference
293count. Drivers can use the :c:func:`drm_gem_vm_open()` and 307count. Drivers can use the :c:func:`drm_gem_vm_open()` and
@@ -303,6 +317,17 @@ created.
303Drivers that want to map the GEM object upfront instead of handling page 317Drivers that want to map the GEM object upfront instead of handling page
304faults can implement their own mmap file operation handler. 318faults can implement their own mmap file operation handler.
305 319
320For platforms without MMU the GEM core provides a helper method
321:c:func:`drm_gem_cma_get_unmapped_area`. The mmap() routines will call
322this to get a proposed address for the mapping.
323
324To use :c:func:`drm_gem_cma_get_unmapped_area`, drivers must fill the
325struct :c:type:`struct file_operations <file_operations>` get_unmapped_area
326field with a pointer on :c:func:`drm_gem_cma_get_unmapped_area`.
327
328More detailed information about get_unmapped_area can be found in
329Documentation/nommu-mmap.txt
330
306Memory Coherency 331Memory Coherency
307---------------- 332----------------
308 333
@@ -442,7 +467,7 @@ LRU Scan/Eviction Support
442------------------------- 467-------------------------
443 468
444.. kernel-doc:: drivers/gpu/drm/drm_mm.c 469.. kernel-doc:: drivers/gpu/drm/drm_mm.c
445 :doc: lru scan roaster 470 :doc: lru scan roster
446 471
447DRM MM Range Allocator Function References 472DRM MM Range Allocator Function References
448------------------------------------------ 473------------------------------------------
@@ -452,3 +477,9 @@ DRM MM Range Allocator Function References
452 477
453.. kernel-doc:: include/drm/drm_mm.h 478.. kernel-doc:: include/drm/drm_mm.h
454 :internal: 479 :internal:
480
481DRM Cache Handling
482==================
483
484.. kernel-doc:: drivers/gpu/drm/drm_cache.c
485 :export:
diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst
index de3ac9f90f8f..fcc228ef5bc4 100644
--- a/Documentation/gpu/drm-uapi.rst
+++ b/Documentation/gpu/drm-uapi.rst
@@ -156,8 +156,12 @@ other hand, a driver requires shared state between clients which is
156visible to user-space and accessible beyond open-file boundaries, they 156visible to user-space and accessible beyond open-file boundaries, they
157cannot support render nodes. 157cannot support render nodes.
158 158
159
160Testing and validation
161======================
162
159Validating changes with IGT 163Validating changes with IGT
160=========================== 164---------------------------
161 165
162There's a collection of tests that aims to cover the whole functionality of 166There's a collection of tests that aims to cover the whole functionality of
163DRM drivers and that can be used to check that changes to DRM drivers or the 167DRM drivers and that can be used to check that changes to DRM drivers or the
@@ -193,6 +197,12 @@ run-tests.sh is a wrapper around piglit that will execute the tests matching
193the -t options. A report in HTML format will be available in 197the -t options. A report in HTML format will be available in
194./results/html/index.html. Results can be compared with piglit. 198./results/html/index.html. Results can be compared with piglit.
195 199
200Display CRC Support
201-------------------
202
203.. kernel-doc:: drivers/gpu/drm/drm_debugfs_crc.c
204 :doc: CRC ABI
205
196VBlank event handling 206VBlank event handling
197===================== 207=====================
198 208
@@ -209,16 +219,3 @@ DRM_IOCTL_MODESET_CTL
209 mode setting, since on many devices the vertical blank counter is 219 mode setting, since on many devices the vertical blank counter is
210 reset to 0 at some point during modeset. Modern drivers should not 220 reset to 0 at some point during modeset. Modern drivers should not
211 call this any more since with kernel mode setting it is a no-op. 221 call this any more since with kernel mode setting it is a no-op.
212
213This second part of the GPU Driver Developer's Guide documents driver
214code, implementation details and also all the driver-specific userspace
215interfaces. Especially since all hardware-acceleration interfaces to
216userspace are driver specific for efficiency and other reasons these
217interfaces can be rather substantial. Hence every driver has its own
218chapter.
219
220Testing and validation
221======================
222
223.. kernel-doc:: drivers/gpu/drm/drm_debugfs_crc.c
224 :doc: CRC ABI
diff --git a/Documentation/gpu/i915.rst b/Documentation/gpu/i915.rst
index 117d2ab7a5f7..b0d6709b8600 100644
--- a/Documentation/gpu/i915.rst
+++ b/Documentation/gpu/i915.rst
@@ -144,6 +144,15 @@ High Definition Audio
144.. kernel-doc:: include/drm/i915_component.h 144.. kernel-doc:: include/drm/i915_component.h
145 :internal: 145 :internal:
146 146
147Intel HDMI LPE Audio Support
148----------------------------
149
150.. kernel-doc:: drivers/gpu/drm/i915/intel_lpe_audio.c
151 :doc: LPE Audio integration for HDMI or DP playback
152
153.. kernel-doc:: drivers/gpu/drm/i915/intel_lpe_audio.c
154 :internal:
155
147Panel Self Refresh PSR (PSR/SRD) 156Panel Self Refresh PSR (PSR/SRD)
148-------------------------------- 157--------------------------------
149 158
@@ -213,6 +222,18 @@ Video BIOS Table (VBT)
213.. kernel-doc:: drivers/gpu/drm/i915/intel_vbt_defs.h 222.. kernel-doc:: drivers/gpu/drm/i915/intel_vbt_defs.h
214 :internal: 223 :internal:
215 224
225Display PLLs
226------------
227
228.. kernel-doc:: drivers/gpu/drm/i915/intel_dpll_mgr.c
229 :doc: Display PLLs
230
231.. kernel-doc:: drivers/gpu/drm/i915/intel_dpll_mgr.c
232 :internal:
233
234.. kernel-doc:: drivers/gpu/drm/i915/intel_dpll_mgr.h
235 :internal:
236
216Memory Management and Command Submission 237Memory Management and Command Submission
217======================================== 238========================================
218 239
@@ -356,4 +377,95 @@ switch_mm
356.. kernel-doc:: drivers/gpu/drm/i915/i915_trace.h 377.. kernel-doc:: drivers/gpu/drm/i915/i915_trace.h
357 :doc: switch_mm tracepoint 378 :doc: switch_mm tracepoint
358 379
380Perf
381====
382
383Overview
384--------
385.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
386 :doc: i915 Perf Overview
387
388Comparison with Core Perf
389-------------------------
390.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
391 :doc: i915 Perf History and Comparison with Core Perf
392
393i915 Driver Entry Points
394------------------------
395
396This section covers the entrypoints exported outside of i915_perf.c to
397integrate with drm/i915 and to handle the `DRM_I915_PERF_OPEN` ioctl.
398
399.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
400 :functions: i915_perf_init
401.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
402 :functions: i915_perf_fini
403.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
404 :functions: i915_perf_register
405.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
406 :functions: i915_perf_unregister
407.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
408 :functions: i915_perf_open_ioctl
409.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
410 :functions: i915_perf_release
411
412i915 Perf Stream
413----------------
414
415This section covers the stream-semantics-agnostic structures and functions
416for representing an i915 perf stream FD and associated file operations.
417
418.. kernel-doc:: drivers/gpu/drm/i915/i915_drv.h
419 :functions: i915_perf_stream
420.. kernel-doc:: drivers/gpu/drm/i915/i915_drv.h
421 :functions: i915_perf_stream_ops
422
423.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
424 :functions: read_properties_unlocked
425.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
426 :functions: i915_perf_open_ioctl_locked
427.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
428 :functions: i915_perf_destroy_locked
429.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
430 :functions: i915_perf_read
431.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
432 :functions: i915_perf_ioctl
433.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
434 :functions: i915_perf_enable_locked
435.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
436 :functions: i915_perf_disable_locked
437.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
438 :functions: i915_perf_poll
439.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
440 :functions: i915_perf_poll_locked
441
442i915 Perf Observation Architecture Stream
443-----------------------------------------
444
445.. kernel-doc:: drivers/gpu/drm/i915/i915_drv.h
446 :functions: i915_oa_ops
447
448.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
449 :functions: i915_oa_stream_init
450.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
451 :functions: i915_oa_read
452.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
453 :functions: i915_oa_stream_enable
454.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
455 :functions: i915_oa_stream_disable
456.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
457 :functions: i915_oa_wait_unlocked
458.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
459 :functions: i915_oa_poll_wait
460
461All i915 Perf Internals
462-----------------------
463
464This section simply includes all currently documented i915 perf internals, in
465no particular order, but may include some more minor utilities or platform
466specific details than found in the more high-level sections.
467
468.. kernel-doc:: drivers/gpu/drm/i915/i915_perf.c
469 :internal:
470
359.. WARNING: DOCPROC directive not supported: !Cdrivers/gpu/drm/i915/i915_irq.c 471.. WARNING: DOCPROC directive not supported: !Cdrivers/gpu/drm/i915/i915_irq.c
diff --git a/Documentation/gpu/index.rst b/Documentation/gpu/index.rst
index 367d7c36b8e9..f81278a7c2cc 100644
--- a/Documentation/gpu/index.rst
+++ b/Documentation/gpu/index.rst
@@ -11,6 +11,7 @@ Linux GPU Driver Developer's Guide
11 drm-kms-helpers 11 drm-kms-helpers
12 drm-uapi 12 drm-uapi
13 i915 13 i915
14 tinydrm
14 vga-switcheroo 15 vga-switcheroo
15 vgaarbiter 16 vgaarbiter
16 17
diff --git a/Documentation/gpu/introduction.rst b/Documentation/gpu/introduction.rst
index 1903595b5310..eb284eb748ba 100644
--- a/Documentation/gpu/introduction.rst
+++ b/Documentation/gpu/introduction.rst
@@ -23,13 +23,12 @@ For consistency this documentation uses American English. Abbreviations
23are written as all-uppercase, for example: DRM, KMS, IOCTL, CRTC, and so 23are written as all-uppercase, for example: DRM, KMS, IOCTL, CRTC, and so
24on. To aid in reading, documentations make full use of the markup 24on. To aid in reading, documentations make full use of the markup
25characters kerneldoc provides: @parameter for function parameters, 25characters kerneldoc provides: @parameter for function parameters,
26@member for structure members, &structure to reference structures and 26@member for structure members (within the same structure), &struct structure to
27function() for functions. These all get automatically hyperlinked if 27reference structures and function() for functions. These all get automatically
28kerneldoc for the referenced objects exists. When referencing entries in 28hyperlinked if kerneldoc for the referenced objects exists. When referencing
29function vtables please use ->vfunc(). Note that kerneldoc does not 29entries in function vtables (and structure members in general) please use
30support referencing struct members directly, so please add a reference 30&vtable_name.vfunc. Unfortunately this does not yet yield a direct link to the
31to the vtable struct somewhere in the same paragraph or at least 31member, only the structure.
32section.
33 32
34Except in special situations (to separate locked from unlocked variants) 33Except in special situations (to separate locked from unlocked variants)
35locking requirements for functions aren't documented in the kerneldoc. 34locking requirements for functions aren't documented in the kerneldoc.
@@ -49,3 +48,5 @@ section name should be all upper-case or not, and whether it should end
49in a colon or not. Go with the file-local style. Other common section 48in a colon or not. Go with the file-local style. Other common section
50names are "Notes" with information for dangerous or tricky corner cases, 49names are "Notes" with information for dangerous or tricky corner cases,
51and "FIXME" where the interface could be cleaned up. 50and "FIXME" where the interface could be cleaned up.
51
52Also read the :ref:`guidelines for the kernel documentation at large <doc_guide>`.
diff --git a/Documentation/gpu/tinydrm.rst b/Documentation/gpu/tinydrm.rst
new file mode 100644
index 000000000000..a913644bfc19
--- /dev/null
+++ b/Documentation/gpu/tinydrm.rst
@@ -0,0 +1,42 @@
1==========================
2drm/tinydrm Driver library
3==========================
4
5.. kernel-doc:: drivers/gpu/drm/tinydrm/core/tinydrm-core.c
6 :doc: overview
7
8Core functionality
9==================
10
11.. kernel-doc:: drivers/gpu/drm/tinydrm/core/tinydrm-core.c
12 :doc: core
13
14.. kernel-doc:: include/drm/tinydrm/tinydrm.h
15 :internal:
16
17.. kernel-doc:: drivers/gpu/drm/tinydrm/core/tinydrm-core.c
18 :export:
19
20.. kernel-doc:: drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c
21 :export:
22
23Additional helpers
24==================
25
26.. kernel-doc:: include/drm/tinydrm/tinydrm-helpers.h
27 :internal:
28
29.. kernel-doc:: drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
30 :export:
31
32MIPI DBI Compatible Controllers
33===============================
34
35.. kernel-doc:: drivers/gpu/drm/tinydrm/mipi-dbi.c
36 :doc: overview
37
38.. kernel-doc:: include/drm/tinydrm/mipi-dbi.h
39 :internal:
40
41.. kernel-doc:: drivers/gpu/drm/tinydrm/mipi-dbi.c
42 :export:
diff --git a/Documentation/hwmon/ds1621 b/Documentation/hwmon/ds1621
index f775e612f582..fa3407997795 100644
--- a/Documentation/hwmon/ds1621
+++ b/Documentation/hwmon/ds1621
@@ -117,10 +117,10 @@ support, which is achieved via the R0 and R1 config register bits, where:
117 117
118R0..R1 118R0..R1
119------ 119------
120 0 0 => 9 bits, 0.5 degrees Celcius 120 0 0 => 9 bits, 0.5 degrees Celsius
121 1 0 => 10 bits, 0.25 degrees Celcius 121 1 0 => 10 bits, 0.25 degrees Celsius
122 0 1 => 11 bits, 0.125 degrees Celcius 122 0 1 => 11 bits, 0.125 degrees Celsius
123 1 1 => 12 bits, 0.0625 degrees Celcius 123 1 1 => 12 bits, 0.0625 degrees Celsius
124 124
125Note: 125Note:
126At initial device power-on, the default resolution is set to 12-bits. 126At initial device power-on, the default resolution is set to 12-bits.
diff --git a/Documentation/i2c/busses/i2c-i801 b/Documentation/i2c/busses/i2c-i801
index 1bba38dd2637..820d9040de16 100644
--- a/Documentation/i2c/busses/i2c-i801
+++ b/Documentation/i2c/busses/i2c-i801
@@ -33,6 +33,7 @@ Supported adapters:
33 * Intel DNV (SOC) 33 * Intel DNV (SOC)
34 * Intel Broxton (SOC) 34 * Intel Broxton (SOC)
35 * Intel Lewisburg (PCH) 35 * Intel Lewisburg (PCH)
36 * Intel Gemini Lake (SOC)
36 Datasheets: Publicly available at the Intel website 37 Datasheets: Publicly available at the Intel website
37 38
38On Intel Patsburg and later chipsets, both the normal host SMBus controller 39On Intel Patsburg and later chipsets, both the normal host SMBus controller
diff --git a/Documentation/i2c/muxes/i2c-mux-gpio b/Documentation/i2c/muxes/i2c-mux-gpio
index d4d91a53fc39..7a8d7d261632 100644
--- a/Documentation/i2c/muxes/i2c-mux-gpio
+++ b/Documentation/i2c/muxes/i2c-mux-gpio
@@ -1,11 +1,11 @@
1Kernel driver i2c-gpio-mux 1Kernel driver i2c-mux-gpio
2 2
3Author: Peter Korsgaard <peter.korsgaard@barco.com> 3Author: Peter Korsgaard <peter.korsgaard@barco.com>
4 4
5Description 5Description
6----------- 6-----------
7 7
8i2c-gpio-mux is an i2c mux driver providing access to I2C bus segments 8i2c-mux-gpio is an i2c mux driver providing access to I2C bus segments
9from a master I2C bus and a hardware MUX controlled through GPIO pins. 9from a master I2C bus and a hardware MUX controlled through GPIO pins.
10 10
11E.G.: 11E.G.:
@@ -26,16 +26,16 @@ according to the settings of the GPIO pins 1..N.
26Usage 26Usage
27----- 27-----
28 28
29i2c-gpio-mux uses the platform bus, so you need to provide a struct 29i2c-mux-gpio uses the platform bus, so you need to provide a struct
30platform_device with the platform_data pointing to a struct 30platform_device with the platform_data pointing to a struct
31gpio_i2cmux_platform_data with the I2C adapter number of the master 31i2c_mux_gpio_platform_data with the I2C adapter number of the master
32bus, the number of bus segments to create and the GPIO pins used 32bus, the number of bus segments to create and the GPIO pins used
33to control it. See include/linux/i2c-gpio-mux.h for details. 33to control it. See include/linux/i2c-mux-gpio.h for details.
34 34
35E.G. something like this for a MUX providing 4 bus segments 35E.G. something like this for a MUX providing 4 bus segments
36controlled through 3 GPIO pins: 36controlled through 3 GPIO pins:
37 37
38#include <linux/i2c-gpio-mux.h> 38#include <linux/i2c-mux-gpio.h>
39#include <linux/platform_device.h> 39#include <linux/platform_device.h>
40 40
41static const unsigned myboard_gpiomux_gpios[] = { 41static const unsigned myboard_gpiomux_gpios[] = {
@@ -46,7 +46,7 @@ static const unsigned myboard_gpiomux_values[] = {
46 0, 1, 2, 3 46 0, 1, 2, 3
47}; 47};
48 48
49static struct gpio_i2cmux_platform_data myboard_i2cmux_data = { 49static struct i2c_mux_gpio_platform_data myboard_i2cmux_data = {
50 .parent = 1, 50 .parent = 1,
51 .base_nr = 2, /* optional */ 51 .base_nr = 2, /* optional */
52 .values = myboard_gpiomux_values, 52 .values = myboard_gpiomux_values,
@@ -57,7 +57,7 @@ static struct gpio_i2cmux_platform_data myboard_i2cmux_data = {
57}; 57};
58 58
59static struct platform_device myboard_i2cmux = { 59static struct platform_device myboard_i2cmux = {
60 .name = "i2c-gpio-mux", 60 .name = "i2c-mux-gpio",
61 .id = 0, 61 .id = 0,
62 .dev = { 62 .dev = {
63 .platform_data = &myboard_i2cmux_data, 63 .platform_data = &myboard_i2cmux_data,
@@ -66,14 +66,14 @@ static struct platform_device myboard_i2cmux = {
66 66
67If you don't know the absolute GPIO pin numbers at registration time, 67If you don't know the absolute GPIO pin numbers at registration time,
68you can instead provide a chip name (.chip_name) and relative GPIO pin 68you can instead provide a chip name (.chip_name) and relative GPIO pin
69numbers, and the i2c-gpio-mux driver will do the work for you, 69numbers, and the i2c-mux-gpio driver will do the work for you,
70including deferred probing if the GPIO chip isn't immediately 70including deferred probing if the GPIO chip isn't immediately
71available. 71available.
72 72
73Device Registration 73Device Registration
74------------------- 74-------------------
75 75
76When registering your i2c-gpio-mux device, you should pass the number 76When registering your i2c-mux-gpio device, you should pass the number
77of any GPIO pin it uses as the device ID. This guarantees that every 77of any GPIO pin it uses as the device ID. This guarantees that every
78instance has a different ID. 78instance has a different ID.
79 79
diff --git a/Documentation/index.rst b/Documentation/index.rst
index cb5d77699c60..f6e641a54bbc 100644
--- a/Documentation/index.rst
+++ b/Documentation/index.rst
@@ -47,7 +47,7 @@ These books get into the details of how specific kernel subsystems work
47from the point of view of a kernel developer. Much of the information here 47from the point of view of a kernel developer. Much of the information here
48is taken directly from the kernel source, with supplemental material added 48is taken directly from the kernel source, with supplemental material added
49as needed (or at least as we managed to add it — probably *not* all that is 49as needed (or at least as we managed to add it — probably *not* all that is
50needed). 50needed).
51 51
52.. toctree:: 52.. toctree::
53 :maxdepth: 2 53 :maxdepth: 2
@@ -68,6 +68,14 @@ Korean translations
68 68
69 translations/ko_KR/index 69 translations/ko_KR/index
70 70
71Chinese translations
72--------------------
73
74.. toctree::
75 :maxdepth: 1
76
77 translations/zh_CN/index
78
71Indices and tables 79Indices and tables
72================== 80==================
73 81
diff --git a/Documentation/input/input.txt b/Documentation/input/input.txt
index 0acfddbe2028..7ebce100fe90 100644
--- a/Documentation/input/input.txt
+++ b/Documentation/input/input.txt
@@ -279,10 +279,10 @@ struct input_event {
279 279
280 'time' is the timestamp, it returns the time at which the event happened. 280 'time' is the timestamp, it returns the time at which the event happened.
281Type is for example EV_REL for relative moment, EV_KEY for a keypress or 281Type is for example EV_REL for relative moment, EV_KEY for a keypress or
282release. More types are defined in include/linux/input.h. 282release. More types are defined in include/uapi/linux/input-event-codes.h.
283 283
284 'code' is event code, for example REL_X or KEY_BACKSPACE, again a complete 284 'code' is event code, for example REL_X or KEY_BACKSPACE, again a complete
285list is in include/linux/input.h. 285list is in include/uapi/linux/input-event-codes.h.
286 286
287 'value' is the value the event carries. Either a relative change for 287 'value' is the value the event carries. Either a relative change for
288EV_REL, absolute new value for EV_ABS (joysticks ...), or 0 for EV_KEY for 288EV_REL, absolute new value for EV_ABS (joysticks ...), or 0 for EV_KEY for
diff --git a/Documentation/ioctl/botching-up-ioctls.txt b/Documentation/ioctl/botching-up-ioctls.txt
index 36138c632f7a..d02cfb48901c 100644
--- a/Documentation/ioctl/botching-up-ioctls.txt
+++ b/Documentation/ioctl/botching-up-ioctls.txt
@@ -24,7 +24,7 @@ Prerequisites
24------------- 24-------------
25 25
26First the prerequisites. Without these you have already failed, because you 26First the prerequisites. Without these you have already failed, because you
27will need to add a a 32-bit compat layer: 27will need to add a 32-bit compat layer:
28 28
29 * Only use fixed sized integers. To avoid conflicts with typedefs in userspace 29 * Only use fixed sized integers. To avoid conflicts with typedefs in userspace
30 the kernel has special types like __u32, __s64. Use them. 30 the kernel has special types like __u32, __s64. Use them.
diff --git a/Documentation/ioctl/ioctl-number.txt b/Documentation/ioctl/ioctl-number.txt
index 81c7f2bb7daf..08244bea5048 100644
--- a/Documentation/ioctl/ioctl-number.txt
+++ b/Documentation/ioctl/ioctl-number.txt
@@ -321,6 +321,7 @@ Code Seq#(hex) Include File Comments
3210xB1 00-1F PPPoX <mailto:mostrows@styx.uwaterloo.ca> 3210xB1 00-1F PPPoX <mailto:mostrows@styx.uwaterloo.ca>
3220xB3 00 linux/mmc/ioctl.h 3220xB3 00 linux/mmc/ioctl.h
3230xB4 00-0F linux/gpio.h <mailto:linux-gpio@vger.kernel.org> 3230xB4 00-0F linux/gpio.h <mailto:linux-gpio@vger.kernel.org>
3240xB5 00-0F uapi/linux/rpmsg.h <mailto:linux-remoteproc@vger.kernel.org>
3240xC0 00-0F linux/usb/iowarrior.h 3250xC0 00-0F linux/usb/iowarrior.h
3250xCA 00-0F uapi/misc/cxl.h 3260xCA 00-0F uapi/misc/cxl.h
3260xCA 80-8F uapi/scsi/cxlflash_ioctl.h 3270xCA 80-8F uapi/scsi/cxlflash_ioctl.h
diff --git a/Documentation/kselftest.txt b/Documentation/kselftest.txt
index e5c7254e73d7..5bd590335839 100644
--- a/Documentation/kselftest.txt
+++ b/Documentation/kselftest.txt
@@ -59,14 +59,14 @@ Install selftests
59================= 59=================
60 60
61You can use kselftest_install.sh tool installs selftests in default 61You can use kselftest_install.sh tool installs selftests in default
62location which is tools/testing/selftests/kselftest or an user specified 62location which is tools/testing/selftests/kselftest or a user specified
63location. 63location.
64 64
65To install selftests in default location: 65To install selftests in default location:
66 $ cd tools/testing/selftests 66 $ cd tools/testing/selftests
67 $ ./kselftest_install.sh 67 $ ./kselftest_install.sh
68 68
69To install selftests in an user specified location: 69To install selftests in a user specified location:
70 $ cd tools/testing/selftests 70 $ cd tools/testing/selftests
71 $ ./kselftest_install.sh install_dir 71 $ ./kselftest_install.sh install_dir
72 72
@@ -95,3 +95,15 @@ In general, the rules for selftests are
95 95
96 * Don't cause the top-level "make run_tests" to fail if your feature is 96 * Don't cause the top-level "make run_tests" to fail if your feature is
97 unconfigured. 97 unconfigured.
98
99Contributing new tests(details)
100===============================
101
102 * Use TEST_GEN_XXX if such binaries or files are generated during
103 compiling.
104 TEST_PROGS, TEST_GEN_PROGS mean it is the excutable tested by
105 default.
106 TEST_PROGS_EXTENDED, TEST_GEN_PROGS_EXTENDED mean it is the
107 executable which is not tested by default.
108 TEST_FILES, TEST_GEN_FILES mean it is the file which is used by
109 test.
diff --git a/Documentation/livepatch/livepatch.txt b/Documentation/livepatch/livepatch.txt
index 7f04e13ec53d..9d2096c7160d 100644
--- a/Documentation/livepatch/livepatch.txt
+++ b/Documentation/livepatch/livepatch.txt
@@ -358,7 +358,7 @@ The current Livepatch implementation has several limitations:
358 Each function has to handle TOC and save LR before it could call 358 Each function has to handle TOC and save LR before it could call
359 the ftrace handler. This operation has to be reverted on return. 359 the ftrace handler. This operation has to be reverted on return.
360 Fortunately, the generic ftrace code has the same problem and all 360 Fortunately, the generic ftrace code has the same problem and all
361 this is is handled on the ftrace level. 361 this is handled on the ftrace level.
362 362
363 363
364 + Kretprobes using the ftrace framework conflict with the patched 364 + Kretprobes using the ftrace framework conflict with the patched
diff --git a/Documentation/md-cluster.txt b/Documentation/md/md-cluster.txt
index 38883276d31c..38883276d31c 100644
--- a/Documentation/md-cluster.txt
+++ b/Documentation/md/md-cluster.txt
diff --git a/Documentation/md/raid5-cache.txt b/Documentation/md/raid5-cache.txt
new file mode 100644
index 000000000000..2b210f295786
--- /dev/null
+++ b/Documentation/md/raid5-cache.txt
@@ -0,0 +1,109 @@
1RAID5 cache
2
3Raid 4/5/6 could include an extra disk for data cache besides normal RAID
4disks. The role of RAID disks isn't changed with the cache disk. The cache disk
5caches data to the RAID disks. The cache can be in write-through (supported
6since 4.4) or write-back mode (supported since 4.10). mdadm (supported since
73.4) has a new option '--write-journal' to create array with cache. Please
8refer to mdadm manual for details. By default (RAID array starts), the cache is
9in write-through mode. A user can switch it to write-back mode by:
10
11echo "write-back" > /sys/block/md0/md/journal_mode
12
13And switch it back to write-through mode by:
14
15echo "write-through" > /sys/block/md0/md/journal_mode
16
17In both modes, all writes to the array will hit cache disk first. This means
18the cache disk must be fast and sustainable.
19
20-------------------------------------
21write-through mode:
22
23This mode mainly fixes the 'write hole' issue. For RAID 4/5/6 array, an unclean
24shutdown can cause data in some stripes to not be in consistent state, eg, data
25and parity don't match. The reason is that a stripe write involves several RAID
26disks and it's possible the writes don't hit all RAID disks yet before the
27unclean shutdown. We call an array degraded if it has inconsistent data. MD
28tries to resync the array to bring it back to normal state. But before the
29resync completes, any system crash will expose the chance of real data
30corruption in the RAID array. This problem is called 'write hole'.
31
32The write-through cache will cache all data on cache disk first. After the data
33is safe on the cache disk, the data will be flushed onto RAID disks. The
34two-step write will guarantee MD can recover correct data after unclean
35shutdown even the array is degraded. Thus the cache can close the 'write hole'.
36
37In write-through mode, MD reports IO completion to upper layer (usually
38filesystems) after the data is safe on RAID disks, so cache disk failure
39doesn't cause data loss. Of course cache disk failure means the array is
40exposed to 'write hole' again.
41
42In write-through mode, the cache disk isn't required to be big. Several
43hundreds megabytes are enough.
44
45--------------------------------------
46write-back mode:
47
48write-back mode fixes the 'write hole' issue too, since all write data is
49cached on cache disk. But the main goal of 'write-back' cache is to speed up
50write. If a write crosses all RAID disks of a stripe, we call it full-stripe
51write. For non-full-stripe writes, MD must read old data before the new parity
52can be calculated. These synchronous reads hurt write throughput. Some writes
53which are sequential but not dispatched in the same time will suffer from this
54overhead too. Write-back cache will aggregate the data and flush the data to
55RAID disks only after the data becomes a full stripe write. This will
56completely avoid the overhead, so it's very helpful for some workloads. A
57typical workload which does sequential write followed by fsync is an example.
58
59In write-back mode, MD reports IO completion to upper layer (usually
60filesystems) right after the data hits cache disk. The data is flushed to raid
61disks later after specific conditions met. So cache disk failure will cause
62data loss.
63
64In write-back mode, MD also caches data in memory. The memory cache includes
65the same data stored on cache disk, so a power loss doesn't cause data loss.
66The memory cache size has performance impact for the array. It's recommended
67the size is big. A user can configure the size by:
68
69echo "2048" > /sys/block/md0/md/stripe_cache_size
70
71Too small cache disk will make the write aggregation less efficient in this
72mode depending on the workloads. It's recommended to use a cache disk with at
73least several gigabytes size in write-back mode.
74
75--------------------------------------
76The implementation:
77
78The write-through and write-back cache use the same disk format. The cache disk
79is organized as a simple write log. The log consists of 'meta data' and 'data'
80pairs. The meta data describes the data. It also includes checksum and sequence
81ID for recovery identification. Data can be IO data and parity data. Data is
82checksumed too. The checksum is stored in the meta data ahead of the data. The
83checksum is an optimization because MD can write meta and data freely without
84worry about the order. MD superblock has a field pointed to the valid meta data
85of log head.
86
87The log implementation is pretty straightforward. The difficult part is the
88order in which MD writes data to cache disk and RAID disks. Specifically, in
89write-through mode, MD calculates parity for IO data, writes both IO data and
90parity to the log, writes the data and parity to RAID disks after the data and
91parity is settled down in log and finally the IO is finished. Read just reads
92from raid disks as usual.
93
94In write-back mode, MD writes IO data to the log and reports IO completion. The
95data is also fully cached in memory at that time, which means read must query
96memory cache. If some conditions are met, MD will flush the data to RAID disks.
97MD will calculate parity for the data and write parity into the log. After this
98is finished, MD will write both data and parity into RAID disks, then MD can
99release the memory cache. The flush conditions could be stripe becomes a full
100stripe write, free cache disk space is low or free in-kernel memory cache space
101is low.
102
103After an unclean shutdown, MD does recovery. MD reads all meta data and data
104from the log. The sequence ID and checksum will help us detect corrupted meta
105data and data. If MD finds a stripe with data and valid parities (1 parity for
106raid4/5 and 2 for raid6), MD will write the data and parities to RAID disks. If
107parities are incompleted, they are discarded. If part of data is corrupted,
108they are discarded too. MD then loads valid data and writes them to RAID disks
109in normal way.
diff --git a/Documentation/media/Makefile b/Documentation/media/Makefile
index 32663602ff25..9b3e70b2cab2 100644
--- a/Documentation/media/Makefile
+++ b/Documentation/media/Makefile
@@ -36,7 +36,7 @@ quiet_cmd_genpdf = GENPDF $2
36 cmd_genpdf = convert $2 $3 36 cmd_genpdf = convert $2 $3
37 37
38quiet_cmd_gendot = DOT $2 38quiet_cmd_gendot = DOT $2
39 cmd_gendot = dot -Tsvg $2 > $3 39 cmd_gendot = dot -Tsvg $2 > $3 || { rm -f $3; exit 1; }
40 40
41%.pdf: %.svg 41%.pdf: %.svg
42 @$(call cmd,genpdf,$<,$@) 42 @$(call cmd,genpdf,$<,$@)
@@ -103,6 +103,7 @@ html: all
103epub: all 103epub: all
104xml: all 104xml: all
105latex: $(IMGPDF) all 105latex: $(IMGPDF) all
106linkcheck:
106 107
107clean: 108clean:
108 -rm -f $(DOTTGT) $(IMGTGT) ${TARGETS} 2>/dev/null 109 -rm -f $(DOTTGT) $(IMGTGT) ${TARGETS} 2>/dev/null
diff --git a/Documentation/media/dvb-drivers/ci.rst b/Documentation/media/dvb-drivers/ci.rst
index 8124bf5ce5ef..69b07e9d1816 100644
--- a/Documentation/media/dvb-drivers/ci.rst
+++ b/Documentation/media/dvb-drivers/ci.rst
@@ -20,7 +20,7 @@ existing low level CI API.
20ca_zap 20ca_zap
21~~~~~~ 21~~~~~~
22 22
23An userspace application, like ``ca_zap`` is required to handle encrypted 23A userspace application, like ``ca_zap`` is required to handle encrypted
24MPEG-TS streams. 24MPEG-TS streams.
25 25
26The ``ca_zap`` userland application is in charge of sending the 26The ``ca_zap`` userland application is in charge of sending the
diff --git a/Documentation/media/uapi/dvb/dvb-frontend-parameters.rst b/Documentation/media/uapi/dvb/dvb-frontend-parameters.rst
index bf31411fc9df..899fd5c3545e 100644
--- a/Documentation/media/uapi/dvb/dvb-frontend-parameters.rst
+++ b/Documentation/media/uapi/dvb/dvb-frontend-parameters.rst
@@ -9,7 +9,7 @@ frontend parameters
9The kind of parameters passed to the frontend device for tuning depend 9The kind of parameters passed to the frontend device for tuning depend
10on the kind of hardware you are using. 10on the kind of hardware you are using.
11 11
12The struct ``dvb_frontend_parameters`` uses an union with specific 12The struct ``dvb_frontend_parameters`` uses a union with specific
13per-system parameters. However, as newer delivery systems required more 13per-system parameters. However, as newer delivery systems required more
14data, the structure size weren't enough to fit, and just extending its 14data, the structure size weren't enough to fit, and just extending its
15size would break the existing applications. So, those parameters were 15size would break the existing applications. So, those parameters were
@@ -23,7 +23,7 @@ So, newer applications should use
23instead, in order to be able to support the newer System Delivery like 23instead, in order to be able to support the newer System Delivery like
24DVB-S2, DVB-T2, DVB-C2, ISDB, etc. 24DVB-S2, DVB-T2, DVB-C2, ISDB, etc.
25 25
26All kinds of parameters are combined as an union in the 26All kinds of parameters are combined as a union in the
27FrontendParameters structure: 27FrontendParameters structure:
28 28
29 29
diff --git a/Documentation/media/v4l-drivers/bttv.rst b/Documentation/media/v4l-drivers/bttv.rst
index bc63b12efafd..195ccaac2816 100644
--- a/Documentation/media/v4l-drivers/bttv.rst
+++ b/Documentation/media/v4l-drivers/bttv.rst
@@ -312,7 +312,7 @@ information out of a register+stack dump printed by the kernel on
312protection faults (so-called "kernel oops"). 312protection faults (so-called "kernel oops").
313 313
314If you run into some kind of deadlock, you can try to dump a call trace 314If you run into some kind of deadlock, you can try to dump a call trace
315for each process using sysrq-t (see Documentation/sysrq.txt). 315for each process using sysrq-t (see Documentation/admin-guide/sysrq.rst).
316This way it is possible to figure where *exactly* some process in "D" 316This way it is possible to figure where *exactly* some process in "D"
317state is stuck. 317state is stuck.
318 318
diff --git a/Documentation/memory-hotplug.txt b/Documentation/memory-hotplug.txt
index 5de846d3ecc0..670f3ded0802 100644
--- a/Documentation/memory-hotplug.txt
+++ b/Documentation/memory-hotplug.txt
@@ -114,11 +114,11 @@ config options.
114 Memory model -> Sparse Memory (CONFIG_SPARSEMEM) 114 Memory model -> Sparse Memory (CONFIG_SPARSEMEM)
115 Allow for memory hot-add (CONFIG_MEMORY_HOTPLUG) 115 Allow for memory hot-add (CONFIG_MEMORY_HOTPLUG)
116 116
117- To enable memory removal, the followings are also necessary 117- To enable memory removal, the following are also necessary
118 Allow for memory hot remove (CONFIG_MEMORY_HOTREMOVE) 118 Allow for memory hot remove (CONFIG_MEMORY_HOTREMOVE)
119 Page Migration (CONFIG_MIGRATION) 119 Page Migration (CONFIG_MIGRATION)
120 120
121- For ACPI memory hotplug, the followings are also necessary 121- For ACPI memory hotplug, the following are also necessary
122 Memory hotplug (under ACPI Support menu) (CONFIG_ACPI_HOTPLUG_MEMORY) 122 Memory hotplug (under ACPI Support menu) (CONFIG_ACPI_HOTPLUG_MEMORY)
123 This option can be kernel module. 123 This option can be kernel module.
124 124
diff --git a/Documentation/networking/cdc_mbim.txt b/Documentation/networking/cdc_mbim.txt
index a15ea602aa52..b9482ca10254 100644
--- a/Documentation/networking/cdc_mbim.txt
+++ b/Documentation/networking/cdc_mbim.txt
@@ -38,7 +38,7 @@ Basic usage
38=========== 38===========
39 39
40MBIM functions are inactive when unmanaged. The cdc_mbim driver only 40MBIM functions are inactive when unmanaged. The cdc_mbim driver only
41provides an userspace interface to the MBIM control channel, and will 41provides a userspace interface to the MBIM control channel, and will
42not participate in the management of the function. This implies that a 42not participate in the management of the function. This implies that a
43userspace MBIM management application always is required to enable a 43userspace MBIM management application always is required to enable a
44MBIM function. 44MBIM function.
@@ -200,7 +200,7 @@ structure described in section 10.5.29 of [1].
200The DSS VLAN subdevices are used as a practical interface between the 200The DSS VLAN subdevices are used as a practical interface between the
201shared MBIM data channel and a MBIM DSS aware userspace application. 201shared MBIM data channel and a MBIM DSS aware userspace application.
202It is not intended to be presented as-is to an end user. The 202It is not intended to be presented as-is to an end user. The
203assumption is that an userspace application initiating a DSS session 203assumption is that a userspace application initiating a DSS session
204also takes care of the necessary framing of the DSS data, presenting 204also takes care of the necessary framing of the DSS data, presenting
205the stream to the end user in an appropriate way for the stream type. 205the stream to the end user in an appropriate way for the stream type.
206 206
diff --git a/Documentation/networking/dsa/dsa.txt b/Documentation/networking/dsa/dsa.txt
index 63912ef34606..b8b40753133e 100644
--- a/Documentation/networking/dsa/dsa.txt
+++ b/Documentation/networking/dsa/dsa.txt
@@ -295,7 +295,6 @@ DSA currently leverages the following subsystems:
295- MDIO/PHY library: drivers/net/phy/phy.c, mdio_bus.c 295- MDIO/PHY library: drivers/net/phy/phy.c, mdio_bus.c
296- Switchdev: net/switchdev/* 296- Switchdev: net/switchdev/*
297- Device Tree for various of_* functions 297- Device Tree for various of_* functions
298- HWMON: drivers/hwmon/*
299 298
300MDIO/PHY library 299MDIO/PHY library
301---------------- 300----------------
@@ -349,12 +348,6 @@ Documentation/devicetree/bindings/net/dsa/dsa.txt. PHY/MDIO library helper
349functions such as of_get_phy_mode(), of_phy_connect() are also used to query 348functions such as of_get_phy_mode(), of_phy_connect() are also used to query
350per-port PHY specific details: interface connection, MDIO bus location etc.. 349per-port PHY specific details: interface connection, MDIO bus location etc..
351 350
352HWMON
353-----
354
355Some switch drivers feature internal temperature sensors which are exposed as
356regular HWMON devices in /sys/class/hwmon/.
357
358Driver development 351Driver development
359================== 352==================
360 353
@@ -495,23 +488,6 @@ Power management
495 BR_STATE_DISABLED and propagating changes to the hardware if this port is 488 BR_STATE_DISABLED and propagating changes to the hardware if this port is
496 disabled while being a bridge member 489 disabled while being a bridge member
497 490
498Hardware monitoring
499-------------------
500
501These callbacks are only available if CONFIG_NET_DSA_HWMON is enabled:
502
503- get_temp: this function queries the given switch for its temperature
504
505- get_temp_limit: this function returns the switch current maximum temperature
506 limit
507
508- set_temp_limit: this function configures the maximum temperature limit allowed
509
510- get_temp_alarm: this function returns the critical temperature threshold
511 returning an alarm notification
512
513See Documentation/hwmon/sysfs-interface for details.
514
515Bridge layer 491Bridge layer
516------------ 492------------
517 493
diff --git a/Documentation/networking/gtp.txt b/Documentation/networking/gtp.txt
new file mode 100644
index 000000000000..93e96750f103
--- /dev/null
+++ b/Documentation/networking/gtp.txt
@@ -0,0 +1,135 @@
1The Linux kernel GTP tunneling module
2======================================================================
3Documentation by Harald Welte <laforge@gnumonks.org>
4
5In 'drivers/net/gtp.c' you are finding a kernel-level implementation
6of a GTP tunnel endpoint.
7
8== What is GTP ==
9
10GTP is the Generic Tunnel Protocol, which is a 3GPP protocol used for
11tunneling User-IP payload between a mobile station (phone, modem)
12and the interconnection between an external packet data network (such
13as the internet).
14
15So when you start a 'data connection' from your mobile phone, the
16phone will use the control plane to signal for the establishment of
17such a tunnel between that external data network and the phone. The
18tunnel endpoints thus reside on the phone and in the gateway. All
19intermediate nodes just transport the encapsulated packet.
20
21The phone itself does not implement GTP but uses some other
22technology-dependent protocol stack for transmitting the user IP
23payload, such as LLC/SNDCP/RLC/MAC.
24
25At some network element inside the cellular operator infrastructure
26(SGSN in case of GPRS/EGPRS or classic UMTS, hNodeB in case of a 3G
27femtocell, eNodeB in case of 4G/LTE), the cellular protocol stacking
28is translated into GTP *without breaking the end-to-end tunnel*. So
29intermediate nodes just perform some specific relay function.
30
31At some point the GTP packet ends up on the so-called GGSN (GSM/UMTS)
32or P-GW (LTE), which terminates the tunnel, decapsulates the packet
33and forwards it onto an external packet data network. This can be
34public internet, but can also be any private IP network (or even
35theoretically some non-IP network like X.25).
36
37You can find the protocol specification in 3GPP TS 29.060, available
38publicly via the 3GPP website at http://www.3gpp.org/DynaReport/29060.htm
39
40A direct PDF link to v13.6.0 is provided for convenience below:
41http://www.etsi.org/deliver/etsi_ts/129000_129099/129060/13.06.00_60/ts_129060v130600p.pdf
42
43== The Linux GTP tunnelling module ==
44
45The module implements the function of a tunnel endpoint, i.e. it is
46able to decapsulate tunneled IP packets in the uplink originated by
47the phone, and encapsulate raw IP packets received from the external
48packet network in downlink towards the phone.
49
50It *only* implements the so-called 'user plane', carrying the User-IP
51payload, called GTP-U. It does not implement the 'control plane',
52which is a signaling protocol used for establishment and teardown of
53GTP tunnels (GTP-C).
54
55So in order to have a working GGSN/P-GW setup, you will need a
56userspace program that implements the GTP-C protocol and which then
57uses the netlink interface provided by the GTP-U module in the kernel
58to configure the kernel module.
59
60This split architecture follows the tunneling modules of other
61protocols, e.g. PPPoE or L2TP, where you also run a userspace daemon
62to handle the tunnel establishment, authentication etc. and only the
63data plane is accelerated inside the kernel.
64
65Don't be confused by terminology: The GTP User Plane goes through
66kernel accelerated path, while the GTP Control Plane goes to
67Userspace :)
68
69The official homepge of the module is at
70https://osmocom.org/projects/linux-kernel-gtp-u/wiki
71
72== Userspace Programs with Linux Kernel GTP-U support ==
73
74At the time of this writing, there are at least two Free Software
75implementations that implement GTP-C and can use the netlink interface
76to make use of the Linux kernel GTP-U support:
77
78* OpenGGSN (classic 2G/3G GGSN in C):
79 https://osmocom.org/projects/openggsn/wiki/OpenGGSN
80
81* ergw (GGSN + P-GW in Erlang):
82 https://github.com/travelping/ergw
83
84== Userspace Library / Command Line Utilities ==
85
86There is a userspace library called 'libgtpnl' which is based on
87libmnl and which implements a C-language API towards the netlink
88interface provided by the Kernel GTP module:
89
90http://git.osmocom.org/libgtpnl/
91
92== Protocol Versions ==
93
94There are two different versions of GTP-U: v0 and v1. Both are
95implemented in the Kernel GTP module. Version 0 is a legacy version,
96and deprecated from recent 3GPP specifications.
97
98There are three versions of GTP-C: v0, v1, and v2. As the kernel
99doesn't implement GTP-C, we don't have to worry about this. It's the
100responsibility of the control plane implementation in userspace to
101implement that.
102
103== IPv6 ==
104
105The 3GPP specifications indicate either IPv4 or IPv6 can be used both
106on the inner (user) IP layer, or on the outer (transport) layer.
107
108Unfortunately, the Kernel module currently supports IPv6 neither for
109the User IP payload, nor for the outer IP layer. Patches or other
110Contributions to fix this are most welcome!
111
112== Mailing List ==
113
114If yo have questions regarding how to use the Kernel GTP module from
115your own software, or want to contribute to the code, please use the
116osmocom-net-grps mailing list for related discussion. The list can be
117reached at osmocom-net-gprs@lists.osmocom.org and the mailman
118interface for managign your subscription is at
119https://lists.osmocom.org/mailman/listinfo/osmocom-net-gprs
120
121== Issue Tracker ==
122
123The Osmocom project maintains an issue tracker for the Kernel GTP-U
124module at
125https://osmocom.org/projects/linux-kernel-gtp-u/issues
126
127== History / Acknowledgements ==
128
129The Module was originally created in 2012 by Harald Welte, but never
130completed. Pablo came in to finish the mess Harald left behind. But
131doe to a lack of user interest, it never got merged.
132
133In 2015, Andreas Schultz came to the rescue and fixed lots more bugs,
134extended it with new features and finally pushed all of us to get it
135mainline, where it was merged in 4.7.0.
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index 7dd65c9cf707..ab0230461377 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -246,21 +246,12 @@ tcp_dsack - BOOLEAN
246 Allows TCP to send "duplicate" SACKs. 246 Allows TCP to send "duplicate" SACKs.
247 247
248tcp_early_retrans - INTEGER 248tcp_early_retrans - INTEGER
249 Enable Early Retransmit (ER), per RFC 5827. ER lowers the threshold 249 Tail loss probe (TLP) converts RTOs occurring due to tail
250 for triggering fast retransmit when the amount of outstanding data is 250 losses into fast recovery (draft-ietf-tcpm-rack). Note that
251 small and when no previously unsent data can be transmitted (such 251 TLP requires RACK to function properly (see tcp_recovery below)
252 that limited transmit could be used). Also controls the use of
253 Tail loss probe (TLP) that converts RTOs occurring due to tail
254 losses into fast recovery (draft-dukkipati-tcpm-tcp-loss-probe-01).
255 Possible values: 252 Possible values:
256 0 disables ER 253 0 disables TLP
257 1 enables ER 254 3 or 4 enables TLP
258 2 enables ER but delays fast recovery and fast retransmit
259 by a fourth of RTT. This mitigates connection falsely
260 recovers when network has a small degree of reordering
261 (less than 3 packets).
262 3 enables delayed ER and TLP.
263 4 enables TLP only.
264 Default: 3 255 Default: 3
265 256
266tcp_ecn - INTEGER 257tcp_ecn - INTEGER
@@ -712,18 +703,6 @@ tcp_thin_linear_timeouts - BOOLEAN
712 Documentation/networking/tcp-thin.txt 703 Documentation/networking/tcp-thin.txt
713 Default: 0 704 Default: 0
714 705
715tcp_thin_dupack - BOOLEAN
716 Enable dynamic triggering of retransmissions after one dupACK
717 for thin streams. If set, a check is performed upon reception
718 of a dupACK to determine if the stream is thin (less than 4
719 packets in flight). As long as the stream is found to be thin,
720 data is retransmitted on the first received dupACK. This
721 improves retransmission latency for non-aggressive thin
722 streams, often found to be time-dependent.
723 For more information on thin streams, see
724 Documentation/networking/tcp-thin.txt
725 Default: 0
726
727tcp_limit_output_bytes - INTEGER 706tcp_limit_output_bytes - INTEGER
728 Controls TCP Small Queue limit per tcp socket. 707 Controls TCP Small Queue limit per tcp socket.
729 TCP bulk sender tends to increase packets in flight until it 708 TCP bulk sender tends to increase packets in flight until it
@@ -742,6 +721,13 @@ tcp_challenge_ack_limit - INTEGER
742 721
743UDP variables: 722UDP variables:
744 723
724udp_l3mdev_accept - BOOLEAN
725 Enabling this option allows a "global" bound socket to work
726 across L3 master domains (e.g., VRFs) with packets capable of
727 being received regardless of the L3 domain in which they
728 originated. Only valid when the kernel was compiled with
729 CONFIG_NET_L3_MASTER_DEV.
730
745udp_mem - vector of 3 INTEGERs: min, pressure, max 731udp_mem - vector of 3 INTEGERs: min, pressure, max
746 Number of pages allowed for queueing by all UDP sockets. 732 Number of pages allowed for queueing by all UDP sockets.
747 733
@@ -843,6 +829,15 @@ ip_local_reserved_ports - list of comma separated ranges
843 829
844 Default: Empty 830 Default: Empty
845 831
832ip_unprivileged_port_start - INTEGER
833 This is a per-namespace sysctl. It defines the first
834 unprivileged port in the network namespace. Privileged ports
835 require root or CAP_NET_BIND_SERVICE in order to bind to them.
836 To disable all privileged ports, set this to 0. It may not
837 overlap with the ip_local_reserved_ports range.
838
839 Default: 1024
840
846ip_nonlocal_bind - BOOLEAN 841ip_nonlocal_bind - BOOLEAN
847 If set, allows processes to bind() to non-local IP addresses, 842 If set, allows processes to bind() to non-local IP addresses,
848 which can be quite useful - but may break some applications. 843 which can be quite useful - but may break some applications.
@@ -1011,7 +1006,8 @@ accept_redirects - BOOLEAN
1011 FALSE (router) 1006 FALSE (router)
1012 1007
1013forwarding - BOOLEAN 1008forwarding - BOOLEAN
1014 Enable IP forwarding on this interface. 1009 Enable IP forwarding on this interface. This controls whether packets
1010 received _on_ this interface can be forwarded.
1015 1011
1016mc_forwarding - BOOLEAN 1012mc_forwarding - BOOLEAN
1017 Do multicast routing. The kernel needs to be compiled with CONFIG_MROUTE 1013 Do multicast routing. The kernel needs to be compiled with CONFIG_MROUTE
diff --git a/Documentation/networking/kcm.txt b/Documentation/networking/kcm.txt
index 3476ede5bc2c..9a513295b07c 100644
--- a/Documentation/networking/kcm.txt
+++ b/Documentation/networking/kcm.txt
@@ -272,7 +272,7 @@ on the socket thus waking up the application thread. When the application
272sees the error (which may just be a disconnect) it should unattach the 272sees the error (which may just be a disconnect) it should unattach the
273socket from KCM and then close it. It is assumed that once an error is 273socket from KCM and then close it. It is assumed that once an error is
274posted on the TCP socket the data stream is unrecoverable (i.e. an error 274posted on the TCP socket the data stream is unrecoverable (i.e. an error
275may have occurred in in the middle of receiving a messssge). 275may have occurred in the middle of receiving a messssge).
276 276
277TCP connection monitoring 277TCP connection monitoring
278------------------------- 278-------------------------
diff --git a/Documentation/networking/netfilter-sysctl.txt b/Documentation/networking/netfilter-sysctl.txt
new file mode 100644
index 000000000000..55791e50e169
--- /dev/null
+++ b/Documentation/networking/netfilter-sysctl.txt
@@ -0,0 +1,10 @@
1/proc/sys/net/netfilter/* Variables:
2
3nf_log_all_netns - BOOLEAN
4 0 - disabled (default)
5 not 0 - enabled
6
7 By default, only init_net namespace can log packets into kernel log
8 with LOG target; this aims to prevent containers from flooding host
9 kernel log. If enabled, this target also works in other network
10 namespaces. This variable is only accessible from init_net.
diff --git a/Documentation/networking/packet_mmap.txt b/Documentation/networking/packet_mmap.txt
index daa015af16a0..f3b9e507ab05 100644
--- a/Documentation/networking/packet_mmap.txt
+++ b/Documentation/networking/packet_mmap.txt
@@ -565,7 +565,7 @@ TPACKET_V1 --> TPACKET_V2:
565 (void *)hdr + TPACKET_ALIGN(sizeof(struct tpacket_hdr)) 565 (void *)hdr + TPACKET_ALIGN(sizeof(struct tpacket_hdr))
566 566
567TPACKET_V2 --> TPACKET_V3: 567TPACKET_V2 --> TPACKET_V3:
568 - Flexible buffer implementation: 568 - Flexible buffer implementation for RX_RING:
569 1. Blocks can be configured with non-static frame-size 569 1. Blocks can be configured with non-static frame-size
570 2. Read/poll is at a block-level (as opposed to packet-level) 570 2. Read/poll is at a block-level (as opposed to packet-level)
571 3. Added poll timeout to avoid indefinite user-space wait 571 3. Added poll timeout to avoid indefinite user-space wait
@@ -574,7 +574,12 @@ TPACKET_V2 --> TPACKET_V3:
574 4.1 block::timeout 574 4.1 block::timeout
575 4.2 tpkt_hdr::sk_rxhash 575 4.2 tpkt_hdr::sk_rxhash
576 - RX Hash data available in user space 576 - RX Hash data available in user space
577 - Currently only RX_RING available 577 - TX_RING semantics are conceptually similar to TPACKET_V2;
578 use tpacket3_hdr instead of tpacket2_hdr, and TPACKET3_HDRLEN
579 instead of TPACKET2_HDRLEN. In the current implementation,
580 the tp_next_offset field in the tpacket3_hdr MUST be set to
581 zero, indicating that the ring does not hold variable sized frames.
582 Packets with non-zero values of tp_next_offset will be dropped.
578 583
579------------------------------------------------------------------------------- 584-------------------------------------------------------------------------------
580+ AF_PACKET fanout mode 585+ AF_PACKET fanout mode
diff --git a/Documentation/networking/regulatory.txt b/Documentation/networking/regulatory.txt
index 356f791af574..7818b5fe448b 100644
--- a/Documentation/networking/regulatory.txt
+++ b/Documentation/networking/regulatory.txt
@@ -156,12 +156,12 @@ struct ieee80211_regdomain mydriver_jp_regdom = {
156 //.alpha2 = "99", /* If I have no alpha2 to map it to */ 156 //.alpha2 = "99", /* If I have no alpha2 to map it to */
157 .reg_rules = { 157 .reg_rules = {
158 /* IEEE 802.11b/g, channels 1..14 */ 158 /* IEEE 802.11b/g, channels 1..14 */
159 REG_RULE(2412-20, 2484+20, 40, 6, 20, 0), 159 REG_RULE(2412-10, 2484+10, 40, 6, 20, 0),
160 /* IEEE 802.11a, channels 34..48 */ 160 /* IEEE 802.11a, channels 34..48 */
161 REG_RULE(5170-20, 5240+20, 40, 6, 20, 161 REG_RULE(5170-10, 5240+10, 40, 6, 20,
162 NL80211_RRF_NO_IR), 162 NL80211_RRF_NO_IR),
163 /* IEEE 802.11a, channels 52..64 */ 163 /* IEEE 802.11a, channels 52..64 */
164 REG_RULE(5260-20, 5320+20, 40, 6, 20, 164 REG_RULE(5260-10, 5320+10, 40, 6, 20,
165 NL80211_RRF_NO_IR| 165 NL80211_RRF_NO_IR|
166 NL80211_RRF_DFS), 166 NL80211_RRF_DFS),
167 } 167 }
@@ -205,7 +205,7 @@ the data in regdb.c as an alternative to using CRDA.
205The file net/wireless/db.txt should be kept up-to-date with the db.txt 205The file net/wireless/db.txt should be kept up-to-date with the db.txt
206file available in the git repository here: 206file available in the git repository here:
207 207
208 git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-regdb.git 208 git://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git
209 209
210Again, most users in most situations should be using the CRDA package 210Again, most users in most situations should be using the CRDA package
211provided with their distribution, and in most other situations users 211provided with their distribution, and in most other situations users
diff --git a/Documentation/networking/vrf.txt b/Documentation/networking/vrf.txt
index 755dab856392..3918dae964d4 100644
--- a/Documentation/networking/vrf.txt
+++ b/Documentation/networking/vrf.txt
@@ -98,10 +98,11 @@ VRF device:
98 98
99or to specify the output device using cmsg and IP_PKTINFO. 99or to specify the output device using cmsg and IP_PKTINFO.
100 100
101TCP services running in the default VRF context (ie., not bound to any VRF 101TCP & UDP services running in the default VRF context (ie., not bound
102device) can work across all VRF domains by enabling the tcp_l3mdev_accept 102to any VRF device) can work across all VRF domains by enabling the
103sysctl option: 103tcp_l3mdev_accept and udp_l3mdev_accept sysctl options:
104 sysctl -w net.ipv4.tcp_l3mdev_accept=1 104 sysctl -w net.ipv4.tcp_l3mdev_accept=1
105 sysctl -w net.ipv4.udp_l3mdev_accept=1
105 106
106netfilter rules on the VRF device can be used to limit access to services 107netfilter rules on the VRF device can be used to limit access to services
107running in the default VRF context as well. 108running in the default VRF context as well.
diff --git a/Documentation/perf/qcom_l2_pmu.txt b/Documentation/perf/qcom_l2_pmu.txt
new file mode 100644
index 000000000000..b25b97659ab9
--- /dev/null
+++ b/Documentation/perf/qcom_l2_pmu.txt
@@ -0,0 +1,38 @@
1Qualcomm Technologies Level-2 Cache Performance Monitoring Unit (PMU)
2=====================================================================
3
4This driver supports the L2 cache clusters found in Qualcomm Technologies
5Centriq SoCs. There are multiple physical L2 cache clusters, each with their
6own PMU. Each cluster has one or more CPUs associated with it.
7
8There is one logical L2 PMU exposed, which aggregates the results from
9the physical PMUs.
10
11The driver provides a description of its available events and configuration
12options in sysfs, see /sys/devices/l2cache_0.
13
14The "format" directory describes the format of the events.
15
16Events can be envisioned as a 2-dimensional array. Each column represents
17a group of events. There are 8 groups. Only one entry from each
18group can be in use at a time. If multiple events from the same group
19are specified, the conflicting events cannot be counted at the same time.
20
21Events are specified as 0xCCG, where CC is 2 hex digits specifying
22the code (array row) and G specifies the group (column) 0-7.
23
24In addition there is a cycle counter event specified by the value 0xFE
25which is outside the above scheme.
26
27The driver provides a "cpumask" sysfs attribute which contains a mask
28consisting of one CPU per cluster which will be used to handle all the PMU
29events on that cluster.
30
31Examples for use with perf:
32
33 perf stat -e l2cache_0/config=0x001/,l2cache_0/config=0x042/ -a sleep 1
34
35 perf stat -e l2cache_0/config=0xfe/ -C 2 sleep 1
36
37The driver does not support sampling, therefore "perf record" will
38not work. Per-task perf sessions are not supported.
diff --git a/Documentation/power/00-INDEX b/Documentation/power/00-INDEX
index 7cb6085839f3..7f3c2def2cac 100644
--- a/Documentation/power/00-INDEX
+++ b/Documentation/power/00-INDEX
@@ -14,8 +14,6 @@ freezing-of-tasks.txt
14 - How processes and controlled during suspend 14 - How processes and controlled during suspend
15interface.txt 15interface.txt
16 - Power management user interface in /sys/power 16 - Power management user interface in /sys/power
17notifiers.txt
18 - Registering suspend notifiers in device drivers
19opp.txt 17opp.txt
20 - Operating Performance Point library 18 - Operating Performance Point library
21pci.txt 19pci.txt
diff --git a/Documentation/power/devices.txt b/Documentation/power/devices.txt
deleted file mode 100644
index 73ddea39a9ce..000000000000
--- a/Documentation/power/devices.txt
+++ /dev/null
@@ -1,716 +0,0 @@
1Device Power Management
2
3Copyright (c) 2010-2011 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc.
4Copyright (c) 2010 Alan Stern <stern@rowland.harvard.edu>
5Copyright (c) 2014 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com>
6
7
8Most of the code in Linux is device drivers, so most of the Linux power
9management (PM) code is also driver-specific. Most drivers will do very
10little; others, especially for platforms with small batteries (like cell
11phones), will do a lot.
12
13This writeup gives an overview of how drivers interact with system-wide
14power management goals, emphasizing the models and interfaces that are
15shared by everything that hooks up to the driver model core. Read it as
16background for the domain-specific work you'd do with any specific driver.
17
18
19Two Models for Device Power Management
20======================================
21Drivers will use one or both of these models to put devices into low-power
22states:
23
24 System Sleep model:
25 Drivers can enter low-power states as part of entering system-wide
26 low-power states like "suspend" (also known as "suspend-to-RAM"), or
27 (mostly for systems with disks) "hibernation" (also known as
28 "suspend-to-disk").
29
30 This is something that device, bus, and class drivers collaborate on
31 by implementing various role-specific suspend and resume methods to
32 cleanly power down hardware and software subsystems, then reactivate
33 them without loss of data.
34
35 Some drivers can manage hardware wakeup events, which make the system
36 leave the low-power state. This feature may be enabled or disabled
37 using the relevant /sys/devices/.../power/wakeup file (for Ethernet
38 drivers the ioctl interface used by ethtool may also be used for this
39 purpose); enabling it may cost some power usage, but let the whole
40 system enter low-power states more often.
41
42 Runtime Power Management model:
43 Devices may also be put into low-power states while the system is
44 running, independently of other power management activity in principle.
45 However, devices are not generally independent of each other (for
46 example, a parent device cannot be suspended unless all of its child
47 devices have been suspended). Moreover, depending on the bus type the
48 device is on, it may be necessary to carry out some bus-specific
49 operations on the device for this purpose. Devices put into low power
50 states at run time may require special handling during system-wide power
51 transitions (suspend or hibernation).
52
53 For these reasons not only the device driver itself, but also the
54 appropriate subsystem (bus type, device type or device class) driver and
55 the PM core are involved in runtime power management. As in the system
56 sleep power management case, they need to collaborate by implementing
57 various role-specific suspend and resume methods, so that the hardware
58 is cleanly powered down and reactivated without data or service loss.
59
60There's not a lot to be said about those low-power states except that they are
61very system-specific, and often device-specific. Also, that if enough devices
62have been put into low-power states (at runtime), the effect may be very similar
63to entering some system-wide low-power state (system sleep) ... and that
64synergies exist, so that several drivers using runtime PM might put the system
65into a state where even deeper power saving options are available.
66
67Most suspended devices will have quiesced all I/O: no more DMA or IRQs (except
68for wakeup events), no more data read or written, and requests from upstream
69drivers are no longer accepted. A given bus or platform may have different
70requirements though.
71
72Examples of hardware wakeup events include an alarm from a real time clock,
73network wake-on-LAN packets, keyboard or mouse activity, and media insertion
74or removal (for PCMCIA, MMC/SD, USB, and so on).
75
76
77Interfaces for Entering System Sleep States
78===========================================
79There are programming interfaces provided for subsystems (bus type, device type,
80device class) and device drivers to allow them to participate in the power
81management of devices they are concerned with. These interfaces cover both
82system sleep and runtime power management.
83
84
85Device Power Management Operations
86----------------------------------
87Device power management operations, at the subsystem level as well as at the
88device driver level, are implemented by defining and populating objects of type
89struct dev_pm_ops:
90
91struct dev_pm_ops {
92 int (*prepare)(struct device *dev);
93 void (*complete)(struct device *dev);
94 int (*suspend)(struct device *dev);
95 int (*resume)(struct device *dev);
96 int (*freeze)(struct device *dev);
97 int (*thaw)(struct device *dev);
98 int (*poweroff)(struct device *dev);
99 int (*restore)(struct device *dev);
100 int (*suspend_late)(struct device *dev);
101 int (*resume_early)(struct device *dev);
102 int (*freeze_late)(struct device *dev);
103 int (*thaw_early)(struct device *dev);
104 int (*poweroff_late)(struct device *dev);
105 int (*restore_early)(struct device *dev);
106 int (*suspend_noirq)(struct device *dev);
107 int (*resume_noirq)(struct device *dev);
108 int (*freeze_noirq)(struct device *dev);
109 int (*thaw_noirq)(struct device *dev);
110 int (*poweroff_noirq)(struct device *dev);
111 int (*restore_noirq)(struct device *dev);
112 int (*runtime_suspend)(struct device *dev);
113 int (*runtime_resume)(struct device *dev);
114 int (*runtime_idle)(struct device *dev);
115};
116
117This structure is defined in include/linux/pm.h and the methods included in it
118are also described in that file. Their roles will be explained in what follows.
119For now, it should be sufficient to remember that the last three methods are
120specific to runtime power management while the remaining ones are used during
121system-wide power transitions.
122
123There also is a deprecated "old" or "legacy" interface for power management
124operations available at least for some subsystems. This approach does not use
125struct dev_pm_ops objects and it is suitable only for implementing system sleep
126power management methods. Therefore it is not described in this document, so
127please refer directly to the source code for more information about it.
128
129
130Subsystem-Level Methods
131-----------------------
132The core methods to suspend and resume devices reside in struct dev_pm_ops
133pointed to by the ops member of struct dev_pm_domain, or by the pm member of
134struct bus_type, struct device_type and struct class. They are mostly of
135interest to the people writing infrastructure for platforms and buses, like PCI
136or USB, or device type and device class drivers. They also are relevant to the
137writers of device drivers whose subsystems (PM domains, device types, device
138classes and bus types) don't provide all power management methods.
139
140Bus drivers implement these methods as appropriate for the hardware and the
141drivers using it; PCI works differently from USB, and so on. Not many people
142write subsystem-level drivers; most driver code is a "device driver" that builds
143on top of bus-specific framework code.
144
145For more information on these driver calls, see the description later;
146they are called in phases for every device, respecting the parent-child
147sequencing in the driver model tree.
148
149
150/sys/devices/.../power/wakeup files
151-----------------------------------
152All device objects in the driver model contain fields that control the handling
153of system wakeup events (hardware signals that can force the system out of a
154sleep state). These fields are initialized by bus or device driver code using
155device_set_wakeup_capable() and device_set_wakeup_enable(), defined in
156include/linux/pm_wakeup.h.
157
158The "power.can_wakeup" flag just records whether the device (and its driver) can
159physically support wakeup events. The device_set_wakeup_capable() routine
160affects this flag. The "power.wakeup" field is a pointer to an object of type
161struct wakeup_source used for controlling whether or not the device should use
162its system wakeup mechanism and for notifying the PM core of system wakeup
163events signaled by the device. This object is only present for wakeup-capable
164devices (i.e. devices whose "can_wakeup" flags are set) and is created (or
165removed) by device_set_wakeup_capable().
166
167Whether or not a device is capable of issuing wakeup events is a hardware
168matter, and the kernel is responsible for keeping track of it. By contrast,
169whether or not a wakeup-capable device should issue wakeup events is a policy
170decision, and it is managed by user space through a sysfs attribute: the
171"power/wakeup" file. User space can write the strings "enabled" or "disabled"
172to it to indicate whether or not, respectively, the device is supposed to signal
173system wakeup. This file is only present if the "power.wakeup" object exists
174for the given device and is created (or removed) along with that object, by
175device_set_wakeup_capable(). Reads from the file will return the corresponding
176string.
177
178The "power/wakeup" file is supposed to contain the "disabled" string initially
179for the majority of devices; the major exceptions are power buttons, keyboards,
180and Ethernet adapters whose WoL (wake-on-LAN) feature has been set up with
181ethtool. It should also default to "enabled" for devices that don't generate
182wakeup requests on their own but merely forward wakeup requests from one bus to
183another (like PCI Express ports).
184
185The device_may_wakeup() routine returns true only if the "power.wakeup" object
186exists and the corresponding "power/wakeup" file contains the string "enabled".
187This information is used by subsystems, like the PCI bus type code, to see
188whether or not to enable the devices' wakeup mechanisms. If device wakeup
189mechanisms are enabled or disabled directly by drivers, they also should use
190device_may_wakeup() to decide what to do during a system sleep transition.
191Device drivers, however, are not supposed to call device_set_wakeup_enable()
192directly in any case.
193
194It ought to be noted that system wakeup is conceptually different from "remote
195wakeup" used by runtime power management, although it may be supported by the
196same physical mechanism. Remote wakeup is a feature allowing devices in
197low-power states to trigger specific interrupts to signal conditions in which
198they should be put into the full-power state. Those interrupts may or may not
199be used to signal system wakeup events, depending on the hardware design. On
200some systems it is impossible to trigger them from system sleep states. In any
201case, remote wakeup should always be enabled for runtime power management for
202all devices and drivers that support it.
203
204/sys/devices/.../power/control files
205------------------------------------
206Each device in the driver model has a flag to control whether it is subject to
207runtime power management. This flag, called runtime_auto, is initialized by the
208bus type (or generally subsystem) code using pm_runtime_allow() or
209pm_runtime_forbid(); the default is to allow runtime power management.
210
211The setting can be adjusted by user space by writing either "on" or "auto" to
212the device's power/control sysfs file. Writing "auto" calls pm_runtime_allow(),
213setting the flag and allowing the device to be runtime power-managed by its
214driver. Writing "on" calls pm_runtime_forbid(), clearing the flag, returning
215the device to full power if it was in a low-power state, and preventing the
216device from being runtime power-managed. User space can check the current value
217of the runtime_auto flag by reading the file.
218
219The device's runtime_auto flag has no effect on the handling of system-wide
220power transitions. In particular, the device can (and in the majority of cases
221should and will) be put into a low-power state during a system-wide transition
222to a sleep state even though its runtime_auto flag is clear.
223
224For more information about the runtime power management framework, refer to
225Documentation/power/runtime_pm.txt.
226
227
228Calling Drivers to Enter and Leave System Sleep States
229======================================================
230When the system goes into a sleep state, each device's driver is asked to
231suspend the device by putting it into a state compatible with the target
232system state. That's usually some version of "off", but the details are
233system-specific. Also, wakeup-enabled devices will usually stay partly
234functional in order to wake the system.
235
236When the system leaves that low-power state, the device's driver is asked to
237resume it by returning it to full power. The suspend and resume operations
238always go together, and both are multi-phase operations.
239
240For simple drivers, suspend might quiesce the device using class code
241and then turn its hardware as "off" as possible during suspend_noirq. The
242matching resume calls would then completely reinitialize the hardware
243before reactivating its class I/O queues.
244
245More power-aware drivers might prepare the devices for triggering system wakeup
246events.
247
248
249Call Sequence Guarantees
250------------------------
251To ensure that bridges and similar links needing to talk to a device are
252available when the device is suspended or resumed, the device tree is
253walked in a bottom-up order to suspend devices. A top-down order is
254used to resume those devices.
255
256The ordering of the device tree is defined by the order in which devices
257get registered: a child can never be registered, probed or resumed before
258its parent; and can't be removed or suspended after that parent.
259
260The policy is that the device tree should match hardware bus topology.
261(Or at least the control bus, for devices which use multiple busses.)
262In particular, this means that a device registration may fail if the parent of
263the device is suspending (i.e. has been chosen by the PM core as the next
264device to suspend) or has already suspended, as well as after all of the other
265devices have been suspended. Device drivers must be prepared to cope with such
266situations.
267
268
269System Power Management Phases
270------------------------------
271Suspending or resuming the system is done in several phases. Different phases
272are used for freeze, standby, and memory sleep states ("suspend-to-RAM") and the
273hibernation state ("suspend-to-disk"). Each phase involves executing callbacks
274for every device before the next phase begins. Not all busses or classes
275support all these callbacks and not all drivers use all the callbacks. The
276various phases always run after tasks have been frozen and before they are
277unfrozen. Furthermore, the *_noirq phases run at a time when IRQ handlers have
278been disabled (except for those marked with the IRQF_NO_SUSPEND flag).
279
280All phases use PM domain, bus, type, class or driver callbacks (that is, methods
281defined in dev->pm_domain->ops, dev->bus->pm, dev->type->pm, dev->class->pm or
282dev->driver->pm). These callbacks are regarded by the PM core as mutually
283exclusive. Moreover, PM domain callbacks always take precedence over all of the
284other callbacks and, for example, type callbacks take precedence over bus, class
285and driver callbacks. To be precise, the following rules are used to determine
286which callback to execute in the given phase:
287
288 1. If dev->pm_domain is present, the PM core will choose the callback
289 included in dev->pm_domain->ops for execution
290
291 2. Otherwise, if both dev->type and dev->type->pm are present, the callback
292 included in dev->type->pm will be chosen for execution.
293
294 3. Otherwise, if both dev->class and dev->class->pm are present, the
295 callback included in dev->class->pm will be chosen for execution.
296
297 4. Otherwise, if both dev->bus and dev->bus->pm are present, the callback
298 included in dev->bus->pm will be chosen for execution.
299
300This allows PM domains and device types to override callbacks provided by bus
301types or device classes if necessary.
302
303The PM domain, type, class and bus callbacks may in turn invoke device- or
304driver-specific methods stored in dev->driver->pm, but they don't have to do
305that.
306
307If the subsystem callback chosen for execution is not present, the PM core will
308execute the corresponding method from dev->driver->pm instead if there is one.
309
310
311Entering System Suspend
312-----------------------
313When the system goes into the freeze, standby or memory sleep state,
314the phases are:
315
316 prepare, suspend, suspend_late, suspend_noirq.
317
318 1. The prepare phase is meant to prevent races by preventing new devices
319 from being registered; the PM core would never know that all the
320 children of a device had been suspended if new children could be
321 registered at will. (By contrast, devices may be unregistered at any
322 time.) Unlike the other suspend-related phases, during the prepare
323 phase the device tree is traversed top-down.
324
325 After the prepare callback method returns, no new children may be
326 registered below the device. The method may also prepare the device or
327 driver in some way for the upcoming system power transition, but it
328 should not put the device into a low-power state.
329
330 For devices supporting runtime power management, the return value of the
331 prepare callback can be used to indicate to the PM core that it may
332 safely leave the device in runtime suspend (if runtime-suspended
333 already), provided that all of the device's descendants are also left in
334 runtime suspend. Namely, if the prepare callback returns a positive
335 number and that happens for all of the descendants of the device too,
336 and all of them (including the device itself) are runtime-suspended, the
337 PM core will skip the suspend, suspend_late and suspend_noirq suspend
338 phases as well as the resume_noirq, resume_early and resume phases of
339 the following system resume for all of these devices. In that case,
340 the complete callback will be called directly after the prepare callback
341 and is entirely responsible for bringing the device back to the
342 functional state as appropriate.
343
344 Note that this direct-complete procedure applies even if the device is
345 disabled for runtime PM; only the runtime-PM status matters. It follows
346 that if a device has system-sleep callbacks but does not support runtime
347 PM, then its prepare callback must never return a positive value. This
348 is because all devices are initially set to runtime-suspended with
349 runtime PM disabled.
350
351 2. The suspend methods should quiesce the device to stop it from performing
352 I/O. They also may save the device registers and put it into the
353 appropriate low-power state, depending on the bus type the device is on,
354 and they may enable wakeup events.
355
356 3 For a number of devices it is convenient to split suspend into the
357 "quiesce device" and "save device state" phases, in which cases
358 suspend_late is meant to do the latter. It is always executed after
359 runtime power management has been disabled for all devices.
360
361 4. The suspend_noirq phase occurs after IRQ handlers have been disabled,
362 which means that the driver's interrupt handler will not be called while
363 the callback method is running. The methods should save the values of
364 the device's registers that weren't saved previously and finally put the
365 device into the appropriate low-power state.
366
367 The majority of subsystems and device drivers need not implement this
368 callback. However, bus types allowing devices to share interrupt
369 vectors, like PCI, generally need it; otherwise a driver might encounter
370 an error during the suspend phase by fielding a shared interrupt
371 generated by some other device after its own device had been set to low
372 power.
373
374At the end of these phases, drivers should have stopped all I/O transactions
375(DMA, IRQs), saved enough state that they can re-initialize or restore previous
376state (as needed by the hardware), and placed the device into a low-power state.
377On many platforms they will gate off one or more clock sources; sometimes they
378will also switch off power supplies or reduce voltages. (Drivers supporting
379runtime PM may already have performed some or all of these steps.)
380
381If device_may_wakeup(dev) returns true, the device should be prepared for
382generating hardware wakeup signals to trigger a system wakeup event when the
383system is in the sleep state. For example, enable_irq_wake() might identify
384GPIO signals hooked up to a switch or other external hardware, and
385pci_enable_wake() does something similar for the PCI PME signal.
386
387If any of these callbacks returns an error, the system won't enter the desired
388low-power state. Instead the PM core will unwind its actions by resuming all
389the devices that were suspended.
390
391
392Leaving System Suspend
393----------------------
394When resuming from freeze, standby or memory sleep, the phases are:
395
396 resume_noirq, resume_early, resume, complete.
397
398 1. The resume_noirq callback methods should perform any actions needed
399 before the driver's interrupt handlers are invoked. This generally
400 means undoing the actions of the suspend_noirq phase. If the bus type
401 permits devices to share interrupt vectors, like PCI, the method should
402 bring the device and its driver into a state in which the driver can
403 recognize if the device is the source of incoming interrupts, if any,
404 and handle them correctly.
405
406 For example, the PCI bus type's ->pm.resume_noirq() puts the device into
407 the full-power state (D0 in the PCI terminology) and restores the
408 standard configuration registers of the device. Then it calls the
409 device driver's ->pm.resume_noirq() method to perform device-specific
410 actions.
411
412 2. The resume_early methods should prepare devices for the execution of
413 the resume methods. This generally involves undoing the actions of the
414 preceding suspend_late phase.
415
416 3 The resume methods should bring the device back to its operating
417 state, so that it can perform normal I/O. This generally involves
418 undoing the actions of the suspend phase.
419
420 4. The complete phase should undo the actions of the prepare phase. Note,
421 however, that new children may be registered below the device as soon as
422 the resume callbacks occur; it's not necessary to wait until the
423 complete phase.
424
425 Moreover, if the preceding prepare callback returned a positive number,
426 the device may have been left in runtime suspend throughout the whole
427 system suspend and resume (the suspend, suspend_late, suspend_noirq
428 phases of system suspend and the resume_noirq, resume_early, resume
429 phases of system resume may have been skipped for it). In that case,
430 the complete callback is entirely responsible for bringing the device
431 back to the functional state after system suspend if necessary. [For
432 example, it may need to queue up a runtime resume request for the device
433 for this purpose.] To check if that is the case, the complete callback
434 can consult the device's power.direct_complete flag. Namely, if that
435 flag is set when the complete callback is being run, it has been called
436 directly after the preceding prepare and special action may be required
437 to make the device work correctly afterward.
438
439At the end of these phases, drivers should be as functional as they were before
440suspending: I/O can be performed using DMA and IRQs, and the relevant clocks are
441gated on.
442
443However, the details here may again be platform-specific. For example,
444some systems support multiple "run" states, and the mode in effect at
445the end of resume might not be the one which preceded suspension.
446That means availability of certain clocks or power supplies changed,
447which could easily affect how a driver works.
448
449Drivers need to be able to handle hardware which has been reset since the
450suspend methods were called, for example by complete reinitialization.
451This may be the hardest part, and the one most protected by NDA'd documents
452and chip errata. It's simplest if the hardware state hasn't changed since
453the suspend was carried out, but that can't be guaranteed (in fact, it usually
454is not the case).
455
456Drivers must also be prepared to notice that the device has been removed
457while the system was powered down, whenever that's physically possible.
458PCMCIA, MMC, USB, Firewire, SCSI, and even IDE are common examples of busses
459where common Linux platforms will see such removal. Details of how drivers
460will notice and handle such removals are currently bus-specific, and often
461involve a separate thread.
462
463These callbacks may return an error value, but the PM core will ignore such
464errors since there's nothing it can do about them other than printing them in
465the system log.
466
467
468Entering Hibernation
469--------------------
470Hibernating the system is more complicated than putting it into the other
471sleep states, because it involves creating and saving a system image.
472Therefore there are more phases for hibernation, with a different set of
473callbacks. These phases always run after tasks have been frozen and memory has
474been freed.
475
476The general procedure for hibernation is to quiesce all devices (freeze), create
477an image of the system memory while everything is stable, reactivate all
478devices (thaw), write the image to permanent storage, and finally shut down the
479system (poweroff). The phases used to accomplish this are:
480
481 prepare, freeze, freeze_late, freeze_noirq, thaw_noirq, thaw_early,
482 thaw, complete, prepare, poweroff, poweroff_late, poweroff_noirq
483
484 1. The prepare phase is discussed in the "Entering System Suspend" section
485 above.
486
487 2. The freeze methods should quiesce the device so that it doesn't generate
488 IRQs or DMA, and they may need to save the values of device registers.
489 However the device does not have to be put in a low-power state, and to
490 save time it's best not to do so. Also, the device should not be
491 prepared to generate wakeup events.
492
493 3. The freeze_late phase is analogous to the suspend_late phase described
494 above, except that the device should not be put in a low-power state and
495 should not be allowed to generate wakeup events by it.
496
497 4. The freeze_noirq phase is analogous to the suspend_noirq phase discussed
498 above, except again that the device should not be put in a low-power
499 state and should not be allowed to generate wakeup events.
500
501At this point the system image is created. All devices should be inactive and
502the contents of memory should remain undisturbed while this happens, so that the
503image forms an atomic snapshot of the system state.
504
505 5. The thaw_noirq phase is analogous to the resume_noirq phase discussed
506 above. The main difference is that its methods can assume the device is
507 in the same state as at the end of the freeze_noirq phase.
508
509 6. The thaw_early phase is analogous to the resume_early phase described
510 above. Its methods should undo the actions of the preceding
511 freeze_late, if necessary.
512
513 7. The thaw phase is analogous to the resume phase discussed above. Its
514 methods should bring the device back to an operating state, so that it
515 can be used for saving the image if necessary.
516
517 8. The complete phase is discussed in the "Leaving System Suspend" section
518 above.
519
520At this point the system image is saved, and the devices then need to be
521prepared for the upcoming system shutdown. This is much like suspending them
522before putting the system into the freeze, standby or memory sleep state,
523and the phases are similar.
524
525 9. The prepare phase is discussed above.
526
527 10. The poweroff phase is analogous to the suspend phase.
528
529 11. The poweroff_late phase is analogous to the suspend_late phase.
530
531 12. The poweroff_noirq phase is analogous to the suspend_noirq phase.
532
533The poweroff, poweroff_late and poweroff_noirq callbacks should do essentially
534the same things as the suspend, suspend_late and suspend_noirq callbacks,
535respectively. The only notable difference is that they need not store the
536device register values, because the registers should already have been stored
537during the freeze, freeze_late or freeze_noirq phases.
538
539
540Leaving Hibernation
541-------------------
542Resuming from hibernation is, again, more complicated than resuming from a sleep
543state in which the contents of main memory are preserved, because it requires
544a system image to be loaded into memory and the pre-hibernation memory contents
545to be restored before control can be passed back to the image kernel.
546
547Although in principle, the image might be loaded into memory and the
548pre-hibernation memory contents restored by the boot loader, in practice this
549can't be done because boot loaders aren't smart enough and there is no
550established protocol for passing the necessary information. So instead, the
551boot loader loads a fresh instance of the kernel, called the boot kernel, into
552memory and passes control to it in the usual way. Then the boot kernel reads
553the system image, restores the pre-hibernation memory contents, and passes
554control to the image kernel. Thus two different kernels are involved in
555resuming from hibernation. In fact, the boot kernel may be completely different
556from the image kernel: a different configuration and even a different version.
557This has important consequences for device drivers and their subsystems.
558
559To be able to load the system image into memory, the boot kernel needs to
560include at least a subset of device drivers allowing it to access the storage
561medium containing the image, although it doesn't need to include all of the
562drivers present in the image kernel. After the image has been loaded, the
563devices managed by the boot kernel need to be prepared for passing control back
564to the image kernel. This is very similar to the initial steps involved in
565creating a system image, and it is accomplished in the same way, using prepare,
566freeze, and freeze_noirq phases. However the devices affected by these phases
567are only those having drivers in the boot kernel; other devices will still be in
568whatever state the boot loader left them.
569
570Should the restoration of the pre-hibernation memory contents fail, the boot
571kernel would go through the "thawing" procedure described above, using the
572thaw_noirq, thaw, and complete phases, and then continue running normally. This
573happens only rarely. Most often the pre-hibernation memory contents are
574restored successfully and control is passed to the image kernel, which then
575becomes responsible for bringing the system back to the working state.
576
577To achieve this, the image kernel must restore the devices' pre-hibernation
578functionality. The operation is much like waking up from the memory sleep
579state, although it involves different phases:
580
581 restore_noirq, restore_early, restore, complete
582
583 1. The restore_noirq phase is analogous to the resume_noirq phase.
584
585 2. The restore_early phase is analogous to the resume_early phase.
586
587 3. The restore phase is analogous to the resume phase.
588
589 4. The complete phase is discussed above.
590
591The main difference from resume[_early|_noirq] is that restore[_early|_noirq]
592must assume the device has been accessed and reconfigured by the boot loader or
593the boot kernel. Consequently the state of the device may be different from the
594state remembered from the freeze, freeze_late and freeze_noirq phases. The
595device may even need to be reset and completely re-initialized. In many cases
596this difference doesn't matter, so the resume[_early|_noirq] and
597restore[_early|_norq] method pointers can be set to the same routines.
598Nevertheless, different callback pointers are used in case there is a situation
599where it actually does matter.
600
601
602Device Power Management Domains
603-------------------------------
604Sometimes devices share reference clocks or other power resources. In those
605cases it generally is not possible to put devices into low-power states
606individually. Instead, a set of devices sharing a power resource can be put
607into a low-power state together at the same time by turning off the shared
608power resource. Of course, they also need to be put into the full-power state
609together, by turning the shared power resource on. A set of devices with this
610property is often referred to as a power domain. A power domain may also be
611nested inside another power domain. The nested domain is referred to as the
612sub-domain of the parent domain.
613
614Support for power domains is provided through the pm_domain field of struct
615device. This field is a pointer to an object of type struct dev_pm_domain,
616defined in include/linux/pm.h, providing a set of power management callbacks
617analogous to the subsystem-level and device driver callbacks that are executed
618for the given device during all power transitions, instead of the respective
619subsystem-level callbacks. Specifically, if a device's pm_domain pointer is
620not NULL, the ->suspend() callback from the object pointed to by it will be
621executed instead of its subsystem's (e.g. bus type's) ->suspend() callback and
622analogously for all of the remaining callbacks. In other words, power
623management domain callbacks, if defined for the given device, always take
624precedence over the callbacks provided by the device's subsystem (e.g. bus
625type).
626
627The support for device power management domains is only relevant to platforms
628needing to use the same device driver power management callbacks in many
629different power domain configurations and wanting to avoid incorporating the
630support for power domains into subsystem-level callbacks, for example by
631modifying the platform bus type. Other platforms need not implement it or take
632it into account in any way.
633
634Devices may be defined as IRQ-safe which indicates to the PM core that their
635runtime PM callbacks may be invoked with disabled interrupts (see
636Documentation/power/runtime_pm.txt for more information). If an IRQ-safe
637device belongs to a PM domain, the runtime PM of the domain will be
638disallowed, unless the domain itself is defined as IRQ-safe. However, it
639makes sense to define a PM domain as IRQ-safe only if all the devices in it
640are IRQ-safe. Moreover, if an IRQ-safe domain has a parent domain, the runtime
641PM of the parent is only allowed if the parent itself is IRQ-safe too with the
642additional restriction that all child domains of an IRQ-safe parent must also
643be IRQ-safe.
644
645Device Low Power (suspend) States
646---------------------------------
647Device low-power states aren't standard. One device might only handle
648"on" and "off", while another might support a dozen different versions of
649"on" (how many engines are active?), plus a state that gets back to "on"
650faster than from a full "off".
651
652Some busses define rules about what different suspend states mean. PCI
653gives one example: after the suspend sequence completes, a non-legacy
654PCI device may not perform DMA or issue IRQs, and any wakeup events it
655issues would be issued through the PME# bus signal. Plus, there are
656several PCI-standard device states, some of which are optional.
657
658In contrast, integrated system-on-chip processors often use IRQs as the
659wakeup event sources (so drivers would call enable_irq_wake) and might
660be able to treat DMA completion as a wakeup event (sometimes DMA can stay
661active too, it'd only be the CPU and some peripherals that sleep).
662
663Some details here may be platform-specific. Systems may have devices that
664can be fully active in certain sleep states, such as an LCD display that's
665refreshed using DMA while most of the system is sleeping lightly ... and
666its frame buffer might even be updated by a DSP or other non-Linux CPU while
667the Linux control processor stays idle.
668
669Moreover, the specific actions taken may depend on the target system state.
670One target system state might allow a given device to be very operational;
671another might require a hard shut down with re-initialization on resume.
672And two different target systems might use the same device in different
673ways; the aforementioned LCD might be active in one product's "standby",
674but a different product using the same SOC might work differently.
675
676
677Power Management Notifiers
678--------------------------
679There are some operations that cannot be carried out by the power management
680callbacks discussed above, because the callbacks occur too late or too early.
681To handle these cases, subsystems and device drivers may register power
682management notifiers that are called before tasks are frozen and after they have
683been thawed. Generally speaking, the PM notifiers are suitable for performing
684actions that either require user space to be available, or at least won't
685interfere with user space.
686
687For details refer to Documentation/power/notifiers.txt.
688
689
690Runtime Power Management
691========================
692Many devices are able to dynamically power down while the system is still
693running. This feature is useful for devices that are not being used, and
694can offer significant power savings on a running system. These devices
695often support a range of runtime power states, which might use names such
696as "off", "sleep", "idle", "active", and so on. Those states will in some
697cases (like PCI) be partially constrained by the bus the device uses, and will
698usually include hardware states that are also used in system sleep states.
699
700A system-wide power transition can be started while some devices are in low
701power states due to runtime power management. The system sleep PM callbacks
702should recognize such situations and react to them appropriately, but the
703necessary actions are subsystem-specific.
704
705In some cases the decision may be made at the subsystem level while in other
706cases the device driver may be left to decide. In some cases it may be
707desirable to leave a suspended device in that state during a system-wide power
708transition, but in other cases the device must be put back into the full-power
709state temporarily, for example so that its system wakeup capability can be
710disabled. This all depends on the hardware and the design of the subsystem and
711device driver in question.
712
713During system-wide resume from a sleep state it's easiest to put devices into
714the full-power state, as explained in Documentation/power/runtime_pm.txt. Refer
715to that document for more information regarding this particular issue as well as
716for information on the device runtime power management framework in general.
diff --git a/Documentation/power/freezing-of-tasks.txt b/Documentation/power/freezing-of-tasks.txt
index 85894d83b352..af005770e767 100644
--- a/Documentation/power/freezing-of-tasks.txt
+++ b/Documentation/power/freezing-of-tasks.txt
@@ -197,7 +197,8 @@ tasks, since it generally exists anyway.
197 197
198A driver must have all firmwares it may need in RAM before suspend() is called. 198A driver must have all firmwares it may need in RAM before suspend() is called.
199If keeping them is not practical, for example due to their size, they must be 199If keeping them is not practical, for example due to their size, they must be
200requested early enough using the suspend notifier API described in notifiers.txt. 200requested early enough using the suspend notifier API described in
201Documentation/driver-api/pm/notifiers.rst.
201 202
202VI. Are there any precautions to be taken to prevent freezing failures? 203VI. Are there any precautions to be taken to prevent freezing failures?
203 204
diff --git a/Documentation/power/notifiers.txt b/Documentation/power/notifiers.txt
deleted file mode 100644
index a81fa254303d..000000000000
--- a/Documentation/power/notifiers.txt
+++ /dev/null
@@ -1,55 +0,0 @@
1Suspend notifiers
2 (C) 2007-2011 Rafael J. Wysocki <rjw@sisk.pl>, GPL
3
4There are some operations that subsystems or drivers may want to carry out
5before hibernation/suspend or after restore/resume, but they require the system
6to be fully functional, so the drivers' and subsystems' .suspend() and .resume()
7or even .prepare() and .complete() callbacks are not suitable for this purpose.
8For example, device drivers may want to upload firmware to their devices after
9resume/restore, but they cannot do it by calling request_firmware() from their
10.resume() or .complete() routines (user land processes are frozen at these
11points). The solution may be to load the firmware into memory before processes
12are frozen and upload it from there in the .resume() routine.
13A suspend/hibernation notifier may be used for this purpose.
14
15The subsystems or drivers having such needs can register suspend notifiers that
16will be called upon the following events by the PM core:
17
18PM_HIBERNATION_PREPARE The system is going to hibernate, tasks will be frozen
19 immediately. This is different from PM_SUSPEND_PREPARE
20 below because here we do additional work between notifiers
21 and drivers freezing.
22
23PM_POST_HIBERNATION The system memory state has been restored from a
24 hibernation image or an error occurred during
25 hibernation. Device drivers' restore callbacks have
26 been executed and tasks have been thawed.
27
28PM_RESTORE_PREPARE The system is going to restore a hibernation image.
29 If all goes well, the restored kernel will issue a
30 PM_POST_HIBERNATION notification.
31
32PM_POST_RESTORE An error occurred during restore from hibernation.
33 Device drivers' restore callbacks have been executed
34 and tasks have been thawed.
35
36PM_SUSPEND_PREPARE The system is preparing for suspend.
37
38PM_POST_SUSPEND The system has just resumed or an error occurred during
39 suspend. Device drivers' resume callbacks have been
40 executed and tasks have been thawed.
41
42It is generally assumed that whatever the notifiers do for
43PM_HIBERNATION_PREPARE, should be undone for PM_POST_HIBERNATION. Analogously,
44operations performed for PM_SUSPEND_PREPARE should be reversed for
45PM_POST_SUSPEND. Additionally, all of the notifiers are called for
46PM_POST_HIBERNATION if one of them fails for PM_HIBERNATION_PREPARE, and
47all of the notifiers are called for PM_POST_SUSPEND if one of them fails for
48PM_SUSPEND_PREPARE.
49
50The hibernation and suspend notifiers are called with pm_mutex held. They are
51defined in the usual way, but their last argument is meaningless (it is always
52NULL). To register and/or unregister a suspend notifier use the functions
53register_pm_notifier() and unregister_pm_notifier(), respectively, defined in
54include/linux/suspend.h . If you don't need to unregister the notifier, you can
55also use the pm_notifier() macro defined in include/linux/suspend.h .
diff --git a/Documentation/power/pci.txt b/Documentation/power/pci.txt
index 85c746cbab2c..a1b7f7158930 100644
--- a/Documentation/power/pci.txt
+++ b/Documentation/power/pci.txt
@@ -713,7 +713,7 @@ In addition to that the prepare() callback may carry out some operations
713preparing the device to be suspended, although it should not allocate memory 713preparing the device to be suspended, although it should not allocate memory
714(if additional memory is required to suspend the device, it has to be 714(if additional memory is required to suspend the device, it has to be
715preallocated earlier, for example in a suspend/hibernate notifier as described 715preallocated earlier, for example in a suspend/hibernate notifier as described
716in Documentation/power/notifiers.txt). 716in Documentation/driver-api/pm/notifiers.rst).
717 717
7183.1.2. suspend() 7183.1.2. suspend()
719 719
diff --git a/Documentation/power/pm_qos_interface.txt b/Documentation/power/pm_qos_interface.txt
index 129f7c0e1483..21d2d48f87a2 100644
--- a/Documentation/power/pm_qos_interface.txt
+++ b/Documentation/power/pm_qos_interface.txt
@@ -163,8 +163,7 @@ of flags and remove sysfs attributes pm_qos_no_power_off and pm_qos_remote_wakeu
163under the device's power directory. 163under the device's power directory.
164 164
165Notification mechanisms: 165Notification mechanisms:
166The per-device PM QoS framework has 2 different and distinct notification trees: 166The per-device PM QoS framework has a per-device notification tree.
167a per-device notification tree and a global notification tree.
168 167
169int dev_pm_qos_add_notifier(device, notifier): 168int dev_pm_qos_add_notifier(device, notifier):
170Adds a notification callback function for the device. 169Adds a notification callback function for the device.
@@ -174,16 +173,6 @@ is changed (for resume latency device PM QoS only).
174int dev_pm_qos_remove_notifier(device, notifier): 173int dev_pm_qos_remove_notifier(device, notifier):
175Removes the notification callback function for the device. 174Removes the notification callback function for the device.
176 175
177int dev_pm_qos_add_global_notifier(notifier):
178Adds a notification callback function in the global notification tree of the
179framework.
180The callback is called when the aggregated value for any device is changed
181(for resume latency device PM QoS only).
182
183int dev_pm_qos_remove_global_notifier(notifier):
184Removes the notification callback function from the global notification tree
185of the framework.
186
187 176
188Active state latency tolerance 177Active state latency tolerance
189 178
diff --git a/Documentation/power/runtime_pm.txt b/Documentation/power/runtime_pm.txt
index 4870980e967e..64546eb9a16a 100644
--- a/Documentation/power/runtime_pm.txt
+++ b/Documentation/power/runtime_pm.txt
@@ -100,7 +100,7 @@ knows what to do to handle the device).
100 * If the suspend callback returns an error code different from -EBUSY and 100 * If the suspend callback returns an error code different from -EBUSY and
101 -EAGAIN, the PM core regards this as a fatal error and will refuse to run 101 -EAGAIN, the PM core regards this as a fatal error and will refuse to run
102 the helper functions described in Section 4 for the device until its status 102 the helper functions described in Section 4 for the device until its status
103 is directly set to either'active', or 'suspended' (the PM core provides 103 is directly set to either 'active', or 'suspended' (the PM core provides
104 special helper functions for this purpose). 104 special helper functions for this purpose).
105 105
106In particular, if the driver requires remote wakeup capability (i.e. hardware 106In particular, if the driver requires remote wakeup capability (i.e. hardware
@@ -217,7 +217,7 @@ defined in include/linux/pm.h:
217 one to complete 217 one to complete
218 218
219 spinlock_t lock; 219 spinlock_t lock;
220 - lock used for synchronisation 220 - lock used for synchronization
221 221
222 atomic_t usage_count; 222 atomic_t usage_count;
223 - the usage counter of the device 223 - the usage counter of the device
@@ -565,7 +565,7 @@ appropriate to ensure that the device is not put back to sleep during the
565probe. This can happen with systems such as the network device layer. 565probe. This can happen with systems such as the network device layer.
566 566
567It may be desirable to suspend the device once ->probe() has finished. 567It may be desirable to suspend the device once ->probe() has finished.
568Therefore the driver core uses the asyncronous pm_request_idle() to submit a 568Therefore the driver core uses the asynchronous pm_request_idle() to submit a
569request to execute the subsystem-level idle callback for the device at that 569request to execute the subsystem-level idle callback for the device at that
570time. A driver that makes use of the runtime autosuspend feature, may want to 570time. A driver that makes use of the runtime autosuspend feature, may want to
571update the last busy mark before returning from ->probe(). 571update the last busy mark before returning from ->probe().
diff --git a/Documentation/pps/pps.txt b/Documentation/pps/pps.txt
index 50022b3c8ebf..1fdbd5447216 100644
--- a/Documentation/pps/pps.txt
+++ b/Documentation/pps/pps.txt
@@ -63,7 +63,7 @@ for instance) is a PPS source too, and if not they should provide the
63possibility to open another device as PPS source. 63possibility to open another device as PPS source.
64 64
65In LinuxPPS the PPS sources are simply char devices usually mapped 65In LinuxPPS the PPS sources are simply char devices usually mapped
66into files /dev/pps0, /dev/pps1, etc.. 66into files /dev/pps0, /dev/pps1, etc.
67 67
68 68
69PPS with USB to serial devices 69PPS with USB to serial devices
@@ -71,9 +71,12 @@ PPS with USB to serial devices
71 71
72It is possible to grab the PPS from an USB to serial device. However, 72It is possible to grab the PPS from an USB to serial device. However,
73you should take into account the latencies and jitter introduced by 73you should take into account the latencies and jitter introduced by
74the USB stack. Users has reported clock instability around +-1ms when 74the USB stack. Users have reported clock instability around +-1ms when
75synchronized with PPS through USB. This isn't suited for time server 75synchronized with PPS through USB. With USB 2.0, jitter may decrease
76synchronization. 76down to the order of 125 microseconds.
77
78This may be suitable for time server synchronization with NTP because
79of its undersampling and algorithms.
77 80
78If your device doesn't report PPS, you can check that the feature is 81If your device doesn't report PPS, you can check that the feature is
79supported by its driver. Most of the time, you only need to add a call 82supported by its driver. Most of the time, you only need to add a call
@@ -166,7 +169,8 @@ Testing the PPS support
166 169
167In order to test the PPS support even without specific hardware you can use 170In order to test the PPS support even without specific hardware you can use
168the ktimer driver (see the client subsection in the PPS configuration menu) 171the ktimer driver (see the client subsection in the PPS configuration menu)
169and the userland tools provided in the Documentation/pps/ directory. 172and the userland tools available in your distribution's pps-tools package,
173http://linuxpps.org , or https://github.com/ago/pps-tools .
170 174
171Once you have enabled the compilation of ktimer just modprobe it (if 175Once you have enabled the compilation of ktimer just modprobe it (if
172not statically compiled): 176not statically compiled):
@@ -183,8 +187,8 @@ and the run ppstest as follow:
183 source 0 - assert 1186592700.388931295, sequence: 365 - clear 0.000000000, sequence: 0 187 source 0 - assert 1186592700.388931295, sequence: 365 - clear 0.000000000, sequence: 0
184 source 0 - assert 1186592701.389032765, sequence: 366 - clear 0.000000000, sequence: 0 188 source 0 - assert 1186592701.389032765, sequence: 366 - clear 0.000000000, sequence: 0
185 189
186Please, note that to compile userland programs you need the file timepps.h 190Please, note that to compile userland programs you need the file timepps.h .
187(see Documentation/pps/). 191This is available in the pps-tools repository mentioned above.
188 192
189 193
190Generators 194Generators
diff --git a/Documentation/s390/Debugging390.txt b/Documentation/s390/Debugging390.txt
index 3df8babcdc41..5ae7f868a007 100644
--- a/Documentation/s390/Debugging390.txt
+++ b/Documentation/s390/Debugging390.txt
@@ -2116,7 +2116,7 @@ The sysrq key reading is very picky ( I have to type the keys in an
2116This is particularly useful for syncing disks unmounting & rebooting 2116This is particularly useful for syncing disks unmounting & rebooting
2117if the machine gets partially hung. 2117if the machine gets partially hung.
2118 2118
2119Read Documentation/sysrq.txt for more info 2119Read Documentation/admin-guide/sysrq.rst for more info
2120 2120
2121References: 2121References:
2122=========== 2122===========
diff --git a/Documentation/scsi/ChangeLog.megaraid_sas b/Documentation/scsi/ChangeLog.megaraid_sas
index 00ffdf187f0b..234ddabb23ef 100644
--- a/Documentation/scsi/ChangeLog.megaraid_sas
+++ b/Documentation/scsi/ChangeLog.megaraid_sas
@@ -549,7 +549,7 @@ ii. Reduced by 1 max cmds sent to FW from Driver to make the reply_q_sz same
5493 Older Version : 00.00.03.02 5493 Older Version : 00.00.03.02
550 550
551i. Send stop adapter to FW & Dump pending FW cmds before declaring adapter dead. 551i. Send stop adapter to FW & Dump pending FW cmds before declaring adapter dead.
552 New varible added to set dbg level. 552 New variable added to set dbg level.
553ii. Disable interrupt made as fn pointer as they are different for 1068 / 1078 553ii. Disable interrupt made as fn pointer as they are different for 1068 / 1078
554iii. Frame count optimization. Main frame can contain 2 SGE for 64 bit SGLs and 554iii. Frame count optimization. Main frame can contain 2 SGE for 64 bit SGLs and
555 3 SGE for 32 bit SGL 555 3 SGE for 32 bit SGL
diff --git a/Documentation/security/keys.txt b/Documentation/security/keys.txt
index 3849814bfe6d..0e03baf271bd 100644
--- a/Documentation/security/keys.txt
+++ b/Documentation/security/keys.txt
@@ -1151,8 +1151,21 @@ access the data:
1151 usage. This is called key->payload.rcu_data0. The following accessors 1151 usage. This is called key->payload.rcu_data0. The following accessors
1152 wrap the RCU calls to this element: 1152 wrap the RCU calls to this element:
1153 1153
1154 rcu_assign_keypointer(struct key *key, void *data); 1154 (a) Set or change the first payload pointer:
1155 void *rcu_dereference_key(struct key *key); 1155
1156 rcu_assign_keypointer(struct key *key, void *data);
1157
1158 (b) Read the first payload pointer with the key semaphore held:
1159
1160 [const] void *dereference_key_locked([const] struct key *key);
1161
1162 Note that the return value will inherit its constness from the key
1163 parameter. Static analysis will give an error if it things the lock
1164 isn't held.
1165
1166 (c) Read the first payload pointer with the RCU read lock held:
1167
1168 const void *dereference_key_rcu(const struct key *key);
1156 1169
1157 1170
1158=================== 1171===================
diff --git a/Documentation/security/self-protection.txt b/Documentation/security/self-protection.txt
index 3010576c9fca..141acfebe6ef 100644
--- a/Documentation/security/self-protection.txt
+++ b/Documentation/security/self-protection.txt
@@ -51,11 +51,17 @@ kernel, they are implemented in a way where the memory is temporarily
51made writable during the update, and then returned to the original 51made writable during the update, and then returned to the original
52permissions.) 52permissions.)
53 53
54In support of this are (the poorly named) CONFIG_DEBUG_RODATA and 54In support of this are CONFIG_STRICT_KERNEL_RWX and
55CONFIG_DEBUG_SET_MODULE_RONX, which seek to make sure that code is not 55CONFIG_STRICT_MODULE_RWX, which seek to make sure that code is not
56writable, data is not executable, and read-only data is neither writable 56writable, data is not executable, and read-only data is neither writable
57nor executable. 57nor executable.
58 58
59Most architectures have these options on by default and not user selectable.
60For some architectures like arm that wish to have these be selectable,
61the architecture Kconfig can select ARCH_OPTIONAL_KERNEL_RWX to enable
62a Kconfig prompt. CONFIG_ARCH_OPTIONAL_KERNEL_RWX_DEFAULT determines
63the default setting when ARCH_OPTIONAL_KERNEL_RWX is enabled.
64
59#### Function pointers and sensitive variables must not be writable 65#### Function pointers and sensitive variables must not be writable
60 66
61Vast areas of kernel memory contain function pointers that are looked 67Vast areas of kernel memory contain function pointers that are looked
diff --git a/Documentation/siphash.txt b/Documentation/siphash.txt
new file mode 100644
index 000000000000..908d348ff777
--- /dev/null
+++ b/Documentation/siphash.txt
@@ -0,0 +1,175 @@
1 SipHash - a short input PRF
2-----------------------------------------------
3Written by Jason A. Donenfeld <jason@zx2c4.com>
4
5SipHash is a cryptographically secure PRF -- a keyed hash function -- that
6performs very well for short inputs, hence the name. It was designed by
7cryptographers Daniel J. Bernstein and Jean-Philippe Aumasson. It is intended
8as a replacement for some uses of: `jhash`, `md5_transform`, `sha_transform`,
9and so forth.
10
11SipHash takes a secret key filled with randomly generated numbers and either
12an input buffer or several input integers. It spits out an integer that is
13indistinguishable from random. You may then use that integer as part of secure
14sequence numbers, secure cookies, or mask it off for use in a hash table.
15
161. Generating a key
17
18Keys should always be generated from a cryptographically secure source of
19random numbers, either using get_random_bytes or get_random_once:
20
21siphash_key_t key;
22get_random_bytes(&key, sizeof(key));
23
24If you're not deriving your key from here, you're doing it wrong.
25
262. Using the functions
27
28There are two variants of the function, one that takes a list of integers, and
29one that takes a buffer:
30
31u64 siphash(const void *data, size_t len, const siphash_key_t *key);
32
33And:
34
35u64 siphash_1u64(u64, const siphash_key_t *key);
36u64 siphash_2u64(u64, u64, const siphash_key_t *key);
37u64 siphash_3u64(u64, u64, u64, const siphash_key_t *key);
38u64 siphash_4u64(u64, u64, u64, u64, const siphash_key_t *key);
39u64 siphash_1u32(u32, const siphash_key_t *key);
40u64 siphash_2u32(u32, u32, const siphash_key_t *key);
41u64 siphash_3u32(u32, u32, u32, const siphash_key_t *key);
42u64 siphash_4u32(u32, u32, u32, u32, const siphash_key_t *key);
43
44If you pass the generic siphash function something of a constant length, it
45will constant fold at compile-time and automatically choose one of the
46optimized functions.
47
483. Hashtable key function usage:
49
50struct some_hashtable {
51 DECLARE_HASHTABLE(hashtable, 8);
52 siphash_key_t key;
53};
54
55void init_hashtable(struct some_hashtable *table)
56{
57 get_random_bytes(&table->key, sizeof(table->key));
58}
59
60static inline hlist_head *some_hashtable_bucket(struct some_hashtable *table, struct interesting_input *input)
61{
62 return &table->hashtable[siphash(input, sizeof(*input), &table->key) & (HASH_SIZE(table->hashtable) - 1)];
63}
64
65You may then iterate like usual over the returned hash bucket.
66
674. Security
68
69SipHash has a very high security margin, with its 128-bit key. So long as the
70key is kept secret, it is impossible for an attacker to guess the outputs of
71the function, even if being able to observe many outputs, since 2^128 outputs
72is significant.
73
74Linux implements the "2-4" variant of SipHash.
75
765. Struct-passing Pitfalls
77
78Often times the XuY functions will not be large enough, and instead you'll
79want to pass a pre-filled struct to siphash. When doing this, it's important
80to always ensure the struct has no padding holes. The easiest way to do this
81is to simply arrange the members of the struct in descending order of size,
82and to use offsetendof() instead of sizeof() for getting the size. For
83performance reasons, if possible, it's probably a good thing to align the
84struct to the right boundary. Here's an example:
85
86const struct {
87 struct in6_addr saddr;
88 u32 counter;
89 u16 dport;
90} __aligned(SIPHASH_ALIGNMENT) combined = {
91 .saddr = *(struct in6_addr *)saddr,
92 .counter = counter,
93 .dport = dport
94};
95u64 h = siphash(&combined, offsetofend(typeof(combined), dport), &secret);
96
976. Resources
98
99Read the SipHash paper if you're interested in learning more:
100https://131002.net/siphash/siphash.pdf
101
102
103~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
104
105HalfSipHash - SipHash's insecure younger cousin
106-----------------------------------------------
107Written by Jason A. Donenfeld <jason@zx2c4.com>
108
109On the off-chance that SipHash is not fast enough for your needs, you might be
110able to justify using HalfSipHash, a terrifying but potentially useful
111possibility. HalfSipHash cuts SipHash's rounds down from "2-4" to "1-3" and,
112even scarier, uses an easily brute-forcable 64-bit key (with a 32-bit output)
113instead of SipHash's 128-bit key. However, this may appeal to some
114high-performance `jhash` users.
115
116Danger!
117
118Do not ever use HalfSipHash except for as a hashtable key function, and only
119then when you can be absolutely certain that the outputs will never be
120transmitted out of the kernel. This is only remotely useful over `jhash` as a
121means of mitigating hashtable flooding denial of service attacks.
122
1231. Generating a key
124
125Keys should always be generated from a cryptographically secure source of
126random numbers, either using get_random_bytes or get_random_once:
127
128hsiphash_key_t key;
129get_random_bytes(&key, sizeof(key));
130
131If you're not deriving your key from here, you're doing it wrong.
132
1332. Using the functions
134
135There are two variants of the function, one that takes a list of integers, and
136one that takes a buffer:
137
138u32 hsiphash(const void *data, size_t len, const hsiphash_key_t *key);
139
140And:
141
142u32 hsiphash_1u32(u32, const hsiphash_key_t *key);
143u32 hsiphash_2u32(u32, u32, const hsiphash_key_t *key);
144u32 hsiphash_3u32(u32, u32, u32, const hsiphash_key_t *key);
145u32 hsiphash_4u32(u32, u32, u32, u32, const hsiphash_key_t *key);
146
147If you pass the generic hsiphash function something of a constant length, it
148will constant fold at compile-time and automatically choose one of the
149optimized functions.
150
1513. Hashtable key function usage:
152
153struct some_hashtable {
154 DECLARE_HASHTABLE(hashtable, 8);
155 hsiphash_key_t key;
156};
157
158void init_hashtable(struct some_hashtable *table)
159{
160 get_random_bytes(&table->key, sizeof(table->key));
161}
162
163static inline hlist_head *some_hashtable_bucket(struct some_hashtable *table, struct interesting_input *input)
164{
165 return &table->hashtable[hsiphash(input, sizeof(*input), &table->key) & (HASH_SIZE(table->hashtable) - 1)];
166}
167
168You may then iterate like usual over the returned hash bucket.
169
1704. Performance
171
172HalfSipHash is roughly 3 times slower than JenkinsHash. For many replacements,
173this will not be a problem, as the hashtable lookup isn't the bottleneck. And
174in general, this is probably a good sacrifice to make for the security and DoS
175resistance of HalfSipHash.
diff --git a/Documentation/sound/hd-audio/dp-mst.rst b/Documentation/sound/hd-audio/dp-mst.rst
index 58b72437e6c3..1617459e332f 100644
--- a/Documentation/sound/hd-audio/dp-mst.rst
+++ b/Documentation/sound/hd-audio/dp-mst.rst
@@ -19,6 +19,23 @@ PCM
19=== 19===
20To be added 20To be added
21 21
22Pin Initialization
23==================
24Each pin may have several device entries (virtual pins). On Intel platform,
25the device entries number is dynamically changed. If DP MST hub is connected,
26it is in DP MST mode, and the device entries number is 3. Otherwise, the
27device entries number is 1.
28
29To simplify the implementation, all the device entries will be initialized
30when bootup no matter whether it is in DP MST mode or not.
31
32Connection list
33===============
34DP MST reuses connection list code. The code can be reused because
35device entries on the same pin have the same connection list.
36
37This means DP MST gets the device entry connection list without the
38device entry setting.
22 39
23Jack 40Jack
24==== 41====
diff --git a/Documentation/sound/hd-audio/notes.rst b/Documentation/sound/hd-audio/notes.rst
index 168d0cfab1ce..9eeb9b468706 100644
--- a/Documentation/sound/hd-audio/notes.rst
+++ b/Documentation/sound/hd-audio/notes.rst
@@ -697,7 +697,7 @@ If it's a regression, at best, send alsa-info outputs of both working
697and non-working kernels. This is really helpful because we can 697and non-working kernels. This is really helpful because we can
698compare the codec registers directly. 698compare the codec registers directly.
699 699
700Send a bug report either the followings: 700Send a bug report either the following:
701 701
702kernel-bugzilla 702kernel-bugzilla
703 https://bugzilla.kernel.org/ 703 https://bugzilla.kernel.org/
diff --git a/Documentation/sparc/console.txt b/Documentation/sparc/console.txt
new file mode 100644
index 000000000000..5aa735a44e02
--- /dev/null
+++ b/Documentation/sparc/console.txt
@@ -0,0 +1,9 @@
1Steps for sending 'break' on sunhv console:
2===========================================
3
4On Baremetal:
5 1. press Esc + 'B'
6
7On LDOM:
8 1. press Ctrl + ']'
9 2. telnet> send break
diff --git a/Documentation/static-keys.txt b/Documentation/static-keys.txt
index ea8d7b4e53f0..32a25fad0c1b 100644
--- a/Documentation/static-keys.txt
+++ b/Documentation/static-keys.txt
@@ -155,7 +155,9 @@ or:
155 155
156There are a few functions and macros that architectures must implement in order 156There are a few functions and macros that architectures must implement in order
157to take advantage of this optimization. If there is no architecture support, we 157to take advantage of this optimization. If there is no architecture support, we
158simply fall back to a traditional, load, test, and jump sequence. 158simply fall back to a traditional, load, test, and jump sequence. Also, the
159struct jump_entry table must be at least 4-byte aligned because the
160static_key->entry field makes use of the two least significant bits.
159 161
160* select HAVE_ARCH_JUMP_LABEL, see: arch/x86/Kconfig 162* select HAVE_ARCH_JUMP_LABEL, see: arch/x86/Kconfig
161 163
diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
index a32b4b748644..bac23c198360 100644
--- a/Documentation/sysctl/kernel.txt
+++ b/Documentation/sysctl/kernel.txt
@@ -85,7 +85,7 @@ show up in /proc/sys/kernel:
85- softlockup_all_cpu_backtrace 85- softlockup_all_cpu_backtrace
86- soft_watchdog 86- soft_watchdog
87- stop-a [ SPARC only ] 87- stop-a [ SPARC only ]
88- sysrq ==> Documentation/sysrq.txt 88- sysrq ==> Documentation/admin-guide/sysrq.rst
89- sysctl_writes_strict 89- sysctl_writes_strict
90- tainted 90- tainted
91- threads-max 91- threads-max
diff --git a/Documentation/sysctl/net.txt b/Documentation/sysctl/net.txt
index f0480f7ea740..2ebabc93014a 100644
--- a/Documentation/sysctl/net.txt
+++ b/Documentation/sysctl/net.txt
@@ -54,6 +54,18 @@ Values :
54 1 - enable JIT hardening for unprivileged users only 54 1 - enable JIT hardening for unprivileged users only
55 2 - enable JIT hardening for all users 55 2 - enable JIT hardening for all users
56 56
57bpf_jit_kallsyms
58----------------
59
60When Berkeley Packet Filter Just in Time compiler is enabled, then compiled
61images are unknown addresses to the kernel, meaning they neither show up in
62traces nor in /proc/kallsyms. This enables export of these addresses, which
63can be used for debugging/tracing. If bpf_jit_harden is enabled, this feature
64is disabled.
65Values :
66 0 - disable JIT kallsyms export (default value)
67 1 - enable JIT kallsyms export for privileged users only
68
57dev_weight 69dev_weight
58-------------- 70--------------
59 71
@@ -61,6 +73,27 @@ The maximum number of packets that kernel can handle on a NAPI interrupt,
61it's a Per-CPU variable. 73it's a Per-CPU variable.
62Default: 64 74Default: 64
63 75
76dev_weight_rx_bias
77--------------
78
79RPS (e.g. RFS, aRFS) processing is competing with the registered NAPI poll function
80of the driver for the per softirq cycle netdev_budget. This parameter influences
81the proportion of the configured netdev_budget that is spent on RPS based packet
82processing during RX softirq cycles. It is further meant for making current
83dev_weight adaptable for asymmetric CPU needs on RX/TX side of the network stack.
84(see dev_weight_tx_bias) It is effective on a per CPU basis. Determination is based
85on dev_weight and is calculated multiplicative (dev_weight * dev_weight_rx_bias).
86Default: 1
87
88dev_weight_tx_bias
89--------------
90
91Scales the maximum number of packets that can be processed during a TX softirq cycle.
92Effective on a per CPU basis. Allows scaling of current dev_weight for asymmetric
93net stack processing needs. Be careful to avoid making TX softirq processing a CPU hog.
94Calculation is based on dev_weight (dev_weight * dev_weight_tx_bias).
95Default: 1
96
64default_qdisc 97default_qdisc
65-------------- 98--------------
66 99
diff --git a/Documentation/sysctl/vm.txt b/Documentation/sysctl/vm.txt
index 95ccbe6d79ce..b4ad97f10b8e 100644
--- a/Documentation/sysctl/vm.txt
+++ b/Documentation/sysctl/vm.txt
@@ -376,8 +376,8 @@ max_map_count:
376 376
377This file contains the maximum number of memory map areas a process 377This file contains the maximum number of memory map areas a process
378may have. Memory map areas are used as a side-effect of calling 378may have. Memory map areas are used as a side-effect of calling
379malloc, directly by mmap and mprotect, and also when loading shared 379malloc, directly by mmap, mprotect, and madvise, and also when loading
380libraries. 380shared libraries.
381 381
382While most applications need less than a thousand maps, certain 382While most applications need less than a thousand maps, certain
383programs, particularly malloc debuggers, may consume lots of them, 383programs, particularly malloc debuggers, may consume lots of them,
diff --git a/Documentation/thermal/nouveau_thermal b/Documentation/thermal/nouveau_thermal
index 60bc29357ac3..6e17a11efcb0 100644
--- a/Documentation/thermal/nouveau_thermal
+++ b/Documentation/thermal/nouveau_thermal
@@ -42,7 +42,7 @@ thresholds can be configured thanks to the following HWMON attributes:
42 * Critical: temp1_crit and temp1_crit_hyst; 42 * Critical: temp1_crit and temp1_crit_hyst;
43 * Shutdown: temp1_emergency and temp1_emergency_hyst. 43 * Shutdown: temp1_emergency and temp1_emergency_hyst.
44 44
45NOTE: Remember that the values are stored as milli degrees Celcius. Don't forget 45NOTE: Remember that the values are stored as milli degrees Celsius. Don't forget
46to multiply! 46to multiply!
47 47
48Fan management 48Fan management
diff --git a/Documentation/trace/kprobetrace.txt b/Documentation/trace/kprobetrace.txt
index e4991fb1eedc..41ef9d8efe95 100644
--- a/Documentation/trace/kprobetrace.txt
+++ b/Documentation/trace/kprobetrace.txt
@@ -12,7 +12,7 @@ kprobes can probe (this means, all functions body except for __kprobes
12functions). Unlike the Tracepoint based event, this can be added and removed 12functions). Unlike the Tracepoint based event, this can be added and removed
13dynamically, on the fly. 13dynamically, on the fly.
14 14
15To enable this feature, build your kernel with CONFIG_KPROBE_EVENT=y. 15To enable this feature, build your kernel with CONFIG_KPROBE_EVENTS=y.
16 16
17Similar to the events tracer, this doesn't need to be activated via 17Similar to the events tracer, this doesn't need to be activated via
18current_tracer. Instead of that, add probe points via 18current_tracer. Instead of that, add probe points via
diff --git a/Documentation/trace/postprocess/trace-vmscan-postprocess.pl b/Documentation/trace/postprocess/trace-vmscan-postprocess.pl
index 8f961ef2b457..ba976805853a 100644
--- a/Documentation/trace/postprocess/trace-vmscan-postprocess.pl
+++ b/Documentation/trace/postprocess/trace-vmscan-postprocess.pl
@@ -112,8 +112,8 @@ my $regex_direct_end_default = 'nr_reclaimed=([0-9]*)';
112my $regex_kswapd_wake_default = 'nid=([0-9]*) order=([0-9]*)'; 112my $regex_kswapd_wake_default = 'nid=([0-9]*) order=([0-9]*)';
113my $regex_kswapd_sleep_default = 'nid=([0-9]*)'; 113my $regex_kswapd_sleep_default = 'nid=([0-9]*)';
114my $regex_wakeup_kswapd_default = 'nid=([0-9]*) zid=([0-9]*) order=([0-9]*)'; 114my $regex_wakeup_kswapd_default = 'nid=([0-9]*) zid=([0-9]*) order=([0-9]*)';
115my $regex_lru_isolate_default = 'isolate_mode=([0-9]*) order=([0-9]*) nr_requested=([0-9]*) nr_scanned=([0-9]*) nr_taken=([0-9]*) file=([0-9]*)'; 115my $regex_lru_isolate_default = 'isolate_mode=([0-9]*) classzone_idx=([0-9]*) order=([0-9]*) nr_requested=([0-9]*) nr_scanned=([0-9]*) nr_skipped=([0-9]*) nr_taken=([0-9]*) lru=([a-z_]*)';
116my $regex_lru_shrink_inactive_default = 'nid=([0-9]*) zid=([0-9]*) nr_scanned=([0-9]*) nr_reclaimed=([0-9]*) priority=([0-9]*) flags=([A-Z_|]*)'; 116my $regex_lru_shrink_inactive_default = 'nid=([0-9]*) nr_scanned=([0-9]*) nr_reclaimed=([0-9]*) nr_dirty=([0-9]*) nr_writeback=([0-9]*) nr_congested=([0-9]*) nr_immediate=([0-9]*) nr_activate=([0-9]*) nr_ref_keep=([0-9]*) nr_unmap_fail=([0-9]*) priority=([0-9]*) flags=([A-Z_|]*)';
117my $regex_lru_shrink_active_default = 'lru=([A-Z_]*) nr_scanned=([0-9]*) nr_rotated=([0-9]*) priority=([0-9]*)'; 117my $regex_lru_shrink_active_default = 'lru=([A-Z_]*) nr_scanned=([0-9]*) nr_rotated=([0-9]*) priority=([0-9]*)';
118my $regex_writepage_default = 'page=([0-9a-f]*) pfn=([0-9]*) flags=([A-Z_|]*)'; 118my $regex_writepage_default = 'page=([0-9a-f]*) pfn=([0-9]*) flags=([A-Z_|]*)';
119 119
@@ -205,15 +205,15 @@ $regex_wakeup_kswapd = generate_traceevent_regex(
205$regex_lru_isolate = generate_traceevent_regex( 205$regex_lru_isolate = generate_traceevent_regex(
206 "vmscan/mm_vmscan_lru_isolate", 206 "vmscan/mm_vmscan_lru_isolate",
207 $regex_lru_isolate_default, 207 $regex_lru_isolate_default,
208 "isolate_mode", "order", 208 "isolate_mode", "classzone_idx", "order",
209 "nr_requested", "nr_scanned", "nr_taken", 209 "nr_requested", "nr_scanned", "nr_skipped", "nr_taken",
210 "file"); 210 "lru");
211$regex_lru_shrink_inactive = generate_traceevent_regex( 211$regex_lru_shrink_inactive = generate_traceevent_regex(
212 "vmscan/mm_vmscan_lru_shrink_inactive", 212 "vmscan/mm_vmscan_lru_shrink_inactive",
213 $regex_lru_shrink_inactive_default, 213 $regex_lru_shrink_inactive_default,
214 "nid", "zid", 214 "nid", "nr_scanned", "nr_reclaimed", "nr_dirty", "nr_writeback",
215 "nr_scanned", "nr_reclaimed", "priority", 215 "nr_congested", "nr_immediate", "nr_activate", "nr_ref_keep",
216 "flags"); 216 "nr_unmap_fail", "priority", "flags");
217$regex_lru_shrink_active = generate_traceevent_regex( 217$regex_lru_shrink_active = generate_traceevent_regex(
218 "vmscan/mm_vmscan_lru_shrink_active", 218 "vmscan/mm_vmscan_lru_shrink_active",
219 $regex_lru_shrink_active_default, 219 $regex_lru_shrink_active_default,
@@ -381,8 +381,8 @@ EVENT_PROCESS:
381 next; 381 next;
382 } 382 }
383 my $isolate_mode = $1; 383 my $isolate_mode = $1;
384 my $nr_scanned = $4; 384 my $nr_scanned = $5;
385 my $file = $6; 385 my $file = $8;
386 386
387 # To closer match vmstat scanning statistics, only count isolate_both 387 # To closer match vmstat scanning statistics, only count isolate_both
388 # and isolate_inactive as scanning. isolate_active is rotation 388 # and isolate_inactive as scanning. isolate_active is rotation
@@ -391,7 +391,7 @@ EVENT_PROCESS:
391 # isolate_both == 3 391 # isolate_both == 3
392 if ($isolate_mode != 2) { 392 if ($isolate_mode != 2) {
393 $perprocesspid{$process_pid}->{HIGH_NR_SCANNED} += $nr_scanned; 393 $perprocesspid{$process_pid}->{HIGH_NR_SCANNED} += $nr_scanned;
394 if ($file == 1) { 394 if ($file =~ /_file/) {
395 $perprocesspid{$process_pid}->{HIGH_NR_FILE_SCANNED} += $nr_scanned; 395 $perprocesspid{$process_pid}->{HIGH_NR_FILE_SCANNED} += $nr_scanned;
396 } else { 396 } else {
397 $perprocesspid{$process_pid}->{HIGH_NR_ANON_SCANNED} += $nr_scanned; 397 $perprocesspid{$process_pid}->{HIGH_NR_ANON_SCANNED} += $nr_scanned;
@@ -406,8 +406,8 @@ EVENT_PROCESS:
406 next; 406 next;
407 } 407 }
408 408
409 my $nr_reclaimed = $4; 409 my $nr_reclaimed = $3;
410 my $flags = $6; 410 my $flags = $12;
411 my $file = 0; 411 my $file = 0;
412 if ($flags =~ /RECLAIM_WB_FILE/) { 412 if ($flags =~ /RECLAIM_WB_FILE/) {
413 $file = 1; 413 $file = 1;
diff --git a/Documentation/trace/uprobetracer.txt b/Documentation/trace/uprobetracer.txt
index fa7b680ee8a0..bf526a7c5559 100644
--- a/Documentation/trace/uprobetracer.txt
+++ b/Documentation/trace/uprobetracer.txt
@@ -7,7 +7,7 @@
7Overview 7Overview
8-------- 8--------
9Uprobe based trace events are similar to kprobe based trace events. 9Uprobe based trace events are similar to kprobe based trace events.
10To enable this feature, build your kernel with CONFIG_UPROBE_EVENT=y. 10To enable this feature, build your kernel with CONFIG_UPROBE_EVENTS=y.
11 11
12Similar to the kprobe-event tracer, this doesn't need to be activated via 12Similar to the kprobe-event tracer, this doesn't need to be activated via
13current_tracer. Instead of that, add probe points via 13current_tracer. Instead of that, add probe points via
diff --git a/Documentation/translations/ja_JP/HOWTO b/Documentation/translations/ja_JP/HOWTO
index b03fc8047f03..4ebd20750ef1 100644
--- a/Documentation/translations/ja_JP/HOWTO
+++ b/Documentation/translations/ja_JP/HOWTO
@@ -111,7 +111,7 @@ Linux カーãƒãƒ«ã‚½ãƒ¼ã‚¹ãƒ„リーã¯å¹…広ã„範囲ã®ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆã‚’å
111カーãƒãƒ«ã®å¤‰æ›´ãŒã€ã‚«ãƒ¼ãƒãƒ«ãŒãƒ¦ãƒ¼ã‚¶ç©ºé–“ã«å…¬é–‹ã—ã¦ã„るインターフェイス㮠111カーãƒãƒ«ã®å¤‰æ›´ãŒã€ã‚«ãƒ¼ãƒãƒ«ãŒãƒ¦ãƒ¼ã‚¶ç©ºé–“ã«å…¬é–‹ã—ã¦ã„るインターフェイスã®
112変更を引ãèµ·ã“ã™å ´åˆã€ãã®å¤‰æ›´ã‚’説明ã™ã‚‹ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ãƒšãƒ¼ã‚¸ã®ãƒ‘ッãƒã‚„情報 112変更を引ãèµ·ã“ã™å ´åˆã€ãã®å¤‰æ›´ã‚’説明ã™ã‚‹ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ãƒšãƒ¼ã‚¸ã®ãƒ‘ッãƒã‚„情報
113をマニュアルページã®ãƒ¡ãƒ³ãƒ†ãƒŠ mtk.manpages@gmail.com ã«é€ã‚Šã€CC ã‚’ 113をマニュアルページã®ãƒ¡ãƒ³ãƒ†ãƒŠ mtk.manpages@gmail.com ã«é€ã‚Šã€CC ã‚’
114linux-api@ver.kernel.org ã«é€ã‚‹ã“ã¨ã‚’å‹§ã‚ã¾ã™ã€‚ 114linux-api@vger.kernel.org ã«é€ã‚‹ã“ã¨ã‚’å‹§ã‚ã¾ã™ã€‚
115 115
116以下ã¯ã‚«ãƒ¼ãƒãƒ«ã‚½ãƒ¼ã‚¹ãƒ„リーã«å«ã¾ã‚Œã¦ã„る読んã§ãŠãã¹ãファイルã®ä¸€è¦§ã§ 116以下ã¯ã‚«ãƒ¼ãƒãƒ«ã‚½ãƒ¼ã‚¹ãƒ„リーã«å«ã¾ã‚Œã¦ã„る読んã§ãŠãã¹ãファイルã®ä¸€è¦§ã§
117ã™- 117ã™-
diff --git a/Documentation/translations/ko_KR/howto.rst b/Documentation/translations/ko_KR/howto.rst
index 3b0c15b277e0..2333697251dd 100644
--- a/Documentation/translations/ko_KR/howto.rst
+++ b/Documentation/translations/ko_KR/howto.rst
@@ -289,8 +289,8 @@ pub/linux/kernel/v4.x/ 디렉토리ì—서 ì°¸ì¡°ë  ìˆ˜ 있다.개발 프로세ì
289Andrew Mortonì˜ ê¸€ì´ ìžˆë‹¤. 289Andrew Mortonì˜ ê¸€ì´ ìžˆë‹¤.
290 290
291 *"커ë„ì´ ì–¸ì œ ë°°í¬ë ì§€ëŠ” ì•„ë¬´ë„ ëª¨ë¥¸ë‹¤. 왜ëƒí•˜ë©´ ë°°í¬ëŠ” 알려진 291 *"커ë„ì´ ì–¸ì œ ë°°í¬ë ì§€ëŠ” ì•„ë¬´ë„ ëª¨ë¥¸ë‹¤. 왜ëƒí•˜ë©´ ë°°í¬ëŠ” 알려진
292 ë²„ê·¸ì˜ ìƒí™©ì— ë”°ë¼ ë°°í¬ë˜ëŠ” 것ì´ì§€ 미리정해 ë†“ì€ ì‹œê°„ì— ë”°ë¼ 292 ë²„ê·¸ì˜ ìƒí™©ì— ë”°ë¼ ë°°í¬ë˜ëŠ” 것ì´ì§€ 미리정해 ë†“ì€ ì‹œê°„ì— ë”°ë¼
293 ë°°í¬ë˜ëŠ” ê²ƒì€ ì•„ë‹ˆê¸° 때문ì´ë‹¤."* 293 ë°°í¬ë˜ëŠ” ê²ƒì€ ì•„ë‹ˆê¸° 때문ì´ë‹¤."*
294 294
2954.x.y - 안정 ì»¤ë„ íŠ¸ë¦¬ 2954.x.y - 안정 ì»¤ë„ íŠ¸ë¦¬
296~~~~~~~~~~~~~~~~~~~~~~ 296~~~~~~~~~~~~~~~~~~~~~~
diff --git a/Documentation/translations/ko_KR/memory-barriers.txt b/Documentation/translations/ko_KR/memory-barriers.txt
index a3228a676cc1..ce0b48d69eaa 100644
--- a/Documentation/translations/ko_KR/memory-barriers.txt
+++ b/Documentation/translations/ko_KR/memory-barriers.txt
@@ -662,6 +662,10 @@ include/linux/rcupdate.h ì˜ rcu_assign_pointer() 와 rcu_dereference() 를
662컨트롤 ì˜ì¡´ì„± 662컨트롤 ì˜ì¡´ì„±
663------------- 663-------------
664 664
665í˜„ìž¬ì˜ ì»´íŒŒì¼ëŸ¬ë“¤ì€ 컨트롤 ì˜ì¡´ì„±ì„ ì´í•´í•˜ê³  있지 않기 ë•Œë¬¸ì— ì»¨íŠ¸ë¡¤ ì˜ì¡´ì„±ì€
666약간 다루기 어려울 수 있습니다. ì´ ì„¹ì…˜ì˜ ëª©ì ì€ ì—¬ëŸ¬ë¶„ì´ ì»´íŒŒì¼ëŸ¬ì˜ 무시로
667ì¸í•´ ì—¬ëŸ¬ë¶„ì˜ ì½”ë“œê°€ ë§ê°€ì§€ëŠ” 걸 ë§‰ì„ ìˆ˜ 있ë„ë¡ ë•는ê²ë‹ˆë‹¤.
668
665로드-로드 컨트롤 ì˜ì¡´ì„±ì€ ë°ì´í„° ì˜ì¡´ì„± 배리어만으로는 정확히 ë™ìž‘í•  수가 669로드-로드 컨트롤 ì˜ì¡´ì„±ì€ ë°ì´í„° ì˜ì¡´ì„± 배리어만으로는 정확히 ë™ìž‘í•  수가
666없어서 ì½ê¸° 메모리 배리어를 필요로 합니다. ì•„ëž˜ì˜ ì½”ë“œë¥¼ 봅시다: 670없어서 ì½ê¸° 메모리 배리어를 필요로 합니다. ì•„ëž˜ì˜ ì½”ë“œë¥¼ 봅시다:
667 671
@@ -689,20 +693,21 @@ CPU 는 b ë¡œë¶€í„°ì˜ ë¡œë“œ 오í¼ë ˆì´ì…˜ì´ a ë¡œë¶€í„°ì˜ ë¡œë“œ 오í¼ë ˆ
689 693
690 q = READ_ONCE(a); 694 q = READ_ONCE(a);
691 if (q) { 695 if (q) {
692 WRITE_ONCE(b, p); 696 WRITE_ONCE(b, 1);
693 } 697 }
694 698
695컨트롤 ì˜ì¡´ì„±ì€ 보통 다른 íƒ€ìž…ì˜ ë°°ë¦¬ì–´ë“¤ê³¼ ì§ì„ ë§žì¶° 사용ë©ë‹ˆë‹¤. 그렇다곤 699컨트롤 ì˜ì¡´ì„±ì€ 보통 다른 íƒ€ìž…ì˜ ë°°ë¦¬ì–´ë“¤ê³¼ ì§ì„ ë§žì¶° 사용ë©ë‹ˆë‹¤. 그렇다곤
696하나, READ_ONCE() 는 반드시 사용해야 í•¨ì„ ë¶€ë”” 명심하세요! READ_ONCE() ê°€ 700하나, READ_ONCE() ë„ WRITE_ONCE() ë„ ì„ íƒì‚¬í•­ì´ ì•„ë‹ˆë¼ í•„ìˆ˜ì‚¬í•­ìž„ì„ ë¶€ë””
697없다면, 컴파ì¼ëŸ¬ê°€ 'a' ë¡œë¶€í„°ì˜ ë¡œë“œë¥¼ 'a' ë¡œë¶€í„°ì˜ ë˜ë‹¤ë¥¸ 로드와, 'b' ë¡œì˜ 701명심하세요! READ_ONCE() ê°€ 없다면, 컴파ì¼ëŸ¬ëŠ” 'a' ë¡œë¶€í„°ì˜ ë¡œë“œë¥¼ 'a' 로부터ì˜
698스토어를 'b' ë¡œì˜ ë˜ë‹¤ë¥¸ 스토어와 ì¡°í•©í•´ 버려 매우 비ì§ê´€ì ì¸ 결과를 초래할 수 702ë˜ë‹¤ë¥¸ 로드와 ì¡°í•©í•  수 있습니다. WRITE_ONCE() ê°€ 없다면, 컴파ì¼ëŸ¬ëŠ” 'b' 로ì˜
699있습니다. 703스토어를 'b' ë¡œì˜ ë˜ë¼ëŠ ìŠ¤í† ì–´ë“¤ê³¼ ì¡°í•©í•  수 있습니다. ë‘ ê²½ìš° ëª¨ë‘ ìˆœì„œì—
704있어 ìƒë‹¹ížˆ 비ì§ê´€ì ì¸ 결과를 초래할 수 있습니다.
700 705
701ì´ê±¸ë¡œ ëì´ ì•„ë‹Œê²Œ, 컴파ì¼ëŸ¬ê°€ 변수 'a' ì˜ ê°’ì´ í•­ìƒ 0ì´ ì•„ë‹ˆë¼ê³  ì¦ëª…í•  수 706ì´ê±¸ë¡œ ëì´ ì•„ë‹Œê²Œ, 컴파ì¼ëŸ¬ê°€ 변수 'a' ì˜ ê°’ì´ í•­ìƒ 0ì´ ì•„ë‹ˆë¼ê³  ì¦ëª…í•  수
702있다면, ì•žì˜ ì˜ˆì—서 "if" ë¬¸ì„ ì—†ì• ì„œ 다ìŒê³¼ ê°™ì´ ìµœì í™” í•  ìˆ˜ë„ ìžˆìŠµë‹ˆë‹¤: 707있다면, ì•žì˜ ì˜ˆì—서 "if" ë¬¸ì„ ì—†ì• ì„œ 다ìŒê³¼ ê°™ì´ ìµœì í™” í•  ìˆ˜ë„ ìžˆìŠµë‹ˆë‹¤:
703 708
704 q = a; 709 q = a;
705 b = p; /* BUG: Compiler and CPU can both reorder!!! */ 710 b = 1; /* BUG: Compiler and CPU can both reorder!!! */
706 711
707그러니 READ_ONCE() 를 반드시 사용하세요. 712그러니 READ_ONCE() 를 반드시 사용하세요.
708 713
@@ -712,11 +717,11 @@ CPU 는 b ë¡œë¶€í„°ì˜ ë¡œë“œ 오í¼ë ˆì´ì…˜ì´ a ë¡œë¶€í„°ì˜ ë¡œë“œ 오í¼ë ˆ
712 q = READ_ONCE(a); 717 q = READ_ONCE(a);
713 if (q) { 718 if (q) {
714 barrier(); 719 barrier();
715 WRITE_ONCE(b, p); 720 WRITE_ONCE(b, 1);
716 do_something(); 721 do_something();
717 } else { 722 } else {
718 barrier(); 723 barrier();
719 WRITE_ONCE(b, p); 724 WRITE_ONCE(b, 1);
720 do_something_else(); 725 do_something_else();
721 } 726 }
722 727
@@ -725,12 +730,12 @@ CPU 는 b ë¡œë¶€í„°ì˜ ë¡œë“œ 오í¼ë ˆì´ì…˜ì´ a ë¡œë¶€í„°ì˜ ë¡œë“œ 오í¼ë ˆ
725 730
726 q = READ_ONCE(a); 731 q = READ_ONCE(a);
727 barrier(); 732 barrier();
728 WRITE_ONCE(b, p); /* BUG: No ordering vs. load from a!!! */ 733 WRITE_ONCE(b, 1); /* BUG: No ordering vs. load from a!!! */
729 if (q) { 734 if (q) {
730 /* WRITE_ONCE(b, p); -- moved up, BUG!!! */ 735 /* WRITE_ONCE(b, 1); -- moved up, BUG!!! */
731 do_something(); 736 do_something();
732 } else { 737 } else {
733 /* WRITE_ONCE(b, p); -- moved up, BUG!!! */ 738 /* WRITE_ONCE(b, 1); -- moved up, BUG!!! */
734 do_something_else(); 739 do_something_else();
735 } 740 }
736 741
@@ -742,10 +747,10 @@ CPU 는 b ë¡œë¶€í„°ì˜ ë¡œë“œ 오í¼ë ˆì´ì…˜ì´ a ë¡œë¶€í„°ì˜ ë¡œë“œ 오í¼ë ˆ
742 747
743 q = READ_ONCE(a); 748 q = READ_ONCE(a);
744 if (q) { 749 if (q) {
745 smp_store_release(&b, p); 750 smp_store_release(&b, 1);
746 do_something(); 751 do_something();
747 } else { 752 } else {
748 smp_store_release(&b, p); 753 smp_store_release(&b, 1);
749 do_something_else(); 754 do_something_else();
750 } 755 }
751 756
@@ -754,10 +759,10 @@ CPU 는 b ë¡œë¶€í„°ì˜ ë¡œë“œ 오í¼ë ˆì´ì…˜ì´ a ë¡œë¶€í„°ì˜ ë¡œë“œ 오í¼ë ˆ
754 759
755 q = READ_ONCE(a); 760 q = READ_ONCE(a);
756 if (q) { 761 if (q) {
757 WRITE_ONCE(b, p); 762 WRITE_ONCE(b, 1);
758 do_something(); 763 do_something();
759 } else { 764 } else {
760 WRITE_ONCE(b, r); 765 WRITE_ONCE(b, 2);
761 do_something_else(); 766 do_something_else();
762 } 767 }
763 768
@@ -770,10 +775,10 @@ CPU 는 b ë¡œë¶€í„°ì˜ ë¡œë“œ 오í¼ë ˆì´ì…˜ì´ a ë¡œë¶€í„°ì˜ ë¡œë“œ 오í¼ë ˆ
770 775
771 q = READ_ONCE(a); 776 q = READ_ONCE(a);
772 if (q % MAX) { 777 if (q % MAX) {
773 WRITE_ONCE(b, p); 778 WRITE_ONCE(b, 1);
774 do_something(); 779 do_something();
775 } else { 780 } else {
776 WRITE_ONCE(b, r); 781 WRITE_ONCE(b, 2);
777 do_something_else(); 782 do_something_else();
778 } 783 }
779 784
@@ -781,7 +786,7 @@ CPU 는 b ë¡œë¶€í„°ì˜ ë¡œë“œ 오í¼ë ˆì´ì…˜ì´ a ë¡œë¶€í„°ì˜ ë¡œë“œ 오í¼ë ˆ
781ìœ„ì˜ ì½”ë“œë¥¼ 아래와 ê°™ì´ ë°”ê¿”ë²„ë¦´ 수 있습니다: 786ìœ„ì˜ ì½”ë“œë¥¼ 아래와 ê°™ì´ ë°”ê¿”ë²„ë¦´ 수 있습니다:
782 787
783 q = READ_ONCE(a); 788 q = READ_ONCE(a);
784 WRITE_ONCE(b, p); 789 WRITE_ONCE(b, 1);
785 do_something_else(); 790 do_something_else();
786 791
787ì´ë ‡ê²Œ ë˜ë©´, CPU 는 변수 'a' ë¡œë¶€í„°ì˜ ë¡œë“œì™€ 변수 'b' ë¡œì˜ ìŠ¤í† ì–´ 사ì´ì˜ 순서를 792ì´ë ‡ê²Œ ë˜ë©´, CPU 는 변수 'a' ë¡œë¶€í„°ì˜ ë¡œë“œì™€ 변수 'b' ë¡œì˜ ìŠ¤í† ì–´ 사ì´ì˜ 순서를
@@ -793,10 +798,10 @@ CPU 는 b ë¡œë¶€í„°ì˜ ë¡œë“œ 오í¼ë ˆì´ì…˜ì´ a ë¡œë¶€í„°ì˜ ë¡œë“œ 오í¼ë ˆ
793 q = READ_ONCE(a); 798 q = READ_ONCE(a);
794 BUILD_BUG_ON(MAX <= 1); /* Order load from a with store to b. */ 799 BUILD_BUG_ON(MAX <= 1); /* Order load from a with store to b. */
795 if (q % MAX) { 800 if (q % MAX) {
796 WRITE_ONCE(b, p); 801 WRITE_ONCE(b, 1);
797 do_something(); 802 do_something();
798 } else { 803 } else {
799 WRITE_ONCE(b, r); 804 WRITE_ONCE(b, 2);
800 do_something_else(); 805 do_something_else();
801 } 806 }
802 807
@@ -828,35 +833,33 @@ CPU 는 b ë¡œë¶€í„°ì˜ ë¡œë“œ 오í¼ë ˆì´ì…˜ì´ a ë¡œë¶€í„°ì˜ ë¡œë“œ 오í¼ë ˆ
828 833
829 q = READ_ONCE(a); 834 q = READ_ONCE(a);
830 if (q) { 835 if (q) {
831 WRITE_ONCE(b, p); 836 WRITE_ONCE(b, 1);
832 } else { 837 } else {
833 WRITE_ONCE(b, r); 838 WRITE_ONCE(b, 2);
834 } 839 }
835 WRITE_ONCE(c, 1); /* BUG: No ordering against the read from "a". */ 840 WRITE_ONCE(c, 1); /* BUG: No ordering against the read from 'a'. */
836 841
837컴파ì¼ëŸ¬ëŠ” volatile íƒ€ìž…ì— ëŒ€í•œ 액세스를 재배치 í•  수 없고 ì´ ì¡°ê±´ í•˜ì˜ "b" 842컴파ì¼ëŸ¬ëŠ” volatile íƒ€ìž…ì— ëŒ€í•œ 액세스를 재배치 í•  수 없고 ì´ ì¡°ê±´ í•˜ì˜ 'b'
838ë¡œì˜ ì“°ê¸°ë¥¼ 재배치 í•  수 없기 ë•Œë¬¸ì— ì—¬ê¸°ì— ìˆœì„œ ê·œì¹™ì´ ì¡´ìž¬í•œë‹¤ê³  주장하고 843ë¡œì˜ ì“°ê¸°ë¥¼ 재배치 í•  수 없기 ë•Œë¬¸ì— ì—¬ê¸°ì— ìˆœì„œ ê·œì¹™ì´ ì¡´ìž¬í•œë‹¤ê³  주장하고
839ì‹¶ì„ ê²ë‹ˆë‹¤. ë¶ˆí–‰ížˆë„ ì´ ê²½ìš°ì—, 컴파ì¼ëŸ¬ëŠ” 다ìŒì˜ ê°€ìƒì˜ pseudo-assembly 언어 844ì‹¶ì„ ê²ë‹ˆë‹¤. ë¶ˆí–‰ížˆë„ ì´ ê²½ìš°ì—, 컴파ì¼ëŸ¬ëŠ” 다ìŒì˜ ê°€ìƒì˜ pseudo-assembly 언어
840코드처럼 "b" ë¡œì˜ ë‘ê°œì˜ ì“°ê¸° 오í¼ë ˆì´ì…˜ì„ conditional-move ì¸ìŠ¤íŠ¸ëŸ­ì…˜ìœ¼ë¡œ 845코드처럼 'b' ë¡œì˜ ë‘ê°œì˜ ì“°ê¸° 오í¼ë ˆì´ì…˜ì„ conditional-move ì¸ìŠ¤íŠ¸ëŸ­ì…˜ìœ¼ë¡œ
841번역할 수 있습니다: 846번역할 수 있습니다:
842 847
843 ld r1,a 848 ld r1,a
844 ld r2,p
845 ld r3,r
846 cmp r1,$0 849 cmp r1,$0
847 cmov,ne r4,r2 850 cmov,ne r4,$1
848 cmov,eq r4,r3 851 cmov,eq r4,$2
849 st r4,b 852 st r4,b
850 st $1,c 853 st $1,c
851 854
852ì™„í™”ëœ ìˆœì„œ ê·œì¹™ì˜ CPU 는 "a" ë¡œë¶€í„°ì˜ ë¡œë“œì™€ "c" ë¡œì˜ ìŠ¤í† ì–´ 사ì´ì— ì–´ë–¤ 855ì™„í™”ëœ ìˆœì„œ ê·œì¹™ì˜ CPU 는 'a' ë¡œë¶€í„°ì˜ ë¡œë“œì™€ 'c' ë¡œì˜ ìŠ¤í† ì–´ 사ì´ì— ì–´ë–¤
853ì¢…ë¥˜ì˜ ì˜ì¡´ì„±ë„ ê°–ì§€ ì•Šì„ ê²ë‹ˆë‹¤. ì´ ì»¨íŠ¸ë¡¤ ì˜ì¡´ì„±ì€ ë‘ê°œì˜ cmov ì¸ìŠ¤íŠ¸ëŸ­ì…˜ê³¼ 856ì¢…ë¥˜ì˜ ì˜ì¡´ì„±ë„ ê°–ì§€ ì•Šì„ ê²ë‹ˆë‹¤. ì´ ì»¨íŠ¸ë¡¤ ì˜ì¡´ì„±ì€ ë‘ê°œì˜ cmov ì¸ìŠ¤íŠ¸ëŸ­ì…˜ê³¼
854ê±°ê¸°ì— ì˜ì¡´í•˜ëŠ” 스토어 ì—게만 ì ìš©ë  ê²ë‹ˆë‹¤. 짧게 ë§í•˜ìžë©´, 컨트롤 ì˜ì¡´ì„±ì€ 857ê±°ê¸°ì— ì˜ì¡´í•˜ëŠ” 스토어 ì—게만 ì ìš©ë  ê²ë‹ˆë‹¤. 짧게 ë§í•˜ìžë©´, 컨트롤 ì˜ì¡´ì„±ì€
855주어진 if ë¬¸ì˜ then 절과 else ì ˆì—게만 (그리고 ì´ ë‘ ì ˆ ë‚´ì—서 호출ë˜ëŠ” 858주어진 if ë¬¸ì˜ then 절과 else ì ˆì—게만 (그리고 ì´ ë‘ ì ˆ ë‚´ì—서 호출ë˜ëŠ”
856함수들ì—게까지) ì ìš©ë˜ì§€, ì´ if ë¬¸ì„ ë’¤ë”°ë¥´ëŠ” 코드ì—는 ì ìš©ë˜ì§€ 않습니다. 859함수들ì—게까지) ì ìš©ë˜ì§€, ì´ if ë¬¸ì„ ë’¤ë”°ë¥´ëŠ” 코드ì—는 ì ìš©ë˜ì§€ 않습니다.
857 860
858마지막으로, 컨트롤 ì˜ì¡´ì„±ì€ ì´í–‰ì„± (transitivity) ì„ ì œê³µí•˜ì§€ -않습니다-. ì´ê±´ 861마지막으로, 컨트롤 ì˜ì¡´ì„±ì€ ì´í–‰ì„± (transitivity) ì„ ì œê³µí•˜ì§€ -않습니다-. ì´ê±´
859x 와 y ê°€ 둘 다 0 ì´ë¼ëŠ” ì´ˆê¸°ê°’ì„ ê°€ì¡Œë‹¤ëŠ” 가정 í•˜ì˜ ë‘ê°œì˜ ì˜ˆì œë¡œ 862'x' 와 'y' ê°€ 둘 다 0 ì´ë¼ëŠ” ì´ˆê¸°ê°’ì„ ê°€ì¡Œë‹¤ëŠ” 가정 í•˜ì˜ ë‘ê°œì˜ ì˜ˆì œë¡œ
860ë³´ì´ê² ìŠµë‹ˆë‹¤: 863ë³´ì´ê² ìŠµë‹ˆë‹¤:
861 864
862 CPU 0 CPU 1 865 CPU 0 CPU 1
@@ -924,6 +927,9 @@ http://www.cl.cam.ac.uk/users/pes20/ppc-supplemental/test6.pdf 와
924 (*) 컨트롤 ì˜ì¡´ì„±ì€ ì´í–‰ì„±ì„ 제공하지 -않습니다-. ì´í–‰ì„±ì´ 필요하다면, 927 (*) 컨트롤 ì˜ì¡´ì„±ì€ ì´í–‰ì„±ì„ 제공하지 -않습니다-. ì´í–‰ì„±ì´ 필요하다면,
925 smp_mb() 를 사용하세요. 928 smp_mb() 를 사용하세요.
926 929
930 (*) 컴파ì¼ëŸ¬ëŠ” 컨트롤 ì˜ì¡´ì„±ì„ ì´í•´í•˜ê³  있지 않습니다. ë”°ë¼ì„œ 컴파ì¼ëŸ¬ê°€
931 ì—¬ëŸ¬ë¶„ì˜ ì½”ë“œë¥¼ ë§ê°€ëœ¨ë¦¬ì§€ 않ë„ë¡ í•˜ëŠ”ê±´ ì—¬ëŸ¬ë¶„ì´ í•´ì•¼ 하는 ì¼ìž…니다.
932
927 933
928SMP 배리어 ì§ë§žì¶”기 934SMP 배리어 ì§ë§žì¶”기
929-------------------- 935--------------------
diff --git a/Documentation/translations/zh_CN/CodingStyle b/Documentation/translations/zh_CN/CodingStyle
deleted file mode 100644
index dc101f48e713..000000000000
--- a/Documentation/translations/zh_CN/CodingStyle
+++ /dev/null
@@ -1,813 +0,0 @@
1Chinese translated version of Documentation/process/coding-style.rst
2
3If you have any comment or update to the content, please post to LKML directly.
4However, if you have problem communicating in English you can also ask the
5Chinese maintainer for help. Contact the Chinese maintainer, if this
6translation is outdated or there is problem with translation.
7
8Chinese maintainer: Zhang Le <r0bertz@gentoo.org>
9---------------------------------------------------------------------
10Documentation/process/coding-style.rst的中文翻译
11
12如果想评论或更新本文的内容,请直接å‘信到LKMLã€‚å¦‚æžœä½ ä½¿ç”¨è‹±æ–‡äº¤æµæœ‰å›°éš¾çš„è¯ï¼Œä¹Ÿå¯
13以å‘中文版维护者求助。如果本翻译更新ä¸åŠæ—¶æˆ–者翻译存在问题,请è”系中文版维护者。
14
15中文版维护者: å¼ ä¹ Zhang Le <r0bertz@gentoo.org>
16中文版翻译者: å¼ ä¹ Zhang Le <r0bertz@gentoo.org>
17中文版校译者: çŽ‹èª Wang Cong <xiyou.wangcong@gmail.com>
18 wheelz <kernel.zeng@gmail.com>
19 管旭东 Xudong Guan <xudong.guan@gmail.com>
20 Li Zefan <lizf@cn.fujitsu.com>
21 Wang Chen <wangchen@cn.fujitsu.com>
22以下为正文
23---------------------------------------------------------------------
24
25 Linux内核代ç é£Žæ ¼
26
27这是一个简短的文档,æè¿°äº† linux 内核的首选代ç é£Žæ ¼ã€‚代ç é£Žæ ¼æ˜¯å› äººè€Œå¼‚的,而且我
28䏿„¿æ„æŠŠè‡ªå·±çš„è§‚ç‚¹å¼ºåŠ ç»™ä»»ä½•äººï¼Œä½†è¿™å°±åƒæˆ‘去åšä»»ä½•事情都必须éµå¾ªçš„原则那样,我也
29希望在ç»å¤§å¤šæ•°äº‹ä¸Šä¿æŒè¿™ç§çš„æ€åº¦ã€‚è¯·ï¼ˆåœ¨å†™ä»£ç æ—¶ï¼‰è‡³å°‘考虑一下这里的代ç é£Žæ ¼ã€‚
30
31首先,我建议你打å°ä¸€ä»½ GNU 代ç è§„范,然åŽä¸è¦è¯»ã€‚烧了它,这是一个具有é‡å¤§è±¡å¾æ€§æ„义
32的动作。
33
34ä¸ç®¡æ€Žæ ·ï¼ŒçŽ°åœ¨æˆ‘ä»¬å¼€å§‹ï¼š
35
36
37 第一章:缩进
38
39制表符是 8 个字符,所以缩进也是 8 个字符。有些异端è¿åŠ¨è¯•å›¾å°†ç¼©è¿›å˜ä¸º 4(甚至 2ï¼ï¼‰
40个字符深,这几乎相当于å°è¯•将圆周率的值定义为 3。
41
42ç†ç”±ï¼šç¼©è¿›çš„全部æ„义就在于清楚的定义一个控制å—起止于何处。尤其是当你盯ç€ä½ çš„å±å¹•
43连续看了 20 å°æ—¶ä¹‹åŽï¼Œä½ å°†ä¼šå‘现大一点的缩进会使你更容易分辨缩进。
44
45现在,有些人会抱怨 8 个字符的缩进会使代ç å‘å³è¾¹ç§»åŠ¨çš„å¤ªè¿œï¼Œåœ¨ 80 个字符的终端å±å¹•上
46就很难读这样的代ç ã€‚è¿™ä¸ªé—®é¢˜çš„ç­”æ¡ˆæ˜¯ï¼Œå¦‚æžœä½ éœ€è¦ 3 级以上的缩进,ä¸ç®¡ç”¨ä½•ç§æ–¹å¼ä½ 
47的代ç å·²ç»æœ‰é—®é¢˜äº†ï¼Œåº”该修正你的程åºã€‚
48
49简而言之,8 个字符的缩进å¯ä»¥è®©ä»£ç æ›´å®¹æ˜“阅读,还有一个好处是当你的函数嵌套太深的
50时候å¯ä»¥ç»™ä½ è­¦å‘Šã€‚留心这个警告。
51
52在 switch 语å¥ä¸­æ¶ˆé™¤å¤šçº§ç¼©è¿›çš„é¦–é€‰çš„æ–¹å¼æ˜¯è®© “switch†和从属于它的 “case†标签
53对é½äºŽåŒä¸€åˆ—,而ä¸è¦ “两次缩进†“case†标签。比如:
54
55 switch (suffix) {
56 case 'G':
57 case 'g':
58 mem <<= 30;
59 break;
60 case 'M':
61 case 'm':
62 mem <<= 20;
63 break;
64 case 'K':
65 case 'k':
66 mem <<= 10;
67 /* fall through */
68 default:
69 break;
70 }
71
72ä¸è¦æŠŠå¤šä¸ªè¯­å¥æ”¾åœ¨ä¸€è¡Œé‡Œï¼Œé™¤éžä½ æœ‰ä»€ä¹ˆä¸œè¥¿è¦éšè—:
73
74 if (condition) do_this;
75 do_something_everytime;
76
77也ä¸è¦åœ¨ä¸€è¡Œé‡Œæ”¾å¤šä¸ªèµ‹å€¼è¯­å¥ã€‚内核代ç é£Žæ ¼è¶…级简å•。就是é¿å…å¯èƒ½å¯¼è‡´åˆ«äººè¯¯è¯»çš„表
78è¾¾å¼ã€‚
79
80é™¤äº†æ³¨é‡Šã€æ–‡æ¡£å’Œ Kconfig 之外,ä¸è¦ä½¿ç”¨ç©ºæ ¼æ¥ç¼©è¿›ï¼Œå‰é¢çš„例孿˜¯ä¾‹å¤–,是有æ„为之。
81
82选用一个好的编辑器,ä¸è¦åœ¨è¡Œå°¾ç•™ç©ºæ ¼ã€‚
83
84
85 第二章:把长的行和字符串打散
86
87代ç é£Žæ ¼çš„æ„ä¹‰å°±åœ¨äºŽä½¿ç”¨å¹³å¸¸ä½¿ç”¨çš„å·¥å…·æ¥ç»´æŒä»£ç çš„å¯è¯»æ€§å’Œå¯ç»´æŠ¤æ€§ã€‚
88
89æ¯ä¸€è¡Œçš„长度的é™åˆ¶æ˜¯ 80 列,我们强烈建议您éµå®ˆè¿™ä¸ªæƒ¯ä¾‹ã€‚
90
91长于 80 列的语å¥è¦æ‰“æ•£æˆæœ‰æ„义的片段。除éžè¶…过 80 列能显著增加å¯è¯»æ€§ï¼Œå¹¶ä¸”ä¸ä¼šéšè—
92ä¿¡æ¯ã€‚å­ç‰‡æ®µè¦æ˜Žæ˜¾çŸ­äºŽæ¯ç‰‡æ®µï¼Œå¹¶æ˜Žæ˜¾é å³ã€‚è¿™åŒæ ·é€‚用于有ç€å¾ˆé•¿å‚数列表的函数头。
93然而,ç»å¯¹ä¸è¦æ‰“散对用户å¯è§çš„字符串,例如 printk ä¿¡æ¯ï¼Œå› ä¸ºè¿™å°†å¯¼è‡´æ— æ³• grep 这些
94ä¿¡æ¯ã€‚
95
96 第三章:大括å·å’Œç©ºæ ¼çš„æ”¾ç½®
97
98C语言风格中å¦å¤–一个常è§é—®é¢˜æ˜¯å¤§æ‹¬å·çš„æ”¾ç½®ã€‚和缩进大å°ä¸åŒï¼Œé€‰æ‹©æˆ–弃用æŸç§æ”¾ç½®ç­–
99略并没有多少技术上的原因,ä¸è¿‡é¦–选的方å¼ï¼Œå°±åƒ Kernighan å’Œ Ritchie 展示给我们的,
100æ˜¯æŠŠèµ·å§‹å¤§æ‹¬å·æ”¾åœ¨è¡Œå°¾ï¼Œè€ŒæŠŠç»“æŸå¤§æ‹¬å·æ”¾åœ¨è¡Œé¦–,所以:
101
102 if (x is true) {
103 we do y
104 }
105
106这适用于所有的éžå‡½æ•°è¯­å¥å—(ifã€switchã€forã€whileã€do)。比如:
107
108 switch (action) {
109 case KOBJ_ADD:
110 return "add";
111 case KOBJ_REMOVE:
112 return "remove";
113 case KOBJ_CHANGE:
114 return "change";
115 default:
116 return NULL;
117 }
118
119ä¸è¿‡ï¼Œæœ‰ä¸€ä¸ªä¾‹å¤–ï¼Œé‚£å°±æ˜¯å‡½æ•°ï¼šå‡½æ•°çš„èµ·å§‹å¤§æ‹¬å·æ”¾ç½®äºŽä¸‹ä¸€è¡Œçš„开头,所以:
120
121 int function(int x)
122 {
123 body of function
124 }
125
126全世界的异端å¯èƒ½ä¼šæŠ±æ€¨è¿™ä¸ªä¸ä¸€è‡´æ€§æ˜¯â€¦â€¦å‘ƒâ€¦â€¦ä¸ä¸€è‡´çš„,ä¸è¿‡æ‰€æœ‰æ€ç»´å¥å…¨çš„人都知é“
127(a) K&R 是 _正确的_,并且 (b) K&R 是正确的。此外,ä¸ç®¡æ€Žæ ·å‡½æ•°éƒ½æ˜¯ç‰¹æ®Šçš„(C
128函数是ä¸èƒ½åµŒå¥—的)。
129
130注æ„结æŸå¤§æ‹¬å·ç‹¬è‡ªå æ®ä¸€è¡Œï¼Œé™¤éžå®ƒåŽé¢è·Ÿç€åŒä¸€ä¸ªè¯­å¥çš„剩余部分,也就是 do 语å¥ä¸­çš„
131“while†或者 if 语å¥ä¸­çš„ “elseâ€ï¼Œåƒè¿™æ ·ï¼š
132
133 do {
134 body of do-loop
135 } while (condition);
136
137和
138
139 if (x == y) {
140 ..
141 } else if (x > y) {
142 ...
143 } else {
144 ....
145 }
146
147ç†ç”±ï¼šK&R。
148
149也请注æ„è¿™ç§å¤§æ‹¬å·çš„æ”¾ç½®æ–¹å¼ä¹Ÿèƒ½ä½¿ç©ºï¼ˆæˆ–者差ä¸å¤šç©ºçš„ï¼‰è¡Œçš„æ•°é‡æœ€å°åŒ–ï¼ŒåŒæ—¶ä¸å¤±å¯
150读性。因此,由于你的å±å¹•上的新行是ä¸å¯å†ç”Ÿèµ„æºï¼ˆæƒ³æƒ³ 25 行的终端å±å¹•),你将会有更
151å¤šçš„ç©ºè¡Œæ¥æ”¾ç½®æ³¨é‡Šã€‚
152
153å½“åªæœ‰ä¸€ä¸ªå•独的语å¥çš„æ—¶å€™ï¼Œä¸ç”¨åŠ ä¸å¿…è¦çš„大括å·ã€‚
154
155 if (condition)
156 action();
157
158和
159
160 if (condition)
161 do_this();
162 else
163 do_that();
164
165这并ä¸é€‚ç”¨äºŽåªæœ‰ä¸€ä¸ªæ¡ä»¶åˆ†æ”¯æ˜¯å•语å¥çš„æƒ…况;这时所有分支都è¦ä½¿ç”¨å¤§æ‹¬å·ï¼š
166
167 if (condition) {
168 do_this();
169 do_that();
170 } else {
171 otherwise();
172 }
173
174 3.1:空格
175
176Linux 内核的空格使用方å¼ï¼ˆä¸»è¦ï¼‰å–决于它是用于函数还是关键字。(大多数)关键字åŽ
177è¦åŠ ä¸€ä¸ªç©ºæ ¼ã€‚å€¼å¾—æ³¨æ„的例外是 sizeofã€typeofã€alignof å’Œ __attribute__,这些
178关键字æŸäº›ç¨‹åº¦ä¸Šçœ‹èµ·æ¥æ›´åƒå‡½æ•°ï¼ˆå®ƒä»¬åœ¨ Linux 里也常常伴éšå°æ‹¬å·è€Œä½¿ç”¨ï¼Œå°½ç®¡åœ¨ C 里
179è¿™æ ·çš„å°æ‹¬å·ä¸æ˜¯å¿…éœ€çš„ï¼Œå°±åƒ â€œstruct fileinfo info†声明过åŽçš„ “sizeof infoâ€ï¼‰ã€‚
180
181æ‰€ä»¥åœ¨è¿™äº›å…³é”®å­—ä¹‹åŽæ”¾ä¸€ä¸ªç©ºæ ¼ï¼š
182
183 if, switch, case, for, do, while
184
185但是ä¸è¦åœ¨ sizeofã€typeofã€alignof 或者 __attribute__ è¿™äº›å…³é”®å­—ä¹‹åŽæ”¾ç©ºæ ¼ã€‚例如,
186
187 s = sizeof(struct file);
188
189ä¸è¦åœ¨å°æ‹¬å·é‡Œçš„表达å¼ä¸¤ä¾§åŠ ç©ºæ ¼ã€‚è¿™æ˜¯ä¸€ä¸ªå例:
190
191 s = sizeof( struct file );
192
193当声明指针类型或者返回指针类型的函数时,“*â€ çš„é¦–é€‰ä½¿ç”¨æ–¹å¼æ˜¯ä½¿ä¹‹é è¿‘å˜é‡å或者函
194æ•°åï¼Œè€Œä¸æ˜¯é è¿‘类型å。例å­ï¼š
195
196 char *linux_banner;
197 unsigned long long memparse(char *ptr, char **retptr);
198 char *match_strdup(substring_t *s);
199
200在大多数二元和三元æ“ä½œç¬¦ä¸¤ä¾§ä½¿ç”¨ä¸€ä¸ªç©ºæ ¼ï¼Œä¾‹å¦‚ä¸‹é¢æ‰€æœ‰è¿™äº›æ“作符:
201
202 = + - < > * / % | & ^ <= >= == != ? :
203
204但是一元æ“作符åŽä¸è¦åŠ ç©ºæ ¼ï¼š
205
206 & * + - ~ ! sizeof typeof alignof __attribute__ defined
207
208åŽç¼€è‡ªåŠ å’Œè‡ªå‡ä¸€å…ƒæ“作符å‰ä¸åŠ ç©ºæ ¼ï¼š
209
210 ++ --
211
212å‰ç¼€è‡ªåŠ å’Œè‡ªå‡ä¸€å…ƒæ“作符åŽä¸åŠ ç©ºæ ¼ï¼š
213
214 ++ --
215
216‘.’ å’Œ “->†结构体æˆå‘˜æ“作符å‰åŽä¸åŠ ç©ºæ ¼ã€‚
217
218ä¸è¦åœ¨è¡Œå°¾ç•™ç©ºç™½ã€‚有些å¯ä»¥è‡ªåŠ¨ç¼©è¿›çš„ç¼–è¾‘å™¨ä¼šåœ¨æ–°è¡Œçš„è¡Œé¦–åŠ å…¥é€‚é‡çš„空白,然åŽä½ 
219å°±å¯ä»¥ç›´æŽ¥åœ¨é‚£ä¸€è¡Œè¾“入代ç ã€‚ä¸è¿‡å‡å¦‚ä½ æœ€åŽæ²¡æœ‰åœ¨é‚£ä¸€è¡Œè¾“入代ç ï¼Œæœ‰äº›ç¼–辑器就ä¸
220会移除已ç»åŠ å…¥çš„ç©ºç™½ï¼Œå°±åƒä½ æ•…æ„ç•™ä¸‹ä¸€ä¸ªåªæœ‰ç©ºç™½çš„行。包å«è¡Œå°¾ç©ºç™½çš„行就这样产
221生了。
222
223当gitå‘现补ä¸åŒ…å«äº†è¡Œå°¾ç©ºç™½çš„æ—¶å€™ä¼šè­¦å‘Šä½ ï¼Œå¹¶ä¸”å¯ä»¥åº”ä½ çš„è¦æ±‚去掉行尾空白;ä¸è¿‡
224如果你是正在打一系列补ä¸ï¼Œè¿™æ ·åšä¼šå¯¼è‡´åŽé¢çš„è¡¥ä¸å¤±è´¥ï¼Œå› ä¸ºä½ æ”¹å˜äº†è¡¥ä¸çš„上下文。
225
226
227 第四章:命å
228
229C是一个简朴的语言,你的命å也应该这样。和 Modula-2 å’Œ Pascal 程åºå‘˜ä¸åŒï¼ŒC 程åºå‘˜
230ä¸ä½¿ç”¨ç±»ä¼¼ ThisVariableIsATemporaryCounter 这样åŽä¸½çš„å字。C 程åºå‘˜ä¼šç§°é‚£ä¸ªå˜é‡
231为 “tmpâ€ï¼Œè¿™æ ·å†™èµ·æ¥ä¼šæ›´å®¹æ˜“,而且至少ä¸ä¼šä»¤å…¶éš¾äºŽç†è§£ã€‚
232
233ä¸è¿‡ï¼Œè™½ç„¶æ··ç”¨å¤§å°å†™çš„åå­—æ˜¯ä¸æå€¡ä½¿ç”¨çš„ï¼Œä½†æ˜¯å…¨å±€å˜é‡è¿˜æ˜¯éœ€è¦ä¸€ä¸ªå…·æè¿°æ€§çš„åå­—
234。称一个全局函数为 “foo†是一个难以饶æ•的错误。
235
236全局å˜é‡ï¼ˆåªæœ‰å½“你真正需è¦å®ƒä»¬çš„æ—¶å€™å†ç”¨å®ƒï¼‰éœ€è¦æœ‰ä¸€ä¸ªå…·æè¿°æ€§çš„å字,就åƒå…¨å±€å‡½
237数。如果你有一个å¯ä»¥è®¡ç®—活动用户数é‡çš„函数,你应该å«å®ƒ “count_active_users()â€
238或者类似的å字,你ä¸åº”该å«å®ƒ “cntuser()â€ã€‚
239
240在函数å中包å«å‡½æ•°ç±»åž‹ï¼ˆæ‰€è°“çš„åŒˆç‰™åˆ©å‘½åæ³•)是脑å­å‡ºäº†é—®é¢˜â€”—编译器知é“那些类型而
241且能够检查那些类型,这样åšåªèƒ½æŠŠç¨‹åºå‘˜å¼„糊涂了。难怪微软总是制造出有问题的程åºã€‚
242
243本地å˜é‡å应该简短,而且能够表达相关的å«ä¹‰ã€‚å¦‚æžœä½ æœ‰ä¸€äº›éšæœºçš„æ•´æ•°åž‹çš„循环计数器
244,它应该被称为 “iâ€ã€‚å«å®ƒ “loop_counter†并无益处,如果它没有被误解的å¯èƒ½çš„è¯ã€‚
245类似的,“tmp†å¯ä»¥ç”¨æ¥ç§°å‘¼ä»»æ„类型的临时å˜é‡ã€‚
246
247如果你怕混淆了你的本地å˜é‡å,你就é‡åˆ°å¦ä¸€ä¸ªé—®é¢˜äº†ï¼Œå«åšå‡½æ•°å¢žé•¿è·å°”蒙失衡综åˆç—‡
248。请看第六章(函数)。
249
250
251 第五章:Typedef
252
253ä¸è¦ä½¿ç”¨ç±»ä¼¼ “vps_t†之类的东西。
254
255对结构体和指针使用 typedef 是一个错误。当你在代ç é‡Œçœ‹åˆ°ï¼š
256
257 vps_t a;
258
259è¿™ä»£è¡¨ä»€ä¹ˆæ„æ€å‘¢ï¼Ÿ
260
261相å,如果是这样
262
263 struct virtual_container *a;
264
265ä½ å°±çŸ¥é“ â€œa†是什么了。
266
267很多人认为 typedef “能æé«˜å¯è¯»æ€§â€ã€‚å®žé™…ä¸æ˜¯è¿™æ ·çš„。它们åªåœ¨ä¸‹åˆ—情况下有用:
268
269 (a) 完全ä¸é€æ˜Žçš„å¯¹è±¡ï¼ˆè¿™ç§æƒ…况下è¦ä¸»åŠ¨ä½¿ç”¨ typedef æ¥éšè—这个对象实际上是什么)。
270
271 例如:“pte_t†等ä¸é€æ˜Žå¯¹è±¡ï¼Œä½ åªèƒ½ç”¨åˆé€‚的访问函数æ¥è®¿é—®å®ƒä»¬ã€‚
272
273 注æ„ï¼ä¸é€æ˜Žæ€§å’Œâ€œè®¿é—®å‡½æ•°â€æœ¬èº«æ˜¯ä¸å¥½çš„。我们使用 pte_t 等类型的原因在于真的是
274 完全没有任何共用的å¯è®¿é—®ä¿¡æ¯ã€‚
275
276 (b) 清楚的整数类型,如此,这层抽象就å¯ä»¥å¸®åŠ©æ¶ˆé™¤åˆ°åº•æ˜¯ “int†还是 “long†的混淆。
277
278 u8/u16/u32 是完全没有问题的 typedef,ä¸è¿‡å®ƒä»¬æ›´ç¬¦åˆç±»åˆ« (d) è€Œä¸æ˜¯è¿™é‡Œã€‚
279
280 冿¬¡æ³¨æ„ï¼è¦è¿™æ ·åšï¼Œå¿…须事出有因。如果æŸä¸ªå˜é‡æ˜¯ “unsigned long“,那么没有必è¦
281
282 typedef unsigned long myflags_t;
283
284 ä¸è¿‡å¦‚果有一个明确的原因,比如它在æŸç§æƒ…况下å¯èƒ½ä¼šæ˜¯ä¸€ä¸ª “unsigned int†而在
285 其他情况下å¯èƒ½ä¸º “unsigned longâ€ï¼Œé‚£ä¹ˆå°±ä¸è¦çŠ¹è±«ï¼Œè¯·åŠ¡å¿…ä½¿ç”¨ typedef。
286
287 (c) 当你使用sparse按字é¢çš„创建一个新类型æ¥åšç±»åž‹æ£€æŸ¥çš„æ—¶å€™ã€‚
288
289 (d) 和标准C99类型相åŒçš„类型,在æŸäº›ä¾‹å¤–的情况下。
290
291 虽然让眼ç›å’Œè„‘ç­‹æ¥é€‚应新的标准类型比如 “uint32_t†ä¸éœ€è¦èŠ±å¾ˆå¤šæ—¶é—´ï¼Œå¯æ˜¯æœ‰äº›
292 人ä»ç„¶æ‹’ç»ä½¿ç”¨å®ƒä»¬ã€‚
293
294 因此,Linux 特有的等åŒäºŽæ ‡å‡†ç±»åž‹çš„ “u8/u16/u32/u64†类型和它们的有符å·ç±»åž‹æ˜¯è¢«
295 å…许的——尽管在你自己的新代ç ä¸­ï¼Œå®ƒä»¬ä¸æ˜¯å¼ºåˆ¶è¦æ±‚è¦ä½¿ç”¨çš„。
296
297 当编辑已ç»ä½¿ç”¨äº†æŸä¸ªç±»åž‹é›†çš„å·²æœ‰ä»£ç æ—¶ï¼Œä½ åº”该éµå¾ªé‚£äº›ä»£ç ä¸­å·²ç»åšå‡ºçš„选择。
298
299 (e) å¯ä»¥åœ¨ç”¨æˆ·ç©ºé—´å®‰å…¨ä½¿ç”¨çš„类型。
300
301 在æŸäº›ç”¨æˆ·ç©ºé—´å¯è§çš„结构体里,我们ä¸èƒ½è¦æ±‚C99类型而且ä¸èƒ½ç”¨ä¸Šé¢æåˆ°çš„ “u32â€
302 类型。因此,我们在与用户空间共享的所有结构体中使用 __u32 和类似的类型。
303
304å¯èƒ½è¿˜æœ‰å…¶ä»–的情况,ä¸è¿‡åŸºæœ¬çš„规则是永远ä¸è¦ä½¿ç”¨ typedef,除éžä½ å¯ä»¥æ˜Žç¡®çš„应用上
305è¿°æŸä¸ªè§„则中的一个。
306
307总的æ¥è¯´ï¼Œå¦‚果一个指针或者一个结构体里的元素å¯ä»¥åˆç†çš„被直接访问到,那么它们就ä¸
308应该是一个 typedef。
309
310
311 第六章:函数
312
313函数应该简短而漂亮,并且åªå®Œæˆä¸€ä»¶äº‹æƒ…。函数应该å¯ä»¥ä¸€å±æˆ–è€…ä¸¤å±æ˜¾ç¤ºå®Œï¼ˆæˆ‘们都知
314é“ ISO/ANSI å±å¹•大尿˜¯ 80x24),åªåšä¸€ä»¶äº‹æƒ…,而且把它åšå¥½ã€‚
315
316ä¸€ä¸ªå‡½æ•°çš„æœ€å¤§é•¿åº¦æ˜¯å’Œè¯¥å‡½æ•°çš„å¤æ‚度和缩进级数æˆå比的。所以,如果你有一个ç†è®ºä¸Š
317很简å•çš„åªæœ‰ä¸€ä¸ªå¾ˆé•¿ï¼ˆä½†æ˜¯ç®€å•)的 case 语å¥çš„函数,而且你需è¦åœ¨æ¯ä¸ª case 里åš
318很多很å°çš„事情,这样的函数尽管很长,但也是å¯ä»¥çš„。
319
320ä¸è¿‡ï¼Œå¦‚æžœä½ æœ‰ä¸€ä¸ªå¤æ‚çš„å‡½æ•°ï¼Œè€Œä¸”ä½ æ€€ç–‘ä¸€ä¸ªå¤©åˆ†ä¸æ˜¯å¾ˆé«˜çš„高中一年级学生å¯èƒ½ç”šè‡³
321æžä¸æ¸…楚这个函数的目的,你应该严格的éµå®ˆå‰é¢æåˆ°çš„长度é™åˆ¶ã€‚使用辅助函数,并为之
322å–个具æè¿°æ€§çš„å字(如果你觉得它们的性能很é‡è¦çš„è¯ï¼Œå¯ä»¥è®©ç¼–译器内è”它们,这样的
323æ•ˆæžœå¾€å¾€ä¼šæ¯”ä½ å†™ä¸€ä¸ªå¤æ‚函数的效果è¦å¥½ã€‚)
324
325函数的å¦å¤–ä¸€ä¸ªè¡¡é‡æ ‡å‡†æ˜¯æœ¬åœ°å˜é‡çš„æ•°é‡ã€‚此数é‡ä¸åº”超过 5ï¼10 个,å¦åˆ™ä½ çš„函数就有
326é—®é¢˜äº†ã€‚é‡æ–°è€ƒè™‘ä¸€ä¸‹ä½ çš„å‡½æ•°ï¼ŒæŠŠå®ƒåˆ†æ‹†æˆæ›´å°çš„函数。人的大脑一般å¯ä»¥è½»æ¾çš„åŒæ—¶è·Ÿ
327踪 7 个ä¸åŒçš„事物,如果å†å¢žå¤šçš„è¯ï¼Œå°±ä¼šç³Šæ¶‚了。å³ä¾¿ä½ èªé¢–过人,你也å¯èƒ½ä¼šè®°ä¸æ¸…ä½ 
3282 个星期å‰åšè¿‡çš„事情。
329
330åœ¨æºæ–‡ä»¶é‡Œï¼Œä½¿ç”¨ç©ºè¡Œéš”å¼€ä¸åŒçš„函数。如果该函数需è¦è¢«å¯¼å‡ºï¼Œå®ƒçš„ EXPORT* å®åº”该紧贴
331在它的结æŸå¤§æ‹¬å·ä¹‹ä¸‹ã€‚比如:
332
333 int system_is_up(void)
334 {
335 return system_state == SYSTEM_RUNNING;
336 }
337 EXPORT_SYMBOL(system_is_up);
338
339在函数原型中,包å«å‡½æ•°å和它们的数æ®ç±»åž‹ã€‚虽然Cè¯­è¨€é‡Œæ²¡æœ‰è¿™æ ·çš„è¦æ±‚,在 Linux 里这
340是æå€¡çš„åšæ³•,因为这样å¯ä»¥å¾ˆç®€å•的给读者æä¾›æ›´å¤šçš„æœ‰ä»·å€¼çš„ä¿¡æ¯ã€‚
341
342
343 第七章:集中的函数退出途径
344
345虽然被æŸäº›äººå£°ç§°å·²ç»è¿‡æ—¶ï¼Œä½†æ˜¯ goto 语å¥çš„等价物还是ç»å¸¸è¢«ç¼–è¯‘å™¨æ‰€ä½¿ç”¨ï¼Œå…·ä½“å½¢å¼æ˜¯
346æ— æ¡ä»¶è·³è½¬æŒ‡ä»¤ã€‚
347
348当一个函数从多个ä½ç½®é€€å‡ºï¼Œå¹¶ä¸”需è¦åšä¸€äº›ç±»ä¼¼æ¸…ç†çš„å¸¸è§æ“作时,goto 语å¥å°±å¾ˆæ–¹ä¾¿äº†ã€‚
349如果并ä¸éœ€è¦æ¸…ç†æ“作,那么直接 return å³å¯ã€‚
350
351ç†ç”±æ˜¯ï¼š
352
353- æ— æ¡ä»¶è¯­å¥å®¹æ˜“ç†è§£å’Œè·Ÿè¸ª
354- 嵌套程度å‡å°
355- å¯ä»¥é¿å…由于修改时忘记更新æŸä¸ªå•独的退出点而导致的错误
356- å‡è½»äº†ç¼–译器的工作,无需删除冗余代ç ;)
357
358 int fun(int a)
359 {
360 int result = 0;
361 char *buffer;
362
363 buffer = kmalloc(SIZE, GFP_KERNEL);
364 if (!buffer)
365 return -ENOMEM;
366
367 if (condition1) {
368 while (loop1) {
369 ...
370 }
371 result = 1;
372 goto out_buffer;
373 }
374 ...
375 out_buffer:
376 kfree(buffer);
377 return result;
378 }
379
380ä¸€ä¸ªéœ€è¦æ³¨æ„的常è§é”™è¯¯æ˜¯â€œä¸€ä¸ª err 错误â€ï¼Œå°±åƒè¿™æ ·ï¼š
381
382 err:
383 kfree(foo->bar);
384 kfree(foo);
385 return ret;
386
387这段代ç çš„错误是,在æŸäº›é€€å‡ºè·¯å¾„上 “foo†是 NULL。通常情况下,通过把它分离æˆä¸¤ä¸ª
388错误标签 “err_bar:†和 “err_foo:†æ¥ä¿®å¤è¿™ä¸ªé”™è¯¯ã€‚
389
390 第八章:注释
391
392注释是好的,ä¸è¿‡æœ‰è¿‡åº¦æ³¨é‡Šçš„å±é™©ã€‚永远ä¸è¦åœ¨æ³¨é‡Šé‡Œè§£é‡Šä½ çš„ä»£ç æ˜¯å¦‚何è¿ä½œçš„:更好
393çš„åšæ³•是让别人一看你的代ç å°±å¯ä»¥æ˜Žç™½ï¼Œè§£é‡Šå†™çš„å¾ˆå·®çš„ä»£ç æ˜¯æµªè´¹æ—¶é—´ã€‚
394
395一般的,你想è¦ä½ çš„æ³¨é‡Šå‘Šè¯‰åˆ«äººä½ çš„代ç åšäº†ä»€ä¹ˆï¼Œè€Œä¸æ˜¯æ€Žä¹ˆåšçš„。也请你ä¸è¦æŠŠæ³¨é‡Š
396æ”¾åœ¨ä¸€ä¸ªå‡½æ•°ä½“å†…éƒ¨ï¼šå¦‚æžœå‡½æ•°å¤æ‚到你需è¦ç‹¬ç«‹çš„æ³¨é‡Šå…¶ä¸­çš„一部分,你很å¯èƒ½éœ€è¦å›žåˆ°
397第六章看一看。你å¯ä»¥åšä¸€äº›å°æ³¨é‡Šæ¥æ³¨æ˜Žæˆ–警告æŸäº›å¾ˆèªæ˜Žï¼ˆæˆ–è€…æ§½ç³•ï¼‰çš„åšæ³•,但ä¸è¦
398加太多。你应该åšçš„,是把注释放在函数的头部,告诉人们它åšäº†ä»€ä¹ˆï¼Œä¹Ÿå¯ä»¥åŠ ä¸Šå®ƒåšè¿™
399些事情的原因。
400
401当注释内核API函数时,请使用 kernel-doc æ ¼å¼ã€‚请看
402Documentation/doc-guide/å’Œscripts/kernel-doc 以获得详细信æ¯ã€‚
403
404Linux的注释风格是 C89 “/* ... */†风格。ä¸è¦ä½¿ç”¨ C99 风格 “// ...†注释。
405
406长(多行)的首选注释风格是:
407
408 /*
409 * This is the preferred style for multi-line
410 * comments in the Linux kernel source code.
411 * Please use it consistently.
412 *
413 * Description: A column of asterisks on the left side,
414 * with beginning and ending almost-blank lines.
415 */
416
417对于在 net/ å’Œ drivers/net/ 的文件,首选的长(多行)注释风格有些ä¸åŒã€‚
418
419 /* The preferred comment style for files in net/ and drivers/net
420 * looks like this.
421 *
422 * It is nearly the same as the generally preferred comment style,
423 * but there is no initial almost-blank line.
424 */
425
426注释数æ®ä¹Ÿæ˜¯å¾ˆé‡è¦çš„,ä¸ç®¡æ˜¯åŸºæœ¬ç±»åž‹è¿˜æ˜¯è¡ç”Ÿç±»åž‹ã€‚为了方便实现这一点,æ¯ä¸€è¡Œåº”åª
427声明一个数æ®ï¼ˆä¸è¦ä½¿ç”¨é€—å·æ¥ä¸€æ¬¡å£°æ˜Žå¤šä¸ªæ•°æ®ï¼‰ã€‚这样你就有空间æ¥ä¸ºæ¯ä¸ªæ•°æ®å†™ä¸€æ®µ
428å°æ³¨é‡Šæ¥è§£é‡Šå®ƒä»¬çš„用途了。
429
430
431 第ä¹ç« ï¼šä½ å·²ç»æŠŠäº‹æƒ…弄糟了
432
433这没什么,我们都是这样。å¯èƒ½ä½ çš„使用了很长时间 Unix 的朋å‹å·²ç»å‘Šè¯‰ä½  “GNU emacs†能
434自动帮你格å¼åŒ– C æºä»£ç ï¼Œè€Œä¸”你也注æ„到了,确实是这样,ä¸è¿‡å®ƒæ‰€ä½¿ç”¨çš„默认值和我们
435想è¦çš„ç›¸åŽ»ç”šè¿œï¼ˆå®žé™…ä¸Šï¼Œç”šè‡³æ¯”éšæœºæ‰“的还è¦å·®â€”—无数个猴å­åœ¨ GNU emacs 里打字永远ä¸
436会创造出一个好程åºï¼‰ï¼ˆè¯‘注:请å‚考 Infinite Monkey Theorem)
437
438所以你è¦ä¹ˆæ”¾å¼ƒ GNU emacs,è¦ä¹ˆæ”¹å˜å®ƒè®©å®ƒä½¿ç”¨æ›´åˆç†çš„设定。è¦é‡‡ç”¨åŽä¸€ä¸ªæ–¹æ¡ˆï¼Œä½ å¯
439以把下é¢è¿™æ®µç²˜è´´åˆ°ä½ çš„ .emacs 文件里。
440
441(defun c-lineup-arglist-tabs-only (ignored)
442 "Line up argument lists by tabs, not spaces"
443 (let* ((anchor (c-langelem-pos c-syntactic-element))
444 (column (c-langelem-2nd-pos c-syntactic-element))
445 (offset (- (1+ column) anchor))
446 (steps (floor offset c-basic-offset)))
447 (* (max steps 1)
448 c-basic-offset)))
449
450(add-hook 'c-mode-common-hook
451 (lambda ()
452 ;; Add kernel style
453 (c-add-style
454 "linux-tabs-only"
455 '("linux" (c-offsets-alist
456 (arglist-cont-nonempty
457 c-lineup-gcc-asm-reg
458 c-lineup-arglist-tabs-only))))))
459
460(add-hook 'c-mode-hook
461 (lambda ()
462 (let ((filename (buffer-file-name)))
463 ;; Enable kernel mode for the appropriate files
464 (when (and filename
465 (string-match (expand-file-name "~/src/linux-trees")
466 filename))
467 (setq indent-tabs-mode t)
468 (setq show-trailing-whitespace t)
469 (c-set-style "linux-tabs-only")))))
470
471这会让 emacs 在 ~/src/linux-trees 目录下的 C æºæ–‡ä»¶èŽ·å¾—æ›´å¥½çš„å†…æ ¸ä»£ç é£Žæ ¼ã€‚
472
473ä¸è¿‡å°±ç®—ä½ å°è¯•让 emacs 正确的格å¼åŒ–代ç å¤±è´¥äº†ï¼Œä¹Ÿå¹¶ä¸æ„味ç€ä½ å¤±åŽ»äº†ä¸€åˆ‡ï¼šè¿˜å¯ä»¥ç”¨
474“indentâ€ã€‚
475
476ä¸è¿‡ï¼ŒGNU indent 也有和 GNU emacs 一样有问题的设定,所以你需è¦ç»™å®ƒä¸€äº›å‘½ä»¤é€‰é¡¹ã€‚ä¸
477过,这还ä¸ç®—太糟糕,因为就算是 GNU indent çš„ä½œè€…ä¹Ÿè®¤åŒ K&R çš„æƒå¨æ€§ï¼ˆGNU çš„äººå¹¶ä¸æ˜¯
478åäººï¼Œä»–ä»¬åªæ˜¯åœ¨è¿™ä¸ªé—®é¢˜ä¸Šè¢«ä¸¥é‡çš„误导了),所以你åªè¦ç»™ indent 指定选项 “-kr -i8â€
479(代表 “K&R,8 个字符缩进â€ï¼‰ï¼Œæˆ–者使用 “scripts/Lindentâ€ï¼Œè¿™æ ·å°±å¯ä»¥ä»¥æœ€æ—¶é«¦çš„æ–¹å¼
480缩进æºä»£ç ã€‚
481
482“indentâ€ æœ‰å¾ˆå¤šé€‰é¡¹ï¼Œç‰¹åˆ«æ˜¯é‡æ–°æ ¼å¼åŒ–注释的时候,你å¯èƒ½éœ€è¦çœ‹ä¸€ä¸‹å®ƒçš„æ‰‹å†Œé¡µã€‚ä¸è¿‡
483è®°ä½ï¼šâ€œindent†ä¸èƒ½ä¿®æ­£å的编程习惯。
484
485
486 第å章:Kconfig é…置文件
487
488对于é布æºç æ ‘的所有 Kconfig* é…置文件æ¥è¯´ï¼Œå®ƒä»¬ç¼©è¿›æ–¹å¼ä¸Ž C 代ç ç›¸æ¯”有所ä¸åŒã€‚紧挨
489在 “config†定义下é¢çš„行缩进一个制表符,帮助信æ¯åˆ™å†å¤šç¼©è¿› 2 个空格。比如:
490
491config AUDIT
492 bool "Auditing support"
493 depends on NET
494 help
495 Enable auditing infrastructure that can be used with another
496 kernel subsystem, such as SELinux (which requires this for
497 logging of avc messages output). Does not do system-call
498 auditing without CONFIG_AUDITSYSCALL.
499
500而那些å±é™©çš„功能(比如æŸäº›æ–‡ä»¶ç³»ç»Ÿçš„写支æŒï¼‰åº”该在它们的æç¤ºå­—符串里显著的声明这
501一点:
502
503config ADFS_FS_RW
504 bool "ADFS write support (DANGEROUS)"
505 depends on ADFS_FS
506 ...
507
508è¦æŸ¥çœ‹é…置文件的完整文档,请看 Documentation/kbuild/kconfig-language.txt。
509
510
511 第å一章:数æ®ç»“æž„
512
513如果一个数æ®ç»“构,在创建和销æ¯å®ƒçš„å•线执行环境之外å¯è§ï¼Œé‚£ä¹ˆå®ƒå¿…é¡»è¦æœ‰ä¸€ä¸ªå¼•用计
514数器。内核里没有垃圾收集(并且内核之外的垃圾收集慢且效率低下),这æ„味ç€ä½ ç»å¯¹éœ€
515è¦è®°å½•ä½ å¯¹è¿™ç§æ•°æ®ç»“构的使用情况。
516
517引用计数æ„味ç€ä½ èƒ½å¤Ÿé¿å…上é”,并且å…许多个用户并行访问这个数æ®ç»“构——而ä¸éœ€è¦æ‹…心
518这个数æ®ç»“构仅仅因为暂时ä¸è¢«ä½¿ç”¨å°±æ¶ˆå¤±äº†ï¼Œé‚£äº›ç”¨æˆ·å¯èƒ½ä¸è¿‡æ˜¯æ²‰ç¡äº†ä¸€é˜µæˆ–者åšäº†ä¸€
519些其他事情而已。
520
521注æ„上é”ä¸èƒ½å–ä»£å¼•ç”¨è®¡æ•°ã€‚ä¸Šé”æ˜¯ä¸ºäº†ä¿æŒæ•°æ®ç»“构的一致性,而引用计数是一个内存管
522ç†æŠ€å·§ã€‚é€šå¸¸äºŒè€…éƒ½éœ€è¦ï¼Œä¸è¦æŠŠä¸¤ä¸ªæžæ··äº†ã€‚
523
524很多数æ®ç»“构实际上有2级引用计数,它们通常有ä¸åŒâ€œç±»â€çš„用户。å­ç±»è®¡æ•°å™¨ç»Ÿè®¡å­ç±»ç”¨
525户的数é‡ï¼Œæ¯å½“å­ç±»è®¡æ•°å™¨å‡è‡³é›¶æ—¶ï¼Œå…¨å±€è®¡æ•°å™¨å‡ä¸€ã€‚
526
527è¿™ç§â€œå¤šçº§å¼•用计数â€çš„例å­å¯ä»¥åœ¨å†…存管ç†ï¼ˆâ€œstruct mm_structâ€ï¼šmm_users å’Œ mm_count)
528和文件系统(“struct super_blockâ€ï¼šs_countå’Œs_active)中找到。
529
530è®°ä½ï¼šå¦‚æžœå¦ä¸€ä¸ªæ‰§è¡Œçº¿ç´¢å¯ä»¥æ‰¾åˆ°ä½ çš„æ•°æ®ç»“构,但是这个数æ®ç»“构没有引用计数器,这
531里几乎肯定是一个 bug。
532
533
534 第å二章:å®ï¼Œæžšä¸¾å’ŒRTL
535
536用于定义常é‡çš„å®çš„åå­—åŠæžšä¸¾é‡Œçš„æ ‡ç­¾éœ€è¦å¤§å†™ã€‚
537
538#define CONSTANT 0x12345
539
540åœ¨å®šä¹‰å‡ ä¸ªç›¸å…³çš„å¸¸é‡æ—¶ï¼Œæœ€å¥½ç”¨æžšä¸¾ã€‚
541
542å®çš„å字请用大写字æ¯ï¼Œä¸è¿‡å½¢å¦‚函数的å®çš„åå­—å¯ä»¥ç”¨å°å†™å­—æ¯ã€‚
543
544一般的,如果能写æˆå†…è”函数就ä¸è¦å†™æˆåƒå‡½æ•°çš„å®ã€‚
545
546嫿œ‰å¤šä¸ªè¯­å¥çš„å®åº”该被包å«åœ¨ä¸€ä¸ª do-while 代ç å—里:
547
548 #define macrofun(a, b, c) \
549 do { \
550 if (a == 5) \
551 do_this(b, c); \
552 } while (0)
553
554使用å®çš„æ—¶å€™åº”é¿å…的事情:
555
5561) å½±å“æŽ§åˆ¶æµç¨‹çš„å®ï¼š
557
558 #define FOO(x) \
559 do { \
560 if (blah(x) < 0) \
561 return -EBUGGERED; \
562 } while (0)
563
564éžå¸¸ä¸å¥½ã€‚它看起æ¥åƒä¸€ä¸ªå‡½æ•°ï¼Œä¸è¿‡å´èƒ½å¯¼è‡´â€œè°ƒç”¨â€å®ƒçš„函数退出;ä¸è¦æ‰“乱读者大脑里
565的语法分æžå™¨ã€‚
566
5672) ä¾èµ–于一个固定å字的本地å˜é‡çš„å®ï¼š
568
569 #define FOO(val) bar(index, val)
570
571å¯èƒ½çœ‹èµ·æ¥åƒæ˜¯ä¸ªä¸é”™çš„东西,ä¸è¿‡å®ƒéžå¸¸å®¹æ˜“把读代ç çš„人æžç³Šæ¶‚,而且容易导致看起æ¥
572ä¸ç›¸å…³çš„æ”¹åЍ另æ¥é”™è¯¯ã€‚
573
5743) ä½œä¸ºå·¦å€¼çš„å¸¦å‚æ•°çš„å®ï¼š FOO(x) = y;如果有人把 FOO å˜æˆä¸€ä¸ªå†…è”函数的è¯ï¼Œè¿™ç§ç”¨
575法就会出错了。
576
5774) 忘记了优先级:使用表达å¼å®šä¹‰å¸¸é‡çš„å®å¿…须将表达å¼ç½®äºŽä¸€å¯¹å°æ‹¬å·ä¹‹å†…ã€‚å¸¦å‚æ•°çš„
578å®ä¹Ÿè¦æ³¨æ„此类问题。
579
580 #define CONSTANT 0x4000
581 #define CONSTEXP (CONSTANT | 3)
582
5835) 在å®é‡Œå®šä¹‰ç±»ä¼¼å‡½æ•°çš„æœ¬åœ°å˜é‡æ—¶å‘½å冲çªï¼š
584
585 #define FOO(x) \
586 ({ \
587 typeof(x) ret; \
588 ret = calc_ret(x); \
589 (ret); \
590 })
591
592ret 是本地å˜é‡çš„通用åå­— - __foo_ret æ›´ä¸å®¹æ˜“与一个已存在的å˜é‡å†²çªã€‚
593
594cpp 手册对å®çš„讲解很详细。gcc internals 手册也详细讲解了 RTL(译注:register
595transfer language),内核里的汇编语言ç»å¸¸ç”¨åˆ°å®ƒã€‚
596
597
598 第å三章:打å°å†…核消æ¯
599
600内核开å‘者应该是å—过良好教育的。请一定注æ„内核信æ¯çš„æ‹¼å†™ï¼Œä»¥ç»™äººä»¥å¥½çš„å°è±¡ã€‚ä¸è¦
601用ä¸è§„范的å•è¯æ¯”如 “dontâ€ï¼Œè€Œè¦ç”¨ “do notâ€æˆ–者 “don'tâ€ã€‚ä¿è¯è¿™äº›ä¿¡æ¯ç®€å•ã€æ˜Žäº†ã€
602无歧义。
603
604内核信æ¯ä¸å¿…以å¥å·ï¼ˆè¯‘注:英文å¥å·ï¼Œå³ç‚¹ï¼‰ç»“æŸã€‚
605
606åœ¨å°æ‹¬å·é‡Œæ‰“å°æ•°å­— (%d) 没有任何价值,应该é¿å…这样åšã€‚
607
608<linux/device.h> 里有一些驱动模型诊断å®ï¼Œä½ åº”该使用它们,以确ä¿ä¿¡æ¯å¯¹åº”于正确的
609设备和驱动,并且被标记了正确的消æ¯çº§åˆ«ã€‚è¿™äº›å®æœ‰ï¼šdev_err(),dev_warn(),
610dev_info() 等等。对于那些ä¸å’ŒæŸä¸ªç‰¹å®šè®¾å¤‡ç›¸å…³è¿žçš„ä¿¡æ¯ï¼Œ<linux/printk.h> 定义了
611pr_notice(),pr_info(),pr_warn(),pr_err() 和其他。
612
613写出好的调试信æ¯å¯ä»¥æ˜¯ä¸€ä¸ªå¾ˆå¤§çš„æŒ‘战;一旦你写出åŽï¼Œè¿™äº›ä¿¡æ¯åœ¨è¿œç¨‹é™¤é”™æ—¶èƒ½æä¾›æžå¤§
614的帮助。然而打å°è°ƒè¯•ä¿¡æ¯çš„å¤„ç†æ–¹å¼åŒæ‰“å°éžè°ƒè¯•ä¿¡æ¯ä¸åŒã€‚å…¶ä»– pr_XXX() 函数能无æ¡ä»¶åœ°
615打å°ï¼Œpr_debug() å´ä¸ï¼›é»˜è®¤æƒ…况下它ä¸ä¼šè¢«ç¼–译,除éžå®šä¹‰äº† DEBUG 或设定了
616CONFIG_DYNAMIC_DEBUGã€‚å®žé™…è¿™åŒæ ·æ˜¯ä¸ºäº† dev_dbg(),一个相关约定是在一个已ç»å¼€å¯äº†
617DEBUG 时,使用 VERBOSE_DEBUG æ¥æ·»åŠ  dev_vdbg()。
618
619许多å­ç³»ç»Ÿæ‹¥æœ‰ Kconfig 调试选项æ¥å¼€å¯ -DDEBUG 在对应的 Makefile 里é¢ï¼›åœ¨å…¶ä»–
620情况下,特殊文件使用 #define DEBUG。当一æ¡è°ƒè¯•ä¿¡æ¯éœ€è¦è¢«æ— æ¡ä»¶æ‰“å°æ—¶ï¼Œä¾‹å¦‚,如果
621å·²ç»åŒ…å«ä¸€ä¸ªè°ƒè¯•相关的 #ifdef æ¡ä»¶ï¼Œprintk(KERN_DEBUG ...) å°±å¯è¢«ä½¿ç”¨ã€‚
622
623
624 第å四章:分é…内存
625
626内核æä¾›äº†ä¸‹é¢çš„一般用途的内存分é…函数:
627kmalloc(),kzalloc(),kmalloc_array(),kcalloc(),vmalloc() 和 vzalloc()。
628请å‚考 API æ–‡æ¡£ä»¥èŽ·å–æœ‰å…³å®ƒä»¬çš„详细信æ¯ã€‚
629
630传递结构体大å°çš„首选形弿˜¯è¿™æ ·çš„:
631
632 p = kmalloc(sizeof(*p), ...);
633
634å¦å¤–一ç§ä¼ é€’æ–¹å¼ä¸­ï¼Œsizeof çš„æ“作数是结构体的å字,这样会é™ä½Žå¯è¯»æ€§ï¼Œå¹¶ä¸”å¯èƒ½ä¼šå¼•
635å…¥ bug。有å¯èƒ½æŒ‡é’ˆå˜é‡ç±»åž‹è¢«æ”¹å˜æ—¶ï¼Œè€Œå¯¹åº”的传递给内存分é…函数的 sizeof 的结果ä¸å˜ã€‚
636
637强制转æ¢ä¸€ä¸ª void 指针返回值是多余的。C 语言本身ä¿è¯äº†ä»Ž void 指针到其他任何指针类型
638çš„è½¬æ¢æ˜¯æ²¡æœ‰é—®é¢˜çš„。
639
640分é…ä¸€ä¸ªæ•°ç»„çš„é¦–é€‰å½¢å¼æ˜¯è¿™æ ·çš„:
641
642 p = kmalloc_array(n, sizeof(...), ...);
643
644分é…ä¸€ä¸ªé›¶é•¿æ•°ç»„çš„é¦–é€‰å½¢å¼æ˜¯è¿™æ ·çš„:
645
646 p = kcalloc(n, sizeof(...), ...);
647
648两ç§å½¢å¼æ£€æŸ¥åˆ†é…å¤§å° n * sizeof(...) 的溢出,如果溢出返回 NULL。
649
650
651 第å五章:内è”弊病
652
653有一个常è§çš„误解是内è”函数是 gcc æä¾›çš„å¯ä»¥è®©ä»£ç è¿è¡Œæ›´å¿«çš„一个选项。虽然使用内è”
654函数有时候是æ°å½“çš„ï¼ˆæ¯”å¦‚ä½œä¸ºä¸€ç§æ›¿ä»£å®çš„æ–¹å¼ï¼Œè¯·çœ‹ç¬¬å二章),ä¸è¿‡å¾ˆå¤šæƒ…况䏋䏿˜¯
655这样。inline 关键字的过度使用会使内核å˜å¤§ï¼Œä»Žè€Œä½¿æ•´ä¸ªç³»ç»Ÿè¿è¡Œé€Ÿåº¦å˜æ…¢ã€‚因为大内核
656会å ç”¨æ›´å¤šçš„æŒ‡ä»¤é«˜é€Ÿç¼“存(译注:一级缓存通常是指令缓存和数æ®ç¼“存分开的)而且会导
657致 pagecache çš„å¯ç”¨å†…å­˜å‡å°‘。想象一下,一次pagecache未命中就会导致一次ç£ç›˜å¯»å€ï¼Œ
658将耗时 5 毫秒。5 毫秒的时间内 CPU 能执行很多很多指令。
659
660一个基本的原则是如果一个函数有 3 行以上,就ä¸è¦æŠŠå®ƒå˜æˆå†…è”函数。这个原则的一个例
661å¤–æ˜¯ï¼Œå¦‚æžœä½ çŸ¥é“æŸä¸ªå‚数是一个编译时常é‡ï¼Œè€Œä¸”因为这个常é‡ä½ ç¡®å®šç¼–译器在编译时能
662优化掉你的函数的大部分代ç ï¼Œé‚£ä»ç„¶å¯ä»¥ç»™å®ƒåŠ ä¸Š inline 关键字。kmalloc() 内è”函数就
663是一个很好的例å­ã€‚
664
665人们ç»å¸¸ä¸»å¼ ç»™ static 的而且åªç”¨äº†ä¸€æ¬¡çš„函数加上 inline,如此ä¸ä¼šæœ‰ä»»ä½•æŸå¤±ï¼Œå› ä¸ºæ²¡
666有什么好æƒè¡¡çš„ã€‚è™½ç„¶ä»ŽæŠ€æœ¯ä¸Šè¯´è¿™æ˜¯æ­£ç¡®çš„ï¼Œä½†æ˜¯å®žé™…ä¸Šè¿™ç§æƒ…况下å³ä½¿ä¸åŠ  inline gcc
667也å¯ä»¥è‡ªåŠ¨ä½¿å…¶å†…è”。而且其他用户å¯èƒ½ä¼šè¦æ±‚移除 inline,由此而æ¥çš„争论会抵消 inline
668自身的潜在价值,得ä¸å¿å¤±ã€‚
669
670
671 第å六章:函数返回值åŠå‘½å
672
673函数å¯ä»¥è¿”回很多ç§ä¸åŒç±»åž‹çš„值,最常è§çš„ä¸€ç§æ˜¯è¡¨æ˜Žå‡½æ•°æ‰§è¡ŒæˆåŠŸæˆ–è€…å¤±è´¥çš„å€¼ã€‚è¿™æ ·
674的一个值å¯ä»¥è¡¨ç¤ºä¸ºä¸€ä¸ªé”™è¯¯ä»£ç æ•´æ•°ï¼ˆ-Exxxï¼å¤±è´¥ï¼Œ0ï¼æˆåŠŸï¼‰æˆ–è€…ä¸€ä¸ªâ€œæˆåŠŸâ€å¸ƒå°”值(
6750ï¼å¤±è´¥ï¼Œéž0ï¼æˆåŠŸï¼‰ã€‚
676
677æ··åˆä½¿ç”¨è¿™ä¸¤ç§è¡¨è¾¾æ–¹å¼æ˜¯éš¾äºŽå‘现的 bug çš„æ¥æºã€‚如果 C 语言本身严格区分整形和布尔型å˜
678é‡ï¼Œé‚£ä¹ˆç¼–译器就能够帮我们å‘现这些错误……ä¸è¿‡ C 语言ä¸åŒºåˆ†ã€‚为了é¿å…äº§ç”Ÿè¿™ç§ bug,请
679éµå¾ªä¸‹é¢çš„æƒ¯ä¾‹ï¼š
680
681 如果函数的åå­—æ˜¯ä¸€ä¸ªåŠ¨ä½œæˆ–è€…å¼ºåˆ¶æ€§çš„å‘½ä»¤ï¼Œé‚£ä¹ˆè¿™ä¸ªå‡½æ•°åº”è¯¥è¿”å›žé”™è¯¯ä»£ç æ•´
682 数。如果是一个判断,那么函数应该返回一个“æˆåŠŸâ€å¸ƒå°”值。
683
684比如,“add work†是一个命令,所以 add_work() 函数在æˆåŠŸæ—¶è¿”å›ž 0,在失败时返回 -EBUSY。
685类似的,因为 “PCI device present†是一个判断,所以 pci_dev_present() 函数在æˆåŠŸæ‰¾åˆ°
686一个匹é…的设备时应该返回 1,如果找ä¸åˆ°æ—¶åº”该返回 0。
687
688所有导出(译注:EXPORT)的函数都必须éµå®ˆè¿™ä¸ªæƒ¯ä¾‹ï¼Œæ‰€æœ‰çš„公共函数也都应该如此。ç§
689有(static)函数ä¸éœ€è¦å¦‚此,但是我们也推è这样åšã€‚
690
691è¿”å›žå€¼æ˜¯å®žé™…è®¡ç®—ç»“æžœè€Œä¸æ˜¯è®¡ç®—æ˜¯å¦æˆåŠŸçš„æ ‡å¿—çš„å‡½æ•°ä¸å—此惯例的é™åˆ¶ã€‚一般的,他们
692通过返回一些正常值范围之外的结果æ¥è¡¨ç¤ºå‡ºé”™ã€‚å…¸åž‹çš„ä¾‹å­æ˜¯è¿”回指针的函数,他们使用
693NULL 或者 ERR_PTR æœºåˆ¶æ¥æŠ¥å‘Šé”™è¯¯ã€‚
694
695
696 第å七章:ä¸è¦é‡æ–°å‘明内核å®
697
698头文件 include/linux/kernel.h 包å«äº†ä¸€äº›å®ï¼Œä½ åº”该使用它们,而ä¸è¦è‡ªå·±å†™ä¸€äº›å®ƒä»¬çš„
699å˜ç§ã€‚比如,如果你需è¦è®¡ç®—一个数组的长度,使用这个å®
700
701 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
702
703类似的,如果你è¦è®¡ç®—æŸç»“构体æˆå‘˜çš„大å°ï¼Œä½¿ç”¨
704
705 #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
706
707还有å¯ä»¥åšä¸¥æ ¼çš„类型检查的 min() å’Œ max() å®ï¼Œå¦‚果你需è¦å¯ä»¥ä½¿ç”¨å®ƒä»¬ã€‚ä½ å¯ä»¥è‡ªå·±çœ‹çœ‹
708那个头文件里还定义了什么你å¯ä»¥æ‹¿æ¥ç”¨çš„东西,如果有定义的è¯ï¼Œä½ å°±ä¸åº”在你的代ç é‡Œ
709è‡ªå·±é‡æ–°å®šä¹‰ã€‚
710
711
712 第å八章:编辑器模å¼è¡Œå’Œå…¶ä»–需è¦ç½—嗦的事情
713
714有一些编辑器å¯ä»¥è§£é‡ŠåµŒå…¥åœ¨æºæ–‡ä»¶é‡Œçš„由一些特殊标记标明的é…置信æ¯ã€‚比如,emacs
715能够解释被标记æˆè¿™æ ·çš„行:
716
717 -*- mode: c -*-
718
719或者这样的:
720
721 /*
722 Local Variables:
723 compile-command: "gcc -DMAGIC_DEBUG_FLAG foo.c"
724 End:
725 */
726
727Vim 能够解释这样的标记:
728
729 /* vim:set sw=8 noet */
730
731ä¸è¦åœ¨æºä»£ç ä¸­åŒ…å«ä»»ä½•这样的内容。æ¯ä¸ªäººéƒ½æœ‰ä»–自己的编辑器é…ç½®ï¼Œä½ çš„æºæ–‡ä»¶ä¸åº”
732该覆盖别人的é…置。这包括有关缩进和模å¼é…置的标记。人们å¯ä»¥ä½¿ç”¨ä»–们自己定制的模
733å¼ï¼Œæˆ–者使用其他å¯ä»¥äº§ç”Ÿæ­£ç¡®çš„缩进的巧妙方法。
734
735
736 第åä¹ç« ï¼šå†…è”æ±‡ç¼–
737
738在特定架构的代ç ä¸­ï¼Œä½ ä¹Ÿè®¸éœ€è¦å†…è”æ±‡ç¼–æ¥ä½¿ç”¨ CPU 接å£å’Œå¹³å°ç›¸å…³åŠŸèƒ½ã€‚åœ¨éœ€è¦
739è¿™ä¹ˆåšæ—¶ï¼Œä¸è¦çŠ¹è±«ã€‚ç„¶è€Œï¼Œå½“ C å¯ä»¥å®Œæˆå·¥ä½œæ—¶ï¼Œä¸è¦æ— ç«¯åœ°ä½¿ç”¨å†…è”æ±‡ç¼–。如果
740å¯èƒ½ï¼Œä½ å¯ä»¥å¹¶ä¸”应该用 C 和硬件交互。
741
742è€ƒè™‘åŽ»å†™é€šç”¨ä¸€ç‚¹çš„å†…è”æ±‡ç¼–ä½œä¸ºç®€æ˜Žçš„è¾…åŠ©å‡½æ•°ï¼Œè€Œä¸æ˜¯é‡å¤å†™ä¸‹å®ƒä»¬çš„细节。记ä½
743å†…è”æ±‡ç¼–å¯ä»¥ä½¿ç”¨ C 傿•°ã€‚
744
745大而特殊的汇编函数应该放在 .S 文件中,对应 C 的原型定义在 C 头文件中。汇编
746函数的 C 原型应该使用 “asmlinkageâ€ã€‚
747
748ä½ å¯èƒ½éœ€è¦å°†ä½ çš„æ±‡ç¼–è¯­å¥æ ‡è®°ä¸º volatile,æ¥é˜»æ­¢ GCC 在没å‘现任何副作用åŽå°±
749移除了它。你ä¸å¿…总是这样åšï¼Œè™½ç„¶ï¼Œè¿™æ ·å¯ä»¥é™åˆ¶ä¸å¿…è¦çš„优化。
750
751在写一个包å«å¤šæ¡æŒ‡ä»¤çš„å•ä¸ªå†…è”æ±‡ç¼–è¯­å¥æ—¶ï¼ŒæŠŠæ¯æ¡æŒ‡ä»¤ç”¨å¼•å·å­—符串分离,并写在
752å•独一行,在æ¯ä¸ªå­—符串结尾,除了 \n\t 结尾之外,在汇编输出中适当地缩进下
753ä¸€æ¡æŒ‡ä»¤ï¼š
754
755 asm ("magic %reg1, #42\n\t"
756 "more_magic %reg2, %reg3"
757 : /* outputs */ : /* inputs */ : /* clobbers */);
758
759
760 第二å章:æ¡ä»¶ç¼–译
761
762åªè¦å¯èƒ½ï¼Œå°±ä¸è¦åœ¨ .c 文件里é¢ä½¿ç”¨é¢„å¤„ç†æ¡ä»¶ï¼›è¿™æ ·åšè®©ä»£ç æ›´éš¾é˜…读并且逻辑难以
763跟踪。替代方案是,在头文件定义函数在这些 .c 文件中使用这类的æ¡ä»¶è¡¨è¾¾å¼ï¼Œæä¾›ç©º
764æ“作的桩版本(译注:桩程åºï¼Œæ˜¯æŒ‡ç”¨æ¥æ›¿æ¢ä¸€éƒ¨åˆ†åŠŸèƒ½çš„ç¨‹åºæ®µï¼‰åœ¨ #else 情况下,
765å†ä»Ž .c 文件中无æ¡ä»¶åœ°è°ƒç”¨è¿™äº›å‡½æ•°ã€‚编译器会é¿å…生æˆä»»ä½•桩调用的代ç ï¼Œäº§ç”Ÿä¸€è‡´
766的结果,但逻辑将更加清晰。
767
768å®å¯ç¼–è¯‘æ•´ä¸ªå‡½æ•°ï¼Œè€Œä¸æ˜¯éƒ¨åˆ†å‡½æ•°æˆ–部分表达å¼ã€‚è€Œä¸æ˜¯åœ¨ä¸€ä¸ªè¡¨è¾¾å¼æ·»åŠ  ifdef,
769è§£æžéƒ¨åˆ†æˆ–全部表达å¼åˆ°ä¸€ä¸ªå•独的辅助函数,并应用æ¡ä»¶åˆ°è¯¥å‡½æ•°å†…。
770
771如果你有一个在特定é…置中å¯èƒ½æ˜¯æœªä½¿ç”¨çš„函数或å˜é‡ï¼Œç¼–译器将警告它定义了但未使用,
772标记这个定义为 __maybe_unused è€Œä¸æ˜¯å°†å®ƒåŒ…å«åœ¨ä¸€ä¸ªé¢„å¤„ç†æ¡ä»¶ä¸­ã€‚(然而,如果
773一个函数或å˜é‡æ€»æ˜¯æœªä½¿ç”¨çš„,就直接删除它。)
774
775在代ç ä¸­ï¼Œå¯èƒ½çš„æƒ…况下,使用 IS_ENABLED 宿¥è½¬åŒ–æŸä¸ª Kconfig 标记为 C 的布尔
776表达å¼ï¼Œå¹¶åœ¨æ­£å¸¸çš„ C æ¡ä»¶ä¸­ä½¿ç”¨å®ƒï¼š
777
778 if (IS_ENABLED(CONFIG_SOMETHING)) {
779 ...
780 }
781
782编译器会无æ¡ä»¶åœ°åšå¸¸æ•°åˆå¹¶ï¼Œå°±åƒä½¿ç”¨ #ifdef é‚£æ ·ï¼ŒåŒ…å«æˆ–排除代ç å—,所以这ä¸ä¼š
783带æ¥ä»»ä½•è¿è¡Œæ—¶å¼€é”€ã€‚ç„¶è€Œï¼Œè¿™ç§æ–¹æ³•便—§å…许 C 编译器查看å—内的代ç ï¼Œå¹¶æ£€æŸ¥å®ƒçš„æ­£ç¡®
784性(语法,类型,符å·å¼•用,等等)。因此,如果æ¡ä»¶ä¸æ»¡è¶³ï¼Œä»£ç å—内的引用符å·å°†ä¸å­˜åœ¨ï¼Œ
785你必须继续使用 #ifdef。
786
787在任何有æ„义的 #if 或 #ifdef å—的末尾(超过几行),在 #endif åŒä¸€è¡Œçš„åŽé¢å†™ä¸‹
788注释,指出该æ¡ä»¶è¡¨è¾¾å¼è¢«ä½¿ç”¨ã€‚例如:
789
790 #ifdef CONFIG_SOMETHING
791 ...
792 #endif /* CONFIG_SOMETHING */
793
794
795 附录 I:å‚考
796
797The C Programming Language, 第二版
798作者:Brian W. Kernighan 和 Denni M. Ritchie.
799Prentice Hall, Inc., 1988.
800ISBN 0-13-110362-8 (软皮), 0-13-110370-9 (硬皮).
801
802The Practice of Programming
803作者:Brian W. Kernighan 和 Rob Pike.
804Addison-Wesley, Inc., 1999.
805ISBN 0-201-61586-X.
806
807GNU 手册 - éµå¾ª K&R 标准和此文本 - cpp, gcc, gcc internals and indent,
808都å¯ä»¥ä»Ž http://www.gnu.org/manual/ 找到
809
810WG14是C语言的国际标准化工作组,URL: http://www.open-std.org/JTC1/SC22/WG14/
811
812Kernel process/coding-style.rst,作者 greg@kroah.com å‘表于OLS 2002:
813http://www.kroah.com/linux/talks/ols_2002_kernel_codingstyle_talk/html/
diff --git a/Documentation/translations/zh_CN/coding-style.rst b/Documentation/translations/zh_CN/coding-style.rst
new file mode 100644
index 000000000000..1466aa64b8b4
--- /dev/null
+++ b/Documentation/translations/zh_CN/coding-style.rst
@@ -0,0 +1,950 @@
1Chinese translated version of Documentation/process/coding-style.rst
2
3If you have any comment or update to the content, please post to LKML directly.
4However, if you have problem communicating in English you can also ask the
5Chinese maintainer for help. Contact the Chinese maintainer, if this
6translation is outdated or there is problem with translation.
7
8Chinese maintainer: Zhang Le <r0bertz@gentoo.org>
9
10---------------------------------------------------------------------
11
12Documentation/process/coding-style.rst 的中文翻译
13
14如果想评论或更新本文的内容,请直接å‘信到LKMLã€‚å¦‚æžœä½ ä½¿ç”¨è‹±æ–‡äº¤æµæœ‰å›°éš¾çš„è¯ï¼Œ
15也å¯ä»¥å‘中文版维护者求助。如果本翻译更新ä¸åŠæ—¶æˆ–者翻译存在问题,请è”系中文版
16维护者::
17
18 中文版维护者: å¼ ä¹ Zhang Le <r0bertz@gentoo.org>
19 中文版翻译者: å¼ ä¹ Zhang Le <r0bertz@gentoo.org>
20 中文版校译者: çŽ‹èª Wang Cong <xiyou.wangcong@gmail.com>
21 wheelz <kernel.zeng@gmail.com>
22 管旭东 Xudong Guan <xudong.guan@gmail.com>
23 Li Zefan <lizf@cn.fujitsu.com>
24 Wang Chen <wangchen@cn.fujitsu.com>
25
26以下为正文
27
28---------------------------------------------------------------------
29
30Linux 内核代ç é£Žæ ¼
31=========================
32
33这是一个简短的文档,æè¿°äº† linux 内核的首选代ç é£Žæ ¼ã€‚代ç é£Žæ ¼æ˜¯å› äººè€Œå¼‚的,
34è€Œä¸”æˆ‘ä¸æ„¿æ„æŠŠè‡ªå·±çš„è§‚ç‚¹å¼ºåŠ ç»™ä»»ä½•äººï¼Œä½†è¿™å°±åƒæˆ‘去åšä»»ä½•事情都必须éµå¾ªçš„原则
35那样,我也希望在ç»å¤§å¤šæ•°äº‹ä¸Šä¿æŒè¿™ç§çš„æ€åº¦ã€‚è¯· (åœ¨å†™ä»£ç æ—¶) 至少考虑一下这里
36的代ç é£Žæ ¼ã€‚
37
38首先,我建议你打å°ä¸€ä»½ GNU 代ç è§„范,然åŽä¸è¦è¯»ã€‚烧了它,这是一个具有é‡å¤§è±¡å¾
39性æ„义的动作。
40
41ä¸ç®¡æ€Žæ ·ï¼ŒçŽ°åœ¨æˆ‘ä»¬å¼€å§‹ï¼š
42
43
441) 缩进
45--------------
46
47制表符是 8 个字符,所以缩进也是 8 个字符。有些异端è¿åŠ¨è¯•å›¾å°†ç¼©è¿›å˜ä¸º 4 (甚至
482ï¼) 字符深,这几乎相当于å°è¯•将圆周率的值定义为 3。
49
50ç†ç”±ï¼šç¼©è¿›çš„全部æ„义就在于清楚的定义一个控制å—起止于何处。尤其是当你盯ç€ä½ çš„
51å±å¹•连续看了 20 å°æ—¶ä¹‹åŽï¼Œä½ å°†ä¼šå‘现大一点的缩进会使你更容易分辨缩进。
52
53现在,有些人会抱怨 8 个字符的缩进会使代ç å‘å³è¾¹ç§»åŠ¨çš„å¤ªè¿œï¼Œåœ¨ 80 个字符的终端
54å±å¹•上就很难读这样的代ç ã€‚è¿™ä¸ªé—®é¢˜çš„ç­”æ¡ˆæ˜¯ï¼Œå¦‚æžœä½ éœ€è¦ 3 级以上的缩进,ä¸ç®¡ç”¨
55ä½•ç§æ–¹å¼ä½ çš„代ç å·²ç»æœ‰é—®é¢˜äº†ï¼Œåº”该修正你的程åºã€‚
56
57简而言之,8 个字符的缩进å¯ä»¥è®©ä»£ç æ›´å®¹æ˜“阅读,还有一个好处是当你的函数嵌套太
58深的时候å¯ä»¥ç»™ä½ è­¦å‘Šã€‚留心这个警告。
59
60在 switch 语å¥ä¸­æ¶ˆé™¤å¤šçº§ç¼©è¿›çš„é¦–é€‰çš„æ–¹å¼æ˜¯è®© ``switch`` 和从属于它的 ``case``
61标签对é½äºŽåŒä¸€åˆ—,而ä¸è¦ ``两次缩进`` ``case`` 标签。比如:
62
63.. code-block:: c
64
65 switch (suffix) {
66 case 'G':
67 case 'g':
68 mem <<= 30;
69 break;
70 case 'M':
71 case 'm':
72 mem <<= 20;
73 break;
74 case 'K':
75 case 'k':
76 mem <<= 10;
77 /* fall through */
78 default:
79 break;
80 }
81
82ä¸è¦æŠŠå¤šä¸ªè¯­å¥æ”¾åœ¨ä¸€è¡Œé‡Œï¼Œé™¤éžä½ æœ‰ä»€ä¹ˆä¸œè¥¿è¦éšè—:
83
84.. code-block:: c
85
86 if (condition) do_this;
87 do_something_everytime;
88
89也ä¸è¦åœ¨ä¸€è¡Œé‡Œæ”¾å¤šä¸ªèµ‹å€¼è¯­å¥ã€‚内核代ç é£Žæ ¼è¶…级简å•。就是é¿å…å¯èƒ½å¯¼è‡´åˆ«äººè¯¯è¯»
90的表达å¼ã€‚
91
92é™¤äº†æ³¨é‡Šã€æ–‡æ¡£å’Œ Kconfig 之外,ä¸è¦ä½¿ç”¨ç©ºæ ¼æ¥ç¼©è¿›ï¼Œå‰é¢çš„例孿˜¯ä¾‹å¤–,是有æ„为
93之。
94
95选用一个好的编辑器,ä¸è¦åœ¨è¡Œå°¾ç•™ç©ºæ ¼ã€‚
96
97
982) 把长的行和字符串打散
99------------------------------
100
101代ç é£Žæ ¼çš„æ„ä¹‰å°±åœ¨äºŽä½¿ç”¨å¹³å¸¸ä½¿ç”¨çš„å·¥å…·æ¥ç»´æŒä»£ç çš„å¯è¯»æ€§å’Œå¯ç»´æŠ¤æ€§ã€‚
102
103æ¯ä¸€è¡Œçš„长度的é™åˆ¶æ˜¯ 80 列,我们强烈建议您éµå®ˆè¿™ä¸ªæƒ¯ä¾‹ã€‚
104
105长于 80 列的语å¥è¦æ‰“æ•£æˆæœ‰æ„义的片段。除éžè¶…过 80 列能显著增加å¯è¯»æ€§ï¼Œå¹¶ä¸”ä¸
106会éšè—ä¿¡æ¯ã€‚å­ç‰‡æ®µè¦æ˜Žæ˜¾çŸ­äºŽæ¯ç‰‡æ®µï¼Œå¹¶æ˜Žæ˜¾é å³ã€‚è¿™åŒæ ·é€‚用于有ç€å¾ˆé•¿å‚数列表
107的函数头。然而,ç»å¯¹ä¸è¦æ‰“散对用户å¯è§çš„字符串,例如 printk ä¿¡æ¯ï¼Œå› ä¸ºè¿™æ ·å°±
108很难对它们 grep。
109
110
1113) 大括å·å’Œç©ºæ ¼çš„æ”¾ç½®
112------------------------------
113
114C 语言风格中å¦å¤–一个常è§é—®é¢˜æ˜¯å¤§æ‹¬å·çš„æ”¾ç½®ã€‚和缩进大å°ä¸åŒï¼Œé€‰æ‹©æˆ–弃用æŸç§æ”¾
115置策略并没有多少技术上的原因,ä¸è¿‡é¦–选的方å¼ï¼Œå°±åƒ Kernighan å’Œ Ritchie 展示
116ç»™æˆ‘ä»¬çš„ï¼Œæ˜¯æŠŠèµ·å§‹å¤§æ‹¬å·æ”¾åœ¨è¡Œå°¾ï¼Œè€ŒæŠŠç»“æŸå¤§æ‹¬å·æ”¾åœ¨è¡Œé¦–,所以:
117
118.. code-block:: c
119
120 if (x is true) {
121 we do y
122 }
123
124这适用于所有的éžå‡½æ•°è¯­å¥å— (if, switch, for, while, do)。比如:
125
126.. code-block:: c
127
128 switch (action) {
129 case KOBJ_ADD:
130 return "add";
131 case KOBJ_REMOVE:
132 return "remove";
133 case KOBJ_CHANGE:
134 return "change";
135 default:
136 return NULL;
137 }
138
139ä¸è¿‡ï¼Œæœ‰ä¸€ä¸ªä¾‹å¤–ï¼Œé‚£å°±æ˜¯å‡½æ•°ï¼šå‡½æ•°çš„èµ·å§‹å¤§æ‹¬å·æ”¾ç½®äºŽä¸‹ä¸€è¡Œçš„开头,所以:
140
141.. code-block:: c
142
143 int function(int x)
144 {
145 body of function
146 }
147
148全世界的异端å¯èƒ½ä¼šæŠ±æ€¨è¿™ä¸ªä¸ä¸€è‡´æ€§æ˜¯... 呃... ä¸ä¸€è‡´çš„,ä¸è¿‡æ‰€æœ‰æ€ç»´å¥å…¨çš„人
149éƒ½çŸ¥é“ (a) K&R 是 **正确的** 并且 (b) K&R 是正确的。此外,ä¸ç®¡æ€Žæ ·å‡½æ•°éƒ½æ˜¯ç‰¹
150殊的 (C 函数是ä¸èƒ½åµŒå¥—çš„)。
151
152注æ„结æŸå¤§æ‹¬å·ç‹¬è‡ªå æ®ä¸€è¡Œï¼Œé™¤éžå®ƒåŽé¢è·Ÿç€åŒä¸€ä¸ªè¯­å¥çš„剩余部分,也就是 do 语
153å¥ä¸­çš„ "while" 或者 if 语å¥ä¸­çš„ "else",åƒè¿™æ ·ï¼š
154
155.. code-block:: c
156
157 do {
158 body of do-loop
159 } while (condition);
160
161和
162
163.. code-block:: c
164
165 if (x == y) {
166 ..
167 } else if (x > y) {
168 ...
169 } else {
170 ....
171 }
172
173ç†ç”±ï¼šK&R。
174
175也请注æ„è¿™ç§å¤§æ‹¬å·çš„æ”¾ç½®æ–¹å¼ä¹Ÿèƒ½ä½¿ç©º (或者差ä¸å¤šç©ºçš„) è¡Œçš„æ•°é‡æœ€å°åŒ–ï¼ŒåŒæ—¶ä¸
176失å¯è¯»æ€§ã€‚因此,由于你的å±å¹•上的新行是ä¸å¯å†ç”Ÿèµ„æº (想想 25 行的终端å±å¹•),你
177å°†ä¼šæœ‰æ›´å¤šçš„ç©ºè¡Œæ¥æ”¾ç½®æ³¨é‡Šã€‚
178
179å½“åªæœ‰ä¸€ä¸ªå•独的语å¥çš„æ—¶å€™ï¼Œä¸ç”¨åŠ ä¸å¿…è¦çš„大括å·ã€‚
180
181.. code-block:: c
182
183 if (condition)
184 action();
185
186和
187
188.. code-block:: c
189
190 if (condition)
191 do_this();
192 else
193 do_that();
194
195这并ä¸é€‚ç”¨äºŽåªæœ‰ä¸€ä¸ªæ¡ä»¶åˆ†æ”¯æ˜¯å•语å¥çš„æƒ…况;这时所有分支都è¦ä½¿ç”¨å¤§æ‹¬å·ï¼š
196
197.. code-block:: c
198
199 if (condition) {
200 do_this();
201 do_that();
202 } else {
203 otherwise();
204 }
205
2063.1) 空格
207********************
208
209Linux å†…æ ¸çš„ç©ºæ ¼ä½¿ç”¨æ–¹å¼ (主è¦) å–决于它是用于函数还是关键字。(大多数) 关键字
210åŽè¦åŠ ä¸€ä¸ªç©ºæ ¼ã€‚å€¼å¾—æ³¨æ„的例外是 sizeof, typeof, alignof å’Œ __attribute__,这
211些关键字æŸäº›ç¨‹åº¦ä¸Šçœ‹èµ·æ¥æ›´åƒå‡½æ•° (它们在 Linux 里也常常伴éšå°æ‹¬å·è€Œä½¿ç”¨ï¼Œå°½ç®¡
212在 C é‡Œè¿™æ ·çš„å°æ‹¬å·ä¸æ˜¯å¿…éœ€çš„ï¼Œå°±åƒ ``struct fileinfo info;`` 声明过åŽçš„
213``sizeof info``)。
214
215æ‰€ä»¥åœ¨è¿™äº›å…³é”®å­—ä¹‹åŽæ”¾ä¸€ä¸ªç©ºæ ¼::
216
217 if, switch, case, for, do, while
218
219但是ä¸è¦åœ¨ sizeof, typeof, alignof 或者 __attribute__ è¿™äº›å…³é”®å­—ä¹‹åŽæ”¾ç©ºæ ¼ã€‚
220例如,
221
222.. code-block:: c
223
224 s = sizeof(struct file);
225
226ä¸è¦åœ¨å°æ‹¬å·é‡Œçš„表达å¼ä¸¤ä¾§åŠ ç©ºæ ¼ã€‚è¿™æ˜¯ä¸€ä¸ª **å例** :
227
228.. code-block:: c
229
230 s = sizeof( struct file );
231
232当声明指针类型或者返回指针类型的函数时, ``*`` çš„é¦–é€‰ä½¿ç”¨æ–¹å¼æ˜¯ä½¿ä¹‹é è¿‘å˜é‡å
233或者函数åï¼Œè€Œä¸æ˜¯é è¿‘类型å。例å­ï¼š
234
235.. code-block:: c
236
237 char *linux_banner;
238 unsigned long long memparse(char *ptr, char **retptr);
239 char *match_strdup(substring_t *s);
240
241在大多数二元和三元æ“ä½œç¬¦ä¸¤ä¾§ä½¿ç”¨ä¸€ä¸ªç©ºæ ¼ï¼Œä¾‹å¦‚ä¸‹é¢æ‰€æœ‰è¿™äº›æ“作符::
242
243 = + - < > * / % | & ^ <= >= == != ? :
244
245但是一元æ“作符åŽä¸è¦åŠ ç©ºæ ¼::
246
247 & * + - ~ ! sizeof typeof alignof __attribute__ defined
248
249åŽç¼€è‡ªåŠ å’Œè‡ªå‡ä¸€å…ƒæ“作符å‰ä¸åŠ ç©ºæ ¼::
250
251 ++ --
252
253å‰ç¼€è‡ªåŠ å’Œè‡ªå‡ä¸€å…ƒæ“作符åŽä¸åŠ ç©ºæ ¼::
254
255 ++ --
256
257``.`` å’Œ ``->`` 结构体æˆå‘˜æ“作符å‰åŽä¸åŠ ç©ºæ ¼ã€‚
258
259ä¸è¦åœ¨è¡Œå°¾ç•™ç©ºç™½ã€‚有些å¯ä»¥è‡ªåŠ¨ç¼©è¿›çš„ç¼–è¾‘å™¨ä¼šåœ¨æ–°è¡Œçš„è¡Œé¦–åŠ å…¥é€‚é‡çš„空白,然åŽ
260ä½ å°±å¯ä»¥ç›´æŽ¥åœ¨é‚£ä¸€è¡Œè¾“入代ç ã€‚ä¸è¿‡å‡å¦‚ä½ æœ€åŽæ²¡æœ‰åœ¨é‚£ä¸€è¡Œè¾“入代ç ï¼Œæœ‰äº›ç¼–辑器
261å°±ä¸ä¼šç§»é™¤å·²ç»åŠ å…¥çš„ç©ºç™½ï¼Œå°±åƒä½ æ•…æ„ç•™ä¸‹ä¸€ä¸ªåªæœ‰ç©ºç™½çš„行。包å«è¡Œå°¾ç©ºç™½çš„行就
262这样产生了。
263
264当 git å‘现补ä¸åŒ…å«äº†è¡Œå°¾ç©ºç™½çš„æ—¶å€™ä¼šè­¦å‘Šä½ ï¼Œå¹¶ä¸”å¯ä»¥åº”ä½ çš„è¦æ±‚去掉行尾空白;
265ä¸è¿‡å¦‚果你是正在打一系列补ä¸ï¼Œè¿™æ ·åšä¼šå¯¼è‡´åŽé¢çš„è¡¥ä¸å¤±è´¥ï¼Œå› ä¸ºä½ æ”¹å˜äº†è¡¥ä¸çš„
266上下文。
267
268
2694) 命å
270------------------------------
271
272C 是一个简朴的语言,你的命å也应该这样。和 Modula-2 å’Œ Pascal 程åºå‘˜ä¸åŒï¼Œ
273C 程åºå‘˜ä¸ä½¿ç”¨ç±»ä¼¼ ThisVariableIsATemporaryCounter 这样åŽä¸½çš„å字。C 程åºå‘˜ä¼š
274称那个å˜é‡ä¸º ``tmp`` ,这样写起æ¥ä¼šæ›´å®¹æ˜“,而且至少ä¸ä¼šä»¤å…¶éš¾äºŽç†è§£ã€‚
275
276ä¸è¿‡ï¼Œè™½ç„¶æ··ç”¨å¤§å°å†™çš„åå­—æ˜¯ä¸æå€¡ä½¿ç”¨çš„ï¼Œä½†æ˜¯å…¨å±€å˜é‡è¿˜æ˜¯éœ€è¦ä¸€ä¸ªå…·æè¿°æ€§çš„
277å字。称一个全局函数为 ``foo`` 是一个难以饶æ•的错误。
278
279全局å˜é‡ (åªæœ‰å½“ä½  **真正** 需è¦å®ƒä»¬çš„æ—¶å€™å†ç”¨å®ƒ) éœ€è¦æœ‰ä¸€ä¸ªå…·æè¿°æ€§çš„å字,就
280åƒå…¨å±€å‡½æ•°ã€‚如果你有一个å¯ä»¥è®¡ç®—活动用户数é‡çš„函数,你应该å«å®ƒ
281``count_active_users()`` 或者类似的å字,你ä¸åº”该å«å®ƒ ``cntuser()`` 。
282
283在函数å中包å«å‡½æ•°ç±»åž‹ (æ‰€è°“çš„åŒˆç‰™åˆ©å‘½åæ³•) 是脑å­å‡ºäº†é—®é¢˜â€”—编译器知é“那些类
284型而且能够检查那些类型,这样åšåªèƒ½æŠŠç¨‹åºå‘˜å¼„糊涂了。难怪微软总是制造出有问题
285的程åºã€‚
286
287本地å˜é‡å应该简短,而且能够表达相关的å«ä¹‰ã€‚å¦‚æžœä½ æœ‰ä¸€äº›éšæœºçš„æ•´æ•°åž‹çš„循环计
288数器,它应该被称为 ``i`` 。å«å®ƒ ``loop_counter`` 并无益处,如果它没有被误解的
289å¯èƒ½çš„è¯ã€‚类似的, ``tmp`` å¯ä»¥ç”¨æ¥ç§°å‘¼ä»»æ„类型的临时å˜é‡ã€‚
290
291如果你怕混淆了你的本地å˜é‡å,你就é‡åˆ°å¦ä¸€ä¸ªé—®é¢˜äº†ï¼Œå«åšå‡½æ•°å¢žé•¿è·å°”蒙失衡综
292åˆç—‡ã€‚请看第六章 (函数)。
293
294
2955) Typedef
296-----------
297
298ä¸è¦ä½¿ç”¨ç±»ä¼¼ ``vps_t`` 之类的东西。
299
300对结构体和指针使用 typedef 是一个 **错误** 。当你在代ç é‡Œçœ‹åˆ°ï¼š
301
302.. code-block:: c
303
304 vps_t a;
305
306è¿™ä»£è¡¨ä»€ä¹ˆæ„æ€å‘¢ï¼Ÿ
307
308相å,如果是这样
309
310.. code-block:: c
311
312 struct virtual_container *a;
313
314ä½ å°±çŸ¥é“ ``a`` 是什么了。
315
316很多人认为 typedef ``能æé«˜å¯è¯»æ€§`` ã€‚å®žé™…ä¸æ˜¯è¿™æ ·çš„。它们åªåœ¨ä¸‹åˆ—情况下有用:
317
318 (a) 完全ä¸é€æ˜Žçš„对象 (è¿™ç§æƒ…况下è¦ä¸»åŠ¨ä½¿ç”¨ typedef æ¥ **éšè—** 这个对象实际上
319 是什么)。
320
321 例如: ``pte_t`` ç­‰ä¸é€æ˜Žå¯¹è±¡ï¼Œä½ åªèƒ½ç”¨åˆé€‚的访问函数æ¥è®¿é—®å®ƒä»¬ã€‚
322
323 .. note::
324
325 ä¸é€æ˜Žæ€§å’Œ "访问函数" 本身是ä¸å¥½çš„。我们使用 pte_t 等类型的原因在于真
326 的是完全没有任何共用的å¯è®¿é—®ä¿¡æ¯ã€‚
327
328 (b) 清楚的整数类型,如此,这层抽象就å¯ä»¥ **帮助** 消除到底是 ``int`` 还是
329 ``long`` 的混淆。
330
331 u8/u16/u32 是完全没有问题的 typedef,ä¸è¿‡å®ƒä»¬æ›´ç¬¦åˆç±»åˆ« (d) è€Œä¸æ˜¯è¿™é‡Œã€‚
332
333 .. note::
334
335 è¦è¿™æ ·åšï¼Œå¿…须事出有因。如果æŸä¸ªå˜é‡æ˜¯ ``unsigned long`` ,那么没有必è¦
336
337 typedef unsigned long myflags_t;
338
339 ä¸è¿‡å¦‚果有一个明确的原因,比如它在æŸç§æƒ…况下å¯èƒ½ä¼šæ˜¯ä¸€ä¸ª ``unsigned int``
340 而在其他情况下å¯èƒ½ä¸º ``unsigned long`` ,那么就ä¸è¦çŠ¹è±«ï¼Œè¯·åŠ¡å¿…ä½¿ç”¨
341 typedef。
342
343 (c) 当你使用 sparse 按字é¢çš„创建一个 **æ–°** 类型æ¥åšç±»åž‹æ£€æŸ¥çš„æ—¶å€™ã€‚
344
345 (d) 和标准 C99 类型相åŒçš„类型,在æŸäº›ä¾‹å¤–的情况下。
346
347 虽然让眼ç›å’Œè„‘ç­‹æ¥é€‚应新的标准类型比如 ``uint32_t`` ä¸éœ€è¦èŠ±å¾ˆå¤šæ—¶é—´ï¼Œå¯
348 是有些人ä»ç„¶æ‹’ç»ä½¿ç”¨å®ƒä»¬ã€‚
349
350 因此,Linux 特有的等åŒäºŽæ ‡å‡†ç±»åž‹çš„ ``u8/u16/u32/u64`` 类型和它们的有符å·
351 类型是被å…许的——尽管在你自己的新代ç ä¸­ï¼Œå®ƒä»¬ä¸æ˜¯å¼ºåˆ¶è¦æ±‚è¦ä½¿ç”¨çš„。
352
353 当编辑已ç»ä½¿ç”¨äº†æŸä¸ªç±»åž‹é›†çš„å·²æœ‰ä»£ç æ—¶ï¼Œä½ åº”该éµå¾ªé‚£äº›ä»£ç ä¸­å·²ç»åšå‡ºçš„选
354 择。
355
356 (e) å¯ä»¥åœ¨ç”¨æˆ·ç©ºé—´å®‰å…¨ä½¿ç”¨çš„类型。
357
358 在æŸäº›ç”¨æˆ·ç©ºé—´å¯è§çš„结构体里,我们ä¸èƒ½è¦æ±‚ C99 类型而且ä¸èƒ½ç”¨ä¸Šé¢æåˆ°çš„
359 ``u32`` 类型。因此,我们在与用户空间共享的所有结构体中使用 __u32 和类似
360 的类型。
361
362å¯èƒ½è¿˜æœ‰å…¶ä»–的情况,ä¸è¿‡åŸºæœ¬çš„规则是 **永远ä¸è¦** 使用 typedef,除éžä½ å¯ä»¥æ˜Ž
363确的应用上述æŸä¸ªè§„则中的一个。
364
365总的æ¥è¯´ï¼Œå¦‚果一个指针或者一个结构体里的元素å¯ä»¥åˆç†çš„被直接访问到,那么它们
366å°±ä¸åº”该是一个 typedef。
367
368
3696) 函数
370------------------------------
371
372函数应该简短而漂亮,并且åªå®Œæˆä¸€ä»¶äº‹æƒ…。函数应该å¯ä»¥ä¸€å±æˆ–è€…ä¸¤å±æ˜¾ç¤ºå®Œ (我们
373éƒ½çŸ¥é“ ISO/ANSI å±å¹•大尿˜¯ 80x24),åªåšä¸€ä»¶äº‹æƒ…,而且把它åšå¥½ã€‚
374
375ä¸€ä¸ªå‡½æ•°çš„æœ€å¤§é•¿åº¦æ˜¯å’Œè¯¥å‡½æ•°çš„å¤æ‚度和缩进级数æˆå比的。所以,如果你有一个ç†
376论上很简å•çš„åªæœ‰ä¸€ä¸ªå¾ˆé•¿ (但是简å•) çš„ case 语å¥çš„函数,而且你需è¦åœ¨æ¯ä¸ª case
377里åšå¾ˆå¤šå¾ˆå°çš„事情,这样的函数尽管很长,但也是å¯ä»¥çš„。
378
379ä¸è¿‡ï¼Œå¦‚æžœä½ æœ‰ä¸€ä¸ªå¤æ‚çš„å‡½æ•°ï¼Œè€Œä¸”ä½ æ€€ç–‘ä¸€ä¸ªå¤©åˆ†ä¸æ˜¯å¾ˆé«˜çš„高中一年级学生å¯èƒ½
380甚至æžä¸æ¸…楚这个函数的目的,你应该严格éµå®ˆå‰é¢æåˆ°çš„长度é™åˆ¶ã€‚使用辅助函数,
381并为之å–个具æè¿°æ€§çš„åå­— (如果你觉得它们的性能很é‡è¦çš„è¯ï¼Œå¯ä»¥è®©ç¼–译器内è”它
382ä»¬ï¼Œè¿™æ ·çš„æ•ˆæžœå¾€å¾€ä¼šæ¯”ä½ å†™ä¸€ä¸ªå¤æ‚函数的效果è¦å¥½ã€‚)
383
384函数的å¦å¤–ä¸€ä¸ªè¡¡é‡æ ‡å‡†æ˜¯æœ¬åœ°å˜é‡çš„æ•°é‡ã€‚此数é‡ä¸åº”超过 5ï¼10 个,å¦åˆ™ä½ çš„函数
385å°±æœ‰é—®é¢˜äº†ã€‚é‡æ–°è€ƒè™‘ä¸€ä¸‹ä½ çš„å‡½æ•°ï¼ŒæŠŠå®ƒåˆ†æ‹†æˆæ›´å°çš„函数。人的大脑一般å¯ä»¥è½»æ¾
386çš„åŒæ—¶è·Ÿè¸ª 7 个ä¸åŒçš„事物,如果å†å¢žå¤šçš„è¯ï¼Œå°±ä¼šç³Šæ¶‚了。å³ä¾¿ä½ èªé¢–过人,你也å¯
387èƒ½ä¼šè®°ä¸æ¸…ä½  2 个星期å‰åšè¿‡çš„事情。
388
389åœ¨æºæ–‡ä»¶é‡Œï¼Œä½¿ç”¨ç©ºè¡Œéš”å¼€ä¸åŒçš„函数。如果该函数需è¦è¢«å¯¼å‡ºï¼Œå®ƒçš„ **EXPORT** å®
390应该紧贴在它的结æŸå¤§æ‹¬å·ä¹‹ä¸‹ã€‚比如:
391
392.. code-block:: c
393
394 int system_is_up(void)
395 {
396 return system_state == SYSTEM_RUNNING;
397 }
398 EXPORT_SYMBOL(system_is_up);
399
400在函数原型中,包å«å‡½æ•°å和它们的数æ®ç±»åž‹ã€‚虽然 C è¯­è¨€é‡Œæ²¡æœ‰è¿™æ ·çš„è¦æ±‚,在
401Linux 里这是æå€¡çš„åšæ³•,因为这样å¯ä»¥å¾ˆç®€å•的给读者æä¾›æ›´å¤šçš„æœ‰ä»·å€¼çš„ä¿¡æ¯ã€‚
402
403
4047) 集中的函数退出途径
405------------------------------
406
407虽然被æŸäº›äººå£°ç§°å·²ç»è¿‡æ—¶ï¼Œä½†æ˜¯ goto 语å¥çš„等价物还是ç»å¸¸è¢«ç¼–译器所使用,具体
408形弿˜¯æ— æ¡ä»¶è·³è½¬æŒ‡ä»¤ã€‚
409
410当一个函数从多个ä½ç½®é€€å‡ºï¼Œå¹¶ä¸”需è¦åšä¸€äº›ç±»ä¼¼æ¸…ç†çš„å¸¸è§æ“作时,goto 语å¥å°±å¾ˆæ–¹
411便了。如果并ä¸éœ€è¦æ¸…ç†æ“作,那么直接 return å³å¯ã€‚
412
413选择一个能够说明 goto 行为或它为何存在的标签å。如果 goto è¦é‡Šæ”¾ ``buffer``,
414一个ä¸é”™çš„åå­—å¯ä»¥æ˜¯ ``out_free_buffer:`` ã€‚åˆ«åŽ»ä½¿ç”¨åƒ ``err1:`` å’Œ ``err2:``
415这样的GW_BASIC å称,因为一旦你添加或删除了 (函数的) 退出路径,你就必须对它们
416釿–°ç¼–å·ï¼Œè¿™æ ·ä¼šéš¾ä»¥åŽ»æ£€éªŒæ­£ç¡®æ€§ã€‚
417
418使用 goto çš„ç†ç”±æ˜¯ï¼š
419
420- æ— æ¡ä»¶è¯­å¥å®¹æ˜“ç†è§£å’Œè·Ÿè¸ª
421- 嵌套程度å‡å°
422- å¯ä»¥é¿å…由于修改时忘记更新个别的退出点而导致错误
423- 让编译器çœåŽ»åˆ é™¤å†—ä½™ä»£ç çš„工作 ;)
424
425.. code-block:: c
426
427 int fun(int a)
428 {
429 int result = 0;
430 char *buffer;
431
432 buffer = kmalloc(SIZE, GFP_KERNEL);
433 if (!buffer)
434 return -ENOMEM;
435
436 if (condition1) {
437 while (loop1) {
438 ...
439 }
440 result = 1;
441 goto out_free_buffer;
442 }
443 ...
444 out_free_buffer:
445 kfree(buffer);
446 return result;
447 }
448
449ä¸€ä¸ªéœ€è¦æ³¨æ„的常è§é”™è¯¯æ˜¯ ``一个 err 错误`` ,就åƒè¿™æ ·ï¼š
450
451.. code-block:: c
452
453 err:
454 kfree(foo->bar);
455 kfree(foo);
456 return ret;
457
458这段代ç çš„错误是,在æŸäº›é€€å‡ºè·¯å¾„上 ``foo`` 是 NULL。通常情况下,通过把它分离
459æˆä¸¤ä¸ªé”™è¯¯æ ‡ç­¾ ``err_free_bar:`` å’Œ ``err_free_foo:`` æ¥ä¿®å¤è¿™ä¸ªé”™è¯¯ï¼š
460
461.. code-block:: c
462
463 err_free_bar:
464 kfree(foo->bar);
465 err_free_foo:
466 kfree(foo);
467 return ret;
468
469ç†æƒ³æƒ…å†µä¸‹ï¼Œä½ åº”è¯¥æ¨¡æ‹Ÿé”™è¯¯æ¥æµ‹è¯•所有退出路径。
470
471
4728) 注释
473------------------------------
474
475注释是好的,ä¸è¿‡æœ‰è¿‡åº¦æ³¨é‡Šçš„å±é™©ã€‚永远ä¸è¦åœ¨æ³¨é‡Šé‡Œè§£é‡Šä½ çš„ä»£ç æ˜¯å¦‚何è¿ä½œçš„:
476æ›´å¥½çš„åšæ³•是让别人一看你的代ç å°±å¯ä»¥æ˜Žç™½ï¼Œè§£é‡Šå†™çš„å¾ˆå·®çš„ä»£ç æ˜¯æµªè´¹æ—¶é—´ã€‚
477
478一般的,你想è¦ä½ çš„æ³¨é‡Šå‘Šè¯‰åˆ«äººä½ çš„代ç åšäº†ä»€ä¹ˆï¼Œè€Œä¸æ˜¯æ€Žä¹ˆåšçš„。也请你ä¸è¦æŠŠ
479æ³¨é‡Šæ”¾åœ¨ä¸€ä¸ªå‡½æ•°ä½“å†…éƒ¨ï¼šå¦‚æžœå‡½æ•°å¤æ‚到你需è¦ç‹¬ç«‹çš„æ³¨é‡Šå…¶ä¸­çš„一部分,你很å¯èƒ½
480需è¦å›žåˆ°ç¬¬å…­ç« çœ‹ä¸€çœ‹ã€‚ä½ å¯ä»¥åšä¸€äº›å°æ³¨é‡Šæ¥æ³¨æ˜Žæˆ–警告æŸäº›å¾ˆèªæ˜Ž (或者槽糕) çš„
481åšæ³•,但ä¸è¦åŠ å¤ªå¤šã€‚ä½ åº”è¯¥åšçš„,是把注释放在函数的头部,告诉人们它åšäº†ä»€ä¹ˆï¼Œ
482也å¯ä»¥åŠ ä¸Šå®ƒåšè¿™äº›äº‹æƒ…的原因。
483
484当注释内核 API 函数时,请使用 kernel-doc æ ¼å¼ã€‚请看
485Documentation/doc-guide/ å’Œ scripts/kernel-doc 以获得详细信æ¯ã€‚
486
487长 (多行) 注释的首选风格是:
488
489.. code-block:: c
490
491 /*
492 * This is the preferred style for multi-line
493 * comments in the Linux kernel source code.
494 * Please use it consistently.
495 *
496 * Description: A column of asterisks on the left side,
497 * with beginning and ending almost-blank lines.
498 */
499
500对于在 net/ å’Œ drivers/net/ 的文件,首选的长 (多行) 注释风格有些ä¸åŒã€‚
501
502.. code-block:: c
503
504 /* The preferred comment style for files in net/ and drivers/net
505 * looks like this.
506 *
507 * It is nearly the same as the generally preferred comment style,
508 * but there is no initial almost-blank line.
509 */
510
511注释数æ®ä¹Ÿæ˜¯å¾ˆé‡è¦çš„,ä¸ç®¡æ˜¯åŸºæœ¬ç±»åž‹è¿˜æ˜¯è¡ç”Ÿç±»åž‹ã€‚为了方便实现这一点,æ¯ä¸€è¡Œ
512应åªå£°æ˜Žä¸€ä¸ªæ•°æ® (ä¸è¦ä½¿ç”¨é€—å·æ¥ä¸€æ¬¡å£°æ˜Žå¤šä¸ªæ•°æ®)。这样你就有空间æ¥ä¸ºæ¯ä¸ªæ•°æ®
513å†™ä¸€æ®µå°æ³¨é‡Šæ¥è§£é‡Šå®ƒä»¬çš„用途了。
514
515
5169) ä½ å·²ç»æŠŠäº‹æƒ…å¼„ç³Ÿäº†
517------------------------------
518
519这没什么,我们都是这样。å¯èƒ½ä½ çš„使用了很长时间 Unix 的朋å‹å·²ç»å‘Šè¯‰ä½ 
520``GNU emacs`` 能自动帮你格å¼åŒ– C æºä»£ç ï¼Œè€Œä¸”你也注æ„到了,确实是这样,ä¸è¿‡å®ƒ
521所使用的默认值和我们想è¦çš„相去甚远 (å®žé™…ä¸Šï¼Œç”šè‡³æ¯”éšæœºæ‰“的还è¦å·®â€”—无数个猴å­
522在 GNU emacs 里打字永远ä¸ä¼šåˆ›é€ å‡ºä¸€ä¸ªå¥½ç¨‹åº) (译注:Infinite Monkey Theorem)
523
524所以你è¦ä¹ˆæ”¾å¼ƒ GNU emacs,è¦ä¹ˆæ”¹å˜å®ƒè®©å®ƒä½¿ç”¨æ›´åˆç†çš„设定。è¦é‡‡ç”¨åŽä¸€ä¸ªæ–¹æ¡ˆï¼Œ
525ä½ å¯ä»¥æŠŠä¸‹é¢è¿™æ®µç²˜è´´åˆ°ä½ çš„ .emacs 文件里。
526
527.. code-block:: none
528
529 (defun c-lineup-arglist-tabs-only (ignored)
530 "Line up argument lists by tabs, not spaces"
531 (let* ((anchor (c-langelem-pos c-syntactic-element))
532 (column (c-langelem-2nd-pos c-syntactic-element))
533 (offset (- (1+ column) anchor))
534 (steps (floor offset c-basic-offset)))
535 (* (max steps 1)
536 c-basic-offset)))
537
538 (add-hook 'c-mode-common-hook
539 (lambda ()
540 ;; Add kernel style
541 (c-add-style
542 "linux-tabs-only"
543 '("linux" (c-offsets-alist
544 (arglist-cont-nonempty
545 c-lineup-gcc-asm-reg
546 c-lineup-arglist-tabs-only))))))
547
548 (add-hook 'c-mode-hook
549 (lambda ()
550 (let ((filename (buffer-file-name)))
551 ;; Enable kernel mode for the appropriate files
552 (when (and filename
553 (string-match (expand-file-name "~/src/linux-trees")
554 filename))
555 (setq indent-tabs-mode t)
556 (setq show-trailing-whitespace t)
557 (c-set-style "linux-tabs-only")))))
558
559这会让 emacs 在 ``~/src/linux-trees`` 下的 C æºæ–‡ä»¶èŽ·å¾—æ›´å¥½çš„å†…æ ¸ä»£ç é£Žæ ¼ã€‚
560
561ä¸è¿‡å°±ç®—ä½ å°è¯•让 emacs 正确的格å¼åŒ–代ç å¤±è´¥äº†ï¼Œä¹Ÿå¹¶ä¸æ„味ç€ä½ å¤±åŽ»äº†ä¸€åˆ‡ï¼šè¿˜å¯
562以用 ``indent`` 。
563
564ä¸è¿‡ï¼ŒGNU indent 也有和 GNU emacs 一样有问题的设定,所以你需è¦ç»™å®ƒä¸€äº›å‘½ä»¤é€‰
565项。ä¸è¿‡ï¼Œè¿™è¿˜ä¸ç®—太糟糕,因为就算是 GNU indent çš„ä½œè€…ä¹Ÿè®¤åŒ K&R çš„æƒå¨æ€§
566(GNU çš„äººå¹¶ä¸æ˜¯åäººï¼Œä»–ä»¬åªæ˜¯åœ¨è¿™ä¸ªé—®é¢˜ä¸Šè¢«ä¸¥é‡çš„误导了),所以你åªè¦ç»™ indent
567指定选项 ``-kr -i8`` (代表 ``K&R,8 字符缩进``),或使用 ``scripts/Lindent``
568这样就å¯ä»¥ä»¥æœ€æ—¶é«¦çš„æ–¹å¼ç¼©è¿›æºä»£ç ã€‚
569
570``indent`` æœ‰å¾ˆå¤šé€‰é¡¹ï¼Œç‰¹åˆ«æ˜¯é‡æ–°æ ¼å¼åŒ–注释的时候,你å¯èƒ½éœ€è¦çœ‹ä¸€ä¸‹å®ƒçš„æ‰‹å†Œã€‚
571ä¸è¿‡è®°ä½ï¼š ``indent`` ä¸èƒ½ä¿®æ­£å的编程习惯。
572
573
57410) Kconfig é…置文件
575------------------------------
576
577对于é布æºç æ ‘的所有 Kconfig* é…置文件æ¥è¯´ï¼Œå®ƒä»¬ç¼©è¿›æ–¹å¼æœ‰æ‰€ä¸åŒã€‚紧挨ç€
578``config`` 定义的行,用一个制表符缩进,然而 help ä¿¡æ¯çš„缩进则é¢å¤–增加 2 个空
579格。举个例å­::
580
581 config AUDIT
582 bool "Auditing support"
583 depends on NET
584 help
585 Enable auditing infrastructure that can be used with another
586 kernel subsystem, such as SELinux (which requires this for
587 logging of avc messages output). Does not do system-call
588 auditing without CONFIG_AUDITSYSCALL.
589
590而那些å±é™©çš„功能 (比如æŸäº›æ–‡ä»¶ç³»ç»Ÿçš„写支æŒ) 应该在它们的æç¤ºå­—符串里显著的声
591明这一点::
592
593 config ADFS_FS_RW
594 bool "ADFS write support (DANGEROUS)"
595 depends on ADFS_FS
596 ...
597
598è¦æŸ¥çœ‹é…置文件的完整文档,请看 Documentation/kbuild/kconfig-language.txt。
599
600
60111) æ•°æ®ç»“æž„
602------------------------------
603
604如果一个数æ®ç»“构,在创建和销æ¯å®ƒçš„å•线执行环境之外å¯è§ï¼Œé‚£ä¹ˆå®ƒå¿…é¡»è¦æœ‰ä¸€ä¸ªå¼•
605用计数器。内核里没有垃圾收集 (并且内核之外的垃圾收集慢且效率低下),这æ„味ç€ä½ 
606ç»å¯¹éœ€è¦è®°å½•ä½ å¯¹è¿™ç§æ•°æ®ç»“构的使用情况。
607
608引用计数æ„味ç€ä½ èƒ½å¤Ÿé¿å…上é”,并且å…许多个用户并行访问这个数æ®ç»“构——而ä¸éœ€è¦
609担心这个数æ®ç»“构仅仅因为暂时ä¸è¢«ä½¿ç”¨å°±æ¶ˆå¤±äº†ï¼Œé‚£äº›ç”¨æˆ·å¯èƒ½ä¸è¿‡æ˜¯æ²‰ç¡äº†ä¸€é˜µæˆ–
610者åšäº†ä¸€äº›å…¶ä»–事情而已。
611
612注æ„ä¸Šé” **ä¸èƒ½** å–ä»£å¼•ç”¨è®¡æ•°ã€‚ä¸Šé”æ˜¯ä¸ºäº†ä¿æŒæ•°æ®ç»“构的一致性,而引用计数是一
613ä¸ªå†…å­˜ç®¡ç†æŠ€å·§ã€‚é€šå¸¸äºŒè€…éƒ½éœ€è¦ï¼Œä¸è¦æŠŠä¸¤ä¸ªæžæ··äº†ã€‚
614
615很多数æ®ç»“构实际上有 2 级引用计数,它们通常有ä¸åŒ ``ç±»`` 的用户。å­ç±»è®¡æ•°å™¨ç»Ÿ
616计å­ç±»ç”¨æˆ·çš„æ•°é‡ï¼Œæ¯å½“å­ç±»è®¡æ•°å™¨å‡è‡³é›¶æ—¶ï¼Œå…¨å±€è®¡æ•°å™¨å‡ä¸€ã€‚
617
618è¿™ç§ ``多级引用计数`` 的例å­å¯ä»¥åœ¨å†…å­˜ç®¡ç† (``struct mm_struct``: mm_users å’Œ
619mm_count),和文件系统 (``struct super_block``: s_count 和 s_active) 中找到。
620
621è®°ä½ï¼šå¦‚æžœå¦ä¸€ä¸ªæ‰§è¡Œçº¿ç´¢å¯ä»¥æ‰¾åˆ°ä½ çš„æ•°æ®ç»“构,但这个数æ®ç»“构没有引用计数器,
622这里几乎肯定是一个 bug。
623
624
62512) å®ï¼Œæžšä¸¾å’ŒRTL
626------------------------------
627
628用于定义常é‡çš„å®çš„åå­—åŠæžšä¸¾é‡Œçš„æ ‡ç­¾éœ€è¦å¤§å†™ã€‚
629
630.. code-block:: c
631
632 #define CONSTANT 0x12345
633
634åœ¨å®šä¹‰å‡ ä¸ªç›¸å…³çš„å¸¸é‡æ—¶ï¼Œæœ€å¥½ç”¨æžšä¸¾ã€‚
635
636å®çš„å字请用大写字æ¯ï¼Œä¸è¿‡å½¢å¦‚函数的å®çš„åå­—å¯ä»¥ç”¨å°å†™å­—æ¯ã€‚
637
638一般的,如果能写æˆå†…è”函数就ä¸è¦å†™æˆåƒå‡½æ•°çš„å®ã€‚
639
640嫿œ‰å¤šä¸ªè¯­å¥çš„å®åº”该被包å«åœ¨ä¸€ä¸ª do-while 代ç å—里:
641
642.. code-block:: c
643
644 #define macrofun(a, b, c) \
645 do { \
646 if (a == 5) \
647 do_this(b, c); \
648 } while (0)
649
650使用å®çš„æ—¶å€™åº”é¿å…的事情:
651
6521) å½±å“æŽ§åˆ¶æµç¨‹çš„å®ï¼š
653
654.. code-block:: c
655
656 #define FOO(x) \
657 do { \
658 if (blah(x) < 0) \
659 return -EBUGGERED; \
660 } while (0)
661
662**éžå¸¸** ä¸å¥½ã€‚它看起æ¥åƒä¸€ä¸ªå‡½æ•°ï¼Œä¸è¿‡å´èƒ½å¯¼è‡´ ``调用`` 它的函数退出;ä¸è¦æ‰“
663乱读者大脑里的语法分æžå™¨ã€‚
664
6652) ä¾èµ–于一个固定å字的本地å˜é‡çš„å®ï¼š
666
667.. code-block:: c
668
669 #define FOO(val) bar(index, val)
670
671å¯èƒ½çœ‹èµ·æ¥åƒæ˜¯ä¸ªä¸é”™çš„东西,ä¸è¿‡å®ƒéžå¸¸å®¹æ˜“把读代ç çš„人æžç³Šæ¶‚,而且容易导致看起
672æ¥ä¸ç›¸å…³çš„æ”¹åЍ另æ¥é”™è¯¯ã€‚
673
6743) ä½œä¸ºå·¦å€¼çš„å¸¦å‚æ•°çš„å®ï¼š FOO(x) = y;如果有人把 FOO å˜æˆä¸€ä¸ªå†…è”函数的è¯ï¼Œè¿™
675 ç§ç”¨æ³•就会出错了。
676
6774) 忘记了优先级:使用表达å¼å®šä¹‰å¸¸é‡çš„å®å¿…须将表达å¼ç½®äºŽä¸€å¯¹å°æ‹¬å·ä¹‹å†…ã€‚å¸¦å‚æ•°
678 çš„å®ä¹Ÿè¦æ³¨æ„此类问题。
679
680.. code-block:: c
681
682 #define CONSTANT 0x4000
683 #define CONSTEXP (CONSTANT | 3)
684
6855) 在å®é‡Œå®šä¹‰ç±»ä¼¼å‡½æ•°çš„æœ¬åœ°å˜é‡æ—¶å‘½å冲çªï¼š
686
687.. code-block:: c
688
689 #define FOO(x) \
690 ({ \
691 typeof(x) ret; \
692 ret = calc_ret(x); \
693 (ret); \
694 })
695
696ret 是本地å˜é‡çš„通用åå­— - __foo_ret æ›´ä¸å®¹æ˜“与一个已存在的å˜é‡å†²çªã€‚
697
698cpp 手册对å®çš„讲解很详细。gcc internals 手册也详细讲解了 RTL,内核里的汇编语
699言ç»å¸¸ç”¨åˆ°å®ƒã€‚
700
701
70213) 打å°å†…核消æ¯
703------------------------------
704
705内核开å‘者应该是å—过良好教育的。请一定注æ„内核信æ¯çš„æ‹¼å†™ï¼Œä»¥ç»™äººä»¥å¥½çš„å°è±¡ã€‚
706ä¸è¦ç”¨ä¸è§„范的å•è¯æ¯”如 ``dont``,而è¦ç”¨ ``do not`` 或者 ``don't`` 。ä¿è¯è¿™äº›ä¿¡
707æ¯ç®€å•明了,无歧义。
708
709内核信æ¯ä¸å¿…以英文å¥å·ç»“æŸã€‚
710
711åœ¨å°æ‹¬å·é‡Œæ‰“å°æ•°å­— (%d) 没有任何价值,应该é¿å…这样åšã€‚
712
713<linux/device.h> 里有一些驱动模型诊断å®ï¼Œä½ åº”该使用它们,以确ä¿ä¿¡æ¯å¯¹åº”于正确
714的设备和驱动,并且被标记了正确的消æ¯çº§åˆ«ã€‚è¿™äº›å®æœ‰ï¼šdev_err(), dev_warn(),
715dev_info() 等等。对于那些ä¸å’ŒæŸä¸ªç‰¹å®šè®¾å¤‡ç›¸å…³è¿žçš„ä¿¡æ¯ï¼Œ<linux/printk.h> 定义
716了 pr_notice(), pr_info(), pr_warn(), pr_err() 和其他。
717
718写出好的调试信æ¯å¯ä»¥æ˜¯ä¸€ä¸ªå¾ˆå¤§çš„æŒ‘战;一旦你写出åŽï¼Œè¿™äº›ä¿¡æ¯åœ¨è¿œç¨‹é™¤é”™æ—¶èƒ½æ
719ä¾›æžå¤§çš„帮助。然而打å°è°ƒè¯•ä¿¡æ¯çš„å¤„ç†æ–¹å¼åŒæ‰“å°éžè°ƒè¯•ä¿¡æ¯ä¸åŒã€‚å…¶ä»– pr_XXX()
720函数能无æ¡ä»¶åœ°æ‰“å°ï¼Œpr_debug() å´ä¸ï¼›é»˜è®¤æƒ…况下它ä¸ä¼šè¢«ç¼–译,除éžå®šä¹‰äº† DEBUG
721或设定了 CONFIG_DYNAMIC_DEBUGã€‚å®žé™…è¿™åŒæ ·æ˜¯ä¸ºäº† dev_dbg(),一个相关约定是在一
722个已ç»å¼€å¯äº† DEBUG 时,使用 VERBOSE_DEBUG æ¥æ·»åŠ  dev_vdbg()。
723
724许多å­ç³»ç»Ÿæ‹¥æœ‰ Kconfig 调试选项æ¥å¼€å¯ -DDEBUG 在对应的 Makefile 里é¢ï¼›åœ¨å…¶ä»–
725情况下,特殊文件使用 #define DEBUG。当一æ¡è°ƒè¯•ä¿¡æ¯éœ€è¦è¢«æ— æ¡ä»¶æ‰“å°æ—¶ï¼Œä¾‹å¦‚,
726如果已ç»åŒ…å«ä¸€ä¸ªè°ƒè¯•相关的 #ifdef æ¡ä»¶ï¼Œprintk(KERN_DEBUG ...) å°±å¯è¢«ä½¿ç”¨ã€‚
727
728
72914) 分é…内存
730------------------------------
731
732内核æä¾›äº†ä¸‹é¢çš„一般用途的内存分é…函数:
733kmalloc(), kzalloc(), kmalloc_array(), kcalloc(), vmalloc() 和 vzalloc()。
734请å‚考 API æ–‡æ¡£ä»¥èŽ·å–æœ‰å…³å®ƒä»¬çš„详细信æ¯ã€‚
735
736传递结构体大å°çš„首选形弿˜¯è¿™æ ·çš„:
737
738.. code-block:: c
739
740 p = kmalloc(sizeof(*p), ...);
741
742å¦å¤–一ç§ä¼ é€’æ–¹å¼ä¸­ï¼Œsizeof çš„æ“作数是结构体的å字,这样会é™ä½Žå¯è¯»æ€§ï¼Œå¹¶ä¸”å¯èƒ½
743会引入 bug。有å¯èƒ½æŒ‡é’ˆå˜é‡ç±»åž‹è¢«æ”¹å˜æ—¶ï¼Œè€Œå¯¹åº”的传递给内存分é…函数的 sizeof
744的结果ä¸å˜ã€‚
745
746强制转æ¢ä¸€ä¸ª void 指针返回值是多余的。C 语言本身ä¿è¯äº†ä»Ž void 指针到其他任何
747æŒ‡é’ˆç±»åž‹çš„è½¬æ¢æ˜¯æ²¡æœ‰é—®é¢˜çš„。
748
749分é…ä¸€ä¸ªæ•°ç»„çš„é¦–é€‰å½¢å¼æ˜¯è¿™æ ·çš„:
750
751.. code-block:: c
752
753 p = kmalloc_array(n, sizeof(...), ...);
754
755分é…ä¸€ä¸ªé›¶é•¿æ•°ç»„çš„é¦–é€‰å½¢å¼æ˜¯è¿™æ ·çš„:
756
757.. code-block:: c
758
759 p = kcalloc(n, sizeof(...), ...);
760
761两ç§å½¢å¼æ£€æŸ¥åˆ†é…å¤§å° n * sizeof(...) 的溢出,如果溢出返回 NULL。
762
763
76415) 内è”弊病
765------------------------------
766
767有一个常è§çš„误解是 ``内è”`` 是 gcc æä¾›çš„å¯ä»¥è®©ä»£ç è¿è¡Œæ›´å¿«çš„一个选项。虽然使
768用内è”函数有时候是æ°å½“çš„ (æ¯”å¦‚ä½œä¸ºä¸€ç§æ›¿ä»£å®çš„æ–¹å¼ï¼Œè¯·çœ‹ç¬¬å二章),ä¸è¿‡å¾ˆå¤šæƒ…
769况䏋䏿˜¯è¿™æ ·ã€‚inline 的过度使用会使内核å˜å¤§ï¼Œä»Žè€Œä½¿æ•´ä¸ªç³»ç»Ÿè¿è¡Œé€Ÿåº¦å˜æ…¢ã€‚
770因为体积大内核会å ç”¨æ›´å¤šçš„æŒ‡ä»¤é«˜é€Ÿç¼“存,而且会导致 pagecache çš„å¯ç”¨å†…å­˜å‡å°‘。
771想象一下,一次 pagecache 未命中就会导致一次ç£ç›˜å¯»å€ï¼Œå°†è€—æ—¶ 5 毫秒。5 毫秒的
772时间内 CPU 能执行很多很多指令。
773
774一个基本的原则是如果一个函数有 3 行以上,就ä¸è¦æŠŠå®ƒå˜æˆå†…è”函数。这个原则的一
775ä¸ªä¾‹å¤–æ˜¯ï¼Œå¦‚æžœä½ çŸ¥é“æŸä¸ªå‚数是一个编译时常é‡ï¼Œè€Œä¸”因为这个常é‡ä½ ç¡®å®šç¼–译器在
776编译时能优化掉你的函数的大部分代ç ï¼Œé‚£ä»ç„¶å¯ä»¥ç»™å®ƒåŠ ä¸Š inline 关键字。
777kmalloc() 内è”函数就是一个很好的例å­ã€‚
778
779人们ç»å¸¸ä¸»å¼ ç»™ static 的而且åªç”¨äº†ä¸€æ¬¡çš„函数加上 inline,如此ä¸ä¼šæœ‰ä»»ä½•æŸå¤±ï¼Œ
780因为没有什么好æƒè¡¡çš„ã€‚è™½ç„¶ä»ŽæŠ€æœ¯ä¸Šè¯´è¿™æ˜¯æ­£ç¡®çš„ï¼Œä½†æ˜¯å®žé™…ä¸Šè¿™ç§æƒ…况下å³ä½¿ä¸åŠ 
781inline gcc 也å¯ä»¥è‡ªåŠ¨ä½¿å…¶å†…è”。而且其他用户å¯èƒ½ä¼šè¦æ±‚移除 inline,由此而æ¥çš„
782争论会抵消 inline 自身的潜在价值,得ä¸å¿å¤±ã€‚
783
784
78516) 函数返回值åŠå‘½å
786------------------------------
787
788函数å¯ä»¥è¿”回多ç§ä¸åŒç±»åž‹çš„值,最常è§çš„ä¸€ç§æ˜¯è¡¨æ˜Žå‡½æ•°æ‰§è¡ŒæˆåŠŸæˆ–è€…å¤±è´¥çš„å€¼ã€‚è¿™æ ·
789的一个值å¯ä»¥è¡¨ç¤ºä¸ºä¸€ä¸ªé”™è¯¯ä»£ç æ•´æ•° (-Exxxï¼å¤±è´¥ï¼Œ0ï¼æˆåŠŸ) 或者一个 ``æˆåŠŸ``
790布尔值 (0ï¼å¤±è´¥ï¼Œéž0ï¼æˆåŠŸ)。
791
792æ··åˆä½¿ç”¨è¿™ä¸¤ç§è¡¨è¾¾æ–¹å¼æ˜¯éš¾äºŽå‘现的 bug çš„æ¥æºã€‚如果 C 语言本身严格区分整形和
793布尔型å˜é‡ï¼Œé‚£ä¹ˆç¼–译器就能够帮我们å‘现这些错误... ä¸è¿‡ C 语言ä¸åŒºåˆ†ã€‚为了é¿å…
794äº§ç”Ÿè¿™ç§ bug,请éµå¾ªä¸‹é¢çš„æƒ¯ä¾‹::
795
796 如果函数的å字是一个动作或者强制性的命令,那么这个函数应该返回错误代
797 ç æ•´æ•°ã€‚如果是一个判断,那么函数应该返回一个 "æˆåŠŸ" 布尔值。
798
799比如, ``add work`` 是一个命令,所以 add_work() 在æˆåŠŸæ—¶è¿”å›ž 0,在失败时返回
800-EBUSY。类似的,因为 ``PCI device present`` 是一个判断,所以 pci_dev_present()
801在æˆåŠŸæ‰¾åˆ°ä¸€ä¸ªåŒ¹é…的设备时应该返回 1,如果找ä¸åˆ°æ—¶åº”该返回 0。
802
803所有 EXPORTed 函数都必须éµå®ˆè¿™ä¸ªæƒ¯ä¾‹ï¼Œæ‰€æœ‰çš„å…¬å…±å‡½æ•°ä¹Ÿéƒ½åº”è¯¥å¦‚æ­¤ã€‚ç§æœ‰
804(static) 函数ä¸éœ€è¦å¦‚此,但是我们也推è这样åšã€‚
805
806è¿”å›žå€¼æ˜¯å®žé™…è®¡ç®—ç»“æžœè€Œä¸æ˜¯è®¡ç®—æ˜¯å¦æˆåŠŸçš„æ ‡å¿—çš„å‡½æ•°ä¸å—此惯例的é™åˆ¶ã€‚一般的,
807他们通过返回一些正常值范围之外的结果æ¥è¡¨ç¤ºå‡ºé”™ã€‚å…¸åž‹çš„ä¾‹å­æ˜¯è¿”回指针的函数,
808他们使用 NULL 或者 ERR_PTR æœºåˆ¶æ¥æŠ¥å‘Šé”™è¯¯ã€‚
809
810
81117) ä¸è¦é‡æ–°å‘明内核å®
812------------------------------
813
814头文件 include/linux/kernel.h 包å«äº†ä¸€äº›å®ï¼Œä½ åº”该使用它们,而ä¸è¦è‡ªå·±å†™ä¸€äº›
815它们的å˜ç§ã€‚比如,如果你需è¦è®¡ç®—一个数组的长度,使用这个å®
816
817.. code-block:: c
818
819 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
820
821类似的,如果你è¦è®¡ç®—æŸç»“构体æˆå‘˜çš„大å°ï¼Œä½¿ç”¨
822
823.. code-block:: c
824
825 #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
826
827还有å¯ä»¥åšä¸¥æ ¼çš„类型检查的 min() å’Œ max() å®ï¼Œå¦‚果你需è¦å¯ä»¥ä½¿ç”¨å®ƒä»¬ã€‚ä½ å¯ä»¥
828自己看看那个头文件里还定义了什么你å¯ä»¥æ‹¿æ¥ç”¨çš„东西,如果有定义的è¯ï¼Œä½ å°±ä¸åº”
829在你的代ç é‡Œè‡ªå·±é‡æ–°å®šä¹‰ã€‚
830
831
83218) 编辑器模å¼è¡Œå’Œå…¶ä»–需è¦ç½—嗦的事情
833--------------------------------------------------
834
835有一些编辑器å¯ä»¥è§£é‡ŠåµŒå…¥åœ¨æºæ–‡ä»¶é‡Œçš„由一些特殊标记标明的é…置信æ¯ã€‚比如,emacs
836能够解释被标记æˆè¿™æ ·çš„行:
837
838.. code-block:: c
839
840 -*- mode: c -*-
841
842或者这样的:
843
844.. code-block:: c
845
846 /*
847 Local Variables:
848 compile-command: "gcc -DMAGIC_DEBUG_FLAG foo.c"
849 End:
850 */
851
852Vim 能够解释这样的标记:
853
854.. code-block:: c
855
856 /* vim:set sw=8 noet */
857
858ä¸è¦åœ¨æºä»£ç ä¸­åŒ…å«ä»»ä½•这样的内容。æ¯ä¸ªäººéƒ½æœ‰ä»–自己的编辑器é…ç½®ï¼Œä½ çš„æºæ–‡ä»¶ä¸
859应该覆盖别人的é…置。这包括有关缩进和模å¼é…置的标记。人们å¯ä»¥ä½¿ç”¨ä»–们自己定制
860的模å¼ï¼Œæˆ–者使用其他å¯ä»¥äº§ç”Ÿæ­£ç¡®çš„缩进的巧妙方法。
861
862
86319) å†…è”æ±‡ç¼–
864------------------------------
865
866在特定架构的代ç ä¸­ï¼Œä½ å¯èƒ½éœ€è¦å†…è”æ±‡ç¼–与 CPU 和平å°ç›¸å…³åŠŸèƒ½è¿žæŽ¥ã€‚éœ€è¦è¿™ä¹ˆåšæ—¶
867å°±ä¸è¦çŠ¹è±«ã€‚ç„¶è€Œï¼Œå½“ C å¯ä»¥å®Œæˆå·¥ä½œæ—¶ï¼Œä¸è¦å¹³ç™½æ— æ•…åœ°ä½¿ç”¨å†…è”æ±‡ç¼–。在å¯èƒ½çš„æƒ…
868况下,你å¯ä»¥å¹¶ä¸”应该用 C 和硬件沟通。
869
870请考虑去写æ†ç»‘通用ä½å…ƒ (wrap common bits) çš„å†…è”æ±‡ç¼–的简å•辅助函数,别去é‡å¤
871åœ°å†™ä¸‹åªæœ‰ç»†å¾®å·®å¼‚å†…è”æ±‡ç¼–。记ä½å†…è”æ±‡ç¼–å¯ä»¥ä½¿ç”¨ C 傿•°ã€‚
872
873å¤§åž‹ï¼Œæœ‰ä¸€å®šå¤æ‚度的汇编函数应该放在 .S 文件内,用相应的 C 原型定义在 C 头文
874件中。汇编函数的 C 原型应该使用 ``asmlinkage`` 。
875
876ä½ å¯èƒ½éœ€è¦æŠŠæ±‡ç¼–è¯­å¥æ ‡è®°ä¸º volatile,用æ¥é˜»æ­¢ GCC 在没å‘现任何副作用åŽå°±æŠŠå®ƒ
877移除了。你ä¸å¿…总是这样åšï¼Œå°½ç®¡ï¼Œè¿™ä¸å¿…è¦çš„举动会é™åˆ¶ä¼˜åŒ–。
878
879在写一个包å«å¤šæ¡æŒ‡ä»¤çš„å•ä¸ªå†…è”æ±‡ç¼–è¯­å¥æ—¶ï¼ŒæŠŠæ¯æ¡æŒ‡ä»¤ç”¨å¼•å·åˆ†å‰²è€Œä¸”å„å ä¸€è¡Œï¼Œ
880除了最åŽä¸€æ¡æŒ‡ä»¤å¤–,在æ¯ä¸ªæŒ‡ä»¤ç»“尾加上 \n\t,让汇编输出时å¯ä»¥æ­£ç¡®åœ°ç¼©è¿›ä¸‹ä¸€æ¡
881指令:
882
883.. code-block:: c
884
885 asm ("magic %reg1, #42\n\t"
886 "more_magic %reg2, %reg3"
887 : /* outputs */ : /* inputs */ : /* clobbers */);
888
889
89020) æ¡ä»¶ç¼–译
891------------------------------
892
893åªè¦å¯èƒ½ï¼Œå°±ä¸è¦åœ¨ .c 文件里é¢ä½¿ç”¨é¢„å¤„ç†æ¡ä»¶ (#if, #ifdef);这样åšè®©ä»£ç æ›´éš¾
894é˜…è¯»å¹¶ä¸”æ›´éš¾åŽ»è·Ÿè¸ªé€»è¾‘ã€‚æ›¿ä»£æ–¹æ¡ˆæ˜¯ï¼Œåœ¨å¤´æ–‡ä»¶ä¸­ç”¨é¢„å¤„ç†æ¡ä»¶æä¾›ç»™é‚£äº› .c 文件
895使用,å†ç»™ #else æä¾›ä¸€ä¸ªç©ºæ¡© (no-op stub) 版本,然åŽåœ¨ .c 文件内无æ¡ä»¶åœ°è°ƒç”¨
896那些 (定义在头文件内的) 函数。这样åšï¼Œç¼–译器会é¿å…为桩函数 (stub) 的调用生æˆ
897任何代ç ï¼Œäº§ç”Ÿçš„结果是相åŒçš„,但逻辑将更加清晰。
898
899最好倾å‘äºŽç¼–è¯‘æ•´ä¸ªå‡½æ•°ï¼Œè€Œä¸æ˜¯å‡½æ•°çš„一部分或表达å¼çš„一部分。与其放一个 ifdef
900在表达å¼å†…,ä¸å¦‚分解出部分或全部表达å¼ï¼Œæ”¾è¿›ä¸€ä¸ªå•独的辅助函数,并应用预处ç†
901æ¡ä»¶åˆ°è¿™ä¸ªè¾…助函数内。
902
903如果你有一个在特定é…置中,å¯èƒ½å˜æˆæœªä½¿ç”¨çš„函数或å˜é‡ï¼Œç¼–译器会警告它定义了但
904未使用,把它标记为 __maybe_unused è€Œä¸æ˜¯å°†å®ƒåŒ…å«åœ¨ä¸€ä¸ªé¢„å¤„ç†æ¡ä»¶ä¸­ã€‚(然而,如
905果一个函数或å˜é‡æ€»æ˜¯æœªä½¿ç”¨ï¼Œå°±ç›´æŽ¥åˆ é™¤å®ƒã€‚)
906
907在代ç ä¸­ï¼Œå°½å¯èƒ½åœ°ä½¿ç”¨ IS_ENABLED 宿¥è½¬åŒ–æŸä¸ª Kconfig 标记为 C 的布尔
908表达å¼ï¼Œå¹¶åœ¨ä¸€èˆ¬çš„ C æ¡ä»¶ä¸­ä½¿ç”¨å®ƒï¼š
909
910.. code-block:: c
911
912 if (IS_ENABLED(CONFIG_SOMETHING)) {
913 ...
914 }
915
916编译器会åšå¸¸é‡æŠ˜å ï¼Œç„¶åŽå°±åƒä½¿ç”¨ #ifdef é‚£æ ·åŽ»åŒ…å«æˆ–排除代ç å—,所以这ä¸ä¼šå¸¦
917æ¥ä»»ä½•è¿è¡Œæ—¶å¼€é”€ã€‚ç„¶è€Œï¼Œè¿™ç§æ–¹æ³•便—§å…许 C 编译器查看å—内的代ç ï¼Œå¹¶æ£€æŸ¥å®ƒçš„æ­£
918确性 (语法,类型,符å·å¼•用,等等)。因此,如果æ¡ä»¶ä¸æ»¡è¶³ï¼Œä»£ç å—内的引用符å·å°±
919ä¸å­˜åœ¨æ—¶ï¼Œä½ è¿˜æ˜¯å¿…须去用 #ifdef。
920
921在任何有æ„义的 #if 或 #ifdef å—的末尾 (超过几行的),在 #endif åŒä¸€è¡Œçš„åŽé¢å†™ä¸‹
922注解,注释这个æ¡ä»¶è¡¨è¾¾å¼ã€‚例如:
923
924.. code-block:: c
925
926 #ifdef CONFIG_SOMETHING
927 ...
928 #endif /* CONFIG_SOMETHING */
929
930
931附录 I) å‚考
932-------------------
933
934The C Programming Language, 第二版
935作者:Brian W. Kernighan 和 Denni M. Ritchie.
936Prentice Hall, Inc., 1988.
937ISBN 0-13-110362-8 (软皮), 0-13-110370-9 (硬皮).
938
939The Practice of Programming
940作者:Brian W. Kernighan 和 Rob Pike.
941Addison-Wesley, Inc., 1999.
942ISBN 0-201-61586-X.
943
944GNU 手册 - éµå¾ª K&R 标准和此文本 - cpp, gcc, gcc internals and indent,
945都å¯ä»¥ä»Ž http://www.gnu.org/manual/ 找到
946
947WG14 是 C 语言的国际标准化工作组,URL: http://www.open-std.org/JTC1/SC22/WG14/
948
949Kernel process/coding-style.rst,作者 greg@kroah.com å‘表于 OLS 2002:
950http://www.kroah.com/linux/talks/ols_2002_kernel_codingstyle_talk/html/
diff --git a/Documentation/translations/zh_CN/index.rst b/Documentation/translations/zh_CN/index.rst
new file mode 100644
index 000000000000..75956d669962
--- /dev/null
+++ b/Documentation/translations/zh_CN/index.rst
@@ -0,0 +1,12 @@
1.. raw:: latex
2
3 \renewcommand\thesection*
4 \renewcommand\thesubsection*
5
6Chinese translations
7====================
8
9.. toctree::
10 :maxdepth: 1
11
12 coding-style
diff --git a/Documentation/usb/gadget-testing.txt b/Documentation/usb/gadget-testing.txt
index 581960574889..fb0cc4df1765 100644
--- a/Documentation/usb/gadget-testing.txt
+++ b/Documentation/usb/gadget-testing.txt
@@ -632,6 +632,8 @@ The uac2 function provides these attributes in its function directory:
632 p_chmask - playback channel mask 632 p_chmask - playback channel mask
633 p_srate - playback sampling rate 633 p_srate - playback sampling rate
634 p_ssize - playback sample size (bytes) 634 p_ssize - playback sample size (bytes)
635 req_number - the number of pre-allocated request for both capture
636 and playback
635 637
636The attributes have sane default values. 638The attributes have sane default values.
637 639
diff --git a/Documentation/usb/power-management.txt b/Documentation/usb/power-management.txt
index 0a94ffe17ab6..00e706997130 100644
--- a/Documentation/usb/power-management.txt
+++ b/Documentation/usb/power-management.txt
@@ -543,7 +543,7 @@ relevant attribute files are usb2_hardware_lpm and usb3_hardware_lpm.
543 When a USB 3.0 lpm-capable device is plugged in to a 543 When a USB 3.0 lpm-capable device is plugged in to a
544 xHCI host which supports link PM, it will check if U1 544 xHCI host which supports link PM, it will check if U1
545 and U2 exit latencies have been set in the BOS 545 and U2 exit latencies have been set in the BOS
546 descriptor; if the check is is passed and the host 546 descriptor; if the check is passed and the host
547 supports USB3 hardware LPM, USB3 hardware LPM will be 547 supports USB3 hardware LPM, USB3 hardware LPM will be
548 enabled for the device and these files will be created. 548 enabled for the device and these files will be created.
549 The files hold a string value (enable or disable) 549 The files hold a string value (enable or disable)
diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index 03145b7cafaa..3c248f772ae6 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -951,6 +951,10 @@ This ioctl allows the user to create or modify a guest physical memory
951slot. When changing an existing slot, it may be moved in the guest 951slot. When changing an existing slot, it may be moved in the guest
952physical memory space, or its flags may be modified. It may not be 952physical memory space, or its flags may be modified. It may not be
953resized. Slots may not overlap in guest physical address space. 953resized. Slots may not overlap in guest physical address space.
954Bits 0-15 of "slot" specifies the slot id and this value should be
955less than the maximum number of user memory slots supported per VM.
956The maximum allowed slots can be queried using KVM_CAP_NR_MEMSLOTS,
957if this capability is supported by the architecture.
954 958
955If KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 of "slot" 959If KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 of "slot"
956specifies the address space which is being modified. They must be 960specifies the address space which is being modified. They must be
@@ -2061,6 +2065,8 @@ registers, find a list below:
2061 MIPS | KVM_REG_MIPS_LO | 64 2065 MIPS | KVM_REG_MIPS_LO | 64
2062 MIPS | KVM_REG_MIPS_PC | 64 2066 MIPS | KVM_REG_MIPS_PC | 64
2063 MIPS | KVM_REG_MIPS_CP0_INDEX | 32 2067 MIPS | KVM_REG_MIPS_CP0_INDEX | 32
2068 MIPS | KVM_REG_MIPS_CP0_ENTRYLO0 | 64
2069 MIPS | KVM_REG_MIPS_CP0_ENTRYLO1 | 64
2064 MIPS | KVM_REG_MIPS_CP0_CONTEXT | 64 2070 MIPS | KVM_REG_MIPS_CP0_CONTEXT | 64
2065 MIPS | KVM_REG_MIPS_CP0_USERLOCAL | 64 2071 MIPS | KVM_REG_MIPS_CP0_USERLOCAL | 64
2066 MIPS | KVM_REG_MIPS_CP0_PAGEMASK | 32 2072 MIPS | KVM_REG_MIPS_CP0_PAGEMASK | 32
@@ -2071,9 +2077,11 @@ registers, find a list below:
2071 MIPS | KVM_REG_MIPS_CP0_ENTRYHI | 64 2077 MIPS | KVM_REG_MIPS_CP0_ENTRYHI | 64
2072 MIPS | KVM_REG_MIPS_CP0_COMPARE | 32 2078 MIPS | KVM_REG_MIPS_CP0_COMPARE | 32
2073 MIPS | KVM_REG_MIPS_CP0_STATUS | 32 2079 MIPS | KVM_REG_MIPS_CP0_STATUS | 32
2080 MIPS | KVM_REG_MIPS_CP0_INTCTL | 32
2074 MIPS | KVM_REG_MIPS_CP0_CAUSE | 32 2081 MIPS | KVM_REG_MIPS_CP0_CAUSE | 32
2075 MIPS | KVM_REG_MIPS_CP0_EPC | 64 2082 MIPS | KVM_REG_MIPS_CP0_EPC | 64
2076 MIPS | KVM_REG_MIPS_CP0_PRID | 32 2083 MIPS | KVM_REG_MIPS_CP0_PRID | 32
2084 MIPS | KVM_REG_MIPS_CP0_EBASE | 64
2077 MIPS | KVM_REG_MIPS_CP0_CONFIG | 32 2085 MIPS | KVM_REG_MIPS_CP0_CONFIG | 32
2078 MIPS | KVM_REG_MIPS_CP0_CONFIG1 | 32 2086 MIPS | KVM_REG_MIPS_CP0_CONFIG1 | 32
2079 MIPS | KVM_REG_MIPS_CP0_CONFIG2 | 32 2087 MIPS | KVM_REG_MIPS_CP0_CONFIG2 | 32
@@ -2148,6 +2156,12 @@ patterns depending on whether they're 32-bit or 64-bit registers:
2148 0x7020 0000 0001 00 <reg:5> <sel:3> (32-bit) 2156 0x7020 0000 0001 00 <reg:5> <sel:3> (32-bit)
2149 0x7030 0000 0001 00 <reg:5> <sel:3> (64-bit) 2157 0x7030 0000 0001 00 <reg:5> <sel:3> (64-bit)
2150 2158
2159Note: KVM_REG_MIPS_CP0_ENTRYLO0 and KVM_REG_MIPS_CP0_ENTRYLO1 are the MIPS64
2160versions of the EntryLo registers regardless of the word size of the host
2161hardware, host kernel, guest, and whether XPA is present in the guest, i.e.
2162with the RI and XI bits (if they exist) in bits 63 and 62 respectively, and
2163the PFNX field starting at bit 30.
2164
2151MIPS KVM control registers (see above) have the following id bit patterns: 2165MIPS KVM control registers (see above) have the following id bit patterns:
2152 0x7030 0000 0002 <reg:16> 2166 0x7030 0000 0002 <reg:16>
2153 2167
@@ -2443,18 +2457,20 @@ are, it will do nothing and return an EBUSY error.
2443The parameter is a pointer to a 32-bit unsigned integer variable 2457The parameter is a pointer to a 32-bit unsigned integer variable
2444containing the order (log base 2) of the desired size of the hash 2458containing the order (log base 2) of the desired size of the hash
2445table, which must be between 18 and 46. On successful return from the 2459table, which must be between 18 and 46. On successful return from the
2446ioctl, it will have been updated with the order of the hash table that 2460ioctl, the value will not be changed by the kernel.
2447was allocated.
2448 2461
2449If no hash table has been allocated when any vcpu is asked to run 2462If no hash table has been allocated when any vcpu is asked to run
2450(with the KVM_RUN ioctl), the host kernel will allocate a 2463(with the KVM_RUN ioctl), the host kernel will allocate a
2451default-sized hash table (16 MB). 2464default-sized hash table (16 MB).
2452 2465
2453If this ioctl is called when a hash table has already been allocated, 2466If this ioctl is called when a hash table has already been allocated,
2454the kernel will clear out the existing hash table (zero all HPTEs) and 2467with a different order from the existing hash table, the existing hash
2455return the hash table order in the parameter. (If the guest is using 2468table will be freed and a new one allocated. If this is ioctl is
2456the virtualized real-mode area (VRMA) facility, the kernel will 2469called when a hash table has already been allocated of the same order
2457re-create the VMRA HPTEs on the next KVM_RUN of any vcpu.) 2470as specified, the kernel will clear out the existing hash table (zero
2471all HPTEs). In either case, if the guest is using the virtualized
2472real-mode area (VRMA) facility, the kernel will re-create the VMRA
2473HPTEs on the next KVM_RUN of any vcpu.
2458 2474
24594.77 KVM_S390_INTERRUPT 24754.77 KVM_S390_INTERRUPT
2460 2476
@@ -3177,7 +3193,7 @@ of IOMMU pages.
3177 3193
3178The rest of functionality is identical to KVM_CREATE_SPAPR_TCE. 3194The rest of functionality is identical to KVM_CREATE_SPAPR_TCE.
3179 3195
31804.98 KVM_REINJECT_CONTROL 31964.99 KVM_REINJECT_CONTROL
3181 3197
3182Capability: KVM_CAP_REINJECT_CONTROL 3198Capability: KVM_CAP_REINJECT_CONTROL
3183Architectures: x86 3199Architectures: x86
@@ -3201,6 +3217,166 @@ struct kvm_reinject_control {
3201pit_reinject = 0 (!reinject mode) is recommended, unless running an old 3217pit_reinject = 0 (!reinject mode) is recommended, unless running an old
3202operating system that uses the PIT for timing (e.g. Linux 2.4.x). 3218operating system that uses the PIT for timing (e.g. Linux 2.4.x).
3203 3219
32204.100 KVM_PPC_CONFIGURE_V3_MMU
3221
3222Capability: KVM_CAP_PPC_RADIX_MMU or KVM_CAP_PPC_HASH_MMU_V3
3223Architectures: ppc
3224Type: vm ioctl
3225Parameters: struct kvm_ppc_mmuv3_cfg (in)
3226Returns: 0 on success,
3227 -EFAULT if struct kvm_ppc_mmuv3_cfg cannot be read,
3228 -EINVAL if the configuration is invalid
3229
3230This ioctl controls whether the guest will use radix or HPT (hashed
3231page table) translation, and sets the pointer to the process table for
3232the guest.
3233
3234struct kvm_ppc_mmuv3_cfg {
3235 __u64 flags;
3236 __u64 process_table;
3237};
3238
3239There are two bits that can be set in flags; KVM_PPC_MMUV3_RADIX and
3240KVM_PPC_MMUV3_GTSE. KVM_PPC_MMUV3_RADIX, if set, configures the guest
3241to use radix tree translation, and if clear, to use HPT translation.
3242KVM_PPC_MMUV3_GTSE, if set and if KVM permits it, configures the guest
3243to be able to use the global TLB and SLB invalidation instructions;
3244if clear, the guest may not use these instructions.
3245
3246The process_table field specifies the address and size of the guest
3247process table, which is in the guest's space. This field is formatted
3248as the second doubleword of the partition table entry, as defined in
3249the Power ISA V3.00, Book III section 5.7.6.1.
3250
32514.101 KVM_PPC_GET_RMMU_INFO
3252
3253Capability: KVM_CAP_PPC_RADIX_MMU
3254Architectures: ppc
3255Type: vm ioctl
3256Parameters: struct kvm_ppc_rmmu_info (out)
3257Returns: 0 on success,
3258 -EFAULT if struct kvm_ppc_rmmu_info cannot be written,
3259 -EINVAL if no useful information can be returned
3260
3261This ioctl returns a structure containing two things: (a) a list
3262containing supported radix tree geometries, and (b) a list that maps
3263page sizes to put in the "AP" (actual page size) field for the tlbie
3264(TLB invalidate entry) instruction.
3265
3266struct kvm_ppc_rmmu_info {
3267 struct kvm_ppc_radix_geom {
3268 __u8 page_shift;
3269 __u8 level_bits[4];
3270 __u8 pad[3];
3271 } geometries[8];
3272 __u32 ap_encodings[8];
3273};
3274
3275The geometries[] field gives up to 8 supported geometries for the
3276radix page table, in terms of the log base 2 of the smallest page
3277size, and the number of bits indexed at each level of the tree, from
3278the PTE level up to the PGD level in that order. Any unused entries
3279will have 0 in the page_shift field.
3280
3281The ap_encodings gives the supported page sizes and their AP field
3282encodings, encoded with the AP value in the top 3 bits and the log
3283base 2 of the page size in the bottom 6 bits.
3284
32854.102 KVM_PPC_RESIZE_HPT_PREPARE
3286
3287Capability: KVM_CAP_SPAPR_RESIZE_HPT
3288Architectures: powerpc
3289Type: vm ioctl
3290Parameters: struct kvm_ppc_resize_hpt (in)
3291Returns: 0 on successful completion,
3292 >0 if a new HPT is being prepared, the value is an estimated
3293 number of milliseconds until preparation is complete
3294 -EFAULT if struct kvm_reinject_control cannot be read,
3295 -EINVAL if the supplied shift or flags are invalid
3296 -ENOMEM if unable to allocate the new HPT
3297 -ENOSPC if there was a hash collision when moving existing
3298 HPT entries to the new HPT
3299 -EIO on other error conditions
3300
3301Used to implement the PAPR extension for runtime resizing of a guest's
3302Hashed Page Table (HPT). Specifically this starts, stops or monitors
3303the preparation of a new potential HPT for the guest, essentially
3304implementing the H_RESIZE_HPT_PREPARE hypercall.
3305
3306If called with shift > 0 when there is no pending HPT for the guest,
3307this begins preparation of a new pending HPT of size 2^(shift) bytes.
3308It then returns a positive integer with the estimated number of
3309milliseconds until preparation is complete.
3310
3311If called when there is a pending HPT whose size does not match that
3312requested in the parameters, discards the existing pending HPT and
3313creates a new one as above.
3314
3315If called when there is a pending HPT of the size requested, will:
3316 * If preparation of the pending HPT is already complete, return 0
3317 * If preparation of the pending HPT has failed, return an error
3318 code, then discard the pending HPT.
3319 * If preparation of the pending HPT is still in progress, return an
3320 estimated number of milliseconds until preparation is complete.
3321
3322If called with shift == 0, discards any currently pending HPT and
3323returns 0 (i.e. cancels any in-progress preparation).
3324
3325flags is reserved for future expansion, currently setting any bits in
3326flags will result in an -EINVAL.
3327
3328Normally this will be called repeatedly with the same parameters until
3329it returns <= 0. The first call will initiate preparation, subsequent
3330ones will monitor preparation until it completes or fails.
3331
3332struct kvm_ppc_resize_hpt {
3333 __u64 flags;
3334 __u32 shift;
3335 __u32 pad;
3336};
3337
33384.103 KVM_PPC_RESIZE_HPT_COMMIT
3339
3340Capability: KVM_CAP_SPAPR_RESIZE_HPT
3341Architectures: powerpc
3342Type: vm ioctl
3343Parameters: struct kvm_ppc_resize_hpt (in)
3344Returns: 0 on successful completion,
3345 -EFAULT if struct kvm_reinject_control cannot be read,
3346 -EINVAL if the supplied shift or flags are invalid
3347 -ENXIO is there is no pending HPT, or the pending HPT doesn't
3348 have the requested size
3349 -EBUSY if the pending HPT is not fully prepared
3350 -ENOSPC if there was a hash collision when moving existing
3351 HPT entries to the new HPT
3352 -EIO on other error conditions
3353
3354Used to implement the PAPR extension for runtime resizing of a guest's
3355Hashed Page Table (HPT). Specifically this requests that the guest be
3356transferred to working with the new HPT, essentially implementing the
3357H_RESIZE_HPT_COMMIT hypercall.
3358
3359This should only be called after KVM_PPC_RESIZE_HPT_PREPARE has
3360returned 0 with the same parameters. In other cases
3361KVM_PPC_RESIZE_HPT_COMMIT will return an error (usually -ENXIO or
3362-EBUSY, though others may be possible if the preparation was started,
3363but failed).
3364
3365This will have undefined effects on the guest if it has not already
3366placed itself in a quiescent state where no vcpu will make MMU enabled
3367memory accesses.
3368
3369On succsful completion, the pending HPT will become the guest's active
3370HPT and the previous HPT will be discarded.
3371
3372On failure, the guest will still be operating on its previous HPT.
3373
3374struct kvm_ppc_resize_hpt {
3375 __u64 flags;
3376 __u32 shift;
3377 __u32 pad;
3378};
3379
32045. The kvm_run structure 33805. The kvm_run structure
3205------------------------ 3381------------------------
3206 3382
@@ -3217,7 +3393,18 @@ struct kvm_run {
3217Request that KVM_RUN return when it becomes possible to inject external 3393Request that KVM_RUN return when it becomes possible to inject external
3218interrupts into the guest. Useful in conjunction with KVM_INTERRUPT. 3394interrupts into the guest. Useful in conjunction with KVM_INTERRUPT.
3219 3395
3220 __u8 padding1[7]; 3396 __u8 immediate_exit;
3397
3398This field is polled once when KVM_RUN starts; if non-zero, KVM_RUN
3399exits immediately, returning -EINTR. In the common scenario where a
3400signal is used to "kick" a VCPU out of KVM_RUN, this field can be used
3401to avoid usage of KVM_SET_SIGNAL_MASK, which has worse scalability.
3402Rather than blocking the signal outside KVM_RUN, userspace can set up
3403a signal handler that sets run->immediate_exit to a non-zero value.
3404
3405This field is ignored if KVM_CAP_IMMEDIATE_EXIT is not available.
3406
3407 __u8 padding1[6];
3221 3408
3222 /* out */ 3409 /* out */
3223 __u32 exit_reason; 3410 __u32 exit_reason;
@@ -3942,3 +4129,21 @@ In order to use SynIC, it has to be activated by setting this
3942capability via KVM_ENABLE_CAP ioctl on the vcpu fd. Note that this 4129capability via KVM_ENABLE_CAP ioctl on the vcpu fd. Note that this
3943will disable the use of APIC hardware virtualization even if supported 4130will disable the use of APIC hardware virtualization even if supported
3944by the CPU, as it's incompatible with SynIC auto-EOI behavior. 4131by the CPU, as it's incompatible with SynIC auto-EOI behavior.
4132
41338.3 KVM_CAP_PPC_RADIX_MMU
4134
4135Architectures: ppc
4136
4137This capability, if KVM_CHECK_EXTENSION indicates that it is
4138available, means that that the kernel can support guests using the
4139radix MMU defined in Power ISA V3.00 (as implemented in the POWER9
4140processor).
4141
41428.4 KVM_CAP_PPC_HASH_MMU_V3
4143
4144Architectures: ppc
4145
4146This capability, if KVM_CHECK_EXTENSION indicates that it is
4147available, means that that the kernel can support guests using the
4148hashed page table MMU defined in Power ISA V3.00 (as implemented in
4149the POWER9 processor), including in-memory segment tables.
diff --git a/Documentation/virtual/kvm/devices/arm-vgic-v3.txt b/Documentation/virtual/kvm/devices/arm-vgic-v3.txt
index 9348b3caccd7..c1a24612c198 100644
--- a/Documentation/virtual/kvm/devices/arm-vgic-v3.txt
+++ b/Documentation/virtual/kvm/devices/arm-vgic-v3.txt
@@ -118,7 +118,7 @@ Groups:
118 -EBUSY: One or more VCPUs are running 118 -EBUSY: One or more VCPUs are running
119 119
120 120
121 KVM_DEV_ARM_VGIC_CPU_SYSREGS 121 KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS
122 Attributes: 122 Attributes:
123 The attr field of kvm_device_attr encodes two values: 123 The attr field of kvm_device_attr encodes two values:
124 bits: | 63 .... 32 | 31 .... 16 | 15 .... 0 | 124 bits: | 63 .... 32 | 31 .... 16 | 15 .... 0 |
@@ -139,13 +139,15 @@ Groups:
139 All system regs accessed through this API are (rw, 64-bit) and 139 All system regs accessed through this API are (rw, 64-bit) and
140 kvm_device_attr.addr points to a __u64 value. 140 kvm_device_attr.addr points to a __u64 value.
141 141
142 KVM_DEV_ARM_VGIC_CPU_SYSREGS accesses the CPU interface registers for the 142 KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS accesses the CPU interface registers for the
143 CPU specified by the mpidr field. 143 CPU specified by the mpidr field.
144 144
145 CPU interface registers access is not implemented for AArch32 mode.
146 Error -ENXIO is returned when accessed in AArch32 mode.
145 Errors: 147 Errors:
146 -ENXIO: Getting or setting this register is not yet supported 148 -ENXIO: Getting or setting this register is not yet supported
147 -EBUSY: VCPU is running 149 -EBUSY: VCPU is running
148 -EINVAL: Invalid mpidr supplied 150 -EINVAL: Invalid mpidr or register value supplied
149 151
150 152
151 KVM_DEV_ARM_VGIC_GRP_NR_IRQS 153 KVM_DEV_ARM_VGIC_GRP_NR_IRQS
@@ -204,3 +206,6 @@ Groups:
204 architecture defined MPIDR, and the field is encoded as follows: 206 architecture defined MPIDR, and the field is encoded as follows:
205 | 63 .... 56 | 55 .... 48 | 47 .... 40 | 39 .... 32 | 207 | 63 .... 56 | 55 .... 48 | 47 .... 40 | 39 .... 32 |
206 | Aff3 | Aff2 | Aff1 | Aff0 | 208 | Aff3 | Aff2 | Aff1 | Aff0 |
209 Errors:
210 -EINVAL: vINTID is not multiple of 32 or
211 info field is not VGIC_LEVEL_INFO_LINE_LEVEL
diff --git a/Documentation/virtual/kvm/hypercalls.txt b/Documentation/virtual/kvm/hypercalls.txt
index c8d040e27046..feaaa634f154 100644
--- a/Documentation/virtual/kvm/hypercalls.txt
+++ b/Documentation/virtual/kvm/hypercalls.txt
@@ -81,3 +81,38 @@ the vcpu to sleep until occurrence of an appropriate event. Another vcpu of the
81same guest can wakeup the sleeping vcpu by issuing KVM_HC_KICK_CPU hypercall, 81same guest can wakeup the sleeping vcpu by issuing KVM_HC_KICK_CPU hypercall,
82specifying APIC ID (a1) of the vcpu to be woken up. An additional argument (a0) 82specifying APIC ID (a1) of the vcpu to be woken up. An additional argument (a0)
83is used in the hypercall for future use. 83is used in the hypercall for future use.
84
85
866. KVM_HC_CLOCK_PAIRING
87------------------------
88Architecture: x86
89Status: active
90Purpose: Hypercall used to synchronize host and guest clocks.
91Usage:
92
93a0: guest physical address where host copies
94"struct kvm_clock_offset" structure.
95
96a1: clock_type, ATM only KVM_CLOCK_PAIRING_WALLCLOCK (0)
97is supported (corresponding to the host's CLOCK_REALTIME clock).
98
99 struct kvm_clock_pairing {
100 __s64 sec;
101 __s64 nsec;
102 __u64 tsc;
103 __u32 flags;
104 __u32 pad[9];
105 };
106
107 Where:
108 * sec: seconds from clock_type clock.
109 * nsec: nanoseconds from clock_type clock.
110 * tsc: guest TSC value used to calculate sec/nsec pair
111 * flags: flags, unused (0) at the moment.
112
113The hypercall lets a guest compute a precise timestamp across
114host and guest. The guest can use the returned TSC value to
115compute the CLOCK_REALTIME for its clock, at the same instant.
116
117Returns KVM_EOPNOTSUPP if the host does not use TSC clocksource,
118or if clock type is different than KVM_CLOCK_PAIRING_WALLCLOCK.
diff --git a/Documentation/virtual/kvm/locking.txt b/Documentation/virtual/kvm/locking.txt
index fd013bf4115b..1bb8bcaf8497 100644
--- a/Documentation/virtual/kvm/locking.txt
+++ b/Documentation/virtual/kvm/locking.txt
@@ -26,9 +26,16 @@ sections.
26Fast page fault: 26Fast page fault:
27 27
28Fast page fault is the fast path which fixes the guest page fault out of 28Fast page fault is the fast path which fixes the guest page fault out of
29the mmu-lock on x86. Currently, the page fault can be fast only if the 29the mmu-lock on x86. Currently, the page fault can be fast in one of the
30shadow page table is present and it is caused by write-protect, that means 30following two cases:
31we just need change the W bit of the spte. 31
321. Access Tracking: The SPTE is not present, but it is marked for access
33tracking i.e. the SPTE_SPECIAL_MASK is set. That means we need to
34restore the saved R/X bits. This is described in more detail later below.
35
362. Write-Protection: The SPTE is present and the fault is
37caused by write-protect. That means we just need to change the W bit of the
38spte.
32 39
33What we use to avoid all the race is the SPTE_HOST_WRITEABLE bit and 40What we use to avoid all the race is the SPTE_HOST_WRITEABLE bit and
34SPTE_MMU_WRITEABLE bit on the spte: 41SPTE_MMU_WRITEABLE bit on the spte:
@@ -38,7 +45,8 @@ SPTE_MMU_WRITEABLE bit on the spte:
38 page write-protection. 45 page write-protection.
39 46
40On fast page fault path, we will use cmpxchg to atomically set the spte W 47On fast page fault path, we will use cmpxchg to atomically set the spte W
41bit if spte.SPTE_HOST_WRITEABLE = 1 and spte.SPTE_WRITE_PROTECT = 1, this 48bit if spte.SPTE_HOST_WRITEABLE = 1 and spte.SPTE_WRITE_PROTECT = 1, or
49restore the saved R/X bits if VMX_EPT_TRACK_ACCESS mask is set, or both. This
42is safe because whenever changing these bits can be detected by cmpxchg. 50is safe because whenever changing these bits can be detected by cmpxchg.
43 51
44But we need carefully check these cases: 52But we need carefully check these cases:
@@ -142,6 +150,21 @@ Since the spte is "volatile" if it can be updated out of mmu-lock, we always
142atomically update the spte, the race caused by fast page fault can be avoided, 150atomically update the spte, the race caused by fast page fault can be avoided,
143See the comments in spte_has_volatile_bits() and mmu_spte_update(). 151See the comments in spte_has_volatile_bits() and mmu_spte_update().
144 152
153Lockless Access Tracking:
154
155This is used for Intel CPUs that are using EPT but do not support the EPT A/D
156bits. In this case, when the KVM MMU notifier is called to track accesses to a
157page (via kvm_mmu_notifier_clear_flush_young), it marks the PTE as not-present
158by clearing the RWX bits in the PTE and storing the original R & X bits in
159some unused/ignored bits. In addition, the SPTE_SPECIAL_MASK is also set on the
160PTE (using the ignored bit 62). When the VM tries to access the page later on,
161a fault is generated and the fast page fault mechanism described above is used
162to atomically restore the PTE to a Present state. The W bit is not saved when
163the PTE is marked for access tracking and during restoration to the Present
164state, the W bit is set depending on whether or not it was a write access. If
165it wasn't, then the W bit will remain clear until a write access happens, at
166which time it will be set using the Dirty tracking mechanism described above.
167
1453. Reference 1683. Reference
146------------ 169------------
147 170
diff --git a/Documentation/virtual/uml/UserModeLinux-HOWTO.txt b/Documentation/virtual/uml/UserModeLinux-HOWTO.txt
index f4099ca6b483..87b80f589e1c 100644
--- a/Documentation/virtual/uml/UserModeLinux-HOWTO.txt
+++ b/Documentation/virtual/uml/UserModeLinux-HOWTO.txt
@@ -2401,9 +2401,9 @@
2401 2401
2402 This takes one argument, which is a single letter. It calls the 2402 This takes one argument, which is a single letter. It calls the
2403 generic kernel's SysRq driver, which does whatever is called for by 2403 generic kernel's SysRq driver, which does whatever is called for by
2404 that argument. See the SysRq documentation in Documentation/sysrq.txt 2404 that argument. See the SysRq documentation in
2405 in your favorite kernel tree to see what letters are valid and what 2405 Documentation/admin-guide/sysrq.rst in your favorite kernel tree to
2406 they do. 2406 see what letters are valid and what they do.
2407 2407
2408 2408
2409 2409
diff --git a/Documentation/vm/ksm.txt b/Documentation/vm/ksm.txt
index f34a8ee6f860..6b0ca7feb135 100644
--- a/Documentation/vm/ksm.txt
+++ b/Documentation/vm/ksm.txt
@@ -38,6 +38,10 @@ the range for whenever the KSM daemon is started; even if the range
38cannot contain any pages which KSM could actually merge; even if 38cannot contain any pages which KSM could actually merge; even if
39MADV_UNMERGEABLE is applied to a range which was never MADV_MERGEABLE. 39MADV_UNMERGEABLE is applied to a range which was never MADV_MERGEABLE.
40 40
41If a region of memory must be split into at least one new MADV_MERGEABLE
42or MADV_UNMERGEABLE region, the madvise may return ENOMEM if the process
43will exceed vm.max_map_count (see Documentation/sysctl/vm.txt).
44
41Like other madvise calls, they are intended for use on mapped areas of 45Like other madvise calls, they are intended for use on mapped areas of
42the user address space: they will report ENOMEM if the specified range 46the user address space: they will report ENOMEM if the specified range
43includes unmapped gaps (though working on the intervening mapped areas), 47includes unmapped gaps (though working on the intervening mapped areas),
@@ -80,6 +84,20 @@ run - set 0 to stop ksmd from running but keep merged pages,
80 Default: 0 (must be changed to 1 to activate KSM, 84 Default: 0 (must be changed to 1 to activate KSM,
81 except if CONFIG_SYSFS is disabled) 85 except if CONFIG_SYSFS is disabled)
82 86
87use_zero_pages - specifies whether empty pages (i.e. allocated pages
88 that only contain zeroes) should be treated specially.
89 When set to 1, empty pages are merged with the kernel
90 zero page(s) instead of with each other as it would
91 happen normally. This can improve the performance on
92 architectures with coloured zero pages, depending on
93 the workload. Care should be taken when enabling this
94 setting, as it can potentially degrade the performance
95 of KSM for some workloads, for example if the checksums
96 of pages candidate for merging match the checksum of
97 an empty page. This setting can be changed at any time,
98 it is only effective for pages merged after the change.
99 Default: 0 (normal KSM behaviour as in earlier releases)
100
83The effectiveness of KSM and MADV_MERGEABLE is shown in /sys/kernel/mm/ksm/: 101The effectiveness of KSM and MADV_MERGEABLE is shown in /sys/kernel/mm/ksm/:
84 102
85pages_shared - how many shared pages are being used 103pages_shared - how many shared pages are being used
diff --git a/Documentation/vm/transhuge.txt b/Documentation/vm/transhuge.txt
index c4171e4519c2..cd28d5ee5273 100644
--- a/Documentation/vm/transhuge.txt
+++ b/Documentation/vm/transhuge.txt
@@ -110,6 +110,7 @@ MADV_HUGEPAGE region.
110 110
111echo always >/sys/kernel/mm/transparent_hugepage/defrag 111echo always >/sys/kernel/mm/transparent_hugepage/defrag
112echo defer >/sys/kernel/mm/transparent_hugepage/defrag 112echo defer >/sys/kernel/mm/transparent_hugepage/defrag
113echo defer+madvise >/sys/kernel/mm/transparent_hugepage/defrag
113echo madvise >/sys/kernel/mm/transparent_hugepage/defrag 114echo madvise >/sys/kernel/mm/transparent_hugepage/defrag
114echo never >/sys/kernel/mm/transparent_hugepage/defrag 115echo never >/sys/kernel/mm/transparent_hugepage/defrag
115 116
@@ -120,10 +121,15 @@ that benefit heavily from THP use and are willing to delay the VM start
120to utilise them. 121to utilise them.
121 122
122"defer" means that an application will wake kswapd in the background 123"defer" means that an application will wake kswapd in the background
123to reclaim pages and wake kcompact to compact memory so that THP is 124to reclaim pages and wake kcompactd to compact memory so that THP is
124available in the near future. It's the responsibility of khugepaged 125available in the near future. It's the responsibility of khugepaged
125to then install the THP pages later. 126to then install the THP pages later.
126 127
128"defer+madvise" will enter direct reclaim and compaction like "always", but
129only for regions that have used madvise(MADV_HUGEPAGE); all other regions
130will wake kswapd in the background to reclaim pages and wake kcompactd to
131compact memory so that THP is available in the near future.
132
127"madvise" will enter direct reclaim like "always" but only for regions 133"madvise" will enter direct reclaim like "always" but only for regions
128that are have used madvise(MADV_HUGEPAGE). This is the default behaviour. 134that are have used madvise(MADV_HUGEPAGE). This is the default behaviour.
129 135
@@ -296,7 +302,7 @@ thp_split_page is incremented every time a huge page is split into base
296 reason is that a huge page is old and is being reclaimed. 302 reason is that a huge page is old and is being reclaimed.
297 This action implies splitting all PMD the page mapped with. 303 This action implies splitting all PMD the page mapped with.
298 304
299thp_split_page_failed is is incremented if kernel fails to split huge 305thp_split_page_failed is incremented if kernel fails to split huge
300 page. This can happen if the page was pinned by somebody. 306 page. This can happen if the page was pinned by somebody.
301 307
302thp_deferred_split_page is incremented when a huge page is put onto split 308thp_deferred_split_page is incremented when a huge page is put onto split
diff --git a/Documentation/vm/userfaultfd.txt b/Documentation/vm/userfaultfd.txt
index 70a3c94d1941..bb2f945f87ab 100644
--- a/Documentation/vm/userfaultfd.txt
+++ b/Documentation/vm/userfaultfd.txt
@@ -54,6 +54,26 @@ uffdio_api.features and uffdio_api.ioctls two 64bit bitmasks of
54respectively all the available features of the read(2) protocol and 54respectively all the available features of the read(2) protocol and
55the generic ioctl available. 55the generic ioctl available.
56 56
57The uffdio_api.features bitmask returned by the UFFDIO_API ioctl
58defines what memory types are supported by the userfaultfd and what
59events, except page fault notifications, may be generated.
60
61If the kernel supports registering userfaultfd ranges on hugetlbfs
62virtual memory areas, UFFD_FEATURE_MISSING_HUGETLBFS will be set in
63uffdio_api.features. Similarly, UFFD_FEATURE_MISSING_SHMEM will be
64set if the kernel supports registering userfaultfd ranges on shared
65memory (covering all shmem APIs, i.e. tmpfs, IPCSHM, /dev/zero
66MAP_SHARED, memfd_create, etc).
67
68The userland application that wants to use userfaultfd with hugetlbfs
69or shared memory need to set the corresponding flag in
70uffdio_api.features to enable those features.
71
72If the userland desires to receive notifications for events other than
73page faults, it has to verify that uffdio_api.features has appropriate
74UFFD_FEATURE_EVENT_* bits set. These events are described in more
75detail below in "Non-cooperative userfaultfd" section.
76
57Once the userfaultfd has been enabled the UFFDIO_REGISTER ioctl should 77Once the userfaultfd has been enabled the UFFDIO_REGISTER ioctl should
58be invoked (if present in the returned uffdio_api.ioctls bitmask) to 78be invoked (if present in the returned uffdio_api.ioctls bitmask) to
59register a memory range in the userfaultfd by setting the 79register a memory range in the userfaultfd by setting the
@@ -129,7 +149,7 @@ migration thread in the QEMU running in the destination node will
129receive the page that triggered the userfault and it'll map it as 149receive the page that triggered the userfault and it'll map it as
130usual with the UFFDIO_COPY|ZEROPAGE (without actually knowing if it 150usual with the UFFDIO_COPY|ZEROPAGE (without actually knowing if it
131was spontaneously sent by the source or if it was an urgent page 151was spontaneously sent by the source or if it was an urgent page
132requested through an userfault). 152requested through a userfault).
133 153
134By the time the userfaults start, the QEMU in the destination node 154By the time the userfaults start, the QEMU in the destination node
135doesn't need to keep any per-page state bitmap relative to the live 155doesn't need to keep any per-page state bitmap relative to the live
@@ -142,3 +162,68 @@ course the bitmap is updated accordingly. It's also useful to avoid
142sending the same page twice (in case the userfault is read by the 162sending the same page twice (in case the userfault is read by the
143postcopy thread just before UFFDIO_COPY|ZEROPAGE runs in the migration 163postcopy thread just before UFFDIO_COPY|ZEROPAGE runs in the migration
144thread). 164thread).
165
166== Non-cooperative userfaultfd ==
167
168When the userfaultfd is monitored by an external manager, the manager
169must be able to track changes in the process virtual memory
170layout. Userfaultfd can notify the manager about such changes using
171the same read(2) protocol as for the page fault notifications. The
172manager has to explicitly enable these events by setting appropriate
173bits in uffdio_api.features passed to UFFDIO_API ioctl:
174
175UFFD_FEATURE_EVENT_FORK - enable userfaultfd hooks for fork(). When
176this feature is enabled, the userfaultfd context of the parent process
177is duplicated into the newly created process. The manager receives
178UFFD_EVENT_FORK with file descriptor of the new userfaultfd context in
179the uffd_msg.fork.
180
181UFFD_FEATURE_EVENT_REMAP - enable notifications about mremap()
182calls. When the non-cooperative process moves a virtual memory area to
183a different location, the manager will receive UFFD_EVENT_REMAP. The
184uffd_msg.remap will contain the old and new addresses of the area and
185its original length.
186
187UFFD_FEATURE_EVENT_REMOVE - enable notifications about
188madvise(MADV_REMOVE) and madvise(MADV_DONTNEED) calls. The event
189UFFD_EVENT_REMOVE will be generated upon these calls to madvise. The
190uffd_msg.remove will contain start and end addresses of the removed
191area.
192
193UFFD_FEATURE_EVENT_UNMAP - enable notifications about memory
194unmapping. The manager will get UFFD_EVENT_UNMAP with uffd_msg.remove
195containing start and end addresses of the unmapped area.
196
197Although the UFFD_FEATURE_EVENT_REMOVE and UFFD_FEATURE_EVENT_UNMAP
198are pretty similar, they quite differ in the action expected from the
199userfaultfd manager. In the former case, the virtual memory is
200removed, but the area is not, the area remains monitored by the
201userfaultfd, and if a page fault occurs in that area it will be
202delivered to the manager. The proper resolution for such page fault is
203to zeromap the faulting address. However, in the latter case, when an
204area is unmapped, either explicitly (with munmap() system call), or
205implicitly (e.g. during mremap()), the area is removed and in turn the
206userfaultfd context for such area disappears too and the manager will
207not get further userland page faults from the removed area. Still, the
208notification is required in order to prevent manager from using
209UFFDIO_COPY on the unmapped area.
210
211Unlike userland page faults which have to be synchronous and require
212explicit or implicit wakeup, all the events are delivered
213asynchronously and the non-cooperative process resumes execution as
214soon as manager executes read(). The userfaultfd manager should
215carefully synchronize calls to UFFDIO_COPY with the events
216processing. To aid the synchronization, the UFFDIO_COPY ioctl will
217return -ENOSPC when the monitored process exits at the time of
218UFFDIO_COPY, and -ENOENT, when the non-cooperative process has changed
219its virtual memory layout simultaneously with outstanding UFFDIO_COPY
220operation.
221
222The current asynchronous model of the event delivery is optimal for
223single threaded non-cooperative userfaultfd manager implementations. A
224synchronous event delivery model can be added later as a new
225userfaultfd feature to facilitate multithreading enhancements of the
226non cooperative manager, for example to allow UFFDIO_COPY ioctls to
227run in parallel to the event reception. Single threaded
228implementations should continue to use the current async event
229delivery model instead.
diff --git a/Documentation/watchdog/watchdog-kernel-api.txt b/Documentation/watchdog/watchdog-kernel-api.txt
index ea277478982f..9b93953f69cf 100644
--- a/Documentation/watchdog/watchdog-kernel-api.txt
+++ b/Documentation/watchdog/watchdog-kernel-api.txt
@@ -280,6 +280,12 @@ To disable the watchdog on reboot, the user must call the following helper:
280 280
281static inline void watchdog_stop_on_reboot(struct watchdog_device *wdd); 281static inline void watchdog_stop_on_reboot(struct watchdog_device *wdd);
282 282
283To disable the watchdog when unregistering the watchdog, the user must call
284the following helper. Note that this will only stop the watchdog if the
285nowayout flag is not set.
286
287static inline void watchdog_stop_on_unregister(struct watchdog_device *wdd);
288
283To change the priority of the restart handler the following helper should be 289To change the priority of the restart handler the following helper should be
284used: 290used:
285 291
diff --git a/Documentation/watchdog/watchdog-parameters.txt b/Documentation/watchdog/watchdog-parameters.txt
index e21850e270a0..4f7d86dd0a5d 100644
--- a/Documentation/watchdog/watchdog-parameters.txt
+++ b/Documentation/watchdog/watchdog-parameters.txt
@@ -209,6 +209,11 @@ timeout: Initial watchdog timeout in seconds (0<timeout<516, default=60)
209nowayout: Watchdog cannot be stopped once started 209nowayout: Watchdog cannot be stopped once started
210 (default=kernel config parameter) 210 (default=kernel config parameter)
211------------------------------------------------- 211-------------------------------------------------
212nic7018_wdt:
213timeout: Initial watchdog timeout in seconds (0<timeout<464, default=80)
214nowayout: Watchdog cannot be stopped once started
215 (default=kernel config parameter)
216-------------------------------------------------
212nuc900_wdt: 217nuc900_wdt:
213heartbeat: Watchdog heartbeats in seconds. 218heartbeat: Watchdog heartbeats in seconds.
214 (default = 15) 219 (default = 15)
diff --git a/Documentation/x86/intel_rdt_ui.txt b/Documentation/x86/intel_rdt_ui.txt
index d918d268cd72..51cf6fa5591f 100644
--- a/Documentation/x86/intel_rdt_ui.txt
+++ b/Documentation/x86/intel_rdt_ui.txt
@@ -212,3 +212,117 @@ Finally we move core 4-7 over to the new group and make sure that the
212kernel and the tasks running there get 50% of the cache. 212kernel and the tasks running there get 50% of the cache.
213 213
214# echo C0 > p0/cpus 214# echo C0 > p0/cpus
215
2164) Locking between applications
217
218Certain operations on the resctrl filesystem, composed of read/writes
219to/from multiple files, must be atomic.
220
221As an example, the allocation of an exclusive reservation of L3 cache
222involves:
223
224 1. Read the cbmmasks from each directory
225 2. Find a contiguous set of bits in the global CBM bitmask that is clear
226 in any of the directory cbmmasks
227 3. Create a new directory
228 4. Set the bits found in step 2 to the new directory "schemata" file
229
230If two applications attempt to allocate space concurrently then they can
231end up allocating the same bits so the reservations are shared instead of
232exclusive.
233
234To coordinate atomic operations on the resctrlfs and to avoid the problem
235above, the following locking procedure is recommended:
236
237Locking is based on flock, which is available in libc and also as a shell
238script command
239
240Write lock:
241
242 A) Take flock(LOCK_EX) on /sys/fs/resctrl
243 B) Read/write the directory structure.
244 C) funlock
245
246Read lock:
247
248 A) Take flock(LOCK_SH) on /sys/fs/resctrl
249 B) If success read the directory structure.
250 C) funlock
251
252Example with bash:
253
254# Atomically read directory structure
255$ flock -s /sys/fs/resctrl/ find /sys/fs/resctrl
256
257# Read directory contents and create new subdirectory
258
259$ cat create-dir.sh
260find /sys/fs/resctrl/ > output.txt
261mask = function-of(output.txt)
262mkdir /sys/fs/resctrl/newres/
263echo mask > /sys/fs/resctrl/newres/schemata
264
265$ flock /sys/fs/resctrl/ ./create-dir.sh
266
267Example with C:
268
269/*
270 * Example code do take advisory locks
271 * before accessing resctrl filesystem
272 */
273#include <sys/file.h>
274#include <stdlib.h>
275
276void resctrl_take_shared_lock(int fd)
277{
278 int ret;
279
280 /* take shared lock on resctrl filesystem */
281 ret = flock(fd, LOCK_SH);
282 if (ret) {
283 perror("flock");
284 exit(-1);
285 }
286}
287
288void resctrl_take_exclusive_lock(int fd)
289{
290 int ret;
291
292 /* release lock on resctrl filesystem */
293 ret = flock(fd, LOCK_EX);
294 if (ret) {
295 perror("flock");
296 exit(-1);
297 }
298}
299
300void resctrl_release_lock(int fd)
301{
302 int ret;
303
304 /* take shared lock on resctrl filesystem */
305 ret = flock(fd, LOCK_UN);
306 if (ret) {
307 perror("flock");
308 exit(-1);
309 }
310}
311
312void main(void)
313{
314 int fd, ret;
315
316 fd = open("/sys/fs/resctrl", O_DIRECTORY);
317 if (fd == -1) {
318 perror("open");
319 exit(-1);
320 }
321 resctrl_take_shared_lock(fd);
322 /* code to read directory contents */
323 resctrl_release_lock(fd);
324
325 resctrl_take_exclusive_lock(fd);
326 /* code to read and write directory contents */
327 resctrl_release_lock(fd);
328}