Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'devicetree-for-3.20' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux

Pull DeviceTree changes from Rob Herring:

- DT unittests for I2C probing and overlays from Pantelis Antoniou

- Remove DT unittest dependency on OF_DYNAMIC from Gaurav Minocha

- Add Tegra compatible strings missing for newer parts from Paul
Walmsley

- Various vendor prefix additions

* tag 'devicetree-for-3.20' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux:
of: Add vendor prefix for OmniVision Technologies
of: Use ovti for Omnivision
of: Add vendor prefix for Truly Semiconductors Limited
of: Add vendor prefix for Himax Technologies Inc.
of/fdt: fix sparse warning
of: unitest: Add I2C overlay unit tests.
Documentation: DT: document compatible string existence requirement
Documentation: DT bindings: add nvidia, tegra132-denver compatible string
Documentation: DT bindings: add more Tegra chip compatible strings
of: EXPORT_SYMBOL_GPL of_property_read_u64_array
of: Fix brace position for struct of_device_id definition
of/unittest: Remove obsolete code
dt-bindings: use isil prefix for Intersil in vendor-prefixes.txt
Add AD Holdings Plc. to vendor-prefixes.
dt-bindings: Add Silicon Mitus vendor prefix
Removes OF_UNITTEST dependency on OF_DYNAMIC config symbol
pinctrl: fix up device tree bindings
DT: Vendors: Add Everspin
doc: add bindings document for altera fpga manager
drivers: of: Export of_reserved_mem_device_{init,release}

+766 -172
+1
Documentation/devicetree/bindings/arm/cpus.txt
··· 175 175 "marvell,pj4a" 176 176 "marvell,pj4b" 177 177 "marvell,sheeva-v5" 178 + "nvidia,tegra132-denver" 178 179 "qcom,krait" 179 180 "qcom,scorpion" 180 181 - enable-method
+4 -1
Documentation/devicetree/bindings/arm/tegra/nvidia,tegra20-ahb.txt
··· 1 1 NVIDIA Tegra AHB 2 2 3 3 Required properties: 4 - - compatible : "nvidia,tegra20-ahb" or "nvidia,tegra30-ahb" 4 + - compatible : For Tegra20, must contain "nvidia,tegra20-ahb". For 5 + Tegra30, must contain "nvidia,tegra30-ahb". Otherwise, must contain 6 + '"nvidia,<chip>-ahb", "nvidia,tegra30-ahb"' where <chip> is tegra124, 7 + tegra132, or tegra210. 5 8 - reg : Should contain 1 register ranges(address and length) 6 9 7 10 Example:
+5 -1
Documentation/devicetree/bindings/arm/tegra/nvidia,tegra20-pmc.txt
··· 6 6 7 7 Required properties: 8 8 - name : Should be pmc 9 - - compatible : Should contain "nvidia,tegra<chip>-pmc". 9 + - compatible : For Tegra20, must contain "nvidia,tegra20-pmc". For Tegra30, 10 + must contain "nvidia,tegra30-pmc". For Tegra114, must contain 11 + "nvidia,tegra114-pmc". For Tegra124, must contain "nvidia,tegra124-pmc". 12 + Otherwise, must contain "nvidia,<chip>-pmc", plus at least one of the 13 + above, where <chip> is tegra132. 10 14 - reg : Offset and length of the register set for the device 11 15 - clocks : Must contain an entry for each entry in clock-names. 12 16 See ../clocks/clock-bindings.txt for details.
+3 -1
Documentation/devicetree/bindings/ata/tegra-sata.txt
··· 1 1 Tegra124 SoC SATA AHCI controller 2 2 3 3 Required properties : 4 - - compatible : "nvidia,tegra124-ahci". 4 + - compatible : For Tegra124, must contain "nvidia,tegra124-ahci". Otherwise, 5 + must contain '"nvidia,<chip>-ahci", "nvidia,tegra124-ahci"', where <chip> 6 + is tegra132. 5 7 - reg : Should contain 2 entries: 6 8 - AHCI register set (SATA BAR5) 7 9 - SATA register set
+17
Documentation/devicetree/bindings/fpga/altera-socfpga-fpga-mgr.txt
··· 1 + Altera SOCFPGA FPGA Manager 2 + 3 + Required properties: 4 + - compatible : should contain "altr,socfpga-fpga-mgr" 5 + - reg : base address and size for memory mapped io. 6 + - The first index is for FPGA manager register access. 7 + - The second index is for writing FPGA configuration data. 8 + - interrupts : interrupt for the FPGA Manager device. 9 + 10 + Example: 11 + 12 + hps_0_fpgamgr: fpgamgr@0xff706000 { 13 + compatible = "altr,socfpga-fpga-mgr"; 14 + reg = <0xFF706000 0x1000 15 + 0xFFB90000 0x1000>; 16 + interrupts = <0 175 4>; 17 + };
+5 -5
Documentation/devicetree/bindings/fuse/nvidia,tegra20-fuse.txt
··· 1 1 NVIDIA Tegra20/Tegra30/Tegr114/Tegra124 fuse block. 2 2 3 3 Required properties: 4 - - compatible : should be: 5 - "nvidia,tegra20-efuse" 6 - "nvidia,tegra30-efuse" 7 - "nvidia,tegra114-efuse" 8 - "nvidia,tegra124-efuse" 4 + - compatible : For Tegra20, must contain "nvidia,tegra20-efuse". For Tegra30, 5 + must contain "nvidia,tegra30-efuse". For Tegra114, must contain 6 + "nvidia,tegra114-efuse". For Tegra124, must contain "nvidia,tegra124-efuse". 7 + Otherwise, must contain "nvidia,<chip>-efuse", plus one of the above, where 8 + <chip> is tegra132. 9 9 Details: 10 10 nvidia,tegra20-efuse: Tegra20 requires using APB DMA to read the fuse data 11 11 due to a hardware bug. Tegra20 also lacks certain information which is
+6 -2
Documentation/devicetree/bindings/gpu/nvidia,tegra20-host1x.txt
··· 197 197 - sor: serial output resource 198 198 199 199 Required properties: 200 - - compatible: "nvidia,tegra124-sor" 200 + - compatible: For Tegra124, must contain "nvidia,tegra124-sor". Otherwise, 201 + must contain '"nvidia,<chip>-sor", "nvidia,tegra124-sor"', where <chip> 202 + is tegra132. 201 203 - reg: Physical base address and length of the controller's registers. 202 204 - interrupts: The interrupt outputs from the controller. 203 205 - clocks: Must contain an entry for each entry in clock-names. ··· 224 222 - nvidia,dpaux: phandle to a DispayPort AUX interface 225 223 226 224 - dpaux: DisplayPort AUX interface 227 - - compatible: "nvidia,tegra124-dpaux" 225 + - compatible: For Tegra124, must contain "nvidia,tegra124-dpaux". Otherwise, 226 + must contain '"nvidia,<chip>-dpaux", "nvidia,tegra124-dpaux"', where 227 + <chip> is tegra132. 228 228 - reg: Physical base address and length of the controller's registers. 229 229 - interrupts: The interrupt outputs from the controller. 230 230 - clocks: Must contain an entry for each entry in clock-names.
+5 -5
Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.txt
··· 1 1 NVIDIA Tegra20/Tegra30/Tegra114 I2C controller driver. 2 2 3 3 Required properties: 4 - - compatible : should be: 5 - "nvidia,tegra114-i2c" 6 - "nvidia,tegra30-i2c" 7 - "nvidia,tegra20-i2c" 8 - "nvidia,tegra20-i2c-dvc" 4 + - compatible : For Tegra20, must be one of "nvidia,tegra20-i2c-dvc" or 5 + "nvidia,tegra20-i2c". For Tegra30, must be "nvidia,tegra30-i2c". 6 + For Tegra114, must be "nvidia,tegra114-i2c". Otherwise, must be 7 + "nvidia,<chip>-i2c", plus at least one of the above, where <chip> is 8 + tegra124, tegra132, or tegra210. 9 9 Details of compatible are as follows: 10 10 nvidia,tegra20-i2c-dvc: Tegra20 has specific I2C controller called as DVC I2C 11 11 controller. This only support master mode of I2C communication. Register
+1 -1
Documentation/devicetree/bindings/media/atmel-isi.txt
··· 38 38 39 39 i2c1: i2c@f0018000 { 40 40 ov2640: camera@0x30 { 41 - compatible = "omnivision,ov2640"; 41 + compatible = "ovti,ov2640"; 42 42 reg = <0x30>; 43 43 44 44 port {
+1 -1
Documentation/devicetree/bindings/media/video-interfaces.txt
··· 162 162 i2c0: i2c@0xfff20000 { 163 163 ... 164 164 ov772x_1: camera@0x21 { 165 - compatible = "omnivision,ov772x"; 165 + compatible = "ovti,ov772x"; 166 166 reg = <0x21>; 167 167 vddio-supply = <&regulator1>; 168 168 vddcore-supply = <&regulator2>;
+4 -5
Documentation/devicetree/bindings/misc/nvidia,tegra20-apbmisc.txt
··· 1 1 NVIDIA Tegra20/Tegra30/Tegr114/Tegra124 apbmisc block 2 2 3 3 Required properties: 4 - - compatible : should be: 5 - "nvidia,tegra20-apbmisc" 6 - "nvidia,tegra30-apbmisc" 7 - "nvidia,tegra114-apbmisc" 8 - "nvidia,tegra124-apbmisc" 4 + - compatible : For Tegra20, must be "nvidia,tegra20-apbmisc". For Tegra30, 5 + must be "nvidia,tegra30-apbmisc". Otherwise, must contain 6 + "nvidia,<chip>-apbmisc", plus one of the above, where <chip> is tegra114, 7 + tegra124, tegra132. 9 8 - reg: Should contain 2 entries: the first entry gives the physical address 10 9 and length of the registers which contain revision and debug features. 11 10 The second entry gives the physical address and length of the
+5 -1
Documentation/devicetree/bindings/mmc/nvidia,tegra20-sdhci.txt
··· 7 7 by mmc.txt and the properties used by the sdhci-tegra driver. 8 8 9 9 Required properties: 10 - - compatible : Should be "nvidia,<chip>-sdhci" 10 + - compatible : For Tegra20, must contain "nvidia,tegra20-sdhci". 11 + For Tegra30, must contain "nvidia,tegra30-sdhci". For Tegra114, 12 + must contain "nvidia,tegra114-sdhci". For Tegra124, must contain 13 + "nvidia,tegra124-sdhci". Otherwise, must contain "nvidia,<chip>-sdhci", 14 + plus one of the above, where <chip> is tegra132 or tegra210. 11 15 - clocks : Must contain one entry, for the module clock. 12 16 See ../clocks/clock-bindings.txt for details. 13 17 - resets : Must contain an entry for each entry in reset-names.
+4 -4
Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt
··· 1 1 NVIDIA Tegra PCIe controller 2 2 3 3 Required properties: 4 - - compatible: Must be one of: 5 - - "nvidia,tegra20-pcie" 6 - - "nvidia,tegra30-pcie" 7 - - "nvidia,tegra124-pcie" 4 + - compatible: For Tegra20, must contain "nvidia,tegra20-pcie". For Tegra30, 5 + "nvidia,tegra30-pcie". For Tegra124, must contain "nvidia,tegra124-pcie". 6 + Otherwise, must contain "nvidia,<chip>-pcie", plus one of the above, where 7 + <chip> is tegra132 or tegra210. 8 8 - device_type: Must be "pci" 9 9 - reg: A list of physical base address and length for each set of controller 10 10 registers. Must contain an entry for each entry in the reg-names property.
+2 -1
Documentation/devicetree/bindings/pinctrl/nvidia,tegra124-pinmux.txt
··· 6 6 a baseline, and only documents the differences between the two bindings. 7 7 8 8 Required properties: 9 - - compatible: "nvidia,tegra124-pinmux" 9 + - compatible: For Tegra124, must contain "nvidia,tegra124-pinmux". For 10 + Tegra132, must contain '"nvidia,tegra132-pinmux", "nvidia-tegra124-pinmux"'. 10 11 - reg: Should contain a list of base address and size pairs for: 11 12 -- first entry - the drive strength and pad control registers. 12 13 -- second entry - the pinmux registers
+3 -1
Documentation/devicetree/bindings/pinctrl/nvidia,tegra124-xusb-padctl.txt
··· 13 13 14 14 Required properties: 15 15 -------------------- 16 - - compatible: should be "nvidia,tegra124-xusb-padctl" 16 + - compatible: For Tegra124, must contain "nvidia,tegra124-xusb-padctl". 17 + Otherwise, must contain '"nvidia,<chip>-xusb-padctl", 18 + "nvidia-tegra124-xusb-padctl"', where <chip> is tegra132 or tegra210. 17 19 - reg: Physical base address and length of the controller's registers. 18 20 - resets: Must contain an entry for each entry in reset-names. 19 21 See ../reset/reset.txt for details.
+4 -3
Documentation/devicetree/bindings/pwm/nvidia,tegra20-pwm.txt
··· 1 1 Tegra SoC PWFM controller 2 2 3 3 Required properties: 4 - - compatible: should be one of: 5 - - "nvidia,tegra20-pwm" 6 - - "nvidia,tegra30-pwm" 4 + - compatible: For Tegra20, must contain "nvidia,tegra20-pwm". For Tegra30, 5 + must contain "nvidia,tegra30-pwm". Otherwise, must contain 6 + "nvidia,<chip>-pwm", plus one of the above, where <chip> is tegra114, 7 + tegra124, tegra132, or tegra210. 7 8 - reg: physical base address and length of the controller's registers 8 9 - #pwm-cells: should be 2. See pwm.txt in this directory for a description of 9 10 the cells format.
+3 -1
Documentation/devicetree/bindings/rtc/nvidia,tegra20-rtc.txt
··· 6 6 7 7 Required properties: 8 8 9 - - compatible : should be "nvidia,tegra20-rtc". 9 + - compatible : For Tegra20, must contain "nvidia,tegra20-rtc". Otherwise, 10 + must contain '"nvidia,<chip>-rtc", "nvidia,tegra20-rtc"', where <chip> 11 + can be tegra30, tegra114, tegra124, or tegra132. 10 12 - reg : Specifies base physical address and size of the registers. 11 13 - interrupts : A single interrupt specifier. 12 14 - clocks : Must contain one entry, for the module clock.
+4 -1
Documentation/devicetree/bindings/serial/of-serial.txt
··· 8 8 - "ns16550" 9 9 - "ns16750" 10 10 - "ns16850" 11 - - "nvidia,tegra20-uart" 11 + - For Tegra20, must contain "nvidia,tegra20-uart" 12 + - For other Tegra, must contain '"nvidia,<chip>-uart", 13 + "nvidia,tegra20-uart"' where <chip> is tegra30, tegra114, tegra124, 14 + tegra132, or tegra210. 12 15 - "nxp,lpc3220-uart" 13 16 - "ralink,rt2880-uart" 14 17 - "ibm,qpace-nwp-serial"
+4 -1
Documentation/devicetree/bindings/sound/nvidia,tegra30-ahub.txt
··· 1 1 NVIDIA Tegra30 AHUB (Audio Hub) 2 2 3 3 Required properties: 4 - - compatible : "nvidia,tegra30-ahub", "nvidia,tegra114-ahub", etc. 4 + - compatible : For Tegra30, must contain "nvidia,tegra30-ahub". For Tegra114, 5 + must contain "nvidia,tegra114-ahub". For Tegra124, must contain 6 + "nvidia,tegra124-ahub". Otherwise, must contain "nvidia,<chip>-ahub", 7 + plus at least one of the above, where <chip> is tegra132. 5 8 - reg : Should contain the register physical address and length for each of 6 9 the AHUB's register blocks. 7 10 - Tegra30 requires 2 entries, for the APBIF and AHUB/AUDIO register blocks.
+3 -1
Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.txt
··· 1 1 NVIDIA Tegra30 HDA controller 2 2 3 3 Required properties: 4 - - compatible : "nvidia,tegra30-hda" 4 + - compatible : For Tegra30, must contain "nvidia,tegra30-hda". Otherwise, 5 + must contain '"nvidia,<chip>-hda", "nvidia,tegra30-hda"', where <chip> is 6 + tegra114, tegra124, or tegra132. 5 7 - reg : Should contain the HDA registers location and length. 6 8 - interrupts : The interrupt from the HDA controller. 7 9 - clocks : Must contain an entry for each required entry in clock-names.
+4 -1
Documentation/devicetree/bindings/sound/nvidia,tegra30-i2s.txt
··· 1 1 NVIDIA Tegra30 I2S controller 2 2 3 3 Required properties: 4 - - compatible : "nvidia,tegra30-i2s" 4 + - compatible : For Tegra30, must contain "nvidia,tegra30-i2s". For Tegra124, 5 + must contain "nvidia,tegra124-i2s". Otherwise, must contain 6 + "nvidia,<chip>-i2s" plus at least one of the above, where <chip> is 7 + tegra114 or tegra132. 5 8 - reg : Should contain I2S registers location and length 6 9 - clocks : Must contain one entry, for the module clock. 7 10 See ../clocks/clock-bindings.txt for details.
+3 -1
Documentation/devicetree/bindings/spi/nvidia,tegra114-spi.txt
··· 1 1 NVIDIA Tegra114 SPI controller. 2 2 3 3 Required properties: 4 - - compatible : should be "nvidia,tegra114-spi". 4 + - compatible : For Tegra114, must contain "nvidia,tegra114-spi". 5 + Otherwise, must contain '"nvidia,<chip>-spi", "nvidia,tegra114-spi"' where 6 + <chip> is tegra124, tegra132, or tegra210. 5 7 - reg: Should contain SPI registers location and length. 6 8 - interrupts: Should contain SPI interrupts. 7 9 - clock-names : Must include the following entries:
+23
Documentation/devicetree/bindings/submitting-patches.txt
··· 15 15 3) The Documentation/ portion of the patch should come in the series before 16 16 the code implementing the binding. 17 17 18 + 4) Any compatible strings used in a chip or board DTS file must be 19 + previously documented in the corresponding DT binding text file 20 + in Documentation/devicetree/bindings. This rule applies even if 21 + the Linux device driver does not yet match on the compatible 22 + string. [ checkpatch will emit warnings if this step is not 23 + followed as of commit bff5da4335256513497cc8c79f9a9d1665e09864 24 + ("checkpatch: add DT compatible string documentation checks"). ] 25 + 26 + 5) The wildcard "<chip>" may be used in compatible strings, as in 27 + the following example: 28 + 29 + - compatible: Must contain '"nvidia,<chip>-pcie", 30 + "nvidia,tegra20-pcie"' where <chip> is tegra30, tegra132, ... 31 + 32 + As in the above example, the known values of "<chip>" should be 33 + documented if it is used. 34 + 35 + 6) If a documented compatible string is not yet matched by the 36 + driver, the documentation should also include a compatible 37 + string that is matched by the driver (as in the "nvidia,tegra20-pcie" 38 + example above). 39 + 40 + 18 41 II. For kernel maintainers 19 42 20 43 1) If you aren't comfortable reviewing a given binding, reply to it and ask
+3 -1
Documentation/devicetree/bindings/thermal/tegra-soctherm.txt
··· 7 7 overheating situation. 8 8 9 9 Required properties : 10 - - compatible : "nvidia,tegra124-soctherm". 10 + - compatible : For Tegra124, must contain "nvidia,tegra124-soctherm". 11 + For Tegra132, must contain "nvidia,tegra132-soctherm". 12 + For Tegra210, must contain "nvidia,tegra210-soctherm". 11 13 - reg : Should contain 1 entry: 12 14 - SOCTHERM register set 13 15 - interrupts : Defines the interrupt used by SOCTHERM
+3 -1
Documentation/devicetree/bindings/timer/nvidia,tegra30-timer.txt
··· 6 6 7 7 Required properties: 8 8 9 - - compatible : should be "nvidia,tegra30-timer", "nvidia,tegra20-timer". 9 + - compatible : For Tegra30, must contain "nvidia,tegra30-timer". Otherwise, 10 + must contain '"nvidia,<chip>-timer", "nvidia,tegra30-timer"' where 11 + <chip> is tegra124 or tegra132. 10 12 - reg : Specifies base physical address and size of the registers. 11 13 - interrupts : A list of 6 interrupts; one per each of timer channels 1 12 14 through 5, and one for the shared interrupt for the remaining channels.
+58 -1
Documentation/devicetree/bindings/unittest.txt
··· 1 - * OF selftest platform device 1 + 1) OF selftest platform device 2 2 3 3 ** selftest 4 4 ··· 11 11 selftest { 12 12 compatible = "selftest"; 13 13 status = "okay"; 14 + }; 15 + 16 + 2) OF selftest i2c adapter platform device 17 + 18 + ** platform device unittest adapter 19 + 20 + Required properties: 21 + - compatible: must be selftest-i2c-bus 22 + 23 + Children nodes contain selftest i2c devices. 24 + 25 + Example: 26 + selftest-i2c-bus { 27 + compatible = "selftest-i2c-bus"; 28 + status = "okay"; 29 + }; 30 + 31 + 3) OF selftest i2c device 32 + 33 + ** I2C selftest device 34 + 35 + Required properties: 36 + - compatible: must be selftest-i2c-dev 37 + 38 + All other properties are optional 39 + 40 + Example: 41 + selftest-i2c-dev { 42 + compatible = "selftest-i2c-dev"; 43 + status = "okay"; 44 + }; 45 + 46 + 4) OF selftest i2c mux device 47 + 48 + ** I2C selftest mux 49 + 50 + Required properties: 51 + - compatible: must be selftest-i2c-mux 52 + 53 + Children nodes contain selftest i2c bus nodes per channel. 54 + 55 + Example: 56 + selftest-i2c-mux { 57 + compatible = "selftest-i2c-mux"; 58 + status = "okay"; 59 + #address-cells = <1>; 60 + #size-cells = <0>; 61 + channel-0 { 62 + reg = <0>; 63 + #address-cells = <1>; 64 + #size-cells = <0>; 65 + i2c-dev { 66 + reg = <8>; 67 + compatible = "selftest-i2c-dev"; 68 + status = "okay"; 69 + }; 70 + }; 14 71 };
+4 -1
Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
··· 6 6 and additions : 7 7 8 8 Required properties : 9 - - compatible : Should be "nvidia,tegra20-ehci". 9 + - compatible : For Tegra20, must contain "nvidia,tegra20-ehci". 10 + For Tegra30, must contain "nvidia,tegra30-ehci". Otherwise, must contain 11 + "nvidia,<chip>-ehci" plus at least one of the above, where <chip> is 12 + tegra114, tegra124, tegra132, or tegra210. 10 13 - nvidia,phy : phandle of the PHY that the controller is connected to. 11 14 - clocks : Must contain one entry, for the module clock. 12 15 See ../clocks/clock-bindings.txt for details.
+4 -1
Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt
··· 3 3 The device node for Tegra SOC USB PHY: 4 4 5 5 Required properties : 6 - - compatible : Should be "nvidia,tegra<chip>-usb-phy". 6 + - compatible : For Tegra20, must contain "nvidia,tegra20-usb-phy". 7 + For Tegra30, must contain "nvidia,tegra30-usb-phy". Otherwise, must contain 8 + "nvidia,<chip>-usb-phy" plus at least one of the above, where <chip> is 9 + tegra114, tegra124, tegra132, or tegra210. 7 10 - reg : Defines the following set of registers, in the order listed: 8 11 - The PHY's own register set. 9 12 Always present.
+7 -2
Documentation/devicetree/bindings/vendor-prefixes.txt
··· 7 7 active-semi Active-Semi International Inc 8 8 ad Avionic Design GmbH 9 9 adapteva Adapteva, Inc. 10 + adh AD Holdings Plc. 10 11 adi Analog Devices, Inc. 11 12 aeroflexgaisler Aeroflex Gaisler AB 12 13 allwinner Allwinner Technology Co., Ltd. ··· 58 57 ettus NI Ettus Research 59 58 eukrea Eukréa Electromatique 60 59 everest Everest Semiconductor Co. Ltd. 60 + everspin Everspin Technologies, Inc. 61 61 excito Excito 62 62 fcs Fairchild Semiconductor 63 63 fsl Freescale Semiconductor ··· 72 70 gw Gateworks Corporation 73 71 hannstar HannStar Display Corporation 74 72 haoyu Haoyu Microelectronic Co. Ltd. 73 + himax Himax Technologies, Inc. 75 74 hisilicon Hisilicon Limited. 76 75 hit Hitachi Ltd. 77 76 honeywell Honeywell ··· 86 83 intel Intel Corporation 87 84 intercontrol Inter Control Group 88 85 isee ISEE 2007 S.L. 89 - isil Intersil (deprecated, use isl) 90 - isl Intersil 86 + isil Intersil 91 87 karo Ka-Ro electronics GmbH 92 88 keymile Keymile GmbH 93 89 lacie LaCie ··· 121 119 nxp NXP Semiconductors 122 120 onnn ON Semiconductor Corp. 123 121 opencores OpenCores.org 122 + ovti OmniVision Technologies 124 123 panasonic Panasonic Corporation 125 124 pericom Pericom Technology Inc. 126 125 phytec PHYTEC Messtechnik GmbH ··· 149 146 semtech Semtech Corporation 150 147 sil Silicon Image 151 148 silabs Silicon Laboratories 149 + siliconmitus Silicon Mitus, Inc. 152 150 simtek 153 151 sii Seiko Instruments, Inc. 154 152 silergy Silergy Corp. ··· 171 167 toradex Toradex AG 172 168 toshiba Toshiba Corporation 173 169 toumaz Toumaz 170 + truly Truly Semiconductors Limited 174 171 usi Universal Scientific Industrial Co., Ltd. 175 172 v3 V3 Semiconductor 176 173 variscite Variscite Ltd.
-1
drivers/of/Kconfig
··· 10 10 config OF_UNITTEST 11 11 bool "Device Tree runtime unit tests" 12 12 depends on OF_IRQ && OF_EARLY_FLATTREE 13 - select OF_DYNAMIC 14 13 select OF_RESOLVE 15 14 help 16 15 This option builds in test cases for the device tree infrastructure
+1
drivers/of/base.c
··· 1303 1303 } 1304 1304 return 0; 1305 1305 } 1306 + EXPORT_SYMBOL_GPL(of_property_read_u64_array); 1306 1307 1307 1308 /** 1308 1309 * of_property_read_string - Find and read a string from a property
+1 -1
drivers/of/fdt.c
··· 762 762 #ifdef CONFIG_SERIAL_EARLYCON 763 763 extern struct of_device_id __earlycon_of_table[]; 764 764 765 - int __init early_init_dt_scan_chosen_serial(void) 765 + static int __init early_init_dt_scan_chosen_serial(void) 766 766 { 767 767 int offset; 768 768 const char *p;
+2
drivers/of/of_reserved_mem.c
··· 265 265 266 266 return ret; 267 267 } 268 + EXPORT_SYMBOL_GPL(of_reserved_mem_device_init); 268 269 269 270 /** 270 271 * of_reserved_mem_device_release() - release reserved memory device structures ··· 290 289 291 290 rmem->ops->device_release(rmem, dev); 292 291 } 292 + EXPORT_SYMBOL_GPL(of_reserved_mem_device_release);
+94
drivers/of/unittest-data/tests-overlay.dtsi
··· 68 68 status = "disabled"; 69 69 reg = <8>; 70 70 }; 71 + 72 + i2c-test-bus { 73 + compatible = "selftest-i2c-bus"; 74 + status = "okay"; 75 + reg = <50>; 76 + 77 + #address-cells = <1>; 78 + #size-cells = <0>; 79 + 80 + test-selftest12 { 81 + reg = <8>; 82 + compatible = "selftest-i2c-dev"; 83 + status = "disabled"; 84 + }; 85 + 86 + test-selftest13 { 87 + reg = <9>; 88 + compatible = "selftest-i2c-dev"; 89 + status = "okay"; 90 + }; 91 + 92 + test-selftest14 { 93 + reg = <10>; 94 + compatible = "selftest-i2c-mux"; 95 + status = "okay"; 96 + 97 + #address-cells = <1>; 98 + #size-cells = <0>; 99 + 100 + i2c@0 { 101 + #address-cells = <1>; 102 + #size-cells = <0>; 103 + reg = <0>; 104 + 105 + test-mux-dev { 106 + reg = <32>; 107 + compatible = "selftest-i2c-dev"; 108 + status = "okay"; 109 + }; 110 + }; 111 + }; 112 + }; 71 113 }; 72 114 }; 73 115 ··· 273 231 }; 274 232 }; 275 233 }; 234 + 235 + /* test enable using absolute target path (i2c) */ 236 + overlay12 { 237 + fragment@0 { 238 + target-path = "/testcase-data/overlay-node/test-bus/i2c-test-bus/test-selftest12"; 239 + __overlay__ { 240 + status = "okay"; 241 + }; 242 + }; 243 + }; 244 + 245 + /* test disable using absolute target path (i2c) */ 246 + overlay13 { 247 + fragment@0 { 248 + target-path = "/testcase-data/overlay-node/test-bus/i2c-test-bus/test-selftest13"; 249 + __overlay__ { 250 + status = "disabled"; 251 + }; 252 + }; 253 + }; 254 + 255 + /* test mux overlay */ 256 + overlay15 { 257 + fragment@0 { 258 + target-path = "/testcase-data/overlay-node/test-bus/i2c-test-bus"; 259 + __overlay__ { 260 + #address-cells = <1>; 261 + #size-cells = <0>; 262 + test-selftest15 { 263 + reg = <11>; 264 + compatible = "selftest-i2c-mux"; 265 + status = "okay"; 266 + 267 + #address-cells = <1>; 268 + #size-cells = <0>; 269 + 270 + i2c@0 { 271 + #address-cells = <1>; 272 + #size-cells = <0>; 273 + reg = <0>; 274 + 275 + test-mux-dev { 276 + reg = <32>; 277 + compatible = "selftest-i2c-dev"; 278 + status = "okay"; 279 + }; 280 + }; 281 + }; 282 + }; 283 + }; 284 + }; 285 + 276 286 }; 277 287 };
+474 -123
drivers/of/unittest.c
··· 20 20 #include <linux/platform_device.h> 21 21 #include <linux/of_platform.h> 22 22 23 + #include <linux/i2c.h> 24 + #include <linux/i2c-mux.h> 25 + 23 26 #include "of_private.h" 24 27 25 28 static struct selftest_results { 26 29 int passed; 27 30 int failed; 28 31 } selftest_results; 29 - 30 - #define NO_OF_NODES 3 31 - static struct device_node *nodes[NO_OF_NODES]; 32 - static int last_node_index; 33 - static bool selftest_live_tree; 34 32 35 33 #define selftest(result, fmt, ...) ({ \ 36 34 bool failed = !(result); \ ··· 820 822 static int attach_node_and_children(struct device_node *np) 821 823 { 822 824 struct device_node *next, *dup, *child; 825 + unsigned long flags; 823 826 824 827 dup = of_find_node_by_path(np->full_name); 825 828 if (dup) { ··· 828 829 return 0; 829 830 } 830 831 831 - /* Children of the root need to be remembered for removal */ 832 - if (np->parent == of_root) { 833 - if (WARN_ON(last_node_index >= NO_OF_NODES)) 834 - return -EINVAL; 835 - nodes[last_node_index++] = np; 836 - } 837 - 838 832 child = np->child; 839 833 np->child = NULL; 840 - np->sibling = NULL; 841 - of_attach_node(np); 834 + 835 + mutex_lock(&of_mutex); 836 + raw_spin_lock_irqsave(&devtree_lock, flags); 837 + np->sibling = np->parent->child; 838 + np->parent->child = np; 839 + of_node_clear_flag(np, OF_DETACHED); 840 + raw_spin_unlock_irqrestore(&devtree_lock, flags); 841 + 842 + __of_attach_node_sysfs(np); 843 + mutex_unlock(&of_mutex); 844 + 842 845 while (child) { 843 846 next = child->sibling; 844 847 attach_node_and_children(child); ··· 890 889 } 891 890 892 891 if (!of_root) { 893 - /* enabling flag for removing nodes */ 894 - selftest_live_tree = true; 895 892 of_root = selftest_data_node; 896 - 897 893 for_each_of_allnodes(np) 898 894 __of_attach_node_sysfs(np); 899 895 of_aliases = of_find_node_by_path("/aliases"); ··· 907 909 np = next; 908 910 } 909 911 return 0; 910 - } 911 - 912 - /** 913 - * detach_node_and_children - detaches node 914 - * and its children from live tree 915 - * 916 - * @np: Node to detach from live tree 917 - */ 918 - static void detach_node_and_children(struct device_node *np) 919 - { 920 - while (np->child) 921 - detach_node_and_children(np->child); 922 - of_detach_node(np); 923 - } 924 - 925 - /** 926 - * selftest_data_remove - removes the selftest data 927 - * nodes from the live tree 928 - */ 929 - static void selftest_data_remove(void) 930 - { 931 - struct device_node *np; 932 - struct property *prop; 933 - 934 - if (selftest_live_tree) { 935 - of_node_put(of_aliases); 936 - of_node_put(of_chosen); 937 - of_aliases = NULL; 938 - of_chosen = NULL; 939 - for_each_child_of_node(of_root, np) 940 - detach_node_and_children(np); 941 - __of_detach_node_sysfs(of_root); 942 - of_root = NULL; 943 - return; 944 - } 945 - 946 - while (last_node_index-- > 0) { 947 - if (nodes[last_node_index]) { 948 - np = of_find_node_by_path(nodes[last_node_index]->full_name); 949 - if (np == nodes[last_node_index]) { 950 - if (of_aliases == np) { 951 - of_node_put(of_aliases); 952 - of_aliases = NULL; 953 - } 954 - detach_node_and_children(np); 955 - } else { 956 - for_each_property_of_node(np, prop) { 957 - if (strcmp(prop->name, "testcase-alias") == 0) 958 - of_remove_property(np, prop); 959 - } 960 - } 961 - } 962 - } 963 912 } 964 913 965 914 #ifdef CONFIG_OF_OVERLAY ··· 979 1034 return pdev != NULL; 980 1035 } 981 1036 982 - static const char *selftest_path(int nr) 1037 + #if IS_ENABLED(CONFIG_I2C) 1038 + 1039 + /* get the i2c client device instantiated at the path */ 1040 + static struct i2c_client *of_path_to_i2c_client(const char *path) 983 1041 { 1042 + struct device_node *np; 1043 + struct i2c_client *client; 1044 + 1045 + np = of_find_node_by_path(path); 1046 + if (np == NULL) 1047 + return NULL; 1048 + 1049 + client = of_find_i2c_device_by_node(np); 1050 + of_node_put(np); 1051 + 1052 + return client; 1053 + } 1054 + 1055 + /* find out if a i2c client device exists at that path */ 1056 + static int of_path_i2c_client_exists(const char *path) 1057 + { 1058 + struct i2c_client *client; 1059 + 1060 + client = of_path_to_i2c_client(path); 1061 + if (client) 1062 + put_device(&client->dev); 1063 + return client != NULL; 1064 + } 1065 + #else 1066 + static int of_path_i2c_client_exists(const char *path) 1067 + { 1068 + return 0; 1069 + } 1070 + #endif 1071 + 1072 + enum overlay_type { 1073 + PDEV_OVERLAY, 1074 + I2C_OVERLAY 1075 + }; 1076 + 1077 + static int of_path_device_type_exists(const char *path, 1078 + enum overlay_type ovtype) 1079 + { 1080 + switch (ovtype) { 1081 + case PDEV_OVERLAY: 1082 + return of_path_platform_device_exists(path); 1083 + case I2C_OVERLAY: 1084 + return of_path_i2c_client_exists(path); 1085 + } 1086 + return 0; 1087 + } 1088 + 1089 + static const char *selftest_path(int nr, enum overlay_type ovtype) 1090 + { 1091 + const char *base; 984 1092 static char buf[256]; 985 1093 986 - snprintf(buf, sizeof(buf) - 1, 987 - "/testcase-data/overlay-node/test-bus/test-selftest%d", nr); 1094 + switch (ovtype) { 1095 + case PDEV_OVERLAY: 1096 + base = "/testcase-data/overlay-node/test-bus"; 1097 + break; 1098 + case I2C_OVERLAY: 1099 + base = "/testcase-data/overlay-node/test-bus/i2c-test-bus"; 1100 + break; 1101 + default: 1102 + buf[0] = '\0'; 1103 + return buf; 1104 + } 1105 + snprintf(buf, sizeof(buf) - 1, "%s/test-selftest%d", base, nr); 988 1106 buf[sizeof(buf) - 1] = '\0'; 989 - 990 1107 return buf; 1108 + } 1109 + 1110 + static int of_selftest_device_exists(int selftest_nr, enum overlay_type ovtype) 1111 + { 1112 + const char *path; 1113 + 1114 + path = selftest_path(selftest_nr, ovtype); 1115 + 1116 + switch (ovtype) { 1117 + case PDEV_OVERLAY: 1118 + return of_path_platform_device_exists(path); 1119 + case I2C_OVERLAY: 1120 + return of_path_i2c_client_exists(path); 1121 + } 1122 + return 0; 991 1123 } 992 1124 993 1125 static const char *overlay_path(int nr) ··· 1115 1093 1116 1094 /* apply an overlay while checking before and after states */ 1117 1095 static int of_selftest_apply_overlay_check(int overlay_nr, int selftest_nr, 1118 - int before, int after) 1096 + int before, int after, enum overlay_type ovtype) 1119 1097 { 1120 1098 int ret; 1121 1099 1122 1100 /* selftest device must not be in before state */ 1123 - if (of_path_platform_device_exists(selftest_path(selftest_nr)) 1124 - != before) { 1101 + if (of_selftest_device_exists(selftest_nr, ovtype) != before) { 1125 1102 selftest(0, "overlay @\"%s\" with device @\"%s\" %s\n", 1126 1103 overlay_path(overlay_nr), 1127 - selftest_path(selftest_nr), 1104 + selftest_path(selftest_nr, ovtype), 1128 1105 !before ? "enabled" : "disabled"); 1129 1106 return -EINVAL; 1130 1107 } ··· 1135 1114 } 1136 1115 1137 1116 /* selftest device must be to set to after state */ 1138 - if (of_path_platform_device_exists(selftest_path(selftest_nr)) 1139 - != after) { 1117 + if (of_selftest_device_exists(selftest_nr, ovtype) != after) { 1140 1118 selftest(0, "overlay @\"%s\" failed to create @\"%s\" %s\n", 1141 1119 overlay_path(overlay_nr), 1142 - selftest_path(selftest_nr), 1120 + selftest_path(selftest_nr, ovtype), 1143 1121 !after ? "enabled" : "disabled"); 1144 1122 return -EINVAL; 1145 1123 } ··· 1148 1128 1149 1129 /* apply an overlay and then revert it while checking before, after states */ 1150 1130 static int of_selftest_apply_revert_overlay_check(int overlay_nr, 1151 - int selftest_nr, int before, int after) 1131 + int selftest_nr, int before, int after, 1132 + enum overlay_type ovtype) 1152 1133 { 1153 1134 int ret, ov_id; 1154 1135 1155 1136 /* selftest device must be in before state */ 1156 - if (of_path_platform_device_exists(selftest_path(selftest_nr)) 1157 - != before) { 1137 + if (of_selftest_device_exists(selftest_nr, ovtype) != before) { 1158 1138 selftest(0, "overlay @\"%s\" with device @\"%s\" %s\n", 1159 1139 overlay_path(overlay_nr), 1160 - selftest_path(selftest_nr), 1140 + selftest_path(selftest_nr, ovtype), 1161 1141 !before ? "enabled" : "disabled"); 1162 1142 return -EINVAL; 1163 1143 } ··· 1170 1150 } 1171 1151 1172 1152 /* selftest device must be in after state */ 1173 - if (of_path_platform_device_exists(selftest_path(selftest_nr)) 1174 - != after) { 1153 + if (of_selftest_device_exists(selftest_nr, ovtype) != after) { 1175 1154 selftest(0, "overlay @\"%s\" failed to create @\"%s\" %s\n", 1176 1155 overlay_path(overlay_nr), 1177 - selftest_path(selftest_nr), 1156 + selftest_path(selftest_nr, ovtype), 1178 1157 !after ? "enabled" : "disabled"); 1179 1158 return -EINVAL; 1180 1159 } ··· 1182 1163 if (ret != 0) { 1183 1164 selftest(0, "overlay @\"%s\" failed to be destroyed @\"%s\"\n", 1184 1165 overlay_path(overlay_nr), 1185 - selftest_path(selftest_nr)); 1166 + selftest_path(selftest_nr, ovtype)); 1186 1167 return ret; 1187 1168 } 1188 1169 1189 1170 /* selftest device must be again in before state */ 1190 - if (of_path_platform_device_exists(selftest_path(selftest_nr)) 1191 - != before) { 1171 + if (of_selftest_device_exists(selftest_nr, PDEV_OVERLAY) != before) { 1192 1172 selftest(0, "overlay @\"%s\" with device @\"%s\" %s\n", 1193 1173 overlay_path(overlay_nr), 1194 - selftest_path(selftest_nr), 1174 + selftest_path(selftest_nr, ovtype), 1195 1175 !before ? "enabled" : "disabled"); 1196 1176 return -EINVAL; 1197 1177 } ··· 1204 1186 int ret; 1205 1187 1206 1188 /* device should enable */ 1207 - ret = of_selftest_apply_overlay_check(0, 0, 0, 1); 1189 + ret = of_selftest_apply_overlay_check(0, 0, 0, 1, PDEV_OVERLAY); 1208 1190 if (ret != 0) 1209 1191 return; 1210 1192 ··· 1217 1199 int ret; 1218 1200 1219 1201 /* device should disable */ 1220 - ret = of_selftest_apply_overlay_check(1, 1, 1, 0); 1202 + ret = of_selftest_apply_overlay_check(1, 1, 1, 0, PDEV_OVERLAY); 1221 1203 if (ret != 0) 1222 1204 return; 1223 1205 ··· 1230 1212 int ret; 1231 1213 1232 1214 /* device should enable */ 1233 - ret = of_selftest_apply_overlay_check(2, 2, 0, 1); 1215 + ret = of_selftest_apply_overlay_check(2, 2, 0, 1, PDEV_OVERLAY); 1234 1216 if (ret != 0) 1235 1217 return; 1236 1218 ··· 1243 1225 int ret; 1244 1226 1245 1227 /* device should disable */ 1246 - ret = of_selftest_apply_overlay_check(3, 3, 1, 0); 1228 + ret = of_selftest_apply_overlay_check(3, 3, 1, 0, PDEV_OVERLAY); 1247 1229 if (ret != 0) 1248 1230 return; 1249 1231 ··· 1256 1238 int ret; 1257 1239 1258 1240 /* device should disable */ 1259 - ret = of_selftest_apply_overlay_check(4, 4, 0, 1); 1241 + ret = of_selftest_apply_overlay_check(4, 4, 0, 1, PDEV_OVERLAY); 1260 1242 if (ret != 0) 1261 1243 return; 1262 1244 ··· 1269 1251 int ret; 1270 1252 1271 1253 /* device should disable */ 1272 - ret = of_selftest_apply_revert_overlay_check(5, 5, 0, 1); 1254 + ret = of_selftest_apply_revert_overlay_check(5, 5, 0, 1, PDEV_OVERLAY); 1273 1255 if (ret != 0) 1274 1256 return; 1275 1257 ··· 1286 1268 1287 1269 /* selftest device must be in before state */ 1288 1270 for (i = 0; i < 2; i++) { 1289 - if (of_path_platform_device_exists( 1290 - selftest_path(selftest_nr + i)) 1271 + if (of_selftest_device_exists(selftest_nr + i, PDEV_OVERLAY) 1291 1272 != before) { 1292 1273 selftest(0, "overlay @\"%s\" with device @\"%s\" %s\n", 1293 1274 overlay_path(overlay_nr + i), 1294 - selftest_path(selftest_nr + i), 1275 + selftest_path(selftest_nr + i, 1276 + PDEV_OVERLAY), 1295 1277 !before ? "enabled" : "disabled"); 1296 1278 return; 1297 1279 } ··· 1318 1300 1319 1301 for (i = 0; i < 2; i++) { 1320 1302 /* selftest device must be in after state */ 1321 - if (of_path_platform_device_exists( 1322 - selftest_path(selftest_nr + i)) 1303 + if (of_selftest_device_exists(selftest_nr + i, PDEV_OVERLAY) 1323 1304 != after) { 1324 1305 selftest(0, "overlay @\"%s\" failed @\"%s\" %s\n", 1325 1306 overlay_path(overlay_nr + i), 1326 - selftest_path(selftest_nr + i), 1307 + selftest_path(selftest_nr + i, 1308 + PDEV_OVERLAY), 1327 1309 !after ? "enabled" : "disabled"); 1328 1310 return; 1329 1311 } ··· 1334 1316 if (ret != 0) { 1335 1317 selftest(0, "overlay @\"%s\" failed destroy @\"%s\"\n", 1336 1318 overlay_path(overlay_nr + i), 1337 - selftest_path(selftest_nr + i)); 1319 + selftest_path(selftest_nr + i, 1320 + PDEV_OVERLAY)); 1338 1321 return; 1339 1322 } 1340 1323 } 1341 1324 1342 1325 for (i = 0; i < 2; i++) { 1343 1326 /* selftest device must be again in before state */ 1344 - if (of_path_platform_device_exists( 1345 - selftest_path(selftest_nr + i)) 1327 + if (of_selftest_device_exists(selftest_nr + i, PDEV_OVERLAY) 1346 1328 != before) { 1347 1329 selftest(0, "overlay @\"%s\" with device @\"%s\" %s\n", 1348 1330 overlay_path(overlay_nr + i), 1349 - selftest_path(selftest_nr + i), 1331 + selftest_path(selftest_nr + i, 1332 + PDEV_OVERLAY), 1350 1333 !before ? "enabled" : "disabled"); 1351 1334 return; 1352 1335 } ··· 1389 1370 if (ret == 0) { 1390 1371 selftest(0, "overlay @\"%s\" was destroyed @\"%s\"\n", 1391 1372 overlay_path(overlay_nr + 0), 1392 - selftest_path(selftest_nr)); 1373 + selftest_path(selftest_nr, 1374 + PDEV_OVERLAY)); 1393 1375 return; 1394 1376 } 1395 1377 ··· 1400 1380 if (ret != 0) { 1401 1381 selftest(0, "overlay @\"%s\" not destroyed @\"%s\"\n", 1402 1382 overlay_path(overlay_nr + i), 1403 - selftest_path(selftest_nr)); 1383 + selftest_path(selftest_nr, 1384 + PDEV_OVERLAY)); 1404 1385 return; 1405 1386 } 1406 1387 } ··· 1416 1395 char *child_path; 1417 1396 1418 1397 /* device should disable */ 1419 - ret = of_selftest_apply_overlay_check(10, 10, 0, 1); 1420 - if (selftest(ret == 0, "overlay test %d failed; overlay application\n", 10)) 1398 + ret = of_selftest_apply_overlay_check(10, 10, 0, 1, PDEV_OVERLAY); 1399 + if (selftest(ret == 0, 1400 + "overlay test %d failed; overlay application\n", 10)) 1421 1401 return; 1422 1402 1423 1403 child_path = kasprintf(GFP_KERNEL, "%s/test-selftest101", 1424 - selftest_path(10)); 1404 + selftest_path(10, PDEV_OVERLAY)); 1425 1405 if (selftest(child_path, "overlay test %d failed; kasprintf\n", 10)) 1426 1406 return; 1427 1407 1428 - ret = of_path_platform_device_exists(child_path); 1408 + ret = of_path_device_type_exists(child_path, PDEV_OVERLAY); 1429 1409 kfree(child_path); 1430 1410 if (selftest(ret, "overlay test %d failed; no child device\n", 10)) 1431 1411 return; ··· 1438 1416 int ret; 1439 1417 1440 1418 /* device should disable */ 1441 - ret = of_selftest_apply_revert_overlay_check(11, 11, 0, 1); 1442 - if (selftest(ret == 0, "overlay test %d failed; overlay application\n", 11)) 1419 + ret = of_selftest_apply_revert_overlay_check(11, 11, 0, 1, 1420 + PDEV_OVERLAY); 1421 + if (selftest(ret == 0, 1422 + "overlay test %d failed; overlay application\n", 11)) 1443 1423 return; 1444 1424 } 1425 + 1426 + #if IS_ENABLED(CONFIG_I2C) && IS_ENABLED(CONFIG_OF_OVERLAY) 1427 + 1428 + struct selftest_i2c_bus_data { 1429 + struct platform_device *pdev; 1430 + struct i2c_adapter adap; 1431 + }; 1432 + 1433 + static int selftest_i2c_master_xfer(struct i2c_adapter *adap, 1434 + struct i2c_msg *msgs, int num) 1435 + { 1436 + struct selftest_i2c_bus_data *std = i2c_get_adapdata(adap); 1437 + 1438 + (void)std; 1439 + 1440 + return num; 1441 + } 1442 + 1443 + static u32 selftest_i2c_functionality(struct i2c_adapter *adap) 1444 + { 1445 + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; 1446 + } 1447 + 1448 + static const struct i2c_algorithm selftest_i2c_algo = { 1449 + .master_xfer = selftest_i2c_master_xfer, 1450 + .functionality = selftest_i2c_functionality, 1451 + }; 1452 + 1453 + static int selftest_i2c_bus_probe(struct platform_device *pdev) 1454 + { 1455 + struct device *dev = &pdev->dev; 1456 + struct device_node *np = dev->of_node; 1457 + struct selftest_i2c_bus_data *std; 1458 + struct i2c_adapter *adap; 1459 + int ret; 1460 + 1461 + if (np == NULL) { 1462 + dev_err(dev, "No OF data for device\n"); 1463 + return -EINVAL; 1464 + 1465 + } 1466 + 1467 + dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); 1468 + 1469 + std = devm_kzalloc(dev, sizeof(*std), GFP_KERNEL); 1470 + if (!std) { 1471 + dev_err(dev, "Failed to allocate selftest i2c data\n"); 1472 + return -ENOMEM; 1473 + } 1474 + 1475 + /* link them together */ 1476 + std->pdev = pdev; 1477 + platform_set_drvdata(pdev, std); 1478 + 1479 + adap = &std->adap; 1480 + i2c_set_adapdata(adap, std); 1481 + adap->nr = -1; 1482 + strlcpy(adap->name, pdev->name, sizeof(adap->name)); 1483 + adap->class = I2C_CLASS_DEPRECATED; 1484 + adap->algo = &selftest_i2c_algo; 1485 + adap->dev.parent = dev; 1486 + adap->dev.of_node = dev->of_node; 1487 + adap->timeout = 5 * HZ; 1488 + adap->retries = 3; 1489 + 1490 + ret = i2c_add_numbered_adapter(adap); 1491 + if (ret != 0) { 1492 + dev_err(dev, "Failed to add I2C adapter\n"); 1493 + return ret; 1494 + } 1495 + 1496 + return 0; 1497 + } 1498 + 1499 + static int selftest_i2c_bus_remove(struct platform_device *pdev) 1500 + { 1501 + struct device *dev = &pdev->dev; 1502 + struct device_node *np = dev->of_node; 1503 + struct selftest_i2c_bus_data *std = platform_get_drvdata(pdev); 1504 + 1505 + dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); 1506 + i2c_del_adapter(&std->adap); 1507 + 1508 + return 0; 1509 + } 1510 + 1511 + static struct of_device_id selftest_i2c_bus_match[] = { 1512 + { .compatible = "selftest-i2c-bus", }, 1513 + {}, 1514 + }; 1515 + 1516 + static struct platform_driver selftest_i2c_bus_driver = { 1517 + .probe = selftest_i2c_bus_probe, 1518 + .remove = selftest_i2c_bus_remove, 1519 + .driver = { 1520 + .name = "selftest-i2c-bus", 1521 + .of_match_table = of_match_ptr(selftest_i2c_bus_match), 1522 + }, 1523 + }; 1524 + 1525 + static int selftest_i2c_dev_probe(struct i2c_client *client, 1526 + const struct i2c_device_id *id) 1527 + { 1528 + struct device *dev = &client->dev; 1529 + struct device_node *np = client->dev.of_node; 1530 + 1531 + if (!np) { 1532 + dev_err(dev, "No OF node\n"); 1533 + return -EINVAL; 1534 + } 1535 + 1536 + dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); 1537 + 1538 + return 0; 1539 + }; 1540 + 1541 + static int selftest_i2c_dev_remove(struct i2c_client *client) 1542 + { 1543 + struct device *dev = &client->dev; 1544 + struct device_node *np = client->dev.of_node; 1545 + 1546 + dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); 1547 + return 0; 1548 + } 1549 + 1550 + static const struct i2c_device_id selftest_i2c_dev_id[] = { 1551 + { .name = "selftest-i2c-dev" }, 1552 + { } 1553 + }; 1554 + 1555 + static struct i2c_driver selftest_i2c_dev_driver = { 1556 + .driver = { 1557 + .name = "selftest-i2c-dev", 1558 + .owner = THIS_MODULE, 1559 + }, 1560 + .probe = selftest_i2c_dev_probe, 1561 + .remove = selftest_i2c_dev_remove, 1562 + .id_table = selftest_i2c_dev_id, 1563 + }; 1564 + 1565 + #if IS_ENABLED(CONFIG_I2C_MUX) 1566 + 1567 + struct selftest_i2c_mux_data { 1568 + int nchans; 1569 + struct i2c_adapter *adap[]; 1570 + }; 1571 + 1572 + static int selftest_i2c_mux_select_chan(struct i2c_adapter *adap, 1573 + void *client, u32 chan) 1574 + { 1575 + return 0; 1576 + } 1577 + 1578 + static int selftest_i2c_mux_probe(struct i2c_client *client, 1579 + const struct i2c_device_id *id) 1580 + { 1581 + int ret, i, nchans, size; 1582 + struct device *dev = &client->dev; 1583 + struct i2c_adapter *adap = to_i2c_adapter(dev->parent); 1584 + struct device_node *np = client->dev.of_node, *child; 1585 + struct selftest_i2c_mux_data *stm; 1586 + u32 reg, max_reg; 1587 + 1588 + dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); 1589 + 1590 + if (!np) { 1591 + dev_err(dev, "No OF node\n"); 1592 + return -EINVAL; 1593 + } 1594 + 1595 + max_reg = (u32)-1; 1596 + for_each_child_of_node(np, child) { 1597 + ret = of_property_read_u32(child, "reg", &reg); 1598 + if (ret) 1599 + continue; 1600 + if (max_reg == (u32)-1 || reg > max_reg) 1601 + max_reg = reg; 1602 + } 1603 + nchans = max_reg == (u32)-1 ? 0 : max_reg + 1; 1604 + if (nchans == 0) { 1605 + dev_err(dev, "No channels\n"); 1606 + return -EINVAL; 1607 + } 1608 + 1609 + size = offsetof(struct selftest_i2c_mux_data, adap[nchans]); 1610 + stm = devm_kzalloc(dev, size, GFP_KERNEL); 1611 + if (!stm) { 1612 + dev_err(dev, "Out of memory\n"); 1613 + return -ENOMEM; 1614 + } 1615 + stm->nchans = nchans; 1616 + for (i = 0; i < nchans; i++) { 1617 + stm->adap[i] = i2c_add_mux_adapter(adap, dev, client, 1618 + 0, i, 0, selftest_i2c_mux_select_chan, NULL); 1619 + if (!stm->adap[i]) { 1620 + dev_err(dev, "Failed to register mux #%d\n", i); 1621 + for (i--; i >= 0; i--) 1622 + i2c_del_mux_adapter(stm->adap[i]); 1623 + return -ENODEV; 1624 + } 1625 + } 1626 + 1627 + i2c_set_clientdata(client, stm); 1628 + 1629 + return 0; 1630 + }; 1631 + 1632 + static int selftest_i2c_mux_remove(struct i2c_client *client) 1633 + { 1634 + struct device *dev = &client->dev; 1635 + struct device_node *np = client->dev.of_node; 1636 + struct selftest_i2c_mux_data *stm = i2c_get_clientdata(client); 1637 + int i; 1638 + 1639 + dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); 1640 + for (i = stm->nchans - 1; i >= 0; i--) 1641 + i2c_del_mux_adapter(stm->adap[i]); 1642 + return 0; 1643 + } 1644 + 1645 + static const struct i2c_device_id selftest_i2c_mux_id[] = { 1646 + { .name = "selftest-i2c-mux" }, 1647 + { } 1648 + }; 1649 + 1650 + static struct i2c_driver selftest_i2c_mux_driver = { 1651 + .driver = { 1652 + .name = "selftest-i2c-mux", 1653 + .owner = THIS_MODULE, 1654 + }, 1655 + .probe = selftest_i2c_mux_probe, 1656 + .remove = selftest_i2c_mux_remove, 1657 + .id_table = selftest_i2c_mux_id, 1658 + }; 1659 + 1660 + #endif 1661 + 1662 + static int of_selftest_overlay_i2c_init(void) 1663 + { 1664 + int ret; 1665 + 1666 + ret = i2c_add_driver(&selftest_i2c_dev_driver); 1667 + if (selftest(ret == 0, 1668 + "could not register selftest i2c device driver\n")) 1669 + return ret; 1670 + 1671 + ret = platform_driver_register(&selftest_i2c_bus_driver); 1672 + if (selftest(ret == 0, 1673 + "could not register selftest i2c bus driver\n")) 1674 + return ret; 1675 + 1676 + #if IS_ENABLED(CONFIG_I2C_MUX) 1677 + ret = i2c_add_driver(&selftest_i2c_mux_driver); 1678 + if (selftest(ret == 0, 1679 + "could not register selftest i2c mux driver\n")) 1680 + return ret; 1681 + #endif 1682 + 1683 + return 0; 1684 + } 1685 + 1686 + static void of_selftest_overlay_i2c_cleanup(void) 1687 + { 1688 + #if IS_ENABLED(CONFIG_I2C_MUX) 1689 + i2c_del_driver(&selftest_i2c_mux_driver); 1690 + #endif 1691 + platform_driver_unregister(&selftest_i2c_bus_driver); 1692 + i2c_del_driver(&selftest_i2c_dev_driver); 1693 + } 1694 + 1695 + static void of_selftest_overlay_i2c_12(void) 1696 + { 1697 + int ret; 1698 + 1699 + /* device should enable */ 1700 + ret = of_selftest_apply_overlay_check(12, 12, 0, 1, I2C_OVERLAY); 1701 + if (ret != 0) 1702 + return; 1703 + 1704 + selftest(1, "overlay test %d passed\n", 12); 1705 + } 1706 + 1707 + /* test deactivation of device */ 1708 + static void of_selftest_overlay_i2c_13(void) 1709 + { 1710 + int ret; 1711 + 1712 + /* device should disable */ 1713 + ret = of_selftest_apply_overlay_check(13, 13, 1, 0, I2C_OVERLAY); 1714 + if (ret != 0) 1715 + return; 1716 + 1717 + selftest(1, "overlay test %d passed\n", 13); 1718 + } 1719 + 1720 + /* just check for i2c mux existence */ 1721 + static void of_selftest_overlay_i2c_14(void) 1722 + { 1723 + } 1724 + 1725 + static void of_selftest_overlay_i2c_15(void) 1726 + { 1727 + int ret; 1728 + 1729 + /* device should enable */ 1730 + ret = of_selftest_apply_overlay_check(16, 15, 0, 1, I2C_OVERLAY); 1731 + if (ret != 0) 1732 + return; 1733 + 1734 + selftest(1, "overlay test %d passed\n", 15); 1735 + } 1736 + 1737 + #else 1738 + 1739 + static inline void of_selftest_overlay_i2c_14(void) { } 1740 + static inline void of_selftest_overlay_i2c_15(void) { } 1741 + 1742 + #endif 1445 1743 1446 1744 static void __init of_selftest_overlay(void) 1447 1745 { ··· 1787 1445 goto out; 1788 1446 } 1789 1447 1790 - if (!of_path_platform_device_exists(selftest_path(100))) { 1448 + if (!of_selftest_device_exists(100, PDEV_OVERLAY)) { 1791 1449 selftest(0, "could not find selftest0 @ \"%s\"\n", 1792 - selftest_path(100)); 1450 + selftest_path(100, PDEV_OVERLAY)); 1793 1451 goto out; 1794 1452 } 1795 1453 1796 - if (of_path_platform_device_exists(selftest_path(101))) { 1454 + if (of_selftest_device_exists(101, PDEV_OVERLAY)) { 1797 1455 selftest(0, "selftest1 @ \"%s\" should not exist\n", 1798 - selftest_path(101)); 1456 + selftest_path(101, PDEV_OVERLAY)); 1799 1457 goto out; 1800 1458 } 1801 1459 ··· 1813 1471 1814 1472 of_selftest_overlay_10(); 1815 1473 of_selftest_overlay_11(); 1474 + 1475 + #if IS_ENABLED(CONFIG_I2C) 1476 + if (selftest(of_selftest_overlay_i2c_init() == 0, "i2c init failed\n")) 1477 + goto out; 1478 + 1479 + of_selftest_overlay_i2c_12(); 1480 + of_selftest_overlay_i2c_13(); 1481 + of_selftest_overlay_i2c_14(); 1482 + of_selftest_overlay_i2c_15(); 1483 + 1484 + of_selftest_overlay_i2c_cleanup(); 1485 + #endif 1816 1486 1817 1487 out: 1818 1488 of_node_put(bus_np); ··· 1867 1513 of_selftest_match_node(); 1868 1514 of_selftest_platform_populate(); 1869 1515 of_selftest_overlay(); 1870 - 1871 - /* removing selftest data from live tree */ 1872 - selftest_data_remove(); 1873 1516 1874 1517 /* Double check linkage after removing testcase data */ 1875 1518 of_selftest_check_tree_linkage();
+1 -2
include/linux/mod_devicetable.h
··· 220 220 /* 221 221 * Struct used for matching a device 222 222 */ 223 - struct of_device_id 224 - { 223 + struct of_device_id { 225 224 char name[32]; 226 225 char type[32]; 227 226 char compatible[128];