Skip to content

Commit

Permalink
of: unitest: Add I2C overlay unit tests.
Browse files Browse the repository at this point in the history
Introduce I2C device tree overlay tests.
Tests insertion and removal of i2c adapters, i2c devices, and muxes.

Signed-off-by: Pantelis Antoniou <[email protected]>
Signed-off-by: Rob Herring <[email protected]>
  • Loading branch information
pantoniou authored and robherring committed Feb 4, 2015
1 parent 962a70d commit d5e7550
Show file tree
Hide file tree
Showing 3 changed files with 614 additions and 51 deletions.
59 changes: 58 additions & 1 deletion Documentation/devicetree/bindings/unittest.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* OF selftest platform device
1) OF selftest platform device

** selftest

Expand All @@ -12,3 +12,60 @@ Example:
compatible = "selftest";
status = "okay";
};

2) OF selftest i2c adapter platform device

** platform device unittest adapter

Required properties:
- compatible: must be selftest-i2c-bus

Children nodes contain selftest i2c devices.

Example:
selftest-i2c-bus {
compatible = "selftest-i2c-bus";
status = "okay";
};

3) OF selftest i2c device

** I2C selftest device

Required properties:
- compatible: must be selftest-i2c-dev

All other properties are optional

Example:
selftest-i2c-dev {
compatible = "selftest-i2c-dev";
status = "okay";
};

4) OF selftest i2c mux device

** I2C selftest mux

Required properties:
- compatible: must be selftest-i2c-mux

Children nodes contain selftest i2c bus nodes per channel.

Example:
selftest-i2c-mux {
compatible = "selftest-i2c-mux";
status = "okay";
#address-cells = <1>;
#size-cells = <0>;
channel-0 {
reg = <0>;
#address-cells = <1>;
#size-cells = <0>;
i2c-dev {
reg = <8>;
compatible = "selftest-i2c-dev";
status = "okay";
};
};
};
94 changes: 94 additions & 0 deletions drivers/of/unittest-data/tests-overlay.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,48 @@
status = "disabled";
reg = <8>;
};

i2c-test-bus {
compatible = "selftest-i2c-bus";
status = "okay";
reg = <50>;

#address-cells = <1>;
#size-cells = <0>;

test-selftest12 {
reg = <8>;
compatible = "selftest-i2c-dev";
status = "disabled";
};

test-selftest13 {
reg = <9>;
compatible = "selftest-i2c-dev";
status = "okay";
};

test-selftest14 {
reg = <10>;
compatible = "selftest-i2c-mux";
status = "okay";

#address-cells = <1>;
#size-cells = <0>;

i2c@0 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0>;

test-mux-dev {
reg = <32>;
compatible = "selftest-i2c-dev";
status = "okay";
};
};
};
};
};
};

Expand Down Expand Up @@ -231,5 +273,57 @@
};
};
};

/* test enable using absolute target path (i2c) */
overlay12 {
fragment@0 {
target-path = "/testcase-data/overlay-node/test-bus/i2c-test-bus/test-selftest12";
__overlay__ {
status = "okay";
};
};
};

/* test disable using absolute target path (i2c) */
overlay13 {
fragment@0 {
target-path = "/testcase-data/overlay-node/test-bus/i2c-test-bus/test-selftest13";
__overlay__ {
status = "disabled";
};
};
};

/* test mux overlay */
overlay15 {
fragment@0 {
target-path = "/testcase-data/overlay-node/test-bus/i2c-test-bus";
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
test-selftest15 {
reg = <11>;
compatible = "selftest-i2c-mux";
status = "okay";

#address-cells = <1>;
#size-cells = <0>;

i2c@0 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0>;

test-mux-dev {
reg = <32>;
compatible = "selftest-i2c-dev";
status = "okay";
};
};
};
};
};
};

};
};
Loading

0 comments on commit d5e7550

Please sign in to comment.