mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/4] eukrea_cpuimx27 : update timings
@ 2010-01-15 10:50 Eric Benard
  2010-01-15 10:50 ` [PATCH 2/4] Add necessary clocks & defines to get I2C support for i.MX27 Eric Benard
  2010-01-16 11:33 ` [PATCH 1/4] eukrea_cpuimx27 : update timings Sascha Hauer
  0 siblings, 2 replies; 5+ messages in thread
From: Eric Benard @ 2010-01-15 10:50 UTC (permalink / raw)
  To: s.hauer; +Cc: barebox

use optimized DDR, NOR & QuadUART timings

Signed-off-by: Eric Benard <eric@eukrea.com>
---
 board/eukrea_cpuimx27/eukrea_cpuimx27.c |   12 ++++++------
 board/eukrea_cpuimx27/lowlevel_init.S   |    4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/board/eukrea_cpuimx27/eukrea_cpuimx27.c b/board/eukrea_cpuimx27/eukrea_cpuimx27.c
index 6878044..629399f 100644
--- a/board/eukrea_cpuimx27/eukrea_cpuimx27.c
+++ b/board/eukrea_cpuimx27/eukrea_cpuimx27.c
@@ -198,9 +198,9 @@ static int eukrea_cpuimx27_devices_init(void)
 	eukrea_cpuimx27_mmu_init();
 
 	/* configure 16 bit nor flash on cs0 */
-	CS0U = 0x0000CC03;
-	CS0L = 0xa0330D01;
-	CS0A = 0x00220800;
+	CS0U = 0x00008F03;
+	CS0L = 0xA0330D01;
+	CS0A = 0x002208C0;
 
 	/* initizalize gpios */
 	for (i = 0; i < ARRAY_SIZE(mode); i++)
@@ -244,9 +244,9 @@ static int eukrea_cpuimx27_console_init(void)
 #endif
 	/* configure 8 bit UART on cs3 */
 	FMCR &= ~0x2;
-	CS3U = 0x0000DCF6;
-	CS3L = 0x444A4541;
-	CS3A = 0x44443302;
+	CS3U = 0x0000D603;
+	CS3L = 0x0D1D0D01;
+	CS3A = 0x00D20000;
 #ifdef CONFIG_DRIVER_SERIAL_NS16550
 	register_device(&quad_uart_serial_device);
 #endif
diff --git a/board/eukrea_cpuimx27/lowlevel_init.S b/board/eukrea_cpuimx27/lowlevel_init.S
index 4622af8..5295a8a 100644
--- a/board/eukrea_cpuimx27/lowlevel_init.S
+++ b/board/eukrea_cpuimx27/lowlevel_init.S
@@ -8,10 +8,10 @@
 
 #if defined CONFIG_EUKREA_CPUIMX27_SDRAM_256MB
 #define ROWS0	ESDCTL_ROW14
-#define CFG0	0x00695729
+#define CFG0	0x0029572D
 #elif defined CONFIG_EUKREA_CPUIMX27_SDRAM_128MB
 #define ROWS0	ESDCTL_ROW13
-#define CFG0	0x00395B28
+#define CFG0	0x00095728
 #endif
 
 #define ESDCTL0_VAL (ESDCTL0_SDE | ROWS0 | ESDCTL0_COL10)
-- 
1.6.3.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/4] Add necessary clocks & defines to get I2C support for i.MX27
  2010-01-15 10:50 [PATCH 1/4] eukrea_cpuimx27 : update timings Eric Benard
@ 2010-01-15 10:50 ` Eric Benard
  2010-01-15 10:50   ` [PATCH 3/4] I2C : add NS LP3972 PMIC support Eric Benard
  2010-01-16 11:33 ` [PATCH 1/4] eukrea_cpuimx27 : update timings Sascha Hauer
  1 sibling, 1 reply; 5+ messages in thread
From: Eric Benard @ 2010-01-15 10:50 UTC (permalink / raw)
  To: s.hauer; +Cc: barebox

Signed-off-by: Eric Benard <eric@eukrea.com>
---
 arch/arm/mach-imx/include/mach/imx27-regs.h |    1 +
 arch/arm/mach-imx/speed-imx27.c             |    5 +++++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/include/mach/imx27-regs.h b/arch/arm/mach-imx/include/mach/imx27-regs.h
index 33d67d6..6c31ccd 100644
--- a/arch/arm/mach-imx/include/mach/imx27-regs.h
+++ b/arch/arm/mach-imx/include/mach/imx27-regs.h
@@ -16,6 +16,7 @@
 #define IMX_UART2_BASE             (0x0b000 + IMX_IO_BASE)
 #define IMX_UART3_BASE             (0x0c000 + IMX_IO_BASE)
 #define IMX_UART4_BASE             (0x0d000 + IMX_IO_BASE)
+#define IMX_I2C1_BASE              (0x12000 + IMX_IO_BASE)
 #define IMX_GPIO_BASE              (0x15000 + IMX_IO_BASE)
 #define IMX_TIM4_BASE              (0x19000 + IMX_IO_BASE)
 #define IMX_TIM5_BASE              (0x1a000 + IMX_IO_BASE)
diff --git a/arch/arm/mach-imx/speed-imx27.c b/arch/arm/mach-imx/speed-imx27.c
index deaca1e..cdcd419 100644
--- a/arch/arm/mach-imx/speed-imx27.c
+++ b/arch/arm/mach-imx/speed-imx27.c
@@ -154,6 +154,11 @@ ulong imx_get_lcdclk(void)
 	return imx_get_perclk3();
 }
 
+ulong imx_get_i2cclk(void)
+{
+	return imx_get_ipgclk();
+}
+
 void imx_dump_clocks(void)
 {
 	uint32_t	cid = CID;
-- 
1.6.3.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 3/4] I2C : add NS LP3972 PMIC support
  2010-01-15 10:50 ` [PATCH 2/4] Add necessary clocks & defines to get I2C support for i.MX27 Eric Benard
@ 2010-01-15 10:50   ` Eric Benard
  2010-01-15 10:50     ` [PATCH 4/4] Eukrea CPUIMX27 : add I2C and LP3972 support Eric Benard
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Benard @ 2010-01-15 10:50 UTC (permalink / raw)
  To: s.hauer; +Cc: barebox

Signed-off-by: Eric Benard <eric@eukrea.com>
---
 drivers/i2c/Kconfig  |    3 +
 drivers/i2c/Makefile |    1 +
 drivers/i2c/lp3972.c |  110 ++++++++++++++++++++++++++++++++++++++++++++++++++
 include/i2c/lp3972.h |    7 +++
 4 files changed, 121 insertions(+), 0 deletions(-)
 create mode 100644 drivers/i2c/lp3972.c
 create mode 100644 include/i2c/lp3972.h

diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index 46723ed..f1b2949 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -13,4 +13,7 @@ config DRIVER_I2C_MC13892
 config DRIVER_I2C_MC9SDZ60
 	bool "MC9SDZ60 driver"
 
+config DRIVER_I2C_LP3972
+	bool "LP3972 driver"
+
 endif
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 5dd642f..62d030b 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -4,3 +4,4 @@ obj-$(CONFIG_DRIVER_I2C_IMX) += i2c-imx.o
 
 obj-$(CONFIG_DRIVER_I2C_MC13892) += mc13892.o
 obj-$(CONFIG_DRIVER_I2C_MC9SDZ60) += mc9sdz60.o
+obj-$(CONFIG_DRIVER_I2C_LP3972) += lp3972.o
diff --git a/drivers/i2c/lp3972.c b/drivers/i2c/lp3972.c
new file mode 100644
index 0000000..9826699
--- /dev/null
+++ b/drivers/i2c/lp3972.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2007 Sascha Hauer, Pengutronix
+ *               2009 Marc Kleine-Budde <mkl@pengutronix.de>
+ *               2009 Eric Benard <eric@eukrea.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+
+#include <common.h>
+#include <init.h>
+#include <driver.h>
+#include <xfuncs.h>
+#include <errno.h>
+
+#include <i2c/i2c.h>
+
+#include <asm/byteorder.h>
+
+#define DRIVERNAME		"lp3972"
+
+struct lp_priv {
+	struct cdev		cdev;
+	struct i2c_client	*client;
+};
+
+#define to_lp_priv(a)		container_of(a, struct lp_priv, cdev)
+
+static struct lp_priv *lp_dev;
+
+struct i2c_client *lp3972_get_client(void)
+{
+	if (!lp_dev)
+		return NULL;
+
+	return lp_dev->client;
+}
+
+static u32 lp_read_reg(struct lp_priv *lp, int reg)
+{
+	u8 buf;
+
+	i2c_read_reg(lp->client, reg, &buf, sizeof(buf));
+
+	return buf;
+}
+
+static ssize_t lp_read(struct cdev *cdev, void *_buf, size_t count, ulong offset, ulong flags)
+{
+	struct lp_priv *priv = to_lp_priv(cdev);
+	int i = count;
+	u8 *buf = _buf;
+
+	while (i) {
+		*buf = lp_read_reg(priv, offset);
+		buf++;
+		i--;
+		offset++;
+	}
+
+	return count;
+}
+
+static struct file_operations lp_fops = {
+	.lseek	= dev_lseek_default,
+	.read	= lp_read,
+};
+
+static int lp_probe(struct device_d *dev)
+{
+	if (lp_dev)
+		return -EBUSY;
+
+	lp_dev = xzalloc(sizeof(struct lp_priv));
+	lp_dev->cdev.name = DRIVERNAME;
+	lp_dev->client = to_i2c_client(dev);
+	lp_dev->cdev.size = 256;
+	lp_dev->cdev.dev = dev;
+	lp_dev->cdev.ops = &lp_fops;
+
+	devfs_create(&lp_dev->cdev);
+
+	return 0;
+}
+
+static struct driver_d lp_driver = {
+	.name  = DRIVERNAME,
+	.probe = lp_probe,
+};
+
+static int lp_init(void)
+{
+	register_driver(&lp_driver);
+	return 0;
+}
+
+device_initcall(lp_init);
diff --git a/include/i2c/lp3972.h b/include/i2c/lp3972.h
new file mode 100644
index 0000000..edb5801
--- /dev/null
+++ b/include/i2c/lp3972.h
@@ -0,0 +1,7 @@
+#ifndef __ASM_ARCH_LP3972_H
+#define __ASM_ARCH_LP3972_H
+
+extern struct i2c_client *lp3972_get_client(void);
+
+#endif /* __ASM_ARCH_LP3972_H */
+
-- 
1.6.3.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 4/4] Eukrea CPUIMX27 : add I2C and LP3972 support
  2010-01-15 10:50   ` [PATCH 3/4] I2C : add NS LP3972 PMIC support Eric Benard
@ 2010-01-15 10:50     ` Eric Benard
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Benard @ 2010-01-15 10:50 UTC (permalink / raw)
  To: s.hauer; +Cc: barebox

This allows to properly setup the voltage on LCD pins at boot.

Signed-off-by: Eric Benard <eric@eukrea.com>
---
 board/eukrea_cpuimx27/eukrea_cpuimx27.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/board/eukrea_cpuimx27/eukrea_cpuimx27.c b/board/eukrea_cpuimx27/eukrea_cpuimx27.c
index 629399f..0908dca 100644
--- a/board/eukrea_cpuimx27/eukrea_cpuimx27.c
+++ b/board/eukrea_cpuimx27/eukrea_cpuimx27.c
@@ -21,6 +21,7 @@
  */
 
 #include <common.h>
+#include <errno.h>
 #include <net.h>
 #include <cfi_flash.h>
 #include <init.h>
@@ -42,6 +43,8 @@
 #include <mach/imx-pll.h>
 #include <ns16550.h>
 #include <asm/mmu.h>
+#include <i2c/i2c.h>
+#include <i2c/lp3972.h>
 
 static struct device_d cfi_dev = {
 	.name     = "cfi_flash",
@@ -140,6 +143,17 @@ static struct device_d quad_uart_serial_device = {
 };
 #endif
 
+static struct i2c_board_info i2c_devices[] = {
+	{
+		I2C_BOARD_INFO("lp3972", 0x34),
+	},
+};
+
+static struct device_d i2c_dev = {
+	.name		= "i2c-imx",
+	.map_base	= IMX_I2C1_BASE,
+};
+
 #ifdef CONFIG_MMU
 static void eukrea_cpuimx27_mmu_init(void)
 {
@@ -187,6 +201,8 @@ static int eukrea_cpuimx27_devices_init(void)
 		PD15_AOUT_FEC_COL,
 		PD16_AIN_FEC_TX_ER,
 		PF23_AIN_FEC_TX_EN,
+		PD17_PF_I2C_DATA,
+		PD18_PF_I2C_CLK,
 #ifdef CONFIG_DRIVER_SERIAL_IMX
 		PE12_PF_UART1_TXD,
 		PE13_PF_UART1_RXD,
@@ -213,6 +229,10 @@ static int eukrea_cpuimx27_devices_init(void)
 	register_device(&nand_dev);
 	register_device(&sdram_dev);
 
+	PCCR0 |= PCCR0_I2C1_EN;
+	i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices));
+	register_device(&i2c_dev);
+
 	devfs_add_partition("nor0", 0x00000, 0x40000, PARTITION_FIXED, "self0");
 	devfs_add_partition("nor0", 0x40000, 0x20000, PARTITION_FIXED, "env0");
 	protect_file("/dev/env0", 1);
@@ -257,9 +277,18 @@ console_initcall(eukrea_cpuimx27_console_init);
 
 static int eukrea_cpuimx27_late_init(void)
 {
+	struct i2c_client *client;
+	u8 reg[1];
+
 	console_flush();
 	register_device(&fec_dev);
 
+	client = lp3972_get_client();
+	if (!client)
+		return -ENODEV;
+	reg[0] = 0xa0;
+	i2c_write_reg(client, 0x39, reg, sizeof(reg));
+
 	return 0;
 }
 
-- 
1.6.3.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/4] eukrea_cpuimx27 : update timings
  2010-01-15 10:50 [PATCH 1/4] eukrea_cpuimx27 : update timings Eric Benard
  2010-01-15 10:50 ` [PATCH 2/4] Add necessary clocks & defines to get I2C support for i.MX27 Eric Benard
@ 2010-01-16 11:33 ` Sascha Hauer
  1 sibling, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2010-01-16 11:33 UTC (permalink / raw)
  To: Eric Benard; +Cc: barebox

Hi Eric,

On Fri, Jan 15, 2010 at 11:50:16AM +0100, Eric Benard wrote:
> use optimized DDR, NOR & QuadUART timings

Ok, applied for -next.

Sascha

> 
> Signed-off-by: Eric Benard <eric@eukrea.com>
> ---
>  board/eukrea_cpuimx27/eukrea_cpuimx27.c |   12 ++++++------
>  board/eukrea_cpuimx27/lowlevel_init.S   |    4 ++--
>  2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/board/eukrea_cpuimx27/eukrea_cpuimx27.c b/board/eukrea_cpuimx27/eukrea_cpuimx27.c
> index 6878044..629399f 100644
> --- a/board/eukrea_cpuimx27/eukrea_cpuimx27.c
> +++ b/board/eukrea_cpuimx27/eukrea_cpuimx27.c
> @@ -198,9 +198,9 @@ static int eukrea_cpuimx27_devices_init(void)
>  	eukrea_cpuimx27_mmu_init();
>  
>  	/* configure 16 bit nor flash on cs0 */
> -	CS0U = 0x0000CC03;
> -	CS0L = 0xa0330D01;
> -	CS0A = 0x00220800;
> +	CS0U = 0x00008F03;
> +	CS0L = 0xA0330D01;
> +	CS0A = 0x002208C0;
>  
>  	/* initizalize gpios */
>  	for (i = 0; i < ARRAY_SIZE(mode); i++)
> @@ -244,9 +244,9 @@ static int eukrea_cpuimx27_console_init(void)
>  #endif
>  	/* configure 8 bit UART on cs3 */
>  	FMCR &= ~0x2;
> -	CS3U = 0x0000DCF6;
> -	CS3L = 0x444A4541;
> -	CS3A = 0x44443302;
> +	CS3U = 0x0000D603;
> +	CS3L = 0x0D1D0D01;
> +	CS3A = 0x00D20000;
>  #ifdef CONFIG_DRIVER_SERIAL_NS16550
>  	register_device(&quad_uart_serial_device);
>  #endif
> diff --git a/board/eukrea_cpuimx27/lowlevel_init.S b/board/eukrea_cpuimx27/lowlevel_init.S
> index 4622af8..5295a8a 100644
> --- a/board/eukrea_cpuimx27/lowlevel_init.S
> +++ b/board/eukrea_cpuimx27/lowlevel_init.S
> @@ -8,10 +8,10 @@
>  
>  #if defined CONFIG_EUKREA_CPUIMX27_SDRAM_256MB
>  #define ROWS0	ESDCTL_ROW14
> -#define CFG0	0x00695729
> +#define CFG0	0x0029572D
>  #elif defined CONFIG_EUKREA_CPUIMX27_SDRAM_128MB
>  #define ROWS0	ESDCTL_ROW13
> -#define CFG0	0x00395B28
> +#define CFG0	0x00095728
>  #endif
>  
>  #define ESDCTL0_VAL (ESDCTL0_SDE | ROWS0 | ESDCTL0_COL10)
> -- 
> 1.6.3.3
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2010-01-16 11:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-15 10:50 [PATCH 1/4] eukrea_cpuimx27 : update timings Eric Benard
2010-01-15 10:50 ` [PATCH 2/4] Add necessary clocks & defines to get I2C support for i.MX27 Eric Benard
2010-01-15 10:50   ` [PATCH 3/4] I2C : add NS LP3972 PMIC support Eric Benard
2010-01-15 10:50     ` [PATCH 4/4] Eukrea CPUIMX27 : add I2C and LP3972 support Eric Benard
2010-01-16 11:33 ` [PATCH 1/4] eukrea_cpuimx27 : update timings Sascha Hauer

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