public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Javier Martin <javier.martin@vista-silicon.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [u-boot] [PATCH][1/2] mx27: Add necessary defines and helper functions to support I2C in i.MX27.
Date: Fri, 30 Oct 2009 15:43:20 +0100	[thread overview]
Message-ID: <4AEAFB88.1030707@vista-silicon.com> (raw)

Add proper register definitions, macros and clock functions required
for I2C driver to be developed.



Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
--
diff --git a/cpu/arm926ejs/mx27/generic.c b/cpu/arm926ejs/mx27/generic.c
index 808371f..540ef0c 100644
--- a/cpu/arm926ejs/mx27/generic.c
+++ b/cpu/arm926ejs/mx27/generic.c
@@ -22,11 +22,21 @@
 #include <div64.h>
 #include <netdev.h>
 #include <asm/io.h>
+#include <asm/arch/asm-offsets.h>
 #include <asm/arch/imx-regs.h>
 #ifdef CONFIG_MXC_MMC
 #include <asm/arch/mxcmmc.h>
 #endif

+int imx_get_revision(void)
+{
+	ulong val;
+
+	val = readl(SYSCTRL_CID);
+
+	return (int)(val >> 28);
+}
+
 /*
  *  get the system pll clock in Hz
  *
@@ -152,6 +162,19 @@ ulong imx_get_perclk4(void)
 	return imx_decode_perclk(((readl(&pll->pcdr1) >> 24) & 0x3f) + 1);
 }

+ulong imx_get_ipgclk(void)
+{
+	ulong rate, ipg_pdf;
+
+	if (imx_get_revision() >= CHIP_REV_2_0)
+		return imx_get_ahbclk();
+	else
+		ipg_pdf = (readl(CSCR) >> 8) & 1;
+
+	rate = imx_get_ahbclk();
+	return rate / (ipg_pdf + 1);
+}
+
 #if defined(CONFIG_DISPLAY_CPUINFO)
 int print_cpuinfo (void)
 {
diff --git a/include/asm-arm/arch-mx27/asm-offsets.h b/include/asm-arm/arch-mx27/asm-offsets.h
index 497afe5..cdecef6 100644
--- a/include/asm-arm/arch-mx27/asm-offsets.h
+++ b/include/asm-arm/arch-mx27/asm-offsets.h
@@ -14,3 +14,5 @@
 #define ESDCTL1_ROF	0x08
 #define ESDCFG1_ROF	0x0C
 #define ESDMISC_ROF	0x10
+#define SYSCTRL_CID	0x10027800
+#define CHIP_REV_2_0		0x01
diff --git a/include/asm-arm/arch-mx27/imx-regs.h b/include/asm-arm/arch-mx27/imx-regs.h
index d36a6da..2b89b4e 100644
--- a/include/asm-arm/arch-mx27/imx-regs.h
+++ b/include/asm-arm/arch-mx27/imx-regs.h
@@ -206,6 +206,10 @@ struct iim_regs {
 };
 #endif

+#define __REG(x)     (*((volatile u32 *)(x)))
+#define __REG16(x)   (*((volatile u16 *)(x)))
+#define __REG8(x)    (*((volatile u8 *)(x)))
+
 #define IMX_IO_BASE		0x10000000

 #define IMX_AIPI1_BASE		(0x00000 + IMX_IO_BASE)
--
Javier Martin
Vista Silicon S.L.
CDTUC - FASE C - Oficina S-345
Avda de los Castros s/n
39005- Santander. Cantabria. Spain
+34 942 25 32 60
www.vista-silicon.com

             reply	other threads:[~2009-10-30 14:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-30 14:43 Javier Martin [this message]
2009-11-02  7:07 ` [U-Boot] [u-boot] [PATCH][1/2] mx27: Add necessary defines and helper functions to support I2C in i.MX27 Heiko Schocher
2009-11-02  8:10   ` javier Martin
2009-11-02  7:35     ` 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=4AEAFB88.1030707@vista-silicon.com \
    --to=javier.martin@vista-silicon.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