Skip to contentSkip to conversation

EXYNOS5: FDT Support for I2C

PATCH Superseded Rajeshwari Shinde 5 participants 23 messages Nov 14, 2012 – Nov 20, 2012

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover EXYNOS5: FDT Support for I2C

This patch set adds FDT support for I2C driver and API's to acess the bus number using the fdt node and also reset the port.

Changes in V2:
- Baord i2c init moved to I2C driver in case of FDT.
- Added Periph id to device node.
- Modified i2c_get_bus_num_fdt api to compare using node.
Rajeshwari Shinde (6):
EXYNOS5: FDT: Add I2C device node data
EXYNOS5 : FDT: Add Aliases for I2C device
EXYNOS5: FDT: Add compatible string for I2C
FDT: Api to find compatible id for a given node
I2C: Driver changes for FDT support
SMDK5250: Initialise I2C using FDT

 arch/arm/dts/exynos-periph-id.dtsi        |   35 +++++++++++
 arch/arm/dts/exynos5250.dtsi              |   73 +++++++++++++++++++++++
 board/samsung/dts/exynos5250-smdk5250.dts |   11 ++++
 board/samsung/smdk5250/smdk5250.c         |   20 +------
 drivers/i2c/s3c24x0_i2c.c                 |   90 ++++++++++++++++++++++++++++-
 drivers/i2c/s3c24x0_i2c.h                 |    8 +++
 include/fdtdec.h                          |   15 +++++
 include/i2c.h                             |   26 ++++++++
 lib/fdtdec.c                              |   13 ++++
 9 files changed, 271 insertions(+), 20 deletions(-)
 create mode 100644 arch/arm/dts/exynos-periph-id.dtsi
Signature · 1 line
1.7.4.4
#1 lore raw

PATCH v2 1/6 EXYNOS5: FDT: Add I2C device node data

Add I2C device node data for exynos

---
Changes in V2:
Added Periph id to the I2C device node

 arch/arm/dts/exynos-periph-id.dtsi |   35 +++++++++++++++++
 arch/arm/dts/exynos5250.dtsi       |   73 ++++++++++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/dts/exynos-periph-id.dtsi
arch/arm/dts/exynos-periph-id.dtsi new file +35 -0
new file mode 100644
index 0000000..cfe2c3d
@@ -0,0 +1,35 @@
+/*
+ * U-Boot Peripheral ID header file for Exynos boards
+ *
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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
+ */
+
+/*
+ * These values come from arch/arm/include/arch-exynos5/periph.h. For
+ * now they must be manually kept in sync.
+ */
+/define/ PERIPH_ID_I2C0 <0>;
+/define/ PERIPH_ID_I2C1 <1>;
+/define/ PERIPH_ID_I2C2 <2>;
+/define/ PERIPH_ID_I2C3 <3>;
+/define/ PERIPH_ID_I2C4 <4>;
+/define/ PERIPH_ID_I2C5 <5>;
+/define/ PERIPH_ID_I2C6 <6>;
+/define/ PERIPH_ID_I2C7 <7>;
arch/arm/dts/exynos5250.dtsi +73 -0

83 lines not on this page · raw message

Signature · 1 line
1.7.4.4
#2 lore raw

PATCH v2 1/6 EXYNOS5: FDT: Add I2C device node data

Hello Rajeshwari

Quoted 11 lines · Rajeshwari Shinde

Add I2C device node data for exynos

---
Changes in V2:
Added Periph id to the I2C device node

  arch/arm/dts/exynos-periph-id.dtsi |   35 +++++++++++++++++
  arch/arm/dts/exynos5250.dtsi       |   73 ++++++++++++++++++++++++++++++++++++
  2 files changed, 108 insertions(+), 0 deletions(-)

create mode 100644 arch/arm/dts/exynos-periph-id.dtsi

I tried to apply this patch to current mainline head commit 59852d03867108217fe88e3bfc3e1e9cedfe63c5
Merge: 22b6fcb b3e5cd1
Author: Tom Rini <[email protected]>
Date: Fri Nov 9 08:47:25 2012 -0700

Merge branch 'master' of git://www.denx.de/git/u-boot-microblaze

but I got this error:

[hs at pollux u-boot-i2c]$ git am index.html
Applying: EXYNOS5: FDT: Add I2C device node data
error: arch/arm/dts/exynos5250.dtsi: does not exist in index Patch failed at 0001 EXYNOS5: FDT: Add I2C device node data When you have resolved this problem run "git am --resolved". If you would prefer to skip this patch, instead run "git am --skip". To restore the original branch and stop patching run "git am --abort". [hs at pollux u-boot-i2c]$

Against which tree is this patchset? Should it go through the samsung tree from Minkyu Kang found here:

http://git.denx.de/u-boot-samsung.git

? If so, I send my Acked-by for this patchset ...

bye,
Heiko

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

PATCH v2 1/6 EXYNOS5: FDT: Add I2C device node data

Hi Heiko,

Thank you for Acking the patchset.
It is based on u-boot-samsung, where the basic FDT support patches for Exynos are submitted.

Regards
Rajeshwari Shinde.

Quoted 55 lines · Heiko Schocher

Hello Rajeshwari

Quoted 5 lines · Rajeshwari Shinde

Add I2C device node data for exynos

Quoted 8 lines

---
Changes in V2:
Added Periph id to the I2C device node

  arch/arm/dts/exynos-periph-id.dtsi |   35 +++++++++++++++++
  arch/arm/dts/exynos5250.dtsi       |   73
++++++++++++++++++++++++++++++++++++
  2 files changed, 108 insertions(+), 0 deletions(-)

create mode 100644 arch/arm/dts/exynos-periph-id.dtsi

I tried to apply this patch to current mainline head commit 59852d03867108217fe88e3bfc3e1e9cedfe63c5
Merge: 22b6fcb b3e5cd1
Author: Tom Rini <[email protected]>
Date: Fri Nov 9 08:47:25 2012 -0700

Merge branch 'master' of git://www.denx.de/git/u-boot-microblaze

but I got this error:

[hs at pollux u-boot-i2c]$ git am index.html
Applying: EXYNOS5: FDT: Add I2C device node data
error: arch/arm/dts/exynos5250.dtsi: does not exist in index Patch failed at 0001 EXYNOS5: FDT: Add I2C device node data When you have resolved this problem run "git am --resolved". If you would prefer to skip this patch, instead run "git am --skip". To restore the original branch and stop patching run "git am --abort". [hs at pollux u-boot-i2c]$

Against which tree is this patchset? Should it go through the samsung tree from Minkyu Kang found here:

http://git.denx.de/u-boot-samsung.git

? If so, I send my Acked-by for this patchset ...

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

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#4 lore raw

PATCH v2 1/6 EXYNOS5: FDT: Add I2C device node data

Dear Heiko,

Quoted 55 lines · Rajeshwari Birje

Hi Heiko,

Thank you for Acking the patchset.
It is based on u-boot-samsung, where the basic FDT support patches for Exynos are submitted.

Regards
Rajeshwari Shinde.

Quoted 45 lines · Heiko Schocher

Hello Rajeshwari

Quoted 5 lines · Rajeshwari Shinde

Add I2C device node data for exynos

Quoted 8 lines

---
Changes in V2:
Added Periph id to the I2C device node

  arch/arm/dts/exynos-periph-id.dtsi |   35 +++++++++++++++++
  arch/arm/dts/exynos5250.dtsi       |   73
++++++++++++++++++++++++++++++++++++
  2 files changed, 108 insertions(+), 0 deletions(-)

create mode 100644 arch/arm/dts/exynos-periph-id.dtsi

I tried to apply this patch to current mainline head commit 59852d03867108217fe88e3bfc3e1e9cedfe63c5
Merge: 22b6fcb b3e5cd1
Author: Tom Rini <[email protected]>
Date: Fri Nov 9 08:47:25 2012 -0700

Merge branch 'master' of git://www.denx.de/git/u-boot-microblaze

but I got this error:

[hs at pollux u-boot-i2c]$ git am index.html
Applying: EXYNOS5: FDT: Add I2C device node data
error: arch/arm/dts/exynos5250.dtsi: does not exist in index Patch failed at 0001 EXYNOS5: FDT: Add I2C device node data When you have resolved this problem run "git am --resolved". If you would prefer to skip this patch, instead run "git am --skip". To restore the original branch and stop patching run "git am --abort". [hs at pollux u-boot-i2c]$

Against which tree is this patchset? Should it go through the samsung tree from Minkyu Kang found here:

http://git.denx.de/u-boot-samsung.git

? If so, I send my Acked-by for this patchset ...

I'll merge this patchset to samsung tree.
Please send your Ack.

Thanks.
Minkyu Kang.

#5 lore raw

PATCH v2 1/6 EXYNOS5: FDT: Add I2C device node data

In reply to Rajeshwari Shinde

Hello Rajeshwari,

Quoted 11 lines · Rajeshwari Shinde

Add I2C device node data for exynos

---
Changes in V2:
Added Periph id to the I2C device node

  arch/arm/dts/exynos-periph-id.dtsi |   35 +++++++++++++++++
  arch/arm/dts/exynos5250.dtsi       |   73 ++++++++++++++++++++++++++++++++++++
  2 files changed, 108 insertions(+), 0 deletions(-)

create mode 100644 arch/arm/dts/exynos-periph-id.dtsi

bye,
Heiko

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

PATCH v2 1/6 EXYNOS5: FDT: Add I2C device node data

Hi,

Quoted 19 lines · Heiko Schocher

Hello Rajeshwari,

Quoted 5 lines · Rajeshwari Shinde

Add I2C device node data for exynos

Quoted 8 lines

---
Changes in V2:
Added Periph id to the I2C device node

  arch/arm/dts/exynos-periph-id.dtsi |   35 +++++++++++++++++
  arch/arm/dts/exynos5250.dtsi       |   73
++++++++++++++++++++++++++++++++++++
  2 files changed, 108 insertions(+), 0 deletions(-)

create mode 100644 arch/arm/dts/exynos-periph-id.dtsi

Quoted 1 line

I'm sorry to say that there is one problem with this. It is using a non-standard dtc feature (Stephen Warren's symbolic work), so I think we should wait until Rajeshwari updates it to avoid that. I believe he will do that soon.

Regards,
Simon

Quoted 7 lines

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

#7 lore raw

PATCH v2 1/6 EXYNOS5: FDT: Add I2C device node data

Quoted 22 lines · Simon Glass

Hi,

Quoted 19 lines · Heiko Schocher

Hello Rajeshwari,

Quoted 13 lines · Rajeshwari Shinde

Add I2C device node data for exynos

---
Changes in V2:
Added Periph id to the I2C device node

  arch/arm/dts/exynos-periph-id.dtsi |   35 +++++++++++++++++
  arch/arm/dts/exynos5250.dtsi       |   73
++++++++++++++++++++++++++++++++++++
  2 files changed, 108 insertions(+), 0 deletions(-)

create mode 100644 arch/arm/dts/exynos-periph-id.dtsi

Quoted 7 lines
Quoted 1 line

I'm sorry to say that there is one problem with this. It is using a non-standard dtc feature (Stephen Warren's symbolic work), so I think we should wait until Rajeshwari updates it to avoid that. I believe he will do that soon.

OK.

Thanks.
Minkyu Kang.

#8 lore raw

PATCH v2 2/6 EXYNOS5 : FDT: Add Aliases for I2C device

In reply to Rajeshwari Shinde

This patch adds aliases for I2C.

---
Changes in V2:
- None.

 board/samsung/dts/exynos5250-smdk5250.dts |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
board/samsung/dts/exynos5250-smdk5250.dts +11 -0
index 2d3ecca..8722b36 100644
@@ -16,6 +16,17 @@
 	model = "SAMSUNG SMDK5250 board based on EXYNOS5250";
 	compatible = "samsung,smdk5250", "samsung,exynos5250";
 
+	aliases {
+		i2c0 = "/i2c at 12c60000";
+		i2c1 = "/i2c at 12c70000";
+		i2c2 = "/i2c at 12c80000";
+		i2c3 = "/i2c at 12c90000";
+		i2c4 = "/i2c at 12ca0000";
+		i2c5 = "/i2c at 12cb0000";
+		i2c6 = "/i2c at 12cc0000";
+		i2c7 = "/i2c at 12cd0000";
+	};
+
 	sromc at 12250000 {
 		bank = <1>;
 		srom-timing = <1 9 12 1 6 1 1>;
Signature · 1 line
1.7.4.4
#9 lore raw

PATCH v2 2/6 EXYNOS5 : FDT: Add Aliases for I2C device

Hello Rajeshwari,

Quoted 9 lines · Rajeshwari Shinde

This patch adds aliases for I2C.

---
Changes in V2:
- None.

  board/samsung/dts/exynos5250-smdk5250.dts |   11 +++++++++++
  1 files changed, 11 insertions(+), 0 deletions(-)

bye,
Heiko

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

PATCH v2 3/6 EXYNOS5: FDT: Add compatible string for I2C

In reply to Rajeshwari Shinde

Add required compatible information for I2C driver.

---
Changes in V2:
- None

 include/fdtdec.h |    1 +
 lib/fdtdec.c     |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)
include/fdtdec.h +1 -0
index 180dfff..f9aac31 100644
@@ -69,6 +69,7 @@ enum fdt_compat_id {
 	COMPAT_SMSC_LAN9215,		/* SMSC 10/100 Ethernet LAN9215 */
 	COMPAT_SAMSUNG_EXYNOS5_SROMC,	/* Exynos5 SROMC */
 	COMPAT_SAMSUNG_EXYNOS_TMU,	/* Exynos TMU */
+	COMPAT_SAMSUNG_S3C2440_I2C,	/* Exynos I2C Controller */
 
 	COMPAT_COUNT,
 };
lib/fdtdec.c +1 -0
index 8e5ed21..6e8c24c 100644
@@ -46,6 +46,7 @@ static const char * const compat_names[COMPAT_COUNT] = {
 	COMPAT(SMSC_LAN9215, "smsc,lan9215"),
 	COMPAT(SAMSUNG_EXYNOS5_SROMC, "samsung,exynos-sromc"),
 	COMPAT(SAMSUNG_EXYNOS_TMU, "samsung,exynos-tmu"),
+	COMPAT(SAMSUNG_S3C2440_I2C, "samsung,s3c2440-i2c"),
 };
 
 const char *fdtdec_get_compatible(enum fdt_compat_id id)
Signature · 1 line
1.7.4.4
#11 lore raw

PATCH v2 3/6 EXYNOS5: FDT: Add compatible string for I2C

Hello Rajeshwari,

Quoted 10 lines · Rajeshwari Shinde

Add required compatible information for I2C driver.

---
Changes in V2:
- None

  include/fdtdec.h |    1 +
  lib/fdtdec.c     |    1 +
  2 files changed, 2 insertions(+), 0 deletions(-)

bye,
Heiko

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

PATCH v2 4/6 FDT: Api to find compatible id for a given node

In reply to Rajeshwari Shinde

This patch adds api to find compatible id for a given FDT node

---
Changes in V2:
- None

 include/fdtdec.h |   14 ++++++++++++++
 lib/fdtdec.c     |   12 ++++++++++++
 2 files changed, 26 insertions(+), 0 deletions(-)
include/fdtdec.h +14 -0
index f9aac31..d501d7e 100644
@@ -389,4 +389,18 @@ int fdtdec_get_byte_array(const void *blob, int node, const char *prop_name,
  */
 const u8 *fdtdec_locate_byte_array(const void *blob, int node,
 			     const char *prop_name, int count);
+
+/**
+ * Find the compatible ID for a given node.
+ *
+ * Generally each node has at least one compatible string attached to it.
+ * This function looks through our list of known compatible strings and
+ * returns the corresponding ID which matches the compatible string.
+ *
+ * @param blob          FDT blob to use
+ * @param node          Node containing compatible string to find
+ * @return compatible ID, or COMPAT_UNKNOWN if we cannot find a match
+ */
+enum fdt_compat_id fdtdec_lookup(const void *blob, int node);
+
 #endif
lib/fdtdec.c +12 -0
index 6e8c24c..dbfca1a 100644
@@ -516,3 +516,15 @@ const u8 *fdtdec_locate_byte_array(const void *blob, int node,
 		return NULL;
 	return cell;
 }
+
+enum fdt_compat_id fdtdec_lookup(const void *blob, int node)
+{
+	enum fdt_compat_id id;
+
+	/* Search our drivers */
+	for (id = COMPAT_UNKNOWN; id < COMPAT_COUNT; id++)
+		if (0 == fdt_node_check_compatible(blob, node,
+				compat_names[id]))
+			return id;
+	return COMPAT_UNKNOWN;
+}
Signature · 1 line
1.7.4.4
#13 lore raw

PATCH v2 4/6 FDT: Api to find compatible id for a given node

Hello Rajeshwari,

Quoted 11 lines · Rajeshwari Shinde

This patch adds api to find compatible id for a given FDT node

---
Changes in V2:
- None

  include/fdtdec.h |   14 ++++++++++++++
  lib/fdtdec.c     |   12 ++++++++++++
  2 files changed, 26 insertions(+), 0 deletions(-)

bye,
Heiko

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

PATCH v2 5/6 I2C: Driver changes for FDT support

In reply to Rajeshwari Shinde

Functions added to get the I2C bus number and reset I2C bus using FDT node.

---
Changes in V2:
- Added periph id to I2C bus structure.
- Modified i2c_get_bus_num_fdt function to compare with node.
- Board i2c init moved to driver in case of FDT.

 drivers/i2c/s3c24x0_i2c.c |   90 ++++++++++++++++++++++++++++++++++++++++++++-
 drivers/i2c/s3c24x0_i2c.h |    8 ++++
 include/i2c.h             |   26 +++++++++++++
 3 files changed, 123 insertions(+), 1 deletions(-)
drivers/i2c/s3c24x0_i2c.c +89 -1
index 9bc4c7f..840585d 100644
@@ -27,9 +27,11 @@
  */
 
 #include <common.h>
+#include <fdtdec.h>
 #ifdef CONFIG_EXYNOS5
 #include <asm/arch/clk.h>
 #include <asm/arch/cpu.h>
+#include <asm/arch/pinmux.h>
 #else
 #include <asm/arch/s3c24x0_cpu.h>
 #endif
@@ -60,7 +62,14 @@
 #define I2C_TIMEOUT 1		/* 1 second */
 
 
-static unsigned int g_current_bus;	/* Stores Current I2C Bus */
+/*
+ * For SPL boot some boards need i2c before SDRAM is initialised so force
+ * variables to live in SRAM
+ */
+static unsigned int g_current_bus __attribute__((section(".data")));
+static struct s3c24x0_i2c_bus i2c_bus[CONFIG_MAX_I2C_NUM]
+			__attribute__((section(".data")));
+static int i2c_busses __attribute__((section(".data")));
 
 #ifndef CONFIG_EXYNOS5
 static int GetI2CSDA(void)
@@ -507,4 +516,83 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
 		(i2c, I2C_WRITE, chip << 1, &xaddr[4 - alen], alen, buffer,
 		 len) != 0);
 }
+
+#ifdef CONFIG_OF_CONTROL
+void board_i2c_init(const void *blob)
+{
+
+	int node_list[CONFIG_MAX_I2C_NUM];
+	int count, i;
+
+	count = fdtdec_find_aliases_for_id(blob, "i2c",
+		COMPAT_SAMSUNG_S3C2440_I2C, node_list,
+		CONFIG_MAX_I2C_NUM);
+	for (i = 0; i < count; i++) {
+		struct s3c24x0_i2c_bus *bus;
+		int node = node_list[i];
+
+		if (node < 0)
+			continue;
+		bus = &i2c_bus[i];
+		bus->regs = (struct s3c24x0_i2c *)
+			fdtdec_get_addr(blob, node, "reg");
+		bus->id = (enum periph_id)
+			fdtdec_get_int(blob, node, "samsung,periph-id", -1);
+		bus->node = node;
+		bus->bus_num = i2c_busses++;
+		exynos_pinmux_config(bus->id, 0);
+	}
+
+}
+
+static struct s3c24x0_i2c_bus *get_bus(unsigned int bus_idx)
+{
+	if (bus_idx < i2c_busses)
+		return &i2c_bus[bus_idx];
+	debug("Undefined bus: %d\n", bus_idx);
+	return NULL;
+}
+
+int i2c_get_bus_num_fdt(const void *blob, int node)
+{
+	enum fdt_compat_id compat;
+	int i;
+
+	compat = fdtdec_lookup(blob, node);
+	if (compat != COMPAT_SAMSUNG_S3C2440_I2C) {
+		debug("%s: Not a supported I2C node\n", __func__);
+		return -1;
+	}
+	for (i = 0; i < i2c_busses; i++) {
+		if (node == i2c_bus[i].node)
+			return i;
+	}
+
+	debug("%s: Can't find any matched I2C bus\n", __func__);
+	return -1;
+}
+
+int i2c_reset_port_fdt(const void *blob, int node)
+{
+	struct s3c24x0_i2c_bus *i2c;
+
+	int bus;
+
+	bus = i2c_get_bus_num_fdt(blob, node);
+	if (bus < 0) {
+		debug("could not get bus for node %d\n", node);
+		return -1;
+	}
+	i2c = get_bus(bus);
+	if (!i2c) {
+		debug("get_bus() failed for node node %d\n", node);
+		return -1;
+	}
+
+	i2c_ch_init(i2c->regs, CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+
+	return 0;
+}
+#endif
+
 #endif /* CONFIG_HARD_I2C */
drivers/i2c/s3c24x0_i2c.h +8 -0
index 2dd4b06..1243bf1 100644
@@ -30,4 +30,12 @@ struct s3c24x0_i2c {
 	u32	iicds;
 	u32	iiclc;
 };
+
+struct s3c24x0_i2c_bus {
+	int node;	/* device tree node */
+	int bus_num;	/* i2c bus number */
+	struct s3c24x0_i2c *regs;
+	enum periph_id id;
+};
+
 #endif /* _S3C24X0_I2C_H */
include/i2c.h +26 -0
index 16f099d..efb097f 100644
@@ -262,4 +262,30 @@ extern int get_multi_scl_pin(void);
 extern int get_multi_sda_pin(void);
 extern int multi_i2c_init(void);
 #endif
+
+/**
+ * Get FDT values for i2c bus.
+ *
+ * @param blob  Device tree blbo
+ * @return the number of I2C bus
+ */
+void board_i2c_init(const void *blob);
+
+/**
+ * Find the I2C bus number by given a FDT I2C node.
+ *
+ * @param blob  Device tree blbo
+ * @param node  FDT I2C node to find
+ * @return the number of I2C bus (zero based), or -1 on error
+ */
+int i2c_get_bus_num_fdt(const void *blob, int node);
+
+/**
+ * Reset the I2C bus represented by the given a FDT I2C node.
+ *
+ * @param blob  Device tree blbo
+ * @param node  FDT I2C node to find
+ * @return 0 if port was reset, -1 if not found
+ */
+int i2c_reset_port_fdt(const void *blob, int node);
 #endif	/* _I2C_H_ */
Signature · 1 line
1.7.4.4
#15 lore raw

PATCH v2 5/6 I2C: Driver changes for FDT support

Hi,

Quoted 10 lines · Rajeshwari Shinde

Functions added to get the I2C bus number and reset I2C bus using FDT node.

---
Changes in V2:
- Added periph id to I2C bus structure.
- Modified i2c_get_bus_num_fdt function to compare with node.
- Board i2c init moved to driver in case of FDT.

This looks good to me, apart from a small thing you can probably drop below.

Quoted 78 lines
 drivers/i2c/s3c24x0_i2c.c |   90 ++++++++++++++++++++++++++++++++++++++++++++-
 drivers/i2c/s3c24x0_i2c.h |    8 ++++
 include/i2c.h             |   26 +++++++++++++
 3 files changed, 123 insertions(+), 1 deletions(-)
drivers/i2c/s3c24x0_i2c.c +47 -1
index 9bc4c7f..840585d 100644
@@ -27,9 +27,11 @@
  */
 
 #include <common.h>
+#include <fdtdec.h>
 #ifdef CONFIG_EXYNOS5
 #include <asm/arch/clk.h>
 #include <asm/arch/cpu.h>
+#include <asm/arch/pinmux.h>
 #else
 #include <asm/arch/s3c24x0_cpu.h>
 #endif
@@ -60,7 +62,14 @@
 #define I2C_TIMEOUT 1          /* 1 second */
 
 
-static unsigned int g_current_bus;     /* Stores Current I2C Bus */
+/*
+ * For SPL boot some boards need i2c before SDRAM is initialised so force
+ * variables to live in SRAM
+ */
+static unsigned int g_current_bus __attribute__((section(".data")));
+static struct s3c24x0_i2c_bus i2c_bus[CONFIG_MAX_I2C_NUM]
+                       __attribute__((section(".data")));
+static int i2c_busses __attribute__((section(".data")));
 
 #ifndef CONFIG_EXYNOS5
 static int GetI2CSDA(void)
@@ -507,4 +516,83 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
                (i2c, I2C_WRITE, chip << 1, &xaddr[4 - alen], alen, buffer,
                 len) != 0);
 }
+
+#ifdef CONFIG_OF_CONTROL
+void board_i2c_init(const void *blob)
+{
+
+       int node_list[CONFIG_MAX_I2C_NUM];
+       int count, i;
+
+       count = fdtdec_find_aliases_for_id(blob, "i2c",
+               COMPAT_SAMSUNG_S3C2440_I2C, node_list,
+               CONFIG_MAX_I2C_NUM);
+       for (i = 0; i < count; i++) {
+               struct s3c24x0_i2c_bus *bus;
+               int node = node_list[i];
+
+               if (node < 0)
+                       continue;
+               bus = &i2c_bus[i];
+               bus->regs = (struct s3c24x0_i2c *)
+                       fdtdec_get_addr(blob, node, "reg");
+               bus->id = (enum periph_id)
+                       fdtdec_get_int(blob, node, "samsung,periph-id", -1);
+               bus->node = node;
+               bus->bus_num = i2c_busses++;
+               exynos_pinmux_config(bus->id, 0);
+       }
+
+}
+
+static struct s3c24x0_i2c_bus *get_bus(unsigned int bus_idx)
+{
+       if (bus_idx < i2c_busses)
+               return &i2c_bus[bus_idx];
+       debug("Undefined bus: %d\n", bus_idx);
+       return NULL;
+}
+

drivers/i2c/s3c24x0_i2c.c int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len) · line 565

Quoted 10 lines
drivers/i2c/s3c24x0_i2c.c +10 -0
+int i2c_get_bus_num_fdt(const void *blob, int node)
+{
+       enum fdt_compat_id compat;
+       int i;
+
+       compat = fdtdec_lookup(blob, node);
+       if (compat != COMPAT_SAMSUNG_S3C2440_I2C) {
+               debug("%s: Not a supported I2C node\n", __func__);
+               return -1;
+       }

I think you can drop this check, since your code immediately below will handle a missing node.

Quoted 86 lines
drivers/i2c/s3c24x0_i2c.c +32 -0
+       for (i = 0; i < i2c_busses; i++) {
+               if (node == i2c_bus[i].node)
+                       return i;
+       }
+
+       debug("%s: Can't find any matched I2C bus\n", __func__);
+       return -1;
+}
+
+int i2c_reset_port_fdt(const void *blob, int node)
+{
+       struct s3c24x0_i2c_bus *i2c;
+
+       int bus;
+
+       bus = i2c_get_bus_num_fdt(blob, node);
+       if (bus < 0) {
+               debug("could not get bus for node %d\n", node);
+               return -1;
+       }
+       i2c = get_bus(bus);
+       if (!i2c) {
+               debug("get_bus() failed for node node %d\n", node);
+               return -1;
+       }
+
+       i2c_ch_init(i2c->regs, CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+
+       return 0;
+}
+#endif
+
 #endif /* CONFIG_HARD_I2C */
drivers/i2c/s3c24x0_i2c.h +8 -0
index 2dd4b06..1243bf1 100644
@@ -30,4 +30,12 @@ struct s3c24x0_i2c {
        u32     iicds;
        u32     iiclc;
 };
+
+struct s3c24x0_i2c_bus {
+       int node;       /* device tree node */
+       int bus_num;    /* i2c bus number */
+       struct s3c24x0_i2c *regs;
+       enum periph_id id;
+};
+
 #endif /* _S3C24X0_I2C_H */
include/i2c.h +26 -1
index 16f099d..efb097f 100644
@@ -262,4 +262,30 @@ extern int get_multi_scl_pin(void);
 extern int get_multi_sda_pin(void);
 extern int multi_i2c_init(void);
 #endif
+
+/**
+ * Get FDT values for i2c bus.
+ *
+ * @param blob  Device tree blbo
+ * @return the number of I2C bus
+ */
+void board_i2c_init(const void *blob);
+
+/**
+ * Find the I2C bus number by given a FDT I2C node.
+ *
+ * @param blob  Device tree blbo
+ * @param node  FDT I2C node to find
+ * @return the number of I2C bus (zero based), or -1 on error
+ */
+int i2c_get_bus_num_fdt(const void *blob, int node);
+
+/**
+ * Reset the I2C bus represented by the given a FDT I2C node.
+ *
+ * @param blob  Device tree blbo
+ * @param node  FDT I2C node to find
+ * @return 0 if port was reset, -1 if not found
+ */
+int i2c_reset_port_fdt(const void *blob, int node);
 #endif /* _I2C_H_ */
--
Quoted 2 lines

1.7.4.4

Regards,
Simon

#16 lore raw

PATCH v2 5/6 I2C: Driver changes for FDT support

In reply to Rajeshwari Shinde

Hello Rajeshwari,

Quoted 10 lines · Rajeshwari Shinde

Functions added to get the I2C bus number and reset I2C bus using FDT node.

---
Changes in V2:
- Added periph id to I2C bus structure.
- Modified i2c_get_bus_num_fdt function to compare with node.
- Board i2c init moved to driver in case of FDT.

Quoted 4 lines
  drivers/i2c/s3c24x0_i2c.c |   90 ++++++++++++++++++++++++++++++++++++++++++++-
  drivers/i2c/s3c24x0_i2c.h |    8 ++++
  include/i2c.h             |   26 +++++++++++++
  3 files changed, 123 insertions(+), 1 deletions(-)

patch looks good, just some nitpicking comments ...

Quoted 4 lines
drivers/i2c/s3c24x0_i2c.c +0 -0
index 9bc4c7f..840585d 100644

[...]

Quoted 12 lines
drivers/i2c/s3c24x0_i2c.c +8 -0
@@ -507,4 +516,83 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
  		(i2c, I2C_WRITE, chip<<  1,&xaddr[4 - alen], alen, buffer,
  		 len) != 0);
  }
+
+#ifdef CONFIG_OF_CONTROL
+void board_i2c_init(const void *blob)
+{
+
+	int node_list[CONFIG_MAX_I2C_NUM];
+	int count, i;
+

drivers/i2c/s3c24x0_i2c.c int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len) · line 536

Quoted 10 lines
drivers/i2c/s3c24x0_i2c.c +10 -0
+	count = fdtdec_find_aliases_for_id(blob, "i2c",
+		COMPAT_SAMSUNG_S3C2440_I2C, node_list,
+		CONFIG_MAX_I2C_NUM);
+	for (i = 0; i<  count; i++) {
+		struct s3c24x0_i2c_bus *bus;
+		int node = node_list[i];
+
+		if (node<  0)
+			continue;
+		bus =&i2c_bus[i];
                      ^
                      space please
Quoted 4 lines
drivers/i2c/s3c24x0_i2c.c +4 -0
+		bus->regs = (struct s3c24x0_i2c *)
+			fdtdec_get_addr(blob, node, "reg");
+		bus->id = (enum periph_id)
+			fdtdec_get_int(blob, node, "samsung,periph-id", -1);

drivers/i2c/s3c24x0_i2c.c int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)

Quoted 10 lines
drivers/i2c/s3c24x0_i2c.c +10 -0
+		bus->node = node;
+		bus->bus_num = i2c_busses++;
+		exynos_pinmux_config(bus->id, 0);
+	}
+
+}
+
+static struct s3c24x0_i2c_bus *get_bus(unsigned int bus_idx)
+{
+	if (bus_idx<  i2c_busses)
                    ^
                    space please

drivers/i2c/s3c24x0_i2c.c int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len) · line 551

Quoted 1 line
drivers/i2c/s3c24x0_i2c.c +1 -0
+		return&i2c_bus[bus_idx];
                       ^
                       space please
Quoted 21 lines
drivers/i2c/s3c24x0_i2c.c +21 -0
+	debug("Undefined bus: %d\n", bus_idx);
+	return NULL;
+}
+
+int i2c_get_bus_num_fdt(const void *blob, int node)
+{
+	enum fdt_compat_id compat;
+	int i;
+
+	compat = fdtdec_lookup(blob, node);
+	if (compat != COMPAT_SAMSUNG_S3C2440_I2C) {
+		debug("%s: Not a supported I2C node\n", __func__);
+		return -1;
+	}
+	for (i = 0; i<  i2c_busses; i++) {
+		if (node == i2c_bus[i].node)
+			return i;
+	}
+
+	debug("%s: Can't find any matched I2C bus\n", __func__);
+	return -1;

drivers/i2c/s3c24x0_i2c.c int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)

Quoted 10 lines
drivers/i2c/s3c24x0_i2c.c +10 -0
+}
+
+int i2c_reset_port_fdt(const void *blob, int node)
+{
+	struct s3c24x0_i2c_bus *i2c;
+
+	int bus;
+
+	bus = i2c_get_bus_num_fdt(blob, node);
+	if (bus<  0) {
                ^
                space
Quoted 38 lines
drivers/i2c/s3c24x0_i2c.c +15 -0
+		debug("could not get bus for node %d\n", node);
+		return -1;
+	}
+	i2c = get_bus(bus);
+	if (!i2c) {
+		debug("get_bus() failed for node node %d\n", node);
+		return -1;
+	}
+
+	i2c_ch_init(i2c->regs, CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+
+	return 0;
+}
+#endif
+
  #endif /* CONFIG_HARD_I2C */
drivers/i2c/s3c24x0_i2c.h +8 -0
index 2dd4b06..1243bf1 100644
@@ -30,4 +30,12 @@ struct s3c24x0_i2c {
  	u32	iicds;
  	u32	iiclc;
  };
+
+struct s3c24x0_i2c_bus {
+	int node;	/* device tree node */
+	int bus_num;	/* i2c bus number */
+	struct s3c24x0_i2c *regs;
+	enum periph_id id;
+};
+
  #endif /* _S3C24X0_I2C_H */
include/i2c.h +0 -0
index 16f099d..efb097f 100644

include/i2c.h extern int get_multi_scl_pin(void); · line 269

Quoted 8 lines
include/i2c.h +5 -0
@@ -262,4 +262,30 @@ extern int get_multi_scl_pin(void);
  extern int get_multi_sda_pin(void);
  extern int multi_i2c_init(void);
  #endif
+
+/**
+ * Get FDT values for i2c bus.
+ *
+ * @param blob  Device tree blbo
                                ^
                                blob

include/i2c.h extern int get_multi_scl_pin(void); · line 277

Quoted 8 lines
include/i2c.h +8 -0
+ * @return the number of I2C bus
+ */
+void board_i2c_init(const void *blob);
+
+/**
+ * Find the I2C bus number by given a FDT I2C node.
+ *
+ * @param blob  Device tree blbo
                                ^
                                blob
Quoted 4 lines
include/i2c.h +4 -0
+ * @param node  FDT I2C node to find
+ * @return the number of I2C bus (zero based), or -1 on error
+ */
+int i2c_get_bus_num_fdt(const void *blob, int node);

include/i2c.h extern int get_multi_scl_pin(void); · line 291

Quoted 10 lines
include/i2c.h +9 -0
+
+/**
+ * Reset the I2C bus represented by the given a FDT I2C node.
+ *
+ * @param blob  Device tree blbo
+ * @param node  FDT I2C node to find
+ * @return 0 if port was reset, -1 if not found
+ */
+int i2c_reset_port_fdt(const void *blob, int node);
  #endif	/* _I2C_H_ */

Thanks!

bye,
Heiko

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

PATCH v2 5/6 I2C: Driver changes for FDT support

Hi Heiko,

Thank you for the comments will modify the same and resend the patch.

Regards,
Rajeshwari Shinde.

Quoted 212 lines · Heiko Schocher

Hello Rajeshwari,

Quoted 11 lines · Rajeshwari Shinde

Functions added to get the I2C bus number and reset I2C bus using FDT node.

---
Changes in V2:
- Added periph id to I2C bus structure.
- Modified i2c_get_bus_num_fdt function to compare with node.
- Board i2c init moved to driver in case of FDT.

Quoted 5 lines
  drivers/i2c/s3c24x0_i2c.c |   90
++++++++++++++++++++++++++++++++++++++++++++-
  drivers/i2c/s3c24x0_i2c.h |    8 ++++
  include/i2c.h             |   26 +++++++++++++
  3 files changed, 123 insertions(+), 1 deletions(-)

patch looks good, just some nitpicking comments ...

Quoted 4 lines
drivers/i2c/s3c24x0_i2c.c +0 -0
index 9bc4c7f..840585d 100644

[...]

Quoted 15 lines
drivers/i2c/s3c24x0_i2c.c +8 -0
@@ -507,4 +516,83 @@ int i2c_write(uchar chip, uint addr, int alen, uchar
 *buffer, int len)
                (i2c, I2C_WRITE, chip<<  1,&xaddr[4 - alen], alen, buffer,
 
                 len) != 0);
  }
+
+#ifdef CONFIG_OF_CONTROL
+void board_i2c_init(const void *blob)
+{
+
+       int node_list[CONFIG_MAX_I2C_NUM];
+       int count, i;
+

drivers/i2c/s3c24x0_i2c.c int i2c_write(uchar chip, uint addr, int alen, uchar

Quoted 10 lines
drivers/i2c/s3c24x0_i2c.c +10 -0
+       count = fdtdec_find_aliases_for_id(blob, "i2c",
+               COMPAT_SAMSUNG_S3C2440_I2C, node_list,
+               CONFIG_MAX_I2C_NUM);
+       for (i = 0; i<  count; i++) {
+               struct s3c24x0_i2c_bus *bus;
+               int node = node_list[i];
+
+               if (node<  0)
+                       continue;
+               bus =&i2c_bus[i];
                     ^
                     space please
Quoted 5 lines
drivers/i2c/s3c24x0_i2c.c +4 -1
+               bus->regs = (struct s3c24x0_i2c *)
+                       fdtdec_get_addr(blob, node, "reg");
+               bus->id = (enum periph_id)
+                       fdtdec_get_int(blob, node, "samsung,periph-id",
-1);

drivers/i2c/s3c24x0_i2c.c int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)

Quoted 10 lines
drivers/i2c/s3c24x0_i2c.c +10 -0
+               bus->node = node;
+               bus->bus_num = i2c_busses++;
+               exynos_pinmux_config(bus->id, 0);
+       }
+
+}
+
+static struct s3c24x0_i2c_bus *get_bus(unsigned int bus_idx)
+{
+       if (bus_idx<  i2c_busses)
                   ^
                   space please
Quoted 2 lines

+ return&i2c_bus[bus_idx];

                      ^
                      space please
Quoted 21 lines
drivers/i2c/s3c24x0_i2c.c +21 -0
+       debug("Undefined bus: %d\n", bus_idx);
+       return NULL;
+}
+
+int i2c_get_bus_num_fdt(const void *blob, int node)
+{
+       enum fdt_compat_id compat;
+       int i;
+
+       compat = fdtdec_lookup(blob, node);
+       if (compat != COMPAT_SAMSUNG_S3C2440_I2C) {
+               debug("%s: Not a supported I2C node\n", __func__);
+               return -1;
+       }
+       for (i = 0; i<  i2c_busses; i++) {
+               if (node == i2c_bus[i].node)
+                       return i;
+       }
+
+       debug("%s: Can't find any matched I2C bus\n", __func__);
+       return -1;

drivers/i2c/s3c24x0_i2c.c int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)

Quoted 10 lines
drivers/i2c/s3c24x0_i2c.c +10 -0
+}
+
+int i2c_reset_port_fdt(const void *blob, int node)
+{
+       struct s3c24x0_i2c_bus *i2c;
+
+       int bus;
+
+       bus = i2c_get_bus_num_fdt(blob, node);
+       if (bus<  0) {
               ^
               space
Quoted 39 lines
drivers/i2c/s3c24x0_i2c.c +10 -0
+               debug("could not get bus for node %d\n", node);
+               return -1;
+       }
+       i2c = get_bus(bus);
+       if (!i2c) {
+               debug("get_bus() failed for node node %d\n", node);
+               return -1;
+       }
+
+       i2c_ch_init(i2c->regs, CONFIG_SYS_I2C_SPEED,

CONFIG_SYS_I2C_SLAVE);

drivers/i2c/s3c24x0_i2c.c +5 -0
+
+       return 0;
+}
+#endif
+
  #endif /* CONFIG_HARD_I2C */
drivers/i2c/s3c24x0_i2c.h +8 -0
index 2dd4b06..1243bf1 100644
@@ -30,4 +30,12 @@ struct s3c24x0_i2c {
        u32     iicds;
        u32     iiclc;
  };
+
+struct s3c24x0_i2c_bus {
+       int node;       /* device tree node */
+       int bus_num;    /* i2c bus number */
+       struct s3c24x0_i2c *regs;
+       enum periph_id id;
+};
+
  #endif /* _S3C24X0_I2C_H */
include/i2c.h +0 -0
index 16f099d..efb097f 100644

include/i2c.h extern int get_multi_scl_pin(void); · line 269

Quoted 8 lines
include/i2c.h +5 -0
@@ -262,4 +262,30 @@ extern int get_multi_scl_pin(void);
  extern int get_multi_sda_pin(void);
  extern int multi_i2c_init(void);
  #endif
+
+/**
+ * Get FDT values for i2c bus.
+ *
+ * @param blob  Device tree blbo
                               ^
                               blob

include/i2c.h extern int get_multi_scl_pin(void); · line 277

Quoted 8 lines
include/i2c.h +8 -0
+ * @return the number of I2C bus
+ */
+void board_i2c_init(const void *blob);
+
+/**
+ * Find the I2C bus number by given a FDT I2C node.
+ *
+ * @param blob  Device tree blbo
                               ^
                               blob
Quoted 4 lines
include/i2c.h +4 -0
+ * @param node  FDT I2C node to find
+ * @return the number of I2C bus (zero based), or -1 on error
+ */
+int i2c_get_bus_num_fdt(const void *blob, int node);

include/i2c.h extern int get_multi_scl_pin(void); · line 291

Quoted 10 lines
include/i2c.h +9 -0
+
+/**
+ * Reset the I2C bus represented by the given a FDT I2C node.
+ *
+ * @param blob  Device tree blbo
+ * @param node  FDT I2C node to find
+ * @return 0 if port was reset, -1 if not found
+ */
+int i2c_reset_port_fdt(const void *blob, int node);
  #endif        /* _I2C_H_ */

Thanks!

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

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#18 lore raw

PATCH v2 5/6 I2C: Driver changes for FDT support

In reply to Rajeshwari Shinde

Hello Rajeshwari,

On 14.11.2012 10:11, Rajeshwari Shinde:wrote

Quoted 10 lines

Functions added to get the I2C bus number and reset I2C bus using FDT node.

---
Changes in V2:
- Added periph id to I2C bus structure.
- Modified i2c_get_bus_num_fdt function to compare with node.
- Board i2c init moved to driver in case of FDT.

Quoted 4 lines
  drivers/i2c/s3c24x0_i2c.c |   90 ++++++++++++++++++++++++++++++++++++++++++++-
  drivers/i2c/s3c24x0_i2c.h |    8 ++++
  include/i2c.h             |   26 +++++++++++++
  3 files changed, 123 insertions(+), 1 deletions(-)

bye,
Heiko

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

PATCH v2 6/6 SMDK5250: Initialise I2C using FDT

In reply to Rajeshwari Shinde

This patch initialises I2C using FDT.

---
Changes since V2:
- board_i2c_init moved to driver in case of FDT.

 board/samsung/smdk5250/smdk5250.c |   20 +-------------------
 1 files changed, 1 insertions(+), 19 deletions(-)
board/samsung/smdk5250/smdk5250.c +1 -19
index db2457b..5ebc665 100644
@@ -272,24 +272,6 @@ static int board_uart_init(void)
 	return 0;
 }
 
-#ifdef CONFIG_SYS_I2C_INIT_BOARD
-static int board_i2c_init(void)
-{
-	int i, err;
-
-	for (i = 0; i < CONFIG_MAX_I2C_NUM; i++) {
-		err = exynos_pinmux_config((PERIPH_ID_I2C0 + i),
-						PINMUX_FLAG_NONE);
-		if (err) {
-			debug("I2C%d not configured\n", (PERIPH_ID_I2C0 + i));
-			return err;
-		}
-	}
-	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
-	return 0;
-}
-#endif
-
 #ifdef CONFIG_BOARD_EARLY_INIT_F
 int board_early_init_f(void)
 {
@@ -300,7 +282,7 @@ int board_early_init_f(void)
 		return err;
 	}
 #ifdef CONFIG_SYS_I2C_INIT_BOARD
-	err = board_i2c_init();
+	board_i2c_init(gd->fdt_blob);
 #endif
 	return err;
 }
Signature · 1 line
1.7.4.4
#20 lore raw

PATCH v2 6/6 SMDK5250: Initialise I2C using FDT

Quoted 3 lines · Rajeshwari Shinde

This patch initialises I2C using FDT.

Quoted 47 lines

---
Changes since V2:
- board_i2c_init moved to driver in case of FDT.

 board/samsung/smdk5250/smdk5250.c |   20 +-------------------
 1 files changed, 1 insertions(+), 19 deletions(-)
board/samsung/smdk5250/smdk5250.c +1 -20
index db2457b..5ebc665 100644
@@ -272,24 +272,6 @@ static int board_uart_init(void)
        return 0;
 }
 
-#ifdef CONFIG_SYS_I2C_INIT_BOARD
-static int board_i2c_init(void)
-{
-       int i, err;
-
-       for (i = 0; i < CONFIG_MAX_I2C_NUM; i++) {
-               err = exynos_pinmux_config((PERIPH_ID_I2C0 + i),
-                                               PINMUX_FLAG_NONE);
-               if (err) {
-                       debug("I2C%d not configured\n", (PERIPH_ID_I2C0 + i));
-                       return err;
-               }
-       }
-       i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
-       return 0;
-}
-#endif
-
 #ifdef CONFIG_BOARD_EARLY_INIT_F
 int board_early_init_f(void)
 {
@@ -300,7 +282,7 @@ int board_early_init_f(void)
                return err;
        }
 #ifdef CONFIG_SYS_I2C_INIT_BOARD
-       err = board_i2c_init();
+       board_i2c_init(gd->fdt_blob);
 #endif
        return err;
 }
--

1.7.4.4

#21 lore raw

PATCH v2 6/6 SMDK5250: Initialise I2C using FDT

In reply to Rajeshwari Shinde

Hello Rajeshwari,

Quoted 8 lines · Rajeshwari Shinde

This patch initialises I2C using FDT.

---
Changes since V2:
- board_i2c_init moved to driver in case of FDT.

  board/samsung/smdk5250/smdk5250.c |   20 +-------------------
  1 files changed, 1 insertions(+), 19 deletions(-)

bye,
Heiko

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

v2 cover EXYNOS5: FDT Support for I2C

In reply to Rajeshwari Shinde

Hi Rajeshwari,

Quoted 9 lines · Rajeshwari Shinde

This patch set adds FDT support for I2C driver and API's to acess the bus number using the fdt node and also reset the port.

Changes in V2:
- Baord i2c init moved to I2C driver in case of FDT.
- Added Periph id to device node.
- Modified i2c_get_bus_num_fdt api to compare using node.

Looks good. I pointed out a minor issue in the driver patch.

Quoted 20 lines

Rajeshwari Shinde (6):
EXYNOS5: FDT: Add I2C device node data
EXYNOS5 : FDT: Add Aliases for I2C device
EXYNOS5: FDT: Add compatible string for I2C
FDT: Api to find compatible id for a given node
I2C: Driver changes for FDT support
SMDK5250: Initialise I2C using FDT

 arch/arm/dts/exynos-periph-id.dtsi        |   35 +++++++++++
 arch/arm/dts/exynos5250.dtsi              |   73 +++++++++++++++++++++++
 board/samsung/dts/exynos5250-smdk5250.dts |   11 ++++
 board/samsung/smdk5250/smdk5250.c         |   20 +------
 drivers/i2c/s3c24x0_i2c.c                 |   90 ++++++++++++++++++++++++++++-
 drivers/i2c/s3c24x0_i2c.h                 |    8 +++
 include/fdtdec.h                          |   15 +++++
 include/i2c.h                             |   26 ++++++++
 lib/fdtdec.c                              |   13 ++++
 9 files changed, 271 insertions(+), 20 deletions(-)
 create mode 100644 arch/arm/dts/exynos-periph-id.dtsi
Quoted 3 lines

--
1.7.4.4

Regards,
Simon