From d75c25dae1671f55f8a0356be0f5bb9aa8df5dc2 Mon Sep 17 00:00:00 2001
From: Joel Stanley <joel@jms.id.au>
Date: Fri, 30 Oct 2015 16:35:05 +1030
Subject: [PATCH] aspeed/i2c: add all buses to device tree

They will only be enabled if the status property is changed from
"disabled".

Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dts | 99 +++++++++++++++++++
 drivers/i2c/busses/i2c-aspeed.c               | 12 +--
 2 files changed, 103 insertions(+), 8 deletions(-)

diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dts b/arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dts
index 5be4e8e1ad8c6..b14b246403d18 100644
--- a/arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dts
+++ b/arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dts
@@ -103,6 +103,7 @@
 					compatible = "aspeed,ast2400-i2c-bus";
 					bus = <0>;
 					clock-frequency = <100000>;
+					status = "okay";
 				};
 
 				i2c1: i2c-bus@0x80 {
@@ -110,7 +111,105 @@
 					compatible = "aspeed,ast2400-i2c-bus";
 					bus = <1>;
 					clock-frequency = <100000>;
+					status = "okay";
 				};
+
+				i2c2: i2c-bus@0xC0 {
+					reg = <0xC0 0x40>;
+					compatible = "aspeed,ast2400-i2c-bus";
+					bus = <2>;
+					clock-frequency = <100000>;
+					status = "disabled";
+				};
+
+				i2c3: i2c-bus@0x100 {
+					reg = <0x100 0x40>;
+					compatible = "aspeed,ast2400-i2c-bus";
+					bus = <3>;
+					clock-frequency = <100000>;
+					status = "disabled";
+				};
+
+				i2c4: i2c-bus@0x140 {
+					reg = <0x140 0x40>;
+					compatible = "aspeed,ast2400-i2c-bus";
+					bus = <4>;
+					clock-frequency = <100000>;
+					status = "disabled";
+				};
+
+				i2c5: i2c-bus@0x180 {
+					reg = <0x180 0x40>;
+					compatible = "aspeed,ast2400-i2c-bus";
+					bus = <5>;
+					clock-frequency = <100000>;
+					status = "disabled";
+				};
+
+				i2c6: i2c-bus@0x1C0 {
+					reg = <0x1C0 0x40>;
+					compatible = "aspeed,ast2400-i2c-bus";
+					bus = <6>;
+					clock-frequency = <100000>;
+					status = "disabled";
+				};
+
+				i2c7: i2c-bus@0x300 {
+					reg = <0x300 0x40>;
+					compatible = "aspeed,ast2400-i2c-bus";
+					bus = <7>;
+					clock-frequency = <100000>;
+					status = "disabled";
+				};
+
+				i2c8: i2c-bus@0x340 {
+					reg = <0x340 0x40>;
+					compatible = "aspeed,ast2400-i2c-bus";
+					bus = <8>;
+					clock-frequency = <100000>;
+					status = "disabled";
+				};
+
+				i2c9: i2c-bus@0x380 {
+					reg = <0x380 0x40>;
+					compatible = "aspeed,ast2400-i2c-bus";
+					bus = <9>;
+					clock-frequency = <100000>;
+					status = "disabled";
+				};
+
+				i2c10: i2c-bus@0x3C0 {
+					reg = <0x380 0x40>;
+					compatible = "aspeed,ast2400-i2c-bus";
+					bus = <10>;
+					clock-frequency = <100000>;
+					status = "disabled";
+				};
+
+				i2c11: i2c-bus@0x400 {
+					reg = <0x400 0x40>;
+					compatible = "aspeed,ast2400-i2c-bus";
+					bus = <11>;
+					clock-frequency = <100000>;
+					status = "disabled";
+				};
+
+				i2c12: i2c-bus@0x440 {
+					reg = <0x400 0x40>;
+					compatible = "aspeed,ast2400-i2c-bus";
+					bus = <12>;
+					clock-frequency = <100000>;
+					status = "disabled";
+				};
+
+				i2c13: i2c-bus@0x480 {
+					reg = <0x480 0x40>;
+					compatible = "aspeed,ast2400-i2c-bus";
+					bus = <13>;
+					clock-frequency = <100000>;
+					status = "disabled";
+				};
+
 			};
 
 			syscon: syscon@1e6e2000 {
diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
index b720874027a1c..395e965c46a69 100644
--- a/drivers/i2c/busses/i2c-aspeed.c
+++ b/drivers/i2c/busses/i2c-aspeed.c
@@ -1287,8 +1287,6 @@ static int aspeed_i2c_add_bus(struct device_node *np,
 	if (ret < 0)
 		return -ENXIO;
 
-	printk("i2c: adding adapter done\n");
-
 	return 0;
 }
 
@@ -1325,19 +1323,17 @@ static int ast_i2c_probe(struct platform_device *pdev)
 		return PTR_ERR(dev->pclk);
 	}
 
-	for_each_child_of_node(pdev->dev.of_node, np) {
-
-		printk("i2c: trying %s\n", np->name);
-
+	for_each_available_child_of_node(pdev->dev.of_node, np) {
 		if (!of_device_is_compatible(np, "aspeed,ast2400-i2c-bus"))
 			continue;
 
-		aspeed_i2c_add_bus(np, dev, pdev);
+		ret = aspeed_i2c_add_bus(np, dev, pdev);
+		if (ret < 0)
+			dev_err(&pdev->dev, "faield to add i2c bus %s\n", np->name);
 	}
 
 	platform_set_drvdata(pdev, dev);
 
-
 	return 0;
 }