public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 03/15] arm64: mvebu: armada-8k: Only configure xHCI power on DB-88F7040 board
Date: Tue, 15 Nov 2016 10:08:19 +0100	[thread overview]
Message-ID: <20161115090831.8426-3-sr@denx.de> (raw)
In-Reply-To: <20161115090831.8426-1-sr@denx.de>

This patch uses of_machine_is_compatible() to detect the board at runtime
and only configured the I2C IO expander for the xHCI power / reset on
the DB-88F7040 board. As this code will be used by other Armada-7k/8k
ports, its necessary to use this runtime detection here.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Nadav Haklai <nadavh@marvell.com>
Cc: Neta Zur Hershkovits <neta@marvell.com>
Cc: Kostya Porotchkin <kostap@marvell.com>
Cc: Omri Itach <omrii@marvell.com>
Cc: Igal Liberman <igall@marvell.com>
Cc: Haim Boot <hayim@marvell.com>
Cc: Hanna Hawa <hannah@marvell.com>
---
 board/Marvell/mvebu_armada-8k/board.c | 146 ++++++++++++++++++----------------
 1 file changed, 78 insertions(+), 68 deletions(-)

diff --git a/board/Marvell/mvebu_armada-8k/board.c b/board/Marvell/mvebu_armada-8k/board.c
index 48bd55c..7d1b5d9 100644
--- a/board/Marvell/mvebu_armada-8k/board.c
+++ b/board/Marvell/mvebu_armada-8k/board.c
@@ -5,6 +5,7 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <i2c.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
@@ -12,6 +13,11 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+/*
+ * Information specific to the DB-88F7040 eval board. We strive to use
+ * DT for such platform specfic configurations. At some point, this
+ * might be removed here and implemented via DT.
+ */
 /* IO expander I2C device */
 #define I2C_IO_EXP_ADDR		0x21
 #define I2C_IO_CFG_REG_0	0x6
@@ -44,45 +50,47 @@ int board_xhci_config(void)
 	int ret;
 	u8 buf[8];
 
-	/* Configure IO exander PCA9555: 7bit address 0x21 */
-	ret = i2c_get_chip_for_busnum(0, I2C_IO_EXP_ADDR, 1, &dev);
-	if (ret) {
-		printf("Cannot find PCA9555: %d\n", ret);
-		return 0;
-	}
-
-	/*
-	 * Read configuration (direction) and set VBUS pin as output
-	 * (reset pin = output)
-	 */
-	ret = dm_i2c_read(dev, I2C_IO_CFG_REG_0, buf, 1);
-	if (ret) {
-		printf("Failed to read IO expander value via I2C\n");
-		return -EIO;
-	}
-	buf[0] &= ~I2C_IO_REG_VBUS;
-	buf[0] &= ~I2C_IO_REG_CL;
-	ret = dm_i2c_write(dev, I2C_IO_CFG_REG_0, buf, 1);
-	if (ret) {
-		printf("Failed to set IO expander via I2C\n");
-		return -EIO;
-	}
-
-	/* Read output value and configure it */
-	ret = dm_i2c_read(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
-	if (ret) {
-		printf("Failed to read IO expander value via I2C\n");
-		return -EIO;
+	if (of_machine_is_compatible("marvell,armada7040-db")) {
+		/* Configure IO exander PCA9555: 7bit address 0x21 */
+		ret = i2c_get_chip_for_busnum(0, I2C_IO_EXP_ADDR, 1, &dev);
+		if (ret) {
+			printf("Cannot find PCA9555: %d\n", ret);
+			return 0;
+		}
+
+		/*
+		 * Read configuration (direction) and set VBUS pin as output
+		 * (reset pin = output)
+		 */
+		ret = dm_i2c_read(dev, I2C_IO_CFG_REG_0, buf, 1);
+		if (ret) {
+			printf("Failed to read IO expander value via I2C\n");
+			return -EIO;
+		}
+		buf[0] &= ~I2C_IO_REG_VBUS;
+		buf[0] &= ~I2C_IO_REG_CL;
+		ret = dm_i2c_write(dev, I2C_IO_CFG_REG_0, buf, 1);
+		if (ret) {
+			printf("Failed to set IO expander via I2C\n");
+			return -EIO;
+		}
+
+		/* Read output value and configure it */
+		ret = dm_i2c_read(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
+		if (ret) {
+			printf("Failed to read IO expander value via I2C\n");
+			return -EIO;
+		}
+		buf[0] &= ~I2C_IO_REG_VBUS;
+		buf[0] |= I2C_IO_REG_CL;
+		ret = dm_i2c_write(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
+		if (ret) {
+			printf("Failed to set IO expander via I2C\n");
+			return -EIO;
+		}
+
+		mdelay(500); /* required delay to let output value settle */
 	}
-	buf[0] &= ~I2C_IO_REG_VBUS;
-	buf[0] |= I2C_IO_REG_CL;
-	ret = dm_i2c_write(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
-	if (ret) {
-		printf("Failed to set IO expander via I2C\n");
-		return -EIO;
-	}
-
-	mdelay(500); /* required delay to let output value settle */
 
 	return 0;
 }
@@ -93,38 +101,40 @@ int board_xhci_enable(void)
 	int ret;
 	u8 buf[8];
 
-	/*
-	 * This function enables all USB ports simultaniously,
-	 * it only needs to get called once
-	 */
-	if (usb_enabled)
-		return 0;
-
-	/* Configure IO exander PCA9555: 7bit address 0x21 */
-	ret = i2c_get_chip_for_busnum(0, I2C_IO_EXP_ADDR, 1, &dev);
-	if (ret) {
-		printf("Cannot find PCA9555: %d\n", ret);
-		return 0;
-	}
-
-	/* Read VBUS output value */
-	ret = dm_i2c_read(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
-	if (ret) {
-		printf("Failed to read IO expander value via I2C\n");
-		return -EIO;
+	if (of_machine_is_compatible("marvell,armada7040-db")) {
+		/*
+		 * This function enables all USB ports simultaniously,
+		 * it only needs to get called once
+		 */
+		if (usb_enabled)
+			return 0;
+
+		/* Configure IO exander PCA9555: 7bit address 0x21 */
+		ret = i2c_get_chip_for_busnum(0, I2C_IO_EXP_ADDR, 1, &dev);
+		if (ret) {
+			printf("Cannot find PCA9555: %d\n", ret);
+			return 0;
+		}
+
+		/* Read VBUS output value */
+		ret = dm_i2c_read(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
+		if (ret) {
+			printf("Failed to read IO expander value via I2C\n");
+			return -EIO;
+		}
+
+		/* Enable VBUS power: Set output value of VBUS pin as enabled */
+		buf[0] |= I2C_IO_REG_VBUS;
+		ret = dm_i2c_write(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
+		if (ret) {
+			printf("Failed to set IO expander via I2C\n");
+			return -EIO;
+		}
+
+		mdelay(500); /* required delay to let output value settle */
+		usb_enabled = 1;
 	}
 
-	/* Enable VBUS power: Set output value of VBUS pin as enabled */
-	buf[0] |= I2C_IO_REG_VBUS;
-	ret = dm_i2c_write(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
-	if (ret) {
-		printf("Failed to set IO expander via I2C\n");
-		return -EIO;
-	}
-
-	mdelay(500); /* required delay to let output value settle */
-	usb_enabled = 1;
-
 	return 0;
 }
 
-- 
2.10.2

  parent reply	other threads:[~2016-11-15  9:08 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-15  9:08 [U-Boot] [PATCH 01/15] arm64: mvebu: Rename db-88f7040 files to armada-8k Stefan Roese
2016-11-15  9:08 ` [U-Boot] [PATCH 02/15] arm64: mvebu: Add Armada-80x0 dts/dtsi files Stefan Roese
2016-11-15  9:08 ` Stefan Roese [this message]
2016-11-15  9:08 ` [U-Boot] [PATCH 04/15] arm64: mvebu: Add slave CP area to the memory map Stefan Roese
2016-11-15  9:08 ` [U-Boot] [PATCH 05/15] arm64: mvebu: Add support for the DB-88F8040 Armada 8k devel board Stefan Roese
2016-11-15  9:08 ` [U-Boot] [PATCH 06/15] arm64: mvebu: armada-cp110-master.dtsi: Rename comphy DT node names Stefan Roese
2016-11-15  9:08 ` [U-Boot] [PATCH 07/15] arm64: mvebu: armada-cp110-slave.dtsi: Add COMPHY / UTMI device tree nodes Stefan Roese
2016-11-15  9:08 ` [U-Boot] [PATCH 08/15] arm64: mvebu: armada-8040-db.dts: Add COMPHY configuration Stefan Roese
2016-11-15  9:08 ` [U-Boot] [PATCH 09/15] arm64: mvebu: armada-8040-db.dts: Add I2C and SPI aliases Stefan Roese
2016-11-15  9:08 ` [U-Boot] [PATCH 10/15] arm64: mvebu: Init COMPHY from the slave-CP on the A8k Stefan Roese
2016-11-15  9:08 ` [U-Boot] [PATCH 11/15] drivers/phy: marvell: Add support for the slave CP COMPHY device Stefan Roese
2016-11-15  9:08 ` [U-Boot] [PATCH 12/15] pci: mvebu: Add PCIe driver for Armada-8K Stefan Roese
2016-11-18  1:14   ` Simon Glass
2016-11-25 13:56     ` Stefan Roese
2016-11-28 12:38   ` [U-Boot] [PATCH 12/15 v2] " Stefan Roese
2016-12-03  4:26     ` Simon Glass
2016-12-03  9:20       ` Stefan Roese
2016-12-03 18:31         ` Simon Glass
2016-12-05 12:23           ` Stefan Roese
2016-11-15  9:08 ` [U-Boot] [PATCH 13/15] arm64: mvebu: Add regions for PCI spaces to the memory map Stefan Roese
2016-11-15  9:08 ` [U-Boot] [PATCH 14/15] arm64: mvebu: Add PCI support to DB-88F8040 board Stefan Roese
2016-11-15  9:08 ` [U-Boot] [PATCH 15/15] arm64: mvebu: Restrict memory size to a usable maximum Stefan Roese
2016-12-05 12:56 ` [U-Boot] [PATCH 01/15] arm64: mvebu: Rename db-88f7040 files to armada-8k Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161115090831.8426-3-sr@denx.de \
    --to=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox