Patchwork [U-Boot,v2] board/common: Add support for QIXIS read/write using i2c

login
register
mail settings
Submitter Prabhakar Kushwaha
Date Jan. 24, 2013, 3:59 a.m.
Message ID <1358999977-29203-1-git-send-email-prabhakar@freescale.com>
Download mbox | patch
Permalink /patch/215191/
State Accepted, archived
Delegated to: Andy Fleming
Headers show

Comments

Prabhakar Kushwaha - Jan. 24, 2013, 3:59 a.m.
QIXIS FPGA is accessable via both i2c and flash controller.
Only flash controller access is supported.

Add support of i2c based access. It is quite useful in the scenario
where either flash controller path is broken or not present.

Signed-off-by: Ruchika Gupta <ruchika.gupta@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
---
Changes for v2: Fix compilation error for other boards
	- Put function under CONFIG_SYS_I2C_FPGA_ADDR define 

 board/freescale/common/qixis.c |   14 ++++++++++++++
 board/freescale/common/qixis.h |    9 +++++++++
 2 files changed, 23 insertions(+)

Patch

diff --git a/board/freescale/common/qixis.c b/board/freescale/common/qixis.c
index c92902a..334fa57 100644
--- a/board/freescale/common/qixis.c
+++ b/board/freescale/common/qixis.c
@@ -14,8 +14,22 @@ 
 #include <common.h>
 #include <command.h>
 #include <asm/io.h>
+#include <i2c.h>
 #include "qixis.h"
 
+#ifdef CONFIG_SYS_I2C_FPGA_ADDR
+u8 qixis_read_i2c(unsigned int reg)
+{
+	return i2c_reg_read(CONFIG_SYS_I2C_FPGA_ADDR, reg);
+}
+
+void qixis_write_i2c(unsigned int reg, u8 value)
+{
+	u8 val = value;
+	i2c_reg_write(CONFIG_SYS_I2C_FPGA_ADDR, reg, val);
+}
+#endif
+
 u8 qixis_read(unsigned int reg)
 {
 	void *p = (void *)QIXIS_BASE;
diff --git a/board/freescale/common/qixis.h b/board/freescale/common/qixis.h
index b98b180..6916374 100644
--- a/board/freescale/common/qixis.h
+++ b/board/freescale/common/qixis.h
@@ -88,8 +88,17 @@  struct qixis {
 
 u8 qixis_read(unsigned int reg);
 void qixis_write(unsigned int reg, u8 value);
+#ifdef CONFIG_SYS_I2C_FPGA_ADDR
+u8 qixis_read_i2c(unsigned int reg);
+void qixis_write_i2c(unsigned int reg, u8 value);
+#endif
 
 #define QIXIS_READ(reg) qixis_read(offsetof(struct qixis, reg))
 #define QIXIS_WRITE(reg, value) qixis_write(offsetof(struct qixis, reg), value)
+#ifdef CONFIG_SYS_I2C_FPGA_ADDR
+#define QIXIS_READ_I2C(reg) qixis_read_i2c(offsetof(struct qixis, reg))
+#define QIXIS_WRITE_I2C(reg, value) \
+			qixis_write_i2c(offsetof(struct qixis, reg), value)
+#endif
 
 #endif