public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: maxims at google.com <maxims@google.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH u-boot 4/5] aspeed: Added function to configure pins for I2C devices.
Date: Tue, 22 Nov 2016 15:56:15 -0800	[thread overview]
Message-ID: <1479858976-139210-5-git-send-email-maxims@google.com> (raw)
In-Reply-To: <1479858976-139210-1-git-send-email-maxims@google.com>

From: Maxim Sloyko <maxims@google.com>

In the absence of pinmux driver, I2C driver will be
configuring pins directly.

Signed-off-by: Maxim Sloyko <maxims@google.com>
---
 arch/arm/include/asm/arch-aspeed/ast_scu.h |  5 +++++
 arch/arm/mach-aspeed/ast-scu.c             | 28 ++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/arch/arm/include/asm/arch-aspeed/ast_scu.h b/arch/arm/include/asm/arch-aspeed/ast_scu.h
index eb5aaa2..80ebd6f 100644
--- a/arch/arm/include/asm/arch-aspeed/ast_scu.h
+++ b/arch/arm/include/asm/arch-aspeed/ast_scu.h
@@ -46,4 +46,9 @@ extern void ast_scu_init_eth(u8 num);
 extern void ast_scu_multi_func_eth(u8 num);
 extern void ast_scu_multi_func_romcs(u8 num);
 
+/* Enable I2C controller and pins for a particular device.
+ * Device numbering starts at 1
+ */
+extern void ast_scu_enable_i2c(u8 num);
+
 #endif
diff --git a/arch/arm/mach-aspeed/ast-scu.c b/arch/arm/mach-aspeed/ast-scu.c
index e00dbe2..b5aa8bf 100644
--- a/arch/arm/mach-aspeed/ast-scu.c
+++ b/arch/arm/mach-aspeed/ast-scu.c
@@ -507,3 +507,31 @@ void ast_scu_get_who_init_dram(void)
 		break;
 	}
 }
+
+void ast_scu_enable_i2c(u8 bus_num)
+{
+	if (bus_num > SCU_I2C_MAX_BUS_NUM) {
+		debug("%s: bus_num is out of range, must be [%d - %d]\n",
+		      __func__, SCU_I2C_MIN_BUS_NUM, SCU_I2C_MAX_BUS_NUM);
+		return;
+	}
+
+	if (bus_num == 0) {
+		/* Enable I2C Controllers */
+		clrbits_le32(AST_SCU_BASE + AST_SCU_RESET, SCU_RESET_I2C);
+	} else if (bus_num >= 3) {
+		setbits_le32(AST_SCU_BASE + AST_SCU_FUN_PIN_CTRL5,
+			     SCU_FUN_PIN_I2C(bus_num));
+	/* In earlier versions of the SoC these pins are always assigned to
+	 * respective I2C buses and require no configuration.
+	 */
+#ifdef AST_SOC_G5
+	} else if (bus_num == 1) {
+		setbits_le32(AST_SCU_BASE + AST_SCU_FUN_PIN_CTRL8,
+			     SCU_FUN_PIN_SDA1 | SCU_FUN_PIN_SCL1);
+	} else if (bus_num == 2) {
+		setbits_le32(AST_SCU_BASE + AST_SCU_FUN_PIN_CTRL8,
+			     SCU_FUN_PIN_SDA2 | SCU_FUN_PIN_SCL2);
+#endif
+	}
+}
-- 
2.8.0.rc3.226.g39d4020

  parent reply	other threads:[~2016-11-22 23:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-22 23:56 [U-Boot] [PATCH u-boot 0/5] Aspeed I2C driver, using Driver Model maxims at google.com
2016-11-22 23:56 ` [U-Boot] [PATCH u-boot 1/5] aspeed/g5: Device Tree for ast2500, copied from openbmc/linux (include file), plus minimal device tree configuration for ast2500 eval board maxims at google.com
2016-11-23 16:13   ` Simon Glass
2016-11-23 16:23     ` Simon Glass
2016-11-22 23:56 ` [U-Boot] [PATCH u-boot 2/5] aspeed: Fixed incosistency in some SCU registers naming maxims at google.com
2016-11-23 16:13   ` Simon Glass
2016-11-23 16:24     ` Simon Glass
2016-11-22 23:56 ` [U-Boot] [PATCH u-boot 3/5] aspeed: Added function to calculate APB Clock frequency maxims at google.com
2016-11-23 16:13   ` Simon Glass
2016-11-23 16:24     ` Simon Glass
2016-11-22 23:56 ` maxims at google.com [this message]
2016-11-23 16:13   ` [U-Boot] [PATCH u-boot 4/5] aspeed: Added function to configure pins for I2C devices Simon Glass
2016-11-23 16:24     ` Simon Glass
2016-11-22 23:56 ` [U-Boot] [PATCH u-boot 5/5] aspeed: I2C driver maxims at google.com
2016-11-23 16:13   ` Simon Glass
2016-11-23 16:24     ` Simon Glass
2016-11-23 12:28 ` [U-Boot] [PATCH u-boot 0/5] Aspeed I2C driver, using Driver Model Heiko Schocher
2016-11-23 16:40   ` Maxim Sloyko
2016-11-24  5:19     ` Heiko Schocher

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=1479858976-139210-5-git-send-email-maxims@google.com \
    --to=maxims@google.com \
    --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