Skip to contentSkip to conversation

mx27: Add necessary defines and helper functions to support I2C in i.MX27.

PATCH New Javier Martin 2 participants 4 messages Oct 30, 2009 – Nov 2, 2009 Arm i.MX and Layerscape

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mx27: Add necessary defines and helper functions to support I2C in i.MX27.

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

--

cpu/arm926ejs/mx27/generic.c +23 -0
index 808371f..540ef0c 100644
@@ -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)
 {
include/asm-arm/arch-mx27/asm-offsets.h +2 -0
index 497afe5..cdecef6 100644
@@ -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
include/asm-arm/arch-mx27/imx-regs.h +4 -0
index d36a6da..2b89b4e 100644
@@ -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

#1 lore raw

PATCH 1/2 mx27: Add necessary defines and helper functions to support I2C in i.MX27.

Hello Javier,

Quoted 9 lines · Javier Martin

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

--

cpu/arm926ejs/mx27/generic.c +0 -0
index 808371f..540ef0c 100644

[...]

include/asm-arm/arch-mx27/imx-regs.h struct iim_regs { · line 212

Quoted 12 lines
include/asm-arm/arch-mx27/imx-regs.h +4 -0
index d36a6da..2b89b4e 100644
@@ -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)))
+

Why you need this? Couldn;t you use io accessor from asm/io.h?

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#2 lore raw

PATCH 1/2 mx27: Add necessary defines and helper functions to support I2C in i.MX27.

2009/11/2 Heiko Schocher <[email protected]>:

Quoted 21 lines

Hello Javier,

Quoted 9 lines · Javier Martin

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

--

cpu/arm926ejs/mx27/generic.c +0 -0
index 808371f..540ef0c 100644

[...]

Quoted 8 lines
include/asm-arm/arch-mx27/imx-regs.h +0 -0
index d36a6da..2b89b4e 100644
@@ -206,6 +206,10 @@ struct iim_regs {
 ?};

?#endif

Quoted 6 lines

include/asm-arm/arch-mx27/imx-regs.h

Quoted 4 lines
include/asm-arm/arch-mx27/imx-regs.h +4 -0
+#define __REG(x) ? ? (*((volatile u32 *)(x)))
+#define __REG16(x) ? (*((volatile u16 *)(x)))
+#define __REG8(x) ? ?(*((volatile u8 *)(x)))
+

Why you need this? Couldn;t you use io accessor from asm/io.h?

Hi Heiko,
thank you for the comments. I think that would make the driver dirty since there would also be needed the use of an ifdef to separate i.MX31 reg accesses, which are accessed through __REG() macros, from i.MX27 ones which should be accessed by io accessors from io.h. If you do not have any complaint about that I will use functions from asm/io.h.

Signature · 7 lines
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
#3 lore raw

PATCH 1/2 mx27: Add necessary defines and helper functions to support I2C in i.MX27.

Hello javier,

Quoted 28 lines · javier Martin

2009/11/2 Heiko Schocher <[email protected]>:

Quoted 21 lines

Hello Javier,

Quoted 9 lines · Javier Martin

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

--

cpu/arm926ejs/mx27/generic.c +0 -0
index 808371f..540ef0c 100644

[...]

Quoted 8 lines
include/asm-arm/arch-mx27/imx-regs.h +0 -0
index d36a6da..2b89b4e 100644
@@ -206,6 +206,10 @@ struct iim_regs {
 };
 #endif
 
Quoted 5 lines

include/asm-arm/arch-mx27/imx-regs.h struct iim_regs { · line 212

Quoted 4 lines
include/asm-arm/arch-mx27/imx-regs.h +4 -0
+#define __REG(x)     (*((volatile u32 *)(x)))
+#define __REG16(x)   (*((volatile u16 *)(x)))
+#define __REG8(x)    (*((volatile u8 *)(x)))
+

Why you need this? Couldn;t you use io accessor from asm/io.h?

Quoted 7 lines

Hi Heiko,
thank you for the comments. I think that would make the driver dirty since there would also be needed the use of an ifdef to separate i.MX31 reg accesses, which are accessed through __REG() macros, from i.MX27 ones which should be accessed by io accessors from io.h. If you do not have any complaint about that I will use functions from asm/io.h.

No, that is suboptimal, I thought more in the direction to cleanup the driver ;-)

I see no reason, why the i.mx31 shouldn;t be able to use also the io accessors from asm/io.h ... Tom, any suggestions?

bye
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany