public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [u-boot] [PATCH][1/2] mx27: Add necessary defines and helper functions to support I2C in i.MX27.
@ 2009-10-30 14:43 Javier Martin
  2009-11-02  7:07 ` Heiko Schocher
  0 siblings, 1 reply; 4+ messages in thread
From: Javier Martin @ 2009-10-30 14:43 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [u-boot] [PATCH][1/2] mx27: Add necessary defines and helper functions to support I2C in i.MX27.
  2009-10-30 14:43 [U-Boot] [u-boot] [PATCH][1/2] mx27: Add necessary defines and helper functions to support I2C in i.MX27 Javier Martin
@ 2009-11-02  7:07 ` Heiko Schocher
  2009-11-02  8:10   ` javier Martin
  0 siblings, 1 reply; 4+ messages in thread
From: Heiko Schocher @ 2009-11-02  7:07 UTC (permalink / raw)
  To: u-boot

Hello Javier,

Javier Martin wrote:
> 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
[...]
> 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)))
> +

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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [u-boot] [PATCH][1/2] mx27: Add necessary defines and helper functions to support I2C in i.MX27.
  2009-11-02  8:10   ` javier Martin
@ 2009-11-02  7:35     ` Heiko Schocher
  0 siblings, 0 replies; 4+ messages in thread
From: Heiko Schocher @ 2009-11-02  7:35 UTC (permalink / raw)
  To: u-boot

Hello javier,

javier Martin wrote:
> 2009/11/2 Heiko Schocher <hs@denx.de>:
>> Hello Javier,
>>
>> Javier Martin wrote:
>>> 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
>> [...]
>>> 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)))
>>> +
>> 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.

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
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [u-boot] [PATCH][1/2] mx27: Add necessary defines and helper functions to support I2C in i.MX27.
  2009-11-02  7:07 ` Heiko Schocher
@ 2009-11-02  8:10   ` javier Martin
  2009-11-02  7:35     ` Heiko Schocher
  0 siblings, 1 reply; 4+ messages in thread
From: javier Martin @ 2009-11-02  8:10 UTC (permalink / raw)
  To: u-boot

2009/11/2 Heiko Schocher <hs@denx.de>:
> Hello Javier,
>
> Javier Martin wrote:
>> 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
> [...]
>> 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)))
>> +
>
> 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.


-- 
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-11-02  8:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-30 14:43 [U-Boot] [u-boot] [PATCH][1/2] mx27: Add necessary defines and helper functions to support I2C in i.MX27 Javier Martin
2009-11-02  7:07 ` Heiko Schocher
2009-11-02  8:10   ` javier Martin
2009-11-02  7:35     ` Heiko Schocher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox